cooperative-software-develo.../bookish.js

3041 lines
1.9 MiB
JavaScript
Raw Normal View History

2023-01-28 19:43:11 +01:00
var EJ=Object.defineProperty;var SJ=(Ht,Yt,en)=>Yt in Ht?EJ(Ht,Yt,{enumerable:!0,configurable:!0,writable:!0,value:en}):Ht[Yt]=en;var et=(Ht,Yt,en)=>(SJ(Ht,typeof Yt!="symbol"?Yt+"":Yt,en),en),JU=(Ht,Yt,en)=>{if(!Yt.has(Ht))throw TypeError("Cannot "+en)};var y=(Ht,Yt,en)=>(JU(Ht,Yt,"read from private field"),en?en.call(Ht):Yt.get(Ht)),it=(Ht,Yt,en)=>{if(Yt.has(Ht))throw TypeError("Cannot add the same private member more than once");Yt instanceof WeakSet?Yt.add(Ht):Yt.set(Ht,en)},st=(Ht,Yt,en,Eo)=>(JU(Ht,Yt,"write to private field"),Eo?Eo.call(Ht,en):Yt.set(Ht,en),en);(function(){var gt,Es,id,vn,Et,_o,yn,me,Ft,Qn,bn,Cn,kr,Sr,sd,At,Gi,mo,Yl,pn,lr,Vt,Zt,Ur,Ts,mn,mi,Be,on,cr;"use strict";function Ht(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var Yt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function en(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Eo={},sf={exports:{}},vr={},A={exports:{}},ze={};/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ql=Symbol.for("react.element"),eF=Symbol.for("react.portal"),tF=Symbol.for("react.fragment"),nF=Symbol.for("react.strict_mode"),rF=Symbol.for("react.profiler"),iF=Symbol.for("react.provider"),sF=Symbol.for("react.context"),aF=Symbol.for("react.forward_ref"),oF=Symbol.for("react.suspense"),lF=Symbol.for("react.memo"),cF=Symbol.for("react.lazy"),lN=Symbol.iterator;function uF(t){return t===null||typeof t!="object"?null:(t=lN&&t[lN]||t["@@iterator"],typeof t=="function"?t:null)}var cN={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},uN=Object.assign,dN={};function So(t,e,n){this.props=t,this.context=e,this.refs=dN,this.updater=n||cN}So.prototype.isReactComponent={},So.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")},So.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function _N(){}_N.prototype=So.prototype;function af(t,e,n){this.props=t,this.context=e,this.refs=dN,this.updater=n||cN}var of=af.prototype=new _N;of.constructor=af,uN(of,So.prototype),of.isPureReactComponent=!0;var pN=Array.isArray,mN=Object.prototype.hasOwnProperty,lf={current:null},fN={key:!0,ref:!0,__self:!0,__source:!0};function hN(t,e,n){var r,i={},s=null,a=null;if(e!=null)for(r in e.ref!==void 0&&(a=e.ref),e.key!==void 0&&(s=""+e.key),e)mN.call(e,r)&&!fN.hasOwnProperty(r)&&(i[r]=e[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var l=Array(o),c=0;c<o;c++)l[c]=arguments[c+2];i.children=l}if(t&&t.defaultProps)for(r in o=t.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return{$$typeof:ql,type:t,key:s,ref:a,props:i,_owner:lf.current}}function dF(t,e){return{$$typeof:ql,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function cf(t){return typeof t=="object"&&t!==null&&t.$$typeof===ql}function _F(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(n){return e[n]})}var gN=/\/+/g;function uf(t,e){return typeof t=="object"&&t!==null&&t.key!=null?_F(""+t.key):e.toString(36)}function ld(t,e,n,r,i){var s=typeof t;(s==="undefined"||s==="boolean")&&(t=null);var a=!1;if(t===null)a=!0;else switch(s){case"string":case"number":a=!0;break;case"object":switch(t.$$typeof){case ql:case eF:a=!0}}if(a)return a=t,i=i(a),t=r===""?"."+uf(a,0):r,pN(i)?(n="",t!=null&&(n=t.replace(gN,"$&/")+"/"),ld(i,e,n,"",function(c){return c})):i!=null&&(cf(i)&&(i=dF(i,n+(!i.key||a&&a.key===i.key?"":(""+i.key).replace(gN,"$&/")+"/")+t)),e.push(i)),1;if(a=0,r=r===""?".":r+":",pN(t))for(var o=0;o<t.length;o++){s=t[o];var l=r+uf(s,o);a+=ld(s,e,n,l,i)}else if(l=uF(t),typeof l=="function")for(t=l.call(t),o=0;!(s=t.next()).done;)s=s.value,l=r+uf(s,o++),a+=ld(s,e,n,l,i);else if(s==="object")throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.");return a}function cd(t,e,n){if(t==null)return t;var r=[],i=0;return ld(t,r,"","",function(s){return e.call(n,s,i++)}),r}function pF(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(n){(t._status===0||t._status===-1)&&(t._status=1,t._result=n)},function(n){(t._status===0||t._status===-1)&&(t._status=2,t._result=n)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var Kn={current:null},ud={transition:null},mF={ReactCurrentDispatcher:Kn,ReactCurrentBatchConfig:ud,ReactCurrentOwner:lf};ze.Children={map:cd,forEach:function(t,e,n){cd(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return cd(t,function(){e++}),e},toArray:function(t){return cd(t,function(e){return e})||[]},only:function(t){if(!cf(t))throw Error("React.Children.only expected to receive a single React element child.");return t}},ze.Component=So,ze.Fragment=tF,ze.Profiler=rF,ze
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/(function(t){function e(H,U){var D=H.length;H.push(U);e:for(;0<D;){var B=D-1>>>1,$=H[B];if(0<i($,U))H[B]=U,H[D]=$,D=B;else break e}}function n(H){return H.length===0?null:H[0]}function r(H){if(H.length===0)return null;var U=H[0],D=H.pop();if(D!==U){H[0]=D;e:for(var B=0,$=H.length,Y=$>>>1;B<Y;){var I=2*(B+1)-1,M=H[I],G=I+1,K=H[G];if(0>i(M,D))G<$&&0>i(K,M)?(H[B]=K,H[G]=D,B=G):(H[B]=M,H[I]=D,B=I);else if(G<$&&0>i(K,D))H[B]=K,H[G]=D,B=G;else break e}}return U}function i(H,U){var D=H.sortIndex-U.sortIndex;return D!==0?D:H.id-U.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();t.unstable_now=function(){return a.now()-o}}var l=[],c=[],u=1,d=null,_=3,p=!1,f=!1,E=!1,h=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function T(H){for(var U=n(c);U!==null;){if(U.callback===null)r(c);else if(U.startTime<=H)r(c),U.sortIndex=U.expirationTime,e(l,U);else break;U=n(c)}}function v(H){if(E=!1,T(H),!f)if(n(l)!==null)f=!0,W(R);else{var U=n(c);U!==null&&ne(v,U.startTime-H)}}function R(H,U){f=!1,E&&(E=!1,m(N),N=-1),p=!0;var D=_;try{for(T(U),d=n(l);d!==null&&(!(d.expirationTime>U)||H&&!F());){var B=d.callback;if(typeof B=="function"){d.callback=null,_=d.priorityLevel;var $=B(d.expirationTime<=U);U=t.unstable_now(),typeof $=="function"?d.callback=$:d===n(l)&&r(l),T(U)}else r(l);d=n(l)}if(d!==null)var Y=!0;else{var I=n(c);I!==null&&ne(v,I.startTime-U),Y=!1}return Y}finally{d=null,_=D,p=!1}}var C=!1,b=null,N=-1,w=5,k=-1;function F(){return!(t.unstable_now()-k<w)}function X(){if(b!==null){var H=t.unstable_now();k=H;var U=!0;try{U=b(!0,H)}finally{U?J():(C=!1,b=null)}}else C=!1}var J;if(typeof g=="function")J=function(){g(X)};else if(typeof MessageChannel<"u"){var se=new MessageChannel,Ce=se.port2;se.port1.onmessage=X,J=function(){Ce.postMessage(null)}}else J=function(){h(X,0)};function W(H){b=H,C||(C=!0,J())}function ne(H,U){N=h(function(){H(t.unstable_now())},U)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(H){H.callback=null},t.unstable_continueExecution=function(){f||p||(f=!0,W(R))},t.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):w=0<H?Math.floor(1e3/H):5},t.unstable_getCurrentPriorityLevel=function(){return _},t.unstable_getFirstCallbackNode=function(){return n(l)},t.unstable_next=function(H){switch(_){case 1:case 2:case 3:var U=3;break;default:U=_}var D=_;_=U;try{return H()}finally{_=D}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(H,U){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var D=_;_=H;try{return U()}finally{_=D}},t.unstable_scheduleCallback=function(H,U,D){var B=t.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?B+D:B):D=B,H){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=D+$,H={id:u++,callback:U,priorityLevel:H,startTime:D,expirationTime:$,sortIndex:-1},D>B?(H.sortIndex=D,e(c,H),n(l)===null&&H===n(c)&&(E?(m(N),N=-1):E=!0,ne(v,D-B))):(H.sortIndex=$,e(l,H),f||p||(f=!0,W(R))),H},t.unstable_shouldYield=F,t.unstable_wrapCallback=function(H){var U=_;return function(){var D=_;_=U;try{return H.apply(this,arguments)}finally{_=D}}}})(SN),function(t){t.exports=SN}(EN);/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var TN=A.exports,yr=EN.exports;function ee(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n<arguments.length;n++)e+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+t+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var vN=new Set,Wl={};function Sa(t,e){To(t,e),To(t+"Capture",e)}function To(t,e){for(Wl[t]=e,t=0;t<e.length;t++)vN.add(e[t])}var zi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),df=Object.prototype.hasOwnProperty,fF=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,yN={},bN={};function hF(t){return df.call(bN,t)?!0:df.call(yN,t)?!1:fF.test(t)?bN[t]=!0:(yN[t]=!0,!1)}function gF(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function EF(t,e,n,r){if(e===null||typeof e>"u"||gF(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Xn(t,e,n,r,i,s,a){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=a}var Nn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Nn[t]=new Xn(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Nn[e]=new Xn(e,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){Nn[t]=new Xn(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Nn[t]=new Xn(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Nn[t]=new Xn(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){Nn[t]=new Xn(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){Nn[t]=new Xn(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){Nn[t]=new Xn(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){Nn[t]=new Xn(t,5,!1,t.toLowerCase(),null,!1,!1)});var _f=/[\-:]([a-z])/g;function pf(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-a
`+vf+t}var yf=!1;function bf(t,e){if(!t||yf)return"";yf=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(e)if(e=function(){throw Error()},Object.defineProperty(e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(e,[])}catch(c){var r=c}Reflect.construct(t,[],e)}else{try{e.call()}catch(c){r=c}t.call(e.prototype)}else{try{throw Error()}catch(c){r=c}t()}}catch(c){if(c&&r&&typeof c.stack=="string"){for(var i=c.stack.split(`
`),s=r.stack.split(`
`),a=i.length-1,o=s.length-1;1<=a&&0<=o&&i[a]!==s[o];)o--;for(;1<=a&&0<=o;a--,o--)if(i[a]!==s[o]){if(a!==1||o!==1)do if(a--,o--,0>o||i[a]!==s[o]){var l=`
`+i[a].replace(" at new "," at ");return t.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",t.displayName)),l}while(1<=a&&0<=o);break}}}finally{yf=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Kl(t):""}function SF(t){switch(t.tag){case 5:return Kl(t.type);case 16:return Kl("Lazy");case 13:return Kl("Suspense");case 19:return Kl("SuspenseList");case 0:case 2:case 15:return t=bf(t.type,!1),t;case 11:return t=bf(t.type.render,!1),t;case 1:return t=bf(t.type,!0),t;default:return""}}function Cf(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case yo:return"Fragment";case vo:return"Portal";case hf:return"Profiler";case ff:return"StrictMode";case Ef:return"Suspense";case Sf:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case NN:return(t.displayName||"Context")+".Consumer";case CN:return(t._context.displayName||"Context")+".Provider";case gf:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Tf:return e=t.displayName||null,e!==null?e:Cf(t.type)||"Memo";case Cs:e=t._payload,t=t._init;try{return Cf(t(e))}catch{}}return null}function TF(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Cf(e);case 8:return e===ff?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Ns(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function ON(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function vF(t){var e=ON(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(a){r=""+a,s.call(this,a)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function pd(t){t._valueTracker||(t._valueTracker=vF(t))}function AN(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=ON(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function md(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Nf(t,e){var n=e.checked;return xt({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n!=null?n:t._wrapperState.initialChecked})}function wN(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=Ns(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function DN(t,e){e=e.checked,e!=null&&mf(t,"checked",e,!1)}function If(t,e){DN(t,e);var n=Ns(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Rf(t,e.type,n):e.hasOwnProperty("defaultValue")&&Rf(t,e.type,Ns(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function MN(t,e,n){if(e.hasOwnProper
`).replace(DB,"")}function kd(t,e,n){if(e=YI(e),YI(t)!==e&&n)throw Error(ee(425))}function Ud(){}var ch=null,uh=null;function dh(t,e){return t==="textarea"||t==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var _h=typeof setTimeout=="function"?setTimeout:void 0,MB=typeof clearTimeout=="function"?clearTimeout:void 0,zI=typeof Promise=="function"?Promise:void 0,LB=typeof queueMicrotask=="function"?queueMicrotask:typeof zI<"u"?function(t){return zI.resolve(null).then(t).catch(xB)}:_h;function xB(t){setTimeout(function(){throw t})}function ph(t,e){var n=e,r=0;do{var i=n.nextSibling;if(t.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){t.removeChild(i),cc(e);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);cc(e)}function Ms(t){for(;t!=null;t=t.nextSibling){var e=t.nodeType;if(e===1||e===3)break;if(e===8){if(e=t.data,e==="$"||e==="$!"||e==="$?")break;if(e==="/$")return null}}return t}function VI(t){t=t.previousSibling;for(var e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="$"||n==="$!"||n==="$?"){if(e===0)return t;e--}else n==="/$"&&e++}t=t.previousSibling}return null}var Mo=Math.random().toString(36).slice(2),Si="__reactFiber$"+Mo,Tc="__reactProps$"+Mo,ji="__reactContainer$"+Mo,mh="__reactEvents$"+Mo,PB="__reactListeners$"+Mo,kB="__reactHandles$"+Mo;function va(t){var e=t[Si];if(e)return e;for(var n=t.parentNode;n;){if(e=n[ji]||n[Si]){if(n=e.alternate,e.child!==null||n!==null&&n.child!==null)for(t=VI(t);t!==null;){if(n=t[Si])return n;t=VI(t)}return e}t=n,n=t.parentNode}return null}function vc(t){return t=t[Si]||t[ji],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Lo(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(ee(33))}function Fd(t){return t[Tc]||null}var fh=[],xo=-1;function Ls(t){return{current:t}}function It(t){0>xo||(t.current=fh[xo],fh[xo]=null,xo--)}function vt(t,e){xo++,fh[xo]=t.current,t.current=e}var xs={},Un=Ls(xs),ur=Ls(!1),ya=xs;function Po(t,e){var n=t.type.contextTypes;if(!n)return xs;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function dr(t){return t=t.childContextTypes,t!=null}function Bd(){It(ur),It(Un)}function jI(t,e,n){if(Un.current!==xs)throw Error(ee(168));vt(Un,e),vt(ur,n)}function HI(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(ee(108,TF(t)||"Unknown",i));return xt({},n,r)}function Gd(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||xs,ya=Un.current,vt(Un,t),vt(ur,ur.current),!0}function qI(t,e,n){var r=t.stateNode;if(!r)throw Error(ee(169));n?(t=HI(t,e,ya),r.__reactInternalMemoizedMergedChildContext=t,It(ur),It(Un),vt(Un,t)):It(ur),vt(ur,n)}var Hi=null,$d=!1,hh=!1;function WI(t){Hi===null?Hi=[t]:Hi.push(t)}function UB(t){$d=!0,WI(t)}function Ps(){if(!hh&&Hi!==null){hh=!0;var t=0,e=ut;try{var n=Hi;for(ut=1;t<n.length;t++){var r=n[t];do r=r(!0);while(r!==null)}Hi=null,$d=!1}catch(i){throw Hi!==null&&(Hi=Hi.slice(t+1)),KN(Ff,Ps),i}finally{ut=e,hh=!1}}return null}var ko=[],Uo=0,Yd=null,zd=0,Fr=[],Br=0,ba=null,qi=1,Wi="";function Ca(t,e){ko[Uo++]=zd,ko[Uo++]=Yd,Yd=t,zd=e}function QI(t,e,n){Fr[Br++]=qi,Fr[Br++]=Wi,Fr[Br++]=ba,ba=t;var r=qi;t=Wi;var i=32-Jr(r)-1;r&=~(1<<i),n+=1;var s=32-Jr(e)+i;if(30<s){var a=i-i%5;s=(r&(1<<a)-1).toString(32),r>>=a,i-=a,qi=1<<32-Jr(e)+i|n<<i|r,Wi=s+t}else qi=1<<s|n<<i|r,Wi=t}function gh(t){t.return!==null&&(Ca(t,1),QI(t,1,0))}function Eh(t){for(;t===Yd;)Yd=ko[--Uo],ko[Uo]=null,zd=ko[--Uo],ko[Uo]=null;for(;t===ba;)ba=Fr[--Br],Fr[Br]=null,Wi=Fr[--Br],Fr[Br]=null,qi=Fr[--Br],Fr[Br]=null}var Cr=null,Nr=null,wt=!1,ti=null;function KI(t,e){var n=zr(5,null,null,0);n.elementType="DELETED",n.stateNode=e,n.return=t,e=t.de
Error generating stack: `+s.message+`
`+s.stack}return{value:t,source:e,stack:i,digest:null}}function Yh(t,e,n){return{value:t,source:null,stack:n!=null?n:null,digest:e!=null?e:null}}function zh(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var HB=typeof WeakMap=="function"?WeakMap:Map;function LR(t,e,n){n=Ki(-1,n),n.tag=3,n.payload={element:null};var r=e.value;return n.callback=function(){c_||(c_=!0,ig=r),zh(t,e)},n}function xR(t,e,n){n=Ki(-1,n),n.tag=3;var r=t.type.getDerivedStateFromError;if(typeof r=="function"){var i=e.value;n.payload=function(){return r(i)},n.callback=function(){zh(t,e)}}var s=t.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){zh(t,e),typeof r!="function"&&(Bs===null?Bs=new Set([this]):Bs.add(this));var a=e.stack;this.componentDidCatch(e.value,{componentStack:a!==null?a:""})}),n}function PR(t,e,n){var r=t.pingCache;if(r===null){r=t.pingCache=new HB;var i=new Set;r.set(e,i)}else i=r.get(e),i===void 0&&(i=new Set,r.set(e,i));i.has(n)||(i.add(n),t=aG.bind(null,t,e,n),e.then(t,t))}function kR(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function UR(t,e,n,r,i){return(t.mode&1)===0?(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=Ki(-1,1),e.tag=2,Us(n,e,1))),n.lanes|=1),t):(t.flags|=65536,t.lanes=i,t)}var qB=Vi.ReactCurrentOwner,_r=!1;function Zn(t,e,n,r){e.child=t===null?uR(e,null,n,r):$o(e,t.child,n,r)}function FR(t,e,n,r,i){n=n.render;var s=e.ref;return Go(e,i),r=kh(t,e,n,r,s,i),n=Uh(),t!==null&&!_r?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Xi(t,e,i)):(wt&&n&&gh(e),e.flags|=1,Zn(t,e,r,i),e.child)}function BR(t,e,n,r,i){if(t===null){var s=n.type;return typeof s=="function"&&!dg(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=s,GR(t,e,s,r,i)):(t=f_(n.type,null,r,e,e.mode,i),t.ref=e.ref,t.return=e,e.child=t)}if(s=t.child,(t.lanes&i)===0){var a=s.memoizedProps;if(n=n.compare,n=n!==null?n:fc,n(a,r)&&t.ref===e.ref)return Xi(t,e,i)}return e.flags|=1,t=zs(s,r),t.ref=e.ref,t.return=e,e.child=t}function GR(t,e,n,r,i){if(t!==null){var s=t.memoizedProps;if(fc(s,r)&&t.ref===e.ref)if(_r=!1,e.pendingProps=r=s,(t.lanes&i)!==0)(t.flags&131072)!==0&&(_r=!0);else return e.lanes=t.lanes,Xi(t,e,i)}return Vh(t,e,n,r,i)}function $R(t,e,n){var r=e.pendingProps,i=r.children,s=t!==null?t.memoizedState:null;if(r.mode==="hidden")if((e.mode&1)===0)e.memoizedState={baseLanes:0,cachePool:null,transitions:null},vt(jo,Ir),Ir|=n;else{if((n&1073741824)===0)return t=s!==null?s.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,vt(jo,Ir),Ir|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,vt(jo,Ir),Ir|=r}else s!==null?(r=s.baseLanes|n,e.memoizedState=null):r=n,vt(jo,Ir),Ir|=r;return Zn(t,e,i,n),e.child}function YR(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function Vh(t,e,n,r,i){var s=dr(n)?ya:Un.current;return s=Po(e,s),Go(e,i),n=kh(t,e,n,r,s,i),r=Uh(),t!==null&&!_r?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Xi(t,e,i)):(wt&&r&&gh(e),e.flags|=1,Zn(t,e,n,i),e.child)}function zR(t,e,n,r,i){if(dr(n)){var s=!0;Gd(e)}else s=!1;if(Go(e,i),e.stateNode===null)i_(t,e),aR(e,n,r),Ah(e,n,r,i),r=!0;else if(t===null){var a=e.stateNode,o=e.memoizedProps;a.props=o;var l=a.context,c=n.contextType;typeof c=="object"&&c!==null?c=Gr(c):(c=dr(n)?ya:Un.current,c=Po(e,c));var u=n.getDerivedStateFromProps,d=typeof u=="function"||typeof a.getSnapshotBeforeUpdate=="function";d||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(o!==r||l!==c)&&oR(e,a,r,c),ks=!1;var _=e.memoizedState;a.state=_,Wd(e,r,a,i),l=e.memoizedState,o!==r||_!==l||ur.current||ks?(typeof u=="function"&&(Oh(e,n,u,r),l=e.memoizedState),(o=ks||sR(e,n,o,r,_,l,c))?(d||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componen
* React Router v6.2.1
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function bi(t,e){if(!t)throw new Error(e)}const Tg=A.exports.createContext(null),vg=A.exports.createContext(null),Wo=A.exports.createContext({outlet:null,matches:[]});function SG(t){return CG(t.context)}function Rr(t){bi(!1)}function TG(t){let{basename:e="/",children:n=null,location:r,navigationType:i=La.Pop,navigator:s,static:a=!1}=t;kc()&&bi(!1);let o=VG(e),l=A.exports.useMemo(()=>({basename:o,navigator:s,static:a}),[o,s,a]);typeof r=="string"&&(r=xa(r));let{pathname:c="/",search:u="",hash:d="",state:_=null,key:p="default"}=r,f=A.exports.useMemo(()=>{let E=MO(c,o);return E==null?null:{pathname:E,search:u,hash:d,state:_,key:p}},[o,c,u,d,_,p]);return f==null?null:A.exports.createElement(Tg.Provider,{value:l},A.exports.createElement(vg.Provider,{children:n,value:{location:f,navigationType:i}}))}function vG(t){let{children:e,location:n}=t;return NG(Cg(e),n)}function yG(t){kc()||bi(!1);let{basename:e,navigator:n}=A.exports.useContext(Tg),{hash:r,pathname:i,search:s}=bg(t),a=i;if(e!=="/"){let o=zG(t),l=o!=null&&o.endsWith("/");a=i==="/"?e+(l?"/":""):Vs([e,i])}return n.createHref({pathname:a,search:s,hash:r})}function kc(){return A.exports.useContext(vg)!=null}function Qo(){return kc()||bi(!1),A.exports.useContext(vg).location}function yg(){kc()||bi(!1);let{basename:t,navigator:e}=A.exports.useContext(Tg),{matches:n}=A.exports.useContext(Wo),{pathname:r}=Qo(),i=JSON.stringify(n.map(o=>o.pathnameBase)),s=A.exports.useRef(!1);return A.exports.useEffect(()=>{s.current=!0}),A.exports.useCallback(function(o,l){if(l===void 0&&(l={}),!s.current)return;if(typeof o=="number"){e.go(o);return}let c=DO(o,JSON.parse(i),r);t!=="/"&&(c.pathname=Vs([t,c.pathname])),(l.replace?e.replace:e.push)(c,l.state)},[t,e,i,r])}const bG=A.exports.createContext(null);function CG(t){let e=A.exports.useContext(Wo).outlet;return e&&A.exports.createElement(bG.Provider,{value:t},e)}function OO(){let{matches:t}=A.exports.useContext(Wo),e=t[t.length-1];return e?e.params:{}}function bg(t){let{matches:e}=A.exports.useContext(Wo),{pathname:n}=Qo(),r=JSON.stringify(e.map(i=>i.pathnameBase));return A.exports.useMemo(()=>DO(t,JSON.parse(r),n),[t,r,n])}function NG(t,e){kc()||bi(!1);let{matches:n}=A.exports.useContext(Wo),r=n[n.length-1],i=r?r.params:{};r&&r.pathname;let s=r?r.pathnameBase:"/";r&&r.route;let a=Qo(),o;if(e){var l;let _=typeof e=="string"?xa(e):e;s==="/"||((l=_.pathname)==null?void 0:l.startsWith(s))||bi(!1),o=_}else o=a;let c=o.pathname||"/",u=s==="/"?c:c.slice(s.length)||"/",d=IG(t,{pathname:u});return UG(d&&d.map(_=>Object.assign({},_,{params:Object.assign({},i,_.params),pathname:Vs([s,_.pathname]),pathnameBase:_.pathnameBase==="/"?s:Vs([s,_.pathnameBase])})),n)}function Cg(t){let e=[];return A.exports.Children.forEach(t,n=>{if(!A.exports.isValidElement(n))return;if(n.type===A.exports.Fragment){e.push.apply(e,Cg(n.props.children));return}n.type!==Rr&&bi(!1);let r={caseSensitive:n.props.caseSensitive,element:n.props.element,index:n.props.index,path:n.props.path};n.props.children&&(r.children=Cg(n.props.children)),e.push(r)}),e}function IG(t,e,n){n===void 0&&(n="/");let r=typeof e=="string"?xa(e):e,i=MO(r.pathname||"/",n);if(i==null)return null;let s=AO(t);RG(s);let a=null;for(let o=0;a==null&&o<s.length;++o)a=kG(s[o],i);return a}function AO(t,e,n,r){return e===void 0&&(e=[]),n===void 0&&(n=[]),r===void 0&&(r=""),t.forEach((i,s)=>{let a={relativePath:i.path||"",caseSensitive:i.caseSensitive===!0,childrenIndex:s,route:i};a.relativePath.startsWith("/")&&(a.relativePath.startsWith(r)||bi(!1),a.relativePath=a.relativePath.slice(r.length));let o=Vs([r,a.relativePath]),l=n.concat(a);i.children&&i.children.length>0&&(i.index===!0&&bi(!1),AO(i.children,e,l,o)),!(i.path==null&&!i.index)&&e.push({path:o,score:xG(o,i.index),routesMeta:l})}),e}function RG(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:PG(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const OG=/^:\w+$/,AG=3,wG=2,DG=1,MG=10,LG=-2,wO=t=>t==="*";function xG(t,e){let n=t.split("/"),r=n.length;return n.some(wO)&&(r+=LG),e&&(r+=wG),n.filter(i=>!wO(i)).reduce((i,s)=>i+(
* React Router DOM v6.2.1
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function b_(){return b_=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},b_.apply(this,arguments)}function LO(t,e){if(t==null)return{};var n={},r=Object.keys(t),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(n[i]=t[i]);return n}const qG=["onClick","reloadDocument","replace","state","target","to"],WG=["aria-current","caseSensitive","className","end","style","to","children"];function QG(t){let{basename:e,children:n,window:r}=t,i=A.exports.useRef();i.current==null&&(i.current=EG({window:r}));let s=i.current,[a,o]=A.exports.useState({action:s.action,location:s.location});return A.exports.useLayoutEffect(()=>s.listen(o),[s]),A.exports.createElement(TG,{basename:e,children:n,location:a.location,navigationType:a.action,navigator:s})}function KG(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}const Vr=A.exports.forwardRef(function(e,n){let{onClick:r,reloadDocument:i,replace:s=!1,state:a,target:o,to:l}=e,c=LO(e,qG),u=yG(l),d=XG(l,{replace:s,state:a,target:o});function _(p){r&&r(p),!p.defaultPrevented&&!i&&d(p)}return A.exports.createElement("a",b_({},c,{href:u,onClick:_,ref:n,target:o}))}),xO=A.exports.forwardRef(function(e,n){let{"aria-current":r="page",caseSensitive:i=!1,className:s="",end:a=!1,style:o,to:l,children:c}=e,u=LO(e,WG),d=Qo(),_=bg(l),p=d.pathname,f=_.pathname;i||(p=p.toLowerCase(),f=f.toLowerCase());let E=p===f||!a&&p.startsWith(f)&&p.charAt(f.length)==="/",h=E?r:void 0,m;typeof s=="function"?m=s({isActive:E}):m=[s,E?"active":null].filter(Boolean).join(" ");let g=typeof o=="function"?o({isActive:E}):o;return A.exports.createElement(Vr,b_({},u,{"aria-current":h,className:m,ref:n,style:g,to:l}),typeof c=="function"?c({isActive:E}):c)});function XG(t,e){let{target:n,replace:r,state:i}=e===void 0?{}:e,s=yg(),a=Qo(),o=bg(t);return A.exports.useCallback(l=>{if(l.button===0&&(!n||n==="_self")&&!KG(l)){l.preventDefault();let c=!!r||Sg(a)===Sg(o);s(t,{replace:c,state:i})}},[a,s,o,r,i,n,t])}let ZG=1;class Pa{constructor(){et(this,"nodeID");this.nodeID=ZG++}getID(){return this.nodeID}traverse(e,n){const r=n===void 0?[this]:[...n,this];this.traverseChildren(e,r),e.call(void 0,this,r)}traverseChildren(e,n){this.getChildren().forEach(i=>i.traverse(e,n))}getNodes(){const e=[];return this.traverse(n=>e.push(n)),e}sortRange(e){const n=e.start.node,r=e.end.node;if(n===r)return{start:{node:n,index:Math.min(e.start.index,e.end.index)},end:{node:r,index:Math.max(e.start.index,e.end.index)}};const i=n.getCommonAncestor(this,r);if(i===void 0)return e;let s=i.getNodes().indexOf(n),a=i.getNodes().indexOf(r);if(s<0||a<0)throw Error("Couldn't find caret range node(s) in this tree.");return s===void 0||a===void 0||s<a?e:s===a?{start:{node:e.start.node,index:Math.min(e.start.index,e.end.index)},end:{node:e.end.node,index:Math.max(e.start.index,e.end.index)}}:{start:e.end,end:e.start}}getNode(e){return this.getNodes().find(n=>n.getID()===e)}getIndexOf(e){const n=this.getNodes().indexOf(e);return n>=0?n:void 0}contains(e){let n=!1;return this.traverse(r=>{r===e&&(n=!0)}),n}getParentsOf(e){let n;if(this.traverse((i,s)=>{i===e&&(n=s)}),n===void 0)return;const r=[...n];return r.pop(),r}getParent(e){return e.getParentOf(this)}hasAncestor(e,n){let r=e.getParentOf(this);for(;r;){if(r===n)return!0;r=e.getParentOf(r)}return!1}getClosestParentOfType(e,n){let r=e.getParentOf(this);for(;r;){if(r instanceof n)return r;r=e.getParentOf(r)}}isInside(e,n){return this.getClosestParentMatching(e,r=>r instanceof n)!==void 0}getClosestParentMatching(e,n){let r=e.getParentOf(this);for(;r;){if(n.call(void 0,r))return r;r=e.getParentOf(r)}}getFarthestParentMatching(e,n){const r=this.getAncestors(e).filter(n);return r.length>0?r[r.length-1]:void 0}getAncestors(e){const n=[];let r=e.getParentOf(this);for(;r;)n.push(r),r=e.getParentOf(r);return n}getCommonAncestor(e,n){const r=this.getAncestors(e),i=n.getAncestors(e);for(let s=0;s<r.length;s++)for(let a=0;a<i.length;a++)if(r[s]===i[a])return r[s]}withNodeReplaced(e,n){if(e===this)return n;c
`):y(this,me).map(r=>(r instanceof pt?"":"*".repeat(n)+" ")+r.toBookdown(n+1)).join(`
`)}getParentOf(n){return y(this,me).map(r=>r===n?this:r.getParentOf(n)).find(r=>r!==void 0)}atBeginningOfItem(n,r){const i=r.node.getFarthestParentMatching(n,s=>s instanceof ue);return i!==void 0&&r.node.hasAncestor(n,this)&&r.index===0&&i.getTextNodes()[0]===r.node}getItemContaining(n){const r=y(this,me).find(s=>s.getParentOf(n.node)!==void 0);if(r===void 0)return;const i=y(this,me).indexOf(r);if(i!==void 0)return i}getItem(n){if(!(n<0||n>=y(this,me).length))return y(this,me)[n]}getFirstCaret(){return y(this,me).length===0?void 0:y(this,me)[0].getFirstCaret()}copy(){return new pt(y(this,me).map(n=>n.copy()),y(this,yn))}withStyle(n){return new pt(y(this,me),n)}withItemAppended(n){return new pt([...y(this,me),n],y(this,yn))}withItemPrepended(n){return new pt([n,...y(this,me)],y(this,yn))}withItemAt(n,r){if(r<0||r>y(this,me).length)return;const i=y(this,me).slice();return i.splice(r,0,n),new pt(i,y(this,yn))}withItemAfter(n,r){const i=y(this,me).indexOf(r);if(!(i<0))return this.withItemAt(n,i+1)}withItemBefore(n,r){const i=y(this,me).indexOf(r);if(!(i<0))return this.withItemAt(n,i)}withItemReplaced(n,r){if(n<0||n>=y(this,me).length)return;const i=y(this,me).slice();return i[n]=r,new pt(i,y(this,yn))}withoutItemAt(n){if(n<0||n>=y(this,me).length)return;const r=y(this,me).slice();return r.splice(n,1),new pt(r,y(this,yn))}withoutItem(n){const r=y(this,me).indexOf(n);if(!(r<0))return this.withoutItemAt(r)}withListAppended(n){return new pt([...y(this,me),...y(n,me)],y(this,yn))}withItemMergedBackwards(n){var s,a;if(n<=0||n>=y(this,me).length)return;const r=y(this,me)[n];let i=y(this,me)[n-1];if(r instanceof pt){if(i instanceof pt)return;const o=r.getFirstItem();if(o===void 0)return;const l=r.withChildReplaced(o,void 0);if(l===void 0)return;const c=this.withChildReplaced(r,l);if(c===void 0)return;const u=i.getLastCaret();if(u===void 0)return;const d=On(i,u);if(d===void 0)return;const _=i.withSegmentsAppended(o),p=c.withChildReplaced(i,_);if(p===void 0)return;const f=er(_,d);return f===void 0?void 0:[p,f]}else if(i instanceof pt){const o=i.getLastItem();if(o===void 0)return;const l=o.getLastCaret();if(l===void 0)return;const c=On(o,l);if(c===void 0)return;const u=o.withSegmentsAppended(r),d=i.withChildReplaced(o,u);if(d===void 0)return;const _=(s=this.withChildReplaced(i,d))==null?void 0:s.withoutItemAt(n);if(_===void 0)return;const p=er(u,c);return p===void 0?void 0:[_,p]}else{const o=i.getLastCaret();if(o===void 0)return;const l=On(i,o);if(l===void 0)return;const c=i.withSegmentsAppended(r),u=(a=this.withItemReplaced(n-1,c))==null?void 0:a.withoutItemAt(n);if(u===void 0)return;const d=er(c,l);return d===void 0?void 0:[u,d]}}withItemSplit(n){var o,l;const r=y(this,me).find(c=>c instanceof ue&&c.contains(n.node));if(r===void 0)return;const i=r.split(n);if(i===void 0)return;const[s,a]=i;return(l=(o=this.withItemAfter(a,r))==null?void 0:o.withItemAfter(s,r))==null?void 0:l.withoutItem(r)}withItemIndented(n){var r,i;for(let s=0;s<y(this,me).length;s++){const a=y(this,me)[s];if(a===n){const o=y(this,me)[s-1],l=y(this,me)[s+1];return o instanceof pt?(r=this.withItemReplaced(s-1,o.withItemAppended(n)))==null?void 0:r.withoutItemAt(s):l instanceof pt?(i=this.withItemReplaced(s+1,l.withItemPrepended(n)))==null?void 0:i.withoutItemAt(s):this.withItemReplaced(s,new pt([n],y(this,yn)))}else if(a instanceof pt){const o=a.withItemIndented(n);if(o!==void 0)return this.withItemReplaced(s,o)}}}withItemUnindented(n){for(let r=0;r<y(this,me).length;r++){const i=y(this,me)[r];if(i instanceof pt){const s=y(i,me).indexOf(n);if(s>=0){const a=new pt(y(i,me).slice(0,s),y(this,yn)),o=new pt(y(i,me).slice(s+1),y(this,yn));let l=y(this,me).slice(0,r);return a.getLength()>0&&l.push(a),l.push(n),o.getLength()>0&&l.push(o),l=l.concat(y(this,me).slice(r+1)),new pt(l,y(this,yn))}else{const a=i.withItemUnindented(n);if(a!==void 0)return this.withItemReplaced(r,a)}}}}withChildReplaced(n,r){const i=y(this,me).indexOf(n);if(!(i<0))return new pt(r===void 0?[...y(this,me).slice(0,i),...y(this,me).slice(i+1)]:[...y(this,me).slice(0,i),r,...y(this,me).slice(i+1)],y(th
`+y(this,bn).getText().replace(/`/g,"\\`")+"\n`"+(y(this,kr)!=="|"?y(this,kr):"")+y(this,Cn).toBookdown()}getChildren(){return[y(this,bn),y(this,Cn)]}copy(){return new Ss(y(this,bn).copy(),y(this,Sr),y(this,kr),y(this,Cn).copy())}getParentOf(n){return n==y(this,bn)||n===y(this,Cn)?this:y(this,Cn).getParentOf(n)}withChildReplaced(n,r){const i=n===y(this,bn)&&r instanceof Z?r:void 0,s=n===y(this,Cn)&&(r instanceof ue||r===void 0)?r:void 0;return i||s?new Ss(i||y(this,bn),y(this,Sr),y(this,kr),s||y(this,Cn)):void 0}withPosition(n){return new Ss(y(this,bn),y(this,Sr),n,y(this,Cn))}withLanguage(n){return new Ss(y(this,bn),n,y(this,kr),y(this,Cn))}withExecutable(n){return new Ss(y(this,bn),n?y(this,Sr)+"!":y(this,Sr),y(this,kr),y(this,Cn))}withCaption(n){return new Ss(y(this,bn),y(this,Sr),y(this,kr),n)}withContentInRange(n){if(!this.contains(n.start.node)&&!this.contains(n.end.node))return this.copy();const r=y(this,Cn).contains(n.start.node)?new Z:y(this,bn).withContentInRange(n),i=n.end.node===y(this,bn)?new ue("",[new Z]):y(this,Cn).withContentInRange(n);if(!(r===void 0||i===void 0))return new Ss(r,y(this,Sr),y(this,kr),i)}};let Ji=Ss;bn=new WeakMap,Cn=new WeakMap,kr=new WeakMap,Sr=new WeakMap,sd=new WeakMap;const po=class extends $n{constructor(n){super();it(this,At,void 0);const r=[];for(let i=0;i<n.length;i++){const s=n[i],a=i===0?void 0:n[i-1];s instanceof Wt&&a instanceof Wt&&s.isNumbered()===a.isNumbered()?r[r.length-1]=a.withListAppended(s):(!(s instanceof dt)&&(i===0||!(a instanceof dt))&&r.push(new dt),r.push(s))}r[r.length-1]instanceof dt||r.push(new dt),st(this,At,r)}getBlocks(){return y(this,At)}getFormats(){return this.getBlocks().reduce((n,r)=>n.concat(r.getFormats()),[])}getIndexOf(n){const r=y(this,At).indexOf(n);return r<0?void 0:r}getBlockBefore(n){const r=y(this,At).indexOf(n);if(!(r<=0))return y(this,At)[r-1]}getBlockAfter(n){const r=y(this,At).indexOf(n);if(!(r<0||r>y(this,At).length-2))return y(this,At)[r+1]}getBlocksBetween(n,r){const i=this.getIndexOf(n),s=this.getIndexOf(r);if(i!==void 0&&s!==void 0){if(i>s){const l=n;n=r,r=l}const a=[];let o=!1;for(let l=0;l<y(this,At).length;l++){let c=y(this,At)[l];if(c===n&&(o=!0),o&&a.push(c),c===r)break}return a}}getBlocksInRange(n){const r=this.getBlockOfCaret(n.start),i=n.end===n.start?r:this.getBlockOfCaret(n.end);if(r===void 0||i===void 0)return;const s=[];let a=!1;return this.getNodes().filter(o=>o instanceof $n).forEach(o=>{o===r&&(a=!0),a&&o instanceof $n&&s.push(o),a&&o===i&&(a=!1)}),s}getBlockOfCaret(n){return n.node.getClosestParentOfType(this,$n)}getParentOf(n){return y(this,At).map(r=>r===n?this:r.getParentOf(n)).find(r=>r!==void 0)}getTextNodes(){return this.getNodes().filter(n=>n instanceof Z)}getAtomNodes(){return this.getNodes().filter(n=>n instanceof ve)}getTextAndAtomNodes(){return this.getNodes().filter(n=>n instanceof Z||n instanceof ve)}getIndexOfTextNode(n){return this.getTextNodes().indexOf(n)}getFirstCaret(){const n=this.getTextNodes();return n.length===0?void 0:{node:n[0],index:0}}getLastCaret(){const n=this.getTextNodes();return n.length===0?void 0:{node:n[n.length-1],index:n[n.length-1].getLength()}}getAdjacentCaret(n,r){if(!this.contains(n.node))return;const i=n.node.getFarthestParentMatching(this,u=>u instanceof Ji);if(i&&n.node===i.getCodeNode()){const u=r?n.node.getNextCaret(n.index):n.node.getPreviousCaret(n.index);if(u!==void 0)return u;if(r)return i.getCaption().getFirstCaret();const d=this.getNodes().filter(h=>h instanceof $n),_=d.indexOf(i);if(_<=0)return;const f=d[_-1].getFormats();return f[f.length-1].getLastCaret()}const s=n.node.getFarthestParentMatching(this,u=>u instanceof ue);if(s===void 0)return;const a=s.getAdjacentCaret(n,r);if(a!==void 0)return a;const o=this.getNodes().filter(u=>{const d=u.getParent(this);return u instanceof Z&&d instanceof Ji||u instanceof ue&&!(d instanceof ve)&&!(d instanceof ue)}),l=o.indexOf(s),c=l<0||o.length===0?void 0:o[l+(r?1:-1)];if(c!==void 0)return r?c.getFirstCaret():c.getLastCaret()}getSelectedFormatRange(n,r){const i=this.getNodes().filter(_=>_ instanceof ue&&!(this.getParentOf(_
`+this.getBlocks().map(n=>n.toBookdown()).join(`
`)+`
=`+(y(this,Gi)!=="|"?y(this,Gi):"")}getChildren(){return this.getBlocks()}copy(){return new $l(this.getBlocks().map(n=>n.copy()),y(this,Gi))}withPosition(n){return new $l(this.getBlocks(),n)}withChildReplaced(n,r){const i=this.getBlocks().indexOf(n);if(i<0)return;const s=r===void 0?[...this.getBlocks().slice(0,i),...this.getBlocks().slice(i+1)]:[...this.getBlocks().slice(0,i),r,...this.getBlocks().slice(i+1)];return new $l(s,y(this,Gi))}create(n){return new $l(n,y(this,Gi))}};let Ko=$l;Gi=new WeakMap;const KC=class extends $n{constructor(n,r){super();it(this,mo,void 0);it(this,Yl,void 0);st(this,mo,n),st(this,Yl,r)}getType(){return"error"}getError(){return y(this,Yl)}getFormats(){return[]}toText(){return""}toBookdown(){return y(this,mo)?y(this,mo):""}getChildren(){return[]}getParentOf(n){}copy(){return new KC(y(this,mo),y(this,Yl))}withChildReplaced(){}withContentInRange(){return this.copy()}};let Qt=KC;mo=new WeakMap,Yl=new WeakMap;class Hs extends ve{constructor(e){super(e===void 0?new ue("",[new Z]):e.withTextIfEmpty())}getType(){return"footnote"}getDefaultCaret(){return this.getMeta().getFirstCaret()}toText(){return this.getMeta().toText()}toBookdown(){return`{${this.getMeta().toBookdown()}}`}copy(){return new Hs(this.getMeta().copy())}getParentOf(e){return e===this.getMeta()?this:this.getMeta().getParentOf(e)}withChildReplaced(e,n){return e===this.getMeta()&&n!==void 0?new Hs(n):void 0}withMeta(e){return new Hs(e)}withContentInRange(e){const n=this.getMeta().withContentInRange(e);if(n!==void 0)return this.withMeta(n)}}const Uc="*",pi=class extends $n{constructor(n,r,i,s,a="|"){super();it(this,pn,void 0);it(this,lr,void 0);it(this,Vt,void 0);it(this,Zt,void 0);it(this,Ur,void 0);st(this,pn,n),st(this,lr,r),st(this,Vt,i===void 0?new ue("",[new Z]):i.withTextIfEmpty()),st(this,Zt,s==null?new ue("",[new Z]):s.withTextIfEmpty()),st(this,Ur,a)}getType(){return"embed"}getURL(){return y(this,pn).split(Uc)[0]}getSmallURL(){return this.isLocal()?"images/small/"+this.getURL():this.hasSmallURL()?y(this,pn).split(Uc)[1]:this.getURL()}hasSmallURL(){return y(this,pn).split(Uc).length>1&&y(this,pn).split(Uc)[1].trim().length>0}isHosted(){return y(this,pn).includes("bookish")}isLocal(){return!y(this,pn).startsWith("http")}getDescription(){return y(this,lr)}getCaption(){return y(this,Vt)}getCredit(){return y(this,Zt)}getPosition(){return y(this,Ur)}getFormats(){return[y(this,Zt),y(this,Vt)]}getChildren(){return[y(this,Zt),y(this,Vt)]}getParentOf(n){if(n===y(this,Vt)||n===y(this,Zt))return this;const r=y(this,Vt).getParentOf(n);if(r)return r;const i=y(this,Zt).getParentOf(n);if(i)return i}toText(){return y(this,Vt).toText()}toBookdown(){return`|${y(this,pn)}|${y(this,lr)}|${y(this,Vt).toBookdown()}|${y(this,Zt).toBookdown()}|`}toJSON(){return{url:y(this,pn),alt:y(this,lr),caption:y(this,Vt).toText(),credit:y(this,Zt).toText()}}copy(){return new pi(y(this,pn),y(this,lr),y(this,Vt).copy(),y(this,Zt).copy(),y(this,Ur))}withChildReplaced(n,r){const i=n===y(this,Vt)&&(r===void 0||r instanceof ue)?r:y(this,Vt),s=n===y(this,Zt)&&(r===void 0||r instanceof ue)?r:y(this,Zt);return i||s?new pi(y(this,pn),y(this,lr),i,s,y(this,Ur)):void 0}withURL(n){return n.includes("www.youtube.com/watch?v=")&&(n=n.replace("/watch?v=","/embed/")),new pi(n,y(this,lr),y(this,Vt),y(this,Zt),y(this,Ur))}withURLs(n,r){return new pi(n+Uc+r,y(this,lr),y(this,Vt),y(this,Zt),y(this,Ur))}withDescription(n){return new pi(y(this,pn),n,y(this,Vt),y(this,Zt),y(this,Ur))}withCaption(n){return new pi(y(this,pn),y(this,lr),n,y(this,Zt),y(this,Ur))}withCredit(n){return new pi(y(this,pn),y(this,lr),y(this,Vt),n,y(this,Ur))}withPosition(n){return new pi(y(this,pn),y(this,lr),y(this,Vt),y(this,Zt),n)}withContentInRange(n){if(!this.contains(n.start.node)&&!this.contains(n.end.node))return this.copy();const r=y(this,Vt).contains(n.start.node)?new ue("",[new Z]):y(this,Zt).withContentInRange(n),i=y(this,Zt).contains(n.end.node)?new ue("",[new Z]):y(this,Vt).withContentInRange(n);if(!(i===void 0||r===void 0))return new pi(y(this,pn),y(this,lr),i,r,y(this,Ur))}};let Yn=pi;pn=new WeakMa
`).join("")+this.getBlocks().map(n=>n.toBookdown()).join(`
`)}getNextTextOrAtom(n){const r=this.getTextAndAtomNodes(),i=r.indexOf(n);return i===void 0?void 0:i<r.length-1?r[i+1]:void 0}getPreviousTextOrAtom(n){const r=this.getTextAndAtomNodes(),i=r.indexOf(n);return i===void 0?void 0:i>0?r[i-1]:void 0}getChildren(){return this.getBlocks()}withChildReplaced(n,r){const i=this.getBlocks().indexOf(n);if(i<0)return;const s=r===void 0?[...this.getBlocks().slice(0,i),...this.getBlocks().slice(i+1)]:[...this.getBlocks().slice(0,i),r,...this.getBlocks().slice(i+1)];return new ad(s,y(this,Ts))}copy(){return new ad(this.getBlocks().map(n=>n.copy()),y(this,Ts))}};let Xo=ad;Ts=new WeakMap;class es extends Ci{constructor(e,n=""){super(e===void 0?new Z:e,n)}getType(){return"definition"}toText(){return this.getText().toText()}toBookdown(){return`~${this.getText().toBookdown()}~${this.getMeta()}`}copy(){return new es(this.getText(),this.getMeta())}withMeta(e){return new es(this.getText(),e)}withText(e){return new es(e,this.getMeta())}}class ts extends Ci{constructor(e,n="plaintext"){super(e===void 0?new Z:e,n)}getType(){return"inline-code"}toText(){return this.getText().getText()}toBookdown(){return"`"+this.getText().toBookdown().replace(/`/g,"\\`")+"`"+(this.getMeta()==="plaintext"?"":this.getMeta())}copy(){return new ts(this.getText(),this.getMeta())}withMeta(e){return new ts(this.getText(),e)}withText(e){return new ts(e,this.getMeta())}}class ai extends Ci{constructor(e,n=""){super(e===void 0?new Z:e,n)}getType(){return"link"}toText(){return this.getText().toText()}toBookdown(){return`[${this.getText().toBookdown()}|${this.getMeta()}]`}copy(){return new ai(this.getText(),this.getMeta())}withMeta(e){return new ai(this.getText(),e)}withText(e){return new ai(e,this.getMeta())}}const ha=class extends js{constructor(n,r,i="|"){super(n);it(this,mn,void 0);it(this,mi,void 0);st(this,mi,i),st(this,mn,r===void 0?new ue("",[new Z]):r.withTextIfEmpty())}getType(){return"quote"}getCredit(){return y(this,mn)}getPosition(){return y(this,mi)}getFormats(){return[y(this,mn)]}toText(){return this.getBlocks().map(n=>n.toText()).join(" ")+(y(this,mn)?" "+y(this,mn).toText():"")}toBookdown(){return`"
${this.getBlocks().map(n=>n.toBookdown()).join(`
`)}
"${y(this,mi)==="|"?"":y(this,mi)}${y(this,mn)?y(this,mn).toBookdown():""}`}getChildren(){return[...this.getBlocks(),y(this,mn)]}getParentOf(n){if(n===y(this,mn))return this;const r=y(this,mn).getParentOf(n);return r!==void 0?r:super.getParentOf(n)}copy(){return new ha(this.getBlocks().map(n=>n.copy()))}create(n){return new ha(n,y(this,mn),y(this,mi))}withChildReplaced(n,r){if(y(this,mn)===n&&(r instanceof ue||r===void 0))return new ha(this.getBlocks(),r,y(this,mi));if(r!==void 0&&!(r instanceof $n))return;const i=this.getBlocks().indexOf(n);if(i<0)return;const s=r===void 0?[...this.getBlocks().slice(0,i),...this.getBlocks().slice(i+1)]:[...this.getBlocks().slice(0,i),r,...this.getBlocks().slice(i+1)];return new ha(s,y(this,mn),y(this,mi))}withCredit(n){return new ha(this.getBlocks(),n,y(this,mi))}withPosition(n){return new ha(this.getBlocks(),y(this,mn),n)}withContentInRange(n){const r=super.withContentInRange(n);if(r===void 0)return;const i=this.getBlocks().find(s=>s.contains(n.end.node))!==void 0?new ue("",[new Z]):y(this,mn).withContentInRange(n);return r.withNodeReplaced(y(this,mn),i)}};let Zo=ha;mn=new WeakMap,mi=new WeakMap;class Or extends Pa{constructor(n,r="",i="",s="",a="",o="",l="",c=!1){super();et(this,"citationID");et(this,"authors");et(this,"year");et(this,"title");et(this,"source");et(this,"url");et(this,"summary");et(this,"short");this.citationID=n,this.authors=r,this.year=i,this.title=s,this.source=a,this.url=o,this.summary=l,this.short=c}getType(){return"reference"}getChildren(){return[]}getParentOf(n){}toText(){return this.authors+" "+this.year+" "+this.title+" "+this.source+(this.summary?this.summary:"")}toBookdown(){return""}toList(){const n=[this.authors,this.year,this.title,this.source];return this.url&&n.push(this.url),this.summary&&n.push(this.summary),n}copy(){return new Or(this.citationID,this.authors,this.year,this.title,this.source,this.url,this.summary,this.short)}withChildReplaced(n,r){}withContentInRange(n){return this.copy()}withCitationID(n){return new Or(n,this.authors,this.year,this.title,this.source,this.url,this.summary,this.short)}withAuthors(n){return new Or(this.citationID,n,this.year,this.title,this.source,this.url,this.summary,this.short)}withYear(n){return new Or(this.citationID,this.authors,n,this.title,this.source,this.url,this.summary,this.short)}withTitle(n){return new Or(this.citationID,this.authors,this.year,n,this.source,this.url,this.summary,this.short)}withSource(n){return new Or(this.citationID,this.authors,this.year,this.title,n,this.url,this.summary,this.short)}withURL(n){return new Or(this.citationID,this.authors,this.year,this.title,this.source,n,this.summary,this.short)}withSummary(n){return new Or(this.citationID,this.authors,this.year,this.title,this.source,this.url,n,this.short)}}class Fc extends $n{constructor(){super()}getType(){return"rule"}toText(){return""}toBookdown(){return"-"}getChildren(){return[]}getParentOf(e){}getFormats(){return[]}copy(){return new Fc}withChildReplaced(e,n){}withContentInRange(e){return this.copy()}}const $i=class extends $n{constructor(n,r,i){super();it(this,Be,void 0);it(this,on,void 0);it(this,cr,void 0);st(this,Be,n.map(s=>s.map(a=>a.withTextIfEmpty()))),st(this,cr,r||"|"),st(this,on,i===void 0?new ue("",[new Z]):i.withTextIfEmpty())}getType(){return"table"}getRows(){return y(this,Be)}getRowCount(){return y(this,Be).length}getColumnCount(){return y(this,Be).length===0?0:y(this,Be)[0].length}getPosition(){return y(this,cr)}getCaption(){return y(this,on)}getFormats(){const n=[];return y(this,Be).forEach(r=>r.forEach(i=>{n.push(i)})),[...n,y(this,on)]}toText(){return y(this,Be).map(n=>n.map(r=>r.toText()).join(", ")).join(", ")}toBookdown(){return y(this,Be).map(n=>`,${n.map(r=>r.toBookdown()).join("|")}`).join(`
`)+`
${y(this,cr)==="|"?"":y(this,cr)}${y(this,on)?""+y(this,on).toBookdown():""}`}getChildren(){const n=[];return y(this,Be).forEach(r=>r.forEach(i=>n.push(i))),n.push(y(this,on)),n}locate(n){for(let r=0;r<y(this,Be).length;r++){const i=y(this,Be)[r];for(let s=0;s<i.length;s++)if(i[s]===n)return{row:r,column:s}}}getCell(n,r){return n>=0&&n<y(this,Be).length&&y(this,Be).length>0&&r>=0&&r<y(this,Be)[0].length?y(this,Be)[n][r]:void 0}getParentOf(n){for(let r=0;r<y(this,Be).length;r++){const i=y(this,Be)[r];for(let s=0;s<i.length;s++){if(i[s]===n)return this;const a=i[s].getParentOf(n);if(a!==void 0)return a}}return n===y(this,on)?this:y(this,on).getParentOf(n)}copy(){const n=[];return y(this,Be).forEach(r=>{const i=[];r.forEach(s=>i.push(s.copy())),n.push(i)}),new $i(n,y(this,cr),y(this,on)?y(this,on).copy():void 0)}withChildReplaced(n,r){if(n===y(this,on)&&(r instanceof ue||r===void 0))return new $i(y(this,Be),y(this,cr),r);if(n instanceof ue&&r instanceof ue){let i=0,s=-1;for(;i<y(this,Be).length&&(s=y(this,Be)[i].indexOf(n),!(s>=0));i++);if(i<y(this,Be).length&&s>=0){const a=y(this,Be).map(o=>[...o]);return a[i][s]=r,new $i(a,y(this,cr),y(this,on))}}}withNewRow(n){if(n<0||n>y(this,Be).length)return;const r=y(this,Be).length===0?0:y(this,Be)[0].length,i=[];for(let a=0;a<r;a++)i.push(new ue("",[new Z]));const s=y(this,Be).slice();return s.splice(n,0,i),new $i(s,y(this,cr),y(this,on))}withoutRow(n){if(n<0||n>=y(this,Be).length)return;const r=y(this,Be).slice();return r.splice(n,1),new $i(r,y(this,cr),y(this,on))}withoutColumn(n){if(n<0||n>=this.getColumnCount())return;const r=y(this,Be).slice();for(let i=0;i<y(this,Be).length;i++)r[i].splice(n,1);return new $i(r,y(this,cr),y(this,on))}withNewColumn(n){if(y(this,Be).length>0&&(n<0||n>y(this,Be)[0].length))return;const r=y(this,Be).slice();for(let i=0;i<y(this,Be).length;i++)r[i]=r[i].slice(),r[i].splice(n,0,new ue("",[new Z]));return new $i(r,y(this,cr),y(this,on))}withContentInRange(n){const r=this.contains(n.start.node),i=this.contains(n.end.node);if(!r&&!i)return this.copy();let s=0,a=0,o=!1,l=!1,c=[];for(;s<y(this,Be).length;s++,a=0){const d=y(this,Be)[s];if(!(r&&!o&&d.find(_=>_.contains(n.start.node))===void 0)){if(i&&l)break;for(c.push([]);a<d.length;a++){!o&&d[a].contains(n.start.node)&&(o=!0);const _=d[a].withContentInRange(n);if(_===void 0)return;c[c.length-1].push((r&&o||!r)&&(i&&!l||!i)?_:new ue("",[new Z])),d[a].contains(n.end.node)&&(l=!0)}}}const u=y(this,on).withContentInRange(n);if(u!==void 0)return new $i(c,y(this,cr),u)}};let Jo=$i;Be=new WeakMap,on=new WeakMap,cr=new WeakMap;const C_=/^[0-9]+\.+/,BO=/^\*+\s+/;class qe{constructor(e,n){et(this,"book");et(this,"text");et(this,"index");et(this,"openedDoubleQuote");et(this,"metadata");if(typeof n!="string")throw"Parser expected a string but received "+typeof n;this.book=e,this.text=n,this.index=0,this.openedDoubleQuote=!1,this.metadata={symbols:{}}}static preprocessSymbols(e,n){if(e&&e.getSymbols())for(const[r,i]of Object.entries(e.getSymbols()))n=n.replace(new RegExp("([^\\\\])@"+r+"\\b","g"),"$1"+i);return n}static parseChapter(e,n){return new qe(e,e===void 0?n:qe.preprocessSymbols(e,n)).parseChapter()}static parseFormat(e,n){return new qe(e,e===void 0?n:qe.preprocessSymbols(e,n)).parseFormat()}static parseEmbed(e,n){return new qe(e,e===void 0?n:qe.preprocessSymbols(e,n)).parseEmbed()}static parseReference(e,n,r,i=!1){if(typeof n=="string")return qe.parseFormat(r,n);if(Array.isArray(n))if(n.length>=4){let s=n[0],a=n[1],o=n[2],l=n[3],c=n.length===5?n[4]:"",u=n.length===6?n[5]:"";if(l.charAt(0)==="#"){let d=r.getSource(l);if(d===null)return new Qt(void 0,"Unknown source "+l);l=d}return new Or(e,s,a,o,l,c,u,i)}else return new Qt(void 0,"Expected at least 4 items in the reference array, but found "+n.length+": "+n.toString());else return new Qt(void 0,"Invalid reference: "+n)}peek(){return this.more()?this.text.charAt(this.index):null}more(){return this.index<this.text.length}read(e=!0){if(!this.more())return null;let n=this.text.charAt(this.index);return e&&(n===`
`&&(this.openedDoubleQuote=!1),n==='"'?(this.openedDoubleQuote?n="\u201D":n="\u201C",this.openedDoubleQuote=!this.openedDoubleQuote):n==="'"&&(/\s/.test(this.text.charAt(this.index-1))?n="\u2018":n="\u2019"),n==="-"&&this.text.charAt(this.index+1)==="-"&&this.text.charAt(this.index)!==`
`&&(this.index++,n="\u2014")),this.index++,n}unread(){this.index--}rest(){return this.text.substring(this.index)}charBeforeNext(){return this.index===0?null:this.text.charAt(this.index-1)}charAfterNext(){return this.index===this.text.length-1?null:this.text.charAt(this.index+1)}restOfLine(){const e=this.text.substring(this.index).indexOf(`
`)+this.index;return e<0?this.text.substring(this.index):this.text.substring(this.index,Math.max(this.index,e))}nextIs(e){return this.more()?this.text.substring(this.index,this.index+e.length)===e:!1}nextIsContentDelimiter(){const e=this.peek(),n=this.charAfterNext();return e===`
`||e==="_"||e==="*"||e==="`"||e==="@"||e==="~"||e===":"&&n!==null&&n.match(/[a-z]/i)!==null||e==="^"||e==="<"||e==="{"||this.charBeforeNext()===" "&&e==="%"||e==="["||e==="\\"}nextMatches(e){return this.more()?e.test(this.rest()):!1}isBlankLine(){return this.restOfLine().trim()===""}readWhitespace(){let e=this.peek();for(;e!==null&&/^[ \t]/.test(e);)this.read(),e=this.peek()}readUntilNewLine(){let e="";for(;this.more()&&this.peek()!==`
`;)e=e+this.read();return e}readUntilNewlineOr(e){let n="";for(;this.more()&&!this.nextIs(`
`)&&!this.nextIs(e);)n=n+this.read();return n}parseChapter(){let e=[];this.parseSymbols();let n=this.text.substring(0,this.index),r=this.rest();for(const[s,a]of Object.entries(this.metadata.symbols))r=r.replace(new RegExp("([^\\\\])@"+s+"\\b","g"),"$1"+a);this.book&&(r=qe.preprocessSymbols(this.book,r)),this.text=n+r;let i=0;for(;this.more();)for(i=0,e.push(this.parseBlock());this.peek()===" "||this.peek()===" "||this.peek()===`
`;)this.peek()===`
`&&i++,this.read();return(e.length===0||i>1)&&e.push(new dt),new Xo(e,this.metadata)}parseSymbols(){for(this.readWhitespace();this.nextIs("@");){this.read();let e=this.readUntilNewlineOr(":");if(!/^[a-zA-Z0-9]+$/.test(e)){new Qt(this.readUntilNewLine(),e.trim()===""?"Did you mean to declare a symbol? Use an @ symbol, then a name of only numbers and letters, then a colon, then whatever content you want it to represent.":"'"+e+"' isn't a valid name for a symbol; letters and numbers only");return}if(this.readWhitespace(),!this.nextIs(":")){new Qt(this.readUntilNewLine(),"Symbol names are to be followed by a ':'");return}this.read(),this.readWhitespace();let n=this.index;for(this.parseBlock(),this.metadata.symbols[e]=this.text.substring(n,this.index).trim();this.peek()===" "||this.peek()===" "||this.peek()===`
`;)this.read()}}parseBlock(){for(this.readWhitespace();this.nextIs("%");)this.readUntilNewLine();return this.nextIs("#")?this.parseHeader():this.nextIs("-")?this.parseRule():this.nextIs("|")?this.parseEmbed():this.nextMatches(BO)||this.nextMatches(C_)?this.parseList():this.nextMatches(/^`[a-zA-Z!]*[ \t]*\n/)?this.parseCode():this.nextMatches(/^"[ \t]*\n/)?this.parseQuote():this.nextMatches(/^=[ \t]*\n/)?this.parseCallout():this.nextIs(",")?this.parseTable():this.parseParagraph()}parseParagraph(){return new dt(0,this.parseFormat())}parseHeader(){let e=0;for(;this.nextIs("#");)this.read(),e++;return this.readWhitespace(),new dt(Math.min(3,e),this.parseFormat())}parseRule(){return this.readUntilNewLine(),new Fc}parseList(){let e=this.nextMatches(C_);const n=[];let r,i;for(;this.nextMatches(C_)||this.nextMatches(BO);){e=this.nextMatches(C_),r=i,i=0;let s;if(e)for(s=this.index,this.readUntilNewlineOr("."),s=this.index-s;this.nextIs(".");)this.read(),i++;else for(i=0;this.nextIs("*");)this.read(),i++;if(r===void 0||r===i){this.readWhitespace();const a=this.parseFormat();n.push(a.isEmpty()?a.withSegmentAppended(new Z):a)}else{let a=i;for(;a>0;)this.unread(),a--;if(s!==void 0)for(;s>0;)this.unread(),s--;if(i<r)break;n.push(this.parseList()),i=r}for(this.readWhitespace();this.peek()===`
`;)this.read(),this.readWhitespace()}return new Wt(n,e)}parseCode(){this.read();let e=this.readUntilNewLine();this.read();let n="";for(;this.more()&&!this.nextIs("`");){let s=this.read(!1);s==="\\"&&this.nextIs("`")&&(this.read(),s="`"),n=n+s}n=n.trim(),this.nextIs("`")&&this.read();let r=this.parsePosition();const i=this.parseFormat();return new Ji(new Z(n),e,r,i)}parsePosition(){let e="|";return this.nextIs("<")?(e="<",this.read()):this.nextIs(">")&&(e=">",this.read()),e}parseQuote(){const e=[];for(this.read(),this.readWhitespace(),this.read();this.more()&&!this.nextIs('"');){const i=this.parseBlock();for(i!==null&&e.push(i);this.peek()===" "||this.peek()===" "||this.peek()===`
`;)this.read()}this.read();const n=this.parsePosition();this.readWhitespace();const r=this.nextIs(`
`)?void 0:this.parseFormat();return new Zo(e,r,n)}parseCallout(){const e=[];for(this.read(),this.readWhitespace(),this.read();this.more()&&!this.nextIs("=");){const r=this.parseBlock();for(r!==null&&e.push(r);this.peek()===" "||this.peek()===" "||this.peek()===`
`;)this.read()}this.read();const n=this.parsePosition();return this.readWhitespace(),new Ko(e,n)}parseTable(){const e=[];for(;this.more()&&this.nextIs(",");){let i=[];for(;this.more()&&!this.nextIs(`
`);)this.read(),this.readWhitespace(),i.push(this.parseFormat("|"));e.push(i),this.read()}const n=this.parsePosition(),r=this.parseFormat();return new Jo(e,n,r)}parseFormat(e){const n=[];for(;this.more()&&!this.nextIs(`
`);){const r=this.peek(),i=this.charAfterNext();if(r==="_"||r==="*"||r==="^")n.push(this.parseStyle(r));else if(this.nextIs("`"))n.push(this.parseInlineCode());else if(this.nextIs("<"))n.push(this.parseCitations());else if(this.nextIs("{"))n.push(this.parseFootnote());else if(this.nextIs("~"))n.push(this.parseDefinition());else if(this.nextIs("\\"))n.push(this.parseEscaped());else if(this.nextIs("["))n.push(this.parseLink());else if(this.charBeforeNext()===" "&&this.nextIs("%"))n.push(this.parseComment());else if(r==="@"){this.read();let s="",a=this.peek();for(;a!==null&&/[a-zA-Z0-9]/.test(a);)s=s+this.read(),a=this.peek();n.push(new Qt(void 0,"Couldn't find symbol @"+s))}else if(r===":"&&i!==null&&i.match(/[a-z]/i))n.push(this.parseLabel());else{let s="";for(;this.more()&&(!e||!this.nextIs(e))&&!this.nextIsContentDelimiter()&&!this.nextIs(`
`);)s=s+this.read();n.push(new Z(s))}if(this.peek()===e)break}return new ue("",n)}parseEmbed(){this.read();const e=this.readUntilNewlineOr("|");if(this.peek()!=="|")return new Qt(this.readUntilNewLine(),"Missing '|' after URL in embed");this.read();const n=this.readUntilNewlineOr("|");if(this.peek()!=="|")return new Qt(this.readUntilNewLine(),"Missing '|' after description in embed");this.read();const r=this.parseFormat("|");if(this.peek()!=="|")return new Qt(this.readUntilNewLine(),"Missing '|' after caption in embed");this.read();const i=this.parseFormat("|");if(this.peek()!=="|")return new Qt(this.readUntilNewLine(),"Missing '|' after credit in embed.");this.read();const s=this.parsePosition();return new Yn(e,n,r,i,s)}parseComment(){this.read();const e=this.parseFormat("%");return this.peek()==="%"&&this.read(),new Qs(e)}parseLabel(){this.read();let e="",n=this.peek();for(;n!==null&&n.match(/[a-z]/i);)e=e+this.read(),n=this.peek();return new Ws(e)}parseStyle(e){const n=this.read();let r=!1;const i=[];let s="";if(this.peek()==="v"&&(this.read(),r=!0),n===null)return new Qt(void 0,"Somehow parsing formatted text at end of file.");for(;this.more()&&this.peek()!==n&&!this.nextIs(`
`);)this.nextIsContentDelimiter()?(s!==""&&i.push(new Z(s)),i.push(this.parseFormat(e)),s=""):s=s+this.read();return s!==""&&i.push(new Z(s)),this.nextIs(n)?this.read():i.push(new Qt(void 0,"Unclosed "+n)),new ue(r?"v":n,i)}parseInlineCode(){this.read();let e="";for(;this.more()&&!this.nextIs("`");){let i=this.read(!1);i==="\\"&&this.nextIs("`")&&(this.read(),i="`"),e=e+i}this.nextIs("`")&&this.read();let n="",r=this.peek();if(r!==null&&/^[a-z]$/.test(r))do n=n+this.read(),r=this.peek();while(r!==null&&/^[a-z]$/.test(r));else n="plaintext";return new ts(new Z(e),n)}parseCitations(){let e="";this.read(),e=this.readUntilNewlineOr(">"),this.peek()===">"&&this.read();const n=e.split(",").map(r=>r.trim()).filter(r=>r.length>0);return new qs(n)}parseFootnote(){this.read();const e=this.parseFormat("}");return this.read(),new Hs(e)}parseDefinition(){this.read();const e=this.readUntilNewlineOr("~");this.read();let n="",r=this.peek();for(;r!==null&&/[a-zA-Z]/.test(r);)n=n+this.read(),r=this.peek();return new es(new Z(e),n)}parseEscaped(){this.read();const e=this.read();return e?new Z(e):new Qt(void 0,"Unterminated escape.")}parseLink(){this.read();const e=this.readUntilNewlineOr("|");if(this.peek()!=="|")return this.readUntilNewLine(),new Qt(void 0,"Missing '|' in link");this.read();let n=this.readUntilNewlineOr("]");return this.peek()!=="]"?(this.readUntilNewLine(),new Qt(void 0,"Missing ] in link")):(this.read(),new ai(new Z(e),n))}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*//**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const GO=function(t){const e=[];let n=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);i<128?e[n++]=i:i<2048?(e[n++]=i>>6|192,e[n++]=i&63|128):(i&64512)===55296&&r+1<t.length&&(t.charCodeAt(r+1)&64512)===56320?(i=65536+((i&1023)<<10)+(t.charCodeAt(++r)&1023),e[n++]=i>>18|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128,e[n++]=i&63|128):(e[n++]=i>>12|224,e[n++]=i>>6&63|128,e[n++]=i&63|128)}return e},JG=function(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n++];if(i<128)e[r++]=String.fromCharCode(i);else if(i>191&&i<224){const s=t[n++];e[r++]=String.fromCharCode((i&31)<<6|s&63)}else if(i>239&&i<365){const s=t[n++],a=t[n++],o=t[n++],l=((i&7)<<18|(s&63)<<12|(a&63)<<6|o&63)-65536;e[r++]=String.fromCharCode(55296+(l>>10)),e[r++]=String.fromCharCode(56320+(l&1023))}else{const s=t[n++],a=t[n++];e[r++]=String.fromCharCode((i&15)<<12|(s&63)<<6|a&63)}}return e.join("")},$O={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let i=0;i<t.length;i+=3){const s=t[i],a=i+1<t.length,o=a?t[i+1]:0,l=i+2<t.length,c=l?t[i+2]:0,u=s>>2,d=(s&3)<<4|o>>4;let _=(o&15)<<2|c>>6,p=c&63;l||(p=64,a||(_=64)),r.push(n[u],n[d],n[_],n[p])}return r.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(GO(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):JG(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let i=0;i<t.length;){const s=n[t.charAt(i++)],o=i<t.length?n[t.charAt(i)]:0;++i;const c=i<t.length?n[t.charAt(i)]:64;++i;const d=i<t.length?n[t.charAt(i)]:64;if(++i,s==null||o==null||c==null||d==null)throw Error();const _=s<<2|o>>4;if(r.push(_),c!==64){const p=o<<4&240|c>>2;if(r.push(p),d!==64){const f=c<<6&192|d;r.push(f)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}},e$=function(t){const e=GO(t);return $O.encodeByteArray(e,!0)},N_=function(t){return e$(t).replace(/\./g,"")},t$=function(t){try{return $O.decodeString(t,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class n${constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,n)=>{this.resolve=e,this.reject=n})}wrapCallback(e){return(n,r)=>{n?this.reject(n):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(n):e(n,r))}}}/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function YO(t,e){if(t.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n={alg:"none",type:"JWT"},r=e||"demo-project",i=t.iat||0,s=t.sub||t.user_id;if(!s)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const a=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:i,exp:i+3600,auth_time:i,sub:s,user_id:s,firebase:{sign_in_provider:"custom",identities:{}}},t),o="";return[N_(JSON.stringify(n)),N_(JSON.stringify(a)),o].join(".")}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function gn(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function zO(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(gn())}function VO(){const t=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof t=="object"&&t.id!==void 0}function jO(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function r$(){return gn().indexOf("Electron/")>=0}function HO(){const t=gn();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function i$(){return gn().indexOf("MSAppHost/")>=0}function s$(){return typeof indexedDB=="object"}function a$(){return new Promise((t,e)=>{try{let n=!0;const r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),t(!0)},i.onupgradeneeded=()=>{n=!1},i.onerror=()=>{var s;e(((s=i.error)===null||s===void 0?void 0:s.message)||"")}}catch(n){e(n)}})}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const o$="FirebaseError";class Ni extends Error{constructor(e,n,r){super(n),this.code=e,this.customData=r,this.name=o$,Object.setPrototypeOf(this,Ni.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Bc.prototype.create)}}class Bc{constructor(e,n,r){this.service=e,this.serviceName=n,this.errors=r}create(e,...n){const r=n[0]||{},i=`${this.service}/${e}`,s=this.errors[e],a=s?l$(s,r):"Error",o=`${this.serviceName}: ${a} (${i}).`;return new Ni(i,o,r)}}function l$(t,e){return t.replace(c$,(n,r)=>{const i=e[r];return i!=null?String(i):`<${r}?>`})}const c$=/\{\$([^}]+)}/g;function u$(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function I_(t,e){if(t===e)return!0;const n=Object.keys(t),r=Object.keys(e);for(const i of n){if(!r.includes(i))return!1;const s=t[i],a=e[i];if(qO(s)&&qO(a)){if(!I_(s,a))return!1}else if(s!==a)return!1}for(const i of r)if(!n.includes(i))return!1;return!0}function qO(t){return t!==null&&typeof t=="object"}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Gc(t){const e=[];for(const[n,r]of Object.entries(t))Array.isArray(r)?r.forEach(i=>{e.push(encodeURIComponent(n)+"="+encodeURIComponent(i))}):e.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function d$(t,e){const n=new _$(t,e);return n.subscribe.bind(n)}class _${constructor(e,n){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=n,this.task.then(()=>{e(this)}).catch(r=>{this.error(r)})}next(e){this.forEachObserver(n=>{n.next(e)})}error(e){this.forEachObserver(n=>{n.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,n,r){let i;if(e===void 0&&n===void 0&&r===void 0)throw new Error("Missing Observer.");p$(e,["next","error","complete"])?i=e:i={next:e,error:n,complete:r},i.next===void 0&&(i.next=Ig),i.error===void 0&&(i.error=Ig),i.complete===void 0&&(i.complete=Ig);const s=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?i.error(this.finalError):i.complete()}catch{}}),this.observers.push(i),s}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let n=0;n<this.observers.length;n++)this.sendOne(n,e)}sendOne(e,n){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{n(this.observers[e])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function p$(t,e){if(typeof t!="object"||t===null)return!1;for(const n of e)if(n in t&&typeof t[n]=="function")return!0;return!1}function Ig(){}/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Ii(t){return t&&t._delegate?t._delegate:t}class Ks{constructor(e,n,r){this.name=e,this.instanceFactory=n,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const ka="[DEFAULT]";/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class m${constructor(e,n){this.name=e,this.container=n,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const n=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(n)){const r=new n$;if(this.instancesDeferred.set(n,r),this.isInitialized(n)||this.shouldAutoInitialize())try{const i=this.getOrInitializeService({instanceIdentifier:n});i&&r.resolve(i)}catch{}}return this.instancesDeferred.get(n).promise}getImmediate(e){var n;const r=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),i=(n=e==null?void 0:e.optional)!==null&&n!==void 0?n:!1;if(this.isInitialized(r)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:r})}catch(s){if(i)return null;throw s}else{if(i)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(h$(e))try{this.getOrInitializeService({instanceIdentifier:ka})}catch{}for(const[n,r]of this.instancesDeferred.entries()){const i=this.normalizeInstanceIdentifier(n);try{const s=this.getOrInitializeService({instanceIdentifier:i});r.resolve(s)}catch{}}}}clearInstance(e=ka){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(n=>"INTERNAL"in n).map(n=>n.INTERNAL.delete()),...e.filter(n=>"_delete"in n).map(n=>n._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=ka){return this.instances.has(e)}getOptions(e=ka){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:n={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const i=this.getOrInitializeService({instanceIdentifier:r,options:n});for(const[s,a]of this.instancesDeferred.entries()){const o=this.normalizeInstanceIdentifier(s);r===o&&a.resolve(i)}return i}onInit(e,n){var r;const i=this.normalizeInstanceIdentifier(n),s=(r=this.onInitCallbacks.get(i))!==null&&r!==void 0?r:new Set;s.add(e),this.onInitCallbacks.set(i,s);const a=this.instances.get(i);return a&&e(a,i),()=>{s.delete(e)}}invokeOnInitCallbacks(e,n){const r=this.onInitCallbacks.get(n);if(!!r)for(const i of r)try{i(e,n)}catch{}}getOrInitializeService({instanceIdentifier:e,options:n={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:f$(e),options:n}),this.instances.set(e,r),this.instancesOptions.set(e,n),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=ka){return this.component?this.component.multipleInstances?e:ka:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function f$(t){return t===ka?void 0:t}function h$(t){return t.instantiationMode==="EAGER"}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class g${constructor(e){this.name=e,this.providers=new Map}addComponent(e){const n=this.getProvider(e.name);if(n.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);n.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const n=new m$(e,this);return this.providers.set(e,n),n}getProviders(){return Array.from(this.providers.values())}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var nt;(function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"})(nt||(nt={}));const E$={debug:nt.DEBUG,verbose:nt.VERBOSE,info:nt.INFO,warn:nt.WARN,error:nt.ERROR,silent:nt.SILENT},S$=nt.INFO,T$={[nt.DEBUG]:"log",[nt.VERBOSE]:"log",[nt.INFO]:"info",[nt.WARN]:"warn",[nt.ERROR]:"error"},v$=(t,e,...n)=>{if(e<t.logLevel)return;const r=new Date().toISOString(),i=T$[e];if(i)console[i](`[${r}] ${t.name}:`,...n);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class Rg{constructor(e){this.name=e,this._logLevel=S$,this._logHandler=v$,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in nt))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?E$[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")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,nt.DEBUG,...e),this._logHandler(this,nt.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,nt.VERBOSE,...e),this._logHandler(this,nt.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,nt.INFO,...e),this._logHandler(this,nt.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,nt.WARN,...e),this._logHandler(this,nt.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,nt.ERROR,...e),this._logHandler(this,nt.ERROR,...e)}}const y$=(t,e)=>e.some(n=>t instanceof n);let WO,QO;function b$(){return WO||(WO=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function C$(){return QO||(QO=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const KO=new WeakMap,Og=new WeakMap,XO=new WeakMap,Ag=new WeakMap,wg=new WeakMap;function N$(t){const e=new Promise((n,r)=>{const i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",a)},s=()=>{n(Xs(t.result)),i()},a=()=>{r(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",a)});return e.then(n=>{n instanceof IDBCursor&&KO.set(n,t)}).catch(()=>{}),wg.set(e,t),e}function I$(t){if(Og.has(t))return;const e=new Promise((n,r)=>{const i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",a),t.removeEventListener("abort",a)},s=()=>{n(),i()},a=()=>{r(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",s),t.addEventListener("error",a),t.addEventListener("abort",a)});Og.set(t,e)}let Dg={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return Og.get(t);if(e==="objectStoreNames")return t.objectStoreNames||XO.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Xs(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function R$(t){Dg=t(Dg)}function O$(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...n){const r=t.call(Mg(this),e,...n);return XO.set(r,e.sort?e.sort():[e]),Xs(r)}:C$().includes(t)?function(...e){return t.apply(Mg(this),e),Xs(KO.get(this))}:function(...e){return Xs(t.apply(Mg(this),e))}}function A$(t){return typeof t=="function"?O$(t):(t instanceof IDBTransaction&&I$(t),y$(t,b$())?new Proxy(t,Dg):t)}function Xs(t){if(t instanceof IDBRequest)return N$(t);if(Ag.has(t))return Ag.get(t);const e=A$(t);return e!==t&&(Ag.set(t,e),wg.set(e,t)),e}const Mg=t=>wg.get(t);function w$(t,e,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){const a=indexedDB.open(t,e),o=Xs(a);return r&&a.addEventListener("upgradeneeded",l=>{r(Xs(a.result),l.oldVersion,l.newVersion,Xs(a.transaction))}),n&&a.addEventListener("blocked",()=>n()),o.then(l=>{s&&l.addEventListener("close",()=>s()),i&&l.addEventListener("versio
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class L${constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(n=>{if(x$(n)){const r=n.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(n=>n).join(" ")}}function x$(t){const e=t.getComponent();return(e==null?void 0:e.type)==="VERSION"}const xg="@firebase/app",JO="0.7.32";/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const Ua=new Rg("@firebase/app"),P$="@firebase/app-compat",k$="@firebase/analytics-compat",U$="@firebase/analytics",F$="@firebase/app-check-compat",B$="@firebase/app-check",G$="@firebase/auth",$$="@firebase/auth-compat",Y$="@firebase/database",z$="@firebase/database-compat",V$="@firebase/functions",j$="@firebase/functions-compat",H$="@firebase/installations",q$="@firebase/installations-compat",W$="@firebase/messaging",Q$="@firebase/messaging-compat",K$="@firebase/performance",X$="@firebase/performance-compat",Z$="@firebase/remote-config",J$="@firebase/remote-config-compat",eY="@firebase/storage",tY="@firebase/storage-compat",nY="@firebase/firestore",rY="@firebase/firestore-compat",iY="firebase",sY="9.9.4";/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const eA="[DEFAULT]",aY={[xg]:"fire-core",[P$]:"fire-core-compat",[U$]:"fire-analytics",[k$]:"fire-analytics-compat",[B$]:"fire-app-check",[F$]:"fire-app-check-compat",[G$]:"fire-auth",[$$]:"fire-auth-compat",[Y$]:"fire-rtdb",[z$]:"fire-rtdb-compat",[V$]:"fire-fn",[j$]:"fire-fn-compat",[H$]:"fire-iid",[q$]:"fire-iid-compat",[W$]:"fire-fcm",[Q$]:"fire-fcm-compat",[K$]:"fire-perf",[X$]:"fire-perf-compat",[Z$]:"fire-rc",[J$]:"fire-rc-compat",[eY]:"fire-gcs",[tY]:"fire-gcs-compat",[nY]:"fire-fst",[rY]:"fire-fst-compat","fire-js":"fire-js",[iY]:"fire-js-all"};/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const R_=new Map,Pg=new Map;function oY(t,e){try{t.container.addComponent(e)}catch(n){Ua.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n)}}function Fa(t){const e=t.name;if(Pg.has(e))return Ua.debug(`There were multiple attempts to register component ${e}.`),!1;Pg.set(e,t);for(const n of R_.values())oY(n,t);return!0}function O_(t,e){const n=t.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),t.container.getProvider(e)}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const lY={["no-app"]:"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()",["bad-app-name"]:"Illegal App name: '{$appName}",["duplicate-app"]:"Firebase App named '{$appName}' already exists with different options or config",["app-deleted"]:"Firebase App named '{$appName}' already deleted",["invalid-app-argument"]:"firebase.{$appName}() takes either no argument or a Firebase App instance.",["invalid-log-argument"]:"First argument to `onLog` must be null or a function.",["idb-open"]:"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.",["idb-get"]:"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.",["idb-set"]:"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.",["idb-delete"]:"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}."},Ba=new Bc("app","Firebase",lY);/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class cY{constructor(e,n,r){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},n),this._name=n.name,this._automaticDataCollectionEnabled=n.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new Ks("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw Ba.create("app-deleted",{appName:this._name})}}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const el=sY;function uY(t,e={}){typeof e!="object"&&(e={name:e});const n=Object.assign({name:eA,automaticDataCollectionEnabled:!1},e),r=n.name;if(typeof r!="string"||!r)throw Ba.create("bad-app-name",{appName:String(r)});const i=R_.get(r);if(i){if(I_(t,i.options)&&I_(n,i.config))return i;throw Ba.create("duplicate-app",{appName:r})}const s=new g$(r);for(const o of Pg.values())s.addComponent(o);const a=new cY(t,n,s);return R_.set(r,a),a}function kg(t=eA){const e=R_.get(t);if(!e)throw Ba.create("no-app",{appName:t});return e}function Ri(t,e,n){var r;let i=(r=aY[t])!==null&&r!==void 0?r:t;n&&(i+=`-${n}`);const s=i.match(/\s|\//),a=e.match(/\s|\//);if(s||a){const o=[`Unable to register library "${i}" with version "${e}":`];s&&o.push(`library name "${i}" contains illegal characters (whitespace or "/")`),s&&a&&o.push("and"),a&&o.push(`version name "${e}" contains illegal characters (whitespace or "/")`),Ua.warn(o.join(" "));return}Fa(new Ks(`${i}-version`,()=>({library:i,version:e}),"VERSION"))}/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const dY="firebase-heartbeat-database",_Y=1,$c="firebase-heartbeat-store";let Ug=null;function tA(){return Ug||(Ug=w$(dY,_Y,{upgrade:(t,e)=>{switch(e){case 0:t.createObjectStore($c)}}}).catch(t=>{throw Ba.create("idb-open",{originalErrorMessage:t.message})})),Ug}async function pY(t){var e;try{return(await tA()).transaction($c).objectStore($c).get(rA(t))}catch(n){if(n instanceof Ni)Ua.warn(n.message);else{const r=Ba.create("idb-get",{originalErrorMessage:(e=n)===null||e===void 0?void 0:e.message});Ua.warn(r.message)}}}async function nA(t,e){var n;try{const i=(await tA()).transaction($c,"readwrite");return await i.objectStore($c).put(e,rA(t)),i.done}catch(r){if(r instanceof Ni)Ua.warn(r.message);else{const i=Ba.create("idb-set",{originalErrorMessage:(n=r)===null||n===void 0?void 0:n.message});Ua.warn(i.message)}}}function rA(t){return`${t.name}!${t.options.appId}`}/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const mY=1024,fY=30*24*60*60*1e3;class hY{constructor(e){this.container=e,this._heartbeatsCache=null;const n=this.container.getProvider("app").getImmediate();this._storage=new EY(n),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){const n=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=iA();if(this._heartbeatsCache===null&&(this._heartbeatsCache=await this._heartbeatsCachePromise),!(this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(i=>i.date===r)))return this._heartbeatsCache.heartbeats.push({date:r,agent:n}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter(i=>{const s=new Date(i.date).valueOf();return Date.now()-s<=fY}),this._storage.overwrite(this._heartbeatsCache)}async getHeartbeatsHeader(){if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache===null||this._heartbeatsCache.heartbeats.length===0)return"";const e=iA(),{heartbeatsToSend:n,unsentEntries:r}=gY(this._heartbeatsCache.heartbeats),i=N_(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=e,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}}function iA(){return new Date().toISOString().substring(0,10)}function gY(t,e=mY){const n=[];let r=t.slice();for(const i of t){const s=n.find(a=>a.agent===i.agent);if(s){if(s.dates.push(i.date),sA(n)>e){s.dates.pop();break}}else if(n.push({agent:i.agent,dates:[i.date]}),sA(n)>e){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}class EY{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return s$()?a$().then(()=>!0).catch(()=>!1):!1}async read(){return await this._canUseIndexedDBPromise?await pY(this.app)||{heartbeats:[]}:{heartbeats:[]}}async overwrite(e){var n;if(await this._canUseIndexedDBPromise){const i=await this.read();return nA(this.app,{lastSentHeartbeatDate:(n=e.lastSentHeartbeatDate)!==null&&n!==void 0?n:i.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var n;if(await this._canUseIndexedDBPromise){const i=await this.read();return nA(this.app,{lastSentHeartbeatDate:(n=e.lastSentHeartbeatDate)!==null&&n!==void 0?n:i.lastSentHeartbeatDate,heartbeats:[...i.heartbeats,...e.heartbeats]})}else return}}function sA(t){return N_(JSON.stringify({version:2,heartbeats:t})).length}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function SY(t){Fa(new Ks("platform-logger",e=>new L$(e),"PRIVATE")),Fa(new Ks("heartbeat",e=>new hY(e),"PRIVATE")),Ri(xg,JO,t),Ri(xg,JO,"esm2017"),Ri("fire-js","")}SY("");var TY="firebase",vY="9.9.4";/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/Ri(TY,vY,"app");function Fg(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function aA(){return{["dependent-sdk-initialized-before-auth"]:"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const yY=aA,oA=new Bc("auth","Firebase",aA());/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const lA=new Rg("@firebase/auth");function A_(t,...e){lA.logLevel<=nt.ERROR&&lA.error(`Auth (${el}): ${t}`,...e)}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function ns(t,...e){throw Bg(t,...e)}function Oi(t,...e){return Bg(t,...e)}function bY(t,e,n){const r=Object.assign(Object.assign({},yY()),{[e]:n});return new Bc("auth","Firebase",r).create(e,{appName:t.name})}function Bg(t,...e){if(typeof t!="string"){const n=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=t.name),t._errorFactory.create(n,...r)}return oA.create(t,...e)}function Me(t,e,...n){if(!t)throw Bg(e,...n)}function rs(t){const e="INTERNAL ASSERTION FAILED: "+t;throw A_(e),new Error(e)}function is(t,e){t||rs(e)}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const cA=new Map;function ss(t){is(t instanceof Function,"Expected a class definition");let e=cA.get(t);return e?(is(e instanceof t,"Instance stored in cache mismatched with class"),e):(e=new t,cA.set(t,e),e)}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function CY(t,e){const n=O_(t,"auth");if(n.isInitialized()){const i=n.getImmediate(),s=n.getOptions();if(I_(s,e!=null?e:{}))return i;ns(i,"already-initialized")}return n.initialize({options:e})}function NY(t,e){const n=(e==null?void 0:e.persistence)||[],r=(Array.isArray(n)?n:[n]).map(ss);e!=null&&e.errorMap&&t._updateErrorMap(e.errorMap),t._initializeWithPersistence(r,e==null?void 0:e.popupRedirectResolver)}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Gg(){var t;return typeof self<"u"&&((t=self.location)===null||t===void 0?void 0:t.href)||""}function IY(){return uA()==="http:"||uA()==="https:"}function uA(){var t;return typeof self<"u"&&((t=self.location)===null||t===void 0?void 0:t.protocol)||null}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function RY(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(IY()||VO()||"connection"in navigator)?navigator.onLine:!0}function OY(){if(typeof navigator>"u")return null;const t=navigator;return t.languages&&t.languages[0]||t.language||null}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Yc{constructor(e,n){this.shortDelay=e,this.longDelay=n,is(n>e,"Short delay should be less than long delay!"),this.isMobile=zO()||jO()}get(){return RY()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function $g(t,e){is(t.emulator,"Emulator should always be set here");const{url:n}=t.emulator;return e?`${n}${e.startsWith("/")?e.slice(1):e}`:n}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class dA{static initialize(e,n,r){this.fetchImpl=e,n&&(this.headersImpl=n),r&&(this.responseImpl=r)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;rs("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;rs("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;rs("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const AY={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"};/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const wY=new Yc(3e4,6e4);function DY(t,e){return t.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:t.tenantId}):e}async function w_(t,e,n,r,i={}){return _A(t,i,async()=>{let s={},a={};r&&(e==="GET"?a=r:s={body:JSON.stringify(r)});const o=Gc(Object.assign({key:t.config.apiKey},a)).slice(1),l=await t._getAdditionalHeaders();return l["Content-Type"]="application/json",t.languageCode&&(l["X-Firebase-Locale"]=t.languageCode),dA.fetch()(pA(t,t.config.apiHost,n,o),Object.assign({method:e,headers:l,referrerPolicy:"no-referrer"},s))})}async function _A(t,e,n){t._canInitEmulator=!1;const r=Object.assign(Object.assign({},AY),e);try{const i=new LY(t),s=await Promise.race([n(),i.promise]);i.clearNetworkTimeout();const a=await s.json();if("needConfirmation"in a)throw D_(t,"account-exists-with-different-credential",a);if(s.ok&&!("errorMessage"in a))return a;{const o=s.ok?a.errorMessage:a.error.message,[l,c]=o.split(" : ");if(l==="FEDERATED_USER_ID_ALREADY_LINKED")throw D_(t,"credential-already-in-use",a);if(l==="EMAIL_EXISTS")throw D_(t,"email-already-in-use",a);if(l==="USER_DISABLED")throw D_(t,"user-disabled",a);const u=r[l]||l.toLowerCase().replace(/[_\s]+/g,"-");if(c)throw bY(t,u,c);ns(t,u)}}catch(i){if(i instanceof Ni)throw i;ns(t,"network-request-failed")}}async function MY(t,e,n,r,i={}){const s=await w_(t,e,n,r,i);return"mfaPendingCredential"in s&&ns(t,"multi-factor-auth-required",{_serverResponse:s}),s}function pA(t,e,n,r){const i=`${e}${n}?${r}`;return t.config.emulator?$g(t.config,i):`${t.config.apiScheme}://${i}`}class LY{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((n,r)=>{this.timer=setTimeout(()=>r(Oi(this.auth,"network-request-failed")),wY.get())})}clearNetworkTimeout(){clearTimeout(this.timer)}}function D_(t,e,n){const r={appName:t.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=Oi(t,e,r);return i.customData._tokenResponse=n,i}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/async function xY(t,e){return w_(t,"POST","/v1/accounts:delete",e)}async function PY(t,e){return w_(t,"POST","/v1/accounts:lookup",e)}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function zc(t){if(!!t)try{const e=new Date(Number(t));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function kY(t,e=!1){const n=Ii(t),r=await n.getIdToken(e),i=zg(r);Me(i&&i.exp&&i.auth_time&&i.iat,n.auth,"internal-error");const s=typeof i.firebase=="object"?i.firebase:void 0,a=s==null?void 0:s.sign_in_provider;return{claims:i,token:r,authTime:zc(Yg(i.auth_time)),issuedAtTime:zc(Yg(i.iat)),expirationTime:zc(Yg(i.exp)),signInProvider:a||null,signInSecondFactor:(s==null?void 0:s.sign_in_second_factor)||null}}function Yg(t){return Number(t)*1e3}function zg(t){var e;const[n,r,i]=t.split(".");if(n===void 0||r===void 0||i===void 0)return A_("JWT malformed, contained fewer than 3 sections"),null;try{const s=t$(r);return s?JSON.parse(s):(A_("Failed to decode base64 JWT payload"),null)}catch(s){return A_("Caught error parsing JWT payload as JSON",(e=s)===null||e===void 0?void 0:e.toString()),null}}function UY(t){const e=zg(t);return Me(e,"internal-error"),Me(typeof e.exp<"u","internal-error"),Me(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/async function Vc(t,e,n=!1){if(n)return e;try{return await e}catch(r){throw r instanceof Ni&&FY(r)&&t.auth.currentUser===t&&await t.auth.signOut(),r}}function FY({code:t}){return t==="auth/user-disabled"||t==="auth/user-token-expired"}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class BY{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){!this.isRunning||(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){var n;if(e){const r=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),r}else{this.errorBackoff=3e4;const i=((n=this.user.stsTokenManager.expirationTime)!==null&&n!==void 0?n:0)-Date.now()-3e5;return Math.max(0,i)}}schedule(e=!1){if(!this.isRunning)return;const n=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},n)}async iteration(){var e;try{await this.user.getIdToken(!0)}catch(n){((e=n)===null||e===void 0?void 0:e.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class mA{constructor(e,n){this.createdAt=e,this.lastLoginAt=n,this._initializeTime()}_initializeTime(){this.lastSignInTime=zc(this.lastLoginAt),this.creationTime=zc(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/async function M_(t){var e;const n=t.auth,r=await t.getIdToken(),i=await Vc(t,PY(n,{idToken:r}));Me(i==null?void 0:i.users.length,n,"internal-error");const s=i.users[0];t._notifyReloadListener(s);const a=!((e=s.providerUserInfo)===null||e===void 0)&&e.length?YY(s.providerUserInfo):[],o=$Y(t.providerData,a),l=t.isAnonymous,c=!(t.email&&s.passwordHash)&&!(o!=null&&o.length),u=l?c:!1,d={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:o,metadata:new mA(s.createdAt,s.lastLoginAt),isAnonymous:u};Object.assign(t,d)}async function GY(t){const e=Ii(t);await M_(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function $Y(t,e){return[...t.filter(r=>!e.some(i=>i.providerId===r.providerId)),...e]}function YY(t){return t.map(e=>{var{providerId:n}=e,r=Fg(e,["providerId"]);return{providerId:n,uid:r.rawId||"",displayName:r.displayName||null,email:r.email||null,phoneNumber:r.phoneNumber||null,photoURL:r.photoUrl||null}})}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/async function zY(t,e){const n=await _A(t,{},async()=>{const r=Gc({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:i,apiKey:s}=t.config,a=pA(t,i,"/v1/token",`key=${s}`),o=await t._getAdditionalHeaders();return o["Content-Type"]="application/x-www-form-urlencoded",dA.fetch()(a,{method:"POST",headers:o,body:r})});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class jc{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){Me(e.idToken,"internal-error"),Me(typeof e.idToken<"u","internal-error"),Me(typeof e.refreshToken<"u","internal-error");const n="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):UY(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,n)}async getToken(e,n=!1){return Me(!this.accessToken||this.refreshToken,e,"user-token-expired"),!n&&this.accessToken&&!this.isExpired?this.accessToken:this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null}clearRefreshToken(){this.refreshToken=null}async refresh(e,n){const{accessToken:r,refreshToken:i,expiresIn:s}=await zY(e,n);this.updateTokensAndExpiration(r,i,Number(s))}updateTokensAndExpiration(e,n,r){this.refreshToken=n||null,this.accessToken=e||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(e,n){const{refreshToken:r,accessToken:i,expirationTime:s}=n,a=new jc;return r&&(Me(typeof r=="string","internal-error",{appName:e}),a.refreshToken=r),i&&(Me(typeof i=="string","internal-error",{appName:e}),a.accessToken=i),s&&(Me(typeof s=="number","internal-error",{appName:e}),a.expirationTime=s),a}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new jc,this.toJSON())}_performRefresh(){return rs("not implemented")}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Zs(t,e){Me(typeof t=="string"||typeof t>"u","internal-error",{appName:e})}class Ga{constructor(e){var{uid:n,auth:r,stsTokenManager:i}=e,s=Fg(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new BY(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=n,this.auth=r,this.stsTokenManager=i,this.accessToken=i.accessToken,this.displayName=s.displayName||null,this.email=s.email||null,this.emailVerified=s.emailVerified||!1,this.phoneNumber=s.phoneNumber||null,this.photoURL=s.photoURL||null,this.isAnonymous=s.isAnonymous||!1,this.tenantId=s.tenantId||null,this.providerData=s.providerData?[...s.providerData]:[],this.metadata=new mA(s.createdAt||void 0,s.lastLoginAt||void 0)}async getIdToken(e){const n=await Vc(this,this.stsTokenManager.getToken(this.auth,e));return Me(n,this.auth,"internal-error"),this.accessToken!==n&&(this.accessToken=n,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),n}getIdTokenResult(e){return kY(this,e)}reload(){return GY(this)}_assign(e){this!==e&&(Me(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(n=>Object.assign({},n)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){return new Ga(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}))}_onReload(e){Me(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,n=!1){let r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),n&&await M_(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){const e=await this.getIdToken();return await Vc(this,xY(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,n){var r,i,s,a,o,l,c,u;const d=(r=n.displayName)!==null&&r!==void 0?r:void 0,_=(i=n.email)!==null&&i!==void 0?i:void 0,p=(s=n.phoneNumber)!==null&&s!==void 0?s:void 0,f=(a=n.photoURL)!==null&&a!==void 0?a:void 0,E=(o=n.tenantId)!==null&&o!==void 0?o:void 0,h=(l=n._redirectEventId)!==null&&l!==void 0?l:void 0,m=(c=n.createdAt)!==null&&c!==void 0?c:void 0,g=(u=n.lastLoginAt)!==null&&u!==void 0?u:void 0,{uid:T,emailVerified:v,isAnonymous:R,providerData:C,stsTokenManager:b}=n;Me(T&&b,e,"internal-error");const N=jc.fromJSON(this.name,b);Me(typeof T=="string",e,"internal-error"),Zs(d,e.name),Zs(_,e.name),Me(typeof v=="boolean",e,"internal-error"),Me(typeof R=="boolean",e,"internal-error"),Zs(p,e.name),Zs(f,e.name),Zs(E,e.name),Zs(h,e.name),Zs(m,e.name),Zs(g,e.name);const w=new Ga({uid:T,auth:e,email:_,emailVerified:v,displayName:d,isAnonymous:R,photoURL:f,phoneNumber:p,tenantId:E,stsTokenManager:N,createdAt:m,lastLoginAt:g});return C&&Array.isArray(C)&&(w.providerData=C.map(k=>Object.assign({},k))),h&&(w._redirectEventId=h),w}static async _fromIdTokenResponse(e,n,r=!1){const i=new jc;i.updateFromServerRespo
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class fA{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,n){this.storage[e]=n}async _get(e){const n=this.storage[e];return n===void 0?null:n}async _remove(e){delete this.storage[e]}_addListener(e,n){}_removeListener(e,n){}}fA.type="NONE";const hA=fA;/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function L_(t,e,n){return`firebase:${t}:${e}:${n}`}class tl{constructor(e,n,r){this.persistence=e,this.auth=n,this.userKey=r;const{config:i,name:s}=this.auth;this.fullUserKey=L_(this.userKey,i.apiKey,s),this.fullPersistenceKey=L_("persistence",i.apiKey,s),this.boundEventHandler=n._onStorageEvent.bind(n),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);return e?Ga._fromJSON(this.auth,e):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const n=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,n)return this.setCurrentUser(n)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,n,r="authUser"){if(!n.length)return new tl(ss(hA),e,r);const i=(await Promise.all(n.map(async c=>{if(await c._isAvailable())return c}))).filter(c=>c);let s=i[0]||ss(hA);const a=L_(r,e.config.apiKey,e.name);let o=null;for(const c of n)try{const u=await c._get(a);if(u){const d=Ga._fromJSON(e,u);c!==s&&(o=d),s=c;break}}catch{}const l=i.filter(c=>c._shouldAllowMigration);return!s._shouldAllowMigration||!l.length?new tl(s,e,r):(s=l[0],o&&await s._set(a,o.toJSON()),await Promise.all(n.map(async c=>{if(c!==s)try{await c._remove(a)}catch{}})),new tl(s,e,r))}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function gA(t){const e=t.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(TA(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(EA(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(yA(e))return"Blackberry";if(bA(e))return"Webos";if(Vg(e))return"Safari";if((e.includes("chrome/")||SA(e))&&!e.includes("edge/"))return"Chrome";if(vA(e))return"Android";{const n=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=t.match(n);if((r==null?void 0:r.length)===2)return r[1]}return"Other"}function EA(t=gn()){return/firefox\//i.test(t)}function Vg(t=gn()){const e=t.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function SA(t=gn()){return/crios\//i.test(t)}function TA(t=gn()){return/iemobile/i.test(t)}function vA(t=gn()){return/android/i.test(t)}function yA(t=gn()){return/blackberry/i.test(t)}function bA(t=gn()){return/webos/i.test(t)}function x_(t=gn()){return/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&/mobile/i.test(t)}function VY(t=gn()){var e;return x_(t)&&!!(!((e=window.navigator)===null||e===void 0)&&e.standalone)}function jY(){return HO()&&document.documentMode===10}function CA(t=gn()){return x_(t)||vA(t)||bA(t)||yA(t)||/windows phone/i.test(t)||TA(t)}function HY(){try{return!!(window&&window!==window.top)}catch{return!1}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function NA(t,e=[]){let n;switch(t){case"Browser":n=gA(gn());break;case"Worker":n=`${gA(gn())}-${t}`;break;default:n=t}const r=e.length?e.join(","):"FirebaseCore-web";return`${n}/JsCore/${el}/${r}`}/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class qY{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,n){const r=s=>new Promise((a,o)=>{try{const l=e(s);a(l)}catch(l){o(l)}});r.onAbort=n,this.queue.push(r);const i=this.queue.length-1;return()=>{this.queue[i]=()=>Promise.resolve()}}async runMiddleware(e){var n;if(this.auth.currentUser===e)return;const r=[];try{for(const i of this.queue)await i(e),i.onAbort&&r.push(i.onAbort)}catch(i){r.reverse();for(const s of r)try{s()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:(n=i)===null||n===void 0?void 0:n.message})}}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class WY{constructor(e,n,r){this.app=e,this.heartbeatServiceProvider=n,this.config=r,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new IA(this),this.idTokenSubscription=new IA(this),this.beforeStateQueue=new qY(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=oA,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=r.sdkClientVersion}_initializeWithPersistence(e,n){return n&&(this._popupRedirectResolver=ss(n)),this._initializationPromise=this.queue(async()=>{var r,i;if(!this._deleted&&(this.persistenceManager=await tl.create(this,e),!this._deleted)){if(!((r=this._popupRedirectResolver)===null||r===void 0)&&r._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(n),this.lastNotifiedUid=((i=this.currentUser)===null||i===void 0?void 0:i.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUser(e){var n;const r=await this.assertedPersistence.getCurrentUser();let i=r,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const a=(n=this.redirectUser)===null||n===void 0?void 0:n._redirectEventId,o=i==null?void 0:i._redirectEventId,l=await this.tryRedirectSignIn(e);(!a||a===o)&&(l==null?void 0:l.user)&&(i=l.user,s=!0)}if(!i)return this.directlySetCurrentUser(null);if(!i._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(i)}catch(a){i=r,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(a))}return i?this.reloadAndSetCurrentUserOrClear(i):this.directlySetCurrentUser(null)}return Me(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===i._redirectEventId?this.directlySetCurrentUser(i):this.reloadAndSetCurrentUserOrClear(i)}async tryRedirectSignIn(e){let n=null;try{n=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return n}async reloadAndSetCurrentUserOrClear(e){var n;try{await M_(e)}catch(r){if(((n=r)===null||n===void 0?void 0:n.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=OY()}async _delete(){this._deleted=!0}async updateCurrentUser(e){const n=e?Ii(e):null;return n&&Me(n.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(n&&n._clone(this))}async _updateCurrentUser(e,n=!1){if(!this._deleted)return e&&Me(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),n||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0)}setPersistence(e){return this.queue(async()=>{await this.assertedPersistence.setPersistence(ss(e))})}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(e){this._errorFactory=new Bc("auth","Firebase",e())}onAuthStateChanged(e,n,r){return this.registerStateListener(this.authStateSubscription,e,n,r)}beforeAuthStateChanged(e,n){return this.beforeStateQueue.pushCallback(e,n)}onIdTokenChanged(e,n,r){return this.registerStateListener(this.idTokenSubscription,e,n,r)}toJSON(){var e;return{apiKey:thi
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class AA{constructor(e,n){this.providerId=e,this.signInMethod=n}toJSON(){return rs("not implemented")}_getIdTokenResponse(e){return rs("not implemented")}_linkToIdToken(e,n){return rs("not implemented")}_getReauthenticationResolver(e){return rs("not implemented")}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/async function nl(t,e){return MY(t,"POST","/v1/accounts:signInWithIdp",DY(t,e))}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const XY="http://localhost";class $a extends AA{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const n=new $a(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(n.idToken=e.idToken),e.accessToken&&(n.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(n.nonce=e.nonce),e.pendingToken&&(n.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(n.accessToken=e.oauthToken,n.secret=e.oauthTokenSecret):ns("argument-error"),n}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const n=typeof e=="string"?JSON.parse(e):e,{providerId:r,signInMethod:i}=n,s=Fg(n,["providerId","signInMethod"]);if(!r||!i)return null;const a=new $a(r,i);return a.idToken=s.idToken||void 0,a.accessToken=s.accessToken||void 0,a.secret=s.secret,a.nonce=s.nonce,a.pendingToken=s.pendingToken||null,a}_getIdTokenResponse(e){const n=this.buildRequest();return nl(e,n)}_linkToIdToken(e,n){const r=this.buildRequest();return r.idToken=n,nl(e,r)}_getReauthenticationResolver(e){const n=this.buildRequest();return n.autoCreate=!1,nl(e,n)}buildRequest(){const e={requestUri:XY,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const n={};this.idToken&&(n.id_token=this.idToken),this.accessToken&&(n.access_token=this.accessToken),this.secret&&(n.oauth_token_secret=this.secret),n.providerId=this.providerId,this.nonce&&!this.pendingToken&&(n.nonce=this.nonce),e.postBody=Gc(n)}return e}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class wA{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Hc extends wA{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Js extends Hc{constructor(){super("facebook.com")}static credential(e){return $a._fromParams({providerId:Js.PROVIDER_ID,signInMethod:Js.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Js.credentialFromTaggedObject(e)}static credentialFromError(e){return Js.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Js.credential(e.oauthAccessToken)}catch{return null}}}Js.FACEBOOK_SIGN_IN_METHOD="facebook.com",Js.PROVIDER_ID="facebook.com";/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class ea extends Hc{constructor(){super("google.com"),this.addScope("profile")}static credential(e,n){return $a._fromParams({providerId:ea.PROVIDER_ID,signInMethod:ea.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:n})}static credentialFromResult(e){return ea.credentialFromTaggedObject(e)}static credentialFromError(e){return ea.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:n,oauthAccessToken:r}=e;if(!n&&!r)return null;try{return ea.credential(n,r)}catch{return null}}}ea.GOOGLE_SIGN_IN_METHOD="google.com",ea.PROVIDER_ID="google.com";/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class ta extends Hc{constructor(){super("github.com")}static credential(e){return $a._fromParams({providerId:ta.PROVIDER_ID,signInMethod:ta.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return ta.credentialFromTaggedObject(e)}static credentialFromError(e){return ta.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return ta.credential(e.oauthAccessToken)}catch{return null}}}ta.GITHUB_SIGN_IN_METHOD="github.com",ta.PROVIDER_ID="github.com";/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class na extends Hc{constructor(){super("twitter.com")}static credential(e,n){return $a._fromParams({providerId:na.PROVIDER_ID,signInMethod:na.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:n})}static credentialFromResult(e){return na.credentialFromTaggedObject(e)}static credentialFromError(e){return na.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:n,oauthTokenSecret:r}=e;if(!n||!r)return null;try{return na.credential(n,r)}catch{return null}}}na.TWITTER_SIGN_IN_METHOD="twitter.com",na.PROVIDER_ID="twitter.com";/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class rl{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,n,r,i=!1){const s=await Ga._fromIdTokenResponse(e,r,i),a=DA(r);return new rl({user:s,providerId:a,_tokenResponse:r,operationType:n})}static async _forOperation(e,n,r){await e._updateTokensIfNecessary(r,!0);const i=DA(r);return new rl({user:e,providerId:i,_tokenResponse:r,operationType:n})}}function DA(t){return t.providerId?t.providerId:"phoneNumber"in t?"phone":null}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class P_ extends Ni{constructor(e,n,r,i){var s;super(n.code,n.message),this.operationType=r,this.user=i,Object.setPrototypeOf(this,P_.prototype),this.customData={appName:e.name,tenantId:(s=e.tenantId)!==null&&s!==void 0?s:void 0,_serverResponse:n.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,n,r,i){return new P_(e,n,r,i)}}function MA(t,e,n,r){return(e==="reauthenticate"?n._getReauthenticationResolver(t):n._getIdTokenResponse(t)).catch(s=>{throw s.code==="auth/multi-factor-auth-required"?P_._fromErrorAndOperation(t,s,e,r):s})}async function ZY(t,e,n=!1){const r=await Vc(t,e._linkToIdToken(t.auth,await t.getIdToken()),n);return rl._forOperation(t,"link",r)}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/async function JY(t,e,n=!1){var r;const{auth:i}=t,s="reauthenticate";try{const a=await Vc(t,MA(i,s,e,t),n);Me(a.idToken,i,"internal-error");const o=zg(a.idToken);Me(o,i,"internal-error");const{sub:l}=o;return Me(t.uid===l,i,"user-mismatch"),rl._forOperation(t,s,a)}catch(a){throw((r=a)===null||r===void 0?void 0:r.code)==="auth/user-not-found"&&ns(i,"user-mismatch"),a}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/async function e2(t,e,n=!1){const r="signIn",i=await MA(t,r,e),s=await rl._fromIdTokenResponse(t,r,i);return n||await t._updateCurrentUser(s.user),s}const k_="__sak";/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class LA{constructor(e,n){this.storageRetriever=e,this.type=n}_isAvailable(){try{return this.storage?(this.storage.setItem(k_,"1"),this.storage.removeItem(k_),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,n){return this.storage.setItem(e,JSON.stringify(n)),Promise.resolve()}_get(e){const n=this.storage.getItem(e);return Promise.resolve(n?JSON.parse(n):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function t2(){const t=gn();return Vg(t)||x_(t)}const n2=1e3,r2=10;class xA extends LA{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,n)=>this.onStorageEvent(e,n),this.listeners={},this.localCache={},this.pollTimer=null,this.safariLocalStorageNotSynced=t2()&&HY(),this.fallbackToPolling=CA(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const n of Object.keys(this.listeners)){const r=this.storage.getItem(n),i=this.localCache[n];r!==i&&e(n,i,r)}}onStorageEvent(e,n=!1){if(!e.key){this.forAllChangedKeys((a,o,l)=>{this.notifyListeners(a,l)});return}const r=e.key;if(n?this.detachListener():this.stopPolling(),this.safariLocalStorageNotSynced){const a=this.storage.getItem(r);if(e.newValue!==a)e.newValue!==null?this.storage.setItem(r,e.newValue):this.storage.removeItem(r);else if(this.localCache[r]===e.newValue&&!n)return}const i=()=>{const a=this.storage.getItem(r);!n&&this.localCache[r]===a||this.notifyListeners(r,a)},s=this.storage.getItem(r);jY()&&s!==e.newValue&&e.newValue!==e.oldValue?setTimeout(i,r2):i()}notifyListeners(e,n){this.localCache[e]=n;const r=this.listeners[e];if(r)for(const i of Array.from(r))i(n&&JSON.parse(n))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,n,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:n,newValue:r}),!0)})},n2)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,n){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(n)}_removeListener(e,n){this.listeners[e]&&(this.listeners[e].delete(n),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,n){await super._set(e,n),this.localCache[e]=JSON.stringify(n)}async _get(e){const n=await super._get(e);return this.localCache[e]=JSON.stringify(n),n}async _remove(e){await super._remove(e),delete this.localCache[e]}}xA.type="LOCAL";const i2=xA;/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class PA extends LA{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,n){}_removeListener(e,n){}}PA.type="SESSION";const kA=PA;/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function s2(t){return Promise.all(t.map(async e=>{try{const n=await e;return{fulfilled:!0,value:n}}catch(n){return{fulfilled:!1,reason:n}}}))}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class U_{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const n=this.receivers.find(i=>i.isListeningto(e));if(n)return n;const r=new U_(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const n=e,{eventId:r,eventType:i,data:s}=n.data,a=this.handlersMap[i];if(!(a!=null&&a.size))return;n.ports[0].postMessage({status:"ack",eventId:r,eventType:i});const o=Array.from(a).map(async c=>c(n.origin,s)),l=await s2(o);n.ports[0].postMessage({status:"done",eventId:r,eventType:i,response:l})}_subscribe(e,n){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(n)}_unsubscribe(e,n){this.handlersMap[e]&&n&&this.handlersMap[e].delete(n),(!n||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}U_.receivers=[];/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Hg(t="",e=10){let n="";for(let r=0;r<e;r++)n+=Math.floor(Math.random()*10);return t+n}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class a2{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,n,r=50){const i=typeof MessageChannel<"u"?new MessageChannel:null;if(!i)throw new Error("connection_unavailable");let s,a;return new Promise((o,l)=>{const c=Hg("",20);i.port1.start();const u=setTimeout(()=>{l(new Error("unsupported_event"))},r);a={messageChannel:i,onMessage(d){const _=d;if(_.data.eventId===c)switch(_.data.status){case"ack":clearTimeout(u),s=setTimeout(()=>{l(new Error("timeout"))},3e3);break;case"done":clearTimeout(s),o(_.data.response);break;default:clearTimeout(u),clearTimeout(s),l(new Error("invalid_response"));break}}},this.handlers.add(a),i.port1.addEventListener("message",a.onMessage),this.target.postMessage({eventType:e,eventId:c,data:n},[i.port2])}).finally(()=>{a&&this.removeMessageHandler(a)})}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Ai(){return window}function o2(t){Ai().location.href=t}/**
* @license
* Copyright 2020 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function UA(){return typeof Ai().WorkerGlobalScope<"u"&&typeof Ai().importScripts=="function"}async function l2(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function c2(){var t;return((t=navigator==null?void 0:navigator.serviceWorker)===null||t===void 0?void 0:t.controller)||null}function u2(){return UA()?self:null}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const FA="firebaseLocalStorageDb",d2=1,F_="firebaseLocalStorage",BA="fbase_key";class qc{constructor(e){this.request=e}toPromise(){return new Promise((e,n)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{n(this.request.error)})})}}function B_(t,e){return t.transaction([F_],e?"readwrite":"readonly").objectStore(F_)}function _2(){const t=indexedDB.deleteDatabase(FA);return new qc(t).toPromise()}function qg(){const t=indexedDB.open(FA,d2);return new Promise((e,n)=>{t.addEventListener("error",()=>{n(t.error)}),t.addEventListener("upgradeneeded",()=>{const r=t.result;try{r.createObjectStore(F_,{keyPath:BA})}catch(i){n(i)}}),t.addEventListener("success",async()=>{const r=t.result;r.objectStoreNames.contains(F_)?e(r):(r.close(),await _2(),e(await qg()))})})}async function GA(t,e,n){const r=B_(t,!0).put({[BA]:e,value:n});return new qc(r).toPromise()}async function p2(t,e){const n=B_(t,!1).get(e),r=await new qc(n).toPromise();return r===void 0?null:r.value}function $A(t,e){const n=B_(t,!0).delete(e);return new qc(n).toPromise()}const m2=800,f2=3;class YA{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await qg(),this.db)}async _withRetries(e){let n=0;for(;;)try{const r=await this._openDb();return await e(r)}catch(r){if(n++>f2)throw r;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return UA()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=U_._getInstance(u2()),this.receiver._subscribe("keyChanged",async(e,n)=>({keyProcessed:(await this._poll()).includes(n.key)})),this.receiver._subscribe("ping",async(e,n)=>["keyChanged"])}async initializeSender(){var e,n;if(this.activeServiceWorker=await l2(),!this.activeServiceWorker)return;this.sender=new a2(this.activeServiceWorker);const r=await this.sender._send("ping",{},800);!r||((e=r[0])===null||e===void 0?void 0:e.fulfilled)&&((n=r[0])===null||n===void 0?void 0:n.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||c2()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await qg();return await GA(e,k_,"1"),await $A(e,k_),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,n){return this._withPendingWrite(async()=>(await this._withRetries(r=>GA(r,e,n)),this.localCache[e]=n,this.notifyServiceWorker(e)))}async _get(e){const n=await this._withRetries(r=>p2(r,e));return this.localCache[e]=n,n}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(n=>$A(n,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(i=>{const s=B_(i,!1).getAll();return new qc(s).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const n=[],r=new Set;for(const{fbase_key:i,value:s}of e)r.add(i),JSON.stringify(this.localCache[i])!==JSON.stringify(s)&&(this.notifyListeners(i,s),n.push(i));for(const i of Object.keys(this.localCache))this.localCache[i]&&!r.has(i)&&(this.notifyListeners(i,null),n.push(i));return n}notifyListeners(e,n){this.localCache[e]=n;const r=this.listeners[e];if(r)for(const i of Array.from(r))i(n)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),m2)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,n){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(n)}_removeListener(
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function g2(){var t,e;return(e=(t=document.getElementsByTagName("head"))===null||t===void 0?void 0:t[0])!==null&&e!==void 0?e:document}function E2(t){return new Promise((e,n)=>{const r=document.createElement("script");r.setAttribute("src",t),r.onload=e,r.onerror=i=>{const s=Oi("internal-error");s.customData=i,n(s)},r.type="text/javascript",r.charset="UTF-8",g2().appendChild(r)})}function S2(t){return`__${t}${Math.floor(Math.random()*1e6)}`}new Yc(3e4,6e4);/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function T2(t,e){return e?ss(e):(Me(t._popupRedirectResolver,t,"argument-error"),t._popupRedirectResolver)}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Wg extends AA{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return nl(e,this._buildIdpRequest())}_linkToIdToken(e,n){return nl(e,this._buildIdpRequest(n))}_getReauthenticationResolver(e){return nl(e,this._buildIdpRequest())}_buildIdpRequest(e){const n={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(n.idToken=e),n}}function v2(t){return e2(t.auth,new Wg(t),t.bypassAuthState)}function y2(t){const{auth:e,user:n}=t;return Me(n,e,"internal-error"),JY(n,new Wg(t),t.bypassAuthState)}async function b2(t){const{auth:e,user:n}=t;return Me(n,e,"internal-error"),ZY(n,new Wg(t),t.bypassAuthState)}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class zA{constructor(e,n,r,i,s=!1){this.auth=e,this.resolver=r,this.user=i,this.bypassAuthState=s,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(n)?n:[n]}execute(){return new Promise(async(e,n)=>{this.pendingPromise={resolve:e,reject:n};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(r){this.reject(r)}})}async onAuthEvent(e){const{urlResponse:n,sessionId:r,postBody:i,tenantId:s,error:a,type:o}=e;if(a){this.reject(a);return}const l={auth:this.auth,requestUri:n,sessionId:r,tenantId:s||void 0,postBody:i||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(o)(l))}catch(c){this.reject(c)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return v2;case"linkViaPopup":case"linkViaRedirect":return b2;case"reauthViaPopup":case"reauthViaRedirect":return y2;default:ns(this.auth,"internal-error")}}resolve(e){is(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){is(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const C2=new Yc(2e3,1e4);class il extends zA{constructor(e,n,r,i,s){super(e,n,i,s),this.provider=r,this.authWindow=null,this.pollId=null,il.currentPopupAction&&il.currentPopupAction.cancel(),il.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return Me(e,this.auth,"internal-error"),e}async onExecution(){is(this.filter.length===1,"Popup operations only handle one event");const e=Hg();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(n=>{this.reject(n)}),this.resolver._isIframeWebStorageSupported(this.auth,n=>{n||this.reject(Oi(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return((e=this.authWindow)===null||e===void 0?void 0:e.associatedEvent)||null}cancel(){this.reject(Oi(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,il.currentPopupAction=null}pollUserCancellation(){const e=()=>{var n,r;if(!((r=(n=this.authWindow)===null||n===void 0?void 0:n.window)===null||r===void 0)&&r.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Oi(this.auth,"popup-closed-by-user"))},2e3);return}this.pollId=window.setTimeout(e,C2.get())};e()}}il.currentPopupAction=null;/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const N2="pendingRedirect",G_=new Map;class I2 extends zA{constructor(e,n,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],n,void 0,r),this.eventId=null}async execute(){let e=G_.get(this.auth._key());if(!e){try{const r=await R2(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(n){e=()=>Promise.reject(n)}G_.set(this.auth._key(),e)}return this.bypassAuthState||G_.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const n=await this.auth._redirectUserForId(e.eventId);if(n)return this.user=n,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function R2(t,e){const n=w2(e),r=A2(t);if(!await r._isAvailable())return!1;const i=await r._get(n)==="true";return await r._remove(n),i}function O2(t,e){G_.set(t._key(),e)}function A2(t){return ss(t._redirectPersistence)}function w2(t){return L_(N2,t.config.apiKey,t.name)}async function D2(t,e,n=!1){const r=jg(t),i=T2(r,e),a=await new I2(r,i,n).execute();return a&&!n&&(delete a.user._redirectEventId,await r._persistUserIfCurrent(a.user),await r._setRedirectUser(null,e)),a}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const M2=10*60*1e3;class L2{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let n=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(e,r)&&(n=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!x2(e)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=e,n=!0)),n}sendToConsumer(e,n){var r;if(e.error&&!jA(e)){const i=((r=e.error.code)===null||r===void 0?void 0:r.split("auth/")[1])||"internal-error";n.onError(Oi(this.auth,i))}else n.onAuthEvent(e)}isEventForConsumer(e,n){const r=n.eventId===null||!!e.eventId&&e.eventId===n.eventId;return n.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=M2&&this.cachedEventUids.clear(),this.cachedEventUids.has(VA(e))}saveEventToCache(e){this.cachedEventUids.add(VA(e)),this.lastProcessedEventTime=Date.now()}}function VA(t){return[t.type,t.eventId,t.sessionId,t.tenantId].filter(e=>e).join("-")}function jA({type:t,error:e}){return t==="unknown"&&(e==null?void 0:e.code)==="auth/no-auth-event"}function x2(t){switch(t.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return jA(t);default:return!1}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/async function P2(t,e={}){return w_(t,"GET","/v1/projects",e)}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const k2=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,U2=/^https?/;async function F2(t){if(t.config.emulator)return;const{authorizedDomains:e}=await P2(t);for(const n of e)try{if(B2(n))return}catch{}ns(t,"unauthorized-domain")}function B2(t){const e=Gg(),{protocol:n,hostname:r}=new URL(e);if(t.startsWith("chrome-extension://")){const a=new URL(t);return a.hostname===""&&r===""?n==="chrome-extension:"&&t.replace("chrome-extension://","")===e.replace("chrome-extension://",""):n==="chrome-extension:"&&a.hostname===r}if(!U2.test(n))return!1;if(k2.test(t))return r===t;const i=t.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)}/**
* @license
* Copyright 2020 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const G2=new Yc(3e4,6e4);function HA(){const t=Ai().___jsl;if(t!=null&&t.H){for(const e of Object.keys(t.H))if(t.H[e].r=t.H[e].r||[],t.H[e].L=t.H[e].L||[],t.H[e].r=[...t.H[e].L],t.CP)for(let n=0;n<t.CP.length;n++)t.CP[n]=null}}function $2(t){return new Promise((e,n)=>{var r,i,s;function a(){HA(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{HA(),n(Oi(t,"network-request-failed"))},timeout:G2.get()})}if(!((i=(r=Ai().gapi)===null||r===void 0?void 0:r.iframes)===null||i===void 0)&&i.Iframe)e(gapi.iframes.getContext());else if(!((s=Ai().gapi)===null||s===void 0)&&s.load)a();else{const o=S2("iframefcb");return Ai()[o]=()=>{gapi.load?a():n(Oi(t,"network-request-failed"))},E2(`https://apis.google.com/js/api.js?onload=${o}`).catch(l=>n(l))}}).catch(e=>{throw $_=null,e})}let $_=null;function Y2(t){return $_=$_||$2(t),$_}/**
* @license
* Copyright 2020 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const z2=new Yc(5e3,15e3),V2="__/auth/iframe",j2="emulator/auth/iframe",H2={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},q2=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function W2(t){const e=t.config;Me(e.authDomain,t,"auth-domain-config-required");const n=e.emulator?$g(e,j2):`https://${t.config.authDomain}/${V2}`,r={apiKey:e.apiKey,appName:t.name,v:el},i=q2.get(t.config.apiHost);i&&(r.eid=i);const s=t._getFrameworks();return s.length&&(r.fw=s.join(",")),`${n}?${Gc(r).slice(1)}`}async function Q2(t){const e=await Y2(t),n=Ai().gapi;return Me(n,t,"internal-error"),e.open({where:document.body,url:W2(t),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:H2,dontclear:!0},r=>new Promise(async(i,s)=>{await r.restyle({setHideOnLeave:!1});const a=Oi(t,"network-request-failed"),o=Ai().setTimeout(()=>{s(a)},z2.get());function l(){Ai().clearTimeout(o),i(r)}r.ping(l).then(l,()=>{s(a)})}))}/**
* @license
* Copyright 2020 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const K2={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},X2=500,Z2=600,J2="_blank",ez="http://localhost";class qA{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function tz(t,e,n,r=X2,i=Z2){const s=Math.max((window.screen.availHeight-i)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let o="";const l=Object.assign(Object.assign({},K2),{width:r.toString(),height:i.toString(),top:s,left:a}),c=gn().toLowerCase();n&&(o=SA(c)?J2:n),EA(c)&&(e=e||ez,l.scrollbars="yes");const u=Object.entries(l).reduce((_,[p,f])=>`${_}${p}=${f},`,"");if(VY(c)&&o!=="_self")return nz(e||"",o),new qA(null);const d=window.open(e||"",o,u);Me(d,t,"popup-blocked");try{d.focus()}catch{}return new qA(d)}function nz(t,e){const n=document.createElement("a");n.href=t,n.target=e;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r)}/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const rz="__/auth/handler",iz="emulator/auth/handler";function WA(t,e,n,r,i,s){Me(t.config.authDomain,t,"auth-domain-config-required"),Me(t.config.apiKey,t,"invalid-api-key");const a={apiKey:t.config.apiKey,appName:t.name,authType:n,redirectUrl:r,v:el,eventId:i};if(e instanceof wA){e.setDefaultLanguage(t.languageCode),a.providerId=e.providerId||"",u$(e.getCustomParameters())||(a.customParameters=JSON.stringify(e.getCustomParameters()));for(const[l,c]of Object.entries(s||{}))a[l]=c}if(e instanceof Hc){const l=e.getScopes().filter(c=>c!=="");l.length>0&&(a.scopes=l.join(","))}t.tenantId&&(a.tid=t.tenantId);const o=a;for(const l of Object.keys(o))o[l]===void 0&&delete o[l];return`${sz(t)}?${Gc(o).slice(1)}`}function sz({config:t}){return t.emulator?$g(t,iz):`https://${t.authDomain}/${rz}`}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const Qg="webStorageSupport";class az{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=kA,this._completeRedirectFn=D2,this._overrideRedirectResult=O2}async _openPopup(e,n,r,i){var s;is((s=this.eventManagers[e._key()])===null||s===void 0?void 0:s.manager,"_initialize() not called before _openPopup()");const a=WA(e,n,r,Gg(),i);return tz(e,a,Hg())}async _openRedirect(e,n,r,i){return await this._originValidation(e),o2(WA(e,n,r,Gg(),i)),new Promise(()=>{})}_initialize(e){const n=e._key();if(this.eventManagers[n]){const{manager:i,promise:s}=this.eventManagers[n];return i?Promise.resolve(i):(is(s,"If manager is not set, promise should be"),s)}const r=this.initAndGetManager(e);return this.eventManagers[n]={promise:r},r.catch(()=>{delete this.eventManagers[n]}),r}async initAndGetManager(e){const n=await Q2(e),r=new L2(e);return n.register("authEvent",i=>(Me(i==null?void 0:i.authEvent,e,"invalid-auth-event"),{status:r.onEvent(i.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=n,r}_isIframeWebStorageSupported(e,n){this.iframes[e._key()].send(Qg,{type:Qg},i=>{var s;const a=(s=i==null?void 0:i[0])===null||s===void 0?void 0:s[Qg];a!==void 0&&n(!!a),ns(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const n=e._key();return this.originValidationPromises[n]||(this.originValidationPromises[n]=F2(e)),this.originValidationPromises[n]}get _shouldInitProactively(){return CA()||Vg()||x_()}}const oz=az;var QA="@firebase/auth",KA="0.20.6";/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class lz{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)===null||e===void 0?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const n=this.auth.onIdTokenChanged(r=>{var i;e(((i=r)===null||i===void 0?void 0:i.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,n),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const n=this.internalListeners.get(e);!n||(this.internalListeners.delete(e),n(),this.updateProactiveRefresh())}assertAuthConfigured(){Me(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function cz(t){switch(t){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";default:return}}function uz(t){Fa(new Ks("auth",(e,{options:n})=>{const r=e.getProvider("app").getImmediate(),i=e.getProvider("heartbeat"),{apiKey:s,authDomain:a}=r.options;return((o,l)=>{Me(s&&!s.includes(":"),"invalid-api-key",{appName:o.name}),Me(!(a!=null&&a.includes(":")),"argument-error",{appName:o.name});const c={apiKey:s,authDomain:a,clientPlatform:t,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:NA(t)},u=new WY(o,l,c);return NY(u,n),u})(r,i)},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,n,r)=>{e.getProvider("auth-internal").initialize()})),Fa(new Ks("auth-internal",e=>{const n=jg(e.getProvider("auth").getImmediate());return(r=>new lz(r))(n)},"PRIVATE").setInstantiationMode("EXPLICIT")),Ri(QA,KA,cz(t)),Ri(QA,KA,"esm2017")}/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function dz(t=kg()){const e=O_(t,"auth");return e.isInitialized()?e.getImmediate():CY(t,{popupRedirectResolver:oz,persistence:[h2,i2,kA]})}uz("Browser");var _z=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},pe,Kg=Kg||{},Le=_z||self;function Y_(){}function Xg(t){var e=typeof t;return e=e!="object"?e:t?Array.isArray(t)?"array":e:"null",e=="array"||e=="object"&&typeof t.length=="number"}function Wc(t){var e=typeof t;return e=="object"&&t!=null||e=="function"}function pz(t){return Object.prototype.hasOwnProperty.call(t,Zg)&&t[Zg]||(t[Zg]=++mz)}var Zg="closure_uid_"+(1e9*Math.random()>>>0),mz=0;function fz(t,e,n){return t.call.apply(t.bind,arguments)}function hz(t,e,n){if(!t)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var i=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(i,r),t.apply(e,i)}}return function(){return t.apply(e,arguments)}}function An(t,e,n){return Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?An=fz:An=hz,An.apply(null,arguments)}function z_(t,e){var n=Array.prototype.slice.call(arguments,1);return function(){var r=n.slice();return r.push.apply(r,arguments),t.apply(this,r)}}function wn(t,e){function n(){}n.prototype=e.prototype,t.Z=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.Vb=function(r,i,s){for(var a=Array(arguments.length-2),o=2;o<arguments.length;o++)a[o-2]=arguments[o];return e.prototype[i].apply(r,a)}}function ra(){this.s=this.s,this.o=this.o}var gz=0;ra.prototype.s=!1,ra.prototype.na=function(){!this.s&&(this.s=!0,this.M(),gz!=0)&&pz(this)},ra.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};const XA=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if(typeof t=="string")return typeof e!="string"||e.length!=1?-1:t.indexOf(e,0);for(let n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},ZA=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){const r=t.length,i=typeof t=="string"?t.split(""):t;for(let s=0;s<r;s++)s in i&&e.call(n,i[s],s,t)};function Ez(t){e:{var e=cV;const n=t.length,r=typeof t=="string"?t.split(""):t;for(let i=0;i<n;i++)if(i in r&&e.call(void 0,r[i],i,t)){e=i;break e}e=-1}return 0>e?null:typeof t=="string"?t.charAt(e):t[e]}function JA(t){return Array.prototype.concat.apply([],arguments)}function Jg(t){const e=t.length;if(0<e){const n=Array(e);for(let r=0;r<e;r++)n[r]=t[r];return n}return[]}function V_(t){return/^[\s\xa0]*$/.test(t)}var ew=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function tr(t,e){return t.indexOf(e)!=-1}function eE(t,e){return t<e?-1:t>e?1:0}var nr;e:{var tw=Le.navigator;if(tw){var nw=tw.userAgent;if(nw){nr=nw;break e}}nr=""}function tE(t,e,n){for(const r in t)e.call(n,t[r],r,t)}function rw(t){const e={};for(const n in t)e[n]=t[n];return e}var iw="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function sw(t,e){let n,r;for(let i=1;i<arguments.length;i++){r=arguments[i];for(n in r)t[n]=r[n];for(let s=0;s<iw.length;s++)n=iw[s],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function nE(t){return nE[" "](t),t}nE[" "]=Y_;function Sz(t){var e=yz;return Object.prototype.hasOwnProperty.call(e,9)?e[9]:e[9]=t(9)}var Tz=tr(nr,"Opera"),sl=tr(nr,"Trident")||tr(nr,"MSIE"),aw=tr(nr,"Edge"),rE=aw||sl,ow=tr(nr,"Gecko")&&!(tr(nr.toLowerCase(),"webkit")&&!tr(nr,"Edge"))&&!(tr(nr,"Trident")||tr(nr,"MSIE"))&&!tr(nr,"Edge"),vz=tr(nr.toLowerCase(),"webkit")&&!tr(nr,"Edge");function lw(){var t=Le.document;return t?t.documentMode:void 0}var j_;e:{var iE="",sE=function(){var t=nr;if(ow)return/rv:([^\);]+)(\)|;)/.exec(t);if(aw)return/Edge\/([\d\.]+)/.exec(t);if(sl)return/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(t);if(vz)return/WebKit\/(\S+)/.exec(t);if(Tz)return/(?:Version)[ \/]?(\S+)/.exec(t)}();if(sE&&(iE=sE?sE[1]:""),sl){var aE=lw();if(aE!=null&&
`+n+`
`+a})}function Bz(t,e,n,r,i,s,a){t.info(function(){return"XMLHTTP RESP ("+r+") [ attempt "+i+"]: "+e+`
`+n+`
`+s+" "+a})}function al(t,e,n,r){t.info(function(){return"XMLHTTP TEXT ("+e+"): "+$z(t,n)+(r?" "+r:"")})}function Gz(t,e){t.info(function(){return"TIMEOUT: "+e})}K_.prototype.info=function(){};function $z(t,e){if(!t.g)return e;if(!e)return null;try{var n=JSON.parse(e);if(n){for(t=0;t<n.length;t++)if(Array.isArray(n[t])){var r=n[t];if(!(2>r.length)){var i=r[1];if(Array.isArray(i)&&!(1>i.length)){var s=i[0];if(s!="noop"&&s!="stop"&&s!="close")for(var a=1;a<i.length;a++)i[a]=""}}}}return hE(n)}catch{return e}}var Ya={},vw=null;function X_(){return vw=vw||new En}Ya.Ma="serverreachability";function yw(t){zn.call(this,Ya.Ma,t)}wn(yw,zn);function Zc(t){const e=X_();Dn(e,new yw(e))}Ya.STAT_EVENT="statevent";function bw(t,e){zn.call(this,Ya.STAT_EVENT,t),this.stat=e}wn(bw,zn);function rr(t){const e=X_();Dn(e,new bw(e,t))}Ya.Na="timingevent";function Cw(t,e){zn.call(this,Ya.Na,t),this.size=e}wn(Cw,zn);function Jc(t,e){if(typeof t!="function")throw Error("Fn must not be null and must be a function");return Le.setTimeout(function(){t()},e)}var Z_={NO_ERROR:0,lb:1,yb:2,xb:3,sb:4,wb:5,zb:6,Ja:7,TIMEOUT:8,Cb:9},Nw={qb:"complete",Mb:"success",Ka:"error",Ja:"abort",Eb:"ready",Fb:"readystatechange",TIMEOUT:"timeout",Ab:"incrementaldata",Db:"progress",tb:"downloadprogress",Ub:"uploadprogress"};function yE(){}yE.prototype.h=null;function Iw(t){return t.h||(t.h=t.i())}function Rw(){}var eu={OPEN:"a",pb:"b",Ka:"c",Bb:"d"};function bE(){zn.call(this,"d")}wn(bE,zn);function CE(){zn.call(this,"c")}wn(CE,zn);var NE;function J_(){}wn(J_,yE),J_.prototype.g=function(){return new XMLHttpRequest},J_.prototype.i=function(){return{}},NE=new J_;function tu(t,e,n,r){this.l=t,this.j=e,this.m=n,this.X=r||1,this.V=new Xc(this),this.P=Yz,t=rE?125:void 0,this.W=new Q_(t),this.H=null,this.i=!1,this.s=this.A=this.v=this.K=this.F=this.Y=this.B=null,this.D=[],this.g=null,this.C=0,this.o=this.u=null,this.N=-1,this.I=!1,this.O=0,this.L=null,this.aa=this.J=this.$=this.U=!1,this.h=new Ow}function Ow(){this.i=null,this.g="",this.h=!1}var Yz=45e3,IE={},ep={};pe=tu.prototype,pe.setTimeout=function(t){this.P=t};function RE(t,e,n){t.K=1,t.v=sp(as(e)),t.s=n,t.U=!0,Aw(t,null)}function Aw(t,e){t.F=Date.now(),nu(t),t.A=as(t.v);var n=t.A,r=t.X;Array.isArray(r)||(r=[String(r)]),Fw(n.h,"t",r),t.C=0,n=t.l.H,t.h=new Ow,t.g=oD(t.l,n?e:null,!t.s),0<t.O&&(t.L=new Uz(An(t.Ia,t,t.g),t.O)),Sw(t.V,t.g,"readystatechange",t.gb),e=t.H?rw(t.H):{},t.s?(t.u||(t.u="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.g.ea(t.A,t.u,t.s,e)):(t.u="GET",t.g.ea(t.A,t.u,null,e)),Zc(),Fz(t.j,t.u,t.A,t.m,t.X,t.s)}pe.gb=function(t){t=t.target;const e=this.L;e&&os(t)==3?e.l():this.Ia(t)},pe.Ia=function(t){try{if(t==this.g)e:{const u=os(this.g);var e=this.g.Da();const d=this.g.ba();if(!(3>u)&&(u!=3||rE||this.g&&(this.h.h||this.g.ga()||Kw(this.g)))){this.I||u!=4||e==7||(e==8||0>=d?Zc(3):Zc(2)),tp(this);var n=this.g.ba();this.N=n;t:if(ww(this)){var r=Kw(this.g);t="";var i=r.length,s=os(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){za(this),ru(this);var a="";break t}this.h.i=new Le.TextDecoder}for(e=0;e<i;e++)this.h.h=!0,t+=this.h.i.decode(r[e],{stream:s&&e==i-1});r.splice(0,i),this.h.g+=t,this.C=0,a=this.h.g}else a=this.g.ga();if(this.i=n==200,Bz(this.j,this.u,this.A,this.m,this.X,u,n),this.i){if(this.$&&!this.J){t:{if(this.g){var o,l=this.g;if((o=l.g?l.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!V_(o)){var c=o;break t}}c=null}if(n=c)al(this.j,this.m,n,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,OE(this,n);else{this.i=!1,this.o=3,rr(12),za(this),ru(this);break e}}this.U?(Dw(this,u,a),rE&&this.i&&u==3&&(Sw(this.V,this.W,"tick",this.fb),this.W.start())):(al(this.j,this.m,a,null),OE(this,a)),u==4&&za(this),this.i&&!this.I&&(u==4?rD(this.l,this):(this.i=!1,nu(this)))}else n==400&&0<a.indexOf("Unknown SID")?(this.o=3,rr(12)):(this.o=0,rr(13)),za(this),ru(this)}}}catch{}finally{}};function ww(t){return t.g?t.u=="GET"&&t.K!=2&&t.l.Ba:!1}function Dw(t,e,n){let r=!0,i;for(;!t.I&&t.C<n.length;)if(i=zz(t,n),i==ep){e==4&&(t.o=4,rr(14),r=!1),al(t.j,t.m,null,"[Incomplete
`,n);return r==-1?ep:(n=Number(e.substring(n,r)),isNaN(n)?IE:(r+=1,r+n>e.length?ep:(e=e.substr(r,n),t.C=r+n,e)))}pe.cancel=function(){this.I=!0,za(this)};function nu(t){t.Y=Date.now()+t.P,Mw(t,t.P)}function Mw(t,e){if(t.B!=null)throw Error("WatchDog timer not null");t.B=Jc(An(t.eb,t),e)}function tp(t){t.B&&(Le.clearTimeout(t.B),t.B=null)}pe.eb=function(){this.B=null;const t=Date.now();0<=t-this.Y?(Gz(this.j,this.A),this.K!=2&&(Zc(),rr(17)),za(this),this.o=2,ru(this)):Mw(this,this.Y-t)};function ru(t){t.l.G==0||t.I||rD(t.l,t)}function za(t){tp(t);var e=t.L;e&&typeof e.na=="function"&&e.na(),t.L=null,TE(t.W),Tw(t.V),t.g&&(e=t.g,t.g=null,e.abort(),e.na())}function OE(t,e){try{var n=t.l;if(n.G!=0&&(n.g==t||DE(n.i,t))){if(n.I=t.N,!t.J&&DE(n.i,t)&&n.G==3){try{var r=n.Ca.g.parse(e)}catch{r=null}if(Array.isArray(r)&&r.length==3){var i=r;if(i[0]==0){e:if(!n.u){if(n.g)if(n.g.F+3e3<t.F)dp(n),cp(n);else break e;FE(n),rr(18)}}else n.ta=i[1],0<n.ta-n.U&&37500>i[2]&&n.N&&n.A==0&&!n.v&&(n.v=Jc(An(n.ab,n),6e3));if(1>=$w(n.i)&&n.ka){try{n.ka()}catch{}n.ka=void 0}}else Ha(n,11)}else if((t.J||n.g==t)&&dp(n),!V_(e))for(i=n.Ca.g.parse(e),e=0;e<i.length;e++){let c=i[e];if(n.U=c[0],c=c[1],n.G==2)if(c[0]=="c"){n.J=c[1],n.la=c[2];const u=c[3];u!=null&&(n.ma=u,n.h.info("VER="+n.ma));const d=c[4];d!=null&&(n.za=d,n.h.info("SVER="+n.za));const _=c[5];_!=null&&typeof _=="number"&&0<_&&(r=1.5*_,n.K=r,n.h.info("backChannelRequestTimeoutMs_="+r)),r=n;const p=t.g;if(p){const f=p.g?p.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(f){var s=r.i;!s.g&&(tr(f,"spdy")||tr(f,"quic")||tr(f,"h2"))&&(s.j=s.l,s.g=new Set,s.h&&(ME(s,s.h),s.h=null))}if(r.D){const E=p.g?p.g.getResponseHeader("X-HTTP-Session-Id"):null;E&&(r.sa=E,Dt(r.F,r.D,E))}}n.G=3,n.j&&n.j.xa(),n.$&&(n.O=Date.now()-t.F,n.h.info("Handshake RTT: "+n.O+"ms")),r=n;var a=t;if(r.oa=aD(r,r.H?r.la:null,r.W),a.J){Yw(r.i,a);var o=a,l=r.K;l&&o.setTimeout(l),o.B&&(tp(o),nu(o)),r.g=a}else tD(r);0<n.l.length&&up(n)}else c[0]!="stop"&&c[0]!="close"||Ha(n,7);else n.G==3&&(c[0]=="stop"||c[0]=="close"?c[0]=="stop"?Ha(n,7):kE(n):c[0]!="noop"&&n.j&&n.j.wa(c),n.A=0)}}Zc(4)}catch{}}function Vz(t){if(t.R&&typeof t.R=="function")return t.R();if(typeof t=="string")return t.split("");if(Xg(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}e=[],n=0;for(r in t)e[n++]=t[r];return e}function AE(t,e){if(t.forEach&&typeof t.forEach=="function")t.forEach(e,void 0);else if(Xg(t)||typeof t=="string")ZA(t,e,void 0);else{if(t.T&&typeof t.T=="function")var n=t.T();else if(t.R&&typeof t.R=="function")n=void 0;else if(Xg(t)||typeof t=="string"){n=[];for(var r=t.length,i=0;i<r;i++)n.push(i)}else for(i in n=[],r=0,t)n[r++]=i;r=Vz(t),i=r.length;for(var s=0;s<i;s++)e.call(void 0,r[s],n&&n[s],t)}}function ol(t,e){this.h={},this.g=[],this.i=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var r=0;r<n;r+=2)this.set(arguments[r],arguments[r+1])}else if(t)if(t instanceof ol)for(n=t.T(),r=0;r<n.length;r++)this.set(n[r],t.get(n[r]));else for(r in t)this.set(r,t[r])}pe=ol.prototype,pe.R=function(){wE(this);for(var t=[],e=0;e<this.g.length;e++)t.push(this.h[this.g[e]]);return t},pe.T=function(){return wE(this),this.g.concat()};function wE(t){if(t.i!=t.g.length){for(var e=0,n=0;e<t.g.length;){var r=t.g[e];Va(t.h,r)&&(t.g[n++]=r),e++}t.g.length=n}if(t.i!=t.g.length){var i={};for(n=e=0;e<t.g.length;)r=t.g[e],Va(i,r)||(t.g[n++]=r,i[r]=1),e++;t.g.length=n}}pe.get=function(t,e){return Va(this.h,t)?this.h[t]:e},pe.set=function(t,e){Va(this.h,t)||(this.i++,this.g.push(t)),this.h[t]=e},pe.forEach=function(t,e){for(var n=this.T(),r=0;r<n.length;r++){var i=n[r],s=this.get(i);t.call(e,s,i,this)}};function Va(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var Lw=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function jz(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var r=t[n].indexOf("="),i=null;if(0<=r){var s=t[n].substring(0,r);i=t[n].substring(r+1)}else s=t[n];e(s,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}fu
`)};function cu(t){t.onreadystatechange&&t.onreadystatechange.call(t)}Object.defineProperty(op.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(t){this.m=t?"include":"same-origin"}});var sV=Le.JSON.parse;function nn(t){En.call(this),this.headers=new ol,this.u=t||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=jw,this.K=this.L=!1}wn(nn,En);var jw="",aV=/^https?$/i,oV=["POST","PUT"];pe=nn.prototype,pe.ea=function(t,e,n,r){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.H+"; newUri="+t);e=e?e.toUpperCase():"GET",this.H=t,this.j="",this.m=0,this.D=!1,this.h=!0,this.g=this.u?this.u.g():NE.g(),this.C=this.u?Iw(this.u):Iw(NE),this.g.onreadystatechange=An(this.Fa,this);try{this.F=!0,this.g.open(e,String(t),!0),this.F=!1}catch(s){Hw(this,s);return}t=n||"";const i=new ol(this.headers);r&&AE(r,function(s,a){i.set(a,s)}),r=Ez(i.T()),n=Le.FormData&&t instanceof Le.FormData,!(0<=XA(oV,e))||r||n||i.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),i.forEach(function(s,a){this.g.setRequestHeader(a,s)},this),this.J&&(this.g.responseType=this.J),"withCredentials"in this.g&&this.g.withCredentials!==this.L&&(this.g.withCredentials=this.L);try{Qw(this),0<this.B&&((this.K=lV(this.g))?(this.g.timeout=this.B,this.g.ontimeout=An(this.pa,this)):this.A=vE(this.pa,this.B,this)),this.v=!0,this.g.send(t),this.v=!1}catch(s){Hw(this,s)}};function lV(t){return sl&&bz()&&typeof t.timeout=="number"&&t.ontimeout!==void 0}function cV(t){return t.toLowerCase()=="content-type"}pe.pa=function(){typeof Kg<"u"&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,Dn(this,"timeout"),this.abort(8))};function Hw(t,e){t.h=!1,t.g&&(t.l=!0,t.g.abort(),t.l=!1),t.j=e,t.m=5,qw(t),lp(t)}function qw(t){t.D||(t.D=!0,Dn(t,"complete"),Dn(t,"error"))}pe.abort=function(t){this.g&&this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=t||7,Dn(this,"complete"),Dn(this,"abort"),lp(this))},pe.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),lp(this,!0)),nn.Z.M.call(this)},pe.Fa=function(){this.s||(this.F||this.v||this.l?Ww(this):this.cb())},pe.cb=function(){Ww(this)};function Ww(t){if(t.h&&typeof Kg<"u"&&(!t.C[1]||os(t)!=4||t.ba()!=2)){if(t.v&&os(t)==4)vE(t.Fa,0,t);else if(Dn(t,"readystatechange"),os(t)==4){t.h=!1;try{const o=t.ba();e:switch(o){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var e=!0;break e;default:e=!1}var n;if(!(n=e)){var r;if(r=o===0){var i=String(t.H).match(Lw)[1]||null;if(!i&&Le.self&&Le.self.location){var s=Le.self.location.protocol;i=s.substr(0,s.length-1)}r=!aV.test(i?i.toLowerCase():"")}n=r}if(n)Dn(t,"complete"),Dn(t,"success");else{t.m=6;try{var a=2<os(t)?t.g.statusText:""}catch{a=""}t.j=a+" ["+t.ba()+"]",qw(t)}}finally{lp(t)}}}}function lp(t,e){if(t.g){Qw(t);const n=t.g,r=t.C[0]?Y_:null;t.g=null,t.C=null,e||Dn(t,"ready");try{n.onreadystatechange=r}catch{}}}function Qw(t){t.g&&t.K&&(t.g.ontimeout=null),t.A&&(Le.clearTimeout(t.A),t.A=null)}function os(t){return t.g?t.g.readyState:0}pe.ba=function(){try{return 2<os(this)?this.g.status:-1}catch{return-1}},pe.ga=function(){try{return this.g?this.g.responseText:""}catch{return""}},pe.Qa=function(t){if(this.g){var e=this.g.responseText;return t&&e.indexOf(t)==0&&(e=e.substring(t.length)),sV(e)}};function Kw(t){try{if(!t.g)return null;if("response"in t.g)return t.g.response;switch(t.J){case jw:case"text":return t.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in t.g)return t.g.mozResponseArrayBuffer}return null}catch{return null}}pe.Da=function(){return this.m},pe.La=function(){return typeof this.j=="string"?this.j:String(this.j)};function uV(t){let e="";return tE(t,function(n,r){e+=r,e+=":",e+=n,e+=`\r
`}),e}function PE(t,e,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=uV(n),typeof t=="string"?n!=null&&encodeURIComponent(String(n)):Dt(t,e,n))}function uu(t,e,n){return n&&n.internalChannelParams&&n.internalChannelParams[t]||e}function Xw(t){this.za=0,this.l=[],this.h=new K_,this.la=this.oa=this.F=this.W=this.g=this.sa=this.D=this.aa=this.o=this.P=this.s=null,this.Za=this.V=0,this.Xa=uu("failFast",!1,t),this.N=this.v=this.u=this.m=this.j=null,this.X=!0,this.I=this.ta=this.U=-1,this.Y=this.A=this.C=0,this.Pa=uu("baseRetryDelayMs",5e3,t),this.$a=uu("retryDelaySeedMs",1e4,t),this.Ya=uu("forwardChannelMaxRetries",2,t),this.ra=uu("forwardChannelRequestTimeoutMs",2e4,t),this.qa=t&&t.xmlHttpFactory||void 0,this.Ba=t&&t.Yb||!1,this.K=void 0,this.H=t&&t.supportsCrossDomainXhr||!1,this.J="",this.i=new Bw(t&&t.concurrentRequestLimit),this.Ca=new nV,this.ja=t&&t.fastHandshake||!1,this.Ra=t&&t.Wb||!1,t&&t.Aa&&this.h.Aa(),t&&t.forceLongPolling&&(this.X=!1),this.$=!this.ja&&this.X&&t&&t.detectBufferingProxy||!1,this.ka=void 0,this.O=0,this.L=!1,this.B=null,this.Wa=!t||t.Xb!==!1}pe=Xw.prototype,pe.ma=8,pe.G=1;function kE(t){if(Zw(t),t.G==3){var e=t.V++,n=as(t.F);Dt(n,"SID",t.J),Dt(n,"RID",e),Dt(n,"TYPE","terminate"),du(t,n),e=new tu(t,t.h,e,void 0),e.K=2,e.v=sp(as(n)),n=!1,Le.navigator&&Le.navigator.sendBeacon&&(n=Le.navigator.sendBeacon(e.v.toString(),"")),!n&&Le.Image&&(new Image().src=e.v,n=!0),n||(e.g=oD(e.l,null),e.g.ea(e.v)),e.F=Date.now(),nu(e)}sD(t)}pe.hb=function(t){try{this.h.info("Origin Trials invoked: "+t)}catch{}};function cp(t){t.g&&(BE(t),t.g.cancel(),t.g=null)}function Zw(t){cp(t),t.u&&(Le.clearTimeout(t.u),t.u=null),dp(t),t.i.cancel(),t.m&&(typeof t.m=="number"&&Le.clearTimeout(t.m),t.m=null)}function UE(t,e){t.l.push(new eV(t.Za++,e)),t.G==3&&up(t)}function up(t){Gw(t.i)||t.m||(t.m=!0,gE(t.Ha,t),t.C=0)}function dV(t,e){return $w(t.i)>=t.i.j-(t.m?1:0)?!1:t.m?(t.l=e.D.concat(t.l),!0):t.G==1||t.G==2||t.C>=(t.Xa?0:t.Ya)?!1:(t.m=Jc(An(t.Ha,t,e),iD(t,t.C)),t.C++,!0)}pe.Ha=function(t){if(this.m)if(this.m=null,this.G==1){if(!t){this.V=Math.floor(1e5*Math.random()),t=this.V++;const i=new tu(this,this.h,t,void 0);let s=this.s;if(this.P&&(s?(s=rw(s),sw(s,this.P)):s=this.P),this.o===null&&(i.H=s),this.ja)e:{for(var e=0,n=0;n<this.l.length;n++){t:{var r=this.l[n];if("__data__"in r.g&&(r=r.g.__data__,typeof r=="string")){r=r.length;break t}r=void 0}if(r===void 0)break;if(e+=r,4096<e){e=n;break e}if(e===4096||n===this.l.length-1){e=n+1;break e}}e=1e3}else e=1e3;e=eD(this,i,e),n=as(this.F),Dt(n,"RID",t),Dt(n,"CVER",22),this.D&&Dt(n,"X-HTTP-Session-Id",this.D),du(this,n),this.o&&s&&PE(n,this.o,s),ME(this.i,i),this.Ra&&Dt(n,"TYPE","init"),this.ja?(Dt(n,"$req",e),Dt(n,"SID","null"),i.$=!0,RE(i,n,null)):RE(i,n,e),this.G=2}}else this.G==3&&(t?Jw(this,t):this.l.length==0||Gw(this.i)||Jw(this))};function Jw(t,e){var n;e?n=e.m:n=t.V++;const r=as(t.F);Dt(r,"SID",t.J),Dt(r,"RID",n),Dt(r,"AID",t.U),du(t,r),t.o&&t.s&&PE(r,t.o,t.s),n=new tu(t,t.h,n,t.C+1),t.o===null&&(n.H=t.s),e&&(t.l=e.D.concat(t.l)),e=eD(t,n,1e3),n.setTimeout(Math.round(.5*t.ra)+Math.round(.5*t.ra*Math.random())),ME(t.i,n),RE(n,r,e)}function du(t,e){t.j&&AE({},function(n,r){Dt(e,r,n)})}function eD(t,e,n){n=Math.min(t.l.length,n);var r=t.j?An(t.j.Oa,t.j,t):null;e:{var i=t.l;let s=-1;for(;;){const a=["count="+n];s==-1?0<n?(s=i[0].h,a.push("ofs="+s)):s=0:a.push("ofs="+s);let o=!0;for(let l=0;l<n;l++){let c=i[l].h;const u=i[l].g;if(c-=s,0>c)s=Math.max(0,i[l].h-100),o=!1;else try{rV(u,a,"req"+c+"_")}catch{r&&r(u)}}if(o){r=a.join("&");break e}}}return t=t.l.splice(0,n),e.D=t,r}function tD(t){t.g||t.u||(t.Y=1,gE(t.Ga,t),t.A=0)}function FE(t){return t.g||t.u||3<=t.A?!1:(t.Y++,t.u=Jc(An(t.Ga,t),iD(t,t.A)),t.A++,!0)}pe.Ga=function(){if(this.u=null,nD(this),this.$&&!(this.L||this.g==null||0>=this.O)){var t=2*this.O;this.h.info("BP detection timer enabled: "+t),this.B=Jc(An(this.bb,this),t)}},pe.bb=function(){this.B&&(this.B=null,this.h.info("BP detection timeout reached."),this.h.info("Buffering proxy detected and switch to long-polling!"),this.N=!1,this.L=!0,rr(10),cp(this),nD(this))};f
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Vn{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}Vn.UNAUTHENTICATED=new Vn(null),Vn.GOOGLE_CREDENTIALS=new Vn("google-credentials-uid"),Vn.FIRST_PARTY=new Vn("first-party-uid"),Vn.MOCK_USER=new Vn("mock-user");/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/let ul="9.9.4";/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const qa=new Rg("@firebase/firestore");function pD(){return qa.logLevel}function ye(t,...e){if(qa.logLevel<=nt.DEBUG){const n=e.map(YE);qa.debug(`Firestore (${ul}): ${t}`,...n)}}function ls(t,...e){if(qa.logLevel<=nt.ERROR){const n=e.map(YE);qa.error(`Firestore (${ul}): ${t}`,...n)}}function $E(t,...e){if(qa.logLevel<=nt.WARN){const n=e.map(YE);qa.warn(`Firestore (${ul}): ${t}`,...n)}}function YE(t){if(typeof t=="string")return t;try{return e=t,JSON.stringify(e)}catch{return t}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var e}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Pe(t="Unexpected state"){const e=`FIRESTORE (${ul}) INTERNAL ASSERTION FAILED: `+t;throw ls(e),new Error(e)}function yt(t,e){t||Pe()}function ke(t,e){return t}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const ie={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class Oe extends Ni{constructor(e,n){super(e,n),this.code=e,this.message=n,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class sa{constructor(){this.promise=new Promise((e,n)=>{this.resolve=e,this.reject=n})}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class mD{constructor(e,n){this.user=n,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class EV{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,n){e.enqueueRetryable(()=>n(Vn.UNAUTHENTICATED))}shutdown(){}}class SV{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,n){this.changeListener=n,e.enqueueRetryable(()=>n(this.token.user))}shutdown(){this.changeListener=null}}class TV{constructor(e){this.t=e,this.currentUser=Vn.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,n){let r=this.i;const i=l=>this.i!==r?(r=this.i,n(l)):Promise.resolve();let s=new sa;this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new sa,e.enqueueRetryable(()=>i(this.currentUser))};const a=()=>{const l=s;e.enqueueRetryable(async()=>{await l.promise,await i(this.currentUser)})},o=l=>{ye("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=l,this.auth.addAuthTokenListener(this.o),a()};this.t.onInit(l=>o(l)),setTimeout(()=>{if(!this.auth){const l=this.t.getImmediate({optional:!0});l?o(l):(ye("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new sa)}},0),a()}getToken(){const e=this.i,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then(r=>this.i!==e?(ye("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(yt(typeof r.accessToken=="string"),new mD(r.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 yt(e===null||typeof e=="string"),new Vn(e)}}class vV{constructor(e,n,r,i){this.h=e,this.l=n,this.m=r,this.g=i,this.type="FirstParty",this.user=Vn.FIRST_PARTY,this.p=new Map}I(){return this.g?this.g():(yt(!(typeof this.h!="object"||this.h===null||!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 yV{constructor(e,n,r,i){this.h=e,this.l=n,this.m=r,this.g=i}getToken(){return Promise.resolve(new vV(this.h,this.l,this.m,this.g))}start(e,n){e.enqueueRetryable(()=>n(Vn.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class bV{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 CV{constructor(e){this.T=e,this.forceRefresh=!1,this.appCheck=null,this.A=null}start(e,n){const r=s=>{s.error!=null&&ye("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${s.error.message}`);const a=s.token!==this.A;return this.A=s.token,ye("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?n(s.token):Promise.resolve()};this.o=s=>{e.enqueueRetryable(()=>r(s))};const i=s=>{ye("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=s,this.appCheck.addTokenListener(this.o)};this.T.onInit(s=>i(s)),setTimeout(()=>{if(!this.appCheck){const s=this.T.getImmediate({optional:!0});s?i(s):ye("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(n=>n?(yt(typeof n.token=="string"),this.A=n.token,new bV(n.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function NV(t){const e=typeof self<"u"&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(n);else for(let r=0;r<t;r++)n[r]=Math.floor(256*Math.random());return n}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class fD{static R(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=Math.floor(256/e.length)*e.length;let r="";for(;r.length<20;){const i=NV(40);for(let s=0;s<i.length;++s)r.length<20&&i[s]<n&&(r+=e.charAt(i[s]%e.length))}return r}}function ot(t,e){return t<e?-1:t>e?1:0}function dl(t,e,n){return t.length===e.length&&t.every((r,i)=>n(r,e[i]))}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class un{constructor(e,n){if(this.seconds=e,this.nanoseconds=n,n<0)throw new Oe(ie.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(n>=1e9)throw new Oe(ie.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(e<-62135596800)throw new Oe(ie.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new Oe(ie.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return un.fromMillis(Date.now())}static fromDate(e){return un.fromMillis(e.getTime())}static fromMillis(e){const n=Math.floor(e/1e3),r=Math.floor(1e6*(e-1e3*n));return new un(n,r)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?ot(this.nanoseconds,e.nanoseconds):ot(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const e=this.seconds- -62135596800;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Ge{constructor(e){this.timestamp=e}static fromTimestamp(e){return new Ge(e)}static min(){return new Ge(new un(0,0))}static max(){return new Ge(new un(253402300799,999999999))}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class _u{constructor(e,n,r){n===void 0?n=0:n>e.length&&Pe(),r===void 0?r=e.length-n:r>e.length-n&&Pe(),this.segments=e,this.offset=n,this.len=r}get length(){return this.len}isEqual(e){return _u.comparator(this,e)===0}child(e){const n=this.segments.slice(this.offset,this.limit());return e instanceof _u?e.forEach(r=>{n.push(r)}):n.push(e),this.construct(n)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let n=0;n<this.length;n++)if(this.get(n)!==e.get(n))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let n=0;n<this.length;n++)if(this.get(n)!==e.get(n))return!1;return!0}forEach(e){for(let n=this.offset,r=this.limit();n<r;n++)e(this.segments[n])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,n){const r=Math.min(e.length,n.length);for(let i=0;i<r;i++){const s=e.get(i),a=n.get(i);if(s<a)return-1;if(s>a)return 1}return e.length<n.length?-1:e.length>n.length?1:0}}class Mt extends _u{construct(e,n,r){return new Mt(e,n,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}static fromString(...e){const n=[];for(const r of e){if(r.indexOf("//")>=0)throw new Oe(ie.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);n.push(...r.split("/").filter(i=>i.length>0))}return new Mt(n)}static emptyPath(){return new Mt([])}}const IV=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class jn extends _u{construct(e,n,r){return new jn(e,n,r)}static isValidIdentifier(e){return IV.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),jn.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)==="__name__"}static keyField(){return new jn(["__name__"])}static fromServerFormat(e){const n=[];let r="",i=0;const s=()=>{if(r.length===0)throw new Oe(ie.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);n.push(r),r=""};let a=!1;for(;i<e.length;){const o=e[i];if(o==="\\"){if(i+1===e.length)throw new Oe(ie.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const l=e[i+1];if(l!=="\\"&&l!=="."&&l!=="`")throw new Oe(ie.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=l,i+=2}else o==="`"?(a=!a,i++):o!=="."||a?(r+=o,i++):(s(),i++)}if(s(),a)throw new Oe(ie.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new jn(n)}static emptyPath(){return new jn([])}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Ne{constructor(e){this.path=e}static fromPath(e){return new Ne(Mt.fromString(e))}static fromName(e){return new Ne(Mt.fromString(e).popFirst(5))}static empty(){return new Ne(Mt.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&Mt.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,n){return Mt.comparator(e.path,n.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new Ne(new Mt(e.slice()))}}function RV(t,e){const n=t.toTimestamp().seconds,r=t.toTimestamp().nanoseconds+1,i=Ge.fromTimestamp(r===1e9?new un(n+1,0):new un(n,r));return new aa(i,Ne.empty(),e)}function OV(t){return new aa(t.readTime,t.key,-1)}class aa{constructor(e,n,r){this.readTime=e,this.documentKey=n,this.largestBatchId=r}static min(){return new aa(Ge.min(),Ne.empty(),-1)}static max(){return new aa(Ge.max(),Ne.empty(),-1)}}function AV(t,e){let n=t.readTime.compareTo(e.readTime);return n!==0?n:(n=Ne.comparator(t.documentKey,e.documentKey),n!==0?n:ot(t.largestBatchId,e.largestBatchId))}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const wV="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class DV{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/async function pu(t){if(t.code!==ie.FAILED_PRECONDITION||t.message!==wV)throw t;ye("LocalStore","Unexpectedly lost primary lease")}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class te{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(n=>{this.isDone=!0,this.result=n,this.nextCallback&&this.nextCallback(n)},n=>{this.isDone=!0,this.error=n,this.catchCallback&&this.catchCallback(n)})}catch(e){return this.next(void 0,e)}next(e,n){return this.callbackAttached&&Pe(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(e,this.result):new te((r,i)=>{this.nextCallback=s=>{this.wrapSuccess(e,s).next(r,i)},this.catchCallback=s=>{this.wrapFailure(n,s).next(r,i)}})}toPromise(){return new Promise((e,n)=>{this.next(e,n)})}wrapUserFunction(e){try{const n=e();return n instanceof te?n:te.resolve(n)}catch(n){return te.reject(n)}}wrapSuccess(e,n){return e?this.wrapUserFunction(()=>e(n)):te.resolve(n)}wrapFailure(e,n){return e?this.wrapUserFunction(()=>e(n)):te.reject(n)}static resolve(e){return new te((n,r)=>{n(e)})}static reject(e){return new te((n,r)=>{r(e)})}static waitFor(e){return new te((n,r)=>{let i=0,s=0,a=!1;e.forEach(o=>{++i,o.next(()=>{++s,a&&s===i&&n()},l=>r(l))}),a=!0,s===i&&n()})}static or(e){let n=te.resolve(!1);for(const r of e)n=n.next(i=>i?te.resolve(i):r());return n}static forEach(e,n){const r=[];return e.forEach((i,s)=>{r.push(n.call(this,i,s))}),this.waitFor(r)}static mapArray(e,n){return new te((r,i)=>{const s=e.length,a=new Array(s);let o=0;for(let l=0;l<s;l++){const c=l;n(e[c]).next(u=>{a[c]=u,++o,o===s&&r(a)},u=>i(u))}})}static doWhile(e,n){return new te((r,i)=>{const s=()=>{e()===!0?n().next(()=>{s()},i):r()};s()})}}function mu(t){return t.name==="IndexedDbTransactionError"}/**
* @license
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class zE{constructor(e,n){this.previousValue=e,n&&(n.sequenceNumberHandler=r=>this.ut(r),this.ct=r=>n.writeSequenceNumber(r))}ut(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ct&&this.ct(e),e}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function hD(t){let e=0;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function _l(t,e){for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function gD(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/zE.at=-1;class dn{constructor(e,n){this.comparator=e,this.root=n||Mn.EMPTY}insert(e,n){return new dn(this.comparator,this.root.insert(e,n,this.comparator).copy(null,null,Mn.BLACK,null,null))}remove(e){return new dn(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Mn.BLACK,null,null))}get(e){let n=this.root;for(;!n.isEmpty();){const r=this.comparator(e,n.key);if(r===0)return n.value;r<0?n=n.left:r>0&&(n=n.right)}return null}indexOf(e){let n=0,r=this.root;for(;!r.isEmpty();){const i=this.comparator(e,r.key);if(i===0)return n+r.left.size;i<0?r=r.left:(n+=r.left.size+1,r=r.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((n,r)=>(e(n,r),!1))}toString(){const e=[];return this.inorderTraversal((n,r)=>(e.push(`${n}:${r}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new mp(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new mp(this.root,e,this.comparator,!1)}getReverseIterator(){return new mp(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new mp(this.root,e,this.comparator,!0)}}class mp{constructor(e,n,r,i){this.isReverse=i,this.nodeStack=[];let s=1;for(;!e.isEmpty();)if(s=n?r(e.key,n):1,n&&i&&(s*=-1),s<0)e=this.isReverse?e.left:e.right;else{if(s===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const n={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return n}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class Mn{constructor(e,n,r,i,s){this.key=e,this.value=n,this.color=r!=null?r:Mn.RED,this.left=i!=null?i:Mn.EMPTY,this.right=s!=null?s:Mn.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,n,r,i,s){return new Mn(e!=null?e:this.key,n!=null?n:this.value,r!=null?r:this.color,i!=null?i:this.left,s!=null?s:this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,n,r){let i=this;const s=r(e,i.key);return i=s<0?i.copy(null,null,null,i.left.insert(e,n,r),null):s===0?i.copy(null,n,null,null,null):i.copy(null,null,null,null,i.right.insert(e,n,r)),i.fixUp()}removeMin(){if(this.left.isEmpty())return Mn.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,n){let r,i=this;if(n(e,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(e,n),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),n(e,i.key)===0){if(i.right.isEmpty())return Mn.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(e,n))}return i.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,Mn.RED,null,this.right.left);return this.right.cop
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class _n{constructor(e){this.comparator=e,this.data=new dn(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((n,r)=>(e(n),!1))}forEachInRange(e,n){const r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){const i=r.getNext();if(this.comparator(i.key,e[1])>=0)return;n(i.key)}}forEachWhile(e,n){let r;for(r=n!==void 0?this.data.getIteratorFrom(n):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){const n=this.data.getIteratorFrom(e);return n.hasNext()?n.getNext().key:null}getIterator(){return new ED(this.data.getIterator())}getIteratorFrom(e){return new ED(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let n=this;return n.size<e.size&&(n=e,e=this),e.forEach(r=>{n=n.add(r)}),n}isEqual(e){if(!(e instanceof _n)||this.size!==e.size)return!1;const n=this.data.getIterator(),r=e.data.getIterator();for(;n.hasNext();){const i=n.getNext().key,s=r.getNext().key;if(this.comparator(i,s)!==0)return!1}return!0}toArray(){const e=[];return this.forEach(n=>{e.push(n)}),e}toString(){const e=[];return this.forEach(n=>e.push(n)),"SortedSet("+e.toString()+")"}copy(e){const n=new _n(this.comparator);return n.data=e,n}}class ED{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class wi{constructor(e){this.fields=e,e.sort(jn.comparator)}static empty(){return new wi([])}unionWith(e){let n=new _n(jn.comparator);for(const r of this.fields)n=n.add(r);for(const r of e)n=n.add(r);return new wi(n.toArray())}covers(e){for(const n of this.fields)if(n.isPrefixOf(e))return!0;return!1}isEqual(e){return dl(this.fields,e.fields,(n,r)=>n.isEqual(r))}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Ln{constructor(e){this.binaryString=e}static fromBase64String(e){const n=atob(e);return new Ln(n)}static fromUint8Array(e){const n=function(r){let i="";for(let s=0;s<r.length;++s)i+=String.fromCharCode(r[s]);return i}(e);return new Ln(n)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return e=this.binaryString,btoa(e);var e}toUint8Array(){return function(e){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return ot(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}Ln.EMPTY_BYTE_STRING=new Ln("");const MV=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function oa(t){if(yt(!!t),typeof t=="string"){let e=0;const n=MV.exec(t);if(yt(!!n),n[1]){let i=n[1];i=(i+"000000000").substr(0,9),e=Number(i)}const r=new Date(t);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:rn(t.seconds),nanos:rn(t.nanos)}}function rn(t){return typeof t=="number"?t:typeof t=="string"?Number(t):0}function pl(t){return typeof t=="string"?Ln.fromBase64String(t):Ln.fromUint8Array(t)}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function SD(t){var e,n;return((n=(((e=t==null?void 0:t.mapValue)===null||e===void 0?void 0:e.fields)||{}).__type__)===null||n===void 0?void 0:n.stringValue)==="server_timestamp"}function TD(t){const e=t.mapValue.fields.__previous_value__;return SD(e)?TD(e):e}function fu(t){const e=oa(t.mapValue.fields.__local_write_time__.timestampValue);return new un(e.seconds,e.nanos)}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class LV{constructor(e,n,r,i,s,a,o,l){this.databaseId=e,this.appId=n,this.persistenceKey=r,this.host=i,this.ssl=s,this.forceLongPolling=a,this.autoDetectLongPolling=o,this.useFetchStreams=l}}class hu{constructor(e,n){this.projectId=e,this.database=n||"(default)"}static empty(){return new hu("","")}get isDefaultDatabase(){return this.database==="(default)"}isEqual(e){return e instanceof hu&&e.projectId===this.projectId&&e.database===this.database}}function fp(t){return t==null}function hp(t){return t===0&&1/t==-1/0}function xV(t){return typeof t=="number"&&Number.isInteger(t)&&!hp(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const gp={mapValue:{fields:{__type__:{stringValue:"__max__"}}}};function Wa(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?SD(t)?4:PV(t)?9007199254740991:10:Pe()}function Di(t,e){if(t===e)return!0;const n=Wa(t);if(n!==Wa(e))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return fu(t).isEqual(fu(e));case 3:return function(r,i){if(typeof r.timestampValue=="string"&&typeof i.timestampValue=="string"&&r.timestampValue.length===i.timestampValue.length)return r.timestampValue===i.timestampValue;const s=oa(r.timestampValue),a=oa(i.timestampValue);return s.seconds===a.seconds&&s.nanos===a.nanos}(t,e);case 5:return t.stringValue===e.stringValue;case 6:return function(r,i){return pl(r.bytesValue).isEqual(pl(i.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(r,i){return rn(r.geoPointValue.latitude)===rn(i.geoPointValue.latitude)&&rn(r.geoPointValue.longitude)===rn(i.geoPointValue.longitude)}(t,e);case 2:return function(r,i){if("integerValue"in r&&"integerValue"in i)return rn(r.integerValue)===rn(i.integerValue);if("doubleValue"in r&&"doubleValue"in i){const s=rn(r.doubleValue),a=rn(i.doubleValue);return s===a?hp(s)===hp(a):isNaN(s)&&isNaN(a)}return!1}(t,e);case 9:return dl(t.arrayValue.values||[],e.arrayValue.values||[],Di);case 10:return function(r,i){const s=r.mapValue.fields||{},a=i.mapValue.fields||{};if(hD(s)!==hD(a))return!1;for(const o in s)if(s.hasOwnProperty(o)&&(a[o]===void 0||!Di(s[o],a[o])))return!1;return!0}(t,e);default:return Pe()}}function gu(t,e){return(t.values||[]).find(n=>Di(n,e))!==void 0}function ml(t,e){if(t===e)return 0;const n=Wa(t),r=Wa(e);if(n!==r)return ot(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return ot(t.booleanValue,e.booleanValue);case 2:return function(i,s){const a=rn(i.integerValue||i.doubleValue),o=rn(s.integerValue||s.doubleValue);return a<o?-1:a>o?1:a===o?0:isNaN(a)?isNaN(o)?0:-1:1}(t,e);case 3:return vD(t.timestampValue,e.timestampValue);case 4:return vD(fu(t),fu(e));case 5:return ot(t.stringValue,e.stringValue);case 6:return function(i,s){const a=pl(i),o=pl(s);return a.compareTo(o)}(t.bytesValue,e.bytesValue);case 7:return function(i,s){const a=i.split("/"),o=s.split("/");for(let l=0;l<a.length&&l<o.length;l++){const c=ot(a[l],o[l]);if(c!==0)return c}return ot(a.length,o.length)}(t.referenceValue,e.referenceValue);case 8:return function(i,s){const a=ot(rn(i.latitude),rn(s.latitude));return a!==0?a:ot(rn(i.longitude),rn(s.longitude))}(t.geoPointValue,e.geoPointValue);case 9:return function(i,s){const a=i.values||[],o=s.values||[];for(let l=0;l<a.length&&l<o.length;++l){const c=ml(a[l],o[l]);if(c)return c}return ot(a.length,o.length)}(t.arrayValue,e.arrayValue);case 10:return function(i,s){if(i===gp.mapValue&&s===gp.mapValue)return 0;if(i===gp.mapValue)return 1;if(s===gp.mapValue)return-1;const a=i.fields||{},o=Object.keys(a),l=s.fields||{},c=Object.keys(l);o.sort(),c.sort();for(let u=0;u<o.length&&u<c.length;++u){const d=ot(o[u],c[u]);if(d!==0)return d;const _=ml(a[o[u]],l[c[u]]);if(_!==0)return _}return ot(o.length,c.length)}(t.mapValue,e.mapValue);default:throw Pe()}}function vD(t,e){if(typeof t=="string"&&typeof e=="string"&&t.length===e.length)return ot(t,e);const n=oa(t),r=oa(e),i=ot(n.seconds,r.seconds);return i!==0?i:ot(n.nanos,r.nanos)}function fl(t){return VE(t)}function VE(t){return"nullValue"in t?"null":"booleanValue"in t?""+t.booleanValue:"integerValue"in t?""+t.integerValue:"doubleValue"in t?""+t.doubleValue:"timestampValue"in t?function(r){const i=oa(r);return`time(${i.seconds},${i.nanos})`}(t.timestampValue):"stringValue"in t?t.stringValue:"bytesValue"in t?pl(t.bytesValue).toBase64():"referenceValue"in t?(n=t.referenceValue,Ne.fromName(n).toString()):"geoPointValue"in t?`geo(${(e=t.geoPointValue).latitude},${e.longitude})`:"arrayValue"in t?function(r){let i="[",s=!0;for(con
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class jr{constructor(e){this.value=e}static empty(){return new jr({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let n=this.value;for(let r=0;r<e.length-1;++r)if(n=(n.mapValue.fields||{})[e.get(r)],!Ep(n))return null;return n=(n.mapValue.fields||{})[e.lastSegment()],n||null}}set(e,n){this.getFieldsMap(e.popLast())[e.lastSegment()]=Eu(n)}setAll(e){let n=jn.emptyPath(),r={},i=[];e.forEach((a,o)=>{if(!n.isImmediateParentOf(o)){const l=this.getFieldsMap(n);this.applyChanges(l,r,i),r={},i=[],n=o.popLast()}a?r[o.lastSegment()]=Eu(a):i.push(o.lastSegment())});const s=this.getFieldsMap(n);this.applyChanges(s,r,i)}delete(e){const n=this.field(e.popLast());Ep(n)&&n.mapValue.fields&&delete n.mapValue.fields[e.lastSegment()]}isEqual(e){return Di(this.value,e.value)}getFieldsMap(e){let n=this.value;n.mapValue.fields||(n.mapValue={fields:{}});for(let r=0;r<e.length;++r){let i=n.mapValue.fields[e.get(r)];Ep(i)&&i.mapValue.fields||(i={mapValue:{fields:{}}},n.mapValue.fields[e.get(r)]=i),n=i}return n.mapValue.fields}applyChanges(e,n,r){_l(n,(i,s)=>e[i]=s);for(const i of r)delete e[i]}clone(){return new jr(Eu(this.value))}}function CD(t){const e=[];return _l(t.fields,(n,r)=>{const i=new jn([n]);if(Ep(r)){const s=CD(r.mapValue).fields;if(s.length===0)e.push(i);else for(const a of s)e.push(i.child(a))}else e.push(i)}),new wi(e)}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class xn{constructor(e,n,r,i,s,a){this.key=e,this.documentType=n,this.version=r,this.readTime=i,this.data=s,this.documentState=a}static newInvalidDocument(e){return new xn(e,0,Ge.min(),Ge.min(),jr.empty(),0)}static newFoundDocument(e,n,r){return new xn(e,1,n,Ge.min(),r,0)}static newNoDocument(e,n){return new xn(e,2,n,Ge.min(),jr.empty(),0)}static newUnknownDocument(e,n){return new xn(e,3,n,Ge.min(),jr.empty(),2)}convertToFoundDocument(e,n){return this.version=e,this.documentType=1,this.data=n,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=jr.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=jr.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=Ge.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof xn&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new xn(this.key,this.documentType,this.version,this.readTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class kV{constructor(e,n=null,r=[],i=[],s=null,a=null,o=null){this.path=e,this.collectionGroup=n,this.orderBy=r,this.filters=i,this.limit=s,this.startAt=a,this.endAt=o,this.ht=null}}function ND(t,e=null,n=[],r=[],i=null,s=null,a=null){return new kV(t,e,n,r,i,s,a)}function qE(t){const e=ke(t);if(e.ht===null){let n=e.path.canonicalString();e.collectionGroup!==null&&(n+="|cg:"+e.collectionGroup),n+="|f:",n+=e.filters.map(r=>{return(i=r).field.canonicalString()+i.op.toString()+fl(i.value);var i}).join(","),n+="|ob:",n+=e.orderBy.map(r=>function(i){return i.field.canonicalString()+i.dir}(r)).join(","),fp(e.limit)||(n+="|l:",n+=e.limit),e.startAt&&(n+="|lb:",n+=e.startAt.inclusive?"b:":"a:",n+=e.startAt.position.map(r=>fl(r)).join(",")),e.endAt&&(n+="|ub:",n+=e.endAt.inclusive?"a:":"b:",n+=e.endAt.position.map(r=>fl(r)).join(",")),e.ht=n}return e.ht}function UV(t){let e=t.path.canonicalString();return t.collectionGroup!==null&&(e+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(e+=`, filters: [${t.filters.map(n=>{return`${(r=n).field.canonicalString()} ${r.op} ${fl(r.value)}`;var r}).join(", ")}]`),fp(t.limit)||(e+=", limit: "+t.limit),t.orderBy.length>0&&(e+=`, orderBy: [${t.orderBy.map(n=>function(r){return`${r.field.canonicalString()} (${r.dir})`}(n)).join(", ")}]`),t.startAt&&(e+=", startAt: ",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map(n=>fl(n)).join(",")),t.endAt&&(e+=", endAt: ",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map(n=>fl(n)).join(",")),`Target(${e})`}function WE(t,e){if(t.limit!==e.limit||t.orderBy.length!==e.orderBy.length)return!1;for(let i=0;i<t.orderBy.length;i++)if(!jV(t.orderBy[i],e.orderBy[i]))return!1;if(t.filters.length!==e.filters.length)return!1;for(let i=0;i<t.filters.length;i++)if(n=t.filters[i],r=e.filters[i],n.op!==r.op||!n.field.isEqual(r.field)||!Di(n.value,r.value))return!1;var n,r;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!OD(t.startAt,e.startAt)&&OD(t.endAt,e.endAt)}function QE(t){return Ne.isDocumentKey(t.path)&&t.collectionGroup===null&&t.filters.length===0}class fr extends class{}{constructor(e,n,r){super(),this.field=e,this.op=n,this.value=r}static create(e,n,r){return e.isKeyField()?n==="in"||n==="not-in"?this.lt(e,n,r):new FV(e,n,r):n==="array-contains"?new $V(e,r):n==="in"?new YV(e,r):n==="not-in"?new zV(e,r):n==="array-contains-any"?new VV(e,r):new fr(e,n,r)}static lt(e,n,r){return n==="in"?new BV(e,r):new GV(e,r)}matches(e){const n=e.data.field(this.field);return this.op==="!="?n!==null&&this.ft(ml(n,this.value)):n!==null&&Wa(this.value)===Wa(n)&&this.ft(ml(n,this.value))}ft(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return Pe()}}dt(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}}class FV extends fr{constructor(e,n,r){super(e,n,r),this.key=Ne.fromName(r.referenceValue)}matches(e){const n=Ne.comparator(e.key,this.key);return this.ft(n)}}class BV extends fr{constructor(e,n){super(e,"in",n),this.keys=ID("in",n)}matches(e){return this.keys.some(n=>n.isEqual(e.key))}}class GV extends fr{constructor(e,n){super(e,"not-in",n),this.keys=ID("not-in",n)}matches(e){return!this.keys.some(n=>n.isEqual(e.key))}}function ID(t,e){var n;return(((n=e.arrayValue)===null||n===void 0?void 0:n.values)||[]).map(r=>Ne.fromName(r.referenceValue))}class $V extends fr{constructor(e,n){super(e,"array-contains",n)}matches(e){const n=e.data.field(this.field);return HE(n)&&gu(n.arrayValue,this.value)}}class YV extends fr{constructor(e,n){super(e,"in",n)}matches(e){const n=e.data.field(this.field);return n!==null&&gu(this.value.arrayValue,n)}}class zV extends fr{constructor(e,n){super(e,"not-in",n)}matches(e){if(gu(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const n=e.data.field(this.field);return n!==null&&!gu(this.value.arrayValue,n)}}class VV extends fr{constructor(e,n){super(e,"array-contains-any",n)}matches(e){const n=e.data.field(this.field);return!(!HE(n)||!n.arrayValue.values)&&n.arrayValue.values.some(r
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Tp{constructor(e,n=null,r=[],i=[],s=null,a="F",o=null,l=null){this.path=e,this.collectionGroup=n,this.explicitOrderBy=r,this.filters=i,this.limit=s,this.limitType=a,this.startAt=o,this.endAt=l,this._t=null,this.wt=null,this.startAt,this.endAt}}function HV(t,e,n,r,i,s,a,o){return new Tp(t,e,n,r,i,s,a,o)}function KE(t){return new Tp(t)}function AD(t){return t.filters.length===0&&t.limit===null&&t.startAt==null&&t.endAt==null&&(t.explicitOrderBy.length===0||t.explicitOrderBy.length===1&&t.explicitOrderBy[0].field.isKeyField())}function qV(t){return t.explicitOrderBy.length>0?t.explicitOrderBy[0].field:null}function WV(t){for(const e of t.filters)if(e.dt())return e.field;return null}function QV(t){return t.collectionGroup!==null}function Tu(t){const e=ke(t);if(e._t===null){e._t=[];const n=WV(e),r=qV(e);if(n!==null&&r===null)n.isKeyField()||e._t.push(new Su(n)),e._t.push(new Su(jn.keyField(),"asc"));else{let i=!1;for(const s of e.explicitOrderBy)e._t.push(s),s.field.isKeyField()&&(i=!0);if(!i){const s=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";e._t.push(new Su(jn.keyField(),s))}}}return e._t}function cs(t){const e=ke(t);if(!e.wt)if(e.limitType==="F")e.wt=ND(e.path,e.collectionGroup,Tu(e),e.filters,e.limit,e.startAt,e.endAt);else{const n=[];for(const s of Tu(e)){const a=s.dir==="desc"?"asc":"desc";n.push(new Su(s.field,a))}const r=e.endAt?new Sp(e.endAt.position,e.endAt.inclusive):null,i=e.startAt?new Sp(e.startAt.position,e.startAt.inclusive):null;e.wt=ND(e.path,e.collectionGroup,n,e.filters,e.limit,r,i)}return e.wt}function XE(t,e,n){return new Tp(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function vp(t,e){return WE(cs(t),cs(e))&&t.limitType===e.limitType}function wD(t){return`${qE(cs(t))}|lt:${t.limitType}`}function ZE(t){return`Query(target=${UV(cs(t))}; limitType=${t.limitType})`}function JE(t,e){return e.isFoundDocument()&&function(n,r){const i=r.key.path;return n.collectionGroup!==null?r.key.hasCollectionId(n.collectionGroup)&&n.path.isPrefixOf(i):Ne.isDocumentKey(n.path)?n.path.isEqual(i):n.path.isImmediateParentOf(i)}(t,e)&&function(n,r){for(const i of n.explicitOrderBy)if(!i.field.isKeyField()&&r.data.field(i.field)===null)return!1;return!0}(t,e)&&function(n,r){for(const i of n.filters)if(!i.matches(r))return!1;return!0}(t,e)&&function(n,r){return!(n.startAt&&!function(i,s,a){const o=RD(i,s,a);return i.inclusive?o<=0:o<0}(n.startAt,Tu(n),r)||n.endAt&&!function(i,s,a){const o=RD(i,s,a);return i.inclusive?o>=0:o>0}(n.endAt,Tu(n),r))}(t,e)}function KV(t){return t.collectionGroup||(t.path.length%2==1?t.path.lastSegment():t.path.get(t.path.length-2))}function DD(t){return(e,n)=>{let r=!1;for(const i of Tu(t)){const s=XV(i,e,n);if(s!==0)return s;r=r||i.field.isKeyField()}return 0}}function XV(t,e,n){const r=t.field.isKeyField()?Ne.comparator(e.key,n.key):function(i,s,a){const o=s.data.field(i),l=a.data.field(i);return o!==null&&l!==null?ml(o,l):Pe()}(t.field,e,n);switch(t.dir){case"asc":return r;case"desc":return-1*r;default:return Pe()}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function MD(t,e){if(t.gt){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:hp(e)?"-0":e}}function LD(t){return{integerValue:""+t}}function ZV(t,e){return xV(e)?LD(e):MD(t,e)}/**
* @license
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class yp{constructor(){this._=void 0}}function JV(t,e,n){return t instanceof bp?function(r,i){const s={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:r.seconds,nanos:r.nanoseconds}}}};return i&&(s.fields.__previous_value__=i),{mapValue:s}}(n,e):t instanceof vu?PD(t,e):t instanceof yu?kD(t,e):function(r,i){const s=xD(r,i),a=UD(s)+UD(r.yt);return jE(s)&&jE(r.yt)?LD(a):MD(r.It,a)}(t,e)}function e4(t,e,n){return t instanceof vu?PD(t,e):t instanceof yu?kD(t,e):n}function xD(t,e){return t instanceof Cp?jE(n=e)||function(r){return!!r&&"doubleValue"in r}(n)?e:{integerValue:0}:null;var n}class bp extends yp{}class vu extends yp{constructor(e){super(),this.elements=e}}function PD(t,e){const n=FD(e);for(const r of t.elements)n.some(i=>Di(i,r))||n.push(r);return{arrayValue:{values:n}}}class yu extends yp{constructor(e){super(),this.elements=e}}function kD(t,e){let n=FD(e);for(const r of t.elements)n=n.filter(i=>!Di(i,r));return{arrayValue:{values:n}}}class Cp extends yp{constructor(e,n){super(),this.It=e,this.yt=n}}function UD(t){return rn(t.integerValue||t.doubleValue)}function FD(t){return HE(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}function t4(t,e){return t.field.isEqual(e.field)&&function(n,r){return n instanceof vu&&r instanceof vu||n instanceof yu&&r instanceof yu?dl(n.elements,r.elements,Di):n instanceof Cp&&r instanceof Cp?Di(n.yt,r.yt):n instanceof bp&&r instanceof bp}(t.transform,e.transform)}class n4{constructor(e,n){this.version=e,this.transformResults=n}}class oi{constructor(e,n){this.updateTime=e,this.exists=n}static none(){return new oi}static exists(e){return new oi(void 0,e)}static updateTime(e){return new oi(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function Np(t,e){return t.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(t.updateTime):t.exists===void 0||t.exists===e.isFoundDocument()}class Ip{}function BD(t,e){if(!t.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return t.isNoDocument()?new eS(t.key,oi.none()):new Cu(t.key,t.data,oi.none());{const n=t.data,r=jr.empty();let i=new _n(jn.comparator);for(let s of e.fields)if(!i.has(s)){let a=n.field(s);a===null&&s.length>1&&(s=s.popLast(),a=n.field(s)),a===null?r.delete(s):r.set(s,a),i=i.add(s)}return new Qa(t.key,r,new wi(i.toArray()),oi.none())}}function r4(t,e,n){t instanceof Cu?function(r,i,s){const a=r.value.clone(),o=YD(r.fieldTransforms,i,s.transformResults);a.setAll(o),i.convertToFoundDocument(s.version,a).setHasCommittedMutations()}(t,e,n):t instanceof Qa?function(r,i,s){if(!Np(r.precondition,i))return void i.convertToUnknownDocument(s.version);const a=YD(r.fieldTransforms,i,s.transformResults),o=i.data;o.setAll($D(r)),o.setAll(a),i.convertToFoundDocument(s.version,o).setHasCommittedMutations()}(t,e,n):function(r,i,s){i.convertToNoDocument(s.version).setHasCommittedMutations()}(0,e,n)}function bu(t,e,n,r){return t instanceof Cu?function(i,s,a,o){if(!Np(i.precondition,s))return a;const l=i.value.clone(),c=zD(i.fieldTransforms,o,s);return l.setAll(c),s.convertToFoundDocument(s.version,l).setHasLocalMutations(),null}(t,e,n,r):t instanceof Qa?function(i,s,a,o){if(!Np(i.precondition,s))return a;const l=zD(i.fieldTransforms,o,s),c=s.data;return c.setAll($D(i)),c.setAll(l),s.convertToFoundDocument(s.version,c).setHasLocalMutations(),a===null?null:a.unionWith(i.fieldMask.fields).unionWith(i.fieldTransforms.map(u=>u.field))}(t,e,n,r):function(i,s,a){return Np(i.precondition,s)?(s.convertToNoDocument(s.version).setHasLocalMutations(),null):a}(t,e,n)}function i4(t,e){let n=null;for(const r of t.fieldTransforms){const i=e.data.field(r.field),s=xD(r.transform,i||null);s!=null&&(n===null&&(n=jr.empty()),n.set(r.field,s))}return n||null}function GD(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&!!function(n,r){return n===void 0&&r===void 0||!(!n||!r)&&dl(n,r,(i,s)=>t4(i,s))}(t.f
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class a4{constructor(e){this.count=e}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var sn,We;function o4(t){switch(t){default:return Pe();case ie.CANCELLED:case ie.UNKNOWN:case ie.DEADLINE_EXCEEDED:case ie.RESOURCE_EXHAUSTED:case ie.INTERNAL:case ie.UNAVAILABLE:case ie.UNAUTHENTICATED:return!1;case ie.INVALID_ARGUMENT:case ie.NOT_FOUND:case ie.ALREADY_EXISTS:case ie.PERMISSION_DENIED:case ie.FAILED_PRECONDITION:case ie.ABORTED:case ie.OUT_OF_RANGE:case ie.UNIMPLEMENTED:case ie.DATA_LOSS:return!0}}function VD(t){if(t===void 0)return ls("GRPC error has no .code"),ie.UNKNOWN;switch(t){case sn.OK:return ie.OK;case sn.CANCELLED:return ie.CANCELLED;case sn.UNKNOWN:return ie.UNKNOWN;case sn.DEADLINE_EXCEEDED:return ie.DEADLINE_EXCEEDED;case sn.RESOURCE_EXHAUSTED:return ie.RESOURCE_EXHAUSTED;case sn.INTERNAL:return ie.INTERNAL;case sn.UNAVAILABLE:return ie.UNAVAILABLE;case sn.UNAUTHENTICATED:return ie.UNAUTHENTICATED;case sn.INVALID_ARGUMENT:return ie.INVALID_ARGUMENT;case sn.NOT_FOUND:return ie.NOT_FOUND;case sn.ALREADY_EXISTS:return ie.ALREADY_EXISTS;case sn.PERMISSION_DENIED:return ie.PERMISSION_DENIED;case sn.FAILED_PRECONDITION:return ie.FAILED_PRECONDITION;case sn.ABORTED:return ie.ABORTED;case sn.OUT_OF_RANGE:return ie.OUT_OF_RANGE;case sn.UNIMPLEMENTED:return ie.UNIMPLEMENTED;case sn.DATA_LOSS:return ie.DATA_LOSS;default:return Pe()}}(We=sn||(sn={}))[We.OK=0]="OK",We[We.CANCELLED=1]="CANCELLED",We[We.UNKNOWN=2]="UNKNOWN",We[We.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",We[We.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",We[We.NOT_FOUND=5]="NOT_FOUND",We[We.ALREADY_EXISTS=6]="ALREADY_EXISTS",We[We.PERMISSION_DENIED=7]="PERMISSION_DENIED",We[We.UNAUTHENTICATED=16]="UNAUTHENTICATED",We[We.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",We[We.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",We[We.ABORTED=10]="ABORTED",We[We.OUT_OF_RANGE=11]="OUT_OF_RANGE",We[We.UNIMPLEMENTED=12]="UNIMPLEMENTED",We[We.INTERNAL=13]="INTERNAL",We[We.UNAVAILABLE=14]="UNAVAILABLE",We[We.DATA_LOSS=15]="DATA_LOSS";/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class hl{constructor(e,n){this.mapKeyFn=e,this.equalsFn=n,this.inner={},this.innerSize=0}get(e){const n=this.mapKeyFn(e),r=this.inner[n];if(r!==void 0){for(const[i,s]of r)if(this.equalsFn(i,e))return s}}has(e){return this.get(e)!==void 0}set(e,n){const r=this.mapKeyFn(e),i=this.inner[r];if(i===void 0)return this.inner[r]=[[e,n]],void this.innerSize++;for(let s=0;s<i.length;s++)if(this.equalsFn(i[s][0],e))return void(i[s]=[e,n]);i.push([e,n]),this.innerSize++}delete(e){const n=this.mapKeyFn(e),r=this.inner[n];if(r===void 0)return!1;for(let i=0;i<r.length;i++)if(this.equalsFn(r[i][0],e))return r.length===1?delete this.inner[n]:r.splice(i,1),this.innerSize--,!0;return!1}forEach(e){_l(this.inner,(n,r)=>{for(const[i,s]of r)e(i,s)})}isEmpty(){return gD(this.inner)}size(){return this.innerSize}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const l4=new dn(Ne.comparator);function us(){return l4}const jD=new dn(Ne.comparator);function Nu(...t){let e=jD;for(const n of t)e=e.insert(n.key,n);return e}function HD(t){let e=jD;return t.forEach((n,r)=>e=e.insert(n,r.overlayedDocument)),e}function Ka(){return Iu()}function qD(){return Iu()}function Iu(){return new hl(t=>t.toString(),(t,e)=>t.isEqual(e))}const c4=new dn(Ne.comparator),u4=new _n(Ne.comparator);function Ve(...t){let e=u4;for(const n of t)e=e.add(n);return e}const d4=new _n(ot);function WD(){return d4}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Rp{constructor(e,n,r,i,s){this.snapshotVersion=e,this.targetChanges=n,this.targetMismatches=r,this.documentUpdates=i,this.resolvedLimboDocuments=s}static createSynthesizedRemoteEventForCurrentChange(e,n){const r=new Map;return r.set(e,Ru.createSynthesizedTargetChangeForCurrentChange(e,n)),new Rp(Ge.min(),r,WD(),us(),Ve())}}class Ru{constructor(e,n,r,i,s){this.resumeToken=e,this.current=n,this.addedDocuments=r,this.modifiedDocuments=i,this.removedDocuments=s}static createSynthesizedTargetChangeForCurrentChange(e,n){return new Ru(Ln.EMPTY_BYTE_STRING,n,Ve(),Ve(),Ve())}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Op{constructor(e,n,r,i){this.Tt=e,this.removedTargetIds=n,this.key=r,this.Et=i}}class QD{constructor(e,n){this.targetId=e,this.At=n}}class KD{constructor(e,n,r=Ln.EMPTY_BYTE_STRING,i=null){this.state=e,this.targetIds=n,this.resumeToken=r,this.cause=i}}class XD{constructor(){this.Rt=0,this.bt=JD(),this.Pt=Ln.EMPTY_BYTE_STRING,this.vt=!1,this.Vt=!0}get current(){return this.vt}get resumeToken(){return this.Pt}get St(){return this.Rt!==0}get Dt(){return this.Vt}Ct(e){e.approximateByteSize()>0&&(this.Vt=!0,this.Pt=e)}xt(){let e=Ve(),n=Ve(),r=Ve();return this.bt.forEach((i,s)=>{switch(s){case 0:e=e.add(i);break;case 2:n=n.add(i);break;case 1:r=r.add(i);break;default:Pe()}}),new Ru(this.Pt,this.vt,e,n,r)}Nt(){this.Vt=!1,this.bt=JD()}kt(e,n){this.Vt=!0,this.bt=this.bt.insert(e,n)}Mt(e){this.Vt=!0,this.bt=this.bt.remove(e)}Ot(){this.Rt+=1}Ft(){this.Rt-=1}$t(){this.Vt=!0,this.vt=!0}}class _4{constructor(e){this.Bt=e,this.Lt=new Map,this.Ut=us(),this.qt=ZD(),this.Kt=new _n(ot)}Gt(e){for(const n of e.Tt)e.Et&&e.Et.isFoundDocument()?this.Qt(n,e.Et):this.jt(n,e.key,e.Et);for(const n of e.removedTargetIds)this.jt(n,e.key,e.Et)}Wt(e){this.forEachTarget(e,n=>{const r=this.zt(n);switch(e.state){case 0:this.Ht(n)&&r.Ct(e.resumeToken);break;case 1:r.Ft(),r.St||r.Nt(),r.Ct(e.resumeToken);break;case 2:r.Ft(),r.St||this.removeTarget(n);break;case 3:this.Ht(n)&&(r.$t(),r.Ct(e.resumeToken));break;case 4:this.Ht(n)&&(this.Jt(n),r.Ct(e.resumeToken));break;default:Pe()}})}forEachTarget(e,n){e.targetIds.length>0?e.targetIds.forEach(n):this.Lt.forEach((r,i)=>{this.Ht(i)&&n(i)})}Yt(e){const n=e.targetId,r=e.At.count,i=this.Xt(n);if(i){const s=i.target;if(QE(s))if(r===0){const a=new Ne(s.path);this.jt(n,a,xn.newNoDocument(a,Ge.min()))}else yt(r===1);else this.Zt(n)!==r&&(this.Jt(n),this.Kt=this.Kt.add(n))}}te(e){const n=new Map;this.Lt.forEach((s,a)=>{const o=this.Xt(a);if(o){if(s.current&&QE(o.target)){const l=new Ne(o.target.path);this.Ut.get(l)!==null||this.ee(a,l)||this.jt(a,l,xn.newNoDocument(l,e))}s.Dt&&(n.set(a,s.xt()),s.Nt())}});let r=Ve();this.qt.forEach((s,a)=>{let o=!0;a.forEachWhile(l=>{const c=this.Xt(l);return!c||c.purpose===2||(o=!1,!1)}),o&&(r=r.add(s))}),this.Ut.forEach((s,a)=>a.setReadTime(e));const i=new Rp(e,n,this.Kt,this.Ut,r);return this.Ut=us(),this.qt=ZD(),this.Kt=new _n(ot),i}Qt(e,n){if(!this.Ht(e))return;const r=this.ee(e,n.key)?2:0;this.zt(e).kt(n.key,r),this.Ut=this.Ut.insert(n.key,n),this.qt=this.qt.insert(n.key,this.ne(n.key).add(e))}jt(e,n,r){if(!this.Ht(e))return;const i=this.zt(e);this.ee(e,n)?i.kt(n,1):i.Mt(n),this.qt=this.qt.insert(n,this.ne(n).delete(e)),r&&(this.Ut=this.Ut.insert(n,r))}removeTarget(e){this.Lt.delete(e)}Zt(e){const n=this.zt(e).xt();return this.Bt.getRemoteKeysForTarget(e).size+n.addedDocuments.size-n.removedDocuments.size}Ot(e){this.zt(e).Ot()}zt(e){let n=this.Lt.get(e);return n||(n=new XD,this.Lt.set(e,n)),n}ne(e){let n=this.qt.get(e);return n||(n=new _n(ot),this.qt=this.qt.insert(e,n)),n}Ht(e){const n=this.Xt(e)!==null;return n||ye("WatchChangeAggregator","Detected inactive target",e),n}Xt(e){const n=this.Lt.get(e);return n&&n.St?null:this.Bt.se(e)}Jt(e){this.Lt.set(e,new XD),this.Bt.getRemoteKeysForTarget(e).forEach(n=>{this.jt(e,n,null)})}ee(e,n){return this.Bt.getRemoteKeysForTarget(e).has(n)}}function ZD(){return new dn(Ne.comparator)}function JD(){return new dn(Ne.comparator)}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const p4=(()=>({asc:"ASCENDING",desc:"DESCENDING"}))(),m4=(()=>({"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"}))();class f4{constructor(e,n){this.databaseId=e,this.gt=n}}function Ap(t,e){return t.gt?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function eM(t,e){return t.gt?e.toBase64():e.toUint8Array()}function h4(t,e){return Ap(t,e.toTimestamp())}function ds(t){return yt(!!t),Ge.fromTimestamp(function(e){const n=oa(e);return new un(n.seconds,n.nanos)}(t))}function tS(t,e){return function(n){return new Mt(["projects",n.projectId,"databases",n.database])}(t).child("documents").child(e).canonicalString()}function tM(t){const e=Mt.fromString(t);return yt(sM(e)),e}function nS(t,e){return tS(t.databaseId,e.path)}function rS(t,e){const n=tM(e);if(n.get(1)!==t.databaseId.projectId)throw new Oe(ie.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+t.databaseId.projectId);if(n.get(3)!==t.databaseId.database)throw new Oe(ie.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new Ne(nM(n))}function iS(t,e){return tS(t.databaseId,e)}function g4(t){const e=tM(t);return e.length===4?Mt.emptyPath():nM(e)}function sS(t){return new Mt(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function nM(t){return yt(t.length>4&&t.get(4)==="documents"),t.popFirst(5)}function rM(t,e,n){return{name:nS(t,e),fields:n.value.mapValue.fields}}function E4(t,e){let n;if("targetChange"in e){e.targetChange;const r=function(l){return l==="NO_CHANGE"?0:l==="ADD"?1:l==="REMOVE"?2:l==="CURRENT"?3:l==="RESET"?4:Pe()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],s=function(l,c){return l.gt?(yt(c===void 0||typeof c=="string"),Ln.fromBase64String(c||"")):(yt(c===void 0||c instanceof Uint8Array),Ln.fromUint8Array(c||new Uint8Array))}(t,e.targetChange.resumeToken),a=e.targetChange.cause,o=a&&function(l){const c=l.code===void 0?ie.UNKNOWN:VD(l.code);return new Oe(c,l.message||"")}(a);n=new KD(r,i,s,o||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const i=rS(t,r.document.name),s=ds(r.document.updateTime),a=new jr({mapValue:{fields:r.document.fields}}),o=xn.newFoundDocument(i,s,a),l=r.targetIds||[],c=r.removedTargetIds||[];n=new Op(l,c,o.key,o)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const i=rS(t,r.document),s=r.readTime?ds(r.readTime):Ge.min(),a=xn.newNoDocument(i,s),o=r.removedTargetIds||[];n=new Op([],o,a.key,a)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const i=rS(t,r.document),s=r.removedTargetIds||[];n=new Op([],s,i,null)}else{if(!("filter"in e))return Pe();{e.filter;const r=e.filter;r.targetId;const i=r.count||0,s=new a4(i),a=r.targetId;n=new QD(a,s)}}return n}function S4(t,e){let n;if(e instanceof Cu)n={update:rM(t,e.key,e.value)};else if(e instanceof eS)n={delete:nS(t,e.key)};else if(e instanceof Qa)n={update:rM(t,e.key,e.data),updateMask:A4(e.fieldMask)};else{if(!(e instanceof s4))return Pe();n={verify:nS(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map(r=>function(i,s){const a=s.transform;if(a instanceof bp)return{fieldPath:s.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(a instanceof vu)return{fieldPath:s.field.canonicalString(),appendMissingElements:{values:a.elements}};if(a instanceof yu)return{fieldPath:s.field.canonicalString(),removeAllFromArray:{values:a.elements}};if(a instanceof Cp)return{fieldPath:s.field.canonicalString(),increment:a.yt};throw Pe()}(0,r))),e.precondition.isNone||(n.currentDocument=function(r,i){return i.updateTime!==void 0?{updateTime:h4(r,i.updateTime)}:i.exist
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class w4{constructor(e,n,r,i){this.batchId=e,this.localWriteTime=n,this.baseMutations=r,this.mutations=i}applyToRemoteDocument(e,n){const r=n.mutationResults;for(let i=0;i<this.mutations.length;i++){const s=this.mutations[i];s.key.isEqual(e.key)&&r4(s,e,r[i])}}applyToLocalView(e,n){for(const r of this.baseMutations)r.key.isEqual(e.key)&&(n=bu(r,e,n,this.localWriteTime));for(const r of this.mutations)r.key.isEqual(e.key)&&(n=bu(r,e,n,this.localWriteTime));return n}applyToLocalDocumentSet(e,n){const r=qD();return this.mutations.forEach(i=>{const s=e.get(i.key),a=s.overlayedDocument;let o=this.applyToLocalView(a,s.mutatedFields);o=n.has(i.key)?null:o;const l=BD(a,o);l!==null&&r.set(i.key,l),a.isValidDocument()||a.convertToNoDocument(Ge.min())}),r}keys(){return this.mutations.reduce((e,n)=>e.add(n.key),Ve())}isEqual(e){return this.batchId===e.batchId&&dl(this.mutations,e.mutations,(n,r)=>GD(n,r))&&dl(this.baseMutations,e.baseMutations,(n,r)=>GD(n,r))}}class aS{constructor(e,n,r,i){this.batch=e,this.commitVersion=n,this.mutationResults=r,this.docVersions=i}static from(e,n,r){yt(e.mutations.length===r.length);let i=c4;const s=e.mutations;for(let a=0;a<s.length;a++)i=i.insert(s[a].key,r[a].version);return new aS(e,n,r,i)}}/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class D4{constructor(e,n){this.largestBatchId=e,this.mutation=n}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
largestBatchId: ${this.largestBatchId},
mutation: ${this.mutation.toString()}
}`}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Xa{constructor(e,n,r,i,s=Ge.min(),a=Ge.min(),o=Ln.EMPTY_BYTE_STRING){this.target=e,this.targetId=n,this.purpose=r,this.sequenceNumber=i,this.snapshotVersion=s,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=o}withSequenceNumber(e){return new Xa(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)}withResumeToken(e,n){return new Xa(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,e)}withLastLimboFreeSnapshotVersion(e){return new Xa(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken)}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class M4{constructor(e){this.re=e}}function L4(t){const e=b4({parent:t.parent,structuredQuery:t.structuredQuery});return t.limitType==="LAST"?XE(e,e.limit,"L"):e}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class x4{constructor(){this.Ye=new P4}addToCollectionParentIndex(e,n){return this.Ye.add(n),te.resolve()}getCollectionParents(e,n){return te.resolve(this.Ye.getEntries(n))}addFieldIndex(e,n){return te.resolve()}deleteFieldIndex(e,n){return te.resolve()}getDocumentsMatchingTarget(e,n){return te.resolve(null)}getIndexType(e,n){return te.resolve(0)}getFieldIndexes(e,n){return te.resolve([])}getNextCollectionGroupToUpdate(e){return te.resolve(null)}getMinOffset(e,n){return te.resolve(aa.min())}getMinOffsetFromCollectionGroup(e,n){return te.resolve(aa.min())}updateCollectionGroup(e,n,r){return te.resolve()}updateIndexEntries(e,n){return te.resolve()}}class P4{constructor(){this.index={}}add(e){const n=e.lastSegment(),r=e.popLast(),i=this.index[n]||new _n(Mt.comparator),s=!i.has(r);return this.index[n]=i.add(r),s}has(e){const n=e.lastSegment(),r=e.popLast(),i=this.index[n];return i&&i.has(r)}getEntries(e){return(this.index[e]||new _n(Mt.comparator)).toArray()}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Sl{constructor(e){this.bn=e}next(){return this.bn+=2,this.bn}static Pn(){return new Sl(0)}static vn(){return new Sl(-1)}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class k4{constructor(){this.changes=new hl(e=>e.toString(),(e,n)=>e.isEqual(n)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,n){this.assertNotApplied(),this.changes.set(e,xn.newInvalidDocument(e).setReadTime(n))}getEntry(e,n){this.assertNotApplied();const r=this.changes.get(n);return r!==void 0?te.resolve(r):this.getFromCache(e,n)}getEntries(e,n){return this.getAllFromCache(e,n)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*//**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class U4{constructor(e,n){this.overlayedDocument=e,this.mutatedFields=n}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class F4{constructor(e,n,r,i){this.remoteDocumentCache=e,this.mutationQueue=n,this.documentOverlayCache=r,this.indexManager=i}getDocument(e,n){let r=null;return this.documentOverlayCache.getOverlay(e,n).next(i=>(r=i,this.getBaseDocument(e,n,r))).next(i=>(r!==null&&bu(r.mutation,i,wi.empty(),un.now()),i))}getDocuments(e,n){return this.remoteDocumentCache.getEntries(e,n).next(r=>this.getLocalViewOfDocuments(e,r,Ve()).next(()=>r))}getLocalViewOfDocuments(e,n,r=Ve()){const i=Ka();return this.populateOverlays(e,i,n).next(()=>this.computeViews(e,n,i,r).next(s=>{let a=Nu();return s.forEach((o,l)=>{a=a.insert(o,l.overlayedDocument)}),a}))}getOverlayedDocuments(e,n){const r=Ka();return this.populateOverlays(e,r,n).next(()=>this.computeViews(e,n,r,Ve()))}populateOverlays(e,n,r){const i=[];return r.forEach(s=>{n.has(s)||i.push(s)}),this.documentOverlayCache.getOverlays(e,i).next(s=>{s.forEach((a,o)=>{n.set(a,o)})})}computeViews(e,n,r,i){let s=us();const a=Iu(),o=Iu();return n.forEach((l,c)=>{const u=r.get(c.key);i.has(c.key)&&(u===void 0||u.mutation instanceof Qa)?s=s.insert(c.key,c):u!==void 0&&(a.set(c.key,u.mutation.getFieldMask()),bu(u.mutation,c,u.mutation.getFieldMask(),un.now()))}),this.recalculateAndSaveOverlays(e,s).next(l=>(l.forEach((c,u)=>a.set(c,u)),n.forEach((c,u)=>{var d;return o.set(c,new U4(u,(d=a.get(c))!==null&&d!==void 0?d:null))}),o))}recalculateAndSaveOverlays(e,n){const r=Iu();let i=new dn((a,o)=>a-o),s=Ve();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,n).next(a=>{for(const o of a)o.keys().forEach(l=>{const c=n.get(l);if(c===null)return;let u=r.get(l)||wi.empty();u=o.applyToLocalView(c,u),r.set(l,u);const d=(i.get(o.batchId)||Ve()).add(l);i=i.insert(o.batchId,d)})}).next(()=>{const a=[],o=i.getReverseIterator();for(;o.hasNext();){const l=o.getNext(),c=l.key,u=l.value,d=qD();u.forEach(_=>{if(!s.has(_)){const p=BD(n.get(_),r.get(_));p!==null&&d.set(_,p),s=s.add(_)}}),a.push(this.documentOverlayCache.saveOverlays(e,c,d))}return te.waitFor(a)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,n){return this.remoteDocumentCache.getEntries(e,n).next(r=>this.recalculateAndSaveOverlays(e,r))}getDocumentsMatchingQuery(e,n,r){return function(i){return Ne.isDocumentKey(i.path)&&i.collectionGroup===null&&i.filters.length===0}(n)?this.getDocumentsMatchingDocumentQuery(e,n.path):QV(n)?this.getDocumentsMatchingCollectionGroupQuery(e,n,r):this.getDocumentsMatchingCollectionQuery(e,n,r)}getNextDocuments(e,n,r,i){return this.remoteDocumentCache.getAllFromCollectionGroup(e,n,r,i).next(s=>{const a=i-s.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,n,r.largestBatchId,i-s.size):te.resolve(Ka());let o=-1,l=s;return a.next(c=>te.forEach(c,(u,d)=>(o<d.largestBatchId&&(o=d.largestBatchId),s.get(u)?te.resolve():this.getBaseDocument(e,u,d).next(_=>{l=l.insert(u,_)}))).next(()=>this.populateOverlays(e,c,s)).next(()=>this.computeViews(e,l,c,Ve())).next(u=>({batchId:o,changes:HD(u)})))})}getDocumentsMatchingDocumentQuery(e,n){return this.getDocument(e,new Ne(n)).next(r=>{let i=Nu();return r.isFoundDocument()&&(i=i.insert(r.key,r)),i})}getDocumentsMatchingCollectionGroupQuery(e,n,r){const i=n.collectionGroup;let s=Nu();return this.indexManager.getCollectionParents(e,i).next(a=>te.forEach(a,o=>{const l=function(c,u){return new Tp(u,null,c.explicitOrderBy.slice(),c.filters.slice(),c.limit,c.limitType,c.startAt,c.endAt)}(n,o.child(i));return this.getDocumentsMatchingCollectionQuery(e,l,r).next(c=>{c.forEach((u,d)=>{s=s.insert(u,d)})})}).next(()=>s))}getDocumentsMatchingCollectionQuery(e,n,r){let i;return this.remoteDocumentCache.getAllFromCollection(e,n.path,r).next(s=>(i=s,this.documentOverlayCache.getOverlaysForCollection(e,n.path,r.largestBatchId))).next(s=>{s.forEach((o,l)=>{const c=l.getKey();i.get(c)===null&&(i=i.insert(c,xn.newInvalidDocument(c)))});let a=Nu();return i.forEach((o,l)=>{const c=s.get(o);c!==void 0&&bu(c.mutation,l,wi.empty(),un.now()),JE(n,l)&&(a=a.insert(o,l))}),a})}getBaseDocument(e,n,r){return r===null||r.mutation.type===1?this.remoteDocumentCache.getEntry(e,n):te.
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class B4{constructor(e){this.It=e,this.Zn=new Map,this.ts=new Map}getBundleMetadata(e,n){return te.resolve(this.Zn.get(n))}saveBundleMetadata(e,n){var r;return this.Zn.set(n.id,{id:(r=n).id,version:r.version,createTime:ds(r.createTime)}),te.resolve()}getNamedQuery(e,n){return te.resolve(this.ts.get(n))}saveNamedQuery(e,n){return this.ts.set(n.name,function(r){return{name:r.name,query:L4(r.bundledQuery),readTime:ds(r.readTime)}}(n)),te.resolve()}}/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class G4{constructor(){this.overlays=new dn(Ne.comparator),this.es=new Map}getOverlay(e,n){return te.resolve(this.overlays.get(n))}getOverlays(e,n){const r=Ka();return te.forEach(n,i=>this.getOverlay(e,i).next(s=>{s!==null&&r.set(i,s)})).next(()=>r)}saveOverlays(e,n,r){return r.forEach((i,s)=>{this.ue(e,n,s)}),te.resolve()}removeOverlaysForBatchId(e,n,r){const i=this.es.get(r);return i!==void 0&&(i.forEach(s=>this.overlays=this.overlays.remove(s)),this.es.delete(r)),te.resolve()}getOverlaysForCollection(e,n,r){const i=Ka(),s=n.length+1,a=new Ne(n.child("")),o=this.overlays.getIteratorFrom(a);for(;o.hasNext();){const l=o.getNext().value,c=l.getKey();if(!n.isPrefixOf(c.path))break;c.path.length===s&&l.largestBatchId>r&&i.set(l.getKey(),l)}return te.resolve(i)}getOverlaysForCollectionGroup(e,n,r,i){let s=new dn((c,u)=>c-u);const a=this.overlays.getIterator();for(;a.hasNext();){const c=a.getNext().value;if(c.getKey().getCollectionGroup()===n&&c.largestBatchId>r){let u=s.get(c.largestBatchId);u===null&&(u=Ka(),s=s.insert(c.largestBatchId,u)),u.set(c.getKey(),c)}}const o=Ka(),l=s.getIterator();for(;l.hasNext()&&(l.getNext().value.forEach((c,u)=>o.set(c,u)),!(o.size()>=i)););return te.resolve(o)}ue(e,n,r){const i=this.overlays.get(r.key);if(i!==null){const a=this.es.get(i.largestBatchId).delete(r.key);this.es.set(i.largestBatchId,a)}this.overlays=this.overlays.insert(r.key,new D4(n,r));let s=this.es.get(n);s===void 0&&(s=Ve(),this.es.set(n,s)),this.es.set(n,s.add(r.key))}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class oS{constructor(){this.ns=new _n(Sn.ss),this.rs=new _n(Sn.os)}isEmpty(){return this.ns.isEmpty()}addReference(e,n){const r=new Sn(e,n);this.ns=this.ns.add(r),this.rs=this.rs.add(r)}us(e,n){e.forEach(r=>this.addReference(r,n))}removeReference(e,n){this.cs(new Sn(e,n))}hs(e,n){e.forEach(r=>this.removeReference(r,n))}ls(e){const n=new Ne(new Mt([])),r=new Sn(n,e),i=new Sn(n,e+1),s=[];return this.rs.forEachInRange([r,i],a=>{this.cs(a),s.push(a.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 n=new Ne(new Mt([])),r=new Sn(n,e),i=new Sn(n,e+1);let s=Ve();return this.rs.forEachInRange([r,i],a=>{s=s.add(a.key)}),s}containsKey(e){const n=new Sn(e,0),r=this.ns.firstAfterOrEqual(n);return r!==null&&e.isEqual(r.key)}}class Sn{constructor(e,n){this.key=e,this._s=n}static ss(e,n){return Ne.comparator(e.key,n.key)||ot(e._s,n._s)}static os(e,n){return ot(e._s,n._s)||Ne.comparator(e.key,n.key)}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class $4{constructor(e,n){this.indexManager=e,this.referenceDelegate=n,this.mutationQueue=[],this.ws=1,this.gs=new _n(Sn.ss)}checkEmpty(e){return te.resolve(this.mutationQueue.length===0)}addMutationBatch(e,n,r,i){const s=this.ws;this.ws++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new w4(s,n,r,i);this.mutationQueue.push(a);for(const o of i)this.gs=this.gs.add(new Sn(o.key,s)),this.indexManager.addToCollectionParentIndex(e,o.key.path.popLast());return te.resolve(a)}lookupMutationBatch(e,n){return te.resolve(this.ys(n))}getNextMutationBatchAfterBatchId(e,n){const r=n+1,i=this.ps(r),s=i<0?0:i;return te.resolve(this.mutationQueue.length>s?this.mutationQueue[s]:null)}getHighestUnacknowledgedBatchId(){return te.resolve(this.mutationQueue.length===0?-1:this.ws-1)}getAllMutationBatches(e){return te.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,n){const r=new Sn(n,0),i=new Sn(n,Number.POSITIVE_INFINITY),s=[];return this.gs.forEachInRange([r,i],a=>{const o=this.ys(a._s);s.push(o)}),te.resolve(s)}getAllMutationBatchesAffectingDocumentKeys(e,n){let r=new _n(ot);return n.forEach(i=>{const s=new Sn(i,0),a=new Sn(i,Number.POSITIVE_INFINITY);this.gs.forEachInRange([s,a],o=>{r=r.add(o._s)})}),te.resolve(this.Is(r))}getAllMutationBatchesAffectingQuery(e,n){const r=n.path,i=r.length+1;let s=r;Ne.isDocumentKey(s)||(s=s.child(""));const a=new Sn(new Ne(s),0);let o=new _n(ot);return this.gs.forEachWhile(l=>{const c=l.key.path;return!!r.isPrefixOf(c)&&(c.length===i&&(o=o.add(l._s)),!0)},a),te.resolve(this.Is(o))}Is(e){const n=[];return e.forEach(r=>{const i=this.ys(r);i!==null&&n.push(i)}),n}removeMutationBatch(e,n){yt(this.Ts(n.batchId,"removed")===0),this.mutationQueue.shift();let r=this.gs;return te.forEach(n.mutations,i=>{const s=new Sn(i.key,n.batchId);return r=r.delete(s),this.referenceDelegate.markPotentiallyOrphaned(e,i.key)}).next(()=>{this.gs=r})}An(e){}containsKey(e,n){const r=new Sn(n,0),i=this.gs.firstAfterOrEqual(r);return te.resolve(n.isEqual(i&&i.key))}performConsistencyCheck(e){return this.mutationQueue.length,te.resolve()}Ts(e,n){return this.ps(e)}ps(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}ys(e){const n=this.ps(e);return n<0||n>=this.mutationQueue.length?null:this.mutationQueue[n]}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Y4{constructor(e){this.Es=e,this.docs=new dn(Ne.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,n){const r=n.key,i=this.docs.get(r),s=i?i.size:0,a=this.Es(n);return this.docs=this.docs.insert(r,{document:n.mutableCopy(),size:a}),this.size+=a-s,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){const n=this.docs.get(e);n&&(this.docs=this.docs.remove(e),this.size-=n.size)}getEntry(e,n){const r=this.docs.get(n);return te.resolve(r?r.document.mutableCopy():xn.newInvalidDocument(n))}getEntries(e,n){let r=us();return n.forEach(i=>{const s=this.docs.get(i);r=r.insert(i,s?s.document.mutableCopy():xn.newInvalidDocument(i))}),te.resolve(r)}getAllFromCollection(e,n,r){let i=us();const s=new Ne(n.child("")),a=this.docs.getIteratorFrom(s);for(;a.hasNext();){const{key:o,value:{document:l}}=a.getNext();if(!n.isPrefixOf(o.path))break;o.path.length>n.length+1||AV(OV(l),r)<=0||(i=i.insert(l.key,l.mutableCopy()))}return te.resolve(i)}getAllFromCollectionGroup(e,n,r,i){Pe()}As(e,n){return te.forEach(this.docs,r=>n(r))}newChangeBuffer(e){return new z4(this)}getSize(e){return te.resolve(this.size)}}class z4 extends k4{constructor(e){super(),this.Yn=e}applyChanges(e){const n=[];return this.changes.forEach((r,i)=>{i.isValidDocument()?n.push(this.Yn.addEntry(e,i)):this.Yn.removeEntry(r)}),te.waitFor(n)}getFromCache(e,n){return this.Yn.getEntry(e,n)}getAllFromCache(e,n){return this.Yn.getEntries(e,n)}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class V4{constructor(e){this.persistence=e,this.Rs=new hl(n=>qE(n),WE),this.lastRemoteSnapshotVersion=Ge.min(),this.highestTargetId=0,this.bs=0,this.Ps=new oS,this.targetCount=0,this.vs=Sl.Pn()}forEachTarget(e,n){return this.Rs.forEach((r,i)=>n(i)),te.resolve()}getLastRemoteSnapshotVersion(e){return te.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return te.resolve(this.bs)}allocateTargetId(e){return this.highestTargetId=this.vs.next(),te.resolve(this.highestTargetId)}setTargetsMetadata(e,n,r){return r&&(this.lastRemoteSnapshotVersion=r),n>this.bs&&(this.bs=n),te.resolve()}Dn(e){this.Rs.set(e.target,e);const n=e.targetId;n>this.highestTargetId&&(this.vs=new Sl(n),this.highestTargetId=n),e.sequenceNumber>this.bs&&(this.bs=e.sequenceNumber)}addTargetData(e,n){return this.Dn(n),this.targetCount+=1,te.resolve()}updateTargetData(e,n){return this.Dn(n),te.resolve()}removeTargetData(e,n){return this.Rs.delete(n.target),this.Ps.ls(n.targetId),this.targetCount-=1,te.resolve()}removeTargets(e,n,r){let i=0;const s=[];return this.Rs.forEach((a,o)=>{o.sequenceNumber<=n&&r.get(o.targetId)===null&&(this.Rs.delete(a),s.push(this.removeMatchingKeysForTargetId(e,o.targetId)),i++)}),te.waitFor(s).next(()=>i)}getTargetCount(e){return te.resolve(this.targetCount)}getTargetData(e,n){const r=this.Rs.get(n)||null;return te.resolve(r)}addMatchingKeys(e,n,r){return this.Ps.us(n,r),te.resolve()}removeMatchingKeys(e,n,r){this.Ps.hs(n,r);const i=this.persistence.referenceDelegate,s=[];return i&&n.forEach(a=>{s.push(i.markPotentiallyOrphaned(e,a))}),te.waitFor(s)}removeMatchingKeysForTargetId(e,n){return this.Ps.ls(n),te.resolve()}getMatchingKeysForTargetId(e,n){const r=this.Ps.ds(n);return te.resolve(r)}containsKey(e,n){return te.resolve(this.Ps.containsKey(n))}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class j4{constructor(e,n){this.Vs={},this.overlays={},this.Ss=new zE(0),this.Ds=!1,this.Ds=!0,this.referenceDelegate=e(this),this.Cs=new V4(this),this.indexManager=new x4,this.remoteDocumentCache=function(r){return new Y4(r)}(r=>this.referenceDelegate.xs(r)),this.It=new M4(n),this.Ns=new B4(this.It)}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 n=this.overlays[e.toKey()];return n||(n=new G4,this.overlays[e.toKey()]=n),n}getMutationQueue(e,n){let r=this.Vs[e.toKey()];return r||(r=new $4(n,this.referenceDelegate),this.Vs[e.toKey()]=r),r}getTargetCache(){return this.Cs}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ns}runTransaction(e,n,r){ye("MemoryPersistence","Starting transaction:",e);const i=new H4(this.Ss.next());return this.referenceDelegate.ks(),r(i).next(s=>this.referenceDelegate.Ms(i).next(()=>s)).toPromise().then(s=>(i.raiseOnCommittedEvent(),s))}Os(e,n){return te.or(Object.values(this.Vs).map(r=>()=>r.containsKey(e,n)))}}class H4 extends DV{constructor(e){super(),this.currentSequenceNumber=e}}class lS{constructor(e){this.persistence=e,this.Fs=new oS,this.$s=null}static Bs(e){return new lS(e)}get Ls(){if(this.$s)return this.$s;throw Pe()}addReference(e,n,r){return this.Fs.addReference(r,n),this.Ls.delete(r.toString()),te.resolve()}removeReference(e,n,r){return this.Fs.removeReference(r,n),this.Ls.add(r.toString()),te.resolve()}markPotentiallyOrphaned(e,n){return this.Ls.add(n.toString()),te.resolve()}removeTarget(e,n){this.Fs.ls(n.targetId).forEach(i=>this.Ls.add(i.toString()));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,n.targetId).next(i=>{i.forEach(s=>this.Ls.add(s.toString()))}).next(()=>r.removeTargetData(e,n))}ks(){this.$s=new Set}Ms(e){const n=this.persistence.getRemoteDocumentCache().newChangeBuffer();return te.forEach(this.Ls,r=>{const i=Ne.fromPath(r);return this.Us(e,i).next(s=>{s||n.removeEntry(i,Ge.min())})}).next(()=>(this.$s=null,n.apply(e)))}updateLimboDocument(e,n){return this.Us(e,n).next(r=>{r?this.Ls.delete(n.toString()):this.Ls.add(n.toString())})}xs(e){return 0}Us(e,n){return te.or([()=>te.resolve(this.Fs.containsKey(n)),()=>this.persistence.getTargetCache().containsKey(e,n),()=>this.persistence.Os(e,n)])}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class cS{constructor(e,n,r,i){this.targetId=e,this.fromCache=n,this.Si=r,this.Di=i}static Ci(e,n){let r=Ve(),i=Ve();for(const s of n.docChanges)switch(s.type){case 0:r=r.add(s.doc.key);break;case 1:i=i.add(s.doc.key)}return new cS(e,n.fromCache,r,i)}}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class q4{constructor(){this.xi=!1}initialize(e,n){this.Ni=e,this.indexManager=n,this.xi=!0}getDocumentsMatchingQuery(e,n,r,i){return this.ki(e,n).next(s=>s||this.Mi(e,n,i,r)).next(s=>s||this.Oi(e,n))}ki(e,n){if(AD(n))return te.resolve(null);let r=cs(n);return this.indexManager.getIndexType(e,r).next(i=>i===0?null:(n.limit!==null&&i===1&&(n=XE(n,null,"F"),r=cs(n)),this.indexManager.getDocumentsMatchingTarget(e,r).next(s=>{const a=Ve(...s);return this.Ni.getDocuments(e,a).next(o=>this.indexManager.getMinOffset(e,r).next(l=>{const c=this.Fi(n,o);return this.$i(n,c,a,l.readTime)?this.ki(e,XE(n,null,"F")):this.Bi(e,c,n,l)}))})))}Mi(e,n,r,i){return AD(n)||i.isEqual(Ge.min())?this.Oi(e,n):this.Ni.getDocuments(e,r).next(s=>{const a=this.Fi(n,s);return this.$i(n,a,r,i)?this.Oi(e,n):(pD()<=nt.DEBUG&&ye("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),ZE(n)),this.Bi(e,a,n,RV(i,-1)))})}Fi(e,n){let r=new _n(DD(e));return n.forEach((i,s)=>{JE(e,s)&&(r=r.add(s))}),r}$i(e,n,r,i){if(e.limit===null)return!1;if(r.size!==n.size)return!0;const s=e.limitType==="F"?n.last():n.first();return!!s&&(s.hasPendingWrites||s.version.compareTo(i)>0)}Oi(e,n){return pD()<=nt.DEBUG&&ye("QueryEngine","Using full collection scan to execute query:",ZE(n)),this.Ni.getDocumentsMatchingQuery(e,n,aa.min())}Bi(e,n,r,i){return this.Ni.getDocumentsMatchingQuery(e,r,i).next(s=>(n.forEach(a=>{s=s.insert(a.key,a)}),s))}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class W4{constructor(e,n,r,i){this.persistence=e,this.Li=n,this.It=i,this.Ui=new dn(ot),this.qi=new hl(s=>qE(s),WE),this.Ki=new Map,this.Gi=e.getRemoteDocumentCache(),this.Cs=e.getTargetCache(),this.Ns=e.getBundleCache(),this.Qi(r)}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 F4(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",n=>e.collect(n,this.Ui))}}function Q4(t,e,n,r){return new W4(t,e,n,r)}async function aM(t,e){const n=ke(t);return await n.persistence.runTransaction("Handle user change","readonly",r=>{let i;return n.mutationQueue.getAllMutationBatches(r).next(s=>(i=s,n.Qi(e),n.mutationQueue.getAllMutationBatches(r))).next(s=>{const a=[],o=[];let l=Ve();for(const c of i){a.push(c.batchId);for(const u of c.mutations)l=l.add(u.key)}for(const c of s){o.push(c.batchId);for(const u of c.mutations)l=l.add(u.key)}return n.localDocuments.getDocuments(r,l).next(c=>({ji:c,removedBatchIds:a,addedBatchIds:o}))})})}function K4(t,e){const n=ke(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",r=>{const i=e.batch.keys(),s=n.Gi.newChangeBuffer({trackRemovals:!0});return function(a,o,l,c){const u=l.batch,d=u.keys();let _=te.resolve();return d.forEach(p=>{_=_.next(()=>c.getEntry(o,p)).next(f=>{const E=l.docVersions.get(p);yt(E!==null),f.version.compareTo(E)<0&&(u.applyToRemoteDocument(f,l),f.isValidDocument()&&(f.setReadTime(l.commitVersion),c.addEntry(f)))})}),_.next(()=>a.mutationQueue.removeMutationBatch(o,u))}(n,r,e,s).next(()=>s.apply(r)).next(()=>n.mutationQueue.performConsistencyCheck(r)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(r,i,e.batch.batchId)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,function(a){let o=Ve();for(let l=0;l<a.mutationResults.length;++l)a.mutationResults[l].transformResults.length>0&&(o=o.add(a.batch.mutations[l].key));return o}(e))).next(()=>n.localDocuments.getDocuments(r,i))})}function oM(t){const e=ke(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",n=>e.Cs.getLastRemoteSnapshotVersion(n))}function X4(t,e){const n=ke(t),r=e.snapshotVersion;let i=n.Ui;return n.persistence.runTransaction("Apply remote event","readwrite-primary",s=>{const a=n.Gi.newChangeBuffer({trackRemovals:!0});i=n.Ui;const o=[];e.targetChanges.forEach((u,d)=>{const _=i.get(d);if(!_)return;o.push(n.Cs.removeMatchingKeys(s,u.removedDocuments,d).next(()=>n.Cs.addMatchingKeys(s,u.addedDocuments,d)));let p=_.withSequenceNumber(s.currentSequenceNumber);e.targetMismatches.has(d)?p=p.withResumeToken(Ln.EMPTY_BYTE_STRING,Ge.min()).withLastLimboFreeSnapshotVersion(Ge.min()):u.resumeToken.approximateByteSize()>0&&(p=p.withResumeToken(u.resumeToken,r)),i=i.insert(d,p),function(f,E,h){return f.resumeToken.approximateByteSize()===0||E.snapshotVersion.toMicroseconds()-f.snapshotVersion.toMicroseconds()>=3e8?!0:h.addedDocuments.size+h.modifiedDocuments.size+h.removedDocuments.size>0}(_,p,u)&&o.push(n.Cs.updateTargetData(s,p))});let l=us(),c=Ve();if(e.documentUpdates.forEach(u=>{e.resolvedLimboDocuments.has(u)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(s,u))}),o.push(Z4(s,a,e.documentUpdates).next(u=>{l=u.Wi,c=u.zi})),!r.isEqual(Ge.min())){const u=n.Cs.getLastRemoteSnapshotVersion(s).next(d=>n.Cs.setTargetsMetadata(s,s.currentSequenceNumber,r));o.push(u)}return te.waitFor(o).next(()=>a.apply(s)).next(()=>n.localDocuments.getLocalViewOfDocuments(s,l,c)).next(()=>l)}).then(s=>(n.Ui=i,s))}function Z4(t,e,n){let r=Ve(),i=Ve();return n.forEach(s=>r=r.add(s)),e.getEntries(t,r).next(s=>{let a=us();return n.forEach((o,l)=>{const c=s.get(o);l.isFoundDocument()!==c.isFoundDocument()&&(i=i.add(o)),l.isNoDocument()&&l.version.isEqual(Ge.min(
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class rj{qr(e){}shutdown(){}}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class uM{constructor(){this.Kr=()=>this.Gr(),this.Qr=()=>this.jr(),this.Wr=[],this.zr()}qr(e){this.Wr.push(e)}shutdown(){window.removeEventListener("online",this.Kr),window.removeEventListener("offline",this.Qr)}zr(){window.addEventListener("online",this.Kr),window.addEventListener("offline",this.Qr)}Gr(){ye("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.Wr)e(0)}jr(){ye("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const e of this.Wr)e(1)}static C(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const ij={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"};/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class sj{constructor(e){this.Hr=e.Hr,this.Jr=e.Jr}Yr(e){this.Xr=e}Zr(e){this.eo=e}onMessage(e){this.no=e}close(){this.Jr()}send(e){this.Hr(e)}so(){this.Xr()}io(e){this.eo(e)}ro(e){this.no(e)}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class aj extends class{constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const n=e.ssl?"https":"http";this.oo=n+"://"+e.host,this.uo="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}co(e,n,r,i,s){const a=this.ao(e,n);ye("RestConnection","Sending: ",a,r);const o={};return this.ho(o,i,s),this.lo(e,a,o,r).then(l=>(ye("RestConnection","Received: ",l),l),l=>{throw $E("RestConnection",`${e} failed with error: `,l,"url: ",a,"request:",r),l})}fo(e,n,r,i,s,a){return this.co(e,n,r,i,s)}ho(e,n,r){e["X-Goog-Api-Client"]="gl-js/ fire/"+ul,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),n&&n.headers.forEach((i,s)=>e[s]=i),r&&r.headers.forEach((i,s)=>e[s]=i)}ao(e,n){const r=ij[e];return`${this.oo}/v1/${n}:${r}`}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams}lo(e,n,r,i){return new Promise((s,a)=>{const o=new gV;o.listenOnce(mV.COMPLETE,()=>{try{switch(o.getLastErrorCode()){case GE.NO_ERROR:const c=o.getResponseJson();ye("Connection","XHR received:",JSON.stringify(c)),s(c);break;case GE.TIMEOUT:ye("Connection",'RPC "'+e+'" timed out'),a(new Oe(ie.DEADLINE_EXCEEDED,"Request time out"));break;case GE.HTTP_ERROR:const u=o.getStatus();if(ye("Connection",'RPC "'+e+'" failed with status:',u,"response text:",o.getResponseText()),u>0){const d=o.getResponseJson().error;if(d&&d.status&&d.message){const _=function(p){const f=p.toLowerCase().replace(/_/g,"-");return Object.values(ie).indexOf(f)>=0?f:ie.UNKNOWN}(d.status);a(new Oe(_,d.message))}else a(new Oe(ie.UNKNOWN,"Server responded with status "+o.getStatus()))}else a(new Oe(ie.UNAVAILABLE,"Connection failed."));break;default:Pe()}}finally{ye("Connection",'RPC "'+e+'" completed.')}});const l=JSON.stringify(i);o.send(n,"POST",l,r,15)})}_o(e,n,r){const i=[this.oo,"/","google.firestore.v1.Firestore","/",e,"/channel"],s=_V(),a=pV(),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 hV({})),this.ho(o.initMessageHeaders,n,r),zO()||jO()||r$()||HO()||i$()||VO()||(o.httpHeadersOverwriteParam="$httpHeaders");const l=i.join("");ye("Connection","Creating WebChannel: "+l,o);const c=s.createWebChannel(l,o);let u=!1,d=!1;const _=new sj({Hr:f=>{d?ye("Connection","Not sending because WebChannel is closed:",f):(u||(ye("Connection","Opening WebChannel transport."),c.open(),u=!0),ye("Connection","WebChannel sending:",f),c.send(f))},Jr:()=>c.close()}),p=(f,E,h)=>{f.listen(E,m=>{try{h(m)}catch(g){setTimeout(()=>{throw g},0)}})};return p(c,pp.EventType.OPEN,()=>{d||ye("Connection","WebChannel transport opened.")}),p(c,pp.EventType.CLOSE,()=>{d||(d=!0,ye("Connection","WebChannel transport closed"),_.io())}),p(c,pp.EventType.ERROR,f=>{d||(d=!0,$E("Connection","WebChannel transport errored:",f),_.io(new Oe(ie.UNAVAILABLE,"The operation could not be completed")))}),p(c,pp.EventType.MESSAGE,f=>{var E;if(!d){const h=f.data[0];yt(!!h);const m=h,g=m.error||((E=m[0])===null||E===void 0?void 0:E.error);if(g){ye("Connection","WebChannel received error:",g);const T=g.status;let v=function(C){const b=sn[C];if(b!==void 0)return VD(b)}(T),R=g.message;v===void 0&&(v=ie.INTERNAL,R="Unknown error status: "+T+" with message "+g.message),d=!0,_.io(new Oe(v,R)),c.close()}else ye("Connection","WebChannel received:",h),_.ro(h)}}),p(a,fV.STAT_EVENT,f=>{f.stat===dD.PROXY?ye("Connection","Detected buffering proxy"):f.stat===dD.NOPROXY&&ye("Connection","Detected no buffering proxy")}),setTimeout(()=>{_.so()},0),_}}function dS(){return typeof document<"u"?document:null}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function wp(t){return new f4(t,!0)}class dM{constructor(e,n,r=1e3,i=1.5,s=6e4){this.Hs=e,this.timerId=n,this.wo=r,this.mo=i,this.yo=s,this.po=0,this.Io=null,this.To=Date.now(),this.reset()}reset(){this.po=0}Eo(){this.po=this.yo}Ao(e){this.cancel();const n=Math.floor(this.po+this.Ro()),r=Math.max(0,Date.now()-this.To),i=Math.max(0,n-r);i>0&&ye("ExponentialBackoff",`Backing off for ${i} ms (base delay: ${this.po} ms, delay with jitter: ${n} ms, last attempt: ${r} ms ago)`),this.Io=this.Hs.enqueueAfterDelay(this.timerId,i,()=>(this.To=Date.now(),e())),this.po*=this.mo,this.po<this.wo&&(this.po=this.wo),this.po>this.yo&&(this.po=this.yo)}bo(){this.Io!==null&&(this.Io.skipDelay(),this.Io=null)}cancel(){this.Io!==null&&(this.Io.cancel(),this.Io=null)}Ro(){return(Math.random()-.5)*this.po}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class _M{constructor(e,n,r,i,s,a,o,l){this.Hs=e,this.Po=r,this.vo=i,this.Vo=s,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=o,this.listener=l,this.state=0,this.So=0,this.Do=null,this.Co=null,this.stream=null,this.xo=new dM(e,n)}No(){return this.state===1||this.state===5||this.ko()}ko(){return this.state===2||this.state===3}start(){this.state!==4?this.auth():this.Mo()}async stop(){this.No()&&await this.close(0)}Oo(){this.state=0,this.xo.reset()}Fo(){this.ko()&&this.Do===null&&(this.Do=this.Hs.enqueueAfterDelay(this.Po,6e4,()=>this.$o()))}Bo(e){this.Lo(),this.stream.send(e)}async $o(){if(this.ko())return this.close(0)}Lo(){this.Do&&(this.Do.cancel(),this.Do=null)}Uo(){this.Co&&(this.Co.cancel(),this.Co=null)}async close(e,n){this.Lo(),this.Uo(),this.xo.cancel(),this.So++,e!==4?this.xo.reset():n&&n.code===ie.RESOURCE_EXHAUSTED?(ls(n.toString()),ls("Using maximum backoff delay to prevent overloading the backend."),this.xo.Eo()):n&&n.code===ie.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.qo(),this.stream.close(),this.stream=null),this.state=e,await this.listener.Zr(n)}qo(){}auth(){this.state=1;const e=this.Ko(this.So),n=this.So;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([r,i])=>{this.So===n&&this.Go(r,i)},r=>{e(()=>{const i=new Oe(ie.UNKNOWN,"Fetching auth token failed: "+r.message);return this.Qo(i)})})}Go(e,n){const r=this.Ko(this.So);this.stream=this.jo(e,n),this.stream.Yr(()=>{r(()=>(this.state=2,this.Co=this.Hs.enqueueAfterDelay(this.vo,1e4,()=>(this.ko()&&(this.state=3),Promise.resolve())),this.listener.Yr()))}),this.stream.Zr(i=>{r(()=>this.Qo(i))}),this.stream.onMessage(i=>{r(()=>this.onMessage(i))})}Mo(){this.state=5,this.xo.Ao(async()=>{this.state=0,this.start()})}Qo(e){return ye("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}Ko(e){return n=>{this.Hs.enqueueAndForget(()=>this.So===e?n():(ye("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class oj extends _M{constructor(e,n,r,i,s,a){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",n,r,i,a),this.It=s}jo(e,n){return this.Vo._o("Listen",e,n)}onMessage(e){this.xo.reset();const n=E4(this.It,e),r=function(i){if(!("targetChange"in i))return Ge.min();const s=i.targetChange;return s.targetIds&&s.targetIds.length?Ge.min():s.readTime?ds(s.readTime):Ge.min()}(e);return this.listener.Wo(n,r)}zo(e){const n={};n.database=sS(this.It),n.addTarget=function(i,s){let a;const o=s.target;return a=QE(o)?{documents:v4(i,o)}:{query:y4(i,o)},a.targetId=s.targetId,s.resumeToken.approximateByteSize()>0?a.resumeToken=eM(i,s.resumeToken):s.snapshotVersion.compareTo(Ge.min())>0&&(a.readTime=Ap(i,s.snapshotVersion.toTimestamp())),a}(this.It,e);const r=C4(this.It,e);r&&(n.labels=r),this.Bo(n)}Ho(e){const n={};n.database=sS(this.It),n.removeTarget=e,this.Bo(n)}}class lj extends _M{constructor(e,n,r,i,s,a){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",n,r,i,a),this.It=s,this.Jo=!1}get Yo(){return this.Jo}start(){this.Jo=!1,this.lastStreamToken=void 0,super.start()}qo(){this.Jo&&this.Xo([])}jo(e,n){return this.Vo._o("Write",e,n)}onMessage(e){if(yt(!!e.streamToken),this.lastStreamToken=e.streamToken,this.Jo){this.xo.reset();const n=T4(e.writeResults,e.commitTime),r=ds(e.commitTime);return this.listener.Zo(r,n)}return yt(!e.writeResults||e.writeResults.length===0),this.Jo=!0,this.listener.tu()}eu(){const e={};e.database=sS(this.It),this.Bo(e)}Xo(e){const n={streamToken:this.lastStreamToken,writes:e.map(r=>S4(this.It,r))};this.Bo(n)}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class cj extends class{}{constructor(e,n,r,i){super(),this.authCredentials=e,this.appCheckCredentials=n,this.Vo=r,this.It=i,this.nu=!1}su(){if(this.nu)throw new Oe(ie.FAILED_PRECONDITION,"The client has already been terminated.")}co(e,n,r){return this.su(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,s])=>this.Vo.co(e,n,r,i,s)).catch(i=>{throw i.name==="FirebaseError"?(i.code===ie.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),i):new Oe(ie.UNKNOWN,i.toString())})}fo(e,n,r,i){return this.su(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,a])=>this.Vo.fo(e,n,r,s,a,i)).catch(s=>{throw s.name==="FirebaseError"?(s.code===ie.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),s):new Oe(ie.UNKNOWN,s.toString())})}terminate(){this.nu=!0}}class uj{constructor(e,n){this.asyncQueue=e,this.onlineStateHandler=n,this.state="Unknown",this.iu=0,this.ru=null,this.ou=!0}uu(){this.iu===0&&(this.cu("Unknown"),this.ru=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.ru=null,this.au("Backend didn't respond within 10 seconds."),this.cu("Offline"),Promise.resolve())))}hu(e){this.state==="Online"?this.cu("Unknown"):(this.iu++,this.iu>=1&&(this.lu(),this.au(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.cu("Offline")))}set(e){this.lu(),this.iu=0,e==="Online"&&(this.ou=!1),this.cu(e)}cu(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}au(e){const n=`Could not reach Cloud Firestore backend. ${e}
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.ou?(ls(n),this.ou=!1):ye("OnlineStateTracker",n)}lu(){this.ru!==null&&(this.ru.cancel(),this.ru=null)}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class dj{constructor(e,n,r,i,s){this.localStore=e,this.datastore=n,this.asyncQueue=r,this.remoteSyncer={},this.fu=[],this.du=new Map,this._u=new Set,this.wu=[],this.mu=s,this.mu.qr(a=>{r.enqueueAndForget(async()=>{Za(this)&&(ye("RemoteStore","Restarting streams for network reachability change."),await async function(o){const l=ke(o);l._u.add(4),await Ou(l),l.gu.set("Unknown"),l._u.delete(4),await Dp(l)}(this))})}),this.gu=new uj(r,i)}}async function Dp(t){if(Za(t))for(const e of t.wu)await e(!0)}async function Ou(t){for(const e of t.wu)await e(!1)}function pM(t,e){const n=ke(t);n.du.has(e.targetId)||(n.du.set(e.targetId,e),mS(n)?pS(n):Tl(n).ko()&&_S(n,e))}function mM(t,e){const n=ke(t),r=Tl(n);n.du.delete(e),r.ko()&&fM(n,e),n.du.size===0&&(r.ko()?r.Fo():Za(n)&&n.gu.set("Unknown"))}function _S(t,e){t.yu.Ot(e.targetId),Tl(t).zo(e)}function fM(t,e){t.yu.Ot(e),Tl(t).Ho(e)}function pS(t){t.yu=new _4({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),se:e=>t.du.get(e)||null}),Tl(t).start(),t.gu.uu()}function mS(t){return Za(t)&&!Tl(t).No()&&t.du.size>0}function Za(t){return ke(t)._u.size===0}function hM(t){t.yu=void 0}async function _j(t){t.du.forEach((e,n)=>{_S(t,e)})}async function pj(t,e){hM(t),mS(t)?(t.gu.hu(e),pS(t)):t.gu.set("Unknown")}async function mj(t,e,n){if(t.gu.set("Online"),e instanceof KD&&e.state===2&&e.cause)try{await async function(r,i){const s=i.cause;for(const a of i.targetIds)r.du.has(a)&&(await r.remoteSyncer.rejectListen(a,s),r.du.delete(a),r.yu.removeTarget(a))}(t,e)}catch(r){ye("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),r),await Mp(t,r)}else if(e instanceof Op?t.yu.Gt(e):e instanceof QD?t.yu.Yt(e):t.yu.Wt(e),!n.isEqual(Ge.min()))try{const r=await oM(t.localStore);n.compareTo(r)>=0&&await function(i,s){const a=i.yu.te(s);return a.targetChanges.forEach((o,l)=>{if(o.resumeToken.approximateByteSize()>0){const c=i.du.get(l);c&&i.du.set(l,c.withResumeToken(o.resumeToken,s))}}),a.targetMismatches.forEach(o=>{const l=i.du.get(o);if(!l)return;i.du.set(o,l.withResumeToken(Ln.EMPTY_BYTE_STRING,l.snapshotVersion)),fM(i,o);const c=new Xa(l.target,o,1,l.sequenceNumber);_S(i,c)}),i.remoteSyncer.applyRemoteEvent(a)}(t,n)}catch(r){ye("RemoteStore","Failed to raise snapshot:",r),await Mp(t,r)}}async function Mp(t,e,n){if(!mu(e))throw e;t._u.add(1),await Ou(t),t.gu.set("Offline"),n||(n=()=>oM(t.localStore)),t.asyncQueue.enqueueRetryable(async()=>{ye("RemoteStore","Retrying IndexedDB access"),await n(),t._u.delete(1),await Dp(t)})}function gM(t,e){return e().catch(n=>Mp(t,n,e))}async function Lp(t){const e=ke(t),n=la(e);let r=e.fu.length>0?e.fu[e.fu.length-1].batchId:-1;for(;fj(e);)try{const i=await J4(e.localStore,r);if(i===null){e.fu.length===0&&n.Fo();break}r=i.batchId,hj(e,i)}catch(i){await Mp(e,i)}EM(e)&&SM(e)}function fj(t){return Za(t)&&t.fu.length<10}function hj(t,e){t.fu.push(e);const n=la(t);n.ko()&&n.Yo&&n.Xo(e.mutations)}function EM(t){return Za(t)&&!la(t).No()&&t.fu.length>0}function SM(t){la(t).start()}async function gj(t){la(t).eu()}async function Ej(t){const e=la(t);for(const n of t.fu)e.Xo(n.mutations)}async function Sj(t,e,n){const r=t.fu.shift(),i=aS.from(r,e,n);await gM(t,()=>t.remoteSyncer.applySuccessfulWrite(i)),await Lp(t)}async function Tj(t,e){e&&la(t).Yo&&await async function(n,r){if(i=r.code,o4(i)&&i!==ie.ABORTED){const s=n.fu.shift();la(n).Oo(),await gM(n,()=>n.remoteSyncer.rejectFailedWrite(s.batchId,r)),await Lp(n)}var i}(t,e),EM(t)&&SM(t)}async function TM(t,e){const n=ke(t);n.asyncQueue.verifyOperationInProgress(),ye("RemoteStore","RemoteStore received new credentials");const r=Za(n);n._u.add(3),await Ou(n),r&&n.gu.set("Unknown"),await n.remoteSyncer.handleCredentialChange(e),n._u.delete(3),await Dp(n)}async function vj(t,e){const n=ke(t);e?(n._u.delete(2),await Dp(n)):e||(n._u.add(2),await Ou(n),n.gu.set("Unknown"))}function Tl(t){return t.pu||(t.pu=function(e,n,r){const i=ke(e);return i.su(),new oj(n,i.Vo,i.authCredentials,i.appCheckCredentials,i.It,r)}(t.datastore,t.asyncQueue,{Yr:_j.bind(null,t),Zr:pj.bind(null,t),Wo:mj.bind(null,t)}),t.
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class fS{constructor(e,n,r,i,s){this.asyncQueue=e,this.timerId=n,this.targetTimeMs=r,this.op=i,this.removalCallback=s,this.deferred=new sa,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(a=>{})}static createAndSchedule(e,n,r,i,s){const a=Date.now()+r,o=new fS(e,n,a,i,s);return o.start(r),o}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new Oe(ie.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function hS(t,e){if(ls("AsyncQueue",`${e}: ${t}`),mu(t))return new Oe(ie.UNAVAILABLE,`${e}: ${t}`);throw t}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class vl{constructor(e){this.comparator=e?(n,r)=>e(n,r)||Ne.comparator(n.key,r.key):(n,r)=>Ne.comparator(n.key,r.key),this.keyedMap=Nu(),this.sortedSet=new dn(this.comparator)}static emptySet(e){return new vl(e.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const n=this.keyedMap.get(e);return n?this.sortedSet.indexOf(n):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((n,r)=>(e(n),!1))}add(e){const n=this.delete(e.key);return n.copy(n.keyedMap.insert(e.key,e),n.sortedSet.insert(e,null))}delete(e){const n=this.get(e);return n?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(n)):this}isEqual(e){if(!(e instanceof vl)||this.size!==e.size)return!1;const n=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;n.hasNext();){const i=n.getNext().key,s=r.getNext().key;if(!i.isEqual(s))return!1}return!0}toString(){const e=[];return this.forEach(n=>{e.push(n.toString())}),e.length===0?"DocumentSet ()":`DocumentSet (
`+e.join(`
`)+`
)`}copy(e,n){const r=new vl;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=n,r}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class vM{constructor(){this.Tu=new dn(Ne.comparator)}track(e){const n=e.doc.key,r=this.Tu.get(n);r?e.type!==0&&r.type===3?this.Tu=this.Tu.insert(n,e):e.type===3&&r.type!==1?this.Tu=this.Tu.insert(n,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.Tu=this.Tu.insert(n,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.Tu=this.Tu.insert(n,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.Tu=this.Tu.remove(n):e.type===1&&r.type===2?this.Tu=this.Tu.insert(n,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.Tu=this.Tu.insert(n,{type:2,doc:e.doc}):Pe():this.Tu=this.Tu.insert(n,e)}Eu(){const e=[];return this.Tu.inorderTraversal((n,r)=>{e.push(r)}),e}}class yl{constructor(e,n,r,i,s,a,o,l){this.query=e,this.docs=n,this.oldDocs=r,this.docChanges=i,this.mutatedKeys=s,this.fromCache=a,this.syncStateChanged=o,this.excludesMetadataChanges=l}static fromInitialDocuments(e,n,r,i){const s=[];return n.forEach(a=>{s.push({type:0,doc:a})}),new yl(e,n,vl.emptySet(n),s,r,i,!0,!1)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&vp(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const n=this.docChanges,r=e.docChanges;if(n.length!==r.length)return!1;for(let i=0;i<n.length;i++)if(n[i].type!==r[i].type||!n[i].doc.isEqual(r[i].doc))return!1;return!0}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class yj{constructor(){this.Au=void 0,this.listeners=[]}}class bj{constructor(){this.queries=new hl(e=>wD(e),vp),this.onlineState="Unknown",this.Ru=new Set}}async function Cj(t,e){const n=ke(t),r=e.query;let i=!1,s=n.queries.get(r);if(s||(i=!0,s=new yj),i)try{s.Au=await n.onListen(r)}catch(a){const o=hS(a,`Initialization of query '${ZE(e.query)}' failed`);return void e.onError(o)}n.queries.set(r,s),s.listeners.push(e),e.bu(n.onlineState),s.Au&&e.Pu(s.Au)&&gS(n)}async function Nj(t,e){const n=ke(t),r=e.query;let i=!1;const s=n.queries.get(r);if(s){const a=s.listeners.indexOf(e);a>=0&&(s.listeners.splice(a,1),i=s.listeners.length===0)}if(i)return n.queries.delete(r),n.onUnlisten(r)}function Ij(t,e){const n=ke(t);let r=!1;for(const i of e){const s=i.query,a=n.queries.get(s);if(a){for(const o of a.listeners)o.Pu(i)&&(r=!0);a.Au=i}}r&&gS(n)}function Rj(t,e,n){const r=ke(t),i=r.queries.get(e);if(i)for(const s of i.listeners)s.onError(n);r.queries.delete(e)}function gS(t){t.Ru.forEach(e=>{e.next()})}class Oj{constructor(e,n,r){this.query=e,this.vu=n,this.Vu=!1,this.Su=null,this.onlineState="Unknown",this.options=r||{}}Pu(e){if(!this.options.includeMetadataChanges){const r=[];for(const i of e.docChanges)i.type!==3&&r.push(i);e=new yl(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0)}let n=!1;return this.Vu?this.Du(e)&&(this.vu.next(e),n=!0):this.Cu(e,this.onlineState)&&(this.xu(e),n=!0),this.Su=e,n}onError(e){this.vu.error(e)}bu(e){this.onlineState=e;let n=!1;return this.Su&&!this.Vu&&this.Cu(this.Su,e)&&(this.xu(this.Su),n=!0),n}Cu(e,n){if(!e.fromCache)return!0;const r=n!=="Offline";return(!this.options.Nu||!r)&&(!e.docs.isEmpty()||n==="Offline")}Du(e){if(e.docChanges.length>0)return!0;const n=this.Su&&this.Su.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!n)&&this.options.includeMetadataChanges===!0}xu(e){e=yl.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache),this.Vu=!0,this.vu.next(e)}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class yM{constructor(e){this.key=e}}class bM{constructor(e){this.key=e}}class Aj{constructor(e,n){this.query=e,this.Lu=n,this.Uu=null,this.current=!1,this.qu=Ve(),this.mutatedKeys=Ve(),this.Ku=DD(e),this.Gu=new vl(this.Ku)}get Qu(){return this.Lu}ju(e,n){const r=n?n.Wu:new vM,i=n?n.Gu:this.Gu;let s=n?n.mutatedKeys:this.mutatedKeys,a=i,o=!1;const l=this.query.limitType==="F"&&i.size===this.query.limit?i.last():null,c=this.query.limitType==="L"&&i.size===this.query.limit?i.first():null;if(e.inorderTraversal((u,d)=>{const _=i.get(u),p=JE(this.query,d)?d:null,f=!!_&&this.mutatedKeys.has(_.key),E=!!p&&(p.hasLocalMutations||this.mutatedKeys.has(p.key)&&p.hasCommittedMutations);let h=!1;_&&p?_.data.isEqual(p.data)?f!==E&&(r.track({type:3,doc:p}),h=!0):this.zu(_,p)||(r.track({type:2,doc:p}),h=!0,(l&&this.Ku(p,l)>0||c&&this.Ku(p,c)<0)&&(o=!0)):!_&&p?(r.track({type:0,doc:p}),h=!0):_&&!p&&(r.track({type:1,doc:_}),h=!0,(l||c)&&(o=!0)),h&&(p?(a=a.add(p),s=E?s.add(u):s.delete(u)):(a=a.delete(u),s=s.delete(u)))}),this.query.limit!==null)for(;a.size>this.query.limit;){const u=this.query.limitType==="F"?a.last():a.first();a=a.delete(u.key),s=s.delete(u.key),r.track({type:1,doc:u})}return{Gu:a,Wu:r,$i:o,mutatedKeys:s}}zu(e,n){return e.hasLocalMutations&&n.hasCommittedMutations&&!n.hasLocalMutations}applyChanges(e,n,r){const i=this.Gu;this.Gu=e.Gu,this.mutatedKeys=e.mutatedKeys;const s=e.Wu.Eu();s.sort((c,u)=>function(d,_){const p=f=>{switch(f){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return Pe()}};return p(d)-p(_)}(c.type,u.type)||this.Ku(c.doc,u.doc)),this.Hu(r);const a=n?this.Ju():[],o=this.qu.size===0&&this.current?1:0,l=o!==this.Uu;return this.Uu=o,s.length!==0||l?{snapshot:new yl(this.query,e.Gu,i,s,e.mutatedKeys,o===0,l,!1),Yu:a}:{Yu:a}}bu(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({Gu:this.Gu,Wu:new vM,mutatedKeys:this.mutatedKeys,$i:!1},!1)):{Yu:[]}}Xu(e){return!this.Lu.has(e)&&!!this.Gu.has(e)&&!this.Gu.get(e).hasLocalMutations}Hu(e){e&&(e.addedDocuments.forEach(n=>this.Lu=this.Lu.add(n)),e.modifiedDocuments.forEach(n=>{}),e.removedDocuments.forEach(n=>this.Lu=this.Lu.delete(n)),this.current=e.current)}Ju(){if(!this.current)return[];const e=this.qu;this.qu=Ve(),this.Gu.forEach(r=>{this.Xu(r.key)&&(this.qu=this.qu.add(r.key))});const n=[];return e.forEach(r=>{this.qu.has(r)||n.push(new bM(r))}),this.qu.forEach(r=>{e.has(r)||n.push(new yM(r))}),n}Zu(e){this.Lu=e.Hi,this.qu=Ve();const n=this.ju(e.documents);return this.applyChanges(n,!0)}tc(){return yl.fromInitialDocuments(this.query,this.Gu,this.mutatedKeys,this.Uu===0)}}class wj{constructor(e,n,r){this.query=e,this.targetId=n,this.view=r}}class Dj{constructor(e){this.key=e,this.ec=!1}}class Mj{constructor(e,n,r,i,s,a){this.localStore=e,this.remoteStore=n,this.eventManager=r,this.sharedClientState=i,this.currentUser=s,this.maxConcurrentLimboResolutions=a,this.nc={},this.sc=new hl(o=>wD(o),vp),this.ic=new Map,this.rc=new Set,this.oc=new dn(Ne.comparator),this.uc=new Map,this.cc=new oS,this.ac={},this.hc=new Map,this.lc=Sl.vn(),this.onlineState="Unknown",this.fc=void 0}get isPrimaryClient(){return this.fc===!0}}async function Lj(t,e){const n=zj(t);let r,i;const s=n.sc.get(e);if(s)r=s.targetId,n.sharedClientState.addLocalQueryTarget(r),i=s.view.tc();else{const a=await ej(n.localStore,cs(e));n.isPrimaryClient&&pM(n.remoteStore,a);const o=n.sharedClientState.addLocalQueryTarget(a.targetId);r=a.targetId,i=await xj(n,e,r,o==="current")}return i}async function xj(t,e,n,r){t.dc=(u,d,_)=>async function(p,f,E,h){let m=f.view.ju(E);m.$i&&(m=await lM(p.localStore,f.query,!1).then(({documents:v})=>f.view.ju(v,m)));const g=h&&h.targetChanges.get(f.targetId),T=f.view.applyChanges(m,p.isPrimaryClient,g);return AM(p,f.targetId,T.Yu),T.snapshot}(t,u,d,_);const i=await lM(t.localStore,e,!0),s=new Aj(e,i.Hi),a=s.ju(i.documents),o=Ru.createSynthesizedTargetChangeForCurrentChange(n,r&&t.onlineState!=="Offline"),l=s.applyChanges(a,t.isPrimaryClient,o);AM(t,n,l.Yu);const c=new wj(e,n,s);return t.sc.set(e,c),t.ic.has(n)?t.ic.get(n).push(e):t.ic.set(n,[
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*//**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class qj{constructor(e){this.observer=e,this.muted=!1}next(e){this.observer.next&&this.Ac(this.observer.next,e)}error(e){this.observer.error?this.Ac(this.observer.error,e):ls("Uncaught Error in snapshot listener:",e)}Rc(){this.muted=!0}Ac(e,n){this.muted||setTimeout(()=>{this.muted||e(n)},0)}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Wj{constructor(e,n,r,i){this.authCredentials=e,this.appCheckCredentials=n,this.asyncQueue=r,this.databaseInfo=i,this.user=Vn.UNAUTHENTICATED,this.clientId=fD.R(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this.authCredentials.start(r,async s=>{ye("FirestoreClient","Received user=",s.uid),await this.authCredentialListener(s),this.user=s}),this.appCheckCredentials.start(r,s=>(ye("FirestoreClient","Received new app check token=",s),this.appCheckCredentialListener(s,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 Oe(ie.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const e=new sa;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(n){const r=hS(n,"Failed to shutdown persistence");e.reject(r)}}),e.promise}}async function Qj(t,e){t.asyncQueue.verifyOperationInProgress(),ye("FirestoreClient","Initializing OfflineComponentProvider");const n=await t.getConfiguration();await e.initialize(n);let r=n.initialUser;t.setCredentialChangeListener(async i=>{r.isEqual(i)||(await aM(e.localStore,i),r=i)}),e.persistence.setDatabaseDeletedListener(()=>t.terminate()),t.offlineComponents=e}async function Kj(t,e){t.asyncQueue.verifyOperationInProgress();const n=await Xj(t);ye("FirestoreClient","Initializing OnlineComponentProvider");const r=await t.getConfiguration();await e.initialize(n,r),t.setCredentialChangeListener(i=>TM(e.remoteStore,i)),t.setAppCheckTokenChangeListener((i,s)=>TM(e.remoteStore,s)),t.onlineComponents=e}async function Xj(t){return t.offlineComponents||(ye("FirestoreClient","Using default OfflineComponentProvider"),await Qj(t,new jj)),t.offlineComponents}async function wM(t){return t.onlineComponents||(ye("FirestoreClient","Using default OnlineComponentProvider"),await Kj(t,new Hj)),t.onlineComponents}function Zj(t){return wM(t).then(e=>e.syncEngine)}async function Jj(t){const e=await wM(t),n=e.eventManager;return n.onListen=Lj.bind(null,e.syncEngine),n.onUnlisten=Pj.bind(null,e.syncEngine),n}function eH(t,e,n={}){const r=new sa;return t.asyncQueue.enqueueAndForget(async()=>function(i,s,a,o,l){const c=new qj({next:d=>{s.enqueueAndForget(()=>Nj(i,u));const _=d.docs.has(a);!_&&d.fromCache?l.reject(new Oe(ie.UNAVAILABLE,"Failed to get document because the client is offline.")):_&&d.fromCache&&o&&o.source==="server"?l.reject(new Oe(ie.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.)')):l.resolve(d)},error:d=>l.reject(d)}),u=new Oj(KE(a.path),c,{includeMetadataChanges:!0,Nu:!0});return Cj(i,u)}(await Jj(t),t.asyncQueue,e,n,r)),r.promise}const DM=new Map;/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function MM(t,e,n){if(!n)throw new Oe(ie.INVALID_ARGUMENT,`Function ${t}() cannot be called with an empty ${e}.`)}function tH(t,e,n,r){if(e===!0&&r===!0)throw new Oe(ie.INVALID_ARGUMENT,`${t} and ${n} cannot be used together.`)}function LM(t){if(!Ne.isDocumentKey(t))throw new Oe(ie.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`)}function xM(t){if(Ne.isDocumentKey(t))throw new Oe(ie.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`)}function TS(t){if(t===void 0)return"undefined";if(t===null)return"null";if(typeof t=="string")return t.length>20&&(t=`${t.substring(0,20)}...`),JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean")return""+t;if(typeof t=="object"){if(t instanceof Array)return"an array";{const e=function(n){return n.constructor?n.constructor.name:null}(t);return e?`a custom ${e} object`:"an object"}}return typeof t=="function"?"a function":Pe()}function Ja(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new Oe(ie.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=TS(t);throw new Oe(ie.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${n}`)}}return t}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class PM{constructor(e){var n;if(e.host===void 0){if(e.ssl!==void 0)throw new Oe(ie.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=e.host,this.ssl=(n=e.ssl)===null||n===void 0||n;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,e.cacheSizeBytes===void 0)this.cacheSizeBytes=41943040;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<1048576)throw new Oe(ie.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.useFetchStreams=!!e.useFetchStreams,tH("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling)}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class xp{constructor(e,n,r,i){this._authCredentials=e,this._appCheckCredentials=n,this._databaseId=r,this._app=i,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new PM({}),this._settingsFrozen=!1}get app(){if(!this._app)throw new Oe(ie.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 this._terminateTask!==void 0}_setSettings(e){if(this._settingsFrozen)throw new Oe(ie.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 PM(e),e.credentials!==void 0&&(this._authCredentials=function(n){if(!n)return new EV;switch(n.type){case"gapi":const r=n.client;return new yV(r,n.sessionIndex||"0",n.iamToken||null,n.authTokenFactory||null);case"provider":return n.client;default:throw new Oe(ie.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 n=DM.get(e);n&&(ye("ComponentProvider","Removing Datastore"),DM.delete(e),n.terminate())}(this),Promise.resolve()}}function vJ(t,e,n,r={}){var i;const s=(t=Ja(t,xp))._getSettings();if(s.host!=="firestore.googleapis.com"&&s.host!==e&&$E("Host has been set in both settings() and useEmulator(), emulator host will be used"),t._setSettings(Object.assign(Object.assign({},s),{host:`${e}:${n}`,ssl:!1})),r.mockUserToken){let a,o;if(typeof r.mockUserToken=="string")a=r.mockUserToken,o=Vn.MOCK_USER;else{a=YO(r.mockUserToken,(i=t._app)===null||i===void 0?void 0:i.options.projectId);const l=r.mockUserToken.sub||r.mockUserToken.user_id;if(!l)throw new Oe(ie.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");o=new Vn(l)}t._authCredentials=new SV(new mD(a,o))}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class wr{constructor(e,n,r){this.converter=n,this._key=r,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new ca(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new wr(this.firestore,e,this._key)}}class vS{constructor(e,n,r){this.converter=n,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new vS(this.firestore,e,this._query)}}class ca extends vS{constructor(e,n,r){super(e,n,KE(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new wr(this.firestore,null,new Ne(e))}withConverter(e){return new ca(this.firestore,e,this._path)}}function kM(t,e,...n){if(t=Ii(t),MM("collection","path",e),t instanceof xp){const r=Mt.fromString(e,...n);return xM(r),new ca(t,null,r)}{if(!(t instanceof wr||t instanceof ca))throw new Oe(ie.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(Mt.fromString(e,...n));return xM(r),new ca(t.firestore,null,r)}}function Pp(t,e,...n){if(t=Ii(t),arguments.length===1&&(e=fD.R()),MM("doc","path",e),t instanceof xp){const r=Mt.fromString(e,...n);return LM(r),new wr(t,null,new Ne(r))}{if(!(t instanceof wr||t instanceof ca))throw new Oe(ie.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(Mt.fromString(e,...n));return LM(r),new wr(t.firestore,t instanceof ca?t.converter:null,new Ne(r))}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class nH{constructor(){this.$c=Promise.resolve(),this.Bc=[],this.Lc=!1,this.Uc=[],this.qc=null,this.Kc=!1,this.Gc=!1,this.Qc=[],this.xo=new dM(this,"async_queue_retry"),this.jc=()=>{const n=dS();n&&ye("AsyncQueue","Visibility state changed to "+n.visibilityState),this.xo.bo()};const e=dS();e&&typeof e.addEventListener=="function"&&e.addEventListener("visibilitychange",this.jc)}get isShuttingDown(){return this.Lc}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Wc(),this.zc(e)}enterRestrictedMode(e){if(!this.Lc){this.Lc=!0,this.Gc=e||!1;const n=dS();n&&typeof n.removeEventListener=="function"&&n.removeEventListener("visibilitychange",this.jc)}}enqueue(e){if(this.Wc(),this.Lc)return new Promise(()=>{});const n=new sa;return this.zc(()=>this.Lc&&this.Gc?Promise.resolve():(e().then(n.resolve,n.reject),n.promise)).then(()=>n.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Bc.push(e),this.Hc()))}async Hc(){if(this.Bc.length!==0){try{await this.Bc[0](),this.Bc.shift(),this.xo.reset()}catch(e){if(!mu(e))throw e;ye("AsyncQueue","Operation failed with retryable error: "+e)}this.Bc.length>0&&this.xo.Ao(()=>this.Hc())}}zc(e){const n=this.$c.then(()=>(this.Kc=!0,e().catch(r=>{this.qc=r,this.Kc=!1;const i=function(s){let a=s.message||"";return s.stack&&(a=s.stack.includes(s.message)?s.stack:s.message+`
`+s.stack),a}(r);throw ls("INTERNAL UNHANDLED ERROR: ",i),r}).then(r=>(this.Kc=!1,r))));return this.$c=n,n}enqueueAfterDelay(e,n,r){this.Wc(),this.Qc.indexOf(e)>-1&&(n=0);const i=fS.createAndSchedule(this,e,n,r,s=>this.Jc(s));return this.Uc.push(i),i}Wc(){this.qc&&Pe()}verifyOperationInProgress(){}async Yc(){let e;do e=this.$c,await e;while(e!==this.$c)}Xc(e){for(const n of this.Uc)if(n.timerId===e)return!0;return!1}Zc(e){return this.Yc().then(()=>{this.Uc.sort((n,r)=>n.targetTimeMs-r.targetTimeMs);for(const n of this.Uc)if(n.skipDelay(),e!=="all"&&n.timerId===e)break;return this.Yc()})}ta(e){this.Qc.push(e)}Jc(e){const n=this.Uc.indexOf(e);this.Uc.splice(n,1)}}class wu extends xp{constructor(e,n,r,i){super(e,n,r,i),this.type="firestore",this._queue=new nH,this._persistenceKey=(i==null?void 0:i.name)||"[DEFAULT]"}_terminate(){return this._firestoreClient||FM(this),this._firestoreClient.terminate()}}function rH(t,e){const n=typeof t=="object"?t:kg(),r=typeof t=="string"?t:e||"(default)";return O_(n,"firestore").getImmediate({identifier:r})}function UM(t){return t._firestoreClient||FM(t),t._firestoreClient.verifyNotTerminated(),t._firestoreClient}function FM(t){var e;const n=t._freezeSettings(),r=function(i,s,a,o){return new LV(i,s,a,o.host,o.ssl,o.experimentalForceLongPolling,o.experimentalAutoDetectLongPolling,o.useFetchStreams)}(t._databaseId,((e=t._app)===null||e===void 0?void 0:e.options.appId)||"",t._persistenceKey,n);t._firestoreClient=new Wj(t._authCredentials,t._appCheckCredentials,t._queue,r)}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*//**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class yS{constructor(...e){for(let n=0;n<e.length;++n)if(e[n].length===0)throw new Oe(ie.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new jn(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class bl{constructor(e){this._byteString=e}static fromBase64String(e){try{return new bl(Ln.fromBase64String(e))}catch(n){throw new Oe(ie.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+n)}}static fromUint8Array(e){return new bl(Ln.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class BM{constructor(e){this._methodName=e}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class bS{constructor(e,n){if(!isFinite(e)||e<-90||e>90)throw new Oe(ie.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(n)||n<-180||n>180)throw new Oe(ie.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+n);this._lat=e,this._long=n}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return ot(this._lat,e._lat)||ot(this._long,e._long)}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const iH=/^__.*__$/;class sH{constructor(e,n,r){this.data=e,this.fieldMask=n,this.fieldTransforms=r}toMutation(e,n){return this.fieldMask!==null?new Qa(e,this.data,this.fieldMask,n,this.fieldTransforms):new Cu(e,this.data,n,this.fieldTransforms)}}function GM(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw Pe()}}class CS{constructor(e,n,r,i,s,a){this.settings=e,this.databaseId=n,this.It=r,this.ignoreUndefinedProperties=i,s===void 0&&this.ea(),this.fieldTransforms=s||[],this.fieldMask=a||[]}get path(){return this.settings.path}get na(){return this.settings.na}sa(e){return new CS(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.It,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}ia(e){var n;const r=(n=this.path)===null||n===void 0?void 0:n.child(e),i=this.sa({path:r,ra:!1});return i.oa(e),i}ua(e){var n;const r=(n=this.path)===null||n===void 0?void 0:n.child(e),i=this.sa({path:r,ra:!1});return i.ea(),i}ca(e){return this.sa({path:void 0,ra:!0})}aa(e){return kp(e,this.settings.methodName,this.settings.ha||!1,this.path,this.settings.la)}contains(e){return this.fieldMask.find(n=>e.isPrefixOf(n))!==void 0||this.fieldTransforms.find(n=>e.isPrefixOf(n.field))!==void 0}ea(){if(this.path)for(let e=0;e<this.path.length;e++)this.oa(this.path.get(e))}oa(e){if(e.length===0)throw this.aa("Document fields must not be empty");if(GM(this.na)&&iH.test(e))throw this.aa('Document fields cannot begin and end with "__"')}}class aH{constructor(e,n,r){this.databaseId=e,this.ignoreUndefinedProperties=n,this.It=r||wp(e)}fa(e,n,r,i=!1){return new CS({na:e,methodName:n,la:r,path:jn.emptyPath(),ra:!1,ha:i},this.databaseId,this.It,this.ignoreUndefinedProperties)}}function $M(t){const e=t._freezeSettings(),n=wp(t._databaseId);return new aH(t._databaseId,!!e.ignoreUndefinedProperties,n)}function YM(t,e,n,r,i,s={}){const a=t.fa(s.merge||s.mergeFields?2:0,e,n,i);HM("Data must be an object, but it was:",a,r);const o=VM(r,a);let l,c;if(s.merge)l=new wi(a.fieldMask),c=a.fieldTransforms;else if(s.mergeFields){const u=[];for(const d of s.mergeFields){const _=oH(e,d,n);if(!a.contains(_))throw new Oe(ie.INVALID_ARGUMENT,`Field '${_}' is specified in your field mask but missing from your input data.`);cH(u,_)||u.push(_)}l=new wi(u),c=a.fieldTransforms.filter(d=>l.covers(d.field))}else l=null,c=a.fieldTransforms;return new sH(new jr(o),l,c)}function zM(t,e){if(jM(t=Ii(t)))return HM("Unsupported field value:",e,t),VM(t,e);if(t instanceof BM)return function(n,r){if(!GM(r.na))throw r.aa(`${n._methodName}() can only be used with update() and set()`);if(!r.path)throw r.aa(`${n._methodName}() is not currently supported inside arrays`);const i=n._toFieldTransform(r);i&&r.fieldTransforms.push(i)}(t,e),null;if(t===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.settings.ra&&e.na!==4)throw e.aa("Nested arrays are not supported");return function(n,r){const i=[];let s=0;for(const a of n){let o=zM(a,r.ca(s));o==null&&(o={nullValue:"NULL_VALUE"}),i.push(o),s++}return{arrayValue:{values:i}}}(t,e)}return function(n,r){if((n=Ii(n))===null)return{nullValue:"NULL_VALUE"};if(typeof n=="number")return ZV(r.It,n);if(typeof n=="boolean")return{booleanValue:n};if(typeof n=="string")return{stringValue:n};if(n instanceof Date){const i=un.fromDate(n);return{timestampValue:Ap(r.It,i)}}if(n instanceof un){const i=new un(n.seconds,1e3*Math.floor(n.nanoseconds/1e3));return{timestampValue:Ap(r.It,i)}}if(n instanceof bS)return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if(n instanceof bl)return{bytesValue:eM(r.It,n._byteString)};if(n instanceof wr){const i=r.databaseId,s=n.firestore._databaseId;if(!s.isEqual(i))throw r.aa(`Document reference is for database ${s.projectId}/${s.database} but should be for database ${i.projectId}/${i.database}`);return{referenceValue:tS(n.firestore._databaseId||r.databaseId,n._key.path)}}throw r.aa(`Unsupported field value: ${TS(n)}`)}(t,e)}function VM(t,e){const n={};return gD(t)?e.path&&e.path.length>0&&e.fieldMask.p
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class WM{constructor(e,n,r,i,s){this._firestore=e,this._userDataWriter=n,this._key=r,this._document=i,this._converter=s}get id(){return this._key.path.lastSegment()}get ref(){return new wr(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new uH(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){const n=this._document.data.field(QM("DocumentSnapshot.get",e));if(n!==null)return this._userDataWriter.convertValue(n)}}}class uH extends WM{data(){return super.data()}}function QM(t,e){return typeof e=="string"?qM(t,e):e instanceof yS?e._internalPath:e._delegate._internalPath}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class dH{constructor(e,n){this.hasPendingWrites=e,this.fromCache=n}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class KM extends WM{constructor(e,n,r,i,s,a){super(e,n,r,i,a),this._firestore=e,this._firestoreImpl=e,this.metadata=s}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const n=new _H(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(n,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,n={}){if(this._document){const r=this._document.data.field(QM("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,n.serverTimestamps)}}}class _H extends KM{data(e={}){return super.data(e)}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class pH{convertValue(e,n="none"){switch(Wa(e)){case 0:return null;case 1:return e.booleanValue;case 2:return rn(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,n);case 5:return e.stringValue;case 6:return this.convertBytes(pl(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,n);case 10:return this.convertObject(e.mapValue,n);default:throw Pe()}}convertObject(e,n){const r={};return _l(e.fields,(i,s)=>{r[i]=this.convertValue(s,n)}),r}convertGeoPoint(e){return new bS(rn(e.latitude),rn(e.longitude))}convertArray(e,n){return(e.values||[]).map(r=>this.convertValue(r,n))}convertServerTimestamp(e,n){switch(n){case"previous":const r=TD(e);return r==null?null:this.convertValue(r,n);case"estimate":return this.convertTimestamp(fu(e));default:return null}}convertTimestamp(e){const n=oa(e);return new un(n.seconds,n.nanos)}convertDocumentKey(e,n){const r=Mt.fromString(e);yt(sM(r));const i=new hu(r.get(1),r.get(3)),s=new Ne(r.popFirst(5));return i.isEqual(n)||ls(`Document ${s} contains a document reference within a different database (${i.projectId}/${i.database}) which is not supported. It will be treated as a reference in the current database (${n.projectId}/${n.database}) instead.`),s}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function XM(t,e,n){let r;return r=t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e,r}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*//**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function mH(t){t=Ja(t,wr);const e=Ja(t.firestore,wu);return eH(UM(e),t._key).then(n=>gH(e,t,n))}class fH extends pH{constructor(e){super(),this.firestore=e}convertBytes(e){return new bl(e)}convertReference(e){const n=this.convertDocumentKey(e,this.firestore._databaseId);return new wr(this.firestore,null,n)}}function NS(t,e,n){t=Ja(t,wr);const r=Ja(t.firestore,wu),i=XM(t.converter,e,n);return IS(r,[YM($M(r),"setDoc",t._key,i,t.converter!==null,n).toMutation(t._key,oi.none())])}function hH(t){return IS(Ja(t.firestore,wu),[new eS(t._key,oi.none())])}function ZM(t,e){const n=Ja(t.firestore,wu),r=Pp(t),i=XM(t.converter,e);return IS(n,[YM($M(t.firestore),"addDoc",r._key,i,t.converter!==null,{}).toMutation(r._key,oi.exists(!1))]).then(()=>r)}function IS(t,e){return function(n,r){const i=new sa;return n.asyncQueue.enqueueAndForget(async()=>kj(await Zj(n),r,i)),i.promise}(UM(t),e)}function gH(t,e,n){const r=n.docs.get(e._key),i=new fH(t);return new KM(t,i,e._key,r,new dH(n.hasPendingWrites,n.fromCache),e.converter)}(function(t,e=!0){(function(n){ul=n})(el),Fa(new Ks("firestore",(n,{instanceIdentifier:r,options:i})=>{const s=n.getProvider("app").getImmediate(),a=new wu(new TV(n.getProvider("auth-internal")),new CV(n.getProvider("app-check-internal")),function(o,l){if(!Object.prototype.hasOwnProperty.apply(o.options,["projectId"]))throw new Oe(ie.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new hu(o.options.projectId,l)}(s,r),s);return i=Object.assign({useFetchStreams:e},i),a._setSettings(i),a},"PUBLIC").setMultipleInstances(!0)),Ri(_D,"3.4.15",t),Ri(_D,"3.4.15","esm2017")})();/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const JM="firebasestorage.googleapis.com",EH="storageBucket",SH=2*60*1e3,TH=10*60*1e3;/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Mi extends Ni{constructor(e,n){super(RS(e),`Firebase Storage: ${n} (${RS(e)})`),this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,Mi.prototype)}_codeEquals(e){return RS(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}
${this.customData.serverResponse}`:this.message=this._baseMessage}}function RS(t){return"storage/"+t}function vH(){const t="An unknown error occurred, please check the error payload for server response.";return new Mi("unknown",t)}function yH(){return new Mi("retry-limit-exceeded","Max retry time for operation exceeded, please try again.")}function bH(){return new Mi("canceled","User canceled the upload/download.")}function CH(t){return new Mi("invalid-url","Invalid URL '"+t+"'.")}function NH(t){return new Mi("invalid-default-bucket","Invalid default bucket '"+t+"'.")}function eL(t){return new Mi("invalid-argument",t)}function tL(){return new Mi("app-deleted","The Firebase app was deleted.")}function IH(t){return new Mi("invalid-root-operation","The operation '"+t+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class li{constructor(e,n){this.bucket=e,this.path_=n}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,n){let r;try{r=li.makeFromUrl(e,n)}catch{return new li(e,"")}if(r.path==="")return r;throw NH(e)}static makeFromUrl(e,n){let r=null;const i="([A-Za-z0-9.\\-_]+)";function s(v){v.path.charAt(v.path.length-1)==="/"&&(v.path_=v.path_.slice(0,-1))}const a="(/(.*))?$",o=new RegExp("^gs://"+i+a,"i"),l={bucket:1,path:3};function c(v){v.path_=decodeURIComponent(v.path)}const u="v[A-Za-z0-9_]+",d=n.replace(/[.]/g,"\\."),_="(/([^?#]*).*)?$",p=new RegExp(`^https?://${d}/${u}/b/${i}/o${_}`,"i"),f={bucket:1,path:3},E=n===JM?"(?:storage.googleapis.com|storage.cloud.google.com)":n,h="([^?#]*)",m=new RegExp(`^https?://${E}/${i}/${h}`,"i"),T=[{regex:o,indices:l,postModify:s},{regex:p,indices:f,postModify:c},{regex:m,indices:{bucket:1,path:2},postModify:c}];for(let v=0;v<T.length;v++){const R=T[v],C=R.regex.exec(e);if(C){const b=C[R.indices.bucket];let N=C[R.indices.path];N||(N=""),r=new li(b,N),R.postModify(r);break}}if(r==null)throw CH(e);return r}}class RH{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function OH(t,e,n){let r=1,i=null,s=null,a=!1,o=0;function l(){return o===2}let c=!1;function u(...h){c||(c=!0,e.apply(null,h))}function d(h){i=setTimeout(()=>{i=null,t(p,l())},h)}function _(){s&&clearTimeout(s)}function p(h,...m){if(c){_();return}if(h){_(),u.call(null,h,...m);return}if(l()||a){_(),u.call(null,h,...m);return}r<64&&(r*=2);let T;o===1?(o=2,T=0):T=(r+Math.random())*1e3,d(T)}let f=!1;function E(h){f||(f=!0,_(),!c&&(i!==null?(h||(o=2),clearTimeout(i),d(0)):h||(o=1)))}return d(0),s=setTimeout(()=>{a=!0,E(!0)},n),E}function AH(t){t(!1)}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function wH(t){return t!==void 0}function nL(t,e,n,r){if(r<e)throw eL(`Invalid value for '${t}'. Expected ${e} or greater.`);if(r>n)throw eL(`Invalid value for '${t}'. Expected ${n} or less.`)}function DH(t){const e=encodeURIComponent;let n="?";for(const r in t)if(t.hasOwnProperty(r)){const i=e(r)+"="+e(t[r]);n=n+i+"&"}return n=n.slice(0,-1),n}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Up;(function(t){t[t.NO_ERROR=0]="NO_ERROR",t[t.NETWORK_ERROR=1]="NETWORK_ERROR",t[t.ABORT=2]="ABORT"})(Up||(Up={}));/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class MH{constructor(e,n,r,i,s,a,o,l,c,u,d){this.url_=e,this.method_=n,this.headers_=r,this.body_=i,this.successCodes_=s,this.additionalRetryCodes_=a,this.callback_=o,this.errorCallback_=l,this.timeout_=c,this.progressCallback_=u,this.connectionFactory_=d,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((_,p)=>{this.resolve_=_,this.reject_=p,this.start_()})}start_(){const e=(r,i)=>{if(i){r(!1,new Fp(!1,null,!0));return}const s=this.connectionFactory_();this.pendingConnection_=s;const a=o=>{const l=o.loaded,c=o.lengthComputable?o.total:-1;this.progressCallback_!==null&&this.progressCallback_(l,c)};this.progressCallback_!==null&&s.addUploadProgressListener(a),s.send(this.url_,this.method_,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&s.removeUploadProgressListener(a),this.pendingConnection_=null;const o=s.getErrorCode()===Up.NO_ERROR,l=s.getStatus();if(!o||this.isRetryStatusCode_(l)){const u=s.getErrorCode()===Up.ABORT;r(!1,new Fp(!1,null,u));return}const c=this.successCodes_.indexOf(l)!==-1;r(!0,new Fp(c,s))})},n=(r,i)=>{const s=this.resolve_,a=this.reject_,o=i.connection;if(i.wasSuccessCode)try{const l=this.callback_(o,o.getResponse());wH(l)?s(l):s()}catch(l){a(l)}else if(o!==null){const l=vH();l.serverResponse=o.getErrorText(),this.errorCallback_?a(this.errorCallback_(o,l)):a(l)}else if(i.canceled){const l=this.appDelete_?tL():bH();a(l)}else{const l=yH();a(l)}};this.canceled_?n(!1,new Fp(!1,null,!0)):this.backoffId_=OH(e,n,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&AH(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}isRetryStatusCode_(e){const n=e>=500&&e<600,i=[408,429].indexOf(e)!==-1,s=this.additionalRetryCodes_.indexOf(e)!==-1;return n||i||s}}class Fp{constructor(e,n,r){this.wasSuccessCode=e,this.connection=n,this.canceled=!!r}}function LH(t,e){e!==null&&e.length>0&&(t.Authorization="Firebase "+e)}function xH(t,e){t["X-Firebase-Storage-Version"]="webjs/"+(e!=null?e:"AppManager")}function PH(t,e){e&&(t["X-Firebase-GMPID"]=e)}function kH(t,e){e!==null&&(t["X-Firebase-AppCheck"]=e)}function UH(t,e,n,r,i,s){const a=DH(t.urlParams),o=t.url+a,l=Object.assign({},t.headers);return PH(l,e),LH(l,n),xH(l,s),kH(l,r),new MH(o,t.method,l,t.body,t.successCodes,t.additionalRetryCodes,t.handler,t.errorHandler,t.timeout,t.progressCallback,i)}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function FH(t){if(t.length===0)return null;const e=t.lastIndexOf("/");return e===-1?"":t.slice(0,e)}function BH(t){const e=t.lastIndexOf("/",t.length-2);return e===-1?t:t.slice(e+1)}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Bp{constructor(e,n){this._service=e,n instanceof li?this._location=n:this._location=li.makeFromUrl(n,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,n){return new Bp(e,n)}get root(){const e=new li(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return BH(this._location.path)}get storage(){return this._service}get parent(){const e=FH(this._location.path);if(e===null)return null;const n=new li(this._location.bucket,e);return new Bp(this._service,n)}_throwIfRoot(e){if(this._location.path==="")throw IH(e)}}function rL(t,e){const n=e==null?void 0:e[EH];return n==null?null:li.makeFromBucketSpec(n,t)}function GH(t,e,n,r={}){t.host=`${e}:${n}`,t._protocol="http";const{mockUserToken:i}=r;i&&(t._overrideAuthToken=typeof i=="string"?i:YO(i,t.app.options.projectId))}class $H{constructor(e,n,r,i,s){this.app=e,this._authProvider=n,this._appCheckProvider=r,this._url=i,this._firebaseVersion=s,this._bucket=null,this._host=JM,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=SH,this._maxUploadRetryTime=TH,this._requests=new Set,i!=null?this._bucket=li.makeFromBucketSpec(i,this._host):this._bucket=rL(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=li.makeFromBucketSpec(this._url,e):this._bucket=rL(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){nL("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){nL("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){const n=await e.getToken();if(n!==null)return n.accessToken}return null}async _getAppCheckToken(){const e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new Bp(this,e)}_makeRequest(e,n,r,i){if(this._deleted)return new RH(tL());{const s=UH(e,this._appId,r,i,n,this._firebaseVersion);return this._requests.add(s),s.getPromise().then(()=>this._requests.delete(s),()=>this._requests.delete(s)),s}}async makeRequestWithTokens(e,n){const[r,i]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,n,r,i).getPromise()}}const iL="@firebase/storage",sL="0.9.9";/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const aL="storage";function YH(t=kg(),e){return t=Ii(t),O_(t,aL).getImmediate({identifier:e})}function yJ(t,e,n,r={}){GH(t,e,n,r)}function zH(t,{instanceIdentifier:e}){const n=t.getProvider("app").getImmediate(),r=t.getProvider("auth-internal"),i=t.getProvider("app-check-internal");return new $H(n,r,i,e,el)}function VH(){Fa(new Ks(aL,zH,"PUBLIC").setMultipleInstances(!0)),Ri(iL,sL,""),Ri(iL,sL,"esm2017")}VH();const Du={VITE_BOOKISH_FIREBASE_API_KEY:"AIzaSyAezJ0ugQCnm4C2NxTWquSwkEZMRn4zfnc",VITE_BOOKISH_AUTH_DOMAIN:"bookish-dev-21ac3.firebaseapp.com",VITE_BOOKISH_PROJECT_ID:"bookish-dev-21ac3",VITE_BOOKISH_STORAGE_BUCKET:"bookish-dev-21ac3.appspot.com",VITE_BOOKISH_MESSAGING_SENDER_ID:"252717859016",VITE_BOOKISH_APP_ID:"1:252717859016:web:269a03f7178635e4cb65fd",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0}.VITE_READER==="true";Du||uY({apiKey:"AIzaSyAezJ0ugQCnm4C2NxTWquSwkEZMRn4zfnc",authDomain:"bookish-dev-21ac3.firebaseapp.com",projectId:"bookish-dev-21ac3",storageBucket:"bookish-dev-21ac3.appspot.com",messagingSenderId:"252717859016",appId:"1:252717859016:web:269a03f7178635e4cb65fd"});const bJ=Du?void 0:dz(),Dr=Du?void 0:rH(),oL=Du?void 0:YH(),jH=async t=>{if(!Dr)throw Error("Can't publish draft, no Firebase connection.");const e=await t.getDraftEdition();if(e===void 0)return;const n=await ZM(kM(Dr,"editions"),e.toObject()),r=t.getRevisions();r.unshift({ref:n,time:Date.now(),summary:"",published:!1}),t.setRevisions(r),lL(t)},HH=async(t,e,n)=>{if(!Dr)throw Error("Can't publish draft, no Firebase connection.");t.setPublished(n,e);const r=await t.getLatestPublishedEdition();r&&t.updateMetadataFromEdition(r),lL(t)},qH=async t=>{if(!Dr)throw Error("Can't update edition, not connected to Firebase.");const e=t.toObject(),n=t.getRef();if(!n)throw Error("Book given has no ID");await NS(Pp(Dr,"editions",n.id),e),t.book!==void 0&&t.isLatestPublishedEdition()&&t.book.updateMetadataFromEdition(t)},lL=async t=>{if(!Dr)throw Error("Can't update boo, not connected to Firebase.");await NS(Pp(Dr,"books",t.getRefID()),t.toObject())},WH=async(t,e)=>{if(!Dr)throw Error("Can't add chapter, not connected to Firebase.");return await ZM(kM(Dr,`editions/${t.id}/chapters`),e)},QH=async t=>{if(!Dr)throw Error("Can't add chapter, not connected to Firebase.");const e=t.getRef();if(!e)throw Error("Can't delete chapter, it doesn't have a document ID.");await hH(e)},KH=async t=>{if(!Dr)throw Error("Not connected to Firebase.");const e=await mH(t);if(!e.exists())throw Error("Chapter text does not exist.");return e.data()},XH=async(t,e,n)=>{if(!Dr)throw Error("Can't update chapter, not connected to Firebase.");const r={text:n};await NS(Pp(Dr,`editions/${t.id}/chapters`,e.id),r)};class cL{constructor(e,n){et(this,"spec");et(this,"edition");et(this,"ast");et(this,"index");et(this,"wordCount");et(this,"edits",[]);et(this,"timerID");et(this,"lastEdit",0);et(this,"listeners",new Set);var r,i;this.edition=e,this.spec={ref:n.ref,id:n.id,title:n.title,authors:(r=n.authors)!=null?r:[],image:(i=n.image)!=null?i:null,numbered:n.numbered===!0||n.numbered===void 0,forthcoming:n.forthcoming===!0,text:n.text},this.spec.text!==void 0?this.setText(this.spec.text):this.spec.ref?KH(this.spec.ref).then(s=>this.setText(s.text)):(this.ast=void 0,this.wordCount=0,this.index=void 0),this.timerID=setInterval(()=>{this.edition.editionRef&&this.spec.ref&&this.spec.text&&Date.now()-this.lastEdit>1e3&&this.edits.length>0&&(this.edition.notifyListeners(Hr.Saving),XH(this.edition.editionRef,this.spec.ref,this.spec.text).then(()=>{this.edits.forEach(s=>s.resolve()),this.edition.notifyListeners(Hr.Saved)}).catch(()=>{this.edits.forEach(s=>s.reject()),this.edition.notifyListeners(Hr.Error)}).finally(()=>{this.edits=[]}))},500)}addListener(e){this.listeners.add(e)}removeListener(e){this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>this.spec.text!==void 0?e.call(void 0,this.spec.text):void 0)}requestSave(){return this.edition.notifyListeners(Hr.Changed),this.lastEdit=Date.now(),new Promise((n,r)=>{this.edits.push({resolve:n,reject:r})})}toObject(){const e=JSON.pars
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var JH=A.exports,eq=Symbol.for("react.element"),tq=Symbol.for("react.fragment"),nq=Object.prototype.hasOwnProperty,rq=JH.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,iq={key:!0,ref:!0,__self:!0,__source:!0};function dL(t,e,n){var r,i={},s=null,a=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(a=e.ref);for(r in e)nq.call(e,r)&&!iq.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:eq,type:t,key:s,ref:a,props:i,_owner:rq.current}}$p.Fragment=tq,$p.jsx=dL,$p.jsxs=dL,function(t){t.exports=$p}(Gp);const je=Gp.exports.Fragment,S=Gp.exports.jsx,q=Gp.exports.jsxs,Yp=t=>{let[e,n]=A.exports.useState(!1);const r=A.exports.useContext(Hn);function i(){return r.marginalID===null||r.marginalID!==t.id}function s(){r.setMarginal&&(OS()&&i()?r.setMarginal(t.id):r.setMarginal(void 0))}const a=()=>n(!0),o=()=>n(!1);return A.exports.useEffect(()=>{const l=uL();return l.addEventListener("change",s),()=>{l.removeEventListener("change",s)}},[]),q("span",{children:[S("span",{className:"bookish-marginal-interactor"+(e?" bookish-marginal-hovered":"")+(i()?"":" bookish-marginal-selected"),onClick:s,onMouseEnter:a,onMouseLeave:o,children:t.interactor}),S("span",{className:"bookish-marginal"+(i()?" bookish-marginal-hidden":"")+(e?" bookish-marginal-hovered":""),onClick:s,onMouseEnter:a,onMouseLeave:o,children:t.content})]})},ir=Zr.createContext(void 0),zp=t=>{const{node:e,textView:n}=t,r=A.exports.useContext(ir),i=r&&r.range&&r.range.start.node===e;function s(a){r!==void 0&&(r.setCaretRange({start:{node:e,index:0},end:{node:e,index:0}}),a.stopPropagation())}return S("span",{className:`bookish-editor-atom ${i?"bookish-editor-atom-selected":""} ${r!=null&&r.focused?"bookish-editor-atom-selected-focused":""}`,onMouseDown:s,children:n})},AS=t=>q("span",{className:"bookish-error","data-nodeid":t.node.nodeID,children:["Error: ",t.node.getError()]}),sr=t=>{const[e,n]=A.exports.useState(0),[r,i]=A.exports.useState(t.text),[s,a]=A.exports.useState(t.valid.call(void 0,t.text)),o=A.exports.useRef(null),l=A.exports.useRef(null);A.exports.useEffect(()=>{u()},[r,e]),A.exports.useEffect(()=>{var m,g;e===1?(m=o==null?void 0:o.current)==null||m.focus():(g=o==null?void 0:o.current)==null||g.blur()},[e]);function c(){return r===""&&e==0}function u(){if(l.current){const m=c()?t.placeholder:r.replace(/\s/g,"\xA0"),g=t.width!==void 0&&(t.clip===!0||e===1)?m.substring(0,t.width)+"\u2026":m;l.current.innerHTML=g}}function d(){n(1)}function _(){n(0),t.saveOnExit===!0&&f(r)}function p(){if(o!=null&&o.current){const m=o==null?void 0:o.current.value;i(m),E(m)===void 0&&t.saveOnExit!==!0&&f(m)}}function f(m){const g=t.save(m);typeof g=="string"&&i(g)}function E(m){const g=t.valid.call(void 0,m);return a(g),g}function h(m){u(),m.key==="Enter"&&(n(0),m.preventDefault())}return q("span",{className:`bookish-text-editor ${c()?"bookish-text-editor-placeholder":""} ${e===0?"bookish-text-editor-viewing":""}`,children:[S("span",{className:"bookish-text-editor-sizer","aria-hidden":!0,ref:l,onClick:d}),S("input",{type:"text",required:!0,role:"textbox",tabIndex:0,"aria-invalid":s!==void 0,"aria-label":t.label,ref:o,value:c()?t.placeholder:r,onChange:p,onKeyPress:h,onBlur:_,onFocus:d}),s?S("span",{"aria-live":"polite",className:`bookish-text-editor-error ${e===1?"bookish-text-editor-error-focused":""}`,children:e===0?"\u2715":s}):null]})},sq=t=>{const{node:e}=t,{editable:n,edition:r}=A.exports.useContext(mt);if(e.short){let i=e.authors.split(","),s;return i.length===1?s=i[0]:i.length===2?s=i[0].trim()+" & "+i[1].trim():s=i[0].trim()+", et al.",q("span",{"data-nodeid":t.node.nodeID,className:"bookish-reference-text",children:[s," (",e.year,"). ",e.url===null?e.title:S("a",{href:e.url,target:"_blank",children:e.title}),e.title.charAt(e.title.length-1)==="?"?"":"."," ",S("em",{children:e.source})]})}else{const i=n&&r?S("em",{children:S(sr,{text:e.authors,label:"Author list editor.",placeholder:"Authors",valid:c=>{if(c.length===0)return"Authors can't be empty."},save:c=>r.e
`&&(n=n+"\uFEFF"),n.length===0&&(n="\uFEFF"),r&&r.highlightedWord){const s=r.highlightedWord,a=n.toLowerCase();if(a.indexOf(s)>=0){const o=[];for(let c=0;c<n.length;++c)a.substring(c,c+s.length)===s&&o.push(c);const l=[];for(let c=0;c<o.length;c++)l.push(n.substring(c===0?0:o[c-1]+s.length,o[c])),l.push(S("span",{className:"bookish-text bookish-content-highlight",children:n.substring(o[c],o[c]+s.length)},"match-"+c));return o[o.length-1]<n.length-1&&l.push(n.substring(o[o.length-1]+s.length,n.length)),S("span",{children:l})}else return S("span",{children:n})}return S("span",{ref:i,className:"bookish-text","data-nodeid":t.node.nodeID,children:n})},lq=t=>{const{node:e}=t,n=e.getMeta(),r=e.getText(),i=A.exports.useContext(Hn);if(!i||!i.book)return S(je,{});let a=i.book.getGlossary()[n];A.exports.useEffect(()=>{i&&i.layoutMarginals&&i.layoutMarginals()});const o=S(Lu,{node:r});return S("span",{className:`bookish-definition ${a===void 0?"bookish-error":""}`,"data-nodeid":t.node.nodeID,children:S(Yp,{id:"glossary-"+n,interactor:o,content:S("span",{className:"bookish-definition-entry",children:a===void 0?q("span",{className:"bookish-error",children:['Unknown glossary entry "',n,'"']}):q(je,{children:[S("strong",{className:"bookish-definition-entry-phrase",children:a.phrase}),": ",S(Ut,{node:qe.parseFormat(i.book,a.definition)},"definition"),a.synonyms&&a.synonyms.length>0?q("span",{className:"bookish-definition-entry-synonyms",children:[S("br",{}),S("br",{}),a.synonyms.join(", ")]}):null]})})})})},cq=t=>{var u;const{node:e}=t,n=e.getMeta(),r=A.exports.useContext(Hn),i=A.exports.useContext(ir),s=(u=r.chapter)==null?void 0:u.getAST();if(s===void 0||!r.book)return S(je,{});let a=s.getFootnotes().indexOf(e),o=r.book.getFootnoteSymbol(a);const l=i&&i.range&&i.range.start.node.hasAncestor(s,e);A.exports.useEffect(()=>{r&&r.layoutMarginals&&r.layoutMarginals()});function c(d){d==null||d.stopPropagation()}return S(zp,{node:e,textView:S("span",{className:"bookish-footnote-link","data-nodeid":t.node.nodeID,children:S(Yp,{id:"footnote-"+a,interactor:S("sup",{className:"bookish-footnote-symbol",children:o}),content:q("span",{className:`bookish-footnote ${l?"bookish-footnote-focused":""}`,onMouseDown:c,children:[S("sup",{className:"bookish-footnote-symbol",children:o}),S(Ut,{node:n,placeholder:"footnote"})]})})})})};var DS={exports:{}};function MS(t){return t instanceof Map?t.clear=t.delete=t.set=function(){throw new Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=function(){throw new Error("set is read-only")}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach(function(e){var n=t[e];typeof n=="object"&&!Object.isFrozen(n)&&MS(n)}),t}DS.exports=MS,DS.exports.default=MS;var uq=DS.exports;class _L{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function pL(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function ua(t,...e){const n=Object.create(null);for(const r in t)n[r]=t[r];return e.forEach(function(r){for(const i in r)n[i]=r[i]}),n}const dq="</span>",mL=t=>!!t.kind,_q=(t,{prefix:e})=>{if(t.includes(".")){const n=t.split(".");return[`${e}${n.shift()}`,...n.map((r,i)=>`${r}${"_".repeat(i+1)}`)].join(" ")}return`${e}${t}`};class pq{constructor(e,n){this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){this.buffer+=pL(e)}openNode(e){if(!mL(e))return;let n=e.kind;e.sublanguage?n=`language-${n}`:n=_q(n,{prefix:this.classPrefix}),this.span(n)}closeNode(e){!mL(e)||(this.buffer+=dq)}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}}class LS{constructor(){this.rootNode={children:[]},this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const n={kind:e,children:[]};this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4
https://github.com/highlightjs/highlight.js/issues/2277`),D=W,U=ne),H===void 0&&(H=!0);const B={code:U,language:D};se("before:highlight",B);const $=B.result?B.result:d(B.language,B.code,H);return $.code=B.code,se("after:highlight",$),$}function d(W,ne,H,U){const D=Object.create(null);function B(oe,ce){return oe.keywords[ce]}function $(){if(!z.keywords){ae.addText(he);return}let oe=0;z.keywordPatternRe.lastIndex=0;let ce=z.keywordPatternRe.exec(he),Ie="";for(;ce;){Ie+=he.substring(oe,ce.index);const Ue=Q.case_insensitive?ce[0].toLowerCase():ce[0],Ze=B(z,Ue);if(Ze){const[Bt,fi]=Ze;if(ae.addText(Ie),Ie="",D[Ue]=(D[Ue]||0)+1,D[Ue]<=Jq&&(ft+=fi),Bt.startsWith("_"))Ie+=ce[0];else{const hi=Q.classNameAliases[Bt]||Bt;ae.addKeyword(ce[0],hi)}}else Ie+=ce[0];oe=z.keywordPatternRe.lastIndex,ce=z.keywordPatternRe.exec(he)}Ie+=he.substr(oe),ae.addText(Ie)}function Y(){if(he==="")return;let oe=null;if(typeof z.subLanguage=="string"){if(!e[z.subLanguage]){ae.addText(he);return}oe=d(z.subLanguage,he,!0,fe[z.subLanguage]),fe[z.subLanguage]=oe._top}else oe=p(he,z.subLanguage.length?z.subLanguage:null);z.relevance>0&&(ft+=oe.relevance),ae.addSublanguage(oe._emitter,oe.language)}function I(){z.subLanguage!=null?Y():$(),he=""}function M(oe,ce){let Ie=1;for(;ce[Ie]!==void 0;){if(!oe._emit[Ie]){Ie++;continue}const Ue=Q.classNameAliases[oe[Ie]]||oe[Ie],Ze=ce[Ie];Ue?ae.addKeyword(Ze,Ue):(he=Ze,$(),he=""),Ie++}}function G(oe,ce){return oe.scope&&typeof oe.scope=="string"&&ae.openNode(Q.classNameAliases[oe.scope]||oe.scope),oe.beginScope&&(oe.beginScope._wrap?(ae.addKeyword(he,Q.classNameAliases[oe.beginScope._wrap]||oe.beginScope._wrap),he=""):oe.beginScope._multi&&(M(oe.beginScope,ce),he="")),z=Object.create(oe,{parent:{value:z}}),z}function K(oe,ce,Ie){let Ue=gq(oe.endRe,Ie);if(Ue){if(oe["on:end"]){const Ze=new _L(oe);oe["on:end"](ce,Ze),Ze.isMatchIgnored&&(Ue=!1)}if(Ue){for(;oe.endsParent&&oe.parent;)oe=oe.parent;return oe}}if(oe.endsWithParent)return K(oe.parent,ce,Ie)}function re(oe){return z.matcher.regexIndex===0?(he+=oe[0],1):(Jt=!0,0)}function le(oe){const ce=oe[0],Ie=oe.rule,Ue=new _L(Ie),Ze=[Ie.__beforeBegin,Ie["on:begin"]];for(const Bt of Ze)if(!!Bt&&(Bt(oe,Ue),Ue.isMatchIgnored))return re(ce);return Ie.skip?he+=ce:(Ie.excludeBegin&&(he+=ce),I(),!Ie.returnBegin&&!Ie.excludeBegin&&(he=ce)),G(Ie,oe),Ie.returnBegin?0:ce.length}function we(oe){const ce=oe[0],Ie=ne.substr(oe.index),Ue=K(z,oe,Ie);if(!Ue)return RL;const Ze=z;z.endScope&&z.endScope._wrap?(I(),ae.addKeyword(ce,z.endScope._wrap)):z.endScope&&z.endScope._multi?(I(),M(z.endScope,oe)):Ze.skip?he+=ce:(Ze.returnEnd||Ze.excludeEnd||(he+=ce),I(),Ze.excludeEnd&&(he=ce));do z.scope&&!z.isMultiClass&&ae.closeNode(),!z.skip&&!z.subLanguage&&(ft+=z.relevance),z=z.parent;while(z!==Ue.parent);return Ue.starts&&G(Ue.starts,oe),Ze.returnEnd?0:ce.length}function ct(){const oe=[];for(let ce=z;ce!==Q;ce=ce.parent)ce.scope&&oe.unshift(ce.scope);oe.forEach(ce=>ae.openNode(ce))}let St={};function Lt(oe,ce){const Ie=ce&&ce[0];if(he+=oe,Ie==null)return I(),0;if(St.type==="begin"&&ce.type==="end"&&St.index===ce.index&&Ie===""){if(he+=ne.slice(ce.index,ce.index+1),!i){const Ue=new Error(`0 width match regex (${W})`);throw Ue.languageName=W,Ue.badRule=St.rule,Ue}return 1}if(St=ce,ce.type==="begin")return le(ce);if(ce.type==="illegal"&&!H){const Ue=new Error('Illegal lexeme "'+Ie+'" for mode "'+(z.scope||"<unnamed>")+'"');throw Ue.mode=z,Ue}else if(ce.type==="end"){const Ue=we(ce);if(Ue!==RL)return Ue}if(ce.type==="illegal"&&Ie==="")return 1;if(Qe>1e5&&Qe>ce.index*3)throw new Error("potential infinite loop, way more iterations than matches");return he+=Ie,Ie.length}const Q=w(W);if(!Q)throw eo(s.replace("{}",W)),new Error('Unknown language: "'+W+'"');const de=Kq(Q);let Ee="",z=U||de;const fe={},ae=new o.__emitter(o);ct();let he="",ft=0,xe=0,Qe=0,Jt=!1;try{for(z.matcher.considerAll();;){Qe++,Jt?Jt=!1:z.matcher.considerAll(),z.matcher.lastIndex=xe;const oe=z.matcher.exec(ne);if(!oe)break;const ce=ne.substring(xe,oe.index),Ie=Lt(ce,oe);xe=oe.index+Ie}return Lt(ne.substr(xe)),ae.closeAllNodes(),ae.finalize(),
]`,`[\\[\\]\\.,\\+\\-<> \r
]`,{returnEnd:!0,relevance:0}),{className:"title",begin:"[\\[\\]]",relevance:0},{className:"string",begin:"[\\.,]",relevance:0},{begin:/(?:\+\+|--)/,contains:[n]},n]}}return sT=t,sT}var aT,XL;function N3(){if(XL)return aT;XL=1;function t(i){return i?typeof i=="string"?i:i.source:null}function e(i){return n("(?:",i,")?")}function n(...i){return i.map(a=>t(a)).join("")}function r(i){const s=i.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),a="decltype\\(auto\\)",o="[a-zA-Z_]\\w*::",l="<[^<>]+>",c="("+a+"|"+e(o)+"[a-zA-Z_]\\w*"+e(l)+")",u={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},d="\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)",_={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[i.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+d+"|.)",end:"'",illegal:"."},i.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},p={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},i.inherit(_,{className:"string"}),{className:"string",begin:/<.*?>/},s,i.C_BLOCK_COMMENT_MODE]},E={className:"title",begin:e(o)+i.IDENT_RE,relevance:0},h=e(o)+i.IDENT_RE+"\\s*\\(",T={keyword:["asm","auto","break","case","const","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","static","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal128","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},v=[f,u,s,i.C_BLOCK_COMMENT_MODE,p,_],R={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:T,contains:v.concat([{begin:/\(/,end:/\)/,keywords:T,contains:v.concat(["self"]),relevance:0}]),relevance:0},C={begin:"("+c+"[\\*&\\s]+)+"+h,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:T,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:a,keywords:T,relevance:0},{begin:h,returnBegin:!0,contains:[i.inherit(E,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:[s,i.C_BLOCK_COMMENT_MODE,_,p,u,{begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:["self",s,i.C_BLOCK_COMMENT_MODE,_,p,u]}]},u,s,i.C_BLOCK_COMMENT_MODE,f]};return{name:"C",aliases:["h"],keywords:T,disableAutodetect:!0,illegal:"</",contains:[].concat(R,C,v,[f,{begin:i.IDENT_RE+"::",keywords:T},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},i.TITLE_MODE]}]),exports:{preprocessor:f,strings:_,keywords:T}}}return aT=r
`},f]}}return Tv=i,Tv}var vv,_x;function GW(){if(_x)return vv;_x=1;function t(e){const n="[a-zA-Z_][\\w.]*",r="<\\?(lasso(script)?|=)",i="\\]|\\?>",s={$pattern:n+"|&[lg]t;",literal:"true false none minimal full all void and or not bw nbw ew new cn ncn lt lte gt gte eq neq rx nrx ft",built_in:"array date decimal duration integer map pair string tag xml null boolean bytes keyword list locale queue set stack staticarray local var variable global data self inherited currentcapture givenblock",keyword:"cache database_names database_schemanames database_tablenames define_tag define_type email_batch encode_set html_comment handle handle_error header if inline iterate ljax_target link link_currentaction link_currentgroup link_currentrecord link_detail link_firstgroup link_firstrecord link_lastgroup link_lastrecord link_nextgroup link_nextrecord link_prevgroup link_prevrecord log loop namespace_using output_none portal private protect records referer referrer repeating resultset rows search_args search_arguments select sort_args sort_arguments thread_atomic value_list while abort case else fail_if fail_ifnot fail if_empty if_false if_null if_true loop_abort loop_continue loop_count params params_up return return_value run_children soap_definetag soap_lastrequest soap_lastresponse tag_name ascending average by define descending do equals frozen group handle_failure import in into join let match max min on order parent protected provide public require returnhome skip split_thread sum take thread to trait type where with yield yieldhome"},a=e.COMMENT("<!--","-->",{relevance:0}),o={className:"meta",begin:"\\[noprocess\\]",starts:{end:"\\[/noprocess\\]",returnEnd:!0,contains:[a]}},l={className:"meta",begin:"\\[/noprocess|"+r},c={className:"symbol",begin:"'"+n+"'"},u=[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.inherit(e.C_NUMBER_MODE,{begin:e.C_NUMBER_RE+"|(-?infinity|NaN)\\b"}),e.inherit(e.APOS_STRING_MODE,{illegal:null}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null}),{className:"string",begin:"`",end:"`"},{variants:[{begin:"[#$]"+n},{begin:"#",end:"\\d+",illegal:"\\W"}]},{className:"type",begin:"::\\s*",end:n,illegal:"\\W"},{className:"params",variants:[{begin:"-(?!infinity)"+n,relevance:0},{begin:"(\\.\\.\\.)"}]},{begin:/(->|\.)\s*/,relevance:0,contains:[c]},{className:"class",beginKeywords:"define",returnEnd:!0,end:"\\(|=>",contains:[e.inherit(e.TITLE_MODE,{begin:n+"(=(?!>))?|[-+*/%](?!>)"})]}];return{name:"Lasso",aliases:["ls","lassoscript"],case_insensitive:!0,keywords:s,contains:[{className:"meta",begin:i,relevance:0,starts:{end:"\\[|"+r,returnEnd:!0,relevance:0,contains:[a]}},o,l,{className:"meta",begin:"\\[no_square_brackets",starts:{end:"\\[/no_square_brackets\\]",keywords:s,contains:[{className:"meta",begin:i,relevance:0,starts:{end:"\\[noprocess\\]|"+r,returnEnd:!0,contains:[a]}},o,l].concat(u)}},{className:"meta",begin:"\\[",relevance:0},{className:"meta",begin:"^#!",end:"lasso9$",relevance:10}].concat(u)}}return vv=t,vv}var yv,px;function $W(){if(px)return yv;px=1;function t(i){return i?typeof i=="string"?i:i.source:null}function e(i){const s=i[i.length-1];return typeof s=="object"&&s.constructor===Object?(i.splice(i.length-1,1),s):{}}function n(...i){const s=e(i);return"("+(s.capture?"":"?:")+i.map(o=>t(o)).join("|")+")"}function r(i){const s=n(...["(?:NeedsTeXFormat|RequirePackage|GetIdInfo)","Provides(?:Expl)?(?:Package|Class|File)","(?:DeclareOption|ProcessOptions)","(?:documentclass|usepackage|input|include)","makeat(?:letter|other)","ExplSyntax(?:On|Off)","(?:new|renew|provide)?command","(?:re)newenvironment","(?:New|Renew|Provide|Declare)(?:Expandable)?DocumentCommand","(?:New|Renew|Provide|Declare)DocumentEnvironment","(?:(?:e|g|x)?def|let)","(?:begin|end)","(?:part|chapter|(?:sub){0,2}section|(?:sub)?paragraph)","caption","(?:label|(?:eq|page|name)?ref|(?:paren|foot|super)?cite)","(?:alpha|beta|[Gg]amma|[Dd]elta|(?:var)?epsilon|zeta|eta|[Tt]heta|vartheta)","(?:iota|(?:var)?kappa|[Ll]ambda|mu|nu|[Xx]i|[Pp]i|varpi|(?:var)rho)","(?:[Ss]igma|varsigma|tau|[Uu]psilon|[Pp]hi|varphi|chi|[Pp]si|[Oo]mega)","(?:frac|sum
]*;`,relevance:0},{begin:"[vp][0-9]+"}]}}return xy=t,xy}var Py,IP;function eK(){if(IP)return Py;IP=1;function t(e){const n="[a-z][a-zA-Z0-9_]*",r={className:"string",begin:"\\$.{1}"},i={className:"symbol",begin:"#"+e.UNDERSCORE_IDENT_RE};return{name:"Smalltalk",aliases:["st"],keywords:["self","super","nil","true","false","thisContext"],contains:[e.COMMENT('"','"'),e.APOS_STRING_MODE,{className:"type",begin:"\\b[A-Z][A-Za-z0-9_]*",relevance:0},{begin:n+":",relevance:0},e.C_NUMBER_MODE,i,r,{begin:"\\|[ ]*"+n+"([ ]+"+n+")*[ ]*\\|",returnBegin:!0,end:/\|/,illegal:/\S/,contains:[{begin:"(\\|[ ]*)?"+n}]},{begin:"#\\(",end:"\\)",contains:[e.APOS_STRING_MODE,r,e.C_NUMBER_MODE,i]}]}}return Py=t,Py}var ky,RP;function tK(){if(RP)return ky;RP=1;function t(e){return{name:"SML (Standard ML)",aliases:["ml"],keywords:{$pattern:"[a-z_]\\w*!?",keyword:"abstype and andalso as case datatype do else end eqtype exception fn fun functor handle if in include infix infixr let local nonfix of op open orelse raise rec sharing sig signature struct structure then type val with withtype where while",built_in:"array bool char exn int list option order real ref string substring vector unit word",literal:"true false NONE SOME LESS EQUAL GREATER nil"},illegal:/\/\/|>>/,contains:[{className:"literal",begin:/\[(\|\|)?\]|\(\)/,relevance:0},e.COMMENT("\\(\\*","\\*\\)",{contains:["self"]}),{className:"symbol",begin:"'[A-Za-z_](?!')[\\w']*"},{className:"type",begin:"`[A-Z][\\w']*"},{className:"type",begin:"\\b[A-Z][\\w']*",relevance:0},{begin:"[a-z_]\\w*'[\\w']*"},e.inherit(e.APOS_STRING_MODE,{className:"string",relevance:0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null}),{className:"number",begin:"\\b(0[xX][a-fA-F0-9_]+[Lln]?|0[oO][0-7_]+[Lln]?|0[bB][01_]+[Lln]?|[0-9][0-9_]*([Lln]|(\\.[0-9_]*)?([eE][-+]?[0-9_]+)?)?)",relevance:0},{begin:/[-=]>/}]}}return ky=t,ky}var Uy,OP;function nK(){if(OP)return Uy;OP=1;function t(e){const n={className:"variable",begin:/\b_+[a-zA-Z]\w*/},r={className:"title",begin:/[a-zA-Z]\w+_fnc_\w+/},i={className:"string",variants:[{begin:'"',end:'"',contains:[{begin:'""',relevance:0}]},{begin:"'",end:"'",contains:[{begin:"''",relevance:0}]}]},s=["case","catch","default","do","else","exit","exitWith","for","forEach","from","if","private","switch","then","throw","to","try","waitUntil","while","with"],a=["blufor","civilian","configNull","controlNull","displayNull","east","endl","false","grpNull","independent","lineBreak","locationNull","nil","objNull","opfor","pi","resistance","scriptNull","sideAmbientLife","sideEmpty","sideLogic","sideUnknown","taskNull","teamMemberNull","true","west"],o=["abs","accTime","acos","action","actionIDs","actionKeys","actionKeysImages","actionKeysNames","actionKeysNamesArray","actionName","actionParams","activateAddons","activatedAddons","activateKey","add3DENConnection","add3DENEventHandler","add3DENLayer","addAction","addBackpack","addBackpackCargo","addBackpackCargoGlobal","addBackpackGlobal","addBinocularItem","addCamShake","addCuratorAddons","addCuratorCameraArea","addCuratorEditableObjects","addCuratorEditingArea","addCuratorPoints","addEditorObject","addEventHandler","addForce","addForceGeneratorRTD","addGoggles","addGroupIcon","addHandgunItem","addHeadgear","addItem","addItemCargo","addItemCargoGlobal","addItemPool","addItemToBackpack","addItemToUniform","addItemToVest","addLiveStats","addMagazine","addMagazineAmmoCargo","addMagazineCargo","addMagazineCargoGlobal","addMagazineGlobal","addMagazinePool","addMagazines","addMagazineTurret","addMenu","addMenuItem","addMissionEventHandler","addMPEventHandler","addMusicEventHandler","addonFiles","addOwnedMine","addPlayerScores","addPrimaryWeaponItem","addPublicVariableEventHandler","addRating","addResources","addScore","addScoreSide","addSecondaryWeaponItem","addSwitchableUnit","addTeamMember","addToRemainsCollector","addTorque","addUniform","addVehicle","addVest","addWaypoint","addWeapon","addWeaponCargo","addWeaponCargoGlobal","addWeaponGlobal","addWeaponItem","addWeaponPool","addWeaponTurret","addWeaponWithAttachmentsCargo","addWeaponWithAttachmentsCargoGl
]*?"'`},{begin:`"[^\r
"]*"`}]},{className:"built_in",variants:[{begin:"\\b(abs|acos|asin|atan|atan2|atanh|ceil|cloglog|comb|cos|digamma|exp|floor|invcloglog|invlogit|ln|lnfact|lnfactorial|lngamma|log|log10|max|min|mod|reldif|round|sign|sin|sqrt|sum|tan|tanh|trigamma|trunc|betaden|Binomial|binorm|binormal|chi2|chi2tail|dgammapda|dgammapdada|dgammapdadx|dgammapdx|dgammapdxdx|F|Fden|Ftail|gammaden|gammap|ibeta|invbinomial|invchi2|invchi2tail|invF|invFtail|invgammap|invibeta|invnchi2|invnFtail|invnibeta|invnorm|invnormal|invttail|nbetaden|nchi2|nFden|nFtail|nibeta|norm|normal|normalden|normd|npnchi2|tden|ttail|uniform|abbrev|char|index|indexnot|length|lower|ltrim|match|plural|proper|real|regexm|regexr|regexs|reverse|rtrim|string|strlen|strlower|strltrim|strmatch|strofreal|strpos|strproper|strreverse|strrtrim|strtrim|strupper|subinstr|subinword|substr|trim|upper|word|wordcount|_caller|autocode|byteorder|chop|clip|cond|e|epsdouble|epsfloat|group|inlist|inrange|irecode|matrix|maxbyte|maxdouble|maxfloat|maxint|maxlong|mi|minbyte|mindouble|minfloat|minint|minlong|missing|r|recode|replay|return|s|scalar|d|date|day|dow|doy|halfyear|mdy|month|quarter|week|year|d|daily|dofd|dofh|dofm|dofq|dofw|dofy|h|halfyearly|hofd|m|mofd|monthly|q|qofd|quarterly|tin|twithin|w|weekly|wofd|y|yearly|yh|ym|yofd|yq|yw|cholesky|colnumb|colsof|corr|det|diag|diag0cnt|el|get|hadamard|I|inv|invsym|issym|issymmetric|J|matmissing|matuniform|mreldif|nullmat|rownumb|rowsof|sweep|syminv|trace|vec|vecdiag)(?=\\()"}]},e.COMMENT("^[ ]*\\*.*$",!1),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]}}return Gy=t,Gy}var $y,MP;function aK(){if(MP)return $y;MP=1;function t(e){return{name:"STEP Part 21",aliases:["p21","step","stp"],case_insensitive:!0,keywords:{$pattern:"[A-Z_][A-Z0-9_.]*",keyword:["HEADER","ENDSEC","DATA"]},contains:[{className:"meta",begin:"ISO-10303-21;",relevance:10},{className:"meta",begin:"END-ISO-10303-21;",relevance:10},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.COMMENT("/\\*\\*!","\\*/"),e.C_NUMBER_MODE,e.inherit(e.APOS_STRING_MODE,{illegal:null}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null}),{className:"string",begin:"'",end:"'"},{className:"symbol",variants:[{begin:"#",end:"\\d+",illegal:"\\W"}]}]}}return $y=t,$y}var Yy,LP;function oK(){if(LP)return Yy;LP=1;const t=o=>({IMPORTANT:{scope:"meta",begin:"!important"},HEXCOLOR:{scope:"number",begin:"#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})"},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[o.APOS_STRING_MODE,o.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:o.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z][A-Za-z0-9_-]*/}}),e=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","p","q","quote","samp","section","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],n=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"],r=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-chi
(multipart)?`,end:`\\]
`},{className:"string",begin:"\\d{4}-\\d{2}-\\d{2}(\\s+)\\d{2}:\\d{2}:\\d{2}.\\d+Z"},{className:"string",begin:"(\\+|-)\\d+"},{className:"keyword",relevance:10,variants:[{begin:"^(test|testing|success|successful|failure|error|skip|xfail|uxsuccess)(:?)\\s+(test)?"},{begin:"^progress(:?)(\\s+)?(pop|push)?"},{begin:"^tags:"},{begin:"^time:"}]}]}}return zy=t,zy}var Vy,PP;function cK(){if(PP)return Vy;PP=1;function t(N){return N?typeof N=="string"?N:N.source:null}function e(N){return n("(?=",N,")")}function n(...N){return N.map(k=>t(k)).join("")}function r(N){const w=N[N.length-1];return typeof w=="object"&&w.constructor===Object?(N.splice(N.length-1,1),w):{}}function i(...N){const w=r(N);return"("+(w.capture?"":"?:")+N.map(F=>t(F)).join("|")+")"}const s=N=>n(/\b/,N,/\w$/.test(N)?/\b/:/\B/),a=["Protocol","Type"].map(s),o=["init","self"].map(s),l=["Any","Self"],c=["actor","associatedtype","async","await",/as\?/,/as!/,"as","break","case","catch","class","continue","convenience","default","defer","deinit","didSet","do","dynamic","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","lazy","let","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],u=["false","nil","true"],d=["assignment","associativity","higherThan","left","lowerThan","none","right"],_=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warn_unqualified_access","#warning"],p=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],f=i(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),E=i(f,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),h=n(f,E,"*"),m=i(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),g=i(m,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),T=n(m,g,"*"),v=n(/[A-Z]/,g,"*"),R=["autoclosure",n(/convention\(/,i("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",n(/objc\(/,T,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","testable","UIApplicationMain","unknown","usableFromInline"],C=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","
`,t.start.index);if(e!==void 0)return Xe(t,t.start.node,e,r=>({node:r,index:t.start.index+1}))}},{description:"split list item",category:"list",control:!1,alt:!1,shift:!1,key:"Enter",visible:!1,active:t=>t.list!==void 0,handler:t=>{var r,i;if(t.list===void 0)return;const e=t.list.getLastItem(),n=e==null?void 0:e.getLastCaret();if(e!==void 0&&n!==void 0&&n.node instanceof Z&&n.node.getLength()===0&&n.node===t.end.node&&n.index===t.end.index){const s=t.list.getParent(t.root);if(s instanceof Wt){const a=t.list.withoutItem(e);if(a===void 0)return;const o=s.withChildReplaced(t.list,a);if(o===void 0)return;const l=o.withItemAfter(e,a);return l===void 0?void 0:Xe(t,s,l,c=>n)}else if(s instanceof js){const a=t.list.withoutItem(e);if(a===void 0)return;const o=(r=s.withChildReplaced(t.list,a))==null?void 0:r.withBlockInsertedAfter(a,new dt(0,e));return o===void 0?void 0:Xe(t,s,o,l=>n)}}else return Xe(t,t.list,(i=t.list)==null?void 0:i.withItemSplit(t.range.start),s=>{var l;const a=(l=t.list)==null?void 0:l.getItemContaining(t.range.start);if(a===void 0)return;const o=s.getItem(a+1);if(o!==void 0)return o.getFirstCaret()})}},{description:"split paragraph",category:"paragraph",control:!1,alt:!1,shift:!1,key:"Enter",visible:!1,active:t=>t.atom===void 0&&t.blocks!==void 0,handler:t=>{var n;const e=(n=t.blocks)==null?void 0:n.withSelectionSplit(t.range);if(e!==void 0)return Xe(t,t.blocks,e.root,()=>e.range.start)}},{label:"indent",icon:YK,description:"indent list item",category:"list",control:!1,alt:!1,shift:!1,key:"Tab",visible:t=>t.list!==void 0,active:t=>t.list!==void 0,handler:t=>{var e;return Xe(t,t.blocks,(e=t.blocks)==null?void 0:e.withListsIndented(t.range,!0))}},{label:"unindent",icon:zK,description:"unindent list item",category:"list",control:!1,alt:!1,shift:!0,key:"Tab",visible:t=>t.list!==void 0,active:t=>t.list!==void 0&&t.list.isInside(t.root,Wt),handler:t=>{var e;return Xe(t,t.blocks,(e=t.blocks)==null?void 0:e.withListsIndented(t.range,!1))}},{label:"plain",icon:UK,description:"clear formatting",category:"text",control:!0,alt:!1,shift:!1,key:"0",visible:!0,active:t=>t.startIsText||t.endIsText,handler:t=>t.root.withRangeFormatted(t.range,"")},{label:"bold",icon:FK,description:"bold",category:"text",control:!0,alt:!1,shift:!1,key:"b",visible:!0,active:t=>t.startIsText||t.endIsText,handler:t=>t.root.withRangeFormatted(t.range,"*")},{description:"italic",icon:BK,category:"text",control:!0,alt:!1,shift:!1,key:"i",visible:!0,active:t=>t.startIsText||t.endIsText,handler:t=>t.root.withRangeFormatted(t.range,"_")},{label:"sub\u2099",icon:GK,description:"subscript",category:"text",control:!0,alt:!1,shift:!1,key:",",visible:!0,active:t=>t.startIsText||t.endIsText,handler:t=>t.root.withRangeFormatted(t.range,"v")},{label:"super\u207F",icon:$K,description:"superscript",category:"text",control:!0,alt:!1,shift:!1,key:".",visible:!0,active:t=>t.startIsText||t.endIsText,handler:t=>t.root.withRangeFormatted(t.range,"^")},{label:"<code>",icon:Qp,description:"toggle code",category:"annotation",control:!0,alt:!1,shift:!1,key:"j",visible:!0,active:t=>t.startIsText||t.endIsText,handler:t=>{var e;return t.meta instanceof ts?Xe(t,t.format,(e=t.format)==null?void 0:e.withSegmentReplaced(t.meta,t.meta.getText())):t.root.withSegmentAtSelection(t.range,n=>new ts(new Z(n)))}},{label:"link \u26AD",icon:ok,description:"toggle link",category:"annotation",control:!0,alt:!1,shift:!1,key:"k",visible:!0,active:t=>t.atom===void 0&&t.meta===void 0||t.meta instanceof ai,handler:t=>{var e;return t.meta instanceof ai?Xe(t,t.format,(e=t.format)==null?void 0:e.withSegmentReplaced(t.meta,t.meta.getText())):t.root.withSegmentAtSelection(t.range,n=>new ai(new Z(n)))}},{label:"Aa",description:"toggle definition",category:"annotation",control:!0,alt:!1,shift:!1,key:"d",visible:t=>t.chapter&&t.atom===void 0&&t.meta===void 0,active:t=>t.chapter&&t.atom===void 0&&t.meta===void 0,handler:t=>{var e;return t.meta instanceof es?Xe(t,t.format,(e=t.format)==null?void 0:e.withSegmentReplaced(t.meta,t.meta.getText())):t.root.withSegmentAtSelection(t.range,n=>new es(new Z(n)))}}
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Tn=typeof Symbol=="function"&&Symbol.for,Cb=Tn?Symbol.for("react.element"):60103,Nb=Tn?Symbol.for("react.portal"):60106,sm=Tn?Symbol.for("react.fragment"):60107,am=Tn?Symbol.for("react.strict_mode"):60108,om=Tn?Symbol.for("react.profiler"):60114,lm=Tn?Symbol.for("react.provider"):60109,cm=Tn?Symbol.for("react.context"):60110,Ib=Tn?Symbol.for("react.async_mode"):60111,um=Tn?Symbol.for("react.concurrent_mode"):60111,dm=Tn?Symbol.for("react.forward_ref"):60112,_m=Tn?Symbol.for("react.suspense"):60113,A5=Tn?Symbol.for("react.suspense_list"):60120,pm=Tn?Symbol.for("react.memo"):60115,mm=Tn?Symbol.for("react.lazy"):60116,w5=Tn?Symbol.for("react.block"):60121,D5=Tn?Symbol.for("react.fundamental"):60117,M5=Tn?Symbol.for("react.responder"):60118,L5=Tn?Symbol.for("react.scope"):60119;function Lr(t){if(typeof t=="object"&&t!==null){var e=t.$$typeof;switch(e){case Cb:switch(t=t.type,t){case Ib:case um:case sm:case om:case am:case _m:return t;default:switch(t=t&&t.$$typeof,t){case cm:case dm:case mm:case pm:case lm:return t;default:return e}}case Nb:return e}}}function Rk(t){return Lr(t)===um}_t.AsyncMode=Ib,_t.ConcurrentMode=um,_t.ContextConsumer=cm,_t.ContextProvider=lm,_t.Element=Cb,_t.ForwardRef=dm,_t.Fragment=sm,_t.Lazy=mm,_t.Memo=pm,_t.Portal=Nb,_t.Profiler=om,_t.StrictMode=am,_t.Suspense=_m,_t.isAsyncMode=function(t){return Rk(t)||Lr(t)===Ib},_t.isConcurrentMode=Rk,_t.isContextConsumer=function(t){return Lr(t)===cm},_t.isContextProvider=function(t){return Lr(t)===lm},_t.isElement=function(t){return typeof t=="object"&&t!==null&&t.$$typeof===Cb},_t.isForwardRef=function(t){return Lr(t)===dm},_t.isFragment=function(t){return Lr(t)===sm},_t.isLazy=function(t){return Lr(t)===mm},_t.isMemo=function(t){return Lr(t)===pm},_t.isPortal=function(t){return Lr(t)===Nb},_t.isProfiler=function(t){return Lr(t)===om},_t.isStrictMode=function(t){return Lr(t)===am},_t.isSuspense=function(t){return Lr(t)===_m},_t.isValidElementType=function(t){return typeof t=="string"||typeof t=="function"||t===sm||t===um||t===om||t===am||t===_m||t===A5||typeof t=="object"&&t!==null&&(t.$$typeof===mm||t.$$typeof===pm||t.$$typeof===lm||t.$$typeof===cm||t.$$typeof===dm||t.$$typeof===D5||t.$$typeof===M5||t.$$typeof===L5||t.$$typeof===w5)},_t.typeOf=Lr,function(t){t.exports=_t}(Ik);var Ok=Ik.exports,x5={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},P5={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Ak={};Ak[Ok.ForwardRef]=x5,Ak[Ok.Memo]=P5;var k5=!0;function wk(t,e,n){var r="";return n.split(" ").forEach(function(i){t[i]!==void 0?e.push(t[i]+";"):r+=i+" "}),r}var Rb=function(e,n,r){var i=e.key+"-"+n.name;(r===!1||k5===!1)&&e.registered[i]===void 0&&(e.registered[i]=n.styles)},Dk=function(e,n,r){Rb(e,n,r);var i=e.key+"-"+n.name;if(e.inserted[n.name]===void 0){var s=n;do e.insert(n===s?"."+i:"",s,e.sheet,!0),s=s.next;while(s!==void 0)}};function U5(t){for(var e=0,n,r=0,i=t.length;i>=4;++r,i-=4)n=t.charCodeAt(r)&255|(t.charCodeAt(++r)&255)<<8|(t.charCodeAt(++r)&255)<<16|(t.charCodeAt(++r)&255)<<24,n=(n&65535)*1540483477+((n>>>16)*59797<<16),n^=n>>>24,e=(n&65535)*1540483477+((n>>>16)*59797<<16)^(e&65535)*1540483477+((e>>>16)*59797<<16);switch(i){case 3:e^=(t.charCodeAt(r+2)&255)<<16;case 2:e^=(t.charCodeAt(r+1)&255)<<8;case 1:e^=t.charCodeAt(r)&255,e=(e&65535)*1540483477+((e>>>16)*59797<<16)}return e^=e>>>13,e=(e&65535)*1540483477+((e>>>16)*59797<<16),((e^e>>>15)>>>0).toString(36)}var F5={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zu(t,e){return J5(t)||e9(t,e)||Gk(t,e)||t9()}function xb(t){return xb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xb(t)}function Pb(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function $k(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function kb(t,e,n){return e&&$k(t.prototype,e),n&&$k(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ub(t,e){return Ub=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},Ub(t,e)}function Fb(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ub(t,e)}function _s(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n9(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Yk(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Rt(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Yk(Object(n),!0).forEach(function(r){n9(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Yk(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fm(t){return fm=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},fm(t)}function r9(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function i9(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function s9(t,e){return e&&(typeof e=="object"||typeof e=="function")?e:i9(t)}function Bb(t){var e=r9();return function(){var r=fm(t),i;if(e){var s=fm(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return s9(this,i)}}var a9=["className","clearValue","cx","getStyles","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"],hm=function(){};function o9(t,e){return e?e[0]==="-"?t+e:t+"__"+e:t}function l9(t,e,n){var r=[n];if(e&&t)for(var i in e)e.hasOwnProperty(i)&&e[i]&&r.push("".concat(o9(t,i)));return r.filter(function(s){return s}).map(function(s){return String(s).trim()}).join(" ")}var zk=function(e){return g9(e)?e.filter(Boolean):xb(e)==="object"&&e!==null?[e]:[]},Vk=function(e){e.className,e.clearValue,e.cx,e.getStyles,e.getValue,e.hasValue,e.isMulti,e.isRtl,e.options,e.selectOption,e.selectProps,e.setValue,e.theme;var n=Al(e,a9);return Rt({},n)};function Gb(t){return[document.documentElement,document.body,window].indexOf(t)>-1}function jk(t){return Gb(t)?window.pageYOffset:t.scrollTop}function gm(t,e){if(Gb(t)){window.scrollTo(0,e);return}t.scrollTop=e}function c9(t){var e=getComputedStyle(t),n=e.position==="absolute",r=/(auto|scroll)/;if(e.position==="fixed")return document.documentElement;for(var i=t;i=i.parentElement;)if(e=getComputedStyle(i),!(n&&e.position==="static")&&r.test(e.overflow+e.overflowY+e.overflowX))return i;return document.documentElement}function u9(t,e,n,r){return n*((t=t/r-1)*t*t+1)+e}function Em(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:200,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:hm,i=jk(t),s=e-i,a=
0%, 80%, 100% { opacity: 0; }
40% { opacity: 1; }
`]))),V9=function(e){var n=e.isFocused,r=e.size,i=e.theme,s=i.colors,a=i.spacing.baseUnit;return{label:"loadingIndicator",color:n?s.neutral60:s.neutral20,display:"flex",padding:a*2,transition:"color 150ms",alignSelf:"center",fontSize:r,lineHeight:1,marginRight:r,textAlign:"center",verticalAlign:"middle"}},zb=function(e){var n=e.delay,r=e.offset;return Re("span",{css:Mb({animation:"".concat(z9," 1s ease-in-out ").concat(n,"ms infinite;"),backgroundColor:"currentColor",borderRadius:"1em",display:"inline-block",marginLeft:r?"1em":void 0,height:"1em",verticalAlign:"top",width:"1em"},"","")})},r1=function(e){var n=e.className,r=e.cx,i=e.getStyles,s=e.innerProps,a=e.isRtl;return Re("div",at({css:i("loadingIndicator",e),className:r({indicator:!0,"loading-indicator":!0},n)},s),Re(zb,{delay:0,offset:a}),Re(zb,{delay:160,offset:!0}),Re(zb,{delay:320,offset:!a}))};r1.defaultProps={size:4};var j9=function(e){var n=e.isDisabled,r=e.isFocused,i=e.theme,s=i.colors,a=i.borderRadius,o=i.spacing;return{label:"control",alignItems:"center",backgroundColor:n?s.neutral5:s.neutral0,borderColor:n?s.neutral10:r?s.primary:s.neutral20,borderRadius:a,borderStyle:"solid",borderWidth:1,boxShadow:r?"0 0 0 1px ".concat(s.primary):void 0,cursor:"default",display:"flex",flexWrap:"wrap",justifyContent:"space-between",minHeight:o.controlHeight,outline:"0 !important",position:"relative",transition:"all 100ms","&:hover":{borderColor:r?s.primary:s.neutral30}}},H9=function(e){var n=e.children,r=e.cx,i=e.getStyles,s=e.className,a=e.isDisabled,o=e.isFocused,l=e.innerRef,c=e.innerProps,u=e.menuIsOpen;return Re("div",at({ref:l,css:i("control",e),className:r({control:!0,"control--is-disabled":a,"control--is-focused":o,"control--menu-is-open":u},s)},c),n)},q9=["data"],W9=function(e){var n=e.theme.spacing;return{paddingBottom:n.baseUnit*2,paddingTop:n.baseUnit*2}},Q9=function(e){var n=e.children,r=e.className,i=e.cx,s=e.getStyles,a=e.Heading,o=e.headingProps,l=e.innerProps,c=e.label,u=e.theme,d=e.selectProps;return Re("div",at({css:s("group",e),className:i({group:!0},r)},l),Re(a,at({},o,{selectProps:d,theme:u,getStyles:s,cx:i}),c),Re("div",null,n))},K9=function(e){var n=e.theme.spacing;return{label:"group",color:"#999",cursor:"default",display:"block",fontSize:"75%",fontWeight:500,marginBottom:"0.25em",paddingLeft:n.baseUnit*3,paddingRight:n.baseUnit*3,textTransform:"uppercase"}},X9=function(e){var n=e.getStyles,r=e.cx,i=e.className,s=Vk(e);s.data;var a=Al(s,q9);return Re("div",at({css:n("groupHeading",e),className:r({"group-heading":!0},i)},a))},Z9=["innerRef","isDisabled","isHidden","inputClassName"],J9=function(e){var n=e.isDisabled,r=e.value,i=e.theme,s=i.spacing,a=i.colors;return Rt({margin:s.baseUnit/2,paddingBottom:s.baseUnit/2,paddingTop:s.baseUnit/2,visibility:n?"hidden":"visible",color:a.neutral80,transform:r?"translateZ(0)":""},e6)},i1={gridArea:"1 / 2",font:"inherit",minWidth:"2px",border:0,margin:0,outline:0,padding:0},e6={flex:"1 1 auto",display:"inline-grid",gridArea:"1 / 1 / 2 / 3",gridTemplateColumns:"0 min-content","&:after":Rt({content:'attr(data-value) " "',visibility:"hidden",whiteSpace:"pre"},i1)},t6=function(e){return Rt({label:"input",color:"inherit",background:0,opacity:e?0:1,width:"100%"},i1)},n6=function(e){var n=e.className,r=e.cx,i=e.getStyles,s=e.value,a=Vk(e),o=a.innerRef,l=a.isDisabled,c=a.isHidden,u=a.inputClassName,d=Al(a,Z9);return Re("div",{className:r({"input-container":!0},n),css:i("input",e),"data-value":s||""},Re("input",at({className:r({input:!0},u),ref:o,style:t6(c),disabled:l},d)))},r6=function(e){var n=e.theme,r=n.spacing,i=n.borderRadius,s=n.colors;return{label:"multiValue",backgroundColor:s.neutral10,borderRadius:i/2,display:"flex",margin:r.baseUnit/2,minWidth:0}},i6=function(e){var n=e.theme,r=n.borderRadius,i=n.colors,s=e.cropWithEllipsis;return{borderRadius:r/2,color:i.neutral80,fontSize:"85%",overflow:"hidden",padding:3,paddingLeft:6,textOverflow:s||s===void 0?"ellipsis":void 0,whiteSpace:"nowrap"}},s6=function(e){var n=e.theme,r=n.spacing,i=n.borderRadius,s=n.colors,a=e.isFocused;return{alignItems:"center",borderRad
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function a1(t){return T6(t)||v6(t)||Gk(t)||y6()}var o1=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function b6(t,e){return!!(t===e||o1(t)&&o1(e))}function C6(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!b6(t[n],e[n]))return!1;return!0}function N6(t,e){e===void 0&&(e=C6);var n,r=[],i,s=!1;function a(){for(var o=[],l=0;l<arguments.length;l++)o[l]=arguments[l];return s&&n===this&&e(o,r)||(i=t.apply(this,o),s=!0,n=this,r=o),i}return a}for(var I6={name:"7pg0cj-a11yText",styles:"label:a11yText;z-index:9999;border:0;clip:rect(1px, 1px, 1px, 1px);height:1px;width:1px;position:absolute;overflow:hidden;padding:0;white-space:nowrap"},l1=function(e){return Re("span",at({css:I6},e))},R6={guidance:function(e){var n=e.isSearchable,r=e.isMulti,i=e.isDisabled,s=e.tabSelectsValue,a=e.context;switch(a){case"menu":return"Use Up and Down to choose options".concat(i?"":", press Enter to select the currently focused option",", press Escape to exit the menu").concat(s?", press Tab to select the option and exit the menu":"",".");case"input":return"".concat(e["aria-label"]||"Select"," is focused ").concat(n?",type to refine list":"",", press Down to open the menu, ").concat(r?" press left to focus selected values":"");case"value":return"Use left and right to toggle between focused values, press Backspace to remove the currently focused value";default:return""}},onChange:function(e){var n=e.action,r=e.label,i=r===void 0?"":r,s=e.labels,a=e.isDisabled;switch(n){case"deselect-option":case"pop-value":case"remove-value":return"option ".concat(i,", deselected.");case"clear":return"All selected options have been cleared.";case"initial-input-focus":return"option".concat(s.length>1?"s":""," ").concat(s.join(","),", selected.");case"select-option":return a?"option ".concat(i," is disabled. Select another option."):"option ".concat(i,", selected.");default:return""}},onFocus:function(e){var n=e.context,r=e.focused,i=e.options,s=e.label,a=s===void 0?"":s,o=e.selectValue,l=e.isDisabled,c=e.isSelected,u=function(f,E){return f&&f.length?"".concat(f.indexOf(E)+1," of ").concat(f.length):""};if(n==="value"&&o)return"value ".concat(a," focused, ").concat(u(o,r),".");if(n==="menu"){var d=l?" disabled":"",_="".concat(c?"selected":"focused").concat(d);return"option ".concat(a," ").concat(_,", ").concat(u(i,r),".")}return""},onFilter:function(e){var n=e.inputValue,r=e.resultsMessage;return"".concat(r).concat(n?" for search term "+n:"",".")}},O6=function(e){var n=e.ariaSelection,r=e.focusedOption,i=e.focusedValue,s=e.focusableOptions,a=e.isFocused,o=e.selectValue,l=e.selectProps,c=e.id,u=l.ariaLiveMessages,d=l.getOptionLabel,_=l.inputValue,p=l.isMulti,f=l.isOptionDisabled,E=l.isSearchable,h=l.menuIsOpen,m=l.options,g=l.screenReaderStatus,T=l.tabSelectsValue,v=l["aria-label"],R=l["aria-live"],C=A.exports.useMemo(function(){return Rt(Rt({},R6),u||{})},[u]),b=A.exports.useMemo(function(){var se="";if(n&&C.onChange){var Ce=n.option,W=n.options,ne=n.removedValue,H=n.removedValues,U=n.value,D=function(K){return Array.isArray(K)?null:K},B=ne||Ce||D(U),$=B?d(B):"",Y=W||H||void 0,I=Y?Y.map(d):[],M=Rt({isDisabled:B&&f(B,o),label:$,labels:I},n);se=C.onChange(M)}return se},[n,C,f,o,d]),N=A.exports.useMemo(function(){var se="",Ce=r||i,W=!!(r&&o&&o.includes(r));if(Ce&&C.onFocus){var ne={focused:Ce,label:d(Ce),isDisabled:f(Ce,o),isSelected:W,options:m,context:Ce===r?"menu":"value",selectValue:o};se=C.onFocus(ne)}return se},[r,i,d,f,C,m,o]),w=A.exports.useMemo(function(){var se="";if(h&&m.length&&C.onFilter){var Ce=g({count:s.length});se=C.onFilter({inputValue:_,resultsMessage:Ce})}return se},[s,_,h,C,m,g]),k=A.exports.useMemo(function(){var se="";if(C.guidance){var Ce=i?"value":h?"menu":"input";se=C.guidance({"aria-label":v,context:Ce,isDisabled:r&&f(r,o),isMulti:p,isSearchable:E,tabSelectsValue:T})}return se},[v,r,i,p,f,E,h,C,o,T]),F="".concat(N," ").concat(w," ").concat(k),X=Re(A.exports.Fragment,null,Re("span",{id:"aria-selection"},b),Re("span",{id:"aria-con
`;if(ft){try{Q.setBaseAndExtent(ae.childNodes[0],fe.start.index,he.childNodes[0],fe.end.index)}catch(ce){throw console.error(ce),Error(`Error setting caret range was set to ${ae.childNodes[0]}:${fe.start.index} - ${he.childNodes[0]}:${fe.end.index}`)}xe=Q.getRangeAt(0)}if(xe){const ce=xe.getBoundingClientRect(),Ie=ae.getBoundingClientRect(),Ue=window.getComputedStyle(ae).getPropertyValue("line-height"),Ze=Ue.endsWith("px")?parseInt(Ue.substring(0,Ue.length-2)):void 0;let Bt=ae.closest(".bookish-editor"),fi=0,hi=0;for(;Bt!=null;)window.getComputedStyle(Bt).position==="relative"&&(fi+=Bt.offsetLeft,hi+=Bt.offsetTop),Bt=Bt.parentElement;const Je=oe?Ie.left:ce.left,vs=oe&&Ze?ce.top+Ze:ce.top;de={x:Je+window.scrollX-fi,y:vs+window.scrollY-hi,height:ce.height}}}}else(Ee=document.getSelection())==null||Ee.empty();if(s(de),de){const fe=de.y,ae=fe+de.height,he=window.innerHeight,ft=(z=e.current)==null?void 0:z.querySelector(".bookish-editor-toolbar"),xe=ft?ft.clientHeight:0,Qe=de.height*5;fe<window.scrollY+Qe+xe?window.scrollTo({top:fe-Qe,behavior:"smooth"}):ae>window.scrollY+he-Qe&&window.scrollTo({top:ae-(he-Qe),behavior:"smooth"})}},[n]);function N(Q,de){const Ee=b.current;if(Q.nodeType===Node.TEXT_NODE){let z=Q.parentNode;for(;z&&!(z instanceof HTMLElement&&z.classList.contains("bookish-text"));)z=z.parentNode;if(z&&z.dataset.nodeid){const fe=Ee.getNode(parseInt(z.dataset.nodeid));if(fe instanceof Z)return{node:fe,index:Math.min(de,fe.getLength())}}}else if(Q.nodeType===Node.ELEMENT_NODE&&Q instanceof HTMLElement&&Q.dataset.nodeid){const z=Ee.getNode(parseInt(Q.dataset.nodeid));if(z instanceof dt)return{node:z.getFirstTextNode(),index:0};if(z instanceof Z)return{node:z,index:0}}}function w(){o(Date.now()),c(!1);const Q=document.getSelection();if(Q&&Q.anchorNode&&Q.anchorOffset&&Q.focusNode&&Q.focusOffset){const de=N(Q.anchorNode,Q.anchorOffset),Ee=N(Q.focusNode,Q.focusOffset);de&&Ee&&r({start:de,end:Ee})}}function k(Q){if(!(Q.node instanceof Z||Q.node instanceof ve))return;const de=document.querySelector(`[data-nodeid='${Q.node.nodeID}`);if(de===null||de.childNodes.length===0)return;const Ee=document.createRange();Ee.setStart(de.childNodes.length===0?de:de.childNodes[0],de.childNodes.length===0?0:Q.index);const z=Ee.getBoundingClientRect();if(z.left>0)return{top:z.top,left:z.left,height:z.height};const fe=de.getBoundingClientRect();return{top:fe.top,left:fe.left,height:fe.height}}function F(Q,de){if(Q.node instanceof Z||Q.node instanceof ve){const Ee=k(Q);let z=g.getAdjacentCaret(Q,de);if(z===void 0)return Q;let fe,ae;if(Ee){for(;z.node instanceof Z||z.node instanceof ve;){const he=k(z);if(he){const xe=Ee.top,Qe=he.top,Jt=ae&&fe&&Math.abs(Ee.left-ae.left)<Math.abs(Ee.left-he.left)?fe:z;if(de){if(fe&&ae&&ae.top>xe+Ee.height&&Qe>ae.top+ae.height)return fe;if(Qe>xe+Ee.height&&he.left>=Ee.left)return Jt}else{if(fe&&ae&&ae.top+ae.height<xe&&Qe+he.height<ae.top)return fe;if(Qe+he.height<xe&&he.left<=Ee.left)return Jt}}const ft=g.getAdjacentCaret(z,de);if(ft===void 0||ft.node===z.node&&ft.index===z.index)break;if(fe=z,ae=he,z=ft,z===void 0)return Q}return z}}return Q}function X(){var de;if(n===void 0||n.start.node!==n.end.node||n.start.index!==n.end.index||!(n.start.node instanceof Z))return!1;const Q=(de=n.start.node.getFormatRoot(g))==null?void 0:de.getFirstCaret();return Q!==void 0&&Q.node===n.start.node&&Q.index===n.start.index}function J(){let Q=_[f+1],de=t.ast instanceof Xo?qe.parseChapter(C.book,Q.bookdown):t.ast instanceof ue?qe.parseFormat(C.book,Q.bookdown):t.ast instanceof Yn?qe.parseEmbed(C.book,Q.bookdown):void 0;if(de===void 0||de instanceof Qt)return;T(de),t.save(de),f<_.length&&E(f+1);const Ee=UO(de,Q.range);if(Ee!==void 0)return{root:de,range:Ee}}function se(){let Q=_[f-1],de=t.ast instanceof Xo?qe.parseChapter(C.book,Q.bookdown):t.ast instanceof ue?qe.parseFormat(C.book,Q.bookdown):t.ast instanceof Yn?qe.parseEmbed(C.book,Q.bookdown):void 0;if(de===void 0)return;T(de),f>0&&E(f-1);const Ee=UO(de,Q.range);if(Ee!==void 0)return{root:de,range:Ee}}function Ce(){var fe;if(n===void 0)return;const Q=g.getNodes();let de=!1
`),m=h.map((g,T)=>q("span",{className:"python-output-line",children:[g,T<h.length-1?S("br",{}):null]},T));return q("div",{className:"bookish-python",ref:c,children:[S(pb,{inline:!1,language:"python",editable:!0,edited:_,nodeID:t.node.nodeID,children:e}),S("div",{className:"bookish-code-language",children:"python"}),q("div",{className:"bookish-python-controls",children:[S("button",{disabled:e===t.code,onClick:d,children:"\u21BB"}),S("button",{disabled:!o,onClick:f,children:"\u25B6\uFE0E"}),S("div",{className:"bookish-python-output",children:m})]})]})},gX=t=>{const{node:e}=t,n=e.getCaption(),r=e.getLanguage(),{editable:i}=A.exports.useContext(mt),s=A.exports.useRef(null);return q("div",{className:"bookish-figure "+Mu(e.getPosition()),"data-nodeid":t.node.nodeID,children:[i?S("code",{className:`bookish-code bookish-code-block language-${r}`,ref:s,children:S(Lu,{node:e.getCodeNode()})}):e.getLanguage()==="python"&&e.isExecutable()?S(hX,{node:e,code:e.getCode()}):q("div",{children:[S(pb,{editable:!1,inline:!1,language:e.getLanguage(),nodeID:e.getCodeNode().nodeID,children:e.getCode()}),e.getLanguage()!=="plaintext"?S("div",{className:"bookish-code-language",children:e.getLanguage()}):null]}),n?S("div",{className:"bookish-figure-caption",children:S(Ut,{node:n,placeholder:"caption"})}):null]})};function k1(t,e){return t instanceof ue?S(Ut,{node:t},e):S(U1,{node:t},e)}const U1=t=>{const e=t.node.getItems().map((n,r)=>n.getType()==="list"?k1(n,"item-"+r):S("li",{children:k1(n)},"item-"+r));return t.node.isNumbered()?S("ol",{"data-nodeid":t.node.nodeID,children:e}):S("ul",{"data-nodeid":t.node.nodeID,children:e})},F1=t=>{var u;const{node:e,placeholder:n}=t,r=e.getFormat(),i=e.getLevel(),s=A.exports.useContext(Hn),a=(u=s.chapter)==null?void 0:u.getAST(),o=e.getLevel()===0?void 0:"header-"+(a?a.getHeaders().indexOf(e):""),l=e.getLevel()===0?void 0:"bookish-header"+(s.highlightedID===o?" bookish-content-highlight":""),c=S(Ut,{node:r});return r===void 0?S(je,{}):i===0?S("p",{"data-nodeid":t.node.nodeID,children:S(Ut,{node:t.node.getFormat(),placeholder:n!=null?n:"\xB6"})}):i===1?S("h2",{className:l,id:o,"data-nodeid":t.node.nodeID,children:c}):i===2?S("h3",{className:l,id:o,"data-nodeid":t.node.nodeID,children:c}):S("h4",{className:l,id:o,"data-nodeid":t.node.nodeID,children:c})},EX=t=>{const{node:e}=t,n=e.getCredit(),r=e.getPosition();return q("blockquote",{className:"bookish-blockquote "+Mu(r),"data-nodeid":t.node.nodeID,children:[e.getBlocks().map((i,s)=>S(Zb,{node:i},"quote-"+s)),n?S("div",{className:"bookish-blockquote-caption",children:S("span",{children:S(Ut,{node:n,placeholder:"credit"})})}):null]})},SX=t=>S("hr",{"data-nodeid":t.node.nodeID}),TX=t=>{const{node:e}=t,n=e.getRows(),r=e.getCaption(),i=e.getPosition();return q("div",{className:"bookish-figure "+Mu(i),"data-nodeid":t.node.nodeID,children:[S("div",{className:"bookish-table",children:S("table",{children:S("tbody",{children:n.map((s,a)=>S("tr",{children:s.length===1?[S("td",{colSpan:n.reduce((o,l)=>Math.max(l.length,o),0),children:S(Ut,{node:s[0]},"cell-"+a)},"cell-"+a)]:s.map((o,l)=>S("td",{children:S(Ut,{node:o},"cell-"+l)},"cell-"+l))},"row-"+a))})})}),r===void 0?null:S("div",{className:"bookish-figure-caption",children:S(Ut,{node:r,placeholder:"caption"})})]})},Zb=t=>{const{node:e,key:n}=t;return e instanceof dt?S(F1,{node:e},n):e instanceof Wt?S(U1,{node:e},n):e instanceof Yn?S(gb,{node:e},n):e instanceof Ko?S(fX,{node:e},n):e instanceof Zo?S(EX,{node:e},n):e instanceof Ji?S(gX,{node:e},n):e instanceof Qt?S(AS,{node:e},n):e instanceof Fc?S(SX,{node:e},n):e instanceof Jo?S(TX,{node:e},n):S("p",{children:"Unknown node type"})},ro=t=>{const{node:e,placeholder:n}=t,r=e.getErrors(),i=e.getBlocks();return q("div",{className:"bookish-chapter-body","data-nodeid":t.node.nodeID,children:[r.length===0?null:S("p",{children:q("span",{className:"bookish-error",children:[r.length+" "+(r.length>1?"errors":"error")," below"]})}),i.length===1&&i[0]instanceof dt&&i[0].getFormat().isEmptyText()?S(F1,{node:i[0],placeholder:n}):e.getBlocks().map((s,a)=>S(Zb,{node:s},"block-"+a))]})},
# Header 1
## Header 2
### Header 3
This is how a sentence with _various_ *formatting* ^will^ look.
* How does it look?
* Would you change anything?
`);return S("div",{className:"bookish-theme-preview",style:{backgroundColor:e?t.theme.dark.backgroundColor:t.theme.light.backgroundColor},children:S(ro,{node:n})})},z1={light:"CSS color",dark:"CSS color",fonts:"CSS font name",sizes:"CSS font size",weights:"CSS font weights",spacing:"CSS length"},GX=t=>{const{group:e,name:n,value:r}=t,{edition:i}=A.exports.useContext(mt);return i===void 0?S("span",{children:r}):q("tr",{children:[S("td",{children:n.replace(/([a-z])([A-Z])/g,"$1 $2").split(" ").map(s=>s.charAt(0).toUpperCase()+s.substring(1)).join(" ")}),S("td",{style:{textAlign:"right"},children:S(sr,{text:r,label:`${n} editor`,placeholder:e in z1?z1[e]:"value",valid:s=>{},save:s=>i.setThemeValue(e,n,s)})})]})},Dl=t=>{const{header:e,group:n,theme:r}=t,i=r[n];return q(je,{children:[S("h2",{children:e}),S("div",{className:"bookish-table",children:S("table",{children:S("tbody",{children:Object.keys(i).sort().map((s,a)=>S(GX,{group:n,name:s,value:i[s]},a))})})})]})},$X=t=>{const{book:e}=t,n=e.getTheme();return q(fs,{children:[S(ps,{book:t.book,label:"Theme",getImage:()=>null,setImage:r=>{},header:"Theme",outline:S(ms,{previous:null,next:null})}),q(ar,{children:["This is the theme editor. You can use it to choose from existing themes or create a custom theme for your book's appearance. To use it, you'll need to know a bit about how to format CSS ",S("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/CSS/color",children:"colors"}),", ",S("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/CSS/font-size",children:"fonts"}),", and ",S("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units",children:"sizes"}),"."]}),n===null?S("button",{onClick:()=>e.setTheme(FX),children:"Customize"}):S(Nm,{commandLabel:"Revert to default",confirmLabel:"Delete your theme?",command:()=>e.setTheme(null)}),n!==null?q(je,{children:[S(BX,{theme:n}),S(Dl,{header:"Light mode colors",group:"light",theme:n}),S(Dl,{header:"Dark mode colors",group:"dark",theme:n}),S(Dl,{header:"Fonts",group:"fonts",theme:n}),S(Dl,{header:"Font sizes",group:"sizes",theme:n}),S(Dl,{header:"Font weights",group:"weights",theme:n}),S(Dl,{header:"Spacing",group:"spacing",theme:n})]}):null]})};UX.polyfill();const YX=t=>{const{edition:e}=t,n=Qo(),[,r]=Zr.useState(),i=Zr.useCallback(()=>r({}),[]),s=t.base?t.base:"";let[a,o]=A.exports.useState(localStorage.getItem("bookish-dark")!=="false"&&(localStorage.getItem("bookish-dark")==="true"||window.matchMedia("(prefers-color-scheme: dark)").matches));const l=yg();n.hash.startsWith("#/")&&l(n.hash.replace("#","")),document.title=e.getTitle();const c=()=>{a?(document.body.classList.add("bookish-dark"),localStorage.setItem("bookish-dark","true")):(document.body.classList.remove("bookish-dark"),localStorage.setItem("bookish-dark","false"))};c();function u(){i()}return A.exports.useEffect(()=>{var d;return(d=e.getBook())==null||d.addListener(u),e.addListener(u),()=>{var _;e.removeListener(u),(_=e.getBook())==null||_.removeListener(u)}},[e]),A.exports.useEffect(c,[a]),VX(e.getTheme()),S("div",{className:"bookish"+(a?" bookish-dark":""),children:S(Kb.Provider,{value:{darkMode:a,setDarkMode:o},children:S(to.Provider,{value:{base:s},children:q(mt.Provider,{value:{edition:e,editable:!!t.editable},children:[q(vG,{children:[S(Rr,{path:"/",element:S(IX,{edition:e})}),e.getChapters().map(d=>S(Rr,{path:"/"+d.getChapterID(),element:S(Jb,{chapter:d,book:e},"chapter-"+d.getChapterID())},"chapter-route-"+d.getChapterID())),e.getChapters().map(d=>S(Rr,{path:d.getChapterID()+"/:word/:number",element:S(Jb,{chapter:d,book:e},"chapter-"+d.getChapterID()+"-highlighted")},"chapter-route-"+d.getChapterID()+"-highlighted")),S(Rr,{path:"references",element:S(wX,{book:e})}),S(Rr,{path:"glossary",element:S(MX,{book:e})}),S(Rr,{path:"index",element:S(G1,{book:e})}),S(Rr,{path:"index/:letter",element:S(G1,{book:e})}),S(Rr,{path:"search",element:S(LX,{book:e})}),S(Rr,{path:"media",element:S(xX,{edition:e})}),S(Rr,{path:"theme",element:S($X,{book:e})}),S(Rr,{path:"print",elem
${Ml(t.light)}
${Ml(t.fonts)}
${Ml(t.sizes)}
${Ml(t.weights)}
${Ml(t.spacing)}
}
.bookish-dark {
${Ml(t.dark)}
}`;e.appendChild(document.createTextNode(n)),document.head.appendChild(e)}function Ml(t){return Object.keys(t).map(e=>`${"--bookish-"+e.replace(/([a-z])([A-Z])/g,"$1 $2").split(" ").map(r=>r.toLowerCase()).join("-")}: ${t[e]};`).join(`
`)}var Im={exports:{}},V1={},ci={},Ll={},Hu={},Fe={},qu={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class e{}t._CodeOrName=e,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class n extends e{constructor(m){if(super(),!t.IDENTIFIER.test(m))throw new Error("CodeGen: name must be a valid identifier");this.str=m}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=n;class r extends e{constructor(m){super(),this._items=typeof m=="string"?[m]:m}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const m=this._items[0];return m===""||m==='""'}get str(){var m;return(m=this._str)!==null&&m!==void 0?m:this._str=this._items.reduce((g,T)=>`${g}${T}`,"")}get names(){var m;return(m=this._names)!==null&&m!==void 0?m:this._names=this._items.reduce((g,T)=>(T instanceof n&&(g[T.str]=(g[T.str]||0)+1),g),{})}}t._Code=r,t.nil=new r("");function i(h,...m){const g=[h[0]];let T=0;for(;T<m.length;)o(g,m[T]),g.push(h[++T]);return new r(g)}t._=i;const s=new r("+");function a(h,...m){const g=[p(h[0])];let T=0;for(;T<m.length;)g.push(s),o(g,m[T]),g.push(s,p(h[++T]));return l(g),new r(g)}t.str=a;function o(h,m){m instanceof r?h.push(...m._items):m instanceof n?h.push(m):h.push(d(m))}t.addCodeArg=o;function l(h){let m=1;for(;m<h.length-1;){if(h[m]===s){const g=c(h[m-1],h[m+1]);if(g!==void 0){h.splice(m-1,3,g);continue}h[m++]="+"}m++}}function c(h,m){if(m==='""')return h;if(h==='""')return m;if(typeof h=="string")return m instanceof n||h[h.length-1]!=='"'?void 0:typeof m!="string"?`${h.slice(0,-1)}${m}"`:m[0]==='"'?h.slice(0,-1)+m.slice(1):void 0;if(typeof m=="string"&&m[0]==='"'&&!(h instanceof n))return`"${h}${m.slice(1)}`}function u(h,m){return m.emptyStr()?h:h.emptyStr()?m:a`${h}${m}`}t.strConcat=u;function d(h){return typeof h=="number"||typeof h=="boolean"||h===null?h:p(Array.isArray(h)?h.join(","):h)}function _(h){return new r(p(h))}t.stringify=_;function p(h){return JSON.stringify(h).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=p;function f(h){return typeof h=="string"&&t.IDENTIFIER.test(h)?new r(`.${h}`):i`[${h}]`}t.getProperty=f;function E(h){return new r(h.toString())}t.regexpCode=E})(qu);var tC={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=qu;class n extends Error{constructor(c){super(`CodeGen: "code" for ${c} not defined`),this.value=c.value}}var r;(function(l){l[l.Started=0]="Started",l[l.Completed=1]="Completed"})(r=t.UsedValueState||(t.UsedValueState={})),t.varKinds={const:new e.Name("const"),let:new e.Name("let"),var:new e.Name("var")};class i{constructor({prefixes:c,parent:u}={}){this._names={},this._prefixes=c,this._parent=u}toName(c){return c instanceof e.Name?c:this.name(c)}name(c){return new e.Name(this._newName(c))}_newName(c){const u=this._names[c]||this._nameGroup(c);return`${c}${u.index++}`}_nameGroup(c){var u,d;if(((d=(u=this._parent)===null||u===void 0?void 0:u._prefixes)===null||d===void 0?void 0:d.has(c))||this._prefixes&&!this._prefixes.has(c))throw new Error(`CodeGen: prefix "${c}" is not allowed in this scope`);return this._names[c]={prefix:c,index:0}}}t.Scope=i;class s extends e.Name{constructor(c,u){super(u),this.prefix=c}setValue(c,{property:u,itemIndex:d}){this.value=c,this.scopePath=(0,e._)`.${new e.Name(u)}[${d}]`}}t.ValueScopeName=s;const a=(0,e._)`\n`;class o extends i{constructor(c){super(c),this._values={},this._scope=c.scope,this.opts={...c,_n:c.lines?a:e.nil}}get(){return this._scope}name(c){return new s(c,this._newName(c))}value(c,u){var d;if(u.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const _=this.toName(c),{prefix:p}=_,f=(d=u.key)!==null&&d!==void 0?d:u.ref;let E=this._values[p];if(E){const g=E.get(f);if(g)return g}else E=this._values[p]=new Map;E.set(f,_);const h=this._scope[p]||(this._scope[p]=[]),m=h.length;return h[m]=u.ref,_.setValue(u,{pr
`:""},this._extScope=I,this._scope=new n.Scope({parent:I}),this._nodes=[new E]}toString(){return this._root.render(this.opts)}name(I){return this._scope.name(I)}scopeName(I){return this._extScope.name(I)}scopeValue(I,M){const G=this._extScope.value(I,M);return(this._values[G.prefix]||(this._values[G.prefix]=new Set)).add(G),G}getScopeValue(I,M){return this._extScope.getValue(I,M)}scopeRefs(I){return this._extScope.scopeRefs(I,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(I,M,G,K){const re=this._scope.toName(M);return G!==void 0&&K&&(this._constants[re.str]=G),this._leafNode(new a(I,re,G)),re}const(I,M,G){return this._def(n.varKinds.const,I,M,G)}let(I,M,G){return this._def(n.varKinds.let,I,M,G)}var(I,M,G){return this._def(n.varKinds.var,I,M,G)}assign(I,M,G){return this._leafNode(new o(I,M,G))}add(I,M){return this._leafNode(new l(I,t.operators.ADD,M))}code(I){return typeof I=="function"?I():I!==e.nil&&this._leafNode(new _(I)),this}object(...I){const M=["{"];for(const[G,K]of I)M.length>1&&M.push(","),M.push(G),(G!==K||this.opts.es5)&&(M.push(":"),(0,e.addCodeArg)(M,K));return M.push("}"),new e._Code(M)}if(I,M,G){if(this._blockNode(new m(I)),M&&G)this.code(M).else().code(G).endIf();else if(M)this.code(M).endIf();else if(G)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(I){return this._elseNode(new m(I))}else(){return this._elseNode(new h)}endIf(){return this._endBlockNode(m,h)}_for(I,M){return this._blockNode(I),M&&this.code(M).endFor(),this}for(I,M){return this._for(new T(I),M)}forRange(I,M,G,K,re=this.opts.es5?n.varKinds.var:n.varKinds.let){const le=this._scope.toName(I);return this._for(new v(re,le,M,G),()=>K(le))}forOf(I,M,G,K=n.varKinds.const){const re=this._scope.toName(I);if(this.opts.es5){const le=M instanceof e.Name?M:this.var("_arr",M);return this.forRange("_i",0,(0,e._)`${le}.length`,we=>{this.var(re,(0,e._)`${le}[${we}]`),G(re)})}return this._for(new R("of",K,re,M),()=>G(re))}forIn(I,M,G,K=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(I,(0,e._)`Object.keys(${M})`,G);const re=this._scope.toName(I);return this._for(new R("in",K,re,M),()=>G(re))}endFor(){return this._endBlockNode(g)}label(I){return this._leafNode(new c(I))}break(I){return this._leafNode(new u(I))}return(I){const M=new b;if(this._blockNode(M),this.code(I),M.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(b)}try(I,M,G){if(!M&&!G)throw new Error('CodeGen: "try" without "catch" and "finally"');const K=new N;if(this._blockNode(K),this.code(I),M){const re=this.name("e");this._currNode=K.catch=new w(re),M(re)}return G&&(this._currNode=K.finally=new k,this.code(G)),this._endBlockNode(w,k)}throw(I){return this._leafNode(new d(I))}block(I,M){return this._blockStarts.push(this._nodes.length),I&&this.code(I).endBlock(M),this}endBlock(I){const M=this._blockStarts.pop();if(M===void 0)throw new Error("CodeGen: not in self-balancing block");const G=this._nodes.length-M;if(G<0||I!==void 0&&G!==I)throw new Error(`CodeGen: wrong number of nodes: ${G} vs ${I} expected`);return this._nodes.length=M,this}func(I,M=e.nil,G,K){return this._blockNode(new C(I,M,G)),K&&this.code(K).endFunc(),this}endFunc(){return this._endBlockNode(C)}optimize(I=1){for(;I-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(I){return this._currNode.nodes.push(I),this}_blockNode(I){this._currNode.nodes.push(I),this._nodes.push(I)}_endBlockNode(I,M){const G=this._currNode;if(G instanceof I||M&&G instanceof M)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${M?`${I.kind}/${M.kind}`:I.kind}"`)}_elseNode(I){const M=this._currNode;if(!(M instanceof m))throw new Error('CodeGen: "else" without "if"');return this._currNode=M.else=I,this}get _root(){return this._nodes[0]}get _currNode(){const I=this._nodes;return I[I.length-1]}set _currNode(I){const M=this._nodes;M[M.length-1]=I}}t.CodeGen=F;function X(Y,I){for(const M in I)Y[M]=(Y[M]||0)+(I[M]||0);return Y}function J(Y,I){r
|| (${w} == "string" && ${b} && ${b} == +${b})`).assign(k,(0,i._)`+${b}`);return;case"integer":C.elseIf((0,i._)`${w} === "boolean" || ${b} === null
|| (${w} === "string" && ${b} && ${b} == +${b} && !(${b} % 1))`).assign(k,(0,i._)`+${b}`);return;case"boolean":C.elseIf((0,i._)`${b} === "false" || ${b} === 0 || ${b} === null`).assign(k,!1).elseIf((0,i._)`${b} === "true" || ${b} === 1`).assign(k,!0);return;case"null":C.elseIf((0,i._)`${b} === "" || ${b} === 0 || ${b} === false`),C.assign(k,null);return;case"array":C.elseIf((0,i._)`${w} === "string" || ${w} === "number"
|| ${w} === "boolean" || ${b} === null`).assign(k,(0,i._)`[${b}]`)}}}function p({gen:T,parentData:v,parentDataProperty:R},C){T.if((0,i._)`${v} !== undefined`,()=>T.assign((0,i._)`${v}[${R}]`,C))}function f(T,v,R,C=a.Correct){const b=C===a.Correct?i.operators.EQ:i.operators.NEQ;let N;switch(T){case"null":return(0,i._)`${v} ${b} null`;case"array":N=(0,i._)`Array.isArray(${v})`;break;case"object":N=(0,i._)`${v} && typeof ${v} == "object" && !Array.isArray(${v})`;break;case"integer":N=w((0,i._)`!(${v} % 1) && !isNaN(${v})`);break;case"number":N=w();break;default:return(0,i._)`typeof ${v} ${b} ${T}`}return C===a.Correct?N:(0,i.not)(N);function w(k=i.nil){return(0,i.and)((0,i._)`typeof ${v} == "number"`,k,R?(0,i._)`isFinite(${v})`:i.nil)}}t.checkDataType=f;function E(T,v,R,C){if(T.length===1)return f(T[0],v,R,C);let b;const N=(0,s.toHash)(T);if(N.array&&N.object){const w=(0,i._)`typeof ${v} != "object"`;b=N.null?w:(0,i._)`!${v} || ${w}`,delete N.null,delete N.array,delete N.object}else b=i.nil;N.number&&delete N.integer;for(const w in N)b=(0,i.and)(b,f(w,v,R,C));return b}t.checkDataTypes=E;const h={message:({schema:T})=>`must be ${T}`,params:({schema:T,schemaValue:v})=>typeof T=="string"?(0,i._)`{type: ${T}}`:(0,i._)`{type: ${v}}`};function m(T){const v=g(T);(0,r.reportError)(v,h)}t.reportTypeError=m;function g(T){const{gen:v,data:R,schema:C}=T,b=(0,s.schemaRefOrVal)(T,C,"type");return{gen:v,keyword:"type",data:R,schema:C.type,schemaCode:b,schemaValue:b,parentSchema:C,params:{},it:T}}}(Wu);var Rm={};Object.defineProperty(Rm,"__esModule",{value:!0}),Rm.assignDefaults=void 0;const xl=Fe,r8=tt;function i8(t,e){const{properties:n,items:r}=t.schema;if(e==="object"&&n)for(const i in n)W1(t,i,n[i].default);else e==="array"&&Array.isArray(r)&&r.forEach((i,s)=>W1(t,s,i.default))}Rm.assignDefaults=i8;function W1(t,e,n){const{gen:r,compositeRule:i,data:s,opts:a}=t;if(n===void 0)return;const o=(0,xl._)`${s}${(0,xl.getProperty)(e)}`;if(i){(0,r8.checkStrictMode)(t,`default is ignored for: ${o}`);return}let l=(0,xl._)`${o} === undefined`;a.useDefaults==="empty"&&(l=(0,xl._)`${l} || ${o} === null || ${o} === ""`),r.if(l,(0,xl._)`${o} = ${(0,xl.stringify)(n)}`)}var Fi={},$e={};Object.defineProperty($e,"__esModule",{value:!0}),$e.validateUnion=$e.validateArray=$e.usePattern=$e.callValidateCode=$e.schemaProperties=$e.allSchemaProperties=$e.noPropertyInData=$e.propertyInData=$e.isOwnProperty=$e.hasPropFunc=$e.reportMissingProp=$e.checkMissingProp=$e.checkReportMissingProp=void 0;const Ot=Fe,nC=tt,_a=Ui,s8=tt;function a8(t,e){const{gen:n,data:r,it:i}=t;n.if(iC(n,r,e,i.opts.ownProperties),()=>{t.setParams({missingProperty:(0,Ot._)`${e}`},!0),t.error()})}$e.checkReportMissingProp=a8;function o8({gen:t,data:e,it:{opts:n}},r,i){return(0,Ot.or)(...r.map(s=>(0,Ot.and)(iC(t,e,s,n.ownProperties),(0,Ot._)`${i} = ${s}`)))}$e.checkMissingProp=o8;function l8(t,e){t.setParams({missingProperty:e},!0),t.error()}$e.reportMissingProp=l8;function Q1(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Ot._)`Object.prototype.hasOwnProperty`})}$e.hasPropFunc=Q1;function rC(t,e,n){return(0,Ot._)`${Q1(t)}.call(${e}, ${n})`}$e.isOwnProperty=rC;function c8(t,e,n,r){const i=(0,Ot._)`${e}${(0,Ot.getProperty)(n)} !== undefined`;return r?(0,Ot._)`${i} && ${rC(t,e,n)}`:i}$e.propertyInData=c8;function iC(t,e,n,r){const i=(0,Ot._)`${e}${(0,Ot.getProperty)(n)} === undefined`;return r?(0,Ot.or)(i,(0,Ot.not)(rC(t,e,n))):i}$e.noPropertyInData=iC;function K1(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}$e.allSchemaProperties=K1;function u8(t,e){return K1(e).filter(n=>!(0,nC.alwaysValidSchema)(t,e[n]))}$e.schemaProperties=u8;function d8({schemaCode:t,data:e,it:{gen:n,topSchemaRef:r,schemaPath:i,errorPath:s},it:a},o,l,c){const u=c?(0,Ot._)`${t}, ${e}, ${r}${i}`:e,d=[[_a.default.instancePath,(0,Ot.strConcat)(_a.default.instancePath,s)],[_a.default.parentData,a.parentData],[_a.default.parentDataProperty,a.parentDataProperty],[_a.default.rootData,_a.default.rootData]];a.opts.dynamicRef&&d.push([_a.default.dynamicAnchors,_a.default.dynamicA
missingProperty: ${d},
depsCount: ${c},
deps: ${u}}`};const i={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(l){const[c,u]=s(l);a(l,c),o(l,u)}};function s({schema:l}){const c={},u={};for(const d in l){if(d==="__proto__")continue;const _=Array.isArray(l[d])?c:u;_[d]=l[d]}return[c,u]}function a(l,c=l.schema){const{gen:u,data:d,it:_}=l;if(Object.keys(c).length===0)return;const p=u.let("missing");for(const f in c){const E=c[f];if(E.length===0)continue;const h=(0,r.propertyInData)(u,d,f,_.opts.ownProperties);l.setParams({property:f,depsCount:E.length,deps:E.join(", ")}),_.allErrors?u.if(h,()=>{for(const m of E)(0,r.checkReportMissingProp)(l,m)}):(u.if((0,e._)`${h} && (${(0,r.checkMissingProp)(l,E,p)})`),(0,r.reportMissingProp)(l,p),u.else())}}t.validatePropertyDeps=a;function o(l,c=l.schema){const{gen:u,data:d,keyword:_,it:p}=l,f=u.name("valid");for(const E in c)(0,n.alwaysValidSchema)(p,c[E])||(u.if((0,r.propertyInData)(u,d,E,p.opts.ownProperties),()=>{const h=l.subschema({keyword:_,schemaProp:E},f);l.mergeValidEvaluated(h,f)},()=>u.var(f,!0)),l.ok(f))}t.validateSchemaDeps=o,t.default=i})(DU);var xC={};Object.defineProperty(xC,"__esModule",{value:!0});const MU=Fe,d7=tt,_7={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:t})=>(0,MU._)`{propertyName: ${t.propertyName}}`},code(t){const{gen:e,schema:n,data:r,it:i}=t;if((0,d7.alwaysValidSchema)(i,n))return;const s=e.name("valid");e.forIn("key",r,a=>{t.setParams({propertyName:a}),t.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:!0},s),e.if((0,MU.not)(s),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(s)}};xC.default=_7;var zm={};Object.defineProperty(zm,"__esModule",{value:!0});const Vm=$e,_i=Fe,p7=Ui,jm=tt,m7={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:t})=>(0,_i._)`{additionalProperty: ${t.additionalProperty}}`},code(t){const{gen:e,schema:n,parentSchema:r,data:i,errsCount:s,it:a}=t;if(!s)throw new Error("ajv implementation error");const{allErrors:o,opts:l}=a;if(a.props=!0,l.removeAdditional!=="all"&&(0,jm.alwaysValidSchema)(a,n))return;const c=(0,Vm.allSchemaProperties)(r.properties),u=(0,Vm.allSchemaProperties)(r.patternProperties);d(),t.ok((0,_i._)`${s} === ${p7.default.errors}`);function d(){e.forIn("key",i,h=>{!c.length&&!u.length?f(h):e.if(_(h),()=>f(h))})}function _(h){let m;if(c.length>8){const g=(0,jm.schemaRefOrVal)(a,r.properties,"properties");m=(0,Vm.isOwnProperty)(e,g,h)}else c.length?m=(0,_i.or)(...c.map(g=>(0,_i._)`${h} === ${g}`)):m=_i.nil;return u.length&&(m=(0,_i.or)(m,...u.map(g=>(0,_i._)`${(0,Vm.usePattern)(t,g)}.test(${h})`))),(0,_i.not)(m)}function p(h){e.code((0,_i._)`delete ${i}[${h}]`)}function f(h){if(l.removeAdditional==="all"||l.removeAdditional&&n===!1){p(h);return}if(n===!1){t.setParams({additionalProperty:h}),t.error(),o||e.break();return}if(typeof n=="object"&&!(0,jm.alwaysValidSchema)(a,n)){const m=e.name("valid");l.removeAdditional==="failing"?(E(h,m,!1),e.if((0,_i.not)(m),()=>{t.reset(),p(h)})):(E(h,m),o||e.if((0,_i.not)(m),()=>e.break()))}}function E(h,m,g){const T={keyword:"additionalProperties",dataProp:h,dataPropType:jm.Type.Str};g===!1&&Object.assign(T,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(T,m)}}};zm.default=m7;var PC={};Object.defineProperty(PC,"__esModule",{value:!0});const f7=ci,LU=$e,kC=tt,xU=zm,h7={keyword:"properties",type:"object",schemaType:"object",code(t){const{gen:e,schema:n,parentSchema:r,data:i,it:s}=t;s.opts.removeAdditional==="all"&&r.additionalProperties===void 0&&xU.default.code(new f7.KeywordCxt(s,xU.default,"additionalProperties"));const a=(0,LU.allSchemaProperties)(n);for(const d of a)s.definedProperties.add(d);s.opts.unevaluated&&a.length&&s.props!==!0&&(s.props=kC.mergeEvaluated.props(e,(0,kC.toHash)(a),s.props));const o=a.filter(d=>!(0,kC.alwaysValidSchema)(s,n[d]));if(o.length===0)return;const l=e.name("valid");for(const d of o)c(d)?u(d)
`):"."));return e=n,Promise.all(e.chapters.filter(i=>!i.forthcoming).map(i=>fetch(t+"chapters/"+i.id+".md").then(s=>{if(s.ok)return s.text();throw Error("Unable to load chapter named '"+i.id+"'. Make sure the chapter ID and chapter file name match.")}).then(s=>{i.text=s}).catch(()=>{i.text=void 0})))}).then(()=>new ZH(void 0,void 0,e))}const pee="",VU=document.createElement("div");document.body.appendChild(VU);const QC=Eo.createRoot(VU);QC.render(S(P1,{}));let jU=new URL(document.baseURI).pathname;rJ(jU).then(t=>{QC.render(S(QG,{basename:jU,children:S(YX,{edition:t})}))}).catch(t=>{console.error(t),QC.render(q("div",{children:[S("h1",{children:"Oh noes."}),S("p",{className:"bookish-error",children:"Unable to load the book. Here's the potentially cryptic reason:"}),S("code",{children:""+t})]}))})})();