/*! For license information please see LICENSES */ (window.webpackJsonp=window.webpackJsonp||[]).push([[24],{1:function(t,e,n){"use strict";function r(t,e){if(e.length1?"s":"")+" required, but only "+e.length+" present")}n.d(e,"a",(function(){return r}))},10:function(t,e,n){"use strict";function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}n.d(e,"a",(function(){return r}))},101:function(t,e,n){"use strict";n.d(e,"a",(function(){return h}));var r=n(1);function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function c(t){return Object(r.a)(1,arguments),t instanceof Date||"object"===o(t)&&"[object Date]"===Object.prototype.toString.call(t)}var l=n(3);function h(t){if(Object(r.a)(1,arguments),!c(t)&&"number"!=typeof t)return!1;var e=Object(l.a)(t);return!isNaN(Number(e))}},122:function(t,e,n){"use strict";var r={name:"ClientOnly",functional:!0,props:{placeholder:String,placeholderTag:{type:String,default:"div"}},render:function(t,e){var n=e.parent,r=e.slots,o=e.props,c=r(),l=c.default;void 0===l&&(l=[]);var h=c.placeholder;return n._isMounted?l:(n.$once("hook:mounted",(function(){n.$forceUpdate()})),o.placeholderTag&&(o.placeholder||h)?t(o.placeholderTag,{class:["client-only-placeholder"]},o.placeholder||h):l.length>0?l.map((function(){return t(!1)})):t(!1))}};t.exports=r},126:function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(90);var o=n(95),c=n(91);function l(t){return Object(r.a)(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Object(o.a)(t)||Object(c.a)()}},127:function(t,e,n){"use strict";n.d(e,"a",(function(){return z}));var r=n(101),o=n(96),c=n(3),l=n(1),h=864e5;var f=n(98),d=n(94),m=n(97),y=n(62);function w(t,e){for(var n=t<0?"-":"",output=Math.abs(t).toString();output.length0?n:1-n;return w("yy"===e?r%100:r,e.length)},M:function(t,e){var n=t.getUTCMonth();return"M"===e?String(n+1):w(n+1,2)},d:function(t,e){return w(t.getUTCDate(),e.length)},a:function(t,e){var n=t.getUTCHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return"am"===n?"a.m.":"p.m."}},h:function(t,e){return w(t.getUTCHours()%12||12,e.length)},H:function(t,e){return w(t.getUTCHours(),e.length)},m:function(t,e){return w(t.getUTCMinutes(),e.length)},s:function(t,e){return w(t.getUTCSeconds(),e.length)},S:function(t,e){var n=e.length,r=t.getUTCMilliseconds();return w(Math.floor(r*Math.pow(10,n-3)),e.length)}},T="midnight",x="noon",S="morning",I="afternoon",_="evening",E="night",O={G:function(t,e,n){var r=t.getUTCFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if("yo"===e){var r=t.getUTCFullYear(),o=r>0?r:1-r;return n.ordinalNumber(o,{unit:"year"})}return v.y(t,e)},Y:function(t,e,n,r){var o=Object(y.a)(t,r),c=o>0?o:1-o;return"YY"===e?w(c%100,2):"Yo"===e?n.ordinalNumber(c,{unit:"year"}):w(c,e.length)},R:function(t,e){return w(Object(d.a)(t),e.length)},u:function(t,e){return w(t.getUTCFullYear(),e.length)},Q:function(t,e,n){var r=Math.ceil((t.getUTCMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return w(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){var r=Math.ceil((t.getUTCMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return w(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){var r=t.getUTCMonth();switch(e){case"M":case"MM":return v.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){var r=t.getUTCMonth();switch(e){case"L":return String(r+1);case"LL":return w(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){var o=Object(m.a)(t,r);return"wo"===e?n.ordinalNumber(o,{unit:"week"}):w(o,e.length)},I:function(t,e,n){var r=Object(f.a)(t);return"Io"===e?n.ordinalNumber(r,{unit:"week"}):w(r,e.length)},d:function(t,e,n){return"do"===e?n.ordinalNumber(t.getUTCDate(),{unit:"date"}):v.d(t,e)},D:function(t,e,n){var r=function(t){Object(l.a)(1,arguments);var e=Object(c.a)(t),n=e.getTime();e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0);var r=e.getTime(),o=n-r;return Math.floor(o/h)+1}(t);return"Do"===e?n.ordinalNumber(r,{unit:"dayOfYear"}):w(r,e.length)},E:function(t,e,n){var r=t.getUTCDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){var o=t.getUTCDay(),c=(o-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(c);case"ee":return w(c,2);case"eo":return n.ordinalNumber(c,{unit:"day"});case"eee":return n.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(o,{width:"short",context:"formatting"});default:return n.day(o,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){var o=t.getUTCDay(),c=(o-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(c);case"cc":return w(c,e.length);case"co":return n.ordinalNumber(c,{unit:"day"});case"ccc":return n.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(o,{width:"narrow",context:"standalone"});case"cccccc":return n.day(o,{width:"short",context:"standalone"});default:return n.day(o,{width:"wide",context:"standalone"})}},i:function(t,e,n){var r=t.getUTCDay(),o=0===r?7:r;switch(e){case"i":return String(o);case"ii":return w(o,e.length);case"io":return n.ordinalNumber(o,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){var r=t.getUTCHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(t,e,n){var r,o=t.getUTCHours();switch(r=12===o?x:0===o?T:o/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(t,e,n){var r,o=t.getUTCHours();switch(r=o>=17?_:o>=12?I:o>=4?S:E,e){case"B":case"BB":case"BBB":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(t,e,n){if("ho"===e){var r=t.getUTCHours()%12;return 0===r&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return v.h(t,e)},H:function(t,e,n){return"Ho"===e?n.ordinalNumber(t.getUTCHours(),{unit:"hour"}):v.H(t,e)},K:function(t,e,n){var r=t.getUTCHours()%12;return"Ko"===e?n.ordinalNumber(r,{unit:"hour"}):w(r,e.length)},k:function(t,e,n){var r=t.getUTCHours();return 0===r&&(r=24),"ko"===e?n.ordinalNumber(r,{unit:"hour"}):w(r,e.length)},m:function(t,e,n){return"mo"===e?n.ordinalNumber(t.getUTCMinutes(),{unit:"minute"}):v.m(t,e)},s:function(t,e,n){return"so"===e?n.ordinalNumber(t.getUTCSeconds(),{unit:"second"}):v.s(t,e)},S:function(t,e){return v.S(t,e)},X:function(t,e,n,r){var o=(r._originalDate||t).getTimezoneOffset();if(0===o)return"Z";switch(e){case"X":return C(o);case"XXXX":case"XX":return D(o);default:return D(o,":")}},x:function(t,e,n,r){var o=(r._originalDate||t).getTimezoneOffset();switch(e){case"x":return C(o);case"xxxx":case"xx":return D(o);default:return D(o,":")}},O:function(t,e,n,r){var o=(r._originalDate||t).getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+k(o,":");default:return"GMT"+D(o,":")}},z:function(t,e,n,r){var o=(r._originalDate||t).getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+k(o,":");default:return"GMT"+D(o,":")}},t:function(t,e,n,r){var o=r._originalDate||t;return w(Math.floor(o.getTime()/1e3),e.length)},T:function(t,e,n,r){return w((r._originalDate||t).getTime(),e.length)}};function k(t,e){var n=t>0?"-":"+",r=Math.abs(t),o=Math.floor(r/60),c=r%60;if(0===c)return n+String(o);var l=e||"";return n+String(o)+l+w(c,2)}function C(t,e){return t%60==0?(t>0?"-":"+")+w(Math.abs(t)/60,2):D(t,e)}function D(t,e){var n=e||"",r=t>0?"-":"+",o=Math.abs(t);return r+w(Math.floor(o/60),2)+n+w(o%60,2)}var A=O,N=n(77),R=n(59),P=n(35),j=n(6),M=n(17),L=n(63),V=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,B=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,F=/^'([^]*?)'?$/,U=/''/g,$=/[a-zA-Z]/;function z(t,e,n){var h,f,d,m,y,w,v,T,x,S,I,_,E,O,k,C,D,F;Object(l.a)(2,arguments);var U=String(e),z=Object(M.a)(),K=null!==(h=null!==(f=null==n?void 0:n.locale)&&void 0!==f?f:z.locale)&&void 0!==h?h:L.a,H=Object(j.a)(null!==(d=null!==(m=null!==(y=null!==(w=null==n?void 0:n.firstWeekContainsDate)&&void 0!==w?w:null==n||null===(v=n.locale)||void 0===v||null===(T=v.options)||void 0===T?void 0:T.firstWeekContainsDate)&&void 0!==y?y:z.firstWeekContainsDate)&&void 0!==m?m:null===(x=z.locale)||void 0===x||null===(S=x.options)||void 0===S?void 0:S.firstWeekContainsDate)&&void 0!==d?d:1);if(!(H>=1&&H<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var Y=Object(j.a)(null!==(I=null!==(_=null!==(E=null!==(O=null==n?void 0:n.weekStartsOn)&&void 0!==O?O:null==n||null===(k=n.locale)||void 0===k||null===(C=k.options)||void 0===C?void 0:C.weekStartsOn)&&void 0!==E?E:z.weekStartsOn)&&void 0!==_?_:null===(D=z.locale)||void 0===D||null===(F=D.options)||void 0===F?void 0:F.weekStartsOn)&&void 0!==I?I:0);if(!(Y>=0&&Y<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!K.localize)throw new RangeError("locale must contain localize property");if(!K.formatLong)throw new RangeError("locale must contain formatLong property");var W=Object(c.a)(t);if(!Object(r.a)(W))throw new RangeError("Invalid time value");var Q=Object(R.a)(W),X=Object(o.a)(W,Q),J={firstWeekContainsDate:H,weekStartsOn:Y,locale:K,_originalDate:W},Z=U.match(B).map((function(t){var e=t[0];return"p"===e||"P"===e?(0,N.a[e])(t,K.formatLong):t})).join("").match(V).map((function(r){if("''"===r)return"'";var o=r[0];if("'"===o)return G(r);var c=A[o];if(c)return null!=n&&n.useAdditionalWeekYearTokens||!Object(P.b)(r)||Object(P.c)(r,e,String(t)),null!=n&&n.useAdditionalDayOfYearTokens||!Object(P.a)(r)||Object(P.c)(r,e,String(t)),c(X,r,K.localize,J);if(o.match($))throw new RangeError("Format string contains an unescaped latin alphabet character `"+o+"`");return r})).join("");return Z}function G(input){var t=input.match(F);return t?t[1].replace(U,"'"):input}},13:function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return sr})),n.d(e,"b",(function(){return cr})),n.d(e,"c",(function(){return ar})),n.d(e,"d",(function(){return lr})),n.d(e,"e",(function(){return ur})),n.d(e,"f",(function(){return fr})),n.d(e,"g",(function(){return dr})),n.d(e,"h",(function(){return ir})),n.d(e,"i",(function(){return or}));var r,o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{},c={},l=l||{},h=o||self;function f(){}function d(a){var b=typeof a;return"array"==(b="object"!=b?b:a?Array.isArray(a)?"array":b:"null")||"object"==b&&"number"==typeof a.length}function p(a){var b=typeof a;return"object"==b&&null!=a||"function"==b}var m="closure_uid_"+(1e9*Math.random()>>>0),y=0;function w(a,b,t){return a.call.apply(a.bind,arguments)}function v(a,b,t){if(!a)throw Error();if(2b?1:0}function R(){var a=h.navigator;return a&&(a=a.userAgent)?a:""}function P(a){return-1!=R().indexOf(a)}function j(a){return j[" "](a),a}j[" "]=f;var M,a,L=P("Opera"),V=P("Trident")||P("MSIE"),B=P("Edge"),F=B||V,U=P("Gecko")&&!(-1!=R().toLowerCase().indexOf("webkit")&&!P("Edge"))&&!(P("Trident")||P("MSIE"))&&!P("Edge"),$=-1!=R().toLowerCase().indexOf("webkit")&&!P("Edge");function z(){var a=h.document;return a?a.documentMode:void 0}t:{var G="",K=(a=R(),U?/rv:([^\);]+)(\)|;)/.exec(a):B?/Edge\/([\d\.]+)/.exec(a):V?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(a):$?/WebKit\/(\S+)/.exec(a):L?/(?:Version)[ \/]?(\S+)/.exec(a):void 0);if(K&&(G=K?K[1]:""),V){var H=z();if(null!=H&&H>parseFloat(G)){M=String(H);break t}}M=G}var Y,W={};function Q(){return function(a){var b=W;return Object.prototype.hasOwnProperty.call(b,9)?b[9]:b[9]=a(9)}((function(){let a=0;const b=A(String(M)).split("."),t=A("9").split("."),e=Math.max(b.length,t.length);for(let o=0;0==a&&o>>0);function _t(a){return"function"==typeof a?a:(a[It]||(a[It]=function(b){return a.handleEvent(b)}),a[It])}function Et(){S.call(this),this.i=new lt(this),this.P=this,this.I=null}function Ot(a,b){var t,e=a.I;if(e)for(t=[];e;e=e.I)t.push(e);if(a=a.P,e=b.type||b,"string"==typeof b)b=new k(b,a);else if(b instanceof k)b.target=b.target||a;else{var n=b;ut(b=new k(e,a),n)}if(n=!0,t)for(var r=t.length-1;0<=r;r--){var o=b.g=t[r];n=kt(o,e,!0,b)&&n}if(n=kt(o=b.g=a,e,!0,b)&&n,n=kt(o,e,!1,b)&&n,t)for(r=0;rnew Rt),(a=>a.reset()));class Rt{constructor(){this.next=this.g=this.h=null}set(a,b){this.h=a,this.g=b,this.next=null}reset(){this.next=this.g=this.h=null}}function Pt(a){h.setTimeout((()=>{throw a}),0)}function jt(a,b){At||function(){var a=h.Promise.resolve(void 0);At=function(){a.then(Vt)}}(),Mt||(At(),Mt=!0),Lt.add(a,b)}var Mt=!1,Lt=new class{constructor(){this.h=this.g=null}add(a,b){const t=Nt.get();t.set(a,b),this.h?this.h.next=t:this.g=t,this.h=t}};function Vt(){for(var a;a=Dt();){try{a.h.call(a.g)}catch(t){Pt(t)}var b=Nt;b.j(a),100>b.h&&(b.h++,a.next=b.g,b.g=a)}Mt=!1}function Bt(a,b){Et.call(this),this.h=a||1,this.g=b||h,this.j=q(this.kb,this),this.l=Date.now()}function Ft(a){a.ca=!1,a.R&&(a.g.clearTimeout(a.R),a.R=null)}function Ut(a,b,t){if("function"==typeof a)t&&(a=q(a,t));else{if(!a||"function"!=typeof a.handleEvent)throw Error("Invalid listener argument");a=q(a.handleEvent,a)}return 2147483647{a.g=null,a.i&&(a.i=!1,qt(a))}),a.j);const b=a.h;a.h=null,a.m.apply(null,b)}x(Bt,Et),(r=Bt.prototype).ca=!1,r.R=null,r.kb=function(){if(this.ca){var a=Date.now()-this.l;0e.length)){var n=e[1];if(Array.isArray(n)&&!(1>n.length)){var r=n[0];if("noop"!=r&&"stop"!=r&&"close"!=r)for(var o=1;ob.length?we:(b=b.substr(e,t),a.C=e+t,b))}function _e(a){a.V=Date.now()+a.O,Ee(a,a.O)}function Ee(a,b){if(null!=a.B)throw Error("WatchDog timer not null");a.B=ie(q(a.fb,a),b)}function Oe(a){a.B&&(h.clearTimeout(a.B),a.B=null)}function ke(a){0==a.l.G||a.I||Gn(a.l,a)}function Ce(a){Oe(a);var b=a.L;b&&"function"==typeof b.na&&b.na(),a.L=null,Ft(a.T),Ht(a.S),a.g&&(b=a.g,a.g=null,b.abort(),b.na())}function De(a,b){try{var t=a.l;if(0!=t.G&&(t.g==a||on(t.h,a)))if(!a.J&&on(t.h,a)&&3==t.G){try{var e=t.Fa.g.parse(b)}catch(t){e=null}if(Array.isArray(e)&&3==e.length){var n=e;if(0==n[0]){t:if(!t.u){if(t.g){if(!(t.g.F+3e3n[2]&&t.L&&0==t.A&&!t.v&&(t.v=ie(q(t.bb,t),6e3));if(1>=rn(t.h)&&t.ja){try{t.ja()}catch(t){}t.ja=void 0}}else Hn(t,11)}else if((a.J||t.g==a)&&zn(t),!D(b))for(n=t.Fa.g.parse(b),b=0;bf)&&(3!=f||F||this.g&&(this.h.h||this.g.fa()||kn(this.g)))){this.I||4!=f||7==b||te(8==b||0>=d?3:2),Oe(this);var t=this.g.aa();this.Y=t;e:if(xe(this)){var e=kn(this.g);a="";var n=e.length,r=4==On(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){Ce(this),ke(this);var o="";break e}this.h.i=new h.TextDecoder}for(b=0;bb)throw Error("Bad port number "+b);a.m=b}else a.m=null}function Le(a,b,t){b instanceof Ye?(a.i=b,function(a,b){b&&!a.j&&(We(a),a.i=null,a.g.forEach((function(t,e){var n=e.toLowerCase();e!=n&&(Qe(this,e),Je(this,n,t))}),a)),a.j=b}(a.i,a.h)):(t||(b=Ue(b,Ke)),a.i=new Ye(b,a.h))}function Ve(a,b,t){a.i.set(b,t)}function Be(a){return Ve(a,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),a}function Fe(a,b){return a?b?decodeURI(a.replace(/%25/g,"%2525")):decodeURIComponent(a):""}function Ue(a,b,t){return"string"==typeof a?(a=encodeURI(a).replace(b,qe),t&&(a=a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),a):null}function qe(a){return"%"+((a=a.charCodeAt(0))>>4&15).toString(16)+(15&a).toString(16)}Re.prototype.toString=function(){var a=[],b=this.j;b&&a.push(Ue(b,$e,!0),":");var t=this.g;return(t||"file"==b)&&(a.push("//"),(b=this.s)&&a.push(Ue(b,$e,!0),"@"),a.push(encodeURIComponent(String(t)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(t=this.m)&&a.push(":",String(t))),(t=this.l)&&(this.g&&"/"!=t.charAt(0)&&a.push("/"),a.push(Ue(t,"/"==t.charAt(0)?Ge:ze,!0))),(t=this.i.toString())&&a.push("?",t),(t=this.o)&&a.push("#",Ue(t,He)),a.join("")};var $e=/[#\/\?@]/g,ze=/[#\?:]/g,Ge=/[#\?]/g,Ke=/[#\?@]/g,He=/#/g;function Ye(a,b){this.h=this.g=null,this.i=a||null,this.j=!!b}function We(a){a.g||(a.g=new Map,a.h=0,a.i&&function(a,b){if(a){a=a.split("&");for(var t=0;t=a.j}function rn(a){return a.h?1:a.g?a.g.size:0}function on(a,b){return a.h?a.h==b:!!a.g&&a.g.has(b)}function sn(a,b){a.g?a.g.add(b):a.h=b}function an(a,b){a.h&&a.h==b?a.h=null:a.g&&a.g.has(b)&&a.g.delete(b)}function cn(a){if(null!=a.h)return a.i.concat(a.h.D);if(null!=a.g&&0!==a.g.size){let b=a.i;for(const t of a.g.values())b=b.concat(t.D);return b}return E(a.i)}function un(){}function ln(){this.g=new un}function hn(a,b,t){const e=t||"";try{Ae(a,(function(t,n){let r=t;p(t)&&(r=Ct(t)),b.push(e+n+"="+encodeURIComponent(r))}))}catch(t){throw b.push(e+"type="+encodeURIComponent("_badmap")),t}}function dd(a,b,t,e,n){try{b.onload=null,b.onerror=null,b.onabort=null,b.ontimeout=null,n(e)}catch(t){}}function fn(a){this.l=a.$b||null,this.j=a.ib||!1}function dn(a,b){Et.call(this),this.D=a,this.u=b,this.m=void 0,this.readyState=pn,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.v=new Headers,this.h=null,this.C="GET",this.B="",this.g=!1,this.A=this.j=this.l=null}tn.prototype.cancel=function(){if(this.i=cn(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(const a of this.g.values())a.cancel();this.g.clear()}},un.prototype.stringify=function(a){return h.JSON.stringify(a,void 0)},un.prototype.parse=function(a){return h.JSON.parse(a,void 0)},x(fn,ae),fn.prototype.g=function(){return new dn(this.l,this.j)},fn.prototype.i=function(a){return function(){return a}}({}),x(dn,Et);var pn=0;function mn(a){a.j.read().then(a.Sa.bind(a)).catch(a.ga.bind(a))}function gn(a){a.readyState=4,a.l=null,a.j=null,a.A=null,yn(a)}function yn(a){a.onreadystatechange&&a.onreadystatechange.call(a)}(r=dn.prototype).open=function(a,b){if(this.readyState!=pn)throw this.abort(),Error("Error reopening a connection");this.C=a,this.B=b,this.readyState=1,yn(this)},r.send=function(a){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;const b={headers:this.v,method:this.C,credentials:this.m,cache:void 0};a&&(b.body=a),(this.D||h).fetch(new Request(this.B,b)).then(this.Va.bind(this),this.ga.bind(this))},r.abort=function(){this.response=this.responseText="",this.v=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch((()=>{})),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,gn(this)),this.readyState=pn},r.Va=function(a){if(this.g&&(this.l=a,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=a.headers,this.readyState=2,yn(this)),this.g&&(this.readyState=3,yn(this),this.g)))if("arraybuffer"===this.responseType)a.arrayBuffer().then(this.Ta.bind(this),this.ga.bind(this));else if(void 0!==h.ReadableStream&&"body"in a){if(this.j=a.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;mn(this)}else a.text().then(this.Ua.bind(this),this.ga.bind(this))},r.Sa=function(a){if(this.g){if(this.u&&a.value)this.response.push(a.value);else if(!this.u){var b=a.value?a.value:new Uint8Array(0);(b=this.A.decode(b,{stream:!a.done}))&&(this.response=this.responseText+=b)}a.done?gn(this):yn(this),3==this.readyState&&mn(this)}},r.Ua=function(a){this.g&&(this.response=this.responseText=a,gn(this))},r.Ta=function(a){this.g&&(this.response=a,gn(this))},r.ga=function(){this.g&&gn(this)},r.setRequestHeader=function(a,b){this.v.append(a,b)},r.getResponseHeader=function(a){return this.h&&this.h.get(a.toLowerCase())||""},r.getAllResponseHeaders=function(){if(!this.h)return"";const a=[],b=this.h.entries();for(var t=b.next();!t.done;)t=t.value,a.push(t[0]+": "+t[1]),t=b.next();return a.join("\r\n")},Object.defineProperty(dn.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(a){this.m=a?"include":"same-origin"}});var bn=h.JSON.parse;function wn(a){Et.call(this),this.headers=new Map,this.u=a||null,this.h=!1,this.C=this.g=null,this.H="",this.m=0,this.j="",this.l=this.F=this.v=this.D=!1,this.B=0,this.A=null,this.J=vn,this.K=this.L=!1}x(wn,Et);var vn="",Tn=/^https?$/i,xn=["POST","PUT"];function Sn(a,b){a.h=!1,a.g&&(a.l=!0,a.g.abort(),a.l=!1),a.j=b,a.m=5,In(a),_n(a)}function In(a){a.D||(a.D=!0,Ot(a,"complete"),Ot(a,"error"))}function td(a){if(a.h&&void 0!==l&&(!a.C[1]||4!=On(a)||2!=a.aa()))if(a.v&&4==On(a))Ut(a.Ha,0,a);else if(Ot(a,"readystatechange"),4==On(a)){a.h=!1;try{const c=a.aa();t:switch(c){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var b=!0;break t;default:b=!1}var t;if(!(t=b)){var e;if(e=0===c){var n=String(a.H).match(Ne)[1]||null;if(!n&&h.self&&h.self.location){var r=h.self.location.protocol;n=r.substr(0,r.length-1)}e=!Tn.test(n?n.toLowerCase():"")}t=e}if(t)Ot(a,"complete"),Ot(a,"success");else{a.m=6;try{var o=2t)r=Math.max(0,n[u].h-100),c=!1;else try{hn(l,o,"req"+t+"_")}catch(t){e&&e(l)}}if(c){e=o.join("&");break t}}}return a=a.i.splice(0,t),b.D=a,e}function Fn(a){a.g||a.u||(a.Z=1,jt(a.Ia,a),a.A=0)}function Un(a){return!(a.g||a.u||3<=a.A)&&(a.Z++,a.u=ie(q(a.Ia,a),Kn(a,a.A)),a.A++,!0)}function qn(a){null!=a.B&&(h.clearTimeout(a.B),a.B=null)}function $n(a){a.g=new me(a,a.j,"rpc",a.Z),null===a.o&&(a.g.H=a.s),a.g.N=0;var b=Pe(a.sa);Ve(b,"RID","rpc"),Ve(b,"SID",a.I),Ve(b,"CI",a.L?"0":"1"),Ve(b,"AID",a.T),Ve(b,"TYPE","xmlhttp"),Vn(a,b),a.o&&a.s&&Dn(b,a.o,a.s),a.J&&a.g.setTimeout(a.J);var t=a.g;a=a.ka,t.K=1,t.v=Be(Pe(b)),t.s=null,t.P=!0,Te(t,a)}function zn(a){null!=a.v&&(h.clearTimeout(a.v),a.v=null)}function Gn(a,b){var t=null;if(a.g==b){zn(a),qn(a),a.g=null;var e=2}else{if(!on(a.h,b))return;t=b.D,an(a.h,b),e=1}if(0!=a.G)if(a.pa=b.Y,b.i)if(1==e){t=b.s?b.s.length:0,b=Date.now()-b.F;var n=a.C;Ot(e=Jt(),new re(e,t,b,n)),Mn(a)}else Fn(a);else if(3==(n=b.o)||0==n&&0=a.h.j-(a.m?1:0)||(a.m?(a.i=b.D.concat(a.i),0):1==a.G||2==a.G||a.C>=(a.Ya?0:a.Za)||(a.m=ie(q(a.Ja,a,b),Kn(a,a.C)),a.C++,0)))}(a,b)||2==e&&Un(a)))switch(t&&0"content-type"==t.toLowerCase())),n=h.FormData&&a instanceof h.FormData,!(0<=_(xn,b))||e||n||t.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[e,n]of t)this.g.setRequestHeader(e,n);this.J&&(this.g.responseType=this.J),"withCredentials"in this.g&&this.g.withCredentials!==this.L&&(this.g.withCredentials=this.L);try{En(this),0=this.P)){var a=2*this.P;this.j.info("BP detection timer enabled: "+a),this.B=ie(q(this.cb,this),a)}},r.cb=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.L=!1,this.K=!0,ne(10),Pn(this),$n(this))},r.bb=function(){null!=this.v&&(this.v=null,Pn(this),Un(this),ne(19))},r.jb=function(a){a?(this.j.info("Successfully pinged google.com"),ne(2)):(this.j.info("Failed to ping google.com"),ne(1))},(r=Xn.prototype).xa=function(){},r.wa=function(){},r.va=function(){},r.ua=function(){},r.Qa=function(){},Jn.prototype.g=function(a,b){return new Zn(a,b)},x(Zn,Et),Zn.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.H=!0);var a=this.g,b=this.l,t=this.h||void 0;ne(0),a.V=b,a.ia=t||{},a.L=a.Y,a.F=Wn(a,null,a.V),Mn(a)},Zn.prototype.close=function(){Rn(this.g)},Zn.prototype.u=function(a){var b=this.g;if("string"==typeof a){var t={};t.__data__=a,a=t}else this.v&&((t={}).__data__=Ct(a),a=t);b.i.push(new class{constructor(a,b){this.h=a,this.g=b}}(b.$a++,a)),3==b.G&&Mn(b)},Zn.prototype.M=function(){this.g.l=null,delete this.j,Rn(this.g),delete this.g,Zn.X.M.call(this)},x(er,fe),x(nr,de),x(rr,Xn),rr.prototype.xa=function(){Ot(this.g,"a")},rr.prototype.wa=function(a){Ot(this.g,new er(a))},rr.prototype.va=function(a){Ot(this.g,new nr(a))},rr.prototype.ua=function(){Ot(this.g,"b")},Jn.prototype.createWebChannel=Jn.prototype.g,Zn.prototype.send=Zn.prototype.u,Zn.prototype.open=Zn.prototype.m,Zn.prototype.close=Zn.prototype.close,oe.NO_ERROR=0,oe.TIMEOUT=8,oe.HTTP_ERROR=6,se.COMPLETE="complete",ue.EventType=he,he.OPEN="a",he.CLOSE="b",he.ERROR="c",he.MESSAGE="d",Et.prototype.listen=Et.prototype.N,wn.prototype.listenOnce=wn.prototype.O,wn.prototype.getLastError=wn.prototype.Na,wn.prototype.getLastErrorCode=wn.prototype.Ea,wn.prototype.getStatus=wn.prototype.aa,wn.prototype.getResponseJson=wn.prototype.Ra,wn.prototype.getResponseText=wn.prototype.fa,wn.prototype.send=wn.prototype.da;var ir=c.createWebChannelTransport=function(){return new Jn},or=c.getStatEventTarget=function(){return Jt()},sr=c.ErrorCode=oe,ar=c.EventType=se,cr=c.Event=Qt,ur=c.Stat={rb:0,ub:1,vb:2,Ob:3,Tb:4,Qb:5,Rb:6,Pb:7,Nb:8,Sb:9,PROXY:10,NOPROXY:11,Lb:12,Hb:13,Ib:14,Gb:15,Jb:16,Kb:17,nb:18,mb:19,ob:20},lr=c.FetchXmlHttpFactory=fn,fr=c.WebChannel=ue,dr=c.XhrIo=wn}).call(this,n(38))},132:function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return Tl})),n.d(e,"b",(function(){return pu})),n.d(e,"c",(function(){return Zc})),n.d(e,"d",(function(){return qc})),n.d(e,"e",(function(){return Ku})),n.d(e,"f",(function(){return du})),n.d(e,"g",(function(){return mu})),n.d(e,"h",(function(){return C})),n.d(e,"i",(function(){return gu})),n.d(e,"j",(function(){return Hu})),n.d(e,"k",(function(){return Yu})),n.d(e,"l",(function(){return z})),n.d(e,"m",(function(){return Il})),n.d(e,"n",(function(){return $t})),n.d(e,"o",(function(){return W})),n.d(e,"p",(function(){return Y})),n.d(e,"q",(function(){return Lc})),n.d(e,"r",(function(){return E})),n.d(e,"s",(function(){return Rt})),n.d(e,"t",(function(){return x})),n.d(e,"u",(function(){return Rc})),n.d(e,"v",(function(){return Rl})),n.d(e,"w",(function(){return $l})),n.d(e,"x",(function(){return ql})),n.d(e,"y",(function(){return su})),n.d(e,"z",(function(){return Gc})),n.d(e,"A",(function(){return Kc})),n.d(e,"B",(function(){return Uc})),n.d(e,"C",(function(){return Nl})),n.d(e,"D",(function(){return Fl})),n.d(e,"E",(function(){return uu})),n.d(e,"F",(function(){return Hc})),n.d(e,"G",(function(){return ru})),n.d(e,"H",(function(){return iu})),n.d(e,"I",(function(){return cu})),n.d(e,"J",(function(){return ml})),n.d(e,"K",(function(){return pl})),n.d(e,"L",(function(){return eu})),n.d(e,"M",(function(){return Ml})),n.d(e,"N",(function(){return ul})),n.d(e,"O",(function(){return El})),n.d(e,"P",(function(){return Ol})),n.d(e,"Q",(function(){return kl})),n.d(e,"R",(function(){return Cl})),n.d(e,"S",(function(){return dl})),n.d(e,"T",(function(){return zl})),n.d(e,"U",(function(){return sl})),n.d(e,"V",(function(){return al})),n.d(e,"W",(function(){return lu})),n.d(e,"X",(function(){return hu})),n.d(e,"Y",(function(){return Pl})),n.d(e,"Z",(function(){return jl})),n.d(e,"ab",(function(){return rl})),n.d(e,"bb",(function(){return Zu})),n.d(e,"cb",(function(){return Wc})),n.d(e,"db",(function(){return Yc})),n.d(e,"eb",(function(){return Bl})),n.d(e,"fb",(function(){return Ul})),n.d(e,"gb",(function(){return Dl})),n.d(e,"hb",(function(){return w})),n.d(e,"ib",(function(){return Qu})),n.d(e,"jb",(function(){return hl})),n.d(e,"kb",(function(){return ll})),n.d(e,"lb",(function(){return Al})),n.d(e,"mb",(function(){return au})),n.d(e,"nb",(function(){return el}));var r=n(40),o=n(51),c=n(22),l=n(4),h=n(13);const f="@firebase/firestore";class b{constructor(t){this.uid=t}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(t){return t.uid===this.uid}}b.UNAUTHENTICATED=new b(null),b.GOOGLE_CREDENTIALS=new b("google-credentials-uid"),b.FIRST_PARTY=new b("first-party-uid"),b.MOCK_USER=new b("mock-user");let d="9.10.0";const m=new c.b("@firebase/firestore");function y(){return m.logLevel}function w(t){m.setLogLevel(t)}function v(t,...e){if(m.logLevel<=c.a.DEBUG){const n=e.map(S);m.debug(`Firestore (${d}): ${t}`,...n)}}function T(t,...e){if(m.logLevel<=c.a.ERROR){const n=e.map(S);m.error(`Firestore (${d}): ${t}`,...n)}}function x(t,...e){if(m.logLevel<=c.a.WARN){const n=e.map(S);m.warn(`Firestore (${d}): ${t}`,...n)}}function S(t){if("string"==typeof t)return t;try{return e=t,JSON.stringify(e)}catch(e){return t}var e}function I(t="Unexpected state"){const e=`FIRESTORE (${d}) INTERNAL ASSERTION FAILED: `+t;throw T(e),new Error(e)}function _(t,e){t||I()}function E(t,e){t||I()}function O(t,e){return t}const k={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class C extends l.c{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class D{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}class A{constructor(t,e){this.user=e,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}}class q{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,e){t.enqueueRetryable((()=>e(b.UNAUTHENTICATED)))}shutdown(){}}class N{constructor(t){this.token=t,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(t,e){this.changeListener=e,t.enqueueRetryable((()=>e(this.token.user)))}shutdown(){this.changeListener=null}}class R{constructor(t){this.t=t,this.currentUser=b.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,e){let n=this.i;const s=t=>this.i!==n?(n=this.i,e(t)):Promise.resolve();let i=new D;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new D,t.enqueueRetryable((()=>s(this.currentUser)))};const r=()=>{const e=i;t.enqueueRetryable((async()=>{await e.promise,await s(this.currentUser)}))},o=t=>{v("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=t,this.auth.addAuthTokenListener(this.o),r()};this.t.onInit((t=>o(t))),setTimeout((()=>{if(!this.auth){const t=this.t.getImmediate({optional:!0});t?o(t):(v("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new D)}}),0),r()}getToken(){const t=this.i,e=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(e).then((e=>this.i!==t?(v("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):e?(_("string"==typeof e.accessToken),new A(e.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.auth.removeAuthTokenListener(this.o)}u(){const t=this.auth&&this.auth.getUid();return _(null===t||"string"==typeof t),new b(t)}}class P{constructor(t,e,n,s){this.h=t,this.l=e,this.m=n,this.g=s,this.type="FirstParty",this.user=b.FIRST_PARTY,this.p=new Map}I(){return this.g?this.g():(_(!("object"!=typeof this.h||null===this.h||!this.h.auth||!this.h.auth.getAuthHeaderValueForFirstParty)),this.h.auth.getAuthHeaderValueForFirstParty([]))}get headers(){this.p.set("X-Goog-AuthUser",this.l);const t=this.I();return t&&this.p.set("Authorization",t),this.m&&this.p.set("X-Goog-Iam-Authorization-Token",this.m),this.p}}class j{constructor(t,e,n,s){this.h=t,this.l=e,this.m=n,this.g=s}getToken(){return Promise.resolve(new P(this.h,this.l,this.m,this.g))}start(t,e){t.enqueueRetryable((()=>e(b.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class M{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class L{constructor(t){this.T=t,this.forceRefresh=!1,this.appCheck=null,this.A=null}start(t,e){const n=t=>{null!=t.error&&v("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${t.error.message}`);const n=t.token!==this.A;return this.A=t.token,v("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?e(t.token):Promise.resolve()};this.o=e=>{t.enqueueRetryable((()=>n(e)))};const s=t=>{v("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=t,this.appCheck.addTokenListener(this.o)};this.T.onInit((t=>s(t))),setTimeout((()=>{if(!this.appCheck){const t=this.T.getImmediate({optional:!0});t?s(t):v("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){const t=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(t).then((t=>t?(_("string"==typeof t.token),this.A=t.token,new M(t.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}function V(t){const e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(n);else for(let e=0;ee?1:0}function U(t,e,n){return t.length===e.length&&t.every(((t,s)=>n(t,e[s])))}function $(t){return t+"\0"}class z{constructor(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new C(k.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new C(k.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new C(k.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new C(k.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}static now(){return z.fromMillis(Date.now())}static fromDate(t){return z.fromMillis(t.getTime())}static fromMillis(t){const e=Math.floor(t/1e3),n=Math.floor(1e6*(t-1e3*e));return new z(e,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(t){return this.seconds===t.seconds?F(this.nanoseconds,t.nanoseconds):F(this.seconds,t.seconds)}isEqual(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}class G{constructor(t){this.timestamp=t}static fromTimestamp(t){return new G(t)}static min(){return new G(new z(0,0))}static max(){return new G(new z(253402300799,999999999))}compareTo(t){return this.timestamp._compareTo(t.timestamp)}isEqual(t){return this.timestamp.isEqual(t.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}class K{constructor(t,e,n){void 0===e?e=0:e>t.length&&I(),void 0===n?n=t.length-e:n>t.length-e&&I(),this.segments=t,this.offset=e,this.len=n}get length(){return this.len}isEqual(t){return 0===K.comparator(this,t)}child(t){const e=this.segments.slice(this.offset,this.limit());return t instanceof K?t.forEach((t=>{e.push(t)})):e.push(t),this.construct(e)}limit(){return this.offset+this.length}popFirst(t){return t=void 0===t?1:t,this.construct(this.segments,this.offset+t,this.length-t)}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(t){return this.segments[this.offset+t]}isEmpty(){return 0===this.length}isPrefixOf(t){if(t.lengthi)return 1}return t.lengthe.length?1:0}}class H extends K{construct(t,e,n){return new H(t,e,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}static fromString(...t){const e=[];for(const n of t){if(n.indexOf("//")>=0)throw new C(k.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);e.push(...n.split("/").filter((t=>t.length>0)))}return new H(e)}static emptyPath(){return new H([])}}const rt=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class Y extends K{construct(t,e,n){return new Y(t,e,n)}static isValidIdentifier(t){return rt.test(t)}canonicalString(){return this.toArray().map((t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),Y.isValidIdentifier(t)||(t="`"+t+"`"),t))).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&"__name__"===this.get(0)}static keyField(){return new Y(["__name__"])}static fromServerFormat(t){const e=[];let n="",s=0;const i=()=>{if(0===n.length)throw new C(k.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(n),n=""};let r=!1;for(;s=2&&this.path.get(this.path.length-2)===t}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(t){return null!==t&&0===H.comparator(this.path,t.path)}toString(){return this.path.toString()}static comparator(t,e){return H.comparator(t.path,e.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(t){return new W(new H(t.slice()))}}class Q{constructor(t,e,n,s){this.indexId=t,this.collectionGroup=e,this.fields=n,this.indexState=s}}function X(t){return t.fields.find((t=>2===t.kind))}function J(t){return t.fields.filter((t=>2!==t.kind))}Q.UNKNOWN_ID=-1;class Z{constructor(t,e){this.fieldPath=t,this.kind=e}}class tt{constructor(t,e){this.sequenceNumber=t,this.offset=e}static empty(){return new tt(0,it.min())}}function et(t,e){const n=t.toTimestamp().seconds,s=t.toTimestamp().nanoseconds+1,i=G.fromTimestamp(1e9===s?new z(n+1,0):new z(n,s));return new it(i,W.empty(),e)}function nt(t){return new it(t.readTime,t.key,-1)}class it{constructor(t,e,n){this.readTime=t,this.documentKey=e,this.largestBatchId=n}static min(){return new it(G.min(),W.empty(),-1)}static max(){return new it(G.max(),W.empty(),-1)}}function ot(t,e){let n=t.readTime.compareTo(e.readTime);return 0!==n?n:(n=W.comparator(t.documentKey,e.documentKey),0!==n?n:F(t.largestBatchId,e.largestBatchId))}const st="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class at{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(t){this.onCommittedListeners.push(t)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((t=>t()))}}async function ct(t){if(t.code!==k.FAILED_PRECONDITION||t.message!==st)throw t;v("LocalStore","Unexpectedly lost primary lease")}class ut{constructor(t){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t((t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)}),(t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)}))}catch(t){return this.next(void 0,t)}next(t,e){return this.callbackAttached&&I(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(e,this.error):this.wrapSuccess(t,this.result):new ut(((n,s)=>{this.nextCallback=e=>{this.wrapSuccess(t,e).next(n,s)},this.catchCallback=t=>{this.wrapFailure(e,t).next(n,s)}}))}toPromise(){return new Promise(((t,e)=>{this.next(t,e)}))}wrapUserFunction(t){try{const e=t();return e instanceof ut?e:ut.resolve(e)}catch(t){return ut.reject(t)}}wrapSuccess(t,e){return t?this.wrapUserFunction((()=>t(e))):ut.resolve(e)}wrapFailure(t,e){return t?this.wrapUserFunction((()=>t(e))):ut.reject(e)}static resolve(t){return new ut(((e,n)=>{e(t)}))}static reject(t){return new ut(((e,n)=>{n(t)}))}static waitFor(t){return new ut(((e,n)=>{let s=0,i=0,r=!1;t.forEach((t=>{++s,t.next((()=>{++i,r&&i===s&&e()}),(t=>n(t)))})),r=!0,i===s&&e()}))}static or(t){let e=ut.resolve(!1);for(const n of t)e=e.next((t=>t?ut.resolve(t):n()));return e}static forEach(t,e){const n=[];return t.forEach(((t,s)=>{n.push(e.call(this,t,s))})),this.waitFor(n)}static mapArray(t,e){return new ut(((n,s)=>{const i=t.length,r=new Array(i);let o=0;for(let u=0;u{r[c]=t,++o,o===i&&n(r)}),(t=>s(t)))}}))}static doWhile(t,e){return new ut(((n,s)=>{const i=()=>{!0===t()?e().next((()=>{i()}),s):n()};i()}))}}class lt{constructor(t,e){this.action=t,this.transaction=e,this.aborted=!1,this.P=new D,this.transaction.oncomplete=()=>{this.P.resolve()},this.transaction.onabort=()=>{e.error?this.P.reject(new pt(t,e.error)):this.P.resolve()},this.transaction.onerror=e=>{const n=wt(e.target.error);this.P.reject(new pt(t,n))}}static open(t,e,n,s){try{return new lt(e,t.transaction(s,n))}catch(t){throw new pt(e,t)}}get v(){return this.P.promise}abort(t){t&&this.P.reject(t),this.aborted||(v("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}V(){const t=this.transaction;this.aborted||"function"!=typeof t.commit||t.commit()}store(t){const e=this.transaction.objectStore(t);return new gt(e)}}class ht{constructor(t,e,n){this.name=t,this.version=e,this.S=n,12.2===ht.D(Object(l.k)())&&T("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}static delete(t){return v("SimpleDb","Removing database:",t),yt(window.indexedDB.deleteDatabase(t)).toPromise()}static C(){if(!Object(l.m)())return!1;if(ht.N())return!0;const t=Object(l.k)(),e=ht.D(t),n=00||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||n||i)}static N(){var e;return void 0!==t&&"YES"===(null===(e=t.env)||void 0===e?void 0:e.M)}static O(t,e){return t.store(e)}static D(t){const e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)}static k(t){const e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)}async F(t){return this.db||(v("SimpleDb","Opening database:",this.name),this.db=await new Promise(((e,n)=>{const s=indexedDB.open(this.name,this.version);s.onsuccess=t=>{const n=t.target.result;e(n)},s.onblocked=()=>{n(new pt(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},s.onerror=e=>{const s=e.target.error;"VersionError"===s.name?n(new C(k.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"===s.name?n(new C(k.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: "+s)):n(new pt(t,s))},s.onupgradeneeded=t=>{v("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',t.oldVersion);const e=t.target.result;this.S.$(e,s.transaction,t.oldVersion,this.version).next((()=>{v("SimpleDb","Database upgrade to version "+this.version+" complete")}))}}))),this.B&&(this.db.onversionchange=t=>this.B(t)),this.db}L(t){this.B=t,this.db&&(this.db.onversionchange=e=>t(e))}async runTransaction(t,e,n,s){const i="readonly"===e;let r=0;for(;;){++r;try{this.db=await this.F(t);const e=lt.open(this.db,t,i?"readonly":"readwrite",n),r=s(e).next((t=>(e.V(),t))).catch((t=>(e.abort(t),ut.reject(t)))).toPromise();return r.catch((()=>{})),await e.v,r}catch(t){const e=t,n="FirebaseError"!==e.name&&r<3;if(v("SimpleDb","Transaction failed with error:",e.message,"Retrying:",n),this.close(),!n)return Promise.reject(e)}}}close(){this.db&&this.db.close(),this.db=void 0}}class ft{constructor(t){this.U=t,this.q=!1,this.K=null}get isDone(){return this.q}get G(){return this.K}set cursor(t){this.U=t}done(){this.q=!0}j(t){this.K=t}delete(){return yt(this.U.delete())}}class pt extends C{constructor(t,e){super(k.UNAVAILABLE,`IndexedDB transaction '${t}' failed: ${e}`),this.name="IndexedDbTransactionError"}}function mt(t){return"IndexedDbTransactionError"===t.name}class gt{constructor(t){this.store=t}put(t,e){let n;return void 0!==e?(v("SimpleDb","PUT",this.store.name,t,e),n=this.store.put(e,t)):(v("SimpleDb","PUT",this.store.name,"",t),n=this.store.put(t)),yt(n)}add(t){return v("SimpleDb","ADD",this.store.name,t,t),yt(this.store.add(t))}get(t){return yt(this.store.get(t)).next((e=>(void 0===e&&(e=null),v("SimpleDb","GET",this.store.name,t,e),e)))}delete(t){return v("SimpleDb","DELETE",this.store.name,t),yt(this.store.delete(t))}count(){return v("SimpleDb","COUNT",this.store.name),yt(this.store.count())}W(t,e){const n=this.options(t,e);if(n.index||"function"!=typeof this.store.getAll){const t=this.cursor(n),e=[];return this.H(t,((t,n)=>{e.push(n)})).next((()=>e))}{const t=this.store.getAll(n.range);return new ut(((e,n)=>{t.onerror=t=>{n(t.target.error)},t.onsuccess=t=>{e(t.target.result)}}))}}J(t,e){const n=this.store.getAll(t,null===e?void 0:e);return new ut(((t,e)=>{n.onerror=t=>{e(t.target.error)},n.onsuccess=e=>{t(e.target.result)}}))}Y(t,e){v("SimpleDb","DELETE ALL",this.store.name);const n=this.options(t,e);n.X=!1;const s=this.cursor(n);return this.H(s,((t,e,n)=>n.delete()))}Z(t,e){let n;e?n=t:(n={},e=t);const s=this.cursor(n);return this.H(s,e)}tt(t){const e=this.cursor({});return new ut(((n,s)=>{e.onerror=t=>{const e=wt(t.target.error);s(e)},e.onsuccess=e=>{const s=e.target.result;s?t(s.primaryKey,s.value).next((t=>{t?s.continue():n()})):n()}}))}H(t,e){const n=[];return new ut(((s,i)=>{t.onerror=t=>{i(t.target.error)},t.onsuccess=t=>{const i=t.target.result;if(!i)return void s();const r=new ft(i),o=e(i.primaryKey,i.value,r);if(o instanceof ut){const t=o.catch((t=>(r.done(),ut.reject(t))));n.push(t)}r.isDone?s():null===r.G?i.continue():i.continue(r.G)}})).next((()=>ut.waitFor(n)))}options(t,e){let n;return void 0!==t&&("string"==typeof t?n=t:e=t),{index:n,range:e}}cursor(t){let e="next";if(t.reverse&&(e="prev"),t.index){const n=this.store.index(t.index);return t.X?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)}}function yt(t){return new ut(((e,n)=>{t.onsuccess=t=>{const n=t.target.result;e(n)},t.onerror=t=>{const e=wt(t.target.error);n(e)}}))}let bt=!1;function wt(t){const e=ht.D(Object(l.k)());if(e>=12.2&&e<13){const e="An internal error was encountered in the Indexed Database server";if(t.message.indexOf(e)>=0){const t=new C("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${e}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return bt||(bt=!0,setTimeout((()=>{throw t}),0)),t}}return t}class vt{constructor(t,e){this.asyncQueue=t,this.et=e,this.task=null}start(){this.nt(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return null!==this.task}nt(t){v("IndexBackiller",`Scheduled in ${t}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",t,(async()=>{this.task=null;try{v("IndexBackiller",`Documents written: ${await this.et.st()}`)}catch(t){mt(t)?v("IndexBackiller","Ignoring IndexedDB error during index backfill: ",t):await ct(t)}await this.nt(6e4)}))}}class Tt{constructor(t,e){this.localStore=t,this.persistence=e}async st(t=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",(e=>this.it(e,t)))}it(t,e){const n=new Set;let s=e,i=!0;return ut.doWhile((()=>!0===i&&s>0),(()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(t).next((e=>{if(null!==e&&!n.has(e))return v("IndexBackiller",`Processing collection: ${e}`),this.rt(t,e,s).next((t=>{s-=t,n.add(e)}));i=!1})))).next((()=>e-s))}rt(t,e,n){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(t,e).next((s=>this.localStore.localDocuments.getNextDocuments(t,e,s,n).next((n=>{const i=n.changes;return this.localStore.indexManager.updateIndexEntries(t,i).next((()=>this.ot(s,n))).next((n=>(v("IndexBackiller",`Updating offset: ${n}`),this.localStore.indexManager.updateCollectionGroup(t,e,n)))).next((()=>i.size))}))))}ot(t,e){let n=t;return e.changes.forEach(((t,e)=>{const s=nt(e);ot(s,n)>0&&(n=s)})),new it(n.readTime,n.documentKey,Math.max(e.batchId,t.largestBatchId))}}class xt{constructor(t,e){this.previousValue=t,e&&(e.sequenceNumberHandler=t=>this.ut(t),this.ct=t=>e.writeSequenceNumber(t))}ut(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){const t=++this.previousValue;return this.ct&&this.ct(t),t}}function St(t){let e=0;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function It(t,e){for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function _t(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}xt.at=-1;class Et{constructor(t,e){this.comparator=t,this.root=e||kt.EMPTY}insert(t,e){return new Et(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,kt.BLACK,null,null))}remove(t){return new Et(this.comparator,this.root.remove(t,this.comparator).copy(null,null,kt.BLACK,null,null))}get(t){let e=this.root;for(;!e.isEmpty();){const n=this.comparator(t,e.key);if(0===n)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null}indexOf(t){let e=0,n=this.root;for(;!n.isEmpty();){const s=this.comparator(t,n.key);if(0===s)return e+n.left.size;s<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(t){return this.root.inorderTraversal(t)}forEach(t){this.inorderTraversal(((e,n)=>(t(e,n),!1)))}toString(){const t=[];return this.inorderTraversal(((e,n)=>(t.push(`${e}:${n}`),!1))),`{${t.join(", ")}}`}reverseTraversal(t){return this.root.reverseTraversal(t)}getIterator(){return new Ot(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new Ot(this.root,t,this.comparator,!1)}getReverseIterator(){return new Ot(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new Ot(this.root,t,this.comparator,!0)}}class Ot{constructor(t,e,n,s){this.isReverse=s,this.nodeStack=[];let i=1;for(;!t.isEmpty();)if(i=e?n(t.key,e):1,e&&s&&(i*=-1),i<0)t=this.isReverse?t.left:t.right;else{if(0===i){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}getNext(){let t=this.nodeStack.pop();const e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;const t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}}}class kt{constructor(t,e,n,s,i){this.key=t,this.value=e,this.color=null!=n?n:kt.RED,this.left=null!=s?s:kt.EMPTY,this.right=null!=i?i:kt.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,e,n,s,i){return new kt(null!=t?t:this.key,null!=e?e:this.value,null!=n?n:this.color,null!=s?s:this.left,null!=i?i:this.right)}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}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(t,e,n){let s=this;const i=n(t,s.key);return s=i<0?s.copy(null,null,null,s.left.insert(t,e,n),null):0===i?s.copy(null,e,null,null,null):s.copy(null,null,null,null,s.right.insert(t,e,n)),s.fixUp()}removeMin(){if(this.left.isEmpty())return kt.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,e){let n,s=this;if(e(t,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(t,e),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),0===e(t,s.key)){if(s.right.isEmpty())return kt.EMPTY;n=s.right.min(),s=s.copy(n.key,n.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(t,e))}return s.fixUp()}isRed(){return this.color}fixUp(){let t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t}moveRedLeft(){let t=this.colorFlip();return t.right.left.isRed()&&(t=t.copy(null,null,null,null,t.right.rotateRight()),t=t.rotateLeft(),t=t.colorFlip()),t}moveRedRight(){let t=this.colorFlip();return t.left.left.isRed()&&(t=t.rotateRight(),t=t.colorFlip()),t}rotateLeft(){const t=this.copy(null,null,kt.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){const t=this.copy(null,null,kt.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){const t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth(){const t=this.check();return Math.pow(2,t)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw I();if(this.right.isRed())throw I();const t=this.left.check();if(t!==this.right.check())throw I();return t+(this.isRed()?0:1)}}kt.EMPTY=null,kt.RED=!0,kt.BLACK=!1,kt.EMPTY=new class{constructor(){this.size=0}get key(){throw I()}get value(){throw I()}get color(){throw I()}get left(){throw I()}get right(){throw I()}copy(t,e,n,s,i){return this}insert(t,e,n){return new kt(t,e)}remove(t,e){return this}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class Ct{constructor(t){this.comparator=t,this.data=new Et(this.comparator)}has(t){return null!==this.data.get(t)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal(((e,n)=>(t(e),!1)))}forEachInRange(t,e){const n=this.data.getIteratorFrom(t[0]);for(;n.hasNext();){const s=n.getNext();if(this.comparator(s.key,t[1])>=0)return;e(s.key)}}forEachWhile(t,e){let n;for(n=void 0!==e?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return}firstAfterOrEqual(t){const e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null}getIterator(){return new Dt(this.data.getIterator())}getIteratorFrom(t){return new Dt(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let e=this;return e.size{e=e.add(t)})),e}isEqual(t){if(!(t instanceof Ct))return!1;if(this.size!==t.size)return!1;const e=this.data.getIterator(),n=t.data.getIterator();for(;e.hasNext();){const t=e.getNext().key,s=n.getNext().key;if(0!==this.comparator(t,s))return!1}return!0}toArray(){const t=[];return this.forEach((e=>{t.push(e)})),t}toString(){const t=[];return this.forEach((e=>t.push(e))),"SortedSet("+t.toString()+")"}copy(t){const e=new Ct(this.comparator);return e.data=t,e}}class Dt{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function At(t){return t.hasNext()?t.getNext():void 0}class Nt{constructor(t){this.fields=t,t.sort(Y.comparator)}static empty(){return new Nt([])}unionWith(t){let e=new Ct(Y.comparator);for(const t of this.fields)e=e.add(t);for(const n of t)e=e.add(n);return new Nt(e.toArray())}covers(t){for(const e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return U(this.fields,t.fields,((t,e)=>t.isEqual(e)))}}function Rt(){return"undefined"!=typeof atob}class Pt{constructor(t){this.binaryString=t}static fromBase64String(t){const e=atob(t);return new Pt(e)}static fromUint8Array(t){const e=function(t){let e="";for(let n=0;nt=Number.MIN_SAFE_INTEGER}const Ht={mapValue:{fields:{__type__:{stringValue:"__max__"}}}},Yt={nullValue:"NULL_VALUE"};function Wt(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?Bt(t)?4:ue(t)?9007199254740991:10:I()}function Qt(t,e){if(t===e)return!0;const n=Wt(t);if(n!==Wt(e))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return Ut(t).isEqual(Ut(e));case 3:return function(t,e){if("string"==typeof t.timestampValue&&"string"==typeof e.timestampValue&&t.timestampValue.length===e.timestampValue.length)return t.timestampValue===e.timestampValue;const n=Mt(t.timestampValue),s=Mt(e.timestampValue);return n.seconds===s.seconds&&n.nanos===s.nanos}(t,e);case 5:return t.stringValue===e.stringValue;case 6:return function(t,e){return Vt(t.bytesValue).isEqual(Vt(e.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(t,e){return Lt(t.geoPointValue.latitude)===Lt(e.geoPointValue.latitude)&&Lt(t.geoPointValue.longitude)===Lt(e.geoPointValue.longitude)}(t,e);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return Lt(t.integerValue)===Lt(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){const n=Lt(t.doubleValue),s=Lt(e.doubleValue);return n===s?Gt(n)===Gt(s):isNaN(n)&&isNaN(s)}return!1}(t,e);case 9:return U(t.arrayValue.values||[],e.arrayValue.values||[],Qt);case 10:return function(t,e){const n=t.mapValue.fields||{},s=e.mapValue.fields||{};if(St(n)!==St(s))return!1;for(const t in n)if(n.hasOwnProperty(t)&&(void 0===s[t]||!Qt(n[t],s[t])))return!1;return!0}(t,e);default:return I()}}function Xt(t,e){return void 0!==(t.values||[]).find((t=>Qt(t,e)))}function Jt(t,e){if(t===e)return 0;const n=Wt(t),s=Wt(e);if(n!==s)return F(n,s);switch(n){case 0:case 9007199254740991:return 0;case 1:return F(t.booleanValue,e.booleanValue);case 2:return function(t,e){const n=Lt(t.integerValue||t.doubleValue),s=Lt(e.integerValue||e.doubleValue);return ns?1:n===s?0:isNaN(n)?isNaN(s)?0:-1:1}(t,e);case 3:return Zt(t.timestampValue,e.timestampValue);case 4:return Zt(Ut(t),Ut(e));case 5:return F(t.stringValue,e.stringValue);case 6:return function(t,e){const n=Vt(t),s=Vt(e);return n.compareTo(s)}(t.bytesValue,e.bytesValue);case 7:return function(t,e){const n=t.split("/"),s=e.split("/");for(let t=0;te.mapValue.fields[t]=ce(n))),e}if(t.arrayValue){const e={arrayValue:{values:[]}};for(let n=0;n<(t.arrayValue.values||[]).length;++n)e.arrayValue.values[n]=ce(t.arrayValue.values[n]);return e}return Object.assign({},t)}function ue(t){return"__max__"===(((t.mapValue||{}).fields||{}).__type__||{}).stringValue}function le(t){return"nullValue"in t?Yt:"booleanValue"in t?{booleanValue:!1}:"integerValue"in t||"doubleValue"in t?{doubleValue:NaN}:"timestampValue"in t?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in t?{stringValue:""}:"bytesValue"in t?{bytesValue:""}:"referenceValue"in t?ne($t.empty(),W.empty()):"geoPointValue"in t?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in t?{arrayValue:{}}:"mapValue"in t?{mapValue:{}}:I()}function he(t){return"nullValue"in t?{booleanValue:!1}:"booleanValue"in t?{doubleValue:NaN}:"integerValue"in t||"doubleValue"in t?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in t?{stringValue:""}:"stringValue"in t?{bytesValue:""}:"bytesValue"in t?ne($t.empty(),W.empty()):"referenceValue"in t?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in t?{arrayValue:{}}:"arrayValue"in t?{mapValue:{}}:"mapValue"in t?Ht:I()}function fe(t,e){const n=Jt(t.value,e.value);return 0!==n?n:t.inclusive&&!e.inclusive?-1:!t.inclusive&&e.inclusive?1:0}function de(t,e){const n=Jt(t.value,e.value);return 0!==n?n:t.inclusive&&!e.inclusive?1:!t.inclusive&&e.inclusive?-1:0}class pe{constructor(t){this.value=t}static empty(){return new pe({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let e=this.value;for(let n=0;n{if(!e.isImmediateParentOf(i)){const t=this.getFieldsMap(e);this.applyChanges(t,n,s),n={},s=[],e=i.popLast()}t?n[i.lastSegment()]=ce(t):s.push(i.lastSegment())}));const i=this.getFieldsMap(e);this.applyChanges(i,n,s)}delete(t){const e=this.field(t.popLast());ae(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return Qt(this.value,t.value)}getFieldsMap(t){let e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(let n=0;nt[e]=n));for(const e of n)delete t[e]}clone(){return new pe(ce(this.value))}}function me(t){const e=[];return It(t.fields,((t,n)=>{const s=new Y([t]);if(ae(n)){const t=me(n.mapValue).fields;if(0===t.length)e.push(s);else for(const n of t)e.push(s.child(n))}else e.push(s)})),new Nt(e)}class ge{constructor(t,e,n,s,i,r){this.key=t,this.documentType=e,this.version=n,this.readTime=s,this.data=i,this.documentState=r}static newInvalidDocument(t){return new ge(t,0,G.min(),G.min(),pe.empty(),0)}static newFoundDocument(t,e,n){return new ge(t,1,e,G.min(),n,0)}static newNoDocument(t,e){return new ge(t,2,e,G.min(),pe.empty(),0)}static newUnknownDocument(t,e){return new ge(t,3,e,G.min(),pe.empty(),2)}convertToFoundDocument(t,e){return this.version=t,this.documentType=1,this.data=e,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=pe.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=pe.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=G.min(),this}setReadTime(t){return this.readTime=t,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(t){return t instanceof ge&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new ge(this.key,this.documentType,this.version,this.readTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class ye{constructor(t,e=null,n=[],s=[],i=null,r=null,o=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=s,this.limit=i,this.startAt=r,this.endAt=o,this.ht=null}}function be(t,e=null,n=[],s=[],i=null,r=null,o=null){return new ye(t,e,n,s,i,r,o)}function we(t){const e=O(t);if(null===e.ht){let t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map((t=>{return(e=t).field.canonicalString()+e.op.toString()+te(e.value);var e})).join(","),t+="|ob:",t+=e.orderBy.map((t=>function(t){return t.field.canonicalString()+t.dir}(t))).join(","),zt(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((t=>te(t))).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((t=>te(t))).join(",")),e.ht=t}return e.ht}function ve(t,e){if(t.limit!==e.limit)return!1;if(t.orderBy.length!==e.orderBy.length)return!1;for(let n=0;nt instanceof _e&&t.field.isEqual(e)))}function Se(t,e,n){let s=Yt,i=!0;for(const n of xe(t,e)){let t=Yt,e=!0;switch(n.op){case"<":case"<=":t=le(n.value);break;case"==":case"in":case">=":t=n.value;break;case">":t=n.value,e=!1;break;case"!=":case"not-in":t=Yt}fe({value:s,inclusive:i},{value:t,inclusive:e})<0&&(s=t,i=e)}if(null!==n)for(let r=0;r=":case">":t=he(n.value),e=!1;break;case"==":case"in":case"<=":t=n.value;break;case"<":t=n.value,e=!1;break;case"!=":case"not-in":t=Ht}de({value:s,inclusive:i},{value:t,inclusive:e})>0&&(s=t,i=e)}if(null!==n)for(let r=0;r0&&(s=t,i=n.inclusive);break}return{value:s,inclusive:i}}class _e extends class{}{constructor(t,e,n){super(),this.field=t,this.op=e,this.value=n}static create(t,e,n){return t.isKeyField()?"in"===e||"not-in"===e?this.lt(t,e,n):new Ee(t,e,n):"array-contains"===e?new De(t,n):"in"===e?new Ae(t,n):"not-in"===e?new Ne(t,n):"array-contains-any"===e?new Re(t,n):new _e(t,e,n)}static lt(t,e,n){return"in"===e?new Oe(t,n):new ke(t,n)}matches(t){const e=t.data.field(this.field);return"!="===this.op?null!==e&&this.ft(Jt(e,this.value)):null!==e&&Wt(this.value)===Wt(e)&&this.ft(Jt(e,this.value))}ft(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case"!=":return 0!==t;case">":return t>0;case">=":return t>=0;default:return I()}}dt(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}}class Ee extends _e{constructor(t,e,n){super(t,e,n),this.key=W.fromName(n.referenceValue)}matches(t){const e=W.comparator(t.key,this.key);return this.ft(e)}}class Oe extends _e{constructor(t,e){super(t,"in",e),this.keys=Ce("in",e)}matches(t){return this.keys.some((e=>e.isEqual(t.key)))}}class ke extends _e{constructor(t,e){super(t,"not-in",e),this.keys=Ce("not-in",e)}matches(t){return!this.keys.some((e=>e.isEqual(t.key)))}}function Ce(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map((t=>W.fromName(t.referenceValue)))}class De extends _e{constructor(t,e){super(t,"array-contains",e)}matches(t){const e=t.data.field(this.field);return ie(e)&&Xt(e.arrayValue,this.value)}}class Ae extends _e{constructor(t,e){super(t,"in",e)}matches(t){const e=t.data.field(this.field);return null!==e&&Xt(this.value.arrayValue,e)}}class Ne extends _e{constructor(t,e){super(t,"not-in",e)}matches(t){if(Xt(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const e=t.data.field(this.field);return null!==e&&!Xt(this.value.arrayValue,e)}}class Re extends _e{constructor(t,e){super(t,"array-contains-any",e)}matches(t){const e=t.data.field(this.field);return!(!ie(e)||!e.arrayValue.values)&&e.arrayValue.values.some((t=>Xt(this.value.arrayValue,t)))}}class Pe{constructor(t,e){this.position=t,this.inclusive=e}}class je{constructor(t,e="asc"){this.field=t,this.dir=e}}function Me(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}function Le(t,e,n){let s=0;for(let i=0;i0?t.explicitOrderBy[0].field:null}function ze(t){for(const e of t.filters)if(e.dt())return e.field;return null}function Ge(t){return null!==t.collectionGroup}function Ke(t){const e=O(t);if(null===e._t){e._t=[];const t=ze(e),n=$e(e);if(null!==t&&null===n)t.isKeyField()||e._t.push(new je(t)),e._t.push(new je(Y.keyField(),"asc"));else{let t=!1;for(const n of e.explicitOrderBy)e._t.push(n),n.field.isKeyField()&&(t=!0);if(!t){const t=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";e._t.push(new je(Y.keyField(),t))}}}return e._t}function He(t){const e=O(t);if(!e.wt)if("F"===e.limitType)e.wt=be(e.path,e.collectionGroup,Ke(e),e.filters,e.limit,e.startAt,e.endAt);else{const t=[];for(const n of Ke(e)){const e="desc"===n.dir?"asc":"desc";t.push(new je(n.field,e))}const n=e.endAt?new Pe(e.endAt.position,e.endAt.inclusive):null,s=e.startAt?new Pe(e.startAt.position,e.startAt.inclusive):null;e.wt=be(e.path,e.collectionGroup,t,e.filters,e.limit,n,s)}return e.wt}function Ye(t,e,n){return new Be(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function We(t,e){return ve(He(t),He(e))&&t.limitType===e.limitType}function Qe(t){return`${we(He(t))}|lt:${t.limitType}`}function Xe(t){return`Query(target=${function(t){let e=t.path.canonicalString();return null!==t.collectionGroup&&(e+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(e+=`, filters: [${t.filters.map((t=>{return`${(e=t).field.canonicalString()} ${e.op} ${te(e.value)}`;var e})).join(", ")}]`),zt(t.limit)||(e+=", limit: "+t.limit),t.orderBy.length>0&&(e+=`, orderBy: [${t.orderBy.map((t=>function(t){return`${t.field.canonicalString()} (${t.dir})`}(t))).join(", ")}]`),t.startAt&&(e+=", startAt: ",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map((t=>te(t))).join(",")),t.endAt&&(e+=", endAt: ",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map((t=>te(t))).join(",")),`Target(${e})`}(He(t))}; limitType=${t.limitType})`}function Je(t,e){return e.isFoundDocument()&&function(t,e){const n=e.key.path;return null!==t.collectionGroup?e.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(n):W.isDocumentKey(t.path)?t.path.isEqual(n):t.path.isImmediateParentOf(n)}(t,e)&&function(t,e){for(const n of t.explicitOrderBy)if(!n.field.isKeyField()&&null===e.data.field(n.field))return!1;return!0}(t,e)&&function(t,e){for(const n of t.filters)if(!n.matches(e))return!1;return!0}(t,e)&&function(t,e){return!(t.startAt&&!function(t,e,n){const s=Le(t,e,n);return t.inclusive?s<=0:s<0}(t.startAt,Ke(t),e))&&!(t.endAt&&!function(t,e,n){const s=Le(t,e,n);return t.inclusive?s>=0:s>0}(t.endAt,Ke(t),e))}(t,e)}function Ze(t){return t.collectionGroup||(t.path.length%2==1?t.path.lastSegment():t.path.get(t.path.length-2))}function tn(t){return(e,n)=>{let s=!1;for(const i of Ke(t)){const t=en(i,e,n);if(0!==t)return t;s=s||i.field.isKeyField()}return 0}}function en(t,e,n){const s=t.field.isKeyField()?W.comparator(e.key,n.key):function(t,e,n){const s=e.data.field(t),i=n.data.field(t);return null!==s&&null!==i?Jt(s,i):I()}(t.field,e,n);switch(t.dir){case"asc":return s;case"desc":return-1*s;default:return I()}}function nn(t,e){if(t.gt){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Gt(e)?"-0":e}}function rn(t){return{integerValue:""+t}}function on(t,e){return Kt(e)?rn(e):nn(t,e)}class sn{constructor(){this._=void 0}}function an(t,e,n){return t instanceof ln?function(t,e){const n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:t.seconds,nanos:t.nanoseconds}}}};return e&&(n.fields.__previous_value__=e),{mapValue:n}}(n,e):t instanceof hn?fn(t,e):t instanceof dn?pn(t,e):function(t,e){const n=un(t,e),s=gn(n)+gn(t.yt);return re(n)&&re(t.yt)?rn(s):nn(t.It,s)}(t,e)}function cn(t,e,n){return t instanceof hn?fn(t,e):t instanceof dn?pn(t,e):n}function un(t,e){return t instanceof mn?re(n=e)||function(t){return!!t&&"doubleValue"in t}(n)?e:{integerValue:0}:null;var n}class ln extends sn{}class hn extends sn{constructor(t){super(),this.elements=t}}function fn(t,e){const n=yn(e);for(const e of t.elements)n.some((t=>Qt(t,e)))||n.push(e);return{arrayValue:{values:n}}}class dn extends sn{constructor(t){super(),this.elements=t}}function pn(t,e){let n=yn(e);for(const e of t.elements)n=n.filter((t=>!Qt(t,e)));return{arrayValue:{values:n}}}class mn extends sn{constructor(t,e){super(),this.It=t,this.yt=e}}function gn(t){return Lt(t.integerValue||t.doubleValue)}function yn(t){return ie(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}class bn{constructor(t,e){this.field=t,this.transform=e}}class wn{constructor(t,e){this.version=t,this.transformResults=e}}class vn{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new vn}static exists(t){return new vn(void 0,t)}static updateTime(t){return new vn(t)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}function Tn(t,e){return void 0!==t.updateTime?e.isFoundDocument()&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e.isFoundDocument()}class xn{}function Sn(t,e){if(!t.hasLocalMutations||e&&0===e.fields.length)return null;if(null===e)return t.isNoDocument()?new Rn(t.key,vn.none()):new kn(t.key,t.data,vn.none());{const n=t.data,s=pe.empty();let i=new Ct(Y.comparator);for(let t of e.fields)if(!i.has(t)){let e=n.field(t);null===e&&t.length>1&&(t=t.popLast(),e=n.field(t)),null===e?s.delete(t):s.set(t,e),i=i.add(t)}return new Cn(t.key,s,new Nt(i.toArray()),vn.none())}}function In(t,e,n){t instanceof kn?function(t,e,n){const s=t.value.clone(),i=An(t.fieldTransforms,e,n.transformResults);s.setAll(i),e.convertToFoundDocument(n.version,s).setHasCommittedMutations()}(t,e,n):t instanceof Cn?function(t,e,n){if(!Tn(t.precondition,e))return void e.convertToUnknownDocument(n.version);const s=An(t.fieldTransforms,e,n.transformResults),i=e.data;i.setAll(Dn(t)),i.setAll(s),e.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(t,e,n):function(t,e,n){e.convertToNoDocument(n.version).setHasCommittedMutations()}(0,e,n)}function _n(t,e,n,s){return t instanceof kn?function(t,e,n,s){if(!Tn(t.precondition,e))return n;const i=t.value.clone(),r=Nn(t.fieldTransforms,s,e);return i.setAll(r),e.convertToFoundDocument(e.version,i).setHasLocalMutations(),null}(t,e,n,s):t instanceof Cn?function(t,e,n,s){if(!Tn(t.precondition,e))return n;const i=Nn(t.fieldTransforms,s,e),r=e.data;return r.setAll(Dn(t)),r.setAll(i),e.convertToFoundDocument(e.version,r).setHasLocalMutations(),null===n?null:n.unionWith(t.fieldMask.fields).unionWith(t.fieldTransforms.map((t=>t.field)))}(t,e,n,s):function(t,e,n){return Tn(t.precondition,e)?(e.convertToNoDocument(e.version).setHasLocalMutations(),null):n}(t,e,n)}function En(t,e){let n=null;for(const s of t.fieldTransforms){const t=e.data.field(s.field),i=un(s.transform,t||null);null!=i&&(null===n&&(n=pe.empty()),n.set(s.field,i))}return n||null}function On(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&!!function(t,e){return void 0===t&&void 0===e||!(!t||!e)&&U(t,e,((t,e)=>function(t,e){return t.field.isEqual(e.field)&&function(t,e){return t instanceof hn&&e instanceof hn||t instanceof dn&&e instanceof dn?U(t.elements,e.elements,Qt):t instanceof mn&&e instanceof mn?Qt(t.yt,e.yt):t instanceof ln&&e instanceof ln}(t.transform,e.transform)}(t,e)))}(t.fieldTransforms,e.fieldTransforms)&&(0===t.type?t.value.isEqual(e.value):1!==t.type||t.data.isEqual(e.data)&&t.fieldMask.isEqual(e.fieldMask))}class kn extends xn{constructor(t,e,n,s=[]){super(),this.key=t,this.value=e,this.precondition=n,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class Cn extends xn{constructor(t,e,n,s,i=[]){super(),this.key=t,this.data=e,this.fieldMask=n,this.precondition=s,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function Dn(t){const e=new Map;return t.fieldMask.fields.forEach((n=>{if(!n.isEmpty()){const s=t.data.field(n);e.set(n,s)}})),e}function An(t,e,n){const s=new Map;_(t.length===n.length);for(let i=0;i{for(const[e,s]of n)t(e,s)}))}isEmpty(){return _t(this.inner)}size(){return this.innerSize}}const Un=new Et(W.comparator);function qn(){return Un}const $n=new Et(W.comparator);function zn(...t){let e=$n;for(const n of t)e=e.insert(n.key,n);return e}function Gn(t){let e=$n;return t.forEach(((t,n)=>e=e.insert(t,n.overlayedDocument))),e}function Kn(){return Yn()}function Hn(){return Yn()}function Yn(){return new Fn((t=>t.toString()),((t,e)=>t.isEqual(e)))}const Wn=new Et(W.comparator),Qn=new Ct(W.comparator);function Xn(...t){let e=Qn;for(const n of t)e=e.add(n);return e}const Jn=new Ct(F);function Zn(){return Jn}class er{constructor(t,e,n,s,i){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=s,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(t,e){const n=new Map;return n.set(t,nr.createSynthesizedTargetChangeForCurrentChange(t,e)),new er(G.min(),n,Zn(),qn(),Xn())}}class nr{constructor(t,e,n,s,i){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=s,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(t,e){return new nr(Pt.EMPTY_BYTE_STRING,e,Xn(),Xn(),Xn())}}class rr{constructor(t,e,n,s){this.Tt=t,this.removedTargetIds=e,this.key=n,this.Et=s}}class ir{constructor(t,e){this.targetId=t,this.At=e}}class or{constructor(t,e,n=Pt.EMPTY_BYTE_STRING,s=null){this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=s}}class sr{constructor(){this.Rt=0,this.bt=ur(),this.Pt=Pt.EMPTY_BYTE_STRING,this.vt=!1,this.Vt=!0}get current(){return this.vt}get resumeToken(){return this.Pt}get St(){return 0!==this.Rt}get Dt(){return this.Vt}Ct(t){t.approximateByteSize()>0&&(this.Vt=!0,this.Pt=t)}xt(){let t=Xn(),e=Xn(),n=Xn();return this.bt.forEach(((s,i)=>{switch(i){case 0:t=t.add(s);break;case 2:e=e.add(s);break;case 1:n=n.add(s);break;default:I()}})),new nr(this.Pt,this.vt,t,e,n)}Nt(){this.Vt=!1,this.bt=ur()}kt(t,e){this.Vt=!0,this.bt=this.bt.insert(t,e)}Mt(t){this.Vt=!0,this.bt=this.bt.remove(t)}Ot(){this.Rt+=1}Ft(){this.Rt-=1}$t(){this.Vt=!0,this.vt=!0}}class ar{constructor(t){this.Bt=t,this.Lt=new Map,this.Ut=qn(),this.qt=cr(),this.Kt=new Ct(F)}Gt(t){for(const e of t.Tt)t.Et&&t.Et.isFoundDocument()?this.Qt(e,t.Et):this.jt(e,t.key,t.Et);for(const e of t.removedTargetIds)this.jt(e,t.key,t.Et)}Wt(t){this.forEachTarget(t,(e=>{const n=this.zt(e);switch(t.state){case 0:this.Ht(e)&&n.Ct(t.resumeToken);break;case 1:n.Ft(),n.St||n.Nt(),n.Ct(t.resumeToken);break;case 2:n.Ft(),n.St||this.removeTarget(e);break;case 3:this.Ht(e)&&(n.$t(),n.Ct(t.resumeToken));break;case 4:this.Ht(e)&&(this.Jt(e),n.Ct(t.resumeToken));break;default:I()}}))}forEachTarget(t,e){t.targetIds.length>0?t.targetIds.forEach(e):this.Lt.forEach(((t,n)=>{this.Ht(n)&&e(n)}))}Yt(t){const e=t.targetId,n=t.At.count,s=this.Xt(e);if(s){const t=s.target;if(Te(t))if(0===n){const n=new W(t.path);this.jt(e,n,ge.newNoDocument(n,G.min()))}else _(1===n);else this.Zt(e)!==n&&(this.Jt(e),this.Kt=this.Kt.add(e))}}te(t){const e=new Map;this.Lt.forEach(((n,s)=>{const i=this.Xt(s);if(i){if(n.current&&Te(i.target)){const e=new W(i.target.path);null!==this.Ut.get(e)||this.ee(s,e)||this.jt(s,e,ge.newNoDocument(e,t))}n.Dt&&(e.set(s,n.xt()),n.Nt())}}));let n=Xn();this.qt.forEach(((t,e)=>{let s=!0;e.forEachWhile((t=>{const e=this.Xt(t);return!e||2===e.purpose||(s=!1,!1)})),s&&(n=n.add(t))})),this.Ut.forEach(((e,n)=>n.setReadTime(t)));const s=new er(t,e,this.Kt,this.Ut,n);return this.Ut=qn(),this.qt=cr(),this.Kt=new Ct(F),s}Qt(t,e){if(!this.Ht(t))return;const n=this.ee(t,e.key)?2:0;this.zt(t).kt(e.key,n),this.Ut=this.Ut.insert(e.key,e),this.qt=this.qt.insert(e.key,this.ne(e.key).add(t))}jt(t,e,n){if(!this.Ht(t))return;const s=this.zt(t);this.ee(t,e)?s.kt(e,1):s.Mt(e),this.qt=this.qt.insert(e,this.ne(e).delete(t)),n&&(this.Ut=this.Ut.insert(e,n))}removeTarget(t){this.Lt.delete(t)}Zt(t){const e=this.zt(t).xt();return this.Bt.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size}Ot(t){this.zt(t).Ot()}zt(t){let e=this.Lt.get(t);return e||(e=new sr,this.Lt.set(t,e)),e}ne(t){let e=this.qt.get(t);return e||(e=new Ct(F),this.qt=this.qt.insert(t,e)),e}Ht(t){const e=null!==this.Xt(t);return e||v("WatchChangeAggregator","Detected inactive target",t),e}Xt(t){const e=this.Lt.get(t);return e&&e.St?null:this.Bt.se(t)}Jt(t){this.Lt.set(t,new sr),this.Bt.getRemoteKeysForTarget(t).forEach((e=>{this.jt(t,e,null)}))}ee(t,e){return this.Bt.getRemoteKeysForTarget(t).has(e)}}function cr(){return new Et(W.comparator)}function ur(){return new Et(W.comparator)}const lr={asc:"ASCENDING",desc:"DESCENDING"},fr={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"};class dr{constructor(t,e){this.databaseId=t,this.gt=e}}function pr(t,e){return t.gt?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function mr(t,e){return t.gt?e.toBase64():e.toUint8Array()}function gr(t,e){return pr(t,e.toTimestamp())}function yr(t){return _(!!t),G.fromTimestamp(function(t){const e=Mt(t);return new z(e.seconds,e.nanos)}(t))}function wr(t,e){return function(t){return new H(["projects",t.projectId,"databases",t.database])}(t).child("documents").child(e).canonicalString()}function vr(t){const e=H.fromString(t);return _(qr(e)),e}function Tr(t,e){return wr(t.databaseId,e.path)}function xr(t,e){const n=vr(e);if(n.get(1)!==t.databaseId.projectId)throw new C(k.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+t.databaseId.projectId);if(n.get(3)!==t.databaseId.database)throw new C(k.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new W(Er(n))}function Sr(t,e){return wr(t.databaseId,e)}function Ir(t){const e=vr(t);return 4===e.length?H.emptyPath():Er(e)}function _r(t){return new H(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function Er(t){return _(t.length>4&&"documents"===t.get(4)),t.popFirst(5)}function Or(t,e,n){return{name:Tr(t,e),fields:n.value.mapValue.fields}}function kr(t,e,n){const s=xr(t,e.name),i=yr(e.updateTime),r=new pe({mapValue:{fields:e.fields}}),o=ge.newFoundDocument(s,i,r);return n&&o.setHasCommittedMutations(),n?o.setHasCommittedMutations():o}function Cr(t,e){let n;if(e instanceof kn)n={update:Or(t,e.key,e.value)};else if(e instanceof Rn)n={delete:Tr(t,e.key)};else if(e instanceof Cn)n={update:Or(t,e.key,e.data),updateMask:Ur(e.fieldMask)};else{if(!(e instanceof Pn))return I();n={verify:Tr(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map((t=>function(t,e){const n=e.transform;if(n instanceof ln)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof hn)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof dn)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof mn)return{fieldPath:e.field.canonicalString(),increment:n.yt};throw I()}(0,t)))),e.precondition.isNone||(n.currentDocument=function(t,e){return void 0!==e.updateTime?{updateTime:gr(t,e.updateTime)}:void 0!==e.exists?{exists:e.exists}:I()}(t,e.precondition)),n}function Dr(t,e){const n=e.currentDocument?function(t){return void 0!==t.updateTime?vn.updateTime(yr(t.updateTime)):void 0!==t.exists?vn.exists(t.exists):vn.none()}(e.currentDocument):vn.none(),s=e.updateTransforms?e.updateTransforms.map((e=>function(t,e){let n=null;if("setToServerValue"in e)_("REQUEST_TIME"===e.setToServerValue),n=new ln;else if("appendMissingElements"in e){const t=e.appendMissingElements.values||[];n=new hn(t)}else if("removeAllFromArray"in e){const t=e.removeAllFromArray.values||[];n=new dn(t)}else"increment"in e?n=new mn(t,e.increment):I();const s=Y.fromServerFormat(e.fieldPath);return new bn(s,n)}(t,e))):[];if(e.update){e.update.name;const i=xr(t,e.update.name),r=new pe({mapValue:{fields:e.update.fields}});if(e.updateMask){const t=function(t){const e=t.fieldPaths||[];return new Nt(e.map((t=>Y.fromServerFormat(t))))}(e.updateMask);return new Cn(i,r,t,n,s)}return new kn(i,r,n,s)}if(e.delete){const s=xr(t,e.delete);return new Rn(s,n)}if(e.verify){const s=xr(t,e.verify);return new Pn(s,n)}return I()}function Ar(t,e){return{documents:[Sr(t,e.path)]}}function Nr(t,e){const n={structuredQuery:{}},s=e.path;null!==e.collectionGroup?(n.parent=Sr(t,s),n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(n.parent=Sr(t,s.popLast()),n.structuredQuery.from=[{collectionId:s.lastSegment()}]);const i=function(t){if(0===t.length)return;const e=t.map((t=>function(t){if("=="===t.op){if(se(t.value))return{unaryFilter:{field:Lr(t.field),op:"IS_NAN"}};if(oe(t.value))return{unaryFilter:{field:Lr(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(se(t.value))return{unaryFilter:{field:Lr(t.field),op:"IS_NOT_NAN"}};if(oe(t.value))return{unaryFilter:{field:Lr(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Lr(t.field),op:Mr(t.op),value:t.value}}}(t)));return 1===e.length?e[0]:{compositeFilter:{op:"AND",filters:e}}}(e.filters);i&&(n.structuredQuery.where=i);const r=function(t){if(0!==t.length)return t.map((t=>function(t){return{field:Lr(t.field),direction:jr(t.dir)}}(t)))}(e.orderBy);r&&(n.structuredQuery.orderBy=r);const o=function(t,e){return t.gt||zt(e)?e:{value:e}}(t,e.limit);var u;return null!==o&&(n.structuredQuery.limit=o),e.startAt&&(n.structuredQuery.startAt={before:(u=e.startAt).inclusive,values:u.position}),e.endAt&&(n.structuredQuery.endAt=function(t){return{before:!t.inclusive,values:t.position}}(e.endAt)),n}function Rr(t){let e=Ir(t.parent);const n=t.structuredQuery,s=n.from?n.from.length:0;let i=null;if(s>0){_(1===s);const t=n.from[0];t.allDescendants?i=t.collectionId:e=e.child(t.collectionId)}let r=[];n.where&&(r=Pr(n.where));let o=[];n.orderBy&&(o=n.orderBy.map((t=>function(t){return new je(Vr(t.field),function(t){switch(t){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(t.direction))}(t))));let u=null;n.limit&&(u=function(t){let e;return e="object"==typeof t?t.value:t,zt(e)?null:e}(n.limit));let c=null;n.startAt&&(c=function(t){const e=!!t.before,n=t.values||[];return new Pe(n,e)}(n.startAt));let a=null;return n.endAt&&(a=function(t){const e=!t.before,n=t.values||[];return new Pe(n,e)}(n.endAt)),Fe(e,i,o,r,u,"F",c,a)}function Pr(t){return t?void 0!==t.unaryFilter?[Fr(t)]:void 0!==t.fieldFilter?[Br(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map((t=>Pr(t))).reduce(((t,e)=>t.concat(e))):I():[]}function jr(t){return lr[t]}function Mr(t){return fr[t]}function Lr(t){return{fieldPath:t.canonicalString()}}function Vr(t){return Y.fromServerFormat(t.fieldPath)}function Br(t){return _e.create(Vr(t.fieldFilter.field),function(t){switch(t){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return I()}}(t.fieldFilter.op),t.fieldFilter.value)}function Fr(t){switch(t.unaryFilter.op){case"IS_NAN":const e=Vr(t.unaryFilter.field);return _e.create(e,"==",{doubleValue:NaN});case"IS_NULL":const n=Vr(t.unaryFilter.field);return _e.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const s=Vr(t.unaryFilter.field);return _e.create(s,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const i=Vr(t.unaryFilter.field);return _e.create(i,"!=",{nullValue:"NULL_VALUE"});default:return I()}}function Ur(t){const e=[];return t.fields.forEach((t=>e.push(t.canonicalString()))),{fieldPaths:e}}function qr(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}function $r(t){let e="";for(let n=0;n0&&(e=Gr(e)),e=zr(t.get(n),e);return Gr(e)}function zr(t,e){let n=e;const s=t.length;for(let e=0;e=2),2===e)return _(""===t.charAt(0)&&""===t.charAt(1)),H.emptyPath();const n=e-2,s=[];let i="";for(let r=0;rn)&&I(),t.charAt(e+1)){case"":const n=t.substring(r,e);let o;0===i.length?o=n:(i+=n,o=i,i=""),s.push(o);break;case"":i+=t.substring(r,e),i+="\0";break;case"":i+=t.substring(r,e+1);break;default:I()}r=e+2}return new H(s)}const Hr=["userId","batchId"];function Yr(t,e){return[t,$r(e)]}function Wr(t,e,n){return[t,$r(e),n]}const li={},Qr=["prefixPath","collectionGroup","readTime","documentId"],Xr=["prefixPath","collectionGroup","documentId"],Jr=["collectionGroup","readTime","prefixPath","documentId"],Zr=["canonicalId","targetId"],ti=["targetId","path"],ei=["path","targetId"],ni=["collectionId","parent"],ri=["indexId","uid"],ii=["uid","sequenceNumber"],oi=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],si=["indexId","uid","orderedDocumentKey"],ai=["userId","collectionPath","documentId"],ci=["userId","collectionPath","largestBatchId"],ui=["userId","collectionGroup","largestBatchId"],hi=["mutationQueues","mutations","documentMutations","remoteDocuments","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries"],fi=[...hi,"documentOverlays"],di=["mutationQueues","mutations","documentMutations","remoteDocumentsV14","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries","documentOverlays"],pi=di,mi=[...pi,"indexConfiguration","indexState","indexEntries"];class gi extends at{constructor(t,e){super(),this.ie=t,this.currentSequenceNumber=e}}function yi(t,e){const n=O(t);return ht.O(n.ie,e)}class bi{constructor(t,e,n,s){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=s}applyToRemoteDocument(t,e){const n=e.mutationResults;for(let e=0;e{const i=t.get(s.key),r=i.overlayedDocument;let o=this.applyToLocalView(r,i.mutatedFields);o=e.has(s.key)?null:o;const u=Sn(r,o);null!==u&&n.set(s.key,u),r.isValidDocument()||r.convertToNoDocument(G.min())})),n}keys(){return this.mutations.reduce(((t,e)=>t.add(e.key)),Xn())}isEqual(t){return this.batchId===t.batchId&&U(this.mutations,t.mutations,((t,e)=>On(t,e)))&&U(this.baseMutations,t.baseMutations,((t,e)=>On(t,e)))}}class wi{constructor(t,e,n,s){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.docVersions=s}static from(t,e,n){_(t.mutations.length===n.length);let s=Wn;const i=t.mutations;for(let t=0;tDr(t.re,e)));for(let t=0;tDr(t.re,e))),i=z.fromMillis(e.localWriteTimeMs);return new bi(e.batchId,i,n,s)}function ki(t){const e=Ei(t.readTime),n=void 0!==t.lastLimboFreeSnapshotVersion?Ei(t.lastLimboFreeSnapshotVersion):G.min();let s;var i;return void 0!==t.query.documents?(_(1===(i=t.query).documents.length),s=He(Ue(Ir(i.documents[0])))):s=function(t){return He(Rr(t))}(t.query),new Ti(s,t.targetId,0,t.lastListenSequenceNumber,e,n,Pt.fromBase64String(t.resumeToken))}function Ci(t,e){const n=_i(e.snapshotVersion),s=_i(e.lastLimboFreeSnapshotVersion);let i;i=Te(e.target)?Ar(t.re,e.target):Nr(t.re,e.target);const r=e.resumeToken.toBase64();return{targetId:e.targetId,canonicalId:we(e.target),readTime:n,resumeToken:r,lastListenSequenceNumber:e.sequenceNumber,lastLimboFreeSnapshotVersion:s,query:i}}function Di(t){const e=Rr({parent:t.parent,structuredQuery:t.structuredQuery});return"LAST"===t.limitType?Ye(e,e.limit,"L"):e}function Ai(t,e){return new vi(e.largestBatchId,Dr(t.re,e.overlayMutation))}function Ni(t,e){const n=e.path.lastSegment();return[t,$r(e.path.popLast()),n]}function Ri(t,e,n,s){return{indexId:t,uid:e.uid||"",sequenceNumber:n,readTime:_i(s.readTime),documentKey:$r(s.documentKey.path),largestBatchId:s.largestBatchId}}class Pi{getBundleMetadata(t,e){return ji(t).get(e).next((t=>{if(t)return{id:(e=t).bundleId,createTime:Ei(e.createTime),version:e.version};var e}))}saveBundleMetadata(t,e){return ji(t).put({bundleId:(n=e).id,createTime:_i(yr(n.createTime)),version:n.version});var n}getNamedQuery(t,e){return Mi(t).get(e).next((t=>{if(t)return{name:(e=t).name,query:Di(e.bundledQuery),readTime:Ei(e.readTime)};var e}))}saveNamedQuery(t,e){return Mi(t).put(function(t){return{name:t.name,readTime:_i(yr(t.readTime)),bundledQuery:t.bundledQuery}}(e))}}function ji(t){return yi(t,"bundles")}function Mi(t){return yi(t,"namedQueries")}class Li{constructor(t,e){this.It=t,this.userId=e}static oe(t,e){const n=e.uid||"";return new Li(t,n)}getOverlay(t,e){return tr(t).get(Ni(this.userId,e)).next((t=>t?Ai(this.It,t):null))}getOverlays(t,e){const n=Kn();return ut.forEach(e,(e=>this.getOverlay(t,e).next((t=>{null!==t&&n.set(e,t)})))).next((()=>n))}saveOverlays(t,e,n){const s=[];return n.forEach(((n,i)=>{const r=new vi(e,i);s.push(this.ue(t,r))})),ut.waitFor(s)}removeOverlaysForBatchId(t,e,n){const s=new Set;e.forEach((t=>s.add($r(t.getCollectionPath()))));const i=[];return s.forEach((e=>{const s=IDBKeyRange.bound([this.userId,e,n],[this.userId,e,n+1],!1,!0);i.push(tr(t).Y("collectionPathOverlayIndex",s))})),ut.waitFor(i)}getOverlaysForCollection(t,e,n){const s=Kn(),i=$r(e),r=IDBKeyRange.bound([this.userId,i,n],[this.userId,i,Number.POSITIVE_INFINITY],!0);return tr(t).W("collectionPathOverlayIndex",r).next((t=>{for(const e of t){const t=Ai(this.It,e);s.set(t.getKey(),t)}return s}))}getOverlaysForCollectionGroup(t,e,n,s){const i=Kn();let r;const o=IDBKeyRange.bound([this.userId,e,n],[this.userId,e,Number.POSITIVE_INFINITY],!0);return tr(t).Z({index:"collectionGroupOverlayIndex",range:o},((t,e,n)=>{const o=Ai(this.It,e);i.size()i))}ue(t,e){return tr(t).put(function(t,e,n){const[s,i,r]=Ni(e,n.mutation.key);return{userId:e,collectionPath:i,documentId:r,collectionGroup:n.mutation.key.getCollectionGroup(),largestBatchId:n.largestBatchId,overlayMutation:Cr(t.re,n.mutation)}}(this.It,this.userId,e))}}function tr(t){return yi(t,"documentOverlays")}class Vi{constructor(){}ce(t,e){this.ae(t,e),e.he()}ae(t,e){if("nullValue"in t)this.le(e,5);else if("booleanValue"in t)this.le(e,10),e.fe(t.booleanValue?1:0);else if("integerValue"in t)this.le(e,15),e.fe(Lt(t.integerValue));else if("doubleValue"in t){const n=Lt(t.doubleValue);isNaN(n)?this.le(e,13):(this.le(e,15),Gt(n)?e.fe(0):e.fe(n))}else if("timestampValue"in t){const n=t.timestampValue;this.le(e,20),"string"==typeof n?e.de(n):(e.de(`${n.seconds||""}`),e.fe(n.nanos||0))}else if("stringValue"in t)this._e(t.stringValue,e),this.we(e);else if("bytesValue"in t)this.le(e,30),e.me(Vt(t.bytesValue)),this.we(e);else if("referenceValue"in t)this.ge(t.referenceValue,e);else if("geoPointValue"in t){const n=t.geoPointValue;this.le(e,45),e.fe(n.latitude||0),e.fe(n.longitude||0)}else"mapValue"in t?ue(t)?this.le(e,Number.MAX_SAFE_INTEGER):(this.ye(t.mapValue,e),this.we(e)):"arrayValue"in t?(this.pe(t.arrayValue,e),this.we(e)):I()}_e(t,e){this.le(e,25),this.Ie(t,e)}Ie(t,e){e.de(t)}ye(t,e){const n=t.fields||{};this.le(e,55);for(const t of Object.keys(n))this._e(t,e),this.ae(n[t],e)}pe(t,e){const n=t.values||[];this.le(e,50);for(const t of n)this.ae(t,e)}ge(t,e){this.le(e,37),W.fromName(t).path.forEach((t=>{this.le(e,60),this.Ie(t,e)}))}le(t,e){t.fe(e)}we(t){t.fe(2)}}function Bi(t){if(0===t)return 8;let e=0;return t>>4==0&&(e+=4,t<<=4),t>>6==0&&(e+=2,t<<=2),t>>7==0&&(e+=1),e}function Fi(t){const e=64-function(t){let e=0;for(let n=0;n<8;++n){const s=Bi(255&t[n]);if(e+=s,8!==s)break}return e}(t);return Math.ceil(e/8)}Vi.Te=new Vi;class Ui{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Ee(t){const e=t[Symbol.iterator]();let n=e.next();for(;!n.done;)this.Ae(n.value),n=e.next();this.Re()}be(t){const e=t[Symbol.iterator]();let n=e.next();for(;!n.done;)this.Pe(n.value),n=e.next();this.ve()}Ve(t){for(const e of t){const t=e.charCodeAt(0);if(t<128)this.Ae(t);else if(t<2048)this.Ae(960|t>>>6),this.Ae(128|63&t);else if(e<"\ud800"||"\udbff">>12),this.Ae(128|63&t>>>6),this.Ae(128|63&t);else{const t=e.codePointAt(0);this.Ae(240|t>>>18),this.Ae(128|63&t>>>12),this.Ae(128|63&t>>>6),this.Ae(128|63&t)}}this.Re()}Se(t){for(const e of t){const t=e.charCodeAt(0);if(t<128)this.Pe(t);else if(t<2048)this.Pe(960|t>>>6),this.Pe(128|63&t);else if(e<"\ud800"||"\udbff">>12),this.Pe(128|63&t>>>6),this.Pe(128|63&t);else{const t=e.codePointAt(0);this.Pe(240|t>>>18),this.Pe(128|63&t>>>12),this.Pe(128|63&t>>>6),this.Pe(128|63&t)}}this.ve()}De(t){const e=this.Ce(t),n=Fi(e);this.xe(1+n),this.buffer[this.position++]=255&n;for(let t=e.length-n;t=this.Ge.length||!this.Je(this.Ge[i++],t))return!1}return!0}ze(t){for(const e of this.Qe)if(this.He(e,t))return!0;return!1}He(t,e){if(void 0===t||!t.field.isEqual(e.fieldPath))return!1;const n="array-contains"===t.op||"array-contains-any"===t.op;return 2===e.kind===n}Je(t,e){return!!t.field.isEqual(e.fieldPath)&&(0===e.kind&&"asc"===t.dir||1===e.kind&&"desc"===t.dir)}}class Yi{constructor(){this.Ye=new Wi}addToCollectionParentIndex(t,e){return this.Ye.add(e),ut.resolve()}getCollectionParents(t,e){return ut.resolve(this.Ye.getEntries(e))}addFieldIndex(t,e){return ut.resolve()}deleteFieldIndex(t,e){return ut.resolve()}getDocumentsMatchingTarget(t,e){return ut.resolve(null)}getIndexType(t,e){return ut.resolve(0)}getFieldIndexes(t,e){return ut.resolve([])}getNextCollectionGroupToUpdate(t){return ut.resolve(null)}getMinOffset(t,e){return ut.resolve(it.min())}getMinOffsetFromCollectionGroup(t,e){return ut.resolve(it.min())}updateCollectionGroup(t,e,n){return ut.resolve()}updateIndexEntries(t,e){return ut.resolve()}}class Wi{constructor(){this.index={}}add(t){const e=t.lastSegment(),n=t.popLast(),s=this.index[e]||new Ct(H.comparator),i=!s.has(n);return this.index[e]=s.add(n),i}has(t){const e=t.lastSegment(),n=t.popLast(),s=this.index[e];return s&&s.has(n)}getEntries(t){return(this.index[t]||new Ct(H.comparator)).toArray()}}const Qi=new Uint8Array(0);class Xi{constructor(t,e){this.user=t,this.databaseId=e,this.Xe=new Wi,this.Ze=new Fn((t=>we(t)),((t,e)=>ve(t,e))),this.uid=t.uid||""}addToCollectionParentIndex(t,e){if(!this.Xe.has(e)){const n=e.lastSegment(),s=e.popLast();t.addOnCommittedListener((()=>{this.Xe.add(e)}));const i={collectionId:n,parent:$r(s)};return Ji(t).put(i)}return ut.resolve()}getCollectionParents(t,e){const n=[],s=IDBKeyRange.bound([e,""],[$(e),""],!1,!0);return Ji(t).W(s).next((t=>{for(const s of t){if(s.collectionId!==e)break;n.push(Kr(s.parent))}return n}))}addFieldIndex(t,e){const n=to(t),s=function(t){return{indexId:t.indexId,collectionGroup:t.collectionGroup,fields:t.fields.map((t=>[t.fieldPath.canonicalString(),t.kind]))}}(e);delete s.indexId;const i=n.add(s);if(e.indexState){const n=eo(t);return i.next((t=>{n.put(Ri(t,this.user,e.indexState.sequenceNumber,e.indexState.offset))}))}return i.next()}deleteFieldIndex(t,e){const n=to(t),s=eo(t),i=Zi(t);return n.delete(e.indexId).next((()=>s.delete(IDBKeyRange.bound([e.indexId],[e.indexId+1],!1,!0)))).next((()=>i.delete(IDBKeyRange.bound([e.indexId],[e.indexId+1],!1,!0))))}getDocumentsMatchingTarget(t,e){const n=Zi(t);let s=!0;const i=new Map;return ut.forEach(this.tn(e),(e=>this.en(t,e).next((t=>{s&&(s=!!t),i.set(e,t)})))).next((()=>{if(s){let t=Xn();const s=[];return ut.forEach(i,((i,r)=>{var o;v("IndexedDbIndexManager",`Using index ${o=i,`id=${o.indexId}|cg=${o.collectionGroup}|f=${o.fields.map((t=>`${t.fieldPath}:${t.kind}`)).join(",")}`} to execute ${we(e)}`);const u=function(t,e){const n=X(e);if(void 0===n)return null;for(const e of xe(t,n.fieldPath))switch(e.op){case"array-contains-any":return e.value.arrayValue.values||[];case"array-contains":return[e.value]}return null}(r,i),c=function(t,e){const n=new Map;for(const s of J(e))for(const e of xe(t,s.fieldPath))switch(e.op){case"==":case"in":n.set(s.fieldPath.canonicalString(),e.value);break;case"not-in":case"!=":return n.set(s.fieldPath.canonicalString(),e.value),Array.from(n.values())}return null}(r,i),a=function(t,e){const n=[];let s=!0;for(const i of J(e)){const e=0===i.kind?Se(t,i.fieldPath,t.startAt):Ie(t,i.fieldPath,t.startAt);n.push(e.value),s&&(s=e.inclusive)}return new Pe(n,s)}(r,i),l=function(t,e){const n=[];let s=!0;for(const i of J(e)){const e=0===i.kind?Ie(t,i.fieldPath,t.endAt):Se(t,i.fieldPath,t.endAt);n.push(e.value),s&&(s=e.inclusive)}return new Pe(n,s)}(r,i),h=this.nn(i,r,a),f=this.nn(i,r,l),d=this.sn(i,r,c),m=this.rn(i.indexId,u,h,a.inclusive,f,l.inclusive,d);return ut.forEach(m,(i=>n.J(i,e.limit).next((e=>{e.forEach((e=>{const n=W.fromSegments(e.documentKey);t.has(n)||(t=t.add(n),s.push(n))}))}))))})).next((()=>s))}return ut.resolve(null)}))}tn(t){let e=this.Ze.get(t);return e||(e=[t],this.Ze.set(t,e),e)}rn(t,e,n,s,i,r,o){const u=(null!=e?e.length:1)*Math.max(n.length,i.length),c=u/(null!=e?e.length:1),a=[];for(let l=0;lthis.un(t,u,e,!0)));a.push(...this.createRange(h,f,d))}return a}un(t,e,n,s){const i=new Gi(t,W.empty(),e,n);return s?i:i.Ke()}cn(t,e,n,s){const i=new Gi(t,W.empty(),e,n);return s?i.Ke():i}en(t,e){const n=new Hi(e),s=null!=e.collectionGroup?e.collectionGroup:e.path.lastSegment();return this.getFieldIndexes(t,s).next((t=>{let e=null;for(const s of t)n.We(s)&&(!e||s.fields.length>e.fields.length)&&(e=s);return e}))}getIndexType(t,e){let n=2;return ut.forEach(this.tn(e),(e=>this.en(t,e).next((t=>{t?0!==n&&t.fields.lengthn))}an(t,e){const n=new zi;for(const s of J(t)){const t=e.data.field(s.fieldPath);if(null==t)return null;const i=n.qe(s.kind);Vi.Te.ce(t,i)}return n.$e()}on(t){const e=new zi;return Vi.Te.ce(t,e.qe(0)),e.$e()}hn(t,e){const n=new zi;return Vi.Te.ce(ne(this.databaseId,e),n.qe(function(t){const e=J(t);return 0===e.length?0:e[e.length-1].kind}(t))),n.$e()}sn(t,e,n){if(null===n)return[];let s=[];s.push(new zi);let i=0;for(const r of J(t)){const t=n[i++];for(const n of s)if(this.ln(e,r.fieldPath)&&ie(t))s=this.fn(s,r,t);else{const e=n.qe(r.kind);Vi.Te.ce(t,e)}}return this.dn(s)}nn(t,e,n){return this.sn(t,e,n.position)}dn(t){const e=[];for(let n=0;nt instanceof _e&&t.field.isEqual(e)&&("in"===t.op||"not-in"===t.op)))}getFieldIndexes(t,e){const n=to(t),s=eo(t);return(e?n.W("collectionGroupIndex",IDBKeyRange.bound(e,e)):n.W()).next((t=>{const e=[];return ut.forEach(t,(t=>s.get([t.indexId,this.uid]).next((n=>{e.push(function(t,e){const n=e?new tt(e.sequenceNumber,new it(Ei(e.readTime),new W(Kr(e.documentKey)),e.largestBatchId)):tt.empty(),s=t.fields.map((([t,e])=>new Z(Y.fromServerFormat(t),e)));return new Q(t.indexId,t.collectionGroup,s,n)}(t,n))})))).next((()=>e))}))}getNextCollectionGroupToUpdate(t){return this.getFieldIndexes(t).next((t=>0===t.length?null:(t.sort(((t,e)=>{const n=t.indexState.sequenceNumber-e.indexState.sequenceNumber;return 0!==n?n:F(t.collectionGroup,e.collectionGroup)})),t[0].collectionGroup)))}updateCollectionGroup(t,e,n){const s=to(t),i=eo(t);return this._n(t).next((t=>s.W("collectionGroupIndex",IDBKeyRange.bound(e,e)).next((e=>ut.forEach(e,(e=>i.put(Ri(e.indexId,this.user,t,n))))))))}updateIndexEntries(t,e){const n=new Map;return ut.forEach(e,((e,s)=>{const i=n.get(e.collectionGroup);return(i?ut.resolve(i):this.getFieldIndexes(t,e.collectionGroup)).next((i=>(n.set(e.collectionGroup,i),ut.forEach(i,(n=>this.wn(t,e,n).next((e=>{const i=this.mn(s,n);return e.isEqual(i)?ut.resolve():this.gn(t,s,n,e,i)})))))))}))}yn(t,e,n,s){return Zi(t).put({indexId:s.indexId,uid:this.uid,arrayValue:s.arrayValue,directionalValue:s.directionalValue,orderedDocumentKey:this.hn(n,e.key),documentKey:e.key.path.toArray()})}pn(t,e,n,s){return Zi(t).delete([s.indexId,this.uid,s.arrayValue,s.directionalValue,this.hn(n,e.key),e.key.path.toArray()])}wn(t,e,n){const s=Zi(t);let i=new Ct(Ki);return s.Z({index:"documentKeyIndex",range:IDBKeyRange.only([n.indexId,this.uid,this.hn(n,e)])},((t,s)=>{i=i.add(new Gi(n.indexId,e,s.arrayValue,s.directionalValue))})).next((()=>i))}mn(t,e){let n=new Ct(Ki);const s=this.an(e,t);if(null==s)return n;const i=X(e);if(null!=i){const r=t.data.field(i.fieldPath);if(ie(r))for(const i of r.arrayValue.values||[])n=n.add(new Gi(e.indexId,t.key,this.on(i),s))}else n=n.add(new Gi(e.indexId,t.key,Qi,s));return n}gn(t,e,n,s,i){v("IndexedDbIndexManager","Updating index entries for document '%s'",e.key);const r=[];return function(t,e,n,s,i){const r=t.getIterator(),o=e.getIterator();let u=At(r),c=At(o);for(;u||c;){let t=!1,e=!1;if(u&&c){const s=n(u,c);s<0?e=!0:s>0&&(t=!0)}else null!=u?e=!0:t=!0;t?(s(c),c=At(o)):e?(i(u),u=At(r)):(u=At(r),c=At(o))}}(s,i,Ki,(s=>{r.push(this.yn(t,e,n,s))}),(s=>{r.push(this.pn(t,e,n,s))})),ut.waitFor(r)}_n(t){let e=1;return eo(t).Z({index:"sequenceNumberIndex",reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},((t,n,s)=>{s.done(),e=n.sequenceNumber+1})).next((()=>e))}createRange(t,e,n){n=n.sort(((t,e)=>Ki(t,e))).filter(((t,e,n)=>!e||0!==Ki(t,n[e-1])));const s=[];s.push(t);for(const i of n){const n=Ki(i,t),r=Ki(i,e);if(0===n)s[0]=t.Ke();else if(n>0&&r<0)s.push(i),s.push(i.Ke());else if(r>0)break}s.push(e);const i=[];for(let t=0;tthis.en(t,e).next((t=>t||I())))).next(no)}}function Ji(t){return yi(t,"collectionParents")}function Zi(t){return yi(t,"indexEntries")}function to(t){return yi(t,"indexConfiguration")}function eo(t){return yi(t,"indexState")}function no(t){_(0!==t.length);let e=t[0].indexState.offset,n=e.largestBatchId;for(let s=1;s(u++,n.delete())));r.push(c.next((()=>{_(1===u)})));const a=[];for(const t of n.mutations){const s=Wr(e,t.key.path,n.batchId);r.push(i.delete(s)),a.push(t.key)}return ut.waitFor(r).next((()=>a))}function so(t){if(!t)return 0;let e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw I();e=t.noDocument}return JSON.stringify(e).length}io.DEFAULT_COLLECTION_PERCENTILE=10,io.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,io.DEFAULT=new io(41943040,io.DEFAULT_COLLECTION_PERCENTILE,io.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),io.DISABLED=new io(-1,0,0);class br{constructor(t,e,n,s){this.userId=t,this.It=e,this.indexManager=n,this.referenceDelegate=s,this.In={}}static oe(t,e,n,s){_(""!==t.uid);const i=t.isAuthenticated()?t.uid:"";return new br(i,e,n,s)}checkEmpty(t){let e=!0;const n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return co(t).Z({index:"userMutationsIndex",range:n},((t,n,s)=>{e=!1,s.done()})).next((()=>e))}addMutationBatch(t,e,n,s){const i=uo(t),r=co(t);return r.add({}).next((o=>{_("number"==typeof o);const u=new bi(o,e,n,s),c=function(t,e,n){const s=n.baseMutations.map((e=>Cr(t.re,e))),i=n.mutations.map((e=>Cr(t.re,e)));return{userId:e,batchId:n.batchId,localWriteTimeMs:n.localWriteTime.toMillis(),baseMutations:s,mutations:i}}(this.It,this.userId,u),a=[];let l=new Ct(((t,e)=>F(t.canonicalString(),e.canonicalString())));for(const t of s){const e=Wr(this.userId,t.key.path,o);l=l.add(t.key.path.popLast()),a.push(r.put(c)),a.push(i.put(e,li))}return l.forEach((e=>{a.push(this.indexManager.addToCollectionParentIndex(t,e))})),t.addOnCommittedListener((()=>{this.In[o]=u.keys()})),ut.waitFor(a).next((()=>u))}))}lookupMutationBatch(t,e){return co(t).get(e).next((t=>t?(_(t.userId===this.userId),Oi(this.It,t)):null))}Tn(t,e){return this.In[e]?ut.resolve(this.In[e]):this.lookupMutationBatch(t,e).next((t=>{if(t){const n=t.keys();return this.In[e]=n,n}return null}))}getNextMutationBatchAfterBatchId(t,e){const n=e+1,s=IDBKeyRange.lowerBound([this.userId,n]);let i=null;return co(t).Z({index:"userMutationsIndex",range:s},((t,e,s)=>{e.userId===this.userId&&(_(e.batchId>=n),i=Oi(this.It,e)),s.done()})).next((()=>i))}getHighestUnacknowledgedBatchId(t){const e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let n=-1;return co(t).Z({index:"userMutationsIndex",range:e,reverse:!0},((t,e,s)=>{n=e.batchId,s.done()})).next((()=>n))}getAllMutationBatches(t){const e=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return co(t).W("userMutationsIndex",e).next((t=>t.map((t=>Oi(this.It,t)))))}getAllMutationBatchesAffectingDocumentKey(t,e){const n=Yr(this.userId,e.path),s=IDBKeyRange.lowerBound(n),i=[];return uo(t).Z({range:s},((n,s,r)=>{const[o,u,c]=n,a=Kr(u);if(o===this.userId&&e.path.isEqual(a))return co(t).get(c).next((t=>{if(!t)throw I();_(t.userId===this.userId),i.push(Oi(this.It,t))}));r.done()})).next((()=>i))}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new Ct(F);const s=[];return e.forEach((e=>{const i=Yr(this.userId,e.path),r=IDBKeyRange.lowerBound(i),o=uo(t).Z({range:r},((t,s,i)=>{const[r,o,u]=t,c=Kr(o);r===this.userId&&e.path.isEqual(c)?n=n.add(u):i.done()}));s.push(o)})),ut.waitFor(s).next((()=>this.En(t,n)))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,s=n.length+1,i=Yr(this.userId,n),r=IDBKeyRange.lowerBound(i);let o=new Ct(F);return uo(t).Z({range:r},((t,e,i)=>{const[r,u,c]=t,a=Kr(u);r===this.userId&&n.isPrefixOf(a)?a.length===s&&(o=o.add(c)):i.done()})).next((()=>this.En(t,o)))}En(t,e){const n=[],s=[];return e.forEach((e=>{s.push(co(t).get(e).next((t=>{if(null===t)throw I();_(t.userId===this.userId),n.push(Oi(this.It,t))})))})),ut.waitFor(s).next((()=>n))}removeMutationBatch(t,e){return oo(t.ie,this.userId,e).next((n=>(t.addOnCommittedListener((()=>{this.An(e.batchId)})),ut.forEach(n,(e=>this.referenceDelegate.markPotentiallyOrphaned(t,e))))))}An(t){delete this.In[t]}performConsistencyCheck(t){return this.checkEmpty(t).next((e=>{if(!e)return ut.resolve();const n=IDBKeyRange.lowerBound([this.userId]),s=[];return uo(t).Z({range:n},((t,e,n)=>{if(t[0]===this.userId){const e=Kr(t[1]);s.push(e)}else n.done()})).next((()=>{_(0===s.length)}))}))}containsKey(t,e){return ao(t,this.userId,e)}Rn(t){return lo(t).get(this.userId).next((t=>t||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""}))}}function ao(t,e,n){const s=Yr(e,n.path),i=s[1],r=IDBKeyRange.lowerBound(s);let o=!1;return uo(t).Z({range:r,X:!0},((t,n,s)=>{const[r,u,c]=t;r===e&&u===i&&(o=!0),s.done()})).next((()=>o))}function co(t){return yi(t,"mutations")}function uo(t){return yi(t,"documentMutations")}function lo(t){return yi(t,"mutationQueues")}class ho{constructor(t){this.bn=t}next(){return this.bn+=2,this.bn}static Pn(){return new ho(0)}static vn(){return new ho(-1)}}class fo{constructor(t,e){this.referenceDelegate=t,this.It=e}allocateTargetId(t){return this.Vn(t).next((e=>{const n=new ho(e.highestTargetId);return e.highestTargetId=n.next(),this.Sn(t,e).next((()=>e.highestTargetId))}))}getLastRemoteSnapshotVersion(t){return this.Vn(t).next((t=>G.fromTimestamp(new z(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))))}getHighestSequenceNumber(t){return this.Vn(t).next((t=>t.highestListenSequenceNumber))}setTargetsMetadata(t,e,n){return this.Vn(t).next((s=>(s.highestListenSequenceNumber=e,n&&(s.lastRemoteSnapshotVersion=n.toTimestamp()),e>s.highestListenSequenceNumber&&(s.highestListenSequenceNumber=e),this.Sn(t,s))))}addTargetData(t,e){return this.Dn(t,e).next((()=>this.Vn(t).next((n=>(n.targetCount+=1,this.Cn(e,n),this.Sn(t,n))))))}updateTargetData(t,e){return this.Dn(t,e)}removeTargetData(t,e){return this.removeMatchingKeysForTargetId(t,e.targetId).next((()=>po(t).delete(e.targetId))).next((()=>this.Vn(t))).next((e=>(_(e.targetCount>0),e.targetCount-=1,this.Sn(t,e))))}removeTargets(t,e,n){let s=0;const i=[];return po(t).Z(((r,o)=>{const u=ki(o);u.sequenceNumber<=e&&null===n.get(u.targetId)&&(s++,i.push(this.removeTargetData(t,u)))})).next((()=>ut.waitFor(i))).next((()=>s))}forEachTarget(t,e){return po(t).Z(((t,n)=>{const s=ki(n);e(s)}))}Vn(t){return mo(t).get("targetGlobalKey").next((t=>(_(null!==t),t)))}Sn(t,e){return mo(t).put("targetGlobalKey",e)}Dn(t,e){return po(t).put(Ci(this.It,e))}Cn(t,e){let n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n}getTargetCount(t){return this.Vn(t).next((t=>t.targetCount))}getTargetData(t,e){const n=we(e),s=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]);let i=null;return po(t).Z({range:s,index:"queryTargetsIndex"},((t,n,s)=>{const r=ki(n);ve(e,r.target)&&(i=r,s.done())})).next((()=>i))}addMatchingKeys(t,e,n){const s=[],i=go(t);return e.forEach((e=>{const r=$r(e.path);s.push(i.put({targetId:n,path:r})),s.push(this.referenceDelegate.addReference(t,n,e))})),ut.waitFor(s)}removeMatchingKeys(t,e,n){const s=go(t);return ut.forEach(e,(e=>{const i=$r(e.path);return ut.waitFor([s.delete([n,i]),this.referenceDelegate.removeReference(t,n,e)])}))}removeMatchingKeysForTargetId(t,e){const n=go(t),s=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(s)}getMatchingKeysForTargetId(t,e){const n=IDBKeyRange.bound([e],[e+1],!1,!0),s=go(t);let i=Xn();return s.Z({range:n,X:!0},((t,e,n)=>{const s=Kr(t[1]),r=new W(s);i=i.add(r)})).next((()=>i))}containsKey(t,e){const n=$r(e.path),s=IDBKeyRange.bound([n],[$(n)],!1,!0);let i=0;return go(t).Z({index:"documentTargetsIndex",X:!0,range:s},(([t,e],n,s)=>{0!==t&&(i++,s.done())})).next((()=>i>0))}se(t,e){return po(t).get(e).next((t=>t?ki(t):null))}}function po(t){return yi(t,"targets")}function mo(t){return yi(t,"targetGlobal")}function go(t){return yi(t,"targetDocuments")}function yo([t,e],[n,s]){const i=F(t,n);return 0===i?F(e,s):i}class bo{constructor(t){this.xn=t,this.buffer=new Ct(yo),this.Nn=0}kn(){return++this.Nn}Mn(t){const e=[t,this.kn()];if(this.buffer.size{this.On=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){mt(t)?v("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",t):await ct(t)}await this.Fn(3e5)}))}}class vo{constructor(t,e){this.$n=t,this.params=e}calculateTargetCount(t,e){return this.$n.Bn(t).next((t=>Math.floor(e/100*t)))}nthSequenceNumber(t,e){if(0===e)return ut.resolve(xt.at);const n=new bo(e);return this.$n.forEachTarget(t,(t=>n.Mn(t.sequenceNumber))).next((()=>this.$n.Ln(t,(t=>n.Mn(t))))).next((()=>n.maxValue))}removeTargets(t,e,n){return this.$n.removeTargets(t,e,n)}removeOrphanedDocuments(t,e){return this.$n.removeOrphanedDocuments(t,e)}collect(t,e){return-1===this.params.cacheSizeCollectionThreshold?(v("LruGarbageCollector","Garbage collection skipped; disabled"),ut.resolve(ro)):this.getCacheSize(t).next((n=>n(e>this.params.maximumSequenceNumbersToCollect?(v("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${e}`),s=this.params.maximumSequenceNumbersToCollect):s=e,r=Date.now(),this.nthSequenceNumber(t,s)))).next((s=>(n=s,o=Date.now(),this.removeTargets(t,n,e)))).next((e=>(i=e,l=Date.now(),this.removeOrphanedDocuments(t,n)))).next((t=>(a=Date.now(),y()<=c.a.DEBUG&&v("LruGarbageCollector",`LRU Garbage Collection\n\tCounted targets in ${r-h}ms\n\tDetermined least recently used ${s} in `+(o-r)+"ms\n"+`\tRemoved ${i} targets in `+(l-o)+"ms\n"+`\tRemoved ${t} documents in `+(a-l)+"ms\n"+`Total Duration: ${a-h}ms`),ut.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:i,documentsRemoved:t}))))}}class To{constructor(t,e){this.db=t,this.garbageCollector=function(t,e){return new vo(t,e)}(this,e)}Bn(t){const e=this.qn(t);return this.db.getTargetCache().getTargetCount(t).next((t=>e.next((e=>t+e))))}qn(t){let e=0;return this.Ln(t,(t=>{e++})).next((()=>e))}forEachTarget(t,e){return this.db.getTargetCache().forEachTarget(t,e)}Ln(t,e){return this.Kn(t,((t,n)=>e(n)))}addReference(t,e,n){return xo(t,n)}removeReference(t,e,n){return xo(t,n)}removeTargets(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)}markPotentiallyOrphaned(t,e){return xo(t,e)}Gn(t,e){return function(t,e){let n=!1;return lo(t).tt((s=>ao(t,s,e).next((t=>(t&&(n=!0),ut.resolve(!t)))))).next((()=>n))}(t,e)}removeOrphanedDocuments(t,e){const n=this.db.getRemoteDocumentCache().newChangeBuffer(),s=[];let i=0;return this.Kn(t,((r,o)=>{if(o<=e){const e=this.Gn(t,r).next((e=>{if(!e)return i++,n.getEntry(t,r).next((()=>(n.removeEntry(r,G.min()),go(t).delete([0,$r(r.path)]))))}));s.push(e)}})).next((()=>ut.waitFor(s))).next((()=>n.apply(t))).next((()=>i))}removeTarget(t,e){const n=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,n)}updateLimboDocument(t,e){return xo(t,e)}Kn(t,e){const n=go(t);let s,i=xt.at;return n.Z({index:"documentTargetsIndex"},(([t,n],{path:r,sequenceNumber:o})=>{0===t?(i!==xt.at&&e(new W(Kr(s)),i),i=o,s=r):i=xt.at})).next((()=>{i!==xt.at&&e(new W(Kr(s)),i)}))}getCacheSize(t){return this.db.getRemoteDocumentCache().getSize(t)}}function xo(t,e){return go(t).put(function(t,e){return{targetId:0,path:$r(t.path),sequenceNumber:e}}(e,t.currentSequenceNumber))}class So{constructor(){this.changes=new Fn((t=>t.toString()),((t,e)=>t.isEqual(e))),this.changesApplied=!1}addEntry(t){this.assertNotApplied(),this.changes.set(t.key,t)}removeEntry(t,e){this.assertNotApplied(),this.changes.set(t,ge.newInvalidDocument(t).setReadTime(e))}getEntry(t,e){this.assertNotApplied();const n=this.changes.get(e);return void 0!==n?ut.resolve(n):this.getFromCache(t,e)}getEntries(t,e){return this.getAllFromCache(t,e)}apply(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)}assertNotApplied(){}}class Io{constructor(t){this.It=t}setIndexManager(t){this.indexManager=t}addEntry(t,e,n){return ko(t).put(n)}removeEntry(t,e,n){return ko(t).delete(function(t,e){const n=t.path.toArray();return[n.slice(0,n.length-2),n[n.length-2],Ii(e),n[n.length-1]]}(e,n))}updateMetadata(t,e){return this.getMetadata(t).next((n=>(n.byteSize+=e,this.Qn(t,n))))}getEntry(t,e){let n=ge.newInvalidDocument(e);return ko(t).Z({index:"documentKeyIndex",range:IDBKeyRange.only(Co(e))},((t,s)=>{n=this.jn(e,s)})).next((()=>n))}Wn(t,e){let n={size:0,document:ge.newInvalidDocument(e)};return ko(t).Z({index:"documentKeyIndex",range:IDBKeyRange.only(Co(e))},((t,s)=>{n={document:this.jn(e,s),size:so(s)}})).next((()=>n))}getEntries(t,e){let n=qn();return this.zn(t,e,((t,e)=>{const s=this.jn(t,e);n=n.insert(t,s)})).next((()=>n))}Hn(t,e){let n=qn(),s=new Et(W.comparator);return this.zn(t,e,((t,e)=>{const i=this.jn(t,e);n=n.insert(t,i),s=s.insert(t,so(e))})).next((()=>({documents:n,Jn:s})))}zn(t,e,n){if(e.isEmpty())return ut.resolve();let s=new Ct(Ao);e.forEach((t=>s=s.add(t)));const i=IDBKeyRange.bound(Co(s.first()),Co(s.last())),r=s.getIterator();let o=r.getNext();return ko(t).Z({index:"documentKeyIndex",range:i},((t,e,s)=>{const i=W.fromSegments([...e.prefixPath,e.collectionGroup,e.documentId]);for(;o&&Ao(o,i)<0;)n(o,null),o=r.getNext();o&&o.isEqual(i)&&(n(o,e),o=r.hasNext()?r.getNext():null),o?s.j(Co(o)):s.done()})).next((()=>{for(;o;)n(o,null),o=r.hasNext()?r.getNext():null}))}getAllFromCollection(t,e,n){const s=[e.popLast().toArray(),e.lastSegment(),Ii(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],i=[e.popLast().toArray(),e.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return ko(t).W(IDBKeyRange.bound(s,i,!0)).next((t=>{let e=qn();for(const n of t){const t=this.jn(W.fromSegments(n.prefixPath.concat(n.collectionGroup,n.documentId)),n);e=e.insert(t.key,t)}return e}))}getAllFromCollectionGroup(t,e,n,s){let i=qn();const r=Do(e,n),o=Do(e,it.max());return ko(t).Z({index:"collectionGroupIndex",range:IDBKeyRange.bound(r,o,!0)},((t,e,n)=>{const r=this.jn(W.fromSegments(e.prefixPath.concat(e.collectionGroup,e.documentId)),e);i=i.insert(r.key,r),i.size===s&&n.done()})).next((()=>i))}newChangeBuffer(t){return new Eo(this,!!t&&t.trackRemovals)}getSize(t){return this.getMetadata(t).next((t=>t.byteSize))}getMetadata(t){return Oo(t).get("remoteDocumentGlobalKey").next((t=>(_(!!t),t)))}Qn(t,e){return Oo(t).put("remoteDocumentGlobalKey",e)}jn(t,e){if(e){const t=function(t,e){let n;if(e.document)n=kr(t.re,e.document,!!e.hasCommittedMutations);else if(e.noDocument){const t=W.fromSegments(e.noDocument.path),s=Ei(e.noDocument.readTime);n=ge.newNoDocument(t,s),e.hasCommittedMutations&&n.setHasCommittedMutations()}else{if(!e.unknownDocument)return I();{const t=W.fromSegments(e.unknownDocument.path),s=Ei(e.unknownDocument.version);n=ge.newUnknownDocument(t,s)}}return e.readTime&&n.setReadTime(function(t){const e=new z(t[0],t[1]);return G.fromTimestamp(e)}(e.readTime)),n}(this.It,e);if(!t.isNoDocument()||!t.version.isEqual(G.min()))return t}return ge.newInvalidDocument(t)}}function _o(t){return new Io(t)}class Eo extends So{constructor(t,e){super(),this.Yn=t,this.trackRemovals=e,this.Xn=new Fn((t=>t.toString()),((t,e)=>t.isEqual(e)))}applyChanges(t){const e=[];let n=0,s=new Ct(((t,e)=>F(t.canonicalString(),e.canonicalString())));return this.changes.forEach(((i,r)=>{const o=this.Xn.get(i);if(e.push(this.Yn.removeEntry(t,i,o.readTime)),r.isValidDocument()){const u=Si(this.Yn.It,r);s=s.add(i.path.popLast());const c=so(u);n+=c-o.size,e.push(this.Yn.addEntry(t,i,u))}else if(n-=o.size,this.trackRemovals){const n=Si(this.Yn.It,r.convertToNoDocument(G.min()));e.push(this.Yn.addEntry(t,i,n))}})),s.forEach((n=>{e.push(this.Yn.indexManager.addToCollectionParentIndex(t,n))})),e.push(this.Yn.updateMetadata(t,n)),ut.waitFor(e)}getFromCache(t,e){return this.Yn.Wn(t,e).next((t=>(this.Xn.set(e,{size:t.size,readTime:t.document.readTime}),t.document)))}getAllFromCache(t,e){return this.Yn.Hn(t,e).next((({documents:t,Jn:e})=>(e.forEach(((e,n)=>{this.Xn.set(e,{size:n,readTime:t.get(e).readTime})})),t)))}}function Oo(t){return yi(t,"remoteDocumentGlobal")}function ko(t){return yi(t,"remoteDocumentsV14")}function Co(t){const e=t.path.toArray();return[e.slice(0,e.length-2),e[e.length-2],e[e.length-1]]}function Do(t,e){const n=e.documentKey.path.toArray();return[t,Ii(e.readTime),n.slice(0,n.length-2),n.length>0?n[n.length-1]:""]}function Ao(t,e){const n=t.path.toArray(),s=e.path.toArray();let i=0;for(let t=0;t(n=s,this.getBaseDocument(t,e,n)))).next((t=>(null!==n&&_n(n.mutation,t,Nt.empty(),z.now()),t)))}getDocuments(t,e){return this.remoteDocumentCache.getEntries(t,e).next((e=>this.getLocalViewOfDocuments(t,e,Xn()).next((()=>e))))}getLocalViewOfDocuments(t,e,n=Xn()){const s=Kn();return this.populateOverlays(t,s,e).next((()=>this.computeViews(t,e,s,n).next((t=>{let e=zn();return t.forEach(((t,n)=>{e=e.insert(t,n.overlayedDocument)})),e}))))}getOverlayedDocuments(t,e){const n=Kn();return this.populateOverlays(t,n,e).next((()=>this.computeViews(t,e,n,Xn())))}populateOverlays(t,e,n){const s=[];return n.forEach((t=>{e.has(t)||s.push(t)})),this.documentOverlayCache.getOverlays(t,s).next((t=>{t.forEach(((t,n)=>{e.set(t,n)}))}))}computeViews(t,e,n,s){let i=qn();const r=Yn(),o=Yn();return e.forEach(((t,e)=>{const o=n.get(e.key);s.has(e.key)&&(void 0===o||o.mutation instanceof Cn)?i=i.insert(e.key,e):void 0!==o&&(r.set(e.key,o.mutation.getFieldMask()),_n(o.mutation,e,o.mutation.getFieldMask(),z.now()))})),this.recalculateAndSaveOverlays(t,i).next((t=>(t.forEach(((t,e)=>r.set(t,e))),e.forEach(((t,e)=>{var n;return o.set(t,new No(e,null!==(n=r.get(t))&&void 0!==n?n:null))})),o)))}recalculateAndSaveOverlays(t,e){const n=Yn();let s=new Et(((t,e)=>t-e)),i=Xn();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(t,e).next((t=>{for(const i of t)i.keys().forEach((t=>{const r=e.get(t);if(null===r)return;let o=n.get(t)||Nt.empty();o=i.applyToLocalView(r,o),n.set(t,o);const u=(s.get(i.batchId)||Xn()).add(t);s=s.insert(i.batchId,u)}))})).next((()=>{const r=[],o=s.getReverseIterator();for(;o.hasNext();){const s=o.getNext(),u=s.key,c=s.value,a=Hn();c.forEach((t=>{if(!i.has(t)){const s=Sn(e.get(t),n.get(t));null!==s&&a.set(t,s),i=i.add(t)}})),r.push(this.documentOverlayCache.saveOverlays(t,u,a))}return ut.waitFor(r)})).next((()=>n))}recalculateAndSaveOverlaysForDocumentKeys(t,e){return this.remoteDocumentCache.getEntries(t,e).next((e=>this.recalculateAndSaveOverlays(t,e)))}getDocumentsMatchingQuery(t,e,n){return function(t){return W.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}(e)?this.getDocumentsMatchingDocumentQuery(t,e.path):Ge(e)?this.getDocumentsMatchingCollectionGroupQuery(t,e,n):this.getDocumentsMatchingCollectionQuery(t,e,n)}getNextDocuments(t,e,n,s){return this.remoteDocumentCache.getAllFromCollectionGroup(t,e,n,s).next((i=>{const r=s-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(t,e,n.largestBatchId,s-i.size):ut.resolve(Kn());let o=-1,u=i;return r.next((e=>ut.forEach(e,((e,n)=>(o{u=u.insert(e,t)}))))).next((()=>this.populateOverlays(t,e,i))).next((()=>this.computeViews(t,u,e,Xn()))).next((t=>({batchId:o,changes:Gn(t)})))))}))}getDocumentsMatchingDocumentQuery(t,e){return this.getDocument(t,new W(e)).next((t=>{let e=zn();return t.isFoundDocument()&&(e=e.insert(t.key,t)),e}))}getDocumentsMatchingCollectionGroupQuery(t,e,n){const s=e.collectionGroup;let i=zn();return this.indexManager.getCollectionParents(t,s).next((r=>ut.forEach(r,(r=>{const o=function(t,e){return new Be(e,null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(e,r.child(s));return this.getDocumentsMatchingCollectionQuery(t,o,n).next((t=>{t.forEach(((t,e)=>{i=i.insert(t,e)}))}))})).next((()=>i))))}getDocumentsMatchingCollectionQuery(t,e,n){let s;return this.remoteDocumentCache.getAllFromCollection(t,e.path,n).next((i=>(s=i,this.documentOverlayCache.getOverlaysForCollection(t,e.path,n.largestBatchId)))).next((t=>{t.forEach(((t,e)=>{const n=e.getKey();null===s.get(n)&&(s=s.insert(n,ge.newInvalidDocument(n)))}));let n=zn();return s.forEach(((s,i)=>{const r=t.get(s);void 0!==r&&_n(r.mutation,i,Nt.empty(),z.now()),Je(e,i)&&(n=n.insert(s,i))})),n}))}getBaseDocument(t,e,n){return null===n||1===n.mutation.type?this.remoteDocumentCache.getEntry(t,e):ut.resolve(ge.newInvalidDocument(e))}}class Po{constructor(t){this.It=t,this.Zn=new Map,this.ts=new Map}getBundleMetadata(t,e){return ut.resolve(this.Zn.get(e))}saveBundleMetadata(t,e){var n;return this.Zn.set(e.id,{id:(n=e).id,version:n.version,createTime:yr(n.createTime)}),ut.resolve()}getNamedQuery(t,e){return ut.resolve(this.ts.get(e))}saveNamedQuery(t,e){return this.ts.set(e.name,function(t){return{name:t.name,query:Di(t.bundledQuery),readTime:yr(t.readTime)}}(e)),ut.resolve()}}class jo{constructor(){this.overlays=new Et(W.comparator),this.es=new Map}getOverlay(t,e){return ut.resolve(this.overlays.get(e))}getOverlays(t,e){const n=Kn();return ut.forEach(e,(e=>this.getOverlay(t,e).next((t=>{null!==t&&n.set(e,t)})))).next((()=>n))}saveOverlays(t,e,n){return n.forEach(((n,s)=>{this.ue(t,e,s)})),ut.resolve()}removeOverlaysForBatchId(t,e,n){const s=this.es.get(n);return void 0!==s&&(s.forEach((t=>this.overlays=this.overlays.remove(t))),this.es.delete(n)),ut.resolve()}getOverlaysForCollection(t,e,n){const s=Kn(),i=e.length+1,r=new W(e.child("")),o=this.overlays.getIteratorFrom(r);for(;o.hasNext();){const t=o.getNext().value,r=t.getKey();if(!e.isPrefixOf(r.path))break;r.path.length===i&&t.largestBatchId>n&&s.set(t.getKey(),t)}return ut.resolve(s)}getOverlaysForCollectionGroup(t,e,n,s){let i=new Et(((t,e)=>t-e));const r=this.overlays.getIterator();for(;r.hasNext();){const t=r.getNext().value;if(t.getKey().getCollectionGroup()===e&&t.largestBatchId>n){let e=i.get(t.largestBatchId);null===e&&(e=Kn(),i=i.insert(t.largestBatchId,e)),e.set(t.getKey(),t)}}const o=Kn(),u=i.getIterator();for(;u.hasNext()&&(u.getNext().value.forEach(((t,e)=>o.set(t,e))),!(o.size()>=s)););return ut.resolve(o)}ue(t,e,n){const s=this.overlays.get(n.key);if(null!==s){const t=this.es.get(s.largestBatchId).delete(n.key);this.es.set(s.largestBatchId,t)}this.overlays=this.overlays.insert(n.key,new vi(e,n));let i=this.es.get(e);void 0===i&&(i=Xn(),this.es.set(e,i)),this.es.set(e,i.add(n.key))}}class Mo{constructor(){this.ns=new Ct(Lo.ss),this.rs=new Ct(Lo.os)}isEmpty(){return this.ns.isEmpty()}addReference(t,e){const n=new Lo(t,e);this.ns=this.ns.add(n),this.rs=this.rs.add(n)}us(t,e){t.forEach((t=>this.addReference(t,e)))}removeReference(t,e){this.cs(new Lo(t,e))}hs(t,e){t.forEach((t=>this.removeReference(t,e)))}ls(t){const e=new W(new H([])),n=new Lo(e,t),s=new Lo(e,t+1),i=[];return this.rs.forEachInRange([n,s],(t=>{this.cs(t),i.push(t.key)})),i}fs(){this.ns.forEach((t=>this.cs(t)))}cs(t){this.ns=this.ns.delete(t),this.rs=this.rs.delete(t)}ds(t){const e=new W(new H([])),n=new Lo(e,t),s=new Lo(e,t+1);let i=Xn();return this.rs.forEachInRange([n,s],(t=>{i=i.add(t.key)})),i}containsKey(t){const e=new Lo(t,0),n=this.ns.firstAfterOrEqual(e);return null!==n&&t.isEqual(n.key)}}class Lo{constructor(t,e){this.key=t,this._s=e}static ss(t,e){return W.comparator(t.key,e.key)||F(t._s,e._s)}static os(t,e){return F(t._s,e._s)||W.comparator(t.key,e.key)}}class Vo{constructor(t,e){this.indexManager=t,this.referenceDelegate=e,this.mutationQueue=[],this.ws=1,this.gs=new Ct(Lo.ss)}checkEmpty(t){return ut.resolve(0===this.mutationQueue.length)}addMutationBatch(t,e,n,s){const i=this.ws;this.ws++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const r=new bi(i,e,n,s);this.mutationQueue.push(r);for(const e of s)this.gs=this.gs.add(new Lo(e.key,i)),this.indexManager.addToCollectionParentIndex(t,e.key.path.popLast());return ut.resolve(r)}lookupMutationBatch(t,e){return ut.resolve(this.ys(e))}getNextMutationBatchAfterBatchId(t,e){const n=e+1,s=this.ps(n),i=s<0?0:s;return ut.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return ut.resolve(0===this.mutationQueue.length?-1:this.ws-1)}getAllMutationBatches(t){return ut.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(t,e){const n=new Lo(e,0),s=new Lo(e,Number.POSITIVE_INFINITY),i=[];return this.gs.forEachInRange([n,s],(t=>{const e=this.ys(t._s);i.push(e)})),ut.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new Ct(F);return e.forEach((t=>{const e=new Lo(t,0),s=new Lo(t,Number.POSITIVE_INFINITY);this.gs.forEachInRange([e,s],(t=>{n=n.add(t._s)}))})),ut.resolve(this.Is(n))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,s=n.length+1;let i=n;W.isDocumentKey(i)||(i=i.child(""));const r=new Lo(new W(i),0);let o=new Ct(F);return this.gs.forEachWhile((t=>{const e=t.key.path;return!!n.isPrefixOf(e)&&(e.length===s&&(o=o.add(t._s)),!0)}),r),ut.resolve(this.Is(o))}Is(t){const e=[];return t.forEach((t=>{const n=this.ys(t);null!==n&&e.push(n)})),e}removeMutationBatch(t,e){_(0===this.Ts(e.batchId,"removed")),this.mutationQueue.shift();let n=this.gs;return ut.forEach(e.mutations,(s=>{const i=new Lo(s.key,e.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(t,s.key)})).next((()=>{this.gs=n}))}An(t){}containsKey(t,e){const n=new Lo(e,0),s=this.gs.firstAfterOrEqual(n);return ut.resolve(e.isEqual(s&&s.key))}performConsistencyCheck(t){return this.mutationQueue.length,ut.resolve()}Ts(t,e){return this.ps(t)}ps(t){return 0===this.mutationQueue.length?0:t-this.mutationQueue[0].batchId}ys(t){const e=this.ps(t);return e<0||e>=this.mutationQueue.length?null:this.mutationQueue[e]}}class Bo{constructor(t){this.Es=t,this.docs=new Et(W.comparator),this.size=0}setIndexManager(t){this.indexManager=t}addEntry(t,e){const n=e.key,s=this.docs.get(n),i=s?s.size:0,r=this.Es(e);return this.docs=this.docs.insert(n,{document:e.mutableCopy(),size:r}),this.size+=r-i,this.indexManager.addToCollectionParentIndex(t,n.path.popLast())}removeEntry(t){const e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)}getEntry(t,e){const n=this.docs.get(e);return ut.resolve(n?n.document.mutableCopy():ge.newInvalidDocument(e))}getEntries(t,e){let n=qn();return e.forEach((t=>{const e=this.docs.get(t);n=n.insert(t,e?e.document.mutableCopy():ge.newInvalidDocument(t))})),ut.resolve(n)}getAllFromCollection(t,e,n){let s=qn();const i=new W(e.child("")),r=this.docs.getIteratorFrom(i);for(;r.hasNext();){const{key:t,value:{document:i}}=r.getNext();if(!e.isPrefixOf(t.path))break;t.path.length>e.length+1||ot(nt(i),n)<=0||(s=s.insert(i.key,i.mutableCopy()))}return ut.resolve(s)}getAllFromCollectionGroup(t,e,n,s){I()}As(t,e){return ut.forEach(this.docs,(t=>e(t)))}newChangeBuffer(t){return new Fo(this)}getSize(t){return ut.resolve(this.size)}}class Fo extends So{constructor(t){super(),this.Yn=t}applyChanges(t){const e=[];return this.changes.forEach(((n,s)=>{s.isValidDocument()?e.push(this.Yn.addEntry(t,s)):this.Yn.removeEntry(n)})),ut.waitFor(e)}getFromCache(t,e){return this.Yn.getEntry(t,e)}getAllFromCache(t,e){return this.Yn.getEntries(t,e)}}class Uo{constructor(t){this.persistence=t,this.Rs=new Fn((t=>we(t)),ve),this.lastRemoteSnapshotVersion=G.min(),this.highestTargetId=0,this.bs=0,this.Ps=new Mo,this.targetCount=0,this.vs=ho.Pn()}forEachTarget(t,e){return this.Rs.forEach(((t,n)=>e(n))),ut.resolve()}getLastRemoteSnapshotVersion(t){return ut.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return ut.resolve(this.bs)}allocateTargetId(t){return this.highestTargetId=this.vs.next(),ut.resolve(this.highestTargetId)}setTargetsMetadata(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.bs&&(this.bs=e),ut.resolve()}Dn(t){this.Rs.set(t.target,t);const e=t.targetId;e>this.highestTargetId&&(this.vs=new ho(e),this.highestTargetId=e),t.sequenceNumber>this.bs&&(this.bs=t.sequenceNumber)}addTargetData(t,e){return this.Dn(e),this.targetCount+=1,ut.resolve()}updateTargetData(t,e){return this.Dn(e),ut.resolve()}removeTargetData(t,e){return this.Rs.delete(e.target),this.Ps.ls(e.targetId),this.targetCount-=1,ut.resolve()}removeTargets(t,e,n){let s=0;const i=[];return this.Rs.forEach(((r,o)=>{o.sequenceNumber<=e&&null===n.get(o.targetId)&&(this.Rs.delete(r),i.push(this.removeMatchingKeysForTargetId(t,o.targetId)),s++)})),ut.waitFor(i).next((()=>s))}getTargetCount(t){return ut.resolve(this.targetCount)}getTargetData(t,e){const n=this.Rs.get(e)||null;return ut.resolve(n)}addMatchingKeys(t,e,n){return this.Ps.us(e,n),ut.resolve()}removeMatchingKeys(t,e,n){this.Ps.hs(e,n);const s=this.persistence.referenceDelegate,i=[];return s&&e.forEach((e=>{i.push(s.markPotentiallyOrphaned(t,e))})),ut.waitFor(i)}removeMatchingKeysForTargetId(t,e){return this.Ps.ls(e),ut.resolve()}getMatchingKeysForTargetId(t,e){const n=this.Ps.ds(e);return ut.resolve(n)}containsKey(t,e){return ut.resolve(this.Ps.containsKey(e))}}class qo{constructor(t,e){this.Vs={},this.overlays={},this.Ss=new xt(0),this.Ds=!1,this.Ds=!0,this.referenceDelegate=t(this),this.Cs=new Uo(this),this.indexManager=new Yi,this.remoteDocumentCache=function(t){return new Bo(t)}((t=>this.referenceDelegate.xs(t))),this.It=new xi(e),this.Ns=new Po(this.It)}start(){return Promise.resolve()}shutdown(){return this.Ds=!1,Promise.resolve()}get started(){return this.Ds}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(t){return this.indexManager}getDocumentOverlayCache(t){let e=this.overlays[t.toKey()];return e||(e=new jo,this.overlays[t.toKey()]=e),e}getMutationQueue(t,e){let n=this.Vs[t.toKey()];return n||(n=new Vo(e,this.referenceDelegate),this.Vs[t.toKey()]=n),n}getTargetCache(){return this.Cs}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ns}runTransaction(t,e,n){v("MemoryPersistence","Starting transaction:",t);const s=new $o(this.Ss.next());return this.referenceDelegate.ks(),n(s).next((t=>this.referenceDelegate.Ms(s).next((()=>t)))).toPromise().then((t=>(s.raiseOnCommittedEvent(),t)))}Os(t,e){return ut.or(Object.values(this.Vs).map((n=>()=>n.containsKey(t,e))))}}class $o extends at{constructor(t){super(),this.currentSequenceNumber=t}}class zo{constructor(t){this.persistence=t,this.Fs=new Mo,this.$s=null}static Bs(t){return new zo(t)}get Ls(){if(this.$s)return this.$s;throw I()}addReference(t,e,n){return this.Fs.addReference(n,e),this.Ls.delete(n.toString()),ut.resolve()}removeReference(t,e,n){return this.Fs.removeReference(n,e),this.Ls.add(n.toString()),ut.resolve()}markPotentiallyOrphaned(t,e){return this.Ls.add(e.toString()),ut.resolve()}removeTarget(t,e){this.Fs.ls(e.targetId).forEach((t=>this.Ls.add(t.toString())));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(t,e.targetId).next((t=>{t.forEach((t=>this.Ls.add(t.toString())))})).next((()=>n.removeTargetData(t,e)))}ks(){this.$s=new Set}Ms(t){const e=this.persistence.getRemoteDocumentCache().newChangeBuffer();return ut.forEach(this.Ls,(n=>{const s=W.fromPath(n);return this.Us(t,s).next((t=>{t||e.removeEntry(s,G.min())}))})).next((()=>(this.$s=null,e.apply(t))))}updateLimboDocument(t,e){return this.Us(t,e).next((t=>{t?this.Ls.delete(e.toString()):this.Ls.add(e.toString())}))}xs(t){return 0}Us(t,e){return ut.or([()=>ut.resolve(this.Fs.containsKey(e)),()=>this.persistence.getTargetCache().containsKey(t,e),()=>this.persistence.Os(t,e)])}}class Go{constructor(t){this.It=t}$(t,e,n,s){const i=new lt("createOrUpgrade",e);n<1&&s>=1&&(function(t){t.createObjectStore("owner")}(t),function(t){t.createObjectStore("mutationQueues",{keyPath:"userId"}),t.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Hr,{unique:!0}),t.createObjectStore("documentMutations")}(t),Ko(t),function(t){t.createObjectStore("remoteDocuments")}(t));let r=ut.resolve();return n<3&&s>=3&&(0!==n&&(function(t){t.deleteObjectStore("targetDocuments"),t.deleteObjectStore("targets"),t.deleteObjectStore("targetGlobal")}(t),Ko(t)),r=r.next((()=>function(t){const e=t.store("targetGlobal"),n={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:G.min().toTimestamp(),targetCount:0};return e.put("targetGlobalKey",n)}(i)))),n<4&&s>=4&&(0!==n&&(r=r.next((()=>function(t,e){return e.store("mutations").W().next((n=>{t.deleteObjectStore("mutations"),t.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Hr,{unique:!0});const s=e.store("mutations"),i=n.map((t=>s.put(t)));return ut.waitFor(i)}))}(t,i)))),r=r.next((()=>{!function(t){t.createObjectStore("clientMetadata",{keyPath:"clientId"})}(t)}))),n<5&&s>=5&&(r=r.next((()=>this.qs(i)))),n<6&&s>=6&&(r=r.next((()=>(function(t){t.createObjectStore("remoteDocumentGlobal")}(t),this.Ks(i))))),n<7&&s>=7&&(r=r.next((()=>this.Gs(i)))),n<8&&s>=8&&(r=r.next((()=>this.Qs(t,i)))),n<9&&s>=9&&(r=r.next((()=>{!function(t){t.objectStoreNames.contains("remoteDocumentChanges")&&t.deleteObjectStore("remoteDocumentChanges")}(t)}))),n<10&&s>=10&&(r=r.next((()=>this.js(i)))),n<11&&s>=11&&(r=r.next((()=>{!function(t){t.createObjectStore("bundles",{keyPath:"bundleId"})}(t),function(t){t.createObjectStore("namedQueries",{keyPath:"name"})}(t)}))),n<12&&s>=12&&(r=r.next((()=>{!function(t){const e=t.createObjectStore("documentOverlays",{keyPath:ai});e.createIndex("collectionPathOverlayIndex",ci,{unique:!1}),e.createIndex("collectionGroupOverlayIndex",ui,{unique:!1})}(t)}))),n<13&&s>=13&&(r=r.next((()=>function(t){const e=t.createObjectStore("remoteDocumentsV14",{keyPath:Qr});e.createIndex("documentKeyIndex",Xr),e.createIndex("collectionGroupIndex",Jr)}(t))).next((()=>this.Ws(t,i))).next((()=>t.deleteObjectStore("remoteDocuments")))),n<14&&s>=14&&(r=r.next((()=>this.zs(t,i)))),n<15&&s>=15&&(r=r.next((()=>function(t){t.createObjectStore("indexConfiguration",{keyPath:"indexId",autoIncrement:!0}).createIndex("collectionGroupIndex","collectionGroup",{unique:!1}),t.createObjectStore("indexState",{keyPath:ri}).createIndex("sequenceNumberIndex",ii,{unique:!1}),t.createObjectStore("indexEntries",{keyPath:oi}).createIndex("documentKeyIndex",si,{unique:!1})}(t)))),r}Ks(t){let e=0;return t.store("remoteDocuments").Z(((t,n)=>{e+=so(n)})).next((()=>{const n={byteSize:e};return t.store("remoteDocumentGlobal").put("remoteDocumentGlobalKey",n)}))}qs(t){const e=t.store("mutationQueues"),n=t.store("mutations");return e.W().next((e=>ut.forEach(e,(e=>{const s=IDBKeyRange.bound([e.userId,-1],[e.userId,e.lastAcknowledgedBatchId]);return n.W("userMutationsIndex",s).next((n=>ut.forEach(n,(n=>{_(n.userId===e.userId);const s=Oi(this.It,n);return oo(t,e.userId,s).next((()=>{}))}))))}))))}Gs(t){const e=t.store("targetDocuments"),n=t.store("remoteDocuments");return t.store("targetGlobal").get("targetGlobalKey").next((t=>{const s=[];return n.Z(((n,i)=>{const r=new H(n),o=function(t){return[0,$r(t)]}(r);s.push(e.get(o).next((n=>n?ut.resolve():(n=>e.put({targetId:0,path:$r(n),sequenceNumber:t.highestListenSequenceNumber}))(r))))})).next((()=>ut.waitFor(s)))}))}Qs(t,e){t.createObjectStore("collectionParents",{keyPath:ni});const n=e.store("collectionParents"),s=new Wi,i=t=>{if(s.add(t)){const e=t.lastSegment(),s=t.popLast();return n.put({collectionId:e,parent:$r(s)})}};return e.store("remoteDocuments").Z({X:!0},((t,e)=>{const n=new H(t);return i(n.popLast())})).next((()=>e.store("documentMutations").Z({X:!0},(([t,e,n],s)=>{const r=Kr(e);return i(r.popLast())}))))}js(t){const e=t.store("targets");return e.Z(((t,n)=>{const s=ki(n),i=Ci(this.It,s);return e.put(i)}))}Ws(t,e){const n=e.store("remoteDocuments"),s=[];return n.Z(((t,n)=>{const i=e.store("remoteDocumentsV14"),r=(o=n,o.document?new W(H.fromString(o.document.name).popFirst(5)):o.noDocument?W.fromSegments(o.noDocument.path):o.unknownDocument?W.fromSegments(o.unknownDocument.path):I()).path.toArray();var o;const u={prefixPath:r.slice(0,r.length-2),collectionGroup:r[r.length-2],documentId:r[r.length-1],readTime:n.readTime||[0,0],unknownDocument:n.unknownDocument,noDocument:n.noDocument,document:n.document,hasCommittedMutations:!!n.hasCommittedMutations};s.push(i.put(u))})).next((()=>ut.waitFor(s)))}zs(t,e){const n=e.store("mutations"),s=_o(this.It),i=new qo(zo.Bs,this.It.re);return n.W().next((t=>{const n=new Map;return t.forEach((t=>{var e;let s=null!==(e=n.get(t.userId))&&void 0!==e?e:Xn();Oi(this.It,t).keys().forEach((t=>s=s.add(t))),n.set(t.userId,s)})),ut.forEach(n,((t,n)=>{const r=new b(n),o=Li.oe(this.It,r),u=i.getIndexManager(r),c=br.oe(r,this.It,u,i.referenceDelegate);return new Ro(s,c,o,u).recalculateAndSaveOverlaysForDocumentKeys(new gi(e,xt.at),t).next()}))}))}}function Ko(t){t.createObjectStore("targetDocuments",{keyPath:ti}).createIndex("documentTargetsIndex",ei,{unique:!0}),t.createObjectStore("targets",{keyPath:"targetId"}).createIndex("queryTargetsIndex",Zr,{unique:!0}),t.createObjectStore("targetGlobal")}const Ho="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 Yo{constructor(t,e,n,s,i,r,o,u,c,a,l=15){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.Hs=i,this.window=r,this.document=o,this.Js=c,this.Ys=a,this.Xs=l,this.Ss=null,this.Ds=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Zs=null,this.inForeground=!1,this.ti=null,this.ei=null,this.ni=Number.NEGATIVE_INFINITY,this.si=t=>Promise.resolve(),!Yo.C())throw new C(k.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new To(this,s),this.ii=e+"main",this.It=new xi(u),this.ri=new ht(this.ii,this.Xs,new Go(this.It)),this.Cs=new fo(this.referenceDelegate,this.It),this.remoteDocumentCache=_o(this.It),this.Ns=new Pi,this.window&&this.window.localStorage?this.oi=this.window.localStorage:(this.oi=null,!1===a&&T("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.ui().then((()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new C(k.FAILED_PRECONDITION,Ho);return this.ci(),this.ai(),this.hi(),this.runTransaction("getHighestListenSequenceNumber","readonly",(t=>this.Cs.getHighestSequenceNumber(t)))})).then((t=>{this.Ss=new xt(t,this.Js)})).then((()=>{this.Ds=!0})).catch((t=>(this.ri&&this.ri.close(),Promise.reject(t))))}li(t){return this.si=async e=>{if(this.started)return t(e)},t(this.isPrimary)}setDatabaseDeletedListener(t){this.ri.L((async e=>{null===e.newVersion&&await t()}))}setNetworkEnabled(t){this.networkEnabled!==t&&(this.networkEnabled=t,this.Hs.enqueueAndForget((async()=>{this.started&&await this.ui()})))}ui(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",(t=>Qo(t).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next((()=>{if(this.isPrimary)return this.fi(t).next((t=>{t||(this.isPrimary=!1,this.Hs.enqueueRetryable((()=>this.si(!1))))}))})).next((()=>this.di(t))).next((e=>this.isPrimary&&!e?this._i(t).next((()=>!1)):!!e&&this.wi(t).next((()=>!0)))))).catch((t=>{if(mt(t))return v("IndexedDbPersistence","Failed to extend owner lease: ",t),this.isPrimary;if(!this.allowTabSynchronization)throw t;return v("IndexedDbPersistence","Releasing owner lease after error during lease refresh",t),!1})).then((t=>{this.isPrimary!==t&&this.Hs.enqueueRetryable((()=>this.si(t))),this.isPrimary=t}))}fi(t){return Wo(t).get("owner").next((t=>ut.resolve(this.mi(t))))}gi(t){return Qo(t).delete(this.clientId)}async yi(){if(this.isPrimary&&!this.pi(this.ni,18e5)){this.ni=Date.now();const t=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",(t=>{const e=yi(t,"clientMetadata");return e.W().next((t=>{const n=this.Ii(t,18e5),s=t.filter((t=>-1===n.indexOf(t)));return ut.forEach(s,(t=>e.delete(t.clientId))).next((()=>s))}))})).catch((()=>[]));if(this.oi)for(const e of t)this.oi.removeItem(this.Ti(e.clientId))}}hi(){this.ei=this.Hs.enqueueAfterDelay("client_metadata_refresh",4e3,(()=>this.ui().then((()=>this.yi())).then((()=>this.hi()))))}mi(t){return!!t&&t.ownerId===this.clientId}di(t){return this.Ys?ut.resolve(!0):Wo(t).get("owner").next((e=>{if(null!==e&&this.pi(e.leaseTimestampMs,5e3)&&!this.Ei(e.ownerId)){if(this.mi(e)&&this.networkEnabled)return!0;if(!this.mi(e)){if(!e.allowTabSynchronization)throw new C(k.FAILED_PRECONDITION,Ho);return!1}}return!(!this.networkEnabled||!this.inForeground)||Qo(t).W().next((t=>void 0===this.Ii(t,5e3).find((t=>{if(this.clientId!==t.clientId){const e=!this.networkEnabled&&t.networkEnabled,n=!this.inForeground&&t.inForeground,s=this.networkEnabled===t.networkEnabled;if(e||n&&s)return!0}return!1}))))})).next((t=>(this.isPrimary!==t&&v("IndexedDbPersistence",`Client ${t?"is":"is not"} eligible for a primary lease.`),t)))}async shutdown(){this.Ds=!1,this.Ai(),this.ei&&(this.ei.cancel(),this.ei=null),this.Ri(),this.bi(),await this.ri.runTransaction("shutdown","readwrite",["owner","clientMetadata"],(t=>{const e=new gi(t,xt.at);return this._i(e).next((()=>this.gi(e)))})),this.ri.close(),this.Pi()}Ii(t,e){return t.filter((t=>this.pi(t.updateTimeMs,e)&&!this.Ei(t.clientId)))}vi(){return this.runTransaction("getActiveClients","readonly",(t=>Qo(t).W().next((t=>this.Ii(t,18e5).map((t=>t.clientId))))))}get started(){return this.Ds}getMutationQueue(t,e){return br.oe(t,this.It,e,this.referenceDelegate)}getTargetCache(){return this.Cs}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(t){return new Xi(t,this.It.re.databaseId)}getDocumentOverlayCache(t){return Li.oe(this.It,t)}getBundleCache(){return this.Ns}runTransaction(t,e,n){v("IndexedDbPersistence","Starting transaction:",t);const s="readonly"===e?"readonly":"readwrite",i=15===(r=this.Xs)?mi:14===r?pi:13===r?di:12===r?fi:11===r?hi:void I();var r;let o;return this.ri.runTransaction(t,s,i,(s=>(o=new gi(s,this.Ss?this.Ss.next():xt.at),"readwrite-primary"===e?this.fi(o).next((t=>!!t||this.di(o))).next((e=>{if(!e)throw T(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.Hs.enqueueRetryable((()=>this.si(!1))),new C(k.FAILED_PRECONDITION,st);return n(o)})).next((t=>this.wi(o).next((()=>t)))):this.Vi(o).next((()=>n(o)))))).then((t=>(o.raiseOnCommittedEvent(),t)))}Vi(t){return Wo(t).get("owner").next((t=>{if(null!==t&&this.pi(t.leaseTimestampMs,5e3)&&!this.Ei(t.ownerId)&&!this.mi(t)&&!(this.Ys||this.allowTabSynchronization&&t.allowTabSynchronization))throw new C(k.FAILED_PRECONDITION,Ho)}))}wi(t){const e={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return Wo(t).put("owner",e)}static C(){return ht.C()}_i(t){const e=Wo(t);return e.get("owner").next((t=>this.mi(t)?(v("IndexedDbPersistence","Releasing primary lease."),e.delete("owner")):ut.resolve()))}pi(t,e){const n=Date.now();return!(tn&&(T(`Detected an update time that is in the future: ${t} > ${n}`),1))}ci(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.ti=()=>{this.Hs.enqueueAndForget((()=>(this.inForeground="visible"===this.document.visibilityState,this.ui())))},this.document.addEventListener("visibilitychange",this.ti),this.inForeground="visible"===this.document.visibilityState)}Ri(){this.ti&&(this.document.removeEventListener("visibilitychange",this.ti),this.ti=null)}ai(){var t;"function"==typeof(null===(t=this.window)||void 0===t?void 0:t.addEventListener)&&(this.Zs=()=>{this.Ai(),Object(l.n)()&&navigator.appVersion.match(/Version\/1[45]/)&&this.Hs.enterRestrictedMode(!0),this.Hs.enqueueAndForget((()=>this.shutdown()))},this.window.addEventListener("pagehide",this.Zs))}bi(){this.Zs&&(this.window.removeEventListener("pagehide",this.Zs),this.Zs=null)}Ei(t){var e;try{const n=null!==(null===(e=this.oi)||void 0===e?void 0:e.getItem(this.Ti(t)));return v("IndexedDbPersistence",`Client '${t}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(t){return T("IndexedDbPersistence","Failed to get zombied client id.",t),!1}}Ai(){if(this.oi)try{this.oi.setItem(this.Ti(this.clientId),String(Date.now()))}catch(t){T("Failed to set zombie client id.",t)}}Pi(){if(this.oi)try{this.oi.removeItem(this.Ti(this.clientId))}catch(t){}}Ti(t){return`firestore_zombie_${this.persistenceKey}_${t}`}}function Wo(t){return yi(t,"owner")}function Qo(t){return yi(t,"clientMetadata")}function Xo(t,e){let n=t.projectId;return t.isDefaultDatabase||(n+="."+t.database),"firestore/"+e+"/"+n+"/"}class Jo{constructor(t,e,n,s){this.targetId=t,this.fromCache=e,this.Si=n,this.Di=s}static Ci(t,e){let n=Xn(),s=Xn();for(const t of e.docChanges)switch(t.type){case 0:n=n.add(t.doc.key);break;case 1:s=s.add(t.doc.key)}return new Jo(t,e.fromCache,n,s)}}class Zo{constructor(){this.xi=!1}initialize(t,e){this.Ni=t,this.indexManager=e,this.xi=!0}getDocumentsMatchingQuery(t,e,n,s){return this.ki(t,e).next((i=>i||this.Mi(t,e,s,n))).next((n=>n||this.Oi(t,e)))}ki(t,e){if(qe(e))return ut.resolve(null);let n=He(e);return this.indexManager.getIndexType(t,n).next((s=>0===s?null:(null!==e.limit&&1===s&&(e=Ye(e,null,"F"),n=He(e)),this.indexManager.getDocumentsMatchingTarget(t,n).next((s=>{const i=Xn(...s);return this.Ni.getDocuments(t,i).next((s=>this.indexManager.getMinOffset(t,n).next((n=>{const r=this.Fi(e,s);return this.$i(e,r,i,n.readTime)?this.ki(t,Ye(e,null,"F")):this.Bi(t,r,e,n)}))))})))))}Mi(t,e,n,s){return qe(e)||s.isEqual(G.min())?this.Oi(t,e):this.Ni.getDocuments(t,n).next((i=>{const r=this.Fi(e,i);return this.$i(e,r,n,s)?this.Oi(t,e):(y()<=c.a.DEBUG&&v("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),Xe(e)),this.Bi(t,r,e,et(s,-1)))}))}Fi(t,e){let n=new Ct(tn(t));return e.forEach(((e,s)=>{Je(t,s)&&(n=n.add(s))})),n}$i(t,e,n,s){if(null===t.limit)return!1;if(n.size!==e.size)return!0;const i="F"===t.limitType?e.last():e.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(s)>0)}Oi(t,e){return y()<=c.a.DEBUG&&v("QueryEngine","Using full collection scan to execute query:",Xe(e)),this.Ni.getDocumentsMatchingQuery(t,e,it.min())}Bi(t,e,n,s){return this.Ni.getDocumentsMatchingQuery(t,n,s).next((t=>(e.forEach((e=>{t=t.insert(e.key,e)})),t)))}}class ts{constructor(t,e,n,s){this.persistence=t,this.Li=e,this.It=s,this.Ui=new Et(F),this.qi=new Fn((t=>we(t)),ve),this.Ki=new Map,this.Gi=t.getRemoteDocumentCache(),this.Cs=t.getTargetCache(),this.Ns=t.getBundleCache(),this.Qi(n)}Qi(t){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(t),this.indexManager=this.persistence.getIndexManager(t),this.mutationQueue=this.persistence.getMutationQueue(t,this.indexManager),this.localDocuments=new Ro(this.Gi,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Gi.setIndexManager(this.indexManager),this.Li.initialize(this.localDocuments,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(e=>t.collect(e,this.Ui)))}}function es(t,e,n,s){return new ts(t,e,n,s)}async function ns(t,e){const n=O(t);return await n.persistence.runTransaction("Handle user change","readonly",(t=>{let s;return n.mutationQueue.getAllMutationBatches(t).next((i=>(s=i,n.Qi(e),n.mutationQueue.getAllMutationBatches(t)))).next((e=>{const i=[],r=[];let o=Xn();for(const t of s){i.push(t.batchId);for(const e of t.mutations)o=o.add(e.key)}for(const t of e){r.push(t.batchId);for(const e of t.mutations)o=o.add(e.key)}return n.localDocuments.getDocuments(t,o).next((t=>({ji:t,removedBatchIds:i,addedBatchIds:r})))}))}))}function rs(t){const e=O(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.Cs.getLastRemoteSnapshotVersion(t)))}function is(t,e,n){let s=Xn(),i=Xn();return n.forEach((t=>s=s.add(t))),e.getEntries(t,s).next((t=>{let s=qn();return n.forEach(((n,r)=>{const o=t.get(n);r.isFoundDocument()!==o.isFoundDocument()&&(i=i.add(n)),r.isNoDocument()&&r.version.isEqual(G.min())?(e.removeEntry(n,r.readTime),s=s.insert(n,r)):!o.isValidDocument()||r.version.compareTo(o.version)>0||0===r.version.compareTo(o.version)&&o.hasPendingWrites?(e.addEntry(r),s=s.insert(n,r)):v("LocalStore","Ignoring outdated watch update for ",n,". Current version:",o.version," Watch version:",r.version)})),{Wi:s,zi:i}}))}function os(t,e){const n=O(t);return n.persistence.runTransaction("Get next mutation batch","readonly",(t=>(void 0===e&&(e=-1),n.mutationQueue.getNextMutationBatchAfterBatchId(t,e))))}function ss(t,e){const n=O(t);return n.persistence.runTransaction("Allocate target","readwrite",(t=>{let s;return n.Cs.getTargetData(t,e).next((i=>i?(s=i,ut.resolve(s)):n.Cs.allocateTargetId(t).next((i=>(s=new Ti(e,i,0,t.currentSequenceNumber),n.Cs.addTargetData(t,s).next((()=>s)))))))})).then((t=>{const s=n.Ui.get(t.targetId);return(null===s||t.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(n.Ui=n.Ui.insert(t.targetId,t),n.qi.set(e,t.targetId)),t}))}async function as(t,e,n){const s=O(t),i=s.Ui.get(e),r=n?"readwrite":"readwrite-primary";try{n||await s.persistence.runTransaction("Release target",r,(t=>s.persistence.referenceDelegate.removeTarget(t,i)))}catch(t){if(!mt(t))throw t;v("LocalStore",`Failed to update sequence numbers for target ${e}: ${t}`)}s.Ui=s.Ui.remove(e),s.qi.delete(i.target)}function cs(t,e,n){const s=O(t);let i=G.min(),r=Xn();return s.persistence.runTransaction("Execute query","readonly",(t=>function(t,e,n){const s=O(t),i=s.qi.get(n);return void 0!==i?ut.resolve(s.Ui.get(i)):s.Cs.getTargetData(e,n)}(s,t,He(e)).next((e=>{if(e)return i=e.lastLimboFreeSnapshotVersion,s.Cs.getMatchingKeysForTargetId(t,e.targetId).next((t=>{r=t}))})).next((()=>s.Li.getDocumentsMatchingQuery(t,e,n?i:G.min(),n?r:Xn()))).next((t=>(hs(s,Ze(e),t),{documents:t,Hi:r})))))}function us(t,e){const n=O(t),s=O(n.Cs),i=n.Ui.get(e);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",(t=>s.se(t,e).next((t=>t?t.target:null))))}function ls(t,e){const n=O(t),s=n.Ki.get(e)||G.min();return n.persistence.runTransaction("Get new document changes","readonly",(t=>n.Gi.getAllFromCollectionGroup(t,e,et(s,-1),Number.MAX_SAFE_INTEGER))).then((t=>(hs(n,e,t),t)))}function hs(t,e,n){let s=G.min();n.forEach(((t,e)=>{e.readTime.compareTo(s)>0&&(s=e.readTime)})),t.Ki.set(e,s)}async function fs(t,e,n=Xn()){const s=await ss(t,He(Di(e.bundledQuery))),i=O(t);return i.persistence.runTransaction("Save named query","readwrite",(t=>{const r=yr(e.readTime);if(s.snapshotVersion.compareTo(r)>=0)return i.Ns.saveNamedQuery(t,e);const o=s.withResumeToken(Pt.EMPTY_BYTE_STRING,r);return i.Ui=i.Ui.insert(o.targetId,o),i.Cs.updateTargetData(t,o).next((()=>i.Cs.removeMatchingKeysForTargetId(t,s.targetId))).next((()=>i.Cs.addMatchingKeys(t,n,s.targetId))).next((()=>i.Ns.saveNamedQuery(t,e)))}))}function ds(t,e){return`firestore_clients_${t}_${e}`}function ps(t,e,n){let s=`firestore_mutations_${t}_${n}`;return e.isAuthenticated()&&(s+=`_${e.uid}`),s}function ms(t,e){return`firestore_targets_${t}_${e}`}class gs{constructor(t,e,n,s){this.user=t,this.batchId=e,this.state=n,this.error=s}static Zi(t,e,n){const s=JSON.parse(n);let i,r="object"==typeof s&&-1!==["pending","acknowledged","rejected"].indexOf(s.state)&&(void 0===s.error||"object"==typeof s.error);return r&&s.error&&(r="string"==typeof s.error.message&&"string"==typeof s.error.code,r&&(i=new C(s.error.code,s.error.message))),r?new gs(t,e,s.state,i):(T("SharedClientState",`Failed to parse mutation state for ID '${e}': ${n}`),null)}tr(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class ys{constructor(t,e,n){this.targetId=t,this.state=e,this.error=n}static Zi(t,e){const n=JSON.parse(e);let s,i="object"==typeof n&&-1!==["not-current","current","rejected"].indexOf(n.state)&&(void 0===n.error||"object"==typeof n.error);return i&&n.error&&(i="string"==typeof n.error.message&&"string"==typeof n.error.code,i&&(s=new C(n.error.code,n.error.message))),i?new ys(t,n.state,s):(T("SharedClientState",`Failed to parse target state for ID '${t}': ${e}`),null)}tr(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class bs{constructor(t,e){this.clientId=t,this.activeTargetIds=e}static Zi(t,e){const n=JSON.parse(e);let s="object"==typeof n&&n.activeTargetIds instanceof Array,i=Zn();for(let t=0;s&&tthis.shutdown())),this.started=!0}writeSequenceNumber(t){this.setItem(this.hr,JSON.stringify(t))}getAllActiveQueryTargets(){return this.Ir(this.ur)}isActiveQueryTarget(t){let e=!1;return this.ur.forEach(((n,s)=>{s.activeTargetIds.has(t)&&(e=!0)})),e}addPendingMutation(t){this.Tr(t,"pending")}updateMutationState(t,e,n){this.Tr(t,e,n),this.Er(t)}addLocalQueryTarget(t){let e="not-current";if(this.isActiveQueryTarget(t)){const n=this.storage.getItem(ms(this.persistenceKey,t));if(n){const s=ys.Zi(t,n);s&&(e=s.state)}}return this.Ar.er(t),this.gr(),e}removeLocalQueryTarget(t){this.Ar.nr(t),this.gr()}isLocalQueryTarget(t){return this.Ar.activeTargetIds.has(t)}clearQueryState(t){this.removeItem(ms(this.persistenceKey,t))}updateQueryState(t,e,n){this.Rr(t,e,n)}handleUserChange(t,e,n){e.forEach((t=>{this.Er(t)})),this.currentUser=t,n.forEach((t=>{this.addPendingMutation(t)}))}setOnlineState(t){this.br(t)}notifyBundleLoaded(t){this.Pr(t)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.ir),this.removeItem(this.ar),this.started=!1)}getItem(t){const e=this.storage.getItem(t);return v("SharedClientState","READ",t,e),e}setItem(t,e){v("SharedClientState","SET",t,e),this.storage.setItem(t,e)}removeItem(t){v("SharedClientState","REMOVE",t),this.storage.removeItem(t)}rr(t){const e=t;if(e.storageArea===this.storage){if(v("SharedClientState","EVENT",e.key,e.newValue),e.key===this.ar)return void T("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Hs.enqueueRetryable((async()=>{if(this.started){if(null!==e.key)if(this.lr.test(e.key)){if(null==e.newValue){const t=this.vr(e.key);return this.Vr(t,null)}{const t=this.Sr(e.key,e.newValue);if(t)return this.Vr(t.clientId,t)}}else if(this.dr.test(e.key)){if(null!==e.newValue){const t=this.Dr(e.key,e.newValue);if(t)return this.Cr(t)}}else if(this._r.test(e.key)){if(null!==e.newValue){const t=this.Nr(e.key,e.newValue);if(t)return this.kr(t)}}else if(e.key===this.wr){if(null!==e.newValue){const t=this.yr(e.newValue);if(t)return this.pr(t)}}else if(e.key===this.hr){const t=function(t){let e=xt.at;if(null!=t)try{const n=JSON.parse(t);_("number"==typeof n),e=n}catch(t){T("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(e.newValue);t!==xt.at&&this.sequenceNumberHandler(t)}else if(e.key===this.mr){const t=this.Mr(e.newValue);await Promise.all(t.map((t=>this.syncEngine.Or(t))))}}else this.cr.push(e)}))}}get Ar(){return this.ur.get(this.sr)}gr(){this.setItem(this.ar,this.Ar.tr())}Tr(t,e,n){const s=new gs(this.currentUser,t,e,n),i=ps(this.persistenceKey,this.currentUser,t);this.setItem(i,s.tr())}Er(t){const e=ps(this.persistenceKey,this.currentUser,t);this.removeItem(e)}br(t){const e={clientId:this.sr,onlineState:t};this.storage.setItem(this.wr,JSON.stringify(e))}Rr(t,e,n){const s=ms(this.persistenceKey,t),i=new ys(t,e,n);this.setItem(s,i.tr())}Pr(t){const e=JSON.stringify(Array.from(t));this.setItem(this.mr,e)}vr(t){const e=this.lr.exec(t);return e?e[1]:null}Sr(t,e){const n=this.vr(t);return bs.Zi(n,e)}Dr(t,e){const n=this.dr.exec(t),s=Number(n[1]),i=void 0!==n[2]?n[2]:null;return gs.Zi(new b(i),s,e)}Nr(t,e){const n=this._r.exec(t),s=Number(n[1]);return ys.Zi(s,e)}yr(t){return ws.Zi(t)}Mr(t){return JSON.parse(t)}async Cr(t){if(t.user.uid===this.currentUser.uid)return this.syncEngine.Fr(t.batchId,t.state,t.error);v("SharedClientState",`Ignoring mutation for non-active user ${t.user.uid}`)}kr(t){return this.syncEngine.$r(t.targetId,t.state,t.error)}Vr(t,e){const n=e?this.ur.insert(t,e):this.ur.remove(t),s=this.Ir(this.ur),i=this.Ir(n),r=[],o=[];return i.forEach((t=>{s.has(t)||r.push(t)})),s.forEach((t=>{i.has(t)||o.push(t)})),this.syncEngine.Br(r,o).then((()=>{this.ur=n}))}pr(t){this.ur.get(t.clientId)&&this.onlineStateHandler(t.onlineState)}Ir(t){let e=Zn();return t.forEach(((t,n)=>{e=e.unionWith(n.activeTargetIds)})),e}}class xs{constructor(){this.Lr=new vs,this.Ur={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,e,n){}addLocalQueryTarget(t){return this.Lr.er(t),this.Ur[t]||"not-current"}updateQueryState(t,e,n){this.Ur[t]=e}removeLocalQueryTarget(t){this.Lr.nr(t)}isLocalQueryTarget(t){return this.Lr.activeTargetIds.has(t)}clearQueryState(t){delete this.Ur[t]}getAllActiveQueryTargets(){return this.Lr.activeTargetIds}isActiveQueryTarget(t){return this.Lr.activeTargetIds.has(t)}start(){return this.Lr=new vs,Promise.resolve()}handleUserChange(t,e,n){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(t){}}class Ss{qr(t){}shutdown(){}}class Is{constructor(){this.Kr=()=>this.Gr(),this.Qr=()=>this.jr(),this.Wr=[],this.zr()}qr(t){this.Wr.push(t)}shutdown(){window.removeEventListener("online",this.Kr),window.removeEventListener("offline",this.Qr)}zr(){window.addEventListener("online",this.Kr),window.addEventListener("offline",this.Qr)}Gr(){v("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const t of this.Wr)t(0)}jr(){v("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const t of this.Wr)t(1)}static C(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}const _s={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"};class Es{constructor(t){this.Hr=t.Hr,this.Jr=t.Jr}Yr(t){this.Xr=t}Zr(t){this.eo=t}onMessage(t){this.no=t}close(){this.Jr()}send(t){this.Hr(t)}so(){this.Xr()}io(t){this.eo(t)}ro(t){this.no(t)}}class Os extends class{constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const e=t.ssl?"https":"http";this.oo=e+"://"+t.host,this.uo="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}co(t,e,n,s,i){const r=this.ao(t,e);v("RestConnection","Sending: ",r,n);const o={};return this.ho(o,s,i),this.lo(t,r,o,n).then((t=>(v("RestConnection","Received: ",t),t)),(e=>{throw x("RestConnection",`${t} failed with error: `,e,"url: ",r,"request:",n),e}))}fo(t,e,n,s,i,r){return this.co(t,e,n,s,i)}ho(t,e,n){t["X-Goog-Api-Client"]="gl-js/ fire/"+d,t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEach(((e,n)=>t[n]=e)),n&&n.headers.forEach(((e,n)=>t[n]=e))}ao(t,e){const n=_s[t];return`${this.oo}/v1/${e}:${n}`}}{constructor(t){super(t),this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams}lo(t,e,n,s){return new Promise(((i,r)=>{const o=new h.g;o.listenOnce(h.c.COMPLETE,(()=>{try{switch(o.getLastErrorCode()){case h.a.NO_ERROR:const e=o.getResponseJson();v("Connection","XHR received:",JSON.stringify(e)),i(e);break;case h.a.TIMEOUT:v("Connection",'RPC "'+t+'" timed out'),r(new C(k.DEADLINE_EXCEEDED,"Request time out"));break;case h.a.HTTP_ERROR:const n=o.getStatus();if(v("Connection",'RPC "'+t+'" failed with status:',n,"response text:",o.getResponseText()),n>0){const t=o.getResponseJson().error;if(t&&t.status&&t.message){const e=function(t){const e=t.toLowerCase().replace(/_/g,"-");return Object.values(k).indexOf(e)>=0?e:k.UNKNOWN}(t.status);r(new C(e,t.message))}else r(new C(k.UNKNOWN,"Server responded with status "+o.getStatus()))}else r(new C(k.UNAVAILABLE,"Connection failed."));break;default:I()}}finally{v("Connection",'RPC "'+t+'" completed.')}}));const u=JSON.stringify(s);o.send(e,"POST",u,n,15)}))}_o(t,e,n){const s=[this.oo,"/","google.firestore.v1.Firestore","/",t,"/channel"],i=Object(h.h)(),r=Object(h.i)(),o={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling};this.useFetchStreams&&(o.xmlHttpFactory=new h.d({})),this.ho(o.initMessageHeaders,e,n),o.encodeInitMessageHeaders=!0;const u=s.join("");v("Connection","Creating WebChannel: "+u,o);const c=i.createWebChannel(u,o);let a=!1,l=!1;const f=new Es({Hr:t=>{l?v("Connection","Not sending because WebChannel is closed:",t):(a||(v("Connection","Opening WebChannel transport."),c.open(),a=!0),v("Connection","WebChannel sending:",t),c.send(t))},Jr:()=>c.close()}),d=(t,e,n)=>{t.listen(e,(t=>{try{n(t)}catch(t){setTimeout((()=>{throw t}),0)}}))};return d(c,h.f.EventType.OPEN,(()=>{l||v("Connection","WebChannel transport opened.")})),d(c,h.f.EventType.CLOSE,(()=>{l||(l=!0,v("Connection","WebChannel transport closed"),f.io())})),d(c,h.f.EventType.ERROR,(t=>{l||(l=!0,x("Connection","WebChannel transport errored:",t),f.io(new C(k.UNAVAILABLE,"The operation could not be completed")))})),d(c,h.f.EventType.MESSAGE,(t=>{var e;if(!l){const n=t.data[0];_(!!n);const s=n,i=s.error||(null===(e=s[0])||void 0===e?void 0:e.error);if(i){v("Connection","WebChannel received error:",i);const t=i.status;let e=function(t){const e=Mn[t];if(void 0!==e)return Bn(e)}(t),n=i.message;void 0===e&&(e=k.INTERNAL,n="Unknown error status: "+t+" with message "+i.message),l=!0,f.io(new C(e,n)),c.close()}else v("Connection","WebChannel received:",n),f.ro(n)}})),d(r,h.b.STAT_EVENT,(t=>{t.stat===h.e.PROXY?v("Connection","Detected buffering proxy"):t.stat===h.e.NOPROXY&&v("Connection","Detected no buffering proxy")})),setTimeout((()=>{f.so()}),0),f}}function ks(){return"undefined"!=typeof window?window:null}function Cs(){return"undefined"!=typeof document?document:null}function Ds(t){return new dr(t,!0)}class As{constructor(t,e,n=1e3,s=1.5,i=6e4){this.Hs=t,this.timerId=e,this.wo=n,this.mo=s,this.yo=i,this.po=0,this.Io=null,this.To=Date.now(),this.reset()}reset(){this.po=0}Eo(){this.po=this.yo}Ao(t){this.cancel();const e=Math.floor(this.po+this.Ro()),n=Math.max(0,Date.now()-this.To),s=Math.max(0,e-n);s>0&&v("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.po} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),this.Io=this.Hs.enqueueAfterDelay(this.timerId,s,(()=>(this.To=Date.now(),t()))),this.po*=this.mo,this.pothis.yo&&(this.po=this.yo)}bo(){null!==this.Io&&(this.Io.skipDelay(),this.Io=null)}cancel(){null!==this.Io&&(this.Io.cancel(),this.Io=null)}Ro(){return(Math.random()-.5)*this.po}}class Ns{constructor(t,e,n,s,i,r,o,u){this.Hs=t,this.Po=n,this.vo=s,this.Vo=i,this.authCredentialsProvider=r,this.appCheckCredentialsProvider=o,this.listener=u,this.state=0,this.So=0,this.Do=null,this.Co=null,this.stream=null,this.xo=new As(t,e)}No(){return 1===this.state||5===this.state||this.ko()}ko(){return 2===this.state||3===this.state}start(){4!==this.state?this.auth():this.Mo()}async stop(){this.No()&&await this.close(0)}Oo(){this.state=0,this.xo.reset()}Fo(){this.ko()&&null===this.Do&&(this.Do=this.Hs.enqueueAfterDelay(this.Po,6e4,(()=>this.$o())))}Bo(t){this.Lo(),this.stream.send(t)}async $o(){if(this.ko())return this.close(0)}Lo(){this.Do&&(this.Do.cancel(),this.Do=null)}Uo(){this.Co&&(this.Co.cancel(),this.Co=null)}async close(t,e){this.Lo(),this.Uo(),this.xo.cancel(),this.So++,4!==t?this.xo.reset():e&&e.code===k.RESOURCE_EXHAUSTED?(T(e.toString()),T("Using maximum backoff delay to prevent overloading the backend."),this.xo.Eo()):e&&e.code===k.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.qo(),this.stream.close(),this.stream=null),this.state=t,await this.listener.Zr(e)}qo(){}auth(){this.state=1;const t=this.Ko(this.So),e=this.So;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([t,n])=>{this.So===e&&this.Go(t,n)}),(e=>{t((()=>{const t=new C(k.UNKNOWN,"Fetching auth token failed: "+e.message);return this.Qo(t)}))}))}Go(t,e){const n=this.Ko(this.So);this.stream=this.jo(t,e),this.stream.Yr((()=>{n((()=>(this.state=2,this.Co=this.Hs.enqueueAfterDelay(this.vo,1e4,(()=>(this.ko()&&(this.state=3),Promise.resolve()))),this.listener.Yr())))})),this.stream.Zr((t=>{n((()=>this.Qo(t)))})),this.stream.onMessage((t=>{n((()=>this.onMessage(t)))}))}Mo(){this.state=5,this.xo.Ao((async()=>{this.state=0,this.start()}))}Qo(t){return v("PersistentStream",`close with error: ${t}`),this.stream=null,this.close(4,t)}Ko(t){return e=>{this.Hs.enqueueAndForget((()=>this.So===t?e():(v("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class Rs extends Ns{constructor(t,e,n,s,i,r){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",e,n,s,r),this.It=i}jo(t,e){return this.Vo._o("Listen",t,e)}onMessage(t){this.xo.reset();const e=function(t,e){let n;if("targetChange"in e){e.targetChange;const s=function(t){return"NO_CHANGE"===t?0:"ADD"===t?1:"REMOVE"===t?2:"CURRENT"===t?3:"RESET"===t?4:I()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],r=function(t,e){return t.gt?(_(void 0===e||"string"==typeof e),Pt.fromBase64String(e||"")):(_(void 0===e||e instanceof Uint8Array),Pt.fromUint8Array(e||new Uint8Array))}(t,e.targetChange.resumeToken),o=e.targetChange.cause,u=o&&function(t){const e=void 0===t.code?k.UNKNOWN:Bn(t.code);return new C(e,t.message||"")}(o);n=new or(s,i,r,u||null)}else if("documentChange"in e){e.documentChange;const s=e.documentChange;s.document,s.document.name,s.document.updateTime;const i=xr(t,s.document.name),r=yr(s.document.updateTime),o=new pe({mapValue:{fields:s.document.fields}}),u=ge.newFoundDocument(i,r,o),c=s.targetIds||[],a=s.removedTargetIds||[];n=new rr(c,a,u.key,u)}else if("documentDelete"in e){e.documentDelete;const s=e.documentDelete;s.document;const i=xr(t,s.document),r=s.readTime?yr(s.readTime):G.min(),o=ge.newNoDocument(i,r),u=s.removedTargetIds||[];n=new rr([],u,o.key,o)}else if("documentRemove"in e){e.documentRemove;const s=e.documentRemove;s.document;const i=xr(t,s.document),r=s.removedTargetIds||[];n=new rr([],r,i,null)}else{if(!("filter"in e))return I();{e.filter;const t=e.filter;t.targetId;const s=t.count||0,i=new jn(s),r=t.targetId;n=new ir(r,i)}}return n}(this.It,t),n=function(t){if(!("targetChange"in t))return G.min();const e=t.targetChange;return e.targetIds&&e.targetIds.length?G.min():e.readTime?yr(e.readTime):G.min()}(t);return this.listener.Wo(e,n)}zo(t){const e={};e.database=_r(this.It),e.addTarget=function(t,e){let n;const s=e.target;return n=Te(s)?{documents:Ar(t,s)}:{query:Nr(t,s)},n.targetId=e.targetId,e.resumeToken.approximateByteSize()>0?n.resumeToken=mr(t,e.resumeToken):e.snapshotVersion.compareTo(G.min())>0&&(n.readTime=pr(t,e.snapshotVersion.toTimestamp())),n}(this.It,t);const n=function(t,e){const n=function(t,e){switch(e){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return I()}}(0,e.purpose);return null==n?null:{"goog-listen-tags":n}}(this.It,t);n&&(e.labels=n),this.Bo(e)}Ho(t){const e={};e.database=_r(this.It),e.removeTarget=t,this.Bo(e)}}class Ps extends Ns{constructor(t,e,n,s,i,r){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",e,n,s,r),this.It=i,this.Jo=!1}get Yo(){return this.Jo}start(){this.Jo=!1,this.lastStreamToken=void 0,super.start()}qo(){this.Jo&&this.Xo([])}jo(t,e){return this.Vo._o("Write",t,e)}onMessage(t){if(_(!!t.streamToken),this.lastStreamToken=t.streamToken,this.Jo){this.xo.reset();const e=function(t,e){return t&&t.length>0?(_(void 0!==e),t.map((t=>function(t,e){let n=t.updateTime?yr(t.updateTime):yr(e);return n.isEqual(G.min())&&(n=yr(e)),new wn(n,t.transformResults||[])}(t,e)))):[]}(t.writeResults,t.commitTime),n=yr(t.commitTime);return this.listener.Zo(n,e)}return _(!t.writeResults||0===t.writeResults.length),this.Jo=!0,this.listener.tu()}eu(){const t={};t.database=_r(this.It),this.Bo(t)}Xo(t){const e={streamToken:this.lastStreamToken,writes:t.map((t=>Cr(this.It,t)))};this.Bo(e)}}class js extends class{}{constructor(t,e,n,s){super(),this.authCredentials=t,this.appCheckCredentials=e,this.Vo=n,this.It=s,this.nu=!1}su(){if(this.nu)throw new C(k.FAILED_PRECONDITION,"The client has already been terminated.")}co(t,e,n){return this.su(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([s,i])=>this.Vo.co(t,e,n,s,i))).catch((t=>{throw"FirebaseError"===t.name?(t.code===k.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new C(k.UNKNOWN,t.toString())}))}fo(t,e,n,s){return this.su(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,r])=>this.Vo.fo(t,e,n,i,r,s))).catch((t=>{throw"FirebaseError"===t.name?(t.code===k.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new C(k.UNKNOWN,t.toString())}))}terminate(){this.nu=!0}}class Ms{constructor(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state="Unknown",this.iu=0,this.ru=null,this.ou=!0}uu(){0===this.iu&&(this.cu("Unknown"),this.ru=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this.ru=null,this.au("Backend didn't respond within 10 seconds."),this.cu("Offline"),Promise.resolve()))))}hu(t){"Online"===this.state?this.cu("Unknown"):(this.iu++,this.iu>=1&&(this.lu(),this.au(`Connection failed 1 times. Most recent error: ${t.toString()}`),this.cu("Offline")))}set(t){this.lu(),this.iu=0,"Online"===t&&(this.ou=!1),this.cu(t)}cu(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))}au(t){const e=`Could not reach Cloud Firestore backend. ${t}\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.ou?(T(e),this.ou=!1):v("OnlineStateTracker",e)}lu(){null!==this.ru&&(this.ru.cancel(),this.ru=null)}}class Ls{constructor(t,e,n,s,i){this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.fu=[],this.du=new Map,this._u=new Set,this.wu=[],this.mu=i,this.mu.qr((t=>{n.enqueueAndForget((async()=>{Ks(this)&&(v("RemoteStore","Restarting streams for network reachability change."),await async function(t){const e=O(t);e._u.add(4),await Bs(e),e.gu.set("Unknown"),e._u.delete(4),await Vs(e)}(this))}))})),this.gu=new Ms(n,s)}}async function Vs(t){if(Ks(t))for(const e of t.wu)await e(!0)}async function Bs(t){for(const e of t.wu)await e(!1)}function Fs(t,e){const n=O(t);n.du.has(e.targetId)||(n.du.set(e.targetId,e),Gs(n)?zs(n):la(n).ko()&&qs(n,e))}function Us(t,e){const n=O(t),s=la(n);n.du.delete(e),s.ko()&&$s(n,e),0===n.du.size&&(s.ko()?s.Fo():Ks(n)&&n.gu.set("Unknown"))}function qs(t,e){t.yu.Ot(e.targetId),la(t).zo(e)}function $s(t,e){t.yu.Ot(e),la(t).Ho(e)}function zs(t){t.yu=new ar({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),se:e=>t.du.get(e)||null}),la(t).start(),t.gu.uu()}function Gs(t){return Ks(t)&&!la(t).No()&&t.du.size>0}function Ks(t){return 0===O(t)._u.size}function Hs(t){t.yu=void 0}async function Ys(t){t.du.forEach(((e,n)=>{qs(t,e)}))}async function Ws(t,e){Hs(t),Gs(t)?(t.gu.hu(e),zs(t)):t.gu.set("Unknown")}async function Qs(t,e,n){if(t.gu.set("Online"),e instanceof or&&2===e.state&&e.cause)try{await async function(t,e){const n=e.cause;for(const s of e.targetIds)t.du.has(s)&&(await t.remoteSyncer.rejectListen(s,n),t.du.delete(s),t.yu.removeTarget(s))}(t,e)}catch(n){v("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),n),await Xs(t,n)}else if(e instanceof rr?t.yu.Gt(e):e instanceof ir?t.yu.Yt(e):t.yu.Wt(e),!n.isEqual(G.min()))try{const e=await rs(t.localStore);n.compareTo(e)>=0&&await function(t,e){const n=t.yu.te(e);return n.targetChanges.forEach(((n,s)=>{if(n.resumeToken.approximateByteSize()>0){const i=t.du.get(s);i&&t.du.set(s,i.withResumeToken(n.resumeToken,e))}})),n.targetMismatches.forEach((e=>{const n=t.du.get(e);if(!n)return;t.du.set(e,n.withResumeToken(Pt.EMPTY_BYTE_STRING,n.snapshotVersion)),$s(t,e);const s=new Ti(n.target,e,1,n.sequenceNumber);qs(t,s)})),t.remoteSyncer.applyRemoteEvent(n)}(t,n)}catch(e){v("RemoteStore","Failed to raise snapshot:",e),await Xs(t,e)}}async function Xs(t,e,n){if(!mt(e))throw e;t._u.add(1),await Bs(t),t.gu.set("Offline"),n||(n=()=>rs(t.localStore)),t.asyncQueue.enqueueRetryable((async()=>{v("RemoteStore","Retrying IndexedDB access"),await n(),t._u.delete(1),await Vs(t)}))}function Js(t,e){return e().catch((n=>Xs(t,n,e)))}async function Zs(t){const e=O(t),n=ha(e);let s=e.fu.length>0?e.fu[e.fu.length-1].batchId:-1;for(;ta(e);)try{const t=await os(e.localStore,s);if(null===t){0===e.fu.length&&n.Fo();break}s=t.batchId,ea(e,t)}catch(t){await Xs(e,t)}na(e)&&ra(e)}function ta(t){return Ks(t)&&t.fu.length<10}function ea(t,e){t.fu.push(e);const n=ha(t);n.ko()&&n.Yo&&n.Xo(e.mutations)}function na(t){return Ks(t)&&!ha(t).No()&&t.fu.length>0}function ra(t){ha(t).start()}async function ia(t){ha(t).eu()}async function oa(t){const e=ha(t);for(const n of t.fu)e.Xo(n.mutations)}async function sa(t,e,n){const s=t.fu.shift(),i=wi.from(s,e,n);await Js(t,(()=>t.remoteSyncer.applySuccessfulWrite(i))),await Zs(t)}async function aa(t,e){e&&ha(t).Yo&&await async function(t,e){if(Vn(n=e.code)&&n!==k.ABORTED){const n=t.fu.shift();ha(t).Oo(),await Js(t,(()=>t.remoteSyncer.rejectFailedWrite(n.batchId,e))),await Zs(t)}var n}(t,e),na(t)&&ra(t)}async function ca(t,e){const n=O(t);n.asyncQueue.verifyOperationInProgress(),v("RemoteStore","RemoteStore received new credentials");const s=Ks(n);n._u.add(3),await Bs(n),s&&n.gu.set("Unknown"),await n.remoteSyncer.handleCredentialChange(e),n._u.delete(3),await Vs(n)}async function ua(t,e){const n=O(t);e?(n._u.delete(2),await Vs(n)):e||(n._u.add(2),await Bs(n),n.gu.set("Unknown"))}function la(t){return t.pu||(t.pu=function(t,e,n){const s=O(t);return s.su(),new Rs(e,s.Vo,s.authCredentials,s.appCheckCredentials,s.It,n)}(t.datastore,t.asyncQueue,{Yr:Ys.bind(null,t),Zr:Ws.bind(null,t),Wo:Qs.bind(null,t)}),t.wu.push((async e=>{e?(t.pu.Oo(),Gs(t)?zs(t):t.gu.set("Unknown")):(await t.pu.stop(),Hs(t))}))),t.pu}function ha(t){return t.Iu||(t.Iu=function(t,e,n){const s=O(t);return s.su(),new Ps(e,s.Vo,s.authCredentials,s.appCheckCredentials,s.It,n)}(t.datastore,t.asyncQueue,{Yr:ia.bind(null,t),Zr:aa.bind(null,t),tu:oa.bind(null,t),Zo:sa.bind(null,t)}),t.wu.push((async e=>{e?(t.Iu.Oo(),await Zs(t)):(await t.Iu.stop(),t.fu.length>0&&(v("RemoteStore",`Stopping write stream with ${t.fu.length} pending writes`),t.fu=[]))}))),t.Iu}class fa{constructor(t,e,n,s,i){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=s,this.removalCallback=i,this.deferred=new D,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((t=>{}))}static createAndSchedule(t,e,n,s,i){const r=Date.now()+n,o=new fa(t,e,r,s,i);return o.start(n),o}start(t){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new C(k.CANCELLED,"Operation cancelled"+(t?": "+t:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then((t=>this.deferred.resolve(t)))):Promise.resolve()))}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function da(t,e){if(T("AsyncQueue",`${e}: ${t}`),mt(t))return new C(k.UNAVAILABLE,`${e}: ${t}`);throw t}class pa{constructor(t){this.comparator=t?(e,n)=>t(e,n)||W.comparator(e.key,n.key):(t,e)=>W.comparator(t.key,e.key),this.keyedMap=zn(),this.sortedSet=new Et(this.comparator)}static emptySet(t){return new pa(t.comparator)}has(t){return null!=this.keyedMap.get(t)}get(t){return this.keyedMap.get(t)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(t){const e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1}get size(){return this.sortedSet.size}forEach(t){this.sortedSet.inorderTraversal(((e,n)=>(t(e),!1)))}add(t){const e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))}delete(t){const e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this}isEqual(t){if(!(t instanceof pa))return!1;if(this.size!==t.size)return!1;const e=this.sortedSet.getIterator(),n=t.sortedSet.getIterator();for(;e.hasNext();){const t=e.getNext().key,s=n.getNext().key;if(!t.isEqual(s))return!1}return!0}toString(){const t=[];return this.forEach((e=>{t.push(e.toString())})),0===t.length?"DocumentSet ()":"DocumentSet (\n "+t.join(" \n")+"\n)"}copy(t,e){const n=new pa;return n.comparator=this.comparator,n.keyedMap=t,n.sortedSet=e,n}}class ma{constructor(){this.Tu=new Et(W.comparator)}track(t){const e=t.doc.key,n=this.Tu.get(e);n?0!==t.type&&3===n.type?this.Tu=this.Tu.insert(e,t):3===t.type&&1!==n.type?this.Tu=this.Tu.insert(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.Tu=this.Tu.insert(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.Tu=this.Tu.insert(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.Tu=this.Tu.remove(e):1===t.type&&2===n.type?this.Tu=this.Tu.insert(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.Tu=this.Tu.insert(e,{type:2,doc:t.doc}):I():this.Tu=this.Tu.insert(e,t)}Eu(){const t=[];return this.Tu.inorderTraversal(((e,n)=>{t.push(n)})),t}}class ga{constructor(t,e,n,s,i,r,o,u){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=s,this.mutatedKeys=i,this.fromCache=r,this.syncStateChanged=o,this.excludesMetadataChanges=u}static fromInitialDocuments(t,e,n,s){const i=[];return e.forEach((t=>{i.push({type:0,doc:t})})),new ga(t,e,pa.emptySet(e),i,n,s,!0,!1)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(t){if(!(this.fromCache===t.fromCache&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&We(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;const e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(let t=0;tQe(t)),We),this.onlineState="Unknown",this.Ru=new Set}}async function wa(t,e){const n=O(t),s=e.query;let i=!1,r=n.queries.get(s);if(r||(i=!0,r=new ya),i)try{r.Au=await n.onListen(s)}catch(t){const n=da(t,`Initialization of query '${Xe(e.query)}' failed`);return void e.onError(n)}n.queries.set(s,r),r.listeners.push(e),e.bu(n.onlineState),r.Au&&e.Pu(r.Au)&&Sa(n)}async function va(t,e){const n=O(t),s=e.query;let i=!1;const r=n.queries.get(s);if(r){const t=r.listeners.indexOf(e);t>=0&&(r.listeners.splice(t,1),i=0===r.listeners.length)}if(i)return n.queries.delete(s),n.onUnlisten(s)}function Ta(t,e){const n=O(t);let s=!1;for(const t of e){const e=t.query,i=n.queries.get(e);if(i){for(const e of i.listeners)e.Pu(t)&&(s=!0);i.Au=t}}s&&Sa(n)}function xa(t,e,n){const s=O(t),i=s.queries.get(e);if(i)for(const t of i.listeners)t.onError(n);s.queries.delete(e)}function Sa(t){t.Ru.forEach((t=>{t.next()}))}class Ia{constructor(t,e,n){this.query=t,this.vu=e,this.Vu=!1,this.Su=null,this.onlineState="Unknown",this.options=n||{}}Pu(t){if(!this.options.includeMetadataChanges){const e=[];for(const n of t.docChanges)3!==n.type&&e.push(n);t=new ga(t.query,t.docs,t.oldDocs,e,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0)}let e=!1;return this.Vu?this.Du(t)&&(this.vu.next(t),e=!0):this.Cu(t,this.onlineState)&&(this.xu(t),e=!0),this.Su=t,e}onError(t){this.vu.error(t)}bu(t){this.onlineState=t;let e=!1;return this.Su&&!this.Vu&&this.Cu(this.Su,t)&&(this.xu(this.Su),e=!0),e}Cu(t,e){if(!t.fromCache)return!0;const n="Offline"!==e;return!(this.options.Nu&&n||t.docs.isEmpty()&&"Offline"!==e)}Du(t){if(t.docChanges.length>0)return!0;const e=this.Su&&this.Su.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&!0===this.options.includeMetadataChanges}xu(t){t=ga.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.Vu=!0,this.vu.next(t)}}class _a{constructor(t,e){this.payload=t,this.byteLength=e}ku(){return"metadata"in this.payload}}class Ea{constructor(t){this.It=t}Ji(t){return xr(this.It,t)}Yi(t){return t.metadata.exists?kr(this.It,t.document,!1):ge.newNoDocument(this.Ji(t.metadata.name),this.Xi(t.metadata.readTime))}Xi(t){return yr(t)}}class Oa{constructor(t,e,n){this.Mu=t,this.localStore=e,this.It=n,this.queries=[],this.documents=[],this.collectionGroups=new Set,this.progress=ka(t)}Ou(t){this.progress.bytesLoaded+=t.byteLength;let e=this.progress.documentsLoaded;if(t.payload.namedQuery)this.queries.push(t.payload.namedQuery);else if(t.payload.documentMetadata){this.documents.push({metadata:t.payload.documentMetadata}),t.payload.documentMetadata.exists||++e;const n=H.fromString(t.payload.documentMetadata.name);this.collectionGroups.add(n.get(n.length-2))}else t.payload.document&&(this.documents[this.documents.length-1].document=t.payload.document,++e);return e!==this.progress.documentsLoaded?(this.progress.documentsLoaded=e,Object.assign({},this.progress)):null}Fu(t){const e=new Map,n=new Ea(this.It);for(const s of t)if(s.metadata.queries){const t=n.Ji(s.metadata.name);for(const n of s.metadata.queries){const s=(e.get(n)||Xn()).add(t);e.set(n,s)}}return e}async complete(){const t=await async function(t,e,n,s){const i=O(t);let r=Xn(),o=qn();for(const t of n){const n=e.Ji(t.metadata.name);t.document&&(r=r.add(n));const s=e.Yi(t);s.setReadTime(e.Xi(t.metadata.readTime)),o=o.insert(n,s)}const u=i.Gi.newChangeBuffer({trackRemovals:!0}),c=await ss(i,function(t){return He(Ue(H.fromString(`__bundle__/docs/${t}`)))}(s));return i.persistence.runTransaction("Apply bundle documents","readwrite",(t=>is(t,u,o).next((e=>(u.apply(t),e))).next((e=>i.Cs.removeMatchingKeysForTargetId(t,c.targetId).next((()=>i.Cs.addMatchingKeys(t,r,c.targetId))).next((()=>i.localDocuments.getLocalViewOfDocuments(t,e.Wi,e.zi))).next((()=>e.Wi))))))}(this.localStore,new Ea(this.It),this.documents,this.Mu.id),e=this.Fu(this.documents);for(const t of this.queries)await fs(this.localStore,t,e.get(t.name));return this.progress.taskState="Success",{progress:this.progress,$u:this.collectionGroups,Bu:t}}}function ka(t){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}class Ca{constructor(t){this.key=t}}class Da{constructor(t){this.key=t}}class Aa{constructor(t,e){this.query=t,this.Lu=e,this.Uu=null,this.current=!1,this.qu=Xn(),this.mutatedKeys=Xn(),this.Ku=tn(t),this.Gu=new pa(this.Ku)}get Qu(){return this.Lu}ju(t,e){const n=e?e.Wu:new ma,s=e?e.Gu:this.Gu;let i=e?e.mutatedKeys:this.mutatedKeys,r=s,o=!1;const u="F"===this.query.limitType&&s.size===this.query.limit?s.last():null,c="L"===this.query.limitType&&s.size===this.query.limit?s.first():null;if(t.inorderTraversal(((t,e)=>{const a=s.get(t),l=Je(this.query,e)?e:null,h=!!a&&this.mutatedKeys.has(a.key),f=!!l&&(l.hasLocalMutations||this.mutatedKeys.has(l.key)&&l.hasCommittedMutations);let d=!1;a&&l?a.data.isEqual(l.data)?h!==f&&(n.track({type:3,doc:l}),d=!0):this.zu(a,l)||(n.track({type:2,doc:l}),d=!0,(u&&this.Ku(l,u)>0||c&&this.Ku(l,c)<0)&&(o=!0)):!a&&l?(n.track({type:0,doc:l}),d=!0):a&&!l&&(n.track({type:1,doc:a}),d=!0,(u||c)&&(o=!0)),d&&(l?(r=r.add(l),i=f?i.add(t):i.delete(t)):(r=r.delete(t),i=i.delete(t)))})),null!==this.query.limit)for(;r.size>this.query.limit;){const t="F"===this.query.limitType?r.last():r.first();r=r.delete(t.key),i=i.delete(t.key),n.track({type:1,doc:t})}return{Gu:r,Wu:n,$i:o,mutatedKeys:i}}zu(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations}applyChanges(t,e,n){const s=this.Gu;this.Gu=t.Gu,this.mutatedKeys=t.mutatedKeys;const i=t.Wu.Eu();i.sort(((t,e)=>function(t,e){const n=t=>{switch(t){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return I()}};return n(t)-n(e)}(t.type,e.type)||this.Ku(t.doc,e.doc))),this.Hu(n);const r=e?this.Ju():[],o=0===this.qu.size&&this.current?1:0,u=o!==this.Uu;return this.Uu=o,0!==i.length||u?{snapshot:new ga(this.query,t.Gu,s,i,t.mutatedKeys,0===o,u,!1),Yu:r}:{Yu:r}}bu(t){return this.current&&"Offline"===t?(this.current=!1,this.applyChanges({Gu:this.Gu,Wu:new ma,mutatedKeys:this.mutatedKeys,$i:!1},!1)):{Yu:[]}}Xu(t){return!this.Lu.has(t)&&!!this.Gu.has(t)&&!this.Gu.get(t).hasLocalMutations}Hu(t){t&&(t.addedDocuments.forEach((t=>this.Lu=this.Lu.add(t))),t.modifiedDocuments.forEach((t=>{})),t.removedDocuments.forEach((t=>this.Lu=this.Lu.delete(t))),this.current=t.current)}Ju(){if(!this.current)return[];const t=this.qu;this.qu=Xn(),this.Gu.forEach((t=>{this.Xu(t.key)&&(this.qu=this.qu.add(t.key))}));const e=[];return t.forEach((t=>{this.qu.has(t)||e.push(new Da(t))})),this.qu.forEach((n=>{t.has(n)||e.push(new Ca(n))})),e}Zu(t){this.Lu=t.Hi,this.qu=Xn();const e=this.ju(t.documents);return this.applyChanges(e,!0)}tc(){return ga.fromInitialDocuments(this.query,this.Gu,this.mutatedKeys,0===this.Uu)}}class Na{constructor(t,e,n){this.query=t,this.targetId=e,this.view=n}}class Ra{constructor(t){this.key=t,this.ec=!1}}class Pa{constructor(t,e,n,s,i,r){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=s,this.currentUser=i,this.maxConcurrentLimboResolutions=r,this.nc={},this.sc=new Fn((t=>Qe(t)),We),this.ic=new Map,this.rc=new Set,this.oc=new Et(W.comparator),this.uc=new Map,this.cc=new Mo,this.ac={},this.hc=new Map,this.lc=ho.vn(),this.onlineState="Unknown",this.fc=void 0}get isPrimaryClient(){return!0===this.fc}}async function ja(t,e){const n=ac(t);let s,i;const r=n.sc.get(e);if(r)s=r.targetId,n.sharedClientState.addLocalQueryTarget(s),i=r.view.tc();else{const t=await ss(n.localStore,He(e));n.isPrimaryClient&&Fs(n.remoteStore,t);const r=n.sharedClientState.addLocalQueryTarget(t.targetId);s=t.targetId,i=await Ma(n,e,s,"current"===r)}return i}async function Ma(t,e,n,s){t.dc=(e,n,s)=>async function(t,e,n,s){let i=e.view.ju(n);i.$i&&(i=await cs(t.localStore,e.query,!1).then((({documents:t})=>e.view.ju(t,i))));const r=s&&s.targetChanges.get(e.targetId),o=e.view.applyChanges(i,t.isPrimaryClient,r);return Ha(t,e.targetId,o.Yu),o.snapshot}(t,e,n,s);const i=await cs(t.localStore,e,!0),r=new Aa(e,i.Hi),o=r.ju(i.documents),u=nr.createSynthesizedTargetChangeForCurrentChange(n,s&&"Offline"!==t.onlineState),c=r.applyChanges(o,t.isPrimaryClient,u);Ha(t,n,c.Yu);const a=new Na(e,n,r);return t.sc.set(e,a),t.ic.has(n)?t.ic.get(n).push(e):t.ic.set(n,[e]),c.snapshot}async function La(t,e){const n=O(t),s=n.sc.get(e),i=n.ic.get(s.targetId);if(i.length>1)return n.ic.set(s.targetId,i.filter((t=>!We(t,e)))),void n.sc.delete(e);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(s.targetId),n.sharedClientState.isActiveQueryTarget(s.targetId)||await as(n.localStore,s.targetId,!1).then((()=>{n.sharedClientState.clearQueryState(s.targetId),Us(n.remoteStore,s.targetId),Ga(n,s.targetId)})).catch(ct)):(Ga(n,s.targetId),await as(n.localStore,s.targetId,!0))}async function Va(t,e){const n=O(t);try{const t=await function(t,e){const n=O(t),s=e.snapshotVersion;let i=n.Ui;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(t=>{const r=n.Gi.newChangeBuffer({trackRemovals:!0});i=n.Ui;const o=[];e.targetChanges.forEach(((r,u)=>{const c=i.get(u);if(!c)return;o.push(n.Cs.removeMatchingKeys(t,r.removedDocuments,u).next((()=>n.Cs.addMatchingKeys(t,r.addedDocuments,u))));let a=c.withSequenceNumber(t.currentSequenceNumber);e.targetMismatches.has(u)?a=a.withResumeToken(Pt.EMPTY_BYTE_STRING,G.min()).withLastLimboFreeSnapshotVersion(G.min()):r.resumeToken.approximateByteSize()>0&&(a=a.withResumeToken(r.resumeToken,s)),i=i.insert(u,a),function(t,e,n){return 0===t.resumeToken.approximateByteSize()||e.snapshotVersion.toMicroseconds()-t.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(c,a,r)&&o.push(n.Cs.updateTargetData(t,a))}));let u=qn(),c=Xn();if(e.documentUpdates.forEach((s=>{e.resolvedLimboDocuments.has(s)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(t,s))})),o.push(is(t,r,e.documentUpdates).next((t=>{u=t.Wi,c=t.zi}))),!s.isEqual(G.min())){const e=n.Cs.getLastRemoteSnapshotVersion(t).next((e=>n.Cs.setTargetsMetadata(t,t.currentSequenceNumber,s)));o.push(e)}return ut.waitFor(o).next((()=>r.apply(t))).next((()=>n.localDocuments.getLocalViewOfDocuments(t,u,c))).next((()=>u))})).then((t=>(n.Ui=i,t)))}(n.localStore,e);e.targetChanges.forEach(((t,e)=>{const s=n.uc.get(e);s&&(_(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1),t.addedDocuments.size>0?s.ec=!0:t.modifiedDocuments.size>0?_(s.ec):t.removedDocuments.size>0&&(_(s.ec),s.ec=!1))})),await Qa(n,t,e)}catch(t){await ct(t)}}function Ba(t,e,n){const s=O(t);if(s.isPrimaryClient&&0===n||!s.isPrimaryClient&&1===n){const t=[];s.sc.forEach(((n,s)=>{const i=s.view.bu(e);i.snapshot&&t.push(i.snapshot)})),function(t,e){const n=O(t);n.onlineState=e;let s=!1;n.queries.forEach(((t,n)=>{for(const t of n.listeners)t.bu(e)&&(s=!0)})),s&&Sa(n)}(s.eventManager,e),t.length&&s.nc.Wo(t),s.onlineState=e,s.isPrimaryClient&&s.sharedClientState.setOnlineState(e)}}async function Fa(t,e,n){const s=O(t);s.sharedClientState.updateQueryState(e,"rejected",n);const i=s.uc.get(e),r=i&&i.key;if(r){let t=new Et(W.comparator);t=t.insert(r,ge.newNoDocument(r,G.min()));const n=Xn().add(r),i=new er(G.min(),new Map,new Ct(F),t,n);await Va(s,i),s.oc=s.oc.remove(r),s.uc.delete(e),Wa(s)}else await as(s.localStore,e,!1).then((()=>Ga(s,e,n))).catch(ct)}async function Ua(t,e){const n=O(t),s=e.batch.batchId;try{const t=await function(t,e){const n=O(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(t=>{const s=e.batch.keys(),i=n.Gi.newChangeBuffer({trackRemovals:!0});return function(t,e,n,s){const i=n.batch,r=i.keys();let o=ut.resolve();return r.forEach((t=>{o=o.next((()=>s.getEntry(e,t))).next((e=>{const r=n.docVersions.get(t);_(null!==r),e.version.compareTo(r)<0&&(i.applyToRemoteDocument(e,n),e.isValidDocument()&&(e.setReadTime(n.commitVersion),s.addEntry(e)))}))})),o.next((()=>t.mutationQueue.removeMutationBatch(e,i)))}(n,t,e,i).next((()=>i.apply(t))).next((()=>n.mutationQueue.performConsistencyCheck(t))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(t,s,e.batch.batchId))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(t,function(t){let e=Xn();for(let n=0;n0&&(e=e.add(t.batch.mutations[n].key));return e}(e)))).next((()=>n.localDocuments.getDocuments(t,s)))}))}(n.localStore,e);za(n,s,null),$a(n,s),n.sharedClientState.updateMutationState(s,"acknowledged"),await Qa(n,t)}catch(t){await ct(t)}}async function qa(t,e,n){const s=O(t);try{const t=await function(t,e){const n=O(t);return n.persistence.runTransaction("Reject batch","readwrite-primary",(t=>{let s;return n.mutationQueue.lookupMutationBatch(t,e).next((e=>(_(null!==e),s=e.keys(),n.mutationQueue.removeMutationBatch(t,e)))).next((()=>n.mutationQueue.performConsistencyCheck(t))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(t,s,e))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(t,s))).next((()=>n.localDocuments.getDocuments(t,s)))}))}(s.localStore,e);za(s,e,n),$a(s,e),s.sharedClientState.updateMutationState(e,"rejected",n),await Qa(s,t)}catch(n){await ct(n)}}function $a(t,e){(t.hc.get(e)||[]).forEach((t=>{t.resolve()})),t.hc.delete(e)}function za(t,e,n){const s=O(t);let i=s.ac[s.currentUser.toKey()];if(i){const t=i.get(e);t&&(n?t.reject(n):t.resolve(),i=i.remove(e)),s.ac[s.currentUser.toKey()]=i}}function Ga(t,e,n=null){t.sharedClientState.removeLocalQueryTarget(e);for(const s of t.ic.get(e))t.sc.delete(s),n&&t.nc._c(s,n);t.ic.delete(e),t.isPrimaryClient&&t.cc.ls(e).forEach((e=>{t.cc.containsKey(e)||Ka(t,e)}))}function Ka(t,e){t.rc.delete(e.path.canonicalString());const n=t.oc.get(e);null!==n&&(Us(t.remoteStore,n),t.oc=t.oc.remove(e),t.uc.delete(n),Wa(t))}function Ha(t,e,n){for(const s of n)s instanceof Ca?(t.cc.addReference(s.key,e),Ya(t,s)):s instanceof Da?(v("SyncEngine","Document no longer in limbo: "+s.key),t.cc.removeReference(s.key,e),t.cc.containsKey(s.key)||Ka(t,s.key)):I()}function Ya(t,e){const n=e.key,s=n.path.canonicalString();t.oc.get(n)||t.rc.has(s)||(v("SyncEngine","New document in limbo: "+n),t.rc.add(s),Wa(t))}function Wa(t){for(;t.rc.size>0&&t.oc.size{o.push(s.dc(u,e,n).then((t=>{if(t){s.isPrimaryClient&&s.sharedClientState.updateQueryState(u.targetId,t.fromCache?"not-current":"current"),i.push(t);const e=Jo.Ci(u.targetId,t);r.push(e)}})))})),await Promise.all(o),s.nc.Wo(i),await async function(t,e){const n=O(t);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(t=>ut.forEach(e,(e=>ut.forEach(e.Si,(s=>n.persistence.referenceDelegate.addReference(t,e.targetId,s))).next((()=>ut.forEach(e.Di,(s=>n.persistence.referenceDelegate.removeReference(t,e.targetId,s)))))))))}catch(t){if(!mt(t))throw t;v("LocalStore","Failed to update sequence numbers: "+t)}for(const t of e){const e=t.targetId;if(!t.fromCache){const t=n.Ui.get(e),s=t.snapshotVersion,i=t.withLastLimboFreeSnapshotVersion(s);n.Ui=n.Ui.insert(e,i)}}}(s.localStore,r))}async function Xa(t,e){const n=O(t);if(!n.currentUser.isEqual(e)){v("SyncEngine","User change. New user:",e.toKey());const t=await ns(n.localStore,e);n.currentUser=e,function(t,e){t.hc.forEach((t=>{t.forEach((t=>{t.reject(new C(k.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),t.hc.clear()}(n),n.sharedClientState.handleUserChange(e,t.removedBatchIds,t.addedBatchIds),await Qa(n,t.ji)}}function Ja(t,e){const n=O(t),s=n.uc.get(e);if(s&&s.ec)return Xn().add(s.key);{let t=Xn();const s=n.ic.get(e);if(!s)return t;for(const e of s){const s=n.sc.get(e);t=t.unionWith(s.view.Qu)}return t}}async function Za(t,e){const n=O(t),s=await cs(n.localStore,e.query,!0),i=e.view.Zu(s);return n.isPrimaryClient&&Ha(n,e.targetId,i.Yu),i}async function tc(t,e){const n=O(t);return ls(n.localStore,e).then((t=>Qa(n,t)))}async function ec(t,e,n,s){const i=O(t),r=await function(t,e){const n=O(t),s=O(n.mutationQueue);return n.persistence.runTransaction("Lookup mutation documents","readonly",(t=>s.Tn(t,e).next((e=>e?n.localDocuments.getDocuments(t,e):ut.resolve(null)))))}(i.localStore,e);null!==r?("pending"===n?await Zs(i.remoteStore):"acknowledged"===n||"rejected"===n?(za(i,e,s||null),$a(i,e),function(t,e){O(O(t).mutationQueue).An(e)}(i.localStore,e)):I(),await Qa(i,r)):v("SyncEngine","Cannot apply mutation batch with id: "+e)}async function nc(t,e,n){const s=O(t),i=[],r=[];for(const t of e){let e;const n=s.ic.get(t);if(n&&0!==n.length){e=await ss(s.localStore,He(n[0]));for(const t of n){const e=s.sc.get(t),n=await Za(s,e);n.snapshot&&r.push(n.snapshot)}}else{const n=await us(s.localStore,t);e=await ss(s.localStore,n),await Ma(s,rc(n),t,!1)}i.push(e)}return s.nc.Wo(r),i}function rc(t){return Fe(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,"F",t.startAt,t.endAt)}function ic(t){const e=O(t);return O(O(e.localStore).persistence).vi()}async function oc(t,e,n,s){const i=O(t);if(i.fc)return void v("SyncEngine","Ignoring unexpected query state notification.");const r=i.ic.get(e);if(r&&r.length>0)switch(n){case"current":case"not-current":{const t=await ls(i.localStore,Ze(r[0])),s=er.createSynthesizedRemoteEventForCurrentChange(e,"current"===n);await Qa(i,t,s);break}case"rejected":await as(i.localStore,e,!0),Ga(i,e,s);break;default:I()}}async function sc(t,e,n){const s=ac(t);if(s.fc){for(const t of e){if(s.ic.has(t)){v("SyncEngine","Adding an already active target "+t);continue}const e=await us(s.localStore,t),n=await ss(s.localStore,e);await Ma(s,rc(e),n.targetId,!1),Fs(s.remoteStore,n)}for(const t of n)s.ic.has(t)&&await as(s.localStore,t,!1).then((()=>{Us(s.remoteStore,t),Ga(s,t)})).catch(ct)}}function ac(t){const e=O(t);return e.remoteStore.remoteSyncer.applyRemoteEvent=Va.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=Ja.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=Fa.bind(null,e),e.nc.Wo=Ta.bind(null,e.eventManager),e.nc._c=xa.bind(null,e.eventManager),e}function cc(t){const e=O(t);return e.remoteStore.remoteSyncer.applySuccessfulWrite=Ua.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=qa.bind(null,e),e}class uc{constructor(){this.synchronizeTabs=!1}async initialize(t){this.It=Ds(t.databaseInfo.databaseId),this.sharedClientState=this.mc(t),this.persistence=this.gc(t),await this.persistence.start(),this.localStore=this.yc(t),this.gcScheduler=this.Ic(t,this.localStore),this.indexBackfillerScheduler=this.Tc(t,this.localStore)}Ic(t,e){return null}Tc(t,e){return null}yc(t){return es(this.persistence,new Zo,t.initialUser,this.It)}gc(t){return new qo(zo.Bs,this.It)}mc(t){return new xs}async terminate(){this.gcScheduler&&this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class lc extends uc{constructor(t,e,n){super(),this.Ec=t,this.cacheSizeBytes=e,this.forceOwnership=n,this.synchronizeTabs=!1}async initialize(t){await super.initialize(t),await this.Ec.initialize(this,t),await cc(this.Ec.syncEngine),await Zs(this.Ec.remoteStore),await this.persistence.li((()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve())))}yc(t){return es(this.persistence,new Zo,t.initialUser,this.It)}Ic(t,e){const n=this.persistence.referenceDelegate.garbageCollector;return new wo(n,t.asyncQueue,e)}Tc(t,e){const n=new Tt(e,this.persistence);return new vt(t.asyncQueue,n)}gc(t){const e=Xo(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?io.withCacheSize(this.cacheSizeBytes):io.DEFAULT;return new Yo(this.synchronizeTabs,e,t.clientId,n,t.asyncQueue,ks(),Cs(),this.It,this.sharedClientState,!!this.forceOwnership)}mc(t){return new xs}}class hc extends lc{constructor(t,e){super(t,e,!1),this.Ec=t,this.cacheSizeBytes=e,this.synchronizeTabs=!0}async initialize(t){await super.initialize(t);const e=this.Ec.syncEngine;this.sharedClientState instanceof Ts&&(this.sharedClientState.syncEngine={Fr:ec.bind(null,e),$r:oc.bind(null,e),Br:sc.bind(null,e),vi:ic.bind(null,e),Or:tc.bind(null,e)},await this.sharedClientState.start()),await this.persistence.li((async t=>{await async function(t,e){const n=O(t);if(ac(n),cc(n),!0===e&&!0!==n.fc){const t=n.sharedClientState.getAllActiveQueryTargets(),e=await nc(n,t.toArray());n.fc=!0,await ua(n.remoteStore,!0);for(const t of e)Fs(n.remoteStore,t)}else if(!1===e&&!1!==n.fc){const t=[];let e=Promise.resolve();n.ic.forEach(((s,i)=>{n.sharedClientState.isLocalQueryTarget(i)?t.push(i):e=e.then((()=>(Ga(n,i),as(n.localStore,i,!0)))),Us(n.remoteStore,i)})),await e,await nc(n,t),function(t){const e=O(t);e.uc.forEach(((t,n)=>{Us(e.remoteStore,n)})),e.cc.fs(),e.uc=new Map,e.oc=new Et(W.comparator)}(n),n.fc=!1,await ua(n.remoteStore,!1)}}(this.Ec.syncEngine,t),this.gcScheduler&&(t&&!this.gcScheduler.started?this.gcScheduler.start():t||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(t&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():t||this.indexBackfillerScheduler.stop())}))}mc(t){const e=ks();if(!Ts.C(e))throw new C(k.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const n=Xo(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new Ts(e,t.asyncQueue,n,t.clientId,t.initialUser)}}class fc{async initialize(t,e){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=t=>Ba(this.syncEngine,t,1),this.remoteStore.remoteSyncer.handleCredentialChange=Xa.bind(null,this.syncEngine),await ua(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return new ba}createDatastore(t){const e=Ds(t.databaseInfo.databaseId),n=(s=t.databaseInfo,new Os(s));var s;return function(t,e,n,s){return new js(t,e,n,s)}(t.authCredentials,t.appCheckCredentials,n,e)}createRemoteStore(t){return e=this.localStore,n=this.datastore,s=t.asyncQueue,i=t=>Ba(this.syncEngine,t,0),r=Is.C()?new Is:new Ss,new Ls(e,n,s,i,r);var e,n,s,i,r}createSyncEngine(t,e){return function(t,e,n,s,i,r,o){const u=new Pa(t,e,n,s,i,r);return o&&(u.fc=!0),u}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)}terminate(){return async function(t){const e=O(t);v("RemoteStore","RemoteStore shutting down."),e._u.add(5),await Bs(e),e.mu.shutdown(),e.gu.set("Unknown")}(this.remoteStore)}}function dc(t,e=10240){let n=0;return{async read(){if(n{this.muted||t(e)}),0)}}class mc{constructor(t,e){this.bc=t,this.It=e,this.metadata=new D,this.buffer=new Uint8Array,this.Pc=new TextDecoder("utf-8"),this.vc().then((t=>{t&&t.ku()?this.metadata.resolve(t.payload.metadata):this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null==t?void 0:t.payload)}`))}),(t=>this.metadata.reject(t)))}close(){return this.bc.cancel()}async getMetadata(){return this.metadata.promise}async wc(){return await this.getMetadata(),this.vc()}async vc(){const t=await this.Vc();if(null===t)return null;const e=this.Pc.decode(t),n=Number(e);isNaN(n)&&this.Sc(`length string (${e}) is not valid number`);const s=await this.Dc(n);return new _a(JSON.parse(s),t.length+n)}Cc(){return this.buffer.findIndex((t=>t==="{".charCodeAt(0)))}async Vc(){for(;this.Cc()<0&&!await this.xc(););if(0===this.buffer.length)return null;const t=this.Cc();t<0&&this.Sc("Reached the end of bundle when a length string is expected.");const e=this.buffer.slice(0,t);return this.buffer=this.buffer.slice(t),e}async Dc(t){for(;this.buffer.length0)throw new C(k.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");const e=await async function(t,e){const n=O(t),s=_r(n.It)+"/documents",i={documents:e.map((t=>Tr(n.It,t)))},r=await n.fo("BatchGetDocuments",s,i,e.length),o=new Map;r.forEach((t=>{const e=function(t,e){return"found"in e?function(t,e){_(!!e.found),e.found.name,e.found.updateTime;const n=xr(t,e.found.name),s=yr(e.found.updateTime),i=new pe({mapValue:{fields:e.found.fields}});return ge.newFoundDocument(n,s,i)}(t,e):"missing"in e?function(t,e){_(!!e.missing),_(!!e.readTime);const n=xr(t,e.missing),s=yr(e.readTime);return ge.newNoDocument(n,s)}(t,e):I()}(n.It,t);o.set(e.key.toString(),e)}));const u=[];return e.forEach((t=>{const e=o.get(t.toString());_(!!e),u.push(e)})),u}(this.datastore,t);return e.forEach((t=>this.recordVersion(t))),e}set(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())}update(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(t){this.lastWriteError=t}this.writtenDocs.add(t.toString())}delete(t){this.write(new Rn(t,this.precondition(t))),this.writtenDocs.add(t.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;const t=this.readVersions;this.mutations.forEach((e=>{t.delete(e.key.toString())})),t.forEach(((t,e)=>{const n=W.fromPath(e);this.mutations.push(new Pn(n,this.precondition(n)))})),await async function(t,e){const n=O(t),s=_r(n.It)+"/documents",i={writes:e.map((t=>Cr(n.It,t)))};await n.co("Commit",s,i)}(this.datastore,this.mutations),this.committed=!0}recordVersion(t){let e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw I();e=G.min()}const n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new C(k.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)}precondition(t){const e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?e.isEqual(G.min())?vn.exists(!1):vn.updateTime(e):vn.none()}preconditionForUpdate(t){const e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(G.min()))throw new C(k.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return vn.updateTime(e)}return vn.exists(!0)}write(t){this.ensureCommitNotCalled(),this.mutations.push(t)}ensureCommitNotCalled(){}}class yc{constructor(t,e,n,s,i){this.asyncQueue=t,this.datastore=e,this.options=n,this.updateFunction=s,this.deferred=i,this.Nc=n.maxAttempts,this.xo=new As(this.asyncQueue,"transaction_retry")}run(){this.Nc-=1,this.kc()}kc(){this.xo.Ao((async()=>{const t=new gc(this.datastore),e=this.Mc(t);e&&e.then((e=>{this.asyncQueue.enqueueAndForget((()=>t.commit().then((()=>{this.deferred.resolve(e)})).catch((t=>{this.Oc(t)}))))})).catch((t=>{this.Oc(t)}))}))}Mc(t){try{const e=this.updateFunction(t);return!zt(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.deferred.reject(t),null}}Oc(t){this.Nc>0&&this.Fc(t)?(this.Nc-=1,this.asyncQueue.enqueueAndForget((()=>(this.kc(),Promise.resolve())))):this.deferred.reject(t)}Fc(t){if("FirebaseError"===t.name){const e=t.code;return"aborted"===e||"failed-precondition"===e||!Vn(e)}return!1}}class bc{constructor(t,e,n,s){this.authCredentials=t,this.appCheckCredentials=e,this.asyncQueue=n,this.databaseInfo=s,this.user=b.UNAUTHENTICATED,this.clientId=B.R(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this.authCredentials.start(n,(async t=>{v("FirestoreClient","Received user=",t.uid),await this.authCredentialListener(t),this.user=t})),this.appCheckCredentials.start(n,(t=>(v("FirestoreClient","Received new app check token=",t),this.appCheckCredentialListener(t,this.user))))}async getConfiguration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(t){this.authCredentialListener=t}setAppCheckTokenChangeListener(t){this.appCheckCredentialListener=t}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new C(k.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const t=new D;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this.onlineComponents&&await this.onlineComponents.terminate(),this.offlineComponents&&await this.offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),t.resolve()}catch(e){const n=da(e,"Failed to shutdown persistence");t.reject(n)}})),t.promise}}async function wc(t,e){t.asyncQueue.verifyOperationInProgress(),v("FirestoreClient","Initializing OfflineComponentProvider");const n=await t.getConfiguration();await e.initialize(n);let s=n.initialUser;t.setCredentialChangeListener((async t=>{s.isEqual(t)||(await ns(e.localStore,t),s=t)})),e.persistence.setDatabaseDeletedListener((()=>t.terminate())),t.offlineComponents=e}async function vc(t,e){t.asyncQueue.verifyOperationInProgress();const n=await Tc(t);v("FirestoreClient","Initializing OnlineComponentProvider");const s=await t.getConfiguration();await e.initialize(n,s),t.setCredentialChangeListener((t=>ca(e.remoteStore,t))),t.setAppCheckTokenChangeListener(((t,n)=>ca(e.remoteStore,n))),t.onlineComponents=e}async function Tc(t){return t.offlineComponents||(v("FirestoreClient","Using default OfflineComponentProvider"),await wc(t,new uc)),t.offlineComponents}async function xc(t){return t.onlineComponents||(v("FirestoreClient","Using default OnlineComponentProvider"),await vc(t,new fc)),t.onlineComponents}function Sc(t){return Tc(t).then((t=>t.persistence))}function Ic(t){return Tc(t).then((t=>t.localStore))}function _c(t){return xc(t).then((t=>t.remoteStore))}function Ec(t){return xc(t).then((t=>t.syncEngine))}async function Oc(t){const e=await xc(t),n=e.eventManager;return n.onListen=ja.bind(null,e.syncEngine),n.onUnlisten=La.bind(null,e.syncEngine),n}function kc(t,e,n={}){const s=new D;return t.asyncQueue.enqueueAndForget((async()=>function(t,e,n,s,i){const r=new pc({next:r=>{e.enqueueAndForget((()=>va(t,o)));const u=r.docs.has(n);!u&&r.fromCache?i.reject(new C(k.UNAVAILABLE,"Failed to get document because the client is offline.")):u&&r.fromCache&&s&&"server"===s.source?i.reject(new C(k.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):i.resolve(r)},error:t=>i.reject(t)}),o=new Ia(Ue(n.path),r,{includeMetadataChanges:!0,Nu:!0});return wa(t,o)}(await Oc(t),t.asyncQueue,e,n,s))),s.promise}function Cc(t,e,n={}){const s=new D;return t.asyncQueue.enqueueAndForget((async()=>function(t,e,n,s,i){const r=new pc({next:n=>{e.enqueueAndForget((()=>va(t,o))),n.fromCache&&"server"===s.source?i.reject(new C(k.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):i.resolve(n)},error:t=>i.reject(t)}),o=new Ia(n,r,{includeMetadataChanges:!0,Nu:!0});return wa(t,o)}(await Oc(t),t.asyncQueue,e,n,s))),s.promise}function Dc(t,e,n,s){const i=function(t,e){let n;return n="string"==typeof t?(new TextEncoder).encode(t):t,function(t,e){return new mc(t,e)}(function(t,e){if(t instanceof Uint8Array)return dc(t,e);if(t instanceof ArrayBuffer)return dc(new Uint8Array(t),e);if(t instanceof ReadableStream)return t.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}(n),e)}(n,Ds(e));t.asyncQueue.enqueueAndForget((async()=>{!function(t,e,n){const s=O(t);(async function(t,e,n){try{const s=await e.getMetadata();if(await function(t,e){const n=O(t),s=yr(e.createTime);return n.persistence.runTransaction("hasNewerBundle","readonly",(t=>n.Ns.getBundleMetadata(t,e.id))).then((t=>!!t&&t.createTime.compareTo(s)>=0))}(t.localStore,s))return await e.close(),n._completeWith(function(t){return{taskState:"Success",documentsLoaded:t.totalDocuments,bytesLoaded:t.totalBytes,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}(s)),Promise.resolve(new Set);n._updateProgress(ka(s));const i=new Oa(s,t.localStore,e.It);let r=await e.wc();for(;r;){const t=await i.Ou(r);t&&n._updateProgress(t),r=await e.wc()}const o=await i.complete();return await Qa(t,o.Bu,void 0),await function(t,e){const n=O(t);return n.persistence.runTransaction("Save bundle","readwrite",(t=>n.Ns.saveBundleMetadata(t,e)))}(t.localStore,s),n._completeWith(o.progress),Promise.resolve(o.$u)}catch(t){return x("SyncEngine",`Loading bundle failed with ${t}`),n._failWith(t),Promise.resolve(new Set)}})(s,e,n).then((t=>{s.sharedClientState.notifyBundleLoaded(t)}))}(await Ec(t),i,s)}))}const Ac=new Map;function Nc(t,e,n){if(!n)throw new C(k.INVALID_ARGUMENT,`Function ${t}() cannot be called with an empty ${e}.`)}function Rc(t,e,n,s){if(!0===e&&!0===s)throw new C(k.INVALID_ARGUMENT,`${t} and ${n} cannot be used together.`)}function Pc(t){if(!W.isDocumentKey(t))throw new C(k.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`)}function jc(t){if(W.isDocumentKey(t))throw new C(k.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`)}function Mc(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return t.length>20&&(t=`${t.substring(0,20)}...`),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"==typeof t){if(t instanceof Array)return"an array";{const e=function(t){return t.constructor?t.constructor.name:null}(t);return e?`a custom ${e} object`:"an object"}}return"function"==typeof t?"a function":I()}function Lc(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new C(k.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=Mc(t);throw new C(k.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${n}`)}}return t}function Vc(t,e){if(e<=0)throw new C(k.INVALID_ARGUMENT,`Function ${t}() requires a positive number, but it was: ${e}.`)}class Bc{constructor(t){var e;if(void 0===t.host){if(void 0!==t.ssl)throw new C(k.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=t.host,this.ssl=null===(e=t.ssl)||void 0===e||e;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,void 0===t.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new C(k.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.useFetchStreams=!!t.useFetchStreams,Rc("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling)}isEqual(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}}class Fc{constructor(t,e,n,s){this._authCredentials=t,this._appCheckCredentials=e,this._databaseId=n,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Bc({}),this._settingsFrozen=!1}get app(){if(!this._app)throw new C(k.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return void 0!==this._terminateTask}_setSettings(t){if(this._settingsFrozen)throw new C(k.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 Bc(t),void 0!==t.credentials&&(this._authCredentials=function(t){if(!t)return new q;switch(t.type){case"gapi":const e=t.client;return new j(e,t.sessionIndex||"0",t.iamToken||null,t.authTokenFactory||null);case"provider":return t.client;default:throw new C(k.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(t.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){const e=Ac.get(t);e&&(v("ComponentProvider","Removing Datastore"),Ac.delete(t),e.terminate())}(this),Promise.resolve()}}function Uc(t,e,n,s={}){var i;const r=(t=Lc(t,Fc))._getSettings();if("firestore.googleapis.com"!==r.host&&r.host!==e&&x("Host has been set in both settings() and useEmulator(), emulator host will be used"),t._setSettings(Object.assign(Object.assign({},r),{host:`${e}:${n}`,ssl:!1})),s.mockUserToken){let e,n;if("string"==typeof s.mockUserToken)e=s.mockUserToken,n=b.MOCK_USER;else{e=Object(l.f)(s.mockUserToken,null===(i=t._app)||void 0===i?void 0:i.options.projectId);const r=s.mockUserToken.sub||s.mockUserToken.user_id;if(!r)throw new C(k.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");n=new b(r)}t._authCredentials=new N(new A(e,n))}}class qc{constructor(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new zc(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new qc(this.firestore,t,this._key)}}class $c{constructor(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}withConverter(t){return new $c(this.firestore,t,this._query)}}class zc extends $c{constructor(t,e,n){super(t,e,Ue(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new qc(this.firestore,null,new W(t))}withConverter(t){return new zc(this.firestore,t,this._path)}}function Gc(t,e,...n){if(t=Object(l.j)(t),Nc("collection","path",e),t instanceof Fc){const s=H.fromString(e,...n);return jc(s),new zc(t,null,s)}{if(!(t instanceof qc||t instanceof zc))throw new C(k.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const s=t._path.child(H.fromString(e,...n));return jc(s),new zc(t.firestore,null,s)}}function Kc(t,e){if(t=Lc(t,Fc),Nc("collectionGroup","collection id",e),e.indexOf("/")>=0)throw new C(k.INVALID_ARGUMENT,`Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new $c(t,null,function(t){return new Be(H.emptyPath(),t)}(e))}function Hc(t,e,...n){if(t=Object(l.j)(t),1===arguments.length&&(e=B.R()),Nc("doc","path",e),t instanceof Fc){const s=H.fromString(e,...n);return Pc(s),new qc(t,null,new W(s))}{if(!(t instanceof qc||t instanceof zc))throw new C(k.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const s=t._path.child(H.fromString(e,...n));return Pc(s),new qc(t.firestore,t instanceof zc?t.converter:null,new W(s))}}function Yc(t,e){return t=Object(l.j)(t),e=Object(l.j)(e),(t instanceof qc||t instanceof zc)&&(e instanceof qc||e instanceof zc)&&t.firestore===e.firestore&&t.path===e.path&&t.converter===e.converter}function Wc(t,e){return t=Object(l.j)(t),e=Object(l.j)(e),t instanceof $c&&e instanceof $c&&t.firestore===e.firestore&&We(t._query,e._query)&&t.converter===e.converter}class Qc{constructor(){this.$c=Promise.resolve(),this.Bc=[],this.Lc=!1,this.Uc=[],this.qc=null,this.Kc=!1,this.Gc=!1,this.Qc=[],this.xo=new As(this,"async_queue_retry"),this.jc=()=>{const t=Cs();t&&v("AsyncQueue","Visibility state changed to "+t.visibilityState),this.xo.bo()};const t=Cs();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.jc)}get isShuttingDown(){return this.Lc}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.Wc(),this.zc(t)}enterRestrictedMode(t){if(!this.Lc){this.Lc=!0,this.Gc=t||!1;const e=Cs();e&&"function"==typeof e.removeEventListener&&e.removeEventListener("visibilitychange",this.jc)}}enqueue(t){if(this.Wc(),this.Lc)return new Promise((()=>{}));const e=new D;return this.zc((()=>this.Lc&&this.Gc?Promise.resolve():(t().then(e.resolve,e.reject),e.promise))).then((()=>e.promise))}enqueueRetryable(t){this.enqueueAndForget((()=>(this.Bc.push(t),this.Hc())))}async Hc(){if(0!==this.Bc.length){try{await this.Bc[0](),this.Bc.shift(),this.xo.reset()}catch(t){if(!mt(t))throw t;v("AsyncQueue","Operation failed with retryable error: "+t)}this.Bc.length>0&&this.xo.Ao((()=>this.Hc()))}}zc(t){const e=this.$c.then((()=>(this.Kc=!0,t().catch((t=>{this.qc=t,this.Kc=!1;const e=function(t){let e=t.message||"";return t.stack&&(e=t.stack.includes(t.message)?t.stack:t.message+"\n"+t.stack),e}(t);throw T("INTERNAL UNHANDLED ERROR: ",e),t})).then((t=>(this.Kc=!1,t))))));return this.$c=e,e}enqueueAfterDelay(t,e,n){this.Wc(),this.Qc.indexOf(t)>-1&&(e=0);const s=fa.createAndSchedule(this,t,e,n,(t=>this.Jc(t)));return this.Uc.push(s),s}Wc(){this.qc&&I()}verifyOperationInProgress(){}async Yc(){let t;do{t=this.$c,await t}while(t!==this.$c)}Xc(t){for(const e of this.Uc)if(e.timerId===t)return!0;return!1}Zc(t){return this.Yc().then((()=>{this.Uc.sort(((t,e)=>t.targetTimeMs-e.targetTimeMs));for(const e of this.Uc)if(e.skipDelay(),"all"!==t&&e.timerId===t)break;return this.Yc()}))}ta(t){this.Qc.push(t)}Jc(t){const e=this.Uc.indexOf(t);this.Uc.splice(e,1)}}function Xc(t){return function(t,e){if("object"!=typeof t||null===t)return!1;const n=t;for(const t of["next","error","complete"])if(t in n&&"function"==typeof n[t])return!0;return!1}(t)}class Jc{constructor(){this._progressObserver={},this._taskCompletionResolver=new D,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(t,e,n){this._progressObserver={next:t,error:e,complete:n}}catch(t){return this._taskCompletionResolver.promise.catch(t)}then(t,e){return this._taskCompletionResolver.promise.then(t,e)}_completeWith(t){this._updateProgress(t),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(t)}_failWith(t){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(t),this._taskCompletionResolver.reject(t)}_updateProgress(t){this._lastProgress=t,this._progressObserver.next&&this._progressObserver.next(t)}}const Zc=-1;class tu extends Fc{constructor(t,e,n,s){super(t,e,n,s),this.type="firestore",this._queue=new Qc,this._persistenceKey=(null==s?void 0:s.name)||"[DEFAULT]"}_terminate(){return this._firestoreClient||nu(this),this._firestoreClient.terminate()}}function eu(t){return t._firestoreClient||nu(t),t._firestoreClient.verifyNotTerminated(),t._firestoreClient}function nu(t){var e;const n=t._freezeSettings(),s=function(t,e,n,s){return new qt(t,e,n,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,s.useFetchStreams)}(t._databaseId,(null===(e=t._app)||void 0===e?void 0:e.options.appId)||"",t._persistenceKey,n);t._firestoreClient=new bc(t._authCredentials,t._appCheckCredentials,t._queue,s)}function ru(t,e){fu(t=Lc(t,tu));const n=eu(t),s=t._freezeSettings(),i=new fc;return ou(n,i,new lc(i,s.cacheSizeBytes,null==e?void 0:e.forceOwnership))}function iu(t){fu(t=Lc(t,tu));const e=eu(t),n=t._freezeSettings(),s=new fc;return ou(e,s,new hc(s,n.cacheSizeBytes))}function ou(t,e,n){const s=new D;return t.asyncQueue.enqueue((async()=>{try{await wc(t,n),await vc(t,e),s.resolve()}catch(t){const e=t;if(!function(t){return"FirebaseError"===t.name?t.code===k.FAILED_PRECONDITION||t.code===k.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||(22===t.code||20===t.code||11===t.code)}(e))throw e;x("Error enabling offline persistence. Falling back to persistence disabled: "+e),s.reject(e)}})).then((()=>s.promise))}function su(t){if(t._initialized&&!t._terminated)throw new C(k.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const e=new D;return t._queue.enqueueAndForgetEvenWhileRestricted((async()=>{try{await async function(t){if(!ht.C())return Promise.resolve();const e=t+"main";await ht.delete(e)}(Xo(t._databaseId,t._persistenceKey)),e.resolve()}catch(t){e.reject(t)}})),e.promise}function au(t){return function(t){const e=new D;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e){const n=O(t);Ks(n.remoteStore)||v("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{const t=await function(t){const e=O(t);return e.persistence.runTransaction("Get highest unacknowledged batch id","readonly",(t=>e.mutationQueue.getHighestUnacknowledgedBatchId(t)))}(n.localStore);if(-1===t)return void e.resolve();const s=n.hc.get(t)||[];s.push(e),n.hc.set(t,s)}catch(t){const n=da(t,"Initialization of waitForPendingWrites() operation failed");e.reject(n)}}(await Ec(t),e))),e.promise}(eu(t=Lc(t,tu)))}function cu(t){return function(t){return t.asyncQueue.enqueue((async()=>{const e=await Sc(t),n=await _c(t);return e.setNetworkEnabled(!0),function(t){const e=O(t);return e._u.delete(0),Vs(e)}(n)}))}(eu(t=Lc(t,tu)))}function uu(t){return function(t){return t.asyncQueue.enqueue((async()=>{const e=await Sc(t),n=await _c(t);return e.setNetworkEnabled(!1),async function(t){const e=O(t);e._u.add(0),await Bs(e),e.gu.set("Offline")}(n)}))}(eu(t=Lc(t,tu)))}function lu(t,e){const n=eu(t=Lc(t,tu)),s=new Jc;return Dc(n,t._databaseId,e,s),s}function hu(t,e){return function(t,e){return t.asyncQueue.enqueue((async()=>function(t,e){const n=O(t);return n.persistence.runTransaction("Get named query","readonly",(t=>n.Ns.getNamedQuery(t,e)))}(await Ic(t),e)))}(eu(t=Lc(t,tu)),e).then((e=>e?new $c(t,null,e.query):null))}function fu(t){if(t._initialized||t._terminated)throw new C(k.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.")}class du{constructor(...t){for(let e=0;e90)throw new C(k.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new C(k.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(t){return F(this._lat,t._lat)||F(this._long,t._long)}}const th=/^__.*__$/;class yu{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return null!==this.fieldMask?new Cn(t,this.data,this.fieldMask,e,this.fieldTransforms):new kn(t,this.data,e,this.fieldTransforms)}}class bu{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return new Cn(t,this.data,this.fieldMask,e,this.fieldTransforms)}}function wu(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw I()}}class vu{constructor(t,e,n,s,i,r){this.settings=t,this.databaseId=e,this.It=n,this.ignoreUndefinedProperties=s,void 0===i&&this.ea(),this.fieldTransforms=i||[],this.fieldMask=r||[]}get path(){return this.settings.path}get na(){return this.settings.na}sa(t){return new vu(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.It,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}ia(t){var e;const n=null===(e=this.path)||void 0===e?void 0:e.child(t),s=this.sa({path:n,ra:!1});return s.oa(t),s}ua(t){var e;const n=null===(e=this.path)||void 0===e?void 0:e.child(t),s=this.sa({path:n,ra:!1});return s.ea(),s}ca(t){return this.sa({path:void 0,ra:!0})}aa(t){return Fu(t,this.settings.methodName,this.settings.ha||!1,this.path,this.settings.la)}contains(t){return void 0!==this.fieldMask.find((e=>t.isPrefixOf(e)))||void 0!==this.fieldTransforms.find((e=>t.isPrefixOf(e.field)))}ea(){if(this.path)for(let t=0;tc.covers(t.field)))}else c=null,a=o.fieldTransforms;return new yu(new pe(u),c,a)}class Iu extends mu{_toFieldTransform(t){if(2!==t.na)throw 1===t.na?t.aa(`${this._methodName}() can only appear at the top level of your update data`):t.aa(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof Iu}}function _u(t,e,n){return new vu({na:3,la:e.settings.la,methodName:t._methodName,ra:n},e.databaseId,e.It,e.ignoreUndefinedProperties)}class Eu extends mu{_toFieldTransform(t){return new bn(t.path,new ln)}isEqual(t){return t instanceof Eu}}class Ou extends mu{constructor(t,e){super(t),this.da=e}_toFieldTransform(t){const e=_u(this,t,!0),n=this.da.map((t=>Ru(t,e))),s=new hn(n);return new bn(t.path,s)}isEqual(t){return this===t}}class ku extends mu{constructor(t,e){super(t),this.da=e}_toFieldTransform(t){const e=_u(this,t,!0),n=this.da.map((t=>Ru(t,e))),s=new dn(n);return new bn(t.path,s)}isEqual(t){return this===t}}class Cu extends mu{constructor(t,e){super(t),this._a=e}_toFieldTransform(t){const e=new mn(t.It,on(t.It,this._a));return new bn(t.path,e)}isEqual(t){return this===t}}function Du(t,e,n,s){const i=t.fa(1,e,n);Mu("Data must be an object, but it was:",i,s);const r=[],o=pe.empty();It(s,((t,s)=>{const u=Bu(e,t,n);s=Object(l.j)(s);const c=i.ua(u);if(s instanceof Iu)r.push(u);else{const t=Ru(s,c);null!=t&&(r.push(u),o.set(u,t))}}));const u=new Nt(r);return new bu(o,u,i.fieldTransforms)}function Au(t,e,n,s,i,r){const o=t.fa(1,e,n),u=[Lu(e,s,n)],c=[i];if(r.length%2!=0)throw new C(k.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let t=0;t=0;--t)if(!Uu(a,u[t])){const e=u[t];let n=c[t];n=Object(l.j)(n);const s=o.ua(e);if(n instanceof Iu)a.push(e);else{const t=Ru(n,s);null!=t&&(a.push(e),h.set(e,t))}}const f=new Nt(a);return new bu(h,f,o.fieldTransforms)}function Nu(t,e,n,s=!1){return Ru(n,t.fa(s?4:3,e))}function Ru(t,e){if(ju(t=Object(l.j)(t)))return Mu("Unsupported field value:",e,t),Pu(t,e);if(t instanceof mu)return function(t,e){if(!wu(e.na))throw e.aa(`${t._methodName}() can only be used with update() and set()`);if(!e.path)throw e.aa(`${t._methodName}() is not currently supported inside arrays`);const n=t._toFieldTransform(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(void 0===t&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.settings.ra&&4!==e.na)throw e.aa("Nested arrays are not supported");return function(t,e){const n=[];let s=0;for(const i of t){let t=Ru(i,e.ca(s));null==t&&(t={nullValue:"NULL_VALUE"}),n.push(t),s++}return{arrayValue:{values:n}}}(t,e)}return function(t,e){if(null===(t=Object(l.j)(t)))return{nullValue:"NULL_VALUE"};if("number"==typeof t)return on(e.It,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){const n=z.fromDate(t);return{timestampValue:pr(e.It,n)}}if(t instanceof z){const n=new z(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:pr(e.It,n)}}if(t instanceof gu)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof pu)return{bytesValue:mr(e.It,t._byteString)};if(t instanceof qc){const n=e.databaseId,s=t.firestore._databaseId;if(!s.isEqual(n))throw e.aa(`Document reference is for database ${s.projectId}/${s.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:wr(t.firestore._databaseId||e.databaseId,t._key.path)}}throw e.aa(`Unsupported field value: ${Mc(t)}`)}(t,e)}function Pu(t,e){const n={};return _t(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):It(t,((t,s)=>{const i=Ru(s,e.ia(t));null!=i&&(n[t]=i)})),{mapValue:{fields:n}}}function ju(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof z||t instanceof gu||t instanceof pu||t instanceof qc||t instanceof mu)}function Mu(t,e,n){if(!ju(n)||!function(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}(n)){const s=Mc(n);throw"an object"===s?e.aa(t+" a custom object"):e.aa(t+" "+s)}}function Lu(t,e,n){if((e=Object(l.j)(e))instanceof du)return e._internalPath;if("string"==typeof e)return Bu(t,e);throw Fu("Field path arguments must be of type string or ",t,!1,void 0,n)}const Vu=new RegExp("[~\\*/\\[\\]]");function Bu(t,e,n){if(e.search(Vu)>=0)throw Fu(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,n);try{return new du(...e.split("."))._internalPath}catch(r){throw Fu(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,n)}}function Fu(t,e,n,s,i){const r=s&&!s.isEmpty(),o=void 0!==i;let u=`Function ${e}() called with invalid data`;n&&(u+=" (via `toFirestore()`)"),u+=". ";let c="";return(r||o)&&(c+=" (found",r&&(c+=` in field ${s}`),o&&(c+=` in document ${i}`),c+=")"),new C(k.INVALID_ARGUMENT,u+t+c)}function Uu(t,e){return t.some((t=>t.isEqual(e)))}class qu{constructor(t,e,n,s,i){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=s,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new qc(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const t=new $u(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}get(t){if(this._document){const e=this._document.data.field(zu("DocumentSnapshot.get",t));if(null!==e)return this._userDataWriter.convertValue(e)}}}class $u extends qu{data(){return super.data()}}function zu(t,e){return"string"==typeof e?Bu(t,e):e instanceof du?e._internalPath:e._delegate._internalPath}class Gu{constructor(t,e){this.hasPendingWrites=t,this.fromCache=e}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}}class Ku extends qu{constructor(t,e,n,s,i,r){super(t,e,n,s,r),this._firestore=t,this._firestoreImpl=t,this.metadata=i}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){const e=new Hu(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}}get(t,e={}){if(this._document){const n=this._document.data.field(zu("DocumentSnapshot.get",t));if(null!==n)return this._userDataWriter.convertValue(n,e.serverTimestamps)}}}class Hu extends Ku{data(t={}){return super.data(t)}}class Yu{constructor(t,e,n,s){this._firestore=t,this._userDataWriter=e,this._snapshot=s,this.metadata=new Gu(s.hasPendingWrites,s.fromCache),this.query=n}get docs(){const t=[];return this.forEach((e=>t.push(e))),t}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(t,e){this._snapshot.docs.forEach((n=>{t.call(e,new Hu(this._firestore,this._userDataWriter,n.key,n,new Gu(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(t={}){const e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new C(k.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(t,e){if(t._snapshot.oldDocs.isEmpty()){let e=0;return t._snapshot.docChanges.map((n=>({type:"added",doc:new Hu(t._firestore,t._userDataWriter,n.doc.key,n.doc,new Gu(t._snapshot.mutatedKeys.has(n.doc.key),t._snapshot.fromCache),t.query.converter),oldIndex:-1,newIndex:e++})))}{let n=t._snapshot.oldDocs;return t._snapshot.docChanges.filter((t=>e||3!==t.type)).map((e=>{const s=new Hu(t._firestore,t._userDataWriter,e.doc.key,e.doc,new Gu(t._snapshot.mutatedKeys.has(e.doc.key),t._snapshot.fromCache),t.query.converter);let i=-1,r=-1;return 0!==e.type&&(i=n.indexOf(e.doc.key),n=n.delete(e.doc.key)),1!==e.type&&(n=n.add(e.doc),r=n.indexOf(e.doc.key)),{type:Wu(e.type),doc:s,oldIndex:i,newIndex:r}}))}}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges}}function Wu(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return I()}}function Qu(t,e){return t instanceof Ku&&e instanceof Ku?t._firestore===e._firestore&&t._key.isEqual(e._key)&&(null===t._document?null===e._document:t._document.isEqual(e._document))&&t._converter===e._converter:t instanceof Yu&&e instanceof Yu&&t._firestore===e._firestore&&Wc(t.query,e.query)&&t.metadata.isEqual(e.metadata)&&t._snapshot.isEqual(e._snapshot)}function Xu(t){if("L"===t.limitType&&0===t.explicitOrderBy.length)throw new C(k.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Ju{}function Zu(t,...e){for(const n of e)t=n._apply(t);return t}class tl extends Ju{constructor(t,e,n){super(),this.wa=t,this.ma=e,this.ga=n,this.type="where"}_apply(t){const e=xu(t.firestore),n=function(t,e,n,s,i,r,o){let u;if(i.isKeyField()){if("array-contains"===r||"array-contains-any"===r)throw new C(k.INVALID_ARGUMENT,`Invalid Query. You can't perform '${r}' queries on documentId().`);if("in"===r||"not-in"===r){bl(o,r);const e=[];for(const n of o)e.push(yl(s,t,n));u={arrayValue:{values:e}}}else u=yl(s,t,o)}else"in"!==r&&"not-in"!==r&&"array-contains-any"!==r||bl(o,r),u=Nu(n,"where",o,"in"===r||"not-in"===r);const c=_e.create(i,r,u);return function(t,e){if(e.dt()){const n=ze(t);if(null!==n&&!n.isEqual(e.field))throw new C(k.INVALID_ARGUMENT,`Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${e.field.toString()}'`);const s=$e(t);null!==s&&wl(t,e.field,s)}const n=function(t,e){for(const n of t.filters)if(e.indexOf(n.op)>=0)return n.op;return null}(t,function(t){switch(t){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(null!==n)throw n===e.op?new C(k.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new C(k.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`)}(t,c),c}(t._query,0,e,t.firestore._databaseId,this.wa,this.ma,this.ga);return new $c(t.firestore,t.converter,function(t,e){const n=t.filters.concat([e]);return new Be(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}(t._query,n))}}function el(t,e,n){const s=e,i=zu("where",t);return new tl(i,s,n)}class nl extends Ju{constructor(t,e){super(),this.wa=t,this.ya=e,this.type="orderBy"}_apply(t){const e=function(t,e,n){if(null!==t.startAt)throw new C(k.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new C(k.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");const s=new je(e,n);return function(t,e){if(null===$e(t)){const n=ze(t);null!==n&&wl(t,n,e.field)}}(t,s),s}(t._query,this.wa,this.ya);return new $c(t.firestore,t.converter,function(t,e){const n=t.explicitOrderBy.concat([e]);return new Be(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(t._query,e))}}function rl(t,e="asc"){const n=e,s=zu("orderBy",t);return new nl(s,n)}class il extends Ju{constructor(t,e,n){super(),this.type=t,this.pa=e,this.Ia=n}_apply(t){return new $c(t.firestore,t.converter,Ye(t._query,this.pa,this.Ia))}}function sl(t){return Vc("limit",t),new il("limit",t,"F")}function al(t){return Vc("limitToLast",t),new il("limitToLast",t,"L")}class cl extends Ju{constructor(t,e,n){super(),this.type=t,this.Ta=e,this.Ea=n}_apply(t){const e=gl(t,this.type,this.Ta,this.Ea);return new $c(t.firestore,t.converter,function(t,e){return new Be(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)}(t._query,e))}}function ll(...t){return new cl("startAt",t,!0)}function hl(...t){return new cl("startAfter",t,!1)}class fl extends Ju{constructor(t,e,n){super(),this.type=t,this.Ta=e,this.Ea=n}_apply(t){const e=gl(t,this.type,this.Ta,this.Ea);return new $c(t.firestore,t.converter,function(t,e){return new Be(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)}(t._query,e))}}function pl(...t){return new fl("endBefore",t,!1)}function ml(...t){return new fl("endAt",t,!0)}function gl(t,e,n,s){if(n[0]=Object(l.j)(n[0]),n[0]instanceof qu)return function(t,e,n,s,i){if(!s)throw new C(k.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);const r=[];for(const n of Ke(t))if(n.field.isKeyField())r.push(ne(e,s.key));else{const t=s.data.field(n.field);if(Bt(t))throw new C(k.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+n.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===t){const t=n.field.canonicalString();throw new C(k.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`)}r.push(t)}return new Pe(r,i)}(t._query,t.firestore._databaseId,e,n[0]._document,s);{const i=xu(t.firestore);return function(t,e,n,s,i,r){const o=t.explicitOrderBy;if(i.length>o.length)throw new C(k.INVALID_ARGUMENT,`Too many arguments provided to ${s}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const u=[];for(let r=0;r10)throw new C(k.INVALID_ARGUMENT,`Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`)}function wl(t,e,n){if(!n.isEqual(e))throw new C(k.INVALID_ARGUMENT,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}const vl={maxAttempts:5};class Tl{convertValue(t,e="none"){switch(Wt(t)){case 0:return null;case 1:return t.booleanValue;case 2:return Lt(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(Vt(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 10:return this.convertObject(t.mapValue,e);default:throw I()}}convertObject(t,e){const n={};return It(t.fields,((t,s)=>{n[t]=this.convertValue(s,e)})),n}convertGeoPoint(t){return new gu(Lt(t.latitude),Lt(t.longitude))}convertArray(t,e){return(t.values||[]).map((t=>this.convertValue(t,e)))}convertServerTimestamp(t,e){switch(e){case"previous":const n=Ft(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(Ut(t));default:return null}}convertTimestamp(t){const e=Mt(t);return new z(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=H.fromString(t);_(qr(n));const s=new $t(n.get(1),n.get(3)),i=new W(n.popFirst(5));return s.isEqual(e)||T(`Document ${i} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),i}}function xl(t,e,n){let s;return s=t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e,s}class Sl extends Tl{constructor(t){super(),this.firestore=t}convertBytes(t){return new pu(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new qc(this.firestore,null,e)}}class Il{constructor(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=xu(t)}set(t,e,n){this._verifyNotCommitted();const s=ol(t,this._firestore),i=xl(s.converter,e,n),r=Su(this._dataReader,"WriteBatch.set",s._key,i,null!==s.converter,n);return this._mutations.push(r.toMutation(s._key,vn.none())),this}update(t,e,n,...s){this._verifyNotCommitted();const i=ol(t,this._firestore);let r;return r="string"==typeof(e=Object(l.j)(e))||e instanceof du?Au(this._dataReader,"WriteBatch.update",i._key,e,n,s):Du(this._dataReader,"WriteBatch.update",i._key,e),this._mutations.push(r.toMutation(i._key,vn.exists(!0))),this}delete(t){this._verifyNotCommitted();const e=ol(t,this._firestore);return this._mutations=this._mutations.concat(new Rn(e._key,vn.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new C(k.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function ol(t,e){if((t=Object(l.j)(t)).firestore!==e)throw new C(k.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return t}function ul(t){t=Lc(t,qc);const e=Lc(t.firestore,tu);return kc(eu(e),t._key).then((n=>Ll(e,t,n)))}class _l extends Tl{constructor(t){super(),this.firestore=t}convertBytes(t){return new pu(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new qc(this.firestore,null,e)}}function El(t){t=Lc(t,qc);const e=Lc(t.firestore,tu),n=eu(e),s=new _l(e);return function(t,e){const n=new D;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e,n){try{const s=await function(t,e){const n=O(t);return n.persistence.runTransaction("read document","readonly",(t=>n.localDocuments.getDocument(t,e)))}(t,e);s.isFoundDocument()?n.resolve(s):s.isNoDocument()?n.resolve(null):n.reject(new C(k.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(t){const s=da(t,`Failed to get document '${e} from cache`);n.reject(s)}}(await Ic(t),e,n))),n.promise}(n,t._key).then((n=>new Ku(e,s,t._key,n,new Gu(null!==n&&n.hasLocalMutations,!0),t.converter)))}function Ol(t){t=Lc(t,qc);const e=Lc(t.firestore,tu);return kc(eu(e),t._key,{source:"server"}).then((n=>Ll(e,t,n)))}function kl(t){t=Lc(t,$c);const e=Lc(t.firestore,tu),n=eu(e),s=new _l(e);return Xu(t._query),Cc(n,t._query).then((n=>new Yu(e,s,t,n)))}function Cl(t){t=Lc(t,$c);const e=Lc(t.firestore,tu),n=eu(e),s=new _l(e);return function(t,e){const n=new D;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e,n){try{const s=await cs(t,e,!0),i=new Aa(e,s.Hi),r=i.ju(s.documents),o=i.applyChanges(r,!1);n.resolve(o.snapshot)}catch(t){const s=da(t,`Failed to execute query '${e} against cache`);n.reject(s)}}(await Ic(t),e,n))),n.promise}(n,t._query).then((n=>new Yu(e,s,t,n)))}function dl(t){t=Lc(t,$c);const e=Lc(t.firestore,tu),n=eu(e),s=new _l(e);return Cc(n,t._query,{source:"server"}).then((n=>new Yu(e,s,t,n)))}function Dl(t,e,n){t=Lc(t,qc);const s=Lc(t.firestore,tu),i=xl(t.converter,e,n);return Ml(s,[Su(xu(s),"setDoc",t._key,i,null!==t.converter,n).toMutation(t._key,vn.none())])}function Al(t,e,n,...s){t=Lc(t,qc);const i=Lc(t.firestore,tu),r=xu(i);let o;return o="string"==typeof(e=Object(l.j)(e))||e instanceof du?Au(r,"updateDoc",t._key,e,n,s):Du(r,"updateDoc",t._key,e),Ml(i,[o.toMutation(t._key,vn.exists(!0))])}function Nl(t){return Ml(Lc(t.firestore,tu),[new Rn(t._key,vn.none())])}function Rl(t,e){const n=Lc(t.firestore,tu),s=Hc(t),i=xl(t.converter,e);return Ml(n,[Su(xu(t.firestore),"addDoc",s._key,i,null!==t.converter,{}).toMutation(s._key,vn.exists(!1))]).then((()=>s))}function Pl(t,...e){var n,s,i;t=Object(l.j)(t);let r={includeMetadataChanges:!1},o=0;"object"!=typeof e[o]||Xc(e[o])||(r=e[o],o++);const u={includeMetadataChanges:r.includeMetadataChanges};if(Xc(e[o])){const t=e[o];e[o]=null===(n=t.next)||void 0===n?void 0:n.bind(t),e[o+1]=null===(s=t.error)||void 0===s?void 0:s.bind(t),e[o+2]=null===(i=t.complete)||void 0===i?void 0:i.bind(t)}let c,a,h;if(t instanceof qc)a=Lc(t.firestore,tu),h=Ue(t._key.path),c={next:n=>{e[o]&&e[o](Ll(a,t,n))},error:e[o+1],complete:e[o+2]};else{const n=Lc(t,$c);a=Lc(n.firestore,tu),h=n._query;const s=new _l(a);c={next:t=>{e[o]&&e[o](new Yu(a,s,n,t))},error:e[o+1],complete:e[o+2]},Xu(t._query)}return function(t,e,n,s){const i=new pc(s),r=new Ia(e,i,n);return t.asyncQueue.enqueueAndForget((async()=>wa(await Oc(t),r))),()=>{i.Rc(),t.asyncQueue.enqueueAndForget((async()=>va(await Oc(t),r)))}}(eu(a),h,u,c)}function jl(t,e){return function(t,e){const n=new pc(e);return t.asyncQueue.enqueueAndForget((async()=>function(t,e){O(t).Ru.add(e),e.next()}(await Oc(t),n))),()=>{n.Rc(),t.asyncQueue.enqueueAndForget((async()=>function(t,e){O(t).Ru.delete(e)}(await Oc(t),n)))}}(eu(t=Lc(t,tu)),Xc(e)?e:{next:e})}function Ml(t,e){return function(t,e){const n=new D;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e,n){const s=cc(t);try{const t=await function(t,e){const n=O(t),s=z.now(),i=e.reduce(((t,e)=>t.add(e.key)),Xn());let r,o;return n.persistence.runTransaction("Locally write mutations","readwrite",(t=>{let u=qn(),c=Xn();return n.Gi.getEntries(t,i).next((t=>{u=t,u.forEach(((t,e)=>{e.isValidDocument()||(c=c.add(t))}))})).next((()=>n.localDocuments.getOverlayedDocuments(t,u))).next((i=>{r=i;const o=[];for(const t of e){const e=En(t,r.get(t.key).overlayedDocument);null!=e&&o.push(new Cn(t.key,e,me(e.value.mapValue),vn.exists(!0)))}return n.mutationQueue.addMutationBatch(t,s,o,e)})).next((e=>{o=e;const s=e.applyToLocalDocumentSet(r,c);return n.documentOverlayCache.saveOverlays(t,e.batchId,s)}))})).then((()=>({batchId:o.batchId,changes:Gn(r)})))}(s.localStore,e);s.sharedClientState.addPendingMutation(t.batchId),function(t,e,n){let s=t.ac[t.currentUser.toKey()];s||(s=new Et(F)),s=s.insert(e,n),t.ac[t.currentUser.toKey()]=s}(s,t.batchId,n),await Qa(s,t.changes),await Zs(s.remoteStore)}catch(t){const e=da(t,"Failed to persist write");n.reject(e)}}(await Ec(t),e,n))),n.promise}(eu(t),e)}function Ll(t,e,n){const s=n.docs.get(e._key),i=new _l(t);return new Ku(t,i,e._key,s,new Gu(n.hasPendingWrites,n.fromCache),e.converter)}class Vl extends class{constructor(t,e){this._firestore=t,this._transaction=e,this._dataReader=xu(t)}get(t){const e=ol(t,this._firestore),n=new Sl(this._firestore);return this._transaction.lookup([e._key]).then((t=>{if(!t||1!==t.length)return I();const s=t[0];if(s.isFoundDocument())return new qu(this._firestore,n,s.key,s,e.converter);if(s.isNoDocument())return new qu(this._firestore,n,e._key,null,e.converter);throw I()}))}set(t,e,n){const s=ol(t,this._firestore),i=xl(s.converter,e,n),r=Su(this._dataReader,"Transaction.set",s._key,i,null!==s.converter,n);return this._transaction.set(s._key,r),this}update(t,e,n,...s){const i=ol(t,this._firestore);let r;return r="string"==typeof(e=Object(l.j)(e))||e instanceof du?Au(this._dataReader,"Transaction.update",i._key,e,n,s):Du(this._dataReader,"Transaction.update",i._key,e),this._transaction.update(i._key,r),this}delete(t){const e=ol(t,this._firestore);return this._transaction.delete(e._key),this}}{constructor(t,e){super(t,e),this._firestore=t}get(t){const e=ol(t,this._firestore),n=new _l(this._firestore);return super.get(t).then((t=>new Ku(this._firestore,n,e._key,t._document,new Gu(!1,!1),e.converter)))}}function Bl(t,e,n){t=Lc(t,tu);const s=Object.assign(Object.assign({},vl),n);return function(t){if(t.maxAttempts<1)throw new C(k.INVALID_ARGUMENT,"Max attempts must be at least 1")}(s),function(t,e,n){const s=new D;return t.asyncQueue.enqueueAndForget((async()=>{const i=await function(t){return xc(t).then((t=>t.datastore))}(t);new yc(t.asyncQueue,i,n,e,s).run()})),s.promise}(eu(t),(n=>e(new Vl(t,n))),s)}function Fl(){return new Iu("deleteField")}function Ul(){return new Eu("serverTimestamp")}function ql(...t){return new Ou("arrayUnion",t)}function $l(...t){return new ku("arrayRemove",t)}function zl(t){return new Cu("increment",t)}!function(t,e=!0){!function(t){d=t}(r.SDK_VERSION),Object(r._registerComponent)(new o.a("firestore",((t,{instanceIdentifier:n,options:s})=>{const i=t.getProvider("app").getImmediate(),r=new tu(new R(t.getProvider("auth-internal")),new L(t.getProvider("app-check-internal")),function(t,e){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new C(k.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new $t(t.options.projectId,e)}(i,n),i);return s=Object.assign({useFetchStreams:e},s),r._setSettings(s),r}),"PUBLIC").setMultipleInstances(!0)),Object(r.registerVersion)(f,"3.5.0",t),Object(r.registerVersion)(f,"3.5.0","esm2017")}()}).call(this,n(118))},16:function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}n.d(e,"a",(function(){return r}))},161:function(t,e,n){"use strict";e.a=function(t,e){return e=e||{},new Promise((function(n,r){var s=new XMLHttpRequest,o=[],u=[],i={},a=function(){return{ok:2==(s.status/100|0),statusText:s.statusText,status:s.status,url:s.responseURL,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(s.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([s.response]))},clone:a,headers:{keys:function(){return o},entries:function(){return u},get:function(t){return i[t.toLowerCase()]},has:function(t){return t.toLowerCase()in i}}}};for(var c in s.open(e.method||"get",t,!0),s.onload=function(){s.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(t,e,n){o.push(e=e.toLowerCase()),u.push([e,n]),i[e]=i[e]?i[e]+","+n:n})),n(a())},s.onerror=r,s.withCredentials="include"==e.credentials,e.headers)s.setRequestHeader(c,e.headers[c]);s.send(e.body||null)}))}},163:function(t,e,n){"use strict";var r=function(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===o}(t)}(t)};var o="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function c(t,e){return!1!==e.clone&&e.isMergeableObject(t)?m((n=t,Array.isArray(n)?[]:{}),t,e):t;var n}function l(t,source,e){return t.concat(source).map((function(element){return c(element,e)}))}function h(t){return Object.keys(t).concat(function(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter((function(symbol){return t.propertyIsEnumerable(symbol)})):[]}(t))}function f(object,t){try{return t in object}catch(t){return!1}}function d(t,source,e){var n={};return e.isMergeableObject(t)&&h(t).forEach((function(r){n[r]=c(t[r],e)})),h(source).forEach((function(r){(function(t,e){return f(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,r)||(f(t,r)&&e.isMergeableObject(source[r])?n[r]=function(t,e){if(!e.customMerge)return m;var n=e.customMerge(t);return"function"==typeof n?n:m}(r,e)(t[r],source[r],e):n[r]=c(source[r],e))})),n}function m(t,source,e){(e=e||{}).arrayMerge=e.arrayMerge||l,e.isMergeableObject=e.isMergeableObject||r,e.cloneUnlessOtherwiseSpecified=c;var n=Array.isArray(source);return n===Array.isArray(t)?n?e.arrayMerge(t,source,e):d(t,source,e):c(source,e)}m.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce((function(t,n){return m(t,n,e)}),{})};var y=m;t.exports=y},164:function(t,e,n){"use strict";n.d(e,"a",(function(){return h}));var r=n(10);n(18),n(88),n(89);function o(t){return null!==t&&"object"===Object(r.a)(t)}function c(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".",r=arguments.length>3?arguments[3]:void 0;if(!o(e))return c(t,{},n,r);var l=Object.assign({},e);for(var h in t)if("__proto__"!==h&&"constructor"!==h){var f=t[h];null!=f&&(r&&r(l,h,f,n)||(Array.isArray(f)&&Array.isArray(l[h])?l[h]=l[h].concat(f):o(f)&&o(l[h])?l[h]=c(f,l[h],(n?"".concat(n,"."):"")+h.toString(),r):l[h]=f))}return l}function l(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r0)?["touchstart"]:["click"];function i(t){var e=t.event,n=t.handler;(0,t.middleware)(e)&&n(e)}function a(e,n){var a=function(t){var e="function"==typeof t;if(!e&&"object"!=typeof t)throw new Error("v-click-outside: Binding value must be a function or an object");return{handler:e?t:t.handler,middleware:t.middleware||function(t){return t},events:t.events||r,isActive:!(!1===t.isActive),detectIframe:!(!1===t.detectIframe),capture:!!t.capture}}(n.value),o=a.handler,c=a.middleware,l=a.detectIframe,u=a.capture;if(a.isActive){if(e[t]=a.events.map((function(t){return{event:t,srcTarget:document.documentElement,handler:function(t){return function(t){var e=t.el,n=t.event,r=t.handler,a=t.middleware,o=n.composedPath&&n.composedPath()||n.path;(o?o.indexOf(e)<0:!e.contains(n.target))&&i({event:n,handler:r,middleware:a})}({el:e,event:t,handler:o,middleware:c})},capture:u}})),l){var h={event:"blur",srcTarget:window,handler:function(t){return function(t){var e=t.el,n=t.event,r=t.handler,a=t.middleware;setTimeout((function(){var t=document.activeElement;t&&"IFRAME"===t.tagName&&!e.contains(t)&&i({event:n,handler:r,middleware:a})}),0)}({el:e,event:t,handler:o,middleware:c})},capture:u};e[t]=[].concat(e[t],[h])}e[t].forEach((function(n){var r=n.event,i=n.srcTarget,a=n.handler;return setTimeout((function(){e[t]&&i.addEventListener(r,a,u)}),0)}))}}function o(e){(e[t]||[]).forEach((function(t){return t.srcTarget.removeEventListener(t.event,t.handler,t.capture)})),delete e[t]}var c=e?{bind:a,update:function(t,e){var n=e.value,r=e.oldValue;JSON.stringify(n)!==JSON.stringify(r)&&(o(t),a(t,{value:n}))},unbind:o}:{};return{install:function(t){t.directive("click-outside",c)},directive:c}}()},166:function(t,e,n){"use strict";var r,o,c,l=n(0);function h(t,e,n,r){return new(n||(n=Promise))((function(o,c){function l(t){try{f(r.next(t))}catch(t){c(t)}}function h(t){try{f(r.throw(t))}catch(t){c(t)}}function f(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(l,h)}f((r=r.apply(t,e||[])).next())}))}!function(t){t.SUCCESS="success",t.ERROR="error",t.WARNING="warning",t.INFO="info",t.DEFAULT="default"}(r||(r={})),function(t){t.TOP_LEFT="top-left",t.TOP_CENTER="top-center",t.TOP_RIGHT="top-right",t.BOTTOM_LEFT="bottom-left",t.BOTTOM_CENTER="bottom-center",t.BOTTOM_RIGHT="bottom-right"}(o||(o={})),function(t){t.ADD="add",t.DISMISS="dismiss",t.UPDATE="update",t.CLEAR="clear",t.UPDATE_DEFAULTS="update_defaults"}(c||(c={}));const f="Vue-Toastification",d={type:{type:String,default:r.DEFAULT},classNames:{type:[String,Array],default:()=>[]},trueBoolean:{type:Boolean,default:!0}},m={type:d.type,customIcon:{type:[String,Boolean,Object,Function],default:!0}},y={component:{type:[String,Object,Function,Boolean],default:"button"},classNames:d.classNames,showOnHover:Boolean,ariaLabel:{type:String,default:"close"}},w={timeout:{type:[Number,Boolean],default:5e3},hideProgressBar:Boolean,isRunning:Boolean},v={transition:{type:[Object,String],default:`${f}__bounce`},transitionDuration:{type:[Number,Object],default:750}};var T={CORE_TOAST:{position:{type:String,default:o.TOP_RIGHT},draggable:d.trueBoolean,draggablePercent:{type:Number,default:.6},pauseOnFocusLoss:d.trueBoolean,pauseOnHover:d.trueBoolean,closeOnClick:d.trueBoolean,timeout:w.timeout,hideProgressBar:w.hideProgressBar,toastClassName:d.classNames,bodyClassName:d.classNames,icon:m.customIcon,closeButton:y.component,closeButtonClassName:y.classNames,showCloseButtonOnHover:y.showOnHover,accessibility:{type:Object,default:()=>({toastRole:"alert",closeButtonLabel:"close"})},rtl:Boolean,eventBus:Object},TOAST:{id:{type:[String,Number],required:!0},type:d.type,content:{type:[String,Object,Function],required:!0},onClick:Function,onClose:Function},CONTAINER:{container:{type:void 0,default:()=>document.body},newestOnTop:d.trueBoolean,maxToasts:{type:Number,default:20},transition:v.transition,transitionDuration:v.transitionDuration,toastDefaults:Object,filterBeforeCreate:{type:Function,default:t=>t},filterToasts:{type:Function,default:t=>t},containerClassName:d.classNames,onMounted:Function},PROGRESS_BAR:w,ICON:m,TRANSITION:v,CLOSE_BUTTON:y};const x=t=>"function"==typeof t,S=t=>"string"==typeof t,I=t=>S(t)&&t.trim().length>0,_=t=>"number"==typeof t,E=t=>void 0===t,O=t=>"object"==typeof t&&null!==t,k=t=>P(t,"tag")&&I(t.tag),C=t=>window.TouchEvent&&t instanceof TouchEvent,D=t=>P(t,"component")&&N(t.component),A=t=>!!(t=>x(t)&&P(t,"cid"))(t)||!!O(t)&&(!(!t.extends&&!t._Ctor)||(!!S(t.template)||j(t))),N=t=>!E(t)&&(S(t)||(t=>t instanceof l.a||A(t))(t)||j(t)||k(t)||D(t)),R=t=>O(t)&&_(t.height)&&_(t.width)&&_(t.right)&&_(t.left)&&_(t.top)&&_(t.bottom),P=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),j=t=>P(t,"render")&&x(t.render),M=(i=0,()=>i++);var i;function L(t){return C(t)?t.targetTouches[0].clientX:t.clientX}function V(t){return C(t)?t.targetTouches[0].clientY:t.clientY}const B=t=>{E(t.remove)?t.parentNode&&t.parentNode.removeChild(t):t.remove()},F=t=>D(t)?F(t.component):k(t)?{render:()=>t}:t;function U(template,style,script,t,e,n,r,o,c,l){"boolean"!=typeof r&&(c=o,o=r,r=!1);const h="function"==typeof script?script.options:script;let f;if(template&&template.render&&(h.render=template.render,h.staticRenderFns=template.staticRenderFns,h._compiled=!0,e&&(h.functional=!0)),t&&(h._scopeId=t),n?(f=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),style&&style.call(this,c(t)),t&&t._registeredComponents&&t._registeredComponents.add(n)},h._ssrRegister=f):style&&(f=r?function(t){style.call(this,l(t,this.$root.$options.shadowRoot))}:function(t){style.call(this,o(t))}),f)if(h.functional){const t=h.render;h.render=function(e,n){return f.call(n),t(e,n)}}else{const t=h.beforeCreate;h.beforeCreate=t?[].concat(t,f):[f]}return script}const $=l.a.extend({props:T.PROGRESS_BAR,data:()=>({hasClass:!0}),computed:{style(){return{animationDuration:`${this.timeout}ms`,animationPlayState:this.isRunning?"running":"paused",opacity:this.hideProgressBar?0:1}},cpClass(){return this.hasClass?`${f}__progress-bar`:""}},mounted(){this.$el.addEventListener("animationend",this.animationEnded)},beforeDestroy(){this.$el.removeEventListener("animationend",this.animationEnded)},methods:{animationEnded(){this.$emit("close-toast")}},watch:{timeout(){this.hasClass=!1,this.$nextTick((()=>this.hasClass=!0))}}});var z=function(){var t=this,e=t.$createElement;return(t._self._c||e)("div",{class:t.cpClass,style:t.style})};z._withStripped=!0;const G=U({render:z,staticRenderFns:[]},undefined,$,undefined,false,undefined,!1,void 0,void 0,void 0);const K=l.a.extend({props:T.CLOSE_BUTTON,computed:{buttonComponent(){return!1!==this.component?F(this.component):"button"},classes(){const t=[`${f}__close-button`];return this.showOnHover&&t.push("show-on-hover"),t.concat(this.classNames)}}});var H=function(){var t=this,e=t.$createElement;return(t._self._c||e)(t.buttonComponent,t._g({tag:"component",class:t.classes,attrs:{"aria-label":t.ariaLabel}},t.$listeners),[t._v("\n ×\n")])};H._withStripped=!0;const Y=U({render:H,staticRenderFns:[]},undefined,K,undefined,false,undefined,!1,void 0,void 0,void 0);const W={};var Q=function(){var t=this.$createElement,e=this._self._c||t;return e("svg",{staticClass:"svg-inline--fa fa-check-circle fa-w-16",attrs:{"aria-hidden":"true",focusable:"false","data-prefix":"fas","data-icon":"check-circle",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"}},[e("path",{attrs:{fill:"currentColor",d:"M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"}})])};Q._withStripped=!0;const X=U({render:Q,staticRenderFns:[]},undefined,W,undefined,false,undefined,!1,void 0,void 0,void 0);const J={};var Z=function(){var t=this.$createElement,e=this._self._c||t;return e("svg",{staticClass:"svg-inline--fa fa-info-circle fa-w-16",attrs:{"aria-hidden":"true",focusable:"false","data-prefix":"fas","data-icon":"info-circle",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"}},[e("path",{attrs:{fill:"currentColor",d:"M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z"}})])};Z._withStripped=!0;const tt=U({render:Z,staticRenderFns:[]},undefined,J,undefined,false,undefined,!1,void 0,void 0,void 0);const et={};var nt=function(){var t=this.$createElement,e=this._self._c||t;return e("svg",{staticClass:"svg-inline--fa fa-exclamation-circle fa-w-16",attrs:{"aria-hidden":"true",focusable:"false","data-prefix":"fas","data-icon":"exclamation-circle",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"}},[e("path",{attrs:{fill:"currentColor",d:"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"}})])};nt._withStripped=!0;const it=U({render:nt,staticRenderFns:[]},undefined,et,undefined,false,undefined,!1,void 0,void 0,void 0);const ot={};var st=function(){var t=this.$createElement,e=this._self._c||t;return e("svg",{staticClass:"svg-inline--fa fa-exclamation-triangle fa-w-18",attrs:{"aria-hidden":"true",focusable:"false","data-prefix":"fas","data-icon":"exclamation-triangle",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512"}},[e("path",{attrs:{fill:"currentColor",d:"M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"}})])};st._withStripped=!0;const at=U({render:st,staticRenderFns:[]},undefined,ot,undefined,false,undefined,!1,void 0,void 0,void 0);const ct=l.a.extend({props:T.ICON,computed:{customIconChildren(){return P(this.customIcon,"iconChildren")?this.trimValue(this.customIcon.iconChildren):""},customIconClass(){return S(this.customIcon)?this.trimValue(this.customIcon):P(this.customIcon,"iconClass")?this.trimValue(this.customIcon.iconClass):""},customIconTag(){return P(this.customIcon,"iconTag")?this.trimValue(this.customIcon.iconTag,"i"):"i"},hasCustomIcon(){return this.customIconClass.length>0},component(){return this.hasCustomIcon?this.customIconTag:N(this.customIcon)?F(this.customIcon):this.iconTypeComponent},iconTypeComponent(){return{[r.DEFAULT]:tt,[r.INFO]:tt,[r.SUCCESS]:X,[r.ERROR]:at,[r.WARNING]:it}[this.type]},iconClasses(){const t=[`${f}__icon`];return this.hasCustomIcon?t.concat(this.customIconClass):t}},methods:{trimValue:(t,e="")=>I(t)?t.trim():e}});var ut=function(){var t=this,e=t.$createElement;return(t._self._c||e)(t.component,{tag:"component",class:t.iconClasses},[t._v(t._s(t.customIconChildren))])};ut._withStripped=!0;const lt=U({render:ut,staticRenderFns:[]},undefined,ct,undefined,false,undefined,!1,void 0,void 0,void 0);const ht=l.a.extend({components:{ProgressBar:G,CloseButton:Y,Icon:lt},inheritAttrs:!1,props:Object.assign({},T.CORE_TOAST,T.TOAST),data:()=>({isRunning:!0,disableTransitions:!1,beingDragged:!1,dragStart:0,dragPos:{x:0,y:0},dragRect:{}}),computed:{classes(){const t=[`${f}__toast`,`${f}__toast--${this.type}`,`${this.position}`].concat(this.toastClassName);return this.disableTransitions&&t.push("disable-transition"),this.rtl&&t.push(`${f}__toast--rtl`),t},bodyClasses(){return[`${f}__toast-${S(this.content)?"body":"component-body"}`].concat(this.bodyClassName)},draggableStyle(){return this.dragStart===this.dragPos.x?{}:this.beingDragged?{transform:`translateX(${this.dragDelta}px)`,opacity:1-Math.abs(this.dragDelta/this.removalDistance)}:{transition:"transform 0.2s, opacity 0.2s",transform:"translateX(0)",opacity:1}},dragDelta(){return this.beingDragged?this.dragPos.x-this.dragStart:0},removalDistance(){return R(this.dragRect)?(this.dragRect.right-this.dragRect.left)*this.draggablePercent:0}},mounted(){this.draggable&&this.draggableSetup(),this.pauseOnFocusLoss&&this.focusSetup()},beforeDestroy(){this.draggable&&this.draggableCleanup(),this.pauseOnFocusLoss&&this.focusCleanup()},destroyed(){setTimeout((()=>{B(this.$el)}),1e3)},methods:{getVueComponentFromObj:F,closeToast(){this.eventBus.$emit(c.DISMISS,this.id)},clickHandler(){this.onClick&&this.onClick(this.closeToast),this.closeOnClick&&(this.beingDragged&&this.dragStart!==this.dragPos.x||this.closeToast())},timeoutHandler(){this.closeToast()},hoverPause(){this.pauseOnHover&&(this.isRunning=!1)},hoverPlay(){this.pauseOnHover&&(this.isRunning=!0)},focusPause(){this.isRunning=!1},focusPlay(){this.isRunning=!0},focusSetup(){addEventListener("blur",this.focusPause),addEventListener("focus",this.focusPlay)},focusCleanup(){removeEventListener("blur",this.focusPause),removeEventListener("focus",this.focusPlay)},draggableSetup(){const element=this.$el;element.addEventListener("touchstart",this.onDragStart,{passive:!0}),element.addEventListener("mousedown",this.onDragStart),addEventListener("touchmove",this.onDragMove,{passive:!1}),addEventListener("mousemove",this.onDragMove),addEventListener("touchend",this.onDragEnd),addEventListener("mouseup",this.onDragEnd)},draggableCleanup(){const element=this.$el;element.removeEventListener("touchstart",this.onDragStart),element.removeEventListener("mousedown",this.onDragStart),removeEventListener("touchmove",this.onDragMove),removeEventListener("mousemove",this.onDragMove),removeEventListener("touchend",this.onDragEnd),removeEventListener("mouseup",this.onDragEnd)},onDragStart(t){this.beingDragged=!0,this.dragPos={x:L(t),y:V(t)},this.dragStart=L(t),this.dragRect=this.$el.getBoundingClientRect()},onDragMove(t){this.beingDragged&&(t.preventDefault(),this.isRunning&&(this.isRunning=!1),this.dragPos={x:L(t),y:V(t)})},onDragEnd(){this.beingDragged&&(Math.abs(this.dragDelta)>=this.removalDistance?(this.disableTransitions=!0,this.$nextTick((()=>this.closeToast()))):setTimeout((()=>{this.beingDragged=!1,R(this.dragRect)&&this.pauseOnHover&&this.dragRect.bottom>=this.dragPos.y&&this.dragPos.y>=this.dragRect.top&&this.dragRect.left<=this.dragPos.x&&this.dragPos.x<=this.dragRect.right?this.isRunning=!1:this.isRunning=!0})))}}});var ft=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:t.classes,style:t.draggableStyle,on:{click:t.clickHandler,mouseenter:t.hoverPause,mouseleave:t.hoverPlay}},[t.icon?n("Icon",{attrs:{"custom-icon":t.icon,type:t.type}}):t._e(),t._v(" "),n("div",{class:t.bodyClasses,attrs:{role:t.accessibility.toastRole||"alert"}},["string"==typeof t.content?[t._v(t._s(t.content))]:n(t.getVueComponentFromObj(t.content),t._g(t._b({tag:"component",attrs:{"toast-id":t.id},on:{"close-toast":t.closeToast}},"component",t.content.props,!1),t.content.listeners))],2),t._v(" "),t.closeButton?n("CloseButton",{attrs:{component:t.closeButton,"class-names":t.closeButtonClassName,"show-on-hover":t.showCloseButtonOnHover,"aria-label":t.accessibility.closeButtonLabel},on:{click:function(e){return e.stopPropagation(),t.closeToast(e)}}}):t._e(),t._v(" "),t.timeout?n("ProgressBar",{attrs:{"is-running":t.isRunning,"hide-progress-bar":t.hideProgressBar,timeout:t.timeout},on:{"close-toast":t.timeoutHandler}}):t._e()],1)};ft._withStripped=!0;const pt=U({render:ft,staticRenderFns:[]},undefined,ht,undefined,false,undefined,!1,void 0,void 0,void 0);const mt=l.a.extend({inheritAttrs:!1,props:T.TRANSITION,methods:{beforeEnter(t){const e="number"==typeof this.transitionDuration?this.transitionDuration:this.transitionDuration.enter;t.style.animationDuration=`${e}ms`,t.style.animationFillMode="both",this.$emit("before-enter",t)},afterEnter(t){this.cleanUpStyles(t),this.$emit("after-enter",t)},afterLeave(t){this.cleanUpStyles(t),this.$emit("after-leave",t)},beforeLeave(t){const e="number"==typeof this.transitionDuration?this.transitionDuration:this.transitionDuration.leave;t.style.animationDuration=`${e}ms`,t.style.animationFillMode="both",this.$emit("before-leave",t)},leave(t,e){this.setAbsolutePosition(t),this.$emit("leave",t,e)},setAbsolutePosition(t){t.style.left=t.offsetLeft+"px",t.style.top=t.offsetTop+"px",t.style.width=getComputedStyle(t).width,t.style.height=getComputedStyle(t).height,t.style.position="absolute"},cleanUpStyles(t){t.style.animationFillMode="",t.style.animationDuration=""}}});var gt=function(){var t=this,e=t.$createElement;return(t._self._c||e)("transition-group",{attrs:{tag:"div","enter-active-class":t.transition.enter?t.transition.enter:t.transition+"-enter-active","move-class":t.transition.move?t.transition.move:t.transition+"-move","leave-active-class":t.transition.leave?t.transition.leave:t.transition+"-leave-active"},on:{leave:t.leave,"before-enter":t.beforeEnter,"before-leave":t.beforeLeave,"after-enter":t.afterEnter,"after-leave":t.afterLeave}},[t._t("default")],2)};gt._withStripped=!0;const yt=U({render:gt,staticRenderFns:[]},undefined,mt,undefined,false,undefined,!1,void 0,void 0,void 0);const bt=l.a.extend({components:{Toast:pt,VtTransition:yt},props:Object.assign({},T.CORE_TOAST,T.CONTAINER,T.TRANSITION),data:()=>({count:0,positions:Object.values(o),toasts:{},defaults:{}}),computed:{toastArray(){return Object.values(this.toasts)},filteredToasts(){return this.defaults.filterToasts(this.toastArray)}},beforeMount(){this.setup(this.container);const t=this.eventBus;t.$on(c.ADD,this.addToast),t.$on(c.CLEAR,this.clearToasts),t.$on(c.DISMISS,this.dismissToast),t.$on(c.UPDATE,this.updateToast),t.$on(c.UPDATE_DEFAULTS,this.updateDefaults),this.defaults=this.$props},methods:{setup(t){return h(this,void 0,void 0,(function*(){x(t)&&(t=yield t()),B(this.$el),t.appendChild(this.$el)}))},setToast(t){E(t.id)||this.$set(this.toasts,t.id,t)},addToast(t){const e=Object.assign({},this.defaults,t.type&&this.defaults.toastDefaults&&this.defaults.toastDefaults[t.type],t),n=this.defaults.filterBeforeCreate(e,this.toastArray);n&&this.setToast(n)},dismissToast(t){const e=this.toasts[t];E(e)||E(e.onClose)||e.onClose(),this.$delete(this.toasts,t)},clearToasts(){Object.keys(this.toasts).forEach((t=>{this.dismissToast(t)}))},getPositionToasts(t){const e=this.filteredToasts.filter((e=>e.position===t)).slice(0,this.defaults.maxToasts);return this.defaults.newestOnTop?e.reverse():e},updateDefaults(t){E(t.container)||this.setup(t.container),this.defaults=Object.assign({},this.defaults,t)},updateToast({id:t,options:e,create:n}){this.toasts[t]?(e.timeout&&e.timeout===this.toasts[t].timeout&&e.timeout++,this.setToast(Object.assign({},this.toasts[t],e))):n&&this.addToast(Object.assign({},{id:t},e))},getClasses(t){return[`${f}__container`,t].concat(this.defaults.containerClassName)}}});var wt=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",t._l(t.positions,(function(e){return n("div",{key:e},[n("VtTransition",{class:t.getClasses(e),attrs:{transition:t.defaults.transition,"transition-duration":t.defaults.transitionDuration}},t._l(t.getPositionToasts(e),(function(e){return n("Toast",t._b({key:e.id},"Toast",e,!1))})),1)],1)})),0)};wt._withStripped=!0;const vt=U({render:wt,staticRenderFns:[]},undefined,bt,undefined,false,undefined,!1,void 0,void 0,void 0),Tt=(t,e={},n=!0)=>{const o=e.eventBus=e.eventBus||new t;if(n){const n=new(t.extend(vt))({el:document.createElement("div"),propsData:e}),r=e.onMounted;E(r)||r(n)}const l=(content,t)=>{const e=Object.assign({},{id:M(),type:r.DEFAULT},t,{content:content});return o.$emit(c.ADD,e),e.id};return l.clear=()=>o.$emit(c.CLEAR),l.updateDefaults=t=>{o.$emit(c.UPDATE_DEFAULTS,t)},l.dismiss=t=>{o.$emit(c.DISMISS,t)},l.update=function(t,{content:content,options:e},n=!1){o.$emit(c.UPDATE,{id:t,options:Object.assign({},e,{content:content}),create:n})},l.success=(content,t)=>l(content,Object.assign({},t,{type:r.SUCCESS})),l.info=(content,t)=>l(content,Object.assign({},t,{type:r.INFO})),l.error=(content,t)=>l(content,Object.assign({},t,{type:r.ERROR})),l.warning=(content,t)=>l(content,Object.assign({},t,{type:r.WARNING})),l};e.a=(t,e)=>{const n=function(t,e=l.a){return t instanceof e?Tt(e,{eventBus:t},!1):Tt(e,t,!0)}(e,t);t.$toast=n,t.prototype.$toast=n}},17:function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r={};function o(){return r}},178:function(t,e,n){(function(t){t.installComponents=function(component,t){var n="function"==typeof component.exports?component.exports.extendOptions:component.options;for(var i in"function"==typeof component.exports&&(n.components=component.exports.options.components),n.components=n.components||{},t)n.components[i]=n.components[i]||t[i];n.functional&&function(component,t){if(component.exports[e])return;component.exports[e]=!0;var n=component.exports.render;component.exports.render=function(e,r){return n(e,Object.assign({},r,{_c:function(e,a,b){return r._c(t[e]||e,a,b)}}))}}(component,n.components)};var e="_functionalComponents"}).call(this,n(38))},21:function(t,e,n){"use strict";n.d(e,"a",(function(){return h}));var r=n(3),o=n(1),c=n(6),l=n(17);function h(t,e){var n,h,f,d,m,y,w,v;Object(o.a)(1,arguments);var T=Object(l.a)(),x=Object(c.a)(null!==(n=null!==(h=null!==(f=null!==(d=null==e?void 0:e.weekStartsOn)&&void 0!==d?d:null==e||null===(m=e.locale)||void 0===m||null===(y=m.options)||void 0===y?void 0:y.weekStartsOn)&&void 0!==f?f:T.weekStartsOn)&&void 0!==h?h:null===(w=T.locale)||void 0===w||null===(v=w.options)||void 0===v?void 0:v.weekStartsOn)&&void 0!==n?n:0);if(!(x>=0&&x<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var S=Object(r.a)(t),I=S.getUTCDay(),_=(I{if(e{e.setLogLevel(t)}))}function y(t,e){for(const n of r){let r=null;e&&e.level&&(r=c[e.level]),n.userLogHandler=null===t?null:(e,n,...c)=>{const l=c.map((t=>{if(null==t)return null;if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t)return t.toString();if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch(t){return null}})).filter((t=>t)).join(" ");n>=(null!=r?r:e.logLevel)&&t({level:o[n].toLowerCase(),message:l,args:c,type:e.name})}}}},223:function(t,e,n){"use strict";function r(){}t.exports=r,r.maxLength=4096,r.parse=function(t){var e=r.maxLength;if("string"!=typeof t)throw new TypeError("str must be a string");if(t.length>e)throw new RangeError("str is too large (CookieParser.maxLength="+e+")");var n=new r;if(arguments.length>1){var o=arguments[1];if("object"==typeof o&&null!==o&&"function"==typeof o.decode)return n.slowParse(t,o.decode)}return n.parse(t)},r.prototype.decode=function(t){try{return decodeURIComponent(t)}catch(e){return t}},r.prototype.extract=function(t,e,n){return e===n+1?"":t.slice(this.trimForward(t,e),this.trimBackward(t,n)+1)},r.prototype.trimForward=function(t,i){for(var e=t.charCodeAt(i);this.isWhiteSpace(e);)e=t.charCodeAt(++i);return i},r.prototype.trimBackward=function(t,i){for(var e=t.charCodeAt(i);this.isWhiteSpace(e);)e=t.charCodeAt(--i);return i},r.prototype.isWhiteSpace=function(t){return t<=32},r.prototype.parse=function(t){var e={},n=0,r=0,o=0,c=0,l=!1,h=!1,i=0,f=t.length;t:for(;i127)return this.slowParse(t,this.decode);if(61===d){r=i-1;var m=i+1;for(d=t.charCodeAt(m);32===d;)m++,d=t.charCodeAt(m);for(34===d&&(m++,h=!0),o=m;m=b.f?n():a.fonts.load(function(a){return C(a)+" "+a.f+"00 300px "+O(a.c)}(b.a),b.h).then((function(a){1<=a.length?e():setTimeout(r,25)}),(function(){n()}))}()})),n=null,r=new Promise((function(a,t){n=setTimeout(t,b.f)}));Promise.race([r,e]).then((function(){n&&(clearTimeout(n),n=null),b.g(b.a)}),(function(){b.j(b.a)}))};var F={D:"serif",C:"sans-serif"},U=null;function $(){if(null===U){var a=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);U=!!a&&(536>parseInt(a[1],10)||536===parseInt(a[1],10)&&11>=parseInt(a[2],10))}return U}function z(a,b,t){for(var e in F)if(F.hasOwnProperty(e)&&b===a.f[F[e]]&&t===a.f[F[e]])return!0;return!1}function G(a){var t,b=a.g.a.offsetWidth,e=a.h.a.offsetWidth;(t=b===a.f.serif&&e===a.f["sans-serif"])||(t=$()&&z(a,b,e)),t?q()-a.A>=a.w?$()&&z(a,b,e)&&(null===a.u||a.u.hasOwnProperty(a.a.c))?K(a,a.v):K(a,a.B):function(a){setTimeout(p((function(){G(this)}),a),50)}(a):K(a,a.v)}function K(a,b){setTimeout(p((function(){d(this.g.a),d(this.h.a),d(this.j.a),d(this.m.a),b(this.a)}),a),0)}function H(a,b,t){this.c=a,this.a=b,this.f=0,this.m=this.j=!1,this.s=t}B.prototype.start=function(){this.f.serif=this.j.a.offsetWidth,this.f["sans-serif"]=this.m.a.offsetWidth,this.A=q(),G(this)};var Y=null;function W(a){0==--a.f&&a.j&&(a.m?((a=a.a).g&&m(a.f,[a.a.c("wf","active")],[a.a.c("wf","loading"),a.a.c("wf","inactive")]),R(a,"active")):N(a.a))}function Q(a){this.j=a,this.a=new P,this.h=0,this.f=this.g=!0}function X(a,b,t,e,n){var r=0==--a.h;(a.f||a.g)&&setTimeout((function(){var a=n||null,o=e||{};if(0===t.length&&r)N(b.a);else{b.f+=t.length,r&&(b.j=r);var c,l=[];for(c=0;c0,o=r?e:1-e;if(o<=50)n=t||100;else{var c=o+50;n=t+100*Math.floor(c/100)-(t>=c%100?100:0)}return r?n:1-n}function Et(t){return t%400==0||t%4==0&&t%100!=0}function Ot(t){return Ot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ot(t)}function kt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ct(t,e){for(var i=0;i0}},{key:"set",value:function(t,e,n){var r=t.getUTCFullYear();if(n.isTwoDigitYear){var o=_t(n.year,r);return t.setUTCFullYear(o,0,1),t.setUTCHours(0,0,0,0),t}var c="era"in e&&1!==e.era?1-n.year:n.year;return t.setUTCFullYear(c,0,1),t.setUTCHours(0,0,0,0),t}}])&&Ct(e.prototype,n),r&&Ct(e,r),c}(P),Lt=n(62),Vt=n(21);function Bt(t){return Bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bt(t)}function Ft(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ut(t,e){for(var i=0;i0}},{key:"set",value:function(t,e,n,r){var o=Object(Lt.a)(t,r);if(n.isTwoDigitYear){var c=_t(n.year,o);return t.setUTCFullYear(c,0,r.firstWeekContainsDate),t.setUTCHours(0,0,0,0),Object(Vt.a)(t,r)}var l="era"in e&&1!==e.era?1-n.year:n.year;return t.setUTCFullYear(l,0,r.firstWeekContainsDate),t.setUTCHours(0,0,0,0),Object(Vt.a)(t,r)}}])&&Ut(e.prototype,n),r&&Ut(e,r),c}(P),Wt=n(28);function Qt(t){return Qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qt(t)}function Xt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Jt(t,e){for(var i=0;i=1&&e<=4}},{key:"set",value:function(t,e,n){return t.setUTCMonth(3*(n-1),1),t.setUTCHours(0,0,0,0),t}}])&&be(e.prototype,n),r&&be(e,r),c}(P);function Ee(t){return Ee="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ee(t)}function Oe(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ke(t,e){for(var i=0;i=1&&e<=4}},{key:"set",value:function(t,e,n){return t.setUTCMonth(3*(n-1),1),t.setUTCHours(0,0,0,0),t}}])&&ke(e.prototype,n),r&&ke(e,r),c}(P);function Me(t){return Me="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Me(t)}function Le(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ve(t,e){for(var i=0;i=0&&e<=11}},{key:"set",value:function(t,e,n){return t.setUTCMonth(n,1),t.setUTCHours(0,0,0,0),t}}])&&Ve(e.prototype,n),r&&Ve(e,r),c}(P);function Ke(t){return Ke="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ke(t)}function He(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ye(t,e){for(var i=0;i=0&&e<=11}},{key:"set",value:function(t,e,n){return t.setUTCMonth(n,1),t.setUTCHours(0,0,0,0),t}}])&&Ye(e.prototype,n),r&&Ye(e,r),c}(P),nn=n(97);function rn(t){return rn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rn(t)}function on(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function sn(t,e){for(var i=0;i=1&&e<=53}},{key:"set",value:function(t,e,n,r){return Object(Vt.a)(function(t,e,n){Object(y.a)(2,arguments);var r=Object(c.a)(t),o=Object(m.a)(e),l=Object(nn.a)(r,n)-o;return r.setUTCDate(r.getUTCDate()-7*l),r}(t,n,r),r)}}],n&&sn(e.prototype,n),r&&sn(e,r),l}(P),pn=n(98);function mn(t){return mn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mn(t)}function gn(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function yn(t,e){for(var i=0;i=1&&e<=53}},{key:"set",value:function(t,e,n){return Object(Wt.a)(function(t,e){Object(y.a)(2,arguments);var n=Object(c.a)(t),r=Object(m.a)(e),o=Object(pn.a)(n)-r;return n.setUTCDate(n.getUTCDate()-7*o),n}(t,n))}}],n&&yn(e.prototype,n),r&&yn(e,r),l}(P);function _n(t){return _n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_n(t)}function En(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function On(t,e){for(var i=0;i=1&&e<=jn[r]:e>=1&&e<=Pn[r]}},{key:"set",value:function(t,e,n){return t.setUTCDate(n),t.setUTCHours(0,0,0,0),t}}])&&On(e.prototype,n),r&&On(e,r),c}(P);function Ln(t){return Ln="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ln(t)}function Vn(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Bn(t,e){for(var i=0;i=1&&e<=366:e>=1&&e<=365}},{key:"set",value:function(t,e,n){return t.setUTCMonth(0,n),t.setUTCHours(0,0,0,0),t}}])&&Bn(e.prototype,n),r&&Bn(e,r),c}(P),Hn=n(17);function Yn(t,e,n){var r,o,l,h,f,d,w,v;Object(y.a)(2,arguments);var T=Object(Hn.a)(),x=Object(m.a)(null!==(r=null!==(o=null!==(l=null!==(h=null==n?void 0:n.weekStartsOn)&&void 0!==h?h:null==n||null===(f=n.locale)||void 0===f||null===(d=f.options)||void 0===d?void 0:d.weekStartsOn)&&void 0!==l?l:T.weekStartsOn)&&void 0!==o?o:null===(w=T.locale)||void 0===w||null===(v=w.options)||void 0===v?void 0:v.weekStartsOn)&&void 0!==r?r:0);if(!(x>=0&&x<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var S=Object(c.a)(t),I=Object(m.a)(e),_=S.getUTCDay(),E=I%7,O=(E+7)%7,k=(O=0&&e<=6}},{key:"set",value:function(t,e,n,r){return(t=Yn(t,n,r)).setUTCHours(0,0,0,0),t}}])&&Xn(e.prototype,n),r&&Xn(e,r),c}(P);function sr(t){return sr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sr(t)}function ar(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function cr(t,e){for(var i=0;i=0&&e<=6}},{key:"set",value:function(t,e,n,r){return(t=Yn(t,n,r)).setUTCHours(0,0,0,0),t}}])&&cr(e.prototype,n),r&&cr(e,r),c}(P);function yr(t){return yr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yr(t)}function wr(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function vr(t,e){for(var i=0;i=0&&e<=6}},{key:"set",value:function(t,e,n,r){return(t=Yn(t,n,r)).setUTCHours(0,0,0,0),t}}])&&vr(e.prototype,n),r&&vr(e,r),c}(P);function kr(t){return kr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kr(t)}function Cr(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Dr(t,e){for(var i=0;i=1&&e<=7}},{key:"set",value:function(t,e,n){return t=function(t,e){Object(y.a)(2,arguments);var n=Object(m.a)(e);n%7==0&&(n-=7);var r=1,o=Object(c.a)(t),l=o.getUTCDay(),h=((n%7+7)%7=1&&e<=12}},{key:"set",value:function(t,e,n){var r=t.getUTCHours()>=12;return r&&n<12?t.setUTCHours(n+12,0,0,0):r||12!==n?t.setUTCHours(n,0,0,0):t.setUTCHours(0,0,0,0),t}}])&&yi(e.prototype,n),r&&yi(e,r),c}(P);function _i(t){return _i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_i(t)}function Ei(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Oi(t,e){for(var i=0;i=0&&e<=23}},{key:"set",value:function(t,e,n){return t.setUTCHours(n,0,0,0),t}}])&&Oi(e.prototype,n),r&&Oi(e,r),c}(P);function ji(t){return ji="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ji(t)}function Mi(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Li(t,e){for(var i=0;i=0&&e<=11}},{key:"set",value:function(t,e,n){return t.getUTCHours()>=12&&n<12?t.setUTCHours(n+12,0,0,0):t.setUTCHours(n,0,0,0),t}}])&&Li(e.prototype,n),r&&Li(e,r),c}(P);function Gi(t){return Gi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gi(t)}function Ki(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Hi(t,e){for(var i=0;i=1&&e<=24}},{key:"set",value:function(t,e,n){var r=n<=24?n%24:n;return t.setUTCHours(r,0,0,0),t}}])&&Hi(e.prototype,n),r&&Hi(e,r),c}(P);function eo(t){return eo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},eo(t)}function no(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ro(t,e){for(var i=0;i=0&&e<=59}},{key:"set",value:function(t,e,n){return t.setUTCMinutes(n,0,0),t}}])&&ro(e.prototype,n),r&&ro(e,r),c}(P);function ho(t){return ho="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ho(t)}function fo(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function po(t,e){for(var i=0;i=0&&e<=59}},{key:"set",value:function(t,e,n){return t.setUTCSeconds(n,0),t}}])&&po(e.prototype,n),r&&po(e,r),c}(P);function xo(t){return xo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xo(t)}function So(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Io(t,e){for(var i=0;i=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,c=!0,l=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return c=t.done,t},e:function(t){l=!0,o=t},f:function(){try{c||null==n.return||n.return()}finally{if(l)throw o}}}}function Ts(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i=1&&z<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var G=Object(m.a)(null!==(D=null!==(A=null!==(R=null!==(P=null==w?void 0:w.weekStartsOn)&&void 0!==P?P:null==w||null===(j=w.locale)||void 0===j||null===(M=j.options)||void 0===M?void 0:M.weekStartsOn)&&void 0!==R?R:U.weekStartsOn)&&void 0!==A?A:null===(L=U.locale)||void 0===L||null===(V=L.options)||void 0===V?void 0:V.weekStartsOn)&&void 0!==D?D:0);if(!(G>=0&&G<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(""===F)return""===B?Object(c.a)(n):new Date(NaN);var K,H={firstWeekContainsDate:z,weekStartsOn:G,locale:$},Y=[new N],W=F.match(Ss).map((function(t){var e=t[0];return e in h.a?(0,h.a[e])(t,$.formatLong):t})).join("").match(xs),Q=[],X=vs(W);try{var J=function(){var e=K.value;null!=w&&w.useAdditionalWeekYearTokens||!Object(d.b)(e)||Object(d.c)(e,F,t),null!=w&&w.useAdditionalDayOfYearTokens||!Object(d.a)(e)||Object(d.c)(e,F,t);var n=e[0],r=bs[n];if(r){var o=r.incompatibleTokens;if(Array.isArray(o)){var c=Q.find((function(t){return o.includes(t.token)||t.token===n}));if(c)throw new RangeError("The format string mustn't contain `".concat(c.fullToken,"` and `").concat(e,"` at the same time"))}else if("*"===r.incompatibleTokens&&Q.length>0)throw new RangeError("The format string mustn't contain `".concat(e,"` and any other token at the same time"));Q.push({token:n,fullToken:e});var l=r.run(B,e,$.match,H);if(!l)return{v:new Date(NaN)};Y.push(l.setter),B=l.rest}else{if(n.match(Os))throw new RangeError("Format string contains an unescaped latin alphabet character `"+n+"`");if("''"===e?e="'":"'"===n&&(e=Cs(e)),0!==B.indexOf(e))return{v:new Date(NaN)};B=B.slice(e.length)}};for(X.s();!(K=X.n()).done;){var Z=J();if("object"===ws(Z))return Z.v}}catch(t){X.e(t)}finally{X.f()}if(B.length>0&&Es.test(B))return new Date(NaN);var tt=Y.map((function(t){return t.priority})).sort((function(a,b){return b-a})).filter((function(t,e,n){return n.indexOf(t)===e})).map((function(t){return Y.filter((function(e){return e.priority===t})).sort((function(a,b){return b.subPriority-a.subPriority}))})).map((function(t){return t[0]})),et=Object(c.a)(n);if(isNaN(et.getTime()))return new Date(NaN);var nt,it=Object(o.a)(et,Object(f.a)(et)),ot={},st=vs(tt);try{for(st.s();!(nt=st.n()).done;){var at=nt.value;if(!at.validate(it,H))return new Date(NaN);var ct=at.set(it,ot,H);Array.isArray(ct)?(it=ct[0],Object(l.a)(ot,ct[1])):it=ct}}catch(t){st.e(t)}finally{st.f()}return it}function Cs(input){return input.match(Is)[1].replace(_s,"'")}},253:function(t,e,n){"use strict";n.d(e,"a",(function(){return D}));var r=n(17),o=n(3),c=n(1);function l(t,e){Object(c.a)(2,arguments);var n=Object(o.a)(t),r=Object(o.a)(e),l=n.getTime()-r.getTime();return l<0?-1:l>0?1:l}function h(t,e){Object(c.a)(2,arguments);var n=Object(o.a)(t),r=Object(o.a)(e),l=n.getFullYear()-r.getFullYear(),h=n.getMonth()-r.getMonth();return 12*l+h}function f(t){Object(c.a)(1,arguments);var e=Object(o.a)(t);return e.setHours(23,59,59,999),e}function d(t){Object(c.a)(1,arguments);var e=Object(o.a)(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(23,59,59,999),e}function m(t){Object(c.a)(1,arguments);var e=Object(o.a)(t);return f(e).getTime()===d(e).getTime()}function y(t,e){Object(c.a)(2,arguments);var n,r=Object(o.a)(t),f=Object(o.a)(e),d=l(r,f),y=Math.abs(h(r,f));if(y<1)n=0;else{1===r.getMonth()&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-d*y);var w=l(r,f)===-d;m(Object(o.a)(t))&&1===y&&1===l(t,f)&&(w=!1),n=d*(y-Number(w))}return 0===n?0:n}function w(t,e){return Object(c.a)(2,arguments),Object(o.a)(t).getTime()-Object(o.a)(e).getTime()}var v={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(t){return t<0?Math.ceil(t):Math.floor(t)}};function T(t){return t?v[t]:v.trunc}function x(t,e,n){Object(c.a)(2,arguments);var r=w(t,e)/1e3;return T(null==n?void 0:n.roundingMethod)(r)}var S=n(63),I=n(61);function _(object){return Object(I.a)({},object)}var E=n(59),O=1440,k=43200;function C(t,e,n){var h,f;Object(c.a)(2,arguments);var d=Object(r.a)(),m=null!==(h=null!==(f=null==n?void 0:n.locale)&&void 0!==f?f:d.locale)&&void 0!==h?h:S.a;if(!m.formatDistance)throw new RangeError("locale must contain formatDistance property");var w=l(t,e);if(isNaN(w))throw new RangeError("Invalid time value");var v,T,C=Object(I.a)(_(n),{addSuffix:Boolean(null==n?void 0:n.addSuffix),comparison:w});w>0?(v=Object(o.a)(e),T=Object(o.a)(t)):(v=Object(o.a)(t),T=Object(o.a)(e));var D,A=x(T,v),N=(Object(E.a)(T)-Object(E.a)(v))/1e3,R=Math.round((A-N)/60);if(R<2)return null!=n&&n.includeSeconds?A<5?m.formatDistance("lessThanXSeconds",5,C):A<10?m.formatDistance("lessThanXSeconds",10,C):A<20?m.formatDistance("lessThanXSeconds",20,C):A<40?m.formatDistance("halfAMinute",0,C):A<60?m.formatDistance("lessThanXMinutes",1,C):m.formatDistance("xMinutes",1,C):0===R?m.formatDistance("lessThanXMinutes",1,C):m.formatDistance("xMinutes",R,C);if(R<45)return m.formatDistance("xMinutes",R,C);if(R<90)return m.formatDistance("aboutXHours",1,C);if(R>6|192,e[p++]=63&n|128):55296==(64512&n)&&i+1>18|240,e[p++]=n>>12&63|128,e[p++]=n>>6&63|128,e[p++]=63&n|128):(e[p++]=n>>12|224,e[p++]=n>>6&63|128,e[p++]=63&n|128)}return e},o={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(input,t){if(!Array.isArray(input))throw Error("encodeByteArray takes an array as a parameter");this.init_();const e=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,output=[];for(let i=0;i>2,h=(3&t)<<4|r>>4;let f=(15&r)<<2|c>>6,d=63&c;o||(d=64,n||(f=64)),output.push(e[l],e[h],e[f],e[d])}return output.join("")},encodeString(input,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(input):this.encodeByteArray(r(input),t)},decodeString(input,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(input):function(t){const e=[];let n=0,r=0;for(;n191&&o<224){const c=t[n++];e[r++]=String.fromCharCode((31&o)<<6|63&c)}else if(o>239&&o<365){const u=((7&o)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++])-65536;e[r++]=String.fromCharCode(55296+(u>>10)),e[r++]=String.fromCharCode(56320+(1023&u))}else{const c=t[n++],l=t[n++];e[r++]=String.fromCharCode((15&o)<<12|(63&c)<<6|63&l)}}return e.join("")}(this.decodeStringToByteArray(input,t))},decodeStringToByteArray(input,t){this.init_();const e=t?this.charToByteMapWebSafe_:this.charToByteMap_,output=[];for(let i=0;i>4;if(output.push(c),64!==r){const t=n<<4&240|r>>2;if(output.push(t),64!==o){const t=r<<6&192|o;output.push(t)}}}return output},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let i=0;i=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(i)]=i,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(i)]=i)}}},c=function(t){return function(t){const e=r(t);return o.encodeByteArray(e,!0)}(t).replace(/\./g,"")};function l(t,source){if(!(source instanceof Object))return source;switch(source.constructor){case Date:return new Date(source.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return source}for(const e in source)source.hasOwnProperty(e)&&"__proto__"!==e&&(t[e]=l(t[e],source[e]));return t}class h{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}wrapCallback(t){return(e,n)=>{e?this.reject(e):this.resolve(n),"function"==typeof t&&(this.promise.catch((()=>{})),1===t.length?t(e):t(e,n))}}}function f(t,e){if(t.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n=e||"demo-project",r=t.iat||0,sub=t.sub||t.user_id;if(!sub)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:r,exp:r+3600,auth_time:r,sub:sub,user_id:sub,firebase:{sign_in_provider:"custom",identities:{}}},t);return[c(JSON.stringify({alg:"none",type:"JWT"})),c(JSON.stringify(o)),""].join(".")}function d(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function m(){return"object"==typeof self&&self.self===self}function y(){return!function(){try{return"[object process]"===Object.prototype.toString.call(t.process)}catch(t){return!1}}()&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function w(){return"object"==typeof indexedDB}function v(){return new Promise(((t,e)=>{try{let n=!0;const r="validate-browser-context-for-indexeddb-analytics-module",o=self.indexedDB.open(r);o.onsuccess=()=>{o.result.close(),n||self.indexedDB.deleteDatabase(r),t(!0)},o.onupgradeneeded=()=>{n=!1},o.onerror=()=>{var t;e((null===(t=o.error)||void 0===t?void 0:t.message)||"")}}catch(t){e(t)}}))}class T extends Error{constructor(code,t,e){super(t),this.code=code,this.customData=e,this.name="FirebaseError",Object.setPrototypeOf(this,T.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,x.prototype.create)}}class x{constructor(t,e,n){this.service=t,this.serviceName=e,this.errors=n}create(code,...data){const t=data[0]||{},e=`${this.service}/${code}`,template=this.errors[code],n=template?function(template,data){return template.replace(S,((t,e)=>{const n=data[e];return null!=n?String(n):`<${e}?>`}))}(template,t):"Error",r=`${this.serviceName}: ${n} (${e}).`;return new T(e,r,t)}}const S=/\{\$([^}]+)}/g;function I(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function _(a,b){if(a===b)return!0;const t=Object.keys(a),e=Object.keys(b);for(const n of t){if(!e.includes(n))return!1;const t=a[n],r=b[n];if(E(t)&&E(r)){if(!_(t,r))return!1}else if(t!==r)return!1}for(const n of e)if(!t.includes(n))return!1;return!0}function E(t){return null!==t&&"object"==typeof t}function O(t,e){const n=new k(t,e);return n.subscribe.bind(n)}class k{constructor(t,e){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then((()=>{t(this)})).catch((t=>{this.error(t)}))}next(t){this.forEachObserver((e=>{e.next(t)}))}error(t){this.forEachObserver((e=>{e.error(t)})),this.close(t)}complete(){this.forEachObserver((t=>{t.complete()})),this.close()}subscribe(t,e,n){let r;if(void 0===t&&void 0===e&&void 0===n)throw new Error("Missing Observer.");r=function(t,e){if("object"!=typeof t||null===t)return!1;for(const n of e)if(n in t&&"function"==typeof t[n])return!0;return!1}(t,["next","error","complete"])?t:{next:t,error:e,complete:n},void 0===r.next&&(r.next=C),void 0===r.error&&(r.error=C),void 0===r.complete&&(r.complete=C);const o=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then((()=>{try{this.finalError?r.error(this.finalError):r.complete()}catch(t){}})),this.observers.push(r),o}unsubscribeOne(i){void 0!==this.observers&&void 0!==this.observers[i]&&(delete this.observers[i],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(t){if(!this.finalized)for(let i=0;i{if(void 0!==this.observers&&void 0!==this.observers[i])try{t(this.observers[i])}catch(t){"undefined"!=typeof console&&console.error&&console.error(t)}}))}close(t){this.finalized||(this.finalized=!0,void 0!==t&&(this.finalError=t),this.task.then((()=>{this.observers=void 0,this.onNoObservers=void 0})))}}function C(){}function D(t){return t&&t._delegate?t._delegate:t}}).call(this,n(38))},40:function(t,e,n){"use strict";n.r(e),n.d(e,"FirebaseError",(function(){return c.c})),n.d(e,"SDK_VERSION",(function(){return H})),n.d(e,"_DEFAULT_ENTRY_NAME",(function(){return R})),n.d(e,"_addComponent",(function(){return L})),n.d(e,"_addOrOverwriteComponent",(function(){return V})),n.d(e,"_apps",(function(){return j})),n.d(e,"_clearComponents",(function(){return $})),n.d(e,"_components",(function(){return M})),n.d(e,"_getProvider",(function(){return F})),n.d(e,"_registerComponent",(function(){return B})),n.d(e,"_removeServiceInstance",(function(){return U})),n.d(e,"deleteApp",(function(){return X})),n.d(e,"getApp",(function(){return W})),n.d(e,"getApps",(function(){return Q})),n.d(e,"initializeApp",(function(){return Y})),n.d(e,"onLog",(function(){return Z})),n.d(e,"registerVersion",(function(){return J})),n.d(e,"setLogLevel",(function(){return tt}));var r=n(51),o=n(22),c=n(4);let l,h;const f=new WeakMap,d=new WeakMap,m=new WeakMap,y=new WeakMap,w=new WeakMap;let v={get(t,e,n){if(t instanceof IDBTransaction){if("done"===e)return d.get(t);if("objectStoreNames"===e)return t.objectStoreNames||m.get(t);if("store"===e)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return S(t[e])},set:(t,e,n)=>(t[e]=n,!0),has:(t,e)=>t instanceof IDBTransaction&&("done"===e||"store"===e)||e in t};function T(t){return t!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(h||(h=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(I(this),e),S(f.get(this))}:function(...e){return S(t.apply(I(this),e))}:function(e,...n){const r=t.call(I(this),e,...n);return m.set(r,e.sort?e.sort():[e]),S(r)}}function x(t){return"function"==typeof t?T(t):(t instanceof IDBTransaction&&function(t){if(d.has(t))return;const e=new Promise(((e,n)=>{const r=()=>{t.removeEventListener("complete",o),t.removeEventListener("error",c),t.removeEventListener("abort",c)},o=()=>{e(),r()},c=()=>{n(t.error||new DOMException("AbortError","AbortError")),r()};t.addEventListener("complete",o),t.addEventListener("error",c),t.addEventListener("abort",c)}));d.set(t,e)}(t),object=t,(l||(l=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some((t=>object instanceof t))?new Proxy(t,v):t);var object}function S(t){if(t instanceof IDBRequest)return function(t){const e=new Promise(((e,n)=>{const r=()=>{t.removeEventListener("success",o),t.removeEventListener("error",c)},o=()=>{e(S(t.result)),r()},c=()=>{n(t.error),r()};t.addEventListener("success",o),t.addEventListener("error",c)}));return e.then((e=>{e instanceof IDBCursor&&f.set(e,t)})).catch((()=>{})),w.set(e,t),e}(t);if(y.has(t))return y.get(t);const e=x(t);return e!==t&&(y.set(t,e),w.set(e,t)),e}const I=t=>w.get(t);const _=["get","getKey","getAll","getAllKeys","count"],E=["put","add","delete","clear"],O=new Map;function k(t,e){if(!(t instanceof IDBDatabase)||e in t||"string"!=typeof e)return;if(O.get(e))return O.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,o=E.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!o&&!_.includes(n))return;const c=async function(t,...e){const c=this.transaction(t,o?"readwrite":"readonly");let l=c.store;return r&&(l=l.index(e.shift())),(await Promise.all([l[n](...e),o&&c.done]))[0]};return O.set(e,c),c}v=(t=>({...t,get:(e,n,r)=>k(e,n)||t.get(e,n,r),has:(e,n)=>!!k(e,n)||t.has(e,n)}))(v);class C{constructor(t){this.container=t}getPlatformInfoString(){return this.container.getProviders().map((t=>{if(function(t){const component=t.getComponent();return"VERSION"===(null==component?void 0:component.type)}(t)){const e=t.getImmediate();return`${e.library}/${e.version}`}return null})).filter((t=>t)).join(" ")}}const D="@firebase/app",A="0.7.33",N=new o.b("@firebase/app"),R="[DEFAULT]",P={[D]:"fire-core","@firebase/app-compat":"fire-core-compat","@firebase/analytics":"fire-analytics","@firebase/analytics-compat":"fire-analytics-compat","@firebase/app-check":"fire-app-check","@firebase/app-check-compat":"fire-app-check-compat","@firebase/auth":"fire-auth","@firebase/auth-compat":"fire-auth-compat","@firebase/database":"fire-rtdb","@firebase/database-compat":"fire-rtdb-compat","@firebase/functions":"fire-fn","@firebase/functions-compat":"fire-fn-compat","@firebase/installations":"fire-iid","@firebase/installations-compat":"fire-iid-compat","@firebase/messaging":"fire-fcm","@firebase/messaging-compat":"fire-fcm-compat","@firebase/performance":"fire-perf","@firebase/performance-compat":"fire-perf-compat","@firebase/remote-config":"fire-rc","@firebase/remote-config-compat":"fire-rc-compat","@firebase/storage":"fire-gcs","@firebase/storage-compat":"fire-gcs-compat","@firebase/firestore":"fire-fst","@firebase/firestore-compat":"fire-fst-compat","fire-js":"fire-js",firebase:"fire-js-all"},j=new Map,M=new Map;function L(t,component){try{t.container.addComponent(component)}catch(e){N.debug(`Component ${component.name} failed to register with FirebaseApp ${t.name}`,e)}}function V(t,component){t.container.addOrOverwriteComponent(component)}function B(component){const t=component.name;if(M.has(t))return N.debug(`There were multiple attempts to register component ${t}.`),!1;M.set(t,component);for(const t of j.values())L(t,component);return!0}function F(t,e){const n=t.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),t.container.getProvider(e)}function U(t,e,n=R){F(t,e).clearInstance(n)}function $(){M.clear()}const z={"no-app":"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()","bad-app-name":"Illegal App name: '{$appName}","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}."},G=new c.b("app","Firebase",z);class K{constructor(t,e,n){this._isDeleted=!1,this._options=Object.assign({},t),this._config=Object.assign({},e),this._name=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new r.a("app",(()=>this),"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(t){this.checkDestroyed(),this._automaticDataCollectionEnabled=t}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(t){this._isDeleted=t}checkDestroyed(){if(this.isDeleted)throw G.create("app-deleted",{appName:this._name})}}const H="9.10.0";function Y(t,e={}){if("object"!=typeof e){e={name:e}}const n=Object.assign({name:R,automaticDataCollectionEnabled:!1},e),o=n.name;if("string"!=typeof o||!o)throw G.create("bad-app-name",{appName:String(o)});const l=j.get(o);if(l){if(Object(c.h)(t,l.options)&&Object(c.h)(n,l.config))return l;throw G.create("duplicate-app",{appName:o})}const h=new r.b(o);for(const component of M.values())h.addComponent(component);const f=new K(t,n,h);return j.set(o,f),f}function W(t=R){const e=j.get(t);if(!e)throw G.create("no-app",{appName:t});return e}function Q(){return Array.from(j.values())}async function X(t){const e=t.name;j.has(e)&&(j.delete(e),await Promise.all(t.container.getProviders().map((t=>t.delete()))),t.isDeleted=!0)}function J(t,e,n){var o;let c=null!==(o=P[t])&&void 0!==o?o:t;n&&(c+=`-${n}`);const l=c.match(/\s|\//),h=e.match(/\s|\//);if(l||h){const t=[`Unable to register library "${c}" with version "${e}":`];return l&&t.push(`library name "${c}" contains illegal characters (whitespace or "/")`),l&&h&&t.push("and"),h&&t.push(`version name "${e}" contains illegal characters (whitespace or "/")`),void N.warn(t.join(" "))}B(new r.a(`${c}-version`,(()=>({library:c,version:e})),"VERSION"))}function Z(t,e){if(null!==t&&"function"!=typeof t)throw G.create("invalid-log-argument");Object(o.d)(t,e)}function tt(t){Object(o.c)(t)}const et="firebase-heartbeat-store";let nt=null;function it(){return nt||(nt=function(t,e,{blocked:n,upgrade:r,blocking:o,terminated:c}={}){const l=indexedDB.open(t,e),h=S(l);return r&&l.addEventListener("upgradeneeded",(t=>{r(S(l.result),t.oldVersion,t.newVersion,S(l.transaction))})),n&&l.addEventListener("blocked",(()=>n())),h.then((t=>{c&&t.addEventListener("close",(()=>c())),o&&t.addEventListener("versionchange",(()=>o()))})).catch((()=>{})),h}("firebase-heartbeat-database",1,{upgrade:(t,e)=>{if(0===e)t.createObjectStore(et)}}).catch((t=>{throw G.create("idb-open",{originalErrorMessage:t.message})}))),nt}async function ot(t,e){var n;try{const n=(await it()).transaction(et,"readwrite"),r=n.objectStore(et);return await r.put(e,st(t)),n.done}catch(t){if(t instanceof c.c)N.warn(t.message);else{const e=G.create("idb-set",{originalErrorMessage:null===(n=t)||void 0===n?void 0:n.message});N.warn(e.message)}}}function st(t){return`${t.name}!${t.options.appId}`}class at{constructor(t){this.container=t,this._heartbeatsCache=null;const e=this.container.getProvider("app").getImmediate();this._storage=new ut(e),this._heartbeatsCachePromise=this._storage.read().then((t=>(this._heartbeatsCache=t,t)))}async triggerHeartbeat(){const t=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),e=ct();if(null===this._heartbeatsCache&&(this._heartbeatsCache=await this._heartbeatsCachePromise),this._heartbeatsCache.lastSentHeartbeatDate!==e&&!this._heartbeatsCache.heartbeats.some((t=>t.date===e)))return this._heartbeatsCache.heartbeats.push({date:e,agent:t}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter((t=>{const e=new Date(t.date).valueOf();return Date.now()-e<=2592e6})),this._storage.overwrite(this._heartbeatsCache)}async getHeartbeatsHeader(){if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null===this._heartbeatsCache||0===this._heartbeatsCache.heartbeats.length)return"";const t=ct(),{heartbeatsToSend:e,unsentEntries:n}=function(t,e=1024){const n=[];let r=t.slice();for(const o of t){const t=n.find((t=>t.agent===o.agent));if(t){if(t.dates.push(o.date),lt(n)>e){t.dates.pop();break}}else if(n.push({agent:o.agent,dates:[o.date]}),lt(n)>e){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}(this._heartbeatsCache.heartbeats),r=Object(c.d)(JSON.stringify({version:2,heartbeats:e}));return this._heartbeatsCache.lastSentHeartbeatDate=t,n.length>0?(this._heartbeatsCache.heartbeats=n,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),r}}function ct(){return(new Date).toISOString().substring(0,10)}class ut{constructor(t){this.app=t,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!Object(c.m)()&&Object(c.o)().then((()=>!0)).catch((()=>!1))}async read(){if(await this._canUseIndexedDBPromise){return await async function(t){var e;try{return(await it()).transaction(et).objectStore(et).get(st(t))}catch(t){if(t instanceof c.c)N.warn(t.message);else{const n=G.create("idb-get",{originalErrorMessage:null===(e=t)||void 0===e?void 0:e.message});N.warn(n.message)}}}(this.app)||{heartbeats:[]}}return{heartbeats:[]}}async overwrite(t){var e;if(await this._canUseIndexedDBPromise){const n=await this.read();return ot(this.app,{lastSentHeartbeatDate:null!==(e=t.lastSentHeartbeatDate)&&void 0!==e?e:n.lastSentHeartbeatDate,heartbeats:t.heartbeats})}}async add(t){var e;if(await this._canUseIndexedDBPromise){const n=await this.read();return ot(this.app,{lastSentHeartbeatDate:null!==(e=t.lastSentHeartbeatDate)&&void 0!==e?e:n.lastSentHeartbeatDate,heartbeats:[...n.heartbeats,...t.heartbeats]})}}}function lt(t){return Object(c.d)(JSON.stringify({version:2,heartbeats:t})).length}var ht;ht="",B(new r.a("platform-logger",(t=>new C(t)),"PRIVATE")),B(new r.a("heartbeat",(t=>new at(t)),"PRIVATE")),J(D,A,ht),J(D,A,"esm2017"),J("fire-js","")},5:function(t,e,n){"use strict";function r(t,e,n,r,o,c,l){try{var h=t[c](l),f=h.value}catch(t){return void n(t)}h.done?e(f):Promise.resolve(f).then(r,o)}function o(t){return function(){var e=this,n=arguments;return new Promise((function(o,c){var l=t.apply(e,n);function h(t){r(l,o,c,h,f,"next",t)}function f(t){r(l,o,c,h,f,"throw",t)}h(void 0)}))}}n.d(e,"a",(function(){return o}))},51:function(t,e,n){"use strict";n.d(e,"a",(function(){return o})),n.d(e,"b",(function(){return h}));var r=n(4);class o{constructor(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}const c="[DEFAULT]";class l{constructor(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(t){const e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){const t=new r.a;if(this.instancesDeferred.set(e,t),this.isInitialized(e)||this.shouldAutoInitialize())try{const n=this.getOrInitializeService({instanceIdentifier:e});n&&t.resolve(n)}catch(t){}}return this.instancesDeferred.get(e).promise}getImmediate(t){var e;const n=this.normalizeInstanceIdentifier(null==t?void 0:t.identifier),r=null!==(e=null==t?void 0:t.optional)&&void 0!==e&&e;if(!this.isInitialized(n)&&!this.shouldAutoInitialize()){if(r)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:n})}catch(t){if(r)return null;throw t}}getComponent(){return this.component}setComponent(component){if(component.name!==this.name)throw Error(`Mismatching Component ${component.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=component,this.shouldAutoInitialize()){if(function(component){return"EAGER"===component.instantiationMode}(component))try{this.getOrInitializeService({instanceIdentifier:c})}catch(t){}for(const[t,e]of this.instancesDeferred.entries()){const n=this.normalizeInstanceIdentifier(t);try{const t=this.getOrInitializeService({instanceIdentifier:n});e.resolve(t)}catch(t){}}}}clearInstance(t="[DEFAULT]"){this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)}async delete(){const t=Array.from(this.instances.values());await Promise.all([...t.filter((t=>"INTERNAL"in t)).map((t=>t.INTERNAL.delete())),...t.filter((t=>"_delete"in t)).map((t=>t._delete()))])}isComponentSet(){return null!=this.component}isInitialized(t="[DEFAULT]"){return this.instances.has(t)}getOptions(t="[DEFAULT]"){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:e={}}=t,n=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const r=this.getOrInitializeService({instanceIdentifier:n,options:e});for(const[t,e]of this.instancesDeferred.entries()){n===this.normalizeInstanceIdentifier(t)&&e.resolve(r)}return r}onInit(t,e){var n;const r=this.normalizeInstanceIdentifier(e),o=null!==(n=this.onInitCallbacks.get(r))&&void 0!==n?n:new Set;o.add(t),this.onInitCallbacks.set(r,o);const c=this.instances.get(r);return c&&t(c,r),()=>{o.delete(t)}}invokeOnInitCallbacks(t,e){const n=this.onInitCallbacks.get(e);if(n)for(const r of n)try{r(t,e)}catch(t){}}getOrInitializeService({instanceIdentifier:t,options:e={}}){let n=this.instances.get(t);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:(r=t,r===c?void 0:r),options:e}),this.instances.set(t,n),this.instancesOptions.set(t,e),this.invokeOnInitCallbacks(n,t),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,t,n)}catch(t){}var r;return n||null}normalizeInstanceIdentifier(t="[DEFAULT]"){return this.component?this.component.multipleInstances?t:c:t}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class h{constructor(t){this.name=t,this.providers=new Map}addComponent(component){const t=this.getProvider(component.name);if(t.isComponentSet())throw new Error(`Component ${component.name} has already been registered with ${this.name}`);t.setComponent(component)}addOrOverwriteComponent(component){this.getProvider(component.name).isComponentSet()&&this.providers.delete(component.name),this.addComponent(component)}getProvider(t){if(this.providers.has(t))return this.providers.get(t);const e=new l(t,this);return this.providers.set(t,e),e}getProviders(){return Array.from(this.providers.values())}}},59:function(t,e,n){"use strict";function r(t){var e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return e.setUTCFullYear(t.getFullYear()),t.getTime()-e.getTime()}n.d(e,"a",(function(){return r}))},6:function(t,e,n){"use strict";function r(t){if(null===t||!0===t||!1===t)return NaN;var e=Number(t);return isNaN(e)?e:e<0?Math.ceil(e):Math.floor(e)}n.d(e,"a",(function(){return r}))},61:function(t,e,n){"use strict";function r(t,object){if(null==t)throw new TypeError("assign requires that input parameter not be null or undefined");for(var e in object)Object.prototype.hasOwnProperty.call(object,e)&&(t[e]=object[e]);return t}n.d(e,"a",(function(){return r}))},62:function(t,e,n){"use strict";n.d(e,"a",(function(){return f}));var r=n(3),o=n(1),c=n(21),l=n(6),h=n(17);function f(t,e){var n,f,d,m,y,w,v,T;Object(o.a)(1,arguments);var x=Object(r.a)(t),S=x.getUTCFullYear(),I=Object(h.a)(),_=Object(l.a)(null!==(n=null!==(f=null!==(d=null!==(m=null==e?void 0:e.firstWeekContainsDate)&&void 0!==m?m:null==e||null===(y=e.locale)||void 0===y||null===(w=y.options)||void 0===w?void 0:w.firstWeekContainsDate)&&void 0!==d?d:I.firstWeekContainsDate)&&void 0!==f?f:null===(v=I.locale)||void 0===v||null===(T=v.options)||void 0===T?void 0:T.firstWeekContainsDate)&&void 0!==n?n:1);if(!(_>=1&&_<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var E=new Date(0);E.setUTCFullYear(S+1,0,_),E.setUTCHours(0,0,0,0);var O=Object(c.a)(E,e),k=new Date(0);k.setUTCFullYear(S,0,_),k.setUTCHours(0,0,0,0);var C=Object(c.a)(k,e);return x.getTime()>=O.getTime()?S+1:x.getTime()>=C.getTime()?S:S-1}},63:function(t,e,n){"use strict";var r={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},o=function(t,e,n){var o,c=r[t];return o="string"==typeof c?c:1===e?c.one:c.other.replace("{{count}}",e.toString()),null!=n&&n.addSuffix?n.comparison&&n.comparison>0?"in "+o:o+" ago":o};function c(t){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.width?String(e.width):t.defaultWidth,r=t.formats[n]||t.formats[t.defaultWidth];return r}}var l={date:c({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:c({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:c({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},h={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},f=function(t,e,n,r){return h[t]};function d(t){return function(e,n){var r;if("formatting"===(null!=n&&n.context?String(n.context):"standalone")&&t.formattingValues){var o=t.defaultFormattingWidth||t.defaultWidth,c=null!=n&&n.width?String(n.width):o;r=t.formattingValues[c]||t.formattingValues[o]}else{var l=t.defaultWidth,h=null!=n&&n.width?String(n.width):t.defaultWidth;r=t.values[h]||t.values[l]}return r[t.argumentCallback?t.argumentCallback(e):e]}}var m={ordinalNumber:function(t,e){var n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:d({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:d({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(t){return t-1}}),month:d({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:d({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:d({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})};function y(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.width,o=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],c=e.match(o);if(!c)return null;var l,h=c[0],f=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],d=Array.isArray(f)?v(f,(function(pattern){return pattern.test(h)})):w(f,(function(pattern){return pattern.test(h)}));l=t.valueCallback?t.valueCallback(d):d,l=n.valueCallback?n.valueCallback(l):l;var m=e.slice(h.length);return{value:l,rest:m}}}function w(object,t){for(var e in object)if(object.hasOwnProperty(e)&&t(object[e]))return e}function v(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{},n=t.match(T.matchPattern);if(!n)return null;var r=n[0],o=t.match(T.parsePattern);if(!o)return null;var c=T.valueCallback?T.valueCallback(o[0]):o[0];c=e.valueCallback?e.valueCallback(c):c;var l=t.slice(r.length);return{value:c,rest:l}}),era:y({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:y({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:function(t){return t+1}}),month:y({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:y({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:y({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},S={code:"en-US",formatDistance:o,formatLong:l,formatRelative:f,localize:m,match:x,options:{weekStartsOn:0,firstWeekContainsDate:1}};e.a=S},64:function(t,e,n){"use strict";var r={name:"NoSsr",functional:!0,props:{placeholder:String,placeholderTag:{type:String,default:"div"}},render:function(t,e){var n=e.parent,r=e.slots,o=e.props,c=r(),l=c.default;void 0===l&&(l=[]);var h=c.placeholder;return n._isMounted?l:(n.$once("hook:mounted",(function(){n.$forceUpdate()})),o.placeholderTag&&(o.placeholder||h)?t(o.placeholderTag,{class:["no-ssr-placeholder"]},o.placeholder||h):l.length>0?l.map((function(){return t(!1)})):t(!1))}};t.exports=r},66:function(t,e,n){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var content=t(e);return e[2]?"@media ".concat(e[2]," {").concat(content,"}"):content})).join("")},e.i=function(t,n,r){"string"==typeof t&&(t=[[null,t,""]]);var o={};if(r)for(var i=0;ie.parts.length&&(n.parts.length=e.parts.length)}else{var o=[];for(r=0;r=h.getTime()?n+1:e.getTime()>=d.getTime()?n:n-1}},95:function(t,e,n){"use strict";function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i