firebase 9.6.2 → 9.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/app/dist/index.cjs.js +1 -1
- package/app/dist/index.esm.js +1 -1
- package/app/dist/index.mjs +1 -1
- package/compat/app/dist/index.cjs.js +1 -1
- package/compat/app/dist/index.esm.js +1 -1
- package/compat/app/dist/index.mjs +1 -1
- package/compat/dist/index.esm.js +2 -2
- package/compat/dist/index.node.cjs +2 -2
- package/compat/dist/index.rn.cjs.js +2 -2
- package/firebase-analytics-compat.js.map +1 -1
- package/firebase-analytics.js +3 -3
- package/firebase-analytics.js.map +1 -1
- package/firebase-app-check-compat.js.map +1 -1
- package/firebase-app-check.js +4 -4
- package/firebase-app-check.js.map +1 -1
- package/firebase-app-compat.js +2 -2
- package/firebase-app-compat.js.map +1 -1
- package/firebase-app.js +9 -9
- package/firebase-app.js.map +1 -1
- package/firebase-auth-compat.js.map +1 -1
- package/firebase-auth.js +4 -4
- package/firebase-auth.js.map +1 -1
- package/firebase-compat.js +3 -3
- package/firebase-compat.js.map +1 -1
- package/firebase-database.js +4 -4
- package/firebase-firestore-compat.js +1 -1
- package/firebase-firestore-compat.js.map +1 -1
- package/firebase-firestore-lite.js +1141 -1141
- package/firebase-firestore-lite.js.map +1 -1
- package/firebase-firestore.js +874 -874
- package/firebase-firestore.js.map +1 -1
- package/firebase-functions-compat.js.map +1 -1
- package/firebase-functions.js +2 -2
- package/firebase-functions.js.map +1 -1
- package/firebase-messaging-compat.js +1 -1
- package/firebase-messaging-compat.js.map +1 -1
- package/firebase-messaging-sw.js +4 -4
- package/firebase-messaging-sw.js.map +1 -1
- package/firebase-messaging.js +3 -3
- package/firebase-messaging.js.map +1 -1
- package/firebase-performance-compat.js.map +1 -1
- package/firebase-performance-standalone-compat.es2017.js +5 -5
- package/firebase-performance-standalone-compat.es2017.js.map +1 -1
- package/firebase-performance-standalone-compat.js +1 -1
- package/firebase-performance-standalone-compat.js.map +1 -1
- package/firebase-performance.js +3 -3
- package/firebase-performance.js.map +1 -1
- package/firebase-remote-config-compat.js.map +1 -1
- package/firebase-remote-config.js +2 -2
- package/firebase-remote-config.js.map +1 -1
- package/firebase-storage-compat.js.map +1 -1
- package/firebase-storage.js +1 -1
- package/firebase-storage.js.map +1 -1
- package/package.json +7 -7
package/firebase-compat.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).firebase=t()}(this,function(){"use strict";!function(e){var t,n,o,r,i,s,a,c,l,u;function h(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function d(e){return e="string"!=typeof e?String(e):e}function p(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function f(t){this.map={},t instanceof f?t.forEach(function(e,t){this.append(t,e)},this):Array.isArray(t)?t.forEach(function(e){this.append(e[0],e[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function g(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function m(n){return new Promise(function(e,t){n.onload=function(){e(n.result)},n.onerror=function(){t(n.error)}})}function v(e){var t=new FileReader,n=m(t);return t.readAsArrayBuffer(e),n}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function _(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e)if("string"==typeof e)this._bodyText=e;else if(o&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(r&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(i&&o&&a(e))this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!i||!ArrayBuffer.prototype.isPrototypeOf(e)&&!c(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=y(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var e=g(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?g(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var e,t,n=g(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=m(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}function w(e,t){var n,r=(t=t||{}).body;if(e instanceof w){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new f(e.headers)),this.method=e.method,this.mode=e.mode,r||null==e._bodyInit||(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"omit",!t.headers&&this.headers||(this.headers=new f(t.headers)),this.method=(e=t.method||this.method||"GET",n=e.toUpperCase(),-1<l.indexOf(n)?n:e),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function b(e){var r=new FormData;return e.trim().split("&").forEach(function(e){var t,n;e&&(t=(n=e.split("=")).shift().replace(/\+/g," "),n=n.join("=").replace(/\+/g," "),r.append(decodeURIComponent(t),decodeURIComponent(n)))}),r}function T(e,t){t=t||{},this.type="default",this.status=void 0===t.status?200:t.status,this.ok=200<=this.status&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}e.fetch||(t="URLSearchParams"in e,n="Symbol"in e&&"iterator"in Symbol,o="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),r="FormData"in e,(i="ArrayBuffer"in e)&&(s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=function(e){return e&&DataView.prototype.isPrototypeOf(e)},c=ArrayBuffer.isView||function(e){return e&&-1<s.indexOf(Object.prototype.toString.call(e))}),f.prototype.append=function(e,t){e=h(e),t=d(t);var n=this.map[e];this.map[e]=n?n+","+t:t},f.prototype.delete=function(e){delete this.map[h(e)]},f.prototype.get=function(e){return e=h(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(h(e))},f.prototype.set=function(e,t){this.map[h(e)]=d(t)},f.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},f.prototype.keys=function(){var n=[];return this.forEach(function(e,t){n.push(t)}),p(n)},f.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),p(t)},f.prototype.entries=function(){var n=[];return this.forEach(function(e,t){n.push([t,e])}),p(n)},n&&(f.prototype[Symbol.iterator]=f.prototype.entries),l=["DELETE","GET","HEAD","OPTIONS","POST","PUT"],w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},_.call(w.prototype),_.call(T.prototype),T.prototype.clone=function(){return new T(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},T.error=function(){var e=new T(null,{status:0,statusText:""});return e.type="error",e},u=[301,302,303,307,308],T.redirect=function(e,t){if(-1===u.indexOf(t))throw new RangeError("Invalid status code");return new T(null,{status:t,headers:{location:e}})},e.Headers=f,e.Request=w,e.Response=T,e.fetch=function(n,r){return new Promise(function(i,e){var t=new w(n,r),s=new XMLHttpRequest;s.onload=function(){var e,r,t={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",r=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var t=e.split(":"),n=t.shift().trim();n&&(t=t.join(":").trim(),r.append(n,t))}),r)};t.url="responseURL"in s?s.responseURL:t.headers.get("X-Request-URL");var n="response"in s?s.response:s.responseText;i(new T(n,t))},s.onerror=function(){e(new TypeError("Network request failed"))},s.ontimeout=function(){e(new TypeError("Network request failed"))},s.open(t.method,t.url,!0),"include"===t.credentials?s.withCredentials=!0:"omit"===t.credentials&&(s.withCredentials=!1),"responseType"in s&&o&&(s.responseType="blob"),t.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),s.send(void 0===t._bodyInit?null:t._bodyInit)})},e.fetch.polyfill=!0)}("undefined"!=typeof self?self:void 0);function e(e){try{return!!e()}catch(e){return!0}}function t(e){if(!g(e))throw TypeError(String(e)+" is not an object");return e}var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r=function(e){return e&&e.Math==Math&&e},i=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof n&&n)||Function("return this")(),s={exports:{}},o=!e(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),a={},c=function(e){return"object"==typeof e?null!==e:"function"==typeof e},l=c,u=i.document,h=l(u)&&l(u.createElement),d=function(e){return h?u.createElement(e):{}},p=d,f=!o&&!e(function(){return 7!=Object.defineProperty(p("div"),"a",{get:function(){return 7}}).a}),g=c,m=c,v=function(e,t){if(!m(e))return e;var n,r;if(t&&"function"==typeof(n=e.toString)&&!m(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!m(r=n.call(e)))return r;if(!t&&"function"==typeof(n=e.toString)&&!m(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")},y=f,_=t,w=v,b=Object.defineProperty;a.f=o?b:function(e,t,n){if(_(e),t=w(t,!0),_(n),y)try{return b(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var T=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},I=a,E=T,k=o?function(e,t,n){return I.f(e,t,E(1,n))}:function(e,t,n){return e[t]=n,e},S=i,C=k,A=function(t,n){try{C(S,t,n)}catch(e){S[t]=n}return n},N=A,R="__core-js_shared__",P=i[R]||N(R,{}),x=P;(s.exports=function(e,t){return x[e]||(x[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"});function D(e,t){return M.call(e,t)}function O(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++L+F).toString(36)}var M={}.hasOwnProperty,L=0,F=Math.random(),U=e,j=!!Object.getOwnPropertySymbols&&!U(function(){return!String(Symbol())}),q=j&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,V=i,B=s.exports,W=D,K=O,$=j,z=q,H=B("wks"),G=V.Symbol,Q=z?G:G&&G.withoutSetter||K,Y=function(e){return W(H,e)||($&&W(G,e)?H[e]=G[e]:H[e]=Q("Symbol."+e)),H[e]},J={};J[Y("toStringTag")]="z";var X="[object z]"===String(J),Z={exports:{}},ee=P,te=Function.toString;"function"!=typeof ee.inspectSource&&(ee.inspectSource=function(e){return te.call(e)});var ne,re,ie,se,oe,ae,ce,le,ue=ee.inspectSource,he=ue,de=i.WeakMap,pe="function"==typeof de&&/native code/.test(he(de)),fe=s.exports,ge=O,me=fe("keys"),ve=function(e){return me[e]||(me[e]=ge(e))},ye={},_e=c,we=k,be=D,Te=ve,Ie=ye,Ee=i.WeakMap;ce=pe?(ne=new Ee,re=ne.get,ie=ne.has,se=ne.set,oe=function(e,t){return se.call(ne,e,t),t},ae=function(e){return re.call(ne,e)||{}},function(e){return ie.call(ne,e)}):(Ie[le=Te("state")]=!0,oe=function(e,t){return we(e,le,t),t},ae=function(e){return be(e,le)?e[le]:{}},function(e){return be(e,le)});var ke={set:oe,get:ae,has:ce,enforce:function(e){return ce(e)?ae(e):oe(e,{})},getterFor:function(n){return function(e){var t;if(!_e(e)||(t=ae(e)).type!==n)throw TypeError("Incompatible receiver, "+n+" required");return t}}},Se=i,Ce=k,Ae=D,Ne=A,Re=ue,Pe=ke.get,xe=ke.enforce,De=String(String).split("String");(Z.exports=function(e,t,n,r){var i=!!r&&!!r.unsafe,s=!!r&&!!r.enumerable,o=!!r&&!!r.noTargetGet;"function"==typeof n&&("string"!=typeof t||Ae(n,"name")||Ce(n,"name",t),xe(n).source=De.join("string"==typeof t?t:"")),e!==Se?(i?!o&&e[t]&&(s=!0):delete e[t],s?e[t]=n:Ce(e,t,n)):s?e[t]=n:Ne(t,n)})(Function.prototype,"toString",function(){return"function"==typeof this&&Pe(this).source||Re(this)});var Oe={}.toString,Me=function(e){return Oe.call(e).slice(8,-1)},Le=X,Fe=Me,Ue=Y("toStringTag"),je="Arguments"==Fe(function(){return arguments}()),qe=Le?Fe:function(e){var t,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),Ue))?n:je?Fe(t):"Object"==(n=Fe(t))&&"function"==typeof t.callee?"Arguments":n},Ve=qe,Be=Z.exports;X||Be(Object.prototype,"toString",X?{}.toString:function(){return"[object "+Ve(this)+"]"},{unsafe:!0});var We=Math.ceil,Ke=Math.floor,$e=function(e){return isNaN(e=+e)?0:(0<e?Ke:We)(e)},ze=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},He=$e,Ge=ze,Qe=function(a){return function(e,t){var n,r,i=String(Ge(e)),s=He(t),o=i.length;return s<0||o<=s?a?"":void 0:(n=i.charCodeAt(s))<55296||56319<n||s+1===o||(r=i.charCodeAt(s+1))<56320||57343<r?a?i.charAt(s):n:a?i.slice(s,s+2):r-56320+(n-55296<<10)+65536}},Ye={codeAt:Qe(!1),charAt:Qe(!0)},Je={},Xe={},Ze={}.propertyIsEnumerable,et=Object.getOwnPropertyDescriptor,tt=et&&!Ze.call({1:2},1);Xe.f=tt?function(e){var t=et(this,e);return!!t&&t.enumerable}:Ze;function nt(e){return at(ct(e))}var rt=e,it=Me,st="".split,ot=rt(function(){return!Object("z").propertyIsEnumerable(0)})?function(e){return"String"==it(e)?st.call(e,""):Object(e)}:Object,at=ot,ct=ze,lt=Xe,ut=T,ht=nt,dt=v,pt=D,ft=f,gt=Object.getOwnPropertyDescriptor;Je.f=o?gt:function(e,t){if(e=ht(e),t=dt(t,!0),ft)try{return gt(e,t)}catch(e){}if(pt(e,t))return ut(!lt.f.call(e,t),e[t])};function mt(e){return"function"==typeof e?e:void 0}function vt(e,t){return arguments.length<2?mt(_t[e])||mt(wt[e]):_t[e]&&_t[e][t]||wt[e]&&wt[e][t]}var yt=i,_t=yt,wt=i,bt={},Tt=$e,It=Math.min,Et=function(e){return 0<e?It(Tt(e),9007199254740991):0},kt=$e,St=Math.max,Ct=Math.min,At=nt,Nt=Et,Rt=function(e,t){var n=kt(e);return n<0?St(n+t,0):Ct(n,t)},Pt=function(a){return function(e,t,n){var r,i=At(e),s=Nt(i.length),o=Rt(n,s);if(a&&t!=t){for(;o<s;)if((r=i[o++])!=r)return!0}else for(;o<s;o++)if((a||o in i)&&i[o]===t)return a||o||0;return!a&&-1}},r={includes:Pt(!0),indexOf:Pt(!1)},xt=D,Dt=nt,Ot=r.indexOf,Mt=ye,n=function(e,t){var n,r=Dt(e),i=0,s=[];for(n in r)!xt(Mt,n)&&xt(r,n)&&s.push(n);for(;t.length>i;)xt(r,n=t[i++])&&(~Ot(s,n)||s.push(n));return s},l=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Lt=n,Ft=l.concat("length","prototype");bt.f=Object.getOwnPropertyNames||function(e){return Lt(e,Ft)};N={};N.f=Object.getOwnPropertySymbols;var Ut=bt,jt=N,qt=t,R=vt("Reflect","ownKeys")||function(e){var t=Ut.f(qt(e)),n=jt.f;return n?t.concat(n(e)):t},Vt=D,Bt=R,Wt=Je,Kt=a,U=function(e,t){for(var n=Bt(t),r=Kt.f,i=Wt.f,s=0;s<n.length;s++){var o=n[s];Vt(e,o)||r(e,o,i(t,o))}},$t=e,zt=/#|\.prototype\./,B=function(e,t){var n=Gt[Ht(e)];return n==Yt||n!=Qt&&("function"==typeof t?$t(t):!!t)},Ht=B.normalize=function(e){return String(e).replace(zt,".").toLowerCase()},Gt=B.data={},Qt=B.NATIVE="N",Yt=B.POLYFILL="P",V=B,Jt=i,Xt=Je.f,Zt=k,en=Z.exports,tn=A,nn=U,rn=V,z=function(e,t){var n,r,i,s=e.target,o=e.global,a=e.stat,c=o?Jt:a?Jt[s]||tn(s,{}):(Jt[s]||{}).prototype;if(c)for(n in t){if(r=t[n],i=e.noTargetGet?(i=Xt(c,n))&&i.value:c[n],!rn(o?n:s+(a?".":"#")+n,e.forced)&&void 0!==i){if(typeof r==typeof i)continue;nn(r,i)}(e.sham||i&&i.sham)&&Zt(r,"sham",!0),en(c,n,r,e)}},sn=ze,K=function(e){return Object(sn(e))},J=!e(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),on=D,an=K,P=J,cn=ve("IE_PROTO"),ln=Object.prototype,ee=P?Object.getPrototypeOf:function(e){return e=an(e),on(e,cn)?e[cn]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?ln:null},he=ee,de=k,fe=D,pe=Y("iterator"),Ee=!1;[].keys&&("next"in(or=[].keys())?(ar=he(he(or)))!==Object.prototype&&(Er=ar):Ee=!0),fe(Er=null==Er?{}:Er,pe)||de(Er,pe,function(){return this});function un(){}var hn,Ie={IteratorPrototype:Er,BUGGY_SAFARI_ITERATORS:Ee},dn=n,pn=l,Te=Object.keys||function(e){return dn(e,pn)},fn=a,gn=t,mn=Te,Le=o?Object.defineProperties:function(e,t){gn(e);for(var n,r=mn(t),i=r.length,s=0;s<i;)fn.f(e,n=r[s++],t[n]);return e},Be=vt("document","documentElement"),vn=t,yn=Le,_n=l,X=ye,wn=Be,bn=d,Tn="prototype",In="script",En=ve("IE_PROTO"),kn=function(e){return"<"+In+">"+e+"</"+In+">"},Sn=function(){try{hn=document.domain&&new ActiveXObject("htmlfile")}catch(e){}var e,t;Sn=hn?function(e){e.write(kn("")),e.close();var t=e.parentWindow.Object;return e=null,t}(hn):(e=bn("iframe"),t="java"+In+":",e.style.display="none",wn.appendChild(e),e.src=String(t),(e=e.contentWindow.document).open(),e.write(kn("document.F=Object")),e.close(),e.F);for(var n=_n.length;n--;)delete Sn[Tn][_n[n]];return Sn()};X[En]=!0;function Cn(){return this}function An(){return this}var Qe=Object.create||function(e,t){var n;return null!==e?(un[Tn]=vn(e),n=new un,un[Tn]=null,n[En]=e):n=Sn(),void 0===t?n:yn(n,t)},Nn=a.f,Rn=D,Pn=Y("toStringTag"),tt=function(e,t,n){e&&!Rn(e=n?e:e.prototype,Pn)&&Nn(e,Pn,{configurable:!0,value:t})},Ze={},xn=Ie.IteratorPrototype,Dn=Qe,On=T,Mn=tt,Ln=Ze,Fn=c,Un=t,jn=function(e){if(!Fn(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype");return e},rt=Object.setPrototypeOf||("__proto__"in{}?function(){var n,r=!1,e={};try{(n=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(e,[]),r=e instanceof Array}catch(e){}return function(e,t){return Un(e),jn(t),r?n.call(e,t):e.__proto__=t,e}}():void 0),qn=z,Vn=function(e,t,n){var r=t+" Iterator";return e.prototype=Dn(xn,{next:On(1,n)}),Mn(e,r,!1),Ln[r]=Cn,e},Bn=ee,Wn=rt,Kn=tt,$n=k,zn=Z.exports,f=Y,Hn=Ze,Gn=Ie.IteratorPrototype,Qn=Ie.BUGGY_SAFARI_ITERATORS,Yn=f("iterator"),Jn="values",Xn="entries",Pt=function(e,t,n,r,i,s,o){Vn(n,t,r);function a(e){if(e===i&&f)return f;if(!Qn&&e in d)return d[e];switch(e){case"keys":case Jn:case Xn:return function(){return new n(this,e)}}return function(){return new n(this)}}var c,l,u=t+" Iterator",h=!1,d=e.prototype,p=d[Yn]||d["@@iterator"]||i&&d[i],f=!Qn&&p||a(i),g="Array"==t&&d.entries||p;if(g&&(g=Bn(g.call(new e)),Gn!==Object.prototype&&g.next&&(Bn(g)!==Gn&&(Wn?Wn(g,Gn):"function"!=typeof g[Yn]&&$n(g,Yn,An)),Kn(g,u,!0))),i==Jn&&p&&p.name!==Jn&&(h=!0,f=function(){return p.call(this)}),d[Yn]!==f&&$n(d,Yn,f),Hn[t]=f,i)if(c={values:a(Jn),keys:s?f:a("keys"),entries:a(Xn)},o)for(l in c)!Qn&&!h&&l in d||zn(d,l,c[l]);else qn({target:t,proto:!0,forced:Qn||h},c);return c},Zn=Ye.charAt,r=ke,R=Pt,er="String Iterator",tr=r.set,nr=r.getterFor(er);R(String,"String",function(e){tr(this,{type:er,string:String(e),index:0})},function(){var e=nr(this),t=e.string,n=e.index;return n>=t.length?{value:void 0,done:!0}:(n=Zn(t,n),e.index+=n.length,{value:n,done:!1})});var B=Qe,A=a,rr=Y("unscopables"),ir=Array.prototype;null==ir[rr]&&A.f(ir,rr,{configurable:!0,value:B(null)});var J=function(e){ir[rr][e]=!0},sr=nt,P=J,he=Ze,or=ke,ar=Pt,cr="Array Iterator",lr=or.set,ur=or.getterFor(cr),fe=ar(Array,"Array",function(e,t){lr(this,{type:cr,target:sr(e),index:0,kind:t})},function(){var e=ur(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?{value:e.target=void 0,done:!0}:"keys"==n?{value:r,done:!1}:"values"==n?{value:t[r],done:!1}:{value:[r,t[r]],done:!1}},"values");he.Arguments=he.Array,P("keys"),P("values"),P("entries");var hr,dr=i,pr={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},fr=fe,gr=k,de=Y,mr=de("iterator"),vr=de("toStringTag"),yr=fr.values;for(hr in pr){var _r=dr[hr],wr=_r&&_r.prototype;if(wr){if(wr[mr]!==yr)try{gr(wr,mr,yr)}catch(fb){wr[mr]=yr}if(wr[vr]||gr(wr,vr,hr),pr[hr])for(var br in fr)if(wr[br]!==fr[br])try{gr(wr,br,fr[br])}catch(fb){wr[br]=fr[br]}}}function Tr(e,t){this.stopped=e,this.result=t}var pe=i.Promise,Ir=Z.exports,Er=function(e,t,n){for(var r in t)Ir(e,r,t[r],n);return e},kr=vt,Sr=a,Cr=o,Ar=Y("species"),Ee=function(e){var t=kr(e),n=Sr.f;Cr&&t&&!t[Ar]&&n(t,Ar,{configurable:!0,get:function(){return this}})},n=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e},Le=function(e,t,n){if(!(e instanceof t))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return e},l={exports:{}},Nr=Ze,Rr=Y("iterator"),Pr=Array.prototype,X=function(e){return void 0!==e&&(Nr.Array===e||Pr[Rr]===e)},xr=n,Ie=function(r,i,e){if(xr(r),void 0===i)return r;switch(e){case 0:return function(){return r.call(i)};case 1:return function(e){return r.call(i,e)};case 2:return function(e,t){return r.call(i,e,t)};case 3:return function(e,t,n){return r.call(i,e,t,n)}}return function(){return r.apply(i,arguments)}},Dr=qe,Or=Ze,Mr=Y("iterator"),f=function(e){if(null!=e)return e[Mr]||e["@@iterator"]||Or[Dr(e)]},Lr=t,Ye=function(t,e,n,r){try{return r?e(Lr(n)[0],n[1]):e(n)}catch(e){var i=t.return;throw void 0!==i&&Lr(i.call(t)),e}},Fr=t,Ur=X,jr=Et,qr=Ie,Vr=f,Br=Ye;(l.exports=function(e,t,n,r,i){var s,o,a,c,l,u,h,d=qr(t,n,r?2:1);if(i)s=e;else{if("function"!=typeof(o=Vr(e)))throw TypeError("Target is not iterable");if(Ur(o)){for(a=0,c=jr(e.length);a<c;a++)if((l=r?d(Fr(h=e[a])[0],h[1]):d(e[a]))&&l instanceof Tr)return l;return new Tr(!1)}s=o.call(e)}for(u=s.next;!(h=u.call(s)).done;)if("object"==typeof(l=Br(s,d,h.value,r))&&l&&l instanceof Tr)return l;return new Tr(!1)}).stop=function(e){return new Tr(!0,e)};var Wr=Y("iterator"),Kr=!1;try{var $r=0,zr={next:function(){return{done:!!$r++}},return:function(){Kr=!0}};zr[Wr]=function(){return this},Array.from(zr,function(){throw 2})}catch(fb){}function Hr(e){return function(){ai(e)}}var Gr,r=function(e,t){if(!t&&!Kr)return!1;var n=!1;try{var r={};r[Wr]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(e){}return n},Qr=t,Yr=n,Jr=Y("species"),R=function(e,t){var n,r=Qr(e).constructor;return void 0===r||null==(n=Qr(r)[Jr])?t:Yr(n)},A=vt("navigator","userAgent")||"",B=/(iphone|ipod|ipad).*applewebkit/i.test(A),Xr=i,or=e,ar=Me,he=Ie,Zr=Be,ei=d,P=B,ti=Xr.location,de=Xr.setImmediate,Ze=Xr.clearImmediate,ni=Xr.process,zr=Xr.MessageChannel,ri=Xr.Dispatch,ii=0,si={},oi="onreadystatechange",ai=function(e){var t;si.hasOwnProperty(e)&&(t=si[e],delete si[e],t())},Be=function(e){ai(e.data)},d=function(e){Xr.postMessage(e+"",ti.protocol+"//"+ti.host)};de&&Ze||(de=function(e){for(var t=[],n=1;n<arguments.length;)t.push(arguments[n++]);return si[++ii]=function(){("function"==typeof e?e:Function(e)).apply(void 0,t)},Gr(ii),ii},Ze=function(e){delete si[e]},"process"==ar(ni)?Gr=function(e){ni.nextTick(Hr(e))}:ri&&ri.now?Gr=function(e){ri.now(Hr(e))}:zr&&!P?(wi=(yi=new zr).port2,yi.port1.onmessage=Be,Gr=he(wi.postMessage,wi,1)):!Xr.addEventListener||"function"!=typeof postMessage||Xr.importScripts||or(d)||"file:"===ti.protocol?Gr=oi in ei("script")?function(e){Zr.appendChild(ei("script"))[oi]=function(){Zr.removeChild(this),ai(e)}}:function(e){setTimeout(Hr(e),0)}:(Gr=d,Xr.addEventListener("message",Be,!1)));var ci,li,ui,hi,di,pi,fi,gi,ar={set:de,clear:Ze},mi=i,P=Je.f,zr=Me,vi=ar.set,yi=B,he=mi.MutationObserver||mi.WebKitMutationObserver,_i=mi.process,wi=mi.Promise,bi="process"==zr(_i),or=P(mi,"queueMicrotask"),d=or&&or.value;d||(ci=function(){var e,t;for(bi&&(e=_i.domain)&&e.exit();li;){t=li.fn,li=li.next;try{t()}catch(e){throw li?hi():ui=void 0,e}}ui=void 0,e&&e.enter()},hi=bi?function(){_i.nextTick(ci)}:he&&!yi?(di=!0,pi=document.createTextNode(""),new he(ci).observe(pi,{characterData:!0}),function(){pi.data=di=!di}):wi&&wi.resolve?(fi=wi.resolve(void 0),gi=fi.then,function(){gi.call(fi,ci)}):function(){vi.call(mi,ci)});function Ti(e){var n,r;this.promise=new e(function(e,t){if(void 0!==n||void 0!==r)throw TypeError("Bad Promise constructor");n=e,r=t}),this.resolve=Ii(n),this.reject=Ii(r)}var Be=d||function(e){var t={fn:e,next:void 0};ui&&(ui.next=t),li||(li=t,hi()),ui=t},de={},Ii=n;de.f=function(e){return new Ti(e)};var Ei=t,ki=c,Si=de,Ze=function(e,t){if(Ei(e),ki(t)&&t.constructor===e)return t;var n=Si.f(e);return(0,n.resolve)(t),n.promise},Ci=i,B=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},zr=A,P=i.process,or=P&&P.versions,yi=or&&or.v8;yi?ji=(Li=yi.split("."))[0]+Li[1]:zr&&(!(Li=zr.match(/Edge\/(\d+)/))||74<=Li[1])&&(Li=zr.match(/Chrome\/(\d+)/))&&(ji=Li[1]);var Ai,Ni,Ri,Pi,he=ji&&+ji,wi=z,xi=i,d=vt,A=pe,P=Z.exports,or=Er,yi=tt,zr=Ee,Di=c,Oi=n,Mi=Le,Li=Me,Fi=ue,Ui=l.exports,ji=r,qi=R,Vi=ar.set,Bi=Be,Wi=Ze,Ki=function(e,t){var n=Ci.console;n&&n.error&&(1===arguments.length?n.error(e):n.error(e,t))},ue=de,$i=B,ar=ke,Be=V,zi=he,Hi=Y("species"),Gi="Promise",Qi=ar.get,Yi=ar.set,Ji=ar.getterFor(Gi),Xi=A,Zi=xi.TypeError,es=xi.document,ts=xi.process,ns=d("fetch"),rs=ue.f,is=rs,ss="process"==Li(ts),os=!!(es&&es.createEvent&&xi.dispatchEvent),as="unhandledrejection",cs="rejectionhandled",ls=1,us=2,hs=1,ds=2,Be=Be(Gi,function(){if(!(Fi(Xi)!==String(Xi))){if(66===zi)return!0;if(!ss&&"function"!=typeof PromiseRejectionEvent)return!0}if(51<=zi&&/native code/.test(Xi))return!1;function e(e){e(function(){},function(){})}var t=Xi.resolve(1);return(t.constructor={})[Hi]=e,!(t.then(function(){})instanceof e)}),ji=Be||!ji(function(e){Xi.all(e).catch(function(){})}),ps=function(e){var t;return!(!Di(e)||"function"!=typeof(t=e.then))&&t},fs=function(p,f,g){var m;f.notified||(f.notified=!0,m=f.reactions,Bi(function(){for(var r,i,e=f.value,t=f.state==ls,n=0;m.length>n;){var s,o,a,c=m[n++],l=t?c.ok:c.fail,u=c.resolve,h=c.reject,d=c.domain;try{l?(t||(f.rejection===ds&&function(e,t){Vi.call(xi,function(){if(ss)ts.emit("rejectionHandled",e);else gs(cs,e,t.value)})}(p,f),f.rejection=hs),!0===l?s=e:(d&&d.enter(),s=l(e),d&&(d.exit(),a=!0)),s===c.promise?h(Zi("Promise-chain cycle")):(o=ps(s))?o.call(s,u,h):u(s)):h(e)}catch(e){d&&!a&&d.exit(),h(e)}}f.reactions=[],f.notified=!1,g&&!f.rejection&&(r=p,i=f,Vi.call(xi,function(){var e,t=i.value,n=ms(i);if(n&&(e=$i(function(){ss?ts.emit("unhandledRejection",t,r):gs(as,r,t)}),i.rejection=ss||ms(i)?ds:hs,e.error))throw e.value}))}))},gs=function(e,t,n){var r,i;os?((r=es.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),xi.dispatchEvent(r)):r={promise:t,reason:n},(i=xi["on"+e])?i(r):e===as&&Ki("Unhandled promise rejection",n)},ms=function(e){return e.rejection!==hs&&!e.parent},vs=function(t,n,r,i){return function(e){t(n,r,e,i)}},ys=function(e,t,n,r){t.done||(t.done=!0,(t=r?r:t).value=n,t.state=us,fs(e,t,!0))},_s=function(n,r,e,t){if(!r.done){r.done=!0,t&&(r=t);try{if(n===e)throw Zi("Promise can't be resolved itself");var i=ps(e);i?Bi(function(){var t={done:!1};try{i.call(e,vs(_s,n,t,r),vs(ys,n,t,r))}catch(e){ys(n,t,e,r)}}):(r.value=e,r.state=ls,fs(n,r,!1))}catch(e){ys(n,{done:!1},e,r)}}};Be&&(Xi=function(e){Mi(this,Xi,Gi),Oi(e),Ai.call(this);var t=Qi(this);try{e(vs(_s,this,t),vs(ys,this,t))}catch(e){ys(this,t,e)}},(Ai=function(e){Yi(this,{type:Gi,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=or(Xi.prototype,{then:function(e,t){var n=Ji(this),r=rs(qi(this,Xi));return r.ok="function"!=typeof e||e,r.fail="function"==typeof t&&t,r.domain=ss?ts.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&fs(this,n,!1),r.promise},catch:function(e){return this.then(void 0,e)}}),Ni=function(){var e=new Ai,t=Qi(e);this.promise=e,this.resolve=vs(_s,e,t),this.reject=vs(ys,e,t)},ue.f=rs=function(e){return e===Xi||e===Ri?new Ni:is(e)},"function"==typeof A&&(Pi=A.prototype.then,P(A.prototype,"then",function(e,t){var n=this;return new Xi(function(e,t){Pi.call(n,e,t)}).then(e,t)},{unsafe:!0}),"function"==typeof ns&&wi({global:!0,enumerable:!0,forced:!0},{fetch:function(e){return Wi(Xi,ns.apply(xi,arguments))}}))),wi({global:!0,wrap:!0,forced:Be},{Promise:Xi}),yi(Xi,Gi,!1),zr(Gi),Ri=d(Gi),wi({target:Gi,stat:!0,forced:Be},{reject:function(e){var t=rs(this);return t.reject.call(void 0,e),t.promise}}),wi({target:Gi,stat:!0,forced:Be},{resolve:function(e){return Wi(this,e)}}),wi({target:Gi,stat:!0,forced:ji},{all:function(e){var a=this,t=rs(a),c=t.resolve,l=t.reject,n=$i(function(){var r=Oi(a.resolve),i=[],s=0,o=1;Ui(e,function(e){var t=s++,n=!1;i.push(void 0),o++,r.call(a,e).then(function(e){n||(n=!0,i[t]=e,--o||c(i))},l)}),--o||c(i)});return n.error&&l(n.value),t.promise},race:function(e){var n=this,r=rs(n),i=r.reject,t=$i(function(){var t=Oi(n.resolve);Ui(e,function(e){t.call(n,e).then(r.resolve,i)})});return t.error&&i(t.value),r.promise}});var d=z,ws=n,bs=de,Ts=B,Is=l.exports;d({target:"Promise",stat:!0},{allSettled:function(e){var a=this,t=bs.f(a),c=t.resolve,n=t.reject,r=Ts(function(){var r=ws(a.resolve),i=[],s=0,o=1;Is(e,function(e){var t=s++,n=!1;i.push(void 0),o++,r.call(a,e).then(function(e){n||(n=!0,i[t]={status:"fulfilled",value:e},--o||c(i))},function(e){n||(n=!0,i[t]={status:"rejected",reason:e},--o||c(i))})}),--o||c(i)});return r.error&&n(r.value),t.promise}});var Be=z,Es=pe,wi=e,ks=vt,Ss=R,Cs=Ze,ji=Z.exports;Be({target:"Promise",proto:!0,real:!0,forced:!!Es&&wi(function(){Es.prototype.finally.call({then:function(){}},function(){})})},{finally:function(t){var n=Ss(this,ks("Promise")),e="function"==typeof t;return this.then(e?function(e){return Cs(n,t()).then(function(){return e})}:t,e?function(e){return Cs(n,t()).then(function(){throw e})}:t)}}),"function"!=typeof Es||Es.prototype.finally||ji(Es.prototype,"finally",ks("Promise").prototype.finally),yt.Promise;function As(e,t){var n=this;if(!(n instanceof As))return new As(e,t);Ps&&(n=Ps(new Error(t),Rs(n)));var r=[];return xs(e,r.push,r),Ns?Os(n,{errors:r,type:"AggregateError"}):n.errors=r,void 0!==t&&Ds(n,"message",String(t)),n}var d=z,Ns=o,Rs=ee,Ps=rt,pe=Qe,Ze=a,Be=T,xs=l.exports,Ds=k,wi=ke,Os=wi.set,Ms=wi.getterFor("AggregateError");As.prototype=pe(Error.prototype,{constructor:Be(5,As),message:Be(5,""),name:Be(5,"AggregateError")}),Ns&&Ze.f(As.prototype,"errors",{get:function(){return Ms(this).errors},configurable:!0}),d({global:!0},{AggregateError:As});var Ls=de,Fs=B;z({target:"Promise",stat:!0},{try:function(e){var t=Ls.f(this),n=Fs(e);return(n.error?t.reject:t.resolve)(n.value),t.promise}});var ji=z,Us=n,js=vt,qs=de,Vs=B,Bs=l.exports,Ws="No one promise resolved";ji({target:"Promise",stat:!0},{any:function(e){var c=this,t=qs.f(c),l=t.resolve,u=t.reject,n=Vs(function(){var r=Us(c.resolve),i=[],s=0,o=1,a=!1;Bs(e,function(e){var t=s++,n=!1;i.push(void 0),o++,r.call(c,e).then(function(e){n||a||(a=!0,l(e))},function(e){n||a||(n=!0,i[t]=e,--o||u(new(js("AggregateError"))(i,Ws)))})}),--o||u(new(js("AggregateError"))(i,Ws))});return n.error&&u(n.value),t.promise}});function Ks(e){throw e}var $s=Me,wi=Array.isArray||function(e){return"Array"==$s(e)},zs=c,Hs=wi,Gs=Y("species"),pe=function(e,t){var n;return new(void 0===(n=Hs(e)&&("function"==typeof(n=e.constructor)&&(n===Array||Hs(n.prototype))||zs(n)&&null===(n=n[Gs]))?void 0:n)?Array:n)(0===t?0:t)},Qs=Ie,Ys=ot,Js=K,Xs=Et,Zs=pe,eo=[].push,Be=function(p){var f=1==p,g=2==p,m=3==p,v=4==p,y=6==p,_=5==p||y;return function(e,t,n,r){for(var i,s,o=Js(e),a=Ys(o),c=Qs(t,n,3),l=Xs(a.length),u=0,h=r||Zs,d=f?h(e,l):g?h(e,0):void 0;u<l;u++)if((_||u in a)&&(s=c(i=a[u],u,o),p))if(f)d[u]=s;else if(s)switch(p){case 3:return!0;case 5:return i;case 6:return u;case 2:eo.call(d,i)}else if(v)return!1;return y?-1:m||v?v:d}},Ze={forEach:Be(0),map:Be(1),filter:Be(2),some:Be(3),every:Be(4),find:Be(5),findIndex:Be(6)},to=o,no=e,ro=D,io=Object.defineProperty,so={},d=function(e,t){if(ro(so,e))return so[e];var n=[][e],r=!!ro(t=t||{},"ACCESSORS")&&t.ACCESSORS,i=ro(t,0)?t[0]:Ks,s=ro(t,1)?t[1]:void 0;return so[e]=!!n&&!no(function(){if(r&&!to)return!0;var e={length:-1};r?io(e,1,{enumerable:!0,get:Ks}):e[1]=1,n.call(e,i,s)})},de=z,oo=Ze.find,B=J,ji="find",ao=!0,Be=d(ji);ji in[]&&Array(1)[ji](function(){ao=!1}),de({target:"Array",proto:!0,forced:ao||!Be},{find:function(e){return oo(this,e,1<arguments.length?arguments[1]:void 0)}}),B(ji);var co=i,lo=Ie,uo=Function.call,de=function(e,t,n){return lo(uo,co[e].prototype[t],n)};de("Array","find");var Be=z,ho=Ze.findIndex,B=J,ji="findIndex",po=!0,J=d(ji);ji in[]&&Array(1)[ji](function(){po=!1}),Be({target:"Array",proto:!0,forced:po||!J},{findIndex:function(e){return ho(this,e,1<arguments.length?arguments[1]:void 0)}}),B(ji),de("Array","findIndex");var fo=v,go=a,mo=T,J=function(e,t,n){var r=fo(t);r in e?go.f(e,r,mo(0,n)):e[r]=n},vo=Ie,yo=K,_o=Ye,wo=X,bo=Et,To=J,Io=f,B=function(e){var t,n,r,i,s,o,a=yo(e),c="function"==typeof this?this:Array,l=arguments.length,u=1<l?arguments[1]:void 0,h=void 0!==u,d=Io(a),p=0;if(h&&(u=vo(u,2<l?arguments[2]:void 0,2)),null==d||c==Array&&wo(d))for(n=new c(t=bo(a.length));p<t;p++)o=h?u(a[p],p):a[p],To(n,p,o);else for(s=(i=d.call(a)).next,n=new c;!(r=s.call(i)).done;p++)o=h?_o(i,u,[r.value,p],!0):r.value,To(n,p,o);return n.length=p,n};z({target:"Array",stat:!0,forced:!r(function(e){Array.from(e)})},{from:B}),yt.Array.from;var Eo=e,ji=z,ko=Ze.some,Ye=d,X=function(e,t){var n=[][e];return!!n&&Eo(function(){n.call(null,t||function(){throw 1},1)})}("some"),B=Ye("some");ji({target:"Array",proto:!0,forced:!X||!B},{some:function(e){return ko(this,e,1<arguments.length?arguments[1]:void 0)}}),de("Array","some");function So(e){return Ro(e)&&Po(Wo,xo(e))}var Co,d="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,Ao=o,No=i,Ro=c,Po=D,xo=qe,Do=k,Oo=Z.exports,Ye=a.f,ji=ee,Mo=rt,X=Y,B=O,Lo=No.Int8Array,Fo=Lo&&Lo.prototype,qe=No.Uint8ClampedArray,ee=qe&&qe.prototype,Uo=Lo&&ji(Lo),jo=Fo&&ji(Fo),qe=Object.prototype,qo=qe.isPrototypeOf,X=X("toStringTag"),Vo=B("TYPED_ARRAY_TAG"),Bo=d&&!!Mo&&"Opera"!==xo(No.opera),d=!1,Wo={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8};for(Co in Wo)No[Co]||(Bo=!1);if((!Bo||"function"!=typeof Uo||Uo===Function.prototype)&&(Uo=function(){throw TypeError("Incorrect invocation")},Bo))for(Co in Wo)No[Co]&&Mo(No[Co],Uo);if((!Bo||!jo||jo===qe)&&(jo=Uo.prototype,Bo))for(Co in Wo)No[Co]&&Mo(No[Co].prototype,jo);if(Bo&&ji(ee)!==jo&&Mo(ee,jo),Ao&&!Po(jo,X))for(Co in d=!0,Ye(jo,X,{get:function(){return Ro(this)?this[Vo]:void 0}}),Wo)No[Co]&&Do(No[Co],Vo,Co);var Ye=i,X={NATIVE_ARRAY_BUFFER_VIEWS:Bo,TYPED_ARRAY_TAG:d&&Vo,aTypedArray:function(e){if(So(e))return e;throw TypeError("Target is not a typed array")},aTypedArrayConstructor:function(e){if(Mo){if(qo.call(Uo,e))return e}else for(var t in Wo)if(Po(Wo,Co)){t=No[t];if(t&&(e===t||qo.call(t,e)))return e}throw TypeError("Target is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n){if(Ao){if(n)for(var r in Wo){r=No[r];r&&Po(r.prototype,e)&&delete r.prototype[e]}jo[e]&&!n||Oo(jo,e,!n&&Bo&&Fo[e]||t)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(Ao){if(Mo){if(n)for(r in Wo)(i=No[r])&&Po(i,e)&&delete i[e];if(Uo[e]&&!n)return;try{return Oo(Uo,e,!n&&Bo&&Lo[e]||t)}catch(e){}}for(r in Wo)!(i=No[r])||i[e]&&!n||Oo(i,e,t)}},isView:function(e){var t=xo(e);return"DataView"===t||Po(Wo,t)},isTypedArray:So,TypedArray:Uo,TypedArrayPrototype:jo},d=fe,fe=Y("iterator"),Ye=Ye.Uint8Array,Ko=d.values,$o=d.keys,zo=d.entries,Ho=X.aTypedArray,d=X.exportTypedArrayMethod,X=Ye&&Ye.prototype[fe],Ye=!!X&&("values"==X.name||null==X.name),X=function(){return Ko.call(Ho(this))};d("entries",function(){return zo.call(Ho(this))}),d("keys",function(){return $o.call(Ho(this))}),d("values",X,!Ye),d(fe,X,!Ye);var Go=o,X=e,Qo=Te,Yo=N,Jo=Xe,Xo=K,Zo=ot,ea=Object.assign,ta=Object.defineProperty,Ye=!ea||X(function(){if(Go&&1!==ea({b:1},ea(ta({},"a",{enumerable:!0,get:function(){ta(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach(function(e){t[e]=e}),7!=ea({},e)[n]||Qo(ea({},t)).join("")!=r})?function(e,t){for(var n=Xo(e),r=arguments.length,i=1,s=Yo.f,o=Jo.f;i<r;)for(var a,c=Zo(arguments[i++]),l=s?Qo(c).concat(s(c)):Qo(c),u=l.length,h=0;h<u;)a=l[h++],Go&&!o.call(c,a)||(n[a]=c[a]);return n}:ea;z({target:"Object",stat:!0,forced:Object.assign!==Ye},{assign:Ye}),yt.Object.assign;var na=o,ra=Te,ia=nt,sa=Xe.f,ot=function(a){return function(e){for(var t,n=ia(e),r=ra(n),i=r.length,s=0,o=[];s<i;)t=r[s++],na&&!sa.call(n,t)||o.push(a?[t,n[t]]:n[t]);return o}},X={entries:ot(!0),values:ot(!1)},Ye=z,oa=X.entries;Ye({target:"Object",stat:!0},{entries:function(e){return oa(e)}}),yt.Object.entries;var ot=z,aa=X.values;ot({target:"Object",stat:!0},{values:function(e){return aa(e)}}),yt.Object.values;var ca=c,la=Me,ua=Y("match"),ha=function(e){var t;return ca(e)&&(void 0!==(t=e[ua])?!!t:"RegExp"==la(e))},Ye=function(e){if(ha(e))throw TypeError("The method doesn't accept regular expressions");return e},da=Y("match"),X=function(t){var n=/./;try{"/./"[t](n)}catch(e){try{return n[da]=!1,"/./"[t](n)}catch(e){}}return!1},pa=Ye,fa=ze;z({target:"String",proto:!0,forced:!X("includes")},{includes:function(e){return!!~String(fa(this)).indexOf(pa(e),1<arguments.length?arguments[1]:void 0)}}),de("String","includes");var ot=z,Me=Je.f,ga=Et,ma=Ye,va=ze,X=X,ya="".startsWith,_a=Math.min,X=X("startsWith");ot({target:"String",proto:!0,forced:!!(X||(!(Me=Me(String.prototype,"startsWith"))||Me.writable))&&!X},{startsWith:function(e){var t=String(va(this));ma(e);var n=ga(_a(1<arguments.length?arguments[1]:void 0,t.length)),r=String(e);return ya?ya.call(t,r,n):t.slice(n,n+r.length)===r}}),de("String","startsWith");var wa=$e,ba=ze;z({target:"String",proto:!0},{repeat:"".repeat||function(e){var t=String(ba(this)),n="",r=wa(e);if(r<0||r==1/0)throw RangeError("Wrong number of repetitions");for(;0<r;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n}}),de("String","repeat");var Ta=e,Ia=he,Ea=Y("species"),$e=z,ze=e,ka=wi,Sa=c,Ca=K,Aa=Et,Na=J,Ra=pe,de=function(t){return 51<=Ia||!Ta(function(){var e=[];return(e.constructor={})[Ea]=function(){return{foo:1}},1!==e[t](Boolean).foo})},Et=he,Pa=Y("isConcatSpreadable"),xa=9007199254740991,Da="Maximum allowed index exceeded",J=51<=Et||!ze(function(){var e=[];return e[Pa]=!1,e.concat()[0]!==e}),pe=de("concat");$e({target:"Array",proto:!0,forced:!J||!pe},{concat:function(e){for(var t,n,r,i=Ca(this),s=Ra(i,0),o=0,a=-1,c=arguments.length;a<c;a++)if(function(e){if(!Sa(e))return!1;var t=e[Pa];return void 0!==t?!!t:ka(e)}(r=-1===a?i:arguments[a])){if(n=Aa(r.length),xa<o+n)throw TypeError(Da);for(t=0;t<n;t++,o++)t in r&&Na(s,o,r[t])}else{if(xa<=o)throw TypeError(Da);Na(s,o++,r)}return s.length=o,s}});var he={},Oa=nt,Ma=bt.f,La={}.toString,Fa="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];he.f=function(e){return Fa&&"[object Window]"==La.call(e)?function(e){try{return Ma(e)}catch(e){return Fa.slice()}}(e):Ma(Oa(e))};Et={};Et.f=Y;function Ua(e,t){var n=_c[e]=Za(pc[lc]);return uc(n,{type:cc,tag:e,description:t}),Ka||(n.description=t),n}function ja(t,e){Ga(t);var n=Ya(e),r=ec(n).concat(Ac(n));return oc(r,function(e){Ka&&!Cc.call(n,e)||Sc(t,e,n[e])}),t}var qa=yt,Va=D,Ba=Et,Wa=a.f,ze=function(e){var t=qa.Symbol||(qa.Symbol={});Va(t,e)||Wa(t,e,{value:Ba.f(e)})},de=z,$e=i,J=vt,Ka=o,pe=j,j=q,q=e,$a=D,za=wi,Ha=c,Ga=t,Qa=K,Ya=nt,Ja=v,Xa=T,Za=Qe,ec=Te,v=bt,T=he,tc=N,Te=Je,bt=a,he=Xe,N=k,Je=Z.exports,Xe=s.exports,k=ve,nc=ye,rc=O,ic=Y,s=Et,sc=ze,ve=tt,Y=ke,oc=Ze.forEach,ac=k("hidden"),cc="Symbol",lc="prototype",k=ic("toPrimitive"),uc=Y.set,hc=Y.getterFor(cc),dc=Object[lc],pc=$e.Symbol,fc=J("JSON","stringify"),gc=Te.f,mc=bt.f,vc=T.f,yc=he.f,_c=Xe("symbols"),wc=Xe("op-symbols"),bc=Xe("string-to-symbol-registry"),Tc=Xe("symbol-to-string-registry"),Xe=Xe("wks"),$e=$e.QObject,Ic=!$e||!$e[lc]||!$e[lc].findChild,Ec=Ka&&q(function(){return 7!=Za(mc({},"a",{get:function(){return mc(this,"a",{value:7}).a}})).a})?function(e,t,n){var r=gc(dc,t);r&&delete dc[t],mc(e,t,n),r&&e!==dc&&mc(dc,t,r)}:mc,kc=j?function(e){return"symbol"==typeof e}:function(e){return Object(e)instanceof pc},Sc=function(e,t,n){e===dc&&Sc(wc,t,n),Ga(e);var r=Ja(t,!0);return Ga(n),$a(_c,r)?(n.enumerable?($a(e,ac)&&e[ac][r]&&(e[ac][r]=!1),n=Za(n,{enumerable:Xa(0,!1)})):($a(e,ac)||mc(e,ac,Xa(1,{})),e[ac][r]=!0),Ec(e,r,n)):mc(e,r,n)},Cc=function(e){var t=Ja(e,!0),n=yc.call(this,t);return!(this===dc&&$a(_c,t)&&!$a(wc,t))&&(!(n||!$a(this,t)||!$a(_c,t)||$a(this,ac)&&this[ac][t])||n)},$e=function(e,t){var n=Ya(e),r=Ja(t,!0);if(n!==dc||!$a(_c,r)||$a(wc,r)){var i=gc(n,r);return!i||!$a(_c,r)||$a(n,ac)&&n[ac][r]||(i.enumerable=!0),i}},j=function(e){var t=vc(Ya(e)),n=[];return oc(t,function(e){$a(_c,e)||$a(nc,e)||n.push(e)}),n},Ac=function(e){var t=e===dc,n=vc(t?wc:Ya(e)),r=[];return oc(n,function(e){!$a(_c,e)||t&&!$a(dc,e)||r.push(_c[e])}),r};pe||(Je((pc=function(){if(this instanceof pc)throw TypeError("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?String(arguments[0]):void 0,t=rc(e),n=function(e){this===dc&&n.call(wc,e),$a(this,ac)&&$a(this[ac],t)&&(this[ac][t]=!1),Ec(this,t,Xa(1,e))};return Ka&&Ic&&Ec(dc,t,{configurable:!0,set:n}),Ua(t,e)})[lc],"toString",function(){return hc(this).tag}),Je(pc,"withoutSetter",function(e){return Ua(rc(e),e)}),he.f=Cc,bt.f=Sc,Te.f=$e,v.f=T.f=j,tc.f=Ac,s.f=function(e){return Ua(ic(e),e)},Ka&&(mc(pc[lc],"description",{configurable:!0,get:function(){return hc(this).description}}),Je(dc,"propertyIsEnumerable",Cc,{unsafe:!0}))),de({global:!0,wrap:!0,forced:!pe,sham:!pe},{Symbol:pc}),oc(ec(Xe),function(e){sc(e)}),de({target:cc,stat:!0,forced:!pe},{for:function(e){var t=String(e);if($a(bc,t))return bc[t];var n=pc(t);return bc[t]=n,Tc[n]=t,n},keyFor:function(e){if(!kc(e))throw TypeError(e+" is not a symbol");if($a(Tc,e))return Tc[e]},useSetter:function(){Ic=!0},useSimple:function(){Ic=!1}}),de({target:"Object",stat:!0,forced:!pe,sham:!Ka},{create:function(e,t){return void 0===t?Za(e):ja(Za(e),t)},defineProperty:Sc,defineProperties:ja,getOwnPropertyDescriptor:$e}),de({target:"Object",stat:!0,forced:!pe},{getOwnPropertyNames:j,getOwnPropertySymbols:Ac}),de({target:"Object",stat:!0,forced:q(function(){tc.f(1)})},{getOwnPropertySymbols:function(e){return tc.f(Qa(e))}}),fc&&de({target:"JSON",stat:!0,forced:!pe||q(function(){var e=pc();return"[null]"!=fc([e])||"{}"!=fc({a:e})||"{}"!=fc(Object(e))})},{stringify:function(e,t,n){for(var r,i=[e],s=1;s<arguments.length;)i.push(arguments[s++]);if((Ha(r=t)||void 0!==e)&&!kc(e))return za(t)||(t=function(e,t){if("function"==typeof r&&(t=r.call(this,e,t)),!kc(t))return t}),i[1]=t,fc.apply(null,i)}}),pc[lc][k]||N(pc[lc],k,pc[lc].valueOf),ve(pc,cc),nc[ac]=!0,ze("asyncIterator");var Nc,Rc,Pc,xc,Dc,k=z,Oc=D,Mc=c,ve=a.f,U=U,Lc=i.Symbol;!o||"function"!=typeof Lc||"description"in Lc.prototype&&void 0===Lc().description||(Nc={},U(Rc=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:String(arguments[0]),t=this instanceof Rc?new Lc(e):void 0===e?Lc():Lc(e);return""===e&&(Nc[t]=!0),t},Lc),(U=Rc.prototype=Lc.prototype).constructor=Rc,Pc=U.toString,xc="Symbol(test)"==String(Lc("test")),Dc=/^Symbol\((.*)\)[^)]+$/,ve(U,"description",{configurable:!0,get:function(){var e=Mc(this)?this.valueOf():this,t=Pc.call(e);if(Oc(Nc,e))return"";t=xc?t.slice(7,-1):t.replace(Dc,"$1");return""===t?void 0:t}}),k({global:!0,forced:!0},{Symbol:Rc})),ze("hasInstance"),ze("isConcatSpreadable"),ze("iterator"),ze("match"),ze("matchAll"),ze("replace"),ze("search"),ze("species"),ze("split"),ze("toPrimitive"),ze("toStringTag"),ze("unscopables"),tt(Math,"Math",!0),tt(i.JSON,"JSON",!0),yt.Symbol,ze("asyncDispose"),ze("dispose"),ze("observable"),ze("patternMatch"),ze("replaceAll"),Et.f("iterator");function Fc(e){qc(e,Bc,{value:{objectID:"O"+ ++Wc,weakData:{}}})}var ze={exports:{}},Et=!e(function(){return Object.isExtensible(Object.preventExtensions({}))}),ye=ye,Uc=c,jc=D,qc=a.f,Vc=Et,Bc=O("meta"),Wc=0,Kc=Object.isExtensible||function(){return!0},$c=ze.exports={REQUIRED:!1,fastKey:function(e,t){if(!Uc(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!jc(e,Bc)){if(!Kc(e))return"F";if(!t)return"E";Fc(e)}return e[Bc].objectID},getWeakData:function(e,t){if(!jc(e,Bc)){if(!Kc(e))return!0;if(!t)return!1;Fc(e)}return e[Bc].weakData},onFreeze:function(e){return Vc&&$c.REQUIRED&&Kc(e)&&!jc(e,Bc)&&Fc(e),e}};ye[Bc]=!0;var zc=c,Hc=rt,Gc=z,Qc=i,Yc=V,Jc=Z.exports,Xc=ze.exports,Zc=l.exports,el=Le,tl=c,nl=e,rl=r,il=tt,sl=function(e,t,n){var r,i;return Hc&&"function"==typeof(r=t.constructor)&&r!==n&&zc(i=r.prototype)&&i!==n.prototype&&Hc(e,i),e},tt=function(r,e,t){function n(e){var n=p[e];Jc(p,e,"add"==e?function(e){return n.call(this,0===e?0:e),this}:"delete"==e?function(e){return!(u&&!tl(e))&&n.call(this,0===e?0:e)}:"get"==e?function(e){return u&&!tl(e)?void 0:n.call(this,0===e?0:e)}:"has"==e?function(e){return!(u&&!tl(e))&&n.call(this,0===e?0:e)}:function(e,t){return n.call(this,0===e?0:e,t),this})}var i,s,o,a,c,l=-1!==r.indexOf("Map"),u=-1!==r.indexOf("Weak"),h=l?"set":"add",d=Qc[r],p=d&&d.prototype,f=d,g={};return Yc(r,"function"!=typeof d||!(u||p.forEach&&!nl(function(){(new d).entries().next()})))?(f=t.getConstructor(e,r,l,h),Xc.REQUIRED=!0):Yc(r,!0)&&(s=(i=new f)[h](u?{}:-0,1)!=i,o=nl(function(){i.has(1)}),a=rl(function(e){new d(e)}),c=!u&&nl(function(){for(var e=new d,t=5;t--;)e[h](t,t);return!e.has(-0)}),a||(((f=e(function(e,t){el(e,f,r);var n=sl(new d,e,f);return null!=t&&Zc(t,n[h],n,l),n})).prototype=p).constructor=f),(o||c)&&(n("delete"),n("has"),l&&n("get")),(c||s)&&n(h),u&&p.clear&&delete p.clear),g[r]=f,Gc({global:!0,forced:f!=d},g),il(f,r),u||t.setStrong(f,r,l),f},ol=a.f,al=Qe,cl=Er,ll=Ie,ul=Le,hl=l.exports,dl=Pt,pl=Ee,fl=o,gl=ze.exports.fastKey,ml=ke.set,vl=ke.getterFor,Pt={getConstructor:function(e,n,r,i){function s(e,t,n){var r,i,s=c(e),o=a(e,t);return o?o.value=n:(s.last=o={index:i=gl(t,!0),key:t,value:n,previous:r=s.last,next:void 0,removed:!1},s.first||(s.first=o),r&&(r.next=o),fl?s.size++:e.size++,"F"!==i&&(s.index[i]=o)),e}function a(e,t){var n,r=c(e),i=gl(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==t)return n}var o=e(function(e,t){ul(e,o,n),ml(e,{type:n,index:al(null),first:void 0,last:void 0,size:0}),fl||(e.size=0),null!=t&&hl(t,e[i],e,r)}),c=vl(n);return cl(o.prototype,{clear:function(){for(var e=c(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,fl?e.size=0:this.size=0},delete:function(e){var t,n,r=c(this),i=a(this,e);return i&&(t=i.next,n=i.previous,delete r.index[i.index],i.removed=!0,n&&(n.next=t),t&&(t.previous=n),r.first==i&&(r.first=t),r.last==i&&(r.last=n),fl?r.size--:this.size--),!!i},forEach:function(e){for(var t,n=c(this),r=ll(e,1<arguments.length?arguments[1]:void 0,3);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!a(this,e)}}),cl(o.prototype,r?{get:function(e){var t=a(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),fl&&ol(o.prototype,"size",{get:function(){return c(this).size}}),o},setStrong:function(e,t,n){var r=t+" Iterator",i=vl(t),s=vl(r);dl(e,t,function(e,t){ml(this,{type:r,target:e,state:i(e),kind:t,last:void 0})},function(){for(var e=s(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?"keys"==t?{value:n.key,done:!1}:"values"==t?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:{value:e.target=void 0,done:!0}},n?"entries":"values",!n,!0),pl(t)}};tt("Map",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},Pt),yt.Map;var yl=n,_l=Ie,wl=l.exports,Ee=function(e){var t,n,r,i,s=arguments.length,o=1<s?arguments[1]:void 0;return yl(this),(t=void 0!==o)&&yl(o),null==e?new this:(n=[],t?(r=0,i=_l(o,2<s?arguments[2]:void 0,2),wl(e,function(e){n.push(i(e,r++))})):wl(e,n.push,n),new this(n))};z({target:"Map",stat:!0},{from:Ee});o=function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];return new this(t)};z({target:"Map",stat:!0},{of:o});var bl=t,Tl=n,ze=function(){for(var e,t=bl(this),n=Tl(t.delete),r=!0,i=0,s=arguments.length;i<s;i++)e=n.call(t,arguments[i]),r=r&&e;return!!r},Il=ze;z({target:"Map",proto:!0,real:!0,forced:!1},{deleteAll:function(){return Il.apply(this,arguments)}});var El=t,kl=f,ke=function(e){return Map.prototype.entries.call(e)},f=z,Sl=t,Cl=Ie,Al=ke,Nl=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{every:function(e){var n=Sl(this),t=Al(n),r=Cl(e,1<arguments.length?arguments[1]:void 0,3);return!Nl(t,function(e,t){if(!r(t,e,n))return Nl.stop()},void 0,!0,!0).stopped}});var f=z,Rl=vt,Pl=t,xl=n,Dl=Ie,Ol=R,Ml=ke,Ll=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{filter:function(e){var n=Pl(this),t=Ml(n),r=Dl(e,1<arguments.length?arguments[1]:void 0,3),i=new(Ol(n,Rl("Map"))),s=xl(i.set);return Ll(t,function(e,t){r(t,e,n)&&s.call(i,e,t)},void 0,!0,!0),i}});var f=z,Fl=t,Ul=Ie,jl=ke,ql=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{find:function(e){var n=Fl(this),t=jl(n),r=Ul(e,1<arguments.length?arguments[1]:void 0,3);return ql(t,function(e,t){if(r(t,e,n))return ql.stop(t)},void 0,!0,!0).result}});var f=z,Vl=t,Bl=Ie,Wl=ke,Kl=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{findKey:function(e){var n=Vl(this),t=Wl(n),r=Bl(e,1<arguments.length?arguments[1]:void 0,3);return Kl(t,function(e,t){if(r(t,e,n))return Kl.stop(e)},void 0,!0,!0).result}});var f=z,$l=l.exports,zl=n;f({target:"Map",stat:!0},{groupBy:function(e,n){var r=new this;zl(n);var i=zl(r.has),s=zl(r.get),o=zl(r.set);return $l(e,function(e){var t=n(e);i.call(r,t)?s.call(r,t).push(e):o.call(r,t,[e])}),r}});var f=z,Hl=t,Gl=ke,Ql=function(e,t){return e===t||e!=e&&t!=t},Yl=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{includes:function(n){return Yl(Gl(Hl(this)),function(e,t){if(Ql(t,n))return Yl.stop()},void 0,!0,!0).stopped}});var f=z,Jl=l.exports,Xl=n;f({target:"Map",stat:!0},{keyBy:function(e,t){var n=new this;Xl(t);var r=Xl(n.set);return Jl(e,function(e){r.call(n,t(e),e)}),n}});var f=z,Zl=t,eu=ke,tu=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{keyOf:function(n){return tu(eu(Zl(this)),function(e,t){if(t===n)return tu.stop(e)},void 0,!0,!0).result}});var f=z,nu=vt,ru=t,iu=n,su=Ie,ou=R,au=ke,cu=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{mapKeys:function(e){var n=ru(this),t=au(n),r=su(e,1<arguments.length?arguments[1]:void 0,3),i=new(ou(n,nu("Map"))),s=iu(i.set);return cu(t,function(e,t){s.call(i,r(t,e,n),t)},void 0,!0,!0),i}});var f=z,lu=vt,uu=t,hu=n,du=Ie,pu=R,fu=ke,gu=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{mapValues:function(e){var n=uu(this),t=fu(n),r=du(e,1<arguments.length?arguments[1]:void 0,3),i=new(pu(n,lu("Map"))),s=hu(i.set);return gu(t,function(e,t){s.call(i,e,r(t,e,n))},void 0,!0,!0),i}});var f=z,mu=t,vu=n,yu=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{merge:function(e){for(var t=mu(this),n=vu(t.set),r=0;r<arguments.length;)yu(arguments[r++],n,t,!0);return t}});var f=z,_u=t,wu=n,bu=ke,Tu=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{reduce:function(n){var r=_u(this),e=bu(r),i=arguments.length<2,s=i?void 0:arguments[1];if(wu(n),Tu(e,function(e,t){s=i?(i=!1,t):n(s,t,e,r)},void 0,!0,!0),i)throw TypeError("Reduce of empty map with no initial value");return s}});var f=z,Iu=t,Eu=Ie,ku=ke,Su=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{some:function(e){var n=Iu(this),t=ku(n),r=Eu(e,1<arguments.length?arguments[1]:void 0,3);return Su(t,function(e,t){if(r(t,e,n))return Su.stop()},void 0,!0,!0).stopped}});var Cu=t,Au=n;z({target:"Map",proto:!0,real:!0,forced:!1},{update:function(e,t){var n=Cu(this),r=arguments.length;Au(t);var i=n.has(e);if(!i&&r<3)throw TypeError("Updating absent value");r=i?n.get(e):Au(2<r?arguments[2]:void 0)(e,n);return n.set(e,t(r,e,n)),n}});var Nu=t,f=function(e,t){var n,r=Nu(this),i=2<arguments.length?arguments[2]:void 0;if("function"!=typeof t&&"function"!=typeof i)throw TypeError("At least one callback required");return r.has(e)?(n=r.get(e),"function"==typeof t&&(n=t(n),r.set(e,n))):"function"==typeof i&&(n=i(),r.set(e,n)),n};z({target:"Map",proto:!0,real:!0,forced:!1},{upsert:f});z({target:"Map",proto:!0,real:!0,forced:!1},{updateOrInsert:f}),tt("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},Pt),yt.Set,z({target:"Set",stat:!0},{from:Ee}),z({target:"Set",stat:!0},{of:o});var Ru=t,Pu=n,xu=function(){for(var e=Ru(this),t=Pu(e.add),n=0,r=arguments.length;n<r;n++)t.call(e,arguments[n]);return e};z({target:"Set",proto:!0,real:!0,forced:!1},{addAll:function(){return xu.apply(this,arguments)}});var Du=ze;z({target:"Set",proto:!0,real:!0,forced:!1},{deleteAll:function(){return Du.apply(this,arguments)}});var o=function(e){return Set.prototype.values.call(e)},ze=z,Ou=t,Mu=Ie,Lu=o,Fu=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{every:function(e){var t=Ou(this),n=Lu(t),r=Mu(e,1<arguments.length?arguments[1]:void 0,3);return!Fu(n,function(e){if(!r(e,e,t))return Fu.stop()},void 0,!1,!0).stopped}});var ze=z,Uu=vt,ju=t,qu=n,Vu=R,Bu=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{difference:function(e){var t=ju(this),n=new(Vu(t,Uu("Set")))(t),r=qu(n.delete);return Bu(e,function(e){r.call(n,e)}),n}});var ze=z,Wu=vt,Ku=t,$u=n,zu=Ie,Hu=R,Gu=o,Qu=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{filter:function(e){var t=Ku(this),n=Gu(t),r=zu(e,1<arguments.length?arguments[1]:void 0,3),i=new(Hu(t,Wu("Set"))),s=$u(i.add);return Qu(n,function(e){r(e,e,t)&&s.call(i,e)},void 0,!1,!0),i}});var ze=z,Yu=t,Ju=Ie,Xu=o,Zu=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{find:function(e){var t=Yu(this),n=Xu(t),r=Ju(e,1<arguments.length?arguments[1]:void 0,3);return Zu(n,function(e){if(r(e,e,t))return Zu.stop(e)},void 0,!1,!0).result}});var ze=z,eh=vt,th=t,nh=n,rh=R,ih=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{intersection:function(e){var t=th(this),n=new(rh(t,eh("Set"))),r=nh(t.has),i=nh(n.add);return ih(e,function(e){r.call(t,e)&&i.call(n,e)}),n}});var ze=z,sh=t,oh=n,ah=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{isDisjointFrom:function(e){var t=sh(this),n=oh(t.has);return!ah(e,function(e){if(!0===n.call(t,e))return ah.stop()}).stopped}});var ze=z,ch=vt,lh=t,uh=n,hh=function(e){var t=kl(e);if("function"!=typeof t)throw TypeError(String(e)+" is not iterable");return El(t.call(e))},dh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{isSubsetOf:function(e){var t=hh(this),n=lh(e),r=n.has;return"function"!=typeof r&&(n=new(ch("Set"))(e),r=uh(n.has)),!dh(t,function(e){if(!1===r.call(n,e))return dh.stop()},void 0,!1,!0).stopped}});var ze=z,ph=t,fh=n,gh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{isSupersetOf:function(e){var t=ph(this),n=fh(t.has);return!gh(e,function(e){if(!1===n.call(t,e))return gh.stop()}).stopped}});var ze=z,mh=t,vh=o,yh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{join:function(e){var t=mh(this),n=vh(t),r=void 0===e?",":String(e),t=[];return yh(n,t.push,t,!1,!0),t.join(r)}});var ze=z,_h=vt,wh=t,bh=n,Th=Ie,Ih=R,Eh=o,kh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{map:function(e){var t=wh(this),n=Eh(t),r=Th(e,1<arguments.length?arguments[1]:void 0,3),i=new(Ih(t,_h("Set"))),s=bh(i.add);return kh(n,function(e){s.call(i,r(e,e,t))},void 0,!1,!0),i}});var ze=z,Sh=t,Ch=n,Ah=o,Nh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{reduce:function(t){var n=Sh(this),e=Ah(n),r=arguments.length<2,i=r?void 0:arguments[1];if(Ch(t),Nh(e,function(e){i=r?(r=!1,e):t(i,e,e,n)},void 0,!1,!0),r)throw TypeError("Reduce of empty set with no initial value");return i}});var ze=z,Rh=t,Ph=Ie,xh=o,Dh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{some:function(e){var t=Rh(this),n=xh(t),r=Ph(e,1<arguments.length?arguments[1]:void 0,3);return Dh(n,function(e){if(r(e,e,t))return Dh.stop()},void 0,!1,!0).stopped}});var ze=z,Oh=vt,Mh=t,Lh=n,Fh=R,Uh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{symmetricDifference:function(e){var t=Mh(this),n=new(Fh(t,Oh("Set")))(t),r=Lh(n.delete),i=Lh(n.add);return Uh(e,function(e){r.call(n,e)||i.call(n,e)}),n}});var ze=z,jh=vt,qh=t,Vh=n,Bh=R,Wh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{union:function(e){var t=qh(this),t=new(Bh(t,jh("Set")))(t);return Wh(e,Vh(t.add),t),t}});var Kh,$h,zh=c,Hh=Math.floor;z({target:"Number",stat:!0},{isInteger:function(e){return!zh(e)&&isFinite(e)&&Hh(e)===e}}),yt.Number.isInteger;function Gh(t){const n=[];let r=0;for(let i=0;i<t.length;i++){let e=t.charCodeAt(i);e<128?n[r++]=e:(e<2048?n[r++]=e>>6|192:(55296==(64512&e)&&i+1<t.length&&56320==(64512&t.charCodeAt(i+1))?(e=65536+((1023&e)<<10)+(1023&t.charCodeAt(++i)),n[r++]=e>>18|240,n[r++]=e>>12&63|128):n[r++]=e>>12|224,n[r++]=e>>6&63|128),n[r++]=63&e|128)}return n}function Qh(e){var t=Gh(e);return Zh.encodeByteArray(t,!0)}const Yh={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},Jh=function(e,t){if(!e)throw Xh(t)},Xh=function(e){return new Error("Firebase Database ("+Yh.SDK_VERSION+") INTERNAL ASSERT FAILED: "+e)},Zh={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(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();var r=e?this.byteToCharMapWebSafe_:this.byteToCharMap_;const i=[];for(let u=0;u<n.length;u+=3){var s=n[u],o=u+1<n.length,a=o?n[u+1]:0,c=u+2<n.length,l=c?n[u+2]:0;let e=(15&a)<<2|l>>6,t=63&l;c||(t=64,o||(e=64)),i.push(r[s>>2],r[(3&s)<<4|a>>4],r[e],r[t])}return i.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(Gh(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let n=0,r=0;for(;n<e.length;){var i,s,o=e[n++];o<128?t[r++]=String.fromCharCode(o):191<o&&o<224?(i=e[n++],t[r++]=String.fromCharCode((31&o)<<6|63&i)):239<o&&o<365?(s=((7&o)<<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))):(i=e[n++],s=e[n++],t[r++]=String.fromCharCode((15&o)<<12|(63&i)<<6|63&s))}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();var n=t?this.charToByteMapWebSafe_:this.charToByteMap_;const r=[];for(let c=0;c<e.length;){var i=n[e.charAt(c++)],s=c<e.length?n[e.charAt(c)]:0;++c;var o=c<e.length?n[e.charAt(c)]:64;++c;var a=c<e.length?n[e.charAt(c)]:64;if(++c,null==i||null==s||null==o||null==a)throw Error();r.push(i<<2|s>>4),64!==o&&(r.push(s<<4&240|o>>2),64!==a&&r.push(o<<6&192|a))}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)}}},ed=function(e){return Qh(e).replace(/\./g,"")},td=function(e){try{return Zh.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function nd(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:const n=t;return new Date(n.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(const r in t)t.hasOwnProperty(r)&&"__proto__"!==r&&(e[r]=nd(e[r],t[r]));return e}class rd{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(n){return(e,t)=>{e?this.reject(e):this.resolve(t),"function"==typeof n&&(this.promise.catch(()=>{}),1===n.length?n(e):n(e,t))}}}function id(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');var n=t||"demo-project",r=e.iat||0,i=e.sub||e.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");i=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[ed(JSON.stringify({alg:"none",type:"JWT"})),ed(JSON.stringify(i)),""].join(".")}function sd(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function od(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(sd())}function ad(){try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(e){return!1}}function cd(){var e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id}function ld(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function ud(){const e=sd();return 0<=e.indexOf("MSIE ")||0<=e.indexOf("Trident/")}function hd(){return!0===Yh.NODE_ADMIN}function dd(){return"object"==typeof indexedDB}function pd(){return new Promise((t,n)=>{try{let e=!0;const r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),e||self.indexedDB.deleteDatabase(r),t(!0)},i.onupgradeneeded=()=>{e=!1},i.onerror=()=>{var e;n((null===(e=i.error)||void 0===e?void 0:e.message)||"")}}catch(e){n(e)}})}function fd(){return!("undefined"==typeof navigator||!navigator.cookieEnabled)}class gd extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,gd.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,md.prototype.create)}}class md{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){var r,n=t[0]||{},i=`${this.service}/${e}`,s=this.errors[e],s=s?(r=n,s.replace(vd,(e,t)=>{var n=r[t];return null!=n?String(n):`<${t}?>`})):"Error",s=`${this.serviceName}: ${s} (${i}).`;return new gd(i,s,n)}}const vd=/\{\$([^}]+)}/g;function yd(e){return JSON.parse(e)}function _d(e){return JSON.stringify(e)}function wd(e){let t={},n={},r={},i="";try{var s=e.split(".");t=yd(td(s[0])||""),n=yd(td(s[1])||""),i=s[2],r=n.d||{},delete n.d}catch(e){}return{header:t,claims:n,data:r,signature:i}}function bd(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Td(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]}function Id(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function Ed(e,t,n){const r={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=t.call(n,e[i],i,e));return r}function kd(e,t){if(e===t)return 1;const n=Object.keys(e),r=Object.keys(t);for(const o of n){if(!r.includes(o))return;var i=e[o],s=t[o];if(Sd(i)&&Sd(s)){if(!kd(i,s))return}else if(i!==s)return}for(const a of r)if(!n.includes(a))return;return 1}function Sd(e){return null!==e&&"object"==typeof e}function Cd(e){const t=[];for(const[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 Ad(e){const r={},t=e.replace(/^\?/,"").split("&");return t.forEach(e=>{var t,n;e&&([t,n]=e.split("="),r[decodeURIComponent(t)]=decodeURIComponent(n))}),r}function Nd(e){var t=e.indexOf("?");if(!t)return"";var n=e.indexOf("#",t);return e.substring(t,0<n?n:void 0)}class Rd{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(let e=1;e<this.blockSize;++e)this.pad_[e]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(n,r){r=r||0;const i=this.W_;if("string"==typeof n)for(let e=0;e<16;e++)i[e]=n.charCodeAt(r)<<24|n.charCodeAt(r+1)<<16|n.charCodeAt(r+2)<<8|n.charCodeAt(r+3),r+=4;else for(let t=0;t<16;t++)i[t]=n[r]<<24|n[r+1]<<16|n[r+2]<<8|n[r+3],r+=4;for(let d=16;d<80;d++){var e=i[d-3]^i[d-8]^i[d-14]^i[d-16];i[d]=4294967295&(e<<1|e>>>31)}let t=this.chain_[0],s=this.chain_[1],o=this.chain_[2],a=this.chain_[3],c=this.chain_[4],l,u;for(let p=0;p<80;p++){u=p<40?p<20?(l=a^s&(o^a),1518500249):(l=s^o^a,1859775393):p<60?(l=s&o|a&(s|o),2400959708):(l=s^o^a,3395469782);var h=(t<<5|t>>>27)+l+c+u+i[p]&4294967295;c=a,a=o,o=4294967295&(s<<30|s>>>2),s=t,t=h}this.chain_[0]=this.chain_[0]+t&4294967295,this.chain_[1]=this.chain_[1]+s&4294967295,this.chain_[2]=this.chain_[2]+o&4294967295,this.chain_[3]=this.chain_[3]+a&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295}update(n,r){if(null!=n){var i=(r=void 0===r?n.length:r)-this.blockSize;let e=0;const s=this.buf_;let t=this.inbuf_;for(;e<r;){if(0===t)for(;e<=i;)this.compress_(n,e),e+=this.blockSize;if("string"==typeof n){for(;e<r;)if(s[t]=n.charCodeAt(e),++t,++e,t===this.blockSize){this.compress_(s),t=0;break}}else for(;e<r;)if(s[t]=n[e],++t,++e,t===this.blockSize){this.compress_(s),t=0;break}}this.inbuf_=t,this.total_+=r}}digest(){const t=[];let e=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let r=this.blockSize-1;56<=r;r--)this.buf_[r]=255&e,e/=256;this.compress_(this.buf_);let n=0;for(let i=0;i<5;i++)for(let e=24;0<=e;e-=8)t[n]=this.chain_[i]>>e&255,++n;return t}}function Pd(e,t){const n=new xd(e,t);return n.subscribe.bind(n)}class xd{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(t){this.forEachObserver(e=>{e.next(t)})}error(t){this.forEachObserver(e=>{e.error(t)}),this.close(t)}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 new Error("Missing Observer.");r=function(e,t){if("object"!=typeof e||null===e)return!1;for(const n of t)if(n in e&&"function"==typeof e[n])return!0;return!1}(e,["next","error","complete"])?e:{next:e,error:t,complete:n},void 0===r.next&&(r.next=Dd),void 0===r.error&&(r.error=Dd),void 0===r.complete&&(r.complete=Dd);var 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,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(t){if(!this.finalized)for(let e=0;e<this.observers.length;e++)this.sendOne(e,t)}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 Dd(){}function Od(e,t,n,r){let i;if(r<t?i="at least "+t:n<r&&(i=0===n?"none":"no more than "+n),i){var s=e+" failed: Was called with "+r+(1===r?" argument.":" arguments.")+" Expects "+i+".";throw new Error(s)}}function Md(e,t){return`${e} failed: ${t} argument `}function Ld(e,t,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(Md(e,t)+"must be a valid function.")}function Fd(e,t,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(Md(e,t)+"must be a valid context object.")}const Ud=function(e){let t=0;for(let r=0;r<e.length;r++){var n=e.charCodeAt(r);n<128?t++:n<2048?t+=2:55296<=n&&n<=56319?(t+=4,r++):t+=3}return t},jd=1e3,qd=2,Vd=144e5,Bd=.5;function Wd(e,t=jd,n=qd){var r=t*Math.pow(n,e),i=Math.round(Bd*r*(Math.random()-.5)*2);return Math.min(Vd,r+i)}function Kd(e){return e&&e._delegate?e._delegate:e}class $d{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}}const zd="[DEFAULT]";class Hd{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){var t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const r=new rd;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{var n=this.getOrInitializeService({instanceIdentifier:t});n&&r.resolve(n)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),n=null!==(n=null==e?void 0:e.optional)&&void 0!==n&&n;if(!this.isInitialized(t)&&!this.shouldAutoInitialize()){if(n)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:t})}catch(e){if(n)return null;throw e}}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:zd})}catch(e){}for(var[t,n]of this.instancesDeferred.entries()){t=this.normalizeInstanceIdentifier(t);try{var r=this.getOrInitializeService({instanceIdentifier:t});n.resolve(r)}catch(e){}}}}clearInstance(e=zd){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(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=zd){return this.instances.has(e)}getOptions(e=zd){return this.instancesOptions.get(e)||{}}initialize(e={}){var{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`);var r,i,s=this.getOrInitializeService({instanceIdentifier:n,options:t});for([r,i]of this.instancesDeferred.entries())n===this.normalizeInstanceIdentifier(r)&&i.resolve(s);return s}onInit(e,t){var n=this.normalizeInstanceIdentifier(t);const r=null!==(i=this.onInitCallbacks.get(n))&&void 0!==i?i:new Set;r.add(e),this.onInitCallbacks.set(n,r);var i=this.instances.get(n);return i&&e(i,n),()=>{r.delete(e)}}invokeOnInitCallbacks(e,t){var n=this.onInitCallbacks.get(t);if(n)for(const 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:(r=e)===zd?void 0:r,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){}var r;return n||null}normalizeInstanceIdentifier(e=zd){return!this.component||this.component.multipleInstances?e:zd}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class Gd{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){const t=this.getProvider(e.name);t.isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);var t=new Hd(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}const Qd=[];($h=Kh=Kh||{})[$h.DEBUG=0]="DEBUG",$h[$h.VERBOSE=1]="VERBOSE",$h[$h.INFO=2]="INFO",$h[$h.WARN=3]="WARN",$h[$h.ERROR=4]="ERROR",$h[$h.SILENT=5]="SILENT";const Yd={debug:Kh.DEBUG,verbose:Kh.VERBOSE,info:Kh.INFO,warn:Kh.WARN,error:Kh.ERROR,silent:Kh.SILENT},Jd=Kh.INFO,Xd={[Kh.DEBUG]:"log",[Kh.VERBOSE]:"log",[Kh.INFO]:"info",[Kh.WARN]:"warn",[Kh.ERROR]:"error"},Zd=(e,t,...n)=>{if(!(t<e.logLevel)){var r=(new Date).toISOString(),i=Xd[t];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[i](`[${r}] ${e.name}:`,...n)}};class ep{constructor(e){this.name=e,this._logLevel=Jd,this._logHandler=Zd,this._userLogHandler=null,Qd.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in Kh))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?Yd[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,Kh.DEBUG,...e),this._logHandler(this,Kh.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,Kh.VERBOSE,...e),this._logHandler(this,Kh.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,Kh.INFO,...e),this._logHandler(this,Kh.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,Kh.WARN,...e),this._logHandler(this,Kh.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,Kh.ERROR,...e),this._logHandler(this,Kh.ERROR,...e)}}class tp{constructor(e){this.container=e}getPlatformInfoString(){const e=this.container.getProviders();return e.map(e=>{if("VERSION"!==(null==(t=e.getComponent())?void 0:t.type))return null;var t,t=e.getImmediate();return`${t.library}/${t.version}`}).filter(e=>e).join(" ")}}const np="@firebase/app",rp=new ep("@firebase/app");var ip;const sp="[DEFAULT]",op={"@firebase/app":"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/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","fire-js":"fire-js",firebase:"fire-js-all"},ap=new Map,cp=new Map;function lp(t,n){try{t.container.addComponent(n)}catch(e){rp.debug(`Component ${n.name} failed to register with FirebaseApp ${t.name}`,e)}}function up(e,t){e.container.addOrOverwriteComponent(t)}function hp(e){var t=e.name;if(cp.has(t))return rp.debug(`There were multiple attempts to register component ${t}.`),!1;cp.set(t,e);for(const n of ap.values())lp(n,e);return!0}function dp(e,t){return e.container.getProvider(t)}const pp=new md("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()","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","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."});class fp{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 $d("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 pp.create("app-deleted",{appName:this._name})}}const gp="9.6.2";function mp(e,t={}){if("object"!=typeof t){const r=t;t={name:r}}var n=Object.assign({name:sp,automaticDataCollectionEnabled:!1},t);const r=n.name;if("string"!=typeof r||!r)throw pp.create("bad-app-name",{appName:String(r)});var i=ap.get(r);if(i){if(kd(e,i.options)&&kd(n,i.config))return i;throw pp.create("duplicate-app",{appName:r})}const s=new Gd(r);for(const o of cp.values())s.addComponent(o);n=new fp(e,n,s);return ap.set(r,n),n}function vp(e=sp){var t=ap.get(e);if(!t)throw pp.create("no-app",{appName:e});return t}async function yp(e){var t=e.name;ap.has(t)&&(ap.delete(t),await Promise.all(e.container.getProviders().map(e=>e.delete())),e.isDeleted=!0)}function _p(e,t,n){let r=null!==(s=op[e])&&void 0!==s?s:e;n&&(r+=`-${n}`);var i=r.match(/\s|\//),s=t.match(/\s|\//);if(i||s){const o=[`Unable to register library "${r}" with version "${t}":`];return i&&o.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&s&&o.push("and"),s&&o.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void rp.warn(o.join(" "))}hp(new $d(`${r}-version`,()=>({library:r,version:t}),"VERSION"))}function wp(e,t){if(null!==e&&"function"!=typeof e)throw pp.create("invalid-log-argument");!function(s,e){for(const t of Qd){let i=null;e&&e.level&&(i=Yd[e.level]),t.userLogHandler=null===s?null:(e,t,...n)=>{var r=n.map(e=>{if(null==e)return null;if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e)return e.toString();if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch(e){return null}}).filter(e=>e).join(" ");t>=(null!==i&&void 0!==i?i:e.logLevel)&&s({level:Kh[t].toLowerCase(),message:r,args:n,type:e.name})}}}(e,t)}function bp(e){var t;t=e,Qd.forEach(e=>{e.setLogLevel(t)})}ip="",hp(new $d("platform-logger",e=>new tp(e),"PRIVATE")),_p(np,"0.7.12",ip),_p(np,"0.7.12","esm2017"),_p("fire-js","");var Tp=Object.freeze({__proto__:null,SDK_VERSION:gp,_DEFAULT_ENTRY_NAME:sp,_addComponent:lp,_addOrOverwriteComponent:up,_apps:ap,_clearComponents:function(){cp.clear()},_components:cp,_getProvider:dp,_registerComponent:hp,_removeServiceInstance:function(e,t,n=sp){dp(e,t).clearInstance(n)},deleteApp:yp,getApp:vp,getApps:function(){return Array.from(ap.values())},initializeApp:mp,onLog:wp,registerVersion:_p,setLogLevel:bp,FirebaseError:gd});class Ip{constructor(e,t){this._delegate=e,this.firebase=t,lp(e,new $d("app-compat",()=>this,"PUBLIC")),this.container=e.container}get automaticDataCollectionEnabled(){return this._delegate.automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this._delegate.automaticDataCollectionEnabled=e}get name(){return this._delegate.name}get options(){return this._delegate.options}delete(){return new Promise(e=>{this._delegate.checkDestroyed(),e()}).then(()=>(this.firebase.INTERNAL.removeApp(this.name),yp(this._delegate)))}_getService(e,t=sp){var n;this._delegate.checkDestroyed();const r=this._delegate.container.getProvider(e);return r.isInitialized()||"EXPLICIT"!==(null===(n=r.getComponent())||void 0===n?void 0:n.instantiationMode)||r.initialize(),r.getImmediate({identifier:t})}_removeServiceInstance(e,t=sp){this._delegate.container.getProvider(e).clearInstance(t)}_addComponent(e){lp(this._delegate,e)}_addOrOverwriteComponent(e){up(this._delegate,e)}toJSON(){return{name:this.name,automaticDataCollectionEnabled:this.automaticDataCollectionEnabled,options:this.options}}}const Ep=new md("app-compat","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance."});function kp(i){const s={},o={__esModule:!0,initializeApp:function(e,t={}){var n=mp(e,t);if(bd(s,n.name))return s[n.name];var r=new i(n,o);return s[n.name]=r},app:a,registerVersion:_p,setLogLevel:bp,onLog:wp,apps:null,SDK_VERSION:gp,INTERNAL:{registerComponent:function(n){const r=n.name,t=r.replace("-compat","");{var e;hp(n)&&"PUBLIC"===n.type&&(e=(e=a())=>{if("function"!=typeof e[t])throw Ep.create("invalid-app-argument",{appName:r});return e[t]()},void 0!==n.serviceProps&&nd(e,n.serviceProps),o[t]=e,i.prototype[t]=function(...e){const t=this._getService.bind(this,r);return t.apply(this,n.multipleInstances?e:[])})}return"PUBLIC"===n.type?o[t]:null},removeApp:function(e){delete s[e]},useAsService:function(e,t){if("serverAuth"===t)return null;var n=t;return n},modularAPIs:Tp}};function a(e){if(e=e||sp,!bd(s,e))throw Ep.create("no-app",{appName:e});return s[e]}return o.default=o,Object.defineProperty(o,"apps",{get:function(){return Object.keys(s).map(e=>s[e])}}),a.App=i,o}l=function e(){const t=kp(Ip);return t.INTERNAL=Object.assign(Object.assign({},t.INTERNAL),{createFirebaseNamespace:e,extendNamespace:function(e){nd(t,e)},createSubscribe:Pd,ErrorFactory:md,deepExtend:nd}),t}();const Sp=new ep("@firebase/app-compat");if("object"==typeof self&&self.self===self&&void 0!==self.firebase){Sp.warn(`
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).firebase=t()}(this,function(){"use strict";!function(e){var t,n,o,r,i,s,a,c,l,u;function h(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function d(e){return e="string"!=typeof e?String(e):e}function p(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function f(t){this.map={},t instanceof f?t.forEach(function(e,t){this.append(t,e)},this):Array.isArray(t)?t.forEach(function(e){this.append(e[0],e[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function g(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function m(n){return new Promise(function(e,t){n.onload=function(){e(n.result)},n.onerror=function(){t(n.error)}})}function v(e){var t=new FileReader,n=m(t);return t.readAsArrayBuffer(e),n}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function _(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e)if("string"==typeof e)this._bodyText=e;else if(o&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(r&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(i&&o&&a(e))this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!i||!ArrayBuffer.prototype.isPrototypeOf(e)&&!c(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=y(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var e=g(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?g(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var e,t,n=g(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=m(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}function w(e,t){var n,r=(t=t||{}).body;if(e instanceof w){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new f(e.headers)),this.method=e.method,this.mode=e.mode,r||null==e._bodyInit||(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"omit",!t.headers&&this.headers||(this.headers=new f(t.headers)),this.method=(e=t.method||this.method||"GET",n=e.toUpperCase(),-1<l.indexOf(n)?n:e),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function b(e){var r=new FormData;return e.trim().split("&").forEach(function(e){var t,n;e&&(t=(n=e.split("=")).shift().replace(/\+/g," "),n=n.join("=").replace(/\+/g," "),r.append(decodeURIComponent(t),decodeURIComponent(n)))}),r}function I(e,t){t=t||{},this.type="default",this.status=void 0===t.status?200:t.status,this.ok=200<=this.status&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}e.fetch||(t="URLSearchParams"in e,n="Symbol"in e&&"iterator"in Symbol,o="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),r="FormData"in e,(i="ArrayBuffer"in e)&&(s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=function(e){return e&&DataView.prototype.isPrototypeOf(e)},c=ArrayBuffer.isView||function(e){return e&&-1<s.indexOf(Object.prototype.toString.call(e))}),f.prototype.append=function(e,t){e=h(e),t=d(t);var n=this.map[e];this.map[e]=n?n+","+t:t},f.prototype.delete=function(e){delete this.map[h(e)]},f.prototype.get=function(e){return e=h(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(h(e))},f.prototype.set=function(e,t){this.map[h(e)]=d(t)},f.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},f.prototype.keys=function(){var n=[];return this.forEach(function(e,t){n.push(t)}),p(n)},f.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),p(t)},f.prototype.entries=function(){var n=[];return this.forEach(function(e,t){n.push([t,e])}),p(n)},n&&(f.prototype[Symbol.iterator]=f.prototype.entries),l=["DELETE","GET","HEAD","OPTIONS","POST","PUT"],w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},_.call(w.prototype),_.call(I.prototype),I.prototype.clone=function(){return new I(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},I.error=function(){var e=new I(null,{status:0,statusText:""});return e.type="error",e},u=[301,302,303,307,308],I.redirect=function(e,t){if(-1===u.indexOf(t))throw new RangeError("Invalid status code");return new I(null,{status:t,headers:{location:e}})},e.Headers=f,e.Request=w,e.Response=I,e.fetch=function(n,r){return new Promise(function(i,e){var t=new w(n,r),s=new XMLHttpRequest;s.onload=function(){var e,r,t={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",r=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var t=e.split(":"),n=t.shift().trim();n&&(t=t.join(":").trim(),r.append(n,t))}),r)};t.url="responseURL"in s?s.responseURL:t.headers.get("X-Request-URL");var n="response"in s?s.response:s.responseText;i(new I(n,t))},s.onerror=function(){e(new TypeError("Network request failed"))},s.ontimeout=function(){e(new TypeError("Network request failed"))},s.open(t.method,t.url,!0),"include"===t.credentials?s.withCredentials=!0:"omit"===t.credentials&&(s.withCredentials=!1),"responseType"in s&&o&&(s.responseType="blob"),t.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),s.send(void 0===t._bodyInit?null:t._bodyInit)})},e.fetch.polyfill=!0)}("undefined"!=typeof self?self:void 0);function e(e){try{return!!e()}catch(e){return!0}}function t(e){if(!g(e))throw TypeError(String(e)+" is not an object");return e}var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r=function(e){return e&&e.Math==Math&&e},i=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof n&&n)||Function("return this")(),s={exports:{}},o=!e(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),a={},c=function(e){return"object"==typeof e?null!==e:"function"==typeof e},l=c,u=i.document,h=l(u)&&l(u.createElement),d=function(e){return h?u.createElement(e):{}},p=d,f=!o&&!e(function(){return 7!=Object.defineProperty(p("div"),"a",{get:function(){return 7}}).a}),g=c,m=c,v=function(e,t){if(!m(e))return e;var n,r;if(t&&"function"==typeof(n=e.toString)&&!m(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!m(r=n.call(e)))return r;if(!t&&"function"==typeof(n=e.toString)&&!m(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")},y=f,_=t,w=v,b=Object.defineProperty;a.f=o?b:function(e,t,n){if(_(e),t=w(t,!0),_(n),y)try{return b(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var I=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},T=a,E=I,k=o?function(e,t,n){return T.f(e,t,E(1,n))}:function(e,t,n){return e[t]=n,e},S=i,C=k,A=function(t,n){try{C(S,t,n)}catch(e){S[t]=n}return n},N=A,R="__core-js_shared__",P=i[R]||N(R,{}),x=P;(s.exports=function(e,t){return x[e]||(x[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"});function D(e,t){return M.call(e,t)}function O(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++L+F).toString(36)}var M={}.hasOwnProperty,L=0,F=Math.random(),U=e,j=!!Object.getOwnPropertySymbols&&!U(function(){return!String(Symbol())}),q=j&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,V=i,B=s.exports,W=D,$=O,K=j,z=q,H=B("wks"),G=V.Symbol,Q=z?G:G&&G.withoutSetter||$,Y=function(e){return W(H,e)||(K&&W(G,e)?H[e]=G[e]:H[e]=Q("Symbol."+e)),H[e]},J={};J[Y("toStringTag")]="z";var X="[object z]"===String(J),Z={exports:{}},ee=P,te=Function.toString;"function"!=typeof ee.inspectSource&&(ee.inspectSource=function(e){return te.call(e)});var ne,re,ie,se,oe,ae,ce,le,ue=ee.inspectSource,he=ue,de=i.WeakMap,pe="function"==typeof de&&/native code/.test(he(de)),fe=s.exports,ge=O,me=fe("keys"),ve=function(e){return me[e]||(me[e]=ge(e))},ye={},_e=c,we=k,be=D,Ie=ve,Te=ye,Ee=i.WeakMap;ce=pe?(ne=new Ee,re=ne.get,ie=ne.has,se=ne.set,oe=function(e,t){return se.call(ne,e,t),t},ae=function(e){return re.call(ne,e)||{}},function(e){return ie.call(ne,e)}):(Te[le=Ie("state")]=!0,oe=function(e,t){return we(e,le,t),t},ae=function(e){return be(e,le)?e[le]:{}},function(e){return be(e,le)});var ke={set:oe,get:ae,has:ce,enforce:function(e){return ce(e)?ae(e):oe(e,{})},getterFor:function(n){return function(e){var t;if(!_e(e)||(t=ae(e)).type!==n)throw TypeError("Incompatible receiver, "+n+" required");return t}}},Se=i,Ce=k,Ae=D,Ne=A,Re=ue,Pe=ke.get,xe=ke.enforce,De=String(String).split("String");(Z.exports=function(e,t,n,r){var i=!!r&&!!r.unsafe,s=!!r&&!!r.enumerable,o=!!r&&!!r.noTargetGet;"function"==typeof n&&("string"!=typeof t||Ae(n,"name")||Ce(n,"name",t),xe(n).source=De.join("string"==typeof t?t:"")),e!==Se?(i?!o&&e[t]&&(s=!0):delete e[t],s?e[t]=n:Ce(e,t,n)):s?e[t]=n:Ne(t,n)})(Function.prototype,"toString",function(){return"function"==typeof this&&Pe(this).source||Re(this)});var Oe={}.toString,Me=function(e){return Oe.call(e).slice(8,-1)},Le=X,Fe=Me,Ue=Y("toStringTag"),je="Arguments"==Fe(function(){return arguments}()),qe=Le?Fe:function(e){var t,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),Ue))?n:je?Fe(t):"Object"==(n=Fe(t))&&"function"==typeof t.callee?"Arguments":n},Ve=qe,Be=Z.exports;X||Be(Object.prototype,"toString",X?{}.toString:function(){return"[object "+Ve(this)+"]"},{unsafe:!0});var We=Math.ceil,$e=Math.floor,Ke=function(e){return isNaN(e=+e)?0:(0<e?$e:We)(e)},ze=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},He=Ke,Ge=ze,Qe=function(a){return function(e,t){var n,r,i=String(Ge(e)),s=He(t),o=i.length;return s<0||o<=s?a?"":void 0:(n=i.charCodeAt(s))<55296||56319<n||s+1===o||(r=i.charCodeAt(s+1))<56320||57343<r?a?i.charAt(s):n:a?i.slice(s,s+2):r-56320+(n-55296<<10)+65536}},Ye={codeAt:Qe(!1),charAt:Qe(!0)},Je={},Xe={},Ze={}.propertyIsEnumerable,et=Object.getOwnPropertyDescriptor,tt=et&&!Ze.call({1:2},1);Xe.f=tt?function(e){var t=et(this,e);return!!t&&t.enumerable}:Ze;function nt(e){return at(ct(e))}var rt=e,it=Me,st="".split,ot=rt(function(){return!Object("z").propertyIsEnumerable(0)})?function(e){return"String"==it(e)?st.call(e,""):Object(e)}:Object,at=ot,ct=ze,lt=Xe,ut=I,ht=nt,dt=v,pt=D,ft=f,gt=Object.getOwnPropertyDescriptor;Je.f=o?gt:function(e,t){if(e=ht(e),t=dt(t,!0),ft)try{return gt(e,t)}catch(e){}if(pt(e,t))return ut(!lt.f.call(e,t),e[t])};function mt(e){return"function"==typeof e?e:void 0}function vt(e,t){return arguments.length<2?mt(_t[e])||mt(wt[e]):_t[e]&&_t[e][t]||wt[e]&&wt[e][t]}var yt=i,_t=yt,wt=i,bt={},It=Ke,Tt=Math.min,Et=function(e){return 0<e?Tt(It(e),9007199254740991):0},kt=Ke,St=Math.max,Ct=Math.min,At=nt,Nt=Et,Rt=function(e,t){var n=kt(e);return n<0?St(n+t,0):Ct(n,t)},Pt=function(a){return function(e,t,n){var r,i=At(e),s=Nt(i.length),o=Rt(n,s);if(a&&t!=t){for(;o<s;)if((r=i[o++])!=r)return!0}else for(;o<s;o++)if((a||o in i)&&i[o]===t)return a||o||0;return!a&&-1}},r={includes:Pt(!0),indexOf:Pt(!1)},xt=D,Dt=nt,Ot=r.indexOf,Mt=ye,n=function(e,t){var n,r=Dt(e),i=0,s=[];for(n in r)!xt(Mt,n)&&xt(r,n)&&s.push(n);for(;t.length>i;)xt(r,n=t[i++])&&(~Ot(s,n)||s.push(n));return s},l=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Lt=n,Ft=l.concat("length","prototype");bt.f=Object.getOwnPropertyNames||function(e){return Lt(e,Ft)};N={};N.f=Object.getOwnPropertySymbols;var Ut=bt,jt=N,qt=t,R=vt("Reflect","ownKeys")||function(e){var t=Ut.f(qt(e)),n=jt.f;return n?t.concat(n(e)):t},Vt=D,Bt=R,Wt=Je,$t=a,U=function(e,t){for(var n=Bt(t),r=$t.f,i=Wt.f,s=0;s<n.length;s++){var o=n[s];Vt(e,o)||r(e,o,i(t,o))}},Kt=e,zt=/#|\.prototype\./,B=function(e,t){var n=Gt[Ht(e)];return n==Yt||n!=Qt&&("function"==typeof t?Kt(t):!!t)},Ht=B.normalize=function(e){return String(e).replace(zt,".").toLowerCase()},Gt=B.data={},Qt=B.NATIVE="N",Yt=B.POLYFILL="P",V=B,Jt=i,Xt=Je.f,Zt=k,en=Z.exports,tn=A,nn=U,rn=V,z=function(e,t){var n,r,i,s=e.target,o=e.global,a=e.stat,c=o?Jt:a?Jt[s]||tn(s,{}):(Jt[s]||{}).prototype;if(c)for(n in t){if(r=t[n],i=e.noTargetGet?(i=Xt(c,n))&&i.value:c[n],!rn(o?n:s+(a?".":"#")+n,e.forced)&&void 0!==i){if(typeof r==typeof i)continue;nn(r,i)}(e.sham||i&&i.sham)&&Zt(r,"sham",!0),en(c,n,r,e)}},sn=ze,$=function(e){return Object(sn(e))},J=!e(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),on=D,an=$,P=J,cn=ve("IE_PROTO"),ln=Object.prototype,ee=P?Object.getPrototypeOf:function(e){return e=an(e),on(e,cn)?e[cn]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?ln:null},he=ee,de=k,fe=D,pe=Y("iterator"),Ee=!1;[].keys&&("next"in(or=[].keys())?(ar=he(he(or)))!==Object.prototype&&(Er=ar):Ee=!0),fe(Er=null==Er?{}:Er,pe)||de(Er,pe,function(){return this});function un(){}var hn,Te={IteratorPrototype:Er,BUGGY_SAFARI_ITERATORS:Ee},dn=n,pn=l,Ie=Object.keys||function(e){return dn(e,pn)},fn=a,gn=t,mn=Ie,Le=o?Object.defineProperties:function(e,t){gn(e);for(var n,r=mn(t),i=r.length,s=0;s<i;)fn.f(e,n=r[s++],t[n]);return e},Be=vt("document","documentElement"),vn=t,yn=Le,_n=l,X=ye,wn=Be,bn=d,In="prototype",Tn="script",En=ve("IE_PROTO"),kn=function(e){return"<"+Tn+">"+e+"</"+Tn+">"},Sn=function(){try{hn=document.domain&&new ActiveXObject("htmlfile")}catch(e){}var e,t;Sn=hn?function(e){e.write(kn("")),e.close();var t=e.parentWindow.Object;return e=null,t}(hn):(e=bn("iframe"),t="java"+Tn+":",e.style.display="none",wn.appendChild(e),e.src=String(t),(e=e.contentWindow.document).open(),e.write(kn("document.F=Object")),e.close(),e.F);for(var n=_n.length;n--;)delete Sn[In][_n[n]];return Sn()};X[En]=!0;function Cn(){return this}function An(){return this}var Qe=Object.create||function(e,t){var n;return null!==e?(un[In]=vn(e),n=new un,un[In]=null,n[En]=e):n=Sn(),void 0===t?n:yn(n,t)},Nn=a.f,Rn=D,Pn=Y("toStringTag"),tt=function(e,t,n){e&&!Rn(e=n?e:e.prototype,Pn)&&Nn(e,Pn,{configurable:!0,value:t})},Ze={},xn=Te.IteratorPrototype,Dn=Qe,On=I,Mn=tt,Ln=Ze,Fn=c,Un=t,jn=function(e){if(!Fn(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype");return e},rt=Object.setPrototypeOf||("__proto__"in{}?function(){var n,r=!1,e={};try{(n=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(e,[]),r=e instanceof Array}catch(e){}return function(e,t){return Un(e),jn(t),r?n.call(e,t):e.__proto__=t,e}}():void 0),qn=z,Vn=function(e,t,n){var r=t+" Iterator";return e.prototype=Dn(xn,{next:On(1,n)}),Mn(e,r,!1),Ln[r]=Cn,e},Bn=ee,Wn=rt,$n=tt,Kn=k,zn=Z.exports,f=Y,Hn=Ze,Gn=Te.IteratorPrototype,Qn=Te.BUGGY_SAFARI_ITERATORS,Yn=f("iterator"),Jn="values",Xn="entries",Pt=function(e,t,n,r,i,s,o){Vn(n,t,r);function a(e){if(e===i&&f)return f;if(!Qn&&e in d)return d[e];switch(e){case"keys":case Jn:case Xn:return function(){return new n(this,e)}}return function(){return new n(this)}}var c,l,u=t+" Iterator",h=!1,d=e.prototype,p=d[Yn]||d["@@iterator"]||i&&d[i],f=!Qn&&p||a(i),g="Array"==t&&d.entries||p;if(g&&(g=Bn(g.call(new e)),Gn!==Object.prototype&&g.next&&(Bn(g)!==Gn&&(Wn?Wn(g,Gn):"function"!=typeof g[Yn]&&Kn(g,Yn,An)),$n(g,u,!0))),i==Jn&&p&&p.name!==Jn&&(h=!0,f=function(){return p.call(this)}),d[Yn]!==f&&Kn(d,Yn,f),Hn[t]=f,i)if(c={values:a(Jn),keys:s?f:a("keys"),entries:a(Xn)},o)for(l in c)!Qn&&!h&&l in d||zn(d,l,c[l]);else qn({target:t,proto:!0,forced:Qn||h},c);return c},Zn=Ye.charAt,r=ke,R=Pt,er="String Iterator",tr=r.set,nr=r.getterFor(er);R(String,"String",function(e){tr(this,{type:er,string:String(e),index:0})},function(){var e=nr(this),t=e.string,n=e.index;return n>=t.length?{value:void 0,done:!0}:(n=Zn(t,n),e.index+=n.length,{value:n,done:!1})});var B=Qe,A=a,rr=Y("unscopables"),ir=Array.prototype;null==ir[rr]&&A.f(ir,rr,{configurable:!0,value:B(null)});var J=function(e){ir[rr][e]=!0},sr=nt,P=J,he=Ze,or=ke,ar=Pt,cr="Array Iterator",lr=or.set,ur=or.getterFor(cr),fe=ar(Array,"Array",function(e,t){lr(this,{type:cr,target:sr(e),index:0,kind:t})},function(){var e=ur(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?{value:e.target=void 0,done:!0}:"keys"==n?{value:r,done:!1}:"values"==n?{value:t[r],done:!1}:{value:[r,t[r]],done:!1}},"values");he.Arguments=he.Array,P("keys"),P("values"),P("entries");var hr,dr=i,pr={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},fr=fe,gr=k,de=Y,mr=de("iterator"),vr=de("toStringTag"),yr=fr.values;for(hr in pr){var _r=dr[hr],wr=_r&&_r.prototype;if(wr){if(wr[mr]!==yr)try{gr(wr,mr,yr)}catch(fb){wr[mr]=yr}if(wr[vr]||gr(wr,vr,hr),pr[hr])for(var br in fr)if(wr[br]!==fr[br])try{gr(wr,br,fr[br])}catch(fb){wr[br]=fr[br]}}}function Ir(e,t){this.stopped=e,this.result=t}var pe=i.Promise,Tr=Z.exports,Er=function(e,t,n){for(var r in t)Tr(e,r,t[r],n);return e},kr=vt,Sr=a,Cr=o,Ar=Y("species"),Ee=function(e){var t=kr(e),n=Sr.f;Cr&&t&&!t[Ar]&&n(t,Ar,{configurable:!0,get:function(){return this}})},n=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e},Le=function(e,t,n){if(!(e instanceof t))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return e},l={exports:{}},Nr=Ze,Rr=Y("iterator"),Pr=Array.prototype,X=function(e){return void 0!==e&&(Nr.Array===e||Pr[Rr]===e)},xr=n,Te=function(r,i,e){if(xr(r),void 0===i)return r;switch(e){case 0:return function(){return r.call(i)};case 1:return function(e){return r.call(i,e)};case 2:return function(e,t){return r.call(i,e,t)};case 3:return function(e,t,n){return r.call(i,e,t,n)}}return function(){return r.apply(i,arguments)}},Dr=qe,Or=Ze,Mr=Y("iterator"),f=function(e){if(null!=e)return e[Mr]||e["@@iterator"]||Or[Dr(e)]},Lr=t,Ye=function(t,e,n,r){try{return r?e(Lr(n)[0],n[1]):e(n)}catch(e){var i=t.return;throw void 0!==i&&Lr(i.call(t)),e}},Fr=t,Ur=X,jr=Et,qr=Te,Vr=f,Br=Ye;(l.exports=function(e,t,n,r,i){var s,o,a,c,l,u,h,d=qr(t,n,r?2:1);if(i)s=e;else{if("function"!=typeof(o=Vr(e)))throw TypeError("Target is not iterable");if(Ur(o)){for(a=0,c=jr(e.length);a<c;a++)if((l=r?d(Fr(h=e[a])[0],h[1]):d(e[a]))&&l instanceof Ir)return l;return new Ir(!1)}s=o.call(e)}for(u=s.next;!(h=u.call(s)).done;)if("object"==typeof(l=Br(s,d,h.value,r))&&l&&l instanceof Ir)return l;return new Ir(!1)}).stop=function(e){return new Ir(!0,e)};var Wr=Y("iterator"),$r=!1;try{var Kr=0,zr={next:function(){return{done:!!Kr++}},return:function(){$r=!0}};zr[Wr]=function(){return this},Array.from(zr,function(){throw 2})}catch(fb){}function Hr(e){return function(){ai(e)}}var Gr,r=function(e,t){if(!t&&!$r)return!1;var n=!1;try{var r={};r[Wr]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(e){}return n},Qr=t,Yr=n,Jr=Y("species"),R=function(e,t){var n,r=Qr(e).constructor;return void 0===r||null==(n=Qr(r)[Jr])?t:Yr(n)},A=vt("navigator","userAgent")||"",B=/(iphone|ipod|ipad).*applewebkit/i.test(A),Xr=i,or=e,ar=Me,he=Te,Zr=Be,ei=d,P=B,ti=Xr.location,de=Xr.setImmediate,Ze=Xr.clearImmediate,ni=Xr.process,zr=Xr.MessageChannel,ri=Xr.Dispatch,ii=0,si={},oi="onreadystatechange",ai=function(e){var t;si.hasOwnProperty(e)&&(t=si[e],delete si[e],t())},Be=function(e){ai(e.data)},d=function(e){Xr.postMessage(e+"",ti.protocol+"//"+ti.host)};de&&Ze||(de=function(e){for(var t=[],n=1;n<arguments.length;)t.push(arguments[n++]);return si[++ii]=function(){("function"==typeof e?e:Function(e)).apply(void 0,t)},Gr(ii),ii},Ze=function(e){delete si[e]},"process"==ar(ni)?Gr=function(e){ni.nextTick(Hr(e))}:ri&&ri.now?Gr=function(e){ri.now(Hr(e))}:zr&&!P?(wi=(yi=new zr).port2,yi.port1.onmessage=Be,Gr=he(wi.postMessage,wi,1)):!Xr.addEventListener||"function"!=typeof postMessage||Xr.importScripts||or(d)||"file:"===ti.protocol?Gr=oi in ei("script")?function(e){Zr.appendChild(ei("script"))[oi]=function(){Zr.removeChild(this),ai(e)}}:function(e){setTimeout(Hr(e),0)}:(Gr=d,Xr.addEventListener("message",Be,!1)));var ci,li,ui,hi,di,pi,fi,gi,ar={set:de,clear:Ze},mi=i,P=Je.f,zr=Me,vi=ar.set,yi=B,he=mi.MutationObserver||mi.WebKitMutationObserver,_i=mi.process,wi=mi.Promise,bi="process"==zr(_i),or=P(mi,"queueMicrotask"),d=or&&or.value;d||(ci=function(){var e,t;for(bi&&(e=_i.domain)&&e.exit();li;){t=li.fn,li=li.next;try{t()}catch(e){throw li?hi():ui=void 0,e}}ui=void 0,e&&e.enter()},hi=bi?function(){_i.nextTick(ci)}:he&&!yi?(di=!0,pi=document.createTextNode(""),new he(ci).observe(pi,{characterData:!0}),function(){pi.data=di=!di}):wi&&wi.resolve?(fi=wi.resolve(void 0),gi=fi.then,function(){gi.call(fi,ci)}):function(){vi.call(mi,ci)});function Ii(e){var n,r;this.promise=new e(function(e,t){if(void 0!==n||void 0!==r)throw TypeError("Bad Promise constructor");n=e,r=t}),this.resolve=Ti(n),this.reject=Ti(r)}var Be=d||function(e){var t={fn:e,next:void 0};ui&&(ui.next=t),li||(li=t,hi()),ui=t},de={},Ti=n;de.f=function(e){return new Ii(e)};var Ei=t,ki=c,Si=de,Ze=function(e,t){if(Ei(e),ki(t)&&t.constructor===e)return t;var n=Si.f(e);return(0,n.resolve)(t),n.promise},Ci=i,B=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},zr=A,P=i.process,or=P&&P.versions,yi=or&&or.v8;yi?ji=(Li=yi.split("."))[0]+Li[1]:zr&&(!(Li=zr.match(/Edge\/(\d+)/))||74<=Li[1])&&(Li=zr.match(/Chrome\/(\d+)/))&&(ji=Li[1]);var Ai,Ni,Ri,Pi,he=ji&&+ji,wi=z,xi=i,d=vt,A=pe,P=Z.exports,or=Er,yi=tt,zr=Ee,Di=c,Oi=n,Mi=Le,Li=Me,Fi=ue,Ui=l.exports,ji=r,qi=R,Vi=ar.set,Bi=Be,Wi=Ze,$i=function(e,t){var n=Ci.console;n&&n.error&&(1===arguments.length?n.error(e):n.error(e,t))},ue=de,Ki=B,ar=ke,Be=V,zi=he,Hi=Y("species"),Gi="Promise",Qi=ar.get,Yi=ar.set,Ji=ar.getterFor(Gi),Xi=A,Zi=xi.TypeError,es=xi.document,ts=xi.process,ns=d("fetch"),rs=ue.f,is=rs,ss="process"==Li(ts),os=!!(es&&es.createEvent&&xi.dispatchEvent),as="unhandledrejection",cs="rejectionhandled",ls=1,us=2,hs=1,ds=2,Be=Be(Gi,function(){if(!(Fi(Xi)!==String(Xi))){if(66===zi)return!0;if(!ss&&"function"!=typeof PromiseRejectionEvent)return!0}if(51<=zi&&/native code/.test(Xi))return!1;function e(e){e(function(){},function(){})}var t=Xi.resolve(1);return(t.constructor={})[Hi]=e,!(t.then(function(){})instanceof e)}),ji=Be||!ji(function(e){Xi.all(e).catch(function(){})}),ps=function(e){var t;return!(!Di(e)||"function"!=typeof(t=e.then))&&t},fs=function(p,f,g){var m;f.notified||(f.notified=!0,m=f.reactions,Bi(function(){for(var r,i,e=f.value,t=f.state==ls,n=0;m.length>n;){var s,o,a,c=m[n++],l=t?c.ok:c.fail,u=c.resolve,h=c.reject,d=c.domain;try{l?(t||(f.rejection===ds&&function(e,t){Vi.call(xi,function(){if(ss)ts.emit("rejectionHandled",e);else gs(cs,e,t.value)})}(p,f),f.rejection=hs),!0===l?s=e:(d&&d.enter(),s=l(e),d&&(d.exit(),a=!0)),s===c.promise?h(Zi("Promise-chain cycle")):(o=ps(s))?o.call(s,u,h):u(s)):h(e)}catch(e){d&&!a&&d.exit(),h(e)}}f.reactions=[],f.notified=!1,g&&!f.rejection&&(r=p,i=f,Vi.call(xi,function(){var e,t=i.value,n=ms(i);if(n&&(e=Ki(function(){ss?ts.emit("unhandledRejection",t,r):gs(as,r,t)}),i.rejection=ss||ms(i)?ds:hs,e.error))throw e.value}))}))},gs=function(e,t,n){var r,i;os?((r=es.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),xi.dispatchEvent(r)):r={promise:t,reason:n},(i=xi["on"+e])?i(r):e===as&&$i("Unhandled promise rejection",n)},ms=function(e){return e.rejection!==hs&&!e.parent},vs=function(t,n,r,i){return function(e){t(n,r,e,i)}},ys=function(e,t,n,r){t.done||(t.done=!0,(t=r?r:t).value=n,t.state=us,fs(e,t,!0))},_s=function(n,r,e,t){if(!r.done){r.done=!0,t&&(r=t);try{if(n===e)throw Zi("Promise can't be resolved itself");var i=ps(e);i?Bi(function(){var t={done:!1};try{i.call(e,vs(_s,n,t,r),vs(ys,n,t,r))}catch(e){ys(n,t,e,r)}}):(r.value=e,r.state=ls,fs(n,r,!1))}catch(e){ys(n,{done:!1},e,r)}}};Be&&(Xi=function(e){Mi(this,Xi,Gi),Oi(e),Ai.call(this);var t=Qi(this);try{e(vs(_s,this,t),vs(ys,this,t))}catch(e){ys(this,t,e)}},(Ai=function(e){Yi(this,{type:Gi,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=or(Xi.prototype,{then:function(e,t){var n=Ji(this),r=rs(qi(this,Xi));return r.ok="function"!=typeof e||e,r.fail="function"==typeof t&&t,r.domain=ss?ts.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&fs(this,n,!1),r.promise},catch:function(e){return this.then(void 0,e)}}),Ni=function(){var e=new Ai,t=Qi(e);this.promise=e,this.resolve=vs(_s,e,t),this.reject=vs(ys,e,t)},ue.f=rs=function(e){return e===Xi||e===Ri?new Ni:is(e)},"function"==typeof A&&(Pi=A.prototype.then,P(A.prototype,"then",function(e,t){var n=this;return new Xi(function(e,t){Pi.call(n,e,t)}).then(e,t)},{unsafe:!0}),"function"==typeof ns&&wi({global:!0,enumerable:!0,forced:!0},{fetch:function(e){return Wi(Xi,ns.apply(xi,arguments))}}))),wi({global:!0,wrap:!0,forced:Be},{Promise:Xi}),yi(Xi,Gi,!1),zr(Gi),Ri=d(Gi),wi({target:Gi,stat:!0,forced:Be},{reject:function(e){var t=rs(this);return t.reject.call(void 0,e),t.promise}}),wi({target:Gi,stat:!0,forced:Be},{resolve:function(e){return Wi(this,e)}}),wi({target:Gi,stat:!0,forced:ji},{all:function(e){var a=this,t=rs(a),c=t.resolve,l=t.reject,n=Ki(function(){var r=Oi(a.resolve),i=[],s=0,o=1;Ui(e,function(e){var t=s++,n=!1;i.push(void 0),o++,r.call(a,e).then(function(e){n||(n=!0,i[t]=e,--o||c(i))},l)}),--o||c(i)});return n.error&&l(n.value),t.promise},race:function(e){var n=this,r=rs(n),i=r.reject,t=Ki(function(){var t=Oi(n.resolve);Ui(e,function(e){t.call(n,e).then(r.resolve,i)})});return t.error&&i(t.value),r.promise}});var d=z,ws=n,bs=de,Is=B,Ts=l.exports;d({target:"Promise",stat:!0},{allSettled:function(e){var a=this,t=bs.f(a),c=t.resolve,n=t.reject,r=Is(function(){var r=ws(a.resolve),i=[],s=0,o=1;Ts(e,function(e){var t=s++,n=!1;i.push(void 0),o++,r.call(a,e).then(function(e){n||(n=!0,i[t]={status:"fulfilled",value:e},--o||c(i))},function(e){n||(n=!0,i[t]={status:"rejected",reason:e},--o||c(i))})}),--o||c(i)});return r.error&&n(r.value),t.promise}});var Be=z,Es=pe,wi=e,ks=vt,Ss=R,Cs=Ze,ji=Z.exports;Be({target:"Promise",proto:!0,real:!0,forced:!!Es&&wi(function(){Es.prototype.finally.call({then:function(){}},function(){})})},{finally:function(t){var n=Ss(this,ks("Promise")),e="function"==typeof t;return this.then(e?function(e){return Cs(n,t()).then(function(){return e})}:t,e?function(e){return Cs(n,t()).then(function(){throw e})}:t)}}),"function"!=typeof Es||Es.prototype.finally||ji(Es.prototype,"finally",ks("Promise").prototype.finally),yt.Promise;function As(e,t){var n=this;if(!(n instanceof As))return new As(e,t);Ps&&(n=Ps(new Error(t),Rs(n)));var r=[];return xs(e,r.push,r),Ns?Os(n,{errors:r,type:"AggregateError"}):n.errors=r,void 0!==t&&Ds(n,"message",String(t)),n}var d=z,Ns=o,Rs=ee,Ps=rt,pe=Qe,Ze=a,Be=I,xs=l.exports,Ds=k,wi=ke,Os=wi.set,Ms=wi.getterFor("AggregateError");As.prototype=pe(Error.prototype,{constructor:Be(5,As),message:Be(5,""),name:Be(5,"AggregateError")}),Ns&&Ze.f(As.prototype,"errors",{get:function(){return Ms(this).errors},configurable:!0}),d({global:!0},{AggregateError:As});var Ls=de,Fs=B;z({target:"Promise",stat:!0},{try:function(e){var t=Ls.f(this),n=Fs(e);return(n.error?t.reject:t.resolve)(n.value),t.promise}});var ji=z,Us=n,js=vt,qs=de,Vs=B,Bs=l.exports,Ws="No one promise resolved";ji({target:"Promise",stat:!0},{any:function(e){var c=this,t=qs.f(c),l=t.resolve,u=t.reject,n=Vs(function(){var r=Us(c.resolve),i=[],s=0,o=1,a=!1;Bs(e,function(e){var t=s++,n=!1;i.push(void 0),o++,r.call(c,e).then(function(e){n||a||(a=!0,l(e))},function(e){n||a||(n=!0,i[t]=e,--o||u(new(js("AggregateError"))(i,Ws)))})}),--o||u(new(js("AggregateError"))(i,Ws))});return n.error&&u(n.value),t.promise}});function $s(e){throw e}var Ks=Me,wi=Array.isArray||function(e){return"Array"==Ks(e)},zs=c,Hs=wi,Gs=Y("species"),pe=function(e,t){var n;return new(void 0===(n=Hs(e)&&("function"==typeof(n=e.constructor)&&(n===Array||Hs(n.prototype))||zs(n)&&null===(n=n[Gs]))?void 0:n)?Array:n)(0===t?0:t)},Qs=Te,Ys=ot,Js=$,Xs=Et,Zs=pe,eo=[].push,Be=function(p){var f=1==p,g=2==p,m=3==p,v=4==p,y=6==p,_=5==p||y;return function(e,t,n,r){for(var i,s,o=Js(e),a=Ys(o),c=Qs(t,n,3),l=Xs(a.length),u=0,h=r||Zs,d=f?h(e,l):g?h(e,0):void 0;u<l;u++)if((_||u in a)&&(s=c(i=a[u],u,o),p))if(f)d[u]=s;else if(s)switch(p){case 3:return!0;case 5:return i;case 6:return u;case 2:eo.call(d,i)}else if(v)return!1;return y?-1:m||v?v:d}},Ze={forEach:Be(0),map:Be(1),filter:Be(2),some:Be(3),every:Be(4),find:Be(5),findIndex:Be(6)},to=o,no=e,ro=D,io=Object.defineProperty,so={},d=function(e,t){if(ro(so,e))return so[e];var n=[][e],r=!!ro(t=t||{},"ACCESSORS")&&t.ACCESSORS,i=ro(t,0)?t[0]:$s,s=ro(t,1)?t[1]:void 0;return so[e]=!!n&&!no(function(){if(r&&!to)return!0;var e={length:-1};r?io(e,1,{enumerable:!0,get:$s}):e[1]=1,n.call(e,i,s)})},de=z,oo=Ze.find,B=J,ji="find",ao=!0,Be=d(ji);ji in[]&&Array(1)[ji](function(){ao=!1}),de({target:"Array",proto:!0,forced:ao||!Be},{find:function(e){return oo(this,e,1<arguments.length?arguments[1]:void 0)}}),B(ji);var co=i,lo=Te,uo=Function.call,de=function(e,t,n){return lo(uo,co[e].prototype[t],n)};de("Array","find");var Be=z,ho=Ze.findIndex,B=J,ji="findIndex",po=!0,J=d(ji);ji in[]&&Array(1)[ji](function(){po=!1}),Be({target:"Array",proto:!0,forced:po||!J},{findIndex:function(e){return ho(this,e,1<arguments.length?arguments[1]:void 0)}}),B(ji),de("Array","findIndex");var fo=v,go=a,mo=I,J=function(e,t,n){var r=fo(t);r in e?go.f(e,r,mo(0,n)):e[r]=n},vo=Te,yo=$,_o=Ye,wo=X,bo=Et,Io=J,To=f,B=function(e){var t,n,r,i,s,o,a=yo(e),c="function"==typeof this?this:Array,l=arguments.length,u=1<l?arguments[1]:void 0,h=void 0!==u,d=To(a),p=0;if(h&&(u=vo(u,2<l?arguments[2]:void 0,2)),null==d||c==Array&&wo(d))for(n=new c(t=bo(a.length));p<t;p++)o=h?u(a[p],p):a[p],Io(n,p,o);else for(s=(i=d.call(a)).next,n=new c;!(r=s.call(i)).done;p++)o=h?_o(i,u,[r.value,p],!0):r.value,Io(n,p,o);return n.length=p,n};z({target:"Array",stat:!0,forced:!r(function(e){Array.from(e)})},{from:B}),yt.Array.from;var Eo=e,ji=z,ko=Ze.some,Ye=d,X=function(e,t){var n=[][e];return!!n&&Eo(function(){n.call(null,t||function(){throw 1},1)})}("some"),B=Ye("some");ji({target:"Array",proto:!0,forced:!X||!B},{some:function(e){return ko(this,e,1<arguments.length?arguments[1]:void 0)}}),de("Array","some");function So(e){return Ro(e)&&Po(Wo,xo(e))}var Co,d="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,Ao=o,No=i,Ro=c,Po=D,xo=qe,Do=k,Oo=Z.exports,Ye=a.f,ji=ee,Mo=rt,X=Y,B=O,Lo=No.Int8Array,Fo=Lo&&Lo.prototype,qe=No.Uint8ClampedArray,ee=qe&&qe.prototype,Uo=Lo&&ji(Lo),jo=Fo&&ji(Fo),qe=Object.prototype,qo=qe.isPrototypeOf,X=X("toStringTag"),Vo=B("TYPED_ARRAY_TAG"),Bo=d&&!!Mo&&"Opera"!==xo(No.opera),d=!1,Wo={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8};for(Co in Wo)No[Co]||(Bo=!1);if((!Bo||"function"!=typeof Uo||Uo===Function.prototype)&&(Uo=function(){throw TypeError("Incorrect invocation")},Bo))for(Co in Wo)No[Co]&&Mo(No[Co],Uo);if((!Bo||!jo||jo===qe)&&(jo=Uo.prototype,Bo))for(Co in Wo)No[Co]&&Mo(No[Co].prototype,jo);if(Bo&&ji(ee)!==jo&&Mo(ee,jo),Ao&&!Po(jo,X))for(Co in d=!0,Ye(jo,X,{get:function(){return Ro(this)?this[Vo]:void 0}}),Wo)No[Co]&&Do(No[Co],Vo,Co);var Ye=i,X={NATIVE_ARRAY_BUFFER_VIEWS:Bo,TYPED_ARRAY_TAG:d&&Vo,aTypedArray:function(e){if(So(e))return e;throw TypeError("Target is not a typed array")},aTypedArrayConstructor:function(e){if(Mo){if(qo.call(Uo,e))return e}else for(var t in Wo)if(Po(Wo,Co)){t=No[t];if(t&&(e===t||qo.call(t,e)))return e}throw TypeError("Target is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n){if(Ao){if(n)for(var r in Wo){r=No[r];r&&Po(r.prototype,e)&&delete r.prototype[e]}jo[e]&&!n||Oo(jo,e,!n&&Bo&&Fo[e]||t)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(Ao){if(Mo){if(n)for(r in Wo)(i=No[r])&&Po(i,e)&&delete i[e];if(Uo[e]&&!n)return;try{return Oo(Uo,e,!n&&Bo&&Lo[e]||t)}catch(e){}}for(r in Wo)!(i=No[r])||i[e]&&!n||Oo(i,e,t)}},isView:function(e){var t=xo(e);return"DataView"===t||Po(Wo,t)},isTypedArray:So,TypedArray:Uo,TypedArrayPrototype:jo},d=fe,fe=Y("iterator"),Ye=Ye.Uint8Array,$o=d.values,Ko=d.keys,zo=d.entries,Ho=X.aTypedArray,d=X.exportTypedArrayMethod,X=Ye&&Ye.prototype[fe],Ye=!!X&&("values"==X.name||null==X.name),X=function(){return $o.call(Ho(this))};d("entries",function(){return zo.call(Ho(this))}),d("keys",function(){return Ko.call(Ho(this))}),d("values",X,!Ye),d(fe,X,!Ye);var Go=o,X=e,Qo=Ie,Yo=N,Jo=Xe,Xo=$,Zo=ot,ea=Object.assign,ta=Object.defineProperty,Ye=!ea||X(function(){if(Go&&1!==ea({b:1},ea(ta({},"a",{enumerable:!0,get:function(){ta(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach(function(e){t[e]=e}),7!=ea({},e)[n]||Qo(ea({},t)).join("")!=r})?function(e,t){for(var n=Xo(e),r=arguments.length,i=1,s=Yo.f,o=Jo.f;i<r;)for(var a,c=Zo(arguments[i++]),l=s?Qo(c).concat(s(c)):Qo(c),u=l.length,h=0;h<u;)a=l[h++],Go&&!o.call(c,a)||(n[a]=c[a]);return n}:ea;z({target:"Object",stat:!0,forced:Object.assign!==Ye},{assign:Ye}),yt.Object.assign;var na=o,ra=Ie,ia=nt,sa=Xe.f,ot=function(a){return function(e){for(var t,n=ia(e),r=ra(n),i=r.length,s=0,o=[];s<i;)t=r[s++],na&&!sa.call(n,t)||o.push(a?[t,n[t]]:n[t]);return o}},X={entries:ot(!0),values:ot(!1)},Ye=z,oa=X.entries;Ye({target:"Object",stat:!0},{entries:function(e){return oa(e)}}),yt.Object.entries;var ot=z,aa=X.values;ot({target:"Object",stat:!0},{values:function(e){return aa(e)}}),yt.Object.values;var ca=c,la=Me,ua=Y("match"),ha=function(e){var t;return ca(e)&&(void 0!==(t=e[ua])?!!t:"RegExp"==la(e))},Ye=function(e){if(ha(e))throw TypeError("The method doesn't accept regular expressions");return e},da=Y("match"),X=function(t){var n=/./;try{"/./"[t](n)}catch(e){try{return n[da]=!1,"/./"[t](n)}catch(e){}}return!1},pa=Ye,fa=ze;z({target:"String",proto:!0,forced:!X("includes")},{includes:function(e){return!!~String(fa(this)).indexOf(pa(e),1<arguments.length?arguments[1]:void 0)}}),de("String","includes");var ot=z,Me=Je.f,ga=Et,ma=Ye,va=ze,X=X,ya="".startsWith,_a=Math.min,X=X("startsWith");ot({target:"String",proto:!0,forced:!!(X||(!(Me=Me(String.prototype,"startsWith"))||Me.writable))&&!X},{startsWith:function(e){var t=String(va(this));ma(e);var n=ga(_a(1<arguments.length?arguments[1]:void 0,t.length)),r=String(e);return ya?ya.call(t,r,n):t.slice(n,n+r.length)===r}}),de("String","startsWith");var wa=Ke,ba=ze;z({target:"String",proto:!0},{repeat:"".repeat||function(e){var t=String(ba(this)),n="",r=wa(e);if(r<0||r==1/0)throw RangeError("Wrong number of repetitions");for(;0<r;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n}}),de("String","repeat");var Ia=e,Ta=he,Ea=Y("species"),Ke=z,ze=e,ka=wi,Sa=c,Ca=$,Aa=Et,Na=J,Ra=pe,de=function(t){return 51<=Ta||!Ia(function(){var e=[];return(e.constructor={})[Ea]=function(){return{foo:1}},1!==e[t](Boolean).foo})},Et=he,Pa=Y("isConcatSpreadable"),xa=9007199254740991,Da="Maximum allowed index exceeded",J=51<=Et||!ze(function(){var e=[];return e[Pa]=!1,e.concat()[0]!==e}),pe=de("concat");Ke({target:"Array",proto:!0,forced:!J||!pe},{concat:function(e){for(var t,n,r,i=Ca(this),s=Ra(i,0),o=0,a=-1,c=arguments.length;a<c;a++)if(function(e){if(!Sa(e))return!1;var t=e[Pa];return void 0!==t?!!t:ka(e)}(r=-1===a?i:arguments[a])){if(n=Aa(r.length),xa<o+n)throw TypeError(Da);for(t=0;t<n;t++,o++)t in r&&Na(s,o,r[t])}else{if(xa<=o)throw TypeError(Da);Na(s,o++,r)}return s.length=o,s}});var he={},Oa=nt,Ma=bt.f,La={}.toString,Fa="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];he.f=function(e){return Fa&&"[object Window]"==La.call(e)?function(e){try{return Ma(e)}catch(e){return Fa.slice()}}(e):Ma(Oa(e))};Et={};Et.f=Y;function Ua(e,t){var n=_c[e]=Za(pc[lc]);return uc(n,{type:cc,tag:e,description:t}),$a||(n.description=t),n}function ja(t,e){Ga(t);var n=Ya(e),r=ec(n).concat(Ac(n));return oc(r,function(e){$a&&!Cc.call(n,e)||Sc(t,e,n[e])}),t}var qa=yt,Va=D,Ba=Et,Wa=a.f,ze=function(e){var t=qa.Symbol||(qa.Symbol={});Va(t,e)||Wa(t,e,{value:Ba.f(e)})},de=z,Ke=i,J=vt,$a=o,pe=j,j=q,q=e,Ka=D,za=wi,Ha=c,Ga=t,Qa=$,Ya=nt,Ja=v,Xa=I,Za=Qe,ec=Ie,v=bt,I=he,tc=N,Ie=Je,bt=a,he=Xe,N=k,Je=Z.exports,Xe=s.exports,k=ve,nc=ye,rc=O,ic=Y,s=Et,sc=ze,ve=tt,Y=ke,oc=Ze.forEach,ac=k("hidden"),cc="Symbol",lc="prototype",k=ic("toPrimitive"),uc=Y.set,hc=Y.getterFor(cc),dc=Object[lc],pc=Ke.Symbol,fc=J("JSON","stringify"),gc=Ie.f,mc=bt.f,vc=I.f,yc=he.f,_c=Xe("symbols"),wc=Xe("op-symbols"),bc=Xe("string-to-symbol-registry"),Ic=Xe("symbol-to-string-registry"),Xe=Xe("wks"),Ke=Ke.QObject,Tc=!Ke||!Ke[lc]||!Ke[lc].findChild,Ec=$a&&q(function(){return 7!=Za(mc({},"a",{get:function(){return mc(this,"a",{value:7}).a}})).a})?function(e,t,n){var r=gc(dc,t);r&&delete dc[t],mc(e,t,n),r&&e!==dc&&mc(dc,t,r)}:mc,kc=j?function(e){return"symbol"==typeof e}:function(e){return Object(e)instanceof pc},Sc=function(e,t,n){e===dc&&Sc(wc,t,n),Ga(e);var r=Ja(t,!0);return Ga(n),Ka(_c,r)?(n.enumerable?(Ka(e,ac)&&e[ac][r]&&(e[ac][r]=!1),n=Za(n,{enumerable:Xa(0,!1)})):(Ka(e,ac)||mc(e,ac,Xa(1,{})),e[ac][r]=!0),Ec(e,r,n)):mc(e,r,n)},Cc=function(e){var t=Ja(e,!0),n=yc.call(this,t);return!(this===dc&&Ka(_c,t)&&!Ka(wc,t))&&(!(n||!Ka(this,t)||!Ka(_c,t)||Ka(this,ac)&&this[ac][t])||n)},Ke=function(e,t){var n=Ya(e),r=Ja(t,!0);if(n!==dc||!Ka(_c,r)||Ka(wc,r)){var i=gc(n,r);return!i||!Ka(_c,r)||Ka(n,ac)&&n[ac][r]||(i.enumerable=!0),i}},j=function(e){var t=vc(Ya(e)),n=[];return oc(t,function(e){Ka(_c,e)||Ka(nc,e)||n.push(e)}),n},Ac=function(e){var t=e===dc,n=vc(t?wc:Ya(e)),r=[];return oc(n,function(e){!Ka(_c,e)||t&&!Ka(dc,e)||r.push(_c[e])}),r};pe||(Je((pc=function(){if(this instanceof pc)throw TypeError("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?String(arguments[0]):void 0,t=rc(e),n=function(e){this===dc&&n.call(wc,e),Ka(this,ac)&&Ka(this[ac],t)&&(this[ac][t]=!1),Ec(this,t,Xa(1,e))};return $a&&Tc&&Ec(dc,t,{configurable:!0,set:n}),Ua(t,e)})[lc],"toString",function(){return hc(this).tag}),Je(pc,"withoutSetter",function(e){return Ua(rc(e),e)}),he.f=Cc,bt.f=Sc,Ie.f=Ke,v.f=I.f=j,tc.f=Ac,s.f=function(e){return Ua(ic(e),e)},$a&&(mc(pc[lc],"description",{configurable:!0,get:function(){return hc(this).description}}),Je(dc,"propertyIsEnumerable",Cc,{unsafe:!0}))),de({global:!0,wrap:!0,forced:!pe,sham:!pe},{Symbol:pc}),oc(ec(Xe),function(e){sc(e)}),de({target:cc,stat:!0,forced:!pe},{for:function(e){var t=String(e);if(Ka(bc,t))return bc[t];var n=pc(t);return bc[t]=n,Ic[n]=t,n},keyFor:function(e){if(!kc(e))throw TypeError(e+" is not a symbol");if(Ka(Ic,e))return Ic[e]},useSetter:function(){Tc=!0},useSimple:function(){Tc=!1}}),de({target:"Object",stat:!0,forced:!pe,sham:!$a},{create:function(e,t){return void 0===t?Za(e):ja(Za(e),t)},defineProperty:Sc,defineProperties:ja,getOwnPropertyDescriptor:Ke}),de({target:"Object",stat:!0,forced:!pe},{getOwnPropertyNames:j,getOwnPropertySymbols:Ac}),de({target:"Object",stat:!0,forced:q(function(){tc.f(1)})},{getOwnPropertySymbols:function(e){return tc.f(Qa(e))}}),fc&&de({target:"JSON",stat:!0,forced:!pe||q(function(){var e=pc();return"[null]"!=fc([e])||"{}"!=fc({a:e})||"{}"!=fc(Object(e))})},{stringify:function(e,t,n){for(var r,i=[e],s=1;s<arguments.length;)i.push(arguments[s++]);if((Ha(r=t)||void 0!==e)&&!kc(e))return za(t)||(t=function(e,t){if("function"==typeof r&&(t=r.call(this,e,t)),!kc(t))return t}),i[1]=t,fc.apply(null,i)}}),pc[lc][k]||N(pc[lc],k,pc[lc].valueOf),ve(pc,cc),nc[ac]=!0,ze("asyncIterator");var Nc,Rc,Pc,xc,Dc,k=z,Oc=D,Mc=c,ve=a.f,U=U,Lc=i.Symbol;!o||"function"!=typeof Lc||"description"in Lc.prototype&&void 0===Lc().description||(Nc={},U(Rc=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:String(arguments[0]),t=this instanceof Rc?new Lc(e):void 0===e?Lc():Lc(e);return""===e&&(Nc[t]=!0),t},Lc),(U=Rc.prototype=Lc.prototype).constructor=Rc,Pc=U.toString,xc="Symbol(test)"==String(Lc("test")),Dc=/^Symbol\((.*)\)[^)]+$/,ve(U,"description",{configurable:!0,get:function(){var e=Mc(this)?this.valueOf():this,t=Pc.call(e);if(Oc(Nc,e))return"";t=xc?t.slice(7,-1):t.replace(Dc,"$1");return""===t?void 0:t}}),k({global:!0,forced:!0},{Symbol:Rc})),ze("hasInstance"),ze("isConcatSpreadable"),ze("iterator"),ze("match"),ze("matchAll"),ze("replace"),ze("search"),ze("species"),ze("split"),ze("toPrimitive"),ze("toStringTag"),ze("unscopables"),tt(Math,"Math",!0),tt(i.JSON,"JSON",!0),yt.Symbol,ze("asyncDispose"),ze("dispose"),ze("observable"),ze("patternMatch"),ze("replaceAll"),Et.f("iterator");function Fc(e){qc(e,Bc,{value:{objectID:"O"+ ++Wc,weakData:{}}})}var ze={exports:{}},Et=!e(function(){return Object.isExtensible(Object.preventExtensions({}))}),ye=ye,Uc=c,jc=D,qc=a.f,Vc=Et,Bc=O("meta"),Wc=0,$c=Object.isExtensible||function(){return!0},Kc=ze.exports={REQUIRED:!1,fastKey:function(e,t){if(!Uc(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!jc(e,Bc)){if(!$c(e))return"F";if(!t)return"E";Fc(e)}return e[Bc].objectID},getWeakData:function(e,t){if(!jc(e,Bc)){if(!$c(e))return!0;if(!t)return!1;Fc(e)}return e[Bc].weakData},onFreeze:function(e){return Vc&&Kc.REQUIRED&&$c(e)&&!jc(e,Bc)&&Fc(e),e}};ye[Bc]=!0;var zc=c,Hc=rt,Gc=z,Qc=i,Yc=V,Jc=Z.exports,Xc=ze.exports,Zc=l.exports,el=Le,tl=c,nl=e,rl=r,il=tt,sl=function(e,t,n){var r,i;return Hc&&"function"==typeof(r=t.constructor)&&r!==n&&zc(i=r.prototype)&&i!==n.prototype&&Hc(e,i),e},tt=function(r,e,t){function n(e){var n=p[e];Jc(p,e,"add"==e?function(e){return n.call(this,0===e?0:e),this}:"delete"==e?function(e){return!(u&&!tl(e))&&n.call(this,0===e?0:e)}:"get"==e?function(e){return u&&!tl(e)?void 0:n.call(this,0===e?0:e)}:"has"==e?function(e){return!(u&&!tl(e))&&n.call(this,0===e?0:e)}:function(e,t){return n.call(this,0===e?0:e,t),this})}var i,s,o,a,c,l=-1!==r.indexOf("Map"),u=-1!==r.indexOf("Weak"),h=l?"set":"add",d=Qc[r],p=d&&d.prototype,f=d,g={};return Yc(r,"function"!=typeof d||!(u||p.forEach&&!nl(function(){(new d).entries().next()})))?(f=t.getConstructor(e,r,l,h),Xc.REQUIRED=!0):Yc(r,!0)&&(s=(i=new f)[h](u?{}:-0,1)!=i,o=nl(function(){i.has(1)}),a=rl(function(e){new d(e)}),c=!u&&nl(function(){for(var e=new d,t=5;t--;)e[h](t,t);return!e.has(-0)}),a||(((f=e(function(e,t){el(e,f,r);var n=sl(new d,e,f);return null!=t&&Zc(t,n[h],n,l),n})).prototype=p).constructor=f),(o||c)&&(n("delete"),n("has"),l&&n("get")),(c||s)&&n(h),u&&p.clear&&delete p.clear),g[r]=f,Gc({global:!0,forced:f!=d},g),il(f,r),u||t.setStrong(f,r,l),f},ol=a.f,al=Qe,cl=Er,ll=Te,ul=Le,hl=l.exports,dl=Pt,pl=Ee,fl=o,gl=ze.exports.fastKey,ml=ke.set,vl=ke.getterFor,Pt={getConstructor:function(e,n,r,i){function s(e,t,n){var r,i,s=c(e),o=a(e,t);return o?o.value=n:(s.last=o={index:i=gl(t,!0),key:t,value:n,previous:r=s.last,next:void 0,removed:!1},s.first||(s.first=o),r&&(r.next=o),fl?s.size++:e.size++,"F"!==i&&(s.index[i]=o)),e}function a(e,t){var n,r=c(e),i=gl(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==t)return n}var o=e(function(e,t){ul(e,o,n),ml(e,{type:n,index:al(null),first:void 0,last:void 0,size:0}),fl||(e.size=0),null!=t&&hl(t,e[i],e,r)}),c=vl(n);return cl(o.prototype,{clear:function(){for(var e=c(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,fl?e.size=0:this.size=0},delete:function(e){var t,n,r=c(this),i=a(this,e);return i&&(t=i.next,n=i.previous,delete r.index[i.index],i.removed=!0,n&&(n.next=t),t&&(t.previous=n),r.first==i&&(r.first=t),r.last==i&&(r.last=n),fl?r.size--:this.size--),!!i},forEach:function(e){for(var t,n=c(this),r=ll(e,1<arguments.length?arguments[1]:void 0,3);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!a(this,e)}}),cl(o.prototype,r?{get:function(e){var t=a(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),fl&&ol(o.prototype,"size",{get:function(){return c(this).size}}),o},setStrong:function(e,t,n){var r=t+" Iterator",i=vl(t),s=vl(r);dl(e,t,function(e,t){ml(this,{type:r,target:e,state:i(e),kind:t,last:void 0})},function(){for(var e=s(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?"keys"==t?{value:n.key,done:!1}:"values"==t?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:{value:e.target=void 0,done:!0}},n?"entries":"values",!n,!0),pl(t)}};tt("Map",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},Pt),yt.Map;var yl=n,_l=Te,wl=l.exports,Ee=function(e){var t,n,r,i,s=arguments.length,o=1<s?arguments[1]:void 0;return yl(this),(t=void 0!==o)&&yl(o),null==e?new this:(n=[],t?(r=0,i=_l(o,2<s?arguments[2]:void 0,2),wl(e,function(e){n.push(i(e,r++))})):wl(e,n.push,n),new this(n))};z({target:"Map",stat:!0},{from:Ee});o=function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];return new this(t)};z({target:"Map",stat:!0},{of:o});var bl=t,Il=n,ze=function(){for(var e,t=bl(this),n=Il(t.delete),r=!0,i=0,s=arguments.length;i<s;i++)e=n.call(t,arguments[i]),r=r&&e;return!!r},Tl=ze;z({target:"Map",proto:!0,real:!0,forced:!1},{deleteAll:function(){return Tl.apply(this,arguments)}});var El=t,kl=f,ke=function(e){return Map.prototype.entries.call(e)},f=z,Sl=t,Cl=Te,Al=ke,Nl=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{every:function(e){var n=Sl(this),t=Al(n),r=Cl(e,1<arguments.length?arguments[1]:void 0,3);return!Nl(t,function(e,t){if(!r(t,e,n))return Nl.stop()},void 0,!0,!0).stopped}});var f=z,Rl=vt,Pl=t,xl=n,Dl=Te,Ol=R,Ml=ke,Ll=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{filter:function(e){var n=Pl(this),t=Ml(n),r=Dl(e,1<arguments.length?arguments[1]:void 0,3),i=new(Ol(n,Rl("Map"))),s=xl(i.set);return Ll(t,function(e,t){r(t,e,n)&&s.call(i,e,t)},void 0,!0,!0),i}});var f=z,Fl=t,Ul=Te,jl=ke,ql=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{find:function(e){var n=Fl(this),t=jl(n),r=Ul(e,1<arguments.length?arguments[1]:void 0,3);return ql(t,function(e,t){if(r(t,e,n))return ql.stop(t)},void 0,!0,!0).result}});var f=z,Vl=t,Bl=Te,Wl=ke,$l=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{findKey:function(e){var n=Vl(this),t=Wl(n),r=Bl(e,1<arguments.length?arguments[1]:void 0,3);return $l(t,function(e,t){if(r(t,e,n))return $l.stop(e)},void 0,!0,!0).result}});var f=z,Kl=l.exports,zl=n;f({target:"Map",stat:!0},{groupBy:function(e,n){var r=new this;zl(n);var i=zl(r.has),s=zl(r.get),o=zl(r.set);return Kl(e,function(e){var t=n(e);i.call(r,t)?s.call(r,t).push(e):o.call(r,t,[e])}),r}});var f=z,Hl=t,Gl=ke,Ql=function(e,t){return e===t||e!=e&&t!=t},Yl=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{includes:function(n){return Yl(Gl(Hl(this)),function(e,t){if(Ql(t,n))return Yl.stop()},void 0,!0,!0).stopped}});var f=z,Jl=l.exports,Xl=n;f({target:"Map",stat:!0},{keyBy:function(e,t){var n=new this;Xl(t);var r=Xl(n.set);return Jl(e,function(e){r.call(n,t(e),e)}),n}});var f=z,Zl=t,eu=ke,tu=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{keyOf:function(n){return tu(eu(Zl(this)),function(e,t){if(t===n)return tu.stop(e)},void 0,!0,!0).result}});var f=z,nu=vt,ru=t,iu=n,su=Te,ou=R,au=ke,cu=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{mapKeys:function(e){var n=ru(this),t=au(n),r=su(e,1<arguments.length?arguments[1]:void 0,3),i=new(ou(n,nu("Map"))),s=iu(i.set);return cu(t,function(e,t){s.call(i,r(t,e,n),t)},void 0,!0,!0),i}});var f=z,lu=vt,uu=t,hu=n,du=Te,pu=R,fu=ke,gu=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{mapValues:function(e){var n=uu(this),t=fu(n),r=du(e,1<arguments.length?arguments[1]:void 0,3),i=new(pu(n,lu("Map"))),s=hu(i.set);return gu(t,function(e,t){s.call(i,e,r(t,e,n))},void 0,!0,!0),i}});var f=z,mu=t,vu=n,yu=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{merge:function(e){for(var t=mu(this),n=vu(t.set),r=0;r<arguments.length;)yu(arguments[r++],n,t,!0);return t}});var f=z,_u=t,wu=n,bu=ke,Iu=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{reduce:function(n){var r=_u(this),e=bu(r),i=arguments.length<2,s=i?void 0:arguments[1];if(wu(n),Iu(e,function(e,t){s=i?(i=!1,t):n(s,t,e,r)},void 0,!0,!0),i)throw TypeError("Reduce of empty map with no initial value");return s}});var f=z,Tu=t,Eu=Te,ku=ke,Su=l.exports;f({target:"Map",proto:!0,real:!0,forced:!1},{some:function(e){var n=Tu(this),t=ku(n),r=Eu(e,1<arguments.length?arguments[1]:void 0,3);return Su(t,function(e,t){if(r(t,e,n))return Su.stop()},void 0,!0,!0).stopped}});var Cu=t,Au=n;z({target:"Map",proto:!0,real:!0,forced:!1},{update:function(e,t){var n=Cu(this),r=arguments.length;Au(t);var i=n.has(e);if(!i&&r<3)throw TypeError("Updating absent value");r=i?n.get(e):Au(2<r?arguments[2]:void 0)(e,n);return n.set(e,t(r,e,n)),n}});var Nu=t,f=function(e,t){var n,r=Nu(this),i=2<arguments.length?arguments[2]:void 0;if("function"!=typeof t&&"function"!=typeof i)throw TypeError("At least one callback required");return r.has(e)?(n=r.get(e),"function"==typeof t&&(n=t(n),r.set(e,n))):"function"==typeof i&&(n=i(),r.set(e,n)),n};z({target:"Map",proto:!0,real:!0,forced:!1},{upsert:f});z({target:"Map",proto:!0,real:!0,forced:!1},{updateOrInsert:f}),tt("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},Pt),yt.Set,z({target:"Set",stat:!0},{from:Ee}),z({target:"Set",stat:!0},{of:o});var Ru=t,Pu=n,xu=function(){for(var e=Ru(this),t=Pu(e.add),n=0,r=arguments.length;n<r;n++)t.call(e,arguments[n]);return e};z({target:"Set",proto:!0,real:!0,forced:!1},{addAll:function(){return xu.apply(this,arguments)}});var Du=ze;z({target:"Set",proto:!0,real:!0,forced:!1},{deleteAll:function(){return Du.apply(this,arguments)}});var o=function(e){return Set.prototype.values.call(e)},ze=z,Ou=t,Mu=Te,Lu=o,Fu=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{every:function(e){var t=Ou(this),n=Lu(t),r=Mu(e,1<arguments.length?arguments[1]:void 0,3);return!Fu(n,function(e){if(!r(e,e,t))return Fu.stop()},void 0,!1,!0).stopped}});var ze=z,Uu=vt,ju=t,qu=n,Vu=R,Bu=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{difference:function(e){var t=ju(this),n=new(Vu(t,Uu("Set")))(t),r=qu(n.delete);return Bu(e,function(e){r.call(n,e)}),n}});var ze=z,Wu=vt,$u=t,Ku=n,zu=Te,Hu=R,Gu=o,Qu=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{filter:function(e){var t=$u(this),n=Gu(t),r=zu(e,1<arguments.length?arguments[1]:void 0,3),i=new(Hu(t,Wu("Set"))),s=Ku(i.add);return Qu(n,function(e){r(e,e,t)&&s.call(i,e)},void 0,!1,!0),i}});var ze=z,Yu=t,Ju=Te,Xu=o,Zu=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{find:function(e){var t=Yu(this),n=Xu(t),r=Ju(e,1<arguments.length?arguments[1]:void 0,3);return Zu(n,function(e){if(r(e,e,t))return Zu.stop(e)},void 0,!1,!0).result}});var ze=z,eh=vt,th=t,nh=n,rh=R,ih=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{intersection:function(e){var t=th(this),n=new(rh(t,eh("Set"))),r=nh(t.has),i=nh(n.add);return ih(e,function(e){r.call(t,e)&&i.call(n,e)}),n}});var ze=z,sh=t,oh=n,ah=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{isDisjointFrom:function(e){var t=sh(this),n=oh(t.has);return!ah(e,function(e){if(!0===n.call(t,e))return ah.stop()}).stopped}});var ze=z,ch=vt,lh=t,uh=n,hh=function(e){var t=kl(e);if("function"!=typeof t)throw TypeError(String(e)+" is not iterable");return El(t.call(e))},dh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{isSubsetOf:function(e){var t=hh(this),n=lh(e),r=n.has;return"function"!=typeof r&&(n=new(ch("Set"))(e),r=uh(n.has)),!dh(t,function(e){if(!1===r.call(n,e))return dh.stop()},void 0,!1,!0).stopped}});var ze=z,ph=t,fh=n,gh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{isSupersetOf:function(e){var t=ph(this),n=fh(t.has);return!gh(e,function(e){if(!1===n.call(t,e))return gh.stop()}).stopped}});var ze=z,mh=t,vh=o,yh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{join:function(e){var t=mh(this),n=vh(t),r=void 0===e?",":String(e),t=[];return yh(n,t.push,t,!1,!0),t.join(r)}});var ze=z,_h=vt,wh=t,bh=n,Ih=Te,Th=R,Eh=o,kh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{map:function(e){var t=wh(this),n=Eh(t),r=Ih(e,1<arguments.length?arguments[1]:void 0,3),i=new(Th(t,_h("Set"))),s=bh(i.add);return kh(n,function(e){s.call(i,r(e,e,t))},void 0,!1,!0),i}});var ze=z,Sh=t,Ch=n,Ah=o,Nh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{reduce:function(t){var n=Sh(this),e=Ah(n),r=arguments.length<2,i=r?void 0:arguments[1];if(Ch(t),Nh(e,function(e){i=r?(r=!1,e):t(i,e,e,n)},void 0,!1,!0),r)throw TypeError("Reduce of empty set with no initial value");return i}});var ze=z,Rh=t,Ph=Te,xh=o,Dh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{some:function(e){var t=Rh(this),n=xh(t),r=Ph(e,1<arguments.length?arguments[1]:void 0,3);return Dh(n,function(e){if(r(e,e,t))return Dh.stop()},void 0,!1,!0).stopped}});var ze=z,Oh=vt,Mh=t,Lh=n,Fh=R,Uh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{symmetricDifference:function(e){var t=Mh(this),n=new(Fh(t,Oh("Set")))(t),r=Lh(n.delete),i=Lh(n.add);return Uh(e,function(e){r.call(n,e)||i.call(n,e)}),n}});var ze=z,jh=vt,qh=t,Vh=n,Bh=R,Wh=l.exports;ze({target:"Set",proto:!0,real:!0,forced:!1},{union:function(e){var t=qh(this),t=new(Bh(t,jh("Set")))(t);return Wh(e,Vh(t.add),t),t}});var $h,Kh,zh=c,Hh=Math.floor;z({target:"Number",stat:!0},{isInteger:function(e){return!zh(e)&&isFinite(e)&&Hh(e)===e}}),yt.Number.isInteger;function Gh(t){const n=[];let r=0;for(let i=0;i<t.length;i++){let e=t.charCodeAt(i);e<128?n[r++]=e:(e<2048?n[r++]=e>>6|192:(55296==(64512&e)&&i+1<t.length&&56320==(64512&t.charCodeAt(i+1))?(e=65536+((1023&e)<<10)+(1023&t.charCodeAt(++i)),n[r++]=e>>18|240,n[r++]=e>>12&63|128):n[r++]=e>>12|224,n[r++]=e>>6&63|128),n[r++]=63&e|128)}return n}function Qh(e){var t=Gh(e);return Zh.encodeByteArray(t,!0)}const Yh={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},Jh=function(e,t){if(!e)throw Xh(t)},Xh=function(e){return new Error("Firebase Database ("+Yh.SDK_VERSION+") INTERNAL ASSERT FAILED: "+e)},Zh={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(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();var r=e?this.byteToCharMapWebSafe_:this.byteToCharMap_;const i=[];for(let u=0;u<n.length;u+=3){var s=n[u],o=u+1<n.length,a=o?n[u+1]:0,c=u+2<n.length,l=c?n[u+2]:0;let e=(15&a)<<2|l>>6,t=63&l;c||(t=64,o||(e=64)),i.push(r[s>>2],r[(3&s)<<4|a>>4],r[e],r[t])}return i.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(Gh(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let n=0,r=0;for(;n<e.length;){var i,s,o=e[n++];o<128?t[r++]=String.fromCharCode(o):191<o&&o<224?(i=e[n++],t[r++]=String.fromCharCode((31&o)<<6|63&i)):239<o&&o<365?(s=((7&o)<<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))):(i=e[n++],s=e[n++],t[r++]=String.fromCharCode((15&o)<<12|(63&i)<<6|63&s))}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();var n=t?this.charToByteMapWebSafe_:this.charToByteMap_;const r=[];for(let c=0;c<e.length;){var i=n[e.charAt(c++)],s=c<e.length?n[e.charAt(c)]:0;++c;var o=c<e.length?n[e.charAt(c)]:64;++c;var a=c<e.length?n[e.charAt(c)]:64;if(++c,null==i||null==s||null==o||null==a)throw Error();r.push(i<<2|s>>4),64!==o&&(r.push(s<<4&240|o>>2),64!==a&&r.push(o<<6&192|a))}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)}}},ed=function(e){return Qh(e).replace(/\./g,"")},td=function(e){try{return Zh.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function nd(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:const n=t;return new Date(n.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(const r in t)t.hasOwnProperty(r)&&"__proto__"!==r&&(e[r]=nd(e[r],t[r]));return e}class rd{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(n){return(e,t)=>{e?this.reject(e):this.resolve(t),"function"==typeof n&&(this.promise.catch(()=>{}),1===n.length?n(e):n(e,t))}}}function id(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');var n=t||"demo-project",r=e.iat||0,i=e.sub||e.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");i=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[ed(JSON.stringify({alg:"none",type:"JWT"})),ed(JSON.stringify(i)),""].join(".")}function sd(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function od(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(sd())}function ad(){try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(e){return!1}}function cd(){var e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id}function ld(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function ud(){const e=sd();return 0<=e.indexOf("MSIE ")||0<=e.indexOf("Trident/")}function hd(){return!0===Yh.NODE_ADMIN}function dd(){return"object"==typeof indexedDB}function pd(){return new Promise((t,n)=>{try{let e=!0;const r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),e||self.indexedDB.deleteDatabase(r),t(!0)},i.onupgradeneeded=()=>{e=!1},i.onerror=()=>{var e;n((null===(e=i.error)||void 0===e?void 0:e.message)||"")}}catch(e){n(e)}})}function fd(){return!("undefined"==typeof navigator||!navigator.cookieEnabled)}class gd extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,gd.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,md.prototype.create)}}class md{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){var r,n=t[0]||{},i=`${this.service}/${e}`,s=this.errors[e],s=s?(r=n,s.replace(vd,(e,t)=>{var n=r[t];return null!=n?String(n):`<${t}?>`})):"Error",s=`${this.serviceName}: ${s} (${i}).`;return new gd(i,s,n)}}const vd=/\{\$([^}]+)}/g;function yd(e){return JSON.parse(e)}function _d(e){return JSON.stringify(e)}function wd(e){let t={},n={},r={},i="";try{var s=e.split(".");t=yd(td(s[0])||""),n=yd(td(s[1])||""),i=s[2],r=n.d||{},delete n.d}catch(e){}return{header:t,claims:n,data:r,signature:i}}function bd(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Id(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]}function Td(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function Ed(e,t,n){const r={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=t.call(n,e[i],i,e));return r}function kd(e,t){if(e===t)return 1;const n=Object.keys(e),r=Object.keys(t);for(const o of n){if(!r.includes(o))return;var i=e[o],s=t[o];if(Sd(i)&&Sd(s)){if(!kd(i,s))return}else if(i!==s)return}for(const a of r)if(!n.includes(a))return;return 1}function Sd(e){return null!==e&&"object"==typeof e}function Cd(e){const t=[];for(const[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 Ad(e){const r={},t=e.replace(/^\?/,"").split("&");return t.forEach(e=>{var t,n;e&&([t,n]=e.split("="),r[decodeURIComponent(t)]=decodeURIComponent(n))}),r}function Nd(e){var t=e.indexOf("?");if(!t)return"";var n=e.indexOf("#",t);return e.substring(t,0<n?n:void 0)}class Rd{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(let e=1;e<this.blockSize;++e)this.pad_[e]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(n,r){r=r||0;const i=this.W_;if("string"==typeof n)for(let e=0;e<16;e++)i[e]=n.charCodeAt(r)<<24|n.charCodeAt(r+1)<<16|n.charCodeAt(r+2)<<8|n.charCodeAt(r+3),r+=4;else for(let t=0;t<16;t++)i[t]=n[r]<<24|n[r+1]<<16|n[r+2]<<8|n[r+3],r+=4;for(let d=16;d<80;d++){var e=i[d-3]^i[d-8]^i[d-14]^i[d-16];i[d]=4294967295&(e<<1|e>>>31)}let t=this.chain_[0],s=this.chain_[1],o=this.chain_[2],a=this.chain_[3],c=this.chain_[4],l,u;for(let p=0;p<80;p++){u=p<40?p<20?(l=a^s&(o^a),1518500249):(l=s^o^a,1859775393):p<60?(l=s&o|a&(s|o),2400959708):(l=s^o^a,3395469782);var h=(t<<5|t>>>27)+l+c+u+i[p]&4294967295;c=a,a=o,o=4294967295&(s<<30|s>>>2),s=t,t=h}this.chain_[0]=this.chain_[0]+t&4294967295,this.chain_[1]=this.chain_[1]+s&4294967295,this.chain_[2]=this.chain_[2]+o&4294967295,this.chain_[3]=this.chain_[3]+a&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295}update(n,r){if(null!=n){var i=(r=void 0===r?n.length:r)-this.blockSize;let e=0;const s=this.buf_;let t=this.inbuf_;for(;e<r;){if(0===t)for(;e<=i;)this.compress_(n,e),e+=this.blockSize;if("string"==typeof n){for(;e<r;)if(s[t]=n.charCodeAt(e),++t,++e,t===this.blockSize){this.compress_(s),t=0;break}}else for(;e<r;)if(s[t]=n[e],++t,++e,t===this.blockSize){this.compress_(s),t=0;break}}this.inbuf_=t,this.total_+=r}}digest(){const t=[];let e=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let r=this.blockSize-1;56<=r;r--)this.buf_[r]=255&e,e/=256;this.compress_(this.buf_);let n=0;for(let i=0;i<5;i++)for(let e=24;0<=e;e-=8)t[n]=this.chain_[i]>>e&255,++n;return t}}function Pd(e,t){const n=new xd(e,t);return n.subscribe.bind(n)}class xd{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(t){this.forEachObserver(e=>{e.next(t)})}error(t){this.forEachObserver(e=>{e.error(t)}),this.close(t)}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 new Error("Missing Observer.");r=function(e,t){if("object"!=typeof e||null===e)return!1;for(const n of t)if(n in e&&"function"==typeof e[n])return!0;return!1}(e,["next","error","complete"])?e:{next:e,error:t,complete:n},void 0===r.next&&(r.next=Dd),void 0===r.error&&(r.error=Dd),void 0===r.complete&&(r.complete=Dd);var 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,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(t){if(!this.finalized)for(let e=0;e<this.observers.length;e++)this.sendOne(e,t)}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 Dd(){}function Od(e,t,n,r){let i;if(r<t?i="at least "+t:n<r&&(i=0===n?"none":"no more than "+n),i){var s=e+" failed: Was called with "+r+(1===r?" argument.":" arguments.")+" Expects "+i+".";throw new Error(s)}}function Md(e,t){return`${e} failed: ${t} argument `}function Ld(e,t,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(Md(e,t)+"must be a valid function.")}function Fd(e,t,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(Md(e,t)+"must be a valid context object.")}const Ud=function(e){let t=0;for(let r=0;r<e.length;r++){var n=e.charCodeAt(r);n<128?t++:n<2048?t+=2:55296<=n&&n<=56319?(t+=4,r++):t+=3}return t},jd=1e3,qd=2,Vd=144e5,Bd=.5;function Wd(e,t=jd,n=qd){var r=t*Math.pow(n,e),i=Math.round(Bd*r*(Math.random()-.5)*2);return Math.min(Vd,r+i)}function $d(e){return e&&e._delegate?e._delegate:e}class Kd{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}}const zd="[DEFAULT]";class Hd{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){var t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const r=new rd;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{var n=this.getOrInitializeService({instanceIdentifier:t});n&&r.resolve(n)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),n=null!==(n=null==e?void 0:e.optional)&&void 0!==n&&n;if(!this.isInitialized(t)&&!this.shouldAutoInitialize()){if(n)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:t})}catch(e){if(n)return null;throw e}}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:zd})}catch(e){}for(var[t,n]of this.instancesDeferred.entries()){t=this.normalizeInstanceIdentifier(t);try{var r=this.getOrInitializeService({instanceIdentifier:t});n.resolve(r)}catch(e){}}}}clearInstance(e=zd){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(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=zd){return this.instances.has(e)}getOptions(e=zd){return this.instancesOptions.get(e)||{}}initialize(e={}){var{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`);var r,i,s=this.getOrInitializeService({instanceIdentifier:n,options:t});for([r,i]of this.instancesDeferred.entries())n===this.normalizeInstanceIdentifier(r)&&i.resolve(s);return s}onInit(e,t){var n=this.normalizeInstanceIdentifier(t);const r=null!==(i=this.onInitCallbacks.get(n))&&void 0!==i?i:new Set;r.add(e),this.onInitCallbacks.set(n,r);var i=this.instances.get(n);return i&&e(i,n),()=>{r.delete(e)}}invokeOnInitCallbacks(e,t){var n=this.onInitCallbacks.get(t);if(n)for(const 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:(r=e)===zd?void 0:r,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){}var r;return n||null}normalizeInstanceIdentifier(e=zd){return!this.component||this.component.multipleInstances?e:zd}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class Gd{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){const t=this.getProvider(e.name);t.isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);var t=new Hd(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}const Qd=[];(Kh=$h=$h||{})[Kh.DEBUG=0]="DEBUG",Kh[Kh.VERBOSE=1]="VERBOSE",Kh[Kh.INFO=2]="INFO",Kh[Kh.WARN=3]="WARN",Kh[Kh.ERROR=4]="ERROR",Kh[Kh.SILENT=5]="SILENT";const Yd={debug:$h.DEBUG,verbose:$h.VERBOSE,info:$h.INFO,warn:$h.WARN,error:$h.ERROR,silent:$h.SILENT},Jd=$h.INFO,Xd={[$h.DEBUG]:"log",[$h.VERBOSE]:"log",[$h.INFO]:"info",[$h.WARN]:"warn",[$h.ERROR]:"error"},Zd=(e,t,...n)=>{if(!(t<e.logLevel)){var r=(new Date).toISOString(),i=Xd[t];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[i](`[${r}] ${e.name}:`,...n)}};class ep{constructor(e){this.name=e,this._logLevel=Jd,this._logHandler=Zd,this._userLogHandler=null,Qd.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in $h))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?Yd[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,$h.DEBUG,...e),this._logHandler(this,$h.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,$h.VERBOSE,...e),this._logHandler(this,$h.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,$h.INFO,...e),this._logHandler(this,$h.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,$h.WARN,...e),this._logHandler(this,$h.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,$h.ERROR,...e),this._logHandler(this,$h.ERROR,...e)}}class tp{constructor(e){this.container=e}getPlatformInfoString(){const e=this.container.getProviders();return e.map(e=>{if("VERSION"!==(null==(t=e.getComponent())?void 0:t.type))return null;var t,t=e.getImmediate();return`${t.library}/${t.version}`}).filter(e=>e).join(" ")}}const np="@firebase/app",rp=new ep("@firebase/app");var ip;const sp="[DEFAULT]",op={"@firebase/app":"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/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","fire-js":"fire-js",firebase:"fire-js-all"},ap=new Map,cp=new Map;function lp(t,n){try{t.container.addComponent(n)}catch(e){rp.debug(`Component ${n.name} failed to register with FirebaseApp ${t.name}`,e)}}function up(e,t){e.container.addOrOverwriteComponent(t)}function hp(e){var t=e.name;if(cp.has(t))return rp.debug(`There were multiple attempts to register component ${t}.`),!1;cp.set(t,e);for(const n of ap.values())lp(n,e);return!0}function dp(e,t){return e.container.getProvider(t)}const pp=new md("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()","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","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."});class fp{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 Kd("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 pp.create("app-deleted",{appName:this._name})}}const gp="9.6.3";function mp(e,t={}){if("object"!=typeof t){const r=t;t={name:r}}var n=Object.assign({name:sp,automaticDataCollectionEnabled:!1},t);const r=n.name;if("string"!=typeof r||!r)throw pp.create("bad-app-name",{appName:String(r)});var i=ap.get(r);if(i){if(kd(e,i.options)&&kd(n,i.config))return i;throw pp.create("duplicate-app",{appName:r})}const s=new Gd(r);for(const o of cp.values())s.addComponent(o);n=new fp(e,n,s);return ap.set(r,n),n}function vp(e=sp){var t=ap.get(e);if(!t)throw pp.create("no-app",{appName:e});return t}async function yp(e){var t=e.name;ap.has(t)&&(ap.delete(t),await Promise.all(e.container.getProviders().map(e=>e.delete())),e.isDeleted=!0)}function _p(e,t,n){let r=null!==(s=op[e])&&void 0!==s?s:e;n&&(r+=`-${n}`);var i=r.match(/\s|\//),s=t.match(/\s|\//);if(i||s){const o=[`Unable to register library "${r}" with version "${t}":`];return i&&o.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&s&&o.push("and"),s&&o.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void rp.warn(o.join(" "))}hp(new Kd(`${r}-version`,()=>({library:r,version:t}),"VERSION"))}function wp(e,t){if(null!==e&&"function"!=typeof e)throw pp.create("invalid-log-argument");!function(s,e){for(const t of Qd){let i=null;e&&e.level&&(i=Yd[e.level]),t.userLogHandler=null===s?null:(e,t,...n)=>{var r=n.map(e=>{if(null==e)return null;if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e)return e.toString();if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch(e){return null}}).filter(e=>e).join(" ");t>=(null!==i&&void 0!==i?i:e.logLevel)&&s({level:$h[t].toLowerCase(),message:r,args:n,type:e.name})}}}(e,t)}function bp(e){var t;t=e,Qd.forEach(e=>{e.setLogLevel(t)})}ip="",hp(new Kd("platform-logger",e=>new tp(e),"PRIVATE")),_p(np,"0.7.13",ip),_p(np,"0.7.13","esm2017"),_p("fire-js","");var Ip=Object.freeze({__proto__:null,SDK_VERSION:gp,_DEFAULT_ENTRY_NAME:sp,_addComponent:lp,_addOrOverwriteComponent:up,_apps:ap,_clearComponents:function(){cp.clear()},_components:cp,_getProvider:dp,_registerComponent:hp,_removeServiceInstance:function(e,t,n=sp){dp(e,t).clearInstance(n)},deleteApp:yp,getApp:vp,getApps:function(){return Array.from(ap.values())},initializeApp:mp,onLog:wp,registerVersion:_p,setLogLevel:bp,FirebaseError:gd});class Tp{constructor(e,t){this._delegate=e,this.firebase=t,lp(e,new Kd("app-compat",()=>this,"PUBLIC")),this.container=e.container}get automaticDataCollectionEnabled(){return this._delegate.automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this._delegate.automaticDataCollectionEnabled=e}get name(){return this._delegate.name}get options(){return this._delegate.options}delete(){return new Promise(e=>{this._delegate.checkDestroyed(),e()}).then(()=>(this.firebase.INTERNAL.removeApp(this.name),yp(this._delegate)))}_getService(e,t=sp){var n;this._delegate.checkDestroyed();const r=this._delegate.container.getProvider(e);return r.isInitialized()||"EXPLICIT"!==(null===(n=r.getComponent())||void 0===n?void 0:n.instantiationMode)||r.initialize(),r.getImmediate({identifier:t})}_removeServiceInstance(e,t=sp){this._delegate.container.getProvider(e).clearInstance(t)}_addComponent(e){lp(this._delegate,e)}_addOrOverwriteComponent(e){up(this._delegate,e)}toJSON(){return{name:this.name,automaticDataCollectionEnabled:this.automaticDataCollectionEnabled,options:this.options}}}const Ep=new md("app-compat","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance."});function kp(i){const s={},o={__esModule:!0,initializeApp:function(e,t={}){var n=mp(e,t);if(bd(s,n.name))return s[n.name];var r=new i(n,o);return s[n.name]=r},app:a,registerVersion:_p,setLogLevel:bp,onLog:wp,apps:null,SDK_VERSION:gp,INTERNAL:{registerComponent:function(n){const r=n.name,t=r.replace("-compat","");{var e;hp(n)&&"PUBLIC"===n.type&&(e=(e=a())=>{if("function"!=typeof e[t])throw Ep.create("invalid-app-argument",{appName:r});return e[t]()},void 0!==n.serviceProps&&nd(e,n.serviceProps),o[t]=e,i.prototype[t]=function(...e){const t=this._getService.bind(this,r);return t.apply(this,n.multipleInstances?e:[])})}return"PUBLIC"===n.type?o[t]:null},removeApp:function(e){delete s[e]},useAsService:function(e,t){if("serverAuth"===t)return null;var n=t;return n},modularAPIs:Ip}};function a(e){if(e=e||sp,!bd(s,e))throw Ep.create("no-app",{appName:e});return s[e]}return o.default=o,Object.defineProperty(o,"apps",{get:function(){return Object.keys(s).map(e=>s[e])}}),a.App=i,o}l=function e(){const t=kp(Tp);return t.INTERNAL=Object.assign(Object.assign({},t.INTERNAL),{createFirebaseNamespace:e,extendNamespace:function(e){nd(t,e)},createSubscribe:Pd,ErrorFactory:md,deepExtend:nd}),t}();const Sp=new ep("@firebase/app-compat");if("object"==typeof self&&self.self===self&&void 0!==self.firebase){Sp.warn(`
|
|
2
2
|
Warning: Firebase is already defined in the global scope. Please make sure
|
|
3
3
|
Firebase library is only loaded once.
|
|
4
4
|
`);const YW=self.firebase.SDK_VERSION;YW&&0<=YW.indexOf("LITE")&&Sp.warn(`
|
|
5
5
|
Warning: You are trying to load Firebase while using Firebase Performance standalone script.
|
|
6
6
|
You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.
|
|
7
|
-
`)}const Cp=l;_p("@firebase/app-compat","0.1.13",void 0);Cp.registerVersion("firebase","9.6.2","app-compat");function Ap(n){return new Promise(function(e,t){n.onsuccess=function(){e(n.result)},n.onerror=function(){t(n.error)}})}function Np(n,r,i){var s,e=new Promise(function(e,t){Ap(s=n[r].apply(n,i)).then(e,t)});return e.request=s,e}function Rp(e,n,t){t.forEach(function(t){Object.defineProperty(e.prototype,t,{get:function(){return this[n][t]},set:function(e){this[n][t]=e}})})}function Pp(t,n,r,e){e.forEach(function(e){e in r.prototype&&(t.prototype[e]=function(){return Np(this[n],e,arguments)})})}function xp(t,n,r,e){e.forEach(function(e){e in r.prototype&&(t.prototype[e]=function(){return this[n][e].apply(this[n],arguments)})})}function Dp(e,r,t,n){n.forEach(function(n){n in t.prototype&&(e.prototype[n]=function(){return e=this[r],(t=Np(e,n,arguments)).then(function(e){if(e)return new Mp(e,t.request)});var e,t})})}function Op(e){this._index=e}function Mp(e,t){this._cursor=e,this._request=t}function Lp(e){this._store=e}function Fp(n){this._tx=n,this.complete=new Promise(function(e,t){n.oncomplete=function(){e()},n.onerror=function(){t(n.error)},n.onabort=function(){t(n.error)}})}function Up(e,t,n){this._db=e,this.oldVersion=t,this.transaction=new Fp(n)}function jp(e){this._db=e}function qp(e,t,n){var r=Np(indexedDB,"open",[e,t]),i=r.request;return i&&(i.onupgradeneeded=function(e){n&&n(new Up(i.result,e.oldVersion,i.transaction))}),r.then(function(e){return new jp(e)})}function Vp(e){return Np(indexedDB,"deleteDatabase",[e])}Rp(Op,"_index",["name","keyPath","multiEntry","unique"]),Pp(Op,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),Dp(Op,"_index",IDBIndex,["openCursor","openKeyCursor"]),Rp(Mp,"_cursor",["direction","key","primaryKey","value"]),Pp(Mp,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach(function(n){n in IDBCursor.prototype&&(Mp.prototype[n]=function(){var t=this,e=arguments;return Promise.resolve().then(function(){return t._cursor[n].apply(t._cursor,e),Ap(t._request).then(function(e){if(e)return new Mp(e,t._request)})})})}),Lp.prototype.createIndex=function(){return new Op(this._store.createIndex.apply(this._store,arguments))},Lp.prototype.index=function(){return new Op(this._store.index.apply(this._store,arguments))},Rp(Lp,"_store",["name","keyPath","indexNames","autoIncrement"]),Pp(Lp,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),Dp(Lp,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),xp(Lp,"_store",IDBObjectStore,["deleteIndex"]),Fp.prototype.objectStore=function(){return new Lp(this._tx.objectStore.apply(this._tx,arguments))},Rp(Fp,"_tx",["objectStoreNames","mode"]),xp(Fp,"_tx",IDBTransaction,["abort"]),Up.prototype.createObjectStore=function(){return new Lp(this._db.createObjectStore.apply(this._db,arguments))},Rp(Up,"_db",["name","version","objectStoreNames"]),xp(Up,"_db",IDBDatabase,["deleteObjectStore","close"]),jp.prototype.transaction=function(){return new Fp(this._db.transaction.apply(this._db,arguments))},Rp(jp,"_db",["name","version","objectStoreNames"]),xp(jp,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach(function(s){[Lp,Op].forEach(function(e){s in e.prototype&&(e.prototype[s.replace("open","iterate")]=function(){var e,t=(e=arguments,Array.prototype.slice.call(e)),n=t[t.length-1],r=this._store||this._index,i=r[s].apply(r,t.slice(0,-1));i.onsuccess=function(){n(i.result)}})})}),[Op,Lp].forEach(function(e){e.prototype.getAll||(e.prototype.getAll=function(e,n){var r=this,i=[];return new Promise(function(t){r.iterateCursor(e,function(e){e?(i.push(e.value),void 0===n||i.length!=n?e.continue():t(i)):t(i)})})})});ze="@firebase/installations",c="0.5.5";const Bp=1e4,Wp="w:0.5.5",Kp="FIS_v2",$p="https://firebaseinstallations.googleapis.com/v1",zp=36e5;const Hp=new md("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 Gp(e){return e instanceof gd&&e.code.includes("request-failed")}function Qp({projectId:e}){return`${$p}/projects/${e}/installations`}function Yp(e){return{token:e.token,requestStatus:2,expiresIn:(e=e.expiresIn,Number(e.replace("s","000"))),creationTime:Date.now()}}async function Jp(e,t){var n=(await t.json()).error;return Hp.create("request-failed",{requestName:e,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})}function Xp({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function Zp(e,{refreshToken:t}){const n=Xp(e);return n.append("Authorization",(t=t,`${Kp} ${t}`)),n}async function ef(e){var t=await e();return 500<=t.status&&t.status<600?e():t}function tf(t){return new Promise(e=>{setTimeout(e,t)})}const nf=/^[cdef][\w-]{21}$/,rf="";function sf(){try{const t=new Uint8Array(17),n=self.crypto||self.msCrypto;n.getRandomValues(t),t[0]=112+t[0]%16;var e=function(e){const t=function(e){const t=btoa(String.fromCharCode(...e));return t.replace(/\+/g,"-").replace(/\//g,"_")}(e);return t.substr(0,22)}(t);return nf.test(e)?e:rf}catch(e){return rf}}function of(e){return`${e.appName}!${e.appId}`}const af=new Map;function cf(e,t){var n=of(e);lf(n,t),function(e,t){const n=function(){!uf&&"BroadcastChannel"in self&&(uf=new BroadcastChannel("[Firebase] FID Change"),uf.onmessage=e=>{lf(e.data.key,e.data.fid)});return uf}();n&&n.postMessage({key:e,fid:t});0===af.size&&uf&&(uf.close(),uf=null)}(n,t)}function lf(e,t){var n=af.get(e);if(n)for(const r of n)r(t)}let uf=null;const hf="firebase-installations-store";let df=null;function pf(){return df=df||qp("firebase-installations-database",1,e=>{0===e.oldVersion&&e.createObjectStore(hf)}),df}async function ff(e,t){var n=of(e);const r=await pf(),i=r.transaction(hf,"readwrite"),s=i.objectStore(hf);var o=await s.get(n);return await s.put(t,n),await i.complete,o&&o.fid===t.fid||cf(e,t.fid),t}async function gf(e){var t=of(e);const n=await pf(),r=n.transaction(hf,"readwrite");await r.objectStore(hf).delete(t),await r.complete}async function mf(e,t){var n=of(e);const r=await pf(),i=r.transaction(hf,"readwrite"),s=i.objectStore(hf);var o=await s.get(n),a=t(o);return void 0===a?await s.delete(n):await s.put(a,n),await i.complete,!a||o&&o.fid===a.fid||cf(e,a.fid),a}async function vf(n){let r;var e=await mf(n,e=>{var t=_f(e||{fid:sf(),registrationStatus:0}),t=function(e,t){{if(0!==t.registrationStatus)return 1===t.registrationStatus?{installationEntry:t,registrationPromise:async function(e){let t=await yf(e);for(;1===t.registrationStatus;)await tf(100),t=await yf(e);if(0!==t.registrationStatus)return t;{var{installationEntry:n,registrationPromise:r}=await vf(e);return r||n}}(e)}:{installationEntry:t};if(!navigator.onLine){var n=Promise.reject(Hp.create("app-offline"));return{installationEntry:t,registrationPromise:n}}var r={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},n=async function(t,n){try{var e=await async function(e,{fid:t}){const n=Qp(e);var r=Xp(e),i={fid:t,authVersion:Kp,appId:e.appId,sdkVersion:Wp};const s={method:"POST",headers:r,body:JSON.stringify(i)},o=await ef(()=>fetch(n,s));if(o.ok){i=await o.json();return{fid:i.fid||t,registrationStatus:2,refreshToken:i.refreshToken,authToken:Yp(i.authToken)}}throw await Jp("Create Installation",o)}(t,n);return ff(t,e)}catch(e){throw Gp(e)&&409===e.customData.serverCode?await gf(t):await ff(t,{fid:n.fid,registrationStatus:0}),e}}(e,r);return{installationEntry:r,registrationPromise:n}}}(n,t);return r=t.registrationPromise,t.installationEntry});return e.fid===rf?{installationEntry:await r}:{installationEntry:e,registrationPromise:r}}function yf(e){return mf(e,e=>{if(!e)throw Hp.create("installation-not-found");return _f(e)})}function _f(e){return 1===(t=e).registrationStatus&&t.registrationTime+Bp<Date.now()?{fid:e.fid,registrationStatus:0}:e;var t}async function wf({appConfig:e,platformLoggerProvider:t},n){const r=([i,s]=[e,n["fid"]],`${Qp(i)}/${s}/authTokens:generate`);var i,s;const o=Zp(e,n),a=t.getImmediate({optional:!0});a&&o.append("x-firebase-client",a.getPlatformInfoString());var c={installation:{sdkVersion:Wp}};const l={method:"POST",headers:o,body:JSON.stringify(c)},u=await ef(()=>fetch(r,l));if(u.ok)return Yp(await u.json());throw await Jp("Generate Auth Token",u)}async function bf(r,i=!1){let s;var e=await mf(r.appConfig,e=>{if(!If(e))throw Hp.create("not-registered");var t,n=e.authToken;if(i||2!==(t=n).requestStatus||function(e){var t=Date.now();return t<e.creationTime||e.creationTime+e.expiresIn<t+zp}(t)){if(1===n.requestStatus)return s=async function(e,t){let n=await Tf(e.appConfig);for(;1===n.authToken.requestStatus;)await tf(100),n=await Tf(e.appConfig);var r=n.authToken;return 0===r.requestStatus?bf(e,t):r}(r,i),e;if(!navigator.onLine)throw Hp.create("app-offline");n=(t=e,n={requestStatus:1,requestTime:Date.now()},Object.assign(Object.assign({},t),{authToken:n}));return s=async function(t,n){try{var r=await wf(t,n),e=Object.assign(Object.assign({},n),{authToken:r});return await ff(t.appConfig,e),r}catch(e){throw!Gp(e)||401!==e.customData.serverCode&&404!==e.customData.serverCode?(r=Object.assign(Object.assign({},n),{authToken:{requestStatus:0}}),await ff(t.appConfig,r)):await gf(t.appConfig),e}}(r,n),n}return e});return s?await s:e.authToken}function Tf(e){return mf(e,e=>{if(!If(e))throw Hp.create("not-registered");var t,n=e.authToken;return 1===(t=n).requestStatus&&t.requestTime+Bp<Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e})}function If(e){return void 0!==e&&2===e.registrationStatus}async function Ef(e,t=!1){var n,r=e;return e=r.appConfig,await((n=(await vf(e)).registrationPromise)&&await n),(await bf(r,t)).token}function kf(e){return Hp.create("missing-app-config-values",{valueName:e})}const Sf="installations",Cf=e=>{var t=e.getProvider("app").getImmediate();return{app:t,appConfig:function(e){if(!e||!e.options)throw kf("App Configuration");if(!e.name)throw kf("App Name");for(const t of["projectId","apiKey","appId"])if(!e.options[t])throw kf(t);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t),platformLoggerProvider:dp(t,"platform-logger"),_delete:()=>Promise.resolve()}},Af=e=>{const t=dp(e.getProvider("app").getImmediate(),Sf).getImmediate();return{getId:()=>async function(e){var t=e;const{installationEntry:n,registrationPromise:r}=await vf(t.appConfig);return(r||bf(t)).catch(console.error),n.fid}(t),getToken:e=>Ef(t,e)}};hp(new $d(Sf,Cf,"PUBLIC")),hp(new $d("installations-internal",Af,"PRIVATE")),_p(ze,c),_p(ze,c,"esm2017");const Nf="analytics",Rf="firebase_id",Pf="origin",xf="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",Df="https://www.googletagmanager.com/gtag/js",Of=new ep("@firebase/analytics");function Mf(e){return Promise.all(e.map(e=>e.catch(e=>e)))}function Lf(r,i,s,o){return async function(e,t,n){try{"event"===e?await async function(e,n,r,i,s){try{let t=[];if(s&&s.send_to){let e=s.send_to;Array.isArray(e)||(e=[e]);const c=await Mf(r);for(const l of e){var o=c.find(e=>e.measurementId===l),a=o&&n[o.appId];if(!a){t=[];break}t.push(a)}}0===t.length&&(t=Object.values(n)),await Promise.all(t),e("event",i,s||{})}catch(e){Of.error(e)}}(r,i,s,t,n):"config"===e?await async function(e,t,n,r,i,s){var o=r[i];try{if(o)await t[o];else{const c=await Mf(n);var a=c.find(e=>e.measurementId===i);a&&await t[a.appId]}}catch(e){Of.error(e)}e("config",i,s)}(r,i,s,o,t,n):r("set",t)}catch(e){Of.error(e)}}}const Ff=new md("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-intialized 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.'}),Uf=30;const jf=new class{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]}};async function qf(e){var t,{appId:n,apiKey:r}=e,r={method:"GET",headers:new Headers({Accept:"application/json","x-goog-api-key":r})},n=xf.replace("{app-id}",n);const i=await fetch(n,r);if(200===i.status||304===i.status)return i.json();{let e="";try{var s=await i.json();null!==(t=s.error)&&void 0!==t&&t.message&&(e=s.error.message)}catch(e){}throw Ff.create("config-fetch-failed",{httpStatus:i.status,responseMessage:e})}}async function Vf(e,t=jf,n){var{appId:r,apiKey:i,measurementId:s}=e.options;if(!r)throw Ff.create("no-app-id");if(!i){if(s)return{measurementId:s,appId:r};throw Ff.create("no-api-key")}var o=t.getThrottleMetadata(r)||{backoffCount:0,throttleEndTimeMillis:Date.now()};const a=new Kf;return setTimeout(async()=>{a.abort()},void 0!==n?n:6e4),async function t(n,{throttleEndTimeMillis:e,backoffCount:r},i,s=jf){const{appId:o,measurementId:a}=n;try{await Bf(i,e)}catch(e){if(a)return Of.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. [${e.message}]`),{appId:o,measurementId:a};throw e}try{const c=await qf(n);return s.deleteThrottleMetadata(o),c}catch(e){if(!Wf(e)){if(s.deleteThrottleMetadata(o),a)return Of.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. [${e.message}]`),{appId:o,measurementId:a};throw e}const l=503===Number(e.customData.httpStatus)?Wd(r,s.intervalMillis,Uf):Wd(r,s.intervalMillis),u={throttleEndTimeMillis:Date.now()+l,backoffCount:r+1};return s.setThrottleMetadata(o,u),Of.debug(`Calling attemptFetch again in ${l} millis`),t(n,u,i,s)}}({appId:r,apiKey:i,measurementId:s},o,a,t)}function Bf(i,s){return new Promise((e,t)=>{var n=Math.max(s-Date.now(),0);const r=setTimeout(e,n);i.addEventListener(()=>{clearTimeout(r),t(Ff.create("fetch-throttle",{throttleEndTimeMillis:s}))})})}function Wf(e){if(!(e instanceof gd&&e.customData))return!1;var t=Number(e.customData.httpStatus);return 429===t||500===t||503===t||504===t}class Kf{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}async function $f(t,e,n,r,i,s,o){const a=Vf(t);a.then(e=>{n[e.measurementId]=e.appId,t.options.measurementId&&e.measurementId!==t.options.measurementId&&Of.warn(`The measurement ID in the local Firebase config (${t.options.measurementId})`+` does not match the measurement ID fetched from the server (${e.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=>Of.error(e)),e.push(a);var c=async function(){if(!dd())return Of.warn(Ff.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;try{await pd()}catch(e){return Of.warn(Ff.create("indexeddb-unavailable",{errorInfo:e}).message),!1}return!0}().then(e=>{if(e)return r.getId()}),[l,u]=await Promise.all([a,c]);!function(){var e=window.document.getElementsByTagName("script");for(const t of Object.values(e))if(t.src&&t.src.includes(Df))return t}()&&function(e,t){const n=document.createElement("script");n.src=`${Df}?l=${e}&id=${t}`,n.async=!0,document.head.appendChild(n)}(s,l.measurementId),i("js",new Date);const h=null!==(c=null==o?void 0:o.config)&&void 0!==c?c:{};return h[Pf]="firebase",h.update=!0,null!=u&&(h[Rf]=u),i("config",l.measurementId,h),l.measurementId}class zf{constructor(e){this.app=e}_delete(){return delete Hf[this.app.options.appId],Promise.resolve()}}let Hf={},Gf=[];const Qf={};let Yf="dataLayer",Jf="gtag",Xf,Zf,eg=!1;function tg(e){if(eg)throw Ff.create("already-initialized");e.dataLayerName&&(Yf=e.dataLayerName),e.gtagName&&(Jf=e.gtagName)}function ng(e,t,n){!function(){const e=[];var t;cd()&&e.push("This is a browser extension environment."),fd()||e.push("Cookies are not available."),0<e.length&&(t=e.map((e,t)=>`(${t+1}) ${e}`).join(" "),t=Ff.create("invalid-analytics-context",{errorInfo:t}),Of.warn(t.message))}();var r,i,s=e.options.appId;if(!s)throw Ff.create("no-app-id");if(!e.options.apiKey){if(!e.options.measurementId)throw Ff.create("no-api-key");Of.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.')}if(null!=Hf[s])throw Ff.create("already-exists",{id:s});return eg||(function(e){let t=[];Array.isArray(window[e])?t=window[e]:window[e]=t,t}(Yf),{wrappedGtag:r,gtagCore:i}=function(e,t,n,r,i){let s=function(){window[r].push(arguments)};return window[i]&&"function"==typeof window[i]&&(s=window[i]),window[i]=Lf(s,e,t,n),{gtagCore:s,wrappedGtag:window[i]}}(Hf,Gf,Qf,Yf,Jf),Zf=r,Xf=i,eg=!0),Hf[s]=$f(e,Gf,Qf,t,Xf,Yf,n),new zf(e)}async function rg(){if(cd())return!1;if(!fd())return!1;if(!dd())return!1;try{return await pd()}catch(e){return!1}}function ig(e,t,n){e=Kd(e),async function(e,t,n,r){if(r&&r.global)return e("set",{screen_name:n}),Promise.resolve();e("config",await t,{update:!0,screen_name:n})}(Zf,Hf[e.app.options.appId],t,n).catch(e=>Of.error(e))}function sg(e,t,n){e=Kd(e),async function(e,t,n,r){if(r&&r.global)return e("set",{user_id:n}),Promise.resolve();e("config",await t,{update:!0,user_id:n})}(Zf,Hf[e.app.options.appId],t,n).catch(e=>Of.error(e))}function og(e,t,n){e=Kd(e),async function(e,t,n,r){if(r&&r.global){const i={};for(const s of Object.keys(n))i[`user_properties.${s}`]=n[s];return e("set",i),Promise.resolve()}e("config",await t,{update:!0,user_properties:n})}(Zf,Hf[e.app.options.appId],t,n).catch(e=>Of.error(e))}function ag(e,t){e=Kd(e),async function(e,t){var n=await e;window[`ga-disable-${n}`]=!t}(Hf[e.app.options.appId],t).catch(e=>Of.error(e))}function cg(e,t,n,r){e=Kd(e),async function(e,t,n,r,i){var s;i&&i.global?e("event",n,r):(s=await t,e("event",n,Object.assign(Object.assign({},r),{send_to:s})))}(Zf,Hf[e.app.options.appId],t,n,r).catch(e=>Of.error(e))}const lg="@firebase/analytics";hp(new $d(Nf,(e,{options:t})=>{return ng(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),t)},"PUBLIC")),hp(new $d("analytics-internal",function(e){try{const r=e.getProvider(Nf).getImmediate();return{logEvent:(e,t,n)=>cg(r,e,t,n)}}catch(e){throw Ff.create("interop-component-reg-failed",{reason:e})}},"PRIVATE")),_p(lg,"0.7.5"),_p(lg,"0.7.5","esm2017");var ug,hg;class dg{constructor(e,t){this.app=e,this._delegate=t}logEvent(e,t,n){cg(this._delegate,e,t,n)}setCurrentScreen(e,t){ig(this._delegate,e,t)}setUserId(e,t){sg(this._delegate,e,t)}setUserProperties(e,t){og(this._delegate,e,t)}setAnalyticsCollectionEnabled(e){ag(this._delegate,e)}}(z=ug=ug||{}).ADD_SHIPPING_INFO="add_shipping_info",z.ADD_PAYMENT_INFO="add_payment_info",z.ADD_TO_CART="add_to_cart",z.ADD_TO_WISHLIST="add_to_wishlist",z.BEGIN_CHECKOUT="begin_checkout",z.CHECKOUT_PROGRESS="checkout_progress",z.EXCEPTION="exception",z.GENERATE_LEAD="generate_lead",z.LOGIN="login",z.PAGE_VIEW="page_view",z.PURCHASE="purchase",z.REFUND="refund",z.REMOVE_FROM_CART="remove_from_cart",z.SCREEN_VIEW="screen_view",z.SEARCH="search",z.SELECT_CONTENT="select_content",z.SELECT_ITEM="select_item",z.SELECT_PROMOTION="select_promotion",z.SET_CHECKOUT_OPTION="set_checkout_option",z.SHARE="share",z.SIGN_UP="sign_up",z.TIMING_COMPLETE="timing_complete",z.VIEW_CART="view_cart",z.VIEW_ITEM="view_item",z.VIEW_ITEM_LIST="view_item_list",z.VIEW_PROMOTION="view_promotion",z.VIEW_SEARCH_RESULTS="view_search_results";const pg=e=>{var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("analytics").getImmediate();return new dg(t,n)};hg={Analytics:dg,settings:tg,isSupported:rg,EventName:ug},Cp.INTERNAL.registerComponent(new $d("analytics-compat",pg,"PUBLIC").setServiceProps(hg).setMultipleInstances(!0)),Cp.registerVersion("@firebase/analytics-compat","0.1.6");const fg=new Map,gg={activated:!1,tokenObservers:[]},mg={initialized:!1,enabled:!1};function vg(e){return fg.get(e)||gg}function yg(e,t){fg.set(e,t)}const _g="https://content-firebaseappcheck.googleapis.com/v1beta",wg="exchangeDebugToken",bg={OFFSET_DURATION:3e5,RETRIAL_MIN_WAIT:3e4,RETRIAL_MAX_WAIT:96e4};class Tg{constructor(e,t,n,r,i){if(this.operation=e,this.retryPolicy=t,this.getWaitDuration=n,this.lowerBound=r,this.upperBound=i,this.pending=null,i<(this.nextErrorWaitInterval=r))throw new Error("Proactive refresh lower bound greater than upper bound!")}start(){this.nextErrorWaitInterval=this.lowerBound,this.process(!0).catch(()=>{})}stop(){this.pending&&(this.pending.reject("cancelled"),this.pending=null)}isRunning(){return!!this.pending}async process(e){this.stop();try{this.pending=new rd,t=this.getNextRun(e),await new Promise(e=>{setTimeout(e,t)}),this.pending.resolve(),await this.pending.promise,this.pending=new rd,await this.operation(),this.pending.resolve(),await this.pending.promise,this.process(!0).catch(()=>{})}catch(e){this.retryPolicy(e)?this.process(!1).catch(()=>{}):this.stop()}var t}getNextRun(e){if(e)return this.nextErrorWaitInterval=this.lowerBound,this.getWaitDuration();var t=this.nextErrorWaitInterval;return this.nextErrorWaitInterval*=2,this.nextErrorWaitInterval>this.upperBound&&(this.nextErrorWaitInterval=this.upperBound),t}}const Ig=new md("appCheck","AppCheck",{"already-initialized":"You have already called initializeAppCheck() for FirebaseApp {$appName} with different options. To avoid this error, call initializeAppCheck() with the same options as when it was originally called. This will return the already initialized instance.","use-before-activation":"App Check is being used before initializeAppCheck() is called for FirebaseApp {$appName}. Call initializeAppCheck() before instantiating other Firebase services.","fetch-network-error":"Fetch failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-parse-error":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status-error":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","recaptcha-error":"ReCAPTCHA error.",throttled:"Requests throttled due to {$httpStatus} error. Attempts allowed again after {$time}"});function Eg(e=!1){var t;return e?null===(t=self.grecaptcha)||void 0===t?void 0:t.enterprise:self.grecaptcha}function kg(e){if(!vg(e).activated)throw Ig.create("use-before-activation",{appName:e.name})}function Sg(e){var t=Math.round(e/1e3),n=Math.floor(t/86400),r=Math.floor((t-3600*n*24)/3600),i=Math.floor((t-3600*n*24-3600*r)/60),t=t-3600*n*24-3600*r-60*i;let s="";return n&&(s+=Cg(n)+"d:"),r&&(s+=Cg(r)+"h:"),s+=Cg(i)+"m:"+Cg(t)+"s",s}function Cg(e){return 0===e?"00":10<=e?e.toString():"0"+e}async function Ag({url:e,body:t},n){const r={"Content-Type":"application/json"},i=n.getImmediate({optional:!0});i&&(r["X-Firebase-Client"]=i.getPlatformInfoString());var s={method:"POST",body:JSON.stringify(t),headers:r};let o;try{o=await fetch(e,s)}catch(e){throw Ig.create("fetch-network-error",{originalErrorMessage:e.message})}if(200!==o.status)throw Ig.create("fetch-status-error",{httpStatus:o.status});let a;try{a=await o.json()}catch(e){throw Ig.create("fetch-parse-error",{originalErrorMessage:e.message})}var c=a.ttl.match(/^([\d.]+)(s)$/);if(!c||!c[2]||isNaN(Number(c[1])))throw Ig.create("fetch-parse-error",{originalErrorMessage:"ttl field (timeToLive) is not in standard Protobuf Duration "+`format: ${a.ttl}`});s=1e3*Number(c[1]),c=Date.now();return{token:a.attestationToken,expireTimeMillis:c+s,issuedAtTimeMillis:c}}const Ng="firebase-app-check-database",Rg=1,Pg="firebase-app-check-store",xg="debug-token";let Dg=null;function Og(){return Dg||(Dg=new Promise((t,n)=>{try{const e=indexedDB.open(Ng,Rg);e.onsuccess=e=>{t(e.target.result)},e.onerror=e=>{var t;n(Ig.create("storage-open",{originalErrorMessage:null===(t=e.target.error)||void 0===t?void 0:t.message}))},e.onupgradeneeded=e=>{const t=e.target.result;0===e.oldVersion&&t.createObjectStore(Pg,{keyPath:"compositeKey"})}}catch(e){n(Ig.create("storage-open",{originalErrorMessage:e.message}))}}),Dg)}async function Mg(e,t){const n=await Og(),r=n.transaction(Pg,"readwrite"),i=r.objectStore(Pg),s=i.put({compositeKey:e,value:t});return new Promise((t,n)=>{s.onsuccess=e=>{t()},r.onerror=e=>{var t;n(Ig.create("storage-set",{originalErrorMessage:null===(t=e.target.error)||void 0===t?void 0:t.message}))}})}async function Lg(e){const t=await Og(),i=t.transaction(Pg,"readonly"),n=i.objectStore(Pg),s=n.get(e);return new Promise((n,r)=>{s.onsuccess=e=>{var t=e.target.result;n(t?t.value:void 0)},i.onerror=e=>{var t;r(Ig.create("storage-get",{originalErrorMessage:null===(t=e.target.error)||void 0===t?void 0:t.message}))}})}function Fg(e){return`${e.options.appId}-${e.name}`}const Ug=new ep("@firebase/app-check");async function jg(t){if(dd()){let e=void 0;try{e=await Lg(Fg(t))}catch(e){Ug.warn(`Failed to read token from IndexedDB. Error: ${e}`)}return e}}function qg(e,t){return dd()?Mg(Fg(e),t).catch(e=>{Ug.warn(`Failed to write token to IndexedDB. Error: ${e}`)}):Promise.resolve()}async function Vg(){let e=void 0;try{e=await Lg(xg)}catch(e){}if(e)return e;var t,n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0,n="x"===e?t:3&t|8;return n.toString(16)});return t=n,Mg(xg,t).catch(e=>Ug.warn(`Failed to persist debug token to IndexedDB. Error: ${e}`)),n}function Bg(){return mg.enabled}async function Wg(){var e=mg;if(e.enabled&&e.token)return e.token.promise;throw Error(`
|
|
7
|
+
`)}const Cp=l;_p("@firebase/app-compat","0.1.14",void 0);Cp.registerVersion("firebase","9.6.3","app-compat");function Ap(n){return new Promise(function(e,t){n.onsuccess=function(){e(n.result)},n.onerror=function(){t(n.error)}})}function Np(n,r,i){var s,e=new Promise(function(e,t){Ap(s=n[r].apply(n,i)).then(e,t)});return e.request=s,e}function Rp(e,n,t){t.forEach(function(t){Object.defineProperty(e.prototype,t,{get:function(){return this[n][t]},set:function(e){this[n][t]=e}})})}function Pp(t,n,r,e){e.forEach(function(e){e in r.prototype&&(t.prototype[e]=function(){return Np(this[n],e,arguments)})})}function xp(t,n,r,e){e.forEach(function(e){e in r.prototype&&(t.prototype[e]=function(){return this[n][e].apply(this[n],arguments)})})}function Dp(e,r,t,n){n.forEach(function(n){n in t.prototype&&(e.prototype[n]=function(){return e=this[r],(t=Np(e,n,arguments)).then(function(e){if(e)return new Mp(e,t.request)});var e,t})})}function Op(e){this._index=e}function Mp(e,t){this._cursor=e,this._request=t}function Lp(e){this._store=e}function Fp(n){this._tx=n,this.complete=new Promise(function(e,t){n.oncomplete=function(){e()},n.onerror=function(){t(n.error)},n.onabort=function(){t(n.error)}})}function Up(e,t,n){this._db=e,this.oldVersion=t,this.transaction=new Fp(n)}function jp(e){this._db=e}function qp(e,t,n){var r=Np(indexedDB,"open",[e,t]),i=r.request;return i&&(i.onupgradeneeded=function(e){n&&n(new Up(i.result,e.oldVersion,i.transaction))}),r.then(function(e){return new jp(e)})}function Vp(e){return Np(indexedDB,"deleteDatabase",[e])}Rp(Op,"_index",["name","keyPath","multiEntry","unique"]),Pp(Op,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),Dp(Op,"_index",IDBIndex,["openCursor","openKeyCursor"]),Rp(Mp,"_cursor",["direction","key","primaryKey","value"]),Pp(Mp,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach(function(n){n in IDBCursor.prototype&&(Mp.prototype[n]=function(){var t=this,e=arguments;return Promise.resolve().then(function(){return t._cursor[n].apply(t._cursor,e),Ap(t._request).then(function(e){if(e)return new Mp(e,t._request)})})})}),Lp.prototype.createIndex=function(){return new Op(this._store.createIndex.apply(this._store,arguments))},Lp.prototype.index=function(){return new Op(this._store.index.apply(this._store,arguments))},Rp(Lp,"_store",["name","keyPath","indexNames","autoIncrement"]),Pp(Lp,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),Dp(Lp,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),xp(Lp,"_store",IDBObjectStore,["deleteIndex"]),Fp.prototype.objectStore=function(){return new Lp(this._tx.objectStore.apply(this._tx,arguments))},Rp(Fp,"_tx",["objectStoreNames","mode"]),xp(Fp,"_tx",IDBTransaction,["abort"]),Up.prototype.createObjectStore=function(){return new Lp(this._db.createObjectStore.apply(this._db,arguments))},Rp(Up,"_db",["name","version","objectStoreNames"]),xp(Up,"_db",IDBDatabase,["deleteObjectStore","close"]),jp.prototype.transaction=function(){return new Fp(this._db.transaction.apply(this._db,arguments))},Rp(jp,"_db",["name","version","objectStoreNames"]),xp(jp,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach(function(s){[Lp,Op].forEach(function(e){s in e.prototype&&(e.prototype[s.replace("open","iterate")]=function(){var e,t=(e=arguments,Array.prototype.slice.call(e)),n=t[t.length-1],r=this._store||this._index,i=r[s].apply(r,t.slice(0,-1));i.onsuccess=function(){n(i.result)}})})}),[Op,Lp].forEach(function(e){e.prototype.getAll||(e.prototype.getAll=function(e,n){var r=this,i=[];return new Promise(function(t){r.iterateCursor(e,function(e){e?(i.push(e.value),void 0===n||i.length!=n?e.continue():t(i)):t(i)})})})});ze="@firebase/installations",c="0.5.5";const Bp=1e4,Wp="w:0.5.5",$p="FIS_v2",Kp="https://firebaseinstallations.googleapis.com/v1",zp=36e5;const Hp=new md("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 Gp(e){return e instanceof gd&&e.code.includes("request-failed")}function Qp({projectId:e}){return`${Kp}/projects/${e}/installations`}function Yp(e){return{token:e.token,requestStatus:2,expiresIn:(e=e.expiresIn,Number(e.replace("s","000"))),creationTime:Date.now()}}async function Jp(e,t){var n=(await t.json()).error;return Hp.create("request-failed",{requestName:e,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})}function Xp({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function Zp(e,{refreshToken:t}){const n=Xp(e);return n.append("Authorization",(t=t,`${$p} ${t}`)),n}async function ef(e){var t=await e();return 500<=t.status&&t.status<600?e():t}function tf(t){return new Promise(e=>{setTimeout(e,t)})}const nf=/^[cdef][\w-]{21}$/,rf="";function sf(){try{const t=new Uint8Array(17),n=self.crypto||self.msCrypto;n.getRandomValues(t),t[0]=112+t[0]%16;var e=function(e){const t=function(e){const t=btoa(String.fromCharCode(...e));return t.replace(/\+/g,"-").replace(/\//g,"_")}(e);return t.substr(0,22)}(t);return nf.test(e)?e:rf}catch(e){return rf}}function of(e){return`${e.appName}!${e.appId}`}const af=new Map;function cf(e,t){var n=of(e);lf(n,t),function(e,t){const n=function(){!uf&&"BroadcastChannel"in self&&(uf=new BroadcastChannel("[Firebase] FID Change"),uf.onmessage=e=>{lf(e.data.key,e.data.fid)});return uf}();n&&n.postMessage({key:e,fid:t});0===af.size&&uf&&(uf.close(),uf=null)}(n,t)}function lf(e,t){var n=af.get(e);if(n)for(const r of n)r(t)}let uf=null;const hf="firebase-installations-store";let df=null;function pf(){return df=df||qp("firebase-installations-database",1,e=>{0===e.oldVersion&&e.createObjectStore(hf)}),df}async function ff(e,t){var n=of(e);const r=await pf(),i=r.transaction(hf,"readwrite"),s=i.objectStore(hf);var o=await s.get(n);return await s.put(t,n),await i.complete,o&&o.fid===t.fid||cf(e,t.fid),t}async function gf(e){var t=of(e);const n=await pf(),r=n.transaction(hf,"readwrite");await r.objectStore(hf).delete(t),await r.complete}async function mf(e,t){var n=of(e);const r=await pf(),i=r.transaction(hf,"readwrite"),s=i.objectStore(hf);var o=await s.get(n),a=t(o);return void 0===a?await s.delete(n):await s.put(a,n),await i.complete,!a||o&&o.fid===a.fid||cf(e,a.fid),a}async function vf(n){let r;var e=await mf(n,e=>{var t=_f(e||{fid:sf(),registrationStatus:0}),t=function(e,t){{if(0!==t.registrationStatus)return 1===t.registrationStatus?{installationEntry:t,registrationPromise:async function(e){let t=await yf(e);for(;1===t.registrationStatus;)await tf(100),t=await yf(e);if(0!==t.registrationStatus)return t;{var{installationEntry:n,registrationPromise:r}=await vf(e);return r||n}}(e)}:{installationEntry:t};if(!navigator.onLine){var n=Promise.reject(Hp.create("app-offline"));return{installationEntry:t,registrationPromise:n}}var r={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},n=async function(t,n){try{var e=await async function(e,{fid:t}){const n=Qp(e);var r=Xp(e),i={fid:t,authVersion:$p,appId:e.appId,sdkVersion:Wp};const s={method:"POST",headers:r,body:JSON.stringify(i)},o=await ef(()=>fetch(n,s));if(o.ok){i=await o.json();return{fid:i.fid||t,registrationStatus:2,refreshToken:i.refreshToken,authToken:Yp(i.authToken)}}throw await Jp("Create Installation",o)}(t,n);return ff(t,e)}catch(e){throw Gp(e)&&409===e.customData.serverCode?await gf(t):await ff(t,{fid:n.fid,registrationStatus:0}),e}}(e,r);return{installationEntry:r,registrationPromise:n}}}(n,t);return r=t.registrationPromise,t.installationEntry});return e.fid===rf?{installationEntry:await r}:{installationEntry:e,registrationPromise:r}}function yf(e){return mf(e,e=>{if(!e)throw Hp.create("installation-not-found");return _f(e)})}function _f(e){return 1===(t=e).registrationStatus&&t.registrationTime+Bp<Date.now()?{fid:e.fid,registrationStatus:0}:e;var t}async function wf({appConfig:e,platformLoggerProvider:t},n){const r=([i,s]=[e,n["fid"]],`${Qp(i)}/${s}/authTokens:generate`);var i,s;const o=Zp(e,n),a=t.getImmediate({optional:!0});a&&o.append("x-firebase-client",a.getPlatformInfoString());var c={installation:{sdkVersion:Wp}};const l={method:"POST",headers:o,body:JSON.stringify(c)},u=await ef(()=>fetch(r,l));if(u.ok)return Yp(await u.json());throw await Jp("Generate Auth Token",u)}async function bf(r,i=!1){let s;var e=await mf(r.appConfig,e=>{if(!Tf(e))throw Hp.create("not-registered");var t,n=e.authToken;if(i||2!==(t=n).requestStatus||function(e){var t=Date.now();return t<e.creationTime||e.creationTime+e.expiresIn<t+zp}(t)){if(1===n.requestStatus)return s=async function(e,t){let n=await If(e.appConfig);for(;1===n.authToken.requestStatus;)await tf(100),n=await If(e.appConfig);var r=n.authToken;return 0===r.requestStatus?bf(e,t):r}(r,i),e;if(!navigator.onLine)throw Hp.create("app-offline");n=(t=e,n={requestStatus:1,requestTime:Date.now()},Object.assign(Object.assign({},t),{authToken:n}));return s=async function(t,n){try{var r=await wf(t,n),e=Object.assign(Object.assign({},n),{authToken:r});return await ff(t.appConfig,e),r}catch(e){throw!Gp(e)||401!==e.customData.serverCode&&404!==e.customData.serverCode?(r=Object.assign(Object.assign({},n),{authToken:{requestStatus:0}}),await ff(t.appConfig,r)):await gf(t.appConfig),e}}(r,n),n}return e});return s?await s:e.authToken}function If(e){return mf(e,e=>{if(!Tf(e))throw Hp.create("not-registered");var t,n=e.authToken;return 1===(t=n).requestStatus&&t.requestTime+Bp<Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e})}function Tf(e){return void 0!==e&&2===e.registrationStatus}async function Ef(e,t=!1){var n,r=e;return e=r.appConfig,await((n=(await vf(e)).registrationPromise)&&await n),(await bf(r,t)).token}function kf(e){return Hp.create("missing-app-config-values",{valueName:e})}const Sf="installations",Cf=e=>{var t=e.getProvider("app").getImmediate();return{app:t,appConfig:function(e){if(!e||!e.options)throw kf("App Configuration");if(!e.name)throw kf("App Name");for(const t of["projectId","apiKey","appId"])if(!e.options[t])throw kf(t);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t),platformLoggerProvider:dp(t,"platform-logger"),_delete:()=>Promise.resolve()}},Af=e=>{const t=dp(e.getProvider("app").getImmediate(),Sf).getImmediate();return{getId:()=>async function(e){var t=e;const{installationEntry:n,registrationPromise:r}=await vf(t.appConfig);return(r||bf(t)).catch(console.error),n.fid}(t),getToken:e=>Ef(t,e)}};hp(new Kd(Sf,Cf,"PUBLIC")),hp(new Kd("installations-internal",Af,"PRIVATE")),_p(ze,c),_p(ze,c,"esm2017");const Nf="analytics",Rf="firebase_id",Pf="origin",xf="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",Df="https://www.googletagmanager.com/gtag/js",Of=new ep("@firebase/analytics");function Mf(e){return Promise.all(e.map(e=>e.catch(e=>e)))}function Lf(r,i,s,o){return async function(e,t,n){try{"event"===e?await async function(e,n,r,i,s){try{let t=[];if(s&&s.send_to){let e=s.send_to;Array.isArray(e)||(e=[e]);const c=await Mf(r);for(const l of e){var o=c.find(e=>e.measurementId===l),a=o&&n[o.appId];if(!a){t=[];break}t.push(a)}}0===t.length&&(t=Object.values(n)),await Promise.all(t),e("event",i,s||{})}catch(e){Of.error(e)}}(r,i,s,t,n):"config"===e?await async function(e,t,n,r,i,s){var o=r[i];try{if(o)await t[o];else{const c=await Mf(n);var a=c.find(e=>e.measurementId===i);a&&await t[a.appId]}}catch(e){Of.error(e)}e("config",i,s)}(r,i,s,o,t,n):r("set",t)}catch(e){Of.error(e)}}}const Ff=new md("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-intialized 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.'}),Uf=30;const jf=new class{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]}};async function qf(e){var t,{appId:n,apiKey:r}=e,r={method:"GET",headers:new Headers({Accept:"application/json","x-goog-api-key":r})},n=xf.replace("{app-id}",n);const i=await fetch(n,r);if(200===i.status||304===i.status)return i.json();{let e="";try{var s=await i.json();null!==(t=s.error)&&void 0!==t&&t.message&&(e=s.error.message)}catch(e){}throw Ff.create("config-fetch-failed",{httpStatus:i.status,responseMessage:e})}}async function Vf(e,t=jf,n){var{appId:r,apiKey:i,measurementId:s}=e.options;if(!r)throw Ff.create("no-app-id");if(!i){if(s)return{measurementId:s,appId:r};throw Ff.create("no-api-key")}var o=t.getThrottleMetadata(r)||{backoffCount:0,throttleEndTimeMillis:Date.now()};const a=new $f;return setTimeout(async()=>{a.abort()},void 0!==n?n:6e4),async function t(n,{throttleEndTimeMillis:e,backoffCount:r},i,s=jf){const{appId:o,measurementId:a}=n;try{await Bf(i,e)}catch(e){if(a)return Of.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. [${e.message}]`),{appId:o,measurementId:a};throw e}try{const c=await qf(n);return s.deleteThrottleMetadata(o),c}catch(e){if(!Wf(e)){if(s.deleteThrottleMetadata(o),a)return Of.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. [${e.message}]`),{appId:o,measurementId:a};throw e}const l=503===Number(e.customData.httpStatus)?Wd(r,s.intervalMillis,Uf):Wd(r,s.intervalMillis),u={throttleEndTimeMillis:Date.now()+l,backoffCount:r+1};return s.setThrottleMetadata(o,u),Of.debug(`Calling attemptFetch again in ${l} millis`),t(n,u,i,s)}}({appId:r,apiKey:i,measurementId:s},o,a,t)}function Bf(i,s){return new Promise((e,t)=>{var n=Math.max(s-Date.now(),0);const r=setTimeout(e,n);i.addEventListener(()=>{clearTimeout(r),t(Ff.create("fetch-throttle",{throttleEndTimeMillis:s}))})})}function Wf(e){if(!(e instanceof gd&&e.customData))return!1;var t=Number(e.customData.httpStatus);return 429===t||500===t||503===t||504===t}class $f{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}async function Kf(t,e,n,r,i,s,o){const a=Vf(t);a.then(e=>{n[e.measurementId]=e.appId,t.options.measurementId&&e.measurementId!==t.options.measurementId&&Of.warn(`The measurement ID in the local Firebase config (${t.options.measurementId})`+` does not match the measurement ID fetched from the server (${e.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=>Of.error(e)),e.push(a);var c=async function(){if(!dd())return Of.warn(Ff.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;try{await pd()}catch(e){return Of.warn(Ff.create("indexeddb-unavailable",{errorInfo:e}).message),!1}return!0}().then(e=>{if(e)return r.getId()}),[l,u]=await Promise.all([a,c]);!function(){var e=window.document.getElementsByTagName("script");for(const t of Object.values(e))if(t.src&&t.src.includes(Df))return t}()&&function(e,t){const n=document.createElement("script");n.src=`${Df}?l=${e}&id=${t}`,n.async=!0,document.head.appendChild(n)}(s,l.measurementId),i("js",new Date);const h=null!==(c=null==o?void 0:o.config)&&void 0!==c?c:{};return h[Pf]="firebase",h.update=!0,null!=u&&(h[Rf]=u),i("config",l.measurementId,h),l.measurementId}class zf{constructor(e){this.app=e}_delete(){return delete Hf[this.app.options.appId],Promise.resolve()}}let Hf={},Gf=[];const Qf={};let Yf="dataLayer",Jf="gtag",Xf,Zf,eg=!1;function tg(e){if(eg)throw Ff.create("already-initialized");e.dataLayerName&&(Yf=e.dataLayerName),e.gtagName&&(Jf=e.gtagName)}function ng(e,t,n){!function(){const e=[];var t;cd()&&e.push("This is a browser extension environment."),fd()||e.push("Cookies are not available."),0<e.length&&(t=e.map((e,t)=>`(${t+1}) ${e}`).join(" "),t=Ff.create("invalid-analytics-context",{errorInfo:t}),Of.warn(t.message))}();var r,i,s=e.options.appId;if(!s)throw Ff.create("no-app-id");if(!e.options.apiKey){if(!e.options.measurementId)throw Ff.create("no-api-key");Of.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.')}if(null!=Hf[s])throw Ff.create("already-exists",{id:s});return eg||(function(e){let t=[];Array.isArray(window[e])?t=window[e]:window[e]=t,t}(Yf),{wrappedGtag:r,gtagCore:i}=function(e,t,n,r,i){let s=function(){window[r].push(arguments)};return window[i]&&"function"==typeof window[i]&&(s=window[i]),window[i]=Lf(s,e,t,n),{gtagCore:s,wrappedGtag:window[i]}}(Hf,Gf,Qf,Yf,Jf),Zf=r,Xf=i,eg=!0),Hf[s]=Kf(e,Gf,Qf,t,Xf,Yf,n),new zf(e)}async function rg(){if(cd())return!1;if(!fd())return!1;if(!dd())return!1;try{return await pd()}catch(e){return!1}}function ig(e,t,n){e=$d(e),async function(e,t,n,r){if(r&&r.global)return e("set",{screen_name:n}),Promise.resolve();e("config",await t,{update:!0,screen_name:n})}(Zf,Hf[e.app.options.appId],t,n).catch(e=>Of.error(e))}function sg(e,t,n){e=$d(e),async function(e,t,n,r){if(r&&r.global)return e("set",{user_id:n}),Promise.resolve();e("config",await t,{update:!0,user_id:n})}(Zf,Hf[e.app.options.appId],t,n).catch(e=>Of.error(e))}function og(e,t,n){e=$d(e),async function(e,t,n,r){if(r&&r.global){const i={};for(const s of Object.keys(n))i[`user_properties.${s}`]=n[s];return e("set",i),Promise.resolve()}e("config",await t,{update:!0,user_properties:n})}(Zf,Hf[e.app.options.appId],t,n).catch(e=>Of.error(e))}function ag(e,t){e=$d(e),async function(e,t){var n=await e;window[`ga-disable-${n}`]=!t}(Hf[e.app.options.appId],t).catch(e=>Of.error(e))}function cg(e,t,n,r){e=$d(e),async function(e,t,n,r,i){var s;i&&i.global?e("event",n,r):(s=await t,e("event",n,Object.assign(Object.assign({},r),{send_to:s})))}(Zf,Hf[e.app.options.appId],t,n,r).catch(e=>Of.error(e))}const lg="@firebase/analytics";hp(new Kd(Nf,(e,{options:t})=>{return ng(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),t)},"PUBLIC")),hp(new Kd("analytics-internal",function(e){try{const r=e.getProvider(Nf).getImmediate();return{logEvent:(e,t,n)=>cg(r,e,t,n)}}catch(e){throw Ff.create("interop-component-reg-failed",{reason:e})}},"PRIVATE")),_p(lg,"0.7.5"),_p(lg,"0.7.5","esm2017");var ug,hg;class dg{constructor(e,t){this.app=e,this._delegate=t}logEvent(e,t,n){cg(this._delegate,e,t,n)}setCurrentScreen(e,t){ig(this._delegate,e,t)}setUserId(e,t){sg(this._delegate,e,t)}setUserProperties(e,t){og(this._delegate,e,t)}setAnalyticsCollectionEnabled(e){ag(this._delegate,e)}}(z=ug=ug||{}).ADD_SHIPPING_INFO="add_shipping_info",z.ADD_PAYMENT_INFO="add_payment_info",z.ADD_TO_CART="add_to_cart",z.ADD_TO_WISHLIST="add_to_wishlist",z.BEGIN_CHECKOUT="begin_checkout",z.CHECKOUT_PROGRESS="checkout_progress",z.EXCEPTION="exception",z.GENERATE_LEAD="generate_lead",z.LOGIN="login",z.PAGE_VIEW="page_view",z.PURCHASE="purchase",z.REFUND="refund",z.REMOVE_FROM_CART="remove_from_cart",z.SCREEN_VIEW="screen_view",z.SEARCH="search",z.SELECT_CONTENT="select_content",z.SELECT_ITEM="select_item",z.SELECT_PROMOTION="select_promotion",z.SET_CHECKOUT_OPTION="set_checkout_option",z.SHARE="share",z.SIGN_UP="sign_up",z.TIMING_COMPLETE="timing_complete",z.VIEW_CART="view_cart",z.VIEW_ITEM="view_item",z.VIEW_ITEM_LIST="view_item_list",z.VIEW_PROMOTION="view_promotion",z.VIEW_SEARCH_RESULTS="view_search_results";const pg=e=>{var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("analytics").getImmediate();return new dg(t,n)};hg={Analytics:dg,settings:tg,isSupported:rg,EventName:ug},Cp.INTERNAL.registerComponent(new Kd("analytics-compat",pg,"PUBLIC").setServiceProps(hg).setMultipleInstances(!0)),Cp.registerVersion("@firebase/analytics-compat","0.1.6");const fg=new Map,gg={activated:!1,tokenObservers:[]},mg={initialized:!1,enabled:!1};function vg(e){return fg.get(e)||gg}function yg(e,t){fg.set(e,t)}const _g="https://content-firebaseappcheck.googleapis.com/v1beta",wg="exchangeDebugToken",bg={OFFSET_DURATION:3e5,RETRIAL_MIN_WAIT:3e4,RETRIAL_MAX_WAIT:96e4};class Ig{constructor(e,t,n,r,i){if(this.operation=e,this.retryPolicy=t,this.getWaitDuration=n,this.lowerBound=r,this.upperBound=i,this.pending=null,i<(this.nextErrorWaitInterval=r))throw new Error("Proactive refresh lower bound greater than upper bound!")}start(){this.nextErrorWaitInterval=this.lowerBound,this.process(!0).catch(()=>{})}stop(){this.pending&&(this.pending.reject("cancelled"),this.pending=null)}isRunning(){return!!this.pending}async process(e){this.stop();try{this.pending=new rd,t=this.getNextRun(e),await new Promise(e=>{setTimeout(e,t)}),this.pending.resolve(),await this.pending.promise,this.pending=new rd,await this.operation(),this.pending.resolve(),await this.pending.promise,this.process(!0).catch(()=>{})}catch(e){this.retryPolicy(e)?this.process(!1).catch(()=>{}):this.stop()}var t}getNextRun(e){if(e)return this.nextErrorWaitInterval=this.lowerBound,this.getWaitDuration();var t=this.nextErrorWaitInterval;return this.nextErrorWaitInterval*=2,this.nextErrorWaitInterval>this.upperBound&&(this.nextErrorWaitInterval=this.upperBound),t}}const Tg=new md("appCheck","AppCheck",{"already-initialized":"You have already called initializeAppCheck() for FirebaseApp {$appName} with different options. To avoid this error, call initializeAppCheck() with the same options as when it was originally called. This will return the already initialized instance.","use-before-activation":"App Check is being used before initializeAppCheck() is called for FirebaseApp {$appName}. Call initializeAppCheck() before instantiating other Firebase services.","fetch-network-error":"Fetch failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-parse-error":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status-error":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","recaptcha-error":"ReCAPTCHA error.",throttled:"Requests throttled due to {$httpStatus} error. Attempts allowed again after {$time}"});function Eg(e=!1){var t;return e?null===(t=self.grecaptcha)||void 0===t?void 0:t.enterprise:self.grecaptcha}function kg(e){if(!vg(e).activated)throw Tg.create("use-before-activation",{appName:e.name})}function Sg(e){var t=Math.round(e/1e3),n=Math.floor(t/86400),r=Math.floor((t-3600*n*24)/3600),i=Math.floor((t-3600*n*24-3600*r)/60),t=t-3600*n*24-3600*r-60*i;let s="";return n&&(s+=Cg(n)+"d:"),r&&(s+=Cg(r)+"h:"),s+=Cg(i)+"m:"+Cg(t)+"s",s}function Cg(e){return 0===e?"00":10<=e?e.toString():"0"+e}async function Ag({url:e,body:t},n){const r={"Content-Type":"application/json"},i=n.getImmediate({optional:!0});i&&(r["X-Firebase-Client"]=i.getPlatformInfoString());var s={method:"POST",body:JSON.stringify(t),headers:r};let o;try{o=await fetch(e,s)}catch(e){throw Tg.create("fetch-network-error",{originalErrorMessage:e.message})}if(200!==o.status)throw Tg.create("fetch-status-error",{httpStatus:o.status});let a;try{a=await o.json()}catch(e){throw Tg.create("fetch-parse-error",{originalErrorMessage:e.message})}var c=a.ttl.match(/^([\d.]+)(s)$/);if(!c||!c[2]||isNaN(Number(c[1])))throw Tg.create("fetch-parse-error",{originalErrorMessage:"ttl field (timeToLive) is not in standard Protobuf Duration "+`format: ${a.ttl}`});s=1e3*Number(c[1]),c=Date.now();return{token:a.attestationToken,expireTimeMillis:c+s,issuedAtTimeMillis:c}}const Ng="firebase-app-check-database",Rg=1,Pg="firebase-app-check-store",xg="debug-token";let Dg=null;function Og(){return Dg||(Dg=new Promise((t,n)=>{try{const e=indexedDB.open(Ng,Rg);e.onsuccess=e=>{t(e.target.result)},e.onerror=e=>{var t;n(Tg.create("storage-open",{originalErrorMessage:null===(t=e.target.error)||void 0===t?void 0:t.message}))},e.onupgradeneeded=e=>{const t=e.target.result;0===e.oldVersion&&t.createObjectStore(Pg,{keyPath:"compositeKey"})}}catch(e){n(Tg.create("storage-open",{originalErrorMessage:e.message}))}}),Dg)}async function Mg(e,t){const n=await Og(),r=n.transaction(Pg,"readwrite"),i=r.objectStore(Pg),s=i.put({compositeKey:e,value:t});return new Promise((t,n)=>{s.onsuccess=e=>{t()},r.onerror=e=>{var t;n(Tg.create("storage-set",{originalErrorMessage:null===(t=e.target.error)||void 0===t?void 0:t.message}))}})}async function Lg(e){const t=await Og(),i=t.transaction(Pg,"readonly"),n=i.objectStore(Pg),s=n.get(e);return new Promise((n,r)=>{s.onsuccess=e=>{var t=e.target.result;n(t?t.value:void 0)},i.onerror=e=>{var t;r(Tg.create("storage-get",{originalErrorMessage:null===(t=e.target.error)||void 0===t?void 0:t.message}))}})}function Fg(e){return`${e.options.appId}-${e.name}`}const Ug=new ep("@firebase/app-check");async function jg(t){if(dd()){let e=void 0;try{e=await Lg(Fg(t))}catch(e){Ug.warn(`Failed to read token from IndexedDB. Error: ${e}`)}return e}}function qg(e,t){return dd()?Mg(Fg(e),t).catch(e=>{Ug.warn(`Failed to write token to IndexedDB. Error: ${e}`)}):Promise.resolve()}async function Vg(){let e=void 0;try{e=await Lg(xg)}catch(e){}if(e)return e;var t,n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0,n="x"===e?t:3&t|8;return n.toString(16)});return t=n,Mg(xg,t).catch(e=>Ug.warn(`Failed to persist debug token to IndexedDB. Error: ${e}`)),n}function Bg(){return mg.enabled}async function Wg(){var e=mg;if(e.enabled&&e.token)return e.token.promise;throw Error(`
|
|
8
8
|
Can't get debug token in production mode.
|
|
9
|
-
`)}function Kg(){var e=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("Unable to locate global object.")}();const t=mg;if(t.initialized=!0,"string"==typeof e.FIREBASE_APPCHECK_DEBUG_TOKEN||!0===e.FIREBASE_APPCHECK_DEBUG_TOKEN){t.enabled=!0;const n=new rd;t.token=n,"string"==typeof e.FIREBASE_APPCHECK_DEBUG_TOKEN?n.resolve(e.FIREBASE_APPCHECK_DEBUG_TOKEN):n.resolve(Vg())}}const $g={error:"UNKNOWN_ERROR"};async function zg(e,t=!1){var n=e.app;kg(n);const r=vg(n);let i=r.token,s=void 0;if(i||(a=await r.cachedTokenPromise)&&Jg(a)&&(i=a),!t&&i&&Jg(i))return{token:i.token};let o=!1;if(Bg()){r.exchangeTokenPromise||(r.exchangeTokenPromise=Ag(function(e,t){var{projectId:n,appId:r,apiKey:i}=e.options;return{url:`${_g}/projects/${n}/apps/${r}:${wg}?key=${i}`,body:{debug_token:t}}}(n,await Wg()),e.platformLoggerProvider).then(e=>(r.exchangeTokenPromise=void 0,e)),o=!0);var a=await r.exchangeTokenPromise;return await qg(n,a),yg(n,Object.assign(Object.assign({},r),{token:a})),{token:a.token}}try{r.exchangeTokenPromise||(r.exchangeTokenPromise=r.provider.getToken().then(e=>(r.exchangeTokenPromise=void 0,e)),o=!0),i=await r.exchangeTokenPromise}catch(e){"appCheck/throttled"===e.code?Ug.warn(e.message):Ug.error(e),s=e}let c;return i?(c={token:i.token},yg(n,Object.assign(Object.assign({},r),{token:i})),await qg(n,i)):c=(e=s,{token:function(e){return Zh.encodeString(JSON.stringify(e),!1)}($g),error:e}),o&&Yg(n,c),c}function Hg(e,t,n,r){var i=e["app"];const s=vg(i);var o={next:n,error:r,type:t};if(yg(i,Object.assign(Object.assign({},s),{tokenObservers:[...s.tokenObservers,o]})),s.token&&Jg(s.token)){const a=s.token;Promise.resolve().then(()=>{n({token:a.token}),Qg(e)}).catch(()=>{})}s.cachedTokenPromise.then(()=>Qg(e))}function Gg(e,t){const n=vg(e);var r=n.tokenObservers.filter(e=>e.next!==t);0===r.length&&n.tokenRefresher&&n.tokenRefresher.isRunning()&&n.tokenRefresher.stop(),yg(e,Object.assign(Object.assign({},n),{tokenObservers:r}))}function Qg(e){var t=e["app"],n=vg(t);let r=n.tokenRefresher;r||(r=function(n){const r=n["app"];return new Tg(async()=>{var e=vg(r);let t;if(t=e.token?await zg(n,!0):await zg(n),t.error)throw t.error},()=>!0,()=>{var e=vg(r);if(e.token){var t=e.token.issuedAtTimeMillis+.5*(e.token.expireTimeMillis-e.token.issuedAtTimeMillis)+3e5,e=e.token.expireTimeMillis-3e5,t=Math.min(t,e);return Math.max(0,t-Date.now())}return 0},bg.RETRIAL_MIN_WAIT,bg.RETRIAL_MAX_WAIT)}(e),yg(t,Object.assign(Object.assign({},n),{tokenRefresher:r}))),!r.isRunning()&&n.isTokenAutoRefreshEnabled&&r.start()}function Yg(e,t){for(const n of vg(e).tokenObservers)try{"EXTERNAL"===n.type&&null!=t.error?n.error(t.error):n.next(t)}catch(e){}}function Jg(e){return 0<e.expireTimeMillis-Date.now()}class Xg{constructor(e,t){this.app=e,this.platformLoggerProvider=t}_delete(){var e=vg(this.app)["tokenObservers"];for(const t of e)Gg(this.app,t.next);return Promise.resolve()}}const Zg="https://www.google.com/recaptcha/api.js",em="https://www.google.com/recaptcha/enterprise.js";function tm(t,n){var e=vg(t);const r=new rd;yg(t,Object.assign(Object.assign({},e),{reCAPTCHAState:{initialized:r}}));const i=im(t);e=Eg(!1);return e?rm(t,n,e,i,r):function(e){const t=document.createElement("script");t.src=Zg,t.onload=e,document.head.appendChild(t)}(()=>{var e=Eg(!1);if(!e)throw new Error("no recaptcha");rm(t,n,e,i,r)}),r.promise}function nm(t,n){var e=vg(t);const r=new rd;yg(t,Object.assign(Object.assign({},e),{reCAPTCHAState:{initialized:r}}));const i=im(t);e=Eg(!0);return e?rm(t,n,e,i,r):function(e){const t=document.createElement("script");t.src=em,t.onload=e,document.head.appendChild(t)}(()=>{var e=Eg(!0);if(!e)throw new Error("no recaptcha");rm(t,n,e,i,r)}),r.promise}function rm(r,i,s,o,a){s.ready(()=>{var e,t,n;e=r,t=s.render(o,{sitekey:i,size:"invisible"}),n=vg(e),yg(e,Object.assign(Object.assign({},n),{reCAPTCHAState:Object.assign(Object.assign({},n.reCAPTCHAState),{widgetId:t})})),a.resolve(s)})}function im(e){var t=`fire_app_check_${e.name}`;const n=document.createElement("div");return n.id=t,n.style.display="none",document.body.appendChild(n),t}async function sm(r){kg(r);const i=await vg(r).reCAPTCHAState.initialized.promise;return new Promise((e,t)=>{const n=vg(r).reCAPTCHAState;i.ready(()=>{e(i.execute(n.widgetId,{action:"fire_app_check"}))})})}class om{constructor(e){this._siteKey=e,this._throttleData=null}async getToken(){um(this._throttleData);var t=await sm(this._app).catch(e=>{throw Ig.create("recaptcha-error")});let e;try{e=await Ag(function(e,t){var{projectId:n,appId:r,apiKey:i}=e.options;return{url:`${_g}/projects/${n}/apps/${r}:exchangeRecaptchaToken?key=${i}`,body:{recaptcha_token:t}}}(this._app,t),this._platformLoggerProvider)}catch(e){throw"fetch-status-error"===e.code?(this._throttleData=lm(Number(null===(t=e.customData)||void 0===t?void 0:t.httpStatus),this._throttleData),Ig.create("throttled",{time:Sg(this._throttleData.allowRequestsAfter-Date.now()),httpStatus:this._throttleData.httpStatus})):e}return this._throttleData=null,e}initialize(e){this._app=e,this._platformLoggerProvider=dp(e,"platform-logger"),tm(e,this._siteKey).catch(()=>{})}isEqual(e){return e instanceof om&&this._siteKey===e._siteKey}}class am{constructor(e){this._siteKey=e,this._throttleData=null}async getToken(){um(this._throttleData);var t=await sm(this._app).catch(e=>{throw Ig.create("recaptcha-error")});let e;try{e=await Ag(function(e,t){var{projectId:n,appId:r,apiKey:i}=e.options;return{url:`${_g}/projects/${n}/apps/${r}:exchangeRecaptchaEnterpriseToken?key=${i}`,body:{recaptcha_enterprise_token:t}}}(this._app,t),this._platformLoggerProvider)}catch(e){throw"fetch-status-error"===e.code?(this._throttleData=lm(Number(null===(t=e.customData)||void 0===t?void 0:t.httpStatus),this._throttleData),Ig.create("throttled",{time:Sg(this._throttleData.allowRequestsAfter-Date.now()),httpStatus:this._throttleData.httpStatus})):e}return this._throttleData=null,e}initialize(e){this._app=e,this._platformLoggerProvider=dp(e,"platform-logger"),nm(e,this._siteKey).catch(()=>{})}isEqual(e){return e instanceof am&&this._siteKey===e._siteKey}}class cm{constructor(e){this._customProviderOptions=e}async getToken(){var e=await this._customProviderOptions.getToken(),t=function(e){const t=wd(e).claims;return"object"==typeof t&&t.hasOwnProperty("iat")?t.iat:null}(e.token),t=null!==t&&t<Date.now()&&0<t?1e3*t:Date.now();return Object.assign(Object.assign({},e),{issuedAtTimeMillis:t})}initialize(e){this._app=e}isEqual(e){return e instanceof cm&&this._customProviderOptions.getToken.toString()===e._customProviderOptions.getToken.toString()}}function lm(e,t){if(404===e||403===e)return{backoffCount:1,allowRequestsAfter:Date.now()+864e5,httpStatus:e};var n=t?t.backoffCount:0,r=Wd(n,1e3,2);return{backoffCount:n+1,allowRequestsAfter:Date.now()+r,httpStatus:e}}function um(e){if(e&&Date.now()-e.allowRequestsAfter<=0)throw Ig.create("throttled",{time:Sg(e.allowRequestsAfter-Date.now()),httpStatus:e.httpStatus})}function hm(e=vp(),t){const n=dp(e=Kd(e),"app-check");if(mg.initialized||Kg(),Bg()&&Wg().then(e=>console.log(`App Check debug token: ${e}. You will need to add it to your app's App Check settings in the Firebase console for it to work.`)),n.isInitialized()){var r=n.getImmediate();const i=n.getOptions();if(i.isTokenAutoRefreshEnabled===t.isTokenAutoRefreshEnabled&&i.provider.isEqual(t.provider))return r;throw Ig.create("already-initialized",{appName:e.name})}r=n.initialize({options:t});return function(t,e,n){const r=vg(t),i=Object.assign(Object.assign({},r),{activated:!0});i.provider=e,i.cachedTokenPromise=jg(t).then(e=>(e&&Jg(e)&&(yg(t,Object.assign(Object.assign({},vg(t)),{token:e})),Yg(t,{token:e.token})),e)),i.isTokenAutoRefreshEnabled=void 0===n?t.automaticDataCollectionEnabled:n,yg(t,i),i.provider.initialize(t)}(e,t.provider,t.isTokenAutoRefreshEnabled),vg(e).isTokenAutoRefreshEnabled&&Hg(r,"INTERNAL",()=>{}),r}const dm="app-check-internal";hp(new $d("app-check",e=>{var t,n=e.getProvider("app").getImmediate(),r=e.getProvider("platform-logger");return t=n,e=r,new Xg(t,e)},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{e.getProvider(dm).initialize()})),hp(new $d(dm,e=>{var t,n=e.getProvider("app-check").getImmediate();return t=n,{getToken:e=>zg(t,e),addTokenListener:e=>Hg(t,"INTERNAL",e),removeTokenListener:e=>Gg(t.app,e)}},"PUBLIC").setInstantiationMode("EXPLICIT")),_p("@firebase/app-check","0.5.3");const pm=new md("appCheck","AppCheck",{"use-before-activation":"App Check is being used before activate() is called for FirebaseApp {$appName}. Call activate() before instantiating other Firebase services."});class fm{constructor(e){this.app=e}activate(e,t){let n;n="string"==typeof e?new om(e):e instanceof am||e instanceof om||e instanceof cm?e:new cm({getToken:e.getToken}),this._delegate=hm(this.app,{provider:n,isTokenAutoRefreshEnabled:t})}setTokenAutoRefreshEnabled(e){if(!this._delegate)throw pm.create("use-before-activation",{appName:this.app.name});!function(e,t){var n=e.app;const r=vg(n);r.tokenRefresher&&(!0===t?r.tokenRefresher.start():r.tokenRefresher.stop()),yg(n,Object.assign(Object.assign({},r),{isTokenAutoRefreshEnabled:t}))}(this._delegate,e)}getToken(e){if(!this._delegate)throw pm.create("use-before-activation",{appName:this.app.name});return async function(e,t){var n=await zg(e,t);if(n.error)throw n.error;return{token:n.token}}(this._delegate,e)}onTokenChanged(e,t,n){if(!this._delegate)throw pm.create("use-before-activation",{appName:this.app.name});return function(e,t,n){let r=()=>{},i=()=>{};return r=null!=t.next?t.next.bind(t):t,null!=t.error?i=t.error.bind(t):n&&(i=n),Hg(e,"EXTERNAL",r,i),()=>Gg(e.app,r)}(this._delegate,e,t)}}const gm=e=>{var t=e.getProvider("app-compat").getImmediate();return new fm(t)};function mm(e,t){var n={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n}Cp.INTERNAL.registerComponent(new $d("appCheck-compat",gm,"PUBLIC").setServiceProps({ReCaptchaEnterpriseProvider:am,ReCaptchaV3Provider:om,CustomProvider:cm})),Cp.registerVersion("@firebase/app-check-compat","0.2.3");const vm={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"},ym={EMAIL_SIGNIN:"EMAIL_SIGNIN",PASSWORD_RESET:"PASSWORD_RESET",RECOVER_EMAIL:"RECOVER_EMAIL",REVERT_SECOND_FACTOR_ADDITION:"REVERT_SECOND_FACTOR_ADDITION",VERIFY_AND_CHANGE_EMAIL:"VERIFY_AND_CHANGE_EMAIL",VERIFY_EMAIL:"VERIFY_EMAIL"};function _m(){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."}}function wm(){return{"admin-restricted-operation":"This operation is restricted to administrators only.","argument-error":"","app-not-authorized":"This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.","app-not-installed":"The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.","captcha-check-failed":"The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.","code-expired":"The SMS code has expired. Please re-send the verification code to try again.","cordova-not-ready":"Cordova framework is not ready.","cors-unsupported":"This browser is not supported.","credential-already-in-use":"This credential is already associated with a different user account.","custom-token-mismatch":"The custom token corresponds to a different audience.","requires-recent-login":"This operation is sensitive and requires recent authentication. Log in again before retrying this request.","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.","dynamic-link-not-activated":"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.","email-change-needs-verification":"Multi-factor users must always have a verified email.","email-already-in-use":"The email address is already in use by another account.","emulator-config-failed":'Auth instance has already been used to make a network call. Auth can no longer be configured to use the emulator. Try calling "connectAuthEmulator()" sooner.',"expired-action-code":"The action code has expired.","cancelled-popup-request":"This operation has been cancelled due to another conflicting popup being opened.","internal-error":"An internal AuthError has occurred.","invalid-app-credential":"The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.","invalid-app-id":"The mobile app identifier is not registed for the current project.","invalid-user-token":"This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.","invalid-auth-event":"An internal AuthError has occurred.","invalid-verification-code":"The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure to use the verification code provided by the user.","invalid-continue-uri":"The continue URL provided in the request is invalid.","invalid-cordova-configuration":"The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.","invalid-custom-token":"The custom token format is incorrect. Please check the documentation.","invalid-dynamic-link-domain":"The provided dynamic link domain is not configured or authorized for the current project.","invalid-email":"The email address is badly formatted.","invalid-emulator-scheme":"Emulator URL must start with a valid scheme (http:// or https://).","invalid-api-key":"Your API key is invalid, please check you have copied it correctly.","invalid-cert-hash":"The SHA-1 certificate hash provided is invalid.","invalid-credential":"The supplied auth credential is malformed or has expired.","invalid-message-payload":"The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-multi-factor-session":"The request does not contain a valid proof of first factor successful sign-in.","invalid-oauth-provider":"EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.","invalid-oauth-client-id":"The OAuth client ID provided is either invalid or does not match the specified API key.","unauthorized-domain":"This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.","invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","wrong-password":"The password is invalid or the user does not have a password.","invalid-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","invalid-phone-number":"The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].","invalid-provider-id":"The specified provider ID is invalid.","invalid-recipient-email":"The email corresponding to this action failed to send as the provided recipient email address is invalid.","invalid-sender":"The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-verification-id":"The verification ID used to create the phone auth credential is invalid.","invalid-tenant-id":"The Auth instance's tenant ID is invalid.","missing-android-pkg-name":"An Android Package Name must be provided if the Android App is required to be installed.","auth-domain-config-required":"Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.","missing-app-credential":"The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.","missing-verification-code":"The phone auth credential was created with an empty SMS verification code.","missing-continue-uri":"A continue URL must be provided in the request.","missing-iframe-start":"An internal AuthError has occurred.","missing-ios-bundle-id":"An iOS Bundle ID must be provided if an App Store ID is provided.","missing-or-invalid-nonce":"The request does not contain a valid nonce. This can occur if the SHA-256 hash of the provided raw nonce does not match the hashed nonce in the ID token payload.","missing-multi-factor-info":"No second factor identifier is provided.","missing-multi-factor-session":"The request is missing proof of first factor successful sign-in.","missing-phone-number":"To send verification codes, provide a phone number for the recipient.","missing-verification-id":"The phone auth credential was created with an empty verification ID.","app-deleted":"This instance of FirebaseApp has been deleted.","multi-factor-info-not-found":"The user does not have a second factor matching the identifier provided.","multi-factor-auth-required":"Proof of ownership of a second factor is required to complete sign-in.","account-exists-with-different-credential":"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.","network-request-failed":"A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred.","no-auth-event":"An internal AuthError has occurred.","no-such-provider":"User was not linked to an account with the given provider.","null-user":"A null user object was provided as the argument for an operation which requires a non-null user object.","operation-not-allowed":"The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.","operation-not-supported-in-this-environment":'This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.',"popup-blocked":"Unable to establish a connection with the popup. It may have been blocked by the browser.","popup-closed-by-user":"The popup has been closed by the user before finalizing the operation.","provider-already-linked":"User can only be linked to one identity for the given provider.","quota-exceeded":"The project's quota for this operation has been exceeded.","redirect-cancelled-by-user":"The redirect operation has been cancelled by the user before finalizing.","redirect-operation-pending":"A redirect sign-in operation is already pending.","rejected-credential":"The request contains malformed or mismatching credentials.","second-factor-already-in-use":"The second factor is already enrolled on this account.","maximum-second-factor-count-exceeded":"The maximum allowed number of second factors on a user has been exceeded.","tenant-id-mismatch":"The provided tenant ID does not match the Auth instance's tenant ID",timeout:"The operation has timed out.","user-token-expired":"The user's credential is no longer valid. The user must sign in again.","too-many-requests":"We have blocked all requests from this device due to unusual activity. Try again later.","unauthorized-continue-uri":"The domain of the continue URL is not whitelisted. Please whitelist the domain in the Firebase console.","unsupported-first-factor":"Enrolling a second factor or signing in with a multi-factor account requires sign-in with a supported first factor.","unsupported-persistence-type":"The current environment does not support the specified persistence type.","unsupported-tenant-operation":"This operation is not supported in a multi-tenant context.","unverified-email":"The operation requires a verified email.","user-cancelled":"The user did not grant your application the permissions it requested.","user-not-found":"There is no user record corresponding to this identifier. The user may have been deleted.","user-disabled":"The user account has been disabled by an administrator.","user-mismatch":"The supplied credentials do not correspond to the previously signed in user.","user-signed-out":"","weak-password":"The password must be 6 characters long or more.","web-storage-unsupported":"This browser is not supported or 3rd party cookies and data may be disabled.","already-initialized":"initializeAuth() has already been called with different options. To avoid this error, call initializeAuth() with the same options as when it was originally called, or call getAuth() to return the already initialized instance."}}const bm=_m,Tm=new md("auth","Firebase",_m()),Im=new ep("@firebase/auth");function Em(e,...t){Im.logLevel<=Kh.ERROR&&Im.error(`Auth (${gp}): ${e}`,...t)}function km(e,...t){throw Nm(e,...t)}function Sm(e,...t){return Nm(e,...t)}function Cm(e,t,n){var r=Object.assign(Object.assign({},bm()),{[t]:n});const i=new md("auth","Firebase",r);return i.create(t,{appName:e.name})}function Am(e,t,n){if(!(t instanceof n))throw n.name!==t.constructor.name&&km(e,"argument-error"),Cm(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.`+"Did you pass a reference from a different Auth SDK?")}function Nm(e,...t){if("string"==typeof e)return Tm.create(e,...t);{var n=t[0];const r=[...t.slice(1)];return r[0]&&(r[0].appName=e.name),e._errorFactory.create(n,...r)}}function Rm(e,t,...n){if(!e)throw Nm(t,...n)}function Pm(e){var t="INTERNAL ASSERTION FAILED: "+e;throw Em(t),new Error(t)}function xm(e,t){e||Pm(t)}const Dm=new Map;function Om(e){xm(e instanceof Function,"Expected a class definition");let t=Dm.get(e);return t?xm(t instanceof e,"Instance stored in cache mismatched with class"):(t=new e,Dm.set(e,t)),t}function Mm(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.href)||""}function Lm(){return"http:"===Fm()||"https:"===Fm()}function Fm(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.protocol)||null}class Um{constructor(e,t){xm((this.shortDelay=e)<(this.longDelay=t),"Short delay should be less than long delay!"),this.isMobile=od()||ld()}get(){return"undefined"!=typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&(Lm()||cd()||"connection"in navigator)&&!navigator.onLine?Math.min(5e3,this.shortDelay):this.isMobile?this.longDelay:this.shortDelay}}function jm(e,t){xm(e.emulator,"Emulator should always be set here");var n=e.emulator["url"];return t?`${n}${t.startsWith("/")?t.slice(1):t}`:n}class qm{static initialize(e,t,n){this.fetchImpl=e,t&&(this.headersImpl=t),n&&(this.responseImpl=n)}static fetch(){return this.fetchImpl||("undefined"!=typeof self&&"fetch"in self?self.fetch:void Pm("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}static headers(){return this.headersImpl||("undefined"!=typeof self&&"Headers"in self?self.Headers:void Pm("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}static response(){return this.responseImpl||("undefined"!=typeof self&&"Response"in self?self.Response:void Pm("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}}const Vm={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:"internal-error",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",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"},Bm=new Um(3e4,6e4);function Wm(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function Km(i,s,o,a,e={}){return $m(i,e,async()=>{let e={},t={};a&&("GET"===s?t=a:e={body:JSON.stringify(a)});var n=Cd(Object.assign({key:i.config.apiKey},t)).slice(1);const r=await i._getAdditionalHeaders();return r["Content-Type"]="application/json",i.languageCode&&(r["X-Firebase-Locale"]=i.languageCode),qm.fetch()(Hm(i,i.config.apiHost,o,n),Object.assign({method:s,headers:r,referrerPolicy:"no-referrer"},e))})}async function $m(t,e,n){t._canInitEmulator=!1;var r=Object.assign(Object.assign({},Vm),e);try{const o=new Gm(t),a=await Promise.race([n(),o.promise]);o.clearNetworkTimeout();var i=await a.json();if("needConfirmation"in i)throw Qm(t,"account-exists-with-different-credential",i);if(a.ok&&!("errorMessage"in i))return i;{const c=a.ok?i.errorMessage:i.error.message,[l,u]=c.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===l)throw Qm(t,"credential-already-in-use",i);if("EMAIL_EXISTS"===l)throw Qm(t,"email-already-in-use",i);var s=r[l]||l.toLowerCase().replace(/[_\s]+/g,"-");if(u)throw Cm(t,s,u);km(t,s)}}catch(e){if(e instanceof gd)throw e;km(t,"network-request-failed")}}async function zm(e,t,n,r,i={}){var s=await Km(e,t,n,r,i);return"mfaPendingCredential"in s&&km(e,"multi-factor-auth-required",{_serverResponse:s}),s}function Hm(e,t,n,r){var i=`${t}${n}?${r}`;return e.config.emulator?jm(e.config,i):`${e.config.apiScheme}://${i}`}class Gm{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(Sm(this.auth,"timeout")),Bm.get())})}clearNetworkTimeout(){clearTimeout(this.timer)}}function Qm(e,t,n){const r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=Sm(e,t,r);return i.customData._tokenResponse=n,i}function Ym(e){if(e)try{const t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}function Jm(e){return 1e3*Number(e)}function Xm(e){var[t,n,r]=e.split(".");if(void 0===t||void 0===n||void 0===r)return Em("JWT malformed, contained fewer than 3 sections"),null;try{var i=td(n);return i?JSON.parse(i):(Em("Failed to decode base64 JWT payload"),null)}catch(e){return Em("Caught error parsing JWT payload as JSON",e),null}}async function Zm(t,n,e=!1){if(e)return n;try{return n}catch(e){throw e instanceof gd&&(n=[e["code"]][0],"auth/user-disabled"===n||"auth/user-token-expired"===n)&&t.auth.currentUser===t&&await t.auth.signOut(),e}}class ev{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){if(e){var t=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),t}this.errorBackoff=3e4;t=(null!==(t=this.user.stsTokenManager.expirationTime)&&void 0!==t?t:0)-Date.now()-3e5;return Math.max(0,t)}schedule(e=!1){var t;this.isRunning&&(t=this.getInterval(e),this.timerId=setTimeout(async()=>{await this.iteration()},t))}async iteration(){try{await this.user.getIdToken(!0)}catch(e){return void("auth/network-request-failed"===e.code&&this.schedule(!0))}this.schedule()}}class tv{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=Ym(this.lastLoginAt),this.creationTime=Ym(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function nv(e){var t=e.auth,n=await e.getIdToken(),r=await Zm(e,async function(e,t){return Km(e,"POST","/v1/accounts:lookup",t)}(t,{idToken:n}));Rm(null==r?void 0:r.users.length,t,"internal-error");var i=r.users[0];e._notifyReloadListener(i);var s,o,t=null!==(n=i.providerUserInfo)&&void 0!==n&&n.length?i.providerUserInfo.map(e=>{var t=e["providerId"],n=mm(e,["providerId"]);return{providerId:t,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}}):[],r=(s=e.providerData,o=t,[...s.filter(t=>!o.some(e=>e.providerId===t.providerId)),...o]),n=e.isAnonymous,t=!(e.email&&i.passwordHash||null!==r&&r.length),t=!!n&&t,t={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:r,metadata:new tv(i.createdAt,i.lastLoginAt),isAnonymous:t};Object.assign(e,t)}class rv{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){Rm(e.idToken,"internal-error"),Rm(void 0!==e.idToken,"internal-error"),Rm(void 0!==e.refreshToken,"internal-error");var t,n,n="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):(t=e.idToken,Rm(n=Xm(t),"internal-error"),Rm(void 0!==n.exp,"internal-error"),Rm(void 0!==n.iat,"internal-error"),Number(n.exp)-Number(n.iat));this.updateTokensAndExpiration(e.idToken,e.refreshToken,n)}async getToken(e,t=!1){return Rm(!this.accessToken||this.refreshToken,e,"user-token-expired"),t||!this.accessToken||this.isExpired?this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null:this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){var i,s,{accessToken:n,refreshToken:r,expiresIn:o}=(s=t,await{accessToken:(o=await $m(i=e,{},async()=>{var e=Cd({grant_type:"refresh_token",refresh_token:s}).slice(1),{tokenApiHost:t,apiKey:n}=i.config,n=Hm(i,t,"/v1/token",`key=${n}`);const r=await i._getAdditionalHeaders();return r["Content-Type"]="application/x-www-form-urlencoded",qm.fetch()(n,{method:"POST",headers:r,body:e})})).access_token,expiresIn:o.expires_in,refreshToken:o.refresh_token});this.updateTokensAndExpiration(n,r,Number(o))}updateTokensAndExpiration(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(e,t){var{refreshToken:n,accessToken:r,expirationTime:i}=t;const s=new rv;return n&&(Rm("string"==typeof n,"internal-error",{appName:e}),s.refreshToken=n),r&&(Rm("string"==typeof r,"internal-error",{appName:e}),s.accessToken=r),i&&(Rm("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 rv,this.toJSON())}_performRefresh(){return Pm("not implemented")}}function iv(e,t){Rm("string"==typeof e||void 0===e,"internal-error",{appName:t})}class sv{constructor(e){var{uid:t,auth:n,stsTokenManager:r}=e,i=mm(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.emailVerified=!1,this.isAnonymous=!1,this.tenantId=null,this.providerData=[],this.proactiveRefresh=new ev(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.metadata=new tv(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){var t=await Zm(this,this.stsTokenManager.getToken(this.auth,e));return Rm(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return async function(e,t=!1){const n=Kd(e);var r=await n.getIdToken(t),i=Xm(r);Rm(i&&i.exp&&i.auth_time&&i.iat,n.auth,"internal-error");var s="object"==typeof i.firebase?i.firebase:void 0,o=null==s?void 0:s.sign_in_provider;return{claims:i,token:r,authTime:Ym(Jm(i.auth_time)),issuedAtTime:Ym(Jm(i.iat)),expirationTime:Ym(Jm(i.exp)),signInProvider:o||null,signInSecondFactor:(null==s?void 0:s.sign_in_second_factor)||null}}(this,e)}reload(){return async function(e){const t=Kd(e);await nv(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}(this)}_assign(e){this!==e&&(Rm(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){return new sv(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}))}_onReload(e){Rm(!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 nv(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){var e=await this.getIdToken();return await Zm(this,async function(e,t){return Km(e,"POST","/v1/accounts:delete",t)}(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var n=null!==(o=t.displayName)&&void 0!==o?o:void 0,r=null!==(g=t.email)&&void 0!==g?g:void 0,i=null!==(a=t.phoneNumber)&&void 0!==a?a:void 0,s=null!==(l=t.photoURL)&&void 0!==l?l:void 0,o=null!==(c=t.tenantId)&&void 0!==c?c:void 0,a=null!==(g=t._redirectEventId)&&void 0!==g?g:void 0,c=null!==(l=t.createdAt)&&void 0!==l?l:void 0,l=null!==(g=t.lastLoginAt)&&void 0!==g?g:void 0;const{uid:u,emailVerified:h,isAnonymous:d,providerData:p,stsTokenManager:f}=t;Rm(u&&f,e,"internal-error");var g=rv.fromJSON(this.name,f);Rm("string"==typeof u,e,"internal-error"),iv(n,e.name),iv(r,e.name),Rm("boolean"==typeof h,e,"internal-error"),Rm("boolean"==typeof d,e,"internal-error"),iv(i,e.name),iv(s,e.name),iv(o,e.name),iv(a,e.name),iv(c,e.name),iv(l,e.name);const m=new sv({uid:u,auth:e,email:r,emailVerified:h,displayName:n,isAnonymous:d,photoURL:s,phoneNumber:i,tenantId:o,stsTokenManager:g,createdAt:c,lastLoginAt:l});return p&&Array.isArray(p)&&(m.providerData=p.map(e=>Object.assign({},e))),a&&(m._redirectEventId=a),m}static async _fromIdTokenResponse(e,t,n=!1){const r=new rv;r.updateFromServerResponse(t);var i=new sv({uid:t.localId,auth:e,stsTokenManager:r,isAnonymous:n});return await nv(i),i}}class ov{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){var t=this.storage[e];return void 0===t?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}ov.type="NONE";const av=ov;function cv(e,t,n){return`firebase:${e}:${t}:${n}`}class lv{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;var{config:r,name:i}=this.auth;this.fullUserKey=cv(this.userKey,r.apiKey,i),this.fullPersistenceKey=cv("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(){var e=await this.persistence._get(this.fullUserKey);return e?sv._fromJSON(this.auth,e):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence!==e){var t=await this.getCurrentUser();return await this.removeCurrentUser(),this.persistence=e,t?this.setCurrentUser(t):void 0}}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,n="authUser"){if(!t.length)return new lv(Om(av),e,n);const r=(await Promise.all(t.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e);let i=r[0]||Om(av);const s=cv(n,e.config.apiKey,e.name);let o=null;for(const u of t)try{var a=await u._get(s);if(a){var c=sv._fromJSON(e,a);u!==i&&(o=c),i=u;break}}catch(e){}var l=r.filter(e=>e._shouldAllowMigration);return i._shouldAllowMigration&&l.length&&(i=l[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 lv(i,e,n)}}function uv(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(fv(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(hv(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(mv(t))return"Blackberry";if(vv(t))return"Webos";if(dv(t))return"Safari";if((t.includes("chrome/")||pv(t))&&!t.includes("edge/"))return"Chrome";if(gv(t))return"Android";var n=e.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/);return 2===(null==n?void 0:n.length)?n[1]:"Other"}function hv(e=sd()){return/firefox\//i.test(e)}function dv(e=sd()){const t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function pv(e=sd()){return/crios\//i.test(e)}function fv(e=sd()){return/iemobile/i.test(e)}function gv(e=sd()){return/android/i.test(e)}function mv(e=sd()){return/blackberry/i.test(e)}function vv(e=sd()){return/webos/i.test(e)}function yv(e=sd()){return/iphone|ipad|ipod/i.test(e)}function _v(e=sd()){return yv(e)||gv(e)||vv(e)||mv(e)||/windows phone/i.test(e)||fv(e)}function wv(e,t=[]){let n;switch(e){case"Browser":n=uv(sd());break;case"Worker":n=`${uv(sd())}-${e}`;break;default:n=e}var r=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${gp}/${r}`}class bv{constructor(e,t){this.app=e,this.config=t,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Iv(this),this.idTokenSubscription=new Iv(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=Tm,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=t.sdkClientVersion}_initializeWithPersistence(t,n){return n&&(this._popupRedirectResolver=Om(n)),this._initializationPromise=this.queue(async()=>{var e;if(!this._deleted&&(this.persistenceManager=await lv.create(this,t),!this._deleted)){if(null!==(e=this._popupRedirectResolver)&&void 0!==e&&e._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(e){}await this.initializeCurrentUser(n),this.lastNotifiedUid=(null===(e=this.currentUser)||void 0===e?void 0:e.uid)||null,this._deleted||(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(!this._deleted){var e=await this.assertedPersistence.getCurrentUser();if(this.currentUser||e)return this.currentUser&&e&&this.currentUser.uid===e.uid?(this._currentUser._assign(e),void await this.currentUser.getIdToken()):void await this._updateCurrentUser(e)}}async initializeCurrentUser(e){var t,n,r;let i=await this.assertedPersistence.getCurrentUser();return e&&this.config.authDomain&&(await this.getOrInitRedirectPersistenceManager(),t=null===(r=this.redirectUser)||void 0===r?void 0:r._redirectEventId,n=null===i||void 0===i?void 0:i._redirectEventId,r=await this.tryRedirectSignIn(e),t&&t!==n||null==r||!r.user||(i=r.user)),i?i._redirectEventId?(Rm(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===i._redirectEventId?this.directlySetCurrentUser(i):this.reloadAndSetCurrentUserOrClear(i)):this.reloadAndSetCurrentUserOrClear(i):this.directlySetCurrentUser(null)}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 nv(e)}catch(e){if("auth/network-request-failed"!==e.code)return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;var e=navigator;return e.languages&&e.languages[0]||e.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(e){const t=e?Kd(e):null;return t&&Rm(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e){if(!this._deleted)return e&&Rm(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null)}setPersistence(e){return this.queue(async()=>{await this.assertedPersistence.setPersistence(Om(e))})}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(e){this._errorFactory=new md("auth","Firebase",e())}onAuthStateChanged(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}onIdTokenChanged(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}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){const n=await this.getOrInitRedirectPersistenceManager(t);return null===e?n.removeCurrentUser():n.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){var t;return this.redirectPersistenceManager||(Rm(t=e&&Om(e)||this._popupRedirectResolver,this,"argument-error"),this.redirectPersistenceManager=await lv.create(this,[Om(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()),this.redirectPersistenceManager}async _redirectUserForId(e){var t;return this._isInitialized&&await this.queue(async()=>{}),(null===(t=this._currentUser)||void 0===t?void 0:t._redirectEventId)===e?this._currentUser:(null===(t=this.redirectUser)||void 0===t?void 0:t._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;this._isInitialized&&(this.idTokenSubscription.next(this.currentUser),e=null!==(e=null===(e=this.currentUser)||void 0===e?void 0:e.uid)&&void 0!==e?e:null,this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser)))}registerStateListener(e,t,n,r){if(this._deleted)return()=>{};const i="function"==typeof t?t:t.next.bind(t),s=this._isInitialized?Promise.resolve():this._initializationPromise;return Rm(s,this,"internal-error"),s.then(()=>i(this.currentUser)),"function"==typeof t?e.addObserver(t,n,r):e.addObserver(t)}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&(this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh()),(this.currentUser=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 Rm(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=wv(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){const e={"X-Client-Version":this.clientVersion};return this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId),e}}function Tv(e){return Kd(e)}class Iv{constructor(e){this.auth=e,this.observer=null,this.addObserver=Pd(e=>this.observer=e)}get next(){return Rm(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}function Ev(e,t,n){const r=Tv(e);Rm(r._canInitEmulator,r,"emulator-config-failed"),Rm(/^https?:\/\//.test(t),r,"invalid-emulator-scheme");var i=!(null==n||!n.disableWarnings);const s=kv(t);var{host:o,port:a}=function(e){const t=kv(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);{if(i){var s=i[1];return{host:s,port:Sv(r.substr(s.length+1))}}var[o,s]=r.split(":");return{host:o,port:Sv(s)}}}(t);r.config.emulator={url:`${s}//${o}${null===a?"":`:${a}`}/`},r.settings.appVerificationDisabledForTesting=!0,r.emulatorConfig=Object.freeze({host:o,port:a,protocol:s.replace(":",""),options:Object.freeze({disableWarnings:i})}),i||function(){function e(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}"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())}()}function kv(e){var t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function Sv(e){if(!e)return null;var t=Number(e);return isNaN(t)?null:t}class Cv{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return Pm("not implemented")}_getIdTokenResponse(e){return Pm("not implemented")}_linkToIdToken(e,t){return Pm("not implemented")}_getReauthenticationResolver(e){return Pm("not implemented")}}async function Av(e,t){return Km(e,"POST","/v1/accounts:resetPassword",Wm(e,t))}async function Nv(e,t){return Km(e,"POST","/v1/accounts:update",t)}async function Rv(e,t){return Km(e,"POST","/v1/accounts:sendOobCode",Wm(e,t))}class Pv extends Cv{constructor(e,t,n,r=null){super("password",n),this._email=e,this._password=t,this._tenantId=r}static _fromEmailAndPassword(e,t){return new Pv(e,t,"password")}static _fromEmailAndCode(e,t,n=null){return new Pv(e,t,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){var t="string"==typeof e?JSON.parse(e):e;if(null!=t&&t.email&&null!=t&&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 async function(e,t){return zm(e,"POST","/v1/accounts:signInWithPassword",Wm(e,t))}(e,{returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(e,t){return zm(e,"POST","/v1/accounts:signInWithEmailLink",Wm(e,t))}(e,{email:this._email,oobCode:this._password});default:km(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return Nv(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(e,t){return zm(e,"POST","/v1/accounts:signInWithEmailLink",Wm(e,t))}(e,{idToken:t,email:this._email,oobCode:this._password});default:km(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function xv(e,t){return zm(e,"POST","/v1/accounts:signInWithIdp",Wm(e,t))}class Dv extends Cv{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new Dv(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):km("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){var t="string"==typeof e?JSON.parse(e):e,{providerId:n,signInMethod:r}=t,t=mm(t,["providerId","signInMethod"]);if(!n||!r)return null;const i=new Dv(n,r);return i.idToken=t.idToken||void 0,i.accessToken=t.accessToken||void 0,i.secret=t.secret,i.nonce=t.nonce,i.pendingToken=t.pendingToken||null,i}_getIdTokenResponse(e){return xv(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,xv(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,xv(e,t)}buildRequest(){const e={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=Cd(t)}return e}}const Ov={USER_NOT_FOUND:"user-not-found"};class Mv extends Cv{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new Mv({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new Mv({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return async function(e,t){return zm(e,"POST","/v1/accounts:signInWithPhoneNumber",Wm(e,t))}(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return async function(e,t){var n=await zm(e,"POST","/v1/accounts:signInWithPhoneNumber",Wm(e,t));if(n.temporaryProof)throw Qm(e,"account-exists-with-different-credential",n);return n}(e,Object.assign({idToken:t},this._makeVerificationRequest()))}_getReauthenticationResolver(e){return async function(e,t){return zm(e,"POST","/v1/accounts:signInWithPhoneNumber",Wm(e,Object.assign(Object.assign({},t),{operation:"REAUTH"})),Ov)}(e,this._makeVerificationRequest())}_makeVerificationRequest(){var{temporaryProof:e,phoneNumber:t,verificationId:n,verificationCode:r}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:n,code:r}}toJSON(){const 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){var{verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}=e="string"==typeof e?JSON.parse(e):e;return n||t||r||i?new Mv({verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}):null}}class Lv{constructor(e){var t=Ad(Nd(e)),n=null!==(r=t.apiKey)&&void 0!==r?r:null,r=null!==(i=t.oobCode)&&void 0!==i?i:null,i=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!==(i=t.mode)&&void 0!==i?i:null);Rm(n&&r&&i,"argument-error"),this.apiKey=n,this.operation=i,this.code=r,this.continueUrl=null!==(r=t.continueUrl)&&void 0!==r?r:null,this.languageCode=null!==(r=t.languageCode)&&void 0!==r?r:null,this.tenantId=null!==(t=t.tenantId)&&void 0!==t?t:null}static parseLink(e){var t,n,r,t=(t=Ad(Nd(e=e)).link,n=t?Ad(Nd(t)).deep_link_id:null,((r=Ad(Nd(e)).deep_link_id)?Ad(Nd(r)).link:null)||r||n||t||e);try{return new Lv(t)}catch(e){return null}}}class Fv{constructor(){this.providerId=Fv.PROVIDER_ID}static credential(e,t){return Pv._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){var n=Lv.parseLink(t);return Rm(n,"argument-error"),Pv._fromEmailAndCode(e,n.code,n.tenantId)}}Fv.PROVIDER_ID="password",Fv.EMAIL_PASSWORD_SIGN_IN_METHOD="password",Fv.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class Uv{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 jv extends Uv{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class qv extends jv{static credentialFromJSON(e){var t="string"==typeof e?JSON.parse(e):e;return Rm("providerId"in t&&"signInMethod"in t,"argument-error"),Dv._fromParams(t)}credential(e){return this._credential(Object.assign(Object.assign({},e),{nonce:e.rawNonce}))}_credential(e){return Rm(e.idToken||e.accessToken,"argument-error"),Dv._fromParams(Object.assign(Object.assign({},e),{providerId:this.providerId,signInMethod:this.providerId}))}static credentialFromResult(e){return qv.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return qv.oauthCredentialFromTaggedObject(e.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthIdToken:t,oauthAccessToken:n,oauthTokenSecret:r,pendingToken:i,nonce:s,providerId:o}=e;if(!(n||r||t||i))return null;if(!o)return null;try{return new qv(o)._credential({idToken:t,accessToken:n,nonce:s,pendingToken:i})}catch(e){return null}}}class Vv extends jv{constructor(){super("facebook.com")}static credential(e){return Dv._fromParams({providerId:Vv.PROVIDER_ID,signInMethod:Vv.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Vv.credentialFromTaggedObject(e)}static credentialFromError(e){return Vv.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return Vv.credential(e.oauthAccessToken)}catch(e){return null}}}Vv.FACEBOOK_SIGN_IN_METHOD="facebook.com",Vv.PROVIDER_ID="facebook.com";class Bv extends jv{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return Dv._fromParams({providerId:Bv.PROVIDER_ID,signInMethod:Bv.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return Bv.credentialFromTaggedObject(e)}static credentialFromError(e){return Bv.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthIdToken:t,oauthAccessToken:n}=e;if(!t&&!n)return null;try{return Bv.credential(t,n)}catch(e){return null}}}Bv.GOOGLE_SIGN_IN_METHOD="google.com",Bv.PROVIDER_ID="google.com";class Wv extends jv{constructor(){super("github.com")}static credential(e){return Dv._fromParams({providerId:Wv.PROVIDER_ID,signInMethod:Wv.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Wv.credentialFromTaggedObject(e)}static credentialFromError(e){return Wv.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return Wv.credential(e.oauthAccessToken)}catch(e){return null}}}Wv.GITHUB_SIGN_IN_METHOD="github.com",Wv.PROVIDER_ID="github.com";class Kv extends Cv{constructor(e,t){super(e,e),this.pendingToken=t}_getIdTokenResponse(e){return xv(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,xv(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,xv(e,t)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(e){var{providerId:t,signInMethod:n,pendingToken:r}="string"==typeof e?JSON.parse(e):e;return t&&n&&r&&t===n?new Kv(t,r):null}static _create(e,t){return new Kv(e,t)}buildRequest(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}class $v extends Uv{constructor(e){Rm(e.startsWith("saml."),"argument-error"),super(e)}static credentialFromResult(e){return $v.samlCredentialFromTaggedObject(e)}static credentialFromError(e){return $v.samlCredentialFromTaggedObject(e.customData||{})}static credentialFromJSON(e){var t=Kv.fromJSON(e);return Rm(t,"argument-error"),t}static samlCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{pendingToken:t,providerId:n}=e;if(!t||!n)return null;try{return Kv._create(n,t)}catch(e){return null}}}class zv extends jv{constructor(){super("twitter.com")}static credential(e,t){return Dv._fromParams({providerId:zv.PROVIDER_ID,signInMethod:zv.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return zv.credentialFromTaggedObject(e)}static credentialFromError(e){return zv.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return zv.credential(t,n)}catch(e){return null}}}async function Hv(e,t){return zm(e,"POST","/v1/accounts:signUp",Wm(e,t))}zv.TWITTER_SIGN_IN_METHOD="twitter.com",zv.PROVIDER_ID="twitter.com";class Gv{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){var i=await sv._fromIdTokenResponse(e,n,r),s=Qv(n);return new Gv({user:i,providerId:s,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);var r=Qv(n);return new Gv({user:e,providerId:r,_tokenResponse:n,operationType:t})}}function Qv(e){return e.providerId||("phoneNumber"in e?"phone":null)}class Yv extends gd{constructor(e,t,n,r){var i;super(t.code,t.message),this.operationType=n,this.user=r,Object.setPrototypeOf(this,Yv.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 Yv(e,t,n,r)}}function Jv(t,n,e,r){const i="reauthenticate"===n?e._getReauthenticationResolver(t):e._getIdTokenResponse(t);return i.catch(e=>{if("auth/multi-factor-auth-required"===e.code)throw Yv._fromErrorAndOperation(t,e,n,r);throw e})}function Xv(e){return new Set(e.map(({providerId:e})=>e).filter(e=>!!e))}async function Zv(e,t){const n=Kd(e);await ty(!0,n,t);var r=(e=n.auth,t={idToken:await n.getIdToken(),deleteProvider:[t]},await Km(e,"POST","/v1/accounts:update",t))["providerUserInfo"];const i=Xv(r||[]);return n.providerData=n.providerData.filter(e=>i.has(e.providerId)),i.has("phone")||(n.phoneNumber=null),await n.auth._persistUserIfCurrent(n),n}async function ey(e,t,n=!1){var r=await Zm(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return Gv._forOperation(e,"link",r)}async function ty(e,t,n){await nv(t);const r=Xv(t.providerData);var i=!1===e?"provider-already-linked":"no-such-provider";Rm(r.has(n)===e,t.auth,i)}async function ny(e,t,n=!1){var r=e["auth"],i="reauthenticate";try{var s=await Zm(e,Jv(r,i,t,e),n);Rm(s.idToken,r,"internal-error");var o=Xm(s.idToken);Rm(o,r,"internal-error");var a=o["sub"];return Rm(e.uid===a,r,"user-mismatch"),Gv._forOperation(e,i,s)}catch(e){throw"auth/user-not-found"===(null==e?void 0:e.code)&&km(r,"user-mismatch"),e}}async function ry(e,t,n=!1){var r=await Jv(e,"signIn",t),r=await Gv._fromIdTokenResponse(e,"signIn",r);return n||await e._updateCurrentUser(r.user),r}async function iy(e,t){return ry(Tv(e),t)}async function sy(e,t){var n=Kd(e);return await ty(!1,n,t.providerId),ey(n,t)}async function oy(e,t){return ny(Kd(e),t)}async function ay(e,t){const n=Tv(e);var r=await zm(n,"POST","/v1/accounts:signInWithCustomToken",Wm(n,{token:t,returnSecureToken:!0})),r=await Gv._fromIdTokenResponse(n,"signIn",r);return await n._updateCurrentUser(r.user),r}class cy{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?ly._fromServerResponse(e,t):km(e,"internal-error")}}class ly extends cy{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new ly(t)}}function uy(e,t,n){var r;Rm(0<(null===(r=n.url)||void 0===r?void 0:r.length),e,"invalid-continue-uri"),Rm(void 0===n.dynamicLinkDomain||0<n.dynamicLinkDomain.length,e,"invalid-dynamic-link-domain"),t.continueUrl=n.url,t.dynamicLinkDomain=n.dynamicLinkDomain,t.canHandleCodeInApp=n.handleCodeInApp,n.iOS&&(Rm(0<n.iOS.bundleId.length,e,"missing-ios-bundle-id"),t.iOSBundleId=n.iOS.bundleId),n.android&&(Rm(0<n.android.packageName.length,e,"missing-android-pkg-name"),t.androidInstallApp=n.android.installApp,t.androidMinimumVersionCode=n.android.minimumVersion,t.androidPackageName=n.android.packageName)}async function hy(e,t,n){var r=Kd(e),i={requestType:"PASSWORD_RESET",email:t};n&&uy(r,i,n),await Rv(r,i)}async function dy(e,t){await Km(e=Kd(e),"POST","/v1/accounts:update",Wm(e,{oobCode:t}))}async function py(e,t){var n=Kd(e),r=await Av(n,{oobCode:t}),i=r.requestType;switch(Rm(i,n,"internal-error"),i){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":Rm(r.newEmail,n,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":Rm(r.mfaInfo,n,"internal-error");default:Rm(r.email,n,"internal-error")}let s=null;return r.mfaInfo&&(s=cy._fromServerResponse(Tv(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:s},operation:i}}async function fy(e,t,n){var r=Kd(e),i={requestType:"EMAIL_SIGNIN",email:t};Rm(n.handleCodeInApp,r,"argument-error"),n&&uy(r,i,n),await Rv(r,i)}async function gy(e,t){var n=Lm()?Mm():"http://localhost",n=(await Km(e=Kd(e),"POST","/v1/accounts:createAuthUri",Wm(e,{identifier:t,continueUri:n})))["signinMethods"];return n||[]}async function my(e,t){var n=Kd(e),r={requestType:"VERIFY_EMAIL",idToken:await e.getIdToken()};t&&uy(n.auth,r,t);var r=(await Rv(n.auth,r))["email"];r!==e.email&&await e.reload()}async function vy(e,t,n){var r=Kd(e),i={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await e.getIdToken(),newEmail:t};n&&uy(r.auth,i,n);var i=(await Rv(r.auth,i))["email"];i!==e.email&&await e.reload()}async function yy(e,{displayName:t,photoURL:n}){if(void 0!==t||void 0!==n){const i=Kd(e);var r=await i.getIdToken(),r=await Zm(i,async function(e,t){return Km(e,"POST","/v1/accounts:update",t)}(i.auth,{idToken:r,displayName:t,photoUrl:n,returnSecureToken:!0}));i.displayName=r.displayName||null,i.photoURL=r.photoUrl||null;const s=i.providerData.find(({providerId:e})=>"password"===e);s&&(s.displayName=i.displayName,s.photoURL=i.photoURL),await i._updateTokensIfNecessary(r)}}async function _y(e,t,n){var r=e["auth"];const i={idToken:await e.getIdToken(),returnSecureToken:!0};t&&(i.email=t),n&&(i.password=n);r=await Zm(e,Nv(r,i));await e._updateTokensIfNecessary(r,!0)}class wy{constructor(e,t,n={}){this.isNewUser=e,this.providerId=t,this.profile=n}}class by extends wy{constructor(e,t,n,r){super(e,t,n),this.username=r}}class Ty extends wy{constructor(e,t){super(e,"facebook.com",t)}}class Iy extends by{constructor(e,t){super(e,"github.com",t,"string"==typeof(null==t?void 0:t.login)?null==t?void 0:t.login:null)}}class Ey extends wy{constructor(e,t){super(e,"google.com",t)}}class ky extends by{constructor(e,t,n){super(e,"twitter.com",t,n)}}function Sy(e){var{user:t,_tokenResponse:n}=e;return t.isAnonymous&&!n?{providerId:null,isNewUser:!1,profile:null}:function(e){if(!e)return null;var t=e["providerId"],n=e.rawUserInfo?JSON.parse(e.rawUserInfo):{},r=e.isNewUser||"identitytoolkit#SignupNewUserResponse"===e.kind;if(!t&&null!=e&&e.idToken){var i=null===(i=null===(i=Xm(e.idToken))||void 0===i?void 0:i.firebase)||void 0===i?void 0:i.sign_in_provider;if(i){i="anonymous"!==i&&"custom"!==i?i:null;return new wy(r,i)}}if(!t)return null;switch(t){case"facebook.com":return new Ty(r,n);case"github.com":return new Iy(r,n);case"google.com":return new Ey(r,n);case"twitter.com":return new ky(r,n,e.screenName||null);case"custom":case"anonymous":return new wy(r,null);default:return new wy(r,t,n)}}(n)}class Cy{constructor(e,t){this.type=e,this.credential=t}static _fromIdtoken(e){return new Cy("enroll",e)}static _fromMfaPendingCredential(e){return new Cy("signin",e)}toJSON(){return{multiFactorSession:{["enroll"===this.type?"idToken":"pendingCredential"]:this.credential}}}static fromJSON(e){var t;if(null!=e&&e.multiFactorSession){if(null!==(t=e.multiFactorSession)&&void 0!==t&&t.pendingCredential)return Cy._fromMfaPendingCredential(e.multiFactorSession.pendingCredential);if(null!==(t=e.multiFactorSession)&&void 0!==t&&t.idToken)return Cy._fromIdtoken(e.multiFactorSession.idToken)}return null}}class Ay{constructor(e,t,n){this.session=e,this.hints=t,this.signInResolver=n}static _fromError(e,i){const s=Tv(e),o=i.customData._serverResponse;var t=(o.mfaInfo||[]).map(e=>cy._fromServerResponse(s,e));Rm(o.mfaPendingCredential,s,"internal-error");const a=Cy._fromMfaPendingCredential(o.mfaPendingCredential);return new Ay(a,t,async e=>{var t=await e._process(s,a);delete o.mfaInfo,delete o.mfaPendingCredential;var n=Object.assign(Object.assign({},o),{idToken:t.idToken,refreshToken:t.refreshToken});switch(i.operationType){case"signIn":var r=await Gv._fromIdTokenResponse(s,i.operationType,n);return await s._updateCurrentUser(r.user),r;case"reauthenticate":return Rm(i.user,s,"internal-error"),Gv._forOperation(i.user,i.operationType,n);default:km(s,"internal-error")}})}async resolveSignIn(e){return this.signInResolver(e)}}class Ny{constructor(t){this.user=t,this.enrolledFactors=[],t._onReload(e=>{e.mfaInfo&&(this.enrolledFactors=e.mfaInfo.map(e=>cy._fromServerResponse(t.auth,e)))})}static _fromUser(e){return new Ny(e)}async getSession(){return Cy._fromIdtoken(await this.user.getIdToken())}async enroll(e,t){const n=e;var r=await this.getSession(),r=await Zm(this.user,n._process(this.user.auth,r,t));return await this.user._updateTokensIfNecessary(r),this.user.reload()}async unenroll(e){const t="string"==typeof e?e:e.uid;var n,r=await this.user.getIdToken(),r=await Zm(this.user,(n=this.user.auth,e={idToken:r,mfaEnrollmentId:t},Km(n,"POST","/v2/accounts/mfaEnrollment:withdraw",Wm(n,e))));this.enrolledFactors=this.enrolledFactors.filter(({uid:e})=>e!==t),await this.user._updateTokensIfNecessary(r);try{await this.user.reload()}catch(e){if("auth/user-token-expired"!==e.code)throw e}}}const Ry=new WeakMap;const Py="__sak";class xy{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Py,"1"),this.storage.removeItem(Py),Promise.resolve(!0)):Promise.resolve(!1)}catch(e){return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){var 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 Dy extends xy{constructor(){var e;super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.safariLocalStorageNotSynced=(dv(e=sd())||yv(e))&&function(){try{return!(!window||window===window.top)}catch(e){return!1}}(),this.fallbackToPolling=_v(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const r of Object.keys(this.listeners)){var t=this.storage.getItem(r),n=this.localCache[r];t!==n&&e(r,n,t)}}onStorageEvent(e,t=!1){if(e.key){const r=e.key;if(t?this.detachListener():this.stopPolling(),this.safariLocalStorageNotSynced){const i=this.storage.getItem(r);if(e.newValue!==i)null!==e.newValue?this.storage.setItem(r,e.newValue):this.storage.removeItem(r);else if(this.localCache[r]===e.newValue&&!t)return}var n=()=>{var e=this.storage.getItem(r);!t&&this.localCache[r]===e||this.notifyListeners(r,e)};const i=this.storage.getItem(r);ud()&&10===document.documentMode&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(n,10):n()}else this.forAllChangedKeys((e,t,n)=>{this.notifyListeners(e,n)})}notifyListeners(e,t){this.localCache[e]=t;var n=this.listeners[e];if(n)for(const r of Array.from(n))r(t&&JSON.parse(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){var t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}Dy.type="LOCAL";const Oy=Dy;class My extends xy{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}My.type="SESSION";const Ly=My;class Fy{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(t){var e=this.receivers.find(e=>e.isListeningto(t));if(e)return e;e=new Fy(t);return this.receivers.push(e),e}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:n,eventType:r,data:i}=t.data;var s=this.handlersMap[r];null!=s&&s.size&&(t.ports[0].postMessage({status:"ack",eventId:n,eventType:r}),s=Array.from(s).map(async e=>e(t.origin,i)),s=await Promise.all(s.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(e){return{fulfilled:!1,reason:e}}})),t.ports[0].postMessage({status:"done",eventId:n,eventType:r,response:s}))}_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 Uy(e="",t=10){let n="";for(let r=0;r<t;r++)n+=Math.floor(10*Math.random());return e+n}Fy.receivers=[];class jy{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,o=50){const a="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!a)throw new Error("connection_unavailable");let c,l;return new Promise((n,r)=>{const i=Uy("",20);a.port1.start();const s=setTimeout(()=>{r(new Error("unsupported_event"))},o);l={messageChannel:a,onMessage(e){var t=e;if(t.data.eventId===i)switch(t.data.status){case"ack":clearTimeout(s),c=setTimeout(()=>{r(new Error("timeout"))},3e3);break;case"done":clearTimeout(c),n(t.data.response);break;default:clearTimeout(s),clearTimeout(c),r(new Error("invalid_response"))}}},this.handlers.add(l),a.port1.addEventListener("message",l.onMessage),this.target.postMessage({eventType:e,eventId:i,data:t},[a.port2])}).finally(()=>{l&&this.removeMessageHandler(l)})}}function qy(){return window}function Vy(){return void 0!==qy().WorkerGlobalScope&&"function"==typeof qy().importScripts}const By="firebaseLocalStorageDb",Wy="firebaseLocalStorage",Ky="fbase_key";class $y{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 zy(e,t){return e.transaction([Wy],t?"readwrite":"readonly").objectStore(Wy)}function Hy(){const r=indexedDB.open(By,1);return new Promise((n,t)=>{r.addEventListener("error",()=>{t(r.error)}),r.addEventListener("upgradeneeded",()=>{const e=r.result;try{e.createObjectStore(Wy,{keyPath:Ky})}catch(e){t(e)}}),r.addEventListener("success",async()=>{const e=r.result;var t;e.objectStoreNames.contains(Wy)?n(e):(e.close(),t=indexedDB.deleteDatabase(By),await new $y(t).toPromise(),n(await Hy()))})})}async function Gy(e,t,n){var r=zy(e,!0).put({fbase_key:t,value:n});return new $y(r).toPromise()}function Qy(e,t){var n=zy(e,!0).delete(t);return new $y(n).toPromise()}class Yy{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 Hy(),this.db)}async _withRetries(e){let t=0;for(;;)try{return e(await this._openDb())}catch(e){if(3<t++)throw e;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Vy()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Fy._getInstance(Vy()?self:null),this.receiver._subscribe("keyChanged",async(e,t)=>{const n=await this._poll();return{keyProcessed:n.includes(t.key)}}),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t,n;this.activeServiceWorker=await async function(){if(null===navigator||void 0===navigator||!navigator.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch(e){return null}}(),this.activeServiceWorker&&(this.sender=new jy(this.activeServiceWorker),(n=await this.sender._send("ping",{},800))&&null!==(e=n[0])&&void 0!==e&&e.fulfilled&&null!==(t=n[0])&&void 0!==t&&t.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0))}async notifyServiceWorker(e){var t;if(this.sender&&this.activeServiceWorker&&((null===(t=null===navigator||void 0===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;var e=await Hy();return await Gy(e,Py,"1"),await Qy(e,Py),!0}catch(e){}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(t,n){return this._withPendingWrite(async()=>(await this._withRetries(e=>Gy(e,t,n)),this.localCache[t]=n,this.notifyServiceWorker(t)))}async _get(t){var e=await this._withRetries(e=>async function(e,t){var n=zy(e,!1).get(t);return void 0===(n=await new $y(n).toPromise())?null:n.value}(e,t));return this.localCache[t]=e}async _remove(t){return this._withPendingWrite(async()=>(await this._withRetries(e=>Qy(e,t)),delete this.localCache[t],this.notifyServiceWorker(t)))}async _poll(){var e,t,n=await this._withRetries(e=>{var t=zy(e,!1).getAll();return new $y(t).toPromise()});if(!n)return[];if(0!==this.pendingWrites)return[];const r=[],i=new Set;for({fbase_key:e,value:t}of n)i.add(e),JSON.stringify(this.localCache[e])!==JSON.stringify(t)&&(this.notifyListeners(e,t),r.push(e));for(const s of Object.keys(this.localCache))this.localCache[s]&&!i.has(s)&&(this.notifyListeners(s,null),r.push(s));return r}notifyListeners(e,t){this.localCache[e]=t;var n=this.listeners[e];if(n)for(const r of Array.from(n))r(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()}}Yy.type="LOCAL";const Jy=Yy;function Xy(i){return new Promise((e,n)=>{const t=document.createElement("script");var r;t.setAttribute("src",i),t.onload=e,t.onerror=e=>{const t=Sm("internal-error");t.customData=e,n(t)},t.type="text/javascript",t.charset="UTF-8",(null!==(r=null===(r=document.getElementsByTagName("head"))||void 0===r?void 0:r[0])&&void 0!==r?r:document).appendChild(t)})}function Zy(e){return`__${e}${Math.floor(1e6*Math.random())}`}class e_{constructor(e){this.auth=e,this.counter=1e12,this._widgets=new Map}render(e,t){var n=this.counter;return this._widgets.set(n,new t_(e,this.auth.name,t||{})),this.counter++,n}reset(e){var t,n=e||1e12;null===(t=this._widgets.get(n))||void 0===t||t.delete(),this._widgets.delete(n)}getResponse(e){var t;return(null===(t=this._widgets.get(e||1e12))||void 0===t?void 0:t.getResponse())||""}async execute(e){var t;return null===(t=this._widgets.get(e||1e12))||void 0===t||t.execute(),""}}class t_{constructor(e,t,n){this.params=n,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=()=>{this.execute()};var r="string"==typeof e?document.getElementById(e):e;Rm(r,"argument-error",{appName:t}),this.container=r,this.isVisible="invisible"!==this.params.size,this.isVisible?this.execute():this.container.addEventListener("click",this.clickHandler)}getResponse(){return this.checkIfDeleted(),this.responseToken}delete(){this.checkIfDeleted(),this.deleted=!0,this.timerId&&(clearTimeout(this.timerId),this.timerId=null),this.container.removeEventListener("click",this.clickHandler)}execute(){this.checkIfDeleted(),this.timerId||(this.timerId=window.setTimeout(()=>{this.responseToken=function(e){const t=[],n="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let r=0;r<e;r++)t.push(n.charAt(Math.floor(Math.random()*n.length)));return t.join("")}(50);const{callback:e,"expired-callback":t}=this.params;if(e)try{e(this.responseToken)}catch(e){}this.timerId=window.setTimeout(()=>{if(this.timerId=null,this.responseToken=null,t)try{t()}catch(e){}this.isVisible&&this.execute()},6e4)},500))}checkIfDeleted(){if(this.deleted)throw new Error("reCAPTCHA mock was already deleted!")}}const n_=Zy("rcb"),r_=new Um(3e4,6e4);class i_{constructor(){this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!qy().grecaptcha}load(s,o=""){var e;return Rm((e=o).length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(e),s,"argument-error"),this.shouldResolveImmediately(o)?Promise.resolve(qy().grecaptcha):new Promise((t,n)=>{const i=qy().setTimeout(()=>{n(Sm(s,"network-request-failed"))},r_.get());qy()[n_]=()=>{qy().clearTimeout(i),delete qy()[n_];const e=qy().grecaptcha;if(e){const r=e.render;e.render=(e,t)=>{var n=r(e,t);return this.counter++,n},this.hostLanguage=o,t(e)}else n(Sm(s,"internal-error"))},Xy(`https://www.google.com/recaptcha/api.js??${Cd({onload:n_,render:"explicit",hl:o})}`).catch(()=>{clearTimeout(i),n(Sm(s,"internal-error"))})})}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){return!!qy().grecaptcha&&(e===this.hostLanguage||0<this.counter||this.librarySeparatelyLoaded)}}class s_{async load(e){return new e_(e)}clearedOneInstance(){}}const o_="recaptcha",a_={theme:"light",type:"image"};class c_{constructor(e,t=Object.assign({},a_),n){this.parameters=t,this.type=o_,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=Tv(n),this.isInvisible="invisible"===this.parameters.size,Rm("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment");var r="string"==typeof e?document.getElementById(e):e;Rm(r,this.auth,"argument-error"),this.container=r,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=new(this.auth.settings.appVerificationDisabledForTesting?s_:i_),this.validateStartingState()}async verify(){this.assertNotDestroyed();const e=await this.render(),r=this.getAssertedRecaptcha();var t=r.getResponse(e);return t||new Promise(t=>{const n=e=>{e&&(this.tokenChangeListeners.delete(n),t(e))};this.tokenChangeListeners.add(n),this.isInvisible&&r.execute(e)})}render(){try{this.assertNotDestroyed()}catch(e){return Promise.reject(e)}return this.renderPromise||(this.renderPromise=this.makeRenderPromise().catch(e=>{throw this.renderPromise=null,e}),this.renderPromise)}_reset(){this.assertNotDestroyed(),null!==this.widgetId&&this.getAssertedRecaptcha().reset(this.widgetId)}clear(){this.assertNotDestroyed(),this.destroyed=!0,this._recaptchaLoader.clearedOneInstance(),this.isInvisible||this.container.childNodes.forEach(e=>{this.container.removeChild(e)})}validateStartingState(){Rm(!this.parameters.sitekey,this.auth,"argument-error"),Rm(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),Rm("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment")}makeTokenCallback(n){return t=>{if(this.tokenChangeListeners.forEach(e=>e(t)),"function"==typeof n)n(t);else if("string"==typeof n){const e=qy()[n];"function"==typeof e&&e(t)}}}assertNotDestroyed(){Rm(!this.destroyed,this.auth,"internal-error")}async makeRenderPromise(){if(await this.init(),!this.widgetId){let e=this.container;var t;this.isInvisible||(t=document.createElement("div"),e.appendChild(t),e=t),this.widgetId=this.getAssertedRecaptcha().render(e,this.parameters)}return this.widgetId}async init(){Rm(Lm()&&!Vy(),this.auth,"internal-error"),await function(){let t=null;return new Promise(e=>{"complete"!==document.readyState?(t=()=>e(),window.addEventListener("load",t)):e()}).catch(e=>{throw t&&window.removeEventListener("load",t),e})}(),this.recaptcha=await this._recaptchaLoader.load(this.auth,this.auth.languageCode||void 0);var e=await((await Km(this.auth,"GET","/v1/recaptchaParams")).recaptchaSiteKey||"");Rm(e,this.auth,"internal-error"),this.parameters.sitekey=e}getAssertedRecaptcha(){return Rm(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}class l_{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){var t=Mv._fromVerification(this.verificationId,e);return this.onConfirmation(t)}}async function u_(t,n,r){var i,s,o,a,c,l,u=await r.verify();try{Rm("string"==typeof u,t,"argument-error"),Rm(r.type===o_,t,"argument-error");let e;if(e="string"==typeof n?{phoneNumber:n}:n,"session"in e){var h=e.session;if("phoneNumber"in e)return Rm("enroll"===h.type,t,"internal-error"),(c=t,l={idToken:h.credential,phoneEnrollmentInfo:{phoneNumber:e.phoneNumber,recaptchaToken:u}},await Km(c,"POST","/v2/accounts/mfaEnrollment:start",Wm(c,l))).phoneSessionInfo.sessionInfo;Rm("signin"===h.type,t,"internal-error");var d=(null===(i=e.multiFactorHint)||void 0===i?void 0:i.uid)||e.multiFactorUid;return Rm(d,t,"missing-multi-factor-info"),(a={mfaPendingCredential:h.credential,mfaEnrollmentId:d,phoneSignInInfo:{recaptchaToken:u}},await Km(t,"POST","/v2/accounts/mfaSignIn:start",Wm(t,a))).phoneResponseInfo.sessionInfo}var p=(s=t,o={phoneNumber:e.phoneNumber,recaptchaToken:u},await Km(s,"POST","/v1/accounts:sendVerificationCode",Wm(s,o)))["sessionInfo"];return p}finally{r._reset()}}class h_{constructor(e){this.providerId=h_.PROVIDER_ID,this.auth=Tv(e)}verifyPhoneNumber(e,t){return u_(this.auth,e,Kd(t))}static credential(e,t){return Mv._fromVerification(e,t)}static credentialFromResult(e){var t=e;return h_.credentialFromTaggedObject(t)}static credentialFromError(e){return h_.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{phoneNumber:t,temporaryProof:n}=e;return t&&n?Mv._fromTokenResponse(t,n):null}}function d_(e,t){return t?Om(t):(Rm(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}h_.PROVIDER_ID="phone",h_.PHONE_SIGN_IN_METHOD="phone";class p_ extends Cv{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return xv(e,this._buildIdpRequest())}_linkToIdToken(e,t){return xv(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return xv(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function f_(e){return ry(e.auth,new p_(e),e.bypassAuthState)}function g_(e){var{auth:t,user:n}=e;return Rm(n,t,"internal-error"),ny(n,new p_(e),e.bypassAuthState)}async function m_(e){var{auth:t,user:n}=e;return Rm(n,t,"internal-error"),ey(n,new p_(e),e.bypassAuthState)}class v_{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){var{urlResponse:t,sessionId:n,postBody:r,tenantId:i,error:s,type:o}=e;if(s)this.reject(s);else{r={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)(r))}catch(e){this.reject(e)}}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return f_;case"linkViaPopup":case"linkViaRedirect":return m_;case"reauthViaPopup":case"reauthViaRedirect":return g_;default:km(this.auth,"internal-error")}}resolve(e){xm(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){xm(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}const y_=new Um(2e3,1e4);class __ extends v_{constructor(e,t,n,r,i){super(e,t,r,i),this.provider=n,this.authWindow=null,this.pollId=null,__.currentPopupAction&&__.currentPopupAction.cancel(),__.currentPopupAction=this}async executeNotNull(){var e=await this.execute();return Rm(e,this.auth,"internal-error"),e}async onExecution(){xm(1===this.filter.length,"Popup operations only handle one event");var e=Uy();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(e=>{this.reject(e)}),this.resolver._isIframeWebStorageSupported(this.auth,e=>{e||this.reject(Sm(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(Sm(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,__.currentPopupAction=null}pollUserCancellation(){const t=()=>{var e;null!==(e=null===(e=this.authWindow)||void 0===e?void 0:e.window)&&void 0!==e&&e.closed?this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Sm(this.auth,"popup-closed-by-user"))},2e3):this.pollId=window.setTimeout(t,y_.get())};t()}}__.currentPopupAction=null;const w_="pendingRedirect",b_=new Map;class T_ extends v_{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let t=b_.get(this.auth._key());if(!t){try{const e=await async function(e,t){const n=k_(t),r=E_(e);if(!await r._isAvailable())return!1;var i="true"===await r._get(n);return await r._remove(n),i}(this.resolver,this.auth)?await super.execute():null;t=()=>Promise.resolve(e)}catch(e){t=()=>Promise.reject(e)}b_.set(this.auth._key(),t)}return this.bypassAuthState||b_.set(this.auth._key(),()=>Promise.resolve(null)),t()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);if("unknown"!==e.type){if(e.eventId){var t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}else this.resolve(null)}async onExecution(){}cleanUp(){}}async function I_(e,t){return E_(e)._set(k_(t),"true")}function E_(e){return Om(e._redirectPersistence)}function k_(e){return cv(w_,e.config.apiKey,e.name)}function S_(e,t,n){return async function(e,t,n){var r=Tv(e);Am(e,t,Uv);const i=d_(r,n);return await I_(i,r),i._openRedirect(r,t,"signInViaRedirect")}(e,t,n)}function C_(e,t,n){return async function(e,t,n){var r=Kd(e);Am(r.auth,t,Uv);const i=d_(r.auth,n);await I_(i,r.auth);var s=await R_(r);return i._openRedirect(r.auth,t,"reauthViaRedirect",s)}(e,t,n)}function A_(e,t,n){return async function(e,t,n){var r=Kd(e);Am(r.auth,t,Uv);const i=d_(r.auth,n);await ty(!1,r,t.providerId),await I_(i,r.auth);var s=await R_(r);return i._openRedirect(r.auth,t,"linkViaRedirect",s)}(e,t,n)}async function N_(e,t,n=!1){const r=Tv(e);var i=d_(r,t);const s=new T_(r,i,n),o=await s.execute();return o&&!n&&(delete o.user._redirectEventId,await r._persistUserIfCurrent(o.user),await r._setRedirectUser(null,t)),o}async function R_(e){var t=Uy(`${e.uid}:::`);return e._redirectEventId=t,await e.auth._setRedirectUser(e),await e.auth._persistUserIfCurrent(e),t}class P_{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(t){if(this.hasEventBeenHandled(t))return!1;let n=!1;return this.consumers.forEach(e=>{this.isEventForConsumer(t,e)&&(n=!0,this.sendToConsumer(t,e),this.saveEventToCache(t))}),this.hasHandledPotentialRedirect||!function(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return D_(e);default:return!1}}(t)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=t,n=!0)),n}sendToConsumer(e,t){var n;e.error&&!D_(e)?(n=(null===(n=e.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error",t.onError(Sm(this.auth,n))):t.onAuthEvent(e)}isEventForConsumer(e,t){var n=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}hasEventBeenHandled(e){return 6e5<=Date.now()-this.lastProcessedEventTime&&this.cachedEventUids.clear(),this.cachedEventUids.has(x_(e))}saveEventToCache(e){this.cachedEventUids.add(x_(e)),this.lastProcessedEventTime=Date.now()}}function x_(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function D_({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===(null==t?void 0:t.code)}async function O_(e,t={}){return Km(e,"GET","/v1/projects",t)}const M_=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,L_=/^https?/;async function F_(e){if(!e.config.emulator){var t=(await O_(e))["authorizedDomains"];for(const n of t)try{if(function(e){const t=Mm(),{protocol:n,hostname:r}=new URL(t);if(e.startsWith("chrome-extension://")){var 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(!L_.test(n))return!1;if(M_.test(e))return r===e;const s=e.replace(/\./g,"\\."),o=new RegExp("^(.+\\."+s+"|"+s+")$","i");return o.test(r)}(n))return}catch(e){}km(e,"unauthorized-domain")}}const U_=new Um(3e4,6e4);function j_(){const t=qy().___jsl;if(null!==t&&void 0!==t&&t.H)for(const n of Object.keys(t.H))if(t.H[n].r=t.H[n].r||[],t.H[n].L=t.H[n].L||[],t.H[n].r=[...t.H[n].L],t.CP)for(let e=0;e<t.CP.length;e++)t.CP[e]=null}let q_=null;function V_(e){var i;return q_=q_||(i=e,new Promise((e,t)=>{function n(){j_(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{j_(),t(Sm(i,"network-request-failed"))},timeout:U_.get()})}if(null!==(r=null===(r=qy().gapi)||void 0===r?void 0:r.iframes)&&void 0!==r&&r.Iframe)e(gapi.iframes.getContext());else{if(null===(r=qy().gapi)||void 0===r||!r.load){var r=Zy("iframefcb");return qy()[r]=()=>{gapi.load?n():t(Sm(i,"network-request-failed"))},Xy(`https://apis.google.com/js/api.js?onload=${r}`).catch(e=>t(e))}n()}}).catch(e=>{throw q_=null,e})),q_}const B_=new Um(5e3,15e3),W_="__/auth/iframe",K_="emulator/auth/iframe",$_={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},z_=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);async function H_(o){const e=await V_(o);var t=qy().gapi;return Rm(t,o,"internal-error"),e.open({where:document.body,url:function(e){var t=e.config;Rm(t.authDomain,e,"auth-domain-config-required");var n=t.emulator?jm(t,K_):`https://${e.config.authDomain}/${W_}`;const r={apiKey:t.apiKey,appName:e.name,v:gp};(t=z_.get(e.config.apiHost))&&(r.eid=t);const i=e._getFrameworks();return i.length&&(r.fw=i.join(",")),`${n}?${Cd(r).slice(1)}`}(o),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:$_,dontclear:!0},s=>new Promise(async(e,t)=>{await s.restyle({setHideOnLeave:!1});const n=Sm(o,"network-request-failed"),r=qy().setTimeout(()=>{t(n)},B_.get());function i(){qy().clearTimeout(r),e(s)}s.ping(i).then(i,()=>{t(n)})}))}const G_={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class Q_{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}function Y_(e,t,n,r=500,i=600){var s=Math.max((window.screen.availHeight-i)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString();let a="";const c=Object.assign(Object.assign({},G_),{width:r.toString(),height:i.toString(),top:s,left:o});s=sd().toLowerCase();n&&(a=pv(s)?"_blank":n),hv(s)&&(t=t||"http://localhost",c.scrollbars="yes");var l,o=Object.entries(c).reduce((e,[t,n])=>`${e}${t}=${n},`,"");if([n=sd()]=[s],yv(n)&&null!==(l=window.navigator)&&void 0!==l&&l.standalone&&"_self"!==a)return function(e,t){const n=document.createElement("a");n.href=e,n.target=t;const 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||"",a),new Q_(null);const u=window.open(t||"",a,o);Rm(u,e,"popup-blocked");try{u.focus()}catch(e){}return new Q_(u)}const J_="__/auth/handler",X_="emulator/auth/handler";function Z_(e,t,n,r,i,s){Rm(e.config.authDomain,e,"auth-domain-config-required"),Rm(e.config.apiKey,e,"invalid-api-key");const o={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:r,v:gp,eventId:i};if(t instanceof Uv){t.setDefaultLanguage(e.languageCode),o.providerId=t.providerId||"",Id(t.getCustomParameters())||(o.customParameters=JSON.stringify(t.getCustomParameters()));for(var[a,c]of Object.entries(s||{}))o[a]=c}if(t instanceof jv){const u=t.getScopes().filter(e=>""!==e);0<u.length&&(o.scopes=u.join(","))}e.tenantId&&(o.tid=e.tenantId);const l=o;for(const h of Object.keys(l))void 0===l[h]&&delete l[h];return`${e=[e["config"]][0],e.emulator?jm(e,X_):`https://${e.authDomain}/${J_}`}?${Cd(l).slice(1)}`}const ew="webStorageSupport";const tw=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Ly,this._completeRedirectFn=N_}async _openPopup(e,t,n,r){var i;return xm(null===(i=this.eventManagers[e._key()])||void 0===i?void 0:i.manager,"_initialize() not called before _openPopup()"),Y_(e,Z_(e,t,n,Mm(),r),Uy())}async _openRedirect(e,t,n,r){return await this._originValidation(e),r=Z_(e,t,n,Mm(),r),qy().location.href=r,new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:r,promise:n}=this.eventManagers[t];return r?Promise.resolve(r):(xm(n,"If manager is not set, promise should be"),n)}const n=this.initAndGetManager(e);return this.eventManagers[t]={promise:n},n.catch(()=>{delete this.eventManagers[t]}),n}async initAndGetManager(t){const e=await H_(t),n=new P_(t);return e.register("authEvent",e=>{return Rm(null==e?void 0:e.authEvent,t,"invalid-auth-event"),{status:n.onEvent(e.authEvent)?"ACK":"ERROR"}},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[t._key()]={manager:n},this.iframes[t._key()]=e,n}_isIframeWebStorageSupported(n,r){const e=this.iframes[n._key()];e.send(ew,{type:ew},e=>{var t=null===(t=null==e?void 0:e[0])||void 0===t?void 0:t[ew];void 0!==t&&r(!!t),km(n,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=F_(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return _v()||dv()||yv()}};class nw extends class{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 Pm("unexpected MultiFactorSessionType")}}}{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new nw(e)}_finalizeEnroll(e,t,n){return e=e,n={idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()},Km(e,"POST","/v2/accounts/mfaEnrollment:finalize",Wm(e,n))}_finalizeSignIn(e,t){return e=e,t={mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()},Km(e,"POST","/v2/accounts/mfaSignIn:finalize",Wm(e,t))}}class rw{constructor(){}static assertion(e){return nw._fromCredential(e)}}rw.FACTOR_ID="phone";var iw,sw="@firebase/auth";class ow{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(t){var e;this.assertAuthConfigured(),this.internalListeners.has(t)||(e=this.auth.onIdTokenChanged(e=>{t((null===e||void 0===e?void 0:e.stsTokenManager.accessToken)||null)}),this.internalListeners.set(t,e),this.updateProactiveRefresh())}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){Rm(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){0<this.internalListeners.size?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function aw(){return window}iw="Browser",hp(new $d("auth",(e,{options:n})=>{var t=e.getProvider("app").getImmediate();const{apiKey:r,authDomain:i}=t.options;return(e=>{Rm(r&&!r.includes(":"),"invalid-api-key",{appName:e.name}),Rm(!(null!==i&&void 0!==i&&i.includes(":")),"argument-error",{appName:e.name});var t={apiKey:r,authDomain:i,clientPlatform:iw,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:wv(iw)},t=new bv(e,t);return function(e,t){const n=(null==t?void 0:t.persistence)||[];var r=(Array.isArray(n)?n:[n]).map(Om);null!=t&&t.errorMap&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,null==t?void 0:t.popupRedirectResolver)}(t,n),t})(t)},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{const r=e.getProvider("auth-internal");r.initialize()})),hp(new $d("auth-internal",e=>{var t=Tv(e.getProvider("auth").getImmediate());return e=t,new ow(e)},"PRIVATE").setInstantiationMode("EXPLICIT")),_p(sw,"0.19.5",function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";default:return}}(iw)),_p(sw,"0.19.5","esm2017");async function cw(e,t,n){var r=aw()["BuildInfo"];xm(t.sessionId,"AuthEvent did not contain a session ID");var i=await async function(e){const t=function(e){if(xm(/[0-9a-zA-Z]+/.test(e),"Can only convert alpha-numeric strings"),"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);const t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}(e),n=await crypto.subtle.digest("SHA-256",t),r=Array.from(new Uint8Array(n));return r.map(e=>e.toString(16).padStart(2,"0")).join("")}(t.sessionId);const s={};return yv()?s.ibi=r.packageName:gv()?s.apn=r.packageName:km(e,"operation-not-supported-in-this-environment"),r.displayName&&(s.appDisplayName=r.displayName),s.sessionId=i,Z_(e,n,t.type,void 0,null!==(i=t.eventId)&&void 0!==i?i:void 0,s)}function lw(r){const i=aw()["cordova"];return new Promise(n=>{i.plugins.browsertab.isAvailable(e=>{let t=null;e?i.plugins.browsertab.openUrl(r):t=i.InAppBrowser.open(r,(e=sd(),/(iPad|iPhone|iPod).*OS 7_\d/i.test(e)||/(iPad|iPhone|iPod).*OS 8_\d/i.test(e)?"_blank":"_system"),"location=yes"),n(t)})})}const uw=20;class hw extends P_{constructor(){super(...arguments),this.passiveListeners=new Set,this.initPromise=new Promise(e=>{this.resolveInialized=e})}addPassiveListener(e){this.passiveListeners.add(e)}removePassiveListener(e){this.passiveListeners.delete(e)}resetRedirect(){this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1}onEvent(t){return this.resolveInialized(),this.passiveListeners.forEach(e=>e(t)),super.onEvent(t)}async initialized(){await this.initPromise}}function dw(e,t,n=null){return{type:t,eventId:n,urlResponse:null,sessionId:function(){const e=[],t="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let r=0;r<uw;r++){var n=Math.floor(Math.random()*t.length);e.push(t.charAt(n))}return e.join("")}(),postBody:null,tenantId:e.tenantId,error:Sm(e,"no-auth-event")}}async function pw(e){var t=await gw()._get(mw(e));return t&&await gw()._remove(mw(e)),t}function fw(e,t){var n,r,i;const s=(n=vw(t=t),o=n.link?decodeURIComponent(n.link):void 0,r=vw(o).link,i=n.deep_link_id?decodeURIComponent(n.deep_link_id):void 0,(n=vw(i).link)||i||r||o||t);if(s.includes("/__/auth/callback")){var o=vw(s),o=o.firebaseError?function(e){try{return JSON.parse(e)}catch(e){return null}}(decodeURIComponent(o.firebaseError)):null,o=null===(o=null===(o=null==o?void 0:o.code)||void 0===o?void 0:o.split("auth/"))||void 0===o?void 0:o[1],o=o?Sm(o):null;return o?{type:e.type,eventId:e.eventId,tenantId:e.tenantId,error:o,urlResponse:null,sessionId:null,postBody:null}:{type:e.type,eventId:e.eventId,tenantId:e.tenantId,sessionId:e.sessionId,urlResponse:s,postBody:null}}return null}function gw(){return Om(Oy)}function mw(e){return cv("authEvent",e.config.apiKey,e.name)}function vw(e){if(null==e||!e.includes("?"))return{};const[,...t]=e.split("?");return Ad(t.join("?"))}const yw=class{constructor(){this._redirectPersistence=Ly,this._shouldInitProactively=!0,this.eventManagers=new Map,this.originValidationPromises={},this._completeRedirectFn=N_}async _initialize(e){var t=e._key();let n=this.eventManagers.get(t);return n||(n=new hw(e),this.eventManagers.set(t,n),this.attachCallbackListeners(e,n)),n}_openPopup(e){km(e,"operation-not-supported-in-this-environment")}async _openRedirect(e,t,n,r){var i,s;i=e,a=aw(),Rm("function"==typeof(null===(s=null==a?void 0:a.universalLinks)||void 0===s?void 0:s.subscribe),i,"invalid-cordova-configuration",{missingPlugin:"cordova-universal-links-plugin-fix"}),Rm(void 0!==(null===(s=null==a?void 0:a.BuildInfo)||void 0===s?void 0:s.packageName),i,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-buildInfo"}),Rm("function"==typeof(null===(s=null===(s=null===(s=null==a?void 0:a.cordova)||void 0===s?void 0:s.plugins)||void 0===s?void 0:s.browsertab)||void 0===s?void 0:s.openUrl),i,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-browsertab"}),Rm("function"==typeof(null===(s=null===(s=null===(s=null==a?void 0:a.cordova)||void 0===s?void 0:s.plugins)||void 0===s?void 0:s.browsertab)||void 0===s?void 0:s.isAvailable),i,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-browsertab"}),Rm("function"==typeof(null===(a=null===(a=null==a?void 0:a.cordova)||void 0===a?void 0:a.InAppBrowser)||void 0===a?void 0:a.open),i,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-inappbrowser"});const o=await this._initialize(e);await o.initialized(),o.resetRedirect(),b_.clear(),await this._originValidation(e);var a=dw(e,n,r);n=e,r=a,await gw()._set(mw(n),r);a=await lw(await cw(e,a,t));return async function(o,a,c){const l=aw()["cordova"];let u=()=>{};try{await new Promise((n,e)=>{let t=null;function r(){var e;n();const t=null===(e=l.plugins.browsertab)||void 0===e?void 0:e.close;"function"==typeof t&&t(),"function"==typeof(null==c?void 0:c.close)&&c.close()}function i(){t=t||window.setTimeout(()=>{e(Sm(o,"redirect-cancelled-by-user"))},2e3)}function s(){"visible"===(null===document||void 0===document?void 0:document.visibilityState)&&i()}a.addPassiveListener(r),document.addEventListener("resume",i,!1),gv()&&document.addEventListener("visibilitychange",s,!1),u=()=>{a.removePassiveListener(r),document.removeEventListener("resume",i,!1),document.removeEventListener("visibilitychange",s,!1),t&&window.clearTimeout(t)}})}finally{u()}}(e,o,a)}_isIframeWebStorageSupported(e,t){throw new Error("Method not implemented.")}_originValidation(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=async function(e){var t=aw()["BuildInfo"];const n={};yv()?n.iosBundleId=t.packageName:gv()?n.androidPackageName=t.packageName:km(e,"operation-not-supported-in-this-environment"),await O_(e,n)}(e)),this.originValidationPromises[t]}attachCallbackListeners(r,i){const{universalLinks:e,handleOpenURL:t,BuildInfo:n}=aw(),s=setTimeout(async()=>{await pw(r),i.onEvent(_w())},500),o=async e=>{clearTimeout(s);var t=await pw(r);let n=null;t&&null!=e&&e.url&&(n=fw(t,e.url)),i.onEvent(n||_w())};void 0!==e&&"function"==typeof e.subscribe&&e.subscribe(null,o);const a=t,c=`${n.packageName.toLowerCase()}://`;aw().handleOpenURL=async e=>{if(e.toLowerCase().startsWith(c)&&o({url:e}),"function"==typeof a)try{a(e)}catch(e){console.error(e)}}}};function _w(){return{type:"unknown",eventId:null,sessionId:null,urlResponse:null,postBody:null,tenantId:null,error:Sm("no-auth-event")}}var ww;function bw(){var e;return(null===(e=null===self||void 0===self?void 0:self.location)||void 0===e?void 0:e.protocol)||null}function Tw(e=sd()){return!("file:"!==bw()&&"ionic:"!==bw()||!e.toLowerCase().match(/iphone|ipad|ipod|android/))}function Iw(e=sd()){return ud()&&11===(null===document||void 0===document?void 0:document.documentMode)||([e=sd()]=[e],/Edge\/\d+/.test(e))}function Ew(){try{const t=self.localStorage;var e=Uy();if(t)return t.setItem(e,"1"),t.removeItem(e),!Iw()||dd()}catch(e){return kw()&&dd()}return!1}function kw(){return"undefined"!=typeof global&&"WorkerGlobalScope"in global&&"importScripts"in global}function Sw(){return("http:"===bw()||"https:"===bw()||cd()||Tw())&&!(ld()||ad())&&Ew()&&!kw()}function Cw(){return Tw()&&"undefined"!=typeof document}const Aw={LOCAL:"local",NONE:"none",SESSION:"session"},Nw=Rm,Rw="persistence";async function Pw(e){await e._initializationPromise;const t=xw();var n=cv(Rw,e.config.apiKey,e.name);null!==t&&void 0!==t&&t.sessionStorage&&t.sessionStorage.setItem(n,e._getPersistence())}function xw(){return"undefined"!=typeof window?window:null}const Dw=Rm;class Ow{constructor(){this.browserResolver=Om(tw),this.cordovaResolver=Om(yw),this.underlyingResolver=null,this._redirectPersistence=Ly,this._completeRedirectFn=N_}async _initialize(e){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._initialize(e)}async _openPopup(e,t,n,r){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openPopup(e,t,n,r)}async _openRedirect(e,t,n,r){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openRedirect(e,t,n,r)}_isIframeWebStorageSupported(e,t){this.assertedUnderlyingResolver._isIframeWebStorageSupported(e,t)}_originValidation(e){return this.assertedUnderlyingResolver._originValidation(e)}get _shouldInitProactively(){return Cw()||this.browserResolver._shouldInitProactively}get assertedUnderlyingResolver(){return Dw(this.underlyingResolver,"internal-error"),this.underlyingResolver}async selectUnderlyingResolver(){var e;this.underlyingResolver||(e=await(!!Cw()&&new Promise(e=>{const t=setTimeout(()=>{e(!1)},1e3);document.addEventListener("deviceready",()=>{clearTimeout(t),e(!0)})})),this.underlyingResolver=e?this.cordovaResolver:this.browserResolver)}}function Mw(e){return e.unwrap()}function Lw(e,t){var n,r,i,s=null===(r=t.customData)||void 0===r?void 0:r._tokenResponse;if("auth/multi-factor-auth-required"===t.code){const a=t;a.resolver=new qw(e,(n=t,i=Kd(e),Rm((o=n).customData.operationType,i,"argument-error"),Rm(null===(r=o.customData._serverResponse)||void 0===r?void 0:r.mfaPendingCredential,i,"argument-error"),Ay._fromError(i,o)))}else if(s){var o=Fw(t);const c=t;o&&(c.credential=o,c.tenantId=s.tenantId||void 0,c.email=s.email||void 0,c.phoneNumber=s.phoneNumber||void 0)}}function Fw(e){var t=(e instanceof gd?e.customData:e)["_tokenResponse"];if(!t)return null;if(!(e instanceof gd)&&"temporaryProof"in t&&"phoneNumber"in t)return h_.credentialFromResult(e);const n=t.providerId;if(!n||n===vm.PASSWORD)return null;let r;switch(n){case vm.GOOGLE:r=Bv;break;case vm.FACEBOOK:r=Vv;break;case vm.GITHUB:r=Wv;break;case vm.TWITTER:r=zv;break;default:var{oauthIdToken:i,oauthAccessToken:s,oauthTokenSecret:o,pendingToken:a,nonce:c}=t;return s||o||i||a?a?n.startsWith("saml.")?Kv._create(n,a):Dv._fromParams({providerId:n,signInMethod:n,pendingToken:a,idToken:i,accessToken:s}):new qv(n).credential({idToken:i,accessToken:s,rawNonce:c}):null}return e instanceof gd?r.credentialFromError(e):r.credentialFromResult(e)}function Uw(t,e){return e.catch(e=>{throw e instanceof gd&&Lw(t,e),e}).then(e=>{var t=e.operationType,n=e.user;return{operationType:t,credential:Fw(e),additionalUserInfo:Sy(e),user:Vw.getOrCreate(n)}})}async function jw(t,e){const n=await e;return{verificationId:n.verificationId,confirm:e=>Uw(t,n.confirm(e))}}class qw{constructor(e,t){this.resolver=t,this.auth=e.wrapped()}get session(){return this.resolver.session}get hints(){return this.resolver.hints}resolveSignIn(e){return Uw(Mw(this.auth),this.resolver.resolveSignIn(e))}}class Vw{constructor(e){var t;this._delegate=e,this.multiFactor=(t=Kd(e),Ry.has(t)||Ry.set(t,Ny._fromUser(t)),Ry.get(t))}static getOrCreate(e){return Vw.USER_MAP.has(e)||Vw.USER_MAP.set(e,new Vw(e)),Vw.USER_MAP.get(e)}delete(){return this._delegate.delete()}reload(){return this._delegate.reload()}toJSON(){return this._delegate.toJSON()}getIdTokenResult(e){return this._delegate.getIdTokenResult(e)}getIdToken(e){return this._delegate.getIdToken(e)}linkAndRetrieveDataWithCredential(e){return this.linkWithCredential(e)}async linkWithCredential(e){return Uw(this.auth,sy(this._delegate,e))}async linkWithPhoneNumber(e,t){return jw(this.auth,async function(e,t,n){const r=Kd(e);await ty(!1,r,"phone");var i=await u_(r.auth,t,Kd(n));return new l_(i,e=>sy(r,e))}(this._delegate,e,t))}async linkWithPopup(e){return Uw(this.auth,async function(e,t,n){var r=Kd(e);Am(r.auth,t,Uv);var i=d_(r.auth,n);const s=new __(r.auth,"linkViaPopup",t,i,r);return s.executeNotNull()}(this._delegate,e,Ow))}async linkWithRedirect(e){return await Pw(Tv(this.auth)),A_(this._delegate,e,Ow)}reauthenticateAndRetrieveDataWithCredential(e){return this.reauthenticateWithCredential(e)}async reauthenticateWithCredential(e){return Uw(this.auth,oy(this._delegate,e))}reauthenticateWithPhoneNumber(e,t){return jw(this.auth,async function(e,t,n){const r=Kd(e);var i=await u_(r.auth,t,Kd(n));return new l_(i,e=>oy(r,e))}(this._delegate,e,t))}reauthenticateWithPopup(e){return Uw(this.auth,async function(e,t,n){var r=Kd(e);Am(r.auth,t,Uv);var i=d_(r.auth,n);const s=new __(r.auth,"reauthViaPopup",t,i,r);return s.executeNotNull()}(this._delegate,e,Ow))}async reauthenticateWithRedirect(e){return await Pw(Tv(this.auth)),C_(this._delegate,e,Ow)}sendEmailVerification(e){return my(this._delegate,e)}async unlink(e){return await Zv(this._delegate,e),this}updateEmail(e){return _y(Kd(this._delegate),e,null)}updatePassword(e){return _y(Kd(this._delegate),null,e)}updatePhoneNumber(e){return async function(e,t){await ey(Kd(e),t)}(this._delegate,e)}updateProfile(e){return yy(this._delegate,e)}verifyBeforeUpdateEmail(e,t){return vy(this._delegate,e,t)}get emailVerified(){return this._delegate.emailVerified}get isAnonymous(){return this._delegate.isAnonymous}get metadata(){return this._delegate.metadata}get phoneNumber(){return this._delegate.phoneNumber}get providerData(){return this._delegate.providerData}get refreshToken(){return this._delegate.refreshToken}get tenantId(){return this._delegate.tenantId}get displayName(){return this._delegate.displayName}get email(){return this._delegate.email}get photoURL(){return this._delegate.photoURL}get providerId(){return this._delegate.providerId}get uid(){return this._delegate.uid}get auth(){return this._delegate.auth}}Vw.USER_MAP=new WeakMap;const Bw=Rm;class Ww{constructor(e,t){if(this.app=e,t.isInitialized())return this._delegate=t.getImmediate(),void this.linkUnderlyingAuth();var n=e.options["apiKey"];Bw(n,"invalid-api-key",{appName:e.name}),Bw(n,"invalid-api-key",{appName:e.name});var r="undefined"!=typeof window?Ow:void 0;this._delegate=t.initialize({options:{persistence:function(e,t){const n=function(e,t){const n=xw();if(null===n||void 0===n||!n.sessionStorage)return[];var r=cv(Rw,e,t);switch(n.sessionStorage.getItem(r)){case Aw.NONE:return[av];case Aw.LOCAL:return[Jy,Ly];case Aw.SESSION:return[Ly];default:return[]}}(e,t);"undefined"==typeof self||n.includes(Jy)||n.push(Jy);if("undefined"!=typeof window)for(const r of[Oy,Ly])n.includes(r)||n.push(r);n.includes(av)||n.push(av);return n}(n,e.name),popupRedirectResolver:r}}),this._delegate._updateErrorMap(wm),this.linkUnderlyingAuth()}get emulatorConfig(){return this._delegate.emulatorConfig}get currentUser(){return this._delegate.currentUser?Vw.getOrCreate(this._delegate.currentUser):null}get languageCode(){return this._delegate.languageCode}set languageCode(e){this._delegate.languageCode=e}get settings(){return this._delegate.settings}get tenantId(){return this._delegate.tenantId}set tenantId(e){this._delegate.tenantId=e}useDeviceLanguage(){this._delegate.useDeviceLanguage()}signOut(){return this._delegate.signOut()}useEmulator(e,t){Ev(this._delegate,e,t)}applyActionCode(e){return dy(this._delegate,e)}checkActionCode(e){return py(this._delegate,e)}confirmPasswordReset(e,t){return async function(e,t,n){await Av(Kd(e),{oobCode:t,newPassword:n})}(this._delegate,e,t)}async createUserWithEmailAndPassword(e,t){return Uw(this._delegate,async function(e,t,n){const r=Tv(e);var i=await Hv(r,{returnSecureToken:!0,email:t,password:n}),i=await Gv._fromIdTokenResponse(r,"signIn",i);return await r._updateCurrentUser(i.user),i}(this._delegate,e,t))}fetchProvidersForEmail(e){return this.fetchSignInMethodsForEmail(e)}fetchSignInMethodsForEmail(e){return gy(this._delegate,e)}isSignInWithEmailLink(e){return this._delegate,e=e,"EMAIL_SIGNIN"===(null==(t=Lv.parseLink(e))?void 0:t.operation);var t}async getRedirectResult(){Bw(Sw(),this._delegate,"operation-not-supported-in-this-environment");var e,t,n=(e=this._delegate,t=Ow,await Tv(e)._initializationPromise,await N_(e,t,!1));return n?Uw(this._delegate,Promise.resolve(n)):{credential:null,user:null}}addFrameworkForLogging(e){Tv(this._delegate)._logFramework(e)}onAuthStateChanged(e,t,n){var{next:r,error:i,complete:s}=Kw(e,t,n);return this._delegate.onAuthStateChanged(r,i,s)}onIdTokenChanged(e,t,n){var{next:r,error:i,complete:s}=Kw(e,t,n);return this._delegate.onIdTokenChanged(r,i,s)}sendSignInLinkToEmail(e,t){return fy(this._delegate,e,t)}sendPasswordResetEmail(e,t){return hy(this._delegate,e,t||void 0)}async setPersistence(e){var t,n;t=this._delegate,n=e,Nw(Object.values(Aw).includes(n),t,"invalid-persistence-type"),ld()?Nw(n!==Aw.SESSION,t,"unsupported-persistence-type"):ad()?Nw(n===Aw.NONE,t,"unsupported-persistence-type"):kw()?Nw(n===Aw.NONE||n===Aw.LOCAL&&dd(),t,"unsupported-persistence-type"):Nw(n===Aw.NONE||Ew(),t,"unsupported-persistence-type");let r;switch(e){case Aw.SESSION:r=Ly;break;case Aw.LOCAL:var i=await Om(Jy)._isAvailable();r=i?Jy:Oy;break;case Aw.NONE:r=av;break;default:return km("argument-error",{appName:this._delegate.name})}return this._delegate.setPersistence(r)}signInAndRetrieveDataWithCredential(e){return this.signInWithCredential(e)}signInAnonymously(){return Uw(this._delegate,async function(e){const t=Tv(e);if(await t._initializationPromise,null!==(n=t.currentUser)&&void 0!==n&&n.isAnonymous)return new Gv({user:t.currentUser,providerId:null,operationType:"signIn"});var n=await Hv(t,{returnSecureToken:!0}),n=await Gv._fromIdTokenResponse(t,"signIn",n,!0);return await t._updateCurrentUser(n.user),n}(this._delegate))}signInWithCredential(e){return Uw(this._delegate,iy(this._delegate,e))}signInWithCustomToken(e){return Uw(this._delegate,ay(this._delegate,e))}signInWithEmailAndPassword(e,t){return Uw(this._delegate,(n=this._delegate,e=e,t=t,iy(Kd(n),Fv.credential(e,t))));var n}signInWithEmailLink(e,t){return Uw(this._delegate,async function(e,t,n){var r=Kd(e),i=Fv.credentialWithLink(t,n||Mm());return Rm(i._tenantId===(r.tenantId||null),r,"tenant-id-mismatch"),iy(r,i)}(this._delegate,e,t))}signInWithPhoneNumber(e,t){return jw(this._delegate,async function(e,t,n){const r=Tv(e);var i=await u_(r,t,Kd(n));return new l_(i,e=>iy(r,e))}(this._delegate,e,t))}async signInWithPopup(e){return Bw(Sw(),this._delegate,"operation-not-supported-in-this-environment"),Uw(this._delegate,async function(e,t,n){var r=Tv(e);Am(e,t,Uv);var i=d_(r,n);const s=new __(r,"signInViaPopup",t,i);return s.executeNotNull()}(this._delegate,e,Ow))}async signInWithRedirect(e){return Bw(Sw(),this._delegate,"operation-not-supported-in-this-environment"),await Pw(this._delegate),S_(this._delegate,e,Ow)}updateCurrentUser(e){return this._delegate.updateCurrentUser(e)}verifyPasswordResetCode(e){return async function(e,t){var n=(await py(Kd(e),t))["data"];return n.email}(this._delegate,e)}unwrap(){return this._delegate}_delete(){return this._delegate._delete()}linkUnderlyingAuth(){this._delegate.wrapped=()=>this}}function Kw(e,t,n){let r=e;"function"!=typeof e&&({next:r,error:t,complete:n}=e);const i=r;return{next:e=>i(e&&Vw.getOrCreate(e)),error:t,complete:n}}Ww.Persistence=Aw;class $w{constructor(){this.providerId="phone",this._delegate=new h_(Mw(Cp.auth()))}static credential(e,t){return h_.credential(e,t)}verifyPhoneNumber(e,t){return this._delegate.verifyPhoneNumber(e,t)}unwrap(){return this._delegate}}$w.PHONE_SIGN_IN_METHOD=h_.PHONE_SIGN_IN_METHOD,$w.PROVIDER_ID=h_.PROVIDER_ID;const zw=Rm;class Hw{constructor(e,t,n=Cp.app()){var r;zw(null===(r=n.options)||void 0===r?void 0:r.apiKey,"invalid-api-key",{appName:n.name}),this._delegate=new c_(e,t,n.auth()),this.type=this._delegate.type}clear(){this._delegate.clear()}render(){return this._delegate.render()}verify(){return this._delegate.verify()}}(ww=Cp).INTERNAL.registerComponent(new $d("auth-compat",e=>{var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("auth");return new Ww(t,n)},"PUBLIC").setServiceProps({ActionCodeInfo:{Operation:{EMAIL_SIGNIN:ym.EMAIL_SIGNIN,PASSWORD_RESET:ym.PASSWORD_RESET,RECOVER_EMAIL:ym.RECOVER_EMAIL,REVERT_SECOND_FACTOR_ADDITION:ym.REVERT_SECOND_FACTOR_ADDITION,VERIFY_AND_CHANGE_EMAIL:ym.VERIFY_AND_CHANGE_EMAIL,VERIFY_EMAIL:ym.VERIFY_EMAIL}},EmailAuthProvider:Fv,FacebookAuthProvider:Vv,GithubAuthProvider:Wv,GoogleAuthProvider:Bv,OAuthProvider:qv,SAMLAuthProvider:$v,PhoneAuthProvider:$w,PhoneMultiFactorGenerator:rw,RecaptchaVerifier:Hw,TwitterAuthProvider:zv,Auth:Ww,AuthCredential:Cv,Error:gd}).setInstantiationMode("LAZY").setMultipleInstances(!1)),ww.registerVersion("@firebase/auth-compat","0.2.5");const Gw="@firebase/database";let Qw="";function Yw(e){Qw=e}class Jw{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){null==t?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),_d(t))}get(e){var t=this.domStorage_.getItem(this.prefixedName_(e));return null==t?null:yd(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}class Xw{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){null==t?delete this.cache_[e]:this.cache_[e]=t}get(e){return bd(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}var Zw,eb,tb,nb,rb,ib,yt=function(e){try{if("undefined"!=typeof window&&void 0!==window[e]){const t=window[e];return t.setItem("firebase:sentinel","cache"),t.removeItem("firebase:sentinel"),new Jw(t)}}catch(e){}return new Xw};function sb(e){var t=function(t){const n=[];let r=0;for(let o=0;o<t.length;o++){let e=t.charCodeAt(o);var i,s;55296<=e&&e<=56319&&(i=e-55296,o++,Jh(o<t.length,"Surrogate pair missing trail surrogate."),s=t.charCodeAt(o)-56320,e=65536+(i<<10)+s),e<128?n[r++]=e:(e<2048?n[r++]=e>>6|192:(e<65536?n[r++]=e>>12|224:(n[r++]=e>>18|240,n[r++]=e>>12&63|128),n[r++]=e>>6&63|128),n[r++]=63&e|128)}return n}(e);const n=new Rd;return n.update(t),t=n.digest(),Zh.encodeByteArray(t)}const ob=yt("localStorage"),ab=yt("sessionStorage"),cb=new ep("@firebase/database"),lb=function(){let e=1;return function(){return e++}}(),ub=function(...e){let t="";for(let r=0;r<e.length;r++){var n=e[r];Array.isArray(n)||n&&"object"==typeof n&&"number"==typeof n.length?t+=ub.apply(null,n):t+="object"==typeof n?_d(n):n,t+=" "}return t};let hb=null,db=!0;function pb(t){return function(...e){wb(t,...e)}}function fb(...e){var t="FIREBASE INTERNAL ERROR: "+ub(...e);cb.error(t)}function gb(e,t){return e===t?0:e<t?-1:1}function mb(e,t){if(t&&e in t)return t[e];throw new Error("Missing required key ("+e+") in object: "+_d(t))}function vb(e){if("object"!=typeof e||null===e)return _d(e);const t=[];for(const r in e)t.push(r);t.sort();let n="{";for(let i=0;i<t.length;i++)0!==i&&(n+=","),n+=_d(t[i]),n+=":",n+=vb(e[t[i]]);return n+="}",n}function yb(e,t){var n=e.length;if(n<=t)return[e];const r=[];for(let i=0;i<n;i+=t)i+t>n?r.push(e.substring(i,n)):r.push(e.substring(i,i+t));return r}const _b=function(e,t){Jh(!t||!0===e||!1===e,"Can't turn on custom loggers persistently."),!0===e?(cb.logLevel=Kh.VERBOSE,hb=cb.log.bind(cb),t&&ab.set("logging_enabled",!0)):"function"==typeof e?hb=e:(hb=null,ab.remove("logging_enabled"))},wb=function(...e){var t;!0===db&&(db=!1,null===hb&&!0===ab.get("logging_enabled")&&_b(!0)),hb&&(t=ub.apply(null,e),hb(t))},bb=function(...e){var t=`FIREBASE FATAL ERROR: ${ub(...e)}`;throw cb.error(t),new Error(t)},Tb=function(...e){var t="FIREBASE WARNING: "+ub(...e);cb.warn(t)},Ib=function(){"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&Tb("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},Eb=function(e){return"number"==typeof e&&(e!=e||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY)},kb="[MIN_NAME]",Sb="[MAX_NAME]",Cb=function(e,t){if(e===t)return 0;if(e===kb||t===Sb)return-1;if(t===kb||e===Sb)return 1;var n=Ob(e),r=Ob(t);return null!==n?null!==r?n-r==0?e.length-t.length:n-r:-1:null===r&&e<t?-1:1};function Ab(e,t){for(const n in e)e.hasOwnProperty(n)&&t(n,e[n])}function Nb(e){Jh(!Eb(e),"Invalid JSON number");let t,n,r,i,s;0===e?(n=0,r=0,t=1/e==-1/0?1:0):(t=e<0,e=Math.abs(e),r=e>=Math.pow(2,-1022)?(i=Math.min(Math.floor(Math.log(e)/Math.LN2),1023),n=i+1023,Math.round(e*Math.pow(2,52-i)-Math.pow(2,52))):(n=0,Math.round(e/Math.pow(2,-1074))));const o=[];for(s=52;s;--s)o.push(r%2?1:0),r=Math.floor(r/2);for(s=11;s;--s)o.push(n%2?1:0),n=Math.floor(n/2);o.push(t?1:0),o.reverse();const a=o.join("");let c="";for(s=0;s<64;s+=8){let e=parseInt(a.substr(s,8),2).toString(16);1===e.length&&(e="0"+e),c+=e}return c.toLowerCase()}function Rb(e,t){const n=setTimeout(e,t);return"object"==typeof n&&n.unref&&n.unref(),n}const Pb=new RegExp("^-?(0*)\\d{1,10}$"),xb=-2147483648,Db=2147483647,Ob=function(e){if(Pb.test(e)){var t=Number(e);if(t>=xb&&t<=Db)return t}return null},Mb=function(e){try{e()}catch(t){setTimeout(()=>{var e=t.stack||"";throw Tb("Exception was thrown by user callback.",e),t},Math.floor(0))}};class Lb{constructor(e,t){this.appName_=e,this.appCheckProvider=t,this.appCheck=null==t?void 0:t.getImmediate({optional:!0}),this.appCheck||null!=t&&t.get().then(e=>this.appCheck=e)}getToken(n){return this.appCheck?this.appCheck.getToken(n):new Promise((e,t)=>{setTimeout(()=>{this.appCheck?this.getToken(n).then(e,t):e(null)},0)})}addTokenChangeListener(t){var e;null!==(e=this.appCheckProvider)&&void 0!==e&&e.get().then(e=>e.addTokenListener(t))}notifyForInvalidToken(){Tb(`Provided AppCheck credentials for the app named "${this.appName_}" `+"are invalid. This usually indicates your app was not initialized correctly.")}}class Fb{constructor(e,t,n){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=n,this.auth_=null,this.auth_=n.getImmediate({optional:!0}),this.auth_||n.onInit(e=>this.auth_=e)}getToken(n){return this.auth_?this.auth_.getToken(n).catch(e=>e&&"auth/token-not-initialized"===e.code?(wb("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(e)):new Promise((e,t)=>{setTimeout(()=>{this.auth_?this.getToken(n).then(e,t):e(null)},0)})}addTokenChangeListener(t){this.auth_?this.auth_.addAuthTokenListener(t):this.authProvider_.get().then(e=>e.addAuthTokenListener(t))}removeTokenChangeListener(t){this.authProvider_.get().then(e=>e.removeAuthTokenListener(t))}notifyForInvalidToken(){let e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',Tb(e)}}class Ub{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}Ub.OWNER="owner";const jb=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,qb="websocket",Vb="long_polling";class Bb{constructor(e,t,n,r,i=!1,s="",o=!1){this.secure=t,this.namespace=n,this.webSocketOnly=r,this.nodeAdmin=i,this.persistenceKey=s,this.includeNamespaceInQueryParams=o,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=ob.get("host:"+e)||this._host}isCacheableHost(){return"s-"===this.internalHost.substr(0,2)}isCustomHost(){return"firebaseio.com"!==this._domain&&"firebaseio-demo.com"!==this._domain}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&ob.set("host:"+this._host,this.internalHost))}toString(){let e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e}toURLString(){var e=this.secure?"https://":"http://",t=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${e}${this.host}/${t}`}}function Wb(e,t,n){Jh("string"==typeof t,"typeof type must == string"),Jh("object"==typeof n,"typeof params must == object");let r;if(t===qb)r=(e.secure?"wss://":"ws://")+e.internalHost+"/.ws?";else{if(t!==Vb)throw new Error("Unknown connection type: "+t);r=(e.secure?"https://":"http://")+e.internalHost+"/.lp?"}((t=e).host!==t.internalHost||t.isCustomHost()||t.includeNamespaceInQueryParams)&&(n.ns=e.namespace);const i=[];return Ab(n,(e,t)=>{i.push(e+"="+t)}),r+i.join("&")}class Kb{constructor(){this.counters_={}}incrementCounter(e,t=1){bd(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return nd(void 0,this.counters_)}}const $b={},zb={};function Hb(e){var t=e.toString();return $b[t]||($b[t]=new Kb),$b[t]}class Gb{constructor(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(e,t){for(this.pendingResponses[e]=t;this.pendingResponses[this.currentResponseNum];){const n=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let e=0;e<n.length;++e)n[e]&&Mb(()=>{this.onMessage_(n[e])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}class Qb{constructor(e,t,n,r,i,s,o){this.connId=e,this.repoInfo=t,this.applicationId=n,this.appCheckToken=r,this.authToken=i,this.transportSessionId=s,this.lastSessionId=o,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=pb(e),this.stats_=Hb(t),this.urlFn=e=>(this.appCheckToken&&(e.ac=this.appCheckToken),Wb(t,Vb,e))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new Gb(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(3e4)),function(t){if("complete"===document.readyState)t();else{let e=!1;const n=function(){document.body?e||(e=!0,t()):setTimeout(n,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{"complete"===document.readyState&&n()}),window.attachEvent("onload",n))}}(()=>{if(!this.isClosed_){this.scriptTagHolder=new Yb((...e)=>{var[t,n,r]=e;if(this.incrementIncomingBytes_(e),this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,"start"===t)this.id=n,this.password=r;else{if("close"!==t)throw new Error("Unrecognized command received: "+t);n?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(n,()=>{this.onClosed_()})):this.onClosed_()}},(...e)=>{var[t,n]=e;this.incrementIncomingBytes_(e),this.myPacketOrderer.handleResponse(t,n)},()=>{this.onClosed_()},this.urlFn);const t={start:"t"};t.ser=Math.floor(1e8*Math.random()),this.scriptTagHolder.uniqueCallbackIdentifier&&(t.cb=this.scriptTagHolder.uniqueCallbackIdentifier),t.v="5",this.transportSessionId&&(t.s=this.transportSessionId),this.lastSessionId&&(t.ls=this.lastSessionId),this.applicationId&&(t.p=this.applicationId),this.appCheckToken&&(t.ac=this.appCheckToken),"undefined"!=typeof location&&location.hostname&&jb.test(location.hostname)&&(t.r="f");var e=this.urlFn(t);this.log_("Connecting via long-poll to "+e),this.scriptTagHolder.addTag(e,()=>{})}})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){Qb.forceAllow_=!0}static forceDisallow(){Qb.forceDisallow_=!0}static isAvailable(){return!!Qb.forceAllow_||!(Qb.forceDisallow_||"undefined"==typeof document||null==document.createElement||"object"==typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href)||"object"==typeof Windows&&"object"==typeof Windows.UI)}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(e){var t=_d(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);var t=Qh(t),n=yb(t,1840);for(let r=0;r<n.length;r++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,n.length,n[r]),this.curSegmentNum++}addDisconnectPingFrame(e,t){this.myDisconnFrame=document.createElement("iframe");const n={dframe:"t"};n.id=e,n.pw=t,this.myDisconnFrame.src=this.urlFn(n),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){var t=_d(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class Yb{constructor(t,n,e,r){this.onDisconnect=e,this.urlFn=r,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0;{this.uniqueCallbackIdentifier=lb(),window["pLPCommand"+this.uniqueCallbackIdentifier]=t,window["pRTLPCB"+this.uniqueCallbackIdentifier]=n,this.myIFrame=Yb.createIFrame_();let e="";this.myIFrame.src&&"javascript:"===this.myIFrame.src.substr(0,"javascript:".length)&&(i=document.domain,e='<script>document.domain="'+i+'";<\/script>');var i="<html><body>"+e+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(i),this.myIFrame.doc.close()}catch(e){wb("frame writing exception"),e.stack&&wb(e.stack),wb(e)}}}static createIFrame_(){const t=document.createElement("iframe");if(t.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(t);try{t.contentWindow.document||wb("No IE domain setting required")}catch(e){var n=document.domain;t.src="javascript:void((function(){document.open();document.domain='"+n+"';document.close();})())"}return t.contentDocument?t.doc=t.contentDocument:t.contentWindow?t.doc=t.contentWindow.document:t.document&&(t.doc=t.document),t}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.innerHTML="",setTimeout(()=>{null!==this.myIFrame&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));const e=this.onDisconnect;e&&(this.onDisconnect=null,e())}startLongPoll(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(0<this.pendingSegs.length?2:1)){this.currentSerial++;const i={};i.id=this.myID,i.pw=this.myPW,i.ser=this.currentSerial;var n=this.urlFn(i);let e="",t=0;for(;0<this.pendingSegs.length;){if(!(this.pendingSegs[0].d.length+30+e.length<=1870))break;var r=this.pendingSegs.shift();e=e+"&seg"+t+"="+r.seg+"&ts"+t+"="+r.ts+"&d"+t+"="+r.d,t++}return n+=e,this.addLongPollTag_(n,this.currentSerial),!0}return!1}enqueueSegment(e,t,n){this.pendingSegs.push({seg:e,ts:t,d:n}),this.alive&&this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);const n=()=>{this.outstandingRequests.delete(t),this.newRequest_()},r=setTimeout(n,Math.floor(25e3));this.addTag(e,()=>{clearTimeout(r),n()})}addTag(e,n){setTimeout(()=>{try{if(!this.sendNewPolls)return;const t=this.myIFrame.doc.createElement("script");t.type="text/javascript",t.async=!0,t.src=e,t.onload=t.onreadystatechange=function(){var e=t.readyState;e&&"loaded"!==e&&"complete"!==e||(t.onload=t.onreadystatechange=null,t.parentNode&&t.parentNode.removeChild(t),n())},t.onerror=()=>{wb("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(t)}catch(e){}},Math.floor(1))}}let Jb=null;"undefined"!=typeof MozWebSocket?Jb=MozWebSocket:"undefined"!=typeof WebSocket&&(Jb=WebSocket);class Xb{constructor(e,t,n,r,i,s,o){this.connId=e,this.applicationId=n,this.appCheckToken=r,this.authToken=i,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=pb(this.connId),this.stats_=Hb(t),this.connURL=Xb.connectionURL_(t,s,o,r),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,n,r){const i={v:"5"};return"undefined"!=typeof location&&location.hostname&&jb.test(location.hostname)&&(i.r="f"),t&&(i.s=t),n&&(i.ls=n),r&&(i.ac=r),Wb(e,qb,i)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,ob.set("previous_websocket_failure",!0);try{hd()||(n={headers:{"X-Firebase-GMPID":this.applicationId||"","X-Firebase-AppCheck":this.appCheckToken||""}},this.mySock=new Jb(this.connURL,[],n))}catch(e){this.log_("Error instantiating WebSocket.");var n=e.message||e.data;return n&&this.log_(n),void this.onClosed_()}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=e=>{this.handleIncomingFrame(e)},this.mySock.onerror=e=>{this.log_("WebSocket error. Closing connection.");var t=e.message||e.data;t&&this.log_(t),this.onClosed_()}}start(){}static forceDisallow(){Xb.forceDisallow_=!0}static isAvailable(){let e=!1;var t;return"undefined"==typeof navigator||!navigator.userAgent||(t=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/))&&1<t.length&&parseFloat(t[1])<4.4&&(e=!0),!e&&null!==Jb&&!Xb.forceDisallow_}static previouslyFailed(){return ob.isInMemoryStorage||!0===ob.get("previous_websocket_failure")}markConnectionHealthy(){ob.remove("previous_websocket_failure")}appendFrame_(e){var t;this.frames.push(e),this.frames.length===this.totalFrames&&(t=this.frames.join(""),this.frames=null,t=yd(t),this.onMessage(t))}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(Jh(null===this.frames,"We already have a frame buffer"),e.length<=6){var t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){var t;null!==this.mySock&&(t=e.data,this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),null!==this.frames?this.appendFrame_(t):null!==(t=this.extractFrameCount_(t))&&this.appendFrame_(t))}send(e){this.resetKeepAlive();var t=_d(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);var n=yb(t,16384);1<n.length&&this.sendString_(String(n.length));for(let r=0;r<n.length;r++)this.sendString_(n[r])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(45e3))}sendString_(e){try{this.mySock.send(e)}catch(e){this.log_("Exception thrown from WebSocket.send():",e.message||e.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}Xb.responsesRequiredToBeHealthy=2,Xb.healthyTimeout=3e4;class Zb{constructor(e){this.initTransports_(e)}static get ALL_TRANSPORTS(){return[Qb,Xb]}initTransports_(e){var t=Xb&&Xb.isAvailable();let n=t&&!Xb.previouslyFailed();if(e.webSocketOnly&&(t||Tb("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),n=!0),n)this.transports_=[Xb];else{const r=this.transports_=[];for(const i of Zb.ALL_TRANSPORTS)i&&i.isAvailable()&&r.push(i)}}initialTransport(){if(0<this.transports_.length)return this.transports_[0];throw new Error("No transports available")}upgradeTransport(){return 1<this.transports_.length?this.transports_[1]:null}}class eT{constructor(e,t,n,r,i,s,o,a,c,l){this.id=e,this.repoInfo_=t,this.applicationId_=n,this.appCheckToken_=r,this.authToken_=i,this.onMessage_=s,this.onReady_=o,this.onDisconnect_=a,this.onKill_=c,this.lastSessionId=l,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=pb("c:"+this.id+":"),this.transportManager_=new Zb(t),this.log_("Connection created"),this.start_()}start_(){const e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.conn_),n=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(()=>{this.conn_&&this.conn_.open(t,n)},Math.floor(0));var r=e.healthyTimeout||0;0<r&&(this.healthyTimeout_=Rb(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&102400<this.conn_.bytesReceived?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes. Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&10240<this.conn_.bytesSent?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes. Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))},Math.floor(r)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(t){return e=>{t===this.conn_?this.onConnectionLost_(e):t===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(t){return e=>{2!==this.state_&&(t===this.rx_?this.onPrimaryMessageReceived_(e):t===this.secondaryConn_?this.onSecondaryMessageReceived_(e):this.log_("message on old connection"))}}sendRequest(e){this.sendData_({t:"d",d:e})}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(e){var t;"t"in e&&("a"===(t=e.t)?this.upgradeIfSecondaryHealthy_():"r"===t?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===t&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_()))}onSecondaryMessageReceived_(e){var t=mb("t",e),n=mb("d",e);if("c"===t)this.onSecondaryControl_(n);else{if("d"!==t)throw new Error("Unknown protocol layer: "+t);this.pendingDataMessages.push(n)}}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:"p",d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:"n",d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){var t=mb("t",e),n=mb("d",e);"c"===t?this.onControl_(n):"d"===t&&this.onDataMessage_(n)}onDataMessage_(e){this.onPrimaryResponse_(),this.onMessage_(e)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(e){var t=mb("t",e);if("d"in e){var n=e.d;if("h"===t)this.onHandshake_(n);else if("n"===t){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let e=0;e<this.pendingDataMessages.length;++e)this.onDataMessage_(this.pendingDataMessages[e]);this.pendingDataMessages=[],this.tryCleanupConnection()}else"s"===t?this.onConnectionShutdown_(n):"r"===t?this.onReset_(n):"e"===t?fb("Server Error: "+n):"o"===t?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):fb("Unknown control packet command: "+t)}}onHandshake_(e){var t=e.ts,n=e.v,r=e.h;this.sessionId=e.s,this.repoInfo_.host=r,0===this.state_&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),"5"!==n&&Tb("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){var e=this.transportManager_.upgradeTransport();e&&this.startUpgrade_(e)}startUpgrade_(e){this.secondaryConn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;var t=this.connReceiver_(this.secondaryConn_),n=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,n),Rb(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(6e4))}onReset_(e){this.log_("Reset packet received. New host: "+e),this.repoInfo_.host=e,1===this.state_?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(e,t){this.log_("Realtime connection established."),this.conn_=e,this.state_=1,this.onReady_&&(this.onReady_(t,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):Rb(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(5e3))}sendPingOnPrimaryIfNecessary_(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))}onSecondaryConnectionLost_(){var e=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==e&&this.rx_!==e||this.close()}onConnectionLost_(e){this.conn_=null,e||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(ob.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()}onConnectionShutdown_(e){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(e),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(e){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(e)}close(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}class tT{put(e,t,n,r){}merge(e,t,n,r){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,n){}onDisconnectMerge(e,t,n){}onDisconnectCancel(e,t){}reportStats(e){}}class nT{constructor(e){this.allowedEvents_=e,this.listeners_={},Jh(Array.isArray(e)&&0<e.length,"Requires a non-empty array")}trigger(t,...n){if(Array.isArray(this.listeners_[t])){const r=[...this.listeners_[t]];for(let e=0;e<r.length;e++)r[e].callback.apply(r[e].context,n)}}on(e,t,n){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:n});var r=this.getInitialEvent(e);r&&t.apply(n,r)}off(e,t,n){this.validateEventType_(e);const r=this.listeners_[e]||[];for(let i=0;i<r.length;i++)if(r[i].callback===t&&(!n||n===r[i].context))return void r.splice(i,1)}validateEventType_(t){Jh(this.allowedEvents_.find(e=>e===t),"Unknown event: "+t)}}class rT extends nT{constructor(){super(["online"]),this.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||od()||(window.addEventListener("online",()=>{this.online_||(this.online_=!0,this.trigger("online",!0))},!1),window.addEventListener("offline",()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))},!1))}static getInstance(){return new rT}getInitialEvent(e){return Jh("online"===e,"Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}class iT{constructor(n,e){if(void 0===e){this.pieces_=n.split("/");let e=0;for(let t=0;t<this.pieces_.length;t++)0<this.pieces_[t].length&&(this.pieces_[e]=this.pieces_[t],e++);this.pieces_.length=e,this.pieceNum_=0}else this.pieces_=n,this.pieceNum_=e}toString(){let e="";for(let t=this.pieceNum_;t<this.pieces_.length;t++)""!==this.pieces_[t]&&(e+="/"+this.pieces_[t]);return e||"/"}}function sT(){return new iT("")}function oT(e){return e.pieceNum_>=e.pieces_.length?null:e.pieces_[e.pieceNum_]}function aT(e){return e.pieces_.length-e.pieceNum_}function cT(e){let t=e.pieceNum_;return t<e.pieces_.length&&t++,new iT(e.pieces_,t)}function lT(e){return e.pieceNum_<e.pieces_.length?e.pieces_[e.pieces_.length-1]:null}function uT(e,t=0){return e.pieces_.slice(e.pieceNum_+t)}function hT(e){if(e.pieceNum_>=e.pieces_.length)return null;const t=[];for(let n=e.pieceNum_;n<e.pieces_.length-1;n++)t.push(e.pieces_[n]);return new iT(t,0)}function dT(e,t){const n=[];for(let i=e.pieceNum_;i<e.pieces_.length;i++)n.push(e.pieces_[i]);if(t instanceof iT)for(let e=t.pieceNum_;e<t.pieces_.length;e++)n.push(t.pieces_[e]);else{var r=t.split("/");for(let e=0;e<r.length;e++)0<r[e].length&&n.push(r[e])}return new iT(n,0)}function pT(e){return e.pieceNum_>=e.pieces_.length}function fT(e,t){var n=oT(e),r=oT(t);if(null===n)return t;if(n===r)return fT(cT(e),cT(t));throw new Error("INTERNAL ERROR: innerPath ("+t+") is not within outerPath ("+e+")")}function gT(e,t){var n=uT(e,0),r=uT(t,0);for(let s=0;s<n.length&&s<r.length;s++){var i=Cb(n[s],r[s]);if(0!==i)return i}return n.length===r.length?0:n.length<r.length?-1:1}function mT(e,t){if(aT(e)!==aT(t))return!1;for(let n=e.pieceNum_,r=t.pieceNum_;n<=e.pieces_.length;n++,r++)if(e.pieces_[n]!==t.pieces_[r])return!1;return!0}function vT(e,t){let n=e.pieceNum_,r=t.pieceNum_;if(aT(e)>aT(t))return!1;for(;n<e.pieces_.length;){if(e.pieces_[n]!==t.pieces_[r])return!1;++n,++r}return!0}class yT{constructor(e,t){this.errorPrefix_=t,this.parts_=uT(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let n=0;n<this.parts_.length;n++)this.byteLength_+=Ud(this.parts_[n]);_T(this)}}function _T(e){if(768<e.byteLength_)throw new Error(e.errorPrefix_+"has a key path longer than 768 bytes ("+e.byteLength_+").");if(32<e.parts_.length)throw new Error(e.errorPrefix_+"path specified exceeds the maximum depth that can be written (32) or object contains a cycle "+wT(e))}function wT(e){return 0===e.parts_.length?"":"in property '"+e.parts_.join(".")+"'"}class bT extends nT{constructor(){super(["visible"]);let t,e;"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(e="visibilitychange",t="hidden"):void 0!==document.mozHidden?(e="mozvisibilitychange",t="mozHidden"):void 0!==document.msHidden?(e="msvisibilitychange",t="msHidden"):void 0!==document.webkitHidden&&(e="webkitvisibilitychange",t="webkitHidden")),this.visible_=!0,e&&document.addEventListener(e,()=>{var e=!document[t];e!==this.visible_&&(this.visible_=e,this.trigger("visible",e))},!1)}static getInstance(){return new bT}getInitialEvent(e){return Jh("visible"===e,"Unknown event type: "+e),[this.visible_]}}class TT extends tT{constructor(e,t,n,r,i,s,o,a){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=n,this.onConnectStatus_=r,this.onServerInfoUpdate_=i,this.authTokenProvider_=s,this.appCheckTokenProvider_=o,this.authOverride_=a,this.id=TT.nextPersistentConnectionId_++,this.log_=pb("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=1e3,this.maxReconnectDelay_=3e5,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,a&&!hd())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");bT.getInstance().on("visible",this.onVisible_,this),-1===e.host.indexOf("fblocal")&&rT.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,n){var r=++this.requestNumber_,i={r:r,a:e,b:t};this.log_(_d(i)),Jh(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(i),n&&(this.requestCBHash_[r]=n)}get(e){this.initConnection_();const n=new rd,r={p:e._path.toString(),q:e._queryObject},t={action:"g",request:r,onComplete:e=>{var t=e.d;"ok"===e.s?(this.onDataUpdate_(r.p,t,!1,null),n.resolve(t)):n.reject(t)}};this.outstandingGets_.push(t),this.outstandingGetCount_++;const i=this.outstandingGets_.length-1;return this.connected_||setTimeout(()=>{var e=this.outstandingGets_[i];void 0!==e&&t===e&&(delete this.outstandingGets_[i],this.outstandingGetCount_--,0===this.outstandingGetCount_&&(this.outstandingGets_=[]),this.log_("get "+i+" timed out on connection"),n.reject(new Error("Client is offline.")))},3e3),this.connected_&&this.sendGet_(i),n.promise}listen(e,t,n,r){this.initConnection_();var i=e._queryIdentifier,s=e._path.toString();this.log_("Listen called for "+s+" "+i),this.listens.has(s)||this.listens.set(s,new Map),Jh(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),Jh(!this.listens.get(s).has(i),"listen() called twice for same path/queryId.");var o={onComplete:r,hashFn:t,query:e,tag:n};this.listens.get(s).set(i,o),this.connected_&&this.sendListen_(o)}sendGet_(t){const n=this.outstandingGets_[t];this.sendRequest("g",n.request,e=>{delete this.outstandingGets_[t],this.outstandingGetCount_--,0===this.outstandingGetCount_&&(this.outstandingGets_=[]),n.onComplete&&n.onComplete(e)})}sendListen_(r){const i=r.query,s=i._path.toString(),o=i._queryIdentifier;this.log_("Listen on "+s+" for "+o);const e={p:s};r.tag&&(e.q=i._queryObject,e.t=r.tag),e.h=r.hashFn(),this.sendRequest("q",e,e=>{var t=e.d,n=e.s;TT.warnOnListenWarnings_(t,i),(this.listens.get(s)&&this.listens.get(s).get(o))===r&&(this.log_("listen response",e),"ok"!==n&&this.removeListen_(s,o),r.onComplete&&r.onComplete(n,t))})}static warnOnListenWarnings_(e,t){if(e&&"object"==typeof e&&bd(e,"w")){const i=Td(e,"w");var n,r;Array.isArray(i)&&~i.indexOf("no_index")&&(n='".indexOn": "'+t._queryParams.getIndex().toString()+'"',r=t._path.toString(),Tb("Using an unspecified index. Your data will be downloaded and "+`filtered on the client. Consider adding ${n} at `+`${r} to your security rules for better performance.`))}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){var t;(e&&40===e.length||(e=e,"object"==typeof(t=wd(e).claims)&&!0===t.admin))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=3e4)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){const r=this.authToken_;var e=function(e){const t=wd(e),n=t.claims;return!!n&&"object"==typeof n&&n.hasOwnProperty("iat")}(r)?"auth":"gauth";const t={cred:r};null===this.authOverride_?t.noauth=!0:"object"==typeof this.authOverride_&&(t.authvar=this.authOverride_),this.sendRequest(e,t,e=>{var t=e.s,n=e.d||"error";this.authToken_===r&&("ok"===t?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(t,n))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{var t=e.s,n=e.d||"error";"ok"===t?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,n)})}unlisten(e,t){var n=e._path.toString(),r=e._queryIdentifier;this.log_("Unlisten called for "+n+" "+r),Jh(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(n,r)&&this.connected_&&this.sendUnlisten_(n,r,e._queryObject,t)}sendUnlisten_(e,t,n,r){this.log_("Unlisten on "+e+" for "+t);const i={p:e};r&&(i.q=n,i.t=r),this.sendRequest("n",i)}onDisconnectPut(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:n})}onDisconnectMerge(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:n})}onDisconnectCancel(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})}sendOnDisconnect_(e,t,n,r){var i={p:t,d:n};this.log_("onDisconnect "+e,i),this.sendRequest(e,i,e=>{r&&setTimeout(()=>{r(e.s,e.d)},Math.floor(0))})}put(e,t,n,r){this.putInternal("p",e,t,n,r)}merge(e,t,n,r){this.putInternal("m",e,t,n,r)}putInternal(e,t,n,r,i){this.initConnection_();const s={p:t,d:n};void 0!==i&&(s.h=i),this.outstandingPuts_.push({action:e,request:s,onComplete:r}),this.outstandingPutCount_++;var o=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(o):this.log_("Buffering put: "+t)}sendPut_(t){const n=this.outstandingPuts_[t].action;var e=this.outstandingPuts_[t].request;const r=this.outstandingPuts_[t].onComplete;this.outstandingPuts_[t].queued=this.connected_,this.sendRequest(n,e,e=>{this.log_(n+" response",e),delete this.outstandingPuts_[t],this.outstandingPutCount_--,0===this.outstandingPutCount_&&(this.outstandingPuts_=[]),r&&r(e.s,e.d)})}reportStats(e){var t;this.connected_&&(this.log_("reportStats",t={c:e}),this.sendRequest("s",t,e=>{var t;"ok"!==e.s&&(t=e.d,this.log_("reportStats","Error sending stats: "+t))}))}onDataMessage_(e){if("r"in e){this.log_("from server: "+_d(e));var t=e.r;const n=this.requestCBHash_[t];n&&(delete this.requestCBHash_[t],n(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,t){this.log_("handleServerMessage",e,t),"d"===e?this.onDataUpdate_(t.p,t.d,!1,t.t):"m"===e?this.onDataUpdate_(t.p,t.d,!0,t.t):"c"===e?this.onListenRevoked_(t.p,t.q):"ac"===e?this.onAuthRevoked_(t.s,t.d):"apc"===e?this.onAppCheckRevoked_(t.s,t.d):"sd"===e?this.onSecurityDebugPacket_(t):fb("Unrecognized action received from server: "+_d(e)+"\nAre you using the latest client?")}onReady_(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){Jh(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(()=>{this.establishConnectionTimer_=null,this.establishConnection_()},Math.floor(e))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=1e3,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=1e3,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){var e;this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()&&(this.visible_?this.lastConnectionEstablishedTime_&&(3e4<(new Date).getTime()-this.lastConnectionEstablishedTime_&&(this.reconnectDelay_=1e3),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime()),e=(new Date).getTime()-this.lastConnectionAttemptTime_,e=Math.max(0,this.reconnectDelay_-e),e=Math.random()*e,this.log_("Trying to reconnect in "+e+"ms"),this.scheduleConnect_(e),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)),this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;var e=this.onDataMessage_.bind(this),r=this.onReady_.bind(this);const u=this.onRealtimeDisconnect_.bind(this);var i=this.id+":"+TT.nextConnectionId_++,s=this.lastSessionId;let t=!1,n=null;var o=function(){n?n.close():(t=!0,u())};this.realtime_={close:o,sendRequest:function(e){Jh(n,"sendRequest call when we're not connected not allowed."),n.sendRequest(e)}};var a=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{var[c,l]=await Promise.all([this.authTokenProvider_.getToken(a),this.appCheckTokenProvider_.getToken(a)]);t?wb("getToken() completed but was canceled"):(wb("getToken() completed. Creating connection."),this.authToken_=c&&c.accessToken,this.appCheckToken_=l&&l.token,n=new eT(i,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,r,u,e=>{Tb(e+" ("+this.repoInfo_.toString()+")"),this.interrupt("server_kill")},s))}catch(e){this.log_("Failed to get token: "+e),t||(this.repoInfo_.nodeAdmin&&Tb(e),o())}}}interrupt(e){wb("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(e){wb("Resuming connection for reason: "+e),delete this.interruptReasons_[e],Id(this.interruptReasons_)&&(this.reconnectDelay_=1e3,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){var t=e-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:t})}cancelSentTransactions_(){for(let e=0;e<this.outstandingPuts_.length;e++){const t=this.outstandingPuts_[e];t&&"h"in t.request&&t.queued&&(t.onComplete&&t.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}0===this.outstandingPutCount_&&(this.outstandingPuts_=[])}onListenRevoked_(e,t){let n;n=t?t.map(e=>vb(e)).join("$"):"default";const r=this.removeListen_(e,n);r&&r.onComplete&&r.onComplete("permission_denied")}removeListen_(e,t){var n=new iT(e).toString();let r;if(this.listens.has(n)){const i=this.listens.get(n);r=i.get(t),i.delete(t),0===i.size&&this.listens.delete(n)}else r=void 0;return r}onAuthRevoked_(e,t){wb("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAuthTokenCount_++,3<=this.invalidAuthTokenCount_&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){wb("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAppCheckTokenCount_++,3<=this.invalidAppCheckTokenCount_&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace("\n","\nFIREBASE: "))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const t of this.listens.values())for(const n of t.values())this.sendListen_(n);for(let r=0;r<this.outstandingPuts_.length;r++)this.outstandingPuts_[r]&&this.sendPut_(r);for(;this.onDisconnectRequestQueue_.length;){var e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let i=0;i<this.outstandingGets_.length;i++)this.outstandingGets_[i]&&this.sendGet_(i)}sendConnectStats_(){const e={};e["sdk.js."+Qw.replace(/\./g,"-")]=1,od()?e["framework.cordova"]=1:ld()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){var e=rT.getInstance().currentlyOnline();return Id(this.interruptReasons_)&&e}}TT.nextPersistentConnectionId_=0,TT.nextConnectionId_=0;class IT{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new IT(e,t)}}class ET{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){var n=new IT(kb,e),r=new IT(kb,t);return 0!==this.compare(n,r)}minPost(){return IT.MIN}}let kT;class ST extends ET{static get __EMPTY_NODE(){return kT}static set __EMPTY_NODE(e){kT=e}compare(e,t){return Cb(e.name,t.name)}isDefinedOn(e){throw Xh("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return IT.MIN}maxPost(){return new IT(Sb,kT)}makePost(e,t){return Jh("string"==typeof e,"KeyIndex indexValue must always be a string."),new IT(e,kT)}toString(){return".key"}}const CT=new ST;class AT{constructor(e,t,n,r,i=null){this.isReverse_=r,this.resultGenerator_=i,this.nodeStack_=[];let s=1;for(;!e.isEmpty();)if(s=t?n(e.key,t):1,r&&(s*=-1),s<0)e=this.isReverse_?e.left:e.right;else{if(0===s){this.nodeStack_.push(e);break}this.nodeStack_.push(e),e=this.isReverse_?e.right:e.left}}getNext(){if(0===this.nodeStack_.length)return null;let e=this.nodeStack_.pop(),t;if(t=this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value},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 0<this.nodeStack_.length}peek(){if(0===this.nodeStack_.length)return null;var e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}}}class NT{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:NT.RED,this.left=null!=r?r:RT.EMPTY_NODE,this.right=null!=i?i:RT.EMPTY_NODE}copy(e,t,n,r,i){return new NT(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)}count(){return this.left.count()+1+this.right.count()}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;var 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)),r.fixUp_()}removeMin_(){if(this.left.isEmpty())return RT.EMPTY_NODE;let e=this;return e.left.isRed_()||e.left.left.isRed_()||(e=e.moveRedLeft_()),e=e.copy(null,null,null,e.left.removeMin_(),null),e.fixUp_()}remove(e,t){let n,r;if(n=this,t(e,n.key)<0)n.left.isEmpty()||n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),n=n.copy(null,null,null,n.left.remove(e,t),null);else{if(n.left.isRed_()&&(n=n.rotateRight_()),n.right.isEmpty()||n.right.isRed_()||n.right.left.isRed_()||(n=n.moveRedRight_()),0===t(e,n.key)){if(n.right.isEmpty())return RT.EMPTY_NODE;r=n.right.min_(),n=n.copy(r.key,r.value,null,null,n.right.removeMin_())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.fixUp_()}isRed_(){return this.color}fixUp_(){let e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e}moveRedLeft_(){let e=this.colorFlip_();return e.right.left.isRed_()&&(e=e.copy(null,null,null,null,e.right.rotateRight_()),e=e.rotateLeft_(),e=e.colorFlip_()),e}moveRedRight_(){let e=this.colorFlip_();return e.left.left.isRed_()&&(e=e.rotateRight_(),e=e.colorFlip_()),e}rotateLeft_(){var e=this.copy(null,null,NT.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){var e=this.copy(null,null,NT.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip_(){var 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_(){var e=this.check_();return Math.pow(2,e)<=this.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");var e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)}}NT.RED=!0,NT.BLACK=!1;class RT{constructor(e,t=RT.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new RT(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,NT.BLACK,null,null))}remove(e){return new RT(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,NT.BLACK,null,null))}get(e){var t;let n=this.root_;for(;!n.isEmpty();){if(0===(t=this.comparator_(e,n.key)))return n.value;t<0?n=n.left:0<t&&(n=n.right)}return null}getPredecessorKey(e){let t,n=this.root_,r=null;for(;!n.isEmpty();){if(0===(t=this.comparator_(e,n.key))){if(n.left.isEmpty())return r?r.key:null;for(n=n.left;!n.right.isEmpty();)n=n.right;return n.key}t<0?n=n.left:0<t&&(r=n,n=n.right)}throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(e){return this.root_.inorderTraversal(e)}reverseTraversal(e){return this.root_.reverseTraversal(e)}getIterator(e){return new AT(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new AT(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new AT(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new AT(this.root_,null,this.comparator_,!0,e)}}function PT(e,t){return Cb(e.name,t.name)}function xT(e,t){return Cb(e,t)}RT.EMPTY_NODE=new class{copy(e,t,n,r,i){return this}insert(e,t,n){return new NT(e,t,null)}remove(e,t){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}};let DT;function OT(e){return"number"==typeof e?"number:"+Nb(e):"string:"+e}function MT(e){var t;e.isLeafNode()?(t=e.val(),Jh("string"==typeof t||"number"==typeof t||"object"==typeof t&&bd(t,".sv"),"Priority must be a string or number.")):Jh(e===DT||e.isEmpty(),"priority of unexpected type."),Jh(e===DT||e.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")}let LT;class FT{constructor(e,t=FT.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,Jh(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),MT(this.priorityNode_)}static set __childrenNodeConstructor(e){LT=e}static get __childrenNodeConstructor(){return LT}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new FT(this.value_,e)}getImmediateChild(e){return".priority"===e?this.priorityNode_:FT.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return pT(e)?this:".priority"===oT(e)?this.priorityNode_:FT.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,t){return null}updateImmediateChild(e,t){return".priority"===e?this.updatePriority(t):t.isEmpty()&&".priority"!==e?this:FT.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){var n=oT(e);return null===n?t:t.isEmpty()&&".priority"!==n?this:(Jh(".priority"!==n||1===aT(e),".priority must be the last token in a path"),this.updateImmediateChild(n,FT.__childrenNodeConstructor.EMPTY_NODE.updateChild(cT(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(null===this.lazyHash_){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+OT(this.priorityNode_.val())+":");var t=typeof this.value_;e+=t+":",e+="number"==t?Nb(this.value_):this.value_,this.lazyHash_=sb(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===FT.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof FT.__childrenNodeConstructor?-1:(Jh(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){var t=typeof e.value_,n=typeof this.value_,r=FT.VALUE_TYPE_ORDER.indexOf(t),i=FT.VALUE_TYPE_ORDER.indexOf(n);return Jh(0<=r,"Unknown leaf type: "+t),Jh(0<=i,"Unknown leaf type: "+n),r===i?"object"==n?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:i-r}withIndex(){return this}isIndexed(){return!0}equals(e){return e===this||!!e.isLeafNode()&&(this.value_===e.value_&&this.priorityNode_.equals(e.priorityNode_))}}FT.VALUE_TYPE_ORDER=["object","boolean","number","string"];let UT,jT;const qT=new class extends ET{compare(e,t){const n=e.node.getPriority();var r=t.node.getPriority(),r=n.compareTo(r);return 0===r?Cb(e.name,t.name):r}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return IT.MIN}maxPost(){return new IT(Sb,new FT("[PRIORITY-POST]",jT))}makePost(e,t){var n=UT(e);return new IT(t,new FT("[PRIORITY-POST]",n))}toString(){return".priority"}},VT=Math.log(2);class BT{constructor(e){var t;this.count=(t=e+1,parseInt(Math.log(t)/VT,10)),this.current_=this.count-1;var n,r=(n=this.count,parseInt(Array(n+1).join("1"),2));this.bits_=e+1&r}nextBitIsOne(){var e=!(this.bits_&1<<this.current_);return this.current_--,e}}function WT(c,e,l,t){c.sort(e);const u=function(e,t){var n=t-e;let r,i;if(0==n)return null;if(1==n)return r=c[e],i=l?l(r):r,new NT(i,r.node,NT.BLACK,null,null);var s=parseInt(n/2,10)+e,o=u(e,s),n=u(s+1,t);return r=c[s],i=l?l(r):r,new NT(i,r.node,NT.BLACK,o,n)};var n=function(e){let s=null,o=null,a=c.length;function t(e,t){var n=a-e,r=a;a-=e;var i=u(1+n,r),r=c[n],n=l?l(r):r;!function(e){if(s){s.left=e;s=e}else{o=e;s=e}}(new NT(n,r.node,t,null,i))}for(let i=0;i<e.count;++i){var n=e.nextBitIsOne(),r=Math.pow(2,e.count-(i+1));n?t(r,NT.BLACK):(t(r,NT.BLACK),t(r,NT.RED))}return o}(new BT(c.length));return new RT(t||e,n)}let KT;const $T={};class zT{constructor(e,t){this.indexes_=e,this.indexSet_=t}static get Default(){return Jh(($T,qT),"ChildrenNode.ts has not been loaded"),KT=KT||new zT({".priority":$T},{".priority":qT}),KT}get(e){var t=Td(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof RT?t:null}hasIndex(e){return bd(this.indexSet_,e.toString())}addIndex(e,t){Jh(e!==CT,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const n=[];let r=!1;const i=t.getIterator(IT.Wrap);let s=i.getNext();for(;s;)r=r||e.isDefinedOn(s.node),n.push(s),s=i.getNext();let o;o=r?WT(n,e.getCompare()):$T;var a=e.toString();const c=Object.assign({},this.indexSet_);c[a]=e;const l=Object.assign({},this.indexes_);return l[a]=o,new zT(l,c)}addToIndexes(o,a){var e=Ed(this.indexes_,(t,e)=>{const n=Td(this.indexSet_,e);if(Jh(n,"Missing index implementation for "+e),t===$T){if(n.isDefinedOn(o.node)){const i=[],s=a.getIterator(IT.Wrap);let e=s.getNext();for(;e;)e.name!==o.name&&i.push(e),e=s.getNext();return i.push(o),WT(i,n.getCompare())}return $T}{var r=a.get(o.name);let e=t;return r&&(e=e.remove(new IT(o.name,r))),e.insert(o,o.node)}});return new zT(e,this.indexSet_)}removeFromIndexes(n,r){var e=Ed(this.indexes_,e=>{if(e===$T)return e;var t=r.get(n.name);return t?e.remove(new IT(n.name,t)):e});return new zT(e,this.indexSet_)}}let HT;class GT{constructor(e,t,n){this.children_=e,this.priorityNode_=t,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&MT(this.priorityNode_),this.children_.isEmpty()&&Jh(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}static get EMPTY_NODE(){return HT=HT||new GT(new RT(xT),null,zT.Default)}isLeafNode(){return!1}getPriority(){return this.priorityNode_||HT}updatePriority(e){return this.children_.isEmpty()?this:new GT(this.children_,e,this.indexMap_)}getImmediateChild(e){if(".priority"===e)return this.getPriority();var t=this.children_.get(e);return null===t?HT:t}getChild(e){var t=oT(e);return null===t?this:this.getImmediateChild(t).getChild(cT(e))}hasChild(e){return null!==this.children_.get(e)}updateImmediateChild(n,r){if(Jh(r,"We should always be passing snapshot nodes"),".priority"===n)return this.updatePriority(r);{var i=new IT(n,r);let e,t;t=r.isEmpty()?(e=this.children_.remove(n),this.indexMap_.removeFromIndexes(i,this.children_)):(e=this.children_.insert(n,r),this.indexMap_.addToIndexes(i,this.children_));i=e.isEmpty()?HT:this.priorityNode_;return new GT(e,i,t)}}updateChild(e,t){var n=oT(e);if(null===n)return t;Jh(".priority"!==oT(e)||1===aT(e),".priority must be the last token in a path");var r=this.getImmediateChild(n).updateChild(cT(e),t);return this.updateImmediateChild(n,r)}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(n){if(this.isEmpty())return null;const r={};let i=0,s=0,o=!0;if(this.forEachChild(qT,(e,t)=>{r[e]=t.val(n),i++,o&>.INTEGER_REGEXP_.test(e)?s=Math.max(s,Number(e)):o=!1}),!n&&o&&s<2*i){const e=[];for(const t in r)e[t]=r[t];return e}return n&&!this.getPriority().isEmpty()&&(r[".priority"]=this.getPriority().val()),r}hash(){if(null===this.lazyHash_){let r="";this.getPriority().isEmpty()||(r+="priority:"+OT(this.getPriority().val())+":"),this.forEachChild(qT,(e,t)=>{var n=t.hash();""!==n&&(r+=":"+e+":"+n)}),this.lazyHash_=""===r?"":sb(r)}return this.lazyHash_}getPredecessorChildName(e,t,n){const r=this.resolveIndex_(n);if(r){var i=r.getPredecessorKey(new IT(e,t));return i?i.name:null}return this.children_.getPredecessorKey(e)}getFirstChildName(e){const t=this.resolveIndex_(e);if(t){var n=t.minKey();return n&&n.name}return this.children_.minKey()}getFirstChild(e){var t=this.getFirstChildName(e);return t?new IT(t,this.children_.get(t)):null}getLastChildName(e){const t=this.resolveIndex_(e);if(t){var n=t.maxKey();return n&&n.name}return this.children_.maxKey()}getLastChild(e){var t=this.getLastChildName(e);return t?new IT(t,this.children_.get(t)):null}forEachChild(e,t){const n=this.resolveIndex_(e);return n?n.inorderTraversal(e=>t(e.name,e.node)):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(t,n){const e=this.resolveIndex_(n);if(e)return e.getIteratorFrom(t,e=>e);{const r=this.children_.getIteratorFrom(t.name,IT.Wrap);let e=r.peek();for(;null!=e&&n.compare(e,t)<0;)r.getNext(),e=r.peek();return r}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(t,n){const e=this.resolveIndex_(n);if(e)return e.getReverseIteratorFrom(t,e=>e);{const r=this.children_.getReverseIteratorFrom(t.name,IT.Wrap);let e=r.peek();for(;null!=e&&0<n.compare(e,t);)r.getNext(),e=r.peek();return r}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===YT?-1:0}withIndex(e){if(e===CT||this.indexMap_.hasIndex(e))return this;var t=this.indexMap_.addIndex(e,this.children_);return new GT(this.children_,this.priorityNode_,t)}isIndexed(e){return e===CT||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{const n=e;if(this.getPriority().equals(n.getPriority())){if(this.children_.count()!==n.children_.count())return!1;{const r=this.getIterator(qT),i=n.getIterator(qT);let e=r.getNext(),t=i.getNext();for(;e&&t;){if(e.name!==t.name||!e.node.equals(t.node))return!1;e=r.getNext(),t=i.getNext()}return null===e&&null===t}}return!1}}resolveIndex_(e){return e===CT?null:this.indexMap_.get(e.toString())}}GT.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class QT extends GT{constructor(){super(new RT(xT),GT.EMPTY_NODE,zT.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return GT.EMPTY_NODE}isEmpty(){return!1}}const YT=new QT;Object.defineProperties(IT,{MIN:{value:new IT(kb,GT.EMPTY_NODE)},MAX:{value:new IT(Sb,YT)}}),ST.__EMPTY_NODE=GT.EMPTY_NODE,FT.__childrenNodeConstructor=GT,Zw=YT,DT=Zw,eb=YT,jT=eb;const JT=!0;function XT(i,e=null){if(null===i)return GT.EMPTY_NODE;if("object"==typeof i&&".priority"in i&&(e=i[".priority"]),Jh(null===e||"string"==typeof e||"number"==typeof e||"object"==typeof e&&".sv"in e,"Invalid priority type found: "+typeof e),"object"!=typeof(i="object"==typeof i&&".value"in i&&null!==i[".value"]?i[".value"]:i)||".sv"in i){var t=i;return new FT(t,XT(e))}if(i instanceof Array||!JT){let r=GT.EMPTY_NODE;return Ab(i,(e,t)=>{if(bd(i,e)&&"."!==e.substring(0,1)){const n=XT(t);!n.isLeafNode()&&n.isEmpty()||(r=r.updateImmediateChild(e,n))}}),r.updatePriority(XT(e))}{const s=[];let r=!1;if(Ab(i,(e,t)=>{if("."!==e.substring(0,1)){const n=XT(t);n.isEmpty()||(r=r||!n.getPriority().isEmpty(),s.push(new IT(e,n)))}}),0===s.length)return GT.EMPTY_NODE;var n=WT(s,PT,e=>e.name,xT);if(r){t=WT(s,qT.getCompare());return new GT(n,XT(e),new zT({".priority":t},{".priority":qT}))}return new GT(n,XT(e),zT.Default)}}UT=XT;class ZT extends ET{constructor(e){super(),this.indexPath_=e,Jh(!pT(e)&&".priority"!==oT(e),"Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,t){const n=this.extractChild(e.node);var r=this.extractChild(t.node),r=n.compareTo(r);return 0===r?Cb(e.name,t.name):r}makePost(e,t){var n=XT(e),n=GT.EMPTY_NODE.updateChild(this.indexPath_,n);return new IT(t,n)}maxPost(){var e=GT.EMPTY_NODE.updateChild(this.indexPath_,YT);return new IT(Sb,e)}toString(){return uT(this.indexPath_,0).join("/")}}function eI(e){if(e===""+Db)return iI;var t=Ob(e);if(null!=t)return""+(t+1);const n=new Array(e.length);for(let i=0;i<n.length;i++)n[i]=e.charAt(i);if(n.length<oI)return n.push(iI),n.join("");let r=n.length-1;for(;0<=r&&n[r]===sI;)r--;return-1===r?Sb:(t=n[r],t=rI.charAt(rI.indexOf(t)+1),n[r]=t,n.slice(0,r+1).join(""))}function tI(e){if(e===""+xb)return kb;var t=Ob(e);if(null!=t)return""+(t-1);const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e.charAt(r);return n[n.length-1]===iI?1===n.length?""+Db:(delete n[n.length-1],n.join("")):(n[n.length-1]=rI.charAt(rI.indexOf(n[n.length-1])-1),n.join("")+sI.repeat(oI-n.length))}const nI=new class extends ET{compare(e,t){var n=e.node.compareTo(t.node);return 0===n?Cb(e.name,t.name):n}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return IT.MIN}maxPost(){return IT.MAX}makePost(e,t){var n=XT(e);return new IT(t,n)}toString(){return".value"}},rI="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",iI="-",sI="z",oI=786,aI=function(){let s=0;const o=[];return function(e){var t=e===s;s=e;let n;const r=new Array(8);for(n=7;0<=n;n--)r[n]=rI.charAt(e%64),e=Math.floor(e/64);Jh(0===e,"Cannot push at time == 0");let i=r.join("");if(t){for(n=11;0<=n&&63===o[n];n--)o[n]=0;o[n]++}else for(n=0;n<12;n++)o[n]=Math.floor(64*Math.random());for(n=0;n<12;n++)i+=rI.charAt(o[n]);return Jh(20===i.length,"nextPushId: Length should be 20."),i}}();function cI(e){return{type:"value",snapshotNode:e}}function lI(e,t){return{type:"child_added",snapshotNode:t,childName:e}}function uI(e,t){return{type:"child_removed",snapshotNode:t,childName:e}}function hI(e,t,n){return{type:"child_changed",snapshotNode:t,childName:e,oldSnap:n}}class dI{constructor(e){this.index_=e}updateChild(e,t,n,r,i,s){Jh(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");const o=e.getImmediateChild(t);return o.getChild(r).equals(n.getChild(r))&&o.isEmpty()===n.isEmpty()?e:(null!=s&&(n.isEmpty()?e.hasChild(t)?s.trackChildChange(uI(t,o)):Jh(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):o.isEmpty()?s.trackChildChange(lI(t,n)):s.trackChildChange(hI(t,n,o))),e.isLeafNode()&&n.isEmpty()?e:e.updateImmediateChild(t,n).withIndex(this.index_))}updateFullNode(r,n,i){return null!=i&&(r.isLeafNode()||r.forEachChild(qT,(e,t)=>{n.hasChild(e)||i.trackChildChange(uI(e,t))}),n.isLeafNode()||n.forEachChild(qT,(e,t)=>{if(r.hasChild(e)){const n=r.getImmediateChild(e);n.equals(t)||i.trackChildChange(hI(e,t,n))}else i.trackChildChange(lI(e,t))})),n.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?GT.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}class pI{constructor(e){this.indexedFilter_=new dI(e.getIndex()),this.index_=e.getIndex(),this.startPost_=pI.getStartPost_(e),this.endPost_=pI.getEndPost_(e)}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(e){return this.index_.compare(this.getStartPost(),e)<=0&&this.index_.compare(e,this.getEndPost())<=0}updateChild(e,t,n,r,i,s){return this.matches(new IT(t,n))||(n=GT.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,n,r,i,s)}updateFullNode(e,t,n){let r=(t=t.isLeafNode()?GT.EMPTY_NODE:t).withIndex(this.index_);r=r.updatePriority(GT.EMPTY_NODE);const i=this;return t.forEachChild(qT,(e,t)=>{i.matches(new IT(e,t))||(r=r.updateImmediateChild(e,GT.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(e,r,n)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(e){if(e.hasStart()){var t=e.getIndexStartName();return e.getIndex().makePost(e.getIndexStartValue(),t)}return e.getIndex().minPost()}static getEndPost_(e){if(e.hasEnd()){var t=e.getIndexEndName();return e.getIndex().makePost(e.getIndexEndValue(),t)}return e.getIndex().maxPost()}}class fI{constructor(e){this.rangedFilter_=new pI(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft()}updateChild(e,t,n,r,i,s){return this.rangedFilter_.matches(new IT(t,n))||(n=GT.EMPTY_NODE),e.getImmediateChild(t).equals(n)?e:e.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,n,r,i,s):this.fullLimitUpdateChild_(e,t,n,i,s)}updateFullNode(e,o,t){let a;if(o.isLeafNode()||o.isEmpty())a=GT.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<o.numChildren()&&o.isIndexed(this.index_)){a=GT.EMPTY_NODE.withIndex(this.index_);let t;t=this.reverse_?o.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):o.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);let n=0;for(;t.hasNext()&&n<this.limit_;){var r=t.getNext();let e;if(e=this.reverse_?this.index_.compare(this.rangedFilter_.getStartPost(),r)<=0:this.index_.compare(r,this.rangedFilter_.getEndPost())<=0,!e)break;a=a.updateImmediateChild(r.name,r.node),n++}}else{a=o.withIndex(this.index_),a=a.updatePriority(GT.EMPTY_NODE);let e,t,n,r;if(this.reverse_){r=a.getReverseIterator(this.index_),e=this.rangedFilter_.getEndPost(),t=this.rangedFilter_.getStartPost();const l=this.index_.getCompare();n=(e,t)=>l(t,e)}else r=a.getIterator(this.index_),e=this.rangedFilter_.getStartPost(),t=this.rangedFilter_.getEndPost(),n=this.index_.getCompare();let i=0,s=!1;for(;r.hasNext();){var c=r.getNext();!s&&n(e,c)<=0&&(s=!0),s&&i<this.limit_&&n(c,t)<=0?i++:a=a.updateImmediateChild(c.name,GT.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,a,t)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(e,t,n,r,i){let s;if(this.reverse_){const d=this.index_.getCompare();s=(e,t)=>d(t,e)}else s=this.index_.getCompare();const o=e;Jh(o.numChildren()===this.limit_,"");var a=new IT(t,n),c=this.reverse_?o.getFirstChild(this.index_):o.getLastChild(this.index_),l=this.rangedFilter_.matches(a);if(o.hasChild(t)){var u=o.getImmediateChild(t);let e=r.getChildAfterChild(this.index_,c,this.reverse_);for(;null!=e&&(e.name===t||o.hasChild(e.name));)e=r.getChildAfterChild(this.index_,e,this.reverse_);var h=null==e?1:s(e,a);if(l&&!n.isEmpty()&&0<=h)return null!=i&&i.trackChildChange(hI(t,n,u)),o.updateImmediateChild(t,n);{null!=i&&i.trackChildChange(uI(t,u));const p=o.updateImmediateChild(t,GT.EMPTY_NODE);return null!=e&&this.rangedFilter_.matches(e)?(null!=i&&i.trackChildChange(lI(e.name,e.node)),p.updateImmediateChild(e.name,e.node)):p}}return!n.isEmpty()&&l&&0<=s(c,a)?(null!=i&&(i.trackChildChange(uI(c.name,c.node)),i.trackChildChange(lI(t,n))),o.updateImmediateChild(t,n).updateImmediateChild(c.name,GT.EMPTY_NODE)):e}}class gI{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=qT}hasStart(){return this.startSet_}hasStartAfter(){return this.startAfterSet_}hasEndBefore(){return this.endBeforeSet_}isViewFromLeft(){return""===this.viewFrom_?this.startSet_:"l"===this.viewFrom_}getIndexStartValue(){return Jh(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return Jh(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:kb}hasEnd(){return this.endSet_}getIndexEndValue(){return Jh(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return Jh(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:Sb}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&""!==this.viewFrom_}getLimit(){return Jh(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===qT}copy(){const e=new gI;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e}}function mI(e,t,n){const r=e.copy();return r.startSet_=!0,void 0===t&&(t=null),r.indexStartValue_=t,null!=n?(r.startNameSet_=!0,r.indexStartName_=n):(r.startNameSet_=!1,r.indexStartName_=""),r}function vI(e,t,n){const r=e.copy();return r.endSet_=!0,void 0===t&&(t=null),r.indexEndValue_=t,void 0!==n?(r.endNameSet_=!0,r.indexEndName_=n):(r.endNameSet_=!1,r.indexEndName_=""),r}function yI(e,t){const n=e.copy();return n.index_=t,n}function _I(e){const t={};if(e.isDefault())return t;let n;return n=e.index_===qT?"$priority":e.index_===nI?"$value":e.index_===CT?"$key":(Jh(e.index_ instanceof ZT,"Unrecognized index type!"),e.index_.toString()),t.orderBy=_d(n),e.startSet_&&(t.startAt=_d(e.indexStartValue_),e.startNameSet_&&(t.startAt+=","+_d(e.indexStartName_))),e.endSet_&&(t.endAt=_d(e.indexEndValue_),e.endNameSet_&&(t.endAt+=","+_d(e.indexEndName_))),e.limitSet_&&(e.isViewFromLeft()?t.limitToFirst=e.limit_:t.limitToLast=e.limit_),t}function wI(t){const n={};if(t.startSet_&&(n.sp=t.indexStartValue_,t.startNameSet_&&(n.sn=t.indexStartName_)),t.endSet_&&(n.ep=t.indexEndValue_,t.endNameSet_&&(n.en=t.indexEndName_)),t.limitSet_){n.l=t.limit_;let e=t.viewFrom_;""===e&&(e=t.isViewFromLeft()?"l":"r"),n.vf=e}return t.index_!==qT&&(n.i=t.index_.toString()),n}class bI extends tT{constructor(e,t,n,r){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=n,this.appCheckTokenProvider_=r,this.log_=pb("p:rest:"),this.listens_={}}reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return void 0!==t?"tag$"+t:(Jh(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}listen(e,t,r,i){const s=e._path.toString();this.log_("Listen called for "+s+" "+e._queryIdentifier);const o=bI.getListenId_(e,r),a={};this.listens_[o]=a;var n=_I(e._queryParams);this.restRequest_(s+".json",n,(t,e)=>{let n=e;if(null===(t=404===t?n=null:t)&&this.onDataUpdate_(s,n,!1,r),Td(this.listens_,o)===a){let e;e=t?401===t?"permission_denied":"rest_error:"+t:"ok",i(e,null)}})}unlisten(e,t){var n=bI.getListenId_(e,t);delete this.listens_[n]}get(e){var t=_I(e._queryParams);const r=e._path.toString(),i=new rd;return this.restRequest_(r+".json",t,(e,t)=>{let n=t;null===(e=404===e?n=null:e)?(this.onDataUpdate_(r,n,!1,null),i.resolve(n)):i.reject(new Error(n))}),i.promise}refreshAuthToken(e){}restRequest_(i,s={},o){return s.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([e,t])=>{e&&e.accessToken&&(s.auth=e.accessToken),t&&t.token&&(s.ac=t.token);const n=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+i+"?ns="+this.repoInfo_.namespace+Cd(s);this.log_("Sending REST request for "+n);const r=new XMLHttpRequest;r.onreadystatechange=()=>{if(o&&4===r.readyState){this.log_("REST Response for "+n+" received. status:",r.status,"response:",r.responseText);let e=null;if(200<=r.status&&r.status<300){try{e=yd(r.responseText)}catch(e){Tb("Failed to parse JSON response for "+n+": "+r.responseText)}o(null,e)}else 401!==r.status&&404!==r.status&&Tb("Got unsuccessful REST response for "+n+" Status: "+r.status),o(r.status);o=null}},r.open("GET",n,!0),r.send()})}}class TI{constructor(){this.rootNode_=GT.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}function II(){return{value:null,children:new Map}}function EI(e,t,n){var r;pT(t)?(e.value=n,e.children.clear()):null!==e.value?e.value=e.value.updateChild(t,n):(r=oT(t),e.children.has(r)||e.children.set(r,II()),EI(e.children.get(r),t=cT(t),n))}function kI(e,n,r){var i;null!==e.value?r(n,e.value):(i=(e,t)=>{kI(t,new iT(n.toString()+"/"+e),r)},e.children.forEach((e,t)=>{i(t,e)}))}class SI{constructor(e){this.collection_=e,this.last_=null}get(){var e=this.collection_.get();const n=Object.assign({},e);return this.last_&&Ab(this.last_,(e,t)=>{n[e]=n[e]-t}),this.last_=e,n}}class CI{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new SI(e);var n=1e4+2e4*Math.random();Rb(this.reportStats_.bind(this),Math.floor(n))}reportStats_(){var e=this.statsListener_.get();const n={};let r=!1;Ab(e,(e,t)=>{0<t&&bd(this.statsToReport_,e)&&(n[e]=t,r=!0)}),r&&this.server_.reportStats(n),Rb(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))}}function AI(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function NI(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function RI(e){return{fromUser:!1,fromServer:!0,queryId:e,tagged:!0}}(z=tb=tb||{})[z.OVERWRITE=0]="OVERWRITE",z[z.MERGE=1]="MERGE",z[z.ACK_USER_WRITE=2]="ACK_USER_WRITE",z[z.LISTEN_COMPLETE=3]="LISTEN_COMPLETE";class PI{constructor(e,t,n){this.path=e,this.affectedTree=t,this.revert=n,this.type=tb.ACK_USER_WRITE,this.source=AI()}operationForChild(e){if(pT(this.path)){if(null!=this.affectedTree.value)return Jh(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;var t=this.affectedTree.subtree(new iT(e));return new PI(sT(),t,this.revert)}return Jh(oT(this.path)===e,"operationForChild called for unrelated child."),new PI(cT(this.path),this.affectedTree,this.revert)}}class xI{constructor(e,t){this.source=e,this.path=t,this.type=tb.LISTEN_COMPLETE}operationForChild(e){return pT(this.path)?new xI(this.source,sT()):new xI(this.source,cT(this.path))}}class DI{constructor(e,t,n){this.source=e,this.path=t,this.snap=n,this.type=tb.OVERWRITE}operationForChild(e){return pT(this.path)?new DI(this.source,sT(),this.snap.getImmediateChild(e)):new DI(this.source,cT(this.path),this.snap)}}class OI{constructor(e,t,n){this.source=e,this.path=t,this.children=n,this.type=tb.MERGE}operationForChild(e){if(pT(this.path)){const t=this.children.subtree(new iT(e));return t.isEmpty()?null:t.value?new DI(this.source,sT(),t.value):new OI(this.source,sT(),t)}return Jh(oT(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new OI(this.source,cT(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}class MI{constructor(e,t,n){this.node_=e,this.fullyInitialized_=t,this.filtered_=n}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(pT(e))return this.isFullyInitialized()&&!this.filtered_;var t=oT(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}class LI{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function FI(n,e,t,r){var i=[];const s=[];return e.forEach(e=>{var t;"child_changed"===e.type&&n.index_.indexedValueChanged(e.oldSnap,e.snapshotNode)&&s.push((t=e.childName,{type:"child_moved",snapshotNode:e.snapshotNode,childName:t}))}),UI(n,i,"child_removed",e,r,t),UI(n,i,"child_added",e,r,t),UI(n,i,"child_moved",s,r,t),UI(n,i,"child_changed",e,r,t),UI(n,i,"value",e,r,t),i}function UI(s,o,t,e,a,c){const n=e.filter(e=>e.type===t);n.sort((e,t)=>function(e,t,n){if(null==t.childName||null==n.childName)throw Xh("Should only compare child_ events.");var r=new IT(t.childName,t.snapshotNode),i=new IT(n.childName,n.snapshotNode);return e.index_.compare(r,i)}(s,e,t)),n.forEach(t=>{const n=(e=s,i=c,"value"===(r=t).type||"child_removed"===r.type||(r.prevName=i.getPredecessorChildName(r.childName,r.snapshotNode,e.index_)),r);var e,r,i;a.forEach(e=>{e.respondsTo(t.type)&&o.push(e.createEvent(n,s.query_))})})}function jI(e,t){return{eventCache:e,serverCache:t}}function qI(e,t,n,r){return jI(new MI(t,n,r),e.serverCache)}function VI(e,t,n,r){return jI(e.eventCache,new MI(t,n,r))}function BI(e){return e.eventCache.isFullyInitialized()?e.eventCache.getNode():null}function WI(e){return e.serverCache.isFullyInitialized()?e.serverCache.getNode():null}let KI;class $I{constructor(e,t=(KI=KI||new RT(gb),KI)){this.value=e,this.children=t}static fromObject(e){let n=new $I(null);return Ab(e,(e,t)=>{n=n.set(new iT(e),t)}),n}isEmpty(){return null===this.value&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(null!=this.value&&t(this.value))return{path:sT(),value:this.value};if(pT(e))return null;{var n=oT(e);const i=this.children.get(n);if(null===i)return null;var r=i.findRootMostMatchingPathAndValue(cT(e),t);return null==r?null:{path:dT(new iT(n),r.path),value:r.value}}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(pT(e))return this;{var t=oT(e);const n=this.children.get(t);return null!==n?n.subtree(cT(e)):new $I(null)}}set(e,t){if(pT(e))return new $I(t,this.children);{var n=oT(e);const i=this.children.get(n)||new $I(null);var r=i.set(cT(e),t),r=this.children.insert(n,r);return new $I(this.value,r)}}remove(t){if(pT(t))return this.children.isEmpty()?new $I(null):new $I(null,this.children);{var n=oT(t);const r=this.children.get(n);if(r){const i=r.remove(cT(t));let e;return e=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),null===this.value&&e.isEmpty()?new $I(null):new $I(this.value,e)}return this}}get(e){if(pT(e))return this.value;{var t=oT(e);const n=this.children.get(t);return n?n.get(cT(e)):null}}setTree(t,n){if(pT(t))return n;{var r=oT(t);const i=this.children.get(r)||new $I(null),s=i.setTree(cT(t),n);let e;return e=s.isEmpty()?this.children.remove(r):this.children.insert(r,s),new $I(this.value,e)}}fold(e){return this.fold_(sT(),e)}fold_(n,r){const i={};return this.children.inorderTraversal((e,t)=>{i[e]=t.fold_(dT(n,e),r)}),r(n,this.value,i)}findOnPath(e,t){return this.findOnPath_(e,sT(),t)}findOnPath_(e,t,n){var r=!!this.value&&n(t,this.value);if(r)return r;if(pT(e))return null;{r=oT(e);const i=this.children.get(r);return i?i.findOnPath_(cT(e),dT(t,r),n):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,sT(),t)}foreachOnPath_(e,t,n){if(pT(e))return this;{this.value&&n(t,this.value);var r=oT(e);const i=this.children.get(r);return i?i.foreachOnPath_(cT(e),dT(t,r),n):new $I(null)}}foreach(e){this.foreach_(sT(),e)}foreach_(n,r){this.children.inorderTraversal((e,t)=>{t.foreach_(dT(n,e),r)}),this.value&&r(n,this.value)}foreachChild(n){this.children.inorderTraversal((e,t)=>{t.value&&n(e,t.value)})}}class zI{constructor(e){this.writeTree_=e}static empty(){return new zI(new $I(null))}}function HI(t,n,r){if(pT(n))return new zI(new $I(r));var i=t.writeTree_.findRootMostValueAndPath(n);if(null!=i){var s=i.path;let e=i.value;i=fT(s,n);return e=e.updateChild(i,r),new zI(t.writeTree_.set(s,e))}s=new $I(r),s=t.writeTree_.setTree(n,s);return new zI(s)}function GI(e,n,t){let r=e;return Ab(t,(e,t)=>{r=HI(r,dT(n,e),t)}),r}function QI(e,t){if(pT(t))return zI.empty();var n=e.writeTree_.setTree(t,new $I(null));return new zI(n)}function YI(e,t){return null!=JI(e,t)}function JI(e,t){var n=e.writeTree_.findRootMostValueAndPath(t);return null!=n?e.writeTree_.get(n.path).getChild(fT(n.path,t)):null}function XI(e){const n=[],t=e.writeTree_.value;return null!=t?t.isLeafNode()||t.forEachChild(qT,(e,t)=>{n.push(new IT(e,t))}):e.writeTree_.children.inorderTraversal((e,t)=>{null!=t.value&&n.push(new IT(e,t.value))}),n}function ZI(e,t){if(pT(t))return e;var n=JI(e,t);return null!=n?new zI(new $I(n)):new zI(e.writeTree_.subtree(t))}function e0(e){return e.writeTree_.isEmpty()}function t0(e,t){return function r(i,e,s){{if(null!=e.value)return s.updateChild(i,e.value);{let n=null;return e.children.inorderTraversal((e,t)=>{".priority"===e?(Jh(null!==t.value,"Priority writes must always be leaf nodes"),n=t.value):s=r(dT(i,e),t,s)}),s=!s.getChild(i).isEmpty()&&null!==n?s.updateChild(dT(i,".priority"),n):s}}}(sT(),e.writeTree_,t)}function n0(e,t){return f0(t,e)}function r0(t,n){var e,r=t.allWrites.findIndex(e=>e.writeId===n);Jh(0<=r,"removeWrite called with nonexistent writeId.");const i=t.allWrites[r];t.allWrites.splice(r,1);let s=i.visible,o=!1,a=t.allWrites.length-1;for(;s&&0<=a;){var c=t.allWrites[a];c.visible&&(a>=r&&function(e,t){{if(e.snap)return vT(e.path,t);for(const n in e.children)if(e.children.hasOwnProperty(n)&&vT(dT(e.path,n),t))return!0;return!1}}(c,i.path)?s=!1:vT(i.path,c.path)&&(o=!0)),a--}return!!s&&(o?((e=t).visibleWrites=s0(e.allWrites,i0,sT()),0<e.allWrites.length?e.lastWriteId=e.allWrites[e.allWrites.length-1].writeId:e.lastWriteId=-1):i.snap?t.visibleWrites=QI(t.visibleWrites,i.path):Ab(i.children,e=>{t.visibleWrites=QI(t.visibleWrites,dT(i.path,e))}),!0)}function i0(e){return e.visible}function s0(e,t,n){let r=zI.empty();for(let s=0;s<e.length;++s){const o=e[s];if(t(o)){var i=o.path;let e;if(o.snap)vT(n,i)?(e=fT(n,i),r=HI(r,e,o.snap)):vT(i,n)&&(e=fT(i,n),r=HI(r,sT(),o.snap.getChild(e)));else{if(!o.children)throw Xh("WriteRecord should have .snap or .children");if(vT(n,i))e=fT(n,i),r=GI(r,e,o.children);else if(vT(i,n))if(e=fT(i,n),pT(e))r=GI(r,sT(),o.children);else{const a=Td(o.children,oT(e));a&&(i=a.getChild(cT(e)),r=HI(r,sT(),i))}}}}return r}function o0(e,t,n,r,i){if(r||i){var s=ZI(e.visibleWrites,t);if(!i&&e0(s))return n;if(i||null!=n||YI(s,sT()))return t0(s0(e.allWrites,function(e){return(e.visible||i)&&(!r||!~r.indexOf(e.writeId))&&(vT(e.path,t)||vT(t,e.path))},t),n||GT.EMPTY_NODE);return null}s=JI(e.visibleWrites,t);if(null!=s)return s;s=ZI(e.visibleWrites,t);return e0(s)?n:null!=n||YI(s,sT())?t0(s,n||GT.EMPTY_NODE):null}function a0(e,t,n,r){return o0(e.writeTree,e.treePath,t,n,r)}function c0(e,t){return function(e,t,n){let r=GT.EMPTY_NODE;const i=JI(e.visibleWrites,t);if(i)return i.isLeafNode()||i.forEachChild(qT,(e,t)=>{r=r.updateImmediateChild(e,t)}),r;if(n){const s=ZI(e.visibleWrites,t);return n.forEachChild(qT,(e,t)=>{var n=t0(ZI(s,new iT(e)),t);r=r.updateImmediateChild(e,n)}),XI(s).forEach(e=>{r=r.updateImmediateChild(e.name,e.node)}),r}return XI(ZI(e.visibleWrites,t)).forEach(e=>{r=r.updateImmediateChild(e.name,e.node)}),r}(e.writeTree,e.treePath,t)}function l0(e,t,n,r){return function(e,t,n,r,i){Jh(r||i,"Either existingEventSnap or existingServerSnap must exist");var s=dT(t,n);return YI(e.visibleWrites,s)?null:e0(s=ZI(e.visibleWrites,s))?i.getChild(n):t0(s,i.getChild(n))}(e.writeTree,e.treePath,t,n,r)}function u0(e,t){return n=e.writeTree,t=dT(e.treePath,t),JI(n.visibleWrites,t);var n}function h0(e,t,n,r,i,s){return function(e,t,n,r,i,s,o){let a;var c=ZI(e.visibleWrites,t),l=JI(c,sT());if(null!=l)a=l;else{if(null==n)return[];a=t0(c,n)}if(a=a.withIndex(o),a.isEmpty()||a.isLeafNode())return[];{const u=[],h=o.getCompare(),d=s?a.getReverseIteratorFrom(r,o):a.getIteratorFrom(r,o);let e=d.getNext();for(;e&&u.length<i;)0!==h(e,r)&&u.push(e),e=d.getNext();return u}}(e.writeTree,e.treePath,t,n,r,i,s)}function d0(e,t,n){return r=e.writeTree,e=e.treePath,n=n,i=dT(e,t=t),null!=(s=JI(r.visibleWrites,i))?s:n.isCompleteForChild(t)?t0(ZI(r.visibleWrites,i),n.getNode().getImmediateChild(t)):null;var r,i,s}function p0(e,t){return f0(dT(e.treePath,t),e.writeTree)}function f0(e,t){return{treePath:e,writeTree:t}}class g0{constructor(){this.changeMap=new Map}trackChildChange(e){var t=e.type,n=e.childName;Jh("child_added"===t||"child_changed"===t||"child_removed"===t,"Only child changes supported for tracking"),Jh(".priority"!==n,"Only non-priority child changes can be tracked.");var r=this.changeMap.get(n);if(r){var i=r.type;if("child_added"===t&&"child_removed"===i)this.changeMap.set(n,hI(n,e.snapshotNode,r.snapshotNode));else if("child_removed"===t&&"child_added"===i)this.changeMap.delete(n);else if("child_removed"===t&&"child_changed"===i)this.changeMap.set(n,uI(n,r.oldSnap));else if("child_changed"===t&&"child_added"===i)this.changeMap.set(n,lI(n,e.snapshotNode));else{if("child_changed"!==t||"child_changed"!==i)throw Xh("Illegal combination of changes: "+e+" occurred after "+r);this.changeMap.set(n,hI(n,e.snapshotNode,r.oldSnap))}}else this.changeMap.set(n,e)}getChanges(){return Array.from(this.changeMap.values())}}const m0=new class{getCompleteChild(e){return null}getChildAfterChild(e,t,n){return null}};class v0{constructor(e,t,n=null){this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=n}getCompleteChild(e){const t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);var n=null!=this.optCompleteServerCache_?new MI(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return d0(this.writes_,e,n)}getChildAfterChild(e,t,n){var r=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:WI(this.viewCache_),r=h0(this.writes_,r,t,1,n,e);return 0===r.length?null:r[0]}}function y0(e,t,n,r,i){const s=new g0;let o,a;if(n.type===tb.OVERWRITE){var c=n;o=c.source.fromUser?b0(e,t,c.path,c.snap,r,i,s):(Jh(c.source.fromServer,"Unknown source."),a=c.source.tagged||t.serverCache.isFiltered()&&!pT(c.path),w0(e,t,c.path,c.snap,r,i,a,s))}else if(n.type===tb.MERGE){c=n;o=c.source.fromUser?function(r,i,s,e,o,a,c){let l=i;return e.foreach((e,t)=>{var n=dT(s,e);T0(i,oT(n))&&(l=b0(r,l,n,t,o,a,c))}),e.foreach((e,t)=>{var n=dT(s,e);T0(i,oT(n))||(l=b0(r,l,n,t,o,a,c))}),l}(e,t,c.path,c.children,r,i,s):(Jh(c.source.fromServer,"Unknown source."),a=c.source.tagged||t.serverCache.isFiltered(),E0(e,t,c.path,c.children,r,i,a,s))}else if(n.type===tb.ACK_USER_WRITE){var l=n;o=l.revert?function(n,r,i,s,e,o){let a;{if(null!=u0(s,i))return r;{var c=new v0(s,r,e);const u=r.eventCache.getNode();let t;if(pT(i)||".priority"===oT(i)){let e;e=r.serverCache.isFullyInitialized()?a0(s,WI(r)):(l=r.serverCache.getNode(),Jh(l instanceof GT,"serverChildren would be complete if leaf node"),c0(s,l)),e=e,t=n.filter.updateFullNode(u,e,o)}else{var l=oT(i);let e=d0(s,l,r.serverCache);null==e&&r.serverCache.isCompleteForChild(l)&&(e=u.getImmediateChild(l)),t=null!=e?n.filter.updateChild(u,l,e,cT(i),c,o):r.eventCache.getNode().hasChild(l)?n.filter.updateChild(u,l,GT.EMPTY_NODE,cT(i),c,o):u,t.isEmpty()&&r.serverCache.isFullyInitialized()&&(a=a0(s,WI(r)),a.isLeafNode()&&(t=n.filter.updateFullNode(t,a,o)))}return a=r.serverCache.isFullyInitialized()||null!=u0(s,sT()),qI(r,t,a,n.filter.filtersNodes())}}}(e,t,l.path,r,i,s):function(e,t,i,n,s,o,a){if(null!=u0(s,i))return t;const c=t.serverCache.isFiltered(),l=t.serverCache;{if(null!=n.value){if(pT(i)&&l.isFullyInitialized()||l.isCompleteForPath(i))return w0(e,t,i,l.getNode().getChild(i),s,o,c,a);if(pT(i)){let n=new $I(null);return l.getNode().forEachChild(CT,(e,t)=>{n=n.set(new iT(e),t)}),E0(e,t,i,n,s,o,c,a)}return t}{let r=new $I(null);return n.foreach((e,t)=>{var n=dT(i,e);l.isCompleteForPath(n)&&(r=r.set(e,l.getNode().getChild(n)))}),E0(e,t,i,r,s,o,c,a)}}}(e,t,l.path,l.affectedTree,r,i,s)}else{if(n.type!==tb.LISTEN_COMPLETE)throw Xh("Unknown operation type: "+n.type);o=function(e,t,n,r,i){const s=t.serverCache,o=VI(t,s.getNode(),s.isFullyInitialized()||pT(n),s.isFiltered());return _0(e,o,n,r,m0,i)}(e,t,n.path,r,s)}l=s.getChanges();return function(e,t,n){const r=t.eventCache;if(r.isFullyInitialized()){var i=r.getNode().isLeafNode()||r.getNode().isEmpty();const s=BI(e);(0<n.length||!e.eventCache.isFullyInitialized()||i&&!r.getNode().equals(s)||!r.getNode().getPriority().equals(s.getPriority()))&&n.push(cI(BI(t)))}}(t,o,l),{viewCache:o,changes:l}}function _0(r,i,s,o,a,c){const l=i.eventCache;if(null!=u0(o,s))return i;{let t,n;if(pT(s)){var e;Jh(i.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),t=i.serverCache.isFiltered()?(e=c0(o,(e=WI(i))instanceof GT?e:GT.EMPTY_NODE),r.filter.updateFullNode(i.eventCache.getNode(),e,c)):(u=a0(o,WI(i)),r.filter.updateFullNode(i.eventCache.getNode(),u,c))}else{var u=oT(s);if(".priority"===u){Jh(1===aT(s),"Can't have a priority with additional path components");var h=l.getNode();n=i.serverCache.getNode();var d=l0(o,s,h,n);t=null!=d?r.filter.updatePriority(h,d):l.getNode()}else{h=cT(s);let e;e=l.isCompleteForChild(u)?(n=i.serverCache.getNode(),null!=(d=l0(o,s,l.getNode(),n))?l.getNode().getImmediateChild(u).updateChild(h,d):l.getNode().getImmediateChild(u)):d0(o,u,i.serverCache),t=null!=e?r.filter.updateChild(l.getNode(),u,e,h,a,c):l.getNode()}}return qI(i,t,l.isFullyInitialized()||pT(s),r.filter.filtersNodes())}}function w0(e,t,n,r,i,s,o,a){const c=t.serverCache;let l;const u=o?e.filter:e.filter.getIndexedFilter();if(pT(n))l=u.updateFullNode(c.getNode(),r,null);else if(u.filtersNodes()&&!c.isFiltered()){var h=c.getNode().updateChild(n,r);l=u.updateFullNode(c.getNode(),h,null)}else{var d=oT(n);if(!c.isCompleteForPath(n)&&1<aT(n))return t;var p=cT(n);const f=c.getNode().getImmediateChild(d);h=f.updateChild(p,r);l=".priority"===d?u.updatePriority(c.getNode(),h):u.updateChild(c.getNode(),d,h,p,m0,null)}p=VI(t,l,c.isFullyInitialized()||pT(n),u.filtersNodes());return _0(e,p,n,i,new v0(i,p,s),a)}function b0(t,n,r,i,e,s,o){const a=n.eventCache;let c,l;const u=new v0(e,n,s);if(pT(r))l=t.filter.updateFullNode(n.eventCache.getNode(),i,o),c=qI(n,l,!0,t.filter.filtersNodes());else{var h=oT(r);if(".priority"===h)l=t.filter.updatePriority(n.eventCache.getNode(),i),c=qI(n,l,a.isFullyInitialized(),a.isFiltered());else{var d=cT(r);const p=a.getNode().getImmediateChild(h);let e;if(pT(d))e=i;else{const f=u.getCompleteChild(h);e=null!=f?".priority"===lT(d)&&f.getChild(hT(d)).isEmpty()?f:f.updateChild(d,i):GT.EMPTY_NODE}c=p.equals(e)?n:qI(n,t.filter.updateChild(a.getNode(),h,e,d,u,o),a.isFullyInitialized(),t.filter.filtersNodes())}}return c}function T0(e,t){return e.eventCache.isCompleteForChild(t)}function I0(e,n,t){return t.foreach((e,t)=>{n=n.updateChild(e,t)}),n}function E0(r,i,e,t,s,o,a,c){if(i.serverCache.getNode().isEmpty()&&!i.serverCache.isFullyInitialized())return i;let l=i,n;n=pT(e)?t:new $I(null).setTree(e,t);const u=i.serverCache.getNode();return n.children.inorderTraversal((e,t)=>{var n;u.hasChild(e)&&(n=I0(0,i.serverCache.getNode().getImmediateChild(e),t),l=w0(r,l,new iT(e),n,s,o,a,c))}),n.children.inorderTraversal((e,t)=>{var n=!i.serverCache.isCompleteForChild(e)&&void 0===t.value;u.hasChild(e)||n||(n=I0(0,i.serverCache.getNode().getImmediateChild(e),t),l=w0(r,l,new iT(e),n,s,o,a,c))}),l}class k0{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const n=this.query_._queryParams,r=new dI(n.getIndex()),i=(e=n).loadsAllData()?new dI(e.getIndex()):new(e.hasLimit()?fI:pI)(e);this.processor_={filter:i};const s=t.serverCache,o=t.eventCache;var a=r.updateFullNode(GT.EMPTY_NODE,s.getNode(),null),c=i.updateFullNode(GT.EMPTY_NODE,o.getNode(),null),a=new MI(a,s.isFullyInitialized(),r.filtersNodes()),c=new MI(c,o.isFullyInitialized(),i.filtersNodes());this.viewCache_=jI(c,a),this.eventGenerator_=new LI(this.query_)}get query(){return this.query_}}function S0(e){return 0===e.eventRegistrations_.length}function C0(n,r,i){const s=[];if(i){Jh(null==r,"A cancel should cancel all event registrations.");const o=n.query._path;n.eventRegistrations_.forEach(e=>{var t=e.createCancelEvent(i,o);t&&s.push(t)})}if(r){let e=[];for(let t=0;t<n.eventRegistrations_.length;++t){const a=n.eventRegistrations_[t];if(a.matches(r)){if(r.hasAnyCallback()){e=e.concat(n.eventRegistrations_.slice(t+1));break}}else e.push(a)}n.eventRegistrations_=e}else n.eventRegistrations_=[];return s}function A0(e,t,n,r){t.type===tb.MERGE&&null!==t.source.queryId&&(Jh(WI(e.viewCache_),"We should always have a full cache before handling merges"),Jh(BI(e.viewCache_),"Missing event cache, even though we have a server cache"));const i=e.viewCache_,s=y0(e.processor_,i,t,n,r);return n=e.processor_,r=s.viewCache,Jh(r.eventCache.getNode().isIndexed(n.filter.getIndex()),"Event snap not indexed"),Jh(r.serverCache.getNode().isIndexed(n.filter.getIndex()),"Server snap not indexed"),Jh(s.viewCache.serverCache.isFullyInitialized()||!i.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),e.viewCache_=s.viewCache,N0(e,s.changes,s.viewCache.eventCache.getNode(),null)}function N0(e,t,n,r){var i=r?[r]:e.eventRegistrations_;return FI(e.eventGenerator_,t,n,i)}let R0;class P0{constructor(){this.views=new Map}}function x0(t,n,r,i){var e=n.source.queryId;if(null!==e){e=t.views.get(e);return Jh(null!=e,"SyncTree gave us an op for an invalid query."),A0(e,n,r,i)}{let e=[];for(const s of t.views.values())e=e.concat(A0(s,n,r,i));return e}}function D0(e,n,r,i,s){var o=n._queryIdentifier,o=e.views.get(o);if(o)return o;{let e=a0(r,s?i:null),t=!1;t=!!e||(e=i instanceof GT?c0(r,i):GT.EMPTY_NODE,!1);o=jI(new MI(e,t,!1),new MI(i,s,!1));return new k0(n,o)}}function O0(e,t,n,r,i,s){var o=D0(e,t,r,i,s);return e.views.has(t._queryIdentifier)||e.views.set(t._queryIdentifier,o),o.eventRegistrations_.push(n),function(e,t){const n=e.viewCache_.eventCache,r=[];if(!n.getNode().isLeafNode()){const i=n.getNode();i.forEachChild(qT,(e,t)=>{r.push(lI(e,t))})}return n.isFullyInitialized()&&r.push(cI(n.getNode())),N0(e,r,n.getNode(),t)}(o,n)}function M0(e,t,n,r){var i=t._queryIdentifier;const s=[];let o=[];var a=q0(e);if("default"===i)for(var[c,l]of e.views.entries())o=o.concat(C0(l,n,r)),S0(l)&&(e.views.delete(c),l.query._queryParams.loadsAllData()||s.push(l.query));else{const u=e.views.get(i);u&&(o=o.concat(C0(u,n,r)),S0(u)&&(e.views.delete(i),u.query._queryParams.loadsAllData()||s.push(u.query)))}return a&&!q0(e)&&s.push((Jh(R0,"Reference.ts has not been loaded"),new R0(t._repo,t._path))),{removed:s,events:o}}function L0(e){const t=[];for(const n of e.views.values())n.query._queryParams.loadsAllData()||t.push(n);return t}function F0(e,t){let n=null;for(const r of e.views.values())n=n||function(e,t){const n=WI(e.viewCache_);return n&&(e.query._queryParams.loadsAllData()||!pT(t)&&!n.getImmediateChild(oT(t)).isEmpty())?n.getChild(t):null}(r,t);return n}function U0(e,t){const n=t._queryParams;if(n.loadsAllData())return V0(e);var r=t._queryIdentifier;return e.views.get(r)}function j0(e,t){return null!=U0(e,t)}function q0(e){return null!=V0(e)}function V0(e){for(const t of e.views.values())if(t.query._queryParams.loadsAllData())return t;return null}let B0;let W0=1;class K0{constructor(e){this.listenProvider_=e,this.syncPointTree_=new $I(null),this.pendingWriteTree_={visibleWrites:zI.empty(),allWrites:[],lastWriteId:-1},this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function $0(e,t,n,r,i){var s,o,a,c;return s=e.pendingWriteTree_,o=t,a=n,c=r,r=i,Jh(c>s.lastWriteId,"Stacking an older write on top of newer ones"),s.allWrites.push({path:o,snap:a,writeId:c,visible:r=void 0===r?!0:r}),r&&(s.visibleWrites=HI(s.visibleWrites,o,a)),s.lastWriteId=c,i?Z0(e,new DI(AI(),t,n)):[]}function z0(e,t,n,r){var i,s,o;i=e.pendingWriteTree_,s=t,o=n,r=r,Jh(r>i.lastWriteId,"Stacking an older merge on top of newer ones"),i.allWrites.push({path:s,children:o,writeId:r,visible:!0}),i.visibleWrites=GI(i.visibleWrites,s,o),i.lastWriteId=r;var a=$I.fromObject(n);return Z0(e,new OI(AI(),t,a))}function H0(e,t,n=!1){var r=function(e,t){for(let r=0;r<e.allWrites.length;r++){var n=e.allWrites[r];if(n.writeId===t)return n}return null}(e.pendingWriteTree_,t);if(r0(e.pendingWriteTree_,t)){let t=new $I(null);return null!=r.snap?t=t.set(sT(),!0):Ab(r.children,e=>{t=t.set(new iT(e),!0)}),Z0(e,new PI(r.path,t,n))}return[]}function G0(e,t,n){return Z0(e,new DI(NI(),t,n))}function Q0(n,e,t,r){var i=e._path,s=n.syncPointTree_.get(i);let o=[];if(s&&("default"===e._queryIdentifier||j0(s,e))){var a=M0(s,e,t,r);0===s.views.size&&(n.syncPointTree_=n.syncPointTree_.remove(i));const h=a.removed;o=a.events;s=-1!==h.findIndex(e=>e._queryParams.loadsAllData()),a=n.syncPointTree_.findOnPath(i,(e,t)=>q0(t));if(s&&!a){const d=n.syncPointTree_.subtree(i);if(!d.isEmpty()){var c=d.fold((e,t,r)=>{if(t&&q0(t))return[V0(t)];{let n=[];return t&&(n=L0(t)),Ab(r,(e,t)=>{n=n.concat(t)}),n}});for(let e=0;e<c.length;++e){var l=c[e],u=l.query,l=tE(n,l);n.listenProvider_.startListening(aE(u),nE(n,u),l.hashFn,l.onComplete)}}}!a&&0<h.length&&!r&&(s?n.listenProvider_.stopListening(aE(e),null):h.forEach(e=>{var t=n.queryToTagMap.get(rE(e));n.listenProvider_.stopListening(aE(e),t)})),function(e,t){for(let i=0;i<t.length;++i){const s=t[i];var n,r;s._queryParams.loadsAllData()||(n=rE(s),r=e.queryToTagMap.get(n),e.queryToTagMap.delete(n),e.tagToQueryMap.delete(r))}}(n,h)}return o}function Y0(e,t,n){const r=t._path;let i=null,s=!1;e.syncPointTree_.foreachOnPath(r,(e,t)=>{var n=fT(e,r);i=i||F0(t,n),s=s||q0(t)});let o=e.syncPointTree_.get(r);o?(s=s||q0(o),i=i||F0(o,sT())):(o=new P0,e.syncPointTree_=e.syncPointTree_.set(r,o));let a;if(null!=i)a=!0;else{a=!1,i=GT.EMPTY_NODE;const d=e.syncPointTree_.subtree(r);d.foreachChild((e,t)=>{var n=F0(t,sT());n&&(i=i.updateImmediateChild(e,n))})}var c,l=j0(o,t);l||t._queryParams.loadsAllData()||(u=rE(t),Jh(!e.queryToTagMap.has(u),"View does not exist, but we have a tag"),c=W0++,e.queryToTagMap.set(u,c),e.tagToQueryMap.set(c,u));var u=n0(e.pendingWriteTree_,r);let h=O0(o,t,n,u,i,a);return l||s||(l=U0(o,t),h=h.concat(function(t,e,n){const r=e._path,i=nE(t,e),s=tE(t,n),o=t.listenProvider_.startListening(aE(e),i,s.hashFn,s.onComplete),a=t.syncPointTree_.subtree(r);if(i)Jh(!q0(a.value),"If we're adding a query, it shouldn't be shadowed");else{var c=a.fold((e,t,r)=>{if(!pT(e)&&t&&q0(t))return[V0(t).query];{let n=[];return t&&(n=n.concat(L0(t).map(e=>e.query))),Ab(r,(e,t)=>{n=n.concat(t)}),n}});for(let e=0;e<c.length;++e){var l=c[e];t.listenProvider_.stopListening(aE(l),nE(t,l))}}return o}(e,t,l))),h}function J0(e,r,t){var n=e.pendingWriteTree_,i=e.syncPointTree_.findOnPath(r,(e,t)=>{var n=F0(t,fT(e,r));if(n)return n});return o0(n,r,i,t,!0)}function X0(e,t){const r=t._path;let i=null;e.syncPointTree_.foreachOnPath(r,(e,t)=>{var n=fT(e,r);i=i||F0(t,n)});let n=e.syncPointTree_.get(r);n?i=i||F0(n,sT()):(n=new P0,e.syncPointTree_=e.syncPointTree_.set(r,n));var s=null!=i;const o=s?new MI(i,!0,!1):null;var a=n0(e.pendingWriteTree_,t._path);return BI(D0(n,t,a,s?o.getNode():GT.EMPTY_NODE,s).viewCache_)}function Z0(e,t){return function t(n,r,i,s){{if(pT(n.path))return eE(n,r,i,s);{const o=r.get(sT());null==i&&null!=o&&(i=F0(o,sT()));let e=[];const a=oT(n.path),c=n.operationForChild(a),l=r.children.get(a);if(l&&c){const u=i?i.getImmediateChild(a):null,h=p0(s,a);e=e.concat(t(c,l,u,h))}return o&&(e=e.concat(x0(o,n,s,i))),e}}}(t,e.syncPointTree_,null,n0(e.pendingWriteTree_,sT()))}function eE(s,e,o,a){var t=e.get(sT());null==o&&null!=t&&(o=F0(t,sT()));let c=[];return e.children.inorderTraversal((e,t)=>{var n=o?o.getImmediateChild(e):null,r=p0(a,e),i=s.operationForChild(e);i&&(c=c.concat(eE(i,t,n,r)))}),t&&(c=c.concat(x0(t,s,a,o))),c}function tE(i,t){const s=t.query,o=nE(i,s);return{hashFn:()=>{const e=t.viewCache_.serverCache.getNode()||GT.EMPTY_NODE;return e.hash()},onComplete:e=>{if("ok"===e)return o?function(e,t,n){if(s=iE(e,n)){var r=sE(s),i=r.path,s=r.queryId,r=fT(i,t);return oE(e,i,new xI(RI(s),r))}return[]}(i,s._path,o):(t=i,n=s._path,Z0(t,new xI(NI(),n)));var t,n,r=function(e,t){let n="Unknown Error";"too_big"===e?n="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"===e?n="Client doesn't have permission to access the desired data.":"unavailable"===e&&(n="The service is unavailable");const r=new Error(e+" at "+t._path.toString()+": "+n);return r.code=e.toUpperCase(),r}(e,s);return Q0(i,s,null,r)}}}function nE(e,t){var n=rE(t);return e.queryToTagMap.get(n)}function rE(e){return e._path.toString()+"$"+e._queryIdentifier}function iE(e,t){return e.tagToQueryMap.get(t)}function sE(e){var t=e.indexOf("$");return Jh(-1!==t&&t<e.length-1,"Bad queryKey."),{queryId:e.substr(t+1),path:new iT(e.substr(0,t))}}function oE(e,t,n){var r=e.syncPointTree_.get(t);return Jh(r,"Missing sync point for query tag that we're tracking"),x0(r,n,n0(e.pendingWriteTree_,t),null)}function aE(e){return e._queryParams.loadsAllData()&&!e._queryParams.isDefault()?(Jh(B0,"Reference.ts has not been loaded"),new B0(e._repo,e._path)):e}class cE{constructor(e){this.node_=e}getImmediateChild(e){var t=this.node_.getImmediateChild(e);return new cE(t)}node(){return this.node_}}class lE{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){var t=dT(this.path_,e);return new lE(this.syncTree_,t)}node(){return J0(this.syncTree_,this.path_)}}function uE(e){return(e=e||{}).timestamp=e.timestamp||(new Date).getTime(),e}function hE(e,t,n){return e&&"object"==typeof e?(Jh(".sv"in e,"Unexpected leaf node or priority contents"),"string"==typeof e[".sv"]?dE(e[".sv"],t,n):"object"==typeof e[".sv"]?pE(e[".sv"],t):void Jh(!1,"Unexpected server value: "+JSON.stringify(e,null,2))):e}const dE=function(e,t,n){if("timestamp"===e)return n.timestamp;Jh(!1,"Unexpected server value: "+e)},pE=function(e,t,n){e.hasOwnProperty("increment")||Jh(!1,"Unexpected server value: "+JSON.stringify(e,null,2));var r=e.increment;"number"!=typeof r&&Jh(!1,"Unexpected increment value: "+r);const i=t.node();if(Jh(null!==i&&void 0!==i,"Expected ChildrenNode.EMPTY_NODE for nulls"),!i.isLeafNode())return r;const s=i;var o=s.getValue();return"number"!=typeof o?r:o+r},fE=function(e,t,n,r){return mE(t,new lE(n,e),r)},gE=function(e,t,n){return mE(e,new cE(t),n)};function mE(e,r,i){var t=e.getPriority().val(),n=hE(t,r.getImmediateChild(".priority"),i);let s;if(e.isLeafNode()){const o=e;t=hE(o.getValue(),r,i);return t!==o.getValue()||n!==o.getPriority().val()?new FT(t,XT(n)):e}{const a=e;return s=a,n!==a.getPriority().val()&&(s=s.updatePriority(new FT(n))),a.forEachChild(qT,(e,t)=>{var n=mE(t,r.getImmediateChild(e),i);n!==t&&(s=s.updateImmediateChild(e,n))}),s}}class vE{constructor(e="",t=null,n={children:{},childCount:0}){this.name=e,this.parent=t,this.node=n}}function yE(e,t){let n=t instanceof iT?t:new iT(t),r=e,i=oT(n);for(;null!==i;){var s=Td(r.node.children,i)||{children:{},childCount:0};r=new vE(i,r,s),n=cT(n),i=oT(n)}return r}function _E(e){return e.node.value}function wE(e,t){e.node.value=t,EE(e)}function bE(e){return 0<e.node.childCount}function TE(n,r){Ab(n.node.children,(e,t)=>{r(new vE(e,n,t))})}function IE(e){return new iT(null===e.parent?e.name:IE(e.parent)+"/"+e.name)}function EE(e){var t,n,r,i;null!==e.parent&&(t=e.parent,n=e.name,r=function(e){return void 0===_E(e)&&!bE(e)}(e=e),i=bd(t.node.children,n),r&&i?(delete t.node.children[n],t.node.childCount--,EE(t)):r||i||(t.node.children[n]=e.node,t.node.childCount++,EE(t)))}function kE(e,t,n,r){r&&void 0===t||UE(Md(e,"value"),t,n)}function SE(e,t,r,n){if(!n||void 0!==t){const i=Md(e,"values");if(!t||"object"!=typeof t||Array.isArray(t))throw new Error(i+" must be an object containing the children to replace.");const s=[];Ab(t,(e,t)=>{const n=new iT(e);if(UE(i,t,dT(r,n)),".priority"===lT(n)&&!FE(t))throw new Error(i+"contains an invalid value for '"+n.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");s.push(n)}),function(t,n){let r,i;for(r=0;r<n.length;r++){i=n[r];var s=uT(i);for(let e=0;e<s.length;e++)if((".priority"!==s[e]||e!==s.length-1)&&!OE(s[e]))throw new Error(t+"contains an invalid key ("+s[e]+") in path "+i.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"')}n.sort(gT);let e=null;for(r=0;r<n.length;r++){if(i=n[r],null!==e&&vT(e,i))throw new Error(t+"contains a path "+e.toString()+" that is ancestor of another path "+i.toString());e=i}}(i,s)}}function CE(e,t,n){if(!n||void 0!==t){if(Eb(t))throw new Error(Md(e,"priority")+"is "+t.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!FE(t))throw new Error(Md(e,"priority")+"must be a valid Firebase priority (a string, finite number, server value, or null).")}}function AE(e,t,n,r){if(!(r&&void 0===n||OE(n)))throw new Error(Md(e,t)+'was an invalid key = "'+n+'". Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").')}function NE(e,t,n,r){n=n&&n.replace(/^\/*\.info(\/|$)/,"/"),jE(e,t,n,r)}function RE(e,t){if(".info"===oT(t))throw new Error(e+" failed = Can't modify data under /.info/")}const PE=/[\[\].#$\/\u0000-\u001F\u007F]/,xE=/[\[\].#$\u0000-\u001F\u007F]/,DE=10485760,OE=function(e){return"string"==typeof e&&0!==e.length&&!PE.test(e)},ME=function(e){return"string"==typeof e&&0!==e.length&&!xE.test(e)},LE=function(e){return e=e&&e.replace(/^\/*\.info(\/|$)/,"/"),ME(e)},FE=function(e){return null===e||"string"==typeof e||"number"==typeof e&&!Eb(e)||e&&"object"==typeof e&&bd(e,".sv")},UE=function(o,e,t){const a=t instanceof iT?new yT(t,o):t;if(void 0===e)throw new Error(o+"contains undefined "+wT(a));if("function"==typeof e)throw new Error(o+"contains a function "+wT(a)+" with contents = "+e.toString());if(Eb(e))throw new Error(o+"contains "+e.toString()+" "+wT(a));if("string"==typeof e&&e.length>DE/3&&Ud(e)>DE)throw new Error(o+"contains a string greater than "+DE+" utf8 bytes "+wT(a)+" ('"+e.substring(0,50)+"...')");if(e&&"object"==typeof e){let i=!1,s=!1;if(Ab(e,(e,t)=>{if(".value"===e)i=!0;else if(".priority"!==e&&".sv"!==e&&(s=!0,!OE(e)))throw new Error(o+" contains an invalid key ("+e+") "+wT(a)+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');var n,r;n=a,e=e,0<n.parts_.length&&(n.byteLength_+=1),n.parts_.push(e),n.byteLength_+=Ud(e),_T(n),UE(o,t,a),t=a,r=t.parts_.pop(),t.byteLength_-=Ud(r),0<t.parts_.length&&--t.byteLength_}),i&&s)throw new Error(o+' contains ".value" child '+wT(a)+" in addition to actual children.")}},jE=function(e,t,n,r){if(!(r&&void 0===n||ME(n)))throw new Error(Md(e,t)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},qE=function(e,t){var n=t.path.toString();if("string"!=typeof t.repoInfo.host||0===t.repoInfo.host.length||!OE(t.repoInfo.namespace)&&"localhost"!==t.repoInfo.host.split(":")[0]||0!==n.length&&!LE(n))throw new Error(Md(e,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')};class VE{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function BE(e,t){let n=null;for(let i=0;i<t.length;i++){const s=t[i];var r=s.getPath();null===n||mT(r,n.path)||(e.eventLists_.push(n),n=null),null===n&&(n={events:[],path:r}),n.events.push(s)}n&&e.eventLists_.push(n)}function WE(e,t,n){BE(e,n),$E(e,e=>mT(e,t))}function KE(e,t,n){BE(e,n),$E(e,e=>vT(e,t)||vT(t,e))}function $E(e,t){e.recursionDepth_++;let n=!0;for(let i=0;i<e.eventLists_.length;i++){var r=e.eventLists_[i];r&&(t(r.path)?(function(e){for(let n=0;n<e.events.length;n++){const r=e.events[n];var t;null!==r&&(e.events[n]=null,t=r.getEventRunner(),hb&&wb("event: "+r.toString()),Mb(t))}}(e.eventLists_[i]),e.eventLists_[i]=null):n=!1)}n&&(e.eventLists_=[]),e.recursionDepth_--}const zE="repo_interrupt",HE=25;class GE{constructor(e,t,n,r){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=n,this.appCheckProvider_=r,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new VE,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=II(),this.transactionQueueTree_=new vE,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function QE(o,e,t){if(o.stats_=Hb(o.repoInfo_),o.forceRestClient_||function(){const e="object"==typeof window&&window.navigator&&window.navigator.userAgent||"";return 0<=e.search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)}())o.server_=new bI(o.repoInfo_,(e,t,n,r)=>{XE(o,e,t,n,r)},o.authTokenProvider_,o.appCheckProvider_),setTimeout(()=>ZE(o,!0),0);else{if(null!=t){if("object"!=typeof t)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{_d(t)}catch(e){throw new Error("Invalid authOverride provided: "+e)}}o.persistentConnection_=new TT(o.repoInfo_,e,(e,t,n,r)=>{XE(o,e,t,n,r)},e=>{ZE(o,e)},e=>{var n;n=o,Ab(e,(e,t)=>{ek(n,e,t)})},o.authTokenProvider_,o.appCheckProvider_,t),o.server_=o.persistentConnection_}var n;o.authTokenProvider_.addTokenChangeListener(e=>{o.server_.refreshAuthToken(e)}),o.appCheckProvider_.addTokenChangeListener(e=>{o.server_.refreshAppCheckToken(e.token)}),o.statsReporter_=(e=o.repoInfo_,t=()=>new CI(o.stats_,o.server_),n=e.toString(),zb[n]||(zb[n]=t()),zb[n]),o.infoData_=new TI,o.infoSyncTree_=new K0({startListening:(e,t,n,r)=>{let i=[];const s=o.infoData_.getNode(e._path);return s.isEmpty()||(i=G0(o.infoSyncTree_,e._path,s),setTimeout(()=>{r("ok")},0)),i},stopListening:()=>{}}),ek(o,"connected",!1),o.serverSyncTree_=new K0({startListening:(r,e,t,i)=>(o.server_.listen(r,t,e,(e,t)=>{var n=i(e,t);KE(o.eventQueue_,r._path,n)}),[]),stopListening:(e,t)=>{o.server_.unlisten(e,t)}})}function YE(e){const t=e.infoData_.getNode(new iT(".info/serverTimeOffset"));var n=t.val()||0;return(new Date).getTime()+n}function JE(e){return uE({timestamp:YE(e)})}function XE(e,t,n,r,i){e.dataUpdateCount++;var s,o,a=new iT(t);n=e.interceptServerDataCallback_?e.interceptServerDataCallback_(t,n):n;let c=[];c=i?r?(s=Ed(n,e=>XT(e)),function(e,t,n,r){if(a=iE(e,r)){var i=sE(a),s=i.path,o=i.queryId,a=fT(s,t),i=$I.fromObject(n);return oE(e,s,new OI(RI(o),a,i))}return[]}(e.serverSyncTree_,a,s,i)):(s=XT(n),function(e,t,n,r){if(null==(s=iE(e,r)))return[];var i=(o=sE(s)).path,s=o.queryId,o=fT(i,t);return oE(e,i,new DI(RI(s),o,n))}(e.serverSyncTree_,a,s,i)):r?(o=Ed(n,e=>XT(e)),t=e.serverSyncTree_,i=a,r=o,o=$I.fromObject(r),Z0(t,new OI(NI(),i,o))):(o=XT(n),G0(e.serverSyncTree_,a,o));let l=a;0<c.length&&(l=hk(e,a)),KE(e.eventQueue_,l,c)}function ZE(e,t){ek(e,"connected",t),!1===t&&function(r){ak(r,"onDisconnectEvents");const i=JE(r),s=II();kI(r.onDisconnect_,sT(),(e,t)=>{var n=fE(e,t,r.serverSyncTree_,i);EI(s,e,n)});let o=[];kI(s,sT(),(e,t)=>{o=o.concat(G0(r.serverSyncTree_,e,t));var n=gk(r,e);hk(r,n)}),r.onDisconnect_=II(),KE(r.eventQueue_,sT(),o)}(e)}function ek(e,t,n){var r=new iT("/.info/"+t),i=XT(n);e.infoData_.updateSnapshot(r,i);i=G0(e.infoSyncTree_,r,i);KE(e.eventQueue_,r,i)}function tk(e){return e.nextWriteId_++}function nk(r,i,e,t,s){ak(r,"set",{path:i.toString(),value:e,priority:t});var n=JE(r);const o=XT(e,t);var a=J0(r.serverSyncTree_,i),n=gE(o,a,n);const c=tk(r);n=$0(r.serverSyncTree_,i,n,c,!0);BE(r.eventQueue_,n),r.server_.put(i.toString(),o.val(!0),(e,t)=>{var n="ok"===e;n||Tb("set at "+i+" failed: "+e);n=H0(r.serverSyncTree_,c,!n);KE(r.eventQueue_,i,n),ck(0,s,e,t)});n=gk(r,i);hk(r,n),KE(r.eventQueue_,n,[])}function rk(n,r,i){n.server_.onDisconnectCancel(r.toString(),(e,t)=>{"ok"===e&&!function e(n,t){if(pT(t))return n.value=null,n.children.clear(),!0;if(null!==n.value){if(n.value.isLeafNode())return!1;{const i=n.value;return n.value=null,i.forEachChild(qT,(e,t)=>{EI(n,new iT(e),t)}),e(n,t)}}if(0<n.children.size){var r=oT(t);return t=cT(t),n.children.has(r)&&e(n.children.get(r),t)&&n.children.delete(r),0===n.children.size}return!0}(n.onDisconnect_,r),ck(0,i,e,t)})}function ik(n,r,e,i){const s=XT(e);n.server_.onDisconnectPut(r.toString(),s.val(!0),(e,t)=>{"ok"===e&&EI(n.onDisconnect_,r,s),ck(0,i,e,t)})}function sk(e,t,n){let r;r=".info"===oT(t._path)?Q0(e.infoSyncTree_,t,n):Q0(e.serverSyncTree_,t,n),WE(e.eventQueue_,t._path,r)}function ok(e){e.persistentConnection_&&e.persistentConnection_.interrupt(zE)}function ak(e,...t){let n="";e.persistentConnection_&&(n=e.persistentConnection_.id+":"),wb(n,...t)}function ck(e,r,i,s){r&&Mb(()=>{if("ok"===i)r(null);else{var t=(i||"error").toUpperCase();let e=t;s&&(e+=": "+s);const n=new Error(e);n.code=t,r(n)}})}function lk(e,t,n){return J0(e.serverSyncTree_,t,n)||GT.EMPTY_NODE}function uk(t,e=t.transactionQueueTree_){if(e||fk(t,e),_E(e)){const n=pk(t,e);Jh(0<n.length,"Sending zero length transaction queue"),n.every(e=>0===e.status)&&function(i,s,o){const e=o.map(e=>e.currentWriteId),t=lk(i,s,e);let n=t;var r=t.hash();for(let u=0;u<o.length;u++){const h=o[u];Jh(0===h.status,"tryToSendTransactionQueue_: items in queue should all be run."),h.status=1,h.retryCount++;var a=fT(s,h.path);n=n.updateChild(a,h.currentOutputSnapshotRaw)}const c=n.val(!0),l=s;i.server_.put(l.toString(),c,t=>{ak(i,"transaction put response",{path:l.toString(),status:t});let n=[];if("ok"===t){const r=[];for(let e=0;e<o.length;e++)o[e].status=2,n=n.concat(H0(i.serverSyncTree_,o[e].currentWriteId)),o[e].onComplete&&r.push(()=>o[e].onComplete(null,!0,o[e].currentOutputSnapshotResolved)),o[e].unwatcher();fk(i,yE(i.transactionQueueTree_,s)),uk(i,i.transactionQueueTree_),KE(i.eventQueue_,s,n);for(let t=0;t<r.length;t++)Mb(r[t])}else{if("datastale"===t)for(let e=0;e<o.length;e++)3===o[e].status?o[e].status=4:o[e].status=0;else{Tb("transaction at "+l.toString()+" failed: "+t);for(let e=0;e<o.length;e++)o[e].status=4,o[e].abortReason=t}hk(i,s)}},r)}(t,IE(e),n)}else bE(e)&&TE(e,e=>{uk(t,e)})}function hk(e,t){var n=dk(e,t),r=IE(n);return function(i,s,o){if(0!==s.length){const l=[];let n=[];const t=s.filter(e=>0===e.status),u=t.map(e=>e.currentWriteId);for(let r=0;r<s.length;r++){const h=s[r];var a=fT(o,h.path);let e=!1,t;if(Jh(null!==a,"rerunTransactionsUnderNode_: relativePath should not be null."),4===h.status)e=!0,t=h.abortReason,n=n.concat(H0(i.serverSyncTree_,h.currentWriteId,!0));else if(0===h.status)if(h.retryCount>=HE)e=!0,t="maxretry",n=n.concat(H0(i.serverSyncTree_,h.currentWriteId,!0));else{const d=lk(i,h.path,u);h.currentInputSnapshot=d;var c=s[r].update(d.val());if(void 0!==c){UE("transaction failed: Data returned ",c,h.path);let e=XT(c);"object"==typeof c&&null!=c&&bd(c,".priority")||(e=e.updatePriority(d.getPriority()));a=h.currentWriteId,c=JE(i),c=gE(e,d,c);h.currentOutputSnapshotRaw=e,h.currentOutputSnapshotResolved=c,h.currentWriteId=tk(i),u.splice(u.indexOf(a),1),n=n.concat($0(i.serverSyncTree_,h.path,c,h.currentWriteId,h.applyLocally)),n=n.concat(H0(i.serverSyncTree_,a,!0))}else e=!0,t="nodata",n=n.concat(H0(i.serverSyncTree_,h.currentWriteId,!0))}KE(i.eventQueue_,o,n),n=[],e&&(s[r].status=2,function(e){setTimeout(e,Math.floor(0))}(s[r].unwatcher),s[r].onComplete&&("nodata"===t?l.push(()=>s[r].onComplete(null,!1,s[r].currentInputSnapshot)):l.push(()=>s[r].onComplete(new Error(t),!1,null))))}fk(i,i.transactionQueueTree_);for(let e=0;e<l.length;e++)Mb(l[e]);uk(i,i.transactionQueueTree_)}}(e,pk(e,n),r),r}function dk(e,t){let n,r=e.transactionQueueTree_;for(n=oT(t);null!==n&&void 0===_E(r);)r=yE(r,n),t=cT(t),n=oT(t);return r}function pk(e,t){const n=[];return function t(n,e,r){const i=_E(e);if(i)for(let e=0;e<i.length;e++)r.push(i[e]);TE(e,e=>{t(n,e,r)})}(e,t,n),n.sort((e,t)=>e.order-t.order),n}function fk(t,n){const r=_E(n);if(r){let e=0;for(let t=0;t<r.length;t++)2!==r[t].status&&(r[e]=r[t],e++);r.length=e,wE(n,0<r.length?r:void 0)}TE(n,e=>{fk(t,e)})}function gk(t,e){var n=IE(dk(t,e)),r=yE(t.transactionQueueTree_,e);return function(e,t,n){let r=n?e:e.parent;for(;null!==r;){if(t(r))return;r=r.parent}}(r,e=>{mk(t,e)}),mk(t,r),function t(e,n,r,i){r&&!i&&n(e),TE(e,e=>{t(e,n,!0,i)}),r&&i&&n(e)}(r,e=>{mk(t,e)}),n}function mk(i,s){const o=_E(s);if(o){const a=[];let e=[],t=-1;for(let n=0;n<o.length;n++)3===o[n].status||(1===o[n].status?(Jh(t===n-1,"All SENT items should be at beginning of queue."),t=n,o[n].status=3,o[n].abortReason="set"):(Jh(0===o[n].status,"Unexpected transaction status in abort"),o[n].unwatcher(),e=e.concat(H0(i.serverSyncTree_,o[n].currentWriteId,!0)),o[n].onComplete&&a.push(o[n].onComplete.bind(null,new Error("set"),!1,null))));-1===t?wE(s,void 0):o.length=t+1,KE(i.eventQueue_,IE(s),e);for(let r=0;r<a.length;r++)Mb(a[r])}}const vk=function(e,t){var n=yk(e),r=n.namespace;"firebase.com"===n.domain&&bb(n.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),r&&"undefined"!==r||"localhost"===n.domain||bb("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),n.secure||Ib();var i="ws"===n.scheme||"wss"===n.scheme;return{repoInfo:new Bb(n.host,n.secure,r,t,i,"",r!==n.subdomain),path:new iT(n.pathString)}},yk=function(r){let i="",s="",o="",a="",c="",l=!0,u="https",h=443;if("string"==typeof r){let e=r.indexOf("//");0<=e&&(u=r.substring(0,e-1),r=r.substring(e+2));let t=r.indexOf("/");-1===t&&(t=r.length);let n=r.indexOf("?");-1===n&&(n=r.length),i=r.substring(0,Math.min(t,n)),t<n&&(a=function(e){let t="";var n=e.split("/");for(let r=0;r<n.length;r++)if(0<n[r].length){let e=n[r];try{e=decodeURIComponent(e.replace(/\+/g," "))}catch(e){}t+="/"+e}return t}(r.substring(t,n)));var d,p=function(e){const t={};for(const r of(e="?"===e.charAt(0)?e.substring(1):e).split("&")){var n;0!==r.length&&(2===(n=r.split("=")).length?t[decodeURIComponent(n[0])]=decodeURIComponent(n[1]):Tb(`Invalid query segment '${r}' in query '${e}'`))}return t}(r.substring(Math.min(r.length,n)));e=i.indexOf(":"),0<=e?(l="https"===u||"wss"===u,h=parseInt(i.substring(e+1),10)):e=i.length;const f=i.slice(0,e);"localhost"===f.toLowerCase()?s="localhost":f.split(".").length<=2?s=f:(d=i.indexOf("."),o=i.substring(0,d).toLowerCase(),s=i.substring(d+1),c=o),"ns"in p&&(c=p.ns)}return{host:i,port:h,domain:s,subdomain:o,secure:l,scheme:u,pathString:a,namespace:c}};class _k{constructor(e,t,n,r){this.eventType=e,this.eventRegistration=t,this.snapshot=n,this.prevName=r}getPath(){var e=this.snapshot.ref;return("value"===this.eventType?e:e.parent)._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+_d(this.snapshot.exportVal())}}class wk{constructor(e,t,n){this.eventRegistration=e,this.error=t,this.path=n}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}class bk{constructor(e,t){this.snapshotCallback=e,this.cancelCallback=t}onValue(e,t){this.snapshotCallback.call(null,e,t)}onCancel(e){return Jh(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,e)}get hasCancelCallback(){return!!this.cancelCallback}matches(e){return this.snapshotCallback===e.snapshotCallback||void 0!==this.snapshotCallback.userCallback&&this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&&this.snapshotCallback.context===e.snapshotCallback.context}}class Tk{constructor(e,t){this._repo=e,this._path=t}cancel(){const e=new rd;return rk(this._repo,this._path,e.wrapCallback(()=>{})),e.promise}remove(){RE("OnDisconnect.remove",this._path);const e=new rd;return ik(this._repo,this._path,null,e.wrapCallback(()=>{})),e.promise}set(e){RE("OnDisconnect.set",this._path),kE("OnDisconnect.set",e,this._path,!1);const t=new rd;return ik(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}setWithPriority(e,t){RE("OnDisconnect.setWithPriority",this._path),kE("OnDisconnect.setWithPriority",e,this._path,!1),CE("OnDisconnect.setWithPriority",t,!1);const n=new rd;return function(n,r,e,t,i){const s=XT(e,t);n.server_.onDisconnectPut(r.toString(),s.val(!0),(e,t)=>{"ok"===e&&EI(n.onDisconnect_,r,s),ck(0,i,e,t)})}(this._repo,this._path,e,t,n.wrapCallback(()=>{})),n.promise}update(e){RE("OnDisconnect.update",this._path),SE("OnDisconnect.update",e,this._path,!1);const t=new rd;return function(r,i,n,s){if(Id(n))return wb("onDisconnect().update() called with empty data. Don't do anything."),ck(0,s,"ok",void 0);r.server_.onDisconnectMerge(i.toString(),n,(e,t)=>{"ok"===e&&Ab(n,(e,t)=>{var n=XT(t);EI(r.onDisconnect_,dT(i,e),n)}),ck(0,s,e,t)})}(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}}class Ik{constructor(e,t,n,r){this._repo=e,this._path=t,this._queryParams=n,this._orderByCalled=r}get key(){return pT(this._path)?null:lT(this._path)}get ref(){return new Ck(this._repo,this._path)}get _queryIdentifier(){var e=wI(this._queryParams),e=vb(e);return"{}"===e?"default":e}get _queryObject(){return wI(this._queryParams)}isEqual(e){if(!((e=Kd(e))instanceof Ik))return!1;var t=this._repo===e._repo,n=mT(this._path,e._path),r=this._queryIdentifier===e._queryIdentifier;return t&&n&&r}toJSON(){return this.toString()}toString(){return this._repo.toString()+function(e){let t="";for(let n=e.pieceNum_;n<e.pieces_.length;n++)""!==e.pieces_[n]&&(t+="/"+encodeURIComponent(String(e.pieces_[n])));return t||"/"}(this._path)}}function Ek(e,t){if(!0===e._orderByCalled)throw new Error(t+": You can't combine multiple orderBy calls.")}function kk(e){let t=null,n=null;if(e.hasStart()&&(t=e.getIndexStartValue()),e.hasEnd()&&(n=e.getIndexEndValue()),e.getIndex()===CT){var r="Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().",i="Query: When ordering by key, the argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() must be a string.";if(e.hasStart()){if(e.getIndexStartName()!==kb)throw new Error(r);if("string"!=typeof t)throw new Error(i)}if(e.hasEnd()){if(e.getIndexEndName()!==Sb)throw new Error(r);if("string"!=typeof n)throw new Error(i)}}else if(e.getIndex()===qT){if(null!=t&&!FE(t)||null!=n&&!FE(n))throw new Error("Query: When ordering by priority, the first argument passed to startAt(), startAfter() endAt(), endBefore(), or equalTo() must be a valid priority value (null, a number, or a string).")}else if(Jh(e.getIndex()instanceof ZT||e.getIndex()===nI,"unknown index type."),null!=t&&"object"==typeof t||null!=n&&"object"==typeof n)throw new Error("Query: First argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() cannot be an object.")}function Sk(e){if(e.hasStart()&&e.hasEnd()&&e.hasLimit()&&!e.hasAnchoredLimit())throw new Error("Query: Can't combine startAt(), startAfter(), endAt(), endBefore(), and limit(). Use limitToFirst() or limitToLast() instead.")}class Ck extends Ik{constructor(e,t){super(e,t,new gI,!1)}get parent(){var e=hT(this._path);return null===e?null:new Ck(this._repo,e)}get root(){let e=this;for(;null!==e.parent;)e=e.parent;return e}}class Ak{constructor(e,t,n){this._node=e,this.ref=t,this._index=n}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){var t=new iT(e),n=Pk(this.ref,e);return new Ak(this._node.getChild(t),n,qT)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(n){if(this._node.isLeafNode())return!1;const e=this._node;return!!e.forEachChild(this._index,(e,t)=>n(new Ak(t,Pk(this.ref,e),qT)))}hasChild(e){var t=new iT(e);return!this._node.getChild(t).isEmpty()}hasChildren(){return!this._node.isLeafNode()&&!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function Nk(e,t){return(e=Kd(e))._checkNotDeleted("ref"),void 0!==t?Pk(e._root,t):e._root}function Rk(e,t){(e=Kd(e))._checkNotDeleted("refFromURL");const n=vk(t,e._repo.repoInfo_.nodeAdmin);qE("refFromURL",n);var r=n.repoInfo;return e._repo.repoInfo_.isCustomHost()||r.host===e._repo.repoInfo_.host||bb("refFromURL: Host name does not match the current database: (found "+r.host+" but expected "+e._repo.repoInfo_.host+")"),Nk(e,n.path.toString())}function Pk(e,t){return(null===oT((e=Kd(e))._path)?NE:jE)("child","path",t,!1),new Ck(e._repo,dT(e._path,t))}function xk(e,t){e=Kd(e),RE("set",e._path),kE("set",t,e._path,!1);const n=new rd;return nk(e._repo,e._path,t,null,n.wrapCallback(()=>{})),n.promise}function Dk(e,t){SE("update",t,e._path,!1);const n=new rd;return function(i,s,e,o){ak(i,"update",{path:s.toString(),value:e});let n=!0;const r=JE(i),a={};if(Ab(e,(e,t)=>{n=!1,a[e]=fE(dT(s,e),XT(t),i.serverSyncTree_,r)}),n)wb("update() called with empty data. Don't do anything."),ck(0,o,"ok",void 0);else{const c=tk(i);var t=z0(i.serverSyncTree_,s,a,c);BE(i.eventQueue_,t),i.server_.merge(s.toString(),e,(e,t)=>{var n="ok"===e;n||Tb("update at "+s+" failed: "+e);var r=H0(i.serverSyncTree_,c,!n),n=0<r.length?hk(i,s):s;KE(i.eventQueue_,n,r),ck(0,o,e,t)}),Ab(e,e=>{var t=gk(i,dT(s,e));hk(i,t)}),KE(i.eventQueue_,s,[])}}(e._repo,e._path,t,n.wrapCallback(()=>{})),n.promise}function Ok(t){return t=Kd(t),r=t._repo,i=t,(null!=(e=X0(r.serverSyncTree_,i))?Promise.resolve(e):r.server_.get(i).then(e=>{var t=XT(e).withIndex(i._queryParams.getIndex()),n=G0(r.serverSyncTree_,i._path,t);return WE(r.eventQueue_,i._path,n),Promise.resolve(t)},e=>(ak(r,"get for query "+_d(i)+" failed: "+e),Promise.reject(new Error(e))))).then(e=>new Ak(e,new Ck(t._repo,t._path),t._queryParams.getIndex()));var r,i,e}class Mk{constructor(e){this.callbackContext=e}respondsTo(e){return"value"===e}createEvent(e,t){var n=t._queryParams.getIndex();return new _k("value",this,new Ak(e.snapshotNode,new Ck(t._repo,t._path),n))}getEventRunner(e){return"cancel"===e.getEventType()?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new wk(this,e,t):null}matches(e){return e instanceof Mk&&(!e.callbackContext||!this.callbackContext||e.callbackContext.matches(this.callbackContext))}hasAnyCallback(){return null!==this.callbackContext}}class Lk{constructor(e,t){this.eventType=e,this.callbackContext=t}respondsTo(e){let t="children_added"===e?"child_added":e;return t="children_removed"===t?"child_removed":t,this.eventType===t}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new wk(this,e,t):null}createEvent(e,t){Jh(null!=e.childName,"Child events should have a childName.");var n=Pk(new Ck(t._repo,t._path),e.childName),r=t._queryParams.getIndex();return new _k(e.type,this,new Ak(e.snapshotNode,n,r),e.prevName)}getEventRunner(e){return"cancel"===e.getEventType()?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,e.prevName)}matches(e){return e instanceof Lk&&(this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)))}hasAnyCallback(){return!!this.callbackContext}}function Fk(n,e,t,r,i){let s;if("object"==typeof r&&(s=void 0,i=r),"function"==typeof r&&(s=r),i&&i.onlyOnce){const c=t;var o=(e,t)=>{sk(n._repo,n,a),c(e,t)};o.userCallback=t.userCallback,o.context=t.context,t=o}o=new bk(t,s||void 0);const a="value"===e?new Mk(o):new Lk(e,o);return function(e,t,n){let r;r=".info"===oT(t._path)?Y0(e.infoSyncTree_,t,n):Y0(e.serverSyncTree_,t,n),WE(e.eventQueue_,t._path,r)}(n._repo,n,a),()=>sk(n._repo,n,a)}function Uk(e,t,n,r){return Fk(e,"value",t,n,r)}function jk(e,t,n,r){return Fk(e,"child_added",t,n,r)}function qk(e,t,n,r){return Fk(e,"child_changed",t,n,r)}function Vk(e,t,n,r){return Fk(e,"child_moved",t,n,r)}function Bk(e,t,n,r){return Fk(e,"child_removed",t,n,r)}function Wk(e,t,n){let r=null;var i=n?new bk(n):null;"value"===t?r=new Mk(i):t&&(r=new Lk(t,i)),sk(e._repo,e,r)}class Kk{}class $k extends Kk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){kE("endAt",this._value,e._path,!0);var t=vI(e._queryParams,this._value,this._key);if(Sk(t),kk(t),e._queryParams.hasEnd())throw new Error("endAt: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new Ik(e._repo,e._path,t,e._orderByCalled)}}class zk extends Kk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){kE("endBefore",this._value,e._path,!1);var t=function(e,t,n){let r,i;return i=e.index_===CT?vI(e,t="string"==typeof t?tI(t):t,n):(r=null==n?kb:tI(n),vI(e,t,r)),i.endBeforeSet_=!0,i}(e._queryParams,this._value,this._key);if(Sk(t),kk(t),e._queryParams.hasEnd())throw new Error("endBefore: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new Ik(e._repo,e._path,t,e._orderByCalled)}}class Hk extends Kk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){kE("startAt",this._value,e._path,!0);var t=mI(e._queryParams,this._value,this._key);if(Sk(t),kk(t),e._queryParams.hasStart())throw new Error("startAt: Starting point was already set (by another call to startAt, startBefore or equalTo).");return new Ik(e._repo,e._path,t,e._orderByCalled)}}class Gk extends Kk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){kE("startAfter",this._value,e._path,!1);var t=function(t,n,r){let i;if(t.index_===CT)"string"==typeof n&&(n=eI(n)),i=mI(t,n,r);else{let e;e=null==r?Sb:eI(r),i=mI(t,n,e)}return i.startAfterSet_=!0,i}(e._queryParams,this._value,this._key);if(Sk(t),kk(t),e._queryParams.hasStart())throw new Error("startAfter: Starting point was already set (by another call to startAt, startAfter, or equalTo).");return new Ik(e._repo,e._path,t,e._orderByCalled)}}class Qk extends Kk{constructor(e){super(),this._limit=e}_apply(e){if(e._queryParams.hasLimit())throw new Error("limitToFirst: Limit was already set (by another call to limitToFirst or limitToLast).");return new Ik(e._repo,e._path,function(e,t){const n=e.copy();return n.limitSet_=!0,n.limit_=t,n.viewFrom_="l",n}(e._queryParams,this._limit),e._orderByCalled)}}class Yk extends Kk{constructor(e){super(),this._limit=e}_apply(e){if(e._queryParams.hasLimit())throw new Error("limitToLast: Limit was already set (by another call to limitToFirst or limitToLast).");return new Ik(e._repo,e._path,function(e,t){const n=e.copy();return n.limitSet_=!0,n.limit_=t,n.viewFrom_="r",n}(e._queryParams,this._limit),e._orderByCalled)}}class Jk extends Kk{constructor(e){super(),this._path=e}_apply(e){Ek(e,"orderByChild");var t=new iT(this._path);if(pT(t))throw new Error("orderByChild: cannot pass in empty path. Use orderByValue() instead.");t=new ZT(t),t=yI(e._queryParams,t);return kk(t),new Ik(e._repo,e._path,t,!0)}}class Xk extends Kk{_apply(e){Ek(e,"orderByKey");var t=yI(e._queryParams,CT);return kk(t),new Ik(e._repo,e._path,t,!0)}}class Zk extends Kk{_apply(e){Ek(e,"orderByPriority");var t=yI(e._queryParams,qT);return kk(t),new Ik(e._repo,e._path,t,!0)}}class eS extends Kk{_apply(e){Ek(e,"orderByValue");var t=yI(e._queryParams,nI);return kk(t),new Ik(e._repo,e._path,t,!0)}}class tS extends Kk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){if(kE("equalTo",this._value,e._path,!1),e._queryParams.hasStart())throw new Error("equalTo: Starting point was already set (by another call to startAt/startAfter or equalTo).");if(e._queryParams.hasEnd())throw new Error("equalTo: Ending point was already set (by another call to endAt/endBefore or equalTo).");return new $k(this._value,this._key)._apply(new Hk(this._value,this._key)._apply(e))}}function nS(e,...t){let n=Kd(e);for(const r of t)n=r._apply(n);return n}nb=Ck,Jh(!R0,"__referenceConstructor has already been defined"),R0=nb,rb=Ck,Jh(!B0,"__referenceConstructor has already been defined"),B0=rb;const rS="FIREBASE_DATABASE_EMULATOR_HOST",iS={};let sS=!1;function oS(e,t,n,r,i){let s=r||e.options.databaseURL;void 0===s&&(e.options.projectId||bb("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),wb("Using default host for project ",e.options.projectId),s=`${e.options.projectId}-default-rtdb.firebaseio.com`);let o=vk(s,i),a=o.repoInfo,c,l=void 0;"undefined"!=typeof process&&(l=process.env[rS]),l?(c=!0,s=`http://${l}?ns=${a.namespace}`,o=vk(s,i),a=o.repoInfo):c=!o.repoInfo.secure;var u=i&&c?new Ub(Ub.OWNER):new Fb(e.name,e.options,t);qE("Invalid Firebase Database URL",o),pT(o.path)||bb("Database URL must point to the root of a Firebase Database (not including a child path).");u=function(e,t,n,r){let i=iS[t.name];i||(i={},iS[t.name]=i);var s=i[e.toURLString()];s&&bb("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call.");return s=new GE(e,sS,n,r),i[e.toURLString()]=s}(a,e,u,new Lb(e.name,n));return new aS(u,e)}class aS{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(QE(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new Ck(this._repo,sT())),this._rootInternal}_delete(){return null!==this._rootInternal&&(function(e,t){const n=iS[t];n&&n[e.key]===e||bb(`Database ${t}(${e.repoInfo_}) has already been deleted.`),ok(e),delete n[e.key]}(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){null===this._rootInternal&&bb("Cannot call "+e+" on a deleted database.")}}function cS(e,t,n,r={}){(e=Kd(e))._checkNotDeleted("useEmulator"),e._instanceStarted&&bb("Cannot call useEmulator() after instance has already been initialized.");var i,s=e._repoInternal;let o=void 0;s.repoInfo_.nodeAdmin?(r.mockUserToken&&bb('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new Ub(Ub.OWNER)):r.mockUserToken&&(i="string"==typeof r.mockUserToken?r.mockUserToken:id(r.mockUserToken,e.app.options.projectId),o=new Ub(i)),r=s,e=t,t=n,n=o,r.repoInfo_=new Bb(`${e}:${t}`,!1,r.repoInfo_.namespace,r.repoInfo_.webSocketOnly,r.repoInfo_.nodeAdmin,r.repoInfo_.persistenceKey,r.repoInfo_.includeNamespaceInQueryParams),n&&(r.authTokenProvider_=n)}function lS(e){(e=Kd(e))._checkNotDeleted("goOnline"),(e=e._repo).persistentConnection_&&e.persistentConnection_.resume(zE)}function uS(e,t){_b(e,t)}const hS={".sv":"timestamp"};class dS{constructor(e,t){this.committed=e,this.snapshot=t}toJSON(){return{committed:this.committed,snapshot:this.snapshot.toJSON()}}}function pS(i,e,t){if(i=Kd(i),RE("Reference.transaction",i._path),".length"===i.key||".keys"===i.key)throw"Reference.transaction failed: "+i.key+" is a read-only object.";var n=null===(r=null==t?void 0:t.applyLocally)||void 0===r||r;const s=new rd;var r=Uk(i,()=>{});return function(t,n,e,r,i,s){ak(t,"transaction on "+n);const o={path:n,update:e,onComplete:r,status:null,order:lb(),applyLocally:s,retryCount:0,unwatcher:i,abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},a=lk(t,n,void 0);o.currentInputSnapshot=a;var c=o.update(a.val());if(void 0===c)o.unwatcher(),o.currentOutputSnapshotRaw=null,o.currentOutputSnapshotResolved=null,o.onComplete&&o.onComplete(null,!1,o.currentInputSnapshot);else{UE("transaction failed: Data returned ",c,o.path),o.status=0;var l=yE(t.transactionQueueTree_,n);const u=_E(l)||[];u.push(o),wE(l,u);let e;if("object"==typeof c&&null!==c&&bd(c,".priority"))e=Td(c,".priority"),Jh(FE(e),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.");else{const h=J0(t.serverSyncTree_,n)||GT.EMPTY_NODE;e=h.getPriority().val()}l=JE(t),c=XT(c,e),l=gE(c,a,l);o.currentOutputSnapshotRaw=c,o.currentOutputSnapshotResolved=l,o.currentWriteId=tk(t);l=$0(t.serverSyncTree_,n,l,o.currentWriteId,o.applyLocally);KE(t.eventQueue_,n,l),uk(t,t.transactionQueueTree_)}}(i._repo,i._path,e,(e,t,n)=>{var r;e?s.reject(e):(r=new Ak(n,new Ck(i._repo,i._path),qT),s.resolve(new dS(t,r)))},r,n),s.promise}TT.prototype.simpleListen=function(e,t){this.sendRequest("q",{p:e},t)},TT.prototype.echo=function(e,t){this.sendRequest("echo",{d:e},t)},Yw(gp),hp(new $d("database",(e,{instanceIdentifier:t})=>{return oS(e.getProvider("app").getImmediate(),e.getProvider("auth-internal"),e.getProvider("app-check-internal"),t)},"PUBLIC").setMultipleInstances(!0)),_p(Gw,"0.12.5",ib),_p(Gw,"0.12.5","esm2017");function fS(e){var t="FIREBASE WARNING: "+e;gS.warn(t)}const gS=new ep("@firebase/database-compat");class mS{constructor(e){this._delegate=e}cancel(t){Od("OnDisconnect.cancel",0,1,arguments.length),Ld("OnDisconnect.cancel","onComplete",t,!0);const e=this._delegate.cancel();return t&&e.then(()=>t(null),e=>t(e)),e}remove(t){Od("OnDisconnect.remove",0,1,arguments.length),Ld("OnDisconnect.remove","onComplete",t,!0);const e=this._delegate.remove();return t&&e.then(()=>t(null),e=>t(e)),e}set(e,t){Od("OnDisconnect.set",1,2,arguments.length),Ld("OnDisconnect.set","onComplete",t,!0);const n=this._delegate.set(e);return t&&n.then(()=>t(null),e=>t(e)),n}setWithPriority(e,t,n){Od("OnDisconnect.setWithPriority",2,3,arguments.length),Ld("OnDisconnect.setWithPriority","onComplete",n,!0);const r=this._delegate.setWithPriority(e,t);return n&&r.then(()=>n(null),e=>n(e)),r}update(t,n){if(Od("OnDisconnect.update",1,2,arguments.length),Array.isArray(t)){const r={};for(let e=0;e<t.length;++e)r[""+e]=t[e];t=r,fS("Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}Ld("OnDisconnect.update","onComplete",n,!0);const e=this._delegate.update(t);return n&&e.then(()=>n(null),e=>n(e)),e}}class vS{constructor(e,t){this.committed=e,this.snapshot=t}toJSON(){return Od("TransactionResult.toJSON",0,1,arguments.length),{committed:this.committed,snapshot:this.snapshot.toJSON()}}}class yS{constructor(e,t){this._database=e,this._delegate=t}val(){return Od("DataSnapshot.val",0,0,arguments.length),this._delegate.val()}exportVal(){return Od("DataSnapshot.exportVal",0,0,arguments.length),this._delegate.exportVal()}toJSON(){return Od("DataSnapshot.toJSON",0,1,arguments.length),this._delegate.toJSON()}exists(){return Od("DataSnapshot.exists",0,0,arguments.length),this._delegate.exists()}child(e){return Od("DataSnapshot.child",0,1,arguments.length),e=String(e),jE("DataSnapshot.child","path",e,!1),new yS(this._database,this._delegate.child(e))}hasChild(e){return Od("DataSnapshot.hasChild",1,1,arguments.length),jE("DataSnapshot.hasChild","path",e,!1),this._delegate.hasChild(e)}getPriority(){return Od("DataSnapshot.getPriority",0,0,arguments.length),this._delegate.priority}forEach(t){return Od("DataSnapshot.forEach",1,1,arguments.length),Ld("DataSnapshot.forEach","action",t,!1),this._delegate.forEach(e=>t(new yS(this._database,e)))}hasChildren(){return Od("DataSnapshot.hasChildren",0,0,arguments.length),this._delegate.hasChildren()}get key(){return this._delegate.key}numChildren(){return Od("DataSnapshot.numChildren",0,0,arguments.length),this._delegate.size}getRef(){return Od("DataSnapshot.ref",0,0,arguments.length),new wS(this._database,this._delegate.ref)}get ref(){return this.getRef()}}class _S{constructor(e,t){this.database=e,this._delegate=t}on(e,n,t,r){var i;Od("Query.on",2,4,arguments.length),Ld("Query.on","callback",n,!1);const s=_S.getCancelAndContextArgs_("Query.on",t,r);var o=(e,t)=>{n.call(s.context,new yS(this.database,e),t)};o.userCallback=n,o.context=s.context;var a=null===(i=s.cancel)||void 0===i?void 0:i.bind(s.context);switch(e){case"value":return Uk(this._delegate,o,a),n;case"child_added":return jk(this._delegate,o,a),n;case"child_removed":return Bk(this._delegate,o,a),n;case"child_changed":return qk(this._delegate,o,a),n;case"child_moved":return Vk(this._delegate,o,a),n;default:throw new Error(Md("Query.on","eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}}off(e,t,n){var r;Od("Query.off",0,3,arguments.length),function(e,t,n){if(!n||void 0!==t)switch(t){case"value":case"child_added":case"child_removed":case"child_changed":case"child_moved":break;default:throw new Error(Md(e,"eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}}("Query.off",e,!0),Ld("Query.off","callback",t,!0),Fd("Query.off","context",n,!0),t?((r=()=>{}).userCallback=t,r.context=n,Wk(this._delegate,e,r)):Wk(this._delegate,e)}get(){return Ok(this._delegate).then(e=>new yS(this.database,e))}once(e,r,t,n){Od("Query.once",1,4,arguments.length),Ld("Query.once","callback",r,!0);const i=_S.getCancelAndContextArgs_("Query.once",t,n),s=new rd;var o=(e,t)=>{var n=new yS(this.database,e);r&&r.call(i.context,n,t),s.resolve(n)};o.userCallback=r,o.context=i.context;var a=e=>{i.cancel&&i.cancel.call(i.context,e),s.reject(e)};switch(e){case"value":Uk(this._delegate,o,a,{onlyOnce:!0});break;case"child_added":jk(this._delegate,o,a,{onlyOnce:!0});break;case"child_removed":Bk(this._delegate,o,a,{onlyOnce:!0});break;case"child_changed":qk(this._delegate,o,a,{onlyOnce:!0});break;case"child_moved":Vk(this._delegate,o,a,{onlyOnce:!0});break;default:throw new Error(Md("Query.once","eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}return s.promise}limitToFirst(e){return Od("Query.limitToFirst",1,1,arguments.length),new _S(this.database,nS(this._delegate,function(e){if("number"!=typeof e||Math.floor(e)!==e||e<=0)throw new Error("limitToFirst: First argument must be a positive integer.");return new Qk(e)}(e)))}limitToLast(e){return Od("Query.limitToLast",1,1,arguments.length),new _S(this.database,nS(this._delegate,function(e){if("number"!=typeof e||Math.floor(e)!==e||e<=0)throw new Error("limitToLast: First argument must be a positive integer.");return new Yk(e)}(e)))}orderByChild(e){return Od("Query.orderByChild",1,1,arguments.length),new _S(this.database,nS(this._delegate,function(e){if("$key"===e)throw new Error('orderByChild: "$key" is invalid. Use orderByKey() instead.');if("$priority"===e)throw new Error('orderByChild: "$priority" is invalid. Use orderByPriority() instead.');if("$value"===e)throw new Error('orderByChild: "$value" is invalid. Use orderByValue() instead.');return jE("orderByChild","path",e,!1),new Jk(e)}(e)))}orderByKey(){return Od("Query.orderByKey",0,0,arguments.length),new _S(this.database,nS(this._delegate,new Xk))}orderByPriority(){return Od("Query.orderByPriority",0,0,arguments.length),new _S(this.database,nS(this._delegate,new Zk))}orderByValue(){return Od("Query.orderByValue",0,0,arguments.length),new _S(this.database,nS(this._delegate,new eS))}startAt(e=null,t){return Od("Query.startAt",0,2,arguments.length),new _S(this.database,nS(this._delegate,([e=null,t]=[e,t],AE("startAt","key",t,!0),new Hk(e,t))))}startAfter(e=null,t){return Od("Query.startAfter",0,2,arguments.length),new _S(this.database,nS(this._delegate,(e=e,t=t,AE("startAfter","key",t,!0),new Gk(e,t))))}endAt(e=null,t){return Od("Query.endAt",0,2,arguments.length),new _S(this.database,nS(this._delegate,(e=e,t=t,AE("endAt","key",t,!0),new $k(e,t))))}endBefore(e=null,t){return Od("Query.endBefore",0,2,arguments.length),new _S(this.database,nS(this._delegate,(e=e,t=t,AE("endBefore","key",t,!0),new zk(e,t))))}equalTo(e,t){return Od("Query.equalTo",1,2,arguments.length),new _S(this.database,nS(this._delegate,(e=e,t=t,AE("equalTo","key",t,!0),new tS(e,t))))}toString(){return Od("Query.toString",0,0,arguments.length),this._delegate.toString()}toJSON(){return Od("Query.toJSON",0,1,arguments.length),this._delegate.toJSON()}isEqual(e){if(Od("Query.isEqual",1,1,arguments.length),e instanceof _S)return this._delegate.isEqual(e._delegate);throw new Error("Query.isEqual failed: First argument must be an instance of firebase.database.Query.")}static getCancelAndContextArgs_(e,t,n){const r={cancel:void 0,context:void 0};if(t&&n)r.cancel=t,Ld(e,"cancel",r.cancel,!0),r.context=n,Fd(e,"context",r.context,!0);else if(t)if("object"==typeof t&&null!==t)r.context=t;else{if("function"!=typeof t)throw new Error(Md(e,"cancelOrContext")+" must either be a cancel callback or a context object.");r.cancel=t}return r}get ref(){return new wS(this.database,new Ck(this._delegate._repo,this._delegate._path))}}class wS extends _S{constructor(e,t){super(e,new Ik(t._repo,t._path,new gI,!1)),this.database=e,this._delegate=t}getKey(){return Od("Reference.key",0,0,arguments.length),this._delegate.key}child(e){return Od("Reference.child",1,1,arguments.length),"number"==typeof e&&(e=String(e)),new wS(this.database,Pk(this._delegate,e))}getParent(){Od("Reference.parent",0,0,arguments.length);var e=this._delegate.parent;return e?new wS(this.database,e):null}getRoot(){return Od("Reference.root",0,0,arguments.length),new wS(this.database,this._delegate.root)}set(e,t){Od("Reference.set",1,2,arguments.length),Ld("Reference.set","onComplete",t,!0);const n=xk(this._delegate,e);return t&&n.then(()=>t(null),e=>t(e)),n}update(t,n){if(Od("Reference.update",1,2,arguments.length),Array.isArray(t)){const r={};for(let e=0;e<t.length;++e)r[""+e]=t[e];t=r,fS("Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}RE("Reference.update",this._delegate._path),Ld("Reference.update","onComplete",n,!0);const e=Dk(this._delegate,t);return n&&e.then(()=>n(null),e=>n(e)),e}setWithPriority(e,t,n){Od("Reference.setWithPriority",2,3,arguments.length),Ld("Reference.setWithPriority","onComplete",n,!0);const r=function(e,t,n){if(RE("setWithPriority",e._path),kE("setWithPriority",t,e._path,!1),CE("setWithPriority",n,!1),".length"===e.key||".keys"===e.key)throw"setWithPriority failed: "+e.key+" is a read-only object.";const r=new rd;return nk(e._repo,e._path,t,n,r.wrapCallback(()=>{})),r.promise}(this._delegate,e,t);return n&&r.then(()=>n(null),e=>n(e)),r}remove(t){Od("Reference.remove",0,1,arguments.length),Ld("Reference.remove","onComplete",t,!0);const e=(n=this._delegate,RE("remove",n._path),xk(n,null));var n;return t&&e.then(()=>t(null),e=>t(e)),e}transaction(e,t,n){Od("Reference.transaction",1,3,arguments.length),Ld("Reference.transaction","transactionUpdate",e,!1),Ld("Reference.transaction","onComplete",t,!0),function(e,t,n,r){if((!r||void 0!==n)&&"boolean"!=typeof n)throw new Error(Md(e,t)+"must be a boolean.")}("Reference.transaction","applyLocally",n,!0);const r=pS(this._delegate,e,{applyLocally:n}).then(e=>new vS(e.committed,new yS(this.database,e.snapshot)));return t&&r.then(e=>t(null,e.committed,e.snapshot),e=>t(e,!1,null)),r}setPriority(e,t){Od("Reference.setPriority",1,2,arguments.length),Ld("Reference.setPriority","onComplete",t,!0);const n=function(e,t){e=Kd(e),RE("setPriority",e._path),CE("setPriority",t,!1);const n=new rd;return nk(e._repo,dT(e._path,".priority"),t,null,n.wrapCallback(()=>{})),n.promise}(this._delegate,e);return t&&n.then(()=>t(null),e=>t(e)),n}push(e,t){Od("Reference.push",0,2,arguments.length),Ld("Reference.push","onComplete",t,!0);const n=function(e,t){e=Kd(e),RE("push",e._path),kE("push",t,e._path,!0);var n=YE(e._repo),n=aI(n);const r=Pk(e,n),i=Pk(e,n);let s;return s=null!=t?xk(i,t).then(()=>i):Promise.resolve(i),r.then=s.then.bind(s),r.catch=s.then.bind(s,void 0),r}(this._delegate,e),r=n.then(e=>new wS(this.database,e));t&&r.then(()=>t(null),e=>t(e));const i=new wS(this.database,n);return i.then=r.then.bind(r),i.catch=r.catch.bind(r,void 0),i}onDisconnect(){return RE("Reference.onDisconnect",this._delegate._path),new mS(new Tk(this._delegate._repo,this._delegate._path))}get key(){return this.getKey()}get parent(){return this.getParent()}get root(){return this.getRoot()}}class bS{constructor(e,t){this._delegate=e,this.app=t,this.INTERNAL={delete:()=>this._delegate._delete()}}useEmulator(e,t,n={}){cS(this._delegate,e,t,n)}ref(e){if(Od("database.ref",0,1,arguments.length),e instanceof wS){var t=Rk(this._delegate,e.toString());return new wS(this,t)}t=Nk(this._delegate,e);return new wS(this,t)}refFromURL(e){Od("database.refFromURL",1,1,arguments.length);var t=Rk(this._delegate,e);return new wS(this,t)}goOffline(){var e;Od("database.goOffline",0,0,arguments.length),(e=Kd(e=this._delegate))._checkNotDeleted("goOffline"),ok(e._repo)}goOnline(){return Od("database.goOnline",0,0,arguments.length),lS(this._delegate)}}bS.ServerValue={TIMESTAMP:hS,increment:e=>({".sv":{increment:e}})};var TS,IS=Object.freeze({__proto__:null,initStandalone:function({app:e,url:t,version:n,customAuthImpl:r,namespace:i,nodeAdmin:s=!1}){Yw(n);const o=new Hd("auth-internal",new Gd("database-standalone"));return o.setComponent(new $d("auth-internal",()=>r,"PRIVATE")),{instance:new bS(oS(e,o,void 0,t,s),e),namespace:i}}});const ES=bS.ServerValue;(TS=Cp).INTERNAL.registerComponent(new $d("database-compat",(e,{instanceIdentifier:t})=>{var n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("database").getImmediate({identifier:t});return new bS(r,n)},"PUBLIC").setServiceProps({Reference:wS,Query:_S,Database:bS,DataSnapshot:yS,enableLogging:uS,INTERNAL:IS,ServerValue:ES}).setMultipleInstances(!0)),TS.registerVersion("@firebase/database-compat","0.1.5");var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},kS={},SS=l||self;function CS(){}function AS(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 NS(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}var RS="closure_uid_"+(1e9*Math.random()>>>0),PS=0;function xS(e,t,n){return e.call.apply(e.bind,arguments)}function DS(t,n,e){if(!t)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var e=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(e,r),t.apply(n,e)}}return function(){return t.apply(n,arguments)}}function OS(e,t,n){return(OS=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?xS:DS).apply(null,arguments)}function MS(t){var n=Array.prototype.slice.call(arguments,1);return function(){var e=n.slice();return e.push.apply(e,arguments),t.apply(this,e)}}function LS(e,s){function t(){}t.prototype=s.prototype,e.Z=s.prototype,e.prototype=new t,(e.prototype.constructor=e).Vb=function(e,t,n){for(var r=Array(arguments.length-2),i=2;i<arguments.length;i++)r[i-2]=arguments[i];return s.prototype[t].apply(e,r)}}function FS(){this.s=this.s,this.o=this.o}var US={};FS.prototype.s=!1,FS.prototype.na=function(){var e,t;!this.s&&(this.s=!0,this.M(),0)&&(t=this,e=Object.prototype.hasOwnProperty.call(t,RS)&&t[RS]||(t[RS]=++PS),delete US[e])},FS.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};const jS=Array.prototype.indexOf?function(e,t){return Array.prototype.indexOf.call(e,t,void 0)}:function(e,t){if("string"==typeof e)return"string"!=typeof t||1!=t.length?-1:e.indexOf(t,0);for(let n=0;n<e.length;n++)if(n in e&&e[n]===t)return n;return-1},qS=Array.prototype.forEach?function(e,t,n){Array.prototype.forEach.call(e,t,n)}:function(e,t,n){var r=e.length,i="string"==typeof e?e.split(""):e;for(let s=0;s<r;s++)s in i&&t.call(n,i[s],s,e)};function VS(){return Array.prototype.concat.apply([],arguments)}function BS(t){var n=t.length;if(0<n){const r=Array(n);for(let e=0;e<n;e++)r[e]=t[e];return r}return[]}function WS(e){return/^[\s\xa0]*$/.test(e)}var KS,$S=String.prototype.trim?function(e){return e.trim()}:function(e){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(e)[1]};function zS(e,t){return-1!=e.indexOf(t)}function HS(e,t){return e<t?-1:t<e?1:0}e:{var GS=SS.navigator;if(GS){GS=GS.userAgent;if(GS){KS=GS;break e}}KS=""}function QS(e,t,n){for(const r in e)t.call(n,e[r],r,e)}function YS(e){const t={};for(const n in e)t[n]=e[n];return t}var JS="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function XS(t){let n,r;for(let i=1;i<arguments.length;i++){for(n in r=arguments[i])t[n]=r[n];for(let e=0;e<JS.length;e++)n=JS[e],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function ZS(e){return ZS[" "](e),e}ZS[" "]=CS;var eC,tC=zS(KS,"Opera"),nC=zS(KS,"Trident")||zS(KS,"MSIE"),rC=zS(KS,"Edge"),iC=rC||nC,sC=zS(KS,"Gecko")&&!(zS(KS.toLowerCase(),"webkit")&&!zS(KS,"Edge"))&&!(zS(KS,"Trident")||zS(KS,"MSIE"))&&!zS(KS,"Edge"),oC=zS(KS.toLowerCase(),"webkit")&&!zS(KS,"Edge");function aC(){var e=SS.document;return e?e.documentMode:void 0}e:{var cC="",lC=(lC=KS,sC?/rv:([^\);]+)(\)|;)/.exec(lC):rC?/Edge\/([\d\.]+)/.exec(lC):nC?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(lC):oC?/WebKit\/(\S+)/.exec(lC):tC?/(?:Version)[ \/]?(\S+)/.exec(lC):void 0);if(lC&&(cC=lC?lC[1]:""),nC){lC=aC();if(null!=lC&&lC>parseFloat(cC)){eC=String(lC);break e}}eC=cC}var uC={};function hC(){return e=function(){let e=0;var t=$S(String(eC)).split("."),n=$S("9").split("."),r=Math.max(t.length,n.length);for(let o=0;0==e&&o<r;o++)for(var i=t[o]||"",s=n[o]||"";i=/(\d*)(\D*)(.*)/.exec(i)||["","","",""],s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],(0!=i[0].length||0!=s[0].length)&&(e=HS(0==i[1].length?0:parseInt(i[1],10),0==s[1].length?0:parseInt(s[1],10))||HS(0==i[2].length,0==s[2].length)||HS(i[2],s[2]),i=i[3],s=s[3],0==e););return 0<=e},t=uC,Object.prototype.hasOwnProperty.call(t,9)?t[9]:t[9]=e(9);var e,t}var dC=SS.document&&nC&&(aC()||parseInt(eC,10))||void 0,pC=function(){if(!SS.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{SS.addEventListener("test",CS,t),SS.removeEventListener("test",CS,t)}catch(e){}return e}();function fC(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}function gC(e,t){if(fC.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(sC){e:{try{ZS(t.nodeName);var i=!0;break e}catch(e){}i=!1}i||(t=null)}}else"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:mC[e.pointerType]||"",this.state=e.state,(this.i=e).defaultPrevented&&gC.Z.h.call(this)}}fC.prototype.h=function(){this.defaultPrevented=!0},LS(gC,fC);var mC={2:"touch",3:"pen",4:"mouse"};gC.prototype.h=function(){gC.Z.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var vC="closure_listenable_"+(1e6*Math.random()|0),yC=0;function _C(e,t,n,r,i){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ia=i,this.key=++yC,this.ca=this.fa=!1}function wC(e){e.ca=!0,e.listener=null,e.proxy=null,e.src=null,e.ia=null}function bC(e){this.src=e,this.g={},this.h=0}function TC(e,t){var n,r,i,s=t.type;s in e.g&&(n=e.g[s],(i=0<=(r=jS(n,t)))&&Array.prototype.splice.call(n,r,1),i&&(wC(t),0==e.g[s].length&&(delete e.g[s],e.h--)))}function IC(e,t,n,r){for(var i=0;i<e.length;++i){var s=e[i];if(!s.ca&&s.listener==t&&s.capture==!!n&&s.ia==r)return i}return-1}bC.prototype.add=function(e,t,n,r,i){var s=e.toString();(e=this.g[s])||(e=this.g[s]=[],this.h++);var o=IC(e,t,r,i);return-1<o?(t=e[o],n||(t.fa=!1)):((t=new _C(t,this.src,s,!!r,i)).fa=n,e.push(t)),t};var EC="closure_lm_"+(1e6*Math.random()|0),kC={};function SC(e,t,n,r,i){if(r&&r.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}r=DC(r);return t&&t[vC]?t.O(n,r,NS(i)?!!i.capture:!!i,s):CC(t,n,r,!0,i,s)}(e,t,n,r,i);if(Array.isArray(t)){for(var s=0;s<t.length;s++)SC(e,t[s],n,r,i);return null}return n=DC(n),e&&e[vC]?e.N(t,n,NS(r)?!!r.capture:!!r,i):CC(e,t,n,!1,r,i)}function CC(e,t,n,r,i,s){if(!t)throw Error("Invalid event type");var o,a=NS(i)?!!i.capture:!!i,c=PC(e);if(c||(e[EC]=c=new bC(e)),(n=c.add(t,n,r,a,s)).proxy)return n;if(o=RC,r=function e(t){return o.call(e.src,e.listener,t)},(n.proxy=r).src=e,r.listener=n,e.addEventListener)void 0===(i=!pC?a:i)&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(NC(t.toString()),r);else{if(!e.addListener||!e.removeListener)throw Error("addEventListener and attachEvent are unavailable.");e.addListener(r)}return n}function AC(e){var t,n,r;"number"!=typeof e&&e&&!e.ca&&((t=e.src)&&t[vC]?TC(t.i,e):(n=e.type,r=e.proxy,t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(NC(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=PC(t))?(TC(n,e),0==n.h&&(n.src=null,t[EC]=null)):wC(e)))}function NC(e){return e in kC?kC[e]:kC[e]="on"+e}function RC(e,t){var n,r;return e=!!e.ca||(t=new gC(t,this),n=e.listener,r=e.ia||e.src,e.fa&&AC(e),n.call(r,t))}function PC(e){return(e=e[EC])instanceof bC?e:null}var xC="__closure_events_fn_"+(1e9*Math.random()>>>0);function DC(t){return"function"==typeof t?t:(t[xC]||(t[xC]=function(e){return t.handleEvent(e)}),t[xC])}function OC(){FS.call(this),this.i=new bC(this),(this.P=this).I=null}function MC(e,t){var n,r=e.I;if(r)for(n=[];r;r=r.I)n.push(r);if(e=e.P,r=t.type||t,"string"==typeof t?t=new fC(t,e):t instanceof fC?t.target=t.target||e:(o=t,XS(t=new fC(r,e),o)),o=!0,n)for(var i=n.length-1;0<=i;i--)var s=t.g=n[i],o=LC(s,r,!0,t)&&o;if(o=LC(s=t.g=e,r,!0,t)&&o,o=LC(s,r,!1,t)&&o,n)for(i=0;i<n.length;i++)o=LC(s=t.g=n[i],r,!1,t)&&o}function LC(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,a,c=t[s];c&&!c.ca&&c.capture==n&&(o=c.listener,a=c.ia||c.src,c.fa&&TC(e.i,c),i=!1!==o.call(a,r)&&i)}return i&&!r.defaultPrevented}LS(OC,FS),OC.prototype[vC]=!0,OC.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=NS(i)?!!i.capture:!!i,r=DC(r),t&&t[vC]?(t=t.i,(n=String(n).toString())in t.g&&-1<(r=IC(o=t.g[n],r,i,s))&&(wC(o[r]),Array.prototype.splice.call(o,r,1),0==o.length&&(delete t.g[n],t.h--))):(t=t&&PC(t))&&(n=t.g[n.toString()],(r=(t=-1)<(t=n?IC(n,r,i,s):t)?n[t]:null)&&AC(r))}(this,e,t,n,r)},OC.prototype.M=function(){if(OC.Z.M.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++)wC(n[r]);delete t.g[e],t.h--}}this.I=null},OC.prototype.N=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},OC.prototype.O=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};var FC=SS.JSON.stringify;var UC,jC=new class{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}}(()=>new qC,e=>e.reset());class qC{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}}function VC(e,t){var n;UC||(n=SS.Promise.resolve(void 0),UC=function(){n.then(KC)}),BC||(UC(),BC=!0),WC.add(e,t)}var BC=!1,WC=new class{constructor(){this.h=this.g=null}add(e,t){const n=jC.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}};function KC(){for(var e;e=function(){var e=WC;let t=null;return e.g&&(t=e.g,e.g=e.g.next,e.g||(e.h=null),t.next=null),t}();){try{e.h.call(e.g)}catch(e){!function(e){SS.setTimeout(()=>{throw e},0)}(e)}var t=jC;t.j(e),t.h<100&&(t.h++,e.next=t.g,t.g=e)}BC=!1}function $C(e,t){OC.call(this),this.h=e||1,this.g=t||SS,this.j=OS(this.kb,this),this.l=Date.now()}function zC(e){e.da=!1,e.S&&(e.g.clearTimeout(e.S),e.S=null)}function HC(e,t,n){if("function"==typeof e)n&&(e=OS(e,n));else{if(!e||"function"!=typeof e.handleEvent)throw Error("Invalid listener argument");e=OS(e.handleEvent,e)}return 2147483647<Number(t)?-1:SS.setTimeout(e,t||0)}LS($C,OC),(ze=$C.prototype).da=!1,ze.S=null,ze.kb=function(){var e;this.da&&(0<(e=Date.now()-this.l)&&e<.8*this.h?this.S=this.g.setTimeout(this.j,this.h-e):(this.S&&(this.g.clearTimeout(this.S),this.S=null),MC(this,"tick"),this.da&&(zC(this),this.start())))},ze.start=function(){this.da=!0,this.S||(this.S=this.g.setTimeout(this.j,this.h),this.l=Date.now())},ze.M=function(){$C.Z.M.call(this),zC(this),delete this.g};class GC extends FS{constructor(e,t){super(),this.m=e,this.j=t,this.h=null,this.i=!1,this.g=null}l(e){this.h=arguments,this.g?this.i=!0:function e(t){t.g=HC(()=>{t.g=null,t.i&&(t.i=!1,e(t))},t.j);var n=t.h;t.h=null,t.m.apply(null,n)}(this)}M(){super.M(),this.g&&(SS.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function QC(e){FS.call(this),this.h=e,this.g={}}LS(QC,FS);var YC=[];function JC(e,t,n,r){Array.isArray(n)||(n&&(YC[0]=n.toString()),n=YC);for(var i=0;i<n.length;i++){var s=SC(t,n[i],r||e.handleEvent,!1,e.h||e);if(!s)break;e.g[s.key]=s}}function XC(e){QS(e.g,function(e,t){this.g.hasOwnProperty(t)&&AC(e)},e),e.g={}}function ZC(){this.g=!0}function eA(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(!(r.length<2)){var i=r[1];if(Array.isArray(i)&&!(i.length<1)){var s=i[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var o=1;o<i.length;o++)i[o]=""}}}return FC(n)}catch(e){return t}}(e,n)+(r?" "+r:"")})}QC.prototype.M=function(){QC.Z.M.call(this),XC(this)},QC.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},ZC.prototype.Aa=function(){this.g=!1},ZC.prototype.info=function(){};var tA={},nA=null;function rA(){return nA=nA||new OC}function iA(e){fC.call(this,tA.Ma,e)}function sA(){var e=rA();MC(e,new iA(e))}function oA(e,t){fC.call(this,tA.STAT_EVENT,e),this.stat=t}function aA(e){var t=rA();MC(t,new oA(t,e))}function cA(e,t){fC.call(this,tA.Na,e),this.size=t}function lA(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return SS.setTimeout(function(){e()},t)}tA.Ma="serverreachability",LS(iA,fC),tA.STAT_EVENT="statevent",LS(oA,fC),tA.Na="timingevent",LS(cA,fC);c={NO_ERROR:0,lb:1,yb:2,xb:3,sb:4,wb:5,zb:6,Ja:7,TIMEOUT:8,Cb:9},yt={qb:"complete",Mb:"success",Ka:"error",Ja:"abort",Eb:"ready",Fb:"readystatechange",TIMEOUT:"timeout",Ab:"incrementaldata",Db:"progress",tb:"downloadprogress",Ub:"uploadprogress"};function uA(){}function hA(e){return e.h||(e.h=e.i())}function dA(){}uA.prototype.h=null;l={OPEN:"a",pb:"b",Ka:"c",Bb:"d"};function pA(){fC.call(this,"d")}function fA(){fC.call(this,"c")}function gA(){}function mA(e,t,n,r){this.l=e,this.j=t,this.m=n,this.X=r||1,this.V=new QC(this),this.P=_A,this.W=new $C(e=iC?125:void 0),this.H=null,this.i=!1,this.s=this.A=this.v=this.K=this.F=this.Y=this.B=null,this.D=[],this.g=null,this.C=0,this.o=this.u=null,this.N=-1,this.I=!1,this.O=0,this.L=null,this.aa=this.J=this.$=this.U=!1,this.h=new vA}function vA(){this.i=null,this.g="",this.h=!1}LS(pA,fC),LS(fA,fC),LS(gA,uA),gA.prototype.g=function(){return new XMLHttpRequest},gA.prototype.i=function(){return{}};var yA=new gA,_A=45e3,wA={},bA={};function TA(e,t,n){e.K=1,e.v=KA(UA(t)),e.s=n,e.U=!0,IA(e,null)}function IA(e,t){e.F=Date.now(),SA(e),e.A=UA(e.v);var o,a,c,l,u,h,n=e.A,r=e.X;Array.isArray(r)||(r=[String(r)]),rN(n.h,"t",r),e.C=0,n=e.l.H,e.h=new vA,e.g=rR(e.l,n?t:null,!e.s),0<e.O&&(e.L=new GC(OS(e.Ia,e,e.g),e.O)),JC(e.V,e.g,"readystatechange",e.gb),t=e.H?YS(e.H):{},e.s?(e.u||(e.u="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.ea(e.A,e.u,e.s,t)):(e.u="GET",e.g.ea(e.A,e.u,null,t)),sA(),o=e.j,a=e.u,c=e.A,l=e.m,u=e.X,h=e.s,o.info(function(){if(o.g)if(h)for(var e="",t=h.split("&"),n=0;n<t.length;n++){var r,i,s=t[n].split("=");1<s.length&&(r=s[0],s=s[1],e=2<=(i=r.split("_")).length&&"type"==i[1]?e+(r+"=")+s+"&":e+(r+"=redacted&"))}else e=null;else e=h;return"XMLHTTP REQ ("+l+") [attempt "+u+"]: "+a+"\n"+c+"\n"+e})}function EA(e){return e.g&&("GET"==e.u&&2!=e.K&&e.l.Ba)}function kA(e,t,n){let r=!0,i;for(;!e.I&&e.C<n.length;){if(i=(o=n,c=a=void 0,a=(s=e).C,-1==(c=o.indexOf("\n",a))?bA:(a=Number(o.substring(a,c)),isNaN(a)?wA:(c+=1)+a>o.length?bA:(o=o.substr(c,a),s.C=c+a,o))),i==bA){4==t&&(e.o=4,aA(14),r=!1),eA(e.j,e.m,null,"[Incomplete Response]");break}if(i==wA){e.o=4,aA(15),eA(e.j,e.m,n,"[Invalid Chunk]"),r=!1;break}eA(e.j,e.m,i,null),PA(e,i)}var s,o,a,c;EA(e)&&i!=bA&&i!=wA&&(e.h.g="",e.C=0),4!=t||0!=n.length||e.h.h||(e.o=1,aA(16),r=!1),e.i=e.i&&r,r?0<n.length&&!e.aa&&(e.aa=!0,(t=e.l).g==e&&t.$&&!t.L&&(t.h.info("Great, no buffering proxy detected. Bytes received: "+n.length),QN(t),t.L=!0,aA(11))):(eA(e.j,e.m,n,"[Invalid Chunked Response]"),RA(e),NA(e))}function SA(e){e.Y=Date.now()+e.P,CA(e,e.P)}function CA(e,t){if(null!=e.B)throw Error("WatchDog timer not null");e.B=lA(OS(e.eb,e),t)}function AA(e){e.B&&(SS.clearTimeout(e.B),e.B=null)}function NA(e){0==e.l.G||e.I||XN(e.l,e)}function RA(e){AA(e);var t=e.L;t&&"function"==typeof t.na&&t.na(),e.L=null,zC(e.W),XC(e.V),e.g&&(t=e.g,e.g=null,t.abort(),t.na())}function PA(e,t){try{var n=e.l;if(0!=n.G&&(n.g==e||uN(n.i,e)))if(n.I=e.N,!e.J&&uN(n.i,e)&&3==n.G){try{var r=n.Ca.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))break e;JN(n),qN(n)}GN(n),aA(18)}}else n.ta=i[1],0<n.ta-n.U&&i[2]<37500&&n.N&&0==n.A&&!n.v&&(n.v=lA(OS(n.ab,n),6e3));if(lN(n.i)<=1&&n.ka){try{n.ka()}catch(e){}n.ka=void 0}}else eR(n,11)}else if(!e.J&&n.g!=e||JN(n),!WS(t))for(i=n.Ca.g.parse(t),t=0;t<i.length;t++){var s=i[t];if(n.U=s[0],s=s[1],2==n.G)if("c"==s[0]){n.J=s[1],n.la=s[2];var o=s[3];null!=o&&(n.ma=o,n.h.info("VER="+n.ma));var a=s[4];null!=a&&(n.za=a,n.h.info("SVER="+n.za));var c,l,u,h=s[5];null!=h&&"number"==typeof h&&0<h&&(r=1.5*h,n.K=r,n.h.info("backChannelRequestTimeoutMs_="+r)),r=n;const g=e.g;g&&(!(c=g.g?g.g.getResponseHeader("X-Client-Wire-Protocol"):null)||!(l=r.i).g&&(zS(c,"spdy")||zS(c,"quic")||zS(c,"h2"))&&(l.j=l.l,l.g=new Set,l.h&&(hN(l,l.h),l.h=null)),!r.D||(u=g.g?g.g.getResponseHeader("X-HTTP-Session-Id"):null)&&(r.sa=u,WA(r.F,r.D,u))),n.G=3,n.j&&n.j.xa(),n.$&&(n.O=Date.now()-e.F,n.h.info("Handshake RTT: "+n.O+"ms"));var d,p,f=e;(r=n).oa=nR(r,r.H?r.la:null,r.W),f.J?(dN(r.i,f),d=f,(p=r.K)&&d.setTimeout(p),d.B&&(AA(d),SA(d)),r.g=f):HN(r),0<n.l.length&&WN(n)}else"stop"!=s[0]&&"close"!=s[0]||eR(n,7);else 3==n.G&&("stop"==s[0]||"close"==s[0]?"stop"==s[0]?eR(n,7):jN(n):"noop"!=s[0]&&n.j&&n.j.wa(s),n.A=0)}sA()}catch(e){}}function xA(e,t){if(e.forEach&&"function"==typeof e.forEach)e.forEach(t,void 0);else if(AS(e)||"string"==typeof e)qS(e,t,void 0);else{if(e.T&&"function"==typeof e.T)var n=e.T();else if(e.R&&"function"==typeof e.R)n=void 0;else if(AS(e)||"string"==typeof e)for(var n=[],r=e.length,i=0;i<r;i++)n.push(i);else for(i in n=[],r=0,e)n[r++]=i;for(var i=(r=function(e){if(e.R&&"function"==typeof e.R)return e.R();if("string"==typeof e)return e.split("");if(AS(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)).length,s=0;s<i;s++)t.call(void 0,r[s],n&&n[s],e)}}function DA(e,t){this.h={},this.g=[],this.i=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var r=0;r<n;r+=2)this.set(arguments[r],arguments[r+1])}else if(e)if(e instanceof DA)for(n=e.T(),r=0;r<n.length;r++)this.set(n[r],e.get(n[r]));else for(r in e)this.set(r,e[r])}function OA(e){if(e.i!=e.g.length){for(var t=0,n=0;t<e.g.length;){var r=e.g[t];MA(e.h,r)&&(e.g[n++]=r),t++}e.g.length=n}if(e.i!=e.g.length){for(var i={},n=t=0;t<e.g.length;)MA(i,r=e.g[t])||(i[e.g[n++]=r]=1),t++;e.g.length=n}}function MA(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(ze=mA.prototype).setTimeout=function(e){this.P=e},ze.gb=function(e){e=e.target;const t=this.L;t&&3==ON(e)?t.l():this.Ia(e)},ze.Ia=function(e){try{if(e==this.g)e:{var t=ON(this.g),n=this.g.Da();this.g.ba();if(!(t<3)&&(3!=t||iC||this.g&&(this.h.h||this.g.ga()||MN(this.g)))){this.I||4!=t||7==n||sA(),AA(this);var r=this.g.ba();this.N=r;t:if(EA(this)){var i=MN(this.g);e="";var s=i.length,o=4==ON(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){RA(this),NA(this);var a="";break t}this.h.i=new SS.TextDecoder}for(n=0;n<s;n++)this.h.h=!0,e+=this.h.i.decode(i[n],{stream:o&&n==s-1});i.splice(0,s),this.h.g+=e,this.C=0,a=this.h.g}else a=this.g.ga();if(this.i=200==r,h=this.j,d=this.u,p=this.A,f=this.m,g=this.X,m=t,v=r,h.info(function(){return"XMLHTTP RESP ("+f+") [ attempt "+g+"]: "+d+"\n"+p+"\n"+m+" "+v}),this.i){if(this.$&&!this.J){t:{if(this.g){var c,l=this.g;if((c=l.g?l.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!WS(c)){var u=c;break t}}u=null}if(!(r=u)){this.i=!1,this.o=3,aA(12),RA(this),NA(this);break e}eA(this.j,this.m,r,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,PA(this,r)}this.U?(kA(this,t,a),iC&&this.i&&3==t&&(JC(this.V,this.W,"tick",this.fb),this.W.start())):(eA(this.j,this.m,a,null),PA(this,a)),4==t&&RA(this),this.i&&!this.I&&(4==t?XN(this.l,this):(this.i=!1,SA(this)))}else 400==r&&0<a.indexOf("Unknown SID")?(this.o=3,aA(12)):(this.o=0,aA(13)),RA(this),NA(this)}}}catch(e){}var h,d,p,f,g,m,v},ze.fb=function(){var e,t;this.g&&(e=ON(this.g),t=this.g.ga(),this.C<t.length&&(AA(this),kA(this,e,t),this.i&&4!=e&&SA(this)))},ze.cancel=function(){this.I=!0,RA(this)},ze.eb=function(){this.B=null;var e,t,n=Date.now();0<=n-this.Y?(e=this.j,t=this.A,e.info(function(){return"TIMEOUT: "+t}),2!=this.K&&(sA(),aA(17)),RA(this),this.o=2,NA(this)):CA(this,this.Y-n)},(ze=DA.prototype).R=function(){OA(this);for(var e=[],t=0;t<this.g.length;t++)e.push(this.h[this.g[t]]);return e},ze.T=function(){return OA(this),this.g.concat()},ze.get=function(e,t){return MA(this.h,e)?this.h[e]:t},ze.set=function(e,t){MA(this.h,e)||(this.i++,this.g.push(e)),this.h[e]=t},ze.forEach=function(e,t){for(var n=this.T(),r=0;r<n.length;r++){var i=n[r],s=this.get(i);e.call(t,s,i,this)}};var LA=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function FA(e,t){var n;this.i=this.s=this.j="",this.m=null,this.o=this.l="",this.g=!1,e instanceof FA?(this.g=void 0!==t?t:e.g,jA(this,e.j),this.s=e.s,qA(this,e.i),VA(this,e.m),this.l=e.l,t=e.h,(n=new ZA).i=t.i,t.g&&(n.g=new DA(t.g),n.h=t.h),BA(this,n),this.o=e.o):e&&(n=String(e).match(LA))?(this.g=!!t,jA(this,n[1]||"",!0),this.s=$A(n[2]||""),qA(this,n[3]||"",!0),VA(this,n[4]),this.l=$A(n[5]||"",!0),BA(this,n[6]||"",!0),this.o=$A(n[7]||"")):(this.g=!!t,this.h=new ZA(null,this.g))}function UA(e){return new FA(e)}function jA(e,t,n){e.j=n?$A(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function qA(e,t,n){e.i=n?$A(t,!0):t}function VA(e,t){if(t){if(t=Number(t),isNaN(t)||t<0)throw Error("Bad port number "+t);e.m=t}else e.m=null}function BA(e,t,n){var r,i;t instanceof ZA?(e.h=t,r=e.h,(i=e.g)&&!r.j&&(eN(r),r.i=null,r.g.forEach(function(e,t){var n=t.toLowerCase();t!=n&&(tN(this,t),rN(this,n,e))},r)),r.j=i):(n||(t=zA(t,JA)),e.h=new ZA(t,e.g))}function WA(e,t,n){e.h.set(t,n)}function KA(e){return WA(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),e}function $A(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function zA(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,HA),e=n?e.replace(/%25([0-9a-fA-F]{2})/g,"%$1"):e):null}function HA(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}FA.prototype.toString=function(){var e=[],t=this.j;t&&e.push(zA(t,GA,!0),":");var n=this.i;return!n&&"file"!=t||(e.push("//"),(t=this.s)&&e.push(zA(t,GA,!0),"@"),e.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.m)&&e.push(":",String(n))),(n=this.l)&&(this.i&&"/"!=n.charAt(0)&&e.push("/"),e.push(zA(n,"/"==n.charAt(0)?YA:QA,!0))),(n=this.h.toString())&&e.push("?",n),(n=this.o)&&e.push("#",zA(n,XA)),e.join("")};var GA=/[#\/\?@]/g,QA=/[#\?:]/g,YA=/[#\?]/g,JA=/[#\?@]/g,XA=/#/g;function ZA(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function eN(n){n.g||(n.g=new DA,n.h=0,n.i&&function(e,t){if(e){e=e.split("&");for(var n=0;n<e.length;n++){var r,i=e[n].indexOf("="),s=null;0<=i?(r=e[n].substring(0,i),s=e[n].substring(i+1)):r=e[n],t(r,s?decodeURIComponent(s.replace(/\+/g," ")):"")}}}(n.i,function(e,t){n.add(decodeURIComponent(e.replace(/\+/g," ")),t)}))}function tN(e,t){eN(e),t=iN(e,t),MA(e.g.h,t)&&(e.i=null,e.h-=e.g.get(t).length,MA((e=e.g).h,t)&&(delete e.h[t],e.i--,e.g.length>2*e.i&&OA(e)))}function nN(e,t){return eN(e),t=iN(e,t),MA(e.g.h,t)}function rN(e,t,n){tN(e,t),0<n.length&&(e.i=null,e.g.set(iN(e,t),BS(n)),e.h+=n.length)}function iN(e,t){return t=String(t),t=e.j?t.toLowerCase():t}(ze=ZA.prototype).add=function(e,t){eN(this),this.i=null,e=iN(this,e);var n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this},ze.forEach=function(n,r){eN(this),this.g.forEach(function(e,t){qS(e,function(e){n.call(r,e,t,this)},this)},this)},ze.T=function(){eN(this);for(var e=this.g.R(),t=this.g.T(),n=[],r=0;r<t.length;r++)for(var i=e[r],s=0;s<i.length;s++)n.push(t[r]);return n},ze.R=function(e){eN(this);var t=[];if("string"==typeof e)nN(this,e)&&(t=VS(t,this.g.get(iN(this,e))));else{e=this.g.R();for(var n=0;n<e.length;n++)t=VS(t,e[n])}return t},ze.set=function(e,t){return eN(this),this.i=null,nN(this,e=iN(this,e))&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},ze.get=function(e,t){return e&&0<(e=this.R(e)).length?String(e[0]):t},ze.toString=function(){if(this.i)return this.i;if(!this.g)return"";for(var e=[],t=this.g.T(),n=0;n<t.length;n++)for(var r=t[n],i=encodeURIComponent(String(r)),r=this.R(r),s=0;s<r.length;s++){var o=i;""!==r[s]&&(o+="="+encodeURIComponent(String(r[s]))),e.push(o)}return this.i=e.join("&")};var sN=class{constructor(e,t){this.h=e,this.g=t}};function oN(e){this.l=e||10,e=SS.PerformanceNavigationTiming?0<(e=SS.performance.getEntriesByType("navigation")).length&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):!!(SS.g&&SS.g.Ea&&SS.g.Ea()&&SS.g.Ea().Zb),this.j=e?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}var aN;function cN(e){return e.h||e.g&&e.g.size>=e.j}function lN(e){return e.h?1:e.g?e.g.size:0}function uN(e,t){return e.h?e.h==t:e.g&&e.g.has(t)}function hN(e,t){e.g?e.g.add(t):e.h=t}function dN(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function pN(t){if(null!=t.h)return t.i.concat(t.h.D);if(null==t.g||0===t.g.size)return BS(t.i);{let e=t.i;for(const n of t.g.values())e=e.concat(n.D);return e}}function fN(){}function gN(){this.g=new fN}function mN(e,t,n,r,i){try{t.onload=null,t.onerror=null,t.onabort=null,t.ontimeout=null,i(r)}catch(e){}}function vN(e){this.l=e.$b||null,this.j=e.ib||!1}function yN(e,t){OC.call(this),this.D=e,this.u=t,this.m=void 0,this.readyState=_N,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.v=new Headers,this.h=null,this.C="GET",this.B="",this.g=!1,this.A=this.j=this.l=null}oN.prototype.cancel=function(){if(this.i=pN(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(const e of this.g.values())e.cancel();this.g.clear()}},fN.prototype.stringify=function(e){return SS.JSON.stringify(e,void 0)},fN.prototype.parse=function(e){return SS.JSON.parse(e,void 0)},LS(vN,uA),vN.prototype.g=function(){return new yN(this.l,this.j)},vN.prototype.i=(aN={},function(){return aN}),LS(yN,OC);var _N=0;function wN(e){e.j.read().then(e.Sa.bind(e)).catch(e.ha.bind(e))}function bN(e){e.readyState=4,e.l=null,e.j=null,e.A=null,TN(e)}function TN(e){e.onreadystatechange&&e.onreadystatechange.call(e)}(ze=yN.prototype).open=function(e,t){if(this.readyState!=_N)throw this.abort(),Error("Error reopening a connection");this.C=e,this.B=t,this.readyState=1,TN(this)},ze.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;const t={headers:this.v,method:this.C,credentials:this.m,cache:void 0};e&&(t.body=e),(this.D||SS).fetch(new Request(this.B,t)).then(this.Va.bind(this),this.ha.bind(this))},ze.abort=function(){this.response=this.responseText="",this.v=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted."),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,bN(this)),this.readyState=_N},ze.Va=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,TN(this)),this.g&&(this.readyState=3,TN(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Ta.bind(this),this.ha.bind(this));else if(void 0!==SS.ReadableStream&&"body"in e){if(this.j=e.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;wN(this)}else e.text().then(this.Ua.bind(this),this.ha.bind(this))},ze.Sa=function(e){var t;this.g&&(this.u&&e.value?this.response.push(e.value):this.u||(t=e.value||new Uint8Array(0),(t=this.A.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)),(e.done?bN:TN)(this),3==this.readyState&&wN(this))},ze.Ua=function(e){this.g&&(this.response=this.responseText=e,bN(this))},ze.Ta=function(e){this.g&&(this.response=e,bN(this))},ze.ha=function(){this.g&&bN(this)},ze.setRequestHeader=function(e,t){this.v.append(e,t)},ze.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||""},ze.getAllResponseHeaders=function(){if(!this.h)return"";const e=[],t=this.h.entries();for(var n=t.next();!n.done;)n=n.value,e.push(n[0]+": "+n[1]),n=t.next();return e.join("\r\n")},Object.defineProperty(yN.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}});var IN=SS.JSON.parse;function EN(e){OC.call(this),this.headers=new DA,this.u=e||null,this.h=!1,this.C=this.g=null,this.H="",this.m=0,this.j="",this.l=this.F=this.v=this.D=!1,this.B=0,this.A=null,this.J=kN,this.K=this.L=!1}LS(EN,OC);var kN="",SN=/^https?$/i,CN=["POST","PUT"];function AN(e){return"content-type"==e.toLowerCase()}function NN(e,t){e.h=!1,e.g&&(e.l=!0,e.g.abort(),e.l=!1),e.j=t,e.m=5,RN(e),xN(e)}function RN(e){e.D||(e.D=!0,MC(e,"complete"),MC(e,"error"))}function PN(e){if(e.h&&void 0!==kS&&(!e.C[1]||4!=ON(e)||2!=e.ba()))if(e.v&&4==ON(e))HC(e.Fa,0,e);else if(MC(e,"readystatechange"),4==ON(e)){e.h=!1;try{var t,n,r,i,s=e.ba();e:switch(s){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var o=!0;break e;default:o=!1}if((t=o)||((n=0===s)&&(!(i=String(e.H).match(LA)[1]||null)&&SS.self&&SS.self.location&&(i=(r=SS.self.location.protocol).substr(0,r.length-1)),n=!SN.test(i?i.toLowerCase():"")),t=n),t)MC(e,"complete"),MC(e,"success");else{e.m=6;try{var a=2<ON(e)?e.g.statusText:""}catch(e){a=""}e.j=a+" ["+e.ba()+"]",RN(e)}}finally{xN(e)}}}function xN(e,t){if(e.g){DN(e);const n=e.g,r=e.C[0]?CS:null;e.g=null,e.C=null,t||MC(e,"ready");try{n.onreadystatechange=r}catch(e){}}}function DN(e){e.g&&e.K&&(e.g.ontimeout=null),e.A&&(SS.clearTimeout(e.A),e.A=null)}function ON(e){return e.g?e.g.readyState:0}function MN(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.J){case kN:case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}function LN(e,t,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=function(e){let n="";return QS(e,function(e,t){n+=t,n+=":",n+=e,n+="\r\n"}),n}(n),"string"==typeof e?null!=n&&encodeURIComponent(String(n)):WA(e,t,n))}function FN(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function UN(e){this.za=0,this.l=[],this.h=new ZC,this.la=this.oa=this.F=this.W=this.g=this.sa=this.D=this.aa=this.o=this.P=this.s=null,this.Za=this.V=0,this.Xa=FN("failFast",!1,e),this.N=this.v=this.u=this.m=this.j=null,this.X=!0,this.I=this.ta=this.U=-1,this.Y=this.A=this.C=0,this.Pa=FN("baseRetryDelayMs",5e3,e),this.$a=FN("retryDelaySeedMs",1e4,e),this.Ya=FN("forwardChannelMaxRetries",2,e),this.ra=FN("forwardChannelRequestTimeoutMs",2e4,e),this.qa=e&&e.xmlHttpFactory||void 0,this.Ba=e&&e.Yb||!1,this.K=void 0,this.H=e&&e.supportsCrossDomainXhr||!1,this.J="",this.i=new oN(e&&e.concurrentRequestLimit),this.Ca=new gN,this.ja=e&&e.fastHandshake||!1,this.Ra=e&&e.Wb||!1,e&&e.Aa&&this.h.Aa(),e&&e.forceLongPolling&&(this.X=!1),this.$=!this.ja&&this.X&&e&&e.detectBufferingProxy||!1,this.ka=void 0,this.O=0,this.L=!1,this.B=null,this.Wa=!e||!1!==e.Xb}function jN(e){var t,n;VN(e),3==e.G&&(t=e.V++,WA(n=UA(e.F),"SID",e.J),WA(n,"RID",t),WA(n,"TYPE","terminate"),$N(e,n),(t=new mA(e,e.h,t,void 0)).K=2,t.v=KA(UA(n)),n=!1,!(n=SS.navigator&&SS.navigator.sendBeacon?SS.navigator.sendBeacon(t.v.toString(),""):n)&&SS.Image&&((new Image).src=t.v,n=!0),n||(t.g=rR(t.l,null),t.g.ea(t.v)),t.F=Date.now(),SA(t)),tR(e)}function qN(e){e.g&&(QN(e),e.g.cancel(),e.g=null)}function VN(e){qN(e),e.u&&(SS.clearTimeout(e.u),e.u=null),JN(e),e.i.cancel(),e.m&&("number"==typeof e.m&&SS.clearTimeout(e.m),e.m=null)}function BN(e,t){e.l.push(new sN(e.Za++,t)),3==e.G&&WN(e)}function WN(e){cN(e.i)||e.m||(e.m=!0,VC(e.Ha,e),e.C=0)}function KN(e,t){var n=t?t.m:e.V++,r=UA(e.F);WA(r,"SID",e.J),WA(r,"RID",n),WA(r,"AID",e.U),$N(e,r),e.o&&e.s&&LN(r,e.o,e.s),n=new mA(e,e.h,n,e.C+1),null===e.o&&(n.H=e.s),t&&(e.l=t.D.concat(e.l)),t=zN(e,n,1e3),n.setTimeout(Math.round(.5*e.ra)+Math.round(.5*e.ra*Math.random())),hN(e.i,n),TA(n,r,t)}function $N(e,n){e.j&&xA({},function(e,t){WA(n,t,e)})}function zN(e,t,r){r=Math.min(e.l.length,r);var i=e.j?OS(e.j.Oa,e.j,e):null;e:{var s=e.l;let n=-1;for(;;){const c=["count="+r];-1==n?0<r?(n=s[0].h,c.push("ofs="+n)):n=0:c.push("ofs="+n);let e=!0;for(let t=0;t<r;t++){var o=s[t].h,a=s[t].g;if((o-=n)<0)n=Math.max(0,s[t].h-100),e=!1;else try{!function(e,r,t){const i=t||"";try{xA(e,function(e,t){let n=e;NS(e)&&(n=FC(e)),r.push(i+t+"="+encodeURIComponent(n))})}catch(e){throw r.push(i+"type="+encodeURIComponent("_badmap")),e}}(a,c,"req"+o+"_")}catch(e){i&&i(a)}}if(e){i=c.join("&");break e}}}return e=e.l.splice(0,r),t.D=e,i}function HN(e){e.g||e.u||(e.Y=1,VC(e.Ga,e),e.A=0)}function GN(e){return!(e.g||e.u||3<=e.A)&&(e.Y++,e.u=lA(OS(e.Ga,e),ZN(e,e.A)),e.A++,1)}function QN(e){null!=e.B&&(SS.clearTimeout(e.B),e.B=null)}function YN(e){e.g=new mA(e,e.h,"rpc",e.Y),null===e.o&&(e.g.H=e.s),e.g.O=0;var t=UA(e.oa);WA(t,"RID","rpc"),WA(t,"SID",e.J),WA(t,"CI",e.N?"0":"1"),WA(t,"AID",e.U),$N(e,t),WA(t,"TYPE","xmlhttp"),e.o&&e.s&&LN(t,e.o,e.s),e.K&&e.g.setTimeout(e.K);var n=e.g;e=e.la,n.K=1,n.v=KA(UA(t)),n.s=null,n.U=!0,IA(n,e)}function JN(e){null!=e.v&&(SS.clearTimeout(e.v),e.v=null)}function XN(e,t){var n,r,i,s=null;if(e.g==t){JN(e),QN(e),e.g=null;var o=2}else{if(!uN(e.i,t))return;s=t.D,dN(e.i,t),o=1}if(e.I=t.N,0!=e.G)if(t.i)1==o?(s=t.s?t.s.length:0,t=Date.now()-t.F,n=e.C,MC(o=rA(),new cA(o,s)),WN(e)):HN(e);else if(3==(n=t.o)||0==n&&0<e.I||(1!=o||(i=t,lN((r=e).i)>=r.i.j-(r.m?1:0)||(r.m?(r.l=i.D.concat(r.l),0):1==r.G||2==r.G||r.C>=(r.Xa?0:r.Ya)||(r.m=lA(OS(r.Ha,r,i),ZN(r,r.C)),r.C++,0))))&&(2!=o||!GN(e)))switch(s&&0<s.length&&(t=e.i,t.i=t.i.concat(s)),n){case 1:eR(e,5);break;case 4:eR(e,10);break;case 3:eR(e,6);break;default:eR(e,2)}}function ZN(e,t){let n=e.Pa+Math.floor(Math.random()*e.$a);return e.j||(n*=2),n*t}function eR(e,t){var n,r;e.h.info("Error code "+t),2==t?(n=null,e.j&&(n=null),r=OS(e.jb,e),n||(n=new FA("//www.google.com/images/cleardot.gif"),SS.location&&"http"==SS.location.protocol||jA(n,"https"),KA(n)),function(e,t){var n=new ZC;if(SS.Image){const r=new Image;r.onload=MS(mN,n,r,"TestLoadImage: loaded",!0,t),r.onerror=MS(mN,n,r,"TestLoadImage: error",!1,t),r.onabort=MS(mN,n,r,"TestLoadImage: abort",!1,t),r.ontimeout=MS(mN,n,r,"TestLoadImage: timeout",!1,t),SS.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}(n.toString(),r)):aA(2),e.G=0,e.j&&e.j.va(t),tR(e),VN(e)}function tR(e){e.G=0,e.I=-1,e.j&&(0==pN(e.i).length&&0==e.l.length||(e.i.i.length=0,BS(e.l),e.l.length=0),e.j.ua())}function nR(e,t,n){let r=(a=n)instanceof FA?UA(a):new FA(a,void 0);var i,s,o,a,c;return""!=r.i?(t&&qA(r,t+"."+r.i),VA(r,r.m)):(c=SS.location,r=(i=c.protocol,s=t?t+"."+c.hostname:c.hostname,o=+c.port,a=n,c=new FA(null,void 0),i&&jA(c,i),s&&qA(c,s),o&&VA(c,o),a&&(c.l=a),c)),e.aa&&QS(e.aa,function(e,t){WA(r,t,e)}),t=e.D,n=e.sa,t&&n&&WA(r,t,n),WA(r,"VER",e.ma),$N(e,r),r}function rR(e,t,n){if(t&&!e.H)throw Error("Can't create secondary domain capable XhrIo object.");return(t=n&&e.Ba&&!e.qa?new EN(new vN({ib:!0})):new EN(e.qa)).L=e.H,t}function iR(){}function sR(){if(nC&&!(10<=Number(dC)))throw Error("Environmental error: no available transport.")}function oR(e,t){OC.call(this),this.g=new UN(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.s=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.ya&&(e?e["X-WebChannel-Client-Profile"]=t.ya:e={"X-WebChannel-Client-Profile":t.ya}),this.g.P=e,(e=t&&t.httpHeadersOverwriteParam)&&!WS(e)&&(this.g.o=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!WS(t)&&(this.g.D=t,null!==(e=this.h)&&t in e&&(t in(e=this.h)&&delete e[t])),this.j=new lR(this)}function aR(e){pA.call(this);var t=e.__sm__;if(t){e:{for(const 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 cR(){fA.call(this),this.status=1}function lR(e){this.g=e}(ze=EN.prototype).ea=function(e,t,n,r){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.H+"; newUri="+e);t=t?t.toUpperCase():"GET",this.H=e,this.j="",this.m=0,this.D=!1,this.h=!0,this.g=(this.u||yA).g(),this.C=this.u?hA(this.u):hA(yA),this.g.onreadystatechange=OS(this.Fa,this);try{this.F=!0,this.g.open(t,String(e),!0),this.F=!1}catch(e){return void NN(this,e)}e=n||"";const i=new DA(this.headers);r&&xA(r,function(e,t){i.set(t,e)}),r=function(t){e:{var n=AN,r=t.length,i="string"==typeof t?t.split(""):t;for(let e=0;e<r;e++)if(e in i&&n.call(void 0,i[e],e,t)){n=e;break e}n=-1}return n<0?null:"string"==typeof t?t.charAt(n):t[n]}(i.T()),n=SS.FormData&&e instanceof SS.FormData,0<=jS(CN,t)&&!r&&!n&&i.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),i.forEach(function(e,t){this.g.setRequestHeader(t,e)},this),this.J&&(this.g.responseType=this.J),"withCredentials"in this.g&&this.g.withCredentials!==this.L&&(this.g.withCredentials=this.L);try{DN(this),0<this.B&&((this.K=(s=this.g,nC&&hC()&&"number"==typeof s.timeout&&void 0!==s.ontimeout))?(this.g.timeout=this.B,this.g.ontimeout=OS(this.pa,this)):this.A=HC(this.pa,this.B,this)),this.v=!0,this.g.send(e),this.v=!1}catch(e){NN(this,e)}var s},ze.pa=function(){void 0!==kS&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,MC(this,"timeout"),this.abort(8))},ze.abort=function(e){this.g&&this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=e||7,MC(this,"complete"),MC(this,"abort"),xN(this))},ze.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),xN(this,!0)),EN.Z.M.call(this)},ze.Fa=function(){this.s||(this.F||this.v||this.l?PN(this):this.cb())},ze.cb=function(){PN(this)},ze.ba=function(){try{return 2<ON(this)?this.g.status:-1}catch(e){return-1}},ze.ga=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},ze.Qa=function(e){if(this.g){var t=this.g.responseText;return e&&0==t.indexOf(e)&&(t=t.substring(e.length)),IN(t)}},ze.Da=function(){return this.m},ze.La=function(){return"string"==typeof this.j?this.j:String(this.j)},(ze=UN.prototype).ma=8,ze.G=1,ze.hb=function(e){try{this.h.info("Origin Trials invoked: "+e)}catch(e){}},ze.Ha=function(t){if(this.m)if(this.m=null,1==this.G){if(!t){this.V=Math.floor(1e5*Math.random()),t=this.V++;const s=new mA(this,this.h,t,void 0);let e=this.s;if(this.P&&(e?(e=YS(e),XS(e,this.P)):e=this.P),null===this.o&&(s.H=e),this.ja)e:{for(var n=0,r=0;r<this.l.length;r++){var i=this.l[r];if("__data__"in i.g&&"string"==typeof(i=i.g.__data__)?i=i.length:i=void 0,void 0===i)break;if(4096<(n+=i)){n=r;break e}if(4096===n||r===this.l.length-1){n=r+1;break e}}n=1e3}else n=1e3;n=zN(this,s,n),WA(r=UA(this.F),"RID",t),WA(r,"CVER",22),this.D&&WA(r,"X-HTTP-Session-Id",this.D),$N(this,r),this.o&&e&&LN(r,this.o,e),hN(this.i,s),this.Ra&&WA(r,"TYPE","init"),this.ja?(WA(r,"$req",n),WA(r,"SID","null"),s.$=!0,TA(s,r,null)):TA(s,r,n),this.G=2}}else 3==this.G&&(t?KN(this,t):0==this.l.length||cN(this.i)||KN(this))},ze.Ga=function(){var e;this.u=null,YN(this),this.$&&!(this.L||null==this.g||this.O<=0)&&(e=2*this.O,this.h.info("BP detection timer enabled: "+e),this.B=lA(OS(this.bb,this),e))},ze.bb=function(){this.B&&(this.B=null,this.h.info("BP detection timeout reached."),this.h.info("Buffering proxy detected and switch to long-polling!"),this.N=!1,this.L=!0,aA(10),qN(this),YN(this))},ze.ab=function(){null!=this.v&&(this.v=null,qN(this),GN(this),aA(19))},ze.jb=function(e){e?(this.h.info("Successfully pinged google.com"),aA(2)):(this.h.info("Failed to ping google.com"),aA(1))},(ze=iR.prototype).xa=function(){},ze.wa=function(){},ze.va=function(){},ze.ua=function(){},ze.Oa=function(){},sR.prototype.g=function(e,t){return new oR(e,t)},LS(oR,OC),oR.prototype.m=function(){this.g.j=this.j,this.A&&(this.g.H=!0);var e=this.g,t=this.l,n=this.h||void 0;e.Wa&&(e.h.info("Origin Trials enabled."),VC(OS(e.hb,e,t))),aA(0),e.W=t,e.aa=n||{},e.N=e.X,e.F=nR(e,null,e.W),WN(e)},oR.prototype.close=function(){jN(this.g)},oR.prototype.u=function(e){var t;"string"==typeof e?((t={}).__data__=e,BN(this.g,t)):this.v?((t={}).__data__=FC(e),BN(this.g,t)):BN(this.g,e)},oR.prototype.M=function(){this.g.j=null,delete this.j,jN(this.g),delete this.g,oR.Z.M.call(this)},LS(aR,pA),LS(cR,fA),LS(lR,iR),lR.prototype.xa=function(){MC(this.g,"a")},lR.prototype.wa=function(e){MC(this.g,new aR(e))},lR.prototype.va=function(e){MC(this.g,new cR)},lR.prototype.ua=function(){MC(this.g,"b")},sR.prototype.createWebChannel=sR.prototype.g,oR.prototype.send=oR.prototype.u,oR.prototype.open=oR.prototype.m,c.NO_ERROR=0,c.TIMEOUT=8,c.HTTP_ERROR=6,yt.COMPLETE="complete",(dA.EventType=l).OPEN="a",l.CLOSE="b",l.ERROR="c",l.MESSAGE="d",OC.prototype.listen=OC.prototype.N,EN.prototype.listenOnce=EN.prototype.O,EN.prototype.getLastError=EN.prototype.La,EN.prototype.getLastErrorCode=EN.prototype.Da,EN.prototype.getStatus=EN.prototype.ba,EN.prototype.getResponseJson=EN.prototype.Qa,EN.prototype.getResponseText=EN.prototype.ga,EN.prototype.send=EN.prototype.ea;var uR,hR=rA,dR=c,pR=yt,fR=tA,gR=10,mR=11,vR=vN,yR=dA,_R=EN;const wR="@firebase/firestore";class bR{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}}bR.UNAUTHENTICATED=new bR(null),bR.GOOGLE_CREDENTIALS=new bR("google-credentials-uid"),bR.FIRST_PARTY=new bR("first-party-uid"),bR.MOCK_USER=new bR("mock-user");let TR="9.6.2";const IR=new ep("@firebase/firestore");function ER(){return IR.logLevel}function kR(e,...t){var n;IR.logLevel<=Kh.DEBUG&&(n=t.map(AR),IR.debug(`Firestore (${TR}): ${e}`,...n))}function SR(e,...t){var n;IR.logLevel<=Kh.ERROR&&(n=t.map(AR),IR.error(`Firestore (${TR}): ${e}`,...n))}function CR(e,...t){var n;IR.logLevel<=Kh.WARN&&(n=t.map(AR),IR.warn(`Firestore (${TR}): ${e}`,...n))}function AR(t){if("string"==typeof t)return t;try{return JSON.stringify(t)}catch(e){return t}}function NR(e="Unexpected state"){var t=`FIRESTORE (${TR}) INTERNAL ASSERTION FAILED: `+e;throw SR(t),new Error(t)}function RR(e){e||NR()}const PR={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class xR extends gd{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class DR{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class OR{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class MR{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(bR.UNAUTHENTICATED))}shutdown(){}}class LR{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 FR{constructor(e){this.t=e,this.currentUser=bR.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,n){let r=this.i;const i=e=>this.i!==r?(r=this.i,n(e)):Promise.resolve();let s=new DR;this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new DR,t.enqueueRetryable(()=>i(this.currentUser))};const o=()=>{const e=s;t.enqueueRetryable(async()=>{await e.promise,await i(this.currentUser)})},a=e=>{kR("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.auth.addAuthTokenListener(this.o),o()};this.t.onInit(e=>a(e)),setTimeout(()=>{var e;this.auth||((e=this.t.getImmediate({optional:!0}))?a(e):(kR("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new DR))},0),o()}getToken(){const t=this.i,e=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(e).then(e=>this.i!==t?(kR("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):e?(RR("string"==typeof e.accessToken),new OR(e.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.auth.removeAuthTokenListener(this.o)}u(){var e=this.auth&&this.auth.getUid();return RR(null===e||"string"==typeof e),new bR(e)}}class UR{constructor(e,t,n){this.type="FirstParty",this.user=bR.FIRST_PARTY,this.headers=new Map,this.headers.set("X-Goog-AuthUser",t);var r=e.auth.getAuthHeaderValueForFirstParty([]);r&&this.headers.set("Authorization",r),n&&this.headers.set("X-Goog-Iam-Authorization-Token",n)}}class jR{constructor(e,t,n){this.h=e,this.l=t,this.m=n}getToken(){return Promise.resolve(new UR(this.h,this.l,this.m))}start(e,t){e.enqueueRetryable(()=>t(bR.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class qR{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&0<e.length&&this.headers.set("x-firebase-appcheck",this.value)}}class VR{constructor(e){this.g=e,this.forceRefresh=!1,this.appCheck=null}start(t,n){this.o=e=>{t.enqueueRetryable(()=>(e=>(null!=e.error&&kR("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`),n(e.token)))(e))};const r=e=>{kR("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.appCheck.addTokenListener(this.o)};this.g.onInit(e=>r(e)),setTimeout(()=>{var e;this.appCheck||((e=this.g.getImmediate({optional:!0}))?r(e):kR("FirebaseAppCheckTokenProvider","AppCheck not yet detected"))},0)}getToken(){var e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(RR("string"==typeof e.token),new qR(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}class BR{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.p(e),this.T=e=>t.writeSequenceNumber(e))}p(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){var e=++this.previousValue;return this.T&&this.T(e),e}}BR.I=-1;class WR{static A(){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=Math.floor(256/t.length)*t.length;let r="";for(;r.length<20;){var i=function(t){const n="undefined"!=typeof self&&(self.crypto||self.msCrypto),r=new Uint8Array(t);if(n&&"function"==typeof n.getRandomValues)n.getRandomValues(r);else for(let e=0;e<t;e++)r[e]=Math.floor(256*Math.random());return r}(40);for(let e=0;e<i.length;++e)r.length<20&&i[e]<n&&(r+=t.charAt(i[e]%t.length))}return r}}function KR(e,t){return e<t?-1:t<e?1:0}function $R(e,n,r){return e.length===n.length&&e.every((e,t)=>r(e,n[t]))}function zR(e){return e+"\0"}class HR{constructor(e,t){if(this.seconds=e,(this.nanoseconds=t)<0)throw new xR(PR.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(1e9<=t)throw new xR(PR.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-62135596800)throw new xR(PR.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(253402300800<=e)throw new xR(PR.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return HR.fromMillis(Date.now())}static fromDate(e){return HR.fromMillis(e.getTime())}static fromMillis(e){var t=Math.floor(e/1e3),n=Math.floor(1e6*(e-1e3*t));return new HR(t,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?KR(this.nanoseconds,e.nanoseconds):KR(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(){var e=this.seconds- -62135596800;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}class GR{constructor(e){this.timestamp=e}static fromTimestamp(e){return new GR(e)}static min(){return new GR(new HR(0,0))}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}}function QR(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function YR(e,t){for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function JR(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class XR{constructor(e,t,n){void 0===t?t=0:t>e.length&&NR(),void 0===n?n=e.length-t:n>e.length-t&&NR(),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return 0===XR.comparator(this,e)}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof XR?e.forEach(e=>{t.push(e)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return this.construct(this.segments,this.offset+(e=void 0===e?1: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){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++){const n=e.get(r),i=t.get(r);if(n<i)return-1;if(n>i)return 1}return e.length<t.length?-1:e.length>t.length?1:0}}class ZR extends XR{construct(e,t,n){return new ZR(e,t,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}static fromString(...e){const t=[];for(const n of e){if(0<=n.indexOf("//"))throw new xR(PR.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter(e=>0<e.length))}return new ZR(t)}static emptyPath(){return new ZR([])}}const eP=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class tP extends XR{construct(e,t,n){return new tP(e,t,n)}static isValidIdentifier(e){return eP.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),e=!tP.isValidIdentifier(e)?"`"+e+"`":e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&"__name__"===this.get(0)}static keyField(){return new tP(["__name__"])}static fromServerFormat(e){const t=[];let n="",r=0;var i=()=>{if(0===n.length)throw new xR(PR.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""};let s=!1;for(;r<e.length;){const t=e[r];if("\\"===t){if(r+1===e.length)throw new xR(PR.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const t=e[r+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new xR(PR.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 xR(PR.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new tP(t)}static emptyPath(){return new tP([])}}class nP{constructor(e){(this.fields=e).sort(tP.comparator)}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return $R(this.fields,e.fields,(e,t)=>e.isEqual(t))}}class rP{constructor(e){this.binaryString=e}static fromBase64String(e){var t=atob(e);return new rP(t)}static fromUint8Array(e){var t=function(e){let t="";for(let n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}(e);return new rP(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return e=this.binaryString,btoa(e);var e}toUint8Array(){return function(e){const 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 KR(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}rP.EMPTY_BYTE_STRING=new rP("");const iP=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function sP(t){if(RR(!!t),"string"!=typeof t)return{seconds:oP(t.seconds),nanos:oP(t.nanos)};{let e=0;var n=iP.exec(t);RR(!!n),n[1]&&(n=((n=n[1])+"000000000").substr(0,9),e=Number(n));const r=new Date(t);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}}function oP(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function aP(e){return"string"==typeof e?rP.fromBase64String(e):rP.fromUint8Array(e)}function cP(e){var t;return"server_timestamp"===(null===(t=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{}).__type__)||void 0===t?void 0:t.stringValue)}function lP(e){var t=sP(e.mapValue.fields.__local_write_time__.timestampValue);return new HR(t.seconds,t.nanos)}function uP(e){return null==e}function hP(e){return 0===e&&1/e==-1/0}function dP(e){return"number"==typeof e&&Number.isInteger(e)&&!hP(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}class pP{constructor(e){this.path=e}static fromPath(e){return new pP(ZR.fromString(e))}static fromName(e){return new pP(ZR.fromString(e).popFirst(5))}hasCollectionId(e){return 2<=this.path.length&&this.path.get(this.path.length-2)===e}isEqual(e){return null!==e&&0===ZR.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return ZR.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new pP(new ZR(e.slice()))}}function fP(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?cP(e)?4:10:NR()}function gP(r,i){if(r===i)return!0;var e,t,n=fP(r);if(n!==fP(i))return!1;switch(n){case 0:return!0;case 1:return r.booleanValue===i.booleanValue;case 4:return lP(r).isEqual(lP(i));case 3:return function(e){if("string"==typeof r.timestampValue&&"string"==typeof e.timestampValue&&r.timestampValue.length===e.timestampValue.length)return r.timestampValue===e.timestampValue;var t=sP(r.timestampValue),n=sP(e.timestampValue);return t.seconds===n.seconds&&t.nanos===n.nanos}(i);case 5:return r.stringValue===i.stringValue;case 6:return t=i,aP(r.bytesValue).isEqual(aP(t.bytesValue));case 7:return r.referenceValue===i.referenceValue;case 8:return e=i,oP((t=r).geoPointValue.latitude)===oP(e.geoPointValue.latitude)&&oP(t.geoPointValue.longitude)===oP(e.geoPointValue.longitude);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return oP(e.integerValue)===oP(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){var n=oP(e.doubleValue),r=oP(t.doubleValue);return n===r?hP(n)===hP(r):isNaN(n)&&isNaN(r)}return!1}(r,i);case 9:return $R(r.arrayValue.values||[],i.arrayValue.values||[],gP);case 10:return function(e){const t=e.mapValue.fields||{},n=i.mapValue.fields||{};if(QR(t)!==QR(n))return!1;for(const e in t)if(t.hasOwnProperty(e)&&(void 0===n[e]||!gP(t[e],n[e])))return!1;return!0}(r);default:return NR()}}function mP(e,t){return void 0!==(e.values||[]).find(e=>gP(e,t))}function vP(e,t){if(e===t)return 0;var n,r,i,s,o=fP(e),a=fP(t);if(o!==a)return KR(o,a);switch(o){case 0:return 0;case 1:return KR(e.booleanValue,t.booleanValue);case 2:return r=t,i=oP(e.integerValue||e.doubleValue),s=oP(r.integerValue||r.doubleValue),i<s?-1:s<i?1:i===s?0:isNaN(i)?isNaN(s)?0:-1:1;case 3:return yP(e.timestampValue,t.timestampValue);case 4:return yP(lP(e),lP(t));case 5:return KR(e.stringValue,t.stringValue);case 6:return function(e,t){const n=aP(e),r=aP(t);return n.compareTo(r)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){var n=e.split("/"),r=t.split("/");for(let i=0;i<n.length&&i<r.length;i++){const t=KR(n[i],r[i]);if(0!==t)return t}return KR(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return n=e.geoPointValue,r=t.geoPointValue,0!==(s=KR(oP(n.latitude),oP(r.latitude)))?s:KR(oP(n.longitude),oP(r.longitude));case 9:return function(e,t){var n=e.values||[],r=t.values||[];for(let i=0;i<n.length&&i<r.length;++i){const t=vP(n[i],r[i]);if(t)return t}return KR(n.length,r.length)}(e.arrayValue,t.arrayValue);case 10:return function(e,t){const n=e.fields||{},r=Object.keys(n),i=t.fields||{},s=Object.keys(i);r.sort(),s.sort();for(let a=0;a<r.length&&a<s.length;++a){const t=KR(r[a],s[a]);if(0!==t)return t;var o=vP(n[r[a]],i[s[a]]);if(0!==o)return o}return KR(r.length,s.length)}(e.mapValue,t.mapValue);default:throw NR()}}function yP(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return KR(e,t);var n=sP(e),r=sP(t),i=KR(n.seconds,r.seconds);return 0!==i?i:KR(n.nanos,r.nanos)}function _P(e){return function s(e){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){const t=sP(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?aP(e.bytesValue).toBase64():"referenceValue"in e?(t=e.referenceValue,pP.fromName(t).toString()):"geoPointValue"in e?`geo(${(t=e.geoPointValue).latitude},${t.longitude})`:"arrayValue"in e?function(e){let t="[",n=!0;for(const r of e.values||[])n?n=!1:t+=",",t+=s(r);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){const t=Object.keys(e.fields||{}).sort();let n="{",r=!0;for(const i of t)r?r=!1:n+=",",n+=`${i}:${s(e.fields[i])}`;return n+"}"}(e.mapValue):NR();var t}(e)}function wP(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function bP(e){return e&&"integerValue"in e}function TP(e){return!!e&&"arrayValue"in e}function IP(e){return e&&"nullValue"in e}function EP(e){return e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function kP(e){return e&&"mapValue"in e}function SP(t){if(t.geoPointValue)return{geoPointValue:Object.assign({},t.geoPointValue)};if(t.timestampValue&&"object"==typeof t.timestampValue)return{timestampValue:Object.assign({},t.timestampValue)};if(t.mapValue){const n={mapValue:{fields:{}}};return YR(t.mapValue.fields,(e,t)=>n.mapValue.fields[e]=SP(t)),n}if(t.arrayValue){const r={arrayValue:{values:[]}};for(let e=0;e<(t.arrayValue.values||[]).length;++e)r.arrayValue.values[e]=SP(t.arrayValue.values[e]);return r}return Object.assign({},t)}class CP{constructor(e){this.value=e}static empty(){return new CP({mapValue:{}})}field(n){if(n.isEmpty())return this.value;{let e=this.value;for(let t=0;t<n.length-1;++t)if(e=(e.mapValue.fields||{})[n.get(t)],!kP(e))return null;return e=(e.mapValue.fields||{})[n.lastSegment()],e||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=SP(t)}setAll(e){let n=tP.emptyPath(),r={},i=[];e.forEach((e,t)=>{if(!n.isImmediateParentOf(t)){const e=this.getFieldsMap(n);this.applyChanges(e,r,i),r={},i=[],n=t.popLast()}e?r[t.lastSegment()]=SP(e):i.push(t.lastSegment())});var t=this.getFieldsMap(n);this.applyChanges(t,r,i)}delete(e){const t=this.field(e.popLast());kP(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return gP(this.value,e.value)}getFieldsMap(t){let n=this.value;n.mapValue.fields||(n.mapValue={fields:{}});for(let r=0;r<t.length;++r){let e=n.mapValue.fields[t.get(r)];kP(e)&&e.mapValue.fields||(e={mapValue:{fields:{}}},n.mapValue.fields[t.get(r)]=e),n=e}return n.mapValue.fields}applyChanges(n,e,t){YR(e,(e,t)=>n[e]=t);for(const e of t)delete n[e]}clone(){return new CP(SP(this.value))}}class AP{constructor(e,t,n,r,i){this.key=e,this.documentType=t,this.version=n,this.data=r,this.documentState=i}static newInvalidDocument(e){return new AP(e,0,GR.min(),CP.empty(),0)}static newFoundDocument(e,t,n){return new AP(e,1,t,n,0)}static newNoDocument(e,t){return new AP(e,2,t,CP.empty(),0)}static newUnknownDocument(e,t){return new AP(e,3,t,CP.empty(),2)}convertToFoundDocument(e,t){return this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=CP.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=CP.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,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 AP&&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 AP(this.key,this.documentType,this.version,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class NP{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.R=null}}function RP(e,t=null,n=[],r=[],i=null,s=null,o=null){return new NP(e,t,n,r,i,s,o)}function PP(e){const t=e;if(null===t.R){let e=t.path.canonicalString();null!==t.collectionGroup&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map(e=>function(e){return e.field.canonicalString()+e.op.toString()+_P(e.value)}(e)).join(","),e+="|ob:",e+=t.orderBy.map(e=>function(e){return e.field.canonicalString()+e.dir}(e)).join(","),uP(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=KP(t.startAt)),t.endAt&&(e+="|ub:",e+=KP(t.endAt)),t.R=e}return t.R}function xP(e,t){if(e.limit!==t.limit)return!1;if(e.orderBy.length!==t.orderBy.length)return!1;for(let o=0;o<e.orderBy.length;o++)if(n=e.orderBy[o],r=t.orderBy[o],n.dir!==r.dir||!n.field.isEqual(r.field))return!1;var n,r,i,s;if(e.filters.length!==t.filters.length)return!1;for(let a=0;a<e.filters.length;a++)if(i=e.filters[a],s=t.filters[a],i.op!==s.op||!i.field.isEqual(s.field)||!gP(i.value,s.value))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!HP(e.startAt,t.startAt)&&HP(e.endAt,t.endAt)}function DP(e){return pP.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}class OP extends class{}{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.P(e,t,n):new MP(e,t,n):"array-contains"===t?new jP(e,n):"in"===t?new qP(e,n):"not-in"===t?new VP(e,n):"array-contains-any"===t?new BP(e,n):new OP(e,t,n)}static P(e,t,n){return new("in"===t?LP:FP)(e,n)}matches(e){var t=e.data.field(this.field);return"!="===this.op?null!==t&&this.v(vP(t,this.value)):null!==t&&fP(this.value)===fP(t)&&this.v(vP(t,this.value))}v(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return 0<e;case">=":return 0<=e;default:return NR()}}V(){return 0<=["<","<=",">",">=","!=","not-in"].indexOf(this.op)}}class MP extends OP{constructor(e,t,n){super(e,t,n),this.key=pP.fromName(n.referenceValue)}matches(e){var t=pP.comparator(e.key,this.key);return this.v(t)}}class LP extends OP{constructor(e,t){super(e,"in",t),this.keys=UP(0,t)}matches(t){return this.keys.some(e=>e.isEqual(t.key))}}class FP extends OP{constructor(e,t){super(e,"not-in",t),this.keys=UP(0,t)}matches(t){return!this.keys.some(e=>e.isEqual(t.key))}}function UP(e,t){var n;return((null===(n=t.arrayValue)||void 0===n?void 0:n.values)||[]).map(e=>pP.fromName(e.referenceValue))}class jP extends OP{constructor(e,t){super(e,"array-contains",t)}matches(e){var t=e.data.field(this.field);return TP(t)&&mP(t.arrayValue,this.value)}}class qP extends OP{constructor(e,t){super(e,"in",t)}matches(e){var t=e.data.field(this.field);return null!==t&&mP(this.value.arrayValue,t)}}class VP extends OP{constructor(e,t){super(e,"not-in",t)}matches(e){if(mP(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var t=e.data.field(this.field);return null!==t&&!mP(this.value.arrayValue,t)}}class BP extends OP{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!TP(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>mP(this.value.arrayValue,e))}}class WP{constructor(e,t){this.position=e,this.before=t}}function KP(e){return`${e.before?"b":"a"}:${e.position.map(e=>_P(e)).join(",")}`}class $P{constructor(e,t="asc"){this.field=e,this.dir=t}}function zP(e,t,n){let r=0;for(let i=0;i<e.position.length;i++){const s=t[i],o=e.position[i];if(r=s.field.isKeyField()?pP.comparator(pP.fromName(o.referenceValue),n.key):vP(o,n.data.field(s.field)),"desc"===s.dir&&(r*=-1),0!==r)break}return e.before?r<=0:r<0}function HP(e,t){if(null===e)return null===t;if(null===t)return!1;if(e.before!==t.before||e.position.length!==t.position.length)return!1;for(let n=0;n<e.position.length;n++)if(!gP(e.position[n],t.position[n]))return!1;return!0}class GP{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.S=null,this.D=null,this.startAt,this.endAt}}function QP(e,t,n,r,i,s,o,a){return new GP(e,t,n,r,i,s,o,a)}function YP(e){return new GP(e)}function JP(e){return!uP(e.limit)&&"F"===e.limitType}function XP(e){return!uP(e.limit)&&"L"===e.limitType}function ZP(e){return 0<e.explicitOrderBy.length?e.explicitOrderBy[0].field:null}function ex(e){for(const t of e.filters)if(t.V())return t.field;return null}function tx(e){return null!==e.collectionGroup}function nx(t){const n=t;if(null===n.S){n.S=[];const t=ex(n),e=ZP(n);if(null!==t&&null===e)t.isKeyField()||n.S.push(new $P(t)),n.S.push(new $P(tP.keyField(),"asc"));else{let e=!1;for(const r of n.explicitOrderBy)n.S.push(r),r.field.isKeyField()&&(e=!0);if(!e){const t=0<n.explicitOrderBy.length?n.explicitOrderBy[n.explicitOrderBy.length-1].dir:"asc";n.S.push(new $P(tP.keyField(),t))}}}return n.S}function rx(e){const t=e;if(!t.D)if("F"===t.limitType)t.D=RP(t.path,t.collectionGroup,nx(t),t.filters,t.limit,t.startAt,t.endAt);else{const e=[];for(const i of nx(t)){const t="desc"===i.dir?"asc":"desc";e.push(new $P(i.field,t))}var n=t.endAt?new WP(t.endAt.position,!t.endAt.before):null,r=t.startAt?new WP(t.startAt.position,!t.startAt.before):null;t.D=RP(t.path,t.collectionGroup,e,t.filters,t.limit,n,r)}return t.D}function ix(e,t,n){return new GP(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function sx(e,t){return xP(rx(e),rx(t))&&e.limitType===t.limitType}function ox(e){return`${PP(rx(e))}|lt:${e.limitType}`}function ax(e){return`Query(target=${function(e){let t=e.path.canonicalString();return null!==e.collectionGroup&&(t+=" collectionGroup="+e.collectionGroup),0<e.filters.length&&(t+=`, filters: [${e.filters.map(e=>{return`${(t=e).field.canonicalString()} ${t.op} ${_P(t.value)}`;var t}).join(", ")}]`),uP(e.limit)||(t+=", limit: "+e.limit),0<e.orderBy.length&&(t+=`, orderBy: [${e.orderBy.map(e=>function(e){return`${e.field.canonicalString()} (${e.dir})`}(e)).join(", ")}]`),e.startAt&&(t+=", startAt: "+KP(e.startAt)),e.endAt&&(t+=", endAt: "+KP(e.endAt)),`Target(${t})`}(rx(e))}; limitType=${e.limitType})`}function cx(n,e){return e.isFoundDocument()&&(t=n,i=(r=e).key.path,null!==t.collectionGroup?r.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(i):pP.isDocumentKey(t.path)?t.path.isEqual(i):t.path.isImmediateParentOf(i))&&function(e){for(const t of n.explicitOrderBy)if(!t.field.isKeyField()&&null===e.data.field(t.field))return;return 1}(e)&&function(e){for(const t of n.filters)if(!t.matches(e))return;return 1}(e)&&(t=e,(!(e=n).startAt||zP(e.startAt,nx(e),t))&&(!e.endAt||!zP(e.endAt,nx(e),t)));var t,r,i}function lx(i){return(e,t)=>{let n=!1;for(const r of nx(i)){const i=function(e,i,t){var n=e.field.isKeyField()?pP.comparator(i.key,t.key):function(e,t){var n=i.data.field(e),r=t.data.field(e);return null!==n&&null!==r?vP(n,r):NR()}(e.field,t);switch(e.dir){case"asc":return n;case"desc":return-1*n;default:return NR()}}(r,e,t);if(0!==i)return i;n=n||r.field.isKeyField()}return 0}}function ux(e,t){if(e.C){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:hP(t)?"-0":t}}function hx(e){return{integerValue:""+e}}function dx(e,t){return dP(t)?hx(t):ux(e,t)}class px{constructor(){this._=void 0}}function fx(e,t){return e instanceof wx?bP(n=t)||n&&"doubleValue"in n?t:{integerValue:0}:null;var n}class gx extends px{}class mx extends px{constructor(e){super(),this.elements=e}}function vx(e,t){const n=Tx(t);for(const t of e.elements)n.some(e=>gP(e,t))||n.push(t);return{arrayValue:{values:n}}}class yx extends px{constructor(e){super(),this.elements=e}}function _x(e,t){let n=Tx(t);for(const t of e.elements)n=n.filter(e=>!gP(e,t));return{arrayValue:{values:n}}}class wx extends px{constructor(e,t){super(),this.k=e,this.N=t}}function bx(e){return oP(e.integerValue||e.doubleValue)}function Tx(e){return TP(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class Ix{constructor(e,t){this.field=e,this.transform=t}}class Ex{constructor(e,t){this.version=e,this.transformResults=t}}class kx{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new kx}static exists(e){return new kx(void 0,e)}static updateTime(e){return new kx(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 Sx(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class Cx{}function Ax(e,t,n){e instanceof xx?function(e,t,n){const r=e.value.clone(),i=Mx(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof Dx?function(e,t,n){if(!Sx(e.precondition,t))return t.convertToUnknownDocument(n.version);const r=Mx(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(Ox(e)),i.setAll(r),t.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(e,t,n):t.convertToNoDocument(n.version).setHasCommittedMutations()}function Nx(e,t,n){e instanceof xx?function(e,t,n){if(Sx(e.precondition,t)){const r=e.value.clone(),i=Lx(e.fieldTransforms,n,t);r.setAll(i),t.convertToFoundDocument(Px(t),r).setHasLocalMutations()}}(e,t,n):e instanceof Dx?function(e,t,n){if(Sx(e.precondition,t)){const r=Lx(e.fieldTransforms,n,t),i=t.data;i.setAll(Ox(e)),i.setAll(r),t.convertToFoundDocument(Px(t),i).setHasLocalMutations()}}(e,t,n):(t=t,Sx(e.precondition,t)&&t.convertToNoDocument(GR.min()))}function Rx(e,t){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&&$R(n,r,(e,t)=>function(e,t){return e.field.isEqual(t.field)&&(e=e.transform,t=t.transform,e instanceof mx&&t instanceof mx||e instanceof yx&&t instanceof yx?$R(e.elements,t.elements,gP):e instanceof wx&&t instanceof wx?gP(e.N,t.N):e instanceof gx&&t instanceof gx)}(e,t)))&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask)));var n,r}function Px(e){return e.isFoundDocument()?e.version:GR.min()}class xx extends Cx{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}}class Dx extends Cx{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}}function Ox(n){const r=new Map;return n.fieldMask.fields.forEach(e=>{var t;e.isEmpty()||(t=n.data.field(e),r.set(e,t))}),r}function Mx(e,t,n){const r=new Map;RR(e.length===n.length);for(let u=0;u<n.length;u++){var i=e[u],s=i.transform,o=t.data.field(i.field);r.set(i.field,(a=s,c=o,l=n[u],a instanceof mx?vx(a,c):a instanceof yx?_x(a,c):l))}var a,c,l;return r}function Lx(e,t,n){const r=new Map;for(const l of e){const e=l.transform,u=n.data.field(l.field);r.set(l.field,(i=e,s=u,o=t,c=a=void 0,i instanceof gx?function(){const e={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:o.seconds,nanos:o.nanoseconds}}}};return s&&(e.fields.__previous_value__=s),{mapValue:e}}():i instanceof mx?vx(i,s):i instanceof yx?_x(i,s):(a=fx(i=i,s),c=bx(a)+bx(i.N),bP(a)&&bP(i.N)?hx(c):ux(i.k,c))))}var i,s,o,a,c;return r}class Fx extends Cx{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}}class Ux extends Cx{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}}class jx{constructor(e){this.count=e}}function qx(e){switch(e){default:return NR(),0;case PR.CANCELLED:case PR.UNKNOWN:case PR.DEADLINE_EXCEEDED:case PR.RESOURCE_EXHAUSTED:case PR.INTERNAL:case PR.UNAVAILABLE:case PR.UNAUTHENTICATED:return;case PR.INVALID_ARGUMENT:case PR.NOT_FOUND:case PR.ALREADY_EXISTS:case PR.PERMISSION_DENIED:case PR.FAILED_PRECONDITION:case PR.ABORTED:case PR.OUT_OF_RANGE:case PR.UNIMPLEMENTED:case PR.DATA_LOSS:return 1}}function Vx(e){if(void 0===e)return SR("GRPC error has no .code"),PR.UNKNOWN;switch(e){case uR.OK:return PR.OK;case uR.CANCELLED:return PR.CANCELLED;case uR.UNKNOWN:return PR.UNKNOWN;case uR.DEADLINE_EXCEEDED:return PR.DEADLINE_EXCEEDED;case uR.RESOURCE_EXHAUSTED:return PR.RESOURCE_EXHAUSTED;case uR.INTERNAL:return PR.INTERNAL;case uR.UNAVAILABLE:return PR.UNAVAILABLE;case uR.UNAUTHENTICATED:return PR.UNAUTHENTICATED;case uR.INVALID_ARGUMENT:return PR.INVALID_ARGUMENT;case uR.NOT_FOUND:return PR.NOT_FOUND;case uR.ALREADY_EXISTS:return PR.ALREADY_EXISTS;case uR.PERMISSION_DENIED:return PR.PERMISSION_DENIED;case uR.FAILED_PRECONDITION:return PR.FAILED_PRECONDITION;case uR.ABORTED:return PR.ABORTED;case uR.OUT_OF_RANGE:return PR.OUT_OF_RANGE;case uR.UNIMPLEMENTED:return PR.UNIMPLEMENTED;case uR.DATA_LOSS:return PR.DATA_LOSS;default:return NR()}}(c=uR=uR||{})[c.OK=0]="OK",c[c.CANCELLED=1]="CANCELLED",c[c.UNKNOWN=2]="UNKNOWN",c[c.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",c[c.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",c[c.NOT_FOUND=5]="NOT_FOUND",c[c.ALREADY_EXISTS=6]="ALREADY_EXISTS",c[c.PERMISSION_DENIED=7]="PERMISSION_DENIED",c[c.UNAUTHENTICATED=16]="UNAUTHENTICATED",c[c.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",c[c.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",c[c.ABORTED=10]="ABORTED",c[c.OUT_OF_RANGE=11]="OUT_OF_RANGE",c[c.UNIMPLEMENTED=12]="UNIMPLEMENTED",c[c.INTERNAL=13]="INTERNAL",c[c.UNAVAILABLE=14]="UNAVAILABLE",c[c.DATA_LOSS=15]="DATA_LOSS";class Bx{constructor(e,t){this.comparator=e,this.root=t||Kx.EMPTY}insert(e,t){return new Bx(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,Kx.BLACK,null,null))}remove(e){return new Bx(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Kx.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){var n=this.comparator(e,t.key);if(0===n)return t.value;n<0?t=t.left:0<n&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){var r=this.comparator(e,n.key);if(0===r)return t+n.left.size;n=r<0?n.left:(t+=n.left.size+1,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(n){this.inorderTraversal((e,t)=>(n(e,t),!1))}toString(){const n=[];return this.inorderTraversal((e,t)=>(n.push(`${e}:${t}`),!1)),`{${n.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Wx(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Wx(this.root,e,this.comparator,!1)}getReverseIterator(){return new Wx(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Wx(this.root,e,this.comparator,!0)}}class Wx{constructor(e,t,n,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?n(e.key,t):1,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();var 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 0<this.nodeStack.length}peek(){if(0===this.nodeStack.length)return null;var e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class Kx{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:Kx.RED,this.left=null!=r?r:Kx.EMPTY,this.right=null!=i?i:Kx.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,r,i){return new Kx(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;var 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)),r.fixUp()}removeMin(){if(this.left.isEmpty())return Kx.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let n,r=this;if(t(e,r.key)<0)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 Kx.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.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){var e=this.copy(null,null,Kx.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){var e=this.copy(null,null,Kx.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){var 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(){var e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw NR();if(this.right.isRed())throw NR();var e=this.left.check();if(e!==this.right.check())throw NR();return e+(this.isRed()?0:1)}}Kx.EMPTY=null,Kx.RED=!0,Kx.BLACK=!1,Kx.EMPTY=new class{constructor(){this.size=0}get key(){throw NR()}get value(){throw NR()}get color(){throw NR()}get left(){throw NR()}get right(){throw NR()}copy(e,t,n,r,i){return this}insert(e,t,n){return new Kx(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 $x{constructor(e){this.comparator=e,this.data=new Bx(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(n){this.data.inorderTraversal((e,t)=>(n(e),!1))}forEachInRange(e,t){const n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){var r=n.getNext();if(0<=this.comparator(r.key,e[1]))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){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new zx(this.data.getIterator())}getIteratorFrom(e){return new zx(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 $x))return!1;if(this.size!==e.size)return!1;const t=this.data.getIterator(),n=e.data.getIterator();for(;t.hasNext();){const e=t.getNext().key,r=n.getNext().key;if(0!==this.comparator(e,r))return!1}return!0}toArray(){const t=[];return this.forEach(e=>{t.push(e)}),t}toString(){const t=[];return this.forEach(e=>t.push(e)),"SortedSet("+t.toString()+")"}copy(e){const t=new $x(this.comparator);return t.data=e,t}}class zx{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}const Hx=new Bx(pP.comparator);const Gx=new Bx(pP.comparator);const Qx=new Bx(pP.comparator);const Yx=new $x(pP.comparator);function Jx(...e){let t=Yx;for(const n of e)t=t.add(n);return t}const Xx=new $x(KR);class Zx{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){const n=new Map;return n.set(e,eD.createSynthesizedTargetChangeForCurrentChange(e,t)),new Zx(GR.min(),n,Xx,Hx,Jx())}}class eD{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){return new eD(rP.EMPTY_BYTE_STRING,t,Jx(),Jx(),Jx())}}class tD{constructor(e,t,n,r){this.$=e,this.removedTargetIds=t,this.key=n,this.O=r}}class nD{constructor(e,t){this.targetId=e,this.F=t}}class rD{constructor(e,t,n=rP.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class iD{constructor(){this.M=0,this.L=aD(),this.B=rP.EMPTY_BYTE_STRING,this.U=!1,this.q=!0}get current(){return this.U}get resumeToken(){return this.B}get K(){return 0!==this.M}get j(){return this.q}W(e){0<e.approximateByteSize()&&(this.q=!0,this.B=e)}G(){let n=Jx(),r=Jx(),i=Jx();return this.L.forEach((e,t)=>{switch(t){case 0:n=n.add(e);break;case 2:r=r.add(e);break;case 1:i=i.add(e);break;default:NR()}}),new eD(this.B,this.U,n,r,i)}H(){this.q=!1,this.L=aD()}J(e,t){this.q=!0,this.L=this.L.insert(e,t)}Y(e){this.q=!0,this.L=this.L.remove(e)}X(){this.M+=1}Z(){--this.M}tt(){this.q=!0,this.U=!0}}class sD{constructor(e){this.et=e,this.nt=new Map,this.st=Hx,this.it=oD(),this.rt=new $x(KR)}ot(e){for(const t of e.$)e.O&&e.O.isFoundDocument()?this.at(t,e.O):this.ct(t,e.key,e.O);for(const n of e.removedTargetIds)this.ct(n,e.key,e.O)}ut(n){this.forEachTarget(n,e=>{const t=this.ht(e);switch(n.state){case 0:this.lt(e)&&t.W(n.resumeToken);break;case 1:t.Z(),t.K||t.H(),t.W(n.resumeToken);break;case 2:t.Z(),t.K||this.removeTarget(e);break;case 3:this.lt(e)&&(t.tt(),t.W(n.resumeToken));break;case 4:this.lt(e)&&(this.ft(e),t.W(n.resumeToken));break;default:NR()}})}forEachTarget(e,n){0<e.targetIds.length?e.targetIds.forEach(n):this.nt.forEach((e,t)=>{this.lt(t)&&n(t)})}dt(e){const t=e.targetId,n=e.F.count,r=this.wt(t);if(r){const e=r.target;if(DP(e))if(0===n){const n=new pP(e.path);this.ct(t,n,AP.newNoDocument(n,GR.min()))}else RR(1===n);else this._t(t)!==n&&(this.ft(t),this.rt=this.rt.add(t))}}gt(r){const i=new Map;this.nt.forEach((e,t)=>{var n=this.wt(t);if(n){if(e.current&&DP(n.target)){const i=new pP(n.target.path);null!==this.st.get(i)||this.yt(t,i)||this.ct(t,i,AP.newNoDocument(i,r))}e.j&&(i.set(t,e.G()),e.H())}});let s=Jx();this.it.forEach((e,t)=>{let n=!0;t.forEachWhile(e=>{var t=this.wt(e);return!t||2===t.purpose||(n=!1)}),n&&(s=s.add(e))});var e=new Zx(r,i,this.rt,this.st,s);return this.st=Hx,this.it=oD(),this.rt=new $x(KR),e}at(e,t){var n;this.lt(e)&&(n=this.yt(e,t.key)?2:0,this.ht(e).J(t.key,n),this.st=this.st.insert(t.key,t),this.it=this.it.insert(t.key,this.Tt(t.key).add(e)))}ct(e,t,n){if(this.lt(e)){const r=this.ht(e);this.yt(e,t)?r.J(t,1):r.Y(t),this.it=this.it.insert(t,this.Tt(t).delete(e)),n&&(this.st=this.st.insert(t,n))}}removeTarget(e){this.nt.delete(e)}_t(e){var t=this.ht(e).G();return this.et.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}X(e){this.ht(e).X()}ht(e){let t=this.nt.get(e);return t||(t=new iD,this.nt.set(e,t)),t}Tt(e){let t=this.it.get(e);return t||(t=new $x(KR),this.it=this.it.insert(e,t)),t}lt(e){var t=null!==this.wt(e);return t||kR("WatchChangeAggregator","Detected inactive target",e),t}wt(e){var t=this.nt.get(e);return t&&t.K?null:this.et.Et(e)}ft(t){this.nt.set(t,new iD),this.et.getRemoteKeysForTarget(t).forEach(e=>{this.ct(t,e,null)})}yt(e,t){return this.et.getRemoteKeysForTarget(e).has(t)}}function oD(){return new Bx(pP.comparator)}function aD(){return new Bx(pP.comparator)}const cD={asc:"ASCENDING",desc:"DESCENDING"},lD={"<":"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"};class uD{constructor(e,t){this.databaseId=e,this.C=t}}function hD(e,t){return e.C?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function dD(e,t){return e.C?t.toBase64():t.toUint8Array()}function pD(e){return RR(!!e),GR.fromTimestamp((t=sP(e),new HR(t.seconds,t.nanos)));var t}function fD(e,t){return e=e,new ZR(["projects",e.projectId,"databases",e.database]).child("documents").child(t).canonicalString()}function gD(e){var t=ZR.fromString(e);return RR(MD(t)),t}function mD(e,t){return fD(e.databaseId,t.path)}function vD(e,t){const n=gD(t);if(n.get(1)!==e.databaseId.projectId)throw new xR(PR.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 xR(PR.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new pP(bD(n))}function yD(e,t){return fD(e.databaseId,t)}function _D(e){var t=gD(e);return 4===t.length?ZR.emptyPath():bD(t)}function wD(e){return new ZR(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function bD(e){return RR(4<e.length&&"documents"===e.get(4)),e.popFirst(5)}function TD(e,t,n){return{name:mD(e,t),fields:n.value.mapValue.fields}}function ID(e,t,n){const r=vD(e,t.name),i=pD(t.updateTime),s=new CP({mapValue:{fields:t.fields}}),o=AP.newFoundDocument(r,i,s);return n&&o.setHasCommittedMutations(),n?o.setHasCommittedMutations():o}function ED(e,t){let n;if(t instanceof xx)n={update:TD(e,t.key,t.value)};else if(t instanceof Fx)n={delete:mD(e,t.key)};else if(t instanceof Dx)n={update:TD(e,t.key,t.data),updateMask:function(e){const t=[];return e.fields.forEach(e=>t.push(e.canonicalString())),{fieldPaths:t}}(t.fieldMask)};else{if(!(t instanceof Ux))return NR();n={verify:mD(e,t.key)}}return 0<t.fieldTransforms.length&&(n.updateTransforms=t.fieldTransforms.map(e=>function(e){var t=e.transform;if(t instanceof gx)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(t instanceof mx)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:t.elements}};if(t instanceof yx)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:t.elements}};if(t instanceof wx)return{fieldPath:e.field.canonicalString(),increment:t.N};throw NR()}(e))),t.precondition.isNone||(n.currentDocument=void 0!==(r=t.precondition).updateTime?{updateTime:(t=r.updateTime,hD(e,t.toTimestamp()))}:void 0!==r.exists?{exists:r.exists}:NR()),n;var r}function kD(t,n){const e=n.currentDocument?void 0!==(i=n.currentDocument).updateTime?kx.updateTime(pD(i.updateTime)):void 0!==i.exists?kx.exists(i.exists):kx.none():kx.none(),r=n.updateTransforms?n.updateTransforms.map(e=>function(e,t){let n=null;if("setToServerValue"in t)RR("REQUEST_TIME"===t.setToServerValue),n=new gx;else if("appendMissingElements"in t){const e=t.appendMissingElements.values||[];n=new mx(e)}else if("removeAllFromArray"in t){const e=t.removeAllFromArray.values||[];n=new yx(e)}else"increment"in t?n=new wx(e,t.increment):NR();var r=tP.fromServerFormat(t.fieldPath);return new Ix(r,n)}(t,e)):[];var i;if(n.update){n.update.name;var s=vD(t,n.update.name),o=new CP({mapValue:{fields:n.update.fields}});if(n.updateMask){const t=function(){const e=n.updateMask.fieldPaths||[];return new nP(e.map(e=>tP.fromServerFormat(e)))}();return new Dx(s,o,t,e,r)}return new xx(s,o,e,r)}if(n.delete){const r=vD(t,n.delete);return new Fx(r,e)}if(n.verify){const r=vD(t,n.verify);return new Ux(r,e)}return NR()}function SD(e,t){return{documents:[yD(e,t.path)]}}function CD(e,t){const n={structuredQuery:{}},r=t.path;null!==t.collectionGroup?(n.parent=yD(e,r),n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(n.parent=yD(e,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);var i=function(e){if(0!==e.length){var t=e.map(e=>function(e){if("=="===e.op){if(EP(e.value))return{unaryFilter:{field:PD(e.field),op:"IS_NAN"}};if(IP(e.value))return{unaryFilter:{field:PD(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(EP(e.value))return{unaryFilter:{field:PD(e.field),op:"IS_NOT_NAN"}};if(IP(e.value))return{unaryFilter:{field:PD(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:PD(e.field),op:(t=e.op,lD[t]),value:e.value}};var t}(e));return 1===t.length?t[0]:{compositeFilter:{op:"AND",filters:t}}}}(t.filters);i&&(n.structuredQuery.where=i);i=function(e){if(0!==e.length)return e.map(e=>function(e){return{field:PD(e.field),direction:(e=e.dir,cD[e])}}(e))}(t.orderBy);i&&(n.structuredQuery.orderBy=i);var s,i=(s=t.limit,e.C||uP(s)?s:{value:s});return null!==i&&(n.structuredQuery.limit=i),t.startAt&&(n.structuredQuery.startAt=ND(t.startAt)),t.endAt&&(n.structuredQuery.endAt=ND(t.endAt)),n}function AD(e){let t=_D(e.parent);const n=e.structuredQuery,r=n.from?n.from.length:0;let i=null;if(0<r){RR(1===r);const h=n.from[0];h.allDescendants?i=h.collectionId:t=t.child(h.collectionId)}let s=[];n.where&&(s=function t(e){return e?void 0!==e.unaryFilter?[OD(e)]:void 0!==e.fieldFilter?[DD(e)]:void 0!==e.compositeFilter?e.compositeFilter.filters.map(e=>t(e)).reduce((e,t)=>e.concat(t)):NR():[]}(n.where));let o=[];n.orderBy&&(o=n.orderBy.map(e=>function(e){return new $P(xD(e.field),function(){switch(e.direction){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}())}(e)));let a=null;var c;n.limit&&(a=(e=n.limit,uP(c="object"==typeof e?e.value:e)?null:c));let l=null;n.startAt&&(l=RD(n.startAt));let u=null;return n.endAt&&(u=RD(n.endAt)),QP(t,i,o,s,a,"F",l,u)}function ND(e){return{before:e.before,values:e.position}}function RD(e){var t=!!e.before,n=e.values||[];return new WP(n,t)}function PD(e){return{fieldPath:e.canonicalString()}}function xD(e){return tP.fromServerFormat(e.fieldPath)}function DD(e){return OP.create(xD(e.fieldFilter.field),function(){switch(e.fieldFilter.op){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return NR()}}(),e.fieldFilter.value)}function OD(e){switch(e.unaryFilter.op){case"IS_NAN":var t=xD(e.unaryFilter.field);return OP.create(t,"==",{doubleValue:NaN});case"IS_NULL":t=xD(e.unaryFilter.field);return OP.create(t,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var n=xD(e.unaryFilter.field);return OP.create(n,"!=",{doubleValue:NaN});case"IS_NOT_NULL":n=xD(e.unaryFilter.field);return OP.create(n,"!=",{nullValue:"NULL_VALUE"});default:return NR()}}function MD(e){return 4<=e.length&&"projects"===e.get(0)&&"databases"===e.get(2)}function LD(e){let t="";for(let n=0;n<e.length;n++)0<t.length&&(t=FD(t)),t=function(e,t){let n=t;const r=e.length;for(let i=0;i<r;i++){const r=e.charAt(i);switch(r){case"\0":n+="";break;case"":n+="";break;default:n+=r}}return n}(e.get(n),t);return FD(t)}function FD(e){return e+""}function UD(t){const n=t.length;if(RR(2<=n),2===n)return RR(""===t.charAt(0)&&""===t.charAt(1)),ZR.emptyPath();const r=n-2,i=[];let s="";for(let o=0;o<n;){const n=t.indexOf("",o);switch((n<0||n>r)&&NR(),t.charAt(n+1)){case"":const r=t.substring(o,n);let e;0===s.length?e=r:(s+=r,e=s,s=""),i.push(e);break;case"":s+=t.substring(o,n),s+="\0";break;case"":s+=t.substring(o,n+1);break;default:NR()}o=n+2}return new ZR(i)}class jD{constructor(e,t){this.seconds=e,this.nanoseconds=t}}class qD{constructor(e,t,n){this.ownerId=e,this.allowTabSynchronization=t,this.leaseTimestampMs=n}}qD.store="owner",qD.key="owner";class VD{constructor(e,t,n){this.userId=e,this.lastAcknowledgedBatchId=t,this.lastStreamToken=n}}VD.store="mutationQueues",VD.keyPath="userId";class BD{constructor(e,t,n,r,i){this.userId=e,this.batchId=t,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i}}BD.store="mutations",BD.keyPath="batchId",BD.userMutationsIndex="userMutationsIndex",BD.userMutationsKeyPath=["userId","batchId"];class WD{constructor(){}static prefixForUser(e){return[e]}static prefixForPath(e,t){return[e,LD(t)]}static key(e,t,n){return[e,LD(t),n]}}WD.store="documentMutations",WD.PLACEHOLDER=new WD;class KD{constructor(e,t){this.path=e,this.readTime=t}}class $D{constructor(e,t){this.path=e,this.version=t}}class zD{constructor(e,t,n,r,i,s){this.unknownDocument=e,this.noDocument=t,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=s}}zD.store="remoteDocuments",zD.readTimeIndex="readTimeIndex",zD.readTimeIndexPath="readTime",zD.collectionReadTimeIndex="collectionReadTimeIndex",zD.collectionReadTimeIndexPath=["parentPath","readTime"];class HD{constructor(e){this.byteSize=e}}HD.store="remoteDocumentGlobal",HD.key="remoteDocumentGlobalKey";class GD{constructor(e,t,n,r,i,s,o){this.targetId=e,this.canonicalId=t,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=s,this.query=o}}GD.store="targets",GD.keyPath="targetId",GD.queryTargetsIndexName="queryTargetsIndex",GD.queryTargetsKeyPath=["canonicalId","targetId"];class QD{constructor(e,t,n){this.targetId=e,this.path=t,this.sequenceNumber=n}}QD.store="targetDocuments",QD.keyPath=["targetId","path"],QD.documentTargetsIndex="documentTargetsIndex",QD.documentTargetsKeyPath=["path","targetId"];class YD{constructor(e,t,n,r){this.highestTargetId=e,this.highestListenSequenceNumber=t,this.lastRemoteSnapshotVersion=n,this.targetCount=r}}YD.key="targetGlobalKey",YD.store="targetGlobal";class JD{constructor(e,t){this.collectionId=e,this.parent=t}}JD.store="collectionParents",JD.keyPath=["collectionId","parent"];class XD{constructor(e,t,n,r){this.clientId=e,this.updateTimeMs=t,this.networkEnabled=n,this.inForeground=r}}XD.store="clientMetadata",XD.keyPath="clientId";class ZD{constructor(e,t,n){this.bundleId=e,this.createTime=t,this.version=n}}ZD.store="bundles",ZD.keyPath="bundleId";class eO{constructor(e,t,n){this.name=e,this.readTime=t,this.bundledQuery=n}}eO.store="namedQueries",eO.keyPath="name";const tO=[VD.store,BD.store,WD.store,zD.store,GD.store,qD.store,YD.store,QD.store,XD.store,HD.store,JD.store,ZD.store,eO.store],nO="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class rO{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}class iO{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(r,i){return this.callbackAttached&&NR(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(i,this.error):this.wrapSuccess(r,this.result):new iO((t,n)=>{this.nextCallback=e=>{this.wrapSuccess(r,e).next(t,n)},this.catchCallback=e=>{this.wrapFailure(i,e).next(t,n)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{var t=e();return t instanceof iO?t:iO.resolve(t)}catch(e){return iO.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):iO.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):iO.reject(t)}static resolve(n){return new iO((e,t)=>{e(n)})}static reject(n){return new iO((e,t)=>{t(n)})}static waitFor(e){return new iO((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=iO.resolve(!1);for(const n of e)t=t.next(e=>e?iO.resolve(e):n());return t}static forEach(e,n){const r=[];return e.forEach((e,t)=>{r.push(n.call(this,e,t))}),this.waitFor(r)}}class sO{constructor(n,e){this.action=n,this.transaction=e,this.aborted=!1,this.It=new DR,this.transaction.oncomplete=()=>{this.It.resolve()},this.transaction.onabort=()=>{e.error?this.It.reject(new cO(n,e.error)):this.It.resolve()},this.transaction.onerror=e=>{var t=pO(e.target.error);this.It.reject(new cO(n,t))}}static open(e,t,n,r){try{return new sO(t,e.transaction(r,n))}catch(e){throw new cO(t,e)}}get At(){return this.It.promise}abort(e){e&&this.It.reject(e),this.aborted||(kR("SimpleDb","Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}store(e){var t=this.transaction.objectStore(e);return new uO(t)}}class oO{constructor(e,t,n){this.name=e,this.version=t,this.Rt=n,12.2===oO.bt(sd())&&SR("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.")}static delete(e){return kR("SimpleDb","Removing database:",e),hO(window.indexedDB.deleteDatabase(e)).toPromise()}static Pt(){if(!dd())return!1;if(oO.vt())return!0;const e=sd(),t=oO.bt(e),n=0<t&&t<10,r=oO.Vt(e),i=0<r&&r<4.5;return!(0<e.indexOf("MSIE ")||0<e.indexOf("Trident/")||0<e.indexOf("Edge/")||n||i)}static vt(){var e;return"undefined"!=typeof process&&"YES"===(null===(e=process.env)||void 0===e?void 0:e.St)}static Dt(e,t){return e.store(t)}static bt(e){const t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=t?t[1].split("_").slice(0,2).join("."):"-1";return Number(n)}static Vt(e){const t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(n)}async Ct(s){return this.db||(kR("SimpleDb","Opening database:",this.name),this.db=await new Promise((n,r)=>{const i=indexedDB.open(this.name,this.version);i.onsuccess=e=>{var t=e.target.result;n(t)},i.onblocked=()=>{r(new cO(s,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=e=>{var t=e.target.error;"VersionError"===t.name?r(new xR(PR.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"===t.name?r(new xR(PR.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: "+t)):r(new cO(s,t))},i.onupgradeneeded=e=>{kR("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',e.oldVersion);var t=e.target.result;this.Rt.Nt(t,i.transaction,e.oldVersion,this.version).next(()=>{kR("SimpleDb","Database upgrade to version "+this.version+" complete")})}})),this.kt&&(this.db.onversionchange=e=>this.kt(e)),this.db}xt(t){this.kt=t,this.db&&(this.db.onversionchange=e=>t(e))}async runTransaction(e,t,n,r){var i="readonly"===t;let s=0;for(;;){++s;try{this.db=await this.Ct(e);const t=sO.open(this.db,e,i?"readonly":"readwrite",n),s=r(t).catch(e=>(t.abort(e),iO.reject(e))).toPromise();return s.catch(()=>{}),await t.At,s}catch(e){const t="FirebaseError"!==e.name&&s<3;if(kR("SimpleDb","Transaction failed with error:",e.message,"Retrying:",t),this.close(),!t)return Promise.reject(e)}}}close(){this.db&&this.db.close(),this.db=void 0}}class aO{constructor(e){this.$t=e,this.Ot=!1,this.Ft=null}get isDone(){return this.Ot}get Mt(){return this.Ft}set cursor(e){this.$t=e}done(){this.Ot=!0}Lt(e){this.Ft=e}delete(){return hO(this.$t.delete())}}class cO extends xR{constructor(e,t){super(PR.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function lO(e){return"IndexedDbTransactionError"===e.name}class uO{constructor(e){this.store=e}put(e,t){let n;return n=void 0!==t?(kR("SimpleDb","PUT",this.store.name,e,t),this.store.put(t,e)):(kR("SimpleDb","PUT",this.store.name,"<auto-key>",e),this.store.put(e)),hO(n)}add(e){return kR("SimpleDb","ADD",this.store.name,e,e),hO(this.store.add(e))}get(t){return hO(this.store.get(t)).next(e=>(kR("SimpleDb","GET",this.store.name,t,e=void 0===e?null:e),e))}delete(e){return kR("SimpleDb","DELETE",this.store.name,e),hO(this.store.delete(e))}count(){return kR("SimpleDb","COUNT",this.store.name),hO(this.store.count())}Bt(e,t){const n=this.cursor(this.options(e,t)),r=[];return this.Ut(n,(e,t)=>{r.push(t)}).next(()=>r)}qt(e,t){kR("SimpleDb","DELETE ALL",this.store.name);const n=this.options(e,t);n.Kt=!1;var r=this.cursor(n);return this.Ut(r,(e,t,n)=>n.delete())}jt(e,t){let n;t?n=e:(n={},t=e);var r=this.cursor(n);return this.Ut(r,t)}Qt(i){const e=this.cursor({});return new iO((n,r)=>{e.onerror=e=>{var t=pO(e.target.error);r(t)},e.onsuccess=e=>{const t=e.target.result;t?i(t.primaryKey,t.value).next(e=>{e?t.continue():n()}):n()}})}Ut(e,s){const o=[];return new iO((i,t)=>{e.onerror=e=>{t(e.target.error)},e.onsuccess=e=>{const t=e.target.result;if(t){const n=new aO(t),r=s(t.primaryKey,t.value,n);if(r instanceof iO){const e=r.catch(e=>(n.done(),iO.reject(e)));o.push(e)}n.isDone?i():null===n.Mt?t.continue():t.continue(n.Mt)}else i()}}).next(()=>iO.waitFor(o))}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){const n=this.store.index(e.index);return e.Kt?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}function hO(e){return new iO((n,r)=>{e.onsuccess=e=>{var t=e.target.result;n(t)},e.onerror=e=>{var t=pO(e.target.error);r(t)}})}let dO=!1;function pO(e){const t=oO.bt(sd());if(12.2<=t&&t<13){const t="An internal error was encountered in the Indexed Database server";if(0<=e.message.indexOf(t)){const e=new xR("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 dO||(dO=!0,setTimeout(()=>{throw e},0)),e}}return e}class fO extends rO{constructor(e,t){super(),this.Wt=e,this.currentSequenceNumber=t}}function gO(e,t){var n=e;return oO.Dt(n.Wt,t)}class mO{constructor(e,t,n,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(e,t){var n=t.mutationResults;for(let r=0;r<this.mutations.length;r++){const i=this.mutations[r];i.key.isEqual(e.key)&&Ax(i,e,n[r])}}applyToLocalView(e){for(const t of this.baseMutations)t.key.isEqual(e.key)&&Nx(t,e,this.localWriteTime);for(const n of this.mutations)n.key.isEqual(e.key)&&Nx(n,e,this.localWriteTime)}applyToLocalDocumentSet(r){this.mutations.forEach(e=>{const t=r.get(e.key),n=t;this.applyToLocalView(n),t.isValidDocument()||n.convertToNoDocument(GR.min())})}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),Jx())}isEqual(e){return this.batchId===e.batchId&&$R(this.mutations,e.mutations,(e,t)=>Rx(e,t))&&$R(this.baseMutations,e.baseMutations,(e,t)=>Rx(e,t))}}class vO{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(e,t,n){RR(e.mutations.length===n.length);let r=Qx;var i=e.mutations;for(let s=0;s<i.length;s++)r=r.insert(i[s].key,n[s].version);return new vO(e,t,n,r)}}class yO{constructor(e,t,n,r,i=GR.min(),s=GR.min(),o=rP.EMPTY_BYTE_STRING){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=o}withSequenceNumber(e){return new yO(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)}withResumeToken(e,t){return new yO(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e)}withLastLimboFreeSnapshotVersion(e){return new yO(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken)}}class _O{constructor(e){this.Gt=e}}function wO(e,t){if(t.document)return ID(e.Gt,t.document,!!t.hasCommittedMutations);if(t.noDocument){const e=pP.fromSegments(t.noDocument.path),n=kO(t.noDocument.readTime),r=AP.newNoDocument(e,n);return t.hasCommittedMutations?r.setHasCommittedMutations():r}if(t.unknownDocument){const e=pP.fromSegments(t.unknownDocument.path),i=kO(t.unknownDocument.version);return AP.newUnknownDocument(e,i)}return NR()}function bO(e,t,n){var r=TO(n),i=t.key.path.popLast().toArray();if(t.isFoundDocument()){const s={name:mD(n=e.Gt,(e=t).key),fields:e.data.value.mapValue.fields,updateTime:hD(n,e.version.toTimestamp())},o=t.hasCommittedMutations;return new zD(null,null,s,o,r,i)}if(t.isNoDocument()){const a=t.key.path.toArray(),s=EO(t.version),c=t.hasCommittedMutations;return new zD(null,new KD(a,s),null,c,r,i)}if(t.isUnknownDocument()){const a=t.key.path.toArray(),s=EO(t.version);return new zD(new $D(a,s),null,null,!0,r,i)}return NR()}function TO(e){var t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function IO(e){var t=new HR(e[0],e[1]);return GR.fromTimestamp(t)}function EO(e){var t=e.toTimestamp();return new jD(t.seconds,t.nanoseconds)}function kO(e){var t=new HR(e.seconds,e.nanoseconds);return GR.fromTimestamp(t)}function SO(t,e){const n=(e.baseMutations||[]).map(e=>kD(t.Gt,e));for(let s=0;s<e.mutations.length-1;++s){const n=e.mutations[s];if(s+1<e.mutations.length&&void 0!==e.mutations[s+1].transform){const r=e.mutations[s+1];n.updateTransforms=r.transform.fieldTransforms,e.mutations.splice(s+1,1),++s}}const r=e.mutations.map(e=>kD(t.Gt,e)),i=HR.fromMillis(e.localWriteTimeMs);return new mO(e.batchId,i,n,r)}function CO(e){var t,n=kO(e.readTime),r=void 0!==e.lastLimboFreeSnapshotVersion?kO(e.lastLimboFreeSnapshotVersion):GR.min();let i;return i=void 0!==e.query.documents?(RR(1===(t=e.query).documents.length),rx(YP(_D(t.documents[0])))):rx(AD(e.query)),new yO(i,e.targetId,0,e.lastListenSequenceNumber,n,r,rP.fromBase64String(e.resumeToken))}function AO(e,t){var n=EO(t.snapshotVersion),r=EO(t.lastLimboFreeSnapshotVersion),i=(DP(t.target)?SD:CD)(e.Gt,t.target),s=t.resumeToken.toBase64();return new GD(t.targetId,PP(t.target),n,s,t.sequenceNumber,r,i)}function NO(e){var t=AD({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?ix(t,t.limit,"L"):t}class RO{getBundleMetadata(e,t){return PO(e).get(t).next(e=>{if(e)return{id:(t=e).bundleId,createTime:kO(t.createTime),version:t.version};var t})}saveBundleMetadata(e,t){return PO(e).put({bundleId:(n=t).id,createTime:EO(pD(n.createTime)),version:n.version});var n}getNamedQuery(e,t){return xO(e).get(t).next(e=>{if(e)return{name:(t=e).name,query:NO(t.bundledQuery),readTime:kO(t.readTime)};var t})}saveNamedQuery(e,t){return xO(e).put({name:(t=t).name,readTime:EO(pD(t.readTime)),bundledQuery:t.bundledQuery})}}function PO(e){return gO(e,ZD.store)}function xO(e){return gO(e,eO.store)}class DO{constructor(){this.zt=new OO}addToCollectionParentIndex(e,t){return this.zt.add(t),iO.resolve()}getCollectionParents(e,t){return iO.resolve(this.zt.getEntries(t))}}class OO{constructor(){this.index={}}add(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new $x(ZR.comparator),i=!r.has(n);return this.index[t]=r.add(n),i}has(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t];return r&&r.has(n)}getEntries(e){return(this.index[e]||new $x(ZR.comparator)).toArray()}}class MO{constructor(){this.Ht=new OO}addToCollectionParentIndex(e,t){if(this.Ht.has(t))return iO.resolve();var n=t.lastSegment(),r=t.popLast();e.addOnCommittedListener(()=>{this.Ht.add(t)});r={collectionId:n,parent:LD(r)};return LO(e).put(r)}getCollectionParents(e,n){const r=[],t=IDBKeyRange.bound([n,""],[zR(n),""],!1,!0);return LO(e).Bt(t).next(e=>{for(const t of e){if(t.collectionId!==n)break;r.push(UD(t.parent))}return r})}}function LO(e){return gO(e,JD.store)}const FO={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class UO{constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}static withCacheSize(e){return new UO(e,UO.DEFAULT_COLLECTION_PERCENTILE,UO.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}function jO(e,t,n){const r=e.store(BD.store),i=e.store(WD.store),s=[],o=IDBKeyRange.only(n.batchId);let a=0;const c=r.jt({range:o},(e,t,n)=>(a++,n.delete()));s.push(c.next(()=>{RR(1===a)}));const l=[];for(const e of n.mutations){const r=WD.key(t,e.key.path,n.batchId);s.push(i.delete(r)),l.push(e.key)}return iO.waitFor(s).next(()=>l)}function qO(e){if(!e)return 0;let t;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw NR();t=e.noDocument}return JSON.stringify(t).length}UO.DEFAULT_COLLECTION_PERCENTILE=10,UO.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,UO.DEFAULT=new UO(41943040,UO.DEFAULT_COLLECTION_PERCENTILE,UO.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),UO.DISABLED=new UO(-1,0,0);class VO{constructor(e,t,n,r){this.userId=e,this.k=t,this.Jt=n,this.referenceDelegate=r,this.Yt={}}static Xt(e,t,n,r){RR(""!==e.uid);var i=e.isAuthenticated()?e.uid:"";return new VO(i,t,n,r)}checkEmpty(e){let r=!0;var t=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return WO(e).jt({index:BD.userMutationsIndex,range:t},(e,t,n)=>{r=!1,n.done()}).next(()=>r)}addMutationBatch(u,h,d,p){const f=KO(u),g=WO(u);return g.add({}).next(e=>{RR("number"==typeof e);const t=new mO(e,h,d,p),n=(i=this.k,s=this.userId,o=t,a=o.baseMutations.map(e=>ED(i.Gt,e)),c=o.mutations.map(e=>ED(i.Gt,e)),new BD(s,o.batchId,o.localWriteTime.toMillis(),a,c)),r=[];var i,s,o,a,c;let l=new $x((e,t)=>KR(e.canonicalString(),t.canonicalString()));for(const u of p){const h=WD.key(this.userId,u.key.path,e);l=l.add(u.key.path.popLast()),r.push(g.put(n)),r.push(f.put(h,WD.PLACEHOLDER))}return l.forEach(e=>{r.push(this.Jt.addToCollectionParentIndex(u,e))}),u.addOnCommittedListener(()=>{this.Yt[e]=t.keys()}),iO.waitFor(r).next(()=>t)})}lookupMutationBatch(e,t){return WO(e).get(t).next(e=>e?(RR(e.userId===this.userId),SO(this.k,e)):null)}Zt(e,n){return this.Yt[n]?iO.resolve(this.Yt[n]):this.lookupMutationBatch(e,n).next(e=>{if(e){var t=e.keys();return this.Yt[n]=t}return null})}getNextMutationBatchAfterBatchId(e,t){const r=t+1,n=IDBKeyRange.lowerBound([this.userId,r]);let i=null;return WO(e).jt({index:BD.userMutationsIndex,range:n},(e,t,n)=>{t.userId===this.userId&&(RR(t.batchId>=r),i=SO(this.k,t)),n.done()}).next(()=>i)}getHighestUnacknowledgedBatchId(e){var t=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let r=-1;return WO(e).jt({index:BD.userMutationsIndex,range:t,reverse:!0},(e,t,n)=>{r=t.batchId,n.done()}).next(()=>r)}getAllMutationBatches(e){var t=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return WO(e).Bt(BD.userMutationsIndex,t).next(e=>e.map(e=>SO(this.k,e)))}getAllMutationBatchesAffectingDocumentKey(o,a){const e=WD.prefixForPath(this.userId,a.path),t=IDBKeyRange.lowerBound(e),c=[];return KO(o).jt({range:t},(e,t,n)=>{var[r,i,s]=e,i=UD(i);if(r===this.userId&&a.path.isEqual(i))return WO(o).get(s).next(e=>{if(!e)throw NR();RR(e.userId===this.userId),c.push(SO(this.k,e))});n.done()}).next(()=>c)}getAllMutationBatchesAffectingDocumentKeys(t,e){let a=new $x(KR);const n=[];return e.forEach(o=>{var e=WD.prefixForPath(this.userId,o.path),e=IDBKeyRange.lowerBound(e),e=KO(t).jt({range:e},(e,t,n)=>{var[r,i,s]=e,i=UD(i);r===this.userId&&o.path.isEqual(i)?a=a.add(s):n.done()});n.push(e)}),iO.waitFor(n).next(()=>this.te(t,a))}getAllMutationBatchesAffectingQuery(e,t){const o=t.path,a=o.length+1,n=WD.prefixForPath(this.userId,o),r=IDBKeyRange.lowerBound(n);let c=new $x(KR);return KO(e).jt({range:r},(e,t,n)=>{var[r,i,s]=e,i=UD(i);r===this.userId&&o.isPrefixOf(i)?i.length===a&&(c=c.add(s)):n.done()}).next(()=>this.te(e,c))}te(t,e){const n=[],r=[];return e.forEach(e=>{r.push(WO(t).get(e).next(e=>{if(null===e)throw NR();RR(e.userId===this.userId),n.push(SO(this.k,e))}))}),iO.waitFor(r).next(()=>n)}removeMutationBatch(t,n){return jO(t.Wt,this.userId,n).next(e=>(t.addOnCommittedListener(()=>{this.ee(n.batchId)}),iO.forEach(e,e=>this.referenceDelegate.markPotentiallyOrphaned(t,e))))}ee(e){delete this.Yt[e]}performConsistencyCheck(n){return this.checkEmpty(n).next(e=>{if(!e)return iO.resolve();const t=IDBKeyRange.lowerBound(WD.prefixForUser(this.userId)),r=[];return KO(n).jt({range:t},(e,t,n)=>{if(e[0]===this.userId){const t=UD(e[1]);r.push(t)}else n.done()}).next(()=>{RR(0===r.length)})})}containsKey(e,t){return BO(e,this.userId,t)}ne(e){return $O(e).get(this.userId).next(e=>e||new VD(this.userId,-1,""))}}function BO(e,s,t){const n=WD.prefixForPath(s,t.path),o=n[1],r=IDBKeyRange.lowerBound(n);let a=!1;return KO(e).jt({range:r,Kt:!0},(e,t,n)=>{var[r,i]=e;r===s&&i===o&&(a=!0),n.done()}).next(()=>a)}function WO(e){return gO(e,BD.store)}function KO(e){return gO(e,WD.store)}function $O(e){return gO(e,VD.store)}class zO{constructor(e){this.se=e}next(){return this.se+=2,this.se}static ie(){return new zO(0)}static re(){return new zO(-1)}}class HO{constructor(e,t){this.referenceDelegate=e,this.k=t}allocateTargetId(n){return this.oe(n).next(e=>{const t=new zO(e.highestTargetId);return e.highestTargetId=t.next(),this.ae(n,e).next(()=>e.highestTargetId)})}getLastRemoteSnapshotVersion(e){return this.oe(e).next(e=>GR.fromTimestamp(new HR(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(e){return this.oe(e).next(e=>e.highestListenSequenceNumber)}setTargetsMetadata(t,n,r){return this.oe(t).next(e=>(e.highestListenSequenceNumber=n,r&&(e.lastRemoteSnapshotVersion=r.toTimestamp()),n>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=n),this.ae(t,e)))}addTargetData(t,n){return this.ce(t,n).next(()=>this.oe(t).next(e=>(e.targetCount+=1,this.ue(n,e),this.ae(t,e))))}updateTargetData(e,t){return this.ce(e,t)}removeTargetData(t,e){return this.removeMatchingKeysForTargetId(t,e.targetId).next(()=>GO(t).delete(e.targetId)).next(()=>this.oe(t)).next(e=>(RR(0<e.targetCount),--e.targetCount,this.ae(t,e)))}removeTargets(r,i,s){let o=0;const a=[];return GO(r).jt((e,t)=>{var n=CO(t);n.sequenceNumber<=i&&null===s.get(n.targetId)&&(o++,a.push(this.removeTargetData(r,n)))}).next(()=>iO.waitFor(a)).next(()=>o)}forEachTarget(e,r){return GO(e).jt((e,t)=>{var n=CO(t);r(n)})}oe(e){return QO(e).get(YD.key).next(e=>(RR(null!==e),e))}ae(e,t){return QO(e).put(YD.key,t)}ce(e,t){return GO(e).put(AO(this.k,t))}ue(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.oe(e).next(e=>e.targetCount)}getTargetData(e,i){var t=PP(i),t=IDBKeyRange.bound([t,Number.NEGATIVE_INFINITY],[t,Number.POSITIVE_INFINITY]);let s=null;return GO(e).jt({range:t,index:GD.queryTargetsIndexName},(e,t,n)=>{var r=CO(t);xP(i,r.target)&&(s=r,n.done())}).next(()=>s)}addMatchingKeys(n,e,r){const i=[],s=YO(n);return e.forEach(e=>{var t=LD(e.path);i.push(s.put(new QD(r,t))),i.push(this.referenceDelegate.addReference(n,r,e))}),iO.waitFor(i)}removeMatchingKeys(n,e,r){const i=YO(n);return iO.forEach(e,e=>{var t=LD(e.path);return iO.waitFor([i.delete([r,t]),this.referenceDelegate.removeReference(n,r,e)])})}removeMatchingKeysForTargetId(e,t){const n=YO(e),r=IDBKeyRange.bound([t],[t+1],!1,!0);return n.delete(r)}getMatchingKeysForTargetId(e,t){const n=IDBKeyRange.bound([t],[t+1],!1,!0),r=YO(e);let i=Jx();return r.jt({range:n,Kt:!0},(e,t,n)=>{var r=UD(e[1]),r=new pP(r);i=i.add(r)}).next(()=>i)}containsKey(e,t){var n=LD(t.path),n=IDBKeyRange.bound([n],[zR(n)],!1,!0);let r=0;return YO(e).jt({index:QD.documentTargetsIndex,Kt:!0,range:n},([e],t,n)=>{0!==e&&(r++,n.done())}).next(()=>0<r)}Et(e,t){return GO(e).get(t).next(e=>e?CO(e):null)}}function GO(e){return gO(e,GD.store)}function QO(e){return gO(e,YD.store)}function YO(e){return gO(e,QD.store)}async function JO(e){if(e.code!==PR.FAILED_PRECONDITION||e.message!==nO)throw e;kR("LocalStore","Unexpectedly lost primary lease")}function XO([e,t],[n,r]){var i=KR(e,n);return 0===i?KR(t,r):i}class ZO{constructor(e){this.he=e,this.buffer=new $x(XO),this.le=0}fe(){return++this.le}de(e){var t=[e,this.fe()];if(this.buffer.size<this.he)this.buffer=this.buffer.add(t);else{const e=this.buffer.last();XO(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class e1{constructor(e,t){this.garbageCollector=e,this.asyncQueue=t,this.we=!1,this._e=null}start(e){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.me(e)}stop(){this._e&&(this._e.cancel(),this._e=null)}get started(){return null!==this._e}me(e){var t=this.we?3e5:6e4;kR("LruGarbageCollector",`Garbage collection scheduled in ${t}ms`),this._e=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",t,async()=>{this._e=null,this.we=!0;try{await e.collectGarbage(this.garbageCollector)}catch(e){lO(e)?kR("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e):await JO(e)}await this.me(e)})}}class t1{constructor(e,t){this.ge=e,this.params=t}calculateTargetCount(e,t){return this.ge.ye(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return iO.resolve(BR.I);const n=new ZO(t);return this.ge.forEachTarget(e,e=>n.de(e.sequenceNumber)).next(()=>this.ge.pe(e,e=>n.de(e))).next(()=>n.maxValue)}removeTargets(e,t,n){return this.ge.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.ge.removeOrphanedDocuments(e,t)}collect(t,n){return-1===this.params.cacheSizeCollectionThreshold?(kR("LruGarbageCollector","Garbage collection skipped; disabled"),iO.resolve(FO)):this.getCacheSize(t).next(e=>e<this.params.cacheSizeCollectionThreshold?(kR("LruGarbageCollector",`Garbage collection skipped; Cache size ${e} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),FO):this.Te(t,n))}getCacheSize(e){return this.ge.getCacheSize(e)}Te(t,n){let r,i,s,o,a,c,l;const u=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next(e=>(i=e>this.params.maximumSequenceNumbersToCollect?(kR("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${e}`),this.params.maximumSequenceNumbersToCollect):e,o=Date.now(),this.nthSequenceNumber(t,i))).next(e=>(r=e,a=Date.now(),this.removeTargets(t,r,n))).next(e=>(s=e,c=Date.now(),this.removeOrphanedDocuments(t,r))).next(e=>(l=Date.now(),ER()<=Kh.DEBUG&&kR("LruGarbageCollector",`LRU Garbage Collection\n\tCounted targets in ${o-u}ms\n\tDetermined least recently used ${i} in `+(a-o)+"ms\n"+`\tRemoved ${s} targets in `+(c-a)+"ms\n"+`\tRemoved ${e} documents in `+(l-c)+"ms\n"+`Total Duration: ${l-u}ms`),iO.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:s,documentsRemoved:e})))}}class n1{constructor(e,t){this.db=e,this.garbageCollector=(e=this,t=t,new t1(e,t))}ye(e){const n=this.Ee(e);return this.db.getTargetCache().getTargetCount(e).next(t=>n.next(e=>t+e))}Ee(e){let t=0;return this.pe(e,e=>{t++}).next(()=>t)}forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}pe(e,n){return this.Ie(e,(e,t)=>n(t))}addReference(e,t,n){return r1(e,n)}removeReference(e,t,n){return r1(e,n)}removeTargets(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}markPotentiallyOrphaned(e,t){return r1(e,t)}Ae(t,n){let r=!1;return $O(t).Qt(e=>BO(t,e,n).next(e=>(e&&(r=!0),iO.resolve(!e)))).next(()=>r)}removeOrphanedDocuments(n,r){const i=this.db.getRemoteDocumentCache().newChangeBuffer(),s=[];let o=0;return this.Ie(n,(t,e)=>{if(e<=r){const r=this.Ae(n,t).next(e=>{if(!e)return o++,i.getEntry(n,t).next(()=>(i.removeEntry(t),YO(n).delete([0,LD(t.path)])))});s.push(r)}}).next(()=>iO.waitFor(s)).next(()=>i.apply(n)).next(()=>o)}removeTarget(e,t){var n=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,n)}updateLimboDocument(e,t){return r1(e,t)}Ie(e,r){const t=YO(e);let i,s=BR.I;return t.jt({index:QD.documentTargetsIndex},([e],{path:t,sequenceNumber:n})=>{0===e?(s!==BR.I&&r(new pP(UD(i)),s),s=n,i=t):s=BR.I}).next(()=>{s!==BR.I&&r(new pP(UD(i)),s)})}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function r1(e,t){return YO(e).put((t=t,e=e.currentSequenceNumber,new QD(0,LD(t.path),e)))}class i1{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={}}get(e){const t=this.mapKeyFn(e),n=this.inner[t];if(void 0!==n)for(const[t,r]of n)if(this.equalsFn(t,e))return r}has(e){return void 0!==this.get(e)}set(t,n){const e=this.mapKeyFn(t),r=this.inner[e];if(void 0!==r){for(let e=0;e<r.length;e++)if(this.equalsFn(r[e][0],t))return void(r[e]=[t,n]);r.push([t,n])}else this.inner[e]=[[t,n]]}delete(e){const 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),!0;return!1}forEach(r){YR(this.inner,(e,t)=>{for(const[e,n]of t)r(e,n)})}isEmpty(){return JR(this.inner)}}class s1{constructor(){this.changes=new i1(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}getReadTime(e){var t=this.changes.get(e);return t?t.readTime:GR.min()}addEntry(e,t){this.assertNotApplied(),this.changes.set(e.key,{document:e,readTime:t})}removeEntry(e,t=null){this.assertNotApplied(),this.changes.set(e,{document:AP.newInvalidDocument(e),readTime:t})}getEntry(e,t){this.assertNotApplied();var n=this.changes.get(t);return void 0!==n?iO.resolve(n.document):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 o1{constructor(e,t){this.k=e,this.Jt=t}addEntry(e,t,n){return l1(e).put(u1(t),n)}removeEntry(e,t){const n=l1(e),r=u1(t);return n.delete(r)}updateMetadata(t,n){return this.getMetadata(t).next(e=>(e.byteSize+=n,this.Re(t,e)))}getEntry(e,t){return l1(e).get(u1(t)).next(e=>this.be(t,e))}Pe(e,t){return l1(e).get(u1(t)).next(e=>({document:this.be(t,e),size:qO(e)}))}getEntries(e,t){let r=Hx;return this.ve(e,t,(e,t)=>{var n=this.be(e,t);r=r.insert(e,n)}).next(()=>r)}Ve(e,t){let r=Hx,i=new Bx(pP.comparator);return this.ve(e,t,(e,t)=>{var n=this.be(e,t);r=r.insert(e,n),i=i.insert(e,qO(t))}).next(()=>({documents:r,Se:i}))}ve(e,t,i){if(t.isEmpty())return iO.resolve();const n=IDBKeyRange.bound(t.first().path.toArray(),t.last().path.toArray()),s=t.getIterator();let o=s.getNext();return l1(e).jt({range:n},(e,t,n)=>{for(var r=pP.fromSegments(e);o&&pP.comparator(o,r)<0;)i(o,null),o=s.getNext();o&&o.isEqual(r)&&(i(o,t),o=s.hasNext()?s.getNext():null),o?n.Lt(o.path.toArray()):n.done()}).next(()=>{for(;o;)i(o,null),o=s.hasNext()?s.getNext():null})}getDocumentsMatchingQuery(e,i,t){let s=Hx;const o=i.path.length+1,n={};if(t.isEqual(GR.min())){const e=i.path.toArray();n.range=IDBKeyRange.lowerBound(e)}else{const e=i.path.toArray(),s=TO(t);n.range=IDBKeyRange.lowerBound([e,s],!0),n.index=zD.collectionReadTimeIndex}return l1(e).jt(n,(e,t,n)=>{var r;e.length===o&&(r=wO(this.k,t),i.path.isPrefixOf(r.key.path)?cx(i,r)&&(s=s.insert(r.key,r)):n.done())}).next(()=>s)}newChangeBuffer(e){return new a1(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next(e=>e.byteSize)}getMetadata(e){return c1(e).get(HD.key).next(e=>(RR(!!e),e))}Re(e,t){return c1(e).put(HD.key,t)}be(e,t){if(t){const e=wO(this.k,t);if(!e.isNoDocument()||!e.version.isEqual(GR.min()))return e}return AP.newInvalidDocument(e)}}class a1 extends s1{constructor(e,t){super(),this.De=e,this.trackRemovals=t,this.Ce=new i1(e=>e.toString(),(e,t)=>e.isEqual(t))}applyChanges(s){const o=[];let a=0,c=new $x((e,t)=>KR(e.canonicalString(),t.canonicalString()));return this.changes.forEach((e,t)=>{var n=this.Ce.get(e);if(t.document.isValidDocument()){var r=bO(this.De.k,t.document,this.getReadTime(e));c=c.add(e.path.popLast());var i=qO(r);a+=i-n,o.push(this.De.addEntry(s,e,r))}else if(a-=n,this.trackRemovals){const a=bO(this.De.k,AP.newNoDocument(e,GR.min()),this.getReadTime(e));o.push(this.De.addEntry(s,e,a))}else o.push(this.De.removeEntry(s,e))}),c.forEach(e=>{o.push(this.De.Jt.addToCollectionParentIndex(s,e))}),o.push(this.De.updateMetadata(s,a)),iO.waitFor(o)}getFromCache(e,t){return this.De.Pe(e,t).next(e=>(this.Ce.set(t,e.size),e.document))}getAllFromCache(e,t){return this.De.Ve(e,t).next(({documents:e,Se:t})=>(t.forEach((e,t)=>{this.Ce.set(e,t)}),e))}}function c1(e){return gO(e,HD.store)}function l1(e){return gO(e,zD.store)}function u1(e){return e.path.toArray()}class h1{constructor(e){this.k=e}Nt(t,n,e,r){RR(e<r&&0<=e&&r<=11);const i=new sO("createOrUpgrade",n);var s;e<1&&1<=r&&(t.createObjectStore(qD.store),(s=t).createObjectStore(VD.store,{keyPath:VD.keyPath}),s.createObjectStore(BD.store,{keyPath:BD.keyPath,autoIncrement:!0}).createIndex(BD.userMutationsIndex,BD.userMutationsKeyPath,{unique:!0}),s.createObjectStore(WD.store),d1(t),t.createObjectStore(zD.store));let o=iO.resolve();return e<3&&3<=r&&(0!==e&&((s=t).deleteObjectStore(QD.store),s.deleteObjectStore(GD.store),s.deleteObjectStore(YD.store),d1(t)),o=o.next(()=>function(){const e=i.store(YD.store),t=new YD(0,0,GR.min().toTimestamp(),0);return e.put(YD.key,t)}())),e<4&&4<=r&&(0!==e&&(o=o.next(()=>function(r,i){return i.store(BD.store).Bt().next(e=>{r.deleteObjectStore(BD.store),r.createObjectStore(BD.store,{keyPath:BD.keyPath,autoIncrement:!0}).createIndex(BD.userMutationsIndex,BD.userMutationsKeyPath,{unique:!0});const t=i.store(BD.store),n=e.map(e=>t.put(e));return iO.waitFor(n)})}(t,i))),o=o.next(()=>{t.createObjectStore(XD.store,{keyPath:XD.keyPath})})),e<5&&5<=r&&(o=o.next(()=>this.Ne(i))),e<6&&6<=r&&(o=o.next(()=>(t.createObjectStore(HD.store),this.ke(i)))),e<7&&7<=r&&(o=o.next(()=>this.xe(i))),e<8&&8<=r&&(o=o.next(()=>this.$e(t,i))),e<9&&9<=r&&(o=o.next(()=>{var e;(e=t).objectStoreNames.contains("remoteDocumentChanges")&&e.deleteObjectStore("remoteDocumentChanges"),function(){const e=n.objectStore(zD.store);e.createIndex(zD.readTimeIndex,zD.readTimeIndexPath,{unique:!1}),e.createIndex(zD.collectionReadTimeIndex,zD.collectionReadTimeIndexPath,{unique:!1})}()})),e<10&&10<=r&&(o=o.next(()=>this.Oe(i))),e<11&&11<=r&&(o=o.next(()=>{t.createObjectStore(ZD.store,{keyPath:ZD.keyPath}),t.createObjectStore(eO.store,{keyPath:eO.keyPath})})),o}ke(t){let n=0;return t.store(zD.store).jt((e,t)=>{n+=qO(t)}).next(()=>{var e=new HD(n);return t.store(HD.store).put(HD.key,e)})}Ne(r){const e=r.store(VD.store),t=r.store(BD.store);return e.Bt().next(e=>iO.forEach(e,n=>{var e=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return t.Bt(BD.userMutationsIndex,e).next(e=>iO.forEach(e,e=>{RR(e.userId===n.userId);var t=SO(this.k,e);return jO(r,n.userId,t).next(()=>{})}))}))}xe(e){const o=e.store(QD.store),t=e.store(zD.store);return e.store(YD.store).get(YD.key).next(i=>{const s=[];return t.jt((e,t)=>{const n=new ZR(e),r=[0,LD(n)];s.push(o.get(r).next(e=>e?iO.resolve():(e=>o.put(new QD(0,LD(e),i.highestListenSequenceNumber)))(n)))}).next(()=>iO.waitFor(s))})}$e(e,t){e.createObjectStore(JD.store,{keyPath:JD.keyPath});const n=t.store(JD.store),r=new OO,i=e=>{if(r.add(e)){const t=e.lastSegment(),r=e.popLast();return n.put({collectionId:t,parent:LD(r)})}};return t.store(zD.store).jt({Kt:!0},(e,t)=>{const n=new ZR(e);return i(n.popLast())}).next(()=>t.store(WD.store).jt({Kt:!0},([,e],t)=>{const n=UD(e);return i(n.popLast())}))}Oe(e){const r=e.store(GD.store);return r.jt((e,t)=>{var n=CO(t),n=AO(this.k,n);return r.put(n)})}}function d1(e){e.createObjectStore(QD.store,{keyPath:QD.keyPath}).createIndex(QD.documentTargetsIndex,QD.documentTargetsKeyPath,{unique:!0}),e.createObjectStore(GD.store,{keyPath:GD.keyPath}).createIndex(GD.queryTargetsIndexName,GD.queryTargetsKeyPath,{unique:!0}),e.createObjectStore(YD.store)}const p1="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.";class f1{constructor(e,t,n,r,i,s,o,a,c,l){if(this.allowTabSynchronization=e,this.persistenceKey=t,this.clientId=n,this.Fe=i,this.window=s,this.document=o,this.Me=c,this.Le=l,this.Be=null,this.Ue=!1,this.isPrimary=!1,this.networkEnabled=!0,this.qe=null,this.inForeground=!1,this.Ke=null,this.je=null,this.Qe=Number.NEGATIVE_INFINITY,this.We=e=>Promise.resolve(),!f1.Pt())throw new xR(PR.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new n1(this,r),this.Ge=t+"main",this.k=new _O(a),this.ze=new oO(this.Ge,11,new h1(this.k)),this.He=new HO(this.referenceDelegate,this.k),this.Jt=new MO,this.Je=(t=this.k,a=this.Jt,new o1(t,a)),this.Ye=new RO,this.window&&this.window.localStorage?this.Xe=this.window.localStorage:(this.Xe=null,!1===l&&SR("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.Ze().then(()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new xR(PR.FAILED_PRECONDITION,p1);return this.tn(),this.en(),this.nn(),this.runTransaction("getHighestListenSequenceNumber","readonly",e=>this.He.getHighestSequenceNumber(e))}).then(e=>{this.Be=new BR(e,this.Me)}).then(()=>{this.Ue=!0}).catch(e=>(this.ze&&this.ze.close(),Promise.reject(e)))}sn(t){return this.We=async e=>{if(this.started)return t(e)},t(this.isPrimary)}setDatabaseDeletedListener(t){this.ze.xt(async e=>{null===e.newVersion&&await t()})}setNetworkEnabled(e){this.networkEnabled!==e&&(this.networkEnabled=e,this.Fe.enqueueAndForget(async()=>{this.started&&await this.Ze()}))}Ze(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",t=>m1(t).put(new XD(this.clientId,Date.now(),this.networkEnabled,this.inForeground)).next(()=>{if(this.isPrimary)return this.rn(t).next(e=>{e||(this.isPrimary=!1,this.Fe.enqueueRetryable(()=>this.We(!1)))})}).next(()=>this.on(t)).next(e=>this.isPrimary&&!e?this.an(t).next(()=>!1):!!e&&this.cn(t).next(()=>!0))).catch(e=>{if(lO(e))return kR("IndexedDbPersistence","Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return kR("IndexedDbPersistence","Releasing owner lease after error during lease refresh",e),!1}).then(e=>{this.isPrimary!==e&&this.Fe.enqueueRetryable(()=>this.We(e)),this.isPrimary=e})}rn(e){return g1(e).get(qD.key).next(e=>iO.resolve(this.un(e)))}hn(e){return m1(e).delete(this.clientId)}async ln(){if(this.isPrimary&&!this.fn(this.Qe,18e5)){this.Qe=Date.now();var e=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",e=>{const r=gO(e,XD.store);return r.Bt().next(e=>{const t=this.dn(e,18e5),n=e.filter(e=>-1===t.indexOf(e));return iO.forEach(n,e=>r.delete(e.clientId)).next(()=>n)})}).catch(()=>[]);if(this.Xe)for(const t of e)this.Xe.removeItem(this.wn(t.clientId))}}nn(){this.je=this.Fe.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.Ze().then(()=>this.ln()).then(()=>this.nn()))}un(e){return!!e&&e.ownerId===this.clientId}on(t){return this.Le?iO.resolve(!0):g1(t).get(qD.key).next(e=>{if(null!==e&&this.fn(e.leaseTimestampMs,5e3)&&!this._n(e.ownerId)){if(this.un(e)&&this.networkEnabled)return!0;if(!this.un(e)){if(!e.allowTabSynchronization)throw new xR(PR.FAILED_PRECONDITION,p1);return!1}}return!(!this.networkEnabled||!this.inForeground)||m1(t).Bt().next(e=>void 0===this.dn(e,5e3).find(e=>{if(this.clientId!==e.clientId){var 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&&kR("IndexedDbPersistence",`Client ${e?"is":"is not"} eligible for a primary lease.`),e))}async shutdown(){this.Ue=!1,this.mn(),this.je&&(this.je.cancel(),this.je=null),this.gn(),this.yn(),await this.ze.runTransaction("shutdown","readwrite",[qD.store,XD.store],e=>{const t=new fO(e,BR.I);return this.an(t).next(()=>this.hn(t))}),this.ze.close(),this.pn()}dn(e,t){return e.filter(e=>this.fn(e.updateTimeMs,t)&&!this._n(e.clientId))}Tn(){return this.runTransaction("getActiveClients","readonly",e=>m1(e).Bt().next(e=>this.dn(e,18e5).map(e=>e.clientId)))}get started(){return this.Ue}getMutationQueue(e){return VO.Xt(e,this.k,this.Jt,this.referenceDelegate)}getTargetCache(){return this.He}getRemoteDocumentCache(){return this.Je}getIndexManager(){return this.Jt}getBundleCache(){return this.Ye}runTransaction(t,n,r){kR("IndexedDbPersistence","Starting transaction:",t);let i;return this.ze.runTransaction(t,"readonly"===n?"readonly":"readwrite",tO,e=>(i=new fO(e,this.Be?this.Be.next():BR.I),"readwrite-primary"===n?this.rn(i).next(e=>!!e||this.on(i)).next(e=>{if(!e)throw SR(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.Fe.enqueueRetryable(()=>this.We(!1)),new xR(PR.FAILED_PRECONDITION,nO);return r(i)}).next(e=>this.cn(i).next(()=>e)):this.En(i).next(()=>r(i)))).then(e=>(i.raiseOnCommittedEvent(),e))}En(e){return g1(e).get(qD.key).next(e=>{if(null!==e&&this.fn(e.leaseTimestampMs,5e3)&&!this._n(e.ownerId)&&!this.un(e)&&!(this.Le||this.allowTabSynchronization&&e.allowTabSynchronization))throw new xR(PR.FAILED_PRECONDITION,p1)})}cn(e){var t=new qD(this.clientId,this.allowTabSynchronization,Date.now());return g1(e).put(qD.key,t)}static Pt(){return oO.Pt()}an(e){const t=g1(e);return t.get(qD.key).next(e=>this.un(e)?(kR("IndexedDbPersistence","Releasing primary lease."),t.delete(qD.key)):iO.resolve())}fn(e,t){var n=Date.now();return!(e<n-t||n<e&&(SR(`Detected an update time that is in the future: ${e} > ${n}`),1))}tn(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Ke=()=>{this.Fe.enqueueAndForget(()=>(this.inForeground="visible"===this.document.visibilityState,this.Ze()))},this.document.addEventListener("visibilitychange",this.Ke),this.inForeground="visible"===this.document.visibilityState)}gn(){this.Ke&&(this.document.removeEventListener("visibilitychange",this.Ke),this.Ke=null)}en(){var e;"function"==typeof(null===(e=this.window)||void 0===e?void 0:e.addEventListener)&&(this.qe=()=>{this.mn(),!ad()&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")&&navigator.appVersion.match(/Version\/1[45]/)&&this.Fe.enterRestrictedMode(!0),this.Fe.enqueueAndForget(()=>this.shutdown())},this.window.addEventListener("pagehide",this.qe))}yn(){this.qe&&(this.window.removeEventListener("pagehide",this.qe),this.qe=null)}_n(e){var t;try{var n=null!==(null===(t=this.Xe)||void 0===t?void 0:t.getItem(this.wn(e)));return kR("IndexedDbPersistence",`Client '${e}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(e){return SR("IndexedDbPersistence","Failed to get zombied client id.",e),!1}}mn(){if(this.Xe)try{this.Xe.setItem(this.wn(this.clientId),String(Date.now()))}catch(e){SR("Failed to set zombie client id.",e)}}pn(){if(this.Xe)try{this.Xe.removeItem(this.wn(this.clientId))}catch(e){}}wn(e){return`firestore_zombie_${this.persistenceKey}_${e}`}}function g1(e){return gO(e,qD.store)}function m1(e){return gO(e,XD.store)}function v1(e,t){let n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}class y1{constructor(e,t){this.progress=e,this.In=t}}class _1{constructor(e,t,n){this.Je=e,this.An=t,this.Jt=n}Rn(t,n){return this.An.getAllMutationBatchesAffectingDocumentKey(t,n).next(e=>this.bn(t,n,e))}bn(e,t,n){return this.Je.getEntry(e,t).next(e=>{for(const t of n)t.applyToLocalView(e);return e})}Pn(e,n){e.forEach((e,t)=>{for(const e of n)e.applyToLocalView(t)})}vn(t,e){return this.Je.getEntries(t,e).next(e=>this.Vn(t,e).next(()=>e))}Vn(e,t){return this.An.getAllMutationBatchesAffectingDocumentKeys(e,t).next(e=>this.Pn(t,e))}getDocumentsMatchingQuery(e,t,n){return r=t,pP.isDocumentKey(r.path)&&null===r.collectionGroup&&0===r.filters.length?this.Sn(e,t.path):tx(t)?this.Dn(e,t,n):this.Cn(e,t,n);var r}Sn(e,t){return this.Rn(e,new pP(t)).next(e=>{let t=Gx;return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}Dn(r,i,s){const o=i.collectionGroup;let a=Gx;return this.Jt.getCollectionParents(r,o).next(e=>iO.forEach(e,e=>{var t,n=(t=i,e=e.child(o),new GP(e,null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt));return this.Cn(r,n,s).next(e=>{e.forEach((e,t)=>{a=a.insert(e,t)})})}).next(()=>a))}Cn(t,n,e){let i,s;return this.Je.getDocumentsMatchingQuery(t,n,e).next(e=>(i=e,this.An.getAllMutationBatchesAffectingQuery(t,n))).next(e=>(s=e,this.Nn(t,s,i).next(t=>{i=t;for(const t of s)for(const r of t.mutations){var n=r.key;let e=i.get(n);null==e&&(e=AP.newInvalidDocument(n),i=i.insert(n,e)),Nx(r,e,t.localWriteTime),e.isFoundDocument()||(i=i.remove(n))}}))).next(()=>(i.forEach((e,t)=>{cx(n,t)||(i=i.remove(e))}),i))}Nn(e,t,n){let r=Jx();for(const e of t)for(const t of e.mutations)t instanceof Dx&&null===n.get(t.key)&&(r=r.add(t.key));let i=n;return this.Je.getEntries(e,r).next(e=>(e.forEach((e,t)=>{t.isFoundDocument()&&(i=i.insert(e,t))}),i))}}class w1{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.kn=n,this.xn=r}static $n(e,t){let n=Jx(),r=Jx();for(const 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 w1(e,t.fromCache,n,r)}}class b1{On(e){this.Fn=e}getDocumentsMatchingQuery(t,r,i,s){return 0===(e=r).filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())||i.isEqual(GR.min())?this.Mn(t,r):this.Fn.vn(t,s).next(e=>{const n=this.Ln(r,e);return(JP(r)||XP(r))&&this.Bn(r.limitType,n,s,i)?this.Mn(t,r):(ER()<=Kh.DEBUG&&kR("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),ax(r)),this.Fn.getDocumentsMatchingQuery(t,r,i).next(t=>(n.forEach(e=>{t=t.insert(e.key,e)}),t)))});var e}Ln(n,e){let r=new $x(lx(n));return e.forEach((e,t)=>{cx(n,t)&&(r=r.add(t))}),r}Bn(e,t,n,r){if(n.size!==t.size)return!0;const i="F"===e?t.last():t.first();return!!i&&(i.hasPendingWrites||0<i.version.compareTo(r))}Mn(e,t){return ER()<=Kh.DEBUG&&kR("QueryEngine","Using full collection scan to execute query:",ax(t)),this.Fn.getDocumentsMatchingQuery(e,t,GR.min())}}class T1{constructor(e,t,n,r){this.persistence=e,this.Un=t,this.k=r,this.qn=new Bx(KR),this.Kn=new i1(e=>PP(e),xP),this.jn=GR.min(),this.An=e.getMutationQueue(n),this.Qn=e.getRemoteDocumentCache(),this.He=e.getTargetCache(),this.Wn=new _1(this.Qn,this.An,this.persistence.getIndexManager()),this.Ye=e.getBundleCache(),this.Un.On(this.Wn)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",e=>t.collect(e,this.qn))}}function I1(e,t,n,r){return new T1(e,t,n,r)}async function E1(e,t){const n=e;let r=n.An,o=n.Wn;var i=await n.persistence.runTransaction("Handle user change","readonly",i=>{let s;return n.An.getAllMutationBatches(i).next(e=>(s=e,r=n.persistence.getMutationQueue(t),o=new _1(n.Qn,r,n.persistence.getIndexManager()),r.getAllMutationBatches(i))).next(e=>{const t=[],n=[];let r=Jx();for(const i of s){t.push(i.batchId);for(const e of i.mutations)r=r.add(e.key)}for(const i of e){n.push(i.batchId);for(const e of i.mutations)r=r.add(e.key)}return o.vn(i,r).next(e=>({Gn:e,removedBatchIds:t,addedBatchIds:n}))})});return n.An=r,n.Wn=o,n.Un.On(n.Wn),i}function k1(e){const t=e;return t.persistence.runTransaction("Get last remote snapshot version","readonly",e=>t.He.getLastRemoteSnapshotVersion(e))}function S1(e,l){const u=e,h=l.snapshotVersion;let d=u.qn;return u.persistence.runTransaction("Apply remote event","readwrite-primary",a=>{const e=u.Qn.newChangeBuffer({trackRemovals:!0});d=u.qn;const c=[];l.targetChanges.forEach((t,n)=>{const r=d.get(n);if(r){c.push(u.He.removeMatchingKeys(a,t.removedDocuments,n).next(()=>u.He.addMatchingKeys(a,t.addedDocuments,n)));let e=r.withSequenceNumber(a.currentSequenceNumber);var i,s,o;l.targetMismatches.has(n)?e=e.withResumeToken(rP.EMPTY_BYTE_STRING,GR.min()).withLastLimboFreeSnapshotVersion(GR.min()):0<t.resumeToken.approximateByteSize()&&(e=e.withResumeToken(t.resumeToken,h)),d=d.insert(n,e),i=r,s=e,o=t,0!==i.resumeToken.approximateByteSize()&&!(3e8<=s.snapshotVersion.toMicroseconds()-i.snapshotVersion.toMicroseconds()||0<o.addedDocuments.size+o.modifiedDocuments.size+o.removedDocuments.size)||c.push(u.He.updateTargetData(a,e))}});let t=Hx;if(l.documentUpdates.forEach((e,t)=>{l.resolvedLimboDocuments.has(e)&&c.push(u.persistence.referenceDelegate.updateLimboDocument(a,e))}),c.push(C1(a,e,l.documentUpdates,h,void 0).next(e=>{t=e})),!h.isEqual(GR.min())){const l=u.He.getLastRemoteSnapshotVersion(a).next(e=>u.He.setTargetsMetadata(a,a.currentSequenceNumber,h));c.push(l)}return iO.waitFor(c).next(()=>e.apply(a)).next(()=>u.Wn.Vn(a,t)).next(()=>t)}).then(e=>(u.qn=d,e))}function C1(e,o,t,a,c){let n=Jx();return t.forEach(e=>n=n.add(e)),o.getEntries(e,n).next(i=>{let s=Hx;return t.forEach((e,t)=>{const n=i.get(e),r=(null==c?void 0:c.get(e))||a;t.isNoDocument()&&t.version.isEqual(GR.min())?(o.removeEntry(e,r),s=s.insert(e,t)):!n.isValidDocument()||0<t.version.compareTo(n.version)||0===t.version.compareTo(n.version)&&n.hasPendingWrites?(o.addEntry(t,r),s=s.insert(e,t)):kR("LocalStore","Ignoring outdated watch update for ",e,". Current version:",n.version," Watch version:",t.version)}),s})}function A1(e,r){const i=e;return i.persistence.runTransaction("Allocate target","readwrite",t=>{let n;return i.He.getTargetData(t,r).next(e=>e?(n=e,iO.resolve(n)):i.He.allocateTargetId(t).next(e=>(n=new yO(r,e,0,t.currentSequenceNumber),i.He.addTargetData(t,n).next(()=>n))))}).then(e=>{var t=i.qn.get(e.targetId);return(null===t||0<e.snapshotVersion.compareTo(t.snapshotVersion))&&(i.qn=i.qn.insert(e.targetId,e),i.Kn.set(r,e.targetId)),e})}async function N1(e,t,n){const r=e,i=r.qn.get(t),s=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",s,e=>r.persistence.referenceDelegate.removeTarget(e,i))}catch(e){if(!lO(e))throw e;kR("LocalStore",`Failed to update sequence numbers for target ${t}: ${e}`)}r.qn=r.qn.remove(t),r.Kn.delete(i.target)}function R1(e,n,r){const i=e;let s=GR.min(),o=Jx();return i.persistence.runTransaction("Execute query","readonly",t=>function(e,t,n){const r=e,i=r.Kn.get(n);return void 0!==i?iO.resolve(r.qn.get(i)):r.He.getTargetData(t,n)}(i,t,rx(n)).next(e=>{if(e)return s=e.lastLimboFreeSnapshotVersion,i.He.getMatchingKeysForTargetId(t,e.targetId).next(e=>{o=e})}).next(()=>i.Un.getDocumentsMatchingQuery(t,n,r?s:GR.min(),r?o:Jx())).next(e=>({documents:e,zn:o})))}function P1(e,t){const n=e,r=n.He,i=n.qn.get(t);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",e=>r.Et(e,t).next(e=>e?e.target:null))}function x1(e){const n=e;return n.persistence.runTransaction("Get new document changes","readonly",e=>function(e,t,n){const r=e;let i=Hx,s=TO(n);const o=l1(t),a=IDBKeyRange.lowerBound(s,!0);return o.jt({index:zD.readTimeIndex,range:a},(e,t)=>{var n=wO(r.k,t);i=i.insert(n.key,n),s=t.readTime}).next(()=>({In:i,readTime:IO(s)}))}(n.Qn,e,n.jn)).then(({In:e,readTime:t})=>(n.jn=t,e))}class D1{constructor(e){this.k=e,this.Xn=new Map,this.Zn=new Map}getBundleMetadata(e,t){return iO.resolve(this.Xn.get(t))}saveBundleMetadata(e,t){return this.Xn.set(t.id,{id:t.id,version:t.version,createTime:pD(t.createTime)}),iO.resolve()}getNamedQuery(e,t){return iO.resolve(this.Zn.get(t))}saveNamedQuery(e,t){return this.Zn.set(t.name,{name:(t=t).name,query:NO(t.bundledQuery),readTime:pD(t.readTime)}),iO.resolve()}}class O1{constructor(){this.ts=new $x(M1.es),this.ns=new $x(M1.ss)}isEmpty(){return this.ts.isEmpty()}addReference(e,t){var n=new M1(e,t);this.ts=this.ts.add(n),this.ns=this.ns.add(n)}rs(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.os(new M1(e,t))}cs(e,t){e.forEach(e=>this.removeReference(e,t))}us(e){const t=new pP(new ZR([])),n=new M1(t,e),r=new M1(t,e+1),i=[];return this.ns.forEachInRange([n,r],e=>{this.os(e),i.push(e.key)}),i}hs(){this.ts.forEach(e=>this.os(e))}os(e){this.ts=this.ts.delete(e),this.ns=this.ns.delete(e)}ls(e){var t=new pP(new ZR([])),n=new M1(t,e),t=new M1(t,e+1);let r=Jx();return this.ns.forEachInRange([n,t],e=>{r=r.add(e.key)}),r}containsKey(e){var t=new M1(e,0),t=this.ts.firstAfterOrEqual(t);return null!==t&&e.isEqual(t.key)}}class M1{constructor(e,t){this.key=e,this.fs=t}static es(e,t){return pP.comparator(e.key,t.key)||KR(e.fs,t.fs)}static ss(e,t){return KR(e.fs,t.fs)||pP.comparator(e.key,t.key)}}class L1{constructor(e,t){this.Jt=e,this.referenceDelegate=t,this.An=[],this.ds=1,this.ws=new $x(M1.es)}checkEmpty(e){return iO.resolve(0===this.An.length)}addMutationBatch(e,t,n,r){var i=this.ds;this.ds++,0<this.An.length&&this.An[this.An.length-1];var s=new mO(i,t,n,r);this.An.push(s);for(const t of r)this.ws=this.ws.add(new M1(t.key,i)),this.Jt.addToCollectionParentIndex(e,t.key.path.popLast());return iO.resolve(s)}lookupMutationBatch(e,t){return iO.resolve(this._s(t))}getNextMutationBatchAfterBatchId(e,t){var n=this.gs(t+1),n=n<0?0:n;return iO.resolve(this.An.length>n?this.An[n]:null)}getHighestUnacknowledgedBatchId(){return iO.resolve(0===this.An.length?-1:this.ds-1)}getAllMutationBatches(e){return iO.resolve(this.An.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const n=new M1(t,0),r=new M1(t,Number.POSITIVE_INFINITY),i=[];return this.ws.forEachInRange([n,r],e=>{var t=this._s(e.fs);i.push(t)}),iO.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new $x(KR);return t.forEach(e=>{var t=new M1(e,0),n=new M1(e,Number.POSITIVE_INFINITY);this.ws.forEachInRange([t,n],e=>{r=r.add(e.fs)})}),iO.resolve(this.ys(r))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,r=n.length+1;let i=n;pP.isDocumentKey(i)||(i=i.child(""));var s=new M1(new pP(i),0);let o=new $x(KR);return this.ws.forEachWhile(e=>{var t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.fs)),!0)},s),iO.resolve(this.ys(o))}ys(e){const n=[];return e.forEach(e=>{var t=this._s(e);null!==t&&n.push(t)}),n}removeMutationBatch(n,r){RR(0===this.ps(r.batchId,"removed")),this.An.shift();let i=this.ws;return iO.forEach(r.mutations,e=>{var t=new M1(e.key,r.batchId);return i=i.delete(t),this.referenceDelegate.markPotentiallyOrphaned(n,e.key)}).next(()=>{this.ws=i})}ee(e){}containsKey(e,t){var n=new M1(t,0),n=this.ws.firstAfterOrEqual(n);return iO.resolve(t.isEqual(n&&n.key))}performConsistencyCheck(e){return this.An.length,iO.resolve()}ps(e,t){return this.gs(e)}gs(e){return 0===this.An.length?0:e-this.An[0].batchId}_s(e){var t=this.gs(e);return t<0||t>=this.An.length?null:this.An[t]}}class F1{constructor(e,t){this.Jt=e,this.Ts=t,this.docs=new Bx(pP.comparator),this.size=0}addEntry(e,t,n){const r=t.key,i=this.docs.get(r),s=i?i.size:0,o=this.Ts(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:o,readTime:n}),this.size+=o-s,this.Jt.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){var t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const n=this.docs.get(t);return iO.resolve(n?n.document.mutableCopy():AP.newInvalidDocument(t))}getEntries(e,t){let n=Hx;return t.forEach(e=>{const t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():AP.newInvalidDocument(e))}),iO.resolve(n)}getDocumentsMatchingQuery(e,t,n){let r=Hx;const i=new pP(t.path.child("")),s=this.docs.getIteratorFrom(i);for(;s.hasNext();){const{key:e,value:{document:i,readTime:o}}=s.getNext();if(!t.path.isPrefixOf(e.path))break;o.compareTo(n)<=0||cx(t,i)&&(r=r.insert(i.key,i.mutableCopy()))}return iO.resolve(r)}Es(e,t){return iO.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new U1(this)}getSize(e){return iO.resolve(this.size)}}class U1 extends s1{constructor(e){super(),this.De=e}applyChanges(n){const r=[];return this.changes.forEach((e,t)=>{t.document.isValidDocument()?r.push(this.De.addEntry(n,t.document,this.getReadTime(e))):this.De.removeEntry(e)}),iO.waitFor(r)}getFromCache(e,t){return this.De.getEntry(e,t)}getAllFromCache(e,t){return this.De.getEntries(e,t)}}class j1{constructor(e){this.persistence=e,this.Is=new i1(e=>PP(e),xP),this.lastRemoteSnapshotVersion=GR.min(),this.highestTargetId=0,this.As=0,this.Rs=new O1,this.targetCount=0,this.bs=zO.ie()}forEachTarget(e,n){return this.Is.forEach((e,t)=>n(t)),iO.resolve()}getLastRemoteSnapshotVersion(e){return iO.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return iO.resolve(this.As)}allocateTargetId(e){return this.highestTargetId=this.bs.next(),iO.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.As&&(this.As=t),iO.resolve()}ce(e){this.Is.set(e.target,e);var t=e.targetId;t>this.highestTargetId&&(this.bs=new zO(t),this.highestTargetId=t),e.sequenceNumber>this.As&&(this.As=e.sequenceNumber)}addTargetData(e,t){return this.ce(t),this.targetCount+=1,iO.resolve()}updateTargetData(e,t){return this.ce(t),iO.resolve()}removeTargetData(e,t){return this.Is.delete(t.target),this.Rs.us(t.targetId),--this.targetCount,iO.resolve()}removeTargets(n,r,i){let s=0;const o=[];return this.Is.forEach((e,t)=>{t.sequenceNumber<=r&&null===i.get(t.targetId)&&(this.Is.delete(e),o.push(this.removeMatchingKeysForTargetId(n,t.targetId)),s++)}),iO.waitFor(o).next(()=>s)}getTargetCount(e){return iO.resolve(this.targetCount)}getTargetData(e,t){var n=this.Is.get(t)||null;return iO.resolve(n)}addMatchingKeys(e,t,n){return this.Rs.rs(t,n),iO.resolve()}removeMatchingKeys(t,e,n){this.Rs.cs(e,n);const r=this.persistence.referenceDelegate,i=[];return r&&e.forEach(e=>{i.push(r.markPotentiallyOrphaned(t,e))}),iO.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.Rs.us(t),iO.resolve()}getMatchingKeysForTargetId(e,t){var n=this.Rs.ls(t);return iO.resolve(n)}containsKey(e,t){return iO.resolve(this.Rs.containsKey(t))}}class q1{constructor(e,t){var n;this.Ps={},this.Be=new BR(0),this.Ue=!1,this.Ue=!0,this.referenceDelegate=e(this),this.He=new j1(this),this.Jt=new DO,this.Je=(n=this.Jt,e=e=>this.referenceDelegate.vs(e),new F1(n,e)),this.k=new _O(t),this.Ye=new D1(this.k)}start(){return Promise.resolve()}shutdown(){return this.Ue=!1,Promise.resolve()}get started(){return this.Ue}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(){return this.Jt}getMutationQueue(e){let t=this.Ps[e.toKey()];return t||(t=new L1(this.Jt,this.referenceDelegate),this.Ps[e.toKey()]=t),t}getTargetCache(){return this.He}getRemoteDocumentCache(){return this.Je}getBundleCache(){return this.Ye}runTransaction(e,t,n){kR("MemoryPersistence","Starting transaction:",e);const r=new V1(this.Be.next());return this.referenceDelegate.Vs(),n(r).next(e=>this.referenceDelegate.Ss(r).next(()=>e)).toPromise().then(e=>(r.raiseOnCommittedEvent(),e))}Ds(t,n){return iO.or(Object.values(this.Ps).map(e=>()=>e.containsKey(t,n)))}}class V1 extends rO{constructor(e){super(),this.currentSequenceNumber=e}}class B1{constructor(e){this.persistence=e,this.Cs=new O1,this.Ns=null}static ks(e){return new B1(e)}get xs(){if(this.Ns)return this.Ns;throw NR()}addReference(e,t,n){return this.Cs.addReference(n,t),this.xs.delete(n.toString()),iO.resolve()}removeReference(e,t,n){return this.Cs.removeReference(n,t),this.xs.add(n.toString()),iO.resolve()}markPotentiallyOrphaned(e,t){return this.xs.add(t.toString()),iO.resolve()}removeTarget(e,t){this.Cs.us(t.targetId).forEach(e=>this.xs.add(e.toString()));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.xs.add(e.toString()))}).next(()=>n.removeTargetData(e,t))}Vs(){this.Ns=new Set}Ss(n){const r=this.persistence.getRemoteDocumentCache().newChangeBuffer();return iO.forEach(this.xs,e=>{const t=pP.fromPath(e);return this.$s(n,t).next(e=>{e||r.removeEntry(t)})}).next(()=>(this.Ns=null,r.apply(n)))}updateLimboDocument(e,t){return this.$s(e,t).next(e=>{e?this.xs.delete(t.toString()):this.xs.add(t.toString())})}vs(e){return 0}$s(e,t){return iO.or([()=>iO.resolve(this.Cs.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ds(e,t)])}}function W1(e,t){return`firestore_clients_${e}_${t}`}function K1(e,t,n){let r=`firestore_mutations_${e}_${n}`;return t.isAuthenticated()&&(r+=`_${t.uid}`),r}function $1(e,t){return`firestore_targets_${e}_${t}`}class z1{constructor(e,t,n,r){this.user=e,this.batchId=t,this.state=n,this.error=r}static Os(e,t,n){var r=JSON.parse(n);let 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,s&&(i=new xR(r.error.code,r.error.message))),s?new z1(e,t,r.state,i):(SR("SharedClientState",`Failed to parse mutation state for ID '${t}': ${n}`),null)}Fs(){const e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class H1{constructor(e,t,n){this.targetId=e,this.state=t,this.error=n}static Os(e,t){var n=JSON.parse(t);let 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,i&&(r=new xR(n.error.code,n.error.message))),i?new H1(e,n.state,r):(SR("SharedClientState",`Failed to parse target state for ID '${e}': ${t}`),null)}Fs(){const e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class G1{constructor(e,t){this.clientId=e,this.activeTargetIds=t}static Os(e,t){var n=JSON.parse(t);let r="object"==typeof n&&n.activeTargetIds instanceof Array,i=Xx;for(let s=0;r&&s<n.activeTargetIds.length;++s)r=dP(n.activeTargetIds[s]),i=i.add(n.activeTargetIds[s]);return r?new G1(e,i):(SR("SharedClientState",`Failed to parse client data for instance '${e}': ${t}`),null)}}class Q1{constructor(e,t){this.clientId=e,this.onlineState=t}static Os(e){var t=JSON.parse(e);return"object"==typeof t&&-1!==["Unknown","Online","Offline"].indexOf(t.onlineState)&&"string"==typeof t.clientId?new Q1(t.clientId,t.onlineState):(SR("SharedClientState",`Failed to parse online state: ${e}`),null)}}class Y1{constructor(){this.activeTargetIds=Xx}Ms(e){this.activeTargetIds=this.activeTargetIds.add(e)}Ls(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Fs(){var e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class J1{constructor(e,t,n,r,i){this.window=e,this.Fe=t,this.persistenceKey=n,this.Bs=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.Us=this.qs.bind(this),this.Ks=new Bx(KR),this.started=!1,this.js=[];var s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Qs=W1(this.persistenceKey,this.Bs),this.Ws=`firestore_sequence_number_${this.persistenceKey}`,this.Ks=this.Ks.insert(this.Bs,new Y1),this.Gs=new RegExp(`^firestore_clients_${s}_([^_]*)$`),this.zs=new RegExp(`^firestore_mutations_${s}_(\\d+)(?:_(.*))?$`),this.Hs=new RegExp(`^firestore_targets_${s}_(\\d+)$`),this.Js=`firestore_online_state_${this.persistenceKey}`,this.Ys=`firestore_bundle_loaded_${this.persistenceKey}`,this.window.addEventListener("storage",this.Us)}static Pt(e){return!(!e||!e.localStorage)}async start(){const e=await this.syncEngine.Tn();for(const n of e)if(n!==this.Bs){const e=this.getItem(W1(this.persistenceKey,n));var t;!e||(t=G1.Os(n,e))&&(this.Ks=this.Ks.insert(t.clientId,t))}this.Xs();const n=this.storage.getItem(this.Js);if(n){const e=this.Zs(n);e&&this.ti(e)}for(const e of this.js)this.qs(e);this.js=[],this.window.addEventListener("pagehide",()=>this.shutdown()),this.started=!0}writeSequenceNumber(e){this.setItem(this.Ws,JSON.stringify(e))}getAllActiveQueryTargets(){return this.ei(this.Ks)}isActiveQueryTarget(n){let r=!1;return this.Ks.forEach((e,t)=>{t.activeTargetIds.has(n)&&(r=!0)}),r}addPendingMutation(e){this.ni(e,"pending")}updateMutationState(e,t,n){this.ni(e,t,n),this.si(e)}addLocalQueryTarget(e){let t="not-current";var n;return this.isActiveQueryTarget(e)&&(!(n=this.storage.getItem($1(this.persistenceKey,e)))||(n=H1.Os(e,n))&&(t=n.state)),this.ii.Ms(e),this.Xs(),t}removeLocalQueryTarget(e){this.ii.Ls(e),this.Xs()}isLocalQueryTarget(e){return this.ii.activeTargetIds.has(e)}clearQueryState(e){this.removeItem($1(this.persistenceKey,e))}updateQueryState(e,t,n){this.ri(e,t,n)}handleUserChange(e,t,n){t.forEach(e=>{this.si(e)}),this.currentUser=e,n.forEach(e=>{this.addPendingMutation(e)})}setOnlineState(e){this.oi(e)}notifyBundleLoaded(){this.ai()}shutdown(){this.started&&(this.window.removeEventListener("storage",this.Us),this.removeItem(this.Qs),this.started=!1)}getItem(e){var t=this.storage.getItem(e);return kR("SharedClientState","READ",e,t),t}setItem(e,t){kR("SharedClientState","SET",e,t),this.storage.setItem(e,t)}removeItem(e){kR("SharedClientState","REMOVE",e),this.storage.removeItem(e)}qs(e){const r=e;r.storageArea===this.storage&&(kR("SharedClientState","EVENT",r.key,r.newValue),r.key!==this.Qs?this.Fe.enqueueRetryable(async()=>{if(this.started){if(null!==r.key)if(this.Gs.test(r.key)){if(null==r.newValue){var e=this.ci(r.key);return this.ui(e,null)}e=this.hi(r.key,r.newValue);if(e)return this.ui(e.clientId,e)}else if(this.zs.test(r.key)){if(null!==r.newValue){var t=this.li(r.key,r.newValue);if(t)return this.fi(t)}}else if(this.Hs.test(r.key)){if(null!==r.newValue){t=this.di(r.key,r.newValue);if(t)return this.wi(t)}}else if(r.key===this.Js){if(null!==r.newValue){var n=this.Zs(r.newValue);if(n)return this.ti(n)}}else if(r.key===this.Ws){n=function(e){let t=BR.I;if(null!=e)try{var n=JSON.parse(e);RR("number"==typeof n),t=n}catch(e){SR("SharedClientState","Failed to read sequence number from WebStorage",e)}return t}(r.newValue);n!==BR.I&&this.sequenceNumberHandler(n)}else if(r.key===this.Ys)return this.syncEngine._i()}else this.js.push(r)}):SR("Received WebStorage notification for local change. Another client might have garbage-collected our state"))}get ii(){return this.Ks.get(this.Bs)}Xs(){this.setItem(this.Qs,this.ii.Fs())}ni(e,t,n){const r=new z1(this.currentUser,e,t,n),i=K1(this.persistenceKey,this.currentUser,e);this.setItem(i,r.Fs())}si(e){var t=K1(this.persistenceKey,this.currentUser,e);this.removeItem(t)}oi(e){var t={clientId:this.Bs,onlineState:e};this.storage.setItem(this.Js,JSON.stringify(t))}ri(e,t,n){const r=$1(this.persistenceKey,e),i=new H1(e,t,n);this.setItem(r,i.Fs())}ai(){this.setItem(this.Ys,"value-not-used")}ci(e){var t=this.Gs.exec(e);return t?t[1]:null}hi(e,t){var n=this.ci(e);return G1.Os(n,t)}li(e,t){var n=this.zs.exec(e),r=Number(n[1]),n=void 0!==n[2]?n[2]:null;return z1.Os(new bR(n),r,t)}di(e,t){var n=this.Hs.exec(e),n=Number(n[1]);return H1.Os(n,t)}Zs(e){return Q1.Os(e)}async fi(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.mi(e.batchId,e.state,e.error);kR("SharedClientState",`Ignoring mutation for non-active user ${e.user.uid}`)}wi(e){return this.syncEngine.gi(e.targetId,e.state,e.error)}ui(e,t){const n=t?this.Ks.insert(e,t):this.Ks.remove(e),r=this.ei(this.Ks),i=this.ei(n),s=[],o=[];return i.forEach(e=>{r.has(e)||s.push(e)}),r.forEach(e=>{i.has(e)||o.push(e)}),this.syncEngine.yi(s,o).then(()=>{this.Ks=n})}ti(e){this.Ks.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}ei(e){let n=Xx;return e.forEach((e,t)=>{n=n.unionWith(t.activeTargetIds)}),n}}class X1{constructor(){this.pi=new Y1,this.Ti={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e){return this.pi.Ms(e),this.Ti[e]||"not-current"}updateQueryState(e,t,n){this.Ti[e]=t}removeLocalQueryTarget(e){this.pi.Ls(e)}isLocalQueryTarget(e){return this.pi.activeTargetIds.has(e)}clearQueryState(e){delete this.Ti[e]}getAllActiveQueryTargets(){return this.pi.activeTargetIds}isActiveQueryTarget(e){return this.pi.activeTargetIds.has(e)}start(){return this.pi=new Y1,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(){}}class Z1{Ei(e){}shutdown(){}}class eM{constructor(){this.Ii=()=>this.Ai(),this.Ri=()=>this.bi(),this.Pi=[],this.vi()}Ei(e){this.Pi.push(e)}shutdown(){window.removeEventListener("online",this.Ii),window.removeEventListener("offline",this.Ri)}vi(){window.addEventListener("online",this.Ii),window.addEventListener("offline",this.Ri)}Ai(){kR("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.Pi)e(0)}bi(){kR("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const e of this.Pi)e(1)}static Pt(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}const tM={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"};class nM{constructor(e){this.Vi=e.Vi,this.Si=e.Si}Di(e){this.Ci=e}Ni(e){this.ki=e}onMessage(e){this.xi=e}close(){this.Si()}send(e){this.Vi(e)}$i(){this.Ci()}Oi(e){this.ki(e)}Fi(e){this.xi(e)}}class rM extends class{constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;var t=e.ssl?"https":"http";this.Mi=t+"://"+e.host,this.Li="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}Bi(t,e,n,r,i){const s=this.Ui(t,e);kR("RestConnection","Sending: ",s,n);var o={};return this.qi(o,r,i),this.Ki(t,s,o,n).then(e=>(kR("RestConnection","Received: ",e),e),e=>{throw CR("RestConnection",`${t} failed with error: `,e,"url: ",s,"request:",n),e})}ji(e,t,n,r,i){return this.Bi(e,t,n,r,i)}qi(n,e,t){n["X-Goog-Api-Client"]="gl-js/ fire/"+TR,n["Content-Type"]="text/plain",this.databaseInfo.appId&&(n["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEach((e,t)=>n[t]=e),t&&t.headers.forEach((e,t)=>n[t]=e)}Ui(e,t){var n=tM[e];return`${this.Mi}/v1/${t}:${n}`}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams}Ki(a,t,n,r){return new Promise((i,s)=>{const o=new _R;o.listenOnce(pR.COMPLETE,()=>{try{switch(o.getLastErrorCode()){case dR.NO_ERROR:var e=o.getResponseJson();kR("Connection","XHR received:",JSON.stringify(e)),i(e);break;case dR.TIMEOUT:kR("Connection",'RPC "'+a+'" timed out'),s(new xR(PR.DEADLINE_EXCEEDED,"Request time out"));break;case dR.HTTP_ERROR:var t,n=o.getStatus();if(kR("Connection",'RPC "'+a+'" failed with status:',n,"response text:",o.getResponseText()),0<n){const a=o.getResponseJson().error;a&&a.status&&a.message?(r=a.status.toLowerCase().replace(/_/g,"-"),t=0<=Object.values(PR).indexOf(r)?r:PR.UNKNOWN,s(new xR(t,a.message))):s(new xR(PR.UNKNOWN,"Server responded with status "+o.getStatus()))}else s(new xR(PR.UNAVAILABLE,"Connection failed."));break;default:NR()}}finally{kR("Connection",'RPC "'+a+'" completed.')}var r});var e=JSON.stringify(r);o.send(t,"POST",e,n,15)})}Qi(e,t,n){const r=[this.Mi,"/","google.firestore.v1.Firestore","/",e,"/channel"],i=new sR,s=hR(),o={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};this.useFetchStreams&&(o.xmlHttpFactory=new vR({})),this.qi(o.initMessageHeaders,t,n),od()||ld()||0<=sd().indexOf("Electron/")||ud()||0<=sd().indexOf("MSAppHost/")||cd()||(o.httpHeadersOverwriteParam="$httpHeaders");var a=r.join("");kR("Connection","Creating WebChannel: "+a,o);const c=i.createWebChannel(a,o);let l=!1,u=!1;const h=new nM({Vi:e=>{u?kR("Connection","Not sending because WebChannel is closed:",e):(l||(kR("Connection","Opening WebChannel transport."),c.open(),l=!0),kR("Connection","WebChannel sending:",e),c.send(e))},Si:()=>c.close()}),d=(e,t,n)=>{e.listen(t,e=>{try{n(e)}catch(e){setTimeout(()=>{throw e},0)}})};return d(c,yR.EventType.OPEN,()=>{u||kR("Connection","WebChannel transport opened.")}),d(c,yR.EventType.CLOSE,()=>{u||(u=!0,kR("Connection","WebChannel transport closed"),h.Oi())}),d(c,yR.EventType.ERROR,e=>{u||(u=!0,CR("Connection","WebChannel transport errored:",e),h.Oi(new xR(PR.UNAVAILABLE,"The operation could not be completed")))}),d(c,yR.EventType.MESSAGE,n=>{if(!u){var e=n.data[0];RR(!!e);var r=e.error||(null===(r=e[0])||void 0===r?void 0:r.error);if(r){kR("Connection","WebChannel received error:",r);const n=r.status;let e=function(e){var t=uR[e];if(void 0!==t)return Vx(t)}(n),t=r.message;void 0===e&&(e=PR.INTERNAL,t="Unknown error status: "+n+" with message "+r.message),u=!0,h.Oi(new xR(e,t)),c.close()}else kR("Connection","WebChannel received:",e),h.Fi(e)}}),d(s,fR.STAT_EVENT,e=>{e.stat===gR?kR("Connection","Detected buffering proxy"):e.stat===mR&&kR("Connection","Detected no buffering proxy")}),setTimeout(()=>{h.$i()},0),h}}function iM(){return"undefined"!=typeof window?window:null}function sM(){return"undefined"!=typeof document?document:null}function oM(e){return new uD(e,!0)}class aM{constructor(e,t,n=1e3,r=1.5,i=6e4){this.Fe=e,this.timerId=t,this.Wi=n,this.Gi=r,this.zi=i,this.Hi=0,this.Ji=null,this.Yi=Date.now(),this.reset()}reset(){this.Hi=0}Xi(){this.Hi=this.zi}Zi(e){this.cancel();var t=Math.floor(this.Hi+this.tr()),n=Math.max(0,Date.now()-this.Yi),r=Math.max(0,t-n);0<r&&kR("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.Hi} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.Ji=this.Fe.enqueueAfterDelay(this.timerId,r,()=>(this.Yi=Date.now(),e())),this.Hi*=this.Gi,this.Hi<this.Wi&&(this.Hi=this.Wi),this.Hi>this.zi&&(this.Hi=this.zi)}er(){null!==this.Ji&&(this.Ji.skipDelay(),this.Ji=null)}cancel(){null!==this.Ji&&(this.Ji.cancel(),this.Ji=null)}tr(){return(Math.random()-.5)*this.Hi}}class cM{constructor(e,t,n,r,i,s,o,a){this.Fe=e,this.nr=n,this.sr=r,this.ir=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=o,this.listener=a,this.state=0,this.rr=0,this.ar=null,this.cr=null,this.stream=null,this.ur=new aM(e,t)}hr(){return 1===this.state||5===this.state||this.lr()}lr(){return 2===this.state||3===this.state}start(){4!==this.state?this.auth():this.dr()}async stop(){this.hr()&&await this.close(0)}wr(){this.state=0,this.ur.reset()}_r(){this.lr()&&null===this.ar&&(this.ar=this.Fe.enqueueAfterDelay(this.nr,6e4,()=>this.mr()))}gr(e){this.yr(),this.stream.send(e)}async mr(){if(this.lr())return this.close(0)}yr(){this.ar&&(this.ar.cancel(),this.ar=null)}pr(){this.cr&&(this.cr.cancel(),this.cr=null)}async close(e,t){this.yr(),this.pr(),this.ur.cancel(),this.rr++,4!==e?this.ur.reset():t&&t.code===PR.RESOURCE_EXHAUSTED?(SR(t.toString()),SR("Using maximum backoff delay to prevent overloading the backend."),this.ur.Xi()):t&&t.code===PR.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.Tr(),this.stream.close(),this.stream=null),this.state=e,await this.listener.Ni(t)}Tr(){}auth(){this.state=1;const e=this.Er(this.rr),n=this.rr;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([e,t])=>{this.rr===n&&this.Ir(e,t)},t=>{e(()=>{var e=new xR(PR.UNKNOWN,"Fetching auth token failed: "+t.message);return this.Ar(e)})})}Ir(e,t){const n=this.Er(this.rr);this.stream=this.Rr(e,t),this.stream.Di(()=>{n(()=>(this.state=2,this.cr=this.Fe.enqueueAfterDelay(this.sr,1e4,()=>(this.lr()&&(this.state=3),Promise.resolve())),this.listener.Di()))}),this.stream.Ni(e=>{n(()=>this.Ar(e))}),this.stream.onMessage(e=>{n(()=>this.onMessage(e))})}dr(){this.state=5,this.ur.Zi(async()=>{this.state=0,this.start()})}Ar(e){return kR("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}Er(t){return e=>{this.Fe.enqueueAndForget(()=>this.rr===t?e():(kR("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class lM extends cM{constructor(e,t,n,r,i,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,r,s),this.k=i}Rr(e,t){return this.ir.Qi("Listen",e,t)}onMessage(e){this.ur.reset();var t=function(e,t){let n;if("targetChange"in t){t.targetChange;var r="NO_CHANGE"===(p=t.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===p?1:"REMOVE"===p?2:"CURRENT"===p?3:"RESET"===p?4:NR(),i=t.targetChange.targetIds||[],s=(p=t.targetChange.resumeToken,e.C?(RR(void 0===p||"string"==typeof p),rP.fromBase64String(p||"")):(RR(void 0===p||p instanceof Uint8Array),rP.fromUint8Array(p||new Uint8Array))),o=t.targetChange.cause,a=o&&(a=void 0===(p=o).code?PR.UNKNOWN:Vx(p.code),new xR(a,p.message||""));n=new rD(r,i,s,a||null)}else if("documentChange"in t){t.documentChange;var c=t.documentChange;c.document,c.document.name,c.document.updateTime;var a=vD(e,c.document.name),l=pD(c.document.updateTime),u=new CP({mapValue:{fields:c.document.fields}}),l=AP.newFoundDocument(a,l,u),u=c.targetIds||[],c=c.removedTargetIds||[];n=new tD(u,c,l.key,l)}else if("documentDelete"in t){t.documentDelete;u=t.documentDelete;u.document;c=vD(e,u.document),l=u.readTime?pD(u.readTime):GR.min(),l=AP.newNoDocument(c,l),u=u.removedTargetIds||[];n=new tD([],u,l.key,l)}else if("documentRemove"in t){t.documentRemove;var h=t.documentRemove;h.document;var d=vD(e,h.document),h=h.removedTargetIds||[];n=new tD([],h,d,null)}else{if(!("filter"in t))return NR();{t.filter;const e=t.filter;e.targetId;h=e.count||0,d=new jx(h),h=e.targetId;n=new nD(h,d)}}var a,p;return n}(this.k,e),n=function(e){if(!("targetChange"in e))return GR.min();var t=e.targetChange;return(!t.targetIds||!t.targetIds.length)&&t.readTime?pD(t.readTime):GR.min()}(e);return this.listener.br(t,n)}Pr(e){const t={};t.database=wD(this.k),t.addTarget=function(e,t){let n;var r=t.target;return n=DP(r)?{documents:SD(e,r)}:{query:CD(e,r)},n.targetId=t.targetId,0<t.resumeToken.approximateByteSize()?n.resumeToken=dD(e,t.resumeToken):0<t.snapshotVersion.compareTo(GR.min())&&(n.readTime=hD(e,t.snapshotVersion.toTimestamp())),n}(this.k,e);var n,r,r=(this.k,n=e,null==(r=function(){switch(n.purpose){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return NR()}}())?null:{"goog-listen-tags":r});r&&(t.labels=r),this.gr(t)}vr(e){const t={};t.database=wD(this.k),t.removeTarget=e,this.gr(t)}}class uM extends cM{constructor(e,t,n,r,i,s){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,r,s),this.k=i,this.Vr=!1}get Sr(){return this.Vr}start(){this.Vr=!1,this.lastStreamToken=void 0,super.start()}Tr(){this.Vr&&this.Dr([])}Rr(e,t){return this.ir.Qi("Write",e,t)}onMessage(e){if(RR(!!e.streamToken),this.lastStreamToken=e.streamToken,this.Vr){this.ur.reset();var t=(r=e.writeResults,i=e.commitTime,r&&0<r.length?(RR(void 0!==i),r.map(e=>function(e,t){let n=e.updateTime?pD(e.updateTime):pD(t);return n.isEqual(GR.min())&&(n=pD(t)),new Ex(n,e.transformResults||[])}(e,i))):[]),n=pD(e.commitTime);return this.listener.Cr(n,t)}var r,i;return RR(!e.writeResults||0===e.writeResults.length),this.Vr=!0,this.listener.Nr()}kr(){const e={};e.database=wD(this.k),this.gr(e)}Dr(e){var t={streamToken:this.lastStreamToken,writes:e.map(e=>ED(this.k,e))};this.gr(t)}}class hM extends class{}{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.ir=n,this.k=r,this.$r=!1}Or(){if(this.$r)throw new xR(PR.FAILED_PRECONDITION,"The client has already been terminated.")}Bi(n,r,i){return this.Or(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([e,t])=>this.ir.Bi(n,r,i,e,t)).catch(e=>{throw"FirebaseError"===e.name?(e.code===PR.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new xR(PR.UNKNOWN,e.toString())})}ji(n,r,i){return this.Or(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([e,t])=>this.ir.ji(n,r,i,e,t)).catch(e=>{throw"FirebaseError"===e.name?(e.code===PR.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new xR(PR.UNKNOWN,e.toString())})}terminate(){this.$r=!0}}class dM{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.Fr=0,this.Mr=null,this.Lr=!0}Br(){0===this.Fr&&(this.Ur("Unknown"),this.Mr=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.Mr=null,this.qr("Backend didn't respond within 10 seconds."),this.Ur("Offline"),Promise.resolve())))}Kr(e){"Online"===this.state?this.Ur("Unknown"):(this.Fr++,1<=this.Fr&&(this.jr(),this.qr(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.Ur("Offline")))}set(e){this.jr(),this.Fr=0,"Online"===e&&(this.Lr=!1),this.Ur(e)}Ur(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}qr(e){var t=`Could not reach Cloud Firestore backend. ${e}\nThis 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.Lr?(SR(t),this.Lr=!1):kR("OnlineStateTracker",t)}jr(){null!==this.Mr&&(this.Mr.cancel(),this.Mr=null)}}class pM{constructor(e,t,n,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.Qr=[],this.Wr=new Map,this.Gr=new Set,this.zr=[],this.Hr=i,this.Hr.Ei(e=>{n.enqueueAndForget(async()=>{TM(this)&&(kR("RemoteStore","Restarting streams for network reachability change."),await async function(e){const t=e;t.Gr.add(4),await gM(t),t.Jr.set("Unknown"),t.Gr.delete(4),await fM(t)}(this))})}),this.Jr=new dM(n,r)}}async function fM(e){if(TM(e))for(const t of e.zr)await t(!0)}async function gM(e){for(const t of e.zr)await t(!1)}function mM(e,t){const n=e;n.Wr.has(t.targetId)||(n.Wr.set(t.targetId,t),bM(n)?wM(n):RM(n).lr()&&yM(n,t))}function vM(e,t){const n=e,r=RM(n);n.Wr.delete(t),r.lr()&&_M(n,t),0===n.Wr.size&&(r.lr()?r._r():TM(n)&&n.Jr.set("Unknown"))}function yM(e,t){e.Yr.X(t.targetId),RM(e).Pr(t)}function _M(e,t){e.Yr.X(t),RM(e).vr(t)}function wM(t){t.Yr=new sD({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),Et:e=>t.Wr.get(e)||null}),RM(t).start(),t.Jr.Br()}function bM(e){return TM(e)&&!RM(e).hr()&&0<e.Wr.size}function TM(e){return 0===e.Gr.size}function IM(e){e.Yr=void 0}async function EM(e,t,n){if(!lO(t))throw t;e.Gr.add(1),await gM(e),e.Jr.set("Offline"),n=n||(()=>k1(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{kR("RemoteStore","Retrying IndexedDB access"),await n(),e.Gr.delete(1),await fM(e)})}function kM(t,n){return n().catch(e=>EM(t,e,n))}async function SM(e){const t=e,n=PM(t);let r=0<t.Qr.length?t.Qr[t.Qr.length-1].batchId:-1;for(;TM(i=t)&&i.Qr.length<10;)try{const e=await function(e,t){const n=e;return n.persistence.runTransaction("Get next mutation batch","readonly",e=>(void 0===t&&(t=-1),n.An.getNextMutationBatchAfterBatchId(e,t)))}(t.localStore,r);if(null===e){0===t.Qr.length&&n._r();break}r=e.batchId,function(e,t){e.Qr.push(t);const n=PM(e);n.lr()&&n.Sr&&n.Dr(t.mutations)}(t,e)}catch(e){await EM(t,e)}var i;CM(t)&&AM(t)}function CM(e){return TM(e)&&!PM(e).hr()&&0<e.Qr.length}function AM(e){PM(e).start()}async function NM(e,t){const n=e;t?(n.Gr.delete(2),await fM(n)):(n.Gr.add(2),await gM(n),n.Jr.set("Unknown"))}function RM(t){return t.Xr||(t.Xr=function(e,t,n){const r=e;return r.Or(),new lM(t,r.ir,r.authCredentials,r.appCheckCredentials,r.k,n)}(t.datastore,t.asyncQueue,{Di:(async function(n){n.Wr.forEach((e,t)=>{yM(n,e)})}).bind(null,t),Ni:(async function(e,t){IM(e),bM(e)?(e.Jr.Kr(t),wM(e)):e.Jr.set("Unknown")}).bind(null,t),br:(async function(e,r,t){if(e.Jr.set("Online"),r instanceof rD&&2===r.state&&r.cause)try{await async function(e){var t=r.cause;for(const n of r.targetIds)e.Wr.has(n)&&(await e.remoteSyncer.rejectListen(n,t),e.Wr.delete(n),e.Yr.removeTarget(n))}(e)}catch(t){kR("RemoteStore","Failed to remove targets %s: %s ",r.targetIds.join(","),t),await EM(e,t)}else if(r instanceof tD?e.Yr.ot(r):r instanceof nD?e.Yr.dt(r):e.Yr.ut(r),!t.isEqual(GR.min()))try{const r=await k1(e.localStore);0<=t.compareTo(r)&&await function(r,i){const e=r.Yr.gt(i);return e.targetChanges.forEach((e,t)=>{if(0<e.resumeToken.approximateByteSize()){const n=r.Wr.get(t);n&&r.Wr.set(t,n.withResumeToken(e.resumeToken,i))}}),e.targetMismatches.forEach(e=>{const t=r.Wr.get(e);var n;t&&(r.Wr.set(e,t.withResumeToken(rP.EMPTY_BYTE_STRING,t.snapshotVersion)),_M(r,e),n=new yO(t.target,e,1,t.sequenceNumber),yM(r,n))}),r.remoteSyncer.applyRemoteEvent(e)}(e,t)}catch(r){kR("RemoteStore","Failed to raise snapshot:",r),await EM(e,r)}}).bind(null,t)}),t.zr.push(async e=>{e?(t.Xr.wr(),bM(t)?wM(t):t.Jr.set("Unknown")):(await t.Xr.stop(),IM(t))})),t.Xr}function PM(t){return t.Zr||(t.Zr=function(e,t,n){const r=e;return r.Or(),new uM(t,r.ir,r.authCredentials,r.appCheckCredentials,r.k,n)}(t.datastore,t.asyncQueue,{Di:(async function(e){PM(e).kr()}).bind(null,t),Ni:(async function(e,t){t&&PM(e).Sr&&await async function(e,t){if(qx(n=t.code)&&n!==PR.ABORTED){const n=e.Qr.shift();PM(e).wr(),await kM(e,()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t)),await SM(e)}var n}(e,t),CM(e)&&AM(e)}).bind(null,t),Nr:(async function(e){const t=PM(e);for(const n of e.Qr)t.Dr(n.mutations)}).bind(null,t),Cr:(async function(e,t,n){const r=e.Qr.shift(),i=vO.from(r,t,n);await kM(e,()=>e.remoteSyncer.applySuccessfulWrite(i)),await SM(e)}).bind(null,t)}),t.zr.push(async e=>{e?(t.Zr.wr(),await SM(t)):(await t.Zr.stop(),0<t.Qr.length&&(kR("RemoteStore",`Stopping write stream with ${t.Qr.length} pending writes`),t.Qr=[]))})),t.Zr}class xM{constructor(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new DR,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(e=>{})}static createAndSchedule(e,t,n,r,i){const s=Date.now()+n,o=new xM(e,t,s,r,i);return o.start(n),o}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new xR(PR.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 DM(e,t){if(SR("AsyncQueue",`${t}: ${e}`),lO(e))return new xR(PR.UNAVAILABLE,`${t}: ${e}`);throw e}class OM{constructor(n){this.comparator=n?(e,t)=>n(e,t)||pP.comparator(e.key,t.key):(e,t)=>pP.comparator(e.key,t.key),this.keyedMap=Gx,this.sortedSet=new Bx(this.comparator)}static emptySet(e){return new OM(e.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){var t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(n){this.sortedSet.inorderTraversal((e,t)=>(n(e),!1))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){var t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof OM))return!1;if(this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),n=e.sortedSet.getIterator();for(;t.hasNext();){const e=t.getNext().key,r=n.getNext().key;if(!e.isEqual(r))return!1}return!0}toString(){const t=[];return this.forEach(e=>{t.push(e.toString())}),0===t.length?"DocumentSet ()":"DocumentSet (\n "+t.join(" \n")+"\n)"}copy(e,t){const n=new OM;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}class MM{constructor(){this.eo=new Bx(pP.comparator)}track(e){var t=e.doc.key,n=this.eo.get(t);!n||0!==e.type&&3===n.type?this.eo=this.eo.insert(t,e):3===e.type&&1!==n.type?this.eo=this.eo.insert(t,{type:n.type,doc:e.doc}):2===e.type&&2===n.type?this.eo=this.eo.insert(t,{type:2,doc:e.doc}):2===e.type&&0===n.type?this.eo=this.eo.insert(t,{type:0,doc:e.doc}):1===e.type&&0===n.type?this.eo=this.eo.remove(t):1===e.type&&2===n.type?this.eo=this.eo.insert(t,{type:1,doc:n.doc}):0===e.type&&1===n.type?this.eo=this.eo.insert(t,{type:2,doc:e.doc}):NR()}no(){const n=[];return this.eo.inorderTraversal((e,t)=>{n.push(t)}),n}}class LM{constructor(e,t,n,r,i,s,o,a){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=o,this.excludesMetadataChanges=a}static fromInitialDocuments(e,t,n,r){const i=[];return t.forEach(e=>{i.push({type:0,doc:e})}),new LM(e,t,OM.emptySet(t),i,n,r,!0,!1)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&sx(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(t[r].type!==n[r].type||!t[r].doc.isEqual(n[r].doc))return!1;return!0}}class FM{constructor(){this.so=void 0,this.listeners=[]}}class UM{constructor(){this.queries=new i1(e=>ox(e),sx),this.onlineState="Unknown",this.io=new Set}}async function jM(e,t){const n=e,r=t.query;let i=!1,s=n.queries.get(r);if(s||(i=!0,s=new FM),i)try{s.so=await n.onListen(r)}catch(e){const n=DM(e,`Initialization of query '${ax(t.query)}' failed`);return void t.onError(n)}n.queries.set(r,s),s.listeners.push(t),t.ro(n.onlineState),!s.so||t.oo(s.so)&&VM(n)}async function qM(e,t){const n=e,r=t.query;let i=!1;const s=n.queries.get(r);if(s){const e=s.listeners.indexOf(t);0<=e&&(s.listeners.splice(e,1),i=0===s.listeners.length)}if(i)return n.queries.delete(r),n.onUnlisten(r)}function VM(e){e.io.forEach(e=>{e.next()})}class BM{constructor(e,t,n){this.query=e,this.ao=t,this.co=!1,this.uo=null,this.onlineState="Unknown",this.options=n||{}}oo(e){if(!this.options.includeMetadataChanges){const t=[];for(const n of e.docChanges)3!==n.type&&t.push(n);e=new LM(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0)}let t=!1;return this.co?this.ho(e)&&(this.ao.next(e),t=!0):this.lo(e,this.onlineState)&&(this.fo(e),t=!0),this.uo=e,t}onError(e){this.ao.error(e)}ro(e){this.onlineState=e;let t=!1;return this.uo&&!this.co&&this.lo(this.uo,e)&&(this.fo(this.uo),t=!0),t}lo(e,t){return!e.fromCache||!(this.options.wo&&"Offline"!==t||e.docs.isEmpty()&&"Offline"!==t)}ho(e){if(0<e.docChanges.length)return!0;var t=this.uo&&this.uo.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}fo(e){e=LM.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache),this.co=!0,this.ao.next(e)}}class WM{constructor(e,t){this.payload=e,this.byteLength=t}_o(){return"metadata"in this.payload}}class KM{constructor(e){this.k=e}Hn(e){return vD(this.k,e)}Jn(e){return e.metadata.exists?ID(this.k,e.document,!1):AP.newNoDocument(this.Hn(e.metadata.name),this.Yn(e.metadata.readTime))}Yn(e){return pD(e)}}class $M{constructor(e,t,n){this.mo=e,this.localStore=t,this.k=n,this.queries=[],this.documents=[],this.progress=zM(e)}yo(e){this.progress.bytesLoaded+=e.byteLength;let t=this.progress.documentsLoaded;return e.payload.namedQuery?this.queries.push(e.payload.namedQuery):e.payload.documentMetadata?(this.documents.push({metadata:e.payload.documentMetadata}),e.payload.documentMetadata.exists||++t):e.payload.document&&(this.documents[this.documents.length-1].document=e.payload.document,++t),t!==this.progress.documentsLoaded?(this.progress.documentsLoaded=t,Object.assign({},this.progress)):null}po(e){const t=new Map,n=new KM(this.k);for(const i of e)if(i.metadata.queries){const e=n.Hn(i.metadata.name);for(const n of i.metadata.queries){var r=(t.get(n)||Jx()).add(e);t.set(n,r)}}return t}async complete(){const e=await async function(e,t,n,r){const i=e;let s=Jx(),o=Hx,a=Qx;for(const e of n){const n=t.Hn(e.metadata.name);e.document&&(s=s.add(n)),o=o.insert(n,t.Jn(e)),a=a.insert(n,t.Yn(e.metadata.readTime))}const c=i.Qn.newChangeBuffer({trackRemovals:!0}),l=await A1(i,(r=r,rx(YP(ZR.fromString(`__bundle__/docs/${r}`)))));return i.persistence.runTransaction("Apply bundle documents","readwrite",t=>C1(t,c,o,GR.min(),a).next(e=>(c.apply(t),e)).next(e=>i.He.removeMatchingKeysForTargetId(t,l.targetId).next(()=>i.He.addMatchingKeys(t,s,l.targetId)).next(()=>i.Wn.Vn(t,e)).next(()=>e)))}(this.localStore,new KM(this.k),this.documents,this.mo.id),t=this.po(this.documents);for(const e of this.queries)await async function(e,n,r=Jx()){const i=await A1(e,rx(NO(n.bundledQuery))),s=e;return s.persistence.runTransaction("Save named query","readwrite",e=>{var t=pD(n.readTime);if(0<=i.snapshotVersion.compareTo(t))return s.Ye.saveNamedQuery(e,n);t=i.withResumeToken(rP.EMPTY_BYTE_STRING,t);return s.qn=s.qn.insert(t.targetId,t),s.He.updateTargetData(e,t).next(()=>s.He.removeMatchingKeysForTargetId(e,i.targetId)).next(()=>s.He.addMatchingKeys(e,r,i.targetId)).next(()=>s.Ye.saveNamedQuery(e,n))})}(this.localStore,e,t.get(e.name));return this.progress.taskState="Success",new y1(Object.assign({},this.progress),e)}}function zM(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}class HM{constructor(e){this.key=e}}class GM{constructor(e){this.key=e}}class QM{constructor(e,t){this.query=e,this.To=t,this.Eo=null,this.current=!1,this.Io=Jx(),this.mutatedKeys=Jx(),this.Ao=lx(e),this.Ro=new OM(this.Ao)}get bo(){return this.To}Po(e,t){const a=t?t.vo:new MM,c=(t||this).Ro;let l=(t||this).mutatedKeys,u=c,h=!1;const d=JP(this.query)&&c.size===this.query.limit?c.last():null,p=XP(this.query)&&c.size===this.query.limit?c.first():null;if(e.inorderTraversal((e,t)=>{const n=c.get(e),r=cx(this.query,t)?t:null,i=!!n&&this.mutatedKeys.has(n.key),s=!!r&&(r.hasLocalMutations||this.mutatedKeys.has(r.key)&&r.hasCommittedMutations);let o=!1;n&&r?n.data.isEqual(r.data)?i!==s&&(a.track({type:3,doc:r}),o=!0):this.Vo(n,r)||(a.track({type:2,doc:r}),o=!0,(d&&0<this.Ao(r,d)||p&&this.Ao(r,p)<0)&&(h=!0)):!n&&r?(a.track({type:0,doc:r}),o=!0):n&&!r&&(a.track({type:1,doc:n}),o=!0,(d||p)&&(h=!0)),o&&(l=r?(u=u.add(r),s?l.add(e):l.delete(e)):(u=u.delete(e),l.delete(e)))}),JP(this.query)||XP(this.query))for(;u.size>this.query.limit;){const e=JP(this.query)?u.last():u.first();u=u.delete(e.key),l=l.delete(e.key),a.track({type:1,doc:e})}return{Ro:u,vo:a,Bn:h,mutatedKeys:l}}Vo(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n){var r=this.Ro;this.Ro=e.Ro,this.mutatedKeys=e.mutatedKeys;const i=e.vo.no();i.sort((e,t)=>function(e,t){var n=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return NR()}};return n(e)-n(t)}(e.type,t.type)||this.Ao(e.doc,t.doc)),this.So(n);var s=t?this.Do():[],o=0===this.Io.size&&this.current?1:0,a=o!==this.Eo;return this.Eo=o,0!==i.length||a?{snapshot:new LM(this.query,e.Ro,r,i,e.mutatedKeys,0==o,a,!1),Co:s}:{Co:s}}ro(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({Ro:this.Ro,vo:new MM,mutatedKeys:this.mutatedKeys,Bn:!1},!1)):{Co:[]}}No(e){return!this.To.has(e)&&!!this.Ro.has(e)&&!this.Ro.get(e).hasLocalMutations}So(e){e&&(e.addedDocuments.forEach(e=>this.To=this.To.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.To=this.To.delete(e)),this.current=e.current)}Do(){if(!this.current)return[];const t=this.Io;this.Io=Jx(),this.Ro.forEach(e=>{this.No(e.key)&&(this.Io=this.Io.add(e.key))});const n=[];return t.forEach(e=>{this.Io.has(e)||n.push(new GM(e))}),this.Io.forEach(e=>{t.has(e)||n.push(new HM(e))}),n}ko(e){this.To=e.zn,this.Io=Jx();var t=this.Po(e.documents);return this.applyChanges(t,!0)}xo(){return LM.fromInitialDocuments(this.query,this.Ro,this.mutatedKeys,0===this.Eo)}}class YM{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class JM{constructor(e){this.key=e,this.$o=!1}}class XM{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.Oo={},this.Fo=new i1(e=>ox(e),sx),this.Mo=new Map,this.Lo=new Set,this.Bo=new Bx(pP.comparator),this.Uo=new Map,this.qo=new O1,this.Ko={},this.jo=new Map,this.Qo=zO.re(),this.onlineState="Unknown",this.Wo=void 0}get isPrimaryClient(){return!0===this.Wo}}async function ZM(n,e,t,r){n.Go=(e,s,t)=>async function(e,t,n){let r=t.view.Po(s);r.Bn&&(r=await R1(e.localStore,t.query,!1).then(({documents:e})=>t.view.Po(e,r)));var i=n&&n.targetChanges.get(t.targetId),i=t.view.applyChanges(r,e.isPrimaryClient,i);return cL(e,t.targetId,i.Co),i.snapshot}(n,e,t);const i=await R1(n.localStore,e,!0),s=new QM(e,i.zn),o=s.Po(i.documents),a=eD.createSynthesizedTargetChangeForCurrentChange(t,r&&"Offline"!==n.onlineState),c=s.applyChanges(o,n.isPrimaryClient,a);cL(n,t,c.Co);var l=new YM(e,t,s);return n.Fo.set(e,l),n.Mo.has(t)?n.Mo.get(t).push(e):n.Mo.set(t,[e]),c.snapshot}async function eL(e,t,n){const r=gL(e);try{const e=await function(e,r){const i=e,s=HR.now(),t=r.reduce((e,t)=>e.add(t.key),Jx());let o;return i.persistence.runTransaction("Locally write mutations","readwrite",n=>i.Wn.vn(n,t).next(e=>{o=e;const t=[];for(const n of r){const r=function(e,t){let n=null;for(const r of e.fieldTransforms){const e=t.data.field(r.field),i=fx(r.transform,e||null);null!=i&&(null==n&&(n=CP.empty()),n.set(r.field,i))}return n||null}(n,o.get(n.key));null!=r&&t.push(new Dx(n.key,r,function r(e){const i=[];return YR(e.fields,(e,t)=>{const n=new tP([e]);if(kP(t)){const e=r(t.mapValue).fields;if(0===e.length)i.push(n);else for(const t of e)i.push(n.child(t))}else i.push(n)}),new nP(i)}(r.value.mapValue),kx.exists(!0)))}return i.An.addMutationBatch(n,s,t,r)})).then(e=>(e.applyToLocalDocumentSet(o),{batchId:e.batchId,changes:o}))}(r.localStore,t);r.sharedClientState.addPendingMutation(e.batchId),function(e,t,n){let r=e.Ko[e.currentUser.toKey()];r=r||new Bx(KR),r=r.insert(t,n),e.Ko[e.currentUser.toKey()]=r}(r,e.batchId,n),await uL(r,e.changes),await SM(r.remoteStore)}catch(e){const t=DM(e,"Failed to persist write");n.reject(t)}}async function tL(e,t){const r=e;try{const e=await S1(r.localStore,t);t.targetChanges.forEach((e,t)=>{const n=r.Uo.get(t);n&&(RR(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1),0<e.addedDocuments.size?n.$o=!0:0<e.modifiedDocuments.size?RR(n.$o):0<e.removedDocuments.size&&(RR(n.$o),n.$o=!1))}),await uL(r,e,t)}catch(e){await JO(e)}}function nL(r,i,e){const t=r;if(t.isPrimaryClient&&0===e||!t.isPrimaryClient&&1===e){const r=[];t.Fo.forEach((e,t)=>{var n=t.view.ro(i);n.snapshot&&r.push(n.snapshot)}),function(e,n){const t=e;t.onlineState=n;let r=!1;t.queries.forEach((e,t)=>{for(const e of t.listeners)e.ro(n)&&(r=!0)}),r&&VM(t)}(t.eventManager,i),r.length&&t.Oo.br(r),t.onlineState=i,t.isPrimaryClient&&t.sharedClientState.setOnlineState(i)}}async function rL(e,t){const n=e,r=t.batch.batchId;try{const e=await function(e,r){const i=e;return i.persistence.runTransaction("Acknowledge batch","readwrite-primary",e=>{const t=r.batch.keys(),n=i.Qn.newChangeBuffer({trackRemovals:!0});return function(e,t,r,i){const s=r.batch,n=s.keys();let o=iO.resolve();return n.forEach(n=>{o=o.next(()=>i.getEntry(t,n)).next(e=>{var t=r.docVersions.get(n);RR(null!==t),e.version.compareTo(t)<0&&(s.applyToRemoteDocument(e,r),e.isValidDocument()&&i.addEntry(e,r.commitVersion))})}),o.next(()=>e.An.removeMutationBatch(t,s))}(i,e,r,n).next(()=>n.apply(e)).next(()=>i.An.performConsistencyCheck(e)).next(()=>i.Wn.vn(e,t))})}(n.localStore,t);sL(n,r,null),iL(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await uL(n,e)}catch(e){await JO(e)}}function iL(e,t){(e.jo.get(t)||[]).forEach(e=>{e.resolve()}),e.jo.delete(t)}function sL(e,t,n){const r=e;let i=r.Ko[r.currentUser.toKey()];if(i){const e=i.get(t);e&&(n?e.reject(n):e.resolve(),i=i.remove(t)),r.Ko[r.currentUser.toKey()]=i}}function oL(t,e,n=null){t.sharedClientState.removeLocalQueryTarget(e);for(const r of t.Mo.get(e))t.Fo.delete(r),n&&t.Oo.zo(r,n);t.Mo.delete(e),t.isPrimaryClient&&t.qo.us(e).forEach(e=>{t.qo.containsKey(e)||aL(t,e)})}function aL(e,t){e.Lo.delete(t.path.canonicalString());var n=e.Bo.get(t);null!==n&&(vM(e.remoteStore,n),e.Bo=e.Bo.remove(t),e.Uo.delete(n),lL(e))}function cL(e,t,n){for(const r of n)r instanceof HM?(e.qo.addReference(r.key,t),function(e,t){const n=t.key,r=n.path.canonicalString();e.Bo.get(n)||e.Lo.has(r)||(kR("SyncEngine","New document in limbo: "+n),e.Lo.add(r),lL(e))}(e,r)):r instanceof GM?(kR("SyncEngine","Document no longer in limbo: "+r.key),e.qo.removeReference(r.key,t),e.qo.containsKey(r.key)||aL(e,r.key)):NR()}function lL(e){for(;0<e.Lo.size&&e.Bo.size<e.maxConcurrentLimboResolutions;){var t=e.Lo.values().next().value;e.Lo.delete(t);var n=new pP(ZR.fromString(t)),t=e.Qo.next();e.Uo.set(t,new JM(n)),e.Bo=e.Bo.insert(n,t),mM(e.remoteStore,new yO(rx(YP(n.path)),t,2,BR.I))}}async function uL(e,t,r){const i=e,s=[],o=[],a=[];i.Fo.isEmpty()||(i.Fo.forEach((e,n)=>{a.push(i.Go(n,t,r).then(e=>{var t;e&&(i.isPrimaryClient&&i.sharedClientState.updateQueryState(n.targetId,e.fromCache?"not-current":"current"),s.push(e),t=w1.$n(n.targetId,e),o.push(t))}))}),await Promise.all(a),i.Oo.br(s),await async function(e,t){const r=e;try{await r.persistence.runTransaction("notifyLocalViewChanges","readwrite",n=>iO.forEach(t,t=>iO.forEach(t.kn,e=>r.persistence.referenceDelegate.addReference(n,t.targetId,e)).next(()=>iO.forEach(t.xn,e=>r.persistence.referenceDelegate.removeReference(n,t.targetId,e)))))}catch(e){if(!lO(e))throw e;kR("LocalStore","Failed to update sequence numbers: "+e)}for(const e of t){const t=e.targetId;if(!e.fromCache){const e=r.qn.get(t),n=e.snapshotVersion,i=e.withLastLimboFreeSnapshotVersion(n);r.qn=r.qn.insert(t,i)}}}(i.localStore,o))}async function hL(r,e){const i=r;if(fL(i),gL(i),!0===e&&!0!==i.Wo){const r=i.sharedClientState.getAllActiveQueryTargets(),e=await dL(i,r.toArray());i.Wo=!0,await NM(i.remoteStore,!0);for(const r of e)mM(i.remoteStore,r)}else if(!1===e&&!1!==i.Wo){const r=[];let n=Promise.resolve();i.Mo.forEach((e,t)=>{i.sharedClientState.isLocalQueryTarget(t)?r.push(t):n=n.then(()=>(oL(i,t),N1(i.localStore,t,!0))),vM(i.remoteStore,t)}),await n,await dL(i,r),function(){const n=i;n.Uo.forEach((e,t)=>{vM(n.remoteStore,t)}),n.qo.hs(),n.Uo=new Map,n.Bo=new Bx(pP.comparator)}(),i.Wo=!1,await NM(i.remoteStore,!1)}}async function dL(t,n){const r=t,i=[],s=[];for(const t of n){let e;const u=r.Mo.get(t);if(u&&0!==u.length){e=await A1(r.localStore,rx(u[0]));for(const t of u){const n=r.Fo.get(t),u=(o=r,a=n,l=c=void 0,l=await R1((c=o).localStore,a.query,!0),l=a.view.ko(l),c.isPrimaryClient&&cL(c,a.targetId,l.Co),await l);u.snapshot&&s.push(u.snapshot)}}else{const u=await P1(r.localStore,t);e=await A1(r.localStore,u),await ZM(r,pL(u),t,!1)}i.push(e)}var o,a,c,l;return r.Oo.br(s),i}function pL(e){return QP(e.path,e.collectionGroup,e.orderBy,e.filters,e.limit,"F",e.startAt,e.endAt)}function fL(e){const t=e;return t.remoteStore.remoteSyncer.applyRemoteEvent=tL.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=(function(e,t){const n=e,r=n.Uo.get(t);if(r&&r.$o)return Jx().add(r.key);{let e=Jx();const r=n.Mo.get(t);if(!r)return e;for(const t of r){const r=n.Fo.get(t);e=e.unionWith(r.view.bo)}return e}}).bind(null,t),t.remoteStore.remoteSyncer.rejectListen=(async function(e,t,n){const r=e;r.sharedClientState.updateQueryState(t,"rejected",n);const i=r.Uo.get(t),s=i&&i.key;if(s){let e=new Bx(pP.comparator);e=e.insert(s,AP.newNoDocument(s,GR.min()));const n=Jx().add(s),i=new Zx(GR.min(),new Map,new $x(KR),e,n);await tL(r,i),r.Bo=r.Bo.remove(s),r.Uo.delete(t),lL(r)}else await N1(r.localStore,t,!1).then(()=>oL(r,t,n)).catch(JO)}).bind(null,t),t.Oo.br=(function(e,t){const n=e;let r=!1;for(const e of t){const t=e.query,i=n.queries.get(t);if(i){for(const t of i.listeners)t.oo(e)&&(r=!0);i.so=e}}r&&VM(n)}).bind(null,t.eventManager),t.Oo.zo=(function(e,t,n){const r=e,i=r.queries.get(t);if(i)for(const e of i.listeners)e.onError(n);r.queries.delete(t)}).bind(null,t.eventManager),t}function gL(e){const t=e;return t.remoteStore.remoteSyncer.applySuccessfulWrite=rL.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=(async function(e,t,n){const r=e;try{const e=await function(e,r){const i=e;return i.persistence.runTransaction("Reject batch","readwrite-primary",t=>{let n;return i.An.lookupMutationBatch(t,r).next(e=>(RR(null!==e),n=e.keys(),i.An.removeMutationBatch(t,e))).next(()=>i.An.performConsistencyCheck(t)).next(()=>i.Wn.vn(t,n))})}(r.localStore,t);sL(r,t,n),iL(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),await uL(r,e)}catch(n){await JO(n)}}).bind(null,t),t}class mL{constructor(){this.synchronizeTabs=!1}async initialize(e){this.k=oM(e.databaseInfo.databaseId),this.sharedClientState=this.Jo(e),this.persistence=this.Yo(e),await this.persistence.start(),this.gcScheduler=this.Xo(e),this.localStore=this.Zo(e)}Xo(e){return null}Zo(e){return I1(this.persistence,new b1,e.initialUser,this.k)}Yo(e){return new q1(B1.ks,this.k)}Jo(e){return new X1}async terminate(){this.gcScheduler&&this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class vL extends mL{constructor(e,t,n){super(),this.ta=e,this.cacheSizeBytes=t,this.forceOwnership=n,this.synchronizeTabs=!1}async initialize(e){await super.initialize(e),await async function(e){const t=e;return t.persistence.runTransaction("Synchronize last document change read time","readonly",t=>function(){const e=l1(t);let r=GR.min();return e.jt({index:zD.readTimeIndex,reverse:!0},(e,t,n)=>{t.readTime&&(r=IO(t.readTime)),n.done()}).next(()=>r)}()).then(e=>{t.jn=e})}(this.localStore),await this.ta.initialize(this,e),await gL(this.ta.syncEngine),await SM(this.ta.remoteStore),await this.persistence.sn(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(this.localStore),Promise.resolve()))}Zo(e){return I1(this.persistence,new b1,e.initialUser,this.k)}Xo(e){var t=this.persistence.referenceDelegate.garbageCollector;return new e1(t,e.asyncQueue)}Yo(e){var t=v1(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?UO.withCacheSize(this.cacheSizeBytes):UO.DEFAULT;return new f1(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,iM(),sM(),this.k,this.sharedClientState,!!this.forceOwnership)}Jo(e){return new X1}}class yL extends vL{constructor(e,t){super(e,t,!1),this.ta=e,this.cacheSizeBytes=t,this.synchronizeTabs=!0}async initialize(e){await super.initialize(e);var t=this.ta.syncEngine;this.sharedClientState instanceof J1&&(this.sharedClientState.syncEngine={mi:(async function(e,t,n,r){var i=e,s=await function(e,n){const r=e,i=r.An;return r.persistence.runTransaction("Lookup mutation documents","readonly",t=>i.Zt(t,n).next(e=>e?r.Wn.vn(t,e):iO.resolve(null)))}(i.localStore,t);null!==s?("pending"===n?await SM(i.remoteStore):"acknowledged"===n||"rejected"===n?(sL(i,t,r||null),iL(i,t),i.localStore.An.ee(t)):NR(),await uL(i,s)):kR("SyncEngine","Cannot apply mutation batch with id: "+t)}).bind(null,t),gi:(async function(e,t,n,r){const i=e;if(i.Wo)kR("SyncEngine","Ignoring unexpected query state notification.");else if(i.Mo.has(t))switch(n){case"current":case"not-current":{const e=await x1(i.localStore),r=Zx.createSynthesizedRemoteEventForCurrentChange(t,"current"===n);await uL(i,e,r);break}case"rejected":await N1(i.localStore,t,!0),oL(i,t,r);break;default:NR()}}).bind(null,t),yi:(async function(e,t,n){const r=fL(e);if(r.Wo){for(const e of t)if(r.Mo.has(e))kR("SyncEngine","Adding an already active target "+e);else{const t=await P1(r.localStore,e),n=await A1(r.localStore,t);await ZM(r,pL(t),n.targetId,!1),mM(r.remoteStore,n)}for(const e of n)r.Mo.has(e)&&await N1(r.localStore,e,!1).then(()=>{vM(r.remoteStore,e),oL(r,e)}).catch(JO)}}).bind(null,t),Tn:(function(e){return e.localStore.persistence.Tn()}).bind(null,t),_i:(async function(e){const t=e;return x1(t.localStore).then(e=>uL(t,e))}).bind(null,t)},await this.sharedClientState.start()),await this.persistence.sn(async e=>{await hL(this.ta.syncEngine,e),this.gcScheduler&&(e&&!this.gcScheduler.started?this.gcScheduler.start(this.localStore):e||this.gcScheduler.stop())})}Jo(e){var t=iM();if(!J1.Pt(t))throw new xR(PR.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var n=v1(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new J1(t,e.asyncQueue,n,e.clientId,e.initialUser)}}class _L{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=e=>nL(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=(async function(e,t){const n=e;if(!n.currentUser.isEqual(t)){kR("SyncEngine","User change. New user:",t.toKey());const r=await E1(n.localStore,t);n.currentUser=t,(e=n).jo.forEach(e=>{e.forEach(e=>{e.reject(new xR(PR.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.jo.clear(),n.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),await uL(n,r.Gn)}}).bind(null,this.syncEngine),await NM(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new UM}createDatastore(e){var t,n,r,i,s=oM(e.databaseInfo.databaseId),t=(t=e.databaseInfo,new rM(t));return n=e.authCredentials,r=e.appCheckCredentials,i=t,e=s,new hM(n,r,i,e)}createRemoteStore(e){return t=this.localStore,n=this.datastore,r=e.asyncQueue,i=e=>nL(this.syncEngine,e,0),s=new(eM.Pt()?eM:Z1),new pM(t,n,r,i,s);var t,n,r,i,s}createSyncEngine(e,t){return function(e,t,n,r,i,s,o){const a=new XM(e,t,n,r,i,s);return o&&(a.Wo=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}terminate(){return async function(e){const t=e;kR("RemoteStore","RemoteStore shutting down."),t.Gr.add(5),await gM(t),t.Hr.shutdown(),t.Jr.set("Unknown")}(this.remoteStore)}}function wL(t,n=10240){let r=0;return{async read(){if(r<t.byteLength){var e={value:t.slice(r,r+n),done:!1};return r+=n,e}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.reject("unimplemented")}}class bL{constructor(e){this.observer=e,this.muted=!1}next(e){this.observer.next&&this.ea(this.observer.next,e)}error(e){this.observer.error?this.ea(this.observer.error,e):console.error("Uncaught Error in snapshot listener:",e)}na(){this.muted=!0}ea(e,t){this.muted||setTimeout(()=>{this.muted||e(t)},0)}}class TL{constructor(e,t){this.sa=e,this.k=t,this.metadata=new DR,this.buffer=new Uint8Array,this.ia=new TextDecoder("utf-8"),this.ra().then(e=>{e&&e._o()?this.metadata.resolve(e.payload.metadata):this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null==e?void 0:e.payload)}`))},e=>this.metadata.reject(e))}close(){return this.sa.cancel()}async getMetadata(){return this.metadata.promise}async Ho(){return await this.getMetadata(),this.ra()}async ra(){var e=await this.oa();if(null===e)return null;var t=this.ia.decode(e),n=Number(t);isNaN(n)&&this.aa(`length string (${t}) is not valid number`);t=await this.ca(n);return new WM(JSON.parse(t),e.length+n)}ua(){return this.buffer.findIndex(e=>e==="{".charCodeAt(0))}async oa(){for(;this.ua()<0&&!await this.ha(););if(0===this.buffer.length)return null;var e=this.ua();e<0&&this.aa("Reached the end of bundle when a length string is expected.");var t=this.buffer.slice(0,e);return this.buffer=this.buffer.slice(e),t}async ca(e){for(;this.buffer.length<e;)await this.ha()&&this.aa("Reached the end of bundle when more is expected.");var t=this.ia.decode(this.buffer.slice(0,e));return this.buffer=this.buffer.slice(e),t}aa(e){throw this.sa.cancel(),new Error(`Invalid bundle format: ${e}`)}async ha(){var e=await this.sa.read();if(!e.done){const 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 IL{constructor(e){this.datastore=e,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}async lookup(e){if(this.ensureCommitNotCalled(),0<this.mutations.length)throw new xR(PR.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");const t=await async function(e,t){const r=e,n=wD(r.k)+"/documents",i={documents:t.map(e=>mD(r.k,e))},s=await r.ji("BatchGetDocuments",n,i),o=new Map;s.forEach(e=>{const t=(n=r.k,"found"in(e=e)?function(e,t){RR(!!t.found),t.found.name,t.found.updateTime;var n=vD(e,t.found.name),r=pD(t.found.updateTime),i=new CP({mapValue:{fields:t.found.fields}});return AP.newFoundDocument(n,r,i)}(n,e):"missing"in e?function(e,t){RR(!!t.missing),RR(!!t.readTime);var n=vD(e,t.missing),r=pD(t.readTime);return AP.newNoDocument(n,r)}(n,e):NR());var n;o.set(t.key.toString(),t)});const a=[];return t.forEach(e=>{var t=o.get(e.toString());RR(!!t),a.push(t)}),a}(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.lastWriteError=e}this.writtenDocs.add(e.toString())}delete(e){this.write(new Fx(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;const t=this.readVersions;this.mutations.forEach(e=>{t.delete(e.key.toString())}),t.forEach((e,t)=>{var n=pP.fromPath(t);this.mutations.push(new Ux(n,this.precondition(n)))}),await async function(e,t){const n=e,r=wD(n.k)+"/documents",i={writes:t.map(e=>ED(n.k,e))};await n.Bi("Commit",r,i)}(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw NR();t=GR.min()}var n=this.readVersions.get(e.key.toString());if(n){if(!t.isEqual(n))throw new xR(PR.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),t)}precondition(e){var t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&t?kx.updateTime(t):kx.none()}preconditionForUpdate(e){const t=this.readVersions.get(e.toString());if(this.writtenDocs.has(e.toString())||!t)return kx.exists(!0);if(t.isEqual(GR.min()))throw new xR(PR.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return kx.updateTime(t)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}class EL{constructor(e,t,n,r){this.asyncQueue=e,this.datastore=t,this.updateFunction=n,this.deferred=r,this.la=5,this.ur=new aM(this.asyncQueue,"transaction_retry")}run(){--this.la,this.fa()}fa(){this.ur.Zi(async()=>{const t=new IL(this.datastore),e=this.da(t);e&&e.then(e=>{this.asyncQueue.enqueueAndForget(()=>t.commit().then(()=>{this.deferred.resolve(e)}).catch(e=>{this.wa(e)}))}).catch(e=>{this.wa(e)})})}da(e){try{var t=this.updateFunction(e);return!uP(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}}wa(e){0<this.la&&this._a(e)?(--this.la,this.asyncQueue.enqueueAndForget(()=>(this.fa(),Promise.resolve()))):this.deferred.reject(e)}_a(e){if("FirebaseError"!==e.name)return!1;var t=e.code;return"aborted"===t||"failed-precondition"===t||!qx(t)}}class kL{constructor(e,t,n,r){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=bR.UNAUTHENTICATED,this.clientId=WR.A(),this.authCredentialListener=()=>Promise.resolve(),this.authCredentials.start(n,async e=>{kR("FirestoreClient","Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(n,()=>Promise.resolve())}async getConfiguration(){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}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new xR(PR.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const n=new DR;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this.onlineComponents&&await this.onlineComponents.terminate(),this.offlineComponents&&await this.offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),n.resolve()}catch(e){var t=DM(e,"Failed to shutdown persistence");n.reject(t)}}),n.promise}}async function SL(e,t){e.asyncQueue.verifyOperationInProgress(),kR("FirestoreClient","Initializing OfflineComponentProvider");var n=await e.getConfiguration();await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener(async e=>{r.isEqual(e)||(await E1(t.localStore,e),r=e)}),t.persistence.setDatabaseDeletedListener(()=>e.terminate()),e.offlineComponents=t}async function CL(e,t){e.asyncQueue.verifyOperationInProgress();var n=await AL(e);kR("FirestoreClient","Initializing OnlineComponentProvider");var r=await e.getConfiguration();await t.initialize(n,r),e.setCredentialChangeListener(e=>async function(e,t){const n=e;n.asyncQueue.verifyOperationInProgress(),kR("RemoteStore","RemoteStore received new credentials");var r=TM(n);n.Gr.add(3),await gM(n),r&&n.Jr.set("Unknown"),await n.remoteSyncer.handleCredentialChange(t),n.Gr.delete(3),await fM(n)}(t.remoteStore,e)),e.onlineComponents=t}async function AL(e){return e.offlineComponents||(kR("FirestoreClient","Using default OfflineComponentProvider"),await SL(e,new mL)),e.offlineComponents}async function NL(e){return e.onlineComponents||(kR("FirestoreClient","Using default OnlineComponentProvider"),await CL(e,new _L)),e.onlineComponents}function RL(e){return AL(e).then(e=>e.persistence)}function PL(e){return AL(e).then(e=>e.localStore)}function xL(e){return NL(e).then(e=>e.remoteStore)}function DL(e){return NL(e).then(e=>e.syncEngine)}async function OL(e){const t=await NL(e),n=t.eventManager;return n.onListen=(async function(e,t){const n=fL(e);let r,i;const s=n.Fo.get(t);if(s)r=s.targetId,n.sharedClientState.addLocalQueryTarget(r),i=s.view.xo();else{const e=await A1(n.localStore,rx(t)),s=n.sharedClientState.addLocalQueryTarget(e.targetId);r=e.targetId,i=await ZM(n,t,r,"current"===s),n.isPrimaryClient&&mM(n.remoteStore,e)}return i}).bind(null,t.syncEngine),n.onUnlisten=(async function(e,t){const n=e,r=n.Fo.get(t),i=n.Mo.get(r.targetId);if(1<i.length)return n.Mo.set(r.targetId,i.filter(e=>!sx(e,t))),void n.Fo.delete(t);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)||await N1(n.localStore,r.targetId,!1).then(()=>{n.sharedClientState.clearQueryState(r.targetId),vM(n.remoteStore,r.targetId),oL(n,r.targetId)}).catch(JO)):(oL(n,r.targetId),await N1(n.localStore,r.targetId,!0))}).bind(null,t.syncEngine),n}function ML(e,t,n={}){const r=new DR;return e.asyncQueue.enqueueAndForget(async()=>function(n,r,i,s,o){const e=new bL({next:e=>{r.enqueueAndForget(()=>qM(n,a));var t=e.docs.has(i);!t&&e.fromCache?o.reject(new xR(PR.UNAVAILABLE,"Failed to get document because the client is offline.")):t&&e.fromCache&&s&&"server"===s.source?o.reject(new xR(PR.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.)')):o.resolve(e)},error:e=>o.reject(e)}),a=new BM(YP(i.path),e,{includeMetadataChanges:!0,wo:!0});return jM(n,a)}(await OL(e),e.asyncQueue,t,n,r)),r.promise}function LL(e,t,n={}){const r=new DR;return e.asyncQueue.enqueueAndForget(async()=>function(t,n,e,r,i){const s=new bL({next:e=>{n.enqueueAndForget(()=>qM(t,o)),e.fromCache&&"server"===r.source?i.reject(new xR(PR.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(e)},error:e=>i.reject(e)}),o=new BM(e,s,{includeMetadataChanges:!0,wo:!0});return jM(t,o)}(await OL(e),e.asyncQueue,t,n,r)),r.promise}function FL(e,t,n,r){const i=(n=n,t=oM(t),s="string"==typeof n?(new TextEncoder).encode(n):n,n=function(e){if(e instanceof Uint8Array)return wL(e,void 0);if(e instanceof ArrayBuffer)return wL(new Uint8Array(e),void 0);if(e instanceof ReadableStream)return e.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}(s),t=t,new TL(n,t));var s;e.asyncQueue.enqueueAndForget(async()=>{!function(e,t,n){const r=e;!async function(t,n,r){try{var i=await n.getMetadata();if(await function(e,t){const n=e,r=pD(t.createTime);return n.persistence.runTransaction("hasNewerBundle","readonly",e=>n.Ye.getBundleMetadata(e,t.id)).then(e=>!!e&&0<=e.createTime.compareTo(r))}(t.localStore,i))return await n.close(),void r._completeWith({taskState:"Success",documentsLoaded:i.totalDocuments,bytesLoaded:i.totalBytes,totalDocuments:i.totalDocuments,totalBytes:i.totalBytes});r._updateProgress(zM(i));const o=new $M(i,t.localStore,n.k);let e=await n.Ho();for(;e;){const t=await o.yo(e);t&&r._updateProgress(t),e=await n.Ho()}var s=await o.complete();await uL(t,s.In,void 0),await function(e,t){const n=e;return n.persistence.runTransaction("Save bundle","readwrite",e=>n.Ye.saveBundleMetadata(e,t))}(t.localStore,i),r._completeWith(s.progress)}catch(t){CR("SyncEngine",`Loading bundle failed with ${t}`),r._failWith(t)}}(r,t,n).then(()=>{r.sharedClientState.notifyBundleLoaded()})}(await DL(e),i,r)})}class UL{constructor(e,t,n,r,i,s,o,a){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=o,this.useFetchStreams=a}}class jL{constructor(e,t){this.projectId=e,this.database=t||"(default)"}get isDefaultDatabase(){return"(default)"===this.database}isEqual(e){return e instanceof jL&&e.projectId===this.projectId&&e.database===this.database}}const qL=new Map;function VL(e,t,n){if(!n)throw new xR(PR.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function BL(e,t,n,r){if(!0===t&&!0===r)throw new xR(PR.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function WL(e){if(!pP.isDocumentKey(e))throw new xR(PR.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function KL(e){if(pP.isDocumentKey(e))throw new xR(PR.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function $L(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return 20<e.length&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"!=typeof e)return"function"==typeof e?"a function":NR();if(e instanceof Array)return"an array";var t=(e=e).constructor?e.constructor.name:null;return t?`a custom ${t} object`:"an object"}function zL(e,t){if((e="_delegate"in e?e._delegate:e)instanceof t)return e;if(t.name===e.constructor.name)throw new xR(PR.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");var n=$L(e);throw new xR(PR.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}function HL(e,t){if(t<=0)throw new xR(PR.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}class GL{constructor(e){var t;if(void 0===e.host){if(void 0!==e.ssl)throw new xR(PR.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=e.host,this.ssl=null===(t=e.ssl)||void 0===t||t;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,void 0===e.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new xR(PR.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.useFetchStreams=!!e.useFetchStreams,BL("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling)}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class QL{constructor(e,t,n){this._authCredentials=t,this._appCheckCredentials=n,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new GL({}),this._settingsFrozen=!1,e instanceof jL?this._databaseId=e:(this._app=e,this._databaseId=function(e){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new xR(PR.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new jL(e.options.projectId)}(e))}get app(){if(!this._app)throw new xR(PR.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 void 0!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new xR(PR.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 GL(e),void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new MR;switch(e.type){case"gapi":var t=e.client;return RR(!("object"!=typeof t||null===t||!t.auth||!t.auth.getAuthHeaderValueForFirstParty)),new jR(t,e.sessionIndex||"0",e.iamToken||null);case"provider":return e.client;default:throw new xR(PR.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){const t=qL.get(e);t&&(kR("ComponentProvider","Removing Datastore"),qL.delete(e),t.terminate())}(this),Promise.resolve()}}class YL{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 XL(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new YL(this.firestore,e,this._key)}}class JL{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new JL(this.firestore,e,this._query)}}class XL extends JL{constructor(e,t,n){super(e,t,YP(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new YL(this.firestore,null,new pP(e))}withConverter(e){return new XL(this.firestore,e,this._path)}}function ZL(e,t,...n){if(e=Kd(e),VL("collection","path",t),e instanceof QL){var r=ZR.fromString(t,...n);return KL(r),new XL(e,null,r)}if(!(e instanceof YL||e instanceof XL))throw new xR(PR.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");r=e._path.child(ZR.fromString(t,...n));return KL(r),new XL(e.firestore,null,r)}function eF(e,t,...n){if(e=Kd(e),VL("doc","path",t=1===arguments.length?WR.A():t),e instanceof QL){var r=ZR.fromString(t,...n);return WL(r),new YL(e,null,new pP(r))}if(!(e instanceof YL||e instanceof XL))throw new xR(PR.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");r=e._path.child(ZR.fromString(t,...n));return WL(r),new YL(e.firestore,e instanceof XL?e.converter:null,new pP(r))}function tF(e,t){return e=Kd(e),t=Kd(t),(e instanceof YL||e instanceof XL)&&(t instanceof YL||t instanceof XL)&&e.firestore===t.firestore&&e.path===t.path&&e.converter===t.converter}function nF(e,t){return e=Kd(e),t=Kd(t),e instanceof JL&&t instanceof JL&&e.firestore===t.firestore&&sx(e._query,t._query)&&e.converter===t.converter}class rF{constructor(){this.ma=Promise.resolve(),this.ga=[],this.ya=!1,this.pa=[],this.Ta=null,this.Ea=!1,this.Ia=!1,this.Aa=[],this.ur=new aM(this,"async_queue_retry"),this.Ra=()=>{var e=sM();e&&kR("AsyncQueue","Visibility state changed to "+e.visibilityState),this.ur.er()};const e=sM();e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.Ra)}get isShuttingDown(){return this.ya}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.ba(),this.Pa(e)}enterRestrictedMode(e){if(!this.ya){this.ya=!0,this.Ia=e||!1;const t=sM();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.Ra)}}enqueue(e){if(this.ba(),this.ya)return new Promise(()=>{});const t=new DR;return this.Pa(()=>this.ya&&this.Ia?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.ga.push(e),this.va()))}async va(){if(0!==this.ga.length){try{await this.ga[0](),this.ga.shift(),this.ur.reset()}catch(e){if(!lO(e))throw e;kR("AsyncQueue","Operation failed with retryable error: "+e)}0<this.ga.length&&this.ur.Zi(()=>this.va())}}Pa(e){var t=this.ma.then(()=>(this.Ea=!0,e().catch(e=>{throw this.Ta=e,this.Ea=!1,SR("INTERNAL UNHANDLED ERROR: ",function(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}(e)),e}).then(e=>(this.Ea=!1,e))));return this.ma=t}enqueueAfterDelay(e,t,n){this.ba(),-1<this.Aa.indexOf(e)&&(t=0);var r=xM.createAndSchedule(this,e,t,n,e=>this.Va(e));return this.pa.push(r),r}ba(){this.Ta&&NR()}verifyOperationInProgress(){}async Sa(){for(var e;await(e=this.ma),e!==this.ma;);}Da(e){for(const t of this.pa)if(t.timerId===e)return!0;return!1}Ca(t){return this.Sa().then(()=>{this.pa.sort((e,t)=>e.targetTimeMs-t.targetTimeMs);for(const e of this.pa)if(e.skipDelay(),"all"!==t&&e.timerId===t)break;return this.Sa()})}Na(e){this.Aa.push(e)}Va(e){var t=this.pa.indexOf(e);this.pa.splice(t,1)}}function iF(e){return function(e){if("object"==typeof e&&null!==e){var t=e;for(const e of["next","error","complete"])if(e in t&&"function"==typeof t[e])return 1}}(e)}class sF{constructor(){this._progressObserver={},this._taskCompletionResolver=new DR,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)}}var oF,aF,cF,lF;class uF extends QL{constructor(e,t,n){super(e,t,n),this.type="firestore",this._queue=new rF,this._persistenceKey="name"in e?e.name:"[DEFAULT]"}_terminate(){return this._firestoreClient||dF(this),this._firestoreClient.terminate()}}function hF(e){return e._firestoreClient||dF(e),e._firestoreClient.verifyNotTerminated(),e._firestoreClient}function dF(e){var t,n,r,i,s,o=e._freezeSettings(),o=(n=e._databaseId,r=(null===(t=e._app)||void 0===t?void 0:t.options.appId)||"",i=e._persistenceKey,s=o,new UL(n,r,i,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,s.useFetchStreams));e._firestoreClient=new kL(e._authCredentials,e._appCheckCredentials,e._queue,o)}function pF(e,n,r){const i=new DR;return e.asyncQueue.enqueue(async()=>{try{await SL(e,r),await CL(e,n),i.resolve()}catch(e){if(!("FirebaseError"===(t=e).name?t.code===PR.FAILED_PRECONDITION||t.code===PR.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||(22===t.code||20===t.code||11===t.code)))throw e;console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+e),i.reject(e)}var t}).then(()=>i.promise)}function fF(e){return function(e){const t=new DR;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t){const n=e;TM(n.remoteStore)||kR("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{const e=await function(){const t=n.localStore;return t.persistence.runTransaction("Get highest unacknowledged batch id","readonly",e=>t.An.getHighestUnacknowledgedBatchId(e))}();if(-1===e)return void t.resolve();const r=n.jo.get(e)||[];r.push(t),n.jo.set(e,r)}catch(e){const n=DM(e,"Initialization of waitForPendingWrites() operation failed");t.reject(n)}}(await DL(e),t)),t.promise}(hF(e=zL(e,uF)))}function gF(e){return(n=hF(e=zL(e,uF))).asyncQueue.enqueue(async()=>{const e=await RL(n),t=await xL(n);return e.setNetworkEnabled(!0),function(){const e=t;return e.Gr.delete(0),fM(e)}()});var n}function mF(e){return(n=hF(e=zL(e,uF))).asyncQueue.enqueue(async()=>{const e=await RL(n),t=await xL(n);return e.setNetworkEnabled(!1),async function(){const e=t;e.Gr.add(0),await gM(e),e.Jr.set("Offline")}()});var n}function vF(t,e){return n=hF(t=zL(t,uF)),r=e,n.asyncQueue.enqueue(async()=>function(e,t){const n=e;return n.persistence.runTransaction("Get named query","readonly",e=>n.Ye.getNamedQuery(e,t))}(await PL(n),r)).then(e=>e?new JL(t,null,e.query):null);var n,r}function yF(e){if(e._initialized||e._terminated)throw new xR(PR.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.")}class _F{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new xR(PR.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new tP(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class wF{constructor(e){this._byteString=e}static fromBase64String(e){try{return new wF(rP.fromBase64String(e))}catch(e){throw new xR(PR.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new wF(rP.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 bF{constructor(e){this._methodName=e}}class TF{constructor(e,t){if(!isFinite(e)||e<-90||90<e)throw new xR(PR.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||180<t)throw new xR(PR.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 KR(this._lat,e._lat)||KR(this._long,e._long)}}const IF=/^__.*__$/;class EF{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return null!==this.fieldMask?new Dx(e,this.data,this.fieldMask,t,this.fieldTransforms):new xx(e,this.data,t,this.fieldTransforms)}}class kF{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new Dx(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function SF(e){switch(e){case 0:case 2:case 1:return 1;case 3:case 4:return;default:throw NR()}}class CF{constructor(e,t,n,r,i,s){this.settings=e,this.databaseId=t,this.k=n,this.ignoreUndefinedProperties=r,void 0===i&&this.ka(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get xa(){return this.settings.xa}$a(e){return new CF(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.k,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Oa(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.$a({path:n,Fa:!1});return r.Ma(e),r}La(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.$a({path:n,Fa:!1});return r.ka(),r}Ba(e){return this.$a({path:void 0,Fa:!0})}Ua(e){return HF(e,this.settings.methodName,this.settings.qa||!1,this.path,this.settings.Ka)}contains(t){return void 0!==this.fieldMask.find(e=>t.isPrefixOf(e))||void 0!==this.fieldTransforms.find(e=>t.isPrefixOf(e.field))}ka(){if(this.path)for(let e=0;e<this.path.length;e++)this.Ma(this.path.get(e))}Ma(e){if(0===e.length)throw this.Ua("Document fields must not be empty");if(SF(this.xa)&&IF.test(e))throw this.Ua('Document fields cannot begin and end with "__"')}}class AF{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.k=n||oM(e)}ja(e,t,n,r=!1){return new CF({xa:e,methodName:t,Ka:n,path:tP.emptyPath(),Fa:!1,qa:r},this.databaseId,this.k,this.ignoreUndefinedProperties)}}function NF(e){var t=e._freezeSettings(),n=oM(e._databaseId);return new AF(e._databaseId,!!t.ignoreUndefinedProperties,n)}function RF(e,t,n,r,i,s={}){const o=e.ja(s.merge||s.mergeFields?2:0,t,n,i);WF("Data must be an object, but it was:",o,r);var a=VF(r,o);let c,l;if(s.merge)c=new nP(o.fieldMask),l=o.fieldTransforms;else if(s.mergeFields){const e=[];for(const r of s.mergeFields){const i=KF(t,r,n);if(!o.contains(i))throw new xR(PR.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);GF(e,i)||e.push(i)}c=new nP(e),l=o.fieldTransforms.filter(e=>c.covers(e.field))}else c=null,l=o.fieldTransforms;return new EF(new CP(a),c,l)}class PF extends bF{_toFieldTransform(e){if(2!==e.xa)throw 1===e.xa?e.Ua(`${this._methodName}() can only appear at the top level of your update data`):e.Ua(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof PF}}function xF(e,t,n){return new CF({xa:3,Ka:t.settings.Ka,methodName:e._methodName,Fa:n},t.databaseId,t.k,t.ignoreUndefinedProperties)}class DF extends bF{_toFieldTransform(e){return new Ix(e.path,new gx)}isEqual(e){return e instanceof DF}}class OF extends bF{constructor(e,t){super(e),this.Qa=t}_toFieldTransform(e){const t=xF(this,e,!0),n=this.Qa.map(e=>qF(e,t)),r=new mx(n);return new Ix(e.path,r)}isEqual(e){return this===e}}class MF extends bF{constructor(e,t){super(e),this.Qa=t}_toFieldTransform(e){const t=xF(this,e,!0),n=this.Qa.map(e=>qF(e,t)),r=new yx(n);return new Ix(e.path,r)}isEqual(e){return this===e}}class LF extends bF{constructor(e,t){super(e),this.Wa=t}_toFieldTransform(e){var t=new wx(e.k,dx(e.k,this.Wa));return new Ix(e.path,t)}isEqual(e){return this===e}}function FF(e,i,s,t){const o=e.ja(1,i,s);WF("Data must be an object, but it was:",o,t);const a=[],c=CP.empty();YR(t,(e,t)=>{var n=zF(i,e,s);t=Kd(t);var r=o.La(n);if(t instanceof PF)a.push(n);else{const e=qF(t,r);null!=e&&(a.push(n),c.set(n,e))}});var n=new nP(a);return new kF(c,n,o.fieldTransforms)}function UF(e,t,n,r,i,s){const o=e.ja(1,t,n),a=[KF(t,r,n)],c=[i];if(s.length%2!=0)throw new xR(PR.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let p=0;p<s.length;p+=2)a.push(KF(t,s[p])),c.push(s[p+1]);const l=[],u=CP.empty();for(let f=a.length-1;0<=f;--f)if(!GF(l,a[f])){const t=a[f];var h=Kd(h=c[f]);const r=o.La(t);if(h instanceof PF)l.push(t);else{const e=qF(h,r);null!=e&&(l.push(t),u.set(t,e))}}var d=new nP(l);return new kF(u,d,o.fieldTransforms)}function jF(e,t,n,r=!1){return qF(n,e.ja(r?4:3,t))}function qF(s,e){if(BF(s=Kd(s)))return WF("Unsupported field value:",e,s),VF(s,e);if(s instanceof bF)return function(e,t){if(!SF(t.xa))throw t.Ua(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.Ua(`${e._methodName}() is not currently supported inside arrays`);var n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(s,e),null;if(void 0===s&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),s instanceof Array){if(e.settings.Fa&&4!==e.xa)throw e.Ua("Nested arrays are not supported");return function(t){const n=[];let r=0;for(const i of s){let e=qF(i,t.Ba(r));null==e&&(e={nullValue:"NULL_VALUE"}),n.push(e),r++}return{arrayValue:{values:n}}}(e)}return function(e,t){if(null===(e=Kd(s)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return dx(t.k,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){var n=HR.fromDate(e);return{timestampValue:hD(t.k,n)}}if(e instanceof HR){n=new HR(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:hD(t.k,n)}}if(e instanceof TF)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof wF)return{bytesValue:dD(t.k,e._byteString)};if(e instanceof YL){const r=t.databaseId,i=e.firestore._databaseId;if(!i.isEqual(r))throw t.Ua(`Document reference is for database ${i.projectId}/${i.database} but should be for database ${r.projectId}/${r.database}`);return{referenceValue:fD(e.firestore._databaseId||t.databaseId,e._key.path)}}throw t.Ua(`Unsupported field value: ${$L(e)}`)}(0,e)}function VF(e,r){const i={};return JR(e)?r.path&&0<r.path.length&&r.fieldMask.push(r.path):YR(e,(e,t)=>{var n=qF(t,r.Oa(e));null!=n&&(i[e]=n)}),{mapValue:{fields:i}}}function BF(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof HR||e instanceof TF||e instanceof wF||e instanceof YL||e instanceof bF)}function WF(e,t,n){if(!BF(n)||("object"!=typeof(i=n)||null===i||Object.getPrototypeOf(i)!==Object.prototype&&null!==Object.getPrototypeOf(i))){var r=$L(n);throw"an object"===r?t.Ua(e+" a custom object"):t.Ua(e+" "+r)}var i}function KF(e,t,n){if((t=Kd(t))instanceof _F)return t._internalPath;if("string"==typeof t)return zF(e,t);throw HF("Field path arguments must be of type string or FieldPath.",e,!1,void 0,n)}const $F=new RegExp("[~\\*/\\[\\]]");function zF(t,n,r){if(0<=n.search($F))throw HF(`Invalid field path (${n}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,r);try{return new _F(...n.split("."))._internalPath}catch(e){throw HF(`Invalid field path (${n}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,r)}}function HF(e,t,n,r,i){var s=r&&!r.isEmpty(),o=void 0!==i;let a=`Function ${t}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let c="";return(s||o)&&(c+=" (found",s&&(c+=` in field ${r}`),o&&(c+=` in document ${i}`),c+=")"),new xR(PR.INVALID_ARGUMENT,a+e+c)}function GF(e,t){return e.some(e=>e.isEqual(t))}class QF{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 YL(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){var e=new YF(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){var t=this._document.data.field(JF("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class YF extends QF{data(){return super.data()}}function JF(e,t){return"string"==typeof t?zF(e,t):(t instanceof _F?t:t._delegate)._internalPath}class XF{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class ZF extends QF{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){var t=new eU(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){var n=this._document.data.field(JF("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}}class eU extends ZF{data(e={}){return super.data(e)}}class tU{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new XF(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){const t=[];return this.forEach(e=>t.push(e)),t}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(t,n){this._snapshot.docs.forEach(e=>{t.call(n,new eU(this._firestore,this._userDataWriter,e.key,e,new XF(this._snapshot.mutatedKeys.has(e.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){var t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new xR(PR.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(s,t){if(s._snapshot.oldDocs.isEmpty()){let t=0;return s._snapshot.docChanges.map(e=>({type:"added",doc:new eU(s._firestore,s._userDataWriter,e.doc.key,e.doc,new XF(s._snapshot.mutatedKeys.has(e.doc.key),s._snapshot.fromCache),s.query.converter),oldIndex:-1,newIndex:t++}))}{let i=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(e=>t||3!==e.type).map(e=>{var t=new eU(s._firestore,s._userDataWriter,e.doc.key,e.doc,new XF(s._snapshot.mutatedKeys.has(e.doc.key),s._snapshot.fromCache),s.query.converter);let n=-1,r=-1;return 0!==e.type&&(n=i.indexOf(e.doc.key),i=i.delete(e.doc.key)),1!==e.type&&(i=i.add(e.doc),r=i.indexOf(e.doc.key)),{type:function(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return NR()}}(e.type),doc:t,oldIndex:n,newIndex:r}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function nU(e,t){return e instanceof ZF&&t instanceof ZF?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 tU&&t instanceof tU&&e._firestore===t._firestore&&nF(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)}function rU(e){if(XP(e)&&0===e.explicitOrderBy.length)throw new xR(PR.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class iU{}function sU(e,...t){for(const n of t)e=n._apply(e);return e}class oU extends iU{constructor(e,t,n){super(),this.Ga=e,this.za=t,this.Ha=n,this.type="where"}_apply(e){var t=NF(e.firestore),t=function(e,t,n,r,i,s,o){let a;if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new xR(PR.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on FieldPath.documentId().`);if("in"===s||"not-in"===s){pU(o,s);const t=[];for(const n of o)t.push(dU(r,e,n));a={arrayValue:{values:t}}}else a=dU(r,e,o)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||pU(o,s),a=jF(n,t,o,"in"===s||"not-in"===s);var c=OP.create(i,s,a);return function(e,t){if(t.V()){const r=ex(e);if(null!==r&&!r.isEqual(t.field))throw new xR(PR.INVALID_ARGUMENT,`Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${r.toString()}' and '${t.field.toString()}'`);var n=ZP(e);null!==n&&fU(0,t.field,n)}const r=function(e,t){for(const n of e.filters)if(0<=t.indexOf(n.op))return n.op;return null}(e,function(){switch(t.op){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}());if(null!==r)throw r===t.op?new xR(PR.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new xR(PR.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${r.toString()}' filters.`)}(e,c),c}(e._query,"where",t,e.firestore._databaseId,this.Ga,this.za,this.Ha);return new JL(e.firestore,e.converter,(e=e._query,t=e.filters.concat([t]),new GP(e.path,e.collectionGroup,e.explicitOrderBy.slice(),t,e.limit,e.limitType,e.startAt,e.endAt)))}}class aU extends iU{constructor(e,t){super(),this.Ga=e,this.Ja=t,this.type="orderBy"}_apply(e){var t=function(e,t,n){if(null!==e.startAt)throw new xR(PR.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new xR(PR.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var r,i=new $P(t,n);return n=i,null!==ZP(e=e)||null!==(r=ex(e))&&fU(0,r,n.field),i}(e._query,this.Ga,this.Ja);return new JL(e.firestore,e.converter,(e=e._query,t=e.explicitOrderBy.concat([t]),new GP(e.path,e.collectionGroup,t,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)))}}class cU extends iU{constructor(e,t,n){super(),this.type=e,this.Ya=t,this.Xa=n}_apply(e){return new JL(e.firestore,e.converter,ix(e._query,this.Ya,this.Xa))}}class lU extends iU{constructor(e,t,n){super(),this.type=e,this.Za=t,this.tc=n}_apply(e){var t,n=hU(e,this.type,this.Za,this.tc);return new JL(e.firestore,e.converter,(t=e._query,e=n,new GP(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)))}}class uU extends iU{constructor(e,t,n){super(),this.type=e,this.Za=t,this.tc=n}_apply(e){var t,n=hU(e,this.type,this.Za,this.tc);return new JL(e.firestore,e.converter,(t=e._query,e=n,new GP(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)))}}function hU(e,t,n,r){if(n[0]=Kd(n[0]),n[0]instanceof QF)return function(e,t,n,r,i){if(!r)throw new xR(PR.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);const s=[];for(const n of nx(e))if(n.field.isKeyField())s.push(wP(t,r.key));else{const e=r.data.field(n.field);if(cP(e))throw new xR(PR.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){const e=n.field.canonicalString();throw new xR(PR.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 WP(s,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);var i=NF(e.firestore);return function(e,t,n,r,i,s){const o=e.explicitOrderBy;if(i.length>o.length)throw new xR(PR.INVALID_ARGUMENT,`Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const a=[];for(let c=0;c<i.length;c++){const l=i[c];if(o[c].field.isKeyField()){if("string"!=typeof l)throw new xR(PR.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof l}`);if(!tx(e)&&-1!==l.indexOf("/"))throw new xR(PR.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to ${r}() must be a plain document ID, but '${l}' contains a slash.`);const n=e.path.child(ZR.fromString(l));if(!pP.isDocumentKey(n))throw new xR(PR.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by FieldPath.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.`);const i=new pP(n);a.push(wP(t,i))}else{const e=jF(n,r,l);a.push(e)}}return new WP(a,s)}(e._query,e.firestore._databaseId,i,t,n,r)}function dU(e,t,n){if("string"==typeof(n=Kd(n))){if(""===n)throw new xR(PR.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!tx(t)&&-1!==n.indexOf("/"))throw new xR(PR.INVALID_ARGUMENT,`Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);var r=t.path.child(ZR.fromString(n));if(!pP.isDocumentKey(r))throw new xR(PR.INVALID_ARGUMENT,`Invalid query. When querying a collection group by FieldPath.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 wP(e,new pP(r))}if(n instanceof YL)return wP(e,n._key);throw new xR(PR.INVALID_ARGUMENT,`Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: ${$L(n)}.`)}function pU(e,t){if(!Array.isArray(e)||0===e.length)throw new xR(PR.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`);if(10<e.length)throw new xR(PR.INVALID_ARGUMENT,`Invalid Query. '${t.toString()}' filters support a maximum of 10 elements in the value array.`)}function fU(e,t,n){if(!n.isEqual(t))throw new xR(PR.INVALID_ARGUMENT,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${t.toString()}' and so you must also use '${t.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}class gU{convertValue(e,t="none"){switch(fP(e)){case 0:return null;case 1:return e.booleanValue;case 2:return oP(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(aP(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 10:return this.convertObject(e.mapValue,t);default:throw NR()}}convertObject(e,n){const r={};return YR(e.fields,(e,t)=>{r[e]=this.convertValue(t,n)}),r}convertGeoPoint(e){return new TF(oP(e.latitude),oP(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":var n=function e(t){var n=t.mapValue.fields.__previous_value__;return cP(n)?e(n):n}(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(lP(e));default:return null}}convertTimestamp(e){var t=sP(e);return new HR(t.seconds,t.nanos)}convertDocumentKey(e,t){const n=ZR.fromString(e);RR(MD(n));const r=new jL(n.get(1),n.get(3)),i=new pP(n.popFirst(5));return r.isEqual(t)||SR(`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 mU(e,t,n){return e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t}class vU extends gU{constructor(e){super(),this.firestore=e}convertBytes(e){return new wF(e)}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return new YL(this.firestore,null,t)}}class yU{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=NF(e)}set(e,t,n){this._verifyNotCommitted();const r=_U(e,this._firestore),i=mU(r.converter,t,n),s=RF(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(s.toMutation(r._key,kx.none())),this}update(e,t,n,...r){this._verifyNotCommitted();var i=_U(e,this._firestore);let s;return s="string"==typeof(t=Kd(t))||t instanceof _F?UF(this._dataReader,"WriteBatch.update",i._key,t,n,r):FF(this._dataReader,"WriteBatch.update",i._key,t),this._mutations.push(s.toMutation(i._key,kx.exists(!0))),this}delete(e){this._verifyNotCommitted();var t=_U(e,this._firestore);return this._mutations=this._mutations.concat(new Fx(t._key,kx.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,0<this._mutations.length?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new xR(PR.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function _U(e,t){if((e=Kd(e)).firestore!==t)throw new xR(PR.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}class wU extends gU{constructor(e){super(),this.firestore=e}convertBytes(e){return new wF(e)}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return new YL(this.firestore,null,t)}}function bU(t){t=zL(t,YL);const n=zL(t.firestore,uF),e=hF(n),r=new wU(n);return function(e,t){const n=new DR;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t,n){try{const i=await function(t){const n=e;return n.persistence.runTransaction("read document","readonly",e=>n.Wn.Rn(e,t))}(t);i.isFoundDocument()?n.resolve(i):i.isNoDocument()?n.resolve(null):n.reject(new xR(PR.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(e){var r=DM(e,`Failed to get document '${t} from cache`);n.reject(r)}}(await PL(e),t,n)),n.promise}(e,t._key).then(e=>new ZF(n,r,t._key,e,new XF(null!==e&&e.hasLocalMutations,!0),t.converter))}function TU(t){t=zL(t,JL);const n=zL(t.firestore,uF),e=hF(n),r=new wU(n);return function(e,t){const n=new DR;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t,n){try{const i=await R1(e,t,!0),s=new QM(t,i.zn),o=s.Po(i.documents),a=s.applyChanges(o,!1);n.resolve(a.snapshot)}catch(e){var r=DM(e,`Failed to execute query '${t} against cache`);n.reject(r)}}(await PL(e),t,n)),n.promise}(e,t._query).then(e=>new tU(n,r,t,e))}function IU(e,t,n){e=zL(e,YL);var r=zL(e.firestore,uF),i=mU(e.converter,t,n);return CU(r,[RF(NF(r),"setDoc",e._key,i,null!==e.converter,n).toMutation(e._key,kx.none())])}function EU(e,t,n,...r){e=zL(e,YL);var i=zL(e.firestore,uF),s=NF(i);let o;return o="string"==typeof(t=Kd(t))||t instanceof _F?UF(s,"updateDoc",e._key,t,n,r):FF(s,"updateDoc",e._key,t),CU(i,[o.toMutation(e._key,kx.exists(!0))])}function kU(t,...n){var e;t=Kd(t);let r={includeMetadataChanges:!1},i=0;"object"!=typeof n[i]||iF(n[i])||(r=n[i],i++);var s={includeMetadataChanges:r.includeMetadataChanges};if(iF(n[i])){const t=n[i];n[i]=null===(e=t.next)||void 0===e?void 0:e.bind(t),n[i+1]=null===(e=t.error)||void 0===e?void 0:e.bind(t),n[i+2]=null===(e=t.complete)||void 0===e?void 0:e.bind(t)}let o,a,c;if(t instanceof YL)a=zL(t.firestore,uF),c=YP(t._key.path),o={next:e=>{n[i]&&n[i](AU(a,t,e))},error:n[i+1],complete:n[i+2]};else{const l=zL(t,JL);a=zL(l.firestore,uF),c=l._query;const u=new wU(a);o={next:e=>{n[i]&&n[i](new tU(a,u,l,e))},error:n[i+1],complete:n[i+2]},rU(t._query)}return function(e,t,n,r){const i=new bL(r),s=new BM(t,i,n);return e.asyncQueue.enqueueAndForget(async()=>jM(await OL(e),s)),()=>{i.na(),e.asyncQueue.enqueueAndForget(async()=>qM(await OL(e),s))}}(hF(a),c,s,o)}function SU(e,t){return function(e,t){const n=new bL(t);return e.asyncQueue.enqueueAndForget(async()=>function(e,t){e.io.add(t),t.next()}(await OL(e),n)),()=>{n.na(),e.asyncQueue.enqueueAndForget(async()=>function(e,t){e.io.delete(t)}(await OL(e),n))}}(hF(e=zL(e,uF)),iF(t)?t:{next:t})}function CU(e,t){return function(e,t){const n=new DR;return e.asyncQueue.enqueueAndForget(async()=>eL(await DL(e),t,n)),n.promise}(hF(e),t)}function AU(e,t,n){var r=n.docs.get(t._key),i=new wU(e);return new ZF(e,i,t._key,r,new XF(n.hasPendingWrites,n.fromCache),t.converter)}class NU extends class{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=NF(e)}get(e){const n=_U(e,this._firestore),r=new vU(this._firestore);return this._transaction.lookup([n._key]).then(e=>{if(!e||1!==e.length)return NR();const t=e[0];if(t.isFoundDocument())return new QF(this._firestore,r,t.key,t,n.converter);if(t.isNoDocument())return new QF(this._firestore,r,n._key,null,n.converter);throw NR()})}set(e,t,n){var r=_U(e,this._firestore),i=mU(r.converter,t,n),i=RF(this._dataReader,"Transaction.set",r._key,i,null!==r.converter,n);return this._transaction.set(r._key,i),this}update(e,t,n,...r){var i=_U(e,this._firestore),s="string"==typeof(t=Kd(t))||t instanceof _F?UF(this._dataReader,"Transaction.update",i._key,t,n,r):FF(this._dataReader,"Transaction.update",i._key,t);return this._transaction.update(i._key,s),this}delete(e){var t=_U(e,this._firestore);return this._transaction.delete(t._key),this}}{constructor(e,t){super(e,t),this._firestore=e}get(e){const t=_U(e,this._firestore),n=new wU(this._firestore);return super.get(e).then(e=>new ZF(this._firestore,n,t._key,e._document,new XF(!1,!1),t.converter))}}function RU(t,n){return function(t,n){const r=new DR;return t.asyncQueue.enqueueAndForget(async()=>{var e=await NL(t).then(e=>e.datastore);new EL(t.asyncQueue,e,n,r).run()}),r.promise}(hF(t=zL(t,uF)),e=>n(new NU(t,e)))}z=gp,TR=z,hp(new $d("firestore",(e,{options:t})=>{const n=e.getProvider("app").getImmediate(),r=new uF(n,new FR(e.getProvider("auth-internal")),new VR(e.getProvider("app-check-internal")));return t=Object.assign({useFetchStreams:!0},t),r._setSettings(t),r},"PUBLIC")),_p(wR,"3.4.2",void 0),_p(wR,"3.4.2","esm2017");function PU(e,t){if(void 0===t)return{merge:!1};if(void 0!==t.mergeFields&&void 0!==t.merge)throw new xR("invalid-argument",`Invalid options passed to function ${e}(): You cannot `+'specify both "merge" and "mergeFields".');return t}function xU(){if("undefined"==typeof Uint8Array)throw new xR("unimplemented","Uint8Arrays are not available in this environment.")}function DU(){if("undefined"==typeof atob)throw new xR("unimplemented","Blobs are unavailable in Firestore in this environment.")}class OU{constructor(e){this._delegate=e}static fromBase64String(e){return DU(),new OU(wF.fromBase64String(e))}static fromUint8Array(e){return xU(),new OU(wF.fromUint8Array(e))}toBase64(){return DU(),this._delegate.toBase64()}toUint8Array(){return xU(),this._delegate.toUint8Array()}isEqual(e){return this._delegate.isEqual(e._delegate)}toString(){return"Blob(base64: "+this.toBase64()+")"}}function MU(e){return function(e,t){if("object"!=typeof e||null===e)return;var n=e;for(const r of t)if(r in n&&"function"==typeof n[r])return 1;return}(e,["next","error","complete"])}class LU{enableIndexedDbPersistence(e,t){return function(e,t){yF(e=zL(e,uF));var n=hF(e),r=e._freezeSettings(),i=new _L;return pF(n,i,new vL(i,r.cacheSizeBytes,null==t?void 0:t.forceOwnership))}(e._delegate,{forceOwnership:t})}enableMultiTabIndexedDbPersistence(e){return function(e){yF(e=zL(e,uF));var t=hF(e),n=e._freezeSettings(),r=new _L;return pF(t,r,new yL(r,n.cacheSizeBytes))}(e._delegate)}clearIndexedDbPersistence(e){return function(e){if(e._initialized&&!e._terminated)throw new xR(PR.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const t=new DR;return e._queue.enqueueAndForgetEvenWhileRestricted(async()=>{try{await async function(e){if(!oO.Pt())return Promise.resolve();var t=e+"main";await oO.delete(t)}(v1(e._databaseId,e._persistenceKey)),t.resolve()}catch(e){t.reject(e)}}),t.promise}(e._delegate)}}class FU{constructor(e,t,n){this._delegate=t,this._persistenceProvider=n,this.INTERNAL={delete:()=>this.terminate()},e instanceof jL||(this._appCompat=e)}get _databaseId(){return this._delegate._databaseId}settings(e){var t=this._delegate._getSettings();e.merge||t.host===e.host||CR("You are overriding the original host. If you did not intend to override your settings, use {merge: true}."),e.merge&&delete(e=Object.assign(Object.assign({},t),e)).merge,this._delegate._setSettings(e)}useEmulator(e,t,n={}){!function(n,e,t,r={}){var i;const s=(n=zL(n,QL))._getSettings();if("firestore.googleapis.com"!==s.host&&s.host!==e&&CR("Host has been set in both settings() and useEmulator(), emulator host will be used"),n._setSettings(Object.assign(Object.assign({},s),{host:`${e}:${t}`,ssl:!1})),r.mockUserToken){let e,t;if("string"==typeof r.mockUserToken)e=r.mockUserToken,t=bR.MOCK_USER;else{e=id(r.mockUserToken,null===(i=n._app)||void 0===i?void 0:i.options.projectId);const s=r.mockUserToken.sub||r.mockUserToken.user_id;if(!s)throw new xR(PR.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");t=new bR(s)}n._authCredentials=new LR(new OR(e,t))}}(this._delegate,e,t,n)}enableNetwork(){return gF(this._delegate)}disableNetwork(){return mF(this._delegate)}enablePersistence(e){let t=!1,n=!1;return e&&(t=!!e.synchronizeTabs,n=!!e.experimentalForceOwningTab,BL("synchronizeTabs",t,"experimentalForceOwningTab",n)),t?this._persistenceProvider.enableMultiTabIndexedDbPersistence(this):this._persistenceProvider.enableIndexedDbPersistence(this,n)}clearPersistence(){return this._persistenceProvider.clearIndexedDbPersistence(this)}terminate(){return this._appCompat&&(this._appCompat._removeServiceInstance("firestore-compat"),this._appCompat._removeServiceInstance("firestore")),this._delegate._delete()}waitForPendingWrites(){return fF(this._delegate)}onSnapshotsInSync(e){return SU(this._delegate,e)}get app(){if(!this._appCompat)throw new xR("failed-precondition","Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._appCompat}collection(e){try{return new JU(this,ZL(this._delegate,e))}catch(e){throw WU(e,"collection()","Firestore.collection()")}}doc(e){try{return new BU(this,eF(this._delegate,e))}catch(e){throw WU(e,"doc()","Firestore.doc()")}}collectionGroup(e){try{return new GU(this,function(e,t){if(e=zL(e,QL),VL("collectionGroup","collection id",t),0<=t.indexOf("/"))throw new xR(PR.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new JL(e,null,(t=t,new GP(ZR.emptyPath(),t)))}(this._delegate,e))}catch(e){throw WU(e,"collectionGroup()","Firestore.collectionGroup()")}}runTransaction(t){return RU(this._delegate,e=>t(new jU(this,e)))}batch(){return hF(this._delegate),new qU(new yU(this._delegate,e=>CU(this._delegate,e)))}loadBundle(e){return t=this._delegate,e=e,n=hF(t=zL(t,uF)),r=new sF,FL(n,t._databaseId,e,r),r;var t,n,r}namedQuery(e){return vF(this._delegate,e).then(e=>e?new GU(this,e):null)}}class UU extends gU{constructor(e){super(),this.firestore=e}convertBytes(e){return new OU(new wF(e))}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return BU.forKey(t,this.firestore,null)}}class jU{constructor(e,t){this._firestore=e,this._delegate=t,this._userDataWriter=new UU(e)}get(e){const t=XU(e);return this._delegate.get(t).then(e=>new zU(this._firestore,new ZF(this._firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,t.converter)))}set(e,t,n){var r=XU(e);return n?(PU("Transaction.set",n),this._delegate.set(r,t,n)):this._delegate.set(r,t),this}update(e,t,n,...r){var i=XU(e);return 2===arguments.length?this._delegate.update(i,t):this._delegate.update(i,t,n,...r),this}delete(e){var t=XU(e);return this._delegate.delete(t),this}}class qU{constructor(e){this._delegate=e}set(e,t,n){var r=XU(e);return n?(PU("WriteBatch.set",n),this._delegate.set(r,t,n)):this._delegate.set(r,t),this}update(e,t,n,...r){var i=XU(e);return 2===arguments.length?this._delegate.update(i,t):this._delegate.update(i,t,n,...r),this}delete(e){var t=XU(e);return this._delegate.delete(t),this}commit(){return this._delegate.commit()}}class VU{constructor(e,t,n){this._firestore=e,this._userDataWriter=t,this._delegate=n}fromFirestore(e,t){var n=new eU(this._firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,null);return this._delegate.fromFirestore(new HU(this._firestore,n),null!=t?t:{})}toFirestore(e,t){return t?this._delegate.toFirestore(e,t):this._delegate.toFirestore(e)}static getInstance(e,t){const n=VU.INSTANCES;let r=n.get(e);r||(r=new WeakMap,n.set(e,r));let i=r.get(t);return i||(i=new VU(e,new UU(e),t),r.set(t,i)),i}}VU.INSTANCES=new WeakMap;class BU{constructor(e,t){this.firestore=e,this._delegate=t,this._userDataWriter=new UU(e)}static forPath(e,t,n){if(e.length%2!=0)throw new xR("invalid-argument","Invalid document reference. Document references must have an even number of segments, but "+`${e.canonicalString()} has ${e.length}`);return new BU(t,new YL(t._delegate,n,new pP(e)))}static forKey(e,t,n){return new BU(t,new YL(t._delegate,n,e))}get id(){return this._delegate.id}get parent(){return new JU(this.firestore,this._delegate.parent)}get path(){return this._delegate.path}collection(e){try{return new JU(this.firestore,ZL(this._delegate,e))}catch(e){throw WU(e,"collection()","DocumentReference.collection()")}}isEqual(e){return(e=Kd(e))instanceof YL&&tF(this._delegate,e)}set(e,t){t=PU("DocumentReference.set",t);try{return t?IU(this._delegate,e,t):IU(this._delegate,e)}catch(e){throw WU(e,"setDoc()","DocumentReference.set()")}}update(e,t,...n){try{return 1===arguments.length?EU(this._delegate,e):EU(this._delegate,e,t,...n)}catch(e){throw WU(e,"updateDoc()","DocumentReference.update()")}}delete(){return CU(zL((e=this._delegate).firestore,uF),[new Fx(e._key,kx.none())]);var e}onSnapshot(...e){var t=KU(e),n=$U(e,e=>new zU(this.firestore,new ZF(this.firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,this._delegate.converter)));return kU(this._delegate,t,n)}get(e){let t;return t=("cache"===(null==e?void 0:e.source)?bU:"server"===(null==e?void 0:e.source)?function(t){t=zL(t,YL);const n=zL(t.firestore,uF);return ML(hF(n),t._key,{source:"server"}).then(e=>AU(n,t,e))}:function(t){t=zL(t,YL);const n=zL(t.firestore,uF);return ML(hF(n),t._key).then(e=>AU(n,t,e))})(this._delegate),t.then(e=>new zU(this.firestore,new ZF(this.firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,this._delegate.converter)))}withConverter(e){return new BU(this.firestore,e?this._delegate.withConverter(VU.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}function WU(e,t,n){return e.message=e.message.replace(t,n),e}function KU(e){for(const t of e)if("object"==typeof t&&!MU(t))return t;return{}}function $U(e,t){var n;let r;return r=MU(e[0])?e[0]:MU(e[1])?e[1]:"function"==typeof e[0]?{next:e[0],error:e[1],complete:e[2]}:{next:e[1],error:e[2],complete:e[3]},{next:e=>{r.next&&r.next(t(e))},error:null===(n=r.error)||void 0===n?void 0:n.bind(r),complete:null===(n=r.complete)||void 0===n?void 0:n.bind(r)}}class zU{constructor(e,t){this._firestore=e,this._delegate=t}get ref(){return new BU(this._firestore,this._delegate.ref)}get id(){return this._delegate.id}get metadata(){return this._delegate.metadata}get exists(){return this._delegate.exists()}data(e){return this._delegate.data(e)}get(e,t){return this._delegate.get(e,t)}isEqual(e){return nU(this._delegate,e._delegate)}}class HU extends zU{data(e){var t=this._delegate.data(e);return void 0!==t||NR(),t}}class GU{constructor(e,t){this.firestore=e,this._delegate=t,this._userDataWriter=new UU(e)}where(e,t,n){try{return new GU(this.firestore,sU(this._delegate,(r=n,i=t,s=JF("where",e),new oU(s,i,r))))}catch(e){throw WU(e,/(orderBy|where)\(\)/,"Query.$1()")}var r,i,s}orderBy(e,t){try{return new GU(this.firestore,sU(this._delegate,([n,r="asc"]=[e,t],i=r,s=JF("orderBy",n),new aU(s,i))))}catch(e){throw WU(e,/(orderBy|where)\(\)/,"Query.$1()")}var n,r,i,s}limit(e){try{return new GU(this.firestore,sU(this._delegate,(HL("limit",t=e),new cU("limit",t,"F"))))}catch(e){throw WU(e,"limit()","Query.limit()")}var t}limitToLast(e){try{return new GU(this.firestore,sU(this._delegate,(HL("limitToLast",t=e),new cU("limitToLast",t,"L"))))}catch(e){throw WU(e,"limitToLast()","Query.limitToLast()")}var t}startAt(...e){try{return new GU(this.firestore,sU(this._delegate,function(...e){return new lU("startAt",e,!0)}(...e)))}catch(e){throw WU(e,"startAt()","Query.startAt()")}}startAfter(...e){try{return new GU(this.firestore,sU(this._delegate,function(...e){return new lU("startAfter",e,!1)}(...e)))}catch(e){throw WU(e,"startAfter()","Query.startAfter()")}}endBefore(...e){try{return new GU(this.firestore,sU(this._delegate,function(...e){return new uU("endBefore",e,!0)}(...e)))}catch(e){throw WU(e,"endBefore()","Query.endBefore()")}}endAt(...e){try{return new GU(this.firestore,sU(this._delegate,function(...e){return new uU("endAt",e,!1)}(...e)))}catch(e){throw WU(e,"endAt()","Query.endAt()")}}isEqual(e){return nF(this._delegate,e._delegate)}get(e){let t;return t=("cache"===(null==e?void 0:e.source)?TU:"server"===(null==e?void 0:e.source)?function(t){t=zL(t,JL);const n=zL(t.firestore,uF),e=hF(n),r=new wU(n);return LL(e,t._query,{source:"server"}).then(e=>new tU(n,r,t,e))}:function(t){t=zL(t,JL);const n=zL(t.firestore,uF),e=hF(n),r=new wU(n);return rU(t._query),LL(e,t._query).then(e=>new tU(n,r,t,e))})(this._delegate),t.then(e=>new YU(this.firestore,new tU(this.firestore._delegate,this._userDataWriter,this._delegate,e._snapshot)))}onSnapshot(...e){var t=KU(e),n=$U(e,e=>new YU(this.firestore,new tU(this.firestore._delegate,this._userDataWriter,this._delegate,e._snapshot)));return kU(this._delegate,t,n)}withConverter(e){return new GU(this.firestore,e?this._delegate.withConverter(VU.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}class QU{constructor(e,t){this._firestore=e,this._delegate=t}get type(){return this._delegate.type}get doc(){return new HU(this._firestore,this._delegate.doc)}get oldIndex(){return this._delegate.oldIndex}get newIndex(){return this._delegate.newIndex}}class YU{constructor(e,t){this._firestore=e,this._delegate=t}get query(){return new GU(this._firestore,this._delegate.query)}get metadata(){return this._delegate.metadata}get size(){return this._delegate.size}get empty(){return this._delegate.empty}get docs(){return this._delegate.docs.map(e=>new HU(this._firestore,e))}docChanges(e){return this._delegate.docChanges(e).map(e=>new QU(this._firestore,e))}forEach(t,n){this._delegate.forEach(e=>{t.call(n,new HU(this._firestore,e))})}isEqual(e){return nU(this._delegate,e._delegate)}}class JU extends GU{constructor(e,t){super(e,t),this.firestore=e,this._delegate=t}get id(){return this._delegate.id}get path(){return this._delegate.path}get parent(){var e=this._delegate.parent;return e?new BU(this.firestore,e):null}doc(e){try{return void 0===e?new BU(this.firestore,eF(this._delegate)):new BU(this.firestore,eF(this._delegate,e))}catch(e){throw WU(e,"doc()","CollectionReference.doc()")}}add(e){return function(e,t){const n=zL(e.firestore,uF),r=eF(e),i=mU(e.converter,t);return CU(n,[RF(NF(e.firestore),"addDoc",r._key,i,null!==e.converter,{}).toMutation(r._key,kx.exists(!1))]).then(()=>r)}(this._delegate,e).then(e=>new BU(this.firestore,e))}isEqual(e){return tF(this._delegate,e._delegate)}withConverter(e){return new JU(this.firestore,e?this._delegate.withConverter(VU.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}function XU(e){return zL(e,YL)}const ZU={Firestore:FU,GeoPoint:TF,Timestamp:HR,Blob:OU,Transaction:jU,WriteBatch:qU,DocumentReference:BU,DocumentSnapshot:zU,Query:GU,QueryDocumentSnapshot:HU,QuerySnapshot:YU,CollectionReference:JU,FieldPath:class JW{constructor(...e){this._delegate=new _F(...e)}static documentId(){return new JW(tP.keyField().canonicalString())}isEqual(e){return(e=Kd(e))instanceof _F&&this._delegate._internalPath.isEqual(e._internalPath)}},FieldValue:class XW{constructor(e){this._delegate=e}static serverTimestamp(){const e=new DF("serverTimestamp");return e._methodName="FieldValue.serverTimestamp",new XW(e)}static delete(){const e=new PF("deleteField");return e._methodName="FieldValue.delete",new XW(e)}static arrayUnion(...e){const t=function(...e){return new OF("arrayUnion",e)}(...e);return t._methodName="FieldValue.arrayUnion",new XW(t)}static arrayRemove(...e){const t=function(...e){return new MF("arrayRemove",e)}(...e);return t._methodName="FieldValue.arrayRemove",new XW(t)}static increment(e){const t=new LF("increment",e);return t._methodName="FieldValue.increment",new XW(t)}isEqual(e){return this._delegate.isEqual(e._delegate)}},setLogLevel:function(e){e=e,IR.setLogLevel(e)},CACHE_SIZE_UNLIMITED:-1};oF=Cp,aF=(e,t)=>new FU(e,t,new LU),oF.INTERNAL.registerComponent(new $d("firestore-compat",e=>{var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("firestore").getImmediate();return aF(t,n)},"PUBLIC").setServiceProps(Object.assign({},ZU))),oF.registerVersion("@firebase/firestore-compat","0.1.11");function ej(e,t){const n={};for(const r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r]));return n}function tj(e){if(null==e)return e;if(e["@type"])switch(e["@type"]){case"type.googleapis.com/google.protobuf.Int64Value":case"type.googleapis.com/google.protobuf.UInt64Value":var t=Number(e.value);if(isNaN(t))throw new Error("Data cannot be decoded from JSON: "+e);return t;default:throw new Error("Data cannot be decoded from JSON: "+e)}return Array.isArray(e)?e.map(e=>tj(e)):"function"==typeof e||"object"==typeof e?ej(e,e=>tj(e)):e}const nj="functions",rj={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class ij extends gd{constructor(e,t,n){super(`${nj}/${e}`,t||""),this.details=n}}function sj(e,t){let n=function(e){if(200<=e&&e<300)return"ok";switch(e){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}(e),r=n,i=void 0;try{var s=t&&t.error;if(s){const e=s.status;if("string"==typeof e){if(!rj[e])return new ij("internal","internal");n=rj[e],r=e}var o=s.message;"string"==typeof o&&(r=o),i=s.details,void 0!==i&&(i=tj(i))}}catch(e){}return"ok"===n?null:new ij(n,r,i)}class oj{constructor(e,t,n){this.auth=null,this.messaging=null,this.appCheck=null,this.auth=e.getImmediate({optional:!0}),this.messaging=t.getImmediate({optional:!0}),this.auth||e.get().then(e=>this.auth=e,()=>{}),this.messaging||t.get().then(e=>this.messaging=e,()=>{}),this.appCheck||n.get().then(e=>this.appCheck=e,()=>{})}async getAuthToken(){if(this.auth)try{var e=await this.auth.getToken();return null==e?void 0:e.accessToken}catch(e){return}}async getMessagingToken(){if(this.messaging&&"Notification"in self&&"granted"===Notification.permission)try{return this.messaging.getToken()}catch(e){return}}async getAppCheckToken(){if(this.appCheck){var e=await this.appCheck.getToken();return e.error?null:e.token}return null}async getContext(){return{authToken:await this.getAuthToken(),messagingToken:await this.getMessagingToken(),appCheckToken:await this.getAppCheckToken()}}}const aj="us-central1";class cj{constructor(e,t,n,r,i=aj,s){this.app=e,this.fetchImpl=s,this.emulatorOrigin=null,this.contextProvider=new oj(t,n,r),this.cancelAllRequests=new Promise(e=>{this.deleteService=()=>Promise.resolve(e())});try{var o=new URL(i);this.customDomain=o.origin,this.region=aj}catch(e){this.customDomain=null,this.region=i}}_delete(){return this.deleteService()}_url(e){var t=this.app.options.projectId;return null===this.emulatorOrigin?null!==this.customDomain?`${this.customDomain}/${e}`:`https://${this.region}-${t}.cloudfunctions.net/${e}`:`${this.emulatorOrigin}/${t}/${this.region}/${e}`}}function lj(t,n,r){return e=>async function(e,t,n,r){const i=e._url(t),s={data:n=function t(e){if(null==e)return null;if("number"==typeof(e=e instanceof Number?e.valueOf():e)&&isFinite(e))return e;if(!0===e||!1===e)return e;if("[object String]"===Object.prototype.toString.call(e))return e;if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(e=>t(e));if("function"==typeof e||"object"==typeof e)return ej(e,e=>t(e));throw new Error("Data cannot be encoded in JSON: "+e)}(n)},o={},a=await e.contextProvider.getContext();a.authToken&&(o.Authorization="Bearer "+a.authToken);a.messagingToken&&(o["Firebase-Instance-ID-Token"]=a.messagingToken);null!==a.appCheckToken&&(o["X-Firebase-AppCheck"]=a.appCheckToken);const c=r.timeout||7e4,l=function(n){let r=null;return{promise:new Promise((e,t)=>{r=setTimeout(()=>{t(new ij("deadline-exceeded","deadline-exceeded"))},n)}),cancel:()=>{r&&clearTimeout(r)}}}(c),u=await Promise.race([async function(e,t,n,r){n["Content-Type"]="application/json";let i;try{i=await r(e,{method:"POST",body:JSON.stringify(t),headers:n})}catch(e){return{status:0,json:null}}let s=null;try{s=await i.json()}catch(e){}return{status:i.status,json:s}}(i,s,o,e.fetchImpl),l.promise,e.cancelAllRequests]);if(l.cancel(),!u)throw new ij("cancelled","Firebase Functions instance was deleted.");var h=sj(u.status,u.json);if(h)throw h;if(!u.json)throw new ij("internal","Response is not valid JSON object.");let d=u.json.data;void 0===d&&(d=u.json.result);if(void 0===d)throw new ij("internal","Response is missing data field.");h=tj(d);return{data:h}}(t,n,e,r||{})}const uj="@firebase/functions";function hj(e,t,n){Kd(e).emulatorOrigin=`http://${t}:${n}`}cF=fetch.bind(self),hp(new $d(nj,(e,{instanceIdentifier:t})=>{var n=e.getProvider("app").getImmediate(),r=e.getProvider("auth-internal"),i=e.getProvider("messaging-internal"),s=e.getProvider("app-check-internal");return new cj(n,r,i,s,t,cF)},"PUBLIC").setMultipleInstances(!0)),_p(uj,"0.7.7",lF),_p(uj,"0.7.7","esm2017");var dj,pj,fj,gj;class mj{constructor(e,t){this.app=e,this._delegate=t,this._region=this._delegate.region,this._customDomain=this._delegate.customDomain}httpsCallable(e,t){return lj(Kd(this._delegate),e,t)}useFunctionsEmulator(e){var t=e.match("[a-zA-Z]+://([a-zA-Z0-9.-]+)(?::([0-9]+))?");if(null==t)throw new gd("functions","No origin provided to useFunctionsEmulator()");if(null==t[2])throw new gd("functions","Port missing in origin provided to useFunctionsEmulator()");return hj(this._delegate,t[1],Number(t[2]))}useEmulator(e,t){return hj(this._delegate,e,t)}}const vj="us-central1",yj=(e,{instanceIdentifier:t})=>{var n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("functions").getImmediate({identifier:null!=t?t:vj});return new mj(n,r)};dj={Functions:mj},Cp.INTERNAL.registerComponent(new $d("functions-compat",yj,"PUBLIC").setServiceProps(dj).setMultipleInstances(!0)),Cp.registerVersion("@firebase/functions-compat","0.1.8");const _j="/firebase-messaging-sw.js",wj="/firebase-cloud-messaging-push-scope",bj="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",Tj="https://fcmregistrations.googleapis.com/v1",Ij="google.c.a.c_id",Ej="google.c.a.e";function kj(e){var t=new Uint8Array(e);const n=btoa(String.fromCharCode(...t));return n.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(yt=DB=DB||{})[yt.DATA_MESSAGE=1]="DATA_MESSAGE",yt[yt.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION",(yt=pj=pj||{}).PUSH_RECEIVED="push-received",yt.NOTIFICATION_CLICKED="notification-clicked";const Sj="fcm_token_details_db",Cj="fcm_token_object_Store";async function Aj(s){if("databases"in indexedDB){const t=await indexedDB.databases(),n=t.map(e=>e.name);if(!n.includes(Sj))return null}let o=null;const e=await qp(Sj,5,async e=>{var t;if(!(e.oldVersion<2)&&e.objectStoreNames.contains(Cj)){const i=e.transaction.objectStore(Cj);var n,r=await i.index("fcmSenderId").get(s);await i.clear(),r&&(2===e.oldVersion?(n=r).auth&&n.p256dh&&n.endpoint&&(o={token:n.fcmToken,createTime:null!==(t=n.createTime)&&void 0!==t?t:Date.now(),subscriptionOptions:{auth:n.auth,p256dh:n.p256dh,endpoint:n.endpoint,swScope:n.swScope,vapidKey:"string"==typeof n.vapidKey?n.vapidKey:kj(n.vapidKey)}}):3===e.oldVersion?(n=r,o={token:n.fcmToken,createTime:n.createTime,subscriptionOptions:{auth:kj(n.auth),p256dh:kj(n.p256dh),endpoint:n.endpoint,swScope:n.swScope,vapidKey:kj(n.vapidKey)}}):4===e.oldVersion&&(r=r,o={token:r.fcmToken,createTime:r.createTime,subscriptionOptions:{auth:kj(r.auth),p256dh:kj(r.p256dh),endpoint:r.endpoint,swScope:r.swScope,vapidKey:kj(r.vapidKey)}}))}});return e.close(),await Vp(Sj),await Vp("fcm_vapid_details_db"),await Vp("undefined"),function(e){if(!e||!e.subscriptionOptions)return!1;var t=e["subscriptionOptions"];return"number"==typeof e.createTime&&0<e.createTime&&"string"==typeof e.token&&0<e.token.length&&"string"==typeof t.auth&&0<t.auth.length&&"string"==typeof t.p256dh&&0<t.p256dh.length&&"string"==typeof t.endpoint&&0<t.endpoint.length&&"string"==typeof t.swScope&&0<t.swScope.length&&"string"==typeof t.vapidKey&&0<t.vapidKey.length}(o)?o:null}const Nj="firebase-messaging-database",Rj=1,Pj="firebase-messaging-store";let xj=null;function Dj(){return xj=xj||qp(Nj,Rj,e=>{0===e.oldVersion&&e.createObjectStore(Pj)}),xj}async function Oj(e){var t=Lj(e);const n=await Dj();t=await n.transaction(Pj).objectStore(Pj).get(t);if(t)return t;t=await Aj(e.appConfig.senderId);return t?(await Mj(e,t),t):void 0}async function Mj(e,t){var n=Lj(e);const r=await Dj(),i=r.transaction(Pj,"readwrite");return await i.objectStore(Pj).put(t,n),await i.complete,t}function Lj({appConfig:e}){return e.appId}const Fj=new md("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.","invalid-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 Uj(e,t){var n={method:"DELETE",headers:await qj(e)};try{const s=await fetch(`${jj(e.appConfig)}/${t}`,n);var r=await s.json();if(r.error){var i=r.error.message;throw Fj.create("token-unsubscribe-failed",{errorInfo:i})}}catch(e){throw Fj.create("token-unsubscribe-failed",{errorInfo:e})}}function jj({projectId:e}){return`${Tj}/projects/${e}/registrations`}async function qj({appConfig:e,installations:t}){var 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 Vj({p256dh:e,auth:t,endpoint:n,vapidKey:r}){const i={web:{endpoint:n,auth:t,p256dh:e}};return r!==bj&&(i.web.applicationPubKey=r),i}const Bj=6048e5;async function Wj(e){const t=await async function(e,t){var n=await e.pushManager.getSubscription();if(n)return n;return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:function(e){var t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/");const n=atob(t),r=new Uint8Array(n.length);for(let i=0;i<n.length;++i)r[i]=n.charCodeAt(i);return r}(t)})}(e.swRegistration,e.vapidKey);var n,r,i,s,o,a={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:t.endpoint,auth:kj(t.getKey("auth")),p256dh:kj(t.getKey("p256dh"))},c=await Oj(e.firebaseDependencies);if(c){if(n=c.subscriptionOptions,r=a.vapidKey===n.vapidKey,i=a.endpoint===n.endpoint,s=a.auth===n.auth,o=a.p256dh===n.p256dh,r&&i&&s&&o)return Date.now()>=c.createTime+Bj?async function(t,e){try{var n=await async function(e,t){var n=await qj(e),r=Vj(t.subscriptionOptions),r={method:"PATCH",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(`${jj(e.appConfig)}/${t.token}`,r);i=await s.json()}catch(e){throw Fj.create("token-update-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Fj.create("token-update-failed",{errorInfo:r})}if(!i.token)throw Fj.create("token-update-no-token");return i.token}(t.firebaseDependencies,e),r=Object.assign(Object.assign({},e),{token:n,createTime:Date.now()});return await Mj(t.firebaseDependencies,r),n}catch(e){throw await Kj(t),e}}(e,{token:c.token,createTime:Date.now(),subscriptionOptions:a}):c.token;try{await Uj(e.firebaseDependencies,c.token)}catch(e){console.warn(e)}return $j(e.firebaseDependencies,a)}return $j(e.firebaseDependencies,a)}async function Kj(e){var t=await Oj(e.firebaseDependencies);t&&(await Uj(e.firebaseDependencies,t.token),await async function(e){var t=Lj(e);const n=await Dj(),r=n.transaction(Pj,"readwrite");await r.objectStore(Pj).delete(t),await r.complete}(e.firebaseDependencies));const n=await e.swRegistration.pushManager.getSubscription();return!n||n.unsubscribe()}async function $j(e,t){var n={token:await async function(e,t){var n=await qj(e),r=Vj(t),r={method:"POST",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(jj(e.appConfig),r);i=await s.json()}catch(e){throw Fj.create("token-subscribe-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Fj.create("token-subscribe-failed",{errorInfo:r})}if(!i.token)throw Fj.create("token-subscribe-no-token");return i.token}(e,t),createTime:Date.now(),subscriptionOptions:t};return await Mj(e,n),n.token}function zj(e){var t,n,r,i={from:e.from,collapseKey:e.collapse_key,messageId:e.fcm_message_id};return n=i,(t=e).notification&&(n.notification={},(r=t.notification.title)&&(n.notification.title=r),(r=t.notification.body)&&(n.notification.body=r),(r=t.notification.image)&&(n.notification.image=r)),t=i,(n=e).data&&(t.data=n.data),n=i,(e=e).fcmOptions&&(n.fcmOptions={},(r=e.fcmOptions.link)&&(n.fcmOptions.link=r),(r=e.fcmOptions.analytics_label)&&(n.fcmOptions.analyticsLabel=r)),i}function Hj(e,t){const n=[];for(let r=0;r<e.length;r++)n.push(e.charAt(r)),r<t.length&&n.push(t.charAt(r));return n.join("")}function Gj(e){return Fj.create("missing-app-config-values",{valueName:e})}Hj("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),Hj("AzSCbw63g1R0nCw85jG8","Iaya3yLKwmgvh7cF0q4");class Qj{constructor(e,t,n){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.logEvents=[],this.isLogServiceStarted=!1;var r=function(e){if(!e||!e.options)throw Gj("App Configuration Object");if(!e.name)throw Gj("App Name");var t=e["options"];for(const n of["projectId","apiKey","appId","messagingSenderId"])if(!t[n])throw Gj(n);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 Yj(e){try{e.swRegistration=await navigator.serviceWorker.register(_j,{scope:wj}),e.swRegistration.update().catch(()=>{})}catch(e){throw Fj.create("failed-service-worker-registration",{browserErrorMessage:e.message})}}async function Jj(e,t){if(!navigator)throw Fj.create("only-available-in-window");if("default"===Notification.permission&&await Notification.requestPermission(),"granted"!==Notification.permission)throw Fj.create("permission-blocked");var n,r;return n=e,await((r=null==t?void 0:t.vapidKey)?n.vapidKey=r:n.vapidKey||(n.vapidKey=bj)),await async function(e,t){if(t||e.swRegistration||await Yj(e),t||!e.swRegistration){if(!(t instanceof ServiceWorkerRegistration))throw Fj.create("invalid-sw-registration");e.swRegistration=t}}(e,null==t?void 0:t.serviceWorkerRegistration),Wj(e)}async function Xj(e,t,n){var r=function(e){switch(e){case pj.NOTIFICATION_CLICKED:return"notification_open";case pj.PUSH_RECEIVED:return"notification_foreground";default:throw new Error}}(t);const i=await e.firebaseDependencies.analyticsProvider.get();i.logEvent(r,{message_id:n[Ij],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 Zj(e,t){var n,r=t.data;r.isFirebaseMessaging&&(e.onMessageHandler&&r.messageType===pj.PUSH_RECEIVED&&("function"==typeof e.onMessageHandler?e.onMessageHandler(zj(r)):e.onMessageHandler.next(zj(r))),n=r.data,"object"==typeof(t=n)&&t&&Ij in t&&"1"===n[Ej]&&await Xj(e,r.messageType,n))}const eq="@firebase/messaging",tq=e=>{const t=new Qj(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return navigator.serviceWorker.addEventListener("message",e=>Zj(t,e)),t},nq=e=>{const t=e.getProvider("messaging").getImmediate();return{getToken:e=>Jj(t,e)}};function rq(e){return async function(e){if(!navigator)throw Fj.create("only-available-in-window");return e.swRegistration||await Yj(e),Kj(e)}(e=Kd(e))}function iq(e,t){return function(e,t){if(!navigator)throw Fj.create("only-available-in-window");return e.onMessageHandler=t,()=>{e.onMessageHandler=null}}(e=Kd(e),t)}hp(new $d("messaging",tq,"PUBLIC")),hp(new $d("messaging-internal",nq,"PRIVATE")),_p(eq,"0.9.5"),_p(eq,"0.9.5","esm2017");const sq="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",oq="https://fcmregistrations.googleapis.com/v1",aq="FCM_MSG",cq="google.c.a.c_id",lq=3,uq=1;function hq(e){var t=new Uint8Array(e);const n=btoa(String.fromCharCode(...t));return n.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(yt=fj=fj||{})[yt.DATA_MESSAGE=1]="DATA_MESSAGE",yt[yt.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION",(c=gj=gj||{}).PUSH_RECEIVED="push-received",c.NOTIFICATION_CLICKED="notification-clicked";const dq="fcm_token_details_db",pq="fcm_token_object_Store";async function fq(s){if("databases"in indexedDB){const t=await indexedDB.databases(),n=t.map(e=>e.name);if(!n.includes(dq))return null}let o=null;const e=await qp(dq,5,async e=>{var t;if(!(e.oldVersion<2)&&e.objectStoreNames.contains(pq)){const i=e.transaction.objectStore(pq);var n,r=await i.index("fcmSenderId").get(s);await i.clear(),r&&(2===e.oldVersion?(n=r).auth&&n.p256dh&&n.endpoint&&(o={token:n.fcmToken,createTime:null!==(t=n.createTime)&&void 0!==t?t:Date.now(),subscriptionOptions:{auth:n.auth,p256dh:n.p256dh,endpoint:n.endpoint,swScope:n.swScope,vapidKey:"string"==typeof n.vapidKey?n.vapidKey:hq(n.vapidKey)}}):3===e.oldVersion?(n=r,o={token:n.fcmToken,createTime:n.createTime,subscriptionOptions:{auth:hq(n.auth),p256dh:hq(n.p256dh),endpoint:n.endpoint,swScope:n.swScope,vapidKey:hq(n.vapidKey)}}):4===e.oldVersion&&(r=r,o={token:r.fcmToken,createTime:r.createTime,subscriptionOptions:{auth:hq(r.auth),p256dh:hq(r.p256dh),endpoint:r.endpoint,swScope:r.swScope,vapidKey:hq(r.vapidKey)}}))}});return e.close(),await Vp(dq),await Vp("fcm_vapid_details_db"),await Vp("undefined"),function(e){if(!e||!e.subscriptionOptions)return!1;var t=e["subscriptionOptions"];return"number"==typeof e.createTime&&0<e.createTime&&"string"==typeof e.token&&0<e.token.length&&"string"==typeof t.auth&&0<t.auth.length&&"string"==typeof t.p256dh&&0<t.p256dh.length&&"string"==typeof t.endpoint&&0<t.endpoint.length&&"string"==typeof t.swScope&&0<t.swScope.length&&"string"==typeof t.vapidKey&&0<t.vapidKey.length}(o)?o:null}const gq="firebase-messaging-database",mq=1,vq="firebase-messaging-store";let yq=null;function _q(){return yq=yq||qp(gq,mq,e=>{0===e.oldVersion&&e.createObjectStore(vq)}),yq}async function wq(e){var t=Tq(e);const n=await _q();t=await n.transaction(vq).objectStore(vq).get(t);if(t)return t;t=await fq(e.appConfig.senderId);return t?(await bq(e,t),t):void 0}async function bq(e,t){var n=Tq(e);const r=await _q(),i=r.transaction(vq,"readwrite");return await i.objectStore(vq).put(t,n),await i.complete,t}function Tq({appConfig:e}){return e.appId}const Iq=new md("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.","invalid-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 Eq(e,t){var n={method:"DELETE",headers:await Sq(e)};try{const s=await fetch(`${kq(e.appConfig)}/${t}`,n);var r=await s.json();if(r.error){var i=r.error.message;throw Iq.create("token-unsubscribe-failed",{errorInfo:i})}}catch(e){throw Iq.create("token-unsubscribe-failed",{errorInfo:e})}}function kq({projectId:e}){return`${oq}/projects/${e}/registrations`}async function Sq({appConfig:e,installations:t}){var 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 Cq({p256dh:e,auth:t,endpoint:n,vapidKey:r}){const i={web:{endpoint:n,auth:t,p256dh:e}};return r!==sq&&(i.web.applicationPubKey=r),i}async function Aq(e){const t=await async function(e,t){var n=await e.pushManager.getSubscription();if(n)return n;return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:function(e){var t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/");const n=atob(t),r=new Uint8Array(n.length);for(let i=0;i<n.length;++i)r[i]=n.charCodeAt(i);return r}(t)})}(e.swRegistration,e.vapidKey);var n,r,i,s,o,a={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:t.endpoint,auth:hq(t.getKey("auth")),p256dh:hq(t.getKey("p256dh"))},c=await wq(e.firebaseDependencies);if(c){if(n=c.subscriptionOptions,r=a.vapidKey===n.vapidKey,i=a.endpoint===n.endpoint,s=a.auth===n.auth,o=a.p256dh===n.p256dh,r&&i&&s&&o)return Date.now()>=c.createTime+6048e5?async function(t,e){try{var n=await async function(e,t){var n=await Sq(e),r=Cq(t.subscriptionOptions),r={method:"PATCH",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(`${kq(e.appConfig)}/${t.token}`,r);i=await s.json()}catch(e){throw Iq.create("token-update-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Iq.create("token-update-failed",{errorInfo:r})}if(!i.token)throw Iq.create("token-update-no-token");return i.token}(t.firebaseDependencies,e),r=Object.assign(Object.assign({},e),{token:n,createTime:Date.now()});return await bq(t.firebaseDependencies,r),n}catch(e){throw await Nq(t),e}}(e,{token:c.token,createTime:Date.now(),subscriptionOptions:a}):c.token;try{await Eq(e.firebaseDependencies,c.token)}catch(e){console.warn(e)}return Rq(e.firebaseDependencies,a)}return Rq(e.firebaseDependencies,a)}async function Nq(e){var t=await wq(e.firebaseDependencies);t&&(await Eq(e.firebaseDependencies,t.token),await async function(e){var t=Tq(e);const n=await _q(),r=n.transaction(vq,"readwrite");await r.objectStore(vq).delete(t),await r.complete}(e.firebaseDependencies));const n=await e.swRegistration.pushManager.getSubscription();return!n||n.unsubscribe()}async function Rq(e,t){var n={token:await async function(e,t){var n=await Sq(e),r=Cq(t),r={method:"POST",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(kq(e.appConfig),r);i=await s.json()}catch(e){throw Iq.create("token-subscribe-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Iq.create("token-subscribe-failed",{errorInfo:r})}if(!i.token)throw Iq.create("token-subscribe-no-token");return i.token}(e,t),createTime:Date.now(),subscriptionOptions:t};return await bq(e,n),n.token}async function Pq(e,t){var n=function(e,t){var n;const r={};e.from&&(r.project_number=e.from);e.fcm_message_id&&(r.message_id=e.fcm_message_id);r.instance_id=t,e.notification?r.message_type=fj.DISPLAY_NOTIFICATION.toString():r.message_type=fj.DATA_MESSAGE.toString();r.sdk_platform=lq.toString(),r.package_name=self.origin.replace(/(^\w+:|^)\/\//,""),e.collapse_key&&(r.collapse_key=e.collapse_key);r.event=uq.toString(),null!==(n=e.fcmOptions)&&void 0!==n&&n.analytics_label&&(r.analytics_label=null===(n=e.fcmOptions)||void 0===n?void 0:n.analytics_label);return r}(t,await e.firebaseDependencies.installations.getId());!function(e,t){const n={};n.event_time_ms=Math.floor(Date.now()).toString(),n.source_extension_json_proto3=JSON.stringify(t),e.logEvents.push(n)}(e,n)}function xq(e,t){const n=[];for(let r=0;r<e.length;r++)n.push(e.charAt(r)),r<t.length&&n.push(t.charAt(r));return n.join("")}async function Dq(e,t){var n=function({data:e}){if(!e)return null;try{return e.json()}catch(e){return null}}(e);if(n){t.deliveryMetricsExportedToBigQueryEnabled&&await Pq(t,n);var r,i,s=await Mq();if(s.some(e=>"visible"===e.visibilityState&&!e.url.startsWith("chrome-extension://")))return function(e,t){t.isFirebaseMessaging=!0,t.messageType=gj.PUSH_RECEIVED;for(const n of e)n.postMessage(t)}(s,n);n.notification&&await function(e){var t=e["actions"],n=Notification["maxActions"];t&&n&&t.length>n&&console.warn(`This browser only supports ${n} actions. The remaining actions will not be displayed.`);return self.registration.showNotification(null!==(n=e.title)&&void 0!==n?n:"",e)}(function(e){const t=Object.assign({},e.notification);return t.data={[aq]:e},t}(n)),t&&t.onBackgroundMessageHandler&&(s={from:(r=n).from,collapseKey:r.collapse_key,messageId:r.fcm_message_id},n=s,(e=r).notification&&(n.notification={},(i=e.notification.title)&&(n.notification.title=i),(i=e.notification.body)&&(n.notification.body=i),(i=e.notification.image)&&(n.notification.image=i)),e=s,(n=r).data&&(e.data=n.data),n=s,(r=r).fcmOptions&&(n.fcmOptions={},(i=r.fcmOptions.link)&&(n.fcmOptions.link=i),(i=r.fcmOptions.analytics_label)&&(n.fcmOptions.analyticsLabel=i)),s=s,"function"==typeof t.onBackgroundMessageHandler?t.onBackgroundMessageHandler(s):t.onBackgroundMessageHandler.next(s))}}async function Oq(e){const t=null===(s=null===(i=e.notification)||void 0===i?void 0:i.data)||void 0===s?void 0:s[aq];if(t&&!e.action){e.stopImmediatePropagation(),e.notification.close();var n=function(e){var t;var n=null!==(t=null===(t=e.fcmOptions)||void 0===t?void 0:t.link)&&void 0!==t?t:null===(n=e.notification)||void 0===n?void 0:n.click_action;if(n)return n;return function(e){return"object"==typeof e&&e&&cq in e}(e.data)?self.location.origin:null}(t);if(n){var r,i=new URL(n,self.location.href),s=new URL(self.location.origin);if(i.host===s.host){let e=await async function(e){var t=await Mq();for(const r of t){var n=new URL(r.url,self.location.href);if(e.host===n.host)return r}return null}(i);if(e?e=await e.focus():(e=await self.clients.openWindow(n),r=3e3,await new Promise(e=>{setTimeout(e,r)})),e)return t.messageType=gj.NOTIFICATION_CLICKED,t.isFirebaseMessaging=!0,e.postMessage(t)}}}}function Mq(){return self.clients.matchAll({type:"window",includeUncontrolled:!0})}function Lq(e){return Iq.create("missing-app-config-values",{valueName:e})}xq("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),xq("AzSCbw63g1R0nCw85jG8","Iaya3yLKwmgvh7cF0q4");class Fq{constructor(e,t,n){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.logEvents=[],this.isLogServiceStarted=!1;var r=function(e){if(!e||!e.options)throw Lq("App Configuration Object");if(!e.name)throw Lq("App Name");var t=e["options"];for(const n of["projectId","apiKey","appId","messagingSenderId"])if(!t[n])throw Lq(n);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()}}const Uq=e=>{const t=new Fq(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return self.addEventListener("push",e=>{e.waitUntil(Dq(e,t))}),self.addEventListener("pushsubscriptionchange",e=>{e.waitUntil(async function(e,t){var n;(n=e["newSubscription"])?(n=await wq(t.firebaseDependencies),await Nq(t),t.vapidKey=null!==(n=null===(n=null==n?void 0:n.subscriptionOptions)||void 0===n?void 0:n.vapidKey)&&void 0!==n?n:sq,await Aq(t)):await Nq(t)}(e,t))}),self.addEventListener("notificationclick",e=>{e.waitUntil(Oq(e))}),t};function jq(e,t){return function(e,t){if(void 0!==self.document)throw Iq.create("only-available-in-sw");return e.onBackgroundMessageHandler=t,()=>{e.onBackgroundMessageHandler=null}}(e=Kd(e),t)}hp(new $d("messaging-sw",Uq,"PUBLIC"));var qq,Vq,Bq;class Wq{constructor(e,t){this.app=e,this._delegate=t,this.app=e,this._delegate=t}async getToken(e){return async function(e,t){return Jj(e=Kd(e),t)}(this._delegate,e)}async deleteToken(){return rq(this._delegate)}onMessage(e){return iq(this._delegate,e)}onBackgroundMessage(e){return jq(this._delegate,e)}}const Kq=e=>self&&"ServiceWorkerGlobalScope"in self?new Wq(e.getProvider("app-compat").getImmediate(),e.getProvider("messaging-sw").getImmediate()):new Wq(e.getProvider("app-compat").getImmediate(),e.getProvider("messaging").getImmediate()),$q={isSupported:function(){return self&&"ServiceWorkerGlobalScope"in self?dd()&&"PushManager"in self&&"Notification"in self&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey"):"undefined"!=typeof window&&dd()&&fd()&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}};Cp.INTERNAL.registerComponent(new $d("messaging-compat",Kq,"PUBLIC").setServiceProps($q)),Cp.registerVersion("@firebase/messaging-compat","0.1.5");const zq="firebasestorage.googleapis.com",Hq="storageBucket";class Gq extends gd{constructor(e,t){super(Qq(e),`Firebase Storage: ${t} (${Qq(e)})`),this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,Gq.prototype)}_codeEquals(e){return Qq(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}\n${this.customData.serverResponse}`:this.message=this._baseMessage}}function Qq(e){return"storage/"+e}function Yq(){return new Gq("unknown","An unknown error occurred, please check the error payload for server response.")}function Jq(){return new Gq("canceled","User canceled the upload/download.")}function Xq(){return new Gq("cannot-slice-blob","Cannot slice blob for upload. Please retry the upload.")}function Zq(e){return new Gq("invalid-argument",e)}function eV(){return new Gq("app-deleted","The Firebase app was deleted.")}function tV(e){return new Gq("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 nV(e,t){return new Gq("invalid-format","String does not match format '"+e+"': "+t)}function rV(e){throw new Gq("internal-error","Internal error: "+e)}class iV{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return 0===this.path.length}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o"}static makeFromBucketSpec(t,e){let n;try{n=iV.makeFromUrl(t,e)}catch(e){return new iV(t,"")}if(""===n.path)return n;throw t=t,new Gq("invalid-default-bucket","Invalid default bucket '"+t+"'.")}static makeFromUrl(e,t){let n=null;var r="([A-Za-z0-9.\\-_]+)";var i=new RegExp("^gs://"+r+"(/(.*))?$","i");function s(e){e.path_=decodeURIComponent(e.path)}var o=t.replace(/[.]/g,"\\."),a=new RegExp(`^https?://${o}/v[A-Za-z0-9_]+/b/${r}/o(/([^?#]*).*)?$`,"i"),o=t===zq?"(?:storage.googleapis.com|storage.cloud.google.com)":t,c=[{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:a,indices:{bucket:1,path:3},postModify:s},{regex:new RegExp(`^https?://${o}/${r}/([^?#]*)`,"i"),indices:{bucket:1,path:2},postModify:s}];for(let h=0;h<c.length;h++){const d=c[h];var l=d.regex.exec(e);if(l){var u=l[d.indices.bucket];let e=l[d.indices.path];e=e||"",n=new iV(u,e),d.postModify(n);break}}if(null==n)throw t=e,new Gq("invalid-url","Invalid URL '"+t+"'.");return n}}class sV{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=0){}}function oV(e){return"string"==typeof e||e instanceof String}function aV(e){return cV()&&e instanceof Blob}function cV(){return"undefined"!=typeof Blob}function lV(e,t,n,r){if(r<t)throw Zq(`Invalid value for '${e}'. Expected ${t} or greater.`);if(n<r)throw Zq(`Invalid value for '${e}'. Expected ${n} or less.`)}function uV(e,t,n){let r=null==n?`https://${t}`:t;return`${n}://${r}/v0${e}`}function hV(e){const t=encodeURIComponent;let n="?";for(const i in e){var r;e.hasOwnProperty(i)&&(r=t(i)+"="+t(e[i]),n=n+r+"&")}return n=n.slice(0,-1),n}(c=qq=qq||{})[c.NO_ERROR=0]="NO_ERROR",c[c.NETWORK_ERROR=1]="NETWORK_ERROR",c[c.ABORT=2]="ABORT";class dV{constructor(e,t,n,r,i,s,o,a,c,l,u){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_=c,this.progressCallback_=l,this.connectionFactory_=u,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_(){var e=(r,e)=>{if(e)r(!1,new pV(!1,null,!0));else{const i=this.connectionFactory_();this.pendingConnection_=i;const s=e=>{var t=e.loaded,n=e.lengthComputable?e.total:-1;null!==this.progressCallback_&&this.progressCallback_(t,n)};null!==this.progressCallback_&&i.addUploadProgressListener(s),i.send(this.url_,this.method_,this.body_,this.headers_).then(()=>{null!==this.progressCallback_&&i.removeUploadProgressListener(s),this.pendingConnection_=null;var e,t=i.getErrorCode()===qq.NO_ERROR,n=i.getStatus();t&&!this.isRetryStatusCode_(n)?(e=-1!==this.successCodes_.indexOf(n),r(!0,new pV(e,i))):(e=i.getErrorCode()===qq.ABORT,r(!1,new pV(!1,null,e)))})}},t=(e,t)=>{const n=this.resolve_,r=this.reject_,i=t.connection;if(t.wasSuccessCode)try{var s=this.callback_(i,i.getResponse());void 0!==s?n(s):n()}catch(e){r(e)}else if(null!==i){const a=Yq();a.serverResponse=i.getErrorText(),this.errorCallback_?r(this.errorCallback_(i,a)):r(a)}else{var o;t.canceled?(o=(this.appDelete_?eV:Jq)(),r(o)):(o=new Gq("retry-limit-exceeded","Max retry time for operation exceeded, please try again."),r(o))}};this.canceled_?t(0,new pV(!1,null,!0)):this.backoffId_=function(t,n,e){let r=1,i=null,s=null,o=!1,a=0;function c(){return 2===a}let l=!1;function u(...e){l||(l=!0,n.apply(null,e))}function h(e){i=setTimeout(()=>{i=null,t(p,c())},e)}function d(){s&&clearTimeout(s)}function p(t,...n){if(l)d();else{if(t)return d(),void u.call(null,t,...n);if(c()||o)return d(),void u.call(null,t,...n);r<64&&(r*=2);let e;e=1===a?(a=2,0):1e3*(r+Math.random()),h(e)}}let f=!1;function g(e){f||(f=!0,d(),l||(null!==i?(e||(a=2),clearTimeout(i),h(0)):e||(a=1)))}return h(0),s=setTimeout(()=>{g(o=!0)},e),g}(e,t,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()}isRetryStatusCode_(e){var t=500<=e&&e<600,n=-1!==[408,429].indexOf(e),r=-1!==this.additionalRetryCodes_.indexOf(e);return t||n||r}}class pV{constructor(e,t,n){this.wasSuccessCode=e,this.connection=t,this.canceled=!!n}}function fV(...t){const n="undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0;if(void 0!==n){const r=new n;for(let e=0;e<t.length;e++)r.append(t[e]);return r.getBlob()}if(cV())return new Blob(t);throw new Gq("unsupported-environment","This browser doesn't seem to support creating Blobs")}const gV={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class mV{constructor(e,t){this.data=e,this.contentType=t||null}}function vV(e,t){switch(e){case gV.RAW:return new mV(yV(t));case gV.BASE64:case gV.BASE64URL:return new mV(_V(e,t));case gV.DATA_URL:return new mV((n=t,(r=new wV(n)).base64?_V(gV.BASE64,r.rest):function(e){let t;try{t=decodeURIComponent(e)}catch(e){throw nV(gV.DATA_URL,"Malformed data URL.")}return yV(t)}(r.rest)),(n=t,new wV(n).contentType))}var n,r;throw Yq()}function yV(t){const n=[];for(let s=0;s<t.length;s++){let e=t.charCodeAt(s);var r,i;e<=127?n.push(e):e<=2047?n.push(192|e>>6,128|63&e):55296==(64512&e)?s<t.length-1&&56320==(64512&t.charCodeAt(s+1))?(r=e,i=t.charCodeAt(++s),e=65536|(1023&r)<<10|1023&i,n.push(240|e>>18,128|e>>12&63,128|e>>6&63,128|63&e)):n.push(239,191,189):56320==(64512&e)?n.push(239,191,189):n.push(224|e>>12,128|e>>6&63,128|63&e)}return new Uint8Array(n)}function _V(t,e){switch(t){case gV.BASE64:var n=-1!==e.indexOf("-"),r=-1!==e.indexOf("_");if(n||r)throw nV(t,"Invalid character '"+(n?"-":"_")+"' found: is it base64url encoded?");break;case gV.BASE64URL:r=-1!==e.indexOf("+"),n=-1!==e.indexOf("/");if(r||n)throw nV(t,"Invalid character '"+(r?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/")}let i;try{i=atob(e)}catch(e){throw nV(t,"Invalid character found")}const s=new Uint8Array(i.length);for(let o=0;o<i.length;o++)s[o]=i.charCodeAt(o);return s}class wV{constructor(e){this.base64=!1,this.contentType=null;var t,n,r=e.match(/^data:([^,]+)?,/);if(null===r)throw nV(gV.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");const i=r[1]||null;null!=i&&(this.base64=(t=i,n=";base64",t.length>=n.length&&t.substring(t.length-n.length)===n),this.contentType=this.base64?i.substring(0,i.length-";base64".length):i),this.rest=e.substring(e.indexOf(",")+1)}}class bV{constructor(e,t){let n=0,r="";aV(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(aV(this.data_)){var n=this.data_,n=(i=e,s=t,(r=n).webkitSlice?r.webkitSlice(i,s):r.mozSlice?r.mozSlice(i,s):r.slice?r.slice(i,s):null);return null===n?null:new bV(n)}var r,i,s,n=new Uint8Array(this.data_.buffer,e,t-e);return new bV(n,!0)}static getBlob(...e){if(cV()){var t=e.map(e=>e instanceof bV?e.data_:e);return new bV(fV.apply(null,t))}{const r=e.map(e=>oV(e)?vV(gV.RAW,e).data:e.data_);let t=0;r.forEach(e=>{t+=e.byteLength});const i=new Uint8Array(t);let n=0;return r.forEach(e=>{for(let t=0;t<e.length;t++)i[n++]=e[t]}),new bV(i,!0)}}uploadData(){return this.data_}}function TV(e){let t;try{t=JSON.parse(e)}catch(e){return null}return"object"!=typeof(e=t)||Array.isArray(e)?null:t}function IV(e){var t=e.lastIndexOf("/",e.length-2);return-1===t?e:e.slice(t+1)}function EV(e,t){return t}class kV{constructor(e,t,n,r){this.server=e,this.local=t||e,this.writable=!!n,this.xform=r||EV}}let SV=null;function CV(){if(SV)return SV;const e=[];e.push(new kV("bucket")),e.push(new kV("generation")),e.push(new kV("metageneration")),e.push(new kV("name","fullPath",!0));const t=new kV("name");t.xform=function(e,t){return!oV(t=t)||t.length<2?t:IV(t)},e.push(t);const n=new kV("size");return n.xform=function(e,t){return void 0!==t?Number(t):t},e.push(n),e.push(new kV("timeCreated")),e.push(new kV("updated")),e.push(new kV("md5Hash",null,!0)),e.push(new kV("cacheControl",null,!0)),e.push(new kV("contentDisposition",null,!0)),e.push(new kV("contentEncoding",null,!0)),e.push(new kV("contentLanguage",null,!0)),e.push(new kV("contentType",null,!0)),e.push(new kV("metadata","customMetadata",!0)),SV=e,SV}function AV(n,r){Object.defineProperty(n,"ref",{get:function(){var e=n.bucket,t=n.fullPath,t=new iV(e,t);return r._makeStorageReference(t)}})}function NV(e,t,n){var r=TV(t);return null===r?null:function(e,t,n){const r={type:"file"};var i=n.length;for(let s=0;s<i;s++){const o=n[s];r[o.local]=o.xform(r,t[o.server])}return AV(r,e),r}(e,r,n)}function RV(e,t){const n={};var r=t.length;for(let s=0;s<r;s++){var i=t[s];i.writable&&(n[i.server]=e[i.local])}return JSON.stringify(n)}function PV(e,t,n){var r=TV(n);return null===r?null:function(e,t,n){const r={prefixes:[],items:[],nextPageToken:n.nextPageToken};if(n.prefixes)for(const o of n.prefixes){var i=o.replace(/\/$/,""),i=e._makeStorageReference(new iV(t,i));r.prefixes.push(i)}if(n.items)for(const a of n.items){var s=e._makeStorageReference(new iV(t,a.name));r.items.push(s)}return r}(e,t,r)}class xV{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 DV(e){if(!e)throw Yq()}function OV(r,i){return function(e,t){var n=NV(r,t,i);return DV(null!==n),n}}function MV(r,i){return function(e,t){var n=PV(r,i,t);return DV(null!==n),n}}function LV(r,i){return function(e,t){var n=NV(r,t,i);return DV(null!==n),function(r,e,i,s){var t=TV(e);if(null===t)return null;if(!oV(t.downloadTokens))return null;const n=t.downloadTokens;if(0===n.length)return null;const o=encodeURIComponent,a=n.split(",");return a.map(e=>{var t=r.bucket,n=r.fullPath;return uV("/b/"+o(t)+"/o/"+o(n),i,s)+hV({alt:"media",token:e})})[0]}(n,t,r.host,r._protocol)}}function FV(i){return function(e,t){let n;var r;return n=401===e.getStatus()?e.getErrorText().includes("Firebase App Check token is invalid")?new Gq("unauthorized-app","This app does not have permission to access Firebase Storage on this project."):new Gq("unauthenticated","User is not authenticated, please authenticate using Firebase Authentication and try again."):402===e.getStatus()?(r=i.bucket,new Gq("quota-exceeded","Quota for bucket '"+r+"' exceeded, please view quota on https://firebase.google.com/pricing/.")):403===e.getStatus()?(e=i.path,new Gq("unauthorized","User does not have permission to access '"+e+"'.")):t,n.serverResponse=t.serverResponse,n}}function UV(r){const i=FV(r);return function(e,t){let n=i(e,t);return 404===e.getStatus()&&(n=(e=r.path,new Gq("object-not-found","Object '"+e+"' does not exist."))),n.serverResponse=t.serverResponse,n}}function jV(e,t,n){var r=uV(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime;const s=new xV(r,"GET",OV(e,n),i);return s.errorHandler=UV(t),s}function qV(e,t,n){const r=Object.assign({},n);return r.fullPath=e.path,r.size=t.size(),r.contentType||(r.contentType=(e=t,(t=null)&&t.contentType||e&&e.type()||"application/octet-stream")),r}function VV(e,t,n,r,i){var s=t.bucketOnlyServerUrl();const o={"X-Goog-Upload-Protocol":"multipart"};var 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;var c=qV(t,r,i),l="--"+a+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+RV(c,n)+"\r\n--"+a+"\r\nContent-Type: "+c.contentType+"\r\n\r\n",a="\r\n--"+a+"--";const u=bV.getBlob(l,r,a);if(null===u)throw Xq();a={name:c.fullPath},c=uV(s,e.host,e._protocol),s=e.maxUploadRetryTime;const h=new xV(c,"POST",OV(e,n),s);return h.urlParams=a,h.headers=o,h.body=u.uploadData(),h.errorHandler=FV(t),h}class BV{constructor(e,t,n,r){this.current=e,this.total=t,this.finalized=!!n,this.metadata=r||null}}function WV(e,t){let n=null;try{n=e.getResponseHeader("X-Goog-Upload-Status")}catch(e){DV(!1)}const r=t||["active"];return DV(!!n&&-1!==r.indexOf(n)),n}function KV(e,t,n,r,i){var s=t.bucketOnlyServerUrl(),o=qV(t,r,i),a={name:o.fullPath},c=uV(s,e.host,e._protocol),l={"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"},s=RV(o,n),o=e.maxUploadRetryTime;const u=new xV(c,"POST",function(e){WV(e);let t;try{t=e.getResponseHeader("X-Goog-Upload-URL")}catch(e){DV(!1)}return DV(oV(t)),t},o);return u.urlParams=a,u.headers=l,u.body=s,u.errorHandler=FV(t),u}function $V(e,t,n,i){var r=e.maxUploadRetryTime;const s=new xV(n,"POST",function(e){var t=WV(e,["active","final"]);let n=null;try{n=e.getResponseHeader("X-Goog-Upload-Size-Received")}catch(e){DV(!1)}n||DV(!1);var r=Number(n);return DV(!isNaN(r)),new BV(r,i.size(),"final"===t)},r);return s.headers={"X-Goog-Upload-Command":"query"},s.errorHandler=FV(t),s}function zV(e,o,t,a,n,c,r,i){const l=new BV(0,0);if(r?(l.current=r.current,l.total=r.total):(l.current=0,l.total=a.size()),a.size()!==l.total)throw new Gq("server-file-wrong-size","Server recorded incorrect upload file size, please retry the upload.");var s=l.total-l.current;let u=s;0<n&&(u=Math.min(u,n));var h=l.current,d=h+u,s={"X-Goog-Upload-Command":u===s?"upload, finalize":"upload","X-Goog-Upload-Offset":`${l.current}`};const p=a.slice(h,d);if(null===p)throw Xq();d=o.maxUploadRetryTime;const f=new xV(t,"POST",function(e,t){var n=WV(e,["active","final"]),r=l.current+u,i=a.size();let s;return s="final"===n?OV(o,c)(e,t):null,new BV(r,i,"final"===n,s)},d);return f.headers=s,f.body=p.uploadData(),f.progressCallback=i||null,f.errorHandler=FV(e),f}const HV={STATE_CHANGED:"state_changed"},GV={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function QV(e){switch(e){case"running":case"pausing":case"canceling":return GV.RUNNING;case"paused":return GV.PAUSED;case"success":return GV.SUCCESS;case"canceled":return GV.CANCELED;default:return GV.ERROR}}class YV{constructor(e,t,n){var r;"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=(r=e).next,this.error=r.error,this.complete=r.complete)}}function JV(t){return(...e)=>{Promise.resolve().then(()=>t(...e))}}class XV extends class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=qq.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=qq.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=qq.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,n,r){if(this.sent_)throw rV("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(t,e,!0),void 0!==r)for(const i in r)r.hasOwnProperty(i)&&this.xhr_.setRequestHeader(i,r[i].toString());return void 0!==n?this.xhr_.send(n):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw rV("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw rV("cannot .getStatus() before sending");try{return this.xhr_.status}catch(e){return-1}}getResponse(){if(!this.sent_)throw rV("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw rV("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)}}{initXhr(){this.xhr_.responseType="text"}}function ZV(){return new XV}class eB{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=CV(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=e=>{this._request=void 0,this._chunkMultiplier=1,e._codeEquals("canceled")?(this._needToFetchStatus=!0,this.completeTransitions_()):(this._error=e,this._transition("error"))},this._metadataErrorHandler=e=>{this._request=void 0,e._codeEquals("canceled")?this.completeTransitions_():(this._error=e,this._transition("error"))},this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t,this._start()}),this._promise.then(null,()=>{})}_makeProgressCallback(){const t=this._transferred;return e=>this._updateProgress(t+e)}_shouldDoResumable(e){return 262144<e.size()}_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._continueUpload():this._oneShotUpload())}_resolveToken(n){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([e,t])=>{switch(this._state){case"running":n(e,t);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused")}})}_createResumable(){this._resolveToken((e,t)=>{var n=KV(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata);const r=this._ref.storage._makeRequest(n,ZV,e,t);this._request=r,r.getPromise().then(e=>{this._request=void 0,this._uploadUrl=e,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){const i=this._uploadUrl;this._resolveToken((e,t)=>{var n=$V(this._ref.storage,this._ref._location,i,this._blob);const r=this._ref.storage._makeRequest(n,ZV,e,t);this._request=r,r.getPromise().then(e=>{this._request=void 0,this._updateProgress(e.current),this._needToFetchStatus=!1,e.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){const i=262144*this._chunkMultiplier,s=new BV(this._transferred,this._blob.size()),o=this._uploadUrl;this._resolveToken((e,t)=>{let n;try{n=zV(this._ref._location,this._ref.storage,o,this._blob,i,this._mappings,s,this._makeProgressCallback())}catch(e){return this._error=e,void this._transition("error")}const r=this._ref.storage._makeRequest(n,ZV,e,t);this._request=r,r.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<33554432&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{var n=jV(this._ref.storage,this._ref._location,this._mappings);const r=this._ref.storage._makeRequest(n,ZV,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)=>{var n=VV(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata);const r=this._ref.storage._makeRequest(n,ZV,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){var 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();break;case"running":var t="paused"===this._state;this._state=e,t&&(this._notifyObservers(),this._start());break;case"paused":this._state=e,this._notifyObservers();break;case"canceled":this._error=Jq(),this._state=e,this._notifyObservers();break;case"error":case"success":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(){var e=QV(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){const i=new YV(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){var t=this._observers.indexOf(e);-1!==t&&this._observers.splice(t,1)}_notifyObservers(){this._finishPromise();const e=this._observers.slice();e.forEach(e=>{this._notifyObserver(e)})}_finishPromise(){if(void 0!==this._resolve){let e=!0;switch(QV(this._state)){case GV.SUCCESS:JV(this._resolve.bind(null,this.snapshot))();break;case GV.CANCELED:case GV.ERROR:const t=this._reject;JV(t.bind(null,this._error))();break;default:e=!1}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(QV(this._state)){case GV.RUNNING:case GV.PAUSED:e.next&&JV(e.next.bind(e,this.snapshot))();break;case GV.SUCCESS:e.complete&&JV(e.complete.bind(e))();break;case GV.CANCELED:case GV.ERROR:default:e.error&&JV(e.error.bind(e,this._error))()}}resume(){var e="paused"===this._state||"pausing"===this._state;return e&&this._transition("running"),e}pause(){var e="running"===this._state;return e&&this._transition("pausing"),e}cancel(){var e="running"===this._state||"pausing"===this._state;return e&&this._transition("canceling"),e}}class tB{constructor(e,t){this._service=e,t instanceof iV?this._location=t:this._location=iV.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new tB(e,t)}get root(){var e=new iV(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return IV(this._location.path)}get storage(){return this._service}get parent(){var e=function(e){if(0===e.length)return null;var t=e.lastIndexOf("/");return-1===t?"":e.slice(0,t)}(this._location.path);if(null===e)return null;e=new iV(this._location.bucket,e);return new tB(this._service,e)}_throwIfRoot(e){if(""===this._location.path)throw tV(e)}}function nB(e){const t={prefixes:[],items:[]};return async function e(t,n,r){const i={pageToken:r};const s=await rB(t,i);n.prefixes.push(...s.prefixes);n.items.push(...s.items);null!=s.nextPageToken&&await e(t,n,s.nextPageToken)}(e,t).then(()=>t)}function rB(e,t){null!=t&&"number"==typeof t.maxResults&&lV("options.maxResults",1,1e3,t.maxResults);var n=t||{},n=function(e,t,n,r,i){const s={};t.isRoot?s.prefix="":s.prefix=t.path+"/",n&&0<n.length&&(s.delimiter=n),r&&(s.pageToken=r),i&&(s.maxResults=i);var o=uV(t.bucketOnlyServerUrl(),e.host,e._protocol),a=e.maxOperationRetryTime;const c=new xV(o,"GET",MV(e,t.bucket),a);return c.urlParams=s,c.errorHandler=FV(t),c}(e.storage,e._location,"/",n.pageToken,n.maxResults);return e.storage.makeRequestWithTokens(n,ZV)}function iB(e,t){e._throwIfRoot("updateMetadata");var n=function(e,t,n,r){var i=uV(t.fullServerUrl(),e.host,e._protocol),s=RV(n,r),o=e.maxOperationRetryTime;const a=new xV(i,"PATCH",OV(e,r),o);return a.headers={"Content-Type":"application/json; charset=utf-8"},a.body=s,a.errorHandler=UV(t),a}(e.storage,e._location,t,CV());return e.storage.makeRequestWithTokens(n,ZV)}function sB(e){e._throwIfRoot("getDownloadURL");var t=function(e,t,n){var r=uV(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime;const s=new xV(r,"GET",LV(e,n),i);return s.errorHandler=UV(t),s}(e.storage,e._location,CV());return e.storage.makeRequestWithTokens(t,ZV).then(e=>{if(null===e)throw new Gq("no-download-url","The given file does not have any download URLs.");return e})}function oB(e){e._throwIfRoot("deleteObject");var t=function(e,t){var n=uV(t.fullServerUrl(),e.host,e._protocol),r=e.maxOperationRetryTime;const i=new xV(n,"DELETE",function(e,t){},r);return i.successCodes=[200,204],i.errorHandler=UV(t),i}(e.storage,e._location);return e.storage.makeRequestWithTokens(t,ZV)}function aB(e,t){var n,r=(n=e._location.path,r=t.split("/").filter(e=>0<e.length).join("/"),0===n.length?r:n+"/"+r),r=new iV(e._location.bucket,r);return new tB(e.storage,r)}function cB(e,t){if(e instanceof hB){var n=e;if(null==n._bucket)throw new Gq("no-default-bucket","No default bucket found. Did you set the '"+Hq+"' property when initializing the app?");n=new tB(n,n._bucket);return null!=t?cB(n,t):n}return void 0!==t?aB(e,t):e}function lB(e,t){if(t&&/^[A-Za-z]+:\/\//.test(t)){if(e instanceof hB)return n=e,r=t,new tB(n,r);throw Zq("To use ref(service, url), the first argument must be a Storage instance.")}return cB(e,t);var n,r}function uB(e,t){var n=null==t?void 0:t[Hq];return null==n?null:iV.makeFromBucketSpec(n,e)}class hB{constructor(e,t,n,r,i){this.app=e,this._authProvider=t,this._appCheckProvider=n,this._url=r,this._firebaseVersion=i,this._bucket=null,this._host=zq,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=12e4,this._maxUploadRetryTime=6e5,this._requests=new Set,this._bucket=null!=r?iV.makeFromBucketSpec(r,this._host):uB(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,null!=this._url?this._bucket=iV.makeFromBucketSpec(this._url,e):this._bucket=uB(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){lV("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){lV("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){var t=await e.getToken();if(null!==t)return t.accessToken}return null}async _getAppCheckToken(){const e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new tB(this,e)}_makeRequest(e,t,n,r){if(this._deleted)return new sV(eV());{const l=(i=e,s=this._appId,o=n,e=r,n=t,r=this._firebaseVersion,a=hV(i.urlParams),c=i.url+a,a=Object.assign({},i.headers),t=a,(s=s)&&(t["X-Firebase-GMPID"]=s),s=a,null!==(o=o)&&0<o.length&&(s.Authorization="Firebase "+o),r=r,a["X-Firebase-Storage-Version"]="webjs/"+(null!=r?r:"AppManager"),r=a,null!==(e=e)&&(r["X-Firebase-AppCheck"]=e),new dV(c,i.method,a,i.body,i.successCodes,i.additionalRetryCodes,i.handler,i.errorHandler,i.timeout,i.progressCallback,n));return this._requests.add(l),l.getPromise().then(()=>this._requests.delete(l),()=>this._requests.delete(l)),l}var i,s,o,a,c}async makeRequestWithTokens(e,t){var[n,r]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,n,r).getPromise()}}const dB="@firebase/storage";function pB(e,t,n){return e=Kd(e),t=t,n=n,(e=e)._throwIfRoot("uploadBytesResumable"),new eB(e,new bV(t),n)}function fB(e){return function(e){e._throwIfRoot("getMetadata");var t=jV(e.storage,e._location,CV());return e.storage.makeRequestWithTokens(t,ZV)}(e=Kd(e))}function gB(e,t){return lB(e=Kd(e),t)}function mB(e,t,n,r={}){!function(e,t,n,r={}){e.host=`${t}:${n}`,e._protocol="http";var i=r["mockUserToken"];i&&(e._overrideAuthToken="string"==typeof i?i:id(i,e.app.options.projectId))}(e,t,n,r)}function vB(e,{instanceIdentifier:t}){var n=e.getProvider("app").getImmediate(),r=e.getProvider("auth-internal"),i=e.getProvider("app-check-internal");return new hB(n,r,i,t,gp)}hp(new $d("storage",vB,"PUBLIC").setMultipleInstances(!0)),_p(dB,"0.9.1",""),_p(dB,"0.9.1","esm2017");class yB{constructor(e,t,n){this._delegate=e,this.task=t,this.ref=n}get bytesTransferred(){return this._delegate.bytesTransferred}get metadata(){return this._delegate.metadata}get state(){return this._delegate.state}get totalBytes(){return this._delegate.totalBytes}}class _B{constructor(e,t){this._delegate=e,this._ref=t,this.cancel=this._delegate.cancel.bind(this._delegate),this.catch=this._delegate.catch.bind(this._delegate),this.pause=this._delegate.pause.bind(this._delegate),this.resume=this._delegate.resume.bind(this._delegate)}get snapshot(){return new yB(this._delegate.snapshot,this,this._ref)}then(t,e){return this._delegate.then(e=>{if(t)return t(new yB(e,this,this._ref))},e)}on(e,t,n,r){let i=void 0;return t&&(i="function"==typeof t?e=>t(new yB(e,this,this._ref)):{next:t.next?e=>t.next(new yB(e,this,this._ref)):void 0,complete:t.complete||void 0,error:t.error||void 0}),this._delegate.on(e,i,n||void 0,r||void 0)}}class wB{constructor(e,t){this._delegate=e,this._service=t}get prefixes(){return this._delegate.prefixes.map(e=>new bB(e,this._service))}get items(){return this._delegate.items.map(e=>new bB(e,this._service))}get nextPageToken(){return this._delegate.nextPageToken||null}}class bB{constructor(e,t){this._delegate=e,this.storage=t}get name(){return this._delegate.name}get bucket(){return this._delegate.bucket}get fullPath(){return this._delegate.fullPath}toString(){return this._delegate.toString()}child(e){var t=aB(this._delegate,e);return new bB(t,this.storage)}get root(){return new bB(this._delegate.root,this.storage)}get parent(){var e=this._delegate.parent;return null==e?null:new bB(e,this.storage)}put(e,t){return this._throwIfRoot("put"),new _B(pB(this._delegate,e,t),this)}putString(e,t=gV.RAW,n){this._throwIfRoot("putString");var r=vV(t,e);const i=Object.assign({},n);return null==i.contentType&&null!=r.contentType&&(i.contentType=r.contentType),new _B(new eB(this._delegate,new bV(r.data,!0),i),this)}listAll(){return nB(Kd(this._delegate)).then(e=>new wB(e,this.storage))}list(e){return t=this._delegate,e=e||void 0,rB(t=Kd(t),e).then(e=>new wB(e,this.storage));var t}getMetadata(){return fB(this._delegate)}updateMetadata(e){return iB(Kd(this._delegate),e)}getDownloadURL(){return sB(Kd(this._delegate))}delete(){return this._throwIfRoot("delete"),oB(Kd(this._delegate))}_throwIfRoot(e){if(""===this._delegate._location.path)throw tV(e)}}class TB{constructor(e,t){this.app=e,this._delegate=t}get maxOperationRetryTime(){return this._delegate.maxOperationRetryTime}get maxUploadRetryTime(){return this._delegate.maxUploadRetryTime}ref(e){if(IB(e))throw Zq("ref() expected a child path but got a URL, use refFromURL instead.");return new bB(gB(this._delegate,e),this)}refFromURL(e){if(!IB(e))throw Zq("refFromURL() expected a full URL but got a child path, use ref() instead.");try{iV.makeFromUrl(e,this._delegate.host)}catch(e){throw Zq("refFromUrl() expected a valid full URL but got an invalid one.")}return new bB(gB(this._delegate,e),this)}setMaxUploadRetryTime(e){this._delegate.maxUploadRetryTime=e}setMaxOperationRetryTime(e){this._delegate.maxOperationRetryTime=e}useEmulator(e,t,n={}){mB(this._delegate,e,t,n)}}function IB(e){return/^[A-Za-z]+:\/\//.test(e)}function EB(e,{instanceIdentifier:t}){var n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("storage").getImmediate({identifier:t});return new TB(n,r)}Vq=Cp,Bq={TaskState:GV,TaskEvent:HV,StringFormat:gV,Storage:TB,Reference:bB},Vq.INTERNAL.registerComponent(new $d("storage-compat",EB,"PUBLIC").setServiceProps(Bq).setMultipleInstances(!0)),Vq.registerVersion("@firebase/storage-compat","0.1.9");const kB="@firebase/performance",SB="0.5.5",CB="FB-PERF-TRACE-MEASURE",AB="@firebase/performance/config",NB="@firebase/performance/configexpire";var RB,PB,xB,DB="Performance";const OB=new md("performance",DB,{"trace started":"Trace {$traceName} was started before.","trace stopped":"Trace {$traceName} is not running.","nonpositive trace startTime":"Trace {$traceName} startTime should be positive.","nonpositive trace duration":"Trace {$traceName} duration should be positive.","no window":"Window is not available.","no app id":"App id is not available.","no project id":"Project id is not available.","no api key":"Api key is not available.","invalid cc log":"Attempted to queue invalid cc event","FB not default":"Performance can only start when Firebase app instance is the default one.","RC response not ok":"RC response is not ok","invalid attribute name":"Attribute name {$attributeName} is invalid.","invalid attribute value":"Attribute value {$attributeValue} is invalid.","invalid custom metric name":"Custom metric name {$customMetricName} is invalid","invalid String merger input":"Input for String merger is invalid, contact support team to resolve.","already initialized":"initializePerformance() has already been called with different options. To avoid this error, call initializePerformance() with the same options as when it was originally called, or call getPerformance() to return the already initialized instance."}),MB=new ep(DB);MB.logLevel=Kh.INFO;let LB,FB;class UB{constructor(e){if(!(this.window=e))throw OB.create("no window");this.performance=e.performance,this.PerformanceObserver=e.PerformanceObserver,this.windowLocation=e.location,this.navigator=e.navigator,this.document=e.document,this.navigator&&this.navigator.cookieEnabled&&(this.localStorage=e.localStorage),e.perfMetrics&&e.perfMetrics.onFirstInputDelay&&(this.onFirstInputDelay=e.perfMetrics.onFirstInputDelay)}getUrl(){return this.windowLocation.href.split("?")[0]}mark(e){this.performance&&this.performance.mark&&this.performance.mark(e)}measure(e,t,n){this.performance&&this.performance.measure&&this.performance.measure(e,t,n)}getEntriesByType(e){return this.performance&&this.performance.getEntriesByType?this.performance.getEntriesByType(e):[]}getEntriesByName(e){return this.performance&&this.performance.getEntriesByName?this.performance.getEntriesByName(e):[]}getTimeOrigin(){return this.performance&&(this.performance.timeOrigin||this.performance.timing.navigationStart)}requiredApisAvailable(){return fetch&&Promise&&fd()?!!dd()||(MB.info("IndexedDB is not supported by current browswer"),!1):(MB.info("Firebase Performance cannot start if browser does not support fetch and Promise or cookie is disabled."),!1)}setupObserver(e,n){if(this.PerformanceObserver){const t=new this.PerformanceObserver(e=>{for(const t of e.getEntries())n(t)});t.observe({entryTypes:[e]})}}static getInstance(){return void 0===LB&&(LB=new UB(FB)),LB}}let jB;function qB(e,t){var n=e.length-t.length;if(n<0||1<n)throw OB.create("invalid String merger input");const r=[];for(let i=0;i<e.length;i++)r.push(e.charAt(i)),t.length>i&&r.push(t.charAt(i));return r.join("")}let VB;class BB{constructor(){this.instrumentationEnabled=!0,this.dataCollectionEnabled=!0,this.loggingEnabled=!1,this.tracesSamplingRate=1,this.networkRequestsSamplingRate=1,this.logEndPointUrl="https://firebaselogging.googleapis.com/v0cc/log?format=json_proto",this.flTransportEndpointUrl=qB("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),this.transportKey=qB("AzSC8r6ReiGqFMyfvgow","Iayx0u-XT3vksVM-pIV"),this.logSource=462,this.logTraceAfterSampling=!1,this.logNetworkAfterSampling=!1,this.configTimeToLive=12}getFlTransportFullUrl(){return this.flTransportEndpointUrl.concat("?key=",this.transportKey)}static getInstance(){return void 0===VB&&(VB=new BB),VB}}(c=RB=RB||{})[c.UNKNOWN=0]="UNKNOWN",c[c.VISIBLE=1]="VISIBLE",c[c.HIDDEN=2]="HIDDEN";const WB=["firebase_","google_","ga_"],KB=new RegExp("^[a-zA-Z]\\w*$");function $B(){switch(UB.getInstance().document.visibilityState){case"visible":return RB.VISIBLE;case"hidden":return RB.HIDDEN;default:return RB.UNKNOWN}}function zB(e){var t=null===(t=e.options)||void 0===t?void 0:t.appId;if(!t)throw OB.create("no app id");return t}const HB="0.0.1",GB={loggingEnabled:!0},QB="FIREBASE_INSTALLATIONS_AUTH";function YB(e,t){var r,i,n=function(){const e=UB.getInstance().localStorage;if(e){var t=e.getItem(NB);if(t&&function(e){return Number(e)>Date.now()}(t)){t=e.getItem(AB);if(t)try{return JSON.parse(t)}catch(e){return}}}}();return n?(XB(n),Promise.resolve()):(i=t,function(e){const t=e.getToken();return t.then(e=>{}),t}((r=e).installations).then(e=>{var t=function(e){var t=null===(t=e.options)||void 0===t?void 0:t.projectId;if(!t)throw OB.create("no project id");return t}(r.app),n=function(e){var t=null===(t=e.options)||void 0===t?void 0:t.apiKey;if(!t)throw OB.create("no api key");return t}(r.app),n=new Request(`https://firebaseremoteconfig.googleapis.com/v1/projects/${t}/namespaces/fireperf:fetch?key=${n}`,{method:"POST",headers:{Authorization:`${QB} ${e}`},body:JSON.stringify({app_instance_id:i,app_instance_id_token:e,app_id:zB(r.app),app_version:SB,sdk_version:HB})});return fetch(n).then(e=>{if(e.ok)return e.json();throw OB.create("RC response not ok")})}).catch(()=>{MB.info(JB)}).then(XB).then(e=>function(e){const t=UB.getInstance().localStorage;e&&t&&(t.setItem(AB,JSON.stringify(e)),t.setItem(NB,String(Date.now()+60*BB.getInstance().configTimeToLive*60*1e3)))}(e),()=>{}))}const JB="Could not fetch config, will use default configs";function XB(e){if(!e)return e;const t=BB.getInstance();var n=e.entries||{};return void 0!==n.fpr_enabled?t.loggingEnabled="true"===String(n.fpr_enabled):t.loggingEnabled=GB.loggingEnabled,n.fpr_log_source&&(t.logSource=Number(n.fpr_log_source)),n.fpr_log_endpoint_url&&(t.logEndPointUrl=n.fpr_log_endpoint_url),n.fpr_log_transport_key&&(t.transportKey=n.fpr_log_transport_key),void 0!==n.fpr_vc_network_request_sampling_rate&&(t.networkRequestsSamplingRate=Number(n.fpr_vc_network_request_sampling_rate)),void 0!==n.fpr_vc_trace_sampling_rate&&(t.tracesSamplingRate=Number(n.fpr_vc_trace_sampling_rate)),t.logTraceAfterSampling=ZB(t.tracesSamplingRate),t.logNetworkAfterSampling=ZB(t.networkRequestsSamplingRate),e}function ZB(e){return Math.random()<=e}let eW=1,tW;function nW(e){var t;return eW=2,tW=tW||(t=e,function(){const n=UB.getInstance().document;return new Promise(e=>{if(n&&"complete"!==n.readyState){const t=()=>{"complete"===n.readyState&&(n.removeEventListener("readystatechange",t),e())};n.addEventListener("readystatechange",t)}else e()})}().then(()=>function(e){const t=e.getId();return t.then(e=>{jB=e}),t}(t.installations)).then(e=>YB(t,e)).then(()=>rW(),()=>rW())),tW}function rW(){eW=3}const iW=1e4,sW=3,oW=1e3;let aW=sW,cW=[],lW=!1;function uW(e){setTimeout(()=>{if(0!==aW)return cW.length?void function(){const e=cW.splice(0,oW),t=e.map(e=>({source_extension_json_proto3:e.message,event_time_ms:String(e.eventTime)})),n={request_time_ms:String(Date.now()),client_info:{client_type:1,js_client_info:{}},log_source:BB.getInstance().logSource,log_event:t};!function(e,r){return function(e){var t=BB.getInstance().getFlTransportFullUrl();return fetch(t,{method:"POST",body:JSON.stringify(e)})}(e).then(e=>(e.ok||MB.info("Call to Firebase backend failed."),e.json())).then(e=>{var t=Number(e.nextRequestWaitMillis);let n=iW;isNaN(t)||(n=Math.max(t,n));t=e.logResponseDetails;Array.isArray(t)&&0<t.length&&"RETRY_REQUEST_LATER"===t[0].responseAction&&(cW=[...r,...cW],MB.info("Retry transport request later.")),aW=sW,uW(n)})}(n,e).catch(()=>{cW=[...e,...cW],aW--,MB.info(`Tries left: ${aW}.`),uW(iW)})}():uW(iW)},e)}function hW(t){return(...e)=>{!function(e){if(!e.eventTime||!e.message)throw OB.create("invalid cc log");cW=[...cW,e]}({message:t(...e),eventTime:Date.now()})}}let dW;function pW(e,t){dW=dW||hW(mW),dW(e,t)}function fW(e){var t=BB.getInstance();!t.instrumentationEnabled&&e.isAuto||(t.dataCollectionEnabled||e.isAuto)&&UB.getInstance().requiredApisAvailable()&&(e.isAuto&&$B()!==RB.VISIBLE||(3===eW?gW(e):nW(e.performanceController).then(()=>gW(e),()=>gW(e))))}function gW(e){var t;!jB||(t=BB.getInstance()).loggingEnabled&&t.logTraceAfterSampling&&setTimeout(()=>pW(e,1),0)}function mW(e,t){return 0===t?(n={url:e.url,http_method:e.httpMethod||0,http_response_code:200,response_payload_bytes:e.responsePayloadBytes,client_start_time_us:e.startTimeUs,time_to_response_initiated_us:e.timeToResponseInitiatedUs,time_to_response_completed_us:e.timeToResponseCompletedUs},n={application_info:vW(e.performanceController.app),network_request_metric:n},JSON.stringify(n)):function(e){const t={name:e.name,is_auto:e.isAuto,client_start_time_us:e.startTimeUs,duration_us:e.durationUs};0!==Object.keys(e.counters).length&&(t.counters=e.counters);var n=e.getAttributes();0!==Object.keys(n).length&&(t.custom_attributes=n);n={application_info:vW(e.performanceController.app),trace_metric:t};return JSON.stringify(n)}(e);var n}function vW(e){return{google_app_id:zB(e),app_instance_id:jB,web_app_info:{sdk_version:SB,page_url:UB.getInstance().getUrl(),service_worker_status:"serviceWorker"in(t=UB.getInstance().navigator)?t.serviceWorker.controller?2:3:1,visibility_state:$B(),effective_connection_type:function(){var e=UB.getInstance().navigator.connection;switch(e&&e.effectiveType){case"slow-2g":return 1;case"2g":return 2;case"3g":return 3;case"4g":return 4;default:return 0}}()},application_process_state:0};var t}const yW=["_fp","_fcp","_fid"];class _W{constructor(e,t,n=!1,r){this.performanceController=e,this.name=t,this.isAuto=n,this.state=1,this.customAttributes={},this.counters={},this.api=UB.getInstance(),this.randomId=Math.floor(1e6*Math.random()),this.isAuto||(this.traceStartMark=`FB-PERF-TRACE-START-${this.randomId}-${this.name}`,this.traceStopMark=`FB-PERF-TRACE-STOP-${this.randomId}-${this.name}`,this.traceMeasure=r||`${CB}-${this.randomId}-${this.name}`,r&&this.calculateTraceMetrics())}start(){if(1!==this.state)throw OB.create("trace started",{traceName:this.name});this.api.mark(this.traceStartMark),this.state=2}stop(){if(2!==this.state)throw OB.create("trace stopped",{traceName:this.name});this.state=3,this.api.mark(this.traceStopMark),this.api.measure(this.traceMeasure,this.traceStartMark,this.traceStopMark),this.calculateTraceMetrics(),fW(this)}record(e,t,n){if(e<=0)throw OB.create("nonpositive trace startTime",{traceName:this.name});if(t<=0)throw OB.create("nonpositive trace duration",{traceName:this.name});if(this.durationUs=Math.floor(1e3*t),this.startTimeUs=Math.floor(1e3*e),n&&n.attributes&&(this.customAttributes=Object.assign({},n.attributes)),n&&n.metrics)for(const r of Object.keys(n.metrics))isNaN(Number(n.metrics[r]))||(this.counters[r]=Number(Math.floor(n.metrics[r])));fW(this)}incrementMetric(e,t=1){void 0===this.counters[e]?this.putMetric(e,t):this.putMetric(e,this.counters[e]+t)}putMetric(e,t){if(r=e,i=this.name,0===r.length||100<r.length||!(i&&i.startsWith("_wt_")&&-1<yW.indexOf(r))&&r.startsWith("_"))throw OB.create("invalid custom metric name",{customMetricName:e});var n,r,i;this.counters[e]=(t=t,(n=Math.floor(t))<t&&MB.info(`Metric value should be an Integer, setting the value as : ${n}.`),n)}getMetric(e){return this.counters[e]||0}putAttribute(e,t){var n,r,i=!(0===(n=e).length||40<n.length)&&(!WB.some(e=>n.startsWith(e))&&!!n.match(KB)),s=0!==(r=t).length&&r.length<=100;if(i&&s)this.customAttributes[e]=t;else{if(!i)throw OB.create("invalid attribute name",{attributeName:e});if(!s)throw OB.create("invalid attribute value",{attributeValue:t})}}getAttribute(e){return this.customAttributes[e]}removeAttribute(e){void 0!==this.customAttributes[e]&&delete this.customAttributes[e]}getAttributes(){return Object.assign({},this.customAttributes)}setStartTime(e){this.startTimeUs=e}setDuration(e){this.durationUs=e}calculateTraceMetrics(){var e=this.api.getEntriesByName(this.traceMeasure),e=e&&e[0];e&&(this.durationUs=Math.floor(1e3*e.duration),this.startTimeUs=Math.floor(1e3*(e.startTime+this.api.getTimeOrigin())))}static createOobTrace(e,t,n,r){var i=UB.getInstance().getUrl();if(i){const s=new _W(e,"_wt_"+i,!0);i=Math.floor(1e3*UB.getInstance().getTimeOrigin());s.setStartTime(i),t&&t[0]&&(s.setDuration(Math.floor(1e3*t[0].duration)),s.putMetric("domInteractive",Math.floor(1e3*t[0].domInteractive)),s.putMetric("domContentLoadedEventEnd",Math.floor(1e3*t[0].domContentLoadedEventEnd)),s.putMetric("loadEventEnd",Math.floor(1e3*t[0].loadEventEnd)));n&&((i=n.find(e=>"first-paint"===e.name))&&i.startTime&&s.putMetric("_fp",Math.floor(1e3*i.startTime)),(i=n.find(e=>"first-contentful-paint"===e.name))&&i.startTime&&s.putMetric("_fcp",Math.floor(1e3*i.startTime)),r&&s.putMetric("_fid",Math.floor(1e3*r))),fW(s)}}static createUserTimingTrace(e,t){fW(new _W(e,t,!1,t))}}function wW(e,t){const n=t;var r,i,s;n&&void 0!==n.responseStart&&(s=UB.getInstance().getTimeOrigin(),r=Math.floor(1e3*(n.startTime+s)),i=n.responseStart?Math.floor(1e3*(n.responseStart-n.startTime)):void 0,s=Math.floor(1e3*(n.responseEnd-n.startTime)),function(e){const t=BB.getInstance();var n,r,i;t.instrumentationEnabled&&(n=e.url,r=t.logEndPointUrl.split("?")[0],i=t.flTransportEndpointUrl.split("?")[0],n!==r&&n!==i&&t.loggingEnabled&&t.logNetworkAfterSampling&&setTimeout(()=>pW(e,0),0))}({performanceController:e,url:n.name&&n.name.split("?")[0],responsePayloadBytes:n.transferSize,startTimeUs:r,timeToResponseInitiatedUs:i,timeToResponseCompletedUs:s}))}const bW=5e3;function TW(e){jB&&(setTimeout(()=>function(n){const e=UB.getInstance(),r=e.getEntriesByType("navigation"),i=e.getEntriesByType("paint");if(e.onFirstInputDelay){let t=setTimeout(()=>{_W.createOobTrace(n,r,i),t=void 0},bW);e.onFirstInputDelay(e=>{t&&(clearTimeout(t),_W.createOobTrace(n,r,i,e))})}else _W.createOobTrace(n,r,i)}(e),0),setTimeout(()=>function(t){const e=UB.getInstance(),n=e.getEntriesByType("resource");for(const r of n)wW(t,r);e.setupObserver("resource",e=>wW(t,e))}(e),0),setTimeout(()=>function(t){const e=UB.getInstance(),n=e.getEntriesByType("measure");for(const r of n)IW(t,r);e.setupObserver("measure",e=>IW(t,e))}(e),0))}function IW(e,t){const n=t.name;n.substring(0,CB.length)!==CB&&_W.createUserTimingTrace(e,n)}class EW{constructor(e,t){this.app=e,this.installations=t,this.initialized=!1}_init(e){this.initialized||(void 0!==(null==e?void 0:e.dataCollectionEnabled)&&(this.dataCollectionEnabled=e.dataCollectionEnabled),void 0!==(null==e?void 0:e.instrumentationEnabled)&&(this.instrumentationEnabled=e.instrumentationEnabled),UB.getInstance().requiredApisAvailable()?pd().then(e=>{e&&(lW||(uW(5500),lW=!0),nW(this).then(()=>TW(this),()=>TW(this)),this.initialized=!0)}).catch(e=>{MB.info(`Environment doesn't support IndexedDB: ${e}`)}):MB.info('Firebase Performance cannot start if the browser does not support "Fetch" and "Promise", or cookies are disabled.'))}set instrumentationEnabled(e){BB.getInstance().instrumentationEnabled=e}get instrumentationEnabled(){return BB.getInstance().instrumentationEnabled}set dataCollectionEnabled(e){BB.getInstance().dataCollectionEnabled=e}get dataCollectionEnabled(){return BB.getInstance().dataCollectionEnabled}}const kW="[DEFAULT]";const SW=(e,{options:t})=>{var n=e.getProvider("app").getImmediate(),r=e.getProvider("installations-internal").getImmediate();if(n.name!==kW)throw OB.create("FB not default");if("undefined"==typeof window)throw OB.create("no window");e=window,FB=e;const i=new EW(n,r);return i._init(t),i};hp(new $d("performance",SW,"PUBLIC")),_p(kB,"0.5.5"),_p(kB,"0.5.5","esm2017");class CW{constructor(e,t){this.app=e,this._delegate=t}get instrumentationEnabled(){return this._delegate.instrumentationEnabled}set instrumentationEnabled(e){this._delegate.instrumentationEnabled=e}get dataCollectionEnabled(){return this._delegate.dataCollectionEnabled}set dataCollectionEnabled(e){this._delegate.dataCollectionEnabled=e}trace(e){return t=this._delegate,e=e,t=Kd(t),new _W(t,e);var t}}function AW(e){var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("performance").getImmediate();return new CW(t,n)}(PB=Cp).INTERNAL.registerComponent(new $d("performance-compat",AW,"PUBLIC")),PB.registerVersion("@firebase/performance-compat","0.1.5");const NW="@firebase/remote-config";class RW{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}const PW=new md("remoteconfig","Remote Config",{"registration-window":"Undefined window object. This SDK only supports usage in a browser environment.","registration-project-id":"Undefined project identifier. Check Firebase app initialization.","registration-api-key":"Undefined API key. Check Firebase app initialization.","registration-app-id":"Undefined app identifier. Check Firebase app initialization.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","storage-delete":"Error thrown when deleting from storage. Original error: {$originalErrorMessage}.","fetch-client-network":"Fetch client failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-timeout":'The config fetch request timed out. Configure timeout using "fetchTimeoutMillis" SDK setting.',"fetch-throttle":'The config fetch request timed out while in an exponential backoff state. Configure timeout using "fetchTimeoutMillis" SDK setting. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',"fetch-client-parse":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","indexed-db-unavailable":"Indexed DB is not supported by current browser"});const xW=["1","true","t","yes","y","on"];class DW{constructor(e,t=""){this._source=e,this._value=t}asString(){return this._value}asBoolean(){return"static"!==this._source&&0<=xW.indexOf(this._value.toLowerCase())}asNumber(){if("static"===this._source)return 0;let e=Number(this._value);return isNaN(e)&&(e=0),e}getSource(){return this._source}}async function OW(e){const t=Kd(e);var[n,r]=await Promise.all([t._storage.getLastSuccessfulFetchResponse(),t._storage.getActiveConfigEtag()]);return!!(n&&n.config&&n.eTag&&n.eTag!==r)&&(await Promise.all([t._storageCache.setActiveConfig(n.config),t._storage.setActiveConfigEtag(n.eTag)]),!0)}function MW(e){const t=Kd(e);return t._initializePromise||(t._initializePromise=t._storageCache.loadFromStorage().then(()=>{t._isInitializationComplete=!0})),t._initializePromise}async function LW(t){const n=Kd(t),e=new RW;setTimeout(async()=>{e.abort()},n.settings.fetchTimeoutMillis);try{await n._client.fetch({cacheMaxAgeMillis:n.settings.minimumFetchIntervalMillis,signal:e}),await n._storageCache.setLastFetchStatus("success")}catch(e){var r=(i="fetch-throttle",(t=e)instanceof gd&&-1!==t.code.indexOf(i)?"throttle":"failure");throw await n._storageCache.setLastFetchStatus(r),e}var i}function FW(n){const e=Kd(n);return[t={},r={}]=[e._storageCache.getActiveConfig(),e.defaultConfig],Object.keys(Object.assign(Object.assign({},t),r)).reduce((e,t)=>(e[t]=UW(n,t),e),{});var t,r}function UW(e,t){const n=Kd(e);n._isInitializationComplete||n._logger.debug(`A value was requested for key "${t}" before SDK initialization completed.`+" Await on ensureInitialized if the intent was to get a previously activated value.");var r=n._storageCache.getActiveConfig();return r&&void 0!==r[t]?new DW("remote",r[t]):n.defaultConfig&&void 0!==n.defaultConfig[t]?new DW("default",String(n.defaultConfig[t])):(n._logger.debug(`Returning static value for key "${t}".`+" Define a default or remote value if this is unintentional."),new DW("static"))}class jW{constructor(e,t,n,r){this.client=e,this.storage=t,this.storageCache=n,this.logger=r}isCachedDataFresh(e,t){if(!t)return this.logger.debug("Config fetch cache check. Cache unpopulated."),!1;var n=Date.now()-t,r=n<=e;return this.logger.debug("Config fetch cache check."+` Cache age millis: ${n}.`+` Cache max age millis (minimumFetchIntervalMillis setting): ${e}.`+` Is cache hit: ${r}.`),r}async fetch(e){var[t,n]=await Promise.all([this.storage.getLastSuccessfulFetchTimestampMillis(),this.storage.getLastSuccessfulFetchResponse()]);if(n&&this.isCachedDataFresh(e.cacheMaxAgeMillis,t))return n;e.eTag=n&&n.eTag;n=await this.client.fetch(e);const r=[this.storageCache.setLastSuccessfulFetchTimestampMillis(Date.now())];return 200===n.status&&r.push(this.storage.setLastSuccessfulFetchResponse(n)),await Promise.all(r),n}}class qW{constructor(e,t,n,r,i,s){this.firebaseInstallations=e,this.sdkVersion=t,this.namespace=n,this.projectId=r,this.apiKey=i,this.appId=s}async fetch(n){var e,[t,r]=await Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken()]),i=`${window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfig.googleapis.com"}/v1/projects/${this.projectId}/namespaces/${this.namespace}:fetch?key=${this.apiKey}`,s={"Content-Type":"application/json","Content-Encoding":"gzip","If-None-Match":n.eTag||"*"},r={sdk_version:this.sdkVersion,app_instance_id:t,app_instance_id_token:r,app_id:this.appId,language_code:(e=navigator).languages&&e.languages[0]||e.language},r={method:"POST",headers:s,body:JSON.stringify(r)},i=fetch(i,r),r=new Promise((e,t)=>{n.signal.addEventListener(()=>{const e=new Error("The operation was aborted.");e.name="AbortError",t(e)})});let o;try{await Promise.race([i,r]),o=await i}catch(e){let t="fetch-client-network";throw"AbortError"===e.name&&(t="fetch-timeout"),PW.create(t,{originalErrorMessage:e.message})}let a=o.status;i=o.headers.get("ETag")||void 0;let c,l;if(200===o.status){let e;try{e=await o.json()}catch(e){throw PW.create("fetch-client-parse",{originalErrorMessage:e.message})}c=e.entries,l=e.state}if("INSTANCE_STATE_UNSPECIFIED"===l?a=500:"NO_CHANGE"===l?a=304:"NO_TEMPLATE"!==l&&"EMPTY_CONFIG"!==l||(c={}),304!==a&&200!==a)throw PW.create("fetch-status",{httpStatus:a});return{status:a,eTag:i,config:c}}}class VW{constructor(e,t){this.client=e,this.storage=t}async fetch(e){var t=await this.storage.getThrottleMetadata()||{backoffCount:0,throttleEndTimeMillis:Date.now()};return this.attemptFetch(e,t)}async attemptFetch(t,{throttleEndTimeMillis:e,backoffCount:n}){var i,s;i=t.signal,s=e,await new Promise((e,t)=>{var n=Math.max(s-Date.now(),0);const r=setTimeout(e,n);i.addEventListener(()=>{clearTimeout(r),t(PW.create("fetch-throttle",{throttleEndTimeMillis:s}))})});try{var r=await this.client.fetch(t);return await this.storage.deleteThrottleMetadata(),r}catch(e){if(!function(e){if(e instanceof gd&&e.customData){var t=Number(e.customData.httpStatus);return 429===t||500===t||503===t||504===t}}(e))throw e;r={throttleEndTimeMillis:Date.now()+Wd(n),backoffCount:n+1};return await this.storage.setThrottleMetadata(r),this.attemptFetch(t,r)}}}class BW{constructor(e,t,n,r,i){this.app=e,this._client=t,this._storageCache=n,this._storage=r,this._logger=i,this._isInitializationComplete=!1,this.settings={fetchTimeoutMillis:6e4,minimumFetchIntervalMillis:432e5},this.defaultConfig={}}get fetchTimeMillis(){return this._storageCache.getLastSuccessfulFetchTimestampMillis()||-1}get lastFetchStatus(){return this._storageCache.getLastFetchStatus()||"no-fetch-yet"}}function WW(e,t){var n=e.target.error||void 0;return PW.create(t,{originalErrorMessage:n&&n.message})}const KW="app_namespace_store";class $W{constructor(e,t,n,r=function(){return new Promise((t,n)=>{try{const e=indexedDB.open("firebase_remote_config",1);e.onerror=e=>{n(WW(e,"storage-open"))},e.onsuccess=e=>{t(e.target.result)},e.onupgradeneeded=e=>{const t=e.target.result;0===e.oldVersion&&t.createObjectStore(KW,{keyPath:"compositeKey"})}}catch(e){n(PW.create("storage-open",{originalErrorMessage:e}))}})}()){this.appId=e,this.appName=t,this.namespace=n,this.openDbPromise=r}getLastFetchStatus(){return this.get("last_fetch_status")}setLastFetchStatus(e){return this.set("last_fetch_status",e)}getLastSuccessfulFetchTimestampMillis(){return this.get("last_successful_fetch_timestamp_millis")}setLastSuccessfulFetchTimestampMillis(e){return this.set("last_successful_fetch_timestamp_millis",e)}getLastSuccessfulFetchResponse(){return this.get("last_successful_fetch_response")}setLastSuccessfulFetchResponse(e){return this.set("last_successful_fetch_response",e)}getActiveConfig(){return this.get("active_config")}setActiveConfig(e){return this.set("active_config",e)}getActiveConfigEtag(){return this.get("active_config_etag")}setActiveConfigEtag(e){return this.set("active_config_etag",e)}getThrottleMetadata(){return this.get("throttle_metadata")}setThrottleMetadata(e){return this.set("throttle_metadata",e)}deleteThrottleMetadata(){return this.delete("throttle_metadata")}async get(o){const a=await this.openDbPromise;return new Promise((n,t)=>{const e=a.transaction([KW],"readonly"),r=e.objectStore(KW);var i=this.createCompositeKey(o);try{const s=r.get(i);s.onerror=e=>{t(WW(e,"storage-get"))},s.onsuccess=e=>{var t=e.target.result;n(t?t.value:void 0)}}catch(e){t(PW.create("storage-get",{originalErrorMessage:e&&e.message}))}})}async set(o,a){const c=await this.openDbPromise;return new Promise((e,t)=>{const n=c.transaction([KW],"readwrite"),r=n.objectStore(KW);var i=this.createCompositeKey(o);try{const s=r.put({compositeKey:i,value:a});s.onerror=e=>{t(WW(e,"storage-set"))},s.onsuccess=()=>{e()}}catch(e){t(PW.create("storage-set",{originalErrorMessage:e&&e.message}))}})}async delete(o){const a=await this.openDbPromise;return new Promise((e,t)=>{const n=a.transaction([KW],"readwrite"),r=n.objectStore(KW);var i=this.createCompositeKey(o);try{const s=r.delete(i);s.onerror=e=>{t(WW(e,"storage-delete"))},s.onsuccess=()=>{e()}}catch(e){t(PW.create("storage-delete",{originalErrorMessage:e&&e.message}))}})}createCompositeKey(e){return[this.appId,this.appName,this.namespace,e].join()}}class zW{constructor(e){this.storage=e}getLastFetchStatus(){return this.lastFetchStatus}getLastSuccessfulFetchTimestampMillis(){return this.lastSuccessfulFetchTimestampMillis}getActiveConfig(){return this.activeConfig}async loadFromStorage(){var e=this.storage.getLastFetchStatus(),t=this.storage.getLastSuccessfulFetchTimestampMillis(),n=this.storage.getActiveConfig(),e=await e;e&&(this.lastFetchStatus=e);t=await t;t&&(this.lastSuccessfulFetchTimestampMillis=t);n=await n;n&&(this.activeConfig=n)}setLastFetchStatus(e){return this.lastFetchStatus=e,this.storage.setLastFetchStatus(e)}setLastSuccessfulFetchTimestampMillis(e){return this.lastSuccessfulFetchTimestampMillis=e,this.storage.setLastSuccessfulFetchTimestampMillis(e)}setActiveConfig(e){return this.activeConfig=e,this.storage.setActiveConfig(e)}}async function HW(){if(!dd())return!1;try{return await pd()}catch(e){return!1}}hp(new $d("remote-config",function(e,{instanceIdentifier:t}){var n=e.getProvider("app").getImmediate(),r=e.getProvider("installations-internal").getImmediate();if("undefined"==typeof window)throw PW.create("registration-window");if(!dd())throw PW.create("indexed-db-unavailable");var{projectId:i,apiKey:s,appId:o}=n.options;if(!i)throw PW.create("registration-project-id");if(!s)throw PW.create("registration-api-key");if(!o)throw PW.create("registration-app-id");t=t||"firebase";const a=new $W(o,n.name,t),c=new zW(a),l=new ep(NW);l.logLevel=Kh.ERROR;o=new qW(r,gp,t,i,s,o),o=new VW(o,a),o=new jW(o,a,c,l),o=new BW(n,o,c,a,l);return MW(o),o},"PUBLIC").setMultipleInstances(!0)),_p(NW,"0.3.4"),_p(NW,"0.3.4","esm2017");class GW{constructor(e,t){this.app=e,this._delegate=t}get defaultConfig(){return this._delegate.defaultConfig}set defaultConfig(e){this._delegate.defaultConfig=e}get fetchTimeMillis(){return this._delegate.fetchTimeMillis}get lastFetchStatus(){return this._delegate.lastFetchStatus}get settings(){return this._delegate.settings}set settings(e){this._delegate.settings=e}activate(){return OW(this._delegate)}ensureInitialized(){return MW(this._delegate)}fetch(){return LW(this._delegate)}fetchAndActivate(){return async function(e){return await LW(e=Kd(e)),OW(e)}(this._delegate)}getAll(){return FW(this._delegate)}getBoolean(e){return UW(Kd(this._delegate),e).asBoolean()}getNumber(e){return UW(Kd(this._delegate),e).asNumber()}getString(e){return UW(Kd(this._delegate),e).asString()}getValue(e){return UW(this._delegate,e)}setLogLevel(e){!function(e,t){const n=Kd(e);switch(t){case"debug":n._logger.logLevel=Kh.DEBUG;break;case"silent":n._logger.logLevel=Kh.SILENT;break;default:n._logger.logLevel=Kh.ERROR}}(this._delegate,e)}}function QW(e,{instanceIdentifier:t}){var n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("remote-config").getImmediate({identifier:t});return new GW(n,r)}return(xB=Cp).INTERNAL.registerComponent(new $d("remoteConfig-compat",QW,"PUBLIC").setMultipleInstances(!0).setServiceProps({isSupported:HW})),xB.registerVersion("@firebase/remote-config-compat","0.1.5"),console.warn("\nIt looks like you're using the development build of the Firebase JS SDK.\nWhen deploying Firebase apps to production, it is advisable to only import\nthe individual SDK components you intend to use.\n\nFor the CDN builds, these are available in the following manner\n(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):\n\nhttps://www.gstatic.com/firebasejs/5.0.0/firebase-<PACKAGE>.js\n"),Cp.registerVersion("firebase","9.6.2","compat-cdn"),Cp});
|
|
9
|
+
`)}function $g(){var e=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("Unable to locate global object.")}();const t=mg;if(t.initialized=!0,"string"==typeof e.FIREBASE_APPCHECK_DEBUG_TOKEN||!0===e.FIREBASE_APPCHECK_DEBUG_TOKEN){t.enabled=!0;const n=new rd;t.token=n,"string"==typeof e.FIREBASE_APPCHECK_DEBUG_TOKEN?n.resolve(e.FIREBASE_APPCHECK_DEBUG_TOKEN):n.resolve(Vg())}}const Kg={error:"UNKNOWN_ERROR"};async function zg(e,t=!1){var n=e.app;kg(n);const r=vg(n);let i=r.token,s=void 0;if(i||(a=await r.cachedTokenPromise)&&Jg(a)&&(i=a),!t&&i&&Jg(i))return{token:i.token};let o=!1;if(Bg()){r.exchangeTokenPromise||(r.exchangeTokenPromise=Ag(function(e,t){var{projectId:n,appId:r,apiKey:i}=e.options;return{url:`${_g}/projects/${n}/apps/${r}:${wg}?key=${i}`,body:{debug_token:t}}}(n,await Wg()),e.platformLoggerProvider).then(e=>(r.exchangeTokenPromise=void 0,e)),o=!0);var a=await r.exchangeTokenPromise;return await qg(n,a),yg(n,Object.assign(Object.assign({},r),{token:a})),{token:a.token}}try{r.exchangeTokenPromise||(r.exchangeTokenPromise=r.provider.getToken().then(e=>(r.exchangeTokenPromise=void 0,e)),o=!0),i=await r.exchangeTokenPromise}catch(e){"appCheck/throttled"===e.code?Ug.warn(e.message):Ug.error(e),s=e}let c;return i?(c={token:i.token},yg(n,Object.assign(Object.assign({},r),{token:i})),await qg(n,i)):c=(e=s,{token:function(e){return Zh.encodeString(JSON.stringify(e),!1)}(Kg),error:e}),o&&Yg(n,c),c}function Hg(e,t,n,r){var i=e["app"];const s=vg(i);var o={next:n,error:r,type:t};if(yg(i,Object.assign(Object.assign({},s),{tokenObservers:[...s.tokenObservers,o]})),s.token&&Jg(s.token)){const a=s.token;Promise.resolve().then(()=>{n({token:a.token}),Qg(e)}).catch(()=>{})}s.cachedTokenPromise.then(()=>Qg(e))}function Gg(e,t){const n=vg(e);var r=n.tokenObservers.filter(e=>e.next!==t);0===r.length&&n.tokenRefresher&&n.tokenRefresher.isRunning()&&n.tokenRefresher.stop(),yg(e,Object.assign(Object.assign({},n),{tokenObservers:r}))}function Qg(e){var t=e["app"],n=vg(t);let r=n.tokenRefresher;r||(r=function(n){const r=n["app"];return new Ig(async()=>{var e=vg(r);let t;if(t=e.token?await zg(n,!0):await zg(n),t.error)throw t.error},()=>!0,()=>{var e=vg(r);if(e.token){var t=e.token.issuedAtTimeMillis+.5*(e.token.expireTimeMillis-e.token.issuedAtTimeMillis)+3e5,e=e.token.expireTimeMillis-3e5,t=Math.min(t,e);return Math.max(0,t-Date.now())}return 0},bg.RETRIAL_MIN_WAIT,bg.RETRIAL_MAX_WAIT)}(e),yg(t,Object.assign(Object.assign({},n),{tokenRefresher:r}))),!r.isRunning()&&n.isTokenAutoRefreshEnabled&&r.start()}function Yg(e,t){for(const n of vg(e).tokenObservers)try{"EXTERNAL"===n.type&&null!=t.error?n.error(t.error):n.next(t)}catch(e){}}function Jg(e){return 0<e.expireTimeMillis-Date.now()}class Xg{constructor(e,t){this.app=e,this.platformLoggerProvider=t}_delete(){var e=vg(this.app)["tokenObservers"];for(const t of e)Gg(this.app,t.next);return Promise.resolve()}}const Zg="https://www.google.com/recaptcha/api.js",em="https://www.google.com/recaptcha/enterprise.js";function tm(t,n){var e=vg(t);const r=new rd;yg(t,Object.assign(Object.assign({},e),{reCAPTCHAState:{initialized:r}}));const i=im(t);e=Eg(!1);return e?rm(t,n,e,i,r):function(e){const t=document.createElement("script");t.src=Zg,t.onload=e,document.head.appendChild(t)}(()=>{var e=Eg(!1);if(!e)throw new Error("no recaptcha");rm(t,n,e,i,r)}),r.promise}function nm(t,n){var e=vg(t);const r=new rd;yg(t,Object.assign(Object.assign({},e),{reCAPTCHAState:{initialized:r}}));const i=im(t);e=Eg(!0);return e?rm(t,n,e,i,r):function(e){const t=document.createElement("script");t.src=em,t.onload=e,document.head.appendChild(t)}(()=>{var e=Eg(!0);if(!e)throw new Error("no recaptcha");rm(t,n,e,i,r)}),r.promise}function rm(r,i,s,o,a){s.ready(()=>{var e,t,n;e=r,t=s.render(o,{sitekey:i,size:"invisible"}),n=vg(e),yg(e,Object.assign(Object.assign({},n),{reCAPTCHAState:Object.assign(Object.assign({},n.reCAPTCHAState),{widgetId:t})})),a.resolve(s)})}function im(e){var t=`fire_app_check_${e.name}`;const n=document.createElement("div");return n.id=t,n.style.display="none",document.body.appendChild(n),t}async function sm(r){kg(r);const i=await vg(r).reCAPTCHAState.initialized.promise;return new Promise((e,t)=>{const n=vg(r).reCAPTCHAState;i.ready(()=>{e(i.execute(n.widgetId,{action:"fire_app_check"}))})})}class om{constructor(e){this._siteKey=e,this._throttleData=null}async getToken(){um(this._throttleData);var t=await sm(this._app).catch(e=>{throw Tg.create("recaptcha-error")});let e;try{e=await Ag(function(e,t){var{projectId:n,appId:r,apiKey:i}=e.options;return{url:`${_g}/projects/${n}/apps/${r}:exchangeRecaptchaToken?key=${i}`,body:{recaptcha_token:t}}}(this._app,t),this._platformLoggerProvider)}catch(e){throw"fetch-status-error"===e.code?(this._throttleData=lm(Number(null===(t=e.customData)||void 0===t?void 0:t.httpStatus),this._throttleData),Tg.create("throttled",{time:Sg(this._throttleData.allowRequestsAfter-Date.now()),httpStatus:this._throttleData.httpStatus})):e}return this._throttleData=null,e}initialize(e){this._app=e,this._platformLoggerProvider=dp(e,"platform-logger"),tm(e,this._siteKey).catch(()=>{})}isEqual(e){return e instanceof om&&this._siteKey===e._siteKey}}class am{constructor(e){this._siteKey=e,this._throttleData=null}async getToken(){um(this._throttleData);var t=await sm(this._app).catch(e=>{throw Tg.create("recaptcha-error")});let e;try{e=await Ag(function(e,t){var{projectId:n,appId:r,apiKey:i}=e.options;return{url:`${_g}/projects/${n}/apps/${r}:exchangeRecaptchaEnterpriseToken?key=${i}`,body:{recaptcha_enterprise_token:t}}}(this._app,t),this._platformLoggerProvider)}catch(e){throw"fetch-status-error"===e.code?(this._throttleData=lm(Number(null===(t=e.customData)||void 0===t?void 0:t.httpStatus),this._throttleData),Tg.create("throttled",{time:Sg(this._throttleData.allowRequestsAfter-Date.now()),httpStatus:this._throttleData.httpStatus})):e}return this._throttleData=null,e}initialize(e){this._app=e,this._platformLoggerProvider=dp(e,"platform-logger"),nm(e,this._siteKey).catch(()=>{})}isEqual(e){return e instanceof am&&this._siteKey===e._siteKey}}class cm{constructor(e){this._customProviderOptions=e}async getToken(){var e=await this._customProviderOptions.getToken(),t=function(e){const t=wd(e).claims;return"object"==typeof t&&t.hasOwnProperty("iat")?t.iat:null}(e.token),t=null!==t&&t<Date.now()&&0<t?1e3*t:Date.now();return Object.assign(Object.assign({},e),{issuedAtTimeMillis:t})}initialize(e){this._app=e}isEqual(e){return e instanceof cm&&this._customProviderOptions.getToken.toString()===e._customProviderOptions.getToken.toString()}}function lm(e,t){if(404===e||403===e)return{backoffCount:1,allowRequestsAfter:Date.now()+864e5,httpStatus:e};var n=t?t.backoffCount:0,r=Wd(n,1e3,2);return{backoffCount:n+1,allowRequestsAfter:Date.now()+r,httpStatus:e}}function um(e){if(e&&Date.now()-e.allowRequestsAfter<=0)throw Tg.create("throttled",{time:Sg(e.allowRequestsAfter-Date.now()),httpStatus:e.httpStatus})}function hm(e=vp(),t){const n=dp(e=$d(e),"app-check");if(mg.initialized||$g(),Bg()&&Wg().then(e=>console.log(`App Check debug token: ${e}. You will need to add it to your app's App Check settings in the Firebase console for it to work.`)),n.isInitialized()){var r=n.getImmediate();const i=n.getOptions();if(i.isTokenAutoRefreshEnabled===t.isTokenAutoRefreshEnabled&&i.provider.isEqual(t.provider))return r;throw Tg.create("already-initialized",{appName:e.name})}r=n.initialize({options:t});return function(t,e,n){const r=vg(t),i=Object.assign(Object.assign({},r),{activated:!0});i.provider=e,i.cachedTokenPromise=jg(t).then(e=>(e&&Jg(e)&&(yg(t,Object.assign(Object.assign({},vg(t)),{token:e})),Yg(t,{token:e.token})),e)),i.isTokenAutoRefreshEnabled=void 0===n?t.automaticDataCollectionEnabled:n,yg(t,i),i.provider.initialize(t)}(e,t.provider,t.isTokenAutoRefreshEnabled),vg(e).isTokenAutoRefreshEnabled&&Hg(r,"INTERNAL",()=>{}),r}const dm="app-check-internal";hp(new Kd("app-check",e=>{var t,n=e.getProvider("app").getImmediate(),r=e.getProvider("platform-logger");return t=n,e=r,new Xg(t,e)},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{e.getProvider(dm).initialize()})),hp(new Kd(dm,e=>{var t,n=e.getProvider("app-check").getImmediate();return t=n,{getToken:e=>zg(t,e),addTokenListener:e=>Hg(t,"INTERNAL",e),removeTokenListener:e=>Gg(t.app,e)}},"PUBLIC").setInstantiationMode("EXPLICIT")),_p("@firebase/app-check","0.5.3");const pm=new md("appCheck","AppCheck",{"use-before-activation":"App Check is being used before activate() is called for FirebaseApp {$appName}. Call activate() before instantiating other Firebase services."});class fm{constructor(e){this.app=e}activate(e,t){let n;n="string"==typeof e?new om(e):e instanceof am||e instanceof om||e instanceof cm?e:new cm({getToken:e.getToken}),this._delegate=hm(this.app,{provider:n,isTokenAutoRefreshEnabled:t})}setTokenAutoRefreshEnabled(e){if(!this._delegate)throw pm.create("use-before-activation",{appName:this.app.name});!function(e,t){var n=e.app;const r=vg(n);r.tokenRefresher&&(!0===t?r.tokenRefresher.start():r.tokenRefresher.stop()),yg(n,Object.assign(Object.assign({},r),{isTokenAutoRefreshEnabled:t}))}(this._delegate,e)}getToken(e){if(!this._delegate)throw pm.create("use-before-activation",{appName:this.app.name});return async function(e,t){var n=await zg(e,t);if(n.error)throw n.error;return{token:n.token}}(this._delegate,e)}onTokenChanged(e,t,n){if(!this._delegate)throw pm.create("use-before-activation",{appName:this.app.name});return function(e,t,n){let r=()=>{},i=()=>{};return r=null!=t.next?t.next.bind(t):t,null!=t.error?i=t.error.bind(t):n&&(i=n),Hg(e,"EXTERNAL",r,i),()=>Gg(e.app,r)}(this._delegate,e,t)}}const gm=e=>{var t=e.getProvider("app-compat").getImmediate();return new fm(t)};function mm(e,t){var n={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n}Cp.INTERNAL.registerComponent(new Kd("appCheck-compat",gm,"PUBLIC").setServiceProps({ReCaptchaEnterpriseProvider:am,ReCaptchaV3Provider:om,CustomProvider:cm})),Cp.registerVersion("@firebase/app-check-compat","0.2.3");const vm={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"},ym={EMAIL_SIGNIN:"EMAIL_SIGNIN",PASSWORD_RESET:"PASSWORD_RESET",RECOVER_EMAIL:"RECOVER_EMAIL",REVERT_SECOND_FACTOR_ADDITION:"REVERT_SECOND_FACTOR_ADDITION",VERIFY_AND_CHANGE_EMAIL:"VERIFY_AND_CHANGE_EMAIL",VERIFY_EMAIL:"VERIFY_EMAIL"};function _m(){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."}}function wm(){return{"admin-restricted-operation":"This operation is restricted to administrators only.","argument-error":"","app-not-authorized":"This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.","app-not-installed":"The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.","captcha-check-failed":"The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.","code-expired":"The SMS code has expired. Please re-send the verification code to try again.","cordova-not-ready":"Cordova framework is not ready.","cors-unsupported":"This browser is not supported.","credential-already-in-use":"This credential is already associated with a different user account.","custom-token-mismatch":"The custom token corresponds to a different audience.","requires-recent-login":"This operation is sensitive and requires recent authentication. Log in again before retrying this request.","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.","dynamic-link-not-activated":"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.","email-change-needs-verification":"Multi-factor users must always have a verified email.","email-already-in-use":"The email address is already in use by another account.","emulator-config-failed":'Auth instance has already been used to make a network call. Auth can no longer be configured to use the emulator. Try calling "connectAuthEmulator()" sooner.',"expired-action-code":"The action code has expired.","cancelled-popup-request":"This operation has been cancelled due to another conflicting popup being opened.","internal-error":"An internal AuthError has occurred.","invalid-app-credential":"The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.","invalid-app-id":"The mobile app identifier is not registed for the current project.","invalid-user-token":"This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.","invalid-auth-event":"An internal AuthError has occurred.","invalid-verification-code":"The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure to use the verification code provided by the user.","invalid-continue-uri":"The continue URL provided in the request is invalid.","invalid-cordova-configuration":"The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.","invalid-custom-token":"The custom token format is incorrect. Please check the documentation.","invalid-dynamic-link-domain":"The provided dynamic link domain is not configured or authorized for the current project.","invalid-email":"The email address is badly formatted.","invalid-emulator-scheme":"Emulator URL must start with a valid scheme (http:// or https://).","invalid-api-key":"Your API key is invalid, please check you have copied it correctly.","invalid-cert-hash":"The SHA-1 certificate hash provided is invalid.","invalid-credential":"The supplied auth credential is malformed or has expired.","invalid-message-payload":"The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-multi-factor-session":"The request does not contain a valid proof of first factor successful sign-in.","invalid-oauth-provider":"EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.","invalid-oauth-client-id":"The OAuth client ID provided is either invalid or does not match the specified API key.","unauthorized-domain":"This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.","invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","wrong-password":"The password is invalid or the user does not have a password.","invalid-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","invalid-phone-number":"The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].","invalid-provider-id":"The specified provider ID is invalid.","invalid-recipient-email":"The email corresponding to this action failed to send as the provided recipient email address is invalid.","invalid-sender":"The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-verification-id":"The verification ID used to create the phone auth credential is invalid.","invalid-tenant-id":"The Auth instance's tenant ID is invalid.","missing-android-pkg-name":"An Android Package Name must be provided if the Android App is required to be installed.","auth-domain-config-required":"Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.","missing-app-credential":"The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.","missing-verification-code":"The phone auth credential was created with an empty SMS verification code.","missing-continue-uri":"A continue URL must be provided in the request.","missing-iframe-start":"An internal AuthError has occurred.","missing-ios-bundle-id":"An iOS Bundle ID must be provided if an App Store ID is provided.","missing-or-invalid-nonce":"The request does not contain a valid nonce. This can occur if the SHA-256 hash of the provided raw nonce does not match the hashed nonce in the ID token payload.","missing-multi-factor-info":"No second factor identifier is provided.","missing-multi-factor-session":"The request is missing proof of first factor successful sign-in.","missing-phone-number":"To send verification codes, provide a phone number for the recipient.","missing-verification-id":"The phone auth credential was created with an empty verification ID.","app-deleted":"This instance of FirebaseApp has been deleted.","multi-factor-info-not-found":"The user does not have a second factor matching the identifier provided.","multi-factor-auth-required":"Proof of ownership of a second factor is required to complete sign-in.","account-exists-with-different-credential":"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.","network-request-failed":"A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred.","no-auth-event":"An internal AuthError has occurred.","no-such-provider":"User was not linked to an account with the given provider.","null-user":"A null user object was provided as the argument for an operation which requires a non-null user object.","operation-not-allowed":"The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.","operation-not-supported-in-this-environment":'This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.',"popup-blocked":"Unable to establish a connection with the popup. It may have been blocked by the browser.","popup-closed-by-user":"The popup has been closed by the user before finalizing the operation.","provider-already-linked":"User can only be linked to one identity for the given provider.","quota-exceeded":"The project's quota for this operation has been exceeded.","redirect-cancelled-by-user":"The redirect operation has been cancelled by the user before finalizing.","redirect-operation-pending":"A redirect sign-in operation is already pending.","rejected-credential":"The request contains malformed or mismatching credentials.","second-factor-already-in-use":"The second factor is already enrolled on this account.","maximum-second-factor-count-exceeded":"The maximum allowed number of second factors on a user has been exceeded.","tenant-id-mismatch":"The provided tenant ID does not match the Auth instance's tenant ID",timeout:"The operation has timed out.","user-token-expired":"The user's credential is no longer valid. The user must sign in again.","too-many-requests":"We have blocked all requests from this device due to unusual activity. Try again later.","unauthorized-continue-uri":"The domain of the continue URL is not whitelisted. Please whitelist the domain in the Firebase console.","unsupported-first-factor":"Enrolling a second factor or signing in with a multi-factor account requires sign-in with a supported first factor.","unsupported-persistence-type":"The current environment does not support the specified persistence type.","unsupported-tenant-operation":"This operation is not supported in a multi-tenant context.","unverified-email":"The operation requires a verified email.","user-cancelled":"The user did not grant your application the permissions it requested.","user-not-found":"There is no user record corresponding to this identifier. The user may have been deleted.","user-disabled":"The user account has been disabled by an administrator.","user-mismatch":"The supplied credentials do not correspond to the previously signed in user.","user-signed-out":"","weak-password":"The password must be 6 characters long or more.","web-storage-unsupported":"This browser is not supported or 3rd party cookies and data may be disabled.","already-initialized":"initializeAuth() has already been called with different options. To avoid this error, call initializeAuth() with the same options as when it was originally called, or call getAuth() to return the already initialized instance."}}const bm=_m,Im=new md("auth","Firebase",_m()),Tm=new ep("@firebase/auth");function Em(e,...t){Tm.logLevel<=$h.ERROR&&Tm.error(`Auth (${gp}): ${e}`,...t)}function km(e,...t){throw Nm(e,...t)}function Sm(e,...t){return Nm(e,...t)}function Cm(e,t,n){var r=Object.assign(Object.assign({},bm()),{[t]:n});const i=new md("auth","Firebase",r);return i.create(t,{appName:e.name})}function Am(e,t,n){if(!(t instanceof n))throw n.name!==t.constructor.name&&km(e,"argument-error"),Cm(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.`+"Did you pass a reference from a different Auth SDK?")}function Nm(e,...t){if("string"==typeof e)return Im.create(e,...t);{var n=t[0];const r=[...t.slice(1)];return r[0]&&(r[0].appName=e.name),e._errorFactory.create(n,...r)}}function Rm(e,t,...n){if(!e)throw Nm(t,...n)}function Pm(e){var t="INTERNAL ASSERTION FAILED: "+e;throw Em(t),new Error(t)}function xm(e,t){e||Pm(t)}const Dm=new Map;function Om(e){xm(e instanceof Function,"Expected a class definition");let t=Dm.get(e);return t?xm(t instanceof e,"Instance stored in cache mismatched with class"):(t=new e,Dm.set(e,t)),t}function Mm(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.href)||""}function Lm(){return"http:"===Fm()||"https:"===Fm()}function Fm(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.protocol)||null}class Um{constructor(e,t){xm((this.shortDelay=e)<(this.longDelay=t),"Short delay should be less than long delay!"),this.isMobile=od()||ld()}get(){return"undefined"!=typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&(Lm()||cd()||"connection"in navigator)&&!navigator.onLine?Math.min(5e3,this.shortDelay):this.isMobile?this.longDelay:this.shortDelay}}function jm(e,t){xm(e.emulator,"Emulator should always be set here");var n=e.emulator["url"];return t?`${n}${t.startsWith("/")?t.slice(1):t}`:n}class qm{static initialize(e,t,n){this.fetchImpl=e,t&&(this.headersImpl=t),n&&(this.responseImpl=n)}static fetch(){return this.fetchImpl||("undefined"!=typeof self&&"fetch"in self?self.fetch:void Pm("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}static headers(){return this.headersImpl||("undefined"!=typeof self&&"Headers"in self?self.Headers:void Pm("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}static response(){return this.responseImpl||("undefined"!=typeof self&&"Response"in self?self.Response:void Pm("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}}const Vm={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:"internal-error",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",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"},Bm=new Um(3e4,6e4);function Wm(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function $m(i,s,o,a,e={}){return Km(i,e,async()=>{let e={},t={};a&&("GET"===s?t=a:e={body:JSON.stringify(a)});var n=Cd(Object.assign({key:i.config.apiKey},t)).slice(1);const r=await i._getAdditionalHeaders();return r["Content-Type"]="application/json",i.languageCode&&(r["X-Firebase-Locale"]=i.languageCode),qm.fetch()(Hm(i,i.config.apiHost,o,n),Object.assign({method:s,headers:r,referrerPolicy:"no-referrer"},e))})}async function Km(t,e,n){t._canInitEmulator=!1;var r=Object.assign(Object.assign({},Vm),e);try{const o=new Gm(t),a=await Promise.race([n(),o.promise]);o.clearNetworkTimeout();var i=await a.json();if("needConfirmation"in i)throw Qm(t,"account-exists-with-different-credential",i);if(a.ok&&!("errorMessage"in i))return i;{const c=a.ok?i.errorMessage:i.error.message,[l,u]=c.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===l)throw Qm(t,"credential-already-in-use",i);if("EMAIL_EXISTS"===l)throw Qm(t,"email-already-in-use",i);var s=r[l]||l.toLowerCase().replace(/[_\s]+/g,"-");if(u)throw Cm(t,s,u);km(t,s)}}catch(e){if(e instanceof gd)throw e;km(t,"network-request-failed")}}async function zm(e,t,n,r,i={}){var s=await $m(e,t,n,r,i);return"mfaPendingCredential"in s&&km(e,"multi-factor-auth-required",{_serverResponse:s}),s}function Hm(e,t,n,r){var i=`${t}${n}?${r}`;return e.config.emulator?jm(e.config,i):`${e.config.apiScheme}://${i}`}class Gm{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(Sm(this.auth,"timeout")),Bm.get())})}clearNetworkTimeout(){clearTimeout(this.timer)}}function Qm(e,t,n){const r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=Sm(e,t,r);return i.customData._tokenResponse=n,i}function Ym(e){if(e)try{const t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}function Jm(e){return 1e3*Number(e)}function Xm(e){var[t,n,r]=e.split(".");if(void 0===t||void 0===n||void 0===r)return Em("JWT malformed, contained fewer than 3 sections"),null;try{var i=td(n);return i?JSON.parse(i):(Em("Failed to decode base64 JWT payload"),null)}catch(e){return Em("Caught error parsing JWT payload as JSON",e),null}}async function Zm(t,n,e=!1){if(e)return n;try{return n}catch(e){throw e instanceof gd&&(n=[e["code"]][0],"auth/user-disabled"===n||"auth/user-token-expired"===n)&&t.auth.currentUser===t&&await t.auth.signOut(),e}}class ev{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){if(e){var t=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),t}this.errorBackoff=3e4;t=(null!==(t=this.user.stsTokenManager.expirationTime)&&void 0!==t?t:0)-Date.now()-3e5;return Math.max(0,t)}schedule(e=!1){var t;this.isRunning&&(t=this.getInterval(e),this.timerId=setTimeout(async()=>{await this.iteration()},t))}async iteration(){try{await this.user.getIdToken(!0)}catch(e){return void("auth/network-request-failed"===e.code&&this.schedule(!0))}this.schedule()}}class tv{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=Ym(this.lastLoginAt),this.creationTime=Ym(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function nv(e){var t=e.auth,n=await e.getIdToken(),r=await Zm(e,async function(e,t){return $m(e,"POST","/v1/accounts:lookup",t)}(t,{idToken:n}));Rm(null==r?void 0:r.users.length,t,"internal-error");var i=r.users[0];e._notifyReloadListener(i);var s,o,t=null!==(n=i.providerUserInfo)&&void 0!==n&&n.length?i.providerUserInfo.map(e=>{var t=e["providerId"],n=mm(e,["providerId"]);return{providerId:t,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}}):[],r=(s=e.providerData,o=t,[...s.filter(t=>!o.some(e=>e.providerId===t.providerId)),...o]),n=e.isAnonymous,t=!(e.email&&i.passwordHash||null!==r&&r.length),t=!!n&&t,t={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:r,metadata:new tv(i.createdAt,i.lastLoginAt),isAnonymous:t};Object.assign(e,t)}class rv{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){Rm(e.idToken,"internal-error"),Rm(void 0!==e.idToken,"internal-error"),Rm(void 0!==e.refreshToken,"internal-error");var t,n,n="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):(t=e.idToken,Rm(n=Xm(t),"internal-error"),Rm(void 0!==n.exp,"internal-error"),Rm(void 0!==n.iat,"internal-error"),Number(n.exp)-Number(n.iat));this.updateTokensAndExpiration(e.idToken,e.refreshToken,n)}async getToken(e,t=!1){return Rm(!this.accessToken||this.refreshToken,e,"user-token-expired"),t||!this.accessToken||this.isExpired?this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null:this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){var i,s,{accessToken:n,refreshToken:r,expiresIn:o}=(s=t,await{accessToken:(o=await Km(i=e,{},async()=>{var e=Cd({grant_type:"refresh_token",refresh_token:s}).slice(1),{tokenApiHost:t,apiKey:n}=i.config,n=Hm(i,t,"/v1/token",`key=${n}`);const r=await i._getAdditionalHeaders();return r["Content-Type"]="application/x-www-form-urlencoded",qm.fetch()(n,{method:"POST",headers:r,body:e})})).access_token,expiresIn:o.expires_in,refreshToken:o.refresh_token});this.updateTokensAndExpiration(n,r,Number(o))}updateTokensAndExpiration(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(e,t){var{refreshToken:n,accessToken:r,expirationTime:i}=t;const s=new rv;return n&&(Rm("string"==typeof n,"internal-error",{appName:e}),s.refreshToken=n),r&&(Rm("string"==typeof r,"internal-error",{appName:e}),s.accessToken=r),i&&(Rm("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 rv,this.toJSON())}_performRefresh(){return Pm("not implemented")}}function iv(e,t){Rm("string"==typeof e||void 0===e,"internal-error",{appName:t})}class sv{constructor(e){var{uid:t,auth:n,stsTokenManager:r}=e,i=mm(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.emailVerified=!1,this.isAnonymous=!1,this.tenantId=null,this.providerData=[],this.proactiveRefresh=new ev(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.metadata=new tv(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){var t=await Zm(this,this.stsTokenManager.getToken(this.auth,e));return Rm(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return async function(e,t=!1){const n=$d(e);var r=await n.getIdToken(t),i=Xm(r);Rm(i&&i.exp&&i.auth_time&&i.iat,n.auth,"internal-error");var s="object"==typeof i.firebase?i.firebase:void 0,o=null==s?void 0:s.sign_in_provider;return{claims:i,token:r,authTime:Ym(Jm(i.auth_time)),issuedAtTime:Ym(Jm(i.iat)),expirationTime:Ym(Jm(i.exp)),signInProvider:o||null,signInSecondFactor:(null==s?void 0:s.sign_in_second_factor)||null}}(this,e)}reload(){return async function(e){const t=$d(e);await nv(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}(this)}_assign(e){this!==e&&(Rm(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){return new sv(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}))}_onReload(e){Rm(!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 nv(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){var e=await this.getIdToken();return await Zm(this,async function(e,t){return $m(e,"POST","/v1/accounts:delete",t)}(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var n=null!==(o=t.displayName)&&void 0!==o?o:void 0,r=null!==(g=t.email)&&void 0!==g?g:void 0,i=null!==(a=t.phoneNumber)&&void 0!==a?a:void 0,s=null!==(l=t.photoURL)&&void 0!==l?l:void 0,o=null!==(c=t.tenantId)&&void 0!==c?c:void 0,a=null!==(g=t._redirectEventId)&&void 0!==g?g:void 0,c=null!==(l=t.createdAt)&&void 0!==l?l:void 0,l=null!==(g=t.lastLoginAt)&&void 0!==g?g:void 0;const{uid:u,emailVerified:h,isAnonymous:d,providerData:p,stsTokenManager:f}=t;Rm(u&&f,e,"internal-error");var g=rv.fromJSON(this.name,f);Rm("string"==typeof u,e,"internal-error"),iv(n,e.name),iv(r,e.name),Rm("boolean"==typeof h,e,"internal-error"),Rm("boolean"==typeof d,e,"internal-error"),iv(i,e.name),iv(s,e.name),iv(o,e.name),iv(a,e.name),iv(c,e.name),iv(l,e.name);const m=new sv({uid:u,auth:e,email:r,emailVerified:h,displayName:n,isAnonymous:d,photoURL:s,phoneNumber:i,tenantId:o,stsTokenManager:g,createdAt:c,lastLoginAt:l});return p&&Array.isArray(p)&&(m.providerData=p.map(e=>Object.assign({},e))),a&&(m._redirectEventId=a),m}static async _fromIdTokenResponse(e,t,n=!1){const r=new rv;r.updateFromServerResponse(t);var i=new sv({uid:t.localId,auth:e,stsTokenManager:r,isAnonymous:n});return await nv(i),i}}class ov{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){var t=this.storage[e];return void 0===t?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}ov.type="NONE";const av=ov;function cv(e,t,n){return`firebase:${e}:${t}:${n}`}class lv{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;var{config:r,name:i}=this.auth;this.fullUserKey=cv(this.userKey,r.apiKey,i),this.fullPersistenceKey=cv("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(){var e=await this.persistence._get(this.fullUserKey);return e?sv._fromJSON(this.auth,e):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence!==e){var t=await this.getCurrentUser();return await this.removeCurrentUser(),this.persistence=e,t?this.setCurrentUser(t):void 0}}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,n="authUser"){if(!t.length)return new lv(Om(av),e,n);const r=(await Promise.all(t.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e);let i=r[0]||Om(av);const s=cv(n,e.config.apiKey,e.name);let o=null;for(const u of t)try{var a=await u._get(s);if(a){var c=sv._fromJSON(e,a);u!==i&&(o=c),i=u;break}}catch(e){}var l=r.filter(e=>e._shouldAllowMigration);return i._shouldAllowMigration&&l.length&&(i=l[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 lv(i,e,n)}}function uv(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(fv(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(hv(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(mv(t))return"Blackberry";if(vv(t))return"Webos";if(dv(t))return"Safari";if((t.includes("chrome/")||pv(t))&&!t.includes("edge/"))return"Chrome";if(gv(t))return"Android";var n=e.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/);return 2===(null==n?void 0:n.length)?n[1]:"Other"}function hv(e=sd()){return/firefox\//i.test(e)}function dv(e=sd()){const t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function pv(e=sd()){return/crios\//i.test(e)}function fv(e=sd()){return/iemobile/i.test(e)}function gv(e=sd()){return/android/i.test(e)}function mv(e=sd()){return/blackberry/i.test(e)}function vv(e=sd()){return/webos/i.test(e)}function yv(e=sd()){return/iphone|ipad|ipod/i.test(e)}function _v(e=sd()){return yv(e)||gv(e)||vv(e)||mv(e)||/windows phone/i.test(e)||fv(e)}function wv(e,t=[]){let n;switch(e){case"Browser":n=uv(sd());break;case"Worker":n=`${uv(sd())}-${e}`;break;default:n=e}var r=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${gp}/${r}`}class bv{constructor(e,t){this.app=e,this.config=t,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Tv(this),this.idTokenSubscription=new Tv(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=Im,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=t.sdkClientVersion}_initializeWithPersistence(t,n){return n&&(this._popupRedirectResolver=Om(n)),this._initializationPromise=this.queue(async()=>{var e;if(!this._deleted&&(this.persistenceManager=await lv.create(this,t),!this._deleted)){if(null!==(e=this._popupRedirectResolver)&&void 0!==e&&e._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(e){}await this.initializeCurrentUser(n),this.lastNotifiedUid=(null===(e=this.currentUser)||void 0===e?void 0:e.uid)||null,this._deleted||(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(!this._deleted){var e=await this.assertedPersistence.getCurrentUser();if(this.currentUser||e)return this.currentUser&&e&&this.currentUser.uid===e.uid?(this._currentUser._assign(e),void await this.currentUser.getIdToken()):void await this._updateCurrentUser(e)}}async initializeCurrentUser(e){var t,n,r;let i=await this.assertedPersistence.getCurrentUser();return e&&this.config.authDomain&&(await this.getOrInitRedirectPersistenceManager(),t=null===(r=this.redirectUser)||void 0===r?void 0:r._redirectEventId,n=null===i||void 0===i?void 0:i._redirectEventId,r=await this.tryRedirectSignIn(e),t&&t!==n||null==r||!r.user||(i=r.user)),i?i._redirectEventId?(Rm(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===i._redirectEventId?this.directlySetCurrentUser(i):this.reloadAndSetCurrentUserOrClear(i)):this.reloadAndSetCurrentUserOrClear(i):this.directlySetCurrentUser(null)}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 nv(e)}catch(e){if("auth/network-request-failed"!==e.code)return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;var e=navigator;return e.languages&&e.languages[0]||e.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(e){const t=e?$d(e):null;return t&&Rm(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e){if(!this._deleted)return e&&Rm(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null)}setPersistence(e){return this.queue(async()=>{await this.assertedPersistence.setPersistence(Om(e))})}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(e){this._errorFactory=new md("auth","Firebase",e())}onAuthStateChanged(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}onIdTokenChanged(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}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){const n=await this.getOrInitRedirectPersistenceManager(t);return null===e?n.removeCurrentUser():n.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){var t;return this.redirectPersistenceManager||(Rm(t=e&&Om(e)||this._popupRedirectResolver,this,"argument-error"),this.redirectPersistenceManager=await lv.create(this,[Om(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()),this.redirectPersistenceManager}async _redirectUserForId(e){var t;return this._isInitialized&&await this.queue(async()=>{}),(null===(t=this._currentUser)||void 0===t?void 0:t._redirectEventId)===e?this._currentUser:(null===(t=this.redirectUser)||void 0===t?void 0:t._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;this._isInitialized&&(this.idTokenSubscription.next(this.currentUser),e=null!==(e=null===(e=this.currentUser)||void 0===e?void 0:e.uid)&&void 0!==e?e:null,this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser)))}registerStateListener(e,t,n,r){if(this._deleted)return()=>{};const i="function"==typeof t?t:t.next.bind(t),s=this._isInitialized?Promise.resolve():this._initializationPromise;return Rm(s,this,"internal-error"),s.then(()=>i(this.currentUser)),"function"==typeof t?e.addObserver(t,n,r):e.addObserver(t)}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&(this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh()),(this.currentUser=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 Rm(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=wv(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){const e={"X-Client-Version":this.clientVersion};return this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId),e}}function Iv(e){return $d(e)}class Tv{constructor(e){this.auth=e,this.observer=null,this.addObserver=Pd(e=>this.observer=e)}get next(){return Rm(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}function Ev(e,t,n){const r=Iv(e);Rm(r._canInitEmulator,r,"emulator-config-failed"),Rm(/^https?:\/\//.test(t),r,"invalid-emulator-scheme");var i=!(null==n||!n.disableWarnings);const s=kv(t);var{host:o,port:a}=function(e){const t=kv(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);{if(i){var s=i[1];return{host:s,port:Sv(r.substr(s.length+1))}}var[o,s]=r.split(":");return{host:o,port:Sv(s)}}}(t);r.config.emulator={url:`${s}//${o}${null===a?"":`:${a}`}/`},r.settings.appVerificationDisabledForTesting=!0,r.emulatorConfig=Object.freeze({host:o,port:a,protocol:s.replace(":",""),options:Object.freeze({disableWarnings:i})}),i||function(){function e(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}"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())}()}function kv(e){var t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function Sv(e){if(!e)return null;var t=Number(e);return isNaN(t)?null:t}class Cv{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return Pm("not implemented")}_getIdTokenResponse(e){return Pm("not implemented")}_linkToIdToken(e,t){return Pm("not implemented")}_getReauthenticationResolver(e){return Pm("not implemented")}}async function Av(e,t){return $m(e,"POST","/v1/accounts:resetPassword",Wm(e,t))}async function Nv(e,t){return $m(e,"POST","/v1/accounts:update",t)}async function Rv(e,t){return $m(e,"POST","/v1/accounts:sendOobCode",Wm(e,t))}class Pv extends Cv{constructor(e,t,n,r=null){super("password",n),this._email=e,this._password=t,this._tenantId=r}static _fromEmailAndPassword(e,t){return new Pv(e,t,"password")}static _fromEmailAndCode(e,t,n=null){return new Pv(e,t,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){var t="string"==typeof e?JSON.parse(e):e;if(null!=t&&t.email&&null!=t&&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 async function(e,t){return zm(e,"POST","/v1/accounts:signInWithPassword",Wm(e,t))}(e,{returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(e,t){return zm(e,"POST","/v1/accounts:signInWithEmailLink",Wm(e,t))}(e,{email:this._email,oobCode:this._password});default:km(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return Nv(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(e,t){return zm(e,"POST","/v1/accounts:signInWithEmailLink",Wm(e,t))}(e,{idToken:t,email:this._email,oobCode:this._password});default:km(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function xv(e,t){return zm(e,"POST","/v1/accounts:signInWithIdp",Wm(e,t))}class Dv extends Cv{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new Dv(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):km("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){var t="string"==typeof e?JSON.parse(e):e,{providerId:n,signInMethod:r}=t,t=mm(t,["providerId","signInMethod"]);if(!n||!r)return null;const i=new Dv(n,r);return i.idToken=t.idToken||void 0,i.accessToken=t.accessToken||void 0,i.secret=t.secret,i.nonce=t.nonce,i.pendingToken=t.pendingToken||null,i}_getIdTokenResponse(e){return xv(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,xv(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,xv(e,t)}buildRequest(){const e={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=Cd(t)}return e}}const Ov={USER_NOT_FOUND:"user-not-found"};class Mv extends Cv{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new Mv({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new Mv({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return async function(e,t){return zm(e,"POST","/v1/accounts:signInWithPhoneNumber",Wm(e,t))}(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return async function(e,t){var n=await zm(e,"POST","/v1/accounts:signInWithPhoneNumber",Wm(e,t));if(n.temporaryProof)throw Qm(e,"account-exists-with-different-credential",n);return n}(e,Object.assign({idToken:t},this._makeVerificationRequest()))}_getReauthenticationResolver(e){return async function(e,t){return zm(e,"POST","/v1/accounts:signInWithPhoneNumber",Wm(e,Object.assign(Object.assign({},t),{operation:"REAUTH"})),Ov)}(e,this._makeVerificationRequest())}_makeVerificationRequest(){var{temporaryProof:e,phoneNumber:t,verificationId:n,verificationCode:r}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:n,code:r}}toJSON(){const 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){var{verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}=e="string"==typeof e?JSON.parse(e):e;return n||t||r||i?new Mv({verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}):null}}class Lv{constructor(e){var t=Ad(Nd(e)),n=null!==(r=t.apiKey)&&void 0!==r?r:null,r=null!==(i=t.oobCode)&&void 0!==i?i:null,i=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!==(i=t.mode)&&void 0!==i?i:null);Rm(n&&r&&i,"argument-error"),this.apiKey=n,this.operation=i,this.code=r,this.continueUrl=null!==(r=t.continueUrl)&&void 0!==r?r:null,this.languageCode=null!==(r=t.languageCode)&&void 0!==r?r:null,this.tenantId=null!==(t=t.tenantId)&&void 0!==t?t:null}static parseLink(e){var t,n,r,t=(t=Ad(Nd(e=e)).link,n=t?Ad(Nd(t)).deep_link_id:null,((r=Ad(Nd(e)).deep_link_id)?Ad(Nd(r)).link:null)||r||n||t||e);try{return new Lv(t)}catch(e){return null}}}class Fv{constructor(){this.providerId=Fv.PROVIDER_ID}static credential(e,t){return Pv._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){var n=Lv.parseLink(t);return Rm(n,"argument-error"),Pv._fromEmailAndCode(e,n.code,n.tenantId)}}Fv.PROVIDER_ID="password",Fv.EMAIL_PASSWORD_SIGN_IN_METHOD="password",Fv.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class Uv{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 jv extends Uv{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class qv extends jv{static credentialFromJSON(e){var t="string"==typeof e?JSON.parse(e):e;return Rm("providerId"in t&&"signInMethod"in t,"argument-error"),Dv._fromParams(t)}credential(e){return this._credential(Object.assign(Object.assign({},e),{nonce:e.rawNonce}))}_credential(e){return Rm(e.idToken||e.accessToken,"argument-error"),Dv._fromParams(Object.assign(Object.assign({},e),{providerId:this.providerId,signInMethod:this.providerId}))}static credentialFromResult(e){return qv.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return qv.oauthCredentialFromTaggedObject(e.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthIdToken:t,oauthAccessToken:n,oauthTokenSecret:r,pendingToken:i,nonce:s,providerId:o}=e;if(!(n||r||t||i))return null;if(!o)return null;try{return new qv(o)._credential({idToken:t,accessToken:n,nonce:s,pendingToken:i})}catch(e){return null}}}class Vv extends jv{constructor(){super("facebook.com")}static credential(e){return Dv._fromParams({providerId:Vv.PROVIDER_ID,signInMethod:Vv.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Vv.credentialFromTaggedObject(e)}static credentialFromError(e){return Vv.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return Vv.credential(e.oauthAccessToken)}catch(e){return null}}}Vv.FACEBOOK_SIGN_IN_METHOD="facebook.com",Vv.PROVIDER_ID="facebook.com";class Bv extends jv{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return Dv._fromParams({providerId:Bv.PROVIDER_ID,signInMethod:Bv.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return Bv.credentialFromTaggedObject(e)}static credentialFromError(e){return Bv.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthIdToken:t,oauthAccessToken:n}=e;if(!t&&!n)return null;try{return Bv.credential(t,n)}catch(e){return null}}}Bv.GOOGLE_SIGN_IN_METHOD="google.com",Bv.PROVIDER_ID="google.com";class Wv extends jv{constructor(){super("github.com")}static credential(e){return Dv._fromParams({providerId:Wv.PROVIDER_ID,signInMethod:Wv.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Wv.credentialFromTaggedObject(e)}static credentialFromError(e){return Wv.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return Wv.credential(e.oauthAccessToken)}catch(e){return null}}}Wv.GITHUB_SIGN_IN_METHOD="github.com",Wv.PROVIDER_ID="github.com";class $v extends Cv{constructor(e,t){super(e,e),this.pendingToken=t}_getIdTokenResponse(e){return xv(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,xv(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,xv(e,t)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(e){var{providerId:t,signInMethod:n,pendingToken:r}="string"==typeof e?JSON.parse(e):e;return t&&n&&r&&t===n?new $v(t,r):null}static _create(e,t){return new $v(e,t)}buildRequest(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}class Kv extends Uv{constructor(e){Rm(e.startsWith("saml."),"argument-error"),super(e)}static credentialFromResult(e){return Kv.samlCredentialFromTaggedObject(e)}static credentialFromError(e){return Kv.samlCredentialFromTaggedObject(e.customData||{})}static credentialFromJSON(e){var t=$v.fromJSON(e);return Rm(t,"argument-error"),t}static samlCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{pendingToken:t,providerId:n}=e;if(!t||!n)return null;try{return $v._create(n,t)}catch(e){return null}}}class zv extends jv{constructor(){super("twitter.com")}static credential(e,t){return Dv._fromParams({providerId:zv.PROVIDER_ID,signInMethod:zv.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return zv.credentialFromTaggedObject(e)}static credentialFromError(e){return zv.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return zv.credential(t,n)}catch(e){return null}}}async function Hv(e,t){return zm(e,"POST","/v1/accounts:signUp",Wm(e,t))}zv.TWITTER_SIGN_IN_METHOD="twitter.com",zv.PROVIDER_ID="twitter.com";class Gv{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){var i=await sv._fromIdTokenResponse(e,n,r),s=Qv(n);return new Gv({user:i,providerId:s,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);var r=Qv(n);return new Gv({user:e,providerId:r,_tokenResponse:n,operationType:t})}}function Qv(e){return e.providerId||("phoneNumber"in e?"phone":null)}class Yv extends gd{constructor(e,t,n,r){var i;super(t.code,t.message),this.operationType=n,this.user=r,Object.setPrototypeOf(this,Yv.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 Yv(e,t,n,r)}}function Jv(t,n,e,r){const i="reauthenticate"===n?e._getReauthenticationResolver(t):e._getIdTokenResponse(t);return i.catch(e=>{if("auth/multi-factor-auth-required"===e.code)throw Yv._fromErrorAndOperation(t,e,n,r);throw e})}function Xv(e){return new Set(e.map(({providerId:e})=>e).filter(e=>!!e))}async function Zv(e,t){const n=$d(e);await ty(!0,n,t);var r=(e=n.auth,t={idToken:await n.getIdToken(),deleteProvider:[t]},await $m(e,"POST","/v1/accounts:update",t))["providerUserInfo"];const i=Xv(r||[]);return n.providerData=n.providerData.filter(e=>i.has(e.providerId)),i.has("phone")||(n.phoneNumber=null),await n.auth._persistUserIfCurrent(n),n}async function ey(e,t,n=!1){var r=await Zm(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return Gv._forOperation(e,"link",r)}async function ty(e,t,n){await nv(t);const r=Xv(t.providerData);var i=!1===e?"provider-already-linked":"no-such-provider";Rm(r.has(n)===e,t.auth,i)}async function ny(e,t,n=!1){var r=e["auth"],i="reauthenticate";try{var s=await Zm(e,Jv(r,i,t,e),n);Rm(s.idToken,r,"internal-error");var o=Xm(s.idToken);Rm(o,r,"internal-error");var a=o["sub"];return Rm(e.uid===a,r,"user-mismatch"),Gv._forOperation(e,i,s)}catch(e){throw"auth/user-not-found"===(null==e?void 0:e.code)&&km(r,"user-mismatch"),e}}async function ry(e,t,n=!1){var r=await Jv(e,"signIn",t),r=await Gv._fromIdTokenResponse(e,"signIn",r);return n||await e._updateCurrentUser(r.user),r}async function iy(e,t){return ry(Iv(e),t)}async function sy(e,t){var n=$d(e);return await ty(!1,n,t.providerId),ey(n,t)}async function oy(e,t){return ny($d(e),t)}async function ay(e,t){const n=Iv(e);var r=await zm(n,"POST","/v1/accounts:signInWithCustomToken",Wm(n,{token:t,returnSecureToken:!0})),r=await Gv._fromIdTokenResponse(n,"signIn",r);return await n._updateCurrentUser(r.user),r}class cy{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?ly._fromServerResponse(e,t):km(e,"internal-error")}}class ly extends cy{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new ly(t)}}function uy(e,t,n){var r;Rm(0<(null===(r=n.url)||void 0===r?void 0:r.length),e,"invalid-continue-uri"),Rm(void 0===n.dynamicLinkDomain||0<n.dynamicLinkDomain.length,e,"invalid-dynamic-link-domain"),t.continueUrl=n.url,t.dynamicLinkDomain=n.dynamicLinkDomain,t.canHandleCodeInApp=n.handleCodeInApp,n.iOS&&(Rm(0<n.iOS.bundleId.length,e,"missing-ios-bundle-id"),t.iOSBundleId=n.iOS.bundleId),n.android&&(Rm(0<n.android.packageName.length,e,"missing-android-pkg-name"),t.androidInstallApp=n.android.installApp,t.androidMinimumVersionCode=n.android.minimumVersion,t.androidPackageName=n.android.packageName)}async function hy(e,t,n){var r=$d(e),i={requestType:"PASSWORD_RESET",email:t};n&&uy(r,i,n),await Rv(r,i)}async function dy(e,t){await $m(e=$d(e),"POST","/v1/accounts:update",Wm(e,{oobCode:t}))}async function py(e,t){var n=$d(e),r=await Av(n,{oobCode:t}),i=r.requestType;switch(Rm(i,n,"internal-error"),i){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":Rm(r.newEmail,n,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":Rm(r.mfaInfo,n,"internal-error");default:Rm(r.email,n,"internal-error")}let s=null;return r.mfaInfo&&(s=cy._fromServerResponse(Iv(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:s},operation:i}}async function fy(e,t,n){var r=$d(e),i={requestType:"EMAIL_SIGNIN",email:t};Rm(n.handleCodeInApp,r,"argument-error"),n&&uy(r,i,n),await Rv(r,i)}async function gy(e,t){var n=Lm()?Mm():"http://localhost",n=(await $m(e=$d(e),"POST","/v1/accounts:createAuthUri",Wm(e,{identifier:t,continueUri:n})))["signinMethods"];return n||[]}async function my(e,t){var n=$d(e),r={requestType:"VERIFY_EMAIL",idToken:await e.getIdToken()};t&&uy(n.auth,r,t);var r=(await Rv(n.auth,r))["email"];r!==e.email&&await e.reload()}async function vy(e,t,n){var r=$d(e),i={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await e.getIdToken(),newEmail:t};n&&uy(r.auth,i,n);var i=(await Rv(r.auth,i))["email"];i!==e.email&&await e.reload()}async function yy(e,{displayName:t,photoURL:n}){if(void 0!==t||void 0!==n){const i=$d(e);var r=await i.getIdToken(),r=await Zm(i,async function(e,t){return $m(e,"POST","/v1/accounts:update",t)}(i.auth,{idToken:r,displayName:t,photoUrl:n,returnSecureToken:!0}));i.displayName=r.displayName||null,i.photoURL=r.photoUrl||null;const s=i.providerData.find(({providerId:e})=>"password"===e);s&&(s.displayName=i.displayName,s.photoURL=i.photoURL),await i._updateTokensIfNecessary(r)}}async function _y(e,t,n){var r=e["auth"];const i={idToken:await e.getIdToken(),returnSecureToken:!0};t&&(i.email=t),n&&(i.password=n);r=await Zm(e,Nv(r,i));await e._updateTokensIfNecessary(r,!0)}class wy{constructor(e,t,n={}){this.isNewUser=e,this.providerId=t,this.profile=n}}class by extends wy{constructor(e,t,n,r){super(e,t,n),this.username=r}}class Iy extends wy{constructor(e,t){super(e,"facebook.com",t)}}class Ty extends by{constructor(e,t){super(e,"github.com",t,"string"==typeof(null==t?void 0:t.login)?null==t?void 0:t.login:null)}}class Ey extends wy{constructor(e,t){super(e,"google.com",t)}}class ky extends by{constructor(e,t,n){super(e,"twitter.com",t,n)}}function Sy(e){var{user:t,_tokenResponse:n}=e;return t.isAnonymous&&!n?{providerId:null,isNewUser:!1,profile:null}:function(e){if(!e)return null;var t=e["providerId"],n=e.rawUserInfo?JSON.parse(e.rawUserInfo):{},r=e.isNewUser||"identitytoolkit#SignupNewUserResponse"===e.kind;if(!t&&null!=e&&e.idToken){var i=null===(i=null===(i=Xm(e.idToken))||void 0===i?void 0:i.firebase)||void 0===i?void 0:i.sign_in_provider;if(i){i="anonymous"!==i&&"custom"!==i?i:null;return new wy(r,i)}}if(!t)return null;switch(t){case"facebook.com":return new Iy(r,n);case"github.com":return new Ty(r,n);case"google.com":return new Ey(r,n);case"twitter.com":return new ky(r,n,e.screenName||null);case"custom":case"anonymous":return new wy(r,null);default:return new wy(r,t,n)}}(n)}class Cy{constructor(e,t){this.type=e,this.credential=t}static _fromIdtoken(e){return new Cy("enroll",e)}static _fromMfaPendingCredential(e){return new Cy("signin",e)}toJSON(){return{multiFactorSession:{["enroll"===this.type?"idToken":"pendingCredential"]:this.credential}}}static fromJSON(e){var t;if(null!=e&&e.multiFactorSession){if(null!==(t=e.multiFactorSession)&&void 0!==t&&t.pendingCredential)return Cy._fromMfaPendingCredential(e.multiFactorSession.pendingCredential);if(null!==(t=e.multiFactorSession)&&void 0!==t&&t.idToken)return Cy._fromIdtoken(e.multiFactorSession.idToken)}return null}}class Ay{constructor(e,t,n){this.session=e,this.hints=t,this.signInResolver=n}static _fromError(e,i){const s=Iv(e),o=i.customData._serverResponse;var t=(o.mfaInfo||[]).map(e=>cy._fromServerResponse(s,e));Rm(o.mfaPendingCredential,s,"internal-error");const a=Cy._fromMfaPendingCredential(o.mfaPendingCredential);return new Ay(a,t,async e=>{var t=await e._process(s,a);delete o.mfaInfo,delete o.mfaPendingCredential;var n=Object.assign(Object.assign({},o),{idToken:t.idToken,refreshToken:t.refreshToken});switch(i.operationType){case"signIn":var r=await Gv._fromIdTokenResponse(s,i.operationType,n);return await s._updateCurrentUser(r.user),r;case"reauthenticate":return Rm(i.user,s,"internal-error"),Gv._forOperation(i.user,i.operationType,n);default:km(s,"internal-error")}})}async resolveSignIn(e){return this.signInResolver(e)}}class Ny{constructor(t){this.user=t,this.enrolledFactors=[],t._onReload(e=>{e.mfaInfo&&(this.enrolledFactors=e.mfaInfo.map(e=>cy._fromServerResponse(t.auth,e)))})}static _fromUser(e){return new Ny(e)}async getSession(){return Cy._fromIdtoken(await this.user.getIdToken())}async enroll(e,t){const n=e;var r=await this.getSession(),r=await Zm(this.user,n._process(this.user.auth,r,t));return await this.user._updateTokensIfNecessary(r),this.user.reload()}async unenroll(e){const t="string"==typeof e?e:e.uid;var n,r=await this.user.getIdToken(),r=await Zm(this.user,(n=this.user.auth,e={idToken:r,mfaEnrollmentId:t},$m(n,"POST","/v2/accounts/mfaEnrollment:withdraw",Wm(n,e))));this.enrolledFactors=this.enrolledFactors.filter(({uid:e})=>e!==t),await this.user._updateTokensIfNecessary(r);try{await this.user.reload()}catch(e){if("auth/user-token-expired"!==e.code)throw e}}}const Ry=new WeakMap;const Py="__sak";class xy{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Py,"1"),this.storage.removeItem(Py),Promise.resolve(!0)):Promise.resolve(!1)}catch(e){return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){var 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 Dy extends xy{constructor(){var e;super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.safariLocalStorageNotSynced=(dv(e=sd())||yv(e))&&function(){try{return!(!window||window===window.top)}catch(e){return!1}}(),this.fallbackToPolling=_v(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const r of Object.keys(this.listeners)){var t=this.storage.getItem(r),n=this.localCache[r];t!==n&&e(r,n,t)}}onStorageEvent(e,t=!1){if(e.key){const r=e.key;if(t?this.detachListener():this.stopPolling(),this.safariLocalStorageNotSynced){const i=this.storage.getItem(r);if(e.newValue!==i)null!==e.newValue?this.storage.setItem(r,e.newValue):this.storage.removeItem(r);else if(this.localCache[r]===e.newValue&&!t)return}var n=()=>{var e=this.storage.getItem(r);!t&&this.localCache[r]===e||this.notifyListeners(r,e)};const i=this.storage.getItem(r);ud()&&10===document.documentMode&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(n,10):n()}else this.forAllChangedKeys((e,t,n)=>{this.notifyListeners(e,n)})}notifyListeners(e,t){this.localCache[e]=t;var n=this.listeners[e];if(n)for(const r of Array.from(n))r(t&&JSON.parse(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){var t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}Dy.type="LOCAL";const Oy=Dy;class My extends xy{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}My.type="SESSION";const Ly=My;class Fy{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(t){var e=this.receivers.find(e=>e.isListeningto(t));if(e)return e;e=new Fy(t);return this.receivers.push(e),e}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:n,eventType:r,data:i}=t.data;var s=this.handlersMap[r];null!=s&&s.size&&(t.ports[0].postMessage({status:"ack",eventId:n,eventType:r}),s=Array.from(s).map(async e=>e(t.origin,i)),s=await Promise.all(s.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(e){return{fulfilled:!1,reason:e}}})),t.ports[0].postMessage({status:"done",eventId:n,eventType:r,response:s}))}_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 Uy(e="",t=10){let n="";for(let r=0;r<t;r++)n+=Math.floor(10*Math.random());return e+n}Fy.receivers=[];class jy{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,o=50){const a="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!a)throw new Error("connection_unavailable");let c,l;return new Promise((n,r)=>{const i=Uy("",20);a.port1.start();const s=setTimeout(()=>{r(new Error("unsupported_event"))},o);l={messageChannel:a,onMessage(e){var t=e;if(t.data.eventId===i)switch(t.data.status){case"ack":clearTimeout(s),c=setTimeout(()=>{r(new Error("timeout"))},3e3);break;case"done":clearTimeout(c),n(t.data.response);break;default:clearTimeout(s),clearTimeout(c),r(new Error("invalid_response"))}}},this.handlers.add(l),a.port1.addEventListener("message",l.onMessage),this.target.postMessage({eventType:e,eventId:i,data:t},[a.port2])}).finally(()=>{l&&this.removeMessageHandler(l)})}}function qy(){return window}function Vy(){return void 0!==qy().WorkerGlobalScope&&"function"==typeof qy().importScripts}const By="firebaseLocalStorageDb",Wy="firebaseLocalStorage",$y="fbase_key";class Ky{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 zy(e,t){return e.transaction([Wy],t?"readwrite":"readonly").objectStore(Wy)}function Hy(){const r=indexedDB.open(By,1);return new Promise((n,t)=>{r.addEventListener("error",()=>{t(r.error)}),r.addEventListener("upgradeneeded",()=>{const e=r.result;try{e.createObjectStore(Wy,{keyPath:$y})}catch(e){t(e)}}),r.addEventListener("success",async()=>{const e=r.result;var t;e.objectStoreNames.contains(Wy)?n(e):(e.close(),t=indexedDB.deleteDatabase(By),await new Ky(t).toPromise(),n(await Hy()))})})}async function Gy(e,t,n){var r=zy(e,!0).put({fbase_key:t,value:n});return new Ky(r).toPromise()}function Qy(e,t){var n=zy(e,!0).delete(t);return new Ky(n).toPromise()}class Yy{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 Hy(),this.db)}async _withRetries(e){let t=0;for(;;)try{return e(await this._openDb())}catch(e){if(3<t++)throw e;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Vy()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Fy._getInstance(Vy()?self:null),this.receiver._subscribe("keyChanged",async(e,t)=>{const n=await this._poll();return{keyProcessed:n.includes(t.key)}}),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t,n;this.activeServiceWorker=await async function(){if(null===navigator||void 0===navigator||!navigator.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch(e){return null}}(),this.activeServiceWorker&&(this.sender=new jy(this.activeServiceWorker),(n=await this.sender._send("ping",{},800))&&null!==(e=n[0])&&void 0!==e&&e.fulfilled&&null!==(t=n[0])&&void 0!==t&&t.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0))}async notifyServiceWorker(e){var t;if(this.sender&&this.activeServiceWorker&&((null===(t=null===navigator||void 0===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;var e=await Hy();return await Gy(e,Py,"1"),await Qy(e,Py),!0}catch(e){}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(t,n){return this._withPendingWrite(async()=>(await this._withRetries(e=>Gy(e,t,n)),this.localCache[t]=n,this.notifyServiceWorker(t)))}async _get(t){var e=await this._withRetries(e=>async function(e,t){var n=zy(e,!1).get(t);return void 0===(n=await new Ky(n).toPromise())?null:n.value}(e,t));return this.localCache[t]=e}async _remove(t){return this._withPendingWrite(async()=>(await this._withRetries(e=>Qy(e,t)),delete this.localCache[t],this.notifyServiceWorker(t)))}async _poll(){var e,t,n=await this._withRetries(e=>{var t=zy(e,!1).getAll();return new Ky(t).toPromise()});if(!n)return[];if(0!==this.pendingWrites)return[];const r=[],i=new Set;for({fbase_key:e,value:t}of n)i.add(e),JSON.stringify(this.localCache[e])!==JSON.stringify(t)&&(this.notifyListeners(e,t),r.push(e));for(const s of Object.keys(this.localCache))this.localCache[s]&&!i.has(s)&&(this.notifyListeners(s,null),r.push(s));return r}notifyListeners(e,t){this.localCache[e]=t;var n=this.listeners[e];if(n)for(const r of Array.from(n))r(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()}}Yy.type="LOCAL";const Jy=Yy;function Xy(i){return new Promise((e,n)=>{const t=document.createElement("script");var r;t.setAttribute("src",i),t.onload=e,t.onerror=e=>{const t=Sm("internal-error");t.customData=e,n(t)},t.type="text/javascript",t.charset="UTF-8",(null!==(r=null===(r=document.getElementsByTagName("head"))||void 0===r?void 0:r[0])&&void 0!==r?r:document).appendChild(t)})}function Zy(e){return`__${e}${Math.floor(1e6*Math.random())}`}class e_{constructor(e){this.auth=e,this.counter=1e12,this._widgets=new Map}render(e,t){var n=this.counter;return this._widgets.set(n,new t_(e,this.auth.name,t||{})),this.counter++,n}reset(e){var t,n=e||1e12;null===(t=this._widgets.get(n))||void 0===t||t.delete(),this._widgets.delete(n)}getResponse(e){var t;return(null===(t=this._widgets.get(e||1e12))||void 0===t?void 0:t.getResponse())||""}async execute(e){var t;return null===(t=this._widgets.get(e||1e12))||void 0===t||t.execute(),""}}class t_{constructor(e,t,n){this.params=n,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=()=>{this.execute()};var r="string"==typeof e?document.getElementById(e):e;Rm(r,"argument-error",{appName:t}),this.container=r,this.isVisible="invisible"!==this.params.size,this.isVisible?this.execute():this.container.addEventListener("click",this.clickHandler)}getResponse(){return this.checkIfDeleted(),this.responseToken}delete(){this.checkIfDeleted(),this.deleted=!0,this.timerId&&(clearTimeout(this.timerId),this.timerId=null),this.container.removeEventListener("click",this.clickHandler)}execute(){this.checkIfDeleted(),this.timerId||(this.timerId=window.setTimeout(()=>{this.responseToken=function(e){const t=[],n="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let r=0;r<e;r++)t.push(n.charAt(Math.floor(Math.random()*n.length)));return t.join("")}(50);const{callback:e,"expired-callback":t}=this.params;if(e)try{e(this.responseToken)}catch(e){}this.timerId=window.setTimeout(()=>{if(this.timerId=null,this.responseToken=null,t)try{t()}catch(e){}this.isVisible&&this.execute()},6e4)},500))}checkIfDeleted(){if(this.deleted)throw new Error("reCAPTCHA mock was already deleted!")}}const n_=Zy("rcb"),r_=new Um(3e4,6e4);class i_{constructor(){this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!qy().grecaptcha}load(s,o=""){var e;return Rm((e=o).length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(e),s,"argument-error"),this.shouldResolveImmediately(o)?Promise.resolve(qy().grecaptcha):new Promise((t,n)=>{const i=qy().setTimeout(()=>{n(Sm(s,"network-request-failed"))},r_.get());qy()[n_]=()=>{qy().clearTimeout(i),delete qy()[n_];const e=qy().grecaptcha;if(e){const r=e.render;e.render=(e,t)=>{var n=r(e,t);return this.counter++,n},this.hostLanguage=o,t(e)}else n(Sm(s,"internal-error"))},Xy(`https://www.google.com/recaptcha/api.js??${Cd({onload:n_,render:"explicit",hl:o})}`).catch(()=>{clearTimeout(i),n(Sm(s,"internal-error"))})})}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){return!!qy().grecaptcha&&(e===this.hostLanguage||0<this.counter||this.librarySeparatelyLoaded)}}class s_{async load(e){return new e_(e)}clearedOneInstance(){}}const o_="recaptcha",a_={theme:"light",type:"image"};class c_{constructor(e,t=Object.assign({},a_),n){this.parameters=t,this.type=o_,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=Iv(n),this.isInvisible="invisible"===this.parameters.size,Rm("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment");var r="string"==typeof e?document.getElementById(e):e;Rm(r,this.auth,"argument-error"),this.container=r,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=new(this.auth.settings.appVerificationDisabledForTesting?s_:i_),this.validateStartingState()}async verify(){this.assertNotDestroyed();const e=await this.render(),r=this.getAssertedRecaptcha();var t=r.getResponse(e);return t||new Promise(t=>{const n=e=>{e&&(this.tokenChangeListeners.delete(n),t(e))};this.tokenChangeListeners.add(n),this.isInvisible&&r.execute(e)})}render(){try{this.assertNotDestroyed()}catch(e){return Promise.reject(e)}return this.renderPromise||(this.renderPromise=this.makeRenderPromise().catch(e=>{throw this.renderPromise=null,e}),this.renderPromise)}_reset(){this.assertNotDestroyed(),null!==this.widgetId&&this.getAssertedRecaptcha().reset(this.widgetId)}clear(){this.assertNotDestroyed(),this.destroyed=!0,this._recaptchaLoader.clearedOneInstance(),this.isInvisible||this.container.childNodes.forEach(e=>{this.container.removeChild(e)})}validateStartingState(){Rm(!this.parameters.sitekey,this.auth,"argument-error"),Rm(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),Rm("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment")}makeTokenCallback(n){return t=>{if(this.tokenChangeListeners.forEach(e=>e(t)),"function"==typeof n)n(t);else if("string"==typeof n){const e=qy()[n];"function"==typeof e&&e(t)}}}assertNotDestroyed(){Rm(!this.destroyed,this.auth,"internal-error")}async makeRenderPromise(){if(await this.init(),!this.widgetId){let e=this.container;var t;this.isInvisible||(t=document.createElement("div"),e.appendChild(t),e=t),this.widgetId=this.getAssertedRecaptcha().render(e,this.parameters)}return this.widgetId}async init(){Rm(Lm()&&!Vy(),this.auth,"internal-error"),await function(){let t=null;return new Promise(e=>{"complete"!==document.readyState?(t=()=>e(),window.addEventListener("load",t)):e()}).catch(e=>{throw t&&window.removeEventListener("load",t),e})}(),this.recaptcha=await this._recaptchaLoader.load(this.auth,this.auth.languageCode||void 0);var e=await((await $m(this.auth,"GET","/v1/recaptchaParams")).recaptchaSiteKey||"");Rm(e,this.auth,"internal-error"),this.parameters.sitekey=e}getAssertedRecaptcha(){return Rm(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}class l_{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){var t=Mv._fromVerification(this.verificationId,e);return this.onConfirmation(t)}}async function u_(t,n,r){var i,s,o,a,c,l,u=await r.verify();try{Rm("string"==typeof u,t,"argument-error"),Rm(r.type===o_,t,"argument-error");let e;if(e="string"==typeof n?{phoneNumber:n}:n,"session"in e){var h=e.session;if("phoneNumber"in e)return Rm("enroll"===h.type,t,"internal-error"),(c=t,l={idToken:h.credential,phoneEnrollmentInfo:{phoneNumber:e.phoneNumber,recaptchaToken:u}},await $m(c,"POST","/v2/accounts/mfaEnrollment:start",Wm(c,l))).phoneSessionInfo.sessionInfo;Rm("signin"===h.type,t,"internal-error");var d=(null===(i=e.multiFactorHint)||void 0===i?void 0:i.uid)||e.multiFactorUid;return Rm(d,t,"missing-multi-factor-info"),(a={mfaPendingCredential:h.credential,mfaEnrollmentId:d,phoneSignInInfo:{recaptchaToken:u}},await $m(t,"POST","/v2/accounts/mfaSignIn:start",Wm(t,a))).phoneResponseInfo.sessionInfo}var p=(s=t,o={phoneNumber:e.phoneNumber,recaptchaToken:u},await $m(s,"POST","/v1/accounts:sendVerificationCode",Wm(s,o)))["sessionInfo"];return p}finally{r._reset()}}class h_{constructor(e){this.providerId=h_.PROVIDER_ID,this.auth=Iv(e)}verifyPhoneNumber(e,t){return u_(this.auth,e,$d(t))}static credential(e,t){return Mv._fromVerification(e,t)}static credentialFromResult(e){var t=e;return h_.credentialFromTaggedObject(t)}static credentialFromError(e){return h_.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{phoneNumber:t,temporaryProof:n}=e;return t&&n?Mv._fromTokenResponse(t,n):null}}function d_(e,t){return t?Om(t):(Rm(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}h_.PROVIDER_ID="phone",h_.PHONE_SIGN_IN_METHOD="phone";class p_ extends Cv{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return xv(e,this._buildIdpRequest())}_linkToIdToken(e,t){return xv(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return xv(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function f_(e){return ry(e.auth,new p_(e),e.bypassAuthState)}function g_(e){var{auth:t,user:n}=e;return Rm(n,t,"internal-error"),ny(n,new p_(e),e.bypassAuthState)}async function m_(e){var{auth:t,user:n}=e;return Rm(n,t,"internal-error"),ey(n,new p_(e),e.bypassAuthState)}class v_{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){var{urlResponse:t,sessionId:n,postBody:r,tenantId:i,error:s,type:o}=e;if(s)this.reject(s);else{r={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)(r))}catch(e){this.reject(e)}}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return f_;case"linkViaPopup":case"linkViaRedirect":return m_;case"reauthViaPopup":case"reauthViaRedirect":return g_;default:km(this.auth,"internal-error")}}resolve(e){xm(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){xm(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}const y_=new Um(2e3,1e4);class __ extends v_{constructor(e,t,n,r,i){super(e,t,r,i),this.provider=n,this.authWindow=null,this.pollId=null,__.currentPopupAction&&__.currentPopupAction.cancel(),__.currentPopupAction=this}async executeNotNull(){var e=await this.execute();return Rm(e,this.auth,"internal-error"),e}async onExecution(){xm(1===this.filter.length,"Popup operations only handle one event");var e=Uy();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(e=>{this.reject(e)}),this.resolver._isIframeWebStorageSupported(this.auth,e=>{e||this.reject(Sm(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(Sm(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,__.currentPopupAction=null}pollUserCancellation(){const t=()=>{var e;null!==(e=null===(e=this.authWindow)||void 0===e?void 0:e.window)&&void 0!==e&&e.closed?this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Sm(this.auth,"popup-closed-by-user"))},2e3):this.pollId=window.setTimeout(t,y_.get())};t()}}__.currentPopupAction=null;const w_="pendingRedirect",b_=new Map;class I_ extends v_{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let t=b_.get(this.auth._key());if(!t){try{const e=await async function(e,t){const n=k_(t),r=E_(e);if(!await r._isAvailable())return!1;var i="true"===await r._get(n);return await r._remove(n),i}(this.resolver,this.auth)?await super.execute():null;t=()=>Promise.resolve(e)}catch(e){t=()=>Promise.reject(e)}b_.set(this.auth._key(),t)}return this.bypassAuthState||b_.set(this.auth._key(),()=>Promise.resolve(null)),t()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);if("unknown"!==e.type){if(e.eventId){var t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}else this.resolve(null)}async onExecution(){}cleanUp(){}}async function T_(e,t){return E_(e)._set(k_(t),"true")}function E_(e){return Om(e._redirectPersistence)}function k_(e){return cv(w_,e.config.apiKey,e.name)}function S_(e,t,n){return async function(e,t,n){var r=Iv(e);Am(e,t,Uv);const i=d_(r,n);return await T_(i,r),i._openRedirect(r,t,"signInViaRedirect")}(e,t,n)}function C_(e,t,n){return async function(e,t,n){var r=$d(e);Am(r.auth,t,Uv);const i=d_(r.auth,n);await T_(i,r.auth);var s=await R_(r);return i._openRedirect(r.auth,t,"reauthViaRedirect",s)}(e,t,n)}function A_(e,t,n){return async function(e,t,n){var r=$d(e);Am(r.auth,t,Uv);const i=d_(r.auth,n);await ty(!1,r,t.providerId),await T_(i,r.auth);var s=await R_(r);return i._openRedirect(r.auth,t,"linkViaRedirect",s)}(e,t,n)}async function N_(e,t,n=!1){const r=Iv(e);var i=d_(r,t);const s=new I_(r,i,n),o=await s.execute();return o&&!n&&(delete o.user._redirectEventId,await r._persistUserIfCurrent(o.user),await r._setRedirectUser(null,t)),o}async function R_(e){var t=Uy(`${e.uid}:::`);return e._redirectEventId=t,await e.auth._setRedirectUser(e),await e.auth._persistUserIfCurrent(e),t}class P_{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(t){if(this.hasEventBeenHandled(t))return!1;let n=!1;return this.consumers.forEach(e=>{this.isEventForConsumer(t,e)&&(n=!0,this.sendToConsumer(t,e),this.saveEventToCache(t))}),this.hasHandledPotentialRedirect||!function(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return D_(e);default:return!1}}(t)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=t,n=!0)),n}sendToConsumer(e,t){var n;e.error&&!D_(e)?(n=(null===(n=e.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error",t.onError(Sm(this.auth,n))):t.onAuthEvent(e)}isEventForConsumer(e,t){var n=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}hasEventBeenHandled(e){return 6e5<=Date.now()-this.lastProcessedEventTime&&this.cachedEventUids.clear(),this.cachedEventUids.has(x_(e))}saveEventToCache(e){this.cachedEventUids.add(x_(e)),this.lastProcessedEventTime=Date.now()}}function x_(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function D_({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===(null==t?void 0:t.code)}async function O_(e,t={}){return $m(e,"GET","/v1/projects",t)}const M_=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,L_=/^https?/;async function F_(e){if(!e.config.emulator){var t=(await O_(e))["authorizedDomains"];for(const n of t)try{if(function(e){const t=Mm(),{protocol:n,hostname:r}=new URL(t);if(e.startsWith("chrome-extension://")){var 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(!L_.test(n))return!1;if(M_.test(e))return r===e;const s=e.replace(/\./g,"\\."),o=new RegExp("^(.+\\."+s+"|"+s+")$","i");return o.test(r)}(n))return}catch(e){}km(e,"unauthorized-domain")}}const U_=new Um(3e4,6e4);function j_(){const t=qy().___jsl;if(null!==t&&void 0!==t&&t.H)for(const n of Object.keys(t.H))if(t.H[n].r=t.H[n].r||[],t.H[n].L=t.H[n].L||[],t.H[n].r=[...t.H[n].L],t.CP)for(let e=0;e<t.CP.length;e++)t.CP[e]=null}let q_=null;function V_(e){var i;return q_=q_||(i=e,new Promise((e,t)=>{function n(){j_(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{j_(),t(Sm(i,"network-request-failed"))},timeout:U_.get()})}if(null!==(r=null===(r=qy().gapi)||void 0===r?void 0:r.iframes)&&void 0!==r&&r.Iframe)e(gapi.iframes.getContext());else{if(null===(r=qy().gapi)||void 0===r||!r.load){var r=Zy("iframefcb");return qy()[r]=()=>{gapi.load?n():t(Sm(i,"network-request-failed"))},Xy(`https://apis.google.com/js/api.js?onload=${r}`).catch(e=>t(e))}n()}}).catch(e=>{throw q_=null,e})),q_}const B_=new Um(5e3,15e3),W_="__/auth/iframe",$_="emulator/auth/iframe",K_={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},z_=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);async function H_(o){const e=await V_(o);var t=qy().gapi;return Rm(t,o,"internal-error"),e.open({where:document.body,url:function(e){var t=e.config;Rm(t.authDomain,e,"auth-domain-config-required");var n=t.emulator?jm(t,$_):`https://${e.config.authDomain}/${W_}`;const r={apiKey:t.apiKey,appName:e.name,v:gp};(t=z_.get(e.config.apiHost))&&(r.eid=t);const i=e._getFrameworks();return i.length&&(r.fw=i.join(",")),`${n}?${Cd(r).slice(1)}`}(o),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:K_,dontclear:!0},s=>new Promise(async(e,t)=>{await s.restyle({setHideOnLeave:!1});const n=Sm(o,"network-request-failed"),r=qy().setTimeout(()=>{t(n)},B_.get());function i(){qy().clearTimeout(r),e(s)}s.ping(i).then(i,()=>{t(n)})}))}const G_={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class Q_{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}function Y_(e,t,n,r=500,i=600){var s=Math.max((window.screen.availHeight-i)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString();let a="";const c=Object.assign(Object.assign({},G_),{width:r.toString(),height:i.toString(),top:s,left:o});s=sd().toLowerCase();n&&(a=pv(s)?"_blank":n),hv(s)&&(t=t||"http://localhost",c.scrollbars="yes");var l,o=Object.entries(c).reduce((e,[t,n])=>`${e}${t}=${n},`,"");if([n=sd()]=[s],yv(n)&&null!==(l=window.navigator)&&void 0!==l&&l.standalone&&"_self"!==a)return function(e,t){const n=document.createElement("a");n.href=e,n.target=t;const 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||"",a),new Q_(null);const u=window.open(t||"",a,o);Rm(u,e,"popup-blocked");try{u.focus()}catch(e){}return new Q_(u)}const J_="__/auth/handler",X_="emulator/auth/handler";function Z_(e,t,n,r,i,s){Rm(e.config.authDomain,e,"auth-domain-config-required"),Rm(e.config.apiKey,e,"invalid-api-key");const o={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:r,v:gp,eventId:i};if(t instanceof Uv){t.setDefaultLanguage(e.languageCode),o.providerId=t.providerId||"",Td(t.getCustomParameters())||(o.customParameters=JSON.stringify(t.getCustomParameters()));for(var[a,c]of Object.entries(s||{}))o[a]=c}if(t instanceof jv){const u=t.getScopes().filter(e=>""!==e);0<u.length&&(o.scopes=u.join(","))}e.tenantId&&(o.tid=e.tenantId);const l=o;for(const h of Object.keys(l))void 0===l[h]&&delete l[h];return`${e=[e["config"]][0],e.emulator?jm(e,X_):`https://${e.authDomain}/${J_}`}?${Cd(l).slice(1)}`}const ew="webStorageSupport";const tw=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Ly,this._completeRedirectFn=N_}async _openPopup(e,t,n,r){var i;return xm(null===(i=this.eventManagers[e._key()])||void 0===i?void 0:i.manager,"_initialize() not called before _openPopup()"),Y_(e,Z_(e,t,n,Mm(),r),Uy())}async _openRedirect(e,t,n,r){return await this._originValidation(e),r=Z_(e,t,n,Mm(),r),qy().location.href=r,new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:r,promise:n}=this.eventManagers[t];return r?Promise.resolve(r):(xm(n,"If manager is not set, promise should be"),n)}const n=this.initAndGetManager(e);return this.eventManagers[t]={promise:n},n.catch(()=>{delete this.eventManagers[t]}),n}async initAndGetManager(t){const e=await H_(t),n=new P_(t);return e.register("authEvent",e=>{return Rm(null==e?void 0:e.authEvent,t,"invalid-auth-event"),{status:n.onEvent(e.authEvent)?"ACK":"ERROR"}},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[t._key()]={manager:n},this.iframes[t._key()]=e,n}_isIframeWebStorageSupported(n,r){const e=this.iframes[n._key()];e.send(ew,{type:ew},e=>{var t=null===(t=null==e?void 0:e[0])||void 0===t?void 0:t[ew];void 0!==t&&r(!!t),km(n,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=F_(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return _v()||dv()||yv()}};class nw extends class{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 Pm("unexpected MultiFactorSessionType")}}}{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new nw(e)}_finalizeEnroll(e,t,n){return e=e,n={idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()},$m(e,"POST","/v2/accounts/mfaEnrollment:finalize",Wm(e,n))}_finalizeSignIn(e,t){return e=e,t={mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()},$m(e,"POST","/v2/accounts/mfaSignIn:finalize",Wm(e,t))}}class rw{constructor(){}static assertion(e){return nw._fromCredential(e)}}rw.FACTOR_ID="phone";var iw,sw="@firebase/auth";class ow{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(t){var e;this.assertAuthConfigured(),this.internalListeners.has(t)||(e=this.auth.onIdTokenChanged(e=>{t((null===e||void 0===e?void 0:e.stsTokenManager.accessToken)||null)}),this.internalListeners.set(t,e),this.updateProactiveRefresh())}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){Rm(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){0<this.internalListeners.size?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function aw(){return window}iw="Browser",hp(new Kd("auth",(e,{options:n})=>{var t=e.getProvider("app").getImmediate();const{apiKey:r,authDomain:i}=t.options;return(e=>{Rm(r&&!r.includes(":"),"invalid-api-key",{appName:e.name}),Rm(!(null!==i&&void 0!==i&&i.includes(":")),"argument-error",{appName:e.name});var t={apiKey:r,authDomain:i,clientPlatform:iw,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:wv(iw)},t=new bv(e,t);return function(e,t){const n=(null==t?void 0:t.persistence)||[];var r=(Array.isArray(n)?n:[n]).map(Om);null!=t&&t.errorMap&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,null==t?void 0:t.popupRedirectResolver)}(t,n),t})(t)},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{const r=e.getProvider("auth-internal");r.initialize()})),hp(new Kd("auth-internal",e=>{var t=Iv(e.getProvider("auth").getImmediate());return e=t,new ow(e)},"PRIVATE").setInstantiationMode("EXPLICIT")),_p(sw,"0.19.5",function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";default:return}}(iw)),_p(sw,"0.19.5","esm2017");async function cw(e,t,n){var r=aw()["BuildInfo"];xm(t.sessionId,"AuthEvent did not contain a session ID");var i=await async function(e){const t=function(e){if(xm(/[0-9a-zA-Z]+/.test(e),"Can only convert alpha-numeric strings"),"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);const t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}(e),n=await crypto.subtle.digest("SHA-256",t),r=Array.from(new Uint8Array(n));return r.map(e=>e.toString(16).padStart(2,"0")).join("")}(t.sessionId);const s={};return yv()?s.ibi=r.packageName:gv()?s.apn=r.packageName:km(e,"operation-not-supported-in-this-environment"),r.displayName&&(s.appDisplayName=r.displayName),s.sessionId=i,Z_(e,n,t.type,void 0,null!==(i=t.eventId)&&void 0!==i?i:void 0,s)}function lw(r){const i=aw()["cordova"];return new Promise(n=>{i.plugins.browsertab.isAvailable(e=>{let t=null;e?i.plugins.browsertab.openUrl(r):t=i.InAppBrowser.open(r,(e=sd(),/(iPad|iPhone|iPod).*OS 7_\d/i.test(e)||/(iPad|iPhone|iPod).*OS 8_\d/i.test(e)?"_blank":"_system"),"location=yes"),n(t)})})}const uw=20;class hw extends P_{constructor(){super(...arguments),this.passiveListeners=new Set,this.initPromise=new Promise(e=>{this.resolveInialized=e})}addPassiveListener(e){this.passiveListeners.add(e)}removePassiveListener(e){this.passiveListeners.delete(e)}resetRedirect(){this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1}onEvent(t){return this.resolveInialized(),this.passiveListeners.forEach(e=>e(t)),super.onEvent(t)}async initialized(){await this.initPromise}}function dw(e,t,n=null){return{type:t,eventId:n,urlResponse:null,sessionId:function(){const e=[],t="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let r=0;r<uw;r++){var n=Math.floor(Math.random()*t.length);e.push(t.charAt(n))}return e.join("")}(),postBody:null,tenantId:e.tenantId,error:Sm(e,"no-auth-event")}}async function pw(e){var t=await gw()._get(mw(e));return t&&await gw()._remove(mw(e)),t}function fw(e,t){var n,r,i;const s=(n=vw(t=t),o=n.link?decodeURIComponent(n.link):void 0,r=vw(o).link,i=n.deep_link_id?decodeURIComponent(n.deep_link_id):void 0,(n=vw(i).link)||i||r||o||t);if(s.includes("/__/auth/callback")){var o=vw(s),o=o.firebaseError?function(e){try{return JSON.parse(e)}catch(e){return null}}(decodeURIComponent(o.firebaseError)):null,o=null===(o=null===(o=null==o?void 0:o.code)||void 0===o?void 0:o.split("auth/"))||void 0===o?void 0:o[1],o=o?Sm(o):null;return o?{type:e.type,eventId:e.eventId,tenantId:e.tenantId,error:o,urlResponse:null,sessionId:null,postBody:null}:{type:e.type,eventId:e.eventId,tenantId:e.tenantId,sessionId:e.sessionId,urlResponse:s,postBody:null}}return null}function gw(){return Om(Oy)}function mw(e){return cv("authEvent",e.config.apiKey,e.name)}function vw(e){if(null==e||!e.includes("?"))return{};const[,...t]=e.split("?");return Ad(t.join("?"))}const yw=class{constructor(){this._redirectPersistence=Ly,this._shouldInitProactively=!0,this.eventManagers=new Map,this.originValidationPromises={},this._completeRedirectFn=N_}async _initialize(e){var t=e._key();let n=this.eventManagers.get(t);return n||(n=new hw(e),this.eventManagers.set(t,n),this.attachCallbackListeners(e,n)),n}_openPopup(e){km(e,"operation-not-supported-in-this-environment")}async _openRedirect(e,t,n,r){var i,s;i=e,a=aw(),Rm("function"==typeof(null===(s=null==a?void 0:a.universalLinks)||void 0===s?void 0:s.subscribe),i,"invalid-cordova-configuration",{missingPlugin:"cordova-universal-links-plugin-fix"}),Rm(void 0!==(null===(s=null==a?void 0:a.BuildInfo)||void 0===s?void 0:s.packageName),i,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-buildInfo"}),Rm("function"==typeof(null===(s=null===(s=null===(s=null==a?void 0:a.cordova)||void 0===s?void 0:s.plugins)||void 0===s?void 0:s.browsertab)||void 0===s?void 0:s.openUrl),i,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-browsertab"}),Rm("function"==typeof(null===(s=null===(s=null===(s=null==a?void 0:a.cordova)||void 0===s?void 0:s.plugins)||void 0===s?void 0:s.browsertab)||void 0===s?void 0:s.isAvailable),i,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-browsertab"}),Rm("function"==typeof(null===(a=null===(a=null==a?void 0:a.cordova)||void 0===a?void 0:a.InAppBrowser)||void 0===a?void 0:a.open),i,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-inappbrowser"});const o=await this._initialize(e);await o.initialized(),o.resetRedirect(),b_.clear(),await this._originValidation(e);var a=dw(e,n,r);n=e,r=a,await gw()._set(mw(n),r);a=await lw(await cw(e,a,t));return async function(o,a,c){const l=aw()["cordova"];let u=()=>{};try{await new Promise((n,e)=>{let t=null;function r(){var e;n();const t=null===(e=l.plugins.browsertab)||void 0===e?void 0:e.close;"function"==typeof t&&t(),"function"==typeof(null==c?void 0:c.close)&&c.close()}function i(){t=t||window.setTimeout(()=>{e(Sm(o,"redirect-cancelled-by-user"))},2e3)}function s(){"visible"===(null===document||void 0===document?void 0:document.visibilityState)&&i()}a.addPassiveListener(r),document.addEventListener("resume",i,!1),gv()&&document.addEventListener("visibilitychange",s,!1),u=()=>{a.removePassiveListener(r),document.removeEventListener("resume",i,!1),document.removeEventListener("visibilitychange",s,!1),t&&window.clearTimeout(t)}})}finally{u()}}(e,o,a)}_isIframeWebStorageSupported(e,t){throw new Error("Method not implemented.")}_originValidation(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=async function(e){var t=aw()["BuildInfo"];const n={};yv()?n.iosBundleId=t.packageName:gv()?n.androidPackageName=t.packageName:km(e,"operation-not-supported-in-this-environment"),await O_(e,n)}(e)),this.originValidationPromises[t]}attachCallbackListeners(r,i){const{universalLinks:e,handleOpenURL:t,BuildInfo:n}=aw(),s=setTimeout(async()=>{await pw(r),i.onEvent(_w())},500),o=async e=>{clearTimeout(s);var t=await pw(r);let n=null;t&&null!=e&&e.url&&(n=fw(t,e.url)),i.onEvent(n||_w())};void 0!==e&&"function"==typeof e.subscribe&&e.subscribe(null,o);const a=t,c=`${n.packageName.toLowerCase()}://`;aw().handleOpenURL=async e=>{if(e.toLowerCase().startsWith(c)&&o({url:e}),"function"==typeof a)try{a(e)}catch(e){console.error(e)}}}};function _w(){return{type:"unknown",eventId:null,sessionId:null,urlResponse:null,postBody:null,tenantId:null,error:Sm("no-auth-event")}}var ww;function bw(){var e;return(null===(e=null===self||void 0===self?void 0:self.location)||void 0===e?void 0:e.protocol)||null}function Iw(e=sd()){return!("file:"!==bw()&&"ionic:"!==bw()||!e.toLowerCase().match(/iphone|ipad|ipod|android/))}function Tw(e=sd()){return ud()&&11===(null===document||void 0===document?void 0:document.documentMode)||([e=sd()]=[e],/Edge\/\d+/.test(e))}function Ew(){try{const t=self.localStorage;var e=Uy();if(t)return t.setItem(e,"1"),t.removeItem(e),!Tw()||dd()}catch(e){return kw()&&dd()}return!1}function kw(){return"undefined"!=typeof global&&"WorkerGlobalScope"in global&&"importScripts"in global}function Sw(){return("http:"===bw()||"https:"===bw()||cd()||Iw())&&!(ld()||ad())&&Ew()&&!kw()}function Cw(){return Iw()&&"undefined"!=typeof document}const Aw={LOCAL:"local",NONE:"none",SESSION:"session"},Nw=Rm,Rw="persistence";async function Pw(e){await e._initializationPromise;const t=xw();var n=cv(Rw,e.config.apiKey,e.name);null!==t&&void 0!==t&&t.sessionStorage&&t.sessionStorage.setItem(n,e._getPersistence())}function xw(){return"undefined"!=typeof window?window:null}const Dw=Rm;class Ow{constructor(){this.browserResolver=Om(tw),this.cordovaResolver=Om(yw),this.underlyingResolver=null,this._redirectPersistence=Ly,this._completeRedirectFn=N_}async _initialize(e){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._initialize(e)}async _openPopup(e,t,n,r){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openPopup(e,t,n,r)}async _openRedirect(e,t,n,r){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openRedirect(e,t,n,r)}_isIframeWebStorageSupported(e,t){this.assertedUnderlyingResolver._isIframeWebStorageSupported(e,t)}_originValidation(e){return this.assertedUnderlyingResolver._originValidation(e)}get _shouldInitProactively(){return Cw()||this.browserResolver._shouldInitProactively}get assertedUnderlyingResolver(){return Dw(this.underlyingResolver,"internal-error"),this.underlyingResolver}async selectUnderlyingResolver(){var e;this.underlyingResolver||(e=await(!!Cw()&&new Promise(e=>{const t=setTimeout(()=>{e(!1)},1e3);document.addEventListener("deviceready",()=>{clearTimeout(t),e(!0)})})),this.underlyingResolver=e?this.cordovaResolver:this.browserResolver)}}function Mw(e){return e.unwrap()}function Lw(e,t){var n,r,i,s=null===(r=t.customData)||void 0===r?void 0:r._tokenResponse;if("auth/multi-factor-auth-required"===t.code){const a=t;a.resolver=new qw(e,(n=t,i=$d(e),Rm((o=n).customData.operationType,i,"argument-error"),Rm(null===(r=o.customData._serverResponse)||void 0===r?void 0:r.mfaPendingCredential,i,"argument-error"),Ay._fromError(i,o)))}else if(s){var o=Fw(t);const c=t;o&&(c.credential=o,c.tenantId=s.tenantId||void 0,c.email=s.email||void 0,c.phoneNumber=s.phoneNumber||void 0)}}function Fw(e){var t=(e instanceof gd?e.customData:e)["_tokenResponse"];if(!t)return null;if(!(e instanceof gd)&&"temporaryProof"in t&&"phoneNumber"in t)return h_.credentialFromResult(e);const n=t.providerId;if(!n||n===vm.PASSWORD)return null;let r;switch(n){case vm.GOOGLE:r=Bv;break;case vm.FACEBOOK:r=Vv;break;case vm.GITHUB:r=Wv;break;case vm.TWITTER:r=zv;break;default:var{oauthIdToken:i,oauthAccessToken:s,oauthTokenSecret:o,pendingToken:a,nonce:c}=t;return s||o||i||a?a?n.startsWith("saml.")?$v._create(n,a):Dv._fromParams({providerId:n,signInMethod:n,pendingToken:a,idToken:i,accessToken:s}):new qv(n).credential({idToken:i,accessToken:s,rawNonce:c}):null}return e instanceof gd?r.credentialFromError(e):r.credentialFromResult(e)}function Uw(t,e){return e.catch(e=>{throw e instanceof gd&&Lw(t,e),e}).then(e=>{var t=e.operationType,n=e.user;return{operationType:t,credential:Fw(e),additionalUserInfo:Sy(e),user:Vw.getOrCreate(n)}})}async function jw(t,e){const n=await e;return{verificationId:n.verificationId,confirm:e=>Uw(t,n.confirm(e))}}class qw{constructor(e,t){this.resolver=t,this.auth=e.wrapped()}get session(){return this.resolver.session}get hints(){return this.resolver.hints}resolveSignIn(e){return Uw(Mw(this.auth),this.resolver.resolveSignIn(e))}}class Vw{constructor(e){var t;this._delegate=e,this.multiFactor=(t=$d(e),Ry.has(t)||Ry.set(t,Ny._fromUser(t)),Ry.get(t))}static getOrCreate(e){return Vw.USER_MAP.has(e)||Vw.USER_MAP.set(e,new Vw(e)),Vw.USER_MAP.get(e)}delete(){return this._delegate.delete()}reload(){return this._delegate.reload()}toJSON(){return this._delegate.toJSON()}getIdTokenResult(e){return this._delegate.getIdTokenResult(e)}getIdToken(e){return this._delegate.getIdToken(e)}linkAndRetrieveDataWithCredential(e){return this.linkWithCredential(e)}async linkWithCredential(e){return Uw(this.auth,sy(this._delegate,e))}async linkWithPhoneNumber(e,t){return jw(this.auth,async function(e,t,n){const r=$d(e);await ty(!1,r,"phone");var i=await u_(r.auth,t,$d(n));return new l_(i,e=>sy(r,e))}(this._delegate,e,t))}async linkWithPopup(e){return Uw(this.auth,async function(e,t,n){var r=$d(e);Am(r.auth,t,Uv);var i=d_(r.auth,n);const s=new __(r.auth,"linkViaPopup",t,i,r);return s.executeNotNull()}(this._delegate,e,Ow))}async linkWithRedirect(e){return await Pw(Iv(this.auth)),A_(this._delegate,e,Ow)}reauthenticateAndRetrieveDataWithCredential(e){return this.reauthenticateWithCredential(e)}async reauthenticateWithCredential(e){return Uw(this.auth,oy(this._delegate,e))}reauthenticateWithPhoneNumber(e,t){return jw(this.auth,async function(e,t,n){const r=$d(e);var i=await u_(r.auth,t,$d(n));return new l_(i,e=>oy(r,e))}(this._delegate,e,t))}reauthenticateWithPopup(e){return Uw(this.auth,async function(e,t,n){var r=$d(e);Am(r.auth,t,Uv);var i=d_(r.auth,n);const s=new __(r.auth,"reauthViaPopup",t,i,r);return s.executeNotNull()}(this._delegate,e,Ow))}async reauthenticateWithRedirect(e){return await Pw(Iv(this.auth)),C_(this._delegate,e,Ow)}sendEmailVerification(e){return my(this._delegate,e)}async unlink(e){return await Zv(this._delegate,e),this}updateEmail(e){return _y($d(this._delegate),e,null)}updatePassword(e){return _y($d(this._delegate),null,e)}updatePhoneNumber(e){return async function(e,t){await ey($d(e),t)}(this._delegate,e)}updateProfile(e){return yy(this._delegate,e)}verifyBeforeUpdateEmail(e,t){return vy(this._delegate,e,t)}get emailVerified(){return this._delegate.emailVerified}get isAnonymous(){return this._delegate.isAnonymous}get metadata(){return this._delegate.metadata}get phoneNumber(){return this._delegate.phoneNumber}get providerData(){return this._delegate.providerData}get refreshToken(){return this._delegate.refreshToken}get tenantId(){return this._delegate.tenantId}get displayName(){return this._delegate.displayName}get email(){return this._delegate.email}get photoURL(){return this._delegate.photoURL}get providerId(){return this._delegate.providerId}get uid(){return this._delegate.uid}get auth(){return this._delegate.auth}}Vw.USER_MAP=new WeakMap;const Bw=Rm;class Ww{constructor(e,t){if(this.app=e,t.isInitialized())return this._delegate=t.getImmediate(),void this.linkUnderlyingAuth();var n=e.options["apiKey"];Bw(n,"invalid-api-key",{appName:e.name}),Bw(n,"invalid-api-key",{appName:e.name});var r="undefined"!=typeof window?Ow:void 0;this._delegate=t.initialize({options:{persistence:function(e,t){const n=function(e,t){const n=xw();if(null===n||void 0===n||!n.sessionStorage)return[];var r=cv(Rw,e,t);switch(n.sessionStorage.getItem(r)){case Aw.NONE:return[av];case Aw.LOCAL:return[Jy,Ly];case Aw.SESSION:return[Ly];default:return[]}}(e,t);"undefined"==typeof self||n.includes(Jy)||n.push(Jy);if("undefined"!=typeof window)for(const r of[Oy,Ly])n.includes(r)||n.push(r);n.includes(av)||n.push(av);return n}(n,e.name),popupRedirectResolver:r}}),this._delegate._updateErrorMap(wm),this.linkUnderlyingAuth()}get emulatorConfig(){return this._delegate.emulatorConfig}get currentUser(){return this._delegate.currentUser?Vw.getOrCreate(this._delegate.currentUser):null}get languageCode(){return this._delegate.languageCode}set languageCode(e){this._delegate.languageCode=e}get settings(){return this._delegate.settings}get tenantId(){return this._delegate.tenantId}set tenantId(e){this._delegate.tenantId=e}useDeviceLanguage(){this._delegate.useDeviceLanguage()}signOut(){return this._delegate.signOut()}useEmulator(e,t){Ev(this._delegate,e,t)}applyActionCode(e){return dy(this._delegate,e)}checkActionCode(e){return py(this._delegate,e)}confirmPasswordReset(e,t){return async function(e,t,n){await Av($d(e),{oobCode:t,newPassword:n})}(this._delegate,e,t)}async createUserWithEmailAndPassword(e,t){return Uw(this._delegate,async function(e,t,n){const r=Iv(e);var i=await Hv(r,{returnSecureToken:!0,email:t,password:n}),i=await Gv._fromIdTokenResponse(r,"signIn",i);return await r._updateCurrentUser(i.user),i}(this._delegate,e,t))}fetchProvidersForEmail(e){return this.fetchSignInMethodsForEmail(e)}fetchSignInMethodsForEmail(e){return gy(this._delegate,e)}isSignInWithEmailLink(e){return this._delegate,e=e,"EMAIL_SIGNIN"===(null==(t=Lv.parseLink(e))?void 0:t.operation);var t}async getRedirectResult(){Bw(Sw(),this._delegate,"operation-not-supported-in-this-environment");var e,t,n=(e=this._delegate,t=Ow,await Iv(e)._initializationPromise,await N_(e,t,!1));return n?Uw(this._delegate,Promise.resolve(n)):{credential:null,user:null}}addFrameworkForLogging(e){Iv(this._delegate)._logFramework(e)}onAuthStateChanged(e,t,n){var{next:r,error:i,complete:s}=$w(e,t,n);return this._delegate.onAuthStateChanged(r,i,s)}onIdTokenChanged(e,t,n){var{next:r,error:i,complete:s}=$w(e,t,n);return this._delegate.onIdTokenChanged(r,i,s)}sendSignInLinkToEmail(e,t){return fy(this._delegate,e,t)}sendPasswordResetEmail(e,t){return hy(this._delegate,e,t||void 0)}async setPersistence(e){var t,n;t=this._delegate,n=e,Nw(Object.values(Aw).includes(n),t,"invalid-persistence-type"),ld()?Nw(n!==Aw.SESSION,t,"unsupported-persistence-type"):ad()?Nw(n===Aw.NONE,t,"unsupported-persistence-type"):kw()?Nw(n===Aw.NONE||n===Aw.LOCAL&&dd(),t,"unsupported-persistence-type"):Nw(n===Aw.NONE||Ew(),t,"unsupported-persistence-type");let r;switch(e){case Aw.SESSION:r=Ly;break;case Aw.LOCAL:var i=await Om(Jy)._isAvailable();r=i?Jy:Oy;break;case Aw.NONE:r=av;break;default:return km("argument-error",{appName:this._delegate.name})}return this._delegate.setPersistence(r)}signInAndRetrieveDataWithCredential(e){return this.signInWithCredential(e)}signInAnonymously(){return Uw(this._delegate,async function(e){const t=Iv(e);if(await t._initializationPromise,null!==(n=t.currentUser)&&void 0!==n&&n.isAnonymous)return new Gv({user:t.currentUser,providerId:null,operationType:"signIn"});var n=await Hv(t,{returnSecureToken:!0}),n=await Gv._fromIdTokenResponse(t,"signIn",n,!0);return await t._updateCurrentUser(n.user),n}(this._delegate))}signInWithCredential(e){return Uw(this._delegate,iy(this._delegate,e))}signInWithCustomToken(e){return Uw(this._delegate,ay(this._delegate,e))}signInWithEmailAndPassword(e,t){return Uw(this._delegate,(n=this._delegate,e=e,t=t,iy($d(n),Fv.credential(e,t))));var n}signInWithEmailLink(e,t){return Uw(this._delegate,async function(e,t,n){var r=$d(e),i=Fv.credentialWithLink(t,n||Mm());return Rm(i._tenantId===(r.tenantId||null),r,"tenant-id-mismatch"),iy(r,i)}(this._delegate,e,t))}signInWithPhoneNumber(e,t){return jw(this._delegate,async function(e,t,n){const r=Iv(e);var i=await u_(r,t,$d(n));return new l_(i,e=>iy(r,e))}(this._delegate,e,t))}async signInWithPopup(e){return Bw(Sw(),this._delegate,"operation-not-supported-in-this-environment"),Uw(this._delegate,async function(e,t,n){var r=Iv(e);Am(e,t,Uv);var i=d_(r,n);const s=new __(r,"signInViaPopup",t,i);return s.executeNotNull()}(this._delegate,e,Ow))}async signInWithRedirect(e){return Bw(Sw(),this._delegate,"operation-not-supported-in-this-environment"),await Pw(this._delegate),S_(this._delegate,e,Ow)}updateCurrentUser(e){return this._delegate.updateCurrentUser(e)}verifyPasswordResetCode(e){return async function(e,t){var n=(await py($d(e),t))["data"];return n.email}(this._delegate,e)}unwrap(){return this._delegate}_delete(){return this._delegate._delete()}linkUnderlyingAuth(){this._delegate.wrapped=()=>this}}function $w(e,t,n){let r=e;"function"!=typeof e&&({next:r,error:t,complete:n}=e);const i=r;return{next:e=>i(e&&Vw.getOrCreate(e)),error:t,complete:n}}Ww.Persistence=Aw;class Kw{constructor(){this.providerId="phone",this._delegate=new h_(Mw(Cp.auth()))}static credential(e,t){return h_.credential(e,t)}verifyPhoneNumber(e,t){return this._delegate.verifyPhoneNumber(e,t)}unwrap(){return this._delegate}}Kw.PHONE_SIGN_IN_METHOD=h_.PHONE_SIGN_IN_METHOD,Kw.PROVIDER_ID=h_.PROVIDER_ID;const zw=Rm;class Hw{constructor(e,t,n=Cp.app()){var r;zw(null===(r=n.options)||void 0===r?void 0:r.apiKey,"invalid-api-key",{appName:n.name}),this._delegate=new c_(e,t,n.auth()),this.type=this._delegate.type}clear(){this._delegate.clear()}render(){return this._delegate.render()}verify(){return this._delegate.verify()}}(ww=Cp).INTERNAL.registerComponent(new Kd("auth-compat",e=>{var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("auth");return new Ww(t,n)},"PUBLIC").setServiceProps({ActionCodeInfo:{Operation:{EMAIL_SIGNIN:ym.EMAIL_SIGNIN,PASSWORD_RESET:ym.PASSWORD_RESET,RECOVER_EMAIL:ym.RECOVER_EMAIL,REVERT_SECOND_FACTOR_ADDITION:ym.REVERT_SECOND_FACTOR_ADDITION,VERIFY_AND_CHANGE_EMAIL:ym.VERIFY_AND_CHANGE_EMAIL,VERIFY_EMAIL:ym.VERIFY_EMAIL}},EmailAuthProvider:Fv,FacebookAuthProvider:Vv,GithubAuthProvider:Wv,GoogleAuthProvider:Bv,OAuthProvider:qv,SAMLAuthProvider:Kv,PhoneAuthProvider:Kw,PhoneMultiFactorGenerator:rw,RecaptchaVerifier:Hw,TwitterAuthProvider:zv,Auth:Ww,AuthCredential:Cv,Error:gd}).setInstantiationMode("LAZY").setMultipleInstances(!1)),ww.registerVersion("@firebase/auth-compat","0.2.5");const Gw="@firebase/database";let Qw="";function Yw(e){Qw=e}class Jw{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){null==t?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),_d(t))}get(e){var t=this.domStorage_.getItem(this.prefixedName_(e));return null==t?null:yd(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}class Xw{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){null==t?delete this.cache_[e]:this.cache_[e]=t}get(e){return bd(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}var Zw,eb,tb,nb,rb,ib,yt=function(e){try{if("undefined"!=typeof window&&void 0!==window[e]){const t=window[e];return t.setItem("firebase:sentinel","cache"),t.removeItem("firebase:sentinel"),new Jw(t)}}catch(e){}return new Xw};function sb(e){var t=function(t){const n=[];let r=0;for(let o=0;o<t.length;o++){let e=t.charCodeAt(o);var i,s;55296<=e&&e<=56319&&(i=e-55296,o++,Jh(o<t.length,"Surrogate pair missing trail surrogate."),s=t.charCodeAt(o)-56320,e=65536+(i<<10)+s),e<128?n[r++]=e:(e<2048?n[r++]=e>>6|192:(e<65536?n[r++]=e>>12|224:(n[r++]=e>>18|240,n[r++]=e>>12&63|128),n[r++]=e>>6&63|128),n[r++]=63&e|128)}return n}(e);const n=new Rd;return n.update(t),t=n.digest(),Zh.encodeByteArray(t)}const ob=yt("localStorage"),ab=yt("sessionStorage"),cb=new ep("@firebase/database"),lb=function(){let e=1;return function(){return e++}}(),ub=function(...e){let t="";for(let r=0;r<e.length;r++){var n=e[r];Array.isArray(n)||n&&"object"==typeof n&&"number"==typeof n.length?t+=ub.apply(null,n):t+="object"==typeof n?_d(n):n,t+=" "}return t};let hb=null,db=!0;function pb(t){return function(...e){wb(t,...e)}}function fb(...e){var t="FIREBASE INTERNAL ERROR: "+ub(...e);cb.error(t)}function gb(e,t){return e===t?0:e<t?-1:1}function mb(e,t){if(t&&e in t)return t[e];throw new Error("Missing required key ("+e+") in object: "+_d(t))}function vb(e){if("object"!=typeof e||null===e)return _d(e);const t=[];for(const r in e)t.push(r);t.sort();let n="{";for(let i=0;i<t.length;i++)0!==i&&(n+=","),n+=_d(t[i]),n+=":",n+=vb(e[t[i]]);return n+="}",n}function yb(e,t){var n=e.length;if(n<=t)return[e];const r=[];for(let i=0;i<n;i+=t)i+t>n?r.push(e.substring(i,n)):r.push(e.substring(i,i+t));return r}const _b=function(e,t){Jh(!t||!0===e||!1===e,"Can't turn on custom loggers persistently."),!0===e?(cb.logLevel=$h.VERBOSE,hb=cb.log.bind(cb),t&&ab.set("logging_enabled",!0)):"function"==typeof e?hb=e:(hb=null,ab.remove("logging_enabled"))},wb=function(...e){var t;!0===db&&(db=!1,null===hb&&!0===ab.get("logging_enabled")&&_b(!0)),hb&&(t=ub.apply(null,e),hb(t))},bb=function(...e){var t=`FIREBASE FATAL ERROR: ${ub(...e)}`;throw cb.error(t),new Error(t)},Ib=function(...e){var t="FIREBASE WARNING: "+ub(...e);cb.warn(t)},Tb=function(){"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&Ib("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},Eb=function(e){return"number"==typeof e&&(e!=e||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY)},kb="[MIN_NAME]",Sb="[MAX_NAME]",Cb=function(e,t){if(e===t)return 0;if(e===kb||t===Sb)return-1;if(t===kb||e===Sb)return 1;var n=Ob(e),r=Ob(t);return null!==n?null!==r?n-r==0?e.length-t.length:n-r:-1:null===r&&e<t?-1:1};function Ab(e,t){for(const n in e)e.hasOwnProperty(n)&&t(n,e[n])}function Nb(e){Jh(!Eb(e),"Invalid JSON number");let t,n,r,i,s;0===e?(n=0,r=0,t=1/e==-1/0?1:0):(t=e<0,e=Math.abs(e),r=e>=Math.pow(2,-1022)?(i=Math.min(Math.floor(Math.log(e)/Math.LN2),1023),n=i+1023,Math.round(e*Math.pow(2,52-i)-Math.pow(2,52))):(n=0,Math.round(e/Math.pow(2,-1074))));const o=[];for(s=52;s;--s)o.push(r%2?1:0),r=Math.floor(r/2);for(s=11;s;--s)o.push(n%2?1:0),n=Math.floor(n/2);o.push(t?1:0),o.reverse();const a=o.join("");let c="";for(s=0;s<64;s+=8){let e=parseInt(a.substr(s,8),2).toString(16);1===e.length&&(e="0"+e),c+=e}return c.toLowerCase()}function Rb(e,t){const n=setTimeout(e,t);return"object"==typeof n&&n.unref&&n.unref(),n}const Pb=new RegExp("^-?(0*)\\d{1,10}$"),xb=-2147483648,Db=2147483647,Ob=function(e){if(Pb.test(e)){var t=Number(e);if(t>=xb&&t<=Db)return t}return null},Mb=function(e){try{e()}catch(t){setTimeout(()=>{var e=t.stack||"";throw Ib("Exception was thrown by user callback.",e),t},Math.floor(0))}};class Lb{constructor(e,t){this.appName_=e,this.appCheckProvider=t,this.appCheck=null==t?void 0:t.getImmediate({optional:!0}),this.appCheck||null!=t&&t.get().then(e=>this.appCheck=e)}getToken(n){return this.appCheck?this.appCheck.getToken(n):new Promise((e,t)=>{setTimeout(()=>{this.appCheck?this.getToken(n).then(e,t):e(null)},0)})}addTokenChangeListener(t){var e;null!==(e=this.appCheckProvider)&&void 0!==e&&e.get().then(e=>e.addTokenListener(t))}notifyForInvalidToken(){Ib(`Provided AppCheck credentials for the app named "${this.appName_}" `+"are invalid. This usually indicates your app was not initialized correctly.")}}class Fb{constructor(e,t,n){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=n,this.auth_=null,this.auth_=n.getImmediate({optional:!0}),this.auth_||n.onInit(e=>this.auth_=e)}getToken(n){return this.auth_?this.auth_.getToken(n).catch(e=>e&&"auth/token-not-initialized"===e.code?(wb("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(e)):new Promise((e,t)=>{setTimeout(()=>{this.auth_?this.getToken(n).then(e,t):e(null)},0)})}addTokenChangeListener(t){this.auth_?this.auth_.addAuthTokenListener(t):this.authProvider_.get().then(e=>e.addAuthTokenListener(t))}removeTokenChangeListener(t){this.authProvider_.get().then(e=>e.removeAuthTokenListener(t))}notifyForInvalidToken(){let e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',Ib(e)}}class Ub{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}Ub.OWNER="owner";const jb=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,qb="websocket",Vb="long_polling";class Bb{constructor(e,t,n,r,i=!1,s="",o=!1){this.secure=t,this.namespace=n,this.webSocketOnly=r,this.nodeAdmin=i,this.persistenceKey=s,this.includeNamespaceInQueryParams=o,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=ob.get("host:"+e)||this._host}isCacheableHost(){return"s-"===this.internalHost.substr(0,2)}isCustomHost(){return"firebaseio.com"!==this._domain&&"firebaseio-demo.com"!==this._domain}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&ob.set("host:"+this._host,this.internalHost))}toString(){let e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e}toURLString(){var e=this.secure?"https://":"http://",t=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${e}${this.host}/${t}`}}function Wb(e,t,n){Jh("string"==typeof t,"typeof type must == string"),Jh("object"==typeof n,"typeof params must == object");let r;if(t===qb)r=(e.secure?"wss://":"ws://")+e.internalHost+"/.ws?";else{if(t!==Vb)throw new Error("Unknown connection type: "+t);r=(e.secure?"https://":"http://")+e.internalHost+"/.lp?"}((t=e).host!==t.internalHost||t.isCustomHost()||t.includeNamespaceInQueryParams)&&(n.ns=e.namespace);const i=[];return Ab(n,(e,t)=>{i.push(e+"="+t)}),r+i.join("&")}class $b{constructor(){this.counters_={}}incrementCounter(e,t=1){bd(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return nd(void 0,this.counters_)}}const Kb={},zb={};function Hb(e){var t=e.toString();return Kb[t]||(Kb[t]=new $b),Kb[t]}class Gb{constructor(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(e,t){for(this.pendingResponses[e]=t;this.pendingResponses[this.currentResponseNum];){const n=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let e=0;e<n.length;++e)n[e]&&Mb(()=>{this.onMessage_(n[e])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}class Qb{constructor(e,t,n,r,i,s,o){this.connId=e,this.repoInfo=t,this.applicationId=n,this.appCheckToken=r,this.authToken=i,this.transportSessionId=s,this.lastSessionId=o,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=pb(e),this.stats_=Hb(t),this.urlFn=e=>(this.appCheckToken&&(e.ac=this.appCheckToken),Wb(t,Vb,e))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new Gb(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(3e4)),function(t){if("complete"===document.readyState)t();else{let e=!1;const n=function(){document.body?e||(e=!0,t()):setTimeout(n,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{"complete"===document.readyState&&n()}),window.attachEvent("onload",n))}}(()=>{if(!this.isClosed_){this.scriptTagHolder=new Yb((...e)=>{var[t,n,r]=e;if(this.incrementIncomingBytes_(e),this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,"start"===t)this.id=n,this.password=r;else{if("close"!==t)throw new Error("Unrecognized command received: "+t);n?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(n,()=>{this.onClosed_()})):this.onClosed_()}},(...e)=>{var[t,n]=e;this.incrementIncomingBytes_(e),this.myPacketOrderer.handleResponse(t,n)},()=>{this.onClosed_()},this.urlFn);const t={start:"t"};t.ser=Math.floor(1e8*Math.random()),this.scriptTagHolder.uniqueCallbackIdentifier&&(t.cb=this.scriptTagHolder.uniqueCallbackIdentifier),t.v="5",this.transportSessionId&&(t.s=this.transportSessionId),this.lastSessionId&&(t.ls=this.lastSessionId),this.applicationId&&(t.p=this.applicationId),this.appCheckToken&&(t.ac=this.appCheckToken),"undefined"!=typeof location&&location.hostname&&jb.test(location.hostname)&&(t.r="f");var e=this.urlFn(t);this.log_("Connecting via long-poll to "+e),this.scriptTagHolder.addTag(e,()=>{})}})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){Qb.forceAllow_=!0}static forceDisallow(){Qb.forceDisallow_=!0}static isAvailable(){return!!Qb.forceAllow_||!(Qb.forceDisallow_||"undefined"==typeof document||null==document.createElement||"object"==typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href)||"object"==typeof Windows&&"object"==typeof Windows.UI)}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(e){var t=_d(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);var t=Qh(t),n=yb(t,1840);for(let r=0;r<n.length;r++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,n.length,n[r]),this.curSegmentNum++}addDisconnectPingFrame(e,t){this.myDisconnFrame=document.createElement("iframe");const n={dframe:"t"};n.id=e,n.pw=t,this.myDisconnFrame.src=this.urlFn(n),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){var t=_d(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class Yb{constructor(t,n,e,r){this.onDisconnect=e,this.urlFn=r,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0;{this.uniqueCallbackIdentifier=lb(),window["pLPCommand"+this.uniqueCallbackIdentifier]=t,window["pRTLPCB"+this.uniqueCallbackIdentifier]=n,this.myIFrame=Yb.createIFrame_();let e="";this.myIFrame.src&&"javascript:"===this.myIFrame.src.substr(0,"javascript:".length)&&(i=document.domain,e='<script>document.domain="'+i+'";<\/script>');var i="<html><body>"+e+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(i),this.myIFrame.doc.close()}catch(e){wb("frame writing exception"),e.stack&&wb(e.stack),wb(e)}}}static createIFrame_(){const t=document.createElement("iframe");if(t.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(t);try{t.contentWindow.document||wb("No IE domain setting required")}catch(e){var n=document.domain;t.src="javascript:void((function(){document.open();document.domain='"+n+"';document.close();})())"}return t.contentDocument?t.doc=t.contentDocument:t.contentWindow?t.doc=t.contentWindow.document:t.document&&(t.doc=t.document),t}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.innerHTML="",setTimeout(()=>{null!==this.myIFrame&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));const e=this.onDisconnect;e&&(this.onDisconnect=null,e())}startLongPoll(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(0<this.pendingSegs.length?2:1)){this.currentSerial++;const i={};i.id=this.myID,i.pw=this.myPW,i.ser=this.currentSerial;var n=this.urlFn(i);let e="",t=0;for(;0<this.pendingSegs.length;){if(!(this.pendingSegs[0].d.length+30+e.length<=1870))break;var r=this.pendingSegs.shift();e=e+"&seg"+t+"="+r.seg+"&ts"+t+"="+r.ts+"&d"+t+"="+r.d,t++}return n+=e,this.addLongPollTag_(n,this.currentSerial),!0}return!1}enqueueSegment(e,t,n){this.pendingSegs.push({seg:e,ts:t,d:n}),this.alive&&this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);const n=()=>{this.outstandingRequests.delete(t),this.newRequest_()},r=setTimeout(n,Math.floor(25e3));this.addTag(e,()=>{clearTimeout(r),n()})}addTag(e,n){setTimeout(()=>{try{if(!this.sendNewPolls)return;const t=this.myIFrame.doc.createElement("script");t.type="text/javascript",t.async=!0,t.src=e,t.onload=t.onreadystatechange=function(){var e=t.readyState;e&&"loaded"!==e&&"complete"!==e||(t.onload=t.onreadystatechange=null,t.parentNode&&t.parentNode.removeChild(t),n())},t.onerror=()=>{wb("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(t)}catch(e){}},Math.floor(1))}}let Jb=null;"undefined"!=typeof MozWebSocket?Jb=MozWebSocket:"undefined"!=typeof WebSocket&&(Jb=WebSocket);class Xb{constructor(e,t,n,r,i,s,o){this.connId=e,this.applicationId=n,this.appCheckToken=r,this.authToken=i,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=pb(this.connId),this.stats_=Hb(t),this.connURL=Xb.connectionURL_(t,s,o,r),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,n,r){const i={v:"5"};return"undefined"!=typeof location&&location.hostname&&jb.test(location.hostname)&&(i.r="f"),t&&(i.s=t),n&&(i.ls=n),r&&(i.ac=r),Wb(e,qb,i)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,ob.set("previous_websocket_failure",!0);try{hd()||(n={headers:{"X-Firebase-GMPID":this.applicationId||"","X-Firebase-AppCheck":this.appCheckToken||""}},this.mySock=new Jb(this.connURL,[],n))}catch(e){this.log_("Error instantiating WebSocket.");var n=e.message||e.data;return n&&this.log_(n),void this.onClosed_()}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=e=>{this.handleIncomingFrame(e)},this.mySock.onerror=e=>{this.log_("WebSocket error. Closing connection.");var t=e.message||e.data;t&&this.log_(t),this.onClosed_()}}start(){}static forceDisallow(){Xb.forceDisallow_=!0}static isAvailable(){let e=!1;var t;return"undefined"==typeof navigator||!navigator.userAgent||(t=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/))&&1<t.length&&parseFloat(t[1])<4.4&&(e=!0),!e&&null!==Jb&&!Xb.forceDisallow_}static previouslyFailed(){return ob.isInMemoryStorage||!0===ob.get("previous_websocket_failure")}markConnectionHealthy(){ob.remove("previous_websocket_failure")}appendFrame_(e){var t;this.frames.push(e),this.frames.length===this.totalFrames&&(t=this.frames.join(""),this.frames=null,t=yd(t),this.onMessage(t))}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(Jh(null===this.frames,"We already have a frame buffer"),e.length<=6){var t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){var t;null!==this.mySock&&(t=e.data,this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),null!==this.frames?this.appendFrame_(t):null!==(t=this.extractFrameCount_(t))&&this.appendFrame_(t))}send(e){this.resetKeepAlive();var t=_d(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);var n=yb(t,16384);1<n.length&&this.sendString_(String(n.length));for(let r=0;r<n.length;r++)this.sendString_(n[r])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(45e3))}sendString_(e){try{this.mySock.send(e)}catch(e){this.log_("Exception thrown from WebSocket.send():",e.message||e.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}Xb.responsesRequiredToBeHealthy=2,Xb.healthyTimeout=3e4;class Zb{constructor(e){this.initTransports_(e)}static get ALL_TRANSPORTS(){return[Qb,Xb]}initTransports_(e){var t=Xb&&Xb.isAvailable();let n=t&&!Xb.previouslyFailed();if(e.webSocketOnly&&(t||Ib("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),n=!0),n)this.transports_=[Xb];else{const r=this.transports_=[];for(const i of Zb.ALL_TRANSPORTS)i&&i.isAvailable()&&r.push(i)}}initialTransport(){if(0<this.transports_.length)return this.transports_[0];throw new Error("No transports available")}upgradeTransport(){return 1<this.transports_.length?this.transports_[1]:null}}class eI{constructor(e,t,n,r,i,s,o,a,c,l){this.id=e,this.repoInfo_=t,this.applicationId_=n,this.appCheckToken_=r,this.authToken_=i,this.onMessage_=s,this.onReady_=o,this.onDisconnect_=a,this.onKill_=c,this.lastSessionId=l,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=pb("c:"+this.id+":"),this.transportManager_=new Zb(t),this.log_("Connection created"),this.start_()}start_(){const e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.conn_),n=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(()=>{this.conn_&&this.conn_.open(t,n)},Math.floor(0));var r=e.healthyTimeout||0;0<r&&(this.healthyTimeout_=Rb(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&102400<this.conn_.bytesReceived?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes. Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&10240<this.conn_.bytesSent?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes. Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))},Math.floor(r)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(t){return e=>{t===this.conn_?this.onConnectionLost_(e):t===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(t){return e=>{2!==this.state_&&(t===this.rx_?this.onPrimaryMessageReceived_(e):t===this.secondaryConn_?this.onSecondaryMessageReceived_(e):this.log_("message on old connection"))}}sendRequest(e){this.sendData_({t:"d",d:e})}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(e){var t;"t"in e&&("a"===(t=e.t)?this.upgradeIfSecondaryHealthy_():"r"===t?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===t&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_()))}onSecondaryMessageReceived_(e){var t=mb("t",e),n=mb("d",e);if("c"===t)this.onSecondaryControl_(n);else{if("d"!==t)throw new Error("Unknown protocol layer: "+t);this.pendingDataMessages.push(n)}}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:"p",d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:"n",d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){var t=mb("t",e),n=mb("d",e);"c"===t?this.onControl_(n):"d"===t&&this.onDataMessage_(n)}onDataMessage_(e){this.onPrimaryResponse_(),this.onMessage_(e)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(e){var t=mb("t",e);if("d"in e){var n=e.d;if("h"===t)this.onHandshake_(n);else if("n"===t){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let e=0;e<this.pendingDataMessages.length;++e)this.onDataMessage_(this.pendingDataMessages[e]);this.pendingDataMessages=[],this.tryCleanupConnection()}else"s"===t?this.onConnectionShutdown_(n):"r"===t?this.onReset_(n):"e"===t?fb("Server Error: "+n):"o"===t?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):fb("Unknown control packet command: "+t)}}onHandshake_(e){var t=e.ts,n=e.v,r=e.h;this.sessionId=e.s,this.repoInfo_.host=r,0===this.state_&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),"5"!==n&&Ib("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){var e=this.transportManager_.upgradeTransport();e&&this.startUpgrade_(e)}startUpgrade_(e){this.secondaryConn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;var t=this.connReceiver_(this.secondaryConn_),n=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,n),Rb(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(6e4))}onReset_(e){this.log_("Reset packet received. New host: "+e),this.repoInfo_.host=e,1===this.state_?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(e,t){this.log_("Realtime connection established."),this.conn_=e,this.state_=1,this.onReady_&&(this.onReady_(t,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):Rb(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(5e3))}sendPingOnPrimaryIfNecessary_(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))}onSecondaryConnectionLost_(){var e=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==e&&this.rx_!==e||this.close()}onConnectionLost_(e){this.conn_=null,e||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(ob.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()}onConnectionShutdown_(e){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(e),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(e){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(e)}close(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}class tI{put(e,t,n,r){}merge(e,t,n,r){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,n){}onDisconnectMerge(e,t,n){}onDisconnectCancel(e,t){}reportStats(e){}}class nI{constructor(e){this.allowedEvents_=e,this.listeners_={},Jh(Array.isArray(e)&&0<e.length,"Requires a non-empty array")}trigger(t,...n){if(Array.isArray(this.listeners_[t])){const r=[...this.listeners_[t]];for(let e=0;e<r.length;e++)r[e].callback.apply(r[e].context,n)}}on(e,t,n){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:n});var r=this.getInitialEvent(e);r&&t.apply(n,r)}off(e,t,n){this.validateEventType_(e);const r=this.listeners_[e]||[];for(let i=0;i<r.length;i++)if(r[i].callback===t&&(!n||n===r[i].context))return void r.splice(i,1)}validateEventType_(t){Jh(this.allowedEvents_.find(e=>e===t),"Unknown event: "+t)}}class rI extends nI{constructor(){super(["online"]),this.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||od()||(window.addEventListener("online",()=>{this.online_||(this.online_=!0,this.trigger("online",!0))},!1),window.addEventListener("offline",()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))},!1))}static getInstance(){return new rI}getInitialEvent(e){return Jh("online"===e,"Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}class iI{constructor(n,e){if(void 0===e){this.pieces_=n.split("/");let e=0;for(let t=0;t<this.pieces_.length;t++)0<this.pieces_[t].length&&(this.pieces_[e]=this.pieces_[t],e++);this.pieces_.length=e,this.pieceNum_=0}else this.pieces_=n,this.pieceNum_=e}toString(){let e="";for(let t=this.pieceNum_;t<this.pieces_.length;t++)""!==this.pieces_[t]&&(e+="/"+this.pieces_[t]);return e||"/"}}function sI(){return new iI("")}function oI(e){return e.pieceNum_>=e.pieces_.length?null:e.pieces_[e.pieceNum_]}function aI(e){return e.pieces_.length-e.pieceNum_}function cI(e){let t=e.pieceNum_;return t<e.pieces_.length&&t++,new iI(e.pieces_,t)}function lI(e){return e.pieceNum_<e.pieces_.length?e.pieces_[e.pieces_.length-1]:null}function uI(e,t=0){return e.pieces_.slice(e.pieceNum_+t)}function hI(e){if(e.pieceNum_>=e.pieces_.length)return null;const t=[];for(let n=e.pieceNum_;n<e.pieces_.length-1;n++)t.push(e.pieces_[n]);return new iI(t,0)}function dI(e,t){const n=[];for(let i=e.pieceNum_;i<e.pieces_.length;i++)n.push(e.pieces_[i]);if(t instanceof iI)for(let e=t.pieceNum_;e<t.pieces_.length;e++)n.push(t.pieces_[e]);else{var r=t.split("/");for(let e=0;e<r.length;e++)0<r[e].length&&n.push(r[e])}return new iI(n,0)}function pI(e){return e.pieceNum_>=e.pieces_.length}function fI(e,t){var n=oI(e),r=oI(t);if(null===n)return t;if(n===r)return fI(cI(e),cI(t));throw new Error("INTERNAL ERROR: innerPath ("+t+") is not within outerPath ("+e+")")}function gI(e,t){var n=uI(e,0),r=uI(t,0);for(let s=0;s<n.length&&s<r.length;s++){var i=Cb(n[s],r[s]);if(0!==i)return i}return n.length===r.length?0:n.length<r.length?-1:1}function mI(e,t){if(aI(e)!==aI(t))return!1;for(let n=e.pieceNum_,r=t.pieceNum_;n<=e.pieces_.length;n++,r++)if(e.pieces_[n]!==t.pieces_[r])return!1;return!0}function vI(e,t){let n=e.pieceNum_,r=t.pieceNum_;if(aI(e)>aI(t))return!1;for(;n<e.pieces_.length;){if(e.pieces_[n]!==t.pieces_[r])return!1;++n,++r}return!0}class yI{constructor(e,t){this.errorPrefix_=t,this.parts_=uI(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let n=0;n<this.parts_.length;n++)this.byteLength_+=Ud(this.parts_[n]);_I(this)}}function _I(e){if(768<e.byteLength_)throw new Error(e.errorPrefix_+"has a key path longer than 768 bytes ("+e.byteLength_+").");if(32<e.parts_.length)throw new Error(e.errorPrefix_+"path specified exceeds the maximum depth that can be written (32) or object contains a cycle "+wI(e))}function wI(e){return 0===e.parts_.length?"":"in property '"+e.parts_.join(".")+"'"}class bI extends nI{constructor(){super(["visible"]);let t,e;"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(e="visibilitychange",t="hidden"):void 0!==document.mozHidden?(e="mozvisibilitychange",t="mozHidden"):void 0!==document.msHidden?(e="msvisibilitychange",t="msHidden"):void 0!==document.webkitHidden&&(e="webkitvisibilitychange",t="webkitHidden")),this.visible_=!0,e&&document.addEventListener(e,()=>{var e=!document[t];e!==this.visible_&&(this.visible_=e,this.trigger("visible",e))},!1)}static getInstance(){return new bI}getInitialEvent(e){return Jh("visible"===e,"Unknown event type: "+e),[this.visible_]}}class II extends tI{constructor(e,t,n,r,i,s,o,a){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=n,this.onConnectStatus_=r,this.onServerInfoUpdate_=i,this.authTokenProvider_=s,this.appCheckTokenProvider_=o,this.authOverride_=a,this.id=II.nextPersistentConnectionId_++,this.log_=pb("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=1e3,this.maxReconnectDelay_=3e5,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,a&&!hd())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");bI.getInstance().on("visible",this.onVisible_,this),-1===e.host.indexOf("fblocal")&&rI.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,n){var r=++this.requestNumber_,i={r:r,a:e,b:t};this.log_(_d(i)),Jh(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(i),n&&(this.requestCBHash_[r]=n)}get(e){this.initConnection_();const n=new rd,r={p:e._path.toString(),q:e._queryObject},t={action:"g",request:r,onComplete:e=>{var t=e.d;"ok"===e.s?(this.onDataUpdate_(r.p,t,!1,null),n.resolve(t)):n.reject(t)}};this.outstandingGets_.push(t),this.outstandingGetCount_++;const i=this.outstandingGets_.length-1;return this.connected_||setTimeout(()=>{var e=this.outstandingGets_[i];void 0!==e&&t===e&&(delete this.outstandingGets_[i],this.outstandingGetCount_--,0===this.outstandingGetCount_&&(this.outstandingGets_=[]),this.log_("get "+i+" timed out on connection"),n.reject(new Error("Client is offline.")))},3e3),this.connected_&&this.sendGet_(i),n.promise}listen(e,t,n,r){this.initConnection_();var i=e._queryIdentifier,s=e._path.toString();this.log_("Listen called for "+s+" "+i),this.listens.has(s)||this.listens.set(s,new Map),Jh(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),Jh(!this.listens.get(s).has(i),"listen() called twice for same path/queryId.");var o={onComplete:r,hashFn:t,query:e,tag:n};this.listens.get(s).set(i,o),this.connected_&&this.sendListen_(o)}sendGet_(t){const n=this.outstandingGets_[t];this.sendRequest("g",n.request,e=>{delete this.outstandingGets_[t],this.outstandingGetCount_--,0===this.outstandingGetCount_&&(this.outstandingGets_=[]),n.onComplete&&n.onComplete(e)})}sendListen_(r){const i=r.query,s=i._path.toString(),o=i._queryIdentifier;this.log_("Listen on "+s+" for "+o);const e={p:s};r.tag&&(e.q=i._queryObject,e.t=r.tag),e.h=r.hashFn(),this.sendRequest("q",e,e=>{var t=e.d,n=e.s;II.warnOnListenWarnings_(t,i),(this.listens.get(s)&&this.listens.get(s).get(o))===r&&(this.log_("listen response",e),"ok"!==n&&this.removeListen_(s,o),r.onComplete&&r.onComplete(n,t))})}static warnOnListenWarnings_(e,t){if(e&&"object"==typeof e&&bd(e,"w")){const i=Id(e,"w");var n,r;Array.isArray(i)&&~i.indexOf("no_index")&&(n='".indexOn": "'+t._queryParams.getIndex().toString()+'"',r=t._path.toString(),Ib("Using an unspecified index. Your data will be downloaded and "+`filtered on the client. Consider adding ${n} at `+`${r} to your security rules for better performance.`))}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){var t;(e&&40===e.length||(e=e,"object"==typeof(t=wd(e).claims)&&!0===t.admin))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=3e4)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){const r=this.authToken_;var e=function(e){const t=wd(e),n=t.claims;return!!n&&"object"==typeof n&&n.hasOwnProperty("iat")}(r)?"auth":"gauth";const t={cred:r};null===this.authOverride_?t.noauth=!0:"object"==typeof this.authOverride_&&(t.authvar=this.authOverride_),this.sendRequest(e,t,e=>{var t=e.s,n=e.d||"error";this.authToken_===r&&("ok"===t?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(t,n))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{var t=e.s,n=e.d||"error";"ok"===t?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,n)})}unlisten(e,t){var n=e._path.toString(),r=e._queryIdentifier;this.log_("Unlisten called for "+n+" "+r),Jh(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(n,r)&&this.connected_&&this.sendUnlisten_(n,r,e._queryObject,t)}sendUnlisten_(e,t,n,r){this.log_("Unlisten on "+e+" for "+t);const i={p:e};r&&(i.q=n,i.t=r),this.sendRequest("n",i)}onDisconnectPut(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:n})}onDisconnectMerge(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:n})}onDisconnectCancel(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})}sendOnDisconnect_(e,t,n,r){var i={p:t,d:n};this.log_("onDisconnect "+e,i),this.sendRequest(e,i,e=>{r&&setTimeout(()=>{r(e.s,e.d)},Math.floor(0))})}put(e,t,n,r){this.putInternal("p",e,t,n,r)}merge(e,t,n,r){this.putInternal("m",e,t,n,r)}putInternal(e,t,n,r,i){this.initConnection_();const s={p:t,d:n};void 0!==i&&(s.h=i),this.outstandingPuts_.push({action:e,request:s,onComplete:r}),this.outstandingPutCount_++;var o=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(o):this.log_("Buffering put: "+t)}sendPut_(t){const n=this.outstandingPuts_[t].action;var e=this.outstandingPuts_[t].request;const r=this.outstandingPuts_[t].onComplete;this.outstandingPuts_[t].queued=this.connected_,this.sendRequest(n,e,e=>{this.log_(n+" response",e),delete this.outstandingPuts_[t],this.outstandingPutCount_--,0===this.outstandingPutCount_&&(this.outstandingPuts_=[]),r&&r(e.s,e.d)})}reportStats(e){var t;this.connected_&&(this.log_("reportStats",t={c:e}),this.sendRequest("s",t,e=>{var t;"ok"!==e.s&&(t=e.d,this.log_("reportStats","Error sending stats: "+t))}))}onDataMessage_(e){if("r"in e){this.log_("from server: "+_d(e));var t=e.r;const n=this.requestCBHash_[t];n&&(delete this.requestCBHash_[t],n(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,t){this.log_("handleServerMessage",e,t),"d"===e?this.onDataUpdate_(t.p,t.d,!1,t.t):"m"===e?this.onDataUpdate_(t.p,t.d,!0,t.t):"c"===e?this.onListenRevoked_(t.p,t.q):"ac"===e?this.onAuthRevoked_(t.s,t.d):"apc"===e?this.onAppCheckRevoked_(t.s,t.d):"sd"===e?this.onSecurityDebugPacket_(t):fb("Unrecognized action received from server: "+_d(e)+"\nAre you using the latest client?")}onReady_(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){Jh(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(()=>{this.establishConnectionTimer_=null,this.establishConnection_()},Math.floor(e))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=1e3,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=1e3,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){var e;this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()&&(this.visible_?this.lastConnectionEstablishedTime_&&(3e4<(new Date).getTime()-this.lastConnectionEstablishedTime_&&(this.reconnectDelay_=1e3),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime()),e=(new Date).getTime()-this.lastConnectionAttemptTime_,e=Math.max(0,this.reconnectDelay_-e),e=Math.random()*e,this.log_("Trying to reconnect in "+e+"ms"),this.scheduleConnect_(e),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)),this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;var e=this.onDataMessage_.bind(this),r=this.onReady_.bind(this);const u=this.onRealtimeDisconnect_.bind(this);var i=this.id+":"+II.nextConnectionId_++,s=this.lastSessionId;let t=!1,n=null;var o=function(){n?n.close():(t=!0,u())};this.realtime_={close:o,sendRequest:function(e){Jh(n,"sendRequest call when we're not connected not allowed."),n.sendRequest(e)}};var a=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{var[c,l]=await Promise.all([this.authTokenProvider_.getToken(a),this.appCheckTokenProvider_.getToken(a)]);t?wb("getToken() completed but was canceled"):(wb("getToken() completed. Creating connection."),this.authToken_=c&&c.accessToken,this.appCheckToken_=l&&l.token,n=new eI(i,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,r,u,e=>{Ib(e+" ("+this.repoInfo_.toString()+")"),this.interrupt("server_kill")},s))}catch(e){this.log_("Failed to get token: "+e),t||(this.repoInfo_.nodeAdmin&&Ib(e),o())}}}interrupt(e){wb("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(e){wb("Resuming connection for reason: "+e),delete this.interruptReasons_[e],Td(this.interruptReasons_)&&(this.reconnectDelay_=1e3,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){var t=e-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:t})}cancelSentTransactions_(){for(let e=0;e<this.outstandingPuts_.length;e++){const t=this.outstandingPuts_[e];t&&"h"in t.request&&t.queued&&(t.onComplete&&t.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}0===this.outstandingPutCount_&&(this.outstandingPuts_=[])}onListenRevoked_(e,t){let n;n=t?t.map(e=>vb(e)).join("$"):"default";const r=this.removeListen_(e,n);r&&r.onComplete&&r.onComplete("permission_denied")}removeListen_(e,t){var n=new iI(e).toString();let r;if(this.listens.has(n)){const i=this.listens.get(n);r=i.get(t),i.delete(t),0===i.size&&this.listens.delete(n)}else r=void 0;return r}onAuthRevoked_(e,t){wb("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAuthTokenCount_++,3<=this.invalidAuthTokenCount_&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){wb("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAppCheckTokenCount_++,3<=this.invalidAppCheckTokenCount_&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace("\n","\nFIREBASE: "))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const t of this.listens.values())for(const n of t.values())this.sendListen_(n);for(let r=0;r<this.outstandingPuts_.length;r++)this.outstandingPuts_[r]&&this.sendPut_(r);for(;this.onDisconnectRequestQueue_.length;){var e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let i=0;i<this.outstandingGets_.length;i++)this.outstandingGets_[i]&&this.sendGet_(i)}sendConnectStats_(){const e={};e["sdk.js."+Qw.replace(/\./g,"-")]=1,od()?e["framework.cordova"]=1:ld()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){var e=rI.getInstance().currentlyOnline();return Td(this.interruptReasons_)&&e}}II.nextPersistentConnectionId_=0,II.nextConnectionId_=0;class TI{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new TI(e,t)}}class EI{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){var n=new TI(kb,e),r=new TI(kb,t);return 0!==this.compare(n,r)}minPost(){return TI.MIN}}let kI;class SI extends EI{static get __EMPTY_NODE(){return kI}static set __EMPTY_NODE(e){kI=e}compare(e,t){return Cb(e.name,t.name)}isDefinedOn(e){throw Xh("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return TI.MIN}maxPost(){return new TI(Sb,kI)}makePost(e,t){return Jh("string"==typeof e,"KeyIndex indexValue must always be a string."),new TI(e,kI)}toString(){return".key"}}const CI=new SI;class AI{constructor(e,t,n,r,i=null){this.isReverse_=r,this.resultGenerator_=i,this.nodeStack_=[];let s=1;for(;!e.isEmpty();)if(s=t?n(e.key,t):1,r&&(s*=-1),s<0)e=this.isReverse_?e.left:e.right;else{if(0===s){this.nodeStack_.push(e);break}this.nodeStack_.push(e),e=this.isReverse_?e.right:e.left}}getNext(){if(0===this.nodeStack_.length)return null;let e=this.nodeStack_.pop(),t;if(t=this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value},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 0<this.nodeStack_.length}peek(){if(0===this.nodeStack_.length)return null;var e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}}}class NI{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:NI.RED,this.left=null!=r?r:RI.EMPTY_NODE,this.right=null!=i?i:RI.EMPTY_NODE}copy(e,t,n,r,i){return new NI(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)}count(){return this.left.count()+1+this.right.count()}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;var 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)),r.fixUp_()}removeMin_(){if(this.left.isEmpty())return RI.EMPTY_NODE;let e=this;return e.left.isRed_()||e.left.left.isRed_()||(e=e.moveRedLeft_()),e=e.copy(null,null,null,e.left.removeMin_(),null),e.fixUp_()}remove(e,t){let n,r;if(n=this,t(e,n.key)<0)n.left.isEmpty()||n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),n=n.copy(null,null,null,n.left.remove(e,t),null);else{if(n.left.isRed_()&&(n=n.rotateRight_()),n.right.isEmpty()||n.right.isRed_()||n.right.left.isRed_()||(n=n.moveRedRight_()),0===t(e,n.key)){if(n.right.isEmpty())return RI.EMPTY_NODE;r=n.right.min_(),n=n.copy(r.key,r.value,null,null,n.right.removeMin_())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.fixUp_()}isRed_(){return this.color}fixUp_(){let e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e}moveRedLeft_(){let e=this.colorFlip_();return e.right.left.isRed_()&&(e=e.copy(null,null,null,null,e.right.rotateRight_()),e=e.rotateLeft_(),e=e.colorFlip_()),e}moveRedRight_(){let e=this.colorFlip_();return e.left.left.isRed_()&&(e=e.rotateRight_(),e=e.colorFlip_()),e}rotateLeft_(){var e=this.copy(null,null,NI.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){var e=this.copy(null,null,NI.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip_(){var 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_(){var e=this.check_();return Math.pow(2,e)<=this.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");var e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)}}NI.RED=!0,NI.BLACK=!1;class RI{constructor(e,t=RI.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new RI(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,NI.BLACK,null,null))}remove(e){return new RI(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,NI.BLACK,null,null))}get(e){var t;let n=this.root_;for(;!n.isEmpty();){if(0===(t=this.comparator_(e,n.key)))return n.value;t<0?n=n.left:0<t&&(n=n.right)}return null}getPredecessorKey(e){let t,n=this.root_,r=null;for(;!n.isEmpty();){if(0===(t=this.comparator_(e,n.key))){if(n.left.isEmpty())return r?r.key:null;for(n=n.left;!n.right.isEmpty();)n=n.right;return n.key}t<0?n=n.left:0<t&&(r=n,n=n.right)}throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(e){return this.root_.inorderTraversal(e)}reverseTraversal(e){return this.root_.reverseTraversal(e)}getIterator(e){return new AI(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new AI(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new AI(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new AI(this.root_,null,this.comparator_,!0,e)}}function PI(e,t){return Cb(e.name,t.name)}function xI(e,t){return Cb(e,t)}RI.EMPTY_NODE=new class{copy(e,t,n,r,i){return this}insert(e,t,n){return new NI(e,t,null)}remove(e,t){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}};let DI;function OI(e){return"number"==typeof e?"number:"+Nb(e):"string:"+e}function MI(e){var t;e.isLeafNode()?(t=e.val(),Jh("string"==typeof t||"number"==typeof t||"object"==typeof t&&bd(t,".sv"),"Priority must be a string or number.")):Jh(e===DI||e.isEmpty(),"priority of unexpected type."),Jh(e===DI||e.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")}let LI;class FI{constructor(e,t=FI.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,Jh(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),MI(this.priorityNode_)}static set __childrenNodeConstructor(e){LI=e}static get __childrenNodeConstructor(){return LI}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new FI(this.value_,e)}getImmediateChild(e){return".priority"===e?this.priorityNode_:FI.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return pI(e)?this:".priority"===oI(e)?this.priorityNode_:FI.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,t){return null}updateImmediateChild(e,t){return".priority"===e?this.updatePriority(t):t.isEmpty()&&".priority"!==e?this:FI.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){var n=oI(e);return null===n?t:t.isEmpty()&&".priority"!==n?this:(Jh(".priority"!==n||1===aI(e),".priority must be the last token in a path"),this.updateImmediateChild(n,FI.__childrenNodeConstructor.EMPTY_NODE.updateChild(cI(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(null===this.lazyHash_){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+OI(this.priorityNode_.val())+":");var t=typeof this.value_;e+=t+":",e+="number"==t?Nb(this.value_):this.value_,this.lazyHash_=sb(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===FI.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof FI.__childrenNodeConstructor?-1:(Jh(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){var t=typeof e.value_,n=typeof this.value_,r=FI.VALUE_TYPE_ORDER.indexOf(t),i=FI.VALUE_TYPE_ORDER.indexOf(n);return Jh(0<=r,"Unknown leaf type: "+t),Jh(0<=i,"Unknown leaf type: "+n),r===i?"object"==n?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:i-r}withIndex(){return this}isIndexed(){return!0}equals(e){return e===this||!!e.isLeafNode()&&(this.value_===e.value_&&this.priorityNode_.equals(e.priorityNode_))}}FI.VALUE_TYPE_ORDER=["object","boolean","number","string"];let UI,jI;const qI=new class extends EI{compare(e,t){const n=e.node.getPriority();var r=t.node.getPriority(),r=n.compareTo(r);return 0===r?Cb(e.name,t.name):r}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return TI.MIN}maxPost(){return new TI(Sb,new FI("[PRIORITY-POST]",jI))}makePost(e,t){var n=UI(e);return new TI(t,new FI("[PRIORITY-POST]",n))}toString(){return".priority"}},VI=Math.log(2);class BI{constructor(e){var t;this.count=(t=e+1,parseInt(Math.log(t)/VI,10)),this.current_=this.count-1;var n,r=(n=this.count,parseInt(Array(n+1).join("1"),2));this.bits_=e+1&r}nextBitIsOne(){var e=!(this.bits_&1<<this.current_);return this.current_--,e}}function WI(c,e,l,t){c.sort(e);const u=function(e,t){var n=t-e;let r,i;if(0==n)return null;if(1==n)return r=c[e],i=l?l(r):r,new NI(i,r.node,NI.BLACK,null,null);var s=parseInt(n/2,10)+e,o=u(e,s),n=u(s+1,t);return r=c[s],i=l?l(r):r,new NI(i,r.node,NI.BLACK,o,n)};var n=function(e){let s=null,o=null,a=c.length;function t(e,t){var n=a-e,r=a;a-=e;var i=u(1+n,r),r=c[n],n=l?l(r):r;!function(e){if(s){s.left=e;s=e}else{o=e;s=e}}(new NI(n,r.node,t,null,i))}for(let i=0;i<e.count;++i){var n=e.nextBitIsOne(),r=Math.pow(2,e.count-(i+1));n?t(r,NI.BLACK):(t(r,NI.BLACK),t(r,NI.RED))}return o}(new BI(c.length));return new RI(t||e,n)}let $I;const KI={};class zI{constructor(e,t){this.indexes_=e,this.indexSet_=t}static get Default(){return Jh((KI,qI),"ChildrenNode.ts has not been loaded"),$I=$I||new zI({".priority":KI},{".priority":qI}),$I}get(e){var t=Id(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof RI?t:null}hasIndex(e){return bd(this.indexSet_,e.toString())}addIndex(e,t){Jh(e!==CI,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const n=[];let r=!1;const i=t.getIterator(TI.Wrap);let s=i.getNext();for(;s;)r=r||e.isDefinedOn(s.node),n.push(s),s=i.getNext();let o;o=r?WI(n,e.getCompare()):KI;var a=e.toString();const c=Object.assign({},this.indexSet_);c[a]=e;const l=Object.assign({},this.indexes_);return l[a]=o,new zI(l,c)}addToIndexes(o,a){var e=Ed(this.indexes_,(t,e)=>{const n=Id(this.indexSet_,e);if(Jh(n,"Missing index implementation for "+e),t===KI){if(n.isDefinedOn(o.node)){const i=[],s=a.getIterator(TI.Wrap);let e=s.getNext();for(;e;)e.name!==o.name&&i.push(e),e=s.getNext();return i.push(o),WI(i,n.getCompare())}return KI}{var r=a.get(o.name);let e=t;return r&&(e=e.remove(new TI(o.name,r))),e.insert(o,o.node)}});return new zI(e,this.indexSet_)}removeFromIndexes(n,r){var e=Ed(this.indexes_,e=>{if(e===KI)return e;var t=r.get(n.name);return t?e.remove(new TI(n.name,t)):e});return new zI(e,this.indexSet_)}}let HI;class GI{constructor(e,t,n){this.children_=e,this.priorityNode_=t,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&MI(this.priorityNode_),this.children_.isEmpty()&&Jh(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}static get EMPTY_NODE(){return HI=HI||new GI(new RI(xI),null,zI.Default)}isLeafNode(){return!1}getPriority(){return this.priorityNode_||HI}updatePriority(e){return this.children_.isEmpty()?this:new GI(this.children_,e,this.indexMap_)}getImmediateChild(e){if(".priority"===e)return this.getPriority();var t=this.children_.get(e);return null===t?HI:t}getChild(e){var t=oI(e);return null===t?this:this.getImmediateChild(t).getChild(cI(e))}hasChild(e){return null!==this.children_.get(e)}updateImmediateChild(n,r){if(Jh(r,"We should always be passing snapshot nodes"),".priority"===n)return this.updatePriority(r);{var i=new TI(n,r);let e,t;t=r.isEmpty()?(e=this.children_.remove(n),this.indexMap_.removeFromIndexes(i,this.children_)):(e=this.children_.insert(n,r),this.indexMap_.addToIndexes(i,this.children_));i=e.isEmpty()?HI:this.priorityNode_;return new GI(e,i,t)}}updateChild(e,t){var n=oI(e);if(null===n)return t;Jh(".priority"!==oI(e)||1===aI(e),".priority must be the last token in a path");var r=this.getImmediateChild(n).updateChild(cI(e),t);return this.updateImmediateChild(n,r)}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(n){if(this.isEmpty())return null;const r={};let i=0,s=0,o=!0;if(this.forEachChild(qI,(e,t)=>{r[e]=t.val(n),i++,o&&GI.INTEGER_REGEXP_.test(e)?s=Math.max(s,Number(e)):o=!1}),!n&&o&&s<2*i){const e=[];for(const t in r)e[t]=r[t];return e}return n&&!this.getPriority().isEmpty()&&(r[".priority"]=this.getPriority().val()),r}hash(){if(null===this.lazyHash_){let r="";this.getPriority().isEmpty()||(r+="priority:"+OI(this.getPriority().val())+":"),this.forEachChild(qI,(e,t)=>{var n=t.hash();""!==n&&(r+=":"+e+":"+n)}),this.lazyHash_=""===r?"":sb(r)}return this.lazyHash_}getPredecessorChildName(e,t,n){const r=this.resolveIndex_(n);if(r){var i=r.getPredecessorKey(new TI(e,t));return i?i.name:null}return this.children_.getPredecessorKey(e)}getFirstChildName(e){const t=this.resolveIndex_(e);if(t){var n=t.minKey();return n&&n.name}return this.children_.minKey()}getFirstChild(e){var t=this.getFirstChildName(e);return t?new TI(t,this.children_.get(t)):null}getLastChildName(e){const t=this.resolveIndex_(e);if(t){var n=t.maxKey();return n&&n.name}return this.children_.maxKey()}getLastChild(e){var t=this.getLastChildName(e);return t?new TI(t,this.children_.get(t)):null}forEachChild(e,t){const n=this.resolveIndex_(e);return n?n.inorderTraversal(e=>t(e.name,e.node)):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(t,n){const e=this.resolveIndex_(n);if(e)return e.getIteratorFrom(t,e=>e);{const r=this.children_.getIteratorFrom(t.name,TI.Wrap);let e=r.peek();for(;null!=e&&n.compare(e,t)<0;)r.getNext(),e=r.peek();return r}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(t,n){const e=this.resolveIndex_(n);if(e)return e.getReverseIteratorFrom(t,e=>e);{const r=this.children_.getReverseIteratorFrom(t.name,TI.Wrap);let e=r.peek();for(;null!=e&&0<n.compare(e,t);)r.getNext(),e=r.peek();return r}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===YI?-1:0}withIndex(e){if(e===CI||this.indexMap_.hasIndex(e))return this;var t=this.indexMap_.addIndex(e,this.children_);return new GI(this.children_,this.priorityNode_,t)}isIndexed(e){return e===CI||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{const n=e;if(this.getPriority().equals(n.getPriority())){if(this.children_.count()!==n.children_.count())return!1;{const r=this.getIterator(qI),i=n.getIterator(qI);let e=r.getNext(),t=i.getNext();for(;e&&t;){if(e.name!==t.name||!e.node.equals(t.node))return!1;e=r.getNext(),t=i.getNext()}return null===e&&null===t}}return!1}}resolveIndex_(e){return e===CI?null:this.indexMap_.get(e.toString())}}GI.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class QI extends GI{constructor(){super(new RI(xI),GI.EMPTY_NODE,zI.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return GI.EMPTY_NODE}isEmpty(){return!1}}const YI=new QI;Object.defineProperties(TI,{MIN:{value:new TI(kb,GI.EMPTY_NODE)},MAX:{value:new TI(Sb,YI)}}),SI.__EMPTY_NODE=GI.EMPTY_NODE,FI.__childrenNodeConstructor=GI,Zw=YI,DI=Zw,eb=YI,jI=eb;const JI=!0;function XI(i,e=null){if(null===i)return GI.EMPTY_NODE;if("object"==typeof i&&".priority"in i&&(e=i[".priority"]),Jh(null===e||"string"==typeof e||"number"==typeof e||"object"==typeof e&&".sv"in e,"Invalid priority type found: "+typeof e),"object"!=typeof(i="object"==typeof i&&".value"in i&&null!==i[".value"]?i[".value"]:i)||".sv"in i){var t=i;return new FI(t,XI(e))}if(i instanceof Array||!JI){let r=GI.EMPTY_NODE;return Ab(i,(e,t)=>{if(bd(i,e)&&"."!==e.substring(0,1)){const n=XI(t);!n.isLeafNode()&&n.isEmpty()||(r=r.updateImmediateChild(e,n))}}),r.updatePriority(XI(e))}{const s=[];let r=!1;if(Ab(i,(e,t)=>{if("."!==e.substring(0,1)){const n=XI(t);n.isEmpty()||(r=r||!n.getPriority().isEmpty(),s.push(new TI(e,n)))}}),0===s.length)return GI.EMPTY_NODE;var n=WI(s,PI,e=>e.name,xI);if(r){t=WI(s,qI.getCompare());return new GI(n,XI(e),new zI({".priority":t},{".priority":qI}))}return new GI(n,XI(e),zI.Default)}}UI=XI;class ZI extends EI{constructor(e){super(),this.indexPath_=e,Jh(!pI(e)&&".priority"!==oI(e),"Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,t){const n=this.extractChild(e.node);var r=this.extractChild(t.node),r=n.compareTo(r);return 0===r?Cb(e.name,t.name):r}makePost(e,t){var n=XI(e),n=GI.EMPTY_NODE.updateChild(this.indexPath_,n);return new TI(t,n)}maxPost(){var e=GI.EMPTY_NODE.updateChild(this.indexPath_,YI);return new TI(Sb,e)}toString(){return uI(this.indexPath_,0).join("/")}}function eT(e){if(e===""+Db)return iT;var t=Ob(e);if(null!=t)return""+(t+1);const n=new Array(e.length);for(let i=0;i<n.length;i++)n[i]=e.charAt(i);if(n.length<oT)return n.push(iT),n.join("");let r=n.length-1;for(;0<=r&&n[r]===sT;)r--;return-1===r?Sb:(t=n[r],t=rT.charAt(rT.indexOf(t)+1),n[r]=t,n.slice(0,r+1).join(""))}function tT(e){if(e===""+xb)return kb;var t=Ob(e);if(null!=t)return""+(t-1);const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e.charAt(r);return n[n.length-1]===iT?1===n.length?""+Db:(delete n[n.length-1],n.join("")):(n[n.length-1]=rT.charAt(rT.indexOf(n[n.length-1])-1),n.join("")+sT.repeat(oT-n.length))}const nT=new class extends EI{compare(e,t){var n=e.node.compareTo(t.node);return 0===n?Cb(e.name,t.name):n}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return TI.MIN}maxPost(){return TI.MAX}makePost(e,t){var n=XI(e);return new TI(t,n)}toString(){return".value"}},rT="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",iT="-",sT="z",oT=786,aT=function(){let s=0;const o=[];return function(e){var t=e===s;s=e;let n;const r=new Array(8);for(n=7;0<=n;n--)r[n]=rT.charAt(e%64),e=Math.floor(e/64);Jh(0===e,"Cannot push at time == 0");let i=r.join("");if(t){for(n=11;0<=n&&63===o[n];n--)o[n]=0;o[n]++}else for(n=0;n<12;n++)o[n]=Math.floor(64*Math.random());for(n=0;n<12;n++)i+=rT.charAt(o[n]);return Jh(20===i.length,"nextPushId: Length should be 20."),i}}();function cT(e){return{type:"value",snapshotNode:e}}function lT(e,t){return{type:"child_added",snapshotNode:t,childName:e}}function uT(e,t){return{type:"child_removed",snapshotNode:t,childName:e}}function hT(e,t,n){return{type:"child_changed",snapshotNode:t,childName:e,oldSnap:n}}class dT{constructor(e){this.index_=e}updateChild(e,t,n,r,i,s){Jh(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");const o=e.getImmediateChild(t);return o.getChild(r).equals(n.getChild(r))&&o.isEmpty()===n.isEmpty()?e:(null!=s&&(n.isEmpty()?e.hasChild(t)?s.trackChildChange(uT(t,o)):Jh(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):o.isEmpty()?s.trackChildChange(lT(t,n)):s.trackChildChange(hT(t,n,o))),e.isLeafNode()&&n.isEmpty()?e:e.updateImmediateChild(t,n).withIndex(this.index_))}updateFullNode(r,n,i){return null!=i&&(r.isLeafNode()||r.forEachChild(qI,(e,t)=>{n.hasChild(e)||i.trackChildChange(uT(e,t))}),n.isLeafNode()||n.forEachChild(qI,(e,t)=>{if(r.hasChild(e)){const n=r.getImmediateChild(e);n.equals(t)||i.trackChildChange(hT(e,t,n))}else i.trackChildChange(lT(e,t))})),n.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?GI.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}class pT{constructor(e){this.indexedFilter_=new dT(e.getIndex()),this.index_=e.getIndex(),this.startPost_=pT.getStartPost_(e),this.endPost_=pT.getEndPost_(e)}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(e){return this.index_.compare(this.getStartPost(),e)<=0&&this.index_.compare(e,this.getEndPost())<=0}updateChild(e,t,n,r,i,s){return this.matches(new TI(t,n))||(n=GI.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,n,r,i,s)}updateFullNode(e,t,n){let r=(t=t.isLeafNode()?GI.EMPTY_NODE:t).withIndex(this.index_);r=r.updatePriority(GI.EMPTY_NODE);const i=this;return t.forEachChild(qI,(e,t)=>{i.matches(new TI(e,t))||(r=r.updateImmediateChild(e,GI.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(e,r,n)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(e){if(e.hasStart()){var t=e.getIndexStartName();return e.getIndex().makePost(e.getIndexStartValue(),t)}return e.getIndex().minPost()}static getEndPost_(e){if(e.hasEnd()){var t=e.getIndexEndName();return e.getIndex().makePost(e.getIndexEndValue(),t)}return e.getIndex().maxPost()}}class fT{constructor(e){this.rangedFilter_=new pT(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft()}updateChild(e,t,n,r,i,s){return this.rangedFilter_.matches(new TI(t,n))||(n=GI.EMPTY_NODE),e.getImmediateChild(t).equals(n)?e:e.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,n,r,i,s):this.fullLimitUpdateChild_(e,t,n,i,s)}updateFullNode(e,o,t){let a;if(o.isLeafNode()||o.isEmpty())a=GI.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<o.numChildren()&&o.isIndexed(this.index_)){a=GI.EMPTY_NODE.withIndex(this.index_);let t;t=this.reverse_?o.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):o.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);let n=0;for(;t.hasNext()&&n<this.limit_;){var r=t.getNext();let e;if(e=this.reverse_?this.index_.compare(this.rangedFilter_.getStartPost(),r)<=0:this.index_.compare(r,this.rangedFilter_.getEndPost())<=0,!e)break;a=a.updateImmediateChild(r.name,r.node),n++}}else{a=o.withIndex(this.index_),a=a.updatePriority(GI.EMPTY_NODE);let e,t,n,r;if(this.reverse_){r=a.getReverseIterator(this.index_),e=this.rangedFilter_.getEndPost(),t=this.rangedFilter_.getStartPost();const l=this.index_.getCompare();n=(e,t)=>l(t,e)}else r=a.getIterator(this.index_),e=this.rangedFilter_.getStartPost(),t=this.rangedFilter_.getEndPost(),n=this.index_.getCompare();let i=0,s=!1;for(;r.hasNext();){var c=r.getNext();!s&&n(e,c)<=0&&(s=!0),s&&i<this.limit_&&n(c,t)<=0?i++:a=a.updateImmediateChild(c.name,GI.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,a,t)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(e,t,n,r,i){let s;if(this.reverse_){const d=this.index_.getCompare();s=(e,t)=>d(t,e)}else s=this.index_.getCompare();const o=e;Jh(o.numChildren()===this.limit_,"");var a=new TI(t,n),c=this.reverse_?o.getFirstChild(this.index_):o.getLastChild(this.index_),l=this.rangedFilter_.matches(a);if(o.hasChild(t)){var u=o.getImmediateChild(t);let e=r.getChildAfterChild(this.index_,c,this.reverse_);for(;null!=e&&(e.name===t||o.hasChild(e.name));)e=r.getChildAfterChild(this.index_,e,this.reverse_);var h=null==e?1:s(e,a);if(l&&!n.isEmpty()&&0<=h)return null!=i&&i.trackChildChange(hT(t,n,u)),o.updateImmediateChild(t,n);{null!=i&&i.trackChildChange(uT(t,u));const p=o.updateImmediateChild(t,GI.EMPTY_NODE);return null!=e&&this.rangedFilter_.matches(e)?(null!=i&&i.trackChildChange(lT(e.name,e.node)),p.updateImmediateChild(e.name,e.node)):p}}return!n.isEmpty()&&l&&0<=s(c,a)?(null!=i&&(i.trackChildChange(uT(c.name,c.node)),i.trackChildChange(lT(t,n))),o.updateImmediateChild(t,n).updateImmediateChild(c.name,GI.EMPTY_NODE)):e}}class gT{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=qI}hasStart(){return this.startSet_}hasStartAfter(){return this.startAfterSet_}hasEndBefore(){return this.endBeforeSet_}isViewFromLeft(){return""===this.viewFrom_?this.startSet_:"l"===this.viewFrom_}getIndexStartValue(){return Jh(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return Jh(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:kb}hasEnd(){return this.endSet_}getIndexEndValue(){return Jh(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return Jh(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:Sb}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&""!==this.viewFrom_}getLimit(){return Jh(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===qI}copy(){const e=new gT;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e}}function mT(e,t,n){const r=e.copy();return r.startSet_=!0,void 0===t&&(t=null),r.indexStartValue_=t,null!=n?(r.startNameSet_=!0,r.indexStartName_=n):(r.startNameSet_=!1,r.indexStartName_=""),r}function vT(e,t,n){const r=e.copy();return r.endSet_=!0,void 0===t&&(t=null),r.indexEndValue_=t,void 0!==n?(r.endNameSet_=!0,r.indexEndName_=n):(r.endNameSet_=!1,r.indexEndName_=""),r}function yT(e,t){const n=e.copy();return n.index_=t,n}function _T(e){const t={};if(e.isDefault())return t;let n;return n=e.index_===qI?"$priority":e.index_===nT?"$value":e.index_===CI?"$key":(Jh(e.index_ instanceof ZI,"Unrecognized index type!"),e.index_.toString()),t.orderBy=_d(n),e.startSet_&&(t.startAt=_d(e.indexStartValue_),e.startNameSet_&&(t.startAt+=","+_d(e.indexStartName_))),e.endSet_&&(t.endAt=_d(e.indexEndValue_),e.endNameSet_&&(t.endAt+=","+_d(e.indexEndName_))),e.limitSet_&&(e.isViewFromLeft()?t.limitToFirst=e.limit_:t.limitToLast=e.limit_),t}function wT(t){const n={};if(t.startSet_&&(n.sp=t.indexStartValue_,t.startNameSet_&&(n.sn=t.indexStartName_)),t.endSet_&&(n.ep=t.indexEndValue_,t.endNameSet_&&(n.en=t.indexEndName_)),t.limitSet_){n.l=t.limit_;let e=t.viewFrom_;""===e&&(e=t.isViewFromLeft()?"l":"r"),n.vf=e}return t.index_!==qI&&(n.i=t.index_.toString()),n}class bT extends tI{constructor(e,t,n,r){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=n,this.appCheckTokenProvider_=r,this.log_=pb("p:rest:"),this.listens_={}}reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return void 0!==t?"tag$"+t:(Jh(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}listen(e,t,r,i){const s=e._path.toString();this.log_("Listen called for "+s+" "+e._queryIdentifier);const o=bT.getListenId_(e,r),a={};this.listens_[o]=a;var n=_T(e._queryParams);this.restRequest_(s+".json",n,(t,e)=>{let n=e;if(null===(t=404===t?n=null:t)&&this.onDataUpdate_(s,n,!1,r),Id(this.listens_,o)===a){let e;e=t?401===t?"permission_denied":"rest_error:"+t:"ok",i(e,null)}})}unlisten(e,t){var n=bT.getListenId_(e,t);delete this.listens_[n]}get(e){var t=_T(e._queryParams);const r=e._path.toString(),i=new rd;return this.restRequest_(r+".json",t,(e,t)=>{let n=t;null===(e=404===e?n=null:e)?(this.onDataUpdate_(r,n,!1,null),i.resolve(n)):i.reject(new Error(n))}),i.promise}refreshAuthToken(e){}restRequest_(i,s={},o){return s.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([e,t])=>{e&&e.accessToken&&(s.auth=e.accessToken),t&&t.token&&(s.ac=t.token);const n=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+i+"?ns="+this.repoInfo_.namespace+Cd(s);this.log_("Sending REST request for "+n);const r=new XMLHttpRequest;r.onreadystatechange=()=>{if(o&&4===r.readyState){this.log_("REST Response for "+n+" received. status:",r.status,"response:",r.responseText);let e=null;if(200<=r.status&&r.status<300){try{e=yd(r.responseText)}catch(e){Ib("Failed to parse JSON response for "+n+": "+r.responseText)}o(null,e)}else 401!==r.status&&404!==r.status&&Ib("Got unsuccessful REST response for "+n+" Status: "+r.status),o(r.status);o=null}},r.open("GET",n,!0),r.send()})}}class IT{constructor(){this.rootNode_=GI.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}function TT(){return{value:null,children:new Map}}function ET(e,t,n){var r;pI(t)?(e.value=n,e.children.clear()):null!==e.value?e.value=e.value.updateChild(t,n):(r=oI(t),e.children.has(r)||e.children.set(r,TT()),ET(e.children.get(r),t=cI(t),n))}function kT(e,n,r){var i;null!==e.value?r(n,e.value):(i=(e,t)=>{kT(t,new iI(n.toString()+"/"+e),r)},e.children.forEach((e,t)=>{i(t,e)}))}class ST{constructor(e){this.collection_=e,this.last_=null}get(){var e=this.collection_.get();const n=Object.assign({},e);return this.last_&&Ab(this.last_,(e,t)=>{n[e]=n[e]-t}),this.last_=e,n}}class CT{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new ST(e);var n=1e4+2e4*Math.random();Rb(this.reportStats_.bind(this),Math.floor(n))}reportStats_(){var e=this.statsListener_.get();const n={};let r=!1;Ab(e,(e,t)=>{0<t&&bd(this.statsToReport_,e)&&(n[e]=t,r=!0)}),r&&this.server_.reportStats(n),Rb(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))}}function AT(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function NT(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function RT(e){return{fromUser:!1,fromServer:!0,queryId:e,tagged:!0}}(z=tb=tb||{})[z.OVERWRITE=0]="OVERWRITE",z[z.MERGE=1]="MERGE",z[z.ACK_USER_WRITE=2]="ACK_USER_WRITE",z[z.LISTEN_COMPLETE=3]="LISTEN_COMPLETE";class PT{constructor(e,t,n){this.path=e,this.affectedTree=t,this.revert=n,this.type=tb.ACK_USER_WRITE,this.source=AT()}operationForChild(e){if(pI(this.path)){if(null!=this.affectedTree.value)return Jh(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;var t=this.affectedTree.subtree(new iI(e));return new PT(sI(),t,this.revert)}return Jh(oI(this.path)===e,"operationForChild called for unrelated child."),new PT(cI(this.path),this.affectedTree,this.revert)}}class xT{constructor(e,t){this.source=e,this.path=t,this.type=tb.LISTEN_COMPLETE}operationForChild(e){return pI(this.path)?new xT(this.source,sI()):new xT(this.source,cI(this.path))}}class DT{constructor(e,t,n){this.source=e,this.path=t,this.snap=n,this.type=tb.OVERWRITE}operationForChild(e){return pI(this.path)?new DT(this.source,sI(),this.snap.getImmediateChild(e)):new DT(this.source,cI(this.path),this.snap)}}class OT{constructor(e,t,n){this.source=e,this.path=t,this.children=n,this.type=tb.MERGE}operationForChild(e){if(pI(this.path)){const t=this.children.subtree(new iI(e));return t.isEmpty()?null:t.value?new DT(this.source,sI(),t.value):new OT(this.source,sI(),t)}return Jh(oI(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new OT(this.source,cI(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}class MT{constructor(e,t,n){this.node_=e,this.fullyInitialized_=t,this.filtered_=n}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(pI(e))return this.isFullyInitialized()&&!this.filtered_;var t=oI(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}class LT{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function FT(n,e,t,r){var i=[];const s=[];return e.forEach(e=>{var t;"child_changed"===e.type&&n.index_.indexedValueChanged(e.oldSnap,e.snapshotNode)&&s.push((t=e.childName,{type:"child_moved",snapshotNode:e.snapshotNode,childName:t}))}),UT(n,i,"child_removed",e,r,t),UT(n,i,"child_added",e,r,t),UT(n,i,"child_moved",s,r,t),UT(n,i,"child_changed",e,r,t),UT(n,i,"value",e,r,t),i}function UT(s,o,t,e,a,c){const n=e.filter(e=>e.type===t);n.sort((e,t)=>function(e,t,n){if(null==t.childName||null==n.childName)throw Xh("Should only compare child_ events.");var r=new TI(t.childName,t.snapshotNode),i=new TI(n.childName,n.snapshotNode);return e.index_.compare(r,i)}(s,e,t)),n.forEach(t=>{const n=(e=s,i=c,"value"===(r=t).type||"child_removed"===r.type||(r.prevName=i.getPredecessorChildName(r.childName,r.snapshotNode,e.index_)),r);var e,r,i;a.forEach(e=>{e.respondsTo(t.type)&&o.push(e.createEvent(n,s.query_))})})}function jT(e,t){return{eventCache:e,serverCache:t}}function qT(e,t,n,r){return jT(new MT(t,n,r),e.serverCache)}function VT(e,t,n,r){return jT(e.eventCache,new MT(t,n,r))}function BT(e){return e.eventCache.isFullyInitialized()?e.eventCache.getNode():null}function WT(e){return e.serverCache.isFullyInitialized()?e.serverCache.getNode():null}let $T;class KT{constructor(e,t=($T=$T||new RI(gb),$T)){this.value=e,this.children=t}static fromObject(e){let n=new KT(null);return Ab(e,(e,t)=>{n=n.set(new iI(e),t)}),n}isEmpty(){return null===this.value&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(null!=this.value&&t(this.value))return{path:sI(),value:this.value};if(pI(e))return null;{var n=oI(e);const i=this.children.get(n);if(null===i)return null;var r=i.findRootMostMatchingPathAndValue(cI(e),t);return null==r?null:{path:dI(new iI(n),r.path),value:r.value}}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(pI(e))return this;{var t=oI(e);const n=this.children.get(t);return null!==n?n.subtree(cI(e)):new KT(null)}}set(e,t){if(pI(e))return new KT(t,this.children);{var n=oI(e);const i=this.children.get(n)||new KT(null);var r=i.set(cI(e),t),r=this.children.insert(n,r);return new KT(this.value,r)}}remove(t){if(pI(t))return this.children.isEmpty()?new KT(null):new KT(null,this.children);{var n=oI(t);const r=this.children.get(n);if(r){const i=r.remove(cI(t));let e;return e=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),null===this.value&&e.isEmpty()?new KT(null):new KT(this.value,e)}return this}}get(e){if(pI(e))return this.value;{var t=oI(e);const n=this.children.get(t);return n?n.get(cI(e)):null}}setTree(t,n){if(pI(t))return n;{var r=oI(t);const i=this.children.get(r)||new KT(null),s=i.setTree(cI(t),n);let e;return e=s.isEmpty()?this.children.remove(r):this.children.insert(r,s),new KT(this.value,e)}}fold(e){return this.fold_(sI(),e)}fold_(n,r){const i={};return this.children.inorderTraversal((e,t)=>{i[e]=t.fold_(dI(n,e),r)}),r(n,this.value,i)}findOnPath(e,t){return this.findOnPath_(e,sI(),t)}findOnPath_(e,t,n){var r=!!this.value&&n(t,this.value);if(r)return r;if(pI(e))return null;{r=oI(e);const i=this.children.get(r);return i?i.findOnPath_(cI(e),dI(t,r),n):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,sI(),t)}foreachOnPath_(e,t,n){if(pI(e))return this;{this.value&&n(t,this.value);var r=oI(e);const i=this.children.get(r);return i?i.foreachOnPath_(cI(e),dI(t,r),n):new KT(null)}}foreach(e){this.foreach_(sI(),e)}foreach_(n,r){this.children.inorderTraversal((e,t)=>{t.foreach_(dI(n,e),r)}),this.value&&r(n,this.value)}foreachChild(n){this.children.inorderTraversal((e,t)=>{t.value&&n(e,t.value)})}}class zT{constructor(e){this.writeTree_=e}static empty(){return new zT(new KT(null))}}function HT(t,n,r){if(pI(n))return new zT(new KT(r));var i=t.writeTree_.findRootMostValueAndPath(n);if(null!=i){var s=i.path;let e=i.value;i=fI(s,n);return e=e.updateChild(i,r),new zT(t.writeTree_.set(s,e))}s=new KT(r),s=t.writeTree_.setTree(n,s);return new zT(s)}function GT(e,n,t){let r=e;return Ab(t,(e,t)=>{r=HT(r,dI(n,e),t)}),r}function QT(e,t){if(pI(t))return zT.empty();var n=e.writeTree_.setTree(t,new KT(null));return new zT(n)}function YT(e,t){return null!=JT(e,t)}function JT(e,t){var n=e.writeTree_.findRootMostValueAndPath(t);return null!=n?e.writeTree_.get(n.path).getChild(fI(n.path,t)):null}function XT(e){const n=[],t=e.writeTree_.value;return null!=t?t.isLeafNode()||t.forEachChild(qI,(e,t)=>{n.push(new TI(e,t))}):e.writeTree_.children.inorderTraversal((e,t)=>{null!=t.value&&n.push(new TI(e,t.value))}),n}function ZT(e,t){if(pI(t))return e;var n=JT(e,t);return null!=n?new zT(new KT(n)):new zT(e.writeTree_.subtree(t))}function e0(e){return e.writeTree_.isEmpty()}function t0(e,t){return function r(i,e,s){{if(null!=e.value)return s.updateChild(i,e.value);{let n=null;return e.children.inorderTraversal((e,t)=>{".priority"===e?(Jh(null!==t.value,"Priority writes must always be leaf nodes"),n=t.value):s=r(dI(i,e),t,s)}),s=!s.getChild(i).isEmpty()&&null!==n?s.updateChild(dI(i,".priority"),n):s}}}(sI(),e.writeTree_,t)}function n0(e,t){return f0(t,e)}function r0(t,n){var e,r=t.allWrites.findIndex(e=>e.writeId===n);Jh(0<=r,"removeWrite called with nonexistent writeId.");const i=t.allWrites[r];t.allWrites.splice(r,1);let s=i.visible,o=!1,a=t.allWrites.length-1;for(;s&&0<=a;){var c=t.allWrites[a];c.visible&&(a>=r&&function(e,t){{if(e.snap)return vI(e.path,t);for(const n in e.children)if(e.children.hasOwnProperty(n)&&vI(dI(e.path,n),t))return!0;return!1}}(c,i.path)?s=!1:vI(i.path,c.path)&&(o=!0)),a--}return!!s&&(o?((e=t).visibleWrites=s0(e.allWrites,i0,sI()),0<e.allWrites.length?e.lastWriteId=e.allWrites[e.allWrites.length-1].writeId:e.lastWriteId=-1):i.snap?t.visibleWrites=QT(t.visibleWrites,i.path):Ab(i.children,e=>{t.visibleWrites=QT(t.visibleWrites,dI(i.path,e))}),!0)}function i0(e){return e.visible}function s0(e,t,n){let r=zT.empty();for(let s=0;s<e.length;++s){const o=e[s];if(t(o)){var i=o.path;let e;if(o.snap)vI(n,i)?(e=fI(n,i),r=HT(r,e,o.snap)):vI(i,n)&&(e=fI(i,n),r=HT(r,sI(),o.snap.getChild(e)));else{if(!o.children)throw Xh("WriteRecord should have .snap or .children");if(vI(n,i))e=fI(n,i),r=GT(r,e,o.children);else if(vI(i,n))if(e=fI(i,n),pI(e))r=GT(r,sI(),o.children);else{const a=Id(o.children,oI(e));a&&(i=a.getChild(cI(e)),r=HT(r,sI(),i))}}}}return r}function o0(e,t,n,r,i){if(r||i){var s=ZT(e.visibleWrites,t);if(!i&&e0(s))return n;if(i||null!=n||YT(s,sI()))return t0(s0(e.allWrites,function(e){return(e.visible||i)&&(!r||!~r.indexOf(e.writeId))&&(vI(e.path,t)||vI(t,e.path))},t),n||GI.EMPTY_NODE);return null}s=JT(e.visibleWrites,t);if(null!=s)return s;s=ZT(e.visibleWrites,t);return e0(s)?n:null!=n||YT(s,sI())?t0(s,n||GI.EMPTY_NODE):null}function a0(e,t,n,r){return o0(e.writeTree,e.treePath,t,n,r)}function c0(e,t){return function(e,t,n){let r=GI.EMPTY_NODE;const i=JT(e.visibleWrites,t);if(i)return i.isLeafNode()||i.forEachChild(qI,(e,t)=>{r=r.updateImmediateChild(e,t)}),r;if(n){const s=ZT(e.visibleWrites,t);return n.forEachChild(qI,(e,t)=>{var n=t0(ZT(s,new iI(e)),t);r=r.updateImmediateChild(e,n)}),XT(s).forEach(e=>{r=r.updateImmediateChild(e.name,e.node)}),r}return XT(ZT(e.visibleWrites,t)).forEach(e=>{r=r.updateImmediateChild(e.name,e.node)}),r}(e.writeTree,e.treePath,t)}function l0(e,t,n,r){return function(e,t,n,r,i){Jh(r||i,"Either existingEventSnap or existingServerSnap must exist");var s=dI(t,n);return YT(e.visibleWrites,s)?null:e0(s=ZT(e.visibleWrites,s))?i.getChild(n):t0(s,i.getChild(n))}(e.writeTree,e.treePath,t,n,r)}function u0(e,t){return n=e.writeTree,t=dI(e.treePath,t),JT(n.visibleWrites,t);var n}function h0(e,t,n,r,i,s){return function(e,t,n,r,i,s,o){let a;var c=ZT(e.visibleWrites,t),l=JT(c,sI());if(null!=l)a=l;else{if(null==n)return[];a=t0(c,n)}if(a=a.withIndex(o),a.isEmpty()||a.isLeafNode())return[];{const u=[],h=o.getCompare(),d=s?a.getReverseIteratorFrom(r,o):a.getIteratorFrom(r,o);let e=d.getNext();for(;e&&u.length<i;)0!==h(e,r)&&u.push(e),e=d.getNext();return u}}(e.writeTree,e.treePath,t,n,r,i,s)}function d0(e,t,n){return r=e.writeTree,e=e.treePath,n=n,i=dI(e,t=t),null!=(s=JT(r.visibleWrites,i))?s:n.isCompleteForChild(t)?t0(ZT(r.visibleWrites,i),n.getNode().getImmediateChild(t)):null;var r,i,s}function p0(e,t){return f0(dI(e.treePath,t),e.writeTree)}function f0(e,t){return{treePath:e,writeTree:t}}class g0{constructor(){this.changeMap=new Map}trackChildChange(e){var t=e.type,n=e.childName;Jh("child_added"===t||"child_changed"===t||"child_removed"===t,"Only child changes supported for tracking"),Jh(".priority"!==n,"Only non-priority child changes can be tracked.");var r=this.changeMap.get(n);if(r){var i=r.type;if("child_added"===t&&"child_removed"===i)this.changeMap.set(n,hT(n,e.snapshotNode,r.snapshotNode));else if("child_removed"===t&&"child_added"===i)this.changeMap.delete(n);else if("child_removed"===t&&"child_changed"===i)this.changeMap.set(n,uT(n,r.oldSnap));else if("child_changed"===t&&"child_added"===i)this.changeMap.set(n,lT(n,e.snapshotNode));else{if("child_changed"!==t||"child_changed"!==i)throw Xh("Illegal combination of changes: "+e+" occurred after "+r);this.changeMap.set(n,hT(n,e.snapshotNode,r.oldSnap))}}else this.changeMap.set(n,e)}getChanges(){return Array.from(this.changeMap.values())}}const m0=new class{getCompleteChild(e){return null}getChildAfterChild(e,t,n){return null}};class v0{constructor(e,t,n=null){this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=n}getCompleteChild(e){const t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);var n=null!=this.optCompleteServerCache_?new MT(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return d0(this.writes_,e,n)}getChildAfterChild(e,t,n){var r=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:WT(this.viewCache_),r=h0(this.writes_,r,t,1,n,e);return 0===r.length?null:r[0]}}function y0(e,t,n,r,i){const s=new g0;let o,a;if(n.type===tb.OVERWRITE){var c=n;o=c.source.fromUser?b0(e,t,c.path,c.snap,r,i,s):(Jh(c.source.fromServer,"Unknown source."),a=c.source.tagged||t.serverCache.isFiltered()&&!pI(c.path),w0(e,t,c.path,c.snap,r,i,a,s))}else if(n.type===tb.MERGE){c=n;o=c.source.fromUser?function(r,i,s,e,o,a,c){let l=i;return e.foreach((e,t)=>{var n=dI(s,e);I0(i,oI(n))&&(l=b0(r,l,n,t,o,a,c))}),e.foreach((e,t)=>{var n=dI(s,e);I0(i,oI(n))||(l=b0(r,l,n,t,o,a,c))}),l}(e,t,c.path,c.children,r,i,s):(Jh(c.source.fromServer,"Unknown source."),a=c.source.tagged||t.serverCache.isFiltered(),E0(e,t,c.path,c.children,r,i,a,s))}else if(n.type===tb.ACK_USER_WRITE){var l=n;o=l.revert?function(n,r,i,s,e,o){let a;{if(null!=u0(s,i))return r;{var c=new v0(s,r,e);const u=r.eventCache.getNode();let t;if(pI(i)||".priority"===oI(i)){let e;e=r.serverCache.isFullyInitialized()?a0(s,WT(r)):(l=r.serverCache.getNode(),Jh(l instanceof GI,"serverChildren would be complete if leaf node"),c0(s,l)),e=e,t=n.filter.updateFullNode(u,e,o)}else{var l=oI(i);let e=d0(s,l,r.serverCache);null==e&&r.serverCache.isCompleteForChild(l)&&(e=u.getImmediateChild(l)),t=null!=e?n.filter.updateChild(u,l,e,cI(i),c,o):r.eventCache.getNode().hasChild(l)?n.filter.updateChild(u,l,GI.EMPTY_NODE,cI(i),c,o):u,t.isEmpty()&&r.serverCache.isFullyInitialized()&&(a=a0(s,WT(r)),a.isLeafNode()&&(t=n.filter.updateFullNode(t,a,o)))}return a=r.serverCache.isFullyInitialized()||null!=u0(s,sI()),qT(r,t,a,n.filter.filtersNodes())}}}(e,t,l.path,r,i,s):function(e,t,i,n,s,o,a){if(null!=u0(s,i))return t;const c=t.serverCache.isFiltered(),l=t.serverCache;{if(null!=n.value){if(pI(i)&&l.isFullyInitialized()||l.isCompleteForPath(i))return w0(e,t,i,l.getNode().getChild(i),s,o,c,a);if(pI(i)){let n=new KT(null);return l.getNode().forEachChild(CI,(e,t)=>{n=n.set(new iI(e),t)}),E0(e,t,i,n,s,o,c,a)}return t}{let r=new KT(null);return n.foreach((e,t)=>{var n=dI(i,e);l.isCompleteForPath(n)&&(r=r.set(e,l.getNode().getChild(n)))}),E0(e,t,i,r,s,o,c,a)}}}(e,t,l.path,l.affectedTree,r,i,s)}else{if(n.type!==tb.LISTEN_COMPLETE)throw Xh("Unknown operation type: "+n.type);o=function(e,t,n,r,i){const s=t.serverCache,o=VT(t,s.getNode(),s.isFullyInitialized()||pI(n),s.isFiltered());return _0(e,o,n,r,m0,i)}(e,t,n.path,r,s)}l=s.getChanges();return function(e,t,n){const r=t.eventCache;if(r.isFullyInitialized()){var i=r.getNode().isLeafNode()||r.getNode().isEmpty();const s=BT(e);(0<n.length||!e.eventCache.isFullyInitialized()||i&&!r.getNode().equals(s)||!r.getNode().getPriority().equals(s.getPriority()))&&n.push(cT(BT(t)))}}(t,o,l),{viewCache:o,changes:l}}function _0(r,i,s,o,a,c){const l=i.eventCache;if(null!=u0(o,s))return i;{let t,n;if(pI(s)){var e;Jh(i.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),t=i.serverCache.isFiltered()?(e=c0(o,(e=WT(i))instanceof GI?e:GI.EMPTY_NODE),r.filter.updateFullNode(i.eventCache.getNode(),e,c)):(u=a0(o,WT(i)),r.filter.updateFullNode(i.eventCache.getNode(),u,c))}else{var u=oI(s);if(".priority"===u){Jh(1===aI(s),"Can't have a priority with additional path components");var h=l.getNode();n=i.serverCache.getNode();var d=l0(o,s,h,n);t=null!=d?r.filter.updatePriority(h,d):l.getNode()}else{h=cI(s);let e;e=l.isCompleteForChild(u)?(n=i.serverCache.getNode(),null!=(d=l0(o,s,l.getNode(),n))?l.getNode().getImmediateChild(u).updateChild(h,d):l.getNode().getImmediateChild(u)):d0(o,u,i.serverCache),t=null!=e?r.filter.updateChild(l.getNode(),u,e,h,a,c):l.getNode()}}return qT(i,t,l.isFullyInitialized()||pI(s),r.filter.filtersNodes())}}function w0(e,t,n,r,i,s,o,a){const c=t.serverCache;let l;const u=o?e.filter:e.filter.getIndexedFilter();if(pI(n))l=u.updateFullNode(c.getNode(),r,null);else if(u.filtersNodes()&&!c.isFiltered()){var h=c.getNode().updateChild(n,r);l=u.updateFullNode(c.getNode(),h,null)}else{var d=oI(n);if(!c.isCompleteForPath(n)&&1<aI(n))return t;var p=cI(n);const f=c.getNode().getImmediateChild(d);h=f.updateChild(p,r);l=".priority"===d?u.updatePriority(c.getNode(),h):u.updateChild(c.getNode(),d,h,p,m0,null)}p=VT(t,l,c.isFullyInitialized()||pI(n),u.filtersNodes());return _0(e,p,n,i,new v0(i,p,s),a)}function b0(t,n,r,i,e,s,o){const a=n.eventCache;let c,l;const u=new v0(e,n,s);if(pI(r))l=t.filter.updateFullNode(n.eventCache.getNode(),i,o),c=qT(n,l,!0,t.filter.filtersNodes());else{var h=oI(r);if(".priority"===h)l=t.filter.updatePriority(n.eventCache.getNode(),i),c=qT(n,l,a.isFullyInitialized(),a.isFiltered());else{var d=cI(r);const p=a.getNode().getImmediateChild(h);let e;if(pI(d))e=i;else{const f=u.getCompleteChild(h);e=null!=f?".priority"===lI(d)&&f.getChild(hI(d)).isEmpty()?f:f.updateChild(d,i):GI.EMPTY_NODE}c=p.equals(e)?n:qT(n,t.filter.updateChild(a.getNode(),h,e,d,u,o),a.isFullyInitialized(),t.filter.filtersNodes())}}return c}function I0(e,t){return e.eventCache.isCompleteForChild(t)}function T0(e,n,t){return t.foreach((e,t)=>{n=n.updateChild(e,t)}),n}function E0(r,i,e,t,s,o,a,c){if(i.serverCache.getNode().isEmpty()&&!i.serverCache.isFullyInitialized())return i;let l=i,n;n=pI(e)?t:new KT(null).setTree(e,t);const u=i.serverCache.getNode();return n.children.inorderTraversal((e,t)=>{var n;u.hasChild(e)&&(n=T0(0,i.serverCache.getNode().getImmediateChild(e),t),l=w0(r,l,new iI(e),n,s,o,a,c))}),n.children.inorderTraversal((e,t)=>{var n=!i.serverCache.isCompleteForChild(e)&&void 0===t.value;u.hasChild(e)||n||(n=T0(0,i.serverCache.getNode().getImmediateChild(e),t),l=w0(r,l,new iI(e),n,s,o,a,c))}),l}class k0{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const n=this.query_._queryParams,r=new dT(n.getIndex()),i=(e=n).loadsAllData()?new dT(e.getIndex()):new(e.hasLimit()?fT:pT)(e);this.processor_={filter:i};const s=t.serverCache,o=t.eventCache;var a=r.updateFullNode(GI.EMPTY_NODE,s.getNode(),null),c=i.updateFullNode(GI.EMPTY_NODE,o.getNode(),null),a=new MT(a,s.isFullyInitialized(),r.filtersNodes()),c=new MT(c,o.isFullyInitialized(),i.filtersNodes());this.viewCache_=jT(c,a),this.eventGenerator_=new LT(this.query_)}get query(){return this.query_}}function S0(e){return 0===e.eventRegistrations_.length}function C0(n,r,i){const s=[];if(i){Jh(null==r,"A cancel should cancel all event registrations.");const o=n.query._path;n.eventRegistrations_.forEach(e=>{var t=e.createCancelEvent(i,o);t&&s.push(t)})}if(r){let e=[];for(let t=0;t<n.eventRegistrations_.length;++t){const a=n.eventRegistrations_[t];if(a.matches(r)){if(r.hasAnyCallback()){e=e.concat(n.eventRegistrations_.slice(t+1));break}}else e.push(a)}n.eventRegistrations_=e}else n.eventRegistrations_=[];return s}function A0(e,t,n,r){t.type===tb.MERGE&&null!==t.source.queryId&&(Jh(WT(e.viewCache_),"We should always have a full cache before handling merges"),Jh(BT(e.viewCache_),"Missing event cache, even though we have a server cache"));const i=e.viewCache_,s=y0(e.processor_,i,t,n,r);return n=e.processor_,r=s.viewCache,Jh(r.eventCache.getNode().isIndexed(n.filter.getIndex()),"Event snap not indexed"),Jh(r.serverCache.getNode().isIndexed(n.filter.getIndex()),"Server snap not indexed"),Jh(s.viewCache.serverCache.isFullyInitialized()||!i.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),e.viewCache_=s.viewCache,N0(e,s.changes,s.viewCache.eventCache.getNode(),null)}function N0(e,t,n,r){var i=r?[r]:e.eventRegistrations_;return FT(e.eventGenerator_,t,n,i)}let R0;class P0{constructor(){this.views=new Map}}function x0(t,n,r,i){var e=n.source.queryId;if(null!==e){e=t.views.get(e);return Jh(null!=e,"SyncTree gave us an op for an invalid query."),A0(e,n,r,i)}{let e=[];for(const s of t.views.values())e=e.concat(A0(s,n,r,i));return e}}function D0(e,n,r,i,s){var o=n._queryIdentifier,o=e.views.get(o);if(o)return o;{let e=a0(r,s?i:null),t=!1;t=!!e||(e=i instanceof GI?c0(r,i):GI.EMPTY_NODE,!1);o=jT(new MT(e,t,!1),new MT(i,s,!1));return new k0(n,o)}}function O0(e,t,n,r,i,s){var o=D0(e,t,r,i,s);return e.views.has(t._queryIdentifier)||e.views.set(t._queryIdentifier,o),o.eventRegistrations_.push(n),function(e,t){const n=e.viewCache_.eventCache,r=[];if(!n.getNode().isLeafNode()){const i=n.getNode();i.forEachChild(qI,(e,t)=>{r.push(lT(e,t))})}return n.isFullyInitialized()&&r.push(cT(n.getNode())),N0(e,r,n.getNode(),t)}(o,n)}function M0(e,t,n,r){var i=t._queryIdentifier;const s=[];let o=[];var a=q0(e);if("default"===i)for(var[c,l]of e.views.entries())o=o.concat(C0(l,n,r)),S0(l)&&(e.views.delete(c),l.query._queryParams.loadsAllData()||s.push(l.query));else{const u=e.views.get(i);u&&(o=o.concat(C0(u,n,r)),S0(u)&&(e.views.delete(i),u.query._queryParams.loadsAllData()||s.push(u.query)))}return a&&!q0(e)&&s.push((Jh(R0,"Reference.ts has not been loaded"),new R0(t._repo,t._path))),{removed:s,events:o}}function L0(e){const t=[];for(const n of e.views.values())n.query._queryParams.loadsAllData()||t.push(n);return t}function F0(e,t){let n=null;for(const r of e.views.values())n=n||function(e,t){const n=WT(e.viewCache_);return n&&(e.query._queryParams.loadsAllData()||!pI(t)&&!n.getImmediateChild(oI(t)).isEmpty())?n.getChild(t):null}(r,t);return n}function U0(e,t){const n=t._queryParams;if(n.loadsAllData())return V0(e);var r=t._queryIdentifier;return e.views.get(r)}function j0(e,t){return null!=U0(e,t)}function q0(e){return null!=V0(e)}function V0(e){for(const t of e.views.values())if(t.query._queryParams.loadsAllData())return t;return null}let B0;let W0=1;class $0{constructor(e){this.listenProvider_=e,this.syncPointTree_=new KT(null),this.pendingWriteTree_={visibleWrites:zT.empty(),allWrites:[],lastWriteId:-1},this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function K0(e,t,n,r,i){var s,o,a,c;return s=e.pendingWriteTree_,o=t,a=n,c=r,r=i,Jh(c>s.lastWriteId,"Stacking an older write on top of newer ones"),s.allWrites.push({path:o,snap:a,writeId:c,visible:r=void 0===r?!0:r}),r&&(s.visibleWrites=HT(s.visibleWrites,o,a)),s.lastWriteId=c,i?Z0(e,new DT(AT(),t,n)):[]}function z0(e,t,n,r){var i,s,o;i=e.pendingWriteTree_,s=t,o=n,r=r,Jh(r>i.lastWriteId,"Stacking an older merge on top of newer ones"),i.allWrites.push({path:s,children:o,writeId:r,visible:!0}),i.visibleWrites=GT(i.visibleWrites,s,o),i.lastWriteId=r;var a=KT.fromObject(n);return Z0(e,new OT(AT(),t,a))}function H0(e,t,n=!1){var r=function(e,t){for(let r=0;r<e.allWrites.length;r++){var n=e.allWrites[r];if(n.writeId===t)return n}return null}(e.pendingWriteTree_,t);if(r0(e.pendingWriteTree_,t)){let t=new KT(null);return null!=r.snap?t=t.set(sI(),!0):Ab(r.children,e=>{t=t.set(new iI(e),!0)}),Z0(e,new PT(r.path,t,n))}return[]}function G0(e,t,n){return Z0(e,new DT(NT(),t,n))}function Q0(n,e,t,r){var i=e._path,s=n.syncPointTree_.get(i);let o=[];if(s&&("default"===e._queryIdentifier||j0(s,e))){var a=M0(s,e,t,r);0===s.views.size&&(n.syncPointTree_=n.syncPointTree_.remove(i));const h=a.removed;o=a.events;s=-1!==h.findIndex(e=>e._queryParams.loadsAllData()),a=n.syncPointTree_.findOnPath(i,(e,t)=>q0(t));if(s&&!a){const d=n.syncPointTree_.subtree(i);if(!d.isEmpty()){var c=d.fold((e,t,r)=>{if(t&&q0(t))return[V0(t)];{let n=[];return t&&(n=L0(t)),Ab(r,(e,t)=>{n=n.concat(t)}),n}});for(let e=0;e<c.length;++e){var l=c[e],u=l.query,l=tE(n,l);n.listenProvider_.startListening(aE(u),nE(n,u),l.hashFn,l.onComplete)}}}!a&&0<h.length&&!r&&(s?n.listenProvider_.stopListening(aE(e),null):h.forEach(e=>{var t=n.queryToTagMap.get(rE(e));n.listenProvider_.stopListening(aE(e),t)})),function(e,t){for(let i=0;i<t.length;++i){const s=t[i];var n,r;s._queryParams.loadsAllData()||(n=rE(s),r=e.queryToTagMap.get(n),e.queryToTagMap.delete(n),e.tagToQueryMap.delete(r))}}(n,h)}return o}function Y0(e,t,n){const r=t._path;let i=null,s=!1;e.syncPointTree_.foreachOnPath(r,(e,t)=>{var n=fI(e,r);i=i||F0(t,n),s=s||q0(t)});let o=e.syncPointTree_.get(r);o?(s=s||q0(o),i=i||F0(o,sI())):(o=new P0,e.syncPointTree_=e.syncPointTree_.set(r,o));let a;if(null!=i)a=!0;else{a=!1,i=GI.EMPTY_NODE;const d=e.syncPointTree_.subtree(r);d.foreachChild((e,t)=>{var n=F0(t,sI());n&&(i=i.updateImmediateChild(e,n))})}var c,l=j0(o,t);l||t._queryParams.loadsAllData()||(u=rE(t),Jh(!e.queryToTagMap.has(u),"View does not exist, but we have a tag"),c=W0++,e.queryToTagMap.set(u,c),e.tagToQueryMap.set(c,u));var u=n0(e.pendingWriteTree_,r);let h=O0(o,t,n,u,i,a);return l||s||(l=U0(o,t),h=h.concat(function(t,e,n){const r=e._path,i=nE(t,e),s=tE(t,n),o=t.listenProvider_.startListening(aE(e),i,s.hashFn,s.onComplete),a=t.syncPointTree_.subtree(r);if(i)Jh(!q0(a.value),"If we're adding a query, it shouldn't be shadowed");else{var c=a.fold((e,t,r)=>{if(!pI(e)&&t&&q0(t))return[V0(t).query];{let n=[];return t&&(n=n.concat(L0(t).map(e=>e.query))),Ab(r,(e,t)=>{n=n.concat(t)}),n}});for(let e=0;e<c.length;++e){var l=c[e];t.listenProvider_.stopListening(aE(l),nE(t,l))}}return o}(e,t,l))),h}function J0(e,r,t){var n=e.pendingWriteTree_,i=e.syncPointTree_.findOnPath(r,(e,t)=>{var n=F0(t,fI(e,r));if(n)return n});return o0(n,r,i,t,!0)}function X0(e,t){const r=t._path;let i=null;e.syncPointTree_.foreachOnPath(r,(e,t)=>{var n=fI(e,r);i=i||F0(t,n)});let n=e.syncPointTree_.get(r);n?i=i||F0(n,sI()):(n=new P0,e.syncPointTree_=e.syncPointTree_.set(r,n));var s=null!=i;const o=s?new MT(i,!0,!1):null;var a=n0(e.pendingWriteTree_,t._path);return BT(D0(n,t,a,s?o.getNode():GI.EMPTY_NODE,s).viewCache_)}function Z0(e,t){return function t(n,r,i,s){{if(pI(n.path))return eE(n,r,i,s);{const o=r.get(sI());null==i&&null!=o&&(i=F0(o,sI()));let e=[];const a=oI(n.path),c=n.operationForChild(a),l=r.children.get(a);if(l&&c){const u=i?i.getImmediateChild(a):null,h=p0(s,a);e=e.concat(t(c,l,u,h))}return o&&(e=e.concat(x0(o,n,s,i))),e}}}(t,e.syncPointTree_,null,n0(e.pendingWriteTree_,sI()))}function eE(s,e,o,a){var t=e.get(sI());null==o&&null!=t&&(o=F0(t,sI()));let c=[];return e.children.inorderTraversal((e,t)=>{var n=o?o.getImmediateChild(e):null,r=p0(a,e),i=s.operationForChild(e);i&&(c=c.concat(eE(i,t,n,r)))}),t&&(c=c.concat(x0(t,s,a,o))),c}function tE(i,t){const s=t.query,o=nE(i,s);return{hashFn:()=>{const e=t.viewCache_.serverCache.getNode()||GI.EMPTY_NODE;return e.hash()},onComplete:e=>{if("ok"===e)return o?function(e,t,n){if(s=iE(e,n)){var r=sE(s),i=r.path,s=r.queryId,r=fI(i,t);return oE(e,i,new xT(RT(s),r))}return[]}(i,s._path,o):(t=i,n=s._path,Z0(t,new xT(NT(),n)));var t,n,r=function(e,t){let n="Unknown Error";"too_big"===e?n="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"===e?n="Client doesn't have permission to access the desired data.":"unavailable"===e&&(n="The service is unavailable");const r=new Error(e+" at "+t._path.toString()+": "+n);return r.code=e.toUpperCase(),r}(e,s);return Q0(i,s,null,r)}}}function nE(e,t){var n=rE(t);return e.queryToTagMap.get(n)}function rE(e){return e._path.toString()+"$"+e._queryIdentifier}function iE(e,t){return e.tagToQueryMap.get(t)}function sE(e){var t=e.indexOf("$");return Jh(-1!==t&&t<e.length-1,"Bad queryKey."),{queryId:e.substr(t+1),path:new iI(e.substr(0,t))}}function oE(e,t,n){var r=e.syncPointTree_.get(t);return Jh(r,"Missing sync point for query tag that we're tracking"),x0(r,n,n0(e.pendingWriteTree_,t),null)}function aE(e){return e._queryParams.loadsAllData()&&!e._queryParams.isDefault()?(Jh(B0,"Reference.ts has not been loaded"),new B0(e._repo,e._path)):e}class cE{constructor(e){this.node_=e}getImmediateChild(e){var t=this.node_.getImmediateChild(e);return new cE(t)}node(){return this.node_}}class lE{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){var t=dI(this.path_,e);return new lE(this.syncTree_,t)}node(){return J0(this.syncTree_,this.path_)}}function uE(e){return(e=e||{}).timestamp=e.timestamp||(new Date).getTime(),e}function hE(e,t,n){return e&&"object"==typeof e?(Jh(".sv"in e,"Unexpected leaf node or priority contents"),"string"==typeof e[".sv"]?dE(e[".sv"],t,n):"object"==typeof e[".sv"]?pE(e[".sv"],t):void Jh(!1,"Unexpected server value: "+JSON.stringify(e,null,2))):e}const dE=function(e,t,n){if("timestamp"===e)return n.timestamp;Jh(!1,"Unexpected server value: "+e)},pE=function(e,t,n){e.hasOwnProperty("increment")||Jh(!1,"Unexpected server value: "+JSON.stringify(e,null,2));var r=e.increment;"number"!=typeof r&&Jh(!1,"Unexpected increment value: "+r);const i=t.node();if(Jh(null!==i&&void 0!==i,"Expected ChildrenNode.EMPTY_NODE for nulls"),!i.isLeafNode())return r;const s=i;var o=s.getValue();return"number"!=typeof o?r:o+r},fE=function(e,t,n,r){return mE(t,new lE(n,e),r)},gE=function(e,t,n){return mE(e,new cE(t),n)};function mE(e,r,i){var t=e.getPriority().val(),n=hE(t,r.getImmediateChild(".priority"),i);let s;if(e.isLeafNode()){const o=e;t=hE(o.getValue(),r,i);return t!==o.getValue()||n!==o.getPriority().val()?new FI(t,XI(n)):e}{const a=e;return s=a,n!==a.getPriority().val()&&(s=s.updatePriority(new FI(n))),a.forEachChild(qI,(e,t)=>{var n=mE(t,r.getImmediateChild(e),i);n!==t&&(s=s.updateImmediateChild(e,n))}),s}}class vE{constructor(e="",t=null,n={children:{},childCount:0}){this.name=e,this.parent=t,this.node=n}}function yE(e,t){let n=t instanceof iI?t:new iI(t),r=e,i=oI(n);for(;null!==i;){var s=Id(r.node.children,i)||{children:{},childCount:0};r=new vE(i,r,s),n=cI(n),i=oI(n)}return r}function _E(e){return e.node.value}function wE(e,t){e.node.value=t,EE(e)}function bE(e){return 0<e.node.childCount}function IE(n,r){Ab(n.node.children,(e,t)=>{r(new vE(e,n,t))})}function TE(e){return new iI(null===e.parent?e.name:TE(e.parent)+"/"+e.name)}function EE(e){var t,n,r,i;null!==e.parent&&(t=e.parent,n=e.name,r=function(e){return void 0===_E(e)&&!bE(e)}(e=e),i=bd(t.node.children,n),r&&i?(delete t.node.children[n],t.node.childCount--,EE(t)):r||i||(t.node.children[n]=e.node,t.node.childCount++,EE(t)))}function kE(e,t,n,r){r&&void 0===t||UE(Md(e,"value"),t,n)}function SE(e,t,r,n){if(!n||void 0!==t){const i=Md(e,"values");if(!t||"object"!=typeof t||Array.isArray(t))throw new Error(i+" must be an object containing the children to replace.");const s=[];Ab(t,(e,t)=>{const n=new iI(e);if(UE(i,t,dI(r,n)),".priority"===lI(n)&&!FE(t))throw new Error(i+"contains an invalid value for '"+n.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");s.push(n)}),function(t,n){let r,i;for(r=0;r<n.length;r++){i=n[r];var s=uI(i);for(let e=0;e<s.length;e++)if((".priority"!==s[e]||e!==s.length-1)&&!OE(s[e]))throw new Error(t+"contains an invalid key ("+s[e]+") in path "+i.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"')}n.sort(gI);let e=null;for(r=0;r<n.length;r++){if(i=n[r],null!==e&&vI(e,i))throw new Error(t+"contains a path "+e.toString()+" that is ancestor of another path "+i.toString());e=i}}(i,s)}}function CE(e,t,n){if(!n||void 0!==t){if(Eb(t))throw new Error(Md(e,"priority")+"is "+t.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!FE(t))throw new Error(Md(e,"priority")+"must be a valid Firebase priority (a string, finite number, server value, or null).")}}function AE(e,t,n,r){if(!(r&&void 0===n||OE(n)))throw new Error(Md(e,t)+'was an invalid key = "'+n+'". Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").')}function NE(e,t,n,r){n=n&&n.replace(/^\/*\.info(\/|$)/,"/"),jE(e,t,n,r)}function RE(e,t){if(".info"===oI(t))throw new Error(e+" failed = Can't modify data under /.info/")}const PE=/[\[\].#$\/\u0000-\u001F\u007F]/,xE=/[\[\].#$\u0000-\u001F\u007F]/,DE=10485760,OE=function(e){return"string"==typeof e&&0!==e.length&&!PE.test(e)},ME=function(e){return"string"==typeof e&&0!==e.length&&!xE.test(e)},LE=function(e){return e=e&&e.replace(/^\/*\.info(\/|$)/,"/"),ME(e)},FE=function(e){return null===e||"string"==typeof e||"number"==typeof e&&!Eb(e)||e&&"object"==typeof e&&bd(e,".sv")},UE=function(o,e,t){const a=t instanceof iI?new yI(t,o):t;if(void 0===e)throw new Error(o+"contains undefined "+wI(a));if("function"==typeof e)throw new Error(o+"contains a function "+wI(a)+" with contents = "+e.toString());if(Eb(e))throw new Error(o+"contains "+e.toString()+" "+wI(a));if("string"==typeof e&&e.length>DE/3&&Ud(e)>DE)throw new Error(o+"contains a string greater than "+DE+" utf8 bytes "+wI(a)+" ('"+e.substring(0,50)+"...')");if(e&&"object"==typeof e){let i=!1,s=!1;if(Ab(e,(e,t)=>{if(".value"===e)i=!0;else if(".priority"!==e&&".sv"!==e&&(s=!0,!OE(e)))throw new Error(o+" contains an invalid key ("+e+") "+wI(a)+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');var n,r;n=a,e=e,0<n.parts_.length&&(n.byteLength_+=1),n.parts_.push(e),n.byteLength_+=Ud(e),_I(n),UE(o,t,a),t=a,r=t.parts_.pop(),t.byteLength_-=Ud(r),0<t.parts_.length&&--t.byteLength_}),i&&s)throw new Error(o+' contains ".value" child '+wI(a)+" in addition to actual children.")}},jE=function(e,t,n,r){if(!(r&&void 0===n||ME(n)))throw new Error(Md(e,t)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},qE=function(e,t){var n=t.path.toString();if("string"!=typeof t.repoInfo.host||0===t.repoInfo.host.length||!OE(t.repoInfo.namespace)&&"localhost"!==t.repoInfo.host.split(":")[0]||0!==n.length&&!LE(n))throw new Error(Md(e,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')};class VE{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function BE(e,t){let n=null;for(let i=0;i<t.length;i++){const s=t[i];var r=s.getPath();null===n||mI(r,n.path)||(e.eventLists_.push(n),n=null),null===n&&(n={events:[],path:r}),n.events.push(s)}n&&e.eventLists_.push(n)}function WE(e,t,n){BE(e,n),KE(e,e=>mI(e,t))}function $E(e,t,n){BE(e,n),KE(e,e=>vI(e,t)||vI(t,e))}function KE(e,t){e.recursionDepth_++;let n=!0;for(let i=0;i<e.eventLists_.length;i++){var r=e.eventLists_[i];r&&(t(r.path)?(function(e){for(let n=0;n<e.events.length;n++){const r=e.events[n];var t;null!==r&&(e.events[n]=null,t=r.getEventRunner(),hb&&wb("event: "+r.toString()),Mb(t))}}(e.eventLists_[i]),e.eventLists_[i]=null):n=!1)}n&&(e.eventLists_=[]),e.recursionDepth_--}const zE="repo_interrupt",HE=25;class GE{constructor(e,t,n,r){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=n,this.appCheckProvider_=r,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new VE,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=TT(),this.transactionQueueTree_=new vE,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function QE(o,e,t){if(o.stats_=Hb(o.repoInfo_),o.forceRestClient_||function(){const e="object"==typeof window&&window.navigator&&window.navigator.userAgent||"";return 0<=e.search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)}())o.server_=new bT(o.repoInfo_,(e,t,n,r)=>{XE(o,e,t,n,r)},o.authTokenProvider_,o.appCheckProvider_),setTimeout(()=>ZE(o,!0),0);else{if(null!=t){if("object"!=typeof t)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{_d(t)}catch(e){throw new Error("Invalid authOverride provided: "+e)}}o.persistentConnection_=new II(o.repoInfo_,e,(e,t,n,r)=>{XE(o,e,t,n,r)},e=>{ZE(o,e)},e=>{var n;n=o,Ab(e,(e,t)=>{ek(n,e,t)})},o.authTokenProvider_,o.appCheckProvider_,t),o.server_=o.persistentConnection_}var n;o.authTokenProvider_.addTokenChangeListener(e=>{o.server_.refreshAuthToken(e)}),o.appCheckProvider_.addTokenChangeListener(e=>{o.server_.refreshAppCheckToken(e.token)}),o.statsReporter_=(e=o.repoInfo_,t=()=>new CT(o.stats_,o.server_),n=e.toString(),zb[n]||(zb[n]=t()),zb[n]),o.infoData_=new IT,o.infoSyncTree_=new $0({startListening:(e,t,n,r)=>{let i=[];const s=o.infoData_.getNode(e._path);return s.isEmpty()||(i=G0(o.infoSyncTree_,e._path,s),setTimeout(()=>{r("ok")},0)),i},stopListening:()=>{}}),ek(o,"connected",!1),o.serverSyncTree_=new $0({startListening:(r,e,t,i)=>(o.server_.listen(r,t,e,(e,t)=>{var n=i(e,t);$E(o.eventQueue_,r._path,n)}),[]),stopListening:(e,t)=>{o.server_.unlisten(e,t)}})}function YE(e){const t=e.infoData_.getNode(new iI(".info/serverTimeOffset"));var n=t.val()||0;return(new Date).getTime()+n}function JE(e){return uE({timestamp:YE(e)})}function XE(e,t,n,r,i){e.dataUpdateCount++;var s,o,a=new iI(t);n=e.interceptServerDataCallback_?e.interceptServerDataCallback_(t,n):n;let c=[];c=i?r?(s=Ed(n,e=>XI(e)),function(e,t,n,r){if(a=iE(e,r)){var i=sE(a),s=i.path,o=i.queryId,a=fI(s,t),i=KT.fromObject(n);return oE(e,s,new OT(RT(o),a,i))}return[]}(e.serverSyncTree_,a,s,i)):(s=XI(n),function(e,t,n,r){if(null==(s=iE(e,r)))return[];var i=(o=sE(s)).path,s=o.queryId,o=fI(i,t);return oE(e,i,new DT(RT(s),o,n))}(e.serverSyncTree_,a,s,i)):r?(o=Ed(n,e=>XI(e)),t=e.serverSyncTree_,i=a,r=o,o=KT.fromObject(r),Z0(t,new OT(NT(),i,o))):(o=XI(n),G0(e.serverSyncTree_,a,o));let l=a;0<c.length&&(l=hk(e,a)),$E(e.eventQueue_,l,c)}function ZE(e,t){ek(e,"connected",t),!1===t&&function(r){ak(r,"onDisconnectEvents");const i=JE(r),s=TT();kT(r.onDisconnect_,sI(),(e,t)=>{var n=fE(e,t,r.serverSyncTree_,i);ET(s,e,n)});let o=[];kT(s,sI(),(e,t)=>{o=o.concat(G0(r.serverSyncTree_,e,t));var n=gk(r,e);hk(r,n)}),r.onDisconnect_=TT(),$E(r.eventQueue_,sI(),o)}(e)}function ek(e,t,n){var r=new iI("/.info/"+t),i=XI(n);e.infoData_.updateSnapshot(r,i);i=G0(e.infoSyncTree_,r,i);$E(e.eventQueue_,r,i)}function tk(e){return e.nextWriteId_++}function nk(r,i,e,t,s){ak(r,"set",{path:i.toString(),value:e,priority:t});var n=JE(r);const o=XI(e,t);var a=J0(r.serverSyncTree_,i),n=gE(o,a,n);const c=tk(r);n=K0(r.serverSyncTree_,i,n,c,!0);BE(r.eventQueue_,n),r.server_.put(i.toString(),o.val(!0),(e,t)=>{var n="ok"===e;n||Ib("set at "+i+" failed: "+e);n=H0(r.serverSyncTree_,c,!n);$E(r.eventQueue_,i,n),ck(0,s,e,t)});n=gk(r,i);hk(r,n),$E(r.eventQueue_,n,[])}function rk(n,r,i){n.server_.onDisconnectCancel(r.toString(),(e,t)=>{"ok"===e&&!function e(n,t){if(pI(t))return n.value=null,n.children.clear(),!0;if(null!==n.value){if(n.value.isLeafNode())return!1;{const i=n.value;return n.value=null,i.forEachChild(qI,(e,t)=>{ET(n,new iI(e),t)}),e(n,t)}}if(0<n.children.size){var r=oI(t);return t=cI(t),n.children.has(r)&&e(n.children.get(r),t)&&n.children.delete(r),0===n.children.size}return!0}(n.onDisconnect_,r),ck(0,i,e,t)})}function ik(n,r,e,i){const s=XI(e);n.server_.onDisconnectPut(r.toString(),s.val(!0),(e,t)=>{"ok"===e&&ET(n.onDisconnect_,r,s),ck(0,i,e,t)})}function sk(e,t,n){let r;r=".info"===oI(t._path)?Q0(e.infoSyncTree_,t,n):Q0(e.serverSyncTree_,t,n),WE(e.eventQueue_,t._path,r)}function ok(e){e.persistentConnection_&&e.persistentConnection_.interrupt(zE)}function ak(e,...t){let n="";e.persistentConnection_&&(n=e.persistentConnection_.id+":"),wb(n,...t)}function ck(e,r,i,s){r&&Mb(()=>{if("ok"===i)r(null);else{var t=(i||"error").toUpperCase();let e=t;s&&(e+=": "+s);const n=new Error(e);n.code=t,r(n)}})}function lk(e,t,n){return J0(e.serverSyncTree_,t,n)||GI.EMPTY_NODE}function uk(t,e=t.transactionQueueTree_){if(e||fk(t,e),_E(e)){const n=pk(t,e);Jh(0<n.length,"Sending zero length transaction queue"),n.every(e=>0===e.status)&&function(i,s,o){const e=o.map(e=>e.currentWriteId),t=lk(i,s,e);let n=t;var r=t.hash();for(let u=0;u<o.length;u++){const h=o[u];Jh(0===h.status,"tryToSendTransactionQueue_: items in queue should all be run."),h.status=1,h.retryCount++;var a=fI(s,h.path);n=n.updateChild(a,h.currentOutputSnapshotRaw)}const c=n.val(!0),l=s;i.server_.put(l.toString(),c,t=>{ak(i,"transaction put response",{path:l.toString(),status:t});let n=[];if("ok"===t){const r=[];for(let e=0;e<o.length;e++)o[e].status=2,n=n.concat(H0(i.serverSyncTree_,o[e].currentWriteId)),o[e].onComplete&&r.push(()=>o[e].onComplete(null,!0,o[e].currentOutputSnapshotResolved)),o[e].unwatcher();fk(i,yE(i.transactionQueueTree_,s)),uk(i,i.transactionQueueTree_),$E(i.eventQueue_,s,n);for(let t=0;t<r.length;t++)Mb(r[t])}else{if("datastale"===t)for(let e=0;e<o.length;e++)3===o[e].status?o[e].status=4:o[e].status=0;else{Ib("transaction at "+l.toString()+" failed: "+t);for(let e=0;e<o.length;e++)o[e].status=4,o[e].abortReason=t}hk(i,s)}},r)}(t,TE(e),n)}else bE(e)&&IE(e,e=>{uk(t,e)})}function hk(e,t){var n=dk(e,t),r=TE(n);return function(i,s,o){if(0!==s.length){const l=[];let n=[];const t=s.filter(e=>0===e.status),u=t.map(e=>e.currentWriteId);for(let r=0;r<s.length;r++){const h=s[r];var a=fI(o,h.path);let e=!1,t;if(Jh(null!==a,"rerunTransactionsUnderNode_: relativePath should not be null."),4===h.status)e=!0,t=h.abortReason,n=n.concat(H0(i.serverSyncTree_,h.currentWriteId,!0));else if(0===h.status)if(h.retryCount>=HE)e=!0,t="maxretry",n=n.concat(H0(i.serverSyncTree_,h.currentWriteId,!0));else{const d=lk(i,h.path,u);h.currentInputSnapshot=d;var c=s[r].update(d.val());if(void 0!==c){UE("transaction failed: Data returned ",c,h.path);let e=XI(c);"object"==typeof c&&null!=c&&bd(c,".priority")||(e=e.updatePriority(d.getPriority()));a=h.currentWriteId,c=JE(i),c=gE(e,d,c);h.currentOutputSnapshotRaw=e,h.currentOutputSnapshotResolved=c,h.currentWriteId=tk(i),u.splice(u.indexOf(a),1),n=n.concat(K0(i.serverSyncTree_,h.path,c,h.currentWriteId,h.applyLocally)),n=n.concat(H0(i.serverSyncTree_,a,!0))}else e=!0,t="nodata",n=n.concat(H0(i.serverSyncTree_,h.currentWriteId,!0))}$E(i.eventQueue_,o,n),n=[],e&&(s[r].status=2,function(e){setTimeout(e,Math.floor(0))}(s[r].unwatcher),s[r].onComplete&&("nodata"===t?l.push(()=>s[r].onComplete(null,!1,s[r].currentInputSnapshot)):l.push(()=>s[r].onComplete(new Error(t),!1,null))))}fk(i,i.transactionQueueTree_);for(let e=0;e<l.length;e++)Mb(l[e]);uk(i,i.transactionQueueTree_)}}(e,pk(e,n),r),r}function dk(e,t){let n,r=e.transactionQueueTree_;for(n=oI(t);null!==n&&void 0===_E(r);)r=yE(r,n),t=cI(t),n=oI(t);return r}function pk(e,t){const n=[];return function t(n,e,r){const i=_E(e);if(i)for(let e=0;e<i.length;e++)r.push(i[e]);IE(e,e=>{t(n,e,r)})}(e,t,n),n.sort((e,t)=>e.order-t.order),n}function fk(t,n){const r=_E(n);if(r){let e=0;for(let t=0;t<r.length;t++)2!==r[t].status&&(r[e]=r[t],e++);r.length=e,wE(n,0<r.length?r:void 0)}IE(n,e=>{fk(t,e)})}function gk(t,e){var n=TE(dk(t,e)),r=yE(t.transactionQueueTree_,e);return function(e,t,n){let r=n?e:e.parent;for(;null!==r;){if(t(r))return;r=r.parent}}(r,e=>{mk(t,e)}),mk(t,r),function t(e,n,r,i){r&&!i&&n(e),IE(e,e=>{t(e,n,!0,i)}),r&&i&&n(e)}(r,e=>{mk(t,e)}),n}function mk(i,s){const o=_E(s);if(o){const a=[];let e=[],t=-1;for(let n=0;n<o.length;n++)3===o[n].status||(1===o[n].status?(Jh(t===n-1,"All SENT items should be at beginning of queue."),t=n,o[n].status=3,o[n].abortReason="set"):(Jh(0===o[n].status,"Unexpected transaction status in abort"),o[n].unwatcher(),e=e.concat(H0(i.serverSyncTree_,o[n].currentWriteId,!0)),o[n].onComplete&&a.push(o[n].onComplete.bind(null,new Error("set"),!1,null))));-1===t?wE(s,void 0):o.length=t+1,$E(i.eventQueue_,TE(s),e);for(let r=0;r<a.length;r++)Mb(a[r])}}const vk=function(e,t){var n=yk(e),r=n.namespace;"firebase.com"===n.domain&&bb(n.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),r&&"undefined"!==r||"localhost"===n.domain||bb("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),n.secure||Tb();var i="ws"===n.scheme||"wss"===n.scheme;return{repoInfo:new Bb(n.host,n.secure,r,t,i,"",r!==n.subdomain),path:new iI(n.pathString)}},yk=function(r){let i="",s="",o="",a="",c="",l=!0,u="https",h=443;if("string"==typeof r){let e=r.indexOf("//");0<=e&&(u=r.substring(0,e-1),r=r.substring(e+2));let t=r.indexOf("/");-1===t&&(t=r.length);let n=r.indexOf("?");-1===n&&(n=r.length),i=r.substring(0,Math.min(t,n)),t<n&&(a=function(e){let t="";var n=e.split("/");for(let r=0;r<n.length;r++)if(0<n[r].length){let e=n[r];try{e=decodeURIComponent(e.replace(/\+/g," "))}catch(e){}t+="/"+e}return t}(r.substring(t,n)));var d,p=function(e){const t={};for(const r of(e="?"===e.charAt(0)?e.substring(1):e).split("&")){var n;0!==r.length&&(2===(n=r.split("=")).length?t[decodeURIComponent(n[0])]=decodeURIComponent(n[1]):Ib(`Invalid query segment '${r}' in query '${e}'`))}return t}(r.substring(Math.min(r.length,n)));e=i.indexOf(":"),0<=e?(l="https"===u||"wss"===u,h=parseInt(i.substring(e+1),10)):e=i.length;const f=i.slice(0,e);"localhost"===f.toLowerCase()?s="localhost":f.split(".").length<=2?s=f:(d=i.indexOf("."),o=i.substring(0,d).toLowerCase(),s=i.substring(d+1),c=o),"ns"in p&&(c=p.ns)}return{host:i,port:h,domain:s,subdomain:o,secure:l,scheme:u,pathString:a,namespace:c}};class _k{constructor(e,t,n,r){this.eventType=e,this.eventRegistration=t,this.snapshot=n,this.prevName=r}getPath(){var e=this.snapshot.ref;return("value"===this.eventType?e:e.parent)._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+_d(this.snapshot.exportVal())}}class wk{constructor(e,t,n){this.eventRegistration=e,this.error=t,this.path=n}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}class bk{constructor(e,t){this.snapshotCallback=e,this.cancelCallback=t}onValue(e,t){this.snapshotCallback.call(null,e,t)}onCancel(e){return Jh(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,e)}get hasCancelCallback(){return!!this.cancelCallback}matches(e){return this.snapshotCallback===e.snapshotCallback||void 0!==this.snapshotCallback.userCallback&&this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&&this.snapshotCallback.context===e.snapshotCallback.context}}class Ik{constructor(e,t){this._repo=e,this._path=t}cancel(){const e=new rd;return rk(this._repo,this._path,e.wrapCallback(()=>{})),e.promise}remove(){RE("OnDisconnect.remove",this._path);const e=new rd;return ik(this._repo,this._path,null,e.wrapCallback(()=>{})),e.promise}set(e){RE("OnDisconnect.set",this._path),kE("OnDisconnect.set",e,this._path,!1);const t=new rd;return ik(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}setWithPriority(e,t){RE("OnDisconnect.setWithPriority",this._path),kE("OnDisconnect.setWithPriority",e,this._path,!1),CE("OnDisconnect.setWithPriority",t,!1);const n=new rd;return function(n,r,e,t,i){const s=XI(e,t);n.server_.onDisconnectPut(r.toString(),s.val(!0),(e,t)=>{"ok"===e&&ET(n.onDisconnect_,r,s),ck(0,i,e,t)})}(this._repo,this._path,e,t,n.wrapCallback(()=>{})),n.promise}update(e){RE("OnDisconnect.update",this._path),SE("OnDisconnect.update",e,this._path,!1);const t=new rd;return function(r,i,n,s){if(Td(n))return wb("onDisconnect().update() called with empty data. Don't do anything."),ck(0,s,"ok",void 0);r.server_.onDisconnectMerge(i.toString(),n,(e,t)=>{"ok"===e&&Ab(n,(e,t)=>{var n=XI(t);ET(r.onDisconnect_,dI(i,e),n)}),ck(0,s,e,t)})}(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}}class Tk{constructor(e,t,n,r){this._repo=e,this._path=t,this._queryParams=n,this._orderByCalled=r}get key(){return pI(this._path)?null:lI(this._path)}get ref(){return new Ck(this._repo,this._path)}get _queryIdentifier(){var e=wT(this._queryParams),e=vb(e);return"{}"===e?"default":e}get _queryObject(){return wT(this._queryParams)}isEqual(e){if(!((e=$d(e))instanceof Tk))return!1;var t=this._repo===e._repo,n=mI(this._path,e._path),r=this._queryIdentifier===e._queryIdentifier;return t&&n&&r}toJSON(){return this.toString()}toString(){return this._repo.toString()+function(e){let t="";for(let n=e.pieceNum_;n<e.pieces_.length;n++)""!==e.pieces_[n]&&(t+="/"+encodeURIComponent(String(e.pieces_[n])));return t||"/"}(this._path)}}function Ek(e,t){if(!0===e._orderByCalled)throw new Error(t+": You can't combine multiple orderBy calls.")}function kk(e){let t=null,n=null;if(e.hasStart()&&(t=e.getIndexStartValue()),e.hasEnd()&&(n=e.getIndexEndValue()),e.getIndex()===CI){var r="Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().",i="Query: When ordering by key, the argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() must be a string.";if(e.hasStart()){if(e.getIndexStartName()!==kb)throw new Error(r);if("string"!=typeof t)throw new Error(i)}if(e.hasEnd()){if(e.getIndexEndName()!==Sb)throw new Error(r);if("string"!=typeof n)throw new Error(i)}}else if(e.getIndex()===qI){if(null!=t&&!FE(t)||null!=n&&!FE(n))throw new Error("Query: When ordering by priority, the first argument passed to startAt(), startAfter() endAt(), endBefore(), or equalTo() must be a valid priority value (null, a number, or a string).")}else if(Jh(e.getIndex()instanceof ZI||e.getIndex()===nT,"unknown index type."),null!=t&&"object"==typeof t||null!=n&&"object"==typeof n)throw new Error("Query: First argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() cannot be an object.")}function Sk(e){if(e.hasStart()&&e.hasEnd()&&e.hasLimit()&&!e.hasAnchoredLimit())throw new Error("Query: Can't combine startAt(), startAfter(), endAt(), endBefore(), and limit(). Use limitToFirst() or limitToLast() instead.")}class Ck extends Tk{constructor(e,t){super(e,t,new gT,!1)}get parent(){var e=hI(this._path);return null===e?null:new Ck(this._repo,e)}get root(){let e=this;for(;null!==e.parent;)e=e.parent;return e}}class Ak{constructor(e,t,n){this._node=e,this.ref=t,this._index=n}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){var t=new iI(e),n=Pk(this.ref,e);return new Ak(this._node.getChild(t),n,qI)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(n){if(this._node.isLeafNode())return!1;const e=this._node;return!!e.forEachChild(this._index,(e,t)=>n(new Ak(t,Pk(this.ref,e),qI)))}hasChild(e){var t=new iI(e);return!this._node.getChild(t).isEmpty()}hasChildren(){return!this._node.isLeafNode()&&!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function Nk(e,t){return(e=$d(e))._checkNotDeleted("ref"),void 0!==t?Pk(e._root,t):e._root}function Rk(e,t){(e=$d(e))._checkNotDeleted("refFromURL");const n=vk(t,e._repo.repoInfo_.nodeAdmin);qE("refFromURL",n);var r=n.repoInfo;return e._repo.repoInfo_.isCustomHost()||r.host===e._repo.repoInfo_.host||bb("refFromURL: Host name does not match the current database: (found "+r.host+" but expected "+e._repo.repoInfo_.host+")"),Nk(e,n.path.toString())}function Pk(e,t){return(null===oI((e=$d(e))._path)?NE:jE)("child","path",t,!1),new Ck(e._repo,dI(e._path,t))}function xk(e,t){e=$d(e),RE("set",e._path),kE("set",t,e._path,!1);const n=new rd;return nk(e._repo,e._path,t,null,n.wrapCallback(()=>{})),n.promise}function Dk(e,t){SE("update",t,e._path,!1);const n=new rd;return function(i,s,e,o){ak(i,"update",{path:s.toString(),value:e});let n=!0;const r=JE(i),a={};if(Ab(e,(e,t)=>{n=!1,a[e]=fE(dI(s,e),XI(t),i.serverSyncTree_,r)}),n)wb("update() called with empty data. Don't do anything."),ck(0,o,"ok",void 0);else{const c=tk(i);var t=z0(i.serverSyncTree_,s,a,c);BE(i.eventQueue_,t),i.server_.merge(s.toString(),e,(e,t)=>{var n="ok"===e;n||Ib("update at "+s+" failed: "+e);var r=H0(i.serverSyncTree_,c,!n),n=0<r.length?hk(i,s):s;$E(i.eventQueue_,n,r),ck(0,o,e,t)}),Ab(e,e=>{var t=gk(i,dI(s,e));hk(i,t)}),$E(i.eventQueue_,s,[])}}(e._repo,e._path,t,n.wrapCallback(()=>{})),n.promise}function Ok(t){return t=$d(t),r=t._repo,i=t,(null!=(e=X0(r.serverSyncTree_,i))?Promise.resolve(e):r.server_.get(i).then(e=>{var t=XI(e).withIndex(i._queryParams.getIndex()),n=G0(r.serverSyncTree_,i._path,t);return WE(r.eventQueue_,i._path,n),Promise.resolve(t)},e=>(ak(r,"get for query "+_d(i)+" failed: "+e),Promise.reject(new Error(e))))).then(e=>new Ak(e,new Ck(t._repo,t._path),t._queryParams.getIndex()));var r,i,e}class Mk{constructor(e){this.callbackContext=e}respondsTo(e){return"value"===e}createEvent(e,t){var n=t._queryParams.getIndex();return new _k("value",this,new Ak(e.snapshotNode,new Ck(t._repo,t._path),n))}getEventRunner(e){return"cancel"===e.getEventType()?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new wk(this,e,t):null}matches(e){return e instanceof Mk&&(!e.callbackContext||!this.callbackContext||e.callbackContext.matches(this.callbackContext))}hasAnyCallback(){return null!==this.callbackContext}}class Lk{constructor(e,t){this.eventType=e,this.callbackContext=t}respondsTo(e){let t="children_added"===e?"child_added":e;return t="children_removed"===t?"child_removed":t,this.eventType===t}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new wk(this,e,t):null}createEvent(e,t){Jh(null!=e.childName,"Child events should have a childName.");var n=Pk(new Ck(t._repo,t._path),e.childName),r=t._queryParams.getIndex();return new _k(e.type,this,new Ak(e.snapshotNode,n,r),e.prevName)}getEventRunner(e){return"cancel"===e.getEventType()?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,e.prevName)}matches(e){return e instanceof Lk&&(this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)))}hasAnyCallback(){return!!this.callbackContext}}function Fk(n,e,t,r,i){let s;if("object"==typeof r&&(s=void 0,i=r),"function"==typeof r&&(s=r),i&&i.onlyOnce){const c=t;var o=(e,t)=>{sk(n._repo,n,a),c(e,t)};o.userCallback=t.userCallback,o.context=t.context,t=o}o=new bk(t,s||void 0);const a="value"===e?new Mk(o):new Lk(e,o);return function(e,t,n){let r;r=".info"===oI(t._path)?Y0(e.infoSyncTree_,t,n):Y0(e.serverSyncTree_,t,n),WE(e.eventQueue_,t._path,r)}(n._repo,n,a),()=>sk(n._repo,n,a)}function Uk(e,t,n,r){return Fk(e,"value",t,n,r)}function jk(e,t,n,r){return Fk(e,"child_added",t,n,r)}function qk(e,t,n,r){return Fk(e,"child_changed",t,n,r)}function Vk(e,t,n,r){return Fk(e,"child_moved",t,n,r)}function Bk(e,t,n,r){return Fk(e,"child_removed",t,n,r)}function Wk(e,t,n){let r=null;var i=n?new bk(n):null;"value"===t?r=new Mk(i):t&&(r=new Lk(t,i)),sk(e._repo,e,r)}class $k{}class Kk extends $k{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){kE("endAt",this._value,e._path,!0);var t=vT(e._queryParams,this._value,this._key);if(Sk(t),kk(t),e._queryParams.hasEnd())throw new Error("endAt: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new Tk(e._repo,e._path,t,e._orderByCalled)}}class zk extends $k{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){kE("endBefore",this._value,e._path,!1);var t=function(e,t,n){let r,i;return i=e.index_===CI?vT(e,t="string"==typeof t?tT(t):t,n):(r=null==n?kb:tT(n),vT(e,t,r)),i.endBeforeSet_=!0,i}(e._queryParams,this._value,this._key);if(Sk(t),kk(t),e._queryParams.hasEnd())throw new Error("endBefore: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new Tk(e._repo,e._path,t,e._orderByCalled)}}class Hk extends $k{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){kE("startAt",this._value,e._path,!0);var t=mT(e._queryParams,this._value,this._key);if(Sk(t),kk(t),e._queryParams.hasStart())throw new Error("startAt: Starting point was already set (by another call to startAt, startBefore or equalTo).");return new Tk(e._repo,e._path,t,e._orderByCalled)}}class Gk extends $k{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){kE("startAfter",this._value,e._path,!1);var t=function(t,n,r){let i;if(t.index_===CI)"string"==typeof n&&(n=eT(n)),i=mT(t,n,r);else{let e;e=null==r?Sb:eT(r),i=mT(t,n,e)}return i.startAfterSet_=!0,i}(e._queryParams,this._value,this._key);if(Sk(t),kk(t),e._queryParams.hasStart())throw new Error("startAfter: Starting point was already set (by another call to startAt, startAfter, or equalTo).");return new Tk(e._repo,e._path,t,e._orderByCalled)}}class Qk extends $k{constructor(e){super(),this._limit=e}_apply(e){if(e._queryParams.hasLimit())throw new Error("limitToFirst: Limit was already set (by another call to limitToFirst or limitToLast).");return new Tk(e._repo,e._path,function(e,t){const n=e.copy();return n.limitSet_=!0,n.limit_=t,n.viewFrom_="l",n}(e._queryParams,this._limit),e._orderByCalled)}}class Yk extends $k{constructor(e){super(),this._limit=e}_apply(e){if(e._queryParams.hasLimit())throw new Error("limitToLast: Limit was already set (by another call to limitToFirst or limitToLast).");return new Tk(e._repo,e._path,function(e,t){const n=e.copy();return n.limitSet_=!0,n.limit_=t,n.viewFrom_="r",n}(e._queryParams,this._limit),e._orderByCalled)}}class Jk extends $k{constructor(e){super(),this._path=e}_apply(e){Ek(e,"orderByChild");var t=new iI(this._path);if(pI(t))throw new Error("orderByChild: cannot pass in empty path. Use orderByValue() instead.");t=new ZI(t),t=yT(e._queryParams,t);return kk(t),new Tk(e._repo,e._path,t,!0)}}class Xk extends $k{_apply(e){Ek(e,"orderByKey");var t=yT(e._queryParams,CI);return kk(t),new Tk(e._repo,e._path,t,!0)}}class Zk extends $k{_apply(e){Ek(e,"orderByPriority");var t=yT(e._queryParams,qI);return kk(t),new Tk(e._repo,e._path,t,!0)}}class eS extends $k{_apply(e){Ek(e,"orderByValue");var t=yT(e._queryParams,nT);return kk(t),new Tk(e._repo,e._path,t,!0)}}class tS extends $k{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){if(kE("equalTo",this._value,e._path,!1),e._queryParams.hasStart())throw new Error("equalTo: Starting point was already set (by another call to startAt/startAfter or equalTo).");if(e._queryParams.hasEnd())throw new Error("equalTo: Ending point was already set (by another call to endAt/endBefore or equalTo).");return new Kk(this._value,this._key)._apply(new Hk(this._value,this._key)._apply(e))}}function nS(e,...t){let n=$d(e);for(const r of t)n=r._apply(n);return n}nb=Ck,Jh(!R0,"__referenceConstructor has already been defined"),R0=nb,rb=Ck,Jh(!B0,"__referenceConstructor has already been defined"),B0=rb;const rS="FIREBASE_DATABASE_EMULATOR_HOST",iS={};let sS=!1;function oS(e,t,n,r,i){let s=r||e.options.databaseURL;void 0===s&&(e.options.projectId||bb("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),wb("Using default host for project ",e.options.projectId),s=`${e.options.projectId}-default-rtdb.firebaseio.com`);let o=vk(s,i),a=o.repoInfo,c,l=void 0;"undefined"!=typeof process&&(l=process.env[rS]),l?(c=!0,s=`http://${l}?ns=${a.namespace}`,o=vk(s,i),a=o.repoInfo):c=!o.repoInfo.secure;var u=i&&c?new Ub(Ub.OWNER):new Fb(e.name,e.options,t);qE("Invalid Firebase Database URL",o),pI(o.path)||bb("Database URL must point to the root of a Firebase Database (not including a child path).");u=function(e,t,n,r){let i=iS[t.name];i||(i={},iS[t.name]=i);var s=i[e.toURLString()];s&&bb("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call.");return s=new GE(e,sS,n,r),i[e.toURLString()]=s}(a,e,u,new Lb(e.name,n));return new aS(u,e)}class aS{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(QE(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new Ck(this._repo,sI())),this._rootInternal}_delete(){return null!==this._rootInternal&&(function(e,t){const n=iS[t];n&&n[e.key]===e||bb(`Database ${t}(${e.repoInfo_}) has already been deleted.`),ok(e),delete n[e.key]}(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){null===this._rootInternal&&bb("Cannot call "+e+" on a deleted database.")}}function cS(e,t,n,r={}){(e=$d(e))._checkNotDeleted("useEmulator"),e._instanceStarted&&bb("Cannot call useEmulator() after instance has already been initialized.");var i,s=e._repoInternal;let o=void 0;s.repoInfo_.nodeAdmin?(r.mockUserToken&&bb('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new Ub(Ub.OWNER)):r.mockUserToken&&(i="string"==typeof r.mockUserToken?r.mockUserToken:id(r.mockUserToken,e.app.options.projectId),o=new Ub(i)),r=s,e=t,t=n,n=o,r.repoInfo_=new Bb(`${e}:${t}`,!1,r.repoInfo_.namespace,r.repoInfo_.webSocketOnly,r.repoInfo_.nodeAdmin,r.repoInfo_.persistenceKey,r.repoInfo_.includeNamespaceInQueryParams),n&&(r.authTokenProvider_=n)}function lS(e){(e=$d(e))._checkNotDeleted("goOnline"),(e=e._repo).persistentConnection_&&e.persistentConnection_.resume(zE)}function uS(e,t){_b(e,t)}const hS={".sv":"timestamp"};class dS{constructor(e,t){this.committed=e,this.snapshot=t}toJSON(){return{committed:this.committed,snapshot:this.snapshot.toJSON()}}}function pS(i,e,t){if(i=$d(i),RE("Reference.transaction",i._path),".length"===i.key||".keys"===i.key)throw"Reference.transaction failed: "+i.key+" is a read-only object.";var n=null===(r=null==t?void 0:t.applyLocally)||void 0===r||r;const s=new rd;var r=Uk(i,()=>{});return function(t,n,e,r,i,s){ak(t,"transaction on "+n);const o={path:n,update:e,onComplete:r,status:null,order:lb(),applyLocally:s,retryCount:0,unwatcher:i,abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},a=lk(t,n,void 0);o.currentInputSnapshot=a;var c=o.update(a.val());if(void 0===c)o.unwatcher(),o.currentOutputSnapshotRaw=null,o.currentOutputSnapshotResolved=null,o.onComplete&&o.onComplete(null,!1,o.currentInputSnapshot);else{UE("transaction failed: Data returned ",c,o.path),o.status=0;var l=yE(t.transactionQueueTree_,n);const u=_E(l)||[];u.push(o),wE(l,u);let e;if("object"==typeof c&&null!==c&&bd(c,".priority"))e=Id(c,".priority"),Jh(FE(e),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.");else{const h=J0(t.serverSyncTree_,n)||GI.EMPTY_NODE;e=h.getPriority().val()}l=JE(t),c=XI(c,e),l=gE(c,a,l);o.currentOutputSnapshotRaw=c,o.currentOutputSnapshotResolved=l,o.currentWriteId=tk(t);l=K0(t.serverSyncTree_,n,l,o.currentWriteId,o.applyLocally);$E(t.eventQueue_,n,l),uk(t,t.transactionQueueTree_)}}(i._repo,i._path,e,(e,t,n)=>{var r;e?s.reject(e):(r=new Ak(n,new Ck(i._repo,i._path),qI),s.resolve(new dS(t,r)))},r,n),s.promise}II.prototype.simpleListen=function(e,t){this.sendRequest("q",{p:e},t)},II.prototype.echo=function(e,t){this.sendRequest("echo",{d:e},t)},Yw(gp),hp(new Kd("database",(e,{instanceIdentifier:t})=>{return oS(e.getProvider("app").getImmediate(),e.getProvider("auth-internal"),e.getProvider("app-check-internal"),t)},"PUBLIC").setMultipleInstances(!0)),_p(Gw,"0.12.5",ib),_p(Gw,"0.12.5","esm2017");function fS(e){var t="FIREBASE WARNING: "+e;gS.warn(t)}const gS=new ep("@firebase/database-compat");class mS{constructor(e){this._delegate=e}cancel(t){Od("OnDisconnect.cancel",0,1,arguments.length),Ld("OnDisconnect.cancel","onComplete",t,!0);const e=this._delegate.cancel();return t&&e.then(()=>t(null),e=>t(e)),e}remove(t){Od("OnDisconnect.remove",0,1,arguments.length),Ld("OnDisconnect.remove","onComplete",t,!0);const e=this._delegate.remove();return t&&e.then(()=>t(null),e=>t(e)),e}set(e,t){Od("OnDisconnect.set",1,2,arguments.length),Ld("OnDisconnect.set","onComplete",t,!0);const n=this._delegate.set(e);return t&&n.then(()=>t(null),e=>t(e)),n}setWithPriority(e,t,n){Od("OnDisconnect.setWithPriority",2,3,arguments.length),Ld("OnDisconnect.setWithPriority","onComplete",n,!0);const r=this._delegate.setWithPriority(e,t);return n&&r.then(()=>n(null),e=>n(e)),r}update(t,n){if(Od("OnDisconnect.update",1,2,arguments.length),Array.isArray(t)){const r={};for(let e=0;e<t.length;++e)r[""+e]=t[e];t=r,fS("Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}Ld("OnDisconnect.update","onComplete",n,!0);const e=this._delegate.update(t);return n&&e.then(()=>n(null),e=>n(e)),e}}class vS{constructor(e,t){this.committed=e,this.snapshot=t}toJSON(){return Od("TransactionResult.toJSON",0,1,arguments.length),{committed:this.committed,snapshot:this.snapshot.toJSON()}}}class yS{constructor(e,t){this._database=e,this._delegate=t}val(){return Od("DataSnapshot.val",0,0,arguments.length),this._delegate.val()}exportVal(){return Od("DataSnapshot.exportVal",0,0,arguments.length),this._delegate.exportVal()}toJSON(){return Od("DataSnapshot.toJSON",0,1,arguments.length),this._delegate.toJSON()}exists(){return Od("DataSnapshot.exists",0,0,arguments.length),this._delegate.exists()}child(e){return Od("DataSnapshot.child",0,1,arguments.length),e=String(e),jE("DataSnapshot.child","path",e,!1),new yS(this._database,this._delegate.child(e))}hasChild(e){return Od("DataSnapshot.hasChild",1,1,arguments.length),jE("DataSnapshot.hasChild","path",e,!1),this._delegate.hasChild(e)}getPriority(){return Od("DataSnapshot.getPriority",0,0,arguments.length),this._delegate.priority}forEach(t){return Od("DataSnapshot.forEach",1,1,arguments.length),Ld("DataSnapshot.forEach","action",t,!1),this._delegate.forEach(e=>t(new yS(this._database,e)))}hasChildren(){return Od("DataSnapshot.hasChildren",0,0,arguments.length),this._delegate.hasChildren()}get key(){return this._delegate.key}numChildren(){return Od("DataSnapshot.numChildren",0,0,arguments.length),this._delegate.size}getRef(){return Od("DataSnapshot.ref",0,0,arguments.length),new wS(this._database,this._delegate.ref)}get ref(){return this.getRef()}}class _S{constructor(e,t){this.database=e,this._delegate=t}on(e,n,t,r){var i;Od("Query.on",2,4,arguments.length),Ld("Query.on","callback",n,!1);const s=_S.getCancelAndContextArgs_("Query.on",t,r);var o=(e,t)=>{n.call(s.context,new yS(this.database,e),t)};o.userCallback=n,o.context=s.context;var a=null===(i=s.cancel)||void 0===i?void 0:i.bind(s.context);switch(e){case"value":return Uk(this._delegate,o,a),n;case"child_added":return jk(this._delegate,o,a),n;case"child_removed":return Bk(this._delegate,o,a),n;case"child_changed":return qk(this._delegate,o,a),n;case"child_moved":return Vk(this._delegate,o,a),n;default:throw new Error(Md("Query.on","eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}}off(e,t,n){var r;Od("Query.off",0,3,arguments.length),function(e,t,n){if(!n||void 0!==t)switch(t){case"value":case"child_added":case"child_removed":case"child_changed":case"child_moved":break;default:throw new Error(Md(e,"eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}}("Query.off",e,!0),Ld("Query.off","callback",t,!0),Fd("Query.off","context",n,!0),t?((r=()=>{}).userCallback=t,r.context=n,Wk(this._delegate,e,r)):Wk(this._delegate,e)}get(){return Ok(this._delegate).then(e=>new yS(this.database,e))}once(e,r,t,n){Od("Query.once",1,4,arguments.length),Ld("Query.once","callback",r,!0);const i=_S.getCancelAndContextArgs_("Query.once",t,n),s=new rd;var o=(e,t)=>{var n=new yS(this.database,e);r&&r.call(i.context,n,t),s.resolve(n)};o.userCallback=r,o.context=i.context;var a=e=>{i.cancel&&i.cancel.call(i.context,e),s.reject(e)};switch(e){case"value":Uk(this._delegate,o,a,{onlyOnce:!0});break;case"child_added":jk(this._delegate,o,a,{onlyOnce:!0});break;case"child_removed":Bk(this._delegate,o,a,{onlyOnce:!0});break;case"child_changed":qk(this._delegate,o,a,{onlyOnce:!0});break;case"child_moved":Vk(this._delegate,o,a,{onlyOnce:!0});break;default:throw new Error(Md("Query.once","eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}return s.promise}limitToFirst(e){return Od("Query.limitToFirst",1,1,arguments.length),new _S(this.database,nS(this._delegate,function(e){if("number"!=typeof e||Math.floor(e)!==e||e<=0)throw new Error("limitToFirst: First argument must be a positive integer.");return new Qk(e)}(e)))}limitToLast(e){return Od("Query.limitToLast",1,1,arguments.length),new _S(this.database,nS(this._delegate,function(e){if("number"!=typeof e||Math.floor(e)!==e||e<=0)throw new Error("limitToLast: First argument must be a positive integer.");return new Yk(e)}(e)))}orderByChild(e){return Od("Query.orderByChild",1,1,arguments.length),new _S(this.database,nS(this._delegate,function(e){if("$key"===e)throw new Error('orderByChild: "$key" is invalid. Use orderByKey() instead.');if("$priority"===e)throw new Error('orderByChild: "$priority" is invalid. Use orderByPriority() instead.');if("$value"===e)throw new Error('orderByChild: "$value" is invalid. Use orderByValue() instead.');return jE("orderByChild","path",e,!1),new Jk(e)}(e)))}orderByKey(){return Od("Query.orderByKey",0,0,arguments.length),new _S(this.database,nS(this._delegate,new Xk))}orderByPriority(){return Od("Query.orderByPriority",0,0,arguments.length),new _S(this.database,nS(this._delegate,new Zk))}orderByValue(){return Od("Query.orderByValue",0,0,arguments.length),new _S(this.database,nS(this._delegate,new eS))}startAt(e=null,t){return Od("Query.startAt",0,2,arguments.length),new _S(this.database,nS(this._delegate,([e=null,t]=[e,t],AE("startAt","key",t,!0),new Hk(e,t))))}startAfter(e=null,t){return Od("Query.startAfter",0,2,arguments.length),new _S(this.database,nS(this._delegate,(e=e,t=t,AE("startAfter","key",t,!0),new Gk(e,t))))}endAt(e=null,t){return Od("Query.endAt",0,2,arguments.length),new _S(this.database,nS(this._delegate,(e=e,t=t,AE("endAt","key",t,!0),new Kk(e,t))))}endBefore(e=null,t){return Od("Query.endBefore",0,2,arguments.length),new _S(this.database,nS(this._delegate,(e=e,t=t,AE("endBefore","key",t,!0),new zk(e,t))))}equalTo(e,t){return Od("Query.equalTo",1,2,arguments.length),new _S(this.database,nS(this._delegate,(e=e,t=t,AE("equalTo","key",t,!0),new tS(e,t))))}toString(){return Od("Query.toString",0,0,arguments.length),this._delegate.toString()}toJSON(){return Od("Query.toJSON",0,1,arguments.length),this._delegate.toJSON()}isEqual(e){if(Od("Query.isEqual",1,1,arguments.length),e instanceof _S)return this._delegate.isEqual(e._delegate);throw new Error("Query.isEqual failed: First argument must be an instance of firebase.database.Query.")}static getCancelAndContextArgs_(e,t,n){const r={cancel:void 0,context:void 0};if(t&&n)r.cancel=t,Ld(e,"cancel",r.cancel,!0),r.context=n,Fd(e,"context",r.context,!0);else if(t)if("object"==typeof t&&null!==t)r.context=t;else{if("function"!=typeof t)throw new Error(Md(e,"cancelOrContext")+" must either be a cancel callback or a context object.");r.cancel=t}return r}get ref(){return new wS(this.database,new Ck(this._delegate._repo,this._delegate._path))}}class wS extends _S{constructor(e,t){super(e,new Tk(t._repo,t._path,new gT,!1)),this.database=e,this._delegate=t}getKey(){return Od("Reference.key",0,0,arguments.length),this._delegate.key}child(e){return Od("Reference.child",1,1,arguments.length),"number"==typeof e&&(e=String(e)),new wS(this.database,Pk(this._delegate,e))}getParent(){Od("Reference.parent",0,0,arguments.length);var e=this._delegate.parent;return e?new wS(this.database,e):null}getRoot(){return Od("Reference.root",0,0,arguments.length),new wS(this.database,this._delegate.root)}set(e,t){Od("Reference.set",1,2,arguments.length),Ld("Reference.set","onComplete",t,!0);const n=xk(this._delegate,e);return t&&n.then(()=>t(null),e=>t(e)),n}update(t,n){if(Od("Reference.update",1,2,arguments.length),Array.isArray(t)){const r={};for(let e=0;e<t.length;++e)r[""+e]=t[e];t=r,fS("Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}RE("Reference.update",this._delegate._path),Ld("Reference.update","onComplete",n,!0);const e=Dk(this._delegate,t);return n&&e.then(()=>n(null),e=>n(e)),e}setWithPriority(e,t,n){Od("Reference.setWithPriority",2,3,arguments.length),Ld("Reference.setWithPriority","onComplete",n,!0);const r=function(e,t,n){if(RE("setWithPriority",e._path),kE("setWithPriority",t,e._path,!1),CE("setWithPriority",n,!1),".length"===e.key||".keys"===e.key)throw"setWithPriority failed: "+e.key+" is a read-only object.";const r=new rd;return nk(e._repo,e._path,t,n,r.wrapCallback(()=>{})),r.promise}(this._delegate,e,t);return n&&r.then(()=>n(null),e=>n(e)),r}remove(t){Od("Reference.remove",0,1,arguments.length),Ld("Reference.remove","onComplete",t,!0);const e=(n=this._delegate,RE("remove",n._path),xk(n,null));var n;return t&&e.then(()=>t(null),e=>t(e)),e}transaction(e,t,n){Od("Reference.transaction",1,3,arguments.length),Ld("Reference.transaction","transactionUpdate",e,!1),Ld("Reference.transaction","onComplete",t,!0),function(e,t,n,r){if((!r||void 0!==n)&&"boolean"!=typeof n)throw new Error(Md(e,t)+"must be a boolean.")}("Reference.transaction","applyLocally",n,!0);const r=pS(this._delegate,e,{applyLocally:n}).then(e=>new vS(e.committed,new yS(this.database,e.snapshot)));return t&&r.then(e=>t(null,e.committed,e.snapshot),e=>t(e,!1,null)),r}setPriority(e,t){Od("Reference.setPriority",1,2,arguments.length),Ld("Reference.setPriority","onComplete",t,!0);const n=function(e,t){e=$d(e),RE("setPriority",e._path),CE("setPriority",t,!1);const n=new rd;return nk(e._repo,dI(e._path,".priority"),t,null,n.wrapCallback(()=>{})),n.promise}(this._delegate,e);return t&&n.then(()=>t(null),e=>t(e)),n}push(e,t){Od("Reference.push",0,2,arguments.length),Ld("Reference.push","onComplete",t,!0);const n=function(e,t){e=$d(e),RE("push",e._path),kE("push",t,e._path,!0);var n=YE(e._repo),n=aT(n);const r=Pk(e,n),i=Pk(e,n);let s;return s=null!=t?xk(i,t).then(()=>i):Promise.resolve(i),r.then=s.then.bind(s),r.catch=s.then.bind(s,void 0),r}(this._delegate,e),r=n.then(e=>new wS(this.database,e));t&&r.then(()=>t(null),e=>t(e));const i=new wS(this.database,n);return i.then=r.then.bind(r),i.catch=r.catch.bind(r,void 0),i}onDisconnect(){return RE("Reference.onDisconnect",this._delegate._path),new mS(new Ik(this._delegate._repo,this._delegate._path))}get key(){return this.getKey()}get parent(){return this.getParent()}get root(){return this.getRoot()}}class bS{constructor(e,t){this._delegate=e,this.app=t,this.INTERNAL={delete:()=>this._delegate._delete()}}useEmulator(e,t,n={}){cS(this._delegate,e,t,n)}ref(e){if(Od("database.ref",0,1,arguments.length),e instanceof wS){var t=Rk(this._delegate,e.toString());return new wS(this,t)}t=Nk(this._delegate,e);return new wS(this,t)}refFromURL(e){Od("database.refFromURL",1,1,arguments.length);var t=Rk(this._delegate,e);return new wS(this,t)}goOffline(){var e;Od("database.goOffline",0,0,arguments.length),(e=$d(e=this._delegate))._checkNotDeleted("goOffline"),ok(e._repo)}goOnline(){return Od("database.goOnline",0,0,arguments.length),lS(this._delegate)}}bS.ServerValue={TIMESTAMP:hS,increment:e=>({".sv":{increment:e}})};var IS,TS=Object.freeze({__proto__:null,initStandalone:function({app:e,url:t,version:n,customAuthImpl:r,namespace:i,nodeAdmin:s=!1}){Yw(n);const o=new Hd("auth-internal",new Gd("database-standalone"));return o.setComponent(new Kd("auth-internal",()=>r,"PRIVATE")),{instance:new bS(oS(e,o,void 0,t,s),e),namespace:i}}});const ES=bS.ServerValue;(IS=Cp).INTERNAL.registerComponent(new Kd("database-compat",(e,{instanceIdentifier:t})=>{var n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("database").getImmediate({identifier:t});return new bS(r,n)},"PUBLIC").setServiceProps({Reference:wS,Query:_S,Database:bS,DataSnapshot:yS,enableLogging:uS,INTERNAL:TS,ServerValue:ES}).setMultipleInstances(!0)),IS.registerVersion("@firebase/database-compat","0.1.5");var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},kS={},SS=l||self;function CS(){}function AS(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 NS(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}var RS="closure_uid_"+(1e9*Math.random()>>>0),PS=0;function xS(e,t,n){return e.call.apply(e.bind,arguments)}function DS(t,n,e){if(!t)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var e=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(e,r),t.apply(n,e)}}return function(){return t.apply(n,arguments)}}function OS(e,t,n){return(OS=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?xS:DS).apply(null,arguments)}function MS(t){var n=Array.prototype.slice.call(arguments,1);return function(){var e=n.slice();return e.push.apply(e,arguments),t.apply(this,e)}}function LS(e,s){function t(){}t.prototype=s.prototype,e.Z=s.prototype,e.prototype=new t,(e.prototype.constructor=e).Vb=function(e,t,n){for(var r=Array(arguments.length-2),i=2;i<arguments.length;i++)r[i-2]=arguments[i];return s.prototype[t].apply(e,r)}}function FS(){this.s=this.s,this.o=this.o}var US={};FS.prototype.s=!1,FS.prototype.na=function(){var e,t;!this.s&&(this.s=!0,this.M(),0)&&(t=this,e=Object.prototype.hasOwnProperty.call(t,RS)&&t[RS]||(t[RS]=++PS),delete US[e])},FS.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};const jS=Array.prototype.indexOf?function(e,t){return Array.prototype.indexOf.call(e,t,void 0)}:function(e,t){if("string"==typeof e)return"string"!=typeof t||1!=t.length?-1:e.indexOf(t,0);for(let n=0;n<e.length;n++)if(n in e&&e[n]===t)return n;return-1},qS=Array.prototype.forEach?function(e,t,n){Array.prototype.forEach.call(e,t,n)}:function(e,t,n){var r=e.length,i="string"==typeof e?e.split(""):e;for(let s=0;s<r;s++)s in i&&t.call(n,i[s],s,e)};function VS(){return Array.prototype.concat.apply([],arguments)}function BS(t){var n=t.length;if(0<n){const r=Array(n);for(let e=0;e<n;e++)r[e]=t[e];return r}return[]}function WS(e){return/^[\s\xa0]*$/.test(e)}var $S,KS=String.prototype.trim?function(e){return e.trim()}:function(e){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(e)[1]};function zS(e,t){return-1!=e.indexOf(t)}function HS(e,t){return e<t?-1:t<e?1:0}e:{var GS=SS.navigator;if(GS){GS=GS.userAgent;if(GS){$S=GS;break e}}$S=""}function QS(e,t,n){for(const r in e)t.call(n,e[r],r,e)}function YS(e){const t={};for(const n in e)t[n]=e[n];return t}var JS="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function XS(t){let n,r;for(let i=1;i<arguments.length;i++){for(n in r=arguments[i])t[n]=r[n];for(let e=0;e<JS.length;e++)n=JS[e],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function ZS(e){return ZS[" "](e),e}ZS[" "]=CS;var eC,tC=zS($S,"Opera"),nC=zS($S,"Trident")||zS($S,"MSIE"),rC=zS($S,"Edge"),iC=rC||nC,sC=zS($S,"Gecko")&&!(zS($S.toLowerCase(),"webkit")&&!zS($S,"Edge"))&&!(zS($S,"Trident")||zS($S,"MSIE"))&&!zS($S,"Edge"),oC=zS($S.toLowerCase(),"webkit")&&!zS($S,"Edge");function aC(){var e=SS.document;return e?e.documentMode:void 0}e:{var cC="",lC=(lC=$S,sC?/rv:([^\);]+)(\)|;)/.exec(lC):rC?/Edge\/([\d\.]+)/.exec(lC):nC?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(lC):oC?/WebKit\/(\S+)/.exec(lC):tC?/(?:Version)[ \/]?(\S+)/.exec(lC):void 0);if(lC&&(cC=lC?lC[1]:""),nC){lC=aC();if(null!=lC&&lC>parseFloat(cC)){eC=String(lC);break e}}eC=cC}var uC={};function hC(){return e=function(){let e=0;var t=KS(String(eC)).split("."),n=KS("9").split("."),r=Math.max(t.length,n.length);for(let o=0;0==e&&o<r;o++)for(var i=t[o]||"",s=n[o]||"";i=/(\d*)(\D*)(.*)/.exec(i)||["","","",""],s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],(0!=i[0].length||0!=s[0].length)&&(e=HS(0==i[1].length?0:parseInt(i[1],10),0==s[1].length?0:parseInt(s[1],10))||HS(0==i[2].length,0==s[2].length)||HS(i[2],s[2]),i=i[3],s=s[3],0==e););return 0<=e},t=uC,Object.prototype.hasOwnProperty.call(t,9)?t[9]:t[9]=e(9);var e,t}var dC=SS.document&&nC&&(aC()||parseInt(eC,10))||void 0,pC=function(){if(!SS.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{SS.addEventListener("test",CS,t),SS.removeEventListener("test",CS,t)}catch(e){}return e}();function fC(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}function gC(e,t){if(fC.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(sC){e:{try{ZS(t.nodeName);var i=!0;break e}catch(e){}i=!1}i||(t=null)}}else"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:mC[e.pointerType]||"",this.state=e.state,(this.i=e).defaultPrevented&&gC.Z.h.call(this)}}fC.prototype.h=function(){this.defaultPrevented=!0},LS(gC,fC);var mC={2:"touch",3:"pen",4:"mouse"};gC.prototype.h=function(){gC.Z.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var vC="closure_listenable_"+(1e6*Math.random()|0),yC=0;function _C(e,t,n,r,i){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ia=i,this.key=++yC,this.ca=this.fa=!1}function wC(e){e.ca=!0,e.listener=null,e.proxy=null,e.src=null,e.ia=null}function bC(e){this.src=e,this.g={},this.h=0}function IC(e,t){var n,r,i,s=t.type;s in e.g&&(n=e.g[s],(i=0<=(r=jS(n,t)))&&Array.prototype.splice.call(n,r,1),i&&(wC(t),0==e.g[s].length&&(delete e.g[s],e.h--)))}function TC(e,t,n,r){for(var i=0;i<e.length;++i){var s=e[i];if(!s.ca&&s.listener==t&&s.capture==!!n&&s.ia==r)return i}return-1}bC.prototype.add=function(e,t,n,r,i){var s=e.toString();(e=this.g[s])||(e=this.g[s]=[],this.h++);var o=TC(e,t,r,i);return-1<o?(t=e[o],n||(t.fa=!1)):((t=new _C(t,this.src,s,!!r,i)).fa=n,e.push(t)),t};var EC="closure_lm_"+(1e6*Math.random()|0),kC={};function SC(e,t,n,r,i){if(r&&r.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}r=DC(r);return t&&t[vC]?t.O(n,r,NS(i)?!!i.capture:!!i,s):CC(t,n,r,!0,i,s)}(e,t,n,r,i);if(Array.isArray(t)){for(var s=0;s<t.length;s++)SC(e,t[s],n,r,i);return null}return n=DC(n),e&&e[vC]?e.N(t,n,NS(r)?!!r.capture:!!r,i):CC(e,t,n,!1,r,i)}function CC(e,t,n,r,i,s){if(!t)throw Error("Invalid event type");var o,a=NS(i)?!!i.capture:!!i,c=PC(e);if(c||(e[EC]=c=new bC(e)),(n=c.add(t,n,r,a,s)).proxy)return n;if(o=RC,r=function e(t){return o.call(e.src,e.listener,t)},(n.proxy=r).src=e,r.listener=n,e.addEventListener)void 0===(i=!pC?a:i)&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(NC(t.toString()),r);else{if(!e.addListener||!e.removeListener)throw Error("addEventListener and attachEvent are unavailable.");e.addListener(r)}return n}function AC(e){var t,n,r;"number"!=typeof e&&e&&!e.ca&&((t=e.src)&&t[vC]?IC(t.i,e):(n=e.type,r=e.proxy,t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(NC(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=PC(t))?(IC(n,e),0==n.h&&(n.src=null,t[EC]=null)):wC(e)))}function NC(e){return e in kC?kC[e]:kC[e]="on"+e}function RC(e,t){var n,r;return e=!!e.ca||(t=new gC(t,this),n=e.listener,r=e.ia||e.src,e.fa&&AC(e),n.call(r,t))}function PC(e){return(e=e[EC])instanceof bC?e:null}var xC="__closure_events_fn_"+(1e9*Math.random()>>>0);function DC(t){return"function"==typeof t?t:(t[xC]||(t[xC]=function(e){return t.handleEvent(e)}),t[xC])}function OC(){FS.call(this),this.i=new bC(this),(this.P=this).I=null}function MC(e,t){var n,r=e.I;if(r)for(n=[];r;r=r.I)n.push(r);if(e=e.P,r=t.type||t,"string"==typeof t?t=new fC(t,e):t instanceof fC?t.target=t.target||e:(o=t,XS(t=new fC(r,e),o)),o=!0,n)for(var i=n.length-1;0<=i;i--)var s=t.g=n[i],o=LC(s,r,!0,t)&&o;if(o=LC(s=t.g=e,r,!0,t)&&o,o=LC(s,r,!1,t)&&o,n)for(i=0;i<n.length;i++)o=LC(s=t.g=n[i],r,!1,t)&&o}function LC(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,a,c=t[s];c&&!c.ca&&c.capture==n&&(o=c.listener,a=c.ia||c.src,c.fa&&IC(e.i,c),i=!1!==o.call(a,r)&&i)}return i&&!r.defaultPrevented}LS(OC,FS),OC.prototype[vC]=!0,OC.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=NS(i)?!!i.capture:!!i,r=DC(r),t&&t[vC]?(t=t.i,(n=String(n).toString())in t.g&&-1<(r=TC(o=t.g[n],r,i,s))&&(wC(o[r]),Array.prototype.splice.call(o,r,1),0==o.length&&(delete t.g[n],t.h--))):(t=t&&PC(t))&&(n=t.g[n.toString()],(r=(t=-1)<(t=n?TC(n,r,i,s):t)?n[t]:null)&&AC(r))}(this,e,t,n,r)},OC.prototype.M=function(){if(OC.Z.M.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++)wC(n[r]);delete t.g[e],t.h--}}this.I=null},OC.prototype.N=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},OC.prototype.O=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};var FC=SS.JSON.stringify;var UC,jC=new class{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}}(()=>new qC,e=>e.reset());class qC{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}}function VC(e,t){var n;UC||(n=SS.Promise.resolve(void 0),UC=function(){n.then($C)}),BC||(UC(),BC=!0),WC.add(e,t)}var BC=!1,WC=new class{constructor(){this.h=this.g=null}add(e,t){const n=jC.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}};function $C(){for(var e;e=function(){var e=WC;let t=null;return e.g&&(t=e.g,e.g=e.g.next,e.g||(e.h=null),t.next=null),t}();){try{e.h.call(e.g)}catch(e){!function(e){SS.setTimeout(()=>{throw e},0)}(e)}var t=jC;t.j(e),t.h<100&&(t.h++,e.next=t.g,t.g=e)}BC=!1}function KC(e,t){OC.call(this),this.h=e||1,this.g=t||SS,this.j=OS(this.kb,this),this.l=Date.now()}function zC(e){e.da=!1,e.S&&(e.g.clearTimeout(e.S),e.S=null)}function HC(e,t,n){if("function"==typeof e)n&&(e=OS(e,n));else{if(!e||"function"!=typeof e.handleEvent)throw Error("Invalid listener argument");e=OS(e.handleEvent,e)}return 2147483647<Number(t)?-1:SS.setTimeout(e,t||0)}LS(KC,OC),(ze=KC.prototype).da=!1,ze.S=null,ze.kb=function(){var e;this.da&&(0<(e=Date.now()-this.l)&&e<.8*this.h?this.S=this.g.setTimeout(this.j,this.h-e):(this.S&&(this.g.clearTimeout(this.S),this.S=null),MC(this,"tick"),this.da&&(zC(this),this.start())))},ze.start=function(){this.da=!0,this.S||(this.S=this.g.setTimeout(this.j,this.h),this.l=Date.now())},ze.M=function(){KC.Z.M.call(this),zC(this),delete this.g};class GC extends FS{constructor(e,t){super(),this.m=e,this.j=t,this.h=null,this.i=!1,this.g=null}l(e){this.h=arguments,this.g?this.i=!0:function e(t){t.g=HC(()=>{t.g=null,t.i&&(t.i=!1,e(t))},t.j);var n=t.h;t.h=null,t.m.apply(null,n)}(this)}M(){super.M(),this.g&&(SS.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function QC(e){FS.call(this),this.h=e,this.g={}}LS(QC,FS);var YC=[];function JC(e,t,n,r){Array.isArray(n)||(n&&(YC[0]=n.toString()),n=YC);for(var i=0;i<n.length;i++){var s=SC(t,n[i],r||e.handleEvent,!1,e.h||e);if(!s)break;e.g[s.key]=s}}function XC(e){QS(e.g,function(e,t){this.g.hasOwnProperty(t)&&AC(e)},e),e.g={}}function ZC(){this.g=!0}function eA(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(!(r.length<2)){var i=r[1];if(Array.isArray(i)&&!(i.length<1)){var s=i[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var o=1;o<i.length;o++)i[o]=""}}}return FC(n)}catch(e){return t}}(e,n)+(r?" "+r:"")})}QC.prototype.M=function(){QC.Z.M.call(this),XC(this)},QC.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},ZC.prototype.Aa=function(){this.g=!1},ZC.prototype.info=function(){};var tA={},nA=null;function rA(){return nA=nA||new OC}function iA(e){fC.call(this,tA.Ma,e)}function sA(){var e=rA();MC(e,new iA(e))}function oA(e,t){fC.call(this,tA.STAT_EVENT,e),this.stat=t}function aA(e){var t=rA();MC(t,new oA(t,e))}function cA(e,t){fC.call(this,tA.Na,e),this.size=t}function lA(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return SS.setTimeout(function(){e()},t)}tA.Ma="serverreachability",LS(iA,fC),tA.STAT_EVENT="statevent",LS(oA,fC),tA.Na="timingevent",LS(cA,fC);c={NO_ERROR:0,lb:1,yb:2,xb:3,sb:4,wb:5,zb:6,Ja:7,TIMEOUT:8,Cb:9},yt={qb:"complete",Mb:"success",Ka:"error",Ja:"abort",Eb:"ready",Fb:"readystatechange",TIMEOUT:"timeout",Ab:"incrementaldata",Db:"progress",tb:"downloadprogress",Ub:"uploadprogress"};function uA(){}function hA(e){return e.h||(e.h=e.i())}function dA(){}uA.prototype.h=null;l={OPEN:"a",pb:"b",Ka:"c",Bb:"d"};function pA(){fC.call(this,"d")}function fA(){fC.call(this,"c")}function gA(){}function mA(e,t,n,r){this.l=e,this.j=t,this.m=n,this.X=r||1,this.V=new QC(this),this.P=_A,this.W=new KC(e=iC?125:void 0),this.H=null,this.i=!1,this.s=this.A=this.v=this.K=this.F=this.Y=this.B=null,this.D=[],this.g=null,this.C=0,this.o=this.u=null,this.N=-1,this.I=!1,this.O=0,this.L=null,this.aa=this.J=this.$=this.U=!1,this.h=new vA}function vA(){this.i=null,this.g="",this.h=!1}LS(pA,fC),LS(fA,fC),LS(gA,uA),gA.prototype.g=function(){return new XMLHttpRequest},gA.prototype.i=function(){return{}};var yA=new gA,_A=45e3,wA={},bA={};function IA(e,t,n){e.K=1,e.v=$A(UA(t)),e.s=n,e.U=!0,TA(e,null)}function TA(e,t){e.F=Date.now(),SA(e),e.A=UA(e.v);var o,a,c,l,u,h,n=e.A,r=e.X;Array.isArray(r)||(r=[String(r)]),rN(n.h,"t",r),e.C=0,n=e.l.H,e.h=new vA,e.g=rR(e.l,n?t:null,!e.s),0<e.O&&(e.L=new GC(OS(e.Ia,e,e.g),e.O)),JC(e.V,e.g,"readystatechange",e.gb),t=e.H?YS(e.H):{},e.s?(e.u||(e.u="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.ea(e.A,e.u,e.s,t)):(e.u="GET",e.g.ea(e.A,e.u,null,t)),sA(),o=e.j,a=e.u,c=e.A,l=e.m,u=e.X,h=e.s,o.info(function(){if(o.g)if(h)for(var e="",t=h.split("&"),n=0;n<t.length;n++){var r,i,s=t[n].split("=");1<s.length&&(r=s[0],s=s[1],e=2<=(i=r.split("_")).length&&"type"==i[1]?e+(r+"=")+s+"&":e+(r+"=redacted&"))}else e=null;else e=h;return"XMLHTTP REQ ("+l+") [attempt "+u+"]: "+a+"\n"+c+"\n"+e})}function EA(e){return e.g&&("GET"==e.u&&2!=e.K&&e.l.Ba)}function kA(e,t,n){let r=!0,i;for(;!e.I&&e.C<n.length;){if(i=(o=n,c=a=void 0,a=(s=e).C,-1==(c=o.indexOf("\n",a))?bA:(a=Number(o.substring(a,c)),isNaN(a)?wA:(c+=1)+a>o.length?bA:(o=o.substr(c,a),s.C=c+a,o))),i==bA){4==t&&(e.o=4,aA(14),r=!1),eA(e.j,e.m,null,"[Incomplete Response]");break}if(i==wA){e.o=4,aA(15),eA(e.j,e.m,n,"[Invalid Chunk]"),r=!1;break}eA(e.j,e.m,i,null),PA(e,i)}var s,o,a,c;EA(e)&&i!=bA&&i!=wA&&(e.h.g="",e.C=0),4!=t||0!=n.length||e.h.h||(e.o=1,aA(16),r=!1),e.i=e.i&&r,r?0<n.length&&!e.aa&&(e.aa=!0,(t=e.l).g==e&&t.$&&!t.L&&(t.h.info("Great, no buffering proxy detected. Bytes received: "+n.length),QN(t),t.L=!0,aA(11))):(eA(e.j,e.m,n,"[Invalid Chunked Response]"),RA(e),NA(e))}function SA(e){e.Y=Date.now()+e.P,CA(e,e.P)}function CA(e,t){if(null!=e.B)throw Error("WatchDog timer not null");e.B=lA(OS(e.eb,e),t)}function AA(e){e.B&&(SS.clearTimeout(e.B),e.B=null)}function NA(e){0==e.l.G||e.I||XN(e.l,e)}function RA(e){AA(e);var t=e.L;t&&"function"==typeof t.na&&t.na(),e.L=null,zC(e.W),XC(e.V),e.g&&(t=e.g,e.g=null,t.abort(),t.na())}function PA(e,t){try{var n=e.l;if(0!=n.G&&(n.g==e||uN(n.i,e)))if(n.I=e.N,!e.J&&uN(n.i,e)&&3==n.G){try{var r=n.Ca.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))break e;JN(n),qN(n)}GN(n),aA(18)}}else n.ta=i[1],0<n.ta-n.U&&i[2]<37500&&n.N&&0==n.A&&!n.v&&(n.v=lA(OS(n.ab,n),6e3));if(lN(n.i)<=1&&n.ka){try{n.ka()}catch(e){}n.ka=void 0}}else eR(n,11)}else if(!e.J&&n.g!=e||JN(n),!WS(t))for(i=n.Ca.g.parse(t),t=0;t<i.length;t++){var s=i[t];if(n.U=s[0],s=s[1],2==n.G)if("c"==s[0]){n.J=s[1],n.la=s[2];var o=s[3];null!=o&&(n.ma=o,n.h.info("VER="+n.ma));var a=s[4];null!=a&&(n.za=a,n.h.info("SVER="+n.za));var c,l,u,h=s[5];null!=h&&"number"==typeof h&&0<h&&(r=1.5*h,n.K=r,n.h.info("backChannelRequestTimeoutMs_="+r)),r=n;const g=e.g;g&&(!(c=g.g?g.g.getResponseHeader("X-Client-Wire-Protocol"):null)||!(l=r.i).g&&(zS(c,"spdy")||zS(c,"quic")||zS(c,"h2"))&&(l.j=l.l,l.g=new Set,l.h&&(hN(l,l.h),l.h=null)),!r.D||(u=g.g?g.g.getResponseHeader("X-HTTP-Session-Id"):null)&&(r.sa=u,WA(r.F,r.D,u))),n.G=3,n.j&&n.j.xa(),n.$&&(n.O=Date.now()-e.F,n.h.info("Handshake RTT: "+n.O+"ms"));var d,p,f=e;(r=n).oa=nR(r,r.H?r.la:null,r.W),f.J?(dN(r.i,f),d=f,(p=r.K)&&d.setTimeout(p),d.B&&(AA(d),SA(d)),r.g=f):HN(r),0<n.l.length&&WN(n)}else"stop"!=s[0]&&"close"!=s[0]||eR(n,7);else 3==n.G&&("stop"==s[0]||"close"==s[0]?"stop"==s[0]?eR(n,7):jN(n):"noop"!=s[0]&&n.j&&n.j.wa(s),n.A=0)}sA()}catch(e){}}function xA(e,t){if(e.forEach&&"function"==typeof e.forEach)e.forEach(t,void 0);else if(AS(e)||"string"==typeof e)qS(e,t,void 0);else{if(e.T&&"function"==typeof e.T)var n=e.T();else if(e.R&&"function"==typeof e.R)n=void 0;else if(AS(e)||"string"==typeof e)for(var n=[],r=e.length,i=0;i<r;i++)n.push(i);else for(i in n=[],r=0,e)n[r++]=i;for(var i=(r=function(e){if(e.R&&"function"==typeof e.R)return e.R();if("string"==typeof e)return e.split("");if(AS(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)).length,s=0;s<i;s++)t.call(void 0,r[s],n&&n[s],e)}}function DA(e,t){this.h={},this.g=[],this.i=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var r=0;r<n;r+=2)this.set(arguments[r],arguments[r+1])}else if(e)if(e instanceof DA)for(n=e.T(),r=0;r<n.length;r++)this.set(n[r],e.get(n[r]));else for(r in e)this.set(r,e[r])}function OA(e){if(e.i!=e.g.length){for(var t=0,n=0;t<e.g.length;){var r=e.g[t];MA(e.h,r)&&(e.g[n++]=r),t++}e.g.length=n}if(e.i!=e.g.length){for(var i={},n=t=0;t<e.g.length;)MA(i,r=e.g[t])||(i[e.g[n++]=r]=1),t++;e.g.length=n}}function MA(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(ze=mA.prototype).setTimeout=function(e){this.P=e},ze.gb=function(e){e=e.target;const t=this.L;t&&3==ON(e)?t.l():this.Ia(e)},ze.Ia=function(e){try{if(e==this.g)e:{var t=ON(this.g),n=this.g.Da();this.g.ba();if(!(t<3)&&(3!=t||iC||this.g&&(this.h.h||this.g.ga()||MN(this.g)))){this.I||4!=t||7==n||sA(),AA(this);var r=this.g.ba();this.N=r;t:if(EA(this)){var i=MN(this.g);e="";var s=i.length,o=4==ON(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){RA(this),NA(this);var a="";break t}this.h.i=new SS.TextDecoder}for(n=0;n<s;n++)this.h.h=!0,e+=this.h.i.decode(i[n],{stream:o&&n==s-1});i.splice(0,s),this.h.g+=e,this.C=0,a=this.h.g}else a=this.g.ga();if(this.i=200==r,h=this.j,d=this.u,p=this.A,f=this.m,g=this.X,m=t,v=r,h.info(function(){return"XMLHTTP RESP ("+f+") [ attempt "+g+"]: "+d+"\n"+p+"\n"+m+" "+v}),this.i){if(this.$&&!this.J){t:{if(this.g){var c,l=this.g;if((c=l.g?l.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!WS(c)){var u=c;break t}}u=null}if(!(r=u)){this.i=!1,this.o=3,aA(12),RA(this),NA(this);break e}eA(this.j,this.m,r,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,PA(this,r)}this.U?(kA(this,t,a),iC&&this.i&&3==t&&(JC(this.V,this.W,"tick",this.fb),this.W.start())):(eA(this.j,this.m,a,null),PA(this,a)),4==t&&RA(this),this.i&&!this.I&&(4==t?XN(this.l,this):(this.i=!1,SA(this)))}else 400==r&&0<a.indexOf("Unknown SID")?(this.o=3,aA(12)):(this.o=0,aA(13)),RA(this),NA(this)}}}catch(e){}var h,d,p,f,g,m,v},ze.fb=function(){var e,t;this.g&&(e=ON(this.g),t=this.g.ga(),this.C<t.length&&(AA(this),kA(this,e,t),this.i&&4!=e&&SA(this)))},ze.cancel=function(){this.I=!0,RA(this)},ze.eb=function(){this.B=null;var e,t,n=Date.now();0<=n-this.Y?(e=this.j,t=this.A,e.info(function(){return"TIMEOUT: "+t}),2!=this.K&&(sA(),aA(17)),RA(this),this.o=2,NA(this)):CA(this,this.Y-n)},(ze=DA.prototype).R=function(){OA(this);for(var e=[],t=0;t<this.g.length;t++)e.push(this.h[this.g[t]]);return e},ze.T=function(){return OA(this),this.g.concat()},ze.get=function(e,t){return MA(this.h,e)?this.h[e]:t},ze.set=function(e,t){MA(this.h,e)||(this.i++,this.g.push(e)),this.h[e]=t},ze.forEach=function(e,t){for(var n=this.T(),r=0;r<n.length;r++){var i=n[r],s=this.get(i);e.call(t,s,i,this)}};var LA=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function FA(e,t){var n;this.i=this.s=this.j="",this.m=null,this.o=this.l="",this.g=!1,e instanceof FA?(this.g=void 0!==t?t:e.g,jA(this,e.j),this.s=e.s,qA(this,e.i),VA(this,e.m),this.l=e.l,t=e.h,(n=new ZA).i=t.i,t.g&&(n.g=new DA(t.g),n.h=t.h),BA(this,n),this.o=e.o):e&&(n=String(e).match(LA))?(this.g=!!t,jA(this,n[1]||"",!0),this.s=KA(n[2]||""),qA(this,n[3]||"",!0),VA(this,n[4]),this.l=KA(n[5]||"",!0),BA(this,n[6]||"",!0),this.o=KA(n[7]||"")):(this.g=!!t,this.h=new ZA(null,this.g))}function UA(e){return new FA(e)}function jA(e,t,n){e.j=n?KA(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function qA(e,t,n){e.i=n?KA(t,!0):t}function VA(e,t){if(t){if(t=Number(t),isNaN(t)||t<0)throw Error("Bad port number "+t);e.m=t}else e.m=null}function BA(e,t,n){var r,i;t instanceof ZA?(e.h=t,r=e.h,(i=e.g)&&!r.j&&(eN(r),r.i=null,r.g.forEach(function(e,t){var n=t.toLowerCase();t!=n&&(tN(this,t),rN(this,n,e))},r)),r.j=i):(n||(t=zA(t,JA)),e.h=new ZA(t,e.g))}function WA(e,t,n){e.h.set(t,n)}function $A(e){return WA(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),e}function KA(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function zA(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,HA),e=n?e.replace(/%25([0-9a-fA-F]{2})/g,"%$1"):e):null}function HA(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}FA.prototype.toString=function(){var e=[],t=this.j;t&&e.push(zA(t,GA,!0),":");var n=this.i;return!n&&"file"!=t||(e.push("//"),(t=this.s)&&e.push(zA(t,GA,!0),"@"),e.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.m)&&e.push(":",String(n))),(n=this.l)&&(this.i&&"/"!=n.charAt(0)&&e.push("/"),e.push(zA(n,"/"==n.charAt(0)?YA:QA,!0))),(n=this.h.toString())&&e.push("?",n),(n=this.o)&&e.push("#",zA(n,XA)),e.join("")};var GA=/[#\/\?@]/g,QA=/[#\?:]/g,YA=/[#\?]/g,JA=/[#\?@]/g,XA=/#/g;function ZA(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function eN(n){n.g||(n.g=new DA,n.h=0,n.i&&function(e,t){if(e){e=e.split("&");for(var n=0;n<e.length;n++){var r,i=e[n].indexOf("="),s=null;0<=i?(r=e[n].substring(0,i),s=e[n].substring(i+1)):r=e[n],t(r,s?decodeURIComponent(s.replace(/\+/g," ")):"")}}}(n.i,function(e,t){n.add(decodeURIComponent(e.replace(/\+/g," ")),t)}))}function tN(e,t){eN(e),t=iN(e,t),MA(e.g.h,t)&&(e.i=null,e.h-=e.g.get(t).length,MA((e=e.g).h,t)&&(delete e.h[t],e.i--,e.g.length>2*e.i&&OA(e)))}function nN(e,t){return eN(e),t=iN(e,t),MA(e.g.h,t)}function rN(e,t,n){tN(e,t),0<n.length&&(e.i=null,e.g.set(iN(e,t),BS(n)),e.h+=n.length)}function iN(e,t){return t=String(t),t=e.j?t.toLowerCase():t}(ze=ZA.prototype).add=function(e,t){eN(this),this.i=null,e=iN(this,e);var n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this},ze.forEach=function(n,r){eN(this),this.g.forEach(function(e,t){qS(e,function(e){n.call(r,e,t,this)},this)},this)},ze.T=function(){eN(this);for(var e=this.g.R(),t=this.g.T(),n=[],r=0;r<t.length;r++)for(var i=e[r],s=0;s<i.length;s++)n.push(t[r]);return n},ze.R=function(e){eN(this);var t=[];if("string"==typeof e)nN(this,e)&&(t=VS(t,this.g.get(iN(this,e))));else{e=this.g.R();for(var n=0;n<e.length;n++)t=VS(t,e[n])}return t},ze.set=function(e,t){return eN(this),this.i=null,nN(this,e=iN(this,e))&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},ze.get=function(e,t){return e&&0<(e=this.R(e)).length?String(e[0]):t},ze.toString=function(){if(this.i)return this.i;if(!this.g)return"";for(var e=[],t=this.g.T(),n=0;n<t.length;n++)for(var r=t[n],i=encodeURIComponent(String(r)),r=this.R(r),s=0;s<r.length;s++){var o=i;""!==r[s]&&(o+="="+encodeURIComponent(String(r[s]))),e.push(o)}return this.i=e.join("&")};var sN=class{constructor(e,t){this.h=e,this.g=t}};function oN(e){this.l=e||10,e=SS.PerformanceNavigationTiming?0<(e=SS.performance.getEntriesByType("navigation")).length&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):!!(SS.g&&SS.g.Ea&&SS.g.Ea()&&SS.g.Ea().Zb),this.j=e?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}var aN;function cN(e){return e.h||e.g&&e.g.size>=e.j}function lN(e){return e.h?1:e.g?e.g.size:0}function uN(e,t){return e.h?e.h==t:e.g&&e.g.has(t)}function hN(e,t){e.g?e.g.add(t):e.h=t}function dN(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function pN(t){if(null!=t.h)return t.i.concat(t.h.D);if(null==t.g||0===t.g.size)return BS(t.i);{let e=t.i;for(const n of t.g.values())e=e.concat(n.D);return e}}function fN(){}function gN(){this.g=new fN}function mN(e,t,n,r,i){try{t.onload=null,t.onerror=null,t.onabort=null,t.ontimeout=null,i(r)}catch(e){}}function vN(e){this.l=e.$b||null,this.j=e.ib||!1}function yN(e,t){OC.call(this),this.D=e,this.u=t,this.m=void 0,this.readyState=_N,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.v=new Headers,this.h=null,this.C="GET",this.B="",this.g=!1,this.A=this.j=this.l=null}oN.prototype.cancel=function(){if(this.i=pN(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(const e of this.g.values())e.cancel();this.g.clear()}},fN.prototype.stringify=function(e){return SS.JSON.stringify(e,void 0)},fN.prototype.parse=function(e){return SS.JSON.parse(e,void 0)},LS(vN,uA),vN.prototype.g=function(){return new yN(this.l,this.j)},vN.prototype.i=(aN={},function(){return aN}),LS(yN,OC);var _N=0;function wN(e){e.j.read().then(e.Sa.bind(e)).catch(e.ha.bind(e))}function bN(e){e.readyState=4,e.l=null,e.j=null,e.A=null,IN(e)}function IN(e){e.onreadystatechange&&e.onreadystatechange.call(e)}(ze=yN.prototype).open=function(e,t){if(this.readyState!=_N)throw this.abort(),Error("Error reopening a connection");this.C=e,this.B=t,this.readyState=1,IN(this)},ze.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;const t={headers:this.v,method:this.C,credentials:this.m,cache:void 0};e&&(t.body=e),(this.D||SS).fetch(new Request(this.B,t)).then(this.Va.bind(this),this.ha.bind(this))},ze.abort=function(){this.response=this.responseText="",this.v=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted."),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,bN(this)),this.readyState=_N},ze.Va=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,IN(this)),this.g&&(this.readyState=3,IN(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Ta.bind(this),this.ha.bind(this));else if(void 0!==SS.ReadableStream&&"body"in e){if(this.j=e.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;wN(this)}else e.text().then(this.Ua.bind(this),this.ha.bind(this))},ze.Sa=function(e){var t;this.g&&(this.u&&e.value?this.response.push(e.value):this.u||(t=e.value||new Uint8Array(0),(t=this.A.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)),(e.done?bN:IN)(this),3==this.readyState&&wN(this))},ze.Ua=function(e){this.g&&(this.response=this.responseText=e,bN(this))},ze.Ta=function(e){this.g&&(this.response=e,bN(this))},ze.ha=function(){this.g&&bN(this)},ze.setRequestHeader=function(e,t){this.v.append(e,t)},ze.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||""},ze.getAllResponseHeaders=function(){if(!this.h)return"";const e=[],t=this.h.entries();for(var n=t.next();!n.done;)n=n.value,e.push(n[0]+": "+n[1]),n=t.next();return e.join("\r\n")},Object.defineProperty(yN.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}});var TN=SS.JSON.parse;function EN(e){OC.call(this),this.headers=new DA,this.u=e||null,this.h=!1,this.C=this.g=null,this.H="",this.m=0,this.j="",this.l=this.F=this.v=this.D=!1,this.B=0,this.A=null,this.J=kN,this.K=this.L=!1}LS(EN,OC);var kN="",SN=/^https?$/i,CN=["POST","PUT"];function AN(e){return"content-type"==e.toLowerCase()}function NN(e,t){e.h=!1,e.g&&(e.l=!0,e.g.abort(),e.l=!1),e.j=t,e.m=5,RN(e),xN(e)}function RN(e){e.D||(e.D=!0,MC(e,"complete"),MC(e,"error"))}function PN(e){if(e.h&&void 0!==kS&&(!e.C[1]||4!=ON(e)||2!=e.ba()))if(e.v&&4==ON(e))HC(e.Fa,0,e);else if(MC(e,"readystatechange"),4==ON(e)){e.h=!1;try{var t,n,r,i,s=e.ba();e:switch(s){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var o=!0;break e;default:o=!1}if((t=o)||((n=0===s)&&(!(i=String(e.H).match(LA)[1]||null)&&SS.self&&SS.self.location&&(i=(r=SS.self.location.protocol).substr(0,r.length-1)),n=!SN.test(i?i.toLowerCase():"")),t=n),t)MC(e,"complete"),MC(e,"success");else{e.m=6;try{var a=2<ON(e)?e.g.statusText:""}catch(e){a=""}e.j=a+" ["+e.ba()+"]",RN(e)}}finally{xN(e)}}}function xN(e,t){if(e.g){DN(e);const n=e.g,r=e.C[0]?CS:null;e.g=null,e.C=null,t||MC(e,"ready");try{n.onreadystatechange=r}catch(e){}}}function DN(e){e.g&&e.K&&(e.g.ontimeout=null),e.A&&(SS.clearTimeout(e.A),e.A=null)}function ON(e){return e.g?e.g.readyState:0}function MN(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.J){case kN:case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}function LN(e,t,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=function(e){let n="";return QS(e,function(e,t){n+=t,n+=":",n+=e,n+="\r\n"}),n}(n),"string"==typeof e?null!=n&&encodeURIComponent(String(n)):WA(e,t,n))}function FN(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function UN(e){this.za=0,this.l=[],this.h=new ZC,this.la=this.oa=this.F=this.W=this.g=this.sa=this.D=this.aa=this.o=this.P=this.s=null,this.Za=this.V=0,this.Xa=FN("failFast",!1,e),this.N=this.v=this.u=this.m=this.j=null,this.X=!0,this.I=this.ta=this.U=-1,this.Y=this.A=this.C=0,this.Pa=FN("baseRetryDelayMs",5e3,e),this.$a=FN("retryDelaySeedMs",1e4,e),this.Ya=FN("forwardChannelMaxRetries",2,e),this.ra=FN("forwardChannelRequestTimeoutMs",2e4,e),this.qa=e&&e.xmlHttpFactory||void 0,this.Ba=e&&e.Yb||!1,this.K=void 0,this.H=e&&e.supportsCrossDomainXhr||!1,this.J="",this.i=new oN(e&&e.concurrentRequestLimit),this.Ca=new gN,this.ja=e&&e.fastHandshake||!1,this.Ra=e&&e.Wb||!1,e&&e.Aa&&this.h.Aa(),e&&e.forceLongPolling&&(this.X=!1),this.$=!this.ja&&this.X&&e&&e.detectBufferingProxy||!1,this.ka=void 0,this.O=0,this.L=!1,this.B=null,this.Wa=!e||!1!==e.Xb}function jN(e){var t,n;VN(e),3==e.G&&(t=e.V++,WA(n=UA(e.F),"SID",e.J),WA(n,"RID",t),WA(n,"TYPE","terminate"),KN(e,n),(t=new mA(e,e.h,t,void 0)).K=2,t.v=$A(UA(n)),n=!1,!(n=SS.navigator&&SS.navigator.sendBeacon?SS.navigator.sendBeacon(t.v.toString(),""):n)&&SS.Image&&((new Image).src=t.v,n=!0),n||(t.g=rR(t.l,null),t.g.ea(t.v)),t.F=Date.now(),SA(t)),tR(e)}function qN(e){e.g&&(QN(e),e.g.cancel(),e.g=null)}function VN(e){qN(e),e.u&&(SS.clearTimeout(e.u),e.u=null),JN(e),e.i.cancel(),e.m&&("number"==typeof e.m&&SS.clearTimeout(e.m),e.m=null)}function BN(e,t){e.l.push(new sN(e.Za++,t)),3==e.G&&WN(e)}function WN(e){cN(e.i)||e.m||(e.m=!0,VC(e.Ha,e),e.C=0)}function $N(e,t){var n=t?t.m:e.V++,r=UA(e.F);WA(r,"SID",e.J),WA(r,"RID",n),WA(r,"AID",e.U),KN(e,r),e.o&&e.s&&LN(r,e.o,e.s),n=new mA(e,e.h,n,e.C+1),null===e.o&&(n.H=e.s),t&&(e.l=t.D.concat(e.l)),t=zN(e,n,1e3),n.setTimeout(Math.round(.5*e.ra)+Math.round(.5*e.ra*Math.random())),hN(e.i,n),IA(n,r,t)}function KN(e,n){e.j&&xA({},function(e,t){WA(n,t,e)})}function zN(e,t,r){r=Math.min(e.l.length,r);var i=e.j?OS(e.j.Oa,e.j,e):null;e:{var s=e.l;let n=-1;for(;;){const c=["count="+r];-1==n?0<r?(n=s[0].h,c.push("ofs="+n)):n=0:c.push("ofs="+n);let e=!0;for(let t=0;t<r;t++){var o=s[t].h,a=s[t].g;if((o-=n)<0)n=Math.max(0,s[t].h-100),e=!1;else try{!function(e,r,t){const i=t||"";try{xA(e,function(e,t){let n=e;NS(e)&&(n=FC(e)),r.push(i+t+"="+encodeURIComponent(n))})}catch(e){throw r.push(i+"type="+encodeURIComponent("_badmap")),e}}(a,c,"req"+o+"_")}catch(e){i&&i(a)}}if(e){i=c.join("&");break e}}}return e=e.l.splice(0,r),t.D=e,i}function HN(e){e.g||e.u||(e.Y=1,VC(e.Ga,e),e.A=0)}function GN(e){return!(e.g||e.u||3<=e.A)&&(e.Y++,e.u=lA(OS(e.Ga,e),ZN(e,e.A)),e.A++,1)}function QN(e){null!=e.B&&(SS.clearTimeout(e.B),e.B=null)}function YN(e){e.g=new mA(e,e.h,"rpc",e.Y),null===e.o&&(e.g.H=e.s),e.g.O=0;var t=UA(e.oa);WA(t,"RID","rpc"),WA(t,"SID",e.J),WA(t,"CI",e.N?"0":"1"),WA(t,"AID",e.U),KN(e,t),WA(t,"TYPE","xmlhttp"),e.o&&e.s&&LN(t,e.o,e.s),e.K&&e.g.setTimeout(e.K);var n=e.g;e=e.la,n.K=1,n.v=$A(UA(t)),n.s=null,n.U=!0,TA(n,e)}function JN(e){null!=e.v&&(SS.clearTimeout(e.v),e.v=null)}function XN(e,t){var n,r,i,s=null;if(e.g==t){JN(e),QN(e),e.g=null;var o=2}else{if(!uN(e.i,t))return;s=t.D,dN(e.i,t),o=1}if(e.I=t.N,0!=e.G)if(t.i)1==o?(s=t.s?t.s.length:0,t=Date.now()-t.F,n=e.C,MC(o=rA(),new cA(o,s)),WN(e)):HN(e);else if(3==(n=t.o)||0==n&&0<e.I||(1!=o||(i=t,lN((r=e).i)>=r.i.j-(r.m?1:0)||(r.m?(r.l=i.D.concat(r.l),0):1==r.G||2==r.G||r.C>=(r.Xa?0:r.Ya)||(r.m=lA(OS(r.Ha,r,i),ZN(r,r.C)),r.C++,0))))&&(2!=o||!GN(e)))switch(s&&0<s.length&&(t=e.i,t.i=t.i.concat(s)),n){case 1:eR(e,5);break;case 4:eR(e,10);break;case 3:eR(e,6);break;default:eR(e,2)}}function ZN(e,t){let n=e.Pa+Math.floor(Math.random()*e.$a);return e.j||(n*=2),n*t}function eR(e,t){var n,r;e.h.info("Error code "+t),2==t?(n=null,e.j&&(n=null),r=OS(e.jb,e),n||(n=new FA("//www.google.com/images/cleardot.gif"),SS.location&&"http"==SS.location.protocol||jA(n,"https"),$A(n)),function(e,t){var n=new ZC;if(SS.Image){const r=new Image;r.onload=MS(mN,n,r,"TestLoadImage: loaded",!0,t),r.onerror=MS(mN,n,r,"TestLoadImage: error",!1,t),r.onabort=MS(mN,n,r,"TestLoadImage: abort",!1,t),r.ontimeout=MS(mN,n,r,"TestLoadImage: timeout",!1,t),SS.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}(n.toString(),r)):aA(2),e.G=0,e.j&&e.j.va(t),tR(e),VN(e)}function tR(e){e.G=0,e.I=-1,e.j&&(0==pN(e.i).length&&0==e.l.length||(e.i.i.length=0,BS(e.l),e.l.length=0),e.j.ua())}function nR(e,t,n){let r=(a=n)instanceof FA?UA(a):new FA(a,void 0);var i,s,o,a,c;return""!=r.i?(t&&qA(r,t+"."+r.i),VA(r,r.m)):(c=SS.location,r=(i=c.protocol,s=t?t+"."+c.hostname:c.hostname,o=+c.port,a=n,c=new FA(null,void 0),i&&jA(c,i),s&&qA(c,s),o&&VA(c,o),a&&(c.l=a),c)),e.aa&&QS(e.aa,function(e,t){WA(r,t,e)}),t=e.D,n=e.sa,t&&n&&WA(r,t,n),WA(r,"VER",e.ma),KN(e,r),r}function rR(e,t,n){if(t&&!e.H)throw Error("Can't create secondary domain capable XhrIo object.");return(t=n&&e.Ba&&!e.qa?new EN(new vN({ib:!0})):new EN(e.qa)).L=e.H,t}function iR(){}function sR(){if(nC&&!(10<=Number(dC)))throw Error("Environmental error: no available transport.")}function oR(e,t){OC.call(this),this.g=new UN(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.s=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.ya&&(e?e["X-WebChannel-Client-Profile"]=t.ya:e={"X-WebChannel-Client-Profile":t.ya}),this.g.P=e,(e=t&&t.httpHeadersOverwriteParam)&&!WS(e)&&(this.g.o=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!WS(t)&&(this.g.D=t,null!==(e=this.h)&&t in e&&(t in(e=this.h)&&delete e[t])),this.j=new lR(this)}function aR(e){pA.call(this);var t=e.__sm__;if(t){e:{for(const 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 cR(){fA.call(this),this.status=1}function lR(e){this.g=e}(ze=EN.prototype).ea=function(e,t,n,r){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.H+"; newUri="+e);t=t?t.toUpperCase():"GET",this.H=e,this.j="",this.m=0,this.D=!1,this.h=!0,this.g=(this.u||yA).g(),this.C=this.u?hA(this.u):hA(yA),this.g.onreadystatechange=OS(this.Fa,this);try{this.F=!0,this.g.open(t,String(e),!0),this.F=!1}catch(e){return void NN(this,e)}e=n||"";const i=new DA(this.headers);r&&xA(r,function(e,t){i.set(t,e)}),r=function(t){e:{var n=AN,r=t.length,i="string"==typeof t?t.split(""):t;for(let e=0;e<r;e++)if(e in i&&n.call(void 0,i[e],e,t)){n=e;break e}n=-1}return n<0?null:"string"==typeof t?t.charAt(n):t[n]}(i.T()),n=SS.FormData&&e instanceof SS.FormData,0<=jS(CN,t)&&!r&&!n&&i.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),i.forEach(function(e,t){this.g.setRequestHeader(t,e)},this),this.J&&(this.g.responseType=this.J),"withCredentials"in this.g&&this.g.withCredentials!==this.L&&(this.g.withCredentials=this.L);try{DN(this),0<this.B&&((this.K=(s=this.g,nC&&hC()&&"number"==typeof s.timeout&&void 0!==s.ontimeout))?(this.g.timeout=this.B,this.g.ontimeout=OS(this.pa,this)):this.A=HC(this.pa,this.B,this)),this.v=!0,this.g.send(e),this.v=!1}catch(e){NN(this,e)}var s},ze.pa=function(){void 0!==kS&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,MC(this,"timeout"),this.abort(8))},ze.abort=function(e){this.g&&this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=e||7,MC(this,"complete"),MC(this,"abort"),xN(this))},ze.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),xN(this,!0)),EN.Z.M.call(this)},ze.Fa=function(){this.s||(this.F||this.v||this.l?PN(this):this.cb())},ze.cb=function(){PN(this)},ze.ba=function(){try{return 2<ON(this)?this.g.status:-1}catch(e){return-1}},ze.ga=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},ze.Qa=function(e){if(this.g){var t=this.g.responseText;return e&&0==t.indexOf(e)&&(t=t.substring(e.length)),TN(t)}},ze.Da=function(){return this.m},ze.La=function(){return"string"==typeof this.j?this.j:String(this.j)},(ze=UN.prototype).ma=8,ze.G=1,ze.hb=function(e){try{this.h.info("Origin Trials invoked: "+e)}catch(e){}},ze.Ha=function(t){if(this.m)if(this.m=null,1==this.G){if(!t){this.V=Math.floor(1e5*Math.random()),t=this.V++;const s=new mA(this,this.h,t,void 0);let e=this.s;if(this.P&&(e?(e=YS(e),XS(e,this.P)):e=this.P),null===this.o&&(s.H=e),this.ja)e:{for(var n=0,r=0;r<this.l.length;r++){var i=this.l[r];if("__data__"in i.g&&"string"==typeof(i=i.g.__data__)?i=i.length:i=void 0,void 0===i)break;if(4096<(n+=i)){n=r;break e}if(4096===n||r===this.l.length-1){n=r+1;break e}}n=1e3}else n=1e3;n=zN(this,s,n),WA(r=UA(this.F),"RID",t),WA(r,"CVER",22),this.D&&WA(r,"X-HTTP-Session-Id",this.D),KN(this,r),this.o&&e&&LN(r,this.o,e),hN(this.i,s),this.Ra&&WA(r,"TYPE","init"),this.ja?(WA(r,"$req",n),WA(r,"SID","null"),s.$=!0,IA(s,r,null)):IA(s,r,n),this.G=2}}else 3==this.G&&(t?$N(this,t):0==this.l.length||cN(this.i)||$N(this))},ze.Ga=function(){var e;this.u=null,YN(this),this.$&&!(this.L||null==this.g||this.O<=0)&&(e=2*this.O,this.h.info("BP detection timer enabled: "+e),this.B=lA(OS(this.bb,this),e))},ze.bb=function(){this.B&&(this.B=null,this.h.info("BP detection timeout reached."),this.h.info("Buffering proxy detected and switch to long-polling!"),this.N=!1,this.L=!0,aA(10),qN(this),YN(this))},ze.ab=function(){null!=this.v&&(this.v=null,qN(this),GN(this),aA(19))},ze.jb=function(e){e?(this.h.info("Successfully pinged google.com"),aA(2)):(this.h.info("Failed to ping google.com"),aA(1))},(ze=iR.prototype).xa=function(){},ze.wa=function(){},ze.va=function(){},ze.ua=function(){},ze.Oa=function(){},sR.prototype.g=function(e,t){return new oR(e,t)},LS(oR,OC),oR.prototype.m=function(){this.g.j=this.j,this.A&&(this.g.H=!0);var e=this.g,t=this.l,n=this.h||void 0;e.Wa&&(e.h.info("Origin Trials enabled."),VC(OS(e.hb,e,t))),aA(0),e.W=t,e.aa=n||{},e.N=e.X,e.F=nR(e,null,e.W),WN(e)},oR.prototype.close=function(){jN(this.g)},oR.prototype.u=function(e){var t;"string"==typeof e?((t={}).__data__=e,BN(this.g,t)):this.v?((t={}).__data__=FC(e),BN(this.g,t)):BN(this.g,e)},oR.prototype.M=function(){this.g.j=null,delete this.j,jN(this.g),delete this.g,oR.Z.M.call(this)},LS(aR,pA),LS(cR,fA),LS(lR,iR),lR.prototype.xa=function(){MC(this.g,"a")},lR.prototype.wa=function(e){MC(this.g,new aR(e))},lR.prototype.va=function(e){MC(this.g,new cR)},lR.prototype.ua=function(){MC(this.g,"b")},sR.prototype.createWebChannel=sR.prototype.g,oR.prototype.send=oR.prototype.u,oR.prototype.open=oR.prototype.m,c.NO_ERROR=0,c.TIMEOUT=8,c.HTTP_ERROR=6,yt.COMPLETE="complete",(dA.EventType=l).OPEN="a",l.CLOSE="b",l.ERROR="c",l.MESSAGE="d",OC.prototype.listen=OC.prototype.N,EN.prototype.listenOnce=EN.prototype.O,EN.prototype.getLastError=EN.prototype.La,EN.prototype.getLastErrorCode=EN.prototype.Da,EN.prototype.getStatus=EN.prototype.ba,EN.prototype.getResponseJson=EN.prototype.Qa,EN.prototype.getResponseText=EN.prototype.ga,EN.prototype.send=EN.prototype.ea;var uR,hR=rA,dR=c,pR=yt,fR=tA,gR=10,mR=11,vR=vN,yR=dA,_R=EN;const wR="@firebase/firestore";class bR{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}}bR.UNAUTHENTICATED=new bR(null),bR.GOOGLE_CREDENTIALS=new bR("google-credentials-uid"),bR.FIRST_PARTY=new bR("first-party-uid"),bR.MOCK_USER=new bR("mock-user");let IR="9.6.3";const TR=new ep("@firebase/firestore");function ER(){return TR.logLevel}function kR(e,...t){var n;TR.logLevel<=$h.DEBUG&&(n=t.map(AR),TR.debug(`Firestore (${IR}): ${e}`,...n))}function SR(e,...t){var n;TR.logLevel<=$h.ERROR&&(n=t.map(AR),TR.error(`Firestore (${IR}): ${e}`,...n))}function CR(e,...t){var n;TR.logLevel<=$h.WARN&&(n=t.map(AR),TR.warn(`Firestore (${IR}): ${e}`,...n))}function AR(t){if("string"==typeof t)return t;try{return JSON.stringify(t)}catch(e){return t}}function NR(e="Unexpected state"){var t=`FIRESTORE (${IR}) INTERNAL ASSERTION FAILED: `+e;throw SR(t),new Error(t)}function RR(e){e||NR()}const PR={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class xR extends gd{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class DR{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class OR{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class MR{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(bR.UNAUTHENTICATED))}shutdown(){}}class LR{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 FR{constructor(e){this.t=e,this.currentUser=bR.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,n){let r=this.i;const i=e=>this.i!==r?(r=this.i,n(e)):Promise.resolve();let s=new DR;this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new DR,t.enqueueRetryable(()=>i(this.currentUser))};const o=()=>{const e=s;t.enqueueRetryable(async()=>{await e.promise,await i(this.currentUser)})},a=e=>{kR("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.auth.addAuthTokenListener(this.o),o()};this.t.onInit(e=>a(e)),setTimeout(()=>{var e;this.auth||((e=this.t.getImmediate({optional:!0}))?a(e):(kR("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new DR))},0),o()}getToken(){const t=this.i,e=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(e).then(e=>this.i!==t?(kR("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):e?(RR("string"==typeof e.accessToken),new OR(e.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.auth.removeAuthTokenListener(this.o)}u(){var e=this.auth&&this.auth.getUid();return RR(null===e||"string"==typeof e),new bR(e)}}class UR{constructor(e,t,n){this.type="FirstParty",this.user=bR.FIRST_PARTY,this.headers=new Map,this.headers.set("X-Goog-AuthUser",t);var r=e.auth.getAuthHeaderValueForFirstParty([]);r&&this.headers.set("Authorization",r),n&&this.headers.set("X-Goog-Iam-Authorization-Token",n)}}class jR{constructor(e,t,n){this.h=e,this.l=t,this.m=n}getToken(){return Promise.resolve(new UR(this.h,this.l,this.m))}start(e,t){e.enqueueRetryable(()=>t(bR.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class qR{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&0<e.length&&this.headers.set("x-firebase-appcheck",this.value)}}class VR{constructor(e){this.g=e,this.forceRefresh=!1,this.appCheck=null}start(t,n){this.o=e=>{t.enqueueRetryable(()=>(e=>(null!=e.error&&kR("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`),n(e.token)))(e))};const r=e=>{kR("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.appCheck.addTokenListener(this.o)};this.g.onInit(e=>r(e)),setTimeout(()=>{var e;this.appCheck||((e=this.g.getImmediate({optional:!0}))?r(e):kR("FirebaseAppCheckTokenProvider","AppCheck not yet detected"))},0)}getToken(){var e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(RR("string"==typeof e.token),new qR(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}class BR{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.p(e),this.T=e=>t.writeSequenceNumber(e))}p(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){var e=++this.previousValue;return this.T&&this.T(e),e}}BR.I=-1;class WR{static A(){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=Math.floor(256/t.length)*t.length;let r="";for(;r.length<20;){var i=function(t){const n="undefined"!=typeof self&&(self.crypto||self.msCrypto),r=new Uint8Array(t);if(n&&"function"==typeof n.getRandomValues)n.getRandomValues(r);else for(let e=0;e<t;e++)r[e]=Math.floor(256*Math.random());return r}(40);for(let e=0;e<i.length;++e)r.length<20&&i[e]<n&&(r+=t.charAt(i[e]%t.length))}return r}}function $R(e,t){return e<t?-1:t<e?1:0}function KR(e,n,r){return e.length===n.length&&e.every((e,t)=>r(e,n[t]))}function zR(e){return e+"\0"}class HR{constructor(e,t){if(this.seconds=e,(this.nanoseconds=t)<0)throw new xR(PR.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(1e9<=t)throw new xR(PR.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-62135596800)throw new xR(PR.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(253402300800<=e)throw new xR(PR.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return HR.fromMillis(Date.now())}static fromDate(e){return HR.fromMillis(e.getTime())}static fromMillis(e){var t=Math.floor(e/1e3),n=Math.floor(1e6*(e-1e3*t));return new HR(t,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?$R(this.nanoseconds,e.nanoseconds):$R(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(){var e=this.seconds- -62135596800;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}class GR{constructor(e){this.timestamp=e}static fromTimestamp(e){return new GR(e)}static min(){return new GR(new HR(0,0))}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}}function QR(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function YR(e,t){for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function JR(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class XR{constructor(e,t,n){void 0===t?t=0:t>e.length&&NR(),void 0===n?n=e.length-t:n>e.length-t&&NR(),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return 0===XR.comparator(this,e)}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof XR?e.forEach(e=>{t.push(e)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return this.construct(this.segments,this.offset+(e=void 0===e?1: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){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++){const n=e.get(r),i=t.get(r);if(n<i)return-1;if(n>i)return 1}return e.length<t.length?-1:e.length>t.length?1:0}}class ZR extends XR{construct(e,t,n){return new ZR(e,t,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}static fromString(...e){const t=[];for(const n of e){if(0<=n.indexOf("//"))throw new xR(PR.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter(e=>0<e.length))}return new ZR(t)}static emptyPath(){return new ZR([])}}const eP=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class tP extends XR{construct(e,t,n){return new tP(e,t,n)}static isValidIdentifier(e){return eP.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),e=!tP.isValidIdentifier(e)?"`"+e+"`":e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&"__name__"===this.get(0)}static keyField(){return new tP(["__name__"])}static fromServerFormat(e){const t=[];let n="",r=0;var i=()=>{if(0===n.length)throw new xR(PR.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""};let s=!1;for(;r<e.length;){const t=e[r];if("\\"===t){if(r+1===e.length)throw new xR(PR.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const t=e[r+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new xR(PR.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 xR(PR.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new tP(t)}static emptyPath(){return new tP([])}}class nP{constructor(e){(this.fields=e).sort(tP.comparator)}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return KR(this.fields,e.fields,(e,t)=>e.isEqual(t))}}class rP{constructor(e){this.binaryString=e}static fromBase64String(e){var t=atob(e);return new rP(t)}static fromUint8Array(e){var t=function(e){let t="";for(let n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}(e);return new rP(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return e=this.binaryString,btoa(e);var e}toUint8Array(){return function(e){const 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 $R(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}rP.EMPTY_BYTE_STRING=new rP("");const iP=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function sP(t){if(RR(!!t),"string"!=typeof t)return{seconds:oP(t.seconds),nanos:oP(t.nanos)};{let e=0;var n=iP.exec(t);RR(!!n),n[1]&&(n=((n=n[1])+"000000000").substr(0,9),e=Number(n));const r=new Date(t);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}}function oP(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function aP(e){return"string"==typeof e?rP.fromBase64String(e):rP.fromUint8Array(e)}function cP(e){var t;return"server_timestamp"===(null===(t=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{}).__type__)||void 0===t?void 0:t.stringValue)}function lP(e){var t=sP(e.mapValue.fields.__local_write_time__.timestampValue);return new HR(t.seconds,t.nanos)}function uP(e){return null==e}function hP(e){return 0===e&&1/e==-1/0}function dP(e){return"number"==typeof e&&Number.isInteger(e)&&!hP(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}class pP{constructor(e){this.path=e}static fromPath(e){return new pP(ZR.fromString(e))}static fromName(e){return new pP(ZR.fromString(e).popFirst(5))}hasCollectionId(e){return 2<=this.path.length&&this.path.get(this.path.length-2)===e}isEqual(e){return null!==e&&0===ZR.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return ZR.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new pP(new ZR(e.slice()))}}function fP(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?cP(e)?4:10:NR()}function gP(r,i){if(r===i)return!0;var e,t,n=fP(r);if(n!==fP(i))return!1;switch(n){case 0:return!0;case 1:return r.booleanValue===i.booleanValue;case 4:return lP(r).isEqual(lP(i));case 3:return function(e){if("string"==typeof r.timestampValue&&"string"==typeof e.timestampValue&&r.timestampValue.length===e.timestampValue.length)return r.timestampValue===e.timestampValue;var t=sP(r.timestampValue),n=sP(e.timestampValue);return t.seconds===n.seconds&&t.nanos===n.nanos}(i);case 5:return r.stringValue===i.stringValue;case 6:return t=i,aP(r.bytesValue).isEqual(aP(t.bytesValue));case 7:return r.referenceValue===i.referenceValue;case 8:return e=i,oP((t=r).geoPointValue.latitude)===oP(e.geoPointValue.latitude)&&oP(t.geoPointValue.longitude)===oP(e.geoPointValue.longitude);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return oP(e.integerValue)===oP(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){var n=oP(e.doubleValue),r=oP(t.doubleValue);return n===r?hP(n)===hP(r):isNaN(n)&&isNaN(r)}return!1}(r,i);case 9:return KR(r.arrayValue.values||[],i.arrayValue.values||[],gP);case 10:return function(e){const t=e.mapValue.fields||{},n=i.mapValue.fields||{};if(QR(t)!==QR(n))return!1;for(const e in t)if(t.hasOwnProperty(e)&&(void 0===n[e]||!gP(t[e],n[e])))return!1;return!0}(r);default:return NR()}}function mP(e,t){return void 0!==(e.values||[]).find(e=>gP(e,t))}function vP(e,t){if(e===t)return 0;var n,r,i,s,o=fP(e),a=fP(t);if(o!==a)return $R(o,a);switch(o){case 0:return 0;case 1:return $R(e.booleanValue,t.booleanValue);case 2:return r=t,i=oP(e.integerValue||e.doubleValue),s=oP(r.integerValue||r.doubleValue),i<s?-1:s<i?1:i===s?0:isNaN(i)?isNaN(s)?0:-1:1;case 3:return yP(e.timestampValue,t.timestampValue);case 4:return yP(lP(e),lP(t));case 5:return $R(e.stringValue,t.stringValue);case 6:return function(e,t){const n=aP(e),r=aP(t);return n.compareTo(r)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){var n=e.split("/"),r=t.split("/");for(let i=0;i<n.length&&i<r.length;i++){const t=$R(n[i],r[i]);if(0!==t)return t}return $R(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return n=e.geoPointValue,r=t.geoPointValue,0!==(s=$R(oP(n.latitude),oP(r.latitude)))?s:$R(oP(n.longitude),oP(r.longitude));case 9:return function(e,t){var n=e.values||[],r=t.values||[];for(let i=0;i<n.length&&i<r.length;++i){const t=vP(n[i],r[i]);if(t)return t}return $R(n.length,r.length)}(e.arrayValue,t.arrayValue);case 10:return function(e,t){const n=e.fields||{},r=Object.keys(n),i=t.fields||{},s=Object.keys(i);r.sort(),s.sort();for(let a=0;a<r.length&&a<s.length;++a){const t=$R(r[a],s[a]);if(0!==t)return t;var o=vP(n[r[a]],i[s[a]]);if(0!==o)return o}return $R(r.length,s.length)}(e.mapValue,t.mapValue);default:throw NR()}}function yP(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return $R(e,t);var n=sP(e),r=sP(t),i=$R(n.seconds,r.seconds);return 0!==i?i:$R(n.nanos,r.nanos)}function _P(e){return function s(e){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){const t=sP(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?aP(e.bytesValue).toBase64():"referenceValue"in e?(t=e.referenceValue,pP.fromName(t).toString()):"geoPointValue"in e?`geo(${(t=e.geoPointValue).latitude},${t.longitude})`:"arrayValue"in e?function(e){let t="[",n=!0;for(const r of e.values||[])n?n=!1:t+=",",t+=s(r);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){const t=Object.keys(e.fields||{}).sort();let n="{",r=!0;for(const i of t)r?r=!1:n+=",",n+=`${i}:${s(e.fields[i])}`;return n+"}"}(e.mapValue):NR();var t}(e)}function wP(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function bP(e){return e&&"integerValue"in e}function IP(e){return!!e&&"arrayValue"in e}function TP(e){return e&&"nullValue"in e}function EP(e){return e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function kP(e){return e&&"mapValue"in e}function SP(t){if(t.geoPointValue)return{geoPointValue:Object.assign({},t.geoPointValue)};if(t.timestampValue&&"object"==typeof t.timestampValue)return{timestampValue:Object.assign({},t.timestampValue)};if(t.mapValue){const n={mapValue:{fields:{}}};return YR(t.mapValue.fields,(e,t)=>n.mapValue.fields[e]=SP(t)),n}if(t.arrayValue){const r={arrayValue:{values:[]}};for(let e=0;e<(t.arrayValue.values||[]).length;++e)r.arrayValue.values[e]=SP(t.arrayValue.values[e]);return r}return Object.assign({},t)}class CP{constructor(e){this.value=e}static empty(){return new CP({mapValue:{}})}field(n){if(n.isEmpty())return this.value;{let e=this.value;for(let t=0;t<n.length-1;++t)if(e=(e.mapValue.fields||{})[n.get(t)],!kP(e))return null;return e=(e.mapValue.fields||{})[n.lastSegment()],e||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=SP(t)}setAll(e){let n=tP.emptyPath(),r={},i=[];e.forEach((e,t)=>{if(!n.isImmediateParentOf(t)){const e=this.getFieldsMap(n);this.applyChanges(e,r,i),r={},i=[],n=t.popLast()}e?r[t.lastSegment()]=SP(e):i.push(t.lastSegment())});var t=this.getFieldsMap(n);this.applyChanges(t,r,i)}delete(e){const t=this.field(e.popLast());kP(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return gP(this.value,e.value)}getFieldsMap(t){let n=this.value;n.mapValue.fields||(n.mapValue={fields:{}});for(let r=0;r<t.length;++r){let e=n.mapValue.fields[t.get(r)];kP(e)&&e.mapValue.fields||(e={mapValue:{fields:{}}},n.mapValue.fields[t.get(r)]=e),n=e}return n.mapValue.fields}applyChanges(n,e,t){YR(e,(e,t)=>n[e]=t);for(const e of t)delete n[e]}clone(){return new CP(SP(this.value))}}class AP{constructor(e,t,n,r,i){this.key=e,this.documentType=t,this.version=n,this.data=r,this.documentState=i}static newInvalidDocument(e){return new AP(e,0,GR.min(),CP.empty(),0)}static newFoundDocument(e,t,n){return new AP(e,1,t,n,0)}static newNoDocument(e,t){return new AP(e,2,t,CP.empty(),0)}static newUnknownDocument(e,t){return new AP(e,3,t,CP.empty(),2)}convertToFoundDocument(e,t){return this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=CP.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=CP.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,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 AP&&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 AP(this.key,this.documentType,this.version,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class NP{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.R=null}}function RP(e,t=null,n=[],r=[],i=null,s=null,o=null){return new NP(e,t,n,r,i,s,o)}function PP(e){const t=e;if(null===t.R){let e=t.path.canonicalString();null!==t.collectionGroup&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map(e=>function(e){return e.field.canonicalString()+e.op.toString()+_P(e.value)}(e)).join(","),e+="|ob:",e+=t.orderBy.map(e=>function(e){return e.field.canonicalString()+e.dir}(e)).join(","),uP(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=$P(t.startAt)),t.endAt&&(e+="|ub:",e+=$P(t.endAt)),t.R=e}return t.R}function xP(e,t){if(e.limit!==t.limit)return!1;if(e.orderBy.length!==t.orderBy.length)return!1;for(let o=0;o<e.orderBy.length;o++)if(n=e.orderBy[o],r=t.orderBy[o],n.dir!==r.dir||!n.field.isEqual(r.field))return!1;var n,r,i,s;if(e.filters.length!==t.filters.length)return!1;for(let a=0;a<e.filters.length;a++)if(i=e.filters[a],s=t.filters[a],i.op!==s.op||!i.field.isEqual(s.field)||!gP(i.value,s.value))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!HP(e.startAt,t.startAt)&&HP(e.endAt,t.endAt)}function DP(e){return pP.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}class OP extends class{}{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.P(e,t,n):new MP(e,t,n):"array-contains"===t?new jP(e,n):"in"===t?new qP(e,n):"not-in"===t?new VP(e,n):"array-contains-any"===t?new BP(e,n):new OP(e,t,n)}static P(e,t,n){return new("in"===t?LP:FP)(e,n)}matches(e){var t=e.data.field(this.field);return"!="===this.op?null!==t&&this.v(vP(t,this.value)):null!==t&&fP(this.value)===fP(t)&&this.v(vP(t,this.value))}v(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return 0<e;case">=":return 0<=e;default:return NR()}}V(){return 0<=["<","<=",">",">=","!=","not-in"].indexOf(this.op)}}class MP extends OP{constructor(e,t,n){super(e,t,n),this.key=pP.fromName(n.referenceValue)}matches(e){var t=pP.comparator(e.key,this.key);return this.v(t)}}class LP extends OP{constructor(e,t){super(e,"in",t),this.keys=UP(0,t)}matches(t){return this.keys.some(e=>e.isEqual(t.key))}}class FP extends OP{constructor(e,t){super(e,"not-in",t),this.keys=UP(0,t)}matches(t){return!this.keys.some(e=>e.isEqual(t.key))}}function UP(e,t){var n;return((null===(n=t.arrayValue)||void 0===n?void 0:n.values)||[]).map(e=>pP.fromName(e.referenceValue))}class jP extends OP{constructor(e,t){super(e,"array-contains",t)}matches(e){var t=e.data.field(this.field);return IP(t)&&mP(t.arrayValue,this.value)}}class qP extends OP{constructor(e,t){super(e,"in",t)}matches(e){var t=e.data.field(this.field);return null!==t&&mP(this.value.arrayValue,t)}}class VP extends OP{constructor(e,t){super(e,"not-in",t)}matches(e){if(mP(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var t=e.data.field(this.field);return null!==t&&!mP(this.value.arrayValue,t)}}class BP extends OP{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!IP(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>mP(this.value.arrayValue,e))}}class WP{constructor(e,t){this.position=e,this.before=t}}function $P(e){return`${e.before?"b":"a"}:${e.position.map(e=>_P(e)).join(",")}`}class KP{constructor(e,t="asc"){this.field=e,this.dir=t}}function zP(e,t,n){let r=0;for(let i=0;i<e.position.length;i++){const s=t[i],o=e.position[i];if(r=s.field.isKeyField()?pP.comparator(pP.fromName(o.referenceValue),n.key):vP(o,n.data.field(s.field)),"desc"===s.dir&&(r*=-1),0!==r)break}return e.before?r<=0:r<0}function HP(e,t){if(null===e)return null===t;if(null===t)return!1;if(e.before!==t.before||e.position.length!==t.position.length)return!1;for(let n=0;n<e.position.length;n++)if(!gP(e.position[n],t.position[n]))return!1;return!0}class GP{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.S=null,this.D=null,this.startAt,this.endAt}}function QP(e,t,n,r,i,s,o,a){return new GP(e,t,n,r,i,s,o,a)}function YP(e){return new GP(e)}function JP(e){return!uP(e.limit)&&"F"===e.limitType}function XP(e){return!uP(e.limit)&&"L"===e.limitType}function ZP(e){return 0<e.explicitOrderBy.length?e.explicitOrderBy[0].field:null}function ex(e){for(const t of e.filters)if(t.V())return t.field;return null}function tx(e){return null!==e.collectionGroup}function nx(t){const n=t;if(null===n.S){n.S=[];const t=ex(n),e=ZP(n);if(null!==t&&null===e)t.isKeyField()||n.S.push(new KP(t)),n.S.push(new KP(tP.keyField(),"asc"));else{let e=!1;for(const r of n.explicitOrderBy)n.S.push(r),r.field.isKeyField()&&(e=!0);if(!e){const t=0<n.explicitOrderBy.length?n.explicitOrderBy[n.explicitOrderBy.length-1].dir:"asc";n.S.push(new KP(tP.keyField(),t))}}}return n.S}function rx(e){const t=e;if(!t.D)if("F"===t.limitType)t.D=RP(t.path,t.collectionGroup,nx(t),t.filters,t.limit,t.startAt,t.endAt);else{const e=[];for(const i of nx(t)){const t="desc"===i.dir?"asc":"desc";e.push(new KP(i.field,t))}var n=t.endAt?new WP(t.endAt.position,!t.endAt.before):null,r=t.startAt?new WP(t.startAt.position,!t.startAt.before):null;t.D=RP(t.path,t.collectionGroup,e,t.filters,t.limit,n,r)}return t.D}function ix(e,t,n){return new GP(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function sx(e,t){return xP(rx(e),rx(t))&&e.limitType===t.limitType}function ox(e){return`${PP(rx(e))}|lt:${e.limitType}`}function ax(e){return`Query(target=${function(e){let t=e.path.canonicalString();return null!==e.collectionGroup&&(t+=" collectionGroup="+e.collectionGroup),0<e.filters.length&&(t+=`, filters: [${e.filters.map(e=>{return`${(t=e).field.canonicalString()} ${t.op} ${_P(t.value)}`;var t}).join(", ")}]`),uP(e.limit)||(t+=", limit: "+e.limit),0<e.orderBy.length&&(t+=`, orderBy: [${e.orderBy.map(e=>function(e){return`${e.field.canonicalString()} (${e.dir})`}(e)).join(", ")}]`),e.startAt&&(t+=", startAt: "+$P(e.startAt)),e.endAt&&(t+=", endAt: "+$P(e.endAt)),`Target(${t})`}(rx(e))}; limitType=${e.limitType})`}function cx(n,e){return e.isFoundDocument()&&(t=n,i=(r=e).key.path,null!==t.collectionGroup?r.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(i):pP.isDocumentKey(t.path)?t.path.isEqual(i):t.path.isImmediateParentOf(i))&&function(e){for(const t of n.explicitOrderBy)if(!t.field.isKeyField()&&null===e.data.field(t.field))return;return 1}(e)&&function(e){for(const t of n.filters)if(!t.matches(e))return;return 1}(e)&&(t=e,(!(e=n).startAt||zP(e.startAt,nx(e),t))&&(!e.endAt||!zP(e.endAt,nx(e),t)));var t,r,i}function lx(i){return(e,t)=>{let n=!1;for(const r of nx(i)){const i=function(e,i,t){var n=e.field.isKeyField()?pP.comparator(i.key,t.key):function(e,t){var n=i.data.field(e),r=t.data.field(e);return null!==n&&null!==r?vP(n,r):NR()}(e.field,t);switch(e.dir){case"asc":return n;case"desc":return-1*n;default:return NR()}}(r,e,t);if(0!==i)return i;n=n||r.field.isKeyField()}return 0}}function ux(e,t){if(e.C){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:hP(t)?"-0":t}}function hx(e){return{integerValue:""+e}}function dx(e,t){return dP(t)?hx(t):ux(e,t)}class px{constructor(){this._=void 0}}function fx(e,t){return e instanceof wx?bP(n=t)||n&&"doubleValue"in n?t:{integerValue:0}:null;var n}class gx extends px{}class mx extends px{constructor(e){super(),this.elements=e}}function vx(e,t){const n=Ix(t);for(const t of e.elements)n.some(e=>gP(e,t))||n.push(t);return{arrayValue:{values:n}}}class yx extends px{constructor(e){super(),this.elements=e}}function _x(e,t){let n=Ix(t);for(const t of e.elements)n=n.filter(e=>!gP(e,t));return{arrayValue:{values:n}}}class wx extends px{constructor(e,t){super(),this.k=e,this.N=t}}function bx(e){return oP(e.integerValue||e.doubleValue)}function Ix(e){return IP(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class Tx{constructor(e,t){this.field=e,this.transform=t}}class Ex{constructor(e,t){this.version=e,this.transformResults=t}}class kx{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new kx}static exists(e){return new kx(void 0,e)}static updateTime(e){return new kx(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 Sx(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class Cx{}function Ax(e,t,n){e instanceof xx?function(e,t,n){const r=e.value.clone(),i=Mx(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof Dx?function(e,t,n){if(!Sx(e.precondition,t))return t.convertToUnknownDocument(n.version);const r=Mx(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(Ox(e)),i.setAll(r),t.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(e,t,n):t.convertToNoDocument(n.version).setHasCommittedMutations()}function Nx(e,t,n){e instanceof xx?function(e,t,n){if(Sx(e.precondition,t)){const r=e.value.clone(),i=Lx(e.fieldTransforms,n,t);r.setAll(i),t.convertToFoundDocument(Px(t),r).setHasLocalMutations()}}(e,t,n):e instanceof Dx?function(e,t,n){if(Sx(e.precondition,t)){const r=Lx(e.fieldTransforms,n,t),i=t.data;i.setAll(Ox(e)),i.setAll(r),t.convertToFoundDocument(Px(t),i).setHasLocalMutations()}}(e,t,n):(t=t,Sx(e.precondition,t)&&t.convertToNoDocument(GR.min()))}function Rx(e,t){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&&KR(n,r,(e,t)=>function(e,t){return e.field.isEqual(t.field)&&(e=e.transform,t=t.transform,e instanceof mx&&t instanceof mx||e instanceof yx&&t instanceof yx?KR(e.elements,t.elements,gP):e instanceof wx&&t instanceof wx?gP(e.N,t.N):e instanceof gx&&t instanceof gx)}(e,t)))&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask)));var n,r}function Px(e){return e.isFoundDocument()?e.version:GR.min()}class xx extends Cx{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}}class Dx extends Cx{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}}function Ox(n){const r=new Map;return n.fieldMask.fields.forEach(e=>{var t;e.isEmpty()||(t=n.data.field(e),r.set(e,t))}),r}function Mx(e,t,n){const r=new Map;RR(e.length===n.length);for(let u=0;u<n.length;u++){var i=e[u],s=i.transform,o=t.data.field(i.field);r.set(i.field,(a=s,c=o,l=n[u],a instanceof mx?vx(a,c):a instanceof yx?_x(a,c):l))}var a,c,l;return r}function Lx(e,t,n){const r=new Map;for(const l of e){const e=l.transform,u=n.data.field(l.field);r.set(l.field,(i=e,s=u,o=t,c=a=void 0,i instanceof gx?function(){const e={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:o.seconds,nanos:o.nanoseconds}}}};return s&&(e.fields.__previous_value__=s),{mapValue:e}}():i instanceof mx?vx(i,s):i instanceof yx?_x(i,s):(a=fx(i=i,s),c=bx(a)+bx(i.N),bP(a)&&bP(i.N)?hx(c):ux(i.k,c))))}var i,s,o,a,c;return r}class Fx extends Cx{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}}class Ux extends Cx{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}}class jx{constructor(e){this.count=e}}function qx(e){switch(e){default:return NR(),0;case PR.CANCELLED:case PR.UNKNOWN:case PR.DEADLINE_EXCEEDED:case PR.RESOURCE_EXHAUSTED:case PR.INTERNAL:case PR.UNAVAILABLE:case PR.UNAUTHENTICATED:return;case PR.INVALID_ARGUMENT:case PR.NOT_FOUND:case PR.ALREADY_EXISTS:case PR.PERMISSION_DENIED:case PR.FAILED_PRECONDITION:case PR.ABORTED:case PR.OUT_OF_RANGE:case PR.UNIMPLEMENTED:case PR.DATA_LOSS:return 1}}function Vx(e){if(void 0===e)return SR("GRPC error has no .code"),PR.UNKNOWN;switch(e){case uR.OK:return PR.OK;case uR.CANCELLED:return PR.CANCELLED;case uR.UNKNOWN:return PR.UNKNOWN;case uR.DEADLINE_EXCEEDED:return PR.DEADLINE_EXCEEDED;case uR.RESOURCE_EXHAUSTED:return PR.RESOURCE_EXHAUSTED;case uR.INTERNAL:return PR.INTERNAL;case uR.UNAVAILABLE:return PR.UNAVAILABLE;case uR.UNAUTHENTICATED:return PR.UNAUTHENTICATED;case uR.INVALID_ARGUMENT:return PR.INVALID_ARGUMENT;case uR.NOT_FOUND:return PR.NOT_FOUND;case uR.ALREADY_EXISTS:return PR.ALREADY_EXISTS;case uR.PERMISSION_DENIED:return PR.PERMISSION_DENIED;case uR.FAILED_PRECONDITION:return PR.FAILED_PRECONDITION;case uR.ABORTED:return PR.ABORTED;case uR.OUT_OF_RANGE:return PR.OUT_OF_RANGE;case uR.UNIMPLEMENTED:return PR.UNIMPLEMENTED;case uR.DATA_LOSS:return PR.DATA_LOSS;default:return NR()}}(c=uR=uR||{})[c.OK=0]="OK",c[c.CANCELLED=1]="CANCELLED",c[c.UNKNOWN=2]="UNKNOWN",c[c.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",c[c.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",c[c.NOT_FOUND=5]="NOT_FOUND",c[c.ALREADY_EXISTS=6]="ALREADY_EXISTS",c[c.PERMISSION_DENIED=7]="PERMISSION_DENIED",c[c.UNAUTHENTICATED=16]="UNAUTHENTICATED",c[c.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",c[c.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",c[c.ABORTED=10]="ABORTED",c[c.OUT_OF_RANGE=11]="OUT_OF_RANGE",c[c.UNIMPLEMENTED=12]="UNIMPLEMENTED",c[c.INTERNAL=13]="INTERNAL",c[c.UNAVAILABLE=14]="UNAVAILABLE",c[c.DATA_LOSS=15]="DATA_LOSS";class Bx{constructor(e,t){this.comparator=e,this.root=t||$x.EMPTY}insert(e,t){return new Bx(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,$x.BLACK,null,null))}remove(e){return new Bx(this.comparator,this.root.remove(e,this.comparator).copy(null,null,$x.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){var n=this.comparator(e,t.key);if(0===n)return t.value;n<0?t=t.left:0<n&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){var r=this.comparator(e,n.key);if(0===r)return t+n.left.size;n=r<0?n.left:(t+=n.left.size+1,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(n){this.inorderTraversal((e,t)=>(n(e,t),!1))}toString(){const n=[];return this.inorderTraversal((e,t)=>(n.push(`${e}:${t}`),!1)),`{${n.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Wx(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Wx(this.root,e,this.comparator,!1)}getReverseIterator(){return new Wx(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Wx(this.root,e,this.comparator,!0)}}class Wx{constructor(e,t,n,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?n(e.key,t):1,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();var 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 0<this.nodeStack.length}peek(){if(0===this.nodeStack.length)return null;var e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class $x{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:$x.RED,this.left=null!=r?r:$x.EMPTY,this.right=null!=i?i:$x.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,r,i){return new $x(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;var 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)),r.fixUp()}removeMin(){if(this.left.isEmpty())return $x.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let n,r=this;if(t(e,r.key)<0)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 $x.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.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){var e=this.copy(null,null,$x.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){var e=this.copy(null,null,$x.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){var 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(){var e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw NR();if(this.right.isRed())throw NR();var e=this.left.check();if(e!==this.right.check())throw NR();return e+(this.isRed()?0:1)}}$x.EMPTY=null,$x.RED=!0,$x.BLACK=!1,$x.EMPTY=new class{constructor(){this.size=0}get key(){throw NR()}get value(){throw NR()}get color(){throw NR()}get left(){throw NR()}get right(){throw NR()}copy(e,t,n,r,i){return this}insert(e,t,n){return new $x(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 Kx{constructor(e){this.comparator=e,this.data=new Bx(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(n){this.data.inorderTraversal((e,t)=>(n(e),!1))}forEachInRange(e,t){const n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){var r=n.getNext();if(0<=this.comparator(r.key,e[1]))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){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new zx(this.data.getIterator())}getIteratorFrom(e){return new zx(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 Kx))return!1;if(this.size!==e.size)return!1;const t=this.data.getIterator(),n=e.data.getIterator();for(;t.hasNext();){const e=t.getNext().key,r=n.getNext().key;if(0!==this.comparator(e,r))return!1}return!0}toArray(){const t=[];return this.forEach(e=>{t.push(e)}),t}toString(){const t=[];return this.forEach(e=>t.push(e)),"SortedSet("+t.toString()+")"}copy(e){const t=new Kx(this.comparator);return t.data=e,t}}class zx{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}const Hx=new Bx(pP.comparator);const Gx=new Bx(pP.comparator);const Qx=new Bx(pP.comparator);const Yx=new Kx(pP.comparator);function Jx(...e){let t=Yx;for(const n of e)t=t.add(n);return t}const Xx=new Kx($R);class Zx{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){const n=new Map;return n.set(e,eD.createSynthesizedTargetChangeForCurrentChange(e,t)),new Zx(GR.min(),n,Xx,Hx,Jx())}}class eD{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){return new eD(rP.EMPTY_BYTE_STRING,t,Jx(),Jx(),Jx())}}class tD{constructor(e,t,n,r){this.$=e,this.removedTargetIds=t,this.key=n,this.O=r}}class nD{constructor(e,t){this.targetId=e,this.M=t}}class rD{constructor(e,t,n=rP.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class iD{constructor(){this.F=0,this.L=aD(),this.B=rP.EMPTY_BYTE_STRING,this.U=!1,this.q=!0}get current(){return this.U}get resumeToken(){return this.B}get K(){return 0!==this.F}get j(){return this.q}W(e){0<e.approximateByteSize()&&(this.q=!0,this.B=e)}G(){let n=Jx(),r=Jx(),i=Jx();return this.L.forEach((e,t)=>{switch(t){case 0:n=n.add(e);break;case 2:r=r.add(e);break;case 1:i=i.add(e);break;default:NR()}}),new eD(this.B,this.U,n,r,i)}H(){this.q=!1,this.L=aD()}J(e,t){this.q=!0,this.L=this.L.insert(e,t)}Y(e){this.q=!0,this.L=this.L.remove(e)}X(){this.F+=1}Z(){--this.F}tt(){this.q=!0,this.U=!0}}class sD{constructor(e){this.et=e,this.nt=new Map,this.st=Hx,this.it=oD(),this.rt=new Kx($R)}ot(e){for(const t of e.$)e.O&&e.O.isFoundDocument()?this.ct(t,e.O):this.at(t,e.key,e.O);for(const n of e.removedTargetIds)this.at(n,e.key,e.O)}ut(n){this.forEachTarget(n,e=>{const t=this.ht(e);switch(n.state){case 0:this.lt(e)&&t.W(n.resumeToken);break;case 1:t.Z(),t.K||t.H(),t.W(n.resumeToken);break;case 2:t.Z(),t.K||this.removeTarget(e);break;case 3:this.lt(e)&&(t.tt(),t.W(n.resumeToken));break;case 4:this.lt(e)&&(this.ft(e),t.W(n.resumeToken));break;default:NR()}})}forEachTarget(e,n){0<e.targetIds.length?e.targetIds.forEach(n):this.nt.forEach((e,t)=>{this.lt(t)&&n(t)})}dt(e){const t=e.targetId,n=e.M.count,r=this.wt(t);if(r){const e=r.target;if(DP(e))if(0===n){const n=new pP(e.path);this.at(t,n,AP.newNoDocument(n,GR.min()))}else RR(1===n);else this._t(t)!==n&&(this.ft(t),this.rt=this.rt.add(t))}}gt(r){const i=new Map;this.nt.forEach((e,t)=>{var n=this.wt(t);if(n){if(e.current&&DP(n.target)){const i=new pP(n.target.path);null!==this.st.get(i)||this.yt(t,i)||this.at(t,i,AP.newNoDocument(i,r))}e.j&&(i.set(t,e.G()),e.H())}});let s=Jx();this.it.forEach((e,t)=>{let n=!0;t.forEachWhile(e=>{var t=this.wt(e);return!t||2===t.purpose||(n=!1)}),n&&(s=s.add(e))});var e=new Zx(r,i,this.rt,this.st,s);return this.st=Hx,this.it=oD(),this.rt=new Kx($R),e}ct(e,t){var n;this.lt(e)&&(n=this.yt(e,t.key)?2:0,this.ht(e).J(t.key,n),this.st=this.st.insert(t.key,t),this.it=this.it.insert(t.key,this.Tt(t.key).add(e)))}at(e,t,n){if(this.lt(e)){const r=this.ht(e);this.yt(e,t)?r.J(t,1):r.Y(t),this.it=this.it.insert(t,this.Tt(t).delete(e)),n&&(this.st=this.st.insert(t,n))}}removeTarget(e){this.nt.delete(e)}_t(e){var t=this.ht(e).G();return this.et.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}X(e){this.ht(e).X()}ht(e){let t=this.nt.get(e);return t||(t=new iD,this.nt.set(e,t)),t}Tt(e){let t=this.it.get(e);return t||(t=new Kx($R),this.it=this.it.insert(e,t)),t}lt(e){var t=null!==this.wt(e);return t||kR("WatchChangeAggregator","Detected inactive target",e),t}wt(e){var t=this.nt.get(e);return t&&t.K?null:this.et.Et(e)}ft(t){this.nt.set(t,new iD),this.et.getRemoteKeysForTarget(t).forEach(e=>{this.at(t,e,null)})}yt(e,t){return this.et.getRemoteKeysForTarget(e).has(t)}}function oD(){return new Bx(pP.comparator)}function aD(){return new Bx(pP.comparator)}const cD={asc:"ASCENDING",desc:"DESCENDING"},lD={"<":"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"};class uD{constructor(e,t){this.databaseId=e,this.C=t}}function hD(e,t){return e.C?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function dD(e,t){return e.C?t.toBase64():t.toUint8Array()}function pD(e){return RR(!!e),GR.fromTimestamp((t=sP(e),new HR(t.seconds,t.nanos)));var t}function fD(e,t){return e=e,new ZR(["projects",e.projectId,"databases",e.database]).child("documents").child(t).canonicalString()}function gD(e){var t=ZR.fromString(e);return RR(MD(t)),t}function mD(e,t){return fD(e.databaseId,t.path)}function vD(e,t){const n=gD(t);if(n.get(1)!==e.databaseId.projectId)throw new xR(PR.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 xR(PR.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new pP(bD(n))}function yD(e,t){return fD(e.databaseId,t)}function _D(e){var t=gD(e);return 4===t.length?ZR.emptyPath():bD(t)}function wD(e){return new ZR(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function bD(e){return RR(4<e.length&&"documents"===e.get(4)),e.popFirst(5)}function ID(e,t,n){return{name:mD(e,t),fields:n.value.mapValue.fields}}function TD(e,t,n){const r=vD(e,t.name),i=pD(t.updateTime),s=new CP({mapValue:{fields:t.fields}}),o=AP.newFoundDocument(r,i,s);return n&&o.setHasCommittedMutations(),n?o.setHasCommittedMutations():o}function ED(e,t){let n;if(t instanceof xx)n={update:ID(e,t.key,t.value)};else if(t instanceof Fx)n={delete:mD(e,t.key)};else if(t instanceof Dx)n={update:ID(e,t.key,t.data),updateMask:function(e){const t=[];return e.fields.forEach(e=>t.push(e.canonicalString())),{fieldPaths:t}}(t.fieldMask)};else{if(!(t instanceof Ux))return NR();n={verify:mD(e,t.key)}}return 0<t.fieldTransforms.length&&(n.updateTransforms=t.fieldTransforms.map(e=>function(e){var t=e.transform;if(t instanceof gx)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(t instanceof mx)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:t.elements}};if(t instanceof yx)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:t.elements}};if(t instanceof wx)return{fieldPath:e.field.canonicalString(),increment:t.N};throw NR()}(e))),t.precondition.isNone||(n.currentDocument=void 0!==(r=t.precondition).updateTime?{updateTime:(t=r.updateTime,hD(e,t.toTimestamp()))}:void 0!==r.exists?{exists:r.exists}:NR()),n;var r}function kD(t,n){const e=n.currentDocument?void 0!==(i=n.currentDocument).updateTime?kx.updateTime(pD(i.updateTime)):void 0!==i.exists?kx.exists(i.exists):kx.none():kx.none(),r=n.updateTransforms?n.updateTransforms.map(e=>function(e,t){let n=null;if("setToServerValue"in t)RR("REQUEST_TIME"===t.setToServerValue),n=new gx;else if("appendMissingElements"in t){const e=t.appendMissingElements.values||[];n=new mx(e)}else if("removeAllFromArray"in t){const e=t.removeAllFromArray.values||[];n=new yx(e)}else"increment"in t?n=new wx(e,t.increment):NR();var r=tP.fromServerFormat(t.fieldPath);return new Tx(r,n)}(t,e)):[];var i;if(n.update){n.update.name;var s=vD(t,n.update.name),o=new CP({mapValue:{fields:n.update.fields}});if(n.updateMask){const t=function(){const e=n.updateMask.fieldPaths||[];return new nP(e.map(e=>tP.fromServerFormat(e)))}();return new Dx(s,o,t,e,r)}return new xx(s,o,e,r)}if(n.delete){const r=vD(t,n.delete);return new Fx(r,e)}if(n.verify){const r=vD(t,n.verify);return new Ux(r,e)}return NR()}function SD(e,t){return{documents:[yD(e,t.path)]}}function CD(e,t){const n={structuredQuery:{}},r=t.path;null!==t.collectionGroup?(n.parent=yD(e,r),n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(n.parent=yD(e,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);var i=function(e){if(0!==e.length){var t=e.map(e=>function(e){if("=="===e.op){if(EP(e.value))return{unaryFilter:{field:PD(e.field),op:"IS_NAN"}};if(TP(e.value))return{unaryFilter:{field:PD(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(EP(e.value))return{unaryFilter:{field:PD(e.field),op:"IS_NOT_NAN"}};if(TP(e.value))return{unaryFilter:{field:PD(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:PD(e.field),op:(t=e.op,lD[t]),value:e.value}};var t}(e));return 1===t.length?t[0]:{compositeFilter:{op:"AND",filters:t}}}}(t.filters);i&&(n.structuredQuery.where=i);i=function(e){if(0!==e.length)return e.map(e=>function(e){return{field:PD(e.field),direction:(e=e.dir,cD[e])}}(e))}(t.orderBy);i&&(n.structuredQuery.orderBy=i);var s,i=(s=t.limit,e.C||uP(s)?s:{value:s});return null!==i&&(n.structuredQuery.limit=i),t.startAt&&(n.structuredQuery.startAt=ND(t.startAt)),t.endAt&&(n.structuredQuery.endAt=ND(t.endAt)),n}function AD(e){let t=_D(e.parent);const n=e.structuredQuery,r=n.from?n.from.length:0;let i=null;if(0<r){RR(1===r);const h=n.from[0];h.allDescendants?i=h.collectionId:t=t.child(h.collectionId)}let s=[];n.where&&(s=function t(e){return e?void 0!==e.unaryFilter?[OD(e)]:void 0!==e.fieldFilter?[DD(e)]:void 0!==e.compositeFilter?e.compositeFilter.filters.map(e=>t(e)).reduce((e,t)=>e.concat(t)):NR():[]}(n.where));let o=[];n.orderBy&&(o=n.orderBy.map(e=>function(e){return new KP(xD(e.field),function(){switch(e.direction){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}())}(e)));let a=null;var c;n.limit&&(a=(e=n.limit,uP(c="object"==typeof e?e.value:e)?null:c));let l=null;n.startAt&&(l=RD(n.startAt));let u=null;return n.endAt&&(u=RD(n.endAt)),QP(t,i,o,s,a,"F",l,u)}function ND(e){return{before:e.before,values:e.position}}function RD(e){var t=!!e.before,n=e.values||[];return new WP(n,t)}function PD(e){return{fieldPath:e.canonicalString()}}function xD(e){return tP.fromServerFormat(e.fieldPath)}function DD(e){return OP.create(xD(e.fieldFilter.field),function(){switch(e.fieldFilter.op){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return NR()}}(),e.fieldFilter.value)}function OD(e){switch(e.unaryFilter.op){case"IS_NAN":var t=xD(e.unaryFilter.field);return OP.create(t,"==",{doubleValue:NaN});case"IS_NULL":t=xD(e.unaryFilter.field);return OP.create(t,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var n=xD(e.unaryFilter.field);return OP.create(n,"!=",{doubleValue:NaN});case"IS_NOT_NULL":n=xD(e.unaryFilter.field);return OP.create(n,"!=",{nullValue:"NULL_VALUE"});default:return NR()}}function MD(e){return 4<=e.length&&"projects"===e.get(0)&&"databases"===e.get(2)}function LD(e){let t="";for(let n=0;n<e.length;n++)0<t.length&&(t=FD(t)),t=function(e,t){let n=t;const r=e.length;for(let i=0;i<r;i++){const r=e.charAt(i);switch(r){case"\0":n+="";break;case"":n+="";break;default:n+=r}}return n}(e.get(n),t);return FD(t)}function FD(e){return e+""}function UD(t){const n=t.length;if(RR(2<=n),2===n)return RR(""===t.charAt(0)&&""===t.charAt(1)),ZR.emptyPath();const r=n-2,i=[];let s="";for(let o=0;o<n;){const n=t.indexOf("",o);switch((n<0||n>r)&&NR(),t.charAt(n+1)){case"":const r=t.substring(o,n);let e;0===s.length?e=r:(s+=r,e=s,s=""),i.push(e);break;case"":s+=t.substring(o,n),s+="\0";break;case"":s+=t.substring(o,n+1);break;default:NR()}o=n+2}return new ZR(i)}class jD{constructor(e,t){this.seconds=e,this.nanoseconds=t}}class qD{constructor(e,t,n){this.ownerId=e,this.allowTabSynchronization=t,this.leaseTimestampMs=n}}qD.store="owner",qD.key="owner";class VD{constructor(e,t,n){this.userId=e,this.lastAcknowledgedBatchId=t,this.lastStreamToken=n}}VD.store="mutationQueues",VD.keyPath="userId";class BD{constructor(e,t,n,r,i){this.userId=e,this.batchId=t,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i}}BD.store="mutations",BD.keyPath="batchId",BD.userMutationsIndex="userMutationsIndex",BD.userMutationsKeyPath=["userId","batchId"];class WD{constructor(){}static prefixForUser(e){return[e]}static prefixForPath(e,t){return[e,LD(t)]}static key(e,t,n){return[e,LD(t),n]}}WD.store="documentMutations",WD.PLACEHOLDER=new WD;class $D{constructor(e,t){this.path=e,this.readTime=t}}class KD{constructor(e,t){this.path=e,this.version=t}}class zD{constructor(e,t,n,r,i,s){this.unknownDocument=e,this.noDocument=t,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=s}}zD.store="remoteDocuments",zD.readTimeIndex="readTimeIndex",zD.readTimeIndexPath="readTime",zD.collectionReadTimeIndex="collectionReadTimeIndex",zD.collectionReadTimeIndexPath=["parentPath","readTime"];class HD{constructor(e){this.byteSize=e}}HD.store="remoteDocumentGlobal",HD.key="remoteDocumentGlobalKey";class GD{constructor(e,t,n,r,i,s,o){this.targetId=e,this.canonicalId=t,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=s,this.query=o}}GD.store="targets",GD.keyPath="targetId",GD.queryTargetsIndexName="queryTargetsIndex",GD.queryTargetsKeyPath=["canonicalId","targetId"];class QD{constructor(e,t,n){this.targetId=e,this.path=t,this.sequenceNumber=n}}QD.store="targetDocuments",QD.keyPath=["targetId","path"],QD.documentTargetsIndex="documentTargetsIndex",QD.documentTargetsKeyPath=["path","targetId"];class YD{constructor(e,t,n,r){this.highestTargetId=e,this.highestListenSequenceNumber=t,this.lastRemoteSnapshotVersion=n,this.targetCount=r}}YD.key="targetGlobalKey",YD.store="targetGlobal";class JD{constructor(e,t){this.collectionId=e,this.parent=t}}JD.store="collectionParents",JD.keyPath=["collectionId","parent"];class XD{constructor(e,t,n,r){this.clientId=e,this.updateTimeMs=t,this.networkEnabled=n,this.inForeground=r}}XD.store="clientMetadata",XD.keyPath="clientId";class ZD{constructor(e,t,n){this.bundleId=e,this.createTime=t,this.version=n}}ZD.store="bundles",ZD.keyPath="bundleId";class eO{constructor(e,t,n){this.name=e,this.readTime=t,this.bundledQuery=n}}eO.store="namedQueries",eO.keyPath="name";const tO=[VD.store,BD.store,WD.store,zD.store,GD.store,qD.store,YD.store,QD.store,XD.store,HD.store,JD.store,ZD.store,eO.store],nO="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class rO{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}class iO{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(r,i){return this.callbackAttached&&NR(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(i,this.error):this.wrapSuccess(r,this.result):new iO((t,n)=>{this.nextCallback=e=>{this.wrapSuccess(r,e).next(t,n)},this.catchCallback=e=>{this.wrapFailure(i,e).next(t,n)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{var t=e();return t instanceof iO?t:iO.resolve(t)}catch(e){return iO.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):iO.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):iO.reject(t)}static resolve(n){return new iO((e,t)=>{e(n)})}static reject(n){return new iO((e,t)=>{t(n)})}static waitFor(e){return new iO((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=iO.resolve(!1);for(const n of e)t=t.next(e=>e?iO.resolve(e):n());return t}static forEach(e,n){const r=[];return e.forEach((e,t)=>{r.push(n.call(this,e,t))}),this.waitFor(r)}}class sO{constructor(n,e){this.action=n,this.transaction=e,this.aborted=!1,this.It=new DR,this.transaction.oncomplete=()=>{this.It.resolve()},this.transaction.onabort=()=>{e.error?this.It.reject(new cO(n,e.error)):this.It.resolve()},this.transaction.onerror=e=>{var t=pO(e.target.error);this.It.reject(new cO(n,t))}}static open(e,t,n,r){try{return new sO(t,e.transaction(r,n))}catch(e){throw new cO(t,e)}}get At(){return this.It.promise}abort(e){e&&this.It.reject(e),this.aborted||(kR("SimpleDb","Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}store(e){var t=this.transaction.objectStore(e);return new uO(t)}}class oO{constructor(e,t,n){this.name=e,this.version=t,this.Rt=n,12.2===oO.bt(sd())&&SR("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.")}static delete(e){return kR("SimpleDb","Removing database:",e),hO(window.indexedDB.deleteDatabase(e)).toPromise()}static Pt(){if(!dd())return!1;if(oO.vt())return!0;const e=sd(),t=oO.bt(e),n=0<t&&t<10,r=oO.Vt(e),i=0<r&&r<4.5;return!(0<e.indexOf("MSIE ")||0<e.indexOf("Trident/")||0<e.indexOf("Edge/")||n||i)}static vt(){var e;return"undefined"!=typeof process&&"YES"===(null===(e=process.env)||void 0===e?void 0:e.St)}static Dt(e,t){return e.store(t)}static bt(e){const t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=t?t[1].split("_").slice(0,2).join("."):"-1";return Number(n)}static Vt(e){const t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(n)}async Ct(s){return this.db||(kR("SimpleDb","Opening database:",this.name),this.db=await new Promise((n,r)=>{const i=indexedDB.open(this.name,this.version);i.onsuccess=e=>{var t=e.target.result;n(t)},i.onblocked=()=>{r(new cO(s,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=e=>{var t=e.target.error;"VersionError"===t.name?r(new xR(PR.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"===t.name?r(new xR(PR.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: "+t)):r(new cO(s,t))},i.onupgradeneeded=e=>{kR("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',e.oldVersion);var t=e.target.result;this.Rt.Nt(t,i.transaction,e.oldVersion,this.version).next(()=>{kR("SimpleDb","Database upgrade to version "+this.version+" complete")})}})),this.kt&&(this.db.onversionchange=e=>this.kt(e)),this.db}xt(t){this.kt=t,this.db&&(this.db.onversionchange=e=>t(e))}async runTransaction(e,t,n,r){var i="readonly"===t;let s=0;for(;;){++s;try{this.db=await this.Ct(e);const t=sO.open(this.db,e,i?"readonly":"readwrite",n),s=r(t).catch(e=>(t.abort(e),iO.reject(e))).toPromise();return s.catch(()=>{}),await t.At,s}catch(e){const t="FirebaseError"!==e.name&&s<3;if(kR("SimpleDb","Transaction failed with error:",e.message,"Retrying:",t),this.close(),!t)return Promise.reject(e)}}}close(){this.db&&this.db.close(),this.db=void 0}}class aO{constructor(e){this.$t=e,this.Ot=!1,this.Mt=null}get isDone(){return this.Ot}get Ft(){return this.Mt}set cursor(e){this.$t=e}done(){this.Ot=!0}Lt(e){this.Mt=e}delete(){return hO(this.$t.delete())}}class cO extends xR{constructor(e,t){super(PR.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function lO(e){return"IndexedDbTransactionError"===e.name}class uO{constructor(e){this.store=e}put(e,t){let n;return n=void 0!==t?(kR("SimpleDb","PUT",this.store.name,e,t),this.store.put(t,e)):(kR("SimpleDb","PUT",this.store.name,"<auto-key>",e),this.store.put(e)),hO(n)}add(e){return kR("SimpleDb","ADD",this.store.name,e,e),hO(this.store.add(e))}get(t){return hO(this.store.get(t)).next(e=>(kR("SimpleDb","GET",this.store.name,t,e=void 0===e?null:e),e))}delete(e){return kR("SimpleDb","DELETE",this.store.name,e),hO(this.store.delete(e))}count(){return kR("SimpleDb","COUNT",this.store.name),hO(this.store.count())}Bt(e,t){const n=this.cursor(this.options(e,t)),r=[];return this.Ut(n,(e,t)=>{r.push(t)}).next(()=>r)}qt(e,t){kR("SimpleDb","DELETE ALL",this.store.name);const n=this.options(e,t);n.Kt=!1;var r=this.cursor(n);return this.Ut(r,(e,t,n)=>n.delete())}jt(e,t){let n;t?n=e:(n={},t=e);var r=this.cursor(n);return this.Ut(r,t)}Qt(i){const e=this.cursor({});return new iO((n,r)=>{e.onerror=e=>{var t=pO(e.target.error);r(t)},e.onsuccess=e=>{const t=e.target.result;t?i(t.primaryKey,t.value).next(e=>{e?t.continue():n()}):n()}})}Ut(e,s){const o=[];return new iO((i,t)=>{e.onerror=e=>{t(e.target.error)},e.onsuccess=e=>{const t=e.target.result;if(t){const n=new aO(t),r=s(t.primaryKey,t.value,n);if(r instanceof iO){const e=r.catch(e=>(n.done(),iO.reject(e)));o.push(e)}n.isDone?i():null===n.Ft?t.continue():t.continue(n.Ft)}else i()}}).next(()=>iO.waitFor(o))}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){const n=this.store.index(e.index);return e.Kt?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}function hO(e){return new iO((n,r)=>{e.onsuccess=e=>{var t=e.target.result;n(t)},e.onerror=e=>{var t=pO(e.target.error);r(t)}})}let dO=!1;function pO(e){const t=oO.bt(sd());if(12.2<=t&&t<13){const t="An internal error was encountered in the Indexed Database server";if(0<=e.message.indexOf(t)){const e=new xR("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 dO||(dO=!0,setTimeout(()=>{throw e},0)),e}}return e}class fO extends rO{constructor(e,t){super(),this.Wt=e,this.currentSequenceNumber=t}}function gO(e,t){var n=e;return oO.Dt(n.Wt,t)}class mO{constructor(e,t,n,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(e,t){var n=t.mutationResults;for(let r=0;r<this.mutations.length;r++){const i=this.mutations[r];i.key.isEqual(e.key)&&Ax(i,e,n[r])}}applyToLocalView(e){for(const t of this.baseMutations)t.key.isEqual(e.key)&&Nx(t,e,this.localWriteTime);for(const n of this.mutations)n.key.isEqual(e.key)&&Nx(n,e,this.localWriteTime)}applyToLocalDocumentSet(r){this.mutations.forEach(e=>{const t=r.get(e.key),n=t;this.applyToLocalView(n),t.isValidDocument()||n.convertToNoDocument(GR.min())})}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),Jx())}isEqual(e){return this.batchId===e.batchId&&KR(this.mutations,e.mutations,(e,t)=>Rx(e,t))&&KR(this.baseMutations,e.baseMutations,(e,t)=>Rx(e,t))}}class vO{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(e,t,n){RR(e.mutations.length===n.length);let r=Qx;var i=e.mutations;for(let s=0;s<i.length;s++)r=r.insert(i[s].key,n[s].version);return new vO(e,t,n,r)}}class yO{constructor(e,t,n,r,i=GR.min(),s=GR.min(),o=rP.EMPTY_BYTE_STRING){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=o}withSequenceNumber(e){return new yO(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)}withResumeToken(e,t){return new yO(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e)}withLastLimboFreeSnapshotVersion(e){return new yO(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken)}}class _O{constructor(e){this.Gt=e}}function wO(e,t){if(t.document)return TD(e.Gt,t.document,!!t.hasCommittedMutations);if(t.noDocument){const e=pP.fromSegments(t.noDocument.path),n=kO(t.noDocument.readTime),r=AP.newNoDocument(e,n);return t.hasCommittedMutations?r.setHasCommittedMutations():r}if(t.unknownDocument){const e=pP.fromSegments(t.unknownDocument.path),i=kO(t.unknownDocument.version);return AP.newUnknownDocument(e,i)}return NR()}function bO(e,t,n){var r=IO(n),i=t.key.path.popLast().toArray();if(t.isFoundDocument()){const s={name:mD(n=e.Gt,(e=t).key),fields:e.data.value.mapValue.fields,updateTime:hD(n,e.version.toTimestamp())},o=t.hasCommittedMutations;return new zD(null,null,s,o,r,i)}if(t.isNoDocument()){const a=t.key.path.toArray(),s=EO(t.version),c=t.hasCommittedMutations;return new zD(null,new $D(a,s),null,c,r,i)}if(t.isUnknownDocument()){const a=t.key.path.toArray(),s=EO(t.version);return new zD(new KD(a,s),null,null,!0,r,i)}return NR()}function IO(e){var t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function TO(e){var t=new HR(e[0],e[1]);return GR.fromTimestamp(t)}function EO(e){var t=e.toTimestamp();return new jD(t.seconds,t.nanoseconds)}function kO(e){var t=new HR(e.seconds,e.nanoseconds);return GR.fromTimestamp(t)}function SO(t,e){const n=(e.baseMutations||[]).map(e=>kD(t.Gt,e));for(let s=0;s<e.mutations.length-1;++s){const n=e.mutations[s];if(s+1<e.mutations.length&&void 0!==e.mutations[s+1].transform){const r=e.mutations[s+1];n.updateTransforms=r.transform.fieldTransforms,e.mutations.splice(s+1,1),++s}}const r=e.mutations.map(e=>kD(t.Gt,e)),i=HR.fromMillis(e.localWriteTimeMs);return new mO(e.batchId,i,n,r)}function CO(e){var t,n=kO(e.readTime),r=void 0!==e.lastLimboFreeSnapshotVersion?kO(e.lastLimboFreeSnapshotVersion):GR.min();let i;return i=void 0!==e.query.documents?(RR(1===(t=e.query).documents.length),rx(YP(_D(t.documents[0])))):rx(AD(e.query)),new yO(i,e.targetId,0,e.lastListenSequenceNumber,n,r,rP.fromBase64String(e.resumeToken))}function AO(e,t){var n=EO(t.snapshotVersion),r=EO(t.lastLimboFreeSnapshotVersion),i=(DP(t.target)?SD:CD)(e.Gt,t.target),s=t.resumeToken.toBase64();return new GD(t.targetId,PP(t.target),n,s,t.sequenceNumber,r,i)}function NO(e){var t=AD({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?ix(t,t.limit,"L"):t}class RO{getBundleMetadata(e,t){return PO(e).get(t).next(e=>{if(e)return{id:(t=e).bundleId,createTime:kO(t.createTime),version:t.version};var t})}saveBundleMetadata(e,t){return PO(e).put({bundleId:(n=t).id,createTime:EO(pD(n.createTime)),version:n.version});var n}getNamedQuery(e,t){return xO(e).get(t).next(e=>{if(e)return{name:(t=e).name,query:NO(t.bundledQuery),readTime:kO(t.readTime)};var t})}saveNamedQuery(e,t){return xO(e).put({name:(t=t).name,readTime:EO(pD(t.readTime)),bundledQuery:t.bundledQuery})}}function PO(e){return gO(e,ZD.store)}function xO(e){return gO(e,eO.store)}class DO{constructor(){this.zt=new OO}addToCollectionParentIndex(e,t){return this.zt.add(t),iO.resolve()}getCollectionParents(e,t){return iO.resolve(this.zt.getEntries(t))}}class OO{constructor(){this.index={}}add(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new Kx(ZR.comparator),i=!r.has(n);return this.index[t]=r.add(n),i}has(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t];return r&&r.has(n)}getEntries(e){return(this.index[e]||new Kx(ZR.comparator)).toArray()}}class MO{constructor(){this.Ht=new OO}addToCollectionParentIndex(e,t){if(this.Ht.has(t))return iO.resolve();var n=t.lastSegment(),r=t.popLast();e.addOnCommittedListener(()=>{this.Ht.add(t)});r={collectionId:n,parent:LD(r)};return LO(e).put(r)}getCollectionParents(e,n){const r=[],t=IDBKeyRange.bound([n,""],[zR(n),""],!1,!0);return LO(e).Bt(t).next(e=>{for(const t of e){if(t.collectionId!==n)break;r.push(UD(t.parent))}return r})}}function LO(e){return gO(e,JD.store)}const FO={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class UO{constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}static withCacheSize(e){return new UO(e,UO.DEFAULT_COLLECTION_PERCENTILE,UO.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}function jO(e,t,n){const r=e.store(BD.store),i=e.store(WD.store),s=[],o=IDBKeyRange.only(n.batchId);let a=0;const c=r.jt({range:o},(e,t,n)=>(a++,n.delete()));s.push(c.next(()=>{RR(1===a)}));const l=[];for(const e of n.mutations){const r=WD.key(t,e.key.path,n.batchId);s.push(i.delete(r)),l.push(e.key)}return iO.waitFor(s).next(()=>l)}function qO(e){if(!e)return 0;let t;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw NR();t=e.noDocument}return JSON.stringify(t).length}UO.DEFAULT_COLLECTION_PERCENTILE=10,UO.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,UO.DEFAULT=new UO(41943040,UO.DEFAULT_COLLECTION_PERCENTILE,UO.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),UO.DISABLED=new UO(-1,0,0);class VO{constructor(e,t,n,r){this.userId=e,this.k=t,this.Jt=n,this.referenceDelegate=r,this.Yt={}}static Xt(e,t,n,r){RR(""!==e.uid);var i=e.isAuthenticated()?e.uid:"";return new VO(i,t,n,r)}checkEmpty(e){let r=!0;var t=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return WO(e).jt({index:BD.userMutationsIndex,range:t},(e,t,n)=>{r=!1,n.done()}).next(()=>r)}addMutationBatch(u,h,d,p){const f=$O(u),g=WO(u);return g.add({}).next(e=>{RR("number"==typeof e);const t=new mO(e,h,d,p),n=(i=this.k,s=this.userId,o=t,a=o.baseMutations.map(e=>ED(i.Gt,e)),c=o.mutations.map(e=>ED(i.Gt,e)),new BD(s,o.batchId,o.localWriteTime.toMillis(),a,c)),r=[];var i,s,o,a,c;let l=new Kx((e,t)=>$R(e.canonicalString(),t.canonicalString()));for(const u of p){const h=WD.key(this.userId,u.key.path,e);l=l.add(u.key.path.popLast()),r.push(g.put(n)),r.push(f.put(h,WD.PLACEHOLDER))}return l.forEach(e=>{r.push(this.Jt.addToCollectionParentIndex(u,e))}),u.addOnCommittedListener(()=>{this.Yt[e]=t.keys()}),iO.waitFor(r).next(()=>t)})}lookupMutationBatch(e,t){return WO(e).get(t).next(e=>e?(RR(e.userId===this.userId),SO(this.k,e)):null)}Zt(e,n){return this.Yt[n]?iO.resolve(this.Yt[n]):this.lookupMutationBatch(e,n).next(e=>{if(e){var t=e.keys();return this.Yt[n]=t}return null})}getNextMutationBatchAfterBatchId(e,t){const r=t+1,n=IDBKeyRange.lowerBound([this.userId,r]);let i=null;return WO(e).jt({index:BD.userMutationsIndex,range:n},(e,t,n)=>{t.userId===this.userId&&(RR(t.batchId>=r),i=SO(this.k,t)),n.done()}).next(()=>i)}getHighestUnacknowledgedBatchId(e){var t=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let r=-1;return WO(e).jt({index:BD.userMutationsIndex,range:t,reverse:!0},(e,t,n)=>{r=t.batchId,n.done()}).next(()=>r)}getAllMutationBatches(e){var t=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return WO(e).Bt(BD.userMutationsIndex,t).next(e=>e.map(e=>SO(this.k,e)))}getAllMutationBatchesAffectingDocumentKey(o,a){const e=WD.prefixForPath(this.userId,a.path),t=IDBKeyRange.lowerBound(e),c=[];return $O(o).jt({range:t},(e,t,n)=>{var[r,i,s]=e,i=UD(i);if(r===this.userId&&a.path.isEqual(i))return WO(o).get(s).next(e=>{if(!e)throw NR();RR(e.userId===this.userId),c.push(SO(this.k,e))});n.done()}).next(()=>c)}getAllMutationBatchesAffectingDocumentKeys(t,e){let a=new Kx($R);const n=[];return e.forEach(o=>{var e=WD.prefixForPath(this.userId,o.path),e=IDBKeyRange.lowerBound(e),e=$O(t).jt({range:e},(e,t,n)=>{var[r,i,s]=e,i=UD(i);r===this.userId&&o.path.isEqual(i)?a=a.add(s):n.done()});n.push(e)}),iO.waitFor(n).next(()=>this.te(t,a))}getAllMutationBatchesAffectingQuery(e,t){const o=t.path,a=o.length+1,n=WD.prefixForPath(this.userId,o),r=IDBKeyRange.lowerBound(n);let c=new Kx($R);return $O(e).jt({range:r},(e,t,n)=>{var[r,i,s]=e,i=UD(i);r===this.userId&&o.isPrefixOf(i)?i.length===a&&(c=c.add(s)):n.done()}).next(()=>this.te(e,c))}te(t,e){const n=[],r=[];return e.forEach(e=>{r.push(WO(t).get(e).next(e=>{if(null===e)throw NR();RR(e.userId===this.userId),n.push(SO(this.k,e))}))}),iO.waitFor(r).next(()=>n)}removeMutationBatch(t,n){return jO(t.Wt,this.userId,n).next(e=>(t.addOnCommittedListener(()=>{this.ee(n.batchId)}),iO.forEach(e,e=>this.referenceDelegate.markPotentiallyOrphaned(t,e))))}ee(e){delete this.Yt[e]}performConsistencyCheck(n){return this.checkEmpty(n).next(e=>{if(!e)return iO.resolve();const t=IDBKeyRange.lowerBound(WD.prefixForUser(this.userId)),r=[];return $O(n).jt({range:t},(e,t,n)=>{if(e[0]===this.userId){const t=UD(e[1]);r.push(t)}else n.done()}).next(()=>{RR(0===r.length)})})}containsKey(e,t){return BO(e,this.userId,t)}ne(e){return KO(e).get(this.userId).next(e=>e||new VD(this.userId,-1,""))}}function BO(e,s,t){const n=WD.prefixForPath(s,t.path),o=n[1],r=IDBKeyRange.lowerBound(n);let a=!1;return $O(e).jt({range:r,Kt:!0},(e,t,n)=>{var[r,i]=e;r===s&&i===o&&(a=!0),n.done()}).next(()=>a)}function WO(e){return gO(e,BD.store)}function $O(e){return gO(e,WD.store)}function KO(e){return gO(e,VD.store)}class zO{constructor(e){this.se=e}next(){return this.se+=2,this.se}static ie(){return new zO(0)}static re(){return new zO(-1)}}class HO{constructor(e,t){this.referenceDelegate=e,this.k=t}allocateTargetId(n){return this.oe(n).next(e=>{const t=new zO(e.highestTargetId);return e.highestTargetId=t.next(),this.ce(n,e).next(()=>e.highestTargetId)})}getLastRemoteSnapshotVersion(e){return this.oe(e).next(e=>GR.fromTimestamp(new HR(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(e){return this.oe(e).next(e=>e.highestListenSequenceNumber)}setTargetsMetadata(t,n,r){return this.oe(t).next(e=>(e.highestListenSequenceNumber=n,r&&(e.lastRemoteSnapshotVersion=r.toTimestamp()),n>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=n),this.ce(t,e)))}addTargetData(t,n){return this.ae(t,n).next(()=>this.oe(t).next(e=>(e.targetCount+=1,this.ue(n,e),this.ce(t,e))))}updateTargetData(e,t){return this.ae(e,t)}removeTargetData(t,e){return this.removeMatchingKeysForTargetId(t,e.targetId).next(()=>GO(t).delete(e.targetId)).next(()=>this.oe(t)).next(e=>(RR(0<e.targetCount),--e.targetCount,this.ce(t,e)))}removeTargets(r,i,s){let o=0;const a=[];return GO(r).jt((e,t)=>{var n=CO(t);n.sequenceNumber<=i&&null===s.get(n.targetId)&&(o++,a.push(this.removeTargetData(r,n)))}).next(()=>iO.waitFor(a)).next(()=>o)}forEachTarget(e,r){return GO(e).jt((e,t)=>{var n=CO(t);r(n)})}oe(e){return QO(e).get(YD.key).next(e=>(RR(null!==e),e))}ce(e,t){return QO(e).put(YD.key,t)}ae(e,t){return GO(e).put(AO(this.k,t))}ue(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.oe(e).next(e=>e.targetCount)}getTargetData(e,i){var t=PP(i),t=IDBKeyRange.bound([t,Number.NEGATIVE_INFINITY],[t,Number.POSITIVE_INFINITY]);let s=null;return GO(e).jt({range:t,index:GD.queryTargetsIndexName},(e,t,n)=>{var r=CO(t);xP(i,r.target)&&(s=r,n.done())}).next(()=>s)}addMatchingKeys(n,e,r){const i=[],s=YO(n);return e.forEach(e=>{var t=LD(e.path);i.push(s.put(new QD(r,t))),i.push(this.referenceDelegate.addReference(n,r,e))}),iO.waitFor(i)}removeMatchingKeys(n,e,r){const i=YO(n);return iO.forEach(e,e=>{var t=LD(e.path);return iO.waitFor([i.delete([r,t]),this.referenceDelegate.removeReference(n,r,e)])})}removeMatchingKeysForTargetId(e,t){const n=YO(e),r=IDBKeyRange.bound([t],[t+1],!1,!0);return n.delete(r)}getMatchingKeysForTargetId(e,t){const n=IDBKeyRange.bound([t],[t+1],!1,!0),r=YO(e);let i=Jx();return r.jt({range:n,Kt:!0},(e,t,n)=>{var r=UD(e[1]),r=new pP(r);i=i.add(r)}).next(()=>i)}containsKey(e,t){var n=LD(t.path),n=IDBKeyRange.bound([n],[zR(n)],!1,!0);let r=0;return YO(e).jt({index:QD.documentTargetsIndex,Kt:!0,range:n},([e],t,n)=>{0!==e&&(r++,n.done())}).next(()=>0<r)}Et(e,t){return GO(e).get(t).next(e=>e?CO(e):null)}}function GO(e){return gO(e,GD.store)}function QO(e){return gO(e,YD.store)}function YO(e){return gO(e,QD.store)}async function JO(e){if(e.code!==PR.FAILED_PRECONDITION||e.message!==nO)throw e;kR("LocalStore","Unexpectedly lost primary lease")}function XO([e,t],[n,r]){var i=$R(e,n);return 0===i?$R(t,r):i}class ZO{constructor(e){this.he=e,this.buffer=new Kx(XO),this.le=0}fe(){return++this.le}de(e){var t=[e,this.fe()];if(this.buffer.size<this.he)this.buffer=this.buffer.add(t);else{const e=this.buffer.last();XO(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class e1{constructor(e,t){this.garbageCollector=e,this.asyncQueue=t,this.we=!1,this._e=null}start(e){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.me(e)}stop(){this._e&&(this._e.cancel(),this._e=null)}get started(){return null!==this._e}me(e){var t=this.we?3e5:6e4;kR("LruGarbageCollector",`Garbage collection scheduled in ${t}ms`),this._e=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",t,async()=>{this._e=null,this.we=!0;try{await e.collectGarbage(this.garbageCollector)}catch(e){lO(e)?kR("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e):await JO(e)}await this.me(e)})}}class t1{constructor(e,t){this.ge=e,this.params=t}calculateTargetCount(e,t){return this.ge.ye(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return iO.resolve(BR.I);const n=new ZO(t);return this.ge.forEachTarget(e,e=>n.de(e.sequenceNumber)).next(()=>this.ge.pe(e,e=>n.de(e))).next(()=>n.maxValue)}removeTargets(e,t,n){return this.ge.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.ge.removeOrphanedDocuments(e,t)}collect(t,n){return-1===this.params.cacheSizeCollectionThreshold?(kR("LruGarbageCollector","Garbage collection skipped; disabled"),iO.resolve(FO)):this.getCacheSize(t).next(e=>e<this.params.cacheSizeCollectionThreshold?(kR("LruGarbageCollector",`Garbage collection skipped; Cache size ${e} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),FO):this.Te(t,n))}getCacheSize(e){return this.ge.getCacheSize(e)}Te(t,n){let r,i,s,o,a,c,l;const u=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next(e=>(i=e>this.params.maximumSequenceNumbersToCollect?(kR("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${e}`),this.params.maximumSequenceNumbersToCollect):e,o=Date.now(),this.nthSequenceNumber(t,i))).next(e=>(r=e,a=Date.now(),this.removeTargets(t,r,n))).next(e=>(s=e,c=Date.now(),this.removeOrphanedDocuments(t,r))).next(e=>(l=Date.now(),ER()<=$h.DEBUG&&kR("LruGarbageCollector",`LRU Garbage Collection\n\tCounted targets in ${o-u}ms\n\tDetermined least recently used ${i} in `+(a-o)+"ms\n"+`\tRemoved ${s} targets in `+(c-a)+"ms\n"+`\tRemoved ${e} documents in `+(l-c)+"ms\n"+`Total Duration: ${l-u}ms`),iO.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:s,documentsRemoved:e})))}}class n1{constructor(e,t){this.db=e,this.garbageCollector=(e=this,t=t,new t1(e,t))}ye(e){const n=this.Ee(e);return this.db.getTargetCache().getTargetCount(e).next(t=>n.next(e=>t+e))}Ee(e){let t=0;return this.pe(e,e=>{t++}).next(()=>t)}forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}pe(e,n){return this.Ie(e,(e,t)=>n(t))}addReference(e,t,n){return r1(e,n)}removeReference(e,t,n){return r1(e,n)}removeTargets(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}markPotentiallyOrphaned(e,t){return r1(e,t)}Ae(t,n){let r=!1;return KO(t).Qt(e=>BO(t,e,n).next(e=>(e&&(r=!0),iO.resolve(!e)))).next(()=>r)}removeOrphanedDocuments(n,r){const i=this.db.getRemoteDocumentCache().newChangeBuffer(),s=[];let o=0;return this.Ie(n,(t,e)=>{if(e<=r){const r=this.Ae(n,t).next(e=>{if(!e)return o++,i.getEntry(n,t).next(()=>(i.removeEntry(t),YO(n).delete([0,LD(t.path)])))});s.push(r)}}).next(()=>iO.waitFor(s)).next(()=>i.apply(n)).next(()=>o)}removeTarget(e,t){var n=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,n)}updateLimboDocument(e,t){return r1(e,t)}Ie(e,r){const t=YO(e);let i,s=BR.I;return t.jt({index:QD.documentTargetsIndex},([e],{path:t,sequenceNumber:n})=>{0===e?(s!==BR.I&&r(new pP(UD(i)),s),s=n,i=t):s=BR.I}).next(()=>{s!==BR.I&&r(new pP(UD(i)),s)})}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function r1(e,t){return YO(e).put((t=t,e=e.currentSequenceNumber,new QD(0,LD(t.path),e)))}class i1{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={}}get(e){const t=this.mapKeyFn(e),n=this.inner[t];if(void 0!==n)for(const[t,r]of n)if(this.equalsFn(t,e))return r}has(e){return void 0!==this.get(e)}set(t,n){const e=this.mapKeyFn(t),r=this.inner[e];if(void 0!==r){for(let e=0;e<r.length;e++)if(this.equalsFn(r[e][0],t))return void(r[e]=[t,n]);r.push([t,n])}else this.inner[e]=[[t,n]]}delete(e){const 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),!0;return!1}forEach(r){YR(this.inner,(e,t)=>{for(const[e,n]of t)r(e,n)})}isEmpty(){return JR(this.inner)}}class s1{constructor(){this.changes=new i1(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}getReadTime(e){var t=this.changes.get(e);return t?t.readTime:GR.min()}addEntry(e,t){this.assertNotApplied(),this.changes.set(e.key,{document:e,readTime:t})}removeEntry(e,t=null){this.assertNotApplied(),this.changes.set(e,{document:AP.newInvalidDocument(e),readTime:t})}getEntry(e,t){this.assertNotApplied();var n=this.changes.get(t);return void 0!==n?iO.resolve(n.document):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 o1{constructor(e,t){this.k=e,this.Jt=t}addEntry(e,t,n){return l1(e).put(u1(t),n)}removeEntry(e,t){const n=l1(e),r=u1(t);return n.delete(r)}updateMetadata(t,n){return this.getMetadata(t).next(e=>(e.byteSize+=n,this.Re(t,e)))}getEntry(e,t){return l1(e).get(u1(t)).next(e=>this.be(t,e))}Pe(e,t){return l1(e).get(u1(t)).next(e=>({document:this.be(t,e),size:qO(e)}))}getEntries(e,t){let r=Hx;return this.ve(e,t,(e,t)=>{var n=this.be(e,t);r=r.insert(e,n)}).next(()=>r)}Ve(e,t){let r=Hx,i=new Bx(pP.comparator);return this.ve(e,t,(e,t)=>{var n=this.be(e,t);r=r.insert(e,n),i=i.insert(e,qO(t))}).next(()=>({documents:r,Se:i}))}ve(e,t,i){if(t.isEmpty())return iO.resolve();const n=IDBKeyRange.bound(t.first().path.toArray(),t.last().path.toArray()),s=t.getIterator();let o=s.getNext();return l1(e).jt({range:n},(e,t,n)=>{for(var r=pP.fromSegments(e);o&&pP.comparator(o,r)<0;)i(o,null),o=s.getNext();o&&o.isEqual(r)&&(i(o,t),o=s.hasNext()?s.getNext():null),o?n.Lt(o.path.toArray()):n.done()}).next(()=>{for(;o;)i(o,null),o=s.hasNext()?s.getNext():null})}getDocumentsMatchingQuery(e,i,t){let s=Hx;const o=i.path.length+1,n={};if(t.isEqual(GR.min())){const e=i.path.toArray();n.range=IDBKeyRange.lowerBound(e)}else{const e=i.path.toArray(),s=IO(t);n.range=IDBKeyRange.lowerBound([e,s],!0),n.index=zD.collectionReadTimeIndex}return l1(e).jt(n,(e,t,n)=>{var r;e.length===o&&(r=wO(this.k,t),i.path.isPrefixOf(r.key.path)?cx(i,r)&&(s=s.insert(r.key,r)):n.done())}).next(()=>s)}newChangeBuffer(e){return new a1(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next(e=>e.byteSize)}getMetadata(e){return c1(e).get(HD.key).next(e=>(RR(!!e),e))}Re(e,t){return c1(e).put(HD.key,t)}be(e,t){if(t){const e=wO(this.k,t);if(!e.isNoDocument()||!e.version.isEqual(GR.min()))return e}return AP.newInvalidDocument(e)}}class a1 extends s1{constructor(e,t){super(),this.De=e,this.trackRemovals=t,this.Ce=new i1(e=>e.toString(),(e,t)=>e.isEqual(t))}applyChanges(s){const o=[];let a=0,c=new Kx((e,t)=>$R(e.canonicalString(),t.canonicalString()));return this.changes.forEach((e,t)=>{var n=this.Ce.get(e);if(t.document.isValidDocument()){var r=bO(this.De.k,t.document,this.getReadTime(e));c=c.add(e.path.popLast());var i=qO(r);a+=i-n,o.push(this.De.addEntry(s,e,r))}else if(a-=n,this.trackRemovals){const a=bO(this.De.k,AP.newNoDocument(e,GR.min()),this.getReadTime(e));o.push(this.De.addEntry(s,e,a))}else o.push(this.De.removeEntry(s,e))}),c.forEach(e=>{o.push(this.De.Jt.addToCollectionParentIndex(s,e))}),o.push(this.De.updateMetadata(s,a)),iO.waitFor(o)}getFromCache(e,t){return this.De.Pe(e,t).next(e=>(this.Ce.set(t,e.size),e.document))}getAllFromCache(e,t){return this.De.Ve(e,t).next(({documents:e,Se:t})=>(t.forEach((e,t)=>{this.Ce.set(e,t)}),e))}}function c1(e){return gO(e,HD.store)}function l1(e){return gO(e,zD.store)}function u1(e){return e.path.toArray()}class h1{constructor(e){this.k=e}Nt(t,n,e,r){RR(e<r&&0<=e&&r<=11);const i=new sO("createOrUpgrade",n);var s;e<1&&1<=r&&(t.createObjectStore(qD.store),(s=t).createObjectStore(VD.store,{keyPath:VD.keyPath}),s.createObjectStore(BD.store,{keyPath:BD.keyPath,autoIncrement:!0}).createIndex(BD.userMutationsIndex,BD.userMutationsKeyPath,{unique:!0}),s.createObjectStore(WD.store),d1(t),t.createObjectStore(zD.store));let o=iO.resolve();return e<3&&3<=r&&(0!==e&&((s=t).deleteObjectStore(QD.store),s.deleteObjectStore(GD.store),s.deleteObjectStore(YD.store),d1(t)),o=o.next(()=>function(){const e=i.store(YD.store),t=new YD(0,0,GR.min().toTimestamp(),0);return e.put(YD.key,t)}())),e<4&&4<=r&&(0!==e&&(o=o.next(()=>function(r,i){return i.store(BD.store).Bt().next(e=>{r.deleteObjectStore(BD.store),r.createObjectStore(BD.store,{keyPath:BD.keyPath,autoIncrement:!0}).createIndex(BD.userMutationsIndex,BD.userMutationsKeyPath,{unique:!0});const t=i.store(BD.store),n=e.map(e=>t.put(e));return iO.waitFor(n)})}(t,i))),o=o.next(()=>{t.createObjectStore(XD.store,{keyPath:XD.keyPath})})),e<5&&5<=r&&(o=o.next(()=>this.Ne(i))),e<6&&6<=r&&(o=o.next(()=>(t.createObjectStore(HD.store),this.ke(i)))),e<7&&7<=r&&(o=o.next(()=>this.xe(i))),e<8&&8<=r&&(o=o.next(()=>this.$e(t,i))),e<9&&9<=r&&(o=o.next(()=>{var e;(e=t).objectStoreNames.contains("remoteDocumentChanges")&&e.deleteObjectStore("remoteDocumentChanges"),function(){const e=n.objectStore(zD.store);e.createIndex(zD.readTimeIndex,zD.readTimeIndexPath,{unique:!1}),e.createIndex(zD.collectionReadTimeIndex,zD.collectionReadTimeIndexPath,{unique:!1})}()})),e<10&&10<=r&&(o=o.next(()=>this.Oe(i))),e<11&&11<=r&&(o=o.next(()=>{t.createObjectStore(ZD.store,{keyPath:ZD.keyPath}),t.createObjectStore(eO.store,{keyPath:eO.keyPath})})),o}ke(t){let n=0;return t.store(zD.store).jt((e,t)=>{n+=qO(t)}).next(()=>{var e=new HD(n);return t.store(HD.store).put(HD.key,e)})}Ne(r){const e=r.store(VD.store),t=r.store(BD.store);return e.Bt().next(e=>iO.forEach(e,n=>{var e=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return t.Bt(BD.userMutationsIndex,e).next(e=>iO.forEach(e,e=>{RR(e.userId===n.userId);var t=SO(this.k,e);return jO(r,n.userId,t).next(()=>{})}))}))}xe(e){const o=e.store(QD.store),t=e.store(zD.store);return e.store(YD.store).get(YD.key).next(i=>{const s=[];return t.jt((e,t)=>{const n=new ZR(e),r=[0,LD(n)];s.push(o.get(r).next(e=>e?iO.resolve():(e=>o.put(new QD(0,LD(e),i.highestListenSequenceNumber)))(n)))}).next(()=>iO.waitFor(s))})}$e(e,t){e.createObjectStore(JD.store,{keyPath:JD.keyPath});const n=t.store(JD.store),r=new OO,i=e=>{if(r.add(e)){const t=e.lastSegment(),r=e.popLast();return n.put({collectionId:t,parent:LD(r)})}};return t.store(zD.store).jt({Kt:!0},(e,t)=>{const n=new ZR(e);return i(n.popLast())}).next(()=>t.store(WD.store).jt({Kt:!0},([,e],t)=>{const n=UD(e);return i(n.popLast())}))}Oe(e){const r=e.store(GD.store);return r.jt((e,t)=>{var n=CO(t),n=AO(this.k,n);return r.put(n)})}}function d1(e){e.createObjectStore(QD.store,{keyPath:QD.keyPath}).createIndex(QD.documentTargetsIndex,QD.documentTargetsKeyPath,{unique:!0}),e.createObjectStore(GD.store,{keyPath:GD.keyPath}).createIndex(GD.queryTargetsIndexName,GD.queryTargetsKeyPath,{unique:!0}),e.createObjectStore(YD.store)}const p1="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.";class f1{constructor(e,t,n,r,i,s,o,a,c,l){if(this.allowTabSynchronization=e,this.persistenceKey=t,this.clientId=n,this.Me=i,this.window=s,this.document=o,this.Fe=c,this.Le=l,this.Be=null,this.Ue=!1,this.isPrimary=!1,this.networkEnabled=!0,this.qe=null,this.inForeground=!1,this.Ke=null,this.je=null,this.Qe=Number.NEGATIVE_INFINITY,this.We=e=>Promise.resolve(),!f1.Pt())throw new xR(PR.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new n1(this,r),this.Ge=t+"main",this.k=new _O(a),this.ze=new oO(this.Ge,11,new h1(this.k)),this.He=new HO(this.referenceDelegate,this.k),this.Jt=new MO,this.Je=(t=this.k,a=this.Jt,new o1(t,a)),this.Ye=new RO,this.window&&this.window.localStorage?this.Xe=this.window.localStorage:(this.Xe=null,!1===l&&SR("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.Ze().then(()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new xR(PR.FAILED_PRECONDITION,p1);return this.tn(),this.en(),this.nn(),this.runTransaction("getHighestListenSequenceNumber","readonly",e=>this.He.getHighestSequenceNumber(e))}).then(e=>{this.Be=new BR(e,this.Fe)}).then(()=>{this.Ue=!0}).catch(e=>(this.ze&&this.ze.close(),Promise.reject(e)))}sn(t){return this.We=async e=>{if(this.started)return t(e)},t(this.isPrimary)}setDatabaseDeletedListener(t){this.ze.xt(async e=>{null===e.newVersion&&await t()})}setNetworkEnabled(e){this.networkEnabled!==e&&(this.networkEnabled=e,this.Me.enqueueAndForget(async()=>{this.started&&await this.Ze()}))}Ze(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",t=>m1(t).put(new XD(this.clientId,Date.now(),this.networkEnabled,this.inForeground)).next(()=>{if(this.isPrimary)return this.rn(t).next(e=>{e||(this.isPrimary=!1,this.Me.enqueueRetryable(()=>this.We(!1)))})}).next(()=>this.on(t)).next(e=>this.isPrimary&&!e?this.cn(t).next(()=>!1):!!e&&this.an(t).next(()=>!0))).catch(e=>{if(lO(e))return kR("IndexedDbPersistence","Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return kR("IndexedDbPersistence","Releasing owner lease after error during lease refresh",e),!1}).then(e=>{this.isPrimary!==e&&this.Me.enqueueRetryable(()=>this.We(e)),this.isPrimary=e})}rn(e){return g1(e).get(qD.key).next(e=>iO.resolve(this.un(e)))}hn(e){return m1(e).delete(this.clientId)}async ln(){if(this.isPrimary&&!this.fn(this.Qe,18e5)){this.Qe=Date.now();var e=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",e=>{const r=gO(e,XD.store);return r.Bt().next(e=>{const t=this.dn(e,18e5),n=e.filter(e=>-1===t.indexOf(e));return iO.forEach(n,e=>r.delete(e.clientId)).next(()=>n)})}).catch(()=>[]);if(this.Xe)for(const t of e)this.Xe.removeItem(this.wn(t.clientId))}}nn(){this.je=this.Me.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.Ze().then(()=>this.ln()).then(()=>this.nn()))}un(e){return!!e&&e.ownerId===this.clientId}on(t){return this.Le?iO.resolve(!0):g1(t).get(qD.key).next(e=>{if(null!==e&&this.fn(e.leaseTimestampMs,5e3)&&!this._n(e.ownerId)){if(this.un(e)&&this.networkEnabled)return!0;if(!this.un(e)){if(!e.allowTabSynchronization)throw new xR(PR.FAILED_PRECONDITION,p1);return!1}}return!(!this.networkEnabled||!this.inForeground)||m1(t).Bt().next(e=>void 0===this.dn(e,5e3).find(e=>{if(this.clientId!==e.clientId){var 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&&kR("IndexedDbPersistence",`Client ${e?"is":"is not"} eligible for a primary lease.`),e))}async shutdown(){this.Ue=!1,this.mn(),this.je&&(this.je.cancel(),this.je=null),this.gn(),this.yn(),await this.ze.runTransaction("shutdown","readwrite",[qD.store,XD.store],e=>{const t=new fO(e,BR.I);return this.cn(t).next(()=>this.hn(t))}),this.ze.close(),this.pn()}dn(e,t){return e.filter(e=>this.fn(e.updateTimeMs,t)&&!this._n(e.clientId))}Tn(){return this.runTransaction("getActiveClients","readonly",e=>m1(e).Bt().next(e=>this.dn(e,18e5).map(e=>e.clientId)))}get started(){return this.Ue}getMutationQueue(e){return VO.Xt(e,this.k,this.Jt,this.referenceDelegate)}getTargetCache(){return this.He}getRemoteDocumentCache(){return this.Je}getIndexManager(){return this.Jt}getBundleCache(){return this.Ye}runTransaction(t,n,r){kR("IndexedDbPersistence","Starting transaction:",t);let i;return this.ze.runTransaction(t,"readonly"===n?"readonly":"readwrite",tO,e=>(i=new fO(e,this.Be?this.Be.next():BR.I),"readwrite-primary"===n?this.rn(i).next(e=>!!e||this.on(i)).next(e=>{if(!e)throw SR(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.Me.enqueueRetryable(()=>this.We(!1)),new xR(PR.FAILED_PRECONDITION,nO);return r(i)}).next(e=>this.an(i).next(()=>e)):this.En(i).next(()=>r(i)))).then(e=>(i.raiseOnCommittedEvent(),e))}En(e){return g1(e).get(qD.key).next(e=>{if(null!==e&&this.fn(e.leaseTimestampMs,5e3)&&!this._n(e.ownerId)&&!this.un(e)&&!(this.Le||this.allowTabSynchronization&&e.allowTabSynchronization))throw new xR(PR.FAILED_PRECONDITION,p1)})}an(e){var t=new qD(this.clientId,this.allowTabSynchronization,Date.now());return g1(e).put(qD.key,t)}static Pt(){return oO.Pt()}cn(e){const t=g1(e);return t.get(qD.key).next(e=>this.un(e)?(kR("IndexedDbPersistence","Releasing primary lease."),t.delete(qD.key)):iO.resolve())}fn(e,t){var n=Date.now();return!(e<n-t||n<e&&(SR(`Detected an update time that is in the future: ${e} > ${n}`),1))}tn(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Ke=()=>{this.Me.enqueueAndForget(()=>(this.inForeground="visible"===this.document.visibilityState,this.Ze()))},this.document.addEventListener("visibilitychange",this.Ke),this.inForeground="visible"===this.document.visibilityState)}gn(){this.Ke&&(this.document.removeEventListener("visibilitychange",this.Ke),this.Ke=null)}en(){var e;"function"==typeof(null===(e=this.window)||void 0===e?void 0:e.addEventListener)&&(this.qe=()=>{this.mn(),!ad()&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")&&navigator.appVersion.match(/Version\/1[45]/)&&this.Me.enterRestrictedMode(!0),this.Me.enqueueAndForget(()=>this.shutdown())},this.window.addEventListener("pagehide",this.qe))}yn(){this.qe&&(this.window.removeEventListener("pagehide",this.qe),this.qe=null)}_n(e){var t;try{var n=null!==(null===(t=this.Xe)||void 0===t?void 0:t.getItem(this.wn(e)));return kR("IndexedDbPersistence",`Client '${e}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(e){return SR("IndexedDbPersistence","Failed to get zombied client id.",e),!1}}mn(){if(this.Xe)try{this.Xe.setItem(this.wn(this.clientId),String(Date.now()))}catch(e){SR("Failed to set zombie client id.",e)}}pn(){if(this.Xe)try{this.Xe.removeItem(this.wn(this.clientId))}catch(e){}}wn(e){return`firestore_zombie_${this.persistenceKey}_${e}`}}function g1(e){return gO(e,qD.store)}function m1(e){return gO(e,XD.store)}function v1(e,t){let n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}class y1{constructor(e,t){this.progress=e,this.In=t}}class _1{constructor(e,t,n){this.Je=e,this.An=t,this.Jt=n}Rn(t,n){return this.An.getAllMutationBatchesAffectingDocumentKey(t,n).next(e=>this.bn(t,n,e))}bn(e,t,n){return this.Je.getEntry(e,t).next(e=>{for(const t of n)t.applyToLocalView(e);return e})}Pn(e,n){e.forEach((e,t)=>{for(const e of n)e.applyToLocalView(t)})}vn(t,e){return this.Je.getEntries(t,e).next(e=>this.Vn(t,e).next(()=>e))}Vn(e,t){return this.An.getAllMutationBatchesAffectingDocumentKeys(e,t).next(e=>this.Pn(t,e))}getDocumentsMatchingQuery(e,t,n){return r=t,pP.isDocumentKey(r.path)&&null===r.collectionGroup&&0===r.filters.length?this.Sn(e,t.path):tx(t)?this.Dn(e,t,n):this.Cn(e,t,n);var r}Sn(e,t){return this.Rn(e,new pP(t)).next(e=>{let t=Gx;return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}Dn(r,i,s){const o=i.collectionGroup;let a=Gx;return this.Jt.getCollectionParents(r,o).next(e=>iO.forEach(e,e=>{var t,n=(t=i,e=e.child(o),new GP(e,null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt));return this.Cn(r,n,s).next(e=>{e.forEach((e,t)=>{a=a.insert(e,t)})})}).next(()=>a))}Cn(t,n,e){let i,s;return this.Je.getDocumentsMatchingQuery(t,n,e).next(e=>(i=e,this.An.getAllMutationBatchesAffectingQuery(t,n))).next(e=>(s=e,this.Nn(t,s,i).next(t=>{i=t;for(const t of s)for(const r of t.mutations){var n=r.key;let e=i.get(n);null==e&&(e=AP.newInvalidDocument(n),i=i.insert(n,e)),Nx(r,e,t.localWriteTime),e.isFoundDocument()||(i=i.remove(n))}}))).next(()=>(i.forEach((e,t)=>{cx(n,t)||(i=i.remove(e))}),i))}Nn(e,t,n){let r=Jx();for(const e of t)for(const t of e.mutations)t instanceof Dx&&null===n.get(t.key)&&(r=r.add(t.key));let i=n;return this.Je.getEntries(e,r).next(e=>(e.forEach((e,t)=>{t.isFoundDocument()&&(i=i.insert(e,t))}),i))}}class w1{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.kn=n,this.xn=r}static $n(e,t){let n=Jx(),r=Jx();for(const 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 w1(e,t.fromCache,n,r)}}class b1{On(e){this.Mn=e}getDocumentsMatchingQuery(t,r,i,s){return 0===(e=r).filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())||i.isEqual(GR.min())?this.Fn(t,r):this.Mn.vn(t,s).next(e=>{const n=this.Ln(r,e);return(JP(r)||XP(r))&&this.Bn(r.limitType,n,s,i)?this.Fn(t,r):(ER()<=$h.DEBUG&&kR("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),ax(r)),this.Mn.getDocumentsMatchingQuery(t,r,i).next(t=>(n.forEach(e=>{t=t.insert(e.key,e)}),t)))});var e}Ln(n,e){let r=new Kx(lx(n));return e.forEach((e,t)=>{cx(n,t)&&(r=r.add(t))}),r}Bn(e,t,n,r){if(n.size!==t.size)return!0;const i="F"===e?t.last():t.first();return!!i&&(i.hasPendingWrites||0<i.version.compareTo(r))}Fn(e,t){return ER()<=$h.DEBUG&&kR("QueryEngine","Using full collection scan to execute query:",ax(t)),this.Mn.getDocumentsMatchingQuery(e,t,GR.min())}}class I1{constructor(e,t,n,r){this.persistence=e,this.Un=t,this.k=r,this.qn=new Bx($R),this.Kn=new i1(e=>PP(e),xP),this.jn=GR.min(),this.An=e.getMutationQueue(n),this.Qn=e.getRemoteDocumentCache(),this.He=e.getTargetCache(),this.Wn=new _1(this.Qn,this.An,this.persistence.getIndexManager()),this.Ye=e.getBundleCache(),this.Un.On(this.Wn)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",e=>t.collect(e,this.qn))}}function T1(e,t,n,r){return new I1(e,t,n,r)}async function E1(e,t){const n=e;let r=n.An,o=n.Wn;var i=await n.persistence.runTransaction("Handle user change","readonly",i=>{let s;return n.An.getAllMutationBatches(i).next(e=>(s=e,r=n.persistence.getMutationQueue(t),o=new _1(n.Qn,r,n.persistence.getIndexManager()),r.getAllMutationBatches(i))).next(e=>{const t=[],n=[];let r=Jx();for(const i of s){t.push(i.batchId);for(const e of i.mutations)r=r.add(e.key)}for(const i of e){n.push(i.batchId);for(const e of i.mutations)r=r.add(e.key)}return o.vn(i,r).next(e=>({Gn:e,removedBatchIds:t,addedBatchIds:n}))})});return n.An=r,n.Wn=o,n.Un.On(n.Wn),i}function k1(e){const t=e;return t.persistence.runTransaction("Get last remote snapshot version","readonly",e=>t.He.getLastRemoteSnapshotVersion(e))}function S1(e,l){const u=e,h=l.snapshotVersion;let d=u.qn;return u.persistence.runTransaction("Apply remote event","readwrite-primary",a=>{const e=u.Qn.newChangeBuffer({trackRemovals:!0});d=u.qn;const c=[];l.targetChanges.forEach((t,n)=>{const r=d.get(n);if(r){c.push(u.He.removeMatchingKeys(a,t.removedDocuments,n).next(()=>u.He.addMatchingKeys(a,t.addedDocuments,n)));let e=r.withSequenceNumber(a.currentSequenceNumber);var i,s,o;l.targetMismatches.has(n)?e=e.withResumeToken(rP.EMPTY_BYTE_STRING,GR.min()).withLastLimboFreeSnapshotVersion(GR.min()):0<t.resumeToken.approximateByteSize()&&(e=e.withResumeToken(t.resumeToken,h)),d=d.insert(n,e),i=r,s=e,o=t,0!==i.resumeToken.approximateByteSize()&&!(3e8<=s.snapshotVersion.toMicroseconds()-i.snapshotVersion.toMicroseconds()||0<o.addedDocuments.size+o.modifiedDocuments.size+o.removedDocuments.size)||c.push(u.He.updateTargetData(a,e))}});let t=Hx;if(l.documentUpdates.forEach((e,t)=>{l.resolvedLimboDocuments.has(e)&&c.push(u.persistence.referenceDelegate.updateLimboDocument(a,e))}),c.push(C1(a,e,l.documentUpdates,h,void 0).next(e=>{t=e})),!h.isEqual(GR.min())){const l=u.He.getLastRemoteSnapshotVersion(a).next(e=>u.He.setTargetsMetadata(a,a.currentSequenceNumber,h));c.push(l)}return iO.waitFor(c).next(()=>e.apply(a)).next(()=>u.Wn.Vn(a,t)).next(()=>t)}).then(e=>(u.qn=d,e))}function C1(e,o,t,a,c){let n=Jx();return t.forEach(e=>n=n.add(e)),o.getEntries(e,n).next(i=>{let s=Hx;return t.forEach((e,t)=>{const n=i.get(e),r=(null==c?void 0:c.get(e))||a;t.isNoDocument()&&t.version.isEqual(GR.min())?(o.removeEntry(e,r),s=s.insert(e,t)):!n.isValidDocument()||0<t.version.compareTo(n.version)||0===t.version.compareTo(n.version)&&n.hasPendingWrites?(o.addEntry(t,r),s=s.insert(e,t)):kR("LocalStore","Ignoring outdated watch update for ",e,". Current version:",n.version," Watch version:",t.version)}),s})}function A1(e,r){const i=e;return i.persistence.runTransaction("Allocate target","readwrite",t=>{let n;return i.He.getTargetData(t,r).next(e=>e?(n=e,iO.resolve(n)):i.He.allocateTargetId(t).next(e=>(n=new yO(r,e,0,t.currentSequenceNumber),i.He.addTargetData(t,n).next(()=>n))))}).then(e=>{var t=i.qn.get(e.targetId);return(null===t||0<e.snapshotVersion.compareTo(t.snapshotVersion))&&(i.qn=i.qn.insert(e.targetId,e),i.Kn.set(r,e.targetId)),e})}async function N1(e,t,n){const r=e,i=r.qn.get(t),s=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",s,e=>r.persistence.referenceDelegate.removeTarget(e,i))}catch(e){if(!lO(e))throw e;kR("LocalStore",`Failed to update sequence numbers for target ${t}: ${e}`)}r.qn=r.qn.remove(t),r.Kn.delete(i.target)}function R1(e,n,r){const i=e;let s=GR.min(),o=Jx();return i.persistence.runTransaction("Execute query","readonly",t=>function(e,t,n){const r=e,i=r.Kn.get(n);return void 0!==i?iO.resolve(r.qn.get(i)):r.He.getTargetData(t,n)}(i,t,rx(n)).next(e=>{if(e)return s=e.lastLimboFreeSnapshotVersion,i.He.getMatchingKeysForTargetId(t,e.targetId).next(e=>{o=e})}).next(()=>i.Un.getDocumentsMatchingQuery(t,n,r?s:GR.min(),r?o:Jx())).next(e=>({documents:e,zn:o})))}function P1(e,t){const n=e,r=n.He,i=n.qn.get(t);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",e=>r.Et(e,t).next(e=>e?e.target:null))}function x1(e){const n=e;return n.persistence.runTransaction("Get new document changes","readonly",e=>function(e,t,n){const r=e;let i=Hx,s=IO(n);const o=l1(t),a=IDBKeyRange.lowerBound(s,!0);return o.jt({index:zD.readTimeIndex,range:a},(e,t)=>{var n=wO(r.k,t);i=i.insert(n.key,n),s=t.readTime}).next(()=>({In:i,readTime:TO(s)}))}(n.Qn,e,n.jn)).then(({In:e,readTime:t})=>(n.jn=t,e))}class D1{constructor(e){this.k=e,this.Xn=new Map,this.Zn=new Map}getBundleMetadata(e,t){return iO.resolve(this.Xn.get(t))}saveBundleMetadata(e,t){return this.Xn.set(t.id,{id:t.id,version:t.version,createTime:pD(t.createTime)}),iO.resolve()}getNamedQuery(e,t){return iO.resolve(this.Zn.get(t))}saveNamedQuery(e,t){return this.Zn.set(t.name,{name:(t=t).name,query:NO(t.bundledQuery),readTime:pD(t.readTime)}),iO.resolve()}}class O1{constructor(){this.ts=new Kx(M1.es),this.ns=new Kx(M1.ss)}isEmpty(){return this.ts.isEmpty()}addReference(e,t){var n=new M1(e,t);this.ts=this.ts.add(n),this.ns=this.ns.add(n)}rs(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.os(new M1(e,t))}cs(e,t){e.forEach(e=>this.removeReference(e,t))}us(e){const t=new pP(new ZR([])),n=new M1(t,e),r=new M1(t,e+1),i=[];return this.ns.forEachInRange([n,r],e=>{this.os(e),i.push(e.key)}),i}hs(){this.ts.forEach(e=>this.os(e))}os(e){this.ts=this.ts.delete(e),this.ns=this.ns.delete(e)}ls(e){var t=new pP(new ZR([])),n=new M1(t,e),t=new M1(t,e+1);let r=Jx();return this.ns.forEachInRange([n,t],e=>{r=r.add(e.key)}),r}containsKey(e){var t=new M1(e,0),t=this.ts.firstAfterOrEqual(t);return null!==t&&e.isEqual(t.key)}}class M1{constructor(e,t){this.key=e,this.fs=t}static es(e,t){return pP.comparator(e.key,t.key)||$R(e.fs,t.fs)}static ss(e,t){return $R(e.fs,t.fs)||pP.comparator(e.key,t.key)}}class L1{constructor(e,t){this.Jt=e,this.referenceDelegate=t,this.An=[],this.ds=1,this.ws=new Kx(M1.es)}checkEmpty(e){return iO.resolve(0===this.An.length)}addMutationBatch(e,t,n,r){var i=this.ds;this.ds++,0<this.An.length&&this.An[this.An.length-1];var s=new mO(i,t,n,r);this.An.push(s);for(const t of r)this.ws=this.ws.add(new M1(t.key,i)),this.Jt.addToCollectionParentIndex(e,t.key.path.popLast());return iO.resolve(s)}lookupMutationBatch(e,t){return iO.resolve(this._s(t))}getNextMutationBatchAfterBatchId(e,t){var n=this.gs(t+1),n=n<0?0:n;return iO.resolve(this.An.length>n?this.An[n]:null)}getHighestUnacknowledgedBatchId(){return iO.resolve(0===this.An.length?-1:this.ds-1)}getAllMutationBatches(e){return iO.resolve(this.An.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const n=new M1(t,0),r=new M1(t,Number.POSITIVE_INFINITY),i=[];return this.ws.forEachInRange([n,r],e=>{var t=this._s(e.fs);i.push(t)}),iO.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new Kx($R);return t.forEach(e=>{var t=new M1(e,0),n=new M1(e,Number.POSITIVE_INFINITY);this.ws.forEachInRange([t,n],e=>{r=r.add(e.fs)})}),iO.resolve(this.ys(r))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,r=n.length+1;let i=n;pP.isDocumentKey(i)||(i=i.child(""));var s=new M1(new pP(i),0);let o=new Kx($R);return this.ws.forEachWhile(e=>{var t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.fs)),!0)},s),iO.resolve(this.ys(o))}ys(e){const n=[];return e.forEach(e=>{var t=this._s(e);null!==t&&n.push(t)}),n}removeMutationBatch(n,r){RR(0===this.ps(r.batchId,"removed")),this.An.shift();let i=this.ws;return iO.forEach(r.mutations,e=>{var t=new M1(e.key,r.batchId);return i=i.delete(t),this.referenceDelegate.markPotentiallyOrphaned(n,e.key)}).next(()=>{this.ws=i})}ee(e){}containsKey(e,t){var n=new M1(t,0),n=this.ws.firstAfterOrEqual(n);return iO.resolve(t.isEqual(n&&n.key))}performConsistencyCheck(e){return this.An.length,iO.resolve()}ps(e,t){return this.gs(e)}gs(e){return 0===this.An.length?0:e-this.An[0].batchId}_s(e){var t=this.gs(e);return t<0||t>=this.An.length?null:this.An[t]}}class F1{constructor(e,t){this.Jt=e,this.Ts=t,this.docs=new Bx(pP.comparator),this.size=0}addEntry(e,t,n){const r=t.key,i=this.docs.get(r),s=i?i.size:0,o=this.Ts(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:o,readTime:n}),this.size+=o-s,this.Jt.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){var t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const n=this.docs.get(t);return iO.resolve(n?n.document.mutableCopy():AP.newInvalidDocument(t))}getEntries(e,t){let n=Hx;return t.forEach(e=>{const t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():AP.newInvalidDocument(e))}),iO.resolve(n)}getDocumentsMatchingQuery(e,t,n){let r=Hx;const i=new pP(t.path.child("")),s=this.docs.getIteratorFrom(i);for(;s.hasNext();){const{key:e,value:{document:i,readTime:o}}=s.getNext();if(!t.path.isPrefixOf(e.path))break;o.compareTo(n)<=0||cx(t,i)&&(r=r.insert(i.key,i.mutableCopy()))}return iO.resolve(r)}Es(e,t){return iO.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new U1(this)}getSize(e){return iO.resolve(this.size)}}class U1 extends s1{constructor(e){super(),this.De=e}applyChanges(n){const r=[];return this.changes.forEach((e,t)=>{t.document.isValidDocument()?r.push(this.De.addEntry(n,t.document,this.getReadTime(e))):this.De.removeEntry(e)}),iO.waitFor(r)}getFromCache(e,t){return this.De.getEntry(e,t)}getAllFromCache(e,t){return this.De.getEntries(e,t)}}class j1{constructor(e){this.persistence=e,this.Is=new i1(e=>PP(e),xP),this.lastRemoteSnapshotVersion=GR.min(),this.highestTargetId=0,this.As=0,this.Rs=new O1,this.targetCount=0,this.bs=zO.ie()}forEachTarget(e,n){return this.Is.forEach((e,t)=>n(t)),iO.resolve()}getLastRemoteSnapshotVersion(e){return iO.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return iO.resolve(this.As)}allocateTargetId(e){return this.highestTargetId=this.bs.next(),iO.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.As&&(this.As=t),iO.resolve()}ae(e){this.Is.set(e.target,e);var t=e.targetId;t>this.highestTargetId&&(this.bs=new zO(t),this.highestTargetId=t),e.sequenceNumber>this.As&&(this.As=e.sequenceNumber)}addTargetData(e,t){return this.ae(t),this.targetCount+=1,iO.resolve()}updateTargetData(e,t){return this.ae(t),iO.resolve()}removeTargetData(e,t){return this.Is.delete(t.target),this.Rs.us(t.targetId),--this.targetCount,iO.resolve()}removeTargets(n,r,i){let s=0;const o=[];return this.Is.forEach((e,t)=>{t.sequenceNumber<=r&&null===i.get(t.targetId)&&(this.Is.delete(e),o.push(this.removeMatchingKeysForTargetId(n,t.targetId)),s++)}),iO.waitFor(o).next(()=>s)}getTargetCount(e){return iO.resolve(this.targetCount)}getTargetData(e,t){var n=this.Is.get(t)||null;return iO.resolve(n)}addMatchingKeys(e,t,n){return this.Rs.rs(t,n),iO.resolve()}removeMatchingKeys(t,e,n){this.Rs.cs(e,n);const r=this.persistence.referenceDelegate,i=[];return r&&e.forEach(e=>{i.push(r.markPotentiallyOrphaned(t,e))}),iO.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.Rs.us(t),iO.resolve()}getMatchingKeysForTargetId(e,t){var n=this.Rs.ls(t);return iO.resolve(n)}containsKey(e,t){return iO.resolve(this.Rs.containsKey(t))}}class q1{constructor(e,t){var n;this.Ps={},this.Be=new BR(0),this.Ue=!1,this.Ue=!0,this.referenceDelegate=e(this),this.He=new j1(this),this.Jt=new DO,this.Je=(n=this.Jt,e=e=>this.referenceDelegate.vs(e),new F1(n,e)),this.k=new _O(t),this.Ye=new D1(this.k)}start(){return Promise.resolve()}shutdown(){return this.Ue=!1,Promise.resolve()}get started(){return this.Ue}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(){return this.Jt}getMutationQueue(e){let t=this.Ps[e.toKey()];return t||(t=new L1(this.Jt,this.referenceDelegate),this.Ps[e.toKey()]=t),t}getTargetCache(){return this.He}getRemoteDocumentCache(){return this.Je}getBundleCache(){return this.Ye}runTransaction(e,t,n){kR("MemoryPersistence","Starting transaction:",e);const r=new V1(this.Be.next());return this.referenceDelegate.Vs(),n(r).next(e=>this.referenceDelegate.Ss(r).next(()=>e)).toPromise().then(e=>(r.raiseOnCommittedEvent(),e))}Ds(t,n){return iO.or(Object.values(this.Ps).map(e=>()=>e.containsKey(t,n)))}}class V1 extends rO{constructor(e){super(),this.currentSequenceNumber=e}}class B1{constructor(e){this.persistence=e,this.Cs=new O1,this.Ns=null}static ks(e){return new B1(e)}get xs(){if(this.Ns)return this.Ns;throw NR()}addReference(e,t,n){return this.Cs.addReference(n,t),this.xs.delete(n.toString()),iO.resolve()}removeReference(e,t,n){return this.Cs.removeReference(n,t),this.xs.add(n.toString()),iO.resolve()}markPotentiallyOrphaned(e,t){return this.xs.add(t.toString()),iO.resolve()}removeTarget(e,t){this.Cs.us(t.targetId).forEach(e=>this.xs.add(e.toString()));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.xs.add(e.toString()))}).next(()=>n.removeTargetData(e,t))}Vs(){this.Ns=new Set}Ss(n){const r=this.persistence.getRemoteDocumentCache().newChangeBuffer();return iO.forEach(this.xs,e=>{const t=pP.fromPath(e);return this.$s(n,t).next(e=>{e||r.removeEntry(t)})}).next(()=>(this.Ns=null,r.apply(n)))}updateLimboDocument(e,t){return this.$s(e,t).next(e=>{e?this.xs.delete(t.toString()):this.xs.add(t.toString())})}vs(e){return 0}$s(e,t){return iO.or([()=>iO.resolve(this.Cs.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ds(e,t)])}}function W1(e,t){return`firestore_clients_${e}_${t}`}function $1(e,t,n){let r=`firestore_mutations_${e}_${n}`;return t.isAuthenticated()&&(r+=`_${t.uid}`),r}function K1(e,t){return`firestore_targets_${e}_${t}`}class z1{constructor(e,t,n,r){this.user=e,this.batchId=t,this.state=n,this.error=r}static Os(e,t,n){var r=JSON.parse(n);let 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,s&&(i=new xR(r.error.code,r.error.message))),s?new z1(e,t,r.state,i):(SR("SharedClientState",`Failed to parse mutation state for ID '${t}': ${n}`),null)}Ms(){const e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class H1{constructor(e,t,n){this.targetId=e,this.state=t,this.error=n}static Os(e,t){var n=JSON.parse(t);let 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,i&&(r=new xR(n.error.code,n.error.message))),i?new H1(e,n.state,r):(SR("SharedClientState",`Failed to parse target state for ID '${e}': ${t}`),null)}Ms(){const e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class G1{constructor(e,t){this.clientId=e,this.activeTargetIds=t}static Os(e,t){var n=JSON.parse(t);let r="object"==typeof n&&n.activeTargetIds instanceof Array,i=Xx;for(let s=0;r&&s<n.activeTargetIds.length;++s)r=dP(n.activeTargetIds[s]),i=i.add(n.activeTargetIds[s]);return r?new G1(e,i):(SR("SharedClientState",`Failed to parse client data for instance '${e}': ${t}`),null)}}class Q1{constructor(e,t){this.clientId=e,this.onlineState=t}static Os(e){var t=JSON.parse(e);return"object"==typeof t&&-1!==["Unknown","Online","Offline"].indexOf(t.onlineState)&&"string"==typeof t.clientId?new Q1(t.clientId,t.onlineState):(SR("SharedClientState",`Failed to parse online state: ${e}`),null)}}class Y1{constructor(){this.activeTargetIds=Xx}Fs(e){this.activeTargetIds=this.activeTargetIds.add(e)}Ls(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ms(){var e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class J1{constructor(e,t,n,r,i){this.window=e,this.Me=t,this.persistenceKey=n,this.Bs=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.Us=this.qs.bind(this),this.Ks=new Bx($R),this.started=!1,this.js=[];var s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Qs=W1(this.persistenceKey,this.Bs),this.Ws=`firestore_sequence_number_${this.persistenceKey}`,this.Ks=this.Ks.insert(this.Bs,new Y1),this.Gs=new RegExp(`^firestore_clients_${s}_([^_]*)$`),this.zs=new RegExp(`^firestore_mutations_${s}_(\\d+)(?:_(.*))?$`),this.Hs=new RegExp(`^firestore_targets_${s}_(\\d+)$`),this.Js=`firestore_online_state_${this.persistenceKey}`,this.Ys=`firestore_bundle_loaded_${this.persistenceKey}`,this.window.addEventListener("storage",this.Us)}static Pt(e){return!(!e||!e.localStorage)}async start(){const e=await this.syncEngine.Tn();for(const n of e)if(n!==this.Bs){const e=this.getItem(W1(this.persistenceKey,n));var t;!e||(t=G1.Os(n,e))&&(this.Ks=this.Ks.insert(t.clientId,t))}this.Xs();const n=this.storage.getItem(this.Js);if(n){const e=this.Zs(n);e&&this.ti(e)}for(const e of this.js)this.qs(e);this.js=[],this.window.addEventListener("pagehide",()=>this.shutdown()),this.started=!0}writeSequenceNumber(e){this.setItem(this.Ws,JSON.stringify(e))}getAllActiveQueryTargets(){return this.ei(this.Ks)}isActiveQueryTarget(n){let r=!1;return this.Ks.forEach((e,t)=>{t.activeTargetIds.has(n)&&(r=!0)}),r}addPendingMutation(e){this.ni(e,"pending")}updateMutationState(e,t,n){this.ni(e,t,n),this.si(e)}addLocalQueryTarget(e){let t="not-current";var n;return this.isActiveQueryTarget(e)&&(!(n=this.storage.getItem(K1(this.persistenceKey,e)))||(n=H1.Os(e,n))&&(t=n.state)),this.ii.Fs(e),this.Xs(),t}removeLocalQueryTarget(e){this.ii.Ls(e),this.Xs()}isLocalQueryTarget(e){return this.ii.activeTargetIds.has(e)}clearQueryState(e){this.removeItem(K1(this.persistenceKey,e))}updateQueryState(e,t,n){this.ri(e,t,n)}handleUserChange(e,t,n){t.forEach(e=>{this.si(e)}),this.currentUser=e,n.forEach(e=>{this.addPendingMutation(e)})}setOnlineState(e){this.oi(e)}notifyBundleLoaded(){this.ci()}shutdown(){this.started&&(this.window.removeEventListener("storage",this.Us),this.removeItem(this.Qs),this.started=!1)}getItem(e){var t=this.storage.getItem(e);return kR("SharedClientState","READ",e,t),t}setItem(e,t){kR("SharedClientState","SET",e,t),this.storage.setItem(e,t)}removeItem(e){kR("SharedClientState","REMOVE",e),this.storage.removeItem(e)}qs(e){const r=e;r.storageArea===this.storage&&(kR("SharedClientState","EVENT",r.key,r.newValue),r.key!==this.Qs?this.Me.enqueueRetryable(async()=>{if(this.started){if(null!==r.key)if(this.Gs.test(r.key)){if(null==r.newValue){var e=this.ai(r.key);return this.ui(e,null)}e=this.hi(r.key,r.newValue);if(e)return this.ui(e.clientId,e)}else if(this.zs.test(r.key)){if(null!==r.newValue){var t=this.li(r.key,r.newValue);if(t)return this.fi(t)}}else if(this.Hs.test(r.key)){if(null!==r.newValue){t=this.di(r.key,r.newValue);if(t)return this.wi(t)}}else if(r.key===this.Js){if(null!==r.newValue){var n=this.Zs(r.newValue);if(n)return this.ti(n)}}else if(r.key===this.Ws){n=function(e){let t=BR.I;if(null!=e)try{var n=JSON.parse(e);RR("number"==typeof n),t=n}catch(e){SR("SharedClientState","Failed to read sequence number from WebStorage",e)}return t}(r.newValue);n!==BR.I&&this.sequenceNumberHandler(n)}else if(r.key===this.Ys)return this.syncEngine._i()}else this.js.push(r)}):SR("Received WebStorage notification for local change. Another client might have garbage-collected our state"))}get ii(){return this.Ks.get(this.Bs)}Xs(){this.setItem(this.Qs,this.ii.Ms())}ni(e,t,n){const r=new z1(this.currentUser,e,t,n),i=$1(this.persistenceKey,this.currentUser,e);this.setItem(i,r.Ms())}si(e){var t=$1(this.persistenceKey,this.currentUser,e);this.removeItem(t)}oi(e){var t={clientId:this.Bs,onlineState:e};this.storage.setItem(this.Js,JSON.stringify(t))}ri(e,t,n){const r=K1(this.persistenceKey,e),i=new H1(e,t,n);this.setItem(r,i.Ms())}ci(){this.setItem(this.Ys,"value-not-used")}ai(e){var t=this.Gs.exec(e);return t?t[1]:null}hi(e,t){var n=this.ai(e);return G1.Os(n,t)}li(e,t){var n=this.zs.exec(e),r=Number(n[1]),n=void 0!==n[2]?n[2]:null;return z1.Os(new bR(n),r,t)}di(e,t){var n=this.Hs.exec(e),n=Number(n[1]);return H1.Os(n,t)}Zs(e){return Q1.Os(e)}async fi(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.mi(e.batchId,e.state,e.error);kR("SharedClientState",`Ignoring mutation for non-active user ${e.user.uid}`)}wi(e){return this.syncEngine.gi(e.targetId,e.state,e.error)}ui(e,t){const n=t?this.Ks.insert(e,t):this.Ks.remove(e),r=this.ei(this.Ks),i=this.ei(n),s=[],o=[];return i.forEach(e=>{r.has(e)||s.push(e)}),r.forEach(e=>{i.has(e)||o.push(e)}),this.syncEngine.yi(s,o).then(()=>{this.Ks=n})}ti(e){this.Ks.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}ei(e){let n=Xx;return e.forEach((e,t)=>{n=n.unionWith(t.activeTargetIds)}),n}}class X1{constructor(){this.pi=new Y1,this.Ti={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e){return this.pi.Fs(e),this.Ti[e]||"not-current"}updateQueryState(e,t,n){this.Ti[e]=t}removeLocalQueryTarget(e){this.pi.Ls(e)}isLocalQueryTarget(e){return this.pi.activeTargetIds.has(e)}clearQueryState(e){delete this.Ti[e]}getAllActiveQueryTargets(){return this.pi.activeTargetIds}isActiveQueryTarget(e){return this.pi.activeTargetIds.has(e)}start(){return this.pi=new Y1,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(){}}class Z1{Ei(e){}shutdown(){}}class eM{constructor(){this.Ii=()=>this.Ai(),this.Ri=()=>this.bi(),this.Pi=[],this.vi()}Ei(e){this.Pi.push(e)}shutdown(){window.removeEventListener("online",this.Ii),window.removeEventListener("offline",this.Ri)}vi(){window.addEventListener("online",this.Ii),window.addEventListener("offline",this.Ri)}Ai(){kR("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.Pi)e(0)}bi(){kR("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const e of this.Pi)e(1)}static Pt(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}const tM={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"};class nM{constructor(e){this.Vi=e.Vi,this.Si=e.Si}Di(e){this.Ci=e}Ni(e){this.ki=e}onMessage(e){this.xi=e}close(){this.Si()}send(e){this.Vi(e)}$i(){this.Ci()}Oi(e){this.ki(e)}Mi(e){this.xi(e)}}class rM extends class{constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;var t=e.ssl?"https":"http";this.Fi=t+"://"+e.host,this.Li="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}Bi(t,e,n,r,i){const s=this.Ui(t,e);kR("RestConnection","Sending: ",s,n);var o={};return this.qi(o,r,i),this.Ki(t,s,o,n).then(e=>(kR("RestConnection","Received: ",e),e),e=>{throw CR("RestConnection",`${t} failed with error: `,e,"url: ",s,"request:",n),e})}ji(e,t,n,r,i){return this.Bi(e,t,n,r,i)}qi(n,e,t){n["X-Goog-Api-Client"]="gl-js/ fire/"+IR,n["Content-Type"]="text/plain",this.databaseInfo.appId&&(n["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEach((e,t)=>n[t]=e),t&&t.headers.forEach((e,t)=>n[t]=e)}Ui(e,t){var n=tM[e];return`${this.Fi}/v1/${t}:${n}`}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams}Ki(a,t,n,r){return new Promise((i,s)=>{const o=new _R;o.listenOnce(pR.COMPLETE,()=>{try{switch(o.getLastErrorCode()){case dR.NO_ERROR:var e=o.getResponseJson();kR("Connection","XHR received:",JSON.stringify(e)),i(e);break;case dR.TIMEOUT:kR("Connection",'RPC "'+a+'" timed out'),s(new xR(PR.DEADLINE_EXCEEDED,"Request time out"));break;case dR.HTTP_ERROR:var t,n=o.getStatus();if(kR("Connection",'RPC "'+a+'" failed with status:',n,"response text:",o.getResponseText()),0<n){const a=o.getResponseJson().error;a&&a.status&&a.message?(r=a.status.toLowerCase().replace(/_/g,"-"),t=0<=Object.values(PR).indexOf(r)?r:PR.UNKNOWN,s(new xR(t,a.message))):s(new xR(PR.UNKNOWN,"Server responded with status "+o.getStatus()))}else s(new xR(PR.UNAVAILABLE,"Connection failed."));break;default:NR()}}finally{kR("Connection",'RPC "'+a+'" completed.')}var r});var e=JSON.stringify(r);o.send(t,"POST",e,n,15)})}Qi(e,t,n){const r=[this.Fi,"/","google.firestore.v1.Firestore","/",e,"/channel"],i=new sR,s=hR(),o={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};this.useFetchStreams&&(o.xmlHttpFactory=new vR({})),this.qi(o.initMessageHeaders,t,n),od()||ld()||0<=sd().indexOf("Electron/")||ud()||0<=sd().indexOf("MSAppHost/")||cd()||(o.httpHeadersOverwriteParam="$httpHeaders");var a=r.join("");kR("Connection","Creating WebChannel: "+a,o);const c=i.createWebChannel(a,o);let l=!1,u=!1;const h=new nM({Vi:e=>{u?kR("Connection","Not sending because WebChannel is closed:",e):(l||(kR("Connection","Opening WebChannel transport."),c.open(),l=!0),kR("Connection","WebChannel sending:",e),c.send(e))},Si:()=>c.close()}),d=(e,t,n)=>{e.listen(t,e=>{try{n(e)}catch(e){setTimeout(()=>{throw e},0)}})};return d(c,yR.EventType.OPEN,()=>{u||kR("Connection","WebChannel transport opened.")}),d(c,yR.EventType.CLOSE,()=>{u||(u=!0,kR("Connection","WebChannel transport closed"),h.Oi())}),d(c,yR.EventType.ERROR,e=>{u||(u=!0,CR("Connection","WebChannel transport errored:",e),h.Oi(new xR(PR.UNAVAILABLE,"The operation could not be completed")))}),d(c,yR.EventType.MESSAGE,n=>{if(!u){var e=n.data[0];RR(!!e);var r=e.error||(null===(r=e[0])||void 0===r?void 0:r.error);if(r){kR("Connection","WebChannel received error:",r);const n=r.status;let e=function(e){var t=uR[e];if(void 0!==t)return Vx(t)}(n),t=r.message;void 0===e&&(e=PR.INTERNAL,t="Unknown error status: "+n+" with message "+r.message),u=!0,h.Oi(new xR(e,t)),c.close()}else kR("Connection","WebChannel received:",e),h.Mi(e)}}),d(s,fR.STAT_EVENT,e=>{e.stat===gR?kR("Connection","Detected buffering proxy"):e.stat===mR&&kR("Connection","Detected no buffering proxy")}),setTimeout(()=>{h.$i()},0),h}}function iM(){return"undefined"!=typeof window?window:null}function sM(){return"undefined"!=typeof document?document:null}function oM(e){return new uD(e,!0)}class aM{constructor(e,t,n=1e3,r=1.5,i=6e4){this.Me=e,this.timerId=t,this.Wi=n,this.Gi=r,this.zi=i,this.Hi=0,this.Ji=null,this.Yi=Date.now(),this.reset()}reset(){this.Hi=0}Xi(){this.Hi=this.zi}Zi(e){this.cancel();var t=Math.floor(this.Hi+this.tr()),n=Math.max(0,Date.now()-this.Yi),r=Math.max(0,t-n);0<r&&kR("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.Hi} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.Ji=this.Me.enqueueAfterDelay(this.timerId,r,()=>(this.Yi=Date.now(),e())),this.Hi*=this.Gi,this.Hi<this.Wi&&(this.Hi=this.Wi),this.Hi>this.zi&&(this.Hi=this.zi)}er(){null!==this.Ji&&(this.Ji.skipDelay(),this.Ji=null)}cancel(){null!==this.Ji&&(this.Ji.cancel(),this.Ji=null)}tr(){return(Math.random()-.5)*this.Hi}}class cM{constructor(e,t,n,r,i,s,o,a){this.Me=e,this.nr=n,this.sr=r,this.ir=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=o,this.listener=a,this.state=0,this.rr=0,this.cr=null,this.ar=null,this.stream=null,this.ur=new aM(e,t)}hr(){return 1===this.state||5===this.state||this.lr()}lr(){return 2===this.state||3===this.state}start(){4!==this.state?this.auth():this.dr()}async stop(){this.hr()&&await this.close(0)}wr(){this.state=0,this.ur.reset()}_r(){this.lr()&&null===this.cr&&(this.cr=this.Me.enqueueAfterDelay(this.nr,6e4,()=>this.mr()))}gr(e){this.yr(),this.stream.send(e)}async mr(){if(this.lr())return this.close(0)}yr(){this.cr&&(this.cr.cancel(),this.cr=null)}pr(){this.ar&&(this.ar.cancel(),this.ar=null)}async close(e,t){this.yr(),this.pr(),this.ur.cancel(),this.rr++,4!==e?this.ur.reset():t&&t.code===PR.RESOURCE_EXHAUSTED?(SR(t.toString()),SR("Using maximum backoff delay to prevent overloading the backend."),this.ur.Xi()):t&&t.code===PR.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.Tr(),this.stream.close(),this.stream=null),this.state=e,await this.listener.Ni(t)}Tr(){}auth(){this.state=1;const e=this.Er(this.rr),n=this.rr;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([e,t])=>{this.rr===n&&this.Ir(e,t)},t=>{e(()=>{var e=new xR(PR.UNKNOWN,"Fetching auth token failed: "+t.message);return this.Ar(e)})})}Ir(e,t){const n=this.Er(this.rr);this.stream=this.Rr(e,t),this.stream.Di(()=>{n(()=>(this.state=2,this.ar=this.Me.enqueueAfterDelay(this.sr,1e4,()=>(this.lr()&&(this.state=3),Promise.resolve())),this.listener.Di()))}),this.stream.Ni(e=>{n(()=>this.Ar(e))}),this.stream.onMessage(e=>{n(()=>this.onMessage(e))})}dr(){this.state=5,this.ur.Zi(async()=>{this.state=0,this.start()})}Ar(e){return kR("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}Er(t){return e=>{this.Me.enqueueAndForget(()=>this.rr===t?e():(kR("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class lM extends cM{constructor(e,t,n,r,i,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,r,s),this.k=i}Rr(e,t){return this.ir.Qi("Listen",e,t)}onMessage(e){this.ur.reset();var t=function(e,t){let n;if("targetChange"in t){t.targetChange;var r="NO_CHANGE"===(p=t.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===p?1:"REMOVE"===p?2:"CURRENT"===p?3:"RESET"===p?4:NR(),i=t.targetChange.targetIds||[],s=(p=t.targetChange.resumeToken,e.C?(RR(void 0===p||"string"==typeof p),rP.fromBase64String(p||"")):(RR(void 0===p||p instanceof Uint8Array),rP.fromUint8Array(p||new Uint8Array))),o=t.targetChange.cause,a=o&&(a=void 0===(p=o).code?PR.UNKNOWN:Vx(p.code),new xR(a,p.message||""));n=new rD(r,i,s,a||null)}else if("documentChange"in t){t.documentChange;var c=t.documentChange;c.document,c.document.name,c.document.updateTime;var a=vD(e,c.document.name),l=pD(c.document.updateTime),u=new CP({mapValue:{fields:c.document.fields}}),l=AP.newFoundDocument(a,l,u),u=c.targetIds||[],c=c.removedTargetIds||[];n=new tD(u,c,l.key,l)}else if("documentDelete"in t){t.documentDelete;u=t.documentDelete;u.document;c=vD(e,u.document),l=u.readTime?pD(u.readTime):GR.min(),l=AP.newNoDocument(c,l),u=u.removedTargetIds||[];n=new tD([],u,l.key,l)}else if("documentRemove"in t){t.documentRemove;var h=t.documentRemove;h.document;var d=vD(e,h.document),h=h.removedTargetIds||[];n=new tD([],h,d,null)}else{if(!("filter"in t))return NR();{t.filter;const e=t.filter;e.targetId;h=e.count||0,d=new jx(h),h=e.targetId;n=new nD(h,d)}}var a,p;return n}(this.k,e),n=function(e){if(!("targetChange"in e))return GR.min();var t=e.targetChange;return(!t.targetIds||!t.targetIds.length)&&t.readTime?pD(t.readTime):GR.min()}(e);return this.listener.br(t,n)}Pr(e){const t={};t.database=wD(this.k),t.addTarget=function(e,t){let n;var r=t.target;return n=DP(r)?{documents:SD(e,r)}:{query:CD(e,r)},n.targetId=t.targetId,0<t.resumeToken.approximateByteSize()?n.resumeToken=dD(e,t.resumeToken):0<t.snapshotVersion.compareTo(GR.min())&&(n.readTime=hD(e,t.snapshotVersion.toTimestamp())),n}(this.k,e);var n,r,r=(this.k,n=e,null==(r=function(){switch(n.purpose){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return NR()}}())?null:{"goog-listen-tags":r});r&&(t.labels=r),this.gr(t)}vr(e){const t={};t.database=wD(this.k),t.removeTarget=e,this.gr(t)}}class uM extends cM{constructor(e,t,n,r,i,s){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,r,s),this.k=i,this.Vr=!1}get Sr(){return this.Vr}start(){this.Vr=!1,this.lastStreamToken=void 0,super.start()}Tr(){this.Vr&&this.Dr([])}Rr(e,t){return this.ir.Qi("Write",e,t)}onMessage(e){if(RR(!!e.streamToken),this.lastStreamToken=e.streamToken,this.Vr){this.ur.reset();var t=(r=e.writeResults,i=e.commitTime,r&&0<r.length?(RR(void 0!==i),r.map(e=>function(e,t){let n=e.updateTime?pD(e.updateTime):pD(t);return n.isEqual(GR.min())&&(n=pD(t)),new Ex(n,e.transformResults||[])}(e,i))):[]),n=pD(e.commitTime);return this.listener.Cr(n,t)}var r,i;return RR(!e.writeResults||0===e.writeResults.length),this.Vr=!0,this.listener.Nr()}kr(){const e={};e.database=wD(this.k),this.gr(e)}Dr(e){var t={streamToken:this.lastStreamToken,writes:e.map(e=>ED(this.k,e))};this.gr(t)}}class hM extends class{}{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.ir=n,this.k=r,this.$r=!1}Or(){if(this.$r)throw new xR(PR.FAILED_PRECONDITION,"The client has already been terminated.")}Bi(n,r,i){return this.Or(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([e,t])=>this.ir.Bi(n,r,i,e,t)).catch(e=>{throw"FirebaseError"===e.name?(e.code===PR.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new xR(PR.UNKNOWN,e.toString())})}ji(n,r,i){return this.Or(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([e,t])=>this.ir.ji(n,r,i,e,t)).catch(e=>{throw"FirebaseError"===e.name?(e.code===PR.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new xR(PR.UNKNOWN,e.toString())})}terminate(){this.$r=!0}}class dM{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.Mr=0,this.Fr=null,this.Lr=!0}Br(){0===this.Mr&&(this.Ur("Unknown"),this.Fr=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.Fr=null,this.qr("Backend didn't respond within 10 seconds."),this.Ur("Offline"),Promise.resolve())))}Kr(e){"Online"===this.state?this.Ur("Unknown"):(this.Mr++,1<=this.Mr&&(this.jr(),this.qr(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.Ur("Offline")))}set(e){this.jr(),this.Mr=0,"Online"===e&&(this.Lr=!1),this.Ur(e)}Ur(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}qr(e){var t=`Could not reach Cloud Firestore backend. ${e}\nThis 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.Lr?(SR(t),this.Lr=!1):kR("OnlineStateTracker",t)}jr(){null!==this.Fr&&(this.Fr.cancel(),this.Fr=null)}}class pM{constructor(e,t,n,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.Qr=[],this.Wr=new Map,this.Gr=new Set,this.zr=[],this.Hr=i,this.Hr.Ei(e=>{n.enqueueAndForget(async()=>{IM(this)&&(kR("RemoteStore","Restarting streams for network reachability change."),await async function(e){const t=e;t.Gr.add(4),await gM(t),t.Jr.set("Unknown"),t.Gr.delete(4),await fM(t)}(this))})}),this.Jr=new dM(n,r)}}async function fM(e){if(IM(e))for(const t of e.zr)await t(!0)}async function gM(e){for(const t of e.zr)await t(!1)}function mM(e,t){const n=e;n.Wr.has(t.targetId)||(n.Wr.set(t.targetId,t),bM(n)?wM(n):RM(n).lr()&&yM(n,t))}function vM(e,t){const n=e,r=RM(n);n.Wr.delete(t),r.lr()&&_M(n,t),0===n.Wr.size&&(r.lr()?r._r():IM(n)&&n.Jr.set("Unknown"))}function yM(e,t){e.Yr.X(t.targetId),RM(e).Pr(t)}function _M(e,t){e.Yr.X(t),RM(e).vr(t)}function wM(t){t.Yr=new sD({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),Et:e=>t.Wr.get(e)||null}),RM(t).start(),t.Jr.Br()}function bM(e){return IM(e)&&!RM(e).hr()&&0<e.Wr.size}function IM(e){return 0===e.Gr.size}function TM(e){e.Yr=void 0}async function EM(e,t,n){if(!lO(t))throw t;e.Gr.add(1),await gM(e),e.Jr.set("Offline"),n=n||(()=>k1(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{kR("RemoteStore","Retrying IndexedDB access"),await n(),e.Gr.delete(1),await fM(e)})}function kM(t,n){return n().catch(e=>EM(t,e,n))}async function SM(e){const t=e,n=PM(t);let r=0<t.Qr.length?t.Qr[t.Qr.length-1].batchId:-1;for(;IM(i=t)&&i.Qr.length<10;)try{const e=await function(e,t){const n=e;return n.persistence.runTransaction("Get next mutation batch","readonly",e=>(void 0===t&&(t=-1),n.An.getNextMutationBatchAfterBatchId(e,t)))}(t.localStore,r);if(null===e){0===t.Qr.length&&n._r();break}r=e.batchId,function(e,t){e.Qr.push(t);const n=PM(e);n.lr()&&n.Sr&&n.Dr(t.mutations)}(t,e)}catch(e){await EM(t,e)}var i;CM(t)&&AM(t)}function CM(e){return IM(e)&&!PM(e).hr()&&0<e.Qr.length}function AM(e){PM(e).start()}async function NM(e,t){const n=e;t?(n.Gr.delete(2),await fM(n)):(n.Gr.add(2),await gM(n),n.Jr.set("Unknown"))}function RM(t){return t.Xr||(t.Xr=function(e,t,n){const r=e;return r.Or(),new lM(t,r.ir,r.authCredentials,r.appCheckCredentials,r.k,n)}(t.datastore,t.asyncQueue,{Di:(async function(n){n.Wr.forEach((e,t)=>{yM(n,e)})}).bind(null,t),Ni:(async function(e,t){TM(e),bM(e)?(e.Jr.Kr(t),wM(e)):e.Jr.set("Unknown")}).bind(null,t),br:(async function(e,r,t){if(e.Jr.set("Online"),r instanceof rD&&2===r.state&&r.cause)try{await async function(e){var t=r.cause;for(const n of r.targetIds)e.Wr.has(n)&&(await e.remoteSyncer.rejectListen(n,t),e.Wr.delete(n),e.Yr.removeTarget(n))}(e)}catch(t){kR("RemoteStore","Failed to remove targets %s: %s ",r.targetIds.join(","),t),await EM(e,t)}else if(r instanceof tD?e.Yr.ot(r):r instanceof nD?e.Yr.dt(r):e.Yr.ut(r),!t.isEqual(GR.min()))try{const r=await k1(e.localStore);0<=t.compareTo(r)&&await function(r,i){const e=r.Yr.gt(i);return e.targetChanges.forEach((e,t)=>{if(0<e.resumeToken.approximateByteSize()){const n=r.Wr.get(t);n&&r.Wr.set(t,n.withResumeToken(e.resumeToken,i))}}),e.targetMismatches.forEach(e=>{const t=r.Wr.get(e);var n;t&&(r.Wr.set(e,t.withResumeToken(rP.EMPTY_BYTE_STRING,t.snapshotVersion)),_M(r,e),n=new yO(t.target,e,1,t.sequenceNumber),yM(r,n))}),r.remoteSyncer.applyRemoteEvent(e)}(e,t)}catch(r){kR("RemoteStore","Failed to raise snapshot:",r),await EM(e,r)}}).bind(null,t)}),t.zr.push(async e=>{e?(t.Xr.wr(),bM(t)?wM(t):t.Jr.set("Unknown")):(await t.Xr.stop(),TM(t))})),t.Xr}function PM(t){return t.Zr||(t.Zr=function(e,t,n){const r=e;return r.Or(),new uM(t,r.ir,r.authCredentials,r.appCheckCredentials,r.k,n)}(t.datastore,t.asyncQueue,{Di:(async function(e){PM(e).kr()}).bind(null,t),Ni:(async function(e,t){t&&PM(e).Sr&&await async function(e,t){if(qx(n=t.code)&&n!==PR.ABORTED){const n=e.Qr.shift();PM(e).wr(),await kM(e,()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t)),await SM(e)}var n}(e,t),CM(e)&&AM(e)}).bind(null,t),Nr:(async function(e){const t=PM(e);for(const n of e.Qr)t.Dr(n.mutations)}).bind(null,t),Cr:(async function(e,t,n){const r=e.Qr.shift(),i=vO.from(r,t,n);await kM(e,()=>e.remoteSyncer.applySuccessfulWrite(i)),await SM(e)}).bind(null,t)}),t.zr.push(async e=>{e?(t.Zr.wr(),await SM(t)):(await t.Zr.stop(),0<t.Qr.length&&(kR("RemoteStore",`Stopping write stream with ${t.Qr.length} pending writes`),t.Qr=[]))})),t.Zr}class xM{constructor(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new DR,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(e=>{})}static createAndSchedule(e,t,n,r,i){const s=Date.now()+n,o=new xM(e,t,s,r,i);return o.start(n),o}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new xR(PR.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 DM(e,t){if(SR("AsyncQueue",`${t}: ${e}`),lO(e))return new xR(PR.UNAVAILABLE,`${t}: ${e}`);throw e}class OM{constructor(n){this.comparator=n?(e,t)=>n(e,t)||pP.comparator(e.key,t.key):(e,t)=>pP.comparator(e.key,t.key),this.keyedMap=Gx,this.sortedSet=new Bx(this.comparator)}static emptySet(e){return new OM(e.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){var t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(n){this.sortedSet.inorderTraversal((e,t)=>(n(e),!1))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){var t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof OM))return!1;if(this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),n=e.sortedSet.getIterator();for(;t.hasNext();){const e=t.getNext().key,r=n.getNext().key;if(!e.isEqual(r))return!1}return!0}toString(){const t=[];return this.forEach(e=>{t.push(e.toString())}),0===t.length?"DocumentSet ()":"DocumentSet (\n "+t.join(" \n")+"\n)"}copy(e,t){const n=new OM;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}class MM{constructor(){this.eo=new Bx(pP.comparator)}track(e){var t=e.doc.key,n=this.eo.get(t);!n||0!==e.type&&3===n.type?this.eo=this.eo.insert(t,e):3===e.type&&1!==n.type?this.eo=this.eo.insert(t,{type:n.type,doc:e.doc}):2===e.type&&2===n.type?this.eo=this.eo.insert(t,{type:2,doc:e.doc}):2===e.type&&0===n.type?this.eo=this.eo.insert(t,{type:0,doc:e.doc}):1===e.type&&0===n.type?this.eo=this.eo.remove(t):1===e.type&&2===n.type?this.eo=this.eo.insert(t,{type:1,doc:n.doc}):0===e.type&&1===n.type?this.eo=this.eo.insert(t,{type:2,doc:e.doc}):NR()}no(){const n=[];return this.eo.inorderTraversal((e,t)=>{n.push(t)}),n}}class LM{constructor(e,t,n,r,i,s,o,a){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=o,this.excludesMetadataChanges=a}static fromInitialDocuments(e,t,n,r){const i=[];return t.forEach(e=>{i.push({type:0,doc:e})}),new LM(e,t,OM.emptySet(t),i,n,r,!0,!1)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&sx(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(t[r].type!==n[r].type||!t[r].doc.isEqual(n[r].doc))return!1;return!0}}class FM{constructor(){this.so=void 0,this.listeners=[]}}class UM{constructor(){this.queries=new i1(e=>ox(e),sx),this.onlineState="Unknown",this.io=new Set}}async function jM(e,t){const n=e,r=t.query;let i=!1,s=n.queries.get(r);if(s||(i=!0,s=new FM),i)try{s.so=await n.onListen(r)}catch(e){const n=DM(e,`Initialization of query '${ax(t.query)}' failed`);return void t.onError(n)}n.queries.set(r,s),s.listeners.push(t),t.ro(n.onlineState),!s.so||t.oo(s.so)&&VM(n)}async function qM(e,t){const n=e,r=t.query;let i=!1;const s=n.queries.get(r);if(s){const e=s.listeners.indexOf(t);0<=e&&(s.listeners.splice(e,1),i=0===s.listeners.length)}if(i)return n.queries.delete(r),n.onUnlisten(r)}function VM(e){e.io.forEach(e=>{e.next()})}class BM{constructor(e,t,n){this.query=e,this.co=t,this.ao=!1,this.uo=null,this.onlineState="Unknown",this.options=n||{}}oo(e){if(!this.options.includeMetadataChanges){const t=[];for(const n of e.docChanges)3!==n.type&&t.push(n);e=new LM(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0)}let t=!1;return this.ao?this.ho(e)&&(this.co.next(e),t=!0):this.lo(e,this.onlineState)&&(this.fo(e),t=!0),this.uo=e,t}onError(e){this.co.error(e)}ro(e){this.onlineState=e;let t=!1;return this.uo&&!this.ao&&this.lo(this.uo,e)&&(this.fo(this.uo),t=!0),t}lo(e,t){return!e.fromCache||!(this.options.wo&&"Offline"!==t||e.docs.isEmpty()&&"Offline"!==t)}ho(e){if(0<e.docChanges.length)return!0;var t=this.uo&&this.uo.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}fo(e){e=LM.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache),this.ao=!0,this.co.next(e)}}class WM{constructor(e,t){this.payload=e,this.byteLength=t}_o(){return"metadata"in this.payload}}class $M{constructor(e){this.k=e}Hn(e){return vD(this.k,e)}Jn(e){return e.metadata.exists?TD(this.k,e.document,!1):AP.newNoDocument(this.Hn(e.metadata.name),this.Yn(e.metadata.readTime))}Yn(e){return pD(e)}}class KM{constructor(e,t,n){this.mo=e,this.localStore=t,this.k=n,this.queries=[],this.documents=[],this.progress=zM(e)}yo(e){this.progress.bytesLoaded+=e.byteLength;let t=this.progress.documentsLoaded;return e.payload.namedQuery?this.queries.push(e.payload.namedQuery):e.payload.documentMetadata?(this.documents.push({metadata:e.payload.documentMetadata}),e.payload.documentMetadata.exists||++t):e.payload.document&&(this.documents[this.documents.length-1].document=e.payload.document,++t),t!==this.progress.documentsLoaded?(this.progress.documentsLoaded=t,Object.assign({},this.progress)):null}po(e){const t=new Map,n=new $M(this.k);for(const i of e)if(i.metadata.queries){const e=n.Hn(i.metadata.name);for(const n of i.metadata.queries){var r=(t.get(n)||Jx()).add(e);t.set(n,r)}}return t}async complete(){const e=await async function(e,t,n,r){const i=e;let s=Jx(),o=Hx,a=Qx;for(const e of n){const n=t.Hn(e.metadata.name);e.document&&(s=s.add(n)),o=o.insert(n,t.Jn(e)),a=a.insert(n,t.Yn(e.metadata.readTime))}const c=i.Qn.newChangeBuffer({trackRemovals:!0}),l=await A1(i,(r=r,rx(YP(ZR.fromString(`__bundle__/docs/${r}`)))));return i.persistence.runTransaction("Apply bundle documents","readwrite",t=>C1(t,c,o,GR.min(),a).next(e=>(c.apply(t),e)).next(e=>i.He.removeMatchingKeysForTargetId(t,l.targetId).next(()=>i.He.addMatchingKeys(t,s,l.targetId)).next(()=>i.Wn.Vn(t,e)).next(()=>e)))}(this.localStore,new $M(this.k),this.documents,this.mo.id),t=this.po(this.documents);for(const e of this.queries)await async function(e,n,r=Jx()){const i=await A1(e,rx(NO(n.bundledQuery))),s=e;return s.persistence.runTransaction("Save named query","readwrite",e=>{var t=pD(n.readTime);if(0<=i.snapshotVersion.compareTo(t))return s.Ye.saveNamedQuery(e,n);t=i.withResumeToken(rP.EMPTY_BYTE_STRING,t);return s.qn=s.qn.insert(t.targetId,t),s.He.updateTargetData(e,t).next(()=>s.He.removeMatchingKeysForTargetId(e,i.targetId)).next(()=>s.He.addMatchingKeys(e,r,i.targetId)).next(()=>s.Ye.saveNamedQuery(e,n))})}(this.localStore,e,t.get(e.name));return this.progress.taskState="Success",new y1(Object.assign({},this.progress),e)}}function zM(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}class HM{constructor(e){this.key=e}}class GM{constructor(e){this.key=e}}class QM{constructor(e,t){this.query=e,this.To=t,this.Eo=null,this.current=!1,this.Io=Jx(),this.mutatedKeys=Jx(),this.Ao=lx(e),this.Ro=new OM(this.Ao)}get bo(){return this.To}Po(e,t){const a=t?t.vo:new MM,c=(t||this).Ro;let l=(t||this).mutatedKeys,u=c,h=!1;const d=JP(this.query)&&c.size===this.query.limit?c.last():null,p=XP(this.query)&&c.size===this.query.limit?c.first():null;if(e.inorderTraversal((e,t)=>{const n=c.get(e),r=cx(this.query,t)?t:null,i=!!n&&this.mutatedKeys.has(n.key),s=!!r&&(r.hasLocalMutations||this.mutatedKeys.has(r.key)&&r.hasCommittedMutations);let o=!1;n&&r?n.data.isEqual(r.data)?i!==s&&(a.track({type:3,doc:r}),o=!0):this.Vo(n,r)||(a.track({type:2,doc:r}),o=!0,(d&&0<this.Ao(r,d)||p&&this.Ao(r,p)<0)&&(h=!0)):!n&&r?(a.track({type:0,doc:r}),o=!0):n&&!r&&(a.track({type:1,doc:n}),o=!0,(d||p)&&(h=!0)),o&&(l=r?(u=u.add(r),s?l.add(e):l.delete(e)):(u=u.delete(e),l.delete(e)))}),JP(this.query)||XP(this.query))for(;u.size>this.query.limit;){const e=JP(this.query)?u.last():u.first();u=u.delete(e.key),l=l.delete(e.key),a.track({type:1,doc:e})}return{Ro:u,vo:a,Bn:h,mutatedKeys:l}}Vo(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n){var r=this.Ro;this.Ro=e.Ro,this.mutatedKeys=e.mutatedKeys;const i=e.vo.no();i.sort((e,t)=>function(e,t){var n=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return NR()}};return n(e)-n(t)}(e.type,t.type)||this.Ao(e.doc,t.doc)),this.So(n);var s=t?this.Do():[],o=0===this.Io.size&&this.current?1:0,a=o!==this.Eo;return this.Eo=o,0!==i.length||a?{snapshot:new LM(this.query,e.Ro,r,i,e.mutatedKeys,0==o,a,!1),Co:s}:{Co:s}}ro(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({Ro:this.Ro,vo:new MM,mutatedKeys:this.mutatedKeys,Bn:!1},!1)):{Co:[]}}No(e){return!this.To.has(e)&&!!this.Ro.has(e)&&!this.Ro.get(e).hasLocalMutations}So(e){e&&(e.addedDocuments.forEach(e=>this.To=this.To.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.To=this.To.delete(e)),this.current=e.current)}Do(){if(!this.current)return[];const t=this.Io;this.Io=Jx(),this.Ro.forEach(e=>{this.No(e.key)&&(this.Io=this.Io.add(e.key))});const n=[];return t.forEach(e=>{this.Io.has(e)||n.push(new GM(e))}),this.Io.forEach(e=>{t.has(e)||n.push(new HM(e))}),n}ko(e){this.To=e.zn,this.Io=Jx();var t=this.Po(e.documents);return this.applyChanges(t,!0)}xo(){return LM.fromInitialDocuments(this.query,this.Ro,this.mutatedKeys,0===this.Eo)}}class YM{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class JM{constructor(e){this.key=e,this.$o=!1}}class XM{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.Oo={},this.Mo=new i1(e=>ox(e),sx),this.Fo=new Map,this.Lo=new Set,this.Bo=new Bx(pP.comparator),this.Uo=new Map,this.qo=new O1,this.Ko={},this.jo=new Map,this.Qo=zO.re(),this.onlineState="Unknown",this.Wo=void 0}get isPrimaryClient(){return!0===this.Wo}}async function ZM(n,e,t,r){n.Go=(e,s,t)=>async function(e,t,n){let r=t.view.Po(s);r.Bn&&(r=await R1(e.localStore,t.query,!1).then(({documents:e})=>t.view.Po(e,r)));var i=n&&n.targetChanges.get(t.targetId),i=t.view.applyChanges(r,e.isPrimaryClient,i);return cL(e,t.targetId,i.Co),i.snapshot}(n,e,t);const i=await R1(n.localStore,e,!0),s=new QM(e,i.zn),o=s.Po(i.documents),a=eD.createSynthesizedTargetChangeForCurrentChange(t,r&&"Offline"!==n.onlineState),c=s.applyChanges(o,n.isPrimaryClient,a);cL(n,t,c.Co);var l=new YM(e,t,s);return n.Mo.set(e,l),n.Fo.has(t)?n.Fo.get(t).push(e):n.Fo.set(t,[e]),c.snapshot}async function eL(e,t,n){const r=gL(e);try{const e=await function(e,r){const i=e,s=HR.now(),t=r.reduce((e,t)=>e.add(t.key),Jx());let o;return i.persistence.runTransaction("Locally write mutations","readwrite",n=>i.Wn.vn(n,t).next(e=>{o=e;const t=[];for(const n of r){const r=function(e,t){let n=null;for(const r of e.fieldTransforms){const e=t.data.field(r.field),i=fx(r.transform,e||null);null!=i&&(null==n&&(n=CP.empty()),n.set(r.field,i))}return n||null}(n,o.get(n.key));null!=r&&t.push(new Dx(n.key,r,function r(e){const i=[];return YR(e.fields,(e,t)=>{const n=new tP([e]);if(kP(t)){const e=r(t.mapValue).fields;if(0===e.length)i.push(n);else for(const t of e)i.push(n.child(t))}else i.push(n)}),new nP(i)}(r.value.mapValue),kx.exists(!0)))}return i.An.addMutationBatch(n,s,t,r)})).then(e=>(e.applyToLocalDocumentSet(o),{batchId:e.batchId,changes:o}))}(r.localStore,t);r.sharedClientState.addPendingMutation(e.batchId),function(e,t,n){let r=e.Ko[e.currentUser.toKey()];r=r||new Bx($R),r=r.insert(t,n),e.Ko[e.currentUser.toKey()]=r}(r,e.batchId,n),await uL(r,e.changes),await SM(r.remoteStore)}catch(e){const t=DM(e,"Failed to persist write");n.reject(t)}}async function tL(e,t){const r=e;try{const e=await S1(r.localStore,t);t.targetChanges.forEach((e,t)=>{const n=r.Uo.get(t);n&&(RR(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1),0<e.addedDocuments.size?n.$o=!0:0<e.modifiedDocuments.size?RR(n.$o):0<e.removedDocuments.size&&(RR(n.$o),n.$o=!1))}),await uL(r,e,t)}catch(e){await JO(e)}}function nL(r,i,e){const t=r;if(t.isPrimaryClient&&0===e||!t.isPrimaryClient&&1===e){const r=[];t.Mo.forEach((e,t)=>{var n=t.view.ro(i);n.snapshot&&r.push(n.snapshot)}),function(e,n){const t=e;t.onlineState=n;let r=!1;t.queries.forEach((e,t)=>{for(const e of t.listeners)e.ro(n)&&(r=!0)}),r&&VM(t)}(t.eventManager,i),r.length&&t.Oo.br(r),t.onlineState=i,t.isPrimaryClient&&t.sharedClientState.setOnlineState(i)}}async function rL(e,t){const n=e,r=t.batch.batchId;try{const e=await function(e,r){const i=e;return i.persistence.runTransaction("Acknowledge batch","readwrite-primary",e=>{const t=r.batch.keys(),n=i.Qn.newChangeBuffer({trackRemovals:!0});return function(e,t,r,i){const s=r.batch,n=s.keys();let o=iO.resolve();return n.forEach(n=>{o=o.next(()=>i.getEntry(t,n)).next(e=>{var t=r.docVersions.get(n);RR(null!==t),e.version.compareTo(t)<0&&(s.applyToRemoteDocument(e,r),e.isValidDocument()&&i.addEntry(e,r.commitVersion))})}),o.next(()=>e.An.removeMutationBatch(t,s))}(i,e,r,n).next(()=>n.apply(e)).next(()=>i.An.performConsistencyCheck(e)).next(()=>i.Wn.vn(e,t))})}(n.localStore,t);sL(n,r,null),iL(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await uL(n,e)}catch(e){await JO(e)}}function iL(e,t){(e.jo.get(t)||[]).forEach(e=>{e.resolve()}),e.jo.delete(t)}function sL(e,t,n){const r=e;let i=r.Ko[r.currentUser.toKey()];if(i){const e=i.get(t);e&&(n?e.reject(n):e.resolve(),i=i.remove(t)),r.Ko[r.currentUser.toKey()]=i}}function oL(t,e,n=null){t.sharedClientState.removeLocalQueryTarget(e);for(const r of t.Fo.get(e))t.Mo.delete(r),n&&t.Oo.zo(r,n);t.Fo.delete(e),t.isPrimaryClient&&t.qo.us(e).forEach(e=>{t.qo.containsKey(e)||aL(t,e)})}function aL(e,t){e.Lo.delete(t.path.canonicalString());var n=e.Bo.get(t);null!==n&&(vM(e.remoteStore,n),e.Bo=e.Bo.remove(t),e.Uo.delete(n),lL(e))}function cL(e,t,n){for(const r of n)r instanceof HM?(e.qo.addReference(r.key,t),function(e,t){const n=t.key,r=n.path.canonicalString();e.Bo.get(n)||e.Lo.has(r)||(kR("SyncEngine","New document in limbo: "+n),e.Lo.add(r),lL(e))}(e,r)):r instanceof GM?(kR("SyncEngine","Document no longer in limbo: "+r.key),e.qo.removeReference(r.key,t),e.qo.containsKey(r.key)||aL(e,r.key)):NR()}function lL(e){for(;0<e.Lo.size&&e.Bo.size<e.maxConcurrentLimboResolutions;){var t=e.Lo.values().next().value;e.Lo.delete(t);var n=new pP(ZR.fromString(t)),t=e.Qo.next();e.Uo.set(t,new JM(n)),e.Bo=e.Bo.insert(n,t),mM(e.remoteStore,new yO(rx(YP(n.path)),t,2,BR.I))}}async function uL(e,t,r){const i=e,s=[],o=[],a=[];i.Mo.isEmpty()||(i.Mo.forEach((e,n)=>{a.push(i.Go(n,t,r).then(e=>{var t;e&&(i.isPrimaryClient&&i.sharedClientState.updateQueryState(n.targetId,e.fromCache?"not-current":"current"),s.push(e),t=w1.$n(n.targetId,e),o.push(t))}))}),await Promise.all(a),i.Oo.br(s),await async function(e,t){const r=e;try{await r.persistence.runTransaction("notifyLocalViewChanges","readwrite",n=>iO.forEach(t,t=>iO.forEach(t.kn,e=>r.persistence.referenceDelegate.addReference(n,t.targetId,e)).next(()=>iO.forEach(t.xn,e=>r.persistence.referenceDelegate.removeReference(n,t.targetId,e)))))}catch(e){if(!lO(e))throw e;kR("LocalStore","Failed to update sequence numbers: "+e)}for(const e of t){const t=e.targetId;if(!e.fromCache){const e=r.qn.get(t),n=e.snapshotVersion,i=e.withLastLimboFreeSnapshotVersion(n);r.qn=r.qn.insert(t,i)}}}(i.localStore,o))}async function hL(r,e){const i=r;if(fL(i),gL(i),!0===e&&!0!==i.Wo){const r=i.sharedClientState.getAllActiveQueryTargets(),e=await dL(i,r.toArray());i.Wo=!0,await NM(i.remoteStore,!0);for(const r of e)mM(i.remoteStore,r)}else if(!1===e&&!1!==i.Wo){const r=[];let n=Promise.resolve();i.Fo.forEach((e,t)=>{i.sharedClientState.isLocalQueryTarget(t)?r.push(t):n=n.then(()=>(oL(i,t),N1(i.localStore,t,!0))),vM(i.remoteStore,t)}),await n,await dL(i,r),function(){const n=i;n.Uo.forEach((e,t)=>{vM(n.remoteStore,t)}),n.qo.hs(),n.Uo=new Map,n.Bo=new Bx(pP.comparator)}(),i.Wo=!1,await NM(i.remoteStore,!1)}}async function dL(t,n){const r=t,i=[],s=[];for(const t of n){let e;const u=r.Fo.get(t);if(u&&0!==u.length){e=await A1(r.localStore,rx(u[0]));for(const t of u){const n=r.Mo.get(t),u=(o=r,a=n,l=c=void 0,l=await R1((c=o).localStore,a.query,!0),l=a.view.ko(l),c.isPrimaryClient&&cL(c,a.targetId,l.Co),await l);u.snapshot&&s.push(u.snapshot)}}else{const u=await P1(r.localStore,t);e=await A1(r.localStore,u),await ZM(r,pL(u),t,!1)}i.push(e)}var o,a,c,l;return r.Oo.br(s),i}function pL(e){return QP(e.path,e.collectionGroup,e.orderBy,e.filters,e.limit,"F",e.startAt,e.endAt)}function fL(e){const t=e;return t.remoteStore.remoteSyncer.applyRemoteEvent=tL.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=(function(e,t){const n=e,r=n.Uo.get(t);if(r&&r.$o)return Jx().add(r.key);{let e=Jx();const r=n.Fo.get(t);if(!r)return e;for(const t of r){const r=n.Mo.get(t);e=e.unionWith(r.view.bo)}return e}}).bind(null,t),t.remoteStore.remoteSyncer.rejectListen=(async function(e,t,n){const r=e;r.sharedClientState.updateQueryState(t,"rejected",n);const i=r.Uo.get(t),s=i&&i.key;if(s){let e=new Bx(pP.comparator);e=e.insert(s,AP.newNoDocument(s,GR.min()));const n=Jx().add(s),i=new Zx(GR.min(),new Map,new Kx($R),e,n);await tL(r,i),r.Bo=r.Bo.remove(s),r.Uo.delete(t),lL(r)}else await N1(r.localStore,t,!1).then(()=>oL(r,t,n)).catch(JO)}).bind(null,t),t.Oo.br=(function(e,t){const n=e;let r=!1;for(const e of t){const t=e.query,i=n.queries.get(t);if(i){for(const t of i.listeners)t.oo(e)&&(r=!0);i.so=e}}r&&VM(n)}).bind(null,t.eventManager),t.Oo.zo=(function(e,t,n){const r=e,i=r.queries.get(t);if(i)for(const e of i.listeners)e.onError(n);r.queries.delete(t)}).bind(null,t.eventManager),t}function gL(e){const t=e;return t.remoteStore.remoteSyncer.applySuccessfulWrite=rL.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=(async function(e,t,n){const r=e;try{const e=await function(e,r){const i=e;return i.persistence.runTransaction("Reject batch","readwrite-primary",t=>{let n;return i.An.lookupMutationBatch(t,r).next(e=>(RR(null!==e),n=e.keys(),i.An.removeMutationBatch(t,e))).next(()=>i.An.performConsistencyCheck(t)).next(()=>i.Wn.vn(t,n))})}(r.localStore,t);sL(r,t,n),iL(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),await uL(r,e)}catch(n){await JO(n)}}).bind(null,t),t}class mL{constructor(){this.synchronizeTabs=!1}async initialize(e){this.k=oM(e.databaseInfo.databaseId),this.sharedClientState=this.Jo(e),this.persistence=this.Yo(e),await this.persistence.start(),this.gcScheduler=this.Xo(e),this.localStore=this.Zo(e)}Xo(e){return null}Zo(e){return T1(this.persistence,new b1,e.initialUser,this.k)}Yo(e){return new q1(B1.ks,this.k)}Jo(e){return new X1}async terminate(){this.gcScheduler&&this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class vL extends mL{constructor(e,t,n){super(),this.tc=e,this.cacheSizeBytes=t,this.forceOwnership=n,this.synchronizeTabs=!1}async initialize(e){await super.initialize(e),await async function(e){const t=e;return t.persistence.runTransaction("Synchronize last document change read time","readonly",t=>function(){const e=l1(t);let r=GR.min();return e.jt({index:zD.readTimeIndex,reverse:!0},(e,t,n)=>{t.readTime&&(r=TO(t.readTime)),n.done()}).next(()=>r)}()).then(e=>{t.jn=e})}(this.localStore),await this.tc.initialize(this,e),await gL(this.tc.syncEngine),await SM(this.tc.remoteStore),await this.persistence.sn(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(this.localStore),Promise.resolve()))}Zo(e){return T1(this.persistence,new b1,e.initialUser,this.k)}Xo(e){var t=this.persistence.referenceDelegate.garbageCollector;return new e1(t,e.asyncQueue)}Yo(e){var t=v1(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?UO.withCacheSize(this.cacheSizeBytes):UO.DEFAULT;return new f1(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,iM(),sM(),this.k,this.sharedClientState,!!this.forceOwnership)}Jo(e){return new X1}}class yL extends vL{constructor(e,t){super(e,t,!1),this.tc=e,this.cacheSizeBytes=t,this.synchronizeTabs=!0}async initialize(e){await super.initialize(e);var t=this.tc.syncEngine;this.sharedClientState instanceof J1&&(this.sharedClientState.syncEngine={mi:(async function(e,t,n,r){var i=e,s=await function(e,n){const r=e,i=r.An;return r.persistence.runTransaction("Lookup mutation documents","readonly",t=>i.Zt(t,n).next(e=>e?r.Wn.vn(t,e):iO.resolve(null)))}(i.localStore,t);null!==s?("pending"===n?await SM(i.remoteStore):"acknowledged"===n||"rejected"===n?(sL(i,t,r||null),iL(i,t),i.localStore.An.ee(t)):NR(),await uL(i,s)):kR("SyncEngine","Cannot apply mutation batch with id: "+t)}).bind(null,t),gi:(async function(e,t,n,r){const i=e;if(i.Wo)kR("SyncEngine","Ignoring unexpected query state notification.");else if(i.Fo.has(t))switch(n){case"current":case"not-current":{const e=await x1(i.localStore),r=Zx.createSynthesizedRemoteEventForCurrentChange(t,"current"===n);await uL(i,e,r);break}case"rejected":await N1(i.localStore,t,!0),oL(i,t,r);break;default:NR()}}).bind(null,t),yi:(async function(e,t,n){const r=fL(e);if(r.Wo){for(const e of t)if(r.Fo.has(e))kR("SyncEngine","Adding an already active target "+e);else{const t=await P1(r.localStore,e),n=await A1(r.localStore,t);await ZM(r,pL(t),n.targetId,!1),mM(r.remoteStore,n)}for(const e of n)r.Fo.has(e)&&await N1(r.localStore,e,!1).then(()=>{vM(r.remoteStore,e),oL(r,e)}).catch(JO)}}).bind(null,t),Tn:(function(e){return e.localStore.persistence.Tn()}).bind(null,t),_i:(async function(e){const t=e;return x1(t.localStore).then(e=>uL(t,e))}).bind(null,t)},await this.sharedClientState.start()),await this.persistence.sn(async e=>{await hL(this.tc.syncEngine,e),this.gcScheduler&&(e&&!this.gcScheduler.started?this.gcScheduler.start(this.localStore):e||this.gcScheduler.stop())})}Jo(e){var t=iM();if(!J1.Pt(t))throw new xR(PR.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var n=v1(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new J1(t,e.asyncQueue,n,e.clientId,e.initialUser)}}class _L{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=e=>nL(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=(async function(e,t){const n=e;if(!n.currentUser.isEqual(t)){kR("SyncEngine","User change. New user:",t.toKey());const r=await E1(n.localStore,t);n.currentUser=t,(e=n).jo.forEach(e=>{e.forEach(e=>{e.reject(new xR(PR.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.jo.clear(),n.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),await uL(n,r.Gn)}}).bind(null,this.syncEngine),await NM(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new UM}createDatastore(e){var t,n,r,i,s=oM(e.databaseInfo.databaseId),t=(t=e.databaseInfo,new rM(t));return n=e.authCredentials,r=e.appCheckCredentials,i=t,e=s,new hM(n,r,i,e)}createRemoteStore(e){return t=this.localStore,n=this.datastore,r=e.asyncQueue,i=e=>nL(this.syncEngine,e,0),s=new(eM.Pt()?eM:Z1),new pM(t,n,r,i,s);var t,n,r,i,s}createSyncEngine(e,t){return function(e,t,n,r,i,s,o){const a=new XM(e,t,n,r,i,s);return o&&(a.Wo=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}terminate(){return async function(e){const t=e;kR("RemoteStore","RemoteStore shutting down."),t.Gr.add(5),await gM(t),t.Hr.shutdown(),t.Jr.set("Unknown")}(this.remoteStore)}}function wL(t,n=10240){let r=0;return{async read(){if(r<t.byteLength){var e={value:t.slice(r,r+n),done:!1};return r+=n,e}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.reject("unimplemented")}}class bL{constructor(e){this.observer=e,this.muted=!1}next(e){this.observer.next&&this.ec(this.observer.next,e)}error(e){this.observer.error?this.ec(this.observer.error,e):console.error("Uncaught Error in snapshot listener:",e)}nc(){this.muted=!0}ec(e,t){this.muted||setTimeout(()=>{this.muted||e(t)},0)}}class IL{constructor(e,t){this.sc=e,this.k=t,this.metadata=new DR,this.buffer=new Uint8Array,this.ic=new TextDecoder("utf-8"),this.rc().then(e=>{e&&e._o()?this.metadata.resolve(e.payload.metadata):this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null==e?void 0:e.payload)}`))},e=>this.metadata.reject(e))}close(){return this.sc.cancel()}async getMetadata(){return this.metadata.promise}async Ho(){return await this.getMetadata(),this.rc()}async rc(){var e=await this.oc();if(null===e)return null;var t=this.ic.decode(e),n=Number(t);isNaN(n)&&this.cc(`length string (${t}) is not valid number`);t=await this.ac(n);return new WM(JSON.parse(t),e.length+n)}uc(){return this.buffer.findIndex(e=>e==="{".charCodeAt(0))}async oc(){for(;this.uc()<0&&!await this.hc(););if(0===this.buffer.length)return null;var e=this.uc();e<0&&this.cc("Reached the end of bundle when a length string is expected.");var t=this.buffer.slice(0,e);return this.buffer=this.buffer.slice(e),t}async ac(e){for(;this.buffer.length<e;)await this.hc()&&this.cc("Reached the end of bundle when more is expected.");var t=this.ic.decode(this.buffer.slice(0,e));return this.buffer=this.buffer.slice(e),t}cc(e){throw this.sc.cancel(),new Error(`Invalid bundle format: ${e}`)}async hc(){var e=await this.sc.read();if(!e.done){const 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 TL{constructor(e){this.datastore=e,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}async lookup(e){if(this.ensureCommitNotCalled(),0<this.mutations.length)throw new xR(PR.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");const t=await async function(e,t){const r=e,n=wD(r.k)+"/documents",i={documents:t.map(e=>mD(r.k,e))},s=await r.ji("BatchGetDocuments",n,i),o=new Map;s.forEach(e=>{const t=(n=r.k,"found"in(e=e)?function(e,t){RR(!!t.found),t.found.name,t.found.updateTime;var n=vD(e,t.found.name),r=pD(t.found.updateTime),i=new CP({mapValue:{fields:t.found.fields}});return AP.newFoundDocument(n,r,i)}(n,e):"missing"in e?function(e,t){RR(!!t.missing),RR(!!t.readTime);var n=vD(e,t.missing),r=pD(t.readTime);return AP.newNoDocument(n,r)}(n,e):NR());var n;o.set(t.key.toString(),t)});const a=[];return t.forEach(e=>{var t=o.get(e.toString());RR(!!t),a.push(t)}),a}(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.lastWriteError=e}this.writtenDocs.add(e.toString())}delete(e){this.write(new Fx(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;const t=this.readVersions;this.mutations.forEach(e=>{t.delete(e.key.toString())}),t.forEach((e,t)=>{var n=pP.fromPath(t);this.mutations.push(new Ux(n,this.precondition(n)))}),await async function(e,t){const n=e,r=wD(n.k)+"/documents",i={writes:t.map(e=>ED(n.k,e))};await n.Bi("Commit",r,i)}(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw NR();t=GR.min()}var n=this.readVersions.get(e.key.toString());if(n){if(!t.isEqual(n))throw new xR(PR.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),t)}precondition(e){var t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&t?kx.updateTime(t):kx.none()}preconditionForUpdate(e){const t=this.readVersions.get(e.toString());if(this.writtenDocs.has(e.toString())||!t)return kx.exists(!0);if(t.isEqual(GR.min()))throw new xR(PR.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return kx.updateTime(t)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}class EL{constructor(e,t,n,r){this.asyncQueue=e,this.datastore=t,this.updateFunction=n,this.deferred=r,this.lc=5,this.ur=new aM(this.asyncQueue,"transaction_retry")}run(){--this.lc,this.fc()}fc(){this.ur.Zi(async()=>{const t=new TL(this.datastore),e=this.dc(t);e&&e.then(e=>{this.asyncQueue.enqueueAndForget(()=>t.commit().then(()=>{this.deferred.resolve(e)}).catch(e=>{this.wc(e)}))}).catch(e=>{this.wc(e)})})}dc(e){try{var t=this.updateFunction(e);return!uP(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}}wc(e){0<this.lc&&this._c(e)?(--this.lc,this.asyncQueue.enqueueAndForget(()=>(this.fc(),Promise.resolve()))):this.deferred.reject(e)}_c(e){if("FirebaseError"!==e.name)return!1;var t=e.code;return"aborted"===t||"failed-precondition"===t||!qx(t)}}class kL{constructor(e,t,n,r){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=bR.UNAUTHENTICATED,this.clientId=WR.A(),this.authCredentialListener=()=>Promise.resolve(),this.authCredentials.start(n,async e=>{kR("FirestoreClient","Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(n,()=>Promise.resolve())}async getConfiguration(){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}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new xR(PR.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const n=new DR;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this.onlineComponents&&await this.onlineComponents.terminate(),this.offlineComponents&&await this.offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),n.resolve()}catch(e){var t=DM(e,"Failed to shutdown persistence");n.reject(t)}}),n.promise}}async function SL(e,t){e.asyncQueue.verifyOperationInProgress(),kR("FirestoreClient","Initializing OfflineComponentProvider");var n=await e.getConfiguration();await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener(async e=>{r.isEqual(e)||(await E1(t.localStore,e),r=e)}),t.persistence.setDatabaseDeletedListener(()=>e.terminate()),e.offlineComponents=t}async function CL(e,t){e.asyncQueue.verifyOperationInProgress();var n=await AL(e);kR("FirestoreClient","Initializing OnlineComponentProvider");var r=await e.getConfiguration();await t.initialize(n,r),e.setCredentialChangeListener(e=>async function(e,t){const n=e;n.asyncQueue.verifyOperationInProgress(),kR("RemoteStore","RemoteStore received new credentials");var r=IM(n);n.Gr.add(3),await gM(n),r&&n.Jr.set("Unknown"),await n.remoteSyncer.handleCredentialChange(t),n.Gr.delete(3),await fM(n)}(t.remoteStore,e)),e.onlineComponents=t}async function AL(e){return e.offlineComponents||(kR("FirestoreClient","Using default OfflineComponentProvider"),await SL(e,new mL)),e.offlineComponents}async function NL(e){return e.onlineComponents||(kR("FirestoreClient","Using default OnlineComponentProvider"),await CL(e,new _L)),e.onlineComponents}function RL(e){return AL(e).then(e=>e.persistence)}function PL(e){return AL(e).then(e=>e.localStore)}function xL(e){return NL(e).then(e=>e.remoteStore)}function DL(e){return NL(e).then(e=>e.syncEngine)}async function OL(e){const t=await NL(e),n=t.eventManager;return n.onListen=(async function(e,t){const n=fL(e);let r,i;const s=n.Mo.get(t);if(s)r=s.targetId,n.sharedClientState.addLocalQueryTarget(r),i=s.view.xo();else{const e=await A1(n.localStore,rx(t)),s=n.sharedClientState.addLocalQueryTarget(e.targetId);r=e.targetId,i=await ZM(n,t,r,"current"===s),n.isPrimaryClient&&mM(n.remoteStore,e)}return i}).bind(null,t.syncEngine),n.onUnlisten=(async function(e,t){const n=e,r=n.Mo.get(t),i=n.Fo.get(r.targetId);if(1<i.length)return n.Fo.set(r.targetId,i.filter(e=>!sx(e,t))),void n.Mo.delete(t);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)||await N1(n.localStore,r.targetId,!1).then(()=>{n.sharedClientState.clearQueryState(r.targetId),vM(n.remoteStore,r.targetId),oL(n,r.targetId)}).catch(JO)):(oL(n,r.targetId),await N1(n.localStore,r.targetId,!0))}).bind(null,t.syncEngine),n}function ML(e,t,n={}){const r=new DR;return e.asyncQueue.enqueueAndForget(async()=>function(n,r,i,s,o){const e=new bL({next:e=>{r.enqueueAndForget(()=>qM(n,a));var t=e.docs.has(i);!t&&e.fromCache?o.reject(new xR(PR.UNAVAILABLE,"Failed to get document because the client is offline.")):t&&e.fromCache&&s&&"server"===s.source?o.reject(new xR(PR.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.)')):o.resolve(e)},error:e=>o.reject(e)}),a=new BM(YP(i.path),e,{includeMetadataChanges:!0,wo:!0});return jM(n,a)}(await OL(e),e.asyncQueue,t,n,r)),r.promise}function LL(e,t,n={}){const r=new DR;return e.asyncQueue.enqueueAndForget(async()=>function(t,n,e,r,i){const s=new bL({next:e=>{n.enqueueAndForget(()=>qM(t,o)),e.fromCache&&"server"===r.source?i.reject(new xR(PR.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(e)},error:e=>i.reject(e)}),o=new BM(e,s,{includeMetadataChanges:!0,wo:!0});return jM(t,o)}(await OL(e),e.asyncQueue,t,n,r)),r.promise}function FL(e,t,n,r){const i=(n=n,t=oM(t),s="string"==typeof n?(new TextEncoder).encode(n):n,n=function(e){if(e instanceof Uint8Array)return wL(e,void 0);if(e instanceof ArrayBuffer)return wL(new Uint8Array(e),void 0);if(e instanceof ReadableStream)return e.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}(s),t=t,new IL(n,t));var s;e.asyncQueue.enqueueAndForget(async()=>{!function(e,t,n){const r=e;!async function(t,n,r){try{var i=await n.getMetadata();if(await function(e,t){const n=e,r=pD(t.createTime);return n.persistence.runTransaction("hasNewerBundle","readonly",e=>n.Ye.getBundleMetadata(e,t.id)).then(e=>!!e&&0<=e.createTime.compareTo(r))}(t.localStore,i))return await n.close(),void r._completeWith({taskState:"Success",documentsLoaded:i.totalDocuments,bytesLoaded:i.totalBytes,totalDocuments:i.totalDocuments,totalBytes:i.totalBytes});r._updateProgress(zM(i));const o=new KM(i,t.localStore,n.k);let e=await n.Ho();for(;e;){const t=await o.yo(e);t&&r._updateProgress(t),e=await n.Ho()}var s=await o.complete();await uL(t,s.In,void 0),await function(e,t){const n=e;return n.persistence.runTransaction("Save bundle","readwrite",e=>n.Ye.saveBundleMetadata(e,t))}(t.localStore,i),r._completeWith(s.progress)}catch(t){CR("SyncEngine",`Loading bundle failed with ${t}`),r._failWith(t)}}(r,t,n).then(()=>{r.sharedClientState.notifyBundleLoaded()})}(await DL(e),i,r)})}class UL{constructor(e,t,n,r,i,s,o,a){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=o,this.useFetchStreams=a}}class jL{constructor(e,t){this.projectId=e,this.database=t||"(default)"}get isDefaultDatabase(){return"(default)"===this.database}isEqual(e){return e instanceof jL&&e.projectId===this.projectId&&e.database===this.database}}const qL=new Map;function VL(e,t,n){if(!n)throw new xR(PR.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function BL(e,t,n,r){if(!0===t&&!0===r)throw new xR(PR.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function WL(e){if(!pP.isDocumentKey(e))throw new xR(PR.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function $L(e){if(pP.isDocumentKey(e))throw new xR(PR.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function KL(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return 20<e.length&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"!=typeof e)return"function"==typeof e?"a function":NR();if(e instanceof Array)return"an array";var t=(e=e).constructor?e.constructor.name:null;return t?`a custom ${t} object`:"an object"}function zL(e,t){if((e="_delegate"in e?e._delegate:e)instanceof t)return e;if(t.name===e.constructor.name)throw new xR(PR.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");var n=KL(e);throw new xR(PR.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}function HL(e,t){if(t<=0)throw new xR(PR.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}class GL{constructor(e){var t;if(void 0===e.host){if(void 0!==e.ssl)throw new xR(PR.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=e.host,this.ssl=null===(t=e.ssl)||void 0===t||t;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,void 0===e.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new xR(PR.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.useFetchStreams=!!e.useFetchStreams,BL("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling)}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class QL{constructor(e,t,n){this._authCredentials=t,this._appCheckCredentials=n,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new GL({}),this._settingsFrozen=!1,e instanceof jL?this._databaseId=e:(this._app=e,this._databaseId=function(e){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new xR(PR.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new jL(e.options.projectId)}(e))}get app(){if(!this._app)throw new xR(PR.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 void 0!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new xR(PR.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 GL(e),void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new MR;switch(e.type){case"gapi":var t=e.client;return RR(!("object"!=typeof t||null===t||!t.auth||!t.auth.getAuthHeaderValueForFirstParty)),new jR(t,e.sessionIndex||"0",e.iamToken||null);case"provider":return e.client;default:throw new xR(PR.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){const t=qL.get(e);t&&(kR("ComponentProvider","Removing Datastore"),qL.delete(e),t.terminate())}(this),Promise.resolve()}}class YL{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 XL(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new YL(this.firestore,e,this._key)}}class JL{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new JL(this.firestore,e,this._query)}}class XL extends JL{constructor(e,t,n){super(e,t,YP(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new YL(this.firestore,null,new pP(e))}withConverter(e){return new XL(this.firestore,e,this._path)}}function ZL(e,t,...n){if(e=$d(e),VL("collection","path",t),e instanceof QL){var r=ZR.fromString(t,...n);return $L(r),new XL(e,null,r)}if(!(e instanceof YL||e instanceof XL))throw new xR(PR.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");r=e._path.child(ZR.fromString(t,...n));return $L(r),new XL(e.firestore,null,r)}function eF(e,t,...n){if(e=$d(e),VL("doc","path",t=1===arguments.length?WR.A():t),e instanceof QL){var r=ZR.fromString(t,...n);return WL(r),new YL(e,null,new pP(r))}if(!(e instanceof YL||e instanceof XL))throw new xR(PR.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");r=e._path.child(ZR.fromString(t,...n));return WL(r),new YL(e.firestore,e instanceof XL?e.converter:null,new pP(r))}function tF(e,t){return e=$d(e),t=$d(t),(e instanceof YL||e instanceof XL)&&(t instanceof YL||t instanceof XL)&&e.firestore===t.firestore&&e.path===t.path&&e.converter===t.converter}function nF(e,t){return e=$d(e),t=$d(t),e instanceof JL&&t instanceof JL&&e.firestore===t.firestore&&sx(e._query,t._query)&&e.converter===t.converter}class rF{constructor(){this.mc=Promise.resolve(),this.gc=[],this.yc=!1,this.Tc=[],this.Ec=null,this.Ic=!1,this.Ac=!1,this.Rc=[],this.ur=new aM(this,"async_queue_retry"),this.bc=()=>{var e=sM();e&&kR("AsyncQueue","Visibility state changed to "+e.visibilityState),this.ur.er()};const e=sM();e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.bc)}get isShuttingDown(){return this.yc}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Pc(),this.vc(e)}enterRestrictedMode(e){if(!this.yc){this.yc=!0,this.Ac=e||!1;const t=sM();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.bc)}}enqueue(e){if(this.Pc(),this.yc)return new Promise(()=>{});const t=new DR;return this.vc(()=>this.yc&&this.Ac?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.gc.push(e),this.Vc()))}async Vc(){if(0!==this.gc.length){try{await this.gc[0](),this.gc.shift(),this.ur.reset()}catch(e){if(!lO(e))throw e;kR("AsyncQueue","Operation failed with retryable error: "+e)}0<this.gc.length&&this.ur.Zi(()=>this.Vc())}}vc(e){var t=this.mc.then(()=>(this.Ic=!0,e().catch(e=>{throw this.Ec=e,this.Ic=!1,SR("INTERNAL UNHANDLED ERROR: ",function(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}(e)),e}).then(e=>(this.Ic=!1,e))));return this.mc=t}enqueueAfterDelay(e,t,n){this.Pc(),-1<this.Rc.indexOf(e)&&(t=0);var r=xM.createAndSchedule(this,e,t,n,e=>this.Sc(e));return this.Tc.push(r),r}Pc(){this.Ec&&NR()}verifyOperationInProgress(){}async Dc(){for(var e;await(e=this.mc),e!==this.mc;);}Cc(e){for(const t of this.Tc)if(t.timerId===e)return!0;return!1}Nc(t){return this.Dc().then(()=>{this.Tc.sort((e,t)=>e.targetTimeMs-t.targetTimeMs);for(const e of this.Tc)if(e.skipDelay(),"all"!==t&&e.timerId===t)break;return this.Dc()})}kc(e){this.Rc.push(e)}Sc(e){var t=this.Tc.indexOf(e);this.Tc.splice(t,1)}}function iF(e){return function(e){if("object"==typeof e&&null!==e){var t=e;for(const e of["next","error","complete"])if(e in t&&"function"==typeof t[e])return 1}}(e)}class sF{constructor(){this._progressObserver={},this._taskCompletionResolver=new DR,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)}}var oF,aF,cF,lF;class uF extends QL{constructor(e,t,n){super(e,t,n),this.type="firestore",this._queue=new rF,this._persistenceKey="name"in e?e.name:"[DEFAULT]"}_terminate(){return this._firestoreClient||dF(this),this._firestoreClient.terminate()}}function hF(e){return e._firestoreClient||dF(e),e._firestoreClient.verifyNotTerminated(),e._firestoreClient}function dF(e){var t,n,r,i,s,o=e._freezeSettings(),o=(n=e._databaseId,r=(null===(t=e._app)||void 0===t?void 0:t.options.appId)||"",i=e._persistenceKey,s=o,new UL(n,r,i,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,s.useFetchStreams));e._firestoreClient=new kL(e._authCredentials,e._appCheckCredentials,e._queue,o)}function pF(e,n,r){const i=new DR;return e.asyncQueue.enqueue(async()=>{try{await SL(e,r),await CL(e,n),i.resolve()}catch(e){if(!("FirebaseError"===(t=e).name?t.code===PR.FAILED_PRECONDITION||t.code===PR.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||(22===t.code||20===t.code||11===t.code)))throw e;console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+e),i.reject(e)}var t}).then(()=>i.promise)}function fF(e){return function(e){const t=new DR;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t){const n=e;IM(n.remoteStore)||kR("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{const e=await function(){const t=n.localStore;return t.persistence.runTransaction("Get highest unacknowledged batch id","readonly",e=>t.An.getHighestUnacknowledgedBatchId(e))}();if(-1===e)return void t.resolve();const r=n.jo.get(e)||[];r.push(t),n.jo.set(e,r)}catch(e){const n=DM(e,"Initialization of waitForPendingWrites() operation failed");t.reject(n)}}(await DL(e),t)),t.promise}(hF(e=zL(e,uF)))}function gF(e){return(n=hF(e=zL(e,uF))).asyncQueue.enqueue(async()=>{const e=await RL(n),t=await xL(n);return e.setNetworkEnabled(!0),function(){const e=t;return e.Gr.delete(0),fM(e)}()});var n}function mF(e){return(n=hF(e=zL(e,uF))).asyncQueue.enqueue(async()=>{const e=await RL(n),t=await xL(n);return e.setNetworkEnabled(!1),async function(){const e=t;e.Gr.add(0),await gM(e),e.Jr.set("Offline")}()});var n}function vF(t,e){return n=hF(t=zL(t,uF)),r=e,n.asyncQueue.enqueue(async()=>function(e,t){const n=e;return n.persistence.runTransaction("Get named query","readonly",e=>n.Ye.getNamedQuery(e,t))}(await PL(n),r)).then(e=>e?new JL(t,null,e.query):null);var n,r}function yF(e){if(e._initialized||e._terminated)throw new xR(PR.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.")}class _F{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new xR(PR.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new tP(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class wF{constructor(e){this._byteString=e}static fromBase64String(e){try{return new wF(rP.fromBase64String(e))}catch(e){throw new xR(PR.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new wF(rP.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 bF{constructor(e){this._methodName=e}}class IF{constructor(e,t){if(!isFinite(e)||e<-90||90<e)throw new xR(PR.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||180<t)throw new xR(PR.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 $R(this._lat,e._lat)||$R(this._long,e._long)}}const TF=/^__.*__$/;class EF{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return null!==this.fieldMask?new Dx(e,this.data,this.fieldMask,t,this.fieldTransforms):new xx(e,this.data,t,this.fieldTransforms)}}class kF{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new Dx(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function SF(e){switch(e){case 0:case 2:case 1:return 1;case 3:case 4:return;default:throw NR()}}class CF{constructor(e,t,n,r,i,s){this.settings=e,this.databaseId=t,this.k=n,this.ignoreUndefinedProperties=r,void 0===i&&this.xc(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get $c(){return this.settings.$c}Oc(e){return new CF(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.k,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Mc(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.Oc({path:n,Fc:!1});return r.Lc(e),r}Bc(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.Oc({path:n,Fc:!1});return r.xc(),r}Uc(e){return this.Oc({path:void 0,Fc:!0})}qc(e){return HF(e,this.settings.methodName,this.settings.Kc||!1,this.path,this.settings.jc)}contains(t){return void 0!==this.fieldMask.find(e=>t.isPrefixOf(e))||void 0!==this.fieldTransforms.find(e=>t.isPrefixOf(e.field))}xc(){if(this.path)for(let e=0;e<this.path.length;e++)this.Lc(this.path.get(e))}Lc(e){if(0===e.length)throw this.qc("Document fields must not be empty");if(SF(this.$c)&&TF.test(e))throw this.qc('Document fields cannot begin and end with "__"')}}class AF{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.k=n||oM(e)}Qc(e,t,n,r=!1){return new CF({$c:e,methodName:t,jc:n,path:tP.emptyPath(),Fc:!1,Kc:r},this.databaseId,this.k,this.ignoreUndefinedProperties)}}function NF(e){var t=e._freezeSettings(),n=oM(e._databaseId);return new AF(e._databaseId,!!t.ignoreUndefinedProperties,n)}function RF(e,t,n,r,i,s={}){const o=e.Qc(s.merge||s.mergeFields?2:0,t,n,i);WF("Data must be an object, but it was:",o,r);var a=VF(r,o);let c,l;if(s.merge)c=new nP(o.fieldMask),l=o.fieldTransforms;else if(s.mergeFields){const e=[];for(const r of s.mergeFields){const i=$F(t,r,n);if(!o.contains(i))throw new xR(PR.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);GF(e,i)||e.push(i)}c=new nP(e),l=o.fieldTransforms.filter(e=>c.covers(e.field))}else c=null,l=o.fieldTransforms;return new EF(new CP(a),c,l)}class PF extends bF{_toFieldTransform(e){if(2!==e.$c)throw 1===e.$c?e.qc(`${this._methodName}() can only appear at the top level of your update data`):e.qc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof PF}}function xF(e,t,n){return new CF({$c:3,jc:t.settings.jc,methodName:e._methodName,Fc:n},t.databaseId,t.k,t.ignoreUndefinedProperties)}class DF extends bF{_toFieldTransform(e){return new Tx(e.path,new gx)}isEqual(e){return e instanceof DF}}class OF extends bF{constructor(e,t){super(e),this.Wc=t}_toFieldTransform(e){const t=xF(this,e,!0),n=this.Wc.map(e=>qF(e,t)),r=new mx(n);return new Tx(e.path,r)}isEqual(e){return this===e}}class MF extends bF{constructor(e,t){super(e),this.Wc=t}_toFieldTransform(e){const t=xF(this,e,!0),n=this.Wc.map(e=>qF(e,t)),r=new yx(n);return new Tx(e.path,r)}isEqual(e){return this===e}}class LF extends bF{constructor(e,t){super(e),this.Gc=t}_toFieldTransform(e){var t=new wx(e.k,dx(e.k,this.Gc));return new Tx(e.path,t)}isEqual(e){return this===e}}function FF(e,i,s,t){const o=e.Qc(1,i,s);WF("Data must be an object, but it was:",o,t);const a=[],c=CP.empty();YR(t,(e,t)=>{var n=zF(i,e,s);t=$d(t);var r=o.Bc(n);if(t instanceof PF)a.push(n);else{const e=qF(t,r);null!=e&&(a.push(n),c.set(n,e))}});var n=new nP(a);return new kF(c,n,o.fieldTransforms)}function UF(e,t,n,r,i,s){const o=e.Qc(1,t,n),a=[$F(t,r,n)],c=[i];if(s.length%2!=0)throw new xR(PR.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let p=0;p<s.length;p+=2)a.push($F(t,s[p])),c.push(s[p+1]);const l=[],u=CP.empty();for(let f=a.length-1;0<=f;--f)if(!GF(l,a[f])){const t=a[f];var h=$d(h=c[f]);const r=o.Bc(t);if(h instanceof PF)l.push(t);else{const e=qF(h,r);null!=e&&(l.push(t),u.set(t,e))}}var d=new nP(l);return new kF(u,d,o.fieldTransforms)}function jF(e,t,n,r=!1){return qF(n,e.Qc(r?4:3,t))}function qF(s,e){if(BF(s=$d(s)))return WF("Unsupported field value:",e,s),VF(s,e);if(s instanceof bF)return function(e,t){if(!SF(t.$c))throw t.qc(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.qc(`${e._methodName}() is not currently supported inside arrays`);var n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(s,e),null;if(void 0===s&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),s instanceof Array){if(e.settings.Fc&&4!==e.$c)throw e.qc("Nested arrays are not supported");return function(t){const n=[];let r=0;for(const i of s){let e=qF(i,t.Uc(r));null==e&&(e={nullValue:"NULL_VALUE"}),n.push(e),r++}return{arrayValue:{values:n}}}(e)}return function(e,t){if(null===(e=$d(s)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return dx(t.k,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){var n=HR.fromDate(e);return{timestampValue:hD(t.k,n)}}if(e instanceof HR){n=new HR(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:hD(t.k,n)}}if(e instanceof IF)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof wF)return{bytesValue:dD(t.k,e._byteString)};if(e instanceof YL){const r=t.databaseId,i=e.firestore._databaseId;if(!i.isEqual(r))throw t.qc(`Document reference is for database ${i.projectId}/${i.database} but should be for database ${r.projectId}/${r.database}`);return{referenceValue:fD(e.firestore._databaseId||t.databaseId,e._key.path)}}throw t.qc(`Unsupported field value: ${KL(e)}`)}(0,e)}function VF(e,r){const i={};return JR(e)?r.path&&0<r.path.length&&r.fieldMask.push(r.path):YR(e,(e,t)=>{var n=qF(t,r.Mc(e));null!=n&&(i[e]=n)}),{mapValue:{fields:i}}}function BF(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof HR||e instanceof IF||e instanceof wF||e instanceof YL||e instanceof bF)}function WF(e,t,n){if(!BF(n)||("object"!=typeof(i=n)||null===i||Object.getPrototypeOf(i)!==Object.prototype&&null!==Object.getPrototypeOf(i))){var r=KL(n);throw"an object"===r?t.qc(e+" a custom object"):t.qc(e+" "+r)}var i}function $F(e,t,n){if((t=$d(t))instanceof _F)return t._internalPath;if("string"==typeof t)return zF(e,t);throw HF("Field path arguments must be of type string or ",e,!1,void 0,n)}const KF=new RegExp("[~\\*/\\[\\]]");function zF(t,n,r){if(0<=n.search(KF))throw HF(`Invalid field path (${n}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,r);try{return new _F(...n.split("."))._internalPath}catch(e){throw HF(`Invalid field path (${n}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,r)}}function HF(e,t,n,r,i){var s=r&&!r.isEmpty(),o=void 0!==i;let a=`Function ${t}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let c="";return(s||o)&&(c+=" (found",s&&(c+=` in field ${r}`),o&&(c+=` in document ${i}`),c+=")"),new xR(PR.INVALID_ARGUMENT,a+e+c)}function GF(e,t){return e.some(e=>e.isEqual(t))}class QF{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 YL(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){var e=new YF(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){var t=this._document.data.field(JF("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class YF extends QF{data(){return super.data()}}function JF(e,t){return"string"==typeof t?zF(e,t):(t instanceof _F?t:t._delegate)._internalPath}class XF{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class ZF extends QF{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){var t=new eU(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){var n=this._document.data.field(JF("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}}class eU extends ZF{data(e={}){return super.data(e)}}class tU{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new XF(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){const t=[];return this.forEach(e=>t.push(e)),t}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(t,n){this._snapshot.docs.forEach(e=>{t.call(n,new eU(this._firestore,this._userDataWriter,e.key,e,new XF(this._snapshot.mutatedKeys.has(e.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){var t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new xR(PR.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(s,t){if(s._snapshot.oldDocs.isEmpty()){let t=0;return s._snapshot.docChanges.map(e=>({type:"added",doc:new eU(s._firestore,s._userDataWriter,e.doc.key,e.doc,new XF(s._snapshot.mutatedKeys.has(e.doc.key),s._snapshot.fromCache),s.query.converter),oldIndex:-1,newIndex:t++}))}{let i=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(e=>t||3!==e.type).map(e=>{var t=new eU(s._firestore,s._userDataWriter,e.doc.key,e.doc,new XF(s._snapshot.mutatedKeys.has(e.doc.key),s._snapshot.fromCache),s.query.converter);let n=-1,r=-1;return 0!==e.type&&(n=i.indexOf(e.doc.key),i=i.delete(e.doc.key)),1!==e.type&&(i=i.add(e.doc),r=i.indexOf(e.doc.key)),{type:function(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return NR()}}(e.type),doc:t,oldIndex:n,newIndex:r}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function nU(e,t){return e instanceof ZF&&t instanceof ZF?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 tU&&t instanceof tU&&e._firestore===t._firestore&&nF(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)}function rU(e){if(XP(e)&&0===e.explicitOrderBy.length)throw new xR(PR.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class iU{}function sU(e,...t){for(const n of t)e=n._apply(e);return e}class oU extends iU{constructor(e,t,n){super(),this.zc=e,this.Hc=t,this.Jc=n,this.type="where"}_apply(e){var t=NF(e.firestore),t=function(e,t,n,r,i,s,o){let a;if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new xR(PR.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){pU(o,s);const t=[];for(const n of o)t.push(dU(r,e,n));a={arrayValue:{values:t}}}else a=dU(r,e,o)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||pU(o,s),a=jF(n,t,o,"in"===s||"not-in"===s);var c=OP.create(i,s,a);return function(e,t){if(t.V()){const r=ex(e);if(null!==r&&!r.isEqual(t.field))throw new xR(PR.INVALID_ARGUMENT,`Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${r.toString()}' and '${t.field.toString()}'`);var n=ZP(e);null!==n&&fU(0,t.field,n)}const r=function(e,t){for(const n of e.filters)if(0<=t.indexOf(n.op))return n.op;return null}(e,function(){switch(t.op){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}());if(null!==r)throw r===t.op?new xR(PR.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new xR(PR.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${r.toString()}' filters.`)}(e,c),c}(e._query,"where",t,e.firestore._databaseId,this.zc,this.Hc,this.Jc);return new JL(e.firestore,e.converter,(e=e._query,t=e.filters.concat([t]),new GP(e.path,e.collectionGroup,e.explicitOrderBy.slice(),t,e.limit,e.limitType,e.startAt,e.endAt)))}}class aU extends iU{constructor(e,t){super(),this.zc=e,this.Yc=t,this.type="orderBy"}_apply(e){var t=function(e,t,n){if(null!==e.startAt)throw new xR(PR.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new xR(PR.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var r,i=new KP(t,n);return n=i,null!==ZP(e=e)||null!==(r=ex(e))&&fU(0,r,n.field),i}(e._query,this.zc,this.Yc);return new JL(e.firestore,e.converter,(e=e._query,t=e.explicitOrderBy.concat([t]),new GP(e.path,e.collectionGroup,t,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)))}}class cU extends iU{constructor(e,t,n){super(),this.type=e,this.Xc=t,this.Zc=n}_apply(e){return new JL(e.firestore,e.converter,ix(e._query,this.Xc,this.Zc))}}class lU extends iU{constructor(e,t,n){super(),this.type=e,this.ta=t,this.ea=n}_apply(e){var t,n=hU(e,this.type,this.ta,this.ea);return new JL(e.firestore,e.converter,(t=e._query,e=n,new GP(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)))}}class uU extends iU{constructor(e,t,n){super(),this.type=e,this.ta=t,this.ea=n}_apply(e){var t,n=hU(e,this.type,this.ta,this.ea);return new JL(e.firestore,e.converter,(t=e._query,e=n,new GP(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)))}}function hU(e,t,n,r){if(n[0]=$d(n[0]),n[0]instanceof QF)return function(e,t,n,r,i){if(!r)throw new xR(PR.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);const s=[];for(const n of nx(e))if(n.field.isKeyField())s.push(wP(t,r.key));else{const e=r.data.field(n.field);if(cP(e))throw new xR(PR.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){const e=n.field.canonicalString();throw new xR(PR.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 WP(s,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);var i=NF(e.firestore);return function(e,t,n,r,i,s){const o=e.explicitOrderBy;if(i.length>o.length)throw new xR(PR.INVALID_ARGUMENT,`Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const a=[];for(let c=0;c<i.length;c++){const l=i[c];if(o[c].field.isKeyField()){if("string"!=typeof l)throw new xR(PR.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof l}`);if(!tx(e)&&-1!==l.indexOf("/"))throw new xR(PR.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.`);const n=e.path.child(ZR.fromString(l));if(!pP.isDocumentKey(n))throw new xR(PR.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.`);const i=new pP(n);a.push(wP(t,i))}else{const e=jF(n,r,l);a.push(e)}}return new WP(a,s)}(e._query,e.firestore._databaseId,i,t,n,r)}function dU(e,t,n){if("string"==typeof(n=$d(n))){if(""===n)throw new xR(PR.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!tx(t)&&-1!==n.indexOf("/"))throw new xR(PR.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);var r=t.path.child(ZR.fromString(n));if(!pP.isDocumentKey(r))throw new xR(PR.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 wP(e,new pP(r))}if(n instanceof YL)return wP(e,n._key);throw new xR(PR.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${KL(n)}.`)}function pU(e,t){if(!Array.isArray(e)||0===e.length)throw new xR(PR.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`);if(10<e.length)throw new xR(PR.INVALID_ARGUMENT,`Invalid Query. '${t.toString()}' filters support a maximum of 10 elements in the value array.`)}function fU(e,t,n){if(!n.isEqual(t))throw new xR(PR.INVALID_ARGUMENT,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${t.toString()}' and so you must also use '${t.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}class gU{convertValue(e,t="none"){switch(fP(e)){case 0:return null;case 1:return e.booleanValue;case 2:return oP(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(aP(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 10:return this.convertObject(e.mapValue,t);default:throw NR()}}convertObject(e,n){const r={};return YR(e.fields,(e,t)=>{r[e]=this.convertValue(t,n)}),r}convertGeoPoint(e){return new IF(oP(e.latitude),oP(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":var n=function e(t){var n=t.mapValue.fields.__previous_value__;return cP(n)?e(n):n}(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(lP(e));default:return null}}convertTimestamp(e){var t=sP(e);return new HR(t.seconds,t.nanos)}convertDocumentKey(e,t){const n=ZR.fromString(e);RR(MD(n));const r=new jL(n.get(1),n.get(3)),i=new pP(n.popFirst(5));return r.isEqual(t)||SR(`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 mU(e,t,n){return e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t}class vU extends gU{constructor(e){super(),this.firestore=e}convertBytes(e){return new wF(e)}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return new YL(this.firestore,null,t)}}class yU{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=NF(e)}set(e,t,n){this._verifyNotCommitted();const r=_U(e,this._firestore),i=mU(r.converter,t,n),s=RF(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(s.toMutation(r._key,kx.none())),this}update(e,t,n,...r){this._verifyNotCommitted();var i=_U(e,this._firestore);let s;return s="string"==typeof(t=$d(t))||t instanceof _F?UF(this._dataReader,"WriteBatch.update",i._key,t,n,r):FF(this._dataReader,"WriteBatch.update",i._key,t),this._mutations.push(s.toMutation(i._key,kx.exists(!0))),this}delete(e){this._verifyNotCommitted();var t=_U(e,this._firestore);return this._mutations=this._mutations.concat(new Fx(t._key,kx.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,0<this._mutations.length?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new xR(PR.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function _U(e,t){if((e=$d(e)).firestore!==t)throw new xR(PR.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}class wU extends gU{constructor(e){super(),this.firestore=e}convertBytes(e){return new wF(e)}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return new YL(this.firestore,null,t)}}function bU(t){t=zL(t,YL);const n=zL(t.firestore,uF),e=hF(n),r=new wU(n);return function(e,t){const n=new DR;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t,n){try{const i=await function(t){const n=e;return n.persistence.runTransaction("read document","readonly",e=>n.Wn.Rn(e,t))}(t);i.isFoundDocument()?n.resolve(i):i.isNoDocument()?n.resolve(null):n.reject(new xR(PR.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(e){var r=DM(e,`Failed to get document '${t} from cache`);n.reject(r)}}(await PL(e),t,n)),n.promise}(e,t._key).then(e=>new ZF(n,r,t._key,e,new XF(null!==e&&e.hasLocalMutations,!0),t.converter))}function IU(t){t=zL(t,JL);const n=zL(t.firestore,uF),e=hF(n),r=new wU(n);return function(e,t){const n=new DR;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t,n){try{const i=await R1(e,t,!0),s=new QM(t,i.zn),o=s.Po(i.documents),a=s.applyChanges(o,!1);n.resolve(a.snapshot)}catch(e){var r=DM(e,`Failed to execute query '${t} against cache`);n.reject(r)}}(await PL(e),t,n)),n.promise}(e,t._query).then(e=>new tU(n,r,t,e))}function TU(e,t,n){e=zL(e,YL);var r=zL(e.firestore,uF),i=mU(e.converter,t,n);return CU(r,[RF(NF(r),"setDoc",e._key,i,null!==e.converter,n).toMutation(e._key,kx.none())])}function EU(e,t,n,...r){e=zL(e,YL);var i=zL(e.firestore,uF),s=NF(i);let o;return o="string"==typeof(t=$d(t))||t instanceof _F?UF(s,"updateDoc",e._key,t,n,r):FF(s,"updateDoc",e._key,t),CU(i,[o.toMutation(e._key,kx.exists(!0))])}function kU(t,...n){var e;t=$d(t);let r={includeMetadataChanges:!1},i=0;"object"!=typeof n[i]||iF(n[i])||(r=n[i],i++);var s={includeMetadataChanges:r.includeMetadataChanges};if(iF(n[i])){const t=n[i];n[i]=null===(e=t.next)||void 0===e?void 0:e.bind(t),n[i+1]=null===(e=t.error)||void 0===e?void 0:e.bind(t),n[i+2]=null===(e=t.complete)||void 0===e?void 0:e.bind(t)}let o,a,c;if(t instanceof YL)a=zL(t.firestore,uF),c=YP(t._key.path),o={next:e=>{n[i]&&n[i](AU(a,t,e))},error:n[i+1],complete:n[i+2]};else{const l=zL(t,JL);a=zL(l.firestore,uF),c=l._query;const u=new wU(a);o={next:e=>{n[i]&&n[i](new tU(a,u,l,e))},error:n[i+1],complete:n[i+2]},rU(t._query)}return function(e,t,n,r){const i=new bL(r),s=new BM(t,i,n);return e.asyncQueue.enqueueAndForget(async()=>jM(await OL(e),s)),()=>{i.nc(),e.asyncQueue.enqueueAndForget(async()=>qM(await OL(e),s))}}(hF(a),c,s,o)}function SU(e,t){return function(e,t){const n=new bL(t);return e.asyncQueue.enqueueAndForget(async()=>function(e,t){e.io.add(t),t.next()}(await OL(e),n)),()=>{n.nc(),e.asyncQueue.enqueueAndForget(async()=>function(e,t){e.io.delete(t)}(await OL(e),n))}}(hF(e=zL(e,uF)),iF(t)?t:{next:t})}function CU(e,t){return function(e,t){const n=new DR;return e.asyncQueue.enqueueAndForget(async()=>eL(await DL(e),t,n)),n.promise}(hF(e),t)}function AU(e,t,n){var r=n.docs.get(t._key),i=new wU(e);return new ZF(e,i,t._key,r,new XF(n.hasPendingWrites,n.fromCache),t.converter)}class NU extends class{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=NF(e)}get(e){const n=_U(e,this._firestore),r=new vU(this._firestore);return this._transaction.lookup([n._key]).then(e=>{if(!e||1!==e.length)return NR();const t=e[0];if(t.isFoundDocument())return new QF(this._firestore,r,t.key,t,n.converter);if(t.isNoDocument())return new QF(this._firestore,r,n._key,null,n.converter);throw NR()})}set(e,t,n){var r=_U(e,this._firestore),i=mU(r.converter,t,n),i=RF(this._dataReader,"Transaction.set",r._key,i,null!==r.converter,n);return this._transaction.set(r._key,i),this}update(e,t,n,...r){var i=_U(e,this._firestore),s="string"==typeof(t=$d(t))||t instanceof _F?UF(this._dataReader,"Transaction.update",i._key,t,n,r):FF(this._dataReader,"Transaction.update",i._key,t);return this._transaction.update(i._key,s),this}delete(e){var t=_U(e,this._firestore);return this._transaction.delete(t._key),this}}{constructor(e,t){super(e,t),this._firestore=e}get(e){const t=_U(e,this._firestore),n=new wU(this._firestore);return super.get(e).then(e=>new ZF(this._firestore,n,t._key,e._document,new XF(!1,!1),t.converter))}}function RU(t,n){return function(t,n){const r=new DR;return t.asyncQueue.enqueueAndForget(async()=>{var e=await NL(t).then(e=>e.datastore);new EL(t.asyncQueue,e,n,r).run()}),r.promise}(hF(t=zL(t,uF)),e=>n(new NU(t,e)))}z=gp,IR=z,hp(new Kd("firestore",(e,{options:t})=>{const n=e.getProvider("app").getImmediate(),r=new uF(n,new FR(e.getProvider("auth-internal")),new VR(e.getProvider("app-check-internal")));return t=Object.assign({useFetchStreams:!0},t),r._setSettings(t),r},"PUBLIC")),_p(wR,"3.4.3",void 0),_p(wR,"3.4.3","esm2017");function PU(e,t){if(void 0===t)return{merge:!1};if(void 0!==t.mergeFields&&void 0!==t.merge)throw new xR("invalid-argument",`Invalid options passed to function ${e}(): You cannot `+'specify both "merge" and "mergeFields".');return t}function xU(){if("undefined"==typeof Uint8Array)throw new xR("unimplemented","Uint8Arrays are not available in this environment.")}function DU(){if("undefined"==typeof atob)throw new xR("unimplemented","Blobs are unavailable in Firestore in this environment.")}class OU{constructor(e){this._delegate=e}static fromBase64String(e){return DU(),new OU(wF.fromBase64String(e))}static fromUint8Array(e){return xU(),new OU(wF.fromUint8Array(e))}toBase64(){return DU(),this._delegate.toBase64()}toUint8Array(){return xU(),this._delegate.toUint8Array()}isEqual(e){return this._delegate.isEqual(e._delegate)}toString(){return"Blob(base64: "+this.toBase64()+")"}}function MU(e){return function(e,t){if("object"!=typeof e||null===e)return;var n=e;for(const r of t)if(r in n&&"function"==typeof n[r])return 1;return}(e,["next","error","complete"])}class LU{enableIndexedDbPersistence(e,t){return function(e,t){yF(e=zL(e,uF));var n=hF(e),r=e._freezeSettings(),i=new _L;return pF(n,i,new vL(i,r.cacheSizeBytes,null==t?void 0:t.forceOwnership))}(e._delegate,{forceOwnership:t})}enableMultiTabIndexedDbPersistence(e){return function(e){yF(e=zL(e,uF));var t=hF(e),n=e._freezeSettings(),r=new _L;return pF(t,r,new yL(r,n.cacheSizeBytes))}(e._delegate)}clearIndexedDbPersistence(e){return function(e){if(e._initialized&&!e._terminated)throw new xR(PR.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const t=new DR;return e._queue.enqueueAndForgetEvenWhileRestricted(async()=>{try{await async function(e){if(!oO.Pt())return Promise.resolve();var t=e+"main";await oO.delete(t)}(v1(e._databaseId,e._persistenceKey)),t.resolve()}catch(e){t.reject(e)}}),t.promise}(e._delegate)}}class FU{constructor(e,t,n){this._delegate=t,this._persistenceProvider=n,this.INTERNAL={delete:()=>this.terminate()},e instanceof jL||(this._appCompat=e)}get _databaseId(){return this._delegate._databaseId}settings(e){var t=this._delegate._getSettings();e.merge||t.host===e.host||CR("You are overriding the original host. If you did not intend to override your settings, use {merge: true}."),e.merge&&delete(e=Object.assign(Object.assign({},t),e)).merge,this._delegate._setSettings(e)}useEmulator(e,t,n={}){!function(n,e,t,r={}){var i;const s=(n=zL(n,QL))._getSettings();if("firestore.googleapis.com"!==s.host&&s.host!==e&&CR("Host has been set in both settings() and useEmulator(), emulator host will be used"),n._setSettings(Object.assign(Object.assign({},s),{host:`${e}:${t}`,ssl:!1})),r.mockUserToken){let e,t;if("string"==typeof r.mockUserToken)e=r.mockUserToken,t=bR.MOCK_USER;else{e=id(r.mockUserToken,null===(i=n._app)||void 0===i?void 0:i.options.projectId);const s=r.mockUserToken.sub||r.mockUserToken.user_id;if(!s)throw new xR(PR.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");t=new bR(s)}n._authCredentials=new LR(new OR(e,t))}}(this._delegate,e,t,n)}enableNetwork(){return gF(this._delegate)}disableNetwork(){return mF(this._delegate)}enablePersistence(e){let t=!1,n=!1;return e&&(t=!!e.synchronizeTabs,n=!!e.experimentalForceOwningTab,BL("synchronizeTabs",t,"experimentalForceOwningTab",n)),t?this._persistenceProvider.enableMultiTabIndexedDbPersistence(this):this._persistenceProvider.enableIndexedDbPersistence(this,n)}clearPersistence(){return this._persistenceProvider.clearIndexedDbPersistence(this)}terminate(){return this._appCompat&&(this._appCompat._removeServiceInstance("firestore-compat"),this._appCompat._removeServiceInstance("firestore")),this._delegate._delete()}waitForPendingWrites(){return fF(this._delegate)}onSnapshotsInSync(e){return SU(this._delegate,e)}get app(){if(!this._appCompat)throw new xR("failed-precondition","Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._appCompat}collection(e){try{return new JU(this,ZL(this._delegate,e))}catch(e){throw WU(e,"collection()","Firestore.collection()")}}doc(e){try{return new BU(this,eF(this._delegate,e))}catch(e){throw WU(e,"doc()","Firestore.doc()")}}collectionGroup(e){try{return new GU(this,function(e,t){if(e=zL(e,QL),VL("collectionGroup","collection id",t),0<=t.indexOf("/"))throw new xR(PR.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new JL(e,null,(t=t,new GP(ZR.emptyPath(),t)))}(this._delegate,e))}catch(e){throw WU(e,"collectionGroup()","Firestore.collectionGroup()")}}runTransaction(t){return RU(this._delegate,e=>t(new jU(this,e)))}batch(){return hF(this._delegate),new qU(new yU(this._delegate,e=>CU(this._delegate,e)))}loadBundle(e){return t=this._delegate,e=e,n=hF(t=zL(t,uF)),r=new sF,FL(n,t._databaseId,e,r),r;var t,n,r}namedQuery(e){return vF(this._delegate,e).then(e=>e?new GU(this,e):null)}}class UU extends gU{constructor(e){super(),this.firestore=e}convertBytes(e){return new OU(new wF(e))}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return BU.forKey(t,this.firestore,null)}}class jU{constructor(e,t){this._firestore=e,this._delegate=t,this._userDataWriter=new UU(e)}get(e){const t=XU(e);return this._delegate.get(t).then(e=>new zU(this._firestore,new ZF(this._firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,t.converter)))}set(e,t,n){var r=XU(e);return n?(PU("Transaction.set",n),this._delegate.set(r,t,n)):this._delegate.set(r,t),this}update(e,t,n,...r){var i=XU(e);return 2===arguments.length?this._delegate.update(i,t):this._delegate.update(i,t,n,...r),this}delete(e){var t=XU(e);return this._delegate.delete(t),this}}class qU{constructor(e){this._delegate=e}set(e,t,n){var r=XU(e);return n?(PU("WriteBatch.set",n),this._delegate.set(r,t,n)):this._delegate.set(r,t),this}update(e,t,n,...r){var i=XU(e);return 2===arguments.length?this._delegate.update(i,t):this._delegate.update(i,t,n,...r),this}delete(e){var t=XU(e);return this._delegate.delete(t),this}commit(){return this._delegate.commit()}}class VU{constructor(e,t,n){this._firestore=e,this._userDataWriter=t,this._delegate=n}fromFirestore(e,t){var n=new eU(this._firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,null);return this._delegate.fromFirestore(new HU(this._firestore,n),null!=t?t:{})}toFirestore(e,t){return t?this._delegate.toFirestore(e,t):this._delegate.toFirestore(e)}static getInstance(e,t){const n=VU.INSTANCES;let r=n.get(e);r||(r=new WeakMap,n.set(e,r));let i=r.get(t);return i||(i=new VU(e,new UU(e),t),r.set(t,i)),i}}VU.INSTANCES=new WeakMap;class BU{constructor(e,t){this.firestore=e,this._delegate=t,this._userDataWriter=new UU(e)}static forPath(e,t,n){if(e.length%2!=0)throw new xR("invalid-argument","Invalid document reference. Document references must have an even number of segments, but "+`${e.canonicalString()} has ${e.length}`);return new BU(t,new YL(t._delegate,n,new pP(e)))}static forKey(e,t,n){return new BU(t,new YL(t._delegate,n,e))}get id(){return this._delegate.id}get parent(){return new JU(this.firestore,this._delegate.parent)}get path(){return this._delegate.path}collection(e){try{return new JU(this.firestore,ZL(this._delegate,e))}catch(e){throw WU(e,"collection()","DocumentReference.collection()")}}isEqual(e){return(e=$d(e))instanceof YL&&tF(this._delegate,e)}set(e,t){t=PU("DocumentReference.set",t);try{return t?TU(this._delegate,e,t):TU(this._delegate,e)}catch(e){throw WU(e,"setDoc()","DocumentReference.set()")}}update(e,t,...n){try{return 1===arguments.length?EU(this._delegate,e):EU(this._delegate,e,t,...n)}catch(e){throw WU(e,"updateDoc()","DocumentReference.update()")}}delete(){return CU(zL((e=this._delegate).firestore,uF),[new Fx(e._key,kx.none())]);var e}onSnapshot(...e){var t=$U(e),n=KU(e,e=>new zU(this.firestore,new ZF(this.firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,this._delegate.converter)));return kU(this._delegate,t,n)}get(e){let t;return t=("cache"===(null==e?void 0:e.source)?bU:"server"===(null==e?void 0:e.source)?function(t){t=zL(t,YL);const n=zL(t.firestore,uF);return ML(hF(n),t._key,{source:"server"}).then(e=>AU(n,t,e))}:function(t){t=zL(t,YL);const n=zL(t.firestore,uF);return ML(hF(n),t._key).then(e=>AU(n,t,e))})(this._delegate),t.then(e=>new zU(this.firestore,new ZF(this.firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,this._delegate.converter)))}withConverter(e){return new BU(this.firestore,e?this._delegate.withConverter(VU.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}function WU(e,t,n){return e.message=e.message.replace(t,n),e}function $U(e){for(const t of e)if("object"==typeof t&&!MU(t))return t;return{}}function KU(e,t){var n;let r;return r=MU(e[0])?e[0]:MU(e[1])?e[1]:"function"==typeof e[0]?{next:e[0],error:e[1],complete:e[2]}:{next:e[1],error:e[2],complete:e[3]},{next:e=>{r.next&&r.next(t(e))},error:null===(n=r.error)||void 0===n?void 0:n.bind(r),complete:null===(n=r.complete)||void 0===n?void 0:n.bind(r)}}class zU{constructor(e,t){this._firestore=e,this._delegate=t}get ref(){return new BU(this._firestore,this._delegate.ref)}get id(){return this._delegate.id}get metadata(){return this._delegate.metadata}get exists(){return this._delegate.exists()}data(e){return this._delegate.data(e)}get(e,t){return this._delegate.get(e,t)}isEqual(e){return nU(this._delegate,e._delegate)}}class HU extends zU{data(e){var t=this._delegate.data(e);return void 0!==t||NR(),t}}class GU{constructor(e,t){this.firestore=e,this._delegate=t,this._userDataWriter=new UU(e)}where(e,t,n){try{return new GU(this.firestore,sU(this._delegate,(r=n,i=t,s=JF("where",e),new oU(s,i,r))))}catch(e){throw WU(e,/(orderBy|where)\(\)/,"Query.$1()")}var r,i,s}orderBy(e,t){try{return new GU(this.firestore,sU(this._delegate,([n,r="asc"]=[e,t],i=r,s=JF("orderBy",n),new aU(s,i))))}catch(e){throw WU(e,/(orderBy|where)\(\)/,"Query.$1()")}var n,r,i,s}limit(e){try{return new GU(this.firestore,sU(this._delegate,(HL("limit",t=e),new cU("limit",t,"F"))))}catch(e){throw WU(e,"limit()","Query.limit()")}var t}limitToLast(e){try{return new GU(this.firestore,sU(this._delegate,(HL("limitToLast",t=e),new cU("limitToLast",t,"L"))))}catch(e){throw WU(e,"limitToLast()","Query.limitToLast()")}var t}startAt(...e){try{return new GU(this.firestore,sU(this._delegate,function(...e){return new lU("startAt",e,!0)}(...e)))}catch(e){throw WU(e,"startAt()","Query.startAt()")}}startAfter(...e){try{return new GU(this.firestore,sU(this._delegate,function(...e){return new lU("startAfter",e,!1)}(...e)))}catch(e){throw WU(e,"startAfter()","Query.startAfter()")}}endBefore(...e){try{return new GU(this.firestore,sU(this._delegate,function(...e){return new uU("endBefore",e,!0)}(...e)))}catch(e){throw WU(e,"endBefore()","Query.endBefore()")}}endAt(...e){try{return new GU(this.firestore,sU(this._delegate,function(...e){return new uU("endAt",e,!1)}(...e)))}catch(e){throw WU(e,"endAt()","Query.endAt()")}}isEqual(e){return nF(this._delegate,e._delegate)}get(e){let t;return t=("cache"===(null==e?void 0:e.source)?IU:"server"===(null==e?void 0:e.source)?function(t){t=zL(t,JL);const n=zL(t.firestore,uF),e=hF(n),r=new wU(n);return LL(e,t._query,{source:"server"}).then(e=>new tU(n,r,t,e))}:function(t){t=zL(t,JL);const n=zL(t.firestore,uF),e=hF(n),r=new wU(n);return rU(t._query),LL(e,t._query).then(e=>new tU(n,r,t,e))})(this._delegate),t.then(e=>new YU(this.firestore,new tU(this.firestore._delegate,this._userDataWriter,this._delegate,e._snapshot)))}onSnapshot(...e){var t=$U(e),n=KU(e,e=>new YU(this.firestore,new tU(this.firestore._delegate,this._userDataWriter,this._delegate,e._snapshot)));return kU(this._delegate,t,n)}withConverter(e){return new GU(this.firestore,e?this._delegate.withConverter(VU.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}class QU{constructor(e,t){this._firestore=e,this._delegate=t}get type(){return this._delegate.type}get doc(){return new HU(this._firestore,this._delegate.doc)}get oldIndex(){return this._delegate.oldIndex}get newIndex(){return this._delegate.newIndex}}class YU{constructor(e,t){this._firestore=e,this._delegate=t}get query(){return new GU(this._firestore,this._delegate.query)}get metadata(){return this._delegate.metadata}get size(){return this._delegate.size}get empty(){return this._delegate.empty}get docs(){return this._delegate.docs.map(e=>new HU(this._firestore,e))}docChanges(e){return this._delegate.docChanges(e).map(e=>new QU(this._firestore,e))}forEach(t,n){this._delegate.forEach(e=>{t.call(n,new HU(this._firestore,e))})}isEqual(e){return nU(this._delegate,e._delegate)}}class JU extends GU{constructor(e,t){super(e,t),this.firestore=e,this._delegate=t}get id(){return this._delegate.id}get path(){return this._delegate.path}get parent(){var e=this._delegate.parent;return e?new BU(this.firestore,e):null}doc(e){try{return void 0===e?new BU(this.firestore,eF(this._delegate)):new BU(this.firestore,eF(this._delegate,e))}catch(e){throw WU(e,"doc()","CollectionReference.doc()")}}add(e){return function(e,t){const n=zL(e.firestore,uF),r=eF(e),i=mU(e.converter,t);return CU(n,[RF(NF(e.firestore),"addDoc",r._key,i,null!==e.converter,{}).toMutation(r._key,kx.exists(!1))]).then(()=>r)}(this._delegate,e).then(e=>new BU(this.firestore,e))}isEqual(e){return tF(this._delegate,e._delegate)}withConverter(e){return new JU(this.firestore,e?this._delegate.withConverter(VU.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}function XU(e){return zL(e,YL)}const ZU={Firestore:FU,GeoPoint:IF,Timestamp:HR,Blob:OU,Transaction:jU,WriteBatch:qU,DocumentReference:BU,DocumentSnapshot:zU,Query:GU,QueryDocumentSnapshot:HU,QuerySnapshot:YU,CollectionReference:JU,FieldPath:class JW{constructor(...e){this._delegate=new _F(...e)}static documentId(){return new JW(tP.keyField().canonicalString())}isEqual(e){return(e=$d(e))instanceof _F&&this._delegate._internalPath.isEqual(e._internalPath)}},FieldValue:class XW{constructor(e){this._delegate=e}static serverTimestamp(){const e=new DF("serverTimestamp");return e._methodName="FieldValue.serverTimestamp",new XW(e)}static delete(){const e=new PF("deleteField");return e._methodName="FieldValue.delete",new XW(e)}static arrayUnion(...e){const t=function(...e){return new OF("arrayUnion",e)}(...e);return t._methodName="FieldValue.arrayUnion",new XW(t)}static arrayRemove(...e){const t=function(...e){return new MF("arrayRemove",e)}(...e);return t._methodName="FieldValue.arrayRemove",new XW(t)}static increment(e){const t=new LF("increment",e);return t._methodName="FieldValue.increment",new XW(t)}isEqual(e){return this._delegate.isEqual(e._delegate)}},setLogLevel:function(e){e=e,TR.setLogLevel(e)},CACHE_SIZE_UNLIMITED:-1};oF=Cp,aF=(e,t)=>new FU(e,t,new LU),oF.INTERNAL.registerComponent(new Kd("firestore-compat",e=>{var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("firestore").getImmediate();return aF(t,n)},"PUBLIC").setServiceProps(Object.assign({},ZU))),oF.registerVersion("@firebase/firestore-compat","0.1.12");function ej(e,t){const n={};for(const r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r]));return n}function tj(e){if(null==e)return e;if(e["@type"])switch(e["@type"]){case"type.googleapis.com/google.protobuf.Int64Value":case"type.googleapis.com/google.protobuf.UInt64Value":var t=Number(e.value);if(isNaN(t))throw new Error("Data cannot be decoded from JSON: "+e);return t;default:throw new Error("Data cannot be decoded from JSON: "+e)}return Array.isArray(e)?e.map(e=>tj(e)):"function"==typeof e||"object"==typeof e?ej(e,e=>tj(e)):e}const nj="functions",rj={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class ij extends gd{constructor(e,t,n){super(`${nj}/${e}`,t||""),this.details=n}}function sj(e,t){let n=function(e){if(200<=e&&e<300)return"ok";switch(e){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}(e),r=n,i=void 0;try{var s=t&&t.error;if(s){const e=s.status;if("string"==typeof e){if(!rj[e])return new ij("internal","internal");n=rj[e],r=e}var o=s.message;"string"==typeof o&&(r=o),i=s.details,void 0!==i&&(i=tj(i))}}catch(e){}return"ok"===n?null:new ij(n,r,i)}class oj{constructor(e,t,n){this.auth=null,this.messaging=null,this.appCheck=null,this.auth=e.getImmediate({optional:!0}),this.messaging=t.getImmediate({optional:!0}),this.auth||e.get().then(e=>this.auth=e,()=>{}),this.messaging||t.get().then(e=>this.messaging=e,()=>{}),this.appCheck||n.get().then(e=>this.appCheck=e,()=>{})}async getAuthToken(){if(this.auth)try{var e=await this.auth.getToken();return null==e?void 0:e.accessToken}catch(e){return}}async getMessagingToken(){if(this.messaging&&"Notification"in self&&"granted"===Notification.permission)try{return this.messaging.getToken()}catch(e){return}}async getAppCheckToken(){if(this.appCheck){var e=await this.appCheck.getToken();return e.error?null:e.token}return null}async getContext(){return{authToken:await this.getAuthToken(),messagingToken:await this.getMessagingToken(),appCheckToken:await this.getAppCheckToken()}}}const aj="us-central1";class cj{constructor(e,t,n,r,i=aj,s){this.app=e,this.fetchImpl=s,this.emulatorOrigin=null,this.contextProvider=new oj(t,n,r),this.cancelAllRequests=new Promise(e=>{this.deleteService=()=>Promise.resolve(e())});try{var o=new URL(i);this.customDomain=o.origin,this.region=aj}catch(e){this.customDomain=null,this.region=i}}_delete(){return this.deleteService()}_url(e){var t=this.app.options.projectId;return null===this.emulatorOrigin?null!==this.customDomain?`${this.customDomain}/${e}`:`https://${this.region}-${t}.cloudfunctions.net/${e}`:`${this.emulatorOrigin}/${t}/${this.region}/${e}`}}function lj(t,n,r){return e=>async function(e,t,n,r){const i=e._url(t),s={data:n=function t(e){if(null==e)return null;if("number"==typeof(e=e instanceof Number?e.valueOf():e)&&isFinite(e))return e;if(!0===e||!1===e)return e;if("[object String]"===Object.prototype.toString.call(e))return e;if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(e=>t(e));if("function"==typeof e||"object"==typeof e)return ej(e,e=>t(e));throw new Error("Data cannot be encoded in JSON: "+e)}(n)},o={},a=await e.contextProvider.getContext();a.authToken&&(o.Authorization="Bearer "+a.authToken);a.messagingToken&&(o["Firebase-Instance-ID-Token"]=a.messagingToken);null!==a.appCheckToken&&(o["X-Firebase-AppCheck"]=a.appCheckToken);const c=r.timeout||7e4,l=function(n){let r=null;return{promise:new Promise((e,t)=>{r=setTimeout(()=>{t(new ij("deadline-exceeded","deadline-exceeded"))},n)}),cancel:()=>{r&&clearTimeout(r)}}}(c),u=await Promise.race([async function(e,t,n,r){n["Content-Type"]="application/json";let i;try{i=await r(e,{method:"POST",body:JSON.stringify(t),headers:n})}catch(e){return{status:0,json:null}}let s=null;try{s=await i.json()}catch(e){}return{status:i.status,json:s}}(i,s,o,e.fetchImpl),l.promise,e.cancelAllRequests]);if(l.cancel(),!u)throw new ij("cancelled","Firebase Functions instance was deleted.");var h=sj(u.status,u.json);if(h)throw h;if(!u.json)throw new ij("internal","Response is not valid JSON object.");let d=u.json.data;void 0===d&&(d=u.json.result);if(void 0===d)throw new ij("internal","Response is missing data field.");h=tj(d);return{data:h}}(t,n,e,r||{})}const uj="@firebase/functions";function hj(e,t,n){$d(e).emulatorOrigin=`http://${t}:${n}`}cF=fetch.bind(self),hp(new Kd(nj,(e,{instanceIdentifier:t})=>{var n=e.getProvider("app").getImmediate(),r=e.getProvider("auth-internal"),i=e.getProvider("messaging-internal"),s=e.getProvider("app-check-internal");return new cj(n,r,i,s,t,cF)},"PUBLIC").setMultipleInstances(!0)),_p(uj,"0.7.7",lF),_p(uj,"0.7.7","esm2017");var dj,pj,fj,gj;class mj{constructor(e,t){this.app=e,this._delegate=t,this._region=this._delegate.region,this._customDomain=this._delegate.customDomain}httpsCallable(e,t){return lj($d(this._delegate),e,t)}useFunctionsEmulator(e){var t=e.match("[a-zA-Z]+://([a-zA-Z0-9.-]+)(?::([0-9]+))?");if(null==t)throw new gd("functions","No origin provided to useFunctionsEmulator()");if(null==t[2])throw new gd("functions","Port missing in origin provided to useFunctionsEmulator()");return hj(this._delegate,t[1],Number(t[2]))}useEmulator(e,t){return hj(this._delegate,e,t)}}const vj="us-central1",yj=(e,{instanceIdentifier:t})=>{var n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("functions").getImmediate({identifier:null!=t?t:vj});return new mj(n,r)};dj={Functions:mj},Cp.INTERNAL.registerComponent(new Kd("functions-compat",yj,"PUBLIC").setServiceProps(dj).setMultipleInstances(!0)),Cp.registerVersion("@firebase/functions-compat","0.1.8");const _j="/firebase-messaging-sw.js",wj="/firebase-cloud-messaging-push-scope",bj="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",Ij="https://fcmregistrations.googleapis.com/v1",Tj="google.c.a.c_id",Ej="google.c.a.e";function kj(e){var t=new Uint8Array(e);const n=btoa(String.fromCharCode(...t));return n.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(yt=DB=DB||{})[yt.DATA_MESSAGE=1]="DATA_MESSAGE",yt[yt.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION",(yt=pj=pj||{}).PUSH_RECEIVED="push-received",yt.NOTIFICATION_CLICKED="notification-clicked";const Sj="fcm_token_details_db",Cj="fcm_token_object_Store";async function Aj(s){if("databases"in indexedDB){const t=await indexedDB.databases(),n=t.map(e=>e.name);if(!n.includes(Sj))return null}let o=null;const e=await qp(Sj,5,async e=>{var t;if(!(e.oldVersion<2)&&e.objectStoreNames.contains(Cj)){const i=e.transaction.objectStore(Cj);var n,r=await i.index("fcmSenderId").get(s);await i.clear(),r&&(2===e.oldVersion?(n=r).auth&&n.p256dh&&n.endpoint&&(o={token:n.fcmToken,createTime:null!==(t=n.createTime)&&void 0!==t?t:Date.now(),subscriptionOptions:{auth:n.auth,p256dh:n.p256dh,endpoint:n.endpoint,swScope:n.swScope,vapidKey:"string"==typeof n.vapidKey?n.vapidKey:kj(n.vapidKey)}}):3===e.oldVersion?(n=r,o={token:n.fcmToken,createTime:n.createTime,subscriptionOptions:{auth:kj(n.auth),p256dh:kj(n.p256dh),endpoint:n.endpoint,swScope:n.swScope,vapidKey:kj(n.vapidKey)}}):4===e.oldVersion&&(r=r,o={token:r.fcmToken,createTime:r.createTime,subscriptionOptions:{auth:kj(r.auth),p256dh:kj(r.p256dh),endpoint:r.endpoint,swScope:r.swScope,vapidKey:kj(r.vapidKey)}}))}});return e.close(),await Vp(Sj),await Vp("fcm_vapid_details_db"),await Vp("undefined"),function(e){if(!e||!e.subscriptionOptions)return!1;var t=e["subscriptionOptions"];return"number"==typeof e.createTime&&0<e.createTime&&"string"==typeof e.token&&0<e.token.length&&"string"==typeof t.auth&&0<t.auth.length&&"string"==typeof t.p256dh&&0<t.p256dh.length&&"string"==typeof t.endpoint&&0<t.endpoint.length&&"string"==typeof t.swScope&&0<t.swScope.length&&"string"==typeof t.vapidKey&&0<t.vapidKey.length}(o)?o:null}const Nj="firebase-messaging-database",Rj=1,Pj="firebase-messaging-store";let xj=null;function Dj(){return xj=xj||qp(Nj,Rj,e=>{0===e.oldVersion&&e.createObjectStore(Pj)}),xj}async function Oj(e){var t=Lj(e);const n=await Dj();t=await n.transaction(Pj).objectStore(Pj).get(t);if(t)return t;t=await Aj(e.appConfig.senderId);return t?(await Mj(e,t),t):void 0}async function Mj(e,t){var n=Lj(e);const r=await Dj(),i=r.transaction(Pj,"readwrite");return await i.objectStore(Pj).put(t,n),await i.complete,t}function Lj({appConfig:e}){return e.appId}const Fj=new md("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.","invalid-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 Uj(e,t){var n={method:"DELETE",headers:await qj(e)};try{const s=await fetch(`${jj(e.appConfig)}/${t}`,n);var r=await s.json();if(r.error){var i=r.error.message;throw Fj.create("token-unsubscribe-failed",{errorInfo:i})}}catch(e){throw Fj.create("token-unsubscribe-failed",{errorInfo:e})}}function jj({projectId:e}){return`${Ij}/projects/${e}/registrations`}async function qj({appConfig:e,installations:t}){var 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 Vj({p256dh:e,auth:t,endpoint:n,vapidKey:r}){const i={web:{endpoint:n,auth:t,p256dh:e}};return r!==bj&&(i.web.applicationPubKey=r),i}const Bj=6048e5;async function Wj(e){const t=await async function(e,t){var n=await e.pushManager.getSubscription();if(n)return n;return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:function(e){var t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/");const n=atob(t),r=new Uint8Array(n.length);for(let i=0;i<n.length;++i)r[i]=n.charCodeAt(i);return r}(t)})}(e.swRegistration,e.vapidKey);var n,r,i,s,o,a={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:t.endpoint,auth:kj(t.getKey("auth")),p256dh:kj(t.getKey("p256dh"))},c=await Oj(e.firebaseDependencies);if(c){if(n=c.subscriptionOptions,r=a.vapidKey===n.vapidKey,i=a.endpoint===n.endpoint,s=a.auth===n.auth,o=a.p256dh===n.p256dh,r&&i&&s&&o)return Date.now()>=c.createTime+Bj?async function(t,e){try{var n=await async function(e,t){var n=await qj(e),r=Vj(t.subscriptionOptions),r={method:"PATCH",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(`${jj(e.appConfig)}/${t.token}`,r);i=await s.json()}catch(e){throw Fj.create("token-update-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Fj.create("token-update-failed",{errorInfo:r})}if(!i.token)throw Fj.create("token-update-no-token");return i.token}(t.firebaseDependencies,e),r=Object.assign(Object.assign({},e),{token:n,createTime:Date.now()});return await Mj(t.firebaseDependencies,r),n}catch(e){throw await $j(t),e}}(e,{token:c.token,createTime:Date.now(),subscriptionOptions:a}):c.token;try{await Uj(e.firebaseDependencies,c.token)}catch(e){console.warn(e)}return Kj(e.firebaseDependencies,a)}return Kj(e.firebaseDependencies,a)}async function $j(e){var t=await Oj(e.firebaseDependencies);t&&(await Uj(e.firebaseDependencies,t.token),await async function(e){var t=Lj(e);const n=await Dj(),r=n.transaction(Pj,"readwrite");await r.objectStore(Pj).delete(t),await r.complete}(e.firebaseDependencies));const n=await e.swRegistration.pushManager.getSubscription();return!n||n.unsubscribe()}async function Kj(e,t){var n={token:await async function(e,t){var n=await qj(e),r=Vj(t),r={method:"POST",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(jj(e.appConfig),r);i=await s.json()}catch(e){throw Fj.create("token-subscribe-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Fj.create("token-subscribe-failed",{errorInfo:r})}if(!i.token)throw Fj.create("token-subscribe-no-token");return i.token}(e,t),createTime:Date.now(),subscriptionOptions:t};return await Mj(e,n),n.token}function zj(e){var t,n,r,i={from:e.from,collapseKey:e.collapse_key,messageId:e.fcmMessageId};return n=i,(t=e).notification&&(n.notification={},(r=t.notification.title)&&(n.notification.title=r),(r=t.notification.body)&&(n.notification.body=r),(r=t.notification.image)&&(n.notification.image=r)),t=i,(n=e).data&&(t.data=n.data),n=i,(e=e).fcmOptions&&(n.fcmOptions={},(r=e.fcmOptions.link)&&(n.fcmOptions.link=r),(r=e.fcmOptions.analytics_label)&&(n.fcmOptions.analyticsLabel=r)),i}function Hj(e,t){const n=[];for(let r=0;r<e.length;r++)n.push(e.charAt(r)),r<t.length&&n.push(t.charAt(r));return n.join("")}function Gj(e){return Fj.create("missing-app-config-values",{valueName:e})}Hj("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),Hj("AzSCbw63g1R0nCw85jG8","Iaya3yLKwmgvh7cF0q4");class Qj{constructor(e,t,n){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.logEvents=[],this.isLogServiceStarted=!1;var r=function(e){if(!e||!e.options)throw Gj("App Configuration Object");if(!e.name)throw Gj("App Name");var t=e["options"];for(const n of["projectId","apiKey","appId","messagingSenderId"])if(!t[n])throw Gj(n);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 Yj(e){try{e.swRegistration=await navigator.serviceWorker.register(_j,{scope:wj}),e.swRegistration.update().catch(()=>{})}catch(e){throw Fj.create("failed-service-worker-registration",{browserErrorMessage:e.message})}}async function Jj(e,t){if(!navigator)throw Fj.create("only-available-in-window");if("default"===Notification.permission&&await Notification.requestPermission(),"granted"!==Notification.permission)throw Fj.create("permission-blocked");var n,r;return n=e,await((r=null==t?void 0:t.vapidKey)?n.vapidKey=r:n.vapidKey||(n.vapidKey=bj)),await async function(e,t){if(t||e.swRegistration||await Yj(e),t||!e.swRegistration){if(!(t instanceof ServiceWorkerRegistration))throw Fj.create("invalid-sw-registration");e.swRegistration=t}}(e,null==t?void 0:t.serviceWorkerRegistration),Wj(e)}async function Xj(e,t,n){var r=function(e){switch(e){case pj.NOTIFICATION_CLICKED:return"notification_open";case pj.PUSH_RECEIVED:return"notification_foreground";default:throw new Error}}(t);const i=await e.firebaseDependencies.analyticsProvider.get();i.logEvent(r,{message_id:n[Tj],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 Zj(e,t){var n,r=t.data;r.isFirebaseMessaging&&(e.onMessageHandler&&r.messageType===pj.PUSH_RECEIVED&&("function"==typeof e.onMessageHandler?e.onMessageHandler(zj(r)):e.onMessageHandler.next(zj(r))),n=r.data,"object"==typeof(t=n)&&t&&Tj in t&&"1"===n[Ej]&&await Xj(e,r.messageType,n))}const eq="@firebase/messaging",tq=e=>{const t=new Qj(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return navigator.serviceWorker.addEventListener("message",e=>Zj(t,e)),t},nq=e=>{const t=e.getProvider("messaging").getImmediate();return{getToken:e=>Jj(t,e)}};function rq(e){return async function(e){if(!navigator)throw Fj.create("only-available-in-window");return e.swRegistration||await Yj(e),$j(e)}(e=$d(e))}function iq(e,t){return function(e,t){if(!navigator)throw Fj.create("only-available-in-window");return e.onMessageHandler=t,()=>{e.onMessageHandler=null}}(e=$d(e),t)}hp(new Kd("messaging",tq,"PUBLIC")),hp(new Kd("messaging-internal",nq,"PRIVATE")),_p(eq,"0.9.6"),_p(eq,"0.9.6","esm2017");const sq="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",oq="https://fcmregistrations.googleapis.com/v1",aq="FCM_MSG",cq="google.c.a.c_id",lq=3,uq=1;function hq(e){var t=new Uint8Array(e);const n=btoa(String.fromCharCode(...t));return n.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(yt=fj=fj||{})[yt.DATA_MESSAGE=1]="DATA_MESSAGE",yt[yt.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION",(c=gj=gj||{}).PUSH_RECEIVED="push-received",c.NOTIFICATION_CLICKED="notification-clicked";const dq="fcm_token_details_db",pq="fcm_token_object_Store";async function fq(s){if("databases"in indexedDB){const t=await indexedDB.databases(),n=t.map(e=>e.name);if(!n.includes(dq))return null}let o=null;const e=await qp(dq,5,async e=>{var t;if(!(e.oldVersion<2)&&e.objectStoreNames.contains(pq)){const i=e.transaction.objectStore(pq);var n,r=await i.index("fcmSenderId").get(s);await i.clear(),r&&(2===e.oldVersion?(n=r).auth&&n.p256dh&&n.endpoint&&(o={token:n.fcmToken,createTime:null!==(t=n.createTime)&&void 0!==t?t:Date.now(),subscriptionOptions:{auth:n.auth,p256dh:n.p256dh,endpoint:n.endpoint,swScope:n.swScope,vapidKey:"string"==typeof n.vapidKey?n.vapidKey:hq(n.vapidKey)}}):3===e.oldVersion?(n=r,o={token:n.fcmToken,createTime:n.createTime,subscriptionOptions:{auth:hq(n.auth),p256dh:hq(n.p256dh),endpoint:n.endpoint,swScope:n.swScope,vapidKey:hq(n.vapidKey)}}):4===e.oldVersion&&(r=r,o={token:r.fcmToken,createTime:r.createTime,subscriptionOptions:{auth:hq(r.auth),p256dh:hq(r.p256dh),endpoint:r.endpoint,swScope:r.swScope,vapidKey:hq(r.vapidKey)}}))}});return e.close(),await Vp(dq),await Vp("fcm_vapid_details_db"),await Vp("undefined"),function(e){if(!e||!e.subscriptionOptions)return!1;var t=e["subscriptionOptions"];return"number"==typeof e.createTime&&0<e.createTime&&"string"==typeof e.token&&0<e.token.length&&"string"==typeof t.auth&&0<t.auth.length&&"string"==typeof t.p256dh&&0<t.p256dh.length&&"string"==typeof t.endpoint&&0<t.endpoint.length&&"string"==typeof t.swScope&&0<t.swScope.length&&"string"==typeof t.vapidKey&&0<t.vapidKey.length}(o)?o:null}const gq="firebase-messaging-database",mq=1,vq="firebase-messaging-store";let yq=null;function _q(){return yq=yq||qp(gq,mq,e=>{0===e.oldVersion&&e.createObjectStore(vq)}),yq}async function wq(e){var t=Iq(e);const n=await _q();t=await n.transaction(vq).objectStore(vq).get(t);if(t)return t;t=await fq(e.appConfig.senderId);return t?(await bq(e,t),t):void 0}async function bq(e,t){var n=Iq(e);const r=await _q(),i=r.transaction(vq,"readwrite");return await i.objectStore(vq).put(t,n),await i.complete,t}function Iq({appConfig:e}){return e.appId}const Tq=new md("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.","invalid-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 Eq(e,t){var n={method:"DELETE",headers:await Sq(e)};try{const s=await fetch(`${kq(e.appConfig)}/${t}`,n);var r=await s.json();if(r.error){var i=r.error.message;throw Tq.create("token-unsubscribe-failed",{errorInfo:i})}}catch(e){throw Tq.create("token-unsubscribe-failed",{errorInfo:e})}}function kq({projectId:e}){return`${oq}/projects/${e}/registrations`}async function Sq({appConfig:e,installations:t}){var 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 Cq({p256dh:e,auth:t,endpoint:n,vapidKey:r}){const i={web:{endpoint:n,auth:t,p256dh:e}};return r!==sq&&(i.web.applicationPubKey=r),i}async function Aq(e){const t=await async function(e,t){var n=await e.pushManager.getSubscription();if(n)return n;return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:function(e){var t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/");const n=atob(t),r=new Uint8Array(n.length);for(let i=0;i<n.length;++i)r[i]=n.charCodeAt(i);return r}(t)})}(e.swRegistration,e.vapidKey);var n,r,i,s,o,a={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:t.endpoint,auth:hq(t.getKey("auth")),p256dh:hq(t.getKey("p256dh"))},c=await wq(e.firebaseDependencies);if(c){if(n=c.subscriptionOptions,r=a.vapidKey===n.vapidKey,i=a.endpoint===n.endpoint,s=a.auth===n.auth,o=a.p256dh===n.p256dh,r&&i&&s&&o)return Date.now()>=c.createTime+6048e5?async function(t,e){try{var n=await async function(e,t){var n=await Sq(e),r=Cq(t.subscriptionOptions),r={method:"PATCH",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(`${kq(e.appConfig)}/${t.token}`,r);i=await s.json()}catch(e){throw Tq.create("token-update-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Tq.create("token-update-failed",{errorInfo:r})}if(!i.token)throw Tq.create("token-update-no-token");return i.token}(t.firebaseDependencies,e),r=Object.assign(Object.assign({},e),{token:n,createTime:Date.now()});return await bq(t.firebaseDependencies,r),n}catch(e){throw await Nq(t),e}}(e,{token:c.token,createTime:Date.now(),subscriptionOptions:a}):c.token;try{await Eq(e.firebaseDependencies,c.token)}catch(e){console.warn(e)}return Rq(e.firebaseDependencies,a)}return Rq(e.firebaseDependencies,a)}async function Nq(e){var t=await wq(e.firebaseDependencies);t&&(await Eq(e.firebaseDependencies,t.token),await async function(e){var t=Iq(e);const n=await _q(),r=n.transaction(vq,"readwrite");await r.objectStore(vq).delete(t),await r.complete}(e.firebaseDependencies));const n=await e.swRegistration.pushManager.getSubscription();return!n||n.unsubscribe()}async function Rq(e,t){var n={token:await async function(e,t){var n=await Sq(e),r=Cq(t),r={method:"POST",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(kq(e.appConfig),r);i=await s.json()}catch(e){throw Tq.create("token-subscribe-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Tq.create("token-subscribe-failed",{errorInfo:r})}if(!i.token)throw Tq.create("token-subscribe-no-token");return i.token}(e,t),createTime:Date.now(),subscriptionOptions:t};return await bq(e,n),n.token}async function Pq(e,t){var n=function(e,t){var n;const r={};e.from&&(r.project_number=e.from);e.fcmMessageId&&(r.message_id=e.fcmMessageId);r.instance_id=t,e.notification?r.message_type=fj.DISPLAY_NOTIFICATION.toString():r.message_type=fj.DATA_MESSAGE.toString();r.sdk_platform=lq.toString(),r.package_name=self.origin.replace(/(^\w+:|^)\/\//,""),e.collapse_key&&(r.collapse_key=e.collapse_key);r.event=uq.toString(),null!==(n=e.fcmOptions)&&void 0!==n&&n.analytics_label&&(r.analytics_label=null===(n=e.fcmOptions)||void 0===n?void 0:n.analytics_label);return r}(t,await e.firebaseDependencies.installations.getId());!function(e,t){const n={};n.event_time_ms=Math.floor(Date.now()).toString(),n.source_extension_json_proto3=JSON.stringify(t),e.logEvents.push(n)}(e,n)}function xq(e,t){const n=[];for(let r=0;r<e.length;r++)n.push(e.charAt(r)),r<t.length&&n.push(t.charAt(r));return n.join("")}async function Dq(e,t){var n=function({data:e}){if(!e)return null;try{return e.json()}catch(e){return null}}(e);if(n){t.deliveryMetricsExportedToBigQueryEnabled&&await Pq(t,n);var r,i,s=await Mq();if(s.some(e=>"visible"===e.visibilityState&&!e.url.startsWith("chrome-extension://")))return function(e,t){t.isFirebaseMessaging=!0,t.messageType=gj.PUSH_RECEIVED;for(const n of e)n.postMessage(t)}(s,n);n.notification&&await function(e){var t=e["actions"],n=Notification["maxActions"];t&&n&&t.length>n&&console.warn(`This browser only supports ${n} actions. The remaining actions will not be displayed.`);return self.registration.showNotification(null!==(n=e.title)&&void 0!==n?n:"",e)}(function(e){const t=Object.assign({},e.notification);return t.data={[aq]:e},t}(n)),t&&t.onBackgroundMessageHandler&&(s={from:(r=n).from,collapseKey:r.collapse_key,messageId:r.fcmMessageId},n=s,(e=r).notification&&(n.notification={},(i=e.notification.title)&&(n.notification.title=i),(i=e.notification.body)&&(n.notification.body=i),(i=e.notification.image)&&(n.notification.image=i)),e=s,(n=r).data&&(e.data=n.data),n=s,(r=r).fcmOptions&&(n.fcmOptions={},(i=r.fcmOptions.link)&&(n.fcmOptions.link=i),(i=r.fcmOptions.analytics_label)&&(n.fcmOptions.analyticsLabel=i)),s=s,"function"==typeof t.onBackgroundMessageHandler?t.onBackgroundMessageHandler(s):t.onBackgroundMessageHandler.next(s))}}async function Oq(e){const t=null===(s=null===(i=e.notification)||void 0===i?void 0:i.data)||void 0===s?void 0:s[aq];if(t&&!e.action){e.stopImmediatePropagation(),e.notification.close();var n=function(e){var t;var n=null!==(t=null===(t=e.fcmOptions)||void 0===t?void 0:t.link)&&void 0!==t?t:null===(n=e.notification)||void 0===n?void 0:n.click_action;if(n)return n;return function(e){return"object"==typeof e&&e&&cq in e}(e.data)?self.location.origin:null}(t);if(n){var r,i=new URL(n,self.location.href),s=new URL(self.location.origin);if(i.host===s.host){let e=await async function(e){var t=await Mq();for(const r of t){var n=new URL(r.url,self.location.href);if(e.host===n.host)return r}return null}(i);if(e?e=await e.focus():(e=await self.clients.openWindow(n),r=3e3,await new Promise(e=>{setTimeout(e,r)})),e)return t.messageType=gj.NOTIFICATION_CLICKED,t.isFirebaseMessaging=!0,e.postMessage(t)}}}}function Mq(){return self.clients.matchAll({type:"window",includeUncontrolled:!0})}function Lq(e){return Tq.create("missing-app-config-values",{valueName:e})}xq("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),xq("AzSCbw63g1R0nCw85jG8","Iaya3yLKwmgvh7cF0q4");class Fq{constructor(e,t,n){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.logEvents=[],this.isLogServiceStarted=!1;var r=function(e){if(!e||!e.options)throw Lq("App Configuration Object");if(!e.name)throw Lq("App Name");var t=e["options"];for(const n of["projectId","apiKey","appId","messagingSenderId"])if(!t[n])throw Lq(n);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()}}const Uq=e=>{const t=new Fq(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return self.addEventListener("push",e=>{e.waitUntil(Dq(e,t))}),self.addEventListener("pushsubscriptionchange",e=>{e.waitUntil(async function(e,t){var n;(n=e["newSubscription"])?(n=await wq(t.firebaseDependencies),await Nq(t),t.vapidKey=null!==(n=null===(n=null==n?void 0:n.subscriptionOptions)||void 0===n?void 0:n.vapidKey)&&void 0!==n?n:sq,await Aq(t)):await Nq(t)}(e,t))}),self.addEventListener("notificationclick",e=>{e.waitUntil(Oq(e))}),t};function jq(e,t){return function(e,t){if(void 0!==self.document)throw Tq.create("only-available-in-sw");return e.onBackgroundMessageHandler=t,()=>{e.onBackgroundMessageHandler=null}}(e=$d(e),t)}hp(new Kd("messaging-sw",Uq,"PUBLIC"));var qq,Vq,Bq;class Wq{constructor(e,t){this.app=e,this._delegate=t,this.app=e,this._delegate=t}async getToken(e){return async function(e,t){return Jj(e=$d(e),t)}(this._delegate,e)}async deleteToken(){return rq(this._delegate)}onMessage(e){return iq(this._delegate,e)}onBackgroundMessage(e){return jq(this._delegate,e)}}const $q=e=>self&&"ServiceWorkerGlobalScope"in self?new Wq(e.getProvider("app-compat").getImmediate(),e.getProvider("messaging-sw").getImmediate()):new Wq(e.getProvider("app-compat").getImmediate(),e.getProvider("messaging").getImmediate()),Kq={isSupported:function(){return self&&"ServiceWorkerGlobalScope"in self?dd()&&"PushManager"in self&&"Notification"in self&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey"):"undefined"!=typeof window&&dd()&&fd()&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}};Cp.INTERNAL.registerComponent(new Kd("messaging-compat",$q,"PUBLIC").setServiceProps(Kq)),Cp.registerVersion("@firebase/messaging-compat","0.1.6");const zq="firebasestorage.googleapis.com",Hq="storageBucket";class Gq extends gd{constructor(e,t){super(Qq(e),`Firebase Storage: ${t} (${Qq(e)})`),this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,Gq.prototype)}_codeEquals(e){return Qq(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}\n${this.customData.serverResponse}`:this.message=this._baseMessage}}function Qq(e){return"storage/"+e}function Yq(){return new Gq("unknown","An unknown error occurred, please check the error payload for server response.")}function Jq(){return new Gq("canceled","User canceled the upload/download.")}function Xq(){return new Gq("cannot-slice-blob","Cannot slice blob for upload. Please retry the upload.")}function Zq(e){return new Gq("invalid-argument",e)}function eV(){return new Gq("app-deleted","The Firebase app was deleted.")}function tV(e){return new Gq("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 nV(e,t){return new Gq("invalid-format","String does not match format '"+e+"': "+t)}function rV(e){throw new Gq("internal-error","Internal error: "+e)}class iV{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return 0===this.path.length}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o"}static makeFromBucketSpec(t,e){let n;try{n=iV.makeFromUrl(t,e)}catch(e){return new iV(t,"")}if(""===n.path)return n;throw t=t,new Gq("invalid-default-bucket","Invalid default bucket '"+t+"'.")}static makeFromUrl(e,t){let n=null;var r="([A-Za-z0-9.\\-_]+)";var i=new RegExp("^gs://"+r+"(/(.*))?$","i");function s(e){e.path_=decodeURIComponent(e.path)}var o=t.replace(/[.]/g,"\\."),a=new RegExp(`^https?://${o}/v[A-Za-z0-9_]+/b/${r}/o(/([^?#]*).*)?$`,"i"),o=t===zq?"(?:storage.googleapis.com|storage.cloud.google.com)":t,c=[{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:a,indices:{bucket:1,path:3},postModify:s},{regex:new RegExp(`^https?://${o}/${r}/([^?#]*)`,"i"),indices:{bucket:1,path:2},postModify:s}];for(let h=0;h<c.length;h++){const d=c[h];var l=d.regex.exec(e);if(l){var u=l[d.indices.bucket];let e=l[d.indices.path];e=e||"",n=new iV(u,e),d.postModify(n);break}}if(null==n)throw t=e,new Gq("invalid-url","Invalid URL '"+t+"'.");return n}}class sV{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=0){}}function oV(e){return"string"==typeof e||e instanceof String}function aV(e){return cV()&&e instanceof Blob}function cV(){return"undefined"!=typeof Blob}function lV(e,t,n,r){if(r<t)throw Zq(`Invalid value for '${e}'. Expected ${t} or greater.`);if(n<r)throw Zq(`Invalid value for '${e}'. Expected ${n} or less.`)}function uV(e,t,n){let r=null==n?`https://${t}`:t;return`${n}://${r}/v0${e}`}function hV(e){const t=encodeURIComponent;let n="?";for(const i in e){var r;e.hasOwnProperty(i)&&(r=t(i)+"="+t(e[i]),n=n+r+"&")}return n=n.slice(0,-1),n}(c=qq=qq||{})[c.NO_ERROR=0]="NO_ERROR",c[c.NETWORK_ERROR=1]="NETWORK_ERROR",c[c.ABORT=2]="ABORT";class dV{constructor(e,t,n,r,i,s,o,a,c,l,u){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_=c,this.progressCallback_=l,this.connectionFactory_=u,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_(){var e=(r,e)=>{if(e)r(!1,new pV(!1,null,!0));else{const i=this.connectionFactory_();this.pendingConnection_=i;const s=e=>{var t=e.loaded,n=e.lengthComputable?e.total:-1;null!==this.progressCallback_&&this.progressCallback_(t,n)};null!==this.progressCallback_&&i.addUploadProgressListener(s),i.send(this.url_,this.method_,this.body_,this.headers_).then(()=>{null!==this.progressCallback_&&i.removeUploadProgressListener(s),this.pendingConnection_=null;var e,t=i.getErrorCode()===qq.NO_ERROR,n=i.getStatus();t&&!this.isRetryStatusCode_(n)?(e=-1!==this.successCodes_.indexOf(n),r(!0,new pV(e,i))):(e=i.getErrorCode()===qq.ABORT,r(!1,new pV(!1,null,e)))})}},t=(e,t)=>{const n=this.resolve_,r=this.reject_,i=t.connection;if(t.wasSuccessCode)try{var s=this.callback_(i,i.getResponse());void 0!==s?n(s):n()}catch(e){r(e)}else if(null!==i){const a=Yq();a.serverResponse=i.getErrorText(),this.errorCallback_?r(this.errorCallback_(i,a)):r(a)}else{var o;t.canceled?(o=(this.appDelete_?eV:Jq)(),r(o)):(o=new Gq("retry-limit-exceeded","Max retry time for operation exceeded, please try again."),r(o))}};this.canceled_?t(0,new pV(!1,null,!0)):this.backoffId_=function(t,n,e){let r=1,i=null,s=null,o=!1,a=0;function c(){return 2===a}let l=!1;function u(...e){l||(l=!0,n.apply(null,e))}function h(e){i=setTimeout(()=>{i=null,t(p,c())},e)}function d(){s&&clearTimeout(s)}function p(t,...n){if(l)d();else{if(t)return d(),void u.call(null,t,...n);if(c()||o)return d(),void u.call(null,t,...n);r<64&&(r*=2);let e;e=1===a?(a=2,0):1e3*(r+Math.random()),h(e)}}let f=!1;function g(e){f||(f=!0,d(),l||(null!==i?(e||(a=2),clearTimeout(i),h(0)):e||(a=1)))}return h(0),s=setTimeout(()=>{g(o=!0)},e),g}(e,t,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()}isRetryStatusCode_(e){var t=500<=e&&e<600,n=-1!==[408,429].indexOf(e),r=-1!==this.additionalRetryCodes_.indexOf(e);return t||n||r}}class pV{constructor(e,t,n){this.wasSuccessCode=e,this.connection=t,this.canceled=!!n}}function fV(...t){const n="undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0;if(void 0!==n){const r=new n;for(let e=0;e<t.length;e++)r.append(t[e]);return r.getBlob()}if(cV())return new Blob(t);throw new Gq("unsupported-environment","This browser doesn't seem to support creating Blobs")}const gV={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class mV{constructor(e,t){this.data=e,this.contentType=t||null}}function vV(e,t){switch(e){case gV.RAW:return new mV(yV(t));case gV.BASE64:case gV.BASE64URL:return new mV(_V(e,t));case gV.DATA_URL:return new mV((n=t,(r=new wV(n)).base64?_V(gV.BASE64,r.rest):function(e){let t;try{t=decodeURIComponent(e)}catch(e){throw nV(gV.DATA_URL,"Malformed data URL.")}return yV(t)}(r.rest)),(n=t,new wV(n).contentType))}var n,r;throw Yq()}function yV(t){const n=[];for(let s=0;s<t.length;s++){let e=t.charCodeAt(s);var r,i;e<=127?n.push(e):e<=2047?n.push(192|e>>6,128|63&e):55296==(64512&e)?s<t.length-1&&56320==(64512&t.charCodeAt(s+1))?(r=e,i=t.charCodeAt(++s),e=65536|(1023&r)<<10|1023&i,n.push(240|e>>18,128|e>>12&63,128|e>>6&63,128|63&e)):n.push(239,191,189):56320==(64512&e)?n.push(239,191,189):n.push(224|e>>12,128|e>>6&63,128|63&e)}return new Uint8Array(n)}function _V(t,e){switch(t){case gV.BASE64:var n=-1!==e.indexOf("-"),r=-1!==e.indexOf("_");if(n||r)throw nV(t,"Invalid character '"+(n?"-":"_")+"' found: is it base64url encoded?");break;case gV.BASE64URL:r=-1!==e.indexOf("+"),n=-1!==e.indexOf("/");if(r||n)throw nV(t,"Invalid character '"+(r?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/")}let i;try{i=atob(e)}catch(e){throw nV(t,"Invalid character found")}const s=new Uint8Array(i.length);for(let o=0;o<i.length;o++)s[o]=i.charCodeAt(o);return s}class wV{constructor(e){this.base64=!1,this.contentType=null;var t,n,r=e.match(/^data:([^,]+)?,/);if(null===r)throw nV(gV.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");const i=r[1]||null;null!=i&&(this.base64=(t=i,n=";base64",t.length>=n.length&&t.substring(t.length-n.length)===n),this.contentType=this.base64?i.substring(0,i.length-";base64".length):i),this.rest=e.substring(e.indexOf(",")+1)}}class bV{constructor(e,t){let n=0,r="";aV(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(aV(this.data_)){var n=this.data_,n=(i=e,s=t,(r=n).webkitSlice?r.webkitSlice(i,s):r.mozSlice?r.mozSlice(i,s):r.slice?r.slice(i,s):null);return null===n?null:new bV(n)}var r,i,s,n=new Uint8Array(this.data_.buffer,e,t-e);return new bV(n,!0)}static getBlob(...e){if(cV()){var t=e.map(e=>e instanceof bV?e.data_:e);return new bV(fV.apply(null,t))}{const r=e.map(e=>oV(e)?vV(gV.RAW,e).data:e.data_);let t=0;r.forEach(e=>{t+=e.byteLength});const i=new Uint8Array(t);let n=0;return r.forEach(e=>{for(let t=0;t<e.length;t++)i[n++]=e[t]}),new bV(i,!0)}}uploadData(){return this.data_}}function IV(e){let t;try{t=JSON.parse(e)}catch(e){return null}return"object"!=typeof(e=t)||Array.isArray(e)?null:t}function TV(e){var t=e.lastIndexOf("/",e.length-2);return-1===t?e:e.slice(t+1)}function EV(e,t){return t}class kV{constructor(e,t,n,r){this.server=e,this.local=t||e,this.writable=!!n,this.xform=r||EV}}let SV=null;function CV(){if(SV)return SV;const e=[];e.push(new kV("bucket")),e.push(new kV("generation")),e.push(new kV("metageneration")),e.push(new kV("name","fullPath",!0));const t=new kV("name");t.xform=function(e,t){return!oV(t=t)||t.length<2?t:TV(t)},e.push(t);const n=new kV("size");return n.xform=function(e,t){return void 0!==t?Number(t):t},e.push(n),e.push(new kV("timeCreated")),e.push(new kV("updated")),e.push(new kV("md5Hash",null,!0)),e.push(new kV("cacheControl",null,!0)),e.push(new kV("contentDisposition",null,!0)),e.push(new kV("contentEncoding",null,!0)),e.push(new kV("contentLanguage",null,!0)),e.push(new kV("contentType",null,!0)),e.push(new kV("metadata","customMetadata",!0)),SV=e,SV}function AV(n,r){Object.defineProperty(n,"ref",{get:function(){var e=n.bucket,t=n.fullPath,t=new iV(e,t);return r._makeStorageReference(t)}})}function NV(e,t,n){var r=IV(t);return null===r?null:function(e,t,n){const r={type:"file"};var i=n.length;for(let s=0;s<i;s++){const o=n[s];r[o.local]=o.xform(r,t[o.server])}return AV(r,e),r}(e,r,n)}function RV(e,t){const n={};var r=t.length;for(let s=0;s<r;s++){var i=t[s];i.writable&&(n[i.server]=e[i.local])}return JSON.stringify(n)}function PV(e,t,n){var r=IV(n);return null===r?null:function(e,t,n){const r={prefixes:[],items:[],nextPageToken:n.nextPageToken};if(n.prefixes)for(const o of n.prefixes){var i=o.replace(/\/$/,""),i=e._makeStorageReference(new iV(t,i));r.prefixes.push(i)}if(n.items)for(const a of n.items){var s=e._makeStorageReference(new iV(t,a.name));r.items.push(s)}return r}(e,t,r)}class xV{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 DV(e){if(!e)throw Yq()}function OV(r,i){return function(e,t){var n=NV(r,t,i);return DV(null!==n),n}}function MV(r,i){return function(e,t){var n=PV(r,i,t);return DV(null!==n),n}}function LV(r,i){return function(e,t){var n=NV(r,t,i);return DV(null!==n),function(r,e,i,s){var t=IV(e);if(null===t)return null;if(!oV(t.downloadTokens))return null;const n=t.downloadTokens;if(0===n.length)return null;const o=encodeURIComponent,a=n.split(",");return a.map(e=>{var t=r.bucket,n=r.fullPath;return uV("/b/"+o(t)+"/o/"+o(n),i,s)+hV({alt:"media",token:e})})[0]}(n,t,r.host,r._protocol)}}function FV(i){return function(e,t){let n;var r;return n=401===e.getStatus()?e.getErrorText().includes("Firebase App Check token is invalid")?new Gq("unauthorized-app","This app does not have permission to access Firebase Storage on this project."):new Gq("unauthenticated","User is not authenticated, please authenticate using Firebase Authentication and try again."):402===e.getStatus()?(r=i.bucket,new Gq("quota-exceeded","Quota for bucket '"+r+"' exceeded, please view quota on https://firebase.google.com/pricing/.")):403===e.getStatus()?(e=i.path,new Gq("unauthorized","User does not have permission to access '"+e+"'.")):t,n.serverResponse=t.serverResponse,n}}function UV(r){const i=FV(r);return function(e,t){let n=i(e,t);return 404===e.getStatus()&&(n=(e=r.path,new Gq("object-not-found","Object '"+e+"' does not exist."))),n.serverResponse=t.serverResponse,n}}function jV(e,t,n){var r=uV(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime;const s=new xV(r,"GET",OV(e,n),i);return s.errorHandler=UV(t),s}function qV(e,t,n){const r=Object.assign({},n);return r.fullPath=e.path,r.size=t.size(),r.contentType||(r.contentType=(e=t,(t=null)&&t.contentType||e&&e.type()||"application/octet-stream")),r}function VV(e,t,n,r,i){var s=t.bucketOnlyServerUrl();const o={"X-Goog-Upload-Protocol":"multipart"};var 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;var c=qV(t,r,i),l="--"+a+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+RV(c,n)+"\r\n--"+a+"\r\nContent-Type: "+c.contentType+"\r\n\r\n",a="\r\n--"+a+"--";const u=bV.getBlob(l,r,a);if(null===u)throw Xq();a={name:c.fullPath},c=uV(s,e.host,e._protocol),s=e.maxUploadRetryTime;const h=new xV(c,"POST",OV(e,n),s);return h.urlParams=a,h.headers=o,h.body=u.uploadData(),h.errorHandler=FV(t),h}class BV{constructor(e,t,n,r){this.current=e,this.total=t,this.finalized=!!n,this.metadata=r||null}}function WV(e,t){let n=null;try{n=e.getResponseHeader("X-Goog-Upload-Status")}catch(e){DV(!1)}const r=t||["active"];return DV(!!n&&-1!==r.indexOf(n)),n}function $V(e,t,n,r,i){var s=t.bucketOnlyServerUrl(),o=qV(t,r,i),a={name:o.fullPath},c=uV(s,e.host,e._protocol),l={"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"},s=RV(o,n),o=e.maxUploadRetryTime;const u=new xV(c,"POST",function(e){WV(e);let t;try{t=e.getResponseHeader("X-Goog-Upload-URL")}catch(e){DV(!1)}return DV(oV(t)),t},o);return u.urlParams=a,u.headers=l,u.body=s,u.errorHandler=FV(t),u}function KV(e,t,n,i){var r=e.maxUploadRetryTime;const s=new xV(n,"POST",function(e){var t=WV(e,["active","final"]);let n=null;try{n=e.getResponseHeader("X-Goog-Upload-Size-Received")}catch(e){DV(!1)}n||DV(!1);var r=Number(n);return DV(!isNaN(r)),new BV(r,i.size(),"final"===t)},r);return s.headers={"X-Goog-Upload-Command":"query"},s.errorHandler=FV(t),s}function zV(e,o,t,a,n,c,r,i){const l=new BV(0,0);if(r?(l.current=r.current,l.total=r.total):(l.current=0,l.total=a.size()),a.size()!==l.total)throw new Gq("server-file-wrong-size","Server recorded incorrect upload file size, please retry the upload.");var s=l.total-l.current;let u=s;0<n&&(u=Math.min(u,n));var h=l.current,d=h+u,s={"X-Goog-Upload-Command":u===s?"upload, finalize":"upload","X-Goog-Upload-Offset":`${l.current}`};const p=a.slice(h,d);if(null===p)throw Xq();d=o.maxUploadRetryTime;const f=new xV(t,"POST",function(e,t){var n=WV(e,["active","final"]),r=l.current+u,i=a.size();let s;return s="final"===n?OV(o,c)(e,t):null,new BV(r,i,"final"===n,s)},d);return f.headers=s,f.body=p.uploadData(),f.progressCallback=i||null,f.errorHandler=FV(e),f}const HV={STATE_CHANGED:"state_changed"},GV={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function QV(e){switch(e){case"running":case"pausing":case"canceling":return GV.RUNNING;case"paused":return GV.PAUSED;case"success":return GV.SUCCESS;case"canceled":return GV.CANCELED;default:return GV.ERROR}}class YV{constructor(e,t,n){var r;"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=(r=e).next,this.error=r.error,this.complete=r.complete)}}function JV(t){return(...e)=>{Promise.resolve().then(()=>t(...e))}}class XV extends class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=qq.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=qq.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=qq.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,n,r){if(this.sent_)throw rV("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(t,e,!0),void 0!==r)for(const i in r)r.hasOwnProperty(i)&&this.xhr_.setRequestHeader(i,r[i].toString());return void 0!==n?this.xhr_.send(n):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw rV("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw rV("cannot .getStatus() before sending");try{return this.xhr_.status}catch(e){return-1}}getResponse(){if(!this.sent_)throw rV("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw rV("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)}}{initXhr(){this.xhr_.responseType="text"}}function ZV(){return new XV}class eB{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=CV(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=e=>{this._request=void 0,this._chunkMultiplier=1,e._codeEquals("canceled")?(this._needToFetchStatus=!0,this.completeTransitions_()):(this._error=e,this._transition("error"))},this._metadataErrorHandler=e=>{this._request=void 0,e._codeEquals("canceled")?this.completeTransitions_():(this._error=e,this._transition("error"))},this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t,this._start()}),this._promise.then(null,()=>{})}_makeProgressCallback(){const t=this._transferred;return e=>this._updateProgress(t+e)}_shouldDoResumable(e){return 262144<e.size()}_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._continueUpload():this._oneShotUpload())}_resolveToken(n){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([e,t])=>{switch(this._state){case"running":n(e,t);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused")}})}_createResumable(){this._resolveToken((e,t)=>{var n=$V(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata);const r=this._ref.storage._makeRequest(n,ZV,e,t);this._request=r,r.getPromise().then(e=>{this._request=void 0,this._uploadUrl=e,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){const i=this._uploadUrl;this._resolveToken((e,t)=>{var n=KV(this._ref.storage,this._ref._location,i,this._blob);const r=this._ref.storage._makeRequest(n,ZV,e,t);this._request=r,r.getPromise().then(e=>{this._request=void 0,this._updateProgress(e.current),this._needToFetchStatus=!1,e.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){const i=262144*this._chunkMultiplier,s=new BV(this._transferred,this._blob.size()),o=this._uploadUrl;this._resolveToken((e,t)=>{let n;try{n=zV(this._ref._location,this._ref.storage,o,this._blob,i,this._mappings,s,this._makeProgressCallback())}catch(e){return this._error=e,void this._transition("error")}const r=this._ref.storage._makeRequest(n,ZV,e,t);this._request=r,r.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<33554432&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{var n=jV(this._ref.storage,this._ref._location,this._mappings);const r=this._ref.storage._makeRequest(n,ZV,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)=>{var n=VV(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata);const r=this._ref.storage._makeRequest(n,ZV,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){var 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();break;case"running":var t="paused"===this._state;this._state=e,t&&(this._notifyObservers(),this._start());break;case"paused":this._state=e,this._notifyObservers();break;case"canceled":this._error=Jq(),this._state=e,this._notifyObservers();break;case"error":case"success":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(){var e=QV(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){const i=new YV(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){var t=this._observers.indexOf(e);-1!==t&&this._observers.splice(t,1)}_notifyObservers(){this._finishPromise();const e=this._observers.slice();e.forEach(e=>{this._notifyObserver(e)})}_finishPromise(){if(void 0!==this._resolve){let e=!0;switch(QV(this._state)){case GV.SUCCESS:JV(this._resolve.bind(null,this.snapshot))();break;case GV.CANCELED:case GV.ERROR:const t=this._reject;JV(t.bind(null,this._error))();break;default:e=!1}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(QV(this._state)){case GV.RUNNING:case GV.PAUSED:e.next&&JV(e.next.bind(e,this.snapshot))();break;case GV.SUCCESS:e.complete&&JV(e.complete.bind(e))();break;case GV.CANCELED:case GV.ERROR:default:e.error&&JV(e.error.bind(e,this._error))()}}resume(){var e="paused"===this._state||"pausing"===this._state;return e&&this._transition("running"),e}pause(){var e="running"===this._state;return e&&this._transition("pausing"),e}cancel(){var e="running"===this._state||"pausing"===this._state;return e&&this._transition("canceling"),e}}class tB{constructor(e,t){this._service=e,t instanceof iV?this._location=t:this._location=iV.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new tB(e,t)}get root(){var e=new iV(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return TV(this._location.path)}get storage(){return this._service}get parent(){var e=function(e){if(0===e.length)return null;var t=e.lastIndexOf("/");return-1===t?"":e.slice(0,t)}(this._location.path);if(null===e)return null;e=new iV(this._location.bucket,e);return new tB(this._service,e)}_throwIfRoot(e){if(""===this._location.path)throw tV(e)}}function nB(e){const t={prefixes:[],items:[]};return async function e(t,n,r){const i={pageToken:r};const s=await rB(t,i);n.prefixes.push(...s.prefixes);n.items.push(...s.items);null!=s.nextPageToken&&await e(t,n,s.nextPageToken)}(e,t).then(()=>t)}function rB(e,t){null!=t&&"number"==typeof t.maxResults&&lV("options.maxResults",1,1e3,t.maxResults);var n=t||{},n=function(e,t,n,r,i){const s={};t.isRoot?s.prefix="":s.prefix=t.path+"/",n&&0<n.length&&(s.delimiter=n),r&&(s.pageToken=r),i&&(s.maxResults=i);var o=uV(t.bucketOnlyServerUrl(),e.host,e._protocol),a=e.maxOperationRetryTime;const c=new xV(o,"GET",MV(e,t.bucket),a);return c.urlParams=s,c.errorHandler=FV(t),c}(e.storage,e._location,"/",n.pageToken,n.maxResults);return e.storage.makeRequestWithTokens(n,ZV)}function iB(e,t){e._throwIfRoot("updateMetadata");var n=function(e,t,n,r){var i=uV(t.fullServerUrl(),e.host,e._protocol),s=RV(n,r),o=e.maxOperationRetryTime;const a=new xV(i,"PATCH",OV(e,r),o);return a.headers={"Content-Type":"application/json; charset=utf-8"},a.body=s,a.errorHandler=UV(t),a}(e.storage,e._location,t,CV());return e.storage.makeRequestWithTokens(n,ZV)}function sB(e){e._throwIfRoot("getDownloadURL");var t=function(e,t,n){var r=uV(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime;const s=new xV(r,"GET",LV(e,n),i);return s.errorHandler=UV(t),s}(e.storage,e._location,CV());return e.storage.makeRequestWithTokens(t,ZV).then(e=>{if(null===e)throw new Gq("no-download-url","The given file does not have any download URLs.");return e})}function oB(e){e._throwIfRoot("deleteObject");var t=function(e,t){var n=uV(t.fullServerUrl(),e.host,e._protocol),r=e.maxOperationRetryTime;const i=new xV(n,"DELETE",function(e,t){},r);return i.successCodes=[200,204],i.errorHandler=UV(t),i}(e.storage,e._location);return e.storage.makeRequestWithTokens(t,ZV)}function aB(e,t){var n,r=(n=e._location.path,r=t.split("/").filter(e=>0<e.length).join("/"),0===n.length?r:n+"/"+r),r=new iV(e._location.bucket,r);return new tB(e.storage,r)}function cB(e,t){if(e instanceof hB){var n=e;if(null==n._bucket)throw new Gq("no-default-bucket","No default bucket found. Did you set the '"+Hq+"' property when initializing the app?");n=new tB(n,n._bucket);return null!=t?cB(n,t):n}return void 0!==t?aB(e,t):e}function lB(e,t){if(t&&/^[A-Za-z]+:\/\//.test(t)){if(e instanceof hB)return n=e,r=t,new tB(n,r);throw Zq("To use ref(service, url), the first argument must be a Storage instance.")}return cB(e,t);var n,r}function uB(e,t){var n=null==t?void 0:t[Hq];return null==n?null:iV.makeFromBucketSpec(n,e)}class hB{constructor(e,t,n,r,i){this.app=e,this._authProvider=t,this._appCheckProvider=n,this._url=r,this._firebaseVersion=i,this._bucket=null,this._host=zq,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=12e4,this._maxUploadRetryTime=6e5,this._requests=new Set,this._bucket=null!=r?iV.makeFromBucketSpec(r,this._host):uB(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,null!=this._url?this._bucket=iV.makeFromBucketSpec(this._url,e):this._bucket=uB(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){lV("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){lV("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){var t=await e.getToken();if(null!==t)return t.accessToken}return null}async _getAppCheckToken(){const e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new tB(this,e)}_makeRequest(e,t,n,r){if(this._deleted)return new sV(eV());{const l=(i=e,s=this._appId,o=n,e=r,n=t,r=this._firebaseVersion,a=hV(i.urlParams),c=i.url+a,a=Object.assign({},i.headers),t=a,(s=s)&&(t["X-Firebase-GMPID"]=s),s=a,null!==(o=o)&&0<o.length&&(s.Authorization="Firebase "+o),r=r,a["X-Firebase-Storage-Version"]="webjs/"+(null!=r?r:"AppManager"),r=a,null!==(e=e)&&(r["X-Firebase-AppCheck"]=e),new dV(c,i.method,a,i.body,i.successCodes,i.additionalRetryCodes,i.handler,i.errorHandler,i.timeout,i.progressCallback,n));return this._requests.add(l),l.getPromise().then(()=>this._requests.delete(l),()=>this._requests.delete(l)),l}var i,s,o,a,c}async makeRequestWithTokens(e,t){var[n,r]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,n,r).getPromise()}}const dB="@firebase/storage";function pB(e,t,n){return e=$d(e),t=t,n=n,(e=e)._throwIfRoot("uploadBytesResumable"),new eB(e,new bV(t),n)}function fB(e){return function(e){e._throwIfRoot("getMetadata");var t=jV(e.storage,e._location,CV());return e.storage.makeRequestWithTokens(t,ZV)}(e=$d(e))}function gB(e,t){return lB(e=$d(e),t)}function mB(e,t,n,r={}){!function(e,t,n,r={}){e.host=`${t}:${n}`,e._protocol="http";var i=r["mockUserToken"];i&&(e._overrideAuthToken="string"==typeof i?i:id(i,e.app.options.projectId))}(e,t,n,r)}function vB(e,{instanceIdentifier:t}){var n=e.getProvider("app").getImmediate(),r=e.getProvider("auth-internal"),i=e.getProvider("app-check-internal");return new hB(n,r,i,t,gp)}hp(new Kd("storage",vB,"PUBLIC").setMultipleInstances(!0)),_p(dB,"0.9.1",""),_p(dB,"0.9.1","esm2017");class yB{constructor(e,t,n){this._delegate=e,this.task=t,this.ref=n}get bytesTransferred(){return this._delegate.bytesTransferred}get metadata(){return this._delegate.metadata}get state(){return this._delegate.state}get totalBytes(){return this._delegate.totalBytes}}class _B{constructor(e,t){this._delegate=e,this._ref=t,this.cancel=this._delegate.cancel.bind(this._delegate),this.catch=this._delegate.catch.bind(this._delegate),this.pause=this._delegate.pause.bind(this._delegate),this.resume=this._delegate.resume.bind(this._delegate)}get snapshot(){return new yB(this._delegate.snapshot,this,this._ref)}then(t,e){return this._delegate.then(e=>{if(t)return t(new yB(e,this,this._ref))},e)}on(e,t,n,r){let i=void 0;return t&&(i="function"==typeof t?e=>t(new yB(e,this,this._ref)):{next:t.next?e=>t.next(new yB(e,this,this._ref)):void 0,complete:t.complete||void 0,error:t.error||void 0}),this._delegate.on(e,i,n||void 0,r||void 0)}}class wB{constructor(e,t){this._delegate=e,this._service=t}get prefixes(){return this._delegate.prefixes.map(e=>new bB(e,this._service))}get items(){return this._delegate.items.map(e=>new bB(e,this._service))}get nextPageToken(){return this._delegate.nextPageToken||null}}class bB{constructor(e,t){this._delegate=e,this.storage=t}get name(){return this._delegate.name}get bucket(){return this._delegate.bucket}get fullPath(){return this._delegate.fullPath}toString(){return this._delegate.toString()}child(e){var t=aB(this._delegate,e);return new bB(t,this.storage)}get root(){return new bB(this._delegate.root,this.storage)}get parent(){var e=this._delegate.parent;return null==e?null:new bB(e,this.storage)}put(e,t){return this._throwIfRoot("put"),new _B(pB(this._delegate,e,t),this)}putString(e,t=gV.RAW,n){this._throwIfRoot("putString");var r=vV(t,e);const i=Object.assign({},n);return null==i.contentType&&null!=r.contentType&&(i.contentType=r.contentType),new _B(new eB(this._delegate,new bV(r.data,!0),i),this)}listAll(){return nB($d(this._delegate)).then(e=>new wB(e,this.storage))}list(e){return t=this._delegate,e=e||void 0,rB(t=$d(t),e).then(e=>new wB(e,this.storage));var t}getMetadata(){return fB(this._delegate)}updateMetadata(e){return iB($d(this._delegate),e)}getDownloadURL(){return sB($d(this._delegate))}delete(){return this._throwIfRoot("delete"),oB($d(this._delegate))}_throwIfRoot(e){if(""===this._delegate._location.path)throw tV(e)}}class IB{constructor(e,t){this.app=e,this._delegate=t}get maxOperationRetryTime(){return this._delegate.maxOperationRetryTime}get maxUploadRetryTime(){return this._delegate.maxUploadRetryTime}ref(e){if(TB(e))throw Zq("ref() expected a child path but got a URL, use refFromURL instead.");return new bB(gB(this._delegate,e),this)}refFromURL(e){if(!TB(e))throw Zq("refFromURL() expected a full URL but got a child path, use ref() instead.");try{iV.makeFromUrl(e,this._delegate.host)}catch(e){throw Zq("refFromUrl() expected a valid full URL but got an invalid one.")}return new bB(gB(this._delegate,e),this)}setMaxUploadRetryTime(e){this._delegate.maxUploadRetryTime=e}setMaxOperationRetryTime(e){this._delegate.maxOperationRetryTime=e}useEmulator(e,t,n={}){mB(this._delegate,e,t,n)}}function TB(e){return/^[A-Za-z]+:\/\//.test(e)}function EB(e,{instanceIdentifier:t}){var n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("storage").getImmediate({identifier:t});return new IB(n,r)}Vq=Cp,Bq={TaskState:GV,TaskEvent:HV,StringFormat:gV,Storage:IB,Reference:bB},Vq.INTERNAL.registerComponent(new Kd("storage-compat",EB,"PUBLIC").setServiceProps(Bq).setMultipleInstances(!0)),Vq.registerVersion("@firebase/storage-compat","0.1.9");const kB="@firebase/performance",SB="0.5.5",CB="FB-PERF-TRACE-MEASURE",AB="@firebase/performance/config",NB="@firebase/performance/configexpire";var RB,PB,xB,DB="Performance";const OB=new md("performance",DB,{"trace started":"Trace {$traceName} was started before.","trace stopped":"Trace {$traceName} is not running.","nonpositive trace startTime":"Trace {$traceName} startTime should be positive.","nonpositive trace duration":"Trace {$traceName} duration should be positive.","no window":"Window is not available.","no app id":"App id is not available.","no project id":"Project id is not available.","no api key":"Api key is not available.","invalid cc log":"Attempted to queue invalid cc event","FB not default":"Performance can only start when Firebase app instance is the default one.","RC response not ok":"RC response is not ok","invalid attribute name":"Attribute name {$attributeName} is invalid.","invalid attribute value":"Attribute value {$attributeValue} is invalid.","invalid custom metric name":"Custom metric name {$customMetricName} is invalid","invalid String merger input":"Input for String merger is invalid, contact support team to resolve.","already initialized":"initializePerformance() has already been called with different options. To avoid this error, call initializePerformance() with the same options as when it was originally called, or call getPerformance() to return the already initialized instance."}),MB=new ep(DB);MB.logLevel=$h.INFO;let LB,FB;class UB{constructor(e){if(!(this.window=e))throw OB.create("no window");this.performance=e.performance,this.PerformanceObserver=e.PerformanceObserver,this.windowLocation=e.location,this.navigator=e.navigator,this.document=e.document,this.navigator&&this.navigator.cookieEnabled&&(this.localStorage=e.localStorage),e.perfMetrics&&e.perfMetrics.onFirstInputDelay&&(this.onFirstInputDelay=e.perfMetrics.onFirstInputDelay)}getUrl(){return this.windowLocation.href.split("?")[0]}mark(e){this.performance&&this.performance.mark&&this.performance.mark(e)}measure(e,t,n){this.performance&&this.performance.measure&&this.performance.measure(e,t,n)}getEntriesByType(e){return this.performance&&this.performance.getEntriesByType?this.performance.getEntriesByType(e):[]}getEntriesByName(e){return this.performance&&this.performance.getEntriesByName?this.performance.getEntriesByName(e):[]}getTimeOrigin(){return this.performance&&(this.performance.timeOrigin||this.performance.timing.navigationStart)}requiredApisAvailable(){return fetch&&Promise&&fd()?!!dd()||(MB.info("IndexedDB is not supported by current browswer"),!1):(MB.info("Firebase Performance cannot start if browser does not support fetch and Promise or cookie is disabled."),!1)}setupObserver(e,n){if(this.PerformanceObserver){const t=new this.PerformanceObserver(e=>{for(const t of e.getEntries())n(t)});t.observe({entryTypes:[e]})}}static getInstance(){return void 0===LB&&(LB=new UB(FB)),LB}}let jB;function qB(e,t){var n=e.length-t.length;if(n<0||1<n)throw OB.create("invalid String merger input");const r=[];for(let i=0;i<e.length;i++)r.push(e.charAt(i)),t.length>i&&r.push(t.charAt(i));return r.join("")}let VB;class BB{constructor(){this.instrumentationEnabled=!0,this.dataCollectionEnabled=!0,this.loggingEnabled=!1,this.tracesSamplingRate=1,this.networkRequestsSamplingRate=1,this.logEndPointUrl="https://firebaselogging.googleapis.com/v0cc/log?format=json_proto",this.flTransportEndpointUrl=qB("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),this.transportKey=qB("AzSC8r6ReiGqFMyfvgow","Iayx0u-XT3vksVM-pIV"),this.logSource=462,this.logTraceAfterSampling=!1,this.logNetworkAfterSampling=!1,this.configTimeToLive=12}getFlTransportFullUrl(){return this.flTransportEndpointUrl.concat("?key=",this.transportKey)}static getInstance(){return void 0===VB&&(VB=new BB),VB}}(c=RB=RB||{})[c.UNKNOWN=0]="UNKNOWN",c[c.VISIBLE=1]="VISIBLE",c[c.HIDDEN=2]="HIDDEN";const WB=["firebase_","google_","ga_"],$B=new RegExp("^[a-zA-Z]\\w*$");function KB(){switch(UB.getInstance().document.visibilityState){case"visible":return RB.VISIBLE;case"hidden":return RB.HIDDEN;default:return RB.UNKNOWN}}function zB(e){var t=null===(t=e.options)||void 0===t?void 0:t.appId;if(!t)throw OB.create("no app id");return t}const HB="0.0.1",GB={loggingEnabled:!0},QB="FIREBASE_INSTALLATIONS_AUTH";function YB(e,t){var r,i,n=function(){const e=UB.getInstance().localStorage;if(e){var t=e.getItem(NB);if(t&&function(e){return Number(e)>Date.now()}(t)){t=e.getItem(AB);if(t)try{return JSON.parse(t)}catch(e){return}}}}();return n?(XB(n),Promise.resolve()):(i=t,function(e){const t=e.getToken();return t.then(e=>{}),t}((r=e).installations).then(e=>{var t=function(e){var t=null===(t=e.options)||void 0===t?void 0:t.projectId;if(!t)throw OB.create("no project id");return t}(r.app),n=function(e){var t=null===(t=e.options)||void 0===t?void 0:t.apiKey;if(!t)throw OB.create("no api key");return t}(r.app),n=new Request(`https://firebaseremoteconfig.googleapis.com/v1/projects/${t}/namespaces/fireperf:fetch?key=${n}`,{method:"POST",headers:{Authorization:`${QB} ${e}`},body:JSON.stringify({app_instance_id:i,app_instance_id_token:e,app_id:zB(r.app),app_version:SB,sdk_version:HB})});return fetch(n).then(e=>{if(e.ok)return e.json();throw OB.create("RC response not ok")})}).catch(()=>{MB.info(JB)}).then(XB).then(e=>function(e){const t=UB.getInstance().localStorage;e&&t&&(t.setItem(AB,JSON.stringify(e)),t.setItem(NB,String(Date.now()+60*BB.getInstance().configTimeToLive*60*1e3)))}(e),()=>{}))}const JB="Could not fetch config, will use default configs";function XB(e){if(!e)return e;const t=BB.getInstance();var n=e.entries||{};return void 0!==n.fpr_enabled?t.loggingEnabled="true"===String(n.fpr_enabled):t.loggingEnabled=GB.loggingEnabled,n.fpr_log_source&&(t.logSource=Number(n.fpr_log_source)),n.fpr_log_endpoint_url&&(t.logEndPointUrl=n.fpr_log_endpoint_url),n.fpr_log_transport_key&&(t.transportKey=n.fpr_log_transport_key),void 0!==n.fpr_vc_network_request_sampling_rate&&(t.networkRequestsSamplingRate=Number(n.fpr_vc_network_request_sampling_rate)),void 0!==n.fpr_vc_trace_sampling_rate&&(t.tracesSamplingRate=Number(n.fpr_vc_trace_sampling_rate)),t.logTraceAfterSampling=ZB(t.tracesSamplingRate),t.logNetworkAfterSampling=ZB(t.networkRequestsSamplingRate),e}function ZB(e){return Math.random()<=e}let eW=1,tW;function nW(e){var t;return eW=2,tW=tW||(t=e,function(){const n=UB.getInstance().document;return new Promise(e=>{if(n&&"complete"!==n.readyState){const t=()=>{"complete"===n.readyState&&(n.removeEventListener("readystatechange",t),e())};n.addEventListener("readystatechange",t)}else e()})}().then(()=>function(e){const t=e.getId();return t.then(e=>{jB=e}),t}(t.installations)).then(e=>YB(t,e)).then(()=>rW(),()=>rW())),tW}function rW(){eW=3}const iW=1e4,sW=3,oW=1e3;let aW=sW,cW=[],lW=!1;function uW(e){setTimeout(()=>{if(0!==aW)return cW.length?void function(){const e=cW.splice(0,oW),t=e.map(e=>({source_extension_json_proto3:e.message,event_time_ms:String(e.eventTime)})),n={request_time_ms:String(Date.now()),client_info:{client_type:1,js_client_info:{}},log_source:BB.getInstance().logSource,log_event:t};!function(e,r){return function(e){var t=BB.getInstance().getFlTransportFullUrl();return fetch(t,{method:"POST",body:JSON.stringify(e)})}(e).then(e=>(e.ok||MB.info("Call to Firebase backend failed."),e.json())).then(e=>{var t=Number(e.nextRequestWaitMillis);let n=iW;isNaN(t)||(n=Math.max(t,n));t=e.logResponseDetails;Array.isArray(t)&&0<t.length&&"RETRY_REQUEST_LATER"===t[0].responseAction&&(cW=[...r,...cW],MB.info("Retry transport request later.")),aW=sW,uW(n)})}(n,e).catch(()=>{cW=[...e,...cW],aW--,MB.info(`Tries left: ${aW}.`),uW(iW)})}():uW(iW)},e)}function hW(t){return(...e)=>{!function(e){if(!e.eventTime||!e.message)throw OB.create("invalid cc log");cW=[...cW,e]}({message:t(...e),eventTime:Date.now()})}}let dW;function pW(e,t){dW=dW||hW(mW),dW(e,t)}function fW(e){var t=BB.getInstance();!t.instrumentationEnabled&&e.isAuto||(t.dataCollectionEnabled||e.isAuto)&&UB.getInstance().requiredApisAvailable()&&(e.isAuto&&KB()!==RB.VISIBLE||(3===eW?gW(e):nW(e.performanceController).then(()=>gW(e),()=>gW(e))))}function gW(e){var t;!jB||(t=BB.getInstance()).loggingEnabled&&t.logTraceAfterSampling&&setTimeout(()=>pW(e,1),0)}function mW(e,t){return 0===t?(n={url:e.url,http_method:e.httpMethod||0,http_response_code:200,response_payload_bytes:e.responsePayloadBytes,client_start_time_us:e.startTimeUs,time_to_response_initiated_us:e.timeToResponseInitiatedUs,time_to_response_completed_us:e.timeToResponseCompletedUs},n={application_info:vW(e.performanceController.app),network_request_metric:n},JSON.stringify(n)):function(e){const t={name:e.name,is_auto:e.isAuto,client_start_time_us:e.startTimeUs,duration_us:e.durationUs};0!==Object.keys(e.counters).length&&(t.counters=e.counters);var n=e.getAttributes();0!==Object.keys(n).length&&(t.custom_attributes=n);n={application_info:vW(e.performanceController.app),trace_metric:t};return JSON.stringify(n)}(e);var n}function vW(e){return{google_app_id:zB(e),app_instance_id:jB,web_app_info:{sdk_version:SB,page_url:UB.getInstance().getUrl(),service_worker_status:"serviceWorker"in(t=UB.getInstance().navigator)?t.serviceWorker.controller?2:3:1,visibility_state:KB(),effective_connection_type:function(){var e=UB.getInstance().navigator.connection;switch(e&&e.effectiveType){case"slow-2g":return 1;case"2g":return 2;case"3g":return 3;case"4g":return 4;default:return 0}}()},application_process_state:0};var t}const yW=["_fp","_fcp","_fid"];class _W{constructor(e,t,n=!1,r){this.performanceController=e,this.name=t,this.isAuto=n,this.state=1,this.customAttributes={},this.counters={},this.api=UB.getInstance(),this.randomId=Math.floor(1e6*Math.random()),this.isAuto||(this.traceStartMark=`FB-PERF-TRACE-START-${this.randomId}-${this.name}`,this.traceStopMark=`FB-PERF-TRACE-STOP-${this.randomId}-${this.name}`,this.traceMeasure=r||`${CB}-${this.randomId}-${this.name}`,r&&this.calculateTraceMetrics())}start(){if(1!==this.state)throw OB.create("trace started",{traceName:this.name});this.api.mark(this.traceStartMark),this.state=2}stop(){if(2!==this.state)throw OB.create("trace stopped",{traceName:this.name});this.state=3,this.api.mark(this.traceStopMark),this.api.measure(this.traceMeasure,this.traceStartMark,this.traceStopMark),this.calculateTraceMetrics(),fW(this)}record(e,t,n){if(e<=0)throw OB.create("nonpositive trace startTime",{traceName:this.name});if(t<=0)throw OB.create("nonpositive trace duration",{traceName:this.name});if(this.durationUs=Math.floor(1e3*t),this.startTimeUs=Math.floor(1e3*e),n&&n.attributes&&(this.customAttributes=Object.assign({},n.attributes)),n&&n.metrics)for(const r of Object.keys(n.metrics))isNaN(Number(n.metrics[r]))||(this.counters[r]=Number(Math.floor(n.metrics[r])));fW(this)}incrementMetric(e,t=1){void 0===this.counters[e]?this.putMetric(e,t):this.putMetric(e,this.counters[e]+t)}putMetric(e,t){if(r=e,i=this.name,0===r.length||100<r.length||!(i&&i.startsWith("_wt_")&&-1<yW.indexOf(r))&&r.startsWith("_"))throw OB.create("invalid custom metric name",{customMetricName:e});var n,r,i;this.counters[e]=(t=t,(n=Math.floor(t))<t&&MB.info(`Metric value should be an Integer, setting the value as : ${n}.`),n)}getMetric(e){return this.counters[e]||0}putAttribute(e,t){var n,r,i=!(0===(n=e).length||40<n.length)&&(!WB.some(e=>n.startsWith(e))&&!!n.match($B)),s=0!==(r=t).length&&r.length<=100;if(i&&s)this.customAttributes[e]=t;else{if(!i)throw OB.create("invalid attribute name",{attributeName:e});if(!s)throw OB.create("invalid attribute value",{attributeValue:t})}}getAttribute(e){return this.customAttributes[e]}removeAttribute(e){void 0!==this.customAttributes[e]&&delete this.customAttributes[e]}getAttributes(){return Object.assign({},this.customAttributes)}setStartTime(e){this.startTimeUs=e}setDuration(e){this.durationUs=e}calculateTraceMetrics(){var e=this.api.getEntriesByName(this.traceMeasure),e=e&&e[0];e&&(this.durationUs=Math.floor(1e3*e.duration),this.startTimeUs=Math.floor(1e3*(e.startTime+this.api.getTimeOrigin())))}static createOobTrace(e,t,n,r){var i=UB.getInstance().getUrl();if(i){const s=new _W(e,"_wt_"+i,!0);i=Math.floor(1e3*UB.getInstance().getTimeOrigin());s.setStartTime(i),t&&t[0]&&(s.setDuration(Math.floor(1e3*t[0].duration)),s.putMetric("domInteractive",Math.floor(1e3*t[0].domInteractive)),s.putMetric("domContentLoadedEventEnd",Math.floor(1e3*t[0].domContentLoadedEventEnd)),s.putMetric("loadEventEnd",Math.floor(1e3*t[0].loadEventEnd)));n&&((i=n.find(e=>"first-paint"===e.name))&&i.startTime&&s.putMetric("_fp",Math.floor(1e3*i.startTime)),(i=n.find(e=>"first-contentful-paint"===e.name))&&i.startTime&&s.putMetric("_fcp",Math.floor(1e3*i.startTime)),r&&s.putMetric("_fid",Math.floor(1e3*r))),fW(s)}}static createUserTimingTrace(e,t){fW(new _W(e,t,!1,t))}}function wW(e,t){const n=t;var r,i,s;n&&void 0!==n.responseStart&&(s=UB.getInstance().getTimeOrigin(),r=Math.floor(1e3*(n.startTime+s)),i=n.responseStart?Math.floor(1e3*(n.responseStart-n.startTime)):void 0,s=Math.floor(1e3*(n.responseEnd-n.startTime)),function(e){const t=BB.getInstance();var n,r,i;t.instrumentationEnabled&&(n=e.url,r=t.logEndPointUrl.split("?")[0],i=t.flTransportEndpointUrl.split("?")[0],n!==r&&n!==i&&t.loggingEnabled&&t.logNetworkAfterSampling&&setTimeout(()=>pW(e,0),0))}({performanceController:e,url:n.name&&n.name.split("?")[0],responsePayloadBytes:n.transferSize,startTimeUs:r,timeToResponseInitiatedUs:i,timeToResponseCompletedUs:s}))}const bW=5e3;function IW(e){jB&&(setTimeout(()=>function(n){const e=UB.getInstance(),r=e.getEntriesByType("navigation"),i=e.getEntriesByType("paint");if(e.onFirstInputDelay){let t=setTimeout(()=>{_W.createOobTrace(n,r,i),t=void 0},bW);e.onFirstInputDelay(e=>{t&&(clearTimeout(t),_W.createOobTrace(n,r,i,e))})}else _W.createOobTrace(n,r,i)}(e),0),setTimeout(()=>function(t){const e=UB.getInstance(),n=e.getEntriesByType("resource");for(const r of n)wW(t,r);e.setupObserver("resource",e=>wW(t,e))}(e),0),setTimeout(()=>function(t){const e=UB.getInstance(),n=e.getEntriesByType("measure");for(const r of n)TW(t,r);e.setupObserver("measure",e=>TW(t,e))}(e),0))}function TW(e,t){const n=t.name;n.substring(0,CB.length)!==CB&&_W.createUserTimingTrace(e,n)}class EW{constructor(e,t){this.app=e,this.installations=t,this.initialized=!1}_init(e){this.initialized||(void 0!==(null==e?void 0:e.dataCollectionEnabled)&&(this.dataCollectionEnabled=e.dataCollectionEnabled),void 0!==(null==e?void 0:e.instrumentationEnabled)&&(this.instrumentationEnabled=e.instrumentationEnabled),UB.getInstance().requiredApisAvailable()?pd().then(e=>{e&&(lW||(uW(5500),lW=!0),nW(this).then(()=>IW(this),()=>IW(this)),this.initialized=!0)}).catch(e=>{MB.info(`Environment doesn't support IndexedDB: ${e}`)}):MB.info('Firebase Performance cannot start if the browser does not support "Fetch" and "Promise", or cookies are disabled.'))}set instrumentationEnabled(e){BB.getInstance().instrumentationEnabled=e}get instrumentationEnabled(){return BB.getInstance().instrumentationEnabled}set dataCollectionEnabled(e){BB.getInstance().dataCollectionEnabled=e}get dataCollectionEnabled(){return BB.getInstance().dataCollectionEnabled}}const kW="[DEFAULT]";const SW=(e,{options:t})=>{var n=e.getProvider("app").getImmediate(),r=e.getProvider("installations-internal").getImmediate();if(n.name!==kW)throw OB.create("FB not default");if("undefined"==typeof window)throw OB.create("no window");e=window,FB=e;const i=new EW(n,r);return i._init(t),i};hp(new Kd("performance",SW,"PUBLIC")),_p(kB,"0.5.5"),_p(kB,"0.5.5","esm2017");class CW{constructor(e,t){this.app=e,this._delegate=t}get instrumentationEnabled(){return this._delegate.instrumentationEnabled}set instrumentationEnabled(e){this._delegate.instrumentationEnabled=e}get dataCollectionEnabled(){return this._delegate.dataCollectionEnabled}set dataCollectionEnabled(e){this._delegate.dataCollectionEnabled=e}trace(e){return t=this._delegate,e=e,t=$d(t),new _W(t,e);var t}}function AW(e){var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("performance").getImmediate();return new CW(t,n)}(PB=Cp).INTERNAL.registerComponent(new Kd("performance-compat",AW,"PUBLIC")),PB.registerVersion("@firebase/performance-compat","0.1.5");const NW="@firebase/remote-config";class RW{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}const PW=new md("remoteconfig","Remote Config",{"registration-window":"Undefined window object. This SDK only supports usage in a browser environment.","registration-project-id":"Undefined project identifier. Check Firebase app initialization.","registration-api-key":"Undefined API key. Check Firebase app initialization.","registration-app-id":"Undefined app identifier. Check Firebase app initialization.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","storage-delete":"Error thrown when deleting from storage. Original error: {$originalErrorMessage}.","fetch-client-network":"Fetch client failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-timeout":'The config fetch request timed out. Configure timeout using "fetchTimeoutMillis" SDK setting.',"fetch-throttle":'The config fetch request timed out while in an exponential backoff state. Configure timeout using "fetchTimeoutMillis" SDK setting. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',"fetch-client-parse":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","indexed-db-unavailable":"Indexed DB is not supported by current browser"});const xW=["1","true","t","yes","y","on"];class DW{constructor(e,t=""){this._source=e,this._value=t}asString(){return this._value}asBoolean(){return"static"!==this._source&&0<=xW.indexOf(this._value.toLowerCase())}asNumber(){if("static"===this._source)return 0;let e=Number(this._value);return isNaN(e)&&(e=0),e}getSource(){return this._source}}async function OW(e){const t=$d(e);var[n,r]=await Promise.all([t._storage.getLastSuccessfulFetchResponse(),t._storage.getActiveConfigEtag()]);return!!(n&&n.config&&n.eTag&&n.eTag!==r)&&(await Promise.all([t._storageCache.setActiveConfig(n.config),t._storage.setActiveConfigEtag(n.eTag)]),!0)}function MW(e){const t=$d(e);return t._initializePromise||(t._initializePromise=t._storageCache.loadFromStorage().then(()=>{t._isInitializationComplete=!0})),t._initializePromise}async function LW(t){const n=$d(t),e=new RW;setTimeout(async()=>{e.abort()},n.settings.fetchTimeoutMillis);try{await n._client.fetch({cacheMaxAgeMillis:n.settings.minimumFetchIntervalMillis,signal:e}),await n._storageCache.setLastFetchStatus("success")}catch(e){var r=(i="fetch-throttle",(t=e)instanceof gd&&-1!==t.code.indexOf(i)?"throttle":"failure");throw await n._storageCache.setLastFetchStatus(r),e}var i}function FW(n){const e=$d(n);return[t={},r={}]=[e._storageCache.getActiveConfig(),e.defaultConfig],Object.keys(Object.assign(Object.assign({},t),r)).reduce((e,t)=>(e[t]=UW(n,t),e),{});var t,r}function UW(e,t){const n=$d(e);n._isInitializationComplete||n._logger.debug(`A value was requested for key "${t}" before SDK initialization completed.`+" Await on ensureInitialized if the intent was to get a previously activated value.");var r=n._storageCache.getActiveConfig();return r&&void 0!==r[t]?new DW("remote",r[t]):n.defaultConfig&&void 0!==n.defaultConfig[t]?new DW("default",String(n.defaultConfig[t])):(n._logger.debug(`Returning static value for key "${t}".`+" Define a default or remote value if this is unintentional."),new DW("static"))}class jW{constructor(e,t,n,r){this.client=e,this.storage=t,this.storageCache=n,this.logger=r}isCachedDataFresh(e,t){if(!t)return this.logger.debug("Config fetch cache check. Cache unpopulated."),!1;var n=Date.now()-t,r=n<=e;return this.logger.debug("Config fetch cache check."+` Cache age millis: ${n}.`+` Cache max age millis (minimumFetchIntervalMillis setting): ${e}.`+` Is cache hit: ${r}.`),r}async fetch(e){var[t,n]=await Promise.all([this.storage.getLastSuccessfulFetchTimestampMillis(),this.storage.getLastSuccessfulFetchResponse()]);if(n&&this.isCachedDataFresh(e.cacheMaxAgeMillis,t))return n;e.eTag=n&&n.eTag;n=await this.client.fetch(e);const r=[this.storageCache.setLastSuccessfulFetchTimestampMillis(Date.now())];return 200===n.status&&r.push(this.storage.setLastSuccessfulFetchResponse(n)),await Promise.all(r),n}}class qW{constructor(e,t,n,r,i,s){this.firebaseInstallations=e,this.sdkVersion=t,this.namespace=n,this.projectId=r,this.apiKey=i,this.appId=s}async fetch(n){var e,[t,r]=await Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken()]),i=`${window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfig.googleapis.com"}/v1/projects/${this.projectId}/namespaces/${this.namespace}:fetch?key=${this.apiKey}`,s={"Content-Type":"application/json","Content-Encoding":"gzip","If-None-Match":n.eTag||"*"},r={sdk_version:this.sdkVersion,app_instance_id:t,app_instance_id_token:r,app_id:this.appId,language_code:(e=navigator).languages&&e.languages[0]||e.language},r={method:"POST",headers:s,body:JSON.stringify(r)},i=fetch(i,r),r=new Promise((e,t)=>{n.signal.addEventListener(()=>{const e=new Error("The operation was aborted.");e.name="AbortError",t(e)})});let o;try{await Promise.race([i,r]),o=await i}catch(e){let t="fetch-client-network";throw"AbortError"===e.name&&(t="fetch-timeout"),PW.create(t,{originalErrorMessage:e.message})}let a=o.status;i=o.headers.get("ETag")||void 0;let c,l;if(200===o.status){let e;try{e=await o.json()}catch(e){throw PW.create("fetch-client-parse",{originalErrorMessage:e.message})}c=e.entries,l=e.state}if("INSTANCE_STATE_UNSPECIFIED"===l?a=500:"NO_CHANGE"===l?a=304:"NO_TEMPLATE"!==l&&"EMPTY_CONFIG"!==l||(c={}),304!==a&&200!==a)throw PW.create("fetch-status",{httpStatus:a});return{status:a,eTag:i,config:c}}}class VW{constructor(e,t){this.client=e,this.storage=t}async fetch(e){var t=await this.storage.getThrottleMetadata()||{backoffCount:0,throttleEndTimeMillis:Date.now()};return this.attemptFetch(e,t)}async attemptFetch(t,{throttleEndTimeMillis:e,backoffCount:n}){var i,s;i=t.signal,s=e,await new Promise((e,t)=>{var n=Math.max(s-Date.now(),0);const r=setTimeout(e,n);i.addEventListener(()=>{clearTimeout(r),t(PW.create("fetch-throttle",{throttleEndTimeMillis:s}))})});try{var r=await this.client.fetch(t);return await this.storage.deleteThrottleMetadata(),r}catch(e){if(!function(e){if(e instanceof gd&&e.customData){var t=Number(e.customData.httpStatus);return 429===t||500===t||503===t||504===t}}(e))throw e;r={throttleEndTimeMillis:Date.now()+Wd(n),backoffCount:n+1};return await this.storage.setThrottleMetadata(r),this.attemptFetch(t,r)}}}class BW{constructor(e,t,n,r,i){this.app=e,this._client=t,this._storageCache=n,this._storage=r,this._logger=i,this._isInitializationComplete=!1,this.settings={fetchTimeoutMillis:6e4,minimumFetchIntervalMillis:432e5},this.defaultConfig={}}get fetchTimeMillis(){return this._storageCache.getLastSuccessfulFetchTimestampMillis()||-1}get lastFetchStatus(){return this._storageCache.getLastFetchStatus()||"no-fetch-yet"}}function WW(e,t){var n=e.target.error||void 0;return PW.create(t,{originalErrorMessage:n&&n.message})}const $W="app_namespace_store";class KW{constructor(e,t,n,r=function(){return new Promise((t,n)=>{try{const e=indexedDB.open("firebase_remote_config",1);e.onerror=e=>{n(WW(e,"storage-open"))},e.onsuccess=e=>{t(e.target.result)},e.onupgradeneeded=e=>{const t=e.target.result;0===e.oldVersion&&t.createObjectStore($W,{keyPath:"compositeKey"})}}catch(e){n(PW.create("storage-open",{originalErrorMessage:e}))}})}()){this.appId=e,this.appName=t,this.namespace=n,this.openDbPromise=r}getLastFetchStatus(){return this.get("last_fetch_status")}setLastFetchStatus(e){return this.set("last_fetch_status",e)}getLastSuccessfulFetchTimestampMillis(){return this.get("last_successful_fetch_timestamp_millis")}setLastSuccessfulFetchTimestampMillis(e){return this.set("last_successful_fetch_timestamp_millis",e)}getLastSuccessfulFetchResponse(){return this.get("last_successful_fetch_response")}setLastSuccessfulFetchResponse(e){return this.set("last_successful_fetch_response",e)}getActiveConfig(){return this.get("active_config")}setActiveConfig(e){return this.set("active_config",e)}getActiveConfigEtag(){return this.get("active_config_etag")}setActiveConfigEtag(e){return this.set("active_config_etag",e)}getThrottleMetadata(){return this.get("throttle_metadata")}setThrottleMetadata(e){return this.set("throttle_metadata",e)}deleteThrottleMetadata(){return this.delete("throttle_metadata")}async get(o){const a=await this.openDbPromise;return new Promise((n,t)=>{const e=a.transaction([$W],"readonly"),r=e.objectStore($W);var i=this.createCompositeKey(o);try{const s=r.get(i);s.onerror=e=>{t(WW(e,"storage-get"))},s.onsuccess=e=>{var t=e.target.result;n(t?t.value:void 0)}}catch(e){t(PW.create("storage-get",{originalErrorMessage:e&&e.message}))}})}async set(o,a){const c=await this.openDbPromise;return new Promise((e,t)=>{const n=c.transaction([$W],"readwrite"),r=n.objectStore($W);var i=this.createCompositeKey(o);try{const s=r.put({compositeKey:i,value:a});s.onerror=e=>{t(WW(e,"storage-set"))},s.onsuccess=()=>{e()}}catch(e){t(PW.create("storage-set",{originalErrorMessage:e&&e.message}))}})}async delete(o){const a=await this.openDbPromise;return new Promise((e,t)=>{const n=a.transaction([$W],"readwrite"),r=n.objectStore($W);var i=this.createCompositeKey(o);try{const s=r.delete(i);s.onerror=e=>{t(WW(e,"storage-delete"))},s.onsuccess=()=>{e()}}catch(e){t(PW.create("storage-delete",{originalErrorMessage:e&&e.message}))}})}createCompositeKey(e){return[this.appId,this.appName,this.namespace,e].join()}}class zW{constructor(e){this.storage=e}getLastFetchStatus(){return this.lastFetchStatus}getLastSuccessfulFetchTimestampMillis(){return this.lastSuccessfulFetchTimestampMillis}getActiveConfig(){return this.activeConfig}async loadFromStorage(){var e=this.storage.getLastFetchStatus(),t=this.storage.getLastSuccessfulFetchTimestampMillis(),n=this.storage.getActiveConfig(),e=await e;e&&(this.lastFetchStatus=e);t=await t;t&&(this.lastSuccessfulFetchTimestampMillis=t);n=await n;n&&(this.activeConfig=n)}setLastFetchStatus(e){return this.lastFetchStatus=e,this.storage.setLastFetchStatus(e)}setLastSuccessfulFetchTimestampMillis(e){return this.lastSuccessfulFetchTimestampMillis=e,this.storage.setLastSuccessfulFetchTimestampMillis(e)}setActiveConfig(e){return this.activeConfig=e,this.storage.setActiveConfig(e)}}async function HW(){if(!dd())return!1;try{return await pd()}catch(e){return!1}}hp(new Kd("remote-config",function(e,{instanceIdentifier:t}){var n=e.getProvider("app").getImmediate(),r=e.getProvider("installations-internal").getImmediate();if("undefined"==typeof window)throw PW.create("registration-window");if(!dd())throw PW.create("indexed-db-unavailable");var{projectId:i,apiKey:s,appId:o}=n.options;if(!i)throw PW.create("registration-project-id");if(!s)throw PW.create("registration-api-key");if(!o)throw PW.create("registration-app-id");t=t||"firebase";const a=new KW(o,n.name,t),c=new zW(a),l=new ep(NW);l.logLevel=$h.ERROR;o=new qW(r,gp,t,i,s,o),o=new VW(o,a),o=new jW(o,a,c,l),o=new BW(n,o,c,a,l);return MW(o),o},"PUBLIC").setMultipleInstances(!0)),_p(NW,"0.3.4"),_p(NW,"0.3.4","esm2017");class GW{constructor(e,t){this.app=e,this._delegate=t}get defaultConfig(){return this._delegate.defaultConfig}set defaultConfig(e){this._delegate.defaultConfig=e}get fetchTimeMillis(){return this._delegate.fetchTimeMillis}get lastFetchStatus(){return this._delegate.lastFetchStatus}get settings(){return this._delegate.settings}set settings(e){this._delegate.settings=e}activate(){return OW(this._delegate)}ensureInitialized(){return MW(this._delegate)}fetch(){return LW(this._delegate)}fetchAndActivate(){return async function(e){return await LW(e=$d(e)),OW(e)}(this._delegate)}getAll(){return FW(this._delegate)}getBoolean(e){return UW($d(this._delegate),e).asBoolean()}getNumber(e){return UW($d(this._delegate),e).asNumber()}getString(e){return UW($d(this._delegate),e).asString()}getValue(e){return UW(this._delegate,e)}setLogLevel(e){!function(e,t){const n=$d(e);switch(t){case"debug":n._logger.logLevel=$h.DEBUG;break;case"silent":n._logger.logLevel=$h.SILENT;break;default:n._logger.logLevel=$h.ERROR}}(this._delegate,e)}}function QW(e,{instanceIdentifier:t}){var n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("remote-config").getImmediate({identifier:t});return new GW(n,r)}return(xB=Cp).INTERNAL.registerComponent(new Kd("remoteConfig-compat",QW,"PUBLIC").setMultipleInstances(!0).setServiceProps({isSupported:HW})),xB.registerVersion("@firebase/remote-config-compat","0.1.5"),console.warn("\nIt looks like you're using the development build of the Firebase JS SDK.\nWhen deploying Firebase apps to production, it is advisable to only import\nthe individual SDK components you intend to use.\n\nFor the CDN builds, these are available in the following manner\n(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):\n\nhttps://www.gstatic.com/firebasejs/5.0.0/firebase-<PACKAGE>.js\n"),Cp.registerVersion("firebase","9.6.3","compat-cdn"),Cp});
|
|
10
10
|
//# sourceMappingURL=firebase-compat.js.map
|