PageSourceSearch

https://www.aapta.in/_next/static/chunks/0-b7tyzjorpk0.js?dpl=dpl_A5vCFKbMsxhCHxB3brPCHhHUKhdn

js aapta.in collected 2026-10-07 19:09:55 UTC 426,263 bytes, 12 lines download raw bytes

1;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="0f566cc3-7262-c163-3751-6375df65d43a")}catch(e){}}();
2(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,467034,(e,t,r)=>{var n={675:function(e,t){"use strict";t.byteLength=function(e){var t=l(e),r=t[0],n=t[1];return(r+n)*3/4-n},t.toByteArray=function(e){var t,r,s=l(e),a=s[0],o=s[1],u=new i((a+o)*3/4-o),h=0,c=o>0?a-4:a;for(r=0;r<c;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],u[h++]=t>>16&255,u[h++]=t>>8&255,u[h++]=255&t;return 2===o&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[h++]=255&t),1===o&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[h++]=t>>8&255,u[h++]=255&t),u},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,s=[],a=0,o=n-i;a<o;a+=16383)s.push(function(e,t,n){for(var i,s=[],a=t;a<n;a+=3)i=(e[a]<<16&0xff0000)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[i>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}(e,a,a+16383>o?o:a+16383));return 1===i?s.push(r[(t=e[n-1])>>2]+r[t<<4&63]+"=="):2===i&&s.push(r[(t=(e[n-2]<<8)+e[n-1])>>10]+r[t>>4&63]+r[t<<2&63]+"="),s.join("")};for(var r=[],n=[],i="u">typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,o=s.length;a<o;++a)r[a]=s[a],n[s.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");-1===r&&(r=t);var n=r===t?0:4-r%4;return[r,n]}n[45]=62,n[95]=63},72:function(e,t,r){"use strict";var n=r(675),i=r(783),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function a(e){if(e>0x7fffffff)throw RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,o.prototype),t}function o(e,t,r){if("number"==typeof e){if("string"==typeof t)throw TypeError('The "string" argument must be of type string. Received type number');return h(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e){var n=e,i=t;if(("string"!=typeof i||""===i)&&(i="utf8"),!o.isEncoding(i))throw TypeError("Unknown encoding: "+i);var s=0|f(n,i),l=a(s),u=l.write(n,i);return u!==s&&(l=l.slice(0,u)),l}if(ArrayBuffer.isView(e))return c(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(x(e,ArrayBuffer)||e&&x(e.buffer,ArrayBuffer)||"u">typeof SharedArrayBuffer&&(x(e,SharedArrayBuffer)||e&&x(e.buffer,SharedArrayBuffer)))return function(e,t,r){var n;if(t<0||e.byteLength<t)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),o.prototype),n}(e,t,r);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');var h=e.valueOf&&e.valueOf();if(null!=h&&h!==e)return o.from(h,t,r);var p=function(e){if(o.isBuffer(e)){var t=0|d(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||function(e){return e!=e}(e.length)?a(0):c(e):"Buffer"===e.type&&Array.isArray(e.data)?c(e.data):void 0}(e);if(p)return p;if("u">typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return o.from(e[Symbol.toPrimitive]("string"),t,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return u(e),a(e<0?0:0|d(e))}function c(e){for(var t=e.length<0?0:0|d(e.length),r=a(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}t.Buffer=o,t.SlowBuffer=function(e){return+e!=e&&(e=0),o.alloc(+e)}
vendor: 16,232 bytes, line 2
2,t.INSPECT_MAX_BYTES=50,t.kMaxLength=0x7fffffff,o.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),!o.TYPED_ARRAY_SUPPORT&&"u">typeof console&&"function"==typeof console.error&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(e,t,r){return(u(e),e<=0)?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)},o.allocUnsafe=function(e){return h(e)},o.allocUnsafeSlow=function(e){return h(e)};function d(e){if(e>=0x7fffffff)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function f(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||x(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return S(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return k(e).length;default:if(i)return n?-1:S(e).length;t=(""+t).toLowerCase(),i=!0}}function p(e,t,r){var i,s,a,o=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=t;s<r;++s)i+=N[e[s]];return i}(this,t,r);case"utf8":case"utf-8":return w(this,t,r);case"ascii":return function(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}(this,t,r);case"latin1":case"binary":return function(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}(this,t,r);case"base64":return i=this,s=t,a=r,0===s&&a===i.length?n.fromByteArray(i):n.fromByteArray(i.slice(s,a));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,r){for(var n=e.slice(t,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}(this,t,r);default:if(o)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function g(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function m(e,t,r,n,i){var s;if(0===e.length)return -1;if("string"==typeof r?(n=r,r=0):r>0x7fffffff?r=0x7fffffff:r<-0x80000000&&(r=-0x80000000),(s=r*=1)!=s&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length)if(i)return -1;else r=e.length-1;else if(r<0)if(!i)return -1;else r=0;if("string"==typeof t&&(t=o.from(t,n)),o.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t){if(t&=255,"function"==typeof Uint8Array.prototype.indexOf)if(i)return Uint8Array.prototype.indexOf.call(e,t,r);else return Uint8Array.prototype.lastIndexOf.call(e,t,r);return y(e,[t],r,n,i)}throw TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var s,a=1,o=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return -1;a=2,o/=2,l/=2,r/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var h=-1;for(s=r;s<o;s++)if(u(e,s)===u(t,-1===h?0:s-h)){if(-1===h&&(h=s),s-h+1===l)return h*a}else -1!==h&&(s-=s-h),h=-1}else for(r+l>o&&(r=o-l),s=r;s>=0;s--){for(var c=!0,d=0;d<l;d++)if(u(e,s+d)!==u(t,d)){c=!1;break}if(c)return s}return -1}o.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==o.prototype},o.compare=function(e,t){if(x(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),x(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,i=0,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:+(n<r)},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);if(void 0===t)for(r=0,t=0;r<e.length;++r)t+=e[r].length;var r,n=o.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var s=e[r];if(x(s,Uint8Array)&&(s=o.from(s)),!o.isBuffer(s))throw TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},o.byteLength=f,o.prototype._isBuffer=!0,o.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},o.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},o.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},o.prototype.toString=function(){var e=this.length;return 0===e?"":0==arguments.length?w(this,0,e):p.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(e){if(!o.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},o.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},s&&(o.prototype[s]=o.prototype.inspect),o.prototype.compare=function(e,t,r,n,i){if(x(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var s=i-n,a=r-t,l=Math.min(s,a),u=this.slice(n,i),h=e.slice(t,r),c=0;c<l;++c)if(u[c]!==h[c]){s=u[c],a=h[c];break}return s<a?-1:+(a<s)},o.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},o.prototype.indexOf=function(e,t,r){return m(this,e,t,r,!0)},o.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,!1)};function w(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var s,a,o,l,u=e[i],h=null,c=u>239?4:u>223?3:u>191?2:1;if(i+c<=r)switch(c){case 1:u<128&&(h=u);break;case 2:(192&(s=e[i+1]))==128&&(l=(31&u)<<6|63&s)>127&&(h=l);break;case 3:s=e[i+1],a=e[i+2],(192&s)==128&&(192&a)==128&&(l=(15&u)<<12|(63&s)<<6|63&a)>2047&&(l<55296||l>57343)&&(h=l);break;case 4:s=e[i+1],a=e[i+2],o=e[i+3],(192&s)==128&&(192&a)==128&&(192&o)==128&&(l=(15&u)<<18|(63&s)<<12|(63&a)<<6|63&o)>65535&&l<1114112&&(h=l)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=c}var d=n,f=d.length;if(f<=4096)return String.fromCharCode.apply(String,d);for(var p="",g=0;g<f;)p+=String.fromCharCode.apply(String,d.slice(g,g+=4096));return p}function v(e,t,r){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>r)throw RangeError("Trying to access beyond buffer length")}function I(e,t,r,n,i,s){if(!o.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw RangeError('"value" argument is out of bounds');if(r+n>e.length)throw RangeError("Index out of range")}function b(e,t,r,n,i,s){if(r+n>e.length||r<0)throw RangeError("Index out of range")}function E(e,t,r,n,s){return t*=1,r>>>=0,s||b(e,t,r,4,34028234663852886e22,-34028234663852886e22),i.write(e,t,r,n,23,4),r+4}function T(e,t,r,n,s){return t*=1,r>>>=0,s||b(e,t,r,8,17976931348623157e292,-17976931348623157e292),i.write(e,t,r,n,52,8),r+8}o.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i,s,a,o,l,u,h,c,d=this.length-t;if((void 0===r||r>d)&&(r=d),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var f=!1;;)switch(n){case"hex":return function(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=t.length;n>s/2&&(n=s/2);for(var a=0;a<n;++a){var o,l=parseInt(t.substr(2*a,2),16);if((o=l)!=o)break;e[r+a]=l}return a}(this,e,t,r);case"utf8":case"utf-8":return i=t,s=r,A(S(e,this.length-i),this,i,s);case"ascii":return a=t,o=r,A(C(e),this,a,o);case"latin1":case"binary":return function(e,t,r,n){return A(C(t),e,r,n)}(this,e,t,r);case"base64":return l=t,u=r,A(k(e),this,l,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h=t,c=r,A(function(e,t){for(var r,n,i=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i.push(r%256),i.push(n);return i}(e,this.length-h),this,h,c);default:if(f)throw TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),f=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},o.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return Object.setPrototypeOf(n,o.prototype),n},o.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n},o.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},o.prototype.readUInt8=function(e,t){return e>>>=0,t||v(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return e>>>=0,t||v(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return e>>>=0,t||v(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return e>>>=0,t||v(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+0x1000000*this[e+3]},o.prototype.readUInt32BE=function(e,t){return e>>>=0,t||v(e,4,this.length),0x1000000*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},o.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var n=t,i=1,s=this[e+--n];n>0&&(i*=256);)s+=this[e+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},o.prototype.readInt8=function(e,t){return(e>>>=0,t||v(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},o.prototype.readInt16LE=function(e,t){e>>>=0,t||v(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?0xffff0000|r:r},o.prototype.readInt16BE=function(e,t){e>>>=0,t||v(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?0xffff0000|r:r},o.prototype.readInt32LE=function(e,t){return e>>>=0,t||v(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e>>>=0,t||v(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return e>>>=0,t||v(e,4,this.length),i.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e>>>=0,t||v(e,4,this.length),i.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e>>>=0,t||v(e,8,this.length),i.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e>>>=0,t||v(e,8,this.length),i.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,r,n){if(e*=1,t>>>=0,r>>>=0,!n){var i=Math.pow(2,8*r)-1;I(this,e,t,r,i,0)}var s=1,a=0;for(this[t]=255&e;++a<r&&(s*=256);)this[t+a]=e/s&255;return t+r},o.prototype.writeUIntBE=function(e,t,r,n){if(e*=1,t>>>=0,r>>>=0,!n){var i=Math.pow(2,8*r)-1;I(this,e,t,r,i,0)}var s=r-1,a=1;for(this[t+s]=255&e;--s>=0&&(a*=256);)this[t+s]=e/a&255;return t+r},o.prototype.writeUInt8=function(e,t,r){return e*=1,t>>>=0,r||I(this,e,t,1,255,0),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,r){return e*=1,t>>>=0,r||I(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeUInt16BE=function(e,t,r){return e*=1,t>>>=0,r||I(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeUInt32LE=function(e,t,r){return e*=1,t>>>=0,r||I(this,e,t,4,0xffffffff,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},o.prototype.writeUInt32BE=function(e,t,r){return e*=1,t>>>=0,r||I(this,e,t,4,0xffffffff,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeIntLE=function(e,t,r,n){if(e*=1,t>>>=0,!n){var i=Math.pow(2,8*r-1);I(this,e,t,r,i-1,-i)}var s=0,a=1,o=0;for(this[t]=255&e;++s<r&&(a*=256);)e<0&&0===o&&0!==this[t+s-1]&&(o=1),this[t+s]=(e/a|0)-o&255;return t+r},o.prototype.writeIntBE=function(e,t,r,n){if(e*=1,t>>>=0,!n){var i=Math.pow(2,8*r-1);I(this,e,t,r,i-1,-i)}var s=r-1,a=1,o=0;for(this[t+s]=255&e;--s>=0&&(a*=256);)e<0&&0===o&&0!==this[t+s+1]&&(o=1),this[t+s]=(e/a|0)-o&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e*=1,t>>>=0,r||I(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e*=1,t>>>=0,r||I(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,r){return e*=1,t>>>=0,r||I(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeInt32LE=function(e,t,r){return e*=1,t>>>=0,r||I(this,e,t,4,0x7fffffff,-0x80000000),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},o.prototype.writeInt32BE=function(e,t,r){return e*=1,t>>>=0,r||I(this,e,t,4,0x7fffffff,-0x80000000),e<0&&(e=0xffffffff+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeFloatLE=function(e,t,r){return E(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return E(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return T(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return T(this,e,t,!1,r)},o.prototype.copy=function(e,t,r,n){if(!o.isBuffer(e))throw TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(n<0)throw RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i=n-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,n);else if(this===e&&r<t&&t<n)for(var s=i-1;s>=0;--s)e[s+t]=this[s+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return i},o.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw TypeError("encoding must be a string");if("string"==typeof n&&!o.isEncoding(n))throw TypeError("Unknown encoding: "+n);if(1===e.length){var i,s=e.charCodeAt(0);("utf8"===n&&s<128||"latin1"===n)&&(e=s)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw RangeError("Out of range index");if(r<=t)return this;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var a=o.isBuffer(e)?e:o.from(e,n),l=a.length;
2if(0===l)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=a[i%l]}return this};var _=/[^+/0-9A-Za-z-_]/g;function S(e,t){t=t||1/0;for(var r,n=e.length,i=null,s=[],a=0;a<n;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!i){if(r>56319||a+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return s}function C(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function k(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(_,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function A(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length)&&!(i>=e.length);++i)t[i+r]=e[i];return i}function x(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}var N=function(){for(var e="0123456789abcdef",t=Array(256),r=0;r<16;++r)for(var n=16*r,i=0;i<16;++i)t[n+i]=e[r]+e[i];return t}()},783:function(e,t){t.read=function(e,t,r,n,i){var s,a,o=8*i-n-1,l=(1<<o)-1,u=l>>1,h=-7,c=r?i-1:0,d=r?-1:1,f=e[t+c];for(c+=d,s=f&(1<<-h)-1,f>>=-h,h+=o;h>0;s=256*s+e[t+c],c+=d,h-=8);for(a=s&(1<<-h)-1,s>>=-h,h+=n;h>0;a=256*a+e[t+c],c+=d,h-=8);if(0===s)s=1-u;else{if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),s-=u}return(f?-1:1)*a*Math.pow(2,s-n)},t.write=function(e,t,r,n,i,s){var a,o,l,u=8*s-i-1,h=(1<<u)-1,c=h>>1,d=5960464477539062e-23*(23===i),f=n?0:s-1,p=n?1:-1,g=+(t<0||0===t&&1/t<0);for(isNaN(t=Math.abs(t))||t===1/0?(o=+!!isNaN(t),a=h):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+c>=1?t+=d/l:t+=d*Math.pow(2,1-c),t*l>=2&&(a++,l/=2),a+c>=h?(o=0,a=h):a+c>=1?(o=(t*l-1)*Math.pow(2,i),a+=c):(o=t*Math.pow(2,c-1)*Math.pow(2,i),a=0));i>=8;e[r+f]=255&o,f+=p,o/=256,i-=8);for(a=a<<i|o,u+=i;u>0;e[r+f]=255&a,f+=p,a/=256,u-=8);e[r+f-p]|=128*g}}},i={};function s(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}},a=!0;try{n[e](r,r.exports,s),a=!1}finally{a&&delete i[e]}return r.exports}s.ab="/ROOT/node_modules/next/dist/compiled/buffer/",t.exports=s(72)},185409,969185,263802,436180,867426,e=>{"use strict";var t,r,n,i,s,a,o,l,u,h,c,d,f,p,g,m=e.i(843476),y=e.i(92953),w=e.i(897427),v=e.i(683877),I=e.i(308070);function b(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}let E=new w.ErrorFactory("auth","Firebase",b()),T=new v.Logger("@firebase/auth");function _(e,...t){T.logLevel<=v.LogLevel.ERROR&&T.error(`Auth (${y.SDK_VERSION}): ${e}`,...t)}function S(e,...t){throw x(e,...t)}function C(e,...t){return x(e,...t)}function k(e,t,r){let n={...b(),[t]:r};return new w.ErrorFactory("auth","Firebase",n).create(t,{appName:e.name})}function A(e){return k(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function x(e,...t){if("string"!=typeof e){let r=t[0],n=[...t.slice(1)];return n[0]&&(n[0].appName=e.name),e._errorFactory.create(r,...n)}return E.create(e,...t)}function N(e,t,...r){if(!e)throw x(t,...r)}function R(e){let t="INTERNAL ASSERTION FAILED: "+e;throw _(t),Error(t)}function D(){return"u">typeof self&&self.location?.href||""}function P(){return"http:"===O()||"https:"===O()}function O(){return"u">typeof self&&self.location?.protocol||null}class L{constructor(e,t){this.shortDelay=e,this.longDelay=t,function(e,t){e||R(t)}(t>e,"Short delay should be less than long delay!"),this.isMobile=(0,w.isMobileCordova)()||(0,w.isReactNative)()}get(){return!("u">typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&(P()||(0,w.isBrowserExtension)()||"connection"in navigator))||navigator.onLine?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}function M(e,t){var r,n;r=e.emulator,n="Emulator should always be set here",r||R(n);let{url:i}=e.emulator;return t?`${i}${t.startsWith("/")?t.slice(1):t}`:i}class V{static initialize(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),r&&(this.responseImpl=r)}static fetch(){return this.fetchImpl?this.fetchImpl:"u">typeof self&&"fetch"in self?self.fetch:"u">typeof globalThis&&globalThis.fetch?globalThis.fetch:"u">typeof fetch?fetch:void R("Could not find fetch implementation, make sure you call FetchProvi
2der.initialize() with an appropriate polyfill")}static headers(){return this.headersImpl?this.headersImpl:"u">typeof self&&"Headers"in self?self.Headers:"u">typeof globalThis&&globalThis.Headers?globalThis.Headers:"u">typeof Headers?Headers:void R("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){return this.responseImpl?this.responseImpl:"u">typeof self&&"Response"in self?self.Response:"u">typeof globalThis&&globalThis.Response?globalThis.Response:"u">typeof Response?Response:void R("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}let F={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"},U=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],B=new L(3e4,6e4);function j(e,t){return e.tenantId&&!t.tenantId?{...t,tenantId:e.tenantId}:t}async function q(e,t,r,n,i={}){return z(e,i,async()=>{let i={},s={};n&&("GET"===t?s=n:i={body:JSON.stringify(n)});let a=(0,w.querystring)({key:e.config.apiKey,...s}).slice(1),o=await e._getAdditionalHeaders();o["Content-Type"]="application/json",e.languageCode&&(o["X-Firebase-Locale"]=e.languageCode);let l={method:t,headers:o,...i};return(0,w.isCloudflareWorker)()||(l.referrerPolicy="no-referrer"),e.emulatorConfig&&(0,w.isCloudWorkstation)(e.emulatorConfig.host)&&(l.credentials="include"),V.fetch()(await $(e,e.config.apiHost,r,a),l)})}async function z(e,t,r){e._canInitEmulator=!1;let n={...F,...t};try{let t=new G(e),i=await Promise.race([r(),t.promise]);t.clearNetworkTimeout();let s=await i.json();if("needConfirmation"in s)throw H(e,"account-exists-with-different-credential",s);if(i.ok&&!("errorMessage"in s))return s;{let[t,r]=(i.ok?s.errorMessage:s.error.message).split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===t)throw H(e,"credential-already-in-use",s);if("EMAIL_EXISTS"===t)throw H(e,"email-already-in-use",s);if("USER_DISABLED"===t)throw H(e,"user-disabled",s);let a=n[t]||t.toLowerCase().replace(/[_\s]+/g,"-");if(r)throw k(e,a,r);S(e,a)}}catch(t){if(t instanceof w.FirebaseError)throw t;S(e,"network-request-failed",{message:String(t)})}}async function K(e,t,r,n,i={}){let s=await q(e,t,r,n,i);return"mfaPendingCredential"in s&&S(e,"multi-factor-auth-required",{_serverResponse:s}),s}async function $(e,t,r,n){let i=`${t}${r}?${n}`,s=e.config.emulator?M(e.config,i):`${e.config.apiScheme}://${i}`;return U.includes(r)&&(await e._persistenceManagerAvailable,"COOKIE"===e._getPersistenceType())?e._getPersistence()._getFinalTarget(s).toString():s}class G{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>
2{this.timer=setTimeout(()=>t(C(this.auth,"network-request-failed")),B.get())})}}function H(e,t,r){let n={appName:e.name};r.email&&(n.email=r.email),r.phoneNumber&&(n.phoneNumber=r.phoneNumber);let i=C(e,t,n);return i.customData._tokenResponse=r,i}function W(e){return void 0!==e&&void 0!==e.getResponse}function Q(e){return void 0!==e&&void 0!==e.enterprise}class J{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],void 0===e.recaptchaKey)throw Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||0===this.recaptchaEnforcementState.length)return null;for(let t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)switch(t.enforcementState){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}return null}isProviderEnabled(e){return"ENFORCE"===this.getProviderEnforcementState(e)||"AUDIT"===this.getProviderEnforcementState(e)}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function Y(e){return(await q(e,"GET","/v1/recaptchaParams")).recaptchaSiteKey||""}async function X(e,t){return q(e,"GET","/v2/recaptchaConfig",j(e,t))}async function Z(e,t){return q(e,"POST","/v1/accounts:delete",t)}async function ee(e,t){return q(e,"POST","/v1/accounts:lookup",t)}function et(e){if(e)try{let t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}async function er(e,t=!1){let r=(0,w.getModularInstance)(e),n=await r.getIdToken(t),i=ei(n);N(i&&i.exp&&i.auth_time&&i.iat,r.auth,"internal-error");let s="object"==typeof i.firebase?i.firebase:void 0,a=s?.sign_in_provider;return{claims:i,token:n,authTime:et(en(i.auth_time)),issuedAtTime:et(en(i.iat)),expirationTime:et(en(i.exp)),signInProvider:a||null,signInSecondFactor:s?.sign_in_second_factor||null}}function en(e){return 1e3*Number(e)}function ei(e){let[t,r,n]=e.split(".");if(void 0===t||void 0===r||void 0===n)return _("JWT malformed, contained fewer than 3 sections"),null;try{let e=(0,w.base64Decode)(r);if(!e)return _("Failed to decode base64 JWT payload"),null;return JSON.parse(e)}catch(e){return _("Caught error parsing JWT payload as JSON",e?.toString()),null}}function es(e){let t=ei(e);return N(t,"internal-error"),N(void 0!==t.exp,"internal-error"),N(void 0!==t.iat,"internal-error"),Number(t.exp)-Number(t.iat)}async function ea(e,t,r=!1){if(r)return t;try{return await t}catch(t){throw t instanceof w.FirebaseError&&function({code:e}){return"auth/user-disabled"===e||"auth/user-token-expired"===e}(t)&&e.auth.currentUser===e&&await e.auth.signOut(),t}}class eo{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)return this.errorBackoff=3e4,Math.max(0,(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5);{let e=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),e}}schedule(e=!1){if(!this.isRunning)return;let t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){e?.code==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}class el{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=et(this.lastLoginAt),this.creationTime=et(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function eu(e){var t,r;let n=e.auth,i=await e.getIdToken(),s=await ea(e,ee(n,{idToken:i}));N(s?.users.length,n,"internal-error");let a=s.users[0];e._notifyReloadListener(a);let o=a.providerUserInfo?.length?ec(a.providerUserInfo):[],l=(t=e.providerData,r=o,[...t.filter(e=>!r.some(t=>t.providerId===e.providerId)),...r]),u=e.isAnonymous,h=!(e.email&&a.passwordHash)&&!l?.length;Object.assign(e,{uid:a.localId,displayName:a.displayName||null,photoURL:a.photoUrl||null,email:a.email||null,emailVerified:a.emailVerified||!1,phoneNumber:a.phoneNumber||null,tenantId:a.tenantId||null,providerData:l,metadata:new el(a.createdAt,a.lastLoginAt),isAnonymous:!!u&&h})}async function eh(e){let t=(0,w.getModularInstance)(e);await eu(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}function ec(e){return e.map(({providerId:e,...t})=>
2({providerId:e,uid:t.rawId||"",displayName:t.displayName||null,email:t.email||null,phoneNumber:t.phoneNumber||null,photoURL:t.photoUrl||null}))}async function ed(e,t){let r=await z(e,{},async()=>{let r=(0,w.querystring)({grant_type:"refresh_token",refresh_token:t}).slice(1),{tokenApiHost:n,apiKey:i}=e.config,s=await $(e,n,"/v1/token",`key=${i}`),a=await e._getAdditionalHeaders();a["Content-Type"]="application/x-www-form-urlencoded";let o={method:"POST",headers:a,body:r};return e.emulatorConfig&&(0,w.isCloudWorkstation)(e.emulatorConfig.host)&&(o.credentials="include"),V.fetch()(s,o)});return{accessToken:r.access_token,expiresIn:r.expires_in,refreshToken:r.refresh_token}}async function ef(e,t){return q(e,"POST","/v2/accounts:revokeToken",j(e,t))}class ep{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){N(e.idToken,"internal-error"),N(void 0!==e.idToken,"internal-error"),N(void 0!==e.refreshToken,"internal-error");let t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):es(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){N(0!==e.length,"internal-error");let t=es(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return t||!this.accessToken||this.isExpired?(N(this.refreshToken,e,"user-token-expired"),this.refreshToken)?(await this.refresh(e,this.refreshToken),this.accessToken):null:this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){let{accessToken:r,refreshToken:n,expiresIn:i}=await ed(e,t);this.updateTokensAndExpiration(r,n,Number(i))}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*r}static fromJSON(e,t){let{refreshToken:r,accessToken:n,expirationTime:i}=t,s=new ep;return r&&(N("string"==typeof r,"internal-error",{appName:e}),s.refreshToken=r),n&&(N("string"==typeof n,"internal-error",{appName:e}),s.accessToken=n),i&&(N("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 ep,this.toJSON())}_performRefresh(){return R("not implemented")}}function eg(e,t){N("string"==typeof e||void 0===e,"internal-error",{appName:t})}class em{constructor({uid:e,auth:t,stsTokenManager:r,...n}){this.providerId="firebase",this.proactiveRefresh=new eo(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=n.displayName||null,this.email=n.email||null,this.emailVerified=n.emailVerified||!1,this.phoneNumber=n.phoneNumber||null,this.photoURL=n.photoURL||null,this.isAnonymous=n.isAnonymous||!1,this.tenantId=n.tenantId||null,this.providerData=n.providerData?[...n.providerData]:[],this.metadata=new el(n.createdAt||void 0,n.lastLoginAt||void 0)}async getIdToken(e){let t=await ea(this,this.stsTokenManager.getToken(this.auth,e));return N(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return er(this,e)}reload(){return eh(this)}_assign(e){this!==e&&(N(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=>({...e})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){let t=new em({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return t.metadata._copy(this.metadata),t}_onReload(e){N(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&await eu(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if((0,y._isFirebaseServerApp)(this.auth.app))return Promise.reject(A(this.auth));let e=await this.getIdToken();return await ea(this,Z(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isA
2nonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>({...e})),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId,...this.metadata.toJSON(),apiKey:this.auth.config.apiKey,appName:this.auth.name}}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){let r=t.displayName??void 0,n=t.email??void 0,i=t.phoneNumber??void 0,s=t.photoURL??void 0,a=t.tenantId??void 0,o=t._redirectEventId??void 0,l=t.createdAt??void 0,u=t.lastLoginAt??void 0,{uid:h,emailVerified:c,isAnonymous:d,providerData:f,stsTokenManager:p}=t;N(h&&p,e,"internal-error");let g=ep.fromJSON(this.name,p);N("string"==typeof h,e,"internal-error"),eg(r,e.name),eg(n,e.name),N("boolean"==typeof c,e,"internal-error"),N("boolean"==typeof d,e,"internal-error"),eg(i,e.name),eg(s,e.name),eg(a,e.name),eg(o,e.name),eg(l,e.name),eg(u,e.name);let m=new em({uid:h,auth:e,email:n,emailVerified:c,displayName:r,isAnonymous:d,photoURL:s,phoneNumber:i,tenantId:a,stsTokenManager:g,createdAt:l,lastLoginAt:u});return f&&Array.isArray(f)&&(m.providerData=f.map(e=>({...e}))),o&&(m._redirectEventId=o),m}static async _fromIdTokenResponse(e,t,r=!1){let n=new ep;n.updateFromServerResponse(t);let i=new em({uid:t.localId,auth:e,stsTokenManager:n,isAnonymous:r});return await eu(i),i}static async _fromGetAccountInfoResponse(e,t,r){let n=t.users[0];N(void 0!==n.localId,"internal-error");let i=void 0!==n.providerUserInfo?ec(n.providerUserInfo):[],s=!(n.email&&n.passwordHash)&&!i?.length,a=new ep;a.updateFromIdToken(r);let o=new em({uid:n.localId,auth:e,stsTokenManager:a,isAnonymous:s});return Object.assign(o,{uid:n.localId,displayName:n.displayName||null,photoURL:n.photoUrl||null,email:n.email||null,emailVerified:n.emailVerified||!1,phoneNumber:n.phoneNumber||null,tenantId:n.tenantId||null,providerData:i,metadata:new el(n.createdAt,n.lastLoginAt),isAnonymous:!(n.email&&n.passwordHash)&&!i?.length}),o}}let ey=new Map;function ew(e){var t,r;t="Expected a class definition",e instanceof Function||R(t);let n=ey.get(e);return n?(r="Instance stored in cache mismatched with class",n instanceof e||R(r)):(n=new e,ey.set(e,n)),n}class ev{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){let t=this.storage[e];return void 0===t?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}function eI(e,t,r){return`firebase:${e}:${t}:${r}`}ev.type="NONE";class eb{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;const{config:n,name:i}=this.auth;this.fullUserKey=eI(this.userKey,n.apiKey,i),this.fullPersistenceKey=eI("persistence",n.apiKey,i),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){let e=await this.persistence._get(this.fullUserKey);if(!e)return null;if("string"==typeof e){let t=await ee(this.auth,{idToken:e}).catch(()=>void 0);return t?em._fromGetAccountInfoResponse(this.auth,t,e):null}return em._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;let t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,r="authUser"){if(!t.length)return new eb(ew(ev),e,r);let n=(await Promise.all(t.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e),i=n[0]||ew(ev),s=eI(r,e.config.apiKey,e.name),a=null;for(let r of t)try{let t=await r._get(s);if(t){let n;if("string"==typeof t){let r=await ee(e,{idToken:t}).catch(()=>void 0);if(!r)break;n=await em._fromGetAccountInfoResponse(e,r,t)}else n=em._fromJSON(e,t);r!==i&&(a=n),i=r;break}}catch{}let o=n.filter(e=>e._shouldAllowMigration);return i._shouldAllowMigration&&o.length&&(i=o[0],a&&await i._set(s,a.toJSON()),await Promise.all(t.map(async e=>{if(e!==i)try{await e._remove(s)}catch{}}))),new eb(i,e,r)}}function eE(e){let t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";{if(eC(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(eT(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(eA(t))return"Blackberry";if(ex(t))return"Webos";if(e_(t))return"Safari";if((t.includes("chrome/")||eS(t))&&!t.includes("edge/"))return"Chrome";if(ek(t))return"Android";let r=e.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/);if(r?.length===2)return r[1]}return"Other"}function eT(e=(0,w.getUA)()){return/firefox\//i.test(e)}function e_(e=(0,w.getUA)()){let t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function eS(e=(0,w.getUA)()){return/crios\//i.test(e)}function eC(e=(0,w.getUA)()){return/iemobile/i.test(e)}function ek(e=(0,w.getUA)()){return/android/i.test(e)}function eA(e=(0,w.getUA)()){return/blackberry/i.test(e)}function ex(e=(0,w.getUA)()){return/webos/i.test(e)}function eN(e=(0,w.getUA)()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function eR(e=(0,w.getUA)()){return eN(e)||ek(e)||ex(e)||eA(e)||/windows phone/i.test(e)||eC(e)}function eD(e,t=[]){let r;switch(e){case"Browser":r=eE((0,w.getUA)());break;case"Worker":r=`${eE((0,w.getUA)())}-${e}`;break;default:r=e}let n=t.length?t.join(","):"FirebaseCore-web";return`${r}/JsCore/${y.SDK_VERSION}/${n}`}class eP{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){let r=t=>new Promise((r,n)=>{try{let n=e(t);r(n)}catch(e){n(e)}});r.onAbort=t,this.queue.push(r);let n=this.queue.length-1;return()=>{this.queue[n]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;let t=[];try{for(let r of this.queue)await r(e),r.onAbort&&t.push(r.onAbort)}catch(e){for(let e of(t.reverse(),t))try{e()}catch(e){}throw this.auth._errorFactory.create("login-blocked",{originalMessage:e?.message})}}}async function eO(e,t={}){return q(e,"GET","/v2/passwordPolicy",j(e,t))}class eL{constructor(e){const t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??6,t.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=t.maxPasswordLength),void 0!==t.containsLowercaseCharacter&&(this.customStrengthOptions.containsLowercaseLetter=t.containsLowercaseCharacter),void 0!==t.containsUppercaseCharacter&&(this.customStrengthOptions.containsUppercaseLetter=t.containsUppercaseCharacter),void 0!==t.containsNumericCharacter&&(this.customStrengthOptions.containsNumericCharacter=t.containsNumericCharacter),void 0!==t.containsNonAlphanumericCharacter&&(this.customStrengthOptions.containsNonAlphanumericCharacter=t.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,"ENFORCEMENT_STATE_UNSPECIFIED"===this.enforcementState&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=e.allowedNonAlphanumericCharacters?.join("")??"",this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){let t={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,t),this.validatePasswordCharacterOptions(e,t),t.isValid&&
2(t.isValid=t.meetsMinPasswordLength??!0),t.isValid&&(t.isValid=t.meetsMaxPasswordLength??!0),t.isValid&&(t.isValid=t.containsLowercaseLetter??!0),t.isValid&&(t.isValid=t.containsUppercaseLetter??!0),t.isValid&&(t.isValid=t.containsNumericCharacter??!0),t.isValid&&(t.isValid=t.containsNonAlphanumericCharacter??!0),t}validatePasswordLengthOptions(e,t){let r=this.customStrengthOptions.minPasswordLength,n=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),n&&(t.meetsMaxPasswordLength=e.length<=n)}validatePasswordCharacterOptions(e,t){let r;this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);for(let n=0;n<e.length;n++)r=e.charAt(n),this.updatePasswordCharacterOptionsStatuses(t,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,t,r,n,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=n)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}class eM{constructor(e,t,r,n){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=n,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new eF(this),this.idTokenSubscription=new eF(this),this.beforeStateQueue=new eP(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=E,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=n.sdkClientVersion,this._persistenceManagerAvailable=new Promise(e=>this._resolvePersistenceManagerAvailable=e)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=ew(t)),this._initializationPromise=this.queue(async()=>{if(!this._deleted){if(this.persistenceManager=await eb.create(this,e),this._resolvePersistenceManagerAvailable?.(),!this._deleted){if(this._popupRedirectResolver?._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(e){}await this.initializeCurrentUser(t),this.lastNotifiedUid=this.currentUser?.uid||null,this._deleted||(this._isInitialized=!0)}}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;let e=await this.assertedPersistence.getCurrentUser();if(this.currentUser||e){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{let t=await ee(this,{idToken:e}),r=await em._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(e){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",e),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){if((0,y._isFirebaseServerApp)(this.app)){let e=this.app.settings.authIdToken;return e?new Promise(t=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(e).then(t,t))}):this.directlySetCurrentUser(null)}let t=await this.assertedPersistence.getCurrentUser(),r=t,n=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();let t=this.redirectUser?._redirectEventId,i=r?._redirectEventId,s=await this.tryRedirectSignIn(e);(!t||t===i)&&s?.user&&(r=s.user,n=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(n)try{await this.beforeStateQueue.runMiddleware(r)}catch(e){r=t,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(e))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return(N(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId)?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch(e){await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await eu(e)}catch(e){if(e?.code!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=function(){if("u"<typeof navigator)return null;let e=navigator;return e.languages&&e.languages[0]||e.language||null}()}async _delete(){this._deleted=!0}
2async updateCurrentUser(e){if((0,y._isFirebaseServerApp)(this.app))return Promise.reject(A(this));let t=e?(0,w.getModularInstance)(e):null;return t&&N(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&N(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return(0,y._isFirebaseServerApp)(this.app)?Promise.reject(A(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return(0,y._isFirebaseServerApp)(this.app)?Promise.reject(A(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(ew(e))})}_getRecaptchaConfig(){return null==this.tenantId?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();let t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return null===this.tenantId?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){let e=new eL(await eO(this));null===this.tenantId?this._projectPasswordPolicy=e:this._tenantPasswordPolicies[this.tenantId]=e}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new w.ErrorFactory("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{let r=this.onAuthStateChanged(()=>{r(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){let t={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:await this.currentUser.getIdToken()};null!=this.tenantId&&(t.tenantId=this.tenantId),await ef(this,t)}}toJSON(){return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:this._currentUser?.toJSON()}}async _setRedirectUser(e,t){let r=await this.getOrInitRedirectPersistenceManager(t);return null===e?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){let t=e&&ew(e)||this._popupRedirectResolver;N(t,this,"argument-error"),this.redirectPersistenceManager=await eb.create(this,[ew(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){return(this._isInitialized&&await this.queue(async()=>{}),this._currentUser?._redirectEventId===e)?this._currentUser:this.redirectUser?._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(){if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);let e=this.currentUser?.uid??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,r,n){if(this._deleted)return()=>{};let i="function"==typeof t?t:t.next.bind(t),s=!1,a=this._isInitialized?Promise.resolve():this._initializationPromise;if(N(a,this,"internal-error"),a.then(()=>{s||i(this.currentUser)}),"function"==typeof t){let i=e.addObserver(t,r,n);return()=>{s=!0,i()}}{let r=e.addObserver(t);return()=>{s=!0,r()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return N(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=eD(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){let e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);let t=await this.heartbeatServiceProvider.getImmediate({optional:!0})?.getHeartbeatsHeader();t&&(e["X-Firebase-Client"]=t);let r=await this._getAppCheckToken();return r&&(e["X-Firebase-AppCheck"]=r),e}async _getAppCheckToken(){if((0,y._isFirebaseServerApp)(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;let e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken();return e?.error&&function(e,...t){T.logLevel<=v.LogLevel.WARN&&T.warn(`Auth (${y.SDK_VERSION}): ${e}`,...t)}(`Error while retrieving App Check token: ${e.error}`),e?.token}}function eV(e){return(0,w.getModularInstance)(e)}class eF{constructor(e){this.auth=e,this.observer=null,this.addObserver=(0,w.createSubscribe)(e=>this.observer=e)}get next(){return N(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let eU={async loadJS(){throw Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function eB(e){return eU.loadJS(e)}function ej(e){return`__${e}${Math.floor(1e6*Math.random())}`}class eq{constructor(e){this.auth=e,this.counter=1e12,this._widgets=new Map}render(e,t){let r=this.counter;return this._widgets.set(r,new e$(e,this.auth.name,t||{})),this.counter++,r}reset(e){let t=e||1e12;this._widgets.get(t)?.delete(),this._widgets.delete(t)}getResponse(e){return this._widgets.get(e||1e12)?.getResponse()||""}async execute(e){return this._widgets.get(e||1e12)?.execute(),""}}class ez{constructor(){this.enterprise=new eK}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class eK{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class e${constructor(e,t,r){this.params=r,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=()=>{this.execute()};const n="string"==typeof e?document.getElementById(e):e;N(n,"argument-error",{appName:t}),this.container=n,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(){let e=[],t="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let r=0;r<50;r++)e.push(t.charAt(Math.floor(Math.random()*t.length)));return e.join("")}();let{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 Error("reCAPTCHA mock was already deleted!")}}let eG="NO_RECAPTCHA";class eH{constructor(e){this.type="recaptcha-enterprise",this.auth=eV(e)}async verify(e="verify",t=!1){async function r(e){if(!t){if(null==e.tenantId&&null!=e._agentRecaptchaConfig)return e._agentRecaptchaConfig.siteKey;if(null!=e.tenantId&&void 0!==e._tenantRecaptchaConfigs[e.tenantId])return e._tenantRecaptchaConfigs[e.tenantId].siteKey}return new Promise(async(t,r)=>
2{X(e,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(n=>{if(void 0===n.recaptchaKey)r(Error("recaptcha Enterprise site key undefined"));else{let r=new J(n);return null==e.tenantId?e._agentRecaptchaConfig=r:e._tenantRecaptchaConfigs[e.tenantId]=r,t(r.siteKey)}}).catch(e=>{r(e)})})}function n(t,r,n){let i=window.grecaptcha;Q(i)?i.enterprise.ready(()=>{i.enterprise.execute(t,{action:e}).then(e=>{r(e)}).catch(()=>{r(eG)})}):n(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new ez().execute("siteKey",{action:"verify"}):new Promise((e,i)=>{r(this.auth).then(r=>{if(!t&&Q(window.grecaptcha))n(r,e,i);else{if("u"<typeof window)return void i(Error("RecaptchaVerifier is only supported in browser"));let t=eU.recaptchaEnterpriseScript;0!==t.length&&(t+=r),eB(t).then(()=>{n(r,e,i)}).catch(e=>{i(e)})}}).catch(e=>{i(e)})})}}async function eW(e,t,r,n=!1,i=!1){let s,a=new eH(e);if(i)s=eG;else try{s=await a.verify(r)}catch(e){s=await a.verify(r,!0)}let o={...t};if("mfaSmsEnrollment"===r||"mfaSmsSignIn"===r){if("phoneEnrollmentInfo"in o){let e=o.phoneEnrollmentInfo.phoneNumber,t=o.phoneEnrollmentInfo.recaptchaToken;Object.assign(o,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:t,captchaResponse:s,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in o){let e=o.phoneSignInInfo.recaptchaToken;Object.assign(o,{phoneSignInInfo:{recaptchaToken:e,captchaResponse:s,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return o}return n?Object.assign(o,{captchaResp:s}):Object.assign(o,{captchaResponse:s}),Object.assign(o,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(o,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),o}async function eQ(e,t,r,n,i){if("EMAIL_PASSWORD_PROVIDER"===i)if(!e._getRecaptchaConfig()?.isProviderEnabled("EMAIL_PASSWORD_PROVIDER"))return n(e,t).catch(async i=>{if("auth/missing-recaptcha-token"!==i.code)return Promise.reject(i);{console.log(`${r} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);let i=await eW(e,t,r,"getOobCode"===r);return n(e,i)}});else{let i=await eW(e,t,r,"getOobCode"===r);return n(e,i)}if("PHONE_PROVIDER"!==i)return Promise.reject(i+" provider is not supported.");if(e._getRecaptchaConfig()?.isProviderEnabled("PHONE_PROVIDER")){let i=await eW(e,t,r);return n(e,i).catch(async i=>{if(e._getRecaptchaConfig()?.getProviderEnforcementState("PHONE_PROVIDER")==="AUDIT"&&("auth/missing-recaptcha-token"===i.code||"auth/invalid-app-credential"===i.code)){console.log(`Failed to verify with reCAPTCHA Enterprise. Automatically triggering the reCAPTCHA v2 flow to complete the ${r} flow.`);let i=await eW(e,t,r,!1,!0);return n(e,i)}return Promise.reject(i)})}{let i=await eW(e,t,r,!1,!0);return n(e,i)}}async function eJ(e){let t=eV(e),r=new J(await X(t,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}));null==t.tenantId?t._agentRecaptchaConfig=r:t._tenantRecaptchaConfigs[t.tenantId]=r,r.isAnyProviderEnabled()&&new eH(t).verify()}function eY(e){let t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function eX(e){if(!e)return null;let t=Number(e);return isNaN(t)?null:t}class eZ{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return R("not implemented")}_getIdTokenResponse(e){return R("not implemented")}_linkToIdToken(e,t){return R("not implemented")}_getReauthenticationResolver(e){return R("not implemented")}}async function e0(e,t){return q(e,"POST","/v1/accounts:signUp",t)}async function e1(e,t){return K(e,"POST","/v1/accounts:signInWithPassword",j(e,t))}async function e2(e,t){return K(e,"POST","/v1/accounts:signInWithEmailLink",j(e,t))}async function e5(e,t){return K(e,"POST","/v1/accounts:signInWithEmailLink",j(e,t))}class e6 extends eZ{constructor(e,t,r,n=null){super("password",r),this._email=e,this._password=t,this._tenantId=n}static _fromEmailAndPassword(e,t){return new e6(e,t,"password")}static _fromEmailAndCode(e,t,r=null){return new e6(e,t,"emailLink",r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){let t="string"==typeof e?JSON.parse(e):e;if(t?.email&&t?.password){if("password"===t.signInMethod)return this._fromEmailAndPassword(t.email,t.password);else if("emailLink"===t.signInMethod)return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":return eQ(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signInWithPassword",e1,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return e2(e,{email:this._email,oobCode:this._password});default:S(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return eQ(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",e0,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return e5(e,{idToken:t,email:this._email,oobCode:this._password});default:S(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function e3(e,t){return K(e,"POST","/v1/accounts:signInWithIdp",j(e,t))}class e8 extends eZ{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){let t=new e8(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&&
2(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):S("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){let{providerId:t,signInMethod:r,...n}="string"==typeof e?JSON.parse(e):e;if(!t||!r)return null;let i=new e8(t,r);return i.idToken=n.idToken||void 0,i.accessToken=n.accessToken||void 0,i.secret=n.secret,i.nonce=n.nonce,i.pendingToken=n.pendingToken||null,i}_getIdTokenResponse(e){return e3(e,this.buildRequest())}_linkToIdToken(e,t){let r=this.buildRequest();return r.idToken=t,e3(e,r)}_getReauthenticationResolver(e){let t=this.buildRequest();return t.autoCreate=!1,e3(e,t)}buildRequest(){let e={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{let t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=(0,w.querystring)(t)}return e}}async function e4(e,t){return q(e,"POST","/v1/accounts:sendVerificationCode",j(e,t))}async function e9(e,t){return K(e,"POST","/v1/accounts:signInWithPhoneNumber",j(e,t))}async function e7(e,t){let r=await K(e,"POST","/v1/accounts:signInWithPhoneNumber",j(e,t));if(r.temporaryProof)throw H(e,"account-exists-with-different-credential",r);return r}let te={USER_NOT_FOUND:"user-not-found"};async function tt(e,t){return K(e,"POST","/v1/accounts:signInWithPhoneNumber",j(e,{...t,operation:"REAUTH"}),te)}class tr extends eZ{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new tr({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new tr({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return e9(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return e7(e,{idToken:t,...this._makeVerificationRequest()})}_getReauthenticationResolver(e){return tt(e,this._makeVerificationRequest())}_makeVerificationRequest(){let{temporaryProof:e,phoneNumber:t,verificationId:r,verificationCode:n}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:r,code:n}}toJSON(){let e={providerId:this.providerId};return this.params.phoneNumber&&(e.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(e.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(e.verificationCode=this.params.verificationCode),this.params.verificationId&&(e.verificationId=this.params.verificationId),e}static fromJSON(e){"string"==typeof e&&(e=JSON.parse(e));let{verificationId:t,verificationCode:r,phoneNumber:n,temporaryProof:i}=e;return r||t||n||i?new tr({verificationId:t,verificationCode:r,phoneNumber:n,temporaryProof:i}):null}}class tn{constructor(e){const t=(0,w.querystringDecode)((0,w.extractQuerystring)(e)),r=t.apiKey??null,n=t.oobCode??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}}(t.mode??null);N(r&&n&&i,"argument-error"),this.apiKey=r,this.operation=i,this.code=n,this.continueUrl=t.continueUrl??null,this.languageCode=t.lang??null,this.tenantId=t.tenantId??null}static parseLink(e){let t,r,n,i=(r=(t=(0,w.querystringDecode)((0,w.extractQuerystring)(e)).link)?(0,w.querystringDecode)((0,w.extractQuerystring)(t)).deep_link_id:null,((n=(0,w.querystringDecode)((0,w.extractQuerystring)(e)).deep_link_id)?(0,w.querystringDecode)((0,w.extractQuerystring)(n)).link:null)||n||r||t||e);try{return new tn(i)}catch{return null}}}class ti{constructor(){this.providerId=ti.PROVIDER_ID}static credential(e,t){return e6._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){let r=tn.parseLink(t);return N(r,"argument-error"),e6._fromEmailAndCode(e,r.code,r.tenantId)}}ti.PROVIDER_ID="password",ti.EMAIL_PASSWORD_SIGN_IN_METHOD="password",ti.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class ts{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 ta extends ts{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class to extends ta{constructor(){super("facebook.com")}static credential(e){return e8._fromParams({providerId:to.PROVIDER_ID,signInMethod:to.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return to.credentialFromTaggedObject(e)}static credentialFromError(e){return to.credentialFromTaggedObject(e.customData||{})}
2static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return to.credential(e.oauthAccessToken)}catch{return null}}}to.FACEBOOK_SIGN_IN_METHOD="facebook.com",to.PROVIDER_ID="facebook.com";class tl extends ta{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return e8._fromParams({providerId:tl.PROVIDER_ID,signInMethod:tl.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return tl.credentialFromTaggedObject(e)}static credentialFromError(e){return tl.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;let{oauthIdToken:t,oauthAccessToken:r}=e;if(!t&&!r)return null;try{return tl.credential(t,r)}catch{return null}}}tl.GOOGLE_SIGN_IN_METHOD="google.com",tl.PROVIDER_ID="google.com";class tu extends ta{constructor(){super("github.com")}static credential(e){return e8._fromParams({providerId:tu.PROVIDER_ID,signInMethod:tu.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return tu.credentialFromTaggedObject(e)}static credentialFromError(e){return tu.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return tu.credential(e.oauthAccessToken)}catch{return null}}}tu.GITHUB_SIGN_IN_METHOD="github.com",tu.PROVIDER_ID="github.com";class th extends ta{constructor(){super("twitter.com")}static credential(e,t){return e8._fromParams({providerId:th.PROVIDER_ID,signInMethod:th.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return th.credentialFromTaggedObject(e)}static credentialFromError(e){return th.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;let{oauthAccessToken:t,oauthTokenSecret:r}=e;if(!t||!r)return null;try{return th.credential(t,r)}catch{return null}}}th.TWITTER_SIGN_IN_METHOD="twitter.com",th.PROVIDER_ID="twitter.com";class tc{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,r,n=!1){return new tc({user:await em._fromIdTokenResponse(e,r,n),providerId:td(r),_tokenResponse:r,operationType:t})}static async _forOperation(e,t,r){return await e._updateTokensIfNecessary(r,!0),new tc({user:e,providerId:td(r),_tokenResponse:r,operationType:t})}}function td(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}class tf extends w.FirebaseError{constructor(e,t,r,n){super(t.code,t.message),this.operationType=r,this.user=n,Object.setPrototypeOf(this,tf.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,n){return new tf(e,t,r,n)}}function tp(e,t,r,n){return("reauthenticate"===t?r._getReauthenticationResolver(e):r._getIdTokenResponse(e)).catch(r=>{if("auth/multi-factor-auth-required"===r.code)throw tf._fromErrorAndOperation(e,r,t,n);throw r})}async function tg(e,t,r=!1){let n=await ea(e,t._linkToIdToken(e.auth,await e.getIdToken()),r);return tc._forOperation(e,"link",n)}async function tm(e,t,r){await eu(t),N(new Set(t.providerData.map(({providerId:e})=>e).filter(e=>!!e)).has(r)===e,t.auth,!1===e?"provider-already-linked":"no-such-provider")}async function ty(e,t,r=!1){let{auth:n}=e;if((0,y._isFirebaseServerApp)(n.app))return Promise.reject(A(n));let i="reauthenticate";try{let s=await ea(e,tp(n,i,t,e),r);N(s.idToken,n,"internal-error");let a=ei(s.idToken);N(a,n,"internal-error");let{sub:o}=a;return N(e.uid===o,n,"user-mismatch"),tc._forOperation(e,i,s)}catch(e){throw e?.code==="auth/user-not-found"&&S(n,"user-mismatch"),e}}async function tw(e,t,r=!1){if((0,y._isFirebaseServerApp)(e.app))return Promise.reject(A(e));let n="signIn",i=await tp(e,n,t),s=await tc._fromIdTokenResponse(e,n,i);return r||await e._updateCurrentUser(s.user),s}async function tv(e,t){return tw(eV(e),t)}async function tI(e,t){let r=(0,w.getModularInstance)(e);return await tm(!1,r,t.providerId),tg(r,t)}class tb{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?tE._fromServerResponse(e,t):"totpInfo"in t?tT._fromServerResponse(e,t):S(e,"internal-error")}}class tE extends tb{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new tE(t)}}class tT extends tb{constructor(e){super("totp",e)}static _fromServerResponse(e,t){return new tT(t)}}function t_(e,t,r,n){return(0,w.getModularInstance)(e).onIdTokenChanged(t,r,n)}function tS(e,t){return q(e,"POST","/v2/accounts/mfaEnrollment:start",j(e,t))}new WeakMap;let tC="__sak";class tk{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{if(!this.storage)return Promise.resolve(!1);return this.storage.setItem(tC,"1"),this.storage.removeItem(tC),Promise.resolve(!0)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){let t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}class tA extends tk{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=eR(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(let t of Object.keys(this.listeners)){let r=this.storage.getItem(t),n=this.localCache[t];r!==n&&e(t,n,r)}}
2onStorageEvent(e,t=!1){if(!e.key)return void this.forAllChangedKeys((e,t,r)=>{this.notifyListeners(e,r)});let r=e.key;t?this.detachListener():this.stopPolling();let n=()=>{let e=this.storage.getItem(r);(t||this.localCache[r]!==e)&&this.notifyListeners(r,e)},i=this.storage.getItem(r);(0,w.isIE)()&&10===document.documentMode&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(n,10):n()}notifyListeners(e,t){this.localCache[e]=t;let r=this.listeners[e];if(r)for(let e of Array.from(r))e(t?JSON.parse(t):t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:r}),!0)})},1e3)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){0===Object.keys(this.listeners).length&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){let t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}tA.type="LOCAL";class tx extends tk{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}tx.type="SESSION";class tN{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){let t=this.receivers.find(t=>t.isListeningto(e));if(t)return t;let r=new tN(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){let{eventId:t,eventType:r,data:n}=e.data,i=this.handlersMap[r];if(!i?.size)return;e.ports[0].postMessage({status:"ack",eventId:t,eventType:r});let s=Array.from(i).map(async t=>t(e.origin,n)),a=await Promise.all(s.map(async e=>{try{let t=await e;return{fulfilled:!0,value:t}}catch(e){return{fulfilled:!1,reason:e}}}));e.ports[0].postMessage({status:"done",eventId:t,eventType:r,response:a})}_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 tR(e="",t=10){let r="";for(let e=0;e<t;e++)r+=Math.floor(10*Math.random());return e+r}tN.receivers=[];class tD{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,r=50){let n,i,s="u">typeof MessageChannel?new MessageChannel:null;if(!s)throw Error("connection_unavailable");return new Promise((a,o)=>{let l=tR("",20);s.port1.start();let u=setTimeout(()=>{o(Error("unsupported_event"))},r);i={messageChannel:s,onMessage(e){if(e.data.eventId===l)switch(e.data.status){case"ack":clearTimeout(u),n=setTimeout(()=>{o(Error("timeout"))},3e3);break;case"done":clearTimeout(n),a(e.data.response);break;default:clearTimeout(u),clearTimeout(n),o(Error("invalid_response"))}}},this.handlers.add(i),s.port1.addEventListener("message",i.onMessage),this.target.postMessage({eventType:e,eventId:l,data:t},[s.port2])}).finally(()=>{i&&this.removeMessageHandler(i)})}}function tP(){return window}function tO(){return void 0!==tP().WorkerGlobalScope&&"function"==typeof tP().importScripts}async function tL(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}let tM="firebaseLocalStorageDb",tV="firebaseLocalStorage",tF="fbase_key";class tU{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>
2{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function tB(e,t){return e.transaction([tV],t?"readwrite":"readonly").objectStore(tV)}function tj(){let e=indexedDB.open(tM,1);return new Promise((t,r)=>{e.addEventListener("error",()=>{r(e.error)}),e.addEventListener("upgradeneeded",()=>{let t=e.result;try{t.createObjectStore(tV,{keyPath:tF})}catch(e){r(e)}}),e.addEventListener("success",async()=>{let r=e.result;r.objectStoreNames.contains(tV)?t(r):(r.close(),await new tU(indexedDB.deleteDatabase(tM)).toPromise(),t(await tj()))})})}async function tq(e,t,r){return new tU(tB(e,!0).put({[tF]:t,value:r})).toPromise()}async function tz(e,t){let r=tB(e,!1).get(t),n=await new tU(r).toPromise();return void 0===n?null:n.value}function tK(e,t){return new tU(tB(e,!0).delete(t)).toPromise()}class t${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 tj()),this.db}async _withRetries(e){let t=0;for(;;)try{let t=await this._openDb();return await e(t)}catch(e){if(t++>3)throw e;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return tO()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=tN._getInstance(tO()?self:null),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){if(this.activeServiceWorker=await tL(),!this.activeServiceWorker)return;this.sender=new tD(this.activeServiceWorker);let e=await this.sender._send("ping",{},800);e&&e[0]?.fulfilled&&e[0]?.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(this.sender&&this.activeServiceWorker&&(navigator?.serviceWorker?.controller||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;let e=await tj();return await tq(e,tC,"1"),await tK(e,tC),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(r=>tq(r,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){let t=await this._withRetries(t=>tz(t,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>tK(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){let e=await this._withRetries(e=>new tU(tB(e,!1).getAll()).toPromise());if(!e||0!==this.pendingWrites)return[];let t=[],r=new Set;if(0!==e.length)for(let{fbase_key:n,value:i}of e)r.add(n),JSON.stringify(this.localCache[n])!==JSON.stringify(i)&&(this.notifyListeners(n,i),t.push(n));for(let e of Object.keys(this.localCache))this.localCache[e]&&!r.has(e)&&(this.notifyListeners(e,null),t.push(e));return t}notifyListeners(e,t){this.localCache[e]=t;let r=this.listeners[e];if(r)for(let e of Array.from(r))e(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&this.stopPolling()}}function tG(e,t){return q(e,"POST","/v2/accounts/mfaSignIn:start",j(e,t))}t$.type="LOCAL";let tH=ej("rcb"),tW=new L(3e4,6e4);class tQ{constructor(){this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!tP().grecaptcha?.render}load(e,t=""){var r;return(N((r=t).length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(r),e,"argument-error"),this.shouldResolveImmediately(t)&&W(tP().grecaptcha))?Promise.resolve(tP().grecaptcha):new Promise((r,n)=>{let i=tP().setTimeout(()=>{n(C(e,"network-request-failed"))},tW.get());tP()[tH]=()=>{tP().clearTimeout(i),delete tP()[tH];let s=tP().grecaptcha;if(!s||!W(s))return void n(C(e,"internal-error"));let a=s.render;s.render=(e,t)=>{let r=a(e,t);return this.counter++,r},this.hostLanguage=t,r(s)},eB(`${eU.recaptchaV2Script}?${(0,w.querystring)({onload:tH,render:"explicit",hl:t})}`).catch(()=>{clearTimeout(i),n(C(e,"internal-error"))})})}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){return!!tP().grecaptcha?.render&&(e===this.hostLanguage||this.counter>0||this.librarySeparatelyLoaded)}}class tJ{async load(e){return new eq(e)}clearedOneInstance(){}}let tY="recaptcha",tX={theme:"light",type:"image"};class tZ{constructor(e,t,r={...tX}){this.parameters=r,this.type=tY,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=eV(e),this.isInvisible="invisible"===this.parameters.size,N("u">typeof document,this.auth,"operation-not-supported-in-this-environment");const n="string"==typeof t?document.getElementById(t):t;N(n,this.auth,"argument-error"),this.container=n,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=this.auth.settings.appVerificationDisabledForTesting?new tJ:new tQ,this.validateStartingState()}async verify(){this.assertNotDestroyed();let e=await this.render(),t=this.getAssertedRecaptcha(),r=t.getResponse(e);return r||new Promise(r=>{let n=e=>{e&&(this.tokenChangeListeners.delete(n),r(e))};this.tokenChangeListeners.add(n),this.isInvisible&&t.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.forEac
2h(e=>{this.container.removeChild(e)})}validateStartingState(){N(!this.parameters.sitekey,this.auth,"argument-error"),N(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),N("u">typeof document,this.auth,"operation-not-supported-in-this-environment")}makeTokenCallback(e){return t=>{if(this.tokenChangeListeners.forEach(e=>e(t)),"function"==typeof e)e(t);else if("string"==typeof e){let r=tP()[e];"function"==typeof r&&r(t)}}}assertNotDestroyed(){N(!this.destroyed,this.auth,"internal-error")}async makeRenderPromise(){if(await this.init(),!this.widgetId){let e=this.container;if(!this.isInvisible){let t=document.createElement("div");e.appendChild(t),e=t}this.widgetId=this.getAssertedRecaptcha().render(e,this.parameters)}return this.widgetId}async init(){let e;N(P()&&!tO(),this.auth,"internal-error"),await (e=null,new Promise(t=>{"complete"===document.readyState?t():(e=()=>t(),window.addEventListener("load",e))}).catch(t=>{throw e&&window.removeEventListener("load",e),t})),this.recaptcha=await this._recaptchaLoader.load(this.auth,this.auth.languageCode||void 0);let t=await Y(this.auth);N(t,this.auth,"internal-error"),this.parameters.sitekey=t}getAssertedRecaptcha(){return N(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}class t0{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){let t=tr._fromVerification(this.verificationId,e);return this.onConfirmation(t)}}async function t1(e,t,r){if((0,y._isFirebaseServerApp)(e.app))return Promise.reject(A(e));let n=eV(e);return new t0(await t5(n,t,(0,w.getModularInstance)(r)),e=>tv(n,e))}async function t2(e,t,r){let n=(0,w.getModularInstance)(e);return await tm(!1,n,"phone"),new t0(await t5(n.auth,t,(0,w.getModularInstance)(r)),e=>tI(n,e))}async function t5(e,t,r){if(!e._getRecaptchaConfig())try{await eJ(e)}catch(e){console.log("Failed to initialize reCAPTCHA Enterprise config. Triggering the reCAPTCHA v2 verification.")}try{let n;if(n="string"==typeof t?{phoneNumber:t}:t,"session"in n){let t=n.session;if("phoneNumber"in n){N("enroll"===t.type,e,"internal-error");let i={idToken:t.credential,phoneEnrollmentInfo:{phoneNumber:n.phoneNumber,clientType:"CLIENT_TYPE_WEB"}},s=async(e,t)=>{if(t.phoneEnrollmentInfo.captchaResponse===eG){N(r?.type===tY,e,"argument-error");let n=await t6(e,t,r);return tS(e,n)}return tS(e,t)},a=eQ(e,i,"mfaSmsEnrollment",s,"PHONE_PROVIDER");return(await a.catch(e=>Promise.reject(e))).phoneSessionInfo.sessionInfo}{N("signin"===t.type,e,"internal-error");let i=n.multiFactorHint?.uid||n.multiFactorUid;N(i,e,"missing-multi-factor-info");let s={mfaPendingCredential:t.credential,mfaEnrollmentId:i,phoneSignInInfo:{clientType:"CLIENT_TYPE_WEB"}},a=async(e,t)=>{if(t.phoneSignInInfo.captchaResponse===eG){N(r?.type===tY,e,"argument-error");let n=await t6(e,t,r);return tG(e,n)}return tG(e,t)},o=eQ(e,s,"mfaSmsSignIn",a,"PHONE_PROVIDER");return(await o.catch(e=>Promise.reject(e))).phoneResponseInfo.sessionInfo}}{let t={phoneNumber:n.phoneNumber,clientType:"CLIENT_TYPE_WEB"},i=async(e,t)=>{if(t.captchaResponse===eG){N(r?.type===tY,e,"argument-error");let n=await t6(e,t,r);return e4(e,n)}return e4(e,t)},s=eQ(e,t,"sendVerificationCode",i,"PHONE_PROVIDER");return(await s.catch(e=>Promise.reject(e))).sessionInfo}}finally{r?._reset()}}async function t6(e,t,r){N(r.type===tY,e,"argument-error");let n=await r.verify();N("string"==typeof n,e,"argument-error");let i={...t};if("phoneEnrollmentInfo"in i){let e=i.phoneEnrollmentInfo.phoneNumber,t=i.phoneEnrollmentInfo.captchaResponse,r=i.phoneEnrollmentInfo.clientType,s=i.phoneEnrollmentInfo.recaptchaVersion;return Object.assign(i,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:n,captchaResponse:t,clientType:r,recaptchaVersion:s}}),i}if(!("phoneSignInInfo"in i))return Object.assign(i,{recaptchaToken:n}),i;{let e=i.phoneSignInInfo.captchaResponse,t=i.phoneSignInInfo.clientType,r=i.phoneSignInInfo.recaptchaVersion;return Object.assign(i,{phoneSignInInfo:{recaptchaToken:n,captchaResponse:e,clientType:t,recaptchaVersion:r}}),i}}class t3{constructor(e){this.providerId=t3.PROVIDER_ID,this.auth=eV(e)}verifyPhoneNumber(e,t){return t5(this.auth,e,(0,w.getModularInstance)(t))}static credential(e,t){return tr._fromVerification(e,t)}static credentialFromResult(e){return t3.credentialFromTaggedObject(e)}static credentialFromError(e){return t3.credentialFromTaggedObject(e.customData||{})}
2static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;let{phoneNumber:t,temporaryProof:r}=e;return t&&r?tr._fromTokenResponse(t,r):null}}function t8(e,t){return t?ew(t):(N(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}t3.PROVIDER_ID="phone",t3.PHONE_SIGN_IN_METHOD="phone";class t4 extends eZ{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return e3(e,this._buildIdpRequest())}_linkToIdToken(e,t){return e3(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return e3(e,this._buildIdpRequest())}_buildIdpRequest(e){let t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function t9(e){return tw(e.auth,new t4(e),e.bypassAuthState)}function t7(e){let{auth:t,user:r}=e;return N(r,t,"internal-error"),ty(r,new t4(e),e.bypassAuthState)}async function re(e){let{auth:t,user:r}=e;return N(r,t,"internal-error"),tg(r,new t4(e),e.bypassAuthState)}class rt{constructor(e,t,r,n,i=!1){this.auth=e,this.resolver=r,this.user=n,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(e){this.reject(e)}})}async onAuthEvent(e){let{urlResponse:t,sessionId:r,postBody:n,tenantId:i,error:s,type:a}=e;if(s)return void this.reject(s);let o={auth:this.auth,requestUri:t,sessionId:r,tenantId:i||void 0,postBody:n||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(a)(o))}catch(e){this.reject(e)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return t9;case"linkViaPopup":case"linkViaRedirect":return re;case"reauthViaPopup":case"reauthViaRedirect":return t7;default:S(this.auth,"internal-error")}}resolve(e){var t,r;t=this.pendingPromise,r="Pending promise was never set",t||R(r),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){var t,r;t=this.pendingPromise,r="Pending promise was never set",t||R(r),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}let rr=new L(2e3,1e4);async function rn(e,t,r){if((0,y._isFirebaseServerApp)(e.app))return Promise.reject(C(e,"operation-not-supported-in-this-environment"));let n=eV(e);if(!(t instanceof ts))throw ts.name!==t.constructor.name&&S(e,"argument-error"),k(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`);let i=t8(n,r);return new ri(n,"signInViaPopup",t,i).executeNotNull()}class ri extends rt{constructor(e,t,r,n,i){super(e,t,n,i),this.provider=r,this.authWindow=null,this.pollId=null,ri.currentPopupAction&&ri.currentPopupAction.cancel(),ri.currentPopupAction=this}async executeNotNull(){let e=await this.execute();return N(e,this.auth,"internal-error"),e}async onExecution(){var e,t;e=1===this.filter.length,t="Popup operations only handle one event",e||R(t);let r=tR();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],r),this.authWindow.associatedEvent=r,this.resolver._originValidation(this.auth).catch(e=>{this.reject(e)}),this.resolver._isIframeWebStorageSupported(this.auth,e=>{e||this.reject(C(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(C(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,ri.currentPopupAction=null}pollUserCancellation(){let e=()=>{if(this.authWindow?.window?.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(C(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,rr.get())};e()}}ri.currentPopupAction=null;let rs=new Map;class ra extends rt{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}async execute(){let e=rs.get(this.auth._key());if(!e){try{let t=await ro(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(t)}catch(t){e=()=>Promise.reject(t)}rs.set(this.auth._key(),e)}return this.bypassAuthState||rs.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);
2if("unknown"===e.type)return void this.resolve(null);if(e.eventId){let t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function ro(e,t){var r;let n=eI("pendingRedirect",(r=t).config.apiKey,r.name),i=ew(e._redirectPersistence);if(!await i._isAvailable())return!1;let s=await i._get(n)==="true";return await i._remove(n),s}function rl(e,t){rs.set(e._key(),t)}async function ru(e,t,r=!1){if((0,y._isFirebaseServerApp)(e.app))return Promise.reject(A(e));let n=eV(e),i=t8(n,t),s=new ra(n,i,r),a=await s.execute();return a&&!r&&(delete a.user._redirectEventId,await n._persistUserIfCurrent(a.user),await n._setRedirectUser(null,t)),a}class rh{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(e,r)&&(t=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!function(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return rd(e);default:return!1}}(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){if(e.error&&!rd(e)){let r=e.error.code?.split("auth/")[1]||"internal-error";t.onError(C(this.auth,r))}else t.onAuthEvent(e)}isEventForConsumer(e,t){let r=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=6e5&&this.cachedEventUids.clear(),this.cachedEventUids.has(rc(e))}saveEventToCache(e){this.cachedEventUids.add(rc(e)),this.lastProcessedEventTime=Date.now()}}function rc(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function rd({type:e,error:t}){return"unknown"===e&&t?.code==="auth/no-auth-event"}async function rf(e,t={}){return q(e,"GET","/v1/projects",t)}let rp=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,rg=/^https?/;async function rm(e){if(e.config.emulator)return;let{authorizedDomains:t}=await rf(e);for(let e of t)try{if(function(e){let t=D(),{protocol:r,hostname:n}=new URL(t);if(e.startsWith("chrome-extension://")){let i=new URL(e);return""===i.hostname&&""===n?"chrome-extension:"===r&&e.replace("chrome-extension://","")===t.replace("chrome-extension://",""):"chrome-extension:"===r&&i.hostname===n}if(!rg.test(r))return!1;if(rp.test(e))return n===e;let i=e.replace(/\./g,"\\.");return RegExp("^(.+\\."+i+"|"+i+")$","i").test(n)}(e))return}catch{}S(e,"unauthorized-domain")}let ry=new L(3e4,6e4);function rw(){let e=tP().___jsl;if(e?.H){for(let t of Object.keys(e.H))if(e.H[t].r=e.H[t].r||[],e.H[t].L=e.H[t].L||[],e.H[t].r=[...e.H[t].L],e.CP)for(let t=0;t<e.CP.length;t++)e.CP[t]=null}}let rv=null,rI=new L(5e3,15e3),rb={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},rE=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);async function rT(e){let t,r,n,i,s,a=await (rv=rv||new Promise((t,r)=>{function n(){rw(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{rw(),r(C(e,"network-request-failed"))},timeout:ry.get()})}if(tP().gapi?.iframes?.Iframe)t(gapi.iframes.getContext());else if(tP().gapi?.load)n();else{let t=ej("iframefcb");return tP()[t]=()=>{gapi.load?n():r(C(e,"network-request-failed"))},eB(`${eU.gapiScript}?onload=${t}`).catch(e=>r(e))}}).catch(e=>{throw rv=null,e})),o=tP().gapi;return N(o,e,"internal-error"),a.open({where:document.body,url:(N((t=e.config).authDomain,e,"auth-domain-config-required"),r=t.emulator?M(t,"emulator/auth/iframe"):`https://${e.config.authDomain}
2/__/auth/iframe`,n={apiKey:t.apiKey,appName:e.name,v:y.SDK_VERSION},(i=rE.get(e.config.apiHost))&&(n.eid=i),(s=e._getFrameworks()).length&&(n.fw=s.join(",")),`${r}?${(0,w.querystring)(n).slice(1)}`),messageHandlersFilter:o.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:rb,dontclear:!0},t=>new Promise(async(r,n)=>{await t.restyle({setHideOnLeave:!1});let i=C(e,"network-request-failed"),s=tP().setTimeout(()=>{n(i)},rI.get());function a(){tP().clearTimeout(s),r(t)}t.ping(a).then(a,()=>{n(i)})}))}let r_={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class rS{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}let rC=encodeURIComponent("fac");async function rk(e,t,r,n,i,s){N(e.config.authDomain,e,"auth-domain-config-required"),N(e.config.apiKey,e,"invalid-api-key");let a={apiKey:e.config.apiKey,appName:e.name,authType:r,redirectUrl:n,v:y.SDK_VERSION,eventId:i};if(t instanceof ts)for(let[r,n]of(t.setDefaultLanguage(e.languageCode),a.providerId=t.providerId||"",(0,w.isEmpty)(t.getCustomParameters())||(a.customParameters=JSON.stringify(t.getCustomParameters())),Object.entries(s||{})))a[r]=n;if(t instanceof ta){let e=t.getScopes().filter(e=>""!==e);e.length>0&&(a.scopes=e.join(","))}for(let t of(e.tenantId&&(a.tid=e.tenantId),Object.keys(a)))void 0===a[t]&&delete a[t];let o=await e._getAppCheckToken(),l=o?`#${rC}=${encodeURIComponent(o)}`:"";return`${function({config:e}){return e.emulator?M(e,"emulator/auth/handler"):`https://${e.authDomain}/__/auth/handler`}(e)}?${(0,w.querystring)(a).slice(1)}${l}`}let rA="webStorageSupport",rx=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=tx,this._completeRedirectFn=ru,this._overrideRedirectResult=rl}async _openPopup(e,t,r,n){var i,s;i=this.eventManagers[e._key()]?.manager,s="_initialize() not called before _openPopup()",i||R(s);let a=await rk(e,t,r,D(),n);return function(e,t,r,n=500,i=600){let s=Math.max((window.screen.availHeight-i)/2,0).toString(),a=Math.max((window.screen.availWidth-n)/2,0).toString(),o="",l={...r_,width:n.toString(),height:i.toString(),top:s,left:a},u=(0,w.getUA)().toLowerCase();r&&(o=eS(u)?"_blank":r),eT(u)&&(t=t||"http://localhost",l.scrollbars="yes");let h=Object.entries(l).reduce((e,[t,r])=>`${e}${t}=${r},`,"");if(function(e=(0,w.getUA)()){return eN(e)&&!!window.navigator?.standalone}(u)&&"_self"!==o){var c,d;let e,r;return c=t||"",d=o,(e=document.createElement("a")).href=c,e.target=d,(r=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),e.dispatchEvent(r),new rS(null)}let f=window.open(t||"",o,h);N(f,e,"popup-blocked");try{f.focus()}catch(e){}return new rS(f)}(e,a,tR())}async _openRedirect(e,t,r,n){var i;return await this._originValidation(e),i=await rk(e,t,r,D(),n),tP().location.href=i,new Promise(()=>{})}_initialize(e){let t=e._key();if(this.eventManagers[t]){var r;let{manager:e,promise:n}=this.eventManagers[t];return e?Promise.resolve(e):(r="If manager is not set, promise should be",n||R(r),n)}let n=this.initAndGetManager(e);return this.eventManagers[t]={promise:n},n.catch(()=>{delete this.eventManagers[t]}),n}async initAndGetManager(e){let t=await rT(e),r=new rh(e);return t.register("authEvent",t=>(N(t?.authEvent,e,"invalid-auth-event"),{status:r.onEvent(t.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=t,r}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(rA,{type:rA},r=>{let n=r?.[0]?.[rA];void 0!==n&&t(!!n),S(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){let t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=rm(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return eR()||e_()||eN()}};var rN="@firebase/auth",rR="1.13.0";class rD{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){return this.assertAuthConfigured(),this.auth.currentUser?.uid||null}async getToken(e){return(this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser)?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;let t=this.auth.onIdTokenChanged(t=>{e(t?.stsTokenManager.accessToken||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();let t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){N(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}let rP=(0,w.getExperimentalSetting)("authIdTokenMaxAge")||300,rO=null;eU={loadJS:e=>
2new Promise((t,r)=>{let n=document.createElement("script");n.setAttribute("src",e),n.onload=t,n.onerror=e=>{let t=C("internal-error");t.customData=e,r(t)},n.type="text/javascript",n.charset="UTF-8",(document.getElementsByTagName("head")?.[0]??document).appendChild(n)}),gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="},t="Browser",(0,y._registerComponent)(new I.Component("auth",(e,{options:r})=>{let n,i,s=e.getProvider("app").getImmediate(),a=e.getProvider("heartbeat"),o=e.getProvider("app-check-internal"),{apiKey:l,authDomain:u}=s.options;N(l&&!l.includes(":"),"invalid-api-key",{appName:s.name});let h=new eM(s,a,o,{apiKey:l,authDomain:u,clientPlatform:t,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:eD(t)});return i=(Array.isArray(n=r?.persistence||[])?n:[n]).map(ew),r?.errorMap&&h._updateErrorMap(r.errorMap),h._initializeWithPersistence(i,r?.popupRedirectResolver),h},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),(0,y._registerComponent)(new I.Component("auth-internal",e=>new rD(eV(e.getProvider("auth").getImmediate())),"PRIVATE").setInstantiationMode("EXPLICIT")),(0,y.registerVersion)(rN,rR,function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}(t)),(0,y.registerVersion)(rN,rR,"esm2020");var rL=e.i(271645),rM=e.i(247167);(0,y.registerVersion)("firebase","12.12.0","app");var rV=e.i(467034),rF=w,rU="u">typeof globalThis?globalThis:"u">typeof window?window:e.g,rB={};(function(){function e(){this.blockSize=-1,this.blockSize=64,this.g=[,,,,],this.C=Array(this.blockSize),this.o=this.h=0,this.u()}var t=function(){this.blockSize=-1};function i(){}function s(e,t,r){r||(r=0);let n=Array(16);if("string"==typeof t)for(var i=0;i<16;++i)n[i]=t.charCodeAt(r++)|t.charCodeAt(r++)<<8|t.charCodeAt(r++)<<16|t.charCodeAt(r++)<<24;else for(i=0;i<16;++i)n[i]=t[r++]|t[r++]<<8|t[r++]<<16|t[r++]<<24;t=e.g[0],r=e.g[1],i=e.g[2];let s=e.g[3],a;a=t+(s^r&(i^s))+n[0]+0xd76aa478|0,a=s+(i^(t=r+(a<<7|a>>>25))&(r^i))+n[1]+0xe8c7b756|0,a=i+(r^(s=t+(a<<12|a>>>20))&(t^r))+n[2]+0x242070db|0,a=r+(t^(i=s+(a<<17|a>>>15))&(s^t))+n[3]+0xc1bdceee|0,a=t+(s^(r=i+(a<<22|a>>>10))&(i^s))+n[4]+0xf57c0faf|0,a=s+(i^(t=r+(a<<7|a>>>25))&(r^i))+n[5]+0x4787c62a|0,a=i+(r^(s=t+(a<<12|a>>>20))&(t^r))+n[6]+0xa8304613|0,a=r+(t^(i=s+(a<<17|a>>>15))&(s^t))+n[7]+0xfd469501|0,a=t+(s^(r=i+(a<<22|a>>>10))&(i^s))+n[8]+0x698098d8|0,a=s+(i^(t=r+(a<<7|a>>>25))&(r^i))+n[9]+0x8b44f7af|0,a=i+(r^(s=t+(a<<12|a>>>20))&(t^r))+n[10]+0xffff5bb1|0,a=r+(t^(i=s+(a<<17|a>>>15))&(s^t))+n[11]+0x895cd7be|0,a=t+(s^(r=i+(a<<22|a>>>10))&(i^s))+n[12]+0x6b901122|0,a=s+(i^(t=r+(a<<7|a>>>25))&(r^i))+n[13]+0xfd987193|0,a=i+(r^(s=t+(a<<12|a>>>20))&(t^r))+n[14]+0xa679438e|0,a=r+(t^(i=s+(a<<17|a>>>15))&(s^t))+n[15]+0x49b40821|0,r=i+(a<<22|a>>>10),a=t+(i^s&(r^i))+n[1]+0xf61e2562|0,t=r+(a<<5|a>>>27),a=s+(r^i&(t^r))+n[6]+0xc040b340|0,s=t+(a<<9|a>>>23),a=i+(t^r&(s^t))+n[11]+0x265e5a51|0,i=s+(a<<14|a>>>18),a=r+(s^t&(i^s))+n[0]+0xe9b6c7aa|0,r=i+(a<<20|a>>>12),a=t+(i^s&(r^i))+n[5]+0xd62f105d|0,t=r+(a<<5|a>>>27),a=s+(r^i&(t^r))+n[10]+0x2441453|0,s=t+(a<<9|a>>>23),a=i+(t^r&(s^t))+n[15]+0xd8a1e681|0,i=s+(a<<14|a>>>18),a=r+(s^t&(i^s))+n[4]+0xe7d3fbc8|0,r=i+(a<<20|a>>>12),a=t+(i^s&(r^i))+n[9]+0x21e1cde6|0,t=r+(a<<5|a>>>27),a=s+(r^i&(t^r))+n[14]+0xc33707d6|0,s=t+(a<<9|a>>>23),a=i+(t^r&(s^t))+n[3]+0xf4d50d87|0,i=s+(a<<14|a>>>18),a=r+(s^t&(i^s))+n[8]+0x455a14ed|0,r=i+(a<<20|a>>>12),a=t+(i^s&(r^i))+n[13]+0xa9e3e905|0,t=r+(a<<5|a>>>27),a=s+(r^i&(t^r))+n[2]+0xfcefa3f8|0,s=t+(a<<9|a>>>23),a=i+(t^r&(s^t))+n[7]+0x676f02d9|0,i=s+(a<<14|a>>>18),a=r+(s^t&(i^s))+n[12]+0x8d2a4c8a|0,a=t+((r=i+(a<<20|a>>>12))^i^s)+n[5]+0xfffa3942|0,a=s+((t=r+(a<<4|a>>>28))^r^i)+n[8]+0x8771f681|0,a=i+((s=t+(a<<11|a>>>21))^t^r)+n[11]+0x6d9d6122|0,a=r+((i=s+(a<<16|a>>>16))^s^t)+n[14]+0xfde5380c|0,a=t+((r=i+(a<<23|a>>>9))^i^s)+n[1]+0xa4beea44|0,a=s+((t=r+(a<<4|a>>>28))^r^i)+n[4]+0x4bdecfa9|0,a=i+((s=t+(a<<11|a>>>21))^t^r)+n[7]+0xf6bb4b60|0,a=r+((i=s+(a<<16|a>>>16))^s^t)+n[10]+0xbebfbc70|0,a=t+((r=i+(a<<23|a>>>9))^i^s)+n[13]+0x289b7ec6|0,a=s+((t=r+(a<<4|a>>>28))^r^i)+n[0]+0xeaa127fa|0,a=i+((s=t+(a<<11|a>>>21))^t^r)+n[3]+0xd4ef3085|0,a=r+((i=s+(a<<16|a>>>16))^s^t)+n[6]+0x4881d05|0,a=t+((r=i+(a<<23|a>>>9))^i^s)+n[9]+0xd9d4d039|0,a=s+((t=r+(a<<4|a>>>28))^r^i)+n[12]+0xe6db99e5|0,a=i+((s=t+(a<<11|a>>>21))^t^r)+n[15]+0x1fa27cf8|0,a=r+((i=s+(a<<16|a>>>16))^s^t)+n[2]+0xc4ac5665|0,r=i+(a<<23|a>>>
29),a=t+(i^(r|~s))+n[0]+0xf4292244|0,t=r+(a<<6|a>>>26),a=s+(r^(t|~i))+n[7]+0x432aff97|0,s=t+(a<<10|a>>>22),a=i+(t^(s|~r))+n[14]+0xab9423a7|0,i=s+(a<<15|a>>>17),a=r+(s^(i|~t))+n[5]+0xfc93a039|0,r=i+(a<<21|a>>>11),a=t+(i^(r|~s))+n[12]+0x655b59c3|0,t=r+(a<<6|a>>>26),a=s+(r^(t|~i))+n[3]+0x8f0ccc92|0,s=t+(a<<10|a>>>22),a=i+(t^(s|~r))+n[10]+0xffeff47d|0,i=s+(a<<15|a>>>17),a=r+(s^(i|~t))+n[1]+0x85845dd1|0,r=i+(a<<21|a>>>11),a=t+(i^(r|~s))+n[8]+0x6fa87e4f|0,t=r+(a<<6|a>>>26),a=s+(r^(t|~i))+n[15]+0xfe2ce6e0|0,s=t+(a<<10|a>>>22),a=i+(t^(s|~r))+n[6]+0xa3014314|0,i=s+(a<<15|a>>>17),a=r+(s^(i|~t))+n[13]+0x4e0811a1|0,r=i+(a<<21|a>>>11),a=t+(i^(r|~s))+n[4]+0xf7537e82|0,t=r+(a<<6|a>>>26),a=s+(r^(t|~i))+n[11]+0xbd3af235|0,s=t+(a<<10|a>>>22),a=i+(t^(s|~r))+n[2]+0x2ad7d2bb|0,i=s+(a<<15|a>>>17),a=r+(s^(i|~t))+n[9]+0xeb86d391|0,e.g[0]=e.g[0]+t|0,e.g[1]=e.g[1]+(i+(a<<21|a>>>11))|0,e.g[2]=e.g[2]+i|0,e.g[3]=e.g[3]+s|0}function a(e,t){this.h=t;let r=[],n=!0;for(let i=e.length-1;i>=0;i--){let s=0|e[i];n&&s==t||(r[i]=s,n=!1)}this.g=r}i.prototype=t.prototype,e.F=t.prototype,e.prototype=new i,e.prototype.constructor=e,e.D=function(e,r,n){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return t.prototype[r].apply(e,i)},e.prototype.u=function(){this.g[0]=0x67452301,this.g[1]=0xefcdab89,this.g[2]=0x98badcfe,this.g[3]=0x10325476,this.o=this.h=0},e.prototype.v=function(e,t){void 0===t&&(t=e.length);let r=t-this.blockSize,n=this.C,i=this.h,a=0;for(;a<t;){if(0==i)for(;a<=r;)s(this,e,a),a+=this.blockSize;if("string"==typeof e){for(;a<t;)if(n[i++]=e.charCodeAt(a++),i==this.blockSize){s(this,n),i=0;break}}else for(;a<t;)if(n[i++]=e[a++],i==this.blockSize){s(this,n),i=0;break}}this.h=i,this.o+=t},e.prototype.A=function(){var e=Array((this.h<56?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var t=1;t<e.length-8;++t)e[t]=0;t=8*this.o;for(var r=e.length-8;r<e.length;++r)e[r]=255&t,t/=256;for(this.v(e),e=Array(16),t=0,r=0;r<4;++r)for(let n=0;n<32;n+=8)e[t++]=this.g[r]>>>n&255;return e};var o,l={};function u(e){var t;return -128<=e&&e<128?(t=function(e){return new a([0|e],e<0?-1:0)},Object.prototype.hasOwnProperty.call(l,e)?l[e]:l[e]=t(e)):new a([0|e],e<0?-1:0)}function h(e){if(isNaN(e)||!isFinite(e))return c;if(e<0)return m(h(-e));let t=[],r=1;for(let n=0;e>=r;n++)t[n]=e/r|0,r*=0x100000000;return new a(t,0)}var c=u(0),d=u(1),f=u(0x1000000);function p(e){if(0!=e.h)return!1;for(let t=0;t<e.g.length;t++)if(0!=e.g[t])return!1;return!0}function g(e){return -1==e.h}function m(e){let t=e.g.length,r=[];for(let n=0;n<t;n++)r[n]=~e.g[n];return new a(r,~e.h).add(d)}function y(e,t){return e.add(m(t))}function w(e,t){for(;(65535&e[t])!=e[t];)e[t+1]+=e[t]>>>16,e[t]&=65535,t++}function v(e,t){this.g=e,this.h=t}function I(e,t){if(p(t))throw Error("division by zero");if(p(e))return new v(c,c);if(g(e))return t=I(m(e),t),new v(m(t.g),m(t.h));if(g(t))return t=I(e,m(t)),new v(m(t.g),t.h);if(e.g.length>30){if(g(e)||g(t))throw Error("slowDivide_ only works with positive integers.");for(var r=d,n=t;0>=n.l(e);)r=b(r),n=b(n);var i=E(r,1),s=E(n,1);for(n=E(n,2),r=E(r,2);!p(n);){var a=s.add(n);0>=a.l(e)&&(i=i.add(r),s=a),n=E(n,1),r=E(r,1)}return t=y(e,i.j(t)),new v(i,t)}for(i=c;e.l(t)>=0;){for(n=(n=Math.ceil(Math.log(r=Math.max(1,Math.floor(e.m()/t.m())))/Math.LN2))<=48?1:Math.pow(2,n-48),a=(s=h(r)).j(t);g(a)||a.l(e)>0;)r-=n,a=(s=h(r)).j(t);p(s)&&(s=d),i=i.add(s),e=y(e,a)}return new v(i,e)}function b(e){let t=e.g.length+1,r=[];for(let n=0;n<t;n++)r[n]=e.i(n)<<1|e.i(n-1)>>>31;return new a(r,e.h)}function E(e,t){let r=t>>5;t%=32;let n=e.g.length-r,i=[];for(let s=0;s<n;s++)i[s]=t>0?e.i(s+r)>>>t|e.i(s+r+1)<<32-t:e.i(s+r);return new a(i,e.h)}(o=a.prototype).m=function(){if(g(this))return-m(this).m();let e=0,t=1;for(let r=0;r<this.g.length;r++){let n=this.i(r);e+=(n>=0?n:0x100000000+n)*t,t*=0x100000000}return e},o.toString=function(e){if((e=e||10)<2||36<e)throw Error("radix out of range: "+e);if(p(this))return"0";if(g(this))return"-"+m(this).toString(e);let t=h(Math.pow(e,6));var r=this;let n="";for(;;){let i=I(r,t).g,s=(((r=y(r,i.j(t))).g.length>0?r.g[0]:r.h)>>>0).toString(e);if(p(r=i))return s+n;for(;s.length<6;)s="0"+s;n=s+n}},o.i=function(e){return e<0?0:e<this.g.length?this.g[e]:this.h},o.l=function(e){return g(e=y(this,e))?-1:+!p(e)},o.abs=function(){return g(this)?m(this):this},o.add=function(e){let t=Math.max(this.g.length,e.g.length),r=[],n=0;for(let i=0;i<=t;i++){let t=n+(65535&this.i(i))+(65535&e.i(i)),s=(t>>>16)+(this.i(i)>>>16)+(e.i(i)>>>16);n=s>>>16,t&=65535,s&=65535,r[i]=s<<16|t}return new a(r,-0x80000000&r[r.length-1]?-1:0)},o.j=function(e){if(p(this)||p(e))return c;if(g(this))return g(e)?m(this).j(m(e)):m(m(this).j(e));if(g(e))return m(this.j(m(e)));if(0>this.l(f)&&0>e.l(f))return h(this.m()*e.m());let t=this.g.length+e.g.length,r=[];for(var n=0;n<2*t;n++)r[n]=0;for(n=0;n<this.g.length;n++)for(let t=0;t<e.g.length;t++){let i=this.i(n)>>>16,s=65535&this.i(n),a=e.i(t)>>>16,o=65535&e.i(t);r[2*n+2*t]+=s*o,w(r,2*n+2*t),r[2*n+2*t+1]+=i*o,w(r,2*n+2*t+1),r[2*n+2*t+1]+=s*a,w(r,2*n+2*t+1),r[2*n+2*t+2]+=i*a,w(r,2*n+2*t+2)}for(e=0;e<t;e++)r[e]=r[2*e+1]<<16|r[2*e];for(e=t;e<2*t;e++)r[e]=0;return new a(r,0)},o.B=function(e){return I(this,e).h},o.and=function(e){let t=Math.max(this.g.length,e.g.length),r=[];for(let n=0;n<t;n++)r[n]=this.i(n)&e.i(n);return new a(r,this.h&e.h)},o.or=function(e){let t=Math.max(this.g.length,e.g.length),r=[];for(let n=0;n<t;n++)r[n]=this.i(n)|e.i(n);return new a(r,this.h|e.h)},o.xor=function(e){let t=Math.max(this.g.length,e.g.length),r=[];for(let n=0;n<t;n++)r[n]=this.i(n)^e.i(n);return new a(r,this.h^e.h)},e.prototype.digest=e.prototype.A,e.prototype.reset=e.prototype.u,e.prototype.update=e.prototype.v,n=rB.Md5=e,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.B,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=h,a.fromString=function e(t,r){if(0==t.length)throw Error("number format error: empty string");if((r=r||10)<2||36<r)throw Error("radix out of range: "+r);if("-"==t.charAt(0))return m(e(t.substring(1),r));if(t.indexOf("-")>=0)throw Error('number format error: interior "-" character');let n=h(Math.pow(r,8)),i=c;for(let e=0;e<t.length;e+=8){var s=Math.min(8,t.length-e);let a=parseInt(t.substring(e,e+s),r);s<8?(s=h(Math.pow(r,s)),i=i.j(s).add(h(a))):i=(i=i.j(n)).add(h(a))}return i},r=rB.Integer=a}).apply(void 0!==rU?rU:"u">typeof self?self:"u">typeof window?window:{});var rj="u">typeof globalThis?globalThis:"u">typeof window?window:e.g,rq={};(function(){var e,t,r=Object.defineProperty,n=function(e){e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof rj&&rj];for(var t=0;t<e.length;++t){var r=e[t];if(r&&r.Math==Math)return r}throw Error("Cannot find global object")}(this);function d(e,t){if(t)e:{var i=n;e=e.split(".");for(var s=0;s<e.length-1;s++){var a=e[s];if(!(a in i))break e;i=i[a]}(t=t(s=i[e=e[e.length-1]]))!=s&&null!=t&&r(i,e,{configurable:!0,writable:!0,value:t})}}d("Symbol.dispose",function(e){return e||Symbol("Symbol.dispose")}),d("Array.prototype.values",function(e){return e||function(){return this[Symbol.iterator]()}}),d("Object.entries",function(e){return e||function(e){var t,r=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.push([t,e[t]]);return r}});var f=f||{},p=this||self;function g(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}function m(e,t,r){return e.call.apply(e.bind,arguments)}function y(e,t,r){return(y=m).apply(null,arguments)}
2function w(e,t){var r=Array.prototype.slice.call(arguments,1);return function(){var t=r.slice();return t.push.apply(t,arguments),e.apply(this,t)}}function v(e,t){function r(){}r.prototype=t.prototype,e.Z=t.prototype,e.prototype=new r,e.prototype.constructor=e,e.Ob=function(e,r,n){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return t.prototype[r].apply(e,i)}}var I="u">typeof AsyncContext&&"function"==typeof AsyncContext.Snapshot?e=>e&&AsyncContext.Snapshot.wrap(e):e=>e;function b(e){let t=e.length;if(t>0){let r=Array(t);for(let n=0;n<t;n++)r[n]=e[n];return r}return[]}function E(e,t){for(let t=1;t<arguments.length;t++){let n=arguments[t];var r=typeof n;if("array"==(r="object"!=r?r:n?Array.isArray(n)?"array":r:"null")||"object"==r&&"number"==typeof n.length){r=e.length||0;let t=n.length||0;e.length=r+t;for(let i=0;i<t;i++)e[r+i]=n[i]}else e.push(n)}}var T=new class{constructor(e,t){this.i=e,this.j=t,this.h=0,this.g=null}get(){let e;return this.h>0?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e}}(()=>new _,e=>e.reset());class _{constructor(){this.next=this.g=this.h=null}set(e,t){this.h=e,this.g=t,this.next=null}reset(){this.next=this.g=this.h=null}}let S,C=!1,k=new class{constructor(){this.h=this.g=null}add(e,t){let r=T.get();r.set(e,t),this.h?this.h.next=r:this.g=r,this.h=r}},A=()=>{let e=Promise.resolve(void 0);S=()=>{e.then(x)}};function x(){let e;for(var t;e=null,k.g&&(e=k.g,k.g=k.g.next,k.g||(k.h=null),e.next=null),t=e;){try{t.h.call(t.g)}catch(e){!function(e){p.setTimeout(()=>{throw e},0)}(e)}T.j(t),T.h<100&&(T.h++,t.next=T.g,T.g=t)}C=!1}function N(){this.u=this.u,this.C=this.C}function R(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}N.prototype.u=!1,N.prototype.dispose=function(){this.u||(this.u=!0,this.N())},N.prototype[Symbol.dispose]=function(){this.dispose()},N.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()},R.prototype.h=function(){this.defaultPrevented=!0};var D=function(){if(!p.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{let e=()=>{};p.addEventListener("test",e,t),p.removeEventListener("test",e,t)}catch(e){}return e}();function P(e){return/^[\s\xa0]*$/.test(e)}function O(e,t){R.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&&this.init(e,t)}v(O,R),O.prototype.init=function(e,t){let r=this.type=e.type,n=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;this.target=e.target||e.srcElement,this.g=t,(t=e.relatedTarget)||("mouseover"==r?t=e.fromElement:"mouseout"==r&&(t=e.toElement)),this.relatedTarget=t,n?(this.clientX=void 0!==n.clientX?n.clientX:n.pageX,this.clientY=void 0!==n.clientY?n.clientY:n.pageY,this.screenX=n.screenX||0,this.screenY=n.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=e.pointerType,this.state=e.state,this.i=e,e.defaultPrevented&&O.Z.h.call(this)},O.prototype.h=function(){O.Z.h.call(this);let e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var L="closure_listenable_"+(1e6*Math.random()|0),M=0;function V(e,t,r,n,i){this.listener=e,this.proxy=null,this.src=t,this.type=r,this.capture=!!n,this.ha=i,this.key=++M,this.da=this.fa=!1}function F(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function U(e,t,r){for(let n in e)t.call(r,e[n],n,e)}function B(e){let t={};for(let r in e)t[r]=e[r];return t}let j="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function q(e,t){let r,n;for(let t=1;t<arguments.length;t++){for(r in n=arguments[t])e[r]=n[r];for(let t=0;t<j.length;t++)r=j[t],Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}}function z(e){this.src=e,this.g={},this.h=0}function K(e,t){let r=t.type;if(r in e.g){var n,i=e.g[r],s=Array.prototype.indexOf.call(i,t,void 0);(n=s>=0)&&Array.prototype.splice.call(i,s,1),n&&(F(t),0==e.g[r].length&&(delete e.g[r],e.h--))}}function $(e,t,r,n){for(let i=0;i<e.length;++i){let s=e[i];if(!s.da&&s.listener==t&&!!r==s.capture&&s.ha==n)return i}return -1}z.prototype.add=function(e,t,r,n,i){let s=e.toString();(e=this.g[s])||(e=this.g[s]=[],this.h++);let a=$(e,t,n,i);return a>-1?(t=e[a],r||(t.fa=!1)):((t=new V(t,this.src,s,!!n,i)).fa=r,e.push(t)),t};var G="closure_lm_"+(1e6*Math.random()|0),H={};function W(e,t,r,n,i,s){if(!t)throw Error("Invalid event type");let a=g(i)?!!i.capture:!!i,o=X(e);if(o||(e[G]=o=new z(e)),(r=o.add(t,r,n,a,s)).proxy)return r;if(n=function e(t){return Y.call(e.src,e.listener,t)},r.proxy=n,n.src=e,n.listener=r,e.addEventListener)D||(i=a),void 0===i&&(i=!1),e.addEventListener(t.toString(),n,i);else if(e.attachEvent)e.attachEvent(J(t.toString()),n);else if(e.addListener&&e.removeListener)e.addListener(n);else throw Error("addEventListener and attachEvent are unavailable.");return r}function Q(e){if("number"!=typeof e&&e&&!e.da){var t=e.src;if(t&&t[L])K(t.i,e);else{var r=e.type,n=e.proxy;t.removeEventListener?t.removeEventListener(r,n,e.capture):t.detachEvent?t.detachEvent(J(r),n):t.addListener&&t.removeListener&&t.removeListener(n),(r=X(t))?(K(r,e),0==r.h&&(r.src=null,t[G]=null)):F(e)}}}function J(e){return e in H?H[e]:H[e]="on"+e}function Y(e,t){if(e.da)e=!0;else{t=new O(t,this);let r=e.listener,n=e.ha||e.src;e.fa&&Q(e),e=r.call(n,t)}return e}function X(e){return(e=e[G])instanceof z?e:null}var Z="__closure_events_fn_"+(1e9*Math.random()>>>0);function ee(e){return"function"==typeof e?e:(e[Z]||(e[Z]=function(t){return e.handleEvent(t)}),e[Z])}function et(){N.call(this),this.i=new z(this),this.M=this,this.G=null}function er(e,t){let r,n;var i,s=e.G;if(s)for(i=[];s;s=s.G)i.push(s);if(e=e.M,s=t.type||t,"string"==typeof t)t=new R(t,e);else if(t instanceof R)t.target=t.target||e;else{var a=t;q(t=new R(s,e),a)}if(a=!0,i)for(n=i.length-1;n>=0;n--)a=en(r=t.g=i[n],s,!0,t)&&a;if(a=en(r=t.g=e,s,!0,t)&&a,a=en(r,s,!1,t)&&a,i)for(n=0;n<i.length;n++)a=en(r=t.g=i[n],s,!1,t)&&a}function en(e,t,r,n){if(!(t=e.i.g[String(t)]))return!0;t=t.concat();let i=!0;for(let s=0;s<t.length;++s){let a=t[s];if(a&&!a.da&&a.capture==r){let t=a.listener,r=a.ha||a.src;a.fa&&K(e.i,a),i=!1!==t.call(r,n)&&i}}return i&&!n.defaultPrevented}v(et,N),et.prototype[L]=!0,et.prototype.removeEventListener=function(e,t,r,n){!function e(t,r,n,i,s){if(Array.isArray(r))for(var a=0;a<r.length;a++)e(t,r[a],n,i,s);else(i=g(i)?!!i.capture:!!i,n=ee(n),t&&t[L])?(t=t.i,(a=String(r).toString())in t.g&&(n=$(r=t.g[a],n,i,s))>-1&&(F(r[n]),Array.prototype.splice.call(r,n,1),0==r.length&&(delete t.g[a],t.h--))):t&&(t=X(t))&&(r=t.g[r.toString()],t=-1,r&&(t=$(r,n,i,s)
2),(n=t>-1?r[t]:null)&&Q(n))}(this,e,t,r,n)},et.prototype.N=function(){if(et.Z.N.call(this),this.i){var e=this.i;for(let t in e.g){let r=e.g[t];for(let e=0;e<r.length;e++)F(r[e]);delete e.g[t],e.h--}}this.G=null},et.prototype.J=function(e,t,r,n){return this.i.add(String(e),t,!1,r,n)},et.prototype.K=function(e,t,r,n){return this.i.add(String(e),t,!0,r,n)};class ei extends N{constructor(e,t){super(),this.m=e,this.l=t,this.h=null,this.i=!1,this.g=null}j(e){this.h=arguments,this.g?this.i=!0:function e(t){t.g=function(e,t){if("function"!=typeof e)if(e&&"function"==typeof e.handleEvent)e=y(e.handleEvent,e);else throw Error("Invalid listener argument");return Number(t)>0x7fffffff?-1:p.setTimeout(e,t||0)}(()=>{t.g=null,t.i&&(t.i=!1,e(t))},t.l);let r=t.h;t.h=null,t.m.apply(null,r)}(this)}N(){super.N(),this.g&&(p.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function es(e){N.call(this),this.h=e,this.g={}}v(es,N);var ea=[];function eo(e){U(e.g,function(e,t){this.g.hasOwnProperty(t)&&Q(e)},e),e.g={}}es.prototype.N=function(){es.Z.N.call(this),eo(this)},es.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var el=p.JSON.stringify,eu=p.JSON.parse,eh=class{stringify(e){return p.JSON.stringify(e,void 0)}parse(e){return p.JSON.parse(e,void 0)}};function ec(){}function ed(){}var ef={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function ep(){R.call(this,"d")}function eg(){R.call(this,"c")}v(ep,R),v(eg,R);var em={},ey=null;function ew(){return ey=ey||new et}function ev(e){R.call(this,em.Ia,e)}function eI(e){let t=ew();er(t,new ev(t))}function eb(e,t){R.call(this,em.STAT_EVENT,e),this.stat=t}function eE(e){let t=ew();er(t,new eb(t,e))}function eT(e,t){R.call(this,em.Ja,e),this.size=t}function e_(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return p.setTimeout(function(){e()},t)}function eS(){this.g=!0}function eC(e,t,r,n){e.info(function(){return"XMLHTTP TEXT ("+t+"): "+function(e,t){if(!e.g)return t;if(!t)return null;try{let s=JSON.parse(t);if(s){for(e=0;e<s.length;e++)if(Array.isArray(s[e])){var r=s[e];if(!(r.length<2)){var n=r[1];if(Array.isArray(n)&&!(n.length<1)){var i=n[0];if("noop"!=i&&"stop"!=i&&"close"!=i)for(let e=1;e<n.length;e++)n[e]=""}}}}return el(s)}catch(e){return t}}(e,r)+(n?" "+n:"")})}em.Ia="serverreachability",v(ev,R),em.STAT_EVENT="statevent",v(eb,R),em.Ja="timingevent",v(eT,R),eS.prototype.ua=function(){this.g=!1},eS.prototype.info=function(){};var ek={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},eA={ib:"complete",Fb:"success",ERROR:"error",Ga:"abort",xb:"ready",yb:"readystatechange",TIMEOUT:"timeout",sb:"incrementaldata",wb:"progress",lb:"downloadprogress",Nb:"uploadprogress"};function ex(){}function eN(e){return encodeURIComponent(String(e))}function eR(e,t,r,n){this.j=e,this.i=t,this.l=r,this.S=n||1,this.V=new es(this),this.H=45e3,this.J=null,this.o=!1,this.u=this.B=this.A=this.M=this.F=this.T=this.D=null,this.G=[],this.g=null,this.C=0,this.m=this.v=null,this.X=-1,this.K=!1,this.P=0,this.O=null,this.W=this.L=this.U=this.R=!1,this.h=new eD}function eD(){this.i=null,this.g="",this.h=!1}v(ex,ec),ex.prototype.g=function(){return new XMLHttpRequest},e=new ex;var eP={},eO={};function eL(e,t,r){e.M=1,e.A=e3(e0(t)),e.u=r,e.R=!0,eM(e,null)}function eM(e,t){e.F=Date.now(),eF(e),e.B=e0(e.A);var r,n,i,s,a,o,l=e.B,u=e.S;Array.isArray(u)||(u=[String(u)]),tu(l.i,"t",u),e.C=0,l=e.j.L,e.h=new eD,e.g=tQ(e.j,l?t:null,!e.u),e.P>0&&(e.O=new ei(y(e.Y,e,e.g),e.P)),t=e.V,l=e.g,u=e.ba;var h="readystatechange";Array.isArray(h)||(h&&(ea[0]=h.toString()),h=ea);for(let e=0;e<h.length;e++){let r=function e(t,r,n,i,s){if(i&&i.once)return function e(t,r,n,i,s){if(Array.isArray(r)){for(let a=0;a<r.length;a++)e(t,r[a],n,i,s);return null}return n=ee(n),t&&t[L]?t.K(r,n,g(i)?!!i.capture:!!i,s):W(t,r,n,!0,i,s)}(t,r,n,i,s);if(Array.isArray(r)){for(let a=0;a<r.length;a++)e(t,r[a],n,i,s);return null}return n=ee(n),t&&t[L]?t.J(r,n,g(i)?!!i.capture:!!i,s):W(t,r,n,!1,i,s)}(l,h[e],u||t.handleEvent,!1,t.h||t);if(!r)break;t.g[r.key]=r}t=e.J?B(e.J):{},e.u?(e.v||(e.v="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.ea(e.B,e.v,e.u,t)):(e.v="GET",e.g.ea(e.B,e.v,null,t)),eI(),r=e.i,n=e.v,i=e.B,s=e.l,a=e.S,o=e.u,r.info(function(){if(r.g)if(o){var e="",t=o.split("&");for(let r=0;r<t.length;r++){var l=t[r].split("=");if(l.length>1){let t=l[0];l=l[1];let r=t.split("_");e=r.length>=2&&"type"==r[1]?e+(t+"=")+l+"&":e+(t+"=redacted&")}}}else e=null;else e=o;return"XMLHTTP REQ ("+s+") [attempt "+a+"]: "+n+"\n"+i+"\n"+e})}function eV(e){return!!e.g&&"GET"==e.v&&2!=e.M&&e.j.Aa}function eF(e){e.T=Date.now()+e.H,eU(e,e.H)}function eU(e,t){if(null!=e.D)throw Error("WatchDog timer not null");e.D=e_(y(e.aa,e),t)}function eB(e){e.D&&(p.clearTimeout(e.D),e.D=null)}function ej(e){0==e.j.I||e.K||tK(e.j,e)}function eq(e){eB(e);var t=e.O;t&&"function"==typeof t.dispose&&t.dispose(),e.O=null,eo(e.V),e.g&&(t=e.g,e.g=null,t.abort(),t.dis
2pose())}function ez(e,t){try{var r=e.j;if(0!=r.I&&(r.g==e||eW(r.h,e))){if(!e.L&&eW(r.h,e)&&3==r.I){try{var n=r.Ba.g.parse(t)}catch(e){n=null}if(Array.isArray(n)&&3==n.length){var i=n;if(0==i[0]){e:if(!r.v){if(r.g)if(r.g.F+3e3<e.F)tz(r),tP(r);else break e;tB(r),eE(18)}}else r.xa=i[1],0<r.xa-r.K&&i[2]<37500&&r.F&&0==r.A&&!r.C&&(r.C=e_(y(r.Va,r),6e3));1>=eH(r.h)&&r.ta&&(r.ta=void 0)}else tG(r,11)}else if((e.L||r.g==e)&&tz(r),!P(t))for(i=r.Ba.g.parse(t),t=0;t<i.length;t++){let o=i[t],l=o[0];if(!(l<=r.K))if(r.K=l,o=o[1],2==r.I)if("c"==o[0]){r.M=o[1],r.ba=o[2];let t=o[3];null!=t&&(r.ka=t,r.j.info("VER="+r.ka));let i=o[4];null!=i&&(r.za=i,r.j.info("SVER="+r.za));let l=o[5];null!=l&&"number"==typeof l&&l>0&&(r.O=n=1.5*l,r.j.info("backChannelRequestTimeoutMs_="+n)),n=r;let u=e.g;if(u){let e=u.g?u.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(e){var s=n.h;s.g||-1==e.indexOf("spdy")&&-1==e.indexOf("quic")&&-1==e.indexOf("h2")||(s.j=s.l,s.g=new Set,s.h&&(eQ(s,s.h),s.h=null))}if(n.G){let e=u.g?u.g.getResponseHeader("X-HTTP-Session-Id"):null;e&&(n.wa=e,e6(n.J,n.G,e))}}if(r.I=3,r.l&&r.l.ra(),r.aa&&(r.T=Date.now()-e.F,r.j.info("Handshake RTT: "+r.T+"ms")),(n=r).na=tW(n,n.L?n.ba:null,n.W),e.L){eJ(n.h,e);var a=n.O;a&&(e.H=a),e.D&&(eB(e),eF(e)),n.g=e}else tU(n);r.i.length>0&&tL(r)}else"stop"!=o[0]&&"close"!=o[0]||tG(r,7);else 3==r.I&&("stop"==o[0]||"close"==o[0]?"stop"==o[0]?tG(r,7):tD(r):"noop"!=o[0]&&r.l&&r.l.qa(o),r.A=0)}}eI(4)}catch(e){}}eR.prototype.ba=function(e){e=e.target;let t=this.O;t&&3==tA(e)?t.j():this.Y(e)},eR.prototype.Y=function(e){try{if(e==this.g)e:{let d=tA(this.g),f=this.g.ya(),g=this.g.ca();if(!(d<3)&&(3!=d||this.g&&(this.h.h||this.g.la()||tx(this.g)))){this.K||4!=d||7==f||(8==f||g<=0?eI(3):eI(2)),eB(this);var t=this.g.ca();this.X=t;var r=function(e){if(!eV(e))return e.g.la();let t=tx(e.g);if(""===t)return"";let r="",n=t.length,i=4==tA(e.g);if(!e.h.i){if("u"<typeof TextDecoder)return eq(e),ej(e),"";e.h.i=new p.TextDecoder}for(let s=0;s<n;s++)e.h.h=!0,r+=e.h.i.decode(t[s],{stream:!(i&&s==n-1)});return t.length=0,e.h.g+=r,e.C=0,e.h.g}(this);if(this.o=200==t,n=this.i,i=this.v,s=this.B,a=this.l,o=this.S,n.info(function(){return"XMLHTTP RESP ("+a+") [ attempt "+o+"]: "+i+"\n"+s+"\n"+d+" "+t}),this.o){if(this.U&&!this.L){t:{if(this.g){var n,i,s,a,o,l,u=this.g;if((l=u.g?u.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!P(l)){var h=l;break t}}h=null}if(e=h)eC(this.i,this.l,e,"Initial handshake response via X-HTTP-Initial-Response"),this.L=!0,ez(this,e);else{this.o=!1,this.m=3,eE(12),eq(this),ej(this);break e}}if(this.R){let t;for(e=!0;!this.K&&this.C<r.length;)if((t=function(e,t){var r=e.C,n=t.indexOf("\n",r);return -1==n?eO:isNaN(r=Number(t.substring(r,n)))?eP:(n+=1)+r>t.length?eO:(t=t.slice(n,n+r),e.C=n+r,t)}(this,r))==eO){4==d&&(this.m=4,eE(14),e=!1),eC(this.i,this.l,null,"[Incomplete Response]");break}else if(t==eP){this.m=4,eE(15),eC(this.i,this.l,r,"[Invalid Chunk]"),e=!1;break}else eC(this.i,this.l,t,null),ez(this,t);if(eV(this)&&0!=this.C&&(this.h.g=this.h.g.slice(this.C),this.C=0),4!=d||0!=r.length||this.h.h||(this.m=1,eE(16),e=!1),this.o=this.o&&e,e){if(r.length>0&&!this.W){this.W=!0;var c=this.j;c.g==this&&c.aa&&!c.P&&(c.j.info("Great, no buffering proxy detected. Bytes received: "+r.length),tj(c),c.P=!0,eE(11))}}else eC(this.i,this.l,r,"[Invalid Chunked Response]"),eq(this),ej(this)}else eC(this.i,this.l,r,null),ez(this,r);4==d&&eq(this),this.o&&!this.K&&(4==d?tK(this.j,this):(this.o=!1,eF(this)))}else(function(e){let t={};e=(e.g&&tA(e)>=2&&e.g.getAllResponseHeaders()||"").split("\r\n");for(let n=0;n<e.length;n++){if(P(e[n]))continue;var r=function(e){var t=1;e=e.split(":");let r=[];for(;t>0&&e.length;)r.push(e.shift()),t--;return e.length&&r.push(e.join(":")),r}(e[n]);let i=r[0];if("string"!=typeof(r=r[1]))continue;r=r.trim();let s=t[i]||[];t[i]=s,s.push(r)}var n=function(e){return e.join(", ")};for(let e in t)n.call(void 0,t[e],e,t)})(this.g),400==t&&r.indexOf("Unknown SID")>0?(this.m=3,eE(12)):(this.m=0,eE(13)),eq(this),ej(this)}}}catch(e){}finally{}},eR.prototype.cancel=function(){this.K=!0,eq(this)},eR.prototype.aa=function(){var e,t;this.D=null;let r=Date.now();r-this.T>=0?(e=this.i,t=this.B,e.info(function(){return"TIMEOUT: "+t}),2!=this.M&&(eI(),eE(17)),eq(this),this.m=2,ej(this)):eU(this,this.T-r)};var eK=class{constructor(e,t){this.g=e,this.map=t}};function e$(e){this.l=e||10,e=p.PerformanceNavigationTiming?(e=p.performance.getEntriesByType("navigation")).length>0&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):!!(p.chrome&&p.chrome.loadTimes&&p.chrome.loadTimes()&&p.chrome.loadTimes().wasFetchedViaSpdy),this.j=e?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function eG(e){return!!e.h||!!e.g&&e.g.size>=e.j}function eH(e){return e.h?1:e.g?e.g.size:0}function eW(e,t){return e.h?e.h==t:!!e.g&&e.g.has(t)}function eQ(e,t){e.g?e.g.add(t):e.h=t}function eJ(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function eY(e){if(null!=e.h)return e.i.concat(e.h.G);if(null!=e.g&&0!==e.g.size){let t=e.i;for(let r of e.g.values())t=t.concat(r.G);return t}return b(e.i)}e$.prototype.cancel=function(){if(this.i=eY(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(let e of this.g.values())e.cancel();this.g.clear()}};var eX=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function eZ(e){let t;this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1,e instanceof eZ?(this.l=e.l,e1(this,e.j),this.o=e.o,this.g=e.g,e2(this,e.u),this.h=e.h,e5(this,th(e.i)),this.m=e.m):e&&(t=String(e).match(eX))?(this.l=!1,e1(this,t[1]||"",!0),this.o=e8(t[2]||""),this.g=e8(t[3]||"",!0),e2(this,t[4]),this.h=e8(t[5]||"",!0),e5(this,t[6]||"",!0),this.m=e8(t[7]||"")):(this.l=!1,this.i=new ti(null,this.l))}function e0(e){return new eZ(e)}function e1(e,t,r){e.j=r?e8(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function e2(e,t){if(t){if(isNaN(t=Number(t))||t<0)throw Error("Bad port number "+t);e.u=t}else e.u=null}function e5(e,t,r){var n,i;t instanceof ti?(e.i=t,n=e.i,(i=e.l)&&!n.j&&(ts(n),n.i=null,n.g.forEach(function(e,t){let r=t.toLowerCase();t!=r&&(ta(this,t),tu(this,r,e))},n)),n.j=i):(r||(t=e4(t,tr)),e.i=new ti(t,e.l))}function e6(e,t,r){e.i.set(t,r)}function e3(e){return e6(e,"zx",Math.floor(0x80000000*Math.random()).toString(36)+Math.abs(Math.floor(0x80000000*Math.random())^Date.now()).toString(36)),e}function e8(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function e4(e,t,r){return"string"==typeof e?(e=encodeURI(e).replace(t,e9),r&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function e9(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}eZ.prototype.toString=function(){let e=[];var t=this.j;t&&e.push(e4(t,e7,!0),":");var r=this.g;return(r||"file"==t)&&(e.push("//"),(t=this.o)&&e.push(e4(t,e7,!0),"@"),e.push(eN(r).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(r=this.u)&&e.push(":",String(r))),(r=this.h)&&(this.g&&"/"!=r.charAt(0)&&e.push("/"),e.push(e4(r,"/"==r.charAt(0)?tt:te,!0))),(r=this.i.toString())&&e.push("?",r),(r=this.m)&&e.push("#",e4(r,tn)),e.join("")},eZ.prototype.resolve=function(e){let t=e0(this),r=!!e.j;r?e1(t,e.j):r=!!e.o,r?t.o=e.o:r=!!e.g,r?t.g=e.g:r=null!=e.u;var n=e.h;if(r)e2(t,e.u);else if(r=!!e.h){if("/"!=n.charAt(0))if(this.g&&!this.h)n="/"+n;else{var i=t.h.lastIndexOf("/");-1!=i&&(n=t.h.slice(0,i+1)+n)}if(".."==(i=n)||"."==i)n="";else if(-1!=i.indexOf("./")||-1!=i.indexOf("/.")){n=0==i.lastIndexOf("/",0),i=i.split("/");let e=[];for(let t=0;t<i.length;){let r=i[t++];"."==r?n&&t==i.length&&e.push(""):".."==r?((e.length>1||1==e.length&&""!=e[0])&&e.pop(),n&&t==i.length&&e.push("")):(e.push(r),n=!0)}n=e.join("/")}else n=i}return r?t.h=n:r=""!==e.i.toString(),r?e5(t,th(e.i)):r=!!e.m,r&&(t.m=e.m),t};var e7=/[#\/\?@]/g,te=/[#\?:]/g,tt=/[#\?]/g,tr=/[#\?@]/g,tn=/#/g;function ti(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function ts(e){e.g||(e.g=new Map,e.h=0,e.i&&function(e,t){if(e){e=e.split("&");for(let r=0;r<e.length;r++){let n=e[r].indexOf("="),i,s=null;n>=0?(i=e[r].substring(0,n),s=e[r].substring(n+1)):i=e[r],t(i,s?decodeURIComponent(s.replace(/\+/g," ")):"")}}}(e.i,function(t,r){e.add(decodeURIComponent(t.replace(/\+/g," ")),r)}))}
2function ta(e,t){ts(e),t=tc(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function to(e,t){return ts(e),t=tc(e,t),e.g.has(t)}function tl(e,t){ts(e);let r=[];if("string"==typeof t)to(e,t)&&(r=r.concat(e.g.get(tc(e,t))));else for(e=Array.from(e.g.values()),t=0;t<e.length;t++)r=r.concat(e[t]);return r}function tu(e,t,r){ta(e,t),r.length>0&&(e.i=null,e.g.set(tc(e,t),b(r)),e.h+=r.length)}function th(e){let t=new ti;return t.i=e.i,e.g&&(t.g=new Map(e.g),t.h=e.h),t}function tc(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function td(e,t,r,n,i){try{i&&(i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null),n(r)}catch(e){}}function tf(){this.g=new eh}function tp(e){this.i=e.Sb||null,this.h=e.ab||!1}function tg(e,t){et.call(this),this.H=e,this.o=t,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.A=new Headers,this.h=null,this.F="GET",this.D="",this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}function tm(e){e.j.read().then(e.Ma.bind(e)).catch(e.ga.bind(e))}function ty(e){e.readyState=4,e.l=null,e.j=null,e.B=null,tw(e)}function tw(e){e.onreadystatechange&&e.onreadystatechange.call(e)}function tv(e){let t="";return U(e,function(e,r){t+=r,t+=":",t+=e,t+="\r\n"}),t}function tI(e,t,r){e:{for(n in r){var n=!1;break e}n=!0}n||(r=tv(r),"string"==typeof e?null!=r&&eN(r):e6(e,t,r))}function tb(e){et.call(this),this.headers=new Map,this.L=e||null,this.h=!1,this.g=null,this.D="",this.o=0,this.l="",this.j=this.B=this.v=this.A=!1,this.m=null,this.F="",this.H=!1}(t=ti.prototype).add=function(e,t){ts(this),this.i=null,e=tc(this,e);let r=this.g.get(e);return r||this.g.set(e,r=[]),r.push(t),this.h+=1,this},t.forEach=function(e,t){ts(this),this.g.forEach(function(r,n){r.forEach(function(r){e.call(t,r,n,this)},this)},this)},t.set=function(e,t){return ts(this),this.i=null,to(this,e=tc(this,e))&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},t.get=function(e,t){return e&&(e=tl(this,e)).length>0?String(e[0]):t},t.toString=function(){if(this.i)return this.i;if(!this.g)return"";let e=[],t=Array.from(this.g.keys());for(let n=0;n<t.length;n++){var r=t[n];let i=eN(r);r=tl(this,r);for(let t=0;t<r.length;t++){let n=i;""!==r[t]&&(n+="="+eN(r[t])),e.push(n)}}return this.i=e.join("&")},v(tp,ec),tp.prototype.g=function(){return new tg(this.i,this.h)},v(tg,et),(t=tg.prototype).open=function(e,t){if(0!=this.readyState)throw this.abort(),Error("Error reopening a connection");this.F=e,this.D=t,this.readyState=1,tw(this)},t.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");if(this.v.signal.aborted)throw this.abort(),Error("Request was aborted.");this.g=!0;let t={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};e&&(t.body=e),(this.H||p).fetch(new Request(this.D,t)).then(this.Pa.bind(this),this.ga.bind(this))},t.abort=function(){this.response=this.responseText="",this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),this.readyState>=1&&this.g&&4!=this.readyState&&(this.g=!1,ty(this)),this.readyState=0},t.Pa=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,tw(this)),this.g&&(this.readyState=3,tw(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(void 0!==p.ReadableStream&&"body"in e){if(this.j=e.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.B=new TextDecoder;tm(this)}else e.text().then(this.Oa.bind(this),this.ga.bind(this))},t.Ma=function(e){if(this.g){if(this.o&&e.value)this.response.push(e.value);else if(!this.o){var t=e.value?e.value:new Uint8Array(0);(t=this.B.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?ty(this):tw(this),3==this.readyState&&tm(this)}},t.Oa=function(e){this.g&&(this.response=this.responseText=e,ty(this))},t.Na=function(e){this.g&&(this.response=e,ty(this))},t.ga=function(){this.g&&ty(this)},t.setRequestHeader=function(e,t){this.A.append(e,t)},t.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||""},t.getAllResponseHeaders=function(){if(!this.h)return"";let e=[],t=this.h.entries();for(var r=t.next();!r.done;)e.push((r=r.value)[0]+": "+r[1]),r=t.next();return e.join("\r\n")},Object.defineProperty(tg.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}}),v(tb,et);var tE=/^https?$/i,tT=["POST","PUT"];function t_(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.o=5,tS(e),tk(e)}function tS(e){e.A||(e.A=!0,er(e,"complete"),er(e,"error"))}function tC(e){if(e.h&&void 0!==f){if(e.v&&4==tA(e))setTimeout(e.Ca.bind(e),0);else if(er(e,"readystatechange"),4==tA(e)){e.h=!1;try{let s=e.ca();switch(s){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var t,r,n=!0;break;default:n=!1}if(!(t=n)){if(r=0===s){let t=String(e.D).match(eX)[1]||null;!t&&p.self&&p.self.location&&(t=p.self.location.protocol.slice(0,-1)),r=!tE.test(t?t.toLowerCase():"")}t=r}if(t)er(e,"complete"),er(e,"success");else{e.o=6;try{var i=tA(e)>2?e.g.statusText:""}catch(e){i=""}e.l=i+" ["+e.ca()+"]",tS(e)}}finally{tk(e)}}}}function tk(e,t){if(e.g){e.m&&(clearTimeout(e.m),e.m=null);let r=e.g;e.g=null,t||er(e,"ready");try{r.onreadystatechange=null}catch(e){}}}function tA(e){return e.g?e.g.readyState:0}function tx(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.F){case"":case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}
2function tN(e,t,r){return r&&r.internalChannelParams&&r.internalChannelParams[e]||t}function tR(e){this.za=0,this.i=[],this.j=new eS,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=tN("failFast",!1,e),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=tN("baseRetryDelayMs",5e3,e),this.Za=tN("retryDelaySeedMs",1e4,e),this.Ta=tN("forwardChannelMaxRetries",2,e),this.va=tN("forwardChannelRequestTimeoutMs",2e4,e),this.ma=e&&e.xmlHttpFactory||void 0,this.Ua=e&&e.Rb||void 0,this.Aa=e&&e.useFetchStreams||!1,this.O=void 0,this.L=e&&e.supportsCrossDomainXhr||!1,this.M="",this.h=new e$(e&&e.concurrentRequestLimit),this.Ba=new tf,this.S=e&&e.fastHandshake||!1,this.R=e&&e.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=e&&e.Pb||!1,e&&e.ua&&this.j.ua(),e&&e.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&e&&e.detectBufferingProxy||!1,this.ia=void 0,e&&e.longPollingTimeout&&e.longPollingTimeout>0&&(this.ia=e.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}function tD(e){if(tO(e),3==e.I){var t=e.V++,r=e0(e.J);if(e6(r,"SID",e.M),e6(r,"RID",t),e6(r,"TYPE","terminate"),tV(e,r),(t=new eR(e,e.j,t)).M=2,t.A=e3(e0(r)),r=!1,p.navigator&&p.navigator.sendBeacon)try{r=p.navigator.sendBeacon(t.A.toString(),"")}catch(e){}!r&&p.Image&&((new Image).src=t.A,r=!0),r||(t.g=tQ(t.j,null),t.g.ea(t.A)),t.F=Date.now(),eF(t)}tH(e)}function tP(e){e.g&&(tj(e),e.g.cancel(),e.g=null)}function tO(e){tP(e),e.v&&(p.clearTimeout(e.v),e.v=null),tz(e),e.h.cancel(),e.m&&("number"==typeof e.m&&p.clearTimeout(e.m),e.m=null)}function tL(e){if(!eG(e.h)&&!e.m){e.m=!0;var t=e.Ea;S||A(),C||(S(),C=!0),k.add(t,e),e.D=0}}function tM(e,t){var r;r=t?t.l:e.V++;let n=e0(e.J);e6(n,"SID",e.M),e6(n,"RID",r),e6(n,"AID",e.K),tV(e,n),e.u&&e.o&&tI(n,e.u,e.o),r=new eR(e,e.j,r,e.D+1),null===e.u&&(r.J=e.o),t&&(e.i=t.G.concat(e.i)),t=tF(e,r,1e3),r.H=Math.round(.5*e.va)+Math.round(.5*e.va*Math.random()),eQ(e.h,r),eL(r,n,t)}function tV(e,t){e.H&&U(e.H,function(e,r){e6(t,r,e)}),e.l&&U({},function(e,r){e6(t,r,e)})}function tF(e,t,r){r=Math.min(e.i.length,r);let n=e.l?y(e.l.Ka,e.l,e):null;e:{var i=e.i;let t=-1;for(;;){let e=["count="+r];-1==t?r>0?(t=i[0].g,e.push("ofs="+t)):t=0:e.push("ofs="+t);let o=!0;for(let l=0;l<r;l++){var s=i[l].g;let r=i[l].map;if((s-=t)<0)t=Math.max(0,i[l].g-100),o=!1;else try{s="req"+s+"_";try{var a=r instanceof Map?r:Object.entries(r);for(let[t,r]of a){let n=r;g(r)&&(n=el(r)),e.push(s+t+"="+encodeURIComponent(n))}}catch(t){throw e.push(s+"type="+encodeURIComponent("_badmap")),t}}catch(e){n&&n(r)}}if(o){a=e.join("&");break e}}a=void 0}return t.G=e=e.i.splice(0,r),a}function tU(e){if(!e.g&&!e.v){e.Y=1;var t=e.Da;S||A(),C||(S(),C=!0),k.add(t,e),e.A=0}}function tB(e){return!e.g&&!e.v&&!(e.A>=3)&&(e.Y++,e.v=e_(y(e.Da,e),t$(e,e.A)),e.A++,!0)}function tj(e){null!=e.B&&(p.clearTimeout(e.B),e.B=null)}function tq(e){e.g=new eR(e,e.j,"rpc",e.Y),null===e.u&&(e.g.J=e.o),e.g.P=0;var t=e0(e.na);e6(t,"RID","rpc"),e6(t,"SID",e.M),e6(t,"AID",e.K),e6(t,"CI",e.F?"0":"1"),!e.F&&e.ia&&e6(t,"TO",e.ia),e6(t,"TYPE","xmlhttp"),tV(e,t),e.u&&e.o&&tI(t,e.u,e.o),e.O&&(e.g.H=e.O);var r=e.g;e=e.ba,r.M=1,r.A=e3(e0(t)),r.u=null,r.R=!0,eM(r,e)}function tz(e){null!=e.C&&(p.clearTimeout(e.C),e.C=null)}function tK(e,t){var r,n=null;if(e.g==t){tz(e),tj(e),e.g=null;var i=2}else{if(!eW(e.h,t))return;n=t.G,eJ(e.h,t),i=1}if(0!=e.I){if(t.o)if(1==i){n=t.u?t.u.length:0,t=Date.now()-t.F;var s=e.D;er(i=ew(),new eT(i,n)),tL(e)}else tU(e);else if(3==(s=t.m)||0==s&&t.X>0||!(1==i&&(r=t,!(eH(e.h)>=e.h.j-!!e.m)&&(e.m?(e.i=r.G.concat(e.i),!0):1!=e.I&&2!=e.I&&!(e.D>=(e.Sa?0:e.Ta))&&(e.m=e_(y(e.Ea,e,r),t$(e,e.D)),e.D++,!0)))||2==i&&tB(e)))switch(n&&n.length>0&&((t=e.h).i=t.i.concat(n)),s){case 1:tG(e,5);break;case 4:tG(e,10);break;case 3:tG(e,6);break;default:tG(e,2)}}}function t$(e,t){let r=e.Qa+Math.floor(Math.random()*e.Za);return e.isActive()||(r*=2),r*t}function tG(e,t){if(e.j.info("Error code "+t),2==t){let t,s,a;var r,n=y(e.bb,e),i=e.Ua;let o=!i;i=new eZ(i||"//www.google.com/images/cleardot.gif"),p.location&&"http"==p.location.protocol||e1(i,"https"),e3(i),o?function(e,t){let r=new eS;if(p.Image){let n=new Image;n.onload=w(td,r,"TestLoadImage: loaded",!0,t,n),n.onerror=w(td,r,"TestLoadImage: error",!1,t,n),n.onabort=w(td,r,"TestLoadImage: abort",!1,t,n),n.ontimeout=w(td,r,"TestLoadImage: timeout",!1,t,n),p.setTimeout(function(){n.ontimeout&&n.ontimeout()},1e4),n.src=e}else t(!1)}(i.toString(),n):(r=i.toString(),t=new eS,s=new AbortController,a=setTimeout(()=>{s.abort(),td(t,"TestPingServer: timeout",!1,n)},1e4),fetch(r,{signal:s.signal}).then(e=>{clearTimeout(a),e.ok?td(t,"TestPingServer: ok",!0,n):td(t,"TestPingServer: server error",!1,n)}).catch(()=>{clearTimeout(a),td(t,"TestPingServer: error",!1,n)}))}else eE(2);e.I=0,e.l&&e.l.pa(t),tH(e),tO(e)}function tH(e){if(e.I=0,e.ja=[],e.l){let t=eY(e.h);(0!=t.length||0!=e.i.length)&&(E(e.ja,t),E(e.ja,e.i),e.h.i.length=0,b(e.i),e.i.length=0),e.l.oa()}}function tW(e,t,r){var n=r instanceof eZ?e0(r):new eZ(r);if(""!=n.g)t&&(n.g=t+"."+n.g),e2(n,n.u);else{var i=p.location;n=i.protocol,t=t?t+"."+i.hostname:i.hostname,i=+i.port;let e=new eZ(null);n&&e1(e,n),t&&(e.g=t),i&&e2(e,i),r&&(e.h=r),n=e}return r=e.G,t=e.wa,r&&t&&e6(n,r,t),e6(n,"VER",e.ka),tV(e,n),n}function tQ(e,t,r){if(t&&!e.L)throw Error("Can't create secondary domain capable XhrIo object.");return(t=new tb(e.Aa&&!e.ma?new tp({ab:r}):e.ma)).Fa(e.L),t}function tJ(){}function tY(){}function tX(e,t){et.call(this),this.g=new tR(t),this.l=e,this.h=t&&t.messageUrlParams||null,e=t&&t.messageHeaders||null,t&&t.clientProtocolHeaderRequired&&(e?e["X-Client-Protocol"]="webchannel":e={"X-Client-Protocol":"webchannel"}),this.g.o=e,e=t&&t.initMessageHeaders||null,t&&t.messageContentType&&(e?e["X-WebChannel-Content-Type"]=t.messageContentType:e={"X-WebChannel-Content-Type":t.messageContentType}),t&&t.sa&&(e?e["X-WebChannel-Client-Profile"]=t.sa:e={"X-WebChannel-Client-Profile":t.sa}),this.g.U=e,(e=t&&t.Qb)&&!P(e)&&(this.g.u=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!P(t)&&(this.g.G=t,null!==(e=this.h)&&t in e&&t in(e=this.h)&&delete e[t]),this.j=new t1(this)}function tZ(e){ep.call(this),e.__headers__&&(this.headers=e.__headers__,this.statusCode=e.__status__,delete e.__headers__,delete e.__status__);var t=e.__sm__;if(t){e:{for(let r in t){e=r;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 t0(){eg.call(this),this.status=1}function t1(e){this.g=e}(t=tb.prototype).Fa=function(e){this.H=e},t.ea=function(t,r,n,i){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+t);r=r?r.toUpperCase():"GET",this.D=t,this.l="",this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():e.g(),this.g.onreadystatechange=I(y(this.Ca,this));try{this.B=!0,this.g.open(r,String(t),!0),this.B=!1}catch(e){t_(this,e);return}if(t=n||"",n=new Map(this.headers),i)if(Object.getPrototypeOf(i)===Object.prototype)for(var s in i)n.set(s,i[s]);else if("function"==typeof i.keys&&"function"==typeof i.get)for(let e of i.keys())n.set(e,i.get(e));else throw Error("Unknown input type for opt_headers: "+String(i));for(let[e,a]of(i=Array.from(n.keys()).find(e=>"content-type"==e.toLowerCase()),s=p.FormData&&t instanceof p.FormData,!(Array.prototype.indexOf.call(tT,r,void 0)>=0)||i||s||n.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),n))this.g.setRequestHeader(e,a);this.F&&(this.g.responseType=this.F),"withCredentials"in this.g&&this.g.withCredentials!==this.H&&(this.g.withCredentials=this.H);try{this.m&&(clearTimeout(this.m),this.m=null),this.v=!0,this.g.send(t),this.v=!1}catch(e){t_(this,e)}},t.abort=function(e){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=e||7,er(this,"complete"),er(this,"abort"),tk(this))},t.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),tk(this,!0)),tb.Z.N.call(this)},t.Ca=function(){this.u||(this.B||this.v||this.j?tC(this):this.Xa())},t.Xa=function(){tC(this)},t.isActive=function(){return!!this.g},t.ca=function(){try{return tA(this)>2?this.g.status:-1}catch(e){return -1}},t.la=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},t.La=function(e){if(this.g){var t=this.g.responseText;
2return e&&0==t.indexOf(e)&&(t=t.substring(e.length)),eu(t)}},t.ya=function(){return this.o},t.Ha=function(){return"string"==typeof this.l?this.l:String(this.l)},(t=tR.prototype).ka=8,t.I=1,t.connect=function(e,t,r,n){eE(0),this.W=e,this.H=t||{},r&&void 0!==n&&(this.H.OSID=r,this.H.OAID=n),this.F=this.X,this.J=tW(this,null,this.W),tL(this)},t.Ea=function(e){if(this.m)if(this.m=null,1==this.I){if(!e){this.V=Math.floor(1e5*Math.random()),e=this.V++;let i=new eR(this,this.j,e),s=this.o;if(this.U&&(s?q(s=B(s),this.U):s=this.U),null!==this.u||this.R||(i.J=s,s=null),this.S)e:{for(var t=0,r=0;r<this.i.length;r++){t:{var n=this.i[r];if("__data__"in n.map&&"string"==typeof(n=n.map.__data__)){n=n.length;break t}n=void 0}if(void 0===n)break;if((t+=n)>4096){t=r;break e}if(4096===t||r===this.i.length-1){t=r+1;break e}}t=1e3}else t=1e3;t=tF(this,i,t),e6(r=e0(this.J),"RID",e),e6(r,"CVER",22),this.G&&e6(r,"X-HTTP-Session-Id",this.G),tV(this,r),s&&(this.R?t="headers="+eN(tv(s))+"&"+t:this.u&&tI(r,this.u,s)),eQ(this.h,i),this.Ra&&e6(r,"TYPE","init"),this.S?(e6(r,"$req",t),e6(r,"SID","null"),i.U=!0,eL(i,r,null)):eL(i,r,t),this.I=2}}else 3==this.I&&(e?tM(this,e):0==this.i.length||eG(this.h)||tM(this))},t.Da=function(){if(this.v=null,tq(this),this.aa&&!(this.P||null==this.g||this.T<=0)){var e=4*this.T;this.j.info("BP detection timer enabled: "+e),this.B=e_(y(this.Wa,this),e)}},t.Wa=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.P=!0,eE(10),tP(this),tq(this))},t.Va=function(){null!=this.C&&(this.C=null,tP(this),tB(this),eE(19))},t.bb=function(e){e?(this.j.info("Successfully pinged google.com"),eE(2)):(this.j.info("Failed to ping google.com"),eE(1))},t.isActive=function(){return!!this.l&&this.l.isActive(this)},(t=tJ.prototype).ra=function(){},t.qa=function(){},t.pa=function(){},t.oa=function(){},t.isActive=function(){return!0},t.Ka=function(){},tY.prototype.g=function(e,t){return new tX(e,t)},v(tX,et),tX.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},tX.prototype.close=function(){tD(this.g)},tX.prototype.o=function(e){var t=this.g;if("string"==typeof e){var r={};r.__data__=e,e=r}else this.v&&((r={}).__data__=el(e),e=r);t.i.push(new eK(t.Ya++,e)),3==t.I&&tL(t)},tX.prototype.N=function(){this.g.l=null,delete this.j,tD(this.g),delete this.g,tX.Z.N.call(this)},v(tZ,ep),v(t0,eg),v(t1,tJ),t1.prototype.ra=function(){er(this.g,"a")},t1.prototype.qa=function(e){er(this.g,new tZ(e))},t1.prototype.pa=function(e){er(this.g,new t0)},t1.prototype.oa=function(){er(this.g,"b")},tY.prototype.createWebChannel=tY.prototype.g,tX.prototype.send=tX.prototype.o,tX.prototype.open=tX.prototype.m,tX.prototype.close=tX.prototype.close,c=rq.createWebChannelTransport=function(){return new tY},h=rq.getStatEventTarget=function(){return ew()},u=rq.Event=em,l=rq.Stat={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},ek.NO_ERROR=0,ek.TIMEOUT=8,ek.HTTP_ERROR=6,o=rq.ErrorCode=ek,eA.COMPLETE="complete",a=rq.EventType=eA,ed.EventType=ef,ef.OPEN="a",ef.CLOSE="b",ef.ERROR="c",ef.MESSAGE="d",et.prototype.listen=et.prototype.J,s=rq.WebChannel=ed,rq.FetchXmlHttpFactory=tp,tb.prototype.listenOnce=tb.prototype.K,tb.prototype.getLastError=tb.prototype.Ha,tb.prototype.getLastErrorCode=tb.prototype.ya,tb.prototype.getStatus=tb.prototype.ca,tb.prototype.getResponseJson=tb.prototype.La,tb.prototype.getResponseText=tb.prototype.la,tb.prototype.send=tb.prototype.ea,tb.prototype.setWithCredentials=tb.prototype.Fa,i=rq.XhrIo=tb}).apply(void 0!==rj?rj:"u">typeof self?self:"u">typeof window?window:{});class rz{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}}rz.UNAUTHENTICATED=new rz(null),rz.GOOGLE_CREDENTIALS=new rz("google-credentials-uid"),rz.FIRST_PARTY=new rz("first-party-uid"),rz.MOCK_USER=new rz("mock-user");let rK="12.12.0";function r$(e){rK=e}let rG=new v.Logger("@firebase/firestore");function rH(){return rG.logLevel}function rW(e,...t){if(rG.logLevel<=v.LogLevel.DEBUG){let r=t.map(rY);rG.debug(`Firestore (${rK}): ${e}`,...r)}}function rQ(e,...t){if(rG.logLevel<=v.LogLevel.ERROR){let r=t.map(rY);rG.error(`Firestore (${rK}): ${e}`,...r)}}function rJ(e,...t){if(rG.logLevel<=v.LogLevel.WARN){let r=t.map(rY);rG.warn(`Firestore (${rK}): ${e}`,...r)}}function rY(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){return e}}function rX(e,t,r){let n="Unexpected state";"string"==typeof t?n=t:r=t,rZ(e,n,r)}function rZ(e,t,r){let n=`FIRESTORE (${rK}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(void 0!==r)try{n+=" CONTEXT: "+JSON.stringify(r)}catch(e){n+=" CONTEXT: "+r}throw rQ(n),Error(n)}function r0(e,t,r,n){let i="Unexpected state";"string"==typeof r?i=r:n=r,e||rZ(t,i,n)}let r1={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENT
2ED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class r2 extends rF.FirebaseError{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class r5{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class r6{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class r3{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(rz.UNAUTHENTICATED))}shutdown(){}}class r8{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 r4{constructor(e){this.t=e,this.currentUser=rz.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){r0(void 0===this.o,42304);let r=this.i,n=e=>this.i!==r?(r=this.i,t(e)):Promise.resolve(),i=new r5;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new r5,e.enqueueRetryable(()=>n(this.currentUser))};let s=()=>{let t=i;e.enqueueRetryable(async()=>{await t.promise,await n(this.currentUser)})},a=e=>{rW("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.o&&(this.auth.addAuthTokenListener(this.o),s())};this.t.onInit(e=>a(e)),setTimeout(()=>{if(!this.auth){let e=this.t.getImmediate({optional:!0});e?a(e):(rW("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new r5)}},0),s()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(t=>this.i!==e?(rW("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(r0("string"==typeof t.accessToken,31837,{l:t}),new r6(t.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){let e=this.auth&&this.auth.getUid();return r0(null===e||"string"==typeof e,2055,{h:e}),new rz(e)}}class r9{constructor(e,t,r){this.P=e,this.T=t,this.I=r,this.type="FirstParty",this.user=rz.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set("X-Goog-AuthUser",this.P);let e=this.A();return e&&this.R.set("Authorization",e),this.T&&this.R.set("X-Goog-Iam-Authorization-Token",this.T),this.R}}class r7{constructor(e,t,r){this.P=e,this.T=t,this.I=r}getToken(){return Promise.resolve(new r9(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable(()=>t(rz.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class ne{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class nt{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,(0,y._isFirebaseServerApp)(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){r0(void 0===this.o,3512);let r=e=>{null!=e.error&&rW("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);let r=e.token!==this.m;return this.m=e.token,rW("FirebaseAppCheckTokenProvider",`Received ${r?"new":"existing"} token.`),r?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable(()=>r(t))};let n=e=>{rW("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(e=>n(e)),setTimeout(()=>{if(!this.appCheck){let e=this.V.getImmediate({optional:!0});e?n(e):rW("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new ne(this.p));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(r0("string"==typeof e.token,44558,{tokenResult:e}),this.m=e.token,new ne(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}class nr{static newId(){let e=62*Math.floor(256/62),t="";for(;t.length<20;){let r=function(){let e="u">typeof self&&(self.crypto||self.msCrypto),t=new Uint8Array(40);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(t);else for(let e=0;e<40;
2e++)t[e]=Math.floor(256*Math.random());return t}();for(let n=0;n<r.length;++n)t.length<20&&r[n]<e&&(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(r[n]%62))}return t}}function nn(e,t){return e<t?-1:+(e>t)}function ni(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++){let r=e.charAt(n),i=t.charAt(n);if(r!==i)return ns(r)===ns(i)?nn(r,i):ns(r)?1:-1}return nn(e.length,t.length)}function ns(e){let t=e.charCodeAt(0);return t>=55296&&t<=57343}function na(e,t,r){return e.length===t.length&&e.every((e,n)=>r(e,t[n]))}let no="__name__";class nl{constructor(e,t,r){void 0===t?t=0:t>e.length&&rX(637,{offset:t,range:e.length}),void 0===r?r=e.length-t:r>e.length-t&&rX(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return 0===nl.comparator(this,e)}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof nl?e.forEach(e=>{t.push(e)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return 0===this.length}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++){let r=nl.compareSegments(e.get(n),t.get(n));if(0!==r)return r}return nn(e.length,t.length)}static compareSegments(e,t){let r=nl.isNumericId(e),n=nl.isNumericId(t);return r&&!n?-1:!r&&n?1:r&&n?nl.extractNumericId(e).compare(nl.extractNumericId(t)):ni(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return r.fromString(e.substring(4,e.length-2))}}class nu extends nl{construct(e,t,r){return new nu(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){let t=[];for(let r of e){if(r.indexOf("//")>=0)throw new r2(r1.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter(e=>e.length>0))}return new nu(t)}static emptyPath(){return new nu([])}}let nh=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class nc extends nl{construct(e,t,r){return new nc(e,t,r)}static isValidIdentifier(e){return nh.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),nc.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===no}static keyField(){return new nc([no])}static fromServerFormat(e){let t=[],r="",n=0,i=()=>{if(0===r.length)throw new r2(r1.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""},s=!1;for(;n<e.length;){let t=e[n];if("\\"===t){if(n+1===e.length)throw new r2(r1.INVALID_ARGUMENT,"Path has trailing escape character: "+e);let t=e[n+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new r2(r1.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=t,n+=2}else"`"===t?s=!s:"."!==t||s?r+=t:i(),n++}if(i(),s)throw new r2(r1.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new nc(t)}static emptyPath(){return new nc([])}}class nd{constructor(e){this.path=e}static fromPath(e){return new nd(nu.fromString(e))}static fromName(e){return new nd(nu.fromString(e).popFirst(5))}static empty(){return new nd(nu.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return null!==e&&0===nu.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return nu.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new nd(new nu(e.slice()))}}function nf(e){if(!nd.isDocumentKey(e))throw new r2(r1.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function np(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function ng(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==typeof e){if(e instanceof Array)return"an array";{var t;let r=(t=e).constructor?t.constructor.name:null;return r?`a custom ${r} object`:"an object"}}return"function"==typeof e?"a function":rX(12329,{type:typeof e})}function nm(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new r2(r1.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{let r=ng(e);throw new r2(r1.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${r}`)}}return e}function ny(e,t){let r={typeString:e};return t&&(r.value=t),r}function nw(e,t){let r;if(!np(e))throw new r2(r1.INVALID_ARGUMENT,"JSON must be an object");for(let n in t)if(t[n]){let i=t[n].typeString,s="value"in t[n]?{value:t[n].value}:void 0;if(!(n in e)){r=`JSON missing required field: '${n}'`;break}let a=e[n];if(i&&typeof a!==i){r=`JSON field '${n}' must be a ${i}.`;break}if(void 0!==s&&a!==s.value){r=`Expected '${n}' field to equal '${s.value}'`;break}}if(r)throw new r2(r1.INVALID_ARGUMENT,r);return!0}class nv{static now(){return nv.fromMillis(Date.now())}static fromDate(e){return nv.fromMillis(e.getTime())}static fromMillis(e){let t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*1e6);return new nv(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0||t>=1e9)throw new r2(r1.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-0xe7791f700||e>=0x3afff44180)throw new r2(r1.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?nn(this.nanoseconds,e.nanoseconds):nn(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:nv._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(nw(e,nv._jsonSchema))return new nv(e.seconds,e.nanoseconds)}valueOf(){return String(this.seconds- -0xe7791f700).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}
2}nv._jsonSchemaVersion="firestore/timestamp/1.0",nv._jsonSchema={type:ny("string",nv._jsonSchemaVersion),seconds:ny("number"),nanoseconds:ny("number")};class nI{static fromTimestamp(e){return new nI(e)}static min(){return new nI(new nv(0,0))}static max(){return new nI(new nv(0x3afff4417f,0x3b9ac9ff))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}class nb{constructor(e,t,r,n){this.indexId=e,this.collectionGroup=t,this.fields=r,this.indexState=n}}function nE(e){return e.fields.find(e=>2===e.kind)}function nT(e){return e.fields.filter(e=>2!==e.kind)}function n_(e,t){let r=nn(e.collectionGroup,t.collectionGroup);if(0!==r)return r;for(let n=0;n<Math.min(e.fields.length,t.fields.length);++n)if(0!==(r=function(e,t){let r=nc.comparator(e.fieldPath,t.fieldPath);return 0!==r?r:nn(e.kind,t.kind)}(e.fields[n],t.fields[n])))return r;return nn(e.fields.length,t.fields.length)}nb.UNKNOWN_ID=-1;class nS{constructor(e,t){this.fieldPath=e,this.kind=t}}class nC{constructor(e,t){this.sequenceNumber=e,this.offset=t}static empty(){return new nC(0,nx.min())}}function nk(e,t){let r=e.toTimestamp().seconds,n=e.toTimestamp().nanoseconds+1;return new nx(nI.fromTimestamp(1e9===n?new nv(r+1,0):new nv(r,n)),nd.empty(),t)}function nA(e){return new nx(e.readTime,e.key,-1)}class nx{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new nx(nI.min(),nd.empty(),-1)}static max(){return new nx(nI.max(),nd.empty(),-1)}}function nN(e,t){let r=e.readTime.compareTo(t.readTime);return 0!==r||0!==(r=nd.comparator(e.documentKey,t.documentKey))?r:nn(e.largestBatchId,t.largestBatchId)}let nR="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class nD{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}async function nP(e){if(e.code!==r1.FAILED_PRECONDITION||e.message!==nR)throw e;rW("LocalStore","Unexpectedly lost primary lease")}class nO{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)},e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&rX(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new nO((r,n)=>{this.nextCallback=t=>{this.wrapSuccess(e,t).next(r,n)},this.catchCallback=e=>{this.wrapFailure(t,e).next(r,n)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{let t=e();return t instanceof nO?t:nO.resolve(t)}catch(e){return nO.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):nO.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):nO.reject(t)}static resolve(e){return new nO((t,r)=>{t(e)})}static reject(e){return new nO((t,r)=>{r(e)})}static waitFor(e){return new nO((t,r)=>{let n=0,i=0,s=!1;e.forEach(e=>{++n,e.next(()=>{++i,s&&i===n&&t()},e=>r(e))}),s=!0,i===n&&t()})}static or(e){let t=nO.resolve(!1);for(let r of e)t=t.next(e=>e?nO.resolve(e):r());return t}static forEach(e,t){let r=[];return e.forEach((e,n)=>{r.push(t.call(this,e,n))}),this.waitFor(r)}static mapArray(e,t){return new nO((r,n)=>{let i=e.length,s=Array(i),a=0;for(let o=0;o<i;o++){let l=o;t(e[l]).next(e=>{s[l]=e,++a===i&&r(s)},e=>n(e))}})}static doWhile(e,t){return new nO((r,n)=>{let i=()=>{!0===e()?t().next(()=>{i()},n):r()};i()})}}let nL="SimpleDb";class nM{static open(e,t,r,n){try{return new nM(t,e.transaction(n,r))}catch(e){throw new nB(t,e)}}constructor(e,t){this.action=e,this.transaction=t,this.aborted=!1,this.S=new r5,this.transaction.oncomplete=()=>{this.S.resolve()},this.transaction.onabort=()=>{t.error?this.S.reject(new nB(e,t.error)):this.S.resolve()},this.transaction.onerror=t=>{let r=n$(t.target.error);this.S.reject(new nB(e,r))}}get D(){return this.S.promise}abort(e){e&&this.S.reject(e),this.aborted||(rW(nL,"Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}C(){let e=this.transaction;this.aborted||"function"!=typeof e.commit||e.commit()}store(e){return new nq(this.transaction.objectStore(e))}}class nV{static delete(e){return rW(nL,"Removing database:",e),nz((0,rF.getGlobal)().indexedDB.deleteDatabase(e)).toPromise()}static v(){if(!(0,rF.isIndexedDBAvailable)())return!1;if(nV.F())return!0;let e=(0,rF.getUA)(),t=nV.M(e),r=nF(e);return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||0<t&&t<10||0<r&&r<4.5)}static F(){return void 0!==rM.default&&"YES"===rM.default.__PRIVATE_env?.__PRIVATE_USE_MOCK_PERSISTENCE}static O(e,t){return e.store(t)}static M(e){let t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i);return Number(t?t[1].split("_").slice(0,2).join("."):"-1")}constructor(e,t,r){this.name=e,this.version=t,this.N=r,this.B=null,12.2===nV.M((0,rF.getUA)())&&rQ("Firestore persistence suffers from a bug in 
2iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}async L(e){return this.db||(rW(nL,"Opening database:",this.name),this.db=await new Promise((t,r)=>{let n=indexedDB.open(this.name,this.version);n.onsuccess=e=>{t(e.target.result)},n.onblocked=()=>{r(new nB(e,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},n.onerror=t=>{let n=t.target.error;"VersionError"===n.name?r(new r2(r1.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"===n.name?r(new r2(r1.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: "+n)):r(new nB(e,n))},n.onupgradeneeded=e=>{rW(nL,'Database "'+this.name+'" requires upgrade from version:',e.oldVersion);let t=e.target.result;this.N.k(t,n.transaction,e.oldVersion,this.version).next(()=>{rW(nL,"Database upgrade to version "+this.version+" complete")})}})),this.q&&(this.db.onversionchange=e=>this.q(e)),this.db}K(e){this.q=e,this.db&&(this.db.onversionchange=t=>e(t))}async runTransaction(e,t,r,n){let i="readonly"===t,s=0;for(;;){++s;try{this.db=await this.L(e);let t=nM.open(this.db,e,i?"readonly":"readwrite",r),s=n(t).next(e=>(t.C(),e)).catch(e=>(t.abort(e),nO.reject(e))).toPromise();return s.catch(()=>{}),await t.D,s}catch(t){let e="FirebaseError"!==t.name&&s<3;if(rW(nL,"Transaction failed with error:",t.message,"Retrying:",e),this.close(),!e)return Promise.reject(t)}}}close(){this.db&&this.db.close(),this.db=void 0}}function nF(e){let t=e.match(/Android ([\d.]+)/i);return Number(t?t[1].split(".").slice(0,2).join("."):"-1")}class nU{constructor(e){this.U=e,this.$=!1,this.W=null}get isDone(){return this.$}get G(){return this.W}set cursor(e){this.U=e}done(){this.$=!0}j(e){this.W=e}delete(){return nz(this.U.delete())}}class nB extends r2{constructor(e,t){super(r1.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function nj(e){return"IndexedDbTransactionError"===e.name}class nq{constructor(e){this.store=e}put(e,t){let r;return void 0!==t?(rW(nL,"PUT",this.store.name,e,t),r=this.store.put(t,e)):(rW(nL,"PUT",this.store.name,"<auto-key>",e),r=this.store.put(e)),nz(r)}add(e){return rW(nL,"ADD",this.store.name,e,e),nz(this.store.add(e))}get(e){return nz(this.store.get(e)).next(t=>(void 0===t&&(t=null),rW(nL,"GET",this.store.name,e,t),t))}delete(e){return rW(nL,"DELETE",this.store.name,e),nz(this.store.delete(e))}count(){return rW(nL,"COUNT",this.store.name),nz(this.store.count())}J(e,t){let r=this.options(e,t),n=r.index?this.store.index(r.index):this.store;if("function"==typeof n.getAll){let e=n.getAll(r.range);return new nO((t,r)=>{e.onerror=e=>{r(e.target.error)},e.onsuccess=e=>{t(e.target.result)}})}{let e=this.cursor(r),t=[];return this.H(e,(e,r)=>{t.push(r)}).next(()=>t)}}Z(e,t){let r=this.store.getAll(e,null===t?void 0:t);return new nO((e,t)=>{r.onerror=e=>{t(e.target.error)},r.onsuccess=t=>{e(t.target.result)}})}X(e,t){rW(nL,"DELETE ALL",this.store.name);let r=this.options(e,t);r.Y=!1;let n=this.cursor(r);return this.H(n,(e,t,r)=>r.delete())}ee(e,t){let r;t?r=e:(r={},t=e);let n=this.cursor(r);return this.H(n,t)}te(e){let t=this.cursor({});return new nO((r,n)=>{t.onerror=e=>{n(n$(e.target.error))},t.onsuccess=t=>{let n=t.target.result;n?e(n.primaryKey,n.value).next(e=>{e?n.continue():r()}):r()}})}H(e,t){let r=[];return new nO((n,i)=>{e.onerror=e=>{i(e.target.error)},e.onsuccess=e=>{let i=e.target.result;if(!i)return void n();let s=new nU(i),a=t(i.primaryKey,i.value,s);if(a instanceof nO){let e=a.catch(e=>(s.done(),nO.reject(e)));r.push(e)}s.isDone?n():null===s.G?i.continue():i.continue(s.G)}}).next(()=>nO.waitFor(r))}options(e,t){let r;return void 0!==e&&("string"==typeof e?r=e:t=e),{index:r,range:t}}cursor(e){let t="next";if(e.reverse&&(t="prev"),e.index){let r=this.store.index(e.index);return e.Y?r.openKeyCursor(e.range,t):r.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}function nz(e){return new nO((t,r)=>{e.onsuccess=e=>{t(e.target.result)},e.onerror=e=>{r(n$(e.target.error))}})}let nK=!1;function n$(e){let t=nV.M((0,rF.getUA)());if(t>=12.2&&t<13){let t="An internal error was encountered in the Indexed Database server";if(e.message.indexOf(t)>=0){let e=new r2("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 nK||(nK=!0,setTimeout(()=>{throw e},0)),e}}return e}let nG="IndexBackfiller";class nH{constructor(e,t){this.asyncQueue=e,this.ne=t,this.task=null}start(){this.re(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return null!==this.task}re(e){rW(nG,`Scheduled in ${e}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",e,async()=>{this.task=null;try{let e=await this.ne.ie();rW(nG,`Documents written: ${e}`)}catch(e){nj(e)?rW(nG,"Ignoring IndexedDB error during index backfill: ",e):await nP(e)}
2await this.re(6e4)})}}class nW{constructor(e,t){this.localStore=e,this.persistence=t}async ie(e=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",t=>this.se(t,e))}se(e,t){let r=new Set,n=t,i=!0;return nO.doWhile(()=>!0===i&&n>0,()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(e).next(t=>{if(null!==t&&!r.has(t))return rW(nG,`Processing collection: ${t}`),this.oe(e,t,n).next(e=>{n-=e,r.add(t)});i=!1})).next(()=>t-n)}oe(e,t,r){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(e,t).next(n=>this.localStore.localDocuments.getNextDocuments(e,t,n,r).next(r=>{let i=r.changes;return this.localStore.indexManager.updateIndexEntries(e,i).next(()=>this._e(n,r)).next(r=>(rW(nG,`Updating offset: ${r}`),this.localStore.indexManager.updateCollectionGroup(e,t,r))).next(()=>i.size)}))}_e(e,t){let r=e;return t.changes.forEach((e,t)=>{let n=nA(t);nN(n,r)>0&&(r=n)}),new nx(r.readTime,r.documentKey,Math.max(t.batchId,e.largestBatchId))}}class nQ{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.ae(e),this.ue=e=>t.writeSequenceNumber(e))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this.ue&&this.ue(e),e}}function nJ(e){return null==e}function nY(e){return 0===e&&1/e==-1/0}function nX(e){return"number"==typeof e&&Number.isInteger(e)&&!nY(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}function nZ(e){let t="";for(let r=0;r<e.length;r++)t.length>0&&(t+="\x01\x01"),t=function(e,t){let r=t,n=e.length;for(let t=0;t<n;t++){let n=e.charAt(t);switch(n){case"\0":r+="\x01\x10";break;case"\x01":r+="\x01\x11";break;default:r+=n}}return r}(e.get(r),t);return t+"\x01\x01"}nQ.ce=-1;function n0(e){let t=e.length;if(r0(t>=2,64408,{path:e}),2===t)return r0("\x01"===e.charAt(0)&&"\x01"===e.charAt(1),56145,{path:e}),nu.emptyPath();let r=t-2,n=[],i="";for(let s=0;s<t;){let t=e.indexOf("\x01",s);switch((t<0||t>r)&&rX(50515,{path:e}),e.charAt(t+1)){case"\x01":let a,o=e.substring(s,t);0===i.length?a=o:(i+=o,a=i,i=""),n.push(a);break;case"\x10":i+=e.substring(s,t),i+="\0";break;case"\x11":i+=e.substring(s,t+1);break;default:rX(61167,{path:e})}s=t+2}return new nu(n)}let n1="remoteDocuments",n2="owner",n5="owner",n6="mutationQueues",n3="mutations",n8="batchId",n4="userMutationsIndex",n9=["userId","batchId"],n7={},ie="documentMutations",it="remoteDocumentsV14",ir=["prefixPath","collectionGroup","readTime","documentId"],ii="documentKeyIndex",is=["prefixPath","collectionGroup","documentId"],ia="collectionGroupIndex",io=["collectionGroup","readTime","prefixPath","documentId"],il="remoteDocumentGlobal",iu="remoteDocumentGlobalKey",ih="targets",ic="queryTargetsIndex",id=["canonicalId","targetId"],ip="targetDocuments",ig=["targetId","path"],im="documentTargetsIndex",iy=["path","targetId"],iw="targetGlobalKey",iv="targetGlobal",iI="collectionParents",ib=["collectionId","parent"],iE="clientMetadata",iT="bundles",i_="namedQueries",iS="indexConfiguration",iC="collectionGroupIndex",ik="indexState",iA=["indexId","uid"],ix="sequenceNumberIndex",iN=["uid","sequenceNumber"],iR="indexEntries",iD=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],iP="documentKeyIndex",iO=["indexId","uid","orderedDocumentKey"],iL="documentOverlays",iM=["userId","collectionPath","documentId"],iV="collectionPathOverlayIndex",iF=["userId","collectionPath","largestBatchId"],iU="collectionGroupOverlayIndex",iB=["userId","collectionGroup","largestBatchId"],ij="globals",iq=[n6,n3,ie,n1,ih,n2,iv,ip,iE,il,iI,iT,i_],iz=[...iq,iL],iK=[n6,n3,ie,it,ih,n2,iv,ip,iE,il,iI,iT,i_,iL],i$=[...iK,iS,ik,iR],iG=[...i$,ij];class iH extends nD{constructor(e,t){super(),this.le=e,this.currentSequenceNumber=t}}function iW(e,t){return nV.O(e.le,t)}function iQ(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function iJ(e,t){for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t(r,e[r])}function iY(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class iX{constructor(e,t){this.comparator=e,this.root=t||i0.EMPTY}insert(e,t){return new iX(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,i0.BLACK,null,
2null))}remove(e){return new iX(this.comparator,this.root.remove(e,this.comparator).copy(null,null,i0.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let r=this.comparator(e,t.key);if(0===r)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){let n=this.comparator(e,r.key);if(0===n)return t+r.left.size;n<0?r=r.left:(t+=r.left.size+1,r=r.right)}return -1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,r)=>(e(t,r),!1))}toString(){let e=[];return this.inorderTraversal((t,r)=>(e.push(`${t}:${r}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new iZ(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new iZ(this.root,e,this.comparator,!1)}getReverseIterator(){return new iZ(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new iZ(this.root,e,this.comparator,!0)}}class iZ{constructor(e,t,r,n){this.isReverse=n,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?r(e.key,t):1,t&&n&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(0===i){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class i0{constructor(e,t,r,n,i){this.key=e,this.value=t,this.color=null!=r?r:i0.RED,this.left=null!=n?n:i0.EMPTY,this.right=null!=i?i:i0.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,n,i){return new i0(null!=e?e:this.key,null!=t?t:this.value,null!=r?r:this.color,null!=n?n: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,r){let n=this,i=r(e,n.key);return(n=i<0?n.copy(null,null,null,n.left.insert(e,t,r),null):0===i?n.copy(null,t,null,null,null):n.copy(null,null,null,null,n.right.insert(e,t,r))).fixUp()}removeMin(){if(this.left.isEmpty())return i0.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),(e=e.copy(null,null,null,e.left.removeMin(),null)).fixUp()}remove(e,t){let r,n=this;if(0>t(e,n.key))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 i0.EMPTY;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=(e=e.copy(null,null,null,null,e.right.rotateRight())).rotateLeft()).colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=(e=e.rotateRight()).colorFlip()),e}rotateLeft(){let e=this.copy(null,null,i0.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){let e=this.copy(null,null,i0.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){let e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){return Math.pow(2,this.check())<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw rX(43730,{key:this.key,value:this.value});if(this.right.isRed())throw rX(14113,{key:this.key,value:this.value});let e=this.left.check();if(e!==this.right.check())throw rX(27949);return e+ +!this.isRed()}}
2i0.EMPTY=null,i0.RED=!0,i0.BLACK=!1,i0.EMPTY=new class{constructor(){this.size=0}get key(){throw rX(57766)}get value(){throw rX(16141)}get color(){throw rX(16727)}get left(){throw rX(29726)}get right(){throw rX(36894)}copy(e,t,r,n,i){return this}insert(e,t,r){return new i0(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 i1{constructor(e){this.comparator=e,this.data=new iX(this.comparator)}has(e){return null!==this.data.get(e)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,r)=>(e(t),!1))}forEachInRange(e,t){let r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){let n=r.getNext();if(this.comparator(n.key,e[1])>=0)return;t(n.key)}}forEachWhile(e,t){let r;for(r=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new i2(this.data.getIterator())}getIteratorFrom(e){return new i2(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 i1)||this.size!==e.size)return!1;let t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){let e=t.getNext().key,n=r.getNext().key;if(0!==this.comparator(e,n))return!1}return!0}toArray(){let e=[];return this.forEach(t=>{e.push(t)}),e}toString(){let e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){let t=new i1(this.comparator);return t.data=e,t}}class i2{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function i5(e){return e.hasNext()?e.getNext():void 0}class i6{constructor(e){this.fields=e,e.sort(nc.comparator)}static empty(){return new i6([])}unionWith(e){let t=new i1(nc.comparator);for(let e of this.fields)t=t.add(e);for(let r of e)t=t.add(r);return new i6(t.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return na(this.fields,e.fields,(e,t)=>e.isEqual(t))}}class i3 extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class i8{constructor(e){this.binaryString=e}static fromBase64String(e){return new i8(function(e){try{return atob(e)}catch(e){throw"u">typeof DOMException&&e instanceof DOMException?new i3("Invalid base64 string: "+e):e}}(e))}static fromUint8Array(e){return new i8(function(e){let t="";for(let r=0;r<e.length;++r)t+=String.fromCharCode(e[r]);return t}(e))}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return btoa(this.binaryString)}toUint8Array(){var e=this.binaryString;let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return nn(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}i8.EMPTY_BYTE_STRING=new i8("");let i4=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function i9(e){if(r0(!!e,39018),"string"==typeof e){let t=0,r=i4.exec(e);if(r0(!!r,46558,{timestamp:e}),r[1]){let e=r[1];t=Number(e=(e+"000000000").substr(0,9))}return{seconds:Math.floor(new Date(e).getTime()/1e3),nanos:t}}return{seconds:i7(e.seconds),nanos:i7(e.nanos)}}function i7(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function se(e){return"string"==typeof e?i8.fromBase64String(e):i8.fromUint8Array(e)}let st="server_timestamp",sr="__type__",sn="__previous_value__",si="__local_write_time__";function ss(e){return(e?.mapValue?.fields||{})[sr]?.stringValue===st}function sa(e){let t=e.mapValue.fields[sn];return ss(t)?sa(t):t}function so(e){let t=i9(e.mapValue.fields[si].timestampValue);return new nv(t.seconds,t.nanos)}class sl{constructor(e,t,r,n,i,s,a,o,l,u,h){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=n,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=a,this.longPollingOptions=o,this.useFetchStreams=l,this.isUsingEmulator=u,this.apiKey=h}}let su="(default)";class sh{constructor(e,t){this.projectId=e,this.database=t||su}static empty(){return new sh("","")}get isDefaultDatabase(){return this.database===su}isEqual(e){return e instanceof sh&&e.projectId===this.projectId&&e.database===this.database}}function sc(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new r2(r1.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new sh(e.options.projectId,t)}let sd="__type__",sf="__max__",sp={mapValue:{fields:{__type__:{stringValue:sf}}}},sg="__vector__",sm="value",sy={nullValue:"NULL_VALUE"};function sw(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?ss(e)?4:sP(e)?0x1fffffffffffff:sR(e)?10:11:rX(28295,{value:e})}function sv(e,t){if(e===t)return!0;let r=sw(e);if(r!==sw(t))return!1;switch(r){case 0:case 0x1fffffffffffff:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return so(e).isEqual(so(t));case 3:if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;let n=i9(e.timestampValue),i=i9(t.timestampValue);return n.seconds===i.seconds&&n.nanos===i.nanos;case 5:return e.stringValue===t.stringValue;case 6:return se(e.bytesValue).isEqual(se(t.bytesValue));case 7:return e.referenceValue===t.referenceValue;case 8:return i7(e.geoPointValue.latitude)===i7(t.geoPointValue.latitude)&&i7(e.geoPointValue.longitude)===i7(t.geoPointValue.longitude);case 2:if("integerValue"in e&&"integerValue"in t)return i7(e.integerValue)===i7(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){let r=i7(e.doubleValue),n=i7(t.doubleValue);return r===n?nY(r)===nY(n):isNaN(r)&&isNaN(n)}return!1;case 9:return na(e.arrayValue.values||[],t.arrayValue.values||[],sv);case 10:case 11:let s=e.mapValue.fields||{},a=t.mapValue.fields||{};if(iQ(s)!==iQ(a))return!1;for(let e in s)if(s.hasOwnProperty(e)&&(void 0===a[e]||!sv(s[e],a[e])))return!1;return!0;default:return rX(52216,{left:e})}}function sI(e,t){return void 0!==(e.values||[]).find(e=>sv(e,t))}
2function sb(e,t){var r,n,i,s,a,o;if(e===t)return 0;let l=sw(e),u=sw(t);if(l!==u)return nn(l,u);switch(l){case 0:case 0x1fffffffffffff:return 0;case 1:return nn(e.booleanValue,t.booleanValue);case 2:let h,c;return h=i7(e.integerValue||e.doubleValue),h<(c=i7(t.integerValue||t.doubleValue))?-1:h>c?1:h===c?0:isNaN(h)?isNaN(c)?0:-1:1;case 3:return sE(e.timestampValue,t.timestampValue);case 4:return sE(so(e),so(t));case 5:return ni(e.stringValue,t.stringValue);case 6:let d,f;return r=e.bytesValue,n=t.bytesValue,d=se(r),f=se(n),d.compareTo(f);case 7:return function(e,t){let r=e.split("/"),n=t.split("/");for(let e=0;e<r.length&&e<n.length;e++){let t=nn(r[e],n[e]);if(0!==t)return t}return nn(r.length,n.length)}(e.referenceValue,t.referenceValue);case 8:let p;return i=e.geoPointValue,s=t.geoPointValue,0!==(p=nn(i7(i.latitude),i7(s.latitude)))?p:nn(i7(i.longitude),i7(s.longitude));case 9:return sT(e.arrayValue,t.arrayValue);case 10:let g,m,y,w,v;return a=e.mapValue,o=t.mapValue,g=a.fields||{},m=o.fields||{},y=g[sm]?.arrayValue,w=m[sm]?.arrayValue,0!==(v=nn(y?.values?.length||0,w?.values?.length||0))?v:sT(y,w);case 11:return function(e,t){if(e===sp.mapValue&&t===sp.mapValue)return 0;if(e===sp.mapValue)return 1;if(t===sp.mapValue)return -1;let r=e.fields||{},n=Object.keys(r),i=t.fields||{},s=Object.keys(i);n.sort(),s.sort();for(let e=0;e<n.length&&e<s.length;++e){let t=ni(n[e],s[e]);if(0!==t)return t;let a=sb(r[n[e]],i[s[e]]);if(0!==a)return a}return nn(n.length,s.length)}(e.mapValue,t.mapValue);default:throw rX(23264,{he:l})}}function sE(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return nn(e,t);let r=i9(e),n=i9(t),i=nn(r.seconds,n.seconds);return 0!==i?i:nn(r.nanos,n.nanos)}function sT(e,t){let r=e.values||[],n=t.values||[];for(let e=0;e<r.length&&e<n.length;++e){let t=sb(r[e],n[e]);if(t)return t}return nn(r.length,n.length)}function s_(e){var t,r;let n;return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?(n=i9(e.timestampValue),`time(${n.seconds},${n.nanos})`):"stringValue"in e?e.stringValue:"bytesValue"in e?se(e.bytesValue).toBase64():"referenceValue"in e?(t=e.referenceValue,nd.fromName(t).toString()):"geoPointValue"in e?(r=e.geoPointValue,`geo(${r.latitude},${r.longitude})`):"arrayValue"in e?function(e){let t="[",r=!0;for(let n of e.values||[])r?r=!1:t+=",",t+=s_(n);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){let t=Object.keys(e.fields||{}).sort(),r="{",n=!0;for(let i of t)n?n=!1:r+=",",r+=`${i}:${s_(e.fields[i])}`;return r+"}"}(e.mapValue):rX(61005,{value:e})}function sS(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function sC(e){return!!e&&"integerValue"in e}function sk(e){return!!e&&"arrayValue"in e}function sA(e){return!!e&&"nullValue"in e}function sx(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function sN(e){return!!e&&"mapValue"in e}function sR(e){return(e?.mapValue?.fields||{})[sd]?.stringValue===sg}function sD(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:{...e.timestampValue}};if(e.mapValue){let t={mapValue:{fields:{}}};return iJ(e.mapValue.fields,(e,r)=>t.mapValue.fields[e]=sD(r)),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let r=0;r<(e.arrayValue.values||[]).length;++r)t.arrayValue.values[r]=sD(e.arrayValue.values[r]);return t}return{...e}}function sP(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===sf}let sO={mapValue:{fields:{[sd]:{stringValue:sg},[sm]:{arrayValue:{}}}}};function sL(e,t){let r=sb(e.value,t.value);return 0!==r?r:e.inclusive&&!t.inclusive?-1:!e.inclusive&&t.inclusive?1:0}function sM(e,t){let r=sb(e.value,t.value);return 0!==r?r:e.inclusive&&!t.inclusive?1:!e.inclusive&&t.inclusive?-1:0}class sV{constructor(e){this.value=e}static empty(){return new sV({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(!sN(t=(t.mapValue.fields||{})[e.get(r)]))return null;return(t=(t.mapValue.fields||{})[e.lastSegment()])||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=sD(t)}setAll(e){let t=nc.emptyPath(),r={},n=[];e.forEach((e,i)=>{if(!t.isImmediateParentOf(i)){let e=this.getFieldsMap(t);this.applyChanges(e,r,n),r={},n=[],t=i.popLast()}e?r[i.lastSegment()]=sD(e):n.push(i.lastSegment())});let i=this.getFieldsMap(t);this.applyChanges(i,r,n)}delete(e){let t=this.field(e.popLast());sN(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return sv(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let n=t.mapValue.fields[e.get(r)];sN(n)&&n.mapValue.fields||(n={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=n),t=n}return t.mapValue.fields}
2applyChanges(e,t,r){for(let n of(iJ(t,(t,r)=>e[t]=r),r))delete e[n]}clone(){return new sV(sD(this.value))}}class sF{constructor(e,t,r,n,i,s,a){this.key=e,this.documentType=t,this.version=r,this.readTime=n,this.createTime=i,this.data=s,this.documentState=a}static newInvalidDocument(e){return new sF(e,0,nI.min(),nI.min(),nI.min(),sV.empty(),0)}static newFoundDocument(e,t,r,n){return new sF(e,1,t,nI.min(),r,n,0)}static newNoDocument(e,t){return new sF(e,2,t,nI.min(),nI.min(),sV.empty(),0)}static newUnknownDocument(e,t){return new sF(e,3,t,nI.min(),nI.min(),sV.empty(),2)}convertToFoundDocument(e,t){return this.createTime.isEqual(nI.min())&&(2===this.documentType||0===this.documentType)&&(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=sV.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=sV.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=nI.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return 1===this.documentState}get hasCommittedMutations(){return 2===this.documentState}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return 0!==this.documentType}isFoundDocument(){return 1===this.documentType}isNoDocument(){return 2===this.documentType}isUnknownDocument(){return 3===this.documentType}isEqual(e){return e instanceof sF&&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 sF(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class sU{constructor(e,t){this.position=e,this.inclusive=t}}function sB(e,t,r){let n=0;for(let i=0;i<e.position.length;i++){let s=t[i],a=e.position[i];if(n=s.field.isKeyField()?nd.comparator(nd.fromName(a.referenceValue),r.key):sb(a,r.data.field(s.field)),"desc"===s.dir&&(n*=-1),0!==n)break}return n}function sj(e,t){if(null===e)return null===t;if(null===t||e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let r=0;r<e.position.length;r++)if(!sv(e.position[r],t.position[r]))return!1;return!0}class sq{constructor(e,t="asc"){this.field=e,this.dir=t}}class sz{}class sK extends sz{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,r):new sY(e,t,r):"array-contains"===t?new s1(e,r):"in"===t?new s2(e,r):"not-in"===t?new s5(e,r):"array-contains-any"===t?new s6(e,r):new sK(e,t,r)}static createKeyFieldInFilter(e,t,r){return"in"===t?new sX(e,r):new sZ(e,r)}matches(e){let t=e.data.field(this.field);return"!="===this.op?null!==t&&void 0===t.nullValue&&this.matchesComparison(sb(t,this.value)):null!==t&&sw(this.value)===sw(t)&&this.matchesComparison(sb(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return rX(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class s$ extends sz{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(e,t){return new s$(e,t)}matches(e){return sG(this)?void 0===this.filters.find(t=>!t.matches(e)):void 0!==this.filters.find(t=>t.matches(e))}getFlattenedFilters(){return null!==this.Pe||(this.Pe=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function sG(e){return"and"===e.op}function sH(e){return"or"===e.op}function sW(e){return sQ(e)&&sG(e)}function sQ(e){for(let t of e.filters)if(t instanceof s$)return!1;return!0}function sJ(e,t){let r=e.filters.concat(t);return s$.create(r,e.op)}class sY extends sK{constructor(e,t,r){super(e,t,r),this.key=nd.fromName(r.referenceValue)}matches(e){let t=nd.comparator(e.key,this.key);return this.matchesComparison(t)}}class sX extends sK{constructor(e,t){super(e,"in",t),this.keys=s0("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class sZ extends sK{constructor(e,t){super(e,"not-in",t),this.keys=s0("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function s0(e,t){return(t.arrayValue?.values||[]).map(e=>nd.fromName(e.referenceValue))}class s1 extends sK{constructor(e,t){super(e,"array-contains",t)}matches(e){let t=e.data.field(this.field);return sk(t)&&sI(t.arrayValue,this.value)}}class s2 extends sK{constructor(e,t){super(e,"in",t)}matches(e){let t=e.data.field(this.field);return null!==t&&sI(this.value.arrayValue,t)}}class s5 extends sK{constructor(e,t){super(e,"not-in",t)}matches(e){if(sI(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let t=e.data.field(this.field);return null!==t&&void 0===t.nullValue&&!sI(this.value.arrayValue,t)}}class s6 extends sK{constructor(e,t){super(e,"array-contains-any",t)}matches(e){let t=e.data.field(this.field);return!(!sk(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>sI(this.value.arrayValue,e))}}class s3{constructor(e,t=null,r=[],n=[],i=null,s=null,a=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=n,this.limit=i,this.startAt=s,this.endAt=a,this.Te=null}}function s8(e,t=null,r=[],n=[],i=null,s=null,a=null){return new s3(e,t,r,n,i,s,a)}function s4(e){if(null===e.Te){let t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(e=>(function e(t){if(t instanceof sK)return t.field.canonicalString()+t.op.toString()+s_(t.value);if(sW(t))return t.filters.map(t=>e(t)).join(",");{let r=t.filters.map(t=>e(t)).join(",");return`${t.op}(${r})`}})(e)).join(","),t+="|ob:",t+=e.orderBy.map(e=>e.field.canonicalString()+e.dir).join(","),nJ(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(e=>s_(e)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(e=>s_(e)).join(",")),e.Te=t}return e.Te}function s9(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(let i=0;i<e.orderBy.length;i++){var r,n;if(r=e.orderBy[i],n=t.orderBy[i],!(r.dir===n.dir&&r.field.isEqual(n.field)))return!1}if(e.filters.length!==t.filters.length)return!1;for(let r=0;r<e.filters.length;r++)if(!function e(t,r){return t instanceof sK?r instanceof sK&&t.op===r.op&&t.field.isEqual(r.field)&&sv(t.value,r.value):t instanceof s$?r instanceof s$&&t.op===r.op&&t.filters.length===r.filters.length&&t.filters.reduce((t,n,i)=>t&&e(n,r.filters[i]),!0):void rX(19439)}(e.filters[r],t.filters[r]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!sj(e.startAt,t.startAt)&&sj(e.endAt,t.endAt)}function s7(e){return nd.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}function ae(e,t){return e.filters.filter(e=>e instanceof sK&&e.field.isEqual(t))}function at(e,t,r){let n=sy,i=!0;for(let r of ae(e,t)){let e=sy,t=!0;switch(r.op){case"<":case"<=":var s;
2e="nullValue"in(s=r.value)?sy:"booleanValue"in s?{booleanValue:!1}:"integerValue"in s||"doubleValue"in s?{doubleValue:NaN}:"timestampValue"in s?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in s?{stringValue:""}:"bytesValue"in s?{bytesValue:""}:"referenceValue"in s?sS(sh.empty(),nd.empty()):"geoPointValue"in s?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in s?{arrayValue:{}}:"mapValue"in s?sR(s)?sO:{mapValue:{}}:rX(35942,{value:s});break;case"==":case"in":case">=":e=r.value;break;case">":e=r.value,t=!1;break;case"!=":case"not-in":e=sy}0>sL({value:n,inclusive:i},{value:e,inclusive:t})&&(n=e,i=t)}if(null!==r){for(let s=0;s<e.orderBy.length;++s)if(e.orderBy[s].field.isEqual(t)){let e=r.position[s];0>sL({value:n,inclusive:i},{value:e,inclusive:r.inclusive})&&(n=e,i=r.inclusive);break}}return{value:n,inclusive:i}}function ar(e,t,r){let n=sp,i=!0;for(let r of ae(e,t)){let e=sp,t=!0;switch(r.op){case">=":case">":var s;e="nullValue"in(s=r.value)?{booleanValue:!1}:"booleanValue"in s?{doubleValue:NaN}:"integerValue"in s||"doubleValue"in s?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in s?{stringValue:""}:"stringValue"in s?{bytesValue:""}:"bytesValue"in s?sS(sh.empty(),nd.empty()):"referenceValue"in s?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in s?{arrayValue:{}}:"arrayValue"in s?sO:"mapValue"in s?sR(s)?{mapValue:{}}:sp:rX(61959,{value:s}),t=!1;break;case"==":case"in":case"<=":e=r.value;break;case"<":e=r.value,t=!1;break;case"!=":case"not-in":e=sp}sM({value:n,inclusive:i},{value:e,inclusive:t})>0&&(n=e,i=t)}if(null!==r){for(let s=0;s<e.orderBy.length;++s)if(e.orderBy[s].field.isEqual(t)){let e=r.position[s];sM({value:n,inclusive:i},{value:e,inclusive:r.inclusive})>0&&(n=e,i=r.inclusive);break}}return{value:n,inclusive:i}}class an{constructor(e,t=null,r=[],n=[],i=null,s="F",a=null,o=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=n,this.limit=i,this.limitType=s,this.startAt=a,this.endAt=o,this.Ee=null,this.Ie=null,this.Re=null,this.startAt,this.endAt}}function ai(e){return new an(e)}function as(e){return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())}function aa(e){return null!==e.collectionGroup}function ao(e){if(null===e.Ee){let t;e.Ee=[];let r=new Set;for(let t of e.explicitOrderBy)e.Ee.push(t),r.add(t.field.canonicalString());let n=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(t=new i1(nc.comparator),e.filters.forEach(e=>{e.getFlattenedFilters().forEach(e=>{e.isInequality()&&(t=t.add(e.field))})}),t).forEach(t=>{r.has(t.canonicalString())||t.isKeyField()||e.Ee.push(new sq(t,n))}),r.has(nc.keyField().canonicalString())||e.Ee.push(new sq(nc.keyField(),n))}return e.Ee}function al(e){return e.Ie||(e.Ie=au(e,ao(e))),e.Ie}function au(e,t){if("F"===e.limitType)return s8(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map(e=>{let t="desc"===e.dir?"asc":"desc";return new sq(e.field,t)});let r=e.endAt?new sU(e.endAt.position,e.endAt.inclusive):null,n=e.startAt?new sU(e.startAt.position,e.startAt.inclusive):null;return s8(e.path,e.collectionGroup,t,e.filters,e.limit,r,n)}}function ah(e,t,r){return new an(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,r,e.startAt,e.endAt)}function ac(e,t){return s9(al(e),al(t))&&e.limitType===t.limitType}function ad(e){return`${s4(al(e))}|lt:${e.limitType}`}function af(e){var t;let r;return`Query(target=${r=(t=al(e)).path.canonicalString(),null!==t.collectionGroup&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map(e=>(function e(t){return t instanceof sK?`${t.field.canonicalString()} ${t.op} ${s_(t.value)}`:t instanceof s$?t.op.toString()+" {"+t.getFilters().map(e).join(" ,")+"}":"Filter"})(e)).join(", ")}]`),nJ(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map(e=>`${e.field.canonicalString()} (${e.dir})`).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map(e=>s_(e)).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map(e=>s_(e)).join(",")),`Target(${r})`}; limitType=${e.limitType})`}function ap(e,t){var r,n,i,s;let a,o,l;
2return t.isFoundDocument()&&(a=t.key.path,null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(a):nd.isDocumentKey(e.path)?e.path.isEqual(a):e.path.isImmediateParentOf(a))&&function(e,t){for(let r of ao(e))if(!r.field.isKeyField()&&null===t.data.field(r.field))return!1;return!0}(e,t)&&function(e,t){for(let r of e.filters)if(!r.matches(t))return!1;return!0}(e,t)&&(r=e,n=t,(!r.startAt||(i=r.startAt,o=sB(i,ao(r),n),i.inclusive?!!(o<=0):!!(o<0)))&&(!r.endAt||(s=r.endAt,l=sB(s,ao(r),n),s.inclusive?!!(l>=0):!!(l>0))))}function ag(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function am(e){return(t,r)=>{let n=!1;for(let i of ao(e)){let e=function(e,t,r){var n;let i,s,a=e.field.isKeyField()?nd.comparator(t.key,r.key):(n=e.field,i=t.data.field(n),s=r.data.field(n),null!==i&&null!==s?sb(i,s):rX(42886));switch(e.dir){case"asc":return a;case"desc":return -1*a;default:return rX(19790,{direction:e.dir})}}(i,t,r);if(0!==e)return e;n=n||i.field.isKeyField()}return 0}}class ay{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),r=this.inner[t];if(void 0!==r){for(let[t,n]of r)if(this.equalsFn(t,e))return n}}has(e){return void 0!==this.get(e)}set(e,t){let r=this.mapKeyFn(e),n=this.inner[r];if(void 0===n)return this.inner[r]=[[e,t]],void this.innerSize++;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return void(n[r]=[e,t]);n.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),r=this.inner[t];if(void 0===r)return!1;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],e))return 1===r.length?delete this.inner[t]:r.splice(n,1),this.innerSize--,!0;return!1}forEach(e){iJ(this.inner,(t,r)=>{for(let[t,n]of r)e(t,n)})}isEmpty(){return iY(this.inner)}size(){return this.innerSize}}let aw=new iX(nd.comparator),av=new iX(nd.comparator);function aI(...e){let t=av;for(let r of e)t=t.insert(r.key,r);return t}function ab(e){let t=av;return e.forEach((e,r)=>t=t.insert(e,r.overlayedDocument)),t}function aE(){return new ay(e=>e.toString(),(e,t)=>e.isEqual(t))}let aT=new iX(nd.comparator),a_=new i1(nd.comparator);function aS(...e){let t=a_;for(let r of e)t=t.add(r);return t}let aC=new i1(nn);function ak(e,t){if(e.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:nY(t)?"-0":t}}function aA(e){return{integerValue:""+e}}class ax{constructor(){this._=void 0}}function aN(e,t){return e instanceof aM?sC(t)||t&&"doubleValue"in t?t:{integerValue:0}:null}class aR extends ax{}class aD extends ax{constructor(e){super(),this.elements=e}}function aP(e,t){let r=aF(t);for(let t of e.elements)r.some(e=>sv(e,t))||r.push(t);return{arrayValue:{values:r}}}class aO extends ax{constructor(e){super(),this.elements=e}}function aL(e,t){let r=aF(t);for(let t of e.elements)r=r.filter(e=>!sv(e,t));return{arrayValue:{values:r}}}class aM extends ax{constructor(e,t){super(),this.serializer=e,this.Ae=t}}function aV(e){return i7(e.integerValue||e.doubleValue)}function aF(e){return sk(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class aU{constructor(e,t){this.field=e,this.transform=t}}class aB{constructor(e,t){this.version=e,this.transformResults=t}}class aj{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new aj}static exists(e){return new aj(void 0,e)}static updateTime(e){return new aj(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 aq(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class az{}function aK(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new aX(e.key,aj.none()):new aH(e.key,e.data,aj.none());{let r=e.data,n=sV.empty(),i=new i1(nc.comparator);for(let e of t.fields)if(!i.has(e)){let t=r.field(e);null===t&&e.length>1&&(e=e.popLast(),t=r.field(e)),null===t?n.delete(e):n.set(e,t),i=i.add(e)}return new aW(e.key,n,new i6(i.toArray()),aj.none())}}function a$(e,t,r,n){return e instanceof aH?function(e,t,r,n){if(!aq(e.precondition,t))return r;let i=e.value.clone(),s=aY(e.fieldTransforms,n,t);return i.setAll(s),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,r,n):e instanceof aW?function(e,t,r,n){if(!aq(e.precondition,t))return r;let i=aY(e.fieldTransforms,n,t),s=t.data;return(s.setAll(aQ(e)),s.setAll(i),t.convertToFoundDocument(t.version,s).setHasLocalMutations(),null===r)?null:r.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map(e=>e.field))}(e,t,r,n):aq(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):r}function aG(e,t){var r,n;return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&(r=e.fieldTransforms,n=t.fieldTransforms,!!(void 0===r&&void 0===n||!(!r||!n)&&na(r,n,(e,t)=>{var r,n;return e.field.isEqual(t.field)&&(r=e.transform,n=t.transform,r instanceof aD&&n instanceof aD||r instanceof aO&&n instanceof aO?na(r.elements,n.elements,sv):r instanceof aM&&n instanceof aM?sv(r.Ae,
2n.Ae):r instanceof aR&&n instanceof aR)})))&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class aH extends az{constructor(e,t,r,n=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=n,this.type=0}getFieldMask(){return null}}class aW extends az{constructor(e,t,r,n,i=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=n,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function aQ(e){let t=new Map;return e.fieldMask.fields.forEach(r=>{if(!r.isEmpty()){let n=e.data.field(r);t.set(r,n)}}),t}function aJ(e,t,r){let n=new Map;r0(e.length===r.length,32656,{Ve:r.length,de:e.length});for(let s=0;s<r.length;s++){var i;let a=e[s],o=a.transform,l=t.data.field(a.field);n.set(a.field,(i=r[s],o instanceof aD?aP(o,l):o instanceof aO?aL(o,l):i))}return n}function aY(e,t,r){let n=new Map;for(let i of e){let e=i.transform,s=r.data.field(i.field);n.set(i.field,function(e,t,r){var n;let i,s,a;return e instanceof aR?(n=t,i={fields:{[sr]:{stringValue:st},[si]:{timestampValue:{seconds:r.seconds,nanos:r.nanoseconds}}}},n&&ss(n)&&(n=sa(n)),n&&(i.fields[sn]=n),{mapValue:i}):e instanceof aD?aP(e,t):e instanceof aO?aL(e,t):(a=aV(s=aN(e,t))+aV(e.Ae),sC(s)&&sC(e.Ae)?aA(a):ak(e.serializer,a))}(e,s,t))}return n}class aX extends az{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class aZ extends az{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class a0{constructor(e,t,r,n){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=n}applyToRemoteDocument(e,t){let r=t.mutationResults;for(let t=0;t<this.mutations.length;t++){let n=this.mutations[t];n.key.isEqual(e.key)&&function(e,t,r){let n,i;e instanceof aH?(n=e.value.clone(),i=aJ(e.fieldTransforms,t,r.transformResults),n.setAll(i),t.convertToFoundDocument(r.version,n).setHasCommittedMutations()):e instanceof aW?function(e,t,r){if(!aq(e.precondition,t))return t.convertToUnknownDocument(r.version);let n=aJ(e.fieldTransforms,t,r.transformResults),i=t.data;i.setAll(aQ(e)),i.setAll(n),t.convertToFoundDocument(r.version,i).setHasCommittedMutations()}(e,t,r):t.convertToNoDocument(r.version).setHasCommittedMutations()}(n,e,r[t])}}applyToLocalView(e,t){for(let r of this.baseMutations)r.key.isEqual(e.key)&&(t=a$(r,e,t,this.localWriteTime));for(let r of this.mutations)r.key.isEqual(e.key)&&(t=a$(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let r=aE();return this.mutations.forEach(n=>{let i=e.get(n.key),s=i.overlayedDocument,a=this.applyToLocalView(s,i.mutatedFields),o=aK(s,a=t.has(n.key)?null:a);null!==o&&r.set(n.key,o),s.isValidDocument()||s.convertToNoDocument(nI.min())}),r}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),aS())}isEqual(e){return this.batchId===e.batchId&&na(this.mutations,e.mutations,(e,t)=>aG(e,t))&&na(this.baseMutations,e.baseMutations,(e,t)=>aG(e,t))}}class a1{constructor(e,t,r,n){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=n}static from(e,t,r){r0(e.mutations.length===r.length,58842,{me:e.mutations.length,fe:r.length});let n=aT,i=e.mutations;for(let e=0;e<i.length;e++)n=n.insert(i[e].key,r[e].version);return new a1(e,t,r,n)}}class a2{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return null!==e&&this.mutation===e.mutation}toString(){return`Overlay{
3      largestBatchId: ${this.largestBatchId},
4      mutation: ${this.mutation.toString()}
5    }`}}class a5{constructor(e,t){this.count=e,this.unchangedNames=t}}function a6(e){switch(e){case r1.OK:return rX(64938);case r1.CANCELLED:case r1.UNKNOWN:case r1.DEADLINE_EXCEEDED:case r1.RESOURCE_EXHAUSTED:case r1.INTERNAL:case r1.UNAVAILABLE:case r1.UNAUTHENTICATED:return!1;case r1.INVALID_ARGUMENT:case r1.NOT_FOUND:case r1.ALREADY_EXISTS:case r1.PERMISSION_DENIED:case r1.FAILED_PRECONDITION:case r1.ABORTED:case r1.OUT_OF_RANGE:case r1.UNIMPLEMENTED:case r1.DATA_LOSS:return!0;default:return rX(15467,{code:e})}}function a3(e){if(void 0===e)return rQ("GRPC error has no .code"),r1.UNKNOWN;switch(e){case d.OK:return r1.OK;case d.CANCELLED:return r1.CANCELLED;case d.UNKNOWN:return r1.UNKNOWN;case d.DEADLINE_EXCEEDED:return r1.DEADLINE_EXCEEDED;case d.RESOURCE_EXHAUSTED:return r1.RESOURCE_EXHAUSTED;case d.INTERNAL:return r1.INTERNAL;case d.UNAVAILABLE:return r1.UNAVAILABLE;case d.UNAUTHENTICATED:return r1.UNAUTHENTICATED;case d.INVALID_ARGUMENT:return r1.INVALID_ARGUMENT;case d.NOT_FOUND:return r1.NOT_FOUND;case d.ALREADY_EXISTS:return r1.ALREADY_EXISTS;case d.PERMISSION_DENIED:return r1.PERMISSION_DENIED;case d.FAILED_PRECONDITION:return r1.FAILED_PRECONDITION;case d.ABORTED:return r1.ABORTED;case d.OUT_OF_RANGE:return r1.OUT_OF_RANGE;
5case d.UNIMPLEMENTED:return r1.UNIMPLEMENTED;case d.DATA_LOSS:return r1.DATA_LOSS;default:return rX(39323,{code:e})}}(f=d||(d={}))[f.OK=0]="OK",f[f.CANCELLED=1]="CANCELLED",f[f.UNKNOWN=2]="UNKNOWN",f[f.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",f[f.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",f[f.NOT_FOUND=5]="NOT_FOUND",f[f.ALREADY_EXISTS=6]="ALREADY_EXISTS",f[f.PERMISSION_DENIED=7]="PERMISSION_DENIED",f[f.UNAUTHENTICATED=16]="UNAUTHENTICATED",f[f.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",f[f.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",f[f.ABORTED=10]="ABORTED",f[f.OUT_OF_RANGE=11]="OUT_OF_RANGE",f[f.UNIMPLEMENTED=12]="UNIMPLEMENTED",f[f.INTERNAL=13]="INTERNAL",f[f.UNAVAILABLE=14]="UNAVAILABLE",f[f.DATA_LOSS=15]="DATA_LOSS";let a8=null;function a4(){return new TextEncoder}let a9=new r([0xffffffff,0xffffffff],0);function a7(e){let t=a4().encode(e),r=new n;return r.update(t),new Uint8Array(r.digest())}function oe(e){let t=new DataView(e.buffer),n=t.getUint32(0,!0),i=t.getUint32(4,!0),s=t.getUint32(8,!0),a=t.getUint32(12,!0);return[new r([n,i],0),new r([s,a],0)]}class ot{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new or(`Invalid padding: ${t}`);if(n<0||e.length>0&&0===this.hashCount)throw new or(`Invalid hash count: ${n}`);if(0===e.length&&0!==t)throw new or(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=r.fromNumber(this.ge)}ye(e,t,n){let i=e.add(t.multiply(r.fromNumber(n)));return 1===i.compare(a9)&&(i=new r([i.getBits(0),i.getBits(1)],0)),i.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.ge)return!1;let[t,r]=oe(a7(e));for(let e=0;e<this.hashCount;e++){let n=this.ye(t,r,e);if(!this.we(n))return!1}return!0}static create(e,t,r){let n=new ot(new Uint8Array(Math.ceil(e/8)),e%8==0?0:8-e%8,t);return r.forEach(e=>n.insert(e)),n}insert(e){if(0===this.ge)return;let[t,r]=oe(a7(e));for(let e=0;e<this.hashCount;e++){let n=this.ye(t,r,e);this.Se(n)}}Se(e){let t=Math.floor(e/8);this.bitmap[t]|=1<<e%8}}class or extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class on{constructor(e,t,r,n,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=n,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,r){let n=new Map;return n.set(e,oi.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new on(nI.min(),n,new iX(nn),aw,aS())}}class oi{constructor(e,t,r,n,i){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=n,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new oi(r,t,aS(),aS(),aS())}}class os{constructor(e,t,r,n){this.be=e,this.removedTargetIds=t,this.key=r,this.De=n}}class oa{constructor(e,t){this.targetId=e,this.Ce=t}}class oo{constructor(e,t,r=i8.EMPTY_BYTE_STRING,n=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=n}}class ol{constructor(){this.ve=0,this.Fe=oc(),this.Me=i8.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return 0!==this.ve}get Be(){return this.Oe}Le(e){e.approximateByteSize()>0&&(this.Oe=!0,this.Me=e)}ke(){let e=aS(),t=aS(),r=aS();return this.Fe.forEach((n,i)=>{switch(i){case 0:e=e.add(n);break;case 2:t=t.add(n);break;case 1:r=r.add(n);break;default:rX(38017,{changeType:i})}}),new oi(this.Me,this.xe,e,t,r)}qe(){this.Oe=!1,this.Fe=oc()}Ke(e,t){this.Oe=!0,this.Fe=this.Fe.insert(e,t)}Ue(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}$e(){this.ve+=1}We(){this.ve-=1,r0(this.ve>=0,3241,{ve:this.ve})}Qe(){this.Oe=!0,this.xe=!0}}class ou{constructor(e){this.Ge=e,this.ze=new Map,this.je=aw,this.Je=oh(),this.He=oh(),this.Ze=new iX(nn)}Xe(e){for(let t of e.be)e.De&&e.De.isFoundDocument()?this.Ye(t,e.De):this.et(t,e.key,e.De);for(let t of e.removedTargetIds)this.et(t,e.key,e.De)}tt(e){this.forEachTarget(e,t=>{let r=this.nt(t);switch(e.state){case 0:this.rt(t)&&r.Le(e.resumeToken);break;case 1:r.We(),r.Ne||r.qe(),r.Le(e.resumeToken);break;case 2:r.We(),r.Ne||this.removeTarget(t);break;case 3:this.rt(t)&&(r.Qe(),r.Le(e.resumeToken));break;case 4:this.rt(t)&&(this.it(t),r.Le(e.resumeToken));break;default:rX(56790,{state:e.state})}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach((e,r)=>{this.rt(r)&&t(r)})}st(e){let t=e.targetId,r=e.Ce.count,n=this.ot(t);if(n){let a=n.target;if(s7(a))if(0===r){let e=new nd(a.path);this.et(t,e,sF.newNoDocument(e,nI.min()))}else r0(1===r,20013,{expectedCount:r});else{let n=this._t(t);if(n!==r){var i,s;let r,a,o=this.ut(e),l=o?this.ct(o,e,n):1;0!==l&&(this.it(t),this.Ze=this.Ze.insert(t,2===l?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch")),a8?.o((i=e.Ce,s=this.Ge.ht(),r={localCacheCount:n,existenceFilterCount:i.count,databaseId:s.database,projectId:s.projectId},(a=i.unchangedNames)&&(r.bloomFilter={applied:0===l,hashCount:a?.hashCount??0,bitmapLength:a?.bits?.bitmap?.length??0,padding:a?.bits?.padding??0,mightContain:e=>o?.mightContain(e)??!1}),r))}}}}ut(e){let t,r,n=e.Ce.unchangedNames;if(!n||!n.bits)return null;let{bits:{bitmap:i="",padding:s=0},hashCount:a=0}=n;try{t=se(i).toUint8Array()}catch(e){if(e instanceof i3)return rJ("Decoding the base64 bloom filter in existence filter failed ("+e.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw e}try{r=new ot(t,s,a)}catch(e){return rJ(e instanceof or?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===r.ge?null:r}ct(e,t,r){return 2*(t.Ce.count!==r-this.Pt(e,t.targetId))}Pt(e,t){let r=this.Ge.getRemoteKeysForTarget(t),n=0;return r.forEach(r=>{let i=this.Ge.ht(),s=`projects/${i.projectId}/databases/${i.database}/documents/${r.path.canonicalString()}`;e.mightContain(s)||(this.et(t,r,null),n++)}),n}Tt(e){let t=new Map;this.ze.forEach((r,n)=>{let i=this.ot(n);if(i){if(r.current&&s7(i.target)){let t=new nd(i.target.path);this.Et(t).has(n)||this.It(n,t)||this.et(n,t,sF.newNoDocument(t,e))}r.Be&&(t.set(n,r.ke()),r.qe())}});let r=aS();this.He.forEach((e,t)=>{let n=!0;t.forEachWhile(e=>{let t=this.ot(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(n=!1,!1)}),n&&(r=r.add(e))}),this.je.forEach((t,r)=>r.setReadTime(e));let n=new on(e,t,this.Ze,this.je,r);return this.je=aw,this.Je=oh(),this.He=oh(),this.Ze=new iX(nn),n}
5Ye(e,t){if(!this.rt(e))return;let r=2*!!this.It(e,t.key);this.nt(e).Ke(t.key,r),this.je=this.je.insert(t.key,t),this.Je=this.Je.insert(t.key,this.Et(t.key).add(e)),this.He=this.He.insert(t.key,this.Rt(t.key).add(e))}et(e,t,r){if(!this.rt(e))return;let n=this.nt(e);this.It(e,t)?n.Ke(t,1):n.Ue(t),this.He=this.He.insert(t,this.Rt(t).delete(e)),this.He=this.He.insert(t,this.Rt(t).add(e)),r&&(this.je=this.je.insert(t,r))}removeTarget(e){this.ze.delete(e)}_t(e){let t=this.nt(e).ke();return this.Ge.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.nt(e).$e()}nt(e){let t=this.ze.get(e);return t||(t=new ol,this.ze.set(e,t)),t}Rt(e){let t=this.He.get(e);return t||(t=new i1(nn),this.He=this.He.insert(e,t)),t}Et(e){let t=this.Je.get(e);return t||(t=new i1(nn),this.Je=this.Je.insert(e,t)),t}rt(e){let t=null!==this.ot(e);return t||rW("WatchChangeAggregator","Detected inactive target",e),t}ot(e){let t=this.ze.get(e);return t&&t.Ne?null:this.Ge.At(e)}it(e){this.ze.set(e,new ol),this.Ge.getRemoteKeysForTarget(e).forEach(t=>{this.et(e,t,null)})}It(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}}function oh(){return new iX(nd.comparator)}function oc(){return new iX(nd.comparator)}let od={asc:"ASCENDING",desc:"DESCENDING"},of={"<":"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"},op={and:"AND",or:"OR"};class og{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function om(e,t){return e.useProto3Json||nJ(t)?t:{value:t}}function oy(e,t){return e.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function ow(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function ov(e){let t;return r0(!!e,49232),nI.fromTimestamp(new nv((t=i9(e)).seconds,t.nanos))}function oI(e,t){return ob(e,t).canonicalString()}function ob(e,t){let r=new nu(["projects",e.projectId,"databases",e.database]).child("documents");return void 0===t?r:r.child(t)}function oE(e){let t=nu.fromString(e);return r0(oF(t),10190,{key:t.toString()}),t}function oT(e,t){return oI(e.databaseId,t.path)}function o_(e,t){let r=oE(t);if(r.get(1)!==e.databaseId.projectId)throw new r2(r1.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+r.get(1)+" vs "+e.databaseId.projectId);if(r.get(3)!==e.databaseId.database)throw new r2(r1.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+r.get(3)+" vs "+e.databaseId.database);return new nd(oA(r))}function oS(e,t){return oI(e.databaseId,t)}function oC(e){let t=oE(e);return 4===t.length?nu.emptyPath():oA(t)}function ok(e){return new nu(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function oA(e){return r0(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}function ox(e,t,r){return{name:oT(e,t),fields:r.value.mapValue.fields}}function oN(e,t,r){let n=o_(e,t.name),i=ov(t.updateTime),s=t.createTime?ov(t.createTime):nI.min(),a=new sV({mapValue:{fields:t.fields}}),o=sF.newFoundDocument(n,i,s,a);return r&&o.setHasCommittedMutations(),r?o.setHasCommittedMutations():o}function oR(e,t){var r,n;let i;if(t instanceof aH)i={update:ox(e,t.key,t.value)};else if(t instanceof aX)i={delete:oT(e,t.key)};else if(t instanceof aW){let r;i={update:ox(e,t.key,t.data),updateMask:(n=t.fieldMask,r=[],n.fields.forEach(e=>r.push(e.canonicalString())),{fieldPaths:r})}}else{if(!(t instanceof aZ))return rX(16599,{dt:t.type});i={verify:oT(e,t.key)}}return t.fieldTransforms.length>0&&(i.updateTransforms=t.fieldTransforms.map(e=>(function(e){let t=e.transform;if(t instanceof aR)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(t instanceof aD)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:t.elements}};if(t instanceof aO)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:t.elements}};if(t instanceof aM)return{fieldPath:e.field.canonicalString(),increment:t.Ae};throw rX(20930,{transform:e.transform})})(e))),t.precondition.isNone||(i.currentDocument=void 0!==(r=t.precondition).updateTime?{updateTime:oy(e,r.updateTime.toTimestamp())}:void 0!==r.exists?{exists:r.exists}:rX(27497)),i}function oD(e,t){var r;let n=t.currentDocument?void 0!==(r=t.currentDocument).updateTime?aj.updateTime(ov(r.updateTime)):void 0!==r.exists?aj.exists(r.exists):aj.none():aj.none(),i=t.updateTransforms?t.updateTransforms.map(t=>{let r;return r=null,"setToServerValue"in t?(r0("REQUEST_TIME"===t.setToServerValue,16630,{proto:t}),r=new aR):"appendMissingElements"in t?r=new aD(t.appendMissingElements.values||[]):"removeAllFromArray"in t?r=new aO(t.removeAllFromArray.values||[]):"increment"in t?r=new aM(e,t.increment):rX(16584,{proto:t}),new aU(nc.fromServerFormat(t.fieldPath),r)}):[];if(t.update){t.update.name;let r=o_(e,t.update.name),s=new sV({mapValue:{fields:t.update.fields}});return t.updateMask?new aW(r,s,new i6((t.updateMask.fieldPaths||[]).map(e=>nc.fromServerFormat(e))),n,i):new aH(r,s,n,i)}return t.delete?new aX(o_(e,t.delete),n):t.verify?new aZ(o_(e,t.verify),n):rX(1463,{proto:t})}function oP(e,t){return{documents:[oS(e,t.path)]}}function oO(e,t){var r,n;let i,s={structuredQuery:{}},a=t.path;null!==t.collectionGroup?(i=a,s.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=a.popLast(),s.structuredQuery.from=[{collectionId:a.lastSegment()}]),s.parent=oS(e,i);let o=function(e){if(0!==e.length)return function e(t){var r;let n;return t instanceof sK?function(e){if("=="===e.op){if(sx(e.value))return{unaryFilter:{field:oM(e.field),op:"IS_NAN"}};if(sA(e.value))return{unaryFilter:{field:oM(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(sx(e.value))return{unaryFilter:{field:oM(e.field),op:"IS_NOT_NA
5N"}};if(sA(e.value))return{unaryFilter:{field:oM(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:oM(e.field),op:of[e.op],value:e.value}}}(t):t instanceof s$?1===(n=(r=t).getFilters().map(t=>e(t))).length?n[0]:{compositeFilter:{op:op[r.op],filters:n}}:rX(54877,{filter:t})}(s$.create(e,"and"))}(t.filters);o&&(s.structuredQuery.where=o);let l=function(e){if(0!==e.length)return e.map(e=>({field:oM(e.field),direction:od[e.dir]}))}(t.orderBy);l&&(s.structuredQuery.orderBy=l);let u=om(e,t.limit);return null!==u&&(s.structuredQuery.limit=u),t.startAt&&(s.structuredQuery.startAt={before:(r=t.startAt).inclusive,values:r.position}),t.endAt&&(s.structuredQuery.endAt={before:!(n=t.endAt).inclusive,values:n.position}),{ft:s,parent:i}}function oL(e){var t,r,n;let i,s,a,o,l=oC(e.parent),u=e.structuredQuery,h=u.from?u.from.length:0,c=null;if(h>0){r0(1===h,65062);let e=u.from[0];e.allDescendants?c=e.collectionId:l=l.child(e.collectionId)}let d=[];u.where&&(d=(i=function e(t){return void 0!==t.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":let t=oV(e.unaryFilter.field);return sK.create(t,"==",{doubleValue:NaN});case"IS_NULL":let r=oV(e.unaryFilter.field);return sK.create(r,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let n=oV(e.unaryFilter.field);return sK.create(n,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let i=oV(e.unaryFilter.field);return sK.create(i,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return rX(61313);default:return rX(60726)}}(t):void 0!==t.fieldFilter?sK.create(oV(t.fieldFilter.field),function(e){switch(e){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return rX(58110);default:return rX(50506)}}(t.fieldFilter.op),t.fieldFilter.value):void 0!==t.compositeFilter?s$.create(t.compositeFilter.filters.map(t=>e(t)),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return rX(1026)}}(t.compositeFilter.op)):rX(30097,{filter:t})}(u.where))instanceof s$&&sW(i)?i.getFilters():[i]);let f=[];u.orderBy&&(f=u.orderBy.map(e=>new sq(oV(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))));let p=null;u.limit&&(p=nJ(s="object"==typeof(t=u.limit)?t.value:t)?null:s);let g=null;u.startAt&&(a=!!(r=u.startAt).before,g=new sU(r.values||[],a));let m=null;return u.endAt&&(o=!(n=u.endAt).before,m=new sU(n.values||[],o)),new an(l,c,f,d,p,"F",g,m)}function oM(e){return{fieldPath:e.canonicalString()}}function oV(e){return nc.fromServerFormat(e.fieldPath)}function oF(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}function oU(e){return!!e&&"function"==typeof e._toProto&&"ProtoValue"===e._protoValueType}class oB{constructor(e,t,r,n,i=nI.min(),s=nI.min(),a=i8.EMPTY_BYTE_STRING,o=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=n,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=a,this.expectedCount=o}withSequenceNumber(e){return new oB(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new oB(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new oB(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new oB(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class oj{constructor(e){this.yt=e}}function oq(e,t){let r=t.key,n={prefixPath:r.getCollectionPath().popLast().toArray(),collectionGroup:r.collectionGroup,documentId:r.path.lastSegment(),readTime:oz(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument()){var i;n.document={name:oT(i=e.yt,t.key),fields:t.data.value.mapValue.fields,updateTime:oy(i,t.version.toTimestamp()),createTime:oy(i,t.createTime.toTimestamp())}}else if(t.isNoDocument())n.noDocument={path:r.path.toArray(),readTime:oK(t.version)};else{if(!t.isUnknownDocument())return rX(57904,{document:t});n.unknownDocument={path:r.path.toArray(),version:oK(t.version)}}return n}function oz(e){let t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function oK(e){let t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function o$(e){let t=new nv(e.seconds,e.nanoseconds);return nI.fromTimestamp(t)}function oG(e,t){let r=(t.baseMutations||[]).map(t=>oD(e.yt,t));for(let e=0;e<t.mutations.length-1;++e){let r=t.mutations[e];e+1<t.mutations.length&&void 0!==t.mutations[e+1].transform&&(r.updateTransforms=t.mutations[e+1].transform.fieldTransforms,t.mutations.splice(e+1,1),++e)}let n=t.mutations.map(t=>oD(e.yt,t)),i=nv.fromMillis(t.localWriteTimeMs);return new a0(t.batchId,i,r,n)}function oH(e){var t;let r,n=o$(e.readTime),i=void 0!==e.lastLimboFreeSnapshotVersion?o$(e.lastLimboFreeSnapshotVersion):nI.min();return new oB(void 0!==e.query.documents?(r0(1===(r=(t=e.query).documents.length),1966,{count:r}),al(ai(oC(t.documents[0])))):al(oL(e.query)),e.targetId,"TargetPurposeListen",e.lastListenSequenceNumber,n,i,i8.fromBase64String(e.resumeToken))}function oW(e,t){let r,n=oK(t.snapshotVersion),i=oK(t.lastLimboFreeSnapshotVersion);r=s7(t.target)?oP(e.yt,t.target):oO(e.yt,t.target).ft;let s=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:s4(t.target),readTime:n,resumeToken:s,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:i,query:r}}function oQ(e){let t=oL({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?ah(t,t.limit,"L"):t}function oJ(e,t){return new a2(t.largestBatchId,oD(e.yt,t.overlayMutation))}function oY(e,t){let r=t.path.lastSegment();return[e,nZ(t.path.popLast()),r]}function oX(e,t,r,n){return{indexId:e,uid:t,sequenceNumber:r,readTime:oK(n.readTime),documentKey:nZ(n.documentKey.path),largestBatchId:n.largestBatchId}}class oZ{getBundleMetadata(e,t){return iW(e,iT).get(t).next(e=>{if(e)return{id:e.bundleId,createTime:o$(e.createTime),version:e.version}})}saveBundleMetadata(e,t){return iW(e,iT).put({bundleId:t.id,createTime:oK(ov(t.createTime)),version:t.version})}getNamedQuery(e,t){return iW(e,i_).get(t).next(e=>{if(e)return{name:e.name,query:oQ(e.bundledQuery),readTime:o$(e.readTime)}})}saveNamedQuery(e,t){return iW(e,i_).put({name:t.name,readTime:oK(ov(t.readTime)),bundledQuery:t.bundledQuery})}}
5class o0{constructor(e,t){this.serializer=e,this.userId=t}static wt(e,t){return new o0(e,t.uid||"")}getOverlay(e,t){return iW(e,iL).get(oY(this.userId,t)).next(e=>e?oJ(this.serializer,e):null)}getOverlays(e,t){let r=aE();return nO.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&r.set(t,e)})).next(()=>r)}saveOverlays(e,t,r){let n=[];return r.forEach((r,i)=>{let s=new a2(t,i);n.push(this.St(e,s))}),nO.waitFor(n)}removeOverlaysForBatchId(e,t,r){let n=new Set;t.forEach(e=>n.add(nZ(e.getCollectionPath())));let i=[];return n.forEach(t=>{let n=IDBKeyRange.bound([this.userId,t,r],[this.userId,t,r+1],!1,!0);i.push(iW(e,iL).X(iV,n))}),nO.waitFor(i)}getOverlaysForCollection(e,t,r){let n=aE(),i=nZ(t),s=IDBKeyRange.bound([this.userId,i,r],[this.userId,i,1/0],!0);return iW(e,iL).J(iV,s).next(e=>{for(let t of e){let e=oJ(this.serializer,t);n.set(e.getKey(),e)}return n})}getOverlaysForCollectionGroup(e,t,r,n){let i,s=aE(),a=IDBKeyRange.bound([this.userId,t,r],[this.userId,t,1/0],!0);return iW(e,iL).ee({index:iU,range:a},(e,t,r)=>{let a=oJ(this.serializer,t);s.size()<n||a.largestBatchId===i?(s.set(a.getKey(),a),i=a.largestBatchId):r.done()}).next(()=>s)}St(e,t){return iW(e,iL).put(function(e,t,r){let[n,i,s]=oY(t,r.mutation.key);return{userId:t,collectionPath:i,documentId:s,collectionGroup:r.mutation.key.getCollectionGroup(),largestBatchId:r.largestBatchId,overlayMutation:oR(e.yt,r.mutation)}}(this.serializer,this.userId,t))}}class o1{bt(e){return iW(e,ij)}getSessionToken(e){return this.bt(e).get("sessionToken").next(e=>{let t=e?.value;return t?i8.fromUint8Array(t):i8.EMPTY_BYTE_STRING})}setSessionToken(e,t){return this.bt(e).put({name:"sessionToken",value:t.toUint8Array()})}}class o2{Dt(e,t){this.Ct(e,t),t.vt()}Ct(e,t){if("nullValue"in e)this.Ft(t,5);else if("booleanValue"in e)this.Ft(t,10),t.Mt(+!!e.booleanValue);else if("integerValue"in e)this.Ft(t,15),t.Mt(i7(e.integerValue));else if("doubleValue"in e){let r=i7(e.doubleValue);isNaN(r)?this.Ft(t,13):(this.Ft(t,15),nY(r)?t.Mt(0):t.Mt(r))}else if("timestampValue"in e){let r=e.timestampValue;this.Ft(t,20),"string"==typeof r&&(r=i9(r)),t.xt(`${r.seconds||""}`),t.Mt(r.nanos||0)}else if("stringValue"in e)this.Ot(e.stringValue,t),this.Nt(t);else if("bytesValue"in e)this.Ft(t,30),t.Bt(se(e.bytesValue)),this.Nt(t);else if("referenceValue"in e)this.Lt(e.referenceValue,t);else if("geoPointValue"in e){let r=e.geoPointValue;this.Ft(t,45),t.Mt(r.latitude||0),t.Mt(r.longitude||0)}else"mapValue"in e?sP(e)?this.Ft(t,Number.MAX_SAFE_INTEGER):sR(e)?this.kt(e.mapValue,t):(this.qt(e.mapValue,t),this.Nt(t)):"arrayValue"in e?(this.Kt(e.arrayValue,t),this.Nt(t)):rX(19022,{Ut:e})}Ot(e,t){this.Ft(t,25),this.$t(e,t)}$t(e,t){t.xt(e)}qt(e,t){let r=e.fields||{};for(let e of(this.Ft(t,55),Object.keys(r)))this.Ot(e,t),this.Ct(r[e],t)}kt(e,t){let r=e.fields||{};this.Ft(t,53);let n=r[sm].arrayValue?.values?.length||0;this.Ft(t,15),t.Mt(i7(n)),this.Ot(sm,t),this.Ct(r[sm],t)}Kt(e,t){let r=e.values||[];for(let e of(this.Ft(t,50),r))this.Ct(e,t)}Lt(e,t){this.Ft(t,37),nd.fromName(e).path.forEach(e=>{this.Ft(t,60),this.$t(e,t)})}Ft(e,t){e.Mt(t)}Nt(e){e.Mt(2)}}function o5(e){return Math.ceil((64-function(e){let t=0;for(let r=0;r<8;++r){let n=function(e){if(0===e)return 8;let t=0;return e>>4||(t+=4,e<<=4),e>>6||(t+=2,e<<=2),e>>7||(t+=1),t}(255&e[r]);if(t+=n,8!==n)break}return t}(e))/8)}o2.Wt=new o2;class o6{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Qt(e){let t=e[Symbol.iterator](),r=t.next();for(;!r.done;)this.Gt(r.value),r=t.next();this.zt()}jt(e){let t=e[Symbol.iterator](),r=t.next();for(;!r.done;)this.Jt(r.value),r=t.next();this.Ht()}Zt(e){for(let t of e){let e=t.charCodeAt(0);if(e<128)this.Gt(e);else if(e<2048)this.Gt(960|e>>>6),this.Gt(128|63&e);else if(t<"\uD800"||"\uDBFF"<t)this.Gt(480|e>>>12),this.Gt(128|63&e>>>6),this.Gt(128|63&e);else{let e=t.codePointAt(0);this.Gt(240|e>>>18),this.Gt(128|63&e>>>12),this.Gt(128|63&e>>>6),this.Gt(128|63&e)}}this.zt()}Xt(e){for(let t of e){let e=t.charCodeAt(0);if(e<128)this.Jt(e);else if(e<2048)this.Jt(960|e>>>6),this.Jt(128|63&e);else if(t<"\uD800"||"\uDBFF"<t)this.Jt(480|e>>>12),this.Jt(128|63&e>>>6),this.Jt(128|63&e);else{let e=t.codePointAt(0);this.Jt(240|e>>>18),this.Jt(128|63&e>>>12),this.Jt(128|63&e>>>6),this.Jt(128|63&e)}}this.Ht()}Yt(e){let t=this.en(e),r=o5(t);this.tn(1+r),this.buffer[this.position++]=255&r;for(let e=t.length-r;e<t.length;++e)this.buffer[this.position++]=255&t[e]}nn(e){let t=this.en(e),r=o5(t);this.tn(1+r),this.buffer[this.position++]=~(255&r);for(let e=t.length-r;e<t.length;++e)this.buffer[this.position++]=~(255&t[e])}rn(){this.sn(255),this.sn(255)}_n(){this.an(255),this.an(255)}reset(){this.position=0}seed(e){this.tn(e.length),this.buffer.set(e,this.position),this.position+=e.length}un(){return this.buffer.slice(0,this.position)}en(e){let t,r=((t=new DataView(new ArrayBuffer(8))).setFloat64(0,e,!1),new Uint8Array(t.buffer)),n=!!(128&r[0]);r[0]^=n?255:128;for(let e=1;e<r.length;++e)r[e]^=255*!!n;return r}Gt(e){let t=255&e;0===t?(this.sn(0),this.sn(255)):255===t?(this.sn(255),this.sn(0)):this.sn(t)}Jt(e){let t=255&e;0===t?(this.an(0),this.an(255)):255===t?(this.an(255),this.an(0)):this.an(e)}zt(){this.sn(0),this.sn(1)}Ht(){this.an(0),this.an(1)}sn(e){this.tn(1),this.buffer[this.position++]=e}an(e){this.tn(1),this.buffer[this.position++]=~e}tn(e){let t=e+this.position;if(t<=this.buffer.length)return;let r=2*this.buffer.length;r<t&&(r=t);let n=new Uint8Array(r);n.set(this.buffer),this.buffer=n}}class o3{constructor(e){this.cn=e}Bt(e){this.cn.Qt(e)}xt(e){this.cn.Zt(e)}Mt(e){this.cn.Yt(e)}vt(){this.cn.rn()}}class o8{constructor(e){this.cn=e}Bt(e){this.cn.jt(e)}xt(e){this.cn.Xt(e)}Mt(e){this.cn.nn(e)}vt(){this.cn._n()}}class o4{constructor(){this.cn=new o6,this.ascending=new o3(this.cn),this.descending=new o8(this.cn)}seed(e){this.cn.seed(e)}ln(e){return 0===e?this.ascending:this.descending}un(){return this.cn.un()}reset(){this.cn.reset()}}class o9{constructor(e,t,r,n){this.hn=e,this.Pn=t,this.Tn=r,this.En=n}In(){let e=this.En.length,t=0===e||255===this.En[e-1]?e+1:e,r=new Uint8Array(t);return r.set(this.En,0),t!==e?r.set([0],this.En.length):++r[r.length-1],new o9(this.hn,this.Pn,this.Tn,r)}Rn(e,t,r){return{indexId:this.hn,uid:e,arrayValue:lt(this.Tn),directionalValue:lt(this.En),orderedDocumentKey:lt(t),documentKey:r.path.toArray()}}An(e,t,r){let n=this.Rn(e,t,r);return[n.indexId,n.uid,n.arrayValue,n.directionalValue,n.orderedDocumentKey,n.documentKey]}}function o7(e,t){let r=e.hn-t.hn;return 0!==r||0!==(r=le(e.Tn,t.Tn))||0!==(r=le(e.En,t.En))?r:nd.comparator(e.Pn,t.Pn)}function le(e,t){for(let r=0;r<e.length&&r<t.length;++r){let n=e[r]-t[r];if(0!==n)return n}return e.length-t.length}function lt(e){return(0,rF.isSafariOrWebkit)()?function(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}(e):e}function lr(e){return"string"!=typeof e?e:function(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}(e)}class ln{constructor(e){for(const t of(this.Vn=new i1((e,t)=>nc.comparator(e.field,t.field)),this.collectionId=null!=e.collectionGroup?e.collectionGroup:e.path.lastSegment(),this.dn=e.orderBy,this.mn=[],e.filters))t.isInequality()?this.Vn=this.Vn.add(t):this.mn.push(t)}get fn(){return this.Vn.size>1}gn(e){if(r0(e.collectionGroup===this.collectionId,49279),this.fn)return!1;let t=nE(e);if(void 0!==t&&!this.pn(t))return!1;let r=nT(e),n=new Set,i=0,s=0;for(;i<r.length&&this.pn(r[i]);++i)n=n.add(r[i].fieldPath.canonicalString());if(i===r.length)return!0;
5if(this.Vn.size>0){let e=this.Vn.getIterator().getNext();if(!n.has(e.field.canonicalString())){let t=r[i];if(!this.yn(e,t)||!this.wn(this.dn[s++],t))return!1}++i}for(;i<r.length;++i){let e=r[i];if(s>=this.dn.length||!this.wn(this.dn[s++],e))return!1}return!0}Sn(){if(this.fn)return null;let e=new i1(nc.comparator),t=[];for(let r of this.mn)if(!r.field.isKeyField())if("array-contains"===r.op||"array-contains-any"===r.op)t.push(new nS(r.field,2));else{if(e.has(r.field))continue;e=e.add(r.field),t.push(new nS(r.field,0))}for(let r of this.dn)r.field.isKeyField()||e.has(r.field)||(e=e.add(r.field),t.push(new nS(r.field,+("asc"!==r.dir))));return new nb(nb.UNKNOWN_ID,this.collectionId,t,nC.empty())}pn(e){for(let t of this.mn)if(this.yn(t,e))return!0;return!1}yn(e,t){if(void 0===e||!e.field.isEqual(t.fieldPath))return!1;let r="array-contains"===e.op||"array-contains-any"===e.op;return 2===t.kind===r}wn(e,t){return!!e.field.isEqual(t.fieldPath)&&(0===t.kind&&"asc"===e.dir||1===t.kind&&"desc"===e.dir)}}function li(e){return e instanceof sK}function ls(e){return e instanceof s$&&sW(e)}function la(e){return li(e)||ls(e)||function(e){if(e instanceof s$&&sH(e)){for(let t of e.getFilters())if(!li(t)&&!ls(t))return!1;return!0}return!1}(e)}function lo(e,t){return r0(e instanceof sK||e instanceof s$,38388),r0(t instanceof sK||t instanceof s$,25473),lu(e instanceof sK?t instanceof sK?s$.create([e,t],"and"):ll(e,t):t instanceof sK?ll(t,e):function(e,t){if(r0(e.filters.length>0&&t.filters.length>0,48005),sG(e)&&sG(t))return sJ(e,t.getFilters());let r=sH(e)?e:t,n=sH(e)?t:e,i=r.filters.map(e=>lo(e,n));return s$.create(i,"or")}(e,t))}function ll(e,t){if(sG(t))return sJ(t,e.getFilters());{let r=t.filters.map(t=>lo(e,t));return s$.create(r,"or")}}function lu(e){if(r0(e instanceof sK||e instanceof s$,11850),e instanceof sK)return e;let t=e.getFilters();if(1===t.length)return lu(t[0]);if(sQ(e))return e;let r=t.map(e=>lu(e)),n=[];return r.forEach(t=>{t instanceof sK?n.push(t):t instanceof s$&&(t.op===e.op?n.push(...t.filters):n.push(t))}),1===n.length?n[0]:s$.create(n,e.op)}class lh{constructor(){this.bn=new lc}addToCollectionParentIndex(e,t){return this.bn.add(t),nO.resolve()}getCollectionParents(e,t){return nO.resolve(this.bn.getEntries(t))}addFieldIndex(e,t){return nO.resolve()}deleteFieldIndex(e,t){return nO.resolve()}deleteAllFieldIndexes(e){return nO.resolve()}createTargetIndexes(e,t){return nO.resolve()}getDocumentsMatchingTarget(e,t){return nO.resolve(null)}getIndexType(e,t){return nO.resolve(0)}getFieldIndexes(e,t){return nO.resolve([])}getNextCollectionGroupToUpdate(e){return nO.resolve(null)}getMinOffset(e,t){return nO.resolve(nx.min())}getMinOffsetFromCollectionGroup(e,t){return nO.resolve(nx.min())}updateCollectionGroup(e,t,r){return nO.resolve()}updateIndexEntries(e,t){return nO.resolve()}}class lc{constructor(){this.index={}}add(e){let t=e.lastSegment(),r=e.popLast(),n=this.index[t]||new i1(nu.comparator),i=!n.has(r);return this.index[t]=n.add(r),i}has(e){let t=e.lastSegment(),r=e.popLast(),n=this.index[t];return n&&n.has(r)}getEntries(e){return(this.index[e]||new i1(nu.comparator)).toArray()}}let ld="IndexedDbIndexManager",lf=new Uint8Array(0);class lp{constructor(e,t){this.databaseId=t,this.Dn=new lc,this.Cn=new ay(e=>s4(e),(e,t)=>s9(e,t)),this.uid=e.uid||""}addToCollectionParentIndex(e,t){if(!this.Dn.has(t)){let r=t.lastSegment(),n=t.popLast();e.addOnCommittedListener(()=>{this.Dn.add(t)});let i={collectionId:r,parent:nZ(n)};return iW(e,iI).put(i)}return nO.resolve()}getCollectionParents(e,t){let r=[],n=IDBKeyRange.bound([t,""],[t+"\0",""],!1,!0);return iW(e,iI).J(n).next(e=>{for(let n of e){if(n.collectionId!==t)break;r.push(n0(n.parent))}return r})}addFieldIndex(e,t){let r=iW(e,iS),n={indexId:t.indexId,collectionGroup:t.collectionGroup,fields:t.fields.map(e=>[e.fieldPath.canonicalString(),e.kind])};delete n.indexId;let i=r.add(n);if(t.indexState){let r=iW(e,ik);return i.next(e=>{r.put(oX(e,this.uid,t.indexState.sequenceNumber,t.indexState.offset))})}return i.next()}deleteFieldIndex(e,t){let r=iW(e,iS),n=iW(e,ik),i=iW(e,iR);return r.delete(t.indexId).next(()=>n.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))).next(()=>i.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0)))}deleteAllFieldIndexes(e){let t=iW(e,iS),r=iW(e,iR),n=iW(e,ik);return t.X().next(()=>r.X()).next(()=>n.X())}createTargetIndexes(e,t){return nO.forEach(this.vn(t),t=>this.getIndexType(e,t).next(r=>{if(0===r||1===r){let r=new ln(t).Sn();if(null!=r)return this.addFieldIndex(e,r)}}))}getDocumentsMatchingTarget(e,t){let r=iW(e,iR),n=!0,i=new Map;return nO.forEach(this.vn(t),t=>this.Fn(e,t).next(e=>{n&&(n=!!e),i.set(t,e)})).next(()=>{if(n){let e=aS(),n=[];return nO.forEach(i,(i,s)=>{rW(ld,`Using index id=${i.indexId}|cg=${i.collectionGroup}|f=${i.fields.map(e=>`${e.fieldPath}:${e.kind}`).join(",")} to execute ${s4(t)}`);let a=function(e,t){let r=nE(t);if(void 0===r)return null;for(let t of ae(e,r.fieldPath))switch(t.op){case"array-contains-any":return t.value.arrayValue.values||[];case"array-contains":return[t.value]}return null}(s,i),o=function(e,t){let r=new Map;for(let n of nT(t))for(let t of ae(e,n.fieldPath))switch(t.op){case"==":case"in":r.set(n.fieldPath.canonicalString(),t.value);break;case"not-in":case"!=":return r.set(n.fieldPath.canonicalString(),t.value),Array.from(r.values())}return null}(s,i),l=function(e,t){let r=[],n=!0;for(let i of nT(t)){let t=0===i.kind?at(e,i.fieldPath,e.startAt):ar(e,i.fieldPath,e.startAt);r.push(t.value),n&&(n=t.inclusive)}return new sU(r,n)}(s,i),u=function(e,t){let r=[],n=!0;for(let i of nT(t)){let t=0===i.kind?ar(e,i.fieldPath,e.endAt):at(e,i.fieldPath,e.endAt);r.push(t.value),n&&(n=t.inclusive)}return new sU(r,n)}(s,i),h=this.Mn(i,s,l),c=this.Mn(i,s,u),d=this.xn(i,s,o),f=this.On(i.indexId,a,h,l.inclusive,c,u.inclusive,d);return nO.forEach(f,i=>r.Z(i,t.limit).next(t=>{t.forEach(t=>{let r=nd.fromSegments(t.documentKey);e.has(r)||(e=e.add(r),n.push(r))})}))}).next(()=>n)}return nO.resolve(null)})}vn(e){let t=this.Cn.get(e);return t||(t=0===e.filters.length?[e]:(function(e){if(0===e.getFilters().length)return[];let t=function e(t){if(r0(t instanceof sK||t instanceof s$,34018),t instanceof sK)return t;if(1===t.filters.length)return e(t.filters[0]);let r=t.filters.map(t=>e(t)),n=s$.create(r,t.op);return la(n=lu(n))?n:(r0(n instanceof s$,64498),r0(sG(n),40251),r0(n.filters.length>1,57927),n.filters.reduce((e,t)=>
5lo(e,t)))}(function e(t){if(r0(t instanceof sK||t instanceof s$,20012),t instanceof sK){if(t instanceof s2){let e=t.value.arrayValue?.values?.map(e=>sK.create(t.field,"==",e))||[];return s$.create(e,"or")}return t}let r=t.filters.map(t=>e(t));return s$.create(r,t.op)}(e));return r0(la(t),7391),li(t)||ls(t)?[t]:t.getFilters()})(s$.create(e.filters,"and")).map(t=>s8(e.path,e.collectionGroup,e.orderBy,t.getFilters(),e.limit,e.startAt,e.endAt)),this.Cn.set(e,t)),t}On(e,t,r,n,i,s,a){let o=(null!=t?t.length:1)*Math.max(r.length,i.length),l=o/(null!=t?t.length:1),u=[];for(let h=0;h<o;++h){let o=t?this.Nn(t[h/l]):lf,c=this.Bn(e,o,r[h%l],n),d=this.Ln(e,o,i[h%l],s),f=a.map(t=>this.Bn(e,o,t,!0));u.push(...this.createRange(c,d,f))}return u}Bn(e,t,r,n){let i=new o9(e,nd.empty(),t,r);return n?i:i.In()}Ln(e,t,r,n){let i=new o9(e,nd.empty(),t,r);return n?i.In():i}Fn(e,t){let r=new ln(t),n=null!=t.collectionGroup?t.collectionGroup:t.path.lastSegment();return this.getFieldIndexes(e,n).next(e=>{let t=null;for(let n of e)r.gn(n)&&(!t||n.fields.length>t.fields.length)&&(t=n);return t})}getIndexType(e,t){let r=2,n=this.vn(t);return nO.forEach(n,t=>this.Fn(e,t).next(e=>{e?0!==r&&e.fields.length<function(e){let t=new i1(nc.comparator),r=!1;for(let n of e.filters)for(let e of n.getFlattenedFilters())e.field.isKeyField()||("array-contains"===e.op||"array-contains-any"===e.op?r=!0:t=t.add(e.field));for(let r of e.orderBy)r.field.isKeyField()||(t=t.add(r.field));return t.size+ +!!r}(t)&&(r=1):r=0})).next(()=>null!==t.limit&&n.length>1&&2===r?1:r)}kn(e,t){let r=new o4;for(let n of nT(e)){let e=t.data.field(n.fieldPath);if(null==e)return null;let i=r.ln(n.kind);o2.Wt.Dt(e,i)}return r.un()}Nn(e){let t=new o4;return o2.Wt.Dt(e,t.ln(0)),t.un()}qn(e,t){let r,n=new o4;return o2.Wt.Dt(sS(this.databaseId,t),n.ln(0===(r=nT(e)).length?0:r[r.length-1].kind)),n.un()}xn(e,t,r){if(null===r)return[];let n=[];n.push(new o4);let i=0;for(let s of nT(e)){let e=r[i++];for(let r of n)if(this.Kn(t,s.fieldPath)&&sk(e))n=this.Un(n,s,e);else{let t=r.ln(s.kind);o2.Wt.Dt(e,t)}}return this.$n(n)}Mn(e,t,r){return this.xn(e,t,r.position)}$n(e){let t=[];for(let r=0;r<e.length;++r)t[r]=e[r].un();return t}Un(e,t,r){let n=[...e],i=[];for(let e of r.arrayValue.values||[])for(let r of n){let n=new o4;n.seed(r.un()),o2.Wt.Dt(e,n.ln(t.kind)),i.push(n)}return i}Kn(e,t){return!!e.filters.find(e=>e instanceof sK&&e.field.isEqual(t)&&("in"===e.op||"not-in"===e.op))}getFieldIndexes(e,t){let r=iW(e,iS),n=iW(e,ik);return(t?r.J(iC,IDBKeyRange.bound(t,t)):r.J()).next(e=>{let t=[];return nO.forEach(e,e=>n.get([e.indexId,this.uid]).next(r=>{let n,i;t.push((n=r?new nC(r.sequenceNumber,new nx(o$(r.readTime),new nd(n0(r.documentKey)),r.largestBatchId)):nC.empty(),i=e.fields.map(([e,t])=>new nS(nc.fromServerFormat(e),t)),new nb(e.indexId,e.collectionGroup,i,n)))})).next(()=>t)})}getNextCollectionGroupToUpdate(e){return this.getFieldIndexes(e).next(e=>0===e.length?null:(e.sort((e,t)=>{let r=e.indexState.sequenceNumber-t.indexState.sequenceNumber;return 0!==r?r:nn(e.collectionGroup,t.collectionGroup)}),e[0].collectionGroup))}updateCollectionGroup(e,t,r){let n=iW(e,iS),i=iW(e,ik);return this.Wn(e).next(e=>n.J(iC,IDBKeyRange.bound(t,t)).next(t=>nO.forEach(t,t=>i.put(oX(t.indexId,this.uid,e,r)))))}updateIndexEntries(e,t){let r=new Map;return nO.forEach(t,(t,n)=>{let i=r.get(t.collectionGroup);return(i?nO.resolve(i):this.getFieldIndexes(e,t.collectionGroup)).next(i=>(r.set(t.collectionGroup,i),nO.forEach(i,r=>this.Qn(e,t,r).next(t=>{let i=this.Gn(n,r);return t.isEqual(i)?nO.resolve():this.zn(e,n,r,t,i)}))))})}jn(e,t,r,n){return iW(e,iR).put(n.Rn(this.uid,this.qn(r,t.key),t.key))}Jn(e,t,r,n){return iW(e,iR).delete(n.An(this.uid,this.qn(r,t.key),t.key))}Qn(e,t,r){let n=iW(e,iR),i=new i1(o7);return n.ee({index:iP,range:IDBKeyRange.only([r.indexId,this.uid,lt(this.qn(r,t))])},(e,n)=>{i=i.add(new o9(r.indexId,t,lr(n.arrayValue),lr(n.directionalValue)))}).next(()=>i)}Gn(e,t){let r=new i1(o7),n=this.kn(t,e);if(null==n)return r;let i=nE(t);if(null!=i){let s=e.data.field(i.fieldPath);if(sk(s))for(let i of s.arrayValue.values||[])r=r.add(new o9(t.indexId,e.key,this.Nn(i),n))}else r=r.add(new o9(t.indexId,e.key,lf,n));return r}zn(e,t,r,n,i){rW(ld,"Updating index entries for document '%s'",t.key);let s=[];return function(e,t,r,n,i){let s=e.getIterator(),a=t.getIterator(),o=i5(s),l=i5(a);for(;o||l;){let e=!1,t=!1;if(o&&l){let n=r(o,l);n<0?t=!0:n>0&&(e=!0)}else null!=o?t=!0:e=!0;e?(n(l),l=i5(a)):t?(i(o),o=i5(s)):(o=i5(s),l=i5(a))}}(n,i,o7,n=>{s.push(this.jn(e,t,r,n))},n=>{s.push(this.Jn(e,t,r,n))}),nO.waitFor(s)}Wn(e){let t=1;return iW(e,ik).ee({index:ix,reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},(e,r,n)=>{n.done(),t=r.sequenceNumber+1}
5).next(()=>t)}createRange(e,t,r){r=r.sort((e,t)=>o7(e,t)).filter((e,t,r)=>!t||0!==o7(e,r[t-1]));let n=[];for(let i of(n.push(e),r)){let r=o7(i,e),s=o7(i,t);if(0===r)n[0]=e.In();else if(r>0&&s<0)n.push(i),n.push(i.In());else if(s>0)break}n.push(t);let i=[];for(let e=0;e<n.length;e+=2){if(this.Hn(n[e],n[e+1]))return[];let t=n[e].An(this.uid,lf,nd.empty()),r=n[e+1].An(this.uid,lf,nd.empty());i.push(IDBKeyRange.bound(t,r))}return i}Hn(e,t){return o7(e,t)>0}getMinOffsetFromCollectionGroup(e,t){return this.getFieldIndexes(e,t).next(lg)}getMinOffset(e,t){return nO.mapArray(this.vn(t),t=>this.Fn(e,t).next(e=>e||rX(44426))).next(lg)}}function lg(e){r0(0!==e.length,28825);let t=e[0].indexState.offset,r=t.largestBatchId;for(let n=1;n<e.length;n++){let i=e[n].indexState.offset;0>nN(i,t)&&(t=i),r<i.largestBatchId&&(r=i.largestBatchId)}return new nx(t.readTime,t.documentKey,r)}let lm={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class ly{static withCacheSize(e){return new ly(e,ly.DEFAULT_COLLECTION_PERCENTILE,ly.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}function lw(e,t,r){let n=e.store(n3),i=e.store(ie),s=[],a=IDBKeyRange.only(r.batchId),o=0,l=n.ee({range:a},(e,t,r)=>(o++,r.delete()));s.push(l.next(()=>{r0(1===o,47070,{batchId:r.batchId})}));let u=[];for(let e of r.mutations){var h,c;let n=(h=e.key.path,c=r.batchId,[t,nZ(h),c]);s.push(i.delete(n)),u.push(e.key)}return nO.waitFor(s).next(()=>u)}function lv(e){let t;if(!e)return 0;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw rX(14731);t=e.noDocument}return JSON.stringify(t).length}ly.DEFAULT_COLLECTION_PERCENTILE=10,ly.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,ly.DEFAULT=new ly(0x2800000,ly.DEFAULT_COLLECTION_PERCENTILE,ly.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),ly.DISABLED=new ly(-1,0,0);class lI{constructor(e,t,r,n){this.userId=e,this.serializer=t,this.indexManager=r,this.referenceDelegate=n,this.Zn={}}static wt(e,t,r,n){return r0(""!==e.uid,64387),new lI(e.isAuthenticated()?e.uid:"",t,r,n)}checkEmpty(e){let t=!0,r=IDBKeyRange.bound([this.userId,-1/0],[this.userId,1/0]);return lE(e).ee({index:n4,range:r},(e,r,n)=>{t=!1,n.done()}).next(()=>t)}addMutationBatch(e,t,r,n){let i=iW(e,ie),s=lE(e);return s.add({}).next(a=>{var o,l,u,h;let c,d;r0("number"==typeof a,49019);let f=new a0(a,t,r,n),p=(o=this.serializer,l=this.userId,c=f.baseMutations.map(e=>oR(o.yt,e)),d=f.mutations.map(e=>oR(o.yt,e)),{userId:l,batchId:f.batchId,localWriteTimeMs:f.localWriteTime.toMillis(),baseMutations:c,mutations:d}),g=[],m=new i1((e,t)=>nn(e.canonicalString(),t.canonicalString()));for(let e of n){let t=(u=this.userId,h=e.key.path,[u,nZ(h),a]);m=m.add(e.key.path.popLast()),g.push(s.put(p)),g.push(i.put(t,n7))}return m.forEach(t=>{g.push(this.indexManager.addToCollectionParentIndex(e,t))}),e.addOnCommittedListener(()=>{this.Zn[a]=f.keys()}),nO.waitFor(g).next(()=>f)})}lookupMutationBatch(e,t){return lE(e).get(t).next(e=>e?(r0(e.userId===this.userId,48,"Unexpected user for mutation batch",{userId:e.userId,batchId:t}),oG(this.serializer,e)):null)}Xn(e,t){return this.Zn[t]?nO.resolve(this.Zn[t]):this.lookupMutationBatch(e,t).next(e=>{if(e){let r=e.keys();return this.Zn[t]=r,r}return null})}getNextMutationBatchAfterBatchId(e,t){let r=t+1,n=IDBKeyRange.lowerBound([this.userId,r]),i=null;return lE(e).ee({index:n4,range:n},(e,t,n)=>{t.userId===this.userId&&(r0(t.batchId>=r,47524,{Yn:r}),i=oG(this.serializer,t)),n.done()}).next(()=>i)}getHighestUnacknowledgedBatchId(e){let t=IDBKeyRange.upperBound([this.userId,1/0]),r=-1;return lE(e).ee({index:n4,range:t,reverse:!0},(e,t,n)=>{r=t.batchId,n.done()}).next(()=>r)}getAllMutationBatches(e){let t=IDBKeyRange.bound([this.userId,-1],[this.userId,1/0]);return lE(e).J(n4,t).next(e=>e.map(e=>oG(this.serializer,e)))}getAllMutationBatchesAffectingDocumentKey(e,t){let r=[this.userId,nZ(t.path)],n=IDBKeyRange.lowerBound(r),i=[];return iW(e,ie).ee({range:n},(r,n,s)=>{let[a,o,l]=r,u=n0(o);if(a===this.userId&&t.path.isEqual(u))return lE(e).get(l).next(e=>{if(!e)throw rX(61480,{er:r,batchId:l});r0(e.userId===this.userId,10503,"Unexpected user for mutation batch",{userId:e.userId,batchId:l}),i.push(oG(this.serializer,e))});s.done()}).next(()=>i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new i1(nn),n=[];return t.forEach(t=>{let i=[this.userId,nZ(t.path)],s=IDBKeyRange.lowerBound(i),a=iW(e,ie).ee({range:s},(e,n,i)=>{let[s,a,o]=e,l=n0(a);s===this.userId&&t.path.isEqual(l)?r=r.add(o):i.done()});n.push(a)}),nO.waitFor(n).next(()=>this.tr(e,r))}getAllMutationBatchesAffectingQuery(e,t){let r=t.path,n=r.length+1,i=[this.userId,nZ(r)],s=IDBKeyRange.lowerBound(i),a=new i1(nn);return iW(e,ie).ee({range:s},(e,t,i)=>{let[s,o,l]=e,u=n0(o);s===this.userId&&r.isPrefixOf(u)?u.length===n&&(a=a.add(l)):i.done()}).next(()=>this.tr(e,a))}tr(e,t){let r=[],n=[];return t.forEach(t=>{n.push(lE(e).get(t).next(e=>{if(null===e)throw rX(35274,{batchId:t});r0(e.userId===this.userId,9748,"Unexpected user for mutation batch",{userId:e.userId,batchId:t}),r.push(oG(this.serializer,e))}))}),nO.waitFor(n).next(()=>r)}removeMutationBatch(e,t){return lw(e.le,this.userId,t).next(r=>(e.addOnCommittedListener(()=>{this.nr(t.batchId)}),nO.forEach(r,t=>this.referenceDelegate.markPotentiallyOrphaned(e,t))))}nr(e){delete this.Zn[e]}performConsistencyCheck(e){return this.checkEmpty(e).next(t=>
5{if(!t)return nO.resolve();let r=IDBKeyRange.lowerBound([this.userId]),n=[];return iW(e,ie).ee({range:r},(e,t,r)=>{if(e[0]===this.userId){let t=n0(e[1]);n.push(t)}else r.done()}).next(()=>{r0(0===n.length,56720,{rr:n.map(e=>e.canonicalString())})})})}containsKey(e,t){return lb(e,this.userId,t)}ir(e){return iW(e,n6).get(this.userId).next(e=>e||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""})}}function lb(e,t,r){let n=[t,nZ(r.path)],i=n[1],s=IDBKeyRange.lowerBound(n),a=!1;return iW(e,ie).ee({range:s,Y:!0},(e,r,n)=>{let[s,o,l]=e;s===t&&o===i&&(a=!0),n.done()}).next(()=>a)}function lE(e){return iW(e,n3)}class lT{constructor(e){this.sr=e}next(){return this.sr+=2,this.sr}static _r(){return new lT(0)}static ar(){return new lT(-1)}}class l_{constructor(e,t){this.referenceDelegate=e,this.serializer=t}allocateTargetId(e){return this.ur(e).next(t=>{let r=new lT(t.highestTargetId);return t.highestTargetId=r.next(),this.cr(e,t).next(()=>t.highestTargetId)})}getLastRemoteSnapshotVersion(e){return this.ur(e).next(e=>nI.fromTimestamp(new nv(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(e){return this.ur(e).next(e=>e.highestListenSequenceNumber)}setTargetsMetadata(e,t,r){return this.ur(e).next(n=>(n.highestListenSequenceNumber=t,r&&(n.lastRemoteSnapshotVersion=r.toTimestamp()),t>n.highestListenSequenceNumber&&(n.highestListenSequenceNumber=t),this.cr(e,n)))}addTargetData(e,t){return this.lr(e,t).next(()=>this.ur(e).next(r=>(r.targetCount+=1,this.hr(t,r),this.cr(e,r))))}updateTargetData(e,t){return this.lr(e,t)}removeTargetData(e,t){return this.removeMatchingKeysForTargetId(e,t.targetId).next(()=>iW(e,ih).delete(t.targetId)).next(()=>this.ur(e)).next(t=>(r0(t.targetCount>0,8065),t.targetCount-=1,this.cr(e,t)))}removeTargets(e,t,r){let n=0,i=[];return iW(e,ih).ee((s,a)=>{let o=oH(a);o.sequenceNumber<=t&&null===r.get(o.targetId)&&(n++,i.push(this.removeTargetData(e,o)))}).next(()=>nO.waitFor(i)).next(()=>n)}forEachTarget(e,t){return iW(e,ih).ee((e,r)=>{t(oH(r))})}ur(e){return iW(e,iv).get(iw).next(e=>(r0(null!==e,2888),e))}cr(e,t){return iW(e,iv).put(iw,t)}lr(e,t){return iW(e,ih).put(oW(this.serializer,t))}hr(e,t){let r=!1;return e.targetId>t.highestTargetId&&(t.highestTargetId=e.targetId,r=!0),e.sequenceNumber>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=e.sequenceNumber,r=!0),r}getTargetCount(e){return this.ur(e).next(e=>e.targetCount)}getTargetData(e,t){let r=s4(t),n=IDBKeyRange.bound([r,-1/0],[r,1/0]),i=null;return iW(e,ih).ee({range:n,index:ic},(e,r,n)=>{let s=oH(r);s9(t,s.target)&&(i=s,n.done())}).next(()=>i)}addMatchingKeys(e,t,r){let n=[],i=lS(e);return t.forEach(t=>{let s=nZ(t.path);n.push(i.put({targetId:r,path:s})),n.push(this.referenceDelegate.addReference(e,r,t))}),nO.waitFor(n)}removeMatchingKeys(e,t,r){let n=lS(e);return nO.forEach(t,t=>{let i=nZ(t.path);return nO.waitFor([n.delete([r,i]),this.referenceDelegate.removeReference(e,r,t)])})}removeMatchingKeysForTargetId(e,t){let r=lS(e),n=IDBKeyRange.bound([t],[t+1],!1,!0);return r.delete(n)}getMatchingKeysForTargetId(e,t){let r=IDBKeyRange.bound([t],[t+1],!1,!0),n=lS(e),i=aS();return n.ee({range:r,Y:!0},(e,t,r)=>{let n=new nd(n0(e[1]));i=i.add(n)}).next(()=>i)}containsKey(e,t){let r=nZ(t.path),n=IDBKeyRange.bound([r],[r+"\0"],!1,!0),i=0;return lS(e).ee({index:im,Y:!0,range:n},([e,t],r,n)=>{0!==e&&(i++,n.done())}).next(()=>i>0)}At(e,t){return iW(e,ih).get(t).next(e=>e?oH(e):null)}}function lS(e){return iW(e,ip)}let lC="LruGarbageCollector";function lk([e,t],[r,n]){let i=nn(e,r);return 0===i?nn(t,n):i}class lA{constructor(e){this.Pr=e,this.buffer=new i1(lk),this.Tr=0}Er(){return++this.Tr}Ir(e){let t=[e,this.Er()];if(this.buffer.size<this.Pr)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();0>lk(t,e)&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class lx{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Rr=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Ar(6e4)}stop(){this.Rr&&(this.Rr.cancel(),this.Rr=null)}get started(){return null!==this.Rr}Ar(e){rW(lC,`Garbage collection scheduled in ${e}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){nj(e)?rW(lC,"Ignoring IndexedDB error during garbage collection: ",e):await nP(e)}
5await this.Ar(3e5)})}}class lN{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.dr(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return nO.resolve(nQ.ce);let r=new lA(t);return this.Vr.forEachTarget(e,e=>r.Ir(e.sequenceNumber)).next(()=>this.Vr.mr(e,e=>r.Ir(e))).next(()=>r.maxValue)}removeTargets(e,t,r){return this.Vr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return -1===this.params.cacheSizeCollectionThreshold?(rW("LruGarbageCollector","Garbage collection skipped; disabled"),nO.resolve(lm)):this.getCacheSize(e).next(r=>r<this.params.cacheSizeCollectionThreshold?(rW("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),lm):this.gr(e,t))}getCacheSize(e){return this.Vr.getCacheSize(e)}gr(e,t){let r,n,i,s,a,o,l,u=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(t=>(t>this.params.maximumSequenceNumbersToCollect?(rW("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),n=this.params.maximumSequenceNumbersToCollect):n=t,s=Date.now(),this.nthSequenceNumber(e,n))).next(n=>(r=n,a=Date.now(),this.removeTargets(e,r,t))).next(t=>(i=t,o=Date.now(),this.removeOrphanedDocuments(e,r))).next(e=>(l=Date.now(),rH()<=v.LogLevel.DEBUG&&rW("LruGarbageCollector",`LRU Garbage Collection
6	Counted targets in ${s-u}ms
7	Determined least recently used ${n} in `+(a-s)+"ms\n"+`	Removed ${i} targets in `+(o-a)+"ms\n"+`	Removed ${e} documents in `+(l-o)+"ms\n"+`Total Duration: ${l-u}ms`),nO.resolve({didRun:!0,sequenceNumbersCollected:n,targetsRemoved:i,documentsRemoved:e})))}}class lR{constructor(e,t){this.db=e,this.garbageCollector=function(e,t){return new lN(e,t)}(this,t)}dr(e){let t=this.pr(e);return this.db.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}pr(e){let t=0;return this.mr(e,e=>{t++}).next(()=>t)}forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}mr(e,t){return this.yr(e,(e,r)=>t(r))}addReference(e,t,r){return lD(e,r)}removeReference(e,t,r){return lD(e,r)}removeTargets(e,t,r){return this.db.getTargetCache().removeTargets(e,t,r)}markPotentiallyOrphaned(e,t){return lD(e,t)}wr(e,t){let r;return r=!1,iW(e,n6).te(n=>lb(e,n,t).next(e=>(e&&(r=!0),nO.resolve(!e)))).next(()=>r)}removeOrphanedDocuments(e,t){let r=this.db.getRemoteDocumentCache().newChangeBuffer(),n=[],i=0;return this.yr(e,(s,a)=>{if(a<=t){let t=this.wr(e,s).next(t=>{if(!t)return i++,r.getEntry(e,s).next(()=>(r.removeEntry(s,nI.min()),lS(e).delete([0,nZ(s.path)])))});n.push(t)}}).next(()=>nO.waitFor(n)).next(()=>r.apply(e)).next(()=>i)}removeTarget(e,t){let r=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,r)}updateLimboDocument(e,t){return lD(e,t)}yr(e,t){let r=lS(e),n,i=nQ.ce;return r.ee({index:im},([e,r],{path:s,sequenceNumber:a})=>{0===e?(i!==nQ.ce&&t(new nd(n0(n)),i),i=a,n=s):i=nQ.ce}).next(()=>{i!==nQ.ce&&t(new nd(n0(n)),i)})}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function lD(e,t){var r;return lS(e).put((r=e.currentSequenceNumber,{targetId:0,path:nZ(t.path),sequenceNumber:r}))}class lP{constructor(){this.changes=new ay(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,sF.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let r=this.changes.get(t);return void 0!==r?nO.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}class lO{constructor(e){this.serializer=e}setIndexManager(e){this.indexManager=e}addEntry(e,t,r){return iW(e,it).put(r)}removeEntry(e,t,r){let n;return iW(e,it).delete([(n=t.path.toArray()).slice(0,n.length-2),n[n.length-2],oz(r),n[n.length-1]])}updateMetadata(e,t){return this.getMetadata(e).next(r=>(r.byteSize+=t,this.Sr(e,r)))}getEntry(e,t){let r=sF.newInvalidDocument(t);return iW(e,it).ee({index:ii,range:IDBKeyRange.only(lM(t))},(e,n)=>{r=this.br(t,n)}).next(()=>r)}Dr(e,t){let r={size:0,document:sF.newInvalidDocument(t)};return iW(e,it).ee({index:ii,range:IDBKeyRange.only(lM(t))},(e,n)=>{r={document:this.br(t,n),size:lv(n)}}).next(()=>r)}getEntries(e,t){let r=aw;return this.Cr(e,t,(e,t)=>{let n=this.br(e,t);r=r.insert(e,n)}).next(()=>r)}vr(e,t){let r=aw,n=new iX(nd.comparator);return this.Cr(e,t,(e,t)=>{let i=this.br(e,t);r=r.insert(e,i),n=n.insert(e,lv(t))}).next(()=>({documents:r,Fr:n}))}Cr(e,t,r){if(t.isEmpty())return nO.resolve();let n=new i1(lF);
7t.forEach(e=>n=n.add(e));let i=IDBKeyRange.bound(lM(n.first()),lM(n.last())),s=n.getIterator(),a=s.getNext();return iW(e,it).ee({index:ii,range:i},(e,t,n)=>{let i=nd.fromSegments([...t.prefixPath,t.collectionGroup,t.documentId]);for(;a&&0>lF(a,i);)r(a,null),a=s.getNext();a&&a.isEqual(i)&&(r(a,t),a=s.hasNext()?s.getNext():null),a?n.j(lM(a)):n.done()}).next(()=>{for(;a;)r(a,null),a=s.hasNext()?s.getNext():null})}getDocumentsMatchingQuery(e,t,r,n,i){let s=t.path,a=[s.popLast().toArray(),s.lastSegment(),oz(r.readTime),r.documentKey.path.isEmpty()?"":r.documentKey.path.lastSegment()],o=[s.popLast().toArray(),s.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return iW(e,it).J(IDBKeyRange.bound(a,o,!0)).next(e=>{i?.incrementDocumentReadCount(e.length);let r=aw;for(let i of e){let e=this.br(nd.fromSegments(i.prefixPath.concat(i.collectionGroup,i.documentId)),i);e.isFoundDocument()&&(ap(t,e)||n.has(e.key))&&(r=r.insert(e.key,e))}return r})}getAllFromCollectionGroup(e,t,r,n){let i=aw,s=lV(t,r),a=lV(t,nx.max());return iW(e,it).ee({index:ia,range:IDBKeyRange.bound(s,a,!0)},(e,t,r)=>{let s=this.br(nd.fromSegments(t.prefixPath.concat(t.collectionGroup,t.documentId)),t);(i=i.insert(s.key,s)).size===n&&r.done()}).next(()=>i)}newChangeBuffer(e){return new lL(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next(e=>e.byteSize)}getMetadata(e){return iW(e,il).get(iu).next(e=>(r0(!!e,20021),e))}Sr(e,t){return iW(e,il).put(iu,t)}br(e,t){if(t){let e=function(e,t){var r;let n,i;if(t.document)n=oN(e.yt,t.document,!!t.hasCommittedMutations);else if(t.noDocument){let e=nd.fromSegments(t.noDocument.path),r=o$(t.noDocument.readTime);n=sF.newNoDocument(e,r),t.hasCommittedMutations&&n.setHasCommittedMutations()}else{if(!t.unknownDocument)return rX(56709);{let e=nd.fromSegments(t.unknownDocument.path),r=o$(t.unknownDocument.version);n=sF.newUnknownDocument(e,r)}}return t.readTime&&n.setReadTime((i=new nv((r=t.readTime)[0],r[1]),nI.fromTimestamp(i))),n}(this.serializer,t);if(!(e.isNoDocument()&&e.version.isEqual(nI.min())))return e}return sF.newInvalidDocument(e)}}class lL extends lP{constructor(e,t){super(),this.Mr=e,this.trackRemovals=t,this.Or=new ay(e=>e.toString(),(e,t)=>e.isEqual(t))}applyChanges(e){let t=[],r=0,n=new i1((e,t)=>nn(e.canonicalString(),t.canonicalString()));
7return this.changes.forEach((i,s)=>{let a=this.Or.get(i);if(t.push(this.Mr.removeEntry(e,i,a.readTime)),s.isValidDocument()){let o=oq(this.Mr.serializer,s);n=n.add(i.path.popLast());let l=lv(o);r+=l-a.size,t.push(this.Mr.addEntry(e,i,o))}else if(r-=a.size,this.trackRemovals){let r=oq(this.Mr.serializer,s.convertToNoDocument(nI.min()));t.push(this.Mr.addEntry(e,i,r))}}),n.forEach(r=>{t.push(this.Mr.indexManager.addToCollectionParentIndex(e,r))}),t.push(this.Mr.updateMetadata(e,r)),nO.waitFor(t)}getFromCache(e,t){return this.Mr.Dr(e,t).next(e=>(this.Or.set(t,{size:e.size,readTime:e.document.readTime}),e.document))}getAllFromCache(e,t){return this.Mr.vr(e,t).next(({documents:e,Fr:t})=>(t.forEach((t,r)=>{this.Or.set(t,{size:r,readTime:e.get(t).readTime})}),e))}}function lM(e){let t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function lV(e,t){let r=t.documentKey.path.toArray();return[e,oz(t.readTime),r.slice(0,r.length-2),r.length>0?r[r.length-1]:""]}function lF(e,t){let r=e.path.toArray(),n=t.path.toArray(),i=0;for(let e=0;e<r.length-2&&e<n.length-2;++e)if(i=nn(r[e],n[e]))return i;return(i=nn(r.length,n.length))||(i=nn(r[r.length-2],n[n.length-2]))||nn(r[r.length-1],n[n.length-1])}class lU{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class lB{constructor(e,t,r,n){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=n}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next(n=>(r=n,this.remoteDocumentCache.getEntry(e,t))).next(e=>(null!==r&&a$(r.mutation,e,i6.empty(),nv.now()),e))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.getLocalViewOfDocuments(e,t,aS()).next(()=>t))}getLocalViewOfDocuments(e,t,r=aS()){let n=aE();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,r).next(e=>{let t=aI();return e.forEach((e,r)=>{t=t.insert(e,r.overlayedDocument)}),t}))}getOverlayedDocuments(e,t){let r=aE();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,aS()))}populateOverlays(e,t,r){let n=[];return r.forEach(e=>{t.has(e)||n.push(e)}),this.documentOverlayCache.getOverlays(e,n).next(e=>{e.forEach((e,r)=>{t.set(e,r)})})}computeViews(e,t,r,n){let i=aw,s=aE(),a=aE();return t.forEach((e,t)=>{let a=r.get(t.key);n.has(t.key)&&(void 0===a||a.mutation instanceof aW)?i=i.insert(t.key,t):void 0!==a?(s.set(t.key,a.mutation.getFieldMask()),a$(a.mutation,t,a.mutation.getFieldMask(),nv.now())):s.set(t.key,i6.empty())}),this.recalculateAndSaveOverlays(e,i).next(e=>(e.forEach((e,t)=>s.set(e,t)),t.forEach((e,t)=>a.set(e,new lU(t,s.get(e)??null))),a))}recalculateAndSaveOverlays(e,t){let r=aE(),n=new iX((e,t)=>e-t),i=aS();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(e=>{for(let i of e)i.keys().forEach(e=>{let s=t.get(e);if(null===s)return;let a=r.get(e)||i6.empty();a=i.applyToLocalView(s,a),r.set(e,a);let o=(n.get(i.batchId)||aS()).add(e);n=n.insert(i.batchId,o)})}).next(()=>{let s=[],a=n.getReverseIterator();for(;a.hasNext();){let n=a.getNext(),o=n.key,l=n.value,u=aE();l.forEach(e=>{if(!i.has(e)){let n=aK(t.get(e),r.get(e));null!==n&&u.set(e,n),i=i.add(e)}}),s.push(this.documentOverlayCache.saveOverlays(e,o,u))}return nO.waitFor(s)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.recalculateAndSaveOverlays(e,t))}getDocumentsMatchingQuery(e,t,r,n){return nd.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length?this.getDocumentsMatchingDocumentQuery(e,t.path):aa(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,n):this.getDocumentsMatchingCollectionQuery(e,t,r,n)}getNextDocuments(e,t,r,n){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,n).next(i=>{let s=n-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,n-i.size):nO.resolve(aE()),a=-1,o=i;return s.next(t=>nO.forEach(t,(t,r)=>(a<r.largestBatchId&&(a=r.largestBatchId),i.get(t)?nO.resolve():this.remoteDocumentCache.getEntry(e,t).next(e=>{o=o.insert(t,e)}))).next(()=>this.populateOverlays(e,t,i)).next(()=>this.computeViews(e,o,t,aS())).next(e=>({batchId:a,changes:ab(e)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new nd(t)).next(e=>{let t=aI();
vendor: 4,145 bytes, line 7
7return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}getDocumentsMatchingCollectionGroupQuery(e,t,r,n){let i=t.collectionGroup,s=aI();return this.indexManager.getCollectionParents(e,i).next(a=>nO.forEach(a,a=>{let o=new an(a.child(i),null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt);return this.getDocumentsMatchingCollectionQuery(e,o,r,n).next(e=>{e.forEach((e,t)=>{s=s.insert(e,t)})})}).next(()=>s))}getDocumentsMatchingCollectionQuery(e,t,r,n){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next(s=>(i=s,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,i,n))).next(e=>{i.forEach((t,r)=>{let n=r.getKey();null===e.get(n)&&(e=e.insert(n,sF.newInvalidDocument(n)))});let r=aI();return e.forEach((e,n)=>{let s=i.get(e);void 0!==s&&a$(s.mutation,n,i6.empty(),nv.now()),ap(t,n)&&(r=r.insert(e,n))}),r})}}class lj{constructor(e){this.serializer=e,this.Nr=new Map,this.Br=new Map}getBundleMetadata(e,t){return nO.resolve(this.Nr.get(t))}saveBundleMetadata(e,t){return this.Nr.set(t.id,{id:t.id,version:t.version,createTime:ov(t.createTime)}),nO.resolve()}getNamedQuery(e,t){return nO.resolve(this.Br.get(t))}saveNamedQuery(e,t){return this.Br.set(t.name,{name:t.name,query:oQ(t.bundledQuery),readTime:ov(t.readTime)}),nO.resolve()}}class lq{constructor(){this.overlays=new iX(nd.comparator),this.Lr=new Map}getOverlay(e,t){return nO.resolve(this.overlays.get(t))}getOverlays(e,t){let r=aE();return nO.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&r.set(t,e)})).next(()=>r)}saveOverlays(e,t,r){return r.forEach((r,n)=>{this.St(e,t,n)}),nO.resolve()}removeOverlaysForBatchId(e,t,r){let n=this.Lr.get(r);return void 0!==n&&(n.forEach(e=>this.overlays=this.overlays.remove(e)),this.Lr.delete(r)),nO.resolve()}getOverlaysForCollection(e,t,r){let n=aE(),i=t.length+1,s=new nd(t.child("")),a=this.overlays.getIteratorFrom(s);for(;a.hasNext();){let e=a.getNext().value,s=e.getKey();if(!t.isPrefixOf(s.path))break;s.path.length===i&&e.largestBatchId>r&&n.set(e.getKey(),e)}return nO.resolve(n)}getOverlaysForCollectionGroup(e,t,r,n){let i=new iX((e,t)=>e-t),s=this.overlays.getIterator();for(;s.hasNext();){let e=s.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>r){let t=i.get(e.largestBatchId);null===t&&(t=aE(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let a=aE(),o=i.getIterator();for(;o.hasNext()&&(o.getNext().value.forEach((e,t)=>a.set(e,t)),!(a.size()>=n)););return nO.resolve(a)}St(e,t,r){let n=this.overlays.get(r.key);if(null!==n){let e=this.Lr.get(n.largestBatchId).delete(r.key);this.Lr.set(n.largestBatchId,e)}this.overlays=this.overlays.insert(r.key,new a2(t,r));let i=this.Lr.get(t);void 0===i&&(i=aS(),this.Lr.set(t,i)),this.Lr.set(t,i.add(r.key))}}class lz{constructor(){this.sessionToken=i8.EMPTY_BYTE_STRING}getSessionToken(e){return nO.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,nO.resolve()}}class lK{constructor(){this.kr=new i1(l$.qr),this.Kr=new i1(l$.Ur)}isEmpty(){return this.kr.isEmpty()}addReference(e,t){let r=new l$(e,t);this.kr=this.kr.add(r),this.Kr=this.Kr.add(r)}$r(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.Wr(new l$(e,t))}Qr(e,t){e.forEach(e=>this.removeReference(e,t))}Gr(e){let t=new nd(new nu([])),r=new l$(t,e),n=new l$(t,e+1),i=[];return this.Kr.forEachInRange([r,n],e=>{this.Wr(e),i.push(e.key)}),i}zr(){this.kr.forEach(e=>this.Wr(e))}Wr(e){this.kr=this.kr.delete(e),this.Kr=this.Kr.delete(e)}jr(e){let t=new nd(new nu([])),r=new l$(t,e),n=new l$(t,e+1),i=aS();return this.Kr.forEachInRange([r,n],e=>{i=i.add(e.key)}),i}containsKey(e){let t=new l$(e,0),r=this.kr.firstAfterOrEqual(t);return null!==r&&e.isEqual(r.key)}}class l${constructor(e,t){this.key=e,this.Jr=t}static qr(e,t){return nd.comparator(e.key,t.key)||nn(e.Jr,t.Jr)}static Ur(e,t){return nn(e.Jr,t.Jr)||nd.comparator(e.key,t.key)}}class lG{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Yn=1,this.Hr=new i1(l$.qr)}checkEmpty(e){return nO.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,r,n){let i=this.Yn;
7this.Yn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let s=new a0(i,t,r,n);for(let t of(this.mutationQueue.push(s),n))this.Hr=this.Hr.add(new l$(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return nO.resolve(s)}lookupMutationBatch(e,t){return nO.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){let r=this.Xr(t+1),n=r<0?0:r;return nO.resolve(this.mutationQueue.length>n?this.mutationQueue[n]:null)}getHighestUnacknowledgedBatchId(){return nO.resolve(0===this.mutationQueue.length?-1:this.Yn-1)}getAllMutationBatches(e){return nO.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let r=new l$(t,0),n=new l$(t,1/0),i=[];return this.Hr.forEachInRange([r,n],e=>{let t=this.Zr(e.Jr);i.push(t)}),nO.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new i1(nn);return t.forEach(e=>{let t=new l$(e,0),n=new l$(e,1/0);this.Hr.forEachInRange([t,n],e=>{r=r.add(e.Jr)})}),nO.resolve(this.Yr(r))}getAllMutationBatchesAffectingQuery(e,t){let r=t.path,n=r.length+1,i=r;nd.isDocumentKey(i)||(i=i.child(""));let s=new l$(new nd(i),0),a=new i1(nn);return this.Hr.forEachWhile(e=>{let t=e.key.path;return!!r.isPrefixOf(t)&&(t.length===n&&(a=a.add(e.Jr)),!0)},s),nO.resolve(this.Yr(a))}Yr(e){let t=[];return e.forEach(e=>{let r=this.Zr(e);null!==r&&t.push(r)}),t}removeMutationBatch(e,t){r0(0===this.ei(t.batchId,"removed"),55003),this.mutationQueue.shift();let r=this.Hr;return nO.forEach(t.mutations,n=>{let i=new l$(n.key,t.batchId);return r=r.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,n.key)}).next(()=>{this.Hr=r})}nr(e){}containsKey(e,t){let r=new l$(t,0),n=this.Hr.firstAfterOrEqual(r);return nO.resolve(t.isEqual(n&&n.key))}performConsistencyCheck(e){return this.mutationQueue.length,nO.resolve()}ei(e,t){return this.Xr(e)}Xr(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}Zr(e){let t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class lH{constructor(e){this.ti=e,this.docs=new iX(nd.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let r=t.key,n=this.docs.get(r),i=n?n.size:0,s=this.ti(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:s}),this.size+=s-i,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){let t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){let r=this.docs.get(t);return nO.resolve(r?r.document.mutableCopy():sF.newInvalidDocument(t))}getEntries(e,t){let r=aw;return t.forEach(e=>{let t=this.docs.get(e);r=r.insert(e,t?t.document.mutableCopy():sF.newInvalidDocument(e))}),nO.resolve(r)}getDocumentsMatchingQuery(e,t,r,n){let i=aw,s=t.path,a=new nd(s.child("__id-9223372036854775808__")),o=this.docs.getIteratorFrom(a);for(;o.hasNext();){let{key:e,value:{document:a}}=o.getNext();if(!s.isPrefixOf(e.path))break;e.path.length>s.length+1||0>=nN(nA(a),r)||(n.has(a.key)||ap(t,a))&&(i=i.insert(a.key,a.mutableCopy()))}return nO.resolve(i)}getAllFromCollectionGroup(e,t,r,n){rX(9500)}ni(e,t){return nO.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new lW(this)}getSize(e){return nO.resolve(this.size)}}class lW extends lP{constructor(e){super(),this.Mr=e}applyChanges(e){let t=[];
vendor: 4,122 bytes, line 7
7return this.changes.forEach((r,n)=>{n.isValidDocument()?t.push(this.Mr.addEntry(e,n)):this.Mr.removeEntry(r)}),nO.waitFor(t)}getFromCache(e,t){return this.Mr.getEntry(e,t)}getAllFromCache(e,t){return this.Mr.getEntries(e,t)}}class lQ{constructor(e){this.persistence=e,this.ri=new ay(e=>s4(e),s9),this.lastRemoteSnapshotVersion=nI.min(),this.highestTargetId=0,this.ii=0,this.si=new lK,this.targetCount=0,this.oi=lT._r()}forEachTarget(e,t){return this.ri.forEach((e,r)=>t(r)),nO.resolve()}getLastRemoteSnapshotVersion(e){return nO.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return nO.resolve(this.ii)}allocateTargetId(e){return this.highestTargetId=this.oi.next(),nO.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.ii&&(this.ii=t),nO.resolve()}lr(e){this.ri.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.oi=new lT(t),this.highestTargetId=t),e.sequenceNumber>this.ii&&(this.ii=e.sequenceNumber)}addTargetData(e,t){return this.lr(t),this.targetCount+=1,nO.resolve()}updateTargetData(e,t){return this.lr(t),nO.resolve()}removeTargetData(e,t){return this.ri.delete(t.target),this.si.Gr(t.targetId),this.targetCount-=1,nO.resolve()}removeTargets(e,t,r){let n=0,i=[];return this.ri.forEach((s,a)=>{a.sequenceNumber<=t&&null===r.get(a.targetId)&&(this.ri.delete(s),i.push(this.removeMatchingKeysForTargetId(e,a.targetId)),n++)}),nO.waitFor(i).next(()=>n)}getTargetCount(e){return nO.resolve(this.targetCount)}getTargetData(e,t){let r=this.ri.get(t)||null;return nO.resolve(r)}addMatchingKeys(e,t,r){return this.si.$r(t,r),nO.resolve()}removeMatchingKeys(e,t,r){this.si.Qr(t,r);let n=this.persistence.referenceDelegate,i=[];return n&&t.forEach(t=>{i.push(n.markPotentiallyOrphaned(e,t))}),nO.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.si.Gr(t),nO.resolve()}getMatchingKeysForTargetId(e,t){let r=this.si.jr(t);return nO.resolve(r)}containsKey(e,t){return nO.resolve(this.si.containsKey(t))}}class lJ{constructor(e,t){this._i={},this.overlays={},this.ai=new nQ(0),this.ui=!1,this.ui=!0,this.ci=new lz,this.referenceDelegate=e(this),this.li=new lQ(this),this.indexManager=new lh,this.remoteDocumentCache=function(e){return new lH(e)}(e=>this.referenceDelegate.hi(e)),this.serializer=new oj(t),this.Pi=new lj(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ui=!1,Promise.resolve()}get started(){return this.ui}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new lq,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this._i[e.toKey()];return r||(r=new lG(t,this.referenceDelegate),this._i[e.toKey()]=r),r}getGlobalsCache(){return this.ci}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Pi}runTransaction(e,t,r){rW("MemoryPersistence","Starting transaction:",e);let n=new lY(this.ai.next());return this.referenceDelegate.Ti(),r(n).next(e=>this.referenceDelegate.Ei(n).next(()=>e)).toPromise().then(e=>(n.raiseOnCommittedEvent(),e))}Ii(e,t){return nO.or(Object.values(this._i).map(r=>()=>r.containsKey(e,t)))}}class lY extends nD{constructor(e){super(),this.currentSequenceNumber=e}}class lX{constructor(e){this.persistence=e,this.Ri=new lK,this.Ai=null}static Vi(e){return new lX(e)}get di(){if(this.Ai)return this.Ai;throw rX(60996)}addReference(e,t,r){return this.Ri.addReference(r,t),this.di.delete(r.toString()),nO.resolve()}removeReference(e,t,r){return this.Ri.removeReference(r,t),this.di.add(r.toString()),nO.resolve()}markPotentiallyOrphaned(e,t){return this.di.add(t.toString()),nO.resolve()}removeTarget(e,t){this.Ri.Gr(t.targetId).forEach(e=>this.di.add(e.toString()));let r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.di.add(e.toString()))}).next(()=>r.removeTargetData(e,t))}Ti(){this.Ai=new Set}Ei(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return nO.forEach(this.di,r=>{let n=nd.fromPath(r);
7return this.mi(e,n).next(e=>{e||t.removeEntry(n,nI.min())})}).next(()=>(this.Ai=null,t.apply(e)))}updateLimboDocument(e,t){return this.mi(e,t).next(e=>{e?this.di.delete(t.toString()):this.di.add(t.toString())})}hi(e){return 0}mi(e,t){return nO.or([()=>nO.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ii(e,t)])}}class lZ{constructor(e,t){this.persistence=e,this.fi=new ay(e=>nZ(e.path),(e,t)=>e.isEqual(t)),this.garbageCollector=function(e,t){return new lN(e,t)}(this,t)}static Vi(e,t){return new lZ(e,t)}Ti(){}Ei(e){return nO.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}dr(e){let t=this.pr(e);return this.persistence.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}pr(e){let t=0;return this.mr(e,e=>{t++}).next(()=>t)}mr(e,t){return nO.forEach(this.fi,(r,n)=>this.wr(e,r,n).next(e=>e?nO.resolve():t(n)))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0,n=this.persistence.getRemoteDocumentCache(),i=n.newChangeBuffer();return n.ni(e,n=>this.wr(e,n,t).next(e=>{e||(r++,i.removeEntry(n,nI.min()))})).next(()=>i.apply(e)).next(()=>r)}markPotentiallyOrphaned(e,t){return this.fi.set(t,e.currentSequenceNumber),nO.resolve()}removeTarget(e,t){let r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.fi.set(r,e.currentSequenceNumber),nO.resolve()}removeReference(e,t,r){return this.fi.set(r,e.currentSequenceNumber),nO.resolve()}updateLimboDocument(e,t){return this.fi.set(t,e.currentSequenceNumber),nO.resolve()}hi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=function e(t){switch(sw(t)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let r=sa(t);return r?16+e(r):16;case 5:return 2*t.stringValue.length;case 6:return se(t.bytesValue).approximateByteSize();case 7:return t.referenceValue.length;case 9:return(t.arrayValue.values||[]).reduce((t,r)=>t+e(r),0);case 10:case 11:var n;let i;return n=t.mapValue,i=0,iJ(n.fields,(t,r)=>{i+=t.length+e(r)}),i;default:throw rX(13486,{value:t})}}(e.data.value)),t}wr(e,t,r){return nO.or([()=>this.persistence.Ii(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.fi.get(t);return nO.resolve(void 0!==e&&e>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class l0{constructor(e){this.serializer=e}k(e,t,r,n){let i=new nM("createOrUpgrade",t);r<1&&n>=1&&(e.createObjectStore(n2),e.createObjectStore(n6,{keyPath:"userId"}),e.createObjectStore(n3,{keyPath:n8,autoIncrement:!0}).createIndex(n4,n9,{unique:!0}),e.createObjectStore(ie),l1(e),e.createObjectStore(n1));let s=nO.resolve();return r<3&&n>=3&&(0!==r&&(e.deleteObjectStore(ip),e.deleteObjectStore(ih),e.deleteObjectStore(iv),l1(e)),s=s.next(()=>{let e,t;return e=i.store(iv),t={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:nI.min().toTimestamp(),targetCount:0},e.put(iw,t)})),r<4&&n>=4&&(0!==r&&(s=s.next(()=>i.store(n3).J().next(t=>{e.deleteObjectStore(n3),e.createObjectStore(n3,{keyPath:n8,autoIncrement:!0}).createIndex(n4,n9,{unique:!0});let r=i.store(n3),n=t.map(e=>r.put(e));return nO.waitFor(n)}))),s=s.next(()=>{e.createObjectStore(iE,{keyPath:"clientId"})})),r<5&&n>=5&&(s=s.next(()=>this.gi(i))),r<6&&n>=6&&(s=s.next(()=>(e.createObjectStore(il),this.pi(i)))),r<7&&n>=7&&(s=s.next(()=>this.yi(i))),r<8&&n>=8&&(s=s.next(()=>this.wi(e,i))),r<9&&n>=9&&(s=s.next(()=>{e.objectStoreNames.contains("remoteDocumentChanges")&&e.deleteObjectStore("remoteDocumentChanges")})),r<10&&n>=10&&(s=s.next(()=>this.Si(i))),r<11&&n>=11&&(s=s.next(()=>{e.createObjectStore(iT,{keyPath:"bundleId"}),e.createObjectStore(i_,{keyPath:"name"})})),r<12&&n>=12&&(s=s.next(()=>{let t;(t=e.createObjectStore(iL,{keyPath:iM})).createIndex(iV,iF,{unique:!1}),t.createIndex(iU,iB,{unique:!1})})),r<13&&n>=13&&(s=s.next(()=>{let t;(t=e.createObjectStore(it,{keyPath:ir})).createIndex(ii,is),t.createIndex(ia,io)}).next(()=>this.bi(e,i)).next(()=>e.deleteObjectStore(n1))),r<14&&n>=14&&(s=s.next(()=>this.Di(e,i))),r<15&&n>=15&&(s=s.next(()=>{e.createObjectStore(iS,{keyPath:"indexId",autoIncrement:!0}).createIndex(iC,"collectionGroup",{unique:!1}),e.createObjectStore(ik,{keyPath:iA}).createIndex(ix,iN,{unique:!1}),e.createObjectStore(iR,{keyPath:iD}).createIndex(iP,iO,{unique:!1})}
7)),r<16&&n>=16&&(s=s.next(()=>{t.objectStore(ik).clear()}).next(()=>{t.objectStore(iR).clear()})),r<17&&n>=17&&(s=s.next(()=>{e.createObjectStore(ij,{keyPath:"name"})})),r<18&&n>=18&&(0,rF.isSafariOrWebkit)()&&(s=s.next(()=>{t.objectStore(ik).clear()}).next(()=>{t.objectStore(iR).clear()})),s}pi(e){let t=0;return e.store(n1).ee((e,r)=>{t+=lv(r)}).next(()=>{let r={byteSize:t};return e.store(il).put(iu,r)})}gi(e){let t=e.store(n6),r=e.store(n3);return t.J().next(t=>nO.forEach(t,t=>{let n=IDBKeyRange.bound([t.userId,-1],[t.userId,t.lastAcknowledgedBatchId]);return r.J(n4,n).next(r=>nO.forEach(r,r=>{r0(r.userId===t.userId,18650,"Cannot process batch from unexpected user",{batchId:r.batchId});let n=oG(this.serializer,r);return lw(e,t.userId,n).next(()=>{})}))}))}yi(e){let t=e.store(ip),r=e.store(n1);return e.store(iv).get(iw).next(e=>{let n=[];return r.ee((r,i)=>{let s=new nu(r),a=[0,nZ(s)];n.push(t.get(a).next(r=>r?nO.resolve():t.put({targetId:0,path:nZ(s),sequenceNumber:e.highestListenSequenceNumber})))}).next(()=>nO.waitFor(n))})}wi(e,t){e.createObjectStore(iI,{keyPath:ib});let r=t.store(iI),n=new lc,i=e=>{if(n.add(e)){let t=e.lastSegment(),n=e.popLast();return r.put({collectionId:t,parent:nZ(n)})}};return t.store(n1).ee({Y:!0},(e,t)=>i(new nu(e).popLast())).next(()=>t.store(ie).ee({Y:!0},([e,t,r],n)=>i(n0(t).popLast())))}Si(e){let t=e.store(ih);return t.ee((e,r)=>{let n=oH(r),i=oW(this.serializer,n);return t.put(i)})}bi(e,t){let r=t.store(n1),n=[];return r.ee((e,r)=>{let i=t.store(it),s=(r.document?new nd(nu.fromString(r.document.name).popFirst(5)):r.noDocument?nd.fromSegments(r.noDocument.path):r.unknownDocument?nd.fromSegments(r.unknownDocument.path):rX(36783)).path.toArray(),a={prefixPath:s.slice(0,s.length-2),collectionGroup:s[s.length-2],documentId:s[s.length-1],readTime:r.readTime||[0,0],unknownDocument:r.unknownDocument,noDocument:r.noDocument,document:r.document,hasCommittedMutations:!!r.hasCommittedMutations};n.push(i.put(a))}).next(()=>nO.waitFor(n))}Di(e,t){let r=t.store(n3),n=new lO(this.serializer),i=new lJ(lX.Vi,this.serializer.yt);return r.J().next(e=>{let r=new Map;return e.forEach(e=>{let t=r.get(e.userId)??aS();oG(this.serializer,e).keys().forEach(e=>t=t.add(e)),r.set(e.userId,t)}),nO.forEach(r,(e,r)=>{let s=new rz(r),a=o0.wt(this.serializer,s),o=i.getIndexManager(s);return new lB(n,lI.wt(s,this.serializer,o,i.referenceDelegate),a,o).recalculateAndSaveOverlaysForDocumentKeys(new iH(t,nQ.ce),e).next()})})}}function l1(e){e.createObjectStore(ip,{keyPath:ig}).createIndex(im,iy,{unique:!0}),e.createObjectStore(ih,{keyPath:"targetId"}).createIndex(ic,id,{unique:!0}),e.createObjectStore(iv)}let l2="IndexedDbPersistence",l5="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 l6{constructor(e,t,r,n,i,s,a,o,l,u,h=18){if(this.allowTabSynchronization=e,this.persistenceKey=t,this.clientId=r,this.Ci=i,this.window=s,this.document=a,this.Fi=l,this.Mi=u,this.xi=h,this.ai=null,this.ui=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Oi=null,this.inForeground=!1,this.Ni=null,this.Bi=null,this.Li=-1/0,this.ki=e=>Promise.resolve(),!l6.v())throw new r2(r1.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new lR(this,n),this.qi=t+"main",this.serializer=new oj(o),this.Ki=new nV(this.qi,this.xi,new l0(this.serializer)),this.ci=new o1,this.li=new l_(this.referenceDelegate,this.serializer),this.remoteDocumentCache=function(e){return new lO(e)}(this.serializer),this.Pi=new oZ,this.window&&this.window.localStorage?this.Ui=this.window.localStorage:(this.Ui=null,!1===u&&rQ(l2,"LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.$i().then(()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new r2(r1.FAILED_PRECONDITION,l5);return this.Wi(),this.Qi(),this.Gi(),this.runTransaction("getHighestListenSequenceNumber","readonly",e=>this.li.getHighestSequenceNumber(e))}).then(e=>{this.ai=new nQ(e,this.Fi)}).then(()=>{this.ui=!0}).catch(e=>(this.Ki&&this.Ki.close(),Promise.reject(e)))}zi(e){return this.ki=async t=>{if(this.started)return e(t)},e(this.isPrimary)}setDatabaseDeletedListener(e){this.Ki.K(async t=>{null===t.newVersion&&await e()})}setNetworkEnabled(e){this.networkEnabled!==e&&(this.networkEnabled=e,this.Ci.enqueueAndForget(async()=>{this.started&&await this.$i()}))}$i(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",e=>iW(e,iE).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next(()=>{if(this.isPrimary)return this.ji(e).next(e=>{e||(this.isPrimary=!1,this.Ci.enqueueRetryable(()=>this.ki(!1)))})}).next(()=>this.Ji(e)).next(t=>this.isPrimary&&!t?this.Hi(e).next(()=>!1):!!t&&this.Zi(e).next(()=>!0))).catch(e=>{if(nj(e))return rW(l2,"Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return rW(l2,"Releasing owner lease after error during lease refresh",e),!1}).then(e=>{this.isPrimary!==e&&this.Ci.enqueueRetryable(()=>this.ki(e)),this.isPrimary=e})}ji(e){return iW(e,n2).get(n5).next(e=>nO.resolve(this.Xi(e)))}Yi(e){return iW(e,iE).delete(this.clientId)}async es(){if(this.isPrimary&&!this.ts(this.Li,18e5)){this.Li=Date.now();let e=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",e=>{let t=iW(e,iE);return t.J().next(e=>{let r=this.ns(e,18e5),n=e.filter(e=>-1===r.indexOf(e));return nO.forEach(n,e=>t.delete(e.clientId)).next(()=>n)})}).catch(()=>[]);if(this.Ui)for(let t of e)this.Ui.removeItem(this.rs(t.clientId))}}Gi(){this.Bi=this.Ci.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.$i().then(()=>this.es()).then(()=>this.Gi()))}Xi(e){return!!e&&e.ownerId===this.clientId}Ji(e){return this.Mi?nO.resolve(!0):iW(e,n2).get(n5).next(t=>
7{if(null!==t&&this.ts(t.leaseTimestampMs,5e3)&&!this.ss(t.ownerId)){if(this.Xi(t)&&this.networkEnabled)return!0;if(!this.Xi(t)){if(!t.allowTabSynchronization)throw new r2(r1.FAILED_PRECONDITION,l5);return!1}}return!(!this.networkEnabled||!this.inForeground)||iW(e,iE).J().next(e=>void 0===this.ns(e,5e3).find(e=>{if(this.clientId!==e.clientId){let t=!this.networkEnabled&&e.networkEnabled,r=!this.inForeground&&e.inForeground,n=this.networkEnabled===e.networkEnabled;if(t||r&&n)return!0}return!1}))}).next(e=>(this.isPrimary!==e&&rW(l2,`Client ${e?"is":"is not"} eligible for a primary lease.`),e))}async shutdown(){this.ui=!1,this._s(),this.Bi&&(this.Bi.cancel(),this.Bi=null),this.us(),this.cs(),await this.Ki.runTransaction("shutdown","readwrite",[n2,iE],e=>{let t=new iH(e,nQ.ce);return this.Hi(t).next(()=>this.Yi(t))}),this.Ki.close(),this.ls()}ns(e,t){return e.filter(e=>this.ts(e.updateTimeMs,t)&&!this.ss(e.clientId))}hs(){return this.runTransaction("getActiveClients","readonly",e=>iW(e,iE).J().next(e=>this.ns(e,18e5).map(e=>e.clientId)))}get started(){return this.ui}getGlobalsCache(){return this.ci}getMutationQueue(e,t){return lI.wt(e,this.serializer,t,this.referenceDelegate)}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(e){return new lp(e,this.serializer.yt.databaseId)}getDocumentOverlayCache(e){return o0.wt(this.serializer,e)}getBundleCache(){return this.Pi}runTransaction(e,t,r){var n;let i;rW(l2,"Starting transaction:",e);let s=18===(n=this.xi)||17===n?iG:16===n||15===n?i$:14===n||13===n?iK:12===n?iz:11===n?iq:void rX(60245);return this.Ki.runTransaction(e,"readonly"===t?"readonly":"readwrite",s,n=>(i=new iH(n,this.ai?this.ai.next():nQ.ce),"readwrite-primary"===t?this.ji(i).next(e=>!!e||this.Ji(i)).next(t=>{if(!t)throw rQ(`Failed to obtain primary lease for action '${e}'.`),this.isPrimary=!1,this.Ci.enqueueRetryable(()=>this.ki(!1)),new r2(r1.FAILED_PRECONDITION,nR);return r(i)}).next(e=>this.Zi(i).next(()=>e)):this.Ps(i).next(()=>r(i)))).then(e=>(i.raiseOnCommittedEvent(),e))}Ps(e){return iW(e,n2).get(n5).next(e=>{if(null!==e&&this.ts(e.leaseTimestampMs,5e3)&&!this.ss(e.ownerId)&&!this.Xi(e)&&!(this.Mi||this.allowTabSynchronization&&e.allowTabSynchronization))throw new r2(r1.FAILED_PRECONDITION,l5)})}Zi(e){let t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return iW(e,n2).put(n5,t)}static v(){return nV.v()}Hi(e){let t=iW(e,n2);return t.get(n5).next(e=>
7this.Xi(e)?(rW(l2,"Releasing primary lease."),t.delete(n5)):nO.resolve())}ts(e,t){let r=Date.now();return!(e<r-t)&&(!(e>r)||(rQ(`Detected an update time that is in the future: ${e} > ${r}`),!1))}Wi(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Ni=()=>{this.Ci.enqueueAndForget(()=>(this.inForeground="visible"===this.document.visibilityState,this.$i()))},this.document.addEventListener("visibilitychange",this.Ni),this.inForeground="visible"===this.document.visibilityState)}us(){this.Ni&&(this.document.removeEventListener("visibilitychange",this.Ni),this.Ni=null)}Qi(){"function"==typeof this.window?.addEventListener&&(this.Oi=()=>{this._s();let e=/(?:Version|Mobile)\/1[456]/;(0,rF.isSafari)()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&this.Ci.enterRestrictedMode(!0),this.Ci.enqueueAndForget(()=>this.shutdown())},this.window.addEventListener("pagehide",this.Oi))}cs(){this.Oi&&(this.window.removeEventListener("pagehide",this.Oi),this.Oi=null)}ss(e){try{let t=null!==this.Ui?.getItem(this.rs(e));return rW(l2,`Client '${e}' ${t?"is":"is not"} zombied in LocalStorage`),t}catch(e){return rQ(l2,"Failed to get zombied client id.",e),!1}}_s(){if(this.Ui)try{this.Ui.setItem(this.rs(this.clientId),String(Date.now()))}catch(e){rQ("Failed to set zombie client id.",e)}}ls(){if(this.Ui)try{this.Ui.removeItem(this.rs(this.clientId))}catch(e){}}rs(e){return`firestore_zombie_${this.persistenceKey}_${e}`}}function l3(e,t){let r=e.projectId;return e.isDefaultDatabase||(r+="."+e.database),"firestore/"+t+"/"+r+"/"}class l8{constructor(e,t,r,n){this.targetId=e,this.fromCache=t,this.Ts=r,this.Es=n}static Is(e,t){let r=aS(),n=aS();for(let e of t.docChanges)switch(e.type){case 0:r=r.add(e.doc.key);break;case 1:n=n.add(e.doc.key)}return new l8(e,t.fromCache,r,n)}}class l4{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class l9{constructor(){this.Rs=!1,this.As=!1,this.Vs=100,this.ds=(0,rF.isSafari)()?8:nF((0,rF.getUA)())>0?6:4}initialize(e,t){this.fs=e,this.indexManager=t,this.Rs=!0}getDocumentsMatchingQuery(e,t,r,n){let i={result:null};return this.gs(e,t).next(e=>{i.result=e}).next(()=>{if(!i.result)return this.ps(e,t,n,r).next(e=>{i.result=e})}).next(()=>{if(i.result)return;let r=new l4;return this.ys(e,t,r).next(n=>{if(i.result=n,this.As)return this.ws(e,t,r,n.size)})}).next(()=>i.result)}ws(e,t,r,n){return r.documentReadCount<this.Vs?(rH()<=v.LogLevel.DEBUG&&rW("QueryEngine","SDK will not create cache indexes for query:",af(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),nO.resolve()):(rH()<=v.LogLevel.DEBUG&&rW("QueryEngine","Query:",af(t),"scans",r.documentReadCount,"local documents and returns",n,"documents as results."),r.documentReadCount>this.ds*n?(rH()<=v.LogLevel.DEBUG&&rW("QueryEngine","The SDK decides to create cache indexes for query:",af(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,al(t))):nO.resolve())}gs(e,t){if(as(t))return nO.resolve(null);let r=al(t);return this.indexManager.getIndexType(e,r).next(n=>0===n?null:(null!==t.limit&&1===n&&(r=al(t=ah(t,null,"F"))),this.indexManager.getDocumentsMatchingTarget(e,r).next(n=>{let i=aS(...n);return this.fs.getDocuments(e,i).next(n=>this.indexManager.getMinOffset(e,r).next(r=>{let s=this.Ss(t,n);return this.bs(t,s,i,r.readTime)?this.gs(e,ah(t,null,"F")):this.Ds(e,s,t,r)}))})))}ps(e,t,r,n){return as(t)||n.isEqual(nI.min())?nO.resolve(null):this.fs.getDocuments(e,r).next(i=>{let s=this.Ss(t,i);return this.bs(t,s,r,n)?nO.resolve(null):(rH()<=v.LogLevel.DEBUG&&rW("QueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),af(t)),this.Ds(e,s,t,nk(n,-1)).next(e=>e))})}Ss(e,t){let r=new i1(am(e));return t.forEach((t,n)=>{ap(e,n)&&(r=r.add(n))}),r}bs(e,t,r,n){if(null===e.limit)return!1;if(r.size!==t.size)return!0;let i="F"===e.limitType?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(n)>0)}ys(e,t,r){return rH()<=v.LogLevel.DEBUG&&rW("QueryEngine","Using full collection scan to execute query:",af(t)),this.fs.getDocumentsMatchingQuery(e,t,nx.min(),r)}Ds(e,t,r,n){return this.fs.getDocumentsMatchingQuery(e,r,n).next(e=>(t.forEach(t=>{e=e.insert(t.key,t)}),e))}}let l7="LocalStore";class ue{constructor(e,t,r,n){this.persistence=e,this.Cs=t,this.serializer
7=n,this.vs=new iX(nn),this.Fs=new ay(e=>s4(e),s9),this.Ms=new Map,this.xs=e.getRemoteDocumentCache(),this.li=e.getTargetCache(),this.Pi=e.getBundleCache(),this.Os(r)}Os(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new lB(this.xs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.xs.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.vs))}}async function ut(e,t){return await e.persistence.runTransaction("Handle user change","readonly",r=>{let n;return e.mutationQueue.getAllMutationBatches(r).next(i=>(n=i,e.Os(t),e.mutationQueue.getAllMutationBatches(r))).next(t=>{let i=[],s=[],a=aS();for(let e of n)for(let t of(i.push(e.batchId),e.mutations))a=a.add(t.key);for(let e of t)for(let t of(s.push(e.batchId),e.mutations))a=a.add(t.key);return e.localDocuments.getDocuments(r,a).next(e=>({Ns:e,removedBatchIds:i,addedBatchIds:s}))})})}function ur(e){return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.li.getLastRemoteSnapshotVersion(t))}function un(e,t,r){let n=aS(),i=aS();return r.forEach(e=>n=n.add(e)),t.getEntries(e,n).next(e=>{let n=aw;return r.forEach((r,s)=>{let a=e.get(r);s.isFoundDocument()!==a.isFoundDocument()&&(i=i.add(r)),s.isNoDocument()&&s.version.isEqual(nI.min())?(t.removeEntry(r,s.readTime),n=n.insert(r,s)):!a.isValidDocument()||s.version.compareTo(a.version)>0||0===s.version.compareTo(a.version)&&a.hasPendingWrites?(t.addEntry(s),n=n.insert(r,s)):rW(l7,"Ignoring outdated watch update for ",r,". Current version:",a.version," Watch version:",s.version)}),{Bs:n,Ls:i}})}function ui(e,t){return e.persistence.runTransaction("Allocate target","readwrite",r=>{let n;return e.li.getTargetData(r,t).next(i=>i?(n=i,nO.resolve(n)):e.li.allocateTargetId(r).next(i=>(n=new oB(t,i,"TargetPurposeListen",r.currentSequenceNumber),e.li.addTargetData(r,n).next(()=>n))))}).then(r=>{let n=e.vs.get(r.targetId);return(null===n||r.snapshotVersion.compareTo(n.snapshotVersion)>0)&&(e.vs=e.vs.insert(r.targetId,r),e.Fs.set(t,r.targetId)),r})}async function us(e,t,r){let n=e.vs.get(t);try{r||await e.persistence.runTransaction("Release target",r?"readwrite":"readwrite-primary",t=>e.persistence.referenceDelegate.removeTarget(t,n))}catch(e){if(!nj(e))throw e;rW(l7,`Failed to update sequence numbers for target ${t}: ${e}`)}e.vs=e.vs.remove(t),e.Fs.delete(n.target)}function ua(e,t,r){let n=nI.min(),i=aS();return e.persistence.runTransaction("Execute query","readwrite",s=>{var a;let o;return(a=al(t),void 0!==(o=e.Fs.get(a))?nO.resolve(e.vs.get(o)):e.li.getTargetData(s,a)).next(t=>{if(t)return n=t.lastLimboFreeSnapshotVersion,e.li.getMatchingKeysForTargetId(s,t.targetId).next(e=>{i=e})}).next(()=>e.Cs.getDocumentsMatchingQuery(s,t,r?n:nI.min(),r?i:aS())).next(r=>(uu(e,ag(t),r),{documents:r,ks:i}))})}function uo(e,t){let r=e.li,n=e.vs.get(t);return n?Promise.resolve(n.target):e.persistence.runTransaction("Get target data","readonly",e=>r.At(e,t).next(e=>e?e.target:null))}function ul(e,t){let r=e.Ms.get(t)||nI.min();return e.persistence.runTransaction("Get new document changes","readonly",n=>e.xs.getAllFromCollectionGroup(n,t,nk(r,-1),Number.MAX_SAFE_INTEGER)).then(r=>(uu(e,t,r),r))}function uu(e,t,r){let n=e.Ms.get(t)||nI.min();r.forEach((e,t)=>{t.readTime.compareTo(n)>0&&(n=t.readTime)}),e.Ms.set(t,n)}async function uh(e,t,r,n){let i=aS(),s=aw;for(let e of r){let r=t.qs(e.metadata.name);e.document&&(i=i.add(r));let n=t.Ks(e);n.setReadTime(t.Us(e.metadata.readTime)),s=s.insert(r,n)}let a=e.xs.newChangeBuffer({trackRemovals:!0}),o=await ui(e,al(ai(nu.fromString(`__bundle__/docs/${n}`))));return e.persistence.runTransaction("Apply bundle documents","readwrite",t=>un(t,a,s).next(e=>(a.apply(t),e)).next(r=>e.li.removeMatchingKeysForTargetId(t,o.targetId).next(()=>e.li.addMatchingKeys(t,i,o.targetId)).next(()=>e.localDocuments.getLocalViewOfDocuments(t,r.Bs,r.Ls)).next(()=>r.Bs)))}async function uc(e,t,r=aS()){let n=await ui(e,al(oQ(t.bundledQuery)));return e.persistence.runTransaction("Save named query","readwrite",i=>{let s=ov(t.readTime);if(n.snapshotVersion.compareTo(s)>=0)return e.Pi.saveNamedQuery(i,t);let a=n.withResumeToken(i8.EMPTY_BYTE_STRING,s);return e.vs=e.vs.insert(a.targetId,a),e.li.updateTargetData(i,a).next(()=>e.li.removeMatchingKeysForTargetId(i,n.targetId)).next(()=>e.li.addMatchingKeys(i,r,n.targetId)).next(()=>e.Pi.saveNamedQuery(i,t))})}let ud="firestore_clients";function uf(e,t){return`${ud}_${e}_${t}`}let up="firestore_mutations";function ug(e,t,r){let n=`${up}_${e}_${r}`;return t.isAuthenticated()&&(n+=`_${t.uid}`),n}let um="firestore_targets";function uy(e,t){return`${um}_${e}_${t}`}
7let uw="SharedClientState";class uv{constructor(e,t,r,n){this.user=e,this.batchId=t,this.state=r,this.error=n}static $s(e,t,r){let n=JSON.parse(r),i,s="object"==typeof n&&-1!==["pending","acknowledged","rejected"].indexOf(n.state)&&(void 0===n.error||"object"==typeof n.error);return s&&n.error&&(s="string"==typeof n.error.message&&"string"==typeof n.error.code)&&(i=new r2(n.error.code,n.error.message)),s?new uv(e,t,n.state,i):(rQ(uw,`Failed to parse mutation state for ID '${t}': ${r}`),null)}Ws(){let e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class uI{constructor(e,t,r){this.targetId=e,this.state=t,this.error=r}static $s(e,t){let r=JSON.parse(t),n,i="object"==typeof r&&-1!==["not-current","current","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error);return i&&r.error&&(i="string"==typeof r.error.message&&"string"==typeof r.error.code)&&(n=new r2(r.error.code,r.error.message)),i?new uI(e,r.state,n):(rQ(uw,`Failed to parse target state for ID '${e}': ${t}`),null)}Ws(){let e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class ub{constructor(e,t){this.clientId=e,this.activeTargetIds=t}static $s(e,t){let r=JSON.parse(t),n="object"==typeof r&&r.activeTargetIds instanceof Array,i=aC;for(let e=0;n&&e<r.activeTargetIds.length;++e)n=nX(r.activeTargetIds[e]),i=i.add(r.activeTargetIds[e]);return n?new ub(e,i):(rQ(uw,`Failed to parse client data for instance '${e}': ${t}`),null)}}class uE{constructor(e,t){this.clientId=e,this.onlineState=t}static $s(e){let t=JSON.parse(e);return"object"==typeof t&&-1!==["Unknown","Online","Offline"].indexOf(t.onlineState)&&"string"==typeof t.clientId?new uE(t.clientId,t.onlineState):(rQ(uw,`Failed to parse online state: ${e}`),null)}}class uT{constructor(){this.activeTargetIds=aC}Qs(e){this.activeTargetIds=this.activeTargetIds.add(e)}Gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){return JSON.stringify({activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()})}}class u_{constructor(e,t,r,n,i){this.window=e,this.Ci=t,this.persistenceKey=r,this.zs=n,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.js=this.Js.bind(this),this.Hs=new iX(nn),this.started=!1,this.Zs=[];const s=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Xs=uf(this.persistenceKey,this.zs),this.Ys=function(e){return`firestore_sequence_number_${e}`}(this.persistenceKey),this.Hs=this.Hs.insert(this.zs,new uT),this.eo=RegExp(`^${ud}_${s}_([^_]*)$`),this.no=RegExp(`^${up}_${s}_(\\d+)(?:_(.*))?$`),this.ro=RegExp(`^${um}_${s}_(\\d+)$`),this.io=function(e){return`firestore_online_state_${e}`}(this.persistenceKey),this.so=function(e){return`firestore_bundle_loaded_v2_${e}`}(this.persistenceKey),this.window.addEventListener("storage",this.js)}static v(e){return!(!e||!e.localStorage)}async start(){for(let e of(await this.syncEngine.hs())){if(e===this.zs)continue;let t=this.getItem(uf(this.persistenceKey,e));if(t){let r=ub.$s(e,t);r&&(this.Hs=this.Hs.insert(r.clientId,r))}}this.oo();let e=this.storage.getItem(this.io);if(e){let t=this._o(e);t&&this.ao(t)}for(let e of this.Zs)this.Js(e);this.Zs=[],this.window.addEventListener("pagehide",()=>this.shutdown()),this.started=!0}writeSequenceNumber(e){this.setItem(this.Ys,JSON.stringify(e))}getAllActiveQueryTargets(){return this.uo(this.Hs)}isActiveQueryTarget(e){let t=!1;return this.Hs.forEach((r,n)=>{n.activeTargetIds.has(e)&&(t=!0)}),t}addPendingMutation(e){this.co(e,"pending")}updateMutationState(e,t,r){this.co(e,t,r),this.lo(e)}addLocalQueryTarget(e,t=!0){let r="not-current";if(this.isActiveQueryTarget(e)){let t=this.storage.getItem(uy(this.persistenceKey,e));if(t){let n=uI.$s(e,t);n&&(r=n.state)}}return t&&this.ho.Qs(e),this.oo(),r}removeLocalQueryTarget(e){this.ho.Gs(e),this.oo()}isLocalQueryTarget(e){return this.ho.activeTargetIds.has(e)}clearQueryState(e){this.removeItem(uy(this.persistenceKey,e))}updateQueryState(e,t,r){this.Po(e,t,r)}
7handleUserChange(e,t,r){t.forEach(e=>{this.lo(e)}),this.currentUser=e,r.forEach(e=>{this.addPendingMutation(e)})}setOnlineState(e){this.To(e)}notifyBundleLoaded(e){this.Eo(e)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.js),this.removeItem(this.Xs),this.started=!1)}getItem(e){let t=this.storage.getItem(e);return rW(uw,"READ",e,t),t}setItem(e,t){rW(uw,"SET",e,t),this.storage.setItem(e,t)}removeItem(e){rW(uw,"REMOVE",e),this.storage.removeItem(e)}Js(e){if(e.storageArea===this.storage){if(rW(uw,"EVENT",e.key,e.newValue),e.key===this.Xs)return void rQ("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Ci.enqueueRetryable(async()=>{if(this.started){if(null!==e.key){if(this.eo.test(e.key)){if(null==e.newValue){let t=this.Io(e.key);return this.Ro(t,null)}{let t=this.Ao(e.key,e.newValue);if(t)return this.Ro(t.clientId,t)}}else if(this.no.test(e.key)){if(null!==e.newValue){let t=this.Vo(e.key,e.newValue);if(t)return this.mo(t)}}else if(this.ro.test(e.key)){if(null!==e.newValue){let t=this.fo(e.key,e.newValue);if(t)return this.po(t)}}else if(e.key===this.io){if(null!==e.newValue){let t=this._o(e.newValue);if(t)return this.ao(t)}}else if(e.key===this.Ys){let t=function(e){let t=nQ.ce;if(null!=e)try{let r=JSON.parse(e);r0("number"==typeof r,30636,{yo:e}),t=r}catch(e){rQ(uw,"Failed to read sequence number from WebStorage",e)}return t}(e.newValue);t!==nQ.ce&&this.sequenceNumberHandler(t)}else if(e.key===this.so){let t=this.wo(e.newValue);await Promise.all(t.map(e=>this.syncEngine.So(e)))}}}else this.Zs.push(e)})}}get ho(){return this.Hs.get(this.zs)}oo(){this.setItem(this.Xs,this.ho.Ws())}co(e,t,r){let n=new uv(this.currentUser,e,t,r),i=ug(this.persistenceKey,this.currentUser,e);this.setItem(i,n.Ws())}lo(e){let t=ug(this.persistenceKey,this.currentUser,e);this.removeItem(t)}To(e){let t={clientId:this.zs,onlineState:e};this.storage.setItem(this.io,JSON.stringify(t))}Po(e,t,r){let n=uy(this.persistenceKey,e),i=new uI(e,t,r);this.setItem(n,i.Ws())}Eo(e){let t=JSON.stringify(Array.from(e));this.setItem(this.so,t)}Io(e){let t=this.eo.exec(e);return t?t[1]:null}Ao(e,t){let r=this.Io(e);return ub.$s(r,t)}Vo(e,t){let r=this.no.exec(e),n=Number(r[1]),i=void 0!==r[2]?r[2]:null;return uv.$s(new rz(i),n,t)}fo(e,t){let r=Number(this.ro.exec(e)[1]);return uI.$s(r,t)}_o(e){return uE.$s(e)}wo(e){return JSON.parse(e)}async mo(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.bo(e.batchId,e.state,e.error);rW(uw,`Ignoring mutation for non-active user ${e.user.uid}`)}po(e){return this.syncEngine.Do(e.targetId,e.state,e.error)}Ro(e,t){let r=t?this.Hs.insert(e,t):this.Hs.remove(e),n=this.uo(this.Hs),i=this.uo(r),s=[],a=[];return i.forEach(e=>{n.has(e)||s.push(e)}),n.forEach(e=>{i.has(e)||a.push(e)}),this.syncEngine.Co(s,a).then(()=>{this.Hs=r})}ao(e){this.Hs.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}uo(e){let t=aC;return e.forEach((e,r)=>{t=t.unionWith(r.activeTargetIds)}),t}}class uS{constructor(){this.vo=new uT,this.Fo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.vo.Qs(e),this.Fo[e]||"not-current"}updateQueryState(e,t,r){this.Fo[e]=t}removeLocalQueryTarget(e){this.vo.Gs(e)}isLocalQueryTarget(e){return this.vo.activeTargetIds.has(e)}clearQueryState(e){delete this.Fo[e]}getAllActiveQueryTargets(){return this.vo.activeTargetIds}isActiveQueryTarget(e){return this.vo.activeTargetIds.has(e)}start(){return this.vo=new uT,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class uC{Mo(e){}shutdown(){}}let uk="ConnectivityMonitor";class uA{constructor(){this.xo=()=>this.Oo(),this.No=()=>this.Bo(),this.Lo=[],this.ko()}Mo(e){this.Lo.push(e)}shutdown(){window.removeEventListener("online",this.xo),window.removeEventListener("offline",this.No)}ko(){window.addEventListener("online",this.xo),window.addEventListener("offline",this.No)}Oo(){for(let e of(rW(uk,"Network connectivity changed: AVAILABLE"),this.Lo))e(0)}Bo(){for(let e of(rW(uk,"Network connectivity changed: UNAVAILABLE"),this.Lo))e(1)}static v(){return"u">typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let ux=null;function uN(){return null===ux?ux=0x10000000+Math.round(0x80000000*Math.random()):ux++,"0x"+ux.toString(16)}let uR="RestConnection",uD={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregation
7Query:"runAggregationQuery",ExecutePipeline:"executePipeline"};class uP{get qo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),n=encodeURIComponent(this.databaseId.database);this.Ko=t+"://"+e.host,this.Uo=`projects/${r}/databases/${n}`,this.$o=this.databaseId.database===su?`project_id=${r}`:`project_id=${r}&database_id=${n}`}Wo(e,t,r,n,i){let s=uN(),a=this.Qo(e,t.toUriEncodedString());rW(uR,`Sending RPC '${e}' ${s}:`,a,r);let o={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.$o};this.Go(o,n,i);let{host:l}=new URL(a),u=(0,rF.isCloudWorkstation)(l);return this.zo(e,a,o,r,u).then(t=>(rW(uR,`Received RPC '${e}' ${s}: `,t),t),t=>{throw rJ(uR,`RPC '${e}' ${s} failed with error: `,t,"url: ",a,"request:",r),t})}jo(e,t,r,n,i,s){return this.Wo(e,t,r,n,i)}Go(e,t,r){e["X-Goog-Api-Client"]="gl-js/ fire/"+rK,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((t,r)=>e[r]=t),r&&r.headers.forEach((t,r)=>e[r]=t)}Qo(e,t){let r=uD[e],n=`${this.Ko}/v1/${t}:${r}`;return this.databaseInfo.apiKey&&(n=`${n}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),n}terminate(){}}class uO{constructor(e){this.Jo=e.Jo,this.Ho=e.Ho}Zo(e){this.Xo=e}Yo(e){this.e_=e}t_(e){this.n_=e}onMessage(e){this.r_=e}close(){this.Ho()}send(e){this.Jo(e)}i_(){this.Xo()}s_(){this.e_()}o_(e){this.n_(e)}__(e){this.r_(e)}}let uL="WebChannelConnection",uM=(e,t,r)=>{e.listen(t,e=>{try{r(e)}catch(e){setTimeout(()=>{throw e},0)}})};class uV extends uP{constructor(e){super(e),this.a_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static u_(){uV.c_||(uM(h(),u.STAT_EVENT,e=>{e.stat===l.PROXY?rW(uL,"STAT_EVENT: detected buffering proxy"):e.stat===l.NOPROXY&&rW(uL,"STAT_EVENT: detected no buffering proxy")}),uV.c_=!0)}zo(e,t,r,n,s){let l=uN();return new Promise((s,u)=>{let h=new i;h.setWithCredentials(!0),h.listenOnce(a.COMPLETE,()=>{try{switch(h.getLastErrorCode()){case o.NO_ERROR:let t=h.getResponseJson();rW(uL,`XHR for RPC '${e}' ${l} received:`,JSON.stringify(t)),s(t);break;case o.TIMEOUT:rW(uL,`RPC '${e}' ${l} timed out`),u(new r2(r1.DEADLINE_EXCEEDED,"Request time out"));break;case o.HTTP_ERROR:let r=h.getStatus();if(rW(uL,`RPC '${e}' ${l} failed with status:`,r,"response text:",h.getResponseText()),r>0){let e=h.getResponseJson();Array.isArray(e)&&(e=e[0]);let t=e?.error;if(t&&t.status&&t.message){let e,r=(e=t.status.toLowerCase().replace(/_/g,"-"),Object.values(r1).indexOf(e)>=0?e:r1.UNKNOWN);u(new r2(r,t.message))}else u(new r2(r1.UNKNOWN,"Server responded with status "+h.getStatus()))}else u(new r2(r1.UNAVAILABLE,"Connection failed."));break;default:rX(9055,{l_:e,streamId:l,h_:h.getLastErrorCode(),P_:h.getLastError()})}}finally{rW(uL,`RPC '${e}' ${l} completed.`)}});let c=JSON.stringify(n);rW(uL,`RPC '${e}' ${l} sending request:`,n),h.send(t,"POST",c,r,15)})}T_(e,t,r){let n=uN(),i=[this.Ko,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=this.createWebChannelTransport(),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},l=this.longPollingOptions.timeoutSeconds;void 0!==l&&(o.longPollingTimeout=Math.round(1e3*l)),this.useFetchStreams&&(o.useFetchStreams=!0),this.Go(o.initMessageHeaders,t,r),o.encodeInitMessageHeaders=!0;let u=i.join("");rW(uL,`Creating RPC '${e}' stream ${n}: ${u}`,o);let h=a.createWebChannel(u,o);this.E_(h);let c=!1,f=!1,p=new uO({Jo:t=>{f?rW(uL,`Not sending because RPC '${e}' stream ${n} is closed:`,t):(c||(rW(uL,`Opening RPC '${e}' stream ${n} transport.`),h.open(),c=!0),rW(uL,`RPC '${e}' stream ${n} sending:`,t),h.send(t))},Ho:()=>h.close()});return uM(h,s.EventType.OPEN,()=>{f||(rW(uL,`RPC '${e}' stream ${n} transport opened.`),p.i_())}),uM(h,s.EventType.CLOSE,()=>{f||(f=!0,rW(uL,`RPC '${e}' stream ${n} transport closed`),p.o_(),this.I_(h))}
7),uM(h,s.EventType.ERROR,t=>{f||(f=!0,rJ(uL,`RPC '${e}' stream ${n} transport errored. Name:`,t.name,"Message:",t.message),p.o_(new r2(r1.UNAVAILABLE,"The operation could not be completed")))}),uM(h,s.EventType.MESSAGE,t=>{if(!f){let r=t.data[0];r0(!!r,16349);let i=r?.error||r[0]?.error;if(i){rW(uL,`RPC '${e}' stream ${n} received error:`,i);let t=i.status,r=function(e){let t=d[e];if(void 0!==t)return a3(t)}(t),s=i.message;"NOT_FOUND"===t&&s.includes("database")&&s.includes("does not exist")&&s.includes(this.databaseId.database)&&rJ(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),void 0===r&&(r=r1.INTERNAL,s="Unknown error status: "+t+" with message "+i.message),f=!0,p.o_(new r2(r,s)),h.close()}else rW(uL,`RPC '${e}' stream ${n} received:`,r),p.__(r)}}),uV.u_(),setTimeout(()=>{p.s_()},0),p}terminate(){this.a_.forEach(e=>e.close()),this.a_=[]}E_(e){this.a_.push(e)}I_(e){this.a_=this.a_.filter(t=>t===e)}Go(e,t,r){super.Go(e,t,r),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return c()}}function uF(){return"u">typeof window?window:null}function uU(){return"u">typeof document?document:null}function uB(e){return new og(e,!0)}uV.c_=!1;class uj{constructor(e,t,r=1e3,n=1.5,i=6e4){this.Ci=e,this.timerId=t,this.R_=r,this.A_=n,this.V_=i,this.d_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.d_=0}g_(){this.d_=this.V_}p_(e){this.cancel();let t=Math.floor(this.d_+this.y_()),r=Math.max(0,Date.now()-this.f_),n=Math.max(0,t-r);n>0&&rW("ExponentialBackoff",`Backing off for ${n} ms (base delay: ${this.d_} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.m_=this.Ci.enqueueAfterDelay(this.timerId,n,()=>(this.f_=Date.now(),e())),this.d_*=this.A_,this.d_<this.R_&&(this.d_=this.R_),this.d_>this.V_&&(this.d_=this.V_)}w_(){null!==this.m_&&(this.m_.skipDelay(),this.m_=null)}cancel(){null!==this.m_&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.d_}}let uq="PersistentStream";class uz{constructor(e,t,r,n,i,s,a,o){this.Ci=e,this.S_=r,this.b_=n,this.connection=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=a,this.listener=o,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new uj(e,t)}x_(){return 1===this.state||5===this.state||this.O_()}O_(){return 2===this.state||3===this.state}start(){this.F_=0,4!==this.state?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&null===this.C_&&(this.C_=this.Ci.enqueueAfterDelay(this.S_,6e4,()=>this.k_()))}q_(e){this.K_(),this.stream.send(e)}async k_(){if(this.O_())return this.close(0)}K_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.K_(),this.U_(),this.M_.cancel(),this.D_++,4!==e?this.M_.reset():t&&t.code===r1.RESOURCE_EXHAUSTED?(rQ(t.toString()),rQ("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):t&&t.code===r1.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.W_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.t_(t)}W_(){}auth(){this.state=1;let e=this.Q_(this.D_),t=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([e,r])=>{this.D_===t&&this.G_(e,r)},t=>{e(()=>{let e=new r2(r1.UNKNOWN,"Fetching auth token failed: "+t.message);return this.z_(e)})})}G_(e,t){let r=this.Q_(this.D_);this.stream=this.j_(e,t),this.stream.Zo(()=>{r(()=>this.listener.Zo())}),this.stream.Yo(()=>{r(()=>(this.state=2,this.v_=this.Ci.enqueueAfterDelay(this.b_,1e4,()=>(this.O_()&&(this.state=3),Promise.resolve())),this.listener.Yo()))}),this.stream.t_(e=>{r(()=>this.z_(e))}),this.stream.onMessage(e=>{r(()=>1==++this.F_?this.J_(e):this.onNext(e))})}N_(){this.state=5,this.M_.p_(async()=>{this.state=0,this.start()})}z_(e){return rW(uq,`close with error: ${e}`),this.stream=null,this.close(4,e)}Q_(e){return t=>{this.Ci.enqueueAndForget(()=>this.D_===e?t():(rW(uq,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class uK extends uz{constructor(e,t,r,n,i,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,n,s),this.serializer
7=i}j_(e,t){return this.connection.T_("Listen",e,t)}J_(e){return this.onNext(e)}onNext(e){this.M_.reset();let t=function(e,t){let r;if("targetChange"in t){var n,i;t.targetChange;let s="NO_CHANGE"===(n=t.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===n?1:"REMOVE"===n?2:"CURRENT"===n?3:"RESET"===n?4:rX(39313,{state:n}),a=t.targetChange.targetIds||[],o=(i=t.targetChange.resumeToken,e.useProto3Json?(r0(void 0===i||"string"==typeof i,58123),i8.fromBase64String(i||"")):(r0(void 0===i||i instanceof rV.Buffer||i instanceof Uint8Array,16193),i8.fromUint8Array(i||new Uint8Array))),l=t.targetChange.cause;r=new oo(s,a,o,l&&new r2(void 0===l.code?r1.UNKNOWN:a3(l.code),l.message||"")||null)}else if("documentChange"in t){t.documentChange;let n=t.documentChange;n.document,n.document.name,n.document.updateTime;let i=o_(e,n.document.name),s=ov(n.document.updateTime),a=n.document.createTime?ov(n.document.createTime):nI.min(),o=new sV({mapValue:{fields:n.document.fields}}),l=sF.newFoundDocument(i,s,a,o);r=new os(n.targetIds||[],n.removedTargetIds||[],l.key,l)}else if("documentDelete"in t){t.documentDelete;let n=t.documentDelete;n.document;let i=o_(e,n.document),s=n.readTime?ov(n.readTime):nI.min(),a=sF.newNoDocument(i,s);r=new os([],n.removedTargetIds||[],a.key,a)}else if("documentRemove"in t){t.documentRemove;let n=t.documentRemove;n.document;let i=o_(e,n.document);r=new os([],n.removedTargetIds||[],i,null)}else{if(!("filter"in t))return rX(11601,{Vt:t});{t.filter;let e=t.filter;e.targetId;let{count:n=0,unchangedNames:i}=e,s=new a5(n,i);r=new oa(e.targetId,s)}}return r}(this.serializer,e),r=function(e){if(!("targetChange"in e))return nI.min();let t=e.targetChange;return t.targetIds&&t.targetIds.length?nI.min():t.readTime?ov(t.readTime):nI.min()}(e);return this.listener.H_(t,r)}Z_(e){let t,r={};r.database=ok(this.serializer),r.addTarget=function(e,t){let r,n=t.target;if((r=s7(n)?{documents:oP(e,n)}:{query:oO(e,n).ft}).targetId=t.targetId,t.resumeToken.approximateByteSize()>0){r.resumeToken=ow(e,t.resumeToken);let n=om(e,t.expectedCount);null!==n&&(r.expectedCount=n)}else if(t.snapshotVersion.compareTo(nI.min())>0){r.readTime=oy(e,t.snapshotVersion.toTimestamp());let n=om(e,t.expectedCount);null!==n&&(r.expectedCount=n)}return r}(this.serializer,e);let n=(this.serializer,null==(t=function(e){switch(e){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return rX(28987,{purpose:e})}}(e.purpose))?null:{"goog-listen-tags":t});n&&(r.labels=n),this.q_(r)}X_(e){let t={};t.database=ok(this.serializer),t.removeTarget=e,this.q_(t)}}class u$ extends uz{constructor(e,t,r,n,i,s){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,n,s),this.serializer=i}get Y_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}W_(){this.Y_&&this.ea([])}j_(e,t){return this.connection.T_("Write",e,t)}J_(e){return r0(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,r0(!e.writeResults||0===e.writeResults.length,55816),this.listener.ta()}onNext(e){var t,r;r0(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();let n=(t=e.writeResults,r=e.commitTime,t&&t.length>0?(r0(void 0!==r,14353),t.map(e=>{let t;return(t=e.updateTime?ov(e.updateTime):ov(r)).isEqual(nI.min())&&(t=ov(r)),new aB(t,e.transformResults||[])})):[]),i=ov(e.commitTime);return this.listener.na(i,n)}ra(){let e={};e.database=ok(this.serializer),this.q_(e)}ea(e){let t={streamToken:this.lastStreamToken,writes:e.map(e=>oR(this.serializer,e))};this.q_(t)}}class uG{}class uH extends uG{constructor(e,t,r,n){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=n,this.ia=!1}sa(){if(this.ia)throw new r2(r1.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,t,r,n){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,s])=>this.connection.Wo(e,ob(t,r),n,i,s)).catch(e=>{throw"FirebaseError"===e.name?(e.code===r1.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new r2(r1.UNKNOWN,e.toString())})}jo(e,t,r,n,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,a])=>this.connection.jo(e,ob(t,r),n,s,a,i)).catch(e=>{throw"FirebaseError"===e.name?(e.code===r1.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new r2(r1.UNKNOWN,e.toString())})}terminate(){this.ia=!0,this.connection.terminate()}}
7class uW{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){0===this.oa&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve())))}ha(e){"Online"===this.state?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ca("Offline")))}set(e){this.Pa(),this.oa=0,"Online"===e&&(this.aa=!1),this.ca(e)}ca(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}la(e){let t=`Could not reach Cloud Firestore backend. ${e}
8This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.aa?(rQ(t),this.aa=!1):rW("OnlineStateTracker",t)}Pa(){null!==this._a&&(this._a.cancel(),this._a=null)}}let uQ="RemoteStore";class uJ{constructor(e,t,r,n,i){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.Ta=[],this.Ea=new Map,this.Ia=new Set,this.Ra=[],this.Aa=i,this.Aa.Mo(e=>{r.enqueueAndForget(async()=>{u3(this)&&(rW(uQ,"Restarting streams for network reachability change."),await async function(e){e.Ia.add(4),await uX(e),e.Va.set("Unknown"),e.Ia.delete(4),await uY(e)}(this))})}),this.Va=new uW(r,n)}}async function uY(e){if(u3(e))for(let t of e.Ra)await t(!0)}async function uX(e){for(let t of e.Ra)await t(!1)}function uZ(e,t){e.Ea.has(t.targetId)||(e.Ea.set(t.targetId,t),u6(e)?u5(e):hc(e).O_()&&u1(e,t))}function u0(e,t){let r=hc(e);e.Ea.delete(t),r.O_()&&u2(e,t),0===e.Ea.size&&(r.O_()?r.L_():u3(e)&&e.Va.set("Unknown"))}function u1(e,t){if(e.da.$e(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(nI.min())>0){let r=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(r)}hc(e).Z_(t)}function u2(e,t){e.da.$e(t),hc(e).X_(t)}function u5(e){e.da=new ou({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),At:t=>e.Ea.get(t)||null,ht:()=>e.datastore.serializer.databaseId}),hc(e).start(),e.Va.ua()}function u6(e){return u3(e)&&!hc(e).x_()&&e.Ea.size>0}function u3(e){return 0===e.Ia.size}async function u8(e){e.Va.set("Online")}async function u4(e){e.Ea.forEach((t,r)=>{u1(e,t)})}async function u9(e,t){e.da=void 0,u6(e)?(e.Va.ha(t),u5(e)):e.Va.set("Unknown")}async function u7(e,t,r){if(e.Va.set("Online"),t instanceof oo&&2===t.state&&t.cause)try{await async function(e,t){let r=t.cause;for(let n of t.targetIds)e.Ea.has(n)&&(await e.remoteSyncer.rejectListen(n,r),e.Ea.delete(n),e.da.removeTarget(n))}(e,t)}catch(r){rW(uQ,"Failed to remove targets %s: %s ",t.targetIds.join(","),r),await he(e,r)}else if(t instanceof os?e.da.Xe(t):t instanceof oa?e.da.st(t):e.da.tt(t),!r.isEqual(nI.min()))try{let t,n=await ur(e.localStore);r.compareTo(n)>
8=0&&await ((t=e.da.Tt(r)).targetChanges.forEach((t,n)=>{if(t.resumeToken.approximateByteSize()>0){let i=e.Ea.get(n);i&&e.Ea.set(n,i.withResumeToken(t.resumeToken,r))}}),t.targetMismatches.forEach((t,r)=>{let n=e.Ea.get(t);if(!n)return;e.Ea.set(t,n.withResumeToken(i8.EMPTY_BYTE_STRING,n.snapshotVersion)),u2(e,t);let i=new oB(n.target,t,r,n.sequenceNumber);u1(e,i)}),e.remoteSyncer.applyRemoteEvent(t))}catch(t){rW(uQ,"Failed to raise snapshot:",t),await he(e,t)}}async function he(e,t,r){if(!nj(t))throw t;e.Ia.add(1),await uX(e),e.Va.set("Offline"),r||(r=()=>ur(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{rW(uQ,"Retrying IndexedDB access"),await r(),e.Ia.delete(1),await uY(e)})}function ht(e,t){return t().catch(r=>he(e,r,t))}async function hr(e){var t;let r=hd(e),n=e.Ta.length>0?e.Ta[e.Ta.length-1].batchId:-1;for(;u3(t=e)&&t.Ta.length<10;)try{let t=await function(e,t){return e.persistence.runTransaction("Get next mutation batch","readonly",r=>(void 0===t&&(t=-1),e.mutationQueue.getNextMutationBatchAfterBatchId(r,t)))}(e.localStore,n);if(null===t){0===e.Ta.length&&r.L_();break}n=t.batchId,function(e,t){e.Ta.push(t);let r=hd(e);r.O_()&&r.Y_&&r.ea(t.mutations)}(e,t)}catch(t){await he(e,t)}hn(e)&&hi(e)}function hn(e){return u3(e)&&!hd(e).x_()&&e.Ta.length>0}function hi(e){hd(e).start()}async function hs(e){hd(e).ra()}async function ha(e){let t=hd(e);for(let r of e.Ta)t.ea(r.mutations)}async function ho(e,t,r){let n=e.Ta.shift(),i=a1.from(n,t,r);await ht(e,()=>e.remoteSyncer.applySuccessfulWrite(i)),await hr(e)}async function hl(e,t){t&&hd(e).Y_&&await async function(e,t){var r;if(a6(r=t.code)&&r!==r1.ABORTED){let r=e.Ta.shift();hd(e).B_(),await ht(e,()=>e.remoteSyncer.rejectFailedWrite(r.batchId,t)),await hr(e)}}(e,t),hn(e)&&hi(e)}async function hu(e,t){e.asyncQueue.verifyOperationInProgress(),rW(uQ,"RemoteStore received new credentials");let r=u3(e);e.Ia.add(3),await uX(e),r&&e.Va.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.Ia.delete(3),await uY(e)}async function hh(e,t){t?(e.Ia.delete(2),await uY(e)):t||(e.Ia.add(2),await uX(e),e.Va.set("Unknown"))}function hc(e){var t,r,n;return e.ma||(t=e.datastore,r=e.asyncQueue,n={Zo:u8.bind(null,e),Yo:u4.bind(null,e),t_:u9.bind(null,e),H_:u7.bind(null,e)},t.sa(),e.ma=new uK(r,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,n),e.Ra.push(async t=>{t?(e.ma.B_(),u6(e)?u5(e):e.Va.set("Unknown")):(await e.ma.stop(),e.da=void 0)})),e.ma}function hd(e){var t,r,n;return e.fa||(t=e.datastore,r=e.asyncQueue,n={Zo:()=>Promise.resolve(),Yo:hs.bind(null,e),t_:hl.bind(null,e),ta:ha.bind(null,e),na:ho.bind(null,e)},t.sa(),e.fa=new u$(r,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,n),e.Ra.push(async t=>{t?(e.fa.B_(),await hr(e)):(await e.fa.stop(),e.Ta.length>0&&(rW(uQ,`Stopping write stream with ${e.Ta.length} pending writes`),e.Ta=[]))})),e.fa}class hf{constructor(e,t,r,n,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=n,this.removalCallback=i,this.deferred=new r5,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(e=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,n,i){let s=new hf(e,t,Date.now()+r,n,i);return s.start(r),s}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new r2(r1.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 hp(e,t){if(rQ("AsyncQueue",`${t}: ${e}`),nj(e))return new r2(r1.UNAVAILABLE,`${t}: ${e}`);throw e}class hg{static emptySet(e){return new hg(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||nd.comparator(t.key,r.key):(e,t)=>nd.comparator(e.key,t.key),this.keyedMap=aI(),this.sortedSet=new iX(this.comparator)}has(e){return null!=this.keyedMap.get(e)}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){let t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,r)=>(e(t),!1))}add(e){let t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){let t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof hg)||this.size!==e.size)return!1;let t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){let e=t.getNext().key,n=r.getNext().key;if(!e.isEqual(n))return!1}return!0}toString(){let e=[];return this.forEach(t=>{e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n  "+e.join("  \n")+"\n)"}copy(e,t){let r=new hg;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}class hm{constructor(){this.ga=new iX(nd.comparator)}track(e){let t=e.doc.key,r=this.ga.get(t);r?0!==e.type&&3===r.type?this.ga=this.ga.insert(t,e):3===e.type&&1!==r.type?this.ga=this.ga.insert(t,{type:r.type,doc:e.doc}):2===e.type&&2===r.type?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):2===e.type&&0===r.type?this.ga=this.ga.insert(t,{type:0,doc:e.doc}):1===e.type&&0===r.type?this.ga=this.ga.remove(t):1===e.type&&2===r.type?this.ga=this.ga.insert(t,{type:1,doc:r.doc}):0===e.type&&1===r.type?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):rX(63341,{Vt:e,pa:r}):this.ga=this.ga.insert(t,e)}ya(){let e=[];return this.ga.inorderTraversal((t,r)=>{e.push(r)}),e}}class hy{constructor(e,t,r,n,i,s,a,o,l){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=n,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=a,this.excludesMetadataChanges=o,this.hasCachedResults=l}static fromInitialDocuments(e,t,r,n,i){let s=[];
8return t.forEach(e=>{s.push({type:0,doc:e})}),new hy(e,t,hg.emptySet(t),s,r,n,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&ac(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let e=0;e<t.length;e++)if(t[e].type!==r[e].type||!t[e].doc.isEqual(r[e].doc))return!1;return!0}}class hw{constructor(){this.wa=void 0,this.Sa=[]}ba(){return this.Sa.some(e=>e.Da())}}class hv{constructor(){this.queries=hI(),this.onlineState="Unknown",this.Ca=new Set}terminate(){var e;let t;e=new r2(r1.ABORTED,"Firestore shutting down"),t=this.queries,this.queries=hI(),t.forEach((t,r)=>{for(let t of r.Sa)t.onError(e)})}}function hI(){return new ay(e=>ad(e),ac)}async function hb(e,t){let r=3,n=t.query,i=e.queries.get(n);i?!i.ba()&&t.Da()&&(r=2):(i=new hw,r=+!t.Da());try{switch(r){case 0:i.wa=await e.onListen(n,!0);break;case 1:i.wa=await e.onListen(n,!1);break;case 2:await e.onFirstRemoteStoreListen(n)}}catch(r){let e=hp(r,`Initialization of query '${af(t.query)}' failed`);return void t.onError(e)}e.queries.set(n,i),i.Sa.push(t),t.va(e.onlineState),i.wa&&t.Fa(i.wa)&&hS(e)}async function hE(e,t){let r=t.query,n=3,i=e.queries.get(r);if(i){let e=i.Sa.indexOf(t);e>=0&&(i.Sa.splice(e,1),0===i.Sa.length?n=+!t.Da():!i.ba()&&t.Da()&&(n=2))}switch(n){case 0:return e.queries.delete(r),e.onUnlisten(r,!0);case 1:return e.queries.delete(r),e.onUnlisten(r,!1);case 2:return e.onLastRemoteStoreUnlisten(r);default:return}}function hT(e,t){let r=!1;for(let n of t){let t=n.query,i=e.queries.get(t);if(i){for(let e of i.Sa)e.Fa(n)&&(r=!0);i.wa=n}}r&&hS(e)}function h_(e,t,r){let n=e.queries.get(t);if(n)for(let e of n.Sa)e.onError(r);e.queries.delete(t)}function hS(e){e.Ca.forEach(e=>{e.next()})}(g=p||(p={})).Ma="default",g.Cache="cache";class hC{constructor(e,t,r){this.query=e,this.xa=t,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=r||{}}Fa(e){if(!this.options.includeMetadataChanges){let t=[];for(let r of e.docChanges)3!==r.type&&t.push(r);e=new hy(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Oa?this.Ba(e)&&(this.xa.next(e),t=!0):this.La(e,this.onlineState)&&(this.ka(e),t=!0),this.Na=e,t}onError(e){this.xa.error(e)}va(e){this.onlineState=e;let t=!1;return this.Na&&!this.Oa&&this.La(this.Na,e)&&(this.ka(this.Na),t=!0),t}La(e,t){return!(e.fromCache&&this.Da())||(!this.options.qa||"Offline"===t)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}Ba(e){if(e.docChanges.length>0)return!0;let t=this.Na&&this.Na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}ka(e){e=hy.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==p.Cache}}class hk{constructor(e,t){this.Ka=e,this.byteLength=t}Ua(){return"metadata"in this.Ka}}class hA{constructor(e){this.serializer=e}qs(e){return o_(this.serializer,e)}Ks(e){return e.metadata.exists?oN(this.serializer,e.document,!1):sF.newNoDocument(this.qs(e.metadata.name),this.Us(e.metadata.readTime))}Us(e){return ov(e)}}class hx{constructor(e,t){this.$a=e,this.serializer=t,this.Wa=[],this.Qa=[],this.collectionGroups=new Set,this.progress=hN(e)}get queries(){return this.Wa}get documents(){return this.Qa}Ga(e){this.progress.bytesLoaded+=e.byteLength;let t=this.progress.documentsLoaded;if(e.Ka.namedQuery)this.Wa.push(e.Ka.namedQuery);else if(e.Ka.documentMetadata){this.Qa.push({metadata:e.Ka.documentMetadata}),e.Ka.documentMetadata.exists||++t;let r=nu.fromString(e.Ka.documentMetadata.name);this.collectionGroups.add(r.get(r.length-2))}else e.Ka.document&&(this.Qa[this.Qa.length-1].document=e.Ka.document,++t);return t!==this.progress.documentsLoaded?(this.progress.documentsLoaded=t,{...this.progress}):null}za(e){let t=new Map,r=new hA(this.serializer);for(let n of e)if(n.metadata.queries){let e=r.qs(n.metadata.name);for(let r of n.metadata.queries){let n=(t.get(r)||aS()).add(e);t.set(r,n)}}return t}async ja(e){let t=await uh(e,new hA(this.serializer),this.Qa,this.$a.id),r=this.za(this.documents);for(let t of this.Wa)await uc(e,t,r.get(t.name));return this.progress.taskState="Success",{progress:this.progress,Ja:this.collectionGroups,Ha:t}}}function hN(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}class hR{constructor(e){this.key=e}}class hD{constructor(e){this.key=e}}class hP{constructor(e,t){this.query=e,this.Za=t,this.Xa=null,this.hasCachedResults=!1,this.current=!1,this.Ya=aS(),this.mutatedKeys=aS(),this.eu=am(e),this.tu=new hg(this.eu)}get nu(){return this.Za}ru(e,t){let r=t?t.iu:new hm,n=t?t.tu:this.tu,i=t?t.mutatedKeys:this.mutatedKeys,s=n,a=!1,o="F"===this.query.limitType&&n.size===this.query.limit?n.last(
8):null,l="L"===this.query.limitType&&n.size===this.query.limit?n.first():null;if(e.inorderTraversal((e,t)=>{let u=n.get(e),h=ap(this.query,t)?t:null,c=!!u&&this.mutatedKeys.has(u.key),d=!!h&&(h.hasLocalMutations||this.mutatedKeys.has(h.key)&&h.hasCommittedMutations),f=!1;u&&h?u.data.isEqual(h.data)?c!==d&&(r.track({type:3,doc:h}),f=!0):this.su(u,h)||(r.track({type:2,doc:h}),f=!0,(o&&this.eu(h,o)>0||l&&0>this.eu(h,l))&&(a=!0)):!u&&h?(r.track({type:0,doc:h}),f=!0):u&&!h&&(r.track({type:1,doc:u}),f=!0,(o||l)&&(a=!0)),f&&(h?(s=s.add(h),i=d?i.add(e):i.delete(e)):(s=s.delete(e),i=i.delete(e)))}),null!==this.query.limit)for(;s.size>this.query.limit;){let e="F"===this.query.limitType?s.last():s.first();s=s.delete(e.key),i=i.delete(e.key),r.track({type:1,doc:e})}return{tu:s,iu:r,bs:a,mutatedKeys:i}}su(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,n){let i=this.tu;this.tu=e.tu,this.mutatedKeys=e.mutatedKeys;let s=e.iu.ya();s.sort((e,t)=>{var r,n;let i;return r=e.type,n=t.type,(i=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return rX(20277,{Vt:e})}})(r)-i(n)||this.eu(e.doc,t.doc)}),this.ou(r),n=n??!1;let a=t&&!n?this._u():[],o=0===this.Ya.size&&this.current&&!n?1:0,l=o!==this.Xa;return(this.Xa=o,0!==s.length||l)?{snapshot:new hy(this.query,e.tu,i,s,e.mutatedKeys,0===o,l,!1,!!r&&r.resumeToken.approximateByteSize()>0),au:a}:{au:a}}va(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({tu:this.tu,iu:new hm,mutatedKeys:this.mutatedKeys,bs:!1},!1)):{au:[]}}uu(e){return!this.Za.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach(e=>this.Za=this.Za.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.Za=this.Za.delete(e)),this.current=e.current)}_u(){if(!this.current)return[];let e=this.Ya;this.Ya=aS(),this.tu.forEach(e=>{this.uu(e.key)&&(this.Ya=this.Ya.add(e.key))});let t=[];return e.forEach(e=>{this.Ya.has(e)||t.push(new hD(e))}),this.Ya.forEach(r=>{e.has(r)||t.push(new hR(r))}),t}cu(e){this.Za=e.ks,this.Ya=aS();let t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return hy.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,0===this.Xa,this.hasCachedResults)}}let hO="SyncEngine";class hL{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class hM{constructor(e){this.key=e,this.hu=!1}}class hV{constructor(e,t,r,n,i,s){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=n,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.Pu={},this.Tu=new ay(e=>ad(e),ac),this.Eu=new Map,this.Iu=new Set,this.Ru=new iX(nd.comparator),this.Au=new Map,this.Vu=new lK,this.du={},this.mu=new Map,this.fu=lT.ar(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return!0===this.gu}}async function hF(e,t,r=!0){let n,i=ci(e),s=i.Tu.get(t);return s?(i.sharedClientState.addLocalQueryTarget(s.targetId),n=s.view.lu()):n=await hB(i,t,r,!0),n}async function hU(e,t){let r=ci(e);await hB(r,t,!0,!1)}async function hB(e,t,r,n){let i,s=await ui(e.localStore,al(t)),a=s.targetId,o=e.sharedCl
8ientState.addLocalQueryTarget(a,r);return n&&(i=await hj(e,t,a,"current"===o,s.resumeToken)),e.isPrimaryClient&&r&&uZ(e.remoteStore,s),i}async function hj(e,t,r,n,i){e.pu=(t,r,n)=>(async function(e,t,r,n){let i=t.view.ru(r);i.bs&&(i=await ua(e.localStore,t.query,!1).then(({documents:e})=>t.view.ru(e,i)));let s=n&&n.targetChanges.get(t.targetId),a=n&&null!=n.targetMismatches.get(t.targetId),o=t.view.applyChanges(i,e.isPrimaryClient,s,a);return h0(e,t.targetId,o.au),o.snapshot})(e,t,r,n);let s=await ua(e.localStore,t,!0),a=new hP(t,s.ks),o=a.ru(s.documents),l=oi.createSynthesizedTargetChangeForCurrentChange(r,n&&"Offline"!==e.onlineState,i),u=a.applyChanges(o,e.isPrimaryClient,l);h0(e,r,u.au);let h=new hL(t,r,a);return e.Tu.set(t,h),e.Eu.has(r)?e.Eu.get(r).push(t):e.Eu.set(r,[t]),u.snapshot}async function hq(e,t,r){let n=e.Tu.get(t),i=e.Eu.get(n.targetId);i.length>1?(e.Eu.set(n.targetId,i.filter(e=>!ac(e,t))),e.Tu.delete(t)):e.isPrimaryClient?(e.sharedClientState.removeLocalQueryTarget(n.targetId),e.sharedClientState.isActiveQueryTarget(n.targetId)||await us(e.localStore,n.targetId,!1).then(()=>{e.sharedClientState.clearQueryState(n.targetId),r&&u0(e.remoteStore,n.targetId),hX(e,n.targetId)}).catch(nP)):(hX(e,n.targetId),await us(e.localStore,n.targetId,!0))}async function hz(e,t){let r=e.Tu.get(t),n=e.Eu.get(r.targetId);e.isPrimaryClient&&1===n.length&&(e.sharedClientState.removeLocalQueryTarget(r.targetId),u0(e.remoteStore,r.targetId))}async function hK(e,t,r){let n=cs(e);try{var i,s;let e,a,o,l,u,h=await (i=n.localStore,o=nv.now(),l=t.reduce((e,t)=>e.add(t.key),aS()),i.persistence.runTransaction("Locally write mutations","readwrite",r=>{let n=aw,s=aS();return i.xs.getEntries(r,l).next(e=>{(n=e).forEach((e,t)=>{t.isValidDocument()||(s=s.add(e))})}).next(()=>i.localDocuments.getOverlayedDocuments(r,n)).next(n=>{e=n;let s=[];for(let r of t){let t=function(e,t){let r=null;for(let n of e.fieldTransforms){let e=t.data.field(n.field),i=aN(n.transform,e||null);null!=i&&(null===r&&(r=sV.empty()),r.set(n.field,i))}return r||null}(r,e.get(r.key).overlayedDocument);null!=t&&s.push(new aW(r.key,t,function e(t){let r=[];return iJ(t.fields,(t,n)=>{let i=new nc([t]);if(sN(n)){let t=e(n.mapValue).fields;if(0===t.length)r.push(i);else for(let e of t)r.push(i.child(e))}else r.push(i)}),new i6(r)}(t.value.mapValue),aj.exists(!0)))}
8return i.mutationQueue.addMutationBatch(r,o,s,t)}).next(t=>{a=t;let n=t.applyToLocalDocumentSet(e,s);return i.documentOverlayCache.saveOverlays(r,t.batchId,n)})}).then(()=>({batchId:a.batchId,changes:ab(e)})));n.sharedClientState.addPendingMutation(h.batchId),s=h.batchId,(u=n.du[n.currentUser.toKey()])||(u=new iX(nn)),u=u.insert(s,r),n.du[n.currentUser.toKey()]=u,await h2(n,h.changes),await hr(n.remoteStore)}catch(t){let e=hp(t,"Failed to persist write");r.reject(e)}}async function h$(e,t){try{var r,n;let i,s,a=await (r=e.localStore,i=(n=t).snapshotVersion,s=r.vs,r.persistence.runTransaction("Apply remote event","readwrite-primary",e=>{let t=r.xs.newChangeBuffer({trackRemovals:!0});s=r.vs;let a=[];n.targetChanges.forEach((t,o)=>{var l;let u=s.get(o);if(!u)return;a.push(r.li.removeMatchingKeys(e,t.removedDocuments,o).next(()=>r.li.addMatchingKeys(e,t.addedDocuments,o)));let h=u.withSequenceNumber(e.currentSequenceNumber);null!==n.targetMismatches.get(o)?h=h.withResumeToken(i8.EMPTY_BYTE_STRING,nI.min()).withLastLimboFreeSnapshotVersion(nI.min()):t.resumeToken.approximateByteSize()>0&&(h=h.withResumeToken(t.resumeToken,i)),s=s.insert(o,h),l=h,(0===u.resumeToken.approximateByteSize()||l.snapshotVersion.toMicroseconds()-u.snapshotVersion.toMicroseconds()>=3e8||t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size>0)&&a.push(r.li.updateTargetData(e,h))});let o=aw,l=aS();if(n.documentUpdates.forEach(t=>{n.resolvedLimboDocuments.has(t)&&a.push(r.persistence.referenceDelegate.updateLimboDocument(e,t))}),a.push(un(e,t,n.documentUpdates).next(e=>{o=e.Bs,l=e.Ls})),!i.isEqual(nI.min())){let t=r.li.getLastRemoteSnapshotVersion(e).next(t=>r.li.setTargetsMetadata(e,e.currentSequenceNumber,i));a.push(t)}return nO.waitFor(a).next(()=>t.apply(e)).next(()=>r.localDocuments.getLocalViewOfDocuments(e,o,l)).next(()=>o)}).then(e=>(r.vs=s,e)));
8t.targetChanges.forEach((t,r)=>{let n=e.Au.get(r);n&&(r0(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1,22616),t.addedDocuments.size>0?n.hu=!0:t.modifiedDocuments.size>0?r0(n.hu,14607):t.removedDocuments.size>0&&(r0(n.hu,42227),n.hu=!1))}),await h2(e,a,t)}catch(e){await nP(e)}}function hG(e,t,r){if(e.isPrimaryClient&&0===r||!e.isPrimaryClient&&1===r){var n;let r,i=[];e.Tu.forEach((e,r)=>{let n=r.view.va(t);n.snapshot&&i.push(n.snapshot)}),(n=e.eventManager).onlineState=t,r=!1,n.queries.forEach((e,n)=>{for(let e of n.Sa)e.va(t)&&(r=!0)}),r&&hS(n),i.length&&e.Pu.H_(i),e.onlineState=t,e.isPrimaryClient&&e.sharedClientState.setOnlineState(t)}}async function hH(e,t,r){e.sharedClientState.updateQueryState(t,"rejected",r);let n=e.Au.get(t),i=n&&n.key;if(i){let r=new iX(nd.comparator);r=r.insert(i,sF.newNoDocument(i,nI.min()));let n=aS().add(i),s=new on(nI.min(),new Map,new iX(nn),r,n);await h$(e,s),e.Ru=e.Ru.remove(i),e.Au.delete(t),h1(e)}else await us(e.localStore,t,!1).then(()=>hX(e,t,r)).catch(nP)}async function hW(e,t){let r=t.batch.batchId;try{var n,i;let s=await (n=e.localStore,i=t,n.persistence.runTransaction("Acknowledge batch","readwrite-primary",e=>{let t,r,s,a=i.batch.keys(),o=n.xs.newChangeBuffer({trackRemovals:!0});return(r=(t=i.batch).keys(),s=nO.resolve(),r.forEach(r=>{s=s.next(()=>o.getEntry(e,r)).next(e=>{let n=i.docVersions.get(r);r0(null!==n,48541),0>e.version.compareTo(n)&&(t.applyToRemoteDocument(e,i),e.isValidDocument()&&(e.setReadTime(i.commitVersion),o.addEntry(e)))})}),s.next(()=>n.mutationQueue.removeMutationBatch(e,t))).next(()=>o.apply(e)).next(()=>n.mutationQueue.performConsistencyCheck(e)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(e,a,i.batch.batchId)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=aS();for(let r=0;r<e.mutationResults.length;++r)e.mutationResults[r].transformResults.length>0&&(t=t.add(e.batch.mutations[r].key));return t}(i))).next(()=>n.localDocuments.getDocuments(e,a))}));hY(e,r,null),hJ(e,r),e.sharedClientState.updateMutationState(r,"acknowledged"),await h2(e,s)}catch(e){await nP(e)}}async function hQ(e,t,r){try{var n;let i=await (n=e.localStore,n.persistence.runTransaction("Reject batch","readwrite-primary",e=>{let r;
8return n.mutationQueue.lookupMutationBatch(e,t).next(t=>(r0(null!==t,37113),r=t.keys(),n.mutationQueue.removeMutationBatch(e,t))).next(()=>n.mutationQueue.performConsistencyCheck(e)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,r)).next(()=>n.localDocuments.getDocuments(e,r))}));hY(e,t,r),hJ(e,t),e.sharedClientState.updateMutationState(t,"rejected",r),await h2(e,i)}catch(e){await nP(e)}}function hJ(e,t){(e.mu.get(t)||[]).forEach(e=>{e.resolve()}),e.mu.delete(t)}function hY(e,t,r){let n=e.du[e.currentUser.toKey()];if(n){let i=n.get(t);i&&(r?i.reject(r):i.resolve(),n=n.remove(t)),e.du[e.currentUser.toKey()]=n}}function hX(e,t,r=null){for(let n of(e.sharedClientState.removeLocalQueryTarget(t),e.Eu.get(t)))e.Tu.delete(n),r&&e.Pu.yu(n,r);e.Eu.delete(t),e.isPrimaryClient&&e.Vu.Gr(t).forEach(t=>{e.Vu.containsKey(t)||hZ(e,t)})}function hZ(e,t){e.Iu.delete(t.path.canonicalString());let r=e.Ru.get(t);null!==r&&(u0(e.remoteStore,r),e.Ru=e.Ru.remove(t),e.Au.delete(r),h1(e))}function h0(e,t,r){for(let n of r)n instanceof hR?(e.Vu.addReference(n.key,t),function(e,t){let r=t.key,n=r.path.canonicalString();e.Ru.get(r)||e.Iu.has(n)||(rW(hO,"New document in limbo: "+r),e.Iu.add(n),h1(e))}(e,n)):n instanceof hD?(rW(hO,"Document no longer in limbo: "+n.key),e.Vu.removeReference(n.key,t),e.Vu.containsKey(n.key)||hZ(e,n.key)):rX(19791,{wu:n})}function h1(e){for(;e.Iu.size>0&&e.Ru.size<e.maxConcurrentLimboResolutions;){let t=e.Iu.values().next().value;e.Iu.delete(t);let r=new nd(nu.fromString(t)),n=e.fu.next();e.Au.set(n,new hM(r)),e.Ru=e.Ru.insert(r,n),uZ(e.remoteStore,new oB(al(ai(r.path)),n,"TargetPurposeLimboResolution",nQ.ce))}}async function h2(e,t,r){let n=[],i=[],s=[];e.Tu.isEmpty()||(e.Tu.forEach((a,o)=>{s.push(e.pu(o,t,r).then(t=>{if((t||r)&&e.isPrimaryClient){let n=t?!t.fromCache:r?.targetChanges.get(o.targetId)?.current;e.sharedClientState.updateQueryState(o.targetId,n?"current":"not-current")}if(t){n.push(t);let e=l8.Is(o.targetId,t);i.push(e)}}))}),await Promise.all(s),e.Pu.H_(n),await async function(e,t){try{await e.persistence.runTransaction("notifyLocalViewChanges","readwrite",r=>nO.forEach(t,t=>nO.forEach(t.Ts,n=>e.persistence.referenceDelegate.addReference(r,t.targetId,n)).next(()=>nO.forEach(t.Es,n=>e.persistence.referenceDelegate.removeReference(r,t.targetId,n)))))}catch(e){if(!nj(e))throw e;rW(l7,"Failed to update sequence numbers: "+e)}for(let r of t){let t=r.targetId;if(!r.fromCache){let r=e.vs.get(t),n=r.snapshotVersion,i=r.withLastLimboFreeSnapshotVersion(n);e.vs=e.vs.insert(t,i)}}}(e.localStore,i))}async function h5(e,t){if(!e.currentUser.isEqual(t)){rW(hO,"User change. New user:",t.toKey());let r=await ut(e.localStore,t);e.currentUser=t,e.mu.forEach(e=>{e.forEach(e=>{e.reject(new r2(r1.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.mu.clear(),e.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),await h2(e,r.Ns)}}function h6(e,t){let r=e.Au.get(t);if(r&&r.hu)return aS().add(r.key);{let r=aS(),n=e.Eu.get(t);if(!n)return r;for(let t of n){let n=e.Tu.get(t);r=r.unionWith(n.view.nu)}return r}}async function h3(e,t){let r=await ua(e.localStore,t.query,!0),n=t.view.cu(r);return e.isPrimaryClient&&h0(e,t.targetId,n.au),n}async function h8(e,t){return ul(e.localStore,t).then(t=>h2(e,t))}async function h4(e,t,r,n){var i,s;let a,o=await (i=e.localStore,a=i.mutationQueue,i.persistence.runTransaction("Lookup mutation documents","readonly",e=>a.Xn(e,t).next(t=>t?i.localDocuments.getDocuments(e,t):nO.resolve(null))));null!==o?("pending"===r?await hr(e.remoteStore):"acknowledged"===r||"rejected"===r?(hY(e,t,n||null),hJ(e,t),s=e.localStore,s.mutationQueue.nr(t)):rX(6720,"Unknown batchState",{Su:r}),await h2(e,o)):rW(hO,"Cannot apply mutation batch with id: "+t)}async function h9(e,t){if(ci(e),cs(e),!0===t&&!0!==e.gu){let t=e.sharedClientState.getAllActiveQueryTargets(),r=await h7(e,t.toArray());for(let t of(e.gu=!0,await hh(e.remoteStore,!0),r))uZ(e.remoteStore,t)}else if(!1===t&&!1!==e.gu){let t=[],r=Promise.resolve();e.Eu.forEach((n,i)=>
8{e.sharedClientState.isLocalQueryTarget(i)?t.push(i):r=r.then(()=>(hX(e,i),us(e.localStore,i,!0))),u0(e.remoteStore,i)}),await r,await h7(e,t),e.Au.forEach((t,r)=>{u0(e.remoteStore,r)}),e.Vu.zr(),e.Au=new Map,e.Ru=new iX(nd.comparator),e.gu=!1,await hh(e.remoteStore,!1)}}async function h7(e,t,r){let n=[],i=[];for(let r of t){let t,s=e.Eu.get(r);if(s&&0!==s.length)for(let r of(t=await ui(e.localStore,al(s[0])),s)){let t=e.Tu.get(r),n=await h3(e,t);n.snapshot&&i.push(n.snapshot)}else{let n=await uo(e.localStore,r);t=await ui(e.localStore,n),await hj(e,ce(n),r,!1,t.resumeToken)}n.push(t)}return e.Pu.H_(i),n}function ce(e){var t,r,n,i,s;return t=e.path,r=e.collectionGroup,n=e.orderBy,i=e.filters,s=e.limit,new an(t,r,n,i,s,"F",e.startAt,e.endAt)}function ct(e){return e.localStore.persistence.hs()}async function cr(e,t,r,n){if(e.gu)return void rW(hO,"Ignoring unexpected query state notification.");let i=e.Eu.get(t);if(i&&i.length>0)switch(r){case"current":case"not-current":{let n=await ul(e.localStore,ag(i[0])),s=on.createSynthesizedRemoteEventForCurrentChange(t,"current"===r,i8.EMPTY_BYTE_STRING);await h2(e,n,s);break}case"rejected":await us(e.localStore,t,!0),hX(e,t,n);break;default:rX(64155,r)}}async function cn(e,t,r){let n=ci(e);if(n.gu){for(let e of t){if(n.Eu.has(e)&&n.sharedClientState.isActiveQueryTarget(e)){rW(hO,"Adding an already active target "+e);continue}let t=await uo(n.localStore,e),r=await ui(n.localStore,t);await hj(n,ce(t),r.targetId,!1,r.resumeToken),uZ(n.remoteStore,r)}for(let e of r)n.Eu.has(e)&&await us(n.localStore,e,!1).then(()=>{u0(n.remoteStore,e),hX(n,e)}).catch(nP)}}function ci(e){return e.remoteStore.remoteSyncer.applyRemoteEvent=h$.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=h6.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=hH.bind(null,e),e.Pu.H_=hT.bind(null,e.eventManager),e.Pu.yu=h_.bind(null,e.eventManager),e}function cs(e){return e.remoteStore.remoteSyncer.applySuccessfulWrite=hW.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=hQ.bind(null,e),e}class ca{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=uB(e.databaseInfo.databaseId),this.sharedClientState=this.Du(e),this.persistence=this.Cu(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Fu(e,this.localStore),this.indexBackfillerScheduler=this.Mu(e,this.localStore)}Fu(e,t){return null}Mu(e,t){return null}vu(e){var t,r;return t=this.persistence,r=new l9,new ue(t,r,e.initialUser,this.serializer)}Cu(e){return new lJ(lX.Vi,this.serializer)}Du(e){return new uS}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}ca.provider={build:()=>new ca};class co extends ca{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){return r0(this.persistence.referenceDelegate instanceof lZ,46915),new lx(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}Cu(e){let t=void 0!==this.cacheSizeBytes?ly.withCacheSize(this.cacheSizeBytes):ly.DEFAULT;return new lJ(e=>lZ.Vi(e,t),this.serializer)}}class cl extends ca{constructor(e,t,r){super(),this.xu=e,this.cacheSizeBytes=t,this.forceOwnership=r,this.kind="persistent",this.synchronizeTabs=!1}async initialize(e){await super.initialize(e),await this.xu.initialize(this,e),await cs(this.xu.syncEngine),await hr(this.xu.remoteStore),await this.persistence.zi(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve()))}vu(e){var t,r;return t=this.persistence,r=new l9,new ue(t,r,e.initialUser,this.serializer)}Fu(e,t){return new lx(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}Mu(e,t){let r=new nW(t,this.persistence);return new nH(e.asyncQueue,r)}Cu(e){let t=l3(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),r=void 0!==this.cacheSizeBytes?ly.withCacheSize(this.cacheSizeBytes):ly.DEFAULT;return new l6(this.synchronizeTabs,t,e.clientId,r,e.asyncQueue,uF(),uU(),this.serializer,this.sharedCl
8ientState,!!this.forceOwnership)}Du(e){return new uS}}class cu{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=>hG(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=h5.bind(null,this.syncEngine),await hh(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new hv}createDatastore(e){var t;let r=uB(e.databaseInfo.databaseId),n=new uV(e.databaseInfo);return t=e.authCredentials,new uH(t,e.appCheckCredentials,n,r)}createRemoteStore(e){var t,r;return t=this.localStore,r=this.datastore,new uJ(t,r,e.asyncQueue,e=>hG(this.syncEngine,e,0),uA.v()?new uA:new uC)}createSyncEngine(e,t){var r,n,i,s,a,o;let l;return r=this.localStore,n=this.remoteStore,i=this.eventManager,s=this.sharedClientState,a=e.initialUser,o=e.maxConcurrentLimboResolutions,l=new hV(r,n,i,s,a,o),t&&(l.gu=!0),l}async terminate(){await async function(e){rW(uQ,"RemoteStore shutting down."),e.Ia.add(5),await uX(e),e.Aa.shutdown(),e.Va.set("Unknown")}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}function ch(e,t=10240){let r=0;return{async read(){if(r<e.byteLength){let n={value:e.slice(r,r+t),done:!1};return r+=t,n}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.resolve()}}cu.provider={build:()=>new cu};class cc{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ou(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ou(this.observer.error,e):rQ("Uncaught Error in snapshot listener:",e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout(()=>{this.muted||e(t)},0)}}class cd{constructor(e,t){this.Bu=e,this.serializer=t,this.metadata=new r5,this.buffer=new Uint8Array,this.Lu=new TextDecoder("utf-8"),this.ku().then(e=>{e&&e.Ua()?this.metadata.resolve(e.Ka.metadata):this.metadata.reject(Error(`The first element of the bundle is not a metadata, it is
9             ${JSON.stringify(e?.Ka)}`))},e=>this.metadata.reject(e))}close(){return this.Bu.cancel()}async getMetadata(){return this.metadata.promise}async bu(){return await this.getMetadata(),this.ku()}async ku(){let e=await this.qu();if(null===e)return null;let t=this.Lu.decode(e),r=Number(t);return isNaN(r)&&this.Ku(`length string (${t}) is not valid number`),new hk(JSON.parse(await this.Uu(r)),e.length+r)}$u(){return this.buffer.findIndex(e=>123===e)}async qu(){for(;0>this.$u()&&!await this.Wu(););if(0===this.buffer.length)return null;let e=this.$u();e<0&&this.Ku("Reached the end of bundle when a length string is expected.");let t=this.buffer.slice(0,e);return this.buffer=this.buffer.slice(e),t}async Uu(e){for(;this.buffer.length<e;)await this.Wu()&&this.Ku("Reached the end of bundle when more is expected.");let t=this.Lu.decode(this.buffer.slice(0,e));return this.buffer=this.buffer.slice(e),t}Ku(e){throw this.Bu.cancel(),Error(`Invalid bundle format: ${e}`)}async Wu(){let e=await this.Bu.read();if(!e.done){let t=new Uint8Array(this.buffer.length+e.value.length);t.set(this.buffer),t.set(e.value,this.buffer.length),this.buffer=t}return e.done}}class cf{constructor(e,t){this.bundleData=e,this.serializer=t,this.cursor=0,this.elements=[];let r=this.bu();if(!r||!r.Ua())throw Error(`The first element of the bundle is not a metadata object, it is
10         ${JSON.stringify(r?.Ka)}`);this.metadata=r;do null!==(r=this.bu())&&this.elements.push(r);while(null!==r)}getMetadata(){return this.metadata}Qu(){return this.elements}bu(){if(this.cursor===this.bundleData.length)return null;let e=this.qu();return new hk(JSON.parse(this.Uu(e)),e)}Uu(e){if(this.cursor+e>this.bundleData.length)throw new r2(r1.INTERNAL,"Reached the end of bundle when more is expected.");return this.bundleData.slice(this.cursor,this.cursor+=e)}qu(){let e=this.cursor,t=this.cursor;for(;t<this.bundleData.length;){if("{"===this.bundleData[t]){if(t===e)throw Error("First character is a bracket and not a number");return this.cursor=t,Number(this.bundleData.slice(e,t))}t++}throw Error("Reached the end of bundle when more is expected.")}}class cp{constructor(e){this.datastore=e,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(e){if(this.ensureCommitNotCalled(),this.mutations.length>
100)throw this.lastTransactionError=new r2(r1.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;let t=await async function(e,t){let r={documents:t.map(t=>oT(e.serializer,t))},n=await e.jo("BatchGetDocuments",e.serializer.databaseId,nu.emptyPath(),r,t.length),i=new Map;n.forEach(t=>{var r;let n,s,a,o,l,u,h=(r=e.serializer,"found"in t?(r0(!!t.found,43571),t.found.name,t.found.updateTime,n=o_(r,t.found.name),s=ov(t.found.updateTime),a=t.found.createTime?ov(t.found.createTime):nI.min(),o=new sV({mapValue:{fields:t.found.fields}}),sF.newFoundDocument(n,s,a,o)):"missing"in t?(r0(!!t.missing,3894),r0(!!t.readTime,22933),l=o_(r,t.missing),u=ov(t.readTime),sF.newNoDocument(l,u)):rX(7234,{result:t}));i.set(h.key.toString(),h)});let s=[];return t.forEach(e=>{let t=i.get(e.toString());r0(!!t,55234,{key:e}),s.push(t)}),s}(this.datastore,e);return t.forEach(e=>this.recordVersion(e)),t}set(e,t){this.write(t.toMutation(e,this.precondition(e))),this.writtenDocs.add(e.toString())}update(e,t){try{this.write(t.toMutation(e,this.preconditionForUpdate(e)))}catch(e){this.lastTransactionError=e}this.writtenDocs.add(e.toString())}delete(e){this.write(new aX(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;let e=this.readVersions;this.mutations.forEach(t=>{e.delete(t.key.toString())}),e.forEach((e,t)=>{let r=nd.fromPath(t);this.mutations.push(new aZ(r,this.precondition(r)))}),await async function(e,t){let r={writes:t.map(t=>oR(e.serializer,t))};await e.Wo("Commit",e.serializer.databaseId,nu.emptyPath(),r)}(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw rX(50498,{Gu:e.constructor.name});t=nI.min()}let r=this.readVersions.get(e.key.toString());if(r){if(!t.isEqual(r))throw new r2(r1.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),t)}precondition(e){let t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&t?t.isEqual(nI.min())?aj.exists(!1):aj.updateTime(t):aj.none()}preconditionForUpdate(e){let t=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&t){if(t.isEqual(nI.min()))throw new r2(r1.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return aj.updateTime(t)}return aj.exists(!0)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}class cg{constructor(e,t,r,n,i){this.asyncQueue=e,this.datastore=t,this.options=r,this.updateFunction=n,this.deferred=i,this.zu=r.maxAttempts,this.M_=new uj(this.asyncQueue,"transaction_retry")}ju(){this.zu-=1,this.Ju()}Ju(){this.M_.p_(async()=>{let e=new cp(this.datastore),t=this.Hu(e);t&&t.then(t=>{this.asyncQueue.enqueueAndForget(()=>e.commit().then(()=>{this.deferred.resolve(t)}).catch(e=>{this.Zu(e)}))}).catch(e=>{this.Zu(e)})})}Hu(e){try{let t=this.updateFunction(e);return!nJ(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}}Zu(e){this.zu>0&&this.Xu(e)?(this.zu-=1,this.asyncQueue.enqueueAndForget(()=>(this.Ju(),Promise.resolve()))):this.deferred.reject(e)}Xu(e){if("FirebaseError"===e?.name){let t=e.code;return"aborted"===t||"failed-precondition"===t||"already-exists"===t||!a6(t)}return!1}}let cm="FirestoreClient";class cy{constructor(e,t,r,n,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this._databaseInfo=n,this.user=rz.UNAUTHENTICATED,this.clientId=nr.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(r,async e=>{rW(cm,"Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(r,e=>(rW(cm,"Received new app check token=",e),this.appCheckCredentialListener(e,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this._databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();let e=new r5;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(r){let t=hp(r,"Failed to shutdown persistence");e.reject(t)}}),e.promise}}async function cw(e,t){e.asyncQueue.verifyOperationInProgress(),rW(cm,"Initializing OfflineComponentProvider");let r=e.configuration;await t.initialize(r);let n=r.initialUser;e.setCredentialChangeListener(async e=>{n.isEqual(e)||(await ut(t.localStore,e),n=e)}),t.persistence.setDatabaseDeletedListener(()=>e.terminate()),e._offlineComponents=t}async function cv(e,t){e.asyncQueue.verifyOperationInProgress();let r=await cI(e);rW(cm,"Initializing OnlineComponentProvider"),await t.initialize(r,e.configuration),e.setCredentialChangeListener(e=>hu(t.remoteStore,e)),e.setAppCheckTokenChangeListener((e,r)=>hu(t.remoteStore,r)),e._onlineComponents=t}async function cI(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){rW(cm,"Using user provided OfflineComponentProvider");try{await cw(e,e._uninitializedComponentsProvider._offline)}catch(t){if(!("FirebaseError"===t.name?t.code===r1.FAILED_PRECONDITION||t.code===r1.UNIMPLEMENT
10ED:!("u">typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code))throw t;rJ("Error using user provided cache. Falling back to memory cache: "+t),await cw(e,new ca)}}else rW(cm,"Using default OfflineComponentProvider"),await cw(e,new co(void 0));return e._offlineComponents}async function cb(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(rW(cm,"Using user provided OnlineComponentProvider"),await cv(e,e._uninitializedComponentsProvider._online)):(rW(cm,"Using default OnlineComponentProvider"),await cv(e,new cu))),e._onlineComponents}function cE(e){return cI(e).then(e=>e.localStore)}function cT(e){return cb(e).then(e=>e.syncEngine)}function c_(e){return cb(e).then(e=>e.datastore)}async function cS(e){let t=await cb(e),r=t.eventManager;return r.onListen=hF.bind(null,t.syncEngine),r.onUnlisten=hq.bind(null,t.syncEngine),r.onFirstRemoteStoreListen=hU.bind(null,t.syncEngine),r.onLastRemoteStoreUnlisten=hz.bind(null,t.syncEngine),r}function cC(e,t,r={}){let n=new r5;return e.asyncQueue.enqueueAndForget(async()=>{var i,s;let a,o;return i=await cS(e),s=e.asyncQueue,a=new cc({next:e=>{a.Nu(),s.enqueueAndForget(()=>hE(i,o));let l=e.docs.has(t);!l&&e.fromCache?n.reject(new r2(r1.UNAVAILABLE,"Failed to get document because the client is offline.")):l&&e.fromCache&&r&&"server"===r.source?n.reject(new r2(r1.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.)')):n.resolve(e)},error:e=>n.reject(e)}),hb(i,o=new hC(ai(t.path),a,{includeMetadataChanges:!0,qa:!0}))}),n.promise}function ck(e,t){let r=new r5;return e.asyncQueue.enqueueAndForget(async()=>hK(await cT(e),t,r)),r.promise}function cA(e){let t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}let cx=new Map,cN="firestore.googleapis.com";class cR{constructor(e){if(void 0===e.host){if(void 0!==e.ssl)throw new r2(r1.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=cN,this.ssl=!0}else this.host=e.host,this.ssl=e.ssl??!0;if(this.isUsingEmulator=void 0!==e.emulatorOptions,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,void 0===e.cacheSizeBytes)this.cacheSizeBytes=0x2800000;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new r2(r1.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}(function(e,t,r,n){if(!0===t&&!0===n)throw new r2(r1.INVALID_ARGUMENT,`${e} and ${r} cannot be used together.`)})("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===e.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=cA(e.experimentalLongPollingOptions??{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new r2(r1.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new r2(r1.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new r2(r1.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){var t,r;return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&(t=this.experimentalLongPollingOptions,r=e.experimentalLongPollingOptions,t.timeoutSeconds===r.timeoutSeconds)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class cD{constructor(e,t,r,n){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=n,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new cR({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new r2(r1.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return"notTerminated"!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new r2(r1.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 cR(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new r3;switch(e.type){case"firstParty":return new r7(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new r2(r1.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invali
10d credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return"notTerminated"===this._terminateTask&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){"notTerminated"===this._terminateTask?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){let e;return(e=cx.get(this))&&(rW("ComponentProvider","Removing Datastore"),cx.delete(this),e.terminate()),Promise.resolve()}}class cP{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new cP(this.firestore,e,this._query)}}class cO{constructor(e,t,r){this.converter=t,this._key=r,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new cL(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new cO(this.firestore,e,this._key)}toJSON(){return{type:cO._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(nw(t,cO._jsonSchema))return new cO(e,r||null,new nd(nu.fromString(t.referencePath)))}}cO._jsonSchemaVersion="firestore/documentReference/1.0",cO._jsonSchema={type:ny("string",cO._jsonSchemaVersion),referencePath:ny("string")};class cL extends cP{constructor(e,t,r){super(e,t,ai(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new cO(this.firestore,null,new nd(e))}withConverter(e){return new cL(this.firestore,e,this._path)}}let cM="AsyncQueue";class cV{constructor(e=Promise.resolve()){this.Yu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new uj(this,"async_queue_retry"),this._c=()=>{let e=uU();e&&rW(cM,"Visibility state changed to "+e.visibilityState),this.M_.w_()},this.ac=e;const t=uU();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.uc(),this.cc(e)}enterRestrictedMode(e){if(!this.ec){this.ec=!0,this.sc=e||!1;let t=uU();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise(()=>{});let t=new r5;return this.cc(()=>this.ec&&this.sc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Yu.push(e),this.lc()))}async lc(){if(0!==this.Yu.length){try{await this.Yu[0](),this.Yu.shift(),this.M_.reset()}catch(e){if(!nj(e))throw e;rW(cM,"Operation failed with retryable error: "+e)}this.Yu.length>0&&this.M_.p_(()=>this.lc())}}cc(e){let t=this.ac.then(()=>(this.rc=!0,e().catch(e=>{throw this.nc=e,this.rc=!1,rQ("INTERNAL UNHANDLED ERROR: ",cF(e)),e}).then(e=>(this.rc=!1,e))));return this.ac=t,t}enqueueAfterDelay(e,t,r){this.uc(),this.oc.indexOf(e)>-1&&(t=0);let n=hf.createAndSchedule(this,e,t,r,e=>this.hc(e));return this.tc.push(n),n}uc(){this.nc&&rX(47125,{Pc:cF(this.nc)})}verifyOperationInProgress(){}async Tc(){let e;do e=this.ac,await e;while(e!==this.ac)}Ec(e){for(let t of this.tc)if(t.timerId===e)return!0;return!1}Ic(e){return this.Tc().then(()=>{for(let t of(this.tc.sort((e,t)=>e.targetTimeMs-t.targetTimeMs),this.tc))if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.Tc()})}Rc(e){this.oc.push(e)}hc(e){let t=this.tc.indexOf(e);this.tc.splice(t,1)}}function cF(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}class cU{constructor(){this._progressObserver={},this._taskCompletionResolver=new r5,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(e,t,r){this._progressObserver={next:e,error:t,complete:r}}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)}}class cB extends cD{constructor(e,t,r,n){super(e,t,r,n),this.type="firestore",this._queue=new cV,this._persistenceKey=n?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new cV(e),this._firestoreClient=void 0,await e}}}function cj(e,t){let r="object"==typeof e?e:(0,y.getApp)(),n=(0,y._getProvider)(r,"firestore").getImmediate({identifier:"string"==typeof e?e:t||su});if(!n._initialized){let e=(0,rF.getDefaultEmulatorHostnameAndPort)("firestore");e&&function(e,t,r,n={}){e=nm(e,cD);let i=(0,rF.isCloudWorkstation)(t),s=e._getSettings(),a={...s,emulatorOptions:e._getEmulatorOptions()},o=`${t}:${r}`;i&&(0,rF.pingServer)(`https://${o}`),s.host!==cN&&s.host!==o&&rJ("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");let l={...s,host:o,ssl:i,emulatorOptions:n};if(!(0,rF.deepEqual)(l,a)&&(e._setSettings(l),n.mockUserToken)){let t,r;if("string"==typeof n.mockUserToken)t=n.mockUserToken,r=rz.MOCK_USER;else{t=(0,rF.createMockUserToken)(n.mockUserToken,e._app?.options.projectId);let i=n.mockUserToken.sub||n.mockUserToken.user_id;if(!i)throw new r2(r1.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");r=new rz(i)}e._authCredentials=new r8(new r6(t,r))}}(n,...e)}return n}function cq(e){if(e._terminated)throw new r2(r1.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||function(e){var t,r,n,i,s;let a,o=e._freezeSettings(),l=(t=e._databaseId,r=e._app?.options.appId||"",n=e._persistenceKey,i=e._app?.options.apiKey,new sl(t,r,n,o.host,o.ssl,o.experimentalForceLongPolling,o.experimentalAutoDetectLongPolling,cA(o.experimentalLongPollingOptions),o.useFetchStreams,o.isUsingEmulator,i));e._componentsProvider||o.localCache?._offlineComponentProvider&&o.localCache?._onlineComponentProvider&&(e._componentsProvider={_offline:o.localCache._offlineComponentProvider,_online:o.localCache._onlineComponentProvider}),e._firestoreClient=new cy(e._authCredentials,e._appCheckCredentials,e._queue,l,e._componentsProvider&&(s=e._componentsProvider,a=s?._online.build(),{_offline:s?._offline.build(a),_online:a}))}(e),e._firestoreClient}class cz{constructor(e){this._byteString=e}static fromBase64String(e){try{return new cz(i8.fromBase64String(e))}catch(e){throw new r2(r1.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new cz(i8.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:cz._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(nw(e,cz._jsonSchema))return cz.fromBase64String(e.bytes)}}
10cz._jsonSchemaVersion="firestore/bytes/1.0",cz._jsonSchema={type:ny("string",cz._jsonSchemaVersion),bytes:ny("string")};class cK{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new r2(r1.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new nc(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class c${constructor(e){this._methodName=e}}class cG{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new r2(r1.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new r2(r1.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return nn(this._lat,e._lat)||nn(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:cG._jsonSchemaVersion}}static fromJSON(e){if(nw(e,cG._jsonSchema))return new cG(e.latitude,e.longitude)}}cG._jsonSchemaVersion="firestore/geoPoint/1.0",cG._jsonSchema={type:ny("string",cG._jsonSchemaVersion),latitude:ny("number"),longitude:ny("number")};class cH{constructor(e){this._values=(e||[]).map(e=>e)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}(this._values,e._values)}toJSON(){return{type:cH._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(nw(e,cH._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(e=>"number"==typeof e))return new cH(e.vectorValues);throw new r2(r1.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}cH._jsonSchemaVersion="firestore/vectorValue/1.0",cH._jsonSchema={type:ny("string",cH._jsonSchemaVersion),vectorValues:ny("object")};let cW=/^__.*__$/;class cQ{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return null!==this.fieldMask?new aW(e,this.data,this.fieldMask,t,this.fieldTransforms):new aH(e,this.data,t,this.fieldTransforms)}}class cJ{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new aW(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function cY(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw rX(40011,{dataSource:e})}}class cX{constructor(e,t,r,n,i,s){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=n,void 0===i&&this.Ac(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}i(e){return new cX({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}dc(e){let t=this.path?.child(e),r=this.i({path:t,arrayElement:!1});return r.mc(e),r}fc(e){let t=this.path?.child(e),r=this.i({path:t,arrayElement:!1});return r.Ac(),r}gc(e){return this.i({path:void 0,arrayElement:!0})}yc(e){return dt(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return void 0!==this.fieldMask.find(t=>e.isPrefixOf(t))||void 0!==this.fieldTransforms.find(t=>e.isPrefixOf(t.field))}Ac(){if(this.path)for(let e=0;e<this.path.length;e++)this.mc(this.path.get(e))}mc(e){if(0===e.length)throw this.yc("Document fields must not be empty");if(cY(this.dataSource)&&cW.test(e))throw this.yc('Document fields cannot begin and end with "__"')}}class cZ{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||uB(e)}I(e,t,r,n=!1){return new cX({dataSource:e,methodName:t,targetDoc:r,path:nc.emptyPath(),arrayElement:!1,hasConverter:n},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function c0(e){let t=e._freezeSettings(),r=uB(e._databaseId);return new cZ(e._databaseId,!!t.ignoreUndefinedProperties,r)}function c1(e,t,r,n,i,s={}){let a,o,l=e.I(s.merge||s.mergeFields?2:0,t,r,i);c4("Data must be an object, but it was:",l,n);let u=c3(n,l);if(s.merge)a=new i6(l.fieldMask),o=l.fieldTransforms;else if(s.mergeFields){let e=[];for(let n of s.mergeFields){let i=c9(t,n,r);if(!l.contains(i))throw new r2(r1.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);dr(e,i)||e.push(i)}a=new i6(e),o=l.fieldTransforms.filter(e=>a.covers(e.field))}else a=null,o=l.fieldTransforms;return new cQ(new sV(u),a,o)}class c2 extends c${_toFieldTransform(e){if(2!==e.dataSource)throw 1===e.dataSource?e.yc(`${this._methodName}() can only appear at the top level of your update data`):e.yc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof c2}}class c5 extends c${_toFieldTransform(e){return new aU(e.path,new aR)}isEqual(e){return e instanceof c5}}function c6(e,t){if(c8(e=(0,rF.getModularInstance)(e)))return c4("Unsupported field value:",t,e),c3(e,t);if(e instanceof c$)return function(e,t){if(!cY(t.dataSource))throw t.yc(`${e._methodName}
10() can only be used with update() and set()`);if(!t.path)throw t.yc(`${e._methodName}() is not currently supported inside arrays`);let r=e._toFieldTransform(t);r&&t.fieldTransforms.push(r)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.arrayElement&&4!==t.dataSource)throw t.yc("Nested arrays are not supported");let r=[],n=0;for(let i of e){let e=c6(i,t.gc(n));null==e&&(e={nullValue:"NULL_VALUE"}),r.push(e),n++}return{arrayValue:{values:r}}}return function(e,t){var r,n,i;if(null===(e=(0,rF.getModularInstance)(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return r=t.serializer,nX(n=e)?aA(n):ak(r,n);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){let r=nv.fromDate(e);return{timestampValue:oy(t.serializer,r)}}if(e instanceof nv){let r=new nv(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:oy(t.serializer,r)}}if(e instanceof cG)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof cz)return{bytesValue:ow(t.serializer,e._byteString)};if(e instanceof cO){let r=t.databaseId,n=e.firestore._databaseId;if(!n.isEqual(r))throw t.yc(`Document reference is for database ${n.projectId}/${n.database} but should be for database ${r.projectId}/${r.database}`);return{referenceValue:oI(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof cH)return{mapValue:{fields:{[sd]:{stringValue:sg},[sm]:{arrayValue:{values:((i=e)instanceof cH?i.toArray():i).map(e=>{if("number"!=typeof e)throw t.yc("VectorValues must only contain numeric values.");return ak(t.serializer,e)})}}}}};if(oU(e))return e._toProto(t.serializer);throw t.yc(`Unsupported field value: ${ng(e)}`)}(e,t)}function c3(e,t){let r={};return iY(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):iJ(e,(e,n)=>{let i=c6(n,t.dc(e));null!=i&&(r[e]=i)}),{mapValue:{fields:r}}}function c8(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof nv||e instanceof cG||e instanceof cz||e instanceof cO||e instanceof c$||e instanceof cH||oU(e))}function c4(e,t,r){if(!c8(r)||!np(r)){let n=ng(r);throw"an object"===n?t.yc(e+" a custom object"):t.yc(e+" "+n)}}function c9(e,t,r){if((t=(0,rF.getModularInstance)(t))instanceof cK)return t._internalPath;if("string"==typeof t)return de(e,t);throw dt("Field path arguments must be of type string or ",e,!1,void 0,r)}let c7=RegExp("[~\\*/\\[\\]]");function de(e,t,r){if(t.search(c7)>=0)throw dt(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,r);try{return new cK(...t.split("."))._internalPath}catch(n){throw dt(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,r)}}function dt(e,t,r,n,i){let s=n&&!n.isEmpty(),a=void 0!==i,o=`Function ${t}() called with invalid data`;r&&(o+=" (via `toFirestore()`)"),o+=". ";let l="";return(s||a)&&(l+=" (found",s&&(l+=` in field ${n}`),a&&(l+=` in document ${i}`),l+=")"),new r2(r1.INVALID_ARGUMENT,o+e+l)}function dr(e,t){return e.some(e=>e.isEqual(t))}class dn{convertValue(e,t="none"){switch(sw(e)){case 0:return null;case 1:return e.booleanValue;case 2:return i7(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(se(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw rX(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){let r={};return iJ(e,(e,n)=>{r[e]=this.convertValue(n,t)}),r}convertVectorValue(e){return new cH(e.fields?.[sm].arrayValue?.values?.map(e=>i7(e.doubleValue)))}convertGeoPoint(e){return new cG(i7(e.latitude),i7(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":let r=sa(e);return null==r?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(so(e));default:return null}}convertTimestamp(e){let t=i9(e);return new nv(t.seconds,t.nanos)}convertDocumentKey(e,t){let r=nu.fromString(e);r0(oF(r),9688,{name:e});let n=new sh(r.get(1),r.get(3)),i=new nd(r.popFirst(5));return n.isEqual(t)||rQ(`Document ${i} contains a document reference within a different database (${n.projectId}/${n.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}}class di extends dn{constructor(e){super(),this.firestore=e}convertBytes(e){return new cz(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);
10return new cO(this.firestore,null,t)}}e.s(["$",0,function(e,t,r,n){let i=e.I(1,t,r);c4("Data must be an object, but it was:",i,n);let s=[],a=sV.empty();return iJ(n,(e,n)=>{let o=de(t,e,r);n=(0,rF.getModularInstance)(n);let l=i.fc(o);if(n instanceof c2)s.push(o);else{let e=c6(n,l);null!=e&&(s.push(o),a.set(o,e))}}),new cJ(a,new i6(s),i.fieldTransforms)},"A",0,dn,"B",0,cz,"C",0,s$,"D",0,cO,"E",0,function(e,t){let r=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.push(t(e[n],n,e));return r},"F",0,cB,"G",0,function(e,t,r){let n=new r5;return e.asyncQueue.enqueueAndForget(async()=>{try{let i=await c_(e);n.resolve(async function(e,t,r){var n;let{request:i,gt:s,parent:a}=function(e,t,r){let{ft:n,parent:i}=oO(e,t),s={},a=[],o=0;return r.forEach(e=>{let t="aggregate_"+o++;s[t]=e.alias,"count"===e.aggregateType?a.push({alias:t,count:{}}):"avg"===e.aggregateType?a.push({alias:t,avg:{field:oM(e.fieldPath)}}):"sum"===e.aggregateType&&a.push({alias:t,sum:{field:oM(e.fieldPath)}})}),{request:{structuredAggregationQuery:{aggregations:a,structuredQuery:n.structuredQuery},parent:n.parent},gt:s,parent:i}}(e.serializer,((n=t).Re||(n.Re=au(n,n.explicitOrderBy)),n.Re),r);e.connection.qo||delete i.parent;let o=(await e.jo("RunAggregationQuery",e.serializer.databaseId,a,i,1)).filter(e=>!!e.result);r0(1===o.length,64727);let l=o[0].result?.aggregateFields;return Object.keys(l).reduce((e,t)=>(e[s[t]]=l[t],e),{})}(i,t,r))}catch(e){n.reject(e)}}),n.promise},"H",0,di,"I",0,nw,"J",0,uB,"K",0,function(e,t){return new cf(e,t)},"L",0,hx,"M",0,oN,"N",0,nr,"O",0,sV,"P",0,oQ,"Q",0,cP,"R",0,nu,"S",0,hg,"T",0,aS,"U",0,rX,"V",0,hy,"W",0,c1,"X",0,aj,"Y",0,cK,"Z",0,function(e,t,r,n,i,s){let a=e.I(1,t,r),o=[c9(t,n,r)],l=[i];if(s.length%2!=0)throw new r2(r1.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let e=0;e<s.length;e+=2)o.push(c9(t,s[e])),l.push(s[e+1]);let u=[],h=sV.empty();for(let e=o.length-1;e>=0;--e)if(!dr(u,o[e])){let t=o[e],r=l[e];r=(0,rF.getModularInstance)(r);let n=a.fc(t);if(r instanceof c2)u.push(t);else{let e=c6(r,n);null!=e&&(u.push(t),h.set(t,e))}}return new cJ(h,new i6(u),a.fieldTransforms)},"_",0,r$,"a",0,r4,"a$",0,function(){return new c5("serverTimestamp")},"a0",0,aX,"a1",0,function(e,t,r){let n=new r5;return e.asyncQueue.enqueueAndForget(async()=>{let i=await c_(e);new cg(e.asyncQueue,i,r,t,n).ju()}),n.promise},"a2",0,cC,"a3",0,function(e,t){let r=new r5;return e.asyncQueue.enqueueAndForget(async()=>(async function(e,t,r){try{let n=await e.persistence.runTransaction("read document","readonly",r=>e.localDocuments.getDocument(r,t));n.isFoundDocument()?r.resolve(n):n.isNoDocument()?r.resolve(null):r.reject(new r2(r1.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(n){let e=hp(n,`Failed to get document '${t} from cache`);r.reject(e)}})(await cE(e),t,r)),r.promise},"a4",0,function(e,t,r={}){let n=new r5;return e.asyncQueue.enqueueAndForget(async()=>{var i,s;let a,o;return i=await cS(e),s=e.asyncQueue,o=new hC(t,a=new cc({next:e=>{a.Nu(),s.enqueueAndForget(()=>hE(i,o)),e.fromCache&&"server"===r.source?n.reject(new r2(r1.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.)')):n.resolve(e)},error:e=>n.reject(e)}),{includeMetadataChanges:!0,qa:!0}),hb(i,o)}),n.promise},"a5",0,function(e,t){let r=new r5;return e.asyncQueue.enqueueAndForget(async()=>(async function(e,t,r){try{let n=await ua(e,t,!0),i=new hP(t,n.ks),s=i.ru(n.documents),a=i.applyChanges(s,!1);r.resolve(a.snapshot)}catch(n){let e=hp(n,`Failed to execute query '${t} against cache`);r.reject(e)}})(await cE(e),t,r)),r.promise},"a6",0,function(e,t,...r){if(e=(0,rF.getModularInstance)(e),1==arguments.length&&(t=nr.newId()),function(e,t){if(!t)throw new r2(r1.INVALID_ARGUMENT,`Function doc() cannot be called with an empty ${e}.`)}("path",t),e instanceof cD){let n=nu.fromString(t,...r);return nf(n),new cO(e,null,new nd(n))}{if(!(e instanceof cO||e instanceof cL))throw new r2(r1.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let n=e._path.child(nu.fromString(t,...r));return nf(n),new cO(e.firestore,e instanceof cL?e.converter:null,new nd(n))}},"a7",0,ai,"a8",0,function(e,t,r,n){let i=new cc(n),s=new hC(t,i,r);return e.asyncQueue.enqueueAndForget(async()=>hb(await cS(e),s)),()=>{i.Nu(),e.asyncQueue.enqueueAndForget(async()=>hE(await cS(e),s))}},"a9",0,function(e,t){let r=cq(e=nm(e,cB)),n=new cU;return function(e,t,r,n){var i;let s=(i=uB(t),new cd(function(e){if(e instanceof Uint8Array)return ch(e,void 0);if(e instanceof ArrayBuffer)return ch(new Uint8Array(e),void 0);if(e instanceof ReadableStream)return e.getReader();throw Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}
10("string"==typeof r?a4().encode(r):r),i));e.asyncQueue.enqueueAndForget(async()=>{var t=await cT(e);(async function(e,t,r){try{var n,i;let s,a=await t.getMetadata();if(await (n=e.localStore,s=ov(a.createTime),n.persistence.runTransaction("hasNewerBundle","readonly",e=>n.Pi.getBundleMetadata(e,a.id)).then(e=>!!e&&e.createTime.compareTo(s)>=0)))return await t.close(),r._completeWith({taskState:"Success",documentsLoaded:a.totalDocuments,bytesLoaded:a.totalBytes,totalDocuments:a.totalDocuments,totalBytes:a.totalBytes}),Promise.resolve(new Set);r._updateProgress(hN(a));let o=new hx(a,t.serializer),l=await t.bu();for(;l;){let e=await o.Ga(l);e&&r._updateProgress(e),l=await t.bu()}let u=await o.ja(e.localStore);return await h2(e,u.Ha,void 0),await (i=e.localStore,i.persistence.runTransaction("Save bundle","readwrite",e=>i.Pi.saveBundleMetadata(e,a))),r._completeWith(u.progress),Promise.resolve(u.Ja)}catch(e){return rJ(hO,`Loading bundle failed with ${e}`),r._failWith(e),Promise.resolve(new Set)}})(t,s,n).then(e=>{t.sharedClientState.notifyBundleLoaded(e)})})}(r,e._databaseId,t,n),n},"aX",0,cj,"aa",0,function(e,t){var r;return(r=cq(e=nm(e,cB)),r.asyncQueue.enqueue(async()=>{var e;return e=await cE(r),e.persistence.runTransaction("Get named query","readonly",r=>e.Pi.getNamedQuery(r,t))})).then(t=>t?new cP(e,null,t.query):null)},"ab",0,function(e,t){let r=new cc(t);return e.asyncQueue.enqueueAndForget(async()=>{var t;return t=await cS(e),void(t.Ca.add(r),r.next())}),()=>{r.Nu(),e.asyncQueue.enqueueAndForget(async()=>{var t;return t=await cS(e),void t.Ca.delete(r)})}},"ac",0,ck,"ad",0,rJ,"ae",0,de,"af",0,nS,"ag",0,nb,"ah",0,nC,"ai",0,function(e,t){return e.asyncQueue.enqueue(async()=>(async function(e,t){let r=e.indexManager,n=[];return e.persistence.runTransaction("Configure indexes","readwrite",e=>r.getFieldIndexes(e).next(i=>(function(e,t,r,n,i){t=[...t],(e=[...e]).sort(r),t.sort(r);let s=e.length,a=t.length,o=0,l=0;for(;o<a&&l<s;){let s=r(e[l],t[o]);s<0?i(e[l++]):s>0?n(t[o++]):(o++,l++)}for(;o<a;)n(t[o++]);for(;l<s;)i(e[l++])})(i,t,n_,t=>{n.push(r.addFieldIndex(e,t))},t=>{n.push(r.deleteFieldIndex(e,t))})).next(()=>nO.waitFor(n)))})(await cE(e),t))},"aj",0,function(e){return e.asyncQueue.enqueue(async()=>{var t;let r;return r=(t=await cE(e)).indexManager,t.persistence.runTransaction("Delete All Indexes","readwrite",e=>r.deleteAllFieldIndexes(e))})},"ak",0,rW,"al",0,function(e,t){return e.asyncQueue.enqueue(async()=>{var r;return r=await cE(e),void(r.Cs.As=t)})},"am",0,function(e){if(a8)throw Error("a TestingHooksSpi instance is already set");a8=e},"an",0,sq,"ao",0,class{constructor(e,t,r){this.alias=e,this.aggregateType=t,this.fieldPath=r}},"ap",0,cu,"aq",0,co,"ar",0,ca,"as",0,cl,"at",0,class extends cl{constructor(e,t){super(e,t,!1),this.xu=e,this.cacheSizeBytes=t,this.synchronizeTabs=!0}async initialize(e){await super.initialize(e);let t=this.xu.syncEngine;this.sharedClientState instanceof u_&&(this.sharedClientState.syncEngine={bo:h4.bind(null,t),Do:cr.bind(null,t),Co:cn.bind(null,t),hs:ct.bind(null,t),So:h8.bind(null,t)},await this.sharedClientState.start()),await this.persistence.zi(async e=>{await h9(this.xu.syncEngine,e),this.gcScheduler&&(e&&!this.gcScheduler.started?this.gcScheduler.start():e||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(e&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():e||this.indexBackfillerScheduler.stop())})}Du(e){let t=uF();if(!u_.v(t))throw new r2(r1.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");let r=l3(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new u_(t,e.asyncQueue,r,e.clientId,e.initialUser)}},"b",0,nt,"c",0,sc,"d",0,r2,"e",0,r1,"f",0,function(e,t){let r=e.filters.concat([t]);return new an(e.path,e.collectionGroup,e.explicitOrderBy.slice(),r,e.limit,e.limitType,e.startAt,e.endAt)},"g",0,c0,"h",0,function(e,t,r,n=!1){return c6(r,e.I(n?4:3,t))},"i",0,sK,"j",0,c9,"k",0,function(e,t){let r=e.explicitOrderBy.concat([t]);return new an(e.path,e.collectionGroup,r,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)},"l",0,ah,"m",0,function(e,t){if(t<=0)throw new r2(r1.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)},"n",0,function(e,t){return new an(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,t,e.endAt)},"o",0,function(e,t){return new an(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,t)},"p",0,ny,"q",0,ao,"r",0,sS,"s",0,ss,"t",0,sU,"u",0,aa,"v",0,nd,"w",0,ng,"x",0,function(e,t){return e=(0,rF.getModularInstance)(e),t=(0,rF.getModularInstance)(t),e instanceof cP&&t instanceof cP&&e.firestore===t.firestore&&ac(e._query,t._query)&&e.converter===t.converter},"y",0,nm,"z",0,cq],969185);let ds="@firebase/firestore",da="4.14.0";class dl{constructor(e,t,r,n,i){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=n,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new cO(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){let e=new du(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){let t=this._document.data.field(c9("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class du extends dl{data(){return super.data()}}class dh{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class dc extends dl{constructor(e,t,r,n,i,s){super(e,t,r,n,s),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new dd(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){let r=this._document.data.field(c9("DocumentSnapshot.get",e));if(null!==r)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new r2(r1.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");let e=this._document,t={};return t.type=dc._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),e&&e.isValidDocument()&&e.isFoundDocument()&&
10(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),this._firestore,this.ref.path,t.bundle="NOT SUPPORTED"),t}}dc._jsonSchemaVersion="firestore/documentSnapshot/1.0",dc._jsonSchema={type:ny("string",dc._jsonSchemaVersion),bundleSource:ny("string","DocumentSnapshot"),bundleName:ny("string"),bundle:ny("string")};class dd extends dc{data(e={}){return super.data(e)}}class df{constructor(e,t,r,n){this._firestore=e,this._userDataWriter=t,this._snapshot=n,this.metadata=new dh(n.hasPendingWrites,n.fromCache),this.query=r}get docs(){let e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(e,t){this._snapshot.docs.forEach(r=>{e.call(t,new dd(this._firestore,this._userDataWriter,r.key,r,new dh(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new r2(r1.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(e,t){if(e._snapshot.oldDocs.isEmpty()){let t=0;return e._snapshot.docChanges.map(r=>{let n=new dd(e._firestore,e._userDataWriter,r.doc.key,r.doc,new dh(e._snapshot.mutatedKeys.has(r.doc.key),e._snapshot.fromCache),e.query.converter);return r.doc,{type:"added",doc:n,oldIndex:-1,newIndex:t++}})}{let r=e._snapshot.oldDocs;return e._snapshot.docChanges.filter(e=>t||3!==e.type).map(t=>{let n=new dd(e._firestore,e._userDataWriter,t.doc.key,t.doc,new dh(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter),i=-1,s=-1;return 0!==t.type&&(i=r.indexOf(t.doc.key),r=r.delete(t.doc.key)),1!==t.type&&(s=(r=r.add(t.doc)).indexOf(t.doc.key)),{type:function(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return rX(61501,{type:e})}}(t.type),doc:n,oldIndex:i,newIndex:s}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new r2(r1.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");let e={};e.type=df._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=nr.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;let t=[],r=[],n=[];return this.docs.forEach(e=>{null!==e._document&&(t.push(e._document),r.push(this._userDataWriter.convertObjectMap(e._document.data.value.mapValue.fields,"previous")),n.push(e.ref.path))}),this._firestore,this.query._query,e.bundleName,e.bundle="NOT SUPPORTED",e}}df._jsonSchemaVersion="firestore/querySnapshot/1.0",df._jsonSchema={type:ny("string",df._jsonSchemaVersion),bundleSource:ny("string","QuerySnapshot"),bundleName:ny("string"),bundle:ny("string")},new WeakMap,function(e=!0){r$(y.SDK_VERSION),(0,y._registerComponent)(new I.Component("firestore",(t,{instanceIdentifier:r,options:n})=>{let i=t.getProvider("app").getImmediate(),s=new cB(new r4(t.getProvider("auth-internal")),new nt(i,t.getProvider("app-check-internal")),sc(i,r),i);return n={useFetchStreams:e,...n},s._setSettings(n),s},"PUBLIC").setMultipleInstances(!0)),(0,y.registerVersion)(ds,da,void 0),(0,y.registerVersion)(ds,da,"esm2020")}(),e.s(["getDoc",0,function(e){e=nm(e,cO);let t=nm(e.firestore,cB);return cC(cq(t),e._key).then(r=>{var n,i,s;let a,o;return n=t,i=e,a=(s=r).docs.get(i._key),o=new di(n),new dc(n,o,i._key,a,new dh(s.hasPendingWrites,s.fromCache),i.converter)})},"setDoc",0,function(e,t,r){var n,i,s;e=nm(e,cO);let a=nm(e.firestore,cB),o=(n=e.converter,n?r&&(r.merge||r.mergeFields)?n.toFirestore(t,r):n.toFirestore(t):t),l=c0(a);return i=a,s=[c1(l,"setDoc",e._key,o,null!==e.converter,r).toMutation(e._key,aj.none())],ck(cq(i),s)}],263802),e.s([],436180);let dp=(0,y.getApps)().length?(0,y.getApp)():(0,y.initializeApp)({apiKey:"AIzaSyCY95t9WKA696sVjDEz0NosR-0_dGL_3Lw",authDomain:"aapta-d3d9a.firebaseapp.com",projectId:"aapta-d3d9a",storageBucket:"aapta-d3d9a.firebasestorage.app",messagingSenderId:"884580919361",appId:"1:884580919361:web:35409e1cd03060394e7ec0",measurementId:"G-96KT7YTXTY"}),dg=function(e=(0,y.getApp)()){let t=(0,y._getProvider)(e,"auth");if(t.isInitialized())return t.getImmediate();let r=function(e,t){let r=(0,y._getProvider)(e,"auth");if(r.isInitialized()){let e=r.getImmediate(),n=r.getOptions();if((0,w.deepEqual)(n,t??{}))return e;S(e,"already-initialized")}return r.initialize({options:t})}(e,{popupRedirectResolver:rx,persistence:[t$,tA,tx]}),n=(0,w.getExperimentalSetting)("authTokenSyncURL");if(n&&"boolean"==typeof isSecureContext&&isSecureContext){let e=new URL(n,location.origin);if(location.origin===e.origin){let t,n=(t=e.toString(),async e=>{let r=e&&await e.getIdTokenResult(),n=r&&(new Date().getTime()-Date.parse(r.issuedAtTime))/1e3;if(n&&n>rP)return;let i=r?.token;rO!==i&&(rO=i,await fetch(t,{method:i?"POST":"DELETE",headers:i?{Authorization:`Bearer ${i}`}:{}}))});(0,w.getModularInstance)(r).beforeAuthStateChanged(n,()=>n(r.currentUser)),t_(r,e=>n(e))}}let i=(0,w.getDefaultEmulatorHost)("auth");return i&&function(e,t){let r=eV(e);
10N(/^https?:\/\//.test(t),r,"invalid-emulator-scheme");let n=eY(t),{host:i,port:s}=function(e){let t=eY(e),r=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!r)return{host:"",port:null};let n=r[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(n);if(i){let e=i[1];return{host:e,port:eX(n.substr(e.length+1))}}{let[e,t]=n.split(":");return{host:e,port:eX(t)}}}(t),a=null===s?"":`:${s}`,o={url:`${n}//${i}${a}/`},l=Object.freeze({host:i,port:s,protocol:n.replace(":",""),options:Object.freeze({disableWarnings:!1})});if(!r._canInitEmulator){N(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),N((0,w.deepEqual)(o,r.config.emulator)&&(0,w.deepEqual)(l,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=o,r.emulatorConfig=l,r.settings.appVerificationDisabledForTesting=!0,(0,w.isCloudWorkstation)(i)?(0,w.pingServer)(`${n}//${i}${a}`):function(){function e(){let e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}"u">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."),"u">typeof window&&"u">typeof document&&("loading"===document.readyState?window.addEventListener("DOMContentLoaded",e):e())}()}(r,`http://${i}`),r}(dp),dm=cj(dp,"default");async function dy(){try{let{isSupported:t,getAnalytics:r}=await e.A(981809);if(!await t())return null;return r(dp)}catch{return null}}e.s(["firebaseAuth",0,dg,"firestore",0,dm,"initAnalyticsIfSupported",0,dy],867426);let dw=(0,rL.createContext)(null);e.s(["AuthProvider",0,function({children:e}){let[t,r]=(0,rL.useState)(null),[n,i]=(0,rL.useState)(!0),s=(0,rL.useRef)(null);(0,rL.useEffect)(()=>{dy();let e=t_(dg,async e=>{r(e),i(!1);try{if(e){let t=await e.getIdToken();await fetch("/api/auth/session",{method:"POST",credentials:"same-origin",headers:{authorization:`Bearer ${t}`}})}else await fetch("/api/auth/session",{method:"DELETE",credentials:"same-origin"})}catch{}});return()=>e()},[]);let a=(0,rL.useCallback)(e=>{if(s.current){try{s.current.clear()}catch{}s.current=null}if("u">typeof document){let t=document.getElementById(e);t&&(t.innerHTML="")}let t=new tZ(dg,e,{size:"invisible"});return s.current=t,t},[]),o=(0,rL.useCallback)(async(e,t)=>t1(dg,e,a(t)),[a]),l=(0,rL.useCallback)(async(e,t)=>{let r=await e.confirm(t);try{await r.user.getIdToken(!0)}catch{}if(s.current){try{s.current.clear()}catch{}s.current=null}return r.user},[]),u=(0,rL.useCallback)(async(e,t)=>{if(!dg.currentUser)throw Error("You must be signed in to link a phone number.");let r=a(t);return t2(dg.currentUser,e,r)},[a]),h=(0,rL.useCallback)(async()=>{let e=new tl;return(await rn(dg,e)).user},[]),c=(0,rL.useCallback)(async()=>{await (0,w.getModularInstance)(dg).signOut(),s.current?.clear(),s.current=null},[]),d=(0,rL.useMemo)(()=>({user:t,loading:n,sendPhoneOtp:o,verifyPhoneOtp:l,linkPhoneOtp:u,signInWithGoogle:h,signOut:c}),[t,n,o,l,u,h,c]);return(0,m.jsx)(dw.Provider,{value:d,children:e})},"useAuth",0,function(){let e=(0,rL.useContext)(dw);if(!e)throw Error("useAuth must be used inside an AuthProvider");return e}],185409)}]);
11
12//# debugId=0f566cc3-7262-c163-3751-6375df65d43a

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.