@thefittingroom/sdk 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * thefittingroom v0.0.11 (2023-09-04T22:52:56.755Z)
2
+ * thefittingroom v0.0.11 (2023-11-21T18:22:57.333Z)
3
3
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
4
4
  */
5
5
  /**
@@ -197,7 +197,7 @@ class u{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Pr
197
197
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
198
198
  * See the License for the specific language governing permissions and
199
199
  * limitations under the License.
200
- */var S;!function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(S||(S={}));const C={debug:S.DEBUG,verbose:S.VERBOSE,info:S.INFO,warn:S.WARN,error:S.ERROR,silent:S.SILENT},k=S.INFO,A={[S.DEBUG]:"log",[S.VERBOSE]:"log",[S.INFO]:"info",[S.WARN]:"warn",[S.ERROR]:"error"},N=(e,t,...n)=>{if(t<e.logLevel)return;const r=(new Date).toISOString(),s=A[t];if(!s)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[s](`[${r}] ${e.name}:`,...n)};class D{constructor(e){this.name=e,this._logLevel=k,this._logHandler=N,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in S))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?C[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,S.DEBUG,...e),this._logHandler(this,S.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,S.VERBOSE,...e),this._logHandler(this,S.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,S.INFO,...e),this._logHandler(this,S.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,S.WARN,...e),this._logHandler(this,S.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,S.ERROR,...e),this._logHandler(this,S.ERROR,...e)}}let R,O;const L=new WeakMap,P=new WeakMap,M=new WeakMap,x=new WeakMap,U=new WeakMap;let F={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return P.get(e);if("objectStoreNames"===t)return e.objectStoreNames||M.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return j(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function V(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(O||(O=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(B(this),t),j(L.get(this))}:function(...t){return j(e.apply(B(this),t))}:function(t,...n){const r=e.call(B(this),t,...n);return M.set(r,t.sort?t.sort():[t]),j(r)}}function q(e){return"function"==typeof e?V(e):(e instanceof IDBTransaction&&function(e){if(P.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",i),e.removeEventListener("abort",i)},s=()=>{t(),r()},i=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",s),e.addEventListener("error",i),e.addEventListener("abort",i)}));P.set(e,t)}(e),t=e,(R||(R=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some((e=>t instanceof e))?new Proxy(e,F):e);var t}function j(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",s),e.removeEventListener("error",i)},s=()=>{t(j(e.result)),r()},i=()=>{n(e.error),r()};e.addEventListener("success",s),e.addEventListener("error",i)}));return t.then((t=>{t instanceof IDBCursor&&L.set(t,e)})).catch((()=>{})),U.set(t,e),t}(e);if(x.has(e))return x.get(e);const t=q(e);return t!==e&&(x.set(e,t),U.set(t,e)),t}const B=e=>U.get(e);const z=["get","getKey","getAll","getAllKeys","count"],$=["put","add","delete","clear"],K=new Map;function H(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(K.get(t))return K.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,s=$.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!s&&!z.includes(n))return;const i=async function(e,...t){const i=this.transaction(e,s?"readwrite":"readonly");let o=i.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),s&&i.done]))[0]};return K.set(t,i),i}F=(e=>({...e,get:(t,n,r)=>H(t,n)||e.get(t,n,r),has:(t,n)=>!!H(t,n)||e.has(t,n)}))(F);
200
+ */var S;!function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(S||(S={}));const C={debug:S.DEBUG,verbose:S.VERBOSE,info:S.INFO,warn:S.WARN,error:S.ERROR,silent:S.SILENT},A=S.INFO,k={[S.DEBUG]:"log",[S.VERBOSE]:"log",[S.INFO]:"info",[S.WARN]:"warn",[S.ERROR]:"error"},N=(e,t,...n)=>{if(t<e.logLevel)return;const r=(new Date).toISOString(),s=k[t];if(!s)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[s](`[${r}] ${e.name}:`,...n)};class D{constructor(e){this.name=e,this._logLevel=A,this._logHandler=N,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in S))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?C[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,S.DEBUG,...e),this._logHandler(this,S.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,S.VERBOSE,...e),this._logHandler(this,S.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,S.INFO,...e),this._logHandler(this,S.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,S.WARN,...e),this._logHandler(this,S.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,S.ERROR,...e),this._logHandler(this,S.ERROR,...e)}}let R,O;const L=new WeakMap,P=new WeakMap,M=new WeakMap,x=new WeakMap,U=new WeakMap;let F={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return P.get(e);if("objectStoreNames"===t)return e.objectStoreNames||M.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return j(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function V(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(O||(O=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(B(this),t),j(L.get(this))}:function(...t){return j(e.apply(B(this),t))}:function(t,...n){const r=e.call(B(this),t,...n);return M.set(r,t.sort?t.sort():[t]),j(r)}}function q(e){return"function"==typeof e?V(e):(e instanceof IDBTransaction&&function(e){if(P.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",i),e.removeEventListener("abort",i)},s=()=>{t(),r()},i=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",s),e.addEventListener("error",i),e.addEventListener("abort",i)}));P.set(e,t)}(e),t=e,(R||(R=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some((e=>t instanceof e))?new Proxy(e,F):e);var t}function j(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",s),e.removeEventListener("error",i)},s=()=>{t(j(e.result)),r()},i=()=>{n(e.error),r()};e.addEventListener("success",s),e.addEventListener("error",i)}));return t.then((t=>{t instanceof IDBCursor&&L.set(t,e)})).catch((()=>{})),U.set(t,e),t}(e);if(x.has(e))return x.get(e);const t=q(e);return t!==e&&(x.set(e,t),U.set(t,e)),t}const B=e=>U.get(e);const z=["get","getKey","getAll","getAllKeys","count"],$=["put","add","delete","clear"],K=new Map;function H(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(K.get(t))return K.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,s=$.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!s&&!z.includes(n))return;const i=async function(e,...t){const i=this.transaction(e,s?"readwrite":"readonly");let o=i.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),s&&i.done]))[0]};return K.set(t,i),i}F=(e=>({...e,get:(t,n,r)=>H(t,n)||e.get(t,n,r),has:(t,n)=>!!H(t,n)||e.has(t,n)}))(F);
201
201
  /**
202
202
  * @license
203
203
  * Copyright 2019 Google LLC
@@ -311,7 +311,7 @@ class ie{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e)
311
311
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
312
312
  * See the License for the specific language governing permissions and
313
313
  * limitations under the License.
314
- */var we;we="",ne(new b("platform-logger",(e=>new G(e)),"PRIVATE")),ne(new b("heartbeat",(e=>new ge(e)),"PRIVATE")),ue(W,Q,we),ue(W,Q,"esm2017"),ue("fire-js","");var Ie=function(e,t){return Ie=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Ie(e,t)};function be(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Te(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,s,i=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)o.push(r.value)}catch(e){s={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(s)throw s.error}}return o}var Ee,_e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Se=Se||{},Ce=_e||self;function ke(){}function Ae(e){var t=typeof e;return"array"==(t="object"!=t?t:e?Array.isArray(e)?"array":t:"null")||"object"==t&&"number"==typeof e.length}function Ne(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}var De="closure_uid_"+(1e9*Math.random()>>>0),Re=0;function Oe(e,t,n){return e.call.apply(e.bind,arguments)}function Le(e,t,n){if(!e)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,r),e.apply(t,n)}}return function(){return e.apply(t,arguments)}}function Pe(e,t,n){return(Pe=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?Oe:Le).apply(null,arguments)}function Me(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}function xe(e,t){function n(){}n.prototype=t.prototype,e.X=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.Wb=function(e,n,r){for(var s=Array(arguments.length-2),i=2;i<arguments.length;i++)s[i-2]=arguments[i];return t.prototype[n].apply(e,s)}}function Ue(){this.s=this.s,this.o=this.o}Ue.prototype.s=!1,Ue.prototype.na=function(){var e;!this.s&&(this.s=!0,this.M(),0)&&(e=this,Object.prototype.hasOwnProperty.call(e,De)&&e[De]||(e[De]=++Re))},Ue.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};var Fe=Array.prototype.indexOf?function(e,t){return Array.prototype.indexOf.call(e,t,void 0)}:function(e,t){if("string"==typeof e)return"string"!=typeof t||1!=t.length?-1:e.indexOf(t,0);for(var n=0;n<e.length;n++)if(n in e&&e[n]===t)return n;return-1};function Ve(e){var t=e.length;if(0<t){for(var n=Array(t),r=0;r<t;r++)n[r]=e[r];return n}return[]}function qe(e,t){for(var n=1;n<arguments.length;n++){var r=arguments[n];if(Ae(r)){var s=e.length||0,i=r.length||0;e.length=s+i;for(var o=0;o<i;o++)e[s+o]=r[o]}else e.push(r)}}function je(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}je.prototype.h=function(){this.defaultPrevented=!0};var Be=function(){if(!Ce.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{Ce.addEventListener("test",ke,t),Ce.removeEventListener("test",ke,t)}catch(e){}return e}();function ze(e){return/^[\s\xa0]*$/.test(e)}var $e=String.prototype.trim?function(e){return e.trim()}:function(e){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(e)[1]};function Ke(e,t){return e<t?-1:e>t?1:0}function He(){var e=Ce.navigator;return e&&(e=e.userAgent)?e:""}function Ge(e){return-1!=He().indexOf(e)}function We(e){return We[" "](e),e}We[" "]=ke;var Qe,Ye,Xe=Ge("Opera"),Je=Ge("Trident")||Ge("MSIE"),Ze=Ge("Edge"),et=Ze||Je,tt=Ge("Gecko")&&!(-1!=He().toLowerCase().indexOf("webkit")&&!Ge("Edge"))&&!(Ge("Trident")||Ge("MSIE"))&&!Ge("Edge"),nt=-1!=He().toLowerCase().indexOf("webkit")&&!Ge("Edge");function rt(){var e=Ce.document;return e?e.documentMode:void 0}e:{var st="",it=(Ye=He(),tt?/rv:([^\);]+)(\)|;)/.exec(Ye):Ze?/Edge\/([\d\.]+)/.exec(Ye):Je?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(Ye):nt?/WebKit\/(\S+)/.exec(Ye):Xe?/(?:Version)[ \/]?(\S+)/.exec(Ye):void 0);if(it&&(st=it?it[1]:""),Je){var ot=rt();if(null!=ot&&ot>parseFloat(st)){Qe=String(ot);break e}}Qe=st}var at,ct={};function ut(){return function(e){var t=ct;return Object.prototype.hasOwnProperty.call(t,9)?t[9]:t[9]=e(9)}((function(){for(var e=0,t=$e(String(Qe)).split("."),n=$e("9").split("."),r=Math.max(t.length,n.length),s=0;0==e&&s<r;s++){var i=t[s]||"",o=n[s]||"";do{if(i=/(\d*)(\D*)(.*)/.exec(i)||["","","",""],o=/(\d*)(\D*)(.*)/.exec(o)||["","","",""],0==i[0].length&&0==o[0].length)break;e=Ke(0==i[1].length?0:parseInt(i[1],10),0==o[1].length?0:parseInt(o[1],10))||Ke(0==i[2].length,0==o[2].length)||Ke(i[2],o[2]),i=i[3],o=o[3]}while(0==e)}return 0<=e}))}if(Ce.document&&Je){var ht=rt();at=ht||(parseInt(Qe,10)||void 0)}else at=void 0;var lt=at;function dt(e,t){if(je.call(this,e?e.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,e){var n=this.type=e.type,r=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;if(this.target=e.target||e.srcElement,this.g=t,t=e.relatedTarget){if(tt){e:{try{We(t.nodeName);var s=!0;break e}catch(e){}s=!1}s||(t=null)}}else"mouseover"==n?t=e.fromElement:"mouseout"==n&&(t=e.toElement);this.relatedTarget=t,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==e.clientX?e.clientX:e.pageX,this.clientY=void 0!==e.clientY?e.clientY:e.pageY,this.screenX=e.screenX||0,this.screenY=e.screenY||0),this.button=e.button,this.key=e.key||"",this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.pointerId=e.pointerId||0,this.pointerType="string"==typeof e.pointerType?e.pointerType:ft[e.pointerType]||"",this.state=e.state,this.i=e,e.defaultPrevented&&dt.X.h.call(this)}}xe(dt,je);var ft={2:"touch",3:"pen",4:"mouse"};dt.prototype.h=function(){dt.X.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var pt="closure_listenable_"+(1e6*Math.random()|0),gt=0;function mt(e,t,n,r,s){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ha=s,this.key=++gt,this.ba=this.ea=!1}function yt(e){e.ba=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function vt(e,t,n){for(var r in e)t.call(n,e[r],r,e)}function wt(e){var t={};for(var n in e)t[n]=e[n];return t}var It="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function bt(e,t){for(var n,r,s=1;s<arguments.length;s++){for(n in r=arguments[s])e[n]=r[n];for(var i=0;i<It.length;i++)n=It[i],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}function Tt(e){this.src=e,this.g={},this.h=0}function Et(e,t){var n=t.type;if(n in e.g){var r,s=e.g[n],i=Fe(s,t);(r=0<=i)&&Array.prototype.splice.call(s,i,1),r&&(yt(t),0==e.g[n].length&&(delete e.g[n],e.h--))}}function _t(e,t,n,r){for(var s=0;s<e.length;++s){var i=e[s];if(!i.ba&&i.listener==t&&i.capture==!!n&&i.ha==r)return s}return-1}Tt.prototype.add=function(e,t,n,r,s){var i=e.toString();(e=this.g[i])||(e=this.g[i]=[],this.h++);var o=_t(e,t,r,s);return-1<o?(t=e[o],n||(t.ea=!1)):((t=new mt(t,this.src,i,!!r,s)).ea=n,e.push(t)),t};var St="closure_lm_"+(1e6*Math.random()|0),Ct={};function kt(e,t,n,r,s){if(r&&r.once)return Nt(e,t,n,r,s);if(Array.isArray(t)){for(var i=0;i<t.length;i++)kt(e,t[i],n,r,s);return null}return n=xt(n),e&&e[pt]?e.N(t,n,Ne(r)?!!r.capture:!!r,s):At(e,t,n,!1,r,s)}function At(e,t,n,r,s,i){if(!t)throw Error("Invalid event type");var o=Ne(s)?!!s.capture:!!s,a=Pt(e);if(a||(e[St]=a=new Tt(e)),(n=a.add(t,n,r,o,i)).proxy)return n;if(r=function(){function e(n){return t.call(e.src,e.listener,n)}var t=Lt;return e}(),n.proxy=r,r.src=e,r.listener=n,e.addEventListener)Be||(s=o),void 0===s&&(s=!1),e.addEventListener(t.toString(),r,s);else if(e.attachEvent)e.attachEvent(Ot(t.toString()),r);else{if(!e.addListener||!e.removeListener)throw Error("addEventListener and attachEvent are unavailable.");e.addListener(r)}return n}function Nt(e,t,n,r,s){if(Array.isArray(t)){for(var i=0;i<t.length;i++)Nt(e,t[i],n,r,s);return null}return n=xt(n),e&&e[pt]?e.O(t,n,Ne(r)?!!r.capture:!!r,s):At(e,t,n,!0,r,s)}function Dt(e,t,n,r,s){if(Array.isArray(t))for(var i=0;i<t.length;i++)Dt(e,t[i],n,r,s);else r=Ne(r)?!!r.capture:!!r,n=xt(n),e&&e[pt]?(e=e.i,(t=String(t).toString())in e.g&&(-1<(n=_t(i=e.g[t],n,r,s))&&(yt(i[n]),Array.prototype.splice.call(i,n,1),0==i.length&&(delete e.g[t],e.h--)))):e&&(e=Pt(e))&&(t=e.g[t.toString()],e=-1,t&&(e=_t(t,n,r,s)),(n=-1<e?t[e]:null)&&Rt(n))}function Rt(e){if("number"!=typeof e&&e&&!e.ba){var t=e.src;if(t&&t[pt])Et(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(Ot(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=Pt(t))?(Et(n,e),0==n.h&&(n.src=null,t[St]=null)):yt(e)}}}function Ot(e){return e in Ct?Ct[e]:Ct[e]="on"+e}function Lt(e,t){if(e.ba)e=!0;else{t=new dt(t,this);var n=e.listener,r=e.ha||e.src;e.ea&&Rt(e),e=n.call(r,t)}return e}function Pt(e){return(e=e[St])instanceof Tt?e:null}var Mt="__closure_events_fn_"+(1e9*Math.random()>>>0);function xt(e){return"function"==typeof e?e:(e[Mt]||(e[Mt]=function(t){return e.handleEvent(t)}),e[Mt])}function Ut(){Ue.call(this),this.i=new Tt(this),this.P=this,this.I=null}function Ft(e,t){var n,r=e.I;if(r)for(n=[];r;r=r.I)n.push(r);if(e=e.P,r=t.type||t,"string"==typeof t)t=new je(t,e);else if(t instanceof je)t.target=t.target||e;else{var s=t;bt(t=new je(r,e),s)}if(s=!0,n)for(var i=n.length-1;0<=i;i--){var o=t.g=n[i];s=Vt(o,r,!0,t)&&s}if(s=Vt(o=t.g=e,r,!0,t)&&s,s=Vt(o,r,!1,t)&&s,n)for(i=0;i<n.length;i++)s=Vt(o=t.g=n[i],r,!1,t)&&s}function Vt(e,t,n,r){if(!(t=e.i.g[String(t)]))return!0;t=t.concat();for(var s=!0,i=0;i<t.length;++i){var o=t[i];if(o&&!o.ba&&o.capture==n){var a=o.listener,c=o.ha||o.src;o.ea&&Et(e.i,o),s=!1!==a.call(c,r)&&s}}return s&&!r.defaultPrevented}xe(Ut,Ue),Ut.prototype[pt]=!0,Ut.prototype.removeEventListener=function(e,t,n,r){Dt(this,e,t,n,r)},Ut.prototype.M=function(){if(Ut.X.M.call(this),this.i){var e,t=this.i;for(e in t.g){for(var n=t.g[e],r=0;r<n.length;r++)yt(n[r]);delete t.g[e],t.h--}}this.I=null},Ut.prototype.N=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},Ut.prototype.O=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};var qt=Ce.JSON.stringify;function jt(){var e=Qt,t=null;return e.g&&(t=e.g,e.g=e.g.next,e.g||(e.h=null),t.next=null),t}var Bt,zt=function(){function e(){this.h=this.g=null}return e.prototype.add=function(e,t){var n=$t.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n},e}(),$t=new(function(){function e(e,t){this.i=e,this.j=t,this.h=0,this.g=null}return e.prototype.get=function(){var e;return 0<this.h?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e},e}())((function(){return new Kt}),(function(e){return e.reset()})),Kt=function(){function e(){this.next=this.g=this.h=null}return e.prototype.set=function(e,t){this.h=e,this.g=t,this.next=null},e.prototype.reset=function(){this.next=this.g=this.h=null},e}();function Ht(e){Ce.setTimeout((function(){throw e}),0)}function Gt(e,t){Bt||function(){var e=Ce.Promise.resolve(void 0);Bt=function(){e.then(Yt)}}(),Wt||(Bt(),Wt=!0),Qt.add(e,t)}var Wt=!1,Qt=new zt;function Yt(){for(var e;e=jt();){try{e.h.call(e.g)}catch(e){Ht(e)}var t=$t;t.j(e),100>t.h&&(t.h++,e.next=t.g,t.g=e)}Wt=!1}function Xt(e,t){Ut.call(this),this.h=e||1,this.g=t||Ce,this.j=Pe(this.lb,this),this.l=Date.now()}function Jt(e){e.ca=!1,e.R&&(e.g.clearTimeout(e.R),e.R=null)}function Zt(e,t,n){if("function"==typeof e)n&&(e=Pe(e,n));else{if(!e||"function"!=typeof e.handleEvent)throw Error("Invalid listener argument");e=Pe(e.handleEvent,e)}return 2147483647<Number(t)?-1:Ce.setTimeout(e,t||0)}function en(e){e.g=Zt((function(){e.g=null,e.i&&(e.i=!1,en(e))}),e.j);var t=e.h;e.h=null,e.m.apply(null,t)}xe(Xt,Ut),(Ee=Xt.prototype).ca=!1,Ee.R=null,Ee.lb=function(){if(this.ca){var e=Date.now()-this.l;0<e&&e<.8*this.h?this.R=this.g.setTimeout(this.j,this.h-e):(this.R&&(this.g.clearTimeout(this.R),this.R=null),Ft(this,"tick"),this.ca&&(Jt(this),this.start()))}},Ee.start=function(){this.ca=!0,this.R||(this.R=this.g.setTimeout(this.j,this.h),this.l=Date.now())},Ee.M=function(){Xt.X.M.call(this),Jt(this),delete this.g};var tn=function(e){function t(t,n){var r=e.call(this)||this;return r.m=t,r.j=n,r.h=null,r.i=!1,r.g=null,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}Ie(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t.prototype.l=function(e){this.h=arguments,this.g?this.i=!0:en(this)},t.prototype.M=function(){e.prototype.M.call(this),this.g&&(Ce.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)},t}(Ue);function nn(e){Ue.call(this),this.h=e,this.g={}}xe(nn,Ue);var rn=[];function sn(e,t,n,r){Array.isArray(n)||(n&&(rn[0]=n.toString()),n=rn);for(var s=0;s<n.length;s++){var i=kt(t,n[s],r||e.handleEvent,!1,e.h||e);if(!i)break;e.g[i.key]=i}}function on(e){vt(e.g,(function(e,t){this.g.hasOwnProperty(t)&&Rt(e)}),e),e.g={}}function an(){this.g=!0}function cn(e,t,n,r){e.info((function(){return"XMLHTTP TEXT ("+t+"): "+function(e,t){if(!e.g)return t;if(!t)return null;try{var n=JSON.parse(t);if(n)for(e=0;e<n.length;e++)if(Array.isArray(n[e])){var r=n[e];if(!(2>r.length)){var s=r[1];if(Array.isArray(s)&&!(1>s.length)){var i=s[0];if("noop"!=i&&"stop"!=i&&"close"!=i)for(var o=1;o<s.length;o++)s[o]=""}}}return qt(n)}catch(e){return t}}(e,n)+(r?" "+r:"")}))}nn.prototype.M=function(){nn.X.M.call(this),on(this)},nn.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},an.prototype.Aa=function(){this.g=!1},an.prototype.info=function(){};var un={},hn=null;function ln(){return hn=hn||new Ut}function dn(e){je.call(this,un.Pa,e)}function fn(e){var t=ln();Ft(t,new dn(t))}function pn(e,t){je.call(this,un.STAT_EVENT,e),this.stat=t}function gn(e){var t=ln();Ft(t,new pn(t,e))}function mn(e,t){je.call(this,un.Qa,e),this.size=t}function yn(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return Ce.setTimeout((function(){e()}),t)}un.Pa="serverreachability",xe(dn,je),un.STAT_EVENT="statevent",xe(pn,je),un.Qa="timingevent",xe(mn,je);var vn={NO_ERROR:0,mb:1,zb:2,yb:3,tb:4,xb:5,Ab:6,Ma:7,TIMEOUT:8,Db:9},wn={rb:"complete",Nb:"success",Na:"error",Ma:"abort",Fb:"ready",Gb:"readystatechange",TIMEOUT:"timeout",Bb:"incrementaldata",Eb:"progress",ub:"downloadprogress",Vb:"uploadprogress"};function In(){}function bn(e){return e.h||(e.h=e.i())}function Tn(){}In.prototype.h=null;var En,_n={OPEN:"a",qb:"b",Na:"c",Cb:"d"};function Sn(){je.call(this,"d")}function Cn(){je.call(this,"c")}function kn(){}function An(e,t,n,r){this.l=e,this.j=t,this.m=n,this.U=r||1,this.S=new nn(this),this.O=Dn,e=et?125:void 0,this.T=new Xt(e),this.H=null,this.i=!1,this.s=this.A=this.v=this.K=this.F=this.V=this.B=null,this.D=[],this.g=null,this.C=0,this.o=this.u=null,this.Y=-1,this.I=!1,this.N=0,this.L=null,this.$=this.J=this.Z=this.P=!1,this.h=new Nn}function Nn(){this.i=null,this.g="",this.h=!1}xe(Sn,je),xe(Cn,je),xe(kn,In),kn.prototype.g=function(){return new XMLHttpRequest},kn.prototype.i=function(){return{}},En=new kn;var Dn=45e3,Rn={},On={};function Ln(e,t,n){e.K=1,e.v=Jn(Gn(t)),e.s=n,e.P=!0,Pn(e,null)}function Pn(e,t){e.F=Date.now(),Fn(e),e.A=Gn(e.v);var n=e.A,r=e.U;Array.isArray(r)||(r=[String(r)]),lr(n.i,"t",r),e.C=0,n=e.l.H,e.h=new Nn,e.g=ls(e.l,n?t:null,!e.s),0<e.N&&(e.L=new tn(Pe(e.La,e,e.g),e.N)),sn(e.S,e.g,"readystatechange",e.ib),t=e.H?wt(e.H):{},e.s?(e.u||(e.u="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.da(e.A,e.u,e.s,t)):(e.u="GET",e.g.da(e.A,e.u,null,t)),fn(),function(e,t,n,r,s,i){e.info((function(){if(e.g)if(i)for(var o="",a=i.split("&"),c=0;c<a.length;c++){var u=a[c].split("=");if(1<u.length){var h=u[0];u=u[1];var l=h.split("_");o=2<=l.length&&"type"==l[1]?o+(h+"=")+u+"&":o+(h+"=redacted&")}}else o=null;else o=i;return"XMLHTTP REQ ("+r+") [attempt "+s+"]: "+t+"\n"+n+"\n"+o}))}(e.j,e.u,e.A,e.m,e.U,e.s)}function Mn(e){return!!e.g&&("GET"==e.u&&2!=e.K&&e.l.Da)}function xn(e,t,n){for(var r,s=!0;!e.I&&e.C<n.length;){if((r=Un(e,n))==On){4==t&&(e.o=4,gn(14),s=!1),cn(e.j,e.m,null,"[Incomplete Response]");break}if(r==Rn){e.o=4,gn(15),cn(e.j,e.m,n,"[Invalid Chunk]"),s=!1;break}cn(e.j,e.m,r,null),zn(e,r)}Mn(e)&&r!=On&&r!=Rn&&(e.h.g="",e.C=0),4!=t||0!=n.length||e.h.h||(e.o=1,gn(16),s=!1),e.i=e.i&&s,s?0<n.length&&!e.$&&(e.$=!0,(t=e.l).g==e&&t.$&&!t.K&&(t.j.info("Great, no buffering proxy detected. Bytes received: "+n.length),rs(t),t.K=!0,gn(11))):(cn(e.j,e.m,n,"[Invalid Chunked Response]"),Bn(e),jn(e))}function Un(e,t){var n=e.C,r=t.indexOf("\n",n);return-1==r?On:(n=Number(t.substring(n,r)),isNaN(n)?Rn:(r+=1)+n>t.length?On:(t=t.substr(r,n),e.C=r+n,t))}function Fn(e){e.V=Date.now()+e.O,Vn(e,e.O)}function Vn(e,t){if(null!=e.B)throw Error("WatchDog timer not null");e.B=yn(Pe(e.gb,e),t)}function qn(e){e.B&&(Ce.clearTimeout(e.B),e.B=null)}function jn(e){0==e.l.G||e.I||os(e.l,e)}function Bn(e){qn(e);var t=e.L;t&&"function"==typeof t.na&&t.na(),e.L=null,Jt(e.T),on(e.S),e.g&&(t=e.g,e.g=null,t.abort(),t.na())}function zn(e,t){try{var n=e.l;if(0!=n.G&&(n.g==e||vr(n.h,e)))if(!e.J&&vr(n.h,e)&&3==n.G){try{var r=n.Fa.g.parse(t)}catch(i){r=null}if(Array.isArray(r)&&3==r.length){var s=r;if(0==s[0]){e:if(!n.u){if(n.g){if(!(n.g.F+3e3<e.F))break e;is(n),Qr(n)}ns(n),gn(18)}}else n.Ba=s[1],0<n.Ba-n.T&&37500>s[2]&&n.L&&0==n.A&&!n.v&&(n.v=yn(Pe(n.cb,n),6e3));if(1>=yr(n.h)&&n.ja){try{n.ja()}catch(i){}n.ja=void 0}}else cs(n,11)}else if((e.J||n.g==e)&&is(n),!ze(t))for(s=n.Fa.g.parse(t),t=0;t<s.length;t++){var i=s[t];if(n.T=i[0],i=i[1],2==n.G)if("c"==i[0]){n.I=i[1],n.ka=i[2];var o=i[3];null!=o&&(n.ma=o,n.j.info("VER="+n.ma));var a=i[4];null!=a&&(n.Ca=a,n.j.info("SVER="+n.Ca));var c=i[5];null!=c&&"number"==typeof c&&0<c&&(r=1.5*c,n.J=r,n.j.info("backChannelRequestTimeoutMs_="+r)),r=n;var u=e.g;if(u){var h=u.g?u.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(h){var l=r.h;l.g||-1==h.indexOf("spdy")&&-1==h.indexOf("quic")&&-1==h.indexOf("h2")||(l.j=l.l,l.g=new Set,l.h&&(wr(l,l.h),l.h=null))}if(r.D){var d=u.g?u.g.getResponseHeader("X-HTTP-Session-Id"):null;d&&(r.za=d,Xn(r.F,r.D,d))}}n.G=3,n.l&&n.l.xa(),n.$&&(n.P=Date.now()-e.F,n.j.info("Handshake RTT: "+n.P+"ms"));var f=e;if((r=n).sa=hs(r,r.H?r.ka:null,r.V),f.J){Ir(r.h,f);var p=f,g=r.J;g&&p.setTimeout(g),p.B&&(qn(p),Fn(p)),r.g=f}else ts(r);0<n.i.length&&Xr(n)}else"stop"!=i[0]&&"close"!=i[0]||cs(n,7);else 3==n.G&&("stop"==i[0]||"close"==i[0]?"stop"==i[0]?cs(n,7):Wr(n):"noop"!=i[0]&&n.l&&n.l.wa(i),n.A=0)}fn()}catch(i){}}function $n(e,t){if(e.forEach&&"function"==typeof e.forEach)e.forEach(t,void 0);else if(Ae(e)||"string"==typeof e)Array.prototype.forEach.call(e,t,void 0);else for(var n=function(e){if(e.oa&&"function"==typeof e.oa)return e.oa();if(!e.W||"function"!=typeof e.W){if("undefined"!=typeof Map&&e instanceof Map)return Array.from(e.keys());if(!("undefined"!=typeof Set&&e instanceof Set)){if(Ae(e)||"string"==typeof e){var t=[];e=e.length;for(var n=0;n<e;n++)t.push(n);return t}for(var r in t=[],n=0,e)t[n++]=r;return t}}}(e),r=function(e){if(e.W&&"function"==typeof e.W)return e.W();if("undefined"!=typeof Map&&e instanceof Map||"undefined"!=typeof Set&&e instanceof Set)return Array.from(e.values());if("string"==typeof e)return e.split("");if(Ae(e)){for(var t=[],n=e.length,r=0;r<n;r++)t.push(e[r]);return t}for(r in t=[],n=0,e)t[n++]=e[r];return t}(e),s=r.length,i=0;i<s;i++)t.call(void 0,r[i],n&&n[i],e)}(Ee=An.prototype).setTimeout=function(e){this.O=e},Ee.ib=function(e){e=e.target;var t=this.L;t&&3==Br(e)?t.l():this.La(e)},Ee.La=function(e){try{if(e==this.g)e:{var t=Br(this.g),n=this.g.Ea();this.g.aa();if(!(3>t)&&(3!=t||et||this.g&&(this.h.h||this.g.fa()||zr(this.g)))){this.I||4!=t||7==n||fn(),qn(this);var r=this.g.aa();this.Y=r;t:if(Mn(this)){var s=zr(this.g);e="";var i=s.length,o=4==Br(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){Bn(this),jn(this);var a="";break t}this.h.i=new Ce.TextDecoder}for(n=0;n<i;n++)this.h.h=!0,e+=this.h.i.decode(s[n],{stream:o&&n==i-1});s.splice(0,i),this.h.g+=e,this.C=0,a=this.h.g}else a=this.g.fa();if(this.i=200==r,function(e,t,n,r,s,i,o){e.info((function(){return"XMLHTTP RESP ("+r+") [ attempt "+s+"]: "+t+"\n"+n+"\n"+i+" "+o}))}(this.j,this.u,this.A,this.m,this.U,t,r),this.i){if(this.Z&&!this.J){t:{if(this.g){var c,u=this.g;if((c=u.g?u.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!ze(c)){var h=c;break t}}h=null}if(!(r=h)){this.i=!1,this.o=3,gn(12),Bn(this),jn(this);break e}cn(this.j,this.m,r,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,zn(this,r)}this.P?(xn(this,t,a),et&&this.i&&3==t&&(sn(this.S,this.T,"tick",this.hb),this.T.start())):(cn(this.j,this.m,a,null),zn(this,a)),4==t&&Bn(this),this.i&&!this.I&&(4==t?os(this.l,this):(this.i=!1,Fn(this)))}else 400==r&&0<a.indexOf("Unknown SID")?(this.o=3,gn(12)):(this.o=0,gn(13)),Bn(this),jn(this)}}}catch(t){}},Ee.hb=function(){if(this.g){var e=Br(this.g),t=this.g.fa();this.C<t.length&&(qn(this),xn(this,e,t),this.i&&4!=e&&Fn(this))}},Ee.cancel=function(){this.I=!0,Bn(this)},Ee.gb=function(){this.B=null;var e=Date.now();0<=e-this.V?(function(e,t){e.info((function(){return"TIMEOUT: "+t}))}(this.j,this.A),2!=this.K&&(fn(),gn(17)),Bn(this),this.o=2,jn(this)):Vn(this,this.V-e)};var Kn=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Hn(e,t){if(this.g=this.s=this.j="",this.m=null,this.o=this.l="",this.h=!1,e instanceof Hn){this.h=void 0!==t?t:e.h,Wn(this,e.j),this.s=e.s,this.g=e.g,Qn(this,e.m),this.l=e.l,t=e.i;var n=new ar;n.i=t.i,t.g&&(n.g=new Map(t.g),n.h=t.h),Yn(this,n),this.o=e.o}else e&&(n=String(e).match(Kn))?(this.h=!!t,Wn(this,n[1]||"",!0),this.s=Zn(n[2]||""),this.g=Zn(n[3]||"",!0),Qn(this,n[4]),this.l=Zn(n[5]||"",!0),Yn(this,n[6]||"",!0),this.o=Zn(n[7]||"")):(this.h=!!t,this.i=new ar(null,this.h))}function Gn(e){return new Hn(e)}function Wn(e,t,n){e.j=n?Zn(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function Qn(e,t){if(t){if(t=Number(t),isNaN(t)||0>t)throw Error("Bad port number "+t);e.m=t}else e.m=null}function Yn(e,t,n){t instanceof ar?(e.i=t,function(e,t){t&&!e.j&&(cr(e),e.i=null,e.g.forEach((function(e,t){var n=t.toLowerCase();t!=n&&(ur(this,t),lr(this,n,e))}),e)),e.j=t}(e.i,e.h)):(n||(t=er(t,ir)),e.i=new ar(t,e.h))}function Xn(e,t,n){e.i.set(t,n)}function Jn(e){return Xn(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),e}function Zn(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function er(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,tr),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function tr(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}Hn.prototype.toString=function(){var e=[],t=this.j;t&&e.push(er(t,nr,!0),":");var n=this.g;return(n||"file"==t)&&(e.push("//"),(t=this.s)&&e.push(er(t,nr,!0),"@"),e.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.m)&&e.push(":",String(n))),(n=this.l)&&(this.g&&"/"!=n.charAt(0)&&e.push("/"),e.push(er(n,"/"==n.charAt(0)?sr:rr,!0))),(n=this.i.toString())&&e.push("?",n),(n=this.o)&&e.push("#",er(n,or)),e.join("")};var nr=/[#\/\?@]/g,rr=/[#\?:]/g,sr=/[#\?]/g,ir=/[#\?@]/g,or=/#/g;function ar(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function cr(e){e.g||(e.g=new Map,e.h=0,e.i&&function(e,t){if(e){e=e.split("&");for(var n=0;n<e.length;n++){var r=e[n].indexOf("="),s=null;if(0<=r){var i=e[n].substring(0,r);s=e[n].substring(r+1)}else i=e[n];t(i,s?decodeURIComponent(s.replace(/\+/g," ")):"")}}}(e.i,(function(t,n){e.add(decodeURIComponent(t.replace(/\+/g," ")),n)})))}function ur(e,t){cr(e),t=dr(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function hr(e,t){return cr(e),t=dr(e,t),e.g.has(t)}function lr(e,t,n){ur(e,t),0<n.length&&(e.i=null,e.g.set(dr(e,t),Ve(n)),e.h+=n.length)}function dr(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}(Ee=ar.prototype).add=function(e,t){cr(this),this.i=null,e=dr(this,e);var n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this},Ee.forEach=function(e,t){cr(this),this.g.forEach((function(n,r){n.forEach((function(n){e.call(t,n,r,this)}),this)}),this)},Ee.oa=function(){cr(this);for(var e=Array.from(this.g.values()),t=Array.from(this.g.keys()),n=[],r=0;r<t.length;r++)for(var s=e[r],i=0;i<s.length;i++)n.push(t[r]);return n},Ee.W=function(e){cr(this);var t=[];if("string"==typeof e)hr(this,e)&&(t=t.concat(this.g.get(dr(this,e))));else{e=Array.from(this.g.values());for(var n=0;n<e.length;n++)t=t.concat(e[n])}return t},Ee.set=function(e,t){return cr(this),this.i=null,hr(this,e=dr(this,e))&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},Ee.get=function(e,t){return e&&0<(e=this.W(e)).length?String(e[0]):t},Ee.toString=function(){if(this.i)return this.i;if(!this.g)return"";for(var e=[],t=Array.from(this.g.keys()),n=0;n<t.length;n++){var r=t[n],s=encodeURIComponent(String(r)),i=this.W(r);for(r=0;r<i.length;r++){var o=s;""!==i[r]&&(o+="="+encodeURIComponent(String(i[r]))),e.push(o)}}return this.i=e.join("&")};var fr=function(e,t){this.h=e,this.g=t};function pr(e){this.l=e||gr,Ce.PerformanceNavigationTiming?e=0<(e=Ce.performance.getEntriesByType("navigation")).length&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):e=!!(Ce.g&&Ce.g.Ga&&Ce.g.Ga()&&Ce.g.Ga().$b),this.j=e?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}var gr=10;function mr(e){return!!e.h||!!e.g&&e.g.size>=e.j}function yr(e){return e.h?1:e.g?e.g.size:0}function vr(e,t){return e.h?e.h==t:!!e.g&&e.g.has(t)}function wr(e,t){e.g?e.g.add(t):e.h=t}function Ir(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function br(e){var t,n;if(null!=e.h)return e.i.concat(e.h.D);if(null!=e.g&&0!==e.g.size){var r=e.i;try{for(var s=be(e.g.values()),i=s.next();!i.done;i=s.next()){var o=i.value;r=r.concat(o.D)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return r}return Ve(e.i)}function Tr(){}function Er(){this.g=new Tr}function _r(e,t,n){var r=n||"";try{$n(e,(function(e,n){var s=e;Ne(e)&&(s=qt(e)),t.push(r+n+"="+encodeURIComponent(s))}))}catch(e){throw t.push(r+"type="+encodeURIComponent("_badmap")),e}}function Sr(e,t,n,r,s){try{t.onload=null,t.onerror=null,t.onabort=null,t.ontimeout=null,s(r)}catch(e){}}function Cr(e){this.l=e.ac||null,this.j=e.jb||!1}function kr(e,t){Ut.call(this),this.D=e,this.u=t,this.m=void 0,this.readyState=Ar,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}pr.prototype.cancel=function(){var e,t;if(this.i=br(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){try{for(var n=be(this.g.values()),r=n.next();!r.done;r=n.next()){r.value.cancel()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.g.clear()}},Tr.prototype.stringify=function(e){return Ce.JSON.stringify(e,void 0)},Tr.prototype.parse=function(e){return Ce.JSON.parse(e,void 0)},xe(Cr,In),Cr.prototype.g=function(){return new kr(this.l,this.j)},Cr.prototype.i=function(e){return function(){return e}}({}),xe(kr,Ut);var Ar=0;function Nr(e){e.j.read().then(e.Ta.bind(e)).catch(e.ga.bind(e))}function Dr(e){e.readyState=4,e.l=null,e.j=null,e.A=null,Rr(e)}function Rr(e){e.onreadystatechange&&e.onreadystatechange.call(e)}(Ee=kr.prototype).open=function(e,t){if(this.readyState!=Ar)throw this.abort(),Error("Error reopening a connection");this.C=e,this.B=t,this.readyState=1,Rr(this)},Ee.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;var t={headers:this.v,method:this.C,credentials:this.m,cache:void 0};e&&(t.body=e),(this.D||Ce).fetch(new Request(this.B,t)).then(this.Wa.bind(this),this.ga.bind(this))},Ee.abort=function(){this.response=this.responseText="",this.v=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch((function(){})),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,Dr(this)),this.readyState=Ar},Ee.Wa=function(e){if(this.g&&(this.l=e,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=e.headers,this.readyState=2,Rr(this)),this.g&&(this.readyState=3,Rr(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Ua.bind(this),this.ga.bind(this));else if(void 0!==Ce.ReadableStream&&"body"in e){if(this.j=e.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;Nr(this)}else e.text().then(this.Va.bind(this),this.ga.bind(this))},Ee.Ta=function(e){if(this.g){if(this.u&&e.value)this.response.push(e.value);else if(!this.u){var t=e.value?e.value:new Uint8Array(0);(t=this.A.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?Dr(this):Rr(this),3==this.readyState&&Nr(this)}},Ee.Va=function(e){this.g&&(this.response=this.responseText=e,Dr(this))},Ee.Ua=function(e){this.g&&(this.response=e,Dr(this))},Ee.ga=function(){this.g&&Dr(this)},Ee.setRequestHeader=function(e,t){this.v.append(e,t)},Ee.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||""},Ee.getAllResponseHeaders=function(){if(!this.h)return"";for(var e=[],t=this.h.entries(),n=t.next();!n.done;)n=n.value,e.push(n[0]+": "+n[1]),n=t.next();return e.join("\r\n")},Object.defineProperty(kr.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}});var Or=Ce.JSON.parse;function Lr(e){Ut.call(this),this.headers=new Map,this.u=e||null,this.h=!1,this.C=this.g=null,this.H="",this.m=0,this.j="",this.l=this.F=this.v=this.D=!1,this.B=0,this.A=null,this.J=Pr,this.K=this.L=!1}xe(Lr,Ut);var Pr="",Mr=/^https?$/i,xr=["POST","PUT"];function Ur(e,t){e.h=!1,e.g&&(e.l=!0,e.g.abort(),e.l=!1),e.j=t,e.m=5,Fr(e),qr(e)}function Fr(e){e.D||(e.D=!0,Ft(e,"complete"),Ft(e,"error"))}function Vr(e){if(e.h&&void 0!==Se&&(!e.C[1]||4!=Br(e)||2!=e.aa()))if(e.v&&4==Br(e))Zt(e.Ha,0,e);else if(Ft(e,"readystatechange"),4==Br(e)){e.h=!1;try{var t,n=e.aa();e:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var r=!0;break e;default:r=!1}if(!(t=r)){var s;if(s=0===n){var i=String(e.H).match(Kn)[1]||null;if(!i&&Ce.self&&Ce.self.location){var o=Ce.self.location.protocol;i=o.substr(0,o.length-1)}s=!Mr.test(i?i.toLowerCase():"")}t=s}if(t)Ft(e,"complete"),Ft(e,"success");else{e.m=6;try{var a=2<Br(e)?e.g.statusText:""}catch(e){a=""}e.j=a+" ["+e.aa()+"]",Fr(e)}}finally{qr(e)}}}function qr(e,t){if(e.g){jr(e);var n=e.g,r=e.C[0]?ke:null;e.g=null,e.C=null,t||Ft(e,"ready");try{n.onreadystatechange=r}catch(e){}}}function jr(e){e.g&&e.K&&(e.g.ontimeout=null),e.A&&(Ce.clearTimeout(e.A),e.A=null)}function Br(e){return e.g?e.g.readyState:0}function zr(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.J){case Pr:case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}function $r(e){var t="";return vt(e,(function(e,n){t+=n,t+=":",t+=e,t+="\r\n"})),t}function Kr(e,t,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=$r(n),"string"==typeof e?null!=n&&encodeURIComponent(String(n)):Xn(e,t,n))}function Hr(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function Gr(e){this.Ca=0,this.i=[],this.j=new an,this.ka=this.sa=this.F=this.V=this.g=this.za=this.D=this.ia=this.o=this.S=this.s=null,this.ab=this.U=0,this.Za=Hr("failFast",!1,e),this.L=this.v=this.u=this.m=this.l=null,this.Y=!0,this.pa=this.Ba=this.T=-1,this.Z=this.A=this.C=0,this.Xa=Hr("baseRetryDelayMs",5e3,e),this.bb=Hr("retryDelaySeedMs",1e4,e),this.$a=Hr("forwardChannelMaxRetries",2,e),this.ta=Hr("forwardChannelRequestTimeoutMs",2e4,e),this.ra=e&&e.xmlHttpFactory||void 0,this.Da=e&&e.Zb||!1,this.J=void 0,this.H=e&&e.supportsCrossDomainXhr||!1,this.I="",this.h=new pr(e&&e.concurrentRequestLimit),this.Fa=new Er,this.O=e&&e.fastHandshake||!1,this.N=e&&e.encodeInitMessageHeaders||!1,this.O&&this.N&&(this.N=!1),this.Ya=e&&e.Xb||!1,e&&e.Aa&&this.j.Aa(),e&&e.forceLongPolling&&(this.Y=!1),this.$=!this.O&&this.Y&&e&&e.detectBufferingProxy||!1,this.ja=void 0,this.P=0,this.K=!1,this.la=this.B=null}function Wr(e){if(Yr(e),3==e.G){var t=e.U++,n=Gn(e.F);Xn(n,"SID",e.I),Xn(n,"RID",t),Xn(n,"TYPE","terminate"),Zr(e,n),(t=new An(e,e.j,t,void 0)).K=2,t.v=Jn(Gn(n)),n=!1,Ce.navigator&&Ce.navigator.sendBeacon&&(n=Ce.navigator.sendBeacon(t.v.toString(),"")),!n&&Ce.Image&&((new Image).src=t.v,n=!0),n||(t.g=ls(t.l,null),t.g.da(t.v)),t.F=Date.now(),Fn(t)}us(e)}function Qr(e){e.g&&(rs(e),e.g.cancel(),e.g=null)}function Yr(e){Qr(e),e.u&&(Ce.clearTimeout(e.u),e.u=null),is(e),e.h.cancel(),e.m&&("number"==typeof e.m&&Ce.clearTimeout(e.m),e.m=null)}function Xr(e){mr(e.h)||e.m||(e.m=!0,Gt(e.Ja,e),e.C=0)}function Jr(e,t){var n;n=t?t.m:e.U++;var r=Gn(e.F);Xn(r,"SID",e.I),Xn(r,"RID",n),Xn(r,"AID",e.T),Zr(e,r),e.o&&e.s&&Kr(r,e.o,e.s),n=new An(e,e.j,n,e.C+1),null===e.o&&(n.H=e.s),t&&(e.i=t.D.concat(e.i)),t=es(e,n,1e3),n.setTimeout(Math.round(.5*e.ta)+Math.round(.5*e.ta*Math.random())),wr(e.h,n),Ln(n,r,t)}function Zr(e,t){e.ia&&vt(e.ia,(function(e,n){Xn(t,n,e)})),e.l&&$n({},(function(e,n){Xn(t,n,e)}))}function es(e,t,n){n=Math.min(e.i.length,n);var r=e.l?Pe(e.l.Ra,e.l,e):null;e:for(var s=e.i,i=-1;;){var o=["count="+n];-1==i?0<n?(i=s[0].h,o.push("ofs="+i)):i=0:o.push("ofs="+i);for(var a=!0,c=0;c<n;c++){var u=s[c].h,h=s[c].g;if(0>(u-=i))i=Math.max(0,s[c].h-100),a=!1;else try{_r(h,o,"req"+u+"_")}catch(e){r&&r(h)}}if(a){r=o.join("&");break e}}return e=e.i.splice(0,n),t.D=e,r}function ts(e){e.g||e.u||(e.Z=1,Gt(e.Ia,e),e.A=0)}function ns(e){return!(e.g||e.u||3<=e.A)&&(e.Z++,e.u=yn(Pe(e.Ia,e),as(e,e.A)),e.A++,!0)}function rs(e){null!=e.B&&(Ce.clearTimeout(e.B),e.B=null)}function ss(e){e.g=new An(e,e.j,"rpc",e.Z),null===e.o&&(e.g.H=e.s),e.g.N=0;var t=Gn(e.sa);Xn(t,"RID","rpc"),Xn(t,"SID",e.I),Xn(t,"CI",e.L?"0":"1"),Xn(t,"AID",e.T),Xn(t,"TYPE","xmlhttp"),Zr(e,t),e.o&&e.s&&Kr(t,e.o,e.s),e.J&&e.g.setTimeout(e.J);var n=e.g;e=e.ka,n.K=1,n.v=Jn(Gn(t)),n.s=null,n.P=!0,Pn(n,e)}function is(e){null!=e.v&&(Ce.clearTimeout(e.v),e.v=null)}function os(e,t){var n=null;if(e.g==t){is(e),rs(e),e.g=null;var r=2}else{if(!vr(e.h,t))return;n=t.D,Ir(e.h,t),r=1}if(0!=e.G)if(e.pa=t.Y,t.i)if(1==r){n=t.s?t.s.length:0,t=Date.now()-t.F;var s=e.C;Ft(r=ln(),new mn(r,n)),Xr(e)}else ts(e);else if(3==(s=t.o)||0==s&&0<e.pa||!(1==r&&function(e,t){return!(yr(e.h)>=e.h.j-(e.m?1:0)||(e.m?(e.i=t.D.concat(e.i),0):1==e.G||2==e.G||e.C>=(e.Za?0:e.$a)||(e.m=yn(Pe(e.Ja,e,t),as(e,e.C)),e.C++,0)))}(e,t)||2==r&&ns(e)))switch(n&&0<n.length&&(t=e.h,t.i=t.i.concat(n)),s){case 1:cs(e,5);break;case 4:cs(e,10);break;case 3:cs(e,6);break;default:cs(e,2)}}function as(e,t){var n=e.Xa+Math.floor(Math.random()*e.bb);return e.l||(n*=2),n*t}function cs(e,t){if(e.j.info("Error code "+t),2==t){var n=null;e.l&&(n=null);var r=Pe(e.kb,e);n||(n=new Hn("//www.google.com/images/cleardot.gif"),Ce.location&&"http"==Ce.location.protocol||Wn(n,"https"),Jn(n)),function(e,t){var n=new an;if(Ce.Image){var r=new Image;r.onload=Me(Sr,n,r,"TestLoadImage: loaded",!0,t),r.onerror=Me(Sr,n,r,"TestLoadImage: error",!1,t),r.onabort=Me(Sr,n,r,"TestLoadImage: abort",!1,t),r.ontimeout=Me(Sr,n,r,"TestLoadImage: timeout",!1,t),Ce.setTimeout((function(){r.ontimeout&&r.ontimeout()}),1e4),r.src=e}else t(!1)}(n.toString(),r)}else gn(2);e.G=0,e.l&&e.l.va(t),us(e),Yr(e)}function us(e){if(e.G=0,e.la=[],e.l){var t=br(e.h);0==t.length&&0==e.i.length||(qe(e.la,t),qe(e.la,e.i),e.h.i.length=0,Ve(e.i),e.i.length=0),e.l.ua()}}function hs(e,t,n){var r=n instanceof Hn?Gn(n):new Hn(n,void 0);if(""!=r.g)t&&(r.g=t+"."+r.g),Qn(r,r.m);else{var s=Ce.location;r=s.protocol,t=t?t+"."+s.hostname:s.hostname,s=+s.port;var i=new Hn(null,void 0);r&&Wn(i,r),t&&(i.g=t),s&&Qn(i,s),n&&(i.l=n),r=i}return n=e.D,t=e.za,n&&t&&Xn(r,n,t),Xn(r,"VER",e.ma),Zr(e,r),r}function ls(e,t,n){if(t&&!e.H)throw Error("Can't create secondary domain capable XhrIo object.");return(t=n&&e.Da&&!e.ra?new Lr(new Cr({jb:!0})):new Lr(e.ra)).Ka(e.H),t}function ds(){}function fs(){if(Je&&!(10<=Number(lt)))throw Error("Environmental error: no available transport.")}function ps(e,t){Ut.call(this),this.g=new Gr(t),this.l=e,this.h=t&&t.messageUrlParams||null,e=t&&t.messageHeaders||null,t&&t.clientProtocolHeaderRequired&&(e?e["X-Client-Protocol"]="webchannel":e={"X-Client-Protocol":"webchannel"}),this.g.s=e,e=t&&t.initMessageHeaders||null,t&&t.messageContentType&&(e?e["X-WebChannel-Content-Type"]=t.messageContentType:e={"X-WebChannel-Content-Type":t.messageContentType}),t&&t.ya&&(e?e["X-WebChannel-Client-Profile"]=t.ya:e={"X-WebChannel-Client-Profile":t.ya}),this.g.S=e,(e=t&&t.Yb)&&!ze(e)&&(this.g.o=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!ze(t)&&(this.g.D=t,null!==(e=this.h)&&t in e&&(t in(e=this.h)&&delete e[t])),this.j=new ys(this)}function gs(e){Sn.call(this);var t=e.__sm__;if(t){e:{for(var n in t){e=n;break e}e=void 0}(this.i=e)&&(e=this.i,t=null!==t&&e in t?t[e]:void 0),this.data=t}else this.data=e}function ms(){Cn.call(this),this.status=1}function ys(e){this.g=e}(Ee=Lr.prototype).Ka=function(e){this.L=e},Ee.da=function(e,t,n,r){var s,i,o,a;if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.H+"; newUri="+e);t=t?t.toUpperCase():"GET",this.H=e,this.j="",this.m=0,this.D=!1,this.h=!0,this.g=this.u?this.u.g():En.g(),this.C=this.u?bn(this.u):bn(En),this.g.onreadystatechange=Pe(this.Ha,this);try{this.F=!0,this.g.open(t,String(e),!0),this.F=!1}catch(l){return void Ur(this,l)}if(e=n||"",n=new Map(this.headers),r)if(Object.getPrototypeOf(r)===Object.prototype)for(var c in r)n.set(c,r[c]);else{if("function"!=typeof r.keys||"function"!=typeof r.get)throw Error("Unknown input type for opt_headers: "+String(r));try{for(var u=be(r.keys()),h=u.next();!h.done;h=u.next()){var l=h.value;n.set(l,r.get(l))}}catch(e){s={error:e}}finally{try{h&&!h.done&&(i=u.return)&&i.call(u)}finally{if(s)throw s.error}}}r=Array.from(n.keys()).find((function(e){return"content-type"==e.toLowerCase()})),c=Ce.FormData&&e instanceof Ce.FormData,!(0<=Fe(xr,t))||r||c||n.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");try{for(var d=be(n),f=d.next();!f.done;f=d.next()){var p=Te(f.value,2),g=(l=p[0],p[1]);this.g.setRequestHeader(l,g)}}catch(e){o={error:e}}finally{try{f&&!f.done&&(a=d.return)&&a.call(d)}finally{if(o)throw o.error}}this.J&&(this.g.responseType=this.J),"withCredentials"in this.g&&this.g.withCredentials!==this.L&&(this.g.withCredentials=this.L);try{jr(this),0<this.B&&((this.K=function(e){return Je&&ut()&&"number"==typeof e.timeout&&void 0!==e.ontimeout}(this.g))?(this.g.timeout=this.B,this.g.ontimeout=Pe(this.qa,this)):this.A=Zt(this.qa,this.B,this)),this.v=!0,this.g.send(e),this.v=!1}catch(l){Ur(this,l)}},Ee.qa=function(){void 0!==Se&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,Ft(this,"timeout"),this.abort(8))},Ee.abort=function(e){this.g&&this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=e||7,Ft(this,"complete"),Ft(this,"abort"),qr(this))},Ee.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),qr(this,!0)),Lr.X.M.call(this)},Ee.Ha=function(){this.s||(this.F||this.v||this.l?Vr(this):this.fb())},Ee.fb=function(){Vr(this)},Ee.aa=function(){try{return 2<Br(this)?this.g.status:-1}catch(e){return-1}},Ee.fa=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},Ee.Sa=function(e){if(this.g){var t=this.g.responseText;return e&&0==t.indexOf(e)&&(t=t.substring(e.length)),Or(t)}},Ee.Ea=function(){return this.m},Ee.Oa=function(){return"string"==typeof this.j?this.j:String(this.j)},(Ee=Gr.prototype).ma=8,Ee.G=1,Ee.Ja=function(e){if(this.m)if(this.m=null,1==this.G){if(!e){this.U=Math.floor(1e5*Math.random()),e=this.U++;var t=new An(this,this.j,e,void 0),n=this.s;if(this.S&&(n?bt(n=wt(n),this.S):n=this.S),null!==this.o||this.N||(t.H=n,n=null),this.O)e:{for(var r=0,s=0;s<this.i.length;s++){var i=this.i[s];if(void 0===(i="__data__"in i.g&&"string"==typeof(i=i.g.__data__)?i.length:void 0))break;if(4096<(r+=i)){r=s;break e}if(4096===r||s===this.i.length-1){r=s+1;break e}}r=1e3}else r=1e3;r=es(this,t,r),Xn(s=Gn(this.F),"RID",e),Xn(s,"CVER",22),this.D&&Xn(s,"X-HTTP-Session-Id",this.D),Zr(this,s),n&&(this.N?r="headers="+encodeURIComponent(String($r(n)))+"&"+r:this.o&&Kr(s,this.o,n)),wr(this.h,t),this.Ya&&Xn(s,"TYPE","init"),this.O?(Xn(s,"$req",r),Xn(s,"SID","null"),t.Z=!0,Ln(t,s,null)):Ln(t,s,r),this.G=2}}else 3==this.G&&(e?Jr(this,e):0==this.i.length||mr(this.h)||Jr(this))},Ee.Ia=function(){if(this.u=null,ss(this),this.$&&!(this.K||null==this.g||0>=this.P)){var e=2*this.P;this.j.info("BP detection timer enabled: "+e),this.B=yn(Pe(this.eb,this),e)}},Ee.eb=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,gn(10),Qr(this),ss(this))},Ee.cb=function(){null!=this.v&&(this.v=null,Qr(this),ns(this),gn(19))},Ee.kb=function(e){e?(this.j.info("Successfully pinged google.com"),gn(2)):(this.j.info("Failed to ping google.com"),gn(1))},(Ee=ds.prototype).xa=function(){},Ee.wa=function(){},Ee.va=function(){},Ee.ua=function(){},Ee.Ra=function(){},fs.prototype.g=function(e,t){return new ps(e,t)},xe(ps,Ut),ps.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.H=!0);var e=this.g,t=this.l,n=this.h||void 0;gn(0),e.V=t,e.ia=n||{},e.L=e.Y,e.F=hs(e,null,e.V),Xr(e)},ps.prototype.close=function(){Wr(this.g)},ps.prototype.u=function(e){var t=this.g;if("string"==typeof e){var n={};n.__data__=e,e=n}else this.v&&((n={}).__data__=qt(e),e=n);t.i.push(new fr(t.ab++,e)),3==t.G&&Xr(t)},ps.prototype.M=function(){this.g.l=null,delete this.j,Wr(this.g),delete this.g,ps.X.M.call(this)},xe(gs,Sn),xe(ms,Cn),xe(ys,ds),ys.prototype.xa=function(){Ft(this.g,"a")},ys.prototype.wa=function(e){Ft(this.g,new gs(e))},ys.prototype.va=function(e){Ft(this.g,new ms)},ys.prototype.ua=function(){Ft(this.g,"b")},fs.prototype.createWebChannel=fs.prototype.g,ps.prototype.send=ps.prototype.u,ps.prototype.open=ps.prototype.m,ps.prototype.close=ps.prototype.close,vn.NO_ERROR=0,vn.TIMEOUT=8,vn.HTTP_ERROR=6,wn.COMPLETE="complete",Tn.EventType=_n,_n.OPEN="a",_n.CLOSE="b",_n.ERROR="c",_n.MESSAGE="d",Ut.prototype.listen=Ut.prototype.N,Lr.prototype.listenOnce=Lr.prototype.O,Lr.prototype.getLastError=Lr.prototype.Oa,Lr.prototype.getLastErrorCode=Lr.prototype.Ea,Lr.prototype.getStatus=Lr.prototype.aa,Lr.prototype.getResponseJson=Lr.prototype.Sa,Lr.prototype.getResponseText=Lr.prototype.fa,Lr.prototype.send=Lr.prototype.da,Lr.prototype.setWithCredentials=Lr.prototype.Ka;var vs=vn,ws=wn,Is=un,bs=10,Ts=11,Es=Cr,_s=Tn,Ss=Lr;const Cs="@firebase/firestore";
314
+ */var we;we="",ne(new b("platform-logger",(e=>new G(e)),"PRIVATE")),ne(new b("heartbeat",(e=>new ge(e)),"PRIVATE")),ue(W,Q,we),ue(W,Q,"esm2017"),ue("fire-js","");var Ie=function(e,t){return Ie=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Ie(e,t)};function be(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Te(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,s,i=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)o.push(r.value)}catch(e){s={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(s)throw s.error}}return o}var Ee,_e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Se=Se||{},Ce=_e||self;function Ae(){}function ke(e){var t=typeof e;return"array"==(t="object"!=t?t:e?Array.isArray(e)?"array":t:"null")||"object"==t&&"number"==typeof e.length}function Ne(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}var De="closure_uid_"+(1e9*Math.random()>>>0),Re=0;function Oe(e,t,n){return e.call.apply(e.bind,arguments)}function Le(e,t,n){if(!e)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,r),e.apply(t,n)}}return function(){return e.apply(t,arguments)}}function Pe(e,t,n){return(Pe=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?Oe:Le).apply(null,arguments)}function Me(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}function xe(e,t){function n(){}n.prototype=t.prototype,e.X=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.Wb=function(e,n,r){for(var s=Array(arguments.length-2),i=2;i<arguments.length;i++)s[i-2]=arguments[i];return t.prototype[n].apply(e,s)}}function Ue(){this.s=this.s,this.o=this.o}Ue.prototype.s=!1,Ue.prototype.na=function(){var e;!this.s&&(this.s=!0,this.M(),0)&&(e=this,Object.prototype.hasOwnProperty.call(e,De)&&e[De]||(e[De]=++Re))},Ue.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};var Fe=Array.prototype.indexOf?function(e,t){return Array.prototype.indexOf.call(e,t,void 0)}:function(e,t){if("string"==typeof e)return"string"!=typeof t||1!=t.length?-1:e.indexOf(t,0);for(var n=0;n<e.length;n++)if(n in e&&e[n]===t)return n;return-1};function Ve(e){var t=e.length;if(0<t){for(var n=Array(t),r=0;r<t;r++)n[r]=e[r];return n}return[]}function qe(e,t){for(var n=1;n<arguments.length;n++){var r=arguments[n];if(ke(r)){var s=e.length||0,i=r.length||0;e.length=s+i;for(var o=0;o<i;o++)e[s+o]=r[o]}else e.push(r)}}function je(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}je.prototype.h=function(){this.defaultPrevented=!0};var Be=function(){if(!Ce.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{Ce.addEventListener("test",Ae,t),Ce.removeEventListener("test",Ae,t)}catch(e){}return e}();function ze(e){return/^[\s\xa0]*$/.test(e)}var $e=String.prototype.trim?function(e){return e.trim()}:function(e){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(e)[1]};function Ke(e,t){return e<t?-1:e>t?1:0}function He(){var e=Ce.navigator;return e&&(e=e.userAgent)?e:""}function Ge(e){return-1!=He().indexOf(e)}function We(e){return We[" "](e),e}We[" "]=Ae;var Qe,Ye,Xe=Ge("Opera"),Je=Ge("Trident")||Ge("MSIE"),Ze=Ge("Edge"),et=Ze||Je,tt=Ge("Gecko")&&!(-1!=He().toLowerCase().indexOf("webkit")&&!Ge("Edge"))&&!(Ge("Trident")||Ge("MSIE"))&&!Ge("Edge"),nt=-1!=He().toLowerCase().indexOf("webkit")&&!Ge("Edge");function rt(){var e=Ce.document;return e?e.documentMode:void 0}e:{var st="",it=(Ye=He(),tt?/rv:([^\);]+)(\)|;)/.exec(Ye):Ze?/Edge\/([\d\.]+)/.exec(Ye):Je?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(Ye):nt?/WebKit\/(\S+)/.exec(Ye):Xe?/(?:Version)[ \/]?(\S+)/.exec(Ye):void 0);if(it&&(st=it?it[1]:""),Je){var ot=rt();if(null!=ot&&ot>parseFloat(st)){Qe=String(ot);break e}}Qe=st}var at,ct={};function ut(){return function(e){var t=ct;return Object.prototype.hasOwnProperty.call(t,9)?t[9]:t[9]=e(9)}((function(){for(var e=0,t=$e(String(Qe)).split("."),n=$e("9").split("."),r=Math.max(t.length,n.length),s=0;0==e&&s<r;s++){var i=t[s]||"",o=n[s]||"";do{if(i=/(\d*)(\D*)(.*)/.exec(i)||["","","",""],o=/(\d*)(\D*)(.*)/.exec(o)||["","","",""],0==i[0].length&&0==o[0].length)break;e=Ke(0==i[1].length?0:parseInt(i[1],10),0==o[1].length?0:parseInt(o[1],10))||Ke(0==i[2].length,0==o[2].length)||Ke(i[2],o[2]),i=i[3],o=o[3]}while(0==e)}return 0<=e}))}if(Ce.document&&Je){var ht=rt();at=ht||(parseInt(Qe,10)||void 0)}else at=void 0;var lt=at;function dt(e,t){if(je.call(this,e?e.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,e){var n=this.type=e.type,r=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;if(this.target=e.target||e.srcElement,this.g=t,t=e.relatedTarget){if(tt){e:{try{We(t.nodeName);var s=!0;break e}catch(e){}s=!1}s||(t=null)}}else"mouseover"==n?t=e.fromElement:"mouseout"==n&&(t=e.toElement);this.relatedTarget=t,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==e.clientX?e.clientX:e.pageX,this.clientY=void 0!==e.clientY?e.clientY:e.pageY,this.screenX=e.screenX||0,this.screenY=e.screenY||0),this.button=e.button,this.key=e.key||"",this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.pointerId=e.pointerId||0,this.pointerType="string"==typeof e.pointerType?e.pointerType:ft[e.pointerType]||"",this.state=e.state,this.i=e,e.defaultPrevented&&dt.X.h.call(this)}}xe(dt,je);var ft={2:"touch",3:"pen",4:"mouse"};dt.prototype.h=function(){dt.X.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var pt="closure_listenable_"+(1e6*Math.random()|0),gt=0;function mt(e,t,n,r,s){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ha=s,this.key=++gt,this.ba=this.ea=!1}function yt(e){e.ba=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function vt(e,t,n){for(var r in e)t.call(n,e[r],r,e)}function wt(e){var t={};for(var n in e)t[n]=e[n];return t}var It="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function bt(e,t){for(var n,r,s=1;s<arguments.length;s++){for(n in r=arguments[s])e[n]=r[n];for(var i=0;i<It.length;i++)n=It[i],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}function Tt(e){this.src=e,this.g={},this.h=0}function Et(e,t){var n=t.type;if(n in e.g){var r,s=e.g[n],i=Fe(s,t);(r=0<=i)&&Array.prototype.splice.call(s,i,1),r&&(yt(t),0==e.g[n].length&&(delete e.g[n],e.h--))}}function _t(e,t,n,r){for(var s=0;s<e.length;++s){var i=e[s];if(!i.ba&&i.listener==t&&i.capture==!!n&&i.ha==r)return s}return-1}Tt.prototype.add=function(e,t,n,r,s){var i=e.toString();(e=this.g[i])||(e=this.g[i]=[],this.h++);var o=_t(e,t,r,s);return-1<o?(t=e[o],n||(t.ea=!1)):((t=new mt(t,this.src,i,!!r,s)).ea=n,e.push(t)),t};var St="closure_lm_"+(1e6*Math.random()|0),Ct={};function At(e,t,n,r,s){if(r&&r.once)return Nt(e,t,n,r,s);if(Array.isArray(t)){for(var i=0;i<t.length;i++)At(e,t[i],n,r,s);return null}return n=xt(n),e&&e[pt]?e.N(t,n,Ne(r)?!!r.capture:!!r,s):kt(e,t,n,!1,r,s)}function kt(e,t,n,r,s,i){if(!t)throw Error("Invalid event type");var o=Ne(s)?!!s.capture:!!s,a=Pt(e);if(a||(e[St]=a=new Tt(e)),(n=a.add(t,n,r,o,i)).proxy)return n;if(r=function(){function e(n){return t.call(e.src,e.listener,n)}var t=Lt;return e}(),n.proxy=r,r.src=e,r.listener=n,e.addEventListener)Be||(s=o),void 0===s&&(s=!1),e.addEventListener(t.toString(),r,s);else if(e.attachEvent)e.attachEvent(Ot(t.toString()),r);else{if(!e.addListener||!e.removeListener)throw Error("addEventListener and attachEvent are unavailable.");e.addListener(r)}return n}function Nt(e,t,n,r,s){if(Array.isArray(t)){for(var i=0;i<t.length;i++)Nt(e,t[i],n,r,s);return null}return n=xt(n),e&&e[pt]?e.O(t,n,Ne(r)?!!r.capture:!!r,s):kt(e,t,n,!0,r,s)}function Dt(e,t,n,r,s){if(Array.isArray(t))for(var i=0;i<t.length;i++)Dt(e,t[i],n,r,s);else r=Ne(r)?!!r.capture:!!r,n=xt(n),e&&e[pt]?(e=e.i,(t=String(t).toString())in e.g&&(-1<(n=_t(i=e.g[t],n,r,s))&&(yt(i[n]),Array.prototype.splice.call(i,n,1),0==i.length&&(delete e.g[t],e.h--)))):e&&(e=Pt(e))&&(t=e.g[t.toString()],e=-1,t&&(e=_t(t,n,r,s)),(n=-1<e?t[e]:null)&&Rt(n))}function Rt(e){if("number"!=typeof e&&e&&!e.ba){var t=e.src;if(t&&t[pt])Et(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(Ot(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=Pt(t))?(Et(n,e),0==n.h&&(n.src=null,t[St]=null)):yt(e)}}}function Ot(e){return e in Ct?Ct[e]:Ct[e]="on"+e}function Lt(e,t){if(e.ba)e=!0;else{t=new dt(t,this);var n=e.listener,r=e.ha||e.src;e.ea&&Rt(e),e=n.call(r,t)}return e}function Pt(e){return(e=e[St])instanceof Tt?e:null}var Mt="__closure_events_fn_"+(1e9*Math.random()>>>0);function xt(e){return"function"==typeof e?e:(e[Mt]||(e[Mt]=function(t){return e.handleEvent(t)}),e[Mt])}function Ut(){Ue.call(this),this.i=new Tt(this),this.P=this,this.I=null}function Ft(e,t){var n,r=e.I;if(r)for(n=[];r;r=r.I)n.push(r);if(e=e.P,r=t.type||t,"string"==typeof t)t=new je(t,e);else if(t instanceof je)t.target=t.target||e;else{var s=t;bt(t=new je(r,e),s)}if(s=!0,n)for(var i=n.length-1;0<=i;i--){var o=t.g=n[i];s=Vt(o,r,!0,t)&&s}if(s=Vt(o=t.g=e,r,!0,t)&&s,s=Vt(o,r,!1,t)&&s,n)for(i=0;i<n.length;i++)s=Vt(o=t.g=n[i],r,!1,t)&&s}function Vt(e,t,n,r){if(!(t=e.i.g[String(t)]))return!0;t=t.concat();for(var s=!0,i=0;i<t.length;++i){var o=t[i];if(o&&!o.ba&&o.capture==n){var a=o.listener,c=o.ha||o.src;o.ea&&Et(e.i,o),s=!1!==a.call(c,r)&&s}}return s&&!r.defaultPrevented}xe(Ut,Ue),Ut.prototype[pt]=!0,Ut.prototype.removeEventListener=function(e,t,n,r){Dt(this,e,t,n,r)},Ut.prototype.M=function(){if(Ut.X.M.call(this),this.i){var e,t=this.i;for(e in t.g){for(var n=t.g[e],r=0;r<n.length;r++)yt(n[r]);delete t.g[e],t.h--}}this.I=null},Ut.prototype.N=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},Ut.prototype.O=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};var qt=Ce.JSON.stringify;function jt(){var e=Qt,t=null;return e.g&&(t=e.g,e.g=e.g.next,e.g||(e.h=null),t.next=null),t}var Bt,zt=function(){function e(){this.h=this.g=null}return e.prototype.add=function(e,t){var n=$t.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n},e}(),$t=new(function(){function e(e,t){this.i=e,this.j=t,this.h=0,this.g=null}return e.prototype.get=function(){var e;return 0<this.h?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e},e}())((function(){return new Kt}),(function(e){return e.reset()})),Kt=function(){function e(){this.next=this.g=this.h=null}return e.prototype.set=function(e,t){this.h=e,this.g=t,this.next=null},e.prototype.reset=function(){this.next=this.g=this.h=null},e}();function Ht(e){Ce.setTimeout((function(){throw e}),0)}function Gt(e,t){Bt||function(){var e=Ce.Promise.resolve(void 0);Bt=function(){e.then(Yt)}}(),Wt||(Bt(),Wt=!0),Qt.add(e,t)}var Wt=!1,Qt=new zt;function Yt(){for(var e;e=jt();){try{e.h.call(e.g)}catch(e){Ht(e)}var t=$t;t.j(e),100>t.h&&(t.h++,e.next=t.g,t.g=e)}Wt=!1}function Xt(e,t){Ut.call(this),this.h=e||1,this.g=t||Ce,this.j=Pe(this.lb,this),this.l=Date.now()}function Jt(e){e.ca=!1,e.R&&(e.g.clearTimeout(e.R),e.R=null)}function Zt(e,t,n){if("function"==typeof e)n&&(e=Pe(e,n));else{if(!e||"function"!=typeof e.handleEvent)throw Error("Invalid listener argument");e=Pe(e.handleEvent,e)}return 2147483647<Number(t)?-1:Ce.setTimeout(e,t||0)}function en(e){e.g=Zt((function(){e.g=null,e.i&&(e.i=!1,en(e))}),e.j);var t=e.h;e.h=null,e.m.apply(null,t)}xe(Xt,Ut),(Ee=Xt.prototype).ca=!1,Ee.R=null,Ee.lb=function(){if(this.ca){var e=Date.now()-this.l;0<e&&e<.8*this.h?this.R=this.g.setTimeout(this.j,this.h-e):(this.R&&(this.g.clearTimeout(this.R),this.R=null),Ft(this,"tick"),this.ca&&(Jt(this),this.start()))}},Ee.start=function(){this.ca=!0,this.R||(this.R=this.g.setTimeout(this.j,this.h),this.l=Date.now())},Ee.M=function(){Xt.X.M.call(this),Jt(this),delete this.g};var tn=function(e){function t(t,n){var r=e.call(this)||this;return r.m=t,r.j=n,r.h=null,r.i=!1,r.g=null,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}Ie(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t.prototype.l=function(e){this.h=arguments,this.g?this.i=!0:en(this)},t.prototype.M=function(){e.prototype.M.call(this),this.g&&(Ce.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)},t}(Ue);function nn(e){Ue.call(this),this.h=e,this.g={}}xe(nn,Ue);var rn=[];function sn(e,t,n,r){Array.isArray(n)||(n&&(rn[0]=n.toString()),n=rn);for(var s=0;s<n.length;s++){var i=At(t,n[s],r||e.handleEvent,!1,e.h||e);if(!i)break;e.g[i.key]=i}}function on(e){vt(e.g,(function(e,t){this.g.hasOwnProperty(t)&&Rt(e)}),e),e.g={}}function an(){this.g=!0}function cn(e,t,n,r){e.info((function(){return"XMLHTTP TEXT ("+t+"): "+function(e,t){if(!e.g)return t;if(!t)return null;try{var n=JSON.parse(t);if(n)for(e=0;e<n.length;e++)if(Array.isArray(n[e])){var r=n[e];if(!(2>r.length)){var s=r[1];if(Array.isArray(s)&&!(1>s.length)){var i=s[0];if("noop"!=i&&"stop"!=i&&"close"!=i)for(var o=1;o<s.length;o++)s[o]=""}}}return qt(n)}catch(e){return t}}(e,n)+(r?" "+r:"")}))}nn.prototype.M=function(){nn.X.M.call(this),on(this)},nn.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},an.prototype.Aa=function(){this.g=!1},an.prototype.info=function(){};var un={},hn=null;function ln(){return hn=hn||new Ut}function dn(e){je.call(this,un.Pa,e)}function fn(e){var t=ln();Ft(t,new dn(t))}function pn(e,t){je.call(this,un.STAT_EVENT,e),this.stat=t}function gn(e){var t=ln();Ft(t,new pn(t,e))}function mn(e,t){je.call(this,un.Qa,e),this.size=t}function yn(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return Ce.setTimeout((function(){e()}),t)}un.Pa="serverreachability",xe(dn,je),un.STAT_EVENT="statevent",xe(pn,je),un.Qa="timingevent",xe(mn,je);var vn={NO_ERROR:0,mb:1,zb:2,yb:3,tb:4,xb:5,Ab:6,Ma:7,TIMEOUT:8,Db:9},wn={rb:"complete",Nb:"success",Na:"error",Ma:"abort",Fb:"ready",Gb:"readystatechange",TIMEOUT:"timeout",Bb:"incrementaldata",Eb:"progress",ub:"downloadprogress",Vb:"uploadprogress"};function In(){}function bn(e){return e.h||(e.h=e.i())}function Tn(){}In.prototype.h=null;var En,_n={OPEN:"a",qb:"b",Na:"c",Cb:"d"};function Sn(){je.call(this,"d")}function Cn(){je.call(this,"c")}function An(){}function kn(e,t,n,r){this.l=e,this.j=t,this.m=n,this.U=r||1,this.S=new nn(this),this.O=Dn,e=et?125:void 0,this.T=new Xt(e),this.H=null,this.i=!1,this.s=this.A=this.v=this.K=this.F=this.V=this.B=null,this.D=[],this.g=null,this.C=0,this.o=this.u=null,this.Y=-1,this.I=!1,this.N=0,this.L=null,this.$=this.J=this.Z=this.P=!1,this.h=new Nn}function Nn(){this.i=null,this.g="",this.h=!1}xe(Sn,je),xe(Cn,je),xe(An,In),An.prototype.g=function(){return new XMLHttpRequest},An.prototype.i=function(){return{}},En=new An;var Dn=45e3,Rn={},On={};function Ln(e,t,n){e.K=1,e.v=Jn(Gn(t)),e.s=n,e.P=!0,Pn(e,null)}function Pn(e,t){e.F=Date.now(),Fn(e),e.A=Gn(e.v);var n=e.A,r=e.U;Array.isArray(r)||(r=[String(r)]),lr(n.i,"t",r),e.C=0,n=e.l.H,e.h=new Nn,e.g=ls(e.l,n?t:null,!e.s),0<e.N&&(e.L=new tn(Pe(e.La,e,e.g),e.N)),sn(e.S,e.g,"readystatechange",e.ib),t=e.H?wt(e.H):{},e.s?(e.u||(e.u="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.da(e.A,e.u,e.s,t)):(e.u="GET",e.g.da(e.A,e.u,null,t)),fn(),function(e,t,n,r,s,i){e.info((function(){if(e.g)if(i)for(var o="",a=i.split("&"),c=0;c<a.length;c++){var u=a[c].split("=");if(1<u.length){var h=u[0];u=u[1];var l=h.split("_");o=2<=l.length&&"type"==l[1]?o+(h+"=")+u+"&":o+(h+"=redacted&")}}else o=null;else o=i;return"XMLHTTP REQ ("+r+") [attempt "+s+"]: "+t+"\n"+n+"\n"+o}))}(e.j,e.u,e.A,e.m,e.U,e.s)}function Mn(e){return!!e.g&&("GET"==e.u&&2!=e.K&&e.l.Da)}function xn(e,t,n){for(var r,s=!0;!e.I&&e.C<n.length;){if((r=Un(e,n))==On){4==t&&(e.o=4,gn(14),s=!1),cn(e.j,e.m,null,"[Incomplete Response]");break}if(r==Rn){e.o=4,gn(15),cn(e.j,e.m,n,"[Invalid Chunk]"),s=!1;break}cn(e.j,e.m,r,null),zn(e,r)}Mn(e)&&r!=On&&r!=Rn&&(e.h.g="",e.C=0),4!=t||0!=n.length||e.h.h||(e.o=1,gn(16),s=!1),e.i=e.i&&s,s?0<n.length&&!e.$&&(e.$=!0,(t=e.l).g==e&&t.$&&!t.K&&(t.j.info("Great, no buffering proxy detected. Bytes received: "+n.length),rs(t),t.K=!0,gn(11))):(cn(e.j,e.m,n,"[Invalid Chunked Response]"),Bn(e),jn(e))}function Un(e,t){var n=e.C,r=t.indexOf("\n",n);return-1==r?On:(n=Number(t.substring(n,r)),isNaN(n)?Rn:(r+=1)+n>t.length?On:(t=t.substr(r,n),e.C=r+n,t))}function Fn(e){e.V=Date.now()+e.O,Vn(e,e.O)}function Vn(e,t){if(null!=e.B)throw Error("WatchDog timer not null");e.B=yn(Pe(e.gb,e),t)}function qn(e){e.B&&(Ce.clearTimeout(e.B),e.B=null)}function jn(e){0==e.l.G||e.I||os(e.l,e)}function Bn(e){qn(e);var t=e.L;t&&"function"==typeof t.na&&t.na(),e.L=null,Jt(e.T),on(e.S),e.g&&(t=e.g,e.g=null,t.abort(),t.na())}function zn(e,t){try{var n=e.l;if(0!=n.G&&(n.g==e||vr(n.h,e)))if(!e.J&&vr(n.h,e)&&3==n.G){try{var r=n.Fa.g.parse(t)}catch(i){r=null}if(Array.isArray(r)&&3==r.length){var s=r;if(0==s[0]){e:if(!n.u){if(n.g){if(!(n.g.F+3e3<e.F))break e;is(n),Qr(n)}ns(n),gn(18)}}else n.Ba=s[1],0<n.Ba-n.T&&37500>s[2]&&n.L&&0==n.A&&!n.v&&(n.v=yn(Pe(n.cb,n),6e3));if(1>=yr(n.h)&&n.ja){try{n.ja()}catch(i){}n.ja=void 0}}else cs(n,11)}else if((e.J||n.g==e)&&is(n),!ze(t))for(s=n.Fa.g.parse(t),t=0;t<s.length;t++){var i=s[t];if(n.T=i[0],i=i[1],2==n.G)if("c"==i[0]){n.I=i[1],n.ka=i[2];var o=i[3];null!=o&&(n.ma=o,n.j.info("VER="+n.ma));var a=i[4];null!=a&&(n.Ca=a,n.j.info("SVER="+n.Ca));var c=i[5];null!=c&&"number"==typeof c&&0<c&&(r=1.5*c,n.J=r,n.j.info("backChannelRequestTimeoutMs_="+r)),r=n;var u=e.g;if(u){var h=u.g?u.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(h){var l=r.h;l.g||-1==h.indexOf("spdy")&&-1==h.indexOf("quic")&&-1==h.indexOf("h2")||(l.j=l.l,l.g=new Set,l.h&&(wr(l,l.h),l.h=null))}if(r.D){var d=u.g?u.g.getResponseHeader("X-HTTP-Session-Id"):null;d&&(r.za=d,Xn(r.F,r.D,d))}}n.G=3,n.l&&n.l.xa(),n.$&&(n.P=Date.now()-e.F,n.j.info("Handshake RTT: "+n.P+"ms"));var f=e;if((r=n).sa=hs(r,r.H?r.ka:null,r.V),f.J){Ir(r.h,f);var p=f,g=r.J;g&&p.setTimeout(g),p.B&&(qn(p),Fn(p)),r.g=f}else ts(r);0<n.i.length&&Xr(n)}else"stop"!=i[0]&&"close"!=i[0]||cs(n,7);else 3==n.G&&("stop"==i[0]||"close"==i[0]?"stop"==i[0]?cs(n,7):Wr(n):"noop"!=i[0]&&n.l&&n.l.wa(i),n.A=0)}fn()}catch(i){}}function $n(e,t){if(e.forEach&&"function"==typeof e.forEach)e.forEach(t,void 0);else if(ke(e)||"string"==typeof e)Array.prototype.forEach.call(e,t,void 0);else for(var n=function(e){if(e.oa&&"function"==typeof e.oa)return e.oa();if(!e.W||"function"!=typeof e.W){if("undefined"!=typeof Map&&e instanceof Map)return Array.from(e.keys());if(!("undefined"!=typeof Set&&e instanceof Set)){if(ke(e)||"string"==typeof e){var t=[];e=e.length;for(var n=0;n<e;n++)t.push(n);return t}for(var r in t=[],n=0,e)t[n++]=r;return t}}}(e),r=function(e){if(e.W&&"function"==typeof e.W)return e.W();if("undefined"!=typeof Map&&e instanceof Map||"undefined"!=typeof Set&&e instanceof Set)return Array.from(e.values());if("string"==typeof e)return e.split("");if(ke(e)){for(var t=[],n=e.length,r=0;r<n;r++)t.push(e[r]);return t}for(r in t=[],n=0,e)t[n++]=e[r];return t}(e),s=r.length,i=0;i<s;i++)t.call(void 0,r[i],n&&n[i],e)}(Ee=kn.prototype).setTimeout=function(e){this.O=e},Ee.ib=function(e){e=e.target;var t=this.L;t&&3==Br(e)?t.l():this.La(e)},Ee.La=function(e){try{if(e==this.g)e:{var t=Br(this.g),n=this.g.Ea();this.g.aa();if(!(3>t)&&(3!=t||et||this.g&&(this.h.h||this.g.fa()||zr(this.g)))){this.I||4!=t||7==n||fn(),qn(this);var r=this.g.aa();this.Y=r;t:if(Mn(this)){var s=zr(this.g);e="";var i=s.length,o=4==Br(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){Bn(this),jn(this);var a="";break t}this.h.i=new Ce.TextDecoder}for(n=0;n<i;n++)this.h.h=!0,e+=this.h.i.decode(s[n],{stream:o&&n==i-1});s.splice(0,i),this.h.g+=e,this.C=0,a=this.h.g}else a=this.g.fa();if(this.i=200==r,function(e,t,n,r,s,i,o){e.info((function(){return"XMLHTTP RESP ("+r+") [ attempt "+s+"]: "+t+"\n"+n+"\n"+i+" "+o}))}(this.j,this.u,this.A,this.m,this.U,t,r),this.i){if(this.Z&&!this.J){t:{if(this.g){var c,u=this.g;if((c=u.g?u.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!ze(c)){var h=c;break t}}h=null}if(!(r=h)){this.i=!1,this.o=3,gn(12),Bn(this),jn(this);break e}cn(this.j,this.m,r,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,zn(this,r)}this.P?(xn(this,t,a),et&&this.i&&3==t&&(sn(this.S,this.T,"tick",this.hb),this.T.start())):(cn(this.j,this.m,a,null),zn(this,a)),4==t&&Bn(this),this.i&&!this.I&&(4==t?os(this.l,this):(this.i=!1,Fn(this)))}else 400==r&&0<a.indexOf("Unknown SID")?(this.o=3,gn(12)):(this.o=0,gn(13)),Bn(this),jn(this)}}}catch(t){}},Ee.hb=function(){if(this.g){var e=Br(this.g),t=this.g.fa();this.C<t.length&&(qn(this),xn(this,e,t),this.i&&4!=e&&Fn(this))}},Ee.cancel=function(){this.I=!0,Bn(this)},Ee.gb=function(){this.B=null;var e=Date.now();0<=e-this.V?(function(e,t){e.info((function(){return"TIMEOUT: "+t}))}(this.j,this.A),2!=this.K&&(fn(),gn(17)),Bn(this),this.o=2,jn(this)):Vn(this,this.V-e)};var Kn=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Hn(e,t){if(this.g=this.s=this.j="",this.m=null,this.o=this.l="",this.h=!1,e instanceof Hn){this.h=void 0!==t?t:e.h,Wn(this,e.j),this.s=e.s,this.g=e.g,Qn(this,e.m),this.l=e.l,t=e.i;var n=new ar;n.i=t.i,t.g&&(n.g=new Map(t.g),n.h=t.h),Yn(this,n),this.o=e.o}else e&&(n=String(e).match(Kn))?(this.h=!!t,Wn(this,n[1]||"",!0),this.s=Zn(n[2]||""),this.g=Zn(n[3]||"",!0),Qn(this,n[4]),this.l=Zn(n[5]||"",!0),Yn(this,n[6]||"",!0),this.o=Zn(n[7]||"")):(this.h=!!t,this.i=new ar(null,this.h))}function Gn(e){return new Hn(e)}function Wn(e,t,n){e.j=n?Zn(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function Qn(e,t){if(t){if(t=Number(t),isNaN(t)||0>t)throw Error("Bad port number "+t);e.m=t}else e.m=null}function Yn(e,t,n){t instanceof ar?(e.i=t,function(e,t){t&&!e.j&&(cr(e),e.i=null,e.g.forEach((function(e,t){var n=t.toLowerCase();t!=n&&(ur(this,t),lr(this,n,e))}),e)),e.j=t}(e.i,e.h)):(n||(t=er(t,ir)),e.i=new ar(t,e.h))}function Xn(e,t,n){e.i.set(t,n)}function Jn(e){return Xn(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),e}function Zn(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function er(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,tr),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function tr(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}Hn.prototype.toString=function(){var e=[],t=this.j;t&&e.push(er(t,nr,!0),":");var n=this.g;return(n||"file"==t)&&(e.push("//"),(t=this.s)&&e.push(er(t,nr,!0),"@"),e.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.m)&&e.push(":",String(n))),(n=this.l)&&(this.g&&"/"!=n.charAt(0)&&e.push("/"),e.push(er(n,"/"==n.charAt(0)?sr:rr,!0))),(n=this.i.toString())&&e.push("?",n),(n=this.o)&&e.push("#",er(n,or)),e.join("")};var nr=/[#\/\?@]/g,rr=/[#\?:]/g,sr=/[#\?]/g,ir=/[#\?@]/g,or=/#/g;function ar(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function cr(e){e.g||(e.g=new Map,e.h=0,e.i&&function(e,t){if(e){e=e.split("&");for(var n=0;n<e.length;n++){var r=e[n].indexOf("="),s=null;if(0<=r){var i=e[n].substring(0,r);s=e[n].substring(r+1)}else i=e[n];t(i,s?decodeURIComponent(s.replace(/\+/g," ")):"")}}}(e.i,(function(t,n){e.add(decodeURIComponent(t.replace(/\+/g," ")),n)})))}function ur(e,t){cr(e),t=dr(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function hr(e,t){return cr(e),t=dr(e,t),e.g.has(t)}function lr(e,t,n){ur(e,t),0<n.length&&(e.i=null,e.g.set(dr(e,t),Ve(n)),e.h+=n.length)}function dr(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}(Ee=ar.prototype).add=function(e,t){cr(this),this.i=null,e=dr(this,e);var n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this},Ee.forEach=function(e,t){cr(this),this.g.forEach((function(n,r){n.forEach((function(n){e.call(t,n,r,this)}),this)}),this)},Ee.oa=function(){cr(this);for(var e=Array.from(this.g.values()),t=Array.from(this.g.keys()),n=[],r=0;r<t.length;r++)for(var s=e[r],i=0;i<s.length;i++)n.push(t[r]);return n},Ee.W=function(e){cr(this);var t=[];if("string"==typeof e)hr(this,e)&&(t=t.concat(this.g.get(dr(this,e))));else{e=Array.from(this.g.values());for(var n=0;n<e.length;n++)t=t.concat(e[n])}return t},Ee.set=function(e,t){return cr(this),this.i=null,hr(this,e=dr(this,e))&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},Ee.get=function(e,t){return e&&0<(e=this.W(e)).length?String(e[0]):t},Ee.toString=function(){if(this.i)return this.i;if(!this.g)return"";for(var e=[],t=Array.from(this.g.keys()),n=0;n<t.length;n++){var r=t[n],s=encodeURIComponent(String(r)),i=this.W(r);for(r=0;r<i.length;r++){var o=s;""!==i[r]&&(o+="="+encodeURIComponent(String(i[r]))),e.push(o)}}return this.i=e.join("&")};var fr=function(e,t){this.h=e,this.g=t};function pr(e){this.l=e||gr,Ce.PerformanceNavigationTiming?e=0<(e=Ce.performance.getEntriesByType("navigation")).length&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):e=!!(Ce.g&&Ce.g.Ga&&Ce.g.Ga()&&Ce.g.Ga().$b),this.j=e?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}var gr=10;function mr(e){return!!e.h||!!e.g&&e.g.size>=e.j}function yr(e){return e.h?1:e.g?e.g.size:0}function vr(e,t){return e.h?e.h==t:!!e.g&&e.g.has(t)}function wr(e,t){e.g?e.g.add(t):e.h=t}function Ir(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function br(e){var t,n;if(null!=e.h)return e.i.concat(e.h.D);if(null!=e.g&&0!==e.g.size){var r=e.i;try{for(var s=be(e.g.values()),i=s.next();!i.done;i=s.next()){var o=i.value;r=r.concat(o.D)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return r}return Ve(e.i)}function Tr(){}function Er(){this.g=new Tr}function _r(e,t,n){var r=n||"";try{$n(e,(function(e,n){var s=e;Ne(e)&&(s=qt(e)),t.push(r+n+"="+encodeURIComponent(s))}))}catch(e){throw t.push(r+"type="+encodeURIComponent("_badmap")),e}}function Sr(e,t,n,r,s){try{t.onload=null,t.onerror=null,t.onabort=null,t.ontimeout=null,s(r)}catch(e){}}function Cr(e){this.l=e.ac||null,this.j=e.jb||!1}function Ar(e,t){Ut.call(this),this.D=e,this.u=t,this.m=void 0,this.readyState=kr,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}pr.prototype.cancel=function(){var e,t;if(this.i=br(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){try{for(var n=be(this.g.values()),r=n.next();!r.done;r=n.next()){r.value.cancel()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.g.clear()}},Tr.prototype.stringify=function(e){return Ce.JSON.stringify(e,void 0)},Tr.prototype.parse=function(e){return Ce.JSON.parse(e,void 0)},xe(Cr,In),Cr.prototype.g=function(){return new Ar(this.l,this.j)},Cr.prototype.i=function(e){return function(){return e}}({}),xe(Ar,Ut);var kr=0;function Nr(e){e.j.read().then(e.Ta.bind(e)).catch(e.ga.bind(e))}function Dr(e){e.readyState=4,e.l=null,e.j=null,e.A=null,Rr(e)}function Rr(e){e.onreadystatechange&&e.onreadystatechange.call(e)}(Ee=Ar.prototype).open=function(e,t){if(this.readyState!=kr)throw this.abort(),Error("Error reopening a connection");this.C=e,this.B=t,this.readyState=1,Rr(this)},Ee.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;var t={headers:this.v,method:this.C,credentials:this.m,cache:void 0};e&&(t.body=e),(this.D||Ce).fetch(new Request(this.B,t)).then(this.Wa.bind(this),this.ga.bind(this))},Ee.abort=function(){this.response=this.responseText="",this.v=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch((function(){})),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,Dr(this)),this.readyState=kr},Ee.Wa=function(e){if(this.g&&(this.l=e,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=e.headers,this.readyState=2,Rr(this)),this.g&&(this.readyState=3,Rr(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Ua.bind(this),this.ga.bind(this));else if(void 0!==Ce.ReadableStream&&"body"in e){if(this.j=e.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;Nr(this)}else e.text().then(this.Va.bind(this),this.ga.bind(this))},Ee.Ta=function(e){if(this.g){if(this.u&&e.value)this.response.push(e.value);else if(!this.u){var t=e.value?e.value:new Uint8Array(0);(t=this.A.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?Dr(this):Rr(this),3==this.readyState&&Nr(this)}},Ee.Va=function(e){this.g&&(this.response=this.responseText=e,Dr(this))},Ee.Ua=function(e){this.g&&(this.response=e,Dr(this))},Ee.ga=function(){this.g&&Dr(this)},Ee.setRequestHeader=function(e,t){this.v.append(e,t)},Ee.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||""},Ee.getAllResponseHeaders=function(){if(!this.h)return"";for(var e=[],t=this.h.entries(),n=t.next();!n.done;)n=n.value,e.push(n[0]+": "+n[1]),n=t.next();return e.join("\r\n")},Object.defineProperty(Ar.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}});var Or=Ce.JSON.parse;function Lr(e){Ut.call(this),this.headers=new Map,this.u=e||null,this.h=!1,this.C=this.g=null,this.H="",this.m=0,this.j="",this.l=this.F=this.v=this.D=!1,this.B=0,this.A=null,this.J=Pr,this.K=this.L=!1}xe(Lr,Ut);var Pr="",Mr=/^https?$/i,xr=["POST","PUT"];function Ur(e,t){e.h=!1,e.g&&(e.l=!0,e.g.abort(),e.l=!1),e.j=t,e.m=5,Fr(e),qr(e)}function Fr(e){e.D||(e.D=!0,Ft(e,"complete"),Ft(e,"error"))}function Vr(e){if(e.h&&void 0!==Se&&(!e.C[1]||4!=Br(e)||2!=e.aa()))if(e.v&&4==Br(e))Zt(e.Ha,0,e);else if(Ft(e,"readystatechange"),4==Br(e)){e.h=!1;try{var t,n=e.aa();e:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var r=!0;break e;default:r=!1}if(!(t=r)){var s;if(s=0===n){var i=String(e.H).match(Kn)[1]||null;if(!i&&Ce.self&&Ce.self.location){var o=Ce.self.location.protocol;i=o.substr(0,o.length-1)}s=!Mr.test(i?i.toLowerCase():"")}t=s}if(t)Ft(e,"complete"),Ft(e,"success");else{e.m=6;try{var a=2<Br(e)?e.g.statusText:""}catch(e){a=""}e.j=a+" ["+e.aa()+"]",Fr(e)}}finally{qr(e)}}}function qr(e,t){if(e.g){jr(e);var n=e.g,r=e.C[0]?Ae:null;e.g=null,e.C=null,t||Ft(e,"ready");try{n.onreadystatechange=r}catch(e){}}}function jr(e){e.g&&e.K&&(e.g.ontimeout=null),e.A&&(Ce.clearTimeout(e.A),e.A=null)}function Br(e){return e.g?e.g.readyState:0}function zr(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.J){case Pr:case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}function $r(e){var t="";return vt(e,(function(e,n){t+=n,t+=":",t+=e,t+="\r\n"})),t}function Kr(e,t,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=$r(n),"string"==typeof e?null!=n&&encodeURIComponent(String(n)):Xn(e,t,n))}function Hr(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function Gr(e){this.Ca=0,this.i=[],this.j=new an,this.ka=this.sa=this.F=this.V=this.g=this.za=this.D=this.ia=this.o=this.S=this.s=null,this.ab=this.U=0,this.Za=Hr("failFast",!1,e),this.L=this.v=this.u=this.m=this.l=null,this.Y=!0,this.pa=this.Ba=this.T=-1,this.Z=this.A=this.C=0,this.Xa=Hr("baseRetryDelayMs",5e3,e),this.bb=Hr("retryDelaySeedMs",1e4,e),this.$a=Hr("forwardChannelMaxRetries",2,e),this.ta=Hr("forwardChannelRequestTimeoutMs",2e4,e),this.ra=e&&e.xmlHttpFactory||void 0,this.Da=e&&e.Zb||!1,this.J=void 0,this.H=e&&e.supportsCrossDomainXhr||!1,this.I="",this.h=new pr(e&&e.concurrentRequestLimit),this.Fa=new Er,this.O=e&&e.fastHandshake||!1,this.N=e&&e.encodeInitMessageHeaders||!1,this.O&&this.N&&(this.N=!1),this.Ya=e&&e.Xb||!1,e&&e.Aa&&this.j.Aa(),e&&e.forceLongPolling&&(this.Y=!1),this.$=!this.O&&this.Y&&e&&e.detectBufferingProxy||!1,this.ja=void 0,this.P=0,this.K=!1,this.la=this.B=null}function Wr(e){if(Yr(e),3==e.G){var t=e.U++,n=Gn(e.F);Xn(n,"SID",e.I),Xn(n,"RID",t),Xn(n,"TYPE","terminate"),Zr(e,n),(t=new kn(e,e.j,t,void 0)).K=2,t.v=Jn(Gn(n)),n=!1,Ce.navigator&&Ce.navigator.sendBeacon&&(n=Ce.navigator.sendBeacon(t.v.toString(),"")),!n&&Ce.Image&&((new Image).src=t.v,n=!0),n||(t.g=ls(t.l,null),t.g.da(t.v)),t.F=Date.now(),Fn(t)}us(e)}function Qr(e){e.g&&(rs(e),e.g.cancel(),e.g=null)}function Yr(e){Qr(e),e.u&&(Ce.clearTimeout(e.u),e.u=null),is(e),e.h.cancel(),e.m&&("number"==typeof e.m&&Ce.clearTimeout(e.m),e.m=null)}function Xr(e){mr(e.h)||e.m||(e.m=!0,Gt(e.Ja,e),e.C=0)}function Jr(e,t){var n;n=t?t.m:e.U++;var r=Gn(e.F);Xn(r,"SID",e.I),Xn(r,"RID",n),Xn(r,"AID",e.T),Zr(e,r),e.o&&e.s&&Kr(r,e.o,e.s),n=new kn(e,e.j,n,e.C+1),null===e.o&&(n.H=e.s),t&&(e.i=t.D.concat(e.i)),t=es(e,n,1e3),n.setTimeout(Math.round(.5*e.ta)+Math.round(.5*e.ta*Math.random())),wr(e.h,n),Ln(n,r,t)}function Zr(e,t){e.ia&&vt(e.ia,(function(e,n){Xn(t,n,e)})),e.l&&$n({},(function(e,n){Xn(t,n,e)}))}function es(e,t,n){n=Math.min(e.i.length,n);var r=e.l?Pe(e.l.Ra,e.l,e):null;e:for(var s=e.i,i=-1;;){var o=["count="+n];-1==i?0<n?(i=s[0].h,o.push("ofs="+i)):i=0:o.push("ofs="+i);for(var a=!0,c=0;c<n;c++){var u=s[c].h,h=s[c].g;if(0>(u-=i))i=Math.max(0,s[c].h-100),a=!1;else try{_r(h,o,"req"+u+"_")}catch(e){r&&r(h)}}if(a){r=o.join("&");break e}}return e=e.i.splice(0,n),t.D=e,r}function ts(e){e.g||e.u||(e.Z=1,Gt(e.Ia,e),e.A=0)}function ns(e){return!(e.g||e.u||3<=e.A)&&(e.Z++,e.u=yn(Pe(e.Ia,e),as(e,e.A)),e.A++,!0)}function rs(e){null!=e.B&&(Ce.clearTimeout(e.B),e.B=null)}function ss(e){e.g=new kn(e,e.j,"rpc",e.Z),null===e.o&&(e.g.H=e.s),e.g.N=0;var t=Gn(e.sa);Xn(t,"RID","rpc"),Xn(t,"SID",e.I),Xn(t,"CI",e.L?"0":"1"),Xn(t,"AID",e.T),Xn(t,"TYPE","xmlhttp"),Zr(e,t),e.o&&e.s&&Kr(t,e.o,e.s),e.J&&e.g.setTimeout(e.J);var n=e.g;e=e.ka,n.K=1,n.v=Jn(Gn(t)),n.s=null,n.P=!0,Pn(n,e)}function is(e){null!=e.v&&(Ce.clearTimeout(e.v),e.v=null)}function os(e,t){var n=null;if(e.g==t){is(e),rs(e),e.g=null;var r=2}else{if(!vr(e.h,t))return;n=t.D,Ir(e.h,t),r=1}if(0!=e.G)if(e.pa=t.Y,t.i)if(1==r){n=t.s?t.s.length:0,t=Date.now()-t.F;var s=e.C;Ft(r=ln(),new mn(r,n)),Xr(e)}else ts(e);else if(3==(s=t.o)||0==s&&0<e.pa||!(1==r&&function(e,t){return!(yr(e.h)>=e.h.j-(e.m?1:0)||(e.m?(e.i=t.D.concat(e.i),0):1==e.G||2==e.G||e.C>=(e.Za?0:e.$a)||(e.m=yn(Pe(e.Ja,e,t),as(e,e.C)),e.C++,0)))}(e,t)||2==r&&ns(e)))switch(n&&0<n.length&&(t=e.h,t.i=t.i.concat(n)),s){case 1:cs(e,5);break;case 4:cs(e,10);break;case 3:cs(e,6);break;default:cs(e,2)}}function as(e,t){var n=e.Xa+Math.floor(Math.random()*e.bb);return e.l||(n*=2),n*t}function cs(e,t){if(e.j.info("Error code "+t),2==t){var n=null;e.l&&(n=null);var r=Pe(e.kb,e);n||(n=new Hn("//www.google.com/images/cleardot.gif"),Ce.location&&"http"==Ce.location.protocol||Wn(n,"https"),Jn(n)),function(e,t){var n=new an;if(Ce.Image){var r=new Image;r.onload=Me(Sr,n,r,"TestLoadImage: loaded",!0,t),r.onerror=Me(Sr,n,r,"TestLoadImage: error",!1,t),r.onabort=Me(Sr,n,r,"TestLoadImage: abort",!1,t),r.ontimeout=Me(Sr,n,r,"TestLoadImage: timeout",!1,t),Ce.setTimeout((function(){r.ontimeout&&r.ontimeout()}),1e4),r.src=e}else t(!1)}(n.toString(),r)}else gn(2);e.G=0,e.l&&e.l.va(t),us(e),Yr(e)}function us(e){if(e.G=0,e.la=[],e.l){var t=br(e.h);0==t.length&&0==e.i.length||(qe(e.la,t),qe(e.la,e.i),e.h.i.length=0,Ve(e.i),e.i.length=0),e.l.ua()}}function hs(e,t,n){var r=n instanceof Hn?Gn(n):new Hn(n,void 0);if(""!=r.g)t&&(r.g=t+"."+r.g),Qn(r,r.m);else{var s=Ce.location;r=s.protocol,t=t?t+"."+s.hostname:s.hostname,s=+s.port;var i=new Hn(null,void 0);r&&Wn(i,r),t&&(i.g=t),s&&Qn(i,s),n&&(i.l=n),r=i}return n=e.D,t=e.za,n&&t&&Xn(r,n,t),Xn(r,"VER",e.ma),Zr(e,r),r}function ls(e,t,n){if(t&&!e.H)throw Error("Can't create secondary domain capable XhrIo object.");return(t=n&&e.Da&&!e.ra?new Lr(new Cr({jb:!0})):new Lr(e.ra)).Ka(e.H),t}function ds(){}function fs(){if(Je&&!(10<=Number(lt)))throw Error("Environmental error: no available transport.")}function ps(e,t){Ut.call(this),this.g=new Gr(t),this.l=e,this.h=t&&t.messageUrlParams||null,e=t&&t.messageHeaders||null,t&&t.clientProtocolHeaderRequired&&(e?e["X-Client-Protocol"]="webchannel":e={"X-Client-Protocol":"webchannel"}),this.g.s=e,e=t&&t.initMessageHeaders||null,t&&t.messageContentType&&(e?e["X-WebChannel-Content-Type"]=t.messageContentType:e={"X-WebChannel-Content-Type":t.messageContentType}),t&&t.ya&&(e?e["X-WebChannel-Client-Profile"]=t.ya:e={"X-WebChannel-Client-Profile":t.ya}),this.g.S=e,(e=t&&t.Yb)&&!ze(e)&&(this.g.o=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!ze(t)&&(this.g.D=t,null!==(e=this.h)&&t in e&&(t in(e=this.h)&&delete e[t])),this.j=new ys(this)}function gs(e){Sn.call(this);var t=e.__sm__;if(t){e:{for(var n in t){e=n;break e}e=void 0}(this.i=e)&&(e=this.i,t=null!==t&&e in t?t[e]:void 0),this.data=t}else this.data=e}function ms(){Cn.call(this),this.status=1}function ys(e){this.g=e}(Ee=Lr.prototype).Ka=function(e){this.L=e},Ee.da=function(e,t,n,r){var s,i,o,a;if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.H+"; newUri="+e);t=t?t.toUpperCase():"GET",this.H=e,this.j="",this.m=0,this.D=!1,this.h=!0,this.g=this.u?this.u.g():En.g(),this.C=this.u?bn(this.u):bn(En),this.g.onreadystatechange=Pe(this.Ha,this);try{this.F=!0,this.g.open(t,String(e),!0),this.F=!1}catch(l){return void Ur(this,l)}if(e=n||"",n=new Map(this.headers),r)if(Object.getPrototypeOf(r)===Object.prototype)for(var c in r)n.set(c,r[c]);else{if("function"!=typeof r.keys||"function"!=typeof r.get)throw Error("Unknown input type for opt_headers: "+String(r));try{for(var u=be(r.keys()),h=u.next();!h.done;h=u.next()){var l=h.value;n.set(l,r.get(l))}}catch(e){s={error:e}}finally{try{h&&!h.done&&(i=u.return)&&i.call(u)}finally{if(s)throw s.error}}}r=Array.from(n.keys()).find((function(e){return"content-type"==e.toLowerCase()})),c=Ce.FormData&&e instanceof Ce.FormData,!(0<=Fe(xr,t))||r||c||n.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");try{for(var d=be(n),f=d.next();!f.done;f=d.next()){var p=Te(f.value,2),g=(l=p[0],p[1]);this.g.setRequestHeader(l,g)}}catch(e){o={error:e}}finally{try{f&&!f.done&&(a=d.return)&&a.call(d)}finally{if(o)throw o.error}}this.J&&(this.g.responseType=this.J),"withCredentials"in this.g&&this.g.withCredentials!==this.L&&(this.g.withCredentials=this.L);try{jr(this),0<this.B&&((this.K=function(e){return Je&&ut()&&"number"==typeof e.timeout&&void 0!==e.ontimeout}(this.g))?(this.g.timeout=this.B,this.g.ontimeout=Pe(this.qa,this)):this.A=Zt(this.qa,this.B,this)),this.v=!0,this.g.send(e),this.v=!1}catch(l){Ur(this,l)}},Ee.qa=function(){void 0!==Se&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,Ft(this,"timeout"),this.abort(8))},Ee.abort=function(e){this.g&&this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=e||7,Ft(this,"complete"),Ft(this,"abort"),qr(this))},Ee.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),qr(this,!0)),Lr.X.M.call(this)},Ee.Ha=function(){this.s||(this.F||this.v||this.l?Vr(this):this.fb())},Ee.fb=function(){Vr(this)},Ee.aa=function(){try{return 2<Br(this)?this.g.status:-1}catch(e){return-1}},Ee.fa=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},Ee.Sa=function(e){if(this.g){var t=this.g.responseText;return e&&0==t.indexOf(e)&&(t=t.substring(e.length)),Or(t)}},Ee.Ea=function(){return this.m},Ee.Oa=function(){return"string"==typeof this.j?this.j:String(this.j)},(Ee=Gr.prototype).ma=8,Ee.G=1,Ee.Ja=function(e){if(this.m)if(this.m=null,1==this.G){if(!e){this.U=Math.floor(1e5*Math.random()),e=this.U++;var t=new kn(this,this.j,e,void 0),n=this.s;if(this.S&&(n?bt(n=wt(n),this.S):n=this.S),null!==this.o||this.N||(t.H=n,n=null),this.O)e:{for(var r=0,s=0;s<this.i.length;s++){var i=this.i[s];if(void 0===(i="__data__"in i.g&&"string"==typeof(i=i.g.__data__)?i.length:void 0))break;if(4096<(r+=i)){r=s;break e}if(4096===r||s===this.i.length-1){r=s+1;break e}}r=1e3}else r=1e3;r=es(this,t,r),Xn(s=Gn(this.F),"RID",e),Xn(s,"CVER",22),this.D&&Xn(s,"X-HTTP-Session-Id",this.D),Zr(this,s),n&&(this.N?r="headers="+encodeURIComponent(String($r(n)))+"&"+r:this.o&&Kr(s,this.o,n)),wr(this.h,t),this.Ya&&Xn(s,"TYPE","init"),this.O?(Xn(s,"$req",r),Xn(s,"SID","null"),t.Z=!0,Ln(t,s,null)):Ln(t,s,r),this.G=2}}else 3==this.G&&(e?Jr(this,e):0==this.i.length||mr(this.h)||Jr(this))},Ee.Ia=function(){if(this.u=null,ss(this),this.$&&!(this.K||null==this.g||0>=this.P)){var e=2*this.P;this.j.info("BP detection timer enabled: "+e),this.B=yn(Pe(this.eb,this),e)}},Ee.eb=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,gn(10),Qr(this),ss(this))},Ee.cb=function(){null!=this.v&&(this.v=null,Qr(this),ns(this),gn(19))},Ee.kb=function(e){e?(this.j.info("Successfully pinged google.com"),gn(2)):(this.j.info("Failed to ping google.com"),gn(1))},(Ee=ds.prototype).xa=function(){},Ee.wa=function(){},Ee.va=function(){},Ee.ua=function(){},Ee.Ra=function(){},fs.prototype.g=function(e,t){return new ps(e,t)},xe(ps,Ut),ps.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.H=!0);var e=this.g,t=this.l,n=this.h||void 0;gn(0),e.V=t,e.ia=n||{},e.L=e.Y,e.F=hs(e,null,e.V),Xr(e)},ps.prototype.close=function(){Wr(this.g)},ps.prototype.u=function(e){var t=this.g;if("string"==typeof e){var n={};n.__data__=e,e=n}else this.v&&((n={}).__data__=qt(e),e=n);t.i.push(new fr(t.ab++,e)),3==t.G&&Xr(t)},ps.prototype.M=function(){this.g.l=null,delete this.j,Wr(this.g),delete this.g,ps.X.M.call(this)},xe(gs,Sn),xe(ms,Cn),xe(ys,ds),ys.prototype.xa=function(){Ft(this.g,"a")},ys.prototype.wa=function(e){Ft(this.g,new gs(e))},ys.prototype.va=function(e){Ft(this.g,new ms)},ys.prototype.ua=function(){Ft(this.g,"b")},fs.prototype.createWebChannel=fs.prototype.g,ps.prototype.send=ps.prototype.u,ps.prototype.open=ps.prototype.m,ps.prototype.close=ps.prototype.close,vn.NO_ERROR=0,vn.TIMEOUT=8,vn.HTTP_ERROR=6,wn.COMPLETE="complete",Tn.EventType=_n,_n.OPEN="a",_n.CLOSE="b",_n.ERROR="c",_n.MESSAGE="d",Ut.prototype.listen=Ut.prototype.N,Lr.prototype.listenOnce=Lr.prototype.O,Lr.prototype.getLastError=Lr.prototype.Oa,Lr.prototype.getLastErrorCode=Lr.prototype.Ea,Lr.prototype.getStatus=Lr.prototype.aa,Lr.prototype.getResponseJson=Lr.prototype.Sa,Lr.prototype.getResponseText=Lr.prototype.fa,Lr.prototype.send=Lr.prototype.da,Lr.prototype.setWithCredentials=Lr.prototype.Ka;var vs=vn,ws=wn,Is=un,bs=10,Ts=11,Es=Cr,_s=Tn,Ss=Lr;const Cs="@firebase/firestore";
315
315
  /**
316
316
  * @license
317
317
  * Copyright 2017 Google LLC
@@ -327,7 +327,7 @@ class ie{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e)
327
327
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
328
328
  * See the License for the specific language governing permissions and
329
329
  * limitations under the License.
330
- */class ks{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}ks.UNAUTHENTICATED=new ks(null),ks.GOOGLE_CREDENTIALS=new ks("google-credentials-uid"),ks.FIRST_PARTY=new ks("first-party-uid"),ks.MOCK_USER=new ks("mock-user");
330
+ */class As{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}As.UNAUTHENTICATED=new As(null),As.GOOGLE_CREDENTIALS=new As("google-credentials-uid"),As.FIRST_PARTY=new As("first-party-uid"),As.MOCK_USER=new As("mock-user");
331
331
  /**
332
332
  * @license
333
333
  * Copyright 2017 Google LLC
@@ -344,7 +344,7 @@ class ie{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e)
344
344
  * See the License for the specific language governing permissions and
345
345
  * limitations under the License.
346
346
  */
347
- let As="9.15.0";
347
+ let ks="9.15.0";
348
348
  /**
349
349
  * @license
350
350
  * Copyright 2017 Google LLC
@@ -360,7 +360,7 @@ let As="9.15.0";
360
360
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
361
361
  * See the License for the specific language governing permissions and
362
362
  * limitations under the License.
363
- */const Ns=new D("@firebase/firestore");function Ds(){return Ns.logLevel}function Rs(e,...t){if(Ns.logLevel<=S.DEBUG){const n=t.map(Ps);Ns.debug(`Firestore (${As}): ${e}`,...n)}}function Os(e,...t){if(Ns.logLevel<=S.ERROR){const n=t.map(Ps);Ns.error(`Firestore (${As}): ${e}`,...n)}}function Ls(e,...t){if(Ns.logLevel<=S.WARN){const n=t.map(Ps);Ns.warn(`Firestore (${As}): ${e}`,...n)}}function Ps(e){if("string"==typeof e)return e;try{return t=e,JSON.stringify(t)}catch(t){return e}
363
+ */const Ns=new D("@firebase/firestore");function Ds(){return Ns.logLevel}function Rs(e,...t){if(Ns.logLevel<=S.DEBUG){const n=t.map(Ps);Ns.debug(`Firestore (${ks}): ${e}`,...n)}}function Os(e,...t){if(Ns.logLevel<=S.ERROR){const n=t.map(Ps);Ns.error(`Firestore (${ks}): ${e}`,...n)}}function Ls(e,...t){if(Ns.logLevel<=S.WARN){const n=t.map(Ps);Ns.warn(`Firestore (${ks}): ${e}`,...n)}}function Ps(e){if("string"==typeof e)return e;try{return t=e,JSON.stringify(t)}catch(t){return e}
364
364
  /**
365
365
  * @license
366
366
  * Copyright 2020 Google LLC
@@ -392,7 +392,7 @@ let As="9.15.0";
392
392
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
393
393
  * See the License for the specific language governing permissions and
394
394
  * limitations under the License.
395
- */function Ms(e="Unexpected state"){const t=`FIRESTORE (${As}) INTERNAL ASSERTION FAILED: `+e;throw Os(t),new Error(t)}function xs(e,t){e||Ms()}function Us(e,t){return e}
395
+ */function Ms(e="Unexpected state"){const t=`FIRESTORE (${ks}) INTERNAL ASSERTION FAILED: `+e;throw Os(t),new Error(t)}function xs(e,t){e||Ms()}function Us(e,t){return e}
396
396
  /**
397
397
  * @license
398
398
  * Copyright 2017 Google LLC
@@ -440,7 +440,7 @@ let As="9.15.0";
440
440
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
441
441
  * See the License for the specific language governing permissions and
442
442
  * limitations under the License.
443
- */class js{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class Bs{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(ks.UNAUTHENTICATED)))}shutdown(){}}class zs{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable((()=>t(this.token.user)))}shutdown(){this.changeListener=null}}class $s{constructor(e){this.t=e,this.currentUser=ks.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){let n=this.i;const r=e=>this.i!==n?(n=this.i,t(e)):Promise.resolve();let s=new qs;this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new qs,e.enqueueRetryable((()=>r(this.currentUser)))};const i=()=>{const t=s;e.enqueueRetryable((async()=>{await t.promise,await r(this.currentUser)}))},o=e=>{Rs("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.auth.addAuthTokenListener(this.o),i()};this.t.onInit((e=>o(e))),setTimeout((()=>{if(!this.auth){const e=this.t.getImmediate({optional:!0});e?o(e):(Rs("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new qs)}}),0),i()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((t=>this.i!==e?(Rs("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(xs("string"==typeof t.accessToken),new js(t.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.auth.removeAuthTokenListener(this.o)}u(){const e=this.auth&&this.auth.getUid();return xs(null===e||"string"==typeof e),new ks(e)}}class Ks{constructor(e,t,n,r){this.h=e,this.l=t,this.m=n,this.g=r,this.type="FirstParty",this.user=ks.FIRST_PARTY,this.p=new Map}I(){return this.g?this.g():(xs(!("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 e=this.I();return e&&this.p.set("Authorization",e),this.m&&this.p.set("X-Goog-Iam-Authorization-Token",this.m),this.p}}class Hs{constructor(e,t,n,r){this.h=e,this.l=t,this.m=n,this.g=r}getToken(){return Promise.resolve(new Ks(this.h,this.l,this.m,this.g))}start(e,t){e.enqueueRetryable((()=>t(ks.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class Gs{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class Ws{constructor(e){this.T=e,this.forceRefresh=!1,this.appCheck=null,this.A=null}start(e,t){const n=e=>{null!=e.error&&Rs("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);const n=e.token!==this.A;return this.A=e.token,Rs("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable((()=>n(t)))};const r=e=>{Rs("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.appCheck.addTokenListener(this.o)};this.T.onInit((e=>r(e))),setTimeout((()=>{if(!this.appCheck){const e=this.T.getImmediate({optional:!0});e?r(e):Rs("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((e=>e?(xs("string"==typeof e.token),this.A=e.token,new Gs(e.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}
443
+ */class js{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class Bs{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(As.UNAUTHENTICATED)))}shutdown(){}}class zs{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable((()=>t(this.token.user)))}shutdown(){this.changeListener=null}}class $s{constructor(e){this.t=e,this.currentUser=As.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){let n=this.i;const r=e=>this.i!==n?(n=this.i,t(e)):Promise.resolve();let s=new qs;this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new qs,e.enqueueRetryable((()=>r(this.currentUser)))};const i=()=>{const t=s;e.enqueueRetryable((async()=>{await t.promise,await r(this.currentUser)}))},o=e=>{Rs("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.auth.addAuthTokenListener(this.o),i()};this.t.onInit((e=>o(e))),setTimeout((()=>{if(!this.auth){const e=this.t.getImmediate({optional:!0});e?o(e):(Rs("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new qs)}}),0),i()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((t=>this.i!==e?(Rs("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(xs("string"==typeof t.accessToken),new js(t.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.auth.removeAuthTokenListener(this.o)}u(){const e=this.auth&&this.auth.getUid();return xs(null===e||"string"==typeof e),new As(e)}}class Ks{constructor(e,t,n,r){this.h=e,this.l=t,this.m=n,this.g=r,this.type="FirstParty",this.user=As.FIRST_PARTY,this.p=new Map}I(){return this.g?this.g():(xs(!("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 e=this.I();return e&&this.p.set("Authorization",e),this.m&&this.p.set("X-Goog-Iam-Authorization-Token",this.m),this.p}}class Hs{constructor(e,t,n,r){this.h=e,this.l=t,this.m=n,this.g=r}getToken(){return Promise.resolve(new Ks(this.h,this.l,this.m,this.g))}start(e,t){e.enqueueRetryable((()=>t(As.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class Gs{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class Ws{constructor(e){this.T=e,this.forceRefresh=!1,this.appCheck=null,this.A=null}start(e,t){const n=e=>{null!=e.error&&Rs("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);const n=e.token!==this.A;return this.A=e.token,Rs("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable((()=>n(t)))};const r=e=>{Rs("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.appCheck.addTokenListener(this.o)};this.T.onInit((e=>r(e))),setTimeout((()=>{if(!this.appCheck){const e=this.T.getImmediate({optional:!0});e?r(e):Rs("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((e=>e?(xs("string"==typeof e.token),this.A=e.token,new Gs(e.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}
444
444
  /**
445
445
  * @license
446
446
  * Copyright 2020 Google LLC
@@ -698,7 +698,7 @@ class bi{constructor(e){this.binaryString=e}static fromBase64String(e){const t=a
698
698
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
699
699
  * See the License for the specific language governing permissions and
700
700
  * limitations under the License.
701
- */function Ci(e){var t,n;return"server_timestamp"===(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function ki(e){const t=e.mapValue.fields.__previous_value__;return Ci(t)?ki(t):t}function Ai(e){const t=Ei(e.mapValue.fields.__local_write_time__.timestampValue);return new Zs(t.seconds,t.nanos)}
701
+ */function Ci(e){var t,n;return"server_timestamp"===(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function Ai(e){const t=e.mapValue.fields.__previous_value__;return Ci(t)?Ai(t):t}function ki(e){const t=Ei(e.mapValue.fields.__local_write_time__.timestampValue);return new Zs(t.seconds,t.nanos)}
702
702
  /**
703
703
  * @license
704
704
  * Copyright 2020 Google LLC
@@ -730,7 +730,7 @@ class bi{constructor(e){this.binaryString=e}static fromBase64String(e){const t=a
730
730
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
731
731
  * See the License for the specific language governing permissions and
732
732
  * limitations under the License.
733
- */(e)?9007199254740991:10:Ms()}function Ri(e,t){if(e===t)return!0;const n=Di(e);if(n!==Di(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return Ai(e).isEqual(Ai(t));case 3:return function(e,t){if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;const n=Ei(e.timestampValue),r=Ei(t.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return function(e,t){return Si(e.bytesValue).isEqual(Si(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return _i(e.geoPointValue.latitude)===_i(t.geoPointValue.latitude)&&_i(e.geoPointValue.longitude)===_i(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return _i(e.integerValue)===_i(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){const n=_i(e.doubleValue),r=_i(t.doubleValue);return n===r?Ii(n)===Ii(r):isNaN(n)&&isNaN(r)}return!1}(e,t);case 9:return Js(e.arrayValue.values||[],t.arrayValue.values||[],Ri);case 10:return function(e,t){const n=e.mapValue.fields||{},r=t.mapValue.fields||{};if(mi(n)!==mi(r))return!1;for(const e in n)if(n.hasOwnProperty(e)&&(void 0===r[e]||!Ri(n[e],r[e])))return!1;return!0}(e,t);default:return Ms()}}function Oi(e,t){return void 0!==(e.values||[]).find((e=>Ri(e,t)))}function Li(e,t){if(e===t)return 0;const n=Di(e),r=Di(t);if(n!==r)return Xs(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return Xs(e.booleanValue,t.booleanValue);case 2:return function(e,t){const n=_i(e.integerValue||e.doubleValue),r=_i(t.integerValue||t.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(e,t);case 3:return Pi(e.timestampValue,t.timestampValue);case 4:return Pi(Ai(e),Ai(t));case 5:return Xs(e.stringValue,t.stringValue);case 6:return function(e,t){const n=Si(e),r=Si(t);return n.compareTo(r)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){const n=e.split("/"),r=t.split("/");for(let e=0;e<n.length&&e<r.length;e++){const t=Xs(n[e],r[e]);if(0!==t)return t}return Xs(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){const n=Xs(_i(e.latitude),_i(t.latitude));return 0!==n?n:Xs(_i(e.longitude),_i(t.longitude))}(e.geoPointValue,t.geoPointValue);case 9:return function(e,t){const n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){const t=Li(n[e],r[e]);if(t)return t}return Xs(n.length,r.length)}(e.arrayValue,t.arrayValue);case 10:return function(e,t){if(e===Ni&&t===Ni)return 0;if(e===Ni)return 1;if(t===Ni)return-1;const n=e.fields||{},r=Object.keys(n),s=t.fields||{},i=Object.keys(s);r.sort(),i.sort();for(let e=0;e<r.length&&e<i.length;++e){const t=Xs(r[e],i[e]);if(0!==t)return t;const o=Li(n[r[e]],s[i[e]]);if(0!==o)return o}return Xs(r.length,i.length)}(e.mapValue,t.mapValue);default:throw Ms()}}function Pi(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return Xs(e,t);const n=Ei(e),r=Ei(t),s=Xs(n.seconds,r.seconds);return 0!==s?s:Xs(n.nanos,r.nanos)}function Mi(e){return xi(e)}function xi(e){return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?function(e){const t=Ei(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?Si(e.bytesValue).toBase64():"referenceValue"in e?(n=e.referenceValue,ii.fromName(n).toString()):"geoPointValue"in e?`geo(${(t=e.geoPointValue).latitude},${t.longitude})`:"arrayValue"in e?function(e){let t="[",n=!0;for(const r of e.values||[])n?n=!1:t+=",",t+=xi(r);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){const t=Object.keys(e.fields||{}).sort();let n="{",r=!0;for(const s of t)r?r=!1:n+=",",n+=`${s}:${xi(e.fields[s])}`;return n+"}"}(e.mapValue):Ms();var t,n}function Ui(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function Fi(e){return!!e&&"integerValue"in e}function Vi(e){return!!e&&"arrayValue"in e}function qi(e){return!!e&&"nullValue"in e}function ji(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function Bi(e){return!!e&&"mapValue"in e}function zi(e){if(e.geoPointValue)return{geoPointValue:Object.assign({},e.geoPointValue)};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:Object.assign({},e.timestampValue)};if(e.mapValue){const t={mapValue:{fields:{}}};return yi(e.mapValue.fields,((e,n)=>t.mapValue.fields[e]=zi(n))),t}if(e.arrayValue){const t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=zi(e.arrayValue.values[n]);return t}return Object.assign({},e)}class $i{constructor(e,t){this.position=e,this.inclusive=t}}function Ki(e,t,n){let r=0;for(let s=0;s<e.position.length;s++){const i=t[s],o=e.position[s];if(r=i.field.isKeyField()?ii.comparator(ii.fromName(o.referenceValue),n.key):Li(o,n.data.field(i.field)),"desc"===i.dir&&(r*=-1),0!==r)break}return r}function Hi(e,t){if(null===e)return null===t;if(null===t)return!1;if(e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let n=0;n<e.position.length;n++)if(!Ri(e.position[n],t.position[n]))return!1;return!0}
733
+ */(e)?9007199254740991:10:Ms()}function Ri(e,t){if(e===t)return!0;const n=Di(e);if(n!==Di(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return ki(e).isEqual(ki(t));case 3:return function(e,t){if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;const n=Ei(e.timestampValue),r=Ei(t.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return function(e,t){return Si(e.bytesValue).isEqual(Si(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return _i(e.geoPointValue.latitude)===_i(t.geoPointValue.latitude)&&_i(e.geoPointValue.longitude)===_i(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return _i(e.integerValue)===_i(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){const n=_i(e.doubleValue),r=_i(t.doubleValue);return n===r?Ii(n)===Ii(r):isNaN(n)&&isNaN(r)}return!1}(e,t);case 9:return Js(e.arrayValue.values||[],t.arrayValue.values||[],Ri);case 10:return function(e,t){const n=e.mapValue.fields||{},r=t.mapValue.fields||{};if(mi(n)!==mi(r))return!1;for(const e in n)if(n.hasOwnProperty(e)&&(void 0===r[e]||!Ri(n[e],r[e])))return!1;return!0}(e,t);default:return Ms()}}function Oi(e,t){return void 0!==(e.values||[]).find((e=>Ri(e,t)))}function Li(e,t){if(e===t)return 0;const n=Di(e),r=Di(t);if(n!==r)return Xs(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return Xs(e.booleanValue,t.booleanValue);case 2:return function(e,t){const n=_i(e.integerValue||e.doubleValue),r=_i(t.integerValue||t.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(e,t);case 3:return Pi(e.timestampValue,t.timestampValue);case 4:return Pi(ki(e),ki(t));case 5:return Xs(e.stringValue,t.stringValue);case 6:return function(e,t){const n=Si(e),r=Si(t);return n.compareTo(r)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){const n=e.split("/"),r=t.split("/");for(let e=0;e<n.length&&e<r.length;e++){const t=Xs(n[e],r[e]);if(0!==t)return t}return Xs(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){const n=Xs(_i(e.latitude),_i(t.latitude));return 0!==n?n:Xs(_i(e.longitude),_i(t.longitude))}(e.geoPointValue,t.geoPointValue);case 9:return function(e,t){const n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){const t=Li(n[e],r[e]);if(t)return t}return Xs(n.length,r.length)}(e.arrayValue,t.arrayValue);case 10:return function(e,t){if(e===Ni&&t===Ni)return 0;if(e===Ni)return 1;if(t===Ni)return-1;const n=e.fields||{},r=Object.keys(n),s=t.fields||{},i=Object.keys(s);r.sort(),i.sort();for(let e=0;e<r.length&&e<i.length;++e){const t=Xs(r[e],i[e]);if(0!==t)return t;const o=Li(n[r[e]],s[i[e]]);if(0!==o)return o}return Xs(r.length,i.length)}(e.mapValue,t.mapValue);default:throw Ms()}}function Pi(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return Xs(e,t);const n=Ei(e),r=Ei(t),s=Xs(n.seconds,r.seconds);return 0!==s?s:Xs(n.nanos,r.nanos)}function Mi(e){return xi(e)}function xi(e){return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?function(e){const t=Ei(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?Si(e.bytesValue).toBase64():"referenceValue"in e?(n=e.referenceValue,ii.fromName(n).toString()):"geoPointValue"in e?`geo(${(t=e.geoPointValue).latitude},${t.longitude})`:"arrayValue"in e?function(e){let t="[",n=!0;for(const r of e.values||[])n?n=!1:t+=",",t+=xi(r);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){const t=Object.keys(e.fields||{}).sort();let n="{",r=!0;for(const s of t)r?r=!1:n+=",",n+=`${s}:${xi(e.fields[s])}`;return n+"}"}(e.mapValue):Ms();var t,n}function Ui(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function Fi(e){return!!e&&"integerValue"in e}function Vi(e){return!!e&&"arrayValue"in e}function qi(e){return!!e&&"nullValue"in e}function ji(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function Bi(e){return!!e&&"mapValue"in e}function zi(e){if(e.geoPointValue)return{geoPointValue:Object.assign({},e.geoPointValue)};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:Object.assign({},e.timestampValue)};if(e.mapValue){const t={mapValue:{fields:{}}};return yi(e.mapValue.fields,((e,n)=>t.mapValue.fields[e]=zi(n))),t}if(e.arrayValue){const t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=zi(e.arrayValue.values[n]);return t}return Object.assign({},e)}class $i{constructor(e,t){this.position=e,this.inclusive=t}}function Ki(e,t,n){let r=0;for(let s=0;s<e.position.length;s++){const i=t[s],o=e.position[s];if(r=i.field.isKeyField()?ii.comparator(ii.fromName(o.referenceValue),n.key):Li(o,n.data.field(i.field)),"desc"===i.dir&&(r*=-1),0!==r)break}return r}function Hi(e,t){if(null===e)return null===t;if(null===t)return!1;if(e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let n=0;n<e.position.length;n++)if(!Ri(e.position[n],t.position[n]))return!1;return!0}
734
734
  /**
735
735
  * @license
736
736
  * Copyright 2022 Google LLC
@@ -875,7 +875,7 @@ class go{constructor(e){this.comparator=e,this.data=new lo(this.comparator)}has(
875
875
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
876
876
  * See the License for the specific language governing permissions and
877
877
  * limitations under the License.
878
- */class So{constructor(e,t=null,n=[],r=[],s=null,i="F",o=null,a=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=r,this.limit=s,this.limitType=i,this.startAt=o,this.endAt=a,this.dt=null,this._t=null,this.startAt,this.endAt}}function Co(e){return new So(e)}function ko(e){return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())}function Ao(e){return e.explicitOrderBy.length>0?e.explicitOrderBy[0].field:null}function No(e){for(const t of e.filters){const e=t.getFirstInequalityField();if(null!==e)return e}return null}function Do(e){return null!==e.collectionGroup}function Ro(e){const t=Us(e);if(null===t.dt){t.dt=[];const e=No(t),n=Ao(t);if(null!==e&&null===n)e.isKeyField()||t.dt.push(new uo(e)),t.dt.push(new uo(si.keyField(),"asc"));else{let e=!1;for(const n of t.explicitOrderBy)t.dt.push(n),n.field.isKeyField()&&(e=!0);if(!e){const e=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";t.dt.push(new uo(si.keyField(),e))}}}return t.dt}function Oo(e){const t=Us(e);if(!t._t)if("F"===t.limitType)t._t=bo(t.path,t.collectionGroup,Ro(t),t.filters,t.limit,t.startAt,t.endAt);else{const e=[];for(const n of Ro(t)){const t="desc"===n.dir?"asc":"desc";e.push(new uo(n.field,t))}const n=t.endAt?new $i(t.endAt.position,t.endAt.inclusive):null,r=t.startAt?new $i(t.startAt.position,t.startAt.inclusive):null;t._t=bo(t.path,t.collectionGroup,e,t.filters,t.limit,n,r)}return t._t}function Lo(e,t){t.getFirstInequalityField(),No(e);const n=e.filters.concat([t]);return new So(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function Po(e,t,n){return new So(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function Mo(e,t){return Eo(Oo(e),Oo(t))&&e.limitType===t.limitType}function xo(e){return`${To(Oo(e))}|lt:${e.limitType}`}function Uo(e){return`Query(target=${function(e){let t=e.path.canonicalString();return null!==e.collectionGroup&&(t+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(t+=`, filters: [${e.filters.map((e=>eo(e))).join(", ")}]`),wi(e.limit)||(t+=", limit: "+e.limit),e.orderBy.length>0&&(t+=`, orderBy: [${e.orderBy.map((e=>function(e){return`${e.field.canonicalString()} (${e.dir})`}(e))).join(", ")}]`),e.startAt&&(t+=", startAt: ",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((e=>Mi(e))).join(",")),e.endAt&&(t+=", endAt: ",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((e=>Mi(e))).join(",")),`Target(${t})`}(Oo(e))}; limitType=${e.limitType})`}function Fo(e,t){return t.isFoundDocument()&&function(e,t){const n=t.key.path;return null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n):ii.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n)}(e,t)&&function(e,t){for(const n of Ro(e))if(!n.field.isKeyField()&&null===t.data.field(n.field))return!1;return!0}(e,t)&&function(e,t){for(const n of e.filters)if(!n.matches(t))return!1;return!0}(e,t)&&function(e,t){return!(e.startAt&&!function(e,t,n){const r=Ki(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,Ro(e),t))&&!(e.endAt&&!function(e,t,n){const r=Ki(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,Ro(e),t))}(e,t)}function Vo(e){return(t,n)=>{let r=!1;for(const s of Ro(e)){const e=qo(s,t,n);if(0!==e)return e;r=r||s.field.isKeyField()}return 0}}function qo(e,t,n){const r=e.field.isKeyField()?ii.comparator(t.key,n.key):function(e,t,n){const r=t.data.field(e),s=n.data.field(e);return null!==r&&null!==s?Li(r,s):Ms()}(e.field,t,n);switch(e.dir){case"asc":return r;case"desc":return-1*r;default:return Ms()}}
878
+ */class So{constructor(e,t=null,n=[],r=[],s=null,i="F",o=null,a=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=r,this.limit=s,this.limitType=i,this.startAt=o,this.endAt=a,this.dt=null,this._t=null,this.startAt,this.endAt}}function Co(e){return new So(e)}function Ao(e){return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())}function ko(e){return e.explicitOrderBy.length>0?e.explicitOrderBy[0].field:null}function No(e){for(const t of e.filters){const e=t.getFirstInequalityField();if(null!==e)return e}return null}function Do(e){return null!==e.collectionGroup}function Ro(e){const t=Us(e);if(null===t.dt){t.dt=[];const e=No(t),n=ko(t);if(null!==e&&null===n)e.isKeyField()||t.dt.push(new uo(e)),t.dt.push(new uo(si.keyField(),"asc"));else{let e=!1;for(const n of t.explicitOrderBy)t.dt.push(n),n.field.isKeyField()&&(e=!0);if(!e){const e=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";t.dt.push(new uo(si.keyField(),e))}}}return t.dt}function Oo(e){const t=Us(e);if(!t._t)if("F"===t.limitType)t._t=bo(t.path,t.collectionGroup,Ro(t),t.filters,t.limit,t.startAt,t.endAt);else{const e=[];for(const n of Ro(t)){const t="desc"===n.dir?"asc":"desc";e.push(new uo(n.field,t))}const n=t.endAt?new $i(t.endAt.position,t.endAt.inclusive):null,r=t.startAt?new $i(t.startAt.position,t.startAt.inclusive):null;t._t=bo(t.path,t.collectionGroup,e,t.filters,t.limit,n,r)}return t._t}function Lo(e,t){t.getFirstInequalityField(),No(e);const n=e.filters.concat([t]);return new So(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function Po(e,t,n){return new So(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function Mo(e,t){return Eo(Oo(e),Oo(t))&&e.limitType===t.limitType}function xo(e){return`${To(Oo(e))}|lt:${e.limitType}`}function Uo(e){return`Query(target=${function(e){let t=e.path.canonicalString();return null!==e.collectionGroup&&(t+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(t+=`, filters: [${e.filters.map((e=>eo(e))).join(", ")}]`),wi(e.limit)||(t+=", limit: "+e.limit),e.orderBy.length>0&&(t+=`, orderBy: [${e.orderBy.map((e=>function(e){return`${e.field.canonicalString()} (${e.dir})`}(e))).join(", ")}]`),e.startAt&&(t+=", startAt: ",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((e=>Mi(e))).join(",")),e.endAt&&(t+=", endAt: ",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((e=>Mi(e))).join(",")),`Target(${t})`}(Oo(e))}; limitType=${e.limitType})`}function Fo(e,t){return t.isFoundDocument()&&function(e,t){const n=t.key.path;return null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n):ii.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n)}(e,t)&&function(e,t){for(const n of Ro(e))if(!n.field.isKeyField()&&null===t.data.field(n.field))return!1;return!0}(e,t)&&function(e,t){for(const n of e.filters)if(!n.matches(t))return!1;return!0}(e,t)&&function(e,t){return!(e.startAt&&!function(e,t,n){const r=Ki(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,Ro(e),t))&&!(e.endAt&&!function(e,t,n){const r=Ki(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,Ro(e),t))}(e,t)}function Vo(e){return(t,n)=>{let r=!1;for(const s of Ro(e)){const e=qo(s,t,n);if(0!==e)return e;r=r||s.field.isKeyField()}return 0}}function qo(e,t,n){const r=e.field.isKeyField()?ii.comparator(t.key,n.key):function(e,t,n){const r=t.data.field(e),s=n.data.field(e);return null!==r&&null!==s?Li(r,s):Ms()}(e.field,t,n);switch(e.dir){case"asc":return r;case"desc":return-1*r;default:return Ms()}}
879
879
  /**
880
880
  * @license
881
881
  * Copyright 2020 Google LLC
@@ -972,7 +972,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
972
972
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
973
973
  * See the License for the specific language governing permissions and
974
974
  * limitations under the License.
975
- */const wa=new lo(ii.comparator);function Ia(){return wa}const ba=new lo(ii.comparator);function Ta(...e){let t=ba;for(const n of e)t=t.insert(n.key,n);return t}function Ea(e){let t=ba;return e.forEach(((e,n)=>t=t.insert(e,n.overlayedDocument))),t}function _a(){return Ca()}function Sa(){return Ca()}function Ca(){return new va((e=>e.toString()),((e,t)=>e.isEqual(t)))}new lo(ii.comparator);const ka=new go(ii.comparator);function Aa(...e){let t=ka;for(const n of e)t=t.add(n);return t}const Na=new go(Xs);function Da(){return Na}
975
+ */const wa=new lo(ii.comparator);function Ia(){return wa}const ba=new lo(ii.comparator);function Ta(...e){let t=ba;for(const n of e)t=t.insert(n.key,n);return t}function Ea(e){let t=ba;return e.forEach(((e,n)=>t=t.insert(e,n.overlayedDocument))),t}function _a(){return Ca()}function Sa(){return Ca()}function Ca(){return new va((e=>e.toString()),((e,t)=>e.isEqual(t)))}new lo(ii.comparator);const Aa=new go(ii.comparator);function ka(...e){let t=Aa;for(const n of e)t=t.add(n);return t}const Na=new go(Xs);function Da(){return Na}
976
976
  /**
977
977
  * @license
978
978
  * Copyright 2017 Google LLC
@@ -988,7 +988,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
988
988
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
989
989
  * See the License for the specific language governing permissions and
990
990
  * limitations under the License.
991
- */class Ra{constructor(e,t,n,r,s){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=s}static createSynthesizedRemoteEventForCurrentChange(e,t,n){const r=new Map;return r.set(e,Oa.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new Ra(ei.min(),r,Da(),Ia(),Aa())}}class Oa{constructor(e,t,n,r,s){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=s}static createSynthesizedTargetChangeForCurrentChange(e,t,n){return new Oa(n,t,Aa(),Aa(),Aa())}}
991
+ */class Ra{constructor(e,t,n,r,s){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=s}static createSynthesizedRemoteEventForCurrentChange(e,t,n){const r=new Map;return r.set(e,Oa.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new Ra(ei.min(),r,Da(),Ia(),ka())}}class Oa{constructor(e,t,n,r,s){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=s}static createSynthesizedTargetChangeForCurrentChange(e,t,n){return new Oa(n,t,ka(),ka(),ka())}}
992
992
  /**
993
993
  * @license
994
994
  * Copyright 2017 Google LLC
@@ -1004,7 +1004,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1004
1004
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1005
1005
  * See the License for the specific language governing permissions and
1006
1006
  * limitations under the License.
1007
- */class La{constructor(e,t,n,r){this.It=e,this.removedTargetIds=t,this.key=n,this.Tt=r}}class Pa{constructor(e,t){this.targetId=e,this.Et=t}}class Ma{constructor(e,t,n=bi.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class xa{constructor(){this.At=0,this.Rt=Va(),this.bt=bi.EMPTY_BYTE_STRING,this.Pt=!1,this.vt=!0}get current(){return this.Pt}get resumeToken(){return this.bt}get Vt(){return 0!==this.At}get St(){return this.vt}Dt(e){e.approximateByteSize()>0&&(this.vt=!0,this.bt=e)}Ct(){let e=Aa(),t=Aa(),n=Aa();return this.Rt.forEach(((r,s)=>{switch(s){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:n=n.add(r);break;default:Ms()}})),new Oa(this.bt,this.Pt,e,t,n)}xt(){this.vt=!1,this.Rt=Va()}Nt(e,t){this.vt=!0,this.Rt=this.Rt.insert(e,t)}kt(e){this.vt=!0,this.Rt=this.Rt.remove(e)}Ot(){this.At+=1}Mt(){this.At-=1}Ft(){this.vt=!0,this.Pt=!0}}class Ua{constructor(e){this.$t=e,this.Bt=new Map,this.Lt=Ia(),this.qt=Fa(),this.Ut=new go(Xs)}Kt(e){for(const t of e.It)e.Tt&&e.Tt.isFoundDocument()?this.Gt(t,e.Tt):this.Qt(t,e.key,e.Tt);for(const t of e.removedTargetIds)this.Qt(t,e.key,e.Tt)}jt(e){this.forEachTarget(e,(t=>{const n=this.Wt(t);switch(e.state){case 0:this.zt(t)&&n.Dt(e.resumeToken);break;case 1:n.Mt(),n.Vt||n.xt(),n.Dt(e.resumeToken);break;case 2:n.Mt(),n.Vt||this.removeTarget(t);break;case 3:this.zt(t)&&(n.Ft(),n.Dt(e.resumeToken));break;case 4:this.zt(t)&&(this.Ht(t),n.Dt(e.resumeToken));break;default:Ms()}}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Bt.forEach(((e,n)=>{this.zt(n)&&t(n)}))}Jt(e){const t=e.targetId,n=e.Et.count,r=this.Yt(t);if(r){const e=r.target;if(_o(e))if(0===n){const n=new ii(e.path);this.Qt(t,n,wo.newNoDocument(n,ei.min()))}else xs(1===n);else this.Xt(t)!==n&&(this.Ht(t),this.Ut=this.Ut.add(t))}}Zt(e){const t=new Map;this.Bt.forEach(((n,r)=>{const s=this.Yt(r);if(s){if(n.current&&_o(s.target)){const t=new ii(s.target.path);null!==this.Lt.get(t)||this.te(r,t)||this.Qt(r,t,wo.newNoDocument(t,e))}n.St&&(t.set(r,n.Ct()),n.xt())}}));let n=Aa();this.qt.forEach(((e,t)=>{let r=!0;t.forEachWhile((e=>{const t=this.Yt(e);return!t||2===t.purpose||(r=!1,!1)})),r&&(n=n.add(e))})),this.Lt.forEach(((t,n)=>n.setReadTime(e)));const r=new Ra(e,t,this.Ut,this.Lt,n);return this.Lt=Ia(),this.qt=Fa(),this.Ut=new go(Xs),r}Gt(e,t){if(!this.zt(e))return;const n=this.te(e,t.key)?2:0;this.Wt(e).Nt(t.key,n),this.Lt=this.Lt.insert(t.key,t),this.qt=this.qt.insert(t.key,this.ee(t.key).add(e))}Qt(e,t,n){if(!this.zt(e))return;const r=this.Wt(e);this.te(e,t)?r.Nt(t,1):r.kt(t),this.qt=this.qt.insert(t,this.ee(t).delete(e)),n&&(this.Lt=this.Lt.insert(t,n))}removeTarget(e){this.Bt.delete(e)}Xt(e){const t=this.Wt(e).Ct();return this.$t.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Ot(e){this.Wt(e).Ot()}Wt(e){let t=this.Bt.get(e);return t||(t=new xa,this.Bt.set(e,t)),t}ee(e){let t=this.qt.get(e);return t||(t=new go(Xs),this.qt=this.qt.insert(e,t)),t}zt(e){const t=null!==this.Yt(e);return t||Rs("WatchChangeAggregator","Detected inactive target",e),t}Yt(e){const t=this.Bt.get(e);return t&&t.Vt?null:this.$t.ne(e)}Ht(e){this.Bt.set(e,new xa),this.$t.getRemoteKeysForTarget(e).forEach((t=>{this.Qt(e,t,null)}))}te(e,t){return this.$t.getRemoteKeysForTarget(e).has(t)}}function Fa(){return new lo(ii.comparator)}function Va(){return new lo(ii.comparator)}
1007
+ */class La{constructor(e,t,n,r){this.It=e,this.removedTargetIds=t,this.key=n,this.Tt=r}}class Pa{constructor(e,t){this.targetId=e,this.Et=t}}class Ma{constructor(e,t,n=bi.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class xa{constructor(){this.At=0,this.Rt=Va(),this.bt=bi.EMPTY_BYTE_STRING,this.Pt=!1,this.vt=!0}get current(){return this.Pt}get resumeToken(){return this.bt}get Vt(){return 0!==this.At}get St(){return this.vt}Dt(e){e.approximateByteSize()>0&&(this.vt=!0,this.bt=e)}Ct(){let e=ka(),t=ka(),n=ka();return this.Rt.forEach(((r,s)=>{switch(s){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:n=n.add(r);break;default:Ms()}})),new Oa(this.bt,this.Pt,e,t,n)}xt(){this.vt=!1,this.Rt=Va()}Nt(e,t){this.vt=!0,this.Rt=this.Rt.insert(e,t)}kt(e){this.vt=!0,this.Rt=this.Rt.remove(e)}Ot(){this.At+=1}Mt(){this.At-=1}Ft(){this.vt=!0,this.Pt=!0}}class Ua{constructor(e){this.$t=e,this.Bt=new Map,this.Lt=Ia(),this.qt=Fa(),this.Ut=new go(Xs)}Kt(e){for(const t of e.It)e.Tt&&e.Tt.isFoundDocument()?this.Gt(t,e.Tt):this.Qt(t,e.key,e.Tt);for(const t of e.removedTargetIds)this.Qt(t,e.key,e.Tt)}jt(e){this.forEachTarget(e,(t=>{const n=this.Wt(t);switch(e.state){case 0:this.zt(t)&&n.Dt(e.resumeToken);break;case 1:n.Mt(),n.Vt||n.xt(),n.Dt(e.resumeToken);break;case 2:n.Mt(),n.Vt||this.removeTarget(t);break;case 3:this.zt(t)&&(n.Ft(),n.Dt(e.resumeToken));break;case 4:this.zt(t)&&(this.Ht(t),n.Dt(e.resumeToken));break;default:Ms()}}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Bt.forEach(((e,n)=>{this.zt(n)&&t(n)}))}Jt(e){const t=e.targetId,n=e.Et.count,r=this.Yt(t);if(r){const e=r.target;if(_o(e))if(0===n){const n=new ii(e.path);this.Qt(t,n,wo.newNoDocument(n,ei.min()))}else xs(1===n);else this.Xt(t)!==n&&(this.Ht(t),this.Ut=this.Ut.add(t))}}Zt(e){const t=new Map;this.Bt.forEach(((n,r)=>{const s=this.Yt(r);if(s){if(n.current&&_o(s.target)){const t=new ii(s.target.path);null!==this.Lt.get(t)||this.te(r,t)||this.Qt(r,t,wo.newNoDocument(t,e))}n.St&&(t.set(r,n.Ct()),n.xt())}}));let n=ka();this.qt.forEach(((e,t)=>{let r=!0;t.forEachWhile((e=>{const t=this.Yt(e);return!t||2===t.purpose||(r=!1,!1)})),r&&(n=n.add(e))})),this.Lt.forEach(((t,n)=>n.setReadTime(e)));const r=new Ra(e,t,this.Ut,this.Lt,n);return this.Lt=Ia(),this.qt=Fa(),this.Ut=new go(Xs),r}Gt(e,t){if(!this.zt(e))return;const n=this.te(e,t.key)?2:0;this.Wt(e).Nt(t.key,n),this.Lt=this.Lt.insert(t.key,t),this.qt=this.qt.insert(t.key,this.ee(t.key).add(e))}Qt(e,t,n){if(!this.zt(e))return;const r=this.Wt(e);this.te(e,t)?r.Nt(t,1):r.kt(t),this.qt=this.qt.insert(t,this.ee(t).delete(e)),n&&(this.Lt=this.Lt.insert(t,n))}removeTarget(e){this.Bt.delete(e)}Xt(e){const t=this.Wt(e).Ct();return this.$t.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Ot(e){this.Wt(e).Ot()}Wt(e){let t=this.Bt.get(e);return t||(t=new xa,this.Bt.set(e,t)),t}ee(e){let t=this.qt.get(e);return t||(t=new go(Xs),this.qt=this.qt.insert(e,t)),t}zt(e){const t=null!==this.Yt(e);return t||Rs("WatchChangeAggregator","Detected inactive target",e),t}Yt(e){const t=this.Bt.get(e);return t&&t.Vt?null:this.$t.ne(e)}Ht(e){this.Bt.set(e,new xa),this.$t.getRemoteKeysForTarget(e).forEach((t=>{this.Qt(e,t,null)}))}te(e,t){return this.$t.getRemoteKeysForTarget(e).has(t)}}function Fa(){return new lo(ii.comparator)}function Va(){return new lo(ii.comparator)}
1008
1008
  /**
1009
1009
  * @license
1010
1010
  * Copyright 2017 Google LLC
@@ -1036,7 +1036,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1036
1036
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1037
1037
  * See the License for the specific language governing permissions and
1038
1038
  * limitations under the License.
1039
- */class hc{constructor(e,t,n,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(e,t){const n=t.mutationResults;for(let t=0;t<this.mutations.length;t++){const r=this.mutations[t];r.key.isEqual(e.key)&&ia(r,e,n[t])}}applyToLocalView(e,t){for(const n of this.baseMutations)n.key.isEqual(e.key)&&(t=oa(n,e,t,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(e.key)&&(t=oa(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const n=Sa();return this.mutations.forEach((r=>{const s=e.get(r.key),i=s.overlayedDocument;let o=this.applyToLocalView(i,s.mutatedFields);o=t.has(r.key)?null:o;const a=sa(i,o);null!==a&&n.set(r.key,a),i.isValidDocument()||i.convertToNoDocument(ei.min())})),n}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),Aa())}isEqual(e){return this.batchId===e.batchId&&Js(this.mutations,e.mutations,((e,t)=>aa(e,t)))&&Js(this.baseMutations,e.baseMutations,((e,t)=>aa(e,t)))}}
1039
+ */class hc{constructor(e,t,n,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(e,t){const n=t.mutationResults;for(let t=0;t<this.mutations.length;t++){const r=this.mutations[t];r.key.isEqual(e.key)&&ia(r,e,n[t])}}applyToLocalView(e,t){for(const n of this.baseMutations)n.key.isEqual(e.key)&&(t=oa(n,e,t,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(e.key)&&(t=oa(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const n=Sa();return this.mutations.forEach((r=>{const s=e.get(r.key),i=s.overlayedDocument;let o=this.applyToLocalView(i,s.mutatedFields);o=t.has(r.key)?null:o;const a=sa(i,o);null!==a&&n.set(r.key,a),i.isValidDocument()||i.convertToNoDocument(ei.min())})),n}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),ka())}isEqual(e){return this.batchId===e.batchId&&Js(this.mutations,e.mutations,((e,t)=>aa(e,t)))&&Js(this.baseMutations,e.baseMutations,((e,t)=>aa(e,t)))}}
1040
1040
  /**
1041
1041
  * @license
1042
1042
  * Copyright 2022 Google LLC
@@ -1180,7 +1180,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1180
1180
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1181
1181
  * See the License for the specific language governing permissions and
1182
1182
  * limitations under the License.
1183
- */class Ic{constructor(e,t,n,r){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=r}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next((r=>(n=r,this.remoteDocumentCache.getEntry(e,t)))).next((e=>(null!==n&&oa(n.mutation,e,yo.empty(),Zs.now()),e)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.getLocalViewOfDocuments(e,t,Aa()).next((()=>t))))}getLocalViewOfDocuments(e,t,n=Aa()){const r=_a();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,n).next((e=>{let t=Ta();return e.forEach(((e,n)=>{t=t.insert(e,n.overlayedDocument)})),t}))))}getOverlayedDocuments(e,t){const n=_a();return this.populateOverlays(e,n,t).next((()=>this.computeViews(e,t,n,Aa())))}populateOverlays(e,t,n){const r=[];return n.forEach((e=>{t.has(e)||r.push(e)})),this.documentOverlayCache.getOverlays(e,r).next((e=>{e.forEach(((e,n)=>{t.set(e,n)}))}))}computeViews(e,t,n,r){let s=Ia();const i=Ca(),o=Ca();return t.forEach(((e,t)=>{const o=n.get(t.key);r.has(t.key)&&(void 0===o||o.mutation instanceof ua)?s=s.insert(t.key,t):void 0!==o&&(i.set(t.key,o.mutation.getFieldMask()),oa(o.mutation,t,o.mutation.getFieldMask(),Zs.now()))})),this.recalculateAndSaveOverlays(e,s).next((e=>(e.forEach(((e,t)=>i.set(e,t))),t.forEach(((e,t)=>{var n;return o.set(e,new wc(t,null!==(n=i.get(e))&&void 0!==n?n:null))})),o)))}recalculateAndSaveOverlays(e,t){const n=Ca();let r=new lo(((e,t)=>e-t)),s=Aa();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((e=>{for(const s of e)s.keys().forEach((e=>{const i=t.get(e);if(null===i)return;let o=n.get(e)||yo.empty();o=s.applyToLocalView(i,o),n.set(e,o);const a=(r.get(s.batchId)||Aa()).add(e);r=r.insert(s.batchId,a)}))})).next((()=>{const i=[],o=r.getReverseIterator();for(;o.hasNext();){const r=o.getNext(),a=r.key,c=r.value,u=Sa();c.forEach((e=>{if(!s.has(e)){const r=sa(t.get(e),n.get(e));null!==r&&u.set(e,r),s=s.add(e)}})),i.push(this.documentOverlayCache.saveOverlays(e,a,u))}return li.waitFor(i)})).next((()=>n))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.recalculateAndSaveOverlays(e,t)))}getDocumentsMatchingQuery(e,t,n){return function(e){return ii.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):Do(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n):this.getDocumentsMatchingCollectionQuery(e,t,n)}getNextDocuments(e,t,n,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,r).next((s=>{const i=r-s.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-s.size):li.resolve(_a());let o=-1,a=s;return i.next((t=>li.forEach(t,((t,n)=>(o<n.largestBatchId&&(o=n.largestBatchId),s.get(t)?li.resolve():this.remoteDocumentCache.getEntry(e,t).next((e=>{a=a.insert(t,e)}))))).next((()=>this.populateOverlays(e,t,s))).next((()=>this.computeViews(e,a,t,Aa()))).next((e=>({batchId:o,changes:Ea(e)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new ii(t)).next((e=>{let t=Ta();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t}))}getDocumentsMatchingCollectionGroupQuery(e,t,n){const r=t.collectionGroup;let s=Ta();return this.indexManager.getCollectionParents(e,r).next((i=>li.forEach(i,(i=>{const o=function(e,t){return new So(t,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(t,i.child(r));return this.getDocumentsMatchingCollectionQuery(e,o,n).next((e=>{e.forEach(((e,t)=>{s=s.insert(e,t)}))}))})).next((()=>s))))}getDocumentsMatchingCollectionQuery(e,t,n){let r;return this.remoteDocumentCache.getAllFromCollection(e,t.path,n).next((s=>(r=s,this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId)))).next((e=>{e.forEach(((e,t)=>{const n=t.getKey();null===r.get(n)&&(r=r.insert(n,wo.newInvalidDocument(n)))}));let n=Ta();return r.forEach(((r,s)=>{const i=e.get(r);void 0!==i&&oa(i.mutation,s,yo.empty(),Zs.now()),Fo(t,s)&&(n=n.insert(r,s))})),n}))}}
1183
+ */class Ic{constructor(e,t,n,r){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=r}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next((r=>(n=r,this.remoteDocumentCache.getEntry(e,t)))).next((e=>(null!==n&&oa(n.mutation,e,yo.empty(),Zs.now()),e)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.getLocalViewOfDocuments(e,t,ka()).next((()=>t))))}getLocalViewOfDocuments(e,t,n=ka()){const r=_a();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,n).next((e=>{let t=Ta();return e.forEach(((e,n)=>{t=t.insert(e,n.overlayedDocument)})),t}))))}getOverlayedDocuments(e,t){const n=_a();return this.populateOverlays(e,n,t).next((()=>this.computeViews(e,t,n,ka())))}populateOverlays(e,t,n){const r=[];return n.forEach((e=>{t.has(e)||r.push(e)})),this.documentOverlayCache.getOverlays(e,r).next((e=>{e.forEach(((e,n)=>{t.set(e,n)}))}))}computeViews(e,t,n,r){let s=Ia();const i=Ca(),o=Ca();return t.forEach(((e,t)=>{const o=n.get(t.key);r.has(t.key)&&(void 0===o||o.mutation instanceof ua)?s=s.insert(t.key,t):void 0!==o&&(i.set(t.key,o.mutation.getFieldMask()),oa(o.mutation,t,o.mutation.getFieldMask(),Zs.now()))})),this.recalculateAndSaveOverlays(e,s).next((e=>(e.forEach(((e,t)=>i.set(e,t))),t.forEach(((e,t)=>{var n;return o.set(e,new wc(t,null!==(n=i.get(e))&&void 0!==n?n:null))})),o)))}recalculateAndSaveOverlays(e,t){const n=Ca();let r=new lo(((e,t)=>e-t)),s=ka();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((e=>{for(const s of e)s.keys().forEach((e=>{const i=t.get(e);if(null===i)return;let o=n.get(e)||yo.empty();o=s.applyToLocalView(i,o),n.set(e,o);const a=(r.get(s.batchId)||ka()).add(e);r=r.insert(s.batchId,a)}))})).next((()=>{const i=[],o=r.getReverseIterator();for(;o.hasNext();){const r=o.getNext(),a=r.key,c=r.value,u=Sa();c.forEach((e=>{if(!s.has(e)){const r=sa(t.get(e),n.get(e));null!==r&&u.set(e,r),s=s.add(e)}})),i.push(this.documentOverlayCache.saveOverlays(e,a,u))}return li.waitFor(i)})).next((()=>n))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.recalculateAndSaveOverlays(e,t)))}getDocumentsMatchingQuery(e,t,n){return function(e){return ii.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):Do(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n):this.getDocumentsMatchingCollectionQuery(e,t,n)}getNextDocuments(e,t,n,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,r).next((s=>{const i=r-s.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-s.size):li.resolve(_a());let o=-1,a=s;return i.next((t=>li.forEach(t,((t,n)=>(o<n.largestBatchId&&(o=n.largestBatchId),s.get(t)?li.resolve():this.remoteDocumentCache.getEntry(e,t).next((e=>{a=a.insert(t,e)}))))).next((()=>this.populateOverlays(e,t,s))).next((()=>this.computeViews(e,a,t,ka()))).next((e=>({batchId:o,changes:Ea(e)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new ii(t)).next((e=>{let t=Ta();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t}))}getDocumentsMatchingCollectionGroupQuery(e,t,n){const r=t.collectionGroup;let s=Ta();return this.indexManager.getCollectionParents(e,r).next((i=>li.forEach(i,(i=>{const o=function(e,t){return new So(t,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(t,i.child(r));return this.getDocumentsMatchingCollectionQuery(e,o,n).next((e=>{e.forEach(((e,t)=>{s=s.insert(e,t)}))}))})).next((()=>s))))}getDocumentsMatchingCollectionQuery(e,t,n){let r;return this.remoteDocumentCache.getAllFromCollection(e,t.path,n).next((s=>(r=s,this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId)))).next((e=>{e.forEach(((e,t)=>{const n=t.getKey();null===r.get(n)&&(r=r.insert(n,wo.newInvalidDocument(n)))}));let n=Ta();return r.forEach(((r,s)=>{const i=e.get(r);void 0!==i&&oa(i.mutation,s,yo.empty(),Zs.now()),Fo(t,s)&&(n=n.insert(r,s))})),n}))}}
1184
1184
  /**
1185
1185
  * @license
1186
1186
  * Copyright 2020 Google LLC
@@ -1212,7 +1212,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1212
1212
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1213
1213
  * See the License for the specific language governing permissions and
1214
1214
  * limitations under the License.
1215
- */class Tc{constructor(){this.overlays=new lo(ii.comparator),this.es=new Map}getOverlay(e,t){return li.resolve(this.overlays.get(t))}getOverlays(e,t){const n=_a();return li.forEach(t,(t=>this.getOverlay(e,t).next((e=>{null!==e&&n.set(t,e)})))).next((()=>n))}saveOverlays(e,t,n){return n.forEach(((n,r)=>{this.oe(e,t,r)})),li.resolve()}removeOverlaysForBatchId(e,t,n){const r=this.es.get(n);return void 0!==r&&(r.forEach((e=>this.overlays=this.overlays.remove(e))),this.es.delete(n)),li.resolve()}getOverlaysForCollection(e,t,n){const r=_a(),s=t.length+1,i=new ii(t.child("")),o=this.overlays.getIteratorFrom(i);for(;o.hasNext();){const e=o.getNext().value,i=e.getKey();if(!t.isPrefixOf(i.path))break;i.path.length===s&&e.largestBatchId>n&&r.set(e.getKey(),e)}return li.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let s=new lo(((e,t)=>e-t));const i=this.overlays.getIterator();for(;i.hasNext();){const e=i.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>n){let t=s.get(e.largestBatchId);null===t&&(t=_a(),s=s.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}const o=_a(),a=s.getIterator();for(;a.hasNext()&&(a.getNext().value.forEach(((e,t)=>o.set(e,t))),!(o.size()>=r)););return li.resolve(o)}oe(e,t,n){const r=this.overlays.get(n.key);if(null!==r){const e=this.es.get(r.largestBatchId).delete(n.key);this.es.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new lc(t,n));let s=this.es.get(t);void 0===s&&(s=Aa(),this.es.set(t,s)),this.es.set(t,s.add(n.key))}}
1215
+ */class Tc{constructor(){this.overlays=new lo(ii.comparator),this.es=new Map}getOverlay(e,t){return li.resolve(this.overlays.get(t))}getOverlays(e,t){const n=_a();return li.forEach(t,(t=>this.getOverlay(e,t).next((e=>{null!==e&&n.set(t,e)})))).next((()=>n))}saveOverlays(e,t,n){return n.forEach(((n,r)=>{this.oe(e,t,r)})),li.resolve()}removeOverlaysForBatchId(e,t,n){const r=this.es.get(n);return void 0!==r&&(r.forEach((e=>this.overlays=this.overlays.remove(e))),this.es.delete(n)),li.resolve()}getOverlaysForCollection(e,t,n){const r=_a(),s=t.length+1,i=new ii(t.child("")),o=this.overlays.getIteratorFrom(i);for(;o.hasNext();){const e=o.getNext().value,i=e.getKey();if(!t.isPrefixOf(i.path))break;i.path.length===s&&e.largestBatchId>n&&r.set(e.getKey(),e)}return li.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let s=new lo(((e,t)=>e-t));const i=this.overlays.getIterator();for(;i.hasNext();){const e=i.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>n){let t=s.get(e.largestBatchId);null===t&&(t=_a(),s=s.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}const o=_a(),a=s.getIterator();for(;a.hasNext()&&(a.getNext().value.forEach(((e,t)=>o.set(e,t))),!(o.size()>=r)););return li.resolve(o)}oe(e,t,n){const r=this.overlays.get(n.key);if(null!==r){const e=this.es.get(r.largestBatchId).delete(n.key);this.es.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new lc(t,n));let s=this.es.get(t);void 0===s&&(s=ka(),this.es.set(t,s)),this.es.set(t,s.add(n.key))}}
1216
1216
  /**
1217
1217
  * @license
1218
1218
  * Copyright 2017 Google LLC
@@ -1228,7 +1228,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1228
1228
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1229
1229
  * See the License for the specific language governing permissions and
1230
1230
  * limitations under the License.
1231
- */class Ec{constructor(){this.ns=new go(_c.ss),this.rs=new go(_c.os)}isEmpty(){return this.ns.isEmpty()}addReference(e,t){const n=new _c(e,t);this.ns=this.ns.add(n),this.rs=this.rs.add(n)}us(e,t){e.forEach((e=>this.addReference(e,t)))}removeReference(e,t){this.cs(new _c(e,t))}hs(e,t){e.forEach((e=>this.removeReference(e,t)))}ls(e){const t=new ii(new ni([])),n=new _c(t,e),r=new _c(t,e+1),s=[];return this.rs.forEachInRange([n,r],(e=>{this.cs(e),s.push(e.key)})),s}fs(){this.ns.forEach((e=>this.cs(e)))}cs(e){this.ns=this.ns.delete(e),this.rs=this.rs.delete(e)}ds(e){const t=new ii(new ni([])),n=new _c(t,e),r=new _c(t,e+1);let s=Aa();return this.rs.forEachInRange([n,r],(e=>{s=s.add(e.key)})),s}containsKey(e){const t=new _c(e,0),n=this.ns.firstAfterOrEqual(t);return null!==n&&e.isEqual(n.key)}}class _c{constructor(e,t){this.key=e,this._s=t}static ss(e,t){return ii.comparator(e.key,t.key)||Xs(e._s,t._s)}static os(e,t){return Xs(e._s,t._s)||ii.comparator(e.key,t.key)}}
1231
+ */class Ec{constructor(){this.ns=new go(_c.ss),this.rs=new go(_c.os)}isEmpty(){return this.ns.isEmpty()}addReference(e,t){const n=new _c(e,t);this.ns=this.ns.add(n),this.rs=this.rs.add(n)}us(e,t){e.forEach((e=>this.addReference(e,t)))}removeReference(e,t){this.cs(new _c(e,t))}hs(e,t){e.forEach((e=>this.removeReference(e,t)))}ls(e){const t=new ii(new ni([])),n=new _c(t,e),r=new _c(t,e+1),s=[];return this.rs.forEachInRange([n,r],(e=>{this.cs(e),s.push(e.key)})),s}fs(){this.ns.forEach((e=>this.cs(e)))}cs(e){this.ns=this.ns.delete(e),this.rs=this.rs.delete(e)}ds(e){const t=new ii(new ni([])),n=new _c(t,e),r=new _c(t,e+1);let s=ka();return this.rs.forEachInRange([n,r],(e=>{s=s.add(e.key)})),s}containsKey(e){const t=new _c(e,0),n=this.ns.firstAfterOrEqual(t);return null!==n&&e.isEqual(n.key)}}class _c{constructor(e,t){this.key=e,this._s=t}static ss(e,t){return ii.comparator(e.key,t.key)||Xs(e._s,t._s)}static os(e,t){return Xs(e._s,t._s)||ii.comparator(e.key,t.key)}}
1232
1232
  /**
1233
1233
  * @license
1234
1234
  * Copyright 2017 Google LLC
@@ -1260,7 +1260,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1260
1260
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261
1261
  * See the License for the specific language governing permissions and
1262
1262
  * limitations under the License.
1263
- */class Cc{constructor(e){this.Es=e,this.docs=new lo(ii.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const n=t.key,r=this.docs.get(n),s=r?r.size:0,i=this.Es(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:i}),this.size+=i-s,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const n=this.docs.get(t);return li.resolve(n?n.document.mutableCopy():wo.newInvalidDocument(t))}getEntries(e,t){let n=Ia();return t.forEach((e=>{const t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():wo.newInvalidDocument(e))})),li.resolve(n)}getAllFromCollection(e,t,n){let r=Ia();const s=new ii(t.child("")),i=this.docs.getIteratorFrom(s);for(;i.hasNext();){const{key:e,value:{document:s}}=i.getNext();if(!t.isPrefixOf(e.path))break;e.path.length>t.length+1||ci(oi(s),n)<=0||(r=r.insert(s.key,s.mutableCopy()))}return li.resolve(r)}getAllFromCollectionGroup(e,t,n,r){Ms()}As(e,t){return li.forEach(this.docs,(e=>t(e)))}newChangeBuffer(e){return new kc(this)}getSize(e){return li.resolve(this.size)}}class kc extends vc{constructor(e){super(),this.Yn=e}applyChanges(e){const t=[];return this.changes.forEach(((n,r)=>{r.isValidDocument()?t.push(this.Yn.addEntry(e,r)):this.Yn.removeEntry(n)})),li.waitFor(t)}getFromCache(e,t){return this.Yn.getEntry(e,t)}getAllFromCache(e,t){return this.Yn.getEntries(e,t)}}
1263
+ */class Cc{constructor(e){this.Es=e,this.docs=new lo(ii.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const n=t.key,r=this.docs.get(n),s=r?r.size:0,i=this.Es(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:i}),this.size+=i-s,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const n=this.docs.get(t);return li.resolve(n?n.document.mutableCopy():wo.newInvalidDocument(t))}getEntries(e,t){let n=Ia();return t.forEach((e=>{const t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():wo.newInvalidDocument(e))})),li.resolve(n)}getAllFromCollection(e,t,n){let r=Ia();const s=new ii(t.child("")),i=this.docs.getIteratorFrom(s);for(;i.hasNext();){const{key:e,value:{document:s}}=i.getNext();if(!t.isPrefixOf(e.path))break;e.path.length>t.length+1||ci(oi(s),n)<=0||(r=r.insert(s.key,s.mutableCopy()))}return li.resolve(r)}getAllFromCollectionGroup(e,t,n,r){Ms()}As(e,t){return li.forEach(this.docs,(e=>t(e)))}newChangeBuffer(e){return new Ac(this)}getSize(e){return li.resolve(this.size)}}class Ac extends vc{constructor(e){super(),this.Yn=e}applyChanges(e){const t=[];return this.changes.forEach(((n,r)=>{r.isValidDocument()?t.push(this.Yn.addEntry(e,r)):this.Yn.removeEntry(n)})),li.waitFor(t)}getFromCache(e,t){return this.Yn.getEntry(e,t)}getAllFromCache(e,t){return this.Yn.getEntries(e,t)}}
1264
1264
  /**
1265
1265
  * @license
1266
1266
  * Copyright 2017 Google LLC
@@ -1276,7 +1276,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1276
1276
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1277
1277
  * See the License for the specific language governing permissions and
1278
1278
  * limitations under the License.
1279
- */class Ac{constructor(e){this.persistence=e,this.Rs=new va((e=>To(e)),Eo),this.lastRemoteSnapshotVersion=ei.min(),this.highestTargetId=0,this.bs=0,this.Ps=new Ec,this.targetCount=0,this.vs=yc.Pn()}forEachTarget(e,t){return this.Rs.forEach(((e,n)=>t(n))),li.resolve()}getLastRemoteSnapshotVersion(e){return li.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return li.resolve(this.bs)}allocateTargetId(e){return this.highestTargetId=this.vs.next(),li.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.bs&&(this.bs=t),li.resolve()}Dn(e){this.Rs.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.vs=new yc(t),this.highestTargetId=t),e.sequenceNumber>this.bs&&(this.bs=e.sequenceNumber)}addTargetData(e,t){return this.Dn(t),this.targetCount+=1,li.resolve()}updateTargetData(e,t){return this.Dn(t),li.resolve()}removeTargetData(e,t){return this.Rs.delete(t.target),this.Ps.ls(t.targetId),this.targetCount-=1,li.resolve()}removeTargets(e,t,n){let r=0;const s=[];return this.Rs.forEach(((i,o)=>{o.sequenceNumber<=t&&null===n.get(o.targetId)&&(this.Rs.delete(i),s.push(this.removeMatchingKeysForTargetId(e,o.targetId)),r++)})),li.waitFor(s).next((()=>r))}getTargetCount(e){return li.resolve(this.targetCount)}getTargetData(e,t){const n=this.Rs.get(t)||null;return li.resolve(n)}addMatchingKeys(e,t,n){return this.Ps.us(t,n),li.resolve()}removeMatchingKeys(e,t,n){this.Ps.hs(t,n);const r=this.persistence.referenceDelegate,s=[];return r&&t.forEach((t=>{s.push(r.markPotentiallyOrphaned(e,t))})),li.waitFor(s)}removeMatchingKeysForTargetId(e,t){return this.Ps.ls(t),li.resolve()}getMatchingKeysForTargetId(e,t){const n=this.Ps.ds(t);return li.resolve(n)}containsKey(e,t){return li.resolve(this.Ps.containsKey(t))}}
1279
+ */class kc{constructor(e){this.persistence=e,this.Rs=new va((e=>To(e)),Eo),this.lastRemoteSnapshotVersion=ei.min(),this.highestTargetId=0,this.bs=0,this.Ps=new Ec,this.targetCount=0,this.vs=yc.Pn()}forEachTarget(e,t){return this.Rs.forEach(((e,n)=>t(n))),li.resolve()}getLastRemoteSnapshotVersion(e){return li.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return li.resolve(this.bs)}allocateTargetId(e){return this.highestTargetId=this.vs.next(),li.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.bs&&(this.bs=t),li.resolve()}Dn(e){this.Rs.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.vs=new yc(t),this.highestTargetId=t),e.sequenceNumber>this.bs&&(this.bs=e.sequenceNumber)}addTargetData(e,t){return this.Dn(t),this.targetCount+=1,li.resolve()}updateTargetData(e,t){return this.Dn(t),li.resolve()}removeTargetData(e,t){return this.Rs.delete(t.target),this.Ps.ls(t.targetId),this.targetCount-=1,li.resolve()}removeTargets(e,t,n){let r=0;const s=[];return this.Rs.forEach(((i,o)=>{o.sequenceNumber<=t&&null===n.get(o.targetId)&&(this.Rs.delete(i),s.push(this.removeMatchingKeysForTargetId(e,o.targetId)),r++)})),li.waitFor(s).next((()=>r))}getTargetCount(e){return li.resolve(this.targetCount)}getTargetData(e,t){const n=this.Rs.get(t)||null;return li.resolve(n)}addMatchingKeys(e,t,n){return this.Ps.us(t,n),li.resolve()}removeMatchingKeys(e,t,n){this.Ps.hs(t,n);const r=this.persistence.referenceDelegate,s=[];return r&&t.forEach((t=>{s.push(r.markPotentiallyOrphaned(e,t))})),li.waitFor(s)}removeMatchingKeysForTargetId(e,t){return this.Ps.ls(t),li.resolve()}getMatchingKeysForTargetId(e,t){const n=this.Ps.ds(t);return li.resolve(n)}containsKey(e,t){return li.resolve(this.Ps.containsKey(t))}}
1280
1280
  /**
1281
1281
  * @license
1282
1282
  * Copyright 2017 Google LLC
@@ -1292,7 +1292,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1292
1292
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1293
1293
  * See the License for the specific language governing permissions and
1294
1294
  * limitations under the License.
1295
- */class Nc{constructor(e,t){this.Vs={},this.overlays={},this.Ss=new fi(0),this.Ds=!1,this.Ds=!0,this.referenceDelegate=e(this),this.Cs=new Ac(this),this.indexManager=new gc,this.remoteDocumentCache=function(e){return new Cc(e)}((e=>this.referenceDelegate.xs(e))),this.yt=new fc(t),this.Ns=new bc(this.yt)}start(){return Promise.resolve()}shutdown(){return this.Ds=!1,Promise.resolve()}get started(){return this.Ds}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new Tc,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.Vs[e.toKey()];return n||(n=new Sc(t,this.referenceDelegate),this.Vs[e.toKey()]=n),n}getTargetCache(){return this.Cs}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ns}runTransaction(e,t,n){Rs("MemoryPersistence","Starting transaction:",e);const r=new Dc(this.Ss.next());return this.referenceDelegate.ks(),n(r).next((e=>this.referenceDelegate.Os(r).next((()=>e)))).toPromise().then((e=>(r.raiseOnCommittedEvent(),e)))}Ms(e,t){return li.or(Object.values(this.Vs).map((n=>()=>n.containsKey(e,t))))}}class Dc extends ui{constructor(e){super(),this.currentSequenceNumber=e}}class Rc{constructor(e){this.persistence=e,this.Fs=new Ec,this.$s=null}static Bs(e){return new Rc(e)}get Ls(){if(this.$s)return this.$s;throw Ms()}addReference(e,t,n){return this.Fs.addReference(n,t),this.Ls.delete(n.toString()),li.resolve()}removeReference(e,t,n){return this.Fs.removeReference(n,t),this.Ls.add(n.toString()),li.resolve()}markPotentiallyOrphaned(e,t){return this.Ls.add(t.toString()),li.resolve()}removeTarget(e,t){this.Fs.ls(t.targetId).forEach((e=>this.Ls.add(e.toString())));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next((e=>{e.forEach((e=>this.Ls.add(e.toString())))})).next((()=>n.removeTargetData(e,t)))}ks(){this.$s=new Set}Os(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return li.forEach(this.Ls,(n=>{const r=ii.fromPath(n);return this.qs(e,r).next((e=>{e||t.removeEntry(r,ei.min())}))})).next((()=>(this.$s=null,t.apply(e))))}updateLimboDocument(e,t){return this.qs(e,t).next((e=>{e?this.Ls.delete(t.toString()):this.Ls.add(t.toString())}))}xs(e){return 0}qs(e,t){return li.or([()=>li.resolve(this.Fs.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ms(e,t)])}}
1295
+ */class Nc{constructor(e,t){this.Vs={},this.overlays={},this.Ss=new fi(0),this.Ds=!1,this.Ds=!0,this.referenceDelegate=e(this),this.Cs=new kc(this),this.indexManager=new gc,this.remoteDocumentCache=function(e){return new Cc(e)}((e=>this.referenceDelegate.xs(e))),this.yt=new fc(t),this.Ns=new bc(this.yt)}start(){return Promise.resolve()}shutdown(){return this.Ds=!1,Promise.resolve()}get started(){return this.Ds}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new Tc,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.Vs[e.toKey()];return n||(n=new Sc(t,this.referenceDelegate),this.Vs[e.toKey()]=n),n}getTargetCache(){return this.Cs}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ns}runTransaction(e,t,n){Rs("MemoryPersistence","Starting transaction:",e);const r=new Dc(this.Ss.next());return this.referenceDelegate.ks(),n(r).next((e=>this.referenceDelegate.Os(r).next((()=>e)))).toPromise().then((e=>(r.raiseOnCommittedEvent(),e)))}Ms(e,t){return li.or(Object.values(this.Vs).map((n=>()=>n.containsKey(e,t))))}}class Dc extends ui{constructor(e){super(),this.currentSequenceNumber=e}}class Rc{constructor(e){this.persistence=e,this.Fs=new Ec,this.$s=null}static Bs(e){return new Rc(e)}get Ls(){if(this.$s)return this.$s;throw Ms()}addReference(e,t,n){return this.Fs.addReference(n,t),this.Ls.delete(n.toString()),li.resolve()}removeReference(e,t,n){return this.Fs.removeReference(n,t),this.Ls.add(n.toString()),li.resolve()}markPotentiallyOrphaned(e,t){return this.Ls.add(t.toString()),li.resolve()}removeTarget(e,t){this.Fs.ls(t.targetId).forEach((e=>this.Ls.add(e.toString())));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next((e=>{e.forEach((e=>this.Ls.add(e.toString())))})).next((()=>n.removeTargetData(e,t)))}ks(){this.$s=new Set}Os(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return li.forEach(this.Ls,(n=>{const r=ii.fromPath(n);return this.qs(e,r).next((e=>{e||t.removeEntry(r,ei.min())}))})).next((()=>(this.$s=null,t.apply(e))))}updateLimboDocument(e,t){return this.qs(e,t).next((e=>{e?this.Ls.delete(t.toString()):this.Ls.add(t.toString())}))}xs(e){return 0}qs(e,t){return li.or([()=>li.resolve(this.Fs.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ms(e,t)])}}
1296
1296
  /**
1297
1297
  * @license
1298
1298
  * Copyright 2017 Google LLC
@@ -1308,7 +1308,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1308
1308
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1309
1309
  * See the License for the specific language governing permissions and
1310
1310
  * limitations under the License.
1311
- */class Oc{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.Si=n,this.Di=r}static Ci(e,t){let n=Aa(),r=Aa();for(const e of t.docChanges)switch(e.type){case 0:n=n.add(e.doc.key);break;case 1:r=r.add(e.doc.key)}return new Oc(e,t.fromCache,n,r)}}
1311
+ */class Oc{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.Si=n,this.Di=r}static Ci(e,t){let n=ka(),r=ka();for(const e of t.docChanges)switch(e.type){case 0:n=n.add(e.doc.key);break;case 1:r=r.add(e.doc.key)}return new Oc(e,t.fromCache,n,r)}}
1312
1312
  /**
1313
1313
  * @license
1314
1314
  * Copyright 2019 Google LLC
@@ -1324,7 +1324,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1324
1324
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1325
1325
  * See the License for the specific language governing permissions and
1326
1326
  * limitations under the License.
1327
- */class Lc{constructor(){this.xi=!1}initialize(e,t){this.Ni=e,this.indexManager=t,this.xi=!0}getDocumentsMatchingQuery(e,t,n,r){return this.ki(e,t).next((s=>s||this.Oi(e,t,r,n))).next((n=>n||this.Mi(e,t)))}ki(e,t){if(ko(t))return li.resolve(null);let n=Oo(t);return this.indexManager.getIndexType(e,n).next((r=>0===r?null:(null!==t.limit&&1===r&&(t=Po(t,null,"F"),n=Oo(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next((r=>{const s=Aa(...r);return this.Ni.getDocuments(e,s).next((r=>this.indexManager.getMinOffset(e,n).next((n=>{const i=this.Fi(t,r);return this.$i(t,i,s,n.readTime)?this.ki(e,Po(t,null,"F")):this.Bi(e,i,t,n)}))))})))))}Oi(e,t,n,r){return ko(t)||r.isEqual(ei.min())?this.Mi(e,t):this.Ni.getDocuments(e,n).next((s=>{const i=this.Fi(t,s);return this.$i(t,i,n,r)?this.Mi(e,t):(Ds()<=S.DEBUG&&Rs("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),Uo(t)),this.Bi(e,i,t,function(e,t){const n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1,s=ei.fromTimestamp(1e9===r?new Zs(n+1,0):new Zs(n,r));return new ai(s,ii.empty(),t)}(r,-1)))}))}Fi(e,t){let n=new go(Vo(e));return t.forEach(((t,r)=>{Fo(e,r)&&(n=n.add(r))})),n}$i(e,t,n,r){if(null===e.limit)return!1;if(n.size!==t.size)return!0;const s="F"===e.limitType?t.last():t.first();return!!s&&(s.hasPendingWrites||s.version.compareTo(r)>0)}Mi(e,t){return Ds()<=S.DEBUG&&Rs("QueryEngine","Using full collection scan to execute query:",Uo(t)),this.Ni.getDocumentsMatchingQuery(e,t,ai.min())}Bi(e,t,n,r){return this.Ni.getDocumentsMatchingQuery(e,n,r).next((e=>(t.forEach((t=>{e=e.insert(t.key,t)})),e)))}}
1327
+ */class Lc{constructor(){this.xi=!1}initialize(e,t){this.Ni=e,this.indexManager=t,this.xi=!0}getDocumentsMatchingQuery(e,t,n,r){return this.ki(e,t).next((s=>s||this.Oi(e,t,r,n))).next((n=>n||this.Mi(e,t)))}ki(e,t){if(Ao(t))return li.resolve(null);let n=Oo(t);return this.indexManager.getIndexType(e,n).next((r=>0===r?null:(null!==t.limit&&1===r&&(t=Po(t,null,"F"),n=Oo(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next((r=>{const s=ka(...r);return this.Ni.getDocuments(e,s).next((r=>this.indexManager.getMinOffset(e,n).next((n=>{const i=this.Fi(t,r);return this.$i(t,i,s,n.readTime)?this.ki(e,Po(t,null,"F")):this.Bi(e,i,t,n)}))))})))))}Oi(e,t,n,r){return Ao(t)||r.isEqual(ei.min())?this.Mi(e,t):this.Ni.getDocuments(e,n).next((s=>{const i=this.Fi(t,s);return this.$i(t,i,n,r)?this.Mi(e,t):(Ds()<=S.DEBUG&&Rs("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),Uo(t)),this.Bi(e,i,t,function(e,t){const n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1,s=ei.fromTimestamp(1e9===r?new Zs(n+1,0):new Zs(n,r));return new ai(s,ii.empty(),t)}(r,-1)))}))}Fi(e,t){let n=new go(Vo(e));return t.forEach(((t,r)=>{Fo(e,r)&&(n=n.add(r))})),n}$i(e,t,n,r){if(null===e.limit)return!1;if(n.size!==t.size)return!0;const s="F"===e.limitType?t.last():t.first();return!!s&&(s.hasPendingWrites||s.version.compareTo(r)>0)}Mi(e,t){return Ds()<=S.DEBUG&&Rs("QueryEngine","Using full collection scan to execute query:",Uo(t)),this.Ni.getDocumentsMatchingQuery(e,t,ai.min())}Bi(e,t,n,r){return this.Ni.getDocumentsMatchingQuery(e,n,r).next((e=>(t.forEach((t=>{e=e.insert(t.key,t)})),e)))}}
1328
1328
  /**
1329
1329
  * @license
1330
1330
  * Copyright 2020 Google LLC
@@ -1340,7 +1340,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1340
1340
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1341
1341
  * See the License for the specific language governing permissions and
1342
1342
  * limitations under the License.
1343
- */class Pc{constructor(e,t,n,r){this.persistence=e,this.Li=t,this.yt=r,this.qi=new lo(Xs),this.Ui=new va((e=>To(e)),Eo),this.Ki=new Map,this.Gi=e.getRemoteDocumentCache(),this.Cs=e.getTargetCache(),this.Ns=e.getBundleCache(),this.Qi(n)}Qi(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Ic(this.Gi,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Gi.setIndexManager(this.indexManager),this.Li.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=>e.collect(t,this.qi)))}}async function Mc(e,t){const n=Us(e);return await n.persistence.runTransaction("Handle user change","readonly",(e=>{let r;return n.mutationQueue.getAllMutationBatches(e).next((s=>(r=s,n.Qi(t),n.mutationQueue.getAllMutationBatches(e)))).next((t=>{const s=[],i=[];let o=Aa();for(const e of r){s.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}for(const e of t){i.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}return n.localDocuments.getDocuments(e,o).next((e=>({ji:e,removedBatchIds:s,addedBatchIds:i})))}))}))}function xc(e){const t=Us(e);return t.persistence.runTransaction("Get last remote snapshot version","readonly",(e=>t.Cs.getLastRemoteSnapshotVersion(e)))}function Uc(e,t){const n=Us(e),r=t.snapshotVersion;let s=n.qi;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(e=>{const i=n.Gi.newChangeBuffer({trackRemovals:!0});s=n.qi;const o=[];t.targetChanges.forEach(((i,a)=>{const c=s.get(a);if(!c)return;o.push(n.Cs.removeMatchingKeys(e,i.removedDocuments,a).next((()=>n.Cs.addMatchingKeys(e,i.addedDocuments,a))));let u=c.withSequenceNumber(e.currentSequenceNumber);t.targetMismatches.has(a)?u=u.withResumeToken(bi.EMPTY_BYTE_STRING,ei.min()).withLastLimboFreeSnapshotVersion(ei.min()):i.resumeToken.approximateByteSize()>0&&(u=u.withResumeToken(i.resumeToken,r)),s=s.insert(a,u),function(e,t,n){return 0===e.resumeToken.approximateByteSize()||(t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0)}(c,u,i)&&o.push(n.Cs.updateTargetData(e,u))}));let a=Ia(),c=Aa();if(t.documentUpdates.forEach((r=>{t.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))})),o.push(function(e,t,n){let r=Aa(),s=Aa();return n.forEach((e=>r=r.add(e))),t.getEntries(e,r).next((e=>{let r=Ia();return n.forEach(((n,i)=>{const o=e.get(n);i.isFoundDocument()!==o.isFoundDocument()&&(s=s.add(n)),i.isNoDocument()&&i.version.isEqual(ei.min())?(t.removeEntry(n,i.readTime),r=r.insert(n,i)):!o.isValidDocument()||i.version.compareTo(o.version)>0||0===i.version.compareTo(o.version)&&o.hasPendingWrites?(t.addEntry(i),r=r.insert(n,i)):Rs("LocalStore","Ignoring outdated watch update for ",n,". Current version:",o.version," Watch version:",i.version)})),{Wi:r,zi:s}}))}(e,i,t.documentUpdates).next((e=>{a=e.Wi,c=e.zi}))),!r.isEqual(ei.min())){const t=n.Cs.getLastRemoteSnapshotVersion(e).next((t=>n.Cs.setTargetsMetadata(e,e.currentSequenceNumber,r)));o.push(t)}return li.waitFor(o).next((()=>i.apply(e))).next((()=>n.localDocuments.getLocalViewOfDocuments(e,a,c))).next((()=>a))})).then((e=>(n.qi=s,e)))}async function Fc(e,t,n){const r=Us(e),s=r.qi.get(t),i=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",i,(e=>r.persistence.referenceDelegate.removeTarget(e,s)))}catch(e){if(!di(e))throw e;Rs("LocalStore",`Failed to update sequence numbers for target ${t}: ${e}`)}r.qi=r.qi.remove(t),r.Ui.delete(s.target)}function Vc(e,t,n){const r=Us(e);let s=ei.min(),i=Aa();return r.persistence.runTransaction("Execute query","readonly",(e=>function(e,t,n){const r=Us(e),s=r.Ui.get(n);return void 0!==s?li.resolve(r.qi.get(s)):r.Cs.getTargetData(t,n)}(r,e,Oo(t)).next((t=>{if(t)return s=t.lastLimboFreeSnapshotVersion,r.Cs.getMatchingKeysForTargetId(e,t.targetId).next((e=>{i=e}))})).next((()=>r.Li.getDocumentsMatchingQuery(e,t,n?s:ei.min(),n?i:Aa()))).next((e=>(function(e,t,n){let r=e.Ki.get(t)||ei.min();n.forEach(((e,t)=>{t.readTime.compareTo(r)>0&&(r=t.readTime)})),e.Ki.set(t,r)}(r,function(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}(t),e),{documents:e,Hi:i})))))}class qc{constructor(){this.activeTargetIds=Da()}er(e){this.activeTargetIds=this.activeTargetIds.add(e)}nr(e){this.activeTargetIds=this.activeTargetIds.delete(e)}tr(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class jc{constructor(){this.Lr=new qc,this.qr={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e){return this.Lr.er(e),this.qr[e]||"not-current"}updateQueryState(e,t,n){this.qr[e]=t}removeLocalQueryTarget(e){this.Lr.nr(e)}isLocalQueryTarget(e){return this.Lr.activeTargetIds.has(e)}clearQueryState(e){delete this.qr[e]}getAllActiveQueryTargets(){return this.Lr.activeTargetIds}isActiveQueryTarget(e){return this.Lr.activeTargetIds.has(e)}start(){return this.Lr=new qc,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}
1343
+ */class Pc{constructor(e,t,n,r){this.persistence=e,this.Li=t,this.yt=r,this.qi=new lo(Xs),this.Ui=new va((e=>To(e)),Eo),this.Ki=new Map,this.Gi=e.getRemoteDocumentCache(),this.Cs=e.getTargetCache(),this.Ns=e.getBundleCache(),this.Qi(n)}Qi(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Ic(this.Gi,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Gi.setIndexManager(this.indexManager),this.Li.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=>e.collect(t,this.qi)))}}async function Mc(e,t){const n=Us(e);return await n.persistence.runTransaction("Handle user change","readonly",(e=>{let r;return n.mutationQueue.getAllMutationBatches(e).next((s=>(r=s,n.Qi(t),n.mutationQueue.getAllMutationBatches(e)))).next((t=>{const s=[],i=[];let o=ka();for(const e of r){s.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}for(const e of t){i.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}return n.localDocuments.getDocuments(e,o).next((e=>({ji:e,removedBatchIds:s,addedBatchIds:i})))}))}))}function xc(e){const t=Us(e);return t.persistence.runTransaction("Get last remote snapshot version","readonly",(e=>t.Cs.getLastRemoteSnapshotVersion(e)))}function Uc(e,t){const n=Us(e),r=t.snapshotVersion;let s=n.qi;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(e=>{const i=n.Gi.newChangeBuffer({trackRemovals:!0});s=n.qi;const o=[];t.targetChanges.forEach(((i,a)=>{const c=s.get(a);if(!c)return;o.push(n.Cs.removeMatchingKeys(e,i.removedDocuments,a).next((()=>n.Cs.addMatchingKeys(e,i.addedDocuments,a))));let u=c.withSequenceNumber(e.currentSequenceNumber);t.targetMismatches.has(a)?u=u.withResumeToken(bi.EMPTY_BYTE_STRING,ei.min()).withLastLimboFreeSnapshotVersion(ei.min()):i.resumeToken.approximateByteSize()>0&&(u=u.withResumeToken(i.resumeToken,r)),s=s.insert(a,u),function(e,t,n){return 0===e.resumeToken.approximateByteSize()||(t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0)}(c,u,i)&&o.push(n.Cs.updateTargetData(e,u))}));let a=Ia(),c=ka();if(t.documentUpdates.forEach((r=>{t.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))})),o.push(function(e,t,n){let r=ka(),s=ka();return n.forEach((e=>r=r.add(e))),t.getEntries(e,r).next((e=>{let r=Ia();return n.forEach(((n,i)=>{const o=e.get(n);i.isFoundDocument()!==o.isFoundDocument()&&(s=s.add(n)),i.isNoDocument()&&i.version.isEqual(ei.min())?(t.removeEntry(n,i.readTime),r=r.insert(n,i)):!o.isValidDocument()||i.version.compareTo(o.version)>0||0===i.version.compareTo(o.version)&&o.hasPendingWrites?(t.addEntry(i),r=r.insert(n,i)):Rs("LocalStore","Ignoring outdated watch update for ",n,". Current version:",o.version," Watch version:",i.version)})),{Wi:r,zi:s}}))}(e,i,t.documentUpdates).next((e=>{a=e.Wi,c=e.zi}))),!r.isEqual(ei.min())){const t=n.Cs.getLastRemoteSnapshotVersion(e).next((t=>n.Cs.setTargetsMetadata(e,e.currentSequenceNumber,r)));o.push(t)}return li.waitFor(o).next((()=>i.apply(e))).next((()=>n.localDocuments.getLocalViewOfDocuments(e,a,c))).next((()=>a))})).then((e=>(n.qi=s,e)))}async function Fc(e,t,n){const r=Us(e),s=r.qi.get(t),i=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",i,(e=>r.persistence.referenceDelegate.removeTarget(e,s)))}catch(e){if(!di(e))throw e;Rs("LocalStore",`Failed to update sequence numbers for target ${t}: ${e}`)}r.qi=r.qi.remove(t),r.Ui.delete(s.target)}function Vc(e,t,n){const r=Us(e);let s=ei.min(),i=ka();return r.persistence.runTransaction("Execute query","readonly",(e=>function(e,t,n){const r=Us(e),s=r.Ui.get(n);return void 0!==s?li.resolve(r.qi.get(s)):r.Cs.getTargetData(t,n)}(r,e,Oo(t)).next((t=>{if(t)return s=t.lastLimboFreeSnapshotVersion,r.Cs.getMatchingKeysForTargetId(e,t.targetId).next((e=>{i=e}))})).next((()=>r.Li.getDocumentsMatchingQuery(e,t,n?s:ei.min(),n?i:ka()))).next((e=>(function(e,t,n){let r=e.Ki.get(t)||ei.min();n.forEach(((e,t)=>{t.readTime.compareTo(r)>0&&(r=t.readTime)})),e.Ki.set(t,r)}(r,function(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}(t),e),{documents:e,Hi:i})))))}class qc{constructor(){this.activeTargetIds=Da()}er(e){this.activeTargetIds=this.activeTargetIds.add(e)}nr(e){this.activeTargetIds=this.activeTargetIds.delete(e)}tr(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class jc{constructor(){this.Lr=new qc,this.qr={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e){return this.Lr.er(e),this.qr[e]||"not-current"}updateQueryState(e,t,n){this.qr[e]=t}removeLocalQueryTarget(e){this.Lr.nr(e)}isLocalQueryTarget(e){return this.Lr.activeTargetIds.has(e)}clearQueryState(e){delete this.qr[e]}getAllActiveQueryTargets(){return this.Lr.activeTargetIds}isActiveQueryTarget(e){return this.Lr.activeTargetIds.has(e)}start(){return this.Lr=new qc,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}
1344
1344
  /**
1345
1345
  * @license
1346
1346
  * Copyright 2019 Google LLC
@@ -1420,7 +1420,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1420
1420
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1421
1421
  * See the License for the specific language governing permissions and
1422
1422
  * limitations under the License.
1423
- */class Hc extends class{constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http";this.oo=t+"://"+e.host,this.uo="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}get co(){return!1}ao(e,t,n,r,s){const i=this.ho(e,t);Rs("RestConnection","Sending: ",i,n);const o={};return this.lo(o,r,s),this.fo(e,i,o,n).then((e=>(Rs("RestConnection","Received: ",e),e)),(t=>{throw Ls("RestConnection",`${e} failed with error: `,t,"url: ",i,"request:",n),t}))}_o(e,t,n,r,s,i){return this.ao(e,t,n,r,s)}lo(e,t,n){e["X-Goog-Api-Client"]="gl-js/ fire/"+As,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach(((t,n)=>e[n]=t)),n&&n.headers.forEach(((t,n)=>e[n]=t))}ho(e,t){const n=$c[e];return`${this.oo}/v1/${t}:${n}`}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams}fo(e,t,n,r){return new Promise(((s,i)=>{const o=new Ss;o.setWithCredentials(!0),o.listenOnce(ws.COMPLETE,(()=>{try{switch(o.getLastErrorCode()){case vs.NO_ERROR:const t=o.getResponseJson();Rs("Connection","XHR received:",JSON.stringify(t)),s(t);break;case vs.TIMEOUT:Rs("Connection",'RPC "'+e+'" timed out'),i(new Vs(Fs.DEADLINE_EXCEEDED,"Request time out"));break;case vs.HTTP_ERROR:const n=o.getStatus();if(Rs("Connection",'RPC "'+e+'" failed with status:',n,"response text:",o.getResponseText()),n>0){let e=o.getResponseJson();Array.isArray(e)&&(e=e[0]);const t=null==e?void 0:e.error;if(t&&t.status&&t.message){const e=function(e){const t=e.toLowerCase().replace(/_/g,"-");return Object.values(Fs).indexOf(t)>=0?t:Fs.UNKNOWN}(t.status);i(new Vs(e,t.message))}else i(new Vs(Fs.UNKNOWN,"Server responded with status "+o.getStatus()))}else i(new Vs(Fs.UNAVAILABLE,"Connection failed."));break;default:Ms()}}finally{Rs("Connection",'RPC "'+e+'" completed.')}}));const a=JSON.stringify(r);o.send(t,"POST",a,n,15)}))}wo(e,t,n){const r=[this.oo,"/","google.firestore.v1.Firestore","/",e,"/channel"],s=new fs,i=ln(),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 Es({})),this.lo(o.initMessageHeaders,t,n),o.encodeInitMessageHeaders=!0;const a=r.join("");Rs("Connection","Creating WebChannel: "+a,o);const c=s.createWebChannel(a,o);let u=!1,h=!1;const l=new Kc({Hr:e=>{h?Rs("Connection","Not sending because WebChannel is closed:",e):(u||(Rs("Connection","Opening WebChannel transport."),c.open(),u=!0),Rs("Connection","WebChannel sending:",e),c.send(e))},Jr:()=>c.close()}),d=(e,t,n)=>{e.listen(t,(e=>{try{n(e)}catch(e){setTimeout((()=>{throw e}),0)}}))};return d(c,_s.EventType.OPEN,(()=>{h||Rs("Connection","WebChannel transport opened.")})),d(c,_s.EventType.CLOSE,(()=>{h||(h=!0,Rs("Connection","WebChannel transport closed"),l.io())})),d(c,_s.EventType.ERROR,(e=>{h||(h=!0,Ls("Connection","WebChannel transport errored:",e),l.io(new Vs(Fs.UNAVAILABLE,"The operation could not be completed")))})),d(c,_s.EventType.MESSAGE,(e=>{var t;if(!h){const n=e.data[0];xs(!!n);const r=n,s=r.error||(null===(t=r[0])||void 0===t?void 0:t.error);if(s){Rs("Connection","WebChannel received error:",s);const e=s.status;let t=function(e){const t=ga[e];if(void 0!==t)return ya(t)}(e),n=s.message;void 0===t&&(t=Fs.INTERNAL,n="Unknown error status: "+e+" with message "+s.message),h=!0,l.io(new Vs(t,n)),c.close()}else Rs("Connection","WebChannel received:",n),l.ro(n)}})),d(i,Is.STAT_EVENT,(e=>{e.stat===bs?Rs("Connection","Detected buffering proxy"):e.stat===Ts&&Rs("Connection","Detected no buffering proxy")})),setTimeout((()=>{l.so()}),0),l}}function Gc(){return"undefined"!=typeof document?document:null}
1423
+ */class Hc extends class{constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http";this.oo=t+"://"+e.host,this.uo="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}get co(){return!1}ao(e,t,n,r,s){const i=this.ho(e,t);Rs("RestConnection","Sending: ",i,n);const o={};return this.lo(o,r,s),this.fo(e,i,o,n).then((e=>(Rs("RestConnection","Received: ",e),e)),(t=>{throw Ls("RestConnection",`${e} failed with error: `,t,"url: ",i,"request:",n),t}))}_o(e,t,n,r,s,i){return this.ao(e,t,n,r,s)}lo(e,t,n){e["X-Goog-Api-Client"]="gl-js/ fire/"+ks,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach(((t,n)=>e[n]=t)),n&&n.headers.forEach(((t,n)=>e[n]=t))}ho(e,t){const n=$c[e];return`${this.oo}/v1/${t}:${n}`}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams}fo(e,t,n,r){return new Promise(((s,i)=>{const o=new Ss;o.setWithCredentials(!0),o.listenOnce(ws.COMPLETE,(()=>{try{switch(o.getLastErrorCode()){case vs.NO_ERROR:const t=o.getResponseJson();Rs("Connection","XHR received:",JSON.stringify(t)),s(t);break;case vs.TIMEOUT:Rs("Connection",'RPC "'+e+'" timed out'),i(new Vs(Fs.DEADLINE_EXCEEDED,"Request time out"));break;case vs.HTTP_ERROR:const n=o.getStatus();if(Rs("Connection",'RPC "'+e+'" failed with status:',n,"response text:",o.getResponseText()),n>0){let e=o.getResponseJson();Array.isArray(e)&&(e=e[0]);const t=null==e?void 0:e.error;if(t&&t.status&&t.message){const e=function(e){const t=e.toLowerCase().replace(/_/g,"-");return Object.values(Fs).indexOf(t)>=0?t:Fs.UNKNOWN}(t.status);i(new Vs(e,t.message))}else i(new Vs(Fs.UNKNOWN,"Server responded with status "+o.getStatus()))}else i(new Vs(Fs.UNAVAILABLE,"Connection failed."));break;default:Ms()}}finally{Rs("Connection",'RPC "'+e+'" completed.')}}));const a=JSON.stringify(r);o.send(t,"POST",a,n,15)}))}wo(e,t,n){const r=[this.oo,"/","google.firestore.v1.Firestore","/",e,"/channel"],s=new fs,i=ln(),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 Es({})),this.lo(o.initMessageHeaders,t,n),o.encodeInitMessageHeaders=!0;const a=r.join("");Rs("Connection","Creating WebChannel: "+a,o);const c=s.createWebChannel(a,o);let u=!1,h=!1;const l=new Kc({Hr:e=>{h?Rs("Connection","Not sending because WebChannel is closed:",e):(u||(Rs("Connection","Opening WebChannel transport."),c.open(),u=!0),Rs("Connection","WebChannel sending:",e),c.send(e))},Jr:()=>c.close()}),d=(e,t,n)=>{e.listen(t,(e=>{try{n(e)}catch(e){setTimeout((()=>{throw e}),0)}}))};return d(c,_s.EventType.OPEN,(()=>{h||Rs("Connection","WebChannel transport opened.")})),d(c,_s.EventType.CLOSE,(()=>{h||(h=!0,Rs("Connection","WebChannel transport closed"),l.io())})),d(c,_s.EventType.ERROR,(e=>{h||(h=!0,Ls("Connection","WebChannel transport errored:",e),l.io(new Vs(Fs.UNAVAILABLE,"The operation could not be completed")))})),d(c,_s.EventType.MESSAGE,(e=>{var t;if(!h){const n=e.data[0];xs(!!n);const r=n,s=r.error||(null===(t=r[0])||void 0===t?void 0:t.error);if(s){Rs("Connection","WebChannel received error:",s);const e=s.status;let t=function(e){const t=ga[e];if(void 0!==t)return ya(t)}(e),n=s.message;void 0===t&&(t=Fs.INTERNAL,n="Unknown error status: "+e+" with message "+s.message),h=!0,l.io(new Vs(t,n)),c.close()}else Rs("Connection","WebChannel received:",n),l.ro(n)}})),d(i,Is.STAT_EVENT,(e=>{e.stat===bs?Rs("Connection","Detected buffering proxy"):e.stat===Ts&&Rs("Connection","Detected no buffering proxy")})),setTimeout((()=>{l.so()}),0),l}}function Gc(){return"undefined"!=typeof document?document:null}
1424
1424
  /**
1425
1425
  * @license
1426
1426
  * Copyright 2020 Google LLC
@@ -1564,7 +1564,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1564
1564
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1565
1565
  * See the License for the specific language governing permissions and
1566
1566
  * limitations under the License.
1567
- */class Tu{constructor(){this.Au=void 0,this.listeners=[]}}class Eu{constructor(){this.queries=new va((e=>xo(e)),Mo),this.onlineState="Unknown",this.Ru=new Set}}async function _u(e,t){const n=Us(e),r=t.query;let s=!1,i=n.queries.get(r);if(i||(s=!0,i=new Tu),s)try{i.Au=await n.onListen(r)}catch(e){const n=vu(e,`Initialization of query '${Uo(t.query)}' failed`);return void t.onError(n)}n.queries.set(r,i),i.listeners.push(t),t.bu(n.onlineState),i.Au&&t.Pu(i.Au)&&Au(n)}async function Su(e,t){const n=Us(e),r=t.query;let s=!1;const i=n.queries.get(r);if(i){const e=i.listeners.indexOf(t);e>=0&&(i.listeners.splice(e,1),s=0===i.listeners.length)}if(s)return n.queries.delete(r),n.onUnlisten(r)}function Cu(e,t){const n=Us(e);let r=!1;for(const e of t){const t=e.query,s=n.queries.get(t);if(s){for(const t of s.listeners)t.Pu(e)&&(r=!0);s.Au=e}}r&&Au(n)}function ku(e,t,n){const r=Us(e),s=r.queries.get(t);if(s)for(const e of s.listeners)e.onError(n);r.queries.delete(t)}function Au(e){e.Ru.forEach((e=>{e.next()}))}class Nu{constructor(e,t,n){this.query=e,this.vu=t,this.Vu=!1,this.Su=null,this.onlineState="Unknown",this.options=n||{}}Pu(e){if(!this.options.includeMetadataChanges){const t=[];for(const n of e.docChanges)3!==n.type&&t.push(n);e=new bu(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Vu?this.Du(e)&&(this.vu.next(e),t=!0):this.Cu(e,this.onlineState)&&(this.xu(e),t=!0),this.Su=e,t}onError(e){this.vu.error(e)}bu(e){this.onlineState=e;let t=!1;return this.Su&&!this.Vu&&this.Cu(this.Su,e)&&(this.xu(this.Su),t=!0),t}Cu(e,t){if(!e.fromCache)return!0;const n="Offline"!==t;return(!this.options.Nu||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}Du(e){if(e.docChanges.length>0)return!0;const t=this.Su&&this.Su.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}xu(e){e=bu.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Vu=!0,this.vu.next(e)}}
1567
+ */class Tu{constructor(){this.Au=void 0,this.listeners=[]}}class Eu{constructor(){this.queries=new va((e=>xo(e)),Mo),this.onlineState="Unknown",this.Ru=new Set}}async function _u(e,t){const n=Us(e),r=t.query;let s=!1,i=n.queries.get(r);if(i||(s=!0,i=new Tu),s)try{i.Au=await n.onListen(r)}catch(e){const n=vu(e,`Initialization of query '${Uo(t.query)}' failed`);return void t.onError(n)}n.queries.set(r,i),i.listeners.push(t),t.bu(n.onlineState),i.Au&&t.Pu(i.Au)&&ku(n)}async function Su(e,t){const n=Us(e),r=t.query;let s=!1;const i=n.queries.get(r);if(i){const e=i.listeners.indexOf(t);e>=0&&(i.listeners.splice(e,1),s=0===i.listeners.length)}if(s)return n.queries.delete(r),n.onUnlisten(r)}function Cu(e,t){const n=Us(e);let r=!1;for(const e of t){const t=e.query,s=n.queries.get(t);if(s){for(const t of s.listeners)t.Pu(e)&&(r=!0);s.Au=e}}r&&ku(n)}function Au(e,t,n){const r=Us(e),s=r.queries.get(t);if(s)for(const e of s.listeners)e.onError(n);r.queries.delete(t)}function ku(e){e.Ru.forEach((e=>{e.next()}))}class Nu{constructor(e,t,n){this.query=e,this.vu=t,this.Vu=!1,this.Su=null,this.onlineState="Unknown",this.options=n||{}}Pu(e){if(!this.options.includeMetadataChanges){const t=[];for(const n of e.docChanges)3!==n.type&&t.push(n);e=new bu(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Vu?this.Du(e)&&(this.vu.next(e),t=!0):this.Cu(e,this.onlineState)&&(this.xu(e),t=!0),this.Su=e,t}onError(e){this.vu.error(e)}bu(e){this.onlineState=e;let t=!1;return this.Su&&!this.Vu&&this.Cu(this.Su,e)&&(this.xu(this.Su),t=!0),t}Cu(e,t){if(!e.fromCache)return!0;const n="Offline"!==t;return(!this.options.Nu||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}Du(e){if(e.docChanges.length>0)return!0;const t=this.Su&&this.Su.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}xu(e){e=bu.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Vu=!0,this.vu.next(e)}}
1568
1568
  /**
1569
1569
  * @license
1570
1570
  * Copyright 2017 Google LLC
@@ -1580,7 +1580,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1580
1580
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1581
1581
  * See the License for the specific language governing permissions and
1582
1582
  * limitations under the License.
1583
- */class Du{constructor(e){this.key=e}}class Ru{constructor(e){this.key=e}}class Ou{constructor(e,t){this.query=e,this.qu=t,this.Uu=null,this.hasCachedResults=!1,this.current=!1,this.Ku=Aa(),this.mutatedKeys=Aa(),this.Gu=Vo(e),this.Qu=new wu(this.Gu)}get ju(){return this.qu}Wu(e,t){const n=t?t.zu:new Iu,r=t?t.Qu:this.Qu;let s=t?t.mutatedKeys:this.mutatedKeys,i=r,o=!1;const a="F"===this.query.limitType&&r.size===this.query.limit?r.last():null,c="L"===this.query.limitType&&r.size===this.query.limit?r.first():null;if(e.inorderTraversal(((e,t)=>{const u=r.get(e),h=Fo(this.query,t)?t:null,l=!!u&&this.mutatedKeys.has(u.key),d=!!h&&(h.hasLocalMutations||this.mutatedKeys.has(h.key)&&h.hasCommittedMutations);let f=!1;u&&h?u.data.isEqual(h.data)?l!==d&&(n.track({type:3,doc:h}),f=!0):this.Hu(u,h)||(n.track({type:2,doc:h}),f=!0,(a&&this.Gu(h,a)>0||c&&this.Gu(h,c)<0)&&(o=!0)):!u&&h?(n.track({type:0,doc:h}),f=!0):u&&!h&&(n.track({type:1,doc:u}),f=!0,(a||c)&&(o=!0)),f&&(h?(i=i.add(h),s=d?s.add(e):s.delete(e)):(i=i.delete(e),s=s.delete(e)))})),null!==this.query.limit)for(;i.size>this.query.limit;){const e="F"===this.query.limitType?i.last():i.first();i=i.delete(e.key),s=s.delete(e.key),n.track({type:1,doc:e})}return{Qu:i,zu:n,$i:o,mutatedKeys:s}}Hu(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n){const r=this.Qu;this.Qu=e.Qu,this.mutatedKeys=e.mutatedKeys;const s=e.zu.Eu();s.sort(((e,t)=>function(e,t){const n=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return Ms()}};return n(e)-n(t)}
1583
+ */class Du{constructor(e){this.key=e}}class Ru{constructor(e){this.key=e}}class Ou{constructor(e,t){this.query=e,this.qu=t,this.Uu=null,this.hasCachedResults=!1,this.current=!1,this.Ku=ka(),this.mutatedKeys=ka(),this.Gu=Vo(e),this.Qu=new wu(this.Gu)}get ju(){return this.qu}Wu(e,t){const n=t?t.zu:new Iu,r=t?t.Qu:this.Qu;let s=t?t.mutatedKeys:this.mutatedKeys,i=r,o=!1;const a="F"===this.query.limitType&&r.size===this.query.limit?r.last():null,c="L"===this.query.limitType&&r.size===this.query.limit?r.first():null;if(e.inorderTraversal(((e,t)=>{const u=r.get(e),h=Fo(this.query,t)?t:null,l=!!u&&this.mutatedKeys.has(u.key),d=!!h&&(h.hasLocalMutations||this.mutatedKeys.has(h.key)&&h.hasCommittedMutations);let f=!1;u&&h?u.data.isEqual(h.data)?l!==d&&(n.track({type:3,doc:h}),f=!0):this.Hu(u,h)||(n.track({type:2,doc:h}),f=!0,(a&&this.Gu(h,a)>0||c&&this.Gu(h,c)<0)&&(o=!0)):!u&&h?(n.track({type:0,doc:h}),f=!0):u&&!h&&(n.track({type:1,doc:u}),f=!0,(a||c)&&(o=!0)),f&&(h?(i=i.add(h),s=d?s.add(e):s.delete(e)):(i=i.delete(e),s=s.delete(e)))})),null!==this.query.limit)for(;i.size>this.query.limit;){const e="F"===this.query.limitType?i.last():i.first();i=i.delete(e.key),s=s.delete(e.key),n.track({type:1,doc:e})}return{Qu:i,zu:n,$i:o,mutatedKeys:s}}Hu(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n){const r=this.Qu;this.Qu=e.Qu,this.mutatedKeys=e.mutatedKeys;const s=e.zu.Eu();s.sort(((e,t)=>function(e,t){const n=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return Ms()}};return n(e)-n(t)}
1584
1584
  /**
1585
1585
  * @license
1586
1586
  * Copyright 2020 Google LLC
@@ -1596,7 +1596,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1596
1596
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1597
1597
  * See the License for the specific language governing permissions and
1598
1598
  * limitations under the License.
1599
- */(e.type,t.type)||this.Gu(e.doc,t.doc))),this.Ju(n);const i=t?this.Yu():[],o=0===this.Ku.size&&this.current?1:0,a=o!==this.Uu;return this.Uu=o,0!==s.length||a?{snapshot:new bu(this.query,e.Qu,r,s,e.mutatedKeys,0===o,a,!1,!!n&&n.resumeToken.approximateByteSize()>0),Xu:i}:{Xu:i}}bu(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({Qu:this.Qu,zu:new Iu,mutatedKeys:this.mutatedKeys,$i:!1},!1)):{Xu:[]}}Zu(e){return!this.qu.has(e)&&!!this.Qu.has(e)&&!this.Qu.get(e).hasLocalMutations}Ju(e){e&&(e.addedDocuments.forEach((e=>this.qu=this.qu.add(e))),e.modifiedDocuments.forEach((e=>{})),e.removedDocuments.forEach((e=>this.qu=this.qu.delete(e))),this.current=e.current)}Yu(){if(!this.current)return[];const e=this.Ku;this.Ku=Aa(),this.Qu.forEach((e=>{this.Zu(e.key)&&(this.Ku=this.Ku.add(e.key))}));const t=[];return e.forEach((e=>{this.Ku.has(e)||t.push(new Ru(e))})),this.Ku.forEach((n=>{e.has(n)||t.push(new Du(n))})),t}tc(e){this.qu=e.Hi,this.Ku=Aa();const t=this.Wu(e.documents);return this.applyChanges(t,!0)}ec(){return bu.fromInitialDocuments(this.query,this.Qu,this.mutatedKeys,0===this.Uu,this.hasCachedResults)}}class Lu{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class Pu{constructor(e){this.key=e,this.nc=!1}}class Mu{constructor(e,t,n,r,s,i){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=r,this.currentUser=s,this.maxConcurrentLimboResolutions=i,this.sc={},this.ic=new va((e=>xo(e)),Mo),this.rc=new Map,this.oc=new Set,this.uc=new lo(ii.comparator),this.cc=new Map,this.ac=new Ec,this.hc={},this.lc=new Map,this.fc=yc.vn(),this.onlineState="Unknown",this.dc=void 0}get isPrimaryClient(){return!0===this.dc}}async function xu(e,t){const n=function(e){const t=Us(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=Fu.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=Wu.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=qu.bind(null,t),t.sc.Wo=Cu.bind(null,t.eventManager),t.sc.wc=ku.bind(null,t.eventManager),t}(e);let r,s;const i=n.ic.get(t);if(i)r=i.targetId,n.sharedClientState.addLocalQueryTarget(r),s=i.view.ec();else{const e=await function(e,t){const n=Us(e);return n.persistence.runTransaction("Allocate target","readwrite",(e=>{let r;return n.Cs.getTargetData(e,t).next((s=>s?(r=s,li.resolve(r)):n.Cs.allocateTargetId(e).next((s=>(r=new dc(t,s,0,e.currentSequenceNumber),n.Cs.addTargetData(e,r).next((()=>r)))))))})).then((e=>{const r=n.qi.get(e.targetId);return(null===r||e.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.qi=n.qi.insert(e.targetId,e),n.Ui.set(t,e.targetId)),e}))}(n.localStore,Oo(t));n.isPrimaryClient&&ru(n.remoteStore,e);const i=n.sharedClientState.addLocalQueryTarget(e.targetId);r=e.targetId,s=await async function(e,t,n,r,s){e._c=(t,n,r)=>async function(e,t,n,r){let s=t.view.Wu(n);s.$i&&(s=await Vc(e.localStore,t.query,!1).then((({documents:e})=>t.view.Wu(e,s))));const i=r&&r.targetChanges.get(t.targetId),o=t.view.applyChanges(s,e.isPrimaryClient,i);return zu(e,t.targetId,o.Xu),o.snapshot}(e,t,n,r);const i=await Vc(e.localStore,t,!0),o=new Ou(t,i.Hi),a=o.Wu(i.documents),c=Oa.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==e.onlineState,s),u=o.applyChanges(a,e.isPrimaryClient,c);zu(e,n,u.Xu);const h=new Lu(t,n,o);return e.ic.set(t,h),e.rc.has(n)?e.rc.get(n).push(t):e.rc.set(n,[t]),u.snapshot}(n,t,r,"current"===i,e.resumeToken)}return s}async function Uu(e,t){const n=Us(e),r=n.ic.get(t),s=n.rc.get(r.targetId);if(s.length>1)return n.rc.set(r.targetId,s.filter((e=>!Mo(e,t)))),void n.ic.delete(t);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)||await Fc(n.localStore,r.targetId,!1).then((()=>{n.sharedClientState.clearQueryState(r.targetId),su(n.remoteStore,r.targetId),ju(n,r.targetId)})).catch(hi)):(ju(n,r.targetId),await Fc(n.localStore,r.targetId,!0))}async function Fu(e,t){const n=Us(e);try{const e=await Uc(n.localStore,t);t.targetChanges.forEach(((e,t)=>{const r=n.cc.get(t);r&&(xs(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1),e.addedDocuments.size>0?r.nc=!0:e.modifiedDocuments.size>0?xs(r.nc):e.removedDocuments.size>0&&(xs(r.nc),r.nc=!1))})),await Hu(n,e,t)}catch(e){await hi(e)}}function Vu(e,t,n){const r=Us(e);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){const e=[];r.ic.forEach(((n,r)=>{const s=r.view.bu(t);s.snapshot&&e.push(s.snapshot)})),function(e,t){const n=Us(e);n.onlineState=t;let r=!1;n.queries.forEach(((e,n)=>{for(const e of n.listeners)e.bu(t)&&(r=!0)})),r&&Au(n)}(r.eventManager,t),e.length&&r.sc.Wo(e),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function qu(e,t,n){const r=Us(e);r.sharedClientState.updateQueryState(t,"rejected",n);const s=r.cc.get(t),i=s&&s.key;if(i){let e=new lo(ii.comparator);e=e.insert(i,wo.newNoDocument(i,ei.min()));const n=Aa().add(i),s=new Ra(ei.min(),new Map,new go(Xs),e,n);await Fu(r,s),r.uc=r.uc.remove(i),r.cc.delete(t),Ku(r)}else await Fc(r.localStore,t,!1).then((()=>ju(r,t,n))).catch(hi)}function ju(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(const r of e.rc.get(t))e.ic.delete(r),n&&e.sc.wc(r,n);e.rc.delete(t),e.isPrimaryClient&&e.ac.ls(t).forEach((t=>{e.ac.containsKey(t)||Bu(e,t)}))}function Bu(e,t){e.oc.delete(t.path.canonicalString());const n=e.uc.get(t);null!==n&&(su(e.remoteStore,n),e.uc=e.uc.remove(t),e.cc.delete(n),Ku(e))}function zu(e,t,n){for(const r of n)r instanceof Du?(e.ac.addReference(r.key,t),$u(e,r)):r instanceof Ru?(Rs("SyncEngine","Document no longer in limbo: "+r.key),e.ac.removeReference(r.key,t),e.ac.containsKey(r.key)||Bu(e,r.key)):Ms()}function $u(e,t){const n=t.key,r=n.path.canonicalString();e.uc.get(n)||e.oc.has(r)||(Rs("SyncEngine","New document in limbo: "+n),e.oc.add(r),Ku(e))}function Ku(e){for(;e.oc.size>0&&e.uc.size<e.maxConcurrentLimboResolutions;){const t=e.oc.values().next().value;e.oc.delete(t);const n=new ii(ni.fromString(t)),r=e.fc.next();e.cc.set(r,new Pu(n)),e.uc=e.uc.insert(n,r),ru(e.remoteStore,new dc(Oo(Co(n.path)),r,2,fi.at))}}async function Hu(e,t,n){const r=Us(e),s=[],i=[],o=[];r.ic.isEmpty()||(r.ic.forEach(((e,a)=>{o.push(r._c(a,t,n).then((e=>{if((e||n)&&r.isPrimaryClient&&r.sharedClientState.updateQueryState(a.targetId,(null==e?void 0:e.fromCache)?"not-current":"current"),e){s.push(e);const t=Oc.Ci(a.targetId,e);i.push(t)}})))})),await Promise.all(o),r.sc.Wo(s),await async function(e,t){const n=Us(e);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(e=>li.forEach(t,(t=>li.forEach(t.Si,(r=>n.persistence.referenceDelegate.addReference(e,t.targetId,r))).next((()=>li.forEach(t.Di,(r=>n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))))))}catch(e){if(!di(e))throw e;Rs("LocalStore","Failed to update sequence numbers: "+e)}for(const e of t){const t=e.targetId;if(!e.fromCache){const e=n.qi.get(t),r=e.snapshotVersion,s=e.withLastLimboFreeSnapshotVersion(r);n.qi=n.qi.insert(t,s)}}}(r.localStore,i))}async function Gu(e,t){const n=Us(e);if(!n.currentUser.isEqual(t)){Rs("SyncEngine","User change. New user:",t.toKey());const e=await Mc(n.localStore,t);n.currentUser=t,function(e,t){e.lc.forEach((e=>{e.forEach((e=>{e.reject(new Vs(Fs.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),e.lc.clear()}(n),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await Hu(n,e.ji)}}function Wu(e,t){const n=Us(e),r=n.cc.get(t);if(r&&r.nc)return Aa().add(r.key);{let e=Aa();const r=n.rc.get(t);if(!r)return e;for(const t of r){const r=n.ic.get(t);e=e.unionWith(r.view.ju)}return e}}class Qu{constructor(){this.synchronizeTabs=!1}async initialize(e){this.yt=Wc(e.databaseInfo.databaseId),this.sharedClientState=this.gc(e),this.persistence=this.yc(e),await this.persistence.start(),this.localStore=this.Ic(e),this.gcScheduler=this.Tc(e,this.localStore),this.indexBackfillerScheduler=this.Ec(e,this.localStore)}Tc(e,t){return null}Ec(e,t){return null}Ic(e){return function(e,t,n,r){return new Pc(e,t,n,r)}(this.persistence,new Lc,e.initialUser,this.yt)}yc(e){return new Nc(Rc.Bs,this.yt)}gc(e){return new jc}async terminate(){this.gcScheduler&&this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class Yu{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=e=>Vu(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=Gu.bind(null,this.syncEngine),await async function(e,t){const n=Us(e);t?(n._u.delete(2),await tu(n)):t||(n._u.add(2),await nu(n),n.gu.set("Unknown"))}(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new Eu}createDatastore(e){const t=Wc(e.databaseInfo.databaseId),n=(r=e.databaseInfo,new Hc(r));var r;return function(e,t,n,r){return new Jc(e,t,n,r)}(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return t=this.localStore,n=this.datastore,r=e.asyncQueue,s=e=>Vu(this.syncEngine,e,0),i=zc.C()?new zc:new Bc,new eu(t,n,r,s,i);var t,n,r,s,i}createSyncEngine(e,t){return function(e,t,n,r,s,i,o){const a=new Mu(e,t,n,r,s,i);return o&&(a.dc=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}terminate(){return async function(e){const t=Us(e);Rs("RemoteStore","RemoteStore shutting down."),t._u.add(5),await nu(t),t.mu.shutdown(),t.gu.set("Unknown")}(this.remoteStore)}}
1599
+ */(e.type,t.type)||this.Gu(e.doc,t.doc))),this.Ju(n);const i=t?this.Yu():[],o=0===this.Ku.size&&this.current?1:0,a=o!==this.Uu;return this.Uu=o,0!==s.length||a?{snapshot:new bu(this.query,e.Qu,r,s,e.mutatedKeys,0===o,a,!1,!!n&&n.resumeToken.approximateByteSize()>0),Xu:i}:{Xu:i}}bu(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({Qu:this.Qu,zu:new Iu,mutatedKeys:this.mutatedKeys,$i:!1},!1)):{Xu:[]}}Zu(e){return!this.qu.has(e)&&!!this.Qu.has(e)&&!this.Qu.get(e).hasLocalMutations}Ju(e){e&&(e.addedDocuments.forEach((e=>this.qu=this.qu.add(e))),e.modifiedDocuments.forEach((e=>{})),e.removedDocuments.forEach((e=>this.qu=this.qu.delete(e))),this.current=e.current)}Yu(){if(!this.current)return[];const e=this.Ku;this.Ku=ka(),this.Qu.forEach((e=>{this.Zu(e.key)&&(this.Ku=this.Ku.add(e.key))}));const t=[];return e.forEach((e=>{this.Ku.has(e)||t.push(new Ru(e))})),this.Ku.forEach((n=>{e.has(n)||t.push(new Du(n))})),t}tc(e){this.qu=e.Hi,this.Ku=ka();const t=this.Wu(e.documents);return this.applyChanges(t,!0)}ec(){return bu.fromInitialDocuments(this.query,this.Qu,this.mutatedKeys,0===this.Uu,this.hasCachedResults)}}class Lu{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class Pu{constructor(e){this.key=e,this.nc=!1}}class Mu{constructor(e,t,n,r,s,i){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=r,this.currentUser=s,this.maxConcurrentLimboResolutions=i,this.sc={},this.ic=new va((e=>xo(e)),Mo),this.rc=new Map,this.oc=new Set,this.uc=new lo(ii.comparator),this.cc=new Map,this.ac=new Ec,this.hc={},this.lc=new Map,this.fc=yc.vn(),this.onlineState="Unknown",this.dc=void 0}get isPrimaryClient(){return!0===this.dc}}async function xu(e,t){const n=function(e){const t=Us(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=Fu.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=Wu.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=qu.bind(null,t),t.sc.Wo=Cu.bind(null,t.eventManager),t.sc.wc=Au.bind(null,t.eventManager),t}(e);let r,s;const i=n.ic.get(t);if(i)r=i.targetId,n.sharedClientState.addLocalQueryTarget(r),s=i.view.ec();else{const e=await function(e,t){const n=Us(e);return n.persistence.runTransaction("Allocate target","readwrite",(e=>{let r;return n.Cs.getTargetData(e,t).next((s=>s?(r=s,li.resolve(r)):n.Cs.allocateTargetId(e).next((s=>(r=new dc(t,s,0,e.currentSequenceNumber),n.Cs.addTargetData(e,r).next((()=>r)))))))})).then((e=>{const r=n.qi.get(e.targetId);return(null===r||e.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.qi=n.qi.insert(e.targetId,e),n.Ui.set(t,e.targetId)),e}))}(n.localStore,Oo(t));n.isPrimaryClient&&ru(n.remoteStore,e);const i=n.sharedClientState.addLocalQueryTarget(e.targetId);r=e.targetId,s=await async function(e,t,n,r,s){e._c=(t,n,r)=>async function(e,t,n,r){let s=t.view.Wu(n);s.$i&&(s=await Vc(e.localStore,t.query,!1).then((({documents:e})=>t.view.Wu(e,s))));const i=r&&r.targetChanges.get(t.targetId),o=t.view.applyChanges(s,e.isPrimaryClient,i);return zu(e,t.targetId,o.Xu),o.snapshot}(e,t,n,r);const i=await Vc(e.localStore,t,!0),o=new Ou(t,i.Hi),a=o.Wu(i.documents),c=Oa.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==e.onlineState,s),u=o.applyChanges(a,e.isPrimaryClient,c);zu(e,n,u.Xu);const h=new Lu(t,n,o);return e.ic.set(t,h),e.rc.has(n)?e.rc.get(n).push(t):e.rc.set(n,[t]),u.snapshot}(n,t,r,"current"===i,e.resumeToken)}return s}async function Uu(e,t){const n=Us(e),r=n.ic.get(t),s=n.rc.get(r.targetId);if(s.length>1)return n.rc.set(r.targetId,s.filter((e=>!Mo(e,t)))),void n.ic.delete(t);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)||await Fc(n.localStore,r.targetId,!1).then((()=>{n.sharedClientState.clearQueryState(r.targetId),su(n.remoteStore,r.targetId),ju(n,r.targetId)})).catch(hi)):(ju(n,r.targetId),await Fc(n.localStore,r.targetId,!0))}async function Fu(e,t){const n=Us(e);try{const e=await Uc(n.localStore,t);t.targetChanges.forEach(((e,t)=>{const r=n.cc.get(t);r&&(xs(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1),e.addedDocuments.size>0?r.nc=!0:e.modifiedDocuments.size>0?xs(r.nc):e.removedDocuments.size>0&&(xs(r.nc),r.nc=!1))})),await Hu(n,e,t)}catch(e){await hi(e)}}function Vu(e,t,n){const r=Us(e);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){const e=[];r.ic.forEach(((n,r)=>{const s=r.view.bu(t);s.snapshot&&e.push(s.snapshot)})),function(e,t){const n=Us(e);n.onlineState=t;let r=!1;n.queries.forEach(((e,n)=>{for(const e of n.listeners)e.bu(t)&&(r=!0)})),r&&ku(n)}(r.eventManager,t),e.length&&r.sc.Wo(e),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function qu(e,t,n){const r=Us(e);r.sharedClientState.updateQueryState(t,"rejected",n);const s=r.cc.get(t),i=s&&s.key;if(i){let e=new lo(ii.comparator);e=e.insert(i,wo.newNoDocument(i,ei.min()));const n=ka().add(i),s=new Ra(ei.min(),new Map,new go(Xs),e,n);await Fu(r,s),r.uc=r.uc.remove(i),r.cc.delete(t),Ku(r)}else await Fc(r.localStore,t,!1).then((()=>ju(r,t,n))).catch(hi)}function ju(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(const r of e.rc.get(t))e.ic.delete(r),n&&e.sc.wc(r,n);e.rc.delete(t),e.isPrimaryClient&&e.ac.ls(t).forEach((t=>{e.ac.containsKey(t)||Bu(e,t)}))}function Bu(e,t){e.oc.delete(t.path.canonicalString());const n=e.uc.get(t);null!==n&&(su(e.remoteStore,n),e.uc=e.uc.remove(t),e.cc.delete(n),Ku(e))}function zu(e,t,n){for(const r of n)r instanceof Du?(e.ac.addReference(r.key,t),$u(e,r)):r instanceof Ru?(Rs("SyncEngine","Document no longer in limbo: "+r.key),e.ac.removeReference(r.key,t),e.ac.containsKey(r.key)||Bu(e,r.key)):Ms()}function $u(e,t){const n=t.key,r=n.path.canonicalString();e.uc.get(n)||e.oc.has(r)||(Rs("SyncEngine","New document in limbo: "+n),e.oc.add(r),Ku(e))}function Ku(e){for(;e.oc.size>0&&e.uc.size<e.maxConcurrentLimboResolutions;){const t=e.oc.values().next().value;e.oc.delete(t);const n=new ii(ni.fromString(t)),r=e.fc.next();e.cc.set(r,new Pu(n)),e.uc=e.uc.insert(n,r),ru(e.remoteStore,new dc(Oo(Co(n.path)),r,2,fi.at))}}async function Hu(e,t,n){const r=Us(e),s=[],i=[],o=[];r.ic.isEmpty()||(r.ic.forEach(((e,a)=>{o.push(r._c(a,t,n).then((e=>{if((e||n)&&r.isPrimaryClient&&r.sharedClientState.updateQueryState(a.targetId,(null==e?void 0:e.fromCache)?"not-current":"current"),e){s.push(e);const t=Oc.Ci(a.targetId,e);i.push(t)}})))})),await Promise.all(o),r.sc.Wo(s),await async function(e,t){const n=Us(e);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(e=>li.forEach(t,(t=>li.forEach(t.Si,(r=>n.persistence.referenceDelegate.addReference(e,t.targetId,r))).next((()=>li.forEach(t.Di,(r=>n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))))))}catch(e){if(!di(e))throw e;Rs("LocalStore","Failed to update sequence numbers: "+e)}for(const e of t){const t=e.targetId;if(!e.fromCache){const e=n.qi.get(t),r=e.snapshotVersion,s=e.withLastLimboFreeSnapshotVersion(r);n.qi=n.qi.insert(t,s)}}}(r.localStore,i))}async function Gu(e,t){const n=Us(e);if(!n.currentUser.isEqual(t)){Rs("SyncEngine","User change. New user:",t.toKey());const e=await Mc(n.localStore,t);n.currentUser=t,function(e,t){e.lc.forEach((e=>{e.forEach((e=>{e.reject(new Vs(Fs.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),e.lc.clear()}(n),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await Hu(n,e.ji)}}function Wu(e,t){const n=Us(e),r=n.cc.get(t);if(r&&r.nc)return ka().add(r.key);{let e=ka();const r=n.rc.get(t);if(!r)return e;for(const t of r){const r=n.ic.get(t);e=e.unionWith(r.view.ju)}return e}}class Qu{constructor(){this.synchronizeTabs=!1}async initialize(e){this.yt=Wc(e.databaseInfo.databaseId),this.sharedClientState=this.gc(e),this.persistence=this.yc(e),await this.persistence.start(),this.localStore=this.Ic(e),this.gcScheduler=this.Tc(e,this.localStore),this.indexBackfillerScheduler=this.Ec(e,this.localStore)}Tc(e,t){return null}Ec(e,t){return null}Ic(e){return function(e,t,n,r){return new Pc(e,t,n,r)}(this.persistence,new Lc,e.initialUser,this.yt)}yc(e){return new Nc(Rc.Bs,this.yt)}gc(e){return new jc}async terminate(){this.gcScheduler&&this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class Yu{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=e=>Vu(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=Gu.bind(null,this.syncEngine),await async function(e,t){const n=Us(e);t?(n._u.delete(2),await tu(n)):t||(n._u.add(2),await nu(n),n.gu.set("Unknown"))}(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new Eu}createDatastore(e){const t=Wc(e.databaseInfo.databaseId),n=(r=e.databaseInfo,new Hc(r));var r;return function(e,t,n,r){return new Jc(e,t,n,r)}(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return t=this.localStore,n=this.datastore,r=e.asyncQueue,s=e=>Vu(this.syncEngine,e,0),i=zc.C()?new zc:new Bc,new eu(t,n,r,s,i);var t,n,r,s,i}createSyncEngine(e,t){return function(e,t,n,r,s,i,o){const a=new Mu(e,t,n,r,s,i);return o&&(a.dc=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}terminate(){return async function(e){const t=Us(e);Rs("RemoteStore","RemoteStore shutting down."),t._u.add(5),await nu(t),t.mu.shutdown(),t.gu.set("Unknown")}(this.remoteStore)}}
1600
1600
  /**
1601
1601
  * @license
1602
1602
  * Copyright 2017 Google LLC
@@ -1644,7 +1644,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1644
1644
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1645
1645
  * See the License for the specific language governing permissions and
1646
1646
  * limitations under the License.
1647
- */class sh{constructor(e,t,n,r){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=r,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new rh({}),this._settingsFrozen=!1}get app(){if(!this._app)throw new Vs(Fs.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return void 0!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new Vs(Fs.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 rh(e),void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new Bs;switch(e.type){case"gapi":const t=e.client;return new Hs(t,e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new Vs(Fs.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){const t=nh.get(e);t&&(Rs("ComponentProvider","Removing Datastore"),nh.delete(e),t.terminate())}(this),Promise.resolve()}}function ih(e,t,r,s={}){var i;const o=(e=th(e,sh))._getSettings();if("firestore.googleapis.com"!==o.host&&o.host!==t&&Ls("Host has been set in both settings() and useEmulator(), emulator host will be used"),e._setSettings(Object.assign(Object.assign({},o),{host:`${t}:${r}`,ssl:!1})),s.mockUserToken){let t,r;if("string"==typeof s.mockUserToken)t=s.mockUserToken,r=ks.MOCK_USER;else{t=function(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const r=t||"demo-project",s=e.iat||0,i=e.sub||e.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},e);return[n(JSON.stringify({alg:"none",type:"JWT"})),n(JSON.stringify(o)),""].join(".")}
1647
+ */class sh{constructor(e,t,n,r){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=r,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new rh({}),this._settingsFrozen=!1}get app(){if(!this._app)throw new Vs(Fs.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return void 0!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new Vs(Fs.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 rh(e),void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new Bs;switch(e.type){case"gapi":const t=e.client;return new Hs(t,e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new Vs(Fs.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){const t=nh.get(e);t&&(Rs("ComponentProvider","Removing Datastore"),nh.delete(e),t.terminate())}(this),Promise.resolve()}}function ih(e,t,r,s={}){var i;const o=(e=th(e,sh))._getSettings();if("firestore.googleapis.com"!==o.host&&o.host!==t&&Ls("Host has been set in both settings() and useEmulator(), emulator host will be used"),e._setSettings(Object.assign(Object.assign({},o),{host:`${t}:${r}`,ssl:!1})),s.mockUserToken){let t,r;if("string"==typeof s.mockUserToken)t=s.mockUserToken,r=As.MOCK_USER;else{t=function(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const r=t||"demo-project",s=e.iat||0,i=e.sub||e.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},e);return[n(JSON.stringify({alg:"none",type:"JWT"})),n(JSON.stringify(o)),""].join(".")}
1648
1648
  /**
1649
1649
  * @license
1650
1650
  * Copyright 2017 Google LLC
@@ -1660,7 +1660,7 @@ class va{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.inn
1660
1660
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1661
1661
  * See the License for the specific language governing permissions and
1662
1662
  * limitations under the License.
1663
- */(s.mockUserToken,null===(i=e._app)||void 0===i?void 0:i.options.projectId);const o=s.mockUserToken.sub||s.mockUserToken.user_id;if(!o)throw new Vs(Fs.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");r=new ks(o)}e._authCredentials=new zs(new js(t,r))}}
1663
+ */(s.mockUserToken,null===(i=e._app)||void 0===i?void 0:i.options.projectId);const o=s.mockUserToken.sub||s.mockUserToken.user_id;if(!o)throw new Vs(Fs.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");r=new As(o)}e._authCredentials=new zs(new js(t,r))}}
1664
1664
  /**
1665
1665
  * @license
1666
1666
  * Copyright 2020 Google LLC
@@ -1725,7 +1725,7 @@ class hh{constructor(e){this.observer=e,this.muted=!1}next(e){this.observer.next
1725
1725
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1726
1726
  * See the License for the specific language governing permissions and
1727
1727
  * limitations under the License.
1728
- */class lh{constructor(e,t,n,r){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=ks.UNAUTHENTICATED,this.clientId=Ys.R(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this.authCredentials.start(n,(async e=>{Rs("FirestoreClient","Received user=",e.uid),await this.authCredentialListener(e),this.user=e})),this.appCheckCredentials.start(n,(e=>(Rs("FirestoreClient","Received new app check token=",e),this.appCheckCredentialListener(e,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(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new Vs(Fs.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const e=new qs;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this.onlineComponents&&await this.onlineComponents.terminate(),this.offlineComponents&&await this.offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const n=vu(t,"Failed to shutdown persistence");e.reject(n)}})),e.promise}}async function dh(e,t){e.asyncQueue.verifyOperationInProgress();const n=await async function(e){return e.offlineComponents||(Rs("FirestoreClient","Using default OfflineComponentProvider"),await async function(e,t){e.asyncQueue.verifyOperationInProgress(),Rs("FirestoreClient","Initializing OfflineComponentProvider");const n=await e.getConfiguration();await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async e=>{r.isEqual(e)||(await Mc(t.localStore,e),r=e)})),t.persistence.setDatabaseDeletedListener((()=>e.terminate())),e.offlineComponents=t}(e,new Qu)),e.offlineComponents}(e);Rs("FirestoreClient","Initializing OnlineComponentProvider");const r=await e.getConfiguration();await t.initialize(n,r),e.setCredentialChangeListener((e=>gu(t.remoteStore,e))),e.setAppCheckTokenChangeListener(((e,n)=>gu(t.remoteStore,n))),e.onlineComponents=t}async function fh(e){const t=await async function(e){return e.onlineComponents||(Rs("FirestoreClient","Using default OnlineComponentProvider"),await dh(e,new Yu)),e.onlineComponents}(e),n=t.eventManager;return n.onListen=xu.bind(null,t.syncEngine),n.onUnlisten=Uu.bind(null,t.syncEngine),n}class ph{constructor(){this.Bc=Promise.resolve(),this.Lc=[],this.qc=!1,this.Uc=[],this.Kc=null,this.Gc=!1,this.Qc=!1,this.jc=[],this.xo=new Qc(this,"async_queue_retry"),this.Wc=()=>{const e=Gc();e&&Rs("AsyncQueue","Visibility state changed to "+e.visibilityState),this.xo.Po()};const e=Gc();e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.Wc)}get isShuttingDown(){return this.qc}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.zc(),this.Hc(e)}enterRestrictedMode(e){if(!this.qc){this.qc=!0,this.Qc=e||!1;const t=Gc();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.Wc)}}enqueue(e){if(this.zc(),this.qc)return new Promise((()=>{}));const t=new qs;return this.Hc((()=>this.qc&&this.Qc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.Lc.push(e),this.Jc())))}async Jc(){if(0!==this.Lc.length){try{await this.Lc[0](),this.Lc.shift(),this.xo.reset()}catch(e){if(!di(e))throw e;Rs("AsyncQueue","Operation failed with retryable error: "+e)}this.Lc.length>0&&this.xo.Ro((()=>this.Jc()))}}Hc(e){const t=this.Bc.then((()=>(this.Gc=!0,e().catch((e=>{this.Kc=e,this.Gc=!1;const t=function(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}
1728
+ */class lh{constructor(e,t,n,r){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=As.UNAUTHENTICATED,this.clientId=Ys.R(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this.authCredentials.start(n,(async e=>{Rs("FirestoreClient","Received user=",e.uid),await this.authCredentialListener(e),this.user=e})),this.appCheckCredentials.start(n,(e=>(Rs("FirestoreClient","Received new app check token=",e),this.appCheckCredentialListener(e,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(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new Vs(Fs.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const e=new qs;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this.onlineComponents&&await this.onlineComponents.terminate(),this.offlineComponents&&await this.offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const n=vu(t,"Failed to shutdown persistence");e.reject(n)}})),e.promise}}async function dh(e,t){e.asyncQueue.verifyOperationInProgress();const n=await async function(e){return e.offlineComponents||(Rs("FirestoreClient","Using default OfflineComponentProvider"),await async function(e,t){e.asyncQueue.verifyOperationInProgress(),Rs("FirestoreClient","Initializing OfflineComponentProvider");const n=await e.getConfiguration();await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async e=>{r.isEqual(e)||(await Mc(t.localStore,e),r=e)})),t.persistence.setDatabaseDeletedListener((()=>e.terminate())),e.offlineComponents=t}(e,new Qu)),e.offlineComponents}(e);Rs("FirestoreClient","Initializing OnlineComponentProvider");const r=await e.getConfiguration();await t.initialize(n,r),e.setCredentialChangeListener((e=>gu(t.remoteStore,e))),e.setAppCheckTokenChangeListener(((e,n)=>gu(t.remoteStore,n))),e.onlineComponents=t}async function fh(e){const t=await async function(e){return e.onlineComponents||(Rs("FirestoreClient","Using default OnlineComponentProvider"),await dh(e,new Yu)),e.onlineComponents}(e),n=t.eventManager;return n.onListen=xu.bind(null,t.syncEngine),n.onUnlisten=Uu.bind(null,t.syncEngine),n}class ph{constructor(){this.Bc=Promise.resolve(),this.Lc=[],this.qc=!1,this.Uc=[],this.Kc=null,this.Gc=!1,this.Qc=!1,this.jc=[],this.xo=new Qc(this,"async_queue_retry"),this.Wc=()=>{const e=Gc();e&&Rs("AsyncQueue","Visibility state changed to "+e.visibilityState),this.xo.Po()};const e=Gc();e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.Wc)}get isShuttingDown(){return this.qc}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.zc(),this.Hc(e)}enterRestrictedMode(e){if(!this.qc){this.qc=!0,this.Qc=e||!1;const t=Gc();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.Wc)}}enqueue(e){if(this.zc(),this.qc)return new Promise((()=>{}));const t=new qs;return this.Hc((()=>this.qc&&this.Qc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.Lc.push(e),this.Jc())))}async Jc(){if(0!==this.Lc.length){try{await this.Lc[0](),this.Lc.shift(),this.xo.reset()}catch(e){if(!di(e))throw e;Rs("AsyncQueue","Operation failed with retryable error: "+e)}this.Lc.length>0&&this.xo.Ro((()=>this.Jc()))}}Hc(e){const t=this.Bc.then((()=>(this.Gc=!0,e().catch((e=>{this.Kc=e,this.Gc=!1;const t=function(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}
1729
1729
  /**
1730
1730
  * @license
1731
1731
  * Copyright 2017 Google LLC
@@ -1869,7 +1869,7 @@ class hh{constructor(e){this.observer=e,this.muted=!1}next(e){this.observer.next
1869
1869
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1870
1870
  * See the License for the specific language governing permissions and
1871
1871
  * limitations under the License.
1872
- */const Sh=/^__.*__$/;function Ch(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw Ms()}}class kh{constructor(e,t,n,r,s,i){this.settings=e,this.databaseId=t,this.yt=n,this.ignoreUndefinedProperties=r,void 0===s&&this.na(),this.fieldTransforms=s||[],this.fieldMask=i||[]}get path(){return this.settings.path}get sa(){return this.settings.sa}ia(e){return new kh(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.yt,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}ra(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.ia({path:n,oa:!1});return r.ua(e),r}ca(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.ia({path:n,oa:!1});return r.na(),r}aa(e){return this.ia({path:void 0,oa:!0})}ha(e){return Oh(e,this.settings.methodName,this.settings.la||!1,this.path,this.settings.fa)}contains(e){return void 0!==this.fieldMask.find((t=>e.isPrefixOf(t)))||void 0!==this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))}na(){if(this.path)for(let e=0;e<this.path.length;e++)this.ua(this.path.get(e))}ua(e){if(0===e.length)throw this.ha("Document fields must not be empty");if(Ch(this.sa)&&Sh.test(e))throw this.ha('Document fields cannot begin and end with "__"')}}class Ah{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.yt=n||Wc(e)}da(e,t,n,r=!1){return new kh({sa:e,methodName:t,fa:n,path:si.emptyPath(),oa:!1,la:r},this.databaseId,this.yt,this.ignoreUndefinedProperties)}}function Nh(e,t){if(Dh(e=I(e)))return function(e,t,n){if(!Dh(n)||!function(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}(n)){const r=eh(n);throw"an object"===r?t.ha(e+" a custom object"):t.ha(e+" "+r)}}("Unsupported field value:",t,e),function(e,t){const n={};return vi(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):yi(e,((e,r)=>{const s=Nh(r,t.ra(e));null!=s&&(n[e]=s)})),{mapValue:{fields:n}}}(e,t);if(e instanceof Eh)return function(e,t){if(!Ch(t.sa))throw t.ha(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.ha(`${e._methodName}() is not currently supported inside arrays`);const n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.oa&&4!==t.sa)throw t.ha("Nested arrays are not supported");return function(e,t){const n=[];let r=0;for(const s of e){let e=Nh(s,t.aa(r));null==e&&(e={nullValue:"NULL_VALUE"}),n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if(null===(e=I(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return zo(t.yt,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){const n=Zs.fromDate(e);return{timestampValue:$a(t.yt,n)}}if(e instanceof Zs){const n=new Zs(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:$a(t.yt,n)}}if(e instanceof _h)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof Ih)return{bytesValue:Ka(t.yt,e._byteString)};if(e instanceof oh){const n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.ha(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:Ga(e.firestore._databaseId||t.databaseId,e._key.path)}}throw t.ha(`Unsupported field value: ${eh(e)}`)}(e,t)}function Dh(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof Zs||e instanceof _h||e instanceof Ih||e instanceof oh||e instanceof Eh)}const Rh=new RegExp("[~\\*/\\[\\]]");function Oh(e,t,n,r,s){const i=r&&!r.isEmpty(),o=void 0!==s;let a=`Function ${t}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let c="";return(i||o)&&(c+=" (found",i&&(c+=` in field ${r}`),o&&(c+=` in document ${s}`),c+=")"),new Vs(Fs.INVALID_ARGUMENT,a+e+c)
1872
+ */const Sh=/^__.*__$/;function Ch(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw Ms()}}class Ah{constructor(e,t,n,r,s,i){this.settings=e,this.databaseId=t,this.yt=n,this.ignoreUndefinedProperties=r,void 0===s&&this.na(),this.fieldTransforms=s||[],this.fieldMask=i||[]}get path(){return this.settings.path}get sa(){return this.settings.sa}ia(e){return new Ah(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.yt,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}ra(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.ia({path:n,oa:!1});return r.ua(e),r}ca(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.ia({path:n,oa:!1});return r.na(),r}aa(e){return this.ia({path:void 0,oa:!0})}ha(e){return Oh(e,this.settings.methodName,this.settings.la||!1,this.path,this.settings.fa)}contains(e){return void 0!==this.fieldMask.find((t=>e.isPrefixOf(t)))||void 0!==this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))}na(){if(this.path)for(let e=0;e<this.path.length;e++)this.ua(this.path.get(e))}ua(e){if(0===e.length)throw this.ha("Document fields must not be empty");if(Ch(this.sa)&&Sh.test(e))throw this.ha('Document fields cannot begin and end with "__"')}}class kh{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.yt=n||Wc(e)}da(e,t,n,r=!1){return new Ah({sa:e,methodName:t,fa:n,path:si.emptyPath(),oa:!1,la:r},this.databaseId,this.yt,this.ignoreUndefinedProperties)}}function Nh(e,t){if(Dh(e=I(e)))return function(e,t,n){if(!Dh(n)||!function(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}(n)){const r=eh(n);throw"an object"===r?t.ha(e+" a custom object"):t.ha(e+" "+r)}}("Unsupported field value:",t,e),function(e,t){const n={};return vi(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):yi(e,((e,r)=>{const s=Nh(r,t.ra(e));null!=s&&(n[e]=s)})),{mapValue:{fields:n}}}(e,t);if(e instanceof Eh)return function(e,t){if(!Ch(t.sa))throw t.ha(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.ha(`${e._methodName}() is not currently supported inside arrays`);const n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.oa&&4!==t.sa)throw t.ha("Nested arrays are not supported");return function(e,t){const n=[];let r=0;for(const s of e){let e=Nh(s,t.aa(r));null==e&&(e={nullValue:"NULL_VALUE"}),n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if(null===(e=I(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return zo(t.yt,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){const n=Zs.fromDate(e);return{timestampValue:$a(t.yt,n)}}if(e instanceof Zs){const n=new Zs(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:$a(t.yt,n)}}if(e instanceof _h)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof Ih)return{bytesValue:Ka(t.yt,e._byteString)};if(e instanceof oh){const n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.ha(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:Ga(e.firestore._databaseId||t.databaseId,e._key.path)}}throw t.ha(`Unsupported field value: ${eh(e)}`)}(e,t)}function Dh(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof Zs||e instanceof _h||e instanceof Ih||e instanceof oh||e instanceof Eh)}const Rh=new RegExp("[~\\*/\\[\\]]");function Oh(e,t,n,r,s){const i=r&&!r.isEmpty(),o=void 0!==s;let a=`Function ${t}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let c="";return(i||o)&&(c+=" (found",i&&(c+=` in field ${r}`),o&&(c+=` in document ${s}`),c+=")"),new Vs(Fs.INVALID_ARGUMENT,a+e+c)
1873
1873
  /**
1874
1874
  * @license
1875
1875
  * Copyright 2020 Google LLC
@@ -1917,7 +1917,7 @@ class hh{constructor(e){this.observer=e,this.muted=!1}next(e){this.observer.next
1917
1917
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1918
1918
  * See the License for the specific language governing permissions and
1919
1919
  * limitations under the License.
1920
- */(r);for(const t of r)e=t._apply(e);return e}class qh extends Fh{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type="where"}static _create(e,t,n){return new qh(e,t,n)}_apply(e){const t=this._parse(e);return Kh(e._query,t),new ah(e.firestore,e.converter,Lo(e._query,t))}_parse(e){const t=function(e){const t=e._freezeSettings(),n=Wc(e._databaseId);return new Ah(e._databaseId,!!t.ignoreUndefinedProperties,n)}(e.firestore),n=function(e,t,n,r,s,i,o){let a;if(s.isKeyField()){if("array-contains"===i||"array-contains-any"===i)throw new Vs(Fs.INVALID_ARGUMENT,`Invalid Query. You can't perform '${i}' queries on documentId().`);if("in"===i||"not-in"===i){$h(o,i);const t=[];for(const n of o)t.push(zh(r,e,n));a={arrayValue:{values:t}}}else a=zh(r,e,o)}else"in"!==i&&"not-in"!==i&&"array-contains-any"!==i||$h(o,i),a=function(e,t,n,r=!1){return Nh(n,e.da(r?4:3,t))}(n,"where",o,"in"===i||"not-in"===i);return Wi.create(s,i,a)}(e._query,0,t,e.firestore._databaseId,this._field,this._op,this._value);return n}}function jh(e,t,n){const r=t,s=Mh("where",e);return qh._create(s,r,n)}class Bh extends Uh{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new Bh(e,t)}_parse(e){const t=this._queryConstraints.map((t=>t._parse(e))).filter((e=>e.getFilters().length>0));return 1===t.length?t[0]:Qi.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return 0===t.getFilters().length?e:(function(e,t){let n=e;const r=t.getFlattenedFilters();for(const e of r)Kh(n,e),n=Lo(n,e)}(e._query,t),new ah(e.firestore,e.converter,Lo(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}function zh(e,t,n){if("string"==typeof(n=I(n))){if(""===n)throw new Vs(Fs.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Do(t)&&-1!==n.indexOf("/"))throw new Vs(Fs.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=t.path.child(ni.fromString(n));if(!ii.isDocumentKey(r))throw new Vs(Fs.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return Ui(e,new ii(r))}if(n instanceof oh)return Ui(e,n._key);throw new Vs(Fs.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${eh(n)}.`)}function $h(e,t){if(!Array.isArray(e)||0===e.length)throw new Vs(Fs.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`);if(e.length>10)throw new Vs(Fs.INVALID_ARGUMENT,`Invalid Query. '${t.toString()}' filters support a maximum of 10 elements in the value array.`)}function Kh(e,t){if(t.isInequality()){const n=No(e),r=t.field;if(null!==n&&!n.isEqual(r))throw new Vs(Fs.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 '${r.toString()}'`);const s=Ao(e);null!==s&&function(e,t,n){if(!n.isEqual(t))throw new Vs(Fs.INVALID_ARGUMENT,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${t.toString()}' and so you must also use '${t.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}(0,r,s)}const n=function(e,t){for(const n of e)for(const e of n.getFlattenedFilters())if(t.indexOf(e.op)>=0)return e.op;return null}(e.filters,function(e){switch(e){case"!=":return["!=","not-in"];case"array-contains":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[]}}(t.op));if(null!==n)throw n===t.op?new Vs(Fs.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new Vs(Fs.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}class Hh{convertValue(e,t="none"){switch(Di(e)){case 0:return null;case 1:return e.booleanValue;case 2:return _i(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Si(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 10:return this.convertObject(e.mapValue,t);default:throw Ms()}}convertObject(e,t){const n={};return yi(e.fields,((e,r)=>{n[e]=this.convertValue(r,t)})),n}convertGeoPoint(e){return new _h(_i(e.latitude),_i(e.longitude))}convertArray(e,t){return(e.values||[]).map((e=>this.convertValue(e,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const n=ki(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(Ai(e));default:return null}}convertTimestamp(e){const t=Ei(e);return new Zs(t.seconds,t.nanos)}convertDocumentKey(e,t){const n=ni.fromString(e);xs(uc(n));const r=new gi(n.get(1),n.get(3)),s=new ii(n.popFirst(5));return r.isEqual(t)||Os(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),s}}
1920
+ */(r);for(const t of r)e=t._apply(e);return e}class qh extends Fh{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type="where"}static _create(e,t,n){return new qh(e,t,n)}_apply(e){const t=this._parse(e);return Kh(e._query,t),new ah(e.firestore,e.converter,Lo(e._query,t))}_parse(e){const t=function(e){const t=e._freezeSettings(),n=Wc(e._databaseId);return new kh(e._databaseId,!!t.ignoreUndefinedProperties,n)}(e.firestore),n=function(e,t,n,r,s,i,o){let a;if(s.isKeyField()){if("array-contains"===i||"array-contains-any"===i)throw new Vs(Fs.INVALID_ARGUMENT,`Invalid Query. You can't perform '${i}' queries on documentId().`);if("in"===i||"not-in"===i){$h(o,i);const t=[];for(const n of o)t.push(zh(r,e,n));a={arrayValue:{values:t}}}else a=zh(r,e,o)}else"in"!==i&&"not-in"!==i&&"array-contains-any"!==i||$h(o,i),a=function(e,t,n,r=!1){return Nh(n,e.da(r?4:3,t))}(n,"where",o,"in"===i||"not-in"===i);return Wi.create(s,i,a)}(e._query,0,t,e.firestore._databaseId,this._field,this._op,this._value);return n}}function jh(e,t,n){const r=t,s=Mh("where",e);return qh._create(s,r,n)}class Bh extends Uh{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new Bh(e,t)}_parse(e){const t=this._queryConstraints.map((t=>t._parse(e))).filter((e=>e.getFilters().length>0));return 1===t.length?t[0]:Qi.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return 0===t.getFilters().length?e:(function(e,t){let n=e;const r=t.getFlattenedFilters();for(const e of r)Kh(n,e),n=Lo(n,e)}(e._query,t),new ah(e.firestore,e.converter,Lo(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}function zh(e,t,n){if("string"==typeof(n=I(n))){if(""===n)throw new Vs(Fs.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Do(t)&&-1!==n.indexOf("/"))throw new Vs(Fs.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=t.path.child(ni.fromString(n));if(!ii.isDocumentKey(r))throw new Vs(Fs.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return Ui(e,new ii(r))}if(n instanceof oh)return Ui(e,n._key);throw new Vs(Fs.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${eh(n)}.`)}function $h(e,t){if(!Array.isArray(e)||0===e.length)throw new Vs(Fs.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`);if(e.length>10)throw new Vs(Fs.INVALID_ARGUMENT,`Invalid Query. '${t.toString()}' filters support a maximum of 10 elements in the value array.`)}function Kh(e,t){if(t.isInequality()){const n=No(e),r=t.field;if(null!==n&&!n.isEqual(r))throw new Vs(Fs.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 '${r.toString()}'`);const s=ko(e);null!==s&&function(e,t,n){if(!n.isEqual(t))throw new Vs(Fs.INVALID_ARGUMENT,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${t.toString()}' and so you must also use '${t.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}(0,r,s)}const n=function(e,t){for(const n of e)for(const e of n.getFlattenedFilters())if(t.indexOf(e.op)>=0)return e.op;return null}(e.filters,function(e){switch(e){case"!=":return["!=","not-in"];case"array-contains":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[]}}(t.op));if(null!==n)throw n===t.op?new Vs(Fs.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new Vs(Fs.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}class Hh{convertValue(e,t="none"){switch(Di(e)){case 0:return null;case 1:return e.booleanValue;case 2:return _i(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Si(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 10:return this.convertObject(e.mapValue,t);default:throw Ms()}}convertObject(e,t){const n={};return yi(e.fields,((e,r)=>{n[e]=this.convertValue(r,t)})),n}convertGeoPoint(e){return new _h(_i(e.latitude),_i(e.longitude))}convertArray(e,t){return(e.values||[]).map((e=>this.convertValue(e,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const n=Ai(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(ki(e));default:return null}}convertTimestamp(e){const t=Ei(e);return new Zs(t.seconds,t.nanos)}convertDocumentKey(e,t){const n=ni.fromString(e);xs(uc(n));const r=new gi(n.get(1),n.get(3)),s=new ii(n.popFirst(5));return r.isEqual(t)||Os(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),s}}
1921
1921
  /**
1922
1922
  * @license
1923
1923
  * Copyright 2020 Google LLC
@@ -1949,7 +1949,7 @@ class hh{constructor(e){this.observer=e,this.muted=!1}next(e){this.observer.next
1949
1949
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1950
1950
  * See the License for the specific language governing permissions and
1951
1951
  * limitations under the License.
1952
- */function Jh(e){e=th(e,oh);const t=th(e.firestore,mh);return function(e,t,n={}){const r=new qs;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,s){const i=new hh({next:i=>{t.enqueueAndForget((()=>Su(e,o)));const a=i.docs.has(n);!a&&i.fromCache?s.reject(new Vs(Fs.UNAVAILABLE,"Failed to get document because the client is offline.")):a&&i.fromCache&&r&&"server"===r.source?s.reject(new Vs(Fs.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.)')):s.resolve(i)},error:e=>s.reject(e)}),o=new Nu(Co(n.path),i,{includeMetadataChanges:!0,Nu:!0});return _u(e,o)}(await fh(e),e.asyncQueue,t,n,r))),r.promise}(vh(t),e._key).then((n=>nl(t,e,n)))}class Zh extends Hh{constructor(e){super(),this.firestore=e}convertBytes(e){return new Ih(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new oh(this.firestore,null,t)}}function el(e){e=th(e,ah);const t=th(e.firestore,mh),n=vh(t),r=new Zh(t);return xh(e._query),function(e,t,n={}){const r=new qs;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,s){const i=new hh({next:n=>{t.enqueueAndForget((()=>Su(e,o))),n.fromCache&&"server"===r.source?s.reject(new Vs(Fs.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.)')):s.resolve(n)},error:e=>s.reject(e)}),o=new Nu(n,i,{includeMetadataChanges:!0,Nu:!0});return _u(e,o)}(await fh(e),e.asyncQueue,t,n,r))),r.promise}(n,e._query).then((n=>new Yh(t,r,e,n)))}function tl(e,...t){var n,r,s;e=I(e);let i={includeMetadataChanges:!1},o=0;"object"!=typeof t[o]||gh(t[o])||(i=t[o],o++);const a={includeMetadataChanges:i.includeMetadataChanges};if(gh(t[o])){const e=t[o];t[o]=null===(n=e.next)||void 0===n?void 0:n.bind(e),t[o+1]=null===(r=e.error)||void 0===r?void 0:r.bind(e),t[o+2]=null===(s=e.complete)||void 0===s?void 0:s.bind(e)}let c,u,h;if(e instanceof oh)u=th(e.firestore,mh),h=Co(e._key.path),c={next:n=>{t[o]&&t[o](nl(u,e,n))},error:t[o+1],complete:t[o+2]};else{const n=th(e,ah);u=th(n.firestore,mh),h=n._query;const r=new Zh(u);c={next:e=>{t[o]&&t[o](new Yh(u,r,n,e))},error:t[o+1],complete:t[o+2]},xh(e._query)}return function(e,t,n,r){const s=new hh(r),i=new Nu(t,s,n);return e.asyncQueue.enqueueAndForget((async()=>_u(await fh(e),i))),()=>{s.bc(),e.asyncQueue.enqueueAndForget((async()=>Su(await fh(e),i)))}}(vh(u),h,a,c)}function nl(e,t,n){const r=n.docs.get(t._key),s=new Zh(e);return new Wh(e,s,t._key,r,new Gh(n.hasPendingWrites,n.fromCache),t.converter)}!function(e,t=!0){As=oe,ne(new b("firestore",((e,{instanceIdentifier:n,options:r})=>{const s=e.getProvider("app").getImmediate(),i=new mh(new $s(e.getProvider("auth-internal")),new Ws(e.getProvider("app-check-internal")),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new Vs(Fs.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new gi(e.options.projectId,t)}(s,n),s);return r=Object.assign({useFetchStreams:t},r),i._setSettings(r),i}),"PUBLIC").setMultipleInstances(!0)),ue(Cs,"3.8.0",e),ue(Cs,"3.8.0","esm2017")}();
1952
+ */function Jh(e){e=th(e,oh);const t=th(e.firestore,mh);return function(e,t,n={}){const r=new qs;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,s){const i=new hh({next:i=>{t.enqueueAndForget((()=>Su(e,o)));const a=i.docs.has(n);!a&&i.fromCache?s.reject(new Vs(Fs.UNAVAILABLE,"Failed to get document because the client is offline.")):a&&i.fromCache&&r&&"server"===r.source?s.reject(new Vs(Fs.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.)')):s.resolve(i)},error:e=>s.reject(e)}),o=new Nu(Co(n.path),i,{includeMetadataChanges:!0,Nu:!0});return _u(e,o)}(await fh(e),e.asyncQueue,t,n,r))),r.promise}(vh(t),e._key).then((n=>nl(t,e,n)))}class Zh extends Hh{constructor(e){super(),this.firestore=e}convertBytes(e){return new Ih(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new oh(this.firestore,null,t)}}function el(e){e=th(e,ah);const t=th(e.firestore,mh),n=vh(t),r=new Zh(t);return xh(e._query),function(e,t,n={}){const r=new qs;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,s){const i=new hh({next:n=>{t.enqueueAndForget((()=>Su(e,o))),n.fromCache&&"server"===r.source?s.reject(new Vs(Fs.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.)')):s.resolve(n)},error:e=>s.reject(e)}),o=new Nu(n,i,{includeMetadataChanges:!0,Nu:!0});return _u(e,o)}(await fh(e),e.asyncQueue,t,n,r))),r.promise}(n,e._query).then((n=>new Yh(t,r,e,n)))}function tl(e,...t){var n,r,s;e=I(e);let i={includeMetadataChanges:!1},o=0;"object"!=typeof t[o]||gh(t[o])||(i=t[o],o++);const a={includeMetadataChanges:i.includeMetadataChanges};if(gh(t[o])){const e=t[o];t[o]=null===(n=e.next)||void 0===n?void 0:n.bind(e),t[o+1]=null===(r=e.error)||void 0===r?void 0:r.bind(e),t[o+2]=null===(s=e.complete)||void 0===s?void 0:s.bind(e)}let c,u,h;if(e instanceof oh)u=th(e.firestore,mh),h=Co(e._key.path),c={next:n=>{t[o]&&t[o](nl(u,e,n))},error:t[o+1],complete:t[o+2]};else{const n=th(e,ah);u=th(n.firestore,mh),h=n._query;const r=new Zh(u);c={next:e=>{t[o]&&t[o](new Yh(u,r,n,e))},error:t[o+1],complete:t[o+2]},xh(e._query)}return function(e,t,n,r){const s=new hh(r),i=new Nu(t,s,n);return e.asyncQueue.enqueueAndForget((async()=>_u(await fh(e),i))),()=>{s.bc(),e.asyncQueue.enqueueAndForget((async()=>Su(await fh(e),i)))}}(vh(u),h,a,c)}function nl(e,t,n){const r=n.docs.get(t._key),s=new Zh(e);return new Wh(e,s,t._key,r,new Gh(n.hasPendingWrites,n.fromCache),t.converter)}!function(e,t=!0){ks=oe,ne(new b("firestore",((e,{instanceIdentifier:n,options:r})=>{const s=e.getProvider("app").getImmediate(),i=new mh(new $s(e.getProvider("auth-internal")),new Ws(e.getProvider("app-check-internal")),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new Vs(Fs.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new gi(e.options.projectId,t)}(s,n),s);return r=Object.assign({useFetchStreams:t},r),i._setSettings(r),i}),"PUBLIC").setMultipleInstances(!0)),ue(Cs,"3.8.0",e),ue(Cs,"3.8.0","esm2017")}();
1953
1953
  /**
1954
1954
  * @license
1955
1955
  * Copyright 2020 Google LLC
@@ -2112,7 +2112,7 @@ class _l{constructor(e,t){this.shortDelay=e,this.longDelay=t,vl(t>e,"Short delay
2112
2112
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2113
2113
  * See the License for the specific language governing permissions and
2114
2114
  * limitations under the License.
2115
- */const kl={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"internal-error",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error"},Al=new _l(3e4,6e4);
2115
+ */const Al={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"internal-error",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error"},kl=new _l(3e4,6e4);
2116
2116
  /**
2117
2117
  * @license
2118
2118
  * Copyright 2020 Google LLC
@@ -2128,7 +2128,7 @@ class _l{constructor(e,t){this.shortDelay=e,this.longDelay=t,vl(t>e,"Short delay
2128
2128
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2129
2129
  * See the License for the specific language governing permissions and
2130
2130
  * limitations under the License.
2131
- */function Nl(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function Dl(e,t,n,r,s={}){return Rl(e,s,(async()=>{let s={},i={};r&&("GET"===t?i=r:s={body:JSON.stringify(r)});const o=g(Object.assign({key:e.config.apiKey},i)).slice(1),a=await e._getAdditionalHeaders();return a["Content-Type"]="application/json",e.languageCode&&(a["X-Firebase-Locale"]=e.languageCode),Cl.fetch()(Ll(e,e.config.apiHost,n,o),Object.assign({method:t,headers:a,referrerPolicy:"no-referrer"},s))}))}async function Rl(e,t,n){e._canInitEmulator=!1;const r=Object.assign(Object.assign({},kl),t);try{const t=new Pl(e),s=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();const i=await s.json();if("needConfirmation"in i)throw Ml(e,"account-exists-with-different-credential",i);if(s.ok&&!("errorMessage"in i))return i;{const t=s.ok?i.errorMessage:i.error.message,[n,o]=t.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw Ml(e,"credential-already-in-use",i);if("EMAIL_EXISTS"===n)throw Ml(e,"email-already-in-use",i);if("USER_DISABLED"===n)throw Ml(e,"user-disabled",i);const a=r[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(o)throw function(e,t,n){const r=Object.assign(Object.assign({},cl()),{[t]:n});return new l("auth","Firebase",r).create(t,{appName:e.name})}(e,a,o);fl(e,a)}}catch(t){if(t instanceof h)throw t;fl(e,"network-request-failed")}}async function Ol(e,t,n,r,s={}){const i=await Dl(e,t,n,r,s);return"mfaPendingCredential"in i&&fl(e,"multi-factor-auth-required",{_serverResponse:i}),i}function Ll(e,t,n,r){const s=`${t}${n}?${r}`;return e.config.emulator?Sl(e.config,s):`${e.config.apiScheme}://${s}`}class Pl{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise(((e,t)=>{this.timer=setTimeout((()=>t(pl(this.auth,"network-request-failed"))),Al.get())}))}clearNetworkTimeout(){clearTimeout(this.timer)}}function Ml(e,t,n){const r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const s=pl(e,t,r);return s.customData._tokenResponse=n,s}
2131
+ */function Nl(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function Dl(e,t,n,r,s={}){return Rl(e,s,(async()=>{let s={},i={};r&&("GET"===t?i=r:s={body:JSON.stringify(r)});const o=g(Object.assign({key:e.config.apiKey},i)).slice(1),a=await e._getAdditionalHeaders();return a["Content-Type"]="application/json",e.languageCode&&(a["X-Firebase-Locale"]=e.languageCode),Cl.fetch()(Ll(e,e.config.apiHost,n,o),Object.assign({method:t,headers:a,referrerPolicy:"no-referrer"},s))}))}async function Rl(e,t,n){e._canInitEmulator=!1;const r=Object.assign(Object.assign({},Al),t);try{const t=new Pl(e),s=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();const i=await s.json();if("needConfirmation"in i)throw Ml(e,"account-exists-with-different-credential",i);if(s.ok&&!("errorMessage"in i))return i;{const t=s.ok?i.errorMessage:i.error.message,[n,o]=t.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw Ml(e,"credential-already-in-use",i);if("EMAIL_EXISTS"===n)throw Ml(e,"email-already-in-use",i);if("USER_DISABLED"===n)throw Ml(e,"user-disabled",i);const a=r[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(o)throw function(e,t,n){const r=Object.assign(Object.assign({},cl()),{[t]:n});return new l("auth","Firebase",r).create(t,{appName:e.name})}(e,a,o);fl(e,a)}}catch(t){if(t instanceof h)throw t;fl(e,"network-request-failed")}}async function Ol(e,t,n,r,s={}){const i=await Dl(e,t,n,r,s);return"mfaPendingCredential"in i&&fl(e,"multi-factor-auth-required",{_serverResponse:i}),i}function Ll(e,t,n,r){const s=`${t}${n}?${r}`;return e.config.emulator?Sl(e.config,s):`${e.config.apiScheme}://${s}`}class Pl{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise(((e,t)=>{this.timer=setTimeout((()=>t(pl(this.auth,"network-request-failed"))),kl.get())}))}clearNetworkTimeout(){clearTimeout(this.timer)}}function Ml(e,t,n){const r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const s=pl(e,t,r);return s.customData._tokenResponse=n,s}
2132
2132
  /**
2133
2133
  * @license
2134
2134
  * Copyright 2020 Google LLC
@@ -2619,7 +2619,7 @@ class Cd extends Ed{constructor(){super("github.com")}static credential(e){retur
2619
2619
  * See the License for the specific language governing permissions and
2620
2620
  * limitations under the License.
2621
2621
  */
2622
- class kd extends Ed{constructor(){super("twitter.com")}static credential(e,t){return wd._fromParams({providerId:kd.PROVIDER_ID,signInMethod:kd.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return kd.credentialFromTaggedObject(e)}static credentialFromError(e){return kd.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return kd.credential(t,n)}catch(e){return null}}}kd.TWITTER_SIGN_IN_METHOD="twitter.com",kd.PROVIDER_ID="twitter.com";
2622
+ class Ad extends Ed{constructor(){super("twitter.com")}static credential(e,t){return wd._fromParams({providerId:Ad.PROVIDER_ID,signInMethod:Ad.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return Ad.credentialFromTaggedObject(e)}static credentialFromError(e){return Ad.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return Ad.credential(t,n)}catch(e){return null}}}Ad.TWITTER_SIGN_IN_METHOD="twitter.com",Ad.PROVIDER_ID="twitter.com";
2623
2623
  /**
2624
2624
  * @license
2625
2625
  * Copyright 2020 Google LLC
@@ -2636,7 +2636,7 @@ class kd extends Ed{constructor(){super("twitter.com")}static credential(e,t){re
2636
2636
  * See the License for the specific language governing permissions and
2637
2637
  * limitations under the License.
2638
2638
  */
2639
- class Ad{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,n,r=!1){const s=await Kl._fromIdTokenResponse(e,n,r),i=Nd(n);return new Ad({user:s,providerId:i,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);const r=Nd(n);return new Ad({user:e,providerId:r,_tokenResponse:n,operationType:t})}}function Nd(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}
2639
+ class kd{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,n,r=!1){const s=await Kl._fromIdTokenResponse(e,n,r),i=Nd(n);return new kd({user:s,providerId:i,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);const r=Nd(n);return new kd({user:e,providerId:r,_tokenResponse:n,operationType:t})}}function Nd(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}
2640
2640
  /**
2641
2641
  * @license
2642
2642
  * Copyright 2020 Google LLC
@@ -2669,7 +2669,7 @@ class Ad{constructor(e){this.user=e.user,this.providerId=e.providerId,this._toke
2669
2669
  * See the License for the specific language governing permissions and
2670
2670
  * limitations under the License.
2671
2671
  */
2672
- async function Od(e,t,n=!1){const r="signIn",s=await Rd(e,r,t),i=await Ad._fromIdTokenResponse(e,r,s);return n||await e._updateCurrentUser(i.user),i}
2672
+ async function Od(e,t,n=!1){const r="signIn",s=await Rd(e,r,t),i=await kd._fromIdTokenResponse(e,r,s);return n||await e._updateCurrentUser(i.user),i}
2673
2673
  /**
2674
2674
  * @license
2675
2675
  * Copyright 2020 Google LLC
@@ -2917,7 +2917,7 @@ class sf extends gd{constructor(e){super("custom","custom"),this.params=e}_getId
2917
2917
  * See the License for the specific language governing permissions and
2918
2918
  * limitations under the License.
2919
2919
  */
2920
- async function(e,t,n=!1){const{auth:r}=e,s="reauthenticate";try{const i=await Vl(e,Rd(r,s,t,e),n);ml(i.idToken,r,"internal-error");const o=Fl(i.idToken);ml(o,r,"internal-error");const{sub:a}=o;return ml(e.uid===a,r,"user-mismatch"),Ad._forOperation(e,s,i)}catch(e){throw"auth/user-not-found"===(null==e?void 0:e.code)&&fl(r,"user-mismatch"),e}}(n,new sf(e),e.bypassAuthState)}async function cf(e){const{auth:t,user:n}=e;return ml(n,t,"internal-error"),async function(e,t,n=!1){const r=await Vl(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return Ad._forOperation(e,"link",r)}(n,new sf(e),e.bypassAuthState)}
2920
+ async function(e,t,n=!1){const{auth:r}=e,s="reauthenticate";try{const i=await Vl(e,Rd(r,s,t,e),n);ml(i.idToken,r,"internal-error");const o=Fl(i.idToken);ml(o,r,"internal-error");const{sub:a}=o;return ml(e.uid===a,r,"user-mismatch"),kd._forOperation(e,s,i)}catch(e){throw"auth/user-not-found"===(null==e?void 0:e.code)&&fl(r,"user-mismatch"),e}}(n,new sf(e),e.bypassAuthState)}async function cf(e){const{auth:t,user:n}=e;return ml(n,t,"internal-error"),async function(e,t,n=!1){const r=await Vl(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return kd._forOperation(e,"link",r)}(n,new sf(e),e.bypassAuthState)}
2921
2921
  /**
2922
2922
  * @license
2923
2923
  * Copyright 2020 Google LLC
@@ -3048,7 +3048,7 @@ const If=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,bf=/^https?/;async function Tf(e
3048
3048
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3049
3049
  * See the License for the specific language governing permissions and
3050
3050
  * limitations under the License.
3051
- */const _f=new _l(3e4,6e4);function Sf(){const e=Kd().___jsl;if(null==e?void 0:e.H)for(const t of Object.keys(e.H))if(e.H[t].r=e.H[t].r||[],e.H[t].L=e.H[t].L||[],e.H[t].r=[...e.H[t].L],e.CP)for(let t=0;t<e.CP.length;t++)e.CP[t]=null}function Cf(e){return new Promise(((t,n)=>{var r,s,i;function o(){Sf(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{Sf(),n(pl(e,"network-request-failed"))},timeout:_f.get()})}if(null===(s=null===(r=Kd().gapi)||void 0===r?void 0:r.iframes)||void 0===s?void 0:s.Iframe)t(gapi.iframes.getContext());else{if(!(null===(i=Kd().gapi)||void 0===i?void 0:i.load)){const t=`__${"iframefcb"}${Math.floor(1e6*Math.random())}`;return Kd()[t]=()=>{gapi.load?o():n(pl(e,"network-request-failed"))},rf(`https://apis.google.com/js/api.js?onload=${t}`).catch((e=>n(e)))}o()}})).catch((e=>{throw kf=null,e}))}let kf=null;
3051
+ */const _f=new _l(3e4,6e4);function Sf(){const e=Kd().___jsl;if(null==e?void 0:e.H)for(const t of Object.keys(e.H))if(e.H[t].r=e.H[t].r||[],e.H[t].L=e.H[t].L||[],e.H[t].r=[...e.H[t].L],e.CP)for(let t=0;t<e.CP.length;t++)e.CP[t]=null}function Cf(e){return new Promise(((t,n)=>{var r,s,i;function o(){Sf(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{Sf(),n(pl(e,"network-request-failed"))},timeout:_f.get()})}if(null===(s=null===(r=Kd().gapi)||void 0===r?void 0:r.iframes)||void 0===s?void 0:s.Iframe)t(gapi.iframes.getContext());else{if(!(null===(i=Kd().gapi)||void 0===i?void 0:i.load)){const t=`__${"iframefcb"}${Math.floor(1e6*Math.random())}`;return Kd()[t]=()=>{gapi.load?o():n(pl(e,"network-request-failed"))},rf(`https://apis.google.com/js/api.js?onload=${t}`).catch((e=>n(e)))}o()}})).catch((e=>{throw Af=null,e}))}let Af=null;
3052
3052
  /**
3053
3053
  * @license
3054
3054
  * Copyright 2020 Google LLC.
@@ -3065,7 +3065,7 @@ const If=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,bf=/^https?/;async function Tf(e
3065
3065
  * See the License for the specific language governing permissions and
3066
3066
  * limitations under the License.
3067
3067
  */
3068
- const Af=new _l(5e3,15e3),Nf={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},Df=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function Rf(e){const t=e.config;ml(t.authDomain,e,"auth-domain-config-required");const n=t.emulator?Sl(t,"emulator/auth/iframe"):`https://${e.config.authDomain}/__/auth/iframe`,r={apiKey:t.apiKey,appName:e.name,v:oe},s=Df.get(e.config.apiHost);s&&(r.eid=s);const i=e._getFrameworks();return i.length&&(r.fw=i.join(",")),`${n}?${g(r).slice(1)}`}async function Of(e){const t=await function(e){return kf=kf||Cf(e),kf}(e),n=Kd().gapi;return ml(n,e,"internal-error"),t.open({where:document.body,url:Rf(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Nf,dontclear:!0},(t=>new Promise((async(n,r)=>{await t.restyle({setHideOnLeave:!1});const s=pl(e,"network-request-failed"),i=Kd().setTimeout((()=>{r(s)}),Af.get());function o(){Kd().clearTimeout(i),n(t)}t.ping(o).then(o,(()=>{r(s)}))}))))}
3068
+ const kf=new _l(5e3,15e3),Nf={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},Df=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function Rf(e){const t=e.config;ml(t.authDomain,e,"auth-domain-config-required");const n=t.emulator?Sl(t,"emulator/auth/iframe"):`https://${e.config.authDomain}/__/auth/iframe`,r={apiKey:t.apiKey,appName:e.name,v:oe},s=Df.get(e.config.apiHost);s&&(r.eid=s);const i=e._getFrameworks();return i.length&&(r.fw=i.join(",")),`${n}?${g(r).slice(1)}`}async function Of(e){const t=await function(e){return Af=Af||Cf(e),Af}(e),n=Kd().gapi;return ml(n,e,"internal-error"),t.open({where:document.body,url:Rf(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Nf,dontclear:!0},(t=>new Promise((async(n,r)=>{await t.restyle({setHideOnLeave:!1});const s=pl(e,"network-request-failed"),i=Kd().setTimeout((()=>{r(s)}),kf.get());function o(){Kd().clearTimeout(i),n(t)}t.ping(o).then(o,(()=>{r(s)}))}))))}
3069
3069
  /**
3070
3070
  * @license
3071
3071
  * Copyright 2020 Google LLC.
@@ -3163,5 +3163,5 @@ class zf{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var
3163
3163
  * See the License for the specific language governing permissions and
3164
3164
  * limitations under the License.
3165
3165
  */
3166
- const $f=c("authIdTokenMaxAge")||300;let Kf=null;function Hf(e=ce()){const t=re(e,"auth");if(t.isInitialized())return t.getImmediate();const n=function(e,t){const n=re(e,"auth");if(n.isInitialized()){const e=n.getImmediate();if(f(n.getOptions(),null!=t?t:{}))return e;fl(e,"already-initialized")}return n.initialize({options:t})}(e,{popupRedirectResolver:qf,persistence:[nf,Vd,jd]}),r=c("authTokenSyncURL");if(r){const e=(s=r,async e=>{const t=e&&await e.getIdTokenResult(),n=t&&((new Date).getTime()-Date.parse(t.issuedAtTime))/1e3;if(n&&n>$f)return;const r=null==t?void 0:t.token;Kf!==r&&(Kf=r,await fetch(s,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))});!function(e,t,n){I(e).beforeAuthStateChanged(t,n)}(n,e,(()=>e(n.currentUser))),function(e,t,n,r){I(e).onIdTokenChanged(t,n,r)}(n,(t=>e(t)))}var s;const i=a("auth");return i&&dd(n,`http://${i}`),n}var Gf;Gf="Browser",ne(new b("auth",((e,{options:t})=>{const n=e.getProvider("app").getImmediate(),r=e.getProvider("heartbeat"),{apiKey:s,authDomain:i}=n.options;return((e,n)=>{ml(s&&!s.includes(":"),"invalid-api-key",{appName:e.name}),ml(!(null==i?void 0:i.includes(":")),"argument-error",{appName:e.name});const r={apiKey:s,authDomain:i,clientPlatform:Gf,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:ad(Gf)},o=new ud(e,n,r);return function(e,t){const n=(null==t?void 0:t.persistence)||[],r=(Array.isArray(n)?n:[n]).map(Il);(null==t?void 0:t.errorMap)&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,null==t?void 0:t.popupRedirectResolver)}(o,t),o})(n,r)}),"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback(((e,t,n)=>{e.getProvider("auth-internal").initialize()}))),ne(new b("auth-internal",(e=>(e=>new zf(e))(hd(e.getProvider("auth").getImmediate()))),"PRIVATE").setInstantiationMode("EXPLICIT")),ue(jf,Bf,function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";default:return}}(Gf)),ue(jf,Bf,"esm2017");class Wf extends Error{constructor(){super("Avatar not created"),this.name="AvatarNotCreatedError"}}class Qf extends Error{constructor(){super("no frames found"),this.name="NoFramesFoundError"}}class Yf extends Error{constructor(){super("request timeout"),this.name="RequestTimeoutError"}}class Xf extends Error{constructor(){super("user not logged in"),this.name="UserNotLoggedInError"}}class Jf extends Error{constructor(){super("no colorway size assets found"),this.name="NoColorwaySizeAssetsFoundError"}}class Zf extends Error{constructor(){super("no styles found"),this.name="NoStylesFoundError"}}class ep extends Error{constructor(e,t){super("recommended available sizes error"),this.name="RecommendedAvailableSizesError",this.recommended_size=e,this.available_sizes=t}}class tp extends Error{constructor(){super("brand user id not set"),this.name="BrandUserIdNotSetError"}}const np="avatar not created";var rp=Object.freeze({__proto__:null,AvatarNotCreatedError:Wf,NoFramesFoundError:Qf,RequestTimeoutError:Yf,UserNotLoggedInError:Xf,NoColorwaySizeAssetsFoundError:Jf,NoStylesFoundError:Zf,RecommendedAvailableSizesError:ep,BrandUserIdNotSetError:tp,AvatarNotCreated:np});class sp{constructor(e,t){this.firestore=e,this.brandUserId=null,this.auth=Hf(t),this.auth.setPersistence(Vd)}get id(){var e;return null===(e=this.user)||void 0===e?void 0:e.uid}onInit(){return new Promise((e=>{const t=this.auth.onAuthStateChanged((n=>{this.setUser(n),e(Boolean(n)),t()}))}))}setUser(e){this.user=e}setBrandUserId(e){this.brandUserId=e}async getToken(){var e;if(!(null===(e=this.user)||void 0===e?void 0:e.uid))throw new Xf;return await this.user.getIdToken()}async getUserProfile(){var e;if(!(null===(e=this.user)||void 0===e?void 0:e.uid))throw new Xf;const t=await Jh(function(e,t,...n){if(e=I(e),1===arguments.length&&(t=Ys.R()),Xu("doc","path",t),e instanceof sh){const r=ni.fromString(t,...n);return Ju(r),new oh(e,null,new ii(r))}{if(!(e instanceof oh||e instanceof ch))throw new Vs(Fs.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(ni.fromString(t,...n));return Ju(r),new oh(e.firestore,e instanceof ch?e.converter:null,new ii(r))}}(this.firestore,"users",this.id));return t.data()}watchUserProfileForChanges(e,t){let n;const r=Vh(uh(this.firestore,"users"),jh(Th(),"==",this.id)),s=setTimeout((()=>n()),t);return new Promise((t=>{n=tl(r,(async r=>{await e(r)&&(clearTimeout(s),n(),t(r.docs[0].data()))}))}))}async login(e,t){this.auth.currentUser&&await this.auth.signOut();const n=await Md(this.auth,e,t);this.setUser(n.user)}async logout(){await this.auth.signOut(),this.setUser(null)}async sendPasswordResetEmail(e){await Ld(this.auth,e)}async confirmPasswordReset(e,t){await Pd(this.auth,e,t)}}class ip{constructor(){this.promisefyOnSnapshot=(e,t)=>{let n;return{promise:new Promise((r=>{n=tl(e,(e=>{r(e),t&&n()}))})),unsubscribe:()=>n()}};const e=ae(rl.getInstance().firebase);this.firestore=yh(e),this.user=new sp(this.firestore,e)}onInit(){return this.user.onInit()}query(e,t,n=!0){const r=Vh(uh(this.firestore,e),t);return this.promisefyOnSnapshot(r,n)}getDocs(e,t){return el(Vh(uh(this.firestore,e),...t))}}const op=e=>{if(e.code===hl)throw new Error("account has been disabled");throw new Error(e.message)};class ap{static get endpoint(){return rl.getInstance().api.url}static async Fetch({user:e,endpointPath:t,method:n,body:r,useToken:s=!0}){const i=this.getUrl(t,s),o={method:n,headers:await this.getHeaders(e,s),credentials:"include"};r&&(o.body=JSON.stringify(r));const a=await fetch(i,o);if(a.ok)return a;if(500===a.status)throw new Error(a.statusText);const c=await a.json();return Promise.reject(c)}static getUrl(e,t){return t?`${this.endpoint}/v1${e}`:this.endpoint+e}static async getHeaders(e,t){if(!t)return{"Content-Type":"application/json"};return{"Content-Type":"application/json",Authorization:`Bearer ${await e.getToken()}`}}static Get(e,t,n){return this.Fetch({user:e,endpointPath:t,method:"GET",body:null,useToken:n})}static Post(e,t,n=null,r){return this.Fetch({user:e,endpointPath:t,method:"POST",body:n,useToken:r})}static Put(e,t,n,r){return this.Fetch({user:e,endpointPath:t,method:"PUT",body:n,useToken:r})}static Patch(e,t,n,r){return this.Fetch({user:e,endpointPath:t,method:"PATCH",body:n,useToken:r})}static Delete(e,t,n,r){return this.Fetch({user:e,endpointPath:t,method:"DELETE",body:n,useToken:r})}}const cp=e=>{const t=new Image;return t.src=e,new Promise((e=>{t.onerror=()=>e(!1),t.onload=()=>e(!0)}))};class up{constructor(e,t){this.brandId=e,this.firebase=t;const n=rl.getInstance().config;up.avatarTimeout=n.avatarTimeout?Number(n.avatarTimeout):12e4,up.vtoTimeout=n.vtoTimeout?Number(n.vtoTimeout):12e4}get user(){return this.firebase.user}get isLoggedIn(){return!this.firebase||Boolean(this.user.id)}onInit(){return this.firebase.onInit()}async tryOn(e){if(!this.isLoggedIn)throw new Xf;try{return await this.getColorwaySizeAssetFrames(e)}catch(t){if(!(t instanceof Qf))throw t;return this.requestThenGetColorwaySizeAssetFrames(e)}}async awaitAvatarCreated(){if(!this.isLoggedIn)throw new Xf;const{promise:e,unsubscribe:t}=this.firebase.query("users",jh(Th(),"==",this.user.id)),n=setTimeout((()=>{throw t(),new Yf}),up.avatarTimeout),r=await e;clearTimeout(n);return"CREATED"===r.docs[0].data().avatar_status}async getRecommendedSizes(e){if(!this.isLoggedIn)throw new Xf;try{const t=await ap.Get(this.user,`/styles/${e}/recommendation`);return await t.json()}catch(e){if((null==e?void 0:e.error)===np)throw new Wf;throw e}}async getRecommendedSizesLabels(e){const t=await this.getRecommendedSizes(e);return{recommendedSizeLabel:t.recommended_sizes.label||t.recommended_sizes.size_value.size,availableSizeLabels:t.available_sizes.map((e=>e.label||e.size_value.size))}}async getStyles(e,t){const n=[jh("brand_id","==",this.brandId)];(null==e?void 0:e.length)>0&&n.push(jh("id","in",e)),(null==t?void 0:t.length)>0&&n.push(jh("brand_style_id","in",t));try{const e=await this.firebase.getDocs("styles",n),t=new Map;return e.forEach((e=>{const n=e.data();t.set(n.id,n)})),t}catch(e){return op(e)}}async submitTelephoneNumber(e){const t=e.replace(/[^\+0-9]/g,""),n=await ap.Post(this.user,"/ios-app-link",{phone_number:t},!1);console.log(n)}async awaitColorwaySizeAssetFrames(e){var t,n,r,s;if(!this.isLoggedIn)throw new Xf;const i=await this.user.watchUserProfileForChanges((async t=>{var n,r,s,i;const o=null===(i=null===(s=null===(r=null===(n=t.docs[0].data())||void 0===n?void 0:n.vto)||void 0===r?void 0:r[this.brandId])||void 0===s?void 0:s[e])||void 0===i?void 0:i.frames;return!!(null==o?void 0:o.length)&&cp(o[0])}),up.vtoTimeout);if(!(null===(s=null===(r=null===(n=null===(t=null==i?void 0:i.vto)||void 0===t?void 0:t[this.brandId])||void 0===n?void 0:n[e])||void 0===r?void 0:r.frames)||void 0===s?void 0:s.length))throw new Qf;return i.vto[this.brandId][e].frames}async requestThenGetColorwaySizeAssetFrames(e){var t,n;const[r,s]=await(i=this.getColorwaySizeAssetFromSku(e),i.then((e=>[null,e])).catch((e=>[e])));var i;if(r)throw r;try{return await this.requestColorwaySizeAssetFrames(s.id),this.awaitColorwaySizeAssetFrames(e)}catch(r){if((null==r?void 0:r.error)===np)throw new Wf;if(!r.recommended_size_id)throw new Error(r);const e=r,i=(await this.getStyles([s.style_id],null)).get(s.style_id);if(!(null==i?void 0:i.sizes))throw new Zf;const o=(null===(t=i.sizes[e.recommended_size_id])||void 0===t?void 0:t.label)||(null===(n=i.sizes[e.recommended_size_id])||void 0===n?void 0:n.size),a=e.available_size_ids.filter((e=>{var t;return(null===(t=i.sizes[e])||void 0===t?void 0:t.size)!==o})).map((e=>{var t,n;return(null===(t=i.sizes[e])||void 0===t?void 0:t.label)||(null===(n=i.sizes[e])||void 0===n?void 0:n.size)}));throw new ep(o,a)}}async getColorwaySizeAssetFromSku(e){const t=await this.getColorwaySizeAssets(null,[e]);if(!(null==t?void 0:t.size))throw new Jf;return Array.from(t.values())[0]}async getColorwaySizeAssets(e,t){const n=[jh("brand_id","==",this.brandId)];e&&n.push(jh("style_id","==",e)),(null==t?void 0:t.length)>0&&n.push(jh("sku","in",t));try{const e=await this.firebase.getDocs("colorway_size_assets",n),t=new Map;return e.forEach((e=>{const n=e.data();t.set(n.id,n)})),t}catch(e){return op(e)}}async requestColorwaySizeAssetFrames(e){if(!this.isLoggedIn)throw new Xf;if(!this.user.brandUserId)throw new tp;await ap.Post(this.user,`/colorway-size-assets/${e}/frames`,{brand_user_id:String(this.user.brandUserId)})}async getColorwaySizeAssetFrames(e){var t,n,r;const s=await this.user.getUserProfile(),i=(null===(r=null===(n=null===(t=null==s?void 0:s.vto)||void 0===t?void 0:t[this.brandId])||void 0===n?void 0:n[e])||void 0===r?void 0:r.frames)||[];if(!i.length)throw new Qf;if(!await cp(i[0]))throw new Qf;return i}}up.avatarTimeout=12e4,up.vtoTimeout=12e4;const hp=(e,t="dev")=>("dev"!==t&&"development"!==t||console.warn("TfrShop is in development mode"),rl.getInstance().setEnv(t),new up(e,new ip));var lp,dp=Object.freeze({__proto__:null}),fp=Object.freeze({__proto__:null});!function(e){e.NOT_CREATED="NOT_CREATED",e.CREATED="CREATED",e.PENDING="PENDING"}(lp||(lp={}));var pp=Object.freeze({__proto__:null,get AvatarState(){return lp}});const gp=up.vtoTimeout;export{rp as Errors,gp as VTO_TIMEOUT_MS,hp as initShop,dp as requests,fp as responses,pp as types};
3166
+ const $f=c("authIdTokenMaxAge")||300;let Kf=null;function Hf(e=ce()){const t=re(e,"auth");if(t.isInitialized())return t.getImmediate();const n=function(e,t){const n=re(e,"auth");if(n.isInitialized()){const e=n.getImmediate();if(f(n.getOptions(),null!=t?t:{}))return e;fl(e,"already-initialized")}return n.initialize({options:t})}(e,{popupRedirectResolver:qf,persistence:[nf,Vd,jd]}),r=c("authTokenSyncURL");if(r){const e=(s=r,async e=>{const t=e&&await e.getIdTokenResult(),n=t&&((new Date).getTime()-Date.parse(t.issuedAtTime))/1e3;if(n&&n>$f)return;const r=null==t?void 0:t.token;Kf!==r&&(Kf=r,await fetch(s,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))});!function(e,t,n){I(e).beforeAuthStateChanged(t,n)}(n,e,(()=>e(n.currentUser))),function(e,t,n,r){I(e).onIdTokenChanged(t,n,r)}(n,(t=>e(t)))}var s;const i=a("auth");return i&&dd(n,`http://${i}`),n}var Gf;Gf="Browser",ne(new b("auth",((e,{options:t})=>{const n=e.getProvider("app").getImmediate(),r=e.getProvider("heartbeat"),{apiKey:s,authDomain:i}=n.options;return((e,n)=>{ml(s&&!s.includes(":"),"invalid-api-key",{appName:e.name}),ml(!(null==i?void 0:i.includes(":")),"argument-error",{appName:e.name});const r={apiKey:s,authDomain:i,clientPlatform:Gf,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:ad(Gf)},o=new ud(e,n,r);return function(e,t){const n=(null==t?void 0:t.persistence)||[],r=(Array.isArray(n)?n:[n]).map(Il);(null==t?void 0:t.errorMap)&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,null==t?void 0:t.popupRedirectResolver)}(o,t),o})(n,r)}),"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback(((e,t,n)=>{e.getProvider("auth-internal").initialize()}))),ne(new b("auth-internal",(e=>(e=>new zf(e))(hd(e.getProvider("auth").getImmediate()))),"PRIVATE").setInstantiationMode("EXPLICIT")),ue(jf,Bf,function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";default:return}}(Gf)),ue(jf,Bf,"esm2017");class Wf extends Error{constructor(){super("Avatar not created"),this.name="AvatarNotCreatedError"}}class Qf extends Error{constructor(){super("no frames found"),this.name="NoFramesFoundError"}}class Yf extends Error{constructor(){super("request timeout"),this.name="RequestTimeoutError"}}class Xf extends Error{constructor(){super("user not logged in"),this.name="UserNotLoggedInError"}}class Jf extends Error{constructor(){super("no colorway size assets found"),this.name="NoColorwaySizeAssetsFoundError"}}class Zf extends Error{constructor(){super("no styles found"),this.name="NoStylesFoundError"}}class ep extends Error{constructor(e,t){super("recommended available sizes error"),this.name="RecommendedAvailableSizesError",this.recommended_size=e,this.available_sizes=t}}class tp extends Error{constructor(){super("brand user id not set"),this.name="BrandUserIdNotSetError"}}const np="avatar not created";var rp=Object.freeze({__proto__:null,AvatarNotCreatedError:Wf,NoFramesFoundError:Qf,RequestTimeoutError:Yf,UserNotLoggedInError:Xf,NoColorwaySizeAssetsFoundError:Jf,NoStylesFoundError:Zf,RecommendedAvailableSizesError:ep,BrandUserIdNotSetError:tp,AvatarNotCreated:np});class sp{constructor(e,t){this.firestore=e,this.brandUserId=null,this.auth=Hf(t),this.auth.setPersistence(Vd)}get id(){var e;return null===(e=this.user)||void 0===e?void 0:e.uid}onInit(){return new Promise((e=>{const t=this.auth.onAuthStateChanged((n=>{this.setUser(n),e(Boolean(n)),t()}))}))}setUser(e){this.user=e}setBrandUserId(e){this.brandUserId=e}async getToken(){var e;if(!(null===(e=this.user)||void 0===e?void 0:e.uid))throw new Xf;return await this.user.getIdToken()}async getUserProfile(){var e;if(!(null===(e=this.user)||void 0===e?void 0:e.uid))throw new Xf;const t=await Jh(function(e,t,...n){if(e=I(e),1===arguments.length&&(t=Ys.R()),Xu("doc","path",t),e instanceof sh){const r=ni.fromString(t,...n);return Ju(r),new oh(e,null,new ii(r))}{if(!(e instanceof oh||e instanceof ch))throw new Vs(Fs.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(ni.fromString(t,...n));return Ju(r),new oh(e.firestore,e instanceof ch?e.converter:null,new ii(r))}}(this.firestore,"users",this.id));return t.data()}watchUserProfileForChanges(e,t){let n;const r=Vh(uh(this.firestore,"users"),jh(Th(),"==",this.id)),s=setTimeout((()=>n()),t);return new Promise((t=>{n=tl(r,(async r=>{await e(r)&&(clearTimeout(s),n(),t(r.docs[0].data()))}))}))}async login(e,t){this.auth.currentUser&&await this.auth.signOut();const n=await Md(this.auth,e,t);this.setUser(n.user)}async logout(){await this.auth.signOut(),this.setUser(null)}async sendPasswordResetEmail(e){await Ld(this.auth,e)}async confirmPasswordReset(e,t){await Pd(this.auth,e,t)}}class ip{constructor(){this.promisefyOnSnapshot=(e,t)=>{let n;return{promise:new Promise((r=>{n=tl(e,(e=>{r(e),t&&n()}))})),unsubscribe:()=>n()}};const e=ae(rl.getInstance().firebase);this.firestore=yh(e),this.user=new sp(this.firestore,e)}onInit(){return this.user.onInit()}query(e,t,n=!0){const r=Vh(uh(this.firestore,e),t);return this.promisefyOnSnapshot(r,n)}getDocs(e,t){return el(Vh(uh(this.firestore,e),...t))}}const op=e=>{if(e.code===hl)throw new Error("account has been disabled");throw new Error(e.message)};class ap{static get endpoint(){return rl.getInstance().api.url}static async Fetch({user:e,endpointPath:t,method:n,body:r,useToken:s=!0}){const i=this.getUrl(t,s),o={method:n,headers:await this.getHeaders(e,s),credentials:"include"};r&&(o.body=JSON.stringify(r));const a=await fetch(i,o);if(a.ok)return a;if(500===a.status)throw new Error(a.statusText);const c=await a.json();return Promise.reject(c)}static getUrl(e,t){return t?`${this.endpoint}/v1${e}`:this.endpoint+e}static async getHeaders(e,t){if(!t)return{"Content-Type":"application/json"};return{"Content-Type":"application/json",Authorization:`Bearer ${await e.getToken()}`}}static Get(e,t,n){return this.Fetch({user:e,endpointPath:t,method:"GET",body:null,useToken:n})}static Post(e,t,n=null,r){return this.Fetch({user:e,endpointPath:t,method:"POST",body:n,useToken:r})}static Put(e,t,n,r){return this.Fetch({user:e,endpointPath:t,method:"PUT",body:n,useToken:r})}static Patch(e,t,n,r){return this.Fetch({user:e,endpointPath:t,method:"PATCH",body:n,useToken:r})}static Delete(e,t,n,r){return this.Fetch({user:e,endpointPath:t,method:"DELETE",body:n,useToken:r})}}const cp=e=>{const t=new Image;return t.src=e,new Promise((e=>{t.onerror=()=>e(!1),t.onload=()=>e(!0)}))};class up{constructor(e,t){this.brandId=e,this.firebase=t;const n=rl.getInstance().config;up.avatarTimeout=n.avatarTimeout?Number(n.avatarTimeout):12e4,up.vtoTimeout=n.vtoTimeout?Number(n.vtoTimeout):12e4}get user(){return this.firebase.user}get isLoggedIn(){return!this.firebase||Boolean(this.user.id)}onInit(){return this.firebase.onInit()}async tryOn(e){if(!this.isLoggedIn)throw new Xf;try{return await this.getColorwaySizeAssetFrames(e)}catch(t){if(!(t instanceof Qf))throw t;return this.requestThenGetColorwaySizeAssetFrames(e)}}async awaitAvatarCreated(){if(!this.isLoggedIn)throw new Xf;const{promise:e,unsubscribe:t}=this.firebase.query("users",jh(Th(),"==",this.user.id)),n=setTimeout((()=>{throw t(),new Yf}),up.avatarTimeout),r=await e;clearTimeout(n);return"CREATED"===r.docs[0].data().avatar_status}async getRecommendedSizes(e){if(!this.isLoggedIn)throw new Xf;try{const t=await ap.Get(this.user,`/styles/${e}/recommendation`);return await t.json()}catch(e){if((null==e?void 0:e.error)===np)throw new Wf;throw e}}async getRecommendedSizesLabels(e){const t=await this.getRecommendedSizes(e);return{recommendedSizeLabel:t.recommended_sizes.label||t.recommended_sizes.size_value.size,availableSizeLabels:t.available_sizes.map((e=>e.label||e.size_value.size))}}async getStyles(e,t){const n=[jh("brand_id","==",this.brandId)];(null==e?void 0:e.length)>0&&n.push(jh("id","in",e)),(null==t?void 0:t.length)>0&&n.push(jh("brand_style_id","in",t));try{const e=await this.firebase.getDocs("styles",n),t=new Map;return e.forEach((e=>{const n=e.data();t.set(n.id,n)})),t}catch(e){return op(e)}}async submitTelephoneNumber(e){const t=e.replace(/[^\+0-9]/g,""),n=await ap.Post(this.user,"/ios-app-link",{phone_number:t},!1);console.log(n)}async getColorwaySizeAssetFromSku(e){const t=await this.getColorwaySizeAssets(null,[e]);if(!(null==t?void 0:t.size))throw new Jf;return Array.from(t.values())[0]}async _getColorwaySizeAssetFromSku(e){const t=await this.getColorwaySizeAssets(null,[e]);if(!(null==t?void 0:t.size))throw new Jf;return Array.from(t.values())}async awaitColorwaySizeAssetFrames(e){var t,n,r,s;if(!this.isLoggedIn)throw new Xf;const i=await this.user.watchUserProfileForChanges((async t=>{var n,r,s,i;const o=null===(i=null===(s=null===(r=null===(n=t.docs[0].data())||void 0===n?void 0:n.vto)||void 0===r?void 0:r[this.brandId])||void 0===s?void 0:s[e])||void 0===i?void 0:i.frames;return!!(null==o?void 0:o.length)&&cp(o[0])}),up.vtoTimeout);if(!(null===(s=null===(r=null===(n=null===(t=null==i?void 0:i.vto)||void 0===t?void 0:t[this.brandId])||void 0===n?void 0:n[e])||void 0===r?void 0:r.frames)||void 0===s?void 0:s.length))throw new Qf;return i.vto[this.brandId][e].frames}async requestThenGetColorwaySizeAssetFrames(e){var t,n;const[r,s]=await(i=this.getColorwaySizeAssetFromSku(e),i.then((e=>[null,e])).catch((e=>[e])));var i;if(r)throw r;try{return await this.requestColorwaySizeAssetFrames(s.id),this.awaitColorwaySizeAssetFrames(e)}catch(r){if((null==r?void 0:r.error)===np)throw new Wf;if(!r.recommended_size_id)throw new Error(r);const e=r,i=(await this.getStyles([s.style_id],null)).get(s.style_id);if(!(null==i?void 0:i.sizes))throw new Zf;const o=(null===(t=i.sizes[e.recommended_size_id])||void 0===t?void 0:t.label)||(null===(n=i.sizes[e.recommended_size_id])||void 0===n?void 0:n.size),a=e.available_size_ids.filter((e=>{var t;return(null===(t=i.sizes[e])||void 0===t?void 0:t.size)!==o})).map((e=>{var t,n;return(null===(t=i.sizes[e])||void 0===t?void 0:t.label)||(null===(n=i.sizes[e])||void 0===n?void 0:n.size)}));throw new ep(o,a)}}async getColorwaySizeAssets(e,t){const n=[jh("brand_id","==",this.brandId)];e&&n.push(jh("style_id","==",e)),(null==t?void 0:t.length)>0&&n.push(jh("sku","in",t));try{const e=await this.firebase.getDocs("colorway_size_assets",n),t=new Map;return e.forEach((e=>{const n=e.data();t.set(n.id,n)})),t}catch(e){return op(e)}}async requestColorwaySizeAssetFrames(e){if(!this.isLoggedIn)throw new Xf;if(!this.user.brandUserId)throw new tp;await ap.Post(this.user,`/colorway-size-assets/${e}/frames`,{brand_user_id:String(this.user.brandUserId)})}async getColorwaySizeAssetFrames(e){var t,n,r;const s=await this.user.getUserProfile(),i=(null===(r=null===(n=null===(t=null==s?void 0:s.vto)||void 0===t?void 0:t[this.brandId])||void 0===n?void 0:n[e])||void 0===r?void 0:r.frames)||[];if(!i.length)throw new Qf;if(!await cp(i[0]))throw new Qf;return i}}up.avatarTimeout=12e4,up.vtoTimeout=12e4;const hp=(e,t="dev")=>("dev"!==t&&"development"!==t||console.warn("TfrShop is in development mode"),rl.getInstance().setEnv(t),new up(e,new ip));var lp,dp=Object.freeze({__proto__:null}),fp=Object.freeze({__proto__:null});!function(e){e.NOT_CREATED="NOT_CREATED",e.CREATED="CREATED",e.PENDING="PENDING"}(lp||(lp={}));var pp=Object.freeze({__proto__:null,get AvatarState(){return lp}});const gp=up.vtoTimeout;export{rp as Errors,gp as VTO_TIMEOUT_MS,hp as initShop,dp as requests,fp as responses,pp as types};
3167
3167
  //# sourceMappingURL=index.min.js.map