firebase 9.6.2-canary.044a8d7f9 → 9.6.2-canary.88d43ec00

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/app/dist/index.cjs.js +1 -1
  2. package/app/dist/index.esm.js +1 -1
  3. package/app/dist/index.mjs +1 -1
  4. package/compat/app/dist/index.cjs.js +1 -1
  5. package/compat/app/dist/index.esm.js +1 -1
  6. package/compat/app/dist/index.mjs +1 -1
  7. package/compat/dist/index.esm.js +2 -2
  8. package/compat/dist/index.node.cjs +2 -2
  9. package/compat/dist/index.rn.cjs.js +2 -2
  10. package/firebase-analytics-compat.js +1 -1
  11. package/firebase-analytics.js +5 -5
  12. package/firebase-app-check-compat.js +1 -1
  13. package/firebase-app-check.js +5 -5
  14. package/firebase-app-compat.js +2 -2
  15. package/firebase-app.js +9 -9
  16. package/firebase-auth-compat.js +1 -1
  17. package/firebase-auth.js +3 -3
  18. package/firebase-compat.js +4 -4
  19. package/firebase-compat.js.map +1 -1
  20. package/firebase-database-compat.js +1 -1
  21. package/firebase-database.js +5 -5
  22. package/firebase-firestore-compat.js +1 -1
  23. package/firebase-firestore-compat.js.map +1 -1
  24. package/firebase-firestore-lite.js +129 -129
  25. package/firebase-firestore-lite.js.map +1 -1
  26. package/firebase-firestore.js +874 -874
  27. package/firebase-firestore.js.map +1 -1
  28. package/firebase-functions-compat.js +1 -1
  29. package/firebase-functions.js +3 -3
  30. package/firebase-messaging-compat.js +1 -1
  31. package/firebase-messaging-compat.js.map +1 -1
  32. package/firebase-messaging-sw.js +5 -5
  33. package/firebase-messaging-sw.js.map +1 -1
  34. package/firebase-messaging.js +4 -4
  35. package/firebase-messaging.js.map +1 -1
  36. package/firebase-performance-compat.js +1 -1
  37. package/firebase-performance-standalone-compat.es2017.js +7 -7
  38. package/firebase-performance-standalone-compat.js +1 -1
  39. package/firebase-performance.js +5 -5
  40. package/firebase-remote-config-compat.js +1 -1
  41. package/firebase-remote-config.js +4 -4
  42. package/firebase-storage-compat.js +1 -1
  43. package/firebase-storage.js +2 -2
  44. package/package.json +26 -26
@@ -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(yb){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(yb){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(yb){}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="0.7.12-canary.044a8d7f9",ip=new ep("@firebase/app");var sp;const op="[DEFAULT]",ap={"@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"},cp=new Map,lp=new Map;function up(t,n){try{t.container.addComponent(n)}catch(e){ip.debug(`Component ${n.name} failed to register with FirebaseApp ${t.name}`,e)}}function hp(e,t){e.container.addOrOverwriteComponent(t)}function dp(e){var t=e.name;if(lp.has(t))return ip.debug(`There were multiple attempts to register component ${t}.`),!1;lp.set(t,e);for(const n of cp.values())up(n,e);return!0}function pp(e,t){return e.container.getProvider(t)}const fp=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 gp{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 fp.create("app-deleted",{appName:this._name})}}const mp="9.6.2-canary.044a8d7f9";function vp(e,t={}){if("object"!=typeof t){const r=t;t={name:r}}var n=Object.assign({name:op,automaticDataCollectionEnabled:!1},t);const r=n.name;if("string"!=typeof r||!r)throw fp.create("bad-app-name",{appName:String(r)});var i=cp.get(r);if(i){if(kd(e,i.options)&&kd(n,i.config))return i;throw fp.create("duplicate-app",{appName:r})}const s=new Gd(r);for(const o of lp.values())s.addComponent(o);n=new gp(e,n,s);return cp.set(r,n),n}function yp(e=op){var t=cp.get(e);if(!t)throw fp.create("no-app",{appName:e});return t}async function _p(e){var t=e.name;cp.has(t)&&(cp.delete(t),await Promise.all(e.container.getProviders().map(e=>e.delete())),e.isDeleted=!0)}function wp(e,t,n){let r=null!==(s=ap[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 ip.warn(o.join(" "))}dp(new $d(`${r}-version`,()=>({library:r,version:t}),"VERSION"))}function bp(e,t){if(null!==e&&"function"!=typeof e)throw fp.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 Tp(e){var t;t=e,Qd.forEach(e=>{e.setLogLevel(t)})}sp="",dp(new $d("platform-logger",e=>new tp(e),"PRIVATE")),wp(np,rp,sp),wp(np,rp,"esm2017"),wp("fire-js","");var Ip=Object.freeze({__proto__:null,SDK_VERSION:mp,_DEFAULT_ENTRY_NAME:op,_addComponent:up,_addOrOverwriteComponent:hp,_apps:cp,_clearComponents:function(){lp.clear()},_components:lp,_getProvider:pp,_registerComponent:dp,_removeServiceInstance:function(e,t,n=op){pp(e,t).clearInstance(n)},deleteApp:_p,getApp:yp,getApps:function(){return Array.from(cp.values())},initializeApp:vp,onLog:bp,registerVersion:wp,setLogLevel:Tp,FirebaseError:gd});class Ep{constructor(e,t){this._delegate=e,this.firebase=t,up(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),_p(this._delegate)))}_getService(e,t=op){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=op){this._delegate.container.getProvider(e).clearInstance(t)}_addComponent(e){up(this._delegate,e)}_addOrOverwriteComponent(e){hp(this._delegate,e)}toJSON(){return{name:this.name,automaticDataCollectionEnabled:this.automaticDataCollectionEnabled,options:this.options}}}const kp=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 Sp(i){const s={},o={__esModule:!0,initializeApp:function(e,t={}){var n=vp(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:wp,setLogLevel:Tp,onLog:bp,apps:null,SDK_VERSION:mp,INTERNAL:{registerComponent:function(n){const r=n.name,t=r.replace("-compat","");{var e;dp(n)&&"PUBLIC"===n.type&&(e=(e=a())=>{if("function"!=typeof e[t])throw kp.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||op,!bd(s,e))throw kp.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=Sp(Ep);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 Cp=new ep("@firebase/app-compat");if("object"==typeof self&&self.self===self&&void 0!==self.firebase){Cp.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(yb){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(yb){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(yb){}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="0.7.12-canary.88d43ec00",ip=new ep("@firebase/app");var sp;const op="[DEFAULT]",ap={"@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"},cp=new Map,lp=new Map;function up(t,n){try{t.container.addComponent(n)}catch(e){ip.debug(`Component ${n.name} failed to register with FirebaseApp ${t.name}`,e)}}function hp(e,t){e.container.addOrOverwriteComponent(t)}function dp(e){var t=e.name;if(lp.has(t))return ip.debug(`There were multiple attempts to register component ${t}.`),!1;lp.set(t,e);for(const n of cp.values())up(n,e);return!0}function pp(e,t){return e.container.getProvider(t)}const fp=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 gp{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 fp.create("app-deleted",{appName:this._name})}}const mp="9.6.2-canary.88d43ec00";function vp(e,t={}){if("object"!=typeof t){const r=t;t={name:r}}var n=Object.assign({name:op,automaticDataCollectionEnabled:!1},t);const r=n.name;if("string"!=typeof r||!r)throw fp.create("bad-app-name",{appName:String(r)});var i=cp.get(r);if(i){if(kd(e,i.options)&&kd(n,i.config))return i;throw fp.create("duplicate-app",{appName:r})}const s=new Gd(r);for(const o of lp.values())s.addComponent(o);n=new gp(e,n,s);return cp.set(r,n),n}function yp(e=op){var t=cp.get(e);if(!t)throw fp.create("no-app",{appName:e});return t}async function _p(e){var t=e.name;cp.has(t)&&(cp.delete(t),await Promise.all(e.container.getProviders().map(e=>e.delete())),e.isDeleted=!0)}function wp(e,t,n){let r=null!==(s=ap[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 ip.warn(o.join(" "))}dp(new Kd(`${r}-version`,()=>({library:r,version:t}),"VERSION"))}function bp(e,t){if(null!==e&&"function"!=typeof e)throw fp.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 Ip(e){var t;t=e,Qd.forEach(e=>{e.setLogLevel(t)})}sp="",dp(new Kd("platform-logger",e=>new tp(e),"PRIVATE")),wp(np,rp,sp),wp(np,rp,"esm2017"),wp("fire-js","");var Tp=Object.freeze({__proto__:null,SDK_VERSION:mp,_DEFAULT_ENTRY_NAME:op,_addComponent:up,_addOrOverwriteComponent:hp,_apps:cp,_clearComponents:function(){lp.clear()},_components:lp,_getProvider:pp,_registerComponent:dp,_removeServiceInstance:function(e,t,n=op){pp(e,t).clearInstance(n)},deleteApp:_p,getApp:yp,getApps:function(){return Array.from(cp.values())},initializeApp:vp,onLog:bp,registerVersion:wp,setLogLevel:Ip,FirebaseError:gd});class Ep{constructor(e,t){this._delegate=e,this.firebase=t,up(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),_p(this._delegate)))}_getService(e,t=op){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=op){this._delegate.container.getProvider(e).clearInstance(t)}_addComponent(e){up(this._delegate,e)}_addOrOverwriteComponent(e){hp(this._delegate,e)}toJSON(){return{name:this.name,automaticDataCollectionEnabled:this.automaticDataCollectionEnabled,options:this.options}}}const kp=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 Sp(i){const s={},o={__esModule:!0,initializeApp:function(e,t={}){var n=vp(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:wp,setLogLevel:Ip,onLog:bp,apps:null,SDK_VERSION:mp,INTERNAL:{registerComponent:function(n){const r=n.name,t=r.replace("-compat","");{var e;dp(n)&&"PUBLIC"===n.type&&(e=(e=a())=>{if("function"!=typeof e[t])throw kp.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||op,!bd(s,e))throw kp.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=Sp(Ep);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 Cp=new ep("@firebase/app-compat");if("object"==typeof self&&self.self===self&&void 0!==self.firebase){Cp.warn(`
2
2
  Warning: Firebase is already defined in the global scope. Please make sure
3
3
  Firebase library is only loaded once.
4
- `);const sK=self.firebase.SDK_VERSION;sK&&0<=sK.indexOf("LITE")&&Cp.warn(`
4
+ `);const s$=self.firebase.SDK_VERSION;s$&&0<=s$.indexOf("LITE")&&Cp.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 Ap=l;wp("@firebase/app-compat","0.1.13-canary.044a8d7f9",void 0);Ap.registerVersion("firebase","9.6.2-canary.044a8d7f9","app-compat");function Np(n){return new Promise(function(e,t){n.onsuccess=function(){e(n.result)},n.onerror=function(){t(n.error)}})}function Rp(n,r,i){var s,e=new Promise(function(e,t){Np(s=n[r].apply(n,i)).then(e,t)});return e.request=s,e}function Pp(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 xp(t,n,r,e){e.forEach(function(e){e in r.prototype&&(t.prototype[e]=function(){return Rp(this[n],e,arguments)})})}function Dp(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 Op(e,r,t,n){n.forEach(function(n){n in t.prototype&&(e.prototype[n]=function(){return e=this[r],(t=Rp(e,n,arguments)).then(function(e){if(e)return new Lp(e,t.request)});var e,t})})}function Mp(e){this._index=e}function Lp(e,t){this._cursor=e,this._request=t}function Fp(e){this._store=e}function Up(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 jp(e,t,n){this._db=e,this.oldVersion=t,this.transaction=new Up(n)}function qp(e){this._db=e}function Vp(e,t,n){var r=Rp(indexedDB,"open",[e,t]),i=r.request;return i&&(i.onupgradeneeded=function(e){n&&n(new jp(i.result,e.oldVersion,i.transaction))}),r.then(function(e){return new qp(e)})}function Bp(e){return Rp(indexedDB,"deleteDatabase",[e])}Pp(Mp,"_index",["name","keyPath","multiEntry","unique"]),xp(Mp,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),Op(Mp,"_index",IDBIndex,["openCursor","openKeyCursor"]),Pp(Lp,"_cursor",["direction","key","primaryKey","value"]),xp(Lp,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach(function(n){n in IDBCursor.prototype&&(Lp.prototype[n]=function(){var t=this,e=arguments;return Promise.resolve().then(function(){return t._cursor[n].apply(t._cursor,e),Np(t._request).then(function(e){if(e)return new Lp(e,t._request)})})})}),Fp.prototype.createIndex=function(){return new Mp(this._store.createIndex.apply(this._store,arguments))},Fp.prototype.index=function(){return new Mp(this._store.index.apply(this._store,arguments))},Pp(Fp,"_store",["name","keyPath","indexNames","autoIncrement"]),xp(Fp,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),Op(Fp,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),Dp(Fp,"_store",IDBObjectStore,["deleteIndex"]),Up.prototype.objectStore=function(){return new Fp(this._tx.objectStore.apply(this._tx,arguments))},Pp(Up,"_tx",["objectStoreNames","mode"]),Dp(Up,"_tx",IDBTransaction,["abort"]),jp.prototype.createObjectStore=function(){return new Fp(this._db.createObjectStore.apply(this._db,arguments))},Pp(jp,"_db",["name","version","objectStoreNames"]),Dp(jp,"_db",IDBDatabase,["deleteObjectStore","close"]),qp.prototype.transaction=function(){return new Up(this._db.transaction.apply(this._db,arguments))},Pp(qp,"_db",["name","version","objectStoreNames"]),Dp(qp,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach(function(s){[Fp,Mp].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)}})})}),[Mp,Fp].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-canary.044a8d7f9";const Wp=1e4,Kp=`w:${c}`,$p="FIS_v2",zp="https://firebaseinstallations.googleapis.com/v1",Hp=36e5;const Gp=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 Qp(e){return e instanceof gd&&e.code.includes("request-failed")}function Yp({projectId:e}){return`${zp}/projects/${e}/installations`}function Jp(e){return{token:e.token,requestStatus:2,expiresIn:(e=e.expiresIn,Number(e.replace("s","000"))),creationTime:Date.now()}}async function Xp(e,t){var n=(await t.json()).error;return Gp.create("request-failed",{requestName:e,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})}function Zp({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function ef(e,{refreshToken:t}){const n=Zp(e);return n.append("Authorization",(t=t,`${$p} ${t}`)),n}async function tf(e){var t=await e();return 500<=t.status&&t.status<600?e():t}function nf(t){return new Promise(e=>{setTimeout(e,t)})}const rf=/^[cdef][\w-]{21}$/,sf="";function of(){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 rf.test(e)?e:sf}catch(e){return sf}}function af(e){return`${e.appName}!${e.appId}`}const cf=new Map;function lf(e,t){var n=af(e);uf(n,t),function(e,t){const n=function(){!hf&&"BroadcastChannel"in self&&(hf=new BroadcastChannel("[Firebase] FID Change"),hf.onmessage=e=>{uf(e.data.key,e.data.fid)});return hf}();n&&n.postMessage({key:e,fid:t});0===cf.size&&hf&&(hf.close(),hf=null)}(n,t)}function uf(e,t){var n=cf.get(e);if(n)for(const r of n)r(t)}let hf=null;const df="firebase-installations-store";let pf=null;function ff(){return pf=pf||Vp("firebase-installations-database",1,e=>{0===e.oldVersion&&e.createObjectStore(df)}),pf}async function gf(e,t){var n=af(e);const r=await ff(),i=r.transaction(df,"readwrite"),s=i.objectStore(df);var o=await s.get(n);return await s.put(t,n),await i.complete,o&&o.fid===t.fid||lf(e,t.fid),t}async function mf(e){var t=af(e);const n=await ff(),r=n.transaction(df,"readwrite");await r.objectStore(df).delete(t),await r.complete}async function vf(e,t){var n=af(e);const r=await ff(),i=r.transaction(df,"readwrite"),s=i.objectStore(df);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||lf(e,a.fid),a}async function yf(n){let r;var e=await vf(n,e=>{var t=wf(e||{fid:of(),registrationStatus:0}),t=function(e,t){{if(0!==t.registrationStatus)return 1===t.registrationStatus?{installationEntry:t,registrationPromise:async function(e){let t=await _f(e);for(;1===t.registrationStatus;)await nf(100),t=await _f(e);if(0!==t.registrationStatus)return t;{var{installationEntry:n,registrationPromise:r}=await yf(e);return r||n}}(e)}:{installationEntry:t};if(!navigator.onLine){var n=Promise.reject(Gp.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=Yp(e);var r=Zp(e),i={fid:t,authVersion:$p,appId:e.appId,sdkVersion:Kp};const s={method:"POST",headers:r,body:JSON.stringify(i)},o=await tf(()=>fetch(n,s));if(o.ok){i=await o.json();return{fid:i.fid||t,registrationStatus:2,refreshToken:i.refreshToken,authToken:Jp(i.authToken)}}throw await Xp("Create Installation",o)}(t,n);return gf(t,e)}catch(e){throw Qp(e)&&409===e.customData.serverCode?await mf(t):await gf(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===sf?{installationEntry:await r}:{installationEntry:e,registrationPromise:r}}function _f(e){return vf(e,e=>{if(!e)throw Gp.create("installation-not-found");return wf(e)})}function wf(e){return 1===(t=e).registrationStatus&&t.registrationTime+Wp<Date.now()?{fid:e.fid,registrationStatus:0}:e;var t}async function bf({appConfig:e,platformLoggerProvider:t},n){const r=([i,s]=[e,n["fid"]],`${Yp(i)}/${s}/authTokens:generate`);var i,s;const o=ef(e,n),a=t.getImmediate({optional:!0});a&&o.append("x-firebase-client",a.getPlatformInfoString());var c={installation:{sdkVersion:Kp}};const l={method:"POST",headers:o,body:JSON.stringify(c)},u=await tf(()=>fetch(r,l));if(u.ok)return Jp(await u.json());throw await Xp("Generate Auth Token",u)}async function Tf(r,i=!1){let s;var e=await vf(r.appConfig,e=>{if(!Ef(e))throw Gp.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+Hp}(t)){if(1===n.requestStatus)return s=async function(e,t){let n=await If(e.appConfig);for(;1===n.authToken.requestStatus;)await nf(100),n=await If(e.appConfig);var r=n.authToken;return 0===r.requestStatus?Tf(e,t):r}(r,i),e;if(!navigator.onLine)throw Gp.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 bf(t,n),e=Object.assign(Object.assign({},n),{authToken:r});return await gf(t.appConfig,e),r}catch(e){throw!Qp(e)||401!==e.customData.serverCode&&404!==e.customData.serverCode?(r=Object.assign(Object.assign({},n),{authToken:{requestStatus:0}}),await gf(t.appConfig,r)):await mf(t.appConfig),e}}(r,n),n}return e});return s?await s:e.authToken}function If(e){return vf(e,e=>{if(!Ef(e))throw Gp.create("not-registered");var t,n=e.authToken;return 1===(t=n).requestStatus&&t.requestTime+Wp<Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e})}function Ef(e){return void 0!==e&&2===e.registrationStatus}async function kf(e,t=!1){var n,r=e;return e=r.appConfig,await((n=(await yf(e)).registrationPromise)&&await n),(await Tf(r,t)).token}function Sf(e){return Gp.create("missing-app-config-values",{valueName:e})}const Cf="installations",Af=e=>{var t=e.getProvider("app").getImmediate();return{app:t,appConfig:function(e){if(!e||!e.options)throw Sf("App Configuration");if(!e.name)throw Sf("App Name");for(const t of["projectId","apiKey","appId"])if(!e.options[t])throw Sf(t);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t),platformLoggerProvider:pp(t,"platform-logger"),_delete:()=>Promise.resolve()}},Nf=e=>{const t=pp(e.getProvider("app").getImmediate(),Cf).getImmediate();return{getId:()=>async function(e){var t=e;const{installationEntry:n,registrationPromise:r}=await yf(t.appConfig);return(r||Tf(t)).catch(console.error),n.fid}(t),getToken:e=>kf(t,e)}};dp(new $d(Cf,Af,"PUBLIC")),dp(new $d("installations-internal",Nf,"PRIVATE")),wp(ze,c),wp(ze,c,"esm2017");const Rf="analytics",Pf="firebase_id",xf="origin",Df="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",Of="https://www.googletagmanager.com/gtag/js",Mf=new ep("@firebase/analytics");function Lf(e){return Promise.all(e.map(e=>e.catch(e=>e)))}function Ff(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 Lf(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){Mf.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 Lf(n);var a=c.find(e=>e.measurementId===i);a&&await t[a.appId]}}catch(e){Mf.error(e)}e("config",i,s)}(r,i,s,o,t,n):r("set",t)}catch(e){Mf.error(e)}}}const Uf=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.'}),jf=30;const qf=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 Vf(e){var t,{appId:n,apiKey:r}=e,r={method:"GET",headers:new Headers({Accept:"application/json","x-goog-api-key":r})},n=Df.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 Uf.create("config-fetch-failed",{httpStatus:i.status,responseMessage:e})}}async function Bf(e,t=qf,n){var{appId:r,apiKey:i,measurementId:s}=e.options;if(!r)throw Uf.create("no-app-id");if(!i){if(s)return{measurementId:s,appId:r};throw Uf.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=qf){const{appId:o,measurementId:a}=n;try{await Wf(i,e)}catch(e){if(a)return Mf.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 Vf(n);return s.deleteThrottleMetadata(o),c}catch(e){if(!Kf(e)){if(s.deleteThrottleMetadata(o),a)return Mf.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,jf):Wd(r,s.intervalMillis),u={throttleEndTimeMillis:Date.now()+l,backoffCount:r+1};return s.setThrottleMetadata(o,u),Mf.debug(`Calling attemptFetch again in ${l} millis`),t(n,u,i,s)}}({appId:r,apiKey:i,measurementId:s},o,a,t)}function Wf(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(Uf.create("fetch-throttle",{throttleEndTimeMillis:s}))})})}function Kf(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 zf(t,e,n,r,i,s,o){const a=Bf(t);a.then(e=>{n[e.measurementId]=e.appId,t.options.measurementId&&e.measurementId!==t.options.measurementId&&Mf.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=>Mf.error(e)),e.push(a);var c=async function(){if(!dd())return Mf.warn(Uf.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;try{await pd()}catch(e){return Mf.warn(Uf.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(Of))return t}()&&function(e,t){const n=document.createElement("script");n.src=`${Of}?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[xf]="firebase",h.update=!0,null!=u&&(h[Pf]=u),i("config",l.measurementId,h),l.measurementId}class Hf{constructor(e){this.app=e}_delete(){return delete Gf[this.app.options.appId],Promise.resolve()}}let Gf={},Qf=[];const Yf={};let Jf="dataLayer",Xf="gtag",Zf,eg,tg=!1;function ng(e){if(tg)throw Uf.create("already-initialized");e.dataLayerName&&(Jf=e.dataLayerName),e.gtagName&&(Xf=e.gtagName)}function rg(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=Uf.create("invalid-analytics-context",{errorInfo:t}),Mf.warn(t.message))}();var r,i,s=e.options.appId;if(!s)throw Uf.create("no-app-id");if(!e.options.apiKey){if(!e.options.measurementId)throw Uf.create("no-api-key");Mf.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!=Gf[s])throw Uf.create("already-exists",{id:s});return tg||(function(e){let t=[];Array.isArray(window[e])?t=window[e]:window[e]=t,t}(Jf),{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]=Ff(s,e,t,n),{gtagCore:s,wrappedGtag:window[i]}}(Gf,Qf,Yf,Jf,Xf),eg=r,Zf=i,tg=!0),Gf[s]=zf(e,Qf,Yf,t,Zf,Jf,n),new Hf(e)}async function ig(){if(cd())return!1;if(!fd())return!1;if(!dd())return!1;try{return await pd()}catch(e){return!1}}function sg(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})}(eg,Gf[e.app.options.appId],t,n).catch(e=>Mf.error(e))}function og(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})}(eg,Gf[e.app.options.appId],t,n).catch(e=>Mf.error(e))}function ag(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})}(eg,Gf[e.app.options.appId],t,n).catch(e=>Mf.error(e))}function cg(e,t){e=Kd(e),async function(e,t){var n=await e;window[`ga-disable-${n}`]=!t}(Gf[e.app.options.appId],t).catch(e=>Mf.error(e))}function lg(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})))}(eg,Gf[e.app.options.appId],t,n,r).catch(e=>Mf.error(e))}const ug="@firebase/analytics",hg="0.7.5-canary.044a8d7f9";dp(new $d(Rf,(e,{options:t})=>{return rg(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),t)},"PUBLIC")),dp(new $d("analytics-internal",function(e){try{const r=e.getProvider(Rf).getImmediate();return{logEvent:(e,t,n)=>lg(r,e,t,n)}}catch(e){throw Uf.create("interop-component-reg-failed",{reason:e})}},"PRIVATE")),wp(ug,hg),wp(ug,hg,"esm2017");var dg,pg;class fg{constructor(e,t){this.app=e,this._delegate=t}logEvent(e,t,n){lg(this._delegate,e,t,n)}setCurrentScreen(e,t){sg(this._delegate,e,t)}setUserId(e,t){og(this._delegate,e,t)}setUserProperties(e,t){ag(this._delegate,e,t)}setAnalyticsCollectionEnabled(e){cg(this._delegate,e)}}(z=dg=dg||{}).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 gg=e=>{var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("analytics").getImmediate();return new fg(t,n)};pg={Analytics:fg,settings:ng,isSupported:ig,EventName:dg},Ap.INTERNAL.registerComponent(new $d("analytics-compat",gg,"PUBLIC").setServiceProps(pg).setMultipleInstances(!0)),Ap.registerVersion("@firebase/analytics-compat","0.1.6-canary.044a8d7f9");const mg=new Map,vg={activated:!1,tokenObservers:[]},yg={initialized:!1,enabled:!1};function _g(e){return mg.get(e)||vg}function wg(e,t){mg.set(e,t)}const bg="https://content-firebaseappcheck.googleapis.com/v1beta",Tg="exchangeDebugToken",Ig={OFFSET_DURATION:3e5,RETRIAL_MIN_WAIT:3e4,RETRIAL_MAX_WAIT:96e4};class Eg{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 kg=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 Sg(e=!1){var t;return e?null===(t=self.grecaptcha)||void 0===t?void 0:t.enterprise:self.grecaptcha}function Cg(e){if(!_g(e).activated)throw kg.create("use-before-activation",{appName:e.name})}function Ag(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+=Ng(n)+"d:"),r&&(s+=Ng(r)+"h:"),s+=Ng(i)+"m:"+Ng(t)+"s",s}function Ng(e){return 0===e?"00":10<=e?e.toString():"0"+e}async function Rg({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 kg.create("fetch-network-error",{originalErrorMessage:e.message})}if(200!==o.status)throw kg.create("fetch-status-error",{httpStatus:o.status});let a;try{a=await o.json()}catch(e){throw kg.create("fetch-parse-error",{originalErrorMessage:e.message})}var c=a.ttl.match(/^([\d.]+)(s)$/);if(!c||!c[2]||isNaN(Number(c[1])))throw kg.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 Pg="firebase-app-check-database",xg=1,Dg="firebase-app-check-store",Og="debug-token";let Mg=null;function Lg(){return Mg||(Mg=new Promise((t,n)=>{try{const e=indexedDB.open(Pg,xg);e.onsuccess=e=>{t(e.target.result)},e.onerror=e=>{var t;n(kg.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(Dg,{keyPath:"compositeKey"})}}catch(e){n(kg.create("storage-open",{originalErrorMessage:e.message}))}}),Mg)}async function Fg(e,t){const n=await Lg(),r=n.transaction(Dg,"readwrite"),i=r.objectStore(Dg),s=i.put({compositeKey:e,value:t});return new Promise((t,n)=>{s.onsuccess=e=>{t()},r.onerror=e=>{var t;n(kg.create("storage-set",{originalErrorMessage:null===(t=e.target.error)||void 0===t?void 0:t.message}))}})}async function Ug(e){const t=await Lg(),i=t.transaction(Dg,"readonly"),n=i.objectStore(Dg),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(kg.create("storage-get",{originalErrorMessage:null===(t=e.target.error)||void 0===t?void 0:t.message}))}})}function jg(e){return`${e.options.appId}-${e.name}`}const qg=new ep("@firebase/app-check");async function Vg(t){if(dd()){let e=void 0;try{e=await Ug(jg(t))}catch(e){qg.warn(`Failed to read token from IndexedDB. Error: ${e}`)}return e}}function Bg(e,t){return dd()?Fg(jg(e),t).catch(e=>{qg.warn(`Failed to write token to IndexedDB. Error: ${e}`)}):Promise.resolve()}async function Wg(){let e=void 0;try{e=await Ug(Og)}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,Fg(Og,t).catch(e=>qg.warn(`Failed to persist debug token to IndexedDB. Error: ${e}`)),n}function Kg(){return yg.enabled}async function $g(){var e=yg;if(e.enabled&&e.token)return e.token.promise;throw Error(`
7
+ `)}const Ap=l;wp("@firebase/app-compat","0.1.13-canary.88d43ec00",void 0);Ap.registerVersion("firebase","9.6.2-canary.88d43ec00","app-compat");function Np(n){return new Promise(function(e,t){n.onsuccess=function(){e(n.result)},n.onerror=function(){t(n.error)}})}function Rp(n,r,i){var s,e=new Promise(function(e,t){Np(s=n[r].apply(n,i)).then(e,t)});return e.request=s,e}function Pp(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 xp(t,n,r,e){e.forEach(function(e){e in r.prototype&&(t.prototype[e]=function(){return Rp(this[n],e,arguments)})})}function Dp(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 Op(e,r,t,n){n.forEach(function(n){n in t.prototype&&(e.prototype[n]=function(){return e=this[r],(t=Rp(e,n,arguments)).then(function(e){if(e)return new Lp(e,t.request)});var e,t})})}function Mp(e){this._index=e}function Lp(e,t){this._cursor=e,this._request=t}function Fp(e){this._store=e}function Up(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 jp(e,t,n){this._db=e,this.oldVersion=t,this.transaction=new Up(n)}function qp(e){this._db=e}function Vp(e,t,n){var r=Rp(indexedDB,"open",[e,t]),i=r.request;return i&&(i.onupgradeneeded=function(e){n&&n(new jp(i.result,e.oldVersion,i.transaction))}),r.then(function(e){return new qp(e)})}function Bp(e){return Rp(indexedDB,"deleteDatabase",[e])}Pp(Mp,"_index",["name","keyPath","multiEntry","unique"]),xp(Mp,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),Op(Mp,"_index",IDBIndex,["openCursor","openKeyCursor"]),Pp(Lp,"_cursor",["direction","key","primaryKey","value"]),xp(Lp,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach(function(n){n in IDBCursor.prototype&&(Lp.prototype[n]=function(){var t=this,e=arguments;return Promise.resolve().then(function(){return t._cursor[n].apply(t._cursor,e),Np(t._request).then(function(e){if(e)return new Lp(e,t._request)})})})}),Fp.prototype.createIndex=function(){return new Mp(this._store.createIndex.apply(this._store,arguments))},Fp.prototype.index=function(){return new Mp(this._store.index.apply(this._store,arguments))},Pp(Fp,"_store",["name","keyPath","indexNames","autoIncrement"]),xp(Fp,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),Op(Fp,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),Dp(Fp,"_store",IDBObjectStore,["deleteIndex"]),Up.prototype.objectStore=function(){return new Fp(this._tx.objectStore.apply(this._tx,arguments))},Pp(Up,"_tx",["objectStoreNames","mode"]),Dp(Up,"_tx",IDBTransaction,["abort"]),jp.prototype.createObjectStore=function(){return new Fp(this._db.createObjectStore.apply(this._db,arguments))},Pp(jp,"_db",["name","version","objectStoreNames"]),Dp(jp,"_db",IDBDatabase,["deleteObjectStore","close"]),qp.prototype.transaction=function(){return new Up(this._db.transaction.apply(this._db,arguments))},Pp(qp,"_db",["name","version","objectStoreNames"]),Dp(qp,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach(function(s){[Fp,Mp].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)}})})}),[Mp,Fp].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-canary.88d43ec00";const Wp=1e4,$p=`w:${c}`,Kp="FIS_v2",zp="https://firebaseinstallations.googleapis.com/v1",Hp=36e5;const Gp=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 Qp(e){return e instanceof gd&&e.code.includes("request-failed")}function Yp({projectId:e}){return`${zp}/projects/${e}/installations`}function Jp(e){return{token:e.token,requestStatus:2,expiresIn:(e=e.expiresIn,Number(e.replace("s","000"))),creationTime:Date.now()}}async function Xp(e,t){var n=(await t.json()).error;return Gp.create("request-failed",{requestName:e,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})}function Zp({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function ef(e,{refreshToken:t}){const n=Zp(e);return n.append("Authorization",(t=t,`${Kp} ${t}`)),n}async function tf(e){var t=await e();return 500<=t.status&&t.status<600?e():t}function nf(t){return new Promise(e=>{setTimeout(e,t)})}const rf=/^[cdef][\w-]{21}$/,sf="";function of(){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 rf.test(e)?e:sf}catch(e){return sf}}function af(e){return`${e.appName}!${e.appId}`}const cf=new Map;function lf(e,t){var n=af(e);uf(n,t),function(e,t){const n=function(){!hf&&"BroadcastChannel"in self&&(hf=new BroadcastChannel("[Firebase] FID Change"),hf.onmessage=e=>{uf(e.data.key,e.data.fid)});return hf}();n&&n.postMessage({key:e,fid:t});0===cf.size&&hf&&(hf.close(),hf=null)}(n,t)}function uf(e,t){var n=cf.get(e);if(n)for(const r of n)r(t)}let hf=null;const df="firebase-installations-store";let pf=null;function ff(){return pf=pf||Vp("firebase-installations-database",1,e=>{0===e.oldVersion&&e.createObjectStore(df)}),pf}async function gf(e,t){var n=af(e);const r=await ff(),i=r.transaction(df,"readwrite"),s=i.objectStore(df);var o=await s.get(n);return await s.put(t,n),await i.complete,o&&o.fid===t.fid||lf(e,t.fid),t}async function mf(e){var t=af(e);const n=await ff(),r=n.transaction(df,"readwrite");await r.objectStore(df).delete(t),await r.complete}async function vf(e,t){var n=af(e);const r=await ff(),i=r.transaction(df,"readwrite"),s=i.objectStore(df);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||lf(e,a.fid),a}async function yf(n){let r;var e=await vf(n,e=>{var t=wf(e||{fid:of(),registrationStatus:0}),t=function(e,t){{if(0!==t.registrationStatus)return 1===t.registrationStatus?{installationEntry:t,registrationPromise:async function(e){let t=await _f(e);for(;1===t.registrationStatus;)await nf(100),t=await _f(e);if(0!==t.registrationStatus)return t;{var{installationEntry:n,registrationPromise:r}=await yf(e);return r||n}}(e)}:{installationEntry:t};if(!navigator.onLine){var n=Promise.reject(Gp.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=Yp(e);var r=Zp(e),i={fid:t,authVersion:Kp,appId:e.appId,sdkVersion:$p};const s={method:"POST",headers:r,body:JSON.stringify(i)},o=await tf(()=>fetch(n,s));if(o.ok){i=await o.json();return{fid:i.fid||t,registrationStatus:2,refreshToken:i.refreshToken,authToken:Jp(i.authToken)}}throw await Xp("Create Installation",o)}(t,n);return gf(t,e)}catch(e){throw Qp(e)&&409===e.customData.serverCode?await mf(t):await gf(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===sf?{installationEntry:await r}:{installationEntry:e,registrationPromise:r}}function _f(e){return vf(e,e=>{if(!e)throw Gp.create("installation-not-found");return wf(e)})}function wf(e){return 1===(t=e).registrationStatus&&t.registrationTime+Wp<Date.now()?{fid:e.fid,registrationStatus:0}:e;var t}async function bf({appConfig:e,platformLoggerProvider:t},n){const r=([i,s]=[e,n["fid"]],`${Yp(i)}/${s}/authTokens:generate`);var i,s;const o=ef(e,n),a=t.getImmediate({optional:!0});a&&o.append("x-firebase-client",a.getPlatformInfoString());var c={installation:{sdkVersion:$p}};const l={method:"POST",headers:o,body:JSON.stringify(c)},u=await tf(()=>fetch(r,l));if(u.ok)return Jp(await u.json());throw await Xp("Generate Auth Token",u)}async function If(r,i=!1){let s;var e=await vf(r.appConfig,e=>{if(!Ef(e))throw Gp.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+Hp}(t)){if(1===n.requestStatus)return s=async function(e,t){let n=await Tf(e.appConfig);for(;1===n.authToken.requestStatus;)await nf(100),n=await Tf(e.appConfig);var r=n.authToken;return 0===r.requestStatus?If(e,t):r}(r,i),e;if(!navigator.onLine)throw Gp.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 bf(t,n),e=Object.assign(Object.assign({},n),{authToken:r});return await gf(t.appConfig,e),r}catch(e){throw!Qp(e)||401!==e.customData.serverCode&&404!==e.customData.serverCode?(r=Object.assign(Object.assign({},n),{authToken:{requestStatus:0}}),await gf(t.appConfig,r)):await mf(t.appConfig),e}}(r,n),n}return e});return s?await s:e.authToken}function Tf(e){return vf(e,e=>{if(!Ef(e))throw Gp.create("not-registered");var t,n=e.authToken;return 1===(t=n).requestStatus&&t.requestTime+Wp<Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e})}function Ef(e){return void 0!==e&&2===e.registrationStatus}async function kf(e,t=!1){var n,r=e;return e=r.appConfig,await((n=(await yf(e)).registrationPromise)&&await n),(await If(r,t)).token}function Sf(e){return Gp.create("missing-app-config-values",{valueName:e})}const Cf="installations",Af=e=>{var t=e.getProvider("app").getImmediate();return{app:t,appConfig:function(e){if(!e||!e.options)throw Sf("App Configuration");if(!e.name)throw Sf("App Name");for(const t of["projectId","apiKey","appId"])if(!e.options[t])throw Sf(t);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t),platformLoggerProvider:pp(t,"platform-logger"),_delete:()=>Promise.resolve()}},Nf=e=>{const t=pp(e.getProvider("app").getImmediate(),Cf).getImmediate();return{getId:()=>async function(e){var t=e;const{installationEntry:n,registrationPromise:r}=await yf(t.appConfig);return(r||If(t)).catch(console.error),n.fid}(t),getToken:e=>kf(t,e)}};dp(new Kd(Cf,Af,"PUBLIC")),dp(new Kd("installations-internal",Nf,"PRIVATE")),wp(ze,c),wp(ze,c,"esm2017");const Rf="analytics",Pf="firebase_id",xf="origin",Df="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",Of="https://www.googletagmanager.com/gtag/js",Mf=new ep("@firebase/analytics");function Lf(e){return Promise.all(e.map(e=>e.catch(e=>e)))}function Ff(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 Lf(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){Mf.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 Lf(n);var a=c.find(e=>e.measurementId===i);a&&await t[a.appId]}}catch(e){Mf.error(e)}e("config",i,s)}(r,i,s,o,t,n):r("set",t)}catch(e){Mf.error(e)}}}const Uf=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.'}),jf=30;const qf=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 Vf(e){var t,{appId:n,apiKey:r}=e,r={method:"GET",headers:new Headers({Accept:"application/json","x-goog-api-key":r})},n=Df.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 Uf.create("config-fetch-failed",{httpStatus:i.status,responseMessage:e})}}async function Bf(e,t=qf,n){var{appId:r,apiKey:i,measurementId:s}=e.options;if(!r)throw Uf.create("no-app-id");if(!i){if(s)return{measurementId:s,appId:r};throw Uf.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=qf){const{appId:o,measurementId:a}=n;try{await Wf(i,e)}catch(e){if(a)return Mf.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 Vf(n);return s.deleteThrottleMetadata(o),c}catch(e){if(!$f(e)){if(s.deleteThrottleMetadata(o),a)return Mf.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,jf):Wd(r,s.intervalMillis),u={throttleEndTimeMillis:Date.now()+l,backoffCount:r+1};return s.setThrottleMetadata(o,u),Mf.debug(`Calling attemptFetch again in ${l} millis`),t(n,u,i,s)}}({appId:r,apiKey:i,measurementId:s},o,a,t)}function Wf(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(Uf.create("fetch-throttle",{throttleEndTimeMillis:s}))})})}function $f(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 zf(t,e,n,r,i,s,o){const a=Bf(t);a.then(e=>{n[e.measurementId]=e.appId,t.options.measurementId&&e.measurementId!==t.options.measurementId&&Mf.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=>Mf.error(e)),e.push(a);var c=async function(){if(!dd())return Mf.warn(Uf.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;try{await pd()}catch(e){return Mf.warn(Uf.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(Of))return t}()&&function(e,t){const n=document.createElement("script");n.src=`${Of}?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[xf]="firebase",h.update=!0,null!=u&&(h[Pf]=u),i("config",l.measurementId,h),l.measurementId}class Hf{constructor(e){this.app=e}_delete(){return delete Gf[this.app.options.appId],Promise.resolve()}}let Gf={},Qf=[];const Yf={};let Jf="dataLayer",Xf="gtag",Zf,eg,tg=!1;function ng(e){if(tg)throw Uf.create("already-initialized");e.dataLayerName&&(Jf=e.dataLayerName),e.gtagName&&(Xf=e.gtagName)}function rg(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=Uf.create("invalid-analytics-context",{errorInfo:t}),Mf.warn(t.message))}();var r,i,s=e.options.appId;if(!s)throw Uf.create("no-app-id");if(!e.options.apiKey){if(!e.options.measurementId)throw Uf.create("no-api-key");Mf.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!=Gf[s])throw Uf.create("already-exists",{id:s});return tg||(function(e){let t=[];Array.isArray(window[e])?t=window[e]:window[e]=t,t}(Jf),{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]=Ff(s,e,t,n),{gtagCore:s,wrappedGtag:window[i]}}(Gf,Qf,Yf,Jf,Xf),eg=r,Zf=i,tg=!0),Gf[s]=zf(e,Qf,Yf,t,Zf,Jf,n),new Hf(e)}async function ig(){if(cd())return!1;if(!fd())return!1;if(!dd())return!1;try{return await pd()}catch(e){return!1}}function sg(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})}(eg,Gf[e.app.options.appId],t,n).catch(e=>Mf.error(e))}function og(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})}(eg,Gf[e.app.options.appId],t,n).catch(e=>Mf.error(e))}function ag(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})}(eg,Gf[e.app.options.appId],t,n).catch(e=>Mf.error(e))}function cg(e,t){e=$d(e),async function(e,t){var n=await e;window[`ga-disable-${n}`]=!t}(Gf[e.app.options.appId],t).catch(e=>Mf.error(e))}function lg(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})))}(eg,Gf[e.app.options.appId],t,n,r).catch(e=>Mf.error(e))}const ug="@firebase/analytics",hg="0.7.5-canary.88d43ec00";dp(new Kd(Rf,(e,{options:t})=>{return rg(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),t)},"PUBLIC")),dp(new Kd("analytics-internal",function(e){try{const r=e.getProvider(Rf).getImmediate();return{logEvent:(e,t,n)=>lg(r,e,t,n)}}catch(e){throw Uf.create("interop-component-reg-failed",{reason:e})}},"PRIVATE")),wp(ug,hg),wp(ug,hg,"esm2017");var dg,pg;class fg{constructor(e,t){this.app=e,this._delegate=t}logEvent(e,t,n){lg(this._delegate,e,t,n)}setCurrentScreen(e,t){sg(this._delegate,e,t)}setUserId(e,t){og(this._delegate,e,t)}setUserProperties(e,t){ag(this._delegate,e,t)}setAnalyticsCollectionEnabled(e){cg(this._delegate,e)}}(z=dg=dg||{}).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 gg=e=>{var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("analytics").getImmediate();return new fg(t,n)};pg={Analytics:fg,settings:ng,isSupported:ig,EventName:dg},Ap.INTERNAL.registerComponent(new Kd("analytics-compat",gg,"PUBLIC").setServiceProps(pg).setMultipleInstances(!0)),Ap.registerVersion("@firebase/analytics-compat","0.1.6-canary.88d43ec00");const mg=new Map,vg={activated:!1,tokenObservers:[]},yg={initialized:!1,enabled:!1};function _g(e){return mg.get(e)||vg}function wg(e,t){mg.set(e,t)}const bg="https://content-firebaseappcheck.googleapis.com/v1beta",Ig="exchangeDebugToken",Tg={OFFSET_DURATION:3e5,RETRIAL_MIN_WAIT:3e4,RETRIAL_MAX_WAIT:96e4};class Eg{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 kg=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 Sg(e=!1){var t;return e?null===(t=self.grecaptcha)||void 0===t?void 0:t.enterprise:self.grecaptcha}function Cg(e){if(!_g(e).activated)throw kg.create("use-before-activation",{appName:e.name})}function Ag(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+=Ng(n)+"d:"),r&&(s+=Ng(r)+"h:"),s+=Ng(i)+"m:"+Ng(t)+"s",s}function Ng(e){return 0===e?"00":10<=e?e.toString():"0"+e}async function Rg({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 kg.create("fetch-network-error",{originalErrorMessage:e.message})}if(200!==o.status)throw kg.create("fetch-status-error",{httpStatus:o.status});let a;try{a=await o.json()}catch(e){throw kg.create("fetch-parse-error",{originalErrorMessage:e.message})}var c=a.ttl.match(/^([\d.]+)(s)$/);if(!c||!c[2]||isNaN(Number(c[1])))throw kg.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 Pg="firebase-app-check-database",xg=1,Dg="firebase-app-check-store",Og="debug-token";let Mg=null;function Lg(){return Mg||(Mg=new Promise((t,n)=>{try{const e=indexedDB.open(Pg,xg);e.onsuccess=e=>{t(e.target.result)},e.onerror=e=>{var t;n(kg.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(Dg,{keyPath:"compositeKey"})}}catch(e){n(kg.create("storage-open",{originalErrorMessage:e.message}))}}),Mg)}async function Fg(e,t){const n=await Lg(),r=n.transaction(Dg,"readwrite"),i=r.objectStore(Dg),s=i.put({compositeKey:e,value:t});return new Promise((t,n)=>{s.onsuccess=e=>{t()},r.onerror=e=>{var t;n(kg.create("storage-set",{originalErrorMessage:null===(t=e.target.error)||void 0===t?void 0:t.message}))}})}async function Ug(e){const t=await Lg(),i=t.transaction(Dg,"readonly"),n=i.objectStore(Dg),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(kg.create("storage-get",{originalErrorMessage:null===(t=e.target.error)||void 0===t?void 0:t.message}))}})}function jg(e){return`${e.options.appId}-${e.name}`}const qg=new ep("@firebase/app-check");async function Vg(t){if(dd()){let e=void 0;try{e=await Ug(jg(t))}catch(e){qg.warn(`Failed to read token from IndexedDB. Error: ${e}`)}return e}}function Bg(e,t){return dd()?Fg(jg(e),t).catch(e=>{qg.warn(`Failed to write token to IndexedDB. Error: ${e}`)}):Promise.resolve()}async function Wg(){let e=void 0;try{e=await Ug(Og)}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,Fg(Og,t).catch(e=>qg.warn(`Failed to persist debug token to IndexedDB. Error: ${e}`)),n}function $g(){return yg.enabled}async function Kg(){var e=yg;if(e.enabled&&e.token)return e.token.promise;throw Error(`
8
8
  Can't get debug token in production mode.
9
- `)}function zg(){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=yg;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(Wg())}}const Hg={error:"UNKNOWN_ERROR"};async function Gg(e,t=!1){var n=e.app;Cg(n);const r=_g(n);let i=r.token,s=void 0;if(i||(a=await r.cachedTokenPromise)&&Zg(a)&&(i=a),!t&&i&&Zg(i))return{token:i.token};let o=!1;if(Kg()){r.exchangeTokenPromise||(r.exchangeTokenPromise=Rg(function(e,t){var{projectId:n,appId:r,apiKey:i}=e.options;return{url:`${bg}/projects/${n}/apps/${r}:${Tg}?key=${i}`,body:{debug_token:t}}}(n,await $g()),e.platformLoggerProvider).then(e=>(r.exchangeTokenPromise=void 0,e)),o=!0);var a=await r.exchangeTokenPromise;return await Bg(n,a),wg(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?qg.warn(e.message):qg.error(e),s=e}let c;return i?(c={token:i.token},wg(n,Object.assign(Object.assign({},r),{token:i})),await Bg(n,i)):c=(e=s,{token:function(e){return Zh.encodeString(JSON.stringify(e),!1)}(Hg),error:e}),o&&Xg(n,c),c}function Qg(e,t,n,r){var i=e["app"];const s=_g(i);var o={next:n,error:r,type:t};if(wg(i,Object.assign(Object.assign({},s),{tokenObservers:[...s.tokenObservers,o]})),s.token&&Zg(s.token)){const a=s.token;Promise.resolve().then(()=>{n({token:a.token}),Jg(e)}).catch(()=>{})}s.cachedTokenPromise.then(()=>Jg(e))}function Yg(e,t){const n=_g(e);var r=n.tokenObservers.filter(e=>e.next!==t);0===r.length&&n.tokenRefresher&&n.tokenRefresher.isRunning()&&n.tokenRefresher.stop(),wg(e,Object.assign(Object.assign({},n),{tokenObservers:r}))}function Jg(e){var t=e["app"],n=_g(t);let r=n.tokenRefresher;r||(r=function(n){const r=n["app"];return new Eg(async()=>{var e=_g(r);let t;if(t=e.token?await Gg(n,!0):await Gg(n),t.error)throw t.error},()=>!0,()=>{var e=_g(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},Ig.RETRIAL_MIN_WAIT,Ig.RETRIAL_MAX_WAIT)}(e),wg(t,Object.assign(Object.assign({},n),{tokenRefresher:r}))),!r.isRunning()&&n.isTokenAutoRefreshEnabled&&r.start()}function Xg(e,t){for(const n of _g(e).tokenObservers)try{"EXTERNAL"===n.type&&null!=t.error?n.error(t.error):n.next(t)}catch(e){}}function Zg(e){return 0<e.expireTimeMillis-Date.now()}class em{constructor(e,t){this.app=e,this.platformLoggerProvider=t}_delete(){var e=_g(this.app)["tokenObservers"];for(const t of e)Yg(this.app,t.next);return Promise.resolve()}}const tm="https://www.google.com/recaptcha/api.js",nm="https://www.google.com/recaptcha/enterprise.js";function rm(t,n){var e=_g(t);const r=new rd;wg(t,Object.assign(Object.assign({},e),{reCAPTCHAState:{initialized:r}}));const i=om(t);e=Sg(!1);return e?sm(t,n,e,i,r):function(e){const t=document.createElement("script");t.src=tm,t.onload=e,document.head.appendChild(t)}(()=>{var e=Sg(!1);if(!e)throw new Error("no recaptcha");sm(t,n,e,i,r)}),r.promise}function im(t,n){var e=_g(t);const r=new rd;wg(t,Object.assign(Object.assign({},e),{reCAPTCHAState:{initialized:r}}));const i=om(t);e=Sg(!0);return e?sm(t,n,e,i,r):function(e){const t=document.createElement("script");t.src=nm,t.onload=e,document.head.appendChild(t)}(()=>{var e=Sg(!0);if(!e)throw new Error("no recaptcha");sm(t,n,e,i,r)}),r.promise}function sm(r,i,s,o,a){s.ready(()=>{var e,t,n;e=r,t=s.render(o,{sitekey:i,size:"invisible"}),n=_g(e),wg(e,Object.assign(Object.assign({},n),{reCAPTCHAState:Object.assign(Object.assign({},n.reCAPTCHAState),{widgetId:t})})),a.resolve(s)})}function om(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 am(r){Cg(r);const i=await _g(r).reCAPTCHAState.initialized.promise;return new Promise((e,t)=>{const n=_g(r).reCAPTCHAState;i.ready(()=>{e(i.execute(n.widgetId,{action:"fire_app_check"}))})})}class cm{constructor(e){this._siteKey=e,this._throttleData=null}async getToken(){dm(this._throttleData);var t=await am(this._app).catch(e=>{throw kg.create("recaptcha-error")});let e;try{e=await Rg(function(e,t){var{projectId:n,appId:r,apiKey:i}=e.options;return{url:`${bg}/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=hm(Number(null===(t=e.customData)||void 0===t?void 0:t.httpStatus),this._throttleData),kg.create("throttled",{time:Ag(this._throttleData.allowRequestsAfter-Date.now()),httpStatus:this._throttleData.httpStatus})):e}return this._throttleData=null,e}initialize(e){this._app=e,this._platformLoggerProvider=pp(e,"platform-logger"),rm(e,this._siteKey).catch(()=>{})}isEqual(e){return e instanceof cm&&this._siteKey===e._siteKey}}class lm{constructor(e){this._siteKey=e,this._throttleData=null}async getToken(){dm(this._throttleData);var t=await am(this._app).catch(e=>{throw kg.create("recaptcha-error")});let e;try{e=await Rg(function(e,t){var{projectId:n,appId:r,apiKey:i}=e.options;return{url:`${bg}/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=hm(Number(null===(t=e.customData)||void 0===t?void 0:t.httpStatus),this._throttleData),kg.create("throttled",{time:Ag(this._throttleData.allowRequestsAfter-Date.now()),httpStatus:this._throttleData.httpStatus})):e}return this._throttleData=null,e}initialize(e){this._app=e,this._platformLoggerProvider=pp(e,"platform-logger"),im(e,this._siteKey).catch(()=>{})}isEqual(e){return e instanceof lm&&this._siteKey===e._siteKey}}class um{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 um&&this._customProviderOptions.getToken.toString()===e._customProviderOptions.getToken.toString()}}function hm(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 dm(e){if(e&&Date.now()-e.allowRequestsAfter<=0)throw kg.create("throttled",{time:Ag(e.allowRequestsAfter-Date.now()),httpStatus:e.httpStatus})}function pm(e=yp(),t){const n=pp(e=Kd(e),"app-check");if(yg.initialized||zg(),Kg()&&$g().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 kg.create("already-initialized",{appName:e.name})}r=n.initialize({options:t});return function(t,e,n){const r=_g(t),i=Object.assign(Object.assign({},r),{activated:!0});i.provider=e,i.cachedTokenPromise=Vg(t).then(e=>(e&&Zg(e)&&(wg(t,Object.assign(Object.assign({},_g(t)),{token:e})),Xg(t,{token:e.token})),e)),i.isTokenAutoRefreshEnabled=void 0===n?t.automaticDataCollectionEnabled:n,wg(t,i),i.provider.initialize(t)}(e,t.provider,t.isTokenAutoRefreshEnabled),_g(e).isTokenAutoRefreshEnabled&&Qg(r,"INTERNAL",()=>{}),r}const fm="app-check-internal";dp(new $d("app-check",e=>{var t,n=e.getProvider("app").getImmediate(),r=e.getProvider("platform-logger");return t=n,e=r,new em(t,e)},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{e.getProvider(fm).initialize()})),dp(new $d(fm,e=>{var t,n=e.getProvider("app-check").getImmediate();return t=n,{getToken:e=>Gg(t,e),addTokenListener:e=>Qg(t,"INTERNAL",e),removeTokenListener:e=>Yg(t.app,e)}},"PUBLIC").setInstantiationMode("EXPLICIT")),wp("@firebase/app-check","0.5.3-canary.044a8d7f9");const gm=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 mm{constructor(e){this.app=e}activate(e,t){let n;n="string"==typeof e?new cm(e):e instanceof lm||e instanceof cm||e instanceof um?e:new um({getToken:e.getToken}),this._delegate=pm(this.app,{provider:n,isTokenAutoRefreshEnabled:t})}setTokenAutoRefreshEnabled(e){if(!this._delegate)throw gm.create("use-before-activation",{appName:this.app.name});!function(e,t){var n=e.app;const r=_g(n);r.tokenRefresher&&(!0===t?r.tokenRefresher.start():r.tokenRefresher.stop()),wg(n,Object.assign(Object.assign({},r),{isTokenAutoRefreshEnabled:t}))}(this._delegate,e)}getToken(e){if(!this._delegate)throw gm.create("use-before-activation",{appName:this.app.name});return async function(e,t){var n=await Gg(e,t);if(n.error)throw n.error;return{token:n.token}}(this._delegate,e)}onTokenChanged(e,t,n){if(!this._delegate)throw gm.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),Qg(e,"EXTERNAL",r,i),()=>Yg(e.app,r)}(this._delegate,e,t)}}const vm=e=>{var t=e.getProvider("app-compat").getImmediate();return new mm(t)};function ym(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}Ap.INTERNAL.registerComponent(new $d("appCheck-compat",vm,"PUBLIC").setServiceProps({ReCaptchaEnterpriseProvider:lm,ReCaptchaV3Provider:cm,CustomProvider:um})),Ap.registerVersion("@firebase/app-check-compat","0.2.3-canary.044a8d7f9");const _m={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"},wm={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 bm(){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 Tm(){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 Im=bm,Em=new md("auth","Firebase",bm()),km=new ep("@firebase/auth");function Sm(e,...t){km.logLevel<=Kh.ERROR&&km.error(`Auth (${mp}): ${e}`,...t)}function Cm(e,...t){throw Pm(e,...t)}function Am(e,...t){return Pm(e,...t)}function Nm(e,t,n){var r=Object.assign(Object.assign({},Im()),{[t]:n});const i=new md("auth","Firebase",r);return i.create(t,{appName:e.name})}function Rm(e,t,n){if(!(t instanceof n))throw n.name!==t.constructor.name&&Cm(e,"argument-error"),Nm(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.`+"Did you pass a reference from a different Auth SDK?")}function Pm(e,...t){if("string"==typeof e)return Em.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 xm(e,t,...n){if(!e)throw Pm(t,...n)}function Dm(e){var t="INTERNAL ASSERTION FAILED: "+e;throw Sm(t),new Error(t)}function Om(e,t){e||Dm(t)}const Mm=new Map;function Lm(e){Om(e instanceof Function,"Expected a class definition");let t=Mm.get(e);return t?Om(t instanceof e,"Instance stored in cache mismatched with class"):(t=new e,Mm.set(e,t)),t}function Fm(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.href)||""}function Um(){return"http:"===jm()||"https:"===jm()}function jm(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.protocol)||null}class qm{constructor(e,t){Om((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&&(Um()||cd()||"connection"in navigator)&&!navigator.onLine?Math.min(5e3,this.shortDelay):this.isMobile?this.longDelay:this.shortDelay}}function Vm(e,t){Om(e.emulator,"Emulator should always be set here");var n=e.emulator["url"];return t?`${n}${t.startsWith("/")?t.slice(1):t}`:n}class Bm{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 Dm("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 Dm("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 Dm("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}}const Wm={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"},Km=new qm(3e4,6e4);function $m(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function zm(i,s,o,a,e={}){return Hm(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),Bm.fetch()(Qm(i,i.config.apiHost,o,n),Object.assign({method:s,headers:r,referrerPolicy:"no-referrer"},e))})}async function Hm(t,e,n){t._canInitEmulator=!1;var r=Object.assign(Object.assign({},Wm),e);try{const o=new Ym(t),a=await Promise.race([n(),o.promise]);o.clearNetworkTimeout();var i=await a.json();if("needConfirmation"in i)throw Jm(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 Jm(t,"credential-already-in-use",i);if("EMAIL_EXISTS"===l)throw Jm(t,"email-already-in-use",i);var s=r[l]||l.toLowerCase().replace(/[_\s]+/g,"-");if(u)throw Nm(t,s,u);Cm(t,s)}}catch(e){if(e instanceof gd)throw e;Cm(t,"network-request-failed")}}async function Gm(e,t,n,r,i={}){var s=await zm(e,t,n,r,i);return"mfaPendingCredential"in s&&Cm(e,"multi-factor-auth-required",{_serverResponse:s}),s}function Qm(e,t,n,r){var i=`${t}${n}?${r}`;return e.config.emulator?Vm(e.config,i):`${e.config.apiScheme}://${i}`}class Ym{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(Am(this.auth,"timeout")),Km.get())})}clearNetworkTimeout(){clearTimeout(this.timer)}}function Jm(e,t,n){const r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=Am(e,t,r);return i.customData._tokenResponse=n,i}function Xm(e){if(e)try{const t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}function Zm(e){return 1e3*Number(e)}function ev(e){var[t,n,r]=e.split(".");if(void 0===t||void 0===n||void 0===r)return Sm("JWT malformed, contained fewer than 3 sections"),null;try{var i=td(n);return i?JSON.parse(i):(Sm("Failed to decode base64 JWT payload"),null)}catch(e){return Sm("Caught error parsing JWT payload as JSON",e),null}}async function tv(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 nv{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 rv{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=Xm(this.lastLoginAt),this.creationTime=Xm(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function iv(e){var t=e.auth,n=await e.getIdToken(),r=await tv(e,async function(e,t){return zm(e,"POST","/v1/accounts:lookup",t)}(t,{idToken:n}));xm(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=ym(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 rv(i.createdAt,i.lastLoginAt),isAnonymous:t};Object.assign(e,t)}class sv{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){xm(e.idToken,"internal-error"),xm(void 0!==e.idToken,"internal-error"),xm(void 0!==e.refreshToken,"internal-error");var t,n,n="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):(t=e.idToken,xm(n=ev(t),"internal-error"),xm(void 0!==n.exp,"internal-error"),xm(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 xm(!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 Hm(i=e,{},async()=>{var e=Cd({grant_type:"refresh_token",refresh_token:s}).slice(1),{tokenApiHost:t,apiKey:n}=i.config,n=Qm(i,t,"/v1/token",`key=${n}`);const r=await i._getAdditionalHeaders();return r["Content-Type"]="application/x-www-form-urlencoded",Bm.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 sv;return n&&(xm("string"==typeof n,"internal-error",{appName:e}),s.refreshToken=n),r&&(xm("string"==typeof r,"internal-error",{appName:e}),s.accessToken=r),i&&(xm("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 sv,this.toJSON())}_performRefresh(){return Dm("not implemented")}}function ov(e,t){xm("string"==typeof e||void 0===e,"internal-error",{appName:t})}class av{constructor(e){var{uid:t,auth:n,stsTokenManager:r}=e,i=ym(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.emailVerified=!1,this.isAnonymous=!1,this.tenantId=null,this.providerData=[],this.proactiveRefresh=new nv(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 rv(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){var t=await tv(this,this.stsTokenManager.getToken(this.auth,e));return xm(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=ev(r);xm(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:Xm(Zm(i.auth_time)),issuedAtTime:Xm(Zm(i.iat)),expirationTime:Xm(Zm(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 iv(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}(this)}_assign(e){this!==e&&(xm(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 av(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}))}_onReload(e){xm(!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 iv(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){var e=await this.getIdToken();return await tv(this,async function(e,t){return zm(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;xm(u&&f,e,"internal-error");var g=sv.fromJSON(this.name,f);xm("string"==typeof u,e,"internal-error"),ov(n,e.name),ov(r,e.name),xm("boolean"==typeof h,e,"internal-error"),xm("boolean"==typeof d,e,"internal-error"),ov(i,e.name),ov(s,e.name),ov(o,e.name),ov(a,e.name),ov(c,e.name),ov(l,e.name);const m=new av({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 sv;r.updateFromServerResponse(t);var i=new av({uid:t.localId,auth:e,stsTokenManager:r,isAnonymous:n});return await iv(i),i}}class cv{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){}}cv.type="NONE";const lv=cv;function uv(e,t,n){return`firebase:${e}:${t}:${n}`}class hv{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;var{config:r,name:i}=this.auth;this.fullUserKey=uv(this.userKey,r.apiKey,i),this.fullPersistenceKey=uv("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?av._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 hv(Lm(lv),e,n);const r=(await Promise.all(t.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e);let i=r[0]||Lm(lv);const s=uv(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=av._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 hv(i,e,n)}}function dv(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(mv(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(pv(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(yv(t))return"Blackberry";if(_v(t))return"Webos";if(fv(t))return"Safari";if((t.includes("chrome/")||gv(t))&&!t.includes("edge/"))return"Chrome";if(vv(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 pv(e=sd()){return/firefox\//i.test(e)}function fv(e=sd()){const t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function gv(e=sd()){return/crios\//i.test(e)}function mv(e=sd()){return/iemobile/i.test(e)}function vv(e=sd()){return/android/i.test(e)}function yv(e=sd()){return/blackberry/i.test(e)}function _v(e=sd()){return/webos/i.test(e)}function wv(e=sd()){return/iphone|ipad|ipod/i.test(e)}function bv(e=sd()){return wv(e)||vv(e)||_v(e)||yv(e)||/windows phone/i.test(e)||mv(e)}function Tv(e,t=[]){let n;switch(e){case"Browser":n=dv(sd());break;case"Worker":n=`${dv(sd())}-${e}`;break;default:n=e}var r=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${mp}/${r}`}class Iv{constructor(e,t){this.app=e,this.config=t,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new kv(this),this.idTokenSubscription=new kv(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=Em,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=Lm(n)),this._initializationPromise=this.queue(async()=>{var e;if(!this._deleted&&(this.persistenceManager=await hv.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?(xm(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 iv(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&&xm(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&&xm(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(Lm(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||(xm(t=e&&Lm(e)||this._popupRedirectResolver,this,"argument-error"),this.redirectPersistenceManager=await hv.create(this,[Lm(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 xm(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 xm(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=Tv(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 Ev(e){return Kd(e)}class kv{constructor(e){this.auth=e,this.observer=null,this.addObserver=Pd(e=>this.observer=e)}get next(){return xm(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}function Sv(e,t,n){const r=Ev(e);xm(r._canInitEmulator,r,"emulator-config-failed"),xm(/^https?:\/\//.test(t),r,"invalid-emulator-scheme");var i=!(null==n||!n.disableWarnings);const s=Cv(t);var{host:o,port:a}=function(e){const t=Cv(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:Av(r.substr(s.length+1))}}var[o,s]=r.split(":");return{host:o,port:Av(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 Cv(e){var t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function Av(e){if(!e)return null;var t=Number(e);return isNaN(t)?null:t}class Nv{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return Dm("not implemented")}_getIdTokenResponse(e){return Dm("not implemented")}_linkToIdToken(e,t){return Dm("not implemented")}_getReauthenticationResolver(e){return Dm("not implemented")}}async function Rv(e,t){return zm(e,"POST","/v1/accounts:resetPassword",$m(e,t))}async function Pv(e,t){return zm(e,"POST","/v1/accounts:update",t)}async function xv(e,t){return zm(e,"POST","/v1/accounts:sendOobCode",$m(e,t))}class Dv extends Nv{constructor(e,t,n,r=null){super("password",n),this._email=e,this._password=t,this._tenantId=r}static _fromEmailAndPassword(e,t){return new Dv(e,t,"password")}static _fromEmailAndCode(e,t,n=null){return new Dv(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 Gm(e,"POST","/v1/accounts:signInWithPassword",$m(e,t))}(e,{returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(e,t){return Gm(e,"POST","/v1/accounts:signInWithEmailLink",$m(e,t))}(e,{email:this._email,oobCode:this._password});default:Cm(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return Pv(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(e,t){return Gm(e,"POST","/v1/accounts:signInWithEmailLink",$m(e,t))}(e,{idToken:t,email:this._email,oobCode:this._password});default:Cm(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function Ov(e,t){return Gm(e,"POST","/v1/accounts:signInWithIdp",$m(e,t))}class Mv extends Nv{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new Mv(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):Cm("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=ym(t,["providerId","signInMethod"]);if(!n||!r)return null;const i=new Mv(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 Ov(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,Ov(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Ov(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 Lv={USER_NOT_FOUND:"user-not-found"};class Fv extends Nv{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new Fv({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new Fv({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return async function(e,t){return Gm(e,"POST","/v1/accounts:signInWithPhoneNumber",$m(e,t))}(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return async function(e,t){var n=await Gm(e,"POST","/v1/accounts:signInWithPhoneNumber",$m(e,t));if(n.temporaryProof)throw Jm(e,"account-exists-with-different-credential",n);return n}(e,Object.assign({idToken:t},this._makeVerificationRequest()))}_getReauthenticationResolver(e){return async function(e,t){return Gm(e,"POST","/v1/accounts:signInWithPhoneNumber",$m(e,Object.assign(Object.assign({},t),{operation:"REAUTH"})),Lv)}(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 Fv({verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}):null}}class Uv{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);xm(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 Uv(t)}catch(e){return null}}}class jv{constructor(){this.providerId=jv.PROVIDER_ID}static credential(e,t){return Dv._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){var n=Uv.parseLink(t);return xm(n,"argument-error"),Dv._fromEmailAndCode(e,n.code,n.tenantId)}}jv.PROVIDER_ID="password",jv.EMAIL_PASSWORD_SIGN_IN_METHOD="password",jv.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class qv{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 Vv extends qv{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class Bv extends Vv{static credentialFromJSON(e){var t="string"==typeof e?JSON.parse(e):e;return xm("providerId"in t&&"signInMethod"in t,"argument-error"),Mv._fromParams(t)}credential(e){return this._credential(Object.assign(Object.assign({},e),{nonce:e.rawNonce}))}_credential(e){return xm(e.idToken||e.accessToken,"argument-error"),Mv._fromParams(Object.assign(Object.assign({},e),{providerId:this.providerId,signInMethod:this.providerId}))}static credentialFromResult(e){return Bv.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return Bv.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 Bv(o)._credential({idToken:t,accessToken:n,nonce:s,pendingToken:i})}catch(e){return null}}}class Wv extends Vv{constructor(){super("facebook.com")}static credential(e){return Mv._fromParams({providerId:Wv.PROVIDER_ID,signInMethod:Wv.FACEBOOK_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.FACEBOOK_SIGN_IN_METHOD="facebook.com",Wv.PROVIDER_ID="facebook.com";class Kv extends Vv{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return Mv._fromParams({providerId:Kv.PROVIDER_ID,signInMethod:Kv.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return Kv.credentialFromTaggedObject(e)}static credentialFromError(e){return Kv.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthIdToken:t,oauthAccessToken:n}=e;if(!t&&!n)return null;try{return Kv.credential(t,n)}catch(e){return null}}}Kv.GOOGLE_SIGN_IN_METHOD="google.com",Kv.PROVIDER_ID="google.com";class $v extends Vv{constructor(){super("github.com")}static credential(e){return Mv._fromParams({providerId:$v.PROVIDER_ID,signInMethod:$v.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return $v.credentialFromTaggedObject(e)}static credentialFromError(e){return $v.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return $v.credential(e.oauthAccessToken)}catch(e){return null}}}$v.GITHUB_SIGN_IN_METHOD="github.com",$v.PROVIDER_ID="github.com";class zv extends Nv{constructor(e,t){super(e,e),this.pendingToken=t}_getIdTokenResponse(e){return Ov(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,Ov(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Ov(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 zv(t,r):null}static _create(e,t){return new zv(e,t)}buildRequest(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}class Hv extends qv{constructor(e){xm(e.startsWith("saml."),"argument-error"),super(e)}static credentialFromResult(e){return Hv.samlCredentialFromTaggedObject(e)}static credentialFromError(e){return Hv.samlCredentialFromTaggedObject(e.customData||{})}static credentialFromJSON(e){var t=zv.fromJSON(e);return xm(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 zv._create(n,t)}catch(e){return null}}}class Gv extends Vv{constructor(){super("twitter.com")}static credential(e,t){return Mv._fromParams({providerId:Gv.PROVIDER_ID,signInMethod:Gv.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return Gv.credentialFromTaggedObject(e)}static credentialFromError(e){return Gv.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return Gv.credential(t,n)}catch(e){return null}}}async function Qv(e,t){return Gm(e,"POST","/v1/accounts:signUp",$m(e,t))}Gv.TWITTER_SIGN_IN_METHOD="twitter.com",Gv.PROVIDER_ID="twitter.com";class Yv{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 av._fromIdTokenResponse(e,n,r),s=Jv(n);return new Yv({user:i,providerId:s,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);var r=Jv(n);return new Yv({user:e,providerId:r,_tokenResponse:n,operationType:t})}}function Jv(e){return e.providerId||("phoneNumber"in e?"phone":null)}class Xv extends gd{constructor(e,t,n,r){var i;super(t.code,t.message),this.operationType=n,this.user=r,Object.setPrototypeOf(this,Xv.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 Xv(e,t,n,r)}}function Zv(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 Xv._fromErrorAndOperation(t,e,n,r);throw e})}function ey(e){return new Set(e.map(({providerId:e})=>e).filter(e=>!!e))}async function ty(e,t){const n=Kd(e);await ry(!0,n,t);var r=(e=n.auth,t={idToken:await n.getIdToken(),deleteProvider:[t]},await zm(e,"POST","/v1/accounts:update",t))["providerUserInfo"];const i=ey(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 ny(e,t,n=!1){var r=await tv(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return Yv._forOperation(e,"link",r)}async function ry(e,t,n){await iv(t);const r=ey(t.providerData);var i=!1===e?"provider-already-linked":"no-such-provider";xm(r.has(n)===e,t.auth,i)}async function iy(e,t,n=!1){var r=e["auth"],i="reauthenticate";try{var s=await tv(e,Zv(r,i,t,e),n);xm(s.idToken,r,"internal-error");var o=ev(s.idToken);xm(o,r,"internal-error");var a=o["sub"];return xm(e.uid===a,r,"user-mismatch"),Yv._forOperation(e,i,s)}catch(e){throw"auth/user-not-found"===(null==e?void 0:e.code)&&Cm(r,"user-mismatch"),e}}async function sy(e,t,n=!1){var r=await Zv(e,"signIn",t),r=await Yv._fromIdTokenResponse(e,"signIn",r);return n||await e._updateCurrentUser(r.user),r}async function oy(e,t){return sy(Ev(e),t)}async function ay(e,t){var n=Kd(e);return await ry(!1,n,t.providerId),ny(n,t)}async function cy(e,t){return iy(Kd(e),t)}async function ly(e,t){const n=Ev(e);var r=await Gm(n,"POST","/v1/accounts:signInWithCustomToken",$m(n,{token:t,returnSecureToken:!0})),r=await Yv._fromIdTokenResponse(n,"signIn",r);return await n._updateCurrentUser(r.user),r}class uy{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?hy._fromServerResponse(e,t):Cm(e,"internal-error")}}class hy extends uy{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new hy(t)}}function dy(e,t,n){var r;xm(0<(null===(r=n.url)||void 0===r?void 0:r.length),e,"invalid-continue-uri"),xm(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&&(xm(0<n.iOS.bundleId.length,e,"missing-ios-bundle-id"),t.iOSBundleId=n.iOS.bundleId),n.android&&(xm(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 py(e,t,n){var r=Kd(e),i={requestType:"PASSWORD_RESET",email:t};n&&dy(r,i,n),await xv(r,i)}async function fy(e,t){await zm(e=Kd(e),"POST","/v1/accounts:update",$m(e,{oobCode:t}))}async function gy(e,t){var n=Kd(e),r=await Rv(n,{oobCode:t}),i=r.requestType;switch(xm(i,n,"internal-error"),i){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":xm(r.newEmail,n,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":xm(r.mfaInfo,n,"internal-error");default:xm(r.email,n,"internal-error")}let s=null;return r.mfaInfo&&(s=uy._fromServerResponse(Ev(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 my(e,t,n){var r=Kd(e),i={requestType:"EMAIL_SIGNIN",email:t};xm(n.handleCodeInApp,r,"argument-error"),n&&dy(r,i,n),await xv(r,i)}async function vy(e,t){var n=Um()?Fm():"http://localhost",n=(await zm(e=Kd(e),"POST","/v1/accounts:createAuthUri",$m(e,{identifier:t,continueUri:n})))["signinMethods"];return n||[]}async function yy(e,t){var n=Kd(e),r={requestType:"VERIFY_EMAIL",idToken:await e.getIdToken()};t&&dy(n.auth,r,t);var r=(await xv(n.auth,r))["email"];r!==e.email&&await e.reload()}async function _y(e,t,n){var r=Kd(e),i={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await e.getIdToken(),newEmail:t};n&&dy(r.auth,i,n);var i=(await xv(r.auth,i))["email"];i!==e.email&&await e.reload()}async function wy(e,{displayName:t,photoURL:n}){if(void 0!==t||void 0!==n){const i=Kd(e);var r=await i.getIdToken(),r=await tv(i,async function(e,t){return zm(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 by(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 tv(e,Pv(r,i));await e._updateTokensIfNecessary(r,!0)}class Ty{constructor(e,t,n={}){this.isNewUser=e,this.providerId=t,this.profile=n}}class Iy extends Ty{constructor(e,t,n,r){super(e,t,n),this.username=r}}class Ey extends Ty{constructor(e,t){super(e,"facebook.com",t)}}class ky extends Iy{constructor(e,t){super(e,"github.com",t,"string"==typeof(null==t?void 0:t.login)?null==t?void 0:t.login:null)}}class Sy extends Ty{constructor(e,t){super(e,"google.com",t)}}class Cy extends Iy{constructor(e,t,n){super(e,"twitter.com",t,n)}}function Ay(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=ev(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 Ty(r,i)}}if(!t)return null;switch(t){case"facebook.com":return new Ey(r,n);case"github.com":return new ky(r,n);case"google.com":return new Sy(r,n);case"twitter.com":return new Cy(r,n,e.screenName||null);case"custom":case"anonymous":return new Ty(r,null);default:return new Ty(r,t,n)}}(n)}class Ny{constructor(e,t){this.type=e,this.credential=t}static _fromIdtoken(e){return new Ny("enroll",e)}static _fromMfaPendingCredential(e){return new Ny("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 Ny._fromMfaPendingCredential(e.multiFactorSession.pendingCredential);if(null!==(t=e.multiFactorSession)&&void 0!==t&&t.idToken)return Ny._fromIdtoken(e.multiFactorSession.idToken)}return null}}class Ry{constructor(e,t,n){this.session=e,this.hints=t,this.signInResolver=n}static _fromError(e,i){const s=Ev(e),o=i.customData._serverResponse;var t=(o.mfaInfo||[]).map(e=>uy._fromServerResponse(s,e));xm(o.mfaPendingCredential,s,"internal-error");const a=Ny._fromMfaPendingCredential(o.mfaPendingCredential);return new Ry(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 Yv._fromIdTokenResponse(s,i.operationType,n);return await s._updateCurrentUser(r.user),r;case"reauthenticate":return xm(i.user,s,"internal-error"),Yv._forOperation(i.user,i.operationType,n);default:Cm(s,"internal-error")}})}async resolveSignIn(e){return this.signInResolver(e)}}class Py{constructor(t){this.user=t,this.enrolledFactors=[],t._onReload(e=>{e.mfaInfo&&(this.enrolledFactors=e.mfaInfo.map(e=>uy._fromServerResponse(t.auth,e)))})}static _fromUser(e){return new Py(e)}async getSession(){return Ny._fromIdtoken(await this.user.getIdToken())}async enroll(e,t){const n=e;var r=await this.getSession(),r=await tv(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 tv(this.user,(n=this.user.auth,e={idToken:r,mfaEnrollmentId:t},zm(n,"POST","/v2/accounts/mfaEnrollment:withdraw",$m(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 xy=new WeakMap;const Dy="__sak";class Oy{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Dy,"1"),this.storage.removeItem(Dy),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 My extends Oy{constructor(){var e;super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.safariLocalStorageNotSynced=(fv(e=sd())||wv(e))&&function(){try{return!(!window||window===window.top)}catch(e){return!1}}(),this.fallbackToPolling=bv(),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]}}My.type="LOCAL";const Ly=My;class Fy extends Oy{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Fy.type="SESSION";const Uy=Fy;class jy{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 jy(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 qy(e="",t=10){let n="";for(let r=0;r<t;r++)n+=Math.floor(10*Math.random());return e+n}jy.receivers=[];class Vy{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=qy("",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 By(){return window}function Wy(){return void 0!==By().WorkerGlobalScope&&"function"==typeof By().importScripts}const Ky="firebaseLocalStorageDb",$y="firebaseLocalStorage",zy="fbase_key";class Hy{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 Gy(e,t){return e.transaction([$y],t?"readwrite":"readonly").objectStore($y)}function Qy(){const r=indexedDB.open(Ky,1);return new Promise((n,t)=>{r.addEventListener("error",()=>{t(r.error)}),r.addEventListener("upgradeneeded",()=>{const e=r.result;try{e.createObjectStore($y,{keyPath:zy})}catch(e){t(e)}}),r.addEventListener("success",async()=>{const e=r.result;var t;e.objectStoreNames.contains($y)?n(e):(e.close(),t=indexedDB.deleteDatabase(Ky),await new Hy(t).toPromise(),n(await Qy()))})})}async function Yy(e,t,n){var r=Gy(e,!0).put({fbase_key:t,value:n});return new Hy(r).toPromise()}function Jy(e,t){var n=Gy(e,!0).delete(t);return new Hy(n).toPromise()}class Xy{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 Qy(),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 Wy()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=jy._getInstance(Wy()?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 Vy(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 Qy();return await Yy(e,Dy,"1"),await Jy(e,Dy),!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=>Yy(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=Gy(e,!1).get(t);return void 0===(n=await new Hy(n).toPromise())?null:n.value}(e,t));return this.localCache[t]=e}async _remove(t){return this._withPendingWrite(async()=>(await this._withRetries(e=>Jy(e,t)),delete this.localCache[t],this.notifyServiceWorker(t)))}async _poll(){var e,t,n=await this._withRetries(e=>{var t=Gy(e,!1).getAll();return new Hy(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()}}Xy.type="LOCAL";const Zy=Xy;function e_(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=Am("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 t_(e){return`__${e}${Math.floor(1e6*Math.random())}`}class n_{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 r_(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 r_{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;xm(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 i_=t_("rcb"),s_=new qm(3e4,6e4);class o_{constructor(){this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!By().grecaptcha}load(s,o=""){var e;return xm((e=o).length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(e),s,"argument-error"),this.shouldResolveImmediately(o)?Promise.resolve(By().grecaptcha):new Promise((t,n)=>{const i=By().setTimeout(()=>{n(Am(s,"network-request-failed"))},s_.get());By()[i_]=()=>{By().clearTimeout(i),delete By()[i_];const e=By().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(Am(s,"internal-error"))},e_(`https://www.google.com/recaptcha/api.js??${Cd({onload:i_,render:"explicit",hl:o})}`).catch(()=>{clearTimeout(i),n(Am(s,"internal-error"))})})}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){return!!By().grecaptcha&&(e===this.hostLanguage||0<this.counter||this.librarySeparatelyLoaded)}}class a_{async load(e){return new n_(e)}clearedOneInstance(){}}const c_="recaptcha",l_={theme:"light",type:"image"};class u_{constructor(e,t=Object.assign({},l_),n){this.parameters=t,this.type=c_,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=Ev(n),this.isInvisible="invisible"===this.parameters.size,xm("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment");var r="string"==typeof e?document.getElementById(e):e;xm(r,this.auth,"argument-error"),this.container=r,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=new(this.auth.settings.appVerificationDisabledForTesting?a_:o_),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(){xm(!this.parameters.sitekey,this.auth,"argument-error"),xm(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),xm("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=By()[n];"function"==typeof e&&e(t)}}}assertNotDestroyed(){xm(!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(){xm(Um()&&!Wy(),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 zm(this.auth,"GET","/v1/recaptchaParams")).recaptchaSiteKey||"");xm(e,this.auth,"internal-error"),this.parameters.sitekey=e}getAssertedRecaptcha(){return xm(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}class h_{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){var t=Fv._fromVerification(this.verificationId,e);return this.onConfirmation(t)}}async function d_(t,n,r){var i,s,o,a,c,l,u=await r.verify();try{xm("string"==typeof u,t,"argument-error"),xm(r.type===c_,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 xm("enroll"===h.type,t,"internal-error"),(c=t,l={idToken:h.credential,phoneEnrollmentInfo:{phoneNumber:e.phoneNumber,recaptchaToken:u}},await zm(c,"POST","/v2/accounts/mfaEnrollment:start",$m(c,l))).phoneSessionInfo.sessionInfo;xm("signin"===h.type,t,"internal-error");var d=(null===(i=e.multiFactorHint)||void 0===i?void 0:i.uid)||e.multiFactorUid;return xm(d,t,"missing-multi-factor-info"),(a={mfaPendingCredential:h.credential,mfaEnrollmentId:d,phoneSignInInfo:{recaptchaToken:u}},await zm(t,"POST","/v2/accounts/mfaSignIn:start",$m(t,a))).phoneResponseInfo.sessionInfo}var p=(s=t,o={phoneNumber:e.phoneNumber,recaptchaToken:u},await zm(s,"POST","/v1/accounts:sendVerificationCode",$m(s,o)))["sessionInfo"];return p}finally{r._reset()}}class p_{constructor(e){this.providerId=p_.PROVIDER_ID,this.auth=Ev(e)}verifyPhoneNumber(e,t){return d_(this.auth,e,Kd(t))}static credential(e,t){return Fv._fromVerification(e,t)}static credentialFromResult(e){var t=e;return p_.credentialFromTaggedObject(t)}static credentialFromError(e){return p_.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{phoneNumber:t,temporaryProof:n}=e;return t&&n?Fv._fromTokenResponse(t,n):null}}function f_(e,t){return t?Lm(t):(xm(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}p_.PROVIDER_ID="phone",p_.PHONE_SIGN_IN_METHOD="phone";class g_ extends Nv{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Ov(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Ov(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Ov(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 m_(e){return sy(e.auth,new g_(e),e.bypassAuthState)}function v_(e){var{auth:t,user:n}=e;return xm(n,t,"internal-error"),iy(n,new g_(e),e.bypassAuthState)}async function y_(e){var{auth:t,user:n}=e;return xm(n,t,"internal-error"),ny(n,new g_(e),e.bypassAuthState)}class __{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 m_;case"linkViaPopup":case"linkViaRedirect":return y_;case"reauthViaPopup":case"reauthViaRedirect":return v_;default:Cm(this.auth,"internal-error")}}resolve(e){Om(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Om(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 w_=new qm(2e3,1e4);class b_ extends __{constructor(e,t,n,r,i){super(e,t,r,i),this.provider=n,this.authWindow=null,this.pollId=null,b_.currentPopupAction&&b_.currentPopupAction.cancel(),b_.currentPopupAction=this}async executeNotNull(){var e=await this.execute();return xm(e,this.auth,"internal-error"),e}async onExecution(){Om(1===this.filter.length,"Popup operations only handle one event");var e=qy();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(Am(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(Am(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,b_.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(Am(this.auth,"popup-closed-by-user"))},2e3):this.pollId=window.setTimeout(t,w_.get())};t()}}b_.currentPopupAction=null;const T_="pendingRedirect",I_=new Map;class E_ extends __{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let t=I_.get(this.auth._key());if(!t){try{const e=await async function(e,t){const n=C_(t),r=S_(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)}I_.set(this.auth._key(),t)}return this.bypassAuthState||I_.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 k_(e,t){return S_(e)._set(C_(t),"true")}function S_(e){return Lm(e._redirectPersistence)}function C_(e){return uv(T_,e.config.apiKey,e.name)}function A_(e,t,n){return async function(e,t,n){var r=Ev(e);Rm(e,t,qv);const i=f_(r,n);return await k_(i,r),i._openRedirect(r,t,"signInViaRedirect")}(e,t,n)}function N_(e,t,n){return async function(e,t,n){var r=Kd(e);Rm(r.auth,t,qv);const i=f_(r.auth,n);await k_(i,r.auth);var s=await x_(r);return i._openRedirect(r.auth,t,"reauthViaRedirect",s)}(e,t,n)}function R_(e,t,n){return async function(e,t,n){var r=Kd(e);Rm(r.auth,t,qv);const i=f_(r.auth,n);await ry(!1,r,t.providerId),await k_(i,r.auth);var s=await x_(r);return i._openRedirect(r.auth,t,"linkViaRedirect",s)}(e,t,n)}async function P_(e,t,n=!1){const r=Ev(e);var i=f_(r,t);const s=new E_(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 x_(e){var t=qy(`${e.uid}:::`);return e._redirectEventId=t,await e.auth._setRedirectUser(e),await e.auth._persistUserIfCurrent(e),t}class D_{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 M_(e);default:return!1}}(t)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=t,n=!0)),n}sendToConsumer(e,t){var n;e.error&&!M_(e)?(n=(null===(n=e.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error",t.onError(Am(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(O_(e))}saveEventToCache(e){this.cachedEventUids.add(O_(e)),this.lastProcessedEventTime=Date.now()}}function O_(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function M_({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===(null==t?void 0:t.code)}async function L_(e,t={}){return zm(e,"GET","/v1/projects",t)}const F_=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,U_=/^https?/;async function j_(e){if(!e.config.emulator){var t=(await L_(e))["authorizedDomains"];for(const n of t)try{if(function(e){const t=Fm(),{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(!U_.test(n))return!1;if(F_.test(e))return r===e;const s=e.replace(/\./g,"\\."),o=new RegExp("^(.+\\."+s+"|"+s+")$","i");return o.test(r)}(n))return}catch(e){}Cm(e,"unauthorized-domain")}}const q_=new qm(3e4,6e4);function V_(){const t=By().___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 B_=null;function W_(e){var i;return B_=B_||(i=e,new Promise((e,t)=>{function n(){V_(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{V_(),t(Am(i,"network-request-failed"))},timeout:q_.get()})}if(null!==(r=null===(r=By().gapi)||void 0===r?void 0:r.iframes)&&void 0!==r&&r.Iframe)e(gapi.iframes.getContext());else{if(null===(r=By().gapi)||void 0===r||!r.load){var r=t_("iframefcb");return By()[r]=()=>{gapi.load?n():t(Am(i,"network-request-failed"))},e_(`https://apis.google.com/js/api.js?onload=${r}`).catch(e=>t(e))}n()}}).catch(e=>{throw B_=null,e})),B_}const K_=new qm(5e3,15e3),$_="__/auth/iframe",z_="emulator/auth/iframe",H_={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},G_=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);async function Q_(o){const e=await W_(o);var t=By().gapi;return xm(t,o,"internal-error"),e.open({where:document.body,url:function(e){var t=e.config;xm(t.authDomain,e,"auth-domain-config-required");var n=t.emulator?Vm(t,z_):`https://${e.config.authDomain}/${$_}`;const r={apiKey:t.apiKey,appName:e.name,v:mp};(t=G_.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:H_,dontclear:!0},s=>new Promise(async(e,t)=>{await s.restyle({setHideOnLeave:!1});const n=Am(o,"network-request-failed"),r=By().setTimeout(()=>{t(n)},K_.get());function i(){By().clearTimeout(r),e(s)}s.ping(i).then(i,()=>{t(n)})}))}const Y_={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class J_{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}function X_(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({},Y_),{width:r.toString(),height:i.toString(),top:s,left:o});s=sd().toLowerCase();n&&(a=gv(s)?"_blank":n),pv(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],wv(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 J_(null);const u=window.open(t||"",a,o);xm(u,e,"popup-blocked");try{u.focus()}catch(e){}return new J_(u)}const Z_="__/auth/handler",ew="emulator/auth/handler";function tw(e,t,n,r,i,s){xm(e.config.authDomain,e,"auth-domain-config-required"),xm(e.config.apiKey,e,"invalid-api-key");const o={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:r,v:mp,eventId:i};if(t instanceof qv){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 Vv){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?Vm(e,ew):`https://${e.authDomain}/${Z_}`}?${Cd(l).slice(1)}`}const nw="webStorageSupport";const rw=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Uy,this._completeRedirectFn=P_}async _openPopup(e,t,n,r){var i;return Om(null===(i=this.eventManagers[e._key()])||void 0===i?void 0:i.manager,"_initialize() not called before _openPopup()"),X_(e,tw(e,t,n,Fm(),r),qy())}async _openRedirect(e,t,n,r){return await this._originValidation(e),r=tw(e,t,n,Fm(),r),By().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):(Om(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 Q_(t),n=new D_(t);return e.register("authEvent",e=>{return xm(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(nw,{type:nw},e=>{var t=null===(t=null==e?void 0:e[0])||void 0===t?void 0:t[nw];void 0!==t&&r(!!t),Cm(n,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=j_(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return bv()||fv()||wv()}};class iw 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 Dm("unexpected MultiFactorSessionType")}}}{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new iw(e)}_finalizeEnroll(e,t,n){return e=e,n={idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()},zm(e,"POST","/v2/accounts/mfaEnrollment:finalize",$m(e,n))}_finalizeSignIn(e,t){return e=e,t={mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()},zm(e,"POST","/v2/accounts/mfaSignIn:finalize",$m(e,t))}}class sw{constructor(){}static assertion(e){return iw._fromCredential(e)}}sw.FACTOR_ID="phone";var ow,aw="@firebase/auth",cw="0.19.5-canary.044a8d7f9";class lw{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(){xm(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){0<this.internalListeners.size?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function uw(){return window}ow="Browser",dp(new $d("auth",(e,{options:n})=>{var t=e.getProvider("app").getImmediate();const{apiKey:r,authDomain:i}=t.options;return(e=>{xm(r&&!r.includes(":"),"invalid-api-key",{appName:e.name}),xm(!(null!==i&&void 0!==i&&i.includes(":")),"argument-error",{appName:e.name});var t={apiKey:r,authDomain:i,clientPlatform:ow,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:Tv(ow)},t=new Iv(e,t);return function(e,t){const n=(null==t?void 0:t.persistence)||[];var r=(Array.isArray(n)?n:[n]).map(Lm);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()})),dp(new $d("auth-internal",e=>{var t=Ev(e.getProvider("auth").getImmediate());return e=t,new lw(e)},"PRIVATE").setInstantiationMode("EXPLICIT")),wp(aw,cw,function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";default:return}}(ow)),wp(aw,cw,"esm2017");async function hw(e,t,n){var r=uw()["BuildInfo"];Om(t.sessionId,"AuthEvent did not contain a session ID");var i=await async function(e){const t=function(e){if(Om(/[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 wv()?s.ibi=r.packageName:vv()?s.apn=r.packageName:Cm(e,"operation-not-supported-in-this-environment"),r.displayName&&(s.appDisplayName=r.displayName),s.sessionId=i,tw(e,n,t.type,void 0,null!==(i=t.eventId)&&void 0!==i?i:void 0,s)}function dw(r){const i=uw()["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 pw=20;class fw extends D_{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 gw(e,t,n=null){return{type:t,eventId:n,urlResponse:null,sessionId:function(){const e=[],t="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let r=0;r<pw;r++){var n=Math.floor(Math.random()*t.length);e.push(t.charAt(n))}return e.join("")}(),postBody:null,tenantId:e.tenantId,error:Am(e,"no-auth-event")}}async function mw(e){var t=await yw()._get(_w(e));return t&&await yw()._remove(_w(e)),t}function vw(e,t){var n,r,i;const s=(n=ww(t=t),o=n.link?decodeURIComponent(n.link):void 0,r=ww(o).link,i=n.deep_link_id?decodeURIComponent(n.deep_link_id):void 0,(n=ww(i).link)||i||r||o||t);if(s.includes("/__/auth/callback")){var o=ww(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?Am(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 yw(){return Lm(Ly)}function _w(e){return uv("authEvent",e.config.apiKey,e.name)}function ww(e){if(null==e||!e.includes("?"))return{};const[,...t]=e.split("?");return Ad(t.join("?"))}const bw=class{constructor(){this._redirectPersistence=Uy,this._shouldInitProactively=!0,this.eventManagers=new Map,this.originValidationPromises={},this._completeRedirectFn=P_}async _initialize(e){var t=e._key();let n=this.eventManagers.get(t);return n||(n=new fw(e),this.eventManagers.set(t,n),this.attachCallbackListeners(e,n)),n}_openPopup(e){Cm(e,"operation-not-supported-in-this-environment")}async _openRedirect(e,t,n,r){var i,s;i=e,a=uw(),xm("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"}),xm(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"}),xm("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"}),xm("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"}),xm("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(),I_.clear(),await this._originValidation(e);var a=gw(e,n,r);n=e,r=a,await yw()._set(_w(n),r);a=await dw(await hw(e,a,t));return async function(o,a,c){const l=uw()["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(Am(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),vv()&&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=uw()["BuildInfo"];const n={};wv()?n.iosBundleId=t.packageName:vv()?n.androidPackageName=t.packageName:Cm(e,"operation-not-supported-in-this-environment"),await L_(e,n)}(e)),this.originValidationPromises[t]}attachCallbackListeners(r,i){const{universalLinks:e,handleOpenURL:t,BuildInfo:n}=uw(),s=setTimeout(async()=>{await mw(r),i.onEvent(Tw())},500),o=async e=>{clearTimeout(s);var t=await mw(r);let n=null;t&&null!=e&&e.url&&(n=vw(t,e.url)),i.onEvent(n||Tw())};void 0!==e&&"function"==typeof e.subscribe&&e.subscribe(null,o);const a=t,c=`${n.packageName.toLowerCase()}://`;uw().handleOpenURL=async e=>{if(e.toLowerCase().startsWith(c)&&o({url:e}),"function"==typeof a)try{a(e)}catch(e){console.error(e)}}}};function Tw(){return{type:"unknown",eventId:null,sessionId:null,urlResponse:null,postBody:null,tenantId:null,error:Am("no-auth-event")}}var Iw;function Ew(){var e;return(null===(e=null===self||void 0===self?void 0:self.location)||void 0===e?void 0:e.protocol)||null}function kw(e=sd()){return!("file:"!==Ew()&&"ionic:"!==Ew()||!e.toLowerCase().match(/iphone|ipad|ipod|android/))}function Sw(e=sd()){return ud()&&11===(null===document||void 0===document?void 0:document.documentMode)||([e=sd()]=[e],/Edge\/\d+/.test(e))}function Cw(){try{const t=self.localStorage;var e=qy();if(t)return t.setItem(e,"1"),t.removeItem(e),!Sw()||dd()}catch(e){return Aw()&&dd()}return!1}function Aw(){return"undefined"!=typeof global&&"WorkerGlobalScope"in global&&"importScripts"in global}function Nw(){return("http:"===Ew()||"https:"===Ew()||cd()||kw())&&!(ld()||ad())&&Cw()&&!Aw()}function Rw(){return kw()&&"undefined"!=typeof document}const Pw={LOCAL:"local",NONE:"none",SESSION:"session"},xw=xm,Dw="persistence";async function Ow(e){await e._initializationPromise;const t=Mw();var n=uv(Dw,e.config.apiKey,e.name);null!==t&&void 0!==t&&t.sessionStorage&&t.sessionStorage.setItem(n,e._getPersistence())}function Mw(){return"undefined"!=typeof window?window:null}const Lw=xm;class Fw{constructor(){this.browserResolver=Lm(rw),this.cordovaResolver=Lm(bw),this.underlyingResolver=null,this._redirectPersistence=Uy,this._completeRedirectFn=P_}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 Rw()||this.browserResolver._shouldInitProactively}get assertedUnderlyingResolver(){return Lw(this.underlyingResolver,"internal-error"),this.underlyingResolver}async selectUnderlyingResolver(){var e;this.underlyingResolver||(e=await(!!Rw()&&new Promise(e=>{const t=setTimeout(()=>{e(!1)},1e3);document.addEventListener("deviceready",()=>{clearTimeout(t),e(!0)})})),this.underlyingResolver=e?this.cordovaResolver:this.browserResolver)}}function Uw(e){return e.unwrap()}function jw(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 Ww(e,(n=t,i=Kd(e),xm((o=n).customData.operationType,i,"argument-error"),xm(null===(r=o.customData._serverResponse)||void 0===r?void 0:r.mfaPendingCredential,i,"argument-error"),Ry._fromError(i,o)))}else if(s){var o=qw(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 qw(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 p_.credentialFromResult(e);const n=t.providerId;if(!n||n===_m.PASSWORD)return null;let r;switch(n){case _m.GOOGLE:r=Kv;break;case _m.FACEBOOK:r=Wv;break;case _m.GITHUB:r=$v;break;case _m.TWITTER:r=Gv;break;default:var{oauthIdToken:i,oauthAccessToken:s,oauthTokenSecret:o,pendingToken:a,nonce:c}=t;return s||o||i||a?a?n.startsWith("saml.")?zv._create(n,a):Mv._fromParams({providerId:n,signInMethod:n,pendingToken:a,idToken:i,accessToken:s}):new Bv(n).credential({idToken:i,accessToken:s,rawNonce:c}):null}return e instanceof gd?r.credentialFromError(e):r.credentialFromResult(e)}function Vw(t,e){return e.catch(e=>{throw e instanceof gd&&jw(t,e),e}).then(e=>{var t=e.operationType,n=e.user;return{operationType:t,credential:qw(e),additionalUserInfo:Ay(e),user:Kw.getOrCreate(n)}})}async function Bw(t,e){const n=await e;return{verificationId:n.verificationId,confirm:e=>Vw(t,n.confirm(e))}}class Ww{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 Vw(Uw(this.auth),this.resolver.resolveSignIn(e))}}class Kw{constructor(e){var t;this._delegate=e,this.multiFactor=(t=Kd(e),xy.has(t)||xy.set(t,Py._fromUser(t)),xy.get(t))}static getOrCreate(e){return Kw.USER_MAP.has(e)||Kw.USER_MAP.set(e,new Kw(e)),Kw.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 Vw(this.auth,ay(this._delegate,e))}async linkWithPhoneNumber(e,t){return Bw(this.auth,async function(e,t,n){const r=Kd(e);await ry(!1,r,"phone");var i=await d_(r.auth,t,Kd(n));return new h_(i,e=>ay(r,e))}(this._delegate,e,t))}async linkWithPopup(e){return Vw(this.auth,async function(e,t,n){var r=Kd(e);Rm(r.auth,t,qv);var i=f_(r.auth,n);const s=new b_(r.auth,"linkViaPopup",t,i,r);return s.executeNotNull()}(this._delegate,e,Fw))}async linkWithRedirect(e){return await Ow(Ev(this.auth)),R_(this._delegate,e,Fw)}reauthenticateAndRetrieveDataWithCredential(e){return this.reauthenticateWithCredential(e)}async reauthenticateWithCredential(e){return Vw(this.auth,cy(this._delegate,e))}reauthenticateWithPhoneNumber(e,t){return Bw(this.auth,async function(e,t,n){const r=Kd(e);var i=await d_(r.auth,t,Kd(n));return new h_(i,e=>cy(r,e))}(this._delegate,e,t))}reauthenticateWithPopup(e){return Vw(this.auth,async function(e,t,n){var r=Kd(e);Rm(r.auth,t,qv);var i=f_(r.auth,n);const s=new b_(r.auth,"reauthViaPopup",t,i,r);return s.executeNotNull()}(this._delegate,e,Fw))}async reauthenticateWithRedirect(e){return await Ow(Ev(this.auth)),N_(this._delegate,e,Fw)}sendEmailVerification(e){return yy(this._delegate,e)}async unlink(e){return await ty(this._delegate,e),this}updateEmail(e){return by(Kd(this._delegate),e,null)}updatePassword(e){return by(Kd(this._delegate),null,e)}updatePhoneNumber(e){return async function(e,t){await ny(Kd(e),t)}(this._delegate,e)}updateProfile(e){return wy(this._delegate,e)}verifyBeforeUpdateEmail(e,t){return _y(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}}Kw.USER_MAP=new WeakMap;const $w=xm;class zw{constructor(e,t){if(this.app=e,t.isInitialized())return this._delegate=t.getImmediate(),void this.linkUnderlyingAuth();var n=e.options["apiKey"];$w(n,"invalid-api-key",{appName:e.name}),$w(n,"invalid-api-key",{appName:e.name});var r="undefined"!=typeof window?Fw:void 0;this._delegate=t.initialize({options:{persistence:function(e,t){const n=function(e,t){const n=Mw();if(null===n||void 0===n||!n.sessionStorage)return[];var r=uv(Dw,e,t);switch(n.sessionStorage.getItem(r)){case Pw.NONE:return[lv];case Pw.LOCAL:return[Zy,Uy];case Pw.SESSION:return[Uy];default:return[]}}(e,t);"undefined"==typeof self||n.includes(Zy)||n.push(Zy);if("undefined"!=typeof window)for(const r of[Ly,Uy])n.includes(r)||n.push(r);n.includes(lv)||n.push(lv);return n}(n,e.name),popupRedirectResolver:r}}),this._delegate._updateErrorMap(Tm),this.linkUnderlyingAuth()}get emulatorConfig(){return this._delegate.emulatorConfig}get currentUser(){return this._delegate.currentUser?Kw.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){Sv(this._delegate,e,t)}applyActionCode(e){return fy(this._delegate,e)}checkActionCode(e){return gy(this._delegate,e)}confirmPasswordReset(e,t){return async function(e,t,n){await Rv(Kd(e),{oobCode:t,newPassword:n})}(this._delegate,e,t)}async createUserWithEmailAndPassword(e,t){return Vw(this._delegate,async function(e,t,n){const r=Ev(e);var i=await Qv(r,{returnSecureToken:!0,email:t,password:n}),i=await Yv._fromIdTokenResponse(r,"signIn",i);return await r._updateCurrentUser(i.user),i}(this._delegate,e,t))}fetchProvidersForEmail(e){return this.fetchSignInMethodsForEmail(e)}fetchSignInMethodsForEmail(e){return vy(this._delegate,e)}isSignInWithEmailLink(e){return this._delegate,e=e,"EMAIL_SIGNIN"===(null==(t=Uv.parseLink(e))?void 0:t.operation);var t}async getRedirectResult(){$w(Nw(),this._delegate,"operation-not-supported-in-this-environment");var e,t,n=(e=this._delegate,t=Fw,await Ev(e)._initializationPromise,await P_(e,t,!1));return n?Vw(this._delegate,Promise.resolve(n)):{credential:null,user:null}}addFrameworkForLogging(e){Ev(this._delegate)._logFramework(e)}onAuthStateChanged(e,t,n){var{next:r,error:i,complete:s}=Hw(e,t,n);return this._delegate.onAuthStateChanged(r,i,s)}onIdTokenChanged(e,t,n){var{next:r,error:i,complete:s}=Hw(e,t,n);return this._delegate.onIdTokenChanged(r,i,s)}sendSignInLinkToEmail(e,t){return my(this._delegate,e,t)}sendPasswordResetEmail(e,t){return py(this._delegate,e,t||void 0)}async setPersistence(e){var t,n;t=this._delegate,n=e,xw(Object.values(Pw).includes(n),t,"invalid-persistence-type"),ld()?xw(n!==Pw.SESSION,t,"unsupported-persistence-type"):ad()?xw(n===Pw.NONE,t,"unsupported-persistence-type"):Aw()?xw(n===Pw.NONE||n===Pw.LOCAL&&dd(),t,"unsupported-persistence-type"):xw(n===Pw.NONE||Cw(),t,"unsupported-persistence-type");let r;switch(e){case Pw.SESSION:r=Uy;break;case Pw.LOCAL:var i=await Lm(Zy)._isAvailable();r=i?Zy:Ly;break;case Pw.NONE:r=lv;break;default:return Cm("argument-error",{appName:this._delegate.name})}return this._delegate.setPersistence(r)}signInAndRetrieveDataWithCredential(e){return this.signInWithCredential(e)}signInAnonymously(){return Vw(this._delegate,async function(e){const t=Ev(e);if(await t._initializationPromise,null!==(n=t.currentUser)&&void 0!==n&&n.isAnonymous)return new Yv({user:t.currentUser,providerId:null,operationType:"signIn"});var n=await Qv(t,{returnSecureToken:!0}),n=await Yv._fromIdTokenResponse(t,"signIn",n,!0);return await t._updateCurrentUser(n.user),n}(this._delegate))}signInWithCredential(e){return Vw(this._delegate,oy(this._delegate,e))}signInWithCustomToken(e){return Vw(this._delegate,ly(this._delegate,e))}signInWithEmailAndPassword(e,t){return Vw(this._delegate,(n=this._delegate,e=e,t=t,oy(Kd(n),jv.credential(e,t))));var n}signInWithEmailLink(e,t){return Vw(this._delegate,async function(e,t,n){var r=Kd(e),i=jv.credentialWithLink(t,n||Fm());return xm(i._tenantId===(r.tenantId||null),r,"tenant-id-mismatch"),oy(r,i)}(this._delegate,e,t))}signInWithPhoneNumber(e,t){return Bw(this._delegate,async function(e,t,n){const r=Ev(e);var i=await d_(r,t,Kd(n));return new h_(i,e=>oy(r,e))}(this._delegate,e,t))}async signInWithPopup(e){return $w(Nw(),this._delegate,"operation-not-supported-in-this-environment"),Vw(this._delegate,async function(e,t,n){var r=Ev(e);Rm(e,t,qv);var i=f_(r,n);const s=new b_(r,"signInViaPopup",t,i);return s.executeNotNull()}(this._delegate,e,Fw))}async signInWithRedirect(e){return $w(Nw(),this._delegate,"operation-not-supported-in-this-environment"),await Ow(this._delegate),A_(this._delegate,e,Fw)}updateCurrentUser(e){return this._delegate.updateCurrentUser(e)}verifyPasswordResetCode(e){return async function(e,t){var n=(await gy(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 Hw(e,t,n){let r=e;"function"!=typeof e&&({next:r,error:t,complete:n}=e);const i=r;return{next:e=>i(e&&Kw.getOrCreate(e)),error:t,complete:n}}zw.Persistence=Pw;class Gw{constructor(){this.providerId="phone",this._delegate=new p_(Uw(Ap.auth()))}static credential(e,t){return p_.credential(e,t)}verifyPhoneNumber(e,t){return this._delegate.verifyPhoneNumber(e,t)}unwrap(){return this._delegate}}Gw.PHONE_SIGN_IN_METHOD=p_.PHONE_SIGN_IN_METHOD,Gw.PROVIDER_ID=p_.PROVIDER_ID;const Qw=xm;class Yw{constructor(e,t,n=Ap.app()){var r;Qw(null===(r=n.options)||void 0===r?void 0:r.apiKey,"invalid-api-key",{appName:n.name}),this._delegate=new u_(e,t,n.auth()),this.type=this._delegate.type}clear(){this._delegate.clear()}render(){return this._delegate.render()}verify(){return this._delegate.verify()}}(Iw=Ap).INTERNAL.registerComponent(new $d("auth-compat",e=>{var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("auth");return new zw(t,n)},"PUBLIC").setServiceProps({ActionCodeInfo:{Operation:{EMAIL_SIGNIN:wm.EMAIL_SIGNIN,PASSWORD_RESET:wm.PASSWORD_RESET,RECOVER_EMAIL:wm.RECOVER_EMAIL,REVERT_SECOND_FACTOR_ADDITION:wm.REVERT_SECOND_FACTOR_ADDITION,VERIFY_AND_CHANGE_EMAIL:wm.VERIFY_AND_CHANGE_EMAIL,VERIFY_EMAIL:wm.VERIFY_EMAIL}},EmailAuthProvider:jv,FacebookAuthProvider:Wv,GithubAuthProvider:$v,GoogleAuthProvider:Kv,OAuthProvider:Bv,SAMLAuthProvider:Hv,PhoneAuthProvider:Gw,PhoneMultiFactorGenerator:sw,RecaptchaVerifier:Yw,TwitterAuthProvider:Gv,Auth:zw,AuthCredential:Nv,Error:gd}).setInstantiationMode("LAZY").setMultipleInstances(!1)),Iw.registerVersion("@firebase/auth-compat","0.2.5-canary.044a8d7f9");const Jw="@firebase/database",Xw="0.12.5-canary.044a8d7f9";let Zw="";function eb(e){Zw=e}class tb{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 nb{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 rb,ib,sb,ob,ab,cb,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 tb(t)}}catch(e){}return new nb};function lb(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 ub=yt("localStorage"),hb=yt("sessionStorage"),db=new ep("@firebase/database"),pb=function(){let e=1;return function(){return e++}}(),fb=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+=fb.apply(null,n):t+="object"==typeof n?_d(n):n,t+=" "}return t};let gb=null,mb=!0;function vb(t){return function(...e){Eb(t,...e)}}function yb(...e){var t="FIREBASE INTERNAL ERROR: "+fb(...e);db.error(t)}function _b(e,t){return e===t?0:e<t?-1:1}function wb(e,t){if(t&&e in t)return t[e];throw new Error("Missing required key ("+e+") in object: "+_d(t))}function bb(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+=bb(e[t[i]]);return n+="}",n}function Tb(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 Ib=function(e,t){Jh(!t||!0===e||!1===e,"Can't turn on custom loggers persistently."),!0===e?(db.logLevel=Kh.VERBOSE,gb=db.log.bind(db),t&&hb.set("logging_enabled",!0)):"function"==typeof e?gb=e:(gb=null,hb.remove("logging_enabled"))},Eb=function(...e){var t;!0===mb&&(mb=!1,null===gb&&!0===hb.get("logging_enabled")&&Ib(!0)),gb&&(t=fb.apply(null,e),gb(t))},kb=function(...e){var t=`FIREBASE FATAL ERROR: ${fb(...e)}`;throw db.error(t),new Error(t)},Sb=function(...e){var t="FIREBASE WARNING: "+fb(...e);db.warn(t)},Cb=function(){"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&Sb("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},Ab=function(e){return"number"==typeof e&&(e!=e||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY)},Nb="[MIN_NAME]",Rb="[MAX_NAME]",Pb=function(e,t){if(e===t)return 0;if(e===Nb||t===Rb)return-1;if(t===Nb||e===Rb)return 1;var n=Ub(e),r=Ub(t);return null!==n?null!==r?n-r==0?e.length-t.length:n-r:-1:null===r&&e<t?-1:1};function xb(e,t){for(const n in e)e.hasOwnProperty(n)&&t(n,e[n])}function Db(e){Jh(!Ab(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 Ob(e,t){const n=setTimeout(e,t);return"object"==typeof n&&n.unref&&n.unref(),n}const Mb=new RegExp("^-?(0*)\\d{1,10}$"),Lb=-2147483648,Fb=2147483647,Ub=function(e){if(Mb.test(e)){var t=Number(e);if(t>=Lb&&t<=Fb)return t}return null},jb=function(e){try{e()}catch(t){setTimeout(()=>{var e=t.stack||"";throw Sb("Exception was thrown by user callback.",e),t},Math.floor(0))}};class qb{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(){Sb(`Provided AppCheck credentials for the app named "${this.appName_}" `+"are invalid. This usually indicates your app was not initialized correctly.")}}class Vb{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?(Eb("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/.',Sb(e)}}class Bb{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}Bb.OWNER="owner";const Wb=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,Kb="websocket",$b="long_polling";class zb{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=ub.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()&&ub.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 Hb(e,t,n){Jh("string"==typeof t,"typeof type must == string"),Jh("object"==typeof n,"typeof params must == object");let r;if(t===Kb)r=(e.secure?"wss://":"ws://")+e.internalHost+"/.ws?";else{if(t!==$b)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 xb(n,(e,t)=>{i.push(e+"="+t)}),r+i.join("&")}class Gb{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 Qb={},Yb={};function Jb(e){var t=e.toString();return Qb[t]||(Qb[t]=new Gb),Qb[t]}class Xb{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]&&jb(()=>{this.onMessage_(n[e])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}class Zb{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_=vb(e),this.stats_=Jb(t),this.urlFn=e=>(this.appCheckToken&&(e.ac=this.appCheckToken),Hb(t,$b,e))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new Xb(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 eT((...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&&Wb.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(){Zb.forceAllow_=!0}static forceDisallow(){Zb.forceDisallow_=!0}static isAvailable(){return!!Zb.forceAllow_||!(Zb.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=Tb(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 eT{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=pb(),window["pLPCommand"+this.uniqueCallbackIdentifier]=t,window["pRTLPCB"+this.uniqueCallbackIdentifier]=n,this.myIFrame=eT.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){Eb("frame writing exception"),e.stack&&Eb(e.stack),Eb(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||Eb("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=()=>{Eb("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(t)}catch(e){}},Math.floor(1))}}let tT=null;"undefined"!=typeof MozWebSocket?tT=MozWebSocket:"undefined"!=typeof WebSocket&&(tT=WebSocket);class nT{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_=vb(this.connId),this.stats_=Jb(t),this.connURL=nT.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&&Wb.test(location.hostname)&&(i.r="f"),t&&(i.s=t),n&&(i.ls=n),r&&(i.ac=r),Hb(e,Kb,i)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,ub.set("previous_websocket_failure",!0);try{hd()||(n={headers:{"X-Firebase-GMPID":this.applicationId||"","X-Firebase-AppCheck":this.appCheckToken||""}},this.mySock=new tT(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(){nT.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!==tT&&!nT.forceDisallow_}static previouslyFailed(){return ub.isInMemoryStorage||!0===ub.get("previous_websocket_failure")}markConnectionHealthy(){ub.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=Tb(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)}}}nT.responsesRequiredToBeHealthy=2,nT.healthyTimeout=3e4;class rT{constructor(e){this.initTransports_(e)}static get ALL_TRANSPORTS(){return[Zb,nT]}initTransports_(e){var t=nT&&nT.isAvailable();let n=t&&!nT.previouslyFailed();if(e.webSocketOnly&&(t||Sb("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),n=!0),n)this.transports_=[nT];else{const r=this.transports_=[];for(const i of rT.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 iT{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_=vb("c:"+this.id+":"),this.transportManager_=new rT(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_=Ob(()=>{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=wb("t",e),n=wb("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=wb("t",e),n=wb("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=wb("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?yb("Server Error: "+n):"o"===t?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):yb("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&&Sb("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),Ob(()=>{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):Ob(()=>{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()&&(ub.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 sT{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 oT{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 aT extends oT{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 aT}getInitialEvent(e){return Jh("online"===e,"Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}class cT{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 lT(){return new cT("")}function uT(e){return e.pieceNum_>=e.pieces_.length?null:e.pieces_[e.pieceNum_]}function hT(e){return e.pieces_.length-e.pieceNum_}function dT(e){let t=e.pieceNum_;return t<e.pieces_.length&&t++,new cT(e.pieces_,t)}function pT(e){return e.pieceNum_<e.pieces_.length?e.pieces_[e.pieces_.length-1]:null}function fT(e,t=0){return e.pieces_.slice(e.pieceNum_+t)}function gT(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 cT(t,0)}function mT(e,t){const n=[];for(let i=e.pieceNum_;i<e.pieces_.length;i++)n.push(e.pieces_[i]);if(t instanceof cT)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 cT(n,0)}function vT(e){return e.pieceNum_>=e.pieces_.length}function yT(e,t){var n=uT(e),r=uT(t);if(null===n)return t;if(n===r)return yT(dT(e),dT(t));throw new Error("INTERNAL ERROR: innerPath ("+t+") is not within outerPath ("+e+")")}function _T(e,t){var n=fT(e,0),r=fT(t,0);for(let s=0;s<n.length&&s<r.length;s++){var i=Pb(n[s],r[s]);if(0!==i)return i}return n.length===r.length?0:n.length<r.length?-1:1}function wT(e,t){if(hT(e)!==hT(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 bT(e,t){let n=e.pieceNum_,r=t.pieceNum_;if(hT(e)>hT(t))return!1;for(;n<e.pieces_.length;){if(e.pieces_[n]!==t.pieces_[r])return!1;++n,++r}return!0}class TT{constructor(e,t){this.errorPrefix_=t,this.parts_=fT(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]);IT(this)}}function IT(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 "+ET(e))}function ET(e){return 0===e.parts_.length?"":"in property '"+e.parts_.join(".")+"'"}class kT extends oT{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 kT}getInitialEvent(e){return Jh("visible"===e,"Unknown event type: "+e),[this.visible_]}}class ST extends sT{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=ST.nextPersistentConnectionId_++,this.log_=vb("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");kT.getInstance().on("visible",this.onVisible_,this),-1===e.host.indexOf("fblocal")&&aT.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;ST.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(),Sb("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):yb("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+":"+ST.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?Eb("getToken() completed but was canceled"):(Eb("getToken() completed. Creating connection."),this.authToken_=c&&c.accessToken,this.appCheckToken_=l&&l.token,n=new iT(i,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,r,u,e=>{Sb(e+" ("+this.repoInfo_.toString()+")"),this.interrupt("server_kill")},s))}catch(e){this.log_("Failed to get token: "+e),t||(this.repoInfo_.nodeAdmin&&Sb(e),o())}}}interrupt(e){Eb("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){Eb("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=>bb(e)).join("$"):"default";const r=this.removeListen_(e,n);r&&r.onComplete&&r.onComplete("permission_denied")}removeListen_(e,t){var n=new cT(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){Eb("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){Eb("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."+Zw.replace(/\./g,"-")]=1,od()?e["framework.cordova"]=1:ld()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){var e=aT.getInstance().currentlyOnline();return Id(this.interruptReasons_)&&e}}ST.nextPersistentConnectionId_=0,ST.nextConnectionId_=0;class CT{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new CT(e,t)}}class AT{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){var n=new CT(Nb,e),r=new CT(Nb,t);return 0!==this.compare(n,r)}minPost(){return CT.MIN}}let NT;class RT extends AT{static get __EMPTY_NODE(){return NT}static set __EMPTY_NODE(e){NT=e}compare(e,t){return Pb(e.name,t.name)}isDefinedOn(e){throw Xh("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return CT.MIN}maxPost(){return new CT(Rb,NT)}makePost(e,t){return Jh("string"==typeof e,"KeyIndex indexValue must always be a string."),new CT(e,NT)}toString(){return".key"}}const PT=new RT;class xT{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 DT{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:DT.RED,this.left=null!=r?r:OT.EMPTY_NODE,this.right=null!=i?i:OT.EMPTY_NODE}copy(e,t,n,r,i){return new DT(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 OT.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 OT.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,DT.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){var e=this.copy(null,null,DT.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)}}DT.RED=!0,DT.BLACK=!1;class OT{constructor(e,t=OT.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new OT(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,DT.BLACK,null,null))}remove(e){return new OT(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,DT.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 xT(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new xT(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new xT(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new xT(this.root_,null,this.comparator_,!0,e)}}function MT(e,t){return Pb(e.name,t.name)}function LT(e,t){return Pb(e,t)}OT.EMPTY_NODE=new class{copy(e,t,n,r,i){return this}insert(e,t,n){return new DT(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 FT;function UT(e){return"number"==typeof e?"number:"+Db(e):"string:"+e}function jT(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===FT||e.isEmpty(),"priority of unexpected type."),Jh(e===FT||e.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")}let qT;class VT{constructor(e,t=VT.__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."),jT(this.priorityNode_)}static set __childrenNodeConstructor(e){qT=e}static get __childrenNodeConstructor(){return qT}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new VT(this.value_,e)}getImmediateChild(e){return".priority"===e?this.priorityNode_:VT.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return vT(e)?this:".priority"===uT(e)?this.priorityNode_:VT.__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:VT.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){var n=uT(e);return null===n?t:t.isEmpty()&&".priority"!==n?this:(Jh(".priority"!==n||1===hT(e),".priority must be the last token in a path"),this.updateImmediateChild(n,VT.__childrenNodeConstructor.EMPTY_NODE.updateChild(dT(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:"+UT(this.priorityNode_.val())+":");var t=typeof this.value_;e+=t+":",e+="number"==t?Db(this.value_):this.value_,this.lazyHash_=lb(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===VT.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof VT.__childrenNodeConstructor?-1:(Jh(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){var t=typeof e.value_,n=typeof this.value_,r=VT.VALUE_TYPE_ORDER.indexOf(t),i=VT.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_))}}VT.VALUE_TYPE_ORDER=["object","boolean","number","string"];let BT,WT;const KT=new class extends AT{compare(e,t){const n=e.node.getPriority();var r=t.node.getPriority(),r=n.compareTo(r);return 0===r?Pb(e.name,t.name):r}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return CT.MIN}maxPost(){return new CT(Rb,new VT("[PRIORITY-POST]",WT))}makePost(e,t){var n=BT(e);return new CT(t,new VT("[PRIORITY-POST]",n))}toString(){return".priority"}},$T=Math.log(2);class zT{constructor(e){var t;this.count=(t=e+1,parseInt(Math.log(t)/$T,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 HT(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 DT(i,r.node,DT.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 DT(i,r.node,DT.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 DT(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,DT.BLACK):(t(r,DT.BLACK),t(r,DT.RED))}return o}(new zT(c.length));return new OT(t||e,n)}let GT;const QT={};class YT{constructor(e,t){this.indexes_=e,this.indexSet_=t}static get Default(){return Jh((QT,KT),"ChildrenNode.ts has not been loaded"),GT=GT||new YT({".priority":QT},{".priority":KT}),GT}get(e){var t=Td(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof OT?t:null}hasIndex(e){return bd(this.indexSet_,e.toString())}addIndex(e,t){Jh(e!==PT,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const n=[];let r=!1;const i=t.getIterator(CT.Wrap);let s=i.getNext();for(;s;)r=r||e.isDefinedOn(s.node),n.push(s),s=i.getNext();let o;o=r?HT(n,e.getCompare()):QT;var a=e.toString();const c=Object.assign({},this.indexSet_);c[a]=e;const l=Object.assign({},this.indexes_);return l[a]=o,new YT(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===QT){if(n.isDefinedOn(o.node)){const i=[],s=a.getIterator(CT.Wrap);let e=s.getNext();for(;e;)e.name!==o.name&&i.push(e),e=s.getNext();return i.push(o),HT(i,n.getCompare())}return QT}{var r=a.get(o.name);let e=t;return r&&(e=e.remove(new CT(o.name,r))),e.insert(o,o.node)}});return new YT(e,this.indexSet_)}removeFromIndexes(n,r){var e=Ed(this.indexes_,e=>{if(e===QT)return e;var t=r.get(n.name);return t?e.remove(new CT(n.name,t)):e});return new YT(e,this.indexSet_)}}let JT;class XT{constructor(e,t,n){this.children_=e,this.priorityNode_=t,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&jT(this.priorityNode_),this.children_.isEmpty()&&Jh(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}static get EMPTY_NODE(){return JT=JT||new XT(new OT(LT),null,YT.Default)}isLeafNode(){return!1}getPriority(){return this.priorityNode_||JT}updatePriority(e){return this.children_.isEmpty()?this:new XT(this.children_,e,this.indexMap_)}getImmediateChild(e){if(".priority"===e)return this.getPriority();var t=this.children_.get(e);return null===t?JT:t}getChild(e){var t=uT(e);return null===t?this:this.getImmediateChild(t).getChild(dT(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 CT(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()?JT:this.priorityNode_;return new XT(e,i,t)}}updateChild(e,t){var n=uT(e);if(null===n)return t;Jh(".priority"!==uT(e)||1===hT(e),".priority must be the last token in a path");var r=this.getImmediateChild(n).updateChild(dT(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(KT,(e,t)=>{r[e]=t.val(n),i++,o&&XT.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:"+UT(this.getPriority().val())+":"),this.forEachChild(KT,(e,t)=>{var n=t.hash();""!==n&&(r+=":"+e+":"+n)}),this.lazyHash_=""===r?"":lb(r)}return this.lazyHash_}getPredecessorChildName(e,t,n){const r=this.resolveIndex_(n);if(r){var i=r.getPredecessorKey(new CT(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 CT(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 CT(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,CT.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,CT.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===eI?-1:0}withIndex(e){if(e===PT||this.indexMap_.hasIndex(e))return this;var t=this.indexMap_.addIndex(e,this.children_);return new XT(this.children_,this.priorityNode_,t)}isIndexed(e){return e===PT||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(KT),i=n.getIterator(KT);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===PT?null:this.indexMap_.get(e.toString())}}XT.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class ZT extends XT{constructor(){super(new OT(LT),XT.EMPTY_NODE,YT.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return XT.EMPTY_NODE}isEmpty(){return!1}}const eI=new ZT;Object.defineProperties(CT,{MIN:{value:new CT(Nb,XT.EMPTY_NODE)},MAX:{value:new CT(Rb,eI)}}),RT.__EMPTY_NODE=XT.EMPTY_NODE,VT.__childrenNodeConstructor=XT,rb=eI,FT=rb,ib=eI,WT=ib;const tI=!0;function nI(i,e=null){if(null===i)return XT.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 VT(t,nI(e))}if(i instanceof Array||!tI){let r=XT.EMPTY_NODE;return xb(i,(e,t)=>{if(bd(i,e)&&"."!==e.substring(0,1)){const n=nI(t);!n.isLeafNode()&&n.isEmpty()||(r=r.updateImmediateChild(e,n))}}),r.updatePriority(nI(e))}{const s=[];let r=!1;if(xb(i,(e,t)=>{if("."!==e.substring(0,1)){const n=nI(t);n.isEmpty()||(r=r||!n.getPriority().isEmpty(),s.push(new CT(e,n)))}}),0===s.length)return XT.EMPTY_NODE;var n=HT(s,MT,e=>e.name,LT);if(r){t=HT(s,KT.getCompare());return new XT(n,nI(e),new YT({".priority":t},{".priority":KT}))}return new XT(n,nI(e),YT.Default)}}BT=nI;class rI extends AT{constructor(e){super(),this.indexPath_=e,Jh(!vT(e)&&".priority"!==uT(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?Pb(e.name,t.name):r}makePost(e,t){var n=nI(e),n=XT.EMPTY_NODE.updateChild(this.indexPath_,n);return new CT(t,n)}maxPost(){var e=XT.EMPTY_NODE.updateChild(this.indexPath_,eI);return new CT(Rb,e)}toString(){return fT(this.indexPath_,0).join("/")}}function iI(e){if(e===""+Fb)return cI;var t=Ub(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<uI)return n.push(cI),n.join("");let r=n.length-1;for(;0<=r&&n[r]===lI;)r--;return-1===r?Rb:(t=n[r],t=aI.charAt(aI.indexOf(t)+1),n[r]=t,n.slice(0,r+1).join(""))}function sI(e){if(e===""+Lb)return Nb;var t=Ub(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]===cI?1===n.length?""+Fb:(delete n[n.length-1],n.join("")):(n[n.length-1]=aI.charAt(aI.indexOf(n[n.length-1])-1),n.join("")+lI.repeat(uI-n.length))}const oI=new class extends AT{compare(e,t){var n=e.node.compareTo(t.node);return 0===n?Pb(e.name,t.name):n}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return CT.MIN}maxPost(){return CT.MAX}makePost(e,t){var n=nI(e);return new CT(t,n)}toString(){return".value"}},aI="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",cI="-",lI="z",uI=786,hI=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]=aI.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+=aI.charAt(o[n]);return Jh(20===i.length,"nextPushId: Length should be 20."),i}}();function dI(e){return{type:"value",snapshotNode:e}}function pI(e,t){return{type:"child_added",snapshotNode:t,childName:e}}function fI(e,t){return{type:"child_removed",snapshotNode:t,childName:e}}function gI(e,t,n){return{type:"child_changed",snapshotNode:t,childName:e,oldSnap:n}}class mI{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(fI(t,o)):Jh(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):o.isEmpty()?s.trackChildChange(pI(t,n)):s.trackChildChange(gI(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(KT,(e,t)=>{n.hasChild(e)||i.trackChildChange(fI(e,t))}),n.isLeafNode()||n.forEachChild(KT,(e,t)=>{if(r.hasChild(e)){const n=r.getImmediateChild(e);n.equals(t)||i.trackChildChange(gI(e,t,n))}else i.trackChildChange(pI(e,t))})),n.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?XT.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}class vI{constructor(e){this.indexedFilter_=new mI(e.getIndex()),this.index_=e.getIndex(),this.startPost_=vI.getStartPost_(e),this.endPost_=vI.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 CT(t,n))||(n=XT.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,n,r,i,s)}updateFullNode(e,t,n){let r=(t=t.isLeafNode()?XT.EMPTY_NODE:t).withIndex(this.index_);r=r.updatePriority(XT.EMPTY_NODE);const i=this;return t.forEachChild(KT,(e,t)=>{i.matches(new CT(e,t))||(r=r.updateImmediateChild(e,XT.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 yI{constructor(e){this.rangedFilter_=new vI(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 CT(t,n))||(n=XT.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=XT.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<o.numChildren()&&o.isIndexed(this.index_)){a=XT.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(XT.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,XT.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 CT(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(gI(t,n,u)),o.updateImmediateChild(t,n);{null!=i&&i.trackChildChange(fI(t,u));const p=o.updateImmediateChild(t,XT.EMPTY_NODE);return null!=e&&this.rangedFilter_.matches(e)?(null!=i&&i.trackChildChange(pI(e.name,e.node)),p.updateImmediateChild(e.name,e.node)):p}}return!n.isEmpty()&&l&&0<=s(c,a)?(null!=i&&(i.trackChildChange(fI(c.name,c.node)),i.trackChildChange(pI(t,n))),o.updateImmediateChild(t,n).updateImmediateChild(c.name,XT.EMPTY_NODE)):e}}class _I{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_=KT}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_:Nb}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_:Rb}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_===KT}copy(){const e=new _I;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 wI(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 bI(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 TI(e,t){const n=e.copy();return n.index_=t,n}function II(e){const t={};if(e.isDefault())return t;let n;return n=e.index_===KT?"$priority":e.index_===oI?"$value":e.index_===PT?"$key":(Jh(e.index_ instanceof rI,"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 EI(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_!==KT&&(n.i=t.index_.toString()),n}class kI extends sT{constructor(e,t,n,r){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=n,this.appCheckTokenProvider_=r,this.log_=vb("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=kI.getListenId_(e,r),a={};this.listens_[o]=a;var n=II(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=kI.getListenId_(e,t);delete this.listens_[n]}get(e){var t=II(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){Sb("Failed to parse JSON response for "+n+": "+r.responseText)}o(null,e)}else 401!==r.status&&404!==r.status&&Sb("Got unsuccessful REST response for "+n+" Status: "+r.status),o(r.status);o=null}},r.open("GET",n,!0),r.send()})}}class SI{constructor(){this.rootNode_=XT.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}function CI(){return{value:null,children:new Map}}function AI(e,t,n){var r;vT(t)?(e.value=n,e.children.clear()):null!==e.value?e.value=e.value.updateChild(t,n):(r=uT(t),e.children.has(r)||e.children.set(r,CI()),AI(e.children.get(r),t=dT(t),n))}function NI(e,n,r){var i;null!==e.value?r(n,e.value):(i=(e,t)=>{NI(t,new cT(n.toString()+"/"+e),r)},e.children.forEach((e,t)=>{i(t,e)}))}class RI{constructor(e){this.collection_=e,this.last_=null}get(){var e=this.collection_.get();const n=Object.assign({},e);return this.last_&&xb(this.last_,(e,t)=>{n[e]=n[e]-t}),this.last_=e,n}}class PI{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new RI(e);var n=1e4+2e4*Math.random();Ob(this.reportStats_.bind(this),Math.floor(n))}reportStats_(){var e=this.statsListener_.get();const n={};let r=!1;xb(e,(e,t)=>{0<t&&bd(this.statsToReport_,e)&&(n[e]=t,r=!0)}),r&&this.server_.reportStats(n),Ob(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))}}function xI(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function DI(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function OI(e){return{fromUser:!1,fromServer:!0,queryId:e,tagged:!0}}(z=sb=sb||{})[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 MI{constructor(e,t,n){this.path=e,this.affectedTree=t,this.revert=n,this.type=sb.ACK_USER_WRITE,this.source=xI()}operationForChild(e){if(vT(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 cT(e));return new MI(lT(),t,this.revert)}return Jh(uT(this.path)===e,"operationForChild called for unrelated child."),new MI(dT(this.path),this.affectedTree,this.revert)}}class LI{constructor(e,t){this.source=e,this.path=t,this.type=sb.LISTEN_COMPLETE}operationForChild(e){return vT(this.path)?new LI(this.source,lT()):new LI(this.source,dT(this.path))}}class FI{constructor(e,t,n){this.source=e,this.path=t,this.snap=n,this.type=sb.OVERWRITE}operationForChild(e){return vT(this.path)?new FI(this.source,lT(),this.snap.getImmediateChild(e)):new FI(this.source,dT(this.path),this.snap)}}class UI{constructor(e,t,n){this.source=e,this.path=t,this.children=n,this.type=sb.MERGE}operationForChild(e){if(vT(this.path)){const t=this.children.subtree(new cT(e));return t.isEmpty()?null:t.value?new FI(this.source,lT(),t.value):new UI(this.source,lT(),t)}return Jh(uT(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new UI(this.source,dT(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}class jI{constructor(e,t,n){this.node_=e,this.fullyInitialized_=t,this.filtered_=n}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(vT(e))return this.isFullyInitialized()&&!this.filtered_;var t=uT(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}class qI{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function VI(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}))}),BI(n,i,"child_removed",e,r,t),BI(n,i,"child_added",e,r,t),BI(n,i,"child_moved",s,r,t),BI(n,i,"child_changed",e,r,t),BI(n,i,"value",e,r,t),i}function BI(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 CT(t.childName,t.snapshotNode),i=new CT(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 WI(e,t){return{eventCache:e,serverCache:t}}function KI(e,t,n,r){return WI(new jI(t,n,r),e.serverCache)}function $I(e,t,n,r){return WI(e.eventCache,new jI(t,n,r))}function zI(e){return e.eventCache.isFullyInitialized()?e.eventCache.getNode():null}function HI(e){return e.serverCache.isFullyInitialized()?e.serverCache.getNode():null}let GI;class QI{constructor(e,t=(GI=GI||new OT(_b),GI)){this.value=e,this.children=t}static fromObject(e){let n=new QI(null);return xb(e,(e,t)=>{n=n.set(new cT(e),t)}),n}isEmpty(){return null===this.value&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(null!=this.value&&t(this.value))return{path:lT(),value:this.value};if(vT(e))return null;{var n=uT(e);const i=this.children.get(n);if(null===i)return null;var r=i.findRootMostMatchingPathAndValue(dT(e),t);return null==r?null:{path:mT(new cT(n),r.path),value:r.value}}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(vT(e))return this;{var t=uT(e);const n=this.children.get(t);return null!==n?n.subtree(dT(e)):new QI(null)}}set(e,t){if(vT(e))return new QI(t,this.children);{var n=uT(e);const i=this.children.get(n)||new QI(null);var r=i.set(dT(e),t),r=this.children.insert(n,r);return new QI(this.value,r)}}remove(t){if(vT(t))return this.children.isEmpty()?new QI(null):new QI(null,this.children);{var n=uT(t);const r=this.children.get(n);if(r){const i=r.remove(dT(t));let e;return e=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),null===this.value&&e.isEmpty()?new QI(null):new QI(this.value,e)}return this}}get(e){if(vT(e))return this.value;{var t=uT(e);const n=this.children.get(t);return n?n.get(dT(e)):null}}setTree(t,n){if(vT(t))return n;{var r=uT(t);const i=this.children.get(r)||new QI(null),s=i.setTree(dT(t),n);let e;return e=s.isEmpty()?this.children.remove(r):this.children.insert(r,s),new QI(this.value,e)}}fold(e){return this.fold_(lT(),e)}fold_(n,r){const i={};return this.children.inorderTraversal((e,t)=>{i[e]=t.fold_(mT(n,e),r)}),r(n,this.value,i)}findOnPath(e,t){return this.findOnPath_(e,lT(),t)}findOnPath_(e,t,n){var r=!!this.value&&n(t,this.value);if(r)return r;if(vT(e))return null;{r=uT(e);const i=this.children.get(r);return i?i.findOnPath_(dT(e),mT(t,r),n):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,lT(),t)}foreachOnPath_(e,t,n){if(vT(e))return this;{this.value&&n(t,this.value);var r=uT(e);const i=this.children.get(r);return i?i.foreachOnPath_(dT(e),mT(t,r),n):new QI(null)}}foreach(e){this.foreach_(lT(),e)}foreach_(n,r){this.children.inorderTraversal((e,t)=>{t.foreach_(mT(n,e),r)}),this.value&&r(n,this.value)}foreachChild(n){this.children.inorderTraversal((e,t)=>{t.value&&n(e,t.value)})}}class YI{constructor(e){this.writeTree_=e}static empty(){return new YI(new QI(null))}}function JI(t,n,r){if(vT(n))return new YI(new QI(r));var i=t.writeTree_.findRootMostValueAndPath(n);if(null!=i){var s=i.path;let e=i.value;i=yT(s,n);return e=e.updateChild(i,r),new YI(t.writeTree_.set(s,e))}s=new QI(r),s=t.writeTree_.setTree(n,s);return new YI(s)}function XI(e,n,t){let r=e;return xb(t,(e,t)=>{r=JI(r,mT(n,e),t)}),r}function ZI(e,t){if(vT(t))return YI.empty();var n=e.writeTree_.setTree(t,new QI(null));return new YI(n)}function e0(e,t){return null!=t0(e,t)}function t0(e,t){var n=e.writeTree_.findRootMostValueAndPath(t);return null!=n?e.writeTree_.get(n.path).getChild(yT(n.path,t)):null}function n0(e){const n=[],t=e.writeTree_.value;return null!=t?t.isLeafNode()||t.forEachChild(KT,(e,t)=>{n.push(new CT(e,t))}):e.writeTree_.children.inorderTraversal((e,t)=>{null!=t.value&&n.push(new CT(e,t.value))}),n}function r0(e,t){if(vT(t))return e;var n=t0(e,t);return null!=n?new YI(new QI(n)):new YI(e.writeTree_.subtree(t))}function i0(e){return e.writeTree_.isEmpty()}function s0(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(mT(i,e),t,s)}),s=!s.getChild(i).isEmpty()&&null!==n?s.updateChild(mT(i,".priority"),n):s}}}(lT(),e.writeTree_,t)}function o0(e,t){return y0(t,e)}function a0(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 bT(e.path,t);for(const n in e.children)if(e.children.hasOwnProperty(n)&&bT(mT(e.path,n),t))return!0;return!1}}(c,i.path)?s=!1:bT(i.path,c.path)&&(o=!0)),a--}return!!s&&(o?((e=t).visibleWrites=l0(e.allWrites,c0,lT()),0<e.allWrites.length?e.lastWriteId=e.allWrites[e.allWrites.length-1].writeId:e.lastWriteId=-1):i.snap?t.visibleWrites=ZI(t.visibleWrites,i.path):xb(i.children,e=>{t.visibleWrites=ZI(t.visibleWrites,mT(i.path,e))}),!0)}function c0(e){return e.visible}function l0(e,t,n){let r=YI.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)bT(n,i)?(e=yT(n,i),r=JI(r,e,o.snap)):bT(i,n)&&(e=yT(i,n),r=JI(r,lT(),o.snap.getChild(e)));else{if(!o.children)throw Xh("WriteRecord should have .snap or .children");if(bT(n,i))e=yT(n,i),r=XI(r,e,o.children);else if(bT(i,n))if(e=yT(i,n),vT(e))r=XI(r,lT(),o.children);else{const a=Td(o.children,uT(e));a&&(i=a.getChild(dT(e)),r=JI(r,lT(),i))}}}}return r}function u0(e,t,n,r,i){if(r||i){var s=r0(e.visibleWrites,t);if(!i&&i0(s))return n;if(i||null!=n||e0(s,lT()))return s0(l0(e.allWrites,function(e){return(e.visible||i)&&(!r||!~r.indexOf(e.writeId))&&(bT(e.path,t)||bT(t,e.path))},t),n||XT.EMPTY_NODE);return null}s=t0(e.visibleWrites,t);if(null!=s)return s;s=r0(e.visibleWrites,t);return i0(s)?n:null!=n||e0(s,lT())?s0(s,n||XT.EMPTY_NODE):null}function h0(e,t,n,r){return u0(e.writeTree,e.treePath,t,n,r)}function d0(e,t){return function(e,t,n){let r=XT.EMPTY_NODE;const i=t0(e.visibleWrites,t);if(i)return i.isLeafNode()||i.forEachChild(KT,(e,t)=>{r=r.updateImmediateChild(e,t)}),r;if(n){const s=r0(e.visibleWrites,t);return n.forEachChild(KT,(e,t)=>{var n=s0(r0(s,new cT(e)),t);r=r.updateImmediateChild(e,n)}),n0(s).forEach(e=>{r=r.updateImmediateChild(e.name,e.node)}),r}return n0(r0(e.visibleWrites,t)).forEach(e=>{r=r.updateImmediateChild(e.name,e.node)}),r}(e.writeTree,e.treePath,t)}function p0(e,t,n,r){return function(e,t,n,r,i){Jh(r||i,"Either existingEventSnap or existingServerSnap must exist");var s=mT(t,n);return e0(e.visibleWrites,s)?null:i0(s=r0(e.visibleWrites,s))?i.getChild(n):s0(s,i.getChild(n))}(e.writeTree,e.treePath,t,n,r)}function f0(e,t){return n=e.writeTree,t=mT(e.treePath,t),t0(n.visibleWrites,t);var n}function g0(e,t,n,r,i,s){return function(e,t,n,r,i,s,o){let a;var c=r0(e.visibleWrites,t),l=t0(c,lT());if(null!=l)a=l;else{if(null==n)return[];a=s0(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 m0(e,t,n){return r=e.writeTree,e=e.treePath,n=n,i=mT(e,t=t),null!=(s=t0(r.visibleWrites,i))?s:n.isCompleteForChild(t)?s0(r0(r.visibleWrites,i),n.getNode().getImmediateChild(t)):null;var r,i,s}function v0(e,t){return y0(mT(e.treePath,t),e.writeTree)}function y0(e,t){return{treePath:e,writeTree:t}}class _0{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,gI(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,fI(n,r.oldSnap));else if("child_changed"===t&&"child_added"===i)this.changeMap.set(n,pI(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,gI(n,e.snapshotNode,r.oldSnap))}}else this.changeMap.set(n,e)}getChanges(){return Array.from(this.changeMap.values())}}const w0=new class{getCompleteChild(e){return null}getChildAfterChild(e,t,n){return null}};class b0{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 jI(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return m0(this.writes_,e,n)}getChildAfterChild(e,t,n){var r=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:HI(this.viewCache_),r=g0(this.writes_,r,t,1,n,e);return 0===r.length?null:r[0]}}function T0(e,t,n,r,i){const s=new _0;let o,a;if(n.type===sb.OVERWRITE){var c=n;o=c.source.fromUser?k0(e,t,c.path,c.snap,r,i,s):(Jh(c.source.fromServer,"Unknown source."),a=c.source.tagged||t.serverCache.isFiltered()&&!vT(c.path),E0(e,t,c.path,c.snap,r,i,a,s))}else if(n.type===sb.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=mT(s,e);S0(i,uT(n))&&(l=k0(r,l,n,t,o,a,c))}),e.foreach((e,t)=>{var n=mT(s,e);S0(i,uT(n))||(l=k0(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(),A0(e,t,c.path,c.children,r,i,a,s))}else if(n.type===sb.ACK_USER_WRITE){var l=n;o=l.revert?function(n,r,i,s,e,o){let a;{if(null!=f0(s,i))return r;{var c=new b0(s,r,e);const u=r.eventCache.getNode();let t;if(vT(i)||".priority"===uT(i)){let e;e=r.serverCache.isFullyInitialized()?h0(s,HI(r)):(l=r.serverCache.getNode(),Jh(l instanceof XT,"serverChildren would be complete if leaf node"),d0(s,l)),e=e,t=n.filter.updateFullNode(u,e,o)}else{var l=uT(i);let e=m0(s,l,r.serverCache);null==e&&r.serverCache.isCompleteForChild(l)&&(e=u.getImmediateChild(l)),t=null!=e?n.filter.updateChild(u,l,e,dT(i),c,o):r.eventCache.getNode().hasChild(l)?n.filter.updateChild(u,l,XT.EMPTY_NODE,dT(i),c,o):u,t.isEmpty()&&r.serverCache.isFullyInitialized()&&(a=h0(s,HI(r)),a.isLeafNode()&&(t=n.filter.updateFullNode(t,a,o)))}return a=r.serverCache.isFullyInitialized()||null!=f0(s,lT()),KI(r,t,a,n.filter.filtersNodes())}}}(e,t,l.path,r,i,s):function(e,t,i,n,s,o,a){if(null!=f0(s,i))return t;const c=t.serverCache.isFiltered(),l=t.serverCache;{if(null!=n.value){if(vT(i)&&l.isFullyInitialized()||l.isCompleteForPath(i))return E0(e,t,i,l.getNode().getChild(i),s,o,c,a);if(vT(i)){let n=new QI(null);return l.getNode().forEachChild(PT,(e,t)=>{n=n.set(new cT(e),t)}),A0(e,t,i,n,s,o,c,a)}return t}{let r=new QI(null);return n.foreach((e,t)=>{var n=mT(i,e);l.isCompleteForPath(n)&&(r=r.set(e,l.getNode().getChild(n)))}),A0(e,t,i,r,s,o,c,a)}}}(e,t,l.path,l.affectedTree,r,i,s)}else{if(n.type!==sb.LISTEN_COMPLETE)throw Xh("Unknown operation type: "+n.type);o=function(e,t,n,r,i){const s=t.serverCache,o=$I(t,s.getNode(),s.isFullyInitialized()||vT(n),s.isFiltered());return I0(e,o,n,r,w0,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=zI(e);(0<n.length||!e.eventCache.isFullyInitialized()||i&&!r.getNode().equals(s)||!r.getNode().getPriority().equals(s.getPriority()))&&n.push(dI(zI(t)))}}(t,o,l),{viewCache:o,changes:l}}function I0(r,i,s,o,a,c){const l=i.eventCache;if(null!=f0(o,s))return i;{let t,n;if(vT(s)){var e;Jh(i.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),t=i.serverCache.isFiltered()?(e=d0(o,(e=HI(i))instanceof XT?e:XT.EMPTY_NODE),r.filter.updateFullNode(i.eventCache.getNode(),e,c)):(u=h0(o,HI(i)),r.filter.updateFullNode(i.eventCache.getNode(),u,c))}else{var u=uT(s);if(".priority"===u){Jh(1===hT(s),"Can't have a priority with additional path components");var h=l.getNode();n=i.serverCache.getNode();var d=p0(o,s,h,n);t=null!=d?r.filter.updatePriority(h,d):l.getNode()}else{h=dT(s);let e;e=l.isCompleteForChild(u)?(n=i.serverCache.getNode(),null!=(d=p0(o,s,l.getNode(),n))?l.getNode().getImmediateChild(u).updateChild(h,d):l.getNode().getImmediateChild(u)):m0(o,u,i.serverCache),t=null!=e?r.filter.updateChild(l.getNode(),u,e,h,a,c):l.getNode()}}return KI(i,t,l.isFullyInitialized()||vT(s),r.filter.filtersNodes())}}function E0(e,t,n,r,i,s,o,a){const c=t.serverCache;let l;const u=o?e.filter:e.filter.getIndexedFilter();if(vT(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=uT(n);if(!c.isCompleteForPath(n)&&1<hT(n))return t;var p=dT(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,w0,null)}p=$I(t,l,c.isFullyInitialized()||vT(n),u.filtersNodes());return I0(e,p,n,i,new b0(i,p,s),a)}function k0(t,n,r,i,e,s,o){const a=n.eventCache;let c,l;const u=new b0(e,n,s);if(vT(r))l=t.filter.updateFullNode(n.eventCache.getNode(),i,o),c=KI(n,l,!0,t.filter.filtersNodes());else{var h=uT(r);if(".priority"===h)l=t.filter.updatePriority(n.eventCache.getNode(),i),c=KI(n,l,a.isFullyInitialized(),a.isFiltered());else{var d=dT(r);const p=a.getNode().getImmediateChild(h);let e;if(vT(d))e=i;else{const f=u.getCompleteChild(h);e=null!=f?".priority"===pT(d)&&f.getChild(gT(d)).isEmpty()?f:f.updateChild(d,i):XT.EMPTY_NODE}c=p.equals(e)?n:KI(n,t.filter.updateChild(a.getNode(),h,e,d,u,o),a.isFullyInitialized(),t.filter.filtersNodes())}}return c}function S0(e,t){return e.eventCache.isCompleteForChild(t)}function C0(e,n,t){return t.foreach((e,t)=>{n=n.updateChild(e,t)}),n}function A0(r,i,e,t,s,o,a,c){if(i.serverCache.getNode().isEmpty()&&!i.serverCache.isFullyInitialized())return i;let l=i,n;n=vT(e)?t:new QI(null).setTree(e,t);const u=i.serverCache.getNode();return n.children.inorderTraversal((e,t)=>{var n;u.hasChild(e)&&(n=C0(0,i.serverCache.getNode().getImmediateChild(e),t),l=E0(r,l,new cT(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=C0(0,i.serverCache.getNode().getImmediateChild(e),t),l=E0(r,l,new cT(e),n,s,o,a,c))}),l}class N0{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const n=this.query_._queryParams,r=new mI(n.getIndex()),i=(e=n).loadsAllData()?new mI(e.getIndex()):new(e.hasLimit()?yI:vI)(e);this.processor_={filter:i};const s=t.serverCache,o=t.eventCache;var a=r.updateFullNode(XT.EMPTY_NODE,s.getNode(),null),c=i.updateFullNode(XT.EMPTY_NODE,o.getNode(),null),a=new jI(a,s.isFullyInitialized(),r.filtersNodes()),c=new jI(c,o.isFullyInitialized(),i.filtersNodes());this.viewCache_=WI(c,a),this.eventGenerator_=new qI(this.query_)}get query(){return this.query_}}function R0(e){return 0===e.eventRegistrations_.length}function P0(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 x0(e,t,n,r){t.type===sb.MERGE&&null!==t.source.queryId&&(Jh(HI(e.viewCache_),"We should always have a full cache before handling merges"),Jh(zI(e.viewCache_),"Missing event cache, even though we have a server cache"));const i=e.viewCache_,s=T0(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,D0(e,s.changes,s.viewCache.eventCache.getNode(),null)}function D0(e,t,n,r){var i=r?[r]:e.eventRegistrations_;return VI(e.eventGenerator_,t,n,i)}let O0;class M0{constructor(){this.views=new Map}}function L0(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."),x0(e,n,r,i)}{let e=[];for(const s of t.views.values())e=e.concat(x0(s,n,r,i));return e}}function F0(e,n,r,i,s){var o=n._queryIdentifier,o=e.views.get(o);if(o)return o;{let e=h0(r,s?i:null),t=!1;t=!!e||(e=i instanceof XT?d0(r,i):XT.EMPTY_NODE,!1);o=WI(new jI(e,t,!1),new jI(i,s,!1));return new N0(n,o)}}function U0(e,t,n,r,i,s){var o=F0(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(KT,(e,t)=>{r.push(pI(e,t))})}return n.isFullyInitialized()&&r.push(dI(n.getNode())),D0(e,r,n.getNode(),t)}(o,n)}function j0(e,t,n,r){var i=t._queryIdentifier;const s=[];let o=[];var a=K0(e);if("default"===i)for(var[c,l]of e.views.entries())o=o.concat(P0(l,n,r)),R0(l)&&(e.views.delete(c),l.query._queryParams.loadsAllData()||s.push(l.query));else{const u=e.views.get(i);u&&(o=o.concat(P0(u,n,r)),R0(u)&&(e.views.delete(i),u.query._queryParams.loadsAllData()||s.push(u.query)))}return a&&!K0(e)&&s.push((Jh(O0,"Reference.ts has not been loaded"),new O0(t._repo,t._path))),{removed:s,events:o}}function q0(e){const t=[];for(const n of e.views.values())n.query._queryParams.loadsAllData()||t.push(n);return t}function V0(e,t){let n=null;for(const r of e.views.values())n=n||function(e,t){const n=HI(e.viewCache_);return n&&(e.query._queryParams.loadsAllData()||!vT(t)&&!n.getImmediateChild(uT(t)).isEmpty())?n.getChild(t):null}(r,t);return n}function B0(e,t){const n=t._queryParams;if(n.loadsAllData())return $0(e);var r=t._queryIdentifier;return e.views.get(r)}function W0(e,t){return null!=B0(e,t)}function K0(e){return null!=$0(e)}function $0(e){for(const t of e.views.values())if(t.query._queryParams.loadsAllData())return t;return null}let z0;let H0=1;class G0{constructor(e){this.listenProvider_=e,this.syncPointTree_=new QI(null),this.pendingWriteTree_={visibleWrites:YI.empty(),allWrites:[],lastWriteId:-1},this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function Q0(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=JI(s.visibleWrites,o,a)),s.lastWriteId=c,i?rE(e,new FI(xI(),t,n)):[]}function Y0(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=XI(i.visibleWrites,s,o),i.lastWriteId=r;var a=QI.fromObject(n);return rE(e,new UI(xI(),t,a))}function J0(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(a0(e.pendingWriteTree_,t)){let t=new QI(null);return null!=r.snap?t=t.set(lT(),!0):xb(r.children,e=>{t=t.set(new cT(e),!0)}),rE(e,new MI(r.path,t,n))}return[]}function X0(e,t,n){return rE(e,new FI(DI(),t,n))}function Z0(n,e,t,r){var i=e._path,s=n.syncPointTree_.get(i);let o=[];if(s&&("default"===e._queryIdentifier||W0(s,e))){var a=j0(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)=>K0(t));if(s&&!a){const d=n.syncPointTree_.subtree(i);if(!d.isEmpty()){var c=d.fold((e,t,r)=>{if(t&&K0(t))return[$0(t)];{let n=[];return t&&(n=q0(t)),xb(r,(e,t)=>{n=n.concat(t)}),n}});for(let e=0;e<c.length;++e){var l=c[e],u=l.query,l=sE(n,l);n.listenProvider_.startListening(hE(u),oE(n,u),l.hashFn,l.onComplete)}}}!a&&0<h.length&&!r&&(s?n.listenProvider_.stopListening(hE(e),null):h.forEach(e=>{var t=n.queryToTagMap.get(aE(e));n.listenProvider_.stopListening(hE(e),t)})),function(e,t){for(let i=0;i<t.length;++i){const s=t[i];var n,r;s._queryParams.loadsAllData()||(n=aE(s),r=e.queryToTagMap.get(n),e.queryToTagMap.delete(n),e.tagToQueryMap.delete(r))}}(n,h)}return o}function eE(e,t,n){const r=t._path;let i=null,s=!1;e.syncPointTree_.foreachOnPath(r,(e,t)=>{var n=yT(e,r);i=i||V0(t,n),s=s||K0(t)});let o=e.syncPointTree_.get(r);o?(s=s||K0(o),i=i||V0(o,lT())):(o=new M0,e.syncPointTree_=e.syncPointTree_.set(r,o));let a;if(null!=i)a=!0;else{a=!1,i=XT.EMPTY_NODE;const d=e.syncPointTree_.subtree(r);d.foreachChild((e,t)=>{var n=V0(t,lT());n&&(i=i.updateImmediateChild(e,n))})}var c,l=W0(o,t);l||t._queryParams.loadsAllData()||(u=aE(t),Jh(!e.queryToTagMap.has(u),"View does not exist, but we have a tag"),c=H0++,e.queryToTagMap.set(u,c),e.tagToQueryMap.set(c,u));var u=o0(e.pendingWriteTree_,r);let h=U0(o,t,n,u,i,a);return l||s||(l=B0(o,t),h=h.concat(function(t,e,n){const r=e._path,i=oE(t,e),s=sE(t,n),o=t.listenProvider_.startListening(hE(e),i,s.hashFn,s.onComplete),a=t.syncPointTree_.subtree(r);if(i)Jh(!K0(a.value),"If we're adding a query, it shouldn't be shadowed");else{var c=a.fold((e,t,r)=>{if(!vT(e)&&t&&K0(t))return[$0(t).query];{let n=[];return t&&(n=n.concat(q0(t).map(e=>e.query))),xb(r,(e,t)=>{n=n.concat(t)}),n}});for(let e=0;e<c.length;++e){var l=c[e];t.listenProvider_.stopListening(hE(l),oE(t,l))}}return o}(e,t,l))),h}function tE(e,r,t){var n=e.pendingWriteTree_,i=e.syncPointTree_.findOnPath(r,(e,t)=>{var n=V0(t,yT(e,r));if(n)return n});return u0(n,r,i,t,!0)}function nE(e,t){const r=t._path;let i=null;e.syncPointTree_.foreachOnPath(r,(e,t)=>{var n=yT(e,r);i=i||V0(t,n)});let n=e.syncPointTree_.get(r);n?i=i||V0(n,lT()):(n=new M0,e.syncPointTree_=e.syncPointTree_.set(r,n));var s=null!=i;const o=s?new jI(i,!0,!1):null;var a=o0(e.pendingWriteTree_,t._path);return zI(F0(n,t,a,s?o.getNode():XT.EMPTY_NODE,s).viewCache_)}function rE(e,t){return function t(n,r,i,s){{if(vT(n.path))return iE(n,r,i,s);{const o=r.get(lT());null==i&&null!=o&&(i=V0(o,lT()));let e=[];const a=uT(n.path),c=n.operationForChild(a),l=r.children.get(a);if(l&&c){const u=i?i.getImmediateChild(a):null,h=v0(s,a);e=e.concat(t(c,l,u,h))}return o&&(e=e.concat(L0(o,n,s,i))),e}}}(t,e.syncPointTree_,null,o0(e.pendingWriteTree_,lT()))}function iE(s,e,o,a){var t=e.get(lT());null==o&&null!=t&&(o=V0(t,lT()));let c=[];return e.children.inorderTraversal((e,t)=>{var n=o?o.getImmediateChild(e):null,r=v0(a,e),i=s.operationForChild(e);i&&(c=c.concat(iE(i,t,n,r)))}),t&&(c=c.concat(L0(t,s,a,o))),c}function sE(i,t){const s=t.query,o=oE(i,s);return{hashFn:()=>{const e=t.viewCache_.serverCache.getNode()||XT.EMPTY_NODE;return e.hash()},onComplete:e=>{if("ok"===e)return o?function(e,t,n){if(s=cE(e,n)){var r=lE(s),i=r.path,s=r.queryId,r=yT(i,t);return uE(e,i,new LI(OI(s),r))}return[]}(i,s._path,o):(t=i,n=s._path,rE(t,new LI(DI(),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 Z0(i,s,null,r)}}}function oE(e,t){var n=aE(t);return e.queryToTagMap.get(n)}function aE(e){return e._path.toString()+"$"+e._queryIdentifier}function cE(e,t){return e.tagToQueryMap.get(t)}function lE(e){var t=e.indexOf("$");return Jh(-1!==t&&t<e.length-1,"Bad queryKey."),{queryId:e.substr(t+1),path:new cT(e.substr(0,t))}}function uE(e,t,n){var r=e.syncPointTree_.get(t);return Jh(r,"Missing sync point for query tag that we're tracking"),L0(r,n,o0(e.pendingWriteTree_,t),null)}function hE(e){return e._queryParams.loadsAllData()&&!e._queryParams.isDefault()?(Jh(z0,"Reference.ts has not been loaded"),new z0(e._repo,e._path)):e}class dE{constructor(e){this.node_=e}getImmediateChild(e){var t=this.node_.getImmediateChild(e);return new dE(t)}node(){return this.node_}}class pE{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){var t=mT(this.path_,e);return new pE(this.syncTree_,t)}node(){return tE(this.syncTree_,this.path_)}}function fE(e){return(e=e||{}).timestamp=e.timestamp||(new Date).getTime(),e}function gE(e,t,n){return e&&"object"==typeof e?(Jh(".sv"in e,"Unexpected leaf node or priority contents"),"string"==typeof e[".sv"]?mE(e[".sv"],t,n):"object"==typeof e[".sv"]?vE(e[".sv"],t):void Jh(!1,"Unexpected server value: "+JSON.stringify(e,null,2))):e}const mE=function(e,t,n){if("timestamp"===e)return n.timestamp;Jh(!1,"Unexpected server value: "+e)},vE=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},yE=function(e,t,n,r){return wE(t,new pE(n,e),r)},_E=function(e,t,n){return wE(e,new dE(t),n)};function wE(e,r,i){var t=e.getPriority().val(),n=gE(t,r.getImmediateChild(".priority"),i);let s;if(e.isLeafNode()){const o=e;t=gE(o.getValue(),r,i);return t!==o.getValue()||n!==o.getPriority().val()?new VT(t,nI(n)):e}{const a=e;return s=a,n!==a.getPriority().val()&&(s=s.updatePriority(new VT(n))),a.forEachChild(KT,(e,t)=>{var n=wE(t,r.getImmediateChild(e),i);n!==t&&(s=s.updateImmediateChild(e,n))}),s}}class bE{constructor(e="",t=null,n={children:{},childCount:0}){this.name=e,this.parent=t,this.node=n}}function TE(e,t){let n=t instanceof cT?t:new cT(t),r=e,i=uT(n);for(;null!==i;){var s=Td(r.node.children,i)||{children:{},childCount:0};r=new bE(i,r,s),n=dT(n),i=uT(n)}return r}function IE(e){return e.node.value}function EE(e,t){e.node.value=t,AE(e)}function kE(e){return 0<e.node.childCount}function SE(n,r){xb(n.node.children,(e,t)=>{r(new bE(e,n,t))})}function CE(e){return new cT(null===e.parent?e.name:CE(e.parent)+"/"+e.name)}function AE(e){var t,n,r,i;null!==e.parent&&(t=e.parent,n=e.name,r=function(e){return void 0===IE(e)&&!kE(e)}(e=e),i=bd(t.node.children,n),r&&i?(delete t.node.children[n],t.node.childCount--,AE(t)):r||i||(t.node.children[n]=e.node,t.node.childCount++,AE(t)))}function NE(e,t,n,r){r&&void 0===t||BE(Md(e,"value"),t,n)}function RE(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=[];xb(t,(e,t)=>{const n=new cT(e);if(BE(i,t,mT(r,n)),".priority"===pT(n)&&!VE(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=fT(i);for(let e=0;e<s.length;e++)if((".priority"!==s[e]||e!==s.length-1)&&!UE(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(_T);let e=null;for(r=0;r<n.length;r++){if(i=n[r],null!==e&&bT(e,i))throw new Error(t+"contains a path "+e.toString()+" that is ancestor of another path "+i.toString());e=i}}(i,s)}}function PE(e,t,n){if(!n||void 0!==t){if(Ab(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(!VE(t))throw new Error(Md(e,"priority")+"must be a valid Firebase priority (a string, finite number, server value, or null).")}}function xE(e,t,n,r){if(!(r&&void 0===n||UE(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 DE(e,t,n,r){n=n&&n.replace(/^\/*\.info(\/|$)/,"/"),WE(e,t,n,r)}function OE(e,t){if(".info"===uT(t))throw new Error(e+" failed = Can't modify data under /.info/")}const ME=/[\[\].#$\/\u0000-\u001F\u007F]/,LE=/[\[\].#$\u0000-\u001F\u007F]/,FE=10485760,UE=function(e){return"string"==typeof e&&0!==e.length&&!ME.test(e)},jE=function(e){return"string"==typeof e&&0!==e.length&&!LE.test(e)},qE=function(e){return e=e&&e.replace(/^\/*\.info(\/|$)/,"/"),jE(e)},VE=function(e){return null===e||"string"==typeof e||"number"==typeof e&&!Ab(e)||e&&"object"==typeof e&&bd(e,".sv")},BE=function(o,e,t){const a=t instanceof cT?new TT(t,o):t;if(void 0===e)throw new Error(o+"contains undefined "+ET(a));if("function"==typeof e)throw new Error(o+"contains a function "+ET(a)+" with contents = "+e.toString());if(Ab(e))throw new Error(o+"contains "+e.toString()+" "+ET(a));if("string"==typeof e&&e.length>FE/3&&Ud(e)>FE)throw new Error(o+"contains a string greater than "+FE+" utf8 bytes "+ET(a)+" ('"+e.substring(0,50)+"...')");if(e&&"object"==typeof e){let i=!1,s=!1;if(xb(e,(e,t)=>{if(".value"===e)i=!0;else if(".priority"!==e&&".sv"!==e&&(s=!0,!UE(e)))throw new Error(o+" contains an invalid key ("+e+") "+ET(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),IT(n),BE(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 '+ET(a)+" in addition to actual children.")}},WE=function(e,t,n,r){if(!(r&&void 0===n||jE(n)))throw new Error(Md(e,t)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},KE=function(e,t){var n=t.path.toString();if("string"!=typeof t.repoInfo.host||0===t.repoInfo.host.length||!UE(t.repoInfo.namespace)&&"localhost"!==t.repoInfo.host.split(":")[0]||0!==n.length&&!qE(n))throw new Error(Md(e,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')};class $E{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function zE(e,t){let n=null;for(let i=0;i<t.length;i++){const s=t[i];var r=s.getPath();null===n||wT(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 HE(e,t,n){zE(e,n),QE(e,e=>wT(e,t))}function GE(e,t,n){zE(e,n),QE(e,e=>bT(e,t)||bT(t,e))}function QE(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(),gb&&Eb("event: "+r.toString()),jb(t))}}(e.eventLists_[i]),e.eventLists_[i]=null):n=!1)}n&&(e.eventLists_=[]),e.recursionDepth_--}const YE="repo_interrupt",JE=25;class XE{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 $E,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=CI(),this.transactionQueueTree_=new bE,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function ZE(o,e,t){if(o.stats_=Jb(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 kI(o.repoInfo_,(e,t,n,r)=>{nk(o,e,t,n,r)},o.authTokenProvider_,o.appCheckProvider_),setTimeout(()=>rk(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 ST(o.repoInfo_,e,(e,t,n,r)=>{nk(o,e,t,n,r)},e=>{rk(o,e)},e=>{var n;n=o,xb(e,(e,t)=>{ik(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 PI(o.stats_,o.server_),n=e.toString(),Yb[n]||(Yb[n]=t()),Yb[n]),o.infoData_=new SI,o.infoSyncTree_=new G0({startListening:(e,t,n,r)=>{let i=[];const s=o.infoData_.getNode(e._path);return s.isEmpty()||(i=X0(o.infoSyncTree_,e._path,s),setTimeout(()=>{r("ok")},0)),i},stopListening:()=>{}}),ik(o,"connected",!1),o.serverSyncTree_=new G0({startListening:(r,e,t,i)=>(o.server_.listen(r,t,e,(e,t)=>{var n=i(e,t);GE(o.eventQueue_,r._path,n)}),[]),stopListening:(e,t)=>{o.server_.unlisten(e,t)}})}function ek(e){const t=e.infoData_.getNode(new cT(".info/serverTimeOffset"));var n=t.val()||0;return(new Date).getTime()+n}function tk(e){return fE({timestamp:ek(e)})}function nk(e,t,n,r,i){e.dataUpdateCount++;var s,o,a=new cT(t);n=e.interceptServerDataCallback_?e.interceptServerDataCallback_(t,n):n;let c=[];c=i?r?(s=Ed(n,e=>nI(e)),function(e,t,n,r){if(a=cE(e,r)){var i=lE(a),s=i.path,o=i.queryId,a=yT(s,t),i=QI.fromObject(n);return uE(e,s,new UI(OI(o),a,i))}return[]}(e.serverSyncTree_,a,s,i)):(s=nI(n),function(e,t,n,r){if(null==(s=cE(e,r)))return[];var i=(o=lE(s)).path,s=o.queryId,o=yT(i,t);return uE(e,i,new FI(OI(s),o,n))}(e.serverSyncTree_,a,s,i)):r?(o=Ed(n,e=>nI(e)),t=e.serverSyncTree_,i=a,r=o,o=QI.fromObject(r),rE(t,new UI(DI(),i,o))):(o=nI(n),X0(e.serverSyncTree_,a,o));let l=a;0<c.length&&(l=gk(e,a)),GE(e.eventQueue_,l,c)}function rk(e,t){ik(e,"connected",t),!1===t&&function(r){hk(r,"onDisconnectEvents");const i=tk(r),s=CI();NI(r.onDisconnect_,lT(),(e,t)=>{var n=yE(e,t,r.serverSyncTree_,i);AI(s,e,n)});let o=[];NI(s,lT(),(e,t)=>{o=o.concat(X0(r.serverSyncTree_,e,t));var n=_k(r,e);gk(r,n)}),r.onDisconnect_=CI(),GE(r.eventQueue_,lT(),o)}(e)}function ik(e,t,n){var r=new cT("/.info/"+t),i=nI(n);e.infoData_.updateSnapshot(r,i);i=X0(e.infoSyncTree_,r,i);GE(e.eventQueue_,r,i)}function sk(e){return e.nextWriteId_++}function ok(r,i,e,t,s){hk(r,"set",{path:i.toString(),value:e,priority:t});var n=tk(r);const o=nI(e,t);var a=tE(r.serverSyncTree_,i),n=_E(o,a,n);const c=sk(r);n=Q0(r.serverSyncTree_,i,n,c,!0);zE(r.eventQueue_,n),r.server_.put(i.toString(),o.val(!0),(e,t)=>{var n="ok"===e;n||Sb("set at "+i+" failed: "+e);n=J0(r.serverSyncTree_,c,!n);GE(r.eventQueue_,i,n),dk(0,s,e,t)});n=_k(r,i);gk(r,n),GE(r.eventQueue_,n,[])}function ak(n,r,i){n.server_.onDisconnectCancel(r.toString(),(e,t)=>{"ok"===e&&!function e(n,t){if(vT(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(KT,(e,t)=>{AI(n,new cT(e),t)}),e(n,t)}}if(0<n.children.size){var r=uT(t);return t=dT(t),n.children.has(r)&&e(n.children.get(r),t)&&n.children.delete(r),0===n.children.size}return!0}(n.onDisconnect_,r),dk(0,i,e,t)})}function ck(n,r,e,i){const s=nI(e);n.server_.onDisconnectPut(r.toString(),s.val(!0),(e,t)=>{"ok"===e&&AI(n.onDisconnect_,r,s),dk(0,i,e,t)})}function lk(e,t,n){let r;r=".info"===uT(t._path)?Z0(e.infoSyncTree_,t,n):Z0(e.serverSyncTree_,t,n),HE(e.eventQueue_,t._path,r)}function uk(e){e.persistentConnection_&&e.persistentConnection_.interrupt(YE)}function hk(e,...t){let n="";e.persistentConnection_&&(n=e.persistentConnection_.id+":"),Eb(n,...t)}function dk(e,r,i,s){r&&jb(()=>{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 pk(e,t,n){return tE(e.serverSyncTree_,t,n)||XT.EMPTY_NODE}function fk(t,e=t.transactionQueueTree_){if(e||yk(t,e),IE(e)){const n=vk(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=pk(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=yT(s,h.path);n=n.updateChild(a,h.currentOutputSnapshotRaw)}const c=n.val(!0),l=s;i.server_.put(l.toString(),c,t=>{hk(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(J0(i.serverSyncTree_,o[e].currentWriteId)),o[e].onComplete&&r.push(()=>o[e].onComplete(null,!0,o[e].currentOutputSnapshotResolved)),o[e].unwatcher();yk(i,TE(i.transactionQueueTree_,s)),fk(i,i.transactionQueueTree_),GE(i.eventQueue_,s,n);for(let t=0;t<r.length;t++)jb(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{Sb("transaction at "+l.toString()+" failed: "+t);for(let e=0;e<o.length;e++)o[e].status=4,o[e].abortReason=t}gk(i,s)}},r)}(t,CE(e),n)}else kE(e)&&SE(e,e=>{fk(t,e)})}function gk(e,t){var n=mk(e,t),r=CE(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=yT(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(J0(i.serverSyncTree_,h.currentWriteId,!0));else if(0===h.status)if(h.retryCount>=JE)e=!0,t="maxretry",n=n.concat(J0(i.serverSyncTree_,h.currentWriteId,!0));else{const d=pk(i,h.path,u);h.currentInputSnapshot=d;var c=s[r].update(d.val());if(void 0!==c){BE("transaction failed: Data returned ",c,h.path);let e=nI(c);"object"==typeof c&&null!=c&&bd(c,".priority")||(e=e.updatePriority(d.getPriority()));a=h.currentWriteId,c=tk(i),c=_E(e,d,c);h.currentOutputSnapshotRaw=e,h.currentOutputSnapshotResolved=c,h.currentWriteId=sk(i),u.splice(u.indexOf(a),1),n=n.concat(Q0(i.serverSyncTree_,h.path,c,h.currentWriteId,h.applyLocally)),n=n.concat(J0(i.serverSyncTree_,a,!0))}else e=!0,t="nodata",n=n.concat(J0(i.serverSyncTree_,h.currentWriteId,!0))}GE(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))))}yk(i,i.transactionQueueTree_);for(let e=0;e<l.length;e++)jb(l[e]);fk(i,i.transactionQueueTree_)}}(e,vk(e,n),r),r}function mk(e,t){let n,r=e.transactionQueueTree_;for(n=uT(t);null!==n&&void 0===IE(r);)r=TE(r,n),t=dT(t),n=uT(t);return r}function vk(e,t){const n=[];return function t(n,e,r){const i=IE(e);if(i)for(let e=0;e<i.length;e++)r.push(i[e]);SE(e,e=>{t(n,e,r)})}(e,t,n),n.sort((e,t)=>e.order-t.order),n}function yk(t,n){const r=IE(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,EE(n,0<r.length?r:void 0)}SE(n,e=>{yk(t,e)})}function _k(t,e){var n=CE(mk(t,e)),r=TE(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=>{wk(t,e)}),wk(t,r),function t(e,n,r,i){r&&!i&&n(e),SE(e,e=>{t(e,n,!0,i)}),r&&i&&n(e)}(r,e=>{wk(t,e)}),n}function wk(i,s){const o=IE(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(J0(i.serverSyncTree_,o[n].currentWriteId,!0)),o[n].onComplete&&a.push(o[n].onComplete.bind(null,new Error("set"),!1,null))));-1===t?EE(s,void 0):o.length=t+1,GE(i.eventQueue_,CE(s),e);for(let r=0;r<a.length;r++)jb(a[r])}}const bk=function(e,t){var n=Tk(e),r=n.namespace;"firebase.com"===n.domain&&kb(n.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),r&&"undefined"!==r||"localhost"===n.domain||kb("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),n.secure||Cb();var i="ws"===n.scheme||"wss"===n.scheme;return{repoInfo:new zb(n.host,n.secure,r,t,i,"",r!==n.subdomain),path:new cT(n.pathString)}},Tk=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]):Sb(`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 Ik{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 Ek{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 kk{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 Sk{constructor(e,t){this._repo=e,this._path=t}cancel(){const e=new rd;return ak(this._repo,this._path,e.wrapCallback(()=>{})),e.promise}remove(){OE("OnDisconnect.remove",this._path);const e=new rd;return ck(this._repo,this._path,null,e.wrapCallback(()=>{})),e.promise}set(e){OE("OnDisconnect.set",this._path),NE("OnDisconnect.set",e,this._path,!1);const t=new rd;return ck(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}setWithPriority(e,t){OE("OnDisconnect.setWithPriority",this._path),NE("OnDisconnect.setWithPriority",e,this._path,!1),PE("OnDisconnect.setWithPriority",t,!1);const n=new rd;return function(n,r,e,t,i){const s=nI(e,t);n.server_.onDisconnectPut(r.toString(),s.val(!0),(e,t)=>{"ok"===e&&AI(n.onDisconnect_,r,s),dk(0,i,e,t)})}(this._repo,this._path,e,t,n.wrapCallback(()=>{})),n.promise}update(e){OE("OnDisconnect.update",this._path),RE("OnDisconnect.update",e,this._path,!1);const t=new rd;return function(r,i,n,s){if(Id(n))return Eb("onDisconnect().update() called with empty data. Don't do anything."),dk(0,s,"ok",void 0);r.server_.onDisconnectMerge(i.toString(),n,(e,t)=>{"ok"===e&&xb(n,(e,t)=>{var n=nI(t);AI(r.onDisconnect_,mT(i,e),n)}),dk(0,s,e,t)})}(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}}class Ck{constructor(e,t,n,r){this._repo=e,this._path=t,this._queryParams=n,this._orderByCalled=r}get key(){return vT(this._path)?null:pT(this._path)}get ref(){return new Pk(this._repo,this._path)}get _queryIdentifier(){var e=EI(this._queryParams),e=bb(e);return"{}"===e?"default":e}get _queryObject(){return EI(this._queryParams)}isEqual(e){if(!((e=Kd(e))instanceof Ck))return!1;var t=this._repo===e._repo,n=wT(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 Ak(e,t){if(!0===e._orderByCalled)throw new Error(t+": You can't combine multiple orderBy calls.")}function Nk(e){let t=null,n=null;if(e.hasStart()&&(t=e.getIndexStartValue()),e.hasEnd()&&(n=e.getIndexEndValue()),e.getIndex()===PT){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()!==Nb)throw new Error(r);if("string"!=typeof t)throw new Error(i)}if(e.hasEnd()){if(e.getIndexEndName()!==Rb)throw new Error(r);if("string"!=typeof n)throw new Error(i)}}else if(e.getIndex()===KT){if(null!=t&&!VE(t)||null!=n&&!VE(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 rI||e.getIndex()===oI,"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 Rk(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 Pk extends Ck{constructor(e,t){super(e,t,new _I,!1)}get parent(){var e=gT(this._path);return null===e?null:new Pk(this._repo,e)}get root(){let e=this;for(;null!==e.parent;)e=e.parent;return e}}class xk{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 cT(e),n=Mk(this.ref,e);return new xk(this._node.getChild(t),n,KT)}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 xk(t,Mk(this.ref,e),KT)))}hasChild(e){var t=new cT(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 Dk(e,t){return(e=Kd(e))._checkNotDeleted("ref"),void 0!==t?Mk(e._root,t):e._root}function Ok(e,t){(e=Kd(e))._checkNotDeleted("refFromURL");const n=bk(t,e._repo.repoInfo_.nodeAdmin);KE("refFromURL",n);var r=n.repoInfo;return e._repo.repoInfo_.isCustomHost()||r.host===e._repo.repoInfo_.host||kb("refFromURL: Host name does not match the current database: (found "+r.host+" but expected "+e._repo.repoInfo_.host+")"),Dk(e,n.path.toString())}function Mk(e,t){return(null===uT((e=Kd(e))._path)?DE:WE)("child","path",t,!1),new Pk(e._repo,mT(e._path,t))}function Lk(e,t){e=Kd(e),OE("set",e._path),NE("set",t,e._path,!1);const n=new rd;return ok(e._repo,e._path,t,null,n.wrapCallback(()=>{})),n.promise}function Fk(e,t){RE("update",t,e._path,!1);const n=new rd;return function(i,s,e,o){hk(i,"update",{path:s.toString(),value:e});let n=!0;const r=tk(i),a={};if(xb(e,(e,t)=>{n=!1,a[e]=yE(mT(s,e),nI(t),i.serverSyncTree_,r)}),n)Eb("update() called with empty data. Don't do anything."),dk(0,o,"ok",void 0);else{const c=sk(i);var t=Y0(i.serverSyncTree_,s,a,c);zE(i.eventQueue_,t),i.server_.merge(s.toString(),e,(e,t)=>{var n="ok"===e;n||Sb("update at "+s+" failed: "+e);var r=J0(i.serverSyncTree_,c,!n),n=0<r.length?gk(i,s):s;GE(i.eventQueue_,n,r),dk(0,o,e,t)}),xb(e,e=>{var t=_k(i,mT(s,e));gk(i,t)}),GE(i.eventQueue_,s,[])}}(e._repo,e._path,t,n.wrapCallback(()=>{})),n.promise}function Uk(t){return t=Kd(t),r=t._repo,i=t,(null!=(e=nE(r.serverSyncTree_,i))?Promise.resolve(e):r.server_.get(i).then(e=>{var t=nI(e).withIndex(i._queryParams.getIndex()),n=X0(r.serverSyncTree_,i._path,t);return HE(r.eventQueue_,i._path,n),Promise.resolve(t)},e=>(hk(r,"get for query "+_d(i)+" failed: "+e),Promise.reject(new Error(e))))).then(e=>new xk(e,new Pk(t._repo,t._path),t._queryParams.getIndex()));var r,i,e}class jk{constructor(e){this.callbackContext=e}respondsTo(e){return"value"===e}createEvent(e,t){var n=t._queryParams.getIndex();return new Ik("value",this,new xk(e.snapshotNode,new Pk(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 Ek(this,e,t):null}matches(e){return e instanceof jk&&(!e.callbackContext||!this.callbackContext||e.callbackContext.matches(this.callbackContext))}hasAnyCallback(){return null!==this.callbackContext}}class qk{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 Ek(this,e,t):null}createEvent(e,t){Jh(null!=e.childName,"Child events should have a childName.");var n=Mk(new Pk(t._repo,t._path),e.childName),r=t._queryParams.getIndex();return new Ik(e.type,this,new xk(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 qk&&(this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)))}hasAnyCallback(){return!!this.callbackContext}}function Vk(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)=>{lk(n._repo,n,a),c(e,t)};o.userCallback=t.userCallback,o.context=t.context,t=o}o=new kk(t,s||void 0);const a="value"===e?new jk(o):new qk(e,o);return function(e,t,n){let r;r=".info"===uT(t._path)?eE(e.infoSyncTree_,t,n):eE(e.serverSyncTree_,t,n),HE(e.eventQueue_,t._path,r)}(n._repo,n,a),()=>lk(n._repo,n,a)}function Bk(e,t,n,r){return Vk(e,"value",t,n,r)}function Wk(e,t,n,r){return Vk(e,"child_added",t,n,r)}function Kk(e,t,n,r){return Vk(e,"child_changed",t,n,r)}function $k(e,t,n,r){return Vk(e,"child_moved",t,n,r)}function zk(e,t,n,r){return Vk(e,"child_removed",t,n,r)}function Hk(e,t,n){let r=null;var i=n?new kk(n):null;"value"===t?r=new jk(i):t&&(r=new qk(t,i)),lk(e._repo,e,r)}class Gk{}class Qk extends Gk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){NE("endAt",this._value,e._path,!0);var t=bI(e._queryParams,this._value,this._key);if(Rk(t),Nk(t),e._queryParams.hasEnd())throw new Error("endAt: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new Ck(e._repo,e._path,t,e._orderByCalled)}}class Yk extends Gk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){NE("endBefore",this._value,e._path,!1);var t=function(e,t,n){let r,i;return i=e.index_===PT?bI(e,t="string"==typeof t?sI(t):t,n):(r=null==n?Nb:sI(n),bI(e,t,r)),i.endBeforeSet_=!0,i}(e._queryParams,this._value,this._key);if(Rk(t),Nk(t),e._queryParams.hasEnd())throw new Error("endBefore: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new Ck(e._repo,e._path,t,e._orderByCalled)}}class Jk extends Gk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){NE("startAt",this._value,e._path,!0);var t=wI(e._queryParams,this._value,this._key);if(Rk(t),Nk(t),e._queryParams.hasStart())throw new Error("startAt: Starting point was already set (by another call to startAt, startBefore or equalTo).");return new Ck(e._repo,e._path,t,e._orderByCalled)}}class Xk extends Gk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){NE("startAfter",this._value,e._path,!1);var t=function(t,n,r){let i;if(t.index_===PT)"string"==typeof n&&(n=iI(n)),i=wI(t,n,r);else{let e;e=null==r?Rb:iI(r),i=wI(t,n,e)}return i.startAfterSet_=!0,i}(e._queryParams,this._value,this._key);if(Rk(t),Nk(t),e._queryParams.hasStart())throw new Error("startAfter: Starting point was already set (by another call to startAt, startAfter, or equalTo).");return new Ck(e._repo,e._path,t,e._orderByCalled)}}class Zk extends Gk{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 Ck(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 eS extends Gk{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 Ck(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 tS extends Gk{constructor(e){super(),this._path=e}_apply(e){Ak(e,"orderByChild");var t=new cT(this._path);if(vT(t))throw new Error("orderByChild: cannot pass in empty path. Use orderByValue() instead.");t=new rI(t),t=TI(e._queryParams,t);return Nk(t),new Ck(e._repo,e._path,t,!0)}}class nS extends Gk{_apply(e){Ak(e,"orderByKey");var t=TI(e._queryParams,PT);return Nk(t),new Ck(e._repo,e._path,t,!0)}}class rS extends Gk{_apply(e){Ak(e,"orderByPriority");var t=TI(e._queryParams,KT);return Nk(t),new Ck(e._repo,e._path,t,!0)}}class iS extends Gk{_apply(e){Ak(e,"orderByValue");var t=TI(e._queryParams,oI);return Nk(t),new Ck(e._repo,e._path,t,!0)}}class sS extends Gk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){if(NE("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 Qk(this._value,this._key)._apply(new Jk(this._value,this._key)._apply(e))}}function oS(e,...t){let n=Kd(e);for(const r of t)n=r._apply(n);return n}ob=Pk,Jh(!O0,"__referenceConstructor has already been defined"),O0=ob,ab=Pk,Jh(!z0,"__referenceConstructor has already been defined"),z0=ab;const aS="FIREBASE_DATABASE_EMULATOR_HOST",cS={};let lS=!1;function uS(e,t,n,r,i){let s=r||e.options.databaseURL;void 0===s&&(e.options.projectId||kb("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),Eb("Using default host for project ",e.options.projectId),s=`${e.options.projectId}-default-rtdb.firebaseio.com`);let o=bk(s,i),a=o.repoInfo,c,l=void 0;"undefined"!=typeof process&&(l=process.env[aS]),l?(c=!0,s=`http://${l}?ns=${a.namespace}`,o=bk(s,i),a=o.repoInfo):c=!o.repoInfo.secure;var u=i&&c?new Bb(Bb.OWNER):new Vb(e.name,e.options,t);KE("Invalid Firebase Database URL",o),vT(o.path)||kb("Database URL must point to the root of a Firebase Database (not including a child path).");u=function(e,t,n,r){let i=cS[t.name];i||(i={},cS[t.name]=i);var s=i[e.toURLString()];s&&kb("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call.");return s=new XE(e,lS,n,r),i[e.toURLString()]=s}(a,e,u,new qb(e.name,n));return new hS(u,e)}class hS{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(ZE(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new Pk(this._repo,lT())),this._rootInternal}_delete(){return null!==this._rootInternal&&(function(e,t){const n=cS[t];n&&n[e.key]===e||kb(`Database ${t}(${e.repoInfo_}) has already been deleted.`),uk(e),delete n[e.key]}(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){null===this._rootInternal&&kb("Cannot call "+e+" on a deleted database.")}}function dS(e,t,n,r={}){(e=Kd(e))._checkNotDeleted("useEmulator"),e._instanceStarted&&kb("Cannot call useEmulator() after instance has already been initialized.");var i,s=e._repoInternal;let o=void 0;s.repoInfo_.nodeAdmin?(r.mockUserToken&&kb('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 Bb(Bb.OWNER)):r.mockUserToken&&(i="string"==typeof r.mockUserToken?r.mockUserToken:id(r.mockUserToken,e.app.options.projectId),o=new Bb(i)),r=s,e=t,t=n,n=o,r.repoInfo_=new zb(`${e}:${t}`,!1,r.repoInfo_.namespace,r.repoInfo_.webSocketOnly,r.repoInfo_.nodeAdmin,r.repoInfo_.persistenceKey,r.repoInfo_.includeNamespaceInQueryParams),n&&(r.authTokenProvider_=n)}function pS(e){(e=Kd(e))._checkNotDeleted("goOnline"),(e=e._repo).persistentConnection_&&e.persistentConnection_.resume(YE)}function fS(e,t){Ib(e,t)}const gS={".sv":"timestamp"};class mS{constructor(e,t){this.committed=e,this.snapshot=t}toJSON(){return{committed:this.committed,snapshot:this.snapshot.toJSON()}}}function vS(i,e,t){if(i=Kd(i),OE("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=Bk(i,()=>{});return function(t,n,e,r,i,s){hk(t,"transaction on "+n);const o={path:n,update:e,onComplete:r,status:null,order:pb(),applyLocally:s,retryCount:0,unwatcher:i,abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},a=pk(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{BE("transaction failed: Data returned ",c,o.path),o.status=0;var l=TE(t.transactionQueueTree_,n);const u=IE(l)||[];u.push(o),EE(l,u);let e;if("object"==typeof c&&null!==c&&bd(c,".priority"))e=Td(c,".priority"),Jh(VE(e),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.");else{const h=tE(t.serverSyncTree_,n)||XT.EMPTY_NODE;e=h.getPriority().val()}l=tk(t),c=nI(c,e),l=_E(c,a,l);o.currentOutputSnapshotRaw=c,o.currentOutputSnapshotResolved=l,o.currentWriteId=sk(t);l=Q0(t.serverSyncTree_,n,l,o.currentWriteId,o.applyLocally);GE(t.eventQueue_,n,l),fk(t,t.transactionQueueTree_)}}(i._repo,i._path,e,(e,t,n)=>{var r;e?s.reject(e):(r=new xk(n,new Pk(i._repo,i._path),KT),s.resolve(new mS(t,r)))},r,n),s.promise}ST.prototype.simpleListen=function(e,t){this.sendRequest("q",{p:e},t)},ST.prototype.echo=function(e,t){this.sendRequest("echo",{d:e},t)},eb(mp),dp(new $d("database",(e,{instanceIdentifier:t})=>{return uS(e.getProvider("app").getImmediate(),e.getProvider("auth-internal"),e.getProvider("app-check-internal"),t)},"PUBLIC").setMultipleInstances(!0)),wp(Jw,Xw,cb),wp(Jw,Xw,"esm2017");function yS(e){var t="FIREBASE WARNING: "+e;_S.warn(t)}const _S=new ep("@firebase/database-compat");class wS{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,yS("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 bS{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 TS{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),WE("DataSnapshot.child","path",e,!1),new TS(this._database,this._delegate.child(e))}hasChild(e){return Od("DataSnapshot.hasChild",1,1,arguments.length),WE("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 TS(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 ES(this._database,this._delegate.ref)}get ref(){return this.getRef()}}class IS{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=IS.getCancelAndContextArgs_("Query.on",t,r);var o=(e,t)=>{n.call(s.context,new TS(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 Bk(this._delegate,o,a),n;case"child_added":return Wk(this._delegate,o,a),n;case"child_removed":return zk(this._delegate,o,a),n;case"child_changed":return Kk(this._delegate,o,a),n;case"child_moved":return $k(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,Hk(this._delegate,e,r)):Hk(this._delegate,e)}get(){return Uk(this._delegate).then(e=>new TS(this.database,e))}once(e,r,t,n){Od("Query.once",1,4,arguments.length),Ld("Query.once","callback",r,!0);const i=IS.getCancelAndContextArgs_("Query.once",t,n),s=new rd;var o=(e,t)=>{var n=new TS(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":Bk(this._delegate,o,a,{onlyOnce:!0});break;case"child_added":Wk(this._delegate,o,a,{onlyOnce:!0});break;case"child_removed":zk(this._delegate,o,a,{onlyOnce:!0});break;case"child_changed":Kk(this._delegate,o,a,{onlyOnce:!0});break;case"child_moved":$k(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 IS(this.database,oS(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 Zk(e)}(e)))}limitToLast(e){return Od("Query.limitToLast",1,1,arguments.length),new IS(this.database,oS(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 eS(e)}(e)))}orderByChild(e){return Od("Query.orderByChild",1,1,arguments.length),new IS(this.database,oS(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 WE("orderByChild","path",e,!1),new tS(e)}(e)))}orderByKey(){return Od("Query.orderByKey",0,0,arguments.length),new IS(this.database,oS(this._delegate,new nS))}orderByPriority(){return Od("Query.orderByPriority",0,0,arguments.length),new IS(this.database,oS(this._delegate,new rS))}orderByValue(){return Od("Query.orderByValue",0,0,arguments.length),new IS(this.database,oS(this._delegate,new iS))}startAt(e=null,t){return Od("Query.startAt",0,2,arguments.length),new IS(this.database,oS(this._delegate,([e=null,t]=[e,t],xE("startAt","key",t,!0),new Jk(e,t))))}startAfter(e=null,t){return Od("Query.startAfter",0,2,arguments.length),new IS(this.database,oS(this._delegate,(e=e,t=t,xE("startAfter","key",t,!0),new Xk(e,t))))}endAt(e=null,t){return Od("Query.endAt",0,2,arguments.length),new IS(this.database,oS(this._delegate,(e=e,t=t,xE("endAt","key",t,!0),new Qk(e,t))))}endBefore(e=null,t){return Od("Query.endBefore",0,2,arguments.length),new IS(this.database,oS(this._delegate,(e=e,t=t,xE("endBefore","key",t,!0),new Yk(e,t))))}equalTo(e,t){return Od("Query.equalTo",1,2,arguments.length),new IS(this.database,oS(this._delegate,(e=e,t=t,xE("equalTo","key",t,!0),new sS(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 IS)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 ES(this.database,new Pk(this._delegate._repo,this._delegate._path))}}class ES extends IS{constructor(e,t){super(e,new Ck(t._repo,t._path,new _I,!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 ES(this.database,Mk(this._delegate,e))}getParent(){Od("Reference.parent",0,0,arguments.length);var e=this._delegate.parent;return e?new ES(this.database,e):null}getRoot(){return Od("Reference.root",0,0,arguments.length),new ES(this.database,this._delegate.root)}set(e,t){Od("Reference.set",1,2,arguments.length),Ld("Reference.set","onComplete",t,!0);const n=Lk(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,yS("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.")}OE("Reference.update",this._delegate._path),Ld("Reference.update","onComplete",n,!0);const e=Fk(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(OE("setWithPriority",e._path),NE("setWithPriority",t,e._path,!1),PE("setWithPriority",n,!1),".length"===e.key||".keys"===e.key)throw"setWithPriority failed: "+e.key+" is a read-only object.";const r=new rd;return ok(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,OE("remove",n._path),Lk(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=vS(this._delegate,e,{applyLocally:n}).then(e=>new bS(e.committed,new TS(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),OE("setPriority",e._path),PE("setPriority",t,!1);const n=new rd;return ok(e._repo,mT(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),OE("push",e._path),NE("push",t,e._path,!0);var n=ek(e._repo),n=hI(n);const r=Mk(e,n),i=Mk(e,n);let s;return s=null!=t?Lk(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 ES(this.database,e));t&&r.then(()=>t(null),e=>t(e));const i=new ES(this.database,n);return i.then=r.then.bind(r),i.catch=r.catch.bind(r,void 0),i}onDisconnect(){return OE("Reference.onDisconnect",this._delegate._path),new wS(new Sk(this._delegate._repo,this._delegate._path))}get key(){return this.getKey()}get parent(){return this.getParent()}get root(){return this.getRoot()}}class kS{constructor(e,t){this._delegate=e,this.app=t,this.INTERNAL={delete:()=>this._delegate._delete()}}useEmulator(e,t,n={}){dS(this._delegate,e,t,n)}ref(e){if(Od("database.ref",0,1,arguments.length),e instanceof ES){var t=Ok(this._delegate,e.toString());return new ES(this,t)}t=Dk(this._delegate,e);return new ES(this,t)}refFromURL(e){Od("database.refFromURL",1,1,arguments.length);var t=Ok(this._delegate,e);return new ES(this,t)}goOffline(){var e;Od("database.goOffline",0,0,arguments.length),(e=Kd(e=this._delegate))._checkNotDeleted("goOffline"),uk(e._repo)}goOnline(){return Od("database.goOnline",0,0,arguments.length),pS(this._delegate)}}kS.ServerValue={TIMESTAMP:gS,increment:e=>({".sv":{increment:e}})};var SS,CS=Object.freeze({__proto__:null,initStandalone:function({app:e,url:t,version:n,customAuthImpl:r,namespace:i,nodeAdmin:s=!1}){eb(n);const o=new Hd("auth-internal",new Gd("database-standalone"));return o.setComponent(new $d("auth-internal",()=>r,"PRIVATE")),{instance:new kS(uS(e,o,void 0,t,s),e),namespace:i}}});const AS=kS.ServerValue;(SS=Ap).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 kS(r,n)},"PUBLIC").setServiceProps({Reference:ES,Query:IS,Database:kS,DataSnapshot:TS,enableLogging:fS,INTERNAL:CS,ServerValue:AS}).setMultipleInstances(!0)),SS.registerVersion("@firebase/database-compat","0.1.5-canary.044a8d7f9");var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},NS={},RS=l||self;function PS(){}function xS(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 DS(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}var OS="closure_uid_"+(1e9*Math.random()>>>0),MS=0;function LS(e,t,n){return e.call.apply(e.bind,arguments)}function FS(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 US(e,t,n){return(US=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?LS:FS).apply(null,arguments)}function jS(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 qS(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 VS(){this.s=this.s,this.o=this.o}var BS={};VS.prototype.s=!1,VS.prototype.na=function(){var e,t;!this.s&&(this.s=!0,this.M(),0)&&(t=this,e=Object.prototype.hasOwnProperty.call(t,OS)&&t[OS]||(t[OS]=++MS),delete BS[e])},VS.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};const WS=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},KS=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 $S(){return Array.prototype.concat.apply([],arguments)}function zS(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 HS(e){return/^[\s\xa0]*$/.test(e)}var GS,QS=String.prototype.trim?function(e){return e.trim()}:function(e){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(e)[1]};function YS(e,t){return-1!=e.indexOf(t)}function JS(e,t){return e<t?-1:t<e?1:0}e:{var XS=RS.navigator;if(XS){XS=XS.userAgent;if(XS){GS=XS;break e}}GS=""}function ZS(e,t,n){for(const r in e)t.call(n,e[r],r,e)}function eC(e){const t={};for(const n in e)t[n]=e[n];return t}var tC="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function nC(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<tC.length;e++)n=tC[e],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function rC(e){return rC[" "](e),e}rC[" "]=PS;var iC,sC=YS(GS,"Opera"),oC=YS(GS,"Trident")||YS(GS,"MSIE"),aC=YS(GS,"Edge"),cC=aC||oC,lC=YS(GS,"Gecko")&&!(YS(GS.toLowerCase(),"webkit")&&!YS(GS,"Edge"))&&!(YS(GS,"Trident")||YS(GS,"MSIE"))&&!YS(GS,"Edge"),uC=YS(GS.toLowerCase(),"webkit")&&!YS(GS,"Edge");function hC(){var e=RS.document;return e?e.documentMode:void 0}e:{var dC="",pC=(pC=GS,lC?/rv:([^\);]+)(\)|;)/.exec(pC):aC?/Edge\/([\d\.]+)/.exec(pC):oC?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(pC):uC?/WebKit\/(\S+)/.exec(pC):sC?/(?:Version)[ \/]?(\S+)/.exec(pC):void 0);if(pC&&(dC=pC?pC[1]:""),oC){pC=hC();if(null!=pC&&pC>parseFloat(dC)){iC=String(pC);break e}}iC=dC}var fC={};function gC(){return e=function(){let e=0;var t=QS(String(iC)).split("."),n=QS("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=JS(0==i[1].length?0:parseInt(i[1],10),0==s[1].length?0:parseInt(s[1],10))||JS(0==i[2].length,0==s[2].length)||JS(i[2],s[2]),i=i[3],s=s[3],0==e););return 0<=e},t=fC,Object.prototype.hasOwnProperty.call(t,9)?t[9]:t[9]=e(9);var e,t}var mC=RS.document&&oC&&(hC()||parseInt(iC,10))||void 0,vC=function(){if(!RS.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{RS.addEventListener("test",PS,t),RS.removeEventListener("test",PS,t)}catch(e){}return e}();function yC(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}function _C(e,t){if(yC.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(lC){e:{try{rC(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:wC[e.pointerType]||"",this.state=e.state,(this.i=e).defaultPrevented&&_C.Z.h.call(this)}}yC.prototype.h=function(){this.defaultPrevented=!0},qS(_C,yC);var wC={2:"touch",3:"pen",4:"mouse"};_C.prototype.h=function(){_C.Z.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var bC="closure_listenable_"+(1e6*Math.random()|0),TC=0;function IC(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=++TC,this.ca=this.fa=!1}function EC(e){e.ca=!0,e.listener=null,e.proxy=null,e.src=null,e.ia=null}function kC(e){this.src=e,this.g={},this.h=0}function SC(e,t){var n,r,i,s=t.type;s in e.g&&(n=e.g[s],(i=0<=(r=WS(n,t)))&&Array.prototype.splice.call(n,r,1),i&&(EC(t),0==e.g[s].length&&(delete e.g[s],e.h--)))}function CC(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}kC.prototype.add=function(e,t,n,r,i){var s=e.toString();(e=this.g[s])||(e=this.g[s]=[],this.h++);var o=CC(e,t,r,i);return-1<o?(t=e[o],n||(t.fa=!1)):((t=new IC(t,this.src,s,!!r,i)).fa=n,e.push(t)),t};var AC="closure_lm_"+(1e6*Math.random()|0),NC={};function RC(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=FC(r);return t&&t[bC]?t.O(n,r,DS(i)?!!i.capture:!!i,s):PC(t,n,r,!0,i,s)}(e,t,n,r,i);if(Array.isArray(t)){for(var s=0;s<t.length;s++)RC(e,t[s],n,r,i);return null}return n=FC(n),e&&e[bC]?e.N(t,n,DS(r)?!!r.capture:!!r,i):PC(e,t,n,!1,r,i)}function PC(e,t,n,r,i,s){if(!t)throw Error("Invalid event type");var o,a=DS(i)?!!i.capture:!!i,c=MC(e);if(c||(e[AC]=c=new kC(e)),(n=c.add(t,n,r,a,s)).proxy)return n;if(o=OC,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=!vC?a:i)&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(DC(t.toString()),r);else{if(!e.addListener||!e.removeListener)throw Error("addEventListener and attachEvent are unavailable.");e.addListener(r)}return n}function xC(e){var t,n,r;"number"!=typeof e&&e&&!e.ca&&((t=e.src)&&t[bC]?SC(t.i,e):(n=e.type,r=e.proxy,t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(DC(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=MC(t))?(SC(n,e),0==n.h&&(n.src=null,t[AC]=null)):EC(e)))}function DC(e){return e in NC?NC[e]:NC[e]="on"+e}function OC(e,t){var n,r;return e=!!e.ca||(t=new _C(t,this),n=e.listener,r=e.ia||e.src,e.fa&&xC(e),n.call(r,t))}function MC(e){return(e=e[AC])instanceof kC?e:null}var LC="__closure_events_fn_"+(1e9*Math.random()>>>0);function FC(t){return"function"==typeof t?t:(t[LC]||(t[LC]=function(e){return t.handleEvent(e)}),t[LC])}function UC(){VS.call(this),this.i=new kC(this),(this.P=this).I=null}function jC(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 yC(t,e):t instanceof yC?t.target=t.target||e:(o=t,nC(t=new yC(r,e),o)),o=!0,n)for(var i=n.length-1;0<=i;i--)var s=t.g=n[i],o=qC(s,r,!0,t)&&o;if(o=qC(s=t.g=e,r,!0,t)&&o,o=qC(s,r,!1,t)&&o,n)for(i=0;i<n.length;i++)o=qC(s=t.g=n[i],r,!1,t)&&o}function qC(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&&SC(e.i,c),i=!1!==o.call(a,r)&&i)}return i&&!r.defaultPrevented}qS(UC,VS),UC.prototype[bC]=!0,UC.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=DS(i)?!!i.capture:!!i,r=FC(r),t&&t[bC]?(t=t.i,(n=String(n).toString())in t.g&&-1<(r=CC(o=t.g[n],r,i,s))&&(EC(o[r]),Array.prototype.splice.call(o,r,1),0==o.length&&(delete t.g[n],t.h--))):(t=t&&MC(t))&&(n=t.g[n.toString()],(r=(t=-1)<(t=n?CC(n,r,i,s):t)?n[t]:null)&&xC(r))}(this,e,t,n,r)},UC.prototype.M=function(){if(UC.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++)EC(n[r]);delete t.g[e],t.h--}}this.I=null},UC.prototype.N=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},UC.prototype.O=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};var VC=RS.JSON.stringify;var BC,WC=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 KC,e=>e.reset());class KC{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 $C(e,t){var n;BC||(n=RS.Promise.resolve(void 0),BC=function(){n.then(GC)}),zC||(BC(),zC=!0),HC.add(e,t)}var zC=!1,HC=new class{constructor(){this.h=this.g=null}add(e,t){const n=WC.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}};function GC(){for(var e;e=function(){var e=HC;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){RS.setTimeout(()=>{throw e},0)}(e)}var t=WC;t.j(e),t.h<100&&(t.h++,e.next=t.g,t.g=e)}zC=!1}function QC(e,t){UC.call(this),this.h=e||1,this.g=t||RS,this.j=US(this.kb,this),this.l=Date.now()}function YC(e){e.da=!1,e.S&&(e.g.clearTimeout(e.S),e.S=null)}function JC(e,t,n){if("function"==typeof e)n&&(e=US(e,n));else{if(!e||"function"!=typeof e.handleEvent)throw Error("Invalid listener argument");e=US(e.handleEvent,e)}return 2147483647<Number(t)?-1:RS.setTimeout(e,t||0)}qS(QC,UC),(ze=QC.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),jC(this,"tick"),this.da&&(YC(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(){QC.Z.M.call(this),YC(this),delete this.g};class XC extends VS{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=JC(()=>{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&&(RS.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function ZC(e){VS.call(this),this.h=e,this.g={}}qS(ZC,VS);var eA=[];function tA(e,t,n,r){Array.isArray(n)||(n&&(eA[0]=n.toString()),n=eA);for(var i=0;i<n.length;i++){var s=RC(t,n[i],r||e.handleEvent,!1,e.h||e);if(!s)break;e.g[s.key]=s}}function nA(e){ZS(e.g,function(e,t){this.g.hasOwnProperty(t)&&xC(e)},e),e.g={}}function rA(){this.g=!0}function iA(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 VC(n)}catch(e){return t}}(e,n)+(r?" "+r:"")})}ZC.prototype.M=function(){ZC.Z.M.call(this),nA(this)},ZC.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},rA.prototype.Aa=function(){this.g=!1},rA.prototype.info=function(){};var sA={},oA=null;function aA(){return oA=oA||new UC}function cA(e){yC.call(this,sA.Ma,e)}function lA(){var e=aA();jC(e,new cA(e))}function uA(e,t){yC.call(this,sA.STAT_EVENT,e),this.stat=t}function hA(e){var t=aA();jC(t,new uA(t,e))}function dA(e,t){yC.call(this,sA.Na,e),this.size=t}function pA(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return RS.setTimeout(function(){e()},t)}sA.Ma="serverreachability",qS(cA,yC),sA.STAT_EVENT="statevent",qS(uA,yC),sA.Na="timingevent",qS(dA,yC);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 fA(){}function gA(e){return e.h||(e.h=e.i())}function mA(){}fA.prototype.h=null;l={OPEN:"a",pb:"b",Ka:"c",Bb:"d"};function vA(){yC.call(this,"d")}function yA(){yC.call(this,"c")}function _A(){}function wA(e,t,n,r){this.l=e,this.j=t,this.m=n,this.X=r||1,this.V=new ZC(this),this.P=IA,this.W=new QC(e=cC?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 bA}function bA(){this.i=null,this.g="",this.h=!1}qS(vA,yC),qS(yA,yC),qS(_A,fA),_A.prototype.g=function(){return new XMLHttpRequest},_A.prototype.i=function(){return{}};var TA=new _A,IA=45e3,EA={},kA={};function SA(e,t,n){e.K=1,e.v=GA(BA(t)),e.s=n,e.U=!0,CA(e,null)}function CA(e,t){e.F=Date.now(),RA(e),e.A=BA(e.v);var o,a,c,l,u,h,n=e.A,r=e.X;Array.isArray(r)||(r=[String(r)]),aN(n.h,"t",r),e.C=0,n=e.l.H,e.h=new bA,e.g=aR(e.l,n?t:null,!e.s),0<e.O&&(e.L=new XC(US(e.Ia,e,e.g),e.O)),tA(e.V,e.g,"readystatechange",e.gb),t=e.H?eC(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)),lA(),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 AA(e){return e.g&&("GET"==e.u&&2!=e.K&&e.l.Ba)}function NA(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))?kA:(a=Number(o.substring(a,c)),isNaN(a)?EA:(c+=1)+a>o.length?kA:(o=o.substr(c,a),s.C=c+a,o))),i==kA){4==t&&(e.o=4,hA(14),r=!1),iA(e.j,e.m,null,"[Incomplete Response]");break}if(i==EA){e.o=4,hA(15),iA(e.j,e.m,n,"[Invalid Chunk]"),r=!1;break}iA(e.j,e.m,i,null),MA(e,i)}var s,o,a,c;AA(e)&&i!=kA&&i!=EA&&(e.h.g="",e.C=0),4!=t||0!=n.length||e.h.h||(e.o=1,hA(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),ZN(t),t.L=!0,hA(11))):(iA(e.j,e.m,n,"[Invalid Chunked Response]"),OA(e),DA(e))}function RA(e){e.Y=Date.now()+e.P,PA(e,e.P)}function PA(e,t){if(null!=e.B)throw Error("WatchDog timer not null");e.B=pA(US(e.eb,e),t)}function xA(e){e.B&&(RS.clearTimeout(e.B),e.B=null)}function DA(e){0==e.l.G||e.I||nR(e.l,e)}function OA(e){xA(e);var t=e.L;t&&"function"==typeof t.na&&t.na(),e.L=null,YC(e.W),nA(e.V),e.g&&(t=e.g,e.g=null,t.abort(),t.na())}function MA(e,t){try{var n=e.l;if(0!=n.G&&(n.g==e||fN(n.i,e)))if(n.I=e.N,!e.J&&fN(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;tR(n),KN(n)}XN(n),hA(18)}}else n.ta=i[1],0<n.ta-n.U&&i[2]<37500&&n.N&&0==n.A&&!n.v&&(n.v=pA(US(n.ab,n),6e3));if(pN(n.i)<=1&&n.ka){try{n.ka()}catch(e){}n.ka=void 0}}else iR(n,11)}else if(!e.J&&n.g!=e||tR(n),!HS(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&&(YS(c,"spdy")||YS(c,"quic")||YS(c,"h2"))&&(l.j=l.l,l.g=new Set,l.h&&(gN(l,l.h),l.h=null)),!r.D||(u=g.g?g.g.getResponseHeader("X-HTTP-Session-Id"):null)&&(r.sa=u,HA(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=oR(r,r.H?r.la:null,r.W),f.J?(mN(r.i,f),d=f,(p=r.K)&&d.setTimeout(p),d.B&&(xA(d),RA(d)),r.g=f):JN(r),0<n.l.length&&HN(n)}else"stop"!=s[0]&&"close"!=s[0]||iR(n,7);else 3==n.G&&("stop"==s[0]||"close"==s[0]?"stop"==s[0]?iR(n,7):WN(n):"noop"!=s[0]&&n.j&&n.j.wa(s),n.A=0)}lA()}catch(e){}}function LA(e,t){if(e.forEach&&"function"==typeof e.forEach)e.forEach(t,void 0);else if(xS(e)||"string"==typeof e)KS(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(xS(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(xS(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 FA(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 FA)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 UA(e){if(e.i!=e.g.length){for(var t=0,n=0;t<e.g.length;){var r=e.g[t];jA(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;)jA(i,r=e.g[t])||(i[e.g[n++]=r]=1),t++;e.g.length=n}}function jA(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(ze=wA.prototype).setTimeout=function(e){this.P=e},ze.gb=function(e){e=e.target;const t=this.L;t&&3==UN(e)?t.l():this.Ia(e)},ze.Ia=function(e){try{if(e==this.g)e:{var t=UN(this.g),n=this.g.Da();this.g.ba();if(!(t<3)&&(3!=t||cC||this.g&&(this.h.h||this.g.ga()||jN(this.g)))){this.I||4!=t||7==n||lA(),xA(this);var r=this.g.ba();this.N=r;t:if(AA(this)){var i=jN(this.g);e="";var s=i.length,o=4==UN(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){OA(this),DA(this);var a="";break t}this.h.i=new RS.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)&&!HS(c)){var u=c;break t}}u=null}if(!(r=u)){this.i=!1,this.o=3,hA(12),OA(this),DA(this);break e}iA(this.j,this.m,r,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,MA(this,r)}this.U?(NA(this,t,a),cC&&this.i&&3==t&&(tA(this.V,this.W,"tick",this.fb),this.W.start())):(iA(this.j,this.m,a,null),MA(this,a)),4==t&&OA(this),this.i&&!this.I&&(4==t?nR(this.l,this):(this.i=!1,RA(this)))}else 400==r&&0<a.indexOf("Unknown SID")?(this.o=3,hA(12)):(this.o=0,hA(13)),OA(this),DA(this)}}}catch(e){}var h,d,p,f,g,m,v},ze.fb=function(){var e,t;this.g&&(e=UN(this.g),t=this.g.ga(),this.C<t.length&&(xA(this),NA(this,e,t),this.i&&4!=e&&RA(this)))},ze.cancel=function(){this.I=!0,OA(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&&(lA(),hA(17)),OA(this),this.o=2,DA(this)):PA(this,this.Y-n)},(ze=FA.prototype).R=function(){UA(this);for(var e=[],t=0;t<this.g.length;t++)e.push(this.h[this.g[t]]);return e},ze.T=function(){return UA(this),this.g.concat()},ze.get=function(e,t){return jA(this.h,e)?this.h[e]:t},ze.set=function(e,t){jA(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 qA=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function VA(e,t){var n;this.i=this.s=this.j="",this.m=null,this.o=this.l="",this.g=!1,e instanceof VA?(this.g=void 0!==t?t:e.g,WA(this,e.j),this.s=e.s,KA(this,e.i),$A(this,e.m),this.l=e.l,t=e.h,(n=new rN).i=t.i,t.g&&(n.g=new FA(t.g),n.h=t.h),zA(this,n),this.o=e.o):e&&(n=String(e).match(qA))?(this.g=!!t,WA(this,n[1]||"",!0),this.s=QA(n[2]||""),KA(this,n[3]||"",!0),$A(this,n[4]),this.l=QA(n[5]||"",!0),zA(this,n[6]||"",!0),this.o=QA(n[7]||"")):(this.g=!!t,this.h=new rN(null,this.g))}function BA(e){return new VA(e)}function WA(e,t,n){e.j=n?QA(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function KA(e,t,n){e.i=n?QA(t,!0):t}function $A(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 zA(e,t,n){var r,i;t instanceof rN?(e.h=t,r=e.h,(i=e.g)&&!r.j&&(iN(r),r.i=null,r.g.forEach(function(e,t){var n=t.toLowerCase();t!=n&&(sN(this,t),aN(this,n,e))},r)),r.j=i):(n||(t=YA(t,tN)),e.h=new rN(t,e.g))}function HA(e,t,n){e.h.set(t,n)}function GA(e){return HA(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),e}function QA(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function YA(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,JA),e=n?e.replace(/%25([0-9a-fA-F]{2})/g,"%$1"):e):null}function JA(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}VA.prototype.toString=function(){var e=[],t=this.j;t&&e.push(YA(t,XA,!0),":");var n=this.i;return!n&&"file"!=t||(e.push("//"),(t=this.s)&&e.push(YA(t,XA,!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(YA(n,"/"==n.charAt(0)?eN:ZA,!0))),(n=this.h.toString())&&e.push("?",n),(n=this.o)&&e.push("#",YA(n,nN)),e.join("")};var XA=/[#\/\?@]/g,ZA=/[#\?:]/g,eN=/[#\?]/g,tN=/[#\?@]/g,nN=/#/g;function rN(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function iN(n){n.g||(n.g=new FA,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 sN(e,t){iN(e),t=cN(e,t),jA(e.g.h,t)&&(e.i=null,e.h-=e.g.get(t).length,jA((e=e.g).h,t)&&(delete e.h[t],e.i--,e.g.length>2*e.i&&UA(e)))}function oN(e,t){return iN(e),t=cN(e,t),jA(e.g.h,t)}function aN(e,t,n){sN(e,t),0<n.length&&(e.i=null,e.g.set(cN(e,t),zS(n)),e.h+=n.length)}function cN(e,t){return t=String(t),t=e.j?t.toLowerCase():t}(ze=rN.prototype).add=function(e,t){iN(this),this.i=null,e=cN(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){iN(this),this.g.forEach(function(e,t){KS(e,function(e){n.call(r,e,t,this)},this)},this)},ze.T=function(){iN(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){iN(this);var t=[];if("string"==typeof e)oN(this,e)&&(t=$S(t,this.g.get(cN(this,e))));else{e=this.g.R();for(var n=0;n<e.length;n++)t=$S(t,e[n])}return t},ze.set=function(e,t){return iN(this),this.i=null,oN(this,e=cN(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 lN=class{constructor(e,t){this.h=e,this.g=t}};function uN(e){this.l=e||10,e=RS.PerformanceNavigationTiming?0<(e=RS.performance.getEntriesByType("navigation")).length&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):!!(RS.g&&RS.g.Ea&&RS.g.Ea()&&RS.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 hN;function dN(e){return e.h||e.g&&e.g.size>=e.j}function pN(e){return e.h?1:e.g?e.g.size:0}function fN(e,t){return e.h?e.h==t:e.g&&e.g.has(t)}function gN(e,t){e.g?e.g.add(t):e.h=t}function mN(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function vN(t){if(null!=t.h)return t.i.concat(t.h.D);if(null==t.g||0===t.g.size)return zS(t.i);{let e=t.i;for(const n of t.g.values())e=e.concat(n.D);return e}}function yN(){}function _N(){this.g=new yN}function wN(e,t,n,r,i){try{t.onload=null,t.onerror=null,t.onabort=null,t.ontimeout=null,i(r)}catch(e){}}function bN(e){this.l=e.$b||null,this.j=e.ib||!1}function TN(e,t){UC.call(this),this.D=e,this.u=t,this.m=void 0,this.readyState=IN,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}uN.prototype.cancel=function(){if(this.i=vN(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()}},yN.prototype.stringify=function(e){return RS.JSON.stringify(e,void 0)},yN.prototype.parse=function(e){return RS.JSON.parse(e,void 0)},qS(bN,fA),bN.prototype.g=function(){return new TN(this.l,this.j)},bN.prototype.i=(hN={},function(){return hN}),qS(TN,UC);var IN=0;function EN(e){e.j.read().then(e.Sa.bind(e)).catch(e.ha.bind(e))}function kN(e){e.readyState=4,e.l=null,e.j=null,e.A=null,SN(e)}function SN(e){e.onreadystatechange&&e.onreadystatechange.call(e)}(ze=TN.prototype).open=function(e,t){if(this.readyState!=IN)throw this.abort(),Error("Error reopening a connection");this.C=e,this.B=t,this.readyState=1,SN(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||RS).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,kN(this)),this.readyState=IN},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,SN(this)),this.g&&(this.readyState=3,SN(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Ta.bind(this),this.ha.bind(this));else if(void 0!==RS.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;EN(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?kN:SN)(this),3==this.readyState&&EN(this))},ze.Ua=function(e){this.g&&(this.response=this.responseText=e,kN(this))},ze.Ta=function(e){this.g&&(this.response=e,kN(this))},ze.ha=function(){this.g&&kN(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(TN.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}});var CN=RS.JSON.parse;function AN(e){UC.call(this),this.headers=new FA,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=NN,this.K=this.L=!1}qS(AN,UC);var NN="",RN=/^https?$/i,PN=["POST","PUT"];function xN(e){return"content-type"==e.toLowerCase()}function DN(e,t){e.h=!1,e.g&&(e.l=!0,e.g.abort(),e.l=!1),e.j=t,e.m=5,ON(e),LN(e)}function ON(e){e.D||(e.D=!0,jC(e,"complete"),jC(e,"error"))}function MN(e){if(e.h&&void 0!==NS&&(!e.C[1]||4!=UN(e)||2!=e.ba()))if(e.v&&4==UN(e))JC(e.Fa,0,e);else if(jC(e,"readystatechange"),4==UN(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(qA)[1]||null)&&RS.self&&RS.self.location&&(i=(r=RS.self.location.protocol).substr(0,r.length-1)),n=!RN.test(i?i.toLowerCase():"")),t=n),t)jC(e,"complete"),jC(e,"success");else{e.m=6;try{var a=2<UN(e)?e.g.statusText:""}catch(e){a=""}e.j=a+" ["+e.ba()+"]",ON(e)}}finally{LN(e)}}}function LN(e,t){if(e.g){FN(e);const n=e.g,r=e.C[0]?PS:null;e.g=null,e.C=null,t||jC(e,"ready");try{n.onreadystatechange=r}catch(e){}}}function FN(e){e.g&&e.K&&(e.g.ontimeout=null),e.A&&(RS.clearTimeout(e.A),e.A=null)}function UN(e){return e.g?e.g.readyState:0}function jN(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.J){case NN:case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}function qN(e,t,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=function(e){let n="";return ZS(e,function(e,t){n+=t,n+=":",n+=e,n+="\r\n"}),n}(n),"string"==typeof e?null!=n&&encodeURIComponent(String(n)):HA(e,t,n))}function VN(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function BN(e){this.za=0,this.l=[],this.h=new rA,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=VN("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=VN("baseRetryDelayMs",5e3,e),this.$a=VN("retryDelaySeedMs",1e4,e),this.Ya=VN("forwardChannelMaxRetries",2,e),this.ra=VN("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 uN(e&&e.concurrentRequestLimit),this.Ca=new _N,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 WN(e){var t,n;$N(e),3==e.G&&(t=e.V++,HA(n=BA(e.F),"SID",e.J),HA(n,"RID",t),HA(n,"TYPE","terminate"),QN(e,n),(t=new wA(e,e.h,t,void 0)).K=2,t.v=GA(BA(n)),n=!1,!(n=RS.navigator&&RS.navigator.sendBeacon?RS.navigator.sendBeacon(t.v.toString(),""):n)&&RS.Image&&((new Image).src=t.v,n=!0),n||(t.g=aR(t.l,null),t.g.ea(t.v)),t.F=Date.now(),RA(t)),sR(e)}function KN(e){e.g&&(ZN(e),e.g.cancel(),e.g=null)}function $N(e){KN(e),e.u&&(RS.clearTimeout(e.u),e.u=null),tR(e),e.i.cancel(),e.m&&("number"==typeof e.m&&RS.clearTimeout(e.m),e.m=null)}function zN(e,t){e.l.push(new lN(e.Za++,t)),3==e.G&&HN(e)}function HN(e){dN(e.i)||e.m||(e.m=!0,$C(e.Ha,e),e.C=0)}function GN(e,t){var n=t?t.m:e.V++,r=BA(e.F);HA(r,"SID",e.J),HA(r,"RID",n),HA(r,"AID",e.U),QN(e,r),e.o&&e.s&&qN(r,e.o,e.s),n=new wA(e,e.h,n,e.C+1),null===e.o&&(n.H=e.s),t&&(e.l=t.D.concat(e.l)),t=YN(e,n,1e3),n.setTimeout(Math.round(.5*e.ra)+Math.round(.5*e.ra*Math.random())),gN(e.i,n),SA(n,r,t)}function QN(e,n){e.j&&LA({},function(e,t){HA(n,t,e)})}function YN(e,t,r){r=Math.min(e.l.length,r);var i=e.j?US(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{LA(e,function(e,t){let n=e;DS(e)&&(n=VC(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 JN(e){e.g||e.u||(e.Y=1,$C(e.Ga,e),e.A=0)}function XN(e){return!(e.g||e.u||3<=e.A)&&(e.Y++,e.u=pA(US(e.Ga,e),rR(e,e.A)),e.A++,1)}function ZN(e){null!=e.B&&(RS.clearTimeout(e.B),e.B=null)}function eR(e){e.g=new wA(e,e.h,"rpc",e.Y),null===e.o&&(e.g.H=e.s),e.g.O=0;var t=BA(e.oa);HA(t,"RID","rpc"),HA(t,"SID",e.J),HA(t,"CI",e.N?"0":"1"),HA(t,"AID",e.U),QN(e,t),HA(t,"TYPE","xmlhttp"),e.o&&e.s&&qN(t,e.o,e.s),e.K&&e.g.setTimeout(e.K);var n=e.g;e=e.la,n.K=1,n.v=GA(BA(t)),n.s=null,n.U=!0,CA(n,e)}function tR(e){null!=e.v&&(RS.clearTimeout(e.v),e.v=null)}function nR(e,t){var n,r,i,s=null;if(e.g==t){tR(e),ZN(e),e.g=null;var o=2}else{if(!fN(e.i,t))return;s=t.D,mN(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,jC(o=aA(),new dA(o,s)),HN(e)):JN(e);else if(3==(n=t.o)||0==n&&0<e.I||(1!=o||(i=t,pN((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=pA(US(r.Ha,r,i),rR(r,r.C)),r.C++,0))))&&(2!=o||!XN(e)))switch(s&&0<s.length&&(t=e.i,t.i=t.i.concat(s)),n){case 1:iR(e,5);break;case 4:iR(e,10);break;case 3:iR(e,6);break;default:iR(e,2)}}function rR(e,t){let n=e.Pa+Math.floor(Math.random()*e.$a);return e.j||(n*=2),n*t}function iR(e,t){var n,r;e.h.info("Error code "+t),2==t?(n=null,e.j&&(n=null),r=US(e.jb,e),n||(n=new VA("//www.google.com/images/cleardot.gif"),RS.location&&"http"==RS.location.protocol||WA(n,"https"),GA(n)),function(e,t){var n=new rA;if(RS.Image){const r=new Image;r.onload=jS(wN,n,r,"TestLoadImage: loaded",!0,t),r.onerror=jS(wN,n,r,"TestLoadImage: error",!1,t),r.onabort=jS(wN,n,r,"TestLoadImage: abort",!1,t),r.ontimeout=jS(wN,n,r,"TestLoadImage: timeout",!1,t),RS.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}(n.toString(),r)):hA(2),e.G=0,e.j&&e.j.va(t),sR(e),$N(e)}function sR(e){e.G=0,e.I=-1,e.j&&(0==vN(e.i).length&&0==e.l.length||(e.i.i.length=0,zS(e.l),e.l.length=0),e.j.ua())}function oR(e,t,n){let r=(a=n)instanceof VA?BA(a):new VA(a,void 0);var i,s,o,a,c;return""!=r.i?(t&&KA(r,t+"."+r.i),$A(r,r.m)):(c=RS.location,r=(i=c.protocol,s=t?t+"."+c.hostname:c.hostname,o=+c.port,a=n,c=new VA(null,void 0),i&&WA(c,i),s&&KA(c,s),o&&$A(c,o),a&&(c.l=a),c)),e.aa&&ZS(e.aa,function(e,t){HA(r,t,e)}),t=e.D,n=e.sa,t&&n&&HA(r,t,n),HA(r,"VER",e.ma),QN(e,r),r}function aR(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 AN(new bN({ib:!0})):new AN(e.qa)).L=e.H,t}function cR(){}function lR(){if(oC&&!(10<=Number(mC)))throw Error("Environmental error: no available transport.")}function uR(e,t){UC.call(this),this.g=new BN(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)&&!HS(e)&&(this.g.o=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!HS(t)&&(this.g.D=t,null!==(e=this.h)&&t in e&&(t in(e=this.h)&&delete e[t])),this.j=new pR(this)}function hR(e){vA.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 dR(){yA.call(this),this.status=1}function pR(e){this.g=e}(ze=AN.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||TA).g(),this.C=this.u?gA(this.u):gA(TA),this.g.onreadystatechange=US(this.Fa,this);try{this.F=!0,this.g.open(t,String(e),!0),this.F=!1}catch(e){return void DN(this,e)}e=n||"";const i=new FA(this.headers);r&&LA(r,function(e,t){i.set(t,e)}),r=function(t){e:{var n=xN,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=RS.FormData&&e instanceof RS.FormData,0<=WS(PN,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{FN(this),0<this.B&&((this.K=(s=this.g,oC&&gC()&&"number"==typeof s.timeout&&void 0!==s.ontimeout))?(this.g.timeout=this.B,this.g.ontimeout=US(this.pa,this)):this.A=JC(this.pa,this.B,this)),this.v=!0,this.g.send(e),this.v=!1}catch(e){DN(this,e)}var s},ze.pa=function(){void 0!==NS&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,jC(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,jC(this,"complete"),jC(this,"abort"),LN(this))},ze.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),LN(this,!0)),AN.Z.M.call(this)},ze.Fa=function(){this.s||(this.F||this.v||this.l?MN(this):this.cb())},ze.cb=function(){MN(this)},ze.ba=function(){try{return 2<UN(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)),CN(t)}},ze.Da=function(){return this.m},ze.La=function(){return"string"==typeof this.j?this.j:String(this.j)},(ze=BN.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 wA(this,this.h,t,void 0);let e=this.s;if(this.P&&(e?(e=eC(e),nC(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=YN(this,s,n),HA(r=BA(this.F),"RID",t),HA(r,"CVER",22),this.D&&HA(r,"X-HTTP-Session-Id",this.D),QN(this,r),this.o&&e&&qN(r,this.o,e),gN(this.i,s),this.Ra&&HA(r,"TYPE","init"),this.ja?(HA(r,"$req",n),HA(r,"SID","null"),s.$=!0,SA(s,r,null)):SA(s,r,n),this.G=2}}else 3==this.G&&(t?GN(this,t):0==this.l.length||dN(this.i)||GN(this))},ze.Ga=function(){var e;this.u=null,eR(this),this.$&&!(this.L||null==this.g||this.O<=0)&&(e=2*this.O,this.h.info("BP detection timer enabled: "+e),this.B=pA(US(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,hA(10),KN(this),eR(this))},ze.ab=function(){null!=this.v&&(this.v=null,KN(this),XN(this),hA(19))},ze.jb=function(e){e?(this.h.info("Successfully pinged google.com"),hA(2)):(this.h.info("Failed to ping google.com"),hA(1))},(ze=cR.prototype).xa=function(){},ze.wa=function(){},ze.va=function(){},ze.ua=function(){},ze.Oa=function(){},lR.prototype.g=function(e,t){return new uR(e,t)},qS(uR,UC),uR.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."),$C(US(e.hb,e,t))),hA(0),e.W=t,e.aa=n||{},e.N=e.X,e.F=oR(e,null,e.W),HN(e)},uR.prototype.close=function(){WN(this.g)},uR.prototype.u=function(e){var t;"string"==typeof e?((t={}).__data__=e,zN(this.g,t)):this.v?((t={}).__data__=VC(e),zN(this.g,t)):zN(this.g,e)},uR.prototype.M=function(){this.g.j=null,delete this.j,WN(this.g),delete this.g,uR.Z.M.call(this)},qS(hR,vA),qS(dR,yA),qS(pR,cR),pR.prototype.xa=function(){jC(this.g,"a")},pR.prototype.wa=function(e){jC(this.g,new hR(e))},pR.prototype.va=function(e){jC(this.g,new dR)},pR.prototype.ua=function(){jC(this.g,"b")},lR.prototype.createWebChannel=lR.prototype.g,uR.prototype.send=uR.prototype.u,uR.prototype.open=uR.prototype.m,c.NO_ERROR=0,c.TIMEOUT=8,c.HTTP_ERROR=6,yt.COMPLETE="complete",(mA.EventType=l).OPEN="a",l.CLOSE="b",l.ERROR="c",l.MESSAGE="d",UC.prototype.listen=UC.prototype.N,AN.prototype.listenOnce=AN.prototype.O,AN.prototype.getLastError=AN.prototype.La,AN.prototype.getLastErrorCode=AN.prototype.Da,AN.prototype.getStatus=AN.prototype.ba,AN.prototype.getResponseJson=AN.prototype.Qa,AN.prototype.getResponseText=AN.prototype.ga,AN.prototype.send=AN.prototype.ea;var fR,gR=aA,mR=c,vR=yt,yR=sA,_R=10,wR=11,bR=bN,TR=mA,IR=AN;const ER="@firebase/firestore";class kR{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}}kR.UNAUTHENTICATED=new kR(null),kR.GOOGLE_CREDENTIALS=new kR("google-credentials-uid"),kR.FIRST_PARTY=new kR("first-party-uid"),kR.MOCK_USER=new kR("mock-user");let SR="9.6.2-canary.044a8d7f9";const CR=new ep("@firebase/firestore");function AR(){return CR.logLevel}function NR(e,...t){var n;CR.logLevel<=Kh.DEBUG&&(n=t.map(xR),CR.debug(`Firestore (${SR}): ${e}`,...n))}function RR(e,...t){var n;CR.logLevel<=Kh.ERROR&&(n=t.map(xR),CR.error(`Firestore (${SR}): ${e}`,...n))}function PR(e,...t){var n;CR.logLevel<=Kh.WARN&&(n=t.map(xR),CR.warn(`Firestore (${SR}): ${e}`,...n))}function xR(t){if("string"==typeof t)return t;try{return JSON.stringify(t)}catch(e){return t}}function DR(e="Unexpected state"){var t=`FIRESTORE (${SR}) INTERNAL ASSERTION FAILED: `+e;throw RR(t),new Error(t)}function OR(e){e||DR()}const MR={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 LR extends gd{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class FR{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class UR{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class jR{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(kR.UNAUTHENTICATED))}shutdown(){}}class qR{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 VR{constructor(e){this.t=e,this.currentUser=kR.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 FR;this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new FR,t.enqueueRetryable(()=>i(this.currentUser))};const o=()=>{const e=s;t.enqueueRetryable(async()=>{await e.promise,await i(this.currentUser)})},a=e=>{NR("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):(NR("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new FR))},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?(NR("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):e?(OR("string"==typeof e.accessToken),new UR(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 OR(null===e||"string"==typeof e),new kR(e)}}class BR{constructor(e,t,n){this.type="FirstParty",this.user=kR.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 WR{constructor(e,t,n){this.h=e,this.l=t,this.m=n}getToken(){return Promise.resolve(new BR(this.h,this.l,this.m))}start(e,t){e.enqueueRetryable(()=>t(kR.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class KR{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 $R{constructor(e){this.g=e,this.forceRefresh=!1,this.appCheck=null}start(t,n){this.o=e=>{t.enqueueRetryable(()=>(e=>(null!=e.error&&NR("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`),n(e.token)))(e))};const r=e=>{NR("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):NR("FirebaseAppCheckTokenProvider","AppCheck not yet detected"))},0)}getToken(){var e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(OR("string"==typeof e.token),new KR(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}class zR{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}}zR.I=-1;class HR{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 GR(e,t){return e<t?-1:t<e?1:0}function QR(e,n,r){return e.length===n.length&&e.every((e,t)=>r(e,n[t]))}function YR(e){return e+"\0"}class JR{constructor(e,t){if(this.seconds=e,(this.nanoseconds=t)<0)throw new LR(MR.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(1e9<=t)throw new LR(MR.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-62135596800)throw new LR(MR.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(253402300800<=e)throw new LR(MR.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return JR.fromMillis(Date.now())}static fromDate(e){return JR.fromMillis(e.getTime())}static fromMillis(e){var t=Math.floor(e/1e3),n=Math.floor(1e6*(e-1e3*t));return new JR(t,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?GR(this.nanoseconds,e.nanoseconds):GR(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 XR{constructor(e){this.timestamp=e}static fromTimestamp(e){return new XR(e)}static min(){return new XR(new JR(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 ZR(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function eP(e,t){for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function tP(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class nP{constructor(e,t,n){void 0===t?t=0:t>e.length&&DR(),void 0===n?n=e.length-t:n>e.length-t&&DR(),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return 0===nP.comparator(this,e)}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof nP?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 rP extends nP{construct(e,t,n){return new rP(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 LR(MR.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter(e=>0<e.length))}return new rP(t)}static emptyPath(){return new rP([])}}const iP=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class sP extends nP{construct(e,t,n){return new sP(e,t,n)}static isValidIdentifier(e){return iP.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),e=!sP.isValidIdentifier(e)?"`"+e+"`":e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&"__name__"===this.get(0)}static keyField(){return new sP(["__name__"])}static fromServerFormat(e){const t=[];let n="",r=0;var i=()=>{if(0===n.length)throw new LR(MR.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 LR(MR.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const t=e[r+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new LR(MR.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 LR(MR.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new sP(t)}static emptyPath(){return new sP([])}}class oP{constructor(e){(this.fields=e).sort(sP.comparator)}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return QR(this.fields,e.fields,(e,t)=>e.isEqual(t))}}class aP{constructor(e){this.binaryString=e}static fromBase64String(e){var t=atob(e);return new aP(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 aP(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 GR(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}aP.EMPTY_BYTE_STRING=new aP("");const cP=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function lP(t){if(OR(!!t),"string"!=typeof t)return{seconds:uP(t.seconds),nanos:uP(t.nanos)};{let e=0;var n=cP.exec(t);OR(!!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 uP(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function hP(e){return"string"==typeof e?aP.fromBase64String(e):aP.fromUint8Array(e)}function dP(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 pP(e){var t=lP(e.mapValue.fields.__local_write_time__.timestampValue);return new JR(t.seconds,t.nanos)}function fP(e){return null==e}function gP(e){return 0===e&&1/e==-1/0}function mP(e){return"number"==typeof e&&Number.isInteger(e)&&!gP(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}class vP{constructor(e){this.path=e}static fromPath(e){return new vP(rP.fromString(e))}static fromName(e){return new vP(rP.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===rP.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return rP.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new vP(new rP(e.slice()))}}function yP(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?dP(e)?4:10:DR()}function _P(r,i){if(r===i)return!0;var e,t,n=yP(r);if(n!==yP(i))return!1;switch(n){case 0:return!0;case 1:return r.booleanValue===i.booleanValue;case 4:return pP(r).isEqual(pP(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=lP(r.timestampValue),n=lP(e.timestampValue);return t.seconds===n.seconds&&t.nanos===n.nanos}(i);case 5:return r.stringValue===i.stringValue;case 6:return t=i,hP(r.bytesValue).isEqual(hP(t.bytesValue));case 7:return r.referenceValue===i.referenceValue;case 8:return e=i,uP((t=r).geoPointValue.latitude)===uP(e.geoPointValue.latitude)&&uP(t.geoPointValue.longitude)===uP(e.geoPointValue.longitude);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return uP(e.integerValue)===uP(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){var n=uP(e.doubleValue),r=uP(t.doubleValue);return n===r?gP(n)===gP(r):isNaN(n)&&isNaN(r)}return!1}(r,i);case 9:return QR(r.arrayValue.values||[],i.arrayValue.values||[],_P);case 10:return function(e){const t=e.mapValue.fields||{},n=i.mapValue.fields||{};if(ZR(t)!==ZR(n))return!1;for(const e in t)if(t.hasOwnProperty(e)&&(void 0===n[e]||!_P(t[e],n[e])))return!1;return!0}(r);default:return DR()}}function wP(e,t){return void 0!==(e.values||[]).find(e=>_P(e,t))}function bP(e,t){if(e===t)return 0;var n,r,i,s,o=yP(e),a=yP(t);if(o!==a)return GR(o,a);switch(o){case 0:return 0;case 1:return GR(e.booleanValue,t.booleanValue);case 2:return r=t,i=uP(e.integerValue||e.doubleValue),s=uP(r.integerValue||r.doubleValue),i<s?-1:s<i?1:i===s?0:isNaN(i)?isNaN(s)?0:-1:1;case 3:return TP(e.timestampValue,t.timestampValue);case 4:return TP(pP(e),pP(t));case 5:return GR(e.stringValue,t.stringValue);case 6:return function(e,t){const n=hP(e),r=hP(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=GR(n[i],r[i]);if(0!==t)return t}return GR(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return n=e.geoPointValue,r=t.geoPointValue,0!==(s=GR(uP(n.latitude),uP(r.latitude)))?s:GR(uP(n.longitude),uP(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=bP(n[i],r[i]);if(t)return t}return GR(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=GR(r[a],s[a]);if(0!==t)return t;var o=bP(n[r[a]],i[s[a]]);if(0!==o)return o}return GR(r.length,s.length)}(e.mapValue,t.mapValue);default:throw DR()}}function TP(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return GR(e,t);var n=lP(e),r=lP(t),i=GR(n.seconds,r.seconds);return 0!==i?i:GR(n.nanos,r.nanos)}function IP(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=lP(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?hP(e.bytesValue).toBase64():"referenceValue"in e?(t=e.referenceValue,vP.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):DR();var t}(e)}function EP(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function kP(e){return e&&"integerValue"in e}function SP(e){return!!e&&"arrayValue"in e}function CP(e){return e&&"nullValue"in e}function AP(e){return e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function NP(e){return e&&"mapValue"in e}function RP(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 eP(t.mapValue.fields,(e,t)=>n.mapValue.fields[e]=RP(t)),n}if(t.arrayValue){const r={arrayValue:{values:[]}};for(let e=0;e<(t.arrayValue.values||[]).length;++e)r.arrayValue.values[e]=RP(t.arrayValue.values[e]);return r}return Object.assign({},t)}class PP{constructor(e){this.value=e}static empty(){return new PP({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)],!NP(e))return null;return e=(e.mapValue.fields||{})[n.lastSegment()],e||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=RP(t)}setAll(e){let n=sP.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()]=RP(e):i.push(t.lastSegment())});var t=this.getFieldsMap(n);this.applyChanges(t,r,i)}delete(e){const t=this.field(e.popLast());NP(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return _P(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)];NP(e)&&e.mapValue.fields||(e={mapValue:{fields:{}}},n.mapValue.fields[t.get(r)]=e),n=e}return n.mapValue.fields}applyChanges(n,e,t){eP(e,(e,t)=>n[e]=t);for(const e of t)delete n[e]}clone(){return new PP(RP(this.value))}}class xP{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 xP(e,0,XR.min(),PP.empty(),0)}static newFoundDocument(e,t,n){return new xP(e,1,t,n,0)}static newNoDocument(e,t){return new xP(e,2,t,PP.empty(),0)}static newUnknownDocument(e,t){return new xP(e,3,t,PP.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=PP.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=PP.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 xP&&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 xP(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 DP{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 OP(e,t=null,n=[],r=[],i=null,s=null,o=null){return new DP(e,t,n,r,i,s,o)}function MP(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()+IP(e.value)}(e)).join(","),e+="|ob:",e+=t.orderBy.map(e=>function(e){return e.field.canonicalString()+e.dir}(e)).join(","),fP(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=GP(t.startAt)),t.endAt&&(e+="|ub:",e+=GP(t.endAt)),t.R=e}return t.R}function LP(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)||!_P(i.value,s.value))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!JP(e.startAt,t.startAt)&&JP(e.endAt,t.endAt)}function FP(e){return vP.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}class UP 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 jP(e,t,n):"array-contains"===t?new WP(e,n):"in"===t?new KP(e,n):"not-in"===t?new $P(e,n):"array-contains-any"===t?new zP(e,n):new UP(e,t,n)}static P(e,t,n){return new("in"===t?qP:VP)(e,n)}matches(e){var t=e.data.field(this.field);return"!="===this.op?null!==t&&this.v(bP(t,this.value)):null!==t&&yP(this.value)===yP(t)&&this.v(bP(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 DR()}}V(){return 0<=["<","<=",">",">=","!=","not-in"].indexOf(this.op)}}class jP extends UP{constructor(e,t,n){super(e,t,n),this.key=vP.fromName(n.referenceValue)}matches(e){var t=vP.comparator(e.key,this.key);return this.v(t)}}class qP extends UP{constructor(e,t){super(e,"in",t),this.keys=BP(0,t)}matches(t){return this.keys.some(e=>e.isEqual(t.key))}}class VP extends UP{constructor(e,t){super(e,"not-in",t),this.keys=BP(0,t)}matches(t){return!this.keys.some(e=>e.isEqual(t.key))}}function BP(e,t){var n;return((null===(n=t.arrayValue)||void 0===n?void 0:n.values)||[]).map(e=>vP.fromName(e.referenceValue))}class WP extends UP{constructor(e,t){super(e,"array-contains",t)}matches(e){var t=e.data.field(this.field);return SP(t)&&wP(t.arrayValue,this.value)}}class KP extends UP{constructor(e,t){super(e,"in",t)}matches(e){var t=e.data.field(this.field);return null!==t&&wP(this.value.arrayValue,t)}}class $P extends UP{constructor(e,t){super(e,"not-in",t)}matches(e){if(wP(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var t=e.data.field(this.field);return null!==t&&!wP(this.value.arrayValue,t)}}class zP extends UP{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!SP(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>wP(this.value.arrayValue,e))}}class HP{constructor(e,t){this.position=e,this.before=t}}function GP(e){return`${e.before?"b":"a"}:${e.position.map(e=>IP(e)).join(",")}`}class QP{constructor(e,t="asc"){this.field=e,this.dir=t}}function YP(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()?vP.comparator(vP.fromName(o.referenceValue),n.key):bP(o,n.data.field(s.field)),"desc"===s.dir&&(r*=-1),0!==r)break}return e.before?r<=0:r<0}function JP(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(!_P(e.position[n],t.position[n]))return!1;return!0}class XP{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 ZP(e,t,n,r,i,s,o,a){return new XP(e,t,n,r,i,s,o,a)}function ex(e){return new XP(e)}function tx(e){return!fP(e.limit)&&"F"===e.limitType}function nx(e){return!fP(e.limit)&&"L"===e.limitType}function rx(e){return 0<e.explicitOrderBy.length?e.explicitOrderBy[0].field:null}function ix(e){for(const t of e.filters)if(t.V())return t.field;return null}function sx(e){return null!==e.collectionGroup}function ox(t){const n=t;if(null===n.S){n.S=[];const t=ix(n),e=rx(n);if(null!==t&&null===e)t.isKeyField()||n.S.push(new QP(t)),n.S.push(new QP(sP.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 QP(sP.keyField(),t))}}}return n.S}function ax(e){const t=e;if(!t.D)if("F"===t.limitType)t.D=OP(t.path,t.collectionGroup,ox(t),t.filters,t.limit,t.startAt,t.endAt);else{const e=[];for(const i of ox(t)){const t="desc"===i.dir?"asc":"desc";e.push(new QP(i.field,t))}var n=t.endAt?new HP(t.endAt.position,!t.endAt.before):null,r=t.startAt?new HP(t.startAt.position,!t.startAt.before):null;t.D=OP(t.path,t.collectionGroup,e,t.filters,t.limit,n,r)}return t.D}function cx(e,t,n){return new XP(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function lx(e,t){return LP(ax(e),ax(t))&&e.limitType===t.limitType}function ux(e){return`${MP(ax(e))}|lt:${e.limitType}`}function hx(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} ${IP(t.value)}`;var t}).join(", ")}]`),fP(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: "+GP(e.startAt)),e.endAt&&(t+=", endAt: "+GP(e.endAt)),`Target(${t})`}(ax(e))}; limitType=${e.limitType})`}function dx(n,e){return e.isFoundDocument()&&(t=n,i=(r=e).key.path,null!==t.collectionGroup?r.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(i):vP.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||YP(e.startAt,ox(e),t))&&(!e.endAt||!YP(e.endAt,ox(e),t)));var t,r,i}function px(i){return(e,t)=>{let n=!1;for(const r of ox(i)){const i=function(e,i,t){var n=e.field.isKeyField()?vP.comparator(i.key,t.key):function(e,t){var n=i.data.field(e),r=t.data.field(e);return null!==n&&null!==r?bP(n,r):DR()}(e.field,t);switch(e.dir){case"asc":return n;case"desc":return-1*n;default:return DR()}}(r,e,t);if(0!==i)return i;n=n||r.field.isKeyField()}return 0}}function fx(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:gP(t)?"-0":t}}function gx(e){return{integerValue:""+e}}function mx(e,t){return mP(t)?gx(t):fx(e,t)}class vx{constructor(){this._=void 0}}function yx(e,t){return e instanceof Ex?kP(n=t)||n&&"doubleValue"in n?t:{integerValue:0}:null;var n}class _x extends vx{}class wx extends vx{constructor(e){super(),this.elements=e}}function bx(e,t){const n=Sx(t);for(const t of e.elements)n.some(e=>_P(e,t))||n.push(t);return{arrayValue:{values:n}}}class Tx extends vx{constructor(e){super(),this.elements=e}}function Ix(e,t){let n=Sx(t);for(const t of e.elements)n=n.filter(e=>!_P(e,t));return{arrayValue:{values:n}}}class Ex extends vx{constructor(e,t){super(),this.k=e,this.N=t}}function kx(e){return uP(e.integerValue||e.doubleValue)}function Sx(e){return SP(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class Cx{constructor(e,t){this.field=e,this.transform=t}}class Ax{constructor(e,t){this.version=e,this.transformResults=t}}class Nx{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Nx}static exists(e){return new Nx(void 0,e)}static updateTime(e){return new Nx(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 Rx(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class Px{}function xx(e,t,n){e instanceof Lx?function(e,t,n){const r=e.value.clone(),i=jx(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof Fx?function(e,t,n){if(!Rx(e.precondition,t))return t.convertToUnknownDocument(n.version);const r=jx(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(Ux(e)),i.setAll(r),t.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(e,t,n):t.convertToNoDocument(n.version).setHasCommittedMutations()}function Dx(e,t,n){e instanceof Lx?function(e,t,n){if(Rx(e.precondition,t)){const r=e.value.clone(),i=qx(e.fieldTransforms,n,t);r.setAll(i),t.convertToFoundDocument(Mx(t),r).setHasLocalMutations()}}(e,t,n):e instanceof Fx?function(e,t,n){if(Rx(e.precondition,t)){const r=qx(e.fieldTransforms,n,t),i=t.data;i.setAll(Ux(e)),i.setAll(r),t.convertToFoundDocument(Mx(t),i).setHasLocalMutations()}}(e,t,n):(t=t,Rx(e.precondition,t)&&t.convertToNoDocument(XR.min()))}function Ox(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&&QR(n,r,(e,t)=>function(e,t){return e.field.isEqual(t.field)&&(e=e.transform,t=t.transform,e instanceof wx&&t instanceof wx||e instanceof Tx&&t instanceof Tx?QR(e.elements,t.elements,_P):e instanceof Ex&&t instanceof Ex?_P(e.N,t.N):e instanceof _x&&t instanceof _x)}(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 Mx(e){return e.isFoundDocument()?e.version:XR.min()}class Lx extends Px{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}}class Fx extends Px{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 Ux(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 jx(e,t,n){const r=new Map;OR(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 wx?bx(a,c):a instanceof Tx?Ix(a,c):l))}var a,c,l;return r}function qx(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 _x?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 wx?bx(i,s):i instanceof Tx?Ix(i,s):(a=yx(i=i,s),c=kx(a)+kx(i.N),kP(a)&&kP(i.N)?gx(c):fx(i.k,c))))}var i,s,o,a,c;return r}class Vx extends Px{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}}class Bx extends Px{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}}class Wx{constructor(e){this.count=e}}function Kx(e){switch(e){default:return DR(),0;case MR.CANCELLED:case MR.UNKNOWN:case MR.DEADLINE_EXCEEDED:case MR.RESOURCE_EXHAUSTED:case MR.INTERNAL:case MR.UNAVAILABLE:case MR.UNAUTHENTICATED:return;case MR.INVALID_ARGUMENT:case MR.NOT_FOUND:case MR.ALREADY_EXISTS:case MR.PERMISSION_DENIED:case MR.FAILED_PRECONDITION:case MR.ABORTED:case MR.OUT_OF_RANGE:case MR.UNIMPLEMENTED:case MR.DATA_LOSS:return 1}}function $x(e){if(void 0===e)return RR("GRPC error has no .code"),MR.UNKNOWN;switch(e){case fR.OK:return MR.OK;case fR.CANCELLED:return MR.CANCELLED;case fR.UNKNOWN:return MR.UNKNOWN;case fR.DEADLINE_EXCEEDED:return MR.DEADLINE_EXCEEDED;case fR.RESOURCE_EXHAUSTED:return MR.RESOURCE_EXHAUSTED;case fR.INTERNAL:return MR.INTERNAL;case fR.UNAVAILABLE:return MR.UNAVAILABLE;case fR.UNAUTHENTICATED:return MR.UNAUTHENTICATED;case fR.INVALID_ARGUMENT:return MR.INVALID_ARGUMENT;case fR.NOT_FOUND:return MR.NOT_FOUND;case fR.ALREADY_EXISTS:return MR.ALREADY_EXISTS;case fR.PERMISSION_DENIED:return MR.PERMISSION_DENIED;case fR.FAILED_PRECONDITION:return MR.FAILED_PRECONDITION;case fR.ABORTED:return MR.ABORTED;case fR.OUT_OF_RANGE:return MR.OUT_OF_RANGE;case fR.UNIMPLEMENTED:return MR.UNIMPLEMENTED;case fR.DATA_LOSS:return MR.DATA_LOSS;default:return DR()}}(c=fR=fR||{})[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 zx{constructor(e,t){this.comparator=e,this.root=t||Gx.EMPTY}insert(e,t){return new zx(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,Gx.BLACK,null,null))}remove(e){return new zx(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Gx.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 Hx(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Hx(this.root,e,this.comparator,!1)}getReverseIterator(){return new Hx(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Hx(this.root,e,this.comparator,!0)}}class Hx{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 Gx{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:Gx.RED,this.left=null!=r?r:Gx.EMPTY,this.right=null!=i?i:Gx.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,r,i){return new Gx(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 Gx.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 Gx.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,Gx.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){var e=this.copy(null,null,Gx.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 DR();if(this.right.isRed())throw DR();var e=this.left.check();if(e!==this.right.check())throw DR();return e+(this.isRed()?0:1)}}Gx.EMPTY=null,Gx.RED=!0,Gx.BLACK=!1,Gx.EMPTY=new class{constructor(){this.size=0}get key(){throw DR()}get value(){throw DR()}get color(){throw DR()}get left(){throw DR()}get right(){throw DR()}copy(e,t,n,r,i){return this}insert(e,t,n){return new Gx(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 Qx{constructor(e){this.comparator=e,this.data=new zx(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 Yx(this.data.getIterator())}getIteratorFrom(e){return new Yx(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 Qx))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 Qx(this.comparator);return t.data=e,t}}class Yx{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}const Jx=new zx(vP.comparator);const Xx=new zx(vP.comparator);const Zx=new zx(vP.comparator);const eD=new Qx(vP.comparator);function tD(...e){let t=eD;for(const n of e)t=t.add(n);return t}const nD=new Qx(GR);class rD{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,iD.createSynthesizedTargetChangeForCurrentChange(e,t)),new rD(XR.min(),n,nD,Jx,tD())}}class iD{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 iD(aP.EMPTY_BYTE_STRING,t,tD(),tD(),tD())}}class sD{constructor(e,t,n,r){this.$=e,this.removedTargetIds=t,this.key=n,this.O=r}}class oD{constructor(e,t){this.targetId=e,this.F=t}}class aD{constructor(e,t,n=aP.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class cD{constructor(){this.M=0,this.L=hD(),this.B=aP.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=tD(),r=tD(),i=tD();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:DR()}}),new iD(this.B,this.U,n,r,i)}H(){this.q=!1,this.L=hD()}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 lD{constructor(e){this.et=e,this.nt=new Map,this.st=Jx,this.it=uD(),this.rt=new Qx(GR)}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:DR()}})}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(FP(e))if(0===n){const n=new vP(e.path);this.ct(t,n,xP.newNoDocument(n,XR.min()))}else OR(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&&FP(n.target)){const i=new vP(n.target.path);null!==this.st.get(i)||this.yt(t,i)||this.ct(t,i,xP.newNoDocument(i,r))}e.j&&(i.set(t,e.G()),e.H())}});let s=tD();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 rD(r,i,this.rt,this.st,s);return this.st=Jx,this.it=uD(),this.rt=new Qx(GR),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 cD,this.nt.set(e,t)),t}Tt(e){let t=this.it.get(e);return t||(t=new Qx(GR),this.it=this.it.insert(e,t)),t}lt(e){var t=null!==this.wt(e);return t||NR("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 cD),this.et.getRemoteKeysForTarget(t).forEach(e=>{this.ct(t,e,null)})}yt(e,t){return this.et.getRemoteKeysForTarget(e).has(t)}}function uD(){return new zx(vP.comparator)}function hD(){return new zx(vP.comparator)}const dD={asc:"ASCENDING",desc:"DESCENDING"},pD={"<":"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 fD{constructor(e,t){this.databaseId=e,this.C=t}}function gD(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 mD(e,t){return e.C?t.toBase64():t.toUint8Array()}function vD(e){return OR(!!e),XR.fromTimestamp((t=lP(e),new JR(t.seconds,t.nanos)));var t}function yD(e,t){return e=e,new rP(["projects",e.projectId,"databases",e.database]).child("documents").child(t).canonicalString()}function _D(e){var t=rP.fromString(e);return OR(jD(t)),t}function wD(e,t){return yD(e.databaseId,t.path)}function bD(e,t){const n=_D(t);if(n.get(1)!==e.databaseId.projectId)throw new LR(MR.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 LR(MR.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new vP(kD(n))}function TD(e,t){return yD(e.databaseId,t)}function ID(e){var t=_D(e);return 4===t.length?rP.emptyPath():kD(t)}function ED(e){return new rP(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function kD(e){return OR(4<e.length&&"documents"===e.get(4)),e.popFirst(5)}function SD(e,t,n){return{name:wD(e,t),fields:n.value.mapValue.fields}}function CD(e,t,n){const r=bD(e,t.name),i=vD(t.updateTime),s=new PP({mapValue:{fields:t.fields}}),o=xP.newFoundDocument(r,i,s);return n&&o.setHasCommittedMutations(),n?o.setHasCommittedMutations():o}function AD(e,t){let n;if(t instanceof Lx)n={update:SD(e,t.key,t.value)};else if(t instanceof Vx)n={delete:wD(e,t.key)};else if(t instanceof Fx)n={update:SD(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 Bx))return DR();n={verify:wD(e,t.key)}}return 0<t.fieldTransforms.length&&(n.updateTransforms=t.fieldTransforms.map(e=>function(e){var t=e.transform;if(t instanceof _x)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(t instanceof wx)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:t.elements}};if(t instanceof Tx)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:t.elements}};if(t instanceof Ex)return{fieldPath:e.field.canonicalString(),increment:t.N};throw DR()}(e))),t.precondition.isNone||(n.currentDocument=void 0!==(r=t.precondition).updateTime?{updateTime:(t=r.updateTime,gD(e,t.toTimestamp()))}:void 0!==r.exists?{exists:r.exists}:DR()),n;var r}function ND(t,n){const e=n.currentDocument?void 0!==(i=n.currentDocument).updateTime?Nx.updateTime(vD(i.updateTime)):void 0!==i.exists?Nx.exists(i.exists):Nx.none():Nx.none(),r=n.updateTransforms?n.updateTransforms.map(e=>function(e,t){let n=null;if("setToServerValue"in t)OR("REQUEST_TIME"===t.setToServerValue),n=new _x;else if("appendMissingElements"in t){const e=t.appendMissingElements.values||[];n=new wx(e)}else if("removeAllFromArray"in t){const e=t.removeAllFromArray.values||[];n=new Tx(e)}else"increment"in t?n=new Ex(e,t.increment):DR();var r=sP.fromServerFormat(t.fieldPath);return new Cx(r,n)}(t,e)):[];var i;if(n.update){n.update.name;var s=bD(t,n.update.name),o=new PP({mapValue:{fields:n.update.fields}});if(n.updateMask){const t=function(){const e=n.updateMask.fieldPaths||[];return new oP(e.map(e=>sP.fromServerFormat(e)))}();return new Fx(s,o,t,e,r)}return new Lx(s,o,e,r)}if(n.delete){const r=bD(t,n.delete);return new Vx(r,e)}if(n.verify){const r=bD(t,n.verify);return new Bx(r,e)}return DR()}function RD(e,t){return{documents:[TD(e,t.path)]}}function PD(e,t){const n={structuredQuery:{}},r=t.path;null!==t.collectionGroup?(n.parent=TD(e,r),n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(n.parent=TD(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(AP(e.value))return{unaryFilter:{field:MD(e.field),op:"IS_NAN"}};if(CP(e.value))return{unaryFilter:{field:MD(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(AP(e.value))return{unaryFilter:{field:MD(e.field),op:"IS_NOT_NAN"}};if(CP(e.value))return{unaryFilter:{field:MD(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:MD(e.field),op:(t=e.op,pD[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:MD(e.field),direction:(e=e.dir,dD[e])}}(e))}(t.orderBy);i&&(n.structuredQuery.orderBy=i);var s,i=(s=t.limit,e.C||fP(s)?s:{value:s});return null!==i&&(n.structuredQuery.limit=i),t.startAt&&(n.structuredQuery.startAt=DD(t.startAt)),t.endAt&&(n.structuredQuery.endAt=DD(t.endAt)),n}function xD(e){let t=ID(e.parent);const n=e.structuredQuery,r=n.from?n.from.length:0;let i=null;if(0<r){OR(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?[UD(e)]:void 0!==e.fieldFilter?[FD(e)]:void 0!==e.compositeFilter?e.compositeFilter.filters.map(e=>t(e)).reduce((e,t)=>e.concat(t)):DR():[]}(n.where));let o=[];n.orderBy&&(o=n.orderBy.map(e=>function(e){return new QP(LD(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,fP(c="object"==typeof e?e.value:e)?null:c));let l=null;n.startAt&&(l=OD(n.startAt));let u=null;return n.endAt&&(u=OD(n.endAt)),ZP(t,i,o,s,a,"F",l,u)}function DD(e){return{before:e.before,values:e.position}}function OD(e){var t=!!e.before,n=e.values||[];return new HP(n,t)}function MD(e){return{fieldPath:e.canonicalString()}}function LD(e){return sP.fromServerFormat(e.fieldPath)}function FD(e){return UP.create(LD(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 DR()}}(),e.fieldFilter.value)}function UD(e){switch(e.unaryFilter.op){case"IS_NAN":var t=LD(e.unaryFilter.field);return UP.create(t,"==",{doubleValue:NaN});case"IS_NULL":t=LD(e.unaryFilter.field);return UP.create(t,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var n=LD(e.unaryFilter.field);return UP.create(n,"!=",{doubleValue:NaN});case"IS_NOT_NULL":n=LD(e.unaryFilter.field);return UP.create(n,"!=",{nullValue:"NULL_VALUE"});default:return DR()}}function jD(e){return 4<=e.length&&"projects"===e.get(0)&&"databases"===e.get(2)}function qD(e){let t="";for(let n=0;n<e.length;n++)0<t.length&&(t=VD(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 VD(t)}function VD(e){return e+""}function BD(t){const n=t.length;if(OR(2<=n),2===n)return OR(""===t.charAt(0)&&""===t.charAt(1)),rP.emptyPath();const r=n-2,i=[];let s="";for(let o=0;o<n;){const n=t.indexOf("",o);switch((n<0||n>r)&&DR(),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:DR()}o=n+2}return new rP(i)}class WD{constructor(e,t){this.seconds=e,this.nanoseconds=t}}class KD{constructor(e,t,n){this.ownerId=e,this.allowTabSynchronization=t,this.leaseTimestampMs=n}}KD.store="owner",KD.key="owner";class $D{constructor(e,t,n){this.userId=e,this.lastAcknowledgedBatchId=t,this.lastStreamToken=n}}$D.store="mutationQueues",$D.keyPath="userId";class zD{constructor(e,t,n,r,i){this.userId=e,this.batchId=t,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i}}zD.store="mutations",zD.keyPath="batchId",zD.userMutationsIndex="userMutationsIndex",zD.userMutationsKeyPath=["userId","batchId"];class HD{constructor(){}static prefixForUser(e){return[e]}static prefixForPath(e,t){return[e,qD(t)]}static key(e,t,n){return[e,qD(t),n]}}HD.store="documentMutations",HD.PLACEHOLDER=new HD;class GD{constructor(e,t){this.path=e,this.readTime=t}}class QD{constructor(e,t){this.path=e,this.version=t}}class YD{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}}YD.store="remoteDocuments",YD.readTimeIndex="readTimeIndex",YD.readTimeIndexPath="readTime",YD.collectionReadTimeIndex="collectionReadTimeIndex",YD.collectionReadTimeIndexPath=["parentPath","readTime"];class JD{constructor(e){this.byteSize=e}}JD.store="remoteDocumentGlobal",JD.key="remoteDocumentGlobalKey";class XD{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}}XD.store="targets",XD.keyPath="targetId",XD.queryTargetsIndexName="queryTargetsIndex",XD.queryTargetsKeyPath=["canonicalId","targetId"];class ZD{constructor(e,t,n){this.targetId=e,this.path=t,this.sequenceNumber=n}}ZD.store="targetDocuments",ZD.keyPath=["targetId","path"],ZD.documentTargetsIndex="documentTargetsIndex",ZD.documentTargetsKeyPath=["path","targetId"];class eO{constructor(e,t,n,r){this.highestTargetId=e,this.highestListenSequenceNumber=t,this.lastRemoteSnapshotVersion=n,this.targetCount=r}}eO.key="targetGlobalKey",eO.store="targetGlobal";class tO{constructor(e,t){this.collectionId=e,this.parent=t}}tO.store="collectionParents",tO.keyPath=["collectionId","parent"];class nO{constructor(e,t,n,r){this.clientId=e,this.updateTimeMs=t,this.networkEnabled=n,this.inForeground=r}}nO.store="clientMetadata",nO.keyPath="clientId";class rO{constructor(e,t,n){this.bundleId=e,this.createTime=t,this.version=n}}rO.store="bundles",rO.keyPath="bundleId";class iO{constructor(e,t,n){this.name=e,this.readTime=t,this.bundledQuery=n}}iO.store="namedQueries",iO.keyPath="name";const sO=[$D.store,zD.store,HD.store,YD.store,XD.store,KD.store,eO.store,ZD.store,nO.store,JD.store,tO.store,rO.store,iO.store],oO="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class aO{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}class cO{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&&DR(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(i,this.error):this.wrapSuccess(r,this.result):new cO((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 cO?t:cO.resolve(t)}catch(e){return cO.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):cO.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):cO.reject(t)}static resolve(n){return new cO((e,t)=>{e(n)})}static reject(n){return new cO((e,t)=>{t(n)})}static waitFor(e){return new cO((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=cO.resolve(!1);for(const n of e)t=t.next(e=>e?cO.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 lO{constructor(n,e){this.action=n,this.transaction=e,this.aborted=!1,this.It=new FR,this.transaction.oncomplete=()=>{this.It.resolve()},this.transaction.onabort=()=>{e.error?this.It.reject(new dO(n,e.error)):this.It.resolve()},this.transaction.onerror=e=>{var t=vO(e.target.error);this.It.reject(new dO(n,t))}}static open(e,t,n,r){try{return new lO(t,e.transaction(r,n))}catch(e){throw new dO(t,e)}}get At(){return this.It.promise}abort(e){e&&this.It.reject(e),this.aborted||(NR("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 fO(t)}}class uO{constructor(e,t,n){this.name=e,this.version=t,this.Rt=n,12.2===uO.bt(sd())&&RR("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 NR("SimpleDb","Removing database:",e),gO(window.indexedDB.deleteDatabase(e)).toPromise()}static Pt(){if(!dd())return!1;if(uO.vt())return!0;const e=sd(),t=uO.bt(e),n=0<t&&t<10,r=uO.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||(NR("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 dO(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 LR(MR.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 LR(MR.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 dO(s,t))},i.onupgradeneeded=e=>{NR("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(()=>{NR("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=lO.open(this.db,e,i?"readonly":"readwrite",n),s=r(t).catch(e=>(t.abort(e),cO.reject(e))).toPromise();return s.catch(()=>{}),await t.At,s}catch(e){const t="FirebaseError"!==e.name&&s<3;if(NR("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 hO{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 gO(this.$t.delete())}}class dO extends LR{constructor(e,t){super(MR.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function pO(e){return"IndexedDbTransactionError"===e.name}class fO{constructor(e){this.store=e}put(e,t){let n;return n=void 0!==t?(NR("SimpleDb","PUT",this.store.name,e,t),this.store.put(t,e)):(NR("SimpleDb","PUT",this.store.name,"<auto-key>",e),this.store.put(e)),gO(n)}add(e){return NR("SimpleDb","ADD",this.store.name,e,e),gO(this.store.add(e))}get(t){return gO(this.store.get(t)).next(e=>(NR("SimpleDb","GET",this.store.name,t,e=void 0===e?null:e),e))}delete(e){return NR("SimpleDb","DELETE",this.store.name,e),gO(this.store.delete(e))}count(){return NR("SimpleDb","COUNT",this.store.name),gO(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){NR("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 cO((n,r)=>{e.onerror=e=>{var t=vO(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 cO((i,t)=>{e.onerror=e=>{t(e.target.error)},e.onsuccess=e=>{const t=e.target.result;if(t){const n=new hO(t),r=s(t.primaryKey,t.value,n);if(r instanceof cO){const e=r.catch(e=>(n.done(),cO.reject(e)));o.push(e)}n.isDone?i():null===n.Mt?t.continue():t.continue(n.Mt)}else i()}}).next(()=>cO.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 gO(e){return new cO((n,r)=>{e.onsuccess=e=>{var t=e.target.result;n(t)},e.onerror=e=>{var t=vO(e.target.error);r(t)}})}let mO=!1;function vO(e){const t=uO.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 LR("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 mO||(mO=!0,setTimeout(()=>{throw e},0)),e}}return e}class yO extends aO{constructor(e,t){super(),this.Wt=e,this.currentSequenceNumber=t}}function _O(e,t){var n=e;return uO.Dt(n.Wt,t)}class wO{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)&&xx(i,e,n[r])}}applyToLocalView(e){for(const t of this.baseMutations)t.key.isEqual(e.key)&&Dx(t,e,this.localWriteTime);for(const n of this.mutations)n.key.isEqual(e.key)&&Dx(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(XR.min())})}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),tD())}isEqual(e){return this.batchId===e.batchId&&QR(this.mutations,e.mutations,(e,t)=>Ox(e,t))&&QR(this.baseMutations,e.baseMutations,(e,t)=>Ox(e,t))}}class bO{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(e,t,n){OR(e.mutations.length===n.length);let r=Zx;var i=e.mutations;for(let s=0;s<i.length;s++)r=r.insert(i[s].key,n[s].version);return new bO(e,t,n,r)}}class TO{constructor(e,t,n,r,i=XR.min(),s=XR.min(),o=aP.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 TO(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)}withResumeToken(e,t){return new TO(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e)}withLastLimboFreeSnapshotVersion(e){return new TO(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken)}}class IO{constructor(e){this.Gt=e}}function EO(e,t){if(t.document)return CD(e.Gt,t.document,!!t.hasCommittedMutations);if(t.noDocument){const e=vP.fromSegments(t.noDocument.path),n=NO(t.noDocument.readTime),r=xP.newNoDocument(e,n);return t.hasCommittedMutations?r.setHasCommittedMutations():r}if(t.unknownDocument){const e=vP.fromSegments(t.unknownDocument.path),i=NO(t.unknownDocument.version);return xP.newUnknownDocument(e,i)}return DR()}function kO(e,t,n){var r=SO(n),i=t.key.path.popLast().toArray();if(t.isFoundDocument()){const s={name:wD(n=e.Gt,(e=t).key),fields:e.data.value.mapValue.fields,updateTime:gD(n,e.version.toTimestamp())},o=t.hasCommittedMutations;return new YD(null,null,s,o,r,i)}if(t.isNoDocument()){const a=t.key.path.toArray(),s=AO(t.version),c=t.hasCommittedMutations;return new YD(null,new GD(a,s),null,c,r,i)}if(t.isUnknownDocument()){const a=t.key.path.toArray(),s=AO(t.version);return new YD(new QD(a,s),null,null,!0,r,i)}return DR()}function SO(e){var t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function CO(e){var t=new JR(e[0],e[1]);return XR.fromTimestamp(t)}function AO(e){var t=e.toTimestamp();return new WD(t.seconds,t.nanoseconds)}function NO(e){var t=new JR(e.seconds,e.nanoseconds);return XR.fromTimestamp(t)}function RO(t,e){const n=(e.baseMutations||[]).map(e=>ND(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=>ND(t.Gt,e)),i=JR.fromMillis(e.localWriteTimeMs);return new wO(e.batchId,i,n,r)}function PO(e){var t,n=NO(e.readTime),r=void 0!==e.lastLimboFreeSnapshotVersion?NO(e.lastLimboFreeSnapshotVersion):XR.min();let i;return i=void 0!==e.query.documents?(OR(1===(t=e.query).documents.length),ax(ex(ID(t.documents[0])))):ax(xD(e.query)),new TO(i,e.targetId,0,e.lastListenSequenceNumber,n,r,aP.fromBase64String(e.resumeToken))}function xO(e,t){var n=AO(t.snapshotVersion),r=AO(t.lastLimboFreeSnapshotVersion),i=(FP(t.target)?RD:PD)(e.Gt,t.target),s=t.resumeToken.toBase64();return new XD(t.targetId,MP(t.target),n,s,t.sequenceNumber,r,i)}function DO(e){var t=xD({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?cx(t,t.limit,"L"):t}class OO{getBundleMetadata(e,t){return MO(e).get(t).next(e=>{if(e)return{id:(t=e).bundleId,createTime:NO(t.createTime),version:t.version};var t})}saveBundleMetadata(e,t){return MO(e).put({bundleId:(n=t).id,createTime:AO(vD(n.createTime)),version:n.version});var n}getNamedQuery(e,t){return LO(e).get(t).next(e=>{if(e)return{name:(t=e).name,query:DO(t.bundledQuery),readTime:NO(t.readTime)};var t})}saveNamedQuery(e,t){return LO(e).put({name:(t=t).name,readTime:AO(vD(t.readTime)),bundledQuery:t.bundledQuery})}}function MO(e){return _O(e,rO.store)}function LO(e){return _O(e,iO.store)}class FO{constructor(){this.zt=new UO}addToCollectionParentIndex(e,t){return this.zt.add(t),cO.resolve()}getCollectionParents(e,t){return cO.resolve(this.zt.getEntries(t))}}class UO{constructor(){this.index={}}add(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new Qx(rP.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 Qx(rP.comparator)).toArray()}}class jO{constructor(){this.Ht=new UO}addToCollectionParentIndex(e,t){if(this.Ht.has(t))return cO.resolve();var n=t.lastSegment(),r=t.popLast();e.addOnCommittedListener(()=>{this.Ht.add(t)});r={collectionId:n,parent:qD(r)};return qO(e).put(r)}getCollectionParents(e,n){const r=[],t=IDBKeyRange.bound([n,""],[YR(n),""],!1,!0);return qO(e).Bt(t).next(e=>{for(const t of e){if(t.collectionId!==n)break;r.push(BD(t.parent))}return r})}}function qO(e){return _O(e,tO.store)}const VO={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class BO{constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}static withCacheSize(e){return new BO(e,BO.DEFAULT_COLLECTION_PERCENTILE,BO.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}function WO(e,t,n){const r=e.store(zD.store),i=e.store(HD.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(()=>{OR(1===a)}));const l=[];for(const e of n.mutations){const r=HD.key(t,e.key.path,n.batchId);s.push(i.delete(r)),l.push(e.key)}return cO.waitFor(s).next(()=>l)}function KO(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 DR();t=e.noDocument}return JSON.stringify(t).length}BO.DEFAULT_COLLECTION_PERCENTILE=10,BO.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,BO.DEFAULT=new BO(41943040,BO.DEFAULT_COLLECTION_PERCENTILE,BO.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),BO.DISABLED=new BO(-1,0,0);class $O{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){OR(""!==e.uid);var i=e.isAuthenticated()?e.uid:"";return new $O(i,t,n,r)}checkEmpty(e){let r=!0;var t=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return HO(e).jt({index:zD.userMutationsIndex,range:t},(e,t,n)=>{r=!1,n.done()}).next(()=>r)}addMutationBatch(u,h,d,p){const f=GO(u),g=HO(u);return g.add({}).next(e=>{OR("number"==typeof e);const t=new wO(e,h,d,p),n=(i=this.k,s=this.userId,o=t,a=o.baseMutations.map(e=>AD(i.Gt,e)),c=o.mutations.map(e=>AD(i.Gt,e)),new zD(s,o.batchId,o.localWriteTime.toMillis(),a,c)),r=[];var i,s,o,a,c;let l=new Qx((e,t)=>GR(e.canonicalString(),t.canonicalString()));for(const u of p){const h=HD.key(this.userId,u.key.path,e);l=l.add(u.key.path.popLast()),r.push(g.put(n)),r.push(f.put(h,HD.PLACEHOLDER))}return l.forEach(e=>{r.push(this.Jt.addToCollectionParentIndex(u,e))}),u.addOnCommittedListener(()=>{this.Yt[e]=t.keys()}),cO.waitFor(r).next(()=>t)})}lookupMutationBatch(e,t){return HO(e).get(t).next(e=>e?(OR(e.userId===this.userId),RO(this.k,e)):null)}Zt(e,n){return this.Yt[n]?cO.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 HO(e).jt({index:zD.userMutationsIndex,range:n},(e,t,n)=>{t.userId===this.userId&&(OR(t.batchId>=r),i=RO(this.k,t)),n.done()}).next(()=>i)}getHighestUnacknowledgedBatchId(e){var t=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let r=-1;return HO(e).jt({index:zD.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 HO(e).Bt(zD.userMutationsIndex,t).next(e=>e.map(e=>RO(this.k,e)))}getAllMutationBatchesAffectingDocumentKey(o,a){const e=HD.prefixForPath(this.userId,a.path),t=IDBKeyRange.lowerBound(e),c=[];return GO(o).jt({range:t},(e,t,n)=>{var[r,i,s]=e,i=BD(i);if(r===this.userId&&a.path.isEqual(i))return HO(o).get(s).next(e=>{if(!e)throw DR();OR(e.userId===this.userId),c.push(RO(this.k,e))});n.done()}).next(()=>c)}getAllMutationBatchesAffectingDocumentKeys(t,e){let a=new Qx(GR);const n=[];return e.forEach(o=>{var e=HD.prefixForPath(this.userId,o.path),e=IDBKeyRange.lowerBound(e),e=GO(t).jt({range:e},(e,t,n)=>{var[r,i,s]=e,i=BD(i);r===this.userId&&o.path.isEqual(i)?a=a.add(s):n.done()});n.push(e)}),cO.waitFor(n).next(()=>this.te(t,a))}getAllMutationBatchesAffectingQuery(e,t){const o=t.path,a=o.length+1,n=HD.prefixForPath(this.userId,o),r=IDBKeyRange.lowerBound(n);let c=new Qx(GR);return GO(e).jt({range:r},(e,t,n)=>{var[r,i,s]=e,i=BD(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(HO(t).get(e).next(e=>{if(null===e)throw DR();OR(e.userId===this.userId),n.push(RO(this.k,e))}))}),cO.waitFor(r).next(()=>n)}removeMutationBatch(t,n){return WO(t.Wt,this.userId,n).next(e=>(t.addOnCommittedListener(()=>{this.ee(n.batchId)}),cO.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 cO.resolve();const t=IDBKeyRange.lowerBound(HD.prefixForUser(this.userId)),r=[];return GO(n).jt({range:t},(e,t,n)=>{if(e[0]===this.userId){const t=BD(e[1]);r.push(t)}else n.done()}).next(()=>{OR(0===r.length)})})}containsKey(e,t){return zO(e,this.userId,t)}ne(e){return QO(e).get(this.userId).next(e=>e||new $D(this.userId,-1,""))}}function zO(e,s,t){const n=HD.prefixForPath(s,t.path),o=n[1],r=IDBKeyRange.lowerBound(n);let a=!1;return GO(e).jt({range:r,Kt:!0},(e,t,n)=>{var[r,i]=e;r===s&&i===o&&(a=!0),n.done()}).next(()=>a)}function HO(e){return _O(e,zD.store)}function GO(e){return _O(e,HD.store)}function QO(e){return _O(e,$D.store)}class YO{constructor(e){this.se=e}next(){return this.se+=2,this.se}static ie(){return new YO(0)}static re(){return new YO(-1)}}class JO{constructor(e,t){this.referenceDelegate=e,this.k=t}allocateTargetId(n){return this.oe(n).next(e=>{const t=new YO(e.highestTargetId);return e.highestTargetId=t.next(),this.ae(n,e).next(()=>e.highestTargetId)})}getLastRemoteSnapshotVersion(e){return this.oe(e).next(e=>XR.fromTimestamp(new JR(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(()=>XO(t).delete(e.targetId)).next(()=>this.oe(t)).next(e=>(OR(0<e.targetCount),--e.targetCount,this.ae(t,e)))}removeTargets(r,i,s){let o=0;const a=[];return XO(r).jt((e,t)=>{var n=PO(t);n.sequenceNumber<=i&&null===s.get(n.targetId)&&(o++,a.push(this.removeTargetData(r,n)))}).next(()=>cO.waitFor(a)).next(()=>o)}forEachTarget(e,r){return XO(e).jt((e,t)=>{var n=PO(t);r(n)})}oe(e){return ZO(e).get(eO.key).next(e=>(OR(null!==e),e))}ae(e,t){return ZO(e).put(eO.key,t)}ce(e,t){return XO(e).put(xO(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=MP(i),t=IDBKeyRange.bound([t,Number.NEGATIVE_INFINITY],[t,Number.POSITIVE_INFINITY]);let s=null;return XO(e).jt({range:t,index:XD.queryTargetsIndexName},(e,t,n)=>{var r=PO(t);LP(i,r.target)&&(s=r,n.done())}).next(()=>s)}addMatchingKeys(n,e,r){const i=[],s=e1(n);return e.forEach(e=>{var t=qD(e.path);i.push(s.put(new ZD(r,t))),i.push(this.referenceDelegate.addReference(n,r,e))}),cO.waitFor(i)}removeMatchingKeys(n,e,r){const i=e1(n);return cO.forEach(e,e=>{var t=qD(e.path);return cO.waitFor([i.delete([r,t]),this.referenceDelegate.removeReference(n,r,e)])})}removeMatchingKeysForTargetId(e,t){const n=e1(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=e1(e);let i=tD();return r.jt({range:n,Kt:!0},(e,t,n)=>{var r=BD(e[1]),r=new vP(r);i=i.add(r)}).next(()=>i)}containsKey(e,t){var n=qD(t.path),n=IDBKeyRange.bound([n],[YR(n)],!1,!0);let r=0;return e1(e).jt({index:ZD.documentTargetsIndex,Kt:!0,range:n},([e],t,n)=>{0!==e&&(r++,n.done())}).next(()=>0<r)}Et(e,t){return XO(e).get(t).next(e=>e?PO(e):null)}}function XO(e){return _O(e,XD.store)}function ZO(e){return _O(e,eO.store)}function e1(e){return _O(e,ZD.store)}async function t1(e){if(e.code!==MR.FAILED_PRECONDITION||e.message!==oO)throw e;NR("LocalStore","Unexpectedly lost primary lease")}function n1([e,t],[n,r]){var i=GR(e,n);return 0===i?GR(t,r):i}class r1{constructor(e){this.he=e,this.buffer=new Qx(n1),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();n1(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class i1{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;NR("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){pO(e)?NR("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e):await t1(e)}await this.me(e)})}}class s1{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 cO.resolve(zR.I);const n=new r1(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?(NR("LruGarbageCollector","Garbage collection skipped; disabled"),cO.resolve(VO)):this.getCacheSize(t).next(e=>e<this.params.cacheSizeCollectionThreshold?(NR("LruGarbageCollector",`Garbage collection skipped; Cache size ${e} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),VO):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?(NR("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(),AR()<=Kh.DEBUG&&NR("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`),cO.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:s,documentsRemoved:e})))}}class o1{constructor(e,t){this.db=e,this.garbageCollector=(e=this,t=t,new s1(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 a1(e,n)}removeReference(e,t,n){return a1(e,n)}removeTargets(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}markPotentiallyOrphaned(e,t){return a1(e,t)}Ae(t,n){let r=!1;return QO(t).Qt(e=>zO(t,e,n).next(e=>(e&&(r=!0),cO.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),e1(n).delete([0,qD(t.path)])))});s.push(r)}}).next(()=>cO.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 a1(e,t)}Ie(e,r){const t=e1(e);let i,s=zR.I;return t.jt({index:ZD.documentTargetsIndex},([e],{path:t,sequenceNumber:n})=>{0===e?(s!==zR.I&&r(new vP(BD(i)),s),s=n,i=t):s=zR.I}).next(()=>{s!==zR.I&&r(new vP(BD(i)),s)})}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function a1(e,t){return e1(e).put((t=t,e=e.currentSequenceNumber,new ZD(0,qD(t.path),e)))}class c1{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){eP(this.inner,(e,t)=>{for(const[e,n]of t)r(e,n)})}isEmpty(){return tP(this.inner)}}class l1{constructor(){this.changes=new c1(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}getReadTime(e){var t=this.changes.get(e);return t?t.readTime:XR.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:xP.newInvalidDocument(e),readTime:t})}getEntry(e,t){this.assertNotApplied();var n=this.changes.get(t);return void 0!==n?cO.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 u1{constructor(e,t){this.k=e,this.Jt=t}addEntry(e,t,n){return p1(e).put(f1(t),n)}removeEntry(e,t){const n=p1(e),r=f1(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 p1(e).get(f1(t)).next(e=>this.be(t,e))}Pe(e,t){return p1(e).get(f1(t)).next(e=>({document:this.be(t,e),size:KO(e)}))}getEntries(e,t){let r=Jx;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=Jx,i=new zx(vP.comparator);return this.ve(e,t,(e,t)=>{var n=this.be(e,t);r=r.insert(e,n),i=i.insert(e,KO(t))}).next(()=>({documents:r,Se:i}))}ve(e,t,i){if(t.isEmpty())return cO.resolve();const n=IDBKeyRange.bound(t.first().path.toArray(),t.last().path.toArray()),s=t.getIterator();let o=s.getNext();return p1(e).jt({range:n},(e,t,n)=>{for(var r=vP.fromSegments(e);o&&vP.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=Jx;const o=i.path.length+1,n={};if(t.isEqual(XR.min())){const e=i.path.toArray();n.range=IDBKeyRange.lowerBound(e)}else{const e=i.path.toArray(),s=SO(t);n.range=IDBKeyRange.lowerBound([e,s],!0),n.index=YD.collectionReadTimeIndex}return p1(e).jt(n,(e,t,n)=>{var r;e.length===o&&(r=EO(this.k,t),i.path.isPrefixOf(r.key.path)?dx(i,r)&&(s=s.insert(r.key,r)):n.done())}).next(()=>s)}newChangeBuffer(e){return new h1(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next(e=>e.byteSize)}getMetadata(e){return d1(e).get(JD.key).next(e=>(OR(!!e),e))}Re(e,t){return d1(e).put(JD.key,t)}be(e,t){if(t){const e=EO(this.k,t);if(!e.isNoDocument()||!e.version.isEqual(XR.min()))return e}return xP.newInvalidDocument(e)}}class h1 extends l1{constructor(e,t){super(),this.De=e,this.trackRemovals=t,this.Ce=new c1(e=>e.toString(),(e,t)=>e.isEqual(t))}applyChanges(s){const o=[];let a=0,c=new Qx((e,t)=>GR(e.canonicalString(),t.canonicalString()));return this.changes.forEach((e,t)=>{var n=this.Ce.get(e);if(t.document.isValidDocument()){var r=kO(this.De.k,t.document,this.getReadTime(e));c=c.add(e.path.popLast());var i=KO(r);a+=i-n,o.push(this.De.addEntry(s,e,r))}else if(a-=n,this.trackRemovals){const a=kO(this.De.k,xP.newNoDocument(e,XR.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)),cO.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 d1(e){return _O(e,JD.store)}function p1(e){return _O(e,YD.store)}function f1(e){return e.path.toArray()}class g1{constructor(e){this.k=e}Nt(t,n,e,r){OR(e<r&&0<=e&&r<=11);const i=new lO("createOrUpgrade",n);var s;e<1&&1<=r&&(t.createObjectStore(KD.store),(s=t).createObjectStore($D.store,{keyPath:$D.keyPath}),s.createObjectStore(zD.store,{keyPath:zD.keyPath,autoIncrement:!0}).createIndex(zD.userMutationsIndex,zD.userMutationsKeyPath,{unique:!0}),s.createObjectStore(HD.store),m1(t),t.createObjectStore(YD.store));let o=cO.resolve();return e<3&&3<=r&&(0!==e&&((s=t).deleteObjectStore(ZD.store),s.deleteObjectStore(XD.store),s.deleteObjectStore(eO.store),m1(t)),o=o.next(()=>function(){const e=i.store(eO.store),t=new eO(0,0,XR.min().toTimestamp(),0);return e.put(eO.key,t)}())),e<4&&4<=r&&(0!==e&&(o=o.next(()=>function(r,i){return i.store(zD.store).Bt().next(e=>{r.deleteObjectStore(zD.store),r.createObjectStore(zD.store,{keyPath:zD.keyPath,autoIncrement:!0}).createIndex(zD.userMutationsIndex,zD.userMutationsKeyPath,{unique:!0});const t=i.store(zD.store),n=e.map(e=>t.put(e));return cO.waitFor(n)})}(t,i))),o=o.next(()=>{t.createObjectStore(nO.store,{keyPath:nO.keyPath})})),e<5&&5<=r&&(o=o.next(()=>this.Ne(i))),e<6&&6<=r&&(o=o.next(()=>(t.createObjectStore(JD.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(YD.store);e.createIndex(YD.readTimeIndex,YD.readTimeIndexPath,{unique:!1}),e.createIndex(YD.collectionReadTimeIndex,YD.collectionReadTimeIndexPath,{unique:!1})}()})),e<10&&10<=r&&(o=o.next(()=>this.Oe(i))),e<11&&11<=r&&(o=o.next(()=>{t.createObjectStore(rO.store,{keyPath:rO.keyPath}),t.createObjectStore(iO.store,{keyPath:iO.keyPath})})),o}ke(t){let n=0;return t.store(YD.store).jt((e,t)=>{n+=KO(t)}).next(()=>{var e=new JD(n);return t.store(JD.store).put(JD.key,e)})}Ne(r){const e=r.store($D.store),t=r.store(zD.store);return e.Bt().next(e=>cO.forEach(e,n=>{var e=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return t.Bt(zD.userMutationsIndex,e).next(e=>cO.forEach(e,e=>{OR(e.userId===n.userId);var t=RO(this.k,e);return WO(r,n.userId,t).next(()=>{})}))}))}xe(e){const o=e.store(ZD.store),t=e.store(YD.store);return e.store(eO.store).get(eO.key).next(i=>{const s=[];return t.jt((e,t)=>{const n=new rP(e),r=[0,qD(n)];s.push(o.get(r).next(e=>e?cO.resolve():(e=>o.put(new ZD(0,qD(e),i.highestListenSequenceNumber)))(n)))}).next(()=>cO.waitFor(s))})}$e(e,t){e.createObjectStore(tO.store,{keyPath:tO.keyPath});const n=t.store(tO.store),r=new UO,i=e=>{if(r.add(e)){const t=e.lastSegment(),r=e.popLast();return n.put({collectionId:t,parent:qD(r)})}};return t.store(YD.store).jt({Kt:!0},(e,t)=>{const n=new rP(e);return i(n.popLast())}).next(()=>t.store(HD.store).jt({Kt:!0},([,e],t)=>{const n=BD(e);return i(n.popLast())}))}Oe(e){const r=e.store(XD.store);return r.jt((e,t)=>{var n=PO(t),n=xO(this.k,n);return r.put(n)})}}function m1(e){e.createObjectStore(ZD.store,{keyPath:ZD.keyPath}).createIndex(ZD.documentTargetsIndex,ZD.documentTargetsKeyPath,{unique:!0}),e.createObjectStore(XD.store,{keyPath:XD.keyPath}).createIndex(XD.queryTargetsIndexName,XD.queryTargetsKeyPath,{unique:!0}),e.createObjectStore(eO.store)}const v1="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 y1{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(),!y1.Pt())throw new LR(MR.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new o1(this,r),this.Ge=t+"main",this.k=new IO(a),this.ze=new uO(this.Ge,11,new g1(this.k)),this.He=new JO(this.referenceDelegate,this.k),this.Jt=new jO,this.Je=(t=this.k,a=this.Jt,new u1(t,a)),this.Ye=new OO,this.window&&this.window.localStorage?this.Xe=this.window.localStorage:(this.Xe=null,!1===l&&RR("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 LR(MR.FAILED_PRECONDITION,v1);return this.tn(),this.en(),this.nn(),this.runTransaction("getHighestListenSequenceNumber","readonly",e=>this.He.getHighestSequenceNumber(e))}).then(e=>{this.Be=new zR(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=>w1(t).put(new nO(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(pO(e))return NR("IndexedDbPersistence","Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return NR("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 _1(e).get(KD.key).next(e=>cO.resolve(this.un(e)))}hn(e){return w1(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=_O(e,nO.store);return r.Bt().next(e=>{const t=this.dn(e,18e5),n=e.filter(e=>-1===t.indexOf(e));return cO.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?cO.resolve(!0):_1(t).get(KD.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 LR(MR.FAILED_PRECONDITION,v1);return!1}}return!(!this.networkEnabled||!this.inForeground)||w1(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&&NR("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",[KD.store,nO.store],e=>{const t=new yO(e,zR.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=>w1(e).Bt().next(e=>this.dn(e,18e5).map(e=>e.clientId)))}get started(){return this.Ue}getMutationQueue(e){return $O.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){NR("IndexedDbPersistence","Starting transaction:",t);let i;return this.ze.runTransaction(t,"readonly"===n?"readonly":"readwrite",sO,e=>(i=new yO(e,this.Be?this.Be.next():zR.I),"readwrite-primary"===n?this.rn(i).next(e=>!!e||this.on(i)).next(e=>{if(!e)throw RR(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.Fe.enqueueRetryable(()=>this.We(!1)),new LR(MR.FAILED_PRECONDITION,oO);return r(i)}).next(e=>this.cn(i).next(()=>e)):this.En(i).next(()=>r(i)))).then(e=>(i.raiseOnCommittedEvent(),e))}En(e){return _1(e).get(KD.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 LR(MR.FAILED_PRECONDITION,v1)})}cn(e){var t=new KD(this.clientId,this.allowTabSynchronization,Date.now());return _1(e).put(KD.key,t)}static Pt(){return uO.Pt()}an(e){const t=_1(e);return t.get(KD.key).next(e=>this.un(e)?(NR("IndexedDbPersistence","Releasing primary lease."),t.delete(KD.key)):cO.resolve())}fn(e,t){var n=Date.now();return!(e<n-t||n<e&&(RR(`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 NR("IndexedDbPersistence",`Client '${e}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(e){return RR("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){RR("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 _1(e){return _O(e,KD.store)}function w1(e){return _O(e,nO.store)}function b1(e,t){let n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}class T1{constructor(e,t){this.progress=e,this.In=t}}class I1{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,vP.isDocumentKey(r.path)&&null===r.collectionGroup&&0===r.filters.length?this.Sn(e,t.path):sx(t)?this.Dn(e,t,n):this.Cn(e,t,n);var r}Sn(e,t){return this.Rn(e,new vP(t)).next(e=>{let t=Xx;return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}Dn(r,i,s){const o=i.collectionGroup;let a=Xx;return this.Jt.getCollectionParents(r,o).next(e=>cO.forEach(e,e=>{var t,n=(t=i,e=e.child(o),new XP(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=xP.newInvalidDocument(n),i=i.insert(n,e)),Dx(r,e,t.localWriteTime),e.isFoundDocument()||(i=i.remove(n))}}))).next(()=>(i.forEach((e,t)=>{dx(n,t)||(i=i.remove(e))}),i))}Nn(e,t,n){let r=tD();for(const e of t)for(const t of e.mutations)t instanceof Fx&&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 E1{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.kn=n,this.xn=r}static $n(e,t){let n=tD(),r=tD();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 E1(e,t.fromCache,n,r)}}class k1{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(XR.min())?this.Mn(t,r):this.Fn.vn(t,s).next(e=>{const n=this.Ln(r,e);return(tx(r)||nx(r))&&this.Bn(r.limitType,n,s,i)?this.Mn(t,r):(AR()<=Kh.DEBUG&&NR("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),hx(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 Qx(px(n));return e.forEach((e,t)=>{dx(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 AR()<=Kh.DEBUG&&NR("QueryEngine","Using full collection scan to execute query:",hx(t)),this.Fn.getDocumentsMatchingQuery(e,t,XR.min())}}class S1{constructor(e,t,n,r){this.persistence=e,this.Un=t,this.k=r,this.qn=new zx(GR),this.Kn=new c1(e=>MP(e),LP),this.jn=XR.min(),this.An=e.getMutationQueue(n),this.Qn=e.getRemoteDocumentCache(),this.He=e.getTargetCache(),this.Wn=new I1(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 C1(e,t,n,r){return new S1(e,t,n,r)}async function A1(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 I1(n.Qn,r,n.persistence.getIndexManager()),r.getAllMutationBatches(i))).next(e=>{const t=[],n=[];let r=tD();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 N1(e){const t=e;return t.persistence.runTransaction("Get last remote snapshot version","readonly",e=>t.He.getLastRemoteSnapshotVersion(e))}function R1(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(aP.EMPTY_BYTE_STRING,XR.min()).withLastLimboFreeSnapshotVersion(XR.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=Jx;if(l.documentUpdates.forEach((e,t)=>{l.resolvedLimboDocuments.has(e)&&c.push(u.persistence.referenceDelegate.updateLimboDocument(a,e))}),c.push(P1(a,e,l.documentUpdates,h,void 0).next(e=>{t=e})),!h.isEqual(XR.min())){const l=u.He.getLastRemoteSnapshotVersion(a).next(e=>u.He.setTargetsMetadata(a,a.currentSequenceNumber,h));c.push(l)}return cO.waitFor(c).next(()=>e.apply(a)).next(()=>u.Wn.Vn(a,t)).next(()=>t)}).then(e=>(u.qn=d,e))}function P1(e,o,t,a,c){let n=tD();return t.forEach(e=>n=n.add(e)),o.getEntries(e,n).next(i=>{let s=Jx;return t.forEach((e,t)=>{const n=i.get(e),r=(null==c?void 0:c.get(e))||a;t.isNoDocument()&&t.version.isEqual(XR.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)):NR("LocalStore","Ignoring outdated watch update for ",e,". Current version:",n.version," Watch version:",t.version)}),s})}function x1(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,cO.resolve(n)):i.He.allocateTargetId(t).next(e=>(n=new TO(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 D1(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(!pO(e))throw e;NR("LocalStore",`Failed to update sequence numbers for target ${t}: ${e}`)}r.qn=r.qn.remove(t),r.Kn.delete(i.target)}function O1(e,n,r){const i=e;let s=XR.min(),o=tD();return i.persistence.runTransaction("Execute query","readonly",t=>function(e,t,n){const r=e,i=r.Kn.get(n);return void 0!==i?cO.resolve(r.qn.get(i)):r.He.getTargetData(t,n)}(i,t,ax(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:XR.min(),r?o:tD())).next(e=>({documents:e,zn:o})))}function M1(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 L1(e){const n=e;return n.persistence.runTransaction("Get new document changes","readonly",e=>function(e,t,n){const r=e;let i=Jx,s=SO(n);const o=p1(t),a=IDBKeyRange.lowerBound(s,!0);return o.jt({index:YD.readTimeIndex,range:a},(e,t)=>{var n=EO(r.k,t);i=i.insert(n.key,n),s=t.readTime}).next(()=>({In:i,readTime:CO(s)}))}(n.Qn,e,n.jn)).then(({In:e,readTime:t})=>(n.jn=t,e))}class F1{constructor(e){this.k=e,this.Xn=new Map,this.Zn=new Map}getBundleMetadata(e,t){return cO.resolve(this.Xn.get(t))}saveBundleMetadata(e,t){return this.Xn.set(t.id,{id:t.id,version:t.version,createTime:vD(t.createTime)}),cO.resolve()}getNamedQuery(e,t){return cO.resolve(this.Zn.get(t))}saveNamedQuery(e,t){return this.Zn.set(t.name,{name:(t=t).name,query:DO(t.bundledQuery),readTime:vD(t.readTime)}),cO.resolve()}}class U1{constructor(){this.ts=new Qx(j1.es),this.ns=new Qx(j1.ss)}isEmpty(){return this.ts.isEmpty()}addReference(e,t){var n=new j1(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 j1(e,t))}cs(e,t){e.forEach(e=>this.removeReference(e,t))}us(e){const t=new vP(new rP([])),n=new j1(t,e),r=new j1(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 vP(new rP([])),n=new j1(t,e),t=new j1(t,e+1);let r=tD();return this.ns.forEachInRange([n,t],e=>{r=r.add(e.key)}),r}containsKey(e){var t=new j1(e,0),t=this.ts.firstAfterOrEqual(t);return null!==t&&e.isEqual(t.key)}}class j1{constructor(e,t){this.key=e,this.fs=t}static es(e,t){return vP.comparator(e.key,t.key)||GR(e.fs,t.fs)}static ss(e,t){return GR(e.fs,t.fs)||vP.comparator(e.key,t.key)}}class q1{constructor(e,t){this.Jt=e,this.referenceDelegate=t,this.An=[],this.ds=1,this.ws=new Qx(j1.es)}checkEmpty(e){return cO.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 wO(i,t,n,r);this.An.push(s);for(const t of r)this.ws=this.ws.add(new j1(t.key,i)),this.Jt.addToCollectionParentIndex(e,t.key.path.popLast());return cO.resolve(s)}lookupMutationBatch(e,t){return cO.resolve(this._s(t))}getNextMutationBatchAfterBatchId(e,t){var n=this.gs(t+1),n=n<0?0:n;return cO.resolve(this.An.length>n?this.An[n]:null)}getHighestUnacknowledgedBatchId(){return cO.resolve(0===this.An.length?-1:this.ds-1)}getAllMutationBatches(e){return cO.resolve(this.An.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const n=new j1(t,0),r=new j1(t,Number.POSITIVE_INFINITY),i=[];return this.ws.forEachInRange([n,r],e=>{var t=this._s(e.fs);i.push(t)}),cO.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new Qx(GR);return t.forEach(e=>{var t=new j1(e,0),n=new j1(e,Number.POSITIVE_INFINITY);this.ws.forEachInRange([t,n],e=>{r=r.add(e.fs)})}),cO.resolve(this.ys(r))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,r=n.length+1;let i=n;vP.isDocumentKey(i)||(i=i.child(""));var s=new j1(new vP(i),0);let o=new Qx(GR);return this.ws.forEachWhile(e=>{var t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.fs)),!0)},s),cO.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){OR(0===this.ps(r.batchId,"removed")),this.An.shift();let i=this.ws;return cO.forEach(r.mutations,e=>{var t=new j1(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 j1(t,0),n=this.ws.firstAfterOrEqual(n);return cO.resolve(t.isEqual(n&&n.key))}performConsistencyCheck(e){return this.An.length,cO.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 V1{constructor(e,t){this.Jt=e,this.Ts=t,this.docs=new zx(vP.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 cO.resolve(n?n.document.mutableCopy():xP.newInvalidDocument(t))}getEntries(e,t){let n=Jx;return t.forEach(e=>{const t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():xP.newInvalidDocument(e))}),cO.resolve(n)}getDocumentsMatchingQuery(e,t,n){let r=Jx;const i=new vP(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||dx(t,i)&&(r=r.insert(i.key,i.mutableCopy()))}return cO.resolve(r)}Es(e,t){return cO.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new B1(this)}getSize(e){return cO.resolve(this.size)}}class B1 extends l1{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)}),cO.waitFor(r)}getFromCache(e,t){return this.De.getEntry(e,t)}getAllFromCache(e,t){return this.De.getEntries(e,t)}}class W1{constructor(e){this.persistence=e,this.Is=new c1(e=>MP(e),LP),this.lastRemoteSnapshotVersion=XR.min(),this.highestTargetId=0,this.As=0,this.Rs=new U1,this.targetCount=0,this.bs=YO.ie()}forEachTarget(e,n){return this.Is.forEach((e,t)=>n(t)),cO.resolve()}getLastRemoteSnapshotVersion(e){return cO.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return cO.resolve(this.As)}allocateTargetId(e){return this.highestTargetId=this.bs.next(),cO.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.As&&(this.As=t),cO.resolve()}ce(e){this.Is.set(e.target,e);var t=e.targetId;t>this.highestTargetId&&(this.bs=new YO(t),this.highestTargetId=t),e.sequenceNumber>this.As&&(this.As=e.sequenceNumber)}addTargetData(e,t){return this.ce(t),this.targetCount+=1,cO.resolve()}updateTargetData(e,t){return this.ce(t),cO.resolve()}removeTargetData(e,t){return this.Is.delete(t.target),this.Rs.us(t.targetId),--this.targetCount,cO.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++)}),cO.waitFor(o).next(()=>s)}getTargetCount(e){return cO.resolve(this.targetCount)}getTargetData(e,t){var n=this.Is.get(t)||null;return cO.resolve(n)}addMatchingKeys(e,t,n){return this.Rs.rs(t,n),cO.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))}),cO.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.Rs.us(t),cO.resolve()}getMatchingKeysForTargetId(e,t){var n=this.Rs.ls(t);return cO.resolve(n)}containsKey(e,t){return cO.resolve(this.Rs.containsKey(t))}}class K1{constructor(e,t){var n;this.Ps={},this.Be=new zR(0),this.Ue=!1,this.Ue=!0,this.referenceDelegate=e(this),this.He=new W1(this),this.Jt=new FO,this.Je=(n=this.Jt,e=e=>this.referenceDelegate.vs(e),new V1(n,e)),this.k=new IO(t),this.Ye=new F1(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 q1(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){NR("MemoryPersistence","Starting transaction:",e);const r=new $1(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 cO.or(Object.values(this.Ps).map(e=>()=>e.containsKey(t,n)))}}class $1 extends aO{constructor(e){super(),this.currentSequenceNumber=e}}class z1{constructor(e){this.persistence=e,this.Cs=new U1,this.Ns=null}static ks(e){return new z1(e)}get xs(){if(this.Ns)return this.Ns;throw DR()}addReference(e,t,n){return this.Cs.addReference(n,t),this.xs.delete(n.toString()),cO.resolve()}removeReference(e,t,n){return this.Cs.removeReference(n,t),this.xs.add(n.toString()),cO.resolve()}markPotentiallyOrphaned(e,t){return this.xs.add(t.toString()),cO.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 cO.forEach(this.xs,e=>{const t=vP.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 cO.or([()=>cO.resolve(this.Cs.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ds(e,t)])}}function H1(e,t){return`firestore_clients_${e}_${t}`}function G1(e,t,n){let r=`firestore_mutations_${e}_${n}`;return t.isAuthenticated()&&(r+=`_${t.uid}`),r}function Q1(e,t){return`firestore_targets_${e}_${t}`}class Y1{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 LR(r.error.code,r.error.message))),s?new Y1(e,t,r.state,i):(RR("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 J1{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 LR(n.error.code,n.error.message))),i?new J1(e,n.state,r):(RR("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 X1{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=nD;for(let s=0;r&&s<n.activeTargetIds.length;++s)r=mP(n.activeTargetIds[s]),i=i.add(n.activeTargetIds[s]);return r?new X1(e,i):(RR("SharedClientState",`Failed to parse client data for instance '${e}': ${t}`),null)}}class Z1{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 Z1(t.clientId,t.onlineState):(RR("SharedClientState",`Failed to parse online state: ${e}`),null)}}class eM{constructor(){this.activeTargetIds=nD}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 tM{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 zx(GR),this.started=!1,this.js=[];var s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Qs=H1(this.persistenceKey,this.Bs),this.Ws=`firestore_sequence_number_${this.persistenceKey}`,this.Ks=this.Ks.insert(this.Bs,new eM),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(H1(this.persistenceKey,n));var t;!e||(t=X1.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(Q1(this.persistenceKey,e)))||(n=J1.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(Q1(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 NR("SharedClientState","READ",e,t),t}setItem(e,t){NR("SharedClientState","SET",e,t),this.storage.setItem(e,t)}removeItem(e){NR("SharedClientState","REMOVE",e),this.storage.removeItem(e)}qs(e){const r=e;r.storageArea===this.storage&&(NR("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=zR.I;if(null!=e)try{var n=JSON.parse(e);OR("number"==typeof n),t=n}catch(e){RR("SharedClientState","Failed to read sequence number from WebStorage",e)}return t}(r.newValue);n!==zR.I&&this.sequenceNumberHandler(n)}else if(r.key===this.Ys)return this.syncEngine._i()}else this.js.push(r)}):RR("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 Y1(this.currentUser,e,t,n),i=G1(this.persistenceKey,this.currentUser,e);this.setItem(i,r.Fs())}si(e){var t=G1(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=Q1(this.persistenceKey,e),i=new J1(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 X1.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 Y1.Os(new kR(n),r,t)}di(e,t){var n=this.Hs.exec(e),n=Number(n[1]);return J1.Os(n,t)}Zs(e){return Z1.Os(e)}async fi(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.mi(e.batchId,e.state,e.error);NR("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=nD;return e.forEach((e,t)=>{n=n.unionWith(t.activeTargetIds)}),n}}class nM{constructor(){this.pi=new eM,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 eM,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(){}}class rM{Ei(e){}shutdown(){}}class iM{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(){NR("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.Pi)e(0)}bi(){NR("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 sM={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"};class oM{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 aM 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);NR("RestConnection","Sending: ",s,n);var o={};return this.qi(o,r,i),this.Ki(t,s,o,n).then(e=>(NR("RestConnection","Received: ",e),e),e=>{throw PR("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/"+SR,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=sM[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 IR;o.listenOnce(vR.COMPLETE,()=>{try{switch(o.getLastErrorCode()){case mR.NO_ERROR:var e=o.getResponseJson();NR("Connection","XHR received:",JSON.stringify(e)),i(e);break;case mR.TIMEOUT:NR("Connection",'RPC "'+a+'" timed out'),s(new LR(MR.DEADLINE_EXCEEDED,"Request time out"));break;case mR.HTTP_ERROR:var t,n=o.getStatus();if(NR("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(MR).indexOf(r)?r:MR.UNKNOWN,s(new LR(t,a.message))):s(new LR(MR.UNKNOWN,"Server responded with status "+o.getStatus()))}else s(new LR(MR.UNAVAILABLE,"Connection failed."));break;default:DR()}}finally{NR("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 lR,s=gR(),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 bR({})),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("");NR("Connection","Creating WebChannel: "+a,o);const c=i.createWebChannel(a,o);let l=!1,u=!1;const h=new oM({Vi:e=>{u?NR("Connection","Not sending because WebChannel is closed:",e):(l||(NR("Connection","Opening WebChannel transport."),c.open(),l=!0),NR("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,TR.EventType.OPEN,()=>{u||NR("Connection","WebChannel transport opened.")}),d(c,TR.EventType.CLOSE,()=>{u||(u=!0,NR("Connection","WebChannel transport closed"),h.Oi())}),d(c,TR.EventType.ERROR,e=>{u||(u=!0,PR("Connection","WebChannel transport errored:",e),h.Oi(new LR(MR.UNAVAILABLE,"The operation could not be completed")))}),d(c,TR.EventType.MESSAGE,n=>{if(!u){var e=n.data[0];OR(!!e);var r=e.error||(null===(r=e[0])||void 0===r?void 0:r.error);if(r){NR("Connection","WebChannel received error:",r);const n=r.status;let e=function(e){var t=fR[e];if(void 0!==t)return $x(t)}(n),t=r.message;void 0===e&&(e=MR.INTERNAL,t="Unknown error status: "+n+" with message "+r.message),u=!0,h.Oi(new LR(e,t)),c.close()}else NR("Connection","WebChannel received:",e),h.Fi(e)}}),d(s,yR.STAT_EVENT,e=>{e.stat===_R?NR("Connection","Detected buffering proxy"):e.stat===wR&&NR("Connection","Detected no buffering proxy")}),setTimeout(()=>{h.$i()},0),h}}function cM(){return"undefined"!=typeof window?window:null}function lM(){return"undefined"!=typeof document?document:null}function uM(e){return new fD(e,!0)}class hM{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&&NR("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 dM{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 hM(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===MR.RESOURCE_EXHAUSTED?(RR(t.toString()),RR("Using maximum backoff delay to prevent overloading the backend."),this.ur.Xi()):t&&t.code===MR.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 LR(MR.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 NR("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}Er(t){return e=>{this.Fe.enqueueAndForget(()=>this.rr===t?e():(NR("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class pM extends dM{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:DR(),i=t.targetChange.targetIds||[],s=(p=t.targetChange.resumeToken,e.C?(OR(void 0===p||"string"==typeof p),aP.fromBase64String(p||"")):(OR(void 0===p||p instanceof Uint8Array),aP.fromUint8Array(p||new Uint8Array))),o=t.targetChange.cause,a=o&&(a=void 0===(p=o).code?MR.UNKNOWN:$x(p.code),new LR(a,p.message||""));n=new aD(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=bD(e,c.document.name),l=vD(c.document.updateTime),u=new PP({mapValue:{fields:c.document.fields}}),l=xP.newFoundDocument(a,l,u),u=c.targetIds||[],c=c.removedTargetIds||[];n=new sD(u,c,l.key,l)}else if("documentDelete"in t){t.documentDelete;u=t.documentDelete;u.document;c=bD(e,u.document),l=u.readTime?vD(u.readTime):XR.min(),l=xP.newNoDocument(c,l),u=u.removedTargetIds||[];n=new sD([],u,l.key,l)}else if("documentRemove"in t){t.documentRemove;var h=t.documentRemove;h.document;var d=bD(e,h.document),h=h.removedTargetIds||[];n=new sD([],h,d,null)}else{if(!("filter"in t))return DR();{t.filter;const e=t.filter;e.targetId;h=e.count||0,d=new Wx(h),h=e.targetId;n=new oD(h,d)}}var a,p;return n}(this.k,e),n=function(e){if(!("targetChange"in e))return XR.min();var t=e.targetChange;return(!t.targetIds||!t.targetIds.length)&&t.readTime?vD(t.readTime):XR.min()}(e);return this.listener.br(t,n)}Pr(e){const t={};t.database=ED(this.k),t.addTarget=function(e,t){let n;var r=t.target;return n=FP(r)?{documents:RD(e,r)}:{query:PD(e,r)},n.targetId=t.targetId,0<t.resumeToken.approximateByteSize()?n.resumeToken=mD(e,t.resumeToken):0<t.snapshotVersion.compareTo(XR.min())&&(n.readTime=gD(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 DR()}}())?null:{"goog-listen-tags":r});r&&(t.labels=r),this.gr(t)}vr(e){const t={};t.database=ED(this.k),t.removeTarget=e,this.gr(t)}}class fM extends dM{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(OR(!!e.streamToken),this.lastStreamToken=e.streamToken,this.Vr){this.ur.reset();var t=(r=e.writeResults,i=e.commitTime,r&&0<r.length?(OR(void 0!==i),r.map(e=>function(e,t){let n=e.updateTime?vD(e.updateTime):vD(t);return n.isEqual(XR.min())&&(n=vD(t)),new Ax(n,e.transformResults||[])}(e,i))):[]),n=vD(e.commitTime);return this.listener.Cr(n,t)}var r,i;return OR(!e.writeResults||0===e.writeResults.length),this.Vr=!0,this.listener.Nr()}kr(){const e={};e.database=ED(this.k),this.gr(e)}Dr(e){var t={streamToken:this.lastStreamToken,writes:e.map(e=>AD(this.k,e))};this.gr(t)}}class gM 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 LR(MR.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===MR.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new LR(MR.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===MR.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new LR(MR.UNKNOWN,e.toString())})}terminate(){this.$r=!0}}class mM{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?(RR(t),this.Lr=!1):NR("OnlineStateTracker",t)}jr(){null!==this.Mr&&(this.Mr.cancel(),this.Mr=null)}}class vM{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()=>{SM(this)&&(NR("RemoteStore","Restarting streams for network reachability change."),await async function(e){const t=e;t.Gr.add(4),await _M(t),t.Jr.set("Unknown"),t.Gr.delete(4),await yM(t)}(this))})}),this.Jr=new mM(n,r)}}async function yM(e){if(SM(e))for(const t of e.zr)await t(!0)}async function _M(e){for(const t of e.zr)await t(!1)}function wM(e,t){const n=e;n.Wr.has(t.targetId)||(n.Wr.set(t.targetId,t),kM(n)?EM(n):OM(n).lr()&&TM(n,t))}function bM(e,t){const n=e,r=OM(n);n.Wr.delete(t),r.lr()&&IM(n,t),0===n.Wr.size&&(r.lr()?r._r():SM(n)&&n.Jr.set("Unknown"))}function TM(e,t){e.Yr.X(t.targetId),OM(e).Pr(t)}function IM(e,t){e.Yr.X(t),OM(e).vr(t)}function EM(t){t.Yr=new lD({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),Et:e=>t.Wr.get(e)||null}),OM(t).start(),t.Jr.Br()}function kM(e){return SM(e)&&!OM(e).hr()&&0<e.Wr.size}function SM(e){return 0===e.Gr.size}function CM(e){e.Yr=void 0}async function AM(e,t,n){if(!pO(t))throw t;e.Gr.add(1),await _M(e),e.Jr.set("Offline"),n=n||(()=>N1(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{NR("RemoteStore","Retrying IndexedDB access"),await n(),e.Gr.delete(1),await yM(e)})}function NM(t,n){return n().catch(e=>AM(t,e,n))}async function RM(e){const t=e,n=MM(t);let r=0<t.Qr.length?t.Qr[t.Qr.length-1].batchId:-1;for(;SM(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=MM(e);n.lr()&&n.Sr&&n.Dr(t.mutations)}(t,e)}catch(e){await AM(t,e)}var i;PM(t)&&xM(t)}function PM(e){return SM(e)&&!MM(e).hr()&&0<e.Qr.length}function xM(e){MM(e).start()}async function DM(e,t){const n=e;t?(n.Gr.delete(2),await yM(n)):(n.Gr.add(2),await _M(n),n.Jr.set("Unknown"))}function OM(t){return t.Xr||(t.Xr=function(e,t,n){const r=e;return r.Or(),new pM(t,r.ir,r.authCredentials,r.appCheckCredentials,r.k,n)}(t.datastore,t.asyncQueue,{Di:(async function(n){n.Wr.forEach((e,t)=>{TM(n,e)})}).bind(null,t),Ni:(async function(e,t){CM(e),kM(e)?(e.Jr.Kr(t),EM(e)):e.Jr.set("Unknown")}).bind(null,t),br:(async function(e,r,t){if(e.Jr.set("Online"),r instanceof aD&&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){NR("RemoteStore","Failed to remove targets %s: %s ",r.targetIds.join(","),t),await AM(e,t)}else if(r instanceof sD?e.Yr.ot(r):r instanceof oD?e.Yr.dt(r):e.Yr.ut(r),!t.isEqual(XR.min()))try{const r=await N1(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(aP.EMPTY_BYTE_STRING,t.snapshotVersion)),IM(r,e),n=new TO(t.target,e,1,t.sequenceNumber),TM(r,n))}),r.remoteSyncer.applyRemoteEvent(e)}(e,t)}catch(r){NR("RemoteStore","Failed to raise snapshot:",r),await AM(e,r)}}).bind(null,t)}),t.zr.push(async e=>{e?(t.Xr.wr(),kM(t)?EM(t):t.Jr.set("Unknown")):(await t.Xr.stop(),CM(t))})),t.Xr}function MM(t){return t.Zr||(t.Zr=function(e,t,n){const r=e;return r.Or(),new fM(t,r.ir,r.authCredentials,r.appCheckCredentials,r.k,n)}(t.datastore,t.asyncQueue,{Di:(async function(e){MM(e).kr()}).bind(null,t),Ni:(async function(e,t){t&&MM(e).Sr&&await async function(e,t){if(Kx(n=t.code)&&n!==MR.ABORTED){const n=e.Qr.shift();MM(e).wr(),await NM(e,()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t)),await RM(e)}var n}(e,t),PM(e)&&xM(e)}).bind(null,t),Nr:(async function(e){const t=MM(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=bO.from(r,t,n);await NM(e,()=>e.remoteSyncer.applySuccessfulWrite(i)),await RM(e)}).bind(null,t)}),t.zr.push(async e=>{e?(t.Zr.wr(),await RM(t)):(await t.Zr.stop(),0<t.Qr.length&&(NR("RemoteStore",`Stopping write stream with ${t.Qr.length} pending writes`),t.Qr=[]))})),t.Zr}class LM{constructor(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new FR,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 LM(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 LR(MR.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 FM(e,t){if(RR("AsyncQueue",`${t}: ${e}`),pO(e))return new LR(MR.UNAVAILABLE,`${t}: ${e}`);throw e}class UM{constructor(n){this.comparator=n?(e,t)=>n(e,t)||vP.comparator(e.key,t.key):(e,t)=>vP.comparator(e.key,t.key),this.keyedMap=Xx,this.sortedSet=new zx(this.comparator)}static emptySet(e){return new UM(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 UM))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 UM;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}class jM{constructor(){this.eo=new zx(vP.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}):DR()}no(){const n=[];return this.eo.inorderTraversal((e,t)=>{n.push(t)}),n}}class qM{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 qM(e,t,UM.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)&&lx(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 VM{constructor(){this.so=void 0,this.listeners=[]}}class BM{constructor(){this.queries=new c1(e=>ux(e),lx),this.onlineState="Unknown",this.io=new Set}}async function WM(e,t){const n=e,r=t.query;let i=!1,s=n.queries.get(r);if(s||(i=!0,s=new VM),i)try{s.so=await n.onListen(r)}catch(e){const n=FM(e,`Initialization of query '${hx(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)&&$M(n)}async function KM(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 $M(e){e.io.forEach(e=>{e.next()})}class zM{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 qM(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=qM.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache),this.co=!0,this.ao.next(e)}}class HM{constructor(e,t){this.payload=e,this.byteLength=t}_o(){return"metadata"in this.payload}}class GM{constructor(e){this.k=e}Hn(e){return bD(this.k,e)}Jn(e){return e.metadata.exists?CD(this.k,e.document,!1):xP.newNoDocument(this.Hn(e.metadata.name),this.Yn(e.metadata.readTime))}Yn(e){return vD(e)}}class QM{constructor(e,t,n){this.mo=e,this.localStore=t,this.k=n,this.queries=[],this.documents=[],this.progress=YM(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 GM(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)||tD()).add(e);t.set(n,r)}}return t}async complete(){const e=await async function(e,t,n,r){const i=e;let s=tD(),o=Jx,a=Zx;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 x1(i,(r=r,ax(ex(rP.fromString(`__bundle__/docs/${r}`)))));return i.persistence.runTransaction("Apply bundle documents","readwrite",t=>P1(t,c,o,XR.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 GM(this.k),this.documents,this.mo.id),t=this.po(this.documents);for(const e of this.queries)await async function(e,n,r=tD()){const i=await x1(e,ax(DO(n.bundledQuery))),s=e;return s.persistence.runTransaction("Save named query","readwrite",e=>{var t=vD(n.readTime);if(0<=i.snapshotVersion.compareTo(t))return s.Ye.saveNamedQuery(e,n);t=i.withResumeToken(aP.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 T1(Object.assign({},this.progress),e)}}function YM(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}class JM{constructor(e){this.key=e}}class XM{constructor(e){this.key=e}}class ZM{constructor(e,t){this.query=e,this.To=t,this.Eo=null,this.current=!1,this.Io=tD(),this.mutatedKeys=tD(),this.Ao=px(e),this.Ro=new UM(this.Ao)}get bo(){return this.To}Po(e,t){const a=t?t.vo:new jM,c=(t||this).Ro;let l=(t||this).mutatedKeys,u=c,h=!1;const d=tx(this.query)&&c.size===this.query.limit?c.last():null,p=nx(this.query)&&c.size===this.query.limit?c.first():null;if(e.inorderTraversal((e,t)=>{const n=c.get(e),r=dx(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)))}),tx(this.query)||nx(this.query))for(;u.size>this.query.limit;){const e=tx(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 DR()}};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 qM(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 jM,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=tD(),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 XM(e))}),this.Io.forEach(e=>{t.has(e)||n.push(new JM(e))}),n}ko(e){this.To=e.zn,this.Io=tD();var t=this.Po(e.documents);return this.applyChanges(t,!0)}xo(){return qM.fromInitialDocuments(this.query,this.Ro,this.mutatedKeys,0===this.Eo)}}class eL{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class tL{constructor(e){this.key=e,this.$o=!1}}class nL{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 c1(e=>ux(e),lx),this.Mo=new Map,this.Lo=new Set,this.Bo=new zx(vP.comparator),this.Uo=new Map,this.qo=new U1,this.Ko={},this.jo=new Map,this.Qo=YO.re(),this.onlineState="Unknown",this.Wo=void 0}get isPrimaryClient(){return!0===this.Wo}}async function rL(n,e,t,r){n.Go=(e,s,t)=>async function(e,t,n){let r=t.view.Po(s);r.Bn&&(r=await O1(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 dL(e,t.targetId,i.Co),i.snapshot}(n,e,t);const i=await O1(n.localStore,e,!0),s=new ZM(e,i.zn),o=s.Po(i.documents),a=iD.createSynthesizedTargetChangeForCurrentChange(t,r&&"Offline"!==n.onlineState),c=s.applyChanges(o,n.isPrimaryClient,a);dL(n,t,c.Co);var l=new eL(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 iL(e,t,n){const r=_L(e);try{const e=await function(e,r){const i=e,s=JR.now(),t=r.reduce((e,t)=>e.add(t.key),tD());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=yx(r.transform,e||null);null!=i&&(null==n&&(n=PP.empty()),n.set(r.field,i))}return n||null}(n,o.get(n.key));null!=r&&t.push(new Fx(n.key,r,function r(e){const i=[];return eP(e.fields,(e,t)=>{const n=new sP([e]);if(NP(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 oP(i)}(r.value.mapValue),Nx.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 zx(GR),r=r.insert(t,n),e.Ko[e.currentUser.toKey()]=r}(r,e.batchId,n),await fL(r,e.changes),await RM(r.remoteStore)}catch(e){const t=FM(e,"Failed to persist write");n.reject(t)}}async function sL(e,t){const r=e;try{const e=await R1(r.localStore,t);t.targetChanges.forEach((e,t)=>{const n=r.Uo.get(t);n&&(OR(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1),0<e.addedDocuments.size?n.$o=!0:0<e.modifiedDocuments.size?OR(n.$o):0<e.removedDocuments.size&&(OR(n.$o),n.$o=!1))}),await fL(r,e,t)}catch(e){await t1(e)}}function oL(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&&$M(t)}(t.eventManager,i),r.length&&t.Oo.br(r),t.onlineState=i,t.isPrimaryClient&&t.sharedClientState.setOnlineState(i)}}async function aL(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=cO.resolve();return n.forEach(n=>{o=o.next(()=>i.getEntry(t,n)).next(e=>{var t=r.docVersions.get(n);OR(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);lL(n,r,null),cL(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await fL(n,e)}catch(e){await t1(e)}}function cL(e,t){(e.jo.get(t)||[]).forEach(e=>{e.resolve()}),e.jo.delete(t)}function lL(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 uL(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)||hL(t,e)})}function hL(e,t){e.Lo.delete(t.path.canonicalString());var n=e.Bo.get(t);null!==n&&(bM(e.remoteStore,n),e.Bo=e.Bo.remove(t),e.Uo.delete(n),pL(e))}function dL(e,t,n){for(const r of n)r instanceof JM?(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)||(NR("SyncEngine","New document in limbo: "+n),e.Lo.add(r),pL(e))}(e,r)):r instanceof XM?(NR("SyncEngine","Document no longer in limbo: "+r.key),e.qo.removeReference(r.key,t),e.qo.containsKey(r.key)||hL(e,r.key)):DR()}function pL(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 vP(rP.fromString(t)),t=e.Qo.next();e.Uo.set(t,new tL(n)),e.Bo=e.Bo.insert(n,t),wM(e.remoteStore,new TO(ax(ex(n.path)),t,2,zR.I))}}async function fL(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=E1.$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=>cO.forEach(t,t=>cO.forEach(t.kn,e=>r.persistence.referenceDelegate.addReference(n,t.targetId,e)).next(()=>cO.forEach(t.xn,e=>r.persistence.referenceDelegate.removeReference(n,t.targetId,e)))))}catch(e){if(!pO(e))throw e;NR("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 gL(r,e){const i=r;if(yL(i),_L(i),!0===e&&!0!==i.Wo){const r=i.sharedClientState.getAllActiveQueryTargets(),e=await mL(i,r.toArray());i.Wo=!0,await DM(i.remoteStore,!0);for(const r of e)wM(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(()=>(uL(i,t),D1(i.localStore,t,!0))),bM(i.remoteStore,t)}),await n,await mL(i,r),function(){const n=i;n.Uo.forEach((e,t)=>{bM(n.remoteStore,t)}),n.qo.hs(),n.Uo=new Map,n.Bo=new zx(vP.comparator)}(),i.Wo=!1,await DM(i.remoteStore,!1)}}async function mL(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 x1(r.localStore,ax(u[0]));for(const t of u){const n=r.Fo.get(t),u=(o=r,a=n,l=c=void 0,l=await O1((c=o).localStore,a.query,!0),l=a.view.ko(l),c.isPrimaryClient&&dL(c,a.targetId,l.Co),await l);u.snapshot&&s.push(u.snapshot)}}else{const u=await M1(r.localStore,t);e=await x1(r.localStore,u),await rL(r,vL(u),t,!1)}i.push(e)}var o,a,c,l;return r.Oo.br(s),i}function vL(e){return ZP(e.path,e.collectionGroup,e.orderBy,e.filters,e.limit,"F",e.startAt,e.endAt)}function yL(e){const t=e;return t.remoteStore.remoteSyncer.applyRemoteEvent=sL.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=(function(e,t){const n=e,r=n.Uo.get(t);if(r&&r.$o)return tD().add(r.key);{let e=tD();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 zx(vP.comparator);e=e.insert(s,xP.newNoDocument(s,XR.min()));const n=tD().add(s),i=new rD(XR.min(),new Map,new Qx(GR),e,n);await sL(r,i),r.Bo=r.Bo.remove(s),r.Uo.delete(t),pL(r)}else await D1(r.localStore,t,!1).then(()=>uL(r,t,n)).catch(t1)}).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&&$M(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 _L(e){const t=e;return t.remoteStore.remoteSyncer.applySuccessfulWrite=aL.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=>(OR(null!==e),n=e.keys(),i.An.removeMutationBatch(t,e))).next(()=>i.An.performConsistencyCheck(t)).next(()=>i.Wn.vn(t,n))})}(r.localStore,t);lL(r,t,n),cL(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),await fL(r,e)}catch(n){await t1(n)}}).bind(null,t),t}class wL{constructor(){this.synchronizeTabs=!1}async initialize(e){this.k=uM(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 C1(this.persistence,new k1,e.initialUser,this.k)}Yo(e){return new K1(z1.ks,this.k)}Jo(e){return new nM}async terminate(){this.gcScheduler&&this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class bL extends wL{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=p1(t);let r=XR.min();return e.jt({index:YD.readTimeIndex,reverse:!0},(e,t,n)=>{t.readTime&&(r=CO(t.readTime)),n.done()}).next(()=>r)}()).then(e=>{t.jn=e})}(this.localStore),await this.ta.initialize(this,e),await _L(this.ta.syncEngine),await RM(this.ta.remoteStore),await this.persistence.sn(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(this.localStore),Promise.resolve()))}Zo(e){return C1(this.persistence,new k1,e.initialUser,this.k)}Xo(e){var t=this.persistence.referenceDelegate.garbageCollector;return new i1(t,e.asyncQueue)}Yo(e){var t=b1(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?BO.withCacheSize(this.cacheSizeBytes):BO.DEFAULT;return new y1(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,cM(),lM(),this.k,this.sharedClientState,!!this.forceOwnership)}Jo(e){return new nM}}class TL extends bL{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 tM&&(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):cO.resolve(null)))}(i.localStore,t);null!==s?("pending"===n?await RM(i.remoteStore):"acknowledged"===n||"rejected"===n?(lL(i,t,r||null),cL(i,t),i.localStore.An.ee(t)):DR(),await fL(i,s)):NR("SyncEngine","Cannot apply mutation batch with id: "+t)}).bind(null,t),gi:(async function(e,t,n,r){const i=e;if(i.Wo)NR("SyncEngine","Ignoring unexpected query state notification.");else if(i.Mo.has(t))switch(n){case"current":case"not-current":{const e=await L1(i.localStore),r=rD.createSynthesizedRemoteEventForCurrentChange(t,"current"===n);await fL(i,e,r);break}case"rejected":await D1(i.localStore,t,!0),uL(i,t,r);break;default:DR()}}).bind(null,t),yi:(async function(e,t,n){const r=yL(e);if(r.Wo){for(const e of t)if(r.Mo.has(e))NR("SyncEngine","Adding an already active target "+e);else{const t=await M1(r.localStore,e),n=await x1(r.localStore,t);await rL(r,vL(t),n.targetId,!1),wM(r.remoteStore,n)}for(const e of n)r.Mo.has(e)&&await D1(r.localStore,e,!1).then(()=>{bM(r.remoteStore,e),uL(r,e)}).catch(t1)}}).bind(null,t),Tn:(function(e){return e.localStore.persistence.Tn()}).bind(null,t),_i:(async function(e){const t=e;return L1(t.localStore).then(e=>fL(t,e))}).bind(null,t)},await this.sharedClientState.start()),await this.persistence.sn(async e=>{await gL(this.ta.syncEngine,e),this.gcScheduler&&(e&&!this.gcScheduler.started?this.gcScheduler.start(this.localStore):e||this.gcScheduler.stop())})}Jo(e){var t=cM();if(!tM.Pt(t))throw new LR(MR.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var n=b1(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new tM(t,e.asyncQueue,n,e.clientId,e.initialUser)}}class IL{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=>oL(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=(async function(e,t){const n=e;if(!n.currentUser.isEqual(t)){NR("SyncEngine","User change. New user:",t.toKey());const r=await A1(n.localStore,t);n.currentUser=t,(e=n).jo.forEach(e=>{e.forEach(e=>{e.reject(new LR(MR.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.jo.clear(),n.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),await fL(n,r.Gn)}}).bind(null,this.syncEngine),await DM(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new BM}createDatastore(e){var t,n,r,i,s=uM(e.databaseInfo.databaseId),t=(t=e.databaseInfo,new aM(t));return n=e.authCredentials,r=e.appCheckCredentials,i=t,e=s,new gM(n,r,i,e)}createRemoteStore(e){return t=this.localStore,n=this.datastore,r=e.asyncQueue,i=e=>oL(this.syncEngine,e,0),s=new(iM.Pt()?iM:rM),new vM(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 nL(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;NR("RemoteStore","RemoteStore shutting down."),t.Gr.add(5),await _M(t),t.Hr.shutdown(),t.Jr.set("Unknown")}(this.remoteStore)}}function EL(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 kL{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 SL{constructor(e,t){this.sa=e,this.k=t,this.metadata=new FR,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 HM(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 CL{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 LR(MR.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");const t=await async function(e,t){const r=e,n=ED(r.k)+"/documents",i={documents:t.map(e=>wD(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){OR(!!t.found),t.found.name,t.found.updateTime;var n=bD(e,t.found.name),r=vD(t.found.updateTime),i=new PP({mapValue:{fields:t.found.fields}});return xP.newFoundDocument(n,r,i)}(n,e):"missing"in e?function(e,t){OR(!!t.missing),OR(!!t.readTime);var n=bD(e,t.missing),r=vD(t.readTime);return xP.newNoDocument(n,r)}(n,e):DR());var n;o.set(t.key.toString(),t)});const a=[];return t.forEach(e=>{var t=o.get(e.toString());OR(!!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 Vx(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=vP.fromPath(t);this.mutations.push(new Bx(n,this.precondition(n)))}),await async function(e,t){const n=e,r=ED(n.k)+"/documents",i={writes:t.map(e=>AD(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 DR();t=XR.min()}var n=this.readVersions.get(e.key.toString());if(n){if(!t.isEqual(n))throw new LR(MR.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?Nx.updateTime(t):Nx.none()}preconditionForUpdate(e){const t=this.readVersions.get(e.toString());if(this.writtenDocs.has(e.toString())||!t)return Nx.exists(!0);if(t.isEqual(XR.min()))throw new LR(MR.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Nx.updateTime(t)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}class AL{constructor(e,t,n,r){this.asyncQueue=e,this.datastore=t,this.updateFunction=n,this.deferred=r,this.la=5,this.ur=new hM(this.asyncQueue,"transaction_retry")}run(){--this.la,this.fa()}fa(){this.ur.Zi(async()=>{const t=new CL(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!fP(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||!Kx(t)}}class NL{constructor(e,t,n,r){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=kR.UNAUTHENTICATED,this.clientId=HR.A(),this.authCredentialListener=()=>Promise.resolve(),this.authCredentials.start(n,async e=>{NR("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 LR(MR.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const n=new FR;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=FM(e,"Failed to shutdown persistence");n.reject(t)}}),n.promise}}async function RL(e,t){e.asyncQueue.verifyOperationInProgress(),NR("FirestoreClient","Initializing OfflineComponentProvider");var n=await e.getConfiguration();await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener(async e=>{r.isEqual(e)||(await A1(t.localStore,e),r=e)}),t.persistence.setDatabaseDeletedListener(()=>e.terminate()),e.offlineComponents=t}async function PL(e,t){e.asyncQueue.verifyOperationInProgress();var n=await xL(e);NR("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(),NR("RemoteStore","RemoteStore received new credentials");var r=SM(n);n.Gr.add(3),await _M(n),r&&n.Jr.set("Unknown"),await n.remoteSyncer.handleCredentialChange(t),n.Gr.delete(3),await yM(n)}(t.remoteStore,e)),e.onlineComponents=t}async function xL(e){return e.offlineComponents||(NR("FirestoreClient","Using default OfflineComponentProvider"),await RL(e,new wL)),e.offlineComponents}async function DL(e){return e.onlineComponents||(NR("FirestoreClient","Using default OnlineComponentProvider"),await PL(e,new IL)),e.onlineComponents}function OL(e){return xL(e).then(e=>e.persistence)}function ML(e){return xL(e).then(e=>e.localStore)}function LL(e){return DL(e).then(e=>e.remoteStore)}function FL(e){return DL(e).then(e=>e.syncEngine)}async function UL(e){const t=await DL(e),n=t.eventManager;return n.onListen=(async function(e,t){const n=yL(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 x1(n.localStore,ax(t)),s=n.sharedClientState.addLocalQueryTarget(e.targetId);r=e.targetId,i=await rL(n,t,r,"current"===s),n.isPrimaryClient&&wM(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=>!lx(e,t))),void n.Fo.delete(t);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)||await D1(n.localStore,r.targetId,!1).then(()=>{n.sharedClientState.clearQueryState(r.targetId),bM(n.remoteStore,r.targetId),uL(n,r.targetId)}).catch(t1)):(uL(n,r.targetId),await D1(n.localStore,r.targetId,!0))}).bind(null,t.syncEngine),n}function jL(e,t,n={}){const r=new FR;return e.asyncQueue.enqueueAndForget(async()=>function(n,r,i,s,o){const e=new kL({next:e=>{r.enqueueAndForget(()=>KM(n,a));var t=e.docs.has(i);!t&&e.fromCache?o.reject(new LR(MR.UNAVAILABLE,"Failed to get document because the client is offline.")):t&&e.fromCache&&s&&"server"===s.source?o.reject(new LR(MR.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 zM(ex(i.path),e,{includeMetadataChanges:!0,wo:!0});return WM(n,a)}(await UL(e),e.asyncQueue,t,n,r)),r.promise}function qL(e,t,n={}){const r=new FR;return e.asyncQueue.enqueueAndForget(async()=>function(t,n,e,r,i){const s=new kL({next:e=>{n.enqueueAndForget(()=>KM(t,o)),e.fromCache&&"server"===r.source?i.reject(new LR(MR.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 zM(e,s,{includeMetadataChanges:!0,wo:!0});return WM(t,o)}(await UL(e),e.asyncQueue,t,n,r)),r.promise}function VL(e,t,n,r){const i=(n=n,t=uM(t),s="string"==typeof n?(new TextEncoder).encode(n):n,n=function(e){if(e instanceof Uint8Array)return EL(e,void 0);if(e instanceof ArrayBuffer)return EL(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 SL(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=vD(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(YM(i));const o=new QM(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 fL(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){PR("SyncEngine",`Loading bundle failed with ${t}`),r._failWith(t)}}(r,t,n).then(()=>{r.sharedClientState.notifyBundleLoaded()})}(await FL(e),i,r)})}class BL{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 WL{constructor(e,t){this.projectId=e,this.database=t||"(default)"}get isDefaultDatabase(){return"(default)"===this.database}isEqual(e){return e instanceof WL&&e.projectId===this.projectId&&e.database===this.database}}const KL=new Map;function $L(e,t,n){if(!n)throw new LR(MR.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function zL(e,t,n,r){if(!0===t&&!0===r)throw new LR(MR.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function HL(e){if(!vP.isDocumentKey(e))throw new LR(MR.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function GL(e){if(vP.isDocumentKey(e))throw new LR(MR.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function QL(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":DR();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 YL(e,t){if((e="_delegate"in e?e._delegate:e)instanceof t)return e;if(t.name===e.constructor.name)throw new LR(MR.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");var n=QL(e);throw new LR(MR.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}function JL(e,t){if(t<=0)throw new LR(MR.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}class XL{constructor(e){var t;if(void 0===e.host){if(void 0!==e.ssl)throw new LR(MR.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 LR(MR.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.useFetchStreams=!!e.useFetchStreams,zL("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 ZL{constructor(e,t,n){this._authCredentials=t,this._appCheckCredentials=n,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new XL({}),this._settingsFrozen=!1,e instanceof WL?this._databaseId=e:(this._app=e,this._databaseId=function(e){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new LR(MR.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new WL(e.options.projectId)}(e))}get app(){if(!this._app)throw new LR(MR.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 LR(MR.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 XL(e),void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new jR;switch(e.type){case"gapi":var t=e.client;return OR(!("object"!=typeof t||null===t||!t.auth||!t.auth.getAuthHeaderValueForFirstParty)),new WR(t,e.sessionIndex||"0",e.iamToken||null);case"provider":return e.client;default:throw new LR(MR.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=KL.get(e);t&&(NR("ComponentProvider","Removing Datastore"),KL.delete(e),t.terminate())}(this),Promise.resolve()}}class eF{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 nF(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new eF(this.firestore,e,this._key)}}class tF{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new tF(this.firestore,e,this._query)}}class nF extends tF{constructor(e,t,n){super(e,t,ex(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 eF(this.firestore,null,new vP(e))}withConverter(e){return new nF(this.firestore,e,this._path)}}function rF(e,t,...n){if(e=Kd(e),$L("collection","path",t),e instanceof ZL){var r=rP.fromString(t,...n);return GL(r),new nF(e,null,r)}if(!(e instanceof eF||e instanceof nF))throw new LR(MR.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");r=e._path.child(rP.fromString(t,...n));return GL(r),new nF(e.firestore,null,r)}function iF(e,t,...n){if(e=Kd(e),$L("doc","path",t=1===arguments.length?HR.A():t),e instanceof ZL){var r=rP.fromString(t,...n);return HL(r),new eF(e,null,new vP(r))}if(!(e instanceof eF||e instanceof nF))throw new LR(MR.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");r=e._path.child(rP.fromString(t,...n));return HL(r),new eF(e.firestore,e instanceof nF?e.converter:null,new vP(r))}function sF(e,t){return e=Kd(e),t=Kd(t),(e instanceof eF||e instanceof nF)&&(t instanceof eF||t instanceof nF)&&e.firestore===t.firestore&&e.path===t.path&&e.converter===t.converter}function oF(e,t){return e=Kd(e),t=Kd(t),e instanceof tF&&t instanceof tF&&e.firestore===t.firestore&&lx(e._query,t._query)&&e.converter===t.converter}class aF{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 hM(this,"async_queue_retry"),this.Ra=()=>{var e=lM();e&&NR("AsyncQueue","Visibility state changed to "+e.visibilityState),this.ur.er()};const e=lM();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=lM();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.Ra)}}enqueue(e){if(this.ba(),this.ya)return new Promise(()=>{});const t=new FR;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(!pO(e))throw e;NR("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,RR("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=LM.createAndSchedule(this,e,t,n,e=>this.Va(e));return this.pa.push(r),r}ba(){this.Ta&&DR()}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 cF(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 lF{constructor(){this._progressObserver={},this._taskCompletionResolver=new FR,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 uF,hF,dF,pF;class fF extends ZL{constructor(e,t,n){super(e,t,n),this.type="firestore",this._queue=new aF,this._persistenceKey="name"in e?e.name:"[DEFAULT]"}_terminate(){return this._firestoreClient||mF(this),this._firestoreClient.terminate()}}function gF(e){return e._firestoreClient||mF(e),e._firestoreClient.verifyNotTerminated(),e._firestoreClient}function mF(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 BL(n,r,i,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,s.useFetchStreams));e._firestoreClient=new NL(e._authCredentials,e._appCheckCredentials,e._queue,o)}function vF(e,n,r){const i=new FR;return e.asyncQueue.enqueue(async()=>{try{await RL(e,r),await PL(e,n),i.resolve()}catch(e){if(!("FirebaseError"===(t=e).name?t.code===MR.FAILED_PRECONDITION||t.code===MR.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 yF(e){return function(e){const t=new FR;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t){const n=e;SM(n.remoteStore)||NR("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=FM(e,"Initialization of waitForPendingWrites() operation failed");t.reject(n)}}(await FL(e),t)),t.promise}(gF(e=YL(e,fF)))}function _F(e){return(n=gF(e=YL(e,fF))).asyncQueue.enqueue(async()=>{const e=await OL(n),t=await LL(n);return e.setNetworkEnabled(!0),function(){const e=t;return e.Gr.delete(0),yM(e)}()});var n}function wF(e){return(n=gF(e=YL(e,fF))).asyncQueue.enqueue(async()=>{const e=await OL(n),t=await LL(n);return e.setNetworkEnabled(!1),async function(){const e=t;e.Gr.add(0),await _M(e),e.Jr.set("Offline")}()});var n}function bF(t,e){return n=gF(t=YL(t,fF)),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 ML(n),r)).then(e=>e?new tF(t,null,e.query):null);var n,r}function TF(e){if(e._initialized||e._terminated)throw new LR(MR.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 IF{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new LR(MR.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new sP(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class EF{constructor(e){this._byteString=e}static fromBase64String(e){try{return new EF(aP.fromBase64String(e))}catch(e){throw new LR(MR.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new EF(aP.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 kF{constructor(e){this._methodName=e}}class SF{constructor(e,t){if(!isFinite(e)||e<-90||90<e)throw new LR(MR.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||180<t)throw new LR(MR.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 GR(this._lat,e._lat)||GR(this._long,e._long)}}const CF=/^__.*__$/;class AF{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return null!==this.fieldMask?new Fx(e,this.data,this.fieldMask,t,this.fieldTransforms):new Lx(e,this.data,t,this.fieldTransforms)}}class NF{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new Fx(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function RF(e){switch(e){case 0:case 2:case 1:return 1;case 3:case 4:return;default:throw DR()}}class PF{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 PF(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 JF(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(RF(this.xa)&&CF.test(e))throw this.Ua('Document fields cannot begin and end with "__"')}}class xF{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.k=n||uM(e)}ja(e,t,n,r=!1){return new PF({xa:e,methodName:t,Ka:n,path:sP.emptyPath(),Fa:!1,qa:r},this.databaseId,this.k,this.ignoreUndefinedProperties)}}function DF(e){var t=e._freezeSettings(),n=uM(e._databaseId);return new xF(e._databaseId,!!t.ignoreUndefinedProperties,n)}function OF(e,t,n,r,i,s={}){const o=e.ja(s.merge||s.mergeFields?2:0,t,n,i);HF("Data must be an object, but it was:",o,r);var a=$F(r,o);let c,l;if(s.merge)c=new oP(o.fieldMask),l=o.fieldTransforms;else if(s.mergeFields){const e=[];for(const r of s.mergeFields){const i=GF(t,r,n);if(!o.contains(i))throw new LR(MR.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);XF(e,i)||e.push(i)}c=new oP(e),l=o.fieldTransforms.filter(e=>c.covers(e.field))}else c=null,l=o.fieldTransforms;return new AF(new PP(a),c,l)}class MF extends kF{_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 MF}}function LF(e,t,n){return new PF({xa:3,Ka:t.settings.Ka,methodName:e._methodName,Fa:n},t.databaseId,t.k,t.ignoreUndefinedProperties)}class FF extends kF{_toFieldTransform(e){return new Cx(e.path,new _x)}isEqual(e){return e instanceof FF}}class UF extends kF{constructor(e,t){super(e),this.Qa=t}_toFieldTransform(e){const t=LF(this,e,!0),n=this.Qa.map(e=>KF(e,t)),r=new wx(n);return new Cx(e.path,r)}isEqual(e){return this===e}}class jF extends kF{constructor(e,t){super(e),this.Qa=t}_toFieldTransform(e){const t=LF(this,e,!0),n=this.Qa.map(e=>KF(e,t)),r=new Tx(n);return new Cx(e.path,r)}isEqual(e){return this===e}}class qF extends kF{constructor(e,t){super(e),this.Wa=t}_toFieldTransform(e){var t=new Ex(e.k,mx(e.k,this.Wa));return new Cx(e.path,t)}isEqual(e){return this===e}}function VF(e,i,s,t){const o=e.ja(1,i,s);HF("Data must be an object, but it was:",o,t);const a=[],c=PP.empty();eP(t,(e,t)=>{var n=YF(i,e,s);t=Kd(t);var r=o.La(n);if(t instanceof MF)a.push(n);else{const e=KF(t,r);null!=e&&(a.push(n),c.set(n,e))}});var n=new oP(a);return new NF(c,n,o.fieldTransforms)}function BF(e,t,n,r,i,s){const o=e.ja(1,t,n),a=[GF(t,r,n)],c=[i];if(s.length%2!=0)throw new LR(MR.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(GF(t,s[p])),c.push(s[p+1]);const l=[],u=PP.empty();for(let f=a.length-1;0<=f;--f)if(!XF(l,a[f])){const t=a[f];var h=Kd(h=c[f]);const r=o.La(t);if(h instanceof MF)l.push(t);else{const e=KF(h,r);null!=e&&(l.push(t),u.set(t,e))}}var d=new oP(l);return new NF(u,d,o.fieldTransforms)}function WF(e,t,n,r=!1){return KF(n,e.ja(r?4:3,t))}function KF(s,e){if(zF(s=Kd(s)))return HF("Unsupported field value:",e,s),$F(s,e);if(s instanceof kF)return function(e,t){if(!RF(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=KF(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 mx(t.k,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){var n=JR.fromDate(e);return{timestampValue:gD(t.k,n)}}if(e instanceof JR){n=new JR(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:gD(t.k,n)}}if(e instanceof SF)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof EF)return{bytesValue:mD(t.k,e._byteString)};if(e instanceof eF){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:yD(e.firestore._databaseId||t.databaseId,e._key.path)}}throw t.Ua(`Unsupported field value: ${QL(e)}`)}(0,e)}function $F(e,r){const i={};return tP(e)?r.path&&0<r.path.length&&r.fieldMask.push(r.path):eP(e,(e,t)=>{var n=KF(t,r.Oa(e));null!=n&&(i[e]=n)}),{mapValue:{fields:i}}}function zF(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof JR||e instanceof SF||e instanceof EF||e instanceof eF||e instanceof kF)}function HF(e,t,n){if(!zF(n)||("object"!=typeof(i=n)||null===i||Object.getPrototypeOf(i)!==Object.prototype&&null!==Object.getPrototypeOf(i))){var r=QL(n);throw"an object"===r?t.Ua(e+" a custom object"):t.Ua(e+" "+r)}var i}function GF(e,t,n){if((t=Kd(t))instanceof IF)return t._internalPath;if("string"==typeof t)return YF(e,t);throw JF("Field path arguments must be of type string or FieldPath.",e,!1,void 0,n)}const QF=new RegExp("[~\\*/\\[\\]]");function YF(t,n,r){if(0<=n.search(QF))throw JF(`Invalid field path (${n}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,r);try{return new IF(...n.split("."))._internalPath}catch(e){throw JF(`Invalid field path (${n}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,r)}}function JF(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 LR(MR.INVALID_ARGUMENT,a+e+c)}function XF(e,t){return e.some(e=>e.isEqual(t))}class ZF{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 eF(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){var e=new eU(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(tU("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class eU extends ZF{data(){return super.data()}}function tU(e,t){return"string"==typeof t?YF(e,t):(t instanceof IF?t:t._delegate)._internalPath}class nU{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class rU extends ZF{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 iU(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(tU("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}}class iU extends rU{data(e={}){return super.data(e)}}class sU{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new nU(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 iU(this._firestore,this._userDataWriter,e.key,e,new nU(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 LR(MR.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 iU(s._firestore,s._userDataWriter,e.doc.key,e.doc,new nU(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 iU(s._firestore,s._userDataWriter,e.doc.key,e.doc,new nU(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 DR()}}(e.type),doc:t,oldIndex:n,newIndex:r}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function oU(e,t){return e instanceof rU&&t instanceof rU?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 sU&&t instanceof sU&&e._firestore===t._firestore&&oF(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)}function aU(e){if(nx(e)&&0===e.explicitOrderBy.length)throw new LR(MR.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class cU{}function lU(e,...t){for(const n of t)e=n._apply(e);return e}class uU extends cU{constructor(e,t,n){super(),this.Ga=e,this.za=t,this.Ha=n,this.type="where"}_apply(e){var t=DF(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 LR(MR.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on FieldPath.documentId().`);if("in"===s||"not-in"===s){vU(o,s);const t=[];for(const n of o)t.push(mU(r,e,n));a={arrayValue:{values:t}}}else a=mU(r,e,o)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||vU(o,s),a=WF(n,t,o,"in"===s||"not-in"===s);var c=UP.create(i,s,a);return function(e,t){if(t.V()){const r=ix(e);if(null!==r&&!r.isEqual(t.field))throw new LR(MR.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=rx(e);null!==n&&yU(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 LR(MR.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new LR(MR.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 tF(e.firestore,e.converter,(e=e._query,t=e.filters.concat([t]),new XP(e.path,e.collectionGroup,e.explicitOrderBy.slice(),t,e.limit,e.limitType,e.startAt,e.endAt)))}}class hU extends cU{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 LR(MR.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new LR(MR.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var r,i=new QP(t,n);return n=i,null!==rx(e=e)||null!==(r=ix(e))&&yU(0,r,n.field),i}(e._query,this.Ga,this.Ja);return new tF(e.firestore,e.converter,(e=e._query,t=e.explicitOrderBy.concat([t]),new XP(e.path,e.collectionGroup,t,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)))}}class dU extends cU{constructor(e,t,n){super(),this.type=e,this.Ya=t,this.Xa=n}_apply(e){return new tF(e.firestore,e.converter,cx(e._query,this.Ya,this.Xa))}}class pU extends cU{constructor(e,t,n){super(),this.type=e,this.Za=t,this.tc=n}_apply(e){var t,n=gU(e,this.type,this.Za,this.tc);return new tF(e.firestore,e.converter,(t=e._query,e=n,new XP(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)))}}class fU extends cU{constructor(e,t,n){super(),this.type=e,this.Za=t,this.tc=n}_apply(e){var t,n=gU(e,this.type,this.Za,this.tc);return new tF(e.firestore,e.converter,(t=e._query,e=n,new XP(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)))}}function gU(e,t,n,r){if(n[0]=Kd(n[0]),n[0]instanceof ZF)return function(e,t,n,r,i){if(!r)throw new LR(MR.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);const s=[];for(const n of ox(e))if(n.field.isKeyField())s.push(EP(t,r.key));else{const e=r.data.field(n.field);if(dP(e))throw new LR(MR.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 LR(MR.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 HP(s,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);var i=DF(e.firestore);return function(e,t,n,r,i,s){const o=e.explicitOrderBy;if(i.length>o.length)throw new LR(MR.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 LR(MR.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof l}`);if(!sx(e)&&-1!==l.indexOf("/"))throw new LR(MR.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(rP.fromString(l));if(!vP.isDocumentKey(n))throw new LR(MR.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 vP(n);a.push(EP(t,i))}else{const e=WF(n,r,l);a.push(e)}}return new HP(a,s)}(e._query,e.firestore._databaseId,i,t,n,r)}function mU(e,t,n){if("string"==typeof(n=Kd(n))){if(""===n)throw new LR(MR.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!sx(t)&&-1!==n.indexOf("/"))throw new LR(MR.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(rP.fromString(n));if(!vP.isDocumentKey(r))throw new LR(MR.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 EP(e,new vP(r))}if(n instanceof eF)return EP(e,n._key);throw new LR(MR.INVALID_ARGUMENT,`Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: ${QL(n)}.`)}function vU(e,t){if(!Array.isArray(e)||0===e.length)throw new LR(MR.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`);if(10<e.length)throw new LR(MR.INVALID_ARGUMENT,`Invalid Query. '${t.toString()}' filters support a maximum of 10 elements in the value array.`)}function yU(e,t,n){if(!n.isEqual(t))throw new LR(MR.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 _U{convertValue(e,t="none"){switch(yP(e)){case 0:return null;case 1:return e.booleanValue;case 2:return uP(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(hP(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 DR()}}convertObject(e,n){const r={};return eP(e.fields,(e,t)=>{r[e]=this.convertValue(t,n)}),r}convertGeoPoint(e){return new SF(uP(e.latitude),uP(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 dP(n)?e(n):n}(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(pP(e));default:return null}}convertTimestamp(e){var t=lP(e);return new JR(t.seconds,t.nanos)}convertDocumentKey(e,t){const n=rP.fromString(e);OR(jD(n));const r=new WL(n.get(1),n.get(3)),i=new vP(n.popFirst(5));return r.isEqual(t)||RR(`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 wU(e,t,n){return e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t}class bU extends _U{constructor(e){super(),this.firestore=e}convertBytes(e){return new EF(e)}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return new eF(this.firestore,null,t)}}class TU{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=DF(e)}set(e,t,n){this._verifyNotCommitted();const r=IU(e,this._firestore),i=wU(r.converter,t,n),s=OF(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(s.toMutation(r._key,Nx.none())),this}update(e,t,n,...r){this._verifyNotCommitted();var i=IU(e,this._firestore);let s;return s="string"==typeof(t=Kd(t))||t instanceof IF?BF(this._dataReader,"WriteBatch.update",i._key,t,n,r):VF(this._dataReader,"WriteBatch.update",i._key,t),this._mutations.push(s.toMutation(i._key,Nx.exists(!0))),this}delete(e){this._verifyNotCommitted();var t=IU(e,this._firestore);return this._mutations=this._mutations.concat(new Vx(t._key,Nx.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 LR(MR.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function IU(e,t){if((e=Kd(e)).firestore!==t)throw new LR(MR.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}class EU extends _U{constructor(e){super(),this.firestore=e}convertBytes(e){return new EF(e)}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return new eF(this.firestore,null,t)}}function kU(t){t=YL(t,eF);const n=YL(t.firestore,fF),e=gF(n),r=new EU(n);return function(e,t){const n=new FR;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 LR(MR.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=FM(e,`Failed to get document '${t} from cache`);n.reject(r)}}(await ML(e),t,n)),n.promise}(e,t._key).then(e=>new rU(n,r,t._key,e,new nU(null!==e&&e.hasLocalMutations,!0),t.converter))}function SU(t){t=YL(t,tF);const n=YL(t.firestore,fF),e=gF(n),r=new EU(n);return function(e,t){const n=new FR;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t,n){try{const i=await O1(e,t,!0),s=new ZM(t,i.zn),o=s.Po(i.documents),a=s.applyChanges(o,!1);n.resolve(a.snapshot)}catch(e){var r=FM(e,`Failed to execute query '${t} against cache`);n.reject(r)}}(await ML(e),t,n)),n.promise}(e,t._query).then(e=>new sU(n,r,t,e))}function CU(e,t,n){e=YL(e,eF);var r=YL(e.firestore,fF),i=wU(e.converter,t,n);return PU(r,[OF(DF(r),"setDoc",e._key,i,null!==e.converter,n).toMutation(e._key,Nx.none())])}function AU(e,t,n,...r){e=YL(e,eF);var i=YL(e.firestore,fF),s=DF(i);let o;return o="string"==typeof(t=Kd(t))||t instanceof IF?BF(s,"updateDoc",e._key,t,n,r):VF(s,"updateDoc",e._key,t),PU(i,[o.toMutation(e._key,Nx.exists(!0))])}function NU(t,...n){var e;t=Kd(t);let r={includeMetadataChanges:!1},i=0;"object"!=typeof n[i]||cF(n[i])||(r=n[i],i++);var s={includeMetadataChanges:r.includeMetadataChanges};if(cF(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 eF)a=YL(t.firestore,fF),c=ex(t._key.path),o={next:e=>{n[i]&&n[i](xU(a,t,e))},error:n[i+1],complete:n[i+2]};else{const l=YL(t,tF);a=YL(l.firestore,fF),c=l._query;const u=new EU(a);o={next:e=>{n[i]&&n[i](new sU(a,u,l,e))},error:n[i+1],complete:n[i+2]},aU(t._query)}return function(e,t,n,r){const i=new kL(r),s=new zM(t,i,n);return e.asyncQueue.enqueueAndForget(async()=>WM(await UL(e),s)),()=>{i.na(),e.asyncQueue.enqueueAndForget(async()=>KM(await UL(e),s))}}(gF(a),c,s,o)}function RU(e,t){return function(e,t){const n=new kL(t);return e.asyncQueue.enqueueAndForget(async()=>function(e,t){e.io.add(t),t.next()}(await UL(e),n)),()=>{n.na(),e.asyncQueue.enqueueAndForget(async()=>function(e,t){e.io.delete(t)}(await UL(e),n))}}(gF(e=YL(e,fF)),cF(t)?t:{next:t})}function PU(e,t){return function(e,t){const n=new FR;return e.asyncQueue.enqueueAndForget(async()=>iL(await FL(e),t,n)),n.promise}(gF(e),t)}function xU(e,t,n){var r=n.docs.get(t._key),i=new EU(e);return new rU(e,i,t._key,r,new nU(n.hasPendingWrites,n.fromCache),t.converter)}class DU extends class{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=DF(e)}get(e){const n=IU(e,this._firestore),r=new bU(this._firestore);return this._transaction.lookup([n._key]).then(e=>{if(!e||1!==e.length)return DR();const t=e[0];if(t.isFoundDocument())return new ZF(this._firestore,r,t.key,t,n.converter);if(t.isNoDocument())return new ZF(this._firestore,r,n._key,null,n.converter);throw DR()})}set(e,t,n){var r=IU(e,this._firestore),i=wU(r.converter,t,n),i=OF(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=IU(e,this._firestore),s="string"==typeof(t=Kd(t))||t instanceof IF?BF(this._dataReader,"Transaction.update",i._key,t,n,r):VF(this._dataReader,"Transaction.update",i._key,t);return this._transaction.update(i._key,s),this}delete(e){var t=IU(e,this._firestore);return this._transaction.delete(t._key),this}}{constructor(e,t){super(e,t),this._firestore=e}get(e){const t=IU(e,this._firestore),n=new EU(this._firestore);return super.get(e).then(e=>new rU(this._firestore,n,t._key,e._document,new nU(!1,!1),t.converter))}}function OU(t,n){return function(t,n){const r=new FR;return t.asyncQueue.enqueueAndForget(async()=>{var e=await DL(t).then(e=>e.datastore);new AL(t.asyncQueue,e,n,r).run()}),r.promise}(gF(t=YL(t,fF)),e=>n(new DU(t,e)))}z=mp,SR=z,dp(new $d("firestore",(e,{options:t})=>{const n=e.getProvider("app").getImmediate(),r=new fF(n,new VR(e.getProvider("auth-internal")),new $R(e.getProvider("app-check-internal")));return t=Object.assign({useFetchStreams:!0},t),r._setSettings(t),r},"PUBLIC")),wp(ER,"3.4.2-canary.044a8d7f9",void 0),wp(ER,"3.4.2-canary.044a8d7f9","esm2017");function MU(e,t){if(void 0===t)return{merge:!1};if(void 0!==t.mergeFields&&void 0!==t.merge)throw new LR("invalid-argument",`Invalid options passed to function ${e}(): You cannot `+'specify both "merge" and "mergeFields".');return t}function LU(){if("undefined"==typeof Uint8Array)throw new LR("unimplemented","Uint8Arrays are not available in this environment.")}function FU(){if("undefined"==typeof atob)throw new LR("unimplemented","Blobs are unavailable in Firestore in this environment.")}class UU{constructor(e){this._delegate=e}static fromBase64String(e){return FU(),new UU(EF.fromBase64String(e))}static fromUint8Array(e){return LU(),new UU(EF.fromUint8Array(e))}toBase64(){return FU(),this._delegate.toBase64()}toUint8Array(){return LU(),this._delegate.toUint8Array()}isEqual(e){return this._delegate.isEqual(e._delegate)}toString(){return"Blob(base64: "+this.toBase64()+")"}}function jU(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 qU{enableIndexedDbPersistence(e,t){return function(e,t){TF(e=YL(e,fF));var n=gF(e),r=e._freezeSettings(),i=new IL;return vF(n,i,new bL(i,r.cacheSizeBytes,null==t?void 0:t.forceOwnership))}(e._delegate,{forceOwnership:t})}enableMultiTabIndexedDbPersistence(e){return function(e){TF(e=YL(e,fF));var t=gF(e),n=e._freezeSettings(),r=new IL;return vF(t,r,new TL(r,n.cacheSizeBytes))}(e._delegate)}clearIndexedDbPersistence(e){return function(e){if(e._initialized&&!e._terminated)throw new LR(MR.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const t=new FR;return e._queue.enqueueAndForgetEvenWhileRestricted(async()=>{try{await async function(e){if(!uO.Pt())return Promise.resolve();var t=e+"main";await uO.delete(t)}(b1(e._databaseId,e._persistenceKey)),t.resolve()}catch(e){t.reject(e)}}),t.promise}(e._delegate)}}class VU{constructor(e,t,n){this._delegate=t,this._persistenceProvider=n,this.INTERNAL={delete:()=>this.terminate()},e instanceof WL||(this._appCompat=e)}get _databaseId(){return this._delegate._databaseId}settings(e){var t=this._delegate._getSettings();e.merge||t.host===e.host||PR("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=YL(n,ZL))._getSettings();if("firestore.googleapis.com"!==s.host&&s.host!==e&&PR("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=kR.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 LR(MR.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");t=new kR(s)}n._authCredentials=new qR(new UR(e,t))}}(this._delegate,e,t,n)}enableNetwork(){return _F(this._delegate)}disableNetwork(){return wF(this._delegate)}enablePersistence(e){let t=!1,n=!1;return e&&(t=!!e.synchronizeTabs,n=!!e.experimentalForceOwningTab,zL("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 yF(this._delegate)}onSnapshotsInSync(e){return RU(this._delegate,e)}get app(){if(!this._appCompat)throw new LR("failed-precondition","Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._appCompat}collection(e){try{return new tj(this,rF(this._delegate,e))}catch(e){throw HU(e,"collection()","Firestore.collection()")}}doc(e){try{return new zU(this,iF(this._delegate,e))}catch(e){throw HU(e,"doc()","Firestore.doc()")}}collectionGroup(e){try{return new XU(this,function(e,t){if(e=YL(e,ZL),$L("collectionGroup","collection id",t),0<=t.indexOf("/"))throw new LR(MR.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new tF(e,null,(t=t,new XP(rP.emptyPath(),t)))}(this._delegate,e))}catch(e){throw HU(e,"collectionGroup()","Firestore.collectionGroup()")}}runTransaction(t){return OU(this._delegate,e=>t(new WU(this,e)))}batch(){return gF(this._delegate),new KU(new TU(this._delegate,e=>PU(this._delegate,e)))}loadBundle(e){return t=this._delegate,e=e,n=gF(t=YL(t,fF)),r=new lF,VL(n,t._databaseId,e,r),r;var t,n,r}namedQuery(e){return bF(this._delegate,e).then(e=>e?new XU(this,e):null)}}class BU extends _U{constructor(e){super(),this.firestore=e}convertBytes(e){return new UU(new EF(e))}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return zU.forKey(t,this.firestore,null)}}class WU{constructor(e,t){this._firestore=e,this._delegate=t,this._userDataWriter=new BU(e)}get(e){const t=nj(e);return this._delegate.get(t).then(e=>new YU(this._firestore,new rU(this._firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,t.converter)))}set(e,t,n){var r=nj(e);return n?(MU("Transaction.set",n),this._delegate.set(r,t,n)):this._delegate.set(r,t),this}update(e,t,n,...r){var i=nj(e);return 2===arguments.length?this._delegate.update(i,t):this._delegate.update(i,t,n,...r),this}delete(e){var t=nj(e);return this._delegate.delete(t),this}}class KU{constructor(e){this._delegate=e}set(e,t,n){var r=nj(e);return n?(MU("WriteBatch.set",n),this._delegate.set(r,t,n)):this._delegate.set(r,t),this}update(e,t,n,...r){var i=nj(e);return 2===arguments.length?this._delegate.update(i,t):this._delegate.update(i,t,n,...r),this}delete(e){var t=nj(e);return this._delegate.delete(t),this}commit(){return this._delegate.commit()}}class $U{constructor(e,t,n){this._firestore=e,this._userDataWriter=t,this._delegate=n}fromFirestore(e,t){var n=new iU(this._firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,null);return this._delegate.fromFirestore(new JU(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=$U.INSTANCES;let r=n.get(e);r||(r=new WeakMap,n.set(e,r));let i=r.get(t);return i||(i=new $U(e,new BU(e),t),r.set(t,i)),i}}$U.INSTANCES=new WeakMap;class zU{constructor(e,t){this.firestore=e,this._delegate=t,this._userDataWriter=new BU(e)}static forPath(e,t,n){if(e.length%2!=0)throw new LR("invalid-argument","Invalid document reference. Document references must have an even number of segments, but "+`${e.canonicalString()} has ${e.length}`);return new zU(t,new eF(t._delegate,n,new vP(e)))}static forKey(e,t,n){return new zU(t,new eF(t._delegate,n,e))}get id(){return this._delegate.id}get parent(){return new tj(this.firestore,this._delegate.parent)}get path(){return this._delegate.path}collection(e){try{return new tj(this.firestore,rF(this._delegate,e))}catch(e){throw HU(e,"collection()","DocumentReference.collection()")}}isEqual(e){return(e=Kd(e))instanceof eF&&sF(this._delegate,e)}set(e,t){t=MU("DocumentReference.set",t);try{return t?CU(this._delegate,e,t):CU(this._delegate,e)}catch(e){throw HU(e,"setDoc()","DocumentReference.set()")}}update(e,t,...n){try{return 1===arguments.length?AU(this._delegate,e):AU(this._delegate,e,t,...n)}catch(e){throw HU(e,"updateDoc()","DocumentReference.update()")}}delete(){return PU(YL((e=this._delegate).firestore,fF),[new Vx(e._key,Nx.none())]);var e}onSnapshot(...e){var t=GU(e),n=QU(e,e=>new YU(this.firestore,new rU(this.firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,this._delegate.converter)));return NU(this._delegate,t,n)}get(e){let t;return t=("cache"===(null==e?void 0:e.source)?kU:"server"===(null==e?void 0:e.source)?function(t){t=YL(t,eF);const n=YL(t.firestore,fF);return jL(gF(n),t._key,{source:"server"}).then(e=>xU(n,t,e))}:function(t){t=YL(t,eF);const n=YL(t.firestore,fF);return jL(gF(n),t._key).then(e=>xU(n,t,e))})(this._delegate),t.then(e=>new YU(this.firestore,new rU(this.firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,this._delegate.converter)))}withConverter(e){return new zU(this.firestore,e?this._delegate.withConverter($U.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}function HU(e,t,n){return e.message=e.message.replace(t,n),e}function GU(e){for(const t of e)if("object"==typeof t&&!jU(t))return t;return{}}function QU(e,t){var n;let r;return r=jU(e[0])?e[0]:jU(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 YU{constructor(e,t){this._firestore=e,this._delegate=t}get ref(){return new zU(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 oU(this._delegate,e._delegate)}}class JU extends YU{data(e){var t=this._delegate.data(e);return void 0!==t||DR(),t}}class XU{constructor(e,t){this.firestore=e,this._delegate=t,this._userDataWriter=new BU(e)}where(e,t,n){try{return new XU(this.firestore,lU(this._delegate,(r=n,i=t,s=tU("where",e),new uU(s,i,r))))}catch(e){throw HU(e,/(orderBy|where)\(\)/,"Query.$1()")}var r,i,s}orderBy(e,t){try{return new XU(this.firestore,lU(this._delegate,([n,r="asc"]=[e,t],i=r,s=tU("orderBy",n),new hU(s,i))))}catch(e){throw HU(e,/(orderBy|where)\(\)/,"Query.$1()")}var n,r,i,s}limit(e){try{return new XU(this.firestore,lU(this._delegate,(JL("limit",t=e),new dU("limit",t,"F"))))}catch(e){throw HU(e,"limit()","Query.limit()")}var t}limitToLast(e){try{return new XU(this.firestore,lU(this._delegate,(JL("limitToLast",t=e),new dU("limitToLast",t,"L"))))}catch(e){throw HU(e,"limitToLast()","Query.limitToLast()")}var t}startAt(...e){try{return new XU(this.firestore,lU(this._delegate,function(...e){return new pU("startAt",e,!0)}(...e)))}catch(e){throw HU(e,"startAt()","Query.startAt()")}}startAfter(...e){try{return new XU(this.firestore,lU(this._delegate,function(...e){return new pU("startAfter",e,!1)}(...e)))}catch(e){throw HU(e,"startAfter()","Query.startAfter()")}}endBefore(...e){try{return new XU(this.firestore,lU(this._delegate,function(...e){return new fU("endBefore",e,!0)}(...e)))}catch(e){throw HU(e,"endBefore()","Query.endBefore()")}}endAt(...e){try{return new XU(this.firestore,lU(this._delegate,function(...e){return new fU("endAt",e,!1)}(...e)))}catch(e){throw HU(e,"endAt()","Query.endAt()")}}isEqual(e){return oF(this._delegate,e._delegate)}get(e){let t;return t=("cache"===(null==e?void 0:e.source)?SU:"server"===(null==e?void 0:e.source)?function(t){t=YL(t,tF);const n=YL(t.firestore,fF),e=gF(n),r=new EU(n);return qL(e,t._query,{source:"server"}).then(e=>new sU(n,r,t,e))}:function(t){t=YL(t,tF);const n=YL(t.firestore,fF),e=gF(n),r=new EU(n);return aU(t._query),qL(e,t._query).then(e=>new sU(n,r,t,e))})(this._delegate),t.then(e=>new ej(this.firestore,new sU(this.firestore._delegate,this._userDataWriter,this._delegate,e._snapshot)))}onSnapshot(...e){var t=GU(e),n=QU(e,e=>new ej(this.firestore,new sU(this.firestore._delegate,this._userDataWriter,this._delegate,e._snapshot)));return NU(this._delegate,t,n)}withConverter(e){return new XU(this.firestore,e?this._delegate.withConverter($U.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}class ZU{constructor(e,t){this._firestore=e,this._delegate=t}get type(){return this._delegate.type}get doc(){return new JU(this._firestore,this._delegate.doc)}get oldIndex(){return this._delegate.oldIndex}get newIndex(){return this._delegate.newIndex}}class ej{constructor(e,t){this._firestore=e,this._delegate=t}get query(){return new XU(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 JU(this._firestore,e))}docChanges(e){return this._delegate.docChanges(e).map(e=>new ZU(this._firestore,e))}forEach(t,n){this._delegate.forEach(e=>{t.call(n,new JU(this._firestore,e))})}isEqual(e){return oU(this._delegate,e._delegate)}}class tj extends XU{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 zU(this.firestore,e):null}doc(e){try{return void 0===e?new zU(this.firestore,iF(this._delegate)):new zU(this.firestore,iF(this._delegate,e))}catch(e){throw HU(e,"doc()","CollectionReference.doc()")}}add(e){return function(e,t){const n=YL(e.firestore,fF),r=iF(e),i=wU(e.converter,t);return PU(n,[OF(DF(e.firestore),"addDoc",r._key,i,null!==e.converter,{}).toMutation(r._key,Nx.exists(!1))]).then(()=>r)}(this._delegate,e).then(e=>new zU(this.firestore,e))}isEqual(e){return sF(this._delegate,e._delegate)}withConverter(e){return new tj(this.firestore,e?this._delegate.withConverter($U.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}function nj(e){return YL(e,eF)}const rj={Firestore:VU,GeoPoint:SF,Timestamp:JR,Blob:UU,Transaction:WU,WriteBatch:KU,DocumentReference:zU,DocumentSnapshot:YU,Query:XU,QueryDocumentSnapshot:JU,QuerySnapshot:ej,CollectionReference:tj,FieldPath:class oK{constructor(...e){this._delegate=new IF(...e)}static documentId(){return new oK(sP.keyField().canonicalString())}isEqual(e){return(e=Kd(e))instanceof IF&&this._delegate._internalPath.isEqual(e._internalPath)}},FieldValue:class aK{constructor(e){this._delegate=e}static serverTimestamp(){const e=new FF("serverTimestamp");return e._methodName="FieldValue.serverTimestamp",new aK(e)}static delete(){const e=new MF("deleteField");return e._methodName="FieldValue.delete",new aK(e)}static arrayUnion(...e){const t=function(...e){return new UF("arrayUnion",e)}(...e);return t._methodName="FieldValue.arrayUnion",new aK(t)}static arrayRemove(...e){const t=function(...e){return new jF("arrayRemove",e)}(...e);return t._methodName="FieldValue.arrayRemove",new aK(t)}static increment(e){const t=new qF("increment",e);return t._methodName="FieldValue.increment",new aK(t)}isEqual(e){return this._delegate.isEqual(e._delegate)}},setLogLevel:function(e){e=e,CR.setLogLevel(e)},CACHE_SIZE_UNLIMITED:-1};uF=Ap,hF=(e,t)=>new VU(e,t,new qU),uF.INTERNAL.registerComponent(new $d("firestore-compat",e=>{var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("firestore").getImmediate();return hF(t,n)},"PUBLIC").setServiceProps(Object.assign({},rj))),uF.registerVersion("@firebase/firestore-compat","0.1.11-canary.044a8d7f9");function ij(e,t){const n={};for(const r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r]));return n}function sj(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=>sj(e)):"function"==typeof e||"object"==typeof e?ij(e,e=>sj(e)):e}const oj="functions",aj={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 cj extends gd{constructor(e,t,n){super(`${oj}/${e}`,t||""),this.details=n}}function lj(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(!aj[e])return new cj("internal","internal");n=aj[e],r=e}var o=s.message;"string"==typeof o&&(r=o),i=s.details,void 0!==i&&(i=sj(i))}}catch(e){}return"ok"===n?null:new cj(n,r,i)}class uj{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 hj="us-central1";class dj{constructor(e,t,n,r,i=hj,s){this.app=e,this.fetchImpl=s,this.emulatorOrigin=null,this.contextProvider=new uj(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=hj}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 pj(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 ij(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 cj("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 cj("cancelled","Firebase Functions instance was deleted.");var h=lj(u.status,u.json);if(h)throw h;if(!u.json)throw new cj("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 cj("internal","Response is missing data field.");h=sj(d);return{data:h}}(t,n,e,r||{})}const fj="@firebase/functions",gj="0.7.7-canary.044a8d7f9";function mj(e,t,n){Kd(e).emulatorOrigin=`http://${t}:${n}`}dF=fetch.bind(self),dp(new $d(oj,(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 dj(n,r,i,s,t,dF)},"PUBLIC").setMultipleInstances(!0)),wp(fj,gj,pF),wp(fj,gj,"esm2017");var vj,yj,_j,wj;class bj{constructor(e,t){this.app=e,this._delegate=t,this._region=this._delegate.region,this._customDomain=this._delegate.customDomain}httpsCallable(e,t){return pj(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 mj(this._delegate,t[1],Number(t[2]))}useEmulator(e,t){return mj(this._delegate,e,t)}}const Tj="us-central1",Ij=(e,{instanceIdentifier:t})=>{var n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("functions").getImmediate({identifier:null!=t?t:Tj});return new bj(n,r)};vj={Functions:bj},Ap.INTERNAL.registerComponent(new $d("functions-compat",Ij,"PUBLIC").setServiceProps(vj).setMultipleInstances(!0)),Ap.registerVersion("@firebase/functions-compat","0.1.8-canary.044a8d7f9");const Ej="/firebase-messaging-sw.js",kj="/firebase-cloud-messaging-push-scope",Sj="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",Cj="https://fcmregistrations.googleapis.com/v1",Aj="google.c.a.c_id",Nj="google.c.a.e";function Rj(e){var t=new Uint8Array(e);const n=btoa(String.fromCharCode(...t));return n.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(yt=VB=VB||{})[yt.DATA_MESSAGE=1]="DATA_MESSAGE",yt[yt.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION",(yt=yj=yj||{}).PUSH_RECEIVED="push-received",yt.NOTIFICATION_CLICKED="notification-clicked";const Pj="fcm_token_details_db",xj="fcm_token_object_Store";async function Dj(s){if("databases"in indexedDB){const t=await indexedDB.databases(),n=t.map(e=>e.name);if(!n.includes(Pj))return null}let o=null;const e=await Vp(Pj,5,async e=>{var t;if(!(e.oldVersion<2)&&e.objectStoreNames.contains(xj)){const i=e.transaction.objectStore(xj);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:Rj(n.vapidKey)}}):3===e.oldVersion?(n=r,o={token:n.fcmToken,createTime:n.createTime,subscriptionOptions:{auth:Rj(n.auth),p256dh:Rj(n.p256dh),endpoint:n.endpoint,swScope:n.swScope,vapidKey:Rj(n.vapidKey)}}):4===e.oldVersion&&(r=r,o={token:r.fcmToken,createTime:r.createTime,subscriptionOptions:{auth:Rj(r.auth),p256dh:Rj(r.p256dh),endpoint:r.endpoint,swScope:r.swScope,vapidKey:Rj(r.vapidKey)}}))}});return e.close(),await Bp(Pj),await Bp("fcm_vapid_details_db"),await Bp("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 Oj="firebase-messaging-database",Mj=1,Lj="firebase-messaging-store";let Fj=null;function Uj(){return Fj=Fj||Vp(Oj,Mj,e=>{0===e.oldVersion&&e.createObjectStore(Lj)}),Fj}async function jj(e){var t=Vj(e);const n=await Uj();t=await n.transaction(Lj).objectStore(Lj).get(t);if(t)return t;t=await Dj(e.appConfig.senderId);return t?(await qj(e,t),t):void 0}async function qj(e,t){var n=Vj(e);const r=await Uj(),i=r.transaction(Lj,"readwrite");return await i.objectStore(Lj).put(t,n),await i.complete,t}function Vj({appConfig:e}){return e.appId}const Bj=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 Wj(e,t){var n={method:"DELETE",headers:await $j(e)};try{const s=await fetch(`${Kj(e.appConfig)}/${t}`,n);var r=await s.json();if(r.error){var i=r.error.message;throw Bj.create("token-unsubscribe-failed",{errorInfo:i})}}catch(e){throw Bj.create("token-unsubscribe-failed",{errorInfo:e})}}function Kj({projectId:e}){return`${Cj}/projects/${e}/registrations`}async function $j({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 zj({p256dh:e,auth:t,endpoint:n,vapidKey:r}){const i={web:{endpoint:n,auth:t,p256dh:e}};return r!==Sj&&(i.web.applicationPubKey=r),i}const Hj=6048e5;async function Gj(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:Rj(t.getKey("auth")),p256dh:Rj(t.getKey("p256dh"))},c=await jj(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+Hj?async function(t,e){try{var n=await async function(e,t){var n=await $j(e),r=zj(t.subscriptionOptions),r={method:"PATCH",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(`${Kj(e.appConfig)}/${t.token}`,r);i=await s.json()}catch(e){throw Bj.create("token-update-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Bj.create("token-update-failed",{errorInfo:r})}if(!i.token)throw Bj.create("token-update-no-token");return i.token}(t.firebaseDependencies,e),r=Object.assign(Object.assign({},e),{token:n,createTime:Date.now()});return await qj(t.firebaseDependencies,r),n}catch(e){throw await Qj(t),e}}(e,{token:c.token,createTime:Date.now(),subscriptionOptions:a}):c.token;try{await Wj(e.firebaseDependencies,c.token)}catch(e){console.warn(e)}return Yj(e.firebaseDependencies,a)}return Yj(e.firebaseDependencies,a)}async function Qj(e){var t=await jj(e.firebaseDependencies);t&&(await Wj(e.firebaseDependencies,t.token),await async function(e){var t=Vj(e);const n=await Uj(),r=n.transaction(Lj,"readwrite");await r.objectStore(Lj).delete(t),await r.complete}(e.firebaseDependencies));const n=await e.swRegistration.pushManager.getSubscription();return!n||n.unsubscribe()}async function Yj(e,t){var n={token:await async function(e,t){var n=await $j(e),r=zj(t),r={method:"POST",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(Kj(e.appConfig),r);i=await s.json()}catch(e){throw Bj.create("token-subscribe-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Bj.create("token-subscribe-failed",{errorInfo:r})}if(!i.token)throw Bj.create("token-subscribe-no-token");return i.token}(e,t),createTime:Date.now(),subscriptionOptions:t};return await qj(e,n),n.token}function Jj(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 Xj(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 Zj(e){return Bj.create("missing-app-config-values",{valueName:e})}Xj("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),Xj("AzSCbw63g1R0nCw85jG8","Iaya3yLKwmgvh7cF0q4");class eq{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 Zj("App Configuration Object");if(!e.name)throw Zj("App Name");var t=e["options"];for(const n of["projectId","apiKey","appId","messagingSenderId"])if(!t[n])throw Zj(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 tq(e){try{e.swRegistration=await navigator.serviceWorker.register(Ej,{scope:kj}),e.swRegistration.update().catch(()=>{})}catch(e){throw Bj.create("failed-service-worker-registration",{browserErrorMessage:e.message})}}async function nq(e,t){if(!navigator)throw Bj.create("only-available-in-window");if("default"===Notification.permission&&await Notification.requestPermission(),"granted"!==Notification.permission)throw Bj.create("permission-blocked");var n,r;return n=e,await((r=null==t?void 0:t.vapidKey)?n.vapidKey=r:n.vapidKey||(n.vapidKey=Sj)),await async function(e,t){if(t||e.swRegistration||await tq(e),t||!e.swRegistration){if(!(t instanceof ServiceWorkerRegistration))throw Bj.create("invalid-sw-registration");e.swRegistration=t}}(e,null==t?void 0:t.serviceWorkerRegistration),Gj(e)}async function rq(e,t,n){var r=function(e){switch(e){case yj.NOTIFICATION_CLICKED:return"notification_open";case yj.PUSH_RECEIVED:return"notification_foreground";default:throw new Error}}(t);const i=await e.firebaseDependencies.analyticsProvider.get();i.logEvent(r,{message_id:n[Aj],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 iq(e,t){var n,r=t.data;r.isFirebaseMessaging&&(e.onMessageHandler&&r.messageType===yj.PUSH_RECEIVED&&("function"==typeof e.onMessageHandler?e.onMessageHandler(Jj(r)):e.onMessageHandler.next(Jj(r))),n=r.data,"object"==typeof(t=n)&&t&&Aj in t&&"1"===n[Nj]&&await rq(e,r.messageType,n))}const sq="@firebase/messaging",oq="0.9.5-canary.044a8d7f9",aq=e=>{const t=new eq(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return navigator.serviceWorker.addEventListener("message",e=>iq(t,e)),t},cq=e=>{const t=e.getProvider("messaging").getImmediate();return{getToken:e=>nq(t,e)}};function lq(e){return async function(e){if(!navigator)throw Bj.create("only-available-in-window");return e.swRegistration||await tq(e),Qj(e)}(e=Kd(e))}function uq(e,t){return function(e,t){if(!navigator)throw Bj.create("only-available-in-window");return e.onMessageHandler=t,()=>{e.onMessageHandler=null}}(e=Kd(e),t)}dp(new $d("messaging",aq,"PUBLIC")),dp(new $d("messaging-internal",cq,"PRIVATE")),wp(sq,oq),wp(sq,oq,"esm2017");const hq="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",dq="https://fcmregistrations.googleapis.com/v1",pq="FCM_MSG",fq="google.c.a.c_id",gq=3,mq=1;function vq(e){var t=new Uint8Array(e);const n=btoa(String.fromCharCode(...t));return n.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(yt=_j=_j||{})[yt.DATA_MESSAGE=1]="DATA_MESSAGE",yt[yt.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION",(c=wj=wj||{}).PUSH_RECEIVED="push-received",c.NOTIFICATION_CLICKED="notification-clicked";const yq="fcm_token_details_db",_q="fcm_token_object_Store";async function wq(s){if("databases"in indexedDB){const t=await indexedDB.databases(),n=t.map(e=>e.name);if(!n.includes(yq))return null}let o=null;const e=await Vp(yq,5,async e=>{var t;if(!(e.oldVersion<2)&&e.objectStoreNames.contains(_q)){const i=e.transaction.objectStore(_q);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:vq(n.vapidKey)}}):3===e.oldVersion?(n=r,o={token:n.fcmToken,createTime:n.createTime,subscriptionOptions:{auth:vq(n.auth),p256dh:vq(n.p256dh),endpoint:n.endpoint,swScope:n.swScope,vapidKey:vq(n.vapidKey)}}):4===e.oldVersion&&(r=r,o={token:r.fcmToken,createTime:r.createTime,subscriptionOptions:{auth:vq(r.auth),p256dh:vq(r.p256dh),endpoint:r.endpoint,swScope:r.swScope,vapidKey:vq(r.vapidKey)}}))}});return e.close(),await Bp(yq),await Bp("fcm_vapid_details_db"),await Bp("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 bq="firebase-messaging-database",Tq=1,Iq="firebase-messaging-store";let Eq=null;function kq(){return Eq=Eq||Vp(bq,Tq,e=>{0===e.oldVersion&&e.createObjectStore(Iq)}),Eq}async function Sq(e){var t=Aq(e);const n=await kq();t=await n.transaction(Iq).objectStore(Iq).get(t);if(t)return t;t=await wq(e.appConfig.senderId);return t?(await Cq(e,t),t):void 0}async function Cq(e,t){var n=Aq(e);const r=await kq(),i=r.transaction(Iq,"readwrite");return await i.objectStore(Iq).put(t,n),await i.complete,t}function Aq({appConfig:e}){return e.appId}const Nq=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 Rq(e,t){var n={method:"DELETE",headers:await xq(e)};try{const s=await fetch(`${Pq(e.appConfig)}/${t}`,n);var r=await s.json();if(r.error){var i=r.error.message;throw Nq.create("token-unsubscribe-failed",{errorInfo:i})}}catch(e){throw Nq.create("token-unsubscribe-failed",{errorInfo:e})}}function Pq({projectId:e}){return`${dq}/projects/${e}/registrations`}async function xq({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 Dq({p256dh:e,auth:t,endpoint:n,vapidKey:r}){const i={web:{endpoint:n,auth:t,p256dh:e}};return r!==hq&&(i.web.applicationPubKey=r),i}async function Oq(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:vq(t.getKey("auth")),p256dh:vq(t.getKey("p256dh"))},c=await Sq(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 xq(e),r=Dq(t.subscriptionOptions),r={method:"PATCH",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(`${Pq(e.appConfig)}/${t.token}`,r);i=await s.json()}catch(e){throw Nq.create("token-update-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Nq.create("token-update-failed",{errorInfo:r})}if(!i.token)throw Nq.create("token-update-no-token");return i.token}(t.firebaseDependencies,e),r=Object.assign(Object.assign({},e),{token:n,createTime:Date.now()});return await Cq(t.firebaseDependencies,r),n}catch(e){throw await Mq(t),e}}(e,{token:c.token,createTime:Date.now(),subscriptionOptions:a}):c.token;try{await Rq(e.firebaseDependencies,c.token)}catch(e){console.warn(e)}return Lq(e.firebaseDependencies,a)}return Lq(e.firebaseDependencies,a)}async function Mq(e){var t=await Sq(e.firebaseDependencies);t&&(await Rq(e.firebaseDependencies,t.token),await async function(e){var t=Aq(e);const n=await kq(),r=n.transaction(Iq,"readwrite");await r.objectStore(Iq).delete(t),await r.complete}(e.firebaseDependencies));const n=await e.swRegistration.pushManager.getSubscription();return!n||n.unsubscribe()}async function Lq(e,t){var n={token:await async function(e,t){var n=await xq(e),r=Dq(t),r={method:"POST",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(Pq(e.appConfig),r);i=await s.json()}catch(e){throw Nq.create("token-subscribe-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Nq.create("token-subscribe-failed",{errorInfo:r})}if(!i.token)throw Nq.create("token-subscribe-no-token");return i.token}(e,t),createTime:Date.now(),subscriptionOptions:t};return await Cq(e,n),n.token}async function Fq(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=_j.DISPLAY_NOTIFICATION.toString():r.message_type=_j.DATA_MESSAGE.toString();r.sdk_platform=gq.toString(),r.package_name=self.origin.replace(/(^\w+:|^)\/\//,""),e.collapse_key&&(r.collapse_key=e.collapse_key);r.event=mq.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 Uq(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 jq(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 Fq(t,n);var r,i,s=await Vq();if(s.some(e=>"visible"===e.visibilityState&&!e.url.startsWith("chrome-extension://")))return function(e,t){t.isFirebaseMessaging=!0,t.messageType=wj.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={[pq]: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 qq(e){const t=null===(s=null===(i=e.notification)||void 0===i?void 0:i.data)||void 0===s?void 0:s[pq];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&&fq 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 Vq();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=wj.NOTIFICATION_CLICKED,t.isFirebaseMessaging=!0,e.postMessage(t)}}}}function Vq(){return self.clients.matchAll({type:"window",includeUncontrolled:!0})}function Bq(e){return Nq.create("missing-app-config-values",{valueName:e})}Uq("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),Uq("AzSCbw63g1R0nCw85jG8","Iaya3yLKwmgvh7cF0q4");class Wq{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 Bq("App Configuration Object");if(!e.name)throw Bq("App Name");var t=e["options"];for(const n of["projectId","apiKey","appId","messagingSenderId"])if(!t[n])throw Bq(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 Kq=e=>{const t=new Wq(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return self.addEventListener("push",e=>{e.waitUntil(jq(e,t))}),self.addEventListener("pushsubscriptionchange",e=>{e.waitUntil(async function(e,t){var n;(n=e["newSubscription"])?(n=await Sq(t.firebaseDependencies),await Mq(t),t.vapidKey=null!==(n=null===(n=null==n?void 0:n.subscriptionOptions)||void 0===n?void 0:n.vapidKey)&&void 0!==n?n:hq,await Oq(t)):await Mq(t)}(e,t))}),self.addEventListener("notificationclick",e=>{e.waitUntil(qq(e))}),t};function $q(e,t){return function(e,t){if(void 0!==self.document)throw Nq.create("only-available-in-sw");return e.onBackgroundMessageHandler=t,()=>{e.onBackgroundMessageHandler=null}}(e=Kd(e),t)}dp(new $d("messaging-sw",Kq,"PUBLIC"));var zq,Hq,Gq;class Qq{constructor(e,t){this.app=e,this._delegate=t,this.app=e,this._delegate=t}async getToken(e){return async function(e,t){return nq(e=Kd(e),t)}(this._delegate,e)}async deleteToken(){return lq(this._delegate)}onMessage(e){return uq(this._delegate,e)}onBackgroundMessage(e){return $q(this._delegate,e)}}const Yq=e=>self&&"ServiceWorkerGlobalScope"in self?new Qq(e.getProvider("app-compat").getImmediate(),e.getProvider("messaging-sw").getImmediate()):new Qq(e.getProvider("app-compat").getImmediate(),e.getProvider("messaging").getImmediate()),Jq={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")}};Ap.INTERNAL.registerComponent(new $d("messaging-compat",Yq,"PUBLIC").setServiceProps(Jq)),Ap.registerVersion("@firebase/messaging-compat","0.1.5-canary.044a8d7f9");const Xq="firebasestorage.googleapis.com",Zq="storageBucket";class eV extends gd{constructor(e,t){super(tV(e),`Firebase Storage: ${t} (${tV(e)})`),this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,eV.prototype)}_codeEquals(e){return tV(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 tV(e){return"storage/"+e}function nV(){return new eV("unknown","An unknown error occurred, please check the error payload for server response.")}function rV(){return new eV("canceled","User canceled the upload/download.")}function iV(){return new eV("cannot-slice-blob","Cannot slice blob for upload. Please retry the upload.")}function sV(e){return new eV("invalid-argument",e)}function oV(){return new eV("app-deleted","The Firebase app was deleted.")}function aV(e){return new eV("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 cV(e,t){return new eV("invalid-format","String does not match format '"+e+"': "+t)}function lV(e){throw new eV("internal-error","Internal error: "+e)}class uV{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=uV.makeFromUrl(t,e)}catch(e){return new uV(t,"")}if(""===n.path)return n;throw t=t,new eV("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===Xq?"(?: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 uV(u,e),d.postModify(n);break}}if(null==n)throw t=e,new eV("invalid-url","Invalid URL '"+t+"'.");return n}}class hV{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=0){}}function dV(e){return"string"==typeof e||e instanceof String}function pV(e){return fV()&&e instanceof Blob}function fV(){return"undefined"!=typeof Blob}function gV(e,t,n,r){if(r<t)throw sV(`Invalid value for '${e}'. Expected ${t} or greater.`);if(n<r)throw sV(`Invalid value for '${e}'. Expected ${n} or less.`)}function mV(e,t,n){let r=null==n?`https://${t}`:t;return`${n}://${r}/v0${e}`}function vV(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=zq=zq||{})[c.NO_ERROR=0]="NO_ERROR",c[c.NETWORK_ERROR=1]="NETWORK_ERROR",c[c.ABORT=2]="ABORT";class yV{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 _V(!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()===zq.NO_ERROR,n=i.getStatus();t&&!this.isRetryStatusCode_(n)?(e=-1!==this.successCodes_.indexOf(n),r(!0,new _V(e,i))):(e=i.getErrorCode()===zq.ABORT,r(!1,new _V(!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=nV();a.serverResponse=i.getErrorText(),this.errorCallback_?r(this.errorCallback_(i,a)):r(a)}else{var o;t.canceled?(o=(this.appDelete_?oV:rV)(),r(o)):(o=new eV("retry-limit-exceeded","Max retry time for operation exceeded, please try again."),r(o))}};this.canceled_?t(0,new _V(!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 _V{constructor(e,t,n){this.wasSuccessCode=e,this.connection=t,this.canceled=!!n}}function wV(...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(fV())return new Blob(t);throw new eV("unsupported-environment","This browser doesn't seem to support creating Blobs")}const bV={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class TV{constructor(e,t){this.data=e,this.contentType=t||null}}function IV(e,t){switch(e){case bV.RAW:return new TV(EV(t));case bV.BASE64:case bV.BASE64URL:return new TV(kV(e,t));case bV.DATA_URL:return new TV((n=t,(r=new SV(n)).base64?kV(bV.BASE64,r.rest):function(e){let t;try{t=decodeURIComponent(e)}catch(e){throw cV(bV.DATA_URL,"Malformed data URL.")}return EV(t)}(r.rest)),(n=t,new SV(n).contentType))}var n,r;throw nV()}function EV(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 kV(t,e){switch(t){case bV.BASE64:var n=-1!==e.indexOf("-"),r=-1!==e.indexOf("_");if(n||r)throw cV(t,"Invalid character '"+(n?"-":"_")+"' found: is it base64url encoded?");break;case bV.BASE64URL:r=-1!==e.indexOf("+"),n=-1!==e.indexOf("/");if(r||n)throw cV(t,"Invalid character '"+(r?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/")}let i;try{i=atob(e)}catch(e){throw cV(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 SV{constructor(e){this.base64=!1,this.contentType=null;var t,n,r=e.match(/^data:([^,]+)?,/);if(null===r)throw cV(bV.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 CV{constructor(e,t){let n=0,r="";pV(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(pV(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 CV(n)}var r,i,s,n=new Uint8Array(this.data_.buffer,e,t-e);return new CV(n,!0)}static getBlob(...e){if(fV()){var t=e.map(e=>e instanceof CV?e.data_:e);return new CV(wV.apply(null,t))}{const r=e.map(e=>dV(e)?IV(bV.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 CV(i,!0)}}uploadData(){return this.data_}}function AV(e){let t;try{t=JSON.parse(e)}catch(e){return null}return"object"!=typeof(e=t)||Array.isArray(e)?null:t}function NV(e){var t=e.lastIndexOf("/",e.length-2);return-1===t?e:e.slice(t+1)}function RV(e,t){return t}class PV{constructor(e,t,n,r){this.server=e,this.local=t||e,this.writable=!!n,this.xform=r||RV}}let xV=null;function DV(){if(xV)return xV;const e=[];e.push(new PV("bucket")),e.push(new PV("generation")),e.push(new PV("metageneration")),e.push(new PV("name","fullPath",!0));const t=new PV("name");t.xform=function(e,t){return!dV(t=t)||t.length<2?t:NV(t)},e.push(t);const n=new PV("size");return n.xform=function(e,t){return void 0!==t?Number(t):t},e.push(n),e.push(new PV("timeCreated")),e.push(new PV("updated")),e.push(new PV("md5Hash",null,!0)),e.push(new PV("cacheControl",null,!0)),e.push(new PV("contentDisposition",null,!0)),e.push(new PV("contentEncoding",null,!0)),e.push(new PV("contentLanguage",null,!0)),e.push(new PV("contentType",null,!0)),e.push(new PV("metadata","customMetadata",!0)),xV=e,xV}function OV(n,r){Object.defineProperty(n,"ref",{get:function(){var e=n.bucket,t=n.fullPath,t=new uV(e,t);return r._makeStorageReference(t)}})}function MV(e,t,n){var r=AV(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 OV(r,e),r}(e,r,n)}function LV(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 FV(e,t,n){var r=AV(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 uV(t,i));r.prefixes.push(i)}if(n.items)for(const a of n.items){var s=e._makeStorageReference(new uV(t,a.name));r.items.push(s)}return r}(e,t,r)}class UV{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 jV(e){if(!e)throw nV()}function qV(r,i){return function(e,t){var n=MV(r,t,i);return jV(null!==n),n}}function VV(r,i){return function(e,t){var n=FV(r,i,t);return jV(null!==n),n}}function BV(r,i){return function(e,t){var n=MV(r,t,i);return jV(null!==n),function(r,e,i,s){var t=AV(e);if(null===t)return null;if(!dV(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 mV("/b/"+o(t)+"/o/"+o(n),i,s)+vV({alt:"media",token:e})})[0]}(n,t,r.host,r._protocol)}}function WV(i){return function(e,t){let n;var r;return n=401===e.getStatus()?e.getErrorText().includes("Firebase App Check token is invalid")?new eV("unauthorized-app","This app does not have permission to access Firebase Storage on this project."):new eV("unauthenticated","User is not authenticated, please authenticate using Firebase Authentication and try again."):402===e.getStatus()?(r=i.bucket,new eV("quota-exceeded","Quota for bucket '"+r+"' exceeded, please view quota on https://firebase.google.com/pricing/.")):403===e.getStatus()?(e=i.path,new eV("unauthorized","User does not have permission to access '"+e+"'.")):t,n.serverResponse=t.serverResponse,n}}function KV(r){const i=WV(r);return function(e,t){let n=i(e,t);return 404===e.getStatus()&&(n=(e=r.path,new eV("object-not-found","Object '"+e+"' does not exist."))),n.serverResponse=t.serverResponse,n}}function $V(e,t,n){var r=mV(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime;const s=new UV(r,"GET",qV(e,n),i);return s.errorHandler=KV(t),s}function zV(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 HV(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=zV(t,r,i),l="--"+a+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+LV(c,n)+"\r\n--"+a+"\r\nContent-Type: "+c.contentType+"\r\n\r\n",a="\r\n--"+a+"--";const u=CV.getBlob(l,r,a);if(null===u)throw iV();a={name:c.fullPath},c=mV(s,e.host,e._protocol),s=e.maxUploadRetryTime;const h=new UV(c,"POST",qV(e,n),s);return h.urlParams=a,h.headers=o,h.body=u.uploadData(),h.errorHandler=WV(t),h}class GV{constructor(e,t,n,r){this.current=e,this.total=t,this.finalized=!!n,this.metadata=r||null}}function QV(e,t){let n=null;try{n=e.getResponseHeader("X-Goog-Upload-Status")}catch(e){jV(!1)}const r=t||["active"];return jV(!!n&&-1!==r.indexOf(n)),n}function YV(e,t,n,r,i){var s=t.bucketOnlyServerUrl(),o=zV(t,r,i),a={name:o.fullPath},c=mV(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=LV(o,n),o=e.maxUploadRetryTime;const u=new UV(c,"POST",function(e){QV(e);let t;try{t=e.getResponseHeader("X-Goog-Upload-URL")}catch(e){jV(!1)}return jV(dV(t)),t},o);return u.urlParams=a,u.headers=l,u.body=s,u.errorHandler=WV(t),u}function JV(e,t,n,i){var r=e.maxUploadRetryTime;const s=new UV(n,"POST",function(e){var t=QV(e,["active","final"]);let n=null;try{n=e.getResponseHeader("X-Goog-Upload-Size-Received")}catch(e){jV(!1)}n||jV(!1);var r=Number(n);return jV(!isNaN(r)),new GV(r,i.size(),"final"===t)},r);return s.headers={"X-Goog-Upload-Command":"query"},s.errorHandler=WV(t),s}function XV(e,o,t,a,n,c,r,i){const l=new GV(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 eV("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 iV();d=o.maxUploadRetryTime;const f=new UV(t,"POST",function(e,t){var n=QV(e,["active","final"]),r=l.current+u,i=a.size();let s;return s="final"===n?qV(o,c)(e,t):null,new GV(r,i,"final"===n,s)},d);return f.headers=s,f.body=p.uploadData(),f.progressCallback=i||null,f.errorHandler=WV(e),f}const ZV={STATE_CHANGED:"state_changed"},eB={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function tB(e){switch(e){case"running":case"pausing":case"canceling":return eB.RUNNING;case"paused":return eB.PAUSED;case"success":return eB.SUCCESS;case"canceled":return eB.CANCELED;default:return eB.ERROR}}class nB{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 rB(t){return(...e)=>{Promise.resolve().then(()=>t(...e))}}class iB extends class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=zq.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=zq.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=zq.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,n,r){if(this.sent_)throw lV("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 lV("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw lV("cannot .getStatus() before sending");try{return this.xhr_.status}catch(e){return-1}}getResponse(){if(!this.sent_)throw lV("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw lV("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 sB(){return new iB}class oB{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=DV(),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=YV(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata);const r=this._ref.storage._makeRequest(n,sB,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=JV(this._ref.storage,this._ref._location,i,this._blob);const r=this._ref.storage._makeRequest(n,sB,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 GV(this._transferred,this._blob.size()),o=this._uploadUrl;this._resolveToken((e,t)=>{let n;try{n=XV(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,sB,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=$V(this._ref.storage,this._ref._location,this._mappings);const r=this._ref.storage._makeRequest(n,sB,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=HV(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata);const r=this._ref.storage._makeRequest(n,sB,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=rV(),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=tB(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 nB(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(tB(this._state)){case eB.SUCCESS:rB(this._resolve.bind(null,this.snapshot))();break;case eB.CANCELED:case eB.ERROR:const t=this._reject;rB(t.bind(null,this._error))();break;default:e=!1}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(tB(this._state)){case eB.RUNNING:case eB.PAUSED:e.next&&rB(e.next.bind(e,this.snapshot))();break;case eB.SUCCESS:e.complete&&rB(e.complete.bind(e))();break;case eB.CANCELED:case eB.ERROR:default:e.error&&rB(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 aB{constructor(e,t){this._service=e,t instanceof uV?this._location=t:this._location=uV.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new aB(e,t)}get root(){var e=new uV(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return NV(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 uV(this._location.bucket,e);return new aB(this._service,e)}_throwIfRoot(e){if(""===this._location.path)throw aV(e)}}function cB(e){const t={prefixes:[],items:[]};return async function e(t,n,r){const i={pageToken:r};const s=await lB(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 lB(e,t){null!=t&&"number"==typeof t.maxResults&&gV("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=mV(t.bucketOnlyServerUrl(),e.host,e._protocol),a=e.maxOperationRetryTime;const c=new UV(o,"GET",VV(e,t.bucket),a);return c.urlParams=s,c.errorHandler=WV(t),c}(e.storage,e._location,"/",n.pageToken,n.maxResults);return e.storage.makeRequestWithTokens(n,sB)}function uB(e,t){e._throwIfRoot("updateMetadata");var n=function(e,t,n,r){var i=mV(t.fullServerUrl(),e.host,e._protocol),s=LV(n,r),o=e.maxOperationRetryTime;const a=new UV(i,"PATCH",qV(e,r),o);return a.headers={"Content-Type":"application/json; charset=utf-8"},a.body=s,a.errorHandler=KV(t),a}(e.storage,e._location,t,DV());return e.storage.makeRequestWithTokens(n,sB)}function hB(e){e._throwIfRoot("getDownloadURL");var t=function(e,t,n){var r=mV(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime;const s=new UV(r,"GET",BV(e,n),i);return s.errorHandler=KV(t),s}(e.storage,e._location,DV());return e.storage.makeRequestWithTokens(t,sB).then(e=>{if(null===e)throw new eV("no-download-url","The given file does not have any download URLs.");return e})}function dB(e){e._throwIfRoot("deleteObject");var t=function(e,t){var n=mV(t.fullServerUrl(),e.host,e._protocol),r=e.maxOperationRetryTime;const i=new UV(n,"DELETE",function(e,t){},r);return i.successCodes=[200,204],i.errorHandler=KV(t),i}(e.storage,e._location);return e.storage.makeRequestWithTokens(t,sB)}function pB(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 uV(e._location.bucket,r);return new aB(e.storage,r)}function fB(e,t){if(e instanceof vB){var n=e;if(null==n._bucket)throw new eV("no-default-bucket","No default bucket found. Did you set the '"+Zq+"' property when initializing the app?");n=new aB(n,n._bucket);return null!=t?fB(n,t):n}return void 0!==t?pB(e,t):e}function gB(e,t){if(t&&/^[A-Za-z]+:\/\//.test(t)){if(e instanceof vB)return n=e,r=t,new aB(n,r);throw sV("To use ref(service, url), the first argument must be a Storage instance.")}return fB(e,t);var n,r}function mB(e,t){var n=null==t?void 0:t[Zq];return null==n?null:uV.makeFromBucketSpec(n,e)}class vB{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=Xq,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=12e4,this._maxUploadRetryTime=6e5,this._requests=new Set,this._bucket=null!=r?uV.makeFromBucketSpec(r,this._host):mB(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,null!=this._url?this._bucket=uV.makeFromBucketSpec(this._url,e):this._bucket=mB(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){gV("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){gV("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 aB(this,e)}_makeRequest(e,t,n,r){if(this._deleted)return new hV(oV());{const l=(i=e,s=this._appId,o=n,e=r,n=t,r=this._firebaseVersion,a=vV(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 yV(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 yB="@firebase/storage",_B="0.9.1-canary.044a8d7f9";function wB(e,t,n){return e=Kd(e),t=t,n=n,(e=e)._throwIfRoot("uploadBytesResumable"),new oB(e,new CV(t),n)}function bB(e){return function(e){e._throwIfRoot("getMetadata");var t=$V(e.storage,e._location,DV());return e.storage.makeRequestWithTokens(t,sB)}(e=Kd(e))}function TB(e,t){return gB(e=Kd(e),t)}function IB(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 EB(e,{instanceIdentifier:t}){var n=e.getProvider("app").getImmediate(),r=e.getProvider("auth-internal"),i=e.getProvider("app-check-internal");return new vB(n,r,i,t,mp)}dp(new $d("storage",EB,"PUBLIC").setMultipleInstances(!0)),wp(yB,_B,""),wp(yB,_B,"esm2017");class kB{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 SB{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 kB(this._delegate.snapshot,this,this._ref)}then(t,e){return this._delegate.then(e=>{if(t)return t(new kB(e,this,this._ref))},e)}on(e,t,n,r){let i=void 0;return t&&(i="function"==typeof t?e=>t(new kB(e,this,this._ref)):{next:t.next?e=>t.next(new kB(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 CB{constructor(e,t){this._delegate=e,this._service=t}get prefixes(){return this._delegate.prefixes.map(e=>new AB(e,this._service))}get items(){return this._delegate.items.map(e=>new AB(e,this._service))}get nextPageToken(){return this._delegate.nextPageToken||null}}class AB{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=pB(this._delegate,e);return new AB(t,this.storage)}get root(){return new AB(this._delegate.root,this.storage)}get parent(){var e=this._delegate.parent;return null==e?null:new AB(e,this.storage)}put(e,t){return this._throwIfRoot("put"),new SB(wB(this._delegate,e,t),this)}putString(e,t=bV.RAW,n){this._throwIfRoot("putString");var r=IV(t,e);const i=Object.assign({},n);return null==i.contentType&&null!=r.contentType&&(i.contentType=r.contentType),new SB(new oB(this._delegate,new CV(r.data,!0),i),this)}listAll(){return cB(Kd(this._delegate)).then(e=>new CB(e,this.storage))}list(e){return t=this._delegate,e=e||void 0,lB(t=Kd(t),e).then(e=>new CB(e,this.storage));var t}getMetadata(){return bB(this._delegate)}updateMetadata(e){return uB(Kd(this._delegate),e)}getDownloadURL(){return hB(Kd(this._delegate))}delete(){return this._throwIfRoot("delete"),dB(Kd(this._delegate))}_throwIfRoot(e){if(""===this._delegate._location.path)throw aV(e)}}class NB{constructor(e,t){this.app=e,this._delegate=t}get maxOperationRetryTime(){return this._delegate.maxOperationRetryTime}get maxUploadRetryTime(){return this._delegate.maxUploadRetryTime}ref(e){if(RB(e))throw sV("ref() expected a child path but got a URL, use refFromURL instead.");return new AB(TB(this._delegate,e),this)}refFromURL(e){if(!RB(e))throw sV("refFromURL() expected a full URL but got a child path, use ref() instead.");try{uV.makeFromUrl(e,this._delegate.host)}catch(e){throw sV("refFromUrl() expected a valid full URL but got an invalid one.")}return new AB(TB(this._delegate,e),this)}setMaxUploadRetryTime(e){this._delegate.maxUploadRetryTime=e}setMaxOperationRetryTime(e){this._delegate.maxOperationRetryTime=e}useEmulator(e,t,n={}){IB(this._delegate,e,t,n)}}function RB(e){return/^[A-Za-z]+:\/\//.test(e)}function PB(e,{instanceIdentifier:t}){var n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("storage").getImmediate({identifier:t});return new NB(n,r)}Hq=Ap,Gq={TaskState:eB,TaskEvent:ZV,StringFormat:bV,Storage:NB,Reference:AB},Hq.INTERNAL.registerComponent(new $d("storage-compat",PB,"PUBLIC").setServiceProps(Gq).setMultipleInstances(!0)),Hq.registerVersion("@firebase/storage-compat","0.1.9-canary.044a8d7f9");const xB="@firebase/performance",DB="0.5.5-canary.044a8d7f9",OB=DB,MB="FB-PERF-TRACE-MEASURE",LB="@firebase/performance/config",FB="@firebase/performance/configexpire";var UB,jB,qB,VB="Performance";const BB=new md("performance",VB,{"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."}),WB=new ep(VB);WB.logLevel=Kh.INFO;let KB,$B;class zB{constructor(e){if(!(this.window=e))throw BB.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()||(WB.info("IndexedDB is not supported by current browswer"),!1):(WB.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===KB&&(KB=new zB($B)),KB}}let HB;function GB(e,t){var n=e.length-t.length;if(n<0||1<n)throw BB.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 QB;class YB{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=GB("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),this.transportKey=GB("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===QB&&(QB=new YB),QB}}(c=UB=UB||{})[c.UNKNOWN=0]="UNKNOWN",c[c.VISIBLE=1]="VISIBLE",c[c.HIDDEN=2]="HIDDEN";const JB=["firebase_","google_","ga_"],XB=new RegExp("^[a-zA-Z]\\w*$");function ZB(){switch(zB.getInstance().document.visibilityState){case"visible":return UB.VISIBLE;case"hidden":return UB.HIDDEN;default:return UB.UNKNOWN}}function eW(e){var t=null===(t=e.options)||void 0===t?void 0:t.appId;if(!t)throw BB.create("no app id");return t}const tW="0.0.1",nW={loggingEnabled:!0},rW="FIREBASE_INSTALLATIONS_AUTH";function iW(e,t){var r,i,n=function(){const e=zB.getInstance().localStorage;if(e){var t=e.getItem(FB);if(t&&function(e){return Number(e)>Date.now()}(t)){t=e.getItem(LB);if(t)try{return JSON.parse(t)}catch(e){return}}}}();return n?(oW(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 BB.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 BB.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:`${rW} ${e}`},body:JSON.stringify({app_instance_id:i,app_instance_id_token:e,app_id:eW(r.app),app_version:OB,sdk_version:tW})});return fetch(n).then(e=>{if(e.ok)return e.json();throw BB.create("RC response not ok")})}).catch(()=>{WB.info(sW)}).then(oW).then(e=>function(e){const t=zB.getInstance().localStorage;e&&t&&(t.setItem(LB,JSON.stringify(e)),t.setItem(FB,String(Date.now()+60*YB.getInstance().configTimeToLive*60*1e3)))}(e),()=>{}))}const sW="Could not fetch config, will use default configs";function oW(e){if(!e)return e;const t=YB.getInstance();var n=e.entries||{};return void 0!==n.fpr_enabled?t.loggingEnabled="true"===String(n.fpr_enabled):t.loggingEnabled=nW.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=aW(t.tracesSamplingRate),t.logNetworkAfterSampling=aW(t.networkRequestsSamplingRate),e}function aW(e){return Math.random()<=e}let cW=1,lW;function uW(e){var t;return cW=2,lW=lW||(t=e,function(){const n=zB.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=>{HB=e}),t}(t.installations)).then(e=>iW(t,e)).then(()=>hW(),()=>hW())),lW}function hW(){cW=3}const dW=1e4,pW=3,fW=1e3;let gW=pW,mW=[],vW=!1;function yW(e){setTimeout(()=>{if(0!==gW)return mW.length?void function(){const e=mW.splice(0,fW),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:YB.getInstance().logSource,log_event:t};!function(e,r){return function(e){var t=YB.getInstance().getFlTransportFullUrl();return fetch(t,{method:"POST",body:JSON.stringify(e)})}(e).then(e=>(e.ok||WB.info("Call to Firebase backend failed."),e.json())).then(e=>{var t=Number(e.nextRequestWaitMillis);let n=dW;isNaN(t)||(n=Math.max(t,n));t=e.logResponseDetails;Array.isArray(t)&&0<t.length&&"RETRY_REQUEST_LATER"===t[0].responseAction&&(mW=[...r,...mW],WB.info("Retry transport request later.")),gW=pW,yW(n)})}(n,e).catch(()=>{mW=[...e,...mW],gW--,WB.info(`Tries left: ${gW}.`),yW(dW)})}():yW(dW)},e)}function _W(t){return(...e)=>{!function(e){if(!e.eventTime||!e.message)throw BB.create("invalid cc log");mW=[...mW,e]}({message:t(...e),eventTime:Date.now()})}}let wW;function bW(e,t){wW=wW||_W(EW),wW(e,t)}function TW(e){var t=YB.getInstance();!t.instrumentationEnabled&&e.isAuto||(t.dataCollectionEnabled||e.isAuto)&&zB.getInstance().requiredApisAvailable()&&(e.isAuto&&ZB()!==UB.VISIBLE||(3===cW?IW(e):uW(e.performanceController).then(()=>IW(e),()=>IW(e))))}function IW(e){var t;!HB||(t=YB.getInstance()).loggingEnabled&&t.logTraceAfterSampling&&setTimeout(()=>bW(e,1),0)}function EW(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:kW(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:kW(e.performanceController.app),trace_metric:t};return JSON.stringify(n)}(e);var n}function kW(e){return{google_app_id:eW(e),app_instance_id:HB,web_app_info:{sdk_version:OB,page_url:zB.getInstance().getUrl(),service_worker_status:"serviceWorker"in(t=zB.getInstance().navigator)?t.serviceWorker.controller?2:3:1,visibility_state:ZB(),effective_connection_type:function(){var e=zB.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 SW=["_fp","_fcp","_fid"];class CW{constructor(e,t,n=!1,r){this.performanceController=e,this.name=t,this.isAuto=n,this.state=1,this.customAttributes={},this.counters={},this.api=zB.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||`${MB}-${this.randomId}-${this.name}`,r&&this.calculateTraceMetrics())}start(){if(1!==this.state)throw BB.create("trace started",{traceName:this.name});this.api.mark(this.traceStartMark),this.state=2}stop(){if(2!==this.state)throw BB.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(),TW(this)}record(e,t,n){if(e<=0)throw BB.create("nonpositive trace startTime",{traceName:this.name});if(t<=0)throw BB.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])));TW(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<SW.indexOf(r))&&r.startsWith("_"))throw BB.create("invalid custom metric name",{customMetricName:e});var n,r,i;this.counters[e]=(t=t,(n=Math.floor(t))<t&&WB.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)&&(!JB.some(e=>n.startsWith(e))&&!!n.match(XB)),s=0!==(r=t).length&&r.length<=100;if(i&&s)this.customAttributes[e]=t;else{if(!i)throw BB.create("invalid attribute name",{attributeName:e});if(!s)throw BB.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=zB.getInstance().getUrl();if(i){const s=new CW(e,"_wt_"+i,!0);i=Math.floor(1e3*zB.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))),TW(s)}}static createUserTimingTrace(e,t){TW(new CW(e,t,!1,t))}}function AW(e,t){const n=t;var r,i,s;n&&void 0!==n.responseStart&&(s=zB.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=YB.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(()=>bW(e,0),0))}({performanceController:e,url:n.name&&n.name.split("?")[0],responsePayloadBytes:n.transferSize,startTimeUs:r,timeToResponseInitiatedUs:i,timeToResponseCompletedUs:s}))}const NW=5e3;function RW(e){HB&&(setTimeout(()=>function(n){const e=zB.getInstance(),r=e.getEntriesByType("navigation"),i=e.getEntriesByType("paint");if(e.onFirstInputDelay){let t=setTimeout(()=>{CW.createOobTrace(n,r,i),t=void 0},NW);e.onFirstInputDelay(e=>{t&&(clearTimeout(t),CW.createOobTrace(n,r,i,e))})}else CW.createOobTrace(n,r,i)}(e),0),setTimeout(()=>function(t){const e=zB.getInstance(),n=e.getEntriesByType("resource");for(const r of n)AW(t,r);e.setupObserver("resource",e=>AW(t,e))}(e),0),setTimeout(()=>function(t){const e=zB.getInstance(),n=e.getEntriesByType("measure");for(const r of n)PW(t,r);e.setupObserver("measure",e=>PW(t,e))}(e),0))}function PW(e,t){const n=t.name;n.substring(0,MB.length)!==MB&&CW.createUserTimingTrace(e,n)}class xW{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),zB.getInstance().requiredApisAvailable()?pd().then(e=>{e&&(vW||(yW(5500),vW=!0),uW(this).then(()=>RW(this),()=>RW(this)),this.initialized=!0)}).catch(e=>{WB.info(`Environment doesn't support IndexedDB: ${e}`)}):WB.info('Firebase Performance cannot start if the browser does not support "Fetch" and "Promise", or cookies are disabled.'))}set instrumentationEnabled(e){YB.getInstance().instrumentationEnabled=e}get instrumentationEnabled(){return YB.getInstance().instrumentationEnabled}set dataCollectionEnabled(e){YB.getInstance().dataCollectionEnabled=e}get dataCollectionEnabled(){return YB.getInstance().dataCollectionEnabled}}const DW="[DEFAULT]";const OW=(e,{options:t})=>{var n=e.getProvider("app").getImmediate(),r=e.getProvider("installations-internal").getImmediate();if(n.name!==DW)throw BB.create("FB not default");if("undefined"==typeof window)throw BB.create("no window");e=window,$B=e;const i=new xW(n,r);return i._init(t),i};dp(new $d("performance",OW,"PUBLIC")),wp(xB,DB),wp(xB,DB,"esm2017");class MW{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 CW(t,e);var t}}function LW(e){var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("performance").getImmediate();return new MW(t,n)}(jB=Ap).INTERNAL.registerComponent(new $d("performance-compat",LW,"PUBLIC")),jB.registerVersion("@firebase/performance-compat","0.1.5-canary.044a8d7f9");const FW="@firebase/remote-config",UW="0.3.4-canary.044a8d7f9";class jW{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}const qW=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 VW=["1","true","t","yes","y","on"];class BW{constructor(e,t=""){this._source=e,this._value=t}asString(){return this._value}asBoolean(){return"static"!==this._source&&0<=VW.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 WW(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 KW(e){const t=Kd(e);return t._initializePromise||(t._initializePromise=t._storageCache.loadFromStorage().then(()=>{t._isInitializationComplete=!0})),t._initializePromise}async function $W(t){const n=Kd(t),e=new jW;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 zW(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]=HW(n,t),e),{});var t,r}function HW(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 BW("remote",r[t]):n.defaultConfig&&void 0!==n.defaultConfig[t]?new BW("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 BW("static"))}class GW{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"),qW.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 qW.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 qW.create("fetch-status",{httpStatus:a});return{status:a,eTag:i,config:c}}}class YW{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(qW.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 JW{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 XW(e,t){var n=e.target.error||void 0;return qW.create(t,{originalErrorMessage:n&&n.message})}const ZW="app_namespace_store";class eK{constructor(e,t,n,r=function(){return new Promise((t,n)=>{try{const e=indexedDB.open("firebase_remote_config",1);e.onerror=e=>{n(XW(e,"storage-open"))},e.onsuccess=e=>{t(e.target.result)},e.onupgradeneeded=e=>{const t=e.target.result;0===e.oldVersion&&t.createObjectStore(ZW,{keyPath:"compositeKey"})}}catch(e){n(qW.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([ZW],"readonly"),r=e.objectStore(ZW);var i=this.createCompositeKey(o);try{const s=r.get(i);s.onerror=e=>{t(XW(e,"storage-get"))},s.onsuccess=e=>{var t=e.target.result;n(t?t.value:void 0)}}catch(e){t(qW.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([ZW],"readwrite"),r=n.objectStore(ZW);var i=this.createCompositeKey(o);try{const s=r.put({compositeKey:i,value:a});s.onerror=e=>{t(XW(e,"storage-set"))},s.onsuccess=()=>{e()}}catch(e){t(qW.create("storage-set",{originalErrorMessage:e&&e.message}))}})}async delete(o){const a=await this.openDbPromise;return new Promise((e,t)=>{const n=a.transaction([ZW],"readwrite"),r=n.objectStore(ZW);var i=this.createCompositeKey(o);try{const s=r.delete(i);s.onerror=e=>{t(XW(e,"storage-delete"))},s.onsuccess=()=>{e()}}catch(e){t(qW.create("storage-delete",{originalErrorMessage:e&&e.message}))}})}createCompositeKey(e){return[this.appId,this.appName,this.namespace,e].join()}}class tK{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 nK(){if(!dd())return!1;try{return await pd()}catch(e){return!1}}dp(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 qW.create("registration-window");if(!dd())throw qW.create("indexed-db-unavailable");var{projectId:i,apiKey:s,appId:o}=n.options;if(!i)throw qW.create("registration-project-id");if(!s)throw qW.create("registration-api-key");if(!o)throw qW.create("registration-app-id");t=t||"firebase";const a=new eK(o,n.name,t),c=new tK(a),l=new ep(FW);l.logLevel=Kh.ERROR;o=new QW(r,mp,t,i,s,o),o=new YW(o,a),o=new GW(o,a,c,l),o=new JW(n,o,c,a,l);return KW(o),o},"PUBLIC").setMultipleInstances(!0)),wp(FW,UW),wp(FW,UW,"esm2017");class rK{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 WW(this._delegate)}ensureInitialized(){return KW(this._delegate)}fetch(){return $W(this._delegate)}fetchAndActivate(){return async function(e){return await $W(e=Kd(e)),WW(e)}(this._delegate)}getAll(){return zW(this._delegate)}getBoolean(e){return HW(Kd(this._delegate),e).asBoolean()}getNumber(e){return HW(Kd(this._delegate),e).asNumber()}getString(e){return HW(Kd(this._delegate),e).asString()}getValue(e){return HW(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 iK(e,{instanceIdentifier:t}){var n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("remote-config").getImmediate({identifier:t});return new rK(n,r)}return(qB=Ap).INTERNAL.registerComponent(new $d("remoteConfig-compat",iK,"PUBLIC").setMultipleInstances(!0).setServiceProps({isSupported:nK})),qB.registerVersion("@firebase/remote-config-compat","0.1.5-canary.044a8d7f9"),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"),Ap.registerVersion("firebase","9.6.2-canary.044a8d7f9","compat-cdn"),Ap});
9
+ `)}function zg(){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=yg;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(Wg())}}const Hg={error:"UNKNOWN_ERROR"};async function Gg(e,t=!1){var n=e.app;Cg(n);const r=_g(n);let i=r.token,s=void 0;if(i||(a=await r.cachedTokenPromise)&&Zg(a)&&(i=a),!t&&i&&Zg(i))return{token:i.token};let o=!1;if($g()){r.exchangeTokenPromise||(r.exchangeTokenPromise=Rg(function(e,t){var{projectId:n,appId:r,apiKey:i}=e.options;return{url:`${bg}/projects/${n}/apps/${r}:${Ig}?key=${i}`,body:{debug_token:t}}}(n,await Kg()),e.platformLoggerProvider).then(e=>(r.exchangeTokenPromise=void 0,e)),o=!0);var a=await r.exchangeTokenPromise;return await Bg(n,a),wg(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?qg.warn(e.message):qg.error(e),s=e}let c;return i?(c={token:i.token},wg(n,Object.assign(Object.assign({},r),{token:i})),await Bg(n,i)):c=(e=s,{token:function(e){return Zh.encodeString(JSON.stringify(e),!1)}(Hg),error:e}),o&&Xg(n,c),c}function Qg(e,t,n,r){var i=e["app"];const s=_g(i);var o={next:n,error:r,type:t};if(wg(i,Object.assign(Object.assign({},s),{tokenObservers:[...s.tokenObservers,o]})),s.token&&Zg(s.token)){const a=s.token;Promise.resolve().then(()=>{n({token:a.token}),Jg(e)}).catch(()=>{})}s.cachedTokenPromise.then(()=>Jg(e))}function Yg(e,t){const n=_g(e);var r=n.tokenObservers.filter(e=>e.next!==t);0===r.length&&n.tokenRefresher&&n.tokenRefresher.isRunning()&&n.tokenRefresher.stop(),wg(e,Object.assign(Object.assign({},n),{tokenObservers:r}))}function Jg(e){var t=e["app"],n=_g(t);let r=n.tokenRefresher;r||(r=function(n){const r=n["app"];return new Eg(async()=>{var e=_g(r);let t;if(t=e.token?await Gg(n,!0):await Gg(n),t.error)throw t.error},()=>!0,()=>{var e=_g(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},Tg.RETRIAL_MIN_WAIT,Tg.RETRIAL_MAX_WAIT)}(e),wg(t,Object.assign(Object.assign({},n),{tokenRefresher:r}))),!r.isRunning()&&n.isTokenAutoRefreshEnabled&&r.start()}function Xg(e,t){for(const n of _g(e).tokenObservers)try{"EXTERNAL"===n.type&&null!=t.error?n.error(t.error):n.next(t)}catch(e){}}function Zg(e){return 0<e.expireTimeMillis-Date.now()}class em{constructor(e,t){this.app=e,this.platformLoggerProvider=t}_delete(){var e=_g(this.app)["tokenObservers"];for(const t of e)Yg(this.app,t.next);return Promise.resolve()}}const tm="https://www.google.com/recaptcha/api.js",nm="https://www.google.com/recaptcha/enterprise.js";function rm(t,n){var e=_g(t);const r=new rd;wg(t,Object.assign(Object.assign({},e),{reCAPTCHAState:{initialized:r}}));const i=om(t);e=Sg(!1);return e?sm(t,n,e,i,r):function(e){const t=document.createElement("script");t.src=tm,t.onload=e,document.head.appendChild(t)}(()=>{var e=Sg(!1);if(!e)throw new Error("no recaptcha");sm(t,n,e,i,r)}),r.promise}function im(t,n){var e=_g(t);const r=new rd;wg(t,Object.assign(Object.assign({},e),{reCAPTCHAState:{initialized:r}}));const i=om(t);e=Sg(!0);return e?sm(t,n,e,i,r):function(e){const t=document.createElement("script");t.src=nm,t.onload=e,document.head.appendChild(t)}(()=>{var e=Sg(!0);if(!e)throw new Error("no recaptcha");sm(t,n,e,i,r)}),r.promise}function sm(r,i,s,o,a){s.ready(()=>{var e,t,n;e=r,t=s.render(o,{sitekey:i,size:"invisible"}),n=_g(e),wg(e,Object.assign(Object.assign({},n),{reCAPTCHAState:Object.assign(Object.assign({},n.reCAPTCHAState),{widgetId:t})})),a.resolve(s)})}function om(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 am(r){Cg(r);const i=await _g(r).reCAPTCHAState.initialized.promise;return new Promise((e,t)=>{const n=_g(r).reCAPTCHAState;i.ready(()=>{e(i.execute(n.widgetId,{action:"fire_app_check"}))})})}class cm{constructor(e){this._siteKey=e,this._throttleData=null}async getToken(){dm(this._throttleData);var t=await am(this._app).catch(e=>{throw kg.create("recaptcha-error")});let e;try{e=await Rg(function(e,t){var{projectId:n,appId:r,apiKey:i}=e.options;return{url:`${bg}/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=hm(Number(null===(t=e.customData)||void 0===t?void 0:t.httpStatus),this._throttleData),kg.create("throttled",{time:Ag(this._throttleData.allowRequestsAfter-Date.now()),httpStatus:this._throttleData.httpStatus})):e}return this._throttleData=null,e}initialize(e){this._app=e,this._platformLoggerProvider=pp(e,"platform-logger"),rm(e,this._siteKey).catch(()=>{})}isEqual(e){return e instanceof cm&&this._siteKey===e._siteKey}}class lm{constructor(e){this._siteKey=e,this._throttleData=null}async getToken(){dm(this._throttleData);var t=await am(this._app).catch(e=>{throw kg.create("recaptcha-error")});let e;try{e=await Rg(function(e,t){var{projectId:n,appId:r,apiKey:i}=e.options;return{url:`${bg}/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=hm(Number(null===(t=e.customData)||void 0===t?void 0:t.httpStatus),this._throttleData),kg.create("throttled",{time:Ag(this._throttleData.allowRequestsAfter-Date.now()),httpStatus:this._throttleData.httpStatus})):e}return this._throttleData=null,e}initialize(e){this._app=e,this._platformLoggerProvider=pp(e,"platform-logger"),im(e,this._siteKey).catch(()=>{})}isEqual(e){return e instanceof lm&&this._siteKey===e._siteKey}}class um{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 um&&this._customProviderOptions.getToken.toString()===e._customProviderOptions.getToken.toString()}}function hm(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 dm(e){if(e&&Date.now()-e.allowRequestsAfter<=0)throw kg.create("throttled",{time:Ag(e.allowRequestsAfter-Date.now()),httpStatus:e.httpStatus})}function pm(e=yp(),t){const n=pp(e=$d(e),"app-check");if(yg.initialized||zg(),$g()&&Kg().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 kg.create("already-initialized",{appName:e.name})}r=n.initialize({options:t});return function(t,e,n){const r=_g(t),i=Object.assign(Object.assign({},r),{activated:!0});i.provider=e,i.cachedTokenPromise=Vg(t).then(e=>(e&&Zg(e)&&(wg(t,Object.assign(Object.assign({},_g(t)),{token:e})),Xg(t,{token:e.token})),e)),i.isTokenAutoRefreshEnabled=void 0===n?t.automaticDataCollectionEnabled:n,wg(t,i),i.provider.initialize(t)}(e,t.provider,t.isTokenAutoRefreshEnabled),_g(e).isTokenAutoRefreshEnabled&&Qg(r,"INTERNAL",()=>{}),r}const fm="app-check-internal";dp(new Kd("app-check",e=>{var t,n=e.getProvider("app").getImmediate(),r=e.getProvider("platform-logger");return t=n,e=r,new em(t,e)},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{e.getProvider(fm).initialize()})),dp(new Kd(fm,e=>{var t,n=e.getProvider("app-check").getImmediate();return t=n,{getToken:e=>Gg(t,e),addTokenListener:e=>Qg(t,"INTERNAL",e),removeTokenListener:e=>Yg(t.app,e)}},"PUBLIC").setInstantiationMode("EXPLICIT")),wp("@firebase/app-check","0.5.3-canary.88d43ec00");const gm=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 mm{constructor(e){this.app=e}activate(e,t){let n;n="string"==typeof e?new cm(e):e instanceof lm||e instanceof cm||e instanceof um?e:new um({getToken:e.getToken}),this._delegate=pm(this.app,{provider:n,isTokenAutoRefreshEnabled:t})}setTokenAutoRefreshEnabled(e){if(!this._delegate)throw gm.create("use-before-activation",{appName:this.app.name});!function(e,t){var n=e.app;const r=_g(n);r.tokenRefresher&&(!0===t?r.tokenRefresher.start():r.tokenRefresher.stop()),wg(n,Object.assign(Object.assign({},r),{isTokenAutoRefreshEnabled:t}))}(this._delegate,e)}getToken(e){if(!this._delegate)throw gm.create("use-before-activation",{appName:this.app.name});return async function(e,t){var n=await Gg(e,t);if(n.error)throw n.error;return{token:n.token}}(this._delegate,e)}onTokenChanged(e,t,n){if(!this._delegate)throw gm.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),Qg(e,"EXTERNAL",r,i),()=>Yg(e.app,r)}(this._delegate,e,t)}}const vm=e=>{var t=e.getProvider("app-compat").getImmediate();return new mm(t)};function ym(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}Ap.INTERNAL.registerComponent(new Kd("appCheck-compat",vm,"PUBLIC").setServiceProps({ReCaptchaEnterpriseProvider:lm,ReCaptchaV3Provider:cm,CustomProvider:um})),Ap.registerVersion("@firebase/app-check-compat","0.2.3-canary.88d43ec00");const _m={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"},wm={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 bm(){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 Im(){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 Tm=bm,Em=new md("auth","Firebase",bm()),km=new ep("@firebase/auth");function Sm(e,...t){km.logLevel<=$h.ERROR&&km.error(`Auth (${mp}): ${e}`,...t)}function Cm(e,...t){throw Pm(e,...t)}function Am(e,...t){return Pm(e,...t)}function Nm(e,t,n){var r=Object.assign(Object.assign({},Tm()),{[t]:n});const i=new md("auth","Firebase",r);return i.create(t,{appName:e.name})}function Rm(e,t,n){if(!(t instanceof n))throw n.name!==t.constructor.name&&Cm(e,"argument-error"),Nm(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.`+"Did you pass a reference from a different Auth SDK?")}function Pm(e,...t){if("string"==typeof e)return Em.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 xm(e,t,...n){if(!e)throw Pm(t,...n)}function Dm(e){var t="INTERNAL ASSERTION FAILED: "+e;throw Sm(t),new Error(t)}function Om(e,t){e||Dm(t)}const Mm=new Map;function Lm(e){Om(e instanceof Function,"Expected a class definition");let t=Mm.get(e);return t?Om(t instanceof e,"Instance stored in cache mismatched with class"):(t=new e,Mm.set(e,t)),t}function Fm(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.href)||""}function Um(){return"http:"===jm()||"https:"===jm()}function jm(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.protocol)||null}class qm{constructor(e,t){Om((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&&(Um()||cd()||"connection"in navigator)&&!navigator.onLine?Math.min(5e3,this.shortDelay):this.isMobile?this.longDelay:this.shortDelay}}function Vm(e,t){Om(e.emulator,"Emulator should always be set here");var n=e.emulator["url"];return t?`${n}${t.startsWith("/")?t.slice(1):t}`:n}class Bm{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 Dm("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 Dm("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 Dm("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}}const Wm={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"},$m=new qm(3e4,6e4);function Km(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function zm(i,s,o,a,e={}){return Hm(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),Bm.fetch()(Qm(i,i.config.apiHost,o,n),Object.assign({method:s,headers:r,referrerPolicy:"no-referrer"},e))})}async function Hm(t,e,n){t._canInitEmulator=!1;var r=Object.assign(Object.assign({},Wm),e);try{const o=new Ym(t),a=await Promise.race([n(),o.promise]);o.clearNetworkTimeout();var i=await a.json();if("needConfirmation"in i)throw Jm(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 Jm(t,"credential-already-in-use",i);if("EMAIL_EXISTS"===l)throw Jm(t,"email-already-in-use",i);var s=r[l]||l.toLowerCase().replace(/[_\s]+/g,"-");if(u)throw Nm(t,s,u);Cm(t,s)}}catch(e){if(e instanceof gd)throw e;Cm(t,"network-request-failed")}}async function Gm(e,t,n,r,i={}){var s=await zm(e,t,n,r,i);return"mfaPendingCredential"in s&&Cm(e,"multi-factor-auth-required",{_serverResponse:s}),s}function Qm(e,t,n,r){var i=`${t}${n}?${r}`;return e.config.emulator?Vm(e.config,i):`${e.config.apiScheme}://${i}`}class Ym{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(Am(this.auth,"timeout")),$m.get())})}clearNetworkTimeout(){clearTimeout(this.timer)}}function Jm(e,t,n){const r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=Am(e,t,r);return i.customData._tokenResponse=n,i}function Xm(e){if(e)try{const t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}function Zm(e){return 1e3*Number(e)}function ev(e){var[t,n,r]=e.split(".");if(void 0===t||void 0===n||void 0===r)return Sm("JWT malformed, contained fewer than 3 sections"),null;try{var i=td(n);return i?JSON.parse(i):(Sm("Failed to decode base64 JWT payload"),null)}catch(e){return Sm("Caught error parsing JWT payload as JSON",e),null}}async function tv(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 nv{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 rv{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=Xm(this.lastLoginAt),this.creationTime=Xm(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function iv(e){var t=e.auth,n=await e.getIdToken(),r=await tv(e,async function(e,t){return zm(e,"POST","/v1/accounts:lookup",t)}(t,{idToken:n}));xm(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=ym(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 rv(i.createdAt,i.lastLoginAt),isAnonymous:t};Object.assign(e,t)}class sv{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){xm(e.idToken,"internal-error"),xm(void 0!==e.idToken,"internal-error"),xm(void 0!==e.refreshToken,"internal-error");var t,n,n="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):(t=e.idToken,xm(n=ev(t),"internal-error"),xm(void 0!==n.exp,"internal-error"),xm(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 xm(!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 Hm(i=e,{},async()=>{var e=Cd({grant_type:"refresh_token",refresh_token:s}).slice(1),{tokenApiHost:t,apiKey:n}=i.config,n=Qm(i,t,"/v1/token",`key=${n}`);const r=await i._getAdditionalHeaders();return r["Content-Type"]="application/x-www-form-urlencoded",Bm.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 sv;return n&&(xm("string"==typeof n,"internal-error",{appName:e}),s.refreshToken=n),r&&(xm("string"==typeof r,"internal-error",{appName:e}),s.accessToken=r),i&&(xm("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 sv,this.toJSON())}_performRefresh(){return Dm("not implemented")}}function ov(e,t){xm("string"==typeof e||void 0===e,"internal-error",{appName:t})}class av{constructor(e){var{uid:t,auth:n,stsTokenManager:r}=e,i=ym(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.emailVerified=!1,this.isAnonymous=!1,this.tenantId=null,this.providerData=[],this.proactiveRefresh=new nv(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 rv(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){var t=await tv(this,this.stsTokenManager.getToken(this.auth,e));return xm(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=ev(r);xm(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:Xm(Zm(i.auth_time)),issuedAtTime:Xm(Zm(i.iat)),expirationTime:Xm(Zm(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 iv(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}(this)}_assign(e){this!==e&&(xm(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 av(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}))}_onReload(e){xm(!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 iv(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){var e=await this.getIdToken();return await tv(this,async function(e,t){return zm(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;xm(u&&f,e,"internal-error");var g=sv.fromJSON(this.name,f);xm("string"==typeof u,e,"internal-error"),ov(n,e.name),ov(r,e.name),xm("boolean"==typeof h,e,"internal-error"),xm("boolean"==typeof d,e,"internal-error"),ov(i,e.name),ov(s,e.name),ov(o,e.name),ov(a,e.name),ov(c,e.name),ov(l,e.name);const m=new av({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 sv;r.updateFromServerResponse(t);var i=new av({uid:t.localId,auth:e,stsTokenManager:r,isAnonymous:n});return await iv(i),i}}class cv{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){}}cv.type="NONE";const lv=cv;function uv(e,t,n){return`firebase:${e}:${t}:${n}`}class hv{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;var{config:r,name:i}=this.auth;this.fullUserKey=uv(this.userKey,r.apiKey,i),this.fullPersistenceKey=uv("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?av._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 hv(Lm(lv),e,n);const r=(await Promise.all(t.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e);let i=r[0]||Lm(lv);const s=uv(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=av._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 hv(i,e,n)}}function dv(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(mv(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(pv(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(yv(t))return"Blackberry";if(_v(t))return"Webos";if(fv(t))return"Safari";if((t.includes("chrome/")||gv(t))&&!t.includes("edge/"))return"Chrome";if(vv(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 pv(e=sd()){return/firefox\//i.test(e)}function fv(e=sd()){const t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function gv(e=sd()){return/crios\//i.test(e)}function mv(e=sd()){return/iemobile/i.test(e)}function vv(e=sd()){return/android/i.test(e)}function yv(e=sd()){return/blackberry/i.test(e)}function _v(e=sd()){return/webos/i.test(e)}function wv(e=sd()){return/iphone|ipad|ipod/i.test(e)}function bv(e=sd()){return wv(e)||vv(e)||_v(e)||yv(e)||/windows phone/i.test(e)||mv(e)}function Iv(e,t=[]){let n;switch(e){case"Browser":n=dv(sd());break;case"Worker":n=`${dv(sd())}-${e}`;break;default:n=e}var r=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${mp}/${r}`}class Tv{constructor(e,t){this.app=e,this.config=t,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new kv(this),this.idTokenSubscription=new kv(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=Em,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=Lm(n)),this._initializationPromise=this.queue(async()=>{var e;if(!this._deleted&&(this.persistenceManager=await hv.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?(xm(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 iv(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&&xm(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&&xm(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(Lm(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||(xm(t=e&&Lm(e)||this._popupRedirectResolver,this,"argument-error"),this.redirectPersistenceManager=await hv.create(this,[Lm(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 xm(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 xm(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=Iv(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 Ev(e){return $d(e)}class kv{constructor(e){this.auth=e,this.observer=null,this.addObserver=Pd(e=>this.observer=e)}get next(){return xm(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}function Sv(e,t,n){const r=Ev(e);xm(r._canInitEmulator,r,"emulator-config-failed"),xm(/^https?:\/\//.test(t),r,"invalid-emulator-scheme");var i=!(null==n||!n.disableWarnings);const s=Cv(t);var{host:o,port:a}=function(e){const t=Cv(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:Av(r.substr(s.length+1))}}var[o,s]=r.split(":");return{host:o,port:Av(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 Cv(e){var t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function Av(e){if(!e)return null;var t=Number(e);return isNaN(t)?null:t}class Nv{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return Dm("not implemented")}_getIdTokenResponse(e){return Dm("not implemented")}_linkToIdToken(e,t){return Dm("not implemented")}_getReauthenticationResolver(e){return Dm("not implemented")}}async function Rv(e,t){return zm(e,"POST","/v1/accounts:resetPassword",Km(e,t))}async function Pv(e,t){return zm(e,"POST","/v1/accounts:update",t)}async function xv(e,t){return zm(e,"POST","/v1/accounts:sendOobCode",Km(e,t))}class Dv extends Nv{constructor(e,t,n,r=null){super("password",n),this._email=e,this._password=t,this._tenantId=r}static _fromEmailAndPassword(e,t){return new Dv(e,t,"password")}static _fromEmailAndCode(e,t,n=null){return new Dv(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 Gm(e,"POST","/v1/accounts:signInWithPassword",Km(e,t))}(e,{returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(e,t){return Gm(e,"POST","/v1/accounts:signInWithEmailLink",Km(e,t))}(e,{email:this._email,oobCode:this._password});default:Cm(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return Pv(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(e,t){return Gm(e,"POST","/v1/accounts:signInWithEmailLink",Km(e,t))}(e,{idToken:t,email:this._email,oobCode:this._password});default:Cm(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function Ov(e,t){return Gm(e,"POST","/v1/accounts:signInWithIdp",Km(e,t))}class Mv extends Nv{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new Mv(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):Cm("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=ym(t,["providerId","signInMethod"]);if(!n||!r)return null;const i=new Mv(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 Ov(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,Ov(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Ov(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 Lv={USER_NOT_FOUND:"user-not-found"};class Fv extends Nv{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new Fv({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new Fv({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return async function(e,t){return Gm(e,"POST","/v1/accounts:signInWithPhoneNumber",Km(e,t))}(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return async function(e,t){var n=await Gm(e,"POST","/v1/accounts:signInWithPhoneNumber",Km(e,t));if(n.temporaryProof)throw Jm(e,"account-exists-with-different-credential",n);return n}(e,Object.assign({idToken:t},this._makeVerificationRequest()))}_getReauthenticationResolver(e){return async function(e,t){return Gm(e,"POST","/v1/accounts:signInWithPhoneNumber",Km(e,Object.assign(Object.assign({},t),{operation:"REAUTH"})),Lv)}(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 Fv({verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}):null}}class Uv{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);xm(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 Uv(t)}catch(e){return null}}}class jv{constructor(){this.providerId=jv.PROVIDER_ID}static credential(e,t){return Dv._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){var n=Uv.parseLink(t);return xm(n,"argument-error"),Dv._fromEmailAndCode(e,n.code,n.tenantId)}}jv.PROVIDER_ID="password",jv.EMAIL_PASSWORD_SIGN_IN_METHOD="password",jv.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class qv{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 Vv extends qv{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class Bv extends Vv{static credentialFromJSON(e){var t="string"==typeof e?JSON.parse(e):e;return xm("providerId"in t&&"signInMethod"in t,"argument-error"),Mv._fromParams(t)}credential(e){return this._credential(Object.assign(Object.assign({},e),{nonce:e.rawNonce}))}_credential(e){return xm(e.idToken||e.accessToken,"argument-error"),Mv._fromParams(Object.assign(Object.assign({},e),{providerId:this.providerId,signInMethod:this.providerId}))}static credentialFromResult(e){return Bv.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return Bv.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 Bv(o)._credential({idToken:t,accessToken:n,nonce:s,pendingToken:i})}catch(e){return null}}}class Wv extends Vv{constructor(){super("facebook.com")}static credential(e){return Mv._fromParams({providerId:Wv.PROVIDER_ID,signInMethod:Wv.FACEBOOK_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.FACEBOOK_SIGN_IN_METHOD="facebook.com",Wv.PROVIDER_ID="facebook.com";class $v extends Vv{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return Mv._fromParams({providerId:$v.PROVIDER_ID,signInMethod:$v.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return $v.credentialFromTaggedObject(e)}static credentialFromError(e){return $v.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthIdToken:t,oauthAccessToken:n}=e;if(!t&&!n)return null;try{return $v.credential(t,n)}catch(e){return null}}}$v.GOOGLE_SIGN_IN_METHOD="google.com",$v.PROVIDER_ID="google.com";class Kv extends Vv{constructor(){super("github.com")}static credential(e){return Mv._fromParams({providerId:Kv.PROVIDER_ID,signInMethod:Kv.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Kv.credentialFromTaggedObject(e)}static credentialFromError(e){return Kv.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return Kv.credential(e.oauthAccessToken)}catch(e){return null}}}Kv.GITHUB_SIGN_IN_METHOD="github.com",Kv.PROVIDER_ID="github.com";class zv extends Nv{constructor(e,t){super(e,e),this.pendingToken=t}_getIdTokenResponse(e){return Ov(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,Ov(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Ov(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 zv(t,r):null}static _create(e,t){return new zv(e,t)}buildRequest(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}class Hv extends qv{constructor(e){xm(e.startsWith("saml."),"argument-error"),super(e)}static credentialFromResult(e){return Hv.samlCredentialFromTaggedObject(e)}static credentialFromError(e){return Hv.samlCredentialFromTaggedObject(e.customData||{})}static credentialFromJSON(e){var t=zv.fromJSON(e);return xm(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 zv._create(n,t)}catch(e){return null}}}class Gv extends Vv{constructor(){super("twitter.com")}static credential(e,t){return Mv._fromParams({providerId:Gv.PROVIDER_ID,signInMethod:Gv.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return Gv.credentialFromTaggedObject(e)}static credentialFromError(e){return Gv.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return Gv.credential(t,n)}catch(e){return null}}}async function Qv(e,t){return Gm(e,"POST","/v1/accounts:signUp",Km(e,t))}Gv.TWITTER_SIGN_IN_METHOD="twitter.com",Gv.PROVIDER_ID="twitter.com";class Yv{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 av._fromIdTokenResponse(e,n,r),s=Jv(n);return new Yv({user:i,providerId:s,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);var r=Jv(n);return new Yv({user:e,providerId:r,_tokenResponse:n,operationType:t})}}function Jv(e){return e.providerId||("phoneNumber"in e?"phone":null)}class Xv extends gd{constructor(e,t,n,r){var i;super(t.code,t.message),this.operationType=n,this.user=r,Object.setPrototypeOf(this,Xv.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 Xv(e,t,n,r)}}function Zv(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 Xv._fromErrorAndOperation(t,e,n,r);throw e})}function ey(e){return new Set(e.map(({providerId:e})=>e).filter(e=>!!e))}async function ty(e,t){const n=$d(e);await ry(!0,n,t);var r=(e=n.auth,t={idToken:await n.getIdToken(),deleteProvider:[t]},await zm(e,"POST","/v1/accounts:update",t))["providerUserInfo"];const i=ey(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 ny(e,t,n=!1){var r=await tv(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return Yv._forOperation(e,"link",r)}async function ry(e,t,n){await iv(t);const r=ey(t.providerData);var i=!1===e?"provider-already-linked":"no-such-provider";xm(r.has(n)===e,t.auth,i)}async function iy(e,t,n=!1){var r=e["auth"],i="reauthenticate";try{var s=await tv(e,Zv(r,i,t,e),n);xm(s.idToken,r,"internal-error");var o=ev(s.idToken);xm(o,r,"internal-error");var a=o["sub"];return xm(e.uid===a,r,"user-mismatch"),Yv._forOperation(e,i,s)}catch(e){throw"auth/user-not-found"===(null==e?void 0:e.code)&&Cm(r,"user-mismatch"),e}}async function sy(e,t,n=!1){var r=await Zv(e,"signIn",t),r=await Yv._fromIdTokenResponse(e,"signIn",r);return n||await e._updateCurrentUser(r.user),r}async function oy(e,t){return sy(Ev(e),t)}async function ay(e,t){var n=$d(e);return await ry(!1,n,t.providerId),ny(n,t)}async function cy(e,t){return iy($d(e),t)}async function ly(e,t){const n=Ev(e);var r=await Gm(n,"POST","/v1/accounts:signInWithCustomToken",Km(n,{token:t,returnSecureToken:!0})),r=await Yv._fromIdTokenResponse(n,"signIn",r);return await n._updateCurrentUser(r.user),r}class uy{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?hy._fromServerResponse(e,t):Cm(e,"internal-error")}}class hy extends uy{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new hy(t)}}function dy(e,t,n){var r;xm(0<(null===(r=n.url)||void 0===r?void 0:r.length),e,"invalid-continue-uri"),xm(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&&(xm(0<n.iOS.bundleId.length,e,"missing-ios-bundle-id"),t.iOSBundleId=n.iOS.bundleId),n.android&&(xm(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 py(e,t,n){var r=$d(e),i={requestType:"PASSWORD_RESET",email:t};n&&dy(r,i,n),await xv(r,i)}async function fy(e,t){await zm(e=$d(e),"POST","/v1/accounts:update",Km(e,{oobCode:t}))}async function gy(e,t){var n=$d(e),r=await Rv(n,{oobCode:t}),i=r.requestType;switch(xm(i,n,"internal-error"),i){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":xm(r.newEmail,n,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":xm(r.mfaInfo,n,"internal-error");default:xm(r.email,n,"internal-error")}let s=null;return r.mfaInfo&&(s=uy._fromServerResponse(Ev(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 my(e,t,n){var r=$d(e),i={requestType:"EMAIL_SIGNIN",email:t};xm(n.handleCodeInApp,r,"argument-error"),n&&dy(r,i,n),await xv(r,i)}async function vy(e,t){var n=Um()?Fm():"http://localhost",n=(await zm(e=$d(e),"POST","/v1/accounts:createAuthUri",Km(e,{identifier:t,continueUri:n})))["signinMethods"];return n||[]}async function yy(e,t){var n=$d(e),r={requestType:"VERIFY_EMAIL",idToken:await e.getIdToken()};t&&dy(n.auth,r,t);var r=(await xv(n.auth,r))["email"];r!==e.email&&await e.reload()}async function _y(e,t,n){var r=$d(e),i={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await e.getIdToken(),newEmail:t};n&&dy(r.auth,i,n);var i=(await xv(r.auth,i))["email"];i!==e.email&&await e.reload()}async function wy(e,{displayName:t,photoURL:n}){if(void 0!==t||void 0!==n){const i=$d(e);var r=await i.getIdToken(),r=await tv(i,async function(e,t){return zm(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 by(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 tv(e,Pv(r,i));await e._updateTokensIfNecessary(r,!0)}class Iy{constructor(e,t,n={}){this.isNewUser=e,this.providerId=t,this.profile=n}}class Ty extends Iy{constructor(e,t,n,r){super(e,t,n),this.username=r}}class Ey extends Iy{constructor(e,t){super(e,"facebook.com",t)}}class ky extends Ty{constructor(e,t){super(e,"github.com",t,"string"==typeof(null==t?void 0:t.login)?null==t?void 0:t.login:null)}}class Sy extends Iy{constructor(e,t){super(e,"google.com",t)}}class Cy extends Ty{constructor(e,t,n){super(e,"twitter.com",t,n)}}function Ay(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=ev(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 Iy(r,i)}}if(!t)return null;switch(t){case"facebook.com":return new Ey(r,n);case"github.com":return new ky(r,n);case"google.com":return new Sy(r,n);case"twitter.com":return new Cy(r,n,e.screenName||null);case"custom":case"anonymous":return new Iy(r,null);default:return new Iy(r,t,n)}}(n)}class Ny{constructor(e,t){this.type=e,this.credential=t}static _fromIdtoken(e){return new Ny("enroll",e)}static _fromMfaPendingCredential(e){return new Ny("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 Ny._fromMfaPendingCredential(e.multiFactorSession.pendingCredential);if(null!==(t=e.multiFactorSession)&&void 0!==t&&t.idToken)return Ny._fromIdtoken(e.multiFactorSession.idToken)}return null}}class Ry{constructor(e,t,n){this.session=e,this.hints=t,this.signInResolver=n}static _fromError(e,i){const s=Ev(e),o=i.customData._serverResponse;var t=(o.mfaInfo||[]).map(e=>uy._fromServerResponse(s,e));xm(o.mfaPendingCredential,s,"internal-error");const a=Ny._fromMfaPendingCredential(o.mfaPendingCredential);return new Ry(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 Yv._fromIdTokenResponse(s,i.operationType,n);return await s._updateCurrentUser(r.user),r;case"reauthenticate":return xm(i.user,s,"internal-error"),Yv._forOperation(i.user,i.operationType,n);default:Cm(s,"internal-error")}})}async resolveSignIn(e){return this.signInResolver(e)}}class Py{constructor(t){this.user=t,this.enrolledFactors=[],t._onReload(e=>{e.mfaInfo&&(this.enrolledFactors=e.mfaInfo.map(e=>uy._fromServerResponse(t.auth,e)))})}static _fromUser(e){return new Py(e)}async getSession(){return Ny._fromIdtoken(await this.user.getIdToken())}async enroll(e,t){const n=e;var r=await this.getSession(),r=await tv(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 tv(this.user,(n=this.user.auth,e={idToken:r,mfaEnrollmentId:t},zm(n,"POST","/v2/accounts/mfaEnrollment:withdraw",Km(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 xy=new WeakMap;const Dy="__sak";class Oy{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Dy,"1"),this.storage.removeItem(Dy),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 My extends Oy{constructor(){var e;super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.safariLocalStorageNotSynced=(fv(e=sd())||wv(e))&&function(){try{return!(!window||window===window.top)}catch(e){return!1}}(),this.fallbackToPolling=bv(),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]}}My.type="LOCAL";const Ly=My;class Fy extends Oy{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Fy.type="SESSION";const Uy=Fy;class jy{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 jy(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 qy(e="",t=10){let n="";for(let r=0;r<t;r++)n+=Math.floor(10*Math.random());return e+n}jy.receivers=[];class Vy{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=qy("",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 By(){return window}function Wy(){return void 0!==By().WorkerGlobalScope&&"function"==typeof By().importScripts}const $y="firebaseLocalStorageDb",Ky="firebaseLocalStorage",zy="fbase_key";class Hy{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 Gy(e,t){return e.transaction([Ky],t?"readwrite":"readonly").objectStore(Ky)}function Qy(){const r=indexedDB.open($y,1);return new Promise((n,t)=>{r.addEventListener("error",()=>{t(r.error)}),r.addEventListener("upgradeneeded",()=>{const e=r.result;try{e.createObjectStore(Ky,{keyPath:zy})}catch(e){t(e)}}),r.addEventListener("success",async()=>{const e=r.result;var t;e.objectStoreNames.contains(Ky)?n(e):(e.close(),t=indexedDB.deleteDatabase($y),await new Hy(t).toPromise(),n(await Qy()))})})}async function Yy(e,t,n){var r=Gy(e,!0).put({fbase_key:t,value:n});return new Hy(r).toPromise()}function Jy(e,t){var n=Gy(e,!0).delete(t);return new Hy(n).toPromise()}class Xy{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 Qy(),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 Wy()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=jy._getInstance(Wy()?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 Vy(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 Qy();return await Yy(e,Dy,"1"),await Jy(e,Dy),!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=>Yy(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=Gy(e,!1).get(t);return void 0===(n=await new Hy(n).toPromise())?null:n.value}(e,t));return this.localCache[t]=e}async _remove(t){return this._withPendingWrite(async()=>(await this._withRetries(e=>Jy(e,t)),delete this.localCache[t],this.notifyServiceWorker(t)))}async _poll(){var e,t,n=await this._withRetries(e=>{var t=Gy(e,!1).getAll();return new Hy(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()}}Xy.type="LOCAL";const Zy=Xy;function e_(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=Am("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 t_(e){return`__${e}${Math.floor(1e6*Math.random())}`}class n_{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 r_(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 r_{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;xm(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 i_=t_("rcb"),s_=new qm(3e4,6e4);class o_{constructor(){this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!By().grecaptcha}load(s,o=""){var e;return xm((e=o).length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(e),s,"argument-error"),this.shouldResolveImmediately(o)?Promise.resolve(By().grecaptcha):new Promise((t,n)=>{const i=By().setTimeout(()=>{n(Am(s,"network-request-failed"))},s_.get());By()[i_]=()=>{By().clearTimeout(i),delete By()[i_];const e=By().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(Am(s,"internal-error"))},e_(`https://www.google.com/recaptcha/api.js??${Cd({onload:i_,render:"explicit",hl:o})}`).catch(()=>{clearTimeout(i),n(Am(s,"internal-error"))})})}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){return!!By().grecaptcha&&(e===this.hostLanguage||0<this.counter||this.librarySeparatelyLoaded)}}class a_{async load(e){return new n_(e)}clearedOneInstance(){}}const c_="recaptcha",l_={theme:"light",type:"image"};class u_{constructor(e,t=Object.assign({},l_),n){this.parameters=t,this.type=c_,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=Ev(n),this.isInvisible="invisible"===this.parameters.size,xm("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment");var r="string"==typeof e?document.getElementById(e):e;xm(r,this.auth,"argument-error"),this.container=r,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=new(this.auth.settings.appVerificationDisabledForTesting?a_:o_),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(){xm(!this.parameters.sitekey,this.auth,"argument-error"),xm(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),xm("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=By()[n];"function"==typeof e&&e(t)}}}assertNotDestroyed(){xm(!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(){xm(Um()&&!Wy(),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 zm(this.auth,"GET","/v1/recaptchaParams")).recaptchaSiteKey||"");xm(e,this.auth,"internal-error"),this.parameters.sitekey=e}getAssertedRecaptcha(){return xm(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}class h_{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){var t=Fv._fromVerification(this.verificationId,e);return this.onConfirmation(t)}}async function d_(t,n,r){var i,s,o,a,c,l,u=await r.verify();try{xm("string"==typeof u,t,"argument-error"),xm(r.type===c_,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 xm("enroll"===h.type,t,"internal-error"),(c=t,l={idToken:h.credential,phoneEnrollmentInfo:{phoneNumber:e.phoneNumber,recaptchaToken:u}},await zm(c,"POST","/v2/accounts/mfaEnrollment:start",Km(c,l))).phoneSessionInfo.sessionInfo;xm("signin"===h.type,t,"internal-error");var d=(null===(i=e.multiFactorHint)||void 0===i?void 0:i.uid)||e.multiFactorUid;return xm(d,t,"missing-multi-factor-info"),(a={mfaPendingCredential:h.credential,mfaEnrollmentId:d,phoneSignInInfo:{recaptchaToken:u}},await zm(t,"POST","/v2/accounts/mfaSignIn:start",Km(t,a))).phoneResponseInfo.sessionInfo}var p=(s=t,o={phoneNumber:e.phoneNumber,recaptchaToken:u},await zm(s,"POST","/v1/accounts:sendVerificationCode",Km(s,o)))["sessionInfo"];return p}finally{r._reset()}}class p_{constructor(e){this.providerId=p_.PROVIDER_ID,this.auth=Ev(e)}verifyPhoneNumber(e,t){return d_(this.auth,e,$d(t))}static credential(e,t){return Fv._fromVerification(e,t)}static credentialFromResult(e){var t=e;return p_.credentialFromTaggedObject(t)}static credentialFromError(e){return p_.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{phoneNumber:t,temporaryProof:n}=e;return t&&n?Fv._fromTokenResponse(t,n):null}}function f_(e,t){return t?Lm(t):(xm(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}p_.PROVIDER_ID="phone",p_.PHONE_SIGN_IN_METHOD="phone";class g_ extends Nv{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Ov(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Ov(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Ov(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 m_(e){return sy(e.auth,new g_(e),e.bypassAuthState)}function v_(e){var{auth:t,user:n}=e;return xm(n,t,"internal-error"),iy(n,new g_(e),e.bypassAuthState)}async function y_(e){var{auth:t,user:n}=e;return xm(n,t,"internal-error"),ny(n,new g_(e),e.bypassAuthState)}class __{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 m_;case"linkViaPopup":case"linkViaRedirect":return y_;case"reauthViaPopup":case"reauthViaRedirect":return v_;default:Cm(this.auth,"internal-error")}}resolve(e){Om(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Om(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 w_=new qm(2e3,1e4);class b_ extends __{constructor(e,t,n,r,i){super(e,t,r,i),this.provider=n,this.authWindow=null,this.pollId=null,b_.currentPopupAction&&b_.currentPopupAction.cancel(),b_.currentPopupAction=this}async executeNotNull(){var e=await this.execute();return xm(e,this.auth,"internal-error"),e}async onExecution(){Om(1===this.filter.length,"Popup operations only handle one event");var e=qy();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(Am(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(Am(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,b_.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(Am(this.auth,"popup-closed-by-user"))},2e3):this.pollId=window.setTimeout(t,w_.get())};t()}}b_.currentPopupAction=null;const I_="pendingRedirect",T_=new Map;class E_ extends __{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let t=T_.get(this.auth._key());if(!t){try{const e=await async function(e,t){const n=C_(t),r=S_(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)}T_.set(this.auth._key(),t)}return this.bypassAuthState||T_.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 k_(e,t){return S_(e)._set(C_(t),"true")}function S_(e){return Lm(e._redirectPersistence)}function C_(e){return uv(I_,e.config.apiKey,e.name)}function A_(e,t,n){return async function(e,t,n){var r=Ev(e);Rm(e,t,qv);const i=f_(r,n);return await k_(i,r),i._openRedirect(r,t,"signInViaRedirect")}(e,t,n)}function N_(e,t,n){return async function(e,t,n){var r=$d(e);Rm(r.auth,t,qv);const i=f_(r.auth,n);await k_(i,r.auth);var s=await x_(r);return i._openRedirect(r.auth,t,"reauthViaRedirect",s)}(e,t,n)}function R_(e,t,n){return async function(e,t,n){var r=$d(e);Rm(r.auth,t,qv);const i=f_(r.auth,n);await ry(!1,r,t.providerId),await k_(i,r.auth);var s=await x_(r);return i._openRedirect(r.auth,t,"linkViaRedirect",s)}(e,t,n)}async function P_(e,t,n=!1){const r=Ev(e);var i=f_(r,t);const s=new E_(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 x_(e){var t=qy(`${e.uid}:::`);return e._redirectEventId=t,await e.auth._setRedirectUser(e),await e.auth._persistUserIfCurrent(e),t}class D_{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 M_(e);default:return!1}}(t)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=t,n=!0)),n}sendToConsumer(e,t){var n;e.error&&!M_(e)?(n=(null===(n=e.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error",t.onError(Am(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(O_(e))}saveEventToCache(e){this.cachedEventUids.add(O_(e)),this.lastProcessedEventTime=Date.now()}}function O_(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function M_({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===(null==t?void 0:t.code)}async function L_(e,t={}){return zm(e,"GET","/v1/projects",t)}const F_=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,U_=/^https?/;async function j_(e){if(!e.config.emulator){var t=(await L_(e))["authorizedDomains"];for(const n of t)try{if(function(e){const t=Fm(),{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(!U_.test(n))return!1;if(F_.test(e))return r===e;const s=e.replace(/\./g,"\\."),o=new RegExp("^(.+\\."+s+"|"+s+")$","i");return o.test(r)}(n))return}catch(e){}Cm(e,"unauthorized-domain")}}const q_=new qm(3e4,6e4);function V_(){const t=By().___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 B_=null;function W_(e){var i;return B_=B_||(i=e,new Promise((e,t)=>{function n(){V_(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{V_(),t(Am(i,"network-request-failed"))},timeout:q_.get()})}if(null!==(r=null===(r=By().gapi)||void 0===r?void 0:r.iframes)&&void 0!==r&&r.Iframe)e(gapi.iframes.getContext());else{if(null===(r=By().gapi)||void 0===r||!r.load){var r=t_("iframefcb");return By()[r]=()=>{gapi.load?n():t(Am(i,"network-request-failed"))},e_(`https://apis.google.com/js/api.js?onload=${r}`).catch(e=>t(e))}n()}}).catch(e=>{throw B_=null,e})),B_}const $_=new qm(5e3,15e3),K_="__/auth/iframe",z_="emulator/auth/iframe",H_={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},G_=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);async function Q_(o){const e=await W_(o);var t=By().gapi;return xm(t,o,"internal-error"),e.open({where:document.body,url:function(e){var t=e.config;xm(t.authDomain,e,"auth-domain-config-required");var n=t.emulator?Vm(t,z_):`https://${e.config.authDomain}/${K_}`;const r={apiKey:t.apiKey,appName:e.name,v:mp};(t=G_.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:H_,dontclear:!0},s=>new Promise(async(e,t)=>{await s.restyle({setHideOnLeave:!1});const n=Am(o,"network-request-failed"),r=By().setTimeout(()=>{t(n)},$_.get());function i(){By().clearTimeout(r),e(s)}s.ping(i).then(i,()=>{t(n)})}))}const Y_={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class J_{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}function X_(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({},Y_),{width:r.toString(),height:i.toString(),top:s,left:o});s=sd().toLowerCase();n&&(a=gv(s)?"_blank":n),pv(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],wv(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 J_(null);const u=window.open(t||"",a,o);xm(u,e,"popup-blocked");try{u.focus()}catch(e){}return new J_(u)}const Z_="__/auth/handler",ew="emulator/auth/handler";function tw(e,t,n,r,i,s){xm(e.config.authDomain,e,"auth-domain-config-required"),xm(e.config.apiKey,e,"invalid-api-key");const o={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:r,v:mp,eventId:i};if(t instanceof qv){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 Vv){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?Vm(e,ew):`https://${e.authDomain}/${Z_}`}?${Cd(l).slice(1)}`}const nw="webStorageSupport";const rw=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Uy,this._completeRedirectFn=P_}async _openPopup(e,t,n,r){var i;return Om(null===(i=this.eventManagers[e._key()])||void 0===i?void 0:i.manager,"_initialize() not called before _openPopup()"),X_(e,tw(e,t,n,Fm(),r),qy())}async _openRedirect(e,t,n,r){return await this._originValidation(e),r=tw(e,t,n,Fm(),r),By().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):(Om(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 Q_(t),n=new D_(t);return e.register("authEvent",e=>{return xm(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(nw,{type:nw},e=>{var t=null===(t=null==e?void 0:e[0])||void 0===t?void 0:t[nw];void 0!==t&&r(!!t),Cm(n,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=j_(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return bv()||fv()||wv()}};class iw 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 Dm("unexpected MultiFactorSessionType")}}}{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new iw(e)}_finalizeEnroll(e,t,n){return e=e,n={idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()},zm(e,"POST","/v2/accounts/mfaEnrollment:finalize",Km(e,n))}_finalizeSignIn(e,t){return e=e,t={mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()},zm(e,"POST","/v2/accounts/mfaSignIn:finalize",Km(e,t))}}class sw{constructor(){}static assertion(e){return iw._fromCredential(e)}}sw.FACTOR_ID="phone";var ow,aw="@firebase/auth",cw="0.19.5-canary.88d43ec00";class lw{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(){xm(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){0<this.internalListeners.size?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function uw(){return window}ow="Browser",dp(new Kd("auth",(e,{options:n})=>{var t=e.getProvider("app").getImmediate();const{apiKey:r,authDomain:i}=t.options;return(e=>{xm(r&&!r.includes(":"),"invalid-api-key",{appName:e.name}),xm(!(null!==i&&void 0!==i&&i.includes(":")),"argument-error",{appName:e.name});var t={apiKey:r,authDomain:i,clientPlatform:ow,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:Iv(ow)},t=new Tv(e,t);return function(e,t){const n=(null==t?void 0:t.persistence)||[];var r=(Array.isArray(n)?n:[n]).map(Lm);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()})),dp(new Kd("auth-internal",e=>{var t=Ev(e.getProvider("auth").getImmediate());return e=t,new lw(e)},"PRIVATE").setInstantiationMode("EXPLICIT")),wp(aw,cw,function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";default:return}}(ow)),wp(aw,cw,"esm2017");async function hw(e,t,n){var r=uw()["BuildInfo"];Om(t.sessionId,"AuthEvent did not contain a session ID");var i=await async function(e){const t=function(e){if(Om(/[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 wv()?s.ibi=r.packageName:vv()?s.apn=r.packageName:Cm(e,"operation-not-supported-in-this-environment"),r.displayName&&(s.appDisplayName=r.displayName),s.sessionId=i,tw(e,n,t.type,void 0,null!==(i=t.eventId)&&void 0!==i?i:void 0,s)}function dw(r){const i=uw()["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 pw=20;class fw extends D_{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 gw(e,t,n=null){return{type:t,eventId:n,urlResponse:null,sessionId:function(){const e=[],t="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let r=0;r<pw;r++){var n=Math.floor(Math.random()*t.length);e.push(t.charAt(n))}return e.join("")}(),postBody:null,tenantId:e.tenantId,error:Am(e,"no-auth-event")}}async function mw(e){var t=await yw()._get(_w(e));return t&&await yw()._remove(_w(e)),t}function vw(e,t){var n,r,i;const s=(n=ww(t=t),o=n.link?decodeURIComponent(n.link):void 0,r=ww(o).link,i=n.deep_link_id?decodeURIComponent(n.deep_link_id):void 0,(n=ww(i).link)||i||r||o||t);if(s.includes("/__/auth/callback")){var o=ww(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?Am(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 yw(){return Lm(Ly)}function _w(e){return uv("authEvent",e.config.apiKey,e.name)}function ww(e){if(null==e||!e.includes("?"))return{};const[,...t]=e.split("?");return Ad(t.join("?"))}const bw=class{constructor(){this._redirectPersistence=Uy,this._shouldInitProactively=!0,this.eventManagers=new Map,this.originValidationPromises={},this._completeRedirectFn=P_}async _initialize(e){var t=e._key();let n=this.eventManagers.get(t);return n||(n=new fw(e),this.eventManagers.set(t,n),this.attachCallbackListeners(e,n)),n}_openPopup(e){Cm(e,"operation-not-supported-in-this-environment")}async _openRedirect(e,t,n,r){var i,s;i=e,a=uw(),xm("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"}),xm(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"}),xm("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"}),xm("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"}),xm("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(),T_.clear(),await this._originValidation(e);var a=gw(e,n,r);n=e,r=a,await yw()._set(_w(n),r);a=await dw(await hw(e,a,t));return async function(o,a,c){const l=uw()["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(Am(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),vv()&&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=uw()["BuildInfo"];const n={};wv()?n.iosBundleId=t.packageName:vv()?n.androidPackageName=t.packageName:Cm(e,"operation-not-supported-in-this-environment"),await L_(e,n)}(e)),this.originValidationPromises[t]}attachCallbackListeners(r,i){const{universalLinks:e,handleOpenURL:t,BuildInfo:n}=uw(),s=setTimeout(async()=>{await mw(r),i.onEvent(Iw())},500),o=async e=>{clearTimeout(s);var t=await mw(r);let n=null;t&&null!=e&&e.url&&(n=vw(t,e.url)),i.onEvent(n||Iw())};void 0!==e&&"function"==typeof e.subscribe&&e.subscribe(null,o);const a=t,c=`${n.packageName.toLowerCase()}://`;uw().handleOpenURL=async e=>{if(e.toLowerCase().startsWith(c)&&o({url:e}),"function"==typeof a)try{a(e)}catch(e){console.error(e)}}}};function Iw(){return{type:"unknown",eventId:null,sessionId:null,urlResponse:null,postBody:null,tenantId:null,error:Am("no-auth-event")}}var Tw;function Ew(){var e;return(null===(e=null===self||void 0===self?void 0:self.location)||void 0===e?void 0:e.protocol)||null}function kw(e=sd()){return!("file:"!==Ew()&&"ionic:"!==Ew()||!e.toLowerCase().match(/iphone|ipad|ipod|android/))}function Sw(e=sd()){return ud()&&11===(null===document||void 0===document?void 0:document.documentMode)||([e=sd()]=[e],/Edge\/\d+/.test(e))}function Cw(){try{const t=self.localStorage;var e=qy();if(t)return t.setItem(e,"1"),t.removeItem(e),!Sw()||dd()}catch(e){return Aw()&&dd()}return!1}function Aw(){return"undefined"!=typeof global&&"WorkerGlobalScope"in global&&"importScripts"in global}function Nw(){return("http:"===Ew()||"https:"===Ew()||cd()||kw())&&!(ld()||ad())&&Cw()&&!Aw()}function Rw(){return kw()&&"undefined"!=typeof document}const Pw={LOCAL:"local",NONE:"none",SESSION:"session"},xw=xm,Dw="persistence";async function Ow(e){await e._initializationPromise;const t=Mw();var n=uv(Dw,e.config.apiKey,e.name);null!==t&&void 0!==t&&t.sessionStorage&&t.sessionStorage.setItem(n,e._getPersistence())}function Mw(){return"undefined"!=typeof window?window:null}const Lw=xm;class Fw{constructor(){this.browserResolver=Lm(rw),this.cordovaResolver=Lm(bw),this.underlyingResolver=null,this._redirectPersistence=Uy,this._completeRedirectFn=P_}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 Rw()||this.browserResolver._shouldInitProactively}get assertedUnderlyingResolver(){return Lw(this.underlyingResolver,"internal-error"),this.underlyingResolver}async selectUnderlyingResolver(){var e;this.underlyingResolver||(e=await(!!Rw()&&new Promise(e=>{const t=setTimeout(()=>{e(!1)},1e3);document.addEventListener("deviceready",()=>{clearTimeout(t),e(!0)})})),this.underlyingResolver=e?this.cordovaResolver:this.browserResolver)}}function Uw(e){return e.unwrap()}function jw(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 Ww(e,(n=t,i=$d(e),xm((o=n).customData.operationType,i,"argument-error"),xm(null===(r=o.customData._serverResponse)||void 0===r?void 0:r.mfaPendingCredential,i,"argument-error"),Ry._fromError(i,o)))}else if(s){var o=qw(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 qw(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 p_.credentialFromResult(e);const n=t.providerId;if(!n||n===_m.PASSWORD)return null;let r;switch(n){case _m.GOOGLE:r=$v;break;case _m.FACEBOOK:r=Wv;break;case _m.GITHUB:r=Kv;break;case _m.TWITTER:r=Gv;break;default:var{oauthIdToken:i,oauthAccessToken:s,oauthTokenSecret:o,pendingToken:a,nonce:c}=t;return s||o||i||a?a?n.startsWith("saml.")?zv._create(n,a):Mv._fromParams({providerId:n,signInMethod:n,pendingToken:a,idToken:i,accessToken:s}):new Bv(n).credential({idToken:i,accessToken:s,rawNonce:c}):null}return e instanceof gd?r.credentialFromError(e):r.credentialFromResult(e)}function Vw(t,e){return e.catch(e=>{throw e instanceof gd&&jw(t,e),e}).then(e=>{var t=e.operationType,n=e.user;return{operationType:t,credential:qw(e),additionalUserInfo:Ay(e),user:$w.getOrCreate(n)}})}async function Bw(t,e){const n=await e;return{verificationId:n.verificationId,confirm:e=>Vw(t,n.confirm(e))}}class Ww{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 Vw(Uw(this.auth),this.resolver.resolveSignIn(e))}}class $w{constructor(e){var t;this._delegate=e,this.multiFactor=(t=$d(e),xy.has(t)||xy.set(t,Py._fromUser(t)),xy.get(t))}static getOrCreate(e){return $w.USER_MAP.has(e)||$w.USER_MAP.set(e,new $w(e)),$w.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 Vw(this.auth,ay(this._delegate,e))}async linkWithPhoneNumber(e,t){return Bw(this.auth,async function(e,t,n){const r=$d(e);await ry(!1,r,"phone");var i=await d_(r.auth,t,$d(n));return new h_(i,e=>ay(r,e))}(this._delegate,e,t))}async linkWithPopup(e){return Vw(this.auth,async function(e,t,n){var r=$d(e);Rm(r.auth,t,qv);var i=f_(r.auth,n);const s=new b_(r.auth,"linkViaPopup",t,i,r);return s.executeNotNull()}(this._delegate,e,Fw))}async linkWithRedirect(e){return await Ow(Ev(this.auth)),R_(this._delegate,e,Fw)}reauthenticateAndRetrieveDataWithCredential(e){return this.reauthenticateWithCredential(e)}async reauthenticateWithCredential(e){return Vw(this.auth,cy(this._delegate,e))}reauthenticateWithPhoneNumber(e,t){return Bw(this.auth,async function(e,t,n){const r=$d(e);var i=await d_(r.auth,t,$d(n));return new h_(i,e=>cy(r,e))}(this._delegate,e,t))}reauthenticateWithPopup(e){return Vw(this.auth,async function(e,t,n){var r=$d(e);Rm(r.auth,t,qv);var i=f_(r.auth,n);const s=new b_(r.auth,"reauthViaPopup",t,i,r);return s.executeNotNull()}(this._delegate,e,Fw))}async reauthenticateWithRedirect(e){return await Ow(Ev(this.auth)),N_(this._delegate,e,Fw)}sendEmailVerification(e){return yy(this._delegate,e)}async unlink(e){return await ty(this._delegate,e),this}updateEmail(e){return by($d(this._delegate),e,null)}updatePassword(e){return by($d(this._delegate),null,e)}updatePhoneNumber(e){return async function(e,t){await ny($d(e),t)}(this._delegate,e)}updateProfile(e){return wy(this._delegate,e)}verifyBeforeUpdateEmail(e,t){return _y(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}}$w.USER_MAP=new WeakMap;const Kw=xm;class zw{constructor(e,t){if(this.app=e,t.isInitialized())return this._delegate=t.getImmediate(),void this.linkUnderlyingAuth();var n=e.options["apiKey"];Kw(n,"invalid-api-key",{appName:e.name}),Kw(n,"invalid-api-key",{appName:e.name});var r="undefined"!=typeof window?Fw:void 0;this._delegate=t.initialize({options:{persistence:function(e,t){const n=function(e,t){const n=Mw();if(null===n||void 0===n||!n.sessionStorage)return[];var r=uv(Dw,e,t);switch(n.sessionStorage.getItem(r)){case Pw.NONE:return[lv];case Pw.LOCAL:return[Zy,Uy];case Pw.SESSION:return[Uy];default:return[]}}(e,t);"undefined"==typeof self||n.includes(Zy)||n.push(Zy);if("undefined"!=typeof window)for(const r of[Ly,Uy])n.includes(r)||n.push(r);n.includes(lv)||n.push(lv);return n}(n,e.name),popupRedirectResolver:r}}),this._delegate._updateErrorMap(Im),this.linkUnderlyingAuth()}get emulatorConfig(){return this._delegate.emulatorConfig}get currentUser(){return this._delegate.currentUser?$w.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){Sv(this._delegate,e,t)}applyActionCode(e){return fy(this._delegate,e)}checkActionCode(e){return gy(this._delegate,e)}confirmPasswordReset(e,t){return async function(e,t,n){await Rv($d(e),{oobCode:t,newPassword:n})}(this._delegate,e,t)}async createUserWithEmailAndPassword(e,t){return Vw(this._delegate,async function(e,t,n){const r=Ev(e);var i=await Qv(r,{returnSecureToken:!0,email:t,password:n}),i=await Yv._fromIdTokenResponse(r,"signIn",i);return await r._updateCurrentUser(i.user),i}(this._delegate,e,t))}fetchProvidersForEmail(e){return this.fetchSignInMethodsForEmail(e)}fetchSignInMethodsForEmail(e){return vy(this._delegate,e)}isSignInWithEmailLink(e){return this._delegate,e=e,"EMAIL_SIGNIN"===(null==(t=Uv.parseLink(e))?void 0:t.operation);var t}async getRedirectResult(){Kw(Nw(),this._delegate,"operation-not-supported-in-this-environment");var e,t,n=(e=this._delegate,t=Fw,await Ev(e)._initializationPromise,await P_(e,t,!1));return n?Vw(this._delegate,Promise.resolve(n)):{credential:null,user:null}}addFrameworkForLogging(e){Ev(this._delegate)._logFramework(e)}onAuthStateChanged(e,t,n){var{next:r,error:i,complete:s}=Hw(e,t,n);return this._delegate.onAuthStateChanged(r,i,s)}onIdTokenChanged(e,t,n){var{next:r,error:i,complete:s}=Hw(e,t,n);return this._delegate.onIdTokenChanged(r,i,s)}sendSignInLinkToEmail(e,t){return my(this._delegate,e,t)}sendPasswordResetEmail(e,t){return py(this._delegate,e,t||void 0)}async setPersistence(e){var t,n;t=this._delegate,n=e,xw(Object.values(Pw).includes(n),t,"invalid-persistence-type"),ld()?xw(n!==Pw.SESSION,t,"unsupported-persistence-type"):ad()?xw(n===Pw.NONE,t,"unsupported-persistence-type"):Aw()?xw(n===Pw.NONE||n===Pw.LOCAL&&dd(),t,"unsupported-persistence-type"):xw(n===Pw.NONE||Cw(),t,"unsupported-persistence-type");let r;switch(e){case Pw.SESSION:r=Uy;break;case Pw.LOCAL:var i=await Lm(Zy)._isAvailable();r=i?Zy:Ly;break;case Pw.NONE:r=lv;break;default:return Cm("argument-error",{appName:this._delegate.name})}return this._delegate.setPersistence(r)}signInAndRetrieveDataWithCredential(e){return this.signInWithCredential(e)}signInAnonymously(){return Vw(this._delegate,async function(e){const t=Ev(e);if(await t._initializationPromise,null!==(n=t.currentUser)&&void 0!==n&&n.isAnonymous)return new Yv({user:t.currentUser,providerId:null,operationType:"signIn"});var n=await Qv(t,{returnSecureToken:!0}),n=await Yv._fromIdTokenResponse(t,"signIn",n,!0);return await t._updateCurrentUser(n.user),n}(this._delegate))}signInWithCredential(e){return Vw(this._delegate,oy(this._delegate,e))}signInWithCustomToken(e){return Vw(this._delegate,ly(this._delegate,e))}signInWithEmailAndPassword(e,t){return Vw(this._delegate,(n=this._delegate,e=e,t=t,oy($d(n),jv.credential(e,t))));var n}signInWithEmailLink(e,t){return Vw(this._delegate,async function(e,t,n){var r=$d(e),i=jv.credentialWithLink(t,n||Fm());return xm(i._tenantId===(r.tenantId||null),r,"tenant-id-mismatch"),oy(r,i)}(this._delegate,e,t))}signInWithPhoneNumber(e,t){return Bw(this._delegate,async function(e,t,n){const r=Ev(e);var i=await d_(r,t,$d(n));return new h_(i,e=>oy(r,e))}(this._delegate,e,t))}async signInWithPopup(e){return Kw(Nw(),this._delegate,"operation-not-supported-in-this-environment"),Vw(this._delegate,async function(e,t,n){var r=Ev(e);Rm(e,t,qv);var i=f_(r,n);const s=new b_(r,"signInViaPopup",t,i);return s.executeNotNull()}(this._delegate,e,Fw))}async signInWithRedirect(e){return Kw(Nw(),this._delegate,"operation-not-supported-in-this-environment"),await Ow(this._delegate),A_(this._delegate,e,Fw)}updateCurrentUser(e){return this._delegate.updateCurrentUser(e)}verifyPasswordResetCode(e){return async function(e,t){var n=(await gy($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 Hw(e,t,n){let r=e;"function"!=typeof e&&({next:r,error:t,complete:n}=e);const i=r;return{next:e=>i(e&&$w.getOrCreate(e)),error:t,complete:n}}zw.Persistence=Pw;class Gw{constructor(){this.providerId="phone",this._delegate=new p_(Uw(Ap.auth()))}static credential(e,t){return p_.credential(e,t)}verifyPhoneNumber(e,t){return this._delegate.verifyPhoneNumber(e,t)}unwrap(){return this._delegate}}Gw.PHONE_SIGN_IN_METHOD=p_.PHONE_SIGN_IN_METHOD,Gw.PROVIDER_ID=p_.PROVIDER_ID;const Qw=xm;class Yw{constructor(e,t,n=Ap.app()){var r;Qw(null===(r=n.options)||void 0===r?void 0:r.apiKey,"invalid-api-key",{appName:n.name}),this._delegate=new u_(e,t,n.auth()),this.type=this._delegate.type}clear(){this._delegate.clear()}render(){return this._delegate.render()}verify(){return this._delegate.verify()}}(Tw=Ap).INTERNAL.registerComponent(new Kd("auth-compat",e=>{var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("auth");return new zw(t,n)},"PUBLIC").setServiceProps({ActionCodeInfo:{Operation:{EMAIL_SIGNIN:wm.EMAIL_SIGNIN,PASSWORD_RESET:wm.PASSWORD_RESET,RECOVER_EMAIL:wm.RECOVER_EMAIL,REVERT_SECOND_FACTOR_ADDITION:wm.REVERT_SECOND_FACTOR_ADDITION,VERIFY_AND_CHANGE_EMAIL:wm.VERIFY_AND_CHANGE_EMAIL,VERIFY_EMAIL:wm.VERIFY_EMAIL}},EmailAuthProvider:jv,FacebookAuthProvider:Wv,GithubAuthProvider:Kv,GoogleAuthProvider:$v,OAuthProvider:Bv,SAMLAuthProvider:Hv,PhoneAuthProvider:Gw,PhoneMultiFactorGenerator:sw,RecaptchaVerifier:Yw,TwitterAuthProvider:Gv,Auth:zw,AuthCredential:Nv,Error:gd}).setInstantiationMode("LAZY").setMultipleInstances(!1)),Tw.registerVersion("@firebase/auth-compat","0.2.5-canary.88d43ec00");const Jw="@firebase/database",Xw="0.12.5-canary.88d43ec00";let Zw="";function eb(e){Zw=e}class tb{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 nb{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 rb,ib,sb,ob,ab,cb,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 tb(t)}}catch(e){}return new nb};function lb(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 ub=yt("localStorage"),hb=yt("sessionStorage"),db=new ep("@firebase/database"),pb=function(){let e=1;return function(){return e++}}(),fb=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+=fb.apply(null,n):t+="object"==typeof n?_d(n):n,t+=" "}return t};let gb=null,mb=!0;function vb(t){return function(...e){Eb(t,...e)}}function yb(...e){var t="FIREBASE INTERNAL ERROR: "+fb(...e);db.error(t)}function _b(e,t){return e===t?0:e<t?-1:1}function wb(e,t){if(t&&e in t)return t[e];throw new Error("Missing required key ("+e+") in object: "+_d(t))}function bb(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+=bb(e[t[i]]);return n+="}",n}function Ib(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 Tb=function(e,t){Jh(!t||!0===e||!1===e,"Can't turn on custom loggers persistently."),!0===e?(db.logLevel=$h.VERBOSE,gb=db.log.bind(db),t&&hb.set("logging_enabled",!0)):"function"==typeof e?gb=e:(gb=null,hb.remove("logging_enabled"))},Eb=function(...e){var t;!0===mb&&(mb=!1,null===gb&&!0===hb.get("logging_enabled")&&Tb(!0)),gb&&(t=fb.apply(null,e),gb(t))},kb=function(...e){var t=`FIREBASE FATAL ERROR: ${fb(...e)}`;throw db.error(t),new Error(t)},Sb=function(...e){var t="FIREBASE WARNING: "+fb(...e);db.warn(t)},Cb=function(){"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&Sb("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},Ab=function(e){return"number"==typeof e&&(e!=e||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY)},Nb="[MIN_NAME]",Rb="[MAX_NAME]",Pb=function(e,t){if(e===t)return 0;if(e===Nb||t===Rb)return-1;if(t===Nb||e===Rb)return 1;var n=Ub(e),r=Ub(t);return null!==n?null!==r?n-r==0?e.length-t.length:n-r:-1:null===r&&e<t?-1:1};function xb(e,t){for(const n in e)e.hasOwnProperty(n)&&t(n,e[n])}function Db(e){Jh(!Ab(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 Ob(e,t){const n=setTimeout(e,t);return"object"==typeof n&&n.unref&&n.unref(),n}const Mb=new RegExp("^-?(0*)\\d{1,10}$"),Lb=-2147483648,Fb=2147483647,Ub=function(e){if(Mb.test(e)){var t=Number(e);if(t>=Lb&&t<=Fb)return t}return null},jb=function(e){try{e()}catch(t){setTimeout(()=>{var e=t.stack||"";throw Sb("Exception was thrown by user callback.",e),t},Math.floor(0))}};class qb{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(){Sb(`Provided AppCheck credentials for the app named "${this.appName_}" `+"are invalid. This usually indicates your app was not initialized correctly.")}}class Vb{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?(Eb("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/.',Sb(e)}}class Bb{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}Bb.OWNER="owner";const Wb=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,$b="websocket",Kb="long_polling";class zb{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=ub.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()&&ub.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 Hb(e,t,n){Jh("string"==typeof t,"typeof type must == string"),Jh("object"==typeof n,"typeof params must == object");let r;if(t===$b)r=(e.secure?"wss://":"ws://")+e.internalHost+"/.ws?";else{if(t!==Kb)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 xb(n,(e,t)=>{i.push(e+"="+t)}),r+i.join("&")}class Gb{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 Qb={},Yb={};function Jb(e){var t=e.toString();return Qb[t]||(Qb[t]=new Gb),Qb[t]}class Xb{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]&&jb(()=>{this.onMessage_(n[e])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}class Zb{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_=vb(e),this.stats_=Jb(t),this.urlFn=e=>(this.appCheckToken&&(e.ac=this.appCheckToken),Hb(t,Kb,e))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new Xb(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 eI((...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&&Wb.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(){Zb.forceAllow_=!0}static forceDisallow(){Zb.forceDisallow_=!0}static isAvailable(){return!!Zb.forceAllow_||!(Zb.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=Ib(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 eI{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=pb(),window["pLPCommand"+this.uniqueCallbackIdentifier]=t,window["pRTLPCB"+this.uniqueCallbackIdentifier]=n,this.myIFrame=eI.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){Eb("frame writing exception"),e.stack&&Eb(e.stack),Eb(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||Eb("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=()=>{Eb("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(t)}catch(e){}},Math.floor(1))}}let tI=null;"undefined"!=typeof MozWebSocket?tI=MozWebSocket:"undefined"!=typeof WebSocket&&(tI=WebSocket);class nI{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_=vb(this.connId),this.stats_=Jb(t),this.connURL=nI.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&&Wb.test(location.hostname)&&(i.r="f"),t&&(i.s=t),n&&(i.ls=n),r&&(i.ac=r),Hb(e,$b,i)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,ub.set("previous_websocket_failure",!0);try{hd()||(n={headers:{"X-Firebase-GMPID":this.applicationId||"","X-Firebase-AppCheck":this.appCheckToken||""}},this.mySock=new tI(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(){nI.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!==tI&&!nI.forceDisallow_}static previouslyFailed(){return ub.isInMemoryStorage||!0===ub.get("previous_websocket_failure")}markConnectionHealthy(){ub.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=Ib(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)}}}nI.responsesRequiredToBeHealthy=2,nI.healthyTimeout=3e4;class rI{constructor(e){this.initTransports_(e)}static get ALL_TRANSPORTS(){return[Zb,nI]}initTransports_(e){var t=nI&&nI.isAvailable();let n=t&&!nI.previouslyFailed();if(e.webSocketOnly&&(t||Sb("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),n=!0),n)this.transports_=[nI];else{const r=this.transports_=[];for(const i of rI.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 iI{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_=vb("c:"+this.id+":"),this.transportManager_=new rI(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_=Ob(()=>{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=wb("t",e),n=wb("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=wb("t",e),n=wb("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=wb("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?yb("Server Error: "+n):"o"===t?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):yb("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&&Sb("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),Ob(()=>{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):Ob(()=>{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()&&(ub.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 sI{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 oI{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 aI extends oI{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 aI}getInitialEvent(e){return Jh("online"===e,"Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}class cI{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 lI(){return new cI("")}function uI(e){return e.pieceNum_>=e.pieces_.length?null:e.pieces_[e.pieceNum_]}function hI(e){return e.pieces_.length-e.pieceNum_}function dI(e){let t=e.pieceNum_;return t<e.pieces_.length&&t++,new cI(e.pieces_,t)}function pI(e){return e.pieceNum_<e.pieces_.length?e.pieces_[e.pieces_.length-1]:null}function fI(e,t=0){return e.pieces_.slice(e.pieceNum_+t)}function gI(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 cI(t,0)}function mI(e,t){const n=[];for(let i=e.pieceNum_;i<e.pieces_.length;i++)n.push(e.pieces_[i]);if(t instanceof cI)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 cI(n,0)}function vI(e){return e.pieceNum_>=e.pieces_.length}function yI(e,t){var n=uI(e),r=uI(t);if(null===n)return t;if(n===r)return yI(dI(e),dI(t));throw new Error("INTERNAL ERROR: innerPath ("+t+") is not within outerPath ("+e+")")}function _I(e,t){var n=fI(e,0),r=fI(t,0);for(let s=0;s<n.length&&s<r.length;s++){var i=Pb(n[s],r[s]);if(0!==i)return i}return n.length===r.length?0:n.length<r.length?-1:1}function wI(e,t){if(hI(e)!==hI(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 bI(e,t){let n=e.pieceNum_,r=t.pieceNum_;if(hI(e)>hI(t))return!1;for(;n<e.pieces_.length;){if(e.pieces_[n]!==t.pieces_[r])return!1;++n,++r}return!0}class II{constructor(e,t){this.errorPrefix_=t,this.parts_=fI(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]);TI(this)}}function TI(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 "+EI(e))}function EI(e){return 0===e.parts_.length?"":"in property '"+e.parts_.join(".")+"'"}class kI extends oI{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 kI}getInitialEvent(e){return Jh("visible"===e,"Unknown event type: "+e),[this.visible_]}}class SI extends sI{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=SI.nextPersistentConnectionId_++,this.log_=vb("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");kI.getInstance().on("visible",this.onVisible_,this),-1===e.host.indexOf("fblocal")&&aI.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;SI.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(),Sb("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):yb("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+":"+SI.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?Eb("getToken() completed but was canceled"):(Eb("getToken() completed. Creating connection."),this.authToken_=c&&c.accessToken,this.appCheckToken_=l&&l.token,n=new iI(i,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,r,u,e=>{Sb(e+" ("+this.repoInfo_.toString()+")"),this.interrupt("server_kill")},s))}catch(e){this.log_("Failed to get token: "+e),t||(this.repoInfo_.nodeAdmin&&Sb(e),o())}}}interrupt(e){Eb("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){Eb("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=>bb(e)).join("$"):"default";const r=this.removeListen_(e,n);r&&r.onComplete&&r.onComplete("permission_denied")}removeListen_(e,t){var n=new cI(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){Eb("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){Eb("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."+Zw.replace(/\./g,"-")]=1,od()?e["framework.cordova"]=1:ld()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){var e=aI.getInstance().currentlyOnline();return Td(this.interruptReasons_)&&e}}SI.nextPersistentConnectionId_=0,SI.nextConnectionId_=0;class CI{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new CI(e,t)}}class AI{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){var n=new CI(Nb,e),r=new CI(Nb,t);return 0!==this.compare(n,r)}minPost(){return CI.MIN}}let NI;class RI extends AI{static get __EMPTY_NODE(){return NI}static set __EMPTY_NODE(e){NI=e}compare(e,t){return Pb(e.name,t.name)}isDefinedOn(e){throw Xh("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return CI.MIN}maxPost(){return new CI(Rb,NI)}makePost(e,t){return Jh("string"==typeof e,"KeyIndex indexValue must always be a string."),new CI(e,NI)}toString(){return".key"}}const PI=new RI;class xI{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 DI{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:DI.RED,this.left=null!=r?r:OI.EMPTY_NODE,this.right=null!=i?i:OI.EMPTY_NODE}copy(e,t,n,r,i){return new DI(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 OI.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 OI.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,DI.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){var e=this.copy(null,null,DI.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)}}DI.RED=!0,DI.BLACK=!1;class OI{constructor(e,t=OI.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new OI(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,DI.BLACK,null,null))}remove(e){return new OI(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,DI.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 xI(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new xI(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new xI(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new xI(this.root_,null,this.comparator_,!0,e)}}function MI(e,t){return Pb(e.name,t.name)}function LI(e,t){return Pb(e,t)}OI.EMPTY_NODE=new class{copy(e,t,n,r,i){return this}insert(e,t,n){return new DI(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 FI;function UI(e){return"number"==typeof e?"number:"+Db(e):"string:"+e}function jI(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===FI||e.isEmpty(),"priority of unexpected type."),Jh(e===FI||e.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")}let qI;class VI{constructor(e,t=VI.__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."),jI(this.priorityNode_)}static set __childrenNodeConstructor(e){qI=e}static get __childrenNodeConstructor(){return qI}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new VI(this.value_,e)}getImmediateChild(e){return".priority"===e?this.priorityNode_:VI.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return vI(e)?this:".priority"===uI(e)?this.priorityNode_:VI.__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:VI.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){var n=uI(e);return null===n?t:t.isEmpty()&&".priority"!==n?this:(Jh(".priority"!==n||1===hI(e),".priority must be the last token in a path"),this.updateImmediateChild(n,VI.__childrenNodeConstructor.EMPTY_NODE.updateChild(dI(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:"+UI(this.priorityNode_.val())+":");var t=typeof this.value_;e+=t+":",e+="number"==t?Db(this.value_):this.value_,this.lazyHash_=lb(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===VI.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof VI.__childrenNodeConstructor?-1:(Jh(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){var t=typeof e.value_,n=typeof this.value_,r=VI.VALUE_TYPE_ORDER.indexOf(t),i=VI.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_))}}VI.VALUE_TYPE_ORDER=["object","boolean","number","string"];let BI,WI;const $I=new class extends AI{compare(e,t){const n=e.node.getPriority();var r=t.node.getPriority(),r=n.compareTo(r);return 0===r?Pb(e.name,t.name):r}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return CI.MIN}maxPost(){return new CI(Rb,new VI("[PRIORITY-POST]",WI))}makePost(e,t){var n=BI(e);return new CI(t,new VI("[PRIORITY-POST]",n))}toString(){return".priority"}},KI=Math.log(2);class zI{constructor(e){var t;this.count=(t=e+1,parseInt(Math.log(t)/KI,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 HI(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 DI(i,r.node,DI.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 DI(i,r.node,DI.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 DI(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,DI.BLACK):(t(r,DI.BLACK),t(r,DI.RED))}return o}(new zI(c.length));return new OI(t||e,n)}let GI;const QI={};class YI{constructor(e,t){this.indexes_=e,this.indexSet_=t}static get Default(){return Jh((QI,$I),"ChildrenNode.ts has not been loaded"),GI=GI||new YI({".priority":QI},{".priority":$I}),GI}get(e){var t=Id(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof OI?t:null}hasIndex(e){return bd(this.indexSet_,e.toString())}addIndex(e,t){Jh(e!==PI,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const n=[];let r=!1;const i=t.getIterator(CI.Wrap);let s=i.getNext();for(;s;)r=r||e.isDefinedOn(s.node),n.push(s),s=i.getNext();let o;o=r?HI(n,e.getCompare()):QI;var a=e.toString();const c=Object.assign({},this.indexSet_);c[a]=e;const l=Object.assign({},this.indexes_);return l[a]=o,new YI(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===QI){if(n.isDefinedOn(o.node)){const i=[],s=a.getIterator(CI.Wrap);let e=s.getNext();for(;e;)e.name!==o.name&&i.push(e),e=s.getNext();return i.push(o),HI(i,n.getCompare())}return QI}{var r=a.get(o.name);let e=t;return r&&(e=e.remove(new CI(o.name,r))),e.insert(o,o.node)}});return new YI(e,this.indexSet_)}removeFromIndexes(n,r){var e=Ed(this.indexes_,e=>{if(e===QI)return e;var t=r.get(n.name);return t?e.remove(new CI(n.name,t)):e});return new YI(e,this.indexSet_)}}let JI;class XI{constructor(e,t,n){this.children_=e,this.priorityNode_=t,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&jI(this.priorityNode_),this.children_.isEmpty()&&Jh(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}static get EMPTY_NODE(){return JI=JI||new XI(new OI(LI),null,YI.Default)}isLeafNode(){return!1}getPriority(){return this.priorityNode_||JI}updatePriority(e){return this.children_.isEmpty()?this:new XI(this.children_,e,this.indexMap_)}getImmediateChild(e){if(".priority"===e)return this.getPriority();var t=this.children_.get(e);return null===t?JI:t}getChild(e){var t=uI(e);return null===t?this:this.getImmediateChild(t).getChild(dI(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 CI(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()?JI:this.priorityNode_;return new XI(e,i,t)}}updateChild(e,t){var n=uI(e);if(null===n)return t;Jh(".priority"!==uI(e)||1===hI(e),".priority must be the last token in a path");var r=this.getImmediateChild(n).updateChild(dI(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($I,(e,t)=>{r[e]=t.val(n),i++,o&&XI.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:"+UI(this.getPriority().val())+":"),this.forEachChild($I,(e,t)=>{var n=t.hash();""!==n&&(r+=":"+e+":"+n)}),this.lazyHash_=""===r?"":lb(r)}return this.lazyHash_}getPredecessorChildName(e,t,n){const r=this.resolveIndex_(n);if(r){var i=r.getPredecessorKey(new CI(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 CI(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 CI(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,CI.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,CI.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===eT?-1:0}withIndex(e){if(e===PI||this.indexMap_.hasIndex(e))return this;var t=this.indexMap_.addIndex(e,this.children_);return new XI(this.children_,this.priorityNode_,t)}isIndexed(e){return e===PI||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($I),i=n.getIterator($I);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===PI?null:this.indexMap_.get(e.toString())}}XI.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class ZI extends XI{constructor(){super(new OI(LI),XI.EMPTY_NODE,YI.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return XI.EMPTY_NODE}isEmpty(){return!1}}const eT=new ZI;Object.defineProperties(CI,{MIN:{value:new CI(Nb,XI.EMPTY_NODE)},MAX:{value:new CI(Rb,eT)}}),RI.__EMPTY_NODE=XI.EMPTY_NODE,VI.__childrenNodeConstructor=XI,rb=eT,FI=rb,ib=eT,WI=ib;const tT=!0;function nT(i,e=null){if(null===i)return XI.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 VI(t,nT(e))}if(i instanceof Array||!tT){let r=XI.EMPTY_NODE;return xb(i,(e,t)=>{if(bd(i,e)&&"."!==e.substring(0,1)){const n=nT(t);!n.isLeafNode()&&n.isEmpty()||(r=r.updateImmediateChild(e,n))}}),r.updatePriority(nT(e))}{const s=[];let r=!1;if(xb(i,(e,t)=>{if("."!==e.substring(0,1)){const n=nT(t);n.isEmpty()||(r=r||!n.getPriority().isEmpty(),s.push(new CI(e,n)))}}),0===s.length)return XI.EMPTY_NODE;var n=HI(s,MI,e=>e.name,LI);if(r){t=HI(s,$I.getCompare());return new XI(n,nT(e),new YI({".priority":t},{".priority":$I}))}return new XI(n,nT(e),YI.Default)}}BI=nT;class rT extends AI{constructor(e){super(),this.indexPath_=e,Jh(!vI(e)&&".priority"!==uI(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?Pb(e.name,t.name):r}makePost(e,t){var n=nT(e),n=XI.EMPTY_NODE.updateChild(this.indexPath_,n);return new CI(t,n)}maxPost(){var e=XI.EMPTY_NODE.updateChild(this.indexPath_,eT);return new CI(Rb,e)}toString(){return fI(this.indexPath_,0).join("/")}}function iT(e){if(e===""+Fb)return cT;var t=Ub(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<uT)return n.push(cT),n.join("");let r=n.length-1;for(;0<=r&&n[r]===lT;)r--;return-1===r?Rb:(t=n[r],t=aT.charAt(aT.indexOf(t)+1),n[r]=t,n.slice(0,r+1).join(""))}function sT(e){if(e===""+Lb)return Nb;var t=Ub(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]===cT?1===n.length?""+Fb:(delete n[n.length-1],n.join("")):(n[n.length-1]=aT.charAt(aT.indexOf(n[n.length-1])-1),n.join("")+lT.repeat(uT-n.length))}const oT=new class extends AI{compare(e,t){var n=e.node.compareTo(t.node);return 0===n?Pb(e.name,t.name):n}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return CI.MIN}maxPost(){return CI.MAX}makePost(e,t){var n=nT(e);return new CI(t,n)}toString(){return".value"}},aT="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",cT="-",lT="z",uT=786,hT=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]=aT.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+=aT.charAt(o[n]);return Jh(20===i.length,"nextPushId: Length should be 20."),i}}();function dT(e){return{type:"value",snapshotNode:e}}function pT(e,t){return{type:"child_added",snapshotNode:t,childName:e}}function fT(e,t){return{type:"child_removed",snapshotNode:t,childName:e}}function gT(e,t,n){return{type:"child_changed",snapshotNode:t,childName:e,oldSnap:n}}class mT{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(fT(t,o)):Jh(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):o.isEmpty()?s.trackChildChange(pT(t,n)):s.trackChildChange(gT(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($I,(e,t)=>{n.hasChild(e)||i.trackChildChange(fT(e,t))}),n.isLeafNode()||n.forEachChild($I,(e,t)=>{if(r.hasChild(e)){const n=r.getImmediateChild(e);n.equals(t)||i.trackChildChange(gT(e,t,n))}else i.trackChildChange(pT(e,t))})),n.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?XI.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}class vT{constructor(e){this.indexedFilter_=new mT(e.getIndex()),this.index_=e.getIndex(),this.startPost_=vT.getStartPost_(e),this.endPost_=vT.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 CI(t,n))||(n=XI.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,n,r,i,s)}updateFullNode(e,t,n){let r=(t=t.isLeafNode()?XI.EMPTY_NODE:t).withIndex(this.index_);r=r.updatePriority(XI.EMPTY_NODE);const i=this;return t.forEachChild($I,(e,t)=>{i.matches(new CI(e,t))||(r=r.updateImmediateChild(e,XI.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 yT{constructor(e){this.rangedFilter_=new vT(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 CI(t,n))||(n=XI.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=XI.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<o.numChildren()&&o.isIndexed(this.index_)){a=XI.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(XI.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,XI.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 CI(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(gT(t,n,u)),o.updateImmediateChild(t,n);{null!=i&&i.trackChildChange(fT(t,u));const p=o.updateImmediateChild(t,XI.EMPTY_NODE);return null!=e&&this.rangedFilter_.matches(e)?(null!=i&&i.trackChildChange(pT(e.name,e.node)),p.updateImmediateChild(e.name,e.node)):p}}return!n.isEmpty()&&l&&0<=s(c,a)?(null!=i&&(i.trackChildChange(fT(c.name,c.node)),i.trackChildChange(pT(t,n))),o.updateImmediateChild(t,n).updateImmediateChild(c.name,XI.EMPTY_NODE)):e}}class _T{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_=$I}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_:Nb}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_:Rb}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_===$I}copy(){const e=new _T;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 wT(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 bT(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 IT(e,t){const n=e.copy();return n.index_=t,n}function TT(e){const t={};if(e.isDefault())return t;let n;return n=e.index_===$I?"$priority":e.index_===oT?"$value":e.index_===PI?"$key":(Jh(e.index_ instanceof rT,"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 ET(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_!==$I&&(n.i=t.index_.toString()),n}class kT extends sI{constructor(e,t,n,r){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=n,this.appCheckTokenProvider_=r,this.log_=vb("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=kT.getListenId_(e,r),a={};this.listens_[o]=a;var n=TT(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=kT.getListenId_(e,t);delete this.listens_[n]}get(e){var t=TT(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){Sb("Failed to parse JSON response for "+n+": "+r.responseText)}o(null,e)}else 401!==r.status&&404!==r.status&&Sb("Got unsuccessful REST response for "+n+" Status: "+r.status),o(r.status);o=null}},r.open("GET",n,!0),r.send()})}}class ST{constructor(){this.rootNode_=XI.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}function CT(){return{value:null,children:new Map}}function AT(e,t,n){var r;vI(t)?(e.value=n,e.children.clear()):null!==e.value?e.value=e.value.updateChild(t,n):(r=uI(t),e.children.has(r)||e.children.set(r,CT()),AT(e.children.get(r),t=dI(t),n))}function NT(e,n,r){var i;null!==e.value?r(n,e.value):(i=(e,t)=>{NT(t,new cI(n.toString()+"/"+e),r)},e.children.forEach((e,t)=>{i(t,e)}))}class RT{constructor(e){this.collection_=e,this.last_=null}get(){var e=this.collection_.get();const n=Object.assign({},e);return this.last_&&xb(this.last_,(e,t)=>{n[e]=n[e]-t}),this.last_=e,n}}class PT{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new RT(e);var n=1e4+2e4*Math.random();Ob(this.reportStats_.bind(this),Math.floor(n))}reportStats_(){var e=this.statsListener_.get();const n={};let r=!1;xb(e,(e,t)=>{0<t&&bd(this.statsToReport_,e)&&(n[e]=t,r=!0)}),r&&this.server_.reportStats(n),Ob(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))}}function xT(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function DT(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function OT(e){return{fromUser:!1,fromServer:!0,queryId:e,tagged:!0}}(z=sb=sb||{})[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 MT{constructor(e,t,n){this.path=e,this.affectedTree=t,this.revert=n,this.type=sb.ACK_USER_WRITE,this.source=xT()}operationForChild(e){if(vI(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 cI(e));return new MT(lI(),t,this.revert)}return Jh(uI(this.path)===e,"operationForChild called for unrelated child."),new MT(dI(this.path),this.affectedTree,this.revert)}}class LT{constructor(e,t){this.source=e,this.path=t,this.type=sb.LISTEN_COMPLETE}operationForChild(e){return vI(this.path)?new LT(this.source,lI()):new LT(this.source,dI(this.path))}}class FT{constructor(e,t,n){this.source=e,this.path=t,this.snap=n,this.type=sb.OVERWRITE}operationForChild(e){return vI(this.path)?new FT(this.source,lI(),this.snap.getImmediateChild(e)):new FT(this.source,dI(this.path),this.snap)}}class UT{constructor(e,t,n){this.source=e,this.path=t,this.children=n,this.type=sb.MERGE}operationForChild(e){if(vI(this.path)){const t=this.children.subtree(new cI(e));return t.isEmpty()?null:t.value?new FT(this.source,lI(),t.value):new UT(this.source,lI(),t)}return Jh(uI(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new UT(this.source,dI(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}class jT{constructor(e,t,n){this.node_=e,this.fullyInitialized_=t,this.filtered_=n}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(vI(e))return this.isFullyInitialized()&&!this.filtered_;var t=uI(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}class qT{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function VT(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}))}),BT(n,i,"child_removed",e,r,t),BT(n,i,"child_added",e,r,t),BT(n,i,"child_moved",s,r,t),BT(n,i,"child_changed",e,r,t),BT(n,i,"value",e,r,t),i}function BT(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 CI(t.childName,t.snapshotNode),i=new CI(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 WT(e,t){return{eventCache:e,serverCache:t}}function $T(e,t,n,r){return WT(new jT(t,n,r),e.serverCache)}function KT(e,t,n,r){return WT(e.eventCache,new jT(t,n,r))}function zT(e){return e.eventCache.isFullyInitialized()?e.eventCache.getNode():null}function HT(e){return e.serverCache.isFullyInitialized()?e.serverCache.getNode():null}let GT;class QT{constructor(e,t=(GT=GT||new OI(_b),GT)){this.value=e,this.children=t}static fromObject(e){let n=new QT(null);return xb(e,(e,t)=>{n=n.set(new cI(e),t)}),n}isEmpty(){return null===this.value&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(null!=this.value&&t(this.value))return{path:lI(),value:this.value};if(vI(e))return null;{var n=uI(e);const i=this.children.get(n);if(null===i)return null;var r=i.findRootMostMatchingPathAndValue(dI(e),t);return null==r?null:{path:mI(new cI(n),r.path),value:r.value}}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(vI(e))return this;{var t=uI(e);const n=this.children.get(t);return null!==n?n.subtree(dI(e)):new QT(null)}}set(e,t){if(vI(e))return new QT(t,this.children);{var n=uI(e);const i=this.children.get(n)||new QT(null);var r=i.set(dI(e),t),r=this.children.insert(n,r);return new QT(this.value,r)}}remove(t){if(vI(t))return this.children.isEmpty()?new QT(null):new QT(null,this.children);{var n=uI(t);const r=this.children.get(n);if(r){const i=r.remove(dI(t));let e;return e=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),null===this.value&&e.isEmpty()?new QT(null):new QT(this.value,e)}return this}}get(e){if(vI(e))return this.value;{var t=uI(e);const n=this.children.get(t);return n?n.get(dI(e)):null}}setTree(t,n){if(vI(t))return n;{var r=uI(t);const i=this.children.get(r)||new QT(null),s=i.setTree(dI(t),n);let e;return e=s.isEmpty()?this.children.remove(r):this.children.insert(r,s),new QT(this.value,e)}}fold(e){return this.fold_(lI(),e)}fold_(n,r){const i={};return this.children.inorderTraversal((e,t)=>{i[e]=t.fold_(mI(n,e),r)}),r(n,this.value,i)}findOnPath(e,t){return this.findOnPath_(e,lI(),t)}findOnPath_(e,t,n){var r=!!this.value&&n(t,this.value);if(r)return r;if(vI(e))return null;{r=uI(e);const i=this.children.get(r);return i?i.findOnPath_(dI(e),mI(t,r),n):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,lI(),t)}foreachOnPath_(e,t,n){if(vI(e))return this;{this.value&&n(t,this.value);var r=uI(e);const i=this.children.get(r);return i?i.foreachOnPath_(dI(e),mI(t,r),n):new QT(null)}}foreach(e){this.foreach_(lI(),e)}foreach_(n,r){this.children.inorderTraversal((e,t)=>{t.foreach_(mI(n,e),r)}),this.value&&r(n,this.value)}foreachChild(n){this.children.inorderTraversal((e,t)=>{t.value&&n(e,t.value)})}}class YT{constructor(e){this.writeTree_=e}static empty(){return new YT(new QT(null))}}function JT(t,n,r){if(vI(n))return new YT(new QT(r));var i=t.writeTree_.findRootMostValueAndPath(n);if(null!=i){var s=i.path;let e=i.value;i=yI(s,n);return e=e.updateChild(i,r),new YT(t.writeTree_.set(s,e))}s=new QT(r),s=t.writeTree_.setTree(n,s);return new YT(s)}function XT(e,n,t){let r=e;return xb(t,(e,t)=>{r=JT(r,mI(n,e),t)}),r}function ZT(e,t){if(vI(t))return YT.empty();var n=e.writeTree_.setTree(t,new QT(null));return new YT(n)}function e0(e,t){return null!=t0(e,t)}function t0(e,t){var n=e.writeTree_.findRootMostValueAndPath(t);return null!=n?e.writeTree_.get(n.path).getChild(yI(n.path,t)):null}function n0(e){const n=[],t=e.writeTree_.value;return null!=t?t.isLeafNode()||t.forEachChild($I,(e,t)=>{n.push(new CI(e,t))}):e.writeTree_.children.inorderTraversal((e,t)=>{null!=t.value&&n.push(new CI(e,t.value))}),n}function r0(e,t){if(vI(t))return e;var n=t0(e,t);return null!=n?new YT(new QT(n)):new YT(e.writeTree_.subtree(t))}function i0(e){return e.writeTree_.isEmpty()}function s0(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(mI(i,e),t,s)}),s=!s.getChild(i).isEmpty()&&null!==n?s.updateChild(mI(i,".priority"),n):s}}}(lI(),e.writeTree_,t)}function o0(e,t){return y0(t,e)}function a0(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 bI(e.path,t);for(const n in e.children)if(e.children.hasOwnProperty(n)&&bI(mI(e.path,n),t))return!0;return!1}}(c,i.path)?s=!1:bI(i.path,c.path)&&(o=!0)),a--}return!!s&&(o?((e=t).visibleWrites=l0(e.allWrites,c0,lI()),0<e.allWrites.length?e.lastWriteId=e.allWrites[e.allWrites.length-1].writeId:e.lastWriteId=-1):i.snap?t.visibleWrites=ZT(t.visibleWrites,i.path):xb(i.children,e=>{t.visibleWrites=ZT(t.visibleWrites,mI(i.path,e))}),!0)}function c0(e){return e.visible}function l0(e,t,n){let r=YT.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)bI(n,i)?(e=yI(n,i),r=JT(r,e,o.snap)):bI(i,n)&&(e=yI(i,n),r=JT(r,lI(),o.snap.getChild(e)));else{if(!o.children)throw Xh("WriteRecord should have .snap or .children");if(bI(n,i))e=yI(n,i),r=XT(r,e,o.children);else if(bI(i,n))if(e=yI(i,n),vI(e))r=XT(r,lI(),o.children);else{const a=Id(o.children,uI(e));a&&(i=a.getChild(dI(e)),r=JT(r,lI(),i))}}}}return r}function u0(e,t,n,r,i){if(r||i){var s=r0(e.visibleWrites,t);if(!i&&i0(s))return n;if(i||null!=n||e0(s,lI()))return s0(l0(e.allWrites,function(e){return(e.visible||i)&&(!r||!~r.indexOf(e.writeId))&&(bI(e.path,t)||bI(t,e.path))},t),n||XI.EMPTY_NODE);return null}s=t0(e.visibleWrites,t);if(null!=s)return s;s=r0(e.visibleWrites,t);return i0(s)?n:null!=n||e0(s,lI())?s0(s,n||XI.EMPTY_NODE):null}function h0(e,t,n,r){return u0(e.writeTree,e.treePath,t,n,r)}function d0(e,t){return function(e,t,n){let r=XI.EMPTY_NODE;const i=t0(e.visibleWrites,t);if(i)return i.isLeafNode()||i.forEachChild($I,(e,t)=>{r=r.updateImmediateChild(e,t)}),r;if(n){const s=r0(e.visibleWrites,t);return n.forEachChild($I,(e,t)=>{var n=s0(r0(s,new cI(e)),t);r=r.updateImmediateChild(e,n)}),n0(s).forEach(e=>{r=r.updateImmediateChild(e.name,e.node)}),r}return n0(r0(e.visibleWrites,t)).forEach(e=>{r=r.updateImmediateChild(e.name,e.node)}),r}(e.writeTree,e.treePath,t)}function p0(e,t,n,r){return function(e,t,n,r,i){Jh(r||i,"Either existingEventSnap or existingServerSnap must exist");var s=mI(t,n);return e0(e.visibleWrites,s)?null:i0(s=r0(e.visibleWrites,s))?i.getChild(n):s0(s,i.getChild(n))}(e.writeTree,e.treePath,t,n,r)}function f0(e,t){return n=e.writeTree,t=mI(e.treePath,t),t0(n.visibleWrites,t);var n}function g0(e,t,n,r,i,s){return function(e,t,n,r,i,s,o){let a;var c=r0(e.visibleWrites,t),l=t0(c,lI());if(null!=l)a=l;else{if(null==n)return[];a=s0(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 m0(e,t,n){return r=e.writeTree,e=e.treePath,n=n,i=mI(e,t=t),null!=(s=t0(r.visibleWrites,i))?s:n.isCompleteForChild(t)?s0(r0(r.visibleWrites,i),n.getNode().getImmediateChild(t)):null;var r,i,s}function v0(e,t){return y0(mI(e.treePath,t),e.writeTree)}function y0(e,t){return{treePath:e,writeTree:t}}class _0{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,gT(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,fT(n,r.oldSnap));else if("child_changed"===t&&"child_added"===i)this.changeMap.set(n,pT(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,gT(n,e.snapshotNode,r.oldSnap))}}else this.changeMap.set(n,e)}getChanges(){return Array.from(this.changeMap.values())}}const w0=new class{getCompleteChild(e){return null}getChildAfterChild(e,t,n){return null}};class b0{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 jT(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return m0(this.writes_,e,n)}getChildAfterChild(e,t,n){var r=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:HT(this.viewCache_),r=g0(this.writes_,r,t,1,n,e);return 0===r.length?null:r[0]}}function I0(e,t,n,r,i){const s=new _0;let o,a;if(n.type===sb.OVERWRITE){var c=n;o=c.source.fromUser?k0(e,t,c.path,c.snap,r,i,s):(Jh(c.source.fromServer,"Unknown source."),a=c.source.tagged||t.serverCache.isFiltered()&&!vI(c.path),E0(e,t,c.path,c.snap,r,i,a,s))}else if(n.type===sb.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=mI(s,e);S0(i,uI(n))&&(l=k0(r,l,n,t,o,a,c))}),e.foreach((e,t)=>{var n=mI(s,e);S0(i,uI(n))||(l=k0(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(),A0(e,t,c.path,c.children,r,i,a,s))}else if(n.type===sb.ACK_USER_WRITE){var l=n;o=l.revert?function(n,r,i,s,e,o){let a;{if(null!=f0(s,i))return r;{var c=new b0(s,r,e);const u=r.eventCache.getNode();let t;if(vI(i)||".priority"===uI(i)){let e;e=r.serverCache.isFullyInitialized()?h0(s,HT(r)):(l=r.serverCache.getNode(),Jh(l instanceof XI,"serverChildren would be complete if leaf node"),d0(s,l)),e=e,t=n.filter.updateFullNode(u,e,o)}else{var l=uI(i);let e=m0(s,l,r.serverCache);null==e&&r.serverCache.isCompleteForChild(l)&&(e=u.getImmediateChild(l)),t=null!=e?n.filter.updateChild(u,l,e,dI(i),c,o):r.eventCache.getNode().hasChild(l)?n.filter.updateChild(u,l,XI.EMPTY_NODE,dI(i),c,o):u,t.isEmpty()&&r.serverCache.isFullyInitialized()&&(a=h0(s,HT(r)),a.isLeafNode()&&(t=n.filter.updateFullNode(t,a,o)))}return a=r.serverCache.isFullyInitialized()||null!=f0(s,lI()),$T(r,t,a,n.filter.filtersNodes())}}}(e,t,l.path,r,i,s):function(e,t,i,n,s,o,a){if(null!=f0(s,i))return t;const c=t.serverCache.isFiltered(),l=t.serverCache;{if(null!=n.value){if(vI(i)&&l.isFullyInitialized()||l.isCompleteForPath(i))return E0(e,t,i,l.getNode().getChild(i),s,o,c,a);if(vI(i)){let n=new QT(null);return l.getNode().forEachChild(PI,(e,t)=>{n=n.set(new cI(e),t)}),A0(e,t,i,n,s,o,c,a)}return t}{let r=new QT(null);return n.foreach((e,t)=>{var n=mI(i,e);l.isCompleteForPath(n)&&(r=r.set(e,l.getNode().getChild(n)))}),A0(e,t,i,r,s,o,c,a)}}}(e,t,l.path,l.affectedTree,r,i,s)}else{if(n.type!==sb.LISTEN_COMPLETE)throw Xh("Unknown operation type: "+n.type);o=function(e,t,n,r,i){const s=t.serverCache,o=KT(t,s.getNode(),s.isFullyInitialized()||vI(n),s.isFiltered());return T0(e,o,n,r,w0,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=zT(e);(0<n.length||!e.eventCache.isFullyInitialized()||i&&!r.getNode().equals(s)||!r.getNode().getPriority().equals(s.getPriority()))&&n.push(dT(zT(t)))}}(t,o,l),{viewCache:o,changes:l}}function T0(r,i,s,o,a,c){const l=i.eventCache;if(null!=f0(o,s))return i;{let t,n;if(vI(s)){var e;Jh(i.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),t=i.serverCache.isFiltered()?(e=d0(o,(e=HT(i))instanceof XI?e:XI.EMPTY_NODE),r.filter.updateFullNode(i.eventCache.getNode(),e,c)):(u=h0(o,HT(i)),r.filter.updateFullNode(i.eventCache.getNode(),u,c))}else{var u=uI(s);if(".priority"===u){Jh(1===hI(s),"Can't have a priority with additional path components");var h=l.getNode();n=i.serverCache.getNode();var d=p0(o,s,h,n);t=null!=d?r.filter.updatePriority(h,d):l.getNode()}else{h=dI(s);let e;e=l.isCompleteForChild(u)?(n=i.serverCache.getNode(),null!=(d=p0(o,s,l.getNode(),n))?l.getNode().getImmediateChild(u).updateChild(h,d):l.getNode().getImmediateChild(u)):m0(o,u,i.serverCache),t=null!=e?r.filter.updateChild(l.getNode(),u,e,h,a,c):l.getNode()}}return $T(i,t,l.isFullyInitialized()||vI(s),r.filter.filtersNodes())}}function E0(e,t,n,r,i,s,o,a){const c=t.serverCache;let l;const u=o?e.filter:e.filter.getIndexedFilter();if(vI(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=uI(n);if(!c.isCompleteForPath(n)&&1<hI(n))return t;var p=dI(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,w0,null)}p=KT(t,l,c.isFullyInitialized()||vI(n),u.filtersNodes());return T0(e,p,n,i,new b0(i,p,s),a)}function k0(t,n,r,i,e,s,o){const a=n.eventCache;let c,l;const u=new b0(e,n,s);if(vI(r))l=t.filter.updateFullNode(n.eventCache.getNode(),i,o),c=$T(n,l,!0,t.filter.filtersNodes());else{var h=uI(r);if(".priority"===h)l=t.filter.updatePriority(n.eventCache.getNode(),i),c=$T(n,l,a.isFullyInitialized(),a.isFiltered());else{var d=dI(r);const p=a.getNode().getImmediateChild(h);let e;if(vI(d))e=i;else{const f=u.getCompleteChild(h);e=null!=f?".priority"===pI(d)&&f.getChild(gI(d)).isEmpty()?f:f.updateChild(d,i):XI.EMPTY_NODE}c=p.equals(e)?n:$T(n,t.filter.updateChild(a.getNode(),h,e,d,u,o),a.isFullyInitialized(),t.filter.filtersNodes())}}return c}function S0(e,t){return e.eventCache.isCompleteForChild(t)}function C0(e,n,t){return t.foreach((e,t)=>{n=n.updateChild(e,t)}),n}function A0(r,i,e,t,s,o,a,c){if(i.serverCache.getNode().isEmpty()&&!i.serverCache.isFullyInitialized())return i;let l=i,n;n=vI(e)?t:new QT(null).setTree(e,t);const u=i.serverCache.getNode();return n.children.inorderTraversal((e,t)=>{var n;u.hasChild(e)&&(n=C0(0,i.serverCache.getNode().getImmediateChild(e),t),l=E0(r,l,new cI(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=C0(0,i.serverCache.getNode().getImmediateChild(e),t),l=E0(r,l,new cI(e),n,s,o,a,c))}),l}class N0{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const n=this.query_._queryParams,r=new mT(n.getIndex()),i=(e=n).loadsAllData()?new mT(e.getIndex()):new(e.hasLimit()?yT:vT)(e);this.processor_={filter:i};const s=t.serverCache,o=t.eventCache;var a=r.updateFullNode(XI.EMPTY_NODE,s.getNode(),null),c=i.updateFullNode(XI.EMPTY_NODE,o.getNode(),null),a=new jT(a,s.isFullyInitialized(),r.filtersNodes()),c=new jT(c,o.isFullyInitialized(),i.filtersNodes());this.viewCache_=WT(c,a),this.eventGenerator_=new qT(this.query_)}get query(){return this.query_}}function R0(e){return 0===e.eventRegistrations_.length}function P0(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 x0(e,t,n,r){t.type===sb.MERGE&&null!==t.source.queryId&&(Jh(HT(e.viewCache_),"We should always have a full cache before handling merges"),Jh(zT(e.viewCache_),"Missing event cache, even though we have a server cache"));const i=e.viewCache_,s=I0(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,D0(e,s.changes,s.viewCache.eventCache.getNode(),null)}function D0(e,t,n,r){var i=r?[r]:e.eventRegistrations_;return VT(e.eventGenerator_,t,n,i)}let O0;class M0{constructor(){this.views=new Map}}function L0(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."),x0(e,n,r,i)}{let e=[];for(const s of t.views.values())e=e.concat(x0(s,n,r,i));return e}}function F0(e,n,r,i,s){var o=n._queryIdentifier,o=e.views.get(o);if(o)return o;{let e=h0(r,s?i:null),t=!1;t=!!e||(e=i instanceof XI?d0(r,i):XI.EMPTY_NODE,!1);o=WT(new jT(e,t,!1),new jT(i,s,!1));return new N0(n,o)}}function U0(e,t,n,r,i,s){var o=F0(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($I,(e,t)=>{r.push(pT(e,t))})}return n.isFullyInitialized()&&r.push(dT(n.getNode())),D0(e,r,n.getNode(),t)}(o,n)}function j0(e,t,n,r){var i=t._queryIdentifier;const s=[];let o=[];var a=$0(e);if("default"===i)for(var[c,l]of e.views.entries())o=o.concat(P0(l,n,r)),R0(l)&&(e.views.delete(c),l.query._queryParams.loadsAllData()||s.push(l.query));else{const u=e.views.get(i);u&&(o=o.concat(P0(u,n,r)),R0(u)&&(e.views.delete(i),u.query._queryParams.loadsAllData()||s.push(u.query)))}return a&&!$0(e)&&s.push((Jh(O0,"Reference.ts has not been loaded"),new O0(t._repo,t._path))),{removed:s,events:o}}function q0(e){const t=[];for(const n of e.views.values())n.query._queryParams.loadsAllData()||t.push(n);return t}function V0(e,t){let n=null;for(const r of e.views.values())n=n||function(e,t){const n=HT(e.viewCache_);return n&&(e.query._queryParams.loadsAllData()||!vI(t)&&!n.getImmediateChild(uI(t)).isEmpty())?n.getChild(t):null}(r,t);return n}function B0(e,t){const n=t._queryParams;if(n.loadsAllData())return K0(e);var r=t._queryIdentifier;return e.views.get(r)}function W0(e,t){return null!=B0(e,t)}function $0(e){return null!=K0(e)}function K0(e){for(const t of e.views.values())if(t.query._queryParams.loadsAllData())return t;return null}let z0;let H0=1;class G0{constructor(e){this.listenProvider_=e,this.syncPointTree_=new QT(null),this.pendingWriteTree_={visibleWrites:YT.empty(),allWrites:[],lastWriteId:-1},this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function Q0(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=JT(s.visibleWrites,o,a)),s.lastWriteId=c,i?rE(e,new FT(xT(),t,n)):[]}function Y0(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=XT(i.visibleWrites,s,o),i.lastWriteId=r;var a=QT.fromObject(n);return rE(e,new UT(xT(),t,a))}function J0(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(a0(e.pendingWriteTree_,t)){let t=new QT(null);return null!=r.snap?t=t.set(lI(),!0):xb(r.children,e=>{t=t.set(new cI(e),!0)}),rE(e,new MT(r.path,t,n))}return[]}function X0(e,t,n){return rE(e,new FT(DT(),t,n))}function Z0(n,e,t,r){var i=e._path,s=n.syncPointTree_.get(i);let o=[];if(s&&("default"===e._queryIdentifier||W0(s,e))){var a=j0(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)=>$0(t));if(s&&!a){const d=n.syncPointTree_.subtree(i);if(!d.isEmpty()){var c=d.fold((e,t,r)=>{if(t&&$0(t))return[K0(t)];{let n=[];return t&&(n=q0(t)),xb(r,(e,t)=>{n=n.concat(t)}),n}});for(let e=0;e<c.length;++e){var l=c[e],u=l.query,l=sE(n,l);n.listenProvider_.startListening(hE(u),oE(n,u),l.hashFn,l.onComplete)}}}!a&&0<h.length&&!r&&(s?n.listenProvider_.stopListening(hE(e),null):h.forEach(e=>{var t=n.queryToTagMap.get(aE(e));n.listenProvider_.stopListening(hE(e),t)})),function(e,t){for(let i=0;i<t.length;++i){const s=t[i];var n,r;s._queryParams.loadsAllData()||(n=aE(s),r=e.queryToTagMap.get(n),e.queryToTagMap.delete(n),e.tagToQueryMap.delete(r))}}(n,h)}return o}function eE(e,t,n){const r=t._path;let i=null,s=!1;e.syncPointTree_.foreachOnPath(r,(e,t)=>{var n=yI(e,r);i=i||V0(t,n),s=s||$0(t)});let o=e.syncPointTree_.get(r);o?(s=s||$0(o),i=i||V0(o,lI())):(o=new M0,e.syncPointTree_=e.syncPointTree_.set(r,o));let a;if(null!=i)a=!0;else{a=!1,i=XI.EMPTY_NODE;const d=e.syncPointTree_.subtree(r);d.foreachChild((e,t)=>{var n=V0(t,lI());n&&(i=i.updateImmediateChild(e,n))})}var c,l=W0(o,t);l||t._queryParams.loadsAllData()||(u=aE(t),Jh(!e.queryToTagMap.has(u),"View does not exist, but we have a tag"),c=H0++,e.queryToTagMap.set(u,c),e.tagToQueryMap.set(c,u));var u=o0(e.pendingWriteTree_,r);let h=U0(o,t,n,u,i,a);return l||s||(l=B0(o,t),h=h.concat(function(t,e,n){const r=e._path,i=oE(t,e),s=sE(t,n),o=t.listenProvider_.startListening(hE(e),i,s.hashFn,s.onComplete),a=t.syncPointTree_.subtree(r);if(i)Jh(!$0(a.value),"If we're adding a query, it shouldn't be shadowed");else{var c=a.fold((e,t,r)=>{if(!vI(e)&&t&&$0(t))return[K0(t).query];{let n=[];return t&&(n=n.concat(q0(t).map(e=>e.query))),xb(r,(e,t)=>{n=n.concat(t)}),n}});for(let e=0;e<c.length;++e){var l=c[e];t.listenProvider_.stopListening(hE(l),oE(t,l))}}return o}(e,t,l))),h}function tE(e,r,t){var n=e.pendingWriteTree_,i=e.syncPointTree_.findOnPath(r,(e,t)=>{var n=V0(t,yI(e,r));if(n)return n});return u0(n,r,i,t,!0)}function nE(e,t){const r=t._path;let i=null;e.syncPointTree_.foreachOnPath(r,(e,t)=>{var n=yI(e,r);i=i||V0(t,n)});let n=e.syncPointTree_.get(r);n?i=i||V0(n,lI()):(n=new M0,e.syncPointTree_=e.syncPointTree_.set(r,n));var s=null!=i;const o=s?new jT(i,!0,!1):null;var a=o0(e.pendingWriteTree_,t._path);return zT(F0(n,t,a,s?o.getNode():XI.EMPTY_NODE,s).viewCache_)}function rE(e,t){return function t(n,r,i,s){{if(vI(n.path))return iE(n,r,i,s);{const o=r.get(lI());null==i&&null!=o&&(i=V0(o,lI()));let e=[];const a=uI(n.path),c=n.operationForChild(a),l=r.children.get(a);if(l&&c){const u=i?i.getImmediateChild(a):null,h=v0(s,a);e=e.concat(t(c,l,u,h))}return o&&(e=e.concat(L0(o,n,s,i))),e}}}(t,e.syncPointTree_,null,o0(e.pendingWriteTree_,lI()))}function iE(s,e,o,a){var t=e.get(lI());null==o&&null!=t&&(o=V0(t,lI()));let c=[];return e.children.inorderTraversal((e,t)=>{var n=o?o.getImmediateChild(e):null,r=v0(a,e),i=s.operationForChild(e);i&&(c=c.concat(iE(i,t,n,r)))}),t&&(c=c.concat(L0(t,s,a,o))),c}function sE(i,t){const s=t.query,o=oE(i,s);return{hashFn:()=>{const e=t.viewCache_.serverCache.getNode()||XI.EMPTY_NODE;return e.hash()},onComplete:e=>{if("ok"===e)return o?function(e,t,n){if(s=cE(e,n)){var r=lE(s),i=r.path,s=r.queryId,r=yI(i,t);return uE(e,i,new LT(OT(s),r))}return[]}(i,s._path,o):(t=i,n=s._path,rE(t,new LT(DT(),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 Z0(i,s,null,r)}}}function oE(e,t){var n=aE(t);return e.queryToTagMap.get(n)}function aE(e){return e._path.toString()+"$"+e._queryIdentifier}function cE(e,t){return e.tagToQueryMap.get(t)}function lE(e){var t=e.indexOf("$");return Jh(-1!==t&&t<e.length-1,"Bad queryKey."),{queryId:e.substr(t+1),path:new cI(e.substr(0,t))}}function uE(e,t,n){var r=e.syncPointTree_.get(t);return Jh(r,"Missing sync point for query tag that we're tracking"),L0(r,n,o0(e.pendingWriteTree_,t),null)}function hE(e){return e._queryParams.loadsAllData()&&!e._queryParams.isDefault()?(Jh(z0,"Reference.ts has not been loaded"),new z0(e._repo,e._path)):e}class dE{constructor(e){this.node_=e}getImmediateChild(e){var t=this.node_.getImmediateChild(e);return new dE(t)}node(){return this.node_}}class pE{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){var t=mI(this.path_,e);return new pE(this.syncTree_,t)}node(){return tE(this.syncTree_,this.path_)}}function fE(e){return(e=e||{}).timestamp=e.timestamp||(new Date).getTime(),e}function gE(e,t,n){return e&&"object"==typeof e?(Jh(".sv"in e,"Unexpected leaf node or priority contents"),"string"==typeof e[".sv"]?mE(e[".sv"],t,n):"object"==typeof e[".sv"]?vE(e[".sv"],t):void Jh(!1,"Unexpected server value: "+JSON.stringify(e,null,2))):e}const mE=function(e,t,n){if("timestamp"===e)return n.timestamp;Jh(!1,"Unexpected server value: "+e)},vE=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},yE=function(e,t,n,r){return wE(t,new pE(n,e),r)},_E=function(e,t,n){return wE(e,new dE(t),n)};function wE(e,r,i){var t=e.getPriority().val(),n=gE(t,r.getImmediateChild(".priority"),i);let s;if(e.isLeafNode()){const o=e;t=gE(o.getValue(),r,i);return t!==o.getValue()||n!==o.getPriority().val()?new VI(t,nT(n)):e}{const a=e;return s=a,n!==a.getPriority().val()&&(s=s.updatePriority(new VI(n))),a.forEachChild($I,(e,t)=>{var n=wE(t,r.getImmediateChild(e),i);n!==t&&(s=s.updateImmediateChild(e,n))}),s}}class bE{constructor(e="",t=null,n={children:{},childCount:0}){this.name=e,this.parent=t,this.node=n}}function IE(e,t){let n=t instanceof cI?t:new cI(t),r=e,i=uI(n);for(;null!==i;){var s=Id(r.node.children,i)||{children:{},childCount:0};r=new bE(i,r,s),n=dI(n),i=uI(n)}return r}function TE(e){return e.node.value}function EE(e,t){e.node.value=t,AE(e)}function kE(e){return 0<e.node.childCount}function SE(n,r){xb(n.node.children,(e,t)=>{r(new bE(e,n,t))})}function CE(e){return new cI(null===e.parent?e.name:CE(e.parent)+"/"+e.name)}function AE(e){var t,n,r,i;null!==e.parent&&(t=e.parent,n=e.name,r=function(e){return void 0===TE(e)&&!kE(e)}(e=e),i=bd(t.node.children,n),r&&i?(delete t.node.children[n],t.node.childCount--,AE(t)):r||i||(t.node.children[n]=e.node,t.node.childCount++,AE(t)))}function NE(e,t,n,r){r&&void 0===t||BE(Md(e,"value"),t,n)}function RE(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=[];xb(t,(e,t)=>{const n=new cI(e);if(BE(i,t,mI(r,n)),".priority"===pI(n)&&!VE(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=fI(i);for(let e=0;e<s.length;e++)if((".priority"!==s[e]||e!==s.length-1)&&!UE(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(_I);let e=null;for(r=0;r<n.length;r++){if(i=n[r],null!==e&&bI(e,i))throw new Error(t+"contains a path "+e.toString()+" that is ancestor of another path "+i.toString());e=i}}(i,s)}}function PE(e,t,n){if(!n||void 0!==t){if(Ab(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(!VE(t))throw new Error(Md(e,"priority")+"must be a valid Firebase priority (a string, finite number, server value, or null).")}}function xE(e,t,n,r){if(!(r&&void 0===n||UE(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 DE(e,t,n,r){n=n&&n.replace(/^\/*\.info(\/|$)/,"/"),WE(e,t,n,r)}function OE(e,t){if(".info"===uI(t))throw new Error(e+" failed = Can't modify data under /.info/")}const ME=/[\[\].#$\/\u0000-\u001F\u007F]/,LE=/[\[\].#$\u0000-\u001F\u007F]/,FE=10485760,UE=function(e){return"string"==typeof e&&0!==e.length&&!ME.test(e)},jE=function(e){return"string"==typeof e&&0!==e.length&&!LE.test(e)},qE=function(e){return e=e&&e.replace(/^\/*\.info(\/|$)/,"/"),jE(e)},VE=function(e){return null===e||"string"==typeof e||"number"==typeof e&&!Ab(e)||e&&"object"==typeof e&&bd(e,".sv")},BE=function(o,e,t){const a=t instanceof cI?new II(t,o):t;if(void 0===e)throw new Error(o+"contains undefined "+EI(a));if("function"==typeof e)throw new Error(o+"contains a function "+EI(a)+" with contents = "+e.toString());if(Ab(e))throw new Error(o+"contains "+e.toString()+" "+EI(a));if("string"==typeof e&&e.length>FE/3&&Ud(e)>FE)throw new Error(o+"contains a string greater than "+FE+" utf8 bytes "+EI(a)+" ('"+e.substring(0,50)+"...')");if(e&&"object"==typeof e){let i=!1,s=!1;if(xb(e,(e,t)=>{if(".value"===e)i=!0;else if(".priority"!==e&&".sv"!==e&&(s=!0,!UE(e)))throw new Error(o+" contains an invalid key ("+e+") "+EI(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),TI(n),BE(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 '+EI(a)+" in addition to actual children.")}},WE=function(e,t,n,r){if(!(r&&void 0===n||jE(n)))throw new Error(Md(e,t)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},$E=function(e,t){var n=t.path.toString();if("string"!=typeof t.repoInfo.host||0===t.repoInfo.host.length||!UE(t.repoInfo.namespace)&&"localhost"!==t.repoInfo.host.split(":")[0]||0!==n.length&&!qE(n))throw new Error(Md(e,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')};class KE{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function zE(e,t){let n=null;for(let i=0;i<t.length;i++){const s=t[i];var r=s.getPath();null===n||wI(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 HE(e,t,n){zE(e,n),QE(e,e=>wI(e,t))}function GE(e,t,n){zE(e,n),QE(e,e=>bI(e,t)||bI(t,e))}function QE(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(),gb&&Eb("event: "+r.toString()),jb(t))}}(e.eventLists_[i]),e.eventLists_[i]=null):n=!1)}n&&(e.eventLists_=[]),e.recursionDepth_--}const YE="repo_interrupt",JE=25;class XE{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 KE,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=CT(),this.transactionQueueTree_=new bE,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function ZE(o,e,t){if(o.stats_=Jb(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 kT(o.repoInfo_,(e,t,n,r)=>{nk(o,e,t,n,r)},o.authTokenProvider_,o.appCheckProvider_),setTimeout(()=>rk(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 SI(o.repoInfo_,e,(e,t,n,r)=>{nk(o,e,t,n,r)},e=>{rk(o,e)},e=>{var n;n=o,xb(e,(e,t)=>{ik(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 PT(o.stats_,o.server_),n=e.toString(),Yb[n]||(Yb[n]=t()),Yb[n]),o.infoData_=new ST,o.infoSyncTree_=new G0({startListening:(e,t,n,r)=>{let i=[];const s=o.infoData_.getNode(e._path);return s.isEmpty()||(i=X0(o.infoSyncTree_,e._path,s),setTimeout(()=>{r("ok")},0)),i},stopListening:()=>{}}),ik(o,"connected",!1),o.serverSyncTree_=new G0({startListening:(r,e,t,i)=>(o.server_.listen(r,t,e,(e,t)=>{var n=i(e,t);GE(o.eventQueue_,r._path,n)}),[]),stopListening:(e,t)=>{o.server_.unlisten(e,t)}})}function ek(e){const t=e.infoData_.getNode(new cI(".info/serverTimeOffset"));var n=t.val()||0;return(new Date).getTime()+n}function tk(e){return fE({timestamp:ek(e)})}function nk(e,t,n,r,i){e.dataUpdateCount++;var s,o,a=new cI(t);n=e.interceptServerDataCallback_?e.interceptServerDataCallback_(t,n):n;let c=[];c=i?r?(s=Ed(n,e=>nT(e)),function(e,t,n,r){if(a=cE(e,r)){var i=lE(a),s=i.path,o=i.queryId,a=yI(s,t),i=QT.fromObject(n);return uE(e,s,new UT(OT(o),a,i))}return[]}(e.serverSyncTree_,a,s,i)):(s=nT(n),function(e,t,n,r){if(null==(s=cE(e,r)))return[];var i=(o=lE(s)).path,s=o.queryId,o=yI(i,t);return uE(e,i,new FT(OT(s),o,n))}(e.serverSyncTree_,a,s,i)):r?(o=Ed(n,e=>nT(e)),t=e.serverSyncTree_,i=a,r=o,o=QT.fromObject(r),rE(t,new UT(DT(),i,o))):(o=nT(n),X0(e.serverSyncTree_,a,o));let l=a;0<c.length&&(l=gk(e,a)),GE(e.eventQueue_,l,c)}function rk(e,t){ik(e,"connected",t),!1===t&&function(r){hk(r,"onDisconnectEvents");const i=tk(r),s=CT();NT(r.onDisconnect_,lI(),(e,t)=>{var n=yE(e,t,r.serverSyncTree_,i);AT(s,e,n)});let o=[];NT(s,lI(),(e,t)=>{o=o.concat(X0(r.serverSyncTree_,e,t));var n=_k(r,e);gk(r,n)}),r.onDisconnect_=CT(),GE(r.eventQueue_,lI(),o)}(e)}function ik(e,t,n){var r=new cI("/.info/"+t),i=nT(n);e.infoData_.updateSnapshot(r,i);i=X0(e.infoSyncTree_,r,i);GE(e.eventQueue_,r,i)}function sk(e){return e.nextWriteId_++}function ok(r,i,e,t,s){hk(r,"set",{path:i.toString(),value:e,priority:t});var n=tk(r);const o=nT(e,t);var a=tE(r.serverSyncTree_,i),n=_E(o,a,n);const c=sk(r);n=Q0(r.serverSyncTree_,i,n,c,!0);zE(r.eventQueue_,n),r.server_.put(i.toString(),o.val(!0),(e,t)=>{var n="ok"===e;n||Sb("set at "+i+" failed: "+e);n=J0(r.serverSyncTree_,c,!n);GE(r.eventQueue_,i,n),dk(0,s,e,t)});n=_k(r,i);gk(r,n),GE(r.eventQueue_,n,[])}function ak(n,r,i){n.server_.onDisconnectCancel(r.toString(),(e,t)=>{"ok"===e&&!function e(n,t){if(vI(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($I,(e,t)=>{AT(n,new cI(e),t)}),e(n,t)}}if(0<n.children.size){var r=uI(t);return t=dI(t),n.children.has(r)&&e(n.children.get(r),t)&&n.children.delete(r),0===n.children.size}return!0}(n.onDisconnect_,r),dk(0,i,e,t)})}function ck(n,r,e,i){const s=nT(e);n.server_.onDisconnectPut(r.toString(),s.val(!0),(e,t)=>{"ok"===e&&AT(n.onDisconnect_,r,s),dk(0,i,e,t)})}function lk(e,t,n){let r;r=".info"===uI(t._path)?Z0(e.infoSyncTree_,t,n):Z0(e.serverSyncTree_,t,n),HE(e.eventQueue_,t._path,r)}function uk(e){e.persistentConnection_&&e.persistentConnection_.interrupt(YE)}function hk(e,...t){let n="";e.persistentConnection_&&(n=e.persistentConnection_.id+":"),Eb(n,...t)}function dk(e,r,i,s){r&&jb(()=>{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 pk(e,t,n){return tE(e.serverSyncTree_,t,n)||XI.EMPTY_NODE}function fk(t,e=t.transactionQueueTree_){if(e||yk(t,e),TE(e)){const n=vk(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=pk(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=yI(s,h.path);n=n.updateChild(a,h.currentOutputSnapshotRaw)}const c=n.val(!0),l=s;i.server_.put(l.toString(),c,t=>{hk(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(J0(i.serverSyncTree_,o[e].currentWriteId)),o[e].onComplete&&r.push(()=>o[e].onComplete(null,!0,o[e].currentOutputSnapshotResolved)),o[e].unwatcher();yk(i,IE(i.transactionQueueTree_,s)),fk(i,i.transactionQueueTree_),GE(i.eventQueue_,s,n);for(let t=0;t<r.length;t++)jb(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{Sb("transaction at "+l.toString()+" failed: "+t);for(let e=0;e<o.length;e++)o[e].status=4,o[e].abortReason=t}gk(i,s)}},r)}(t,CE(e),n)}else kE(e)&&SE(e,e=>{fk(t,e)})}function gk(e,t){var n=mk(e,t),r=CE(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=yI(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(J0(i.serverSyncTree_,h.currentWriteId,!0));else if(0===h.status)if(h.retryCount>=JE)e=!0,t="maxretry",n=n.concat(J0(i.serverSyncTree_,h.currentWriteId,!0));else{const d=pk(i,h.path,u);h.currentInputSnapshot=d;var c=s[r].update(d.val());if(void 0!==c){BE("transaction failed: Data returned ",c,h.path);let e=nT(c);"object"==typeof c&&null!=c&&bd(c,".priority")||(e=e.updatePriority(d.getPriority()));a=h.currentWriteId,c=tk(i),c=_E(e,d,c);h.currentOutputSnapshotRaw=e,h.currentOutputSnapshotResolved=c,h.currentWriteId=sk(i),u.splice(u.indexOf(a),1),n=n.concat(Q0(i.serverSyncTree_,h.path,c,h.currentWriteId,h.applyLocally)),n=n.concat(J0(i.serverSyncTree_,a,!0))}else e=!0,t="nodata",n=n.concat(J0(i.serverSyncTree_,h.currentWriteId,!0))}GE(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))))}yk(i,i.transactionQueueTree_);for(let e=0;e<l.length;e++)jb(l[e]);fk(i,i.transactionQueueTree_)}}(e,vk(e,n),r),r}function mk(e,t){let n,r=e.transactionQueueTree_;for(n=uI(t);null!==n&&void 0===TE(r);)r=IE(r,n),t=dI(t),n=uI(t);return r}function vk(e,t){const n=[];return function t(n,e,r){const i=TE(e);if(i)for(let e=0;e<i.length;e++)r.push(i[e]);SE(e,e=>{t(n,e,r)})}(e,t,n),n.sort((e,t)=>e.order-t.order),n}function yk(t,n){const r=TE(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,EE(n,0<r.length?r:void 0)}SE(n,e=>{yk(t,e)})}function _k(t,e){var n=CE(mk(t,e)),r=IE(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=>{wk(t,e)}),wk(t,r),function t(e,n,r,i){r&&!i&&n(e),SE(e,e=>{t(e,n,!0,i)}),r&&i&&n(e)}(r,e=>{wk(t,e)}),n}function wk(i,s){const o=TE(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(J0(i.serverSyncTree_,o[n].currentWriteId,!0)),o[n].onComplete&&a.push(o[n].onComplete.bind(null,new Error("set"),!1,null))));-1===t?EE(s,void 0):o.length=t+1,GE(i.eventQueue_,CE(s),e);for(let r=0;r<a.length;r++)jb(a[r])}}const bk=function(e,t){var n=Ik(e),r=n.namespace;"firebase.com"===n.domain&&kb(n.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),r&&"undefined"!==r||"localhost"===n.domain||kb("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),n.secure||Cb();var i="ws"===n.scheme||"wss"===n.scheme;return{repoInfo:new zb(n.host,n.secure,r,t,i,"",r!==n.subdomain),path:new cI(n.pathString)}},Ik=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]):Sb(`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 Tk{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 Ek{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 kk{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 Sk{constructor(e,t){this._repo=e,this._path=t}cancel(){const e=new rd;return ak(this._repo,this._path,e.wrapCallback(()=>{})),e.promise}remove(){OE("OnDisconnect.remove",this._path);const e=new rd;return ck(this._repo,this._path,null,e.wrapCallback(()=>{})),e.promise}set(e){OE("OnDisconnect.set",this._path),NE("OnDisconnect.set",e,this._path,!1);const t=new rd;return ck(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}setWithPriority(e,t){OE("OnDisconnect.setWithPriority",this._path),NE("OnDisconnect.setWithPriority",e,this._path,!1),PE("OnDisconnect.setWithPriority",t,!1);const n=new rd;return function(n,r,e,t,i){const s=nT(e,t);n.server_.onDisconnectPut(r.toString(),s.val(!0),(e,t)=>{"ok"===e&&AT(n.onDisconnect_,r,s),dk(0,i,e,t)})}(this._repo,this._path,e,t,n.wrapCallback(()=>{})),n.promise}update(e){OE("OnDisconnect.update",this._path),RE("OnDisconnect.update",e,this._path,!1);const t=new rd;return function(r,i,n,s){if(Td(n))return Eb("onDisconnect().update() called with empty data. Don't do anything."),dk(0,s,"ok",void 0);r.server_.onDisconnectMerge(i.toString(),n,(e,t)=>{"ok"===e&&xb(n,(e,t)=>{var n=nT(t);AT(r.onDisconnect_,mI(i,e),n)}),dk(0,s,e,t)})}(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}}class Ck{constructor(e,t,n,r){this._repo=e,this._path=t,this._queryParams=n,this._orderByCalled=r}get key(){return vI(this._path)?null:pI(this._path)}get ref(){return new Pk(this._repo,this._path)}get _queryIdentifier(){var e=ET(this._queryParams),e=bb(e);return"{}"===e?"default":e}get _queryObject(){return ET(this._queryParams)}isEqual(e){if(!((e=$d(e))instanceof Ck))return!1;var t=this._repo===e._repo,n=wI(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 Ak(e,t){if(!0===e._orderByCalled)throw new Error(t+": You can't combine multiple orderBy calls.")}function Nk(e){let t=null,n=null;if(e.hasStart()&&(t=e.getIndexStartValue()),e.hasEnd()&&(n=e.getIndexEndValue()),e.getIndex()===PI){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()!==Nb)throw new Error(r);if("string"!=typeof t)throw new Error(i)}if(e.hasEnd()){if(e.getIndexEndName()!==Rb)throw new Error(r);if("string"!=typeof n)throw new Error(i)}}else if(e.getIndex()===$I){if(null!=t&&!VE(t)||null!=n&&!VE(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 rT||e.getIndex()===oT,"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 Rk(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 Pk extends Ck{constructor(e,t){super(e,t,new _T,!1)}get parent(){var e=gI(this._path);return null===e?null:new Pk(this._repo,e)}get root(){let e=this;for(;null!==e.parent;)e=e.parent;return e}}class xk{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 cI(e),n=Mk(this.ref,e);return new xk(this._node.getChild(t),n,$I)}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 xk(t,Mk(this.ref,e),$I)))}hasChild(e){var t=new cI(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 Dk(e,t){return(e=$d(e))._checkNotDeleted("ref"),void 0!==t?Mk(e._root,t):e._root}function Ok(e,t){(e=$d(e))._checkNotDeleted("refFromURL");const n=bk(t,e._repo.repoInfo_.nodeAdmin);$E("refFromURL",n);var r=n.repoInfo;return e._repo.repoInfo_.isCustomHost()||r.host===e._repo.repoInfo_.host||kb("refFromURL: Host name does not match the current database: (found "+r.host+" but expected "+e._repo.repoInfo_.host+")"),Dk(e,n.path.toString())}function Mk(e,t){return(null===uI((e=$d(e))._path)?DE:WE)("child","path",t,!1),new Pk(e._repo,mI(e._path,t))}function Lk(e,t){e=$d(e),OE("set",e._path),NE("set",t,e._path,!1);const n=new rd;return ok(e._repo,e._path,t,null,n.wrapCallback(()=>{})),n.promise}function Fk(e,t){RE("update",t,e._path,!1);const n=new rd;return function(i,s,e,o){hk(i,"update",{path:s.toString(),value:e});let n=!0;const r=tk(i),a={};if(xb(e,(e,t)=>{n=!1,a[e]=yE(mI(s,e),nT(t),i.serverSyncTree_,r)}),n)Eb("update() called with empty data. Don't do anything."),dk(0,o,"ok",void 0);else{const c=sk(i);var t=Y0(i.serverSyncTree_,s,a,c);zE(i.eventQueue_,t),i.server_.merge(s.toString(),e,(e,t)=>{var n="ok"===e;n||Sb("update at "+s+" failed: "+e);var r=J0(i.serverSyncTree_,c,!n),n=0<r.length?gk(i,s):s;GE(i.eventQueue_,n,r),dk(0,o,e,t)}),xb(e,e=>{var t=_k(i,mI(s,e));gk(i,t)}),GE(i.eventQueue_,s,[])}}(e._repo,e._path,t,n.wrapCallback(()=>{})),n.promise}function Uk(t){return t=$d(t),r=t._repo,i=t,(null!=(e=nE(r.serverSyncTree_,i))?Promise.resolve(e):r.server_.get(i).then(e=>{var t=nT(e).withIndex(i._queryParams.getIndex()),n=X0(r.serverSyncTree_,i._path,t);return HE(r.eventQueue_,i._path,n),Promise.resolve(t)},e=>(hk(r,"get for query "+_d(i)+" failed: "+e),Promise.reject(new Error(e))))).then(e=>new xk(e,new Pk(t._repo,t._path),t._queryParams.getIndex()));var r,i,e}class jk{constructor(e){this.callbackContext=e}respondsTo(e){return"value"===e}createEvent(e,t){var n=t._queryParams.getIndex();return new Tk("value",this,new xk(e.snapshotNode,new Pk(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 Ek(this,e,t):null}matches(e){return e instanceof jk&&(!e.callbackContext||!this.callbackContext||e.callbackContext.matches(this.callbackContext))}hasAnyCallback(){return null!==this.callbackContext}}class qk{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 Ek(this,e,t):null}createEvent(e,t){Jh(null!=e.childName,"Child events should have a childName.");var n=Mk(new Pk(t._repo,t._path),e.childName),r=t._queryParams.getIndex();return new Tk(e.type,this,new xk(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 qk&&(this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)))}hasAnyCallback(){return!!this.callbackContext}}function Vk(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)=>{lk(n._repo,n,a),c(e,t)};o.userCallback=t.userCallback,o.context=t.context,t=o}o=new kk(t,s||void 0);const a="value"===e?new jk(o):new qk(e,o);return function(e,t,n){let r;r=".info"===uI(t._path)?eE(e.infoSyncTree_,t,n):eE(e.serverSyncTree_,t,n),HE(e.eventQueue_,t._path,r)}(n._repo,n,a),()=>lk(n._repo,n,a)}function Bk(e,t,n,r){return Vk(e,"value",t,n,r)}function Wk(e,t,n,r){return Vk(e,"child_added",t,n,r)}function $k(e,t,n,r){return Vk(e,"child_changed",t,n,r)}function Kk(e,t,n,r){return Vk(e,"child_moved",t,n,r)}function zk(e,t,n,r){return Vk(e,"child_removed",t,n,r)}function Hk(e,t,n){let r=null;var i=n?new kk(n):null;"value"===t?r=new jk(i):t&&(r=new qk(t,i)),lk(e._repo,e,r)}class Gk{}class Qk extends Gk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){NE("endAt",this._value,e._path,!0);var t=bT(e._queryParams,this._value,this._key);if(Rk(t),Nk(t),e._queryParams.hasEnd())throw new Error("endAt: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new Ck(e._repo,e._path,t,e._orderByCalled)}}class Yk extends Gk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){NE("endBefore",this._value,e._path,!1);var t=function(e,t,n){let r,i;return i=e.index_===PI?bT(e,t="string"==typeof t?sT(t):t,n):(r=null==n?Nb:sT(n),bT(e,t,r)),i.endBeforeSet_=!0,i}(e._queryParams,this._value,this._key);if(Rk(t),Nk(t),e._queryParams.hasEnd())throw new Error("endBefore: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new Ck(e._repo,e._path,t,e._orderByCalled)}}class Jk extends Gk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){NE("startAt",this._value,e._path,!0);var t=wT(e._queryParams,this._value,this._key);if(Rk(t),Nk(t),e._queryParams.hasStart())throw new Error("startAt: Starting point was already set (by another call to startAt, startBefore or equalTo).");return new Ck(e._repo,e._path,t,e._orderByCalled)}}class Xk extends Gk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){NE("startAfter",this._value,e._path,!1);var t=function(t,n,r){let i;if(t.index_===PI)"string"==typeof n&&(n=iT(n)),i=wT(t,n,r);else{let e;e=null==r?Rb:iT(r),i=wT(t,n,e)}return i.startAfterSet_=!0,i}(e._queryParams,this._value,this._key);if(Rk(t),Nk(t),e._queryParams.hasStart())throw new Error("startAfter: Starting point was already set (by another call to startAt, startAfter, or equalTo).");return new Ck(e._repo,e._path,t,e._orderByCalled)}}class Zk extends Gk{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 Ck(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 eS extends Gk{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 Ck(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 tS extends Gk{constructor(e){super(),this._path=e}_apply(e){Ak(e,"orderByChild");var t=new cI(this._path);if(vI(t))throw new Error("orderByChild: cannot pass in empty path. Use orderByValue() instead.");t=new rT(t),t=IT(e._queryParams,t);return Nk(t),new Ck(e._repo,e._path,t,!0)}}class nS extends Gk{_apply(e){Ak(e,"orderByKey");var t=IT(e._queryParams,PI);return Nk(t),new Ck(e._repo,e._path,t,!0)}}class rS extends Gk{_apply(e){Ak(e,"orderByPriority");var t=IT(e._queryParams,$I);return Nk(t),new Ck(e._repo,e._path,t,!0)}}class iS extends Gk{_apply(e){Ak(e,"orderByValue");var t=IT(e._queryParams,oT);return Nk(t),new Ck(e._repo,e._path,t,!0)}}class sS extends Gk{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){if(NE("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 Qk(this._value,this._key)._apply(new Jk(this._value,this._key)._apply(e))}}function oS(e,...t){let n=$d(e);for(const r of t)n=r._apply(n);return n}ob=Pk,Jh(!O0,"__referenceConstructor has already been defined"),O0=ob,ab=Pk,Jh(!z0,"__referenceConstructor has already been defined"),z0=ab;const aS="FIREBASE_DATABASE_EMULATOR_HOST",cS={};let lS=!1;function uS(e,t,n,r,i){let s=r||e.options.databaseURL;void 0===s&&(e.options.projectId||kb("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),Eb("Using default host for project ",e.options.projectId),s=`${e.options.projectId}-default-rtdb.firebaseio.com`);let o=bk(s,i),a=o.repoInfo,c,l=void 0;"undefined"!=typeof process&&(l=process.env[aS]),l?(c=!0,s=`http://${l}?ns=${a.namespace}`,o=bk(s,i),a=o.repoInfo):c=!o.repoInfo.secure;var u=i&&c?new Bb(Bb.OWNER):new Vb(e.name,e.options,t);$E("Invalid Firebase Database URL",o),vI(o.path)||kb("Database URL must point to the root of a Firebase Database (not including a child path).");u=function(e,t,n,r){let i=cS[t.name];i||(i={},cS[t.name]=i);var s=i[e.toURLString()];s&&kb("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call.");return s=new XE(e,lS,n,r),i[e.toURLString()]=s}(a,e,u,new qb(e.name,n));return new hS(u,e)}class hS{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(ZE(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new Pk(this._repo,lI())),this._rootInternal}_delete(){return null!==this._rootInternal&&(function(e,t){const n=cS[t];n&&n[e.key]===e||kb(`Database ${t}(${e.repoInfo_}) has already been deleted.`),uk(e),delete n[e.key]}(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){null===this._rootInternal&&kb("Cannot call "+e+" on a deleted database.")}}function dS(e,t,n,r={}){(e=$d(e))._checkNotDeleted("useEmulator"),e._instanceStarted&&kb("Cannot call useEmulator() after instance has already been initialized.");var i,s=e._repoInternal;let o=void 0;s.repoInfo_.nodeAdmin?(r.mockUserToken&&kb('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 Bb(Bb.OWNER)):r.mockUserToken&&(i="string"==typeof r.mockUserToken?r.mockUserToken:id(r.mockUserToken,e.app.options.projectId),o=new Bb(i)),r=s,e=t,t=n,n=o,r.repoInfo_=new zb(`${e}:${t}`,!1,r.repoInfo_.namespace,r.repoInfo_.webSocketOnly,r.repoInfo_.nodeAdmin,r.repoInfo_.persistenceKey,r.repoInfo_.includeNamespaceInQueryParams),n&&(r.authTokenProvider_=n)}function pS(e){(e=$d(e))._checkNotDeleted("goOnline"),(e=e._repo).persistentConnection_&&e.persistentConnection_.resume(YE)}function fS(e,t){Tb(e,t)}const gS={".sv":"timestamp"};class mS{constructor(e,t){this.committed=e,this.snapshot=t}toJSON(){return{committed:this.committed,snapshot:this.snapshot.toJSON()}}}function vS(i,e,t){if(i=$d(i),OE("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=Bk(i,()=>{});return function(t,n,e,r,i,s){hk(t,"transaction on "+n);const o={path:n,update:e,onComplete:r,status:null,order:pb(),applyLocally:s,retryCount:0,unwatcher:i,abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},a=pk(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{BE("transaction failed: Data returned ",c,o.path),o.status=0;var l=IE(t.transactionQueueTree_,n);const u=TE(l)||[];u.push(o),EE(l,u);let e;if("object"==typeof c&&null!==c&&bd(c,".priority"))e=Id(c,".priority"),Jh(VE(e),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.");else{const h=tE(t.serverSyncTree_,n)||XI.EMPTY_NODE;e=h.getPriority().val()}l=tk(t),c=nT(c,e),l=_E(c,a,l);o.currentOutputSnapshotRaw=c,o.currentOutputSnapshotResolved=l,o.currentWriteId=sk(t);l=Q0(t.serverSyncTree_,n,l,o.currentWriteId,o.applyLocally);GE(t.eventQueue_,n,l),fk(t,t.transactionQueueTree_)}}(i._repo,i._path,e,(e,t,n)=>{var r;e?s.reject(e):(r=new xk(n,new Pk(i._repo,i._path),$I),s.resolve(new mS(t,r)))},r,n),s.promise}SI.prototype.simpleListen=function(e,t){this.sendRequest("q",{p:e},t)},SI.prototype.echo=function(e,t){this.sendRequest("echo",{d:e},t)},eb(mp),dp(new Kd("database",(e,{instanceIdentifier:t})=>{return uS(e.getProvider("app").getImmediate(),e.getProvider("auth-internal"),e.getProvider("app-check-internal"),t)},"PUBLIC").setMultipleInstances(!0)),wp(Jw,Xw,cb),wp(Jw,Xw,"esm2017");function yS(e){var t="FIREBASE WARNING: "+e;_S.warn(t)}const _S=new ep("@firebase/database-compat");class wS{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,yS("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 bS{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 IS{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),WE("DataSnapshot.child","path",e,!1),new IS(this._database,this._delegate.child(e))}hasChild(e){return Od("DataSnapshot.hasChild",1,1,arguments.length),WE("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 IS(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 ES(this._database,this._delegate.ref)}get ref(){return this.getRef()}}class TS{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=TS.getCancelAndContextArgs_("Query.on",t,r);var o=(e,t)=>{n.call(s.context,new IS(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 Bk(this._delegate,o,a),n;case"child_added":return Wk(this._delegate,o,a),n;case"child_removed":return zk(this._delegate,o,a),n;case"child_changed":return $k(this._delegate,o,a),n;case"child_moved":return Kk(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,Hk(this._delegate,e,r)):Hk(this._delegate,e)}get(){return Uk(this._delegate).then(e=>new IS(this.database,e))}once(e,r,t,n){Od("Query.once",1,4,arguments.length),Ld("Query.once","callback",r,!0);const i=TS.getCancelAndContextArgs_("Query.once",t,n),s=new rd;var o=(e,t)=>{var n=new IS(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":Bk(this._delegate,o,a,{onlyOnce:!0});break;case"child_added":Wk(this._delegate,o,a,{onlyOnce:!0});break;case"child_removed":zk(this._delegate,o,a,{onlyOnce:!0});break;case"child_changed":$k(this._delegate,o,a,{onlyOnce:!0});break;case"child_moved":Kk(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 TS(this.database,oS(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 Zk(e)}(e)))}limitToLast(e){return Od("Query.limitToLast",1,1,arguments.length),new TS(this.database,oS(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 eS(e)}(e)))}orderByChild(e){return Od("Query.orderByChild",1,1,arguments.length),new TS(this.database,oS(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 WE("orderByChild","path",e,!1),new tS(e)}(e)))}orderByKey(){return Od("Query.orderByKey",0,0,arguments.length),new TS(this.database,oS(this._delegate,new nS))}orderByPriority(){return Od("Query.orderByPriority",0,0,arguments.length),new TS(this.database,oS(this._delegate,new rS))}orderByValue(){return Od("Query.orderByValue",0,0,arguments.length),new TS(this.database,oS(this._delegate,new iS))}startAt(e=null,t){return Od("Query.startAt",0,2,arguments.length),new TS(this.database,oS(this._delegate,([e=null,t]=[e,t],xE("startAt","key",t,!0),new Jk(e,t))))}startAfter(e=null,t){return Od("Query.startAfter",0,2,arguments.length),new TS(this.database,oS(this._delegate,(e=e,t=t,xE("startAfter","key",t,!0),new Xk(e,t))))}endAt(e=null,t){return Od("Query.endAt",0,2,arguments.length),new TS(this.database,oS(this._delegate,(e=e,t=t,xE("endAt","key",t,!0),new Qk(e,t))))}endBefore(e=null,t){return Od("Query.endBefore",0,2,arguments.length),new TS(this.database,oS(this._delegate,(e=e,t=t,xE("endBefore","key",t,!0),new Yk(e,t))))}equalTo(e,t){return Od("Query.equalTo",1,2,arguments.length),new TS(this.database,oS(this._delegate,(e=e,t=t,xE("equalTo","key",t,!0),new sS(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 TS)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 ES(this.database,new Pk(this._delegate._repo,this._delegate._path))}}class ES extends TS{constructor(e,t){super(e,new Ck(t._repo,t._path,new _T,!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 ES(this.database,Mk(this._delegate,e))}getParent(){Od("Reference.parent",0,0,arguments.length);var e=this._delegate.parent;return e?new ES(this.database,e):null}getRoot(){return Od("Reference.root",0,0,arguments.length),new ES(this.database,this._delegate.root)}set(e,t){Od("Reference.set",1,2,arguments.length),Ld("Reference.set","onComplete",t,!0);const n=Lk(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,yS("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.")}OE("Reference.update",this._delegate._path),Ld("Reference.update","onComplete",n,!0);const e=Fk(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(OE("setWithPriority",e._path),NE("setWithPriority",t,e._path,!1),PE("setWithPriority",n,!1),".length"===e.key||".keys"===e.key)throw"setWithPriority failed: "+e.key+" is a read-only object.";const r=new rd;return ok(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,OE("remove",n._path),Lk(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=vS(this._delegate,e,{applyLocally:n}).then(e=>new bS(e.committed,new IS(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),OE("setPriority",e._path),PE("setPriority",t,!1);const n=new rd;return ok(e._repo,mI(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),OE("push",e._path),NE("push",t,e._path,!0);var n=ek(e._repo),n=hT(n);const r=Mk(e,n),i=Mk(e,n);let s;return s=null!=t?Lk(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 ES(this.database,e));t&&r.then(()=>t(null),e=>t(e));const i=new ES(this.database,n);return i.then=r.then.bind(r),i.catch=r.catch.bind(r,void 0),i}onDisconnect(){return OE("Reference.onDisconnect",this._delegate._path),new wS(new Sk(this._delegate._repo,this._delegate._path))}get key(){return this.getKey()}get parent(){return this.getParent()}get root(){return this.getRoot()}}class kS{constructor(e,t){this._delegate=e,this.app=t,this.INTERNAL={delete:()=>this._delegate._delete()}}useEmulator(e,t,n={}){dS(this._delegate,e,t,n)}ref(e){if(Od("database.ref",0,1,arguments.length),e instanceof ES){var t=Ok(this._delegate,e.toString());return new ES(this,t)}t=Dk(this._delegate,e);return new ES(this,t)}refFromURL(e){Od("database.refFromURL",1,1,arguments.length);var t=Ok(this._delegate,e);return new ES(this,t)}goOffline(){var e;Od("database.goOffline",0,0,arguments.length),(e=$d(e=this._delegate))._checkNotDeleted("goOffline"),uk(e._repo)}goOnline(){return Od("database.goOnline",0,0,arguments.length),pS(this._delegate)}}kS.ServerValue={TIMESTAMP:gS,increment:e=>({".sv":{increment:e}})};var SS,CS=Object.freeze({__proto__:null,initStandalone:function({app:e,url:t,version:n,customAuthImpl:r,namespace:i,nodeAdmin:s=!1}){eb(n);const o=new Hd("auth-internal",new Gd("database-standalone"));return o.setComponent(new Kd("auth-internal",()=>r,"PRIVATE")),{instance:new kS(uS(e,o,void 0,t,s),e),namespace:i}}});const AS=kS.ServerValue;(SS=Ap).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 kS(r,n)},"PUBLIC").setServiceProps({Reference:ES,Query:TS,Database:kS,DataSnapshot:IS,enableLogging:fS,INTERNAL:CS,ServerValue:AS}).setMultipleInstances(!0)),SS.registerVersion("@firebase/database-compat","0.1.5-canary.88d43ec00");var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},NS={},RS=l||self;function PS(){}function xS(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 DS(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}var OS="closure_uid_"+(1e9*Math.random()>>>0),MS=0;function LS(e,t,n){return e.call.apply(e.bind,arguments)}function FS(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 US(e,t,n){return(US=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?LS:FS).apply(null,arguments)}function jS(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 qS(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 VS(){this.s=this.s,this.o=this.o}var BS={};VS.prototype.s=!1,VS.prototype.na=function(){var e,t;!this.s&&(this.s=!0,this.M(),0)&&(t=this,e=Object.prototype.hasOwnProperty.call(t,OS)&&t[OS]||(t[OS]=++MS),delete BS[e])},VS.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};const WS=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},$S=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 KS(){return Array.prototype.concat.apply([],arguments)}function zS(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 HS(e){return/^[\s\xa0]*$/.test(e)}var GS,QS=String.prototype.trim?function(e){return e.trim()}:function(e){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(e)[1]};function YS(e,t){return-1!=e.indexOf(t)}function JS(e,t){return e<t?-1:t<e?1:0}e:{var XS=RS.navigator;if(XS){XS=XS.userAgent;if(XS){GS=XS;break e}}GS=""}function ZS(e,t,n){for(const r in e)t.call(n,e[r],r,e)}function eC(e){const t={};for(const n in e)t[n]=e[n];return t}var tC="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function nC(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<tC.length;e++)n=tC[e],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function rC(e){return rC[" "](e),e}rC[" "]=PS;var iC,sC=YS(GS,"Opera"),oC=YS(GS,"Trident")||YS(GS,"MSIE"),aC=YS(GS,"Edge"),cC=aC||oC,lC=YS(GS,"Gecko")&&!(YS(GS.toLowerCase(),"webkit")&&!YS(GS,"Edge"))&&!(YS(GS,"Trident")||YS(GS,"MSIE"))&&!YS(GS,"Edge"),uC=YS(GS.toLowerCase(),"webkit")&&!YS(GS,"Edge");function hC(){var e=RS.document;return e?e.documentMode:void 0}e:{var dC="",pC=(pC=GS,lC?/rv:([^\);]+)(\)|;)/.exec(pC):aC?/Edge\/([\d\.]+)/.exec(pC):oC?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(pC):uC?/WebKit\/(\S+)/.exec(pC):sC?/(?:Version)[ \/]?(\S+)/.exec(pC):void 0);if(pC&&(dC=pC?pC[1]:""),oC){pC=hC();if(null!=pC&&pC>parseFloat(dC)){iC=String(pC);break e}}iC=dC}var fC={};function gC(){return e=function(){let e=0;var t=QS(String(iC)).split("."),n=QS("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=JS(0==i[1].length?0:parseInt(i[1],10),0==s[1].length?0:parseInt(s[1],10))||JS(0==i[2].length,0==s[2].length)||JS(i[2],s[2]),i=i[3],s=s[3],0==e););return 0<=e},t=fC,Object.prototype.hasOwnProperty.call(t,9)?t[9]:t[9]=e(9);var e,t}var mC=RS.document&&oC&&(hC()||parseInt(iC,10))||void 0,vC=function(){if(!RS.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{RS.addEventListener("test",PS,t),RS.removeEventListener("test",PS,t)}catch(e){}return e}();function yC(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}function _C(e,t){if(yC.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(lC){e:{try{rC(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:wC[e.pointerType]||"",this.state=e.state,(this.i=e).defaultPrevented&&_C.Z.h.call(this)}}yC.prototype.h=function(){this.defaultPrevented=!0},qS(_C,yC);var wC={2:"touch",3:"pen",4:"mouse"};_C.prototype.h=function(){_C.Z.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var bC="closure_listenable_"+(1e6*Math.random()|0),IC=0;function TC(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=++IC,this.ca=this.fa=!1}function EC(e){e.ca=!0,e.listener=null,e.proxy=null,e.src=null,e.ia=null}function kC(e){this.src=e,this.g={},this.h=0}function SC(e,t){var n,r,i,s=t.type;s in e.g&&(n=e.g[s],(i=0<=(r=WS(n,t)))&&Array.prototype.splice.call(n,r,1),i&&(EC(t),0==e.g[s].length&&(delete e.g[s],e.h--)))}function CC(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}kC.prototype.add=function(e,t,n,r,i){var s=e.toString();(e=this.g[s])||(e=this.g[s]=[],this.h++);var o=CC(e,t,r,i);return-1<o?(t=e[o],n||(t.fa=!1)):((t=new TC(t,this.src,s,!!r,i)).fa=n,e.push(t)),t};var AC="closure_lm_"+(1e6*Math.random()|0),NC={};function RC(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=FC(r);return t&&t[bC]?t.O(n,r,DS(i)?!!i.capture:!!i,s):PC(t,n,r,!0,i,s)}(e,t,n,r,i);if(Array.isArray(t)){for(var s=0;s<t.length;s++)RC(e,t[s],n,r,i);return null}return n=FC(n),e&&e[bC]?e.N(t,n,DS(r)?!!r.capture:!!r,i):PC(e,t,n,!1,r,i)}function PC(e,t,n,r,i,s){if(!t)throw Error("Invalid event type");var o,a=DS(i)?!!i.capture:!!i,c=MC(e);if(c||(e[AC]=c=new kC(e)),(n=c.add(t,n,r,a,s)).proxy)return n;if(o=OC,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=!vC?a:i)&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(DC(t.toString()),r);else{if(!e.addListener||!e.removeListener)throw Error("addEventListener and attachEvent are unavailable.");e.addListener(r)}return n}function xC(e){var t,n,r;"number"!=typeof e&&e&&!e.ca&&((t=e.src)&&t[bC]?SC(t.i,e):(n=e.type,r=e.proxy,t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(DC(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=MC(t))?(SC(n,e),0==n.h&&(n.src=null,t[AC]=null)):EC(e)))}function DC(e){return e in NC?NC[e]:NC[e]="on"+e}function OC(e,t){var n,r;return e=!!e.ca||(t=new _C(t,this),n=e.listener,r=e.ia||e.src,e.fa&&xC(e),n.call(r,t))}function MC(e){return(e=e[AC])instanceof kC?e:null}var LC="__closure_events_fn_"+(1e9*Math.random()>>>0);function FC(t){return"function"==typeof t?t:(t[LC]||(t[LC]=function(e){return t.handleEvent(e)}),t[LC])}function UC(){VS.call(this),this.i=new kC(this),(this.P=this).I=null}function jC(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 yC(t,e):t instanceof yC?t.target=t.target||e:(o=t,nC(t=new yC(r,e),o)),o=!0,n)for(var i=n.length-1;0<=i;i--)var s=t.g=n[i],o=qC(s,r,!0,t)&&o;if(o=qC(s=t.g=e,r,!0,t)&&o,o=qC(s,r,!1,t)&&o,n)for(i=0;i<n.length;i++)o=qC(s=t.g=n[i],r,!1,t)&&o}function qC(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&&SC(e.i,c),i=!1!==o.call(a,r)&&i)}return i&&!r.defaultPrevented}qS(UC,VS),UC.prototype[bC]=!0,UC.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=DS(i)?!!i.capture:!!i,r=FC(r),t&&t[bC]?(t=t.i,(n=String(n).toString())in t.g&&-1<(r=CC(o=t.g[n],r,i,s))&&(EC(o[r]),Array.prototype.splice.call(o,r,1),0==o.length&&(delete t.g[n],t.h--))):(t=t&&MC(t))&&(n=t.g[n.toString()],(r=(t=-1)<(t=n?CC(n,r,i,s):t)?n[t]:null)&&xC(r))}(this,e,t,n,r)},UC.prototype.M=function(){if(UC.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++)EC(n[r]);delete t.g[e],t.h--}}this.I=null},UC.prototype.N=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},UC.prototype.O=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};var VC=RS.JSON.stringify;var BC,WC=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 $C,e=>e.reset());class $C{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 KC(e,t){var n;BC||(n=RS.Promise.resolve(void 0),BC=function(){n.then(GC)}),zC||(BC(),zC=!0),HC.add(e,t)}var zC=!1,HC=new class{constructor(){this.h=this.g=null}add(e,t){const n=WC.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}};function GC(){for(var e;e=function(){var e=HC;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){RS.setTimeout(()=>{throw e},0)}(e)}var t=WC;t.j(e),t.h<100&&(t.h++,e.next=t.g,t.g=e)}zC=!1}function QC(e,t){UC.call(this),this.h=e||1,this.g=t||RS,this.j=US(this.kb,this),this.l=Date.now()}function YC(e){e.da=!1,e.S&&(e.g.clearTimeout(e.S),e.S=null)}function JC(e,t,n){if("function"==typeof e)n&&(e=US(e,n));else{if(!e||"function"!=typeof e.handleEvent)throw Error("Invalid listener argument");e=US(e.handleEvent,e)}return 2147483647<Number(t)?-1:RS.setTimeout(e,t||0)}qS(QC,UC),(ze=QC.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),jC(this,"tick"),this.da&&(YC(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(){QC.Z.M.call(this),YC(this),delete this.g};class XC extends VS{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=JC(()=>{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&&(RS.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function ZC(e){VS.call(this),this.h=e,this.g={}}qS(ZC,VS);var eA=[];function tA(e,t,n,r){Array.isArray(n)||(n&&(eA[0]=n.toString()),n=eA);for(var i=0;i<n.length;i++){var s=RC(t,n[i],r||e.handleEvent,!1,e.h||e);if(!s)break;e.g[s.key]=s}}function nA(e){ZS(e.g,function(e,t){this.g.hasOwnProperty(t)&&xC(e)},e),e.g={}}function rA(){this.g=!0}function iA(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 VC(n)}catch(e){return t}}(e,n)+(r?" "+r:"")})}ZC.prototype.M=function(){ZC.Z.M.call(this),nA(this)},ZC.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},rA.prototype.Aa=function(){this.g=!1},rA.prototype.info=function(){};var sA={},oA=null;function aA(){return oA=oA||new UC}function cA(e){yC.call(this,sA.Ma,e)}function lA(){var e=aA();jC(e,new cA(e))}function uA(e,t){yC.call(this,sA.STAT_EVENT,e),this.stat=t}function hA(e){var t=aA();jC(t,new uA(t,e))}function dA(e,t){yC.call(this,sA.Na,e),this.size=t}function pA(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return RS.setTimeout(function(){e()},t)}sA.Ma="serverreachability",qS(cA,yC),sA.STAT_EVENT="statevent",qS(uA,yC),sA.Na="timingevent",qS(dA,yC);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 fA(){}function gA(e){return e.h||(e.h=e.i())}function mA(){}fA.prototype.h=null;l={OPEN:"a",pb:"b",Ka:"c",Bb:"d"};function vA(){yC.call(this,"d")}function yA(){yC.call(this,"c")}function _A(){}function wA(e,t,n,r){this.l=e,this.j=t,this.m=n,this.X=r||1,this.V=new ZC(this),this.P=TA,this.W=new QC(e=cC?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 bA}function bA(){this.i=null,this.g="",this.h=!1}qS(vA,yC),qS(yA,yC),qS(_A,fA),_A.prototype.g=function(){return new XMLHttpRequest},_A.prototype.i=function(){return{}};var IA=new _A,TA=45e3,EA={},kA={};function SA(e,t,n){e.K=1,e.v=GA(BA(t)),e.s=n,e.U=!0,CA(e,null)}function CA(e,t){e.F=Date.now(),RA(e),e.A=BA(e.v);var o,a,c,l,u,h,n=e.A,r=e.X;Array.isArray(r)||(r=[String(r)]),aN(n.h,"t",r),e.C=0,n=e.l.H,e.h=new bA,e.g=aR(e.l,n?t:null,!e.s),0<e.O&&(e.L=new XC(US(e.Ia,e,e.g),e.O)),tA(e.V,e.g,"readystatechange",e.gb),t=e.H?eC(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)),lA(),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 AA(e){return e.g&&("GET"==e.u&&2!=e.K&&e.l.Ba)}function NA(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))?kA:(a=Number(o.substring(a,c)),isNaN(a)?EA:(c+=1)+a>o.length?kA:(o=o.substr(c,a),s.C=c+a,o))),i==kA){4==t&&(e.o=4,hA(14),r=!1),iA(e.j,e.m,null,"[Incomplete Response]");break}if(i==EA){e.o=4,hA(15),iA(e.j,e.m,n,"[Invalid Chunk]"),r=!1;break}iA(e.j,e.m,i,null),MA(e,i)}var s,o,a,c;AA(e)&&i!=kA&&i!=EA&&(e.h.g="",e.C=0),4!=t||0!=n.length||e.h.h||(e.o=1,hA(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),ZN(t),t.L=!0,hA(11))):(iA(e.j,e.m,n,"[Invalid Chunked Response]"),OA(e),DA(e))}function RA(e){e.Y=Date.now()+e.P,PA(e,e.P)}function PA(e,t){if(null!=e.B)throw Error("WatchDog timer not null");e.B=pA(US(e.eb,e),t)}function xA(e){e.B&&(RS.clearTimeout(e.B),e.B=null)}function DA(e){0==e.l.G||e.I||nR(e.l,e)}function OA(e){xA(e);var t=e.L;t&&"function"==typeof t.na&&t.na(),e.L=null,YC(e.W),nA(e.V),e.g&&(t=e.g,e.g=null,t.abort(),t.na())}function MA(e,t){try{var n=e.l;if(0!=n.G&&(n.g==e||fN(n.i,e)))if(n.I=e.N,!e.J&&fN(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;tR(n),$N(n)}XN(n),hA(18)}}else n.ta=i[1],0<n.ta-n.U&&i[2]<37500&&n.N&&0==n.A&&!n.v&&(n.v=pA(US(n.ab,n),6e3));if(pN(n.i)<=1&&n.ka){try{n.ka()}catch(e){}n.ka=void 0}}else iR(n,11)}else if(!e.J&&n.g!=e||tR(n),!HS(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&&(YS(c,"spdy")||YS(c,"quic")||YS(c,"h2"))&&(l.j=l.l,l.g=new Set,l.h&&(gN(l,l.h),l.h=null)),!r.D||(u=g.g?g.g.getResponseHeader("X-HTTP-Session-Id"):null)&&(r.sa=u,HA(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=oR(r,r.H?r.la:null,r.W),f.J?(mN(r.i,f),d=f,(p=r.K)&&d.setTimeout(p),d.B&&(xA(d),RA(d)),r.g=f):JN(r),0<n.l.length&&HN(n)}else"stop"!=s[0]&&"close"!=s[0]||iR(n,7);else 3==n.G&&("stop"==s[0]||"close"==s[0]?"stop"==s[0]?iR(n,7):WN(n):"noop"!=s[0]&&n.j&&n.j.wa(s),n.A=0)}lA()}catch(e){}}function LA(e,t){if(e.forEach&&"function"==typeof e.forEach)e.forEach(t,void 0);else if(xS(e)||"string"==typeof e)$S(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(xS(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(xS(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 FA(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 FA)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 UA(e){if(e.i!=e.g.length){for(var t=0,n=0;t<e.g.length;){var r=e.g[t];jA(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;)jA(i,r=e.g[t])||(i[e.g[n++]=r]=1),t++;e.g.length=n}}function jA(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(ze=wA.prototype).setTimeout=function(e){this.P=e},ze.gb=function(e){e=e.target;const t=this.L;t&&3==UN(e)?t.l():this.Ia(e)},ze.Ia=function(e){try{if(e==this.g)e:{var t=UN(this.g),n=this.g.Da();this.g.ba();if(!(t<3)&&(3!=t||cC||this.g&&(this.h.h||this.g.ga()||jN(this.g)))){this.I||4!=t||7==n||lA(),xA(this);var r=this.g.ba();this.N=r;t:if(AA(this)){var i=jN(this.g);e="";var s=i.length,o=4==UN(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){OA(this),DA(this);var a="";break t}this.h.i=new RS.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)&&!HS(c)){var u=c;break t}}u=null}if(!(r=u)){this.i=!1,this.o=3,hA(12),OA(this),DA(this);break e}iA(this.j,this.m,r,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,MA(this,r)}this.U?(NA(this,t,a),cC&&this.i&&3==t&&(tA(this.V,this.W,"tick",this.fb),this.W.start())):(iA(this.j,this.m,a,null),MA(this,a)),4==t&&OA(this),this.i&&!this.I&&(4==t?nR(this.l,this):(this.i=!1,RA(this)))}else 400==r&&0<a.indexOf("Unknown SID")?(this.o=3,hA(12)):(this.o=0,hA(13)),OA(this),DA(this)}}}catch(e){}var h,d,p,f,g,m,v},ze.fb=function(){var e,t;this.g&&(e=UN(this.g),t=this.g.ga(),this.C<t.length&&(xA(this),NA(this,e,t),this.i&&4!=e&&RA(this)))},ze.cancel=function(){this.I=!0,OA(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&&(lA(),hA(17)),OA(this),this.o=2,DA(this)):PA(this,this.Y-n)},(ze=FA.prototype).R=function(){UA(this);for(var e=[],t=0;t<this.g.length;t++)e.push(this.h[this.g[t]]);return e},ze.T=function(){return UA(this),this.g.concat()},ze.get=function(e,t){return jA(this.h,e)?this.h[e]:t},ze.set=function(e,t){jA(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 qA=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function VA(e,t){var n;this.i=this.s=this.j="",this.m=null,this.o=this.l="",this.g=!1,e instanceof VA?(this.g=void 0!==t?t:e.g,WA(this,e.j),this.s=e.s,$A(this,e.i),KA(this,e.m),this.l=e.l,t=e.h,(n=new rN).i=t.i,t.g&&(n.g=new FA(t.g),n.h=t.h),zA(this,n),this.o=e.o):e&&(n=String(e).match(qA))?(this.g=!!t,WA(this,n[1]||"",!0),this.s=QA(n[2]||""),$A(this,n[3]||"",!0),KA(this,n[4]),this.l=QA(n[5]||"",!0),zA(this,n[6]||"",!0),this.o=QA(n[7]||"")):(this.g=!!t,this.h=new rN(null,this.g))}function BA(e){return new VA(e)}function WA(e,t,n){e.j=n?QA(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function $A(e,t,n){e.i=n?QA(t,!0):t}function KA(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 zA(e,t,n){var r,i;t instanceof rN?(e.h=t,r=e.h,(i=e.g)&&!r.j&&(iN(r),r.i=null,r.g.forEach(function(e,t){var n=t.toLowerCase();t!=n&&(sN(this,t),aN(this,n,e))},r)),r.j=i):(n||(t=YA(t,tN)),e.h=new rN(t,e.g))}function HA(e,t,n){e.h.set(t,n)}function GA(e){return HA(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),e}function QA(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function YA(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,JA),e=n?e.replace(/%25([0-9a-fA-F]{2})/g,"%$1"):e):null}function JA(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}VA.prototype.toString=function(){var e=[],t=this.j;t&&e.push(YA(t,XA,!0),":");var n=this.i;return!n&&"file"!=t||(e.push("//"),(t=this.s)&&e.push(YA(t,XA,!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(YA(n,"/"==n.charAt(0)?eN:ZA,!0))),(n=this.h.toString())&&e.push("?",n),(n=this.o)&&e.push("#",YA(n,nN)),e.join("")};var XA=/[#\/\?@]/g,ZA=/[#\?:]/g,eN=/[#\?]/g,tN=/[#\?@]/g,nN=/#/g;function rN(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function iN(n){n.g||(n.g=new FA,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 sN(e,t){iN(e),t=cN(e,t),jA(e.g.h,t)&&(e.i=null,e.h-=e.g.get(t).length,jA((e=e.g).h,t)&&(delete e.h[t],e.i--,e.g.length>2*e.i&&UA(e)))}function oN(e,t){return iN(e),t=cN(e,t),jA(e.g.h,t)}function aN(e,t,n){sN(e,t),0<n.length&&(e.i=null,e.g.set(cN(e,t),zS(n)),e.h+=n.length)}function cN(e,t){return t=String(t),t=e.j?t.toLowerCase():t}(ze=rN.prototype).add=function(e,t){iN(this),this.i=null,e=cN(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){iN(this),this.g.forEach(function(e,t){$S(e,function(e){n.call(r,e,t,this)},this)},this)},ze.T=function(){iN(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){iN(this);var t=[];if("string"==typeof e)oN(this,e)&&(t=KS(t,this.g.get(cN(this,e))));else{e=this.g.R();for(var n=0;n<e.length;n++)t=KS(t,e[n])}return t},ze.set=function(e,t){return iN(this),this.i=null,oN(this,e=cN(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 lN=class{constructor(e,t){this.h=e,this.g=t}};function uN(e){this.l=e||10,e=RS.PerformanceNavigationTiming?0<(e=RS.performance.getEntriesByType("navigation")).length&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):!!(RS.g&&RS.g.Ea&&RS.g.Ea()&&RS.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 hN;function dN(e){return e.h||e.g&&e.g.size>=e.j}function pN(e){return e.h?1:e.g?e.g.size:0}function fN(e,t){return e.h?e.h==t:e.g&&e.g.has(t)}function gN(e,t){e.g?e.g.add(t):e.h=t}function mN(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function vN(t){if(null!=t.h)return t.i.concat(t.h.D);if(null==t.g||0===t.g.size)return zS(t.i);{let e=t.i;for(const n of t.g.values())e=e.concat(n.D);return e}}function yN(){}function _N(){this.g=new yN}function wN(e,t,n,r,i){try{t.onload=null,t.onerror=null,t.onabort=null,t.ontimeout=null,i(r)}catch(e){}}function bN(e){this.l=e.$b||null,this.j=e.ib||!1}function IN(e,t){UC.call(this),this.D=e,this.u=t,this.m=void 0,this.readyState=TN,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}uN.prototype.cancel=function(){if(this.i=vN(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()}},yN.prototype.stringify=function(e){return RS.JSON.stringify(e,void 0)},yN.prototype.parse=function(e){return RS.JSON.parse(e,void 0)},qS(bN,fA),bN.prototype.g=function(){return new IN(this.l,this.j)},bN.prototype.i=(hN={},function(){return hN}),qS(IN,UC);var TN=0;function EN(e){e.j.read().then(e.Sa.bind(e)).catch(e.ha.bind(e))}function kN(e){e.readyState=4,e.l=null,e.j=null,e.A=null,SN(e)}function SN(e){e.onreadystatechange&&e.onreadystatechange.call(e)}(ze=IN.prototype).open=function(e,t){if(this.readyState!=TN)throw this.abort(),Error("Error reopening a connection");this.C=e,this.B=t,this.readyState=1,SN(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||RS).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,kN(this)),this.readyState=TN},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,SN(this)),this.g&&(this.readyState=3,SN(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Ta.bind(this),this.ha.bind(this));else if(void 0!==RS.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;EN(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?kN:SN)(this),3==this.readyState&&EN(this))},ze.Ua=function(e){this.g&&(this.response=this.responseText=e,kN(this))},ze.Ta=function(e){this.g&&(this.response=e,kN(this))},ze.ha=function(){this.g&&kN(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(IN.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}});var CN=RS.JSON.parse;function AN(e){UC.call(this),this.headers=new FA,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=NN,this.K=this.L=!1}qS(AN,UC);var NN="",RN=/^https?$/i,PN=["POST","PUT"];function xN(e){return"content-type"==e.toLowerCase()}function DN(e,t){e.h=!1,e.g&&(e.l=!0,e.g.abort(),e.l=!1),e.j=t,e.m=5,ON(e),LN(e)}function ON(e){e.D||(e.D=!0,jC(e,"complete"),jC(e,"error"))}function MN(e){if(e.h&&void 0!==NS&&(!e.C[1]||4!=UN(e)||2!=e.ba()))if(e.v&&4==UN(e))JC(e.Fa,0,e);else if(jC(e,"readystatechange"),4==UN(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(qA)[1]||null)&&RS.self&&RS.self.location&&(i=(r=RS.self.location.protocol).substr(0,r.length-1)),n=!RN.test(i?i.toLowerCase():"")),t=n),t)jC(e,"complete"),jC(e,"success");else{e.m=6;try{var a=2<UN(e)?e.g.statusText:""}catch(e){a=""}e.j=a+" ["+e.ba()+"]",ON(e)}}finally{LN(e)}}}function LN(e,t){if(e.g){FN(e);const n=e.g,r=e.C[0]?PS:null;e.g=null,e.C=null,t||jC(e,"ready");try{n.onreadystatechange=r}catch(e){}}}function FN(e){e.g&&e.K&&(e.g.ontimeout=null),e.A&&(RS.clearTimeout(e.A),e.A=null)}function UN(e){return e.g?e.g.readyState:0}function jN(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.J){case NN:case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}function qN(e,t,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=function(e){let n="";return ZS(e,function(e,t){n+=t,n+=":",n+=e,n+="\r\n"}),n}(n),"string"==typeof e?null!=n&&encodeURIComponent(String(n)):HA(e,t,n))}function VN(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function BN(e){this.za=0,this.l=[],this.h=new rA,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=VN("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=VN("baseRetryDelayMs",5e3,e),this.$a=VN("retryDelaySeedMs",1e4,e),this.Ya=VN("forwardChannelMaxRetries",2,e),this.ra=VN("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 uN(e&&e.concurrentRequestLimit),this.Ca=new _N,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 WN(e){var t,n;KN(e),3==e.G&&(t=e.V++,HA(n=BA(e.F),"SID",e.J),HA(n,"RID",t),HA(n,"TYPE","terminate"),QN(e,n),(t=new wA(e,e.h,t,void 0)).K=2,t.v=GA(BA(n)),n=!1,!(n=RS.navigator&&RS.navigator.sendBeacon?RS.navigator.sendBeacon(t.v.toString(),""):n)&&RS.Image&&((new Image).src=t.v,n=!0),n||(t.g=aR(t.l,null),t.g.ea(t.v)),t.F=Date.now(),RA(t)),sR(e)}function $N(e){e.g&&(ZN(e),e.g.cancel(),e.g=null)}function KN(e){$N(e),e.u&&(RS.clearTimeout(e.u),e.u=null),tR(e),e.i.cancel(),e.m&&("number"==typeof e.m&&RS.clearTimeout(e.m),e.m=null)}function zN(e,t){e.l.push(new lN(e.Za++,t)),3==e.G&&HN(e)}function HN(e){dN(e.i)||e.m||(e.m=!0,KC(e.Ha,e),e.C=0)}function GN(e,t){var n=t?t.m:e.V++,r=BA(e.F);HA(r,"SID",e.J),HA(r,"RID",n),HA(r,"AID",e.U),QN(e,r),e.o&&e.s&&qN(r,e.o,e.s),n=new wA(e,e.h,n,e.C+1),null===e.o&&(n.H=e.s),t&&(e.l=t.D.concat(e.l)),t=YN(e,n,1e3),n.setTimeout(Math.round(.5*e.ra)+Math.round(.5*e.ra*Math.random())),gN(e.i,n),SA(n,r,t)}function QN(e,n){e.j&&LA({},function(e,t){HA(n,t,e)})}function YN(e,t,r){r=Math.min(e.l.length,r);var i=e.j?US(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{LA(e,function(e,t){let n=e;DS(e)&&(n=VC(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 JN(e){e.g||e.u||(e.Y=1,KC(e.Ga,e),e.A=0)}function XN(e){return!(e.g||e.u||3<=e.A)&&(e.Y++,e.u=pA(US(e.Ga,e),rR(e,e.A)),e.A++,1)}function ZN(e){null!=e.B&&(RS.clearTimeout(e.B),e.B=null)}function eR(e){e.g=new wA(e,e.h,"rpc",e.Y),null===e.o&&(e.g.H=e.s),e.g.O=0;var t=BA(e.oa);HA(t,"RID","rpc"),HA(t,"SID",e.J),HA(t,"CI",e.N?"0":"1"),HA(t,"AID",e.U),QN(e,t),HA(t,"TYPE","xmlhttp"),e.o&&e.s&&qN(t,e.o,e.s),e.K&&e.g.setTimeout(e.K);var n=e.g;e=e.la,n.K=1,n.v=GA(BA(t)),n.s=null,n.U=!0,CA(n,e)}function tR(e){null!=e.v&&(RS.clearTimeout(e.v),e.v=null)}function nR(e,t){var n,r,i,s=null;if(e.g==t){tR(e),ZN(e),e.g=null;var o=2}else{if(!fN(e.i,t))return;s=t.D,mN(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,jC(o=aA(),new dA(o,s)),HN(e)):JN(e);else if(3==(n=t.o)||0==n&&0<e.I||(1!=o||(i=t,pN((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=pA(US(r.Ha,r,i),rR(r,r.C)),r.C++,0))))&&(2!=o||!XN(e)))switch(s&&0<s.length&&(t=e.i,t.i=t.i.concat(s)),n){case 1:iR(e,5);break;case 4:iR(e,10);break;case 3:iR(e,6);break;default:iR(e,2)}}function rR(e,t){let n=e.Pa+Math.floor(Math.random()*e.$a);return e.j||(n*=2),n*t}function iR(e,t){var n,r;e.h.info("Error code "+t),2==t?(n=null,e.j&&(n=null),r=US(e.jb,e),n||(n=new VA("//www.google.com/images/cleardot.gif"),RS.location&&"http"==RS.location.protocol||WA(n,"https"),GA(n)),function(e,t){var n=new rA;if(RS.Image){const r=new Image;r.onload=jS(wN,n,r,"TestLoadImage: loaded",!0,t),r.onerror=jS(wN,n,r,"TestLoadImage: error",!1,t),r.onabort=jS(wN,n,r,"TestLoadImage: abort",!1,t),r.ontimeout=jS(wN,n,r,"TestLoadImage: timeout",!1,t),RS.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}(n.toString(),r)):hA(2),e.G=0,e.j&&e.j.va(t),sR(e),KN(e)}function sR(e){e.G=0,e.I=-1,e.j&&(0==vN(e.i).length&&0==e.l.length||(e.i.i.length=0,zS(e.l),e.l.length=0),e.j.ua())}function oR(e,t,n){let r=(a=n)instanceof VA?BA(a):new VA(a,void 0);var i,s,o,a,c;return""!=r.i?(t&&$A(r,t+"."+r.i),KA(r,r.m)):(c=RS.location,r=(i=c.protocol,s=t?t+"."+c.hostname:c.hostname,o=+c.port,a=n,c=new VA(null,void 0),i&&WA(c,i),s&&$A(c,s),o&&KA(c,o),a&&(c.l=a),c)),e.aa&&ZS(e.aa,function(e,t){HA(r,t,e)}),t=e.D,n=e.sa,t&&n&&HA(r,t,n),HA(r,"VER",e.ma),QN(e,r),r}function aR(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 AN(new bN({ib:!0})):new AN(e.qa)).L=e.H,t}function cR(){}function lR(){if(oC&&!(10<=Number(mC)))throw Error("Environmental error: no available transport.")}function uR(e,t){UC.call(this),this.g=new BN(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)&&!HS(e)&&(this.g.o=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!HS(t)&&(this.g.D=t,null!==(e=this.h)&&t in e&&(t in(e=this.h)&&delete e[t])),this.j=new pR(this)}function hR(e){vA.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 dR(){yA.call(this),this.status=1}function pR(e){this.g=e}(ze=AN.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||IA).g(),this.C=this.u?gA(this.u):gA(IA),this.g.onreadystatechange=US(this.Fa,this);try{this.F=!0,this.g.open(t,String(e),!0),this.F=!1}catch(e){return void DN(this,e)}e=n||"";const i=new FA(this.headers);r&&LA(r,function(e,t){i.set(t,e)}),r=function(t){e:{var n=xN,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=RS.FormData&&e instanceof RS.FormData,0<=WS(PN,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{FN(this),0<this.B&&((this.K=(s=this.g,oC&&gC()&&"number"==typeof s.timeout&&void 0!==s.ontimeout))?(this.g.timeout=this.B,this.g.ontimeout=US(this.pa,this)):this.A=JC(this.pa,this.B,this)),this.v=!0,this.g.send(e),this.v=!1}catch(e){DN(this,e)}var s},ze.pa=function(){void 0!==NS&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,jC(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,jC(this,"complete"),jC(this,"abort"),LN(this))},ze.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),LN(this,!0)),AN.Z.M.call(this)},ze.Fa=function(){this.s||(this.F||this.v||this.l?MN(this):this.cb())},ze.cb=function(){MN(this)},ze.ba=function(){try{return 2<UN(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)),CN(t)}},ze.Da=function(){return this.m},ze.La=function(){return"string"==typeof this.j?this.j:String(this.j)},(ze=BN.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 wA(this,this.h,t,void 0);let e=this.s;if(this.P&&(e?(e=eC(e),nC(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=YN(this,s,n),HA(r=BA(this.F),"RID",t),HA(r,"CVER",22),this.D&&HA(r,"X-HTTP-Session-Id",this.D),QN(this,r),this.o&&e&&qN(r,this.o,e),gN(this.i,s),this.Ra&&HA(r,"TYPE","init"),this.ja?(HA(r,"$req",n),HA(r,"SID","null"),s.$=!0,SA(s,r,null)):SA(s,r,n),this.G=2}}else 3==this.G&&(t?GN(this,t):0==this.l.length||dN(this.i)||GN(this))},ze.Ga=function(){var e;this.u=null,eR(this),this.$&&!(this.L||null==this.g||this.O<=0)&&(e=2*this.O,this.h.info("BP detection timer enabled: "+e),this.B=pA(US(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,hA(10),$N(this),eR(this))},ze.ab=function(){null!=this.v&&(this.v=null,$N(this),XN(this),hA(19))},ze.jb=function(e){e?(this.h.info("Successfully pinged google.com"),hA(2)):(this.h.info("Failed to ping google.com"),hA(1))},(ze=cR.prototype).xa=function(){},ze.wa=function(){},ze.va=function(){},ze.ua=function(){},ze.Oa=function(){},lR.prototype.g=function(e,t){return new uR(e,t)},qS(uR,UC),uR.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."),KC(US(e.hb,e,t))),hA(0),e.W=t,e.aa=n||{},e.N=e.X,e.F=oR(e,null,e.W),HN(e)},uR.prototype.close=function(){WN(this.g)},uR.prototype.u=function(e){var t;"string"==typeof e?((t={}).__data__=e,zN(this.g,t)):this.v?((t={}).__data__=VC(e),zN(this.g,t)):zN(this.g,e)},uR.prototype.M=function(){this.g.j=null,delete this.j,WN(this.g),delete this.g,uR.Z.M.call(this)},qS(hR,vA),qS(dR,yA),qS(pR,cR),pR.prototype.xa=function(){jC(this.g,"a")},pR.prototype.wa=function(e){jC(this.g,new hR(e))},pR.prototype.va=function(e){jC(this.g,new dR)},pR.prototype.ua=function(){jC(this.g,"b")},lR.prototype.createWebChannel=lR.prototype.g,uR.prototype.send=uR.prototype.u,uR.prototype.open=uR.prototype.m,c.NO_ERROR=0,c.TIMEOUT=8,c.HTTP_ERROR=6,yt.COMPLETE="complete",(mA.EventType=l).OPEN="a",l.CLOSE="b",l.ERROR="c",l.MESSAGE="d",UC.prototype.listen=UC.prototype.N,AN.prototype.listenOnce=AN.prototype.O,AN.prototype.getLastError=AN.prototype.La,AN.prototype.getLastErrorCode=AN.prototype.Da,AN.prototype.getStatus=AN.prototype.ba,AN.prototype.getResponseJson=AN.prototype.Qa,AN.prototype.getResponseText=AN.prototype.ga,AN.prototype.send=AN.prototype.ea;var fR,gR=aA,mR=c,vR=yt,yR=sA,_R=10,wR=11,bR=bN,IR=mA,TR=AN;const ER="@firebase/firestore";class kR{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}}kR.UNAUTHENTICATED=new kR(null),kR.GOOGLE_CREDENTIALS=new kR("google-credentials-uid"),kR.FIRST_PARTY=new kR("first-party-uid"),kR.MOCK_USER=new kR("mock-user");let SR="9.6.2-canary.88d43ec00";const CR=new ep("@firebase/firestore");function AR(){return CR.logLevel}function NR(e,...t){var n;CR.logLevel<=$h.DEBUG&&(n=t.map(xR),CR.debug(`Firestore (${SR}): ${e}`,...n))}function RR(e,...t){var n;CR.logLevel<=$h.ERROR&&(n=t.map(xR),CR.error(`Firestore (${SR}): ${e}`,...n))}function PR(e,...t){var n;CR.logLevel<=$h.WARN&&(n=t.map(xR),CR.warn(`Firestore (${SR}): ${e}`,...n))}function xR(t){if("string"==typeof t)return t;try{return JSON.stringify(t)}catch(e){return t}}function DR(e="Unexpected state"){var t=`FIRESTORE (${SR}) INTERNAL ASSERTION FAILED: `+e;throw RR(t),new Error(t)}function OR(e){e||DR()}const MR={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 LR extends gd{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class FR{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class UR{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class jR{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(kR.UNAUTHENTICATED))}shutdown(){}}class qR{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 VR{constructor(e){this.t=e,this.currentUser=kR.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 FR;this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new FR,t.enqueueRetryable(()=>i(this.currentUser))};const o=()=>{const e=s;t.enqueueRetryable(async()=>{await e.promise,await i(this.currentUser)})},a=e=>{NR("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):(NR("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new FR))},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?(NR("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):e?(OR("string"==typeof e.accessToken),new UR(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 OR(null===e||"string"==typeof e),new kR(e)}}class BR{constructor(e,t,n){this.type="FirstParty",this.user=kR.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 WR{constructor(e,t,n){this.h=e,this.l=t,this.m=n}getToken(){return Promise.resolve(new BR(this.h,this.l,this.m))}start(e,t){e.enqueueRetryable(()=>t(kR.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class $R{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 KR{constructor(e){this.g=e,this.forceRefresh=!1,this.appCheck=null}start(t,n){this.o=e=>{t.enqueueRetryable(()=>(e=>(null!=e.error&&NR("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`),n(e.token)))(e))};const r=e=>{NR("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):NR("FirebaseAppCheckTokenProvider","AppCheck not yet detected"))},0)}getToken(){var e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(OR("string"==typeof e.token),new $R(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}class zR{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}}zR.I=-1;class HR{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 GR(e,t){return e<t?-1:t<e?1:0}function QR(e,n,r){return e.length===n.length&&e.every((e,t)=>r(e,n[t]))}function YR(e){return e+"\0"}class JR{constructor(e,t){if(this.seconds=e,(this.nanoseconds=t)<0)throw new LR(MR.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(1e9<=t)throw new LR(MR.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-62135596800)throw new LR(MR.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(253402300800<=e)throw new LR(MR.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return JR.fromMillis(Date.now())}static fromDate(e){return JR.fromMillis(e.getTime())}static fromMillis(e){var t=Math.floor(e/1e3),n=Math.floor(1e6*(e-1e3*t));return new JR(t,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?GR(this.nanoseconds,e.nanoseconds):GR(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 XR{constructor(e){this.timestamp=e}static fromTimestamp(e){return new XR(e)}static min(){return new XR(new JR(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 ZR(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function eP(e,t){for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function tP(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class nP{constructor(e,t,n){void 0===t?t=0:t>e.length&&DR(),void 0===n?n=e.length-t:n>e.length-t&&DR(),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return 0===nP.comparator(this,e)}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof nP?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 rP extends nP{construct(e,t,n){return new rP(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 LR(MR.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter(e=>0<e.length))}return new rP(t)}static emptyPath(){return new rP([])}}const iP=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class sP extends nP{construct(e,t,n){return new sP(e,t,n)}static isValidIdentifier(e){return iP.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),e=!sP.isValidIdentifier(e)?"`"+e+"`":e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&"__name__"===this.get(0)}static keyField(){return new sP(["__name__"])}static fromServerFormat(e){const t=[];let n="",r=0;var i=()=>{if(0===n.length)throw new LR(MR.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 LR(MR.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const t=e[r+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new LR(MR.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 LR(MR.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new sP(t)}static emptyPath(){return new sP([])}}class oP{constructor(e){(this.fields=e).sort(sP.comparator)}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return QR(this.fields,e.fields,(e,t)=>e.isEqual(t))}}class aP{constructor(e){this.binaryString=e}static fromBase64String(e){var t=atob(e);return new aP(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 aP(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 GR(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}aP.EMPTY_BYTE_STRING=new aP("");const cP=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function lP(t){if(OR(!!t),"string"!=typeof t)return{seconds:uP(t.seconds),nanos:uP(t.nanos)};{let e=0;var n=cP.exec(t);OR(!!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 uP(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function hP(e){return"string"==typeof e?aP.fromBase64String(e):aP.fromUint8Array(e)}function dP(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 pP(e){var t=lP(e.mapValue.fields.__local_write_time__.timestampValue);return new JR(t.seconds,t.nanos)}function fP(e){return null==e}function gP(e){return 0===e&&1/e==-1/0}function mP(e){return"number"==typeof e&&Number.isInteger(e)&&!gP(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}class vP{constructor(e){this.path=e}static fromPath(e){return new vP(rP.fromString(e))}static fromName(e){return new vP(rP.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===rP.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return rP.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new vP(new rP(e.slice()))}}function yP(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?dP(e)?4:10:DR()}function _P(r,i){if(r===i)return!0;var e,t,n=yP(r);if(n!==yP(i))return!1;switch(n){case 0:return!0;case 1:return r.booleanValue===i.booleanValue;case 4:return pP(r).isEqual(pP(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=lP(r.timestampValue),n=lP(e.timestampValue);return t.seconds===n.seconds&&t.nanos===n.nanos}(i);case 5:return r.stringValue===i.stringValue;case 6:return t=i,hP(r.bytesValue).isEqual(hP(t.bytesValue));case 7:return r.referenceValue===i.referenceValue;case 8:return e=i,uP((t=r).geoPointValue.latitude)===uP(e.geoPointValue.latitude)&&uP(t.geoPointValue.longitude)===uP(e.geoPointValue.longitude);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return uP(e.integerValue)===uP(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){var n=uP(e.doubleValue),r=uP(t.doubleValue);return n===r?gP(n)===gP(r):isNaN(n)&&isNaN(r)}return!1}(r,i);case 9:return QR(r.arrayValue.values||[],i.arrayValue.values||[],_P);case 10:return function(e){const t=e.mapValue.fields||{},n=i.mapValue.fields||{};if(ZR(t)!==ZR(n))return!1;for(const e in t)if(t.hasOwnProperty(e)&&(void 0===n[e]||!_P(t[e],n[e])))return!1;return!0}(r);default:return DR()}}function wP(e,t){return void 0!==(e.values||[]).find(e=>_P(e,t))}function bP(e,t){if(e===t)return 0;var n,r,i,s,o=yP(e),a=yP(t);if(o!==a)return GR(o,a);switch(o){case 0:return 0;case 1:return GR(e.booleanValue,t.booleanValue);case 2:return r=t,i=uP(e.integerValue||e.doubleValue),s=uP(r.integerValue||r.doubleValue),i<s?-1:s<i?1:i===s?0:isNaN(i)?isNaN(s)?0:-1:1;case 3:return IP(e.timestampValue,t.timestampValue);case 4:return IP(pP(e),pP(t));case 5:return GR(e.stringValue,t.stringValue);case 6:return function(e,t){const n=hP(e),r=hP(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=GR(n[i],r[i]);if(0!==t)return t}return GR(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return n=e.geoPointValue,r=t.geoPointValue,0!==(s=GR(uP(n.latitude),uP(r.latitude)))?s:GR(uP(n.longitude),uP(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=bP(n[i],r[i]);if(t)return t}return GR(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=GR(r[a],s[a]);if(0!==t)return t;var o=bP(n[r[a]],i[s[a]]);if(0!==o)return o}return GR(r.length,s.length)}(e.mapValue,t.mapValue);default:throw DR()}}function IP(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return GR(e,t);var n=lP(e),r=lP(t),i=GR(n.seconds,r.seconds);return 0!==i?i:GR(n.nanos,r.nanos)}function TP(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=lP(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?hP(e.bytesValue).toBase64():"referenceValue"in e?(t=e.referenceValue,vP.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):DR();var t}(e)}function EP(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function kP(e){return e&&"integerValue"in e}function SP(e){return!!e&&"arrayValue"in e}function CP(e){return e&&"nullValue"in e}function AP(e){return e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function NP(e){return e&&"mapValue"in e}function RP(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 eP(t.mapValue.fields,(e,t)=>n.mapValue.fields[e]=RP(t)),n}if(t.arrayValue){const r={arrayValue:{values:[]}};for(let e=0;e<(t.arrayValue.values||[]).length;++e)r.arrayValue.values[e]=RP(t.arrayValue.values[e]);return r}return Object.assign({},t)}class PP{constructor(e){this.value=e}static empty(){return new PP({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)],!NP(e))return null;return e=(e.mapValue.fields||{})[n.lastSegment()],e||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=RP(t)}setAll(e){let n=sP.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()]=RP(e):i.push(t.lastSegment())});var t=this.getFieldsMap(n);this.applyChanges(t,r,i)}delete(e){const t=this.field(e.popLast());NP(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return _P(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)];NP(e)&&e.mapValue.fields||(e={mapValue:{fields:{}}},n.mapValue.fields[t.get(r)]=e),n=e}return n.mapValue.fields}applyChanges(n,e,t){eP(e,(e,t)=>n[e]=t);for(const e of t)delete n[e]}clone(){return new PP(RP(this.value))}}class xP{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 xP(e,0,XR.min(),PP.empty(),0)}static newFoundDocument(e,t,n){return new xP(e,1,t,n,0)}static newNoDocument(e,t){return new xP(e,2,t,PP.empty(),0)}static newUnknownDocument(e,t){return new xP(e,3,t,PP.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=PP.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=PP.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 xP&&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 xP(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 DP{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 OP(e,t=null,n=[],r=[],i=null,s=null,o=null){return new DP(e,t,n,r,i,s,o)}function MP(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()+TP(e.value)}(e)).join(","),e+="|ob:",e+=t.orderBy.map(e=>function(e){return e.field.canonicalString()+e.dir}(e)).join(","),fP(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=GP(t.startAt)),t.endAt&&(e+="|ub:",e+=GP(t.endAt)),t.R=e}return t.R}function LP(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)||!_P(i.value,s.value))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!JP(e.startAt,t.startAt)&&JP(e.endAt,t.endAt)}function FP(e){return vP.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}class UP 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 jP(e,t,n):"array-contains"===t?new WP(e,n):"in"===t?new $P(e,n):"not-in"===t?new KP(e,n):"array-contains-any"===t?new zP(e,n):new UP(e,t,n)}static P(e,t,n){return new("in"===t?qP:VP)(e,n)}matches(e){var t=e.data.field(this.field);return"!="===this.op?null!==t&&this.v(bP(t,this.value)):null!==t&&yP(this.value)===yP(t)&&this.v(bP(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 DR()}}V(){return 0<=["<","<=",">",">=","!=","not-in"].indexOf(this.op)}}class jP extends UP{constructor(e,t,n){super(e,t,n),this.key=vP.fromName(n.referenceValue)}matches(e){var t=vP.comparator(e.key,this.key);return this.v(t)}}class qP extends UP{constructor(e,t){super(e,"in",t),this.keys=BP(0,t)}matches(t){return this.keys.some(e=>e.isEqual(t.key))}}class VP extends UP{constructor(e,t){super(e,"not-in",t),this.keys=BP(0,t)}matches(t){return!this.keys.some(e=>e.isEqual(t.key))}}function BP(e,t){var n;return((null===(n=t.arrayValue)||void 0===n?void 0:n.values)||[]).map(e=>vP.fromName(e.referenceValue))}class WP extends UP{constructor(e,t){super(e,"array-contains",t)}matches(e){var t=e.data.field(this.field);return SP(t)&&wP(t.arrayValue,this.value)}}class $P extends UP{constructor(e,t){super(e,"in",t)}matches(e){var t=e.data.field(this.field);return null!==t&&wP(this.value.arrayValue,t)}}class KP extends UP{constructor(e,t){super(e,"not-in",t)}matches(e){if(wP(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var t=e.data.field(this.field);return null!==t&&!wP(this.value.arrayValue,t)}}class zP extends UP{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!SP(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>wP(this.value.arrayValue,e))}}class HP{constructor(e,t){this.position=e,this.before=t}}function GP(e){return`${e.before?"b":"a"}:${e.position.map(e=>TP(e)).join(",")}`}class QP{constructor(e,t="asc"){this.field=e,this.dir=t}}function YP(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()?vP.comparator(vP.fromName(o.referenceValue),n.key):bP(o,n.data.field(s.field)),"desc"===s.dir&&(r*=-1),0!==r)break}return e.before?r<=0:r<0}function JP(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(!_P(e.position[n],t.position[n]))return!1;return!0}class XP{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 ZP(e,t,n,r,i,s,o,a){return new XP(e,t,n,r,i,s,o,a)}function ex(e){return new XP(e)}function tx(e){return!fP(e.limit)&&"F"===e.limitType}function nx(e){return!fP(e.limit)&&"L"===e.limitType}function rx(e){return 0<e.explicitOrderBy.length?e.explicitOrderBy[0].field:null}function ix(e){for(const t of e.filters)if(t.V())return t.field;return null}function sx(e){return null!==e.collectionGroup}function ox(t){const n=t;if(null===n.S){n.S=[];const t=ix(n),e=rx(n);if(null!==t&&null===e)t.isKeyField()||n.S.push(new QP(t)),n.S.push(new QP(sP.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 QP(sP.keyField(),t))}}}return n.S}function ax(e){const t=e;if(!t.D)if("F"===t.limitType)t.D=OP(t.path,t.collectionGroup,ox(t),t.filters,t.limit,t.startAt,t.endAt);else{const e=[];for(const i of ox(t)){const t="desc"===i.dir?"asc":"desc";e.push(new QP(i.field,t))}var n=t.endAt?new HP(t.endAt.position,!t.endAt.before):null,r=t.startAt?new HP(t.startAt.position,!t.startAt.before):null;t.D=OP(t.path,t.collectionGroup,e,t.filters,t.limit,n,r)}return t.D}function cx(e,t,n){return new XP(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function lx(e,t){return LP(ax(e),ax(t))&&e.limitType===t.limitType}function ux(e){return`${MP(ax(e))}|lt:${e.limitType}`}function hx(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} ${TP(t.value)}`;var t}).join(", ")}]`),fP(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: "+GP(e.startAt)),e.endAt&&(t+=", endAt: "+GP(e.endAt)),`Target(${t})`}(ax(e))}; limitType=${e.limitType})`}function dx(n,e){return e.isFoundDocument()&&(t=n,i=(r=e).key.path,null!==t.collectionGroup?r.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(i):vP.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||YP(e.startAt,ox(e),t))&&(!e.endAt||!YP(e.endAt,ox(e),t)));var t,r,i}function px(i){return(e,t)=>{let n=!1;for(const r of ox(i)){const i=function(e,i,t){var n=e.field.isKeyField()?vP.comparator(i.key,t.key):function(e,t){var n=i.data.field(e),r=t.data.field(e);return null!==n&&null!==r?bP(n,r):DR()}(e.field,t);switch(e.dir){case"asc":return n;case"desc":return-1*n;default:return DR()}}(r,e,t);if(0!==i)return i;n=n||r.field.isKeyField()}return 0}}function fx(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:gP(t)?"-0":t}}function gx(e){return{integerValue:""+e}}function mx(e,t){return mP(t)?gx(t):fx(e,t)}class vx{constructor(){this._=void 0}}function yx(e,t){return e instanceof Ex?kP(n=t)||n&&"doubleValue"in n?t:{integerValue:0}:null;var n}class _x extends vx{}class wx extends vx{constructor(e){super(),this.elements=e}}function bx(e,t){const n=Sx(t);for(const t of e.elements)n.some(e=>_P(e,t))||n.push(t);return{arrayValue:{values:n}}}class Ix extends vx{constructor(e){super(),this.elements=e}}function Tx(e,t){let n=Sx(t);for(const t of e.elements)n=n.filter(e=>!_P(e,t));return{arrayValue:{values:n}}}class Ex extends vx{constructor(e,t){super(),this.k=e,this.N=t}}function kx(e){return uP(e.integerValue||e.doubleValue)}function Sx(e){return SP(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class Cx{constructor(e,t){this.field=e,this.transform=t}}class Ax{constructor(e,t){this.version=e,this.transformResults=t}}class Nx{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Nx}static exists(e){return new Nx(void 0,e)}static updateTime(e){return new Nx(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 Rx(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class Px{}function xx(e,t,n){e instanceof Lx?function(e,t,n){const r=e.value.clone(),i=jx(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof Fx?function(e,t,n){if(!Rx(e.precondition,t))return t.convertToUnknownDocument(n.version);const r=jx(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(Ux(e)),i.setAll(r),t.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(e,t,n):t.convertToNoDocument(n.version).setHasCommittedMutations()}function Dx(e,t,n){e instanceof Lx?function(e,t,n){if(Rx(e.precondition,t)){const r=e.value.clone(),i=qx(e.fieldTransforms,n,t);r.setAll(i),t.convertToFoundDocument(Mx(t),r).setHasLocalMutations()}}(e,t,n):e instanceof Fx?function(e,t,n){if(Rx(e.precondition,t)){const r=qx(e.fieldTransforms,n,t),i=t.data;i.setAll(Ux(e)),i.setAll(r),t.convertToFoundDocument(Mx(t),i).setHasLocalMutations()}}(e,t,n):(t=t,Rx(e.precondition,t)&&t.convertToNoDocument(XR.min()))}function Ox(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&&QR(n,r,(e,t)=>function(e,t){return e.field.isEqual(t.field)&&(e=e.transform,t=t.transform,e instanceof wx&&t instanceof wx||e instanceof Ix&&t instanceof Ix?QR(e.elements,t.elements,_P):e instanceof Ex&&t instanceof Ex?_P(e.N,t.N):e instanceof _x&&t instanceof _x)}(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 Mx(e){return e.isFoundDocument()?e.version:XR.min()}class Lx extends Px{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}}class Fx extends Px{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 Ux(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 jx(e,t,n){const r=new Map;OR(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 wx?bx(a,c):a instanceof Ix?Tx(a,c):l))}var a,c,l;return r}function qx(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 _x?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 wx?bx(i,s):i instanceof Ix?Tx(i,s):(a=yx(i=i,s),c=kx(a)+kx(i.N),kP(a)&&kP(i.N)?gx(c):fx(i.k,c))))}var i,s,o,a,c;return r}class Vx extends Px{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}}class Bx extends Px{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}}class Wx{constructor(e){this.count=e}}function $x(e){switch(e){default:return DR(),0;case MR.CANCELLED:case MR.UNKNOWN:case MR.DEADLINE_EXCEEDED:case MR.RESOURCE_EXHAUSTED:case MR.INTERNAL:case MR.UNAVAILABLE:case MR.UNAUTHENTICATED:return;case MR.INVALID_ARGUMENT:case MR.NOT_FOUND:case MR.ALREADY_EXISTS:case MR.PERMISSION_DENIED:case MR.FAILED_PRECONDITION:case MR.ABORTED:case MR.OUT_OF_RANGE:case MR.UNIMPLEMENTED:case MR.DATA_LOSS:return 1}}function Kx(e){if(void 0===e)return RR("GRPC error has no .code"),MR.UNKNOWN;switch(e){case fR.OK:return MR.OK;case fR.CANCELLED:return MR.CANCELLED;case fR.UNKNOWN:return MR.UNKNOWN;case fR.DEADLINE_EXCEEDED:return MR.DEADLINE_EXCEEDED;case fR.RESOURCE_EXHAUSTED:return MR.RESOURCE_EXHAUSTED;case fR.INTERNAL:return MR.INTERNAL;case fR.UNAVAILABLE:return MR.UNAVAILABLE;case fR.UNAUTHENTICATED:return MR.UNAUTHENTICATED;case fR.INVALID_ARGUMENT:return MR.INVALID_ARGUMENT;case fR.NOT_FOUND:return MR.NOT_FOUND;case fR.ALREADY_EXISTS:return MR.ALREADY_EXISTS;case fR.PERMISSION_DENIED:return MR.PERMISSION_DENIED;case fR.FAILED_PRECONDITION:return MR.FAILED_PRECONDITION;case fR.ABORTED:return MR.ABORTED;case fR.OUT_OF_RANGE:return MR.OUT_OF_RANGE;case fR.UNIMPLEMENTED:return MR.UNIMPLEMENTED;case fR.DATA_LOSS:return MR.DATA_LOSS;default:return DR()}}(c=fR=fR||{})[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 zx{constructor(e,t){this.comparator=e,this.root=t||Gx.EMPTY}insert(e,t){return new zx(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,Gx.BLACK,null,null))}remove(e){return new zx(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Gx.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 Hx(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Hx(this.root,e,this.comparator,!1)}getReverseIterator(){return new Hx(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Hx(this.root,e,this.comparator,!0)}}class Hx{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 Gx{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:Gx.RED,this.left=null!=r?r:Gx.EMPTY,this.right=null!=i?i:Gx.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,r,i){return new Gx(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 Gx.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 Gx.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,Gx.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){var e=this.copy(null,null,Gx.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 DR();if(this.right.isRed())throw DR();var e=this.left.check();if(e!==this.right.check())throw DR();return e+(this.isRed()?0:1)}}Gx.EMPTY=null,Gx.RED=!0,Gx.BLACK=!1,Gx.EMPTY=new class{constructor(){this.size=0}get key(){throw DR()}get value(){throw DR()}get color(){throw DR()}get left(){throw DR()}get right(){throw DR()}copy(e,t,n,r,i){return this}insert(e,t,n){return new Gx(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 Qx{constructor(e){this.comparator=e,this.data=new zx(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 Yx(this.data.getIterator())}getIteratorFrom(e){return new Yx(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 Qx))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 Qx(this.comparator);return t.data=e,t}}class Yx{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}const Jx=new zx(vP.comparator);const Xx=new zx(vP.comparator);const Zx=new zx(vP.comparator);const eD=new Qx(vP.comparator);function tD(...e){let t=eD;for(const n of e)t=t.add(n);return t}const nD=new Qx(GR);class rD{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,iD.createSynthesizedTargetChangeForCurrentChange(e,t)),new rD(XR.min(),n,nD,Jx,tD())}}class iD{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 iD(aP.EMPTY_BYTE_STRING,t,tD(),tD(),tD())}}class sD{constructor(e,t,n,r){this.$=e,this.removedTargetIds=t,this.key=n,this.O=r}}class oD{constructor(e,t){this.targetId=e,this.M=t}}class aD{constructor(e,t,n=aP.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class cD{constructor(){this.F=0,this.L=hD(),this.B=aP.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=tD(),r=tD(),i=tD();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:DR()}}),new iD(this.B,this.U,n,r,i)}H(){this.q=!1,this.L=hD()}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 lD{constructor(e){this.et=e,this.nt=new Map,this.st=Jx,this.it=uD(),this.rt=new Qx(GR)}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:DR()}})}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(FP(e))if(0===n){const n=new vP(e.path);this.at(t,n,xP.newNoDocument(n,XR.min()))}else OR(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&&FP(n.target)){const i=new vP(n.target.path);null!==this.st.get(i)||this.yt(t,i)||this.at(t,i,xP.newNoDocument(i,r))}e.j&&(i.set(t,e.G()),e.H())}});let s=tD();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 rD(r,i,this.rt,this.st,s);return this.st=Jx,this.it=uD(),this.rt=new Qx(GR),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 cD,this.nt.set(e,t)),t}Tt(e){let t=this.it.get(e);return t||(t=new Qx(GR),this.it=this.it.insert(e,t)),t}lt(e){var t=null!==this.wt(e);return t||NR("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 cD),this.et.getRemoteKeysForTarget(t).forEach(e=>{this.at(t,e,null)})}yt(e,t){return this.et.getRemoteKeysForTarget(e).has(t)}}function uD(){return new zx(vP.comparator)}function hD(){return new zx(vP.comparator)}const dD={asc:"ASCENDING",desc:"DESCENDING"},pD={"<":"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 fD{constructor(e,t){this.databaseId=e,this.C=t}}function gD(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 mD(e,t){return e.C?t.toBase64():t.toUint8Array()}function vD(e){return OR(!!e),XR.fromTimestamp((t=lP(e),new JR(t.seconds,t.nanos)));var t}function yD(e,t){return e=e,new rP(["projects",e.projectId,"databases",e.database]).child("documents").child(t).canonicalString()}function _D(e){var t=rP.fromString(e);return OR(jD(t)),t}function wD(e,t){return yD(e.databaseId,t.path)}function bD(e,t){const n=_D(t);if(n.get(1)!==e.databaseId.projectId)throw new LR(MR.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 LR(MR.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new vP(kD(n))}function ID(e,t){return yD(e.databaseId,t)}function TD(e){var t=_D(e);return 4===t.length?rP.emptyPath():kD(t)}function ED(e){return new rP(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function kD(e){return OR(4<e.length&&"documents"===e.get(4)),e.popFirst(5)}function SD(e,t,n){return{name:wD(e,t),fields:n.value.mapValue.fields}}function CD(e,t,n){const r=bD(e,t.name),i=vD(t.updateTime),s=new PP({mapValue:{fields:t.fields}}),o=xP.newFoundDocument(r,i,s);return n&&o.setHasCommittedMutations(),n?o.setHasCommittedMutations():o}function AD(e,t){let n;if(t instanceof Lx)n={update:SD(e,t.key,t.value)};else if(t instanceof Vx)n={delete:wD(e,t.key)};else if(t instanceof Fx)n={update:SD(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 Bx))return DR();n={verify:wD(e,t.key)}}return 0<t.fieldTransforms.length&&(n.updateTransforms=t.fieldTransforms.map(e=>function(e){var t=e.transform;if(t instanceof _x)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(t instanceof wx)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:t.elements}};if(t instanceof Ix)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:t.elements}};if(t instanceof Ex)return{fieldPath:e.field.canonicalString(),increment:t.N};throw DR()}(e))),t.precondition.isNone||(n.currentDocument=void 0!==(r=t.precondition).updateTime?{updateTime:(t=r.updateTime,gD(e,t.toTimestamp()))}:void 0!==r.exists?{exists:r.exists}:DR()),n;var r}function ND(t,n){const e=n.currentDocument?void 0!==(i=n.currentDocument).updateTime?Nx.updateTime(vD(i.updateTime)):void 0!==i.exists?Nx.exists(i.exists):Nx.none():Nx.none(),r=n.updateTransforms?n.updateTransforms.map(e=>function(e,t){let n=null;if("setToServerValue"in t)OR("REQUEST_TIME"===t.setToServerValue),n=new _x;else if("appendMissingElements"in t){const e=t.appendMissingElements.values||[];n=new wx(e)}else if("removeAllFromArray"in t){const e=t.removeAllFromArray.values||[];n=new Ix(e)}else"increment"in t?n=new Ex(e,t.increment):DR();var r=sP.fromServerFormat(t.fieldPath);return new Cx(r,n)}(t,e)):[];var i;if(n.update){n.update.name;var s=bD(t,n.update.name),o=new PP({mapValue:{fields:n.update.fields}});if(n.updateMask){const t=function(){const e=n.updateMask.fieldPaths||[];return new oP(e.map(e=>sP.fromServerFormat(e)))}();return new Fx(s,o,t,e,r)}return new Lx(s,o,e,r)}if(n.delete){const r=bD(t,n.delete);return new Vx(r,e)}if(n.verify){const r=bD(t,n.verify);return new Bx(r,e)}return DR()}function RD(e,t){return{documents:[ID(e,t.path)]}}function PD(e,t){const n={structuredQuery:{}},r=t.path;null!==t.collectionGroup?(n.parent=ID(e,r),n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(n.parent=ID(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(AP(e.value))return{unaryFilter:{field:MD(e.field),op:"IS_NAN"}};if(CP(e.value))return{unaryFilter:{field:MD(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(AP(e.value))return{unaryFilter:{field:MD(e.field),op:"IS_NOT_NAN"}};if(CP(e.value))return{unaryFilter:{field:MD(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:MD(e.field),op:(t=e.op,pD[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:MD(e.field),direction:(e=e.dir,dD[e])}}(e))}(t.orderBy);i&&(n.structuredQuery.orderBy=i);var s,i=(s=t.limit,e.C||fP(s)?s:{value:s});return null!==i&&(n.structuredQuery.limit=i),t.startAt&&(n.structuredQuery.startAt=DD(t.startAt)),t.endAt&&(n.structuredQuery.endAt=DD(t.endAt)),n}function xD(e){let t=TD(e.parent);const n=e.structuredQuery,r=n.from?n.from.length:0;let i=null;if(0<r){OR(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?[UD(e)]:void 0!==e.fieldFilter?[FD(e)]:void 0!==e.compositeFilter?e.compositeFilter.filters.map(e=>t(e)).reduce((e,t)=>e.concat(t)):DR():[]}(n.where));let o=[];n.orderBy&&(o=n.orderBy.map(e=>function(e){return new QP(LD(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,fP(c="object"==typeof e?e.value:e)?null:c));let l=null;n.startAt&&(l=OD(n.startAt));let u=null;return n.endAt&&(u=OD(n.endAt)),ZP(t,i,o,s,a,"F",l,u)}function DD(e){return{before:e.before,values:e.position}}function OD(e){var t=!!e.before,n=e.values||[];return new HP(n,t)}function MD(e){return{fieldPath:e.canonicalString()}}function LD(e){return sP.fromServerFormat(e.fieldPath)}function FD(e){return UP.create(LD(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 DR()}}(),e.fieldFilter.value)}function UD(e){switch(e.unaryFilter.op){case"IS_NAN":var t=LD(e.unaryFilter.field);return UP.create(t,"==",{doubleValue:NaN});case"IS_NULL":t=LD(e.unaryFilter.field);return UP.create(t,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var n=LD(e.unaryFilter.field);return UP.create(n,"!=",{doubleValue:NaN});case"IS_NOT_NULL":n=LD(e.unaryFilter.field);return UP.create(n,"!=",{nullValue:"NULL_VALUE"});default:return DR()}}function jD(e){return 4<=e.length&&"projects"===e.get(0)&&"databases"===e.get(2)}function qD(e){let t="";for(let n=0;n<e.length;n++)0<t.length&&(t=VD(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 VD(t)}function VD(e){return e+""}function BD(t){const n=t.length;if(OR(2<=n),2===n)return OR(""===t.charAt(0)&&""===t.charAt(1)),rP.emptyPath();const r=n-2,i=[];let s="";for(let o=0;o<n;){const n=t.indexOf("",o);switch((n<0||n>r)&&DR(),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:DR()}o=n+2}return new rP(i)}class WD{constructor(e,t){this.seconds=e,this.nanoseconds=t}}class $D{constructor(e,t,n){this.ownerId=e,this.allowTabSynchronization=t,this.leaseTimestampMs=n}}$D.store="owner",$D.key="owner";class KD{constructor(e,t,n){this.userId=e,this.lastAcknowledgedBatchId=t,this.lastStreamToken=n}}KD.store="mutationQueues",KD.keyPath="userId";class zD{constructor(e,t,n,r,i){this.userId=e,this.batchId=t,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i}}zD.store="mutations",zD.keyPath="batchId",zD.userMutationsIndex="userMutationsIndex",zD.userMutationsKeyPath=["userId","batchId"];class HD{constructor(){}static prefixForUser(e){return[e]}static prefixForPath(e,t){return[e,qD(t)]}static key(e,t,n){return[e,qD(t),n]}}HD.store="documentMutations",HD.PLACEHOLDER=new HD;class GD{constructor(e,t){this.path=e,this.readTime=t}}class QD{constructor(e,t){this.path=e,this.version=t}}class YD{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}}YD.store="remoteDocuments",YD.readTimeIndex="readTimeIndex",YD.readTimeIndexPath="readTime",YD.collectionReadTimeIndex="collectionReadTimeIndex",YD.collectionReadTimeIndexPath=["parentPath","readTime"];class JD{constructor(e){this.byteSize=e}}JD.store="remoteDocumentGlobal",JD.key="remoteDocumentGlobalKey";class XD{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}}XD.store="targets",XD.keyPath="targetId",XD.queryTargetsIndexName="queryTargetsIndex",XD.queryTargetsKeyPath=["canonicalId","targetId"];class ZD{constructor(e,t,n){this.targetId=e,this.path=t,this.sequenceNumber=n}}ZD.store="targetDocuments",ZD.keyPath=["targetId","path"],ZD.documentTargetsIndex="documentTargetsIndex",ZD.documentTargetsKeyPath=["path","targetId"];class eO{constructor(e,t,n,r){this.highestTargetId=e,this.highestListenSequenceNumber=t,this.lastRemoteSnapshotVersion=n,this.targetCount=r}}eO.key="targetGlobalKey",eO.store="targetGlobal";class tO{constructor(e,t){this.collectionId=e,this.parent=t}}tO.store="collectionParents",tO.keyPath=["collectionId","parent"];class nO{constructor(e,t,n,r){this.clientId=e,this.updateTimeMs=t,this.networkEnabled=n,this.inForeground=r}}nO.store="clientMetadata",nO.keyPath="clientId";class rO{constructor(e,t,n){this.bundleId=e,this.createTime=t,this.version=n}}rO.store="bundles",rO.keyPath="bundleId";class iO{constructor(e,t,n){this.name=e,this.readTime=t,this.bundledQuery=n}}iO.store="namedQueries",iO.keyPath="name";const sO=[KD.store,zD.store,HD.store,YD.store,XD.store,$D.store,eO.store,ZD.store,nO.store,JD.store,tO.store,rO.store,iO.store],oO="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class aO{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}class cO{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&&DR(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(i,this.error):this.wrapSuccess(r,this.result):new cO((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 cO?t:cO.resolve(t)}catch(e){return cO.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):cO.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):cO.reject(t)}static resolve(n){return new cO((e,t)=>{e(n)})}static reject(n){return new cO((e,t)=>{t(n)})}static waitFor(e){return new cO((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=cO.resolve(!1);for(const n of e)t=t.next(e=>e?cO.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 lO{constructor(n,e){this.action=n,this.transaction=e,this.aborted=!1,this.It=new FR,this.transaction.oncomplete=()=>{this.It.resolve()},this.transaction.onabort=()=>{e.error?this.It.reject(new dO(n,e.error)):this.It.resolve()},this.transaction.onerror=e=>{var t=vO(e.target.error);this.It.reject(new dO(n,t))}}static open(e,t,n,r){try{return new lO(t,e.transaction(r,n))}catch(e){throw new dO(t,e)}}get At(){return this.It.promise}abort(e){e&&this.It.reject(e),this.aborted||(NR("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 fO(t)}}class uO{constructor(e,t,n){this.name=e,this.version=t,this.Rt=n,12.2===uO.bt(sd())&&RR("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 NR("SimpleDb","Removing database:",e),gO(window.indexedDB.deleteDatabase(e)).toPromise()}static Pt(){if(!dd())return!1;if(uO.vt())return!0;const e=sd(),t=uO.bt(e),n=0<t&&t<10,r=uO.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||(NR("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 dO(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 LR(MR.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 LR(MR.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 dO(s,t))},i.onupgradeneeded=e=>{NR("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(()=>{NR("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=lO.open(this.db,e,i?"readonly":"readwrite",n),s=r(t).catch(e=>(t.abort(e),cO.reject(e))).toPromise();return s.catch(()=>{}),await t.At,s}catch(e){const t="FirebaseError"!==e.name&&s<3;if(NR("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 hO{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 gO(this.$t.delete())}}class dO extends LR{constructor(e,t){super(MR.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function pO(e){return"IndexedDbTransactionError"===e.name}class fO{constructor(e){this.store=e}put(e,t){let n;return n=void 0!==t?(NR("SimpleDb","PUT",this.store.name,e,t),this.store.put(t,e)):(NR("SimpleDb","PUT",this.store.name,"<auto-key>",e),this.store.put(e)),gO(n)}add(e){return NR("SimpleDb","ADD",this.store.name,e,e),gO(this.store.add(e))}get(t){return gO(this.store.get(t)).next(e=>(NR("SimpleDb","GET",this.store.name,t,e=void 0===e?null:e),e))}delete(e){return NR("SimpleDb","DELETE",this.store.name,e),gO(this.store.delete(e))}count(){return NR("SimpleDb","COUNT",this.store.name),gO(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){NR("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 cO((n,r)=>{e.onerror=e=>{var t=vO(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 cO((i,t)=>{e.onerror=e=>{t(e.target.error)},e.onsuccess=e=>{const t=e.target.result;if(t){const n=new hO(t),r=s(t.primaryKey,t.value,n);if(r instanceof cO){const e=r.catch(e=>(n.done(),cO.reject(e)));o.push(e)}n.isDone?i():null===n.Ft?t.continue():t.continue(n.Ft)}else i()}}).next(()=>cO.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 gO(e){return new cO((n,r)=>{e.onsuccess=e=>{var t=e.target.result;n(t)},e.onerror=e=>{var t=vO(e.target.error);r(t)}})}let mO=!1;function vO(e){const t=uO.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 LR("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 mO||(mO=!0,setTimeout(()=>{throw e},0)),e}}return e}class yO extends aO{constructor(e,t){super(),this.Wt=e,this.currentSequenceNumber=t}}function _O(e,t){var n=e;return uO.Dt(n.Wt,t)}class wO{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)&&xx(i,e,n[r])}}applyToLocalView(e){for(const t of this.baseMutations)t.key.isEqual(e.key)&&Dx(t,e,this.localWriteTime);for(const n of this.mutations)n.key.isEqual(e.key)&&Dx(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(XR.min())})}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),tD())}isEqual(e){return this.batchId===e.batchId&&QR(this.mutations,e.mutations,(e,t)=>Ox(e,t))&&QR(this.baseMutations,e.baseMutations,(e,t)=>Ox(e,t))}}class bO{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(e,t,n){OR(e.mutations.length===n.length);let r=Zx;var i=e.mutations;for(let s=0;s<i.length;s++)r=r.insert(i[s].key,n[s].version);return new bO(e,t,n,r)}}class IO{constructor(e,t,n,r,i=XR.min(),s=XR.min(),o=aP.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 IO(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)}withResumeToken(e,t){return new IO(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e)}withLastLimboFreeSnapshotVersion(e){return new IO(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken)}}class TO{constructor(e){this.Gt=e}}function EO(e,t){if(t.document)return CD(e.Gt,t.document,!!t.hasCommittedMutations);if(t.noDocument){const e=vP.fromSegments(t.noDocument.path),n=NO(t.noDocument.readTime),r=xP.newNoDocument(e,n);return t.hasCommittedMutations?r.setHasCommittedMutations():r}if(t.unknownDocument){const e=vP.fromSegments(t.unknownDocument.path),i=NO(t.unknownDocument.version);return xP.newUnknownDocument(e,i)}return DR()}function kO(e,t,n){var r=SO(n),i=t.key.path.popLast().toArray();if(t.isFoundDocument()){const s={name:wD(n=e.Gt,(e=t).key),fields:e.data.value.mapValue.fields,updateTime:gD(n,e.version.toTimestamp())},o=t.hasCommittedMutations;return new YD(null,null,s,o,r,i)}if(t.isNoDocument()){const a=t.key.path.toArray(),s=AO(t.version),c=t.hasCommittedMutations;return new YD(null,new GD(a,s),null,c,r,i)}if(t.isUnknownDocument()){const a=t.key.path.toArray(),s=AO(t.version);return new YD(new QD(a,s),null,null,!0,r,i)}return DR()}function SO(e){var t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function CO(e){var t=new JR(e[0],e[1]);return XR.fromTimestamp(t)}function AO(e){var t=e.toTimestamp();return new WD(t.seconds,t.nanoseconds)}function NO(e){var t=new JR(e.seconds,e.nanoseconds);return XR.fromTimestamp(t)}function RO(t,e){const n=(e.baseMutations||[]).map(e=>ND(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=>ND(t.Gt,e)),i=JR.fromMillis(e.localWriteTimeMs);return new wO(e.batchId,i,n,r)}function PO(e){var t,n=NO(e.readTime),r=void 0!==e.lastLimboFreeSnapshotVersion?NO(e.lastLimboFreeSnapshotVersion):XR.min();let i;return i=void 0!==e.query.documents?(OR(1===(t=e.query).documents.length),ax(ex(TD(t.documents[0])))):ax(xD(e.query)),new IO(i,e.targetId,0,e.lastListenSequenceNumber,n,r,aP.fromBase64String(e.resumeToken))}function xO(e,t){var n=AO(t.snapshotVersion),r=AO(t.lastLimboFreeSnapshotVersion),i=(FP(t.target)?RD:PD)(e.Gt,t.target),s=t.resumeToken.toBase64();return new XD(t.targetId,MP(t.target),n,s,t.sequenceNumber,r,i)}function DO(e){var t=xD({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?cx(t,t.limit,"L"):t}class OO{getBundleMetadata(e,t){return MO(e).get(t).next(e=>{if(e)return{id:(t=e).bundleId,createTime:NO(t.createTime),version:t.version};var t})}saveBundleMetadata(e,t){return MO(e).put({bundleId:(n=t).id,createTime:AO(vD(n.createTime)),version:n.version});var n}getNamedQuery(e,t){return LO(e).get(t).next(e=>{if(e)return{name:(t=e).name,query:DO(t.bundledQuery),readTime:NO(t.readTime)};var t})}saveNamedQuery(e,t){return LO(e).put({name:(t=t).name,readTime:AO(vD(t.readTime)),bundledQuery:t.bundledQuery})}}function MO(e){return _O(e,rO.store)}function LO(e){return _O(e,iO.store)}class FO{constructor(){this.zt=new UO}addToCollectionParentIndex(e,t){return this.zt.add(t),cO.resolve()}getCollectionParents(e,t){return cO.resolve(this.zt.getEntries(t))}}class UO{constructor(){this.index={}}add(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new Qx(rP.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 Qx(rP.comparator)).toArray()}}class jO{constructor(){this.Ht=new UO}addToCollectionParentIndex(e,t){if(this.Ht.has(t))return cO.resolve();var n=t.lastSegment(),r=t.popLast();e.addOnCommittedListener(()=>{this.Ht.add(t)});r={collectionId:n,parent:qD(r)};return qO(e).put(r)}getCollectionParents(e,n){const r=[],t=IDBKeyRange.bound([n,""],[YR(n),""],!1,!0);return qO(e).Bt(t).next(e=>{for(const t of e){if(t.collectionId!==n)break;r.push(BD(t.parent))}return r})}}function qO(e){return _O(e,tO.store)}const VO={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class BO{constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}static withCacheSize(e){return new BO(e,BO.DEFAULT_COLLECTION_PERCENTILE,BO.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}function WO(e,t,n){const r=e.store(zD.store),i=e.store(HD.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(()=>{OR(1===a)}));const l=[];for(const e of n.mutations){const r=HD.key(t,e.key.path,n.batchId);s.push(i.delete(r)),l.push(e.key)}return cO.waitFor(s).next(()=>l)}function $O(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 DR();t=e.noDocument}return JSON.stringify(t).length}BO.DEFAULT_COLLECTION_PERCENTILE=10,BO.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,BO.DEFAULT=new BO(41943040,BO.DEFAULT_COLLECTION_PERCENTILE,BO.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),BO.DISABLED=new BO(-1,0,0);class KO{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){OR(""!==e.uid);var i=e.isAuthenticated()?e.uid:"";return new KO(i,t,n,r)}checkEmpty(e){let r=!0;var t=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return HO(e).jt({index:zD.userMutationsIndex,range:t},(e,t,n)=>{r=!1,n.done()}).next(()=>r)}addMutationBatch(u,h,d,p){const f=GO(u),g=HO(u);return g.add({}).next(e=>{OR("number"==typeof e);const t=new wO(e,h,d,p),n=(i=this.k,s=this.userId,o=t,a=o.baseMutations.map(e=>AD(i.Gt,e)),c=o.mutations.map(e=>AD(i.Gt,e)),new zD(s,o.batchId,o.localWriteTime.toMillis(),a,c)),r=[];var i,s,o,a,c;let l=new Qx((e,t)=>GR(e.canonicalString(),t.canonicalString()));for(const u of p){const h=HD.key(this.userId,u.key.path,e);l=l.add(u.key.path.popLast()),r.push(g.put(n)),r.push(f.put(h,HD.PLACEHOLDER))}return l.forEach(e=>{r.push(this.Jt.addToCollectionParentIndex(u,e))}),u.addOnCommittedListener(()=>{this.Yt[e]=t.keys()}),cO.waitFor(r).next(()=>t)})}lookupMutationBatch(e,t){return HO(e).get(t).next(e=>e?(OR(e.userId===this.userId),RO(this.k,e)):null)}Zt(e,n){return this.Yt[n]?cO.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 HO(e).jt({index:zD.userMutationsIndex,range:n},(e,t,n)=>{t.userId===this.userId&&(OR(t.batchId>=r),i=RO(this.k,t)),n.done()}).next(()=>i)}getHighestUnacknowledgedBatchId(e){var t=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let r=-1;return HO(e).jt({index:zD.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 HO(e).Bt(zD.userMutationsIndex,t).next(e=>e.map(e=>RO(this.k,e)))}getAllMutationBatchesAffectingDocumentKey(o,a){const e=HD.prefixForPath(this.userId,a.path),t=IDBKeyRange.lowerBound(e),c=[];return GO(o).jt({range:t},(e,t,n)=>{var[r,i,s]=e,i=BD(i);if(r===this.userId&&a.path.isEqual(i))return HO(o).get(s).next(e=>{if(!e)throw DR();OR(e.userId===this.userId),c.push(RO(this.k,e))});n.done()}).next(()=>c)}getAllMutationBatchesAffectingDocumentKeys(t,e){let a=new Qx(GR);const n=[];return e.forEach(o=>{var e=HD.prefixForPath(this.userId,o.path),e=IDBKeyRange.lowerBound(e),e=GO(t).jt({range:e},(e,t,n)=>{var[r,i,s]=e,i=BD(i);r===this.userId&&o.path.isEqual(i)?a=a.add(s):n.done()});n.push(e)}),cO.waitFor(n).next(()=>this.te(t,a))}getAllMutationBatchesAffectingQuery(e,t){const o=t.path,a=o.length+1,n=HD.prefixForPath(this.userId,o),r=IDBKeyRange.lowerBound(n);let c=new Qx(GR);return GO(e).jt({range:r},(e,t,n)=>{var[r,i,s]=e,i=BD(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(HO(t).get(e).next(e=>{if(null===e)throw DR();OR(e.userId===this.userId),n.push(RO(this.k,e))}))}),cO.waitFor(r).next(()=>n)}removeMutationBatch(t,n){return WO(t.Wt,this.userId,n).next(e=>(t.addOnCommittedListener(()=>{this.ee(n.batchId)}),cO.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 cO.resolve();const t=IDBKeyRange.lowerBound(HD.prefixForUser(this.userId)),r=[];return GO(n).jt({range:t},(e,t,n)=>{if(e[0]===this.userId){const t=BD(e[1]);r.push(t)}else n.done()}).next(()=>{OR(0===r.length)})})}containsKey(e,t){return zO(e,this.userId,t)}ne(e){return QO(e).get(this.userId).next(e=>e||new KD(this.userId,-1,""))}}function zO(e,s,t){const n=HD.prefixForPath(s,t.path),o=n[1],r=IDBKeyRange.lowerBound(n);let a=!1;return GO(e).jt({range:r,Kt:!0},(e,t,n)=>{var[r,i]=e;r===s&&i===o&&(a=!0),n.done()}).next(()=>a)}function HO(e){return _O(e,zD.store)}function GO(e){return _O(e,HD.store)}function QO(e){return _O(e,KD.store)}class YO{constructor(e){this.se=e}next(){return this.se+=2,this.se}static ie(){return new YO(0)}static re(){return new YO(-1)}}class JO{constructor(e,t){this.referenceDelegate=e,this.k=t}allocateTargetId(n){return this.oe(n).next(e=>{const t=new YO(e.highestTargetId);return e.highestTargetId=t.next(),this.ce(n,e).next(()=>e.highestTargetId)})}getLastRemoteSnapshotVersion(e){return this.oe(e).next(e=>XR.fromTimestamp(new JR(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(()=>XO(t).delete(e.targetId)).next(()=>this.oe(t)).next(e=>(OR(0<e.targetCount),--e.targetCount,this.ce(t,e)))}removeTargets(r,i,s){let o=0;const a=[];return XO(r).jt((e,t)=>{var n=PO(t);n.sequenceNumber<=i&&null===s.get(n.targetId)&&(o++,a.push(this.removeTargetData(r,n)))}).next(()=>cO.waitFor(a)).next(()=>o)}forEachTarget(e,r){return XO(e).jt((e,t)=>{var n=PO(t);r(n)})}oe(e){return ZO(e).get(eO.key).next(e=>(OR(null!==e),e))}ce(e,t){return ZO(e).put(eO.key,t)}ae(e,t){return XO(e).put(xO(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=MP(i),t=IDBKeyRange.bound([t,Number.NEGATIVE_INFINITY],[t,Number.POSITIVE_INFINITY]);let s=null;return XO(e).jt({range:t,index:XD.queryTargetsIndexName},(e,t,n)=>{var r=PO(t);LP(i,r.target)&&(s=r,n.done())}).next(()=>s)}addMatchingKeys(n,e,r){const i=[],s=e1(n);return e.forEach(e=>{var t=qD(e.path);i.push(s.put(new ZD(r,t))),i.push(this.referenceDelegate.addReference(n,r,e))}),cO.waitFor(i)}removeMatchingKeys(n,e,r){const i=e1(n);return cO.forEach(e,e=>{var t=qD(e.path);return cO.waitFor([i.delete([r,t]),this.referenceDelegate.removeReference(n,r,e)])})}removeMatchingKeysForTargetId(e,t){const n=e1(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=e1(e);let i=tD();return r.jt({range:n,Kt:!0},(e,t,n)=>{var r=BD(e[1]),r=new vP(r);i=i.add(r)}).next(()=>i)}containsKey(e,t){var n=qD(t.path),n=IDBKeyRange.bound([n],[YR(n)],!1,!0);let r=0;return e1(e).jt({index:ZD.documentTargetsIndex,Kt:!0,range:n},([e],t,n)=>{0!==e&&(r++,n.done())}).next(()=>0<r)}Et(e,t){return XO(e).get(t).next(e=>e?PO(e):null)}}function XO(e){return _O(e,XD.store)}function ZO(e){return _O(e,eO.store)}function e1(e){return _O(e,ZD.store)}async function t1(e){if(e.code!==MR.FAILED_PRECONDITION||e.message!==oO)throw e;NR("LocalStore","Unexpectedly lost primary lease")}function n1([e,t],[n,r]){var i=GR(e,n);return 0===i?GR(t,r):i}class r1{constructor(e){this.he=e,this.buffer=new Qx(n1),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();n1(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class i1{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;NR("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){pO(e)?NR("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e):await t1(e)}await this.me(e)})}}class s1{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 cO.resolve(zR.I);const n=new r1(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?(NR("LruGarbageCollector","Garbage collection skipped; disabled"),cO.resolve(VO)):this.getCacheSize(t).next(e=>e<this.params.cacheSizeCollectionThreshold?(NR("LruGarbageCollector",`Garbage collection skipped; Cache size ${e} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),VO):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?(NR("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(),AR()<=$h.DEBUG&&NR("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`),cO.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:s,documentsRemoved:e})))}}class o1{constructor(e,t){this.db=e,this.garbageCollector=(e=this,t=t,new s1(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 a1(e,n)}removeReference(e,t,n){return a1(e,n)}removeTargets(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}markPotentiallyOrphaned(e,t){return a1(e,t)}Ae(t,n){let r=!1;return QO(t).Qt(e=>zO(t,e,n).next(e=>(e&&(r=!0),cO.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),e1(n).delete([0,qD(t.path)])))});s.push(r)}}).next(()=>cO.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 a1(e,t)}Ie(e,r){const t=e1(e);let i,s=zR.I;return t.jt({index:ZD.documentTargetsIndex},([e],{path:t,sequenceNumber:n})=>{0===e?(s!==zR.I&&r(new vP(BD(i)),s),s=n,i=t):s=zR.I}).next(()=>{s!==zR.I&&r(new vP(BD(i)),s)})}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function a1(e,t){return e1(e).put((t=t,e=e.currentSequenceNumber,new ZD(0,qD(t.path),e)))}class c1{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){eP(this.inner,(e,t)=>{for(const[e,n]of t)r(e,n)})}isEmpty(){return tP(this.inner)}}class l1{constructor(){this.changes=new c1(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}getReadTime(e){var t=this.changes.get(e);return t?t.readTime:XR.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:xP.newInvalidDocument(e),readTime:t})}getEntry(e,t){this.assertNotApplied();var n=this.changes.get(t);return void 0!==n?cO.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 u1{constructor(e,t){this.k=e,this.Jt=t}addEntry(e,t,n){return p1(e).put(f1(t),n)}removeEntry(e,t){const n=p1(e),r=f1(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 p1(e).get(f1(t)).next(e=>this.be(t,e))}Pe(e,t){return p1(e).get(f1(t)).next(e=>({document:this.be(t,e),size:$O(e)}))}getEntries(e,t){let r=Jx;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=Jx,i=new zx(vP.comparator);return this.ve(e,t,(e,t)=>{var n=this.be(e,t);r=r.insert(e,n),i=i.insert(e,$O(t))}).next(()=>({documents:r,Se:i}))}ve(e,t,i){if(t.isEmpty())return cO.resolve();const n=IDBKeyRange.bound(t.first().path.toArray(),t.last().path.toArray()),s=t.getIterator();let o=s.getNext();return p1(e).jt({range:n},(e,t,n)=>{for(var r=vP.fromSegments(e);o&&vP.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=Jx;const o=i.path.length+1,n={};if(t.isEqual(XR.min())){const e=i.path.toArray();n.range=IDBKeyRange.lowerBound(e)}else{const e=i.path.toArray(),s=SO(t);n.range=IDBKeyRange.lowerBound([e,s],!0),n.index=YD.collectionReadTimeIndex}return p1(e).jt(n,(e,t,n)=>{var r;e.length===o&&(r=EO(this.k,t),i.path.isPrefixOf(r.key.path)?dx(i,r)&&(s=s.insert(r.key,r)):n.done())}).next(()=>s)}newChangeBuffer(e){return new h1(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next(e=>e.byteSize)}getMetadata(e){return d1(e).get(JD.key).next(e=>(OR(!!e),e))}Re(e,t){return d1(e).put(JD.key,t)}be(e,t){if(t){const e=EO(this.k,t);if(!e.isNoDocument()||!e.version.isEqual(XR.min()))return e}return xP.newInvalidDocument(e)}}class h1 extends l1{constructor(e,t){super(),this.De=e,this.trackRemovals=t,this.Ce=new c1(e=>e.toString(),(e,t)=>e.isEqual(t))}applyChanges(s){const o=[];let a=0,c=new Qx((e,t)=>GR(e.canonicalString(),t.canonicalString()));return this.changes.forEach((e,t)=>{var n=this.Ce.get(e);if(t.document.isValidDocument()){var r=kO(this.De.k,t.document,this.getReadTime(e));c=c.add(e.path.popLast());var i=$O(r);a+=i-n,o.push(this.De.addEntry(s,e,r))}else if(a-=n,this.trackRemovals){const a=kO(this.De.k,xP.newNoDocument(e,XR.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)),cO.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 d1(e){return _O(e,JD.store)}function p1(e){return _O(e,YD.store)}function f1(e){return e.path.toArray()}class g1{constructor(e){this.k=e}Nt(t,n,e,r){OR(e<r&&0<=e&&r<=11);const i=new lO("createOrUpgrade",n);var s;e<1&&1<=r&&(t.createObjectStore($D.store),(s=t).createObjectStore(KD.store,{keyPath:KD.keyPath}),s.createObjectStore(zD.store,{keyPath:zD.keyPath,autoIncrement:!0}).createIndex(zD.userMutationsIndex,zD.userMutationsKeyPath,{unique:!0}),s.createObjectStore(HD.store),m1(t),t.createObjectStore(YD.store));let o=cO.resolve();return e<3&&3<=r&&(0!==e&&((s=t).deleteObjectStore(ZD.store),s.deleteObjectStore(XD.store),s.deleteObjectStore(eO.store),m1(t)),o=o.next(()=>function(){const e=i.store(eO.store),t=new eO(0,0,XR.min().toTimestamp(),0);return e.put(eO.key,t)}())),e<4&&4<=r&&(0!==e&&(o=o.next(()=>function(r,i){return i.store(zD.store).Bt().next(e=>{r.deleteObjectStore(zD.store),r.createObjectStore(zD.store,{keyPath:zD.keyPath,autoIncrement:!0}).createIndex(zD.userMutationsIndex,zD.userMutationsKeyPath,{unique:!0});const t=i.store(zD.store),n=e.map(e=>t.put(e));return cO.waitFor(n)})}(t,i))),o=o.next(()=>{t.createObjectStore(nO.store,{keyPath:nO.keyPath})})),e<5&&5<=r&&(o=o.next(()=>this.Ne(i))),e<6&&6<=r&&(o=o.next(()=>(t.createObjectStore(JD.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(YD.store);e.createIndex(YD.readTimeIndex,YD.readTimeIndexPath,{unique:!1}),e.createIndex(YD.collectionReadTimeIndex,YD.collectionReadTimeIndexPath,{unique:!1})}()})),e<10&&10<=r&&(o=o.next(()=>this.Oe(i))),e<11&&11<=r&&(o=o.next(()=>{t.createObjectStore(rO.store,{keyPath:rO.keyPath}),t.createObjectStore(iO.store,{keyPath:iO.keyPath})})),o}ke(t){let n=0;return t.store(YD.store).jt((e,t)=>{n+=$O(t)}).next(()=>{var e=new JD(n);return t.store(JD.store).put(JD.key,e)})}Ne(r){const e=r.store(KD.store),t=r.store(zD.store);return e.Bt().next(e=>cO.forEach(e,n=>{var e=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return t.Bt(zD.userMutationsIndex,e).next(e=>cO.forEach(e,e=>{OR(e.userId===n.userId);var t=RO(this.k,e);return WO(r,n.userId,t).next(()=>{})}))}))}xe(e){const o=e.store(ZD.store),t=e.store(YD.store);return e.store(eO.store).get(eO.key).next(i=>{const s=[];return t.jt((e,t)=>{const n=new rP(e),r=[0,qD(n)];s.push(o.get(r).next(e=>e?cO.resolve():(e=>o.put(new ZD(0,qD(e),i.highestListenSequenceNumber)))(n)))}).next(()=>cO.waitFor(s))})}$e(e,t){e.createObjectStore(tO.store,{keyPath:tO.keyPath});const n=t.store(tO.store),r=new UO,i=e=>{if(r.add(e)){const t=e.lastSegment(),r=e.popLast();return n.put({collectionId:t,parent:qD(r)})}};return t.store(YD.store).jt({Kt:!0},(e,t)=>{const n=new rP(e);return i(n.popLast())}).next(()=>t.store(HD.store).jt({Kt:!0},([,e],t)=>{const n=BD(e);return i(n.popLast())}))}Oe(e){const r=e.store(XD.store);return r.jt((e,t)=>{var n=PO(t),n=xO(this.k,n);return r.put(n)})}}function m1(e){e.createObjectStore(ZD.store,{keyPath:ZD.keyPath}).createIndex(ZD.documentTargetsIndex,ZD.documentTargetsKeyPath,{unique:!0}),e.createObjectStore(XD.store,{keyPath:XD.keyPath}).createIndex(XD.queryTargetsIndexName,XD.queryTargetsKeyPath,{unique:!0}),e.createObjectStore(eO.store)}const v1="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 y1{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(),!y1.Pt())throw new LR(MR.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new o1(this,r),this.Ge=t+"main",this.k=new TO(a),this.ze=new uO(this.Ge,11,new g1(this.k)),this.He=new JO(this.referenceDelegate,this.k),this.Jt=new jO,this.Je=(t=this.k,a=this.Jt,new u1(t,a)),this.Ye=new OO,this.window&&this.window.localStorage?this.Xe=this.window.localStorage:(this.Xe=null,!1===l&&RR("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 LR(MR.FAILED_PRECONDITION,v1);return this.tn(),this.en(),this.nn(),this.runTransaction("getHighestListenSequenceNumber","readonly",e=>this.He.getHighestSequenceNumber(e))}).then(e=>{this.Be=new zR(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=>w1(t).put(new nO(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(pO(e))return NR("IndexedDbPersistence","Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return NR("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 _1(e).get($D.key).next(e=>cO.resolve(this.un(e)))}hn(e){return w1(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=_O(e,nO.store);return r.Bt().next(e=>{const t=this.dn(e,18e5),n=e.filter(e=>-1===t.indexOf(e));return cO.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?cO.resolve(!0):_1(t).get($D.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 LR(MR.FAILED_PRECONDITION,v1);return!1}}return!(!this.networkEnabled||!this.inForeground)||w1(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&&NR("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",[$D.store,nO.store],e=>{const t=new yO(e,zR.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=>w1(e).Bt().next(e=>this.dn(e,18e5).map(e=>e.clientId)))}get started(){return this.Ue}getMutationQueue(e){return KO.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){NR("IndexedDbPersistence","Starting transaction:",t);let i;return this.ze.runTransaction(t,"readonly"===n?"readonly":"readwrite",sO,e=>(i=new yO(e,this.Be?this.Be.next():zR.I),"readwrite-primary"===n?this.rn(i).next(e=>!!e||this.on(i)).next(e=>{if(!e)throw RR(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.Me.enqueueRetryable(()=>this.We(!1)),new LR(MR.FAILED_PRECONDITION,oO);return r(i)}).next(e=>this.an(i).next(()=>e)):this.En(i).next(()=>r(i)))).then(e=>(i.raiseOnCommittedEvent(),e))}En(e){return _1(e).get($D.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 LR(MR.FAILED_PRECONDITION,v1)})}an(e){var t=new $D(this.clientId,this.allowTabSynchronization,Date.now());return _1(e).put($D.key,t)}static Pt(){return uO.Pt()}cn(e){const t=_1(e);return t.get($D.key).next(e=>this.un(e)?(NR("IndexedDbPersistence","Releasing primary lease."),t.delete($D.key)):cO.resolve())}fn(e,t){var n=Date.now();return!(e<n-t||n<e&&(RR(`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 NR("IndexedDbPersistence",`Client '${e}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(e){return RR("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){RR("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 _1(e){return _O(e,$D.store)}function w1(e){return _O(e,nO.store)}function b1(e,t){let n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}class I1{constructor(e,t){this.progress=e,this.In=t}}class T1{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,vP.isDocumentKey(r.path)&&null===r.collectionGroup&&0===r.filters.length?this.Sn(e,t.path):sx(t)?this.Dn(e,t,n):this.Cn(e,t,n);var r}Sn(e,t){return this.Rn(e,new vP(t)).next(e=>{let t=Xx;return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}Dn(r,i,s){const o=i.collectionGroup;let a=Xx;return this.Jt.getCollectionParents(r,o).next(e=>cO.forEach(e,e=>{var t,n=(t=i,e=e.child(o),new XP(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=xP.newInvalidDocument(n),i=i.insert(n,e)),Dx(r,e,t.localWriteTime),e.isFoundDocument()||(i=i.remove(n))}}))).next(()=>(i.forEach((e,t)=>{dx(n,t)||(i=i.remove(e))}),i))}Nn(e,t,n){let r=tD();for(const e of t)for(const t of e.mutations)t instanceof Fx&&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 E1{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.kn=n,this.xn=r}static $n(e,t){let n=tD(),r=tD();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 E1(e,t.fromCache,n,r)}}class k1{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(XR.min())?this.Fn(t,r):this.Mn.vn(t,s).next(e=>{const n=this.Ln(r,e);return(tx(r)||nx(r))&&this.Bn(r.limitType,n,s,i)?this.Fn(t,r):(AR()<=$h.DEBUG&&NR("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),hx(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 Qx(px(n));return e.forEach((e,t)=>{dx(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 AR()<=$h.DEBUG&&NR("QueryEngine","Using full collection scan to execute query:",hx(t)),this.Mn.getDocumentsMatchingQuery(e,t,XR.min())}}class S1{constructor(e,t,n,r){this.persistence=e,this.Un=t,this.k=r,this.qn=new zx(GR),this.Kn=new c1(e=>MP(e),LP),this.jn=XR.min(),this.An=e.getMutationQueue(n),this.Qn=e.getRemoteDocumentCache(),this.He=e.getTargetCache(),this.Wn=new T1(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 C1(e,t,n,r){return new S1(e,t,n,r)}async function A1(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 T1(n.Qn,r,n.persistence.getIndexManager()),r.getAllMutationBatches(i))).next(e=>{const t=[],n=[];let r=tD();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 N1(e){const t=e;return t.persistence.runTransaction("Get last remote snapshot version","readonly",e=>t.He.getLastRemoteSnapshotVersion(e))}function R1(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(aP.EMPTY_BYTE_STRING,XR.min()).withLastLimboFreeSnapshotVersion(XR.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=Jx;if(l.documentUpdates.forEach((e,t)=>{l.resolvedLimboDocuments.has(e)&&c.push(u.persistence.referenceDelegate.updateLimboDocument(a,e))}),c.push(P1(a,e,l.documentUpdates,h,void 0).next(e=>{t=e})),!h.isEqual(XR.min())){const l=u.He.getLastRemoteSnapshotVersion(a).next(e=>u.He.setTargetsMetadata(a,a.currentSequenceNumber,h));c.push(l)}return cO.waitFor(c).next(()=>e.apply(a)).next(()=>u.Wn.Vn(a,t)).next(()=>t)}).then(e=>(u.qn=d,e))}function P1(e,o,t,a,c){let n=tD();return t.forEach(e=>n=n.add(e)),o.getEntries(e,n).next(i=>{let s=Jx;return t.forEach((e,t)=>{const n=i.get(e),r=(null==c?void 0:c.get(e))||a;t.isNoDocument()&&t.version.isEqual(XR.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)):NR("LocalStore","Ignoring outdated watch update for ",e,". Current version:",n.version," Watch version:",t.version)}),s})}function x1(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,cO.resolve(n)):i.He.allocateTargetId(t).next(e=>(n=new IO(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 D1(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(!pO(e))throw e;NR("LocalStore",`Failed to update sequence numbers for target ${t}: ${e}`)}r.qn=r.qn.remove(t),r.Kn.delete(i.target)}function O1(e,n,r){const i=e;let s=XR.min(),o=tD();return i.persistence.runTransaction("Execute query","readonly",t=>function(e,t,n){const r=e,i=r.Kn.get(n);return void 0!==i?cO.resolve(r.qn.get(i)):r.He.getTargetData(t,n)}(i,t,ax(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:XR.min(),r?o:tD())).next(e=>({documents:e,zn:o})))}function M1(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 L1(e){const n=e;return n.persistence.runTransaction("Get new document changes","readonly",e=>function(e,t,n){const r=e;let i=Jx,s=SO(n);const o=p1(t),a=IDBKeyRange.lowerBound(s,!0);return o.jt({index:YD.readTimeIndex,range:a},(e,t)=>{var n=EO(r.k,t);i=i.insert(n.key,n),s=t.readTime}).next(()=>({In:i,readTime:CO(s)}))}(n.Qn,e,n.jn)).then(({In:e,readTime:t})=>(n.jn=t,e))}class F1{constructor(e){this.k=e,this.Xn=new Map,this.Zn=new Map}getBundleMetadata(e,t){return cO.resolve(this.Xn.get(t))}saveBundleMetadata(e,t){return this.Xn.set(t.id,{id:t.id,version:t.version,createTime:vD(t.createTime)}),cO.resolve()}getNamedQuery(e,t){return cO.resolve(this.Zn.get(t))}saveNamedQuery(e,t){return this.Zn.set(t.name,{name:(t=t).name,query:DO(t.bundledQuery),readTime:vD(t.readTime)}),cO.resolve()}}class U1{constructor(){this.ts=new Qx(j1.es),this.ns=new Qx(j1.ss)}isEmpty(){return this.ts.isEmpty()}addReference(e,t){var n=new j1(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 j1(e,t))}cs(e,t){e.forEach(e=>this.removeReference(e,t))}us(e){const t=new vP(new rP([])),n=new j1(t,e),r=new j1(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 vP(new rP([])),n=new j1(t,e),t=new j1(t,e+1);let r=tD();return this.ns.forEachInRange([n,t],e=>{r=r.add(e.key)}),r}containsKey(e){var t=new j1(e,0),t=this.ts.firstAfterOrEqual(t);return null!==t&&e.isEqual(t.key)}}class j1{constructor(e,t){this.key=e,this.fs=t}static es(e,t){return vP.comparator(e.key,t.key)||GR(e.fs,t.fs)}static ss(e,t){return GR(e.fs,t.fs)||vP.comparator(e.key,t.key)}}class q1{constructor(e,t){this.Jt=e,this.referenceDelegate=t,this.An=[],this.ds=1,this.ws=new Qx(j1.es)}checkEmpty(e){return cO.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 wO(i,t,n,r);this.An.push(s);for(const t of r)this.ws=this.ws.add(new j1(t.key,i)),this.Jt.addToCollectionParentIndex(e,t.key.path.popLast());return cO.resolve(s)}lookupMutationBatch(e,t){return cO.resolve(this._s(t))}getNextMutationBatchAfterBatchId(e,t){var n=this.gs(t+1),n=n<0?0:n;return cO.resolve(this.An.length>n?this.An[n]:null)}getHighestUnacknowledgedBatchId(){return cO.resolve(0===this.An.length?-1:this.ds-1)}getAllMutationBatches(e){return cO.resolve(this.An.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const n=new j1(t,0),r=new j1(t,Number.POSITIVE_INFINITY),i=[];return this.ws.forEachInRange([n,r],e=>{var t=this._s(e.fs);i.push(t)}),cO.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new Qx(GR);return t.forEach(e=>{var t=new j1(e,0),n=new j1(e,Number.POSITIVE_INFINITY);this.ws.forEachInRange([t,n],e=>{r=r.add(e.fs)})}),cO.resolve(this.ys(r))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,r=n.length+1;let i=n;vP.isDocumentKey(i)||(i=i.child(""));var s=new j1(new vP(i),0);let o=new Qx(GR);return this.ws.forEachWhile(e=>{var t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.fs)),!0)},s),cO.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){OR(0===this.ps(r.batchId,"removed")),this.An.shift();let i=this.ws;return cO.forEach(r.mutations,e=>{var t=new j1(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 j1(t,0),n=this.ws.firstAfterOrEqual(n);return cO.resolve(t.isEqual(n&&n.key))}performConsistencyCheck(e){return this.An.length,cO.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 V1{constructor(e,t){this.Jt=e,this.Ts=t,this.docs=new zx(vP.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 cO.resolve(n?n.document.mutableCopy():xP.newInvalidDocument(t))}getEntries(e,t){let n=Jx;return t.forEach(e=>{const t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():xP.newInvalidDocument(e))}),cO.resolve(n)}getDocumentsMatchingQuery(e,t,n){let r=Jx;const i=new vP(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||dx(t,i)&&(r=r.insert(i.key,i.mutableCopy()))}return cO.resolve(r)}Es(e,t){return cO.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new B1(this)}getSize(e){return cO.resolve(this.size)}}class B1 extends l1{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)}),cO.waitFor(r)}getFromCache(e,t){return this.De.getEntry(e,t)}getAllFromCache(e,t){return this.De.getEntries(e,t)}}class W1{constructor(e){this.persistence=e,this.Is=new c1(e=>MP(e),LP),this.lastRemoteSnapshotVersion=XR.min(),this.highestTargetId=0,this.As=0,this.Rs=new U1,this.targetCount=0,this.bs=YO.ie()}forEachTarget(e,n){return this.Is.forEach((e,t)=>n(t)),cO.resolve()}getLastRemoteSnapshotVersion(e){return cO.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return cO.resolve(this.As)}allocateTargetId(e){return this.highestTargetId=this.bs.next(),cO.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.As&&(this.As=t),cO.resolve()}ae(e){this.Is.set(e.target,e);var t=e.targetId;t>this.highestTargetId&&(this.bs=new YO(t),this.highestTargetId=t),e.sequenceNumber>this.As&&(this.As=e.sequenceNumber)}addTargetData(e,t){return this.ae(t),this.targetCount+=1,cO.resolve()}updateTargetData(e,t){return this.ae(t),cO.resolve()}removeTargetData(e,t){return this.Is.delete(t.target),this.Rs.us(t.targetId),--this.targetCount,cO.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++)}),cO.waitFor(o).next(()=>s)}getTargetCount(e){return cO.resolve(this.targetCount)}getTargetData(e,t){var n=this.Is.get(t)||null;return cO.resolve(n)}addMatchingKeys(e,t,n){return this.Rs.rs(t,n),cO.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))}),cO.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.Rs.us(t),cO.resolve()}getMatchingKeysForTargetId(e,t){var n=this.Rs.ls(t);return cO.resolve(n)}containsKey(e,t){return cO.resolve(this.Rs.containsKey(t))}}class $1{constructor(e,t){var n;this.Ps={},this.Be=new zR(0),this.Ue=!1,this.Ue=!0,this.referenceDelegate=e(this),this.He=new W1(this),this.Jt=new FO,this.Je=(n=this.Jt,e=e=>this.referenceDelegate.vs(e),new V1(n,e)),this.k=new TO(t),this.Ye=new F1(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 q1(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){NR("MemoryPersistence","Starting transaction:",e);const r=new K1(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 cO.or(Object.values(this.Ps).map(e=>()=>e.containsKey(t,n)))}}class K1 extends aO{constructor(e){super(),this.currentSequenceNumber=e}}class z1{constructor(e){this.persistence=e,this.Cs=new U1,this.Ns=null}static ks(e){return new z1(e)}get xs(){if(this.Ns)return this.Ns;throw DR()}addReference(e,t,n){return this.Cs.addReference(n,t),this.xs.delete(n.toString()),cO.resolve()}removeReference(e,t,n){return this.Cs.removeReference(n,t),this.xs.add(n.toString()),cO.resolve()}markPotentiallyOrphaned(e,t){return this.xs.add(t.toString()),cO.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 cO.forEach(this.xs,e=>{const t=vP.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 cO.or([()=>cO.resolve(this.Cs.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ds(e,t)])}}function H1(e,t){return`firestore_clients_${e}_${t}`}function G1(e,t,n){let r=`firestore_mutations_${e}_${n}`;return t.isAuthenticated()&&(r+=`_${t.uid}`),r}function Q1(e,t){return`firestore_targets_${e}_${t}`}class Y1{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 LR(r.error.code,r.error.message))),s?new Y1(e,t,r.state,i):(RR("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 J1{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 LR(n.error.code,n.error.message))),i?new J1(e,n.state,r):(RR("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 X1{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=nD;for(let s=0;r&&s<n.activeTargetIds.length;++s)r=mP(n.activeTargetIds[s]),i=i.add(n.activeTargetIds[s]);return r?new X1(e,i):(RR("SharedClientState",`Failed to parse client data for instance '${e}': ${t}`),null)}}class Z1{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 Z1(t.clientId,t.onlineState):(RR("SharedClientState",`Failed to parse online state: ${e}`),null)}}class eM{constructor(){this.activeTargetIds=nD}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 tM{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 zx(GR),this.started=!1,this.js=[];var s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Qs=H1(this.persistenceKey,this.Bs),this.Ws=`firestore_sequence_number_${this.persistenceKey}`,this.Ks=this.Ks.insert(this.Bs,new eM),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(H1(this.persistenceKey,n));var t;!e||(t=X1.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(Q1(this.persistenceKey,e)))||(n=J1.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(Q1(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 NR("SharedClientState","READ",e,t),t}setItem(e,t){NR("SharedClientState","SET",e,t),this.storage.setItem(e,t)}removeItem(e){NR("SharedClientState","REMOVE",e),this.storage.removeItem(e)}qs(e){const r=e;r.storageArea===this.storage&&(NR("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=zR.I;if(null!=e)try{var n=JSON.parse(e);OR("number"==typeof n),t=n}catch(e){RR("SharedClientState","Failed to read sequence number from WebStorage",e)}return t}(r.newValue);n!==zR.I&&this.sequenceNumberHandler(n)}else if(r.key===this.Ys)return this.syncEngine._i()}else this.js.push(r)}):RR("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 Y1(this.currentUser,e,t,n),i=G1(this.persistenceKey,this.currentUser,e);this.setItem(i,r.Ms())}si(e){var t=G1(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=Q1(this.persistenceKey,e),i=new J1(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 X1.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 Y1.Os(new kR(n),r,t)}di(e,t){var n=this.Hs.exec(e),n=Number(n[1]);return J1.Os(n,t)}Zs(e){return Z1.Os(e)}async fi(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.mi(e.batchId,e.state,e.error);NR("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=nD;return e.forEach((e,t)=>{n=n.unionWith(t.activeTargetIds)}),n}}class nM{constructor(){this.pi=new eM,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 eM,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(){}}class rM{Ei(e){}shutdown(){}}class iM{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(){NR("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.Pi)e(0)}bi(){NR("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 sM={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"};class oM{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 aM 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);NR("RestConnection","Sending: ",s,n);var o={};return this.qi(o,r,i),this.Ki(t,s,o,n).then(e=>(NR("RestConnection","Received: ",e),e),e=>{throw PR("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/"+SR,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=sM[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 TR;o.listenOnce(vR.COMPLETE,()=>{try{switch(o.getLastErrorCode()){case mR.NO_ERROR:var e=o.getResponseJson();NR("Connection","XHR received:",JSON.stringify(e)),i(e);break;case mR.TIMEOUT:NR("Connection",'RPC "'+a+'" timed out'),s(new LR(MR.DEADLINE_EXCEEDED,"Request time out"));break;case mR.HTTP_ERROR:var t,n=o.getStatus();if(NR("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(MR).indexOf(r)?r:MR.UNKNOWN,s(new LR(t,a.message))):s(new LR(MR.UNKNOWN,"Server responded with status "+o.getStatus()))}else s(new LR(MR.UNAVAILABLE,"Connection failed."));break;default:DR()}}finally{NR("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 lR,s=gR(),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 bR({})),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("");NR("Connection","Creating WebChannel: "+a,o);const c=i.createWebChannel(a,o);let l=!1,u=!1;const h=new oM({Vi:e=>{u?NR("Connection","Not sending because WebChannel is closed:",e):(l||(NR("Connection","Opening WebChannel transport."),c.open(),l=!0),NR("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,IR.EventType.OPEN,()=>{u||NR("Connection","WebChannel transport opened.")}),d(c,IR.EventType.CLOSE,()=>{u||(u=!0,NR("Connection","WebChannel transport closed"),h.Oi())}),d(c,IR.EventType.ERROR,e=>{u||(u=!0,PR("Connection","WebChannel transport errored:",e),h.Oi(new LR(MR.UNAVAILABLE,"The operation could not be completed")))}),d(c,IR.EventType.MESSAGE,n=>{if(!u){var e=n.data[0];OR(!!e);var r=e.error||(null===(r=e[0])||void 0===r?void 0:r.error);if(r){NR("Connection","WebChannel received error:",r);const n=r.status;let e=function(e){var t=fR[e];if(void 0!==t)return Kx(t)}(n),t=r.message;void 0===e&&(e=MR.INTERNAL,t="Unknown error status: "+n+" with message "+r.message),u=!0,h.Oi(new LR(e,t)),c.close()}else NR("Connection","WebChannel received:",e),h.Mi(e)}}),d(s,yR.STAT_EVENT,e=>{e.stat===_R?NR("Connection","Detected buffering proxy"):e.stat===wR&&NR("Connection","Detected no buffering proxy")}),setTimeout(()=>{h.$i()},0),h}}function cM(){return"undefined"!=typeof window?window:null}function lM(){return"undefined"!=typeof document?document:null}function uM(e){return new fD(e,!0)}class hM{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&&NR("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 dM{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 hM(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===MR.RESOURCE_EXHAUSTED?(RR(t.toString()),RR("Using maximum backoff delay to prevent overloading the backend."),this.ur.Xi()):t&&t.code===MR.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 LR(MR.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 NR("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}Er(t){return e=>{this.Me.enqueueAndForget(()=>this.rr===t?e():(NR("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class pM extends dM{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:DR(),i=t.targetChange.targetIds||[],s=(p=t.targetChange.resumeToken,e.C?(OR(void 0===p||"string"==typeof p),aP.fromBase64String(p||"")):(OR(void 0===p||p instanceof Uint8Array),aP.fromUint8Array(p||new Uint8Array))),o=t.targetChange.cause,a=o&&(a=void 0===(p=o).code?MR.UNKNOWN:Kx(p.code),new LR(a,p.message||""));n=new aD(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=bD(e,c.document.name),l=vD(c.document.updateTime),u=new PP({mapValue:{fields:c.document.fields}}),l=xP.newFoundDocument(a,l,u),u=c.targetIds||[],c=c.removedTargetIds||[];n=new sD(u,c,l.key,l)}else if("documentDelete"in t){t.documentDelete;u=t.documentDelete;u.document;c=bD(e,u.document),l=u.readTime?vD(u.readTime):XR.min(),l=xP.newNoDocument(c,l),u=u.removedTargetIds||[];n=new sD([],u,l.key,l)}else if("documentRemove"in t){t.documentRemove;var h=t.documentRemove;h.document;var d=bD(e,h.document),h=h.removedTargetIds||[];n=new sD([],h,d,null)}else{if(!("filter"in t))return DR();{t.filter;const e=t.filter;e.targetId;h=e.count||0,d=new Wx(h),h=e.targetId;n=new oD(h,d)}}var a,p;return n}(this.k,e),n=function(e){if(!("targetChange"in e))return XR.min();var t=e.targetChange;return(!t.targetIds||!t.targetIds.length)&&t.readTime?vD(t.readTime):XR.min()}(e);return this.listener.br(t,n)}Pr(e){const t={};t.database=ED(this.k),t.addTarget=function(e,t){let n;var r=t.target;return n=FP(r)?{documents:RD(e,r)}:{query:PD(e,r)},n.targetId=t.targetId,0<t.resumeToken.approximateByteSize()?n.resumeToken=mD(e,t.resumeToken):0<t.snapshotVersion.compareTo(XR.min())&&(n.readTime=gD(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 DR()}}())?null:{"goog-listen-tags":r});r&&(t.labels=r),this.gr(t)}vr(e){const t={};t.database=ED(this.k),t.removeTarget=e,this.gr(t)}}class fM extends dM{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(OR(!!e.streamToken),this.lastStreamToken=e.streamToken,this.Vr){this.ur.reset();var t=(r=e.writeResults,i=e.commitTime,r&&0<r.length?(OR(void 0!==i),r.map(e=>function(e,t){let n=e.updateTime?vD(e.updateTime):vD(t);return n.isEqual(XR.min())&&(n=vD(t)),new Ax(n,e.transformResults||[])}(e,i))):[]),n=vD(e.commitTime);return this.listener.Cr(n,t)}var r,i;return OR(!e.writeResults||0===e.writeResults.length),this.Vr=!0,this.listener.Nr()}kr(){const e={};e.database=ED(this.k),this.gr(e)}Dr(e){var t={streamToken:this.lastStreamToken,writes:e.map(e=>AD(this.k,e))};this.gr(t)}}class gM 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 LR(MR.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===MR.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new LR(MR.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===MR.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new LR(MR.UNKNOWN,e.toString())})}terminate(){this.$r=!0}}class mM{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?(RR(t),this.Lr=!1):NR("OnlineStateTracker",t)}jr(){null!==this.Fr&&(this.Fr.cancel(),this.Fr=null)}}class vM{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()=>{SM(this)&&(NR("RemoteStore","Restarting streams for network reachability change."),await async function(e){const t=e;t.Gr.add(4),await _M(t),t.Jr.set("Unknown"),t.Gr.delete(4),await yM(t)}(this))})}),this.Jr=new mM(n,r)}}async function yM(e){if(SM(e))for(const t of e.zr)await t(!0)}async function _M(e){for(const t of e.zr)await t(!1)}function wM(e,t){const n=e;n.Wr.has(t.targetId)||(n.Wr.set(t.targetId,t),kM(n)?EM(n):OM(n).lr()&&IM(n,t))}function bM(e,t){const n=e,r=OM(n);n.Wr.delete(t),r.lr()&&TM(n,t),0===n.Wr.size&&(r.lr()?r._r():SM(n)&&n.Jr.set("Unknown"))}function IM(e,t){e.Yr.X(t.targetId),OM(e).Pr(t)}function TM(e,t){e.Yr.X(t),OM(e).vr(t)}function EM(t){t.Yr=new lD({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),Et:e=>t.Wr.get(e)||null}),OM(t).start(),t.Jr.Br()}function kM(e){return SM(e)&&!OM(e).hr()&&0<e.Wr.size}function SM(e){return 0===e.Gr.size}function CM(e){e.Yr=void 0}async function AM(e,t,n){if(!pO(t))throw t;e.Gr.add(1),await _M(e),e.Jr.set("Offline"),n=n||(()=>N1(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{NR("RemoteStore","Retrying IndexedDB access"),await n(),e.Gr.delete(1),await yM(e)})}function NM(t,n){return n().catch(e=>AM(t,e,n))}async function RM(e){const t=e,n=MM(t);let r=0<t.Qr.length?t.Qr[t.Qr.length-1].batchId:-1;for(;SM(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=MM(e);n.lr()&&n.Sr&&n.Dr(t.mutations)}(t,e)}catch(e){await AM(t,e)}var i;PM(t)&&xM(t)}function PM(e){return SM(e)&&!MM(e).hr()&&0<e.Qr.length}function xM(e){MM(e).start()}async function DM(e,t){const n=e;t?(n.Gr.delete(2),await yM(n)):(n.Gr.add(2),await _M(n),n.Jr.set("Unknown"))}function OM(t){return t.Xr||(t.Xr=function(e,t,n){const r=e;return r.Or(),new pM(t,r.ir,r.authCredentials,r.appCheckCredentials,r.k,n)}(t.datastore,t.asyncQueue,{Di:(async function(n){n.Wr.forEach((e,t)=>{IM(n,e)})}).bind(null,t),Ni:(async function(e,t){CM(e),kM(e)?(e.Jr.Kr(t),EM(e)):e.Jr.set("Unknown")}).bind(null,t),br:(async function(e,r,t){if(e.Jr.set("Online"),r instanceof aD&&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){NR("RemoteStore","Failed to remove targets %s: %s ",r.targetIds.join(","),t),await AM(e,t)}else if(r instanceof sD?e.Yr.ot(r):r instanceof oD?e.Yr.dt(r):e.Yr.ut(r),!t.isEqual(XR.min()))try{const r=await N1(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(aP.EMPTY_BYTE_STRING,t.snapshotVersion)),TM(r,e),n=new IO(t.target,e,1,t.sequenceNumber),IM(r,n))}),r.remoteSyncer.applyRemoteEvent(e)}(e,t)}catch(r){NR("RemoteStore","Failed to raise snapshot:",r),await AM(e,r)}}).bind(null,t)}),t.zr.push(async e=>{e?(t.Xr.wr(),kM(t)?EM(t):t.Jr.set("Unknown")):(await t.Xr.stop(),CM(t))})),t.Xr}function MM(t){return t.Zr||(t.Zr=function(e,t,n){const r=e;return r.Or(),new fM(t,r.ir,r.authCredentials,r.appCheckCredentials,r.k,n)}(t.datastore,t.asyncQueue,{Di:(async function(e){MM(e).kr()}).bind(null,t),Ni:(async function(e,t){t&&MM(e).Sr&&await async function(e,t){if($x(n=t.code)&&n!==MR.ABORTED){const n=e.Qr.shift();MM(e).wr(),await NM(e,()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t)),await RM(e)}var n}(e,t),PM(e)&&xM(e)}).bind(null,t),Nr:(async function(e){const t=MM(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=bO.from(r,t,n);await NM(e,()=>e.remoteSyncer.applySuccessfulWrite(i)),await RM(e)}).bind(null,t)}),t.zr.push(async e=>{e?(t.Zr.wr(),await RM(t)):(await t.Zr.stop(),0<t.Qr.length&&(NR("RemoteStore",`Stopping write stream with ${t.Qr.length} pending writes`),t.Qr=[]))})),t.Zr}class LM{constructor(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new FR,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 LM(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 LR(MR.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 FM(e,t){if(RR("AsyncQueue",`${t}: ${e}`),pO(e))return new LR(MR.UNAVAILABLE,`${t}: ${e}`);throw e}class UM{constructor(n){this.comparator=n?(e,t)=>n(e,t)||vP.comparator(e.key,t.key):(e,t)=>vP.comparator(e.key,t.key),this.keyedMap=Xx,this.sortedSet=new zx(this.comparator)}static emptySet(e){return new UM(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 UM))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 UM;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}class jM{constructor(){this.eo=new zx(vP.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}):DR()}no(){const n=[];return this.eo.inorderTraversal((e,t)=>{n.push(t)}),n}}class qM{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 qM(e,t,UM.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)&&lx(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 VM{constructor(){this.so=void 0,this.listeners=[]}}class BM{constructor(){this.queries=new c1(e=>ux(e),lx),this.onlineState="Unknown",this.io=new Set}}async function WM(e,t){const n=e,r=t.query;let i=!1,s=n.queries.get(r);if(s||(i=!0,s=new VM),i)try{s.so=await n.onListen(r)}catch(e){const n=FM(e,`Initialization of query '${hx(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)&&KM(n)}async function $M(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 KM(e){e.io.forEach(e=>{e.next()})}class zM{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 qM(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=qM.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache),this.ao=!0,this.co.next(e)}}class HM{constructor(e,t){this.payload=e,this.byteLength=t}_o(){return"metadata"in this.payload}}class GM{constructor(e){this.k=e}Hn(e){return bD(this.k,e)}Jn(e){return e.metadata.exists?CD(this.k,e.document,!1):xP.newNoDocument(this.Hn(e.metadata.name),this.Yn(e.metadata.readTime))}Yn(e){return vD(e)}}class QM{constructor(e,t,n){this.mo=e,this.localStore=t,this.k=n,this.queries=[],this.documents=[],this.progress=YM(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 GM(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)||tD()).add(e);t.set(n,r)}}return t}async complete(){const e=await async function(e,t,n,r){const i=e;let s=tD(),o=Jx,a=Zx;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 x1(i,(r=r,ax(ex(rP.fromString(`__bundle__/docs/${r}`)))));return i.persistence.runTransaction("Apply bundle documents","readwrite",t=>P1(t,c,o,XR.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 GM(this.k),this.documents,this.mo.id),t=this.po(this.documents);for(const e of this.queries)await async function(e,n,r=tD()){const i=await x1(e,ax(DO(n.bundledQuery))),s=e;return s.persistence.runTransaction("Save named query","readwrite",e=>{var t=vD(n.readTime);if(0<=i.snapshotVersion.compareTo(t))return s.Ye.saveNamedQuery(e,n);t=i.withResumeToken(aP.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 I1(Object.assign({},this.progress),e)}}function YM(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}class JM{constructor(e){this.key=e}}class XM{constructor(e){this.key=e}}class ZM{constructor(e,t){this.query=e,this.To=t,this.Eo=null,this.current=!1,this.Io=tD(),this.mutatedKeys=tD(),this.Ao=px(e),this.Ro=new UM(this.Ao)}get bo(){return this.To}Po(e,t){const a=t?t.vo:new jM,c=(t||this).Ro;let l=(t||this).mutatedKeys,u=c,h=!1;const d=tx(this.query)&&c.size===this.query.limit?c.last():null,p=nx(this.query)&&c.size===this.query.limit?c.first():null;if(e.inorderTraversal((e,t)=>{const n=c.get(e),r=dx(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)))}),tx(this.query)||nx(this.query))for(;u.size>this.query.limit;){const e=tx(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 DR()}};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 qM(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 jM,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=tD(),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 XM(e))}),this.Io.forEach(e=>{t.has(e)||n.push(new JM(e))}),n}ko(e){this.To=e.zn,this.Io=tD();var t=this.Po(e.documents);return this.applyChanges(t,!0)}xo(){return qM.fromInitialDocuments(this.query,this.Ro,this.mutatedKeys,0===this.Eo)}}class eL{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class tL{constructor(e){this.key=e,this.$o=!1}}class nL{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 c1(e=>ux(e),lx),this.Fo=new Map,this.Lo=new Set,this.Bo=new zx(vP.comparator),this.Uo=new Map,this.qo=new U1,this.Ko={},this.jo=new Map,this.Qo=YO.re(),this.onlineState="Unknown",this.Wo=void 0}get isPrimaryClient(){return!0===this.Wo}}async function rL(n,e,t,r){n.Go=(e,s,t)=>async function(e,t,n){let r=t.view.Po(s);r.Bn&&(r=await O1(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 dL(e,t.targetId,i.Co),i.snapshot}(n,e,t);const i=await O1(n.localStore,e,!0),s=new ZM(e,i.zn),o=s.Po(i.documents),a=iD.createSynthesizedTargetChangeForCurrentChange(t,r&&"Offline"!==n.onlineState),c=s.applyChanges(o,n.isPrimaryClient,a);dL(n,t,c.Co);var l=new eL(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 iL(e,t,n){const r=_L(e);try{const e=await function(e,r){const i=e,s=JR.now(),t=r.reduce((e,t)=>e.add(t.key),tD());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=yx(r.transform,e||null);null!=i&&(null==n&&(n=PP.empty()),n.set(r.field,i))}return n||null}(n,o.get(n.key));null!=r&&t.push(new Fx(n.key,r,function r(e){const i=[];return eP(e.fields,(e,t)=>{const n=new sP([e]);if(NP(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 oP(i)}(r.value.mapValue),Nx.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 zx(GR),r=r.insert(t,n),e.Ko[e.currentUser.toKey()]=r}(r,e.batchId,n),await fL(r,e.changes),await RM(r.remoteStore)}catch(e){const t=FM(e,"Failed to persist write");n.reject(t)}}async function sL(e,t){const r=e;try{const e=await R1(r.localStore,t);t.targetChanges.forEach((e,t)=>{const n=r.Uo.get(t);n&&(OR(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1),0<e.addedDocuments.size?n.$o=!0:0<e.modifiedDocuments.size?OR(n.$o):0<e.removedDocuments.size&&(OR(n.$o),n.$o=!1))}),await fL(r,e,t)}catch(e){await t1(e)}}function oL(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&&KM(t)}(t.eventManager,i),r.length&&t.Oo.br(r),t.onlineState=i,t.isPrimaryClient&&t.sharedClientState.setOnlineState(i)}}async function aL(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=cO.resolve();return n.forEach(n=>{o=o.next(()=>i.getEntry(t,n)).next(e=>{var t=r.docVersions.get(n);OR(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);lL(n,r,null),cL(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await fL(n,e)}catch(e){await t1(e)}}function cL(e,t){(e.jo.get(t)||[]).forEach(e=>{e.resolve()}),e.jo.delete(t)}function lL(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 uL(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)||hL(t,e)})}function hL(e,t){e.Lo.delete(t.path.canonicalString());var n=e.Bo.get(t);null!==n&&(bM(e.remoteStore,n),e.Bo=e.Bo.remove(t),e.Uo.delete(n),pL(e))}function dL(e,t,n){for(const r of n)r instanceof JM?(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)||(NR("SyncEngine","New document in limbo: "+n),e.Lo.add(r),pL(e))}(e,r)):r instanceof XM?(NR("SyncEngine","Document no longer in limbo: "+r.key),e.qo.removeReference(r.key,t),e.qo.containsKey(r.key)||hL(e,r.key)):DR()}function pL(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 vP(rP.fromString(t)),t=e.Qo.next();e.Uo.set(t,new tL(n)),e.Bo=e.Bo.insert(n,t),wM(e.remoteStore,new IO(ax(ex(n.path)),t,2,zR.I))}}async function fL(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=E1.$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=>cO.forEach(t,t=>cO.forEach(t.kn,e=>r.persistence.referenceDelegate.addReference(n,t.targetId,e)).next(()=>cO.forEach(t.xn,e=>r.persistence.referenceDelegate.removeReference(n,t.targetId,e)))))}catch(e){if(!pO(e))throw e;NR("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 gL(r,e){const i=r;if(yL(i),_L(i),!0===e&&!0!==i.Wo){const r=i.sharedClientState.getAllActiveQueryTargets(),e=await mL(i,r.toArray());i.Wo=!0,await DM(i.remoteStore,!0);for(const r of e)wM(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(()=>(uL(i,t),D1(i.localStore,t,!0))),bM(i.remoteStore,t)}),await n,await mL(i,r),function(){const n=i;n.Uo.forEach((e,t)=>{bM(n.remoteStore,t)}),n.qo.hs(),n.Uo=new Map,n.Bo=new zx(vP.comparator)}(),i.Wo=!1,await DM(i.remoteStore,!1)}}async function mL(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 x1(r.localStore,ax(u[0]));for(const t of u){const n=r.Mo.get(t),u=(o=r,a=n,l=c=void 0,l=await O1((c=o).localStore,a.query,!0),l=a.view.ko(l),c.isPrimaryClient&&dL(c,a.targetId,l.Co),await l);u.snapshot&&s.push(u.snapshot)}}else{const u=await M1(r.localStore,t);e=await x1(r.localStore,u),await rL(r,vL(u),t,!1)}i.push(e)}var o,a,c,l;return r.Oo.br(s),i}function vL(e){return ZP(e.path,e.collectionGroup,e.orderBy,e.filters,e.limit,"F",e.startAt,e.endAt)}function yL(e){const t=e;return t.remoteStore.remoteSyncer.applyRemoteEvent=sL.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=(function(e,t){const n=e,r=n.Uo.get(t);if(r&&r.$o)return tD().add(r.key);{let e=tD();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 zx(vP.comparator);e=e.insert(s,xP.newNoDocument(s,XR.min()));const n=tD().add(s),i=new rD(XR.min(),new Map,new Qx(GR),e,n);await sL(r,i),r.Bo=r.Bo.remove(s),r.Uo.delete(t),pL(r)}else await D1(r.localStore,t,!1).then(()=>uL(r,t,n)).catch(t1)}).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&&KM(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 _L(e){const t=e;return t.remoteStore.remoteSyncer.applySuccessfulWrite=aL.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=>(OR(null!==e),n=e.keys(),i.An.removeMutationBatch(t,e))).next(()=>i.An.performConsistencyCheck(t)).next(()=>i.Wn.vn(t,n))})}(r.localStore,t);lL(r,t,n),cL(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),await fL(r,e)}catch(n){await t1(n)}}).bind(null,t),t}class wL{constructor(){this.synchronizeTabs=!1}async initialize(e){this.k=uM(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 C1(this.persistence,new k1,e.initialUser,this.k)}Yo(e){return new $1(z1.ks,this.k)}Jo(e){return new nM}async terminate(){this.gcScheduler&&this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class bL extends wL{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=p1(t);let r=XR.min();return e.jt({index:YD.readTimeIndex,reverse:!0},(e,t,n)=>{t.readTime&&(r=CO(t.readTime)),n.done()}).next(()=>r)}()).then(e=>{t.jn=e})}(this.localStore),await this.tc.initialize(this,e),await _L(this.tc.syncEngine),await RM(this.tc.remoteStore),await this.persistence.sn(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(this.localStore),Promise.resolve()))}Zo(e){return C1(this.persistence,new k1,e.initialUser,this.k)}Xo(e){var t=this.persistence.referenceDelegate.garbageCollector;return new i1(t,e.asyncQueue)}Yo(e){var t=b1(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?BO.withCacheSize(this.cacheSizeBytes):BO.DEFAULT;return new y1(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,cM(),lM(),this.k,this.sharedClientState,!!this.forceOwnership)}Jo(e){return new nM}}class IL extends bL{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 tM&&(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):cO.resolve(null)))}(i.localStore,t);null!==s?("pending"===n?await RM(i.remoteStore):"acknowledged"===n||"rejected"===n?(lL(i,t,r||null),cL(i,t),i.localStore.An.ee(t)):DR(),await fL(i,s)):NR("SyncEngine","Cannot apply mutation batch with id: "+t)}).bind(null,t),gi:(async function(e,t,n,r){const i=e;if(i.Wo)NR("SyncEngine","Ignoring unexpected query state notification.");else if(i.Fo.has(t))switch(n){case"current":case"not-current":{const e=await L1(i.localStore),r=rD.createSynthesizedRemoteEventForCurrentChange(t,"current"===n);await fL(i,e,r);break}case"rejected":await D1(i.localStore,t,!0),uL(i,t,r);break;default:DR()}}).bind(null,t),yi:(async function(e,t,n){const r=yL(e);if(r.Wo){for(const e of t)if(r.Fo.has(e))NR("SyncEngine","Adding an already active target "+e);else{const t=await M1(r.localStore,e),n=await x1(r.localStore,t);await rL(r,vL(t),n.targetId,!1),wM(r.remoteStore,n)}for(const e of n)r.Fo.has(e)&&await D1(r.localStore,e,!1).then(()=>{bM(r.remoteStore,e),uL(r,e)}).catch(t1)}}).bind(null,t),Tn:(function(e){return e.localStore.persistence.Tn()}).bind(null,t),_i:(async function(e){const t=e;return L1(t.localStore).then(e=>fL(t,e))}).bind(null,t)},await this.sharedClientState.start()),await this.persistence.sn(async e=>{await gL(this.tc.syncEngine,e),this.gcScheduler&&(e&&!this.gcScheduler.started?this.gcScheduler.start(this.localStore):e||this.gcScheduler.stop())})}Jo(e){var t=cM();if(!tM.Pt(t))throw new LR(MR.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var n=b1(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new tM(t,e.asyncQueue,n,e.clientId,e.initialUser)}}class TL{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=>oL(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=(async function(e,t){const n=e;if(!n.currentUser.isEqual(t)){NR("SyncEngine","User change. New user:",t.toKey());const r=await A1(n.localStore,t);n.currentUser=t,(e=n).jo.forEach(e=>{e.forEach(e=>{e.reject(new LR(MR.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.jo.clear(),n.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),await fL(n,r.Gn)}}).bind(null,this.syncEngine),await DM(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new BM}createDatastore(e){var t,n,r,i,s=uM(e.databaseInfo.databaseId),t=(t=e.databaseInfo,new aM(t));return n=e.authCredentials,r=e.appCheckCredentials,i=t,e=s,new gM(n,r,i,e)}createRemoteStore(e){return t=this.localStore,n=this.datastore,r=e.asyncQueue,i=e=>oL(this.syncEngine,e,0),s=new(iM.Pt()?iM:rM),new vM(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 nL(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;NR("RemoteStore","RemoteStore shutting down."),t.Gr.add(5),await _M(t),t.Hr.shutdown(),t.Jr.set("Unknown")}(this.remoteStore)}}function EL(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 kL{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 SL{constructor(e,t){this.sc=e,this.k=t,this.metadata=new FR,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 HM(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 CL{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 LR(MR.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");const t=await async function(e,t){const r=e,n=ED(r.k)+"/documents",i={documents:t.map(e=>wD(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){OR(!!t.found),t.found.name,t.found.updateTime;var n=bD(e,t.found.name),r=vD(t.found.updateTime),i=new PP({mapValue:{fields:t.found.fields}});return xP.newFoundDocument(n,r,i)}(n,e):"missing"in e?function(e,t){OR(!!t.missing),OR(!!t.readTime);var n=bD(e,t.missing),r=vD(t.readTime);return xP.newNoDocument(n,r)}(n,e):DR());var n;o.set(t.key.toString(),t)});const a=[];return t.forEach(e=>{var t=o.get(e.toString());OR(!!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 Vx(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=vP.fromPath(t);this.mutations.push(new Bx(n,this.precondition(n)))}),await async function(e,t){const n=e,r=ED(n.k)+"/documents",i={writes:t.map(e=>AD(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 DR();t=XR.min()}var n=this.readVersions.get(e.key.toString());if(n){if(!t.isEqual(n))throw new LR(MR.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?Nx.updateTime(t):Nx.none()}preconditionForUpdate(e){const t=this.readVersions.get(e.toString());if(this.writtenDocs.has(e.toString())||!t)return Nx.exists(!0);if(t.isEqual(XR.min()))throw new LR(MR.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Nx.updateTime(t)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}class AL{constructor(e,t,n,r){this.asyncQueue=e,this.datastore=t,this.updateFunction=n,this.deferred=r,this.lc=5,this.ur=new hM(this.asyncQueue,"transaction_retry")}run(){--this.lc,this.fc()}fc(){this.ur.Zi(async()=>{const t=new CL(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!fP(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||!$x(t)}}class NL{constructor(e,t,n,r){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=kR.UNAUTHENTICATED,this.clientId=HR.A(),this.authCredentialListener=()=>Promise.resolve(),this.authCredentials.start(n,async e=>{NR("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 LR(MR.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const n=new FR;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=FM(e,"Failed to shutdown persistence");n.reject(t)}}),n.promise}}async function RL(e,t){e.asyncQueue.verifyOperationInProgress(),NR("FirestoreClient","Initializing OfflineComponentProvider");var n=await e.getConfiguration();await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener(async e=>{r.isEqual(e)||(await A1(t.localStore,e),r=e)}),t.persistence.setDatabaseDeletedListener(()=>e.terminate()),e.offlineComponents=t}async function PL(e,t){e.asyncQueue.verifyOperationInProgress();var n=await xL(e);NR("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(),NR("RemoteStore","RemoteStore received new credentials");var r=SM(n);n.Gr.add(3),await _M(n),r&&n.Jr.set("Unknown"),await n.remoteSyncer.handleCredentialChange(t),n.Gr.delete(3),await yM(n)}(t.remoteStore,e)),e.onlineComponents=t}async function xL(e){return e.offlineComponents||(NR("FirestoreClient","Using default OfflineComponentProvider"),await RL(e,new wL)),e.offlineComponents}async function DL(e){return e.onlineComponents||(NR("FirestoreClient","Using default OnlineComponentProvider"),await PL(e,new TL)),e.onlineComponents}function OL(e){return xL(e).then(e=>e.persistence)}function ML(e){return xL(e).then(e=>e.localStore)}function LL(e){return DL(e).then(e=>e.remoteStore)}function FL(e){return DL(e).then(e=>e.syncEngine)}async function UL(e){const t=await DL(e),n=t.eventManager;return n.onListen=(async function(e,t){const n=yL(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 x1(n.localStore,ax(t)),s=n.sharedClientState.addLocalQueryTarget(e.targetId);r=e.targetId,i=await rL(n,t,r,"current"===s),n.isPrimaryClient&&wM(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=>!lx(e,t))),void n.Mo.delete(t);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)||await D1(n.localStore,r.targetId,!1).then(()=>{n.sharedClientState.clearQueryState(r.targetId),bM(n.remoteStore,r.targetId),uL(n,r.targetId)}).catch(t1)):(uL(n,r.targetId),await D1(n.localStore,r.targetId,!0))}).bind(null,t.syncEngine),n}function jL(e,t,n={}){const r=new FR;return e.asyncQueue.enqueueAndForget(async()=>function(n,r,i,s,o){const e=new kL({next:e=>{r.enqueueAndForget(()=>$M(n,a));var t=e.docs.has(i);!t&&e.fromCache?o.reject(new LR(MR.UNAVAILABLE,"Failed to get document because the client is offline.")):t&&e.fromCache&&s&&"server"===s.source?o.reject(new LR(MR.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 zM(ex(i.path),e,{includeMetadataChanges:!0,wo:!0});return WM(n,a)}(await UL(e),e.asyncQueue,t,n,r)),r.promise}function qL(e,t,n={}){const r=new FR;return e.asyncQueue.enqueueAndForget(async()=>function(t,n,e,r,i){const s=new kL({next:e=>{n.enqueueAndForget(()=>$M(t,o)),e.fromCache&&"server"===r.source?i.reject(new LR(MR.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 zM(e,s,{includeMetadataChanges:!0,wo:!0});return WM(t,o)}(await UL(e),e.asyncQueue,t,n,r)),r.promise}function VL(e,t,n,r){const i=(n=n,t=uM(t),s="string"==typeof n?(new TextEncoder).encode(n):n,n=function(e){if(e instanceof Uint8Array)return EL(e,void 0);if(e instanceof ArrayBuffer)return EL(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 SL(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=vD(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(YM(i));const o=new QM(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 fL(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){PR("SyncEngine",`Loading bundle failed with ${t}`),r._failWith(t)}}(r,t,n).then(()=>{r.sharedClientState.notifyBundleLoaded()})}(await FL(e),i,r)})}class BL{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 WL{constructor(e,t){this.projectId=e,this.database=t||"(default)"}get isDefaultDatabase(){return"(default)"===this.database}isEqual(e){return e instanceof WL&&e.projectId===this.projectId&&e.database===this.database}}const $L=new Map;function KL(e,t,n){if(!n)throw new LR(MR.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function zL(e,t,n,r){if(!0===t&&!0===r)throw new LR(MR.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function HL(e){if(!vP.isDocumentKey(e))throw new LR(MR.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function GL(e){if(vP.isDocumentKey(e))throw new LR(MR.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function QL(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":DR();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 YL(e,t){if((e="_delegate"in e?e._delegate:e)instanceof t)return e;if(t.name===e.constructor.name)throw new LR(MR.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");var n=QL(e);throw new LR(MR.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}function JL(e,t){if(t<=0)throw new LR(MR.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}class XL{constructor(e){var t;if(void 0===e.host){if(void 0!==e.ssl)throw new LR(MR.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 LR(MR.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.useFetchStreams=!!e.useFetchStreams,zL("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 ZL{constructor(e,t,n){this._authCredentials=t,this._appCheckCredentials=n,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new XL({}),this._settingsFrozen=!1,e instanceof WL?this._databaseId=e:(this._app=e,this._databaseId=function(e){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new LR(MR.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new WL(e.options.projectId)}(e))}get app(){if(!this._app)throw new LR(MR.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 LR(MR.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 XL(e),void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new jR;switch(e.type){case"gapi":var t=e.client;return OR(!("object"!=typeof t||null===t||!t.auth||!t.auth.getAuthHeaderValueForFirstParty)),new WR(t,e.sessionIndex||"0",e.iamToken||null);case"provider":return e.client;default:throw new LR(MR.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=$L.get(e);t&&(NR("ComponentProvider","Removing Datastore"),$L.delete(e),t.terminate())}(this),Promise.resolve()}}class eF{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 nF(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new eF(this.firestore,e,this._key)}}class tF{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new tF(this.firestore,e,this._query)}}class nF extends tF{constructor(e,t,n){super(e,t,ex(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 eF(this.firestore,null,new vP(e))}withConverter(e){return new nF(this.firestore,e,this._path)}}function rF(e,t,...n){if(e=$d(e),KL("collection","path",t),e instanceof ZL){var r=rP.fromString(t,...n);return GL(r),new nF(e,null,r)}if(!(e instanceof eF||e instanceof nF))throw new LR(MR.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");r=e._path.child(rP.fromString(t,...n));return GL(r),new nF(e.firestore,null,r)}function iF(e,t,...n){if(e=$d(e),KL("doc","path",t=1===arguments.length?HR.A():t),e instanceof ZL){var r=rP.fromString(t,...n);return HL(r),new eF(e,null,new vP(r))}if(!(e instanceof eF||e instanceof nF))throw new LR(MR.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");r=e._path.child(rP.fromString(t,...n));return HL(r),new eF(e.firestore,e instanceof nF?e.converter:null,new vP(r))}function sF(e,t){return e=$d(e),t=$d(t),(e instanceof eF||e instanceof nF)&&(t instanceof eF||t instanceof nF)&&e.firestore===t.firestore&&e.path===t.path&&e.converter===t.converter}function oF(e,t){return e=$d(e),t=$d(t),e instanceof tF&&t instanceof tF&&e.firestore===t.firestore&&lx(e._query,t._query)&&e.converter===t.converter}class aF{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 hM(this,"async_queue_retry"),this.bc=()=>{var e=lM();e&&NR("AsyncQueue","Visibility state changed to "+e.visibilityState),this.ur.er()};const e=lM();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=lM();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.bc)}}enqueue(e){if(this.Pc(),this.yc)return new Promise(()=>{});const t=new FR;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(!pO(e))throw e;NR("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,RR("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=LM.createAndSchedule(this,e,t,n,e=>this.Sc(e));return this.Tc.push(r),r}Pc(){this.Ec&&DR()}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 cF(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 lF{constructor(){this._progressObserver={},this._taskCompletionResolver=new FR,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 uF,hF,dF,pF;class fF extends ZL{constructor(e,t,n){super(e,t,n),this.type="firestore",this._queue=new aF,this._persistenceKey="name"in e?e.name:"[DEFAULT]"}_terminate(){return this._firestoreClient||mF(this),this._firestoreClient.terminate()}}function gF(e){return e._firestoreClient||mF(e),e._firestoreClient.verifyNotTerminated(),e._firestoreClient}function mF(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 BL(n,r,i,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,s.useFetchStreams));e._firestoreClient=new NL(e._authCredentials,e._appCheckCredentials,e._queue,o)}function vF(e,n,r){const i=new FR;return e.asyncQueue.enqueue(async()=>{try{await RL(e,r),await PL(e,n),i.resolve()}catch(e){if(!("FirebaseError"===(t=e).name?t.code===MR.FAILED_PRECONDITION||t.code===MR.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 yF(e){return function(e){const t=new FR;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t){const n=e;SM(n.remoteStore)||NR("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=FM(e,"Initialization of waitForPendingWrites() operation failed");t.reject(n)}}(await FL(e),t)),t.promise}(gF(e=YL(e,fF)))}function _F(e){return(n=gF(e=YL(e,fF))).asyncQueue.enqueue(async()=>{const e=await OL(n),t=await LL(n);return e.setNetworkEnabled(!0),function(){const e=t;return e.Gr.delete(0),yM(e)}()});var n}function wF(e){return(n=gF(e=YL(e,fF))).asyncQueue.enqueue(async()=>{const e=await OL(n),t=await LL(n);return e.setNetworkEnabled(!1),async function(){const e=t;e.Gr.add(0),await _M(e),e.Jr.set("Offline")}()});var n}function bF(t,e){return n=gF(t=YL(t,fF)),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 ML(n),r)).then(e=>e?new tF(t,null,e.query):null);var n,r}function IF(e){if(e._initialized||e._terminated)throw new LR(MR.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 TF{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new LR(MR.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new sP(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class EF{constructor(e){this._byteString=e}static fromBase64String(e){try{return new EF(aP.fromBase64String(e))}catch(e){throw new LR(MR.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new EF(aP.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 kF{constructor(e){this._methodName=e}}class SF{constructor(e,t){if(!isFinite(e)||e<-90||90<e)throw new LR(MR.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||180<t)throw new LR(MR.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 GR(this._lat,e._lat)||GR(this._long,e._long)}}const CF=/^__.*__$/;class AF{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return null!==this.fieldMask?new Fx(e,this.data,this.fieldMask,t,this.fieldTransforms):new Lx(e,this.data,t,this.fieldTransforms)}}class NF{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new Fx(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function RF(e){switch(e){case 0:case 2:case 1:return 1;case 3:case 4:return;default:throw DR()}}class PF{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 PF(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 JF(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(RF(this.$c)&&CF.test(e))throw this.qc('Document fields cannot begin and end with "__"')}}class xF{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.k=n||uM(e)}Qc(e,t,n,r=!1){return new PF({$c:e,methodName:t,jc:n,path:sP.emptyPath(),Fc:!1,Kc:r},this.databaseId,this.k,this.ignoreUndefinedProperties)}}function DF(e){var t=e._freezeSettings(),n=uM(e._databaseId);return new xF(e._databaseId,!!t.ignoreUndefinedProperties,n)}function OF(e,t,n,r,i,s={}){const o=e.Qc(s.merge||s.mergeFields?2:0,t,n,i);HF("Data must be an object, but it was:",o,r);var a=KF(r,o);let c,l;if(s.merge)c=new oP(o.fieldMask),l=o.fieldTransforms;else if(s.mergeFields){const e=[];for(const r of s.mergeFields){const i=GF(t,r,n);if(!o.contains(i))throw new LR(MR.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);XF(e,i)||e.push(i)}c=new oP(e),l=o.fieldTransforms.filter(e=>c.covers(e.field))}else c=null,l=o.fieldTransforms;return new AF(new PP(a),c,l)}class MF extends kF{_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 MF}}function LF(e,t,n){return new PF({$c:3,jc:t.settings.jc,methodName:e._methodName,Fc:n},t.databaseId,t.k,t.ignoreUndefinedProperties)}class FF extends kF{_toFieldTransform(e){return new Cx(e.path,new _x)}isEqual(e){return e instanceof FF}}class UF extends kF{constructor(e,t){super(e),this.Wc=t}_toFieldTransform(e){const t=LF(this,e,!0),n=this.Wc.map(e=>$F(e,t)),r=new wx(n);return new Cx(e.path,r)}isEqual(e){return this===e}}class jF extends kF{constructor(e,t){super(e),this.Wc=t}_toFieldTransform(e){const t=LF(this,e,!0),n=this.Wc.map(e=>$F(e,t)),r=new Ix(n);return new Cx(e.path,r)}isEqual(e){return this===e}}class qF extends kF{constructor(e,t){super(e),this.Gc=t}_toFieldTransform(e){var t=new Ex(e.k,mx(e.k,this.Gc));return new Cx(e.path,t)}isEqual(e){return this===e}}function VF(e,i,s,t){const o=e.Qc(1,i,s);HF("Data must be an object, but it was:",o,t);const a=[],c=PP.empty();eP(t,(e,t)=>{var n=YF(i,e,s);t=$d(t);var r=o.Bc(n);if(t instanceof MF)a.push(n);else{const e=$F(t,r);null!=e&&(a.push(n),c.set(n,e))}});var n=new oP(a);return new NF(c,n,o.fieldTransforms)}function BF(e,t,n,r,i,s){const o=e.Qc(1,t,n),a=[GF(t,r,n)],c=[i];if(s.length%2!=0)throw new LR(MR.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(GF(t,s[p])),c.push(s[p+1]);const l=[],u=PP.empty();for(let f=a.length-1;0<=f;--f)if(!XF(l,a[f])){const t=a[f];var h=$d(h=c[f]);const r=o.Bc(t);if(h instanceof MF)l.push(t);else{const e=$F(h,r);null!=e&&(l.push(t),u.set(t,e))}}var d=new oP(l);return new NF(u,d,o.fieldTransforms)}function WF(e,t,n,r=!1){return $F(n,e.Qc(r?4:3,t))}function $F(s,e){if(zF(s=$d(s)))return HF("Unsupported field value:",e,s),KF(s,e);if(s instanceof kF)return function(e,t){if(!RF(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=$F(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 mx(t.k,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){var n=JR.fromDate(e);return{timestampValue:gD(t.k,n)}}if(e instanceof JR){n=new JR(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:gD(t.k,n)}}if(e instanceof SF)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof EF)return{bytesValue:mD(t.k,e._byteString)};if(e instanceof eF){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:yD(e.firestore._databaseId||t.databaseId,e._key.path)}}throw t.qc(`Unsupported field value: ${QL(e)}`)}(0,e)}function KF(e,r){const i={};return tP(e)?r.path&&0<r.path.length&&r.fieldMask.push(r.path):eP(e,(e,t)=>{var n=$F(t,r.Mc(e));null!=n&&(i[e]=n)}),{mapValue:{fields:i}}}function zF(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof JR||e instanceof SF||e instanceof EF||e instanceof eF||e instanceof kF)}function HF(e,t,n){if(!zF(n)||("object"!=typeof(i=n)||null===i||Object.getPrototypeOf(i)!==Object.prototype&&null!==Object.getPrototypeOf(i))){var r=QL(n);throw"an object"===r?t.qc(e+" a custom object"):t.qc(e+" "+r)}var i}function GF(e,t,n){if((t=$d(t))instanceof TF)return t._internalPath;if("string"==typeof t)return YF(e,t);throw JF("Field path arguments must be of type string or ",e,!1,void 0,n)}const QF=new RegExp("[~\\*/\\[\\]]");function YF(t,n,r){if(0<=n.search(QF))throw JF(`Invalid field path (${n}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,r);try{return new TF(...n.split("."))._internalPath}catch(e){throw JF(`Invalid field path (${n}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,r)}}function JF(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 LR(MR.INVALID_ARGUMENT,a+e+c)}function XF(e,t){return e.some(e=>e.isEqual(t))}class ZF{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 eF(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){var e=new eU(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(tU("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class eU extends ZF{data(){return super.data()}}function tU(e,t){return"string"==typeof t?YF(e,t):(t instanceof TF?t:t._delegate)._internalPath}class nU{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class rU extends ZF{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 iU(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(tU("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}}class iU extends rU{data(e={}){return super.data(e)}}class sU{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new nU(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 iU(this._firestore,this._userDataWriter,e.key,e,new nU(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 LR(MR.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 iU(s._firestore,s._userDataWriter,e.doc.key,e.doc,new nU(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 iU(s._firestore,s._userDataWriter,e.doc.key,e.doc,new nU(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 DR()}}(e.type),doc:t,oldIndex:n,newIndex:r}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function oU(e,t){return e instanceof rU&&t instanceof rU?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 sU&&t instanceof sU&&e._firestore===t._firestore&&oF(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)}function aU(e){if(nx(e)&&0===e.explicitOrderBy.length)throw new LR(MR.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class cU{}function lU(e,...t){for(const n of t)e=n._apply(e);return e}class uU extends cU{constructor(e,t,n){super(),this.zc=e,this.Hc=t,this.Jc=n,this.type="where"}_apply(e){var t=DF(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 LR(MR.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){vU(o,s);const t=[];for(const n of o)t.push(mU(r,e,n));a={arrayValue:{values:t}}}else a=mU(r,e,o)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||vU(o,s),a=WF(n,t,o,"in"===s||"not-in"===s);var c=UP.create(i,s,a);return function(e,t){if(t.V()){const r=ix(e);if(null!==r&&!r.isEqual(t.field))throw new LR(MR.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=rx(e);null!==n&&yU(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 LR(MR.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new LR(MR.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 tF(e.firestore,e.converter,(e=e._query,t=e.filters.concat([t]),new XP(e.path,e.collectionGroup,e.explicitOrderBy.slice(),t,e.limit,e.limitType,e.startAt,e.endAt)))}}class hU extends cU{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 LR(MR.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new LR(MR.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var r,i=new QP(t,n);return n=i,null!==rx(e=e)||null!==(r=ix(e))&&yU(0,r,n.field),i}(e._query,this.zc,this.Yc);return new tF(e.firestore,e.converter,(e=e._query,t=e.explicitOrderBy.concat([t]),new XP(e.path,e.collectionGroup,t,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)))}}class dU extends cU{constructor(e,t,n){super(),this.type=e,this.Xc=t,this.Zc=n}_apply(e){return new tF(e.firestore,e.converter,cx(e._query,this.Xc,this.Zc))}}class pU extends cU{constructor(e,t,n){super(),this.type=e,this.ta=t,this.ea=n}_apply(e){var t,n=gU(e,this.type,this.ta,this.ea);return new tF(e.firestore,e.converter,(t=e._query,e=n,new XP(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)))}}class fU extends cU{constructor(e,t,n){super(),this.type=e,this.ta=t,this.ea=n}_apply(e){var t,n=gU(e,this.type,this.ta,this.ea);return new tF(e.firestore,e.converter,(t=e._query,e=n,new XP(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)))}}function gU(e,t,n,r){if(n[0]=$d(n[0]),n[0]instanceof ZF)return function(e,t,n,r,i){if(!r)throw new LR(MR.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);const s=[];for(const n of ox(e))if(n.field.isKeyField())s.push(EP(t,r.key));else{const e=r.data.field(n.field);if(dP(e))throw new LR(MR.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 LR(MR.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 HP(s,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);var i=DF(e.firestore);return function(e,t,n,r,i,s){const o=e.explicitOrderBy;if(i.length>o.length)throw new LR(MR.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 LR(MR.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof l}`);if(!sx(e)&&-1!==l.indexOf("/"))throw new LR(MR.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(rP.fromString(l));if(!vP.isDocumentKey(n))throw new LR(MR.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 vP(n);a.push(EP(t,i))}else{const e=WF(n,r,l);a.push(e)}}return new HP(a,s)}(e._query,e.firestore._databaseId,i,t,n,r)}function mU(e,t,n){if("string"==typeof(n=$d(n))){if(""===n)throw new LR(MR.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!sx(t)&&-1!==n.indexOf("/"))throw new LR(MR.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(rP.fromString(n));if(!vP.isDocumentKey(r))throw new LR(MR.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 EP(e,new vP(r))}if(n instanceof eF)return EP(e,n._key);throw new LR(MR.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${QL(n)}.`)}function vU(e,t){if(!Array.isArray(e)||0===e.length)throw new LR(MR.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`);if(10<e.length)throw new LR(MR.INVALID_ARGUMENT,`Invalid Query. '${t.toString()}' filters support a maximum of 10 elements in the value array.`)}function yU(e,t,n){if(!n.isEqual(t))throw new LR(MR.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 _U{convertValue(e,t="none"){switch(yP(e)){case 0:return null;case 1:return e.booleanValue;case 2:return uP(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(hP(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 DR()}}convertObject(e,n){const r={};return eP(e.fields,(e,t)=>{r[e]=this.convertValue(t,n)}),r}convertGeoPoint(e){return new SF(uP(e.latitude),uP(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 dP(n)?e(n):n}(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(pP(e));default:return null}}convertTimestamp(e){var t=lP(e);return new JR(t.seconds,t.nanos)}convertDocumentKey(e,t){const n=rP.fromString(e);OR(jD(n));const r=new WL(n.get(1),n.get(3)),i=new vP(n.popFirst(5));return r.isEqual(t)||RR(`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 wU(e,t,n){return e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t}class bU extends _U{constructor(e){super(),this.firestore=e}convertBytes(e){return new EF(e)}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return new eF(this.firestore,null,t)}}class IU{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=DF(e)}set(e,t,n){this._verifyNotCommitted();const r=TU(e,this._firestore),i=wU(r.converter,t,n),s=OF(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(s.toMutation(r._key,Nx.none())),this}update(e,t,n,...r){this._verifyNotCommitted();var i=TU(e,this._firestore);let s;return s="string"==typeof(t=$d(t))||t instanceof TF?BF(this._dataReader,"WriteBatch.update",i._key,t,n,r):VF(this._dataReader,"WriteBatch.update",i._key,t),this._mutations.push(s.toMutation(i._key,Nx.exists(!0))),this}delete(e){this._verifyNotCommitted();var t=TU(e,this._firestore);return this._mutations=this._mutations.concat(new Vx(t._key,Nx.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 LR(MR.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function TU(e,t){if((e=$d(e)).firestore!==t)throw new LR(MR.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}class EU extends _U{constructor(e){super(),this.firestore=e}convertBytes(e){return new EF(e)}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return new eF(this.firestore,null,t)}}function kU(t){t=YL(t,eF);const n=YL(t.firestore,fF),e=gF(n),r=new EU(n);return function(e,t){const n=new FR;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 LR(MR.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=FM(e,`Failed to get document '${t} from cache`);n.reject(r)}}(await ML(e),t,n)),n.promise}(e,t._key).then(e=>new rU(n,r,t._key,e,new nU(null!==e&&e.hasLocalMutations,!0),t.converter))}function SU(t){t=YL(t,tF);const n=YL(t.firestore,fF),e=gF(n),r=new EU(n);return function(e,t){const n=new FR;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t,n){try{const i=await O1(e,t,!0),s=new ZM(t,i.zn),o=s.Po(i.documents),a=s.applyChanges(o,!1);n.resolve(a.snapshot)}catch(e){var r=FM(e,`Failed to execute query '${t} against cache`);n.reject(r)}}(await ML(e),t,n)),n.promise}(e,t._query).then(e=>new sU(n,r,t,e))}function CU(e,t,n){e=YL(e,eF);var r=YL(e.firestore,fF),i=wU(e.converter,t,n);return PU(r,[OF(DF(r),"setDoc",e._key,i,null!==e.converter,n).toMutation(e._key,Nx.none())])}function AU(e,t,n,...r){e=YL(e,eF);var i=YL(e.firestore,fF),s=DF(i);let o;return o="string"==typeof(t=$d(t))||t instanceof TF?BF(s,"updateDoc",e._key,t,n,r):VF(s,"updateDoc",e._key,t),PU(i,[o.toMutation(e._key,Nx.exists(!0))])}function NU(t,...n){var e;t=$d(t);let r={includeMetadataChanges:!1},i=0;"object"!=typeof n[i]||cF(n[i])||(r=n[i],i++);var s={includeMetadataChanges:r.includeMetadataChanges};if(cF(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 eF)a=YL(t.firestore,fF),c=ex(t._key.path),o={next:e=>{n[i]&&n[i](xU(a,t,e))},error:n[i+1],complete:n[i+2]};else{const l=YL(t,tF);a=YL(l.firestore,fF),c=l._query;const u=new EU(a);o={next:e=>{n[i]&&n[i](new sU(a,u,l,e))},error:n[i+1],complete:n[i+2]},aU(t._query)}return function(e,t,n,r){const i=new kL(r),s=new zM(t,i,n);return e.asyncQueue.enqueueAndForget(async()=>WM(await UL(e),s)),()=>{i.nc(),e.asyncQueue.enqueueAndForget(async()=>$M(await UL(e),s))}}(gF(a),c,s,o)}function RU(e,t){return function(e,t){const n=new kL(t);return e.asyncQueue.enqueueAndForget(async()=>function(e,t){e.io.add(t),t.next()}(await UL(e),n)),()=>{n.nc(),e.asyncQueue.enqueueAndForget(async()=>function(e,t){e.io.delete(t)}(await UL(e),n))}}(gF(e=YL(e,fF)),cF(t)?t:{next:t})}function PU(e,t){return function(e,t){const n=new FR;return e.asyncQueue.enqueueAndForget(async()=>iL(await FL(e),t,n)),n.promise}(gF(e),t)}function xU(e,t,n){var r=n.docs.get(t._key),i=new EU(e);return new rU(e,i,t._key,r,new nU(n.hasPendingWrites,n.fromCache),t.converter)}class DU extends class{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=DF(e)}get(e){const n=TU(e,this._firestore),r=new bU(this._firestore);return this._transaction.lookup([n._key]).then(e=>{if(!e||1!==e.length)return DR();const t=e[0];if(t.isFoundDocument())return new ZF(this._firestore,r,t.key,t,n.converter);if(t.isNoDocument())return new ZF(this._firestore,r,n._key,null,n.converter);throw DR()})}set(e,t,n){var r=TU(e,this._firestore),i=wU(r.converter,t,n),i=OF(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=TU(e,this._firestore),s="string"==typeof(t=$d(t))||t instanceof TF?BF(this._dataReader,"Transaction.update",i._key,t,n,r):VF(this._dataReader,"Transaction.update",i._key,t);return this._transaction.update(i._key,s),this}delete(e){var t=TU(e,this._firestore);return this._transaction.delete(t._key),this}}{constructor(e,t){super(e,t),this._firestore=e}get(e){const t=TU(e,this._firestore),n=new EU(this._firestore);return super.get(e).then(e=>new rU(this._firestore,n,t._key,e._document,new nU(!1,!1),t.converter))}}function OU(t,n){return function(t,n){const r=new FR;return t.asyncQueue.enqueueAndForget(async()=>{var e=await DL(t).then(e=>e.datastore);new AL(t.asyncQueue,e,n,r).run()}),r.promise}(gF(t=YL(t,fF)),e=>n(new DU(t,e)))}z=mp,SR=z,dp(new Kd("firestore",(e,{options:t})=>{const n=e.getProvider("app").getImmediate(),r=new fF(n,new VR(e.getProvider("auth-internal")),new KR(e.getProvider("app-check-internal")));return t=Object.assign({useFetchStreams:!0},t),r._setSettings(t),r},"PUBLIC")),wp(ER,"3.4.2-canary.88d43ec00",void 0),wp(ER,"3.4.2-canary.88d43ec00","esm2017");function MU(e,t){if(void 0===t)return{merge:!1};if(void 0!==t.mergeFields&&void 0!==t.merge)throw new LR("invalid-argument",`Invalid options passed to function ${e}(): You cannot `+'specify both "merge" and "mergeFields".');return t}function LU(){if("undefined"==typeof Uint8Array)throw new LR("unimplemented","Uint8Arrays are not available in this environment.")}function FU(){if("undefined"==typeof atob)throw new LR("unimplemented","Blobs are unavailable in Firestore in this environment.")}class UU{constructor(e){this._delegate=e}static fromBase64String(e){return FU(),new UU(EF.fromBase64String(e))}static fromUint8Array(e){return LU(),new UU(EF.fromUint8Array(e))}toBase64(){return FU(),this._delegate.toBase64()}toUint8Array(){return LU(),this._delegate.toUint8Array()}isEqual(e){return this._delegate.isEqual(e._delegate)}toString(){return"Blob(base64: "+this.toBase64()+")"}}function jU(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 qU{enableIndexedDbPersistence(e,t){return function(e,t){IF(e=YL(e,fF));var n=gF(e),r=e._freezeSettings(),i=new TL;return vF(n,i,new bL(i,r.cacheSizeBytes,null==t?void 0:t.forceOwnership))}(e._delegate,{forceOwnership:t})}enableMultiTabIndexedDbPersistence(e){return function(e){IF(e=YL(e,fF));var t=gF(e),n=e._freezeSettings(),r=new TL;return vF(t,r,new IL(r,n.cacheSizeBytes))}(e._delegate)}clearIndexedDbPersistence(e){return function(e){if(e._initialized&&!e._terminated)throw new LR(MR.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const t=new FR;return e._queue.enqueueAndForgetEvenWhileRestricted(async()=>{try{await async function(e){if(!uO.Pt())return Promise.resolve();var t=e+"main";await uO.delete(t)}(b1(e._databaseId,e._persistenceKey)),t.resolve()}catch(e){t.reject(e)}}),t.promise}(e._delegate)}}class VU{constructor(e,t,n){this._delegate=t,this._persistenceProvider=n,this.INTERNAL={delete:()=>this.terminate()},e instanceof WL||(this._appCompat=e)}get _databaseId(){return this._delegate._databaseId}settings(e){var t=this._delegate._getSettings();e.merge||t.host===e.host||PR("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=YL(n,ZL))._getSettings();if("firestore.googleapis.com"!==s.host&&s.host!==e&&PR("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=kR.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 LR(MR.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");t=new kR(s)}n._authCredentials=new qR(new UR(e,t))}}(this._delegate,e,t,n)}enableNetwork(){return _F(this._delegate)}disableNetwork(){return wF(this._delegate)}enablePersistence(e){let t=!1,n=!1;return e&&(t=!!e.synchronizeTabs,n=!!e.experimentalForceOwningTab,zL("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 yF(this._delegate)}onSnapshotsInSync(e){return RU(this._delegate,e)}get app(){if(!this._appCompat)throw new LR("failed-precondition","Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._appCompat}collection(e){try{return new tj(this,rF(this._delegate,e))}catch(e){throw HU(e,"collection()","Firestore.collection()")}}doc(e){try{return new zU(this,iF(this._delegate,e))}catch(e){throw HU(e,"doc()","Firestore.doc()")}}collectionGroup(e){try{return new XU(this,function(e,t){if(e=YL(e,ZL),KL("collectionGroup","collection id",t),0<=t.indexOf("/"))throw new LR(MR.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new tF(e,null,(t=t,new XP(rP.emptyPath(),t)))}(this._delegate,e))}catch(e){throw HU(e,"collectionGroup()","Firestore.collectionGroup()")}}runTransaction(t){return OU(this._delegate,e=>t(new WU(this,e)))}batch(){return gF(this._delegate),new $U(new IU(this._delegate,e=>PU(this._delegate,e)))}loadBundle(e){return t=this._delegate,e=e,n=gF(t=YL(t,fF)),r=new lF,VL(n,t._databaseId,e,r),r;var t,n,r}namedQuery(e){return bF(this._delegate,e).then(e=>e?new XU(this,e):null)}}class BU extends _U{constructor(e){super(),this.firestore=e}convertBytes(e){return new UU(new EF(e))}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return zU.forKey(t,this.firestore,null)}}class WU{constructor(e,t){this._firestore=e,this._delegate=t,this._userDataWriter=new BU(e)}get(e){const t=nj(e);return this._delegate.get(t).then(e=>new YU(this._firestore,new rU(this._firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,t.converter)))}set(e,t,n){var r=nj(e);return n?(MU("Transaction.set",n),this._delegate.set(r,t,n)):this._delegate.set(r,t),this}update(e,t,n,...r){var i=nj(e);return 2===arguments.length?this._delegate.update(i,t):this._delegate.update(i,t,n,...r),this}delete(e){var t=nj(e);return this._delegate.delete(t),this}}class $U{constructor(e){this._delegate=e}set(e,t,n){var r=nj(e);return n?(MU("WriteBatch.set",n),this._delegate.set(r,t,n)):this._delegate.set(r,t),this}update(e,t,n,...r){var i=nj(e);return 2===arguments.length?this._delegate.update(i,t):this._delegate.update(i,t,n,...r),this}delete(e){var t=nj(e);return this._delegate.delete(t),this}commit(){return this._delegate.commit()}}class KU{constructor(e,t,n){this._firestore=e,this._userDataWriter=t,this._delegate=n}fromFirestore(e,t){var n=new iU(this._firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,null);return this._delegate.fromFirestore(new JU(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=KU.INSTANCES;let r=n.get(e);r||(r=new WeakMap,n.set(e,r));let i=r.get(t);return i||(i=new KU(e,new BU(e),t),r.set(t,i)),i}}KU.INSTANCES=new WeakMap;class zU{constructor(e,t){this.firestore=e,this._delegate=t,this._userDataWriter=new BU(e)}static forPath(e,t,n){if(e.length%2!=0)throw new LR("invalid-argument","Invalid document reference. Document references must have an even number of segments, but "+`${e.canonicalString()} has ${e.length}`);return new zU(t,new eF(t._delegate,n,new vP(e)))}static forKey(e,t,n){return new zU(t,new eF(t._delegate,n,e))}get id(){return this._delegate.id}get parent(){return new tj(this.firestore,this._delegate.parent)}get path(){return this._delegate.path}collection(e){try{return new tj(this.firestore,rF(this._delegate,e))}catch(e){throw HU(e,"collection()","DocumentReference.collection()")}}isEqual(e){return(e=$d(e))instanceof eF&&sF(this._delegate,e)}set(e,t){t=MU("DocumentReference.set",t);try{return t?CU(this._delegate,e,t):CU(this._delegate,e)}catch(e){throw HU(e,"setDoc()","DocumentReference.set()")}}update(e,t,...n){try{return 1===arguments.length?AU(this._delegate,e):AU(this._delegate,e,t,...n)}catch(e){throw HU(e,"updateDoc()","DocumentReference.update()")}}delete(){return PU(YL((e=this._delegate).firestore,fF),[new Vx(e._key,Nx.none())]);var e}onSnapshot(...e){var t=GU(e),n=QU(e,e=>new YU(this.firestore,new rU(this.firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,this._delegate.converter)));return NU(this._delegate,t,n)}get(e){let t;return t=("cache"===(null==e?void 0:e.source)?kU:"server"===(null==e?void 0:e.source)?function(t){t=YL(t,eF);const n=YL(t.firestore,fF);return jL(gF(n),t._key,{source:"server"}).then(e=>xU(n,t,e))}:function(t){t=YL(t,eF);const n=YL(t.firestore,fF);return jL(gF(n),t._key).then(e=>xU(n,t,e))})(this._delegate),t.then(e=>new YU(this.firestore,new rU(this.firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,this._delegate.converter)))}withConverter(e){return new zU(this.firestore,e?this._delegate.withConverter(KU.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}function HU(e,t,n){return e.message=e.message.replace(t,n),e}function GU(e){for(const t of e)if("object"==typeof t&&!jU(t))return t;return{}}function QU(e,t){var n;let r;return r=jU(e[0])?e[0]:jU(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 YU{constructor(e,t){this._firestore=e,this._delegate=t}get ref(){return new zU(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 oU(this._delegate,e._delegate)}}class JU extends YU{data(e){var t=this._delegate.data(e);return void 0!==t||DR(),t}}class XU{constructor(e,t){this.firestore=e,this._delegate=t,this._userDataWriter=new BU(e)}where(e,t,n){try{return new XU(this.firestore,lU(this._delegate,(r=n,i=t,s=tU("where",e),new uU(s,i,r))))}catch(e){throw HU(e,/(orderBy|where)\(\)/,"Query.$1()")}var r,i,s}orderBy(e,t){try{return new XU(this.firestore,lU(this._delegate,([n,r="asc"]=[e,t],i=r,s=tU("orderBy",n),new hU(s,i))))}catch(e){throw HU(e,/(orderBy|where)\(\)/,"Query.$1()")}var n,r,i,s}limit(e){try{return new XU(this.firestore,lU(this._delegate,(JL("limit",t=e),new dU("limit",t,"F"))))}catch(e){throw HU(e,"limit()","Query.limit()")}var t}limitToLast(e){try{return new XU(this.firestore,lU(this._delegate,(JL("limitToLast",t=e),new dU("limitToLast",t,"L"))))}catch(e){throw HU(e,"limitToLast()","Query.limitToLast()")}var t}startAt(...e){try{return new XU(this.firestore,lU(this._delegate,function(...e){return new pU("startAt",e,!0)}(...e)))}catch(e){throw HU(e,"startAt()","Query.startAt()")}}startAfter(...e){try{return new XU(this.firestore,lU(this._delegate,function(...e){return new pU("startAfter",e,!1)}(...e)))}catch(e){throw HU(e,"startAfter()","Query.startAfter()")}}endBefore(...e){try{return new XU(this.firestore,lU(this._delegate,function(...e){return new fU("endBefore",e,!0)}(...e)))}catch(e){throw HU(e,"endBefore()","Query.endBefore()")}}endAt(...e){try{return new XU(this.firestore,lU(this._delegate,function(...e){return new fU("endAt",e,!1)}(...e)))}catch(e){throw HU(e,"endAt()","Query.endAt()")}}isEqual(e){return oF(this._delegate,e._delegate)}get(e){let t;return t=("cache"===(null==e?void 0:e.source)?SU:"server"===(null==e?void 0:e.source)?function(t){t=YL(t,tF);const n=YL(t.firestore,fF),e=gF(n),r=new EU(n);return qL(e,t._query,{source:"server"}).then(e=>new sU(n,r,t,e))}:function(t){t=YL(t,tF);const n=YL(t.firestore,fF),e=gF(n),r=new EU(n);return aU(t._query),qL(e,t._query).then(e=>new sU(n,r,t,e))})(this._delegate),t.then(e=>new ej(this.firestore,new sU(this.firestore._delegate,this._userDataWriter,this._delegate,e._snapshot)))}onSnapshot(...e){var t=GU(e),n=QU(e,e=>new ej(this.firestore,new sU(this.firestore._delegate,this._userDataWriter,this._delegate,e._snapshot)));return NU(this._delegate,t,n)}withConverter(e){return new XU(this.firestore,e?this._delegate.withConverter(KU.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}class ZU{constructor(e,t){this._firestore=e,this._delegate=t}get type(){return this._delegate.type}get doc(){return new JU(this._firestore,this._delegate.doc)}get oldIndex(){return this._delegate.oldIndex}get newIndex(){return this._delegate.newIndex}}class ej{constructor(e,t){this._firestore=e,this._delegate=t}get query(){return new XU(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 JU(this._firestore,e))}docChanges(e){return this._delegate.docChanges(e).map(e=>new ZU(this._firestore,e))}forEach(t,n){this._delegate.forEach(e=>{t.call(n,new JU(this._firestore,e))})}isEqual(e){return oU(this._delegate,e._delegate)}}class tj extends XU{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 zU(this.firestore,e):null}doc(e){try{return void 0===e?new zU(this.firestore,iF(this._delegate)):new zU(this.firestore,iF(this._delegate,e))}catch(e){throw HU(e,"doc()","CollectionReference.doc()")}}add(e){return function(e,t){const n=YL(e.firestore,fF),r=iF(e),i=wU(e.converter,t);return PU(n,[OF(DF(e.firestore),"addDoc",r._key,i,null!==e.converter,{}).toMutation(r._key,Nx.exists(!1))]).then(()=>r)}(this._delegate,e).then(e=>new zU(this.firestore,e))}isEqual(e){return sF(this._delegate,e._delegate)}withConverter(e){return new tj(this.firestore,e?this._delegate.withConverter(KU.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}function nj(e){return YL(e,eF)}const rj={Firestore:VU,GeoPoint:SF,Timestamp:JR,Blob:UU,Transaction:WU,WriteBatch:$U,DocumentReference:zU,DocumentSnapshot:YU,Query:XU,QueryDocumentSnapshot:JU,QuerySnapshot:ej,CollectionReference:tj,FieldPath:class o${constructor(...e){this._delegate=new TF(...e)}static documentId(){return new o$(sP.keyField().canonicalString())}isEqual(e){return(e=$d(e))instanceof TF&&this._delegate._internalPath.isEqual(e._internalPath)}},FieldValue:class a${constructor(e){this._delegate=e}static serverTimestamp(){const e=new FF("serverTimestamp");return e._methodName="FieldValue.serverTimestamp",new a$(e)}static delete(){const e=new MF("deleteField");return e._methodName="FieldValue.delete",new a$(e)}static arrayUnion(...e){const t=function(...e){return new UF("arrayUnion",e)}(...e);return t._methodName="FieldValue.arrayUnion",new a$(t)}static arrayRemove(...e){const t=function(...e){return new jF("arrayRemove",e)}(...e);return t._methodName="FieldValue.arrayRemove",new a$(t)}static increment(e){const t=new qF("increment",e);return t._methodName="FieldValue.increment",new a$(t)}isEqual(e){return this._delegate.isEqual(e._delegate)}},setLogLevel:function(e){e=e,CR.setLogLevel(e)},CACHE_SIZE_UNLIMITED:-1};uF=Ap,hF=(e,t)=>new VU(e,t,new qU),uF.INTERNAL.registerComponent(new Kd("firestore-compat",e=>{var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("firestore").getImmediate();return hF(t,n)},"PUBLIC").setServiceProps(Object.assign({},rj))),uF.registerVersion("@firebase/firestore-compat","0.1.11-canary.88d43ec00");function ij(e,t){const n={};for(const r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r]));return n}function sj(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=>sj(e)):"function"==typeof e||"object"==typeof e?ij(e,e=>sj(e)):e}const oj="functions",aj={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 cj extends gd{constructor(e,t,n){super(`${oj}/${e}`,t||""),this.details=n}}function lj(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(!aj[e])return new cj("internal","internal");n=aj[e],r=e}var o=s.message;"string"==typeof o&&(r=o),i=s.details,void 0!==i&&(i=sj(i))}}catch(e){}return"ok"===n?null:new cj(n,r,i)}class uj{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 hj="us-central1";class dj{constructor(e,t,n,r,i=hj,s){this.app=e,this.fetchImpl=s,this.emulatorOrigin=null,this.contextProvider=new uj(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=hj}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 pj(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 ij(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 cj("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 cj("cancelled","Firebase Functions instance was deleted.");var h=lj(u.status,u.json);if(h)throw h;if(!u.json)throw new cj("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 cj("internal","Response is missing data field.");h=sj(d);return{data:h}}(t,n,e,r||{})}const fj="@firebase/functions",gj="0.7.7-canary.88d43ec00";function mj(e,t,n){$d(e).emulatorOrigin=`http://${t}:${n}`}dF=fetch.bind(self),dp(new Kd(oj,(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 dj(n,r,i,s,t,dF)},"PUBLIC").setMultipleInstances(!0)),wp(fj,gj,pF),wp(fj,gj,"esm2017");var vj,yj,_j,wj;class bj{constructor(e,t){this.app=e,this._delegate=t,this._region=this._delegate.region,this._customDomain=this._delegate.customDomain}httpsCallable(e,t){return pj($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 mj(this._delegate,t[1],Number(t[2]))}useEmulator(e,t){return mj(this._delegate,e,t)}}const Ij="us-central1",Tj=(e,{instanceIdentifier:t})=>{var n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("functions").getImmediate({identifier:null!=t?t:Ij});return new bj(n,r)};vj={Functions:bj},Ap.INTERNAL.registerComponent(new Kd("functions-compat",Tj,"PUBLIC").setServiceProps(vj).setMultipleInstances(!0)),Ap.registerVersion("@firebase/functions-compat","0.1.8-canary.88d43ec00");const Ej="/firebase-messaging-sw.js",kj="/firebase-cloud-messaging-push-scope",Sj="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",Cj="https://fcmregistrations.googleapis.com/v1",Aj="google.c.a.c_id",Nj="google.c.a.e";function Rj(e){var t=new Uint8Array(e);const n=btoa(String.fromCharCode(...t));return n.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(yt=VB=VB||{})[yt.DATA_MESSAGE=1]="DATA_MESSAGE",yt[yt.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION",(yt=yj=yj||{}).PUSH_RECEIVED="push-received",yt.NOTIFICATION_CLICKED="notification-clicked";const Pj="fcm_token_details_db",xj="fcm_token_object_Store";async function Dj(s){if("databases"in indexedDB){const t=await indexedDB.databases(),n=t.map(e=>e.name);if(!n.includes(Pj))return null}let o=null;const e=await Vp(Pj,5,async e=>{var t;if(!(e.oldVersion<2)&&e.objectStoreNames.contains(xj)){const i=e.transaction.objectStore(xj);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:Rj(n.vapidKey)}}):3===e.oldVersion?(n=r,o={token:n.fcmToken,createTime:n.createTime,subscriptionOptions:{auth:Rj(n.auth),p256dh:Rj(n.p256dh),endpoint:n.endpoint,swScope:n.swScope,vapidKey:Rj(n.vapidKey)}}):4===e.oldVersion&&(r=r,o={token:r.fcmToken,createTime:r.createTime,subscriptionOptions:{auth:Rj(r.auth),p256dh:Rj(r.p256dh),endpoint:r.endpoint,swScope:r.swScope,vapidKey:Rj(r.vapidKey)}}))}});return e.close(),await Bp(Pj),await Bp("fcm_vapid_details_db"),await Bp("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 Oj="firebase-messaging-database",Mj=1,Lj="firebase-messaging-store";let Fj=null;function Uj(){return Fj=Fj||Vp(Oj,Mj,e=>{0===e.oldVersion&&e.createObjectStore(Lj)}),Fj}async function jj(e){var t=Vj(e);const n=await Uj();t=await n.transaction(Lj).objectStore(Lj).get(t);if(t)return t;t=await Dj(e.appConfig.senderId);return t?(await qj(e,t),t):void 0}async function qj(e,t){var n=Vj(e);const r=await Uj(),i=r.transaction(Lj,"readwrite");return await i.objectStore(Lj).put(t,n),await i.complete,t}function Vj({appConfig:e}){return e.appId}const Bj=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 Wj(e,t){var n={method:"DELETE",headers:await Kj(e)};try{const s=await fetch(`${$j(e.appConfig)}/${t}`,n);var r=await s.json();if(r.error){var i=r.error.message;throw Bj.create("token-unsubscribe-failed",{errorInfo:i})}}catch(e){throw Bj.create("token-unsubscribe-failed",{errorInfo:e})}}function $j({projectId:e}){return`${Cj}/projects/${e}/registrations`}async function Kj({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 zj({p256dh:e,auth:t,endpoint:n,vapidKey:r}){const i={web:{endpoint:n,auth:t,p256dh:e}};return r!==Sj&&(i.web.applicationPubKey=r),i}const Hj=6048e5;async function Gj(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:Rj(t.getKey("auth")),p256dh:Rj(t.getKey("p256dh"))},c=await jj(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+Hj?async function(t,e){try{var n=await async function(e,t){var n=await Kj(e),r=zj(t.subscriptionOptions),r={method:"PATCH",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(`${$j(e.appConfig)}/${t.token}`,r);i=await s.json()}catch(e){throw Bj.create("token-update-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Bj.create("token-update-failed",{errorInfo:r})}if(!i.token)throw Bj.create("token-update-no-token");return i.token}(t.firebaseDependencies,e),r=Object.assign(Object.assign({},e),{token:n,createTime:Date.now()});return await qj(t.firebaseDependencies,r),n}catch(e){throw await Qj(t),e}}(e,{token:c.token,createTime:Date.now(),subscriptionOptions:a}):c.token;try{await Wj(e.firebaseDependencies,c.token)}catch(e){console.warn(e)}return Yj(e.firebaseDependencies,a)}return Yj(e.firebaseDependencies,a)}async function Qj(e){var t=await jj(e.firebaseDependencies);t&&(await Wj(e.firebaseDependencies,t.token),await async function(e){var t=Vj(e);const n=await Uj(),r=n.transaction(Lj,"readwrite");await r.objectStore(Lj).delete(t),await r.complete}(e.firebaseDependencies));const n=await e.swRegistration.pushManager.getSubscription();return!n||n.unsubscribe()}async function Yj(e,t){var n={token:await async function(e,t){var n=await Kj(e),r=zj(t),r={method:"POST",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch($j(e.appConfig),r);i=await s.json()}catch(e){throw Bj.create("token-subscribe-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Bj.create("token-subscribe-failed",{errorInfo:r})}if(!i.token)throw Bj.create("token-subscribe-no-token");return i.token}(e,t),createTime:Date.now(),subscriptionOptions:t};return await qj(e,n),n.token}function Jj(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 Xj(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 Zj(e){return Bj.create("missing-app-config-values",{valueName:e})}Xj("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),Xj("AzSCbw63g1R0nCw85jG8","Iaya3yLKwmgvh7cF0q4");class eq{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 Zj("App Configuration Object");if(!e.name)throw Zj("App Name");var t=e["options"];for(const n of["projectId","apiKey","appId","messagingSenderId"])if(!t[n])throw Zj(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 tq(e){try{e.swRegistration=await navigator.serviceWorker.register(Ej,{scope:kj}),e.swRegistration.update().catch(()=>{})}catch(e){throw Bj.create("failed-service-worker-registration",{browserErrorMessage:e.message})}}async function nq(e,t){if(!navigator)throw Bj.create("only-available-in-window");if("default"===Notification.permission&&await Notification.requestPermission(),"granted"!==Notification.permission)throw Bj.create("permission-blocked");var n,r;return n=e,await((r=null==t?void 0:t.vapidKey)?n.vapidKey=r:n.vapidKey||(n.vapidKey=Sj)),await async function(e,t){if(t||e.swRegistration||await tq(e),t||!e.swRegistration){if(!(t instanceof ServiceWorkerRegistration))throw Bj.create("invalid-sw-registration");e.swRegistration=t}}(e,null==t?void 0:t.serviceWorkerRegistration),Gj(e)}async function rq(e,t,n){var r=function(e){switch(e){case yj.NOTIFICATION_CLICKED:return"notification_open";case yj.PUSH_RECEIVED:return"notification_foreground";default:throw new Error}}(t);const i=await e.firebaseDependencies.analyticsProvider.get();i.logEvent(r,{message_id:n[Aj],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 iq(e,t){var n,r=t.data;r.isFirebaseMessaging&&(e.onMessageHandler&&r.messageType===yj.PUSH_RECEIVED&&("function"==typeof e.onMessageHandler?e.onMessageHandler(Jj(r)):e.onMessageHandler.next(Jj(r))),n=r.data,"object"==typeof(t=n)&&t&&Aj in t&&"1"===n[Nj]&&await rq(e,r.messageType,n))}const sq="@firebase/messaging",oq="0.9.5-canary.88d43ec00",aq=e=>{const t=new eq(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return navigator.serviceWorker.addEventListener("message",e=>iq(t,e)),t},cq=e=>{const t=e.getProvider("messaging").getImmediate();return{getToken:e=>nq(t,e)}};function lq(e){return async function(e){if(!navigator)throw Bj.create("only-available-in-window");return e.swRegistration||await tq(e),Qj(e)}(e=$d(e))}function uq(e,t){return function(e,t){if(!navigator)throw Bj.create("only-available-in-window");return e.onMessageHandler=t,()=>{e.onMessageHandler=null}}(e=$d(e),t)}dp(new Kd("messaging",aq,"PUBLIC")),dp(new Kd("messaging-internal",cq,"PRIVATE")),wp(sq,oq),wp(sq,oq,"esm2017");const hq="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",dq="https://fcmregistrations.googleapis.com/v1",pq="FCM_MSG",fq="google.c.a.c_id",gq=3,mq=1;function vq(e){var t=new Uint8Array(e);const n=btoa(String.fromCharCode(...t));return n.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(yt=_j=_j||{})[yt.DATA_MESSAGE=1]="DATA_MESSAGE",yt[yt.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION",(c=wj=wj||{}).PUSH_RECEIVED="push-received",c.NOTIFICATION_CLICKED="notification-clicked";const yq="fcm_token_details_db",_q="fcm_token_object_Store";async function wq(s){if("databases"in indexedDB){const t=await indexedDB.databases(),n=t.map(e=>e.name);if(!n.includes(yq))return null}let o=null;const e=await Vp(yq,5,async e=>{var t;if(!(e.oldVersion<2)&&e.objectStoreNames.contains(_q)){const i=e.transaction.objectStore(_q);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:vq(n.vapidKey)}}):3===e.oldVersion?(n=r,o={token:n.fcmToken,createTime:n.createTime,subscriptionOptions:{auth:vq(n.auth),p256dh:vq(n.p256dh),endpoint:n.endpoint,swScope:n.swScope,vapidKey:vq(n.vapidKey)}}):4===e.oldVersion&&(r=r,o={token:r.fcmToken,createTime:r.createTime,subscriptionOptions:{auth:vq(r.auth),p256dh:vq(r.p256dh),endpoint:r.endpoint,swScope:r.swScope,vapidKey:vq(r.vapidKey)}}))}});return e.close(),await Bp(yq),await Bp("fcm_vapid_details_db"),await Bp("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 bq="firebase-messaging-database",Iq=1,Tq="firebase-messaging-store";let Eq=null;function kq(){return Eq=Eq||Vp(bq,Iq,e=>{0===e.oldVersion&&e.createObjectStore(Tq)}),Eq}async function Sq(e){var t=Aq(e);const n=await kq();t=await n.transaction(Tq).objectStore(Tq).get(t);if(t)return t;t=await wq(e.appConfig.senderId);return t?(await Cq(e,t),t):void 0}async function Cq(e,t){var n=Aq(e);const r=await kq(),i=r.transaction(Tq,"readwrite");return await i.objectStore(Tq).put(t,n),await i.complete,t}function Aq({appConfig:e}){return e.appId}const Nq=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 Rq(e,t){var n={method:"DELETE",headers:await xq(e)};try{const s=await fetch(`${Pq(e.appConfig)}/${t}`,n);var r=await s.json();if(r.error){var i=r.error.message;throw Nq.create("token-unsubscribe-failed",{errorInfo:i})}}catch(e){throw Nq.create("token-unsubscribe-failed",{errorInfo:e})}}function Pq({projectId:e}){return`${dq}/projects/${e}/registrations`}async function xq({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 Dq({p256dh:e,auth:t,endpoint:n,vapidKey:r}){const i={web:{endpoint:n,auth:t,p256dh:e}};return r!==hq&&(i.web.applicationPubKey=r),i}async function Oq(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:vq(t.getKey("auth")),p256dh:vq(t.getKey("p256dh"))},c=await Sq(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 xq(e),r=Dq(t.subscriptionOptions),r={method:"PATCH",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(`${Pq(e.appConfig)}/${t.token}`,r);i=await s.json()}catch(e){throw Nq.create("token-update-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Nq.create("token-update-failed",{errorInfo:r})}if(!i.token)throw Nq.create("token-update-no-token");return i.token}(t.firebaseDependencies,e),r=Object.assign(Object.assign({},e),{token:n,createTime:Date.now()});return await Cq(t.firebaseDependencies,r),n}catch(e){throw await Mq(t),e}}(e,{token:c.token,createTime:Date.now(),subscriptionOptions:a}):c.token;try{await Rq(e.firebaseDependencies,c.token)}catch(e){console.warn(e)}return Lq(e.firebaseDependencies,a)}return Lq(e.firebaseDependencies,a)}async function Mq(e){var t=await Sq(e.firebaseDependencies);t&&(await Rq(e.firebaseDependencies,t.token),await async function(e){var t=Aq(e);const n=await kq(),r=n.transaction(Tq,"readwrite");await r.objectStore(Tq).delete(t),await r.complete}(e.firebaseDependencies));const n=await e.swRegistration.pushManager.getSubscription();return!n||n.unsubscribe()}async function Lq(e,t){var n={token:await async function(e,t){var n=await xq(e),r=Dq(t),r={method:"POST",headers:n,body:JSON.stringify(r)};let i;try{const s=await fetch(Pq(e.appConfig),r);i=await s.json()}catch(e){throw Nq.create("token-subscribe-failed",{errorInfo:e})}if(i.error){r=i.error.message;throw Nq.create("token-subscribe-failed",{errorInfo:r})}if(!i.token)throw Nq.create("token-subscribe-no-token");return i.token}(e,t),createTime:Date.now(),subscriptionOptions:t};return await Cq(e,n),n.token}async function Fq(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=_j.DISPLAY_NOTIFICATION.toString():r.message_type=_j.DATA_MESSAGE.toString();r.sdk_platform=gq.toString(),r.package_name=self.origin.replace(/(^\w+:|^)\/\//,""),e.collapse_key&&(r.collapse_key=e.collapse_key);r.event=mq.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 Uq(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 jq(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 Fq(t,n);var r,i,s=await Vq();if(s.some(e=>"visible"===e.visibilityState&&!e.url.startsWith("chrome-extension://")))return function(e,t){t.isFirebaseMessaging=!0,t.messageType=wj.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={[pq]: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 qq(e){const t=null===(s=null===(i=e.notification)||void 0===i?void 0:i.data)||void 0===s?void 0:s[pq];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&&fq 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 Vq();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=wj.NOTIFICATION_CLICKED,t.isFirebaseMessaging=!0,e.postMessage(t)}}}}function Vq(){return self.clients.matchAll({type:"window",includeUncontrolled:!0})}function Bq(e){return Nq.create("missing-app-config-values",{valueName:e})}Uq("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),Uq("AzSCbw63g1R0nCw85jG8","Iaya3yLKwmgvh7cF0q4");class Wq{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 Bq("App Configuration Object");if(!e.name)throw Bq("App Name");var t=e["options"];for(const n of["projectId","apiKey","appId","messagingSenderId"])if(!t[n])throw Bq(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 $q=e=>{const t=new Wq(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return self.addEventListener("push",e=>{e.waitUntil(jq(e,t))}),self.addEventListener("pushsubscriptionchange",e=>{e.waitUntil(async function(e,t){var n;(n=e["newSubscription"])?(n=await Sq(t.firebaseDependencies),await Mq(t),t.vapidKey=null!==(n=null===(n=null==n?void 0:n.subscriptionOptions)||void 0===n?void 0:n.vapidKey)&&void 0!==n?n:hq,await Oq(t)):await Mq(t)}(e,t))}),self.addEventListener("notificationclick",e=>{e.waitUntil(qq(e))}),t};function Kq(e,t){return function(e,t){if(void 0!==self.document)throw Nq.create("only-available-in-sw");return e.onBackgroundMessageHandler=t,()=>{e.onBackgroundMessageHandler=null}}(e=$d(e),t)}dp(new Kd("messaging-sw",$q,"PUBLIC"));var zq,Hq,Gq;class Qq{constructor(e,t){this.app=e,this._delegate=t,this.app=e,this._delegate=t}async getToken(e){return async function(e,t){return nq(e=$d(e),t)}(this._delegate,e)}async deleteToken(){return lq(this._delegate)}onMessage(e){return uq(this._delegate,e)}onBackgroundMessage(e){return Kq(this._delegate,e)}}const Yq=e=>self&&"ServiceWorkerGlobalScope"in self?new Qq(e.getProvider("app-compat").getImmediate(),e.getProvider("messaging-sw").getImmediate()):new Qq(e.getProvider("app-compat").getImmediate(),e.getProvider("messaging").getImmediate()),Jq={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")}};Ap.INTERNAL.registerComponent(new Kd("messaging-compat",Yq,"PUBLIC").setServiceProps(Jq)),Ap.registerVersion("@firebase/messaging-compat","0.1.5-canary.88d43ec00");const Xq="firebasestorage.googleapis.com",Zq="storageBucket";class eV extends gd{constructor(e,t){super(tV(e),`Firebase Storage: ${t} (${tV(e)})`),this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,eV.prototype)}_codeEquals(e){return tV(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 tV(e){return"storage/"+e}function nV(){return new eV("unknown","An unknown error occurred, please check the error payload for server response.")}function rV(){return new eV("canceled","User canceled the upload/download.")}function iV(){return new eV("cannot-slice-blob","Cannot slice blob for upload. Please retry the upload.")}function sV(e){return new eV("invalid-argument",e)}function oV(){return new eV("app-deleted","The Firebase app was deleted.")}function aV(e){return new eV("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 cV(e,t){return new eV("invalid-format","String does not match format '"+e+"': "+t)}function lV(e){throw new eV("internal-error","Internal error: "+e)}class uV{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=uV.makeFromUrl(t,e)}catch(e){return new uV(t,"")}if(""===n.path)return n;throw t=t,new eV("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===Xq?"(?: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 uV(u,e),d.postModify(n);break}}if(null==n)throw t=e,new eV("invalid-url","Invalid URL '"+t+"'.");return n}}class hV{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=0){}}function dV(e){return"string"==typeof e||e instanceof String}function pV(e){return fV()&&e instanceof Blob}function fV(){return"undefined"!=typeof Blob}function gV(e,t,n,r){if(r<t)throw sV(`Invalid value for '${e}'. Expected ${t} or greater.`);if(n<r)throw sV(`Invalid value for '${e}'. Expected ${n} or less.`)}function mV(e,t,n){let r=null==n?`https://${t}`:t;return`${n}://${r}/v0${e}`}function vV(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=zq=zq||{})[c.NO_ERROR=0]="NO_ERROR",c[c.NETWORK_ERROR=1]="NETWORK_ERROR",c[c.ABORT=2]="ABORT";class yV{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 _V(!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()===zq.NO_ERROR,n=i.getStatus();t&&!this.isRetryStatusCode_(n)?(e=-1!==this.successCodes_.indexOf(n),r(!0,new _V(e,i))):(e=i.getErrorCode()===zq.ABORT,r(!1,new _V(!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=nV();a.serverResponse=i.getErrorText(),this.errorCallback_?r(this.errorCallback_(i,a)):r(a)}else{var o;t.canceled?(o=(this.appDelete_?oV:rV)(),r(o)):(o=new eV("retry-limit-exceeded","Max retry time for operation exceeded, please try again."),r(o))}};this.canceled_?t(0,new _V(!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 _V{constructor(e,t,n){this.wasSuccessCode=e,this.connection=t,this.canceled=!!n}}function wV(...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(fV())return new Blob(t);throw new eV("unsupported-environment","This browser doesn't seem to support creating Blobs")}const bV={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class IV{constructor(e,t){this.data=e,this.contentType=t||null}}function TV(e,t){switch(e){case bV.RAW:return new IV(EV(t));case bV.BASE64:case bV.BASE64URL:return new IV(kV(e,t));case bV.DATA_URL:return new IV((n=t,(r=new SV(n)).base64?kV(bV.BASE64,r.rest):function(e){let t;try{t=decodeURIComponent(e)}catch(e){throw cV(bV.DATA_URL,"Malformed data URL.")}return EV(t)}(r.rest)),(n=t,new SV(n).contentType))}var n,r;throw nV()}function EV(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 kV(t,e){switch(t){case bV.BASE64:var n=-1!==e.indexOf("-"),r=-1!==e.indexOf("_");if(n||r)throw cV(t,"Invalid character '"+(n?"-":"_")+"' found: is it base64url encoded?");break;case bV.BASE64URL:r=-1!==e.indexOf("+"),n=-1!==e.indexOf("/");if(r||n)throw cV(t,"Invalid character '"+(r?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/")}let i;try{i=atob(e)}catch(e){throw cV(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 SV{constructor(e){this.base64=!1,this.contentType=null;var t,n,r=e.match(/^data:([^,]+)?,/);if(null===r)throw cV(bV.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 CV{constructor(e,t){let n=0,r="";pV(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(pV(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 CV(n)}var r,i,s,n=new Uint8Array(this.data_.buffer,e,t-e);return new CV(n,!0)}static getBlob(...e){if(fV()){var t=e.map(e=>e instanceof CV?e.data_:e);return new CV(wV.apply(null,t))}{const r=e.map(e=>dV(e)?TV(bV.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 CV(i,!0)}}uploadData(){return this.data_}}function AV(e){let t;try{t=JSON.parse(e)}catch(e){return null}return"object"!=typeof(e=t)||Array.isArray(e)?null:t}function NV(e){var t=e.lastIndexOf("/",e.length-2);return-1===t?e:e.slice(t+1)}function RV(e,t){return t}class PV{constructor(e,t,n,r){this.server=e,this.local=t||e,this.writable=!!n,this.xform=r||RV}}let xV=null;function DV(){if(xV)return xV;const e=[];e.push(new PV("bucket")),e.push(new PV("generation")),e.push(new PV("metageneration")),e.push(new PV("name","fullPath",!0));const t=new PV("name");t.xform=function(e,t){return!dV(t=t)||t.length<2?t:NV(t)},e.push(t);const n=new PV("size");return n.xform=function(e,t){return void 0!==t?Number(t):t},e.push(n),e.push(new PV("timeCreated")),e.push(new PV("updated")),e.push(new PV("md5Hash",null,!0)),e.push(new PV("cacheControl",null,!0)),e.push(new PV("contentDisposition",null,!0)),e.push(new PV("contentEncoding",null,!0)),e.push(new PV("contentLanguage",null,!0)),e.push(new PV("contentType",null,!0)),e.push(new PV("metadata","customMetadata",!0)),xV=e,xV}function OV(n,r){Object.defineProperty(n,"ref",{get:function(){var e=n.bucket,t=n.fullPath,t=new uV(e,t);return r._makeStorageReference(t)}})}function MV(e,t,n){var r=AV(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 OV(r,e),r}(e,r,n)}function LV(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 FV(e,t,n){var r=AV(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 uV(t,i));r.prefixes.push(i)}if(n.items)for(const a of n.items){var s=e._makeStorageReference(new uV(t,a.name));r.items.push(s)}return r}(e,t,r)}class UV{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 jV(e){if(!e)throw nV()}function qV(r,i){return function(e,t){var n=MV(r,t,i);return jV(null!==n),n}}function VV(r,i){return function(e,t){var n=FV(r,i,t);return jV(null!==n),n}}function BV(r,i){return function(e,t){var n=MV(r,t,i);return jV(null!==n),function(r,e,i,s){var t=AV(e);if(null===t)return null;if(!dV(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 mV("/b/"+o(t)+"/o/"+o(n),i,s)+vV({alt:"media",token:e})})[0]}(n,t,r.host,r._protocol)}}function WV(i){return function(e,t){let n;var r;return n=401===e.getStatus()?e.getErrorText().includes("Firebase App Check token is invalid")?new eV("unauthorized-app","This app does not have permission to access Firebase Storage on this project."):new eV("unauthenticated","User is not authenticated, please authenticate using Firebase Authentication and try again."):402===e.getStatus()?(r=i.bucket,new eV("quota-exceeded","Quota for bucket '"+r+"' exceeded, please view quota on https://firebase.google.com/pricing/.")):403===e.getStatus()?(e=i.path,new eV("unauthorized","User does not have permission to access '"+e+"'.")):t,n.serverResponse=t.serverResponse,n}}function $V(r){const i=WV(r);return function(e,t){let n=i(e,t);return 404===e.getStatus()&&(n=(e=r.path,new eV("object-not-found","Object '"+e+"' does not exist."))),n.serverResponse=t.serverResponse,n}}function KV(e,t,n){var r=mV(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime;const s=new UV(r,"GET",qV(e,n),i);return s.errorHandler=$V(t),s}function zV(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 HV(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=zV(t,r,i),l="--"+a+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+LV(c,n)+"\r\n--"+a+"\r\nContent-Type: "+c.contentType+"\r\n\r\n",a="\r\n--"+a+"--";const u=CV.getBlob(l,r,a);if(null===u)throw iV();a={name:c.fullPath},c=mV(s,e.host,e._protocol),s=e.maxUploadRetryTime;const h=new UV(c,"POST",qV(e,n),s);return h.urlParams=a,h.headers=o,h.body=u.uploadData(),h.errorHandler=WV(t),h}class GV{constructor(e,t,n,r){this.current=e,this.total=t,this.finalized=!!n,this.metadata=r||null}}function QV(e,t){let n=null;try{n=e.getResponseHeader("X-Goog-Upload-Status")}catch(e){jV(!1)}const r=t||["active"];return jV(!!n&&-1!==r.indexOf(n)),n}function YV(e,t,n,r,i){var s=t.bucketOnlyServerUrl(),o=zV(t,r,i),a={name:o.fullPath},c=mV(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=LV(o,n),o=e.maxUploadRetryTime;const u=new UV(c,"POST",function(e){QV(e);let t;try{t=e.getResponseHeader("X-Goog-Upload-URL")}catch(e){jV(!1)}return jV(dV(t)),t},o);return u.urlParams=a,u.headers=l,u.body=s,u.errorHandler=WV(t),u}function JV(e,t,n,i){var r=e.maxUploadRetryTime;const s=new UV(n,"POST",function(e){var t=QV(e,["active","final"]);let n=null;try{n=e.getResponseHeader("X-Goog-Upload-Size-Received")}catch(e){jV(!1)}n||jV(!1);var r=Number(n);return jV(!isNaN(r)),new GV(r,i.size(),"final"===t)},r);return s.headers={"X-Goog-Upload-Command":"query"},s.errorHandler=WV(t),s}function XV(e,o,t,a,n,c,r,i){const l=new GV(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 eV("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 iV();d=o.maxUploadRetryTime;const f=new UV(t,"POST",function(e,t){var n=QV(e,["active","final"]),r=l.current+u,i=a.size();let s;return s="final"===n?qV(o,c)(e,t):null,new GV(r,i,"final"===n,s)},d);return f.headers=s,f.body=p.uploadData(),f.progressCallback=i||null,f.errorHandler=WV(e),f}const ZV={STATE_CHANGED:"state_changed"},eB={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function tB(e){switch(e){case"running":case"pausing":case"canceling":return eB.RUNNING;case"paused":return eB.PAUSED;case"success":return eB.SUCCESS;case"canceled":return eB.CANCELED;default:return eB.ERROR}}class nB{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 rB(t){return(...e)=>{Promise.resolve().then(()=>t(...e))}}class iB extends class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=zq.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=zq.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=zq.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,n,r){if(this.sent_)throw lV("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 lV("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw lV("cannot .getStatus() before sending");try{return this.xhr_.status}catch(e){return-1}}getResponse(){if(!this.sent_)throw lV("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw lV("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 sB(){return new iB}class oB{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=DV(),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=YV(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata);const r=this._ref.storage._makeRequest(n,sB,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=JV(this._ref.storage,this._ref._location,i,this._blob);const r=this._ref.storage._makeRequest(n,sB,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 GV(this._transferred,this._blob.size()),o=this._uploadUrl;this._resolveToken((e,t)=>{let n;try{n=XV(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,sB,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=KV(this._ref.storage,this._ref._location,this._mappings);const r=this._ref.storage._makeRequest(n,sB,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=HV(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata);const r=this._ref.storage._makeRequest(n,sB,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=rV(),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=tB(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 nB(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(tB(this._state)){case eB.SUCCESS:rB(this._resolve.bind(null,this.snapshot))();break;case eB.CANCELED:case eB.ERROR:const t=this._reject;rB(t.bind(null,this._error))();break;default:e=!1}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(tB(this._state)){case eB.RUNNING:case eB.PAUSED:e.next&&rB(e.next.bind(e,this.snapshot))();break;case eB.SUCCESS:e.complete&&rB(e.complete.bind(e))();break;case eB.CANCELED:case eB.ERROR:default:e.error&&rB(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 aB{constructor(e,t){this._service=e,t instanceof uV?this._location=t:this._location=uV.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new aB(e,t)}get root(){var e=new uV(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return NV(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 uV(this._location.bucket,e);return new aB(this._service,e)}_throwIfRoot(e){if(""===this._location.path)throw aV(e)}}function cB(e){const t={prefixes:[],items:[]};return async function e(t,n,r){const i={pageToken:r};const s=await lB(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 lB(e,t){null!=t&&"number"==typeof t.maxResults&&gV("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=mV(t.bucketOnlyServerUrl(),e.host,e._protocol),a=e.maxOperationRetryTime;const c=new UV(o,"GET",VV(e,t.bucket),a);return c.urlParams=s,c.errorHandler=WV(t),c}(e.storage,e._location,"/",n.pageToken,n.maxResults);return e.storage.makeRequestWithTokens(n,sB)}function uB(e,t){e._throwIfRoot("updateMetadata");var n=function(e,t,n,r){var i=mV(t.fullServerUrl(),e.host,e._protocol),s=LV(n,r),o=e.maxOperationRetryTime;const a=new UV(i,"PATCH",qV(e,r),o);return a.headers={"Content-Type":"application/json; charset=utf-8"},a.body=s,a.errorHandler=$V(t),a}(e.storage,e._location,t,DV());return e.storage.makeRequestWithTokens(n,sB)}function hB(e){e._throwIfRoot("getDownloadURL");var t=function(e,t,n){var r=mV(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime;const s=new UV(r,"GET",BV(e,n),i);return s.errorHandler=$V(t),s}(e.storage,e._location,DV());return e.storage.makeRequestWithTokens(t,sB).then(e=>{if(null===e)throw new eV("no-download-url","The given file does not have any download URLs.");return e})}function dB(e){e._throwIfRoot("deleteObject");var t=function(e,t){var n=mV(t.fullServerUrl(),e.host,e._protocol),r=e.maxOperationRetryTime;const i=new UV(n,"DELETE",function(e,t){},r);return i.successCodes=[200,204],i.errorHandler=$V(t),i}(e.storage,e._location);return e.storage.makeRequestWithTokens(t,sB)}function pB(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 uV(e._location.bucket,r);return new aB(e.storage,r)}function fB(e,t){if(e instanceof vB){var n=e;if(null==n._bucket)throw new eV("no-default-bucket","No default bucket found. Did you set the '"+Zq+"' property when initializing the app?");n=new aB(n,n._bucket);return null!=t?fB(n,t):n}return void 0!==t?pB(e,t):e}function gB(e,t){if(t&&/^[A-Za-z]+:\/\//.test(t)){if(e instanceof vB)return n=e,r=t,new aB(n,r);throw sV("To use ref(service, url), the first argument must be a Storage instance.")}return fB(e,t);var n,r}function mB(e,t){var n=null==t?void 0:t[Zq];return null==n?null:uV.makeFromBucketSpec(n,e)}class vB{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=Xq,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=12e4,this._maxUploadRetryTime=6e5,this._requests=new Set,this._bucket=null!=r?uV.makeFromBucketSpec(r,this._host):mB(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,null!=this._url?this._bucket=uV.makeFromBucketSpec(this._url,e):this._bucket=mB(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){gV("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){gV("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 aB(this,e)}_makeRequest(e,t,n,r){if(this._deleted)return new hV(oV());{const l=(i=e,s=this._appId,o=n,e=r,n=t,r=this._firebaseVersion,a=vV(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 yV(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 yB="@firebase/storage",_B="0.9.1-canary.88d43ec00";function wB(e,t,n){return e=$d(e),t=t,n=n,(e=e)._throwIfRoot("uploadBytesResumable"),new oB(e,new CV(t),n)}function bB(e){return function(e){e._throwIfRoot("getMetadata");var t=KV(e.storage,e._location,DV());return e.storage.makeRequestWithTokens(t,sB)}(e=$d(e))}function IB(e,t){return gB(e=$d(e),t)}function TB(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 EB(e,{instanceIdentifier:t}){var n=e.getProvider("app").getImmediate(),r=e.getProvider("auth-internal"),i=e.getProvider("app-check-internal");return new vB(n,r,i,t,mp)}dp(new Kd("storage",EB,"PUBLIC").setMultipleInstances(!0)),wp(yB,_B,""),wp(yB,_B,"esm2017");class kB{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 SB{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 kB(this._delegate.snapshot,this,this._ref)}then(t,e){return this._delegate.then(e=>{if(t)return t(new kB(e,this,this._ref))},e)}on(e,t,n,r){let i=void 0;return t&&(i="function"==typeof t?e=>t(new kB(e,this,this._ref)):{next:t.next?e=>t.next(new kB(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 CB{constructor(e,t){this._delegate=e,this._service=t}get prefixes(){return this._delegate.prefixes.map(e=>new AB(e,this._service))}get items(){return this._delegate.items.map(e=>new AB(e,this._service))}get nextPageToken(){return this._delegate.nextPageToken||null}}class AB{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=pB(this._delegate,e);return new AB(t,this.storage)}get root(){return new AB(this._delegate.root,this.storage)}get parent(){var e=this._delegate.parent;return null==e?null:new AB(e,this.storage)}put(e,t){return this._throwIfRoot("put"),new SB(wB(this._delegate,e,t),this)}putString(e,t=bV.RAW,n){this._throwIfRoot("putString");var r=TV(t,e);const i=Object.assign({},n);return null==i.contentType&&null!=r.contentType&&(i.contentType=r.contentType),new SB(new oB(this._delegate,new CV(r.data,!0),i),this)}listAll(){return cB($d(this._delegate)).then(e=>new CB(e,this.storage))}list(e){return t=this._delegate,e=e||void 0,lB(t=$d(t),e).then(e=>new CB(e,this.storage));var t}getMetadata(){return bB(this._delegate)}updateMetadata(e){return uB($d(this._delegate),e)}getDownloadURL(){return hB($d(this._delegate))}delete(){return this._throwIfRoot("delete"),dB($d(this._delegate))}_throwIfRoot(e){if(""===this._delegate._location.path)throw aV(e)}}class NB{constructor(e,t){this.app=e,this._delegate=t}get maxOperationRetryTime(){return this._delegate.maxOperationRetryTime}get maxUploadRetryTime(){return this._delegate.maxUploadRetryTime}ref(e){if(RB(e))throw sV("ref() expected a child path but got a URL, use refFromURL instead.");return new AB(IB(this._delegate,e),this)}refFromURL(e){if(!RB(e))throw sV("refFromURL() expected a full URL but got a child path, use ref() instead.");try{uV.makeFromUrl(e,this._delegate.host)}catch(e){throw sV("refFromUrl() expected a valid full URL but got an invalid one.")}return new AB(IB(this._delegate,e),this)}setMaxUploadRetryTime(e){this._delegate.maxUploadRetryTime=e}setMaxOperationRetryTime(e){this._delegate.maxOperationRetryTime=e}useEmulator(e,t,n={}){TB(this._delegate,e,t,n)}}function RB(e){return/^[A-Za-z]+:\/\//.test(e)}function PB(e,{instanceIdentifier:t}){var n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("storage").getImmediate({identifier:t});return new NB(n,r)}Hq=Ap,Gq={TaskState:eB,TaskEvent:ZV,StringFormat:bV,Storage:NB,Reference:AB},Hq.INTERNAL.registerComponent(new Kd("storage-compat",PB,"PUBLIC").setServiceProps(Gq).setMultipleInstances(!0)),Hq.registerVersion("@firebase/storage-compat","0.1.9-canary.88d43ec00");const xB="@firebase/performance",DB="0.5.5-canary.88d43ec00",OB=DB,MB="FB-PERF-TRACE-MEASURE",LB="@firebase/performance/config",FB="@firebase/performance/configexpire";var UB,jB,qB,VB="Performance";const BB=new md("performance",VB,{"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."}),WB=new ep(VB);WB.logLevel=$h.INFO;let $B,KB;class zB{constructor(e){if(!(this.window=e))throw BB.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()||(WB.info("IndexedDB is not supported by current browswer"),!1):(WB.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===$B&&($B=new zB(KB)),$B}}let HB;function GB(e,t){var n=e.length-t.length;if(n<0||1<n)throw BB.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 QB;class YB{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=GB("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),this.transportKey=GB("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===QB&&(QB=new YB),QB}}(c=UB=UB||{})[c.UNKNOWN=0]="UNKNOWN",c[c.VISIBLE=1]="VISIBLE",c[c.HIDDEN=2]="HIDDEN";const JB=["firebase_","google_","ga_"],XB=new RegExp("^[a-zA-Z]\\w*$");function ZB(){switch(zB.getInstance().document.visibilityState){case"visible":return UB.VISIBLE;case"hidden":return UB.HIDDEN;default:return UB.UNKNOWN}}function eW(e){var t=null===(t=e.options)||void 0===t?void 0:t.appId;if(!t)throw BB.create("no app id");return t}const tW="0.0.1",nW={loggingEnabled:!0},rW="FIREBASE_INSTALLATIONS_AUTH";function iW(e,t){var r,i,n=function(){const e=zB.getInstance().localStorage;if(e){var t=e.getItem(FB);if(t&&function(e){return Number(e)>Date.now()}(t)){t=e.getItem(LB);if(t)try{return JSON.parse(t)}catch(e){return}}}}();return n?(oW(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 BB.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 BB.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:`${rW} ${e}`},body:JSON.stringify({app_instance_id:i,app_instance_id_token:e,app_id:eW(r.app),app_version:OB,sdk_version:tW})});return fetch(n).then(e=>{if(e.ok)return e.json();throw BB.create("RC response not ok")})}).catch(()=>{WB.info(sW)}).then(oW).then(e=>function(e){const t=zB.getInstance().localStorage;e&&t&&(t.setItem(LB,JSON.stringify(e)),t.setItem(FB,String(Date.now()+60*YB.getInstance().configTimeToLive*60*1e3)))}(e),()=>{}))}const sW="Could not fetch config, will use default configs";function oW(e){if(!e)return e;const t=YB.getInstance();var n=e.entries||{};return void 0!==n.fpr_enabled?t.loggingEnabled="true"===String(n.fpr_enabled):t.loggingEnabled=nW.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=aW(t.tracesSamplingRate),t.logNetworkAfterSampling=aW(t.networkRequestsSamplingRate),e}function aW(e){return Math.random()<=e}let cW=1,lW;function uW(e){var t;return cW=2,lW=lW||(t=e,function(){const n=zB.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=>{HB=e}),t}(t.installations)).then(e=>iW(t,e)).then(()=>hW(),()=>hW())),lW}function hW(){cW=3}const dW=1e4,pW=3,fW=1e3;let gW=pW,mW=[],vW=!1;function yW(e){setTimeout(()=>{if(0!==gW)return mW.length?void function(){const e=mW.splice(0,fW),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:YB.getInstance().logSource,log_event:t};!function(e,r){return function(e){var t=YB.getInstance().getFlTransportFullUrl();return fetch(t,{method:"POST",body:JSON.stringify(e)})}(e).then(e=>(e.ok||WB.info("Call to Firebase backend failed."),e.json())).then(e=>{var t=Number(e.nextRequestWaitMillis);let n=dW;isNaN(t)||(n=Math.max(t,n));t=e.logResponseDetails;Array.isArray(t)&&0<t.length&&"RETRY_REQUEST_LATER"===t[0].responseAction&&(mW=[...r,...mW],WB.info("Retry transport request later.")),gW=pW,yW(n)})}(n,e).catch(()=>{mW=[...e,...mW],gW--,WB.info(`Tries left: ${gW}.`),yW(dW)})}():yW(dW)},e)}function _W(t){return(...e)=>{!function(e){if(!e.eventTime||!e.message)throw BB.create("invalid cc log");mW=[...mW,e]}({message:t(...e),eventTime:Date.now()})}}let wW;function bW(e,t){wW=wW||_W(EW),wW(e,t)}function IW(e){var t=YB.getInstance();!t.instrumentationEnabled&&e.isAuto||(t.dataCollectionEnabled||e.isAuto)&&zB.getInstance().requiredApisAvailable()&&(e.isAuto&&ZB()!==UB.VISIBLE||(3===cW?TW(e):uW(e.performanceController).then(()=>TW(e),()=>TW(e))))}function TW(e){var t;!HB||(t=YB.getInstance()).loggingEnabled&&t.logTraceAfterSampling&&setTimeout(()=>bW(e,1),0)}function EW(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:kW(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:kW(e.performanceController.app),trace_metric:t};return JSON.stringify(n)}(e);var n}function kW(e){return{google_app_id:eW(e),app_instance_id:HB,web_app_info:{sdk_version:OB,page_url:zB.getInstance().getUrl(),service_worker_status:"serviceWorker"in(t=zB.getInstance().navigator)?t.serviceWorker.controller?2:3:1,visibility_state:ZB(),effective_connection_type:function(){var e=zB.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 SW=["_fp","_fcp","_fid"];class CW{constructor(e,t,n=!1,r){this.performanceController=e,this.name=t,this.isAuto=n,this.state=1,this.customAttributes={},this.counters={},this.api=zB.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||`${MB}-${this.randomId}-${this.name}`,r&&this.calculateTraceMetrics())}start(){if(1!==this.state)throw BB.create("trace started",{traceName:this.name});this.api.mark(this.traceStartMark),this.state=2}stop(){if(2!==this.state)throw BB.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(),IW(this)}record(e,t,n){if(e<=0)throw BB.create("nonpositive trace startTime",{traceName:this.name});if(t<=0)throw BB.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])));IW(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<SW.indexOf(r))&&r.startsWith("_"))throw BB.create("invalid custom metric name",{customMetricName:e});var n,r,i;this.counters[e]=(t=t,(n=Math.floor(t))<t&&WB.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)&&(!JB.some(e=>n.startsWith(e))&&!!n.match(XB)),s=0!==(r=t).length&&r.length<=100;if(i&&s)this.customAttributes[e]=t;else{if(!i)throw BB.create("invalid attribute name",{attributeName:e});if(!s)throw BB.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=zB.getInstance().getUrl();if(i){const s=new CW(e,"_wt_"+i,!0);i=Math.floor(1e3*zB.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))),IW(s)}}static createUserTimingTrace(e,t){IW(new CW(e,t,!1,t))}}function AW(e,t){const n=t;var r,i,s;n&&void 0!==n.responseStart&&(s=zB.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=YB.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(()=>bW(e,0),0))}({performanceController:e,url:n.name&&n.name.split("?")[0],responsePayloadBytes:n.transferSize,startTimeUs:r,timeToResponseInitiatedUs:i,timeToResponseCompletedUs:s}))}const NW=5e3;function RW(e){HB&&(setTimeout(()=>function(n){const e=zB.getInstance(),r=e.getEntriesByType("navigation"),i=e.getEntriesByType("paint");if(e.onFirstInputDelay){let t=setTimeout(()=>{CW.createOobTrace(n,r,i),t=void 0},NW);e.onFirstInputDelay(e=>{t&&(clearTimeout(t),CW.createOobTrace(n,r,i,e))})}else CW.createOobTrace(n,r,i)}(e),0),setTimeout(()=>function(t){const e=zB.getInstance(),n=e.getEntriesByType("resource");for(const r of n)AW(t,r);e.setupObserver("resource",e=>AW(t,e))}(e),0),setTimeout(()=>function(t){const e=zB.getInstance(),n=e.getEntriesByType("measure");for(const r of n)PW(t,r);e.setupObserver("measure",e=>PW(t,e))}(e),0))}function PW(e,t){const n=t.name;n.substring(0,MB.length)!==MB&&CW.createUserTimingTrace(e,n)}class xW{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),zB.getInstance().requiredApisAvailable()?pd().then(e=>{e&&(vW||(yW(5500),vW=!0),uW(this).then(()=>RW(this),()=>RW(this)),this.initialized=!0)}).catch(e=>{WB.info(`Environment doesn't support IndexedDB: ${e}`)}):WB.info('Firebase Performance cannot start if the browser does not support "Fetch" and "Promise", or cookies are disabled.'))}set instrumentationEnabled(e){YB.getInstance().instrumentationEnabled=e}get instrumentationEnabled(){return YB.getInstance().instrumentationEnabled}set dataCollectionEnabled(e){YB.getInstance().dataCollectionEnabled=e}get dataCollectionEnabled(){return YB.getInstance().dataCollectionEnabled}}const DW="[DEFAULT]";const OW=(e,{options:t})=>{var n=e.getProvider("app").getImmediate(),r=e.getProvider("installations-internal").getImmediate();if(n.name!==DW)throw BB.create("FB not default");if("undefined"==typeof window)throw BB.create("no window");e=window,KB=e;const i=new xW(n,r);return i._init(t),i};dp(new Kd("performance",OW,"PUBLIC")),wp(xB,DB),wp(xB,DB,"esm2017");class MW{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 CW(t,e);var t}}function LW(e){var t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("performance").getImmediate();return new MW(t,n)}(jB=Ap).INTERNAL.registerComponent(new Kd("performance-compat",LW,"PUBLIC")),jB.registerVersion("@firebase/performance-compat","0.1.5-canary.88d43ec00");const FW="@firebase/remote-config",UW="0.3.4-canary.88d43ec00";class jW{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}const qW=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 VW=["1","true","t","yes","y","on"];class BW{constructor(e,t=""){this._source=e,this._value=t}asString(){return this._value}asBoolean(){return"static"!==this._source&&0<=VW.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 WW(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 $W(e){const t=$d(e);return t._initializePromise||(t._initializePromise=t._storageCache.loadFromStorage().then(()=>{t._isInitializationComplete=!0})),t._initializePromise}async function KW(t){const n=$d(t),e=new jW;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 zW(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]=HW(n,t),e),{});var t,r}function HW(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 BW("remote",r[t]):n.defaultConfig&&void 0!==n.defaultConfig[t]?new BW("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 BW("static"))}class GW{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"),qW.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 qW.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 qW.create("fetch-status",{httpStatus:a});return{status:a,eTag:i,config:c}}}class YW{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(qW.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 JW{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 XW(e,t){var n=e.target.error||void 0;return qW.create(t,{originalErrorMessage:n&&n.message})}const ZW="app_namespace_store";class e${constructor(e,t,n,r=function(){return new Promise((t,n)=>{try{const e=indexedDB.open("firebase_remote_config",1);e.onerror=e=>{n(XW(e,"storage-open"))},e.onsuccess=e=>{t(e.target.result)},e.onupgradeneeded=e=>{const t=e.target.result;0===e.oldVersion&&t.createObjectStore(ZW,{keyPath:"compositeKey"})}}catch(e){n(qW.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([ZW],"readonly"),r=e.objectStore(ZW);var i=this.createCompositeKey(o);try{const s=r.get(i);s.onerror=e=>{t(XW(e,"storage-get"))},s.onsuccess=e=>{var t=e.target.result;n(t?t.value:void 0)}}catch(e){t(qW.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([ZW],"readwrite"),r=n.objectStore(ZW);var i=this.createCompositeKey(o);try{const s=r.put({compositeKey:i,value:a});s.onerror=e=>{t(XW(e,"storage-set"))},s.onsuccess=()=>{e()}}catch(e){t(qW.create("storage-set",{originalErrorMessage:e&&e.message}))}})}async delete(o){const a=await this.openDbPromise;return new Promise((e,t)=>{const n=a.transaction([ZW],"readwrite"),r=n.objectStore(ZW);var i=this.createCompositeKey(o);try{const s=r.delete(i);s.onerror=e=>{t(XW(e,"storage-delete"))},s.onsuccess=()=>{e()}}catch(e){t(qW.create("storage-delete",{originalErrorMessage:e&&e.message}))}})}createCompositeKey(e){return[this.appId,this.appName,this.namespace,e].join()}}class t${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 n$(){if(!dd())return!1;try{return await pd()}catch(e){return!1}}dp(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 qW.create("registration-window");if(!dd())throw qW.create("indexed-db-unavailable");var{projectId:i,apiKey:s,appId:o}=n.options;if(!i)throw qW.create("registration-project-id");if(!s)throw qW.create("registration-api-key");if(!o)throw qW.create("registration-app-id");t=t||"firebase";const a=new e$(o,n.name,t),c=new t$(a),l=new ep(FW);l.logLevel=$h.ERROR;o=new QW(r,mp,t,i,s,o),o=new YW(o,a),o=new GW(o,a,c,l),o=new JW(n,o,c,a,l);return $W(o),o},"PUBLIC").setMultipleInstances(!0)),wp(FW,UW),wp(FW,UW,"esm2017");class r${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 WW(this._delegate)}ensureInitialized(){return $W(this._delegate)}fetch(){return KW(this._delegate)}fetchAndActivate(){return async function(e){return await KW(e=$d(e)),WW(e)}(this._delegate)}getAll(){return zW(this._delegate)}getBoolean(e){return HW($d(this._delegate),e).asBoolean()}getNumber(e){return HW($d(this._delegate),e).asNumber()}getString(e){return HW($d(this._delegate),e).asString()}getValue(e){return HW(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 i$(e,{instanceIdentifier:t}){var n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("remote-config").getImmediate({identifier:t});return new r$(n,r)}return(qB=Ap).INTERNAL.registerComponent(new Kd("remoteConfig-compat",i$,"PUBLIC").setMultipleInstances(!0).setServiceProps({isSupported:n$})),qB.registerVersion("@firebase/remote-config-compat","0.1.5-canary.88d43ec00"),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"),Ap.registerVersion("firebase","9.6.2-canary.88d43ec00","compat-cdn"),Ap});
10
10
  //# sourceMappingURL=firebase-compat.js.map