(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function Wx(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var vv={exports:{}},Bu={},_v={exports:{}},pe={};/** * @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 cl=Symbol.for("react.element"),qx=Symbol.for("react.portal"),Hx=Symbol.for("react.fragment"),Gx=Symbol.for("react.strict_mode"),Kx=Symbol.for("react.profiler"),Qx=Symbol.for("react.provider"),Yx=Symbol.for("react.context"),Xx=Symbol.for("react.forward_ref"),Jx=Symbol.for("react.suspense"),Zx=Symbol.for("react.memo"),eE=Symbol.for("react.lazy"),Nm=Symbol.iterator;function tE(t){return t===null||typeof t!="object"?null:(t=Nm&&t[Nm]||t["@@iterator"],typeof t=="function"?t:null)}var wv={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},xv=Object.assign,Ev={};function To(t,e,n){this.props=t,this.context=e,this.refs=Ev,this.updater=n||wv}To.prototype.isReactComponent={};To.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")};To.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function kv(){}kv.prototype=To.prototype;function Uf(t,e,n){this.props=t,this.context=e,this.refs=Ev,this.updater=n||wv}var zf=Uf.prototype=new kv;zf.constructor=Uf;xv(zf,To.prototype);zf.isPureReactComponent=!0;var Pm=Array.isArray,Tv=Object.prototype.hasOwnProperty,Bf={current:null},Sv={key:!0,ref:!0,__self:!0,__source:!0};function Iv(t,e,n){var r,s={},i=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(i=""+e.key),e)Tv.call(e,r)&&!Sv.hasOwnProperty(r)&&(s[r]=e[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1>>1,Ee=Q[Ce];if(0>>1;Ces(yt,re))Les(Vt,yt)?(Q[Ce]=Vt,Q[Le]=re,Ce=Le):(Q[Ce]=yt,Q[We]=re,Ce=We);else if(Les(Vt,re))Q[Ce]=Vt,Q[Le]=re,Ce=Le;else break e}}return se}function s(Q,se){var re=Q.sortIndex-se.sortIndex;return re!==0?re:Q.id-se.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],h=[],m=1,v=null,g=3,N=!1,L=!1,O=!1,z=typeof setTimeout=="function"?setTimeout:null,I=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function b(Q){for(var se=n(h);se!==null;){if(se.callback===null)r(h);else if(se.startTime<=Q)r(h),se.sortIndex=se.expirationTime,e(c,se);else break;se=n(h)}}function F(Q){if(O=!1,b(Q),!L)if(n(c)!==null)L=!0,Ot(K);else{var se=n(h);se!==null&&Mt(F,se.startTime-Q)}}function K(Q,se){L=!1,O&&(O=!1,I(_),_=-1),N=!0;var re=g;try{for(b(se),v=n(c);v!==null&&(!(v.expirationTime>se)||Q&&!A());){var Ce=v.callback;if(typeof Ce=="function"){v.callback=null,g=v.priorityLevel;var Ee=Ce(v.expirationTime<=se);se=t.unstable_now(),typeof Ee=="function"?v.callback=Ee:v===n(c)&&r(c),b(se)}else r(c);v=n(c)}if(v!==null)var be=!0;else{var We=n(h);We!==null&&Mt(F,We.startTime-se),be=!1}return be}finally{v=null,g=re,N=!1}}var H=!1,k=null,_=-1,w=5,S=-1;function A(){return!(t.unstable_now()-SQ||125Ce?(Q.sortIndex=re,e(h,Q),n(c)===null&&Q===n(h)&&(O?(I(_),_=-1):O=!0,Mt(F,re-Ce))):(Q.sortIndex=Ee,e(c,Q),L||N||(L=!0,Ot(K))),Q},t.unstable_shouldYield=A,t.unstable_wrapCallback=function(Q){var se=g;return function(){var re=g;g=se;try{return Q.apply(this,arguments)}finally{g=re}}}})(Pv);Nv.exports=Pv;var fE=Nv.exports;/** * @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 pE=G,Jt=fE;function q(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),kh=Object.prototype.hasOwnProperty,mE=/^[: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]*$/,Dm={},jm={};function gE(t){return kh.call(jm,t)?!0:kh.call(Dm,t)?!1:mE.test(t)?jm[t]=!0:(Dm[t]=!0,!1)}function yE(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 vE(t,e,n,r){if(e===null||typeof e>"u"||yE(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 Lt(t,e,n,r,s,i,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=i,this.removeEmptyString=o}var mt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){mt[t]=new Lt(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];mt[e]=new Lt(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){mt[t]=new Lt(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){mt[t]=new Lt(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){mt[t]=new Lt(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){mt[t]=new Lt(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){mt[t]=new Lt(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){mt[t]=new Lt(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){mt[t]=new Lt(t,5,!1,t.toLowerCase(),null,!1,!1)});var Wf=/[\-:]([a-z])/g;function qf(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-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Wf,qf);mt[e]=new Lt(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Wf,qf);mt[e]=new Lt(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Wf,qf);mt[e]=new Lt(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){mt[t]=new Lt(t,1,!1,t.toLowerCase(),null,!1,!1)});mt.xlinkHref=new Lt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){mt[t]=new Lt(t,1,!1,t.toLowerCase(),null,!0,!0)});function Hf(t,e,n,r){var s=mt.hasOwnProperty(e)?mt[e]:null;(s!==null?s.type!==0:r||!(2l||s[o]!==i[l]){var c=` `+s[o].replace(" at new "," at ");return t.displayName&&c.includes("")&&(c=c.replace("",t.displayName)),c}while(1<=o&&0<=l);break}}}finally{Od=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?fa(t):""}function _E(t){switch(t.tag){case 5:return fa(t.type);case 16:return fa("Lazy");case 13:return fa("Suspense");case 19:return fa("SuspenseList");case 0:case 2:case 15:return t=Md(t.type,!1),t;case 11:return t=Md(t.type.render,!1),t;case 1:return t=Md(t.type,!0),t;default:return""}}function Ch(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 Ui:return"Fragment";case Fi:return"Portal";case Th:return"Profiler";case Gf:return"StrictMode";case Sh:return"Suspense";case Ih:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case jv:return(t.displayName||"Context")+".Consumer";case Dv:return(t._context.displayName||"Context")+".Provider";case Kf:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Qf:return e=t.displayName||null,e!==null?e:Ch(t.type)||"Memo";case Mr:e=t._payload,t=t._init;try{return Ch(t(e))}catch{}}return null}function wE(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 Ch(e);case 8:return e===Gf?"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 os(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Ov(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function xE(t){var e=Ov(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 s=n.get,i=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return s.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function ac(t){t._valueTracker||(t._valueTracker=xE(t))}function Mv(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=Ov(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function Zc(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 bh(t,e){var n=e.checked;return ze({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Om(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=os(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 Vv(t,e){e=e.checked,e!=null&&Hf(t,"checked",e,!1)}function Ah(t,e){Vv(t,e);var n=os(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")?Nh(t,e.type,n):e.hasOwnProperty("defaultValue")&&Nh(t,e.type,os(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Mm(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Nh(t,e,n){(e!=="number"||Zc(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var pa=Array.isArray;function Ji(t,e,n,r){if(t=t.options,e){e={};for(var s=0;s"+e.valueOf().toString()+"",e=lc.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Va(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var ka={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},EE=["Webkit","ms","Moz","O"];Object.keys(ka).forEach(function(t){EE.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),ka[e]=ka[t]})});function Bv(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||ka.hasOwnProperty(t)&&ka[t]?(""+e).trim():e+"px"}function $v(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=Bv(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,s):t[n]=s}}var kE=ze({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Dh(t,e){if(e){if(kE[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(q(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(q(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(q(61))}if(e.style!=null&&typeof e.style!="object")throw Error(q(62))}}function jh(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Lh=null;function Yf(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Oh=null,Zi=null,eo=null;function Um(t){if(t=hl(t)){if(typeof Oh!="function")throw Error(q(280));var e=t.stateNode;e&&(e=Gu(e),Oh(t.stateNode,t.type,e))}}function Wv(t){Zi?eo?eo.push(t):eo=[t]:Zi=t}function qv(){if(Zi){var t=Zi,e=eo;if(eo=Zi=null,Um(t),e)for(t=0;t>>=0,t===0?32:31-(jE(t)/LE|0)|0}var cc=64,uc=4194304;function ma(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function ru(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,s=t.suspendedLanes,i=t.pingedLanes,o=n&268435455;if(o!==0){var l=o&~s;l!==0?r=ma(l):(i&=o,i!==0&&(r=ma(i)))}else o=n&~s,o!==0?r=ma(o):i!==0&&(r=ma(i));if(r===0)return 0;if(e!==0&&e!==r&&!(e&s)&&(s=r&-r,i=e&-e,s>=i||s===16&&(i&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function ul(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-wn(e),t[e]=n}function FE(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=Sa),Qm=" ",Ym=!1;function d0(t,e){switch(t){case"keyup":return fk.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function h0(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var zi=!1;function mk(t,e){switch(t){case"compositionend":return h0(e);case"keypress":return e.which!==32?null:(Ym=!0,Qm);case"textInput":return t=e.data,t===Qm&&Ym?null:t;default:return null}}function gk(t,e){if(zi)return t==="compositionend"||!sp&&d0(t,e)?(t=c0(),Lc=tp=qr=null,zi=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=eg(n)}}function g0(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?g0(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function y0(){for(var t=window,e=Zc();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=Zc(t.document)}return e}function ip(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function Sk(t){var e=y0(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&g0(n.ownerDocument.documentElement,n)){if(r!==null&&ip(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!t.extend&&i>r&&(s=r,r=i,i=s),s=tg(n,i);var o=tg(n,r);s&&o&&(t.rangeCount!==1||t.anchorNode!==s.node||t.anchorOffset!==s.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(s.node,s.offset),t.removeAllRanges(),i>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Bi=null,Bh=null,Ca=null,$h=!1;function ng(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;$h||Bi==null||Bi!==Zc(r)||(r=Bi,"selectionStart"in r&&ip(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Ca&&Wa(Ca,r)||(Ca=r,r=ou(Bh,"onSelect"),0qi||(t.current=Qh[qi],Qh[qi]=null,qi--)}function Ne(t,e){qi++,Qh[qi]=t.current,t.current=e}var as={},Ct=hs(as),Wt=hs(!1),Gs=as;function co(t,e){var n=t.type.contextTypes;if(!n)return as;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=e[i];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=s),s}function qt(t){return t=t.childContextTypes,t!=null}function lu(){je(Wt),je(Ct)}function cg(t,e,n){if(Ct.current!==as)throw Error(q(168));Ne(Ct,e),Ne(Wt,n)}function I0(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in e))throw Error(q(108,wE(t)||"Unknown",s));return ze({},n,r)}function cu(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||as,Gs=Ct.current,Ne(Ct,t),Ne(Wt,Wt.current),!0}function ug(t,e,n){var r=t.stateNode;if(!r)throw Error(q(169));n?(t=I0(t,e,Gs),r.__reactInternalMemoizedMergedChildContext=t,je(Wt),je(Ct),Ne(Ct,t)):je(Wt),Ne(Wt,n)}var Xn=null,Ku=!1,Xd=!1;function C0(t){Xn===null?Xn=[t]:Xn.push(t)}function Mk(t){Ku=!0,C0(t)}function fs(){if(!Xd&&Xn!==null){Xd=!0;var t=0,e=ke;try{var n=Xn;for(ke=1;t>=o,s-=o,Jn=1<<32-wn(e)+s|n<_?(w=k,k=null):w=k.sibling;var S=g(I,k,b[_],F);if(S===null){k===null&&(k=w);break}t&&k&&S.alternate===null&&e(I,k),x=i(S,x,_),H===null?K=S:H.sibling=S,H=S,k=w}if(_===b.length)return n(I,k),Me&&Ms(I,_),K;if(k===null){for(;__?(w=k,k=null):w=k.sibling;var A=g(I,k,S.value,F);if(A===null){k===null&&(k=w);break}t&&k&&A.alternate===null&&e(I,k),x=i(A,x,_),H===null?K=A:H.sibling=A,H=A,k=w}if(S.done)return n(I,k),Me&&Ms(I,_),K;if(k===null){for(;!S.done;_++,S=b.next())S=v(I,S.value,F),S!==null&&(x=i(S,x,_),H===null?K=S:H.sibling=S,H=S);return Me&&Ms(I,_),K}for(k=r(I,k);!S.done;_++,S=b.next())S=N(k,I,_,S.value,F),S!==null&&(t&&S.alternate!==null&&k.delete(S.key===null?_:S.key),x=i(S,x,_),H===null?K=S:H.sibling=S,H=S);return t&&k.forEach(function(R){return e(I,R)}),Me&&Ms(I,_),K}function z(I,x,b,F){if(typeof b=="object"&&b!==null&&b.type===Ui&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case oc:e:{for(var K=b.key,H=x;H!==null;){if(H.key===K){if(K=b.type,K===Ui){if(H.tag===7){n(I,H.sibling),x=s(H,b.props.children),x.return=I,I=x;break e}}else if(H.elementType===K||typeof K=="object"&&K!==null&&K.$$typeof===Mr&&fg(K)===H.type){n(I,H.sibling),x=s(H,b.props),x.ref=na(I,H,b),x.return=I,I=x;break e}n(I,H);break}else e(I,H);H=H.sibling}b.type===Ui?(x=qs(b.props.children,I.mode,F,b.key),x.return=I,I=x):(F=$c(b.type,b.key,b.props,null,I.mode,F),F.ref=na(I,x,b),F.return=I,I=F)}return o(I);case Fi:e:{for(H=b.key;x!==null;){if(x.key===H)if(x.tag===4&&x.stateNode.containerInfo===b.containerInfo&&x.stateNode.implementation===b.implementation){n(I,x.sibling),x=s(x,b.children||[]),x.return=I,I=x;break e}else{n(I,x);break}else e(I,x);x=x.sibling}x=ih(b,I.mode,F),x.return=I,I=x}return o(I);case Mr:return H=b._init,z(I,x,H(b._payload),F)}if(pa(b))return L(I,x,b,F);if(Xo(b))return O(I,x,b,F);yc(I,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,x!==null&&x.tag===6?(n(I,x.sibling),x=s(x,b),x.return=I,I=x):(n(I,x),x=sh(b,I.mode,F),x.return=I,I=x),o(I)):n(I,x)}return z}var ho=P0(!0),R0=P0(!1),hu=hs(null),fu=null,Ki=null,cp=null;function up(){cp=Ki=fu=null}function dp(t){var e=hu.current;je(hu),t._currentValue=e}function Jh(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function no(t,e){fu=t,cp=Ki=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&($t=!0),t.firstContext=null)}function cn(t){var e=t._currentValue;if(cp!==t)if(t={context:t,memoizedValue:e,next:null},Ki===null){if(fu===null)throw Error(q(308));Ki=t,fu.dependencies={lanes:0,firstContext:t}}else Ki=Ki.next=t;return e}var zs=null;function hp(t){zs===null?zs=[t]:zs.push(t)}function D0(t,e,n,r){var s=e.interleaved;return s===null?(n.next=n,hp(e)):(n.next=s.next,s.next=n),e.interleaved=n,lr(t,r)}function lr(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var Vr=!1;function fp(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function j0(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function rr(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function Jr(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,_e&2){var s=r.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),r.pending=e,lr(t,n)}return s=r.interleaved,s===null?(e.next=e,hp(r)):(e.next=s.next,s.next=e),r.interleaved=e,lr(t,n)}function Mc(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Jf(t,n)}}function pg(t,e){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=o:i=i.next=o,n=n.next}while(n!==null);i===null?s=i=e:i=i.next=e}else s=i=e;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function pu(t,e,n,r){var s=t.updateQueue;Vr=!1;var i=s.firstBaseUpdate,o=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,h=c.next;c.next=null,o===null?i=h:o.next=h,o=c;var m=t.alternate;m!==null&&(m=m.updateQueue,l=m.lastBaseUpdate,l!==o&&(l===null?m.firstBaseUpdate=h:l.next=h,m.lastBaseUpdate=c))}if(i!==null){var v=s.baseState;o=0,m=h=c=null,l=i;do{var g=l.lane,N=l.eventTime;if((r&g)===g){m!==null&&(m=m.next={eventTime:N,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var L=t,O=l;switch(g=e,N=n,O.tag){case 1:if(L=O.payload,typeof L=="function"){v=L.call(N,v,g);break e}v=L;break e;case 3:L.flags=L.flags&-65537|128;case 0:if(L=O.payload,g=typeof L=="function"?L.call(N,v,g):L,g==null)break e;v=ze({},v,g);break e;case 2:Vr=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,g=s.effects,g===null?s.effects=[l]:g.push(l))}else N={eventTime:N,lane:g,tag:l.tag,payload:l.payload,callback:l.callback,next:null},m===null?(h=m=N,c=v):m=m.next=N,o|=g;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;g=l,l=g.next,g.next=null,s.lastBaseUpdate=g,s.shared.pending=null}}while(!0);if(m===null&&(c=v),s.baseState=c,s.firstBaseUpdate=h,s.lastBaseUpdate=m,e=s.shared.interleaved,e!==null){s=e;do o|=s.lane,s=s.next;while(s!==e)}else i===null&&(s.shared.lanes=0);Ys|=o,t.lanes=o,t.memoizedState=v}}function mg(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=Zd.transition;Zd.transition={};try{t(!1),e()}finally{ke=n,Zd.transition=r}}function X0(){return un().memoizedState}function zk(t,e,n){var r=es(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},J0(t))Z0(e,n);else if(n=D0(t,e,n,r),n!==null){var s=Pt();xn(n,t,r,s),e_(n,e,r)}}function Bk(t,e,n){var r=es(t),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(J0(t))Z0(e,s);else{var i=t.alternate;if(t.lanes===0&&(i===null||i.lanes===0)&&(i=e.lastRenderedReducer,i!==null))try{var o=e.lastRenderedState,l=i(o,n);if(s.hasEagerState=!0,s.eagerState=l,En(l,o)){var c=e.interleaved;c===null?(s.next=s,hp(e)):(s.next=c.next,c.next=s),e.interleaved=s;return}}catch{}finally{}n=D0(t,e,s,r),n!==null&&(s=Pt(),xn(n,t,r,s),e_(n,e,r))}}function J0(t){var e=t.alternate;return t===Ue||e!==null&&e===Ue}function Z0(t,e){ba=gu=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function e_(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Jf(t,n)}}var yu={readContext:cn,useCallback:_t,useContext:_t,useEffect:_t,useImperativeHandle:_t,useInsertionEffect:_t,useLayoutEffect:_t,useMemo:_t,useReducer:_t,useRef:_t,useState:_t,useDebugValue:_t,useDeferredValue:_t,useTransition:_t,useMutableSource:_t,useSyncExternalStore:_t,useId:_t,unstable_isNewReconciler:!1},$k={readContext:cn,useCallback:function(t,e){return jn().memoizedState=[t,e===void 0?null:e],t},useContext:cn,useEffect:yg,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Fc(4194308,4,H0.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Fc(4194308,4,t,e)},useInsertionEffect:function(t,e){return Fc(4,2,t,e)},useMemo:function(t,e){var n=jn();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=jn();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=zk.bind(null,Ue,t),[r.memoizedState,t]},useRef:function(t){var e=jn();return t={current:t},e.memoizedState=t},useState:gg,useDebugValue:xp,useDeferredValue:function(t){return jn().memoizedState=t},useTransition:function(){var t=gg(!1),e=t[0];return t=Uk.bind(null,t[1]),jn().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=Ue,s=jn();if(Me){if(n===void 0)throw Error(q(407));n=n()}else{if(n=e(),lt===null)throw Error(q(349));Qs&30||V0(r,e,n)}s.memoizedState=n;var i={value:n,getSnapshot:e};return s.queue=i,yg(U0.bind(null,r,i,t),[t]),r.flags|=2048,Ja(9,F0.bind(null,r,i,n,e),void 0,null),n},useId:function(){var t=jn(),e=lt.identifierPrefix;if(Me){var n=Zn,r=Jn;n=(r&~(1<<32-wn(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Ya++,0<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[Ln]=e,t[Ga]=r,u_(t,e,!1,!1),e.stateNode=t;e:{switch(o=jh(n,r),n){case"dialog":Pe("cancel",t),Pe("close",t),s=r;break;case"iframe":case"object":case"embed":Pe("load",t),s=r;break;case"video":case"audio":for(s=0;smo&&(e.flags|=128,r=!0,ra(i,!1),e.lanes=4194304)}else{if(!r)if(t=mu(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),ra(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!Me)return wt(e),null}else 2*He()-i.renderingStartTime>mo&&n!==1073741824&&(e.flags|=128,r=!0,ra(i,!1),e.lanes=4194304);i.isBackwards?(o.sibling=e.child,e.child=o):(n=i.last,n!==null?n.sibling=o:e.child=o,i.last=o)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=He(),e.sibling=null,n=Fe.current,Ne(Fe,r?n&1|2:n&1),e):(wt(e),null);case 22:case 23:return Cp(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Kt&1073741824&&(wt(e),e.subtreeFlags&6&&(e.flags|=8192)):wt(e),null;case 24:return null;case 25:return null}throw Error(q(156,e.tag))}function Xk(t,e){switch(ap(e),e.tag){case 1:return qt(e.type)&&lu(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return fo(),je(Wt),je(Ct),gp(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return mp(e),null;case 13:if(je(Fe),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(q(340));uo()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return je(Fe),null;case 4:return fo(),null;case 10:return dp(e.type._context),null;case 22:case 23:return Cp(),null;case 24:return null;default:return null}}var _c=!1,Tt=!1,Jk=typeof WeakSet=="function"?WeakSet:Set,J=null;function Qi(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){$e(t,e,r)}else n.current=null}function lf(t,e,n){try{n()}catch(r){$e(t,e,r)}}var bg=!1;function Zk(t,e){if(Wh=su,t=y0(),ip(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,l=-1,c=-1,h=0,m=0,v=t,g=null;t:for(;;){for(var N;v!==n||s!==0&&v.nodeType!==3||(l=o+s),v!==i||r!==0&&v.nodeType!==3||(c=o+r),v.nodeType===3&&(o+=v.nodeValue.length),(N=v.firstChild)!==null;)g=v,v=N;for(;;){if(v===t)break t;if(g===n&&++h===s&&(l=o),g===i&&++m===r&&(c=o),(N=v.nextSibling)!==null)break;v=g,g=v.parentNode}v=N}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(qh={focusedElem:t,selectionRange:n},su=!1,J=e;J!==null;)if(e=J,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,J=t;else for(;J!==null;){e=J;try{var L=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(L!==null){var O=L.memoizedProps,z=L.memoizedState,I=e.stateNode,x=I.getSnapshotBeforeUpdate(e.elementType===e.type?O:yn(e.type,O),z);I.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var b=e.stateNode.containerInfo;b.nodeType===1?b.textContent="":b.nodeType===9&&b.documentElement&&b.removeChild(b.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(q(163))}}catch(F){$e(e,e.return,F)}if(t=e.sibling,t!==null){t.return=e.return,J=t;break}J=e.return}return L=bg,bg=!1,L}function Aa(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&t)===t){var i=s.destroy;s.destroy=void 0,i!==void 0&&lf(e,n,i)}s=s.next}while(s!==r)}}function Xu(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function cf(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function f_(t){var e=t.alternate;e!==null&&(t.alternate=null,f_(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Ln],delete e[Ga],delete e[Kh],delete e[Lk],delete e[Ok])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function p_(t){return t.tag===5||t.tag===3||t.tag===4}function Ag(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||p_(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function uf(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=au));else if(r!==4&&(t=t.child,t!==null))for(uf(t,e,n),t=t.sibling;t!==null;)uf(t,e,n),t=t.sibling}function df(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(df(t,e,n),t=t.sibling;t!==null;)df(t,e,n),t=t.sibling}var ut=null,vn=!1;function Lr(t,e,n){for(n=n.child;n!==null;)m_(t,e,n),n=n.sibling}function m_(t,e,n){if(Mn&&typeof Mn.onCommitFiberUnmount=="function")try{Mn.onCommitFiberUnmount($u,n)}catch{}switch(n.tag){case 5:Tt||Qi(n,e);case 6:var r=ut,s=vn;ut=null,Lr(t,e,n),ut=r,vn=s,ut!==null&&(vn?(t=ut,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):ut.removeChild(n.stateNode));break;case 18:ut!==null&&(vn?(t=ut,n=n.stateNode,t.nodeType===8?Yd(t.parentNode,n):t.nodeType===1&&Yd(t,n),Ba(t)):Yd(ut,n.stateNode));break;case 4:r=ut,s=vn,ut=n.stateNode.containerInfo,vn=!0,Lr(t,e,n),ut=r,vn=s;break;case 0:case 11:case 14:case 15:if(!Tt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&lf(n,e,o),s=s.next}while(s!==r)}Lr(t,e,n);break;case 1:if(!Tt&&(Qi(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){$e(n,e,l)}Lr(t,e,n);break;case 21:Lr(t,e,n);break;case 22:n.mode&1?(Tt=(r=Tt)||n.memoizedState!==null,Lr(t,e,n),Tt=r):Lr(t,e,n);break;default:Lr(t,e,n)}}function Ng(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new Jk),e.forEach(function(r){var s=l1.bind(null,t,r);n.has(r)||(n.add(r),r.then(s,s))})}}function gn(t,e){var n=e.deletions;if(n!==null)for(var r=0;rs&&(s=o),r&=~i}if(r=s,r=He()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*t1(r/1960))-r,10t?16:t,Hr===null)var r=!1;else{if(t=Hr,Hr=null,wu=0,_e&6)throw Error(q(331));var s=_e;for(_e|=4,J=t.current;J!==null;){var i=J,o=i.child;if(J.flags&16){var l=i.deletions;if(l!==null){for(var c=0;cHe()-Sp?Ws(t,0):Tp|=n),Ht(t,e)}function k_(t,e){e===0&&(t.mode&1?(e=uc,uc<<=1,!(uc&130023424)&&(uc=4194304)):e=1);var n=Pt();t=lr(t,e),t!==null&&(ul(t,e,n),Ht(t,n))}function a1(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),k_(t,n)}function l1(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,s=t.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(q(314))}r!==null&&r.delete(e),k_(t,n)}var T_;T_=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Wt.current)$t=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return $t=!1,Qk(t,e,n);$t=!!(t.flags&131072)}else $t=!1,Me&&e.flags&1048576&&b0(e,du,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Uc(t,e),t=e.pendingProps;var s=co(e,Ct.current);no(e,n),s=vp(null,e,r,t,s,n);var i=_p();return e.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,qt(r)?(i=!0,cu(e)):i=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,fp(e),s.updater=Yu,e.stateNode=s,s._reactInternals=e,ef(e,r,t,n),e=rf(null,e,r,!0,i,n)):(e.tag=0,Me&&i&&op(e),Nt(null,e,s,n),e=e.child),e;case 16:r=e.elementType;e:{switch(Uc(t,e),t=e.pendingProps,s=r._init,r=s(r._payload),e.type=r,s=e.tag=u1(r),t=yn(r,t),s){case 0:e=nf(null,e,r,t,n);break e;case 1:e=Sg(null,e,r,t,n);break e;case 11:e=kg(null,e,r,t,n);break e;case 14:e=Tg(null,e,r,yn(r.type,t),n);break e}throw Error(q(306,r,""))}return e;case 0:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:yn(r,s),nf(t,e,r,s,n);case 1:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:yn(r,s),Sg(t,e,r,s,n);case 3:e:{if(a_(e),t===null)throw Error(q(387));r=e.pendingProps,i=e.memoizedState,s=i.element,j0(t,e),pu(e,r,null,n);var o=e.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=i,e.memoizedState=i,e.flags&256){s=po(Error(q(423)),e),e=Ig(t,e,r,n,s);break e}else if(r!==s){s=po(Error(q(424)),e),e=Ig(t,e,r,n,s);break e}else for(Qt=Xr(e.stateNode.containerInfo.firstChild),Xt=e,Me=!0,_n=null,n=R0(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(uo(),r===s){e=cr(t,e,n);break e}Nt(t,e,r,n)}e=e.child}return e;case 5:return L0(e),t===null&&Xh(e),r=e.type,s=e.pendingProps,i=t!==null?t.memoizedProps:null,o=s.children,Hh(r,s)?o=null:i!==null&&Hh(r,i)&&(e.flags|=32),o_(t,e),Nt(t,e,o,n),e.child;case 6:return t===null&&Xh(e),null;case 13:return l_(t,e,n);case 4:return pp(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=ho(e,null,r,n):Nt(t,e,r,n),e.child;case 11:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:yn(r,s),kg(t,e,r,s,n);case 7:return Nt(t,e,e.pendingProps,n),e.child;case 8:return Nt(t,e,e.pendingProps.children,n),e.child;case 12:return Nt(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,s=e.pendingProps,i=e.memoizedProps,o=s.value,Ne(hu,r._currentValue),r._currentValue=o,i!==null)if(En(i.value,o)){if(i.children===s.children&&!Wt.current){e=cr(t,e,n);break e}}else for(i=e.child,i!==null&&(i.return=e);i!==null;){var l=i.dependencies;if(l!==null){o=i.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=rr(-1,n&-n),c.tag=2;var h=i.updateQueue;if(h!==null){h=h.shared;var m=h.pending;m===null?c.next=c:(c.next=m.next,m.next=c),h.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),Jh(i.return,n,e),l.lanes|=n;break}c=c.next}}else if(i.tag===10)o=i.type===e.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(q(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Jh(o,n,e),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===e){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}Nt(t,e,s.children,n),e=e.child}return e;case 9:return s=e.type,r=e.pendingProps.children,no(e,n),s=cn(s),r=r(s),e.flags|=1,Nt(t,e,r,n),e.child;case 14:return r=e.type,s=yn(r,e.pendingProps),s=yn(r.type,s),Tg(t,e,r,s,n);case 15:return s_(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:yn(r,s),Uc(t,e),e.tag=1,qt(r)?(t=!0,cu(e)):t=!1,no(e,n),t_(e,r,s),ef(e,r,s,n),rf(null,e,r,!0,t,n);case 19:return c_(t,e,n);case 22:return i_(t,e,n)}throw Error(q(156,e.tag))};function S_(t,e){return Jv(t,e)}function c1(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function an(t,e,n,r){return new c1(t,e,n,r)}function Ap(t){return t=t.prototype,!(!t||!t.isReactComponent)}function u1(t){if(typeof t=="function")return Ap(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Kf)return 11;if(t===Qf)return 14}return 2}function ts(t,e){var n=t.alternate;return n===null?(n=an(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function $c(t,e,n,r,s,i){var o=2;if(r=t,typeof t=="function")Ap(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Ui:return qs(n.children,s,i,e);case Gf:o=8,s|=8;break;case Th:return t=an(12,n,e,s|2),t.elementType=Th,t.lanes=i,t;case Sh:return t=an(13,n,e,s),t.elementType=Sh,t.lanes=i,t;case Ih:return t=an(19,n,e,s),t.elementType=Ih,t.lanes=i,t;case Lv:return Zu(n,s,i,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Dv:o=10;break e;case jv:o=9;break e;case Kf:o=11;break e;case Qf:o=14;break e;case Mr:o=16,r=null;break e}throw Error(q(130,t==null?t:typeof t,""))}return e=an(o,n,e,s),e.elementType=t,e.type=r,e.lanes=i,e}function qs(t,e,n,r){return t=an(7,t,r,e),t.lanes=n,t}function Zu(t,e,n,r){return t=an(22,t,r,e),t.elementType=Lv,t.lanes=n,t.stateNode={isHidden:!1},t}function sh(t,e,n){return t=an(6,t,null,e),t.lanes=n,t}function ih(t,e,n){return e=an(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function d1(t,e,n,r,s){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Fd(0),this.expirationTimes=Fd(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Fd(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Np(t,e,n,r,s,i,o,l,c){return t=new d1(t,e,n,l,c),e===1?(e=1,i===!0&&(e|=8)):e=0,i=an(3,null,null,e),t.current=i,i.stateNode=t,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},fp(i),t}function h1(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(A_)}catch(t){console.error(t)}}A_(),Av.exports=Zt;var y1=Av.exports,Vg=y1;Eh.createRoot=Vg.createRoot,Eh.hydrateRoot=Vg.hydrateRoot;/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var v1={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _1=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),fe=(t,e)=>{const n=G.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:o,className:l="",children:c,...h},m)=>G.createElement("svg",{ref:m,...v1,width:s,height:s,stroke:r,strokeWidth:o?Number(i)*24/Number(s):i,className:["lucide",`lucide-${_1(t)}`,l].join(" "),...h},[...e.map(([v,g])=>G.createElement(v,g)),...Array.isArray(c)?c:[c]]));return n.displayName=`${t}`,n};/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w1=fe("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x1=fe("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ia=fe("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fg=fe("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ug=fe("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rn=fe("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zg=fe("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E1=fe("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bg=fe("CircleUser",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $g=fe("CloudSun",[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z",key:"s09mg5"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ls=fe("Droplets",[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oh=fe("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wg=fe("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ah=fe("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lh=fe("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k1=fe("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T1=fe("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qg=fe("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S1=fe("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I1=fe("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C1=fe("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b1=fe("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ec=fe("Pen",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A1=fe("PieChart",[["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}],["path",{d:"M22 12A10 10 0 0 0 12 2v10z",key:"1rfc4y"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oa=fe("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N1=fe("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hg=fe("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ch=fe("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gg=fe("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kg=fe("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aa=fe("Shirt",[["path",{d:"M20.38 3.46 16 2a4 4 0 0 1-8 0L3.62 3.46a2 2 0 0 0-1.34 2.23l.58 3.47a1 1 0 0 0 .99.84H6v10c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V10h2.15a1 1 0 0 0 .99-.84l.58-3.47a2 2 0 0 0-1.34-2.23z",key:"1wgbhj"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qg=fe("ShoppingBag",[["path",{d:"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z",key:"hou9p0"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const la=fe("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P1=fe("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yg=fe("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xg=fe("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kc=fe("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R1=fe("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/** * @license lucide-react v0.344.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Di=fe("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);var Jg={};/** * @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 N_=function(t){const e=[];let n=0;for(let r=0;r>6|192,e[n++]=s&63|128):(s&64512)===55296&&r+1>18|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128,e[n++]=s&63|128):(e[n++]=s>>12|224,e[n++]=s>>6&63|128,e[n++]=s&63|128)}return e},D1=function(t){const e=[];let n=0,r=0;for(;n191&&s<224){const i=t[n++];e[r++]=String.fromCharCode((s&31)<<6|i&63)}else if(s>239&&s<365){const i=t[n++],o=t[n++],l=t[n++],c=((s&7)<<18|(i&63)<<12|(o&63)<<6|l&63)-65536;e[r++]=String.fromCharCode(55296+(c>>10)),e[r++]=String.fromCharCode(56320+(c&1023))}else{const i=t[n++],o=t[n++];e[r++]=String.fromCharCode((s&15)<<12|(i&63)<<6|o&63)}}return e.join("")},P_={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 s=0;s>2,v=(i&3)<<4|l>>4;let g=(l&15)<<2|h>>6,N=h&63;c||(N=64,o||(g=64)),r.push(n[m],n[v],n[g],n[N])}return r.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(N_(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):D1(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s>4;if(r.push(g),h!==64){const N=l<<4&240|h>>2;if(r.push(N),v!==64){const L=h<<6&192|v;r.push(L)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}};class j1 extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const L1=function(t){const e=N_(t);return P_.encodeByteArray(e,!0)},ku=function(t){return L1(t).replace(/\./g,"")},R_=function(t){try{return P_.decodeString(t,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/** * @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. */function O1(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}/** * @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. */const M1=()=>O1().__FIREBASE_DEFAULTS__,V1=()=>{if(typeof process>"u"||typeof Jg>"u")return;const t=Jg.__FIREBASE_DEFAULTS__;if(t)return JSON.parse(t)},F1=()=>{if(typeof document>"u")return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=t&&R_(t[1]);return e&&JSON.parse(e)},sd=()=>{try{return M1()||V1()||F1()}catch(t){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`);return}},D_=t=>{var e,n;return(n=(e=sd())===null||e===void 0?void 0:e.emulatorHosts)===null||n===void 0?void 0:n[t]},U1=t=>{const e=D_(t);if(!e)return;const n=e.lastIndexOf(":");if(n<=0||n+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const r=parseInt(e.substring(n+1),10);return e[0]==="["?[e.substring(1,n-1),r]:[e.substring(0,n),r]},j_=()=>{var t;return(t=sd())===null||t===void 0?void 0:t.config},L_=t=>{var e;return(e=sd())===null||e===void 0?void 0:e[`_${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 z1{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 B1(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",s=t.iat||0,i=t.sub||t.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},t);return[ku(JSON.stringify(n)),ku(JSON.stringify(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 bt(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function $1(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(bt())}function W1(){var t;const e=(t=sd())===null||t===void 0?void 0:t.forceEnvironment;if(e==="node")return!0;if(e==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function q1(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function H1(){const t=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof t=="object"&&t.id!==void 0}function G1(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function K1(){const t=bt();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function Q1(){return!W1()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function Y1(){try{return typeof indexedDB=="object"}catch{return!1}}function X1(){return new Promise((t,e)=>{try{let n=!0;const r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),n||self.indexedDB.deleteDatabase(r),t(!0)},s.onupgradeneeded=()=>{n=!1},s.onerror=()=>{var i;e(((i=s.error)===null||i===void 0?void 0:i.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 J1="FirebaseError";class mr extends Error{constructor(e,n,r){super(n),this.code=e,this.customData=r,this.name=J1,Object.setPrototypeOf(this,mr.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,pl.prototype.create)}}class pl{constructor(e,n,r){this.service=e,this.serviceName=n,this.errors=r}create(e,...n){const r=n[0]||{},s=`${this.service}/${e}`,i=this.errors[e],o=i?Z1(i,r):"Error",l=`${this.serviceName}: ${o} (${s}).`;return new mr(s,l,r)}}function Z1(t,e){return t.replace(eT,(n,r)=>{const s=e[r];return s!=null?String(s):`<${r}?>`})}const eT=/\{\$([^}]+)}/g;function tT(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function Tu(t,e){if(t===e)return!0;const n=Object.keys(t),r=Object.keys(e);for(const s of n){if(!r.includes(s))return!1;const i=t[s],o=e[s];if(Zg(i)&&Zg(o)){if(!Tu(i,o))return!1}else if(i!==o)return!1}for(const s of r)if(!n.includes(s))return!1;return!0}function Zg(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 ml(t){const e=[];for(const[n,r]of Object.entries(t))Array.isArray(r)?r.forEach(s=>{e.push(encodeURIComponent(n)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function ya(t){const e={};return t.replace(/^\?/,"").split("&").forEach(r=>{if(r){const[s,i]=r.split("=");e[decodeURIComponent(s)]=decodeURIComponent(i)}}),e}function va(t){const e=t.indexOf("?");if(!e)return"";const n=t.indexOf("#",e);return t.substring(e,n>0?n:void 0)}function nT(t,e){const n=new rT(t,e);return n.subscribe.bind(n)}class rT{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 s;if(e===void 0&&n===void 0&&r===void 0)throw new Error("Missing Observer.");sT(e,["next","error","complete"])?s=e:s={next:e,error:n,complete:r},s.next===void 0&&(s.next=uh),s.error===void 0&&(s.error=uh),s.complete===void 0&&(s.complete=uh);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?s.error(this.finalError):s.complete()}catch{}}),this.observers.push(s),i}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{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 sT(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 uh(){}/** * @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 Ge(t){return t&&t._delegate?t._delegate:t}class Js{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 Fs="[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 iT{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 z1;if(this.instancesDeferred.set(n,r),this.isInitialized(n)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:n});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(n).promise}getImmediate(e){var n;const r=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),s=(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(i){if(s)return null;throw i}else{if(s)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(aT(e))try{this.getOrInitializeService({instanceIdentifier:Fs})}catch{}for(const[n,r]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(n);try{const i=this.getOrInitializeService({instanceIdentifier:s});r.resolve(i)}catch{}}}}clearInstance(e=Fs){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=Fs){return this.instances.has(e)}getOptions(e=Fs){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 s=this.getOrInitializeService({instanceIdentifier:r,options:n});for(const[i,o]of this.instancesDeferred.entries()){const l=this.normalizeInstanceIdentifier(i);r===l&&o.resolve(s)}return s}onInit(e,n){var r;const s=this.normalizeInstanceIdentifier(n),i=(r=this.onInitCallbacks.get(s))!==null&&r!==void 0?r:new Set;i.add(e),this.onInitCallbacks.set(s,i);const o=this.instances.get(s);return o&&e(o,s),()=>{i.delete(e)}}invokeOnInitCallbacks(e,n){const r=this.onInitCallbacks.get(n);if(r)for(const s of r)try{s(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:oT(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=Fs){return this.component?this.component.multipleInstances?e:Fs:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function oT(t){return t===Fs?void 0:t}function aT(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 lT{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 iT(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 ye;(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"})(ye||(ye={}));const cT={debug:ye.DEBUG,verbose:ye.VERBOSE,info:ye.INFO,warn:ye.WARN,error:ye.ERROR,silent:ye.SILENT},uT=ye.INFO,dT={[ye.DEBUG]:"log",[ye.VERBOSE]:"log",[ye.INFO]:"info",[ye.WARN]:"warn",[ye.ERROR]:"error"},hT=(t,e,...n)=>{if(ee.some(n=>t instanceof n);let ey,ty;function pT(){return ey||(ey=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function mT(){return ty||(ty=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const O_=new WeakMap,gf=new WeakMap,M_=new WeakMap,dh=new WeakMap,Lp=new WeakMap;function gT(t){const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("success",i),t.removeEventListener("error",o)},i=()=>{n(ns(t.result)),s()},o=()=>{r(t.error),s()};t.addEventListener("success",i),t.addEventListener("error",o)});return e.then(n=>{n instanceof IDBCursor&&O_.set(n,t)}).catch(()=>{}),Lp.set(e,t),e}function yT(t){if(gf.has(t))return;const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",o),t.removeEventListener("abort",o)},i=()=>{n(),s()},o=()=>{r(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",i),t.addEventListener("error",o),t.addEventListener("abort",o)});gf.set(t,e)}let yf={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return gf.get(t);if(e==="objectStoreNames")return t.objectStoreNames||M_.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return ns(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 vT(t){yf=t(yf)}function _T(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...n){const r=t.call(hh(this),e,...n);return M_.set(r,e.sort?e.sort():[e]),ns(r)}:mT().includes(t)?function(...e){return t.apply(hh(this),e),ns(O_.get(this))}:function(...e){return ns(t.apply(hh(this),e))}}function wT(t){return typeof t=="function"?_T(t):(t instanceof IDBTransaction&&yT(t),fT(t,pT())?new Proxy(t,yf):t)}function ns(t){if(t instanceof IDBRequest)return gT(t);if(dh.has(t))return dh.get(t);const e=wT(t);return e!==t&&(dh.set(t,e),Lp.set(e,t)),e}const hh=t=>Lp.get(t);function xT(t,e,{blocked:n,upgrade:r,blocking:s,terminated:i}={}){const o=indexedDB.open(t,e),l=ns(o);return r&&o.addEventListener("upgradeneeded",c=>{r(ns(o.result),c.oldVersion,c.newVersion,ns(o.transaction),c)}),n&&o.addEventListener("blocked",c=>n(c.oldVersion,c.newVersion,c)),l.then(c=>{i&&c.addEventListener("close",()=>i()),s&&c.addEventListener("versionchange",h=>s(h.oldVersion,h.newVersion,h))}).catch(()=>{}),l}const ET=["get","getKey","getAll","getAllKeys","count"],kT=["put","add","delete","clear"],fh=new Map;function ny(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(fh.get(e))return fh.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,s=kT.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(s||ET.includes(n)))return;const i=async function(o,...l){const c=this.transaction(o,s?"readwrite":"readonly");let h=c.store;return r&&(h=h.index(l.shift())),(await Promise.all([h[n](...l),s&&c.done]))[0]};return fh.set(e,i),i}vT(t=>({...t,get:(e,n,r)=>ny(e,n)||t.get(e,n,r),has:(e,n)=>!!ny(e,n)||t.has(e,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 TT{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(n=>{if(ST(n)){const r=n.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(n=>n).join(" ")}}function ST(t){const e=t.getComponent();return(e==null?void 0:e.type)==="VERSION"}const vf="@firebase/app",ry="0.10.13";/** * @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 ur=new jp("@firebase/app"),IT="@firebase/app-compat",CT="@firebase/analytics-compat",bT="@firebase/analytics",AT="@firebase/app-check-compat",NT="@firebase/app-check",PT="@firebase/auth",RT="@firebase/auth-compat",DT="@firebase/database",jT="@firebase/data-connect",LT="@firebase/database-compat",OT="@firebase/functions",MT="@firebase/functions-compat",VT="@firebase/installations",FT="@firebase/installations-compat",UT="@firebase/messaging",zT="@firebase/messaging-compat",BT="@firebase/performance",$T="@firebase/performance-compat",WT="@firebase/remote-config",qT="@firebase/remote-config-compat",HT="@firebase/storage",GT="@firebase/storage-compat",KT="@firebase/firestore",QT="@firebase/vertexai-preview",YT="@firebase/firestore-compat",XT="firebase",JT="10.14.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. */const _f="[DEFAULT]",ZT={[vf]:"fire-core",[IT]:"fire-core-compat",[bT]:"fire-analytics",[CT]:"fire-analytics-compat",[NT]:"fire-app-check",[AT]:"fire-app-check-compat",[PT]:"fire-auth",[RT]:"fire-auth-compat",[DT]:"fire-rtdb",[jT]:"fire-data-connect",[LT]:"fire-rtdb-compat",[OT]:"fire-fn",[MT]:"fire-fn-compat",[VT]:"fire-iid",[FT]:"fire-iid-compat",[UT]:"fire-fcm",[zT]:"fire-fcm-compat",[BT]:"fire-perf",[$T]:"fire-perf-compat",[WT]:"fire-rc",[qT]:"fire-rc-compat",[HT]:"fire-gcs",[GT]:"fire-gcs-compat",[KT]:"fire-fst",[YT]:"fire-fst-compat",[QT]:"fire-vertex","fire-js":"fire-js",[XT]:"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 Su=new Map,eS=new Map,wf=new Map;function sy(t,e){try{t.container.addComponent(e)}catch(n){ur.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n)}}function go(t){const e=t.name;if(wf.has(e))return ur.debug(`There were multiple attempts to register component ${e}.`),!1;wf.set(e,t);for(const n of Su.values())sy(n,t);for(const n of eS.values())sy(n,t);return!0}function Op(t,e){const n=t.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),t.container.getProvider(e)}function On(t){return t.settings!==void 0}/** * @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 tS={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","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","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","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}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},rs=new pl("app","Firebase",tS);/** * @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 nS{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 Js("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 rs.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 Co=JT;function V_(t,e={}){let n=t;typeof e!="object"&&(e={name:e});const r=Object.assign({name:_f,automaticDataCollectionEnabled:!1},e),s=r.name;if(typeof s!="string"||!s)throw rs.create("bad-app-name",{appName:String(s)});if(n||(n=j_()),!n)throw rs.create("no-options");const i=Su.get(s);if(i){if(Tu(n,i.options)&&Tu(r,i.config))return i;throw rs.create("duplicate-app",{appName:s})}const o=new lT(s);for(const c of wf.values())o.addComponent(c);const l=new nS(n,r,o);return Su.set(s,l),l}function F_(t=_f){const e=Su.get(t);if(!e&&t===_f&&j_())return V_();if(!e)throw rs.create("no-app",{appName:t});return e}function ss(t,e,n){var r;let s=(r=ZT[t])!==null&&r!==void 0?r:t;n&&(s+=`-${n}`);const i=s.match(/\s|\//),o=e.match(/\s|\//);if(i||o){const l=[`Unable to register library "${s}" with version "${e}":`];i&&l.push(`library name "${s}" contains illegal characters (whitespace or "/")`),i&&o&&l.push("and"),o&&l.push(`version name "${e}" contains illegal characters (whitespace or "/")`),ur.warn(l.join(" "));return}go(new Js(`${s}-version`,()=>({library:s,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 rS="firebase-heartbeat-database",sS=1,el="firebase-heartbeat-store";let ph=null;function U_(){return ph||(ph=xT(rS,sS,{upgrade:(t,e)=>{switch(e){case 0:try{t.createObjectStore(el)}catch(n){console.warn(n)}}}}).catch(t=>{throw rs.create("idb-open",{originalErrorMessage:t.message})})),ph}async function iS(t){try{const n=(await U_()).transaction(el),r=await n.objectStore(el).get(z_(t));return await n.done,r}catch(e){if(e instanceof mr)ur.warn(e.message);else{const n=rs.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});ur.warn(n.message)}}}async function iy(t,e){try{const r=(await U_()).transaction(el,"readwrite");await r.objectStore(el).put(e,z_(t)),await r.done}catch(n){if(n instanceof mr)ur.warn(n.message);else{const r=rs.create("idb-set",{originalErrorMessage:n==null?void 0:n.message});ur.warn(r.message)}}}function z_(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 oS=1024,aS=30*24*60*60*1e3;class lS{constructor(e){this.container=e,this._heartbeatsCache=null;const n=this.container.getProvider("app").getImmediate();this._storage=new uS(n),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){var e,n;try{const s=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),i=oy();return((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((n=this._heartbeatsCache)===null||n===void 0?void 0:n.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some(o=>o.date===i)?void 0:(this._heartbeatsCache.heartbeats.push({date:i,agent:s}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter(o=>{const l=new Date(o.date).valueOf();return Date.now()-l<=aS}),this._storage.overwrite(this._heartbeatsCache))}catch(r){ur.warn(r)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const n=oy(),{heartbeatsToSend:r,unsentEntries:s}=cS(this._heartbeatsCache.heartbeats),i=ku(JSON.stringify({version:2,heartbeats:r}));return this._heartbeatsCache.lastSentHeartbeatDate=n,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(n){return ur.warn(n),""}}}function oy(){return new Date().toISOString().substring(0,10)}function cS(t,e=oS){const n=[];let r=t.slice();for(const s of t){const i=n.find(o=>o.agent===s.agent);if(i){if(i.dates.push(s.date),ay(n)>e){i.dates.pop();break}}else if(n.push({agent:s.agent,dates:[s.date]}),ay(n)>e){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}class uS{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return Y1()?X1().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const n=await iS(this.app);return n!=null&&n.heartbeats?n:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){var n;if(await this._canUseIndexedDBPromise){const s=await this.read();return iy(this.app,{lastSentHeartbeatDate:(n=e.lastSentHeartbeatDate)!==null&&n!==void 0?n:s.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var n;if(await this._canUseIndexedDBPromise){const s=await this.read();return iy(this.app,{lastSentHeartbeatDate:(n=e.lastSentHeartbeatDate)!==null&&n!==void 0?n:s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...e.heartbeats]})}else return}}function ay(t){return ku(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 dS(t){go(new Js("platform-logger",e=>new TT(e),"PRIVATE")),go(new Js("heartbeat",e=>new lS(e),"PRIVATE")),ss(vf,ry,t),ss(vf,ry,"esm2017"),ss("fire-js","")}dS("");function Mp(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 s=0,r=Object.getOwnPropertySymbols(t);s"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 gl{constructor(e,n){this.shortDelay=e,this.longDelay=n,dr(n>e,"Short delay should be less than long delay!"),this.isMobile=$1()||G1()}get(){return mS()?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 Fp(t,e){dr(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 q_{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;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;er("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;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;er("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;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;er("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 yS={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};/** * @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 vS=new gl(3e4,6e4);function gr(t,e){return t.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:t.tenantId}):e}async function yr(t,e,n,r,s={}){return H_(t,s,async()=>{let i={},o={};r&&(e==="GET"?o=r:i={body:JSON.stringify(r)});const l=ml(Object.assign({key:t.config.apiKey},o)).slice(1),c=await t._getAdditionalHeaders();c["Content-Type"]="application/json",t.languageCode&&(c["X-Firebase-Locale"]=t.languageCode);const h=Object.assign({method:e,headers:c},i);return q1()||(h.referrerPolicy="no-referrer"),q_.fetch()(G_(t,t.config.apiHost,n,l),h)})}async function H_(t,e,n){t._canInitEmulator=!1;const r=Object.assign(Object.assign({},yS),e);try{const s=new wS(t),i=await Promise.race([n(),s.promise]);s.clearNetworkTimeout();const o=await i.json();if("needConfirmation"in o)throw Tc(t,"account-exists-with-different-credential",o);if(i.ok&&!("errorMessage"in o))return o;{const l=i.ok?o.errorMessage:o.error.message,[c,h]=l.split(" : ");if(c==="FEDERATED_USER_ID_ALREADY_LINKED")throw Tc(t,"credential-already-in-use",o);if(c==="EMAIL_EXISTS")throw Tc(t,"email-already-in-use",o);if(c==="USER_DISABLED")throw Tc(t,"user-disabled",o);const m=r[c]||c.toLowerCase().replace(/[_\s]+/g,"-");if(h)throw W_(t,m,h);kn(t,m)}}catch(s){if(s instanceof mr)throw s;kn(t,"network-request-failed",{message:String(s)})}}async function yl(t,e,n,r,s={}){const i=await yr(t,e,n,r,s);return"mfaPendingCredential"in i&&kn(t,"multi-factor-auth-required",{_serverResponse:i}),i}function G_(t,e,n,r){const s=`${e}${n}?${r}`;return t.config.emulator?Fp(t.config,s):`${t.config.apiScheme}://${s}`}function _S(t){switch(t){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class wS{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((n,r)=>{this.timer=setTimeout(()=>r(Fn(this.auth,"network-request-failed")),vS.get())})}clearNetworkTimeout(){clearTimeout(this.timer)}}function Tc(t,e,n){const r={appName:t.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const s=Fn(t,e,r);return s.customData._tokenResponse=n,s}function cy(t){return t!==void 0&&t.enterprise!==void 0}class xS{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],e.recaptchaKey===void 0)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(const n of this.recaptchaEnforcementState)if(n.provider&&n.provider===e)return _S(n.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)==="ENFORCE"||this.getProviderEnforcementState(e)==="AUDIT"}}async function ES(t,e){return yr(t,"GET","/v2/recaptchaConfig",gr(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. */async function kS(t,e){return yr(t,"POST","/v1/accounts:delete",e)}async function K_(t,e){return yr(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 Ra(t){if(t)try{const e=new Date(Number(t));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function TS(t,e=!1){const n=Ge(t),r=await n.getIdToken(e),s=Up(r);ie(s&&s.exp&&s.auth_time&&s.iat,n.auth,"internal-error");const i=typeof s.firebase=="object"?s.firebase:void 0,o=i==null?void 0:i.sign_in_provider;return{claims:s,token:r,authTime:Ra(mh(s.auth_time)),issuedAtTime:Ra(mh(s.iat)),expirationTime:Ra(mh(s.exp)),signInProvider:o||null,signInSecondFactor:(i==null?void 0:i.sign_in_second_factor)||null}}function mh(t){return Number(t)*1e3}function Up(t){const[e,n,r]=t.split(".");if(e===void 0||n===void 0||r===void 0)return Wc("JWT malformed, contained fewer than 3 sections"),null;try{const s=R_(n);return s?JSON.parse(s):(Wc("Failed to decode base64 JWT payload"),null)}catch(s){return Wc("Caught error parsing JWT payload as JSON",s==null?void 0:s.toString()),null}}function uy(t){const e=Up(t);return ie(e,"internal-error"),ie(typeof e.exp<"u","internal-error"),ie(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 tl(t,e,n=!1){if(n)return e;try{return await e}catch(r){throw r instanceof mr&&SS(r)&&t.auth.currentUser===t&&await t.auth.signOut(),r}}function SS({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 IS{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 s=((n=this.user.stsTokenManager.expirationTime)!==null&&n!==void 0?n:0)-Date.now()-3e5;return Math.max(0,s)}}schedule(e=!1){if(!this.isRunning)return;const n=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},n)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){(e==null?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 Ef{constructor(e,n){this.createdAt=e,this.lastLoginAt=n,this._initializeTime()}_initializeTime(){this.lastSignInTime=Ra(this.lastLoginAt),this.creationTime=Ra(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 Cu(t){var e;const n=t.auth,r=await t.getIdToken(),s=await tl(t,K_(n,{idToken:r}));ie(s==null?void 0:s.users.length,n,"internal-error");const i=s.users[0];t._notifyReloadListener(i);const o=!((e=i.providerUserInfo)===null||e===void 0)&&e.length?Q_(i.providerUserInfo):[],l=bS(t.providerData,o),c=t.isAnonymous,h=!(t.email&&i.passwordHash)&&!(l!=null&&l.length),m=c?h:!1,v={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:l,metadata:new Ef(i.createdAt,i.lastLoginAt),isAnonymous:m};Object.assign(t,v)}async function CS(t){const e=Ge(t);await Cu(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function bS(t,e){return[...t.filter(r=>!e.some(s=>s.providerId===r.providerId)),...e]}function Q_(t){return t.map(e=>{var{providerId:n}=e,r=Mp(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 AS(t,e){const n=await H_(t,{},async()=>{const r=ml({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:s,apiKey:i}=t.config,o=G_(t,s,"/v1/token",`key=${i}`),l=await t._getAdditionalHeaders();return l["Content-Type"]="application/x-www-form-urlencoded",q_.fetch()(o,{method:"POST",headers:l,body:r})});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async function NS(t,e){return yr(t,"POST","/v2/accounts:revokeToken",gr(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. */class so{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){ie(e.idToken,"internal-error"),ie(typeof e.idToken<"u","internal-error"),ie(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)}updateFromIdToken(e){ie(e.length!==0,"internal-error");const n=uy(e);this.updateTokensAndExpiration(e,null,n)}async getToken(e,n=!1){return!n&&this.accessToken&&!this.isExpired?this.accessToken:(ie(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,n){const{accessToken:r,refreshToken:s,expiresIn:i}=await AS(e,n);this.updateTokensAndExpiration(r,s,Number(i))}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:s,expirationTime:i}=n,o=new so;return r&&(ie(typeof r=="string","internal-error",{appName:e}),o.refreshToken=r),s&&(ie(typeof s=="string","internal-error",{appName:e}),o.accessToken=s),i&&(ie(typeof i=="number","internal-error",{appName:e}),o.expirationTime=i),o}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 so,this.toJSON())}_performRefresh(){return er("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 Or(t,e){ie(typeof t=="string"||typeof t>"u","internal-error",{appName:e})}class tr{constructor(e){var{uid:n,auth:r,stsTokenManager:s}=e,i=Mp(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new IS(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=n,this.auth=r,this.stsTokenManager=s,this.accessToken=s.accessToken,this.displayName=i.displayName||null,this.email=i.email||null,this.emailVerified=i.emailVerified||!1,this.phoneNumber=i.phoneNumber||null,this.photoURL=i.photoURL||null,this.isAnonymous=i.isAnonymous||!1,this.tenantId=i.tenantId||null,this.providerData=i.providerData?[...i.providerData]:[],this.metadata=new Ef(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){const n=await tl(this,this.stsTokenManager.getToken(this.auth,e));return ie(n,this.auth,"internal-error"),this.accessToken!==n&&(this.accessToken=n,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),n}getIdTokenResult(e){return TS(this,e)}reload(){return CS(this)}_assign(e){this!==e&&(ie(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){const n=new tr(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return n.metadata._copy(this.metadata),n}_onReload(e){ie(!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 Cu(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(On(this.auth.app))return Promise.reject(sr(this.auth));const e=await this.getIdToken();return await tl(this,kS(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,s,i,o,l,c,h,m;const v=(r=n.displayName)!==null&&r!==void 0?r:void 0,g=(s=n.email)!==null&&s!==void 0?s:void 0,N=(i=n.phoneNumber)!==null&&i!==void 0?i:void 0,L=(o=n.photoURL)!==null&&o!==void 0?o:void 0,O=(l=n.tenantId)!==null&&l!==void 0?l:void 0,z=(c=n._redirectEventId)!==null&&c!==void 0?c:void 0,I=(h=n.createdAt)!==null&&h!==void 0?h:void 0,x=(m=n.lastLoginAt)!==null&&m!==void 0?m:void 0,{uid:b,emailVerified:F,isAnonymous:K,providerData:H,stsTokenManager:k}=n;ie(b&&k,e,"internal-error");const _=so.fromJSON(this.name,k);ie(typeof b=="string",e,"internal-error"),Or(v,e.name),Or(g,e.name),ie(typeof F=="boolean",e,"internal-error"),ie(typeof K=="boolean",e,"internal-error"),Or(N,e.name),Or(L,e.name),Or(O,e.name),Or(z,e.name),Or(I,e.name),Or(x,e.name);const w=new tr({uid:b,auth:e,email:g,emailVerified:F,displayName:v,isAnonymous:K,photoURL:L,phoneNumber:N,tenantId:O,stsTokenManager:_,createdAt:I,lastLoginAt:x});return H&&Array.isArray(H)&&(w.providerData=H.map(S=>Object.assign({},S))),z&&(w._redirectEventId=z),w}static async _fromIdTokenResponse(e,n,r=!1){const s=new so;s.updateFromServerResponse(n);const i=new tr({uid:n.localId,auth:e,stsTokenManager:s,isAnonymous:r});return await Cu(i),i}static async _fromGetAccountInfoResponse(e,n,r){const s=n.users[0];ie(s.localId!==void 0,"internal-error");const i=s.providerUserInfo!==void 0?Q_(s.providerUserInfo):[],o=!(s.email&&s.passwordHash)&&!(i!=null&&i.length),l=new so;l.updateFromIdToken(r);const c=new tr({uid:s.localId,auth:e,stsTokenManager:l,isAnonymous:o}),h={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:i,metadata:new Ef(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!(i!=null&&i.length)};return Object.assign(c,h),c}}/** * @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 dy=new Map;function nr(t){dr(t instanceof Function,"Expected a class definition");let e=dy.get(t);return e?(dr(e instanceof t,"Instance stored in cache mismatched with class"),e):(e=new t,dy.set(t,e),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 Y_{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){}}Y_.type="NONE";const hy=Y_;/** * @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 qc(t,e,n){return`firebase:${t}:${e}:${n}`}class io{constructor(e,n,r){this.persistence=e,this.auth=n,this.userKey=r;const{config:s,name:i}=this.auth;this.fullUserKey=qc(this.userKey,s.apiKey,i),this.fullPersistenceKey=qc("persistence",s.apiKey,i),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?tr._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 io(nr(hy),e,r);const s=(await Promise.all(n.map(async h=>{if(await h._isAvailable())return h}))).filter(h=>h);let i=s[0]||nr(hy);const o=qc(r,e.config.apiKey,e.name);let l=null;for(const h of n)try{const m=await h._get(o);if(m){const v=tr._fromJSON(e,m);h!==i&&(l=v),i=h;break}}catch{}const c=s.filter(h=>h._shouldAllowMigration);return!i._shouldAllowMigration||!c.length?new io(i,e,r):(i=c[0],l&&await i._set(o,l.toJSON()),await Promise.all(n.map(async h=>{if(h!==i)try{await h._remove(o)}catch{}})),new io(i,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 fy(t){const e=t.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(ew(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(X_(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(nw(e))return"Blackberry";if(rw(e))return"Webos";if(J_(e))return"Safari";if((e.includes("chrome/")||Z_(e))&&!e.includes("edge/"))return"Chrome";if(tw(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 X_(t=bt()){return/firefox\//i.test(t)}function J_(t=bt()){const e=t.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function Z_(t=bt()){return/crios\//i.test(t)}function ew(t=bt()){return/iemobile/i.test(t)}function tw(t=bt()){return/android/i.test(t)}function nw(t=bt()){return/blackberry/i.test(t)}function rw(t=bt()){return/webos/i.test(t)}function zp(t=bt()){return/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&/mobile/i.test(t)}function PS(t=bt()){var e;return zp(t)&&!!(!((e=window.navigator)===null||e===void 0)&&e.standalone)}function RS(){return K1()&&document.documentMode===10}function sw(t=bt()){return zp(t)||tw(t)||rw(t)||nw(t)||/windows phone/i.test(t)||ew(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 iw(t,e=[]){let n;switch(t){case"Browser":n=fy(bt());break;case"Worker":n=`${fy(bt())}-${t}`;break;default:n=t}const r=e.length?e.join(","):"FirebaseCore-web";return`${n}/JsCore/${Co}/${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 DS{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,n){const r=i=>new Promise((o,l)=>{try{const c=e(i);o(c)}catch(c){l(c)}});r.onAbort=n,this.queue.push(r);const s=this.queue.length-1;return()=>{this.queue[s]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const n=[];try{for(const r of this.queue)await r(e),r.onAbort&&n.push(r.onAbort)}catch(r){n.reverse();for(const s of n)try{s()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r==null?void 0:r.message})}}}/** * @license * Copyright 2023 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 jS(t,e={}){return yr(t,"GET","/v2/passwordPolicy",gr(t,e))}/** * @license * Copyright 2023 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 LS=6;class OS{constructor(e){var n,r,s,i;const o=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=(n=o.minPasswordLength)!==null&&n!==void 0?n:LS,o.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=o.maxPasswordLength),o.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=o.containsLowercaseCharacter),o.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=o.containsUppercaseCharacter),o.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=o.containsNumericCharacter),o.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=o.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=(s=(r=e.allowedNonAlphanumericCharacters)===null||r===void 0?void 0:r.join(""))!==null&&s!==void 0?s:"",this.forceUpgradeOnSignin=(i=e.forceUpgradeOnSignin)!==null&&i!==void 0?i:!1,this.schemaVersion=e.schemaVersion}validatePassword(e){var n,r,s,i,o,l;const c={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,c),this.validatePasswordCharacterOptions(e,c),c.isValid&&(c.isValid=(n=c.meetsMinPasswordLength)!==null&&n!==void 0?n:!0),c.isValid&&(c.isValid=(r=c.meetsMaxPasswordLength)!==null&&r!==void 0?r:!0),c.isValid&&(c.isValid=(s=c.containsLowercaseLetter)!==null&&s!==void 0?s:!0),c.isValid&&(c.isValid=(i=c.containsUppercaseLetter)!==null&&i!==void 0?i:!0),c.isValid&&(c.isValid=(o=c.containsNumericCharacter)!==null&&o!==void 0?o:!0),c.isValid&&(c.isValid=(l=c.containsNonAlphanumericCharacter)!==null&&l!==void 0?l:!0),c}validatePasswordLengthOptions(e,n){const r=this.customStrengthOptions.minPasswordLength,s=this.customStrengthOptions.maxPasswordLength;r&&(n.meetsMinPasswordLength=e.length>=r),s&&(n.meetsMaxPasswordLength=e.length<=s)}validatePasswordCharacterOptions(e,n){this.updatePasswordCharacterOptionsStatuses(n,!1,!1,!1,!1);let r;for(let s=0;s="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,n,r,s,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=n)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=s)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=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. */class MS{constructor(e,n,r,s){this.app=e,this.heartbeatServiceProvider=n,this.appCheckServiceProvider=r,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new py(this),this.idTokenSubscription=new py(this),this.beforeStateQueue=new DS(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=$_,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=s.sdkClientVersion}_initializeWithPersistence(e,n){return n&&(this._popupRedirectResolver=nr(n)),this._initializationPromise=this.queue(async()=>{var r,s;if(!this._deleted&&(this.persistenceManager=await io.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=((s=this.currentUser)===null||s===void 0?void 0:s.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 initializeCurrentUserFromIdToken(e){try{const n=await K_(this,{idToken:e}),r=await tr._fromGetAccountInfoResponse(this,n,e);await this.directlySetCurrentUser(r)}catch(n){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",n),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var n;if(On(this.app)){const o=this.app.settings.authIdToken;return o?new Promise(l=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(o).then(l,l))}):this.directlySetCurrentUser(null)}const r=await this.assertedPersistence.getCurrentUser();let s=r,i=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const o=(n=this.redirectUser)===null||n===void 0?void 0:n._redirectEventId,l=s==null?void 0:s._redirectEventId,c=await this.tryRedirectSignIn(e);(!o||o===l)&&(c!=null&&c.user)&&(s=c.user,i=!0)}if(!s)return this.directlySetCurrentUser(null);if(!s._redirectEventId){if(i)try{await this.beforeStateQueue.runMiddleware(s)}catch(o){s=r,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(o))}return s?this.reloadAndSetCurrentUserOrClear(s):this.directlySetCurrentUser(null)}return ie(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===s._redirectEventId?this.directlySetCurrentUser(s):this.reloadAndSetCurrentUserOrClear(s)}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){try{await Cu(e)}catch(n){if((n==null?void 0:n.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=gS()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(On(this.app))return Promise.reject(sr(this));const n=e?Ge(e):null;return n&&ie(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&&ie(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 On(this.app)?Promise.reject(sr(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return On(this.app)?Promise.reject(sr(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(nr(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const n=this._getPasswordPolicyInternal();return n.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):n.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await jS(this),n=new OS(e);this.tenantId===null?this._projectPasswordPolicy=n:this._tenantPasswordPolicies[this.tenantId]=n}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(e){this._errorFactory=new pl("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)}authStateReady(){return new Promise((e,n)=>{if(this.currentUser)e();else{const r=this.onAuthStateChanged(()=>{r(),e()},n)}})}async revokeAccessToken(e){if(this.currentUser){const n=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:n};this.tenantId!=null&&(r.tenantId=this.tenantId),await NS(this,r)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)===null||e===void 0?void 0:e.toJSON()}}async _setRedirectUser(e,n){const r=await this.getOrInitRedirectPersistenceManager(n);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const n=e&&nr(e)||this._popupRedirectResolver;ie(n,this,"argument-error"),this.redirectPersistenceManager=await io.create(this,[nr(n._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var n,r;return this._isInitialized&&await this.queue(async()=>{}),((n=this._currentUser)===null||n===void 0?void 0:n._redirectEventId)===e?this._currentUser:((r=this.redirectUser)===null||r===void 0?void 0:r._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,n;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const r=(n=(e=this.currentUser)===null||e===void 0?void 0:e.uid)!==null&&n!==void 0?n:null;this.lastNotifiedUid!==r&&(this.lastNotifiedUid=r,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,n,r,s){if(this._deleted)return()=>{};const i=typeof n=="function"?n:n.next.bind(n);let o=!1;const l=this._isInitialized?Promise.resolve():this._initializationPromise;if(ie(l,this,"internal-error"),l.then(()=>{o||i(this.currentUser)}),typeof n=="function"){const c=e.addObserver(n,r,s);return()=>{o=!0,c()}}else{const c=e.addObserver(n);return()=>{o=!0,c()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return ie(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=iw(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const n={"X-Client-Version":this.clientVersion};this.app.options.appId&&(n["X-Firebase-gmpid"]=this.app.options.appId);const r=await((e=this.heartbeatServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getHeartbeatsHeader());r&&(n["X-Firebase-Client"]=r);const s=await this._getAppCheckToken();return s&&(n["X-Firebase-AppCheck"]=s),n}async _getAppCheckToken(){var e;const n=await((e=this.appCheckServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getToken());return n!=null&&n.error&&fS(`Error while retrieving App Check token: ${n.error}`),n==null?void 0:n.token}}function ps(t){return Ge(t)}class py{constructor(e){this.auth=e,this.observer=null,this.addObserver=nT(n=>this.observer=n)}get next(){return ie(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/** * @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. */let id={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function VS(t){id=t}function ow(t){return id.loadJS(t)}function FS(){return id.recaptchaEnterpriseScript}function US(){return id.gapiScript}function zS(t){return`__${t}${Math.floor(Math.random()*1e6)}`}const BS="recaptcha-enterprise",$S="NO_RECAPTCHA";class WS{constructor(e){this.type=BS,this.auth=ps(e)}async verify(e="verify",n=!1){async function r(i){if(!n){if(i.tenantId==null&&i._agentRecaptchaConfig!=null)return i._agentRecaptchaConfig.siteKey;if(i.tenantId!=null&&i._tenantRecaptchaConfigs[i.tenantId]!==void 0)return i._tenantRecaptchaConfigs[i.tenantId].siteKey}return new Promise(async(o,l)=>{ES(i,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(c=>{if(c.recaptchaKey===void 0)l(new Error("recaptcha Enterprise site key undefined"));else{const h=new xS(c);return i.tenantId==null?i._agentRecaptchaConfig=h:i._tenantRecaptchaConfigs[i.tenantId]=h,o(h.siteKey)}}).catch(c=>{l(c)})})}function s(i,o,l){const c=window.grecaptcha;cy(c)?c.enterprise.ready(()=>{c.enterprise.execute(i,{action:e}).then(h=>{o(h)}).catch(()=>{o($S)})}):l(Error("No reCAPTCHA enterprise script loaded."))}return new Promise((i,o)=>{r(this.auth).then(l=>{if(!n&&cy(window.grecaptcha))s(l,i,o);else{if(typeof window>"u"){o(new Error("RecaptchaVerifier is only supported in browser"));return}let c=FS();c.length!==0&&(c+=l),ow(c).then(()=>{s(l,i,o)}).catch(h=>{o(h)})}}).catch(l=>{o(l)})})}}async function my(t,e,n,r=!1){const s=new WS(t);let i;try{i=await s.verify(n)}catch{i=await s.verify(n,!0)}const o=Object.assign({},e);return r?Object.assign(o,{captchaResp:i}):Object.assign(o,{captchaResponse:i}),Object.assign(o,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(o,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),o}async function bu(t,e,n,r){var s;if(!((s=t._getRecaptchaConfig())===null||s===void 0)&&s.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const i=await my(t,e,n,n==="getOobCode");return r(t,i)}else return r(t,e).catch(async i=>{if(i.code==="auth/missing-recaptcha-token"){console.log(`${n} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const o=await my(t,e,n,n==="getOobCode");return r(t,o)}else return Promise.reject(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. */function qS(t,e){const n=Op(t,"auth");if(n.isInitialized()){const s=n.getImmediate(),i=n.getOptions();if(Tu(i,e??{}))return s;kn(s,"already-initialized")}return n.initialize({options:e})}function HS(t,e){const n=(e==null?void 0:e.persistence)||[],r=(Array.isArray(n)?n:[n]).map(nr);e!=null&&e.errorMap&&t._updateErrorMap(e.errorMap),t._initializeWithPersistence(r,e==null?void 0:e.popupRedirectResolver)}function GS(t,e,n){const r=ps(t);ie(r._canInitEmulator,r,"emulator-config-failed"),ie(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const s=!1,i=aw(e),{host:o,port:l}=KS(e),c=l===null?"":`:${l}`;r.config.emulator={url:`${i}//${o}${c}/`},r.settings.appVerificationDisabledForTesting=!0,r.emulatorConfig=Object.freeze({host:o,port:l,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:s})}),QS()}function aw(t){const e=t.indexOf(":");return e<0?"":t.substr(0,e+1)}function KS(t){const e=aw(t),n=/(\/\/)?([^?#/]+)/.exec(t.substr(e.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(r);if(s){const i=s[1];return{host:i,port:gy(r.substr(i.length+1))}}else{const[i,o]=r.split(":");return{host:i,port:gy(o)}}}function gy(t){if(!t)return null;const e=Number(t);return isNaN(e)?null:e}function QS(){function t(){const e=document.createElement("p"),n=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",n.position="fixed",n.width="100%",n.backgroundColor="#ffffff",n.border=".1em solid #000000",n.color="#b50000",n.bottom="0px",n.left="0px",n.margin="0px",n.zIndex="10000",n.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",t):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 Bp{constructor(e,n){this.providerId=e,this.signInMethod=n}toJSON(){return er("not implemented")}_getIdTokenResponse(e){return er("not implemented")}_linkToIdToken(e,n){return er("not implemented")}_getReauthenticationResolver(e){return er("not implemented")}}async function YS(t,e){return yr(t,"POST","/v1/accounts:signUp",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. */async function XS(t,e){return yl(t,"POST","/v1/accounts:signInWithPassword",gr(t,e))}async function JS(t,e){return yr(t,"POST","/v1/accounts:sendOobCode",gr(t,e))}async function ZS(t,e){return JS(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. */async function eI(t,e){return yl(t,"POST","/v1/accounts:signInWithEmailLink",gr(t,e))}async function tI(t,e){return yl(t,"POST","/v1/accounts:signInWithEmailLink",gr(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. */class nl extends Bp{constructor(e,n,r,s=null){super("password",r),this._email=e,this._password=n,this._tenantId=s}static _fromEmailAndPassword(e,n){return new nl(e,n,"password")}static _fromEmailAndCode(e,n,r=null){return new nl(e,n,"emailLink",r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const n=typeof e=="string"?JSON.parse(e):e;if(n!=null&&n.email&&(n!=null&&n.password)){if(n.signInMethod==="password")return this._fromEmailAndPassword(n.email,n.password);if(n.signInMethod==="emailLink")return this._fromEmailAndCode(n.email,n.password,n.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":const n={returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return bu(e,n,"signInWithPassword",XS);case"emailLink":return eI(e,{email:this._email,oobCode:this._password});default:kn(e,"internal-error")}}async _linkToIdToken(e,n){switch(this.signInMethod){case"password":const r={idToken:n,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return bu(e,r,"signUpPassword",YS);case"emailLink":return tI(e,{idToken:n,email:this._email,oobCode:this._password});default:kn(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(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. */async function oo(t,e){return yl(t,"POST","/v1/accounts:signInWithIdp",gr(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 nI="http://localhost";class Zs extends Bp{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const n=new Zs(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):kn("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:s}=n,i=Mp(n,["providerId","signInMethod"]);if(!r||!s)return null;const o=new Zs(r,s);return o.idToken=i.idToken||void 0,o.accessToken=i.accessToken||void 0,o.secret=i.secret,o.nonce=i.nonce,o.pendingToken=i.pendingToken||null,o}_getIdTokenResponse(e){const n=this.buildRequest();return oo(e,n)}_linkToIdToken(e,n){const r=this.buildRequest();return r.idToken=n,oo(e,r)}_getReauthenticationResolver(e){const n=this.buildRequest();return n.autoCreate=!1,oo(e,n)}buildRequest(){const e={requestUri:nI,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=ml(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. */function rI(t){switch(t){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}function sI(t){const e=ya(va(t)).link,n=e?ya(va(e)).deep_link_id:null,r=ya(va(t)).deep_link_id;return(r?ya(va(r)).link:null)||r||n||e||t}class $p{constructor(e){var n,r,s,i,o,l;const c=ya(va(e)),h=(n=c.apiKey)!==null&&n!==void 0?n:null,m=(r=c.oobCode)!==null&&r!==void 0?r:null,v=rI((s=c.mode)!==null&&s!==void 0?s:null);ie(h&&m&&v,"argument-error"),this.apiKey=h,this.operation=v,this.code=m,this.continueUrl=(i=c.continueUrl)!==null&&i!==void 0?i:null,this.languageCode=(o=c.languageCode)!==null&&o!==void 0?o:null,this.tenantId=(l=c.tenantId)!==null&&l!==void 0?l:null}static parseLink(e){const n=sI(e);try{return new $p(n)}catch{return 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 bo{constructor(){this.providerId=bo.PROVIDER_ID}static credential(e,n){return nl._fromEmailAndPassword(e,n)}static credentialWithLink(e,n){const r=$p.parseLink(n);return ie(r,"argument-error"),nl._fromEmailAndCode(e,r.code,r.tenantId)}}bo.PROVIDER_ID="password";bo.EMAIL_PASSWORD_SIGN_IN_METHOD="password";bo.EMAIL_LINK_SIGN_IN_METHOD="emailLink";/** * @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 lw{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 vl extends lw{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 zr extends vl{constructor(){super("facebook.com")}static credential(e){return Zs._fromParams({providerId:zr.PROVIDER_ID,signInMethod:zr.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return zr.credentialFromTaggedObject(e)}static credentialFromError(e){return zr.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return zr.credential(e.oauthAccessToken)}catch{return null}}}zr.FACEBOOK_SIGN_IN_METHOD="facebook.com";zr.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 Br extends vl{constructor(){super("google.com"),this.addScope("profile")}static credential(e,n){return Zs._fromParams({providerId:Br.PROVIDER_ID,signInMethod:Br.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:n})}static credentialFromResult(e){return Br.credentialFromTaggedObject(e)}static credentialFromError(e){return Br.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:n,oauthAccessToken:r}=e;if(!n&&!r)return null;try{return Br.credential(n,r)}catch{return null}}}Br.GOOGLE_SIGN_IN_METHOD="google.com";Br.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 $r extends vl{constructor(){super("github.com")}static credential(e){return Zs._fromParams({providerId:$r.PROVIDER_ID,signInMethod:$r.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return $r.credentialFromTaggedObject(e)}static credentialFromError(e){return $r.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return $r.credential(e.oauthAccessToken)}catch{return null}}}$r.GITHUB_SIGN_IN_METHOD="github.com";$r.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 Wr extends vl{constructor(){super("twitter.com")}static credential(e,n){return Zs._fromParams({providerId:Wr.PROVIDER_ID,signInMethod:Wr.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:n})}static credentialFromResult(e){return Wr.credentialFromTaggedObject(e)}static credentialFromError(e){return Wr.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:n,oauthTokenSecret:r}=e;if(!n||!r)return null;try{return Wr.credential(n,r)}catch{return null}}}Wr.TWITTER_SIGN_IN_METHOD="twitter.com";Wr.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. */async function iI(t,e){return yl(t,"POST","/v1/accounts:signUp",gr(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. */class ei{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,n,r,s=!1){const i=await tr._fromIdTokenResponse(e,r,s),o=yy(r);return new ei({user:i,providerId:o,_tokenResponse:r,operationType:n})}static async _forOperation(e,n,r){await e._updateTokensIfNecessary(r,!0);const s=yy(r);return new ei({user:e,providerId:s,_tokenResponse:r,operationType:n})}}function yy(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 Au extends mr{constructor(e,n,r,s){var i;super(n.code,n.message),this.operationType=r,this.user=s,Object.setPrototypeOf(this,Au.prototype),this.customData={appName:e.name,tenantId:(i=e.tenantId)!==null&&i!==void 0?i:void 0,_serverResponse:n.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,n,r,s){return new Au(e,n,r,s)}}function cw(t,e,n,r){return(e==="reauthenticate"?n._getReauthenticationResolver(t):n._getIdTokenResponse(t)).catch(i=>{throw i.code==="auth/multi-factor-auth-required"?Au._fromErrorAndOperation(t,i,e,r):i})}async function oI(t,e,n=!1){const r=await tl(t,e._linkToIdToken(t.auth,await t.getIdToken()),n);return ei._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 aI(t,e,n=!1){const{auth:r}=t;if(On(r.app))return Promise.reject(sr(r));const s="reauthenticate";try{const i=await tl(t,cw(r,s,e,t),n);ie(i.idToken,r,"internal-error");const o=Up(i.idToken);ie(o,r,"internal-error");const{sub:l}=o;return ie(t.uid===l,r,"user-mismatch"),ei._forOperation(t,s,i)}catch(i){throw(i==null?void 0:i.code)==="auth/user-not-found"&&kn(r,"user-mismatch"),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 uw(t,e,n=!1){if(On(t.app))return Promise.reject(sr(t));const r="signIn",s=await cw(t,r,e),i=await ei._fromIdTokenResponse(t,r,s);return n||await t._updateCurrentUser(i.user),i}async function lI(t,e){return uw(ps(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. */async function dw(t){const e=ps(t);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}async function cI(t,e,n){const r=ps(t);await bu(r,{requestType:"PASSWORD_RESET",email:e,clientType:"CLIENT_TYPE_WEB"},"getOobCode",ZS)}async function uI(t,e,n){if(On(t.app))return Promise.reject(sr(t));const r=ps(t),o=await bu(r,{returnSecureToken:!0,email:e,password:n,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",iI).catch(c=>{throw c.code==="auth/password-does-not-meet-requirements"&&dw(t),c}),l=await ei._fromIdTokenResponse(r,"signIn",o);return await r._updateCurrentUser(l.user),l}function dI(t,e,n){return On(t.app)?Promise.reject(sr(t)):lI(Ge(t),bo.credential(e,n)).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&dw(t),r})}function hI(t,e,n,r){return Ge(t).onIdTokenChanged(e,n,r)}function fI(t,e,n){return Ge(t).beforeAuthStateChanged(e,n)}function pI(t,e,n,r){return Ge(t).onAuthStateChanged(e,n,r)}function mI(t){return Ge(t).signOut()}const Nu="__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 hw{constructor(e,n){this.storageRetriever=e,this.type=n}_isAvailable(){try{return this.storage?(this.storage.setItem(Nu,"1"),this.storage.removeItem(Nu),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. */const gI=1e3,yI=10;class fw extends hw{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,n)=>this.onStorageEvent(e,n),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=sw(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const n of Object.keys(this.listeners)){const r=this.storage.getItem(n),s=this.localCache[n];r!==s&&e(n,s,r)}}onStorageEvent(e,n=!1){if(!e.key){this.forAllChangedKeys((o,l,c)=>{this.notifyListeners(o,c)});return}const r=e.key;n?this.detachListener():this.stopPolling();const s=()=>{const o=this.storage.getItem(r);!n&&this.localCache[r]===o||this.notifyListeners(r,o)},i=this.storage.getItem(r);RS()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(s,yI):s()}notifyListeners(e,n){this.localCache[e]=n;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(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)})},gI)}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]}}fw.type="LOCAL";const vI=fw;/** * @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 pw extends hw{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,n){}_removeListener(e,n){}}pw.type="SESSION";const mw=pw;/** * @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 _I(t){return Promise.all(t.map(async e=>{try{return{fulfilled:!0,value:await e}}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 od{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const n=this.receivers.find(s=>s.isListeningto(e));if(n)return n;const r=new od(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const n=e,{eventId:r,eventType:s,data:i}=n.data,o=this.handlersMap[s];if(!(o!=null&&o.size))return;n.ports[0].postMessage({status:"ack",eventId:r,eventType:s});const l=Array.from(o).map(async h=>h(n.origin,i)),c=await _I(l);n.ports[0].postMessage({status:"done",eventId:r,eventType:s,response:c})}_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)}}od.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 Wp(t="",e=10){let n="";for(let r=0;r{const h=Wp("",20);s.port1.start();const m=setTimeout(()=>{c(new Error("unsupported_event"))},r);o={messageChannel:s,onMessage(v){const g=v;if(g.data.eventId===h)switch(g.data.status){case"ack":clearTimeout(m),i=setTimeout(()=>{c(new Error("timeout"))},3e3);break;case"done":clearTimeout(i),l(g.data.response);break;default:clearTimeout(m),clearTimeout(i),c(new Error("invalid_response"));break}}},this.handlers.add(o),s.port1.addEventListener("message",o.onMessage),this.target.postMessage({eventType:e,eventId:h,data:n},[s.port2])}).finally(()=>{o&&this.removeMessageHandler(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 Un(){return window}function xI(t){Un().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 gw(){return typeof Un().WorkerGlobalScope<"u"&&typeof Un().importScripts=="function"}async function EI(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function kI(){var t;return((t=navigator==null?void 0:navigator.serviceWorker)===null||t===void 0?void 0:t.controller)||null}function TI(){return gw()?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 yw="firebaseLocalStorageDb",SI=1,Pu="firebaseLocalStorage",vw="fbase_key";class _l{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 ad(t,e){return t.transaction([Pu],e?"readwrite":"readonly").objectStore(Pu)}function II(){const t=indexedDB.deleteDatabase(yw);return new _l(t).toPromise()}function kf(){const t=indexedDB.open(yw,SI);return new Promise((e,n)=>{t.addEventListener("error",()=>{n(t.error)}),t.addEventListener("upgradeneeded",()=>{const r=t.result;try{r.createObjectStore(Pu,{keyPath:vw})}catch(s){n(s)}}),t.addEventListener("success",async()=>{const r=t.result;r.objectStoreNames.contains(Pu)?e(r):(r.close(),await II(),e(await kf()))})})}async function vy(t,e,n){const r=ad(t,!0).put({[vw]:e,value:n});return new _l(r).toPromise()}async function CI(t,e){const n=ad(t,!1).get(e),r=await new _l(n).toPromise();return r===void 0?null:r.value}function _y(t,e){const n=ad(t,!0).delete(e);return new _l(n).toPromise()}const bI=800,AI=3;class _w{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 kf(),this.db)}async _withRetries(e){let n=0;for(;;)try{const r=await this._openDb();return await e(r)}catch(r){if(n++>AI)throw r;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return gw()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=od._getInstance(TI()),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 EI(),!this.activeServiceWorker)return;this.sender=new wI(this.activeServiceWorker);const r=await this.sender._send("ping",{},800);r&&!((e=r[0])===null||e===void 0)&&e.fulfilled&&!((n=r[0])===null||n===void 0)&&n.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||kI()!==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 kf();return await vy(e,Nu,"1"),await _y(e,Nu),!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=>vy(r,e,n)),this.localCache[e]=n,this.notifyServiceWorker(e)))}async _get(e){const n=await this._withRetries(r=>CI(r,e));return this.localCache[e]=n,n}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(n=>_y(n,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(s=>{const i=ad(s,!1).getAll();return new _l(i).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const n=[],r=new Set;if(e.length!==0)for(const{fbase_key:s,value:i}of e)r.add(s),JSON.stringify(this.localCache[s])!==JSON.stringify(i)&&(this.notifyListeners(s,i),n.push(s));for(const s of Object.keys(this.localCache))this.localCache[s]&&!r.has(s)&&(this.notifyListeners(s,null),n.push(s));return n}notifyListeners(e,n){this.localCache[e]=n;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(n)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),bI)}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(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.stopPolling()}}_w.type="LOCAL";const NI=_w;new gl(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 PI(t,e){return e?nr(e):(ie(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 qp extends Bp{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return oo(e,this._buildIdpRequest())}_linkToIdToken(e,n){return oo(e,this._buildIdpRequest(n))}_getReauthenticationResolver(e){return oo(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 RI(t){return uw(t.auth,new qp(t),t.bypassAuthState)}function DI(t){const{auth:e,user:n}=t;return ie(n,e,"internal-error"),aI(n,new qp(t),t.bypassAuthState)}async function jI(t){const{auth:e,user:n}=t;return ie(n,e,"internal-error"),oI(n,new qp(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 ww{constructor(e,n,r,s,i=!1){this.auth=e,this.resolver=r,this.user=s,this.bypassAuthState=i,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:s,tenantId:i,error:o,type:l}=e;if(o){this.reject(o);return}const c={auth:this.auth,requestUri:n,sessionId:r,tenantId:i||void 0,postBody:s||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(l)(c))}catch(h){this.reject(h)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return RI;case"linkViaPopup":case"linkViaRedirect":return jI;case"reauthViaPopup":case"reauthViaRedirect":return DI;default:kn(this.auth,"internal-error")}}resolve(e){dr(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){dr(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 LI=new gl(2e3,1e4);class Xi extends ww{constructor(e,n,r,s,i){super(e,n,s,i),this.provider=r,this.authWindow=null,this.pollId=null,Xi.currentPopupAction&&Xi.currentPopupAction.cancel(),Xi.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return ie(e,this.auth,"internal-error"),e}async onExecution(){dr(this.filter.length===1,"Popup operations only handle one event");const e=Wp();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(Fn(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(Fn(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Xi.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(Fn(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,LI.get())};e()}}Xi.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 OI="pendingRedirect",Hc=new Map;class MI extends ww{constructor(e,n,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],n,void 0,r),this.eventId=null}async execute(){let e=Hc.get(this.auth._key());if(!e){try{const r=await VI(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(n){e=()=>Promise.reject(n)}Hc.set(this.auth._key(),e)}return this.bypassAuthState||Hc.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 VI(t,e){const n=zI(e),r=UI(t);if(!await r._isAvailable())return!1;const s=await r._get(n)==="true";return await r._remove(n),s}function FI(t,e){Hc.set(t._key(),e)}function UI(t){return nr(t._redirectPersistence)}function zI(t){return qc(OI,t.config.apiKey,t.name)}async function BI(t,e,n=!1){if(On(t.app))return Promise.reject(sr(t));const r=ps(t),s=PI(r,e),o=await new MI(r,s,n).execute();return o&&!n&&(delete o.user._redirectEventId,await r._persistUserIfCurrent(o.user),await r._setRedirectUser(null,e)),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. */const $I=10*60*1e3;class WI{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||!qI(e)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=e,n=!0)),n}sendToConsumer(e,n){var r;if(e.error&&!xw(e)){const s=((r=e.error.code)===null||r===void 0?void 0:r.split("auth/")[1])||"internal-error";n.onError(Fn(this.auth,s))}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>=$I&&this.cachedEventUids.clear(),this.cachedEventUids.has(wy(e))}saveEventToCache(e){this.cachedEventUids.add(wy(e)),this.lastProcessedEventTime=Date.now()}}function wy(t){return[t.type,t.eventId,t.sessionId,t.tenantId].filter(e=>e).join("-")}function xw({type:t,error:e}){return t==="unknown"&&(e==null?void 0:e.code)==="auth/no-auth-event"}function qI(t){switch(t.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return xw(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 HI(t,e={}){return yr(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 GI=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,KI=/^https?/;async function QI(t){if(t.config.emulator)return;const{authorizedDomains:e}=await HI(t);for(const n of e)try{if(YI(n))return}catch{}kn(t,"unauthorized-domain")}function YI(t){const e=xf(),{protocol:n,hostname:r}=new URL(e);if(t.startsWith("chrome-extension://")){const o=new URL(t);return o.hostname===""&&r===""?n==="chrome-extension:"&&t.replace("chrome-extension://","")===e.replace("chrome-extension://",""):n==="chrome-extension:"&&o.hostname===r}if(!KI.test(n))return!1;if(GI.test(t))return r===t;const s=t.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","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 XI=new gl(3e4,6e4);function xy(){const t=Un().___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{var r,s,i;function o(){xy(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{xy(),n(Fn(t,"network-request-failed"))},timeout:XI.get()})}if(!((s=(r=Un().gapi)===null||r===void 0?void 0:r.iframes)===null||s===void 0)&&s.Iframe)e(gapi.iframes.getContext());else if(!((i=Un().gapi)===null||i===void 0)&&i.load)o();else{const l=zS("iframefcb");return Un()[l]=()=>{gapi.load?o():n(Fn(t,"network-request-failed"))},ow(`${US()}?onload=${l}`).catch(c=>n(c))}}).catch(e=>{throw Gc=null,e})}let Gc=null;function ZI(t){return Gc=Gc||JI(t),Gc}/** * @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 eC=new gl(5e3,15e3),tC="__/auth/iframe",nC="emulator/auth/iframe",rC={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},sC=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function iC(t){const e=t.config;ie(e.authDomain,t,"auth-domain-config-required");const n=e.emulator?Fp(e,nC):`https://${t.config.authDomain}/${tC}`,r={apiKey:e.apiKey,appName:t.name,v:Co},s=sC.get(t.config.apiHost);s&&(r.eid=s);const i=t._getFrameworks();return i.length&&(r.fw=i.join(",")),`${n}?${ml(r).slice(1)}`}async function oC(t){const e=await ZI(t),n=Un().gapi;return ie(n,t,"internal-error"),e.open({where:document.body,url:iC(t),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:rC,dontclear:!0},r=>new Promise(async(s,i)=>{await r.restyle({setHideOnLeave:!1});const o=Fn(t,"network-request-failed"),l=Un().setTimeout(()=>{i(o)},eC.get());function c(){Un().clearTimeout(l),s(r)}r.ping(c).then(c,()=>{i(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. */const aC={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},lC=500,cC=600,uC="_blank",dC="http://localhost";class Ey{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function hC(t,e,n,r=lC,s=cC){const i=Math.max((window.screen.availHeight-s)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString();let l="";const c=Object.assign(Object.assign({},aC),{width:r.toString(),height:s.toString(),top:i,left:o}),h=bt().toLowerCase();n&&(l=Z_(h)?uC:n),X_(h)&&(e=e||dC,c.scrollbars="yes");const m=Object.entries(c).reduce((g,[N,L])=>`${g}${N}=${L},`,"");if(PS(h)&&l!=="_self")return fC(e||"",l),new Ey(null);const v=window.open(e||"",l,m);ie(v,t,"popup-blocked");try{v.focus()}catch{}return new Ey(v)}function fC(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 pC="__/auth/handler",mC="emulator/auth/handler",gC=encodeURIComponent("fac");async function ky(t,e,n,r,s,i){ie(t.config.authDomain,t,"auth-domain-config-required"),ie(t.config.apiKey,t,"invalid-api-key");const o={apiKey:t.config.apiKey,appName:t.name,authType:n,redirectUrl:r,v:Co,eventId:s};if(e instanceof lw){e.setDefaultLanguage(t.languageCode),o.providerId=e.providerId||"",tT(e.getCustomParameters())||(o.customParameters=JSON.stringify(e.getCustomParameters()));for(const[m,v]of Object.entries({}))o[m]=v}if(e instanceof vl){const m=e.getScopes().filter(v=>v!=="");m.length>0&&(o.scopes=m.join(","))}t.tenantId&&(o.tid=t.tenantId);const l=o;for(const m of Object.keys(l))l[m]===void 0&&delete l[m];const c=await t._getAppCheckToken(),h=c?`#${gC}=${encodeURIComponent(c)}`:"";return`${yC(t)}?${ml(l).slice(1)}${h}`}function yC({config:t}){return t.emulator?Fp(t,mC):`https://${t.authDomain}/${pC}`}/** * @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 gh="webStorageSupport";class vC{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=mw,this._completeRedirectFn=BI,this._overrideRedirectResult=FI}async _openPopup(e,n,r,s){var i;dr((i=this.eventManagers[e._key()])===null||i===void 0?void 0:i.manager,"_initialize() not called before _openPopup()");const o=await ky(e,n,r,xf(),s);return hC(e,o,Wp())}async _openRedirect(e,n,r,s){await this._originValidation(e);const i=await ky(e,n,r,xf(),s);return xI(i),new Promise(()=>{})}_initialize(e){const n=e._key();if(this.eventManagers[n]){const{manager:s,promise:i}=this.eventManagers[n];return s?Promise.resolve(s):(dr(i,"If manager is not set, promise should be"),i)}const r=this.initAndGetManager(e);return this.eventManagers[n]={promise:r},r.catch(()=>{delete this.eventManagers[n]}),r}async initAndGetManager(e){const n=await oC(e),r=new WI(e);return n.register("authEvent",s=>(ie(s==null?void 0:s.authEvent,e,"invalid-auth-event"),{status:r.onEvent(s.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(gh,{type:gh},s=>{var i;const o=(i=s==null?void 0:s[0])===null||i===void 0?void 0:i[gh];o!==void 0&&n(!!o),kn(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const n=e._key();return this.originValidationPromises[n]||(this.originValidationPromises[n]=QI(e)),this.originValidationPromises[n]}get _shouldInitProactively(){return sw()||J_()||zp()}}const _C=vC;var Ty="@firebase/auth",Sy="1.7.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. */class wC{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=>{e((r==null?void 0:r.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(){ie(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 xC(t){switch(t){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function EC(t){go(new Js("auth",(e,{options:n})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:o,authDomain:l}=r.options;ie(o&&!o.includes(":"),"invalid-api-key",{appName:r.name});const c={apiKey:o,authDomain:l,clientPlatform:t,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:iw(t)},h=new MS(r,s,i,c);return HS(h,n),h},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,n,r)=>{e.getProvider("auth-internal").initialize()})),go(new Js("auth-internal",e=>{const n=ps(e.getProvider("auth").getImmediate());return(r=>new wC(r))(n)},"PRIVATE").setInstantiationMode("EXPLICIT")),ss(Ty,Sy,xC(t)),ss(Ty,Sy,"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. */const kC=5*60,TC=L_("authIdTokenMaxAge")||kC;let Iy=null;const SC=t=>async e=>{const n=e&&await e.getIdTokenResult(),r=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(r&&r>TC)return;const s=n==null?void 0:n.token;Iy!==s&&(Iy=s,await fetch(t,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function IC(t=F_()){const e=Op(t,"auth");if(e.isInitialized())return e.getImmediate();const n=qS(t,{popupRedirectResolver:_C,persistence:[NI,vI,mw]}),r=L_("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const i=new URL(r,location.origin);if(location.origin===i.origin){const o=SC(i.toString());fI(n,o,()=>o(n.currentUser)),hI(n,l=>o(l))}}const s=D_("auth");return s&&GS(n,`http://${s}`),n}function CC(){var t,e;return(e=(t=document.getElementsByTagName("head"))===null||t===void 0?void 0:t[0])!==null&&e!==void 0?e:document}VS({loadJS(t){return new Promise((e,n)=>{const r=document.createElement("script");r.setAttribute("src",t),r.onload=e,r.onerror=s=>{const i=Fn("internal-error");i.customData=s,n(i)},r.type="text/javascript",r.charset="UTF-8",CC().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});EC("Browser");var Cy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license Copyright The Closure Library Authors. SPDX-License-Identifier: Apache-2.0 */var Hs,Ew;(function(){var t;/** @license Copyright The Closure Library Authors. SPDX-License-Identifier: Apache-2.0 */function e(k,_){function w(){}w.prototype=_.prototype,k.D=_.prototype,k.prototype=new w,k.prototype.constructor=k,k.C=function(S,A,R){for(var T=Array(arguments.length-2),Ke=2;KeA;++A)S[A]=_.charCodeAt(w++)|_.charCodeAt(w++)<<8|_.charCodeAt(w++)<<16|_.charCodeAt(w++)<<24;else for(A=0;16>A;++A)S[A]=_[w++]|_[w++]<<8|_[w++]<<16|_[w++]<<24;_=k.g[0],w=k.g[1],A=k.g[2];var R=k.g[3],T=_+(R^w&(A^R))+S[0]+3614090360&4294967295;_=w+(T<<7&4294967295|T>>>25),T=R+(A^_&(w^A))+S[1]+3905402710&4294967295,R=_+(T<<12&4294967295|T>>>20),T=A+(w^R&(_^w))+S[2]+606105819&4294967295,A=R+(T<<17&4294967295|T>>>15),T=w+(_^A&(R^_))+S[3]+3250441966&4294967295,w=A+(T<<22&4294967295|T>>>10),T=_+(R^w&(A^R))+S[4]+4118548399&4294967295,_=w+(T<<7&4294967295|T>>>25),T=R+(A^_&(w^A))+S[5]+1200080426&4294967295,R=_+(T<<12&4294967295|T>>>20),T=A+(w^R&(_^w))+S[6]+2821735955&4294967295,A=R+(T<<17&4294967295|T>>>15),T=w+(_^A&(R^_))+S[7]+4249261313&4294967295,w=A+(T<<22&4294967295|T>>>10),T=_+(R^w&(A^R))+S[8]+1770035416&4294967295,_=w+(T<<7&4294967295|T>>>25),T=R+(A^_&(w^A))+S[9]+2336552879&4294967295,R=_+(T<<12&4294967295|T>>>20),T=A+(w^R&(_^w))+S[10]+4294925233&4294967295,A=R+(T<<17&4294967295|T>>>15),T=w+(_^A&(R^_))+S[11]+2304563134&4294967295,w=A+(T<<22&4294967295|T>>>10),T=_+(R^w&(A^R))+S[12]+1804603682&4294967295,_=w+(T<<7&4294967295|T>>>25),T=R+(A^_&(w^A))+S[13]+4254626195&4294967295,R=_+(T<<12&4294967295|T>>>20),T=A+(w^R&(_^w))+S[14]+2792965006&4294967295,A=R+(T<<17&4294967295|T>>>15),T=w+(_^A&(R^_))+S[15]+1236535329&4294967295,w=A+(T<<22&4294967295|T>>>10),T=_+(A^R&(w^A))+S[1]+4129170786&4294967295,_=w+(T<<5&4294967295|T>>>27),T=R+(w^A&(_^w))+S[6]+3225465664&4294967295,R=_+(T<<9&4294967295|T>>>23),T=A+(_^w&(R^_))+S[11]+643717713&4294967295,A=R+(T<<14&4294967295|T>>>18),T=w+(R^_&(A^R))+S[0]+3921069994&4294967295,w=A+(T<<20&4294967295|T>>>12),T=_+(A^R&(w^A))+S[5]+3593408605&4294967295,_=w+(T<<5&4294967295|T>>>27),T=R+(w^A&(_^w))+S[10]+38016083&4294967295,R=_+(T<<9&4294967295|T>>>23),T=A+(_^w&(R^_))+S[15]+3634488961&4294967295,A=R+(T<<14&4294967295|T>>>18),T=w+(R^_&(A^R))+S[4]+3889429448&4294967295,w=A+(T<<20&4294967295|T>>>12),T=_+(A^R&(w^A))+S[9]+568446438&4294967295,_=w+(T<<5&4294967295|T>>>27),T=R+(w^A&(_^w))+S[14]+3275163606&4294967295,R=_+(T<<9&4294967295|T>>>23),T=A+(_^w&(R^_))+S[3]+4107603335&4294967295,A=R+(T<<14&4294967295|T>>>18),T=w+(R^_&(A^R))+S[8]+1163531501&4294967295,w=A+(T<<20&4294967295|T>>>12),T=_+(A^R&(w^A))+S[13]+2850285829&4294967295,_=w+(T<<5&4294967295|T>>>27),T=R+(w^A&(_^w))+S[2]+4243563512&4294967295,R=_+(T<<9&4294967295|T>>>23),T=A+(_^w&(R^_))+S[7]+1735328473&4294967295,A=R+(T<<14&4294967295|T>>>18),T=w+(R^_&(A^R))+S[12]+2368359562&4294967295,w=A+(T<<20&4294967295|T>>>12),T=_+(w^A^R)+S[5]+4294588738&4294967295,_=w+(T<<4&4294967295|T>>>28),T=R+(_^w^A)+S[8]+2272392833&4294967295,R=_+(T<<11&4294967295|T>>>21),T=A+(R^_^w)+S[11]+1839030562&4294967295,A=R+(T<<16&4294967295|T>>>16),T=w+(A^R^_)+S[14]+4259657740&4294967295,w=A+(T<<23&4294967295|T>>>9),T=_+(w^A^R)+S[1]+2763975236&4294967295,_=w+(T<<4&4294967295|T>>>28),T=R+(_^w^A)+S[4]+1272893353&4294967295,R=_+(T<<11&4294967295|T>>>21),T=A+(R^_^w)+S[7]+4139469664&4294967295,A=R+(T<<16&4294967295|T>>>16),T=w+(A^R^_)+S[10]+3200236656&4294967295,w=A+(T<<23&4294967295|T>>>9),T=_+(w^A^R)+S[13]+681279174&4294967295,_=w+(T<<4&4294967295|T>>>28),T=R+(_^w^A)+S[0]+3936430074&4294967295,R=_+(T<<11&4294967295|T>>>21),T=A+(R^_^w)+S[3]+3572445317&4294967295,A=R+(T<<16&4294967295|T>>>16),T=w+(A^R^_)+S[6]+76029189&4294967295,w=A+(T<<23&4294967295|T>>>9),T=_+(w^A^R)+S[9]+3654602809&4294967295,_=w+(T<<4&4294967295|T>>>28),T=R+(_^w^A)+S[12]+3873151461&4294967295,R=_+(T<<11&4294967295|T>>>21),T=A+(R^_^w)+S[15]+530742520&4294967295,A=R+(T<<16&4294967295|T>>>16),T=w+(A^R^_)+S[2]+3299628645&4294967295,w=A+(T<<23&4294967295|T>>>9),T=_+(A^(w|~R))+S[0]+4096336452&4294967295,_=w+(T<<6&4294967295|T>>>26),T=R+(w^(_|~A))+S[7]+1126891415&4294967295,R=_+(T<<10&4294967295|T>>>22),T=A+(_^(R|~w))+S[14]+2878612391&4294967295,A=R+(T<<15&4294967295|T>>>17),T=w+(R^(A|~_))+S[5]+4237533241&4294967295,w=A+(T<<21&4294967295|T>>>11),T=_+(A^(w|~R))+S[12]+1700485571&4294967295,_=w+(T<<6&4294967295|T>>>26),T=R+(w^(_|~A))+S[3]+2399980690&4294967295,R=_+(T<<10&4294967295|T>>>22),T=A+(_^(R|~w))+S[10]+4293915773&4294967295,A=R+(T<<15&4294967295|T>>>17),T=w+(R^(A|~_))+S[1]+2240044497&4294967295,w=A+(T<<21&4294967295|T>>>11),T=_+(A^(w|~R))+S[8]+1873313359&4294967295,_=w+(T<<6&4294967295|T>>>26),T=R+(w^(_|~A))+S[15]+4264355552&4294967295,R=_+(T<<10&4294967295|T>>>22),T=A+(_^(R|~w))+S[6]+2734768916&4294967295,A=R+(T<<15&4294967295|T>>>17),T=w+(R^(A|~_))+S[13]+1309151649&4294967295,w=A+(T<<21&4294967295|T>>>11),T=_+(A^(w|~R))+S[4]+4149444226&4294967295,_=w+(T<<6&4294967295|T>>>26),T=R+(w^(_|~A))+S[11]+3174756917&4294967295,R=_+(T<<10&4294967295|T>>>22),T=A+(_^(R|~w))+S[2]+718787259&4294967295,A=R+(T<<15&4294967295|T>>>17),T=w+(R^(A|~_))+S[9]+3951481745&4294967295,k.g[0]=k.g[0]+_&4294967295,k.g[1]=k.g[1]+(A+(T<<21&4294967295|T>>>11))&4294967295,k.g[2]=k.g[2]+A&4294967295,k.g[3]=k.g[3]+R&4294967295}r.prototype.u=function(k,_){_===void 0&&(_=k.length);for(var w=_-this.blockSize,S=this.B,A=this.h,R=0;R<_;){if(A==0)for(;R<=w;)s(this,k,R),R+=this.blockSize;if(typeof k=="string"){for(;R<_;)if(S[A++]=k.charCodeAt(R++),A==this.blockSize){s(this,S),A=0;break}}else for(;R<_;)if(S[A++]=k[R++],A==this.blockSize){s(this,S),A=0;break}}this.h=A,this.o+=_},r.prototype.v=function(){var k=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);k[0]=128;for(var _=1;__;++_)for(var S=0;32>S;S+=8)k[w++]=this.g[_]>>>S&255;return k};function i(k,_){var w=l;return Object.prototype.hasOwnProperty.call(w,k)?w[k]:w[k]=_(k)}function o(k,_){this.h=_;for(var w=[],S=!0,A=k.length-1;0<=A;A--){var R=k[A]|0;S&&R==_||(w[A]=R,S=!1)}this.g=w}var l={};function c(k){return-128<=k&&128>k?i(k,function(_){return new o([_|0],0>_?-1:0)}):new o([k|0],0>k?-1:0)}function h(k){if(isNaN(k)||!isFinite(k))return v;if(0>k)return z(h(-k));for(var _=[],w=1,S=0;k>=w;S++)_[S]=k/w|0,w*=4294967296;return new o(_,0)}function m(k,_){if(k.length==0)throw Error("number format error: empty string");if(_=_||10,2>_||36<_)throw Error("radix out of range: "+_);if(k.charAt(0)=="-")return z(m(k.substring(1),_));if(0<=k.indexOf("-"))throw Error('number format error: interior "-" character');for(var w=h(Math.pow(_,8)),S=v,A=0;AR?(R=h(Math.pow(_,R)),S=S.j(R).add(h(T))):(S=S.j(w),S=S.add(h(T)))}return S}var v=c(0),g=c(1),N=c(16777216);t=o.prototype,t.m=function(){if(O(this))return-z(this).m();for(var k=0,_=1,w=0;wk||36>>0).toString(k);if(w=A,L(w))return R+S;for(;6>R.length;)R="0"+R;S=R+S}},t.i=function(k){return 0>k?0:k>>16)+(this.i(A)>>>16)+(k.i(A)>>>16);S=T>>>16,R&=65535,T&=65535,w[A]=T<<16|R}return new o(w,w[w.length-1]&-2147483648?-1:0)};function I(k,_){return k.add(z(_))}t.j=function(k){if(L(this)||L(k))return v;if(O(this))return O(k)?z(this).j(z(k)):z(z(this).j(k));if(O(k))return z(this.j(z(k)));if(0>this.l(N)&&0>k.l(N))return h(this.m()*k.m());for(var _=this.g.length+k.g.length,w=[],S=0;S<2*_;S++)w[S]=0;for(S=0;S>>16,T=this.i(S)&65535,Ke=k.i(A)>>>16,dn=k.i(A)&65535;w[2*S+2*A]+=T*dn,x(w,2*S+2*A),w[2*S+2*A+1]+=R*dn,x(w,2*S+2*A+1),w[2*S+2*A+1]+=T*Ke,x(w,2*S+2*A+1),w[2*S+2*A+2]+=R*Ke,x(w,2*S+2*A+2)}for(S=0;S<_;S++)w[S]=w[2*S+1]<<16|w[2*S];for(S=_;S<2*_;S++)w[S]=0;return new o(w,0)};function x(k,_){for(;(k[_]&65535)!=k[_];)k[_+1]+=k[_]>>>16,k[_]&=65535,_++}function b(k,_){this.g=k,this.h=_}function F(k,_){if(L(_))throw Error("division by zero");if(L(k))return new b(v,v);if(O(k))return _=F(z(k),_),new b(z(_.g),z(_.h));if(O(_))return _=F(k,z(_)),new b(z(_.g),_.h);if(30=S.l(k);)w=K(w),S=K(S);var A=H(w,1),R=H(S,1);for(S=H(S,2),w=H(w,2);!L(S);){var T=R.add(S);0>=T.l(k)&&(A=A.add(w),R=T),S=H(S,1),w=H(w,1)}return _=I(k,A.j(_)),new b(A,_)}for(A=v;0<=k.l(_);){for(w=Math.max(1,Math.floor(k.m()/_.m())),S=Math.ceil(Math.log(w)/Math.LN2),S=48>=S?1:Math.pow(2,S-48),R=h(w),T=R.j(_);O(T)||0>>31;return new o(w,k.h)}function H(k,_){var w=_>>5;_%=32;for(var S=k.g.length-w,A=[],R=0;R>>_|k.i(R+w+1)<<32-_:k.i(R+w);return new o(A,k.h)}r.prototype.digest=r.prototype.v,r.prototype.reset=r.prototype.s,r.prototype.update=r.prototype.u,Ew=r,o.prototype.add=o.prototype.add,o.prototype.multiply=o.prototype.j,o.prototype.modulo=o.prototype.A,o.prototype.compare=o.prototype.l,o.prototype.toNumber=o.prototype.m,o.prototype.toString=o.prototype.toString,o.prototype.getBits=o.prototype.i,o.fromNumber=h,o.fromString=m,Hs=o}).apply(typeof Cy<"u"?Cy:typeof self<"u"?self:typeof window<"u"?window:{});var Sc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license Copyright The Closure Library Authors. SPDX-License-Identifier: Apache-2.0 */var kw,_a,Tw,Kc,Tf,Sw,Iw,Cw;(function(){var t,e=typeof Object.defineProperties=="function"?Object.defineProperty:function(a,d,f){return a==Array.prototype||a==Object.prototype||(a[d]=f.value),a};function n(a){a=[typeof globalThis=="object"&&globalThis,a,typeof window=="object"&&window,typeof self=="object"&&self,typeof Sc=="object"&&Sc];for(var d=0;d{throw a},0)}function T(){var a=se;let d=null;return a.g&&(d=a.g,a.g=a.g.next,a.g||(a.h=null),d.next=null),d}class Ke{constructor(){this.h=this.g=null}add(d,f){const y=dn.get();y.set(d,f),this.h?this.h.next=y:this.g=y,this.h=y}}var dn=new I(()=>new Ot,a=>a.reset());class Ot{constructor(){this.next=this.g=this.h=null}set(d,f){this.h=d,this.g=f,this.next=null}reset(){this.next=this.g=this.h=null}}let Mt,Q=!1,se=new Ke,re=()=>{const a=l.Promise.resolve(void 0);Mt=()=>{a.then(Ce)}};var Ce=()=>{for(var a;a=T();){try{a.h.call(a.g)}catch(f){R(f)}var d=dn;d.j(a),100>d.h&&(d.h++,a.next=d.g,d.g=a)}Q=!1};function Ee(){this.s=this.s,this.C=this.C}Ee.prototype.s=!1,Ee.prototype.ma=function(){this.s||(this.s=!0,this.N())},Ee.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function be(a,d){this.type=a,this.g=this.target=d,this.defaultPrevented=!1}be.prototype.h=function(){this.defaultPrevented=!0};var We=function(){if(!l.addEventListener||!Object.defineProperty)return!1;var a=!1,d=Object.defineProperty({},"passive",{get:function(){a=!0}});try{const f=()=>{};l.addEventListener("test",f,d),l.removeEventListener("test",f,d)}catch{}return a}();function yt(a,d){if(be.call(this,a?a.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,a){var f=this.type=a.type,y=a.changedTouches&&a.changedTouches.length?a.changedTouches[0]:null;if(this.target=a.target||a.srcElement,this.g=d,d=a.relatedTarget){if(K){e:{try{F(d.nodeName);var P=!0;break e}catch{}P=!1}P||(d=null)}}else f=="mouseover"?d=a.fromElement:f=="mouseout"&&(d=a.toElement);this.relatedTarget=d,y?(this.clientX=y.clientX!==void 0?y.clientX:y.pageX,this.clientY=y.clientY!==void 0?y.clientY:y.pageY,this.screenX=y.screenX||0,this.screenY=y.screenY||0):(this.clientX=a.clientX!==void 0?a.clientX:a.pageX,this.clientY=a.clientY!==void 0?a.clientY:a.pageY,this.screenX=a.screenX||0,this.screenY=a.screenY||0),this.button=a.button,this.key=a.key||"",this.ctrlKey=a.ctrlKey,this.altKey=a.altKey,this.shiftKey=a.shiftKey,this.metaKey=a.metaKey,this.pointerId=a.pointerId||0,this.pointerType=typeof a.pointerType=="string"?a.pointerType:Le[a.pointerType]||"",this.state=a.state,this.i=a,a.defaultPrevented&&yt.aa.h.call(this)}}L(yt,be);var Le={2:"touch",3:"pen",4:"mouse"};yt.prototype.h=function(){yt.aa.h.call(this);var a=this.i;a.preventDefault?a.preventDefault():a.returnValue=!1};var Vt="closure_listenable_"+(1e6*Math.random()|0),W=0;function Ro(a,d,f,y,P){this.listener=a,this.proxy=null,this.src=d,this.type=f,this.capture=!!y,this.ha=P,this.key=++W,this.da=this.fa=!1}function gs(a){a.da=!0,a.listener=null,a.proxy=null,a.src=null,a.ha=null}function vr(a){this.src=a,this.g={},this.h=0}vr.prototype.add=function(a,d,f,y,P){var D=a.toString();a=this.g[D],a||(a=this.g[D]=[],this.h++);var j=vs(a,d,y,P);return-1>>0);function di(a){return typeof a=="function"?a:(a[Do]||(a[Do]=function(d){return a.handleEvent(d)}),a[Do])}function Se(){Ee.call(this),this.i=new vr(this),this.M=this,this.F=null}L(Se,Ee),Se.prototype[Vt]=!0,Se.prototype.removeEventListener=function(a,d,f,y){ws(this,a,d,f,y)};function nt(a,d){var f,y=a.F;if(y)for(f=[];y;y=y.F)f.push(y);if(a=a.M,y=d.type||d,typeof d=="string")d=new be(d,a);else if(d instanceof be)d.target=d.target||a;else{var P=d;d=new be(y,a),S(d,P)}if(P=!0,f)for(var D=f.length-1;0<=D;D--){var j=d.g=f[D];P=xr(j,y,!0,d)&&P}if(j=d.g=a,P=xr(j,y,!0,d)&&P,P=xr(j,y,!1,d)&&P,f)for(D=0;D{a.g=null,a.i&&(a.i=!1,Es(a))},a.l);const d=a.h;a.h=null,a.m.apply(null,d)}class Rl extends Ee{constructor(d,f){super(),this.m=d,this.l=f,this.h=null,this.i=!1,this.g=null}j(d){this.h=arguments,this.g?this.i=!0:Es(this)}N(){super.N(),this.g&&(l.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Sn(a){Ee.call(this),this.h=a,this.g={}}L(Sn,Ee);var Dl=[];function Lo(a){H(a.g,function(d,f){this.g.hasOwnProperty(f)&&qn(d)},a),a.g={}}Sn.prototype.N=function(){Sn.aa.N.call(this),Lo(this)},Sn.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var hi=l.JSON.stringify,In=l.JSON.parse,jl=class{stringify(a){return l.JSON.stringify(a,void 0)}parse(a){return l.JSON.parse(a,void 0)}};function Er(){}Er.prototype.h=null;function Oo(a){return a.h||(a.h=a.i())}function Mo(){}var kr={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function fi(){be.call(this,"d")}L(fi,be);function rt(){be.call(this,"c")}L(rt,be);var tn={},Ll=null;function Hn(){return Ll=Ll||new Se}tn.La="serverreachability";function Vo(a){be.call(this,tn.La,a)}L(Vo,be);function Tr(a){const d=Hn();nt(d,new Vo(d))}tn.STAT_EVENT="statevent";function pi(a,d){be.call(this,tn.STAT_EVENT,a),this.stat=d}L(pi,be);function st(a){const d=Hn();nt(d,new pi(d,a))}tn.Ma="timingevent";function nn(a,d){be.call(this,tn.Ma,a),this.size=d}L(nn,be);function Sr(a,d){if(typeof a!="function")throw Error("Fn must not be null and must be a function");return l.setTimeout(function(){a()},d)}function ct(){this.g=!0}ct.prototype.xa=function(){this.g=!1};function Fo(a,d,f,y,P,D){a.info(function(){if(a.g)if(D)for(var j="",le=D.split("&"),xe=0;xey.length)){var P=y[1];if(Array.isArray(P)&&!(1>P.length)){var D=P[0];if(D!="noop"&&D!="stop"&&D!="close")for(var j=1;jme)&&(me!=3||this.g&&(this.h.h||this.g.oa()||nc(this.g)))){this.J||me!=4||d==7||(d==8||0>=Ut?Tr(3):Tr(2)),Uo(this);var f=this.g.Z();this.X=f;t:if(Vl(this)){var y=nc(this.g);a="";var P=y.length,D=mn(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){bn(this),Gn(this);var j="";break t}this.h.i=new l.TextDecoder}for(d=0;dd.length?ks:(d=d.slice(y,y+f),a.C=y+f,d)))}At.prototype.cancel=function(){this.J=!0,bn(this)};function rn(a){a.S=Date.now()+a.I,Ul(a,a.I)}function Ul(a,d){if(a.B!=null)throw Error("WatchDog timer not null");a.B=Sr(g(a.ba,a),d)}function Uo(a){a.B&&(l.clearTimeout(a.B),a.B=null)}At.prototype.ba=function(){this.B=null;const a=Date.now();0<=a-this.S?(mi(this.i,this.A),this.L!=2&&(Tr(),st(17)),bn(this),this.s=2,Gn(this)):Ul(this,this.S-a)};function Gn(a){a.j.G==0||a.J||Ko(a.j,a)}function bn(a){Uo(a);var d=a.M;d&&typeof d.ma=="function"&&d.ma(),a.M=null,Lo(a.U),a.g&&(d=a.g,a.g=null,d.abort(),d.ma())}function hn(a,d){try{var f=a.j;if(f.G!=0&&(f.g==a||Nr(f.h,a))){if(!a.K&&Nr(f.h,a)&&f.G==3){try{var y=f.Da.g.parse(d)}catch{y=null}if(Array.isArray(y)&&y.length==3){var P=y;if(P[0]==0){e:if(!f.u){if(f.g)if(f.g.F+3e3P[2]&&f.F&&f.v==0&&!f.C&&(f.C=Sr(g(f.Za,f),6e3));if(1>=wi(f.h)&&f.ca){try{f.ca()}catch{}f.ca=void 0}}else Nn(f,11)}else if((a.K||f.g==a)&&Ds(f),!x(d))for(P=f.Da.g.parse(d),d=0;d=a.j:!1}function wi(a){return a.h?1:a.g?a.g.size:0}function Nr(a,d){return a.h?a.h==d:a.g?a.g.has(d):!1}function zo(a,d){a.g?a.g.add(d):a.h=d}function Bl(a,d){a.h&&a.h==d?a.h=null:a.g&&a.g.has(d)&&a.g.delete(d)}zl.prototype.cancel=function(){if(this.i=xi(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const a of this.g.values())a.cancel();this.g.clear()}};function xi(a){if(a.h!=null)return a.i.concat(a.h.D);if(a.g!=null&&a.g.size!==0){let d=a.i;for(const f of a.g.values())d=d.concat(f.D);return d}return O(a.i)}function Sd(a){if(a.V&&typeof a.V=="function")return a.V();if(typeof Map<"u"&&a instanceof Map||typeof Set<"u"&&a instanceof Set)return Array.from(a.values());if(typeof a=="string")return a.split("");if(c(a)){for(var d=[],f=a.length,y=0;yd)throw Error("Bad port number "+d);a.s=d}else a.s=null}function Wl(a,d,f){d instanceof Is?(a.i=d,Kl(a.i,a.h)):(f||(d=Ss(d,bd)),a.i=new Is(d,a.h))}function Ie(a,d,f){a.i.set(d,f)}function ki(a){return Ie(a,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),a}function Ts(a,d){return a?d?decodeURI(a.replace(/%25/g,"%2525")):decodeURIComponent(a):""}function Ss(a,d,f){return typeof a=="string"?(a=encodeURI(a).replace(d,Id),f&&(a=a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),a):null}function Id(a){return a=a.charCodeAt(0),"%"+(a>>4&15).toString(16)+(a&15).toString(16)}var ql=/[#\/\?@]/g,Cd=/[#\?:]/g,Hl=/[#\?]/g,bd=/[#\?@]/g,Ad=/#/g;function Is(a,d){this.h=this.g=null,this.i=a||null,this.j=!!d}function vt(a){a.g||(a.g=new Map,a.h=0,a.i&&E(a.i,function(d,f){a.add(decodeURIComponent(d.replace(/\+/g," ")),f)}))}t=Is.prototype,t.add=function(a,d){vt(this),this.i=null,a=Rr(this,a);var f=this.g.get(a);return f||this.g.set(a,f=[]),f.push(d),this.h+=1,this};function Ti(a,d){vt(a),d=Rr(a,d),a.g.has(d)&&(a.i=null,a.h-=a.g.get(d).length,a.g.delete(d))}function Si(a,d){return vt(a),d=Rr(a,d),a.g.has(d)}t.forEach=function(a,d){vt(this),this.g.forEach(function(f,y){f.forEach(function(P){a.call(d,P,y,this)},this)},this)},t.na=function(){vt(this);const a=Array.from(this.g.values()),d=Array.from(this.g.keys()),f=[];for(let y=0;y{y.abort(),pn(f,"TestPingServer: timeout",!1,d)},1e4);fetch(a,{signal:y.signal}).then(D=>{clearTimeout(P),D.ok?pn(f,"TestPingServer: ok",!0,d):pn(f,"TestPingServer: server error",!1,d)}).catch(()=>{clearTimeout(P),pn(f,"TestPingServer: error",!1,d)})}function pn(a,d,f,y,P){try{P&&(P.onload=null,P.onerror=null,P.onabort=null,P.ontimeout=null),y(f)}catch{}}function Ii(){this.g=new jl}function Yl(a,d,f){const y=f||"";try{Kn(a,function(P,D){let j=P;h(P)&&(j=hi(P)),d.push(y+D+"="+encodeURIComponent(j))})}catch(P){throw d.push(y+"type="+encodeURIComponent("_badmap")),P}}function Cs(a){this.l=a.Ub||null,this.j=a.eb||!1}L(Cs,Er),Cs.prototype.g=function(){return new bs(this.l,this.j)},Cs.prototype.i=function(a){return function(){return a}}({});function bs(a,d){Se.call(this),this.D=a,this.o=d,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}L(bs,Se),t=bs.prototype,t.open=function(a,d){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=a,this.A=d,this.readyState=1,Dr(this)},t.send=function(a){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const d={headers:this.u,method:this.B,credentials:this.m,cache:void 0};a&&(d.body=a),(this.D||l).fetch(new Request(this.A,d)).then(this.Sa.bind(this),this.ga.bind(this))},t.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,Ns(this)),this.readyState=0},t.Sa=function(a){if(this.g&&(this.l=a,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=a.headers,this.readyState=2,Dr(this)),this.g&&(this.readyState=3,Dr(this),this.g)))if(this.responseType==="arraybuffer")a.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof l.ReadableStream<"u"&&"body"in a){if(this.j=a.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;As(this)}else a.text().then(this.Ra.bind(this),this.ga.bind(this))};function As(a){a.j.read().then(a.Pa.bind(a)).catch(a.ga.bind(a))}t.Pa=function(a){if(this.g){if(this.o&&a.value)this.response.push(a.value);else if(!this.o){var d=a.value?a.value:new Uint8Array(0);(d=this.v.decode(d,{stream:!a.done}))&&(this.response=this.responseText+=d)}a.done?Ns(this):Dr(this),this.readyState==3&&As(this)}},t.Ra=function(a){this.g&&(this.response=this.responseText=a,Ns(this))},t.Qa=function(a){this.g&&(this.response=a,Ns(this))},t.ga=function(){this.g&&Ns(this)};function Ns(a){a.readyState=4,a.l=null,a.j=null,a.v=null,Dr(a)}t.setRequestHeader=function(a,d){this.u.append(a,d)},t.getResponseHeader=function(a){return this.h&&this.h.get(a.toLowerCase())||""},t.getAllResponseHeaders=function(){if(!this.h)return"";const a=[],d=this.h.entries();for(var f=d.next();!f.done;)f=f.value,a.push(f[0]+": "+f[1]),f=d.next();return a.join(`\r `)};function Dr(a){a.onreadystatechange&&a.onreadystatechange.call(a)}Object.defineProperty(bs.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(a){this.m=a?"include":"same-origin"}});function Xl(a){let d="";return H(a,function(f,y){d+=y,d+=":",d+=f,d+=`\r `}),d}function An(a,d,f){e:{for(y in f){var y=!1;break e}y=!0}y||(f=Xl(f),typeof a=="string"?f!=null&&encodeURIComponent(String(f)):Ie(a,d,f))}function Oe(a){Se.call(this),this.headers=new Map,this.o=a||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}L(Oe,Se);var Pd=/^https?$/i,Rd=["POST","PUT"];t=Oe.prototype,t.Ha=function(a){this.J=a},t.ea=function(a,d,f,y){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+a);d=d?d.toUpperCase():"GET",this.D=a,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Cn.g(),this.v=this.o?Oo(this.o):Oo(Cn),this.g.onreadystatechange=g(this.Ea,this);try{this.B=!0,this.g.open(d,String(a),!0),this.B=!1}catch(D){Jl(this,D);return}if(a=f||"",f=new Map(this.headers),y)if(Object.getPrototypeOf(y)===Object.prototype)for(var P in y)f.set(P,y[P]);else if(typeof y.keys=="function"&&typeof y.get=="function")for(const D of y.keys())f.set(D,y.get(D));else throw Error("Unknown input type for opt_headers: "+String(y));y=Array.from(f.keys()).find(D=>D.toLowerCase()=="content-type"),P=l.FormData&&a instanceof l.FormData,!(0<=Array.prototype.indexOf.call(Rd,d,void 0))||y||P||f.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[D,j]of f)this.g.setRequestHeader(D,j);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{tc(this),this.u=!0,this.g.send(a),this.u=!1}catch(D){Jl(this,D)}};function Jl(a,d){a.h=!1,a.g&&(a.j=!0,a.g.abort(),a.j=!1),a.l=d,a.m=5,Zl(a),Ci(a)}function Zl(a){a.A||(a.A=!0,nt(a,"complete"),nt(a,"error"))}t.abort=function(a){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=a||7,nt(this,"complete"),nt(this,"abort"),Ci(this))},t.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Ci(this,!0)),Oe.aa.N.call(this)},t.Ea=function(){this.s||(this.B||this.u||this.j?ec(this):this.bb())},t.bb=function(){ec(this)};function ec(a){if(a.h&&typeof o<"u"&&(!a.v[1]||mn(a)!=4||a.Z()!=2)){if(a.u&&mn(a)==4)jo(a.Ea,0,a);else if(nt(a,"readystatechange"),mn(a)==4){a.h=!1;try{const j=a.Z();e:switch(j){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var d=!0;break e;default:d=!1}var f;if(!(f=d)){var y;if(y=j===0){var P=String(a.D).match($l)[1]||null;!P&&l.self&&l.self.location&&(P=l.self.location.protocol.slice(0,-1)),y=!Pd.test(P?P.toLowerCase():"")}f=y}if(f)nt(a,"complete"),nt(a,"success");else{a.m=6;try{var D=2{}:null;a.g=null,a.v=null,d||nt(a,"ready");try{f.onreadystatechange=y}catch{}}}function tc(a){a.I&&(l.clearTimeout(a.I),a.I=null)}t.isActive=function(){return!!this.g};function mn(a){return a.g?a.g.readyState:0}t.Z=function(){try{return 2=a.h.j-(a.s?1:0)?!1:a.s?(a.i=d.D.concat(a.i),!0):a.G==1||a.G==2||a.B>=(a.Va?0:a.Wa)?!1:(a.s=Sr(g(a.Ga,a,d),Qo(a,a.B)),a.B++,!0)}t.Ga=function(a){if(this.s)if(this.s=null,this.G==1){if(!a){this.U=Math.floor(1e5*Math.random()),a=this.U++;const P=new At(this,this.j,a);let D=this.o;if(this.S&&(D?(D=_(D),S(D,this.S)):D=this.S),this.m!==null||this.O||(P.H=D,D=null),this.P)e:{for(var d=0,f=0;fae)D=Math.max(0,P[xe].g-100),le=!1;else try{Yl(Ae,j,"req"+ae+"_")}catch{y&&y(Ae)}}if(le){y=j.join("&");break e}}}return a=a.i.splice(0,f),d.D=a,y}function Ho(a){if(!a.g&&!a.u){a.Y=1;var d=a.Fa;Mt||re(),Q||(Mt(),Q=!0),se.add(d,a),a.v=0}}function Ai(a){return a.g||a.u||3<=a.v?!1:(a.Y++,a.u=Sr(g(a.Fa,a),Qo(a,a.v)),a.v++,!0)}t.Fa=function(){if(this.u=null,Go(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var a=2*this.R;this.j.info("BP detection timer enabled: "+a),this.A=Sr(g(this.ab,this),a)}},t.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,st(10),bi(this),Go(this))};function Ni(a){a.A!=null&&(l.clearTimeout(a.A),a.A=null)}function Go(a){a.g=new At(a,a.j,"rpc",a.Y),a.m===null&&(a.g.H=a.o),a.g.O=0;var d=fn(a.qa);Ie(d,"RID","rpc"),Ie(d,"SID",a.K),Ie(d,"AID",a.T),Ie(d,"CI",a.F?"0":"1"),!a.F&&a.ja&&Ie(d,"TO",a.ja),Ie(d,"TYPE","xmlhttp"),jr(a,d),a.m&&a.o&&An(d,a.m,a.o),a.L&&(a.g.I=a.L);var f=a.g;a=a.ia,f.L=1,f.v=ki(fn(d)),f.m=null,f.P=!0,_i(f,a)}t.Za=function(){this.C!=null&&(this.C=null,bi(this),Ai(this),st(19))};function Ds(a){a.C!=null&&(l.clearTimeout(a.C),a.C=null)}function Ko(a,d){var f=null;if(a.g==d){Ds(a),Ni(a),a.g=null;var y=2}else if(Nr(a.h,d))f=d.D,Bl(a.h,d),y=1;else return;if(a.G!=0){if(d.o)if(y==1){f=d.m?d.m.length:0,d=Date.now()-d.F;var P=a.B;y=Hn(),nt(y,new nn(y,f)),Rs(a)}else Ho(a);else if(P=d.s,P==3||P==0&&0`${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 ir{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 bw{constructor(e,n){this.user=n,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class bC{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,n){e.enqueueRetryable(()=>n(kt.UNAUTHENTICATED))}shutdown(){}}class AC{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 NC{constructor(e){this.t=e,this.currentUser=kt.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,n){Te(this.o===void 0);let r=this.i;const s=c=>this.i!==r?(r=this.i,n(c)):Promise.resolve();let i=new ir;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new ir,e.enqueueRetryable(()=>s(this.currentUser))};const o=()=>{const c=i;e.enqueueRetryable(async()=>{await c.promise,await s(this.currentUser)})},l=c=>{ee("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=c,this.o&&(this.auth.addAuthTokenListener(this.o),o())};this.t.onInit(c=>l(c)),setTimeout(()=>{if(!this.auth){const c=this.t.getImmediate({optional:!0});c?l(c):(ee("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new ir)}},0),o()}getToken(){const e=this.i,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then(r=>this.i!==e?(ee("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(Te(typeof r.accessToken=="string"),new bw(r.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const e=this.auth&&this.auth.getUid();return Te(e===null||typeof e=="string"),new kt(e)}}class PC{constructor(e,n,r){this.l=e,this.h=n,this.P=r,this.type="FirstParty",this.user=kt.FIRST_PARTY,this.I=new Map}T(){return this.P?this.P():null}get headers(){this.I.set("X-Goog-AuthUser",this.l);const e=this.T();return e&&this.I.set("Authorization",e),this.h&&this.I.set("X-Goog-Iam-Authorization-Token",this.h),this.I}}class RC{constructor(e,n,r){this.l=e,this.h=n,this.P=r}getToken(){return Promise.resolve(new PC(this.l,this.h,this.P))}start(e,n){e.enqueueRetryable(()=>n(kt.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class DC{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 jC{constructor(e){this.A=e,this.forceRefresh=!1,this.appCheck=null,this.R=null}start(e,n){Te(this.o===void 0);const r=i=>{i.error!=null&&ee("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${i.error.message}`);const o=i.token!==this.R;return this.R=i.token,ee("FirebaseAppCheckTokenProvider",`Received ${o?"new":"existing"} token.`),o?n(i.token):Promise.resolve()};this.o=i=>{e.enqueueRetryable(()=>r(i))};const s=i=>{ee("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=i,this.o&&this.appCheck.addTokenListener(this.o)};this.A.onInit(i=>s(i)),setTimeout(()=>{if(!this.appCheck){const i=this.A.getImmediate({optional:!0});i?s(i):ee("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(n=>n?(Te(typeof n.token=="string"),this.R=n.token,new DC(n.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=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. */function LC(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;re?1:0}function vo(t,e,n){return t.length===e.length&&t.every((r,s)=>n(r,e[s]))}/** * @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 et{constructor(e,n){if(this.seconds=e,this.nanoseconds=n,n<0)throw new X(U.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(n>=1e9)throw new X(U.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(e<-62135596800)throw new X(U.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new X(U.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return et.fromMillis(Date.now())}static fromDate(e){return et.fromMillis(e.getTime())}static fromMillis(e){const n=Math.floor(e/1e3),r=Math.floor(1e6*(e-1e3*n));return new et(n,r)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?we(this.nanoseconds,e.nanoseconds):we(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 ue{constructor(e){this.timestamp=e}static fromTimestamp(e){return new ue(e)}static min(){return new ue(new et(0,0))}static max(){return new ue(new et(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 rl{constructor(e,n,r){n===void 0?n=0:n>e.length&&oe(),r===void 0?r=e.length-n:r>e.length-n&&oe(),this.segments=e,this.offset=n,this.len=r}get length(){return this.len}isEqual(e){return rl.comparator(this,e)===0}child(e){const n=this.segments.slice(this.offset,this.limit());return e instanceof rl?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.lengtho)return 1}return e.lengthn.length?1:0}}class De extends rl{construct(e,n,r){return new De(e,n,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const n=[];for(const r of e){if(r.indexOf("//")>=0)throw new X(U.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);n.push(...r.split("/").filter(s=>s.length>0))}return new De(n)}static emptyPath(){return new De([])}}const OC=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class ht extends rl{construct(e,n,r){return new ht(e,n,r)}static isValidIdentifier(e){return OC.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),ht.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)==="__name__"}static keyField(){return new ht(["__name__"])}static fromServerFormat(e){const n=[];let r="",s=0;const i=()=>{if(r.length===0)throw new X(U.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);n.push(r),r=""};let o=!1;for(;s=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&&De.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,n){return De.comparator(e.path,n.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new ne(new De(e.slice()))}}function MC(t,e){const n=t.toTimestamp().seconds,r=t.toTimestamp().nanoseconds+1,s=ue.fromTimestamp(r===1e9?new et(n+1,0):new et(n,r));return new ls(s,ne.empty(),e)}function VC(t){return new ls(t.readTime,t.key,-1)}class ls{constructor(e,n,r){this.readTime=e,this.documentKey=n,this.largestBatchId=r}static min(){return new ls(ue.min(),ne.empty(),-1)}static max(){return new ls(ue.max(),ne.empty(),-1)}}function FC(t,e){let n=t.readTime.compareTo(e.readTime);return n!==0?n:(n=ne.comparator(t.documentKey,e.documentKey),n!==0?n:we(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 UC="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class zC{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 wl(t){if(t.code!==U.FAILED_PRECONDITION||t.message!==UC)throw t;ee("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 B{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&&oe(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(e,this.result):new B((r,s)=>{this.nextCallback=i=>{this.wrapSuccess(e,i).next(r,s)},this.catchCallback=i=>{this.wrapFailure(n,i).next(r,s)}})}toPromise(){return new Promise((e,n)=>{this.next(e,n)})}wrapUserFunction(e){try{const n=e();return n instanceof B?n:B.resolve(n)}catch(n){return B.reject(n)}}wrapSuccess(e,n){return e?this.wrapUserFunction(()=>e(n)):B.resolve(n)}wrapFailure(e,n){return e?this.wrapUserFunction(()=>e(n)):B.reject(n)}static resolve(e){return new B((n,r)=>{n(e)})}static reject(e){return new B((n,r)=>{r(e)})}static waitFor(e){return new B((n,r)=>{let s=0,i=0,o=!1;e.forEach(l=>{++s,l.next(()=>{++i,o&&i===s&&n()},c=>r(c))}),o=!0,i===s&&n()})}static or(e){let n=B.resolve(!1);for(const r of e)n=n.next(s=>s?B.resolve(s):r());return n}static forEach(e,n){const r=[];return e.forEach((s,i)=>{r.push(n.call(this,s,i))}),this.waitFor(r)}static mapArray(e,n){return new B((r,s)=>{const i=e.length,o=new Array(i);let l=0;for(let c=0;c{o[h]=m,++l,l===i&&r(o)},m=>s(m))}})}static doWhile(e,n){return new B((r,s)=>{const i=()=>{e()===!0?n().next(()=>{i()},s):r()};i()})}}function BC(t){const e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)}function xl(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 Gp{constructor(e,n){this.previousValue=e,n&&(n.sequenceNumberHandler=r=>this.ie(r),this.se=r=>n.writeSequenceNumber(r))}ie(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.se&&this.se(e),e}}Gp.oe=-1;function ld(t){return t==null}function Ru(t){return t===0&&1/t==-1/0}function $C(t){return typeof t=="number"&&Number.isInteger(t)&&!Ru(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}/** * @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 Ay(t){let e=0;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function oi(t,e){for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function Nw(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. */class Be{constructor(e,n){this.comparator=e,this.root=n||dt.EMPTY}insert(e,n){return new Be(this.comparator,this.root.insert(e,n,this.comparator).copy(null,null,dt.BLACK,null,null))}remove(e){return new Be(this.comparator,this.root.remove(e,this.comparator).copy(null,null,dt.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 s=this.comparator(e,r.key);if(s===0)return n+r.left.size;s<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 Ic(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Ic(this.root,e,this.comparator,!1)}getReverseIterator(){return new Ic(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Ic(this.root,e,this.comparator,!0)}}class Ic{constructor(e,n,r,s){this.isReverse=s,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=n?r(e.key,n):1,n&&s&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(i===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 dt{constructor(e,n,r,s,i){this.key=e,this.value=n,this.color=r??dt.RED,this.left=s??dt.EMPTY,this.right=i??dt.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,n,r,s,i){return new dt(e??this.key,n??this.value,r??this.color,s??this.left,i??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,n,r){let s=this;const i=r(e,s.key);return s=i<0?s.copy(null,null,null,s.left.insert(e,n,r),null):i===0?s.copy(null,n,null,null,null):s.copy(null,null,null,null,s.right.insert(e,n,r)),s.fixUp()}removeMin(){if(this.left.isEmpty())return dt.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,s=this;if(n(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,n),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),n(e,s.key)===0){if(s.right.isEmpty())return dt.EMPTY;r=s.right.min(),s=s.copy(r.key,r.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,n))}return s.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,dt.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,dt.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),n=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,n)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw oe();const e=this.left.check();if(e!==this.right.check())throw oe();return e+(this.isRed()?0:1)}}dt.EMPTY=null,dt.RED=!0,dt.BLACK=!1;dt.EMPTY=new class{constructor(){this.size=0}get key(){throw oe()}get value(){throw oe()}get color(){throw oe()}get left(){throw oe()}get right(){throw oe()}copy(e,n,r,s,i){return this}insert(e,n,r){return new dt(e,n)}remove(e,n){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/** * @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 pt{constructor(e){this.comparator=e,this.data=new Be(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 s=r.getNext();if(this.comparator(s.key,e[1])>=0)return;n(s.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 Ny(this.data.getIterator())}getIteratorFrom(e){return new Ny(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{n=n.add(r)}),n}isEqual(e){if(!(e instanceof pt)||this.size!==e.size)return!1;const n=this.data.getIterator(),r=e.data.getIterator();for(;n.hasNext();){const s=n.getNext().key,i=r.getNext().key;if(this.comparator(s,i)!==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 pt(this.comparator);return n.data=e,n}}class Ny{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 Yt{constructor(e){this.fields=e,e.sort(ht.comparator)}static empty(){return new Yt([])}unionWith(e){let n=new pt(ht.comparator);for(const r of this.fields)n=n.add(r);for(const r of e)n=n.add(r);return new Yt(n.toArray())}covers(e){for(const n of this.fields)if(n.isPrefixOf(e))return!0;return!1}isEqual(e){return vo(this.fields,e.fields,(n,r)=>n.isEqual(r))}}/** * @license * Copyright 2023 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 Pw extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/** * @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 gt{constructor(e){this.binaryString=e}static fromBase64String(e){const n=function(s){try{return atob(s)}catch(i){throw typeof DOMException<"u"&&i instanceof DOMException?new Pw("Invalid base64 string: "+i):i}}(e);return new gt(n)}static fromUint8Array(e){const n=function(s){let i="";for(let o=0;oe$n(n,e))!==void 0}function _o(t,e){if(t===e)return 0;const n=ri(t),r=ri(e);if(n!==r)return we(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return we(t.booleanValue,e.booleanValue);case 2:return function(i,o){const l=qe(i.integerValue||i.doubleValue),c=qe(o.integerValue||o.doubleValue);return lc?1:l===c?0:isNaN(l)?isNaN(c)?0:-1:1}(t,e);case 3:return Py(t.timestampValue,e.timestampValue);case 4:return Py(sl(t),sl(e));case 5:return we(t.stringValue,e.stringValue);case 6:return function(i,o){const l=ni(i),c=ni(o);return l.compareTo(c)}(t.bytesValue,e.bytesValue);case 7:return function(i,o){const l=i.split("/"),c=o.split("/");for(let h=0;he.mapValue.fields[n]=Da(r)),e}if(t.arrayValue){const e={arrayValue:{values:[]}};for(let n=0;n<(t.arrayValue.values||[]).length;++n)e.arrayValue.values[n]=Da(t.arrayValue.values[n]);return e}return Object.assign({},t)}function GC(t){return(((t.mapValue||{}).fields||{}).__type__||{}).stringValue==="__max__"}/** * @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 Bt{constructor(e){this.value=e}static empty(){return new Bt({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let n=this.value;for(let r=0;r{if(!n.isImmediateParentOf(l)){const c=this.getFieldsMap(n);this.applyChanges(c,r,s),r={},s=[],n=l.popLast()}o?r[l.lastSegment()]=Da(o):s.push(l.lastSegment())});const i=this.getFieldsMap(n);this.applyChanges(i,r,s)}delete(e){const n=this.field(e.popLast());Qc(n)&&n.mapValue.fields&&delete n.mapValue.fields[e.lastSegment()]}isEqual(e){return $n(this.value,e.value)}getFieldsMap(e){let n=this.value;n.mapValue.fields||(n.mapValue={fields:{}});for(let r=0;re[s]=i);for(const s of r)delete e[s]}clone(){return new Bt(Da(this.value))}}function Rw(t){const e=[];return oi(t.fields,(n,r)=>{const s=new ht([n]);if(Qc(r)){const i=Rw(r.mapValue).fields;if(i.length===0)e.push(s);else for(const o of i)e.push(s.child(o))}else e.push(s)}),new Yt(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 St{constructor(e,n,r,s,i,o,l){this.key=e,this.documentType=n,this.version=r,this.readTime=s,this.createTime=i,this.data=o,this.documentState=l}static newInvalidDocument(e){return new St(e,0,ue.min(),ue.min(),ue.min(),Bt.empty(),0)}static newFoundDocument(e,n,r,s){return new St(e,1,n,ue.min(),r,s,0)}static newNoDocument(e,n){return new St(e,2,n,ue.min(),ue.min(),Bt.empty(),0)}static newUnknownDocument(e,n){return new St(e,3,n,ue.min(),ue.min(),Bt.empty(),2)}convertToFoundDocument(e,n){return!this.createTime.isEqual(ue.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=n,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Bt.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Bt.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=ue.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 St&&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 St(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}/** * @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 Du{constructor(e,n){this.position=e,this.inclusive=n}}function Oy(t,e,n){let r=0;for(let s=0;s":return e>0;case">=":return e>=0;default:return oe()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class Tn extends Dw{constructor(e,n){super(),this.filters=e,this.op=n,this.ae=null}static create(e,n){return new Tn(e,n)}matches(e){return jw(this)?this.filters.find(n=>!n.matches(e))===void 0:this.filters.find(n=>n.matches(e))!==void 0}getFlattenedFilters(){return this.ae!==null||(this.ae=this.filters.reduce((e,n)=>e.concat(n.getFlattenedFilters()),[])),this.ae}getFilters(){return Object.assign([],this.filters)}}function jw(t){return t.op==="and"}function Lw(t){return QC(t)&&jw(t)}function QC(t){for(const e of t.filters)if(e instanceof Tn)return!1;return!0}function Cf(t){if(t instanceof Xe)return t.field.canonicalString()+t.op.toString()+wo(t.value);if(Lw(t))return t.filters.map(e=>Cf(e)).join(",");{const e=t.filters.map(n=>Cf(n)).join(",");return`${t.op}(${e})`}}function Ow(t,e){return t instanceof Xe?function(r,s){return s instanceof Xe&&r.op===s.op&&r.field.isEqual(s.field)&&$n(r.value,s.value)}(t,e):t instanceof Tn?function(r,s){return s instanceof Tn&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce((i,o,l)=>i&&Ow(o,s.filters[l]),!0):!1}(t,e):void oe()}function Mw(t){return t instanceof Xe?function(n){return`${n.field.canonicalString()} ${n.op} ${wo(n.value)}`}(t):t instanceof Tn?function(n){return n.op.toString()+" {"+n.getFilters().map(Mw).join(" ,")+"}"}(t):"Filter"}class YC extends Xe{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.matchesComparison(n)}}class XC extends Xe{constructor(e,n){super(e,"in",n),this.keys=Vw("in",n)}matches(e){return this.keys.some(n=>n.isEqual(e.key))}}class JC extends Xe{constructor(e,n){super(e,"not-in",n),this.keys=Vw("not-in",n)}matches(e){return!this.keys.some(n=>n.isEqual(e.key))}}function Vw(t,e){var n;return(((n=e.arrayValue)===null||n===void 0?void 0:n.values)||[]).map(r=>ne.fromName(r.referenceValue))}class ZC extends Xe{constructor(e,n){super(e,"array-contains",n)}matches(e){const n=e.data.field(this.field);return Yp(n)&&ol(n.arrayValue,this.value)}}class eb extends Xe{constructor(e,n){super(e,"in",n)}matches(e){const n=e.data.field(this.field);return n!==null&&ol(this.value.arrayValue,n)}}class tb extends Xe{constructor(e,n){super(e,"not-in",n)}matches(e){if(ol(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const n=e.data.field(this.field);return n!==null&&!ol(this.value.arrayValue,n)}}class nb extends Xe{constructor(e,n){super(e,"array-contains-any",n)}matches(e){const n=e.data.field(this.field);return!(!Yp(n)||!n.arrayValue.values)&&n.arrayValue.values.some(r=>ol(this.value.arrayValue,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. */class rb{constructor(e,n=null,r=[],s=[],i=null,o=null,l=null){this.path=e,this.collectionGroup=n,this.orderBy=r,this.filters=s,this.limit=i,this.startAt=o,this.endAt=l,this.ue=null}}function Vy(t,e=null,n=[],r=[],s=null,i=null,o=null){return new rb(t,e,n,r,s,i,o)}function Xp(t){const e=de(t);if(e.ue===null){let n=e.path.canonicalString();e.collectionGroup!==null&&(n+="|cg:"+e.collectionGroup),n+="|f:",n+=e.filters.map(r=>Cf(r)).join(","),n+="|ob:",n+=e.orderBy.map(r=>function(i){return i.field.canonicalString()+i.dir}(r)).join(","),ld(e.limit)||(n+="|l:",n+=e.limit),e.startAt&&(n+="|lb:",n+=e.startAt.inclusive?"b:":"a:",n+=e.startAt.position.map(r=>wo(r)).join(",")),e.endAt&&(n+="|ub:",n+=e.endAt.inclusive?"a:":"b:",n+=e.endAt.position.map(r=>wo(r)).join(",")),e.ue=n}return e.ue}function Jp(t,e){if(t.limit!==e.limit||t.orderBy.length!==e.orderBy.length)return!1;for(let n=0;n0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(o){let l=new pt(ht.comparator);return o.filters.forEach(c=>{c.getFlattenedFilters().forEach(h=>{h.isInequality()&&(l=l.add(h.field))})}),l})(e).forEach(i=>{n.has(i.canonicalString())||i.isKeyField()||e.ce.push(new ju(i,r))}),n.has(ht.keyField().canonicalString())||e.ce.push(new ju(ht.keyField(),r))}return e.ce}function zn(t){const e=de(t);return e.le||(e.le=ib(e,ja(t))),e.le}function ib(t,e){if(t.limitType==="F")return Vy(t.path,t.collectionGroup,e,t.filters,t.limit,t.startAt,t.endAt);{e=e.map(s=>{const i=s.dir==="desc"?"asc":"desc";return new ju(s.field,i)});const n=t.endAt?new Du(t.endAt.position,t.endAt.inclusive):null,r=t.startAt?new Du(t.startAt.position,t.startAt.inclusive):null;return Vy(t.path,t.collectionGroup,e,t.filters,t.limit,n,r)}}function Af(t,e){const n=t.filters.concat([e]);return new El(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}function Nf(t,e,n){return new El(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function ud(t,e){return Jp(zn(t),zn(e))&&t.limitType===e.limitType}function Uw(t){return`${Xp(zn(t))}|lt:${t.limitType}`}function Oi(t){return`Query(target=${function(n){let r=n.path.canonicalString();return n.collectionGroup!==null&&(r+=" collectionGroup="+n.collectionGroup),n.filters.length>0&&(r+=`, filters: [${n.filters.map(s=>Mw(s)).join(", ")}]`),ld(n.limit)||(r+=", limit: "+n.limit),n.orderBy.length>0&&(r+=`, orderBy: [${n.orderBy.map(s=>function(o){return`${o.field.canonicalString()} (${o.dir})`}(s)).join(", ")}]`),n.startAt&&(r+=", startAt: ",r+=n.startAt.inclusive?"b:":"a:",r+=n.startAt.position.map(s=>wo(s)).join(",")),n.endAt&&(r+=", endAt: ",r+=n.endAt.inclusive?"a:":"b:",r+=n.endAt.position.map(s=>wo(s)).join(",")),`Target(${r})`}(zn(t))}; limitType=${t.limitType})`}function dd(t,e){return e.isFoundDocument()&&function(r,s){const i=s.key.path;return r.collectionGroup!==null?s.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(i):ne.isDocumentKey(r.path)?r.path.isEqual(i):r.path.isImmediateParentOf(i)}(t,e)&&function(r,s){for(const i of ja(r))if(!i.field.isKeyField()&&s.data.field(i.field)===null)return!1;return!0}(t,e)&&function(r,s){for(const i of r.filters)if(!i.matches(s))return!1;return!0}(t,e)&&function(r,s){return!(r.startAt&&!function(o,l,c){const h=Oy(o,l,c);return o.inclusive?h<=0:h<0}(r.startAt,ja(r),s)||r.endAt&&!function(o,l,c){const h=Oy(o,l,c);return o.inclusive?h>=0:h>0}(r.endAt,ja(r),s))}(t,e)}function ob(t){return t.collectionGroup||(t.path.length%2==1?t.path.lastSegment():t.path.get(t.path.length-2))}function zw(t){return(e,n)=>{let r=!1;for(const s of ja(t)){const i=ab(s,e,n);if(i!==0)return i;r=r||s.field.isKeyField()}return 0}}function ab(t,e,n){const r=t.field.isKeyField()?ne.comparator(e.key,n.key):function(i,o,l){const c=o.data.field(i),h=l.data.field(i);return c!==null&&h!==null?_o(c,h):oe()}(t.field,e,n);switch(t.dir){case"asc":return r;case"desc":return-1*r;default:return oe()}}/** * @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 No{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[s,i]of r)if(this.equalsFn(s,e))return i}}has(e){return this.get(e)!==void 0}set(e,n){const r=this.mapKeyFn(e),s=this.inner[r];if(s===void 0)return this.inner[r]=[[e,n]],void this.innerSize++;for(let i=0;i{for(const[s,i]of r)e(s,i)})}isEmpty(){return Nw(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 lb=new Be(ne.comparator);function fr(){return lb}const Bw=new Be(ne.comparator);function wa(...t){let e=Bw;for(const n of t)e=e.insert(n.key,n);return e}function $w(t){let e=Bw;return t.forEach((n,r)=>e=e.insert(n,r.overlayedDocument)),e}function $s(){return La()}function Ww(){return La()}function La(){return new No(t=>t.toString(),(t,e)=>t.isEqual(e))}const cb=new Be(ne.comparator),ub=new pt(ne.comparator);function ge(...t){let e=ub;for(const n of t)e=e.add(n);return e}const db=new pt(we);function hb(){return db}/** * @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 Zp(t,e){if(t.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Ru(e)?"-0":e}}function qw(t){return{integerValue:""+t}}function fb(t,e){return $C(e)?qw(e):Zp(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 hd{constructor(){this._=void 0}}function pb(t,e,n){return t instanceof Lu?function(s,i){const o={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return i&&Kp(i)&&(i=Qp(i)),i&&(o.fields.__previous_value__=i),{mapValue:o}}(n,e):t instanceof al?Gw(t,e):t instanceof ll?Kw(t,e):function(s,i){const o=Hw(s,i),l=Uy(o)+Uy(s.Pe);return If(o)&&If(s.Pe)?qw(l):Zp(s.serializer,l)}(t,e)}function mb(t,e,n){return t instanceof al?Gw(t,e):t instanceof ll?Kw(t,e):n}function Hw(t,e){return t instanceof Ou?function(r){return If(r)||function(i){return!!i&&"doubleValue"in i}(r)}(e)?e:{integerValue:0}:null}class Lu extends hd{}class al extends hd{constructor(e){super(),this.elements=e}}function Gw(t,e){const n=Qw(e);for(const r of t.elements)n.some(s=>$n(s,r))||n.push(r);return{arrayValue:{values:n}}}class ll extends hd{constructor(e){super(),this.elements=e}}function Kw(t,e){let n=Qw(e);for(const r of t.elements)n=n.filter(s=>!$n(s,r));return{arrayValue:{values:n}}}class Ou extends hd{constructor(e,n){super(),this.serializer=e,this.Pe=n}}function Uy(t){return qe(t.integerValue||t.doubleValue)}function Qw(t){return Yp(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}function gb(t,e){return t.field.isEqual(e.field)&&function(r,s){return r instanceof al&&s instanceof al||r instanceof ll&&s instanceof ll?vo(r.elements,s.elements,$n):r instanceof Ou&&s instanceof Ou?$n(r.Pe,s.Pe):r instanceof Lu&&s instanceof Lu}(t.transform,e.transform)}class yb{constructor(e,n){this.version=e,this.transformResults=n}}class Rt{constructor(e,n){this.updateTime=e,this.exists=n}static none(){return new Rt}static exists(e){return new Rt(void 0,e)}static updateTime(e){return new Rt(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 Yc(t,e){return t.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(t.updateTime):t.exists===void 0||t.exists===e.isFoundDocument()}class fd{}function Yw(t,e){if(!t.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return t.isNoDocument()?new pd(t.key,Rt.none()):new kl(t.key,t.data,Rt.none());{const n=t.data,r=Bt.empty();let s=new pt(ht.comparator);for(let i of e.fields)if(!s.has(i)){let o=n.field(i);o===null&&i.length>1&&(i=i.popLast(),o=n.field(i)),o===null?r.delete(i):r.set(i,o),s=s.add(i)}return new ms(t.key,r,new Yt(s.toArray()),Rt.none())}}function vb(t,e,n){t instanceof kl?function(s,i,o){const l=s.value.clone(),c=By(s.fieldTransforms,i,o.transformResults);l.setAll(c),i.convertToFoundDocument(o.version,l).setHasCommittedMutations()}(t,e,n):t instanceof ms?function(s,i,o){if(!Yc(s.precondition,i))return void i.convertToUnknownDocument(o.version);const l=By(s.fieldTransforms,i,o.transformResults),c=i.data;c.setAll(Xw(s)),c.setAll(l),i.convertToFoundDocument(o.version,c).setHasCommittedMutations()}(t,e,n):function(s,i,o){i.convertToNoDocument(o.version).setHasCommittedMutations()}(0,e,n)}function Oa(t,e,n,r){return t instanceof kl?function(i,o,l,c){if(!Yc(i.precondition,o))return l;const h=i.value.clone(),m=$y(i.fieldTransforms,c,o);return h.setAll(m),o.convertToFoundDocument(o.version,h).setHasLocalMutations(),null}(t,e,n,r):t instanceof ms?function(i,o,l,c){if(!Yc(i.precondition,o))return l;const h=$y(i.fieldTransforms,c,o),m=o.data;return m.setAll(Xw(i)),m.setAll(h),o.convertToFoundDocument(o.version,m).setHasLocalMutations(),l===null?null:l.unionWith(i.fieldMask.fields).unionWith(i.fieldTransforms.map(v=>v.field))}(t,e,n,r):function(i,o,l){return Yc(i.precondition,o)?(o.convertToNoDocument(o.version).setHasLocalMutations(),null):l}(t,e,n)}function _b(t,e){let n=null;for(const r of t.fieldTransforms){const s=e.data.field(r.field),i=Hw(r.transform,s||null);i!=null&&(n===null&&(n=Bt.empty()),n.set(r.field,i))}return n||null}function zy(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&!!function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&vo(r,s,(i,o)=>gb(i,o))}(t.fieldTransforms,e.fieldTransforms)&&(t.type===0?t.value.isEqual(e.value):t.type!==1||t.data.isEqual(e.data)&&t.fieldMask.isEqual(e.fieldMask))}class kl extends fd{constructor(e,n,r,s=[]){super(),this.key=e,this.value=n,this.precondition=r,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class ms extends fd{constructor(e,n,r,s,i=[]){super(),this.key=e,this.data=n,this.fieldMask=r,this.precondition=s,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function Xw(t){const e=new Map;return t.fieldMask.fields.forEach(n=>{if(!n.isEmpty()){const r=t.data.field(n);e.set(n,r)}}),e}function By(t,e,n){const r=new Map;Te(t.length===n.length);for(let s=0;s{const i=e.get(s.key),o=i.overlayedDocument;let l=this.applyToLocalView(o,i.mutatedFields);l=n.has(s.key)?null:l;const c=Yw(o,l);c!==null&&r.set(s.key,c),o.isValidDocument()||o.convertToNoDocument(ue.min())}),r}keys(){return this.mutations.reduce((e,n)=>e.add(n.key),ge())}isEqual(e){return this.batchId===e.batchId&&vo(this.mutations,e.mutations,(n,r)=>zy(n,r))&&vo(this.baseMutations,e.baseMutations,(n,r)=>zy(n,r))}}class em{constructor(e,n,r,s){this.batch=e,this.commitVersion=n,this.mutationResults=r,this.docVersions=s}static from(e,n,r){Te(e.mutations.length===r.length);let s=function(){return cb}();const i=e.mutations;for(let o=0;o=8)throw new xa(`Invalid padding: ${n}`);if(r<0)throw new xa(`Invalid hash count: ${r}`);if(e.length>0&&this.hashCount===0)throw new xa(`Invalid hash count: ${r}`);if(e.length===0&&n!==0)throw new xa(`Invalid padding when bitmap length is 0: ${n}`);this.Ie=8*e.length-n,this.Te=Hs.fromNumber(this.Ie)}Ee(e,n,r){let s=e.add(n.multiply(Hs.fromNumber(r)));return s.compare(Ib)===1&&(s=new Hs([s.getBits(0),s.getBits(1)],0)),s.modulo(this.Te).toNumber()}de(e){return(this.bitmap[Math.floor(e/8)]&1<o.insert(l)),o}insert(e){if(this.Ie===0)return;const n=Wy(e),[r,s]=qy(n);for(let i=0;i0&&(this.we=!0,this.pe=e)}ve(){let e=ge(),n=ge(),r=ge();return this.ge.forEach((s,i)=>{switch(i){case 0:e=e.add(s);break;case 2:n=n.add(s);break;case 1:r=r.add(s);break;default:oe()}}),new Tl(this.pe,this.ye,e,n,r)}Ce(){this.we=!1,this.ge=Ky()}Fe(e,n){this.we=!0,this.ge=this.ge.insert(e,n)}Me(e){this.we=!0,this.ge=this.ge.remove(e)}xe(){this.fe+=1}Oe(){this.fe-=1,Te(this.fe>=0)}Ne(){this.we=!0,this.ye=!0}}class Cb{constructor(e){this.Le=e,this.Be=new Map,this.ke=fr(),this.qe=Gy(),this.Qe=new Be(we)}Ke(e){for(const n of e.Re)e.Ve&&e.Ve.isFoundDocument()?this.$e(n,e.Ve):this.Ue(n,e.key,e.Ve);for(const n of e.removedTargetIds)this.Ue(n,e.key,e.Ve)}We(e){this.forEachTarget(e,n=>{const r=this.Ge(n);switch(e.state){case 0:this.ze(n)&&r.De(e.resumeToken);break;case 1:r.Oe(),r.Se||r.Ce(),r.De(e.resumeToken);break;case 2:r.Oe(),r.Se||this.removeTarget(n);break;case 3:this.ze(n)&&(r.Ne(),r.De(e.resumeToken));break;case 4:this.ze(n)&&(this.je(n),r.De(e.resumeToken));break;default:oe()}})}forEachTarget(e,n){e.targetIds.length>0?e.targetIds.forEach(n):this.Be.forEach((r,s)=>{this.ze(s)&&n(s)})}He(e){const n=e.targetId,r=e.me.count,s=this.Je(n);if(s){const i=s.target;if(bf(i))if(r===0){const o=new ne(i.path);this.Ue(n,o,St.newNoDocument(o,ue.min()))}else Te(r===1);else{const o=this.Ye(n);if(o!==r){const l=this.Ze(e),c=l?this.Xe(l,e,o):1;if(c!==0){this.je(n);const h=c===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Qe=this.Qe.insert(n,h)}}}}}Ze(e){const n=e.me.unchangedNames;if(!n||!n.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:i=0}=n;let o,l;try{o=ni(r).toUint8Array()}catch(c){if(c instanceof Pw)return yo("Decoding the base64 bloom filter in existence filter failed ("+c.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw c}try{l=new tm(o,s,i)}catch(c){return yo(c instanceof xa?"BloomFilter error: ":"Applying bloom filter failed: ",c),null}return l.Ie===0?null:l}Xe(e,n,r){return n.me.count===r-this.nt(e,n.targetId)?0:2}nt(e,n){const r=this.Le.getRemoteKeysForTarget(n);let s=0;return r.forEach(i=>{const o=this.Le.tt(),l=`projects/${o.projectId}/databases/${o.database}/documents/${i.path.canonicalString()}`;e.mightContain(l)||(this.Ue(n,i,null),s++)}),s}rt(e){const n=new Map;this.Be.forEach((i,o)=>{const l=this.Je(o);if(l){if(i.current&&bf(l.target)){const c=new ne(l.target.path);this.ke.get(c)!==null||this.it(o,c)||this.Ue(o,c,St.newNoDocument(c,e))}i.be&&(n.set(o,i.ve()),i.Ce())}});let r=ge();this.qe.forEach((i,o)=>{let l=!0;o.forEachWhile(c=>{const h=this.Je(c);return!h||h.purpose==="TargetPurposeLimboResolution"||(l=!1,!1)}),l&&(r=r.add(i))}),this.ke.forEach((i,o)=>o.setReadTime(e));const s=new md(e,n,this.Qe,this.ke,r);return this.ke=fr(),this.qe=Gy(),this.Qe=new Be(we),s}$e(e,n){if(!this.ze(e))return;const r=this.it(e,n.key)?2:0;this.Ge(e).Fe(n.key,r),this.ke=this.ke.insert(n.key,n),this.qe=this.qe.insert(n.key,this.st(n.key).add(e))}Ue(e,n,r){if(!this.ze(e))return;const s=this.Ge(e);this.it(e,n)?s.Fe(n,1):s.Me(n),this.qe=this.qe.insert(n,this.st(n).delete(e)),r&&(this.ke=this.ke.insert(n,r))}removeTarget(e){this.Be.delete(e)}Ye(e){const n=this.Ge(e).ve();return this.Le.getRemoteKeysForTarget(e).size+n.addedDocuments.size-n.removedDocuments.size}xe(e){this.Ge(e).xe()}Ge(e){let n=this.Be.get(e);return n||(n=new Hy,this.Be.set(e,n)),n}st(e){let n=this.qe.get(e);return n||(n=new pt(we),this.qe=this.qe.insert(e,n)),n}ze(e){const n=this.Je(e)!==null;return n||ee("WatchChangeAggregator","Detected inactive target",e),n}Je(e){const n=this.Be.get(e);return n&&n.Se?null:this.Le.ot(e)}je(e){this.Be.set(e,new Hy),this.Le.getRemoteKeysForTarget(e).forEach(n=>{this.Ue(e,n,null)})}it(e,n){return this.Le.getRemoteKeysForTarget(e).has(n)}}function Gy(){return new Be(ne.comparator)}function Ky(){return new Be(ne.comparator)}const bb={asc:"ASCENDING",desc:"DESCENDING"},Ab={"<":"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"},Nb={and:"AND",or:"OR"};class Pb{constructor(e,n){this.databaseId=e,this.useProto3Json=n}}function Pf(t,e){return t.useProto3Json||ld(e)?e:{value:e}}function Mu(t,e){return t.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function tx(t,e){return t.useProto3Json?e.toBase64():e.toUint8Array()}function Rb(t,e){return Mu(t,e.toTimestamp())}function Bn(t){return Te(!!t),ue.fromTimestamp(function(n){const r=cs(n);return new et(r.seconds,r.nanos)}(t))}function nm(t,e){return Rf(t,e).canonicalString()}function Rf(t,e){const n=function(s){return new De(["projects",s.projectId,"databases",s.database])}(t).child("documents");return e===void 0?n:n.child(e)}function nx(t){const e=De.fromString(t);return Te(ax(e)),e}function Df(t,e){return nm(t.databaseId,e.path)}function yh(t,e){const n=nx(e);if(n.get(1)!==t.databaseId.projectId)throw new X(U.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 X(U.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new ne(sx(n))}function rx(t,e){return nm(t.databaseId,e)}function Db(t){const e=nx(t);return e.length===4?De.emptyPath():sx(e)}function jf(t){return new De(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function sx(t){return Te(t.length>4&&t.get(4)==="documents"),t.popFirst(5)}function Qy(t,e,n){return{name:Df(t,e),fields:n.value.mapValue.fields}}function jb(t,e){let n;if("targetChange"in e){e.targetChange;const r=function(h){return h==="NO_CHANGE"?0:h==="ADD"?1:h==="REMOVE"?2:h==="CURRENT"?3:h==="RESET"?4:oe()}(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],i=function(h,m){return h.useProto3Json?(Te(m===void 0||typeof m=="string"),gt.fromBase64String(m||"")):(Te(m===void 0||m instanceof Buffer||m instanceof Uint8Array),gt.fromUint8Array(m||new Uint8Array))}(t,e.targetChange.resumeToken),o=e.targetChange.cause,l=o&&function(h){const m=h.code===void 0?U.UNKNOWN:Jw(h.code);return new X(m,h.message||"")}(o);n=new ex(r,s,i,l||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const s=yh(t,r.document.name),i=Bn(r.document.updateTime),o=r.document.createTime?Bn(r.document.createTime):ue.min(),l=new Bt({mapValue:{fields:r.document.fields}}),c=St.newFoundDocument(s,i,o,l),h=r.targetIds||[],m=r.removedTargetIds||[];n=new Xc(h,m,c.key,c)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const s=yh(t,r.document),i=r.readTime?Bn(r.readTime):ue.min(),o=St.newNoDocument(s,i),l=r.removedTargetIds||[];n=new Xc([],l,o.key,o)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const s=yh(t,r.document),i=r.removedTargetIds||[];n=new Xc([],i,s,null)}else{if(!("filter"in e))return oe();{e.filter;const r=e.filter;r.targetId;const{count:s=0,unchangedNames:i}=r,o=new kb(s,i),l=r.targetId;n=new Zw(l,o)}}return n}function Lb(t,e){let n;if(e instanceof kl)n={update:Qy(t,e.key,e.value)};else if(e instanceof pd)n={delete:Df(t,e.key)};else if(e instanceof ms)n={update:Qy(t,e.key,e.data),updateMask:Wb(e.fieldMask)};else{if(!(e instanceof wb))return oe();n={verify:Df(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map(r=>function(i,o){const l=o.transform;if(l instanceof Lu)return{fieldPath:o.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(l instanceof al)return{fieldPath:o.field.canonicalString(),appendMissingElements:{values:l.elements}};if(l instanceof ll)return{fieldPath:o.field.canonicalString(),removeAllFromArray:{values:l.elements}};if(l instanceof Ou)return{fieldPath:o.field.canonicalString(),increment:l.Pe};throw oe()}(0,r))),e.precondition.isNone||(n.currentDocument=function(s,i){return i.updateTime!==void 0?{updateTime:Rb(s,i.updateTime)}:i.exists!==void 0?{exists:i.exists}:oe()}(t,e.precondition)),n}function Ob(t,e){return t&&t.length>0?(Te(e!==void 0),t.map(n=>function(s,i){let o=s.updateTime?Bn(s.updateTime):Bn(i);return o.isEqual(ue.min())&&(o=Bn(i)),new yb(o,s.transformResults||[])}(n,e))):[]}function Mb(t,e){return{documents:[rx(t,e.path)]}}function Vb(t,e){const n={structuredQuery:{}},r=e.path;let s;e.collectionGroup!==null?(s=r,n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=r.popLast(),n.structuredQuery.from=[{collectionId:r.lastSegment()}]),n.parent=rx(t,s);const i=function(h){if(h.length!==0)return ox(Tn.create(h,"and"))}(e.filters);i&&(n.structuredQuery.where=i);const o=function(h){if(h.length!==0)return h.map(m=>function(g){return{field:Mi(g.field),direction:zb(g.dir)}}(m))}(e.orderBy);o&&(n.structuredQuery.orderBy=o);const l=Pf(t,e.limit);return l!==null&&(n.structuredQuery.limit=l),e.startAt&&(n.structuredQuery.startAt=function(h){return{before:h.inclusive,values:h.position}}(e.startAt)),e.endAt&&(n.structuredQuery.endAt=function(h){return{before:!h.inclusive,values:h.position}}(e.endAt)),{_t:n,parent:s}}function Fb(t){let e=Db(t.parent);const n=t.structuredQuery,r=n.from?n.from.length:0;let s=null;if(r>0){Te(r===1);const m=n.from[0];m.allDescendants?s=m.collectionId:e=e.child(m.collectionId)}let i=[];n.where&&(i=function(v){const g=ix(v);return g instanceof Tn&&Lw(g)?g.getFilters():[g]}(n.where));let o=[];n.orderBy&&(o=function(v){return v.map(g=>function(L){return new ju(Vi(L.field),function(z){switch(z){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(L.direction))}(g))}(n.orderBy));let l=null;n.limit&&(l=function(v){let g;return g=typeof v=="object"?v.value:v,ld(g)?null:g}(n.limit));let c=null;n.startAt&&(c=function(v){const g=!!v.before,N=v.values||[];return new Du(N,g)}(n.startAt));let h=null;return n.endAt&&(h=function(v){const g=!v.before,N=v.values||[];return new Du(N,g)}(n.endAt)),sb(e,s,o,i,l,"F",c,h)}function Ub(t,e){const n=function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return oe()}}(e.purpose);return n==null?null:{"goog-listen-tags":n}}function ix(t){return t.unaryFilter!==void 0?function(n){switch(n.unaryFilter.op){case"IS_NAN":const r=Vi(n.unaryFilter.field);return Xe.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=Vi(n.unaryFilter.field);return Xe.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const i=Vi(n.unaryFilter.field);return Xe.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const o=Vi(n.unaryFilter.field);return Xe.create(o,"!=",{nullValue:"NULL_VALUE"});default:return oe()}}(t):t.fieldFilter!==void 0?function(n){return Xe.create(Vi(n.fieldFilter.field),function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return oe()}}(n.fieldFilter.op),n.fieldFilter.value)}(t):t.compositeFilter!==void 0?function(n){return Tn.create(n.compositeFilter.filters.map(r=>ix(r)),function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return oe()}}(n.compositeFilter.op))}(t):oe()}function zb(t){return bb[t]}function Bb(t){return Ab[t]}function $b(t){return Nb[t]}function Mi(t){return{fieldPath:t.canonicalString()}}function Vi(t){return ht.fromServerFormat(t.fieldPath)}function ox(t){return t instanceof Xe?function(n){if(n.op==="=="){if(Ly(n.value))return{unaryFilter:{field:Mi(n.field),op:"IS_NAN"}};if(jy(n.value))return{unaryFilter:{field:Mi(n.field),op:"IS_NULL"}}}else if(n.op==="!="){if(Ly(n.value))return{unaryFilter:{field:Mi(n.field),op:"IS_NOT_NAN"}};if(jy(n.value))return{unaryFilter:{field:Mi(n.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Mi(n.field),op:Bb(n.op),value:n.value}}}(t):t instanceof Tn?function(n){const r=n.getFilters().map(s=>ox(s));return r.length===1?r[0]:{compositeFilter:{op:$b(n.op),filters:r}}}(t):oe()}function Wb(t){const e=[];return t.fields.forEach(n=>e.push(n.canonicalString())),{fieldPaths:e}}function ax(t){return t.length>=4&&t.get(0)==="projects"&&t.get(2)==="databases"}/** * @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 Gr{constructor(e,n,r,s,i=ue.min(),o=ue.min(),l=gt.EMPTY_BYTE_STRING,c=null){this.target=e,this.targetId=n,this.purpose=r,this.sequenceNumber=s,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=l,this.expectedCount=c}withSequenceNumber(e){return new Gr(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,n){return new Gr(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new Gr(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new Gr(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}/** * @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 qb{constructor(e){this.ct=e}}function Hb(t){const e=Fb({parent:t.parent,structuredQuery:t.structuredQuery});return t.limitType==="LAST"?Nf(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 Gb{constructor(){this.un=new Kb}addToCollectionParentIndex(e,n){return this.un.add(n),B.resolve()}getCollectionParents(e,n){return B.resolve(this.un.getEntries(n))}addFieldIndex(e,n){return B.resolve()}deleteFieldIndex(e,n){return B.resolve()}deleteAllFieldIndexes(e){return B.resolve()}createTargetIndexes(e,n){return B.resolve()}getDocumentsMatchingTarget(e,n){return B.resolve(null)}getIndexType(e,n){return B.resolve(0)}getFieldIndexes(e,n){return B.resolve([])}getNextCollectionGroupToUpdate(e){return B.resolve(null)}getMinOffset(e,n){return B.resolve(ls.min())}getMinOffsetFromCollectionGroup(e,n){return B.resolve(ls.min())}updateCollectionGroup(e,n,r){return B.resolve()}updateIndexEntries(e,n){return B.resolve()}}class Kb{constructor(){this.index={}}add(e){const n=e.lastSegment(),r=e.popLast(),s=this.index[n]||new pt(De.comparator),i=!s.has(r);return this.index[n]=s.add(r),i}has(e){const n=e.lastSegment(),r=e.popLast(),s=this.index[n];return s&&s.has(r)}getEntries(e){return(this.index[e]||new pt(De.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 xo{constructor(e){this.Ln=e}next(){return this.Ln+=2,this.Ln}static Bn(){return new xo(0)}static kn(){return new xo(-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 Qb{constructor(){this.changes=new No(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,St.newInvalidDocument(e).setReadTime(n))}getEntry(e,n){this.assertNotApplied();const r=this.changes.get(n);return r!==void 0?B.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 Yb{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 Xb{constructor(e,n,r,s){this.remoteDocumentCache=e,this.mutationQueue=n,this.documentOverlayCache=r,this.indexManager=s}getDocument(e,n){let r=null;return this.documentOverlayCache.getOverlay(e,n).next(s=>(r=s,this.remoteDocumentCache.getEntry(e,n))).next(s=>(r!==null&&Oa(r.mutation,s,Yt.empty(),et.now()),s))}getDocuments(e,n){return this.remoteDocumentCache.getEntries(e,n).next(r=>this.getLocalViewOfDocuments(e,r,ge()).next(()=>r))}getLocalViewOfDocuments(e,n,r=ge()){const s=$s();return this.populateOverlays(e,s,n).next(()=>this.computeViews(e,n,s,r).next(i=>{let o=wa();return i.forEach((l,c)=>{o=o.insert(l,c.overlayedDocument)}),o}))}getOverlayedDocuments(e,n){const r=$s();return this.populateOverlays(e,r,n).next(()=>this.computeViews(e,n,r,ge()))}populateOverlays(e,n,r){const s=[];return r.forEach(i=>{n.has(i)||s.push(i)}),this.documentOverlayCache.getOverlays(e,s).next(i=>{i.forEach((o,l)=>{n.set(o,l)})})}computeViews(e,n,r,s){let i=fr();const o=La(),l=function(){return La()}();return n.forEach((c,h)=>{const m=r.get(h.key);s.has(h.key)&&(m===void 0||m.mutation instanceof ms)?i=i.insert(h.key,h):m!==void 0?(o.set(h.key,m.mutation.getFieldMask()),Oa(m.mutation,h,m.mutation.getFieldMask(),et.now())):o.set(h.key,Yt.empty())}),this.recalculateAndSaveOverlays(e,i).next(c=>(c.forEach((h,m)=>o.set(h,m)),n.forEach((h,m)=>{var v;return l.set(h,new Yb(m,(v=o.get(h))!==null&&v!==void 0?v:null))}),l))}recalculateAndSaveOverlays(e,n){const r=La();let s=new Be((o,l)=>o-l),i=ge();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,n).next(o=>{for(const l of o)l.keys().forEach(c=>{const h=n.get(c);if(h===null)return;let m=r.get(c)||Yt.empty();m=l.applyToLocalView(h,m),r.set(c,m);const v=(s.get(l.batchId)||ge()).add(c);s=s.insert(l.batchId,v)})}).next(()=>{const o=[],l=s.getReverseIterator();for(;l.hasNext();){const c=l.getNext(),h=c.key,m=c.value,v=Ww();m.forEach(g=>{if(!i.has(g)){const N=Yw(n.get(g),r.get(g));N!==null&&v.set(g,N),i=i.add(g)}}),o.push(this.documentOverlayCache.saveOverlays(e,h,v))}return B.waitFor(o)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,n){return this.remoteDocumentCache.getEntries(e,n).next(r=>this.recalculateAndSaveOverlays(e,r))}getDocumentsMatchingQuery(e,n,r,s){return function(o){return ne.isDocumentKey(o.path)&&o.collectionGroup===null&&o.filters.length===0}(n)?this.getDocumentsMatchingDocumentQuery(e,n.path):Fw(n)?this.getDocumentsMatchingCollectionGroupQuery(e,n,r,s):this.getDocumentsMatchingCollectionQuery(e,n,r,s)}getNextDocuments(e,n,r,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,n,r,s).next(i=>{const o=s-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,n,r.largestBatchId,s-i.size):B.resolve($s());let l=-1,c=i;return o.next(h=>B.forEach(h,(m,v)=>(l{c=c.insert(m,g)}))).next(()=>this.populateOverlays(e,h,i)).next(()=>this.computeViews(e,c,h,ge())).next(m=>({batchId:l,changes:$w(m)})))})}getDocumentsMatchingDocumentQuery(e,n){return this.getDocument(e,new ne(n)).next(r=>{let s=wa();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s})}getDocumentsMatchingCollectionGroupQuery(e,n,r,s){const i=n.collectionGroup;let o=wa();return this.indexManager.getCollectionParents(e,i).next(l=>B.forEach(l,c=>{const h=function(v,g){return new El(g,null,v.explicitOrderBy.slice(),v.filters.slice(),v.limit,v.limitType,v.startAt,v.endAt)}(n,c.child(i));return this.getDocumentsMatchingCollectionQuery(e,h,r,s).next(m=>{m.forEach((v,g)=>{o=o.insert(v,g)})})}).next(()=>o))}getDocumentsMatchingCollectionQuery(e,n,r,s){let i;return this.documentOverlayCache.getOverlaysForCollection(e,n.path,r.largestBatchId).next(o=>(i=o,this.remoteDocumentCache.getDocumentsMatchingQuery(e,n,r,i,s))).next(o=>{i.forEach((c,h)=>{const m=h.getKey();o.get(m)===null&&(o=o.insert(m,St.newInvalidDocument(m)))});let l=wa();return o.forEach((c,h)=>{const m=i.get(c);m!==void 0&&Oa(m.mutation,h,Yt.empty(),et.now()),dd(n,h)&&(l=l.insert(c,h))}),l})}}/** * @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 Jb{constructor(e){this.serializer=e,this.hr=new Map,this.Pr=new Map}getBundleMetadata(e,n){return B.resolve(this.hr.get(n))}saveBundleMetadata(e,n){return this.hr.set(n.id,function(s){return{id:s.id,version:s.version,createTime:Bn(s.createTime)}}(n)),B.resolve()}getNamedQuery(e,n){return B.resolve(this.Pr.get(n))}saveNamedQuery(e,n){return this.Pr.set(n.name,function(s){return{name:s.name,query:Hb(s.bundledQuery),readTime:Bn(s.readTime)}}(n)),B.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 Zb{constructor(){this.overlays=new Be(ne.comparator),this.Ir=new Map}getOverlay(e,n){return B.resolve(this.overlays.get(n))}getOverlays(e,n){const r=$s();return B.forEach(n,s=>this.getOverlay(e,s).next(i=>{i!==null&&r.set(s,i)})).next(()=>r)}saveOverlays(e,n,r){return r.forEach((s,i)=>{this.ht(e,n,i)}),B.resolve()}removeOverlaysForBatchId(e,n,r){const s=this.Ir.get(r);return s!==void 0&&(s.forEach(i=>this.overlays=this.overlays.remove(i)),this.Ir.delete(r)),B.resolve()}getOverlaysForCollection(e,n,r){const s=$s(),i=n.length+1,o=new ne(n.child("")),l=this.overlays.getIteratorFrom(o);for(;l.hasNext();){const c=l.getNext().value,h=c.getKey();if(!n.isPrefixOf(h.path))break;h.path.length===i&&c.largestBatchId>r&&s.set(c.getKey(),c)}return B.resolve(s)}getOverlaysForCollectionGroup(e,n,r,s){let i=new Be((h,m)=>h-m);const o=this.overlays.getIterator();for(;o.hasNext();){const h=o.getNext().value;if(h.getKey().getCollectionGroup()===n&&h.largestBatchId>r){let m=i.get(h.largestBatchId);m===null&&(m=$s(),i=i.insert(h.largestBatchId,m)),m.set(h.getKey(),h)}}const l=$s(),c=i.getIterator();for(;c.hasNext()&&(c.getNext().value.forEach((h,m)=>l.set(h,m)),!(l.size()>=s)););return B.resolve(l)}ht(e,n,r){const s=this.overlays.get(r.key);if(s!==null){const o=this.Ir.get(s.largestBatchId).delete(r.key);this.Ir.set(s.largestBatchId,o)}this.overlays=this.overlays.insert(r.key,new Eb(n,r));let i=this.Ir.get(n);i===void 0&&(i=ge(),this.Ir.set(n,i)),this.Ir.set(n,i.add(r.key))}}/** * @license * Copyright 2024 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{constructor(){this.sessionToken=gt.EMPTY_BYTE_STRING}getSessionToken(e){return B.resolve(this.sessionToken)}setSessionToken(e,n){return this.sessionToken=n,B.resolve()}}/** * @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 rm{constructor(){this.Tr=new pt(ot.Er),this.dr=new pt(ot.Ar)}isEmpty(){return this.Tr.isEmpty()}addReference(e,n){const r=new ot(e,n);this.Tr=this.Tr.add(r),this.dr=this.dr.add(r)}Rr(e,n){e.forEach(r=>this.addReference(r,n))}removeReference(e,n){this.Vr(new ot(e,n))}mr(e,n){e.forEach(r=>this.removeReference(r,n))}gr(e){const n=new ne(new De([])),r=new ot(n,e),s=new ot(n,e+1),i=[];return this.dr.forEachInRange([r,s],o=>{this.Vr(o),i.push(o.key)}),i}pr(){this.Tr.forEach(e=>this.Vr(e))}Vr(e){this.Tr=this.Tr.delete(e),this.dr=this.dr.delete(e)}yr(e){const n=new ne(new De([])),r=new ot(n,e),s=new ot(n,e+1);let i=ge();return this.dr.forEachInRange([r,s],o=>{i=i.add(o.key)}),i}containsKey(e){const n=new ot(e,0),r=this.Tr.firstAfterOrEqual(n);return r!==null&&e.isEqual(r.key)}}class ot{constructor(e,n){this.key=e,this.wr=n}static Er(e,n){return ne.comparator(e.key,n.key)||we(e.wr,n.wr)}static Ar(e,n){return we(e.wr,n.wr)||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 tA{constructor(e,n){this.indexManager=e,this.referenceDelegate=n,this.mutationQueue=[],this.Sr=1,this.br=new pt(ot.Er)}checkEmpty(e){return B.resolve(this.mutationQueue.length===0)}addMutationBatch(e,n,r,s){const i=this.Sr;this.Sr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const o=new xb(i,n,r,s);this.mutationQueue.push(o);for(const l of s)this.br=this.br.add(new ot(l.key,i)),this.indexManager.addToCollectionParentIndex(e,l.key.path.popLast());return B.resolve(o)}lookupMutationBatch(e,n){return B.resolve(this.Dr(n))}getNextMutationBatchAfterBatchId(e,n){const r=n+1,s=this.vr(r),i=s<0?0:s;return B.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return B.resolve(this.mutationQueue.length===0?-1:this.Sr-1)}getAllMutationBatches(e){return B.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,n){const r=new ot(n,0),s=new ot(n,Number.POSITIVE_INFINITY),i=[];return this.br.forEachInRange([r,s],o=>{const l=this.Dr(o.wr);i.push(l)}),B.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,n){let r=new pt(we);return n.forEach(s=>{const i=new ot(s,0),o=new ot(s,Number.POSITIVE_INFINITY);this.br.forEachInRange([i,o],l=>{r=r.add(l.wr)})}),B.resolve(this.Cr(r))}getAllMutationBatchesAffectingQuery(e,n){const r=n.path,s=r.length+1;let i=r;ne.isDocumentKey(i)||(i=i.child(""));const o=new ot(new ne(i),0);let l=new pt(we);return this.br.forEachWhile(c=>{const h=c.key.path;return!!r.isPrefixOf(h)&&(h.length===s&&(l=l.add(c.wr)),!0)},o),B.resolve(this.Cr(l))}Cr(e){const n=[];return e.forEach(r=>{const s=this.Dr(r);s!==null&&n.push(s)}),n}removeMutationBatch(e,n){Te(this.Fr(n.batchId,"removed")===0),this.mutationQueue.shift();let r=this.br;return B.forEach(n.mutations,s=>{const i=new ot(s.key,n.batchId);return r=r.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)}).next(()=>{this.br=r})}On(e){}containsKey(e,n){const r=new ot(n,0),s=this.br.firstAfterOrEqual(r);return B.resolve(n.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,B.resolve()}Fr(e,n){return this.vr(e)}vr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Dr(e){const n=this.vr(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 nA{constructor(e){this.Mr=e,this.docs=function(){return new Be(ne.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,n){const r=n.key,s=this.docs.get(r),i=s?s.size:0,o=this.Mr(n);return this.docs=this.docs.insert(r,{document:n.mutableCopy(),size:o}),this.size+=o-i,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 B.resolve(r?r.document.mutableCopy():St.newInvalidDocument(n))}getEntries(e,n){let r=fr();return n.forEach(s=>{const i=this.docs.get(s);r=r.insert(s,i?i.document.mutableCopy():St.newInvalidDocument(s))}),B.resolve(r)}getDocumentsMatchingQuery(e,n,r,s){let i=fr();const o=n.path,l=new ne(o.child("")),c=this.docs.getIteratorFrom(l);for(;c.hasNext();){const{key:h,value:{document:m}}=c.getNext();if(!o.isPrefixOf(h.path))break;h.path.length>o.length+1||FC(VC(m),r)<=0||(s.has(m.key)||dd(n,m))&&(i=i.insert(m.key,m.mutableCopy()))}return B.resolve(i)}getAllFromCollectionGroup(e,n,r,s){oe()}Or(e,n){return B.forEach(this.docs,r=>n(r))}newChangeBuffer(e){return new rA(this)}getSize(e){return B.resolve(this.size)}}class rA extends Qb{constructor(e){super(),this.cr=e}applyChanges(e){const n=[];return this.changes.forEach((r,s)=>{s.isValidDocument()?n.push(this.cr.addEntry(e,s)):this.cr.removeEntry(r)}),B.waitFor(n)}getFromCache(e,n){return this.cr.getEntry(e,n)}getAllFromCache(e,n){return this.cr.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 sA{constructor(e){this.persistence=e,this.Nr=new No(n=>Xp(n),Jp),this.lastRemoteSnapshotVersion=ue.min(),this.highestTargetId=0,this.Lr=0,this.Br=new rm,this.targetCount=0,this.kr=xo.Bn()}forEachTarget(e,n){return this.Nr.forEach((r,s)=>n(s)),B.resolve()}getLastRemoteSnapshotVersion(e){return B.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return B.resolve(this.Lr)}allocateTargetId(e){return this.highestTargetId=this.kr.next(),B.resolve(this.highestTargetId)}setTargetsMetadata(e,n,r){return r&&(this.lastRemoteSnapshotVersion=r),n>this.Lr&&(this.Lr=n),B.resolve()}Kn(e){this.Nr.set(e.target,e);const n=e.targetId;n>this.highestTargetId&&(this.kr=new xo(n),this.highestTargetId=n),e.sequenceNumber>this.Lr&&(this.Lr=e.sequenceNumber)}addTargetData(e,n){return this.Kn(n),this.targetCount+=1,B.resolve()}updateTargetData(e,n){return this.Kn(n),B.resolve()}removeTargetData(e,n){return this.Nr.delete(n.target),this.Br.gr(n.targetId),this.targetCount-=1,B.resolve()}removeTargets(e,n,r){let s=0;const i=[];return this.Nr.forEach((o,l)=>{l.sequenceNumber<=n&&r.get(l.targetId)===null&&(this.Nr.delete(o),i.push(this.removeMatchingKeysForTargetId(e,l.targetId)),s++)}),B.waitFor(i).next(()=>s)}getTargetCount(e){return B.resolve(this.targetCount)}getTargetData(e,n){const r=this.Nr.get(n)||null;return B.resolve(r)}addMatchingKeys(e,n,r){return this.Br.Rr(n,r),B.resolve()}removeMatchingKeys(e,n,r){this.Br.mr(n,r);const s=this.persistence.referenceDelegate,i=[];return s&&n.forEach(o=>{i.push(s.markPotentiallyOrphaned(e,o))}),B.waitFor(i)}removeMatchingKeysForTargetId(e,n){return this.Br.gr(n),B.resolve()}getMatchingKeysForTargetId(e,n){const r=this.Br.yr(n);return B.resolve(r)}containsKey(e,n){return B.resolve(this.Br.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 iA{constructor(e,n){this.qr={},this.overlays={},this.Qr=new Gp(0),this.Kr=!1,this.Kr=!0,this.$r=new eA,this.referenceDelegate=e(this),this.Ur=new sA(this),this.indexManager=new Gb,this.remoteDocumentCache=function(s){return new nA(s)}(r=>this.referenceDelegate.Wr(r)),this.serializer=new qb(n),this.Gr=new Jb(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.Kr=!1,Promise.resolve()}get started(){return this.Kr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let n=this.overlays[e.toKey()];return n||(n=new Zb,this.overlays[e.toKey()]=n),n}getMutationQueue(e,n){let r=this.qr[e.toKey()];return r||(r=new tA(n,this.referenceDelegate),this.qr[e.toKey()]=r),r}getGlobalsCache(){return this.$r}getTargetCache(){return this.Ur}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Gr}runTransaction(e,n,r){ee("MemoryPersistence","Starting transaction:",e);const s=new oA(this.Qr.next());return this.referenceDelegate.zr(),r(s).next(i=>this.referenceDelegate.jr(s).next(()=>i)).toPromise().then(i=>(s.raiseOnCommittedEvent(),i))}Hr(e,n){return B.or(Object.values(this.qr).map(r=>()=>r.containsKey(e,n)))}}class oA extends zC{constructor(e){super(),this.currentSequenceNumber=e}}class sm{constructor(e){this.persistence=e,this.Jr=new rm,this.Yr=null}static Zr(e){return new sm(e)}get Xr(){if(this.Yr)return this.Yr;throw oe()}addReference(e,n,r){return this.Jr.addReference(r,n),this.Xr.delete(r.toString()),B.resolve()}removeReference(e,n,r){return this.Jr.removeReference(r,n),this.Xr.add(r.toString()),B.resolve()}markPotentiallyOrphaned(e,n){return this.Xr.add(n.toString()),B.resolve()}removeTarget(e,n){this.Jr.gr(n.targetId).forEach(s=>this.Xr.add(s.toString()));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,n.targetId).next(s=>{s.forEach(i=>this.Xr.add(i.toString()))}).next(()=>r.removeTargetData(e,n))}zr(){this.Yr=new Set}jr(e){const n=this.persistence.getRemoteDocumentCache().newChangeBuffer();return B.forEach(this.Xr,r=>{const s=ne.fromPath(r);return this.ei(e,s).next(i=>{i||n.removeEntry(s,ue.min())})}).next(()=>(this.Yr=null,n.apply(e)))}updateLimboDocument(e,n){return this.ei(e,n).next(r=>{r?this.Xr.delete(n.toString()):this.Xr.add(n.toString())})}Wr(e){return 0}ei(e,n){return B.or([()=>B.resolve(this.Jr.containsKey(n)),()=>this.persistence.getTargetCache().containsKey(e,n),()=>this.persistence.Hr(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 im{constructor(e,n,r,s){this.targetId=e,this.fromCache=n,this.$i=r,this.Ui=s}static Wi(e,n){let r=ge(),s=ge();for(const i of n.docChanges)switch(i.type){case 0:r=r.add(i.doc.key);break;case 1:s=s.add(i.doc.key)}return new im(e,n.fromCache,r,s)}}/** * @license * Copyright 2023 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(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=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 lA{constructor(){this.Gi=!1,this.zi=!1,this.ji=100,this.Hi=function(){return Q1()?8:BC(bt())>0?6:4}()}initialize(e,n){this.Ji=e,this.indexManager=n,this.Gi=!0}getDocumentsMatchingQuery(e,n,r,s){const i={result:null};return this.Yi(e,n).next(o=>{i.result=o}).next(()=>{if(!i.result)return this.Zi(e,n,s,r).next(o=>{i.result=o})}).next(()=>{if(i.result)return;const o=new aA;return this.Xi(e,n,o).next(l=>{if(i.result=l,this.zi)return this.es(e,n,o,l.size)})}).next(()=>i.result)}es(e,n,r,s){return r.documentReadCountthis.Hi*s?(ca()<=ye.DEBUG&&ee("QueryEngine","The SDK decides to create cache indexes for query:",Oi(n),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,zn(n))):B.resolve())}Yi(e,n){if(Fy(n))return B.resolve(null);let r=zn(n);return this.indexManager.getIndexType(e,r).next(s=>s===0?null:(n.limit!==null&&s===1&&(n=Nf(n,null,"F"),r=zn(n)),this.indexManager.getDocumentsMatchingTarget(e,r).next(i=>{const o=ge(...i);return this.Ji.getDocuments(e,o).next(l=>this.indexManager.getMinOffset(e,r).next(c=>{const h=this.ts(n,l);return this.ns(n,h,o,c.readTime)?this.Yi(e,Nf(n,null,"F")):this.rs(e,h,n,c)}))})))}Zi(e,n,r,s){return Fy(n)||s.isEqual(ue.min())?B.resolve(null):this.Ji.getDocuments(e,r).next(i=>{const o=this.ts(n,i);return this.ns(n,o,r,s)?B.resolve(null):(ca()<=ye.DEBUG&&ee("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),Oi(n)),this.rs(e,o,n,MC(s,-1)).next(l=>l))})}ts(e,n){let r=new pt(zw(e));return n.forEach((s,i)=>{dd(e,i)&&(r=r.add(i))}),r}ns(e,n,r,s){if(e.limit===null)return!1;if(r.size!==n.size)return!0;const i=e.limitType==="F"?n.last():n.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(s)>0)}Xi(e,n,r){return ca()<=ye.DEBUG&&ee("QueryEngine","Using full collection scan to execute query:",Oi(n)),this.Ji.getDocumentsMatchingQuery(e,n,ls.min(),r)}rs(e,n,r,s){return this.Ji.getDocumentsMatchingQuery(e,r,s).next(i=>(n.forEach(o=>{i=i.insert(o.key,o)}),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. */class cA{constructor(e,n,r,s){this.persistence=e,this.ss=n,this.serializer=s,this.os=new Be(we),this._s=new No(i=>Xp(i),Jp),this.us=new Map,this.cs=e.getRemoteDocumentCache(),this.Ur=e.getTargetCache(),this.Gr=e.getBundleCache(),this.ls(r)}ls(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Xb(this.cs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.cs.setIndexManager(this.indexManager),this.ss.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",n=>e.collect(n,this.os))}}function uA(t,e,n,r){return new cA(t,e,n,r)}async function lx(t,e){const n=de(t);return await n.persistence.runTransaction("Handle user change","readonly",r=>{let s;return n.mutationQueue.getAllMutationBatches(r).next(i=>(s=i,n.ls(e),n.mutationQueue.getAllMutationBatches(r))).next(i=>{const o=[],l=[];let c=ge();for(const h of s){o.push(h.batchId);for(const m of h.mutations)c=c.add(m.key)}for(const h of i){l.push(h.batchId);for(const m of h.mutations)c=c.add(m.key)}return n.localDocuments.getDocuments(r,c).next(h=>({hs:h,removedBatchIds:o,addedBatchIds:l}))})})}function dA(t,e){const n=de(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",r=>{const s=e.batch.keys(),i=n.cs.newChangeBuffer({trackRemovals:!0});return function(l,c,h,m){const v=h.batch,g=v.keys();let N=B.resolve();return g.forEach(L=>{N=N.next(()=>m.getEntry(c,L)).next(O=>{const z=h.docVersions.get(L);Te(z!==null),O.version.compareTo(z)<0&&(v.applyToRemoteDocument(O,h),O.isValidDocument()&&(O.setReadTime(h.commitVersion),m.addEntry(O)))})}),N.next(()=>l.mutationQueue.removeMutationBatch(c,v))}(n,r,e,i).next(()=>i.apply(r)).next(()=>n.mutationQueue.performConsistencyCheck(r)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(r,s,e.batch.batchId)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,function(l){let c=ge();for(let h=0;h0&&(c=c.add(l.batch.mutations[h].key));return c}(e))).next(()=>n.localDocuments.getDocuments(r,s))})}function cx(t){const e=de(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",n=>e.Ur.getLastRemoteSnapshotVersion(n))}function hA(t,e){const n=de(t),r=e.snapshotVersion;let s=n.os;return n.persistence.runTransaction("Apply remote event","readwrite-primary",i=>{const o=n.cs.newChangeBuffer({trackRemovals:!0});s=n.os;const l=[];e.targetChanges.forEach((m,v)=>{const g=s.get(v);if(!g)return;l.push(n.Ur.removeMatchingKeys(i,m.removedDocuments,v).next(()=>n.Ur.addMatchingKeys(i,m.addedDocuments,v)));let N=g.withSequenceNumber(i.currentSequenceNumber);e.targetMismatches.get(v)!==null?N=N.withResumeToken(gt.EMPTY_BYTE_STRING,ue.min()).withLastLimboFreeSnapshotVersion(ue.min()):m.resumeToken.approximateByteSize()>0&&(N=N.withResumeToken(m.resumeToken,r)),s=s.insert(v,N),function(O,z,I){return O.resumeToken.approximateByteSize()===0||z.snapshotVersion.toMicroseconds()-O.snapshotVersion.toMicroseconds()>=3e8?!0:I.addedDocuments.size+I.modifiedDocuments.size+I.removedDocuments.size>0}(g,N,m)&&l.push(n.Ur.updateTargetData(i,N))});let c=fr(),h=ge();if(e.documentUpdates.forEach(m=>{e.resolvedLimboDocuments.has(m)&&l.push(n.persistence.referenceDelegate.updateLimboDocument(i,m))}),l.push(fA(i,o,e.documentUpdates).next(m=>{c=m.Ps,h=m.Is})),!r.isEqual(ue.min())){const m=n.Ur.getLastRemoteSnapshotVersion(i).next(v=>n.Ur.setTargetsMetadata(i,i.currentSequenceNumber,r));l.push(m)}return B.waitFor(l).next(()=>o.apply(i)).next(()=>n.localDocuments.getLocalViewOfDocuments(i,c,h)).next(()=>c)}).then(i=>(n.os=s,i))}function fA(t,e,n){let r=ge(),s=ge();return n.forEach(i=>r=r.add(i)),e.getEntries(t,r).next(i=>{let o=fr();return n.forEach((l,c)=>{const h=i.get(l);c.isFoundDocument()!==h.isFoundDocument()&&(s=s.add(l)),c.isNoDocument()&&c.version.isEqual(ue.min())?(e.removeEntry(l,c.readTime),o=o.insert(l,c)):!h.isValidDocument()||c.version.compareTo(h.version)>0||c.version.compareTo(h.version)===0&&h.hasPendingWrites?(e.addEntry(c),o=o.insert(l,c)):ee("LocalStore","Ignoring outdated watch update for ",l,". Current version:",h.version," Watch version:",c.version)}),{Ps:o,Is:s}})}function pA(t,e){const n=de(t);return n.persistence.runTransaction("Get next mutation batch","readonly",r=>(e===void 0&&(e=-1),n.mutationQueue.getNextMutationBatchAfterBatchId(r,e)))}function mA(t,e){const n=de(t);return n.persistence.runTransaction("Allocate target","readwrite",r=>{let s;return n.Ur.getTargetData(r,e).next(i=>i?(s=i,B.resolve(s)):n.Ur.allocateTargetId(r).next(o=>(s=new Gr(e,o,"TargetPurposeListen",r.currentSequenceNumber),n.Ur.addTargetData(r,s).next(()=>s))))}).then(r=>{const s=n.os.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(n.os=n.os.insert(r.targetId,r),n._s.set(e,r.targetId)),r})}async function Lf(t,e,n){const r=de(t),s=r.os.get(e),i=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",i,o=>r.persistence.referenceDelegate.removeTarget(o,s))}catch(o){if(!xl(o))throw o;ee("LocalStore",`Failed to update sequence numbers for target ${e}: ${o}`)}r.os=r.os.remove(e),r._s.delete(s.target)}function Yy(t,e,n){const r=de(t);let s=ue.min(),i=ge();return r.persistence.runTransaction("Execute query","readwrite",o=>function(c,h,m){const v=de(c),g=v._s.get(m);return g!==void 0?B.resolve(v.os.get(g)):v.Ur.getTargetData(h,m)}(r,o,zn(e)).next(l=>{if(l)return s=l.lastLimboFreeSnapshotVersion,r.Ur.getMatchingKeysForTargetId(o,l.targetId).next(c=>{i=c})}).next(()=>r.ss.getDocumentsMatchingQuery(o,e,n?s:ue.min(),n?i:ge())).next(l=>(gA(r,ob(e),l),{documents:l,Ts:i})))}function gA(t,e,n){let r=t.us.get(e)||ue.min();n.forEach((s,i)=>{i.readTime.compareTo(r)>0&&(r=i.readTime)}),t.us.set(e,r)}class Xy{constructor(){this.activeTargetIds=hb()}fs(e){this.activeTargetIds=this.activeTargetIds.add(e)}gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Vs(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class yA{constructor(){this.so=new Xy,this.oo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,n,r){}addLocalQueryTarget(e,n=!0){return n&&this.so.fs(e),this.oo[e]||"not-current"}updateQueryState(e,n,r){this.oo[e]=n}removeLocalQueryTarget(e){this.so.gs(e)}isLocalQueryTarget(e){return this.so.activeTargetIds.has(e)}clearQueryState(e){delete this.oo[e]}getAllActiveQueryTargets(){return this.so.activeTargetIds}isActiveQueryTarget(e){return this.so.activeTargetIds.has(e)}start(){return this.so=new Xy,Promise.resolve()}handleUserChange(e,n,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(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 vA{_o(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 Jy{constructor(){this.ao=()=>this.uo(),this.co=()=>this.lo(),this.ho=[],this.Po()}_o(e){this.ho.push(e)}shutdown(){window.removeEventListener("online",this.ao),window.removeEventListener("offline",this.co)}Po(){window.addEventListener("online",this.ao),window.addEventListener("offline",this.co)}uo(){ee("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.ho)e(0)}lo(){ee("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const e of this.ho)e(1)}static D(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/** * @license * Copyright 2023 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 bc=null;function vh(){return bc===null?bc=function(){return 268435456+Math.round(2147483648*Math.random())}():bc++,"0x"+bc.toString(16)}/** * @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 _A={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};/** * @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 wA{constructor(e){this.Io=e.Io,this.To=e.To}Eo(e){this.Ao=e}Ro(e){this.Vo=e}mo(e){this.fo=e}onMessage(e){this.po=e}close(){this.To()}send(e){this.Io(e)}yo(){this.Ao()}wo(){this.Vo()}So(e){this.fo(e)}bo(e){this.po(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. */const xt="WebChannelConnection";class xA extends class{constructor(n){this.databaseInfo=n,this.databaseId=n.databaseId;const r=n.ssl?"https":"http",s=encodeURIComponent(this.databaseId.projectId),i=encodeURIComponent(this.databaseId.database);this.Do=r+"://"+n.host,this.vo=`projects/${s}/databases/${i}`,this.Co=this.databaseId.database==="(default)"?`project_id=${s}`:`project_id=${s}&database_id=${i}`}get Fo(){return!1}Mo(n,r,s,i,o){const l=vh(),c=this.xo(n,r.toUriEncodedString());ee("RestConnection",`Sending RPC '${n}' ${l}:`,c,s);const h={"google-cloud-resource-prefix":this.vo,"x-goog-request-params":this.Co};return this.Oo(h,i,o),this.No(n,c,h,s).then(m=>(ee("RestConnection",`Received RPC '${n}' ${l}: `,m),m),m=>{throw yo("RestConnection",`RPC '${n}' ${l} failed with error: `,m,"url: ",c,"request:",s),m})}Lo(n,r,s,i,o,l){return this.Mo(n,r,s,i,o)}Oo(n,r,s){n["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+Ao}(),n["Content-Type"]="text/plain",this.databaseInfo.appId&&(n["X-Firebase-GMPID"]=this.databaseInfo.appId),r&&r.headers.forEach((i,o)=>n[o]=i),s&&s.headers.forEach((i,o)=>n[o]=i)}xo(n,r){const s=_A[n];return`${this.Do}/v1/${r}:${s}`}terminate(){}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}No(e,n,r,s){const i=vh();return new Promise((o,l)=>{const c=new kw;c.setWithCredentials(!0),c.listenOnce(Tw.COMPLETE,()=>{try{switch(c.getLastErrorCode()){case Kc.NO_ERROR:const m=c.getResponseJson();ee(xt,`XHR for RPC '${e}' ${i} received:`,JSON.stringify(m)),o(m);break;case Kc.TIMEOUT:ee(xt,`RPC '${e}' ${i} timed out`),l(new X(U.DEADLINE_EXCEEDED,"Request time out"));break;case Kc.HTTP_ERROR:const v=c.getStatus();if(ee(xt,`RPC '${e}' ${i} failed with status:`,v,"response text:",c.getResponseText()),v>0){let g=c.getResponseJson();Array.isArray(g)&&(g=g[0]);const N=g==null?void 0:g.error;if(N&&N.status&&N.message){const L=function(z){const I=z.toLowerCase().replace(/_/g,"-");return Object.values(U).indexOf(I)>=0?I:U.UNKNOWN}(N.status);l(new X(L,N.message))}else l(new X(U.UNKNOWN,"Server responded with status "+c.getStatus()))}else l(new X(U.UNAVAILABLE,"Connection failed."));break;default:oe()}}finally{ee(xt,`RPC '${e}' ${i} completed.`)}});const h=JSON.stringify(s);ee(xt,`RPC '${e}' ${i} sending request:`,s),c.send(n,"POST",h,r,15)})}Bo(e,n,r){const s=vh(),i=[this.Do,"/","google.firestore.v1.Firestore","/",e,"/channel"],o=Cw(),l=Iw(),c={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},h=this.longPollingOptions.timeoutSeconds;h!==void 0&&(c.longPollingTimeout=Math.round(1e3*h)),this.useFetchStreams&&(c.useFetchStreams=!0),this.Oo(c.initMessageHeaders,n,r),c.encodeInitMessageHeaders=!0;const m=i.join("");ee(xt,`Creating RPC '${e}' stream ${s}: ${m}`,c);const v=o.createWebChannel(m,c);let g=!1,N=!1;const L=new wA({Io:z=>{N?ee(xt,`Not sending because RPC '${e}' stream ${s} is closed:`,z):(g||(ee(xt,`Opening RPC '${e}' stream ${s} transport.`),v.open(),g=!0),ee(xt,`RPC '${e}' stream ${s} sending:`,z),v.send(z))},To:()=>v.close()}),O=(z,I,x)=>{z.listen(I,b=>{try{x(b)}catch(F){setTimeout(()=>{throw F},0)}})};return O(v,_a.EventType.OPEN,()=>{N||(ee(xt,`RPC '${e}' stream ${s} transport opened.`),L.yo())}),O(v,_a.EventType.CLOSE,()=>{N||(N=!0,ee(xt,`RPC '${e}' stream ${s} transport closed`),L.So())}),O(v,_a.EventType.ERROR,z=>{N||(N=!0,yo(xt,`RPC '${e}' stream ${s} transport errored:`,z),L.So(new X(U.UNAVAILABLE,"The operation could not be completed")))}),O(v,_a.EventType.MESSAGE,z=>{var I;if(!N){const x=z.data[0];Te(!!x);const b=x,F=b.error||((I=b[0])===null||I===void 0?void 0:I.error);if(F){ee(xt,`RPC '${e}' stream ${s} received error:`,F);const K=F.status;let H=function(w){const S=Qe[w];if(S!==void 0)return Jw(S)}(K),k=F.message;H===void 0&&(H=U.INTERNAL,k="Unknown error status: "+K+" with message "+F.message),N=!0,L.So(new X(H,k)),v.close()}else ee(xt,`RPC '${e}' stream ${s} received:`,x),L.bo(x)}}),O(l,Sw.STAT_EVENT,z=>{z.stat===Tf.PROXY?ee(xt,`RPC '${e}' stream ${s} detected buffering proxy`):z.stat===Tf.NOPROXY&&ee(xt,`RPC '${e}' stream ${s} detected no buffering proxy`)}),setTimeout(()=>{L.wo()},0),L}}function _h(){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 gd(t){return new Pb(t,!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 ux{constructor(e,n,r=1e3,s=1.5,i=6e4){this.ui=e,this.timerId=n,this.ko=r,this.qo=s,this.Qo=i,this.Ko=0,this.$o=null,this.Uo=Date.now(),this.reset()}reset(){this.Ko=0}Wo(){this.Ko=this.Qo}Go(e){this.cancel();const n=Math.floor(this.Ko+this.zo()),r=Math.max(0,Date.now()-this.Uo),s=Math.max(0,n-r);s>0&&ee("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.Ko} ms, delay with jitter: ${n} ms, last attempt: ${r} ms ago)`),this.$o=this.ui.enqueueAfterDelay(this.timerId,s,()=>(this.Uo=Date.now(),e())),this.Ko*=this.qo,this.Kothis.Qo&&(this.Ko=this.Qo)}jo(){this.$o!==null&&(this.$o.skipDelay(),this.$o=null)}cancel(){this.$o!==null&&(this.$o.cancel(),this.$o=null)}zo(){return(Math.random()-.5)*this.Ko}}/** * @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 dx{constructor(e,n,r,s,i,o,l,c){this.ui=e,this.Ho=r,this.Jo=s,this.connection=i,this.authCredentialsProvider=o,this.appCheckCredentialsProvider=l,this.listener=c,this.state=0,this.Yo=0,this.Zo=null,this.Xo=null,this.stream=null,this.e_=0,this.t_=new ux(e,n)}n_(){return this.state===1||this.state===5||this.r_()}r_(){return this.state===2||this.state===3}start(){this.e_=0,this.state!==4?this.auth():this.i_()}async stop(){this.n_()&&await this.close(0)}s_(){this.state=0,this.t_.reset()}o_(){this.r_()&&this.Zo===null&&(this.Zo=this.ui.enqueueAfterDelay(this.Ho,6e4,()=>this.__()))}a_(e){this.u_(),this.stream.send(e)}async __(){if(this.r_())return this.close(0)}u_(){this.Zo&&(this.Zo.cancel(),this.Zo=null)}c_(){this.Xo&&(this.Xo.cancel(),this.Xo=null)}async close(e,n){this.u_(),this.c_(),this.t_.cancel(),this.Yo++,e!==4?this.t_.reset():n&&n.code===U.RESOURCE_EXHAUSTED?(hr(n.toString()),hr("Using maximum backoff delay to prevent overloading the backend."),this.t_.Wo()):n&&n.code===U.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.l_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.mo(n)}l_(){}auth(){this.state=1;const e=this.h_(this.Yo),n=this.Yo;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([r,s])=>{this.Yo===n&&this.P_(r,s)},r=>{e(()=>{const s=new X(U.UNKNOWN,"Fetching auth token failed: "+r.message);return this.I_(s)})})}P_(e,n){const r=this.h_(this.Yo);this.stream=this.T_(e,n),this.stream.Eo(()=>{r(()=>this.listener.Eo())}),this.stream.Ro(()=>{r(()=>(this.state=2,this.Xo=this.ui.enqueueAfterDelay(this.Jo,1e4,()=>(this.r_()&&(this.state=3),Promise.resolve())),this.listener.Ro()))}),this.stream.mo(s=>{r(()=>this.I_(s))}),this.stream.onMessage(s=>{r(()=>++this.e_==1?this.E_(s):this.onNext(s))})}i_(){this.state=5,this.t_.Go(async()=>{this.state=0,this.start()})}I_(e){return ee("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}h_(e){return n=>{this.ui.enqueueAndForget(()=>this.Yo===e?n():(ee("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class EA extends dx{constructor(e,n,r,s,i,o){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",n,r,s,o),this.serializer=i}T_(e,n){return this.connection.Bo("Listen",e,n)}E_(e){return this.onNext(e)}onNext(e){this.t_.reset();const n=jb(this.serializer,e),r=function(i){if(!("targetChange"in i))return ue.min();const o=i.targetChange;return o.targetIds&&o.targetIds.length?ue.min():o.readTime?Bn(o.readTime):ue.min()}(e);return this.listener.d_(n,r)}A_(e){const n={};n.database=jf(this.serializer),n.addTarget=function(i,o){let l;const c=o.target;if(l=bf(c)?{documents:Mb(i,c)}:{query:Vb(i,c)._t},l.targetId=o.targetId,o.resumeToken.approximateByteSize()>0){l.resumeToken=tx(i,o.resumeToken);const h=Pf(i,o.expectedCount);h!==null&&(l.expectedCount=h)}else if(o.snapshotVersion.compareTo(ue.min())>0){l.readTime=Mu(i,o.snapshotVersion.toTimestamp());const h=Pf(i,o.expectedCount);h!==null&&(l.expectedCount=h)}return l}(this.serializer,e);const r=Ub(this.serializer,e);r&&(n.labels=r),this.a_(n)}R_(e){const n={};n.database=jf(this.serializer),n.removeTarget=e,this.a_(n)}}class kA extends dx{constructor(e,n,r,s,i,o){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",n,r,s,o),this.serializer=i}get V_(){return this.e_>0}start(){this.lastStreamToken=void 0,super.start()}l_(){this.V_&&this.m_([])}T_(e,n){return this.connection.Bo("Write",e,n)}E_(e){return Te(!!e.streamToken),this.lastStreamToken=e.streamToken,Te(!e.writeResults||e.writeResults.length===0),this.listener.f_()}onNext(e){Te(!!e.streamToken),this.lastStreamToken=e.streamToken,this.t_.reset();const n=Ob(e.writeResults,e.commitTime),r=Bn(e.commitTime);return this.listener.g_(r,n)}p_(){const e={};e.database=jf(this.serializer),this.a_(e)}m_(e){const n={streamToken:this.lastStreamToken,writes:e.map(r=>Lb(this.serializer,r))};this.a_(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 TA extends class{}{constructor(e,n,r,s){super(),this.authCredentials=e,this.appCheckCredentials=n,this.connection=r,this.serializer=s,this.y_=!1}w_(){if(this.y_)throw new X(U.FAILED_PRECONDITION,"The client has already been terminated.")}Mo(e,n,r,s){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,o])=>this.connection.Mo(e,Rf(n,r),s,i,o)).catch(i=>{throw i.name==="FirebaseError"?(i.code===U.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),i):new X(U.UNKNOWN,i.toString())})}Lo(e,n,r,s,i){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([o,l])=>this.connection.Lo(e,Rf(n,r),s,o,l,i)).catch(o=>{throw o.name==="FirebaseError"?(o.code===U.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),o):new X(U.UNKNOWN,o.toString())})}terminate(){this.y_=!0,this.connection.terminate()}}class SA{constructor(e,n){this.asyncQueue=e,this.onlineStateHandler=n,this.state="Unknown",this.S_=0,this.b_=null,this.D_=!0}v_(){this.S_===0&&(this.C_("Unknown"),this.b_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.b_=null,this.F_("Backend didn't respond within 10 seconds."),this.C_("Offline"),Promise.resolve())))}M_(e){this.state==="Online"?this.C_("Unknown"):(this.S_++,this.S_>=1&&(this.x_(),this.F_(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.C_("Offline")))}set(e){this.x_(),this.S_=0,e==="Online"&&(this.D_=!1),this.C_(e)}C_(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}F_(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.D_?(hr(n),this.D_=!1):ee("OnlineStateTracker",n)}x_(){this.b_!==null&&(this.b_.cancel(),this.b_=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 IA{constructor(e,n,r,s,i){this.localStore=e,this.datastore=n,this.asyncQueue=r,this.remoteSyncer={},this.O_=[],this.N_=new Map,this.L_=new Set,this.B_=[],this.k_=i,this.k_._o(o=>{r.enqueueAndForget(async()=>{ai(this)&&(ee("RemoteStore","Restarting streams for network reachability change."),await async function(c){const h=de(c);h.L_.add(4),await Sl(h),h.q_.set("Unknown"),h.L_.delete(4),await yd(h)}(this))})}),this.q_=new SA(r,s)}}async function yd(t){if(ai(t))for(const e of t.B_)await e(!0)}async function Sl(t){for(const e of t.B_)await e(!1)}function hx(t,e){const n=de(t);n.N_.has(e.targetId)||(n.N_.set(e.targetId,e),cm(n)?lm(n):Po(n).r_()&&am(n,e))}function om(t,e){const n=de(t),r=Po(n);n.N_.delete(e),r.r_()&&fx(n,e),n.N_.size===0&&(r.r_()?r.o_():ai(n)&&n.q_.set("Unknown"))}function am(t,e){if(t.Q_.xe(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(ue.min())>0){const n=t.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(n)}Po(t).A_(e)}function fx(t,e){t.Q_.xe(e),Po(t).R_(e)}function lm(t){t.Q_=new Cb({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),ot:e=>t.N_.get(e)||null,tt:()=>t.datastore.serializer.databaseId}),Po(t).start(),t.q_.v_()}function cm(t){return ai(t)&&!Po(t).n_()&&t.N_.size>0}function ai(t){return de(t).L_.size===0}function px(t){t.Q_=void 0}async function CA(t){t.q_.set("Online")}async function bA(t){t.N_.forEach((e,n)=>{am(t,e)})}async function AA(t,e){px(t),cm(t)?(t.q_.M_(e),lm(t)):t.q_.set("Unknown")}async function NA(t,e,n){if(t.q_.set("Online"),e instanceof ex&&e.state===2&&e.cause)try{await async function(s,i){const o=i.cause;for(const l of i.targetIds)s.N_.has(l)&&(await s.remoteSyncer.rejectListen(l,o),s.N_.delete(l),s.Q_.removeTarget(l))}(t,e)}catch(r){ee("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),r),await Vu(t,r)}else if(e instanceof Xc?t.Q_.Ke(e):e instanceof Zw?t.Q_.He(e):t.Q_.We(e),!n.isEqual(ue.min()))try{const r=await cx(t.localStore);n.compareTo(r)>=0&&await function(i,o){const l=i.Q_.rt(o);return l.targetChanges.forEach((c,h)=>{if(c.resumeToken.approximateByteSize()>0){const m=i.N_.get(h);m&&i.N_.set(h,m.withResumeToken(c.resumeToken,o))}}),l.targetMismatches.forEach((c,h)=>{const m=i.N_.get(c);if(!m)return;i.N_.set(c,m.withResumeToken(gt.EMPTY_BYTE_STRING,m.snapshotVersion)),fx(i,c);const v=new Gr(m.target,c,h,m.sequenceNumber);am(i,v)}),i.remoteSyncer.applyRemoteEvent(l)}(t,n)}catch(r){ee("RemoteStore","Failed to raise snapshot:",r),await Vu(t,r)}}async function Vu(t,e,n){if(!xl(e))throw e;t.L_.add(1),await Sl(t),t.q_.set("Offline"),n||(n=()=>cx(t.localStore)),t.asyncQueue.enqueueRetryable(async()=>{ee("RemoteStore","Retrying IndexedDB access"),await n(),t.L_.delete(1),await yd(t)})}function mx(t,e){return e().catch(n=>Vu(t,n,e))}async function vd(t){const e=de(t),n=us(e);let r=e.O_.length>0?e.O_[e.O_.length-1].batchId:-1;for(;PA(e);)try{const s=await pA(e.localStore,r);if(s===null){e.O_.length===0&&n.o_();break}r=s.batchId,RA(e,s)}catch(s){await Vu(e,s)}gx(e)&&yx(e)}function PA(t){return ai(t)&&t.O_.length<10}function RA(t,e){t.O_.push(e);const n=us(t);n.r_()&&n.V_&&n.m_(e.mutations)}function gx(t){return ai(t)&&!us(t).n_()&&t.O_.length>0}function yx(t){us(t).start()}async function DA(t){us(t).p_()}async function jA(t){const e=us(t);for(const n of t.O_)e.m_(n.mutations)}async function LA(t,e,n){const r=t.O_.shift(),s=em.from(r,e,n);await mx(t,()=>t.remoteSyncer.applySuccessfulWrite(s)),await vd(t)}async function OA(t,e){e&&us(t).V_&&await async function(r,s){if(function(o){return Tb(o)&&o!==U.ABORTED}(s.code)){const i=r.O_.shift();us(r).s_(),await mx(r,()=>r.remoteSyncer.rejectFailedWrite(i.batchId,s)),await vd(r)}}(t,e),gx(t)&&yx(t)}async function Zy(t,e){const n=de(t);n.asyncQueue.verifyOperationInProgress(),ee("RemoteStore","RemoteStore received new credentials");const r=ai(n);n.L_.add(3),await Sl(n),r&&n.q_.set("Unknown"),await n.remoteSyncer.handleCredentialChange(e),n.L_.delete(3),await yd(n)}async function MA(t,e){const n=de(t);e?(n.L_.delete(2),await yd(n)):e||(n.L_.add(2),await Sl(n),n.q_.set("Unknown"))}function Po(t){return t.K_||(t.K_=function(n,r,s){const i=de(n);return i.w_(),new EA(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)}(t.datastore,t.asyncQueue,{Eo:CA.bind(null,t),Ro:bA.bind(null,t),mo:AA.bind(null,t),d_:NA.bind(null,t)}),t.B_.push(async e=>{e?(t.K_.s_(),cm(t)?lm(t):t.q_.set("Unknown")):(await t.K_.stop(),px(t))})),t.K_}function us(t){return t.U_||(t.U_=function(n,r,s){const i=de(n);return i.w_(),new kA(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)}(t.datastore,t.asyncQueue,{Eo:()=>Promise.resolve(),Ro:DA.bind(null,t),mo:OA.bind(null,t),f_:jA.bind(null,t),g_:LA.bind(null,t)}),t.B_.push(async e=>{e?(t.U_.s_(),await vd(t)):(await t.U_.stop(),t.O_.length>0&&(ee("RemoteStore",`Stopping write stream with ${t.O_.length} pending writes`),t.O_=[]))})),t.U_}/** * @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 um{constructor(e,n,r,s,i){this.asyncQueue=e,this.timerId=n,this.targetTimeMs=r,this.op=s,this.removalCallback=i,this.deferred=new ir,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(o=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,n,r,s,i){const o=Date.now()+r,l=new um(e,n,o,s,i);return l.start(r),l}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new X(U.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 dm(t,e){if(hr("AsyncQueue",`${e}: ${t}`),xl(t))return new X(U.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 ao{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=wa(),this.sortedSet=new Be(this.comparator)}static emptySet(e){return new ao(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 ao)||this.size!==e.size)return!1;const n=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;n.hasNext();){const s=n.getNext().key,i=r.getNext().key;if(!s.isEqual(i))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 ao;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 ev{constructor(){this.W_=new Be(ne.comparator)}track(e){const n=e.doc.key,r=this.W_.get(n);r?e.type!==0&&r.type===3?this.W_=this.W_.insert(n,e):e.type===3&&r.type!==1?this.W_=this.W_.insert(n,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.W_=this.W_.insert(n,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.W_=this.W_.insert(n,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.W_=this.W_.remove(n):e.type===1&&r.type===2?this.W_=this.W_.insert(n,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.W_=this.W_.insert(n,{type:2,doc:e.doc}):oe():this.W_=this.W_.insert(n,e)}G_(){const e=[];return this.W_.inorderTraversal((n,r)=>{e.push(r)}),e}}class Eo{constructor(e,n,r,s,i,o,l,c,h){this.query=e,this.docs=n,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=i,this.fromCache=o,this.syncStateChanged=l,this.excludesMetadataChanges=c,this.hasCachedResults=h}static fromInitialDocuments(e,n,r,s,i){const o=[];return n.forEach(l=>{o.push({type:0,doc:l})}),new Eo(e,n,ao.emptySet(n),o,r,s,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&ud(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 s=0;se.J_())}}class FA{constructor(){this.queries=tv(),this.onlineState="Unknown",this.Y_=new Set}terminate(){(function(n,r){const s=de(n),i=s.queries;s.queries=tv(),i.forEach((o,l)=>{for(const c of l.j_)c.onError(r)})})(this,new X(U.ABORTED,"Firestore shutting down"))}}function tv(){return new No(t=>Uw(t),ud)}async function hm(t,e){const n=de(t);let r=3;const s=e.query;let i=n.queries.get(s);i?!i.H_()&&e.J_()&&(r=2):(i=new VA,r=e.J_()?0:1);try{switch(r){case 0:i.z_=await n.onListen(s,!0);break;case 1:i.z_=await n.onListen(s,!1);break;case 2:await n.onFirstRemoteStoreListen(s)}}catch(o){const l=dm(o,`Initialization of query '${Oi(e.query)}' failed`);return void e.onError(l)}n.queries.set(s,i),i.j_.push(e),e.Z_(n.onlineState),i.z_&&e.X_(i.z_)&&pm(n)}async function fm(t,e){const n=de(t),r=e.query;let s=3;const i=n.queries.get(r);if(i){const o=i.j_.indexOf(e);o>=0&&(i.j_.splice(o,1),i.j_.length===0?s=e.J_()?0:1:!i.H_()&&e.J_()&&(s=2))}switch(s){case 0:return n.queries.delete(r),n.onUnlisten(r,!0);case 1:return n.queries.delete(r),n.onUnlisten(r,!1);case 2:return n.onLastRemoteStoreUnlisten(r);default:return}}function UA(t,e){const n=de(t);let r=!1;for(const s of e){const i=s.query,o=n.queries.get(i);if(o){for(const l of o.j_)l.X_(s)&&(r=!0);o.z_=s}}r&&pm(n)}function zA(t,e,n){const r=de(t),s=r.queries.get(e);if(s)for(const i of s.j_)i.onError(n);r.queries.delete(e)}function pm(t){t.Y_.forEach(e=>{e.next()})}var Of,nv;(nv=Of||(Of={})).ea="default",nv.Cache="cache";class mm{constructor(e,n,r){this.query=e,this.ta=n,this.na=!1,this.ra=null,this.onlineState="Unknown",this.options=r||{}}X_(e){if(!this.options.includeMetadataChanges){const r=[];for(const s of e.docChanges)s.type!==3&&r.push(s);e=new Eo(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let n=!1;return this.na?this.ia(e)&&(this.ta.next(e),n=!0):this.sa(e,this.onlineState)&&(this.oa(e),n=!0),this.ra=e,n}onError(e){this.ta.error(e)}Z_(e){this.onlineState=e;let n=!1;return this.ra&&!this.na&&this.sa(this.ra,e)&&(this.oa(this.ra),n=!0),n}sa(e,n){if(!e.fromCache||!this.J_())return!0;const r=n!=="Offline";return(!this.options._a||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||n==="Offline")}ia(e){if(e.docChanges.length>0)return!0;const n=this.ra&&this.ra.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!n)&&this.options.includeMetadataChanges===!0}oa(e){e=Eo.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.na=!0,this.ta.next(e)}J_(){return this.options.source!==Of.Cache}}/** * @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 vx{constructor(e){this.key=e}}class _x{constructor(e){this.key=e}}class BA{constructor(e,n){this.query=e,this.Ta=n,this.Ea=null,this.hasCachedResults=!1,this.current=!1,this.da=ge(),this.mutatedKeys=ge(),this.Aa=zw(e),this.Ra=new ao(this.Aa)}get Va(){return this.Ta}ma(e,n){const r=n?n.fa:new ev,s=n?n.Ra:this.Ra;let i=n?n.mutatedKeys:this.mutatedKeys,o=s,l=!1;const c=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,h=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal((m,v)=>{const g=s.get(m),N=dd(this.query,v)?v:null,L=!!g&&this.mutatedKeys.has(g.key),O=!!N&&(N.hasLocalMutations||this.mutatedKeys.has(N.key)&&N.hasCommittedMutations);let z=!1;g&&N?g.data.isEqual(N.data)?L!==O&&(r.track({type:3,doc:N}),z=!0):this.ga(g,N)||(r.track({type:2,doc:N}),z=!0,(c&&this.Aa(N,c)>0||h&&this.Aa(N,h)<0)&&(l=!0)):!g&&N?(r.track({type:0,doc:N}),z=!0):g&&!N&&(r.track({type:1,doc:g}),z=!0,(c||h)&&(l=!0)),z&&(N?(o=o.add(N),i=O?i.add(m):i.delete(m)):(o=o.delete(m),i=i.delete(m)))}),this.query.limit!==null)for(;o.size>this.query.limit;){const m=this.query.limitType==="F"?o.last():o.first();o=o.delete(m.key),i=i.delete(m.key),r.track({type:1,doc:m})}return{Ra:o,fa:r,ns:l,mutatedKeys:i}}ga(e,n){return e.hasLocalMutations&&n.hasCommittedMutations&&!n.hasLocalMutations}applyChanges(e,n,r,s){const i=this.Ra;this.Ra=e.Ra,this.mutatedKeys=e.mutatedKeys;const o=e.fa.G_();o.sort((m,v)=>function(N,L){const O=z=>{switch(z){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return oe()}};return O(N)-O(L)}(m.type,v.type)||this.Aa(m.doc,v.doc)),this.pa(r),s=s!=null&&s;const l=n&&!s?this.ya():[],c=this.da.size===0&&this.current&&!s?1:0,h=c!==this.Ea;return this.Ea=c,o.length!==0||h?{snapshot:new Eo(this.query,e.Ra,i,o,e.mutatedKeys,c===0,h,!1,!!r&&r.resumeToken.approximateByteSize()>0),wa:l}:{wa:l}}Z_(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({Ra:this.Ra,fa:new ev,mutatedKeys:this.mutatedKeys,ns:!1},!1)):{wa:[]}}Sa(e){return!this.Ta.has(e)&&!!this.Ra.has(e)&&!this.Ra.get(e).hasLocalMutations}pa(e){e&&(e.addedDocuments.forEach(n=>this.Ta=this.Ta.add(n)),e.modifiedDocuments.forEach(n=>{}),e.removedDocuments.forEach(n=>this.Ta=this.Ta.delete(n)),this.current=e.current)}ya(){if(!this.current)return[];const e=this.da;this.da=ge(),this.Ra.forEach(r=>{this.Sa(r.key)&&(this.da=this.da.add(r.key))});const n=[];return e.forEach(r=>{this.da.has(r)||n.push(new _x(r))}),this.da.forEach(r=>{e.has(r)||n.push(new vx(r))}),n}ba(e){this.Ta=e.Ts,this.da=ge();const n=this.ma(e.documents);return this.applyChanges(n,!0)}Da(){return Eo.fromInitialDocuments(this.query,this.Ra,this.mutatedKeys,this.Ea===0,this.hasCachedResults)}}class $A{constructor(e,n,r){this.query=e,this.targetId=n,this.view=r}}class WA{constructor(e){this.key=e,this.va=!1}}class qA{constructor(e,n,r,s,i,o){this.localStore=e,this.remoteStore=n,this.eventManager=r,this.sharedClientState=s,this.currentUser=i,this.maxConcurrentLimboResolutions=o,this.Ca={},this.Fa=new No(l=>Uw(l),ud),this.Ma=new Map,this.xa=new Set,this.Oa=new Be(ne.comparator),this.Na=new Map,this.La=new rm,this.Ba={},this.ka=new Map,this.qa=xo.kn(),this.onlineState="Unknown",this.Qa=void 0}get isPrimaryClient(){return this.Qa===!0}}async function HA(t,e,n=!0){const r=Sx(t);let s;const i=r.Fa.get(e);return i?(r.sharedClientState.addLocalQueryTarget(i.targetId),s=i.view.Da()):s=await wx(r,e,n,!0),s}async function GA(t,e){const n=Sx(t);await wx(n,e,!0,!1)}async function wx(t,e,n,r){const s=await mA(t.localStore,zn(e)),i=s.targetId,o=t.sharedClientState.addLocalQueryTarget(i,n);let l;return r&&(l=await KA(t,e,i,o==="current",s.resumeToken)),t.isPrimaryClient&&n&&hx(t.remoteStore,s),l}async function KA(t,e,n,r,s){t.Ka=(v,g,N)=>async function(O,z,I,x){let b=z.view.ma(I);b.ns&&(b=await Yy(O.localStore,z.query,!1).then(({documents:k})=>z.view.ma(k,b)));const F=x&&x.targetChanges.get(z.targetId),K=x&&x.targetMismatches.get(z.targetId)!=null,H=z.view.applyChanges(b,O.isPrimaryClient,F,K);return sv(O,z.targetId,H.wa),H.snapshot}(t,v,g,N);const i=await Yy(t.localStore,e,!0),o=new BA(e,i.Ts),l=o.ma(i.documents),c=Tl.createSynthesizedTargetChangeForCurrentChange(n,r&&t.onlineState!=="Offline",s),h=o.applyChanges(l,t.isPrimaryClient,c);sv(t,n,h.wa);const m=new $A(e,n,o);return t.Fa.set(e,m),t.Ma.has(n)?t.Ma.get(n).push(e):t.Ma.set(n,[e]),h.snapshot}async function QA(t,e,n){const r=de(t),s=r.Fa.get(e),i=r.Ma.get(s.targetId);if(i.length>1)return r.Ma.set(s.targetId,i.filter(o=>!ud(o,e))),void r.Fa.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedClientState.isActiveQueryTarget(s.targetId)||await Lf(r.localStore,s.targetId,!1).then(()=>{r.sharedClientState.clearQueryState(s.targetId),n&&om(r.remoteStore,s.targetId),Mf(r,s.targetId)}).catch(wl)):(Mf(r,s.targetId),await Lf(r.localStore,s.targetId,!0))}async function YA(t,e){const n=de(t),r=n.Fa.get(e),s=n.Ma.get(r.targetId);n.isPrimaryClient&&s.length===1&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),om(n.remoteStore,r.targetId))}async function XA(t,e,n){const r=s2(t);try{const s=await function(o,l){const c=de(o),h=et.now(),m=l.reduce((N,L)=>N.add(L.key),ge());let v,g;return c.persistence.runTransaction("Locally write mutations","readwrite",N=>{let L=fr(),O=ge();return c.cs.getEntries(N,m).next(z=>{L=z,L.forEach((I,x)=>{x.isValidDocument()||(O=O.add(I))})}).next(()=>c.localDocuments.getOverlayedDocuments(N,L)).next(z=>{v=z;const I=[];for(const x of l){const b=_b(x,v.get(x.key).overlayedDocument);b!=null&&I.push(new ms(x.key,b,Rw(b.value.mapValue),Rt.exists(!0)))}return c.mutationQueue.addMutationBatch(N,h,I,l)}).next(z=>{g=z;const I=z.applyToLocalDocumentSet(v,O);return c.documentOverlayCache.saveOverlays(N,z.batchId,I)})}).then(()=>({batchId:g.batchId,changes:$w(v)}))}(r.localStore,e);r.sharedClientState.addPendingMutation(s.batchId),function(o,l,c){let h=o.Ba[o.currentUser.toKey()];h||(h=new Be(we)),h=h.insert(l,c),o.Ba[o.currentUser.toKey()]=h}(r,s.batchId,n),await Il(r,s.changes),await vd(r.remoteStore)}catch(s){const i=dm(s,"Failed to persist write");n.reject(i)}}async function xx(t,e){const n=de(t);try{const r=await hA(n.localStore,e);e.targetChanges.forEach((s,i)=>{const o=n.Na.get(i);o&&(Te(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1),s.addedDocuments.size>0?o.va=!0:s.modifiedDocuments.size>0?Te(o.va):s.removedDocuments.size>0&&(Te(o.va),o.va=!1))}),await Il(n,r,e)}catch(r){await wl(r)}}function rv(t,e,n){const r=de(t);if(r.isPrimaryClient&&n===0||!r.isPrimaryClient&&n===1){const s=[];r.Fa.forEach((i,o)=>{const l=o.view.Z_(e);l.snapshot&&s.push(l.snapshot)}),function(o,l){const c=de(o);c.onlineState=l;let h=!1;c.queries.forEach((m,v)=>{for(const g of v.j_)g.Z_(l)&&(h=!0)}),h&&pm(c)}(r.eventManager,e),s.length&&r.Ca.d_(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function JA(t,e,n){const r=de(t);r.sharedClientState.updateQueryState(e,"rejected",n);const s=r.Na.get(e),i=s&&s.key;if(i){let o=new Be(ne.comparator);o=o.insert(i,St.newNoDocument(i,ue.min()));const l=ge().add(i),c=new md(ue.min(),new Map,new Be(we),o,l);await xx(r,c),r.Oa=r.Oa.remove(i),r.Na.delete(e),gm(r)}else await Lf(r.localStore,e,!1).then(()=>Mf(r,e,n)).catch(wl)}async function ZA(t,e){const n=de(t),r=e.batch.batchId;try{const s=await dA(n.localStore,e);kx(n,r,null),Ex(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await Il(n,s)}catch(s){await wl(s)}}async function e2(t,e,n){const r=de(t);try{const s=await function(o,l){const c=de(o);return c.persistence.runTransaction("Reject batch","readwrite-primary",h=>{let m;return c.mutationQueue.lookupMutationBatch(h,l).next(v=>(Te(v!==null),m=v.keys(),c.mutationQueue.removeMutationBatch(h,v))).next(()=>c.mutationQueue.performConsistencyCheck(h)).next(()=>c.documentOverlayCache.removeOverlaysForBatchId(h,m,l)).next(()=>c.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(h,m)).next(()=>c.localDocuments.getDocuments(h,m))})}(r.localStore,e);kx(r,e,n),Ex(r,e),r.sharedClientState.updateMutationState(e,"rejected",n),await Il(r,s)}catch(s){await wl(s)}}function Ex(t,e){(t.ka.get(e)||[]).forEach(n=>{n.resolve()}),t.ka.delete(e)}function kx(t,e,n){const r=de(t);let s=r.Ba[r.currentUser.toKey()];if(s){const i=s.get(e);i&&(n?i.reject(n):i.resolve(),s=s.remove(e)),r.Ba[r.currentUser.toKey()]=s}}function Mf(t,e,n=null){t.sharedClientState.removeLocalQueryTarget(e);for(const r of t.Ma.get(e))t.Fa.delete(r),n&&t.Ca.$a(r,n);t.Ma.delete(e),t.isPrimaryClient&&t.La.gr(e).forEach(r=>{t.La.containsKey(r)||Tx(t,r)})}function Tx(t,e){t.xa.delete(e.path.canonicalString());const n=t.Oa.get(e);n!==null&&(om(t.remoteStore,n),t.Oa=t.Oa.remove(e),t.Na.delete(n),gm(t))}function sv(t,e,n){for(const r of n)r instanceof vx?(t.La.addReference(r.key,e),t2(t,r)):r instanceof _x?(ee("SyncEngine","Document no longer in limbo: "+r.key),t.La.removeReference(r.key,e),t.La.containsKey(r.key)||Tx(t,r.key)):oe()}function t2(t,e){const n=e.key,r=n.path.canonicalString();t.Oa.get(n)||t.xa.has(r)||(ee("SyncEngine","New document in limbo: "+n),t.xa.add(r),gm(t))}function gm(t){for(;t.xa.size>0&&t.Oa.size{o.push(r.Ka(c,e,n).then(h=>{var m;if((h||n)&&r.isPrimaryClient){const v=h?!h.fromCache:(m=n==null?void 0:n.targetChanges.get(c.targetId))===null||m===void 0?void 0:m.current;r.sharedClientState.updateQueryState(c.targetId,v?"current":"not-current")}if(h){s.push(h);const v=im.Wi(c.targetId,h);i.push(v)}}))}),await Promise.all(o),r.Ca.d_(s),await async function(c,h){const m=de(c);try{await m.persistence.runTransaction("notifyLocalViewChanges","readwrite",v=>B.forEach(h,g=>B.forEach(g.$i,N=>m.persistence.referenceDelegate.addReference(v,g.targetId,N)).next(()=>B.forEach(g.Ui,N=>m.persistence.referenceDelegate.removeReference(v,g.targetId,N)))))}catch(v){if(!xl(v))throw v;ee("LocalStore","Failed to update sequence numbers: "+v)}for(const v of h){const g=v.targetId;if(!v.fromCache){const N=m.os.get(g),L=N.snapshotVersion,O=N.withLastLimboFreeSnapshotVersion(L);m.os=m.os.insert(g,O)}}}(r.localStore,i))}async function n2(t,e){const n=de(t);if(!n.currentUser.isEqual(e)){ee("SyncEngine","User change. New user:",e.toKey());const r=await lx(n.localStore,e);n.currentUser=e,function(i,o){i.ka.forEach(l=>{l.forEach(c=>{c.reject(new X(U.CANCELLED,o))})}),i.ka.clear()}(n,"'waitForPendingWrites' promise is rejected due to a user change."),n.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await Il(n,r.hs)}}function r2(t,e){const n=de(t),r=n.Na.get(e);if(r&&r.va)return ge().add(r.key);{let s=ge();const i=n.Ma.get(e);if(!i)return s;for(const o of i){const l=n.Fa.get(o);s=s.unionWith(l.view.Va)}return s}}function Sx(t){const e=de(t);return e.remoteStore.remoteSyncer.applyRemoteEvent=xx.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=r2.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=JA.bind(null,e),e.Ca.d_=UA.bind(null,e.eventManager),e.Ca.$a=zA.bind(null,e.eventManager),e}function s2(t){const e=de(t);return e.remoteStore.remoteSyncer.applySuccessfulWrite=ZA.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=e2.bind(null,e),e}class Fu{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=gd(e.databaseInfo.databaseId),this.sharedClientState=this.Wa(e),this.persistence=this.Ga(e),await this.persistence.start(),this.localStore=this.za(e),this.gcScheduler=this.ja(e,this.localStore),this.indexBackfillerScheduler=this.Ha(e,this.localStore)}ja(e,n){return null}Ha(e,n){return null}za(e){return uA(this.persistence,new lA,e.initialUser,this.serializer)}Ga(e){return new iA(sm.Zr,this.serializer)}Wa(e){return new yA}async terminate(){var e,n;(e=this.gcScheduler)===null||e===void 0||e.stop(),(n=this.indexBackfillerScheduler)===null||n===void 0||n.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}Fu.provider={build:()=>new Fu};class Vf{async initialize(e,n){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(n),this.remoteStore=this.createRemoteStore(n),this.eventManager=this.createEventManager(n),this.syncEngine=this.createSyncEngine(n,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>rv(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=n2.bind(null,this.syncEngine),await MA(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new FA}()}createDatastore(e){const n=gd(e.databaseInfo.databaseId),r=function(i){return new xA(i)}(e.databaseInfo);return function(i,o,l,c){return new TA(i,o,l,c)}(e.authCredentials,e.appCheckCredentials,r,n)}createRemoteStore(e){return function(r,s,i,o,l){return new IA(r,s,i,o,l)}(this.localStore,this.datastore,e.asyncQueue,n=>rv(this.syncEngine,n,0),function(){return Jy.D()?new Jy:new vA}())}createSyncEngine(e,n){return function(s,i,o,l,c,h,m){const v=new qA(s,i,o,l,c,h);return m&&(v.Qa=!0),v}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,n)}async terminate(){var e,n;await async function(s){const i=de(s);ee("RemoteStore","RemoteStore shutting down."),i.L_.add(5),await Sl(i),i.k_.shutdown(),i.q_.set("Unknown")}(this.remoteStore),(e=this.datastore)===null||e===void 0||e.terminate(),(n=this.eventManager)===null||n===void 0||n.terminate()}}Vf.provider={build:()=>new Vf};/** * @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 ym{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ya(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ya(this.observer.error,e):hr("Uncaught Error in snapshot listener:",e.toString()))}Za(){this.muted=!0}Ya(e,n){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 i2{constructor(e,n,r,s,i){this.authCredentials=e,this.appCheckCredentials=n,this.asyncQueue=r,this.databaseInfo=s,this.user=kt.UNAUTHENTICATED,this.clientId=Aw.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(r,async o=>{ee("FirestoreClient","Received user=",o.uid),await this.authCredentialListener(o),this.user=o}),this.appCheckCredentials.start(r,o=>(ee("FirestoreClient","Received new app check token=",o),this.appCheckCredentialListener(o,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new ir;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=dm(n,"Failed to shutdown persistence");e.reject(r)}}),e.promise}}async function wh(t,e){t.asyncQueue.verifyOperationInProgress(),ee("FirestoreClient","Initializing OfflineComponentProvider");const n=t.configuration;await e.initialize(n);let r=n.initialUser;t.setCredentialChangeListener(async s=>{r.isEqual(s)||(await lx(e.localStore,s),r=s)}),e.persistence.setDatabaseDeletedListener(()=>t.terminate()),t._offlineComponents=e}async function iv(t,e){t.asyncQueue.verifyOperationInProgress();const n=await o2(t);ee("FirestoreClient","Initializing OnlineComponentProvider"),await e.initialize(n,t.configuration),t.setCredentialChangeListener(r=>Zy(e.remoteStore,r)),t.setAppCheckTokenChangeListener((r,s)=>Zy(e.remoteStore,s)),t._onlineComponents=e}async function o2(t){if(!t._offlineComponents)if(t._uninitializedComponentsProvider){ee("FirestoreClient","Using user provided OfflineComponentProvider");try{await wh(t,t._uninitializedComponentsProvider._offline)}catch(e){const n=e;if(!function(s){return s.name==="FirebaseError"?s.code===U.FAILED_PRECONDITION||s.code===U.UNIMPLEMENTED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11}(n))throw n;yo("Error using user provided cache. Falling back to memory cache: "+n),await wh(t,new Fu)}}else ee("FirestoreClient","Using default OfflineComponentProvider"),await wh(t,new Fu);return t._offlineComponents}async function Ix(t){return t._onlineComponents||(t._uninitializedComponentsProvider?(ee("FirestoreClient","Using user provided OnlineComponentProvider"),await iv(t,t._uninitializedComponentsProvider._online)):(ee("FirestoreClient","Using default OnlineComponentProvider"),await iv(t,new Vf))),t._onlineComponents}function a2(t){return Ix(t).then(e=>e.syncEngine)}async function Uu(t){const e=await Ix(t),n=e.eventManager;return n.onListen=HA.bind(null,e.syncEngine),n.onUnlisten=QA.bind(null,e.syncEngine),n.onFirstRemoteStoreListen=GA.bind(null,e.syncEngine),n.onLastRemoteStoreUnlisten=YA.bind(null,e.syncEngine),n}function l2(t,e,n={}){const r=new ir;return t.asyncQueue.enqueueAndForget(async()=>function(i,o,l,c,h){const m=new ym({next:g=>{m.Za(),o.enqueueAndForget(()=>fm(i,v));const N=g.docs.has(l);!N&&g.fromCache?h.reject(new X(U.UNAVAILABLE,"Failed to get document because the client is offline.")):N&&g.fromCache&&c&&c.source==="server"?h.reject(new X(U.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.)')):h.resolve(g)},error:g=>h.reject(g)}),v=new mm(cd(l.path),m,{includeMetadataChanges:!0,_a:!0});return hm(i,v)}(await Uu(t),t.asyncQueue,e,n,r)),r.promise}function c2(t,e,n={}){const r=new ir;return t.asyncQueue.enqueueAndForget(async()=>function(i,o,l,c,h){const m=new ym({next:g=>{m.Za(),o.enqueueAndForget(()=>fm(i,v)),g.fromCache&&c.source==="server"?h.reject(new X(U.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):h.resolve(g)},error:g=>h.reject(g)}),v=new mm(l,m,{includeMetadataChanges:!0,_a:!0});return hm(i,v)}(await Uu(t),t.asyncQueue,e,n,r)),r.promise}/** * @license * Copyright 2023 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 Cx(t){const e={};return t.timeoutSeconds!==void 0&&(e.timeoutSeconds=t.timeoutSeconds),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 ov=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 bx(t,e,n){if(!n)throw new X(U.INVALID_ARGUMENT,`Function ${t}() cannot be called with an empty ${e}.`)}function u2(t,e,n,r){if(e===!0&&r===!0)throw new X(U.INVALID_ARGUMENT,`${t} and ${n} cannot be used together.`)}function av(t){if(!ne.isDocumentKey(t))throw new X(U.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`)}function lv(t){if(ne.isDocumentKey(t))throw new X(U.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`)}function _d(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(r){return r.constructor?r.constructor.name:null}(t);return e?`a custom ${e} object`:"an object"}}return typeof t=="function"?"a function":oe()}function Dt(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new X(U.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=_d(t);throw new X(U.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 cv{constructor(e){var n,r;if(e.host===void 0){if(e.ssl!==void 0)throw new X(U.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,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=41943040;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<1048576)throw new X(U.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}u2("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=Cx((r=e.experimentalLongPollingOptions)!==null&&r!==void 0?r:{}),function(i){if(i.timeoutSeconds!==void 0){if(isNaN(i.timeoutSeconds))throw new X(U.INVALID_ARGUMENT,`invalid long polling timeout: ${i.timeoutSeconds} (must not be NaN)`);if(i.timeoutSeconds<5)throw new X(U.INVALID_ARGUMENT,`invalid long polling timeout: ${i.timeoutSeconds} (minimum allowed value is 5)`);if(i.timeoutSeconds>30)throw new X(U.INVALID_ARGUMENT,`invalid long polling timeout: ${i.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}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&&function(r,s){return r.timeoutSeconds===s.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class wd{constructor(e,n,r,s){this._authCredentials=e,this._appCheckCredentials=n,this._databaseId=r,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new cv({}),this._settingsFrozen=!1,this._terminateTask="notTerminated"}get app(){if(!this._app)throw new X(U.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!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new X(U.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 cv(e),e.credentials!==void 0&&(this._authCredentials=function(r){if(!r)return new bC;switch(r.type){case"firstParty":return new RC(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new X(U.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==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(n){const r=ov.get(n);r&&(ee("ComponentProvider","Removing Datastore"),ov.delete(n),r.terminate())}(this),Promise.resolve()}}function d2(t,e,n,r={}){var s;const i=(t=Dt(t,wd))._getSettings(),o=`${e}:${n}`;if(i.host!=="firestore.googleapis.com"&&i.host!==o&&yo("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),t._setSettings(Object.assign(Object.assign({},i),{host:o,ssl:!1})),r.mockUserToken){let l,c;if(typeof r.mockUserToken=="string")l=r.mockUserToken,c=kt.MOCK_USER;else{l=B1(r.mockUserToken,(s=t._app)===null||s===void 0?void 0:s.options.projectId);const h=r.mockUserToken.sub||r.mockUserToken.user_id;if(!h)throw new X(U.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");c=new kt(h)}t._authCredentials=new AC(new bw(l,c))}}/** * @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 li{constructor(e,n,r){this.converter=n,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new li(this.firestore,e,this._query)}}class It{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 is(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new It(this.firestore,e,this._key)}}class is extends li{constructor(e,n,r){super(e,n,cd(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 It(this.firestore,null,new ne(e))}withConverter(e){return new is(this.firestore,e,this._path)}}function Et(t,e,...n){if(t=Ge(t),bx("collection","path",e),t instanceof wd){const r=De.fromString(e,...n);return lv(r),new is(t,null,r)}{if(!(t instanceof It||t instanceof is))throw new X(U.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(De.fromString(e,...n));return lv(r),new is(t.firestore,null,r)}}function Re(t,e,...n){if(t=Ge(t),arguments.length===1&&(e=Aw.newId()),bx("doc","path",e),t instanceof wd){const r=De.fromString(e,...n);return av(r),new It(t,null,new ne(r))}{if(!(t instanceof It||t instanceof is))throw new X(U.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(De.fromString(e,...n));return av(r),new It(t.firestore,t instanceof is?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 uv{constructor(e=Promise.resolve()){this.Pu=[],this.Iu=!1,this.Tu=[],this.Eu=null,this.du=!1,this.Au=!1,this.Ru=[],this.t_=new ux(this,"async_queue_retry"),this.Vu=()=>{const r=_h();r&&ee("AsyncQueue","Visibility state changed to "+r.visibilityState),this.t_.jo()},this.mu=e;const n=_h();n&&typeof n.addEventListener=="function"&&n.addEventListener("visibilitychange",this.Vu)}get isShuttingDown(){return this.Iu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.fu(),this.gu(e)}enterRestrictedMode(e){if(!this.Iu){this.Iu=!0,this.Au=e||!1;const n=_h();n&&typeof n.removeEventListener=="function"&&n.removeEventListener("visibilitychange",this.Vu)}}enqueue(e){if(this.fu(),this.Iu)return new Promise(()=>{});const n=new ir;return this.gu(()=>this.Iu&&this.Au?Promise.resolve():(e().then(n.resolve,n.reject),n.promise)).then(()=>n.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Pu.push(e),this.pu()))}async pu(){if(this.Pu.length!==0){try{await this.Pu[0](),this.Pu.shift(),this.t_.reset()}catch(e){if(!xl(e))throw e;ee("AsyncQueue","Operation failed with retryable error: "+e)}this.Pu.length>0&&this.t_.Go(()=>this.pu())}}gu(e){const n=this.mu.then(()=>(this.du=!0,e().catch(r=>{this.Eu=r,this.du=!1;const s=function(o){let l=o.message||"";return o.stack&&(l=o.stack.includes(o.message)?o.stack:o.message+` `+o.stack),l}(r);throw hr("INTERNAL UNHANDLED ERROR: ",s),r}).then(r=>(this.du=!1,r))));return this.mu=n,n}enqueueAfterDelay(e,n,r){this.fu(),this.Ru.indexOf(e)>-1&&(n=0);const s=um.createAndSchedule(this,e,n,r,i=>this.yu(i));return this.Tu.push(s),s}fu(){this.Eu&&oe()}verifyOperationInProgress(){}async wu(){let e;do e=this.mu,await e;while(e!==this.mu)}Su(e){for(const n of this.Tu)if(n.timerId===e)return!0;return!1}bu(e){return this.wu().then(()=>{this.Tu.sort((n,r)=>n.targetTimeMs-r.targetTimeMs);for(const n of this.Tu)if(n.skipDelay(),e!=="all"&&n.timerId===e)break;return this.wu()})}Du(e){this.Ru.push(e)}yu(e){const n=this.Tu.indexOf(e);this.Tu.splice(n,1)}}function dv(t){return function(n,r){if(typeof n!="object"||n===null)return!1;const s=n;for(const i of r)if(i in s&&typeof s[i]=="function")return!0;return!1}(t,["next","error","complete"])}class Wn extends wd{constructor(e,n,r,s){super(e,n,r,s),this.type="firestore",this._queue=new uv,this._persistenceKey=(s==null?void 0:s.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new uv(e),this._firestoreClient=void 0,await e}}}function h2(t,e){const n=typeof t=="object"?t:F_(),r=typeof t=="string"?t:"(default)",s=Op(n,"firestore").getImmediate({identifier:r});if(!s._initialized){const i=U1("firestore");i&&d2(s,...i)}return s}function Cl(t){if(t._terminated)throw new X(U.FAILED_PRECONDITION,"The client has already been terminated.");return t._firestoreClient||f2(t),t._firestoreClient}function f2(t){var e,n,r;const s=t._freezeSettings(),i=function(l,c,h,m){return new qC(l,c,h,m.host,m.ssl,m.experimentalForceLongPolling,m.experimentalAutoDetectLongPolling,Cx(m.experimentalLongPollingOptions),m.useFetchStreams)}(t._databaseId,((e=t._app)===null||e===void 0?void 0:e.options.appId)||"",t._persistenceKey,s);t._componentsProvider||!((n=s.localCache)===null||n===void 0)&&n._offlineComponentProvider&&(!((r=s.localCache)===null||r===void 0)&&r._onlineComponentProvider)&&(t._componentsProvider={_offline:s.localCache._offlineComponentProvider,_online:s.localCache._onlineComponentProvider}),t._firestoreClient=new i2(t._authCredentials,t._appCheckCredentials,t._queue,i,t._componentsProvider&&function(l){const c=l==null?void 0:l._online.build();return{_offline:l==null?void 0:l._offline.build(c),_online:c}}(t._componentsProvider))}/** * @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 ko{constructor(e){this._byteString=e}static fromBase64String(e){try{return new ko(gt.fromBase64String(e))}catch(n){throw new X(U.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+n)}}static fromUint8Array(e){return new ko(gt.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 bl{constructor(...e){for(let n=0;n90)throw new X(U.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(n)||n<-180||n>180)throw new X(U.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 we(this._lat,e._lat)||we(this._long,e._long)}}/** * @license * Copyright 2024 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){this._values=(e||[]).map(n=>n)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(r,s){if(r.length!==s.length)return!1;for(let i=0;ie.isPrefixOf(n))!==void 0||this.fieldTransforms.find(n=>e.isPrefixOf(n.field))!==void 0}vu(){if(this.path)for(let e=0;ec.covers(v.field))}else c=null,h=o.fieldTransforms;return new m2(new Bt(l),c,h)}class xd extends vm{_toFieldTransform(e){if(e.Cu!==2)throw e.Cu===1?e.Bu(`${this._methodName}() can only appear at the top level of your update data`):e.Bu(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof xd}}function Px(t,e,n,r){const s=t.Qu(1,e,n);km("Data must be an object, but it was:",s,r);const i=[],o=Bt.empty();oi(r,(c,h)=>{const m=Tm(e,c,n);h=Ge(h);const v=s.Nu(m);if(h instanceof xd)i.push(m);else{const g=Nl(h,v);g!=null&&(i.push(m),o.set(m,g))}});const l=new Yt(i);return new Ax(o,l,s.fieldTransforms)}function Rx(t,e,n,r,s,i){const o=t.Qu(1,e,n),l=[Ff(e,r,n)],c=[s];if(i.length%2!=0)throw new X(U.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let g=0;g=0;--g)if(!Lx(h,l[g])){const N=l[g];let L=c[g];L=Ge(L);const O=o.Nu(N);if(L instanceof xd)h.push(N);else{const z=Nl(L,O);z!=null&&(h.push(N),m.set(N,z))}}const v=new Yt(h);return new Ax(m,v,o.fieldTransforms)}function y2(t,e,n,r=!1){return Nl(n,t.Qu(r?4:3,e))}function Nl(t,e){if(jx(t=Ge(t)))return km("Unsupported field value:",e,t),Dx(t,e);if(t instanceof vm)return function(r,s){if(!Nx(s.Cu))throw s.Bu(`${r._methodName}() can only be used with update() and set()`);if(!s.path)throw s.Bu(`${r._methodName}() is not currently supported inside arrays`);const i=r._toFieldTransform(s);i&&s.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.xu&&e.Cu!==4)throw e.Bu("Nested arrays are not supported");return function(r,s){const i=[];let o=0;for(const l of r){let c=Nl(l,s.Lu(o));c==null&&(c={nullValue:"NULL_VALUE"}),i.push(c),o++}return{arrayValue:{values:i}}}(t,e)}return function(r,s){if((r=Ge(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return fb(s.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){const i=et.fromDate(r);return{timestampValue:Mu(s.serializer,i)}}if(r instanceof et){const i=new et(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:Mu(s.serializer,i)}}if(r instanceof _m)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof ko)return{bytesValue:tx(s.serializer,r._byteString)};if(r instanceof It){const i=s.databaseId,o=r.firestore._databaseId;if(!o.isEqual(i))throw s.Bu(`Document reference is for database ${o.projectId}/${o.database} but should be for database ${i.projectId}/${i.database}`);return{referenceValue:nm(r.firestore._databaseId||s.databaseId,r._key.path)}}if(r instanceof wm)return function(o,l){return{mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{values:o.toArray().map(c=>{if(typeof c!="number")throw l.Bu("VectorValues must only contain numeric values.");return Zp(l.serializer,c)})}}}}}}(r,s);throw s.Bu(`Unsupported field value: ${_d(r)}`)}(t,e)}function Dx(t,e){const n={};return Nw(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):oi(t,(r,s)=>{const i=Nl(s,e.Mu(r));i!=null&&(n[r]=i)}),{mapValue:{fields:n}}}function jx(t){return!(typeof t!="object"||t===null||t instanceof Array||t instanceof Date||t instanceof et||t instanceof _m||t instanceof ko||t instanceof It||t instanceof vm||t instanceof wm)}function km(t,e,n){if(!jx(n)||!function(s){return typeof s=="object"&&s!==null&&(Object.getPrototypeOf(s)===Object.prototype||Object.getPrototypeOf(s)===null)}(n)){const r=_d(n);throw r==="an object"?e.Bu(t+" a custom object"):e.Bu(t+" "+r)}}function Ff(t,e,n){if((e=Ge(e))instanceof bl)return e._internalPath;if(typeof e=="string")return Tm(t,e);throw zu("Field path arguments must be of type string or ",t,!1,void 0,n)}const v2=new RegExp("[~\\*/\\[\\]]");function Tm(t,e,n){if(e.search(v2)>=0)throw zu(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,n);try{return new bl(...e.split("."))._internalPath}catch{throw zu(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,n)}}function zu(t,e,n,r,s){const i=r&&!r.isEmpty(),o=s!==void 0;let l=`Function ${e}() called with invalid data`;n&&(l+=" (via `toFirestore()`)"),l+=". ";let c="";return(i||o)&&(c+=" (found",i&&(c+=` in field ${r}`),o&&(c+=` in document ${s}`),c+=")"),new X(U.INVALID_ARGUMENT,l+t+c)}function Lx(t,e){return t.some(n=>n.isEqual(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 Ox{constructor(e,n,r,s,i){this._firestore=e,this._userDataWriter=n,this._key=r,this._document=s,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new It(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new _2(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(Sm("DocumentSnapshot.get",e));if(n!==null)return this._userDataWriter.convertValue(n)}}}class _2 extends Ox{data(){return super.data()}}function Sm(t,e){return typeof e=="string"?Tm(t,e):e instanceof bl?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. */function Mx(t){if(t.limitType==="L"&&t.explicitOrderBy.length===0)throw new X(U.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Im{}class w2 extends Im{}function hv(t,e,...n){let r=[];e instanceof Im&&r.push(e),r=r.concat(n),function(i){const o=i.filter(c=>c instanceof Cm).length,l=i.filter(c=>c instanceof Ed).length;if(o>1||o>0&&l>0)throw new X(U.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(r);for(const s of r)t=s._apply(t);return t}class Ed extends w2{constructor(e,n,r){super(),this._field=e,this._op=n,this._value=r,this.type="where"}static _create(e,n,r){return new Ed(e,n,r)}_apply(e){const n=this._parse(e);return Vx(e._query,n),new li(e.firestore,e.converter,Af(e._query,n))}_parse(e){const n=Al(e.firestore);return function(i,o,l,c,h,m,v){let g;if(h.isKeyField()){if(m==="array-contains"||m==="array-contains-any")throw new X(U.INVALID_ARGUMENT,`Invalid Query. You can't perform '${m}' queries on documentId().`);if(m==="in"||m==="not-in"){mv(v,m);const N=[];for(const L of v)N.push(pv(c,i,L));g={arrayValue:{values:N}}}else g=pv(c,i,v)}else m!=="in"&&m!=="not-in"&&m!=="array-contains-any"||mv(v,m),g=y2(l,o,v,m==="in"||m==="not-in");return Xe.create(h,m,g)}(e._query,"where",n,e.firestore._databaseId,this._field,this._op,this._value)}}function fv(t,e,n){const r=e,s=Sm("where",t);return Ed._create(s,r,n)}class Cm extends Im{constructor(e,n){super(),this.type=e,this._queryConstraints=n}static _create(e,n){return new Cm(e,n)}_parse(e){const n=this._queryConstraints.map(r=>r._parse(e)).filter(r=>r.getFilters().length>0);return n.length===1?n[0]:Tn.create(n,this._getOperator())}_apply(e){const n=this._parse(e);return n.getFilters().length===0?e:(function(s,i){let o=s;const l=i.getFlattenedFilters();for(const c of l)Vx(o,c),o=Af(o,c)}(e._query,n),new li(e.firestore,e.converter,Af(e._query,n)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}function pv(t,e,n){if(typeof(n=Ge(n))=="string"){if(n==="")throw new X(U.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Fw(e)&&n.indexOf("/")!==-1)throw new X(U.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=e.path.child(De.fromString(n));if(!ne.isDocumentKey(r))throw new X(U.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return Dy(t,new ne(r))}if(n instanceof It)return Dy(t,n._key);throw new X(U.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${_d(n)}.`)}function mv(t,e){if(!Array.isArray(t)||t.length===0)throw new X(U.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function Vx(t,e){const n=function(s,i){for(const o of s)for(const l of o.getFlattenedFilters())if(i.indexOf(l.op)>=0)return l.op;return null}(t.filters,function(s){switch(s){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(n!==null)throw n===e.op?new X(U.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new X(U.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`)}class x2{convertValue(e,n="none"){switch(ri(e)){case 0:return null;case 1:return e.booleanValue;case 2:return qe(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(ni(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 11:return this.convertObject(e.mapValue,n);case 10:return this.convertVectorValue(e.mapValue);default:throw oe()}}convertObject(e,n){return this.convertObjectMap(e.fields,n)}convertObjectMap(e,n="none"){const r={};return oi(e,(s,i)=>{r[s]=this.convertValue(i,n)}),r}convertVectorValue(e){var n,r,s;const i=(s=(r=(n=e.fields)===null||n===void 0?void 0:n.value.arrayValue)===null||r===void 0?void 0:r.values)===null||s===void 0?void 0:s.map(o=>qe(o.doubleValue));return new wm(i)}convertGeoPoint(e){return new _m(qe(e.latitude),qe(e.longitude))}convertArray(e,n){return(e.values||[]).map(r=>this.convertValue(r,n))}convertServerTimestamp(e,n){switch(n){case"previous":const r=Qp(e);return r==null?null:this.convertValue(r,n);case"estimate":return this.convertTimestamp(sl(e));default:return null}}convertTimestamp(e){const n=cs(e);return new et(n.seconds,n.nanos)}convertDocumentKey(e,n){const r=De.fromString(e);Te(ax(r));const s=new il(r.get(1),r.get(3)),i=new ne(r.popFirst(5));return s.isEqual(n)||hr(`Document ${i} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${n.projectId}/${n.database}) instead.`),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. */function bm(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. */class Ea{constructor(e,n){this.hasPendingWrites=e,this.fromCache=n}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class Fx extends Ox{constructor(e,n,r,s,i,o){super(e,n,r,s,o),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const n=new Jc(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(Sm("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,n.serverTimestamps)}}}class Jc extends Fx{data(e={}){return super.data(e)}}class Ux{constructor(e,n,r,s){this._firestore=e,this._userDataWriter=n,this._snapshot=s,this.metadata=new Ea(s.hasPendingWrites,s.fromCache),this.query=r}get docs(){const e=[];return this.forEach(n=>e.push(n)),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,n){this._snapshot.docs.forEach(r=>{e.call(n,new Jc(this._firestore,this._userDataWriter,r.key,r,new Ea(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){const n=!!e.includeMetadataChanges;if(n&&this._snapshot.excludesMetadataChanges)throw new X(U.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===n||(this._cachedChanges=function(s,i){if(s._snapshot.oldDocs.isEmpty()){let o=0;return s._snapshot.docChanges.map(l=>{const c=new Jc(s._firestore,s._userDataWriter,l.doc.key,l.doc,new Ea(s._snapshot.mutatedKeys.has(l.doc.key),s._snapshot.fromCache),s.query.converter);return l.doc,{type:"added",doc:c,oldIndex:-1,newIndex:o++}})}{let o=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(l=>i||l.type!==3).map(l=>{const c=new Jc(s._firestore,s._userDataWriter,l.doc.key,l.doc,new Ea(s._snapshot.mutatedKeys.has(l.doc.key),s._snapshot.fromCache),s.query.converter);let h=-1,m=-1;return l.type!==0&&(h=o.indexOf(l.doc.key),o=o.delete(l.doc.key)),l.type!==1&&(o=o.add(l.doc),m=o.indexOf(l.doc.key)),{type:E2(l.type),doc:c,oldIndex:h,newIndex:m}})}}(this,n),this._cachedChangesIncludeMetadataChanges=n),this._cachedChanges}}function E2(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return oe()}}/** * @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 gv(t){t=Dt(t,It);const e=Dt(t.firestore,Wn);return l2(Cl(e),t._key).then(n=>zx(e,t,n))}class Am extends x2{constructor(e){super(),this.firestore=e}convertBytes(e){return new ko(e)}convertReference(e){const n=this.convertDocumentKey(e,this.firestore._databaseId);return new It(this.firestore,null,n)}}function Ac(t){t=Dt(t,li);const e=Dt(t.firestore,Wn),n=Cl(e),r=new Am(e);return Mx(t._query),c2(n,t._query).then(s=>new Ux(e,r,t,s))}function Os(t,e,n){t=Dt(t,It);const r=Dt(t.firestore,Wn),s=bm(t.converter,e,n);return Pl(r,[Em(Al(r),"setDoc",t._key,s,t.converter!==null,n).toMutation(t._key,Rt.none())])}function Dn(t,e,n,...r){t=Dt(t,It);const s=Dt(t.firestore,Wn),i=Al(s);let o;return o=typeof(e=Ge(e))=="string"||e instanceof bl?Rx(i,"updateDoc",t._key,e,n,r):Px(i,"updateDoc",t._key,e),Pl(s,[o.toMutation(t._key,Rt.exists(!0))])}function ua(t){return Pl(Dt(t.firestore,Wn),[new pd(t._key,Rt.none())])}function ji(t,e){const n=Dt(t.firestore,Wn),r=Re(t),s=bm(t.converter,e);return Pl(n,[Em(Al(t.firestore),"addDoc",r._key,s,t.converter!==null,{}).toMutation(r._key,Rt.exists(!1))]).then(()=>r)}function Li(t,...e){var n,r,s;t=Ge(t);let i={includeMetadataChanges:!1,source:"default"},o=0;typeof e[o]!="object"||dv(e[o])||(i=e[o],o++);const l={includeMetadataChanges:i.includeMetadataChanges,source:i.source};if(dv(e[o])){const v=e[o];e[o]=(n=v.next)===null||n===void 0?void 0:n.bind(v),e[o+1]=(r=v.error)===null||r===void 0?void 0:r.bind(v),e[o+2]=(s=v.complete)===null||s===void 0?void 0:s.bind(v)}let c,h,m;if(t instanceof It)h=Dt(t.firestore,Wn),m=cd(t._key.path),c={next:v=>{e[o]&&e[o](zx(h,t,v))},error:e[o+1],complete:e[o+2]};else{const v=Dt(t,li);h=Dt(v.firestore,Wn),m=v._query;const g=new Am(h);c={next:N=>{e[o]&&e[o](new Ux(h,g,v,N))},error:e[o+1],complete:e[o+2]},Mx(t._query)}return function(g,N,L,O){const z=new ym(O),I=new mm(N,z,L);return g.asyncQueue.enqueueAndForget(async()=>hm(await Uu(g),I)),()=>{z.Za(),g.asyncQueue.enqueueAndForget(async()=>fm(await Uu(g),I))}}(Cl(h),m,l,c)}function Pl(t,e){return function(r,s){const i=new ir;return r.asyncQueue.enqueueAndForget(async()=>XA(await a2(r),s,i)),i.promise}(Cl(t),e)}function zx(t,e,n){const r=n.docs.get(e._key),s=new Am(t);return new Fx(t,s,e._key,r,new Ea(n.hasPendingWrites,n.fromCache),e.converter)}/** * @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 k2{constructor(e,n){this._firestore=e,this._commitHandler=n,this._mutations=[],this._committed=!1,this._dataReader=Al(e)}set(e,n,r){this._verifyNotCommitted();const s=xh(e,this._firestore),i=bm(s.converter,n,r),o=Em(this._dataReader,"WriteBatch.set",s._key,i,s.converter!==null,r);return this._mutations.push(o.toMutation(s._key,Rt.none())),this}update(e,n,r,...s){this._verifyNotCommitted();const i=xh(e,this._firestore);let o;return o=typeof(n=Ge(n))=="string"||n instanceof bl?Rx(this._dataReader,"WriteBatch.update",i._key,n,r,s):Px(this._dataReader,"WriteBatch.update",i._key,n),this._mutations.push(o.toMutation(i._key,Rt.exists(!0))),this}delete(e){this._verifyNotCommitted();const n=xh(e,this._firestore);return this._mutations=this._mutations.concat(new pd(n._key,Rt.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new X(U.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function xh(t,e){if((t=Ge(t)).firestore!==e)throw new X(U.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");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. */function da(t){return Cl(t=Dt(t,Wn)),new k2(t,e=>Pl(t,e))}(function(e,n=!0){(function(s){Ao=s})(Co),go(new Js("firestore",(r,{instanceIdentifier:s,options:i})=>{const o=r.getProvider("app").getImmediate(),l=new Wn(new NC(r.getProvider("auth-internal")),new jC(r.getProvider("app-check-internal")),function(h,m){if(!Object.prototype.hasOwnProperty.apply(h.options,["projectId"]))throw new X(U.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new il(h.options.projectId,m)}(o,s),o);return i=Object.assign({useFetchStreams:n},i),l._setSettings(i),l},"PUBLIC").setMultipleInstances(!0)),ss(by,"4.7.3",e),ss(by,"4.7.3","esm2017")})();var T2="firebase",S2="10.14.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. */ss(T2,S2,"app");const I2={apiKey:"AIzaSyBBitFgNKnJ_3B0aqJgbbhGL_erufKd9lk",authDomain:"mycloset1-864c4.firebaseapp.com",projectId:"mycloset1-864c4",storageBucket:"mycloset1-864c4.firebasestorage.app",messagingSenderId:"219982610263",appId:"1:219982610263:web:0ebe67d9cf0e7d2753c812"},Bx=V_(I2),ha=IC(Bx),ce=h2(Bx),he="my-closet-app",Ve=({children:t,className:e="",darkMode:n,...r})=>u.jsx("div",{className:`rounded-[2rem] border transition-all duration-300 ${n?"bg-gray-800/40 border-gray-700/50 backdrop-blur-md":"bg-white/80 border-gray-200/50 backdrop-blur-md shadow-sm"} ${e}`,...r,children:t}),Nc=({children:t,variant:e="default"})=>{const n={default:"bg-indigo-100 text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-300",success:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300",danger:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300",warning:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300"};return u.jsx("span",{className:`px-3 py-1 rounded-full text-[10px] font-black uppercase tracking-widest whitespace-nowrap ${n[e]}`,children:t})},Pc=({label:t,type:e="text",value:n,onChange:r,placeholder:s,required:i=!1,name:o,minLength:l,defaultValue:c})=>{const h=n!==void 0;return u.jsxs("div",{className:"flex flex-col gap-1 w-full",children:[t&&u.jsx("label",{className:"text-sm font-black uppercase tracking-widest opacity-40 ml-1",children:t}),u.jsx("input",{type:e,name:o,...h?{value:n}:{defaultValue:c},onChange:m=>r?r(m.target.value):null,placeholder:s,required:i,minLength:l,className:"w-full p-5 rounded-2xl border-none outline-none focus:ring-4 focus:ring-indigo-500/10 font-bold bg-gray-100 dark:bg-gray-700 text-inherit transition-all"})]})},yv={PT:{loginModeIntro:"O Futuro do Teu Estilo",emailPlaceholder:"E-mail",passwordPlaceholder:"Palavra-passe",loginBtn:"ENTRAR",registerBtn:"REGISTAR",createAccount:"Criar Conta",haveAccount:"Já tenho conta",authErrorDisabled:"Este método de login está desativado na base de dados.",forgotPassword:"Esqueceu-se da palavra-passe?",forgotPasswordPrompt:"Introduza o seu e-mail para recuperar a palavra-passe:",passwordResetSent:"E-mail de recuperação enviado! Verifique a sua caixa de entrada.",sendEmailBtn:"Enviar Email",dashboard:"Painel",closet:"Armário",laundry:"Lavandaria",outfits:"Outfits",settings:"Definições",online:"Online",away:"Ausente",offline:"Offline",dailyOutfit:"Outfit Diário",noOutfitPlanned:"Nenhum Outfit Planeado",goToPlanning:"Vá ao planeamento para adicionar",onlyFavorites:"Apenas Favoritos",logout:"Sair",overview:"Visão Geral",myCloset:"O Meu Armário",outfitsAndStyle:"Outfits",readyClothes:"Roupas Prontas",inLaundry:"Na Lavandaria",myLooks:"Meus Outfits",favorites:"Favoritos",todayIn:"Hoje em Portugal",weatherUpdate:"22°C - Ensolarado",weatherCurrentAvg:"{current}°C Atual • Média {avg}°C",weatherForecastDesc:"O dia de hoje tem máximas de {max}°C e mínimas de {min}°C.",weatherMsg:"Está um dia fantástico! Recomendamos as tuas peças leves. Que tal um visual casual com as tuas sapatilhas favoritas?",exploreSuggestions:"Explorar Sugestões",topColors:"Top Cores",searchPlaceholder:"Procurar no meu guarda-roupa...",all:"Todos",tops:"Tops",bottoms:"Bottoms",footwear:"Calçado",coats:"Casacos",accessories:"Acessórios",edit:"Editar",makeDirty:"Lavar",moveToTrash:"Mover para Lixo",laundryBasket:"Cesto da Roupa",lookSentToLaundry:"Peças enviadas para a lavandaria!",laundryMsg:"Aqui encontras as peças que marcaste como sujas. Lava-as para que voltem ao armário principal.",washing:"A lavar",emptyBasket:"Cesto Vazio",createNewLook:"Criar Novo Outfit",lookName:"Nome do Outfit",selectedPieces:"Peças Selecionadas",selectPieces:"Seleciona peças...",saveLook:"Guardar Outfit",closetLabel:"Armário",lookHistory:"Histórico de Outfits",pieces:"Peças",newItem:"Novo Item",preview:"Preview",name:"Nome",category:"Categoria",color:"Cor",imageUrl:"URL da Imagem",cancel:"Cancelar",save:"Guardar",register:"Registar",yourAccount:"A Tua Conta",papMode:"Modo PAP",preferences:"Preferências",darkMode:"Modo Escuro",interfaceAppearance:"Aparência da interface",notifications:"Notificações",lookReminders:"Lembretes de outfits",weatherAlerts:"Alertas de Clima",weatherSuggestions:"Sugestões pelo tempo",systemAndData:"Sistema e Dados",appLanguage:"Idioma da Aplicação",portuguese:"Português (PT)",english:"English (EN)",spanish:"Español (ES)",french:"Français (FR)",german:"Deutsch (DE)",exportData:"Exportar Dados (JSON)",exportDataAlert:"Os teus dados seriam exportados agora em formato JSON.",privacyPolicy:"Política de Privacidade",recycleBin:"Reciclagem",empty:"Esvaziar",deleted:"Eliminado",criticalZone:"Zona Crítica",fullCleanActions:"Ações de limpeza total do armário.",clearAll:"Limpar Tudo",confirmDeletePerm:"Apagar permanentemente?",confirmDeleteLook:"Apagar este Outfit?",confirmEmptyTrash:"Esvaziar o lixo permanentemente?",confirmClearAll:"Mover todas as peças ativas para o lixo?",colorBlack:"Preto",colorWhite:"Branco",colorBlue:"Azul",colorRed:"Vermelho",colorGreen:"Verde",colorYellow:"Amarelo",colorPink:"Rosa",colorPurple:"Roxo",colorOrange:"Laranja",colorBrown:"Marrom",colorBeige:"Bege",colorGray:"Cinza",userTitle:"Utilizador",themeColor:"Cor do Tema",personalizeColor:"Personalizar a cor",advancedFilters:"Filtros",filterByColor:"Cor",filterByAge:"Idade da Peça",anyAge:"Qualquer Idade",lessThanMonth:"Menos de 1 Mês",lessThan6Months:"Menos de 6 Meses",lessThanYear:"Menos de 1 Ano",older:"Mais antigo",applyFilters:"Aplicar Filtros",profileInfo:"Informações da Conta",username:"Nome de Utilizador",fullName:"Nome Completo",dob:"Data de Nascimento",bio:"Bio / Sobre mim",optional:"(Opcional)",saving:"A guardar...",sections:"Secções",manageSections:"Gerir Secções",newSection:"Nova Secção",sectionName:"Nome da Secção",sectionEmoji:"Emoji",noSections:"Nenhuma secção criada ainda.",addSection:"Adicionar Secção",deleteSection:"Apagar",assignSections:"Atribuir a Secções",allSections:"Todas",confirmDeleteSection:"Apagar esta secção?",sectionPlaceholder:"Ex: Trabalho, Festa...",emojiPlaceholder:"Ex: 💼",createSection:"Criar Secção",noSectionsCreated:"Ainda não tem secções criadas",linkCopied:"Link copiado!",share:"Partilhar",piecesInLaundry:"peça(s) na lavandaria",toBeWashed:"A ser lavados",unavailable:"Indisponíveis",availableLooks:"Disponíveis",noLooksAvailable:"Nenhum outfit disponível",location:"Localidade",locationEx:"Ex: Lisboa, Portugal",ideaSuggestion:"Ideia / Sugestão",bugError:"Bug / Erro",writeMessage:"Escreva aqui a sua mensagem...",sendMessage:"Enviar Mensagem",notificationsModal:"Notificações",noNotifications:"Sem Notificações",markAllRead:"Marcar todas como lidas",lookCopiedBy:"copiou o seu outfit",userSavedLook:"guardou o seu outfit",inTheirCloset:"no armário dele!",sharedLookTitle:"Outfit Partilhado",sharedBy:"Partilhado por",includedPieces:"Peças incluídas",ignore:"Ignorar",copying:"A copiar...",copyToMyCloset:"Copiar para o meu armário",msgSentSuccess:"Mensagem enviada com sucesso!",msgSendError:"Erro ao enviar mensagem. Verifica a tua ligação.",wishlist:"Carrinho",addFuturePurchase:"Adicionar peça como compra futura",wishlistDesc:"Carrinho",someone:"alguém",feedbackTitle:"Suporte e Feedback",feedbackDesc:"Tem alguma ideia, sugestão ou encontrou algum problema? Envie uma mensagem diretamente para nós!",themeColorTitle:"Cor do Tema",personalizeColorDesc:"Personalize a cor",saveChanges:"Guardar Alterações",pasteLink:"Colar Link",pasteSharedLookLink:"Cole o link do outfit partilhado:",invalidSharedLink:"Link inválido. Certifique-se de copiar o link completo.",planning:"Planeamento",today:"Hoje",monthLabel:"Mês",weekLabel:"Semana",chooseOutfit:"Escolher Outfit",removeOutfitDay:"Remover Outfit deste Dia",noOutfitCreated:"Nenhum outfit criado",piecesShort:"peças",editLook:"Editar Outfit",uploadGallery:"Upload da Galeria / Ficheiros",selectOneColor:"Selecione pelo menos uma cor",addColorsToItems:"Adicione cores aos seus itens.",or:"OU",cardSize:"Tamanho dos itens",cardSizeDesc:"Tamanho no armário/carrinho",small:"Pequeno",medium:"Médio",large:"Grande",defaultPage:"Página Inicial",defaultPageDesc:"Página que aparece após o login",community:"Comunidade",searchUsers:"Procurar por @username...",privateProfile:"Perfil Privado",privateProfileDesc:"Ocultar armário de outros utilizadores",viewProfile:"Ver Perfil",noUsersFound:"Nenhum utilizador encontrado",isPrivateUser:"Este perfil é privado.",userOutfits:"Outfits do Utilizador",userCloset:"Armário",usernameTaken:"Este nome de utilizador já está em uso."},EN:{loginModeIntro:"The Future of Your Style",emailPlaceholder:"Email",passwordPlaceholder:"Password",loginBtn:"LOGIN",registerBtn:"REGISTER",createAccount:"Create Account",haveAccount:"I already have an account",authErrorDisabled:"This login method is disabled in the database.",forgotPassword:"Forgot password?",forgotPasswordPrompt:"Enter your email to reset your password:",passwordResetSent:"Password reset email sent! Check your inbox.",sendEmailBtn:"Send Email",dashboard:"Dashboard",closet:"Closet",laundry:"Laundry",outfits:"Outfits",settings:"Settings",online:"Online",away:"Away",offline:"Offline",dailyOutfit:"Daily Outfit",noOutfitPlanned:"No Outfit Planned",goToPlanning:"Go to planning to add one",onlyFavorites:"Favorites Only",logout:"Logout",overview:"Overview",myCloset:"My Closet",outfitsAndStyle:"Outfits & Style",readyClothes:"Ready Clothes",inLaundry:"In Laundry",myLooks:"My Outfits",favorites:"Favorites",todayIn:"Today in Portugal",weatherUpdate:"22°C - Sunny",weatherCurrentAvg:"{current}°C Current • Average {avg}°C",weatherForecastDesc:"Today has highs of {max}°C and lows of {min}°C.",weatherMsg:"It's a fantastic day! We recommend your light pieces. How about a casual look with your favorite sneakers?",exploreSuggestions:"Explore Suggestions",topColors:"Top Colors",searchPlaceholder:"Search my wardrobe...",all:"All",tops:"Tops",bottoms:"Bottoms",footwear:"Footwear",coats:"Coats",accessories:"Accessories",edit:"Edit",makeDirty:"Make Dirty",moveToTrash:"Move to Trash",laundryBasket:"Laundry Basket",lookSentToLaundry:"Pieces sent to the laundry!",laundryMsg:"Here you find the pieces you marked as dirty. Wash them to return them to the main closet.",washing:"Washing",emptyBasket:"Empty Basket",createNewLook:"Create New Outfit",lookName:"Outfit Name",selectedPieces:"Selected Pieces",selectPieces:"Select pieces...",saveLook:"Save Outfit",closetLabel:"Closet",lookHistory:"Outfit History",pieces:"Pieces",newItem:"New Item",preview:"Preview",name:"Name",category:"Category",color:"Color",imageUrl:"Image URL",cancel:"Cancel",save:"Save",register:"Register",yourAccount:"Your Account",papMode:"PAP Mode",preferences:"Preferences",darkMode:"Dark Mode",interfaceAppearance:"Interface Appearance",notifications:"Notifications",lookReminders:"Outfit reminders",weatherAlerts:"Weather Alerts",weatherSuggestions:"Weather-based suggestions",systemAndData:"System and Data",appLanguage:"App Language",portuguese:"Português (PT)",english:"English (EN)",spanish:"Español (ES)",french:"Français (FR)",german:"Deutsch (DE)",exportData:"Export Data (JSON)",exportDataAlert:"Your data would be exported now in JSON format.",privacyPolicy:"Privacy Policy",recycleBin:"Recycle Bin",empty:"Empty",deleted:"Deleted",criticalZone:"Critical Zone",fullCleanActions:"Full closet wipe actions.",clearAll:"Clear All",confirmDeletePerm:"Delete permanently?",confirmDeleteLook:"Delete this Outfit?",confirmEmptyTrash:"Empty trash permanently?",confirmClearAll:"Move all active pieces to trash?",colorBlack:"Black",colorWhite:"White",colorBlue:"Blue",colorRed:"Red",colorGreen:"Green",colorYellow:"Yellow",colorPink:"Pink",colorPurple:"Purple",colorOrange:"Orange",colorBrown:"Brown",colorBeige:"Beige",colorGray:"Gray",userTitle:"User",themeColor:"Theme Color",personalizeColor:"Personalize the color",advancedFilters:"Filters",filterByColor:"Color",filterByAge:"Item Age",anyAge:"Any Age",lessThanMonth:"Less than 1 Month",lessThan6Months:"Less than 6 Months",lessThanYear:"Less than 1 Year",older:"Older",applyFilters:"Apply Filters",profileInfo:"Account Information",username:"Username",fullName:"Full Name",dob:"Date of Birth",bio:"Bio / About me",optional:"(Optional)",saving:"Saving...",sections:"Sections",manageSections:"Manage Sections",newSection:"New Section",sectionName:"Section Name",sectionEmoji:"Emoji",noSections:"No sections created yet.",addSection:"Add Section",deleteSection:"Delete",assignSections:"Assign to Sections",allSections:"All",confirmDeleteSection:"Delete this section?",sectionPlaceholder:"E.g.: Work, Party...",emojiPlaceholder:"E.g.: 💼",createSection:"Create Section",noSectionsCreated:"No sections created yet",linkCopied:"Link copied!",share:"Share",piecesInLaundry:"piece(s) in laundry",toBeWashed:"To be washed",unavailable:"Unavailable",availableLooks:"Available",noLooksAvailable:"No outfit available",location:"Location",locationEx:"E.g.: Lisbon, Portugal",ideaSuggestion:"Idea / Suggestion",bugError:"Bug / Error",writeMessage:"Write your message here...",sendMessage:"Send Message",notificationsModal:"Notifications",noNotifications:"No Notifications",markAllRead:"Mark all as read",lookCopiedBy:"copied your outfit",userSavedLook:"saved your outfit",inTheirCloset:"in their closet!",sharedLookTitle:"Shared Outfit",sharedBy:"Shared by",includedPieces:"Included Pieces",ignore:"Ignore",copying:"Copying...",copyToMyCloset:"Copy to my closet",msgSentSuccess:"Message sent successfully!",msgSendError:"Error sending message. Check your connection.",addFuturePurchase:"Add piece as future purchase",wishlist:"Wishlist",wishlistDesc:"Wishlist",someone:"someone",feedbackTitle:"Support and Feedback",feedbackDesc:"Do you have any ideas, suggestions, or found a problem? Send a message directly to us!",themeColorTitle:"Theme Color",personalizeColorDesc:"Personalize the color",saveChanges:"Save Changes",pasteLink:"Paste Link",pasteSharedLookLink:"Paste the shared outfit link:",invalidSharedLink:"Invalid link. Make sure you copied the full link.",planning:"Planning",today:"Today",monthLabel:"Month",weekLabel:"Week",chooseOutfit:"Choose Outfit",removeOutfitDay:"Remove Outfit from this Day",noOutfitCreated:"No outfit created",piecesShort:"pieces",editLook:"Edit Outfit",uploadGallery:"Upload from Gallery / Files",selectOneColor:"Select at least one color",addColorsToItems:"Add colors to your items.",or:"OR",cardSize:"Item Size",cardSizeDesc:"Size in closet/cart",small:"Small",medium:"Medium",large:"Large",defaultPage:"Home Page",defaultPageDesc:"Page that appears after login",community:"Community",searchUsers:"Search by @username...",privateProfile:"Private Profile",privateProfileDesc:"Hide closet from other users",viewProfile:"View Profile",noUsersFound:"No users found",isPrivateUser:"This profile is private.",userOutfits:"User's Outfits",userCloset:"Closet",usernameTaken:"This username is already taken."},ES:{loginModeIntro:"El Futuro de Tu Estilo",emailPlaceholder:"Correo electrónico",passwordPlaceholder:"Contraseña",loginBtn:"ENTRAR",registerBtn:"REGISTRAR",createAccount:"Crear Cuenta",haveAccount:"Ya tengo cuenta",authErrorDisabled:"Este método de inicio de sesión está desactivado en la base de datos.",forgotPassword:"¿Olvidaste tu contraseña?",forgotPasswordPrompt:"Introduce tu correo electrónico para recuperar la contraseña:",passwordResetSent:"¡Correo de recuperación enviado! Revisa tu bandeja de entrada.",sendEmailBtn:"Enviar Correo",dashboard:"Panel",closet:"Armario",laundry:"Lavandería",outfits:"Outfits",settings:"Ajustes",online:"En línea",away:"Ausente",offline:"Desconectado",dailyOutfit:"Outfit Diario",noOutfitPlanned:"Sin Outfit Planeado",goToPlanning:"Ve a planificación para añadir",onlyFavorites:"Solo Favoritos",logout:"Cerrar Sesión",overview:"Visión General",myCloset:"Mi Armario",outfitsAndStyle:"Outfits y Estilo",readyClothes:"Ropa Lista",inLaundry:"En la Lavandería",myLooks:"Mis Outfits",favorites:"Favoritos",todayIn:"Hoy en Portugal",weatherUpdate:"22°C - Soleado",weatherCurrentAvg:"{current}°C Actual • Media {avg}°C",weatherForecastDesc:"El día de hoy tiene máximas de {max}°C y mínimas de {min}°C.",weatherMsg:"¡Es un día fantástico! Recomendamos tus piezas ligeras. ¿Qué tal un look casual con tus zapatillas favoritas?",exploreSuggestions:"Explorar Sugerencias",topColors:"Colores Principales",searchPlaceholder:"Buscar en mi guardarropa...",all:"Todos",tops:"Tops",bottoms:"Partes Inferiores",footwear:"Calzado",coats:"Abrigos",accessories:"Accesorios",edit:"Editar",makeDirty:"Ensuciar",moveToTrash:"Mover a la Papelera",laundryBasket:"Cesto de Ropa",lookSentToLaundry:"¡Piezas enviadas a la lavandería!",laundryMsg:"Aquí encuentras las piezas que marcaste como sucias. Lávalas para que vuelvan al armario principal.",washing:"Lavando",emptyBasket:"Cesto Vacío",createNewLook:"Crear Nuevo Outfit",lookName:"Nombre del Outfit",selectedPieces:"Piezas Seleccionadas",selectPieces:"Elige piezas...",saveLook:"Guardar Outfit",closetLabel:"Armario",lookHistory:"Historial de Outfits",pieces:"Piezas",newItem:"Nuevo Artículo",preview:"Vista Previa",name:"Nombre",category:"Categoría",color:"Color",imageUrl:"URL de la Imagen",cancel:"Cancelar",save:"Guardar",register:"Registrar",yourAccount:"Tu Cuenta",papMode:"Modo PAP",preferences:"Preferencias",darkMode:"Modo Oscuro",interfaceAppearance:"Apariencia de la interfaz",notifications:"Notificaciones",lookReminders:"Recordatorios de looks",weatherAlerts:"Alertas del Clima",weatherSuggestions:"Sugerencias por clima",systemAndData:"Sistema y Datos",appLanguage:"Idioma de la Aplicación",portuguese:"Português (PT)",english:"English (EN)",spanish:"Español (ES)",french:"Français (FR)",german:"Deutsch (DE)",exportData:"Exportar Datos (JSON)",exportDataAlert:"Tus datos se exportarían ahora en formato JSON.",privacyPolicy:"Política de Privacidad",recycleBin:"Papelera de Reciclaje",empty:"Vaciar",deleted:"Eliminado",criticalZone:"Zona Crítica",fullCleanActions:"Acciones de limpieza total.",clearAll:"Limpiar Todo",confirmDeletePerm:"¿Borrar permanentemente?",confirmDeleteLook:"¿Borrar este Outfit?",confirmEmptyTrash:"¿Vaciar la papelera permanentemente?",confirmClearAll:"¿Mover todas las piezas activas a la papelera?",colorBlack:"Negro",colorWhite:"Blanco",colorBlue:"Azul",colorRed:"Rojo",colorGreen:"Verde",colorYellow:"Amarillo",colorPink:"Rosa",colorPurple:"Morado",colorOrange:"Naranja",colorBrown:"Marrón",colorBeige:"Beige",colorGray:"Gris",userTitle:"Usuario",themeColor:"Color del Tema",personalizeColor:"Personaliza el color",advancedFilters:"Filtros",filterByColor:"Color",filterByAge:"Edad de la Prenda",anyAge:"Cualquier Edad",lessThanMonth:"Menos de 1 Mes",lessThan6Months:"Menos de 6 Meses",lessThanYear:"Menos de 1 Año",older:"Más Antiguo",applyFilters:"Aplicar Filtros",profileInfo:"Información de la Cuenta",username:"Nombre de Usuario",fullName:"Nombre Completo",dob:"Fecha de Nacimiento",bio:"Bio / Sobre mí",optional:"(Opcional)",saving:"Guardando...",sections:"Secciones",manageSections:"Gestionar Secciones",newSection:"Nueva Sección",sectionName:"Nombre de la Sección",sectionEmoji:"Emoji",noSections:"Aún no hay secciones creadas.",addSection:"Añadir Sección",deleteSection:"Eliminar",assignSections:"Asignar a Secciones",allSections:"Todas",confirmDeleteSection:"¿Eliminar esta sección?",sectionPlaceholder:"Ej: Trabajo, Fiesta...",emojiPlaceholder:"Ej: 💼",createSection:"Crear Sección",noSectionsCreated:"Aún no hay secciones creadas",linkCopied:"¡Enlace copiado!",share:"Compartir",piecesInLaundry:"pieza(s) en la lavandería",toBeWashed:"Por lavar",unavailable:"No disponibles",availableLooks:"Disponibles",noLooksAvailable:"Ningún outfit disponible",location:"Ubicación",locationEx:"Ej: Lisboa, Portugal",ideaSuggestion:"Idea / Sugerencia",bugError:"Error / Fallo",writeMessage:"Escribe aquí tu mensaje...",sendMessage:"Enviar Mensaje",notificationsModal:"Notificaciones",noNotifications:"Sin Notificaciones",markAllRead:"Marcar todas como leídas",lookCopiedBy:"copió tu outfit",userSavedLook:"guardó tu outfit",inTheirCloset:"en su armario!",sharedLookTitle:"Outfit Compartido",sharedBy:"Compartido por",includedPieces:"Piezas incluidas",ignore:"Ignorar",copying:"Copiando...",copyToMyCloset:"Copiar a mi armario",msgSentSuccess:"¡Mensaje enviado con éxito!",msgSendError:"Error al enviar. Revisa tu conexión.",addFuturePurchase:"Añadir pieza como compra futura",wishlist:"Lista de Deseos",wishlistDesc:"Lista de Deseos",someone:"alguien",feedbackTitle:"Soporte y Comentarios",feedbackDesc:"¿Tienes alguna idea, sugerencia o encontraste un problema? ¡Envíanos un mensaje directamente!",themeColorTitle:"Color del Tema",personalizeColorDesc:"Personaliza el color",saveChanges:"Guardar Cambios",pasteLink:"Pegar Enlace",pasteSharedLookLink:"Pega el enlace del outfit compartido:",invalidSharedLink:"Enlace no válido. Asegúrate de copiar el enlace completo.",planning:"Planificación",today:"Hoy",monthLabel:"Mes",weekLabel:"Semana",chooseOutfit:"Elegir Outfit",removeOutfitDay:"Quitar Outfit de este Día",noOutfitCreated:"Ningún outfit creado",piecesShort:"piezas",editLook:"Editar Outfit",uploadGallery:"Subir desde la Galería / Archivos",selectOneColor:"Selecciona al menos un color",addColorsToItems:"Añade colores a tus artículos.",or:"O",cardSize:"Tamaño de los ítems",cardSizeDesc:"Tamaño en armario/carrito",small:"Pequeño",medium:"Medio",large:"Grande",defaultPage:"Página de Inicio",defaultPageDesc:"Página que aparece después de iniciar sesión",community:"Comunidad",searchUsers:"Buscar por @username...",privateProfile:"Perfil Privado",privateProfileDesc:"Ocultar armario de otros usuarios",viewProfile:"Ver Perfil",noUsersFound:"Ningún usuario encontrado",isPrivateUser:"Este perfil es privado.",userOutfits:"Outfits del Usuario",userCloset:"Armario",usernameTaken:"Este nombre de usuario ya está en uso."},FR:{loginModeIntro:"Le Futur de Ton Style",emailPlaceholder:"E-mail",passwordPlaceholder:"Mot de passe",loginBtn:"CONNEXION",registerBtn:"S'INSCRIRE",createAccount:"Créer un Compte",haveAccount:"J'ai déjà un compte",authErrorDisabled:"Cette méthode de connexion est désactivée dans la base de données.",forgotPassword:"Mot de passe oublié ?",forgotPasswordPrompt:"Entrez votre e-mail pour réinitialiser votre mot de passe :",passwordResetSent:"E-mail de réinitialisation envoyé ! Vérifiez votre boîte de réception.",sendEmailBtn:"Envoyer l'E-mail",dashboard:"Tableau de bord",closet:"Placard",laundry:"Blanchisserie",outfits:"Tenues",settings:"Paramètres",online:"En ligne",away:"Absent",offline:"Hors ligne",dailyOutfit:"Tenue du Jour",noOutfitPlanned:"Aucune Tenue Prévue",goToPlanning:"Allez dans planification pour ajouter",onlyFavorites:"Favoris Uniquement",logout:"Déconnexion",overview:"Vue d'ensemble",myCloset:"Mon Placard",outfitsAndStyle:"Tenues & Style",readyClothes:"Vêtements Prêts",inLaundry:"À la Blanchisserie",myLooks:"Mes Outfits",favorites:"Favoris",todayIn:"Aujourd'hui au Portugal",weatherUpdate:"22°C - Ensoleillé",weatherCurrentAvg:"{current}°C Actuel • Moyenne {avg}°C",weatherForecastDesc:"Aujourd'hui a des maximales de {max}°C et des minimales de {min}°C.",weatherMsg:"C'est une journée fantastique ! Nous recommandons vos pièces légères. Que diriez-vous d'un look décontracté avec vos baskets préférées ?",exploreSuggestions:"Explorer les Suggestions",topColors:"Couleurs Principales",searchPlaceholder:"Chercher dans ma garde-robe...",all:"Tout",tops:"Hauts",bottoms:"Bas",footwear:"Chaussures",coats:"Manteaux",accessories:"Accessoires",edit:"Modifier",makeDirty:"Salir",moveToTrash:"Mettre à la corbeille",laundryBasket:"Panier à linge",lookSentToLaundry:"Pièces envoyées à la blanchisserie !",laundryMsg:"Ici vous trouvez les pièces que vous avez marquées comme sales. Lavez-les pour les remettre dans le placard principal.",washing:"En lavage",emptyBasket:"Panier Vide",createNewLook:"Créer un Nouvel Outfit",lookName:"Nom de l'Outfit",selectedPieces:"Pièces Sélectionnées",selectPieces:"Sélectionnez des pièces...",saveLook:"Enregistrer l'Outfit",closetLabel:"Placard",lookHistory:"Historique des Outfits",pieces:"Pièces",newItem:"Nouvel Article",preview:"Aperçu",name:"Nom",category:"Catégorie",color:"Couleur",imageUrl:"URL de l'image",cancel:"Annuler",save:"Enregistrer",register:"S'inscrire",yourAccount:"Votre Compte",papMode:"Mode PAP",preferences:"Préférences",darkMode:"Mode Sombre",interfaceAppearance:"Apparence de l'interface",notifications:"Notifications",lookReminders:"Rappels d'outfits",weatherAlerts:"Alertes Météo",weatherSuggestions:"Suggestions selon la météo",systemAndData:"Système et Données",appLanguage:"Langue de l'application",portuguese:"Português (PT)",english:"English (EN)",spanish:"Español (ES)",french:"Français (FR)",german:"Deutsch (DE)",exportData:"Exporter les Données (JSON)",exportDataAlert:"Vos données seraient exportées maintenant au format JSON.",privacyPolicy:"Politique de Confidentialité",recycleBin:"Corbeille",empty:"Vider",deleted:"Supprimé",criticalZone:"Zone Critique",fullCleanActions:"Actions de nettoyage total.",clearAll:"Tout Effacer",confirmDeletePerm:"Supprimer définitivement ?",confirmDeleteLook:"Supprimer cet Outfit ?",confirmEmptyTrash:"Vider la corbeille définitivement ?",confirmClearAll:"Déplacer toutes les pièces actives vers la corbeille ?",colorBlack:"Noir",colorWhite:"Blanc",colorBlue:"Bleu",colorRed:"Rouge",colorGreen:"Vert",colorYellow:"Jaune",colorPink:"Rose",colorPurple:"Violet",colorOrange:"Orange",colorBrown:"Marron",colorBeige:"Beige",colorGray:"Gris",userTitle:"Utilisateur",themeColor:"Couleur du Thème",personalizeColor:"Personnaliser la couleur",advancedFilters:"Filtres",filterByColor:"Couleur",filterByAge:"Âge de l'article",anyAge:"Tout âge",lessThanMonth:"Moins d'un mois",lessThan6Months:"Moins de 6 mois",lessThanYear:"Moins d'un an",older:"Plus ancien",applyFilters:"Appliquer les filtres",profileInfo:"Informations du Compte",username:"Nom d'utilisateur",fullName:"Nom Complet",dob:"Date de Naissance",bio:"Bio / À propos",optional:"(Optionnel)",saving:"Enregistrement...",sections:"Sections",manageSections:"Gérer les Sections",newSection:"Nouvelle Section",sectionName:"Nom de la Section",sectionEmoji:"Emoji",noSections:"Aucune section créée pour l'instant.",addSection:"Ajouter une Section",deleteSection:"Supprimer",assignSections:"Attribuer aux Sections",allSections:"Toutes",confirmDeleteSection:"Supprimer cette section ?",sectionPlaceholder:"Ex: Travail, Fête...",emojiPlaceholder:"Ex: 💼",createSection:"Créer une Section",noSectionsCreated:"Aucune section créée",linkCopied:"Lien copié !",share:"Partager",piecesInLaundry:"pièce(s) à la blanchisserie",toBeWashed:"À laver",unavailable:"Indisponibles",availableLooks:"Disponibles",noLooksAvailable:"Aucun outfit disponible",location:"Emplacement",locationEx:"Ex: Lisbonne, Portugal",ideaSuggestion:"Idée / Suggestion",bugError:"Bug / Erreur",writeMessage:"Écrivez votre message ici...",sendMessage:"Envoyer le Message",notificationsModal:"Notifications",noNotifications:"Aucune Notification",markAllRead:"Tout marquer comme lu",lookCopiedBy:"a copié votre outfit",userSavedLook:"a sauvegardé votre outfit",inTheirCloset:"dans son placard !",sharedLookTitle:"Outfit Partagé",sharedBy:"Partagé par",includedPieces:"Pièces incluses",ignore:"Ignorer",copying:"Copie en cours...",copyToMyCloset:"Copier dans mon placard",msgSentSuccess:"Message envoyé avec succès !",msgSendError:"Erreur d'envoi. Vérifiez votre connexion.",addFuturePurchase:"Ajouter comme achat futur",wishlist:"Liste de Souhaits",wishlistDesc:"Liste de Souhaits",someone:"quelqu'un",feedbackTitle:"Support et Commentaires",feedbackDesc:"Avez-vous des idées, des suggestions ou trouvé un problème ? Envoyez-nous un message directement !",themeColorTitle:"Couleur du Thème",personalizeColorDesc:"Personnaliser la couleur",saveChanges:"Enregistrer les Modifications",pasteLink:"Coller le Lien",pasteSharedLookLink:"Collez le lien de l'outfit partagé :",invalidSharedLink:"Lien invalide. Assurez-vous d'avoir copié le lien complet.",planning:"Planification",today:"Aujourd'hui",monthLabel:"Mois",weekLabel:"Semaine",chooseOutfit:"Choisir un Outfit",removeOutfitDay:"Retirer l'Outfit de ce Jour",noOutfitCreated:"Aucun outfit créé",piecesShort:"pièces",editLook:"Modifier l'Outfit",uploadGallery:"Télécharger depuis la Galerie / Fichiers",selectOneColor:"Sélectionnez au moins une couleur",addColorsToItems:"Ajoutez des couleurs à vos articles.",or:"OU",cardSize:"Taille des articles",cardSizeDesc:"Taille dans placard/panier",small:"Petit",medium:"Moyen",large:"Grand",defaultPage:"Page d'Accueil",defaultPageDesc:"Page qui apparaît après la connexion",community:"Communauté",searchUsers:"Rechercher par @username...",privateProfile:"Profil Privé",privateProfileDesc:"Cacher le placard aux autres utilisateurs",viewProfile:"Voir le Profil",noUsersFound:"Aucun utilisateur trouvé",isPrivateUser:"Ce profil est privé.",userOutfits:"Outfits de l'Utilisateur",userCloset:"Placard",usernameTaken:"Ce nom d'utilisateur est déjà utilisé."},DE:{loginModeIntro:"Die Zukunft deines Stils",emailPlaceholder:"E-Mail",passwordPlaceholder:"Passwort",loginBtn:"ANMELDEN",registerBtn:"REGISTRIEREN",createAccount:"Konto Erstellen",haveAccount:"Ich habe bereits ein Konto",authErrorDisabled:"Diese Anmeldemethode ist in der Datenbank deaktiviert.",forgotPassword:"Passwort vergessen?",forgotPasswordPrompt:"Gib deine E-Mail-Adresse ein, um dein Passwort zurückzusetzen:",passwordResetSent:"E-mail zum Zurücksetzen des Passworts gesendet! Überprüfe deinen Posteingang.",sendEmailBtn:"E-Mail Senden",dashboard:"Startseite",closet:"Schrank",laundry:"Wäsche",outfits:"Outfits",settings:"Einstellungen",online:"Online",away:"Abwesend",offline:"Offline",dailyOutfit:"Tägliches Outfit",noOutfitPlanned:"Kein Outfit Geplant",goToPlanning:"Gehen Sie zur Planung, um eins hinzuzufügen",onlyFavorites:"Nur Favoriten",logout:"Abmelden",overview:"Übersicht",myCloset:"Mein Schrank",outfitsAndStyle:"Outfits & Stil",readyClothes:"Fertige Kleidung",inLaundry:"In der Wäsche",myLooks:"Meine Outfits",favorites:"Favoriten",todayIn:"Heute in Portugal",weatherUpdate:"22°C - Sonnig",weatherCurrentAvg:"{current}°C Aktuell • Durchschnitt {avg}°C",weatherForecastDesc:"Der heutige Tag hat Höchstwerte von {max}°C und Tiefstwerte von {min}°C.",weatherMsg:"Es ist ein fantastischer Tag! Wir empfehlen leichte Stücke. Wie wäre es mit einem lässigen Look mit deinen Lieblings-Sneakern?",exploreSuggestions:"Vorschläge entdecken",topColors:"Top Farben",searchPlaceholder:"In meiner Garderobe suchen...",all:"Alle",tops:"Oberteile",bottoms:"Unterteile",footwear:"Schuhe",coats:"Mäntel",accessories:"Accessoires",edit:"Bearbeiten",makeDirty:"Schmutzig machen",moveToTrash:"In den Papierkorb verschieben",laundryBasket:"Wäschekorb",lookSentToLaundry:"Stücke in die Wäsche geschickt!",laundryMsg:"Hier findest du die Stücke, die du als schmutzig markiert hast. Wasche sie, um sie in den Hauptschrank zurückzulegen.",washing:"Waschen",emptyBasket:"Leerer Korb",createNewLook:"Neues Outfit erstellen",lookName:"Outfit Name",selectedPieces:"Ausgewählte Stücke",selectPieces:"Stücke auswählen...",saveLook:"Outfit speichern",closetLabel:"Schrank",lookHistory:"Outfit-Verlauf",pieces:"Stücke",newItem:"Neuer Artikel",preview:"Vorschau",name:"Name",category:"Kategorie",color:"Farbe",imageUrl:"Bild-URL",cancel:"Abbrechen",save:"Speichern",register:"Registrieren",yourAccount:"Dein Konto",papMode:"PAP-Modus",preferences:"Präferenzen",darkMode:"Dunkelmodus",interfaceAppearance:"Erscheinungsbild der Schnittstelle",notifications:"Benachrichtigungen",lookReminders:"Outfit-Erinnerungen",weatherAlerts:"Wetterwarnungen",weatherSuggestions:"Wetterbasierte Vorschläge",systemAndData:"System und Daten",appLanguage:"App-Sprache",portuguese:"Português (PT)",english:"English (EN)",spanish:"Español (ES)",french:"Français (FR)",german:"Deutsch (DE)",exportData:"Daten exportieren (JSON)",exportDataAlert:"Deine Daten würden jetzt im JSON-Format exportiert werden.",privacyPolicy:"Datenschutzrichtlinie",recycleBin:"Papierkorb",empty:"Leeren",deleted:"Gelöscht",criticalZone:"Kritische Zone",fullCleanActions:"Aktionen zur vollständigen Bereinigung.",clearAll:"Alles löschen",confirmDeletePerm:"Dauerhaft löschen?",confirmDeleteLook:"Dieses Outfit löschen?",confirmEmptyTrash:"Papierkorb dauerhaft leeren?",confirmClearAll:"Alle aktiven Stücke in den Papierkorb verschieben?",colorBlack:"Schwarz",colorWhite:"Weiß",colorBlue:"Blau",colorRed:"Rot",colorGreen:"Grün",colorYellow:"Gelb",colorPink:"Rosa",colorPurple:"Lila",colorOrange:"Orange",colorBrown:"Braun",colorBeige:"Beige",colorGray:"Grau",userTitle:"Benutzer",themeColor:"Themenfarbe",personalizeColor:"Farbe anpassen",advancedFilters:"Filter",filterByColor:"Farbe",filterByAge:"Artikelalter",anyAge:"Jedes Alter",lessThanMonth:"Weniger als 1 Monat",lessThan6Months:"Weniger als 6 Monate",lessThanYear:"Weniger als 1 Jahr",older:"Älter",applyFilters:"Filter anwenden",profileInfo:"Kontoinformationen",username:"Benutzername",fullName:"Vollständiger Name",dob:"Geburtsdatum",bio:"Biografie / Über mich",optional:"(Optional)",saving:"Speichern...",sections:"Bereiche",manageSections:"Bereiche verwalten",newSection:"Neuer Bereich",sectionName:"Bereichsname",sectionEmoji:"Emoji",noSections:"Noch keine Bereiche erstellt.",addSection:"Bereich hinzufügen",deleteSection:"Löschen",assignSections:"Bereichen zuweisen",allSections:"Alle",confirmDeleteSection:"Diesen Bereich löschen?",sectionPlaceholder:"Zb: Arbeit, Party...",emojiPlaceholder:"Zb: 💼",createSection:"Bereich erstellen",noSectionsCreated:"Noch keine Bereiche erstellt",linkCopied:"Link kopiert!",share:"Teilen",piecesInLaundry:"Stück(e) in der Wäsche",toBeWashed:"Zum Waschen",unavailable:"Nicht verfügbar",availableLooks:"Verfügbar",noLooksAvailable:"Kein Outfit verfügbar",location:"Ort",locationEx:"Z.B.: Lissabon, Portugal",ideaSuggestion:"Idee / Vorschlag",bugError:"Fehler / Bug",writeMessage:"Schreibe hier deine Nachricht...",sendMessage:"Nachricht Senden",notificationsModal:"Benachrichtigungen",noNotifications:"Keine Benachrichtigungen",markAllRead:"Alle als gelesen markieren",lookCopiedBy:"hat dein Outfit kopiert",userSavedLook:"hat dein Outfit gespeichert",inTheirCloset:"in seinem Schrank!",sharedLookTitle:"Geteiltes Outfit",sharedBy:"Geteilt von",includedPieces:"Enthaltene Stücke",ignore:"Ignorieren",copying:"Kopieren...",copyToMyCloset:"In meinen Schrank kopieren",msgSentSuccess:"Nachricht erfolgreich gesendet!",msgSendError:"Fehler beim Senden. Überprüfe deine Verbindung.",addFuturePurchase:"Als zukünftigen Kauf hinzufügen",wishlist:"Wunschzettel",wishlistDesc:"Wunschzettel",someone:"jemand",feedbackTitle:"Support und Feedback",feedbackDesc:"Hast du Ideen, Vorschläge oder ein Problem gefunden? Sende uns direkt eine Nachricht!",themeColorTitle:"Themenfarbe",personalizeColorDesc:"Farbe anpassen",saveChanges:"Änderungen Speichern",pasteLink:"Link Einfügen",pasteSharedLookLink:"Fügen Sie den Link zum geteilten Outfit ein:",invalidSharedLink:"Ungültiger Link. Stellen Sie sicher, dass Sie den vollständigen Link kopiert haben.",planning:"Planung",today:"Heute",monthLabel:"Monat",weekLabel:"Woche",chooseOutfit:"Outfit Wählen",removeOutfitDay:"Outfit von diesem Tag entfernen",noOutfitCreated:"Kein Outfit erstellt",piecesShort:"Stücke",editLook:"Outfit bearbeiten",uploadGallery:"Aus Galerie / Dateien hochladen",selectOneColor:"Wählen Sie mindestens eine Farbe",addColorsToItems:"Fügen Sie Ihren Artikeln Farben hinzu.",or:"ODER",cardSize:"Artikelgröße",cardSizeDesc:"Größe in Schrank/Warenkorb",small:"Klein",medium:"Mittel",large:"Groß",defaultPage:"Startseite",defaultPageDesc:"Seite, die nach der Anmeldung angezeigt wird",community:"Gemeinschaft",searchUsers:"Nach @username suchen...",privateProfile:"Privates Profil",privateProfileDesc:"Kleiderschrank vor anderen Benutzern verbergen",viewProfile:"Profil anzeigen",noUsersFound:"Keine Benutzer gefunden",isPrivateUser:"Dieses Profil ist privat.",userOutfits:"Outfits des Benutzers",userCloset:"Kleiderschrank",usernameTaken:"Dieser Benutzername ist bereits vergeben."}};function C2(){var $o,Rs,sc,Wo,jr,qo,Ho,Ai,Ni,Go,Ds,Ko,Qo,Nn,Yo;const[t,e]=G.useState("auth"),[n,r]=G.useState(null),[s,i]=G.useState(!0),[o,l]=G.useState([]),[c,h]=G.useState([]),[m,v]=G.useState(null),[g,N]=G.useState(!1),[L,O]=G.useState(""),[z,I]=G.useState(""),[x,b]=G.useState([]),[F,K]=G.useState(!0),[H,k]=G.useState("login"),[_,w]=G.useState(""),[S,A]=G.useState(!1),[R,T]=G.useState(""),[Ke,dn]=G.useState("Todos"),[Ot,Mt]=G.useState(""),[Q,se]=G.useState("any"),[re,Ce]=G.useState(!1),[Ee,be]=G.useState(!1),[We,yt]=G.useState([]),[Le,Vt]=G.useState(null),[W,Ro]=G.useState({}),[gs,vr]=G.useState(!1),[ys,vs]=G.useState(!0),[_r,_s]=G.useState(!0),[tt,ci]=G.useState("PT"),[kd,ws]=G.useState(!1),[qn,xs]=G.useState("theme-indigo"),[wr,ui]=G.useState("large"),[Do,di]=G.useState("dashboard"),[Se,nt]=G.useState(null),[xr,jo]=G.useState(!1),[Es,Rl]=G.useState("online"),[Sn,Dl]=G.useState(""),[Lo,hi]=G.useState([]),[In,jl]=G.useState(null),[Er,Oo]=G.useState([]),[Mo,kr]=G.useState([]),fi=G.useRef(""),[rt,tn]=G.useState(null),[Ll,Hn]=G.useState(!1),[Vo,Tr]=G.useState(!1),[pi,st]=G.useState(null),[nn,Sr]=G.useState([]),[ct,Fo]=G.useState("all"),[Td,Gt]=G.useState(!1),[mi,Ol]=G.useState(""),[gi,Ml]=G.useState(""),[Cn,Ir]=G.useState([]),[At,yi]=G.useState([]),[vi,ks]=G.useState(null),[Cr,_i]=G.useState(""),[Vl,Fl]=G.useState(""),[rn,Ul]=G.useState([]),[Uo,Gn]=G.useState(!1),[bn,hn]=G.useState(null),[br,zl]=G.useState("month"),[Ar,wi]=G.useState(new Date),[Nr,zo]=G.useState([]),[Bl,xi]=G.useState(!1),[Sd,Ei]=G.useState(!1),[Kn,$l]=G.useState(null),E=p=>{var C;return((C=yv[tt])==null?void 0:C[p])||yv.PT[p]||p},Qn={Vermelho:"#ef4444",Azul:"#3b82f6",Amarelo:"#eab308",Verde:"#22c55e",Laranja:"#f97316",Roxo:"#a855f7",Branco:"#f8fafc",Preto:"#0f172a",Cinzento:"#6b7280",Bege:"#d4b896"},fn=p=>{if(!p)return{backgroundColor:"#e5e7eb"};const M=p.split(",").map($=>$.trim()).filter(Boolean).map($=>Qn[$]||$.toLowerCase());return M.length===1?{backgroundColor:M[0]}:{background:`linear-gradient(135deg, ${M.join(", ")})`}},Ft=async(p,C)=>{if(n)try{const M=Re(ce,"artifacts",he,"users",n.uid,"profile","data");if(await Os(M,{settings:{[p]:C}},{merge:!0}),p==="isPrivate"){const $=Re(ce,"artifacts",he,"publicProfiles",n.uid);await Os($,{isPrivate:C,uid:n.uid},{merge:!0})}}catch(M){console.error("Error saving setting:",M)}},Pr=p=>{N(p),Ft("darkMode",p)},Wl=p=>{xs(p),Ft("theme",p)},Ie=p=>{ci(p),Ft("language",p),ws(!1)},ki=p=>{vs(p),Ft("notificationsEnabled",p)},Ts=p=>{_s(p),Ft("weatherAlerts",p)},Ss=p=>{ui(p),Ft("cardSize",p)},Id=p=>{di(p),Ft("defaultPage",p)},ql=p=>{jo(p),Ft("isPrivate",p)},Cd=p=>{p.stopPropagation(),p.preventDefault();const C=["online","away","offline"],M=C.indexOf(Es),$=C[(M+1)%C.length];Rl($),Ft("status",$)},Hl=async p=>{if(p)try{const C=Re(ce,"artifacts",he,"sharedLooks",p),M=await gv(C);M.exists()&&(tn({id:M.id,...M.data()}),Hn(!0),window.history.replaceState({},"",window.location.pathname))}catch(C){console.error("Erro ao buscar look partilhado:",C)}},bd=()=>{const p=window.prompt(E("pasteSharedLookLink")||"Cole o link do look partilhado:");if(p)try{const M=new URL(p).searchParams.get("shared");M?Hl(M):alert(E("invalidSharedLink")||"Link inválido. Certifique-se de copiar o link completo.")}catch{alert(E("invalidSharedLink")||"Link inválido. Certifique-se de copiar o link completo.")}};G.useEffect(()=>{m&&m.color?b(m.color.split(",").map(p=>p.trim()).filter(Boolean)):b([]),Ir((m==null?void 0:m.sections)||[])},[m]),G.useEffect(()=>{yi((Le==null?void 0:Le.sections)||[])},[Le]),G.useEffect(()=>{document.documentElement.classList.remove("theme-indigo","theme-rose","theme-emerald","theme-amber","theme-slate");const p=t==="auth"?"theme-indigo":qn;document.documentElement.classList.add(p),t!=="auth"&&(n!=null&&n.uid)&&localStorage.setItem(`app-theme-${n.uid}`,qn)},[qn,t,n==null?void 0:n.uid]),G.useEffect(()=>{(async()=>{})();const C=pI(ha,async M=>{if(!M)r(null),l([]),h([]),Sr([]),Ro({}),N(!1),xs("theme-indigo"),ci("PT"),vs(!0),_s(!0),nt(null),e("auth"),i(!1);else{const $=localStorage.getItem(`app-theme-${M.uid}`)||"theme-indigo";xs($),r(M);try{const Y=Re(ce,"artifacts",he,"users",M.uid,"profile","data"),te=await gv(Y);let Z="dashboard";if(te.exists()){const a=te.data();a.settings&&a.settings.defaultPage&&(Z=a.settings.defaultPage==="planning"?"planner":a.settings.defaultPage,di(Z))}e(Z)}catch{e("dashboard")}const V=fi.current||new URLSearchParams(window.location.search).get("shared");fi.current="",V&&Hl(V),i(!1)}});return()=>C()},[]),G.useEffect(()=>{if(!n)return;const p=Et(ce,"artifacts",he,"users",n.uid,"clothes"),C=Li(p,D=>{l(D.docs.map(j=>({id:j.id,...j.data()})))},D=>console.error(D)),M=Et(ce,"artifacts",he,"users",n.uid,"looks"),$=Li(M,D=>{h(D.docs.map(j=>({id:j.id,...j.data()})))},D=>console.error(D)),V=Et(ce,"artifacts",he,"users",n.uid,"sections"),Y=Li(V,D=>{Sr(D.docs.map(j=>({id:j.id,...j.data()})).sort((j,le)=>j.createdAt-le.createdAt))},D=>console.error(D)),te=Et(ce,"artifacts",he,"users",n.uid,"outfitPlans"),Z=Li(te,D=>{zo(D.docs.map(j=>({id:j.id,...j.data()})))},D=>console.error(D)),a=Re(ce,"artifacts",he,"users",n.uid,"profile","data"),d=Li(a,D=>{if(D.exists()){const j=D.data();Ro(j),j.settings&&(j.settings.language!==void 0&&ci(j.settings.language),j.settings.darkMode!==void 0&&N(j.settings.darkMode),j.settings.theme!==void 0&&xs(j.settings.theme),j.settings.notificationsEnabled!==void 0&&vs(j.settings.notificationsEnabled),j.settings.weatherAlerts!==void 0&&_s(j.settings.weatherAlerts),j.settings.cardSize!==void 0&&ui(j.settings.cardSize),j.settings.defaultPage!==void 0&&di(j.settings.defaultPage==="planning"?"planner":j.settings.defaultPage),j.settings.isPrivate!==void 0&&jo(j.settings.isPrivate),j.settings.status!==void 0&&Rl(j.settings.status))}else Ro({})},D=>console.error(D)),f=Et(ce,"artifacts",he,"inboxNotifications"),y=hv(f,fv("recipientUid","==",n.uid)),P=Li(y,D=>{Ul(D.docs.map(j=>({id:j.id,...j.data()})).sort((j,le)=>le.createdAt-j.createdAt))},D=>console.error("Notif listener error:",D));return()=>{C(),$(),Y(),d(),P(),Z()}},[n]);const Ad=p=>p===0?"☀️":[1,2,3].includes(p)?"⛅":[45,48].includes(p)?"🌫️":[51,53,55,56,57,61,63,65,66,67].includes(p)?"🌧️":[71,73,75,77,85,86].includes(p)?"❄️":[80,81,82].includes(p)?"🌦️":[95,96,99].includes(p)?"⛈️":"☀️";G.useEffect(()=>{if(!n)return;(async()=>{try{const C=(W==null?void 0:W.location)||"Lisboa, Portugal",$=await(await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(C)}&count=1&language=pt&format=json`)).json();if($.results&&$.results.length>0){const{latitude:V,longitude:Y,name:te,country:Z}=$.results[0],d=await(await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${V}&longitude=${Y}¤t_weather=true&daily=temperature_2m_max,temperature_2m_min,weathercode&timezone=auto`)).json();if(d.current_weather&&d.daily){const f=d.daily.time.map((y,P)=>({date:y,min:Math.round(d.daily.temperature_2m_min[P]),max:Math.round(d.daily.temperature_2m_max[P]),weathercode:d.daily.weathercode[P]}));nt({name:`${te}, ${Z||""}`.replace(/,\s*$/,""),currentTemp:Math.round(d.current_weather.temperature),minTemp:Math.round(d.daily.temperature_2m_min[0]),maxTemp:Math.round(d.daily.temperature_2m_max[0]),avgTemp:Math.round((d.daily.temperature_2m_min[0]+d.daily.temperature_2m_max[0])/2),forecast:f})}}}catch(C){console.error("Error fetching weather",C)}})()},[W==null?void 0:W.location,n]),G.useEffect(()=>{var p;if(n&&W){const C=Re(ce,"artifacts",he,"publicProfiles",n.uid);Os(C,{uid:n.uid,username:W.username||"",fullName:W.fullName||"",avatar:W.avatar||null,isPrivate:((p=W.settings)==null?void 0:p.isPrivate)||!1},{merge:!0}).catch(console.error)}},[n,W==null?void 0:W.username,W==null?void 0:W.fullName,W==null?void 0:W.avatar,($o=W==null?void 0:W.settings)==null?void 0:$o.isPrivate]),G.useEffect(()=>{if(t!=="community")return;(async()=>{try{const C=Et(ce,"artifacts",he,"publicProfiles"),$=(await Ac(C)).docs.map(V=>V.data()).filter(V=>V.uid!==(n==null?void 0:n.uid));if(Sn.trim()){let V=Sn.toLowerCase();V.startsWith("@")&&(V=V.substring(1)),hi($.filter(Y=>Y.username&&Y.username.toLowerCase().includes(V)))}else hi($)}catch(C){console.error("Erro ao buscar comunidade",C)}})()},[t,Sn,n==null?void 0:n.uid]);const Is=async p=>{if(jl(p),p.isPrivate){Oo([]),kr([]);return}try{const C=Et(ce,"artifacts",he,"users",p.uid,"clothes"),M=await Ac(C);Oo(M.docs.map(Y=>({id:Y.id,...Y.data()})).filter(Y=>Y.status!=="trash"));const $=Et(ce,"artifacts",he,"users",p.uid,"looks"),V=await Ac($);kr(V.docs.map(Y=>({id:Y.id,...Y.data()})))}catch(C){console.error("Erro ao carregar perfil do utilizador",C)}},vt=G.useMemo(()=>o.filter(p=>p.status==="active"),[o]),Ti=G.useMemo(()=>o.filter(p=>p.status==="laundry"),[o]),Si=G.useMemo(()=>o.filter(p=>p.status==="trash"),[o]),Gl=G.useMemo(()=>o.filter(p=>p.status==="wishlist"),[o]),Rr=G.useMemo(()=>o.filter(p=>{const C=p.status!=="trash",M=ct==="all"||p.sections&&p.sections.includes(ct);return C&&M}),[o,ct]),Kl=async()=>{if(!Cr.trim()||!n||!vi)return;const p=Re(ce,"artifacts",he,"users",n.uid,"sections",vi);await Dn(p,{name:Cr.trim(),emoji:Vl.trim()||"💼"}),ks(null),_i(""),Fl("")},Ql=async()=>{if(!mi.trim()||!n)return;const p=Et(ce,"artifacts",he,"users",n.uid,"sections");await ji(p,{name:mi.trim(),emoji:gi.trim()||"💼",createdAt:new Date().getTime()}),Ol(""),Ml("")},Nd=async p=>{if(!window.confirm(E("confirmDeleteSection")))return;const C=Re(ce,"artifacts",he,"users",n.uid,"sections",p);await ua(C);const M=da(ce);o.forEach($=>{if($.sections&&$.sections.includes(p)){const V=Re(ce,"artifacts",he,"users",n.uid,"clothes",$.id);M.update(V,{sections:$.sections.filter(Y=>Y!==p)})}}),c.forEach($=>{if($.sections&&$.sections.includes(p)){const V=Re(ce,"artifacts",he,"users",n.uid,"looks",$.id);M.update(V,{sections:$.sections.filter(Y=>Y!==p)})}}),await M.commit(),ct===p&&Fo("all")},pn=async(p,C)=>{if(!n)return;const M=Re(ce,"artifacts",he,"users",n.uid,"outfitPlans",p),$=Nr.find(Y=>Y.date===p);let V=[];if($&&(V=$.lookIds||($.lookId?[$.lookId]:[])),C===null){await ua(M);return}V.includes(C)?V=V.filter(Y=>Y!==C):V=[...V,C],V.length>0?await Os(M,{date:p,lookIds:V,updatedAt:new Date().getTime()},{merge:!0}):await ua(M)},Ii=new Date;Ii.setHours(0,0,0,0);const Yl=`${Ii.getFullYear()}-${String(Ii.getMonth()+1).padStart(2,"0")}-${String(Ii.getDate()).padStart(2,"0")}`,Cs=p=>{const C=Nr.find($=>$.date===p);return C?(C.lookIds||(C.lookId?[C.lookId]:[])).map($=>c.find(V=>V.id===$)).filter(Boolean):[]},bs=Cs(Yl),As=t==="wishlist"?Gl:vt,Ns=G.useMemo(()=>{const p=new Set(As.map(C=>C.color).filter(Boolean));return Array.from(p)},[As]),Dr=G.useMemo(()=>{if(!vt.length)return[];const p={};let C=0;return vt.forEach(M=>{M.color&&(p[M.color]=(p[M.color]||0)+1,C++)}),C===0?[]:Object.entries(p).sort((M,$)=>$[1]-M[1]).slice(0,3).map(([M,$])=>({color:M,count:$,percentage:Math.round($/C*100)}))},[vt]),Xl=G.useMemo(()=>As.filter(p=>{const C=(p.name||"").toLowerCase().includes(L.toLowerCase())||(p.color||"").toLowerCase().includes(L.toLowerCase()),M=Ke==="Todos"||Ke===E("all")||p.category===Ke,$=!Ot||p.color&&p.color.includes(Ot),V=ct==="all"||p.sections&&p.sections.includes(ct);let Y=!0;if(Q!=="any"){const a=(new Date().getTime()-(p.createdAt||new Date().getTime()))/(1e3*60*60*24);Q==="month"?Y=a<=30:Q==="6months"?Y=a<=180:Q==="1year"?Y=a<=365:Q==="older"&&(Y=a>365)}const te=!re||p.favorite;return C&&M&&$&&Y&&V&&te}),[As,L,Ke,Ot,Q,E,ct,re]),An=async(p,C)=>{if(!n)return;const M=Re(ce,"artifacts",he,"users",n.uid,"clothes",C.id||C);switch(p){case"favorite":await Dn(M,{favorite:!C.favorite});break;case"trash":await Dn(M,{status:"trash",trashedAt:new Date().getTime()});break;case"restore":await Dn(M,{status:"active",trashedAt:null});break;case"laundry":await Dn(M,{status:"laundry"});break;case"clean":await Dn(M,{status:"active"});break;case"delete":window.confirm(E("confirmDeletePerm"))&&await ua(M);break}},Oe=async(p,C)=>{if(!n)return;const M=Re(ce,"artifacts",he,"users",n.uid,"looks",C.id||C);switch(p){case"favorite":await Dn(M,{favorite:!C.favorite});break}},Pd=async p=>{if(p.preventDefault(),!n)return;const C=new FormData(p.target),M=C.get("color");if(!M||M.trim()===""){alert("Por favor selecione pelo menos uma cor.");return}i(!0);const $={name:C.get("name"),category:C.get("category"),color:C.get("color"),imageUrl:C.get("imageUrl")||"https://images.unsplash.com/photo-1521572267360-ee0c2909d518?q=80&w=500&auto=format&fit=crop",status:C.get("isWishlist")?"wishlist":m&&m.status==="wishlist"?"active":m?m.status:"active",favorite:m&&m.favorite||!1,sections:Cn,updatedAt:new Date().getTime()};try{const V=m?m.id:null;if(v(null),I(""),dn("Todos"),Mt(""),se("any"),O(""),e(C.get("isWishlist")?"wishlist":"closet"),V){const Y=Re(ce,"artifacts",he,"users",n.uid,"clothes",V);await Dn(Y,$)}else{$.createdAt=new Date().getTime();const Y=Et(ce,"artifacts",he,"users",n.uid,"clothes");await ji(Y,$)}}catch(V){console.error(V)}finally{i(!1)}},Rd=async p=>{if(p.preventDefault(),We.length<2)return;i(!0);const M={name:new FormData(p.target).get("lookName"),items:We,sections:At,updatedAt:new Date().getTime()};try{if(Le){const $=Re(ce,"artifacts",he,"users",n.uid,"looks",Le.id);await Dn($,M)}else{M.createdAt=new Date().getTime();const $=Et(ce,"artifacts",he,"users",n.uid,"looks");await ji($,M)}yt([]),Vt(null),e("outfits")}catch($){console.error($)}finally{i(!1)}},Jl=async p=>{if(!window.confirm(E("confirmDeleteLook")))return;const C=Re(ce,"artifacts",he,"users",n.uid,"looks",p);await ua(C)},Zl=async p=>{if(n)try{const C=p.items.map(Z=>{const a=o.find(d=>d.id===Z);return a?{name:a.name,category:a.category,color:a.color,imageUrl:a.imageUrl}:null}).filter(Boolean),M=Et(ce,"artifacts",he,"sharedLooks"),$=Re(M),Y=`${window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"https://mycloset.epvc.pt":window.location.origin}${window.location.pathname}?shared=${$.id}`;let te=!1;try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(Y),te=!0;else throw new Error("Clipboard API indisponível")}catch{try{const a=document.createElement("textarea");a.value=Y,a.style.position="fixed",a.style.left="-9999px",document.body.appendChild(a),a.focus(),a.select(),te=document.execCommand("copy"),document.body.removeChild(a)}catch(a){console.error("Erro no fallback de clipboard:",a)}}await Os($,{lookName:p.name,ownerUid:n.uid,ownerEmail:n.email||"",items:C,createdAt:new Date().getTime()}),te?(st(p.id),setTimeout(()=>st(null),3e3)):alert("Link de partilha: "+Y)}catch(C){console.error("Erro ao partilhar look:",C),alert("Erro ao gerar link de partilha.")}},ec=async()=>{if(!(!n||!rt)){Tr(!0);try{const p=[];for(const M of rt.items){const $=Et(ce,"artifacts",he,"users",n.uid,"clothes"),V=await ji($,{name:M.name,category:M.category,color:M.color,imageUrl:M.imageUrl,status:"active",favorite:!1,createdAt:new Date().getTime(),updatedAt:new Date().getTime()});p.push(V.id)}const C=Et(ce,"artifacts",he,"users",n.uid,"looks");if(await ji(C,{name:rt.lookName,items:p,createdAt:new Date().getTime(),updatedAt:new Date().getTime()}),rt.ownerUid&&rt.ownerUid!==n.uid)try{const M=Et(ce,"artifacts",he,"inboxNotifications");await ji(M,{type:"look_copied",recipientUid:rt.ownerUid,lookName:rt.lookName,copiedByEmail:(W==null?void 0:W.username)||n.email||"Alguém",createdAt:new Date().getTime(),read:!1})}catch(M){console.error("Não foi possível enviar notificação ao dono do look:",M)}Hn(!1),tn(null),e("outfits")}catch(p){console.error("Erro ao copiar look:",p),alert("Erro ao copiar look.")}finally{Tr(!1)}}},Ci=async p=>{i(!0);try{const C=da(ce);p.items.forEach(M=>{const $=Re(ce,"artifacts",he,"users",n.uid,"clothes",M);C.update($,{status:"laundry"})}),await C.commit(),hn(E("lookSentToLaundry")||"Peças enviadas para a lavandaria!"),setTimeout(()=>hn(null),3e3)}catch(C){console.error(C)}finally{i(!1)}},tc=async p=>{p.preventDefault(),w(""),i(!0);const C=new FormData(p.target),M=C.get("email"),$=C.get("password");try{H==="login"?await dI(ha,M,$):await uI(ha,M,$)}catch(V){console.error(V),V.code==="auth/operation-not-allowed"?w(E("authErrorDisabled")):w(V.message)}finally{i(!1)}},mn=()=>{w(""),A(!0)},nc=async p=>{p.preventDefault();const C=R;if(C){i(!0),w("");try{await cI(ha,C),A(!1),T(""),hn(E("passwordResetSent")||"E-mail de recuperação enviado! Verifique a sua caixa de entrada.")}catch(M){console.error(M),w(M.message)}finally{i(!1)}}},Dd=async()=>{if(!(!n||!window.confirm(E("confirmEmptyTrash")))){i(!0);try{const p=da(ce);Si.forEach(C=>{const M=Re(ce,"artifacts",he,"users",n.uid,"clothes",C.id);p.delete(M)}),await p.commit()}catch(p){console.error(p)}finally{i(!1)}}},Ps=async()=>{if(!(!n||!window.confirm(E("confirmClearAll")))){i(!0);try{const p=da(ce);vt.forEach(C=>{const M=Re(ce,"artifacts",he,"users",n.uid,"clothes",C.id);p.update(M,{status:"trash",trashedAt:new Date().getTime()})}),await p.commit()}catch(p){console.error(p)}finally{i(!1)}}},rc=p=>{const C=p.target.files[0];if(!C||!n)return;const M=new FileReader;M.onload=$=>{const V=new Image;V.onload=async()=>{const Y=document.createElement("canvas"),te=400;let Z=V.width,a=V.height;Z>a?Z>te&&(a*=te/Z,Z=te):a>te&&(Z*=te/a,a=te),Y.width=Z,Y.height=a,Y.getContext("2d").drawImage(V,0,0,Z,a);const f=Y.toDataURL("image/jpeg",.8);try{const y=Re(ce,"artifacts",he,"users",n.uid,"profile","data");await Os(y,{avatar:f},{merge:!0})}catch(y){console.error("Error uploading image:",y)}},V.src=$.target.result},M.readAsDataURL(C)},Bo=p=>{const C=p.target.files[0];if(!C)return;const M=new FileReader;M.onload=$=>{const V=new Image;V.onload=()=>{const Y=document.createElement("canvas"),te=800;let Z=V.width,a=V.height;Z>a?Z>te&&(a*=te/Z,Z=te):a>te&&(Z*=te/a,a=te),Y.width=Z,Y.height=a,Y.getContext("2d").drawImage(V,0,0,Z,a);const f=Y.toDataURL("image/jpeg",.8);I(f)},V.src=$.target.result},M.readAsDataURL(C)},bi=async p=>{p.preventDefault(),vr(!0);const C=new FormData(p.target);try{let M=(C.get("username")||"").trim();if(M.startsWith("@")&&(M=M.substring(1)),M){const a=Et(ce,"artifacts",he,"publicProfiles"),d=hv(a,fv("username","==",M));if((await Ac(d)).docs.some(P=>P.data().uid!==n.uid)){alert(E("usernameTaken")||"Este nome de utilizador já está em uso."),vr(!1);return}}const $=Re(ce,"artifacts",he,"users",n.uid,"profile","data"),V=C.get("dobDay"),Y=C.get("dobMonth"),te=C.get("dobYear");let Z=C.get("dob")||"";V&&Y&&te&&(Z=`${te}-${Y}-${V}`),Os($,{username:M,fullName:C.get("fullName")||"",dob:Z,bio:C.get("bio")||"",location:C.get("location")||""},{merge:!0}).catch(a=>{console.error(a)})}catch(M){console.error(M)}finally{setTimeout(()=>{vr(!1)},600)}};return s&&!n?u.jsx("div",{className:"h-screen flex items-center justify-center bg-primary-50 dark:bg-gray-950",children:u.jsx(qg,{className:"animate-spin text-primary-600",size:40})}):t==="auth"?u.jsxs("div",{className:`min-h-screen bg-gradient-to-br from-primary-100 via-white to-purple-50 dark:from-gray-950 dark:to-gray-900 flex items-center justify-center p-6 text-gray-900 ${g?"dark":""}`,children:[u.jsx(Ve,{className:"max-w-md w-full p-12 border-none shadow-2xl overflow-hidden",darkMode:g,children:u.jsxs("div",{className:"animate-custom-zoom",children:[u.jsxs("div",{className:"text-center mb-10",children:[u.jsx("div",{className:"inline-flex p-5 bg-primary-600 rounded-[2rem] shadow-2xl shadow-primary-600/40 mb-6 transition-all duration-300",children:H==="login"?u.jsx(aa,{className:"text-white w-12 h-12"}):u.jsx(Bg,{className:"text-white w-12 h-12"})}),u.jsx("h1",{className:"text-5xl font-black tracking-tighter italic",children:"MyCloset"})]}),_&&u.jsxs("div",{className:"mb-6 p-4 bg-red-50 text-red-600 text-[10px] rounded-2xl flex items-center gap-2 font-black uppercase tracking-widest border border-red-100",children:[u.jsx(w1,{size:16})," ",_]}),u.jsxs("form",{onSubmit:tc,className:"space-y-4",children:[u.jsx("input",{name:"email",type:"email",placeholder:E("emailPlaceholder"),required:!0,className:"w-full p-5 rounded-2xl bg-gray-50 dark:bg-gray-800 border-none focus:ring-2 focus:ring-primary-500 outline-none font-bold"}),u.jsx("input",{name:"password",type:"password",placeholder:E("passwordPlaceholder"),required:!0,className:"w-full p-5 rounded-2xl bg-gray-50 dark:bg-gray-800 border-none focus:ring-2 focus:ring-primary-500 outline-none font-bold"}),H==="login"&&u.jsx("div",{className:"text-right",children:u.jsx("button",{type:"button",onClick:mn,className:"text-[10px] font-black text-primary-500 hover:text-primary-600 uppercase tracking-widest transition-colors",children:E("forgotPassword")||"Esqueceu-se da palavra-passe?"})}),u.jsx("button",{className:"w-full py-5 bg-primary-600 text-white rounded-[2rem] font-black text-lg shadow-2xl hover:scale-[1.02] active:scale-95 transition-all",children:E(H==="login"?"loginBtn":"registerBtn")})]}),u.jsx("div",{className:"mt-10 text-center",children:u.jsx("button",{type:"button",onClick:()=>k(H==="login"?"register":"login"),className:"text-gray-400 font-black text-[10px] uppercase tracking-[0.3em] hover:text-primary-600 transition-colors text-inherit",children:E(H==="login"?"createAccount":"haveAccount")})}),u.jsx("div",{className:"mt-12 flex justify-center gap-5 pt-8 border-t border-gray-100 dark:border-gray-800/50",children:[{id:"PT",flag:"🇵🇹"},{id:"EN",flag:"🇬🇧"},{id:"ES",flag:"🇪🇸"},{id:"FR",flag:"🇫🇷"},{id:"DE",flag:"🇩🇪"}].map(p=>u.jsx("button",{type:"button",onClick:()=>ci(p.id),className:`text-2xl transition-all duration-500 hover:scale-150 active:scale-95 ${tt===p.id?"scale-125 drop-shadow-[0_0_8px_rgba(79,70,229,0.3)]":"grayscale opacity-30 hover:grayscale-0 hover:opacity-100"}`,title:p.id,children:p.flag},p.id))})]},H)}),S&&u.jsx("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/60 backdrop-blur-sm p-6",onClick:()=>A(!1),children:u.jsxs(Ve,{className:"w-full max-w-md p-8 animate-in zoom-in-95",darkMode:g,onClick:p=>p.stopPropagation(),children:[u.jsx("h3",{className:"text-2xl font-black mb-4 text-center text-inherit",children:E("forgotPassword")}),u.jsx("p",{className:"text-center opacity-70 mb-8 text-sm text-inherit",children:E("forgotPasswordPrompt")}),u.jsxs("form",{onSubmit:nc,className:"space-y-4",children:[u.jsx("input",{name:"resetEmail",type:"email",placeholder:E("emailPlaceholder"),required:!0,value:R,onChange:p=>T(p.target.value),className:"w-full p-5 rounded-2xl bg-gray-50 dark:bg-gray-800 border-none focus:ring-2 focus:ring-primary-500 outline-none font-bold text-inherit"}),u.jsx("button",{type:"submit",disabled:s,className:"w-full py-5 bg-primary-600 text-white rounded-[2rem] font-black text-lg shadow-2xl hover:scale-[1.02] active:scale-95 transition-all disabled:opacity-50",children:E(s?"saving":"sendEmailBtn")})]}),u.jsx("button",{type:"button",onClick:()=>A(!1),className:"w-full mt-6 py-4 uppercase font-black text-[10px] tracking-widest text-gray-500 hover:text-gray-900 dark:hover:text-white transition-colors",children:E("cancel")})]})})]}):u.jsxs("div",{className:`min-h-screen flex transition-all duration-700 ${g?"bg-gray-950 text-white dark":"bg-[#FDFDFF] text-gray-900"}`,children:[u.jsx("aside",{className:` fixed md:relative inset-y-0 left-0 z-[100] transition-all duration-500 ease-in-out border-r overflow-hidden ${g?"bg-gray-900/80 border-gray-800":"bg-white border-gray-100"} ${F?"w-80 translate-x-0":"w-0 -translate-x-full md:w-0 md:opacity-0"} `,children:u.jsxs("div",{className:"p-10 h-full flex flex-col backdrop-blur-xl",children:[u.jsxs("button",{onClick:()=>e("closet"),className:"flex items-center gap-4 mb-16 hover:scale-[1.02] transition-transform text-left cursor-pointer w-full",children:[u.jsx("div",{className:"p-3 bg-primary-600 rounded-2xl shadow-xl shadow-primary-600/30",children:u.jsx(aa,{className:"text-white",size:24})}),u.jsx("span",{className:"text-3xl font-black tracking-tighter italic",children:"MyCloset"})]}),u.jsx("nav",{className:"flex-1 space-y-3",children:[{id:"dashboard",label:E("dashboard"),icon:k1},{id:"closet",label:E("closet"),icon:aa},{id:"wishlist",label:E("wishlist")||"Carrinho",icon:Qg},{id:"laundry",label:E("laundry"),icon:Ls},{id:"outfits",label:E("outfits"),icon:la},{id:"planner",label:E("planning"),icon:Fg},{id:"community",label:E("community"),icon:R1},{id:"settings",label:E("settings"),icon:ch}].map(p=>u.jsxs("button",{onClick:()=>e(p.id),className:`w-full flex items-center gap-4 px-6 py-4 rounded-2xl transition-all font-black text-[11px] uppercase tracking-widest ${t===p.id?"bg-primary-600 text-white shadow-2xl shadow-primary-600/30 scale-105":"opacity-40 hover:opacity-100 hover:bg-primary-500/5"}`,children:[u.jsx(p.icon,{size:20}),u.jsx("span",{children:p.label})]},p.id))}),u.jsxs("div",{className:"mt-auto pt-10 border-t border-inherit",children:[u.jsxs("div",{onClick:()=>e("profile"),className:"w-full flex items-center gap-4 mb-8 px-2 text-left hover:bg-gray-100 dark:hover:bg-gray-800 py-3 rounded-2xl transition-all cursor-pointer",children:[u.jsx("div",{className:`w-12 h-12 rounded-2xl shrink-0 flex items-center justify-center font-black text-white shadow-xl overflow-hidden ${g?"bg-primary-500":"bg-primary-600"}`,children:W!=null&&W.avatar?u.jsx("img",{src:W.avatar,className:"w-full h-full object-cover",alt:"Avatar"}):(((Rs=W==null?void 0:W.fullName)==null?void 0:Rs[0])||((sc=W==null?void 0:W.username)==null?void 0:sc[0])||((Wo=n==null?void 0:n.email)==null?void 0:Wo[0])||"U").toUpperCase()}),u.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[u.jsxs("p",{className:"text-sm font-black truncate text-inherit",children:["@",(W==null?void 0:W.username)||((jr=n==null?void 0:n.email)==null?void 0:jr.split("@")[0])||E("userTitle")]}),u.jsx("div",{onClick:Cd,className:"inline-block mt-1 cursor-pointer hover:opacity-80 transition-opacity",title:"Mudar estado",children:u.jsx(Nc,{variant:Es==="online"?"success":Es==="away"?"warning":"default",children:E(Es)})})]})]}),u.jsxs("button",{onClick:()=>{n!=null&&n.uid&&localStorage.removeItem(`app-theme-${n.uid}`),mI(ha)},className:"w-full py-4 text-red-500 font-black uppercase tracking-widest text-[10px] hover:bg-red-500/10 rounded-2xl transition-all flex items-center justify-center gap-3",children:[u.jsx(S1,{size:16})," ",E("logout")]})]})]})}),u.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[u.jsxs("header",{className:`h-24 shrink-0 flex items-center justify-between px-8 md:px-12 transition-all border-b border-inherit ${g?"bg-gray-950/50":"bg-white/50"} backdrop-blur-xl`,children:[u.jsxs("div",{className:"flex items-center gap-6",children:[u.jsx("button",{onClick:()=>K(!F),className:`p-3 rounded-2xl transition-all border ${g?"bg-gray-800 border-gray-700":"bg-gray-50 border-gray-200"}`,children:F?u.jsx(C1,{size:24}):u.jsx(b1,{size:24})}),u.jsxs("h2",{className:"text-3xl font-black tracking-tighter",children:[t==="dashboard"&&E("overview"),t==="closet"&&E("myCloset"),t==="wishlist"&&(E("wishlist")||"Carrinho"),t==="laundry"&&E("laundry"),t==="outfits"&&E("outfitsAndStyle"),t==="planner"&&E("planning"),t==="community"&&E("community"),t==="settings"&&E("settings"),t==="profile"&&E("profileInfo")]})]}),u.jsxs("div",{className:"flex items-center gap-4",children:[u.jsx("button",{onClick:()=>xi(!0),className:"p-3 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-200 rounded-2xl hover:scale-105 active:scale-95 transition-all",children:u.jsx(la,{size:20})}),u.jsxs("div",{className:"flex bg-gray-100 dark:bg-gray-800 p-1.5 rounded-2xl",children:[u.jsx("button",{onClick:()=>Pr(!1),className:`p-2 rounded-xl ${g?"text-gray-500":"bg-white shadow-md text-primary-600"}`,children:u.jsx(P1,{size:18})}),u.jsx("button",{onClick:()=>Pr(!0),className:`p-2 rounded-xl ${g?"bg-gray-900 shadow-md text-primary-400":"text-gray-500"}`,children:u.jsx(I1,{size:18})})]}),u.jsxs("button",{onClick:()=>Gn(!0),className:"relative p-4 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-200 rounded-2xl hover:scale-105 active:scale-95 transition-all",children:[u.jsx(ia,{size:24}),rn.filter(p=>!p.read).length>0&&u.jsx("span",{className:"absolute top-2 right-2 w-3 h-3 bg-red-500 rounded-full border-2 border-white dark:border-gray-800"})]}),u.jsx("button",{onClick:()=>{v(null),I(""),e("add"),Vt(null),yt([])},className:"p-4 bg-primary-600 text-white rounded-2xl shadow-xl shadow-primary-600/30 hover:scale-105 active:scale-95 transition-all",children:u.jsx(oa,{size:24})})]})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto p-8 md:p-12 space-y-12",children:[t==="dashboard"&&u.jsxs("div",{className:"space-y-12 animate-in fade-in duration-700",children:[u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8",children:[{label:E("readyClothes"),val:vt.length,icon:aa,col:"primary"},{label:E("inLaundry"),val:Ti.length,icon:Ls,col:"blue"},{label:E("myLooks"),val:c.length,icon:la,col:"purple"}].map((p,C)=>u.jsxs(Ve,{className:"p-8 group hover:-translate-y-2",darkMode:g,children:[u.jsx("div",{className:`w-14 h-14 rounded-2xl flex items-center justify-center mb-6 shadow-inner ${g?"bg-gray-700 text-primary-400":"bg-primary-50 text-primary-600"}`,children:u.jsx(p.icon,{size:28})}),u.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest opacity-40 mb-1",children:p.label}),u.jsx("h4",{className:"text-4xl font-black tracking-tight",children:p.val})]},C))}),u.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[u.jsxs("div",{className:"lg:col-span-2 p-10 rounded-[2rem] relative overflow-hidden shadow-2xl",style:{backgroundColor:"hsl(var(--primary-600))",color:"white"},children:[u.jsxs("div",{className:"relative z-10 flex flex-col justify-between h-full",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[u.jsx($g,{size:28,style:{color:"rgba(255,255,255,0.7)"}}),u.jsx(Nc,{variant:"warning",children:Se?Se.name:E("todayIn")})]}),u.jsx("h3",{className:"text-5xl font-black tracking-tighter mb-4",style:{color:"white"},children:Se?E("weatherCurrentAvg").replace("{current}",Se.currentTemp).replace("{avg}",Se.avgTemp):E("weatherUpdate")}),u.jsx("p",{className:"text-lg font-medium max-w-lg leading-relaxed",style:{color:"rgba(255,255,255,0.8)"},children:Se?`${E("weatherForecastDesc").replace("{max}",Se.maxTemp).replace("{min}",Se.minTemp)} ${E("weatherMsg")}`:E("weatherMsg")})]}),u.jsxs("div",{className:"mt-10 flex gap-4 items-center",children:[vt.filter(p=>p.category==="Tops").slice(0,2).map(p=>u.jsx("div",{className:"w-16 h-16 rounded-xl overflow-hidden border-2",style:{borderColor:"rgba(255,255,255,0.4)"},children:u.jsx("img",{src:p.imageUrl,className:"w-full h-full object-cover",alt:""})},p.id)),u.jsxs("button",{onClick:()=>e("closet"),className:"flex items-center gap-2 font-black uppercase text-xs tracking-widest hover:translate-x-2 transition-transform",style:{color:"white"},children:[E("exploreSuggestions")," ",u.jsx(x1,{size:18})]})]})]}),u.jsx($g,{size:350,className:"absolute -bottom-20 -right-20",style:{color:"rgba(255,255,255,0.1)"}})]}),u.jsxs(Ve,{className:"p-8",darkMode:g,children:[u.jsxs("h3",{className:"text-lg font-black tracking-tight mb-8 flex items-center gap-2 text-inherit",children:[u.jsx(A1,{size:20})," ",E("topColors")]}),u.jsx("div",{className:"space-y-6",children:Dr.length>0?Dr.map(p=>u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex justify-between text-[10px] font-black uppercase tracking-widest opacity-50",children:[u.jsx("span",{children:p.color}),u.jsxs("span",{children:[p.percentage,"% (",p.count,")"]})]}),u.jsx("div",{className:"h-2 w-full bg-gray-100 dark:bg-gray-700 rounded-full overflow-hidden",children:u.jsx("div",{className:"h-full bg-primary-600",style:{width:`${p.percentage}%`}})})]},p.color)):u.jsx("p",{className:"text-xs opacity-50 italic",children:E("addColorsToItems")})})]})]})]}),(t==="closet"||t==="wishlist")&&u.jsxs("div",{className:"space-y-10 animate-in slide-in-from-bottom-8 duration-700",children:[u.jsxs("div",{className:"flex flex-col xl:flex-row gap-8 items-center justify-between",children:[u.jsxs("div",{className:"relative w-full max-w-2xl",children:[u.jsx(Hg,{className:"absolute left-6 top-1/2 -translate-y-1/2 text-gray-400",size:24}),u.jsx("input",{placeholder:E("searchPlaceholder"),className:`w-full pl-16 pr-8 py-6 rounded-[2rem] shadow-inner outline-none border-none focus:ring-4 focus:ring-primary-500/10 font-bold text-lg ${g?"bg-gray-800":"bg-gray-100"}`,onChange:p=>O(p.target.value)})]}),u.jsx("div",{className:"flex gap-3 w-full xl:w-auto",children:u.jsxs("button",{onClick:()=>be(!0),className:"flex items-center gap-3 px-8 py-4 bg-primary-600 text-white rounded-[2rem] font-black uppercase text-[10px] tracking-widest shadow-xl shadow-primary-600/30 hover:scale-105 transition-all",children:[u.jsx(oh,{size:18})," ",E("advancedFilters"),(Ot||re||Q!=="any"||Ke!=="Todos"&&Ke!==E("all"))&&u.jsx("span",{className:"w-2 h-2 rounded-full bg-white animate-pulse"})]})})]}),(t==="closet"||t==="wishlist"||t==="outfits")&&u.jsxs("div",{className:"flex items-center gap-3 overflow-x-auto pb-1 custom-scrollbar",children:[u.jsxs("button",{onClick:()=>Fo("all"),className:`shrink-0 flex items-center gap-2 px-5 py-2.5 rounded-2xl font-black text-[10px] uppercase tracking-widest transition-all ${ct==="all"?"bg-primary-600 text-white shadow-lg shadow-primary-600/30":g?"bg-gray-800 text-gray-400 hover:bg-gray-700":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:[u.jsx(Wg,{size:14})," ",E("allSections")]}),nn.map(p=>u.jsx("button",{onClick:()=>Fo(p.id),className:`shrink-0 flex items-center gap-2 px-5 py-2.5 rounded-2xl font-black text-[10px] uppercase tracking-widest transition-all ${ct===p.id?"bg-primary-600 text-white shadow-lg shadow-primary-600/30 scale-105":g?"bg-gray-800 text-gray-400 hover:bg-gray-700":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:p.name},p.id)),u.jsxs("button",{onClick:()=>Gt(!0),className:`shrink-0 flex items-center gap-2 px-4 py-2.5 rounded-2xl font-black text-[10px] uppercase tracking-widest transition-all border-2 border-dashed ${g?"border-gray-700 text-gray-500 hover:border-primary-500 hover:text-primary-400":"border-gray-200 text-gray-400 hover:border-primary-400 hover:text-primary-600"}`,children:[u.jsx(ch,{size:14})," ",E("manageSections")]})]}),u.jsx("div",{className:wr==="small"?"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-5 2xl:grid-cols-6 gap-6":wr==="medium"?"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 2xl:grid-cols-5 gap-8":"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 gap-10",children:Xl.map(p=>{const C={small:{badgeClass:"top-2 left-2 scale-[0.65] origin-top-left",heartContClass:"top-2 right-2",heartBtnClass:"p-1.5 rounded-lg",heartIcon:10,overlayContClass:"p-2 pb-[50px]",btnPyClass:"py-1 px-1",btnTextClass:"hidden",btnIcon:10,btnGap:"gap-1",btnRadius:"rounded-md",infoContClass:"bottom-2 left-2 right-2 p-2 rounded-xl",titleClass:"text-xs",colorDotClass:"w-2 h-2",colorTextClass:"text-[8px]",secTextClass:"text-[8px] px-1 py-0 rounded"},medium:{badgeClass:"top-4 left-4 scale-90 origin-top-left",heartContClass:"top-4 right-4",heartBtnClass:"p-2 rounded-xl",heartIcon:14,overlayContClass:"p-4 pb-[90px]",btnPyClass:"py-2 px-2",btnTextClass:"text-[8px]",btnIcon:12,btnGap:"gap-1.5",btnRadius:"rounded-xl",infoContClass:"bottom-4 left-4 right-4 p-4 rounded-2xl",titleClass:"text-sm",colorDotClass:"w-3 h-3",colorTextClass:"text-[9px]",secTextClass:"text-[9px] px-1.5 py-0.5 rounded-md"},large:{badgeClass:"top-6 left-6",heartContClass:"top-6 right-6",heartBtnClass:"p-3 rounded-2xl",heartIcon:18,overlayContClass:"p-6 pb-[136px]",btnPyClass:"py-3 px-2",btnTextClass:"text-[9px]",btnIcon:14,btnGap:"gap-2",btnRadius:"rounded-xl",infoContClass:"bottom-6 left-6 right-6 p-6 rounded-3xl",titleClass:"text-xl",colorDotClass:"w-4 h-4",colorTextClass:"text-[10px]",secTextClass:"text-[10px] px-2 py-0.5 rounded-md"}}[wr]||{badgeClass:"top-6 left-6",heartContClass:"top-6 right-6",heartBtnClass:"p-3 rounded-2xl",heartIcon:18,overlayContClass:"p-6 pb-[136px]",btnPyClass:"py-3 px-2",btnTextClass:"text-[9px]",btnIcon:14,btnGap:"gap-2",btnRadius:"rounded-xl",infoContClass:"bottom-6 left-6 right-6 p-6 rounded-3xl",titleClass:"text-xl",colorDotClass:"w-4 h-4",colorTextClass:"text-[10px]",secTextClass:"text-[10px] px-2 py-0.5 rounded-md"};return u.jsx("div",{className:"group",children:u.jsxs(Ve,{className:`overflow-hidden p-0 relative border-none hover:shadow-2xl transition-all duration-500 ${wr==="small"?"h-[180px]":wr==="medium"?"h-[320px]":"h-[480px]"}`,darkMode:g,children:[u.jsx("img",{src:p.imageUrl,className:"w-full h-full object-cover transition-transform duration-1000 group-hover:scale-110",alt:p.name}),u.jsx("div",{className:`absolute inset-0 bg-gradient-to-t from-black/80 via-transparent opacity-0 group-hover:opacity-100 transition-all duration-300 flex flex-col justify-end text-white z-10 pointer-events-none ${C.overlayContClass}`,children:u.jsxs("div",{className:`grid grid-cols-2 ${C.btnGap} pointer-events-auto`,children:[u.jsxs("button",{onClick:()=>{v(p),I(p.imageUrl||""),e("edit")},className:`${C.btnPyClass} bg-white text-primary-600 ${C.btnRadius} font-black uppercase flex items-center justify-center gap-1.5 hover:bg-primary-50`,children:[u.jsx(Ec,{size:C.btnIcon})," ",u.jsx("span",{className:C.btnTextClass,children:E("edit")})]}),u.jsxs("button",{onClick:()=>An("laundry",p),className:`${C.btnPyClass} bg-blue-600 text-white ${C.btnRadius} font-black uppercase flex items-center justify-center gap-1.5 hover:bg-blue-700`,children:[u.jsx(Ls,{size:C.btnIcon})," ",u.jsx("span",{className:C.btnTextClass,children:E("makeDirty")})]}),u.jsxs("button",{onClick:()=>An("trash",p),className:`${C.btnPyClass} bg-red-600/20 text-red-100 backdrop-blur-md ${C.btnRadius} font-black uppercase flex items-center justify-center gap-1.5 hover:bg-red-600 transition-colors col-span-2`,children:[u.jsx(Xg,{size:C.btnIcon})," ",u.jsx("span",{className:C.btnTextClass,children:E("moveToTrash")})]})]})}),u.jsx("div",{className:`absolute z-20 ${C.badgeClass}`,children:u.jsx(Nc,{children:p.category})}),u.jsx("div",{className:`absolute z-20 pointer-events-auto ${C.heartContClass}`,children:u.jsx("button",{onClick:()=>An("favorite",p),className:`${C.heartBtnClass} shadow-xl backdrop-blur-md transition-all ${p.favorite?"bg-rose-500 text-white":"bg-white/90 text-gray-400"}`,children:u.jsx(ah,{size:C.heartIcon,fill:p.favorite?"currentColor":"none"})})}),u.jsxs("div",{className:`absolute bg-white/95 dark:bg-gray-900/95 backdrop-blur-2xl shadow-2xl transform transition-transform group-hover:-translate-y-2 z-20 pointer-events-auto ${C.infoContClass}`,children:[u.jsx("h4",{className:`${C.titleClass} font-black tracking-tighter truncate`,children:p.name}),u.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5 border-r border-gray-200 dark:border-gray-700 pr-2",children:[u.jsx("div",{className:`${C.colorDotClass} rounded-full border border-black/10 shrink-0`,style:fn(p.color)}),u.jsx("span",{className:`${C.colorTextClass} font-black opacity-40 uppercase tracking-widest`,children:p.color})]}),p.sections&&p.sections.length>0&&u.jsx("div",{className:"flex items-center gap-1 overflow-x-auto custom-scrollbar no-scrollbar",children:p.sections.map(M=>{const $=nn.find(V=>V.id===M);return $?u.jsx("span",{className:`${C.secTextClass} font-bold bg-gray-100 dark:bg-gray-800 text-gray-500 whitespace-nowrap`,children:$.name},$.id):null})})]})]})]})},p.id)})})]}),t==="laundry"&&u.jsxs("div",{className:"space-y-12 animate-in fade-in duration-700",children:[u.jsxs("div",{className:"text-center max-w-2xl mx-auto space-y-4 text-inherit",children:[u.jsx("div",{className:"w-20 h-20 bg-blue-100 dark:bg-blue-900/30 rounded-[2rem] flex items-center justify-center mx-auto text-blue-600 shadow-inner",children:u.jsx(Ls,{size:40})}),u.jsx("h3",{className:"text-4xl font-black tracking-tight",children:E("laundryBasket")})]}),u.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8",children:[Ti.map(p=>u.jsxs(Ve,{className:"p-4 flex items-center gap-4 border-blue-200 dark:border-blue-900/50",darkMode:g,children:[u.jsx("img",{src:p.imageUrl,className:"w-16 h-16 rounded-2xl object-cover shadow-sm shrink-0",alt:""}),u.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center items-start",children:[u.jsx("p",{className:"font-black text-sm truncate w-full text-inherit",children:p.name}),u.jsx("div",{className:"mt-1.5",children:u.jsx(Nc,{variant:"warning",children:E("washing")})})]}),u.jsx("button",{onClick:()=>An("clean",p),className:"p-3 bg-green-500 text-white rounded-xl shadow-md hover:scale-105 transition-all shrink-0",children:u.jsx(Ug,{size:20})})]},p.id)),Ti.length===0&&u.jsx("div",{className:"col-span-full py-20 text-center opacity-20 font-black uppercase tracking-[0.5em] text-sm",children:E("emptyBasket")})]})]}),t==="outfits"&&u.jsx("div",{className:"space-y-12 animate-in fade-in duration-700 pb-20",children:u.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-12",children:[u.jsxs("div",{className:"lg:col-span-1 space-y-8",children:[u.jsxs(Ve,{className:"p-8 border-primary-200",darkMode:g,children:[u.jsxs("h3",{className:"text-2xl font-black tracking-tighter mb-6 flex items-center gap-3 text-inherit",children:[u.jsx(la,{className:"text-primary-600"})," ",Le?E("editLook")||"Editar Outfit":E("createNewLook")]}),u.jsxs("form",{onSubmit:Rd,className:"space-y-6",children:[u.jsx("input",{name:"lookName",placeholder:E("lookName"),defaultValue:(Le==null?void 0:Le.name)||"",required:!0,className:`w-full p-4 rounded-xl border-none shadow-inner font-bold ${g?"bg-gray-700":"bg-gray-100"}`}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("p",{className:"text-[10px] font-black uppercase opacity-40 tracking-widest",children:[E("selectedPieces")," (",We.length,")"]}),u.jsxs("div",{className:"flex flex-wrap gap-2",children:[We.map(p=>{const C=o.find(M=>M.id===p);return u.jsxs("div",{className:"relative group",children:[u.jsx("img",{src:C==null?void 0:C.imageUrl,className:"w-12 h-12 rounded-lg object-cover border-2 border-primary-500",alt:""}),u.jsx("button",{type:"button",onClick:()=>yt(We.filter(M=>M!==p)),className:"absolute -top-1 -right-1 bg-red-500 text-white rounded-full p-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:u.jsx(Di,{size:10})})]},p)}),We.length===0&&u.jsx("p",{className:"text-xs text-gray-400 italic",children:E("selectPieces")})]})]}),u.jsxs("div",{className:"space-y-3 pt-3 border-t border-inherit",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("label",{className:"text-[10px] font-black uppercase tracking-widest opacity-50 flex items-center gap-2",children:[u.jsx(Yg,{size:12})," ",E("assignSections")]}),u.jsxs("button",{type:"button",onClick:()=>Gt(!0),className:"text-[10px] font-black uppercase tracking-widest text-primary-600 hover:text-primary-700 flex items-center gap-1",children:[u.jsx(oa,{size:10})," ",E("createSection")]})]}),nn.length===0?u.jsx("div",{className:"p-4 border-2 border-dashed border-gray-200 dark:border-gray-800 rounded-2xl text-center",children:u.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest opacity-40",children:E("noSectionsCreated")})}):u.jsx("div",{className:"flex flex-wrap gap-2",children:nn.map(p=>u.jsxs("button",{type:"button",onClick:()=>{At.includes(p.id)?yi(At.filter(C=>C!==p.id)):yi([...At,p.id])},className:`flex items-center gap-2 px-3 py-1.5 rounded-xl text-xs font-bold transition-all border-2 ${At.includes(p.id)?"border-primary-600 bg-primary-600 text-white shadow-md shadow-primary-600/30":"border-transparent bg-gray-100 dark:bg-gray-800 text-gray-500 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:[p.name,At.includes(p.id)&&u.jsx(Rn,{size:12})]},p.id))})]}),u.jsxs("div",{className:"flex gap-4",children:[Le&&u.jsx("button",{type:"button",onClick:()=>{Vt(null),yt([])},className:"flex-1 py-4 font-black uppercase text-[10px] tracking-widest text-gray-500 hover:text-gray-900 transition-colors",children:E("cancel")}),u.jsx("button",{disabled:We.length<2,className:"flex-[2] py-4 bg-primary-600 text-white rounded-2xl font-black uppercase tracking-widest text-xs shadow-xl shadow-primary-600/30 disabled:opacity-30 transition-all",children:Le?E("saveChanges")||"Guardar":E("saveLook")})]})]},Le?Le.id:"new")]}),u.jsxs("div",{className:"space-y-4",children:[u.jsx("p",{className:"text-xs font-black uppercase opacity-50 tracking-widest px-2",children:E("closetLabel")}),u.jsx("div",{className:"grid grid-cols-4 gap-3 max-h-96 overflow-y-auto pr-2 custom-scrollbar",children:Rr.map(p=>u.jsxs("button",{onClick:()=>!We.includes(p.id)&&yt([...We,p.id]),className:`relative rounded-xl overflow-hidden aspect-square border-2 transition-all ${We.includes(p.id)?"border-primary-600 scale-90":"border-transparent hover:border-primary-200"}`,children:[u.jsx("img",{src:p.imageUrl,className:"w-full h-full object-cover",alt:""}),p.status==="wishlist"&&u.jsx("div",{className:"absolute top-1 left-1 bg-yellow-500 text-white p-1 rounded-md shadow-md",children:u.jsx(Qg,{size:10})}),We.includes(p.id)&&u.jsx("div",{className:"absolute inset-0 bg-primary-600/40 flex items-center justify-center text-white",children:u.jsx(Rn,{size:20})})]},p.id))})]})]}),u.jsx("div",{className:"lg:col-span-2 space-y-10",children:(()=>{const p=c.filter(V=>{const Y=ct==="all"||V.sections&&V.sections.includes(ct);let te=!0;Ot&&(te=V.items.some(a=>{const d=o.find(f=>f.id===a);return d&&d.color&&d.color.includes(Ot)}));const Z=!re||V.favorite;return Y&&te&&Z}),C=p.filter(V=>V.items.every(Y=>{const te=o.find(Z=>Z.id===Y);return!te||te.status!=="laundry"})),M=p.filter(V=>V.items.some(Y=>{const te=o.find(Z=>Z.id===Y);return te&&te.status==="laundry"})),$=V=>{const Y=V.items.some(te=>{const Z=o.find(a=>a.id===te);return Z&&Z.status==="laundry"});return u.jsxs(Ve,{className:`p-8 group hover:shadow-2xl transition-all border-none shadow-md ${Y?"opacity-75":""}`,darkMode:g,children:[u.jsxs("div",{className:"flex justify-between items-start mb-6",children:[u.jsxs("div",{className:"text-inherit",children:[u.jsx("h4",{className:"text-xl font-black tracking-tight",children:V.name}),u.jsxs("p",{className:"text-[10px] opacity-40 font-bold uppercase tracking-widest",children:[V.items.length," ",E("pieces")," • ",new Date(V.createdAt).toLocaleDateString()]})]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsxs("button",{onClick:()=>Zl(V),className:`p-2 transition-colors relative group/share ${pi===V.id?"text-green-500":"text-gray-300 hover:text-green-500"}`,title:"Partilhar outfit",children:[pi===V.id?u.jsx(Rn,{size:18}):u.jsx(Gg,{size:18}),u.jsx("span",{className:"absolute -top-8 left-1/2 -translate-x-1/2 bg-gray-900 text-white text-[9px] font-black uppercase tracking-widest px-2 py-1 rounded-lg whitespace-nowrap opacity-0 group-hover/share:opacity-100 transition-opacity pointer-events-none",children:pi===V.id?E("linkCopied"):E("share")})]}),u.jsx("button",{onClick:()=>Oe("favorite",V),className:`p-2 transition-colors relative group/fav ${V.favorite?"text-rose-500":"text-gray-300 hover:text-rose-500"}`,title:"Favorito",children:u.jsx(ah,{size:18,fill:V.favorite?"currentColor":"none"})}),u.jsx("button",{onClick:()=>{Vt(V),yt(V.items)},className:"p-2 text-gray-300 hover:text-primary-500 transition-colors",children:u.jsx(Ec,{size:18})}),u.jsx("button",{onClick:()=>Ci(V),className:"p-2 text-gray-300 hover:text-blue-500 transition-colors",title:"Lavar outfit inteiro",children:u.jsx(Ls,{size:18})}),u.jsx("button",{onClick:()=>Jl(V.id),className:"p-2 text-gray-300 hover:text-red-500 transition-colors",children:u.jsx(kc,{size:18})})]})]}),u.jsx("div",{className:"flex -space-x-4 mb-4",children:V.items.map(te=>{const Z=o.find(d=>d.id===te),a=(Z==null?void 0:Z.status)==="laundry";return u.jsxs("div",{className:`relative w-20 h-20 rounded-2xl border-4 overflow-hidden shadow-lg transform group-hover:rotate-6 transition-transform ${a?"border-blue-400":"border-white dark:border-gray-800"}`,children:[u.jsx("img",{src:Z==null?void 0:Z.imageUrl,className:`w-full h-full object-cover ${a?"brightness-75":""}`,alt:""}),a&&u.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-blue-500/30 backdrop-blur-[1px]",children:u.jsx(Ls,{size:18,className:"text-white drop-shadow"})})]},te)})}),Y&&u.jsxs("div",{className:"flex items-center gap-2 mt-2 px-3 py-2 bg-blue-50 dark:bg-blue-900/20 rounded-xl",children:[u.jsx(Ls,{size:14,className:"text-blue-500 shrink-0"}),u.jsxs("p",{className:"text-[10px] font-black uppercase tracking-widest text-blue-500",children:[V.items.filter(te=>{const Z=o.find(a=>a.id===te);return(Z==null?void 0:Z.status)==="laundry"}).length," ",E("piecesInLaundry")]})]}),V.sections&&V.sections.length>0&&u.jsx("div",{className:"flex items-center gap-1 mt-4 overflow-x-auto custom-scrollbar no-scrollbar",children:V.sections.map(te=>{const Z=nn.find(a=>a.id===te);return Z?u.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded-md bg-gray-100 dark:bg-gray-800 text-gray-500 whitespace-nowrap",children:Z.name},Z.id):null})})]},V.id)};return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"flex items-center justify-between px-2 flex-wrap gap-4",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-500"}),u.jsxs("h3",{className:"text-2xl font-black tracking-tighter text-inherit",children:[E("lookHistory")," ",u.jsxs("span",{className:"text-sm font-bold opacity-40",children:["— ",E("availableLooks")," (",C.length,")"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("button",{onClick:bd,className:`flex items-center gap-2 px-4 py-2 rounded-xl font-black text-[10px] uppercase tracking-widest transition-colors ${g?"bg-primary-900/30 text-primary-400 hover:bg-primary-900/50":"bg-primary-50 text-primary-600 hover:bg-primary-100"}`,title:E("pasteSharedLookLink")||"Colar link de look",children:[u.jsx(T1,{size:14})," ",u.jsx("span",{className:"hidden sm:inline",children:E("pasteLink")||"Colar Link"})]}),u.jsx(oh,{size:16,className:"text-gray-400 ml-2"}),u.jsxs("select",{value:Ot,onChange:V=>Mt(V.target.value),className:`p-2 rounded-xl border-none outline-none focus:ring-2 focus:ring-primary-500 font-bold text-xs ${g?"bg-gray-800 text-white":"bg-gray-100"}`,children:[u.jsx("option",{value:"",children:E("all")||"Todas as cores"}),["Vermelho","Azul","Amarelo","Verde","Laranja","Roxo","Branco","Preto","Cinzento","Bege"].map(V=>u.jsx("option",{value:V,children:V},V))]})]})]}),C.length>0?u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:C.map($)}):u.jsx("div",{className:"py-12 text-center opacity-20 font-black uppercase tracking-[0.3em] text-sm",children:E("noLooksAvailable")})]}),M.length>0&&u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"flex items-center gap-3 px-2",children:[u.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-blue-400"}),u.jsxs("h3",{className:"text-2xl font-black tracking-tighter text-inherit",children:[E("toBeWashed")," ",u.jsxs("span",{className:"text-sm font-bold opacity-40",children:["— ",E("unavailable")," (",M.length,")"]})]})]}),u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:M.map($)})]})]})})()})]})}),t==="planner"&&(()=>{const p=Ar.getFullYear(),C=Ar.getMonth(),M=j=>`${j.getFullYear()}-${String(j.getMonth()+1).padStart(2,"0")}-${String(j.getDate()).padStart(2,"0")}`,$=()=>{const j=new Date(p,C,1),le=new Date(p,C+1,0),xe=(j.getDay()+6)%7,ae=[];for(let me=0;me{const j=new Date(Ar),le=(j.getDay()+6)%7,xe=new Date(j);return xe.setDate(j.getDate()-le),Array.from({length:7},(ae,Ae)=>{const me=new Date(xe);return me.setDate(xe.getDate()+Ae),me})},te={PT:"pt-PT",EN:"en-GB",ES:"es-ES",FR:"fr-FR",DE:"de-DE"}[tt]||"pt-PT",Z=Array.from({length:12},(j,le)=>{const ae=new Date(2e3,le,1).toLocaleDateString(te,{month:"long"});return ae.charAt(0).toUpperCase()+ae.slice(1)}),a=Array.from({length:7},(j,le)=>new Date(2024,0,le+1).toLocaleDateString(te,{weekday:"short"}).replace(".","")),d=()=>{const j=new Date(Ar);br==="month"?j.setMonth(C-1):j.setDate(j.getDate()-7),wi(j)},f=()=>{const j=new Date(Ar);br==="month"?j.setMonth(C+1):j.setDate(j.getDate()+7),wi(j)},y=V(),P=`${y[0].getDate()} ${Z[y[0].getMonth()]} — ${y[6].getDate()} ${Z[y[6].getMonth()]} ${y[6].getFullYear()}`,D=({date:j,cur:le=!0})=>{const xe=M(j),ae=Cs(xe),Ae=xe===Yl,me=br==="week";let Ut=null;return _r&&Se&&Se.forecast&&(Ut=Se.forecast.find(it=>it.date===xe)),u.jsxs("div",{onClick:()=>{$l(xe),Ei(!0)},className:`relative rounded-2xl overflow-hidden cursor-pointer transition-all group border-2 flex flex-col ${Ae?"border-primary-600 shadow-lg shadow-primary-600/20":le?"border-transparent hover:border-primary-300 dark:hover:border-primary-700":"border-transparent opacity-30"} ${g?"bg-gray-800/80":"bg-gray-50"}`,style:{minHeight:me?"180px":"100px"},children:[u.jsxs("div",{className:`px-3 py-2 flex items-center justify-between shrink-0 ${Ae?"bg-primary-600":""}`,children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("span",{className:`text-xs font-black ${Ae?"text-white":""}`,children:j.getDate()}),Ut&&u.jsxs("div",{className:"flex items-center gap-1 text-xs",title:`${Ut.min}ºC - ${Ut.max}ºC`,children:[u.jsx("span",{className:"text-sm drop-shadow-sm",children:Ad(Ut.weathercode)}),u.jsxs("span",{className:`text-[10px] font-black ${Ae?"text-white/90":"text-gray-500 dark:text-gray-400"}`,children:[Math.round((Ut.min+Ut.max)/2),"°C"]})]})]}),Ae&&u.jsx("span",{className:"text-[8px] font-black text-white/80 uppercase tracking-widest",children:E("today")})]}),ae.length>0?u.jsx("div",{className:"px-2 pb-2 pt-1 flex-1 overflow-y-auto custom-scrollbar space-y-3",children:ae.map(it=>u.jsxs("div",{className:"space-y-1",children:[u.jsx("div",{className:"flex -space-x-2",children:it.items.slice(0,me?4:3).map(js=>{const Pi=o.find($x=>$x.id===js);return Pi?u.jsx("div",{className:`${me?"w-10 h-10":"w-7 h-7"} rounded-lg overflow-hidden border-2 border-white dark:border-gray-700 shrink-0`,children:u.jsx("img",{src:Pi.imageUrl,className:"w-full h-full object-cover",alt:""})},js):null})}),u.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest opacity-50 truncate",children:it.name}),me&&u.jsxs("p",{className:"text-[9px] opacity-40 font-bold",children:[it.items.length," ",E("piecesShort")]})]},it.id))}):le&&u.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:u.jsxs("div",{className:`flex items-center gap-1 px-3 py-1.5 rounded-xl text-[9px] font-black uppercase tracking-widest ${g?"bg-gray-700 text-primary-400":"bg-white text-primary-600 shadow-sm"}`,children:[u.jsx(oa,{size:10})," Outfit"]})})]})};return u.jsxs("div",{className:"space-y-6 animate-in fade-in duration-700 pb-20",children:[u.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("button",{onClick:d,className:`p-3 rounded-2xl transition-all border ${g?"bg-gray-800 border-gray-700 hover:bg-gray-700":"bg-white border-gray-200 hover:bg-gray-50"} shadow-sm`,children:u.jsx(zg,{size:20})}),u.jsx("h3",{className:"text-lg font-black tracking-tight min-w-[220px] text-center",children:br==="month"?`${Z[C]} ${p}`:P}),u.jsx("button",{onClick:f,className:`p-3 rounded-2xl transition-all border ${g?"bg-gray-800 border-gray-700 hover:bg-gray-700":"bg-white border-gray-200 hover:bg-gray-50"} shadow-sm`,children:u.jsx(E1,{size:20})}),u.jsx("button",{onClick:()=>wi(new Date),className:"px-4 py-2 text-[10px] font-black uppercase tracking-widest text-primary-600 bg-primary-50 dark:bg-primary-900/20 rounded-xl hover:bg-primary-100 dark:hover:bg-primary-900/40 transition-colors",children:E("today")})]}),u.jsx("div",{className:`flex p-1.5 rounded-2xl gap-1 ${g?"bg-gray-800":"bg-gray-100"}`,children:["month","week"].map(j=>u.jsx("button",{onClick:()=>zl(j),className:`px-5 py-2 rounded-xl font-black text-[10px] uppercase tracking-widest transition-all ${br===j?`${g?"bg-gray-700":"bg-white"} shadow-md text-primary-600`:"text-gray-500 hover:text-gray-700"}`,children:E(j==="month"?"monthLabel":"weekLabel")},j))})]}),u.jsx("div",{className:"grid grid-cols-7 gap-2",children:a.map(j=>u.jsx("div",{className:"text-center text-[10px] font-black uppercase tracking-widest opacity-40 py-1",children:j},j))}),br==="month"?u.jsx("div",{className:"grid grid-cols-7 gap-2",children:$().map(({date:j,cur:le})=>u.jsx(D,{date:j,cur:le},M(j)))}):u.jsx("div",{className:"grid grid-cols-7 gap-3",children:V().map(j=>u.jsx(D,{date:j,cur:!0},M(j)))})]})})(),(t==="add"||t==="edit")&&u.jsx("div",{className:"max-w-4xl mx-auto animate-in zoom-in-95 duration-500",children:u.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-12 items-start",children:[u.jsxs("div",{className:"space-y-8",children:[u.jsx("h3",{className:"text-5xl font-black tracking-tighter text-inherit",children:E(m?"edit":"newItem")}),u.jsx(Ve,{className:"aspect-[3/4] overflow-hidden shadow-2xl relative",darkMode:g,children:z?u.jsx("img",{src:z,className:"w-full h-full object-cover",alt:""}):u.jsxs("div",{className:"h-full flex flex-col items-center justify-center opacity-10",children:[u.jsx(lh,{size:100}),u.jsx("p",{className:"font-black uppercase tracking-[0.5em] mt-6",children:E("preview")})]})})]}),u.jsx(Ve,{className:"p-10 shadow-2xl",darkMode:g,children:u.jsxs("form",{onSubmit:Pd,className:"space-y-8",children:[u.jsx(Pc,{label:E("name"),name:"name",defaultValue:m==null?void 0:m.name,required:!0}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("label",{className:"text-[10px] font-black uppercase opacity-40 tracking-widest ml-1 text-inherit",children:E("category")}),u.jsxs("select",{name:"category",defaultValue:(m==null?void 0:m.category)||"Tops",className:`w-full p-5 rounded-2xl border-none outline-none focus:ring-4 focus:ring-primary-500/10 font-bold ${g?"bg-gray-700 text-white":"bg-gray-100"}`,children:[u.jsx("option",{children:E("tops")}),u.jsx("option",{children:E("bottoms")}),u.jsx("option",{children:E("footwear")}),u.jsx("option",{children:E("coats")}),u.jsx("option",{children:E("accessories")})]})]}),u.jsxs("label",{className:"flex items-center gap-3 p-4 rounded-xl border border-gray-100 dark:border-gray-800 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[u.jsx("input",{type:"checkbox",name:"isWishlist",defaultChecked:(m==null?void 0:m.status)==="wishlist",className:"w-5 h-5 text-primary-600 focus:ring-primary-500 rounded-lg"}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold text-sm text-inherit",children:E("wishlist")||E("wishlistDesc")}),u.jsx("p",{className:"text-[10px] uppercase tracking-widest opacity-50",children:E("addFuturePurchase")})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("label",{className:"text-[10px] font-black uppercase opacity-40 tracking-widest ml-1 text-inherit",children:[E("color")," *"]}),u.jsx("div",{className:"flex flex-wrap gap-2",children:["Vermelho","Azul","Amarelo","Verde","Laranja","Roxo","Branco","Preto","Cinzento","Bege"].map(p=>u.jsx("button",{type:"button",onClick:()=>{x.includes(p)?b(x.filter(C=>C!==p)):b([...x,p])},className:`px-4 py-2 rounded-xl text-xs font-bold transition-all border-2 ${x.includes(p)?"border-primary-600 bg-primary-600 text-white shadow-lg shadow-primary-600/30":"border-transparent bg-gray-100 dark:bg-gray-800 text-gray-500 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:p},p))}),u.jsx("input",{type:"hidden",name:"color",value:x.join(", ")}),x.length===0&&u.jsx("p",{className:"text-[10px] text-red-500 uppercase tracking-widest font-black mt-2",children:E("selectOneColor")})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsxs("label",{className:"text-[10px] font-black uppercase opacity-40 tracking-widest ml-1 text-inherit flex items-center gap-2",children:[u.jsx(lh,{size:12})," ",E("imageUrl")," ou Upload"]}),u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsx("input",{type:"text",name:"imageUrl",value:z,onChange:p=>I(p.target.value),placeholder:"https://...",className:`w-full p-5 rounded-2xl border-none outline-none focus:ring-4 focus:ring-primary-500/10 font-bold transition-all ${g?"bg-gray-700 text-white":"bg-gray-100 text-gray-900"}`}),u.jsxs("div",{className:"flex items-center gap-4",children:[u.jsx("div",{className:"h-px bg-gray-200 dark:bg-gray-700 flex-1"}),u.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest opacity-30",children:E("or")}),u.jsx("div",{className:"h-px bg-gray-200 dark:bg-gray-700 flex-1"})]}),u.jsxs("label",{className:`flex items-center justify-center gap-3 p-5 rounded-2xl cursor-pointer transition-all font-black text-[10px] uppercase tracking-widest border-2 border-dashed ${g?"bg-gray-800 border-gray-700 hover:border-primary-500 hover:text-primary-400":"bg-gray-50 border-gray-200 hover:border-primary-400 hover:text-primary-600"}`,children:[u.jsx(lh,{size:16}),u.jsx("span",{children:E("uploadGallery")}),u.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:Bo})]})]})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("label",{className:"text-[10px] font-black uppercase opacity-40 tracking-widest ml-1 text-inherit flex items-center gap-2",children:[u.jsx(Yg,{size:12})," ",E("assignSections")]}),u.jsxs("button",{type:"button",onClick:()=>Gt(!0),className:"text-[10px] font-black uppercase tracking-widest text-primary-600 hover:text-primary-700 flex items-center gap-1",children:[u.jsx(oa,{size:10})," ",E("createSection")]})]}),nn.length===0?u.jsx("div",{className:"p-4 border-2 border-dashed border-gray-200 dark:border-gray-800 rounded-2xl text-center",children:u.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest opacity-40",children:E("noSectionsCreated")})}):u.jsx("div",{className:"flex flex-wrap gap-2",children:nn.map(p=>u.jsxs("button",{type:"button",onClick:()=>{Cn.includes(p.id)?Ir(Cn.filter(C=>C!==p.id)):Ir([...Cn,p.id])},className:`flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold transition-all border-2 ${Cn.includes(p.id)?"border-primary-600 bg-primary-600 text-white shadow-lg shadow-primary-600/30":"border-transparent bg-gray-100 dark:bg-gray-800 text-gray-500 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:[p.name,Cn.includes(p.id)&&u.jsx(Rn,{size:12})]},p.id))})]}),u.jsxs("div",{className:"flex gap-4 pt-6",children:[u.jsx("button",{type:"button",onClick:()=>{v(null),I(""),e("closet")},className:"flex-1 font-black uppercase text-[10px] opacity-40 hover:opacity-100 tracking-widest transition-all text-inherit",children:E("cancel")}),u.jsx("button",{type:"submit",className:"flex-1 py-5 bg-primary-600 text-white rounded-[2rem] font-black uppercase tracking-widest text-[10px] shadow-2xl shadow-primary-600/40 hover:scale-[1.02] active:scale-95 transition-all",children:E(m?"save":"register")})]})]})})]})}),t==="profile"&&u.jsxs("div",{className:"max-w-4xl mx-auto space-y-12 animate-in fade-in duration-700 pb-20",children:[u.jsx(Ve,{className:"p-10 border-primary-100 relative overflow-hidden",darkMode:g,children:u.jsxs("div",{className:"flex items-center gap-8 relative z-10 text-inherit",children:[u.jsxs("div",{className:"w-24 h-24 rounded-[2.5rem] bg-primary-600 flex items-center justify-center text-white text-4xl font-black shadow-2xl relative overflow-hidden group cursor-pointer",children:[W!=null&&W.avatar?u.jsx("img",{src:W.avatar,className:"w-full h-full object-cover",alt:"Profile"}):u.jsx("span",{children:(((qo=W==null?void 0:W.fullName)==null?void 0:qo[0])||((Ho=W==null?void 0:W.username)==null?void 0:Ho[0])||((Ai=n==null?void 0:n.email)==null?void 0:Ai[0])||"U").toUpperCase()}),u.jsxs("label",{className:"absolute inset-0 bg-black/50 flex flex-col items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer text-white",children:[u.jsx(Ec,{size:20}),u.jsx("span",{className:"text-[8px] uppercase font-black mt-1 tracking-widest",children:E("edit")}),u.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:rc})]})]}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-3xl font-black tracking-tighter",children:(W==null?void 0:W.fullName)||E("yourAccount")}),u.jsxs("p",{className:"opacity-60 font-bold text-sm",children:["@",(W==null?void 0:W.username)||((Ni=n==null?void 0:n.email)==null?void 0:Ni.split("@")[0])||E("papMode")]})]})]})}),u.jsxs(Ve,{className:"p-8",darkMode:g,children:[u.jsxs("h3",{className:"text-xl font-black mb-6 flex items-center gap-3 text-inherit",children:[u.jsx(Bg,{className:"text-primary-600"})," ",E("profileInfo")]}),u.jsxs("form",{onSubmit:bi,className:"space-y-6",children:[u.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[u.jsxs("div",{className:"space-y-2 relative",children:[u.jsx("label",{className:"text-[10px] font-black uppercase opacity-40 tracking-widest ml-1 text-inherit",children:E("username")}),u.jsxs("div",{className:"relative",children:[u.jsx("span",{className:"absolute left-4 top-1/2 -translate-y-1/2 opacity-40 font-black",children:"@"}),u.jsx("input",{name:"username",defaultValue:(W==null?void 0:W.username)||"",placeholder:"amari",className:`w-full p-4 pl-10 rounded-xl border-none outline-none focus:ring-2 focus:ring-primary-500 font-bold ${g?"bg-gray-800 text-white":"bg-gray-50"}`})]})]}),u.jsx(Pc,{label:E("fullName"),name:"fullName",defaultValue:(W==null?void 0:W.fullName)||"",placeholder:"Ex: Amari Rodriguez"}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("label",{className:"text-[10px] font-black uppercase opacity-40 tracking-widest ml-1 text-inherit",children:[E("dob")," ",E("optional")]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsxs("select",{name:"dobDay",defaultValue:((Go=W==null?void 0:W.dob)==null?void 0:Go.split("-")[2])||"",className:`flex-1 p-4 rounded-xl border-none outline-none focus:ring-2 focus:ring-primary-500 font-bold ${g?"bg-gray-800 text-white":"bg-gray-50"}`,children:[u.jsx("option",{value:"",children:"DD"}),Array.from({length:31},(p,C)=>String(C+1).padStart(2,"0")).map(p=>u.jsx("option",{value:p,children:p},p))]}),u.jsxs("select",{name:"dobMonth",defaultValue:((Ds=W==null?void 0:W.dob)==null?void 0:Ds.split("-")[1])||"",className:`flex-1 p-4 rounded-xl border-none outline-none focus:ring-2 focus:ring-primary-500 font-bold ${g?"bg-gray-800 text-white":"bg-gray-50"}`,children:[u.jsx("option",{value:"",children:"MM"}),Array.from({length:12},(p,C)=>String(C+1).padStart(2,"0")).map(p=>u.jsx("option",{value:p,children:p},p))]}),u.jsxs("select",{name:"dobYear",defaultValue:((Ko=W==null?void 0:W.dob)==null?void 0:Ko.split("-")[0])||"",className:`flex-[1.5] p-4 rounded-xl border-none outline-none focus:ring-2 focus:ring-primary-500 font-bold ${g?"bg-gray-800 text-white":"bg-gray-50"}`,children:[u.jsx("option",{value:"",children:"YYYY"}),Array.from({length:100},(p,C)=>new Date().getFullYear()-C).map(p=>u.jsx("option",{value:p,children:p},p))]})]})]}),u.jsx(Pc,{label:`${E("bio")} ${E("optional")}`,name:"bio",defaultValue:(W==null?void 0:W.bio)||"",placeholder:"..."}),u.jsx(Pc,{label:E("location"),name:"location",defaultValue:(W==null?void 0:W.location)||"",placeholder:E("locationEx")})]}),u.jsx("button",{disabled:gs,type:"submit",className:"w-full py-4 bg-primary-600 text-white rounded-xl font-black uppercase text-[10px] tracking-widest shadow-xl shadow-primary-600/30 disabled:opacity-50 hover:scale-[1.01] transition-all",children:E(gs?"saving":"save")})]},`${W==null?void 0:W.username}-${W==null?void 0:W.fullName}-${W==null?void 0:W.dob}-${W==null?void 0:W.bio}-${W==null?void 0:W.location}`)]})]}),t==="community"&&u.jsx("div",{className:"max-w-7xl mx-auto space-y-12 animate-in fade-in duration-700 pb-20",children:In?u.jsxs("div",{className:"space-y-8",children:[u.jsxs("button",{onClick:()=>jl(null),className:"flex items-center gap-2 opacity-60 hover:opacity-100 transition-opacity font-black text-inherit uppercase text-xs tracking-widest",children:[u.jsx(zg,{size:16})," Voltar"]}),u.jsx(Ve,{className:"p-8 border-primary-100 relative overflow-hidden",darkMode:g,children:u.jsxs("div",{className:"flex items-center gap-8 relative z-10 text-inherit",children:[u.jsx("div",{className:"w-24 h-24 rounded-[2.5rem] bg-primary-600 text-white flex items-center justify-center font-black text-4xl overflow-hidden",children:In.avatar?u.jsx("img",{src:In.avatar,className:"w-full h-full object-cover",alt:"Avatar"}):u.jsx("span",{children:(((Qo=In.fullName)==null?void 0:Qo[0])||((Nn=In.username)==null?void 0:Nn[0])||"U").toUpperCase()})}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-3xl font-black tracking-tighter",children:In.fullName||E("userTitle")}),u.jsxs("p",{className:"opacity-60 font-bold text-sm",children:["@",In.username||"user"]})]})]})}),In.isPrivate?u.jsxs("div",{className:"text-center py-20 opacity-50 font-black text-2xl text-inherit",children:[u.jsx(Kg,{className:"w-16 h-16 mx-auto mb-4 opacity-50"}),E("isPrivateUser")]}):u.jsxs("div",{className:"space-y-12 text-inherit",children:[u.jsxs("div",{children:[u.jsxs("h3",{className:"text-xl font-black mb-6 uppercase tracking-widest text-[11px] opacity-50",children:[E("userOutfits")," (",Mo.length,")"]}),u.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-6",children:Mo.map(p=>u.jsxs("div",{className:"group relative aspect-[3/4] rounded-[2rem] overflow-hidden bg-gray-100 dark:bg-gray-800 cursor-pointer shadow-lg",children:[p.items&&p.items[0]&&Er.find(C=>C.id===p.items[0])&&u.jsx("img",{src:Er.find(C=>C.id===p.items[0]).imageUrl,className:"w-full h-full object-cover group-hover:scale-110 transition-transform duration-700",alt:"Look"}),u.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent flex items-end p-6",children:u.jsx("span",{className:"text-white font-black text-sm",children:p.name})})]},p.id))})]}),u.jsxs("div",{children:[u.jsxs("h3",{className:"text-xl font-black mb-6 uppercase tracking-widest text-[11px] opacity-50",children:[E("userCloset")," (",Er.length,")"]}),u.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-4",children:Er.map(p=>u.jsx("div",{className:"aspect-square rounded-2xl overflow-hidden bg-gray-100 dark:bg-gray-800 shadow-md",children:u.jsx("img",{src:p.imageUrl,className:"w-full h-full object-cover",alt:"Item"})},p.id))})]})]})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"relative mb-8",children:[u.jsx(Hg,{className:"absolute left-6 top-1/2 -translate-y-1/2 opacity-40 text-inherit",size:24}),u.jsx("input",{type:"text",placeholder:E("searchUsers"),value:Sn,onChange:p=>Dl(p.target.value),className:`w-full p-6 pl-16 rounded-3xl font-black text-lg outline-none focus:ring-4 focus:ring-primary-500/20 transition-all shadow-xl shadow-black/5 text-inherit ${g?"bg-gray-800":"bg-white"}`})]}),u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Lo.length===0?u.jsx("div",{className:"col-span-full text-center py-12 opacity-50 text-inherit font-black text-xl",children:E("noUsersFound")}):Lo.map(p=>{var C,M;return u.jsx(Ve,{className:"p-6 cursor-pointer hover:scale-105 transition-transform",darkMode:g,onClick:()=>Is(p),children:u.jsxs("div",{className:"flex items-center gap-4 text-inherit",children:[u.jsx("div",{className:"w-16 h-16 rounded-2xl bg-primary-600 text-white flex items-center justify-center font-black text-2xl overflow-hidden",children:p.avatar?u.jsx("img",{src:p.avatar,className:"w-full h-full object-cover",alt:"Avatar"}):u.jsx("span",{children:(((C=p.fullName)==null?void 0:C[0])||((M=p.username)==null?void 0:M[0])||"U").toUpperCase()})}),u.jsxs("div",{children:[u.jsx("h3",{className:"font-black text-lg",children:p.fullName||E("userTitle")}),u.jsxs("p",{className:"text-sm opacity-60 font-bold",children:["@",p.username||"user"]})]})]})},p.uid)})})]})}),t==="settings"&&u.jsxs("div",{className:"max-w-4xl mx-auto space-y-12 animate-in fade-in duration-700 pb-20",children:[u.jsxs("div",{className:"flex flex-col gap-8",children:[u.jsxs(Ve,{className:"p-8",darkMode:g,children:[u.jsxs("h3",{className:"text-xl font-black mb-6 flex items-center gap-3 text-inherit",children:[u.jsx(ch,{className:"text-primary-600"})," ",E("preferences")]}),u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"font-bold text-inherit",children:E("darkMode")}),u.jsx("p",{className:"text-[10px] uppercase tracking-widest opacity-50 text-inherit",children:E("interfaceAppearance")})]}),u.jsx("button",{onClick:()=>Pr(!g),className:`w-14 h-8 rounded-full transition-colors relative ${g?"bg-primary-600":"bg-gray-200"}`,children:u.jsx("div",{className:`w-6 h-6 rounded-full bg-white absolute top-1 transition-all ${g?"left-7":"left-1"}`})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"font-bold text-inherit",children:E("themeColor")||"Cor do Tema"}),u.jsx("p",{className:"text-[10px] uppercase tracking-widest opacity-50 text-inherit",children:E("personalizeColor")||"Personalize a cor"})]}),u.jsx("div",{className:"flex gap-2",children:[{id:"theme-indigo",color:"#4f46e5"},{id:"theme-rose",color:"#e11d48"},{id:"theme-emerald",color:"#10b981"},{id:"theme-amber",color:"#f59e0b"},{id:"theme-slate",color:"#64748b"}].map(p=>u.jsx("button",{onClick:()=>Wl(p.id),className:`w-6 h-6 rounded-full transition-all flex items-center justify-center ${qn===p.id?"ring-2 ring-offset-2 ring-offset-white dark:ring-offset-gray-900 ring-primary-500 scale-110":"hover:scale-110"}`,style:{backgroundColor:p.color},children:qn===p.id&&u.jsx(Rn,{size:12,className:"text-white"})},p.id))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"font-bold text-inherit flex items-center gap-2",children:E("notifications")}),u.jsx("p",{className:"text-[10px] uppercase tracking-widest opacity-50 text-inherit",children:E("lookReminders")})]}),u.jsx("button",{onClick:()=>ki(!ys),className:`w-14 h-8 rounded-full transition-colors relative ${ys?"bg-primary-600":"bg-gray-200"}`,children:u.jsx("div",{className:`w-6 h-6 rounded-full bg-white absolute top-1 transition-all ${ys?"left-7":"left-1"}`})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"font-bold text-inherit flex items-center gap-2",children:E("weatherAlerts")}),u.jsx("p",{className:"text-[10px] uppercase tracking-widest opacity-50 text-inherit",children:E("weatherSuggestions")})]}),u.jsx("button",{onClick:()=>Ts(!_r),className:`w-14 h-8 rounded-full transition-colors relative ${_r?"bg-primary-600":"bg-gray-200"}`,children:u.jsx("div",{className:`w-6 h-6 rounded-full bg-white absolute top-1 transition-all ${_r?"left-7":"left-1"}`})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"font-bold text-inherit flex items-center gap-2",children:E("privateProfile")}),u.jsx("p",{className:"text-[10px] uppercase tracking-widest opacity-50 text-inherit",children:E("privateProfileDesc")})]}),u.jsx("button",{onClick:()=>ql(!xr),className:`w-14 h-8 rounded-full transition-colors relative ${xr?"bg-primary-600":"bg-gray-200"}`,children:u.jsx("div",{className:`w-6 h-6 rounded-full bg-white absolute top-1 transition-all ${xr?"left-7":"left-1"}`})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"font-bold text-inherit",children:E("cardSize")||"Tamanho do Card"}),u.jsx("p",{className:"text-[10px] uppercase tracking-widest opacity-50 text-inherit",children:E("cardSizeDesc")||"Tamanho no armário/carrinho"})]}),u.jsx("div",{className:"flex gap-2",children:["small","medium","large"].map(p=>u.jsx("button",{onClick:()=>Ss(p),className:`px-3 py-1.5 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all border-2 ${wr===p?"border-primary-600 bg-primary-600 text-white shadow-lg shadow-primary-600/30 scale-105":"border-transparent bg-gray-100 dark:bg-gray-800 text-gray-500 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:p==="small"?E("small")||"Pequeno":p==="medium"?E("medium")||"Médio":E("large")||"Grande"},p))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"font-bold text-inherit",children:E("defaultPage")||"Página Inicial"}),u.jsx("p",{className:"text-[10px] uppercase tracking-widest opacity-50 text-inherit",children:E("defaultPageDesc")||"Página que aparece após o login"})]}),u.jsx("div",{className:"flex gap-2",children:["dashboard","closet","outfits","planner"].map(p=>u.jsx("button",{onClick:()=>Id(p),className:`px-3 py-1.5 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all border-2 ${Do===p?"border-primary-600 bg-primary-600 text-white shadow-lg shadow-primary-600/30 scale-105":"border-transparent bg-gray-100 dark:bg-gray-800 text-gray-500 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:E(p==="dashboard"?"dashboard":p==="closet"?"myCloset":p==="outfits"?"outfits":"planning")},p))})]}),u.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-100 dark:border-gray-800",children:[u.jsxs("div",{children:[u.jsx("p",{className:"font-bold text-inherit",children:E("appLanguage")}),u.jsx("p",{className:"text-[10px] uppercase tracking-widest opacity-50 text-inherit",children:tt==="PT"?"🇵🇹 "+E("portuguese"):tt==="EN"?"🇬🇧 "+E("english"):tt==="ES"?"🇪🇸 "+E("spanish"):tt==="FR"?"🇫🇷 "+E("french"):tt==="DE"?"🇩🇪 "+E("german"):tt})]}),u.jsx("button",{onClick:()=>ws(!0),className:"px-5 py-2 font-black text-[10px] uppercase tracking-widest bg-primary-50 text-primary-600 rounded-xl hover:bg-primary-100 transition-colors dark:bg-primary-900/40 dark:text-primary-400",children:E("edit")})]})]})]}),u.jsxs(Ve,{className:"p-8",darkMode:g,children:[u.jsxs("h3",{className:"text-xl font-black mb-6 flex items-center gap-3 text-inherit",children:[u.jsx(ia,{className:"text-primary-600"})," ",E("feedbackTitle")||"Suporte e Feedback"]}),u.jsx("p",{className:"opacity-60 text-sm font-medium mb-6",children:E("feedbackDesc")||"Tem alguma ideia, sugestão ou encontrou algum problema? Envie uma mensagem diretamente para nós!"}),u.jsxs("form",{onSubmit:async p=>{p.preventDefault();const C=new FormData(p.target),M=C.get("type"),$=C.get("message"),V="faiker027@gmail.com";try{if((await fetch(`https://formsubmit.co/ajax/${V}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({Tipo:M,Mensagem:$,Utilizador:(n==null?void 0:n.email)||"Desconhecido",_subject:`MyCloset Feedback: ${M}`})})).ok)hn(E("msgSentSuccess")),setTimeout(()=>hn(null),4e3),p.target.reset();else throw new Error("Falha no envio")}catch(Y){console.error("Erro ao enviar feedback:",Y),hn(E("msgSendError")),setTimeout(()=>hn(null),4e3)}},className:"space-y-4",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[u.jsxs("label",{className:"flex items-center gap-3 p-4 rounded-xl border border-gray-100 dark:border-gray-800 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[u.jsx("input",{type:"radio",name:"type",value:"Ideia/Sugestão",defaultChecked:!0,className:"text-primary-600 focus:ring-primary-500"}),u.jsx("span",{className:"font-bold text-sm text-inherit",children:E("ideaSuggestion")})]}),u.jsxs("label",{className:"flex items-center gap-3 p-4 rounded-xl border border-gray-100 dark:border-gray-800 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[u.jsx("input",{type:"radio",name:"type",value:"Bug/Erro",className:"text-primary-600 focus:ring-primary-500"}),u.jsx("span",{className:"font-bold text-sm text-inherit",children:E("bugError")})]})]}),u.jsx("textarea",{name:"message",required:!0,placeholder:E("writeMessage"),rows:4,className:`w-full p-4 rounded-xl border-none outline-none focus:ring-2 focus:ring-primary-500 font-bold resize-none ${g?"bg-gray-800 text-white":"bg-gray-50"}`}),u.jsx("button",{type:"submit",className:"w-full py-4 bg-primary-600 text-white rounded-xl font-black uppercase text-[10px] tracking-widest shadow-xl shadow-primary-600/30 hover:scale-[1.01] transition-all",children:E("sendMessage")})]})]})]}),u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"flex items-center justify-between px-2 text-inherit",children:[u.jsxs("h3",{className:"text-xl font-black text-red-500 flex items-center gap-3 tracking-widest uppercase",children:[u.jsx(Xg,{size:24})," ",E("recycleBin")]}),Si.length>0&&u.jsx("button",{onClick:Dd,className:"text-[10px] font-black text-red-500 uppercase tracking-widest hover:underline",children:E("empty")})]}),u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Si.map(p=>u.jsxs(Ve,{className:"p-4 flex items-center gap-5 border-red-50",darkMode:g,children:[u.jsx("img",{src:p.imageUrl,className:"w-16 h-16 rounded-2xl object-cover grayscale opacity-40",alt:""}),u.jsxs("div",{className:"flex-1 min-w-0 text-inherit",children:[u.jsx("p",{className:"font-black text-sm truncate",children:p.name}),u.jsx("p",{className:"text-[10px] font-black text-red-400 uppercase tracking-tighter",children:E("deleted")})]}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("button",{onClick:()=>An("restore",p),className:"p-3 text-primary-600 hover:bg-primary-50 rounded-2xl transition-all",children:u.jsx(N1,{size:18})}),u.jsx("button",{onClick:()=>An("delete",p.id),className:"p-3 text-red-600 hover:bg-red-50 rounded-2xl transition-all",children:u.jsx(kc,{size:18})})]})]},p.id))})]}),u.jsx(Ve,{className:"p-10 border-red-200 bg-red-50/10",darkMode:g,children:u.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-8",children:[u.jsxs("div",{className:"text-inherit",children:[u.jsxs("h4",{className:"text-xl font-black text-red-700 flex items-center gap-3",children:[u.jsx(Kg,{})," ",E("criticalZone")]}),u.jsx("p",{className:"opacity-60 font-bold text-sm mt-2",children:E("fullCleanActions")})]}),u.jsx("button",{onClick:Ps,className:"px-8 py-4 bg-red-600 text-white rounded-2xl font-black uppercase text-[10px] tracking-widest hover:bg-red-700 transition-all",children:E("clearAll")})]})})]})]})]}),Sd&&Kn&&u.jsx("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/60 backdrop-blur-sm p-6",onClick:()=>Ei(!1),children:u.jsxs(Ve,{className:"w-full max-w-lg p-8 animate-in zoom-in-95 flex flex-col max-h-[80vh]",darkMode:g,onClick:p=>p.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between mb-6",children:[u.jsxs("div",{children:[u.jsxs("h3",{className:"text-xl font-black text-inherit flex items-center gap-3",children:[u.jsx(Fg,{size:22,className:"text-primary-600"})," ",E("chooseOutfit")]}),u.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest opacity-40 mt-1",children:(()=>{const p={PT:"pt-PT",EN:"en-GB",ES:"es-ES",FR:"fr-FR",DE:"de-DE"};return new Date(Kn+"T12:00:00").toLocaleDateString(p[tt]||"pt-PT",{weekday:"long",day:"numeric",month:"long"})})()})]}),u.jsx("button",{onClick:()=>Ei(!1),className:"p-2 bg-gray-100 dark:bg-gray-800 rounded-full hover:scale-110 transition-all text-inherit",children:u.jsx(Di,{size:20})})]}),Nr.find(p=>p.date===Kn)&&u.jsxs("button",{onClick:async()=>{await pn(Kn,null),Ei(!1)},className:"mb-4 w-full py-3 border-2 border-dashed border-red-200 dark:border-red-900/50 text-red-400 rounded-2xl font-black text-[10px] uppercase tracking-widest hover:border-red-400 hover:text-red-500 transition-all flex items-center justify-center gap-2",children:[u.jsx(kc,{size:14})," ",E("removeOutfitDay")]}),u.jsx("div",{className:"flex-1 overflow-y-auto space-y-3 custom-scrollbar",children:c.length===0?u.jsx("div",{className:"py-12 text-center opacity-30 font-black uppercase tracking-[0.3em] text-sm",children:E("noOutfitCreated")}):c.map(p=>{const C=Nr.find(V=>V.date===Kn),$=(C?C.lookIds||(C.lookId?[C.lookId]:[]):[]).includes(p.id);return u.jsxs("button",{onClick:async()=>{await pn(Kn,p.id)},className:`w-full flex items-center gap-4 p-4 rounded-2xl transition-all border-2 text-left ${$?"border-primary-600 bg-primary-50 dark:bg-primary-900/20":`border-transparent ${g?"bg-gray-800 hover:bg-gray-700":"bg-gray-50 hover:bg-gray-100"}`}`,children:[u.jsx("div",{className:"flex -space-x-2 shrink-0",children:p.items.slice(0,3).map(V=>{const Y=o.find(te=>te.id===V);return Y?u.jsx("div",{className:"w-12 h-12 rounded-xl overflow-hidden border-2 border-white dark:border-gray-700",children:u.jsx("img",{src:Y.imageUrl,className:"w-full h-full object-cover",alt:""})},V):null})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"font-black text-sm truncate text-inherit",children:p.name}),u.jsxs("p",{className:"text-[10px] uppercase tracking-widest opacity-40 font-bold",children:[p.items.length," ",E("piecesShort")]})]}),$&&u.jsx(Rn,{size:18,className:"text-primary-600 shrink-0"})]},p.id)})})]})}),bn&&u.jsx("div",{className:"fixed bottom-8 left-1/2 transform -translate-x-1/2 z-[300] animate-in slide-in-from-bottom-5",children:u.jsxs("div",{className:"bg-gray-900 text-white px-6 py-3 rounded-full shadow-2xl font-bold text-sm tracking-wide flex items-center gap-3",children:[u.jsx(Ug,{size:18,className:"text-green-400"}),bn]})}),Uo&&u.jsx("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/60 backdrop-blur-sm p-6",onClick:()=>Gn(!1),children:u.jsxs(Ve,{className:"w-full max-w-md p-8 animate-in zoom-in-95 flex flex-col max-h-[80vh]",darkMode:g,onClick:p=>p.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between mb-6",children:[u.jsxs("div",{children:[u.jsxs("h3",{className:"text-2xl font-black text-inherit flex items-center gap-3",children:[u.jsx(ia,{size:24,className:"text-primary-600"})," ",E("notificationsModal")]}),rn.filter(p=>!p.read).length>0&&u.jsxs("p",{className:"text-[10px] font-black uppercase tracking-widest text-primary-600 mt-1",children:[rn.filter(p=>!p.read).length," ",tt==="PT"?"nova(s)":tt==="EN"?"new":tt==="ES"?"nueva(s)":tt==="FR"?"nouvelle(s)":"neue"]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[rn.filter(p=>!p.read).length>0&&u.jsx("button",{onClick:async()=>{const p=da(ce);rn.filter(C=>!C.read).forEach(C=>{const M=Re(ce,"artifacts",he,"inboxNotifications",C.id);p.update(M,{read:!0})}),await p.commit()},className:"text-[9px] font-black uppercase tracking-widest text-primary-600 hover:underline px-3 py-2 hover:bg-primary-50 dark:hover:bg-primary-900/20 rounded-xl transition-all",children:E("markAllRead")}),u.jsx("button",{onClick:()=>Gn(!1),className:"p-2 bg-gray-100 dark:bg-gray-800 rounded-full hover:scale-110 transition-all text-inherit",children:u.jsx(Di,{size:20})})]})]}),u.jsx("div",{className:"flex-1 overflow-y-auto space-y-3 custom-scrollbar",children:rn.length===0?u.jsxs("div",{className:"py-16 text-center flex flex-col items-center gap-4 opacity-30",children:[u.jsx(ia,{size:40}),u.jsx("span",{className:"font-black uppercase tracking-[0.3em] text-sm",children:E("noNotifications")})]}):rn.map(p=>u.jsxs("div",{className:`p-4 rounded-2xl flex items-start gap-4 transition-all ${p.read?g?"bg-gray-800/60":"bg-gray-50":"bg-primary-50 dark:bg-primary-900/20 border border-primary-100 dark:border-primary-800/40"}`,children:[u.jsx("div",{className:`shrink-0 w-12 h-12 flex items-center justify-center rounded-2xl text-xl shadow-sm ${p.read?g?"bg-gray-700":"bg-gray-200":"bg-primary-100 dark:bg-primary-900/50"}`,children:p.type==="look_copied"?"✂️":u.jsx(ia,{size:20})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"font-bold text-sm leading-snug text-inherit",children:p.type==="look_copied"&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-primary-600 font-black",children:p.copiedByEmail})," ",E("lookCopiedBy")," ",u.jsxs("span",{className:"italic",children:['"',p.lookName,'"']})]})}),u.jsxs("p",{className:"text-[10px] uppercase font-black tracking-widest opacity-40 mt-1.5",children:[new Date(p.createdAt).toLocaleDateString()," às ",new Date(p.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]}),!p.read&&u.jsx("button",{onClick:async()=>{const C=Re(ce,"artifacts",he,"inboxNotifications",p.id);await Dn(C,{read:!0})},className:"shrink-0 p-2 text-primary-600 hover:bg-primary-100 dark:hover:bg-primary-900/40 rounded-xl transition-all",title:"Marcar como lida",children:u.jsx(Rn,{size:16})})]},p.id))})]})}),Td&&u.jsx("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/60 backdrop-blur-sm p-6",onClick:()=>Gt(!1),children:u.jsxs(Ve,{className:"w-full max-w-lg p-8 animate-in zoom-in-95 flex flex-col max-h-[90vh]",darkMode:g,onClick:p=>p.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between mb-8",children:[u.jsxs("h3",{className:"text-2xl font-black text-inherit flex items-center gap-3",children:[u.jsx(Wg,{size:24,className:"text-primary-600"})," ",E("manageSections")]}),u.jsx("button",{onClick:()=>Gt(!1),className:"p-2 bg-gray-100 dark:bg-gray-800 rounded-full hover:scale-110 transition-all text-inherit",children:u.jsx(Di,{size:20})})]}),u.jsxs("div",{className:`flex gap-3 mb-8 p-4 rounded-2xl ${g?"bg-gray-800":"bg-gray-50"}`,children:[u.jsx("input",{value:mi,onChange:p=>Ol(p.target.value),placeholder:E("sectionPlaceholder"),onKeyDown:p=>p.key==="Enter"&&Ql(),className:`flex-1 p-3 rounded-xl border-none outline-none font-bold ${g?"bg-gray-700 text-white":"bg-white"} shadow-sm`}),u.jsx("button",{onClick:Ql,disabled:!mi.trim(),className:"px-5 py-3 bg-primary-600 text-white rounded-xl font-black text-[10px] uppercase tracking-widest shadow-lg shadow-primary-600/30 hover:scale-105 active:scale-95 transition-all disabled:opacity-30",children:u.jsx(oa,{size:18})})]}),u.jsx("div",{className:"flex-1 overflow-y-auto space-y-3 custom-scrollbar",children:nn.length===0?u.jsx("div",{className:"py-12 text-center opacity-30 font-black uppercase tracking-[0.3em] text-sm",children:E("noSections")}):nn.map(p=>u.jsx("div",{className:`flex items-center gap-4 p-4 rounded-2xl transition-all ${g?"bg-gray-800":"bg-gray-50"}`,children:vi===p.id?u.jsxs(u.Fragment,{children:[u.jsx("input",{value:Cr,onChange:C=>_i(C.target.value),onKeyDown:C=>C.key==="Enter"&&Kl(),className:`flex-1 p-2 rounded-xl border-none outline-none font-bold text-sm ${g?"bg-gray-700 text-white":"bg-white"} shadow-sm`}),u.jsx("button",{onClick:Kl,disabled:!Cr.trim(),className:"p-2 bg-green-500 text-white rounded-xl shadow-md hover:scale-105 disabled:opacity-30",children:u.jsx(Rn,{size:16})}),u.jsx("button",{onClick:()=>ks(null),className:"p-2 bg-gray-200 dark:bg-gray-700 text-gray-500 dark:text-gray-400 rounded-xl hover:scale-105",children:u.jsx(Di,{size:16})})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"font-black text-sm truncate",children:p.name}),u.jsxs("p",{className:"text-[10px] opacity-40 font-bold uppercase tracking-widest",children:[o.filter(C=>C.sections&&C.sections.includes(p.id)).length," ",E("pieces")," • ",c.filter(C=>C.sections&&C.sections.includes(p.id)).length," look(s)"]})]}),u.jsx("button",{onClick:()=>{ks(p.id),_i(p.name),Fl(p.emoji)},className:"p-2 text-gray-400 hover:text-primary-600 hover:bg-primary-50 dark:hover:bg-primary-900/20 rounded-xl transition-all",children:u.jsx(Ec,{size:16})}),u.jsx("button",{onClick:()=>Nd(p.id),className:"p-2 text-red-400 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-xl transition-all",children:u.jsx(kc,{size:16})})]})},p.id))}),u.jsx("button",{onClick:()=>Gt(!1),className:"mt-8 w-full py-4 font-black uppercase text-[10px] tracking-widest text-gray-500 hover:text-gray-900 dark:hover:text-white transition-colors",children:E("cancel")})]})}),Ee&&u.jsx("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/60 backdrop-blur-sm p-6",onClick:()=>be(!1),children:u.jsxs(Ve,{className:"w-full max-w-lg p-8 animate-in zoom-in-95 flex flex-col max-h-[90vh]",darkMode:g,onClick:p=>p.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between mb-8",children:[u.jsxs("h3",{className:"text-2xl font-black text-inherit flex items-center gap-3",children:[u.jsx(oh,{size:24,className:"text-primary-600"})," ",E("advancedFilters")]}),u.jsx("button",{onClick:()=>be(!1),className:"p-2 bg-gray-100 dark:bg-gray-800 rounded-full hover:scale-110 transition-all text-inherit",children:u.jsx(Di,{size:20})})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto space-y-8 pr-2 custom-scrollbar",children:[u.jsxs("div",{className:"space-y-4",children:[u.jsx("label",{className:"text-[10px] font-black uppercase opacity-40 tracking-widest ml-1 text-inherit",children:E("closet")}),u.jsx("div",{className:"flex flex-wrap gap-2",children:[E("all"),E("tops"),E("bottoms"),E("footwear"),E("coats"),E("accessories")].map(p=>u.jsx("button",{onClick:()=>dn(p),className:`px-5 py-3 rounded-xl font-black text-[10px] uppercase tracking-widest transition-all ${Ke===p?"bg-primary-600 text-white shadow-xl shadow-primary-600/30":g?"bg-gray-800 text-gray-400":"bg-gray-50 text-gray-500 shadow-sm border border-gray-100"} hover:scale-[1.02]`,children:p},p))})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsx("label",{className:"text-[10px] font-black uppercase opacity-40 tracking-widest ml-1 text-inherit",children:E("filterByColor")}),u.jsxs("select",{value:Ot,onChange:p=>Mt(p.target.value),className:`w-full p-4 rounded-2xl border-none outline-none focus:ring-2 focus:ring-primary-500 font-bold ${g?"bg-gray-800 text-white":"bg-gray-50"}`,children:[u.jsx("option",{value:"",children:E("all")}),Ns.map(p=>u.jsx("option",{value:p,children:p},p))]})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsx("label",{className:"text-[10px] font-black uppercase opacity-40 tracking-widest ml-1 text-inherit",children:E("favorites")}),u.jsxs("button",{onClick:()=>Ce(!re),className:`w-full p-4 rounded-2xl flex items-center justify-between font-bold transition-all border-2 ${re?"border-rose-500 bg-rose-50 text-rose-600 dark:bg-rose-900/20 dark:text-rose-400":`border-transparent ${g?"bg-gray-800 text-gray-400 hover:bg-gray-700":"bg-gray-50 text-gray-500 hover:bg-gray-100"}`}`,children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(ah,{size:20,fill:re?"currentColor":"none"}),u.jsx("span",{children:E("onlyFavorites")})]}),re&&u.jsx(Rn,{size:20})]})]})]}),u.jsxs("div",{className:"pt-8 flex gap-4 border-t mt-8 border-gray-100 dark:border-gray-800",children:[u.jsx("button",{onClick:()=>{dn("Todos"),Mt(""),se("any"),Ce(!1)},className:"flex-1 py-4 font-black uppercase text-[10px] tracking-widest text-gray-500 hover:text-gray-900 dark:hover:text-white transition-colors",children:E("clearAll")}),u.jsx("button",{onClick:()=>be(!1),className:"flex-1 py-4 bg-primary-600 text-white rounded-2xl font-black uppercase text-[10px] tracking-widest shadow-xl shadow-primary-600/30 hover:scale-105 transition-all",children:E("applyFilters")})]})]})}),kd&&u.jsx("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/60 backdrop-blur-sm p-6",onClick:()=>ws(!1),children:u.jsxs(Ve,{className:"w-full max-w-lg p-8 animate-in zoom-in-95",darkMode:g,onClick:p=>p.stopPropagation(),children:[u.jsx("h3",{className:"text-2xl font-black mb-8 text-center text-inherit",children:E("appLanguage")}),u.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[{id:"PT",flag:"🇵🇹",label:E("portuguese")},{id:"EN",flag:"🇬🇧",label:E("english")},{id:"ES",flag:"🇪🇸",label:E("spanish")},{id:"FR",flag:"🇫🇷",label:E("french")},{id:"DE",flag:"🇩🇪",label:E("german")}].map(p=>u.jsxs("button",{onClick:()=>Ie(p.id),className:`p-6 rounded-2xl flex flex-col items-center justify-center gap-4 transition-all ${tt===p.id?"bg-primary-600 text-white shadow-xl shadow-primary-600/30 scale-105":"bg-gray-50 text-gray-600 hover:bg-gray-100 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"}`,children:[u.jsx("span",{className:"text-4xl",children:p.flag}),u.jsx("span",{className:"font-black text-[10px] uppercase tracking-widest text-center",children:p.label})]},p.id))}),u.jsx("button",{onClick:()=>ws(!1),className:"w-full mt-8 py-4 uppercase font-black text-[10px] tracking-widest text-gray-500 hover:text-gray-900 dark:hover:text-white transition-colors",children:E("cancel")})]})}),Ll&&rt&&u.jsx("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-black/70 backdrop-blur-md p-6",onClick:()=>{Hn(!1),tn(null)},children:u.jsxs("div",{className:`w-full max-w-lg rounded-[2rem] shadow-2xl overflow-hidden animate-in zoom-in-95 duration-300 ${g?"bg-gray-900":"bg-white"}`,onClick:p=>p.stopPropagation(),children:[u.jsxs("div",{className:"relative p-8 pb-6",style:{background:"linear-gradient(135deg, hsl(var(--primary-600)), hsl(var(--primary-400)))"},children:[u.jsx("div",{className:"absolute inset-0 opacity-20",style:{backgroundImage:"radial-gradient(circle at 80% 20%, white 0%, transparent 60%)"}}),u.jsxs("div",{className:"relative z-10",children:[u.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[u.jsx("div",{className:"p-2 bg-white/20 rounded-xl backdrop-blur-sm",children:u.jsx(Gg,{size:20,className:"text-white"})}),u.jsx("span",{className:"text-white/80 font-black uppercase text-[10px] tracking-widest",children:E("sharedLookTitle")})]}),u.jsx("h2",{className:"text-3xl font-black text-white tracking-tight",children:rt.lookName}),u.jsxs("p",{className:"text-white/60 text-sm font-bold mt-1",children:[rt.items.length," peça",rt.items.length!==1?"s":""," • ",E("sharedBy")," ",((Yo=rt.ownerEmail)==null?void 0:Yo.split("@")[0])||E("someone")]})]})]}),u.jsxs("div",{className:`p-8 ${g?"bg-gray-900":"bg-white"}`,children:[u.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest opacity-40 mb-4",children:E("includedPieces")}),u.jsx("div",{className:"flex flex-wrap gap-3 mb-8",children:rt.items.map((p,C)=>u.jsxs("div",{className:"relative group/item",children:[u.jsx("div",{className:"w-20 h-20 rounded-2xl overflow-hidden border-2 border-gray-100 dark:border-gray-700 shadow-lg",children:u.jsx("img",{src:p.imageUrl,alt:p.name,className:"w-full h-full object-cover group-hover/item:scale-110 transition-transform duration-500"})}),u.jsx("div",{className:"absolute -bottom-1 left-1/2 -translate-x-1/2 bg-gray-900/90 text-white text-[8px] font-black uppercase tracking-wide px-2 py-0.5 rounded-full whitespace-nowrap opacity-0 group-hover/item:opacity-100 transition-opacity",children:p.name})]},C))}),u.jsx("div",{className:"space-y-2 mb-8 max-h-32 overflow-y-auto custom-scrollbar",children:rt.items.map((p,C)=>u.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 rounded-xl ${g?"bg-gray-800":"bg-gray-50"}`,children:[u.jsx("span",{className:"text-xs font-black truncate flex-1",children:p.name}),u.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest opacity-40 shrink-0",children:p.category})]},C))}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx("button",{onClick:()=>{Hn(!1),tn(null)},className:`flex-1 py-4 font-black uppercase text-[10px] tracking-widest rounded-2xl transition-all ${g?"bg-gray-800 text-gray-400 hover:bg-gray-700":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:"Ignorar"}),u.jsx("button",{onClick:ec,disabled:Vo,className:"flex-[2] py-4 font-black uppercase text-[10px] tracking-widest rounded-2xl text-white shadow-xl transition-all hover:scale-[1.02] active:scale-95 disabled:opacity-60 flex items-center justify-center gap-2",style:{background:"linear-gradient(135deg, hsl(var(--primary-600)), hsl(var(--primary-500)))"},children:Vo?u.jsxs(u.Fragment,{children:[u.jsx(qg,{size:16,className:"animate-spin"})," ",E("copying")]}):u.jsxs(u.Fragment,{children:[u.jsx(Rn,{size:16})," ",E("copyToMyCloset")]})})]})]})]})}),Bl&&u.jsx("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-black/70 backdrop-blur-md p-6",onClick:()=>xi(!1),children:u.jsxs("div",{className:`w-full max-w-lg rounded-[2rem] shadow-2xl overflow-hidden animate-in zoom-in-95 duration-300 ${g?"bg-gray-900":"bg-white"}`,onClick:p=>p.stopPropagation(),children:[u.jsxs("div",{className:"relative p-8 pb-6 bg-gradient-to-br from-primary-600 to-primary-400",children:[u.jsx("div",{className:"absolute inset-0 opacity-20",style:{backgroundImage:"radial-gradient(circle at 80% 20%, white 0%, transparent 60%)"}}),u.jsxs("div",{className:"relative z-10",children:[u.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[u.jsx("div",{className:"p-2 bg-white/20 rounded-xl backdrop-blur-sm",children:u.jsx(la,{size:20,className:"text-white"})}),u.jsx("span",{className:"text-white/80 font-black uppercase text-[10px] tracking-widest",children:E("dailyOutfit")})]}),u.jsx("h2",{className:"text-3xl font-black text-white tracking-tight",children:E("today")})]})]}),u.jsx("div",{className:`p-8 ${g?"bg-gray-900":"bg-white"} max-h-[60vh] overflow-y-auto custom-scrollbar`,children:bs.length>0?u.jsx("div",{className:"space-y-6",children:bs.map(p=>u.jsxs("div",{className:`p-4 rounded-2xl border-2 border-gray-100 dark:border-gray-800 ${g?"bg-gray-800/50":"bg-gray-50"}`,children:[u.jsxs("div",{className:"flex items-center justify-between mb-4",children:[u.jsx("h4",{className:"font-black text-lg text-inherit",children:p.name}),u.jsxs("span",{className:"text-[10px] font-black uppercase tracking-widest opacity-40",children:[p.items.length," ",E("piecesShort")]})]}),u.jsx("div",{className:"flex -space-x-4 overflow-x-auto custom-scrollbar pb-2",children:p.items.map(C=>{const M=o.find($=>$.id===C);return M?u.jsx("div",{className:"w-16 h-16 rounded-xl overflow-hidden border-2 border-white dark:border-gray-700 shrink-0 shadow-sm relative group",children:u.jsx("img",{src:M.imageUrl,className:"w-full h-full object-cover",alt:""})},C):null})})]},p.id))}):u.jsxs("div",{className:"py-12 flex flex-col items-center justify-center text-center opacity-50",children:[u.jsx(aa,{size:48,className:"mb-4 text-gray-400"}),u.jsx("p",{className:"font-black text-lg text-inherit",children:E("noOutfitPlanned")}),u.jsx("p",{className:"text-xs mt-2 uppercase tracking-widest",children:E("goToPlanning")})]})}),u.jsx("div",{className:`p-4 border-t ${g?"border-gray-800 bg-gray-900":"border-gray-100 bg-gray-50"}`,children:u.jsx("button",{onClick:()=>xi(!1),className:"w-full py-4 bg-gray-200 dark:bg-gray-800 hover:bg-gray-300 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300 rounded-2xl font-black uppercase text-[10px] tracking-widest transition-all",children:E("close")})})]})})]})}Eh.createRoot(document.getElementById("root")).render(u.jsx(oE.StrictMode,{children:u.jsx(C2,{})}));