&k());){var pe=v.callback;if(typeof pe=="function"){v.callback=null,T=v.priorityLevel;var S=pe(v.expirationTime<=$);if($=t.unstable_now(),typeof S=="function"){v.callback=S,H($),le=!0;break t}v===n(d)&&s(d),H($)}else s(d);v=n(d)}if(v!==null)le=!0;else{var Q=n(m);Q!==null&&ye(K,Q.startTime-$),le=!1}}break e}finally{v=null,T=se,E=!1}le=void 0}}finally{le?F():te=!1}}}var F;if(typeof B=="function")F=function(){B(j)};else if(typeof MessageChannel<"u"){var V=new MessageChannel,ue=V.port2;V.port1.onmessage=j,F=function(){ue.postMessage(null)}}else F=function(){L(j,0)};function ye($,le){M=L(function(){$(t.unstable_now())},le)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function($){$.callback=null},t.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<$?Math.floor(1e3/$):5},t.unstable_getCurrentPriorityLevel=function(){return T},t.unstable_next=function($){switch(T){case 1:case 2:case 3:var le=3;break;default:le=T}var se=T;T=le;try{return $()}finally{T=se}},t.unstable_requestPaint=function(){N=!0},t.unstable_runWithPriority=function($,le){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var se=T;T=$;try{return le()}finally{T=se}},t.unstable_scheduleCallback=function($,le,se){var pe=t.unstable_now();switch(typeof se=="object"&&se!==null?(se=se.delay,se=typeof se=="number"&&0pe?($.sortIndex=se,e(m,$),n(d)===null&&$===n(m)&&(P?(z(M),M=-1):P=!0,ye(K,se-pe))):($.sortIndex=S,e(d,$),R||E||(R=!0,te||(te=!0,F()))),$},t.unstable_shouldYield=k,t.unstable_wrapCallback=function($){var le=T;return function(){var se=T;T=le;try{return $.apply(this,arguments)}finally{T=se}}}})(ey)),ey}var ox;function eO(){return ox||(ox=1,Jg.exports=JD()),Jg.exports}var ty={exports:{}},Me={};var ax;function tO(){if(ax)return Me;ax=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.iterator;function T(S){return S===null||typeof S!="object"?null:(S=v&&S[v]||S["@@iterator"],typeof S=="function"?S:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},R=Object.assign,P={};function N(S,Q,ce){this.props=S,this.context=Q,this.refs=P,this.updater=ce||E}N.prototype.isReactComponent={},N.prototype.setState=function(S,Q){if(typeof S!="object"&&typeof S!="function"&&S!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,S,Q,"setState")},N.prototype.forceUpdate=function(S){this.updater.enqueueForceUpdate(this,S,"forceUpdate")};function L(){}L.prototype=N.prototype;function z(S,Q,ce){this.props=S,this.context=Q,this.refs=P,this.updater=ce||E}var B=z.prototype=new L;B.constructor=z,R(B,N.prototype),B.isPureReactComponent=!0;var H=Array.isArray,K={H:null,A:null,T:null,S:null,V:null},te=Object.prototype.hasOwnProperty;function M(S,Q,ce,fe,de,Ee){return ce=Ee.ref,{$typeof:t,type:S,key:Q,ref:ce!==void 0?ce:null,props:Ee}}function A(S,Q){return M(S.type,Q,void 0,void 0,void 0,S.props)}function O(S){return typeof S=="object"&&S!==null&&S.$typeof===t}function k(S){var Q={"=":"=0",":":"=2"};return"$"+S.replace(/[=:]/g,function(ce){return Q[ce]})}var j=/\/+/g;function F(S,Q){return typeof S=="object"&&S!==null&&S.key!=null?k(""+S.key):Q.toString(36)}function V(){}function ue(S){switch(S.status){case"fulfilled":return S.value;case"rejected":throw S.reason;default:switch(typeof S.status=="string"?S.then(V,V):(S.status="pending",S.then(function(Q){S.status==="pending"&&(S.status="fulfilled",S.value=Q)},function(Q){S.status==="pending"&&(S.status="rejected",S.reason=Q)})),S.status){case"fulfilled":return S.value;case"rejected":throw S.reason}}throw S}function ye(S,Q,ce,fe,de){var Ee=typeof S;(Ee==="undefined"||Ee==="boolean")&&(S=null);var ve=!1;if(S===null)ve=!0;else switch(Ee){case"bigint":case"string":case"number":ve=!0;break;case"object":switch(S.$typeof){case t:case e:ve=!0;break;case g:return ve=S._init,ye(ve(S._payload),Q,ce,fe,de)}}if(ve)return de=de(S),ve=fe===""?"."+F(S,0):fe,H(de)?(ce="",ve!=null&&(ce=ve.replace(j,"/")+"/"),ye(de,Q,ce,"",function(Ke){return Ke})):de!=null&&(O(de)&&(de=A(de,ce+(de.key==null||S&&S.key===de.key?"":(""+de.key).replace(j,"/")+"/")+ve)),Q.push(de)),1;ve=0;var et=fe===""?".":fe+":";if(H(S))for(var qe=0;qe"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),ny.exports=nO(),ny.exports}var fx;function sO(){if(fx)return tu;fx=1;var t=eO(),e=am(),n=e1();function s(i){var r="https://react.dev/errors/"+i;if(1S||(i.current=pe[S],pe[S]=null,S--)}function fe(i,r){S++,pe[S]=i.current,i.current=r}var de=Q(null),Ee=Q(null),ve=Q(null),et=Q(null);function qe(i,r){switch(fe(ve,r),fe(Ee,i),fe(de,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?Pw(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=Pw(r),i=Dw(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}ce(de),fe(de,i)}function Ke(){ce(de),ce(Ee),ce(ve)}function Vs(i){i.memoizedState!==null&&fe(et,i);var r=de.current,a=Dw(r,i.type);r!==a&&(fe(Ee,i),fe(de,a))}function Pn(i){Ee.current===i&&(ce(de),ce(Ee)),et.current===i&&(ce(et),Yc._currentValue=se)}var Dn=Object.prototype.hasOwnProperty,on=t.unstable_scheduleCallback,hs=t.unstable_cancelCallback,Zm=t.unstable_shouldYield,Yl=t.unstable_requestPaint,Sn=t.unstable_now,vf=t.unstable_getCurrentPriorityLevel,kt=t.unstable_ImmediatePriority,qt=t.unstable_UserBlockingPriority,fi=t.unstable_NormalPriority,Jm=t.unstable_LowPriority,Wl=t.unstable_IdlePriority,ep=t.log,fo=t.unstable_setDisableYieldValue,Qi=null,an=null;function Kn(i){if(typeof ep=="function"&&fo(i),an&&typeof an.setStrictMode=="function")try{an.setStrictMode(Qi,i)}catch{}}var gn=Math.clz32?Math.clz32:_f,tp=Math.log,bf=Math.LN2;function _f(i){return i>>>=0,i===0?32:31-(tp(i)/bf|0)|0}var js=256,Yi=4194304;function ds(i){var r=i&42;if(r!==0)return r;switch(i&-i){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:return 64;case 128:return 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 i&4194048;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Qn(i,r,a){var u=i.pendingLanes;if(u===0)return 0;var p=0,y=i.suspendedLanes,x=i.pingedLanes;i=i.warmLanes;var C=u&134217727;return C!==0?(u=C&~y,u!==0?p=ds(u):(x&=C,x!==0?p=ds(x):a||(a=C&~i,a!==0&&(p=ds(a))))):(C=u&~y,C!==0?p=ds(C):x!==0?p=ds(x):a||(a=u&~i,a!==0&&(p=ds(a)))),p===0?0:r!==0&&r!==p&&(r&y)===0&&(y=p&-p,a=r&-r,y>=a||y===32&&(a&4194048)!==0)?r:p}function Wi(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function Ta(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32: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 r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Xl(){var i=js;return js<<=1,(js&4194048)===0&&(js=256),i}function Xi(){var i=Yi;return Yi<<=1,(Yi&62914560)===0&&(Yi=4194304),i}function wa(i){for(var r=[],a=0;31>a;a++)r.push(i);return r}function _t(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Tf(i,r,a,u,p,y){var x=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var C=i.entanglements,U=i.expirationTimes,X=i.hiddenUpdates;for(a=x&~a;0)":-1p||U[u]!==X[p]){var ne=` `+U[u].replace(" at new "," at ");return i.displayName&&ne.includes("")&&(ne=ne.replace("",i.displayName)),ne}while(1<=u&&0<=p);break}}}finally{Aa=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?mi(a):""}function rp(i){switch(i.tag){case 26:case 27:case 5:return mi(i.type);case 16:return mi("Lazy");case 13:return mi("Suspense");case 19:return mi("SuspenseList");case 0:case 15:return Ra(i.type,!1);case 11:return Ra(i.type.render,!1);case 1:return Ra(i.type,!0);case 31:return mi("Activity");default:return""}}function ps(i){try{var r="";do r+=rp(i),i=i.return;while(i);return r}catch(a){return` Error generating stack: `+a.message+` `+a.stack}}function pt(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function sr(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function _o(i){var r=sr(i)?"checked":"value",a=Object.getOwnPropertyDescriptor(i.constructor.prototype,r),u=""+i[r];if(!i.hasOwnProperty(r)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var p=a.get,y=a.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return p.call(this)},set:function(x){u=""+x,y.call(this,x)}}),Object.defineProperty(i,r,{enumerable:a.enumerable}),{getValue:function(){return u},setValue:function(x){u=""+x},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function ir(i){i._valueTracker||(i._valueTracker=_o(i))}function tt(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var a=r.getValue(),u="";return i&&(u=sr(i)?i.checked?"true":"false":i.value),i=u,i!==a?(r.setValue(i),!0):!1}function pi(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var To=/[\n"\\]/g;function Ht(i){return i.replace(To,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function ec(i,r,a,u,p,y,x,C){i.name="",x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"?i.type=x:i.removeAttribute("type"),r!=null?x==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+pt(r)):i.value!==""+pt(r)&&(i.value=""+pt(r)):x!=="submit"&&x!=="reset"||i.removeAttribute("value"),r!=null?nc(i,x,pt(r)):a!=null?nc(i,x,pt(a)):u!=null&&i.removeAttribute("value"),p==null&&y!=null&&(i.defaultChecked=!!y),p!=null&&(i.checked=p&&typeof p!="function"&&typeof p!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?i.name=""+pt(C):i.removeAttribute("name")}function tc(i,r,a,u,p,y,x,C){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),r!=null||a!=null){if(!(y!=="submit"&&y!=="reset"||r!=null))return;a=a!=null?""+pt(a):"",r=r!=null?""+pt(r):a,C||r===i.value||(i.value=r),i.defaultValue=r}u=u??p,u=typeof u!="function"&&typeof u!="symbol"&&!!u,i.checked=C?i.checked:!!u,i.defaultChecked=!!u,x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(i.name=x)}function nc(i,r,a){r==="number"&&pi(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function rr(i,r,a,u){if(i=i.options,r){r={};for(var p=0;p"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),yi=!1;if(vn)try{var lr={};Object.defineProperty(lr,"passive",{get:function(){yi=!0}}),window.addEventListener("test",lr,lr),window.removeEventListener("test",lr,lr)}catch{yi=!1}var Xn=null,at=null,Ia=null;function Cf(){if(Ia)return Ia;var i,r=at,a=r.length,u,p="value"in Xn?Xn.value:Xn.textContent,y=p.length;for(i=0;i=ut),On=" ",Gs=!1;function ys(i,r){switch(i){case"keyup":return he.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function vs(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var bs=!1;function hc(i,r){switch(i){case"compositionend":return vs(r);case"keypress":return r.which!==32?null:(Gs=!0,On);case"textInput":return i=r.data,i===On&&Gs?null:i;default:return null}}function xP(i,r){if(bs)return i==="compositionend"||!De&&ys(i,r)?(i=Cf(),Ia=at=Xn=null,bs=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:a,offset:r-i};i=u}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Z0(a)}}function e_(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?e_(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function t_(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=pi(i.document);r instanceof i.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)i=r.contentWindow;else break;r=pi(i.document)}return r}function cp(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var PP=vn&&"documentMode"in document&&11>=document.documentMode,ka=null,up=null,gc=null,fp=!1;function n_(i,r,a){var u=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;fp||ka==null||ka!==pi(u)||(u=ka,"selectionStart"in u&&cp(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),gc&&pc(gc,u)||(gc=u,u=wh(up,"onSelect"),0>=x,p-=x,_i=1<<32-gn(r)+p|a<y?y:8;var x=$.T,C={};$.T=C,Wp(i,!1,r,a);try{var U=p(),X=$.S;if(X!==null&&X(C,U),U!==null&&typeof U=="object"&&typeof U.then=="function"){var ne=zP(U,u);Pc(i,r,ne,Un(i))}else Pc(i,r,u,Un(i))}catch(oe){Pc(i,r,{then:function(){},status:"rejected",reason:oe},Un())}finally{le.p=y,$.T=x}}function GP(){}function Qp(i,r,a,u){if(i.tag!==5)throw Error(s(476));var p=sT(i).queue;nT(i,p,r,se,a===null?GP:function(){return iT(i),a(u)})}function sT(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:se,baseState:se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ei,lastRenderedState:se},next:null};var a={};return r.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ei,lastRenderedState:a},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function iT(i){var r=sT(i).next.queue;Pc(i,r,{},Un())}function Yp(){return cn(Yc)}function rT(){return It().memoizedState}function oT(){return It().memoizedState}function $P(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var a=Un();i=hr(a);var u=dr(r,i,a);u!==null&&(zn(u,r,a),Sc(u,r,a)),r={cache:Sp()},i.payload=r;return}r=r.return}}function KP(i,r,a){var u=Un();a={lane:u,revertLane:0,action:a,hasEagerState:!1,eagerState:null,next:null},nh(i)?lT(r,a):(a=pp(i,r,a,u),a!==null&&(zn(a,i,u),cT(a,r,u)))}function aT(i,r,a){var u=Un();Pc(i,r,a,u)}function Pc(i,r,a,u){var p={lane:u,revertLane:0,action:a,hasEagerState:!1,eagerState:null,next:null};if(nh(i))lT(r,p);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=r.lastRenderedReducer,y!==null))try{var x=r.lastRenderedState,C=y(x,a);if(p.hasEagerState=!0,p.eagerState=C,Mn(C,x))return Uf(i,r,p,0),lt===null&&Lf(),!1}catch{}if(a=pp(i,r,p,u),a!==null)return zn(a,i,u),cT(a,r,u),!0}return!1}function Wp(i,r,a,u){if(u={lane:2,revertLane:Cg(),action:u,hasEagerState:!1,eagerState:null,next:null},nh(i)){if(r)throw Error(s(479))}else r=pp(i,a,u,2),r!==null&&zn(r,i,2)}function nh(i){var r=i.alternate;return i===ke||r!==null&&r===ke}function lT(i,r){Ga=Wf=!0;var a=i.pending;a===null?r.next=r:(r.next=a.next,a.next=r),i.pending=r}function cT(i,r,a){if((a&4194048)!==0){var u=r.lanes;u&=i.pendingLanes,a|=u,r.lanes=a,Ji(i,a)}}var sh={readContext:cn,use:Zf,useCallback:Et,useContext:Et,useEffect:Et,useImperativeHandle:Et,useLayoutEffect:Et,useInsertionEffect:Et,useMemo:Et,useReducer:Et,useRef:Et,useState:Et,useDebugValue:Et,useDeferredValue:Et,useTransition:Et,useSyncExternalStore:Et,useId:Et,useHostTransitionStatus:Et,useFormState:Et,useActionState:Et,useOptimistic:Et,useMemoCache:Et,useCacheRefresh:Et},uT={readContext:cn,use:Zf,useCallback:function(i,r){return An().memoizedState=[i,r===void 0?null:r],i},useContext:cn,useEffect:K_,useImperativeHandle:function(i,r,a){a=a!=null?a.concat([i]):null,th(4194308,4,X_.bind(null,r,i),a)},useLayoutEffect:function(i,r){return th(4194308,4,i,r)},useInsertionEffect:function(i,r){th(4,2,i,r)},useMemo:function(i,r){var a=An();r=r===void 0?null:r;var u=i();if(qo){Kn(!0);try{i()}finally{Kn(!1)}}return a.memoizedState=[u,r],u},useReducer:function(i,r,a){var u=An();if(a!==void 0){var p=a(r);if(qo){Kn(!0);try{a(r)}finally{Kn(!1)}}}else p=r;return u.memoizedState=u.baseState=p,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:p},u.queue=i,i=i.dispatch=KP.bind(null,ke,i),[u.memoizedState,i]},useRef:function(i){var r=An();return i={current:i},r.memoizedState=i},useState:function(i){i=Hp(i);var r=i.queue,a=aT.bind(null,ke,r);return r.dispatch=a,[i.memoizedState,a]},useDebugValue:$p,useDeferredValue:function(i,r){var a=An();return Kp(a,i,r)},useTransition:function(){var i=Hp(!1);return i=nT.bind(null,ke,i.queue,!0,!1),An().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,a){var u=ke,p=An();if(Ye){if(a===void 0)throw Error(s(407));a=a()}else{if(a=r(),lt===null)throw Error(s(349));(He&124)!==0||P_(u,r,a)}p.memoizedState=a;var y={value:a,getSnapshot:r};return p.queue=y,K_(O_.bind(null,u,y,i),[i]),u.flags|=2048,Ka(9,eh(),D_.bind(null,u,y,a,r),null),a},useId:function(){var i=An(),r=lt.identifierPrefix;if(Ye){var a=Ti,u=_i;a=(u&~(1<<32-gn(u)-1)).toString(32)+a,r="«"+r+"R"+a,a=Xf++,0Re?(Kt=xe,xe=null):Kt=xe.sibling;var Qe=Z(G,xe,Y[Re],ie);if(Qe===null){xe===null&&(xe=Kt);break}i&&xe&&Qe.alternate===null&&r(G,xe),q=y(Qe,q,Re),je===null?be=Qe:je.sibling=Qe,je=Qe,xe=Kt}if(Re===Y.length)return a(G,xe),Ye&&jo(G,Re),be;if(xe===null){for(;ReRe?(Kt=xe,xe=null):Kt=xe.sibling;var Nr=Z(G,xe,Qe.value,ie);if(Nr===null){xe===null&&(xe=Kt);break}i&&xe&&Nr.alternate===null&&r(G,xe),q=y(Nr,q,Re),je===null?be=Nr:je.sibling=Nr,je=Nr,xe=Kt}if(Qe.done)return a(G,xe),Ye&&jo(G,Re),be;if(xe===null){for(;!Qe.done;Re++,Qe=Y.next())Qe=oe(G,Qe.value,ie),Qe!==null&&(q=y(Qe,q,Re),je===null?be=Qe:je.sibling=Qe,je=Qe);return Ye&&jo(G,Re),be}for(xe=u(xe);!Qe.done;Re++,Qe=Y.next())Qe=J(xe,G,Re,Qe.value,ie),Qe!==null&&(i&&Qe.alternate!==null&&xe.delete(Qe.key===null?Re:Qe.key),q=y(Qe,q,Re),je===null?be=Qe:je.sibling=Qe,je=Qe);return i&&xe.forEach(function(YD){return r(G,YD)}),Ye&&jo(G,Re),be}function it(G,q,Y,ie){if(typeof Y=="object"&&Y!==null&&Y.type===R&&Y.key===null&&(Y=Y.props.children),typeof Y=="object"&&Y!==null){switch(Y.$typeof){case T:e:{for(var be=Y.key;q!==null;){if(q.key===be){if(be=Y.type,be===R){if(q.tag===7){a(G,q.sibling),ie=p(q,Y.props.children),ie.return=G,G=ie;break e}}else if(q.elementType===be||typeof be=="object"&&be!==null&&be.$typeof===A&&hT(be)===q.type){a(G,q.sibling),ie=p(q,Y.props),Oc(ie,Y),ie.return=G,G=ie;break e}a(G,q);break}else r(G,q);q=q.sibling}Y.type===R?(ie=ko(Y.props.children,G.mode,ie,Y.key),ie.return=G,G=ie):(ie=Bf(Y.type,Y.key,Y.props,null,G.mode,ie),Oc(ie,Y),ie.return=G,G=ie)}return x(G);case E:e:{for(be=Y.key;q!==null;){if(q.key===be)if(q.tag===4&&q.stateNode.containerInfo===Y.containerInfo&&q.stateNode.implementation===Y.implementation){a(G,q.sibling),ie=p(q,Y.children||[]),ie.return=G,G=ie;break e}else{a(G,q);break}else r(G,q);q=q.sibling}ie=vp(Y,G.mode,ie),ie.return=G,G=ie}return x(G);case A:return be=Y._init,Y=be(Y._payload),it(G,q,Y,ie)}if(ye(Y))return Ne(G,q,Y,ie);if(F(Y)){if(be=F(Y),typeof be!="function")throw Error(s(150));return Y=be.call(Y),Ae(G,q,Y,ie)}if(typeof Y.then=="function")return it(G,q,ih(Y),ie);if(Y.$typeof===B)return it(G,q,Gf(G,Y),ie);rh(G,Y)}return typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint"?(Y=""+Y,q!==null&&q.tag===6?(a(G,q.sibling),ie=p(q,Y),ie.return=G,G=ie):(a(G,q),ie=yp(Y,G.mode,ie),ie.return=G,G=ie),x(G)):a(G,q)}return function(G,q,Y,ie){try{Dc=0;var be=it(G,q,Y,ie);return Qa=null,be}catch(xe){if(xe===xc||xe===Kf)throw xe;var je=kn(29,xe,null,G.mode);return je.lanes=ie,je.return=G,je}}}var Ya=dT(!0),mT=dT(!1),ns=Q(null),Ks=null;function pr(i){var r=i.alternate;fe(Lt,Lt.current&1),fe(ns,i),Ks===null&&(r===null||Ha.current!==null||r.memoizedState!==null)&&(Ks=i)}function pT(i){if(i.tag===22){if(fe(Lt,Lt.current),fe(ns,i),Ks===null){var r=i.alternate;r!==null&&r.memoizedState!==null&&(Ks=i)}}else gr()}function gr(){fe(Lt,Lt.current),fe(ns,ns.current)}function Si(i){ce(ns),Ks===i&&(Ks=null),ce(Lt)}var Lt=Q(0);function oh(i){for(var r=i;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||zg(a)))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}function Xp(i,r,a,u){r=i.memoizedState,a=a(u,r),a=a==null?r:g({},r,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Zp={enqueueSetState:function(i,r,a){i=i._reactInternals;var u=Un(),p=hr(u);p.payload=r,a!=null&&(p.callback=a),r=dr(i,p,u),r!==null&&(zn(r,i,u),Sc(r,i,u))},enqueueReplaceState:function(i,r,a){i=i._reactInternals;var u=Un(),p=hr(u);p.tag=1,p.payload=r,a!=null&&(p.callback=a),r=dr(i,p,u),r!==null&&(zn(r,i,u),Sc(r,i,u))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var a=Un(),u=hr(a);u.tag=2,r!=null&&(u.callback=r),r=dr(i,u,a),r!==null&&(zn(r,i,a),Sc(r,i,a))}};function gT(i,r,a,u,p,y,x){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(u,y,x):r.prototype&&r.prototype.isPureReactComponent?!pc(a,u)||!pc(p,y):!0}function yT(i,r,a,u){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,u),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,u),r.state!==i&&Zp.enqueueReplaceState(r,r.state,null)}function Ho(i,r){var a=r;if("ref"in r){a={};for(var u in r)u!=="ref"&&(a[u]=r[u])}if(i=i.defaultProps){a===r&&(a=g({},a));for(var p in i)a[p]===void 0&&(a[p]=i[p])}return a}var ah=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)};function vT(i){ah(i)}function bT(i){console.error(i)}function _T(i){ah(i)}function lh(i,r){try{var a=i.onUncaughtError;a(r.value,{componentStack:r.stack})}catch(u){setTimeout(function(){throw u})}}function TT(i,r,a){try{var u=i.onCaughtError;u(a.value,{componentStack:a.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(p){setTimeout(function(){throw p})}}function Jp(i,r,a){return a=hr(a),a.tag=3,a.payload={element:null},a.callback=function(){lh(i,r)},a}function wT(i){return i=hr(i),i.tag=3,i}function xT(i,r,a,u){var p=a.type.getDerivedStateFromError;if(typeof p=="function"){var y=u.value;i.payload=function(){return p(y)},i.callback=function(){TT(r,a,u)}}var x=a.stateNode;x!==null&&typeof x.componentDidCatch=="function"&&(i.callback=function(){TT(r,a,u),typeof p!="function"&&(wr===null?wr=new Set([this]):wr.add(this));var C=u.stack;this.componentDidCatch(u.value,{componentStack:C!==null?C:""})})}function YP(i,r,a,u,p){if(a.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(r=a.alternate,r!==null&&_c(r,a,p,!0),a=ns.current,a!==null){switch(a.tag){case 13:return Ks===null?xg():a.alternate===null&&vt===0&&(vt=3),a.flags&=-257,a.flags|=65536,a.lanes=p,u===Cp?a.flags|=16384:(r=a.updateQueue,r===null?a.updateQueue=new Set([u]):r.add(u),Sg(i,u,p)),!1;case 22:return a.flags|=65536,u===Cp?a.flags|=16384:(r=a.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([u])},a.updateQueue=r):(a=r.retryQueue,a===null?r.retryQueue=new Set([u]):a.add(u)),Sg(i,u,p)),!1}throw Error(s(435,a.tag))}return Sg(i,u,p),xg(),!1}if(Ye)return r=ns.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=p,u!==Tp&&(i=Error(s(422),{cause:u}),bc(Zn(i,a)))):(u!==Tp&&(r=Error(s(423),{cause:u}),bc(Zn(r,a))),i=i.current.alternate,i.flags|=65536,p&=-p,i.lanes|=p,u=Zn(u,a),p=Jp(i.stateNode,u,p),Pp(i,p),vt!==4&&(vt=2)),!1;var y=Error(s(520),{cause:u});if(y=Zn(y,a),zc===null?zc=[y]:zc.push(y),vt!==4&&(vt=2),r===null)return!0;u=Zn(u,a),a=r;do{switch(a.tag){case 3:return a.flags|=65536,i=p&-p,a.lanes|=i,i=Jp(a.stateNode,u,i),Pp(a,i),!1;case 1:if(r=a.type,y=a.stateNode,(a.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(wr===null||!wr.has(y))))return a.flags|=65536,p&=-p,a.lanes|=p,p=wT(p),xT(p,i,a,u),Pp(a,p),!1}a=a.return}while(a!==null);return!1}var ET=Error(s(461)),Gt=!1;function Xt(i,r,a,u){r.child=i===null?mT(r,null,a,u):Ya(r,i.child,a,u)}function ST(i,r,a,u,p){a=a.render;var y=r.ref;if("ref"in u){var x={};for(var C in u)C!=="ref"&&(x[C]=u[C])}else x=u;return Bo(r),u=Vp(i,r,a,x,y,p),C=jp(),i!==null&&!Gt?(Lp(i,r,p),Ai(i,r,p)):(Ye&&C&&bp(r),r.flags|=1,Xt(i,r,u,p),r.child)}function AT(i,r,a,u,p){if(i===null){var y=a.type;return typeof y=="function"&&!gp(y)&&y.defaultProps===void 0&&a.compare===null?(r.tag=15,r.type=y,RT(i,r,y,u,p)):(i=Bf(a.type,null,u,r,r.mode,p),i.ref=r.ref,i.return=r,r.child=i)}if(y=i.child,!ag(i,p)){var x=y.memoizedProps;if(a=a.compare,a=a!==null?a:pc,a(x,u)&&i.ref===r.ref)return Ai(i,r,p)}return r.flags|=1,i=bi(y,u),i.ref=r.ref,i.return=r,r.child=i}function RT(i,r,a,u,p){if(i!==null){var y=i.memoizedProps;if(pc(y,u)&&i.ref===r.ref)if(Gt=!1,r.pendingProps=u=y,ag(i,p))(i.flags&131072)!==0&&(Gt=!0);else return r.lanes=i.lanes,Ai(i,r,p)}return eg(i,r,a,u,p)}function CT(i,r,a){var u=r.pendingProps,p=u.children,y=i!==null?i.memoizedState:null;if(u.mode==="hidden"){if((r.flags&128)!==0){if(u=y!==null?y.baseLanes|a:a,i!==null){for(p=r.child=i.child,y=0;p!==null;)y=y|p.lanes|p.childLanes,p=p.sibling;r.childLanes=y&~u}else r.childLanes=0,r.child=null;return IT(i,r,u,a)}if((a&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},i!==null&&$f(r,y!==null?y.cachePool:null),y!==null?R_(r,y):Op(),pT(r);else return r.lanes=r.childLanes=536870912,IT(i,r,y!==null?y.baseLanes|a:a,a)}else y!==null?($f(r,y.cachePool),R_(r,y),gr(),r.memoizedState=null):(i!==null&&$f(r,null),Op(),gr());return Xt(i,r,p,a),r.child}function IT(i,r,a,u){var p=Rp();return p=p===null?null:{parent:jt._currentValue,pool:p},r.memoizedState={baseLanes:a,cachePool:p},i!==null&&$f(r,null),Op(),pT(r),i!==null&&_c(i,r,u,!0),null}function ch(i,r){var a=r.ref;if(a===null)i!==null&&i.ref!==null&&(r.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(s(284));(i===null||i.ref!==a)&&(r.flags|=4194816)}}function eg(i,r,a,u,p){return Bo(r),a=Vp(i,r,a,u,void 0,p),u=jp(),i!==null&&!Gt?(Lp(i,r,p),Ai(i,r,p)):(Ye&&u&&bp(r),r.flags|=1,Xt(i,r,a,p),r.child)}function NT(i,r,a,u,p,y){return Bo(r),r.updateQueue=null,a=I_(r,u,a,p),C_(i),u=jp(),i!==null&&!Gt?(Lp(i,r,y),Ai(i,r,y)):(Ye&&u&&bp(r),r.flags|=1,Xt(i,r,a,y),r.child)}function PT(i,r,a,u,p){if(Bo(r),r.stateNode===null){var y=Ua,x=a.contextType;typeof x=="object"&&x!==null&&(y=cn(x)),y=new a(u,y),r.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,y.updater=Zp,r.stateNode=y,y._reactInternals=r,y=r.stateNode,y.props=u,y.state=r.memoizedState,y.refs={},Ip(r),x=a.contextType,y.context=typeof x=="object"&&x!==null?cn(x):Ua,y.state=r.memoizedState,x=a.getDerivedStateFromProps,typeof x=="function"&&(Xp(r,a,x,u),y.state=r.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(x=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),x!==y.state&&Zp.enqueueReplaceState(y,y.state,null),Rc(r,u,y,p),Ac(),y.state=r.memoizedState),typeof y.componentDidMount=="function"&&(r.flags|=4194308),u=!0}else if(i===null){y=r.stateNode;var C=r.memoizedProps,U=Ho(a,C);y.props=U;var X=y.context,ne=a.contextType;x=Ua,typeof ne=="object"&&ne!==null&&(x=cn(ne));var oe=a.getDerivedStateFromProps;ne=typeof oe=="function"||typeof y.getSnapshotBeforeUpdate=="function",C=r.pendingProps!==C,ne||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(C||X!==x)&&yT(r,y,u,x),fr=!1;var Z=r.memoizedState;y.state=Z,Rc(r,u,y,p),Ac(),X=r.memoizedState,C||Z!==X||fr?(typeof oe=="function"&&(Xp(r,a,oe,u),X=r.memoizedState),(U=fr||gT(r,a,U,u,Z,X,x))?(ne||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(r.flags|=4194308)):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=u,r.memoizedState=X),y.props=u,y.state=X,y.context=x,u=U):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{y=r.stateNode,Np(i,r),x=r.memoizedProps,ne=Ho(a,x),y.props=ne,oe=r.pendingProps,Z=y.context,X=a.contextType,U=Ua,typeof X=="object"&&X!==null&&(U=cn(X)),C=a.getDerivedStateFromProps,(X=typeof C=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(x!==oe||Z!==U)&&yT(r,y,u,U),fr=!1,Z=r.memoizedState,y.state=Z,Rc(r,u,y,p),Ac();var J=r.memoizedState;x!==oe||Z!==J||fr||i!==null&&i.dependencies!==null&&Hf(i.dependencies)?(typeof C=="function"&&(Xp(r,a,C,u),J=r.memoizedState),(ne=fr||gT(r,a,ne,u,Z,J,U)||i!==null&&i.dependencies!==null&&Hf(i.dependencies))?(X||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(u,J,U),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(u,J,U)),typeof y.componentDidUpdate=="function"&&(r.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof y.componentDidUpdate!="function"||x===i.memoizedProps&&Z===i.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||x===i.memoizedProps&&Z===i.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=J),y.props=u,y.state=J,y.context=U,u=ne):(typeof y.componentDidUpdate!="function"||x===i.memoizedProps&&Z===i.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||x===i.memoizedProps&&Z===i.memoizedState||(r.flags|=1024),u=!1)}return y=u,ch(i,r),u=(r.flags&128)!==0,y||u?(y=r.stateNode,a=u&&typeof a.getDerivedStateFromError!="function"?null:y.render(),r.flags|=1,i!==null&&u?(r.child=Ya(r,i.child,null,p),r.child=Ya(r,null,a,p)):Xt(i,r,a,p),r.memoizedState=y.state,i=r.child):i=Ai(i,r,p),i}function DT(i,r,a,u){return vc(),r.flags|=256,Xt(i,r,a,u),r.child}var tg={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function ng(i){return{baseLanes:i,cachePool:b_()}}function sg(i,r,a){return i=i!==null?i.childLanes&~a:0,r&&(i|=ss),i}function OT(i,r,a){var u=r.pendingProps,p=!1,y=(r.flags&128)!==0,x;if((x=y)||(x=i!==null&&i.memoizedState===null?!1:(Lt.current&2)!==0),x&&(p=!0,r.flags&=-129),x=(r.flags&32)!==0,r.flags&=-33,i===null){if(Ye){if(p?pr(r):gr(),Ye){var C=yt,U;if(U=C){e:{for(U=C,C=$s;U.nodeType!==8;){if(!C){C=null;break e}if(U=ws(U.nextSibling),U===null){C=null;break e}}C=U}C!==null?(r.memoizedState={dehydrated:C,treeContext:Vo!==null?{id:_i,overflow:Ti}:null,retryLane:536870912,hydrationErrors:null},U=kn(18,null,null,0),U.stateNode=C,U.return=r,r.child=U,_n=r,yt=null,U=!0):U=!1}U||Uo(r)}if(C=r.memoizedState,C!==null&&(C=C.dehydrated,C!==null))return zg(C)?r.lanes=32:r.lanes=536870912,null;Si(r)}return C=u.children,u=u.fallback,p?(gr(),p=r.mode,C=uh({mode:"hidden",children:C},p),u=ko(u,p,a,null),C.return=r,u.return=r,C.sibling=u,r.child=C,p=r.child,p.memoizedState=ng(a),p.childLanes=sg(i,x,a),r.memoizedState=tg,u):(pr(r),ig(r,C))}if(U=i.memoizedState,U!==null&&(C=U.dehydrated,C!==null)){if(y)r.flags&256?(pr(r),r.flags&=-257,r=rg(i,r,a)):r.memoizedState!==null?(gr(),r.child=i.child,r.flags|=128,r=null):(gr(),p=u.fallback,C=r.mode,u=uh({mode:"visible",children:u.children},C),p=ko(p,C,a,null),p.flags|=2,u.return=r,p.return=r,u.sibling=p,r.child=u,Ya(r,i.child,null,a),u=r.child,u.memoizedState=ng(a),u.childLanes=sg(i,x,a),r.memoizedState=tg,r=p);else if(pr(r),zg(C)){if(x=C.nextSibling&&C.nextSibling.dataset,x)var X=x.dgst;x=X,u=Error(s(419)),u.stack="",u.digest=x,bc({value:u,source:null,stack:null}),r=rg(i,r,a)}else if(Gt||_c(i,r,a,!1),x=(a&i.childLanes)!==0,Gt||x){if(x=lt,x!==null&&(u=a&-a,u=(u&42)!==0?1:Zl(u),u=(u&(x.suspendedLanes|a))!==0?0:u,u!==0&&u!==U.retryLane))throw U.retryLane=u,La(i,u),zn(x,i,u),ET;C.data==="$?"||xg(),r=rg(i,r,a)}else C.data==="$?"?(r.flags|=192,r.child=i.child,r=null):(i=U.treeContext,yt=ws(C.nextSibling),_n=r,Ye=!0,Lo=null,$s=!1,i!==null&&(es[ts++]=_i,es[ts++]=Ti,es[ts++]=Vo,_i=i.id,Ti=i.overflow,Vo=r),r=ig(r,u.children),r.flags|=4096);return r}return p?(gr(),p=u.fallback,C=r.mode,U=i.child,X=U.sibling,u=bi(U,{mode:"hidden",children:u.children}),u.subtreeFlags=U.subtreeFlags&65011712,X!==null?p=bi(X,p):(p=ko(p,C,a,null),p.flags|=2),p.return=r,u.return=r,u.sibling=p,r.child=u,u=p,p=r.child,C=i.child.memoizedState,C===null?C=ng(a):(U=C.cachePool,U!==null?(X=jt._currentValue,U=U.parent!==X?{parent:X,pool:X}:U):U=b_(),C={baseLanes:C.baseLanes|a,cachePool:U}),p.memoizedState=C,p.childLanes=sg(i,x,a),r.memoizedState=tg,u):(pr(r),a=i.child,i=a.sibling,a=bi(a,{mode:"visible",children:u.children}),a.return=r,a.sibling=null,i!==null&&(x=r.deletions,x===null?(r.deletions=[i],r.flags|=16):x.push(i)),r.child=a,r.memoizedState=null,a)}function ig(i,r){return r=uh({mode:"visible",children:r},i.mode),r.return=i,i.child=r}function uh(i,r){return i=kn(22,i,null,r),i.lanes=0,i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null},i}function rg(i,r,a){return Ya(r,i.child,null,a),i=ig(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function MT(i,r,a){i.lanes|=r;var u=i.alternate;u!==null&&(u.lanes|=r),xp(i.return,r,a)}function og(i,r,a,u,p){var y=i.memoizedState;y===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:a,tailMode:p}:(y.isBackwards=r,y.rendering=null,y.renderingStartTime=0,y.last=u,y.tail=a,y.tailMode=p)}function kT(i,r,a){var u=r.pendingProps,p=u.revealOrder,y=u.tail;if(Xt(i,r,u.children,a),u=Lt.current,(u&2)!==0)u=u&1|2,r.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&MT(i,a,r);else if(i.tag===19)MT(i,a,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}u&=1}switch(fe(Lt,u),p){case"forwards":for(a=r.child,p=null;a!==null;)i=a.alternate,i!==null&&oh(i)===null&&(p=a),a=a.sibling;a=p,a===null?(p=r.child,r.child=null):(p=a.sibling,a.sibling=null),og(r,!1,p,a,y);break;case"backwards":for(a=null,p=r.child,r.child=null;p!==null;){if(i=p.alternate,i!==null&&oh(i)===null){r.child=p;break}i=p.sibling,p.sibling=a,a=p,p=i}og(r,!0,a,null,y);break;case"together":og(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function Ai(i,r,a){if(i!==null&&(r.dependencies=i.dependencies),Tr|=r.lanes,(a&r.childLanes)===0)if(i!==null){if(_c(i,r,a,!1),(a&r.childLanes)===0)return null}else return null;if(i!==null&&r.child!==i.child)throw Error(s(153));if(r.child!==null){for(i=r.child,a=bi(i,i.pendingProps),r.child=a,a.return=r;i.sibling!==null;)i=i.sibling,a=a.sibling=bi(i,i.pendingProps),a.return=r;a.sibling=null}return r.child}function ag(i,r){return(i.lanes&r)!==0?!0:(i=i.dependencies,!!(i!==null&&Hf(i)))}function WP(i,r,a){switch(r.tag){case 3:qe(r,r.stateNode.containerInfo),ur(r,jt,i.memoizedState.cache),vc();break;case 27:case 5:Vs(r);break;case 4:qe(r,r.stateNode.containerInfo);break;case 10:ur(r,r.type,r.memoizedProps.value);break;case 13:var u=r.memoizedState;if(u!==null)return u.dehydrated!==null?(pr(r),r.flags|=128,null):(a&r.child.childLanes)!==0?OT(i,r,a):(pr(r),i=Ai(i,r,a),i!==null?i.sibling:null);pr(r);break;case 19:var p=(i.flags&128)!==0;if(u=(a&r.childLanes)!==0,u||(_c(i,r,a,!1),u=(a&r.childLanes)!==0),p){if(u)return kT(i,r,a);r.flags|=128}if(p=r.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),fe(Lt,Lt.current),u)break;return null;case 22:case 23:return r.lanes=0,CT(i,r,a);case 24:ur(r,jt,i.memoizedState.cache)}return Ai(i,r,a)}function VT(i,r,a){if(i!==null)if(i.memoizedProps!==r.pendingProps)Gt=!0;else{if(!ag(i,a)&&(r.flags&128)===0)return Gt=!1,WP(i,r,a);Gt=(i.flags&131072)!==0}else Gt=!1,Ye&&(r.flags&1048576)!==0&&h_(r,qf,r.index);switch(r.lanes=0,r.tag){case 16:e:{i=r.pendingProps;var u=r.elementType,p=u._init;if(u=p(u._payload),r.type=u,typeof u=="function")gp(u)?(i=Ho(u,i),r.tag=1,r=PT(null,r,u,i,a)):(r.tag=0,r=eg(null,r,u,i,a));else{if(u!=null){if(p=u.$typeof,p===H){r.tag=11,r=ST(null,r,u,i,a);break e}else if(p===M){r.tag=14,r=AT(null,r,u,i,a);break e}}throw r=ue(u)||u,Error(s(306,r,""))}}return r;case 0:return eg(i,r,r.type,r.pendingProps,a);case 1:return u=r.type,p=Ho(u,r.pendingProps),PT(i,r,u,p,a);case 3:e:{if(qe(r,r.stateNode.containerInfo),i===null)throw Error(s(387));u=r.pendingProps;var y=r.memoizedState;p=y.element,Np(i,r),Rc(r,u,null,a);var x=r.memoizedState;if(u=x.cache,ur(r,jt,u),u!==y.cache&&Ep(r,[jt],a,!0),Ac(),u=x.element,y.isDehydrated)if(y={element:u,isDehydrated:!1,cache:x.cache},r.updateQueue.baseState=y,r.memoizedState=y,r.flags&256){r=DT(i,r,u,a);break e}else if(u!==p){p=Zn(Error(s(424)),r),bc(p),r=DT(i,r,u,a);break e}else for(i=r.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,yt=ws(i.firstChild),_n=r,Ye=!0,Lo=null,$s=!0,a=mT(r,null,u,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(vc(),u===p){r=Ai(i,r,a);break e}Xt(i,r,u,a)}r=r.child}return r;case 26:return ch(i,r),i===null?(a=zw(r.type,null,r.pendingProps,null))?r.memoizedState=a:Ye||(a=r.type,i=r.pendingProps,u=Eh(ve.current).createElement(a),u[Tt]=r,u[Wt]=i,Jt(u,a,i),wt(u),r.stateNode=u):r.memoizedState=zw(r.type,i.memoizedProps,r.pendingProps,i.memoizedState),null;case 27:return Vs(r),i===null&&Ye&&(u=r.stateNode=jw(r.type,r.pendingProps,ve.current),_n=r,$s=!0,p=yt,Sr(r.type)?(Bg=p,yt=ws(u.firstChild)):yt=p),Xt(i,r,r.pendingProps.children,a),ch(i,r),i===null&&(r.flags|=4194304),r.child;case 5:return i===null&&Ye&&((p=u=yt)&&(u=ED(u,r.type,r.pendingProps,$s),u!==null?(r.stateNode=u,_n=r,yt=ws(u.firstChild),$s=!1,p=!0):p=!1),p||Uo(r)),Vs(r),p=r.type,y=r.pendingProps,x=i!==null?i.memoizedProps:null,u=y.children,jg(p,y)?u=null:x!==null&&jg(p,x)&&(r.flags|=32),r.memoizedState!==null&&(p=Vp(i,r,FP,null,null,a),Yc._currentValue=p),ch(i,r),Xt(i,r,u,a),r.child;case 6:return i===null&&Ye&&((i=a=yt)&&(a=SD(a,r.pendingProps,$s),a!==null?(r.stateNode=a,_n=r,yt=null,i=!0):i=!1),i||Uo(r)),null;case 13:return OT(i,r,a);case 4:return qe(r,r.stateNode.containerInfo),u=r.pendingProps,i===null?r.child=Ya(r,null,u,a):Xt(i,r,u,a),r.child;case 11:return ST(i,r,r.type,r.pendingProps,a);case 7:return Xt(i,r,r.pendingProps,a),r.child;case 8:return Xt(i,r,r.pendingProps.children,a),r.child;case 12:return Xt(i,r,r.pendingProps.children,a),r.child;case 10:return u=r.pendingProps,ur(r,r.type,u.value),Xt(i,r,u.children,a),r.child;case 9:return p=r.type._context,u=r.pendingProps.children,Bo(r),p=cn(p),u=u(p),r.flags|=1,Xt(i,r,u,a),r.child;case 14:return AT(i,r,r.type,r.pendingProps,a);case 15:return RT(i,r,r.type,r.pendingProps,a);case 19:return kT(i,r,a);case 31:return u=r.pendingProps,a=r.mode,u={mode:u.mode,children:u.children},i===null?(a=uh(u,a),a.ref=r.ref,r.child=a,a.return=r,r=a):(a=bi(i.child,u),a.ref=r.ref,r.child=a,a.return=r,r=a),r;case 22:return CT(i,r,a);case 24:return Bo(r),u=cn(jt),i===null?(p=Rp(),p===null&&(p=lt,y=Sp(),p.pooledCache=y,y.refCount++,y!==null&&(p.pooledCacheLanes|=a),p=y),r.memoizedState={parent:u,cache:p},Ip(r),ur(r,jt,p)):((i.lanes&a)!==0&&(Np(i,r),Rc(r,null,null,a),Ac()),p=i.memoizedState,y=r.memoizedState,p.parent!==u?(p={parent:u,cache:u},r.memoizedState=p,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=p),ur(r,jt,u)):(u=y.cache,ur(r,jt,u),u!==p.cache&&Ep(r,[jt],a,!0))),Xt(i,r,r.pendingProps.children,a),r.child;case 29:throw r.pendingProps}throw Error(s(156,r.tag))}function Ri(i){i.flags|=4}function jT(i,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!Gw(r)){if(r=ns.current,r!==null&&((He&4194048)===He?Ks!==null:(He&62914560)!==He&&(He&536870912)===0||r!==Ks))throw Ec=Cp,__;i.flags|=8192}}function fh(i,r){r!==null&&(i.flags|=4),i.flags&16384&&(r=i.tag!==22?Xi():536870912,i.lanes|=r,Ja|=r)}function Mc(i,r){if(!Ye)switch(i.tailMode){case"hidden":r=i.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var u=null;a!==null;)a.alternate!==null&&(u=a),a=a.sibling;u===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:u.sibling=null}}function gt(i){var r=i.alternate!==null&&i.alternate.child===i.child,a=0,u=0;if(r)for(var p=i.child;p!==null;)a|=p.lanes|p.childLanes,u|=p.subtreeFlags&65011712,u|=p.flags&65011712,p.return=i,p=p.sibling;else for(p=i.child;p!==null;)a|=p.lanes|p.childLanes,u|=p.subtreeFlags,u|=p.flags,p.return=i,p=p.sibling;return i.subtreeFlags|=u,i.childLanes=a,r}function XP(i,r,a){var u=r.pendingProps;switch(_p(r),r.tag){case 31:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return gt(r),null;case 1:return gt(r),null;case 3:return a=r.stateNode,u=null,i!==null&&(u=i.memoizedState.cache),r.memoizedState.cache!==u&&(r.flags|=2048),xi(jt),Ke(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(yc(r)?Ri(r):i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,p_())),gt(r),null;case 26:return a=r.memoizedState,i===null?(Ri(r),a!==null?(gt(r),jT(r,a)):(gt(r),r.flags&=-16777217)):a?a!==i.memoizedState?(Ri(r),gt(r),jT(r,a)):(gt(r),r.flags&=-16777217):(i.memoizedProps!==u&&Ri(r),gt(r),r.flags&=-16777217),null;case 27:Pn(r),a=ve.current;var p=r.type;if(i!==null&&r.stateNode!=null)i.memoizedProps!==u&&Ri(r);else{if(!u){if(r.stateNode===null)throw Error(s(166));return gt(r),null}i=de.current,yc(r)?d_(r):(i=jw(p,u,a),r.stateNode=i,Ri(r))}return gt(r),null;case 5:if(Pn(r),a=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==u&&Ri(r);else{if(!u){if(r.stateNode===null)throw Error(s(166));return gt(r),null}if(i=de.current,yc(r))d_(r);else{switch(p=Eh(ve.current),i){case 1:i=p.createElementNS("http://www.w3.org/2000/svg",a);break;case 2:i=p.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;default:switch(a){case"svg":i=p.createElementNS("http://www.w3.org/2000/svg",a);break;case"math":i=p.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;case"script":i=p.createElement("div"),i.innerHTML="&{alignmentOffset:le}},reset:$}}}),c4=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,s;const{placement:o,middlewareData:l,rects:c,initialPlacement:f,platform:d,elements:m}=e,{mainAxis:g=!0,crossAxis:v=!0,fallbackPlacements:T,fallbackStrategy:E="bestFit",fallbackAxisSideDirection:R="none",flipAlignment:P=!0,...N}=Ui(t,e);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const L=zi(o),z=ei(f),B=zi(f)===f,H=await(d.isRTL==null?void 0:d.isRTL(m.floating)),K=T||(B||!P?[Ad(f)]:JV(f)),te=R!=="none";!T&&te&&K.push(...s4(f,P,R,H));const M=[f,...K],A=await d.detectOverflow(e,N),O=[];let k=((s=l.flip)==null?void 0:s.overflows)||[];if(g&&O.push(A[L]),v){const ue=ZV(o,c,H);O.push(A[ue[0]],A[ue[1]])}if(k=[...k,{placement:o,overflows:O}],!O.every(ue=>ue<=0)){var j,F;const ue=(((j=l.flip)==null?void 0:j.index)||0)+1,ye=M[ue];if(ye&&(!(v==="alignment"?z!==ei(ye):!1)||k.every(se=>ei(se.placement)===z?se.overflows[0]>0:!0)))return{data:{index:ue,overflows:k},reset:{placement:ye}};let $=(F=k.filter(le=>le.overflows[0]<=0).sort((le,se)=>le.overflows[1]-se.overflows[1])[0])==null?void 0:F.placement;if(!$)switch(E){case"bestFit":{var V;const le=(V=k.filter(se=>{if(te){const pe=ei(se.placement);return pe===z||pe==="y"}return!0}).map(se=>[se.placement,se.overflows.filter(pe=>pe>0).reduce((pe,S)=>pe+S,0)]).sort((se,pe)=>se[1]-pe[1])[0])==null?void 0:V[0];le&&($=le);break}case"initialPlacement":$=f;break}if(o!==$)return{reset:{placement:$}}}return{}}}};function Yx(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Wx(t){return WV.some(e=>t[e]>=0)}const u4=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:s}=e,{strategy:o="referenceHidden",...l}=Ui(t,e);switch(o){case"referenceHidden":{const c=await s.detectOverflow(e,{...l,elementContext:"reference"}),f=Yx(c,n.reference);return{data:{referenceHiddenOffsets:f,referenceHidden:Wx(f)}}}case"escaped":{const c=await s.detectOverflow(e,{...l,altBoundary:!0}),f=Yx(c,n.floating);return{data:{escapedOffsets:f,escaped:Wx(f)}}}default:return{}}}}},pR=new Set(["left","top"]);async function f4(t,e){const{placement:n,platform:s,elements:o}=t,l=await(s.isRTL==null?void 0:s.isRTL(o.floating)),c=zi(n),f=jl(n),d=ei(n)==="y",m=pR.has(c)?-1:1,g=l&&d?-1:1,v=Ui(e,t);let{mainAxis:T,crossAxis:E,alignmentAxis:R}=typeof v=="number"?{mainAxis:v,crossAxis:0,alignmentAxis:null}:{mainAxis:v.mainAxis||0,crossAxis:v.crossAxis||0,alignmentAxis:v.alignmentAxis};return f&&typeof R=="number"&&(E=f==="end"?R*-1:R),d?{x:E*g,y:T*m}:{x:T*m,y:E*g}}const h4=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,s;const{x:o,y:l,placement:c,middlewareData:f}=e,d=await f4(e,t);return c===((n=f.offset)==null?void 0:n.placement)&&(s=f.arrow)!=null&&s.alignmentOffset?{}:{x:o+d.x,y:l+d.y,data:{...d,placement:c}}}}},d4=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:s,placement:o,platform:l}=e,{mainAxis:c=!0,crossAxis:f=!1,limiter:d={fn:L=>{let{x:z,y:B}=L;return{x:z,y:B}}},...m}=Ui(t,e),g={x:n,y:s},v=await l.detectOverflow(e,m),T=ei(zi(o)),E=hb(T);let R=g[E],P=g[T];if(c){const L=E==="y"?"top":"left",z=E==="y"?"bottom":"right",B=R+v[L],H=R-v[z];R=Jy(B,R,H)}if(f){const L=T==="y"?"top":"left",z=T==="y"?"bottom":"right",B=P+v[L],H=P-v[z];P=Jy(B,P,H)}const N=d.fn({...e,[E]:R,[T]:P});return{...N,data:{x:N.x-n,y:N.y-s,enabled:{[E]:c,[T]:f}}}}}},m4=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:s,placement:o,rects:l,middlewareData:c}=e,{offset:f=0,mainAxis:d=!0,crossAxis:m=!0}=Ui(t,e),g={x:n,y:s},v=ei(o),T=hb(v);let E=g[T],R=g[v];const P=Ui(f,e),N=typeof P=="number"?{mainAxis:P,crossAxis:0}:{mainAxis:0,crossAxis:0,...P};if(d){const B=T==="y"?"height":"width",H=l.reference[T]-l.floating[B]+N.mainAxis,K=l.reference[T]+l.reference[B]-N.mainAxis;EK&&(E=K)}if(m){var L,z;const B=T==="y"?"width":"height",H=pR.has(zi(o)),K=l.reference[v]-l.floating[B]+(H&&((L=c.offset)==null?void 0:L[v])||0)+(H?0:N.crossAxis),te=l.reference[v]+l.reference[B]+(H?0:((z=c.offset)==null?void 0:z[v])||0)-(H?N.crossAxis:0);Rte&&(R=te)}return{[T]:E,[v]:R}}}},p4=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,s;const{placement:o,rects:l,platform:c,elements:f}=e,{apply:d=()=>{},...m}=Ui(t,e),g=await c.detectOverflow(e,m),v=zi(o),T=jl(o),E=ei(o)==="y",{width:R,height:P}=l.floating;let N,L;v==="top"||v==="bottom"?(N=v,L=T===(await(c.isRTL==null?void 0:c.isRTL(f.floating))?"start":"end")?"left":"right"):(L=v,N=T==="end"?"top":"bottom");const z=P-g.top-g.bottom,B=R-g.left-g.right,H=Kr(P-g[N],z),K=Kr(R-g[L],B),te=!e.middlewareData.shift;let M=H,A=K;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(A=B),(s=e.middlewareData.shift)!=null&&s.enabled.y&&(M=z),te&&!T){const k=Bn(g.left,0),j=Bn(g.right,0),F=Bn(g.top,0),V=Bn(g.bottom,0);E?A=R-2*(k!==0||j!==0?k+j:Bn(g.left,g.right)):M=P-2*(F!==0||V!==0?F+V:Bn(g.top,g.bottom))}await d({...e,availableWidth:A,availableHeight:M});const O=await c.getDimensions(f.floating);return R!==O.width||P!==O.height?{reset:{rects:!0}}:{}}}};function ym(){return typeof window<"u"}function Ll(t){return gR(t)?(t.nodeName||"").toLowerCase():"#document"}function Hn(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ui(t){var e;return(e=(gR(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function gR(t){return ym()?t instanceof Node||t instanceof Hn(t).Node:!1}function Ds(t){return ym()?t instanceof Element||t instanceof Hn(t).Element:!1}function Gi(t){return ym()?t instanceof HTMLElement||t instanceof Hn(t).HTMLElement:!1}function Xx(t){return!ym()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Hn(t).ShadowRoot}function Wu(t){const{overflow:e,overflowX:n,overflowY:s,display:o}=Os(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+n)&&o!=="inline"&&o!=="contents"}function g4(t){return/^(table|td|th)$/.test(Ll(t))}function vm(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const y4=/transform|translate|scale|rotate|perspective|filter/,v4=/paint|layout|strict|content/,Yo=t=>!!t&&t!=="none";let cy;function pb(t){const e=Ds(t)?Os(t):t;return Yo(e.transform)||Yo(e.translate)||Yo(e.scale)||Yo(e.rotate)||Yo(e.perspective)||!gb()&&(Yo(e.backdropFilter)||Yo(e.filter))||y4.test(e.willChange||"")||v4.test(e.contain||"")}function b4(t){let e=Qr(t);for(;Gi(e)&&!Al(e);){if(pb(e))return e;if(vm(e))return null;e=Qr(e)}return null}function gb(){return cy==null&&(cy=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),cy}function Al(t){return/^(html|body|#document)$/.test(Ll(t))}function Os(t){return Hn(t).getComputedStyle(t)}function bm(t){return Ds(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Qr(t){if(Ll(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Xx(t)&&t.host||ui(t);return Xx(e)?e.host:e}function yR(t){const e=Qr(t);return Al(e)?t.ownerDocument?t.ownerDocument.body:t.body:Gi(e)&&Wu(e)?e:yR(e)}function Nu(t,e,n){var s;e===void 0&&(e=[]),n===void 0&&(n=!0);const o=yR(t),l=o===((s=t.ownerDocument)==null?void 0:s.body),c=Hn(o);if(l){const f=tv(c);return e.concat(c,c.visualViewport||[],Wu(o)?o:[],f&&n?Nu(f):[])}else return e.concat(o,Nu(o,[],n))}function tv(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function vR(t){const e=Os(t);let n=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const o=Gi(t),l=o?t.offsetWidth:n,c=o?t.offsetHeight:s,f=Sd(n)!==l||Sd(s)!==c;return f&&(n=l,s=c),{width:n,height:s,$:f}}function yb(t){return Ds(t)?t:t.contextElement}function yl(t){const e=yb(t);if(!Gi(e))return ti(1);const n=e.getBoundingClientRect(),{width:s,height:o,$:l}=vR(e);let c=(l?Sd(n.width):n.width)/s,f=(l?Sd(n.height):n.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!f||!Number.isFinite(f))&&(f=1),{x:c,y:f}}const _4=ti(0);function bR(t){const e=Hn(t);return!gb()||!e.visualViewport?_4:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function T4(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Hn(t)?!1:e}function la(t,e,n,s){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),l=yb(t);let c=ti(1);e&&(s?Ds(s)&&(c=yl(s)):c=yl(t));const f=T4(l,n,s)?bR(l):ti(0);let d=(o.left+f.x)/c.x,m=(o.top+f.y)/c.y,g=o.width/c.x,v=o.height/c.y;if(l){const T=Hn(l),E=s&&Ds(s)?Hn(s):s;let R=T,P=tv(R);for(;P&&s&&E!==R;){const N=yl(P),L=P.getBoundingClientRect(),z=Os(P),B=L.left+(P.clientLeft+parseFloat(z.paddingLeft))*N.x,H=L.top+(P.clientTop+parseFloat(z.paddingTop))*N.y;d*=N.x,m*=N.y,g*=N.x,v*=N.y,d+=B,m+=H,R=Hn(P),P=tv(R)}}return Rd({width:g,height:v,x:d,y:m})}function _m(t,e){const n=bm(t).scrollLeft;return e?e.left+n:la(ui(t)).left+n}function _R(t,e){const n=t.getBoundingClientRect(),s=n.left+e.scrollLeft-_m(t,n),o=n.top+e.scrollTop;return{x:s,y:o}}function w4(t){let{elements:e,rect:n,offsetParent:s,strategy:o}=t;const l=o==="fixed",c=ui(s),f=e?vm(e.floating):!1;if(s===c||f&&l)return n;let d={scrollLeft:0,scrollTop:0},m=ti(1);const g=ti(0),v=Gi(s);if((v||!v&&!l)&&((Ll(s)!=="body"||Wu(c))&&(d=bm(s)),v)){const E=la(s);m=yl(s),g.x=E.x+s.clientLeft,g.y=E.y+s.clientTop}const T=c&&!v&&!l?_R(c,d):ti(0);return{width:n.width*m.x,height:n.height*m.y,x:n.x*m.x-d.scrollLeft*m.x+g.x+T.x,y:n.y*m.y-d.scrollTop*m.y+g.y+T.y}}function x4(t){return Array.from(t.getClientRects())}function E4(t){const e=ui(t),n=bm(t),s=t.ownerDocument.body,o=Bn(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),l=Bn(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let c=-n.scrollLeft+_m(t);const f=-n.scrollTop;return Os(s).direction==="rtl"&&(c+=Bn(e.clientWidth,s.clientWidth)-o),{width:o,height:l,x:c,y:f}}const Zx=25;function S4(t,e){const n=Hn(t),s=ui(t),o=n.visualViewport;let l=s.clientWidth,c=s.clientHeight,f=0,d=0;if(o){l=o.width,c=o.height;const g=gb();(!g||g&&e==="fixed")&&(f=o.offsetLeft,d=o.offsetTop)}const m=_m(s);if(m<=0){const g=s.ownerDocument,v=g.body,T=getComputedStyle(v),E=g.compatMode==="CSS1Compat"&&parseFloat(T.marginLeft)+parseFloat(T.marginRight)||0,R=Math.abs(s.clientWidth-v.clientWidth-E);R<=Zx&&(l-=R)}else m<=Zx&&(l+=m);return{width:l,height:c,x:f,y:d}}function A4(t,e){const n=la(t,!0,e==="fixed"),s=n.top+t.clientTop,o=n.left+t.clientLeft,l=Gi(t)?yl(t):ti(1),c=t.clientWidth*l.x,f=t.clientHeight*l.y,d=o*l.x,m=s*l.y;return{width:c,height:f,x:d,y:m}}function Jx(t,e,n){let s;if(e==="viewport")s=S4(t,n);else if(e==="document")s=E4(ui(t));else if(Ds(e))s=A4(e,n);else{const o=bR(t);s={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return Rd(s)}function TR(t,e){const n=Qr(t);return n===e||!Ds(n)||Al(n)?!1:Os(n).position==="fixed"||TR(n,e)}function R4(t,e){const n=e.get(t);if(n)return n;let s=Nu(t,[],!1).filter(f=>Ds(f)&&Ll(f)!=="body"),o=null;const l=Os(t).position==="fixed";let c=l?Qr(t):t;for(;Ds(c)&&!Al(c);){const f=Os(c),d=pb(c);!d&&f.position==="fixed"&&(o=null),(l?!d&&!o:!d&&f.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Wu(c)&&!d&&TR(t,c))?s=s.filter(g=>g!==c):o=f,c=Qr(c)}return e.set(t,s),s}function C4(t){let{element:e,boundary:n,rootBoundary:s,strategy:o}=t;const c=[...n==="clippingAncestors"?vm(e)?[]:R4(e,this._c):[].concat(n),s],f=Jx(e,c[0],o);let d=f.top,m=f.right,g=f.bottom,v=f.left;for(let T=1;T{c(!1,1e-7)},1e3)}M===1&&!xR(m,t.getBoundingClientRect())&&c(),H=!1}try{n=new IntersectionObserver(K,{...B,root:o.ownerDocument})}catch{n=new IntersectionObserver(K,B)}n.observe(t)}return c(!0),l}function k4(t,e,n,s){s===void 0&&(s={});const{ancestorScroll:o=!0,ancestorResize:l=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:f=typeof IntersectionObserver=="function",animationFrame:d=!1}=s,m=yb(t),g=o||l?[...m?Nu(m):[],...e?Nu(e):[]]:[];g.forEach(L=>{o&&L.addEventListener("scroll",n,{passive:!0}),l&&L.addEventListener("resize",n)});const v=m&&f?M4(m,n):null;let T=-1,E=null;c&&(E=new ResizeObserver(L=>{let[z]=L;z&&z.target===m&&E&&e&&(E.unobserve(e),cancelAnimationFrame(T),T=requestAnimationFrame(()=>{var B;(B=E)==null||B.observe(e)})),n()}),m&&!d&&E.observe(m),e&&E.observe(e));let R,P=d?la(t):null;d&&N();function N(){const L=la(t);P&&!xR(P,L)&&n(),P=L,R=requestAnimationFrame(N)}return n(),()=>{var L;g.forEach(z=>{o&&z.removeEventListener("scroll",n),l&&z.removeEventListener("resize",n)}),v?.(),(L=E)==null||L.disconnect(),E=null,d&&cancelAnimationFrame(R)}}const V4=h4,j4=d4,L4=c4,U4=p4,z4=u4,tE=l4,B4=m4,F4=(t,e,n)=>{const s=new Map,o={platform:O4,...n},l={...o.platform,_c:s};return a4(t,e,{...o,platform:l})};var q4=typeof document<"u",H4=function(){},sd=q4?I.useLayoutEffect:H4;function Cd(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,s,o;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(s=n;s--!==0;)if(!Cd(t[s],e[s]))return!1;return!0}if(o=Object.keys(t),n=o.length,n!==Object.keys(e).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(e,o[s]))return!1;for(s=n;s--!==0;){const l=o[s];if(!(l==="_owner"&&t.$typeof)&&!Cd(t[l],e[l]))return!1}return!0}return t!==t&&e!==e}function ER(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function nE(t,e){const n=ER(t);return Math.round(e*n)/n}function fy(t){const e=I.useRef(t);return sd(()=>{e.current=t}),e}function G4(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:s=[],platform:o,elements:{reference:l,floating:c}={},transform:f=!0,whileElementsMounted:d,open:m}=t,[g,v]=I.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[T,E]=I.useState(s);Cd(T,s)||E(s);const[R,P]=I.useState(null),[N,L]=I.useState(null),z=I.useCallback(se=>{se!==te.current&&(te.current=se,P(se))},[]),B=I.useCallback(se=>{se!==M.current&&(M.current=se,L(se))},[]),H=l||R,K=c||N,te=I.useRef(null),M=I.useRef(null),A=I.useRef(g),O=d!=null,k=fy(d),j=fy(o),F=fy(m),V=I.useCallback(()=>{if(!te.current||!M.current)return;const se={placement:e,strategy:n,middleware:T};j.current&&(se.platform=j.current),F4(te.current,M.current,se).then(pe=>{const S={...pe,isPositioned:F.current!==!1};ue.current&&!Cd(A.current,S)&&(A.current=S,um.flushSync(()=>{v(S)}))})},[T,e,n,j,F]);sd(()=>{m===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,v(se=>({...se,isPositioned:!1})))},[m]);const ue=I.useRef(!1);sd(()=>(ue.current=!0,()=>{ue.current=!1}),[]),sd(()=>{if(H&&(te.current=H),K&&(M.current=K),H&&K){if(k.current)return k.current(H,K,V);V()}},[H,K,V,k,O]);const ye=I.useMemo(()=>({reference:te,floating:M,setReference:z,setFloating:B}),[z,B]),$=I.useMemo(()=>({reference:H,floating:K}),[H,K]),le=I.useMemo(()=>{const se={position:n,left:0,top:0};if(!$.floating)return se;const pe=nE($.floating,g.x),S=nE($.floating,g.y);return f?{...se,transform:"translate("+pe+"px, "+S+"px)",...ER($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:pe,top:S}},[n,f,$.floating,g.x,g.y]);return I.useMemo(()=>({...g,update:V,refs:ye,elements:$,floatingStyles:le}),[g,V,ye,$,le])}const $4=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:s,padding:o}=typeof t=="function"?t(n):t;return s&&e(s)?s.current!=null?tE({element:s.current,padding:o}).fn(n):{}:s?tE({element:s,padding:o}).fn(n):{}}}},K4=(t,e)=>{const n=V4(t);return{name:n.name,fn:n.fn,options:[t,e]}},Q4=(t,e)=>{const n=j4(t);return{name:n.name,fn:n.fn,options:[t,e]}},Y4=(t,e)=>({fn:B4(t).fn,options:[t,e]}),W4=(t,e)=>{const n=L4(t);return{name:n.name,fn:n.fn,options:[t,e]}},X4=(t,e)=>{const n=U4(t);return{name:n.name,fn:n.fn,options:[t,e]}},Z4=(t,e)=>{const n=z4(t);return{name:n.name,fn:n.fn,options:[t,e]}},J4=(t,e)=>{const n=$4(t);return{name:n.name,fn:n.fn,options:[t,e]}};var ej="Arrow",SR=I.forwardRef((t,e)=>{const{children:n,width:s=10,height:o=5,...l}=t;return b.jsx(pn.svg,{...l,ref:e,width:s,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:b.jsx("polygon",{points:"0,0 30,0 15,10"})})});SR.displayName=ej;var tj=SR;function AR(t){const[e,n]=I.useState(void 0);return $r(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const s=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const l=o[0];let c,f;if("borderBoxSize"in l){const d=l.borderBoxSize,m=Array.isArray(d)?d[0]:d;c=m.inlineSize,f=m.blockSize}else c=t.offsetWidth,f=t.offsetHeight;n({width:c,height:f})});return s.observe(t,{box:"border-box"}),()=>s.unobserve(t)}else n(void 0)},[t]),e}var RR="Popper",[CR,IR]=Qu(RR),[oG,NR]=CR(RR),PR="PopperAnchor",DR=I.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:s,...o}=t,l=NR(PR,n),c=I.useRef(null),f=$n(e,c),d=I.useRef(null);return I.useEffect(()=>{const m=d.current;d.current=s?.current||c.current,m!==d.current&&l.onAnchorChange(d.current)}),s?null:b.jsx(pn.div,{...o,ref:f})});DR.displayName=PR;var vb="PopperContent",[nj,sj]=CR(vb),OR=I.forwardRef((t,e)=>{const{__scopePopper:n,side:s="bottom",sideOffset:o=0,align:l="center",alignOffset:c=0,arrowPadding:f=0,avoidCollisions:d=!0,collisionBoundary:m=[],collisionPadding:g=0,sticky:v="partial",hideWhenDetached:T=!1,updatePositionStrategy:E="optimized",onPlaced:R,...P}=t,N=NR(vb,n),[L,z]=I.useState(null),B=$n(e,et=>z(et)),[H,K]=I.useState(null),te=AR(H),M=te?.width??0,A=te?.height??0,O=s+(l!=="center"?"-"+l:""),k=typeof g=="number"?g:{top:0,right:0,bottom:0,left:0,...g},j=Array.isArray(m)?m:[m],F=j.length>0,V={padding:k,boundary:j.filter(rj),altBoundary:F},{refs:ue,floatingStyles:ye,placement:$,isPositioned:le,middlewareData:se}=G4({strategy:"fixed",placement:O,whileElementsMounted:(...et)=>k4(...et,{animationFrame:E==="always"}),elements:{reference:N.anchor},middleware:[K4({mainAxis:o+A,alignmentAxis:c}),d&&Q4({mainAxis:!0,crossAxis:!1,limiter:v==="partial"?Y4():void 0,...V}),d&&W4({...V}),X4({...V,apply:({elements:et,rects:qe,availableWidth:Ke,availableHeight:Vs})=>{const{width:Pn,height:Dn}=qe.reference,on=et.floating.style;on.setProperty("--radix-popper-available-width",`${Ke}px`),on.setProperty("--radix-popper-available-height",`${Vs}px`),on.setProperty("--radix-popper-anchor-width",`${Pn}px`),on.setProperty("--radix-popper-anchor-height",`${Dn}px`)}}),H&&J4({element:H,padding:f}),oj({arrowWidth:M,arrowHeight:A}),T&&Z4({strategy:"referenceHidden",...V})]}),[pe,S]=VR($),Q=Gr(R);$r(()=>{le&&Q?.()},[le,Q]);const ce=se.arrow?.x,fe=se.arrow?.y,de=se.arrow?.centerOffset!==0,[Ee,ve]=I.useState();return $r(()=>{L&&ve(window.getComputedStyle(L).zIndex)},[L]),b.jsx("div",{ref:ue.setFloating,"data-radix-popper-content-wrapper":"",style:{...ye,transform:le?ye.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ee,"--radix-popper-transform-origin":[se.transformOrigin?.x,se.transformOrigin?.y].join(" "),...se.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:b.jsx(nj,{scope:n,placedSide:pe,onArrowChange:K,arrowX:ce,arrowY:fe,shouldHideArrow:de,children:b.jsx(pn.div,{"data-side":pe,"data-align":S,...P,ref:B,style:{...P.style,animation:le?void 0:"none"}})})})});OR.displayName=vb;var MR="PopperArrow",ij={top:"bottom",right:"left",bottom:"top",left:"right"},kR=I.forwardRef(function(e,n){const{__scopePopper:s,...o}=e,l=sj(MR,s),c=ij[l.placedSide];return b.jsx("span",{ref:l.onArrowChange,style:{position:"absolute",left:l.arrowX,top:l.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[l.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[l.placedSide],visibility:l.shouldHideArrow?"hidden":void 0},children:b.jsx(tj,{...o,ref:n,style:{...o.style,display:"block"}})})});kR.displayName=MR;function rj(t){return t!==null}var oj=t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:s,middlewareData:o}=e,c=o.arrow?.centerOffset!==0,f=c?0:t.arrowWidth,d=c?0:t.arrowHeight,[m,g]=VR(n),v={start:"0%",center:"50%",end:"100%"}[g],T=(o.arrow?.x??0)+f/2,E=(o.arrow?.y??0)+d/2;let R="",P="";return m==="bottom"?(R=c?v:`${T}px`,P=`${-d}px`):m==="top"?(R=c?v:`${T}px`,P=`${s.floating.height+d}px`):m==="right"?(R=`${-d}px`,P=c?v:`${E}px`):m==="left"&&(R=`${s.floating.width+d}px`,P=c?v:`${E}px`),{data:{x:R,y:P}}}});function VR(t){const[e,n="center"]=t.split("-");return[e,n]}var aj=DR,lj=OR,cj=kR,[Tm]=Qu("Tooltip",[IR]),bb=IR(),jR="TooltipProvider",uj=700,sE="tooltip.open",[fj,LR]=Tm(jR),UR=t=>{const{__scopeTooltip:e,delayDuration:n=uj,skipDelayDuration:s=300,disableHoverableContent:o=!1,children:l}=t,c=I.useRef(!0),f=I.useRef(!1),d=I.useRef(0);return I.useEffect(()=>{const m=d.current;return()=>window.clearTimeout(m)},[]),b.jsx(fj,{scope:e,isOpenDelayedRef:c,delayDuration:n,onOpen:I.useCallback(()=>{window.clearTimeout(d.current),c.current=!1},[]),onClose:I.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>c.current=!0,s)},[s]),isPointerInTransitRef:f,onPointerInTransitChange:I.useCallback(m=>{f.current=m},[]),disableHoverableContent:o,children:l})};UR.displayName=jR;var zR="Tooltip",[aG,Xu]=Tm(zR),nv="TooltipTrigger",hj=I.forwardRef((t,e)=>{const{__scopeTooltip:n,...s}=t,o=Xu(nv,n),l=LR(nv,n),c=bb(n),f=I.useRef(null),d=$n(e,f,o.onTriggerChange),m=I.useRef(!1),g=I.useRef(!1),v=I.useCallback(()=>m.current=!1,[]);return I.useEffect(()=>()=>document.removeEventListener("pointerup",v),[v]),b.jsx(aj,{asChild:!0,...c,children:b.jsx(pn.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...s,ref:d,onPointerMove:Dt(t.onPointerMove,T=>{T.pointerType!=="touch"&&!g.current&&!l.isPointerInTransitRef.current&&(o.onTriggerEnter(),g.current=!0)}),onPointerLeave:Dt(t.onPointerLeave,()=>{o.onTriggerLeave(),g.current=!1}),onPointerDown:Dt(t.onPointerDown,()=>{o.open&&o.onClose(),m.current=!0,document.addEventListener("pointerup",v,{once:!0})}),onFocus:Dt(t.onFocus,()=>{m.current||o.onOpen()}),onBlur:Dt(t.onBlur,o.onClose),onClick:Dt(t.onClick,o.onClose)})})});hj.displayName=nv;var _b="TooltipPortal",[dj,mj]=Tm(_b,{forceMount:void 0}),BR=t=>{const{__scopeTooltip:e,forceMount:n,children:s,container:o}=t,l=Xu(_b,e);return b.jsx(dj,{scope:e,forceMount:n,children:b.jsx(fm,{present:n||l.open,children:b.jsx(ob,{asChild:!0,container:o,children:s})})})};BR.displayName=_b;var Rl="TooltipContent",FR=I.forwardRef((t,e)=>{const n=mj(Rl,t.__scopeTooltip),{forceMount:s=n.forceMount,side:o="top",...l}=t,c=Xu(Rl,t.__scopeTooltip);return b.jsx(fm,{present:s||c.open,children:c.disableHoverableContent?b.jsx(qR,{side:o,...l,ref:e}):b.jsx(pj,{side:o,...l,ref:e})})}),pj=I.forwardRef((t,e)=>{const n=Xu(Rl,t.__scopeTooltip),s=LR(Rl,t.__scopeTooltip),o=I.useRef(null),l=$n(e,o),[c,f]=I.useState(null),{trigger:d,onClose:m}=n,g=o.current,{onPointerInTransitChange:v}=s,T=I.useCallback(()=>{f(null),v(!1)},[v]),E=I.useCallback((R,P)=>{const N=R.currentTarget,L={x:R.clientX,y:R.clientY},z=_j(L,N.getBoundingClientRect()),B=Tj(L,z),H=wj(P.getBoundingClientRect()),K=Ej([...B,...H]);f(K),v(!0)},[v]);return I.useEffect(()=>()=>T(),[T]),I.useEffect(()=>{if(d&&g){const R=N=>E(N,g),P=N=>E(N,d);return d.addEventListener("pointerleave",R),g.addEventListener("pointerleave",P),()=>{d.removeEventListener("pointerleave",R),g.removeEventListener("pointerleave",P)}}},[d,g,E,T]),I.useEffect(()=>{if(c){const R=P=>{const N=P.target,L={x:P.clientX,y:P.clientY},z=d?.contains(N)||g?.contains(N),B=!xj(L,c);z?T():B&&(T(),m())};return document.addEventListener("pointermove",R),()=>document.removeEventListener("pointermove",R)}},[d,g,c,m,T]),b.jsx(qR,{...t,ref:l})}),[gj,yj]=Tm(zR,{isInside:!1}),vj=mM("TooltipContent"),qR=I.forwardRef((t,e)=>{const{__scopeTooltip:n,children:s,"aria-label":o,onEscapeKeyDown:l,onPointerDownOutside:c,...f}=t,d=Xu(Rl,n),m=bb(n),{onClose:g}=d;return I.useEffect(()=>(document.addEventListener(sE,g),()=>document.removeEventListener(sE,g)),[g]),I.useEffect(()=>{if(d.trigger){const v=T=>{T.target?.contains(d.trigger)&&g()};return window.addEventListener("scroll",v,{capture:!0}),()=>window.removeEventListener("scroll",v,{capture:!0})}},[d.trigger,g]),b.jsx(rb,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:v=>v.preventDefault(),onDismiss:g,children:b.jsxs(lj,{"data-state":d.stateAttribute,...m,...f,ref:e,style:{...f.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[b.jsx(vj,{children:s}),b.jsx(gj,{scope:n,isInside:!0,children:b.jsx(LM,{id:d.contentId,role:"tooltip",children:o||s})})]})})});FR.displayName=Rl;var HR="TooltipArrow",bj=I.forwardRef((t,e)=>{const{__scopeTooltip:n,...s}=t,o=bb(n);return yj(HR,n).isInside?null:b.jsx(cj,{...o,...s,ref:e})});bj.displayName=HR;function _j(t,e){const n=Math.abs(e.top-t.y),s=Math.abs(e.bottom-t.y),o=Math.abs(e.right-t.x),l=Math.abs(e.left-t.x);switch(Math.min(n,s,o,l)){case l:return"left";case o:return"right";case n:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function Tj(t,e,n=5){const s=[];switch(e){case"top":s.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":s.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":s.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":s.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return s}function wj(t){const{top:e,right:n,bottom:s,left:o}=t;return[{x:o,y:e},{x:n,y:e},{x:n,y:s},{x:o,y:s}]}function xj(t,e){const{x:n,y:s}=t;let o=!1;for(let l=0,c=e.length-1;ls!=T>s&&n<(v-m)*(s-g)/(T-g)+m&&(o=!o)}return o}function Ej(t){const e=t.slice();return e.sort((n,s)=>n.xs.x?1:n.ys.y?1:0),Sj(e)}function Sj(t){if(t.length<=1)return t.slice();const e=[];for(let s=0;s=2;){const l=e[e.length-1],c=e[e.length-2];if((l.x-c.x)*(o.y-c.y)>=(l.y-c.y)*(o.x-c.x))e.pop();else break}e.push(o)}e.pop();const n=[];for(let s=t.length-1;s>=0;s--){const o=t[s];for(;n.length>=2;){const l=n[n.length-1],c=n[n.length-2];if((l.x-c.x)*(o.y-c.y)>=(l.y-c.y)*(o.x-c.x))n.pop();else break}n.push(o)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var Aj=UR,Rj=BR,GR=FR;const Cj=Aj,Ij=I.forwardRef(({className:t,sideOffset:e=4,...n},s)=>b.jsx(Rj,{children:b.jsx(GR,{ref:s,sideOffset:e,className:Yt("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...n})}));Ij.displayName=GR.displayName;const $R=I.forwardRef(({className:t,...e},n)=>b.jsx("div",{ref:n,className:Yt("rounded-xl border bg-card text-card-foreground shadow",t),...e}));$R.displayName="Card";const Nj=I.forwardRef(({className:t,...e},n)=>b.jsx("div",{ref:n,className:Yt("flex flex-col space-y-1.5 p-6",t),...e}));Nj.displayName="CardHeader";const Pj=I.forwardRef(({className:t,...e},n)=>b.jsx("div",{ref:n,className:Yt("font-semibold leading-none tracking-tight",t),...e}));Pj.displayName="CardTitle";const Dj=I.forwardRef(({className:t,...e},n)=>b.jsx("div",{ref:n,className:Yt("text-sm text-muted-foreground",t),...e}));Dj.displayName="CardDescription";const KR=I.forwardRef(({className:t,...e},n)=>b.jsx("div",{ref:n,className:Yt("p-6 pt-0",t),...e}));KR.displayName="CardContent";const Oj=I.forwardRef(({className:t,...e},n)=>b.jsx("div",{ref:n,className:Yt("flex items-center p-6 pt-0",t),...e}));Oj.displayName="CardFooter";function Mj(){return b.jsx("div",{className:"min-h-screen w-full flex items-center justify-center bg-gray-50",children:b.jsx($R,{className:"w-full max-w-md mx-4",children:b.jsxs(KR,{className:"pt-6",children:[b.jsxs("div",{className:"flex mb-4 gap-2",children:[b.jsx(vk,{className:"h-8 w-8 text-red-500"}),b.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"404 Page Not Found"})]}),b.jsx("p",{className:"mt-4 text-sm text-gray-600",children:"Did you forget to add the page to the router?"})]})})})}function kj({cartCount:t}){const[e]=io(),n=[{href:"/",icon:Dk,label:"الرئيسية"},{href:"/cart",icon:pm,label:"السلة",badge:t},{href:"/account",icon:gm,label:"الحساب"}];return b.jsx("div",{className:"fixed bottom-0 w-full bg-background border-t border-border pb-safe pt-2 px-6 flex justify-between items-center z-50 md:hidden",children:n.map(s=>{const o=s.icon,l=e===s.href;return b.jsx(AO,{href:s.href,className:"flex-1",children:b.jsxs("div",{className:Yt("flex flex-col items-center gap-1 cursor-pointer transition-colors py-2",l?"text-primary":"text-muted-foreground"),children:[b.jsxs("div",{className:"relative",children:[b.jsx(o,{className:"w-6 h-6"}),s.badge!==void 0&&s.badge>0&&b.jsx("span",{className:"absolute -top-1 -right-2 bg-destructive text-destructive-foreground text-[10px] font-bold px-1.5 py-0.5 rounded-full min-w-[18px] text-center",children:s.badge})]}),b.jsx("span",{className:"text-[10px] font-bold",children:s.label})]})},s.href)})})}var QR={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},iE=Tn.createContext&&Tn.createContext(QR),Vj=["attr","size","title"];function jj(t,e){if(t==null)return{};var n,s,o=Lj(t,e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);for(s=0;sTn.createElement(e.tag,Nd({key:n},e.attr),YR(e.child)))}function wm(t){return e=>Tn.createElement(Fj,Id({attr:Nd({},t.attr)},e),YR(t.child))}function Fj(t){var e=n=>{var{attr:s,size:o,title:l}=t,c=jj(t,Vj),f=o||n.size||"1em",d;return n.className&&(d=n.className),t.className&&(d=(d?d+" ":"")+t.className),Tn.createElement("svg",Id({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,s,c,{className:d,style:Nd(Nd({color:t.color||n.color},n.style),t.style),height:f,width:f,xmlns:"http://www.w3.org/2000/svg"}),l&&Tn.createElement("title",null,l),t.children)};return iE!==void 0?Tn.createElement(iE.Consumer,null,n=>e(n)):e(QR)}function qj(t){return wm({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z"},child:[]}]})(t)}function Hj(t){return wm({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413Z"},child:[]}]})(t)}function Gj(t){return wm({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.05-2.89-.35-4.2-.97-.57-.26-1.1-.59-1.62-.93-.01 2.92.01 5.84-.02 8.75-.08 1.4-.54 2.79-1.35 3.94-1.31 1.92-3.58 3.17-5.91 3.21-1.43.08-2.86-.31-4.08-1.03-2.02-1.19-3.44-3.37-3.65-5.71-.02-.5-.03-1-.01-1.49.18-1.9 1.12-3.72 2.58-4.96 1.66-1.44 3.98-2.13 6.15-1.72.02 1.48-.04 2.96-.04 4.44-.99-.32-2.15-.23-3.02.37-.63.41-1.11 1.04-1.36 1.75-.21.51-.15 1.07-.14 1.61.24 1.64 1.82 3.02 3.5 2.87 1.12-.01 2.19-.66 2.77-1.61.19-.33.4-.67.41-1.06.1-1.79.06-3.57.07-5.36.01-4.03-.01-8.05.02-12.07z"},child:[]}]})(t)}function $j(t){return wm({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z"},child:[]}]})(t)}const Kj=[{label:"واتساب",icon:Hj,href:"https://wa.me/966500000000",color:"hover:text-[#25D366]"},{label:"تيك توك",icon:Gj,href:"https://tiktok.com/@pr7store",color:"hover:text-foreground"},{label:"X (تويتر)",icon:qj,href:"https://x.com/pr7store",color:"hover:text-foreground"},{label:"ايميل",icon:K1,href:"mailto:support@pr7store.com",color:"hover:text-foreground"}];function Qj(){return b.jsx("footer",{className:"border-t border-border bg-card mt-8 pb-24 md:pb-8","data-testid":"footer",children:b.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-8 flex flex-col items-center gap-6",children:[b.jsxs("div",{className:"text-center",children:[b.jsx("p",{className:"font-black text-xl tracking-wide",children:"Pr7 Store"}),b.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"متجر فلوس GTA الموثوق"})]}),b.jsx("div",{className:"flex items-center gap-6",children:Kj.map(({label:t,icon:e,href:n,color:s})=>b.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",title:t,"data-testid":`link-social-${t}`,className:`text-muted-foreground transition-colors ${s} flex flex-col items-center gap-1`,children:[b.jsx(e,{className:"w-6 h-6"}),b.jsx("span",{className:"text-[10px] font-semibold",children:t})]},t))}),b.jsx("p",{className:"text-xs text-muted-foreground text-center max-w-sm leading-relaxed",children:"التسليم يتم مباشرة داخل اللعبة عبر واتساب — لا يوجد شحن أو توصيل فعلي"}),b.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["© ",new Date().getFullYear()," Pr7 Store — جميع الحقوق محفوظة"]})]})})}const Tb=I.createContext({});function wb(t){const e=I.useRef(null);return e.current===null&&(e.current=t()),e.current}const Yj=typeof window<"u",WR=Yj?I.useLayoutEffect:I.useEffect,xm=I.createContext(null);function xb(t,e){t.indexOf(e)===-1&&t.push(e)}function Pd(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const ai=(t,e,n)=>n>e?e:n{};const Yr={},XR=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function ZR(t){return typeof t=="object"&&t!==null}const JR=t=>/^0[^.\s]+$/u.test(t);function eC(t){let e;return()=>(e===void 0&&(e=t()),e)}const cs=t=>t,Wj=(t,e)=>n=>e(t(n)),Zu=(...t)=>t.reduce(Wj),Pu=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class Sb{constructor(){this.subscriptions=[]}add(e){return xb(this.subscriptions,e),()=>Pd(this.subscriptions,e)}notify(e,n,s){const o=this.subscriptions.length;if(o)if(o===1)this.subscriptions[0](e,n,s);else for(let l=0;lt*1e3,ls=t=>t/1e3;function tC(t,e){return e?t*(1e3/e):0}const nC=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Xj=1e-7,Zj=12;function Jj(t,e,n,s,o){let l,c,f=0;do c=e+(n-e)/2,l=nC(c,s,o)-t,l>0?n=c:e=c;while(Math.abs(l)>Xj&&++fJj(l,0,1,t,n);return l=>l===0||l===1?l:nC(o(l),e,s)}const sC=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,iC=t=>e=>1-t(1-e),rC=Ju(.33,1.53,.69,.99),Ab=iC(rC),oC=sC(Ab),aC=t=>t>=1?1:(t*=2)<1?.5*Ab(t):.5*(2-Math.pow(2,-10*(t-1))),Rb=t=>1-Math.sin(Math.acos(t)),lC=iC(Rb),cC=sC(Rb),eL=Ju(.42,0,1,1),tL=Ju(0,0,.58,1),uC=Ju(.42,0,.58,1),nL=t=>Array.isArray(t)&&typeof t[0]!="number",fC=t=>Array.isArray(t)&&typeof t[0]=="number",sL={linear:cs,easeIn:eL,easeInOut:uC,easeOut:tL,circIn:Rb,circInOut:cC,circOut:lC,backIn:Ab,backInOut:oC,backOut:rC,anticipate:aC},iL=t=>typeof t=="string",oE=t=>{if(fC(t)){Eb(t.length===4);const[e,n,s,o]=t;return Ju(e,n,s,o)}else if(iL(t))return sL[t];return t},qh=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function rL(t,e){let n=new Set,s=new Set,o=!1,l=!1;const c=new WeakSet;let f={delta:0,timestamp:0,isProcessing:!1};function d(g){c.has(g)&&(m.schedule(g),t()),g(f)}const m={schedule:(g,v=!1,T=!1)=>{const R=T&&o?n:s;return v&&c.add(g),R.add(g),g},cancel:g=>{s.delete(g),c.delete(g)},process:g=>{if(f=g,o){l=!0;return}o=!0;const v=n;n=s,s=v,n.forEach(d),n.clear(),o=!1,l&&(l=!1,m.process(g))}};return m}const oL=40;function hC(t,e){let n=!1,s=!0;const o={delta:0,timestamp:0,isProcessing:!1},l=()=>n=!0,c=qh.reduce((B,H)=>(B[H]=rL(l),B),{}),{setup:f,read:d,resolveKeyframes:m,preUpdate:g,update:v,preRender:T,render:E,postRender:R}=c,P=()=>{const B=Yr.useManualTiming,H=B?o.timestamp:performance.now();n=!1,B||(o.delta=s?1e3/60:Math.max(Math.min(H-o.timestamp,oL),1)),o.timestamp=H,o.isProcessing=!0,f.process(o),d.process(o),m.process(o),g.process(o),v.process(o),T.process(o),E.process(o),R.process(o),o.isProcessing=!1,n&&e&&(s=!1,t(P))},N=()=>{n=!0,s=!0,o.isProcessing||t(P)};return{schedule:qh.reduce((B,H)=>{const K=c[H];return B[H]=(te,M=!1,A=!1)=>(n||N(),K.schedule(te,M,A)),B},{}),cancel:B=>{for(let H=0;H(id===void 0&&xn.set(en.isProcessing||Yr.useManualTiming?en.timestamp:performance.now()),id),set:t=>{id=t,queueMicrotask(aL)}},dC=t=>e=>typeof e=="string"&&e.startsWith(t),mC=dC("--"),lL=dC("var(--"),Cb=t=>lL(t)?cL.test(t.split("/*")[0].trim()):!1,cL=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function aE(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const Ul={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Du={...Ul,transform:t=>ai(0,1,t)},Hh={...Ul,default:1},pu=t=>Math.round(t*1e5)/1e5,Ib=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function uL(t){return t==null}const fL=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Nb=(t,e)=>n=>!!(typeof n=="string"&&fL.test(n)&&n.startsWith(t)||e&&!uL(n)&&Object.prototype.hasOwnProperty.call(n,e)),pC=(t,e,n)=>s=>{if(typeof s!="string")return s;const[o,l,c,f]=s.match(Ib);return{[t]:parseFloat(o),[e]:parseFloat(l),[n]:parseFloat(c),alpha:f!==void 0?parseFloat(f):1}},hL=t=>ai(0,255,t),dy={...Ul,transform:t=>Math.round(hL(t))},ta={test:Nb("rgb","red"),parse:pC("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+dy.transform(t)+", "+dy.transform(e)+", "+dy.transform(n)+", "+pu(Du.transform(s))+")"};function dL(t){let e="",n="",s="",o="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),o=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),o=t.substring(4,5),e+=e,n+=n,s+=s,o+=o),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:o?parseInt(o,16)/255:1}}const sv={test:Nb("#"),parse:dL,transform:ta.transform},ef=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),kr=ef("deg"),ni=ef("%"),Te=ef("px"),mL=ef("vh"),pL=ef("vw"),lE={...ni,parse:t=>ni.parse(t)/100,transform:t=>ni.transform(t*100)},ml={test:Nb("hsl","hue"),parse:pC("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+ni.transform(pu(e))+", "+ni.transform(pu(n))+", "+pu(Du.transform(s))+")"},Pt={test:t=>ta.test(t)||sv.test(t)||ml.test(t),parse:t=>ta.test(t)?ta.parse(t):ml.test(t)?ml.parse(t):sv.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?ta.transform(t):ml.transform(t),getAnimatableNone:t=>{const e=Pt.parse(t);return e.alpha=0,Pt.transform(e)}},gL=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function yL(t){return isNaN(t)&&typeof t=="string"&&(t.match(Ib)?.length||0)+(t.match(gL)?.length||0)>0}const gC="number",yC="color",vL="var",bL="var(",cE="${}",_L=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Cl(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},o=[];let l=0;const f=e.replace(_L,d=>(Pt.test(d)?(s.color.push(l),o.push(yC),n.push(Pt.parse(d))):d.startsWith(bL)?(s.var.push(l),o.push(vL),n.push(d)):(s.number.push(l),o.push(gC),n.push(parseFloat(d))),++l,cE)).split(cE);return{values:n,split:f,indexes:s,types:o}}function TL(t){return Cl(t).values}function vC({split:t,types:e}){const n=t.length;return s=>{let o="";for(let l=0;ltypeof t=="number"?0:Pt.test(t)?Pt.getAnimatableNone(t):t,EL=(t,e)=>typeof t=="number"?e?.trim().endsWith("/")?t:0:xL(t);function SL(t){const e=Cl(t);return vC(e)(e.values.map((s,o)=>EL(s,e.split[o])))}const Rs={test:yL,parse:TL,createTransformer:wL,getAnimatableNone:SL};function my(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function AL({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let o=0,l=0,c=0;if(!e)o=l=c=n;else{const f=n<.5?n*(1+e):n+e-n*e,d=2*n-f;o=my(d,f,t+1/3),l=my(d,f,t),c=my(d,f,t-1/3)}return{red:Math.round(o*255),green:Math.round(l*255),blue:Math.round(c*255),alpha:s}}function Dd(t,e){return n=>n>0?e:t}const ht=(t,e,n)=>t+(e-t)*n,py=(t,e,n)=>{const s=t*t,o=n*(e*e-s)+s;return o<0?0:Math.sqrt(o)},RL=[sv,ta,ml],CL=t=>RL.find(e=>e.test(t));function uE(t){const e=CL(t);if(!e)return!1;let n=e.parse(t);return e===ml&&(n=AL(n)),n}const fE=(t,e)=>{const n=uE(t),s=uE(e);if(!n||!s)return Dd(t,e);const o={...n};return l=>(o.red=py(n.red,s.red,l),o.green=py(n.green,s.green,l),o.blue=py(n.blue,s.blue,l),o.alpha=ht(n.alpha,s.alpha,l),ta.transform(o))},iv=new Set(["none","hidden"]);function IL(t,e){return iv.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function NL(t,e){return n=>ht(t,e,n)}function Pb(t){return typeof t=="number"?NL:typeof t=="string"?Cb(t)?Dd:Pt.test(t)?fE:OL:Array.isArray(t)?bC:typeof t=="object"?Pt.test(t)?fE:PL:Dd}function bC(t,e){const n=[...t],s=n.length,o=t.map((l,c)=>Pb(l)(l,e[c]));return l=>{for(let c=0;c{for(const l in s)n[l]=s[l](o);return n}}function DL(t,e){const n=[],s={color:0,var:0,number:0};for(let o=0;o{const n=Rs.createTransformer(e),s=Cl(t),o=Cl(e);return s.indexes.var.length===o.indexes.var.length&&s.indexes.color.length===o.indexes.color.length&&s.indexes.number.length>=o.indexes.number.length?iv.has(t)&&!o.values.length||iv.has(e)&&!s.values.length?IL(t,e):Zu(bC(DL(s,o),o.values),n):Dd(t,e)};function _C(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?ht(t,e,n):Pb(t)(t,e)}const ML=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>ot.update(e,n),stop:()=>Wr(e),now:()=>en.isProcessing?en.timestamp:xn.now()}},TC=(t,e,n=10)=>{let s="";const o=Math.max(Math.round(e/n),2);for(let l=0;l=Od?1/0:e}function kL(t,e=100,n){const s=n({...t,keyframes:[0,e]}),o=Math.min(Db(s),Od);return{type:"keyframes",ease:l=>s.next(o*l).value/e,duration:ls(o)}}const bt={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function rv(t,e){return t*Math.sqrt(1-e*e)}const VL=12;function jL(t,e,n){let s=n;for(let o=1;o{const g=m*c,v=g*t,T=g-n,E=rv(m,c),R=Math.exp(-v);return gy-T/E*R},l=m=>{const v=m*c*t,T=v*n+n,E=Math.pow(c,2)*Math.pow(m,2)*t,R=Math.exp(-v),P=rv(Math.pow(m,2),c);return(-o(m)+gy>0?-1:1)*((T-E)*R)/P}):(o=m=>{const g=Math.exp(-m*t),v=(m-n)*t+1;return-gy+g*v},l=m=>{const g=Math.exp(-m*t),v=(n-m)*(t*t);return g*v});const f=5/t,d=jL(o,l,f);if(t=Gn(t),isNaN(d))return{stiffness:bt.stiffness,damping:bt.damping,duration:t};{const m=Math.pow(d,2)*s;return{stiffness:m,damping:c*2*Math.sqrt(s*m),duration:t}}}const UL=["duration","bounce"],zL=["stiffness","damping","mass"];function hE(t,e){return e.some(n=>t[n]!==void 0)}function BL(t){let e={velocity:bt.velocity,stiffness:bt.stiffness,damping:bt.damping,mass:bt.mass,isResolvedFromDuration:!1,...t};if(!hE(t,zL)&&hE(t,UL))if(e.velocity=0,t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),o=s*s,l=2*ai(.05,1,1-(t.bounce||0))*Math.sqrt(o);e={...e,mass:bt.mass,stiffness:o,damping:l}}else{const n=LL({...t,velocity:0});e={...e,...n,mass:bt.mass},e.isResolvedFromDuration=!0}return e}function Md(t=bt.visualDuration,e=bt.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:o}=n;const l=n.keyframes[0],c=n.keyframes[n.keyframes.length-1],f={done:!1,value:l},{stiffness:d,damping:m,mass:g,duration:v,velocity:T,isResolvedFromDuration:E}=BL({...n,velocity:-ls(n.velocity||0)}),R=T||0,P=m/(2*Math.sqrt(d*g)),N=c-l,L=ls(Math.sqrt(d/g)),z=Math.abs(N)<5;s||(s=z?bt.restSpeed.granular:bt.restSpeed.default),o||(o=z?bt.restDelta.granular:bt.restDelta.default);let B,H,K,te,M,A;if(P<1)K=rv(L,P),te=(R+P*L*N)/K,B=k=>{const j=Math.exp(-P*L*k);return c-j*(te*Math.sin(K*k)+N*Math.cos(K*k))},M=P*L*te+N*K,A=P*L*N-te*K,H=k=>Math.exp(-P*L*k)*(M*Math.sin(K*k)+A*Math.cos(K*k));else if(P===1){B=j=>c-Math.exp(-L*j)*(N+(R+L*N)*j);const k=R+L*N;H=j=>Math.exp(-L*j)*(L*k*j-R)}else{const k=L*Math.sqrt(P*P-1);B=ue=>{const ye=Math.exp(-P*L*ue),$=Math.min(k*ue,300);return c-ye*((R+P*L*N)*Math.sinh($)+k*N*Math.cosh($))/k};const j=(R+P*L*N)/k,F=P*L*j-N*k,V=P*L*N-j*k;H=ue=>{const ye=Math.exp(-P*L*ue),$=Math.min(k*ue,300);return ye*(F*Math.sinh($)+V*Math.cosh($))}}const O={calculatedDuration:E&&v||null,velocity:k=>Gn(H(k)),next:k=>{if(!E&&P<1){const F=Math.exp(-P*L*k),V=Math.sin(K*k),ue=Math.cos(K*k),ye=c-F*(te*V+N*ue),$=Gn(F*(M*V+A*ue));return f.done=Math.abs($)<=s&&Math.abs(c-ye)<=o,f.value=f.done?c:ye,f}const j=B(k);if(E)f.done=k>=v;else{const F=Gn(H(k));f.done=Math.abs(F)<=s&&Math.abs(c-j)<=o}return f.value=f.done?c:j,f},toString:()=>{const k=Math.min(Db(O),Od),j=TC(F=>O.next(k*F).value,k,30);return k+"ms "+j},toTransition:()=>{}};return O}Md.applyToOptions=t=>{const e=kL(t,100,Md);return t.ease=e.ease,t.duration=Gn(e.duration),t.type="keyframes",t};const FL=5;function wC(t,e,n){const s=Math.max(e-FL,0);return tC(n-t(s),e-s)}function ov({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:o=10,bounceStiffness:l=500,modifyTarget:c,min:f,max:d,restDelta:m=.5,restSpeed:g}){const v=t[0],T={done:!1,value:v},E=A=>f!==void 0&&Ad,R=A=>f===void 0?d:d===void 0||Math.abs(f-A)-P*Math.exp(-A/s),B=A=>L+z(A),H=A=>{const O=z(A),k=B(A);T.done=Math.abs(O)<=m,T.value=T.done?L:k};let K,te;const M=A=>{E(T.value)&&(K=A,te=Md({keyframes:[T.value,R(T.value)],velocity:wC(B,A,T.value),damping:o,stiffness:l,restDelta:m,restSpeed:g}))};return M(0),{calculatedDuration:null,next:A=>{let O=!1;return!te&&K===void 0&&(O=!0,H(A),M(A)),K!==void 0&&A>=K?te.next(A-K):(!O&&H(A),T)}}}function qL(t,e,n){const s=[],o=n||Yr.mix||_C,l=t.length-1;for(let c=0;ce[0];if(l===2&&e[0]===e[1])return()=>e[1];const c=t[0]===t[1];t[0]>t[l-1]&&(t=[...t].reverse(),e=[...e].reverse());const f=qL(e,s,o),d=f.length,m=g=>{if(c&&g1)for(;vm(ai(t[0],t[l-1],g)):m}function GL(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const o=Pu(0,e,s);t.push(ht(n,1,o))}}function $L(t){const e=[0];return GL(e,t.length-1),e}function KL(t,e){return t.map(n=>n*e)}function QL(t,e){return t.map(()=>e||uC).splice(0,t.length-1)}function gu({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const o=nL(s)?s.map(oE):oE(s),l={done:!1,value:e[0]},c=KL(n&&n.length===e.length?n:$L(e),t),f=HL(c,e,{ease:Array.isArray(o)?o:QL(e,o)});return{calculatedDuration:t,next:d=>(l.value=f(d),l.done=d>=t,l)}}const YL=t=>t!==null;function Em(t,{repeat:e,repeatType:n="loop"},s,o=1){const l=t.filter(YL),f=o<0||e&&n!=="loop"&&e%2===1?0:l.length-1;return!f||s===void 0?l[f]:s}const WL={decay:ov,inertia:ov,tween:gu,keyframes:gu,spring:Md};function xC(t){typeof t.type=="string"&&(t.type=WL[t.type])}class Ob{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const XL=t=>t/100;class kd extends Ob{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==xn.now()&&this.tick(xn.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;xC(e);const{type:n=gu,repeat:s=0,repeatDelay:o=0,repeatType:l,velocity:c=0}=e;let{keyframes:f}=e;const d=n||gu;d!==gu&&typeof f[0]!="number"&&(this.mixKeyframes=Zu(XL,_C(f[0],f[1])),f=[0,100]);const m=d({...e,keyframes:f});l==="mirror"&&(this.mirroredGenerator=d({...e,keyframes:[...f].reverse(),velocity:-c})),m.calculatedDuration===null&&(m.calculatedDuration=Db(m));const{calculatedDuration:g}=m;this.calculatedDuration=g,this.resolvedDuration=g+o,this.totalDuration=this.resolvedDuration*(s+1)-o,this.generator=m}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:o,mixKeyframes:l,mirroredGenerator:c,resolvedDuration:f,calculatedDuration:d}=this;if(this.startTime===null)return s.next(0);const{delay:m=0,keyframes:g,repeat:v,repeatType:T,repeatDelay:E,type:R,onUpdate:P,finalKeyframe:N}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-o/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const L=this.currentTime-m*(this.playbackSpeed>=0?1:-1),z=this.playbackSpeed>=0?L<0:L>o;this.currentTime=Math.max(L,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=o);let B=this.currentTime,H=s;if(v){const A=Math.min(this.currentTime,o)/f;let O=Math.floor(A),k=A%1;!k&&A>=1&&(k=1),k===1&&O--,O=Math.min(O,v+1),O%2&&(T==="reverse"?(k=1-k,E&&(k-=E/f)):T==="mirror"&&(H=c)),B=ai(0,1,k)*f}let K;z?(this.delayState.value=g[0],K=this.delayState):K=H.next(B),l&&!z&&(K.value=l(K.value));let{done:te}=K;!z&&d!==null&&(te=this.playbackSpeed>=0?this.currentTime>=o:this.currentTime<=0);const M=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&te);return M&&R!==ov&&(K.value=Em(g,this.options,N,this.speed)),P&&P(K.value),M&&this.finish(),K}then(e,n){return this.finished.then(e,n)}get duration(){return ls(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ls(e)}get time(){return ls(this.currentTime)}set time(e){e=Gn(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=e,this.tick(e))}getGeneratorVelocity(){const e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);const n=this.generator.next(e).value;return wC(s=>this.generator.next(s).value,e,n)}get speed(){return this.playbackSpeed}set speed(e){const n=this.playbackSpeed!==e;n&&this.driver&&this.updateTime(xn.now()),this.playbackSpeed=e,n&&this.driver&&(this.time=ls(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=ML,startTime:n}=this.options;this.driver||(this.driver=e(o=>this.tick(o))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(xn.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function ZL(t){for(let e=1;et*180/Math.PI,av=t=>{const e=na(Math.atan2(t[1],t[0]));return lv(e)},JL={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:av,rotateZ:av,skewX:t=>na(Math.atan(t[1])),skewY:t=>na(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},lv=t=>(t=t%360,t<0&&(t+=360),t),dE=av,mE=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),pE=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),e3={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:mE,scaleY:pE,scale:t=>(mE(t)+pE(t))/2,rotateX:t=>lv(na(Math.atan2(t[6],t[5]))),rotateY:t=>lv(na(Math.atan2(-t[2],t[0]))),rotateZ:dE,rotate:dE,skewX:t=>na(Math.atan(t[4])),skewY:t=>na(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function cv(t){return t.includes("scale")?1:0}function uv(t,e){if(!t||t==="none")return cv(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,o;if(n)s=e3,o=n;else{const f=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=JL,o=f}if(!o)return cv(e);const l=s[e],c=o[1].split(",").map(n3);return typeof l=="function"?l(c):c[l]}const t3=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return uv(n,e)};function n3(t){return parseFloat(t.trim())}const zl=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Bl=new Set(zl),gE=t=>t===Ul||t===Te,s3=new Set(["x","y","z"]),i3=zl.filter(t=>!s3.has(t));function r3(t){const e=[];return i3.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const Ur={width:({x:t},{paddingLeft:e="0",paddingRight:n="0",boxSizing:s})=>{const o=t.max-t.min;return s==="border-box"?o:o-parseFloat(e)-parseFloat(n)},height:({y:t},{paddingTop:e="0",paddingBottom:n="0",boxSizing:s})=>{const o=t.max-t.min;return s==="border-box"?o:o-parseFloat(e)-parseFloat(n)},top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>uv(e,"x"),y:(t,{transform:e})=>uv(e,"y")};Ur.translateX=Ur.x;Ur.translateY=Ur.y;const ra=new Set;let fv=!1,hv=!1,dv=!1;function EC(){if(hv){const t=Array.from(ra).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const o=r3(s);o.length&&(n.set(s,o),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const o=n.get(s);o&&o.forEach(([l,c])=>{s.getValue(l)?.set(c)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}hv=!1,fv=!1,ra.forEach(t=>t.complete(dv)),ra.clear()}function SC(){ra.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(hv=!0)})}function o3(){dv=!0,SC(),EC(),dv=!1}class Mb{constructor(e,n,s,o,l,c=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=o,this.element=l,this.isAsync=c}scheduleResolve(){this.state="scheduled",this.isAsync?(ra.add(this),fv||(fv=!0,ot.read(SC),ot.resolveKeyframes(EC))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:o}=this;if(e[0]===null){const l=o?.get(),c=e[e.length-1];if(l!==void 0)e[0]=l;else if(s&&n){const f=s.readValue(n,c);f!=null&&(e[0]=f)}e[0]===void 0&&(e[0]=c),o&&l===void 0&&o.set(e[0])}ZL(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ra.delete(this)}cancel(){this.state==="scheduled"&&(ra.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const a3=t=>t.startsWith("--");function AC(t,e,n){a3(e)?t.style.setProperty(e,n):t.style[e]=n}const l3={};function RC(t,e){const n=eC(t);return()=>l3[e]??n()}const c3=RC(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),CC=RC(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),au=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,yE={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:au([0,.65,.55,1]),circOut:au([.55,0,1,.45]),backIn:au([.31,.01,.66,-.59]),backOut:au([.33,1.53,.69,.99])};function IC(t,e){if(t)return typeof t=="function"?CC()?TC(t,e):"ease-out":fC(t)?au(t):Array.isArray(t)?t.map(n=>IC(n,e)||yE.easeOut):yE[t]}function u3(t,e,n,{delay:s=0,duration:o=300,repeat:l=0,repeatType:c="loop",ease:f="easeOut",times:d}={},m=void 0){const g={[e]:n};d&&(g.offset=d);const v=IC(f,o);Array.isArray(v)&&(g.easing=v);const T={delay:s,duration:o,easing:Array.isArray(v)?"linear":v,fill:"both",iterations:l+1,direction:c==="reverse"?"alternate":"normal"};return m&&(T.pseudoElement=m),t.animate(g,T)}function NC(t){return typeof t=="function"&&"applyToOptions"in t}function f3({type:t,...e}){return NC(t)&&CC()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class PC extends Ob{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:n,name:s,keyframes:o,pseudoElement:l,allowFlatten:c=!1,finalKeyframe:f,onComplete:d}=e;this.isPseudoElement=!!l,this.allowFlatten=c,this.options=e,Eb(typeof e.type!="string");const m=f3(e);this.animation=u3(n,s,o,m,l),m.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!l){const g=Em(o,this.options,f,this.speed);this.updateMotionValue&&this.updateMotionValue(g),AC(n,s,g),this.animation.cancel()}d?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return ls(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ls(e)}get time(){return ls(Number(this.animation.currentTime)||0)}set time(e){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Gn(e),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:n,rangeEnd:s,observe:o}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&c3()?(this.animation.timeline=e,n&&(this.animation.rangeStart=n),s&&(this.animation.rangeEnd=s),cs):o(this)}}const DC={anticipate:aC,backInOut:oC,circInOut:cC};function h3(t){return t in DC}function d3(t){typeof t.ease=="string"&&h3(t.ease)&&(t.ease=DC[t.ease])}const yy=10;class m3 extends PC{constructor(e){d3(e),xC(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:o,element:l,...c}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const f=new kd({...c,autoplay:!1}),d=Math.max(yy,xn.now()-this.startTime),m=ai(0,yy,d-yy),g=f.sample(d).value,{name:v}=this.options;l&&v&&AC(l,v,g),n.setWithVelocity(f.sample(Math.max(0,d-m)).value,g,m),f.stop()}}const vE=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Rs.test(t)||t==="0")&&!t.startsWith("url("));function p3(t){const e=t[0];if(t.length===1)return!0;for(let n=0;nObject.hasOwnProperty.call(Element.prototype,"animate"));function T3(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:o,damping:l,type:c,keyframes:f}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:m,transformTemplate:g}=e.owner.getProps();return _3()&&n&&(OC.has(n)||b3.has(n)&&v3(f))&&(n!=="transform"||!g)&&!m&&!s&&o!=="mirror"&&l!==0&&c!=="inertia"}const w3=40;class x3 extends Ob{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:o=0,repeatDelay:l=0,repeatType:c="loop",keyframes:f,name:d,motionValue:m,element:g,...v}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=xn.now();const T={autoplay:e,delay:n,type:s,repeat:o,repeatDelay:l,repeatType:c,name:d,motionValue:m,element:g,...v},E=g?.KeyframeResolver||Mb;this.keyframeResolver=new E(f,(R,P,N)=>this.onKeyframesResolved(R,P,T,!N),d,m,g),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,o){this.keyframeResolver=void 0;const{name:l,type:c,velocity:f,delay:d,isHandoff:m,onUpdate:g}=s;this.resolvedAt=xn.now();let v=!0;g3(e,l,c,f)||(v=!1,(Yr.instantAnimations||!d)&&g?.(Em(e,s,n)),e[0]=e[e.length-1],mv(s),s.repeat=0);const E={startTime:o?this.resolvedAt?this.resolvedAt-this.createdAt>w3?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},R=v&&!m&&T3(E),P=E.motionValue?.owner?.current;let N;if(R)try{N=new m3({...E,element:P})}catch{N=new kd(E)}else N=new kd(E);N.finished.then(()=>{this.notifyFinished()}).catch(cs),this.pendingTimeline&&(this.stopTimeline=N.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=N}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),o3()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}function MC(t,e,n,s=0,o=1){const l=Array.from(t).sort((m,g)=>m.sortNodePosition(g)).indexOf(e),c=t.size,f=(c-1)*s;return typeof n=="function"?n(l,c):o===1?l*s:f-l*s}const E3=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function S3(t){const e=E3.exec(t);if(!e)return[,];const[,n,s,o]=e;return[`--${n??s}`,o]}function kC(t,e,n=1){const[s,o]=S3(t);if(!s)return;const l=window.getComputedStyle(e).getPropertyValue(s);if(l){const c=l.trim();return XR(c)?parseFloat(c):c}return Cb(o)?kC(o,e,n+1):o}const A3={type:"spring",stiffness:500,damping:25,restSpeed:10},R3=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),C3={type:"keyframes",duration:.8},I3={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},N3=(t,{keyframes:e})=>e.length>2?C3:Bl.has(t)?t.startsWith("scale")?R3(e[1]):A3:I3;function VC(t,e){if(t?.inherit&&e){const{inherit:n,...s}=t;return{...e,...s}}return t}function kb(t,e){const n=t?.[e]??t?.default??t;return n!==t?VC(n,t):n}const P3=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function D3(t){for(const e in t)if(!P3.has(e))return!0;return!1}const Vb=(t,e,n,s={},o,l)=>c=>{const f=kb(s,t)||{},d=f.delay||s.delay||0;let{elapsed:m=0}=s;m=m-Gn(d);const g={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...f,delay:-m,onUpdate:T=>{e.set(T),f.onUpdate&&f.onUpdate(T)},onComplete:()=>{c(),f.onComplete&&f.onComplete()},name:t,motionValue:e,element:l?void 0:o};D3(f)||Object.assign(g,N3(t,g)),g.duration&&(g.duration=Gn(g.duration)),g.repeatDelay&&(g.repeatDelay=Gn(g.repeatDelay)),g.from!==void 0&&(g.keyframes[0]=g.from);let v=!1;if((g.type===!1||g.duration===0&&!g.repeatDelay)&&(mv(g),g.delay===0&&(v=!0)),(Yr.instantAnimations||Yr.skipAnimations||o?.shouldSkipAnimations)&&(v=!0,mv(g),g.delay=0),g.allowFlatten=!f.type&&!f.ease,v&&!l&&e.get()!==void 0){const T=Em(g.keyframes,f);if(T!==void 0){ot.update(()=>{g.onUpdate(T),g.onComplete()});return}}return f.isSync?new kd(g):new x3(g)};function bE(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function jb(t,e,n,s){if(typeof e=="function"){const[o,l]=bE(s);e=e(n!==void 0?n:t.custom,o,l)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[o,l]=bE(s);e=e(n!==void 0?n:t.custom,o,l)}return e}function oa(t,e,n){const s=t.getProps();return jb(s,e,n!==void 0?n:s.custom,t)}const jC=new Set(["width","height","top","left","right","bottom",...zl]),_E=30,O3=t=>!isNaN(parseFloat(t));class M3{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const o=xn.now();if(this.updatedAt!==o&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const l of this.dependents)l.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=xn.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=O3(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Sb);const s=this.events[e].add(n);return e==="change"?()=>{s(),ot.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=xn.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>_E)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,_E);return tC(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Il(t,e){return new M3(t,e)}const pv=t=>Array.isArray(t);function k3(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Il(n))}function V3(t){return pv(t)?t[t.length-1]||0:t}function j3(t,e){const n=oa(t,e);let{transitionEnd:s={},transition:o={},...l}=n||{};l={...l,...s};for(const c in l){const f=V3(l[c]);k3(t,c,f)}}const sn=t=>!!(t&&t.getVelocity);function L3(t){return!!(sn(t)&&t.add)}function gv(t,e){const n=t.getValue("willChange");if(L3(n))return n.add(e);if(!n&&Yr.WillChange){const s=new Yr.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Lb(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const U3="framerAppearId",LC="data-"+Lb(U3);function UC(t){return t.props[LC]}function z3({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function zC(t,e,{delay:n=0,transitionOverride:s,type:o}={}){let{transition:l,transitionEnd:c,...f}=e;const d=t.getDefaultTransition();l=l?VC(l,d):d;const m=l?.reduceMotion;s&&(l=s);const g=[],v=o&&t.animationState&&t.animationState.getState()[o];for(const T in f){const E=t.getValue(T,t.latestValues[T]??null),R=f[T];if(R===void 0||v&&z3(v,T))continue;const P={delay:n,...kb(l||{},T)},N=E.get();if(N!==void 0&&!E.isAnimating()&&!Array.isArray(R)&&R===N&&!P.velocity){ot.update(()=>E.set(R));continue}let L=!1;if(window.MotionHandoffAnimation){const H=UC(t);if(H){const K=window.MotionHandoffAnimation(H,T,ot);K!==null&&(P.startTime=K,L=!0)}}gv(t,T);const z=m??t.shouldReduceMotion;E.start(Vb(T,E,R,z&&jC.has(T)?{type:!1}:P,t,L));const B=E.animation;B&&g.push(B)}if(c){const T=()=>ot.update(()=>{c&&j3(t,c)});g.length?Promise.all(g).then(T):T()}return g}function yv(t,e,n={}){const s=oa(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:o=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(o=n.transitionOverride);const l=s?()=>Promise.all(zC(t,s,n)):()=>Promise.resolve(),c=t.variantChildren&&t.variantChildren.size?(d=0)=>{const{delayChildren:m=0,staggerChildren:g,staggerDirection:v}=o;return B3(t,e,d,m,g,v,n)}:()=>Promise.resolve(),{when:f}=o;if(f){const[d,m]=f==="beforeChildren"?[l,c]:[c,l];return d().then(()=>m())}else return Promise.all([l(),c(n.delay)])}function B3(t,e,n=0,s=0,o=0,l=1,c){const f=[];for(const d of t.variantChildren)d.notify("AnimationStart",e),f.push(yv(d,e,{...c,delay:n+(typeof s=="function"?0:s)+MC(t.variantChildren,d,s,o,l)}).then(()=>d.notify("AnimationComplete",e)));return Promise.all(f)}function F3(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const o=e.map(l=>yv(t,l,n));s=Promise.all(o)}else if(typeof e=="string")s=yv(t,e,n);else{const o=typeof e=="function"?oa(t,e,n.custom):e;s=Promise.all(zC(t,o,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}const q3={test:t=>t==="auto",parse:t=>t},BC=t=>e=>e.test(t),FC=[Ul,Te,ni,kr,pL,mL,q3],TE=t=>FC.find(BC(t));function H3(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||JR(t):!0}const G3=new Set(["brightness","contrast","saturate","opacity"]);function $3(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(Ib)||[];if(!s)return t;const o=n.replace(s,"");let l=G3.has(e)?1:0;return s!==n&&(l*=100),e+"("+l+o+")"}const K3=/\b([a-z-]*)\(.*?\)/gu,vv={...Rs,getAnimatableNone:t=>{const e=t.match(K3);return e?e.map($3).join(" "):t}},bv={...Rs,getAnimatableNone:t=>{const e=Rs.parse(t);return Rs.createTransformer(t)(e.map(s=>typeof s=="number"?0:typeof s=="object"?{...s,alpha:1}:s))}},wE={...Ul,transform:Math.round},Q3={rotate:kr,rotateX:kr,rotateY:kr,rotateZ:kr,scale:Hh,scaleX:Hh,scaleY:Hh,scaleZ:Hh,skew:kr,skewX:kr,skewY:kr,distance:Te,translateX:Te,translateY:Te,translateZ:Te,x:Te,y:Te,z:Te,perspective:Te,transformPerspective:Te,opacity:Du,originX:lE,originY:lE,originZ:Te},Ub={borderWidth:Te,borderTopWidth:Te,borderRightWidth:Te,borderBottomWidth:Te,borderLeftWidth:Te,borderRadius:Te,borderTopLeftRadius:Te,borderTopRightRadius:Te,borderBottomRightRadius:Te,borderBottomLeftRadius:Te,width:Te,maxWidth:Te,height:Te,maxHeight:Te,top:Te,right:Te,bottom:Te,left:Te,inset:Te,insetBlock:Te,insetBlockStart:Te,insetBlockEnd:Te,insetInline:Te,insetInlineStart:Te,insetInlineEnd:Te,padding:Te,paddingTop:Te,paddingRight:Te,paddingBottom:Te,paddingLeft:Te,paddingBlock:Te,paddingBlockStart:Te,paddingBlockEnd:Te,paddingInline:Te,paddingInlineStart:Te,paddingInlineEnd:Te,margin:Te,marginTop:Te,marginRight:Te,marginBottom:Te,marginLeft:Te,marginBlock:Te,marginBlockStart:Te,marginBlockEnd:Te,marginInline:Te,marginInlineStart:Te,marginInlineEnd:Te,fontSize:Te,backgroundPositionX:Te,backgroundPositionY:Te,...Q3,zIndex:wE,fillOpacity:Du,strokeOpacity:Du,numOctaves:wE},Y3={...Ub,color:Pt,backgroundColor:Pt,outlineColor:Pt,fill:Pt,stroke:Pt,borderColor:Pt,borderTopColor:Pt,borderRightColor:Pt,borderBottomColor:Pt,borderLeftColor:Pt,filter:vv,WebkitFilter:vv,mask:bv,WebkitMask:bv},qC=t=>Y3[t],W3=new Set([vv,bv]);function HC(t,e){let n=qC(t);return W3.has(n)||(n=Rs),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const X3=new Set(["auto","none","0"]);function Z3(t,e,n){let s=0,o;for(;s{e.getValue(f).set(d)}),this.resolveNoneKeyframes()}}function GC(t,e,n){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const o=n?.[t]??s.querySelectorAll(t);return o?Array.from(o):[]}return Array.from(t).filter(s=>s!=null)}const $C=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function rd(t){return ZR(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:zb}=hC(queueMicrotask,!1),Es={x:!1,y:!1};function KC(){return Es.x||Es.y}function e6(t){return t==="x"||t==="y"?Es[t]?null:(Es[t]=!0,()=>{Es[t]=!1}):Es.x||Es.y?null:(Es.x=Es.y=!0,()=>{Es.x=Es.y=!1})}function QC(t,e){const n=GC(t),s=new AbortController,o={passive:!0,...e,signal:s.signal};return[n,o,()=>s.abort()]}function t6(t){return!(t.pointerType==="touch"||KC())}function n6(t,e,n={}){const[s,o,l]=QC(t,n);return s.forEach(c=>{let f=!1,d=!1,m;const g=()=>{c.removeEventListener("pointerleave",R)},v=N=>{m&&(m(N),m=void 0),g()},T=N=>{f=!1,window.removeEventListener("pointerup",T),window.removeEventListener("pointercancel",T),d&&(d=!1,v(N))},E=()=>{f=!0,window.addEventListener("pointerup",T,o),window.addEventListener("pointercancel",T,o)},R=N=>{if(N.pointerType!=="touch"){if(f){d=!0;return}v(N)}},P=N=>{if(!t6(N))return;d=!1;const L=e(c,N);typeof L=="function"&&(m=L,c.addEventListener("pointerleave",R,o))};c.addEventListener("pointerenter",P,o),c.addEventListener("pointerdown",E,o)}),l}const YC=(t,e)=>e?t===e?!0:YC(t,e.parentElement):!1,Bb=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,s6=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function i6(t){return s6.has(t.tagName)||t.isContentEditable===!0}const r6=new Set(["INPUT","SELECT","TEXTAREA"]);function o6(t){return r6.has(t.tagName)||t.isContentEditable===!0}const od=new WeakSet;function xE(t){return e=>{e.key==="Enter"&&t(e)}}function vy(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const a6=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=xE(()=>{if(od.has(n))return;vy(n,"down");const o=xE(()=>{vy(n,"up")}),l=()=>vy(n,"cancel");n.addEventListener("keyup",o,e),n.addEventListener("blur",l,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function EE(t){return Bb(t)&&!KC()}const SE=new WeakSet;function l6(t,e,n={}){const[s,o,l]=QC(t,n),c=f=>{const d=f.currentTarget;if(!EE(f)||SE.has(f))return;od.add(d),n.stopPropagation&&SE.add(f);const m=e(d,f),g=(E,R)=>{window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",T),od.has(d)&&od.delete(d),EE(E)&&typeof m=="function"&&m(E,{success:R})},v=E=>{g(E,d===window||d===document||n.useGlobalTarget||YC(d,E.target))},T=E=>{g(E,!1)};window.addEventListener("pointerup",v,o),window.addEventListener("pointercancel",T,o)};return s.forEach(f=>{(n.useGlobalTarget?window:f).addEventListener("pointerdown",c,o),rd(f)&&(f.addEventListener("focus",m=>a6(m,o)),!i6(f)&&!f.hasAttribute("tabindex")&&(f.tabIndex=0))}),l}function Fb(t){return ZR(t)&&"ownerSVGElement"in t}const ad=new WeakMap;let ld;const WC=(t,e,n)=>(s,o)=>o&&o[0]?o[0][t+"Size"]:Fb(s)&&"getBBox"in s?s.getBBox()[e]:s[n],c6=WC("inline","width","offsetWidth"),u6=WC("block","height","offsetHeight");function f6({target:t,borderBoxSize:e}){ad.get(t)?.forEach(n=>{n(t,{get width(){return c6(t,e)},get height(){return u6(t,e)}})})}function h6(t){t.forEach(f6)}function d6(){typeof ResizeObserver>"u"||(ld=new ResizeObserver(h6))}function m6(t,e){ld||d6();const n=GC(t);return n.forEach(s=>{let o=ad.get(s);o||(o=new Set,ad.set(s,o)),o.add(e),ld?.observe(s)}),()=>{n.forEach(s=>{const o=ad.get(s);o?.delete(e),o?.size||ld?.unobserve(s)})}}const cd=new Set;let pl;function p6(){pl=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};cd.forEach(e=>e(t))},window.addEventListener("resize",pl)}function g6(t){return cd.add(t),pl||p6(),()=>{cd.delete(t),!cd.size&&typeof pl=="function"&&(window.removeEventListener("resize",pl),pl=void 0)}}function AE(t,e){return typeof t=="function"?g6(t):m6(t,e)}function y6(t){return Fb(t)&&t.tagName==="svg"}const v6=[...FC,Pt,Rs],b6=t=>v6.find(BC(t)),RE=()=>({translate:0,scale:1,origin:0,originPoint:0}),gl=()=>({x:RE(),y:RE()}),CE=()=>({min:0,max:0}),zt=()=>({x:CE(),y:CE()}),_6=new WeakMap;function Sm(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Ou(t){return typeof t=="string"||Array.isArray(t)}const qb=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Hb=["initial",...qb];function Am(t){return Sm(t.animate)||Hb.some(e=>Ou(t[e]))}function XC(t){return!!(Am(t)||t.variants)}function T6(t,e,n){for(const s in e){const o=e[s],l=n[s];if(sn(o))t.addValue(s,o);else if(sn(l))t.addValue(s,Il(o,{owner:t}));else if(l!==o)if(t.hasValue(s)){const c=t.getValue(s);c.liveStyle===!0?c.jump(o):c.hasAnimated||c.set(o)}else{const c=t.getStaticValue(s);t.addValue(s,Il(c!==void 0?c:o,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const _v={current:null},ZC={current:!1},w6=typeof window<"u";function x6(){if(ZC.current=!0,!!w6)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>_v.current=t.matches;t.addEventListener("change",e),e()}else _v.current=!1}const IE=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Vd={};function JC(t){Vd=t}function E6(){return Vd}class S6{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:o,skipAnimations:l,blockInitialAnimation:c,visualState:f},d={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Mb,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const E=xn.now();this.renderScheduledAtthis.bindToMotionValue(s,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(ZC.current||x6(),this.shouldReduceMotion=_v.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Wr(this.notifyUpdate),Wr(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),n.accelerate&&OC.has(e)&&this.current instanceof HTMLElement){const{factory:c,keyframes:f,times:d,ease:m,duration:g}=n.accelerate,v=new PC({element:this.current,name:e,keyframes:f,times:d,ease:m,duration:Gn(g)}),T=c(v);this.valueSubscriptions.set(e,()=>{T(),v.cancel()});return}const s=Bl.has(e);s&&this.onBindTransform&&this.onBindTransform();const o=n.on("change",c=>{this.latestValues[e]=c,this.props.onUpdate&&ot.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let l;typeof window<"u"&&window.MotionCheckAppearSync&&(l=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{o(),l&&l(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Vd){const n=Vd[e];if(!n)continue;const{isEnabled:s,Feature:o}=n;if(!this.features[e]&&o&&s(this.props)&&(this.features[e]=new o(this)),this.features[e]){const l=this.features[e];l.isMounted?l.update():(l.mount(),l.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):zt()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;sn.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=Il(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&(XR(s)||JR(s))?s=parseFloat(s):!b6(s)&&Rs.test(n)&&(s=HC(e,n)),this.setBaseTarget(e,sn(s)?s.get():s)),sn(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const l=jb(this.props,n,this.presenceContext?.custom);l&&(s=l[e])}if(n&&s!==void 0)return s;const o=this.getBaseTargetFromProps(this.props,e);return o!==void 0&&!sn(o)?o:this.initialValues[e]!==void 0&&s===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Sb),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){zb.render(this.render)}}class e2 extends S6{constructor(){super(...arguments),this.KeyframeResolver=J3}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){const s=e.style;return s?s[n]:void 0}removeValueFromRenderState(e,{vars:n,style:s}){delete n[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;sn(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class oo{constructor(e){this.isMounted=!1,this.node=e}update(){}}function t2({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function A6({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function R6(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function by(t){return t===void 0||t===1}function Tv({scale:t,scaleX:e,scaleY:n}){return!by(t)||!by(e)||!by(n)}function Zo(t){return Tv(t)||n2(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function n2(t){return NE(t.x)||NE(t.y)}function NE(t){return t&&t!=="0%"}function jd(t,e,n){const s=t-n,o=e*s;return n+o}function PE(t,e,n,s,o){return o!==void 0&&(t=jd(t,o,s)),jd(t,n,s)+e}function wv(t,e=0,n=1,s,o){t.min=PE(t.min,e,n,s,o),t.max=PE(t.max,e,n,s,o)}function s2(t,{x:e,y:n}){wv(t.x,e.translate,e.scale,e.originPoint),wv(t.y,n.translate,n.scale,n.originPoint)}const DE=.999999999999,OE=1.0000000000001;function C6(t,e,n,s=!1){const o=n.length;if(!o)return;e.x=e.y=1;let l,c;for(let f=0;fDE&&(e.x=1),e.yDE&&(e.y=1)}function Js(t,e){t.min+=e,t.max+=e}function ME(t,e,n,s,o=.5){const l=ht(t.min,t.max,o);wv(t,e,n,l,s)}function kE(t,e){return typeof t=="string"?parseFloat(t)/100*(e.max-e.min):t}function ud(t,e,n){const s=n??t;ME(t.x,kE(e.x,s.x),e.scaleX,e.scale,e.originX),ME(t.y,kE(e.y,s.y),e.scaleY,e.scale,e.originY)}function i2(t,e){return t2(R6(t.getBoundingClientRect(),e))}function I6(t,e,n){const s=i2(t,n),{scroll:o}=e;return o&&(Js(s.x,o.offset.x),Js(s.y,o.offset.y)),s}const N6={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},P6=zl.length;function D6(t,e,n){let s="",o=!0;for(let l=0;l{if(!e.target)return t;if(typeof t=="string")if(Te.test(t))t=parseFloat(t);else return t;const n=VE(t,e.target.x),s=VE(t,e.target.y);return`${n}% ${s}%`}},O6={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,o=Rs.parse(t);if(o.length>5)return s;const l=Rs.createTransformer(t),c=typeof o[0]!="number"?1:0,f=n.x.scale*e.x,d=n.y.scale*e.y;o[0+c]/=f,o[1+c]/=d;const m=ht(f,d,.5);return typeof o[2+c]=="number"&&(o[2+c]/=m),typeof o[3+c]=="number"&&(o[3+c]/=m),l(o)}},xv={borderRadius:{...su,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:su,borderTopRightRadius:su,borderBottomLeftRadius:su,borderBottomRightRadius:su,boxShadow:O6};function o2(t,{layout:e,layoutId:n}){return Bl.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!xv[t]||t==="opacity")}function $b(t,e,n){const s=t.style,o=e?.style,l={};if(!s)return l;for(const c in s)(sn(s[c])||o&&sn(o[c])||o2(c,t)||n?.getValue(c)?.liveStyle!==void 0)&&(l[c]=s[c]);return l}function M6(t){return window.getComputedStyle(t)}class k6 extends e2{constructor(){super(...arguments),this.type="html",this.renderInstance=r2}readValueFromInstance(e,n){if(Bl.has(n))return this.projection?.isProjecting?cv(n):t3(e,n);{const s=M6(e),o=(mC(n)?s.getPropertyValue(n):s[n])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(e,{transformPagePoint:n}){return i2(e,n)}build(e,n,s){Gb(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return $b(e,n,s)}}const V6={offset:"stroke-dashoffset",array:"stroke-dasharray"},j6={offset:"strokeDashoffset",array:"strokeDasharray"};function L6(t,e,n=1,s=0,o=!0){t.pathLength=1;const l=o?V6:j6;t[l.offset]=`${-s}`,t[l.array]=`${e} ${n}`}const U6=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function a2(t,{attrX:e,attrY:n,attrScale:s,pathLength:o,pathSpacing:l=1,pathOffset:c=0,...f},d,m,g){if(Gb(t,f,m),d){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:v,style:T}=t;v.transform&&(T.transform=v.transform,delete v.transform),(T.transform||v.transformOrigin)&&(T.transformOrigin=v.transformOrigin??"50% 50%",delete v.transformOrigin),T.transform&&(T.transformBox=g?.transformBox??"fill-box",delete v.transformBox);for(const E of U6)v[E]!==void 0&&(T[E]=v[E],delete v[E]);e!==void 0&&(v.x=e),n!==void 0&&(v.y=n),s!==void 0&&(v.scale=s),o!==void 0&&L6(v,o,l,c,!1)}const l2=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),c2=t=>typeof t=="string"&&t.toLowerCase()==="svg";function z6(t,e,n,s){r2(t,e,void 0,s);for(const o in e.attrs)t.setAttribute(l2.has(o)?o:Lb(o),e.attrs[o])}function u2(t,e,n){const s=$b(t,e,n);for(const o in t)if(sn(t[o])||sn(e[o])){const l=zl.indexOf(o)!==-1?"attr"+o.charAt(0).toUpperCase()+o.substring(1):o;s[l]=t[o]}return s}class B6 extends e2{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=zt}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Bl.has(n)){const s=qC(n);return s&&s.default||0}return n=l2.has(n)?n:Lb(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return u2(e,n,s)}build(e,n,s){a2(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,o){z6(e,n,s,o)}mount(e){this.isSVGTag=c2(e.tagName),super.mount(e)}}const F6=Hb.length;function f2(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?f2(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;nPromise.all(e.map(({animation:n,options:s})=>F3(t,n,s)))}function $6(t){let e=G6(t),n=jE(),s=!0,o=!1;const l=m=>(g,v)=>{const T=oa(t,v,m==="exit"?t.presenceContext?.custom:void 0);if(T){const{transition:E,transitionEnd:R,...P}=T;g={...g,...P,...R}}return g};function c(m){e=m(t)}function f(m){const{props:g}=t,v=f2(t.parent)||{},T=[],E=new Set;let R={},P=1/0;for(let L=0;LP&&K,k=!1;const j=Array.isArray(H)?H:[H];let F=j.reduce(l(z),{});te===!1&&(F={});const{prevResolvedValues:V={}}=B,ue={...V,...F},ye=se=>{O=!0,E.has(se)&&(k=!0,E.delete(se)),B.needsAnimating[se]=!0;const pe=t.getValue(se);pe&&(pe.liveStyle=!1)};for(const se in ue){const pe=F[se],S=V[se];if(R.hasOwnProperty(se))continue;let Q=!1;pv(pe)&&pv(S)?Q=!h2(pe,S):Q=pe!==S,Q?pe!=null?ye(se):E.add(se):pe!==void 0&&E.has(se)?ye(se):B.protectedKeys[se]=!0}B.prevProp=H,B.prevResolvedValues=F,B.isActive&&(R={...R,...F}),(s||o)&&t.blockInitialAnimation&&(O=!1);const $=M&&A;O&&(!$||k)&&T.push(...j.map(se=>{const pe={type:z};if(typeof se=="string"&&(s||o)&&!&t.manuallyAnimateOnMount&&t.parent){const{parent:S}=t,Q=oa(S,se);if(S.enteringChildren&&Q){const{delayChildren:ce}=Q.transition||{};pe.delay=MC(S.enteringChildren,t,ce)}}return{animation:se,options:pe}}))}if(E.size){const L={};if(typeof g.initial!="boolean"){const z=oa(t,Array.isArray(g.initial)?g.initial[0]:g.initial);z&&z.transition&&(L.transition=z.transition)}E.forEach(z=>{const B=t.getBaseTarget(z),H=t.getValue(z);H&&(H.liveStyle=!0),L[z]=B??null}),T.push({animation:L})}let N=!!T.length;return s&&(g.initial===!1||g.initial===g.animate)&&!t.manuallyAnimateOnMount&&(N=!1),s=!1,o=!1,N?e(T):Promise.resolve()}function d(m,g){if(n[m].isActive===g)return Promise.resolve();t.variantChildren?.forEach(T=>T.animationState?.setActive(m,g)),n[m].isActive=g;const v=f(m);for(const T in n)n[T].protectedKeys={};return v}return{animateChanges:f,setActive:d,setAnimateFunction:c,getState:()=>n,reset:()=>{n=jE(),o=!0}}}function K6(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!h2(e,t):!1}function Wo(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function jE(){return{animate:Wo(!0),whileInView:Wo(),whileHover:Wo(),whileTap:Wo(),whileDrag:Wo(),whileFocus:Wo(),exit:Wo()}}function Ev(t,e){t.min=e.min,t.max=e.max}function xs(t,e){Ev(t.x,e.x),Ev(t.y,e.y)}function LE(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const d2=1e-4,Q6=1-d2,Y6=1+d2,m2=.01,W6=0-m2,X6=0+m2;function En(t){return t.max-t.min}function Z6(t,e,n){return Math.abs(t-e)<=n}function UE(t,e,n,s=.5){t.origin=s,t.originPoint=ht(e.min,e.max,t.origin),t.scale=En(n)/En(e),t.translate=ht(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Q6&&t.scale<=Y6||isNaN(t.scale))&&(t.scale=1),(t.translate>=W6&&t.translate<=X6||isNaN(t.translate))&&(t.translate=0)}function yu(t,e,n,s){UE(t.x,e.x,n.x,s?s.originX:void 0),UE(t.y,e.y,n.y,s?s.originY:void 0)}function zE(t,e,n,s=0){const o=s?ht(n.min,n.max,s):n.min;t.min=o+e.min,t.max=t.min+En(e)}function J6(t,e,n,s){zE(t.x,e.x,n.x,s?.x),zE(t.y,e.y,n.y,s?.y)}function BE(t,e,n,s=0){const o=s?ht(n.min,n.max,s):n.min;t.min=e.min-o,t.max=t.min+En(e)}function Ld(t,e,n,s){BE(t.x,e.x,n.x,s?.x),BE(t.y,e.y,n.y,s?.y)}function FE(t,e,n,s,o){return t-=e,t=jd(t,1/n,s),o!==void 0&&(t=jd(t,1/o,s)),t}function eU(t,e=0,n=1,s=.5,o,l=t,c=t){if(ni.test(e)&&(e=parseFloat(e),e=ht(c.min,c.max,e/100)-c.min),typeof e!="number")return;let f=ht(l.min,l.max,s);t===l&&(f-=e),t.min=FE(t.min,e,n,f,o),t.max=FE(t.max,e,n,f,o)}function qE(t,e,[n,s,o],l,c){eU(t,e[n],e[s],e[o],e.scale,l,c)}const tU=["x","scaleX","originX"],nU=["y","scaleY","originY"];function HE(t,e,n,s){qE(t.x,e,tU,n?n.x:void 0,s?s.x:void 0),qE(t.y,e,nU,n?n.y:void 0,s?s.y:void 0)}function GE(t){return t.translate===0&&t.scale===1}function p2(t){return GE(t.x)&&GE(t.y)}function $E(t,e){return t.min===e.min&&t.max===e.max}function sU(t,e){return $E(t.x,e.x)&&$E(t.y,e.y)}function KE(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function g2(t,e){return KE(t.x,e.x)&&KE(t.y,e.y)}function QE(t){return En(t.x)/En(t.y)}function YE(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function Xs(t){return[t("x"),t("y")]}function iU(t,e,n){let s="";const o=t.x.translate/e.x,l=t.y.translate/e.y,c=n?.z||0;if((o||l||c)&&(s=`translate3d(${o}px, ${l}px, ${c}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:m,rotate:g,rotateX:v,rotateY:T,skewX:E,skewY:R}=n;m&&(s=`perspective(${m}px) ${s}`),g&&(s+=`rotate(${g}deg) `),v&&(s+=`rotateX(${v}deg) `),T&&(s+=`rotateY(${T}deg) `),E&&(s+=`skewX(${E}deg) `),R&&(s+=`skewY(${R}deg) `)}const f=t.x.scale*e.x,d=t.y.scale*e.y;return(f!==1||d!==1)&&(s+=`scale(${f}, ${d})`),s||"none"}const y2=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],rU=y2.length,WE=t=>typeof t=="string"?parseFloat(t):t,XE=t=>typeof t=="number"||Te.test(t);function oU(t,e,n,s,o,l){o?(t.opacity=ht(0,n.opacity??1,aU(s)),t.opacityExit=ht(e.opacity??1,0,lU(s))):l&&(t.opacity=ht(e.opacity??1,n.opacity??1,s));for(let c=0;cse?1:n(Pu(t,e,s))}function cU(t,e,n){const s=sn(t)?t:Il(t);return s.start(Vb("",s,e,n)),s.animation}function Mu(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}const uU=(t,e)=>t.depth-e.depth;class fU{constructor(){this.children=[],this.isDirty=!1}add(e){xb(this.children,e),this.isDirty=!0}remove(e){Pd(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(uU),this.isDirty=!1,this.children.forEach(e)}}function hU(t,e){const n=xn.now(),s=({timestamp:o})=>{const l=o-n;l>=e&&(Wr(s),t(l-e))};return ot.setup(s,!0),()=>Wr(s)}function fd(t){return sn(t)?t.get():t}class dU{constructor(){this.members=[]}add(e){xb(this.members,e);for(let n=this.members.length-1;n>=0;n--){const s=this.members[n];if(s===e||s===this.lead||s===this.prevLead)continue;const o=s.instance;(!o||o.isConnected===!1)&&!s.snapshot&&(Pd(this.members,s),s.unmount())}e.scheduleRender()}remove(e){if(Pd(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){for(let n=this.members.indexOf(e)-1;n>=0;n--){const s=this.members[n];if(s.isPresent!==!1&&s.instance?.isConnected!==!1)return this.promote(s),!0}return!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.updateSnapshot(),e.scheduleRender();const{layoutDependency:o}=s.options,{layoutDependency:l}=e.options;(o===void 0||o!==l)&&(e.resumeFrom=s,n&&(s.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}}const hd={hasAnimatedSinceResize:!0,hasEverUpdated:!1},_y=["","X","Y","Z"],mU=1e3;let pU=0;function Ty(t,e,n,s){const{latestValues:o}=e;o[t]&&(n[t]=o[t],e.setStaticValue(t,0),s&&(s[t]=0))}function b2(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=UC(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:o,layoutId:l}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",ot,!(o||l))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&b2(s)}function _2({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:o}){return class{constructor(c={},f=e?.()){this.id=pU++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(vU),this.nodes.forEach(EU),this.nodes.forEach(SU),this.nodes.forEach(bU)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=c,this.root=f?f.root||f:this,this.path=f?[...f.path,f]:[],this.parent=f,this.depth=f?f.depth+1:0;for(let d=0;dthis.root.updateBlockedByResize=!1;ot.read(()=>{v=window.innerWidth}),t(c,()=>{const E=window.innerWidth;E!==v&&(v=E,this.root.updateBlockedByResize=!0,g&&g(),g=hU(T,250),hd.hasAnimatedSinceResize&&(hd.hasAnimatedSinceResize=!1,this.nodes.forEach(tS)))})}f&&this.root.registerSharedNode(f,this),this.options.animate!==!1&&m&&(f||d)&&this.addEventListener("didUpdate",({delta:g,hasLayoutChanged:v,hasRelativeLayoutChanged:T,layout:E})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const R=this.options.transition||m.getDefaultTransition()||NU,{onLayoutAnimationStart:P,onLayoutAnimationComplete:N}=m.getProps(),L=!this.targetLayout||!g2(this.targetLayout,E),z=!v&&T;if(this.options.layoutRoot||this.resumeFrom||z||v&&(L||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const B={...kb(R,"layout"),onPlay:P,onComplete:N};(m.shouldReduceMotion||this.options.layoutRoot)&&(B.delay=0,B.type=!1),this.startAnimation(B),this.setAnimationOrigin(g,z)}else v||tS(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=E})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const c=this.getStack();c&&c.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Wr(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(AU),this.animationId++)}getTransformTemplate(){const{visualElement:c}=this.options;return c&&c.getProps().transformTemplate}willUpdate(c=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&b2(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let g=0;g{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!En(this.snapshot.measuredBox.x)&&!En(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let d=0;d{const K=H/1e3;nS(v.x,c.x,K),nS(v.y,c.y,K),this.setTargetDelta(v),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Ld(T,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),CU(this.relativeTarget,this.relativeTargetOrigin,T,K),B&&sU(this.relativeTarget,B)&&(this.isProjectionDirty=!1),B||(B=zt()),xs(B,this.relativeTarget)),P&&(this.animationValues=g,oU(g,m,this.latestValues,K,z,L)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=K},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(c){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Wr(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ot.update(()=>{hd.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Il(0)),this.motionValue.jump(0,!1),this.currentAnimation=cU(this.motionValue,[0,1e3],{...c,velocity:0,isSync:!0,onUpdate:f=>{this.mixTargetDelta(f),c.onUpdate&&c.onUpdate(f)},onStop:()=>{},onComplete:()=>{c.onComplete&&c.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const c=this.getStack();c&&c.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(mU),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const c=this.getLead();let{targetWithTransforms:f,target:d,layout:m,latestValues:g}=c;if(!(!f||!d||!m)){if(this!==c&&this.layout&&m&&T2(this.options.animationType,this.layout.layoutBox,m.layoutBox)){d=this.target||zt();const v=En(this.layout.layoutBox.x);d.x.min=c.target.x.min,d.x.max=d.x.min+v;const T=En(this.layout.layoutBox.y);d.y.min=c.target.y.min,d.y.max=d.y.min+T}xs(f,d),ud(f,g),yu(this.projectionDeltaWithTransform,this.layoutCorrected,f,g)}}registerSharedNode(c,f){this.sharedNodes.has(c)||this.sharedNodes.set(c,new dU),this.sharedNodes.get(c).add(f);const m=f.options.initialPromotionConfig;f.promote({transition:m?m.transition:void 0,preserveFollowOpacity:m&&m.shouldPreserveFollowOpacity?m.shouldPreserveFollowOpacity(f):void 0})}isLead(){const c=this.getStack();return c?c.lead===this:!0}getLead(){const{layoutId:c}=this.options;return c?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:c}=this.options;return c?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:c}=this.options;if(c)return this.root.sharedNodes.get(c)}promote({needsReset:c,transition:f,preserveFollowOpacity:d}={}){const m=this.getStack();m&&m.promote(this,d),c&&(this.projectionDelta=void 0,this.needsReset=!0),f&&this.setOptions({transition:f})}relegate(){const c=this.getStack();return c?c.relegate(this):!1}resetSkewAndRotation(){const{visualElement:c}=this.options;if(!c)return;let f=!1;const{latestValues:d}=c;if((d.z||d.rotate||d.rotateX||d.rotateY||d.rotateZ||d.skewX||d.skewY)&&(f=!0),!f)return;const m={};d.z&&Ty("z",c,m,this.animationValues);for(let g=0;g<_y.length;g++)Ty(`rotate${_y[g]}`,c,m,this.animationValues),Ty(`skew${_y[g]}`,c,m,this.animationValues);c.render();for(const g in m)c.setStaticValue(g,m[g]),this.animationValues&&(this.animationValues[g]=m[g]);c.scheduleRender()}applyProjectionStyles(c,f){if(!this.instance||this.isSVG)return;if(!this.isVisible){c.visibility="hidden";return}const d=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,c.visibility="",c.opacity="",c.pointerEvents=fd(f?.pointerEvents)||"",c.transform=d?d(this.latestValues,""):"none";return}const m=this.getLead();if(!this.projectionDelta||!this.layout||!m.target){this.options.layoutId&&(c.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,c.pointerEvents=fd(f?.pointerEvents)||""),this.hasProjected&&!Zo(this.latestValues)&&(c.transform=d?d({},""):"none",this.hasProjected=!1);return}c.visibility="";const g=m.animationValues||m.latestValues;this.applyTransformsToTarget();let v=iU(this.projectionDeltaWithTransform,this.treeScale,g);d&&(v=d(g,v)),c.transform=v;const{x:T,y:E}=this.projectionDelta;c.transformOrigin=`${T.origin*100}% ${E.origin*100}% 0`,m.animationValues?c.opacity=m===this?g.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:g.opacityExit:c.opacity=m===this?g.opacity!==void 0?g.opacity:"":g.opacityExit!==void 0?g.opacityExit:0;for(const R in xv){if(g[R]===void 0)continue;const{correct:P,applyTo:N,isCSSVariable:L}=xv[R],z=v==="none"?g[R]:P(g[R],m);if(N){const B=N.length;for(let H=0;Hc.currentAnimation?.stop()),this.root.nodes.forEach(JE),this.root.sharedNodes.clear()}}}function gU(t){t.updateLayout()}function yU(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:o}=t.options,l=e.source!==t.layout.source;if(o==="size")Xs(g=>{const v=l?e.measuredBox[g]:e.layoutBox[g],T=En(v);v.min=n[g].min,v.max=v.min+T});else if(o==="x"||o==="y"){const g=o==="x"?"y":"x";Ev(l?e.measuredBox[g]:e.layoutBox[g],n[g])}else T2(o,e.layoutBox,n)&&Xs(g=>{const v=l?e.measuredBox[g]:e.layoutBox[g],T=En(n[g]);v.max=v.min+T,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[g].max=t.relativeTarget[g].min+T)});const c=gl();yu(c,n,e.layoutBox);const f=gl();l?yu(f,t.applyTransform(s,!0),e.measuredBox):yu(f,n,e.layoutBox);const d=!p2(c);let m=!1;if(!t.resumeFrom){const g=t.getClosestProjectingParent();if(g&&!g.resumeFrom){const{snapshot:v,layout:T}=g;if(v&&T){const E=t.options.layoutAnchor||void 0,R=zt();Ld(R,e.layoutBox,v.layoutBox,E);const P=zt();Ld(P,n,T.layoutBox,E),g2(R,P)||(m=!0),g.options.layoutRoot&&(t.relativeTarget=P,t.relativeTargetOrigin=R,t.relativeParent=g)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:f,layoutDelta:c,hasLayoutChanged:d,hasRelativeLayoutChanged:m})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function vU(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function bU(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function _U(t){t.clearSnapshot()}function JE(t){t.clearMeasurements()}function TU(t){t.isLayoutDirty=!0,t.updateLayout()}function eS(t){t.isLayoutDirty=!1}function wU(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function xU(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function tS(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function EU(t){t.resolveTargetDelta()}function SU(t){t.calcProjection()}function AU(t){t.resetSkewAndRotation()}function RU(t){t.removeLeadSnapshot()}function nS(t,e,n){t.translate=ht(e.translate,0,n),t.scale=ht(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function sS(t,e,n,s){t.min=ht(e.min,n.min,s),t.max=ht(e.max,n.max,s)}function CU(t,e,n,s){sS(t.x,e.x,n.x,s),sS(t.y,e.y,n.y,s)}function IU(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const NU={duration:.45,ease:[.4,0,.1,1]},iS=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),rS=iS("applewebkit/")&&!iS("chrome/")?Math.round:cs;function oS(t){t.min=rS(t.min),t.max=rS(t.max)}function PU(t){oS(t.x),oS(t.y)}function T2(t,e,n){return t==="position"||t==="preserve-aspect"&&!Z6(QE(e),QE(n),.2)}function DU(t){return t!==t.root&&t.scroll?.wasRoot}const OU=_2({attachResizeListener:(t,e)=>Mu(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),wy={current:void 0},w2=_2({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!wy.current){const t=new OU({});t.mount(window),t.setOptions({layoutScroll:!0}),wy.current=t}return wy.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Kb=I.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function aS(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function MU(...t){return e=>{let n=!1;const s=t.map(o=>{const l=aS(o,e);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let o=0;o{const{width:T,height:E,top:R,left:P,right:N,bottom:L}=d.current;if(e||l===!1||!f.current||!T||!E)return;const z=n==="left"?`left: ${P}`:`right: ${N}`,B=s==="bottom"?`bottom: ${L}`:`top: ${R}`;f.current.dataset.motionPopId=c;const H=document.createElement("style");m&&(H.nonce=m);const K=o??document.head;return K.appendChild(H),H.sheet&&H.sheet.insertRule(` [data-motion-pop-id="${c}"] { position: absolute !important; width: ${T}px !important; height: ${E}px !important; ${z}px !important; ${B}px !important; } `),()=>{f.current?.removeAttribute("data-motion-pop-id"),K.contains(H)&&K.removeChild(H)}},[e]),b.jsx(VU,{isPresent:e,childRef:f,sizeRef:d,pop:l,children:l===!1?t:I.cloneElement(t,{ref:v})})}const LU=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:o,presenceAffectsLayout:l,mode:c,anchorX:f,anchorY:d,root:m})=>{const g=wb(UU),v=I.useId();let T=!0,E=I.useMemo(()=>(T=!1,{id:v,initial:e,isPresent:n,custom:o,onExitComplete:R=>{g.set(R,!0);for(const P of g.values())if(!P)return;s&&s()},register:R=>(g.set(R,!1),()=>g.delete(R))}),[n,g,s]);return l&&T&&(E={...E}),I.useMemo(()=>{g.forEach((R,P)=>g.set(P,!1))},[n]),I.useEffect(()=>{!n&&!g.size&&s&&s()},[n]),t=b.jsx(jU,{pop:c==="popLayout",isPresent:n,anchorX:f,anchorY:d,root:m,children:t}),b.jsx(xm.Provider,{value:E,children:t})};function UU(){return new Map}function x2(t=!0){const e=I.useContext(xm);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:o}=e,l=I.useId();I.useEffect(()=>{if(t)return o(l)},[t]);const c=I.useCallback(()=>t&&s&&s(l),[l,s,t]);return!n&&s?[!1,c]:[!0]}const Gh=t=>t.key||"";function lS(t){const e=[];return I.Children.forEach(t,n=>{I.isValidElement(n)&&e.push(n)}),e}const zU=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:o=!0,mode:l="sync",propagate:c=!1,anchorX:f="left",anchorY:d="top",root:m})=>{const[g,v]=x2(c),T=I.useMemo(()=>lS(t),[t]),E=c&&!g?[]:T.map(Gh),R=I.useRef(!0),P=I.useRef(T),N=wb(()=>new Map),L=I.useRef(new Set),[z,B]=I.useState(T),[H,K]=I.useState(T);WR(()=>{R.current=!1,P.current=T;for(let A=0;A{const O=Gh(A),k=c&&!g?!1:T===H||E.includes(O),j=()=>{if(L.current.has(O))return;if(N.has(O))L.current.add(O),N.set(O,!0);else return;let F=!0;N.forEach(V=>{V||(F=!1)}),F&&(M?.(),K(P.current),c&&v?.(),s&&s())};return b.jsx(LU,{isPresent:k,initial:!R.current||n?void 0:!1,custom:e,presenceAffectsLayout:o,mode:l,root:m,onExitComplete:k?void 0:j,anchorX:f,anchorY:d,children:A},O)})})},E2=I.createContext({strict:!1}),cS={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let uS=!1;function BU(){if(uS)return;const t={};for(const e in cS)t[e]={isEnabled:n=>cS[e].some(s=>!!n[s])};JC(t),uS=!0}function S2(){return BU(),E6()}function FU(t){const e=S2();for(const n in t)e[n]={...e[n],...t[n]};JC(e)}const qU=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Ud(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||qU.has(t)}let A2=t=>!Ud(t);function HU(t){typeof t=="function"&&(A2=e=>e.startsWith("on")?!Ud(e):t(e))}try{HU(require("@emotion/is-prop-valid").default)}catch{}function GU(t,e,n){const s={};for(const o in t)o==="values"&&typeof t.values=="object"||sn(t[o])||(A2(o)||n===!0&&Ud(o)||!e&&!Ud(o)||t.draggable&&o.startsWith("onDrag"))&&(s[o]=t[o]);return s}const Rm=I.createContext({});function $U(t,e){if(Am(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Ou(n)?n:void 0,animate:Ou(s)?s:void 0}}return t.inherit!==!1?e:{}}function KU(t){const{initial:e,animate:n}=$U(t,I.useContext(Rm));return I.useMemo(()=>({initial:e,animate:n}),[fS(e),fS(n)])}function fS(t){return Array.isArray(t)?t.join(" "):t}const Qb=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function R2(t,e,n){for(const s in e)!sn(e[s])&&!o2(s,n)&&(t[s]=e[s])}function QU({transformTemplate:t},e){return I.useMemo(()=>{const n=Qb();return Gb(n,e,t),Object.assign({},n.vars,n.style)},[e])}function YU(t,e){const n=t.style||{},s={};return R2(s,n,t),Object.assign(s,QU(t,e)),s}function WU(t,e){const n={},s=YU(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=s,n}const C2=()=>({...Qb(),attrs:{}});function XU(t,e,n,s){const o=I.useMemo(()=>{const l=C2();return a2(l,e,c2(s),t.transformTemplate,t.style),{...l.attrs,style:{...l.style}}},[e]);if(t.style){const l={};R2(l,t.style,t),o.style={...l,...o.style}}return o}const ZU=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Yb(t){return typeof t!="string"||t.includes("-")?!1:!!(ZU.indexOf(t)>-1||/[A-Z]/u.test(t))}function JU(t,e,n,{latestValues:s},o,l=!1,c){const d=(c??Yb(t)?XU:WU)(e,s,o,t),m=GU(e,typeof t=="string",l),g=t!==I.Fragment?{...m,...d,ref:n}:{},{children:v}=e,T=I.useMemo(()=>sn(v)?v.get():v,[v]);return I.createElement(t,{...g,children:T})}function e9({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,o){return{latestValues:t9(n,s,o,t),renderState:e()}}function t9(t,e,n,s){const o={},l=s(t,{});for(const T in l)o[T]=fd(l[T]);let{initial:c,animate:f}=t;const d=Am(t),m=XC(t);e&&m&&!d&&t.inherit!==!1&&(c===void 0&&(c=e.initial),f===void 0&&(f=e.animate));let g=n?n.initial===!1:!1;g=g||c===!1;const v=g?f:c;if(v&&typeof v!="boolean"&&!Sm(v)){const T=Array.isArray(v)?v:[v];for(let E=0;E(e,n)=>{const s=I.useContext(Rm),o=I.useContext(xm),l=()=>e9(t,e,s,o);return n?l():wb(l)},n9=I2({scrapeMotionValuesFromProps:$b,createRenderState:Qb}),s9=I2({scrapeMotionValuesFromProps:u2,createRenderState:C2}),i9=Symbol.for("motionComponentSymbol");function r9(t,e,n){const s=I.useRef(n);I.useInsertionEffect(()=>{s.current=n});const o=I.useRef(null);return I.useCallback(l=>{l&&t.onMount?.(l);const c=s.current;if(typeof c=="function")if(l){const f=c(l);typeof f=="function"&&(o.current=f)}else o.current?(o.current(),o.current=null):c(l);else c&&(c.current=l);e&&(l?e.mount(l):e.unmount())},[e])}const N2=I.createContext({});function cl(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function o9(t,e,n,s,o,l){const{visualElement:c}=I.useContext(Rm),f=I.useContext(E2),d=I.useContext(xm),m=I.useContext(Kb),g=m.reducedMotion,v=m.skipAnimations,T=I.useRef(null),E=I.useRef(!1);s=s||f.renderer,!T.current&&s&&(T.current=s(t,{visualState:e,parent:c,props:n,presenceContext:d,blockInitialAnimation:d?d.initial===!1:!1,reducedMotionConfig:g,skipAnimations:v,isSVG:l}),E.current&&T.current&&(T.current.manuallyAnimateOnMount=!0));const R=T.current,P=I.useContext(N2);R&&!R.projection&&o&&(R.type==="html"||R.type==="svg")&&a9(T.current,n,o,P);const N=I.useRef(!1);I.useInsertionEffect(()=>{R&&N.current&&R.update(n,d)});const L=n[LC],z=I.useRef(!!L&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(L)&&window.MotionHasOptimisedAnimation?.(L));return WR(()=>{E.current=!0,R&&(N.current=!0,window.MotionIsMounted=!0,R.updateFeatures(),R.scheduleRenderMicrotask(),z.current&&R.animationState&&R.animationState.animateChanges())}),I.useEffect(()=>{R&&(!z.current&&R.animationState&&R.animationState.animateChanges(),z.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(L)}),z.current=!1),R.enteringChildren=void 0)}),R}function a9(t,e,n,s){const{layoutId:o,layout:l,drag:c,dragConstraints:f,layoutScroll:d,layoutRoot:m,layoutAnchor:g,layoutCrossfade:v}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:P2(t.parent)),t.projection.setOptions({layoutId:o,layout:l,alwaysMeasureLayout:!!c||f&&cl(f),visualElement:t,animationType:typeof l=="string"?l:"both",initialPromotionConfig:s,crossfade:v,layoutScroll:d,layoutRoot:m,layoutAnchor:g})}function P2(t){if(t)return t.options.allowProjection!==!1?t.projection:P2(t.parent)}function xy(t,{forwardMotionProps:e=!1,type:n}={},s,o){s&&FU(s);const l=n?n==="svg":Yb(t),c=l?s9:n9;function f(m,g){let v;const T={...I.useContext(Kb),...m,layoutId:l9(m)},{isStatic:E}=T,R=KU(m),P=c(m,E);if(!E&&typeof window<"u"){c9();const N=u9(T);v=N.MeasureLayout,R.visualElement=o9(t,P,T,o,N.ProjectionNode,l)}return b.jsxs(Rm.Provider,{value:R,children:[v&&R.visualElement?b.jsx(v,{visualElement:R.visualElement,...T}):null,JU(t,m,r9(P,R.visualElement,g),P,E,e,l)]})}f.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const d=I.forwardRef(f);return d[i9]=t,d}function l9({layoutId:t}){const e=I.useContext(Tb).id;return e&&t!==void 0?e+"-"+t:t}function c9(t,e){I.useContext(E2).strict}function u9(t){const e=S2(),{drag:n,layout:s}=e;if(!n&&!s)return{};const o={...n,...s};return{MeasureLayout:n?.isEnabled(t)||s?.isEnabled(t)?o.MeasureLayout:void 0,ProjectionNode:o.ProjectionNode}}function f9(t,e){if(typeof Proxy>"u")return xy;const n=new Map,s=(l,c)=>xy(l,c,t,e),o=(l,c)=>s(l,c);return new Proxy(o,{get:(l,c)=>c==="create"?s:(n.has(c)||n.set(c,xy(c,void 0,t,e)),n.get(c))})}const h9=(t,e)=>e.isSVG??Yb(t)?new B6(e):new k6(e,{allowProjection:t!==I.Fragment});class d9 extends oo{constructor(e){super(e),e.animationState||(e.animationState=$6(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Sm(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let m9=0;class p9 extends oo{constructor(){super(...arguments),this.id=m9++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;if(e&&s===!1){if(this.isExitComplete){const{initial:l,custom:c}=this.node.getProps();if(typeof l=="string"){const f=oa(this.node,l,c);if(f){const{transition:d,transitionEnd:m,...g}=f;for(const v in g)this.node.getValue(v)?.jump(g[v])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const o=this.node.animationState.setActive("exit",!e);n&&!e&&o.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const g9={animation:{Feature:d9},exit:{Feature:p9}};function tf(t){return{point:{x:t.pageX,y:t.pageY}}}const y9=t=>e=>Bb(e)&&t(e,tf(e));function vu(t,e,n,s){return Mu(t,e,y9(n),s)}const D2=({current:t})=>t?t.ownerDocument.defaultView:null,hS=(t,e)=>Math.abs(t-e);function v9(t,e){const n=hS(t.x,e.x),s=hS(t.y,e.y);return Math.sqrt(n**2+s**2)}const dS=new Set(["auto","scroll"]);class O2{constructor(e,n,{transformPagePoint:s,contextWindow:o=window,dragSnapToOrigin:l=!1,distanceThreshold:c=3,element:f}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=E=>{this.handleScroll(E.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=$h(this.lastRawMoveEventInfo,this.transformPagePoint));const E=Ey(this.lastMoveEventInfo,this.history),R=this.startEvent!==null,P=v9(E.offset,{x:0,y:0})>=this.distanceThreshold;if(!R&&!P)return;const{point:N}=E,{timestamp:L}=en;this.history.push({...N,timestamp:L});const{onStart:z,onMove:B}=this.handlers;R||(z&&z(this.lastMoveEvent,E),this.startEvent=this.lastMoveEvent),B&&B(this.lastMoveEvent,E)},this.handlePointerMove=(E,R)=>{this.lastMoveEvent=E,this.lastRawMoveEventInfo=R,this.lastMoveEventInfo=$h(R,this.transformPagePoint),ot.update(this.updatePoint,!0)},this.handlePointerUp=(E,R)=>{this.end();const{onEnd:P,onSessionEnd:N,resumeAnimation:L}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&L&&L(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const z=Ey(E.type==="pointercancel"?this.lastMoveEventInfo:$h(R,this.transformPagePoint),this.history);this.startEvent&&P&&P(E,z),N&&N(E,z)},!Bb(e))return;this.dragSnapToOrigin=l,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=c,this.contextWindow=o||window;const d=tf(e),m=$h(d,this.transformPagePoint),{point:g}=m,{timestamp:v}=en;this.history=[{...g,timestamp:v}];const{onSessionStart:T}=n;T&&T(e,Ey(m,this.history)),this.removeListeners=Zu(vu(this.contextWindow,"pointermove",this.handlePointerMove),vu(this.contextWindow,"pointerup",this.handlePointerUp),vu(this.contextWindow,"pointercancel",this.handlePointerUp)),f&&this.startScrollTracking(f)}startScrollTracking(e){let n=e.parentElement;for(;n;){const s=getComputedStyle(n);(dS.has(s.overflowX)||dS.has(s.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const n=this.scrollPositions.get(e);if(!n)return;const s=e===window,o=s?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},l={x:o.x-n.x,y:o.y-n.y};l.x===0&&l.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=l.x,this.lastMoveEventInfo.point.y+=l.y):this.history.length>0&&(this.history[0].x-=l.x,this.history[0].y-=l.y),this.scrollPositions.set(e,o),ot.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Wr(this.updatePoint)}}function $h(t,e){return e?{point:e(t.point)}:t}function mS(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Ey({point:t},e){return{point:t,delta:mS(t,M2(e)),offset:mS(t,b9(e)),velocity:_9(e,.1)}}function b9(t){return t[0]}function M2(t){return t[t.length-1]}function _9(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const o=M2(t);for(;n>=0&&(s=t[n],!(o.timestamp-s.timestamp>Gn(e)));)n--;if(!s)return{x:0,y:0};s===t[0]&&t.length>2&&o.timestamp-s.timestamp>Gn(e)*2&&(s=t[1]);const l=ls(o.timestamp-s.timestamp);if(l===0)return{x:0,y:0};const c={x:(o.x-s.x)/l,y:(o.y-s.y)/l};return c.x===1/0&&(c.x=0),c.y===1/0&&(c.y=0),c}function T9(t,{min:e,max:n},s){return e!==void 0&&tn&&(t=s?ht(n,t,s.max):Math.min(t,n)),t}function pS(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function w9(t,{top:e,left:n,bottom:s,right:o}){return{x:pS(t.x,n,o),y:pS(t.y,e,s)}}function gS(t,e){let n=e.min-t.min,s=e.max-t.max;return e.max-e.mins?n=Pu(e.min,e.max-s,t.min):s>o&&(n=Pu(t.min,t.max-o,e.min)),ai(0,1,n)}function S9(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const Sv=.35;function A9(t=Sv){return t===!1?t=0:t===!0&&(t=Sv),{x:yS(t,"left","right"),y:yS(t,"top","bottom")}}function yS(t,e,n){return{min:vS(t,e),max:vS(t,n)}}function vS(t,e){return typeof t=="number"?t:t[e]||0}const R9=new WeakMap;class C9{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=zt(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:o}=this.visualElement;if(o&&o.isPresent===!1)return;const l=v=>{n&&this.snapToCursor(tf(v).point),this.stopAnimation()},c=(v,T)=>{const{drag:E,dragPropagation:R,onDragStart:P}=this.getProps();if(E&&!R&&(this.openDragLock&&this.openDragLock(),this.openDragLock=e6(E),!this.openDragLock))return;this.latestPointerEvent=v,this.latestPanInfo=T,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Xs(L=>{let z=this.getAxisMotionValue(L).get()||0;if(ni.test(z)){const{projection:B}=this.visualElement;if(B&&B.layout){const H=B.layout.layoutBox[L];H&&(z=En(H)*(parseFloat(z)/100))}}this.originPoint[L]=z}),P&&ot.update(()=>P(v,T),!1,!0),gv(this.visualElement,"transform");const{animationState:N}=this.visualElement;N&&N.setActive("whileDrag",!0)},f=(v,T)=>{this.latestPointerEvent=v,this.latestPanInfo=T;const{dragPropagation:E,dragDirectionLock:R,onDirectionLock:P,onDrag:N}=this.getProps();if(!E&&!this.openDragLock)return;const{offset:L}=T;if(R&&this.currentDirection===null){this.currentDirection=N9(L),this.currentDirection!==null&&P&&P(this.currentDirection);return}this.updateAxis("x",T.point,L),this.updateAxis("y",T.point,L),this.visualElement.render(),N&&ot.update(()=>N(v,T),!1,!0)},d=(v,T)=>{this.latestPointerEvent=v,this.latestPanInfo=T,this.stop(v,T),this.latestPointerEvent=null,this.latestPanInfo=null},m=()=>{const{dragSnapToOrigin:v}=this.getProps();(v||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:g}=this.getProps();this.panSession=new O2(e,{onSessionStart:l,onStart:c,onMove:f,onSessionEnd:d,resumeAnimation:m},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:g,distanceThreshold:s,contextWindow:D2(this.visualElement),element:this.visualElement.current})}stop(e,n){const s=e||this.latestPointerEvent,o=n||this.latestPanInfo,l=this.isDragging;if(this.cancel(),!l||!o||!s)return;const{velocity:c}=o;this.startAnimation(c);const{onDragEnd:f}=this.getProps();f&&ot.postRender(()=>f(s,o))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,n,s){const{drag:o}=this.getProps();if(!s||!Kh(e,o,this.currentDirection))return;const l=this.getAxisMotionValue(e);let c=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(c=T9(c,this.constraints[e],this.elastic[e])),l.set(c)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,o=this.constraints;e&&cl(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=w9(s.layoutBox,e):this.constraints=!1,this.elastic=A9(n),o!==this.constraints&&!cl(e)&&s&&this.constraints&&!this.hasMutatedConstraints&&Xs(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=S9(s.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!cl(e))return!1;const s=e.current,{projection:o}=this.visualElement;if(!o||!o.layout)return!1;const l=I6(s,o.root,this.visualElement.getTransformPagePoint());let c=x9(o.layout.layoutBox,l);if(n){const f=n(A6(c));this.hasMutatedConstraints=!!f,f&&(c=t2(f))}return c}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:o,dragTransition:l,dragSnapToOrigin:c,onDragTransitionEnd:f}=this.getProps(),d=this.constraints||{},m=Xs(g=>{if(!Kh(g,n,this.currentDirection))return;let v=d&&d[g]||{};(c===!0||c===g)&&(v={min:0,max:0});const T=o?200:1e6,E=o?40:1e7,R={type:"inertia",velocity:s?e[g]:0,bounceStiffness:T,bounceDamping:E,timeConstant:750,restDelta:1,restSpeed:10,...l,...v};return this.startAxisValueAnimation(g,R)});return Promise.all(m).then(f)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return gv(this.visualElement,e),s.start(Vb(e,s,0,n,this.visualElement,!1))}stopAnimation(){Xs(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),o=s[n];return o||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){Xs(n=>{const{drag:s}=this.getProps();if(!Kh(n,s,this.currentDirection))return;const{projection:o}=this.visualElement,l=this.getAxisMotionValue(n);if(o&&o.layout){const{min:c,max:f}=o.layout.layoutBox[n],d=l.get()||0;l.set(e[n]-ht(c,f,.5)+d)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!cl(n)||!s||!this.constraints)return;this.stopAnimation();const o={x:0,y:0};Xs(c=>{const f=this.getAxisMotionValue(c);if(f&&this.constraints!==!1){const d=f.get();o[c]=E9({min:d,max:d},this.constraints[c])}});const{transformTemplate:l}=this.visualElement.getProps();this.visualElement.current.style.transform=l?l({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),Xs(c=>{if(!Kh(c,e,null))return;const f=this.getAxisMotionValue(c),{min:d,max:m}=this.constraints[c];f.set(ht(d,m,o[c]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;R9.set(this.visualElement,this);const e=this.visualElement.current,n=vu(e,"pointerdown",m=>{const{drag:g,dragListener:v=!0}=this.getProps(),T=m.target,E=T!==e&&o6(T);g&&v&&!E&&this.start(m)});let s;const o=()=>{const{dragConstraints:m}=this.getProps();cl(m)&&m.current&&(this.constraints=this.resolveRefConstraints(),s||(s=I9(e,m.current,()=>this.scalePositionWithinConstraints())))},{projection:l}=this.visualElement,c=l.addEventListener("measure",o);l&&!l.layout&&(l.root&&l.root.updateScroll(),l.updateLayout()),ot.read(o);const f=Mu(window,"resize",()=>this.scalePositionWithinConstraints()),d=l.addEventListener("didUpdate",(({delta:m,hasLayoutChanged:g})=>{this.isDragging&&g&&(Xs(v=>{const T=this.getAxisMotionValue(v);T&&(this.originPoint[v]+=m[v].translate,T.set(T.get()+m[v].translate))}),this.visualElement.render())}));return()=>{f(),n(),c(),d&&d(),s&&s()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:o=!1,dragConstraints:l=!1,dragElastic:c=Sv,dragMomentum:f=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:o,dragConstraints:l,dragElastic:c,dragMomentum:f}}}function bS(t){let e=!0;return()=>{if(e){e=!1;return}t()}}function I9(t,e,n){const s=AE(t,bS(n)),o=AE(e,bS(n));return()=>{s(),o()}}function Kh(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function N9(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class P9 extends oo{constructor(e){super(e),this.removeGroupControls=cs,this.removeListeners=cs,this.controls=new C9(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||cs}update(){const{dragControls:e}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const Sy=t=>(e,n)=>{t&&ot.update(()=>t(e,n),!1,!0)};class D9 extends oo{constructor(){super(...arguments),this.removePointerDownListener=cs}onPointerDown(e){this.session=new O2(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:D2(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:o}=this.node.getProps();return{onSessionStart:Sy(e),onStart:Sy(n),onMove:Sy(s),onEnd:(l,c)=>{delete this.session,o&&ot.postRender(()=>o(l,c))}}}mount(){this.removePointerDownListener=vu(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Ay=!1;class O9 extends I.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:o}=this.props,{projection:l}=e;l&&(n.group&&n.group.add(l),s&&s.register&&o&&s.register(l),Ay&&l.root.didUpdate(),l.addEventListener("animationComplete",()=>{this.safeToRemove()}),l.setOptions({...l.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),hd.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:o,isPresent:l}=this.props,{projection:c}=s;return c&&(c.isPresent=l,e.layoutDependency!==n&&c.setOptions({...c.options,layoutDependency:n}),Ay=!0,o||e.layoutDependency!==n||n===void 0||e.isPresent!==l?c.willUpdate():this.safeToRemove(),e.isPresent!==l&&(l?c.promote():c.relegate()||ot.postRender(()=>{const f=c.getStack();(!f||!f.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:e,layoutAnchor:n}=this.props,{projection:s}=e;s&&(s.options.layoutAnchor=n,s.root.didUpdate(),zb.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:o}=e;Ay=!0,o&&(o.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(o),s&&s.deregister&&s.deregister(o))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function k2(t){const[e,n]=x2(),s=I.useContext(Tb);return b.jsx(O9,{...t,layoutGroup:s,switchLayoutGroup:I.useContext(N2),isPresent:e,safeToRemove:n})}const M9={pan:{Feature:D9},drag:{Feature:P9,ProjectionNode:w2,MeasureLayout:k2}};function _S(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const o="onHover"+n,l=s[o];l&&ot.postRender(()=>l(e,tf(e)))}class k9 extends oo{mount(){const{current:e}=this.node;e&&(this.unmount=n6(e,(n,s)=>(_S(this.node,s,"Start"),o=>_S(this.node,o,"End"))))}unmount(){}}class V9 extends oo{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Zu(Mu(this.node.current,"focus",()=>this.onFocus()),Mu(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function TS(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const o="onTap"+(n==="End"?"":n),l=s[o];l&&ot.postRender(()=>l(e,tf(e)))}class j9 extends oo{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=l6(e,(o,l)=>(TS(this.node,l,"Start"),(c,{success:f})=>TS(this.node,c,f?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:s?.tap===!1})}unmount(){}}const Av=new WeakMap,Ry=new WeakMap,L9=t=>{const e=Av.get(t.target);e&&e(t)},U9=t=>{t.forEach(L9)};function z9({root:t,...e}){const n=t||document;Ry.has(n)||Ry.set(n,{});const s=Ry.get(n),o=JSON.stringify(e);return s[o]||(s[o]=new IntersectionObserver(U9,{root:t,...e})),s[o]}function B9(t,e,n){const s=z9(e);return Av.set(t,n),s.observe(t),()=>{Av.delete(t),s.unobserve(t)}}const F9={some:0,all:1};class q9 extends oo{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:o="some",once:l}=e,c={root:n?n.current:void 0,rootMargin:s,threshold:typeof o=="number"?o:F9[o]},f=d=>{const{isIntersecting:m}=d;if(this.isInView===m||(this.isInView=m,l&&!m&&this.hasEnteredView))return;m&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",m);const{onViewportEnter:g,onViewportLeave:v}=this.node.getProps(),T=m?g:v;T&&T(d)};this.stopObserver=B9(this.node.current,c,f)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(H9(e,n))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}function H9({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const G9={inView:{Feature:q9},tap:{Feature:j9},focus:{Feature:V9},hover:{Feature:k9}},$9={layout:{ProjectionNode:w2,MeasureLayout:k2}},K9={...g9,...G9,...M9,...$9},Cs=f9(K9,h9);const Q9=()=>{};var wS={};const V2=function(t){const e=[];let n=0;for(let s=0;s>6|192,e[n++]=o&63|128):(o&64512)===55296&&s+1>18|240,e[n++]=o>>12&63|128,e[n++]=o>>6&63|128,e[n++]=o&63|128):(e[n++]=o>>12|224,e[n++]=o>>6&63|128,e[n++]=o&63|128)}return e},Y9=function(t){const e=[];let n=0,s=0;for(;n191&&o<224){const l=t[n++];e[s++]=String.fromCharCode((o&31)<<6|l&63)}else if(o>239&&o<365){const l=t[n++],c=t[n++],f=t[n++],d=((o&7)<<18|(l&63)<<12|(c&63)<<6|f&63)-65536;e[s++]=String.fromCharCode(55296+(d>>10)),e[s++]=String.fromCharCode(56320+(d&1023))}else{const l=t[n++],c=t[n++];e[s++]=String.fromCharCode((o&15)<<12|(l&63)<<6|c&63)}}return e.join("")},j2={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_,s=[];for(let o=0;o>2,v=(l&3)<<4|f>>4;let T=(f&15)<<2|m>>6,E=m&63;d||(E=64,c||(T=64)),s.push(n[g],n[v],n[T],n[E])}return s.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(V2(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):Y9(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const n=e?this.charToByteMapWebSafe_:this.charToByteMap_,s=[];for(let o=0;o>4;if(s.push(T),m!==64){const E=f<<4&240|m>>2;if(s.push(E),v!==64){const R=m<<6&192|v;s.push(R)}}}return s},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 W9 extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const X9=function(t){const e=V2(t);return j2.encodeByteArray(e,!0)},zd=function(t){return X9(t).replace(/\./g,"")},L2=function(t){try{return j2.decodeString(t,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function Z9(){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.")}const J9=()=>Z9().__FIREBASE_DEFAULTS__,e5=()=>{if(typeof process>"u"||typeof wS>"u")return;const t=wS.__FIREBASE_DEFAULTS__;if(t)return JSON.parse(t)},t5=()=>{if(typeof document>"u")return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=t&&L2(t[1]);return e&&JSON.parse(e)},Cm=()=>{try{return Q9()||J9()||e5()||t5()}catch(t){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`);return}},U2=t=>Cm()?.emulatorHosts?.[t],n5=t=>{const e=U2(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 s=parseInt(e.substring(n+1),10);return e[0]==="["?[e.substring(1,n-1),s]:[e.substring(0,n),s]},z2=()=>Cm()?.config,B2=t=>Cm()?.[`_${t}`];class s5{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,n)=>{this.resolve=e,this.reject=n})}wrapCallback(e){return(n,s)=>{n?this.reject(n):this.resolve(s),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(n):e(n,s))}}}function i5(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"},s=e||"demo-project",o=t.iat||0,l=t.sub||t.user_id;if(!l)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const c={iss:`https://securetoken.google.com/${s}`,aud:s,iat:o,exp:o+3600,auth_time:o,sub:l,user_id:l,firebase:{sign_in_provider:"custom",identities:{}},...t};return[zd(JSON.stringify(n)),zd(JSON.stringify(c)),""].join(".")}function mn(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function r5(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(mn())}function o5(){const t=Cm()?.forceEnvironment;if(t==="node")return!0;if(t==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function a5(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function l5(){const t=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof t=="object"&&t.id!==void 0}function c5(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function u5(){const t=mn();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function f5(){return!o5()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function h5(){try{return typeof indexedDB=="object"}catch{return!1}}function d5(){return new Promise((t,e)=>{try{let n=!0;const s="validate-browser-context-for-indexeddb-analytics-module",o=self.indexedDB.open(s);o.onsuccess=()=>{o.result.close(),n||self.indexedDB.deleteDatabase(s),t(!0)},o.onupgradeneeded=()=>{n=!1},o.onerror=()=>{e(o.error?.message||"")}}catch(n){e(n)}})}const m5="FirebaseError";class $i extends Error{constructor(e,n,s){super(n),this.code=e,this.customData=s,this.name=m5,Object.setPrototypeOf(this,$i.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,nf.prototype.create)}}class nf{constructor(e,n,s){this.service=e,this.serviceName=n,this.errors=s}create(e,...n){const s=n[0]||{},o=`${this.service}/${e}`,l=this.errors[e],c=l?p5(l,s):"Error",f=`${this.serviceName}: ${c} (${o}).`;return new $i(o,f,s)}}function p5(t,e){return t.replace(g5,(n,s)=>{const o=e[s];return o!=null?String(o):`<${s}?>`})}const g5=/\{\$([^}]+)}/g;function y5(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function ca(t,e){if(t===e)return!0;const n=Object.keys(t),s=Object.keys(e);for(const o of n){if(!s.includes(o))return!1;const l=t[o],c=e[o];if(xS(l)&&xS(c)){if(!ca(l,c))return!1}else if(l!==c)return!1}for(const o of s)if(!n.includes(o))return!1;return!0}function xS(t){return t!==null&&typeof t=="object"}function sf(t){const e=[];for(const[n,s]of Object.entries(t))Array.isArray(s)?s.forEach(o=>{e.push(encodeURIComponent(n)+"="+encodeURIComponent(o))}):e.push(encodeURIComponent(n)+"="+encodeURIComponent(s));return e.length?"&"+e.join("&"):""}function lu(t){const e={};return t.replace(/^\?/,"").split("&").forEach(s=>{if(s){const[o,l]=s.split("=");e[decodeURIComponent(o)]=decodeURIComponent(l)}}),e}function cu(t){const e=t.indexOf("?");if(!e)return"";const n=t.indexOf("#",e);return t.substring(e,n>0?n:void 0)}function v5(t,e){const n=new b5(t,e);return n.subscribe.bind(n)}class b5{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(s=>{this.error(s)})}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,s){let o;if(e===void 0&&n===void 0&&s===void 0)throw new Error("Missing Observer.");_5(e,["next","error","complete"])?o=e:o={next:e,error:n,complete:s},o.next===void 0&&(o.next=Cy),o.error===void 0&&(o.error=Cy),o.complete===void 0&&(o.complete=Cy);const l=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?o.error(this.finalError):o.complete()}catch{}}),this.observers.push(o),l}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(s){typeof console<"u"&&console.error&&console.error(s)}})}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 _5(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 Cy(){}function Ft(t){return t&&t._delegate?t._delegate:t}function rf(t){try{return(t.startsWith("http://")||t.startsWith("https://")?new URL(t).hostname:t).endsWith(".cloudworkstations.dev")}catch{return!1}}async function F2(t){return(await fetch(t,{credentials:"include"})).ok}class ua{constructor(e,n,s){this.name=e,this.instanceFactory=n,this.type=s,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}}const Jo="[DEFAULT]";class T5{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 s=new s5;if(this.instancesDeferred.set(n,s),this.isInitialized(n)||this.shouldAutoInitialize())try{const o=this.getOrInitializeService({instanceIdentifier:n});o&&s.resolve(o)}catch{}}return this.instancesDeferred.get(n).promise}getImmediate(e){const n=this.normalizeInstanceIdentifier(e?.identifier),s=e?.optional??!1;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(o){if(s)return null;throw o}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(x5(e))try{this.getOrInitializeService({instanceIdentifier:Jo})}catch{}for(const[n,s]of this.instancesDeferred.entries()){const o=this.normalizeInstanceIdentifier(n);try{const l=this.getOrInitializeService({instanceIdentifier:o});s.resolve(l)}catch{}}}}clearInstance(e=Jo){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=Jo){return this.instances.has(e)}getOptions(e=Jo){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:n={}}=e,s=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(s))throw Error(`${this.name}(${s}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const o=this.getOrInitializeService({instanceIdentifier:s,options:n});for(const[l,c]of this.instancesDeferred.entries()){const f=this.normalizeInstanceIdentifier(l);s===f&&c.resolve(o)}return o}onInit(e,n){const s=this.normalizeInstanceIdentifier(n),o=this.onInitCallbacks.get(s)??new Set;o.add(e),this.onInitCallbacks.set(s,o);const l=this.instances.get(s);return l&&e(l,s),()=>{o.delete(e)}}invokeOnInitCallbacks(e,n){const s=this.onInitCallbacks.get(n);if(s)for(const o of s)try{o(e,n)}catch{}}getOrInitializeService({instanceIdentifier:e,options:n={}}){let s=this.instances.get(e);if(!s&&this.component&&(s=this.component.instanceFactory(this.container,{instanceIdentifier:w5(e),options:n}),this.instances.set(e,s),this.instancesOptions.set(e,n),this.invokeOnInitCallbacks(s,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,s)}catch{}return s||null}normalizeInstanceIdentifier(e=Jo){return this.component?this.component.multipleInstances?e:Jo:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function w5(t){return t===Jo?void 0:t}function x5(t){return t.instantiationMode==="EAGER"}class E5{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 T5(e,this);return this.providers.set(e,n),n}getProviders(){return Array.from(this.providers.values())}}var Fe;(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"})(Fe||(Fe={}));const S5={debug:Fe.DEBUG,verbose:Fe.VERBOSE,info:Fe.INFO,warn:Fe.WARN,error:Fe.ERROR,silent:Fe.SILENT},A5=Fe.INFO,R5={[Fe.DEBUG]:"log",[Fe.VERBOSE]:"log",[Fe.INFO]:"info",[Fe.WARN]:"warn",[Fe.ERROR]:"error"},C5=(t,e,...n)=>{if(ee.some(n=>t instanceof n);let ES,SS;function N5(){return ES||(ES=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function P5(){return SS||(SS=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const q2=new WeakMap,Rv=new WeakMap,H2=new WeakMap,Iy=new WeakMap,Xb=new WeakMap;function D5(t){const e=new Promise((n,s)=>{const o=()=>{t.removeEventListener("success",l),t.removeEventListener("error",c)},l=()=>{n(zr(t.result)),o()},c=()=>{s(t.error),o()};t.addEventListener("success",l),t.addEventListener("error",c)});return e.then(n=>{n instanceof IDBCursor&&q2.set(n,t)}).catch(()=>{}),Xb.set(e,t),e}function O5(t){if(Rv.has(t))return;const e=new Promise((n,s)=>{const o=()=>{t.removeEventListener("complete",l),t.removeEventListener("error",c),t.removeEventListener("abort",c)},l=()=>{n(),o()},c=()=>{s(t.error||new DOMException("AbortError","AbortError")),o()};t.addEventListener("complete",l),t.addEventListener("error",c),t.addEventListener("abort",c)});Rv.set(t,e)}let Cv={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return Rv.get(t);if(e==="objectStoreNames")return t.objectStoreNames||H2.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return zr(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 M5(t){Cv=t(Cv)}function k5(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...n){const s=t.call(Ny(this),e,...n);return H2.set(s,e.sort?e.sort():[e]),zr(s)}:P5().includes(t)?function(...e){return t.apply(Ny(this),e),zr(q2.get(this))}:function(...e){return zr(t.apply(Ny(this),e))}}function V5(t){return typeof t=="function"?k5(t):(t instanceof IDBTransaction&&O5(t),I5(t,N5())?new Proxy(t,Cv):t)}function zr(t){if(t instanceof IDBRequest)return D5(t);if(Iy.has(t))return Iy.get(t);const e=V5(t);return e!==t&&(Iy.set(t,e),Xb.set(e,t)),e}const Ny=t=>Xb.get(t);function j5(t,e,{blocked:n,upgrade:s,blocking:o,terminated:l}={}){const c=indexedDB.open(t,e),f=zr(c);return s&&c.addEventListener("upgradeneeded",d=>{s(zr(c.result),d.oldVersion,d.newVersion,zr(c.transaction),d)}),n&&c.addEventListener("blocked",d=>n(d.oldVersion,d.newVersion,d)),f.then(d=>{l&&d.addEventListener("close",()=>l()),o&&d.addEventListener("versionchange",m=>o(m.oldVersion,m.newVersion,m))}).catch(()=>{}),f}const L5=["get","getKey","getAll","getAllKeys","count"],U5=["put","add","delete","clear"],Py=new Map;function AS(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Py.get(e))return Py.get(e);const n=e.replace(/FromIndex$/,""),s=e!==n,o=U5.includes(n);if(!(n in(s?IDBIndex:IDBObjectStore).prototype)||!(o||L5.includes(n)))return;const l=async function(c,...f){const d=this.transaction(c,o?"readwrite":"readonly");let m=d.store;return s&&(m=m.index(f.shift())),(await Promise.all([m[n](...f),o&&d.done]))[0]};return Py.set(e,l),l}M5(t=>({...t,get:(e,n,s)=>AS(e,n)||t.get(e,n,s),has:(e,n)=>!!AS(e,n)||t.has(e,n)}));class z5{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(n=>{if(B5(n)){const s=n.getImmediate();return`${s.library}/${s.version}`}else return null}).filter(n=>n).join(" ")}}function B5(t){return t.getComponent()?.type==="VERSION"}const Iv="@firebase/app",RS="0.14.13";const Bi=new Wb("@firebase/app"),F5="@firebase/app-compat",q5="@firebase/analytics-compat",H5="@firebase/analytics",G5="@firebase/app-check-compat",$5="@firebase/app-check",K5="@firebase/auth",Q5="@firebase/auth-compat",Y5="@firebase/database",W5="@firebase/data-connect",X5="@firebase/database-compat",Z5="@firebase/functions",J5="@firebase/functions-compat",ez="@firebase/installations",tz="@firebase/installations-compat",nz="@firebase/messaging",sz="@firebase/messaging-compat",iz="@firebase/performance",rz="@firebase/performance-compat",oz="@firebase/remote-config",az="@firebase/remote-config-compat",lz="@firebase/storage",cz="@firebase/storage-compat",uz="@firebase/firestore",fz="@firebase/ai",hz="@firebase/firestore-compat",dz="firebase",mz="12.14.0";const Nv="[DEFAULT]",pz={[Iv]:"fire-core",[F5]:"fire-core-compat",[H5]:"fire-analytics",[q5]:"fire-analytics-compat",[$5]:"fire-app-check",[G5]:"fire-app-check-compat",[K5]:"fire-auth",[Q5]:"fire-auth-compat",[Y5]:"fire-rtdb",[W5]:"fire-data-connect",[X5]:"fire-rtdb-compat",[Z5]:"fire-fn",[J5]:"fire-fn-compat",[ez]:"fire-iid",[tz]:"fire-iid-compat",[nz]:"fire-fcm",[sz]:"fire-fcm-compat",[iz]:"fire-perf",[rz]:"fire-perf-compat",[oz]:"fire-rc",[az]:"fire-rc-compat",[lz]:"fire-gcs",[cz]:"fire-gcs-compat",[uz]:"fire-fst",[hz]:"fire-fst-compat",[fz]:"fire-vertex","fire-js":"fire-js",[dz]:"fire-js-all"};const Bd=new Map,gz=new Map,Pv=new Map;function CS(t,e){try{t.container.addComponent(e)}catch(n){Bi.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n)}}function Nl(t){const e=t.name;if(Pv.has(e))return Bi.debug(`There were multiple attempts to register component ${e}.`),!1;Pv.set(e,t);for(const n of Bd.values())CS(n,t);for(const n of gz.values())CS(n,t);return!0}function Zb(t,e){const n=t.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),t.container.getProvider(e)}function Fn(t){return t==null?!1:t.settings!==void 0}const yz={"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."},Br=new nf("app","Firebase",yz);class vz{constructor(e,n,s){this._isDeleted=!1,this._options={...e},this._config={...n},this._name=n.name,this._automaticDataCollectionEnabled=n.automaticDataCollectionEnabled,this._container=s,this.container.addComponent(new ua("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 Br.create("app-deleted",{appName:this._name})}}const Fl=mz;function G2(t,e={}){let n=t;typeof e!="object"&&(e={name:e});const s={name:Nv,automaticDataCollectionEnabled:!0,...e},o=s.name;if(typeof o!="string"||!o)throw Br.create("bad-app-name",{appName:String(o)});if(n||(n=z2()),!n)throw Br.create("no-options");const l=Bd.get(o);if(l){if(ca(n,l.options)&&ca(s,l.config))return l;throw Br.create("duplicate-app",{appName:o})}const c=new E5(o);for(const d of Pv.values())c.addComponent(d);const f=new vz(n,s,c);return Bd.set(o,f),f}function $2(t=Nv){const e=Bd.get(t);if(!e&&t===Nv&&z2())return G2();if(!e)throw Br.create("no-app",{appName:t});return e}function Fr(t,e,n){let s=pz[t]??t;n&&(s+=`-${n}`);const o=s.match(/\s|\//),l=e.match(/\s|\//);if(o||l){const c=[`Unable to register library "${s}" with version "${e}":`];o&&c.push(`library name "${s}" contains illegal characters (whitespace or "/")`),o&&l&&c.push("and"),l&&c.push(`version name "${e}" contains illegal characters (whitespace or "/")`),Bi.warn(c.join(" "));return}Nl(new ua(`${s}-version`,()=>({library:s,version:e}),"VERSION"))}const bz="firebase-heartbeat-database",_z=1,ku="firebase-heartbeat-store";let Dy=null;function K2(){return Dy||(Dy=j5(bz,_z,{upgrade:(t,e)=>{switch(e){case 0:try{t.createObjectStore(ku)}catch(n){console.warn(n)}}}}).catch(t=>{throw Br.create("idb-open",{originalErrorMessage:t.message})})),Dy}async function Tz(t){try{const n=(await K2()).transaction(ku),s=await n.objectStore(ku).get(Q2(t));return await n.done,s}catch(e){if(e instanceof $i)Bi.warn(e.message);else{const n=Br.create("idb-get",{originalErrorMessage:e?.message});Bi.warn(n.message)}}}async function IS(t,e){try{const s=(await K2()).transaction(ku,"readwrite");await s.objectStore(ku).put(e,Q2(t)),await s.done}catch(n){if(n instanceof $i)Bi.warn(n.message);else{const s=Br.create("idb-set",{originalErrorMessage:n?.message});Bi.warn(s.message)}}}function Q2(t){return`${t.name}!${t.options.appId}`}const wz=1024,xz=30;class Ez{constructor(e){this.container=e,this._heartbeatsCache=null;const n=this.container.getProvider("app").getImmediate();this._storage=new Az(n),this._heartbeatsCachePromise=this._storage.read().then(s=>(this._heartbeatsCache=s,s))}async triggerHeartbeat(){try{const n=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),s=NS();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===s||this._heartbeatsCache.heartbeats.some(o=>o.date===s))return;if(this._heartbeatsCache.heartbeats.push({date:s,agent:n}),this._heartbeatsCache.heartbeats.length>xz){const o=Rz(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(o,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){Bi.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return"";const e=NS(),{heartbeatsToSend:n,unsentEntries:s}=Sz(this._heartbeatsCache.heartbeats),o=zd(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=e,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),o}catch(e){return Bi.warn(e),""}}}function NS(){return new Date().toISOString().substring(0,10)}function Sz(t,e=wz){const n=[];let s=t.slice();for(const o of t){const l=n.find(c=>c.agent===o.agent);if(l){if(l.dates.push(o.date),PS(n)>e){l.dates.pop();break}}else if(n.push({agent:o.agent,dates:[o.date]}),PS(n)>e){n.pop();break}s=s.slice(1)}return{heartbeatsToSend:n,unsentEntries:s}}class Az{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return h5()?d5().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const n=await Tz(this.app);return n?.heartbeats?n:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const s=await this.read();return IS(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??s.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){const s=await this.read();return IS(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...e.heartbeats]})}else return}}function PS(t){return zd(JSON.stringify({version:2,heartbeats:t})).length}function Rz(t){if(t.length===0)return-1;let e=0,n=t[0].date;for(let s=1;snew z5(e),"PRIVATE")),Nl(new ua("heartbeat",e=>new Ez(e),"PRIVATE")),Fr(Iv,RS,t),Fr(Iv,RS,"esm2020"),Fr("fire-js","")}Cz("");var DS=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var qr,Y2;(function(){var t;function e(M,A){function O(){}O.prototype=A.prototype,M.F=A.prototype,M.prototype=new O,M.prototype.constructor=M,M.D=function(k,j,F){for(var V=Array(arguments.length-2),ue=2;ue>>25),V=F+(j^A&(O^j))+k[1]+3905402710&4294967295,F=A+(V<<12&4294967295|V>>>20),V=j+(O^F&(A^O))+k[2]+606105819&4294967295,j=F+(V<<17&4294967295|V>>>15),V=O+(A^j&(F^A))+k[3]+3250441966&4294967295,O=j+(V<<22&4294967295|V>>>10),V=A+(F^O&(j^F))+k[4]+4118548399&4294967295,A=O+(V<<7&4294967295|V>>>25),V=F+(j^A&(O^j))+k[5]+1200080426&4294967295,F=A+(V<<12&4294967295|V>>>20),V=j+(O^F&(A^O))+k[6]+2821735955&4294967295,j=F+(V<<17&4294967295|V>>>15),V=O+(A^j&(F^A))+k[7]+4249261313&4294967295,O=j+(V<<22&4294967295|V>>>10),V=A+(F^O&(j^F))+k[8]+1770035416&4294967295,A=O+(V<<7&4294967295|V>>>25),V=F+(j^A&(O^j))+k[9]+2336552879&4294967295,F=A+(V<<12&4294967295|V>>>20),V=j+(O^F&(A^O))+k[10]+4294925233&4294967295,j=F+(V<<17&4294967295|V>>>15),V=O+(A^j&(F^A))+k[11]+2304563134&4294967295,O=j+(V<<22&4294967295|V>>>10),V=A+(F^O&(j^F))+k[12]+1804603682&4294967295,A=O+(V<<7&4294967295|V>>>25),V=F+(j^A&(O^j))+k[13]+4254626195&4294967295,F=A+(V<<12&4294967295|V>>>20),V=j+(O^F&(A^O))+k[14]+2792965006&4294967295,j=F+(V<<17&4294967295|V>>>15),V=O+(A^j&(F^A))+k[15]+1236535329&4294967295,O=j+(V<<22&4294967295|V>>>10),V=A+(j^F&(O^j))+k[1]+4129170786&4294967295,A=O+(V<<5&4294967295|V>>>27),V=F+(O^j&(A^O))+k[6]+3225465664&4294967295,F=A+(V<<9&4294967295|V>>>23),V=j+(A^O&(F^A))+k[11]+643717713&4294967295,j=F+(V<<14&4294967295|V>>>18),V=O+(F^A&(j^F))+k[0]+3921069994&4294967295,O=j+(V<<20&4294967295|V>>>12),V=A+(j^F&(O^j))+k[5]+3593408605&4294967295,A=O+(V<<5&4294967295|V>>>27),V=F+(O^j&(A^O))+k[10]+38016083&4294967295,F=A+(V<<9&4294967295|V>>>23),V=j+(A^O&(F^A))+k[15]+3634488961&4294967295,j=F+(V<<14&4294967295|V>>>18),V=O+(F^A&(j^F))+k[4]+3889429448&4294967295,O=j+(V<<20&4294967295|V>>>12),V=A+(j^F&(O^j))+k[9]+568446438&4294967295,A=O+(V<<5&4294967295|V>>>27),V=F+(O^j&(A^O))+k[14]+3275163606&4294967295,F=A+(V<<9&4294967295|V>>>23),V=j+(A^O&(F^A))+k[3]+4107603335&4294967295,j=F+(V<<14&4294967295|V>>>18),V=O+(F^A&(j^F))+k[8]+1163531501&4294967295,O=j+(V<<20&4294967295|V>>>12),V=A+(j^F&(O^j))+k[13]+2850285829&4294967295,A=O+(V<<5&4294967295|V>>>27),V=F+(O^j&(A^O))+k[2]+4243563512&4294967295,F=A+(V<<9&4294967295|V>>>23),V=j+(A^O&(F^A))+k[7]+1735328473&4294967295,j=F+(V<<14&4294967295|V>>>18),V=O+(F^A&(j^F))+k[12]+2368359562&4294967295,O=j+(V<<20&4294967295|V>>>12),V=A+(O^j^F)+k[5]+4294588738&4294967295,A=O+(V<<4&4294967295|V>>>28),V=F+(A^O^j)+k[8]+2272392833&4294967295,F=A+(V<<11&4294967295|V>>>21),V=j+(F^A^O)+k[11]+1839030562&4294967295,j=F+(V<<16&4294967295|V>>>16),V=O+(j^F^A)+k[14]+4259657740&4294967295,O=j+(V<<23&4294967295|V>>>9),V=A+(O^j^F)+k[1]+2763975236&4294967295,A=O+(V<<4&4294967295|V>>>28),V=F+(A^O^j)+k[4]+1272893353&4294967295,F=A+(V<<11&4294967295|V>>>21),V=j+(F^A^O)+k[7]+4139469664&4294967295,j=F+(V<<16&4294967295|V>>>16),V=O+(j^F^A)+k[10]+3200236656&4294967295,O=j+(V<<23&4294967295|V>>>9),V=A+(O^j^F)+k[13]+681279174&4294967295,A=O+(V<<4&4294967295|V>>>28),V=F+(A^O^j)+k[0]+3936430074&4294967295,F=A+(V<<11&4294967295|V>>>21),V=j+(F^A^O)+k[3]+3572445317&4294967295,j=F+(V<<16&4294967295|V>>>16),V=O+(j^F^A)+k[6]+76029189&4294967295,O=j+(V<<23&4294967295|V>>>9),V=A+(O^j^F)+k[9]+3654602809&4294967295,A=O+(V<<4&4294967295|V>>>28),V=F+(A^O^j)+k[12]+3873151461&4294967295,F=A+(V<<11&4294967295|V>>>21),V=j+(F^A^O)+k[15]+530742520&4294967295,j=F+(V<<16&4294967295|V>>>16),V=O+(j^F^A)+k[2]+3299628645&4294967295,O=j+(V<<23&4294967295|V>>>9),V=A+(j^(O|~F))+k[0]+4096336452&4294967295,A=O+(V<<6&4294967295|V>>>26),V=F+(O^(A|~j))+k[7]+1126891415&4294967295,F=A+(V<<10&4294967295|V>>>22),V=j+(A^(F|~O))+k[14]+2878612391&4294967295,j=F+(V<<15&4294967295|V>>>17),V=O+(F^(j|~A))+k[5]+4237533241&4294967295,O=j+(V<<21&4294967295|V>>>11),V=A+(j^(O|~F))+k[12]+1700485571&4294967295,A=O+(V<<6&4294967295|V>>>26),V=F+(O^(A|~j))+k[3]+2399980690&4294967295,F=A+(V<<10&4294967295|V>>>22),V=j+(A^(F|~O))+k[10]+4293915773&4294967295,j=F+(V<<15&4294967295|V>>>17),V=O+(F^(j|~A))+k[1]+2240044497&4294967295,O=j+(V<<21&4294967295|V>>>11),V=A+(j^(O|~F))+k[8]+1873313359&4294967295,A=O+(V<<6&4294967295|V>>>26),V=F+(O^(A|~j))+k[15]+4264355552&4294967295,F=A+(V<<10&4294967295|V>>>22),V=j+(A^(F|~O))+k[6]+2734768916&4294967295,j=F+(V<<15&4294967295|V>>>17),V=O+(F^(j|~A))+k[13]+1309151649&4294967295,O=j+(V<<21&4294967295|V>>>11),V=A+(j^(O|~F))+k[4]+4149444226&4294967295,A=O+(V<<6&4294967295|V>>>26),V=F+(O^(A|~j))+k[11]+3174756917&4294967295,F=A+(V<<10&4294967295|V>>>22),V=j+(A^(F|~O))+k[2]+718787259&4294967295,j=F+(V<<15&4294967295|V>>>17),V=O+(F^(j|~A))+k[9]+3951481745&4294967295,M.g[0]=M.g[0]+A&4294967295,M.g[1]=M.g[1]+(j+(V<<21&4294967295|V>>>11))&4294967295,M.g[2]=M.g[2]+j&4294967295,M.g[3]=M.g[3]+F&4294967295}s.prototype.v=function(M,A){A===void 0&&(A=M.length);const O=A-this.blockSize,k=this.C;let j=this.h,F=0;for(;F>>k&255;return M};function l(M,A){var O=f;return Object.prototype.hasOwnProperty.call(O,M)?O[M]:O[M]=A(M)}function c(M,A){this.h=A;const O=[];let k=!0;for(let j=M.length-1;j>=0;j--){const F=M[j]|0;k&&F==A||(O[j]=F,k=!1)}this.g=O}var f={};function d(M){return-128<=M&&M<128?l(M,function(A){return new c([A|0],A<0?-1:0)}):new c([M|0],M<0?-1:0)}function m(M){if(isNaN(M)||!isFinite(M))return v;if(M<0)return N(m(-M));const A=[];let O=1;for(let k=0;M>=O;k++)A[k]=M/O|0,O*=4294967296;return new c(A,0)}function g(M,A){if(M.length==0)throw Error("number format error: empty string");if(A=A||10,A<2||36=0)throw Error('number format error: interior "-" character');const O=m(Math.pow(A,8));let k=v;for(let F=0;F=0?k:4294967296+k)*A,A*=4294967296}return M},t.toString=function(M){if(M=M||10,M<2||360?O.g[0]:O.h)>>>0).toString(M);if(O=j,R(O))return F+k;for(;F.length<6;)F="0"+F;k=F+k}},t.i=function(M){return M<0?0:M>>16)+(this.i(j)>>>16)+(M.i(j)>>>16);k=V>>>16,F&=65535,V&=65535,O[j]=V<<16|F}return new c(O,O[O.length-1]&-2147483648?-1:0)};function L(M,A){return M.add(N(A))}t.j=function(M){if(R(this)||R(M))return v;if(P(this))return P(M)?N(this).j(N(M)):N(N(this).j(M));if(P(M))return N(this.j(N(M)));if(this.l(E)<0&&M.l(E)<0)return m(this.m()*M.m());const A=this.g.length+M.g.length,O=[];for(var k=0;k<2*A;k++)O[k]=0;for(k=0;k>>16,V=this.i(k)&65535,ue=M.i(j)>>>16,ye=M.i(j)&65535;O[2*k+2*j]+=V*ye,z(O,2*k+2*j),O[2*k+2*j+1]+=F*ye,z(O,2*k+2*j+1),O[2*k+2*j+1]+=V*ue,z(O,2*k+2*j+1),O[2*k+2*j+2]+=F*ue,z(O,2*k+2*j+2)}for(M=0;M>>16,M[A]&=65535,A++}function B(M,A){this.g=M,this.h=A}function H(M,A){if(R(A))throw Error("division by zero");if(R(M))return new B(v,v);if(P(M))return A=H(N(M),A),new B(N(A.g),N(A.h));if(P(A))return A=H(M,N(A)),new B(N(A.g),A.h);if(M.g.length>30){if(P(M)||P(A))throw Error("slowDivide_ only works with positive integers.");for(var O=T,k=A;k.l(M)<=0;)O=K(O),k=K(k);var j=te(O,1),F=te(k,1);for(k=te(k,2),O=te(O,2);!R(k);){var V=F.add(k);V.l(M)<=0&&(j=j.add(O),F=V),k=te(k,1),O=te(O,1)}return A=L(M,j.j(A)),new B(j,A)}for(j=v;M.l(A)>=0;){for(O=Math.max(1,Math.floor(M.m()/A.m())),k=Math.ceil(Math.log(O)/Math.LN2),k=k<=48?1:Math.pow(2,k-48),F=m(O),V=F.j(A);P(V)||V.l(M)>0;)O-=k,F=m(O),V=F.j(A);R(F)&&(F=T),j=j.add(F),M=L(M,V)}return new B(j,M)}t.B=function(M){return H(this,M).h},t.and=function(M){const A=Math.max(this.g.length,M.g.length),O=[];for(let k=0;k>>31;return new c(O,M.h)}function te(M,A){const O=A>>5;A%=32;const k=M.g.length-O,j=[];for(let F=0;F0?M.i(F+O)>>>A|M.i(F+O+1)<<32-A:M.i(F+O);return new c(j,M.h)}s.prototype.digest=s.prototype.A,s.prototype.reset=s.prototype.u,s.prototype.update=s.prototype.v,Y2=s,c.prototype.add=c.prototype.add,c.prototype.multiply=c.prototype.j,c.prototype.modulo=c.prototype.B,c.prototype.compare=c.prototype.l,c.prototype.toNumber=c.prototype.m,c.prototype.toString=c.prototype.toString,c.prototype.getBits=c.prototype.i,c.fromNumber=m,c.fromString=g,qr=c}).apply(typeof DS<"u"?DS:typeof self<"u"?self:typeof window<"u"?window:{});var Qh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var W2,uu,X2,dd,Dv,Z2,J2,eI;(function(){var t,e=Object.defineProperty;function n(h){h=[typeof globalThis=="object"&&globalThis,h,typeof window=="object"&&window,typeof self=="object"&&self,typeof Qh=="object"&&Qh];for(var _=0;_h&&AsyncContext.Snapshot.wrap(h):h=>h;function E(h){const _=h.length;if(_>0){const w=Array(_);for(let D=0;D<_;D++)w[D]=h[D];return w}return[]}function R(h,_){for(let D=1;D0?(this.h--,_=this.g,this.g=_.next,_.next=null):_=this.i(),_}}function N(h){c.setTimeout(()=>{throw h},0)}function L(){var h=M;let _=null;return h.g&&(_=h.g,h.g=h.g.next,h.g||(h.h=null),_.next=null),_}class z{constructor(){this.h=this.g=null}add(_,w){const D=B.get();D.set(_,w),this.h?this.h.next=D:this.g=D,this.h=D}}var B=new P(()=>new H,h=>h.reset());class H{constructor(){this.next=this.g=this.h=null}set(_,w){this.h=_,this.g=w,this.next=null}reset(){this.next=this.g=this.h=null}}let K,te=!1,M=new z,A=()=>{const h=Promise.resolve(void 0);K=()=>{h.then(O)}};function O(){for(var h;h=L();){try{h.h.call(h.g)}catch(w){N(w)}var _=B;_.j(h),_.h<100&&(_.h++,h.next=_.g,_.g=h)}te=!1}function k(){this.u=this.u,this.C=this.C}k.prototype.u=!1,k.prototype.dispose=function(){this.u||(this.u=!0,this.N())},k.prototype[Symbol.dispose]=function(){this.dispose()},k.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function j(h,_){this.type=h,this.g=this.target=_,this.defaultPrevented=!1}j.prototype.h=function(){this.defaultPrevented=!0};var F=(function(){if(!c.addEventListener||!Object.defineProperty)return!1;var h=!1,_=Object.defineProperty({},"passive",{get:function(){h=!0}});try{const w=()=>{};c.addEventListener("test",w,_),c.removeEventListener("test",w,_)}catch{}return h})();function V(h){return/^[\s\xa0]*$/.test(h)}function ue(h,_){j.call(this,h?h.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,h&&this.init(h,_)}v(ue,j),ue.prototype.init=function(h,_){const w=this.type=h.type,D=h.changedTouches&&h.changedTouches.length?h.changedTouches[0]:null;this.target=h.target||h.srcElement,this.g=_,_=h.relatedTarget,_||(w=="mouseover"?_=h.fromElement:w=="mouseout"&&(_=h.toElement)),this.relatedTarget=_,D?(this.clientX=D.clientX!==void 0?D.clientX:D.pageX,this.clientY=D.clientY!==void 0?D.clientY:D.pageY,this.screenX=D.screenX||0,this.screenY=D.screenY||0):(this.clientX=h.clientX!==void 0?h.clientX:h.pageX,this.clientY=h.clientY!==void 0?h.clientY:h.pageY,this.screenX=h.screenX||0,this.screenY=h.screenY||0),this.button=h.button,this.key=h.key||"",this.ctrlKey=h.ctrlKey,this.altKey=h.altKey,this.shiftKey=h.shiftKey,this.metaKey=h.metaKey,this.pointerId=h.pointerId||0,this.pointerType=h.pointerType,this.state=h.state,this.i=h,h.defaultPrevented&&ue.Z.h.call(this)},ue.prototype.h=function(){ue.Z.h.call(this);const h=this.i;h.preventDefault?h.preventDefault():h.returnValue=!1};var ye="closure_listenable_"+(Math.random()*1e6|0),$=0;function le(h,_,w,D,W){this.listener=h,this.proxy=null,this.src=_,this.type=w,this.capture=!!D,this.ha=W,this.key=++$,this.da=this.fa=!1}function se(h){h.da=!0,h.listener=null,h.proxy=null,h.src=null,h.ha=null}function pe(h,_,w){for(const D in h)_.call(w,h[D],D,h)}function S(h,_){for(const w in h)_.call(void 0,h[w],w,h)}function Q(h){const _={};for(const w in h)_[w]=h[w];return _}const ce="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function fe(h,_){let w,D;for(let W=1;W-1?(_=h[he],w||(_.fa=!1)):(_=new le(_,this.src,ee,!!D,W),_.fa=w,h.push(_)),_};function Ee(h,_){const w=_.type;if(w in h.g){var D=h.g[w],W=Array.prototype.indexOf.call(D,_,void 0),ee;(ee=W>=0)&&Array.prototype.splice.call(D,W,1),ee&&(se(_),h.g[w].length==0&&(delete h.g[w],h.h--))}}function ve(h,_,w,D){for(let W=0;W-1&&(se(_[w]),Array.prototype.splice.call(_,w,1),_.length==0&&(delete h.g[ee],h.h--)))):h&&(h=Yl(h))&&(_=h.g[_.toString()],h=-1,_&&(h=ve(_,w,D,W)),(w=h>-1?_[h]:null)&&on(w))}function on(h){if(typeof h!="number"&&h&&!h.da){var _=h.src;if(_&&_[ye])Ee(_.i,h);else{var w=h.type,D=h.proxy;_.removeEventListener?_.removeEventListener(w,D,h.capture):_.detachEvent?_.detachEvent(hs(w),D):_.addListener&&_.removeListener&&_.removeListener(D),(w=Yl(_))?(Ee(w,h),w.h==0&&(w.src=null,_[et]=null)):se(h)}}}function hs(h){return h in qe?qe[h]:qe[h]="on"+h}function Zm(h,_){if(h.da)h=!0;else{_=new ue(_,this);const w=h.listener,D=h.ha||h.src;h.fa&&on(h),h=w.call(D,_)}return h}function Yl(h){return h=h[et],h instanceof de?h:null}var Sn="__closure_events_fn_"+(Math.random()*1e9>>>0);function vf(h){return typeof h=="function"?h:(h[Sn]||(h[Sn]=function(_){return h.handleEvent(_)}),h[Sn])}function kt(){k.call(this),this.i=new de(this),this.M=this,this.G=null}v(kt,k),kt.prototype[ye]=!0,kt.prototype.removeEventListener=function(h,_,w,D){Dn(this,h,_,w,D)};function qt(h,_){var w,D=h.G;if(D)for(w=[];D;D=D.G)w.push(D);if(h=h.M,D=_.type||_,typeof _=="string")_=new j(_,h);else if(_ instanceof j)_.target=_.target||h;else{var W=_;_=new j(D,h),fe(_,W)}W=!0;let ee,he;if(w)for(he=w.length-1;he>=0;he--)ee=_.g=w[he],W=fi(ee,D,!0,_)&&W;if(ee=_.g=h,W=fi(ee,D,!0,_)&&W,W=fi(ee,D,!1,_)&&W,w)for(he=0;he2147483647?-1:c.setTimeout(h,_||0)}function Wl(h){h.g=Jm(()=>{h.g=null,h.i&&(h.i=!1,Wl(h))},h.l);const _=h.h;h.h=null,h.m.apply(null,_)}class ep extends k{constructor(_,w){super(),this.m=_,this.l=w,this.h=null,this.i=!1,this.g=null}j(_){this.h=arguments,this.g?this.i=!0:Wl(this)}N(){super.N(),this.g&&(c.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function fo(h){k.call(this),this.h=h,this.g={}}v(fo,k);var Qi=[];function an(h){pe(h.g,function(_,w){this.g.hasOwnProperty(w)&&on(_)},h),h.g={}}fo.prototype.N=function(){fo.Z.N.call(this),an(this)},fo.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Kn=c.JSON.stringify,gn=c.JSON.parse,tp=class{stringify(h){return c.JSON.stringify(h,void 0)}parse(h){return c.JSON.parse(h,void 0)}};function bf(){}function _f(){}var js={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function Yi(){j.call(this,"d")}v(Yi,j);function ds(){j.call(this,"c")}v(ds,j);var Qn={},Wi=null;function Ta(){return Wi=Wi||new kt}Qn.Ia="serverreachability";function Xl(h){j.call(this,Qn.Ia,h)}v(Xl,j);function Xi(h){const _=Ta();qt(_,new Xl(_))}Qn.STAT_EVENT="statevent";function wa(h,_){j.call(this,Qn.STAT_EVENT,h),this.stat=_}v(wa,j);function _t(h){const _=Ta();qt(_,new wa(_,h))}Qn.Ja="timingevent";function Tf(h,_){j.call(this,Qn.Ja,h),this.size=_}v(Tf,j);function Zi(h,_){if(typeof h!="function")throw Error("Fn must not be null and must be a function");return c.setTimeout(function(){h()},_)}function Ji(){this.g=!0}Ji.prototype.ua=function(){this.g=!1};function Zl(h,_,w,D,W,ee){h.info(function(){if(h.g)if(ee){var he="",De=ee.split("&");for(let Xe=0;Xe1){const xt=ut[0];ut=ut[1];const On=xt.split("_");he=On.length>=2&&On[1]=="type"?he+(xt+"="+ut+"&"):he+(xt+"=redacted&")}}}else he=null;else he=ee;return"XMLHTTP REQ ("+D+") [attempt "+W+"]: "+_+` `+w+` `+he})}function Jl(h,_,w,D,W,ee,he){h.info(function(){return"XMLHTTP RESP ("+D+") [ attempt "+W+"]: "+_+` `+w+` `+ee+" "+he})}function hi(h,_,w,D){h.info(function(){return"XMLHTTP TEXT ("+_+"): "+Ls(h,w)+(D?" "+D:"")})}function np(h,_){h.info(function(){return"TIMEOUT: "+_})}Ji.prototype.info=function(){};function Ls(h,_){if(!h.g)return _;if(!_)return null;try{const ee=JSON.parse(_);if(ee){for(h=0;h0&&h.length;)w.push(h.shift()),_--;return h.length&&w.push(h.join(":")),w}function ms(h,_,w,D){this.j=h,this.i=_,this.l=w,this.S=D||1,this.V=new fo(this),this.H=45e3,this.J=null,this.o=!1,this.u=this.B=this.A=this.M=this.F=this.T=this.D=null,this.G=[],this.g=null,this.C=0,this.m=this.v=null,this.X=-1,this.K=!1,this.P=0,this.O=null,this.W=this.L=this.U=this.R=!1,this.h=new er}function er(){this.i=null,this.g="",this.h=!1}var xa={},Us={};function zs(h,_,w){h.M=1,h.A=pi(pt(_)),h.u=w,h.R=!0,tr(h,null)}function tr(h,_){h.F=Date.now(),po(h),h.B=pt(h.A);var w=h.B,D=h.S;Array.isArray(D)||(D=[String(D)]),Sf(w.i,"t",D),h.C=0,w=h.j.L,h.h=new er,h.g=Oa(h.j,w?_:null,!h.u),h.P>0&&(h.O=new ep(m(h.Y,h,h.g),h.P)),_=h.V,w=h.g,D=h.ba;var W="readystatechange";Array.isArray(W)||(W&&(Qi[0]=W.toString()),W=Qi);for(let ee=0;ee0&&!this.W){this.W=!0;var he=this.j;he.g==this&&he.aa&&!he.P&&(he.j.info("Great, no buffering proxy detected. Bytes received: "+w.length),cc(he),he.P=!0,_t(11))}}else hi(this.i,this.l,w,null),Ea(this,w);De==4&&qs(this),this.o&&!this.K&&(De==4?uc(this.j,this):(this.o=!1,po(this)))}else Ro(this.g),_==400&&w.indexOf("Unknown SID")>0?(this.m=3,_t(12)):(this.m=0,_t(13)),qs(this),go(this)}}}catch{}};function nr(h){if(!wt(h))return h.g.la();const _=Ao(h.g);if(_==="")return"";let w="";const D=_.length,W=ln(h.g)==4;if(!h.h.i){if(typeof TextDecoder>"u")return qs(h),go(h),"";h.h.i=new c.TextDecoder}for(let ee=0;ee_.length?Us:(_=_.slice(D,D+w),h.C=D+w,_)))}ms.prototype.cancel=function(){this.K=!0,qs(this)};function po(h){h.T=Date.now()+h.H,Bs(h,h.H)}function Bs(h,_){if(h.D!=null)throw Error("WatchDog timer not null");h.D=Zi(m(h.aa,h),_)}function Fs(h){h.D&&(c.clearTimeout(h.D),h.D=null)}ms.prototype.aa=function(){this.D=null;const h=Date.now();h-this.T>=0?(np(this.i,this.B),this.M!=2&&(Xi(),_t(17)),qs(this),this.m=2,go(this)):Bs(this,this.T-h)};function go(h){h.j.I==0||h.K||uc(h.j,h)}function qs(h){Fs(h);var _=h.O;_&&typeof _.dispose=="function"&&_.dispose(),h.O=null,an(h.V),h.g&&(_=h.g,h.g=null,_.abort(),_.dispose())}function Ea(h,_){try{var w=h.j;if(w.I!=0&&(w.g==h||bo(w.h,h))){if(!h.L&&bo(w.h,h)&&w.I==3){try{var D=w.Ba.g.parse(_)}catch{D=null}if(Array.isArray(D)&&D.length==3){var W=D;if(W[0]==0){e:if(!w.v){if(w.g)if(w.g.F+3e30&&(D=1.5*ys,w.O=D,w.j.info("backChannelRequestTimeoutMs_="+D)),D=w;const vs=h.g;if(vs){const bs=vs.g?vs.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(bs){var ee=D.h;ee.g||bs.indexOf("spdy")==-1&&bs.indexOf("quic")==-1&&bs.indexOf("h2")==-1||(ee.j=ee.l,ee.g=new Set,ee.h&&(Sa(ee,ee.h),ee.h=null))}if(D.G){const hc=vs.g?vs.g.getResponseHeader("X-HTTP-Session-Id"):null;hc&&(D.wa=hc,tt(D.J,D.G,hc))}}w.I=3,w.l&&w.l.ra(),w.aa&&(w.T=Date.now()-h.F,w.j.info("Handshake RTT: "+w.T+"ms")),D=w;var he=h;if(D.na=Mf(D,D.L?D.ba:null,D.W),he.L){mi(D.h,he);var De=he,ut=D.O;ut&&(De.H=ut),De.D&&(Fs(De),po(De)),D.g=he}else Nf(D);w.i.length>0&&Po(w)}else Xe[0]!="stop"&&Xe[0]!="close"||vi(w,7);else w.I==3&&(Xe[0]=="stop"||Xe[0]=="close"?Xe[0]=="stop"?vi(w,7):Io(w):Xe[0]!="noop"&&w.l&&w.l.qa(Xe),w.A=0)}}Xi(4)}catch{}}var ip=class{constructor(h,_){this.g=h,this.map=_}};function yo(h){this.l=h||10,c.PerformanceNavigationTiming?(h=c.performance.getEntriesByType("navigation"),h=h.length>0&&(h[0].nextHopProtocol=="hq"||h[0].nextHopProtocol=="h2")):h=!!(c.chrome&&c.chrome.loadTimes&&c.chrome.loadTimes()&&c.chrome.loadTimes().wasFetchedViaSpdy),this.j=h?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function vo(h){return h.h?!0:h.g?h.g.size>=h.j:!1}function Yn(h){return h.h?1:h.g?h.g.size:0}function bo(h,_){return h.h?h.h==_:h.g?h.g.has(_):!1}function Sa(h,_){h.g?h.g.add(_):h.h=_}function mi(h,_){h.h&&h.h==_?h.h=null:h.g&&h.g.has(_)&&h.g.delete(_)}yo.prototype.cancel=function(){if(this.i=Aa(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const h of this.g.values())h.cancel();this.g.clear()}};function Aa(h){if(h.h!=null)return h.i.concat(h.h.G);if(h.g!=null&&h.g.size!==0){let _=h.i;for(const w of h.g.values())_=_.concat(w.G);return _}return E(h.i)}var Ra=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function rp(h,_){if(h){h=h.split("&");for(let w=0;w=0?(W=h[w].substring(0,D),ee=h[w].substring(D+1)):W=h[w],_(W,ee?decodeURIComponent(ee.replace(/\+/g," ")):"")}}}function ps(h){this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1;let _;h instanceof ps?(this.l=h.l,sr(this,h.j),this.o=h.o,this.g=h.g,_o(this,h.u),this.h=h.h,ir(this,Af(h.i)),this.m=h.m):h&&(_=String(h).match(Ra))?(this.l=!1,sr(this,_[1]||"",!0),this.o=To(_[2]||""),this.g=To(_[3]||"",!0),_o(this,_[4]),this.h=To(_[5]||"",!0),ir(this,_[6]||"",!0),this.m=To(_[7]||"")):(this.l=!1,this.i=new Wn(null,this.l))}ps.prototype.toString=function(){const h=[];var _=this.j;_&&h.push(Ht(_,tc,!0),":");var w=this.g;return(w||_=="file")&&(h.push("//"),(_=this.o)&&h.push(Ht(_,tc,!0),"@"),h.push(mo(w).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),w=this.u,w!=null&&h.push(":",String(w))),(w=this.h)&&(this.g&&w.charAt(0)!="/"&&h.push("/"),h.push(Ht(w,w.charAt(0)=="/"?rr:nc,!0))),(w=this.i.toString())&&h.push("?",w),(w=this.m)&&h.push("#",Ht(w,Ef)),h.join("")},ps.prototype.resolve=function(h){const _=pt(this);let w=!!h.j;w?sr(_,h.j):w=!!h.o,w?_.o=h.o:w=!!h.g,w?_.g=h.g:w=h.u!=null;var D=h.h;if(w)_o(_,h.u);else if(w=!!h.h){if(D.charAt(0)!="/")if(this.g&&!this.h)D="/"+D;else{var W=_.h.lastIndexOf("/");W!=-1&&(D=_.h.slice(0,W+1)+D)}if(W=D,W==".."||W==".")D="";else if(W.indexOf("./")!=-1||W.indexOf("/.")!=-1){D=W.lastIndexOf("/",0)==0,W=W.split("/");const ee=[];for(let he=0;he1||ee.length==1&&ee[0]!="")&&ee.pop(),D&&he==W.length&&ee.push("")):(ee.push(De),D=!0)}D=ee.join("/")}else D=W}return w?_.h=D:w=h.i.toString()!=="",w?ir(_,Af(h.i)):w=!!h.m,w&&(_.m=h.m),_};function pt(h){return new ps(h)}function sr(h,_,w){h.j=w?To(_,!0):_,h.j&&(h.j=h.j.replace(/:$/,""))}function _o(h,_){if(_){if(_=Number(_),isNaN(_)||_<0)throw Error("Bad port number "+_);h.u=_}else h.u=null}function ir(h,_,w){_ instanceof Wn?(h.i=_,rc(h.i,h.l)):(w||(_=Ht(_,xf)),h.i=new Wn(_,h.l))}function tt(h,_,w){h.i.set(_,w)}function pi(h){return tt(h,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),h}function To(h,_){return h?_?decodeURI(h.replace(/%25/g,"%2525")):decodeURIComponent(h):""}function Ht(h,_,w){return typeof h=="string"?(h=encodeURI(h).replace(_,ec),w&&(h=h.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),h):null}function ec(h){return h=h.charCodeAt(0),"%"+(h>>4&15).toString(16)+(h&15).toString(16)}var tc=/[#\/\?@]/g,nc=/[#\?:]/g,rr=/[#\?]/g,xf=/[#\?@]/g,Ef=/#/g;function Wn(h,_){this.h=this.g=null,this.i=h||null,this.j=!!_}function gi(h){h.g||(h.g=new Map,h.h=0,h.i&&rp(h.i,function(_,w){h.add(decodeURIComponent(_.replace(/\+/g," ")),w)}))}t=Wn.prototype,t.add=function(h,_){gi(this),this.i=null,h=gs(this,h);let w=this.g.get(h);return w||this.g.set(h,w=[]),w.push(_),this.h+=1,this};function sc(h,_){gi(h),_=gs(h,_),h.g.has(_)&&(h.i=null,h.h-=h.g.get(_).length,h.g.delete(_))}function ic(h,_){return gi(h),_=gs(h,_),h.g.has(_)}t.forEach=function(h,_){gi(this),this.g.forEach(function(w,D){w.forEach(function(W){h.call(_,W,D,this)},this)},this)};function Ca(h,_){gi(h);let w=[];if(typeof _=="string")ic(h,_)&&(w=w.concat(h.g.get(gs(h,_))));else for(h=Array.from(h.g.values()),_=0;_0?String(h[0]):_):_};function Sf(h,_,w){sc(h,_),w.length>0&&(h.i=null,h.g.set(gs(h,_),E(w)),h.h+=w.length)}t.toString=function(){if(this.i)return this.i;if(!this.g)return"";const h=[],_=Array.from(this.g.keys());for(let D=0;D<_.length;D++){var w=_[D];const W=mo(w);w=Ca(this,w);for(let ee=0;ee{D.abort(),yn(w,"TestPingServer: timeout",!1,_)},1e4);fetch(h,{signal:D.signal}).then(ee=>{clearTimeout(W),ee.ok?yn(w,"TestPingServer: ok",!0,_):yn(w,"TestPingServer: server error",!1,_)}).catch(()=>{clearTimeout(W),yn(w,"TestPingServer: error",!1,_)})}function yn(h,_,w,D,W){try{W&&(W.onload=null,W.onerror=null,W.onabort=null,W.ontimeout=null),D(w)}catch{}}function Rf(){this.g=new tp}function wo(h){this.i=h.Sb||null,this.h=h.ab||!1}v(wo,bf),wo.prototype.g=function(){return new xo(this.i,this.h)};function xo(h,_){kt.call(this),this.H=h,this.o=_,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.A=new Headers,this.h=null,this.F="GET",this.D="",this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}v(xo,kt),t=xo.prototype,t.open=function(h,_){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.F=h,this.D=_,this.readyState=1,yi(this)},t.send=function(h){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");if(this.v.signal.aborted)throw this.abort(),Error("Request was aborted.");this.g=!0;const _={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};h&&(_.body=h),(this.H||c).fetch(new Request(this.D,_)).then(this.Pa.bind(this),this.ga.bind(this))},t.abort=function(){this.response=this.responseText="",this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),this.readyState>=1&&this.g&&this.readyState!=4&&(this.g=!1,vn(this)),this.readyState=0},t.Pa=function(h){if(this.g&&(this.l=h,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=h.headers,this.readyState=2,yi(this)),this.g&&(this.readyState=3,yi(this),this.g)))if(this.responseType==="arraybuffer")h.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(typeof c.ReadableStream<"u"&&"body"in h){if(this.j=h.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.B=new TextDecoder;ar(this)}else h.text().then(this.Oa.bind(this),this.ga.bind(this))};function ar(h){h.j.read().then(h.Ma.bind(h)).catch(h.ga.bind(h))}t.Ma=function(h){if(this.g){if(this.o&&h.value)this.response.push(h.value);else if(!this.o){var _=h.value?h.value:new Uint8Array(0);(_=this.B.decode(_,{stream:!h.done}))&&(this.response=this.responseText+=_)}h.done?vn(this):yi(this),this.readyState==3&&ar(this)}},t.Oa=function(h){this.g&&(this.response=this.responseText=h,vn(this))},t.Na=function(h){this.g&&(this.response=h,vn(this))},t.ga=function(){this.g&&vn(this)};function vn(h){h.readyState=4,h.l=null,h.j=null,h.B=null,yi(h)}t.setRequestHeader=function(h,_){this.A.append(h,_)},t.getResponseHeader=function(h){return this.h&&this.h.get(h.toLowerCase())||""},t.getAllResponseHeaders=function(){if(!this.h)return"";const h=[],_=this.h.entries();for(var w=_.next();!w.done;)w=w.value,h.push(w[0]+": "+w[1]),w=_.next();return h.join(`\r `)};function yi(h){h.onreadystatechange&&h.onreadystatechange.call(h)}Object.defineProperty(xo.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(h){this.m=h?"include":"same-origin"}});function lr(h){let _="";return pe(h,function(w,D){_+=D,_+=":",_+=w,_+=`\r `}),_}function Xn(h,_,w){e:{for(D in w){var D=!1;break e}D=!0}D||(w=lr(w),typeof h=="string"?w!=null&&mo(w):tt(h,_,w))}function at(h){kt.call(this),this.headers=new Map,this.L=h||null,this.h=!1,this.g=null,this.D="",this.o=0,this.l="",this.j=this.B=this.v=this.A=!1,this.m=null,this.F="",this.H=!1}v(at,kt);var Ia=/^https?$/i,Cf=["POST","PUT"];t=at.prototype,t.Fa=function(h){this.H=h},t.ea=function(h,_,w,D){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+h);_=_?_.toUpperCase():"GET",this.D=h,this.l="",this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():di.g(),this.g.onreadystatechange=T(m(this.Ca,this));try{this.B=!0,this.g.open(_,String(h),!0),this.B=!1}catch(ee){Eo(this,ee);return}if(h=w||"",w=new Map(this.headers),D)if(Object.getPrototypeOf(D)===Object.prototype)for(var W in D)w.set(W,D[W]);else if(typeof D.keys=="function"&&typeof D.get=="function")for(const ee of D.keys())w.set(ee,D.get(ee));else throw Error("Unknown input type for opt_headers: "+String(D));D=Array.from(w.keys()).find(ee=>ee.toLowerCase()=="content-type"),W=c.FormData&&h instanceof c.FormData,!(Array.prototype.indexOf.call(Cf,_,void 0)>=0)||D||W||w.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[ee,he]of w)this.g.setRequestHeader(ee,he);this.F&&(this.g.responseType=this.F),"withCredentials"in this.g&&this.g.withCredentials!==this.H&&(this.g.withCredentials=this.H);try{this.m&&(clearTimeout(this.m),this.m=null),this.v=!0,this.g.send(h),this.v=!1}catch(ee){Eo(this,ee)}};function Eo(h,_){h.h=!1,h.g&&(h.j=!0,h.g.abort(),h.j=!1),h.l=_,h.o=5,So(h),Vt(h)}function So(h){h.A||(h.A=!0,qt(h,"complete"),qt(h,"error"))}t.abort=function(h){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=h||7,qt(this,"complete"),qt(this,"abort"),Vt(this))},t.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Vt(this,!0)),at.Z.N.call(this)},t.Ca=function(){this.u||(this.B||this.v||this.j?ac(this):this.Xa())},t.Xa=function(){ac(this)};function ac(h){if(h.h&&typeof l<"u"){if(h.v&&ln(h)==4)setTimeout(h.Ca.bind(h),0);else if(qt(h,"readystatechange"),ln(h)==4){h.h=!1;try{const ee=h.ca();e:switch(ee){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var _=!0;break e;default:_=!1}var w;if(!(w=_)){var D;if(D=ee===0){let he=String(h.D).match(Ra)[1]||null;!he&&c.self&&c.self.location&&(he=c.self.location.protocol.slice(0,-1)),D=!Ia.test(he?he.toLowerCase():"")}w=D}if(w)qt(h,"complete"),qt(h,"success");else{h.o=6;try{var W=ln(h)>2?h.g.statusText:""}catch{W=""}h.l=W+" ["+h.ca()+"]",So(h)}}finally{Vt(h)}}}}function Vt(h,_){if(h.g){h.m&&(clearTimeout(h.m),h.m=null);const w=h.g;h.g=null,_||qt(h,"ready");try{w.onreadystatechange=null}catch{}}}t.isActive=function(){return!!this.g};function ln(h){return h.g?h.g.readyState:0}t.ca=function(){try{return ln(this)>2?this.g.status:-1}catch{return-1}},t.la=function(){try{return this.g?this.g.responseText:""}catch{return""}},t.La=function(h){if(this.g){var _=this.g.responseText;return h&&_.indexOf(h)==0&&(_=_.substring(h.length)),gn(_)}};function Ao(h){try{if(!h.g)return null;if("response"in h.g)return h.g.response;switch(h.F){case"":case"text":return h.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in h.g)return h.g.mozResponseArrayBuffer}return null}catch{return null}}function Ro(h){const _={};h=(h.g&&ln(h)>=2&&h.g.getAllResponseHeaders()||"").split(`\r `);for(let D=0;D0&&(this.ia=h.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}t=Na.prototype,t.ka=8,t.I=1,t.connect=function(h,_,w,D){_t(0),this.W=h,this.H=_||{},w&&D!==void 0&&(this.H.OSID=w,this.H.OAID=D),this.F=this.X,this.J=Mf(this,null,this.W),Po(this)};function Io(h){if(No(h),h.I==3){var _=h.V++,w=pt(h.J);if(tt(w,"SID",h.M),tt(w,"RID",_),tt(w,"TYPE","terminate"),Do(h,w),_=new ms(h,h.j,_),_.M=2,_.A=pi(pt(w)),w=!1,c.navigator&&c.navigator.sendBeacon)try{w=c.navigator.sendBeacon(_.A.toString(),"")}catch{}!w&&c.Image&&(new Image().src=_.A,w=!0),w||(_.g=Oa(_.j,null),_.g.ea(_.A)),_.F=Date.now(),po(_)}Of(h)}function Hs(h){h.g&&(cc(h),h.g.cancel(),h.g=null)}function No(h){Hs(h),h.v&&(c.clearTimeout(h.v),h.v=null),Da(h),h.h.cancel(),h.m&&(typeof h.m=="number"&&c.clearTimeout(h.m),h.m=null)}function Po(h){if(!vo(h.h)&&!h.m){h.m=!0;var _=h.Ea;K||A(),te||(K(),te=!0),M.add(_,h),h.D=0}}function op(h,_){return Yn(h.h)>=h.h.j-(h.m?1:0)?!1:h.m?(h.i=_.G.concat(h.i),!0):h.I==1||h.I==2||h.D>=(h.Sa?0:h.Ta)?!1:(h.m=Zi(m(h.Ea,h,_),Df(h,h.D)),h.D++,!0)}t.Ea=function(h){if(this.m)if(this.m=null,this.I==1){if(!h){this.V=Math.floor(Math.random()*1e5),h=this.V++;const W=new ms(this,this.j,h);let ee=this.o;if(this.U&&(ee?(ee=Q(ee),fe(ee,this.U)):ee=this.U),this.u!==null||this.R||(W.J=ee,ee=null),this.S)e:{for(var _=0,w=0;w4096){_=w;break e}if(_===4096||w===this.i.length-1){_=w+1;break e}}_=1e3}else _=1e3;_=Pa(this,W,_),w=pt(this.J),tt(w,"RID",h),tt(w,"CVER",22),this.G&&tt(w,"X-HTTP-Session-Id",this.G),Do(this,w),ee&&(this.R?_="headers="+mo(lr(ee))+"&"+_:this.u&&Xn(w,this.u,ee)),Sa(this.h,W),this.Ra&&tt(w,"TYPE","init"),this.S?(tt(w,"$req",_),tt(w,"SID","null"),W.U=!0,zs(W,w,null)):zs(W,w,_),this.I=2}}else this.I==3&&(h?If(this,h):this.i.length==0||vo(this.h)||If(this))};function If(h,_){var w;_?w=_.l:w=h.V++;const D=pt(h.J);tt(D,"SID",h.M),tt(D,"RID",w),tt(D,"AID",h.K),Do(h,D),h.u&&h.o&&Xn(D,h.u,h.o),w=new ms(h,h.j,w,h.D+1),h.u===null&&(w.J=h.o),_&&(h.i=_.G.concat(h.i)),_=Pa(h,w,1e3),w.H=Math.round(h.va*.5)+Math.round(h.va*.5*Math.random()),Sa(h.h,w),zs(w,D,_)}function Do(h,_){h.H&&pe(h.H,function(w,D){tt(_,D,w)}),h.l&&pe({},function(w,D){tt(_,D,w)})}function Pa(h,_,w){w=Math.min(h.i.length,w);const D=h.l?m(h.l.Ka,h.l,h):null;e:{var W=h.i;let De=-1;for(;;){const ut=["count="+w];De==-1?w>0?(De=W[0].g,ut.push("ofs="+De)):De=0:ut.push("ofs="+De);let Xe=!0;for(let xt=0;xt=3?!1:(h.Y++,h.v=Zi(m(h.Da,h),Df(h,h.A)),h.A++,!0)}t.Da=function(){if(this.v=null,Pf(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var h=4*this.T;this.j.info("BP detection timer enabled: "+h),this.B=Zi(m(this.Wa,this),h)}},t.Wa=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.P=!0,_t(10),Hs(this),Pf(this))};function cc(h){h.B!=null&&(c.clearTimeout(h.B),h.B=null)}function Pf(h){h.g=new ms(h,h.j,"rpc",h.Y),h.u===null&&(h.g.J=h.o),h.g.P=0;var _=pt(h.na);tt(_,"RID","rpc"),tt(_,"SID",h.M),tt(_,"AID",h.K),tt(_,"CI",h.F?"0":"1"),!h.F&&h.ia&&tt(_,"TO",h.ia),tt(_,"TYPE","xmlhttp"),Do(h,_),h.u&&h.o&&Xn(_,h.u,h.o),h.O&&(h.g.H=h.O);var w=h.g;h=h.ba,w.M=1,w.A=pi(pt(_)),w.u=null,w.R=!0,tr(w,h)}t.Va=function(){this.C!=null&&(this.C=null,Hs(this),lc(this),_t(19))};function Da(h){h.C!=null&&(c.clearTimeout(h.C),h.C=null)}function uc(h,_){var w=null;if(h.g==_){Da(h),cc(h),h.g=null;var D=2}else if(bo(h.h,_))w=_.G,mi(h.h,_),D=1;else return;if(h.I!=0){if(_.o)if(D==1){w=_.u?_.u.length:0,_=Date.now()-_.F;var W=h.D;D=Ta(),qt(D,new Tf(D,w)),Po(h)}else Nf(h);else if(W=_.m,W==3||W==0&&_.X>0||!(D==1&&op(h,_)||D==2&&lc(h)))switch(w&&w.length>0&&(_=h.h,_.i=_.i.concat(w)),W){case 1:vi(h,5);break;case 4:vi(h,10);break;case 3:vi(h,6);break;default:vi(h,2)}}}function Df(h,_){let w=h.Qa+Math.floor(Math.random()*h.Za);return h.isActive()||(w*=2),w*_}function vi(h,_){if(h.j.info("Error code "+_),_==2){var w=m(h.bb,h),D=h.Ua;const W=!D;D=new ps(D||"//www.google.com/images/cleardot.gif"),c.location&&c.location.protocol=="http"||sr(D,"https"),pi(D),W?oc(D.toString(),w):or(D.toString(),w)}else _t(2);h.I=0,h.l&&h.l.pa(_),Of(h),No(h)}t.bb=function(h){h?(this.j.info("Successfully pinged google.com"),_t(2)):(this.j.info("Failed to ping google.com"),_t(1))};function Of(h){if(h.I=0,h.ja=[],h.l){const _=Aa(h.h);(_.length!=0||h.i.length!=0)&&(R(h.ja,_),R(h.ja,h.i),h.h.i.length=0,E(h.i),h.i.length=0),h.l.oa()}}function Mf(h,_,w){var D=w instanceof ps?pt(w):new ps(w);if(D.g!="")_&&(D.g=_+"."+D.g),_o(D,D.u);else{var W=c.location;D=W.protocol,_=_?_+"."+W.hostname:W.hostname,W=+W.port;const ee=new ps(null);D&&sr(ee,D),_&&(ee.g=_),W&&_o(ee,W),w&&(ee.h=w),D=ee}return w=h.G,_=h.wa,w&&_&&tt(D,w,_),tt(D,"VER",h.ka),Do(h,D),D}function Oa(h,_,w){if(_&&!h.L)throw Error("Can't create secondary domain capable XhrIo object.");return _=h.Aa&&!h.ma?new at(new wo({ab:w})):new at(h.ma),_.Fa(h.L),_}t.isActive=function(){return!!this.l&&this.l.isActive(this)};function kf(){}t=kf.prototype,t.ra=function(){},t.qa=function(){},t.pa=function(){},t.oa=function(){},t.isActive=function(){return!0},t.Ka=function(){};function Ma(){}Ma.prototype.g=function(h,_){return new bn(h,_)};function bn(h,_){kt.call(this),this.g=new Na(_),this.l=h,this.h=_&&_.messageUrlParams||null,h=_&&_.messageHeaders||null,_&&_.clientProtocolHeaderRequired&&(h?h["X-Client-Protocol"]="webchannel":h={"X-Client-Protocol":"webchannel"}),this.g.o=h,h=_&&_.initMessageHeaders||null,_&&_.messageContentType&&(h?h["X-WebChannel-Content-Type"]=_.messageContentType:h={"X-WebChannel-Content-Type":_.messageContentType}),_&&_.sa&&(h?h["X-WebChannel-Client-Profile"]=_.sa:h={"X-WebChannel-Client-Profile":_.sa}),this.g.U=h,(h=_&&_.Qb)&&!V(h)&&(this.g.u=h),this.A=_&&_.supportsCrossDomainXhr||!1,this.v=_&&_.sendRawJson||!1,(_=_&&_.httpSessionIdParam)&&!V(_)&&(this.g.G=_,h=this.h,h!==null&&_ in h&&(h=this.h,_ in h&&delete h[_])),this.j=new cr(this)}v(bn,kt),bn.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},bn.prototype.close=function(){Io(this.g)},bn.prototype.o=function(h){var _=this.g;if(typeof h=="string"){var w={};w.__data__=h,h=w}else this.v&&(w={},w.__data__=Kn(h),h=w);_.i.push(new ip(_.Ya++,h)),_.I==3&&Po(_)},bn.prototype.N=function(){this.g.l=null,delete this.j,Io(this.g),delete this.g,bn.Z.N.call(this)};function fc(h){Yi.call(this),h.__headers__&&(this.headers=h.__headers__,this.statusCode=h.__status__,delete h.__headers__,delete h.__status__);var _=h.__sm__;if(_){e:{for(const w in _){h=w;break e}h=void 0}(this.i=h)&&(h=this.i,_=_!==null&&h in _?_[h]:void 0),this.data=_}else this.data=h}v(fc,Yi);function Vf(){ds.call(this),this.status=1}v(Vf,ds);function cr(h){this.g=h}v(cr,kf),cr.prototype.ra=function(){qt(this.g,"a")},cr.prototype.qa=function(h){qt(this.g,new fc(h))},cr.prototype.pa=function(h){qt(this.g,new Vf)},cr.prototype.oa=function(){qt(this.g,"b")},Ma.prototype.createWebChannel=Ma.prototype.g,bn.prototype.send=bn.prototype.o,bn.prototype.open=bn.prototype.m,bn.prototype.close=bn.prototype.close,eI=function(){return new Ma},J2=function(){return Ta()},Z2=Qn,Dv={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},Tt.NO_ERROR=0,Tt.TIMEOUT=8,Tt.HTTP_ERROR=6,dd=Tt,Wt.COMPLETE="complete",X2=Wt,_f.EventType=js,js.OPEN="a",js.CLOSE="b",js.ERROR="c",js.MESSAGE="d",kt.prototype.listen=kt.prototype.J,uu=_f,at.prototype.listenOnce=at.prototype.K,at.prototype.getLastError=at.prototype.Ha,at.prototype.getLastErrorCode=at.prototype.ya,at.prototype.getStatus=at.prototype.ca,at.prototype.getResponseJson=at.prototype.La,at.prototype.getResponseText=at.prototype.la,at.prototype.send=at.prototype.ea,at.prototype.setWithCredentials=at.prototype.Fa,W2=at}).apply(typeof Qh<"u"?Qh:typeof self<"u"?self:typeof window<"u"?window:{});class hn{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}hn.UNAUTHENTICATED=new hn(null),hn.GOOGLE_CREDENTIALS=new hn("google-credentials-uid"),hn.FIRST_PARTY=new hn("first-party-uid"),hn.MOCK_USER=new hn("mock-user");let ql="12.14.0";function Iz(t){ql=t}const fa=new Wb("@firebase/firestore");function ul(){return fa.logLevel}function me(t,...e){if(fa.logLevel<=Fe.DEBUG){const n=e.map(Jb);fa.debug(`Firestore (${ql}): ${t}`,...n)}}function Fi(t,...e){if(fa.logLevel<=Fe.ERROR){const n=e.map(Jb);fa.error(`Firestore (${ql}): ${t}`,...n)}}function ha(t,...e){if(fa.logLevel<=Fe.WARN){const n=e.map(Jb);fa.warn(`Firestore (${ql}): ${t}`,...n)}}function Jb(t){if(typeof t=="string")return t;try{return(function(n){return JSON.stringify(n)})(t)}catch{return t}}function Ie(t,e,n){let s="Unexpected state";typeof e=="string"?s=e:n=e,tI(t,s,n)}function tI(t,e,n){let s=`FIRESTORE (${ql}) INTERNAL ASSERTION FAILED: ${e} (ID: ${t.toString(16)})`;if(n!==void 0)try{s+=" CONTEXT: "+JSON.stringify(n)}catch{s+=" CONTEXT: "+n}throw Fi(s),new Error(s)}function We(t,e,n,s){let o="Unexpected state";typeof n=="string"?o=n:s=n,t||tI(e,o,s)}function Oe(t,e){return t}const re={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class ge extends $i{constructor(e,n){super(e,n),this.code=e,this.message=n,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class ji{constructor(){this.promise=new Promise(((e,n)=>{this.resolve=e,this.reject=n}))}}class nI{constructor(e,n){this.user=n,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class Nz{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,n){e.enqueueRetryable((()=>n(hn.UNAUTHENTICATED)))}shutdown(){}}class Pz{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 Dz{constructor(e){this.t=e,this.currentUser=hn.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,n){We(this.o===void 0,42304);let s=this.i;const o=d=>this.i!==s?(s=this.i,n(d)):Promise.resolve();let l=new ji;this.o=()=>{this.i++,this.currentUser=this.u(),l.resolve(),l=new ji,e.enqueueRetryable((()=>o(this.currentUser)))};const c=()=>{const d=l;e.enqueueRetryable((async()=>{await d.promise,await o(this.currentUser)}))},f=d=>{me("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=d,this.o&&(this.auth.addAuthTokenListener(this.o),c())};this.t.onInit((d=>f(d))),setTimeout((()=>{if(!this.auth){const d=this.t.getImmediate({optional:!0});d?f(d):(me("FirebaseAuthCredentialsProvider","Auth not yet detected"),l.resolve(),l=new ji)}}),0),c()}getToken(){const e=this.i,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then((s=>this.i!==e?(me("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):s?(We(typeof s.accessToken=="string",31837,{l:s}),new nI(s.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 We(e===null||typeof e=="string",2055,{h:e}),new hn(e)}}class Oz{constructor(e,n,s){this.P=e,this.T=n,this.I=s,this.type="FirstParty",this.user=hn.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set("X-Goog-AuthUser",this.P);const e=this.A();return e&&this.R.set("Authorization",e),this.T&&this.R.set("X-Goog-Iam-Authorization-Token",this.T),this.R}}class Mz{constructor(e,n,s){this.P=e,this.T=n,this.I=s}getToken(){return Promise.resolve(new Oz(this.P,this.T,this.I))}start(e,n){e.enqueueRetryable((()=>n(hn.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class OS{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 kz{constructor(e,n){this.V=n,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,Fn(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,n){We(this.o===void 0,3512);const s=l=>{l.error!=null&&me("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${l.error.message}`);const c=l.token!==this.m;return this.m=l.token,me("FirebaseAppCheckTokenProvider",`Received ${c?"new":"existing"} token.`),c?n(l.token):Promise.resolve()};this.o=l=>{e.enqueueRetryable((()=>s(l)))};const o=l=>{me("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=l,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((l=>o(l))),setTimeout((()=>{if(!this.appCheck){const l=this.V.getImmediate({optional:!0});l?o(l):me("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){if(this.p)return Promise.resolve(new OS(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((n=>n?(We(typeof n.token=="string",44558,{tokenResult:n}),this.m=n.token,new OS(n.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}function Vz(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 s=0;se?1:0}function Ov(t,e){const n=Math.min(t.length,e.length);for(let s=0;s=jz&&e<=Lz}function Pl(t,e,n){return t.length===e.length&&t.every(((s,o)=>n(s,e[o])))}const MS="__name__";class Zs{constructor(e,n,s){n===void 0?n=0:n>e.length&&Ie(637,{offset:n,range:e.length}),s===void 0?s=e.length-n:s>e.length-n&&Ie(1746,{length:s,range:e.length-n}),this.segments=e,this.offset=n,this.len=s}get length(){return this.len}isEqual(e){return Zs.comparator(this,e)===0}child(e){const n=this.segments.slice(this.offset,this.limit());return e instanceof Zs?e.forEach((s=>{n.push(s)})):n.push(e),this.construct(n)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length=0)throw new ge(re.INVALID_ARGUMENT,`Invalid segment (${s}). Paths must not contain // in them.`);n.push(...s.split("/").filter((o=>o.length>0)))}return new ct(n)}static emptyPath(){return new ct([])}}const Uz=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class nn extends Zs{construct(e,n,s){return new nn(e,n,s)}static isValidIdentifier(e){return Uz.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),nn.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===MS}static keyField(){return new nn([MS])}static fromServerFormat(e){const n=[];let s="",o=0;const l=()=>{if(s.length===0)throw new ge(re.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);n.push(s),s=""};let c=!1;for(;o=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&&ct.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,n){return ct.comparator(e.path,n.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new Se(new ct(e.slice()))}}function sI(t,e,n){if(!n)throw new ge(re.INVALID_ARGUMENT,`Function ${t}() cannot be called with an empty ${e}.`)}function zz(t,e,n,s){if(e===!0&&s===!0)throw new ge(re.INVALID_ARGUMENT,`${t} and ${n} cannot be used together.`)}function kS(t){if(!Se.isDocumentKey(t))throw new ge(re.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`)}function VS(t){if(Se.isDocumentKey(t))throw new ge(re.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`)}function iI(t){return typeof t=="object"&&t!==null&&(Object.getPrototypeOf(t)===Object.prototype||Object.getPrototypeOf(t)===null)}function Im(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(s){return s.constructor?s.constructor.name:null})(t);return e?`a custom ${e} object`:"an object"}}return typeof t=="function"?"a function":Ie(12329,{type:typeof t})}function Ms(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new ge(re.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=Im(t);throw new ge(re.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${n}`)}}return t}function Mt(t,e){const n={typeString:t};return e&&(n.value=e),n}function of(t,e){if(!iI(t))throw new ge(re.INVALID_ARGUMENT,"JSON must be an object");let n;for(const s in e)if(e[s]){const o=e[s].typeString,l="value"in e[s]?{value:e[s].value}:void 0;if(!(s in t)){n=`JSON missing required field: '${s}'`;break}const c=t[s];if(o&&typeof c!==o){n=`JSON field '${s}' must be a ${o}.`;break}if(l!==void 0&&c!==l.value){n=`Expected '${s}' field to equal '${l.value}'`;break}}if(n)throw new ge(re.INVALID_ARGUMENT,n);return!0}const jS=-62135596800,LS=1e6;class ft{static now(){return ft.fromMillis(Date.now())}static fromDate(e){return ft.fromMillis(e.getTime())}static fromMillis(e){const n=Math.floor(e/1e3),s=Math.floor((e-1e3*n)*LS);return new ft(n,s)}constructor(e,n){if(this.seconds=e,this.nanoseconds=n,n<0)throw new ge(re.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(n>=1e9)throw new ge(re.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(e=253402300800)throw new ge(re.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/LS}_compareTo(e){return this.seconds===e.seconds?ze(this.nanoseconds,e.nanoseconds):ze(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:ft._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(of(e,ft._jsonSchema))return new ft(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-jS;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}ft._jsonSchemaVersion="firestore/timestamp/1.0",ft._jsonSchema={type:Mt("string",ft._jsonSchemaVersion),seconds:Mt("number"),nanoseconds:Mt("number")};class Pe{static fromTimestamp(e){return new Pe(e)}static min(){return new Pe(new ft(0,0))}static max(){return new Pe(new ft(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}const Vu=-1;function Bz(t,e){const n=t.toTimestamp().seconds,s=t.toTimestamp().nanoseconds+1,o=Pe.fromTimestamp(s===1e9?new ft(n+1,0):new ft(n,s));return new Xr(o,Se.empty(),e)}function Fz(t){return new Xr(t.readTime,t.key,Vu)}class Xr{constructor(e,n,s){this.readTime=e,this.documentKey=n,this.largestBatchId=s}static min(){return new Xr(Pe.min(),Se.empty(),Vu)}static max(){return new Xr(Pe.max(),Se.empty(),Vu)}}function qz(t,e){let n=t.readTime.compareTo(e.readTime);return n!==0?n:(n=Se.comparator(t.documentKey,e.documentKey),n!==0?n:ze(t.largestBatchId,e.largestBatchId))}const Hz="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class Gz{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}}async function Hl(t){if(t.code!==re.FAILED_PRECONDITION||t.message!==Hz)throw t;me("LocalStore","Unexpectedly lost primary lease")}class ae{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&&Ie(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(e,this.result):new ae(((s,o)=>{this.nextCallback=l=>{this.wrapSuccess(e,l).next(s,o)},this.catchCallback=l=>{this.wrapFailure(n,l).next(s,o)}}))}toPromise(){return new Promise(((e,n)=>{this.next(e,n)}))}wrapUserFunction(e){try{const n=e();return n instanceof ae?n:ae.resolve(n)}catch(n){return ae.reject(n)}}wrapSuccess(e,n){return e?this.wrapUserFunction((()=>e(n))):ae.resolve(n)}wrapFailure(e,n){return e?this.wrapUserFunction((()=>e(n))):ae.reject(n)}static resolve(e){return new ae(((n,s)=>{n(e)}))}static reject(e){return new ae(((n,s)=>{s(e)}))}static waitFor(e){return new ae(((n,s)=>{let o=0,l=0,c=!1;e.forEach((f=>{++o,f.next((()=>{++l,c&&l===o&&n()}),(d=>s(d)))})),c=!0,l===o&&n()}))}static or(e){let n=ae.resolve(!1);for(const s of e)n=n.next((o=>o?ae.resolve(o):s()));return n}static forEach(e,n){const s=[];return e.forEach(((o,l)=>{s.push(n.call(this,o,l))})),this.waitFor(s)}static mapArray(e,n){return new ae(((s,o)=>{const l=e.length,c=new Array(l);let f=0;for(let d=0;d{c[m]=g,++f,f===l&&s(c)}),(g=>o(g)))}}))}static doWhile(e,n){return new ae(((s,o)=>{const l=()=>{e()===!0?n().next((()=>{l()}),o):s()};l()}))}}function $z(t){const e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)}function Gl(t){return t.name==="IndexedDbTransactionError"}class Nm{constructor(e,n){this.previousValue=e,n&&(n.sequenceNumberHandler=s=>this.ae(s),this.ue=s=>n.writeSequenceNumber(s))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ue&&this.ue(e),e}}Nm.ce=-1;const t0=-1;function Pm(t){return t==null}function Fd(t){return t===0&&1/t==-1/0}function Kz(t){return typeof t=="number"&&Number.isInteger(t)&&!Fd(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}const rI="";function Qz(t){let e="";for(let n=0;n0&&(e=US(e)),e=Yz(t.get(n),e);return US(e)}function Yz(t,e){let n=e;const s=t.length;for(let o=0;o0&&(n=n.right)}return null}indexOf(e){let n=0,s=this.root;for(;!s.isEmpty();){const o=this.comparator(e,s.key);if(o===0)return n+s.left.size;o<0?s=s.left:(n+=s.left.size+1,s=s.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,s)=>(e(n,s),!1)))}toString(){const e=[];return this.inorderTraversal(((n,s)=>(e.push(`${n}:${s}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Yh(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Yh(this.root,e,this.comparator,!1)}getReverseIterator(){return new Yh(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Yh(this.root,e,this.comparator,!0)}}class Yh{constructor(e,n,s,o){this.isReverse=o,this.nodeStack=[];let l=1;for(;!e.isEmpty();)if(l=n?s(e.key,n):1,n&&o&&(l*=-1),l<0)e=this.isReverse?e.left:e.right;else{if(l===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 tn{constructor(e,n,s,o,l){this.key=e,this.value=n,this.color=s??tn.RED,this.left=o??tn.EMPTY,this.right=l??tn.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,n,s,o,l){return new tn(e??this.key,n??this.value,s??this.color,o??this.left,l??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,s){let o=this;const l=s(e,o.key);return o=l<0?o.copy(null,null,null,o.left.insert(e,n,s),null):l===0?o.copy(null,n,null,null,null):o.copy(null,null,null,null,o.right.insert(e,n,s)),o.fixUp()}removeMin(){if(this.left.isEmpty())return tn.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 s,o=this;if(n(e,o.key)<0)o.left.isEmpty()||o.left.isRed()||o.left.left.isRed()||(o=o.moveRedLeft()),o=o.copy(null,null,null,o.left.remove(e,n),null);else{if(o.left.isRed()&&(o=o.rotateRight()),o.right.isEmpty()||o.right.isRed()||o.right.left.isRed()||(o=o.moveRedRight()),n(e,o.key)===0){if(o.right.isEmpty())return tn.EMPTY;s=o.right.min(),o=o.copy(s.key,s.value,null,null,o.right.removeMin())}o=o.copy(null,null,null,null,o.right.remove(e,n))}return o.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,tn.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,tn.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())throw Ie(43730,{key:this.key,value:this.value});if(this.right.isRed())throw Ie(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw Ie(27949);return e+(this.isRed()?0:1)}}tn.EMPTY=null,tn.RED=!0,tn.BLACK=!1;tn.EMPTY=new class{constructor(){this.size=0}get key(){throw Ie(57766)}get value(){throw Ie(16141)}get color(){throw Ie(16727)}get left(){throw Ie(29726)}get right(){throw Ie(36894)}copy(e,n,s,o,l){return this}insert(e,n,s){return new tn(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}};class Bt{constructor(e){this.comparator=e,this.data=new mt(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,s)=>(e(n),!1)))}forEachInRange(e,n){const s=this.data.getIteratorFrom(e[0]);for(;s.hasNext();){const o=s.getNext();if(this.comparator(o.key,e[1])>=0)return;n(o.key)}}forEachWhile(e,n){let s;for(s=n!==void 0?this.data.getIteratorFrom(n):this.data.getIterator();s.hasNext();)if(!e(s.getNext().key))return}firstAfterOrEqual(e){const n=this.data.getIteratorFrom(e);return n.hasNext()?n.getNext().key:null}getIterator(){return new BS(this.data.getIterator())}getIteratorFrom(e){return new BS(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(s)})),n}isEqual(e){if(!(e instanceof Bt)||this.size!==e.size)return!1;const n=this.data.getIterator(),s=e.data.getIterator();for(;n.hasNext();){const o=n.getNext().key,l=s.getNext().key;if(this.comparator(o,l)!==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 Bt(this.comparator);return n.data=e,n}}class BS{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class qn{constructor(e){this.fields=e,e.sort(nn.comparator)}static empty(){return new qn([])}unionWith(e){let n=new Bt(nn.comparator);for(const s of this.fields)n=n.add(s);for(const s of e)n=n.add(s);return new qn(n.toArray())}covers(e){for(const n of this.fields)if(n.isPrefixOf(e))return!0;return!1}isEqual(e){return Pl(this.fields,e.fields,((n,s)=>n.isEqual(s)))}}class aI extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class rn{constructor(e){this.binaryString=e}static fromBase64String(e){const n=(function(o){try{return atob(o)}catch(l){throw typeof DOMException<"u"&&l instanceof DOMException?new aI("Invalid base64 string: "+l):l}})(e);return new rn(n)}static fromUint8Array(e){const n=(function(o){let l="";for(let c=0;celi(n,e)))!==void 0}function Dl(t,e){if(t===e)return 0;const n=eo(t),s=eo(e);if(n!==s)return ze(n,s);switch(n){case 0:case 9007199254740991:return 0;case 1:return ze(t.booleanValue,e.booleanValue);case 2:return(function(l,c){const f=At(l.integerValue||l.doubleValue),d=At(c.integerValue||c.doubleValue);return fd?1:f===d?0:isNaN(f)?isNaN(d)?0:-1:1})(t,e);case 3:return FS(t.timestampValue,e.timestampValue);case 4:return FS(ju(t),ju(e));case 5:return Ov(t.stringValue,e.stringValue);case 6:return(function(l,c){const f=Jr(l),d=Jr(c);return f.compareTo(d)})(t.bytesValue,e.bytesValue);case 7:return(function(l,c){const f=l.split("/"),d=c.split("/");for(let m=0;mo+md(l)),0)})(t.arrayValue);case 10:case 11:return(function(s){let o=0;return ao(s.fields,((l,c)=>{o+=l.length+md(c)})),o})(t.mapValue);default:throw Ie(13486,{value:t})}}function HS(t,e){return{referenceValue:`projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`}}function zu(t){return!!t&&"integerValue"in t}function mI(t){return zu(t)||(function(n){return!!n&&"doubleValue"in n})(t)}function s0(t){return!!t&&"arrayValue"in t}function GS(t){return!!t&&"nullValue"in t}function $S(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function pd(t){return!!t&&"mapValue"in t}function eB(t){return(t?.mapValue?.fields||{})[hI]?.stringValue===dI}function bu(t){if(t.geoPointValue)return{geoPointValue:{...t.geoPointValue}};if(t.timestampValue&&typeof t.timestampValue=="object")return{timestampValue:{...t.timestampValue}};if(t.mapValue){const e={mapValue:{fields:{}}};return ao(t.mapValue.fields,((n,s)=>e.mapValue.fields[n]=bu(s))),e}if(t.arrayValue){const e={arrayValue:{values:[]}};for(let n=0;n<(t.arrayValue.values||[]).length;++n)e.arrayValue.values[n]=bu(t.arrayValue.values[n]);return e}return{...t}}function tB(t){return(((t.mapValue||{}).fields||{}).__type__||{}).stringValue===Jz}class Nn{constructor(e){this.value=e}static empty(){return new Nn({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let n=this.value;for(let s=0;s{if(!n.isImmediateParentOf(f)){const d=this.getFieldsMap(n);this.applyChanges(d,s,o),s={},o=[],n=f.popLast()}c?s[f.lastSegment()]=bu(c):o.push(f.lastSegment())}));const l=this.getFieldsMap(n);this.applyChanges(l,s,o)}delete(e){const n=this.field(e.popLast());pd(n)&&n.mapValue.fields&&delete n.mapValue.fields[e.lastSegment()]}isEqual(e){return li(this.value,e.value)}getFieldsMap(e){let n=this.value;n.mapValue.fields||(n.mapValue={fields:{}});for(let s=0;se[o]=l));for(const o of s)delete e[o]}clone(){return new Nn(bu(this.value))}}function pI(t){const e=[];return ao(t.fields,((n,s)=>{const o=new nn([n]);if(pd(s)){const l=pI(s.mapValue).fields;if(l.length===0)e.push(o);else for(const c of l)e.push(o.child(c))}else e.push(o)})),new qn(e)}class dn{constructor(e,n,s,o,l,c,f){this.key=e,this.documentType=n,this.version=s,this.readTime=o,this.createTime=l,this.data=c,this.documentState=f}static newInvalidDocument(e){return new dn(e,0,Pe.min(),Pe.min(),Pe.min(),Nn.empty(),0)}static newFoundDocument(e,n,s,o){return new dn(e,1,n,Pe.min(),s,o,0)}static newNoDocument(e,n){return new dn(e,2,n,Pe.min(),Pe.min(),Nn.empty(),0)}static newUnknownDocument(e,n){return new dn(e,3,n,Pe.min(),Pe.min(),Nn.empty(),2)}convertToFoundDocument(e,n){return!this.createTime.isEqual(Pe.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=Nn.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Nn.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=Pe.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 dn&&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 dn(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class Gd{constructor(e,n){this.position=e,this.inclusive=n}}function KS(t,e,n){let s=0;for(let o=0;o":return e>0;case">=":return e>=0;default:return Ie(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class ks extends gI{constructor(e,n){super(),this.filters=e,this.op=n,this.Pe=null}static create(e,n){return new ks(e,n)}matches(e){return yI(this)?this.filters.find((n=>!n.matches(e)))===void 0:this.filters.find((n=>n.matches(e)))!==void 0}getFlattenedFilters(){return this.Pe!==null||(this.Pe=this.filters.reduce(((e,n)=>e.concat(n.getFlattenedFilters())),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function yI(t){return t.op==="and"}function vI(t){return sB(t)&&yI(t)}function sB(t){for(const e of t.filters)if(e instanceof ks)return!1;return!0}function kv(t){if(t instanceof Ot)return t.field.canonicalString()+t.op.toString()+Ol(t.value);if(vI(t))return t.filters.map((e=>kv(e))).join(",");{const e=t.filters.map((n=>kv(n))).join(",");return`${t.op}(${e})`}}function bI(t,e){return t instanceof Ot?(function(s,o){return o instanceof Ot&&s.op===o.op&&s.field.isEqual(o.field)&&li(s.value,o.value)})(t,e):t instanceof ks?(function(s,o){return o instanceof ks&&s.op===o.op&&s.filters.length===o.filters.length?s.filters.reduce(((l,c,f)=>l&&bI(c,o.filters[f])),!0):!1})(t,e):void Ie(19439)}function _I(t){return t instanceof Ot?(function(n){return`${n.field.canonicalString()} ${n.op} ${Ol(n.value)}`})(t):t instanceof ks?(function(n){return n.op.toString()+" {"+n.getFilters().map(_I).join(" ,")+"}"})(t):"Filter"}class iB extends Ot{constructor(e,n,s){super(e,n,s),this.key=Se.fromName(s.referenceValue)}matches(e){const n=Se.comparator(e.key,this.key);return this.matchesComparison(n)}}class rB extends Ot{constructor(e,n){super(e,"in",n),this.keys=TI("in",n)}matches(e){return this.keys.some((n=>n.isEqual(e.key)))}}class oB extends Ot{constructor(e,n){super(e,"not-in",n),this.keys=TI("not-in",n)}matches(e){return!this.keys.some((n=>n.isEqual(e.key)))}}function TI(t,e){return(e.arrayValue?.values||[]).map((n=>Se.fromName(n.referenceValue)))}class aB extends Ot{constructor(e,n){super(e,"array-contains",n)}matches(e){const n=e.data.field(this.field);return s0(n)&&Uu(n.arrayValue,this.value)}}class lB extends Ot{constructor(e,n){super(e,"in",n)}matches(e){const n=e.data.field(this.field);return n!==null&&Uu(this.value.arrayValue,n)}}class cB extends Ot{constructor(e,n){super(e,"not-in",n)}matches(e){if(Uu(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const n=e.data.field(this.field);return n!==null&&n.nullValue===void 0&&!Uu(this.value.arrayValue,n)}}class uB extends Ot{constructor(e,n){super(e,"array-contains-any",n)}matches(e){const n=e.data.field(this.field);return!(!s0(n)||!n.arrayValue.values)&&n.arrayValue.values.some((s=>Uu(this.value.arrayValue,s)))}}class fB{constructor(e,n=null,s=[],o=[],l=null,c=null,f=null){this.path=e,this.collectionGroup=n,this.orderBy=s,this.filters=o,this.limit=l,this.startAt=c,this.endAt=f,this.Te=null}}function YS(t,e=null,n=[],s=[],o=null,l=null,c=null){return new fB(t,e,n,s,o,l,c)}function i0(t){const e=Oe(t);if(e.Te===null){let n=e.path.canonicalString();e.collectionGroup!==null&&(n+="|cg:"+e.collectionGroup),n+="|f:",n+=e.filters.map((s=>kv(s))).join(","),n+="|ob:",n+=e.orderBy.map((s=>(function(l){return l.field.canonicalString()+l.dir})(s))).join(","),Pm(e.limit)||(n+="|l:",n+=e.limit),e.startAt&&(n+="|lb:",n+=e.startAt.inclusive?"b:":"a:",n+=e.startAt.position.map((s=>Ol(s))).join(",")),e.endAt&&(n+="|ub:",n+=e.endAt.inclusive?"a:":"b:",n+=e.endAt.position.map((s=>Ol(s))).join(",")),e.Te=n}return e.Te}function r0(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(c){let f=new Bt(nn.comparator);return c.filters.forEach((d=>{d.getFlattenedFilters().forEach((m=>{m.isInequality()&&(f=f.add(m.field))}))})),f})(e).forEach((l=>{n.has(l.canonicalString())||l.isKeyField()||e.Ie.push(new Bu(l,s))})),n.has(nn.keyField().canonicalString())||e.Ie.push(new Bu(nn.keyField(),s))}return e.Ie}function si(t){const e=Oe(t);return e.Ee||(e.Ee=mB(e,_u(t))),e.Ee}function mB(t,e){if(t.limitType==="F")return YS(t.path,t.collectionGroup,e,t.filters,t.limit,t.startAt,t.endAt);{e=e.map((o=>{const l=o.dir==="desc"?"asc":"desc";return new Bu(o.field,l)}));const n=t.endAt?new Gd(t.endAt.position,t.endAt.inclusive):null,s=t.startAt?new Gd(t.startAt.position,t.startAt.inclusive):null;return YS(t.path,t.collectionGroup,e,t.filters,t.limit,n,s)}}function jv(t,e){const n=t.filters.concat([e]);return new $l(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}function pB(t,e){const n=t.explicitOrderBy.concat([e]);return new $l(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}function Lv(t,e,n){return new $l(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function Om(t,e){return r0(si(t),si(e))&&t.limitType===e.limitType}function xI(t){return`${i0(si(t))}|lt:${t.limitType}`}function fl(t){return`Query(target=${(function(n){let s=n.path.canonicalString();return n.collectionGroup!==null&&(s+=" collectionGroup="+n.collectionGroup),n.filters.length>0&&(s+=`, filters: [${n.filters.map((o=>_I(o))).join(", ")}]`),Pm(n.limit)||(s+=", limit: "+n.limit),n.orderBy.length>0&&(s+=`, orderBy: [${n.orderBy.map((o=>(function(c){return`${c.field.canonicalString()} (${c.dir})`})(o))).join(", ")}]`),n.startAt&&(s+=", startAt: ",s+=n.startAt.inclusive?"b:":"a:",s+=n.startAt.position.map((o=>Ol(o))).join(",")),n.endAt&&(s+=", endAt: ",s+=n.endAt.inclusive?"a:":"b:",s+=n.endAt.position.map((o=>Ol(o))).join(",")),`Target(${s})`})(si(t))}; limitType=${t.limitType})`}function Mm(t,e){return e.isFoundDocument()&&(function(s,o){const l=o.key.path;return s.collectionGroup!==null?o.key.hasCollectionId(s.collectionGroup)&&s.path.isPrefixOf(l):Se.isDocumentKey(s.path)?s.path.isEqual(l):s.path.isImmediateParentOf(l)})(t,e)&&(function(s,o){for(const l of _u(s))if(!l.field.isKeyField()&&o.data.field(l.field)===null)return!1;return!0})(t,e)&&(function(s,o){for(const l of s.filters)if(!l.matches(o))return!1;return!0})(t,e)&&(function(s,o){return!(s.startAt&&!(function(c,f,d){const m=KS(c,f,d);return c.inclusive?m<=0:m<0})(s.startAt,_u(s),o)||s.endAt&&!(function(c,f,d){const m=KS(c,f,d);return c.inclusive?m>=0:m>0})(s.endAt,_u(s),o))})(t,e)}function gB(t){return t.collectionGroup||(t.path.length%2==1?t.path.lastSegment():t.path.get(t.path.length-2))}function EI(t){return(e,n)=>{let s=!1;for(const o of _u(t)){const l=yB(o,e,n);if(l!==0)return l;s=s||o.field.isKeyField()}return 0}}function yB(t,e,n){const s=t.field.isKeyField()?Se.comparator(e.key,n.key):(function(l,c,f){const d=c.data.field(l),m=f.data.field(l);return d!==null&&m!==null?Dl(d,m):Ie(42886)})(t.field,e,n);switch(t.dir){case"asc":return s;case"desc":return-1*s;default:return Ie(19790,{direction:t.dir})}}class ya{constructor(e,n){this.mapKeyFn=e,this.equalsFn=n,this.inner={},this.innerSize=0}get(e){const n=this.mapKeyFn(e),s=this.inner[n];if(s!==void 0){for(const[o,l]of s)if(this.equalsFn(o,e))return l}}has(e){return this.get(e)!==void 0}set(e,n){const s=this.mapKeyFn(e),o=this.inner[s];if(o===void 0)return this.inner[s]=[[e,n]],void this.innerSize++;for(let l=0;l{for(const[o,l]of s)e(o,l)}))}isEmpty(){return oI(this.inner)}size(){return this.innerSize}}const vB=new mt(Se.comparator);function qi(){return vB}const SI=new mt(Se.comparator);function fu(...t){let e=SI;for(const n of t)e=e.insert(n.key,n);return e}function AI(t){let e=SI;return t.forEach(((n,s)=>e=e.insert(n,s.overlayedDocument))),e}function sa(){return Tu()}function RI(){return Tu()}function Tu(){return new ya((t=>t.toString()),((t,e)=>t.isEqual(e)))}const bB=new mt(Se.comparator),_B=new Bt(Se.comparator);function Be(...t){let e=_B;for(const n of t)e=e.add(n);return e}const TB=new Bt(ze);function wB(){return TB}function km(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:Fd(e)?"-0":e}}function a0(t){return{integerValue:""+t}}function xB(t,e){return Kz(e)?a0(e):km(t,e)}class Vm{constructor(){this._=void 0}}function EB(t,e,n){return t instanceof Fu?(function(o,l){const c={fields:{[cI]:{stringValue:lI},[fI]:{timestampValue:{seconds:o.seconds,nanos:o.nanoseconds}}}};return l&&n0(l)&&(l=Dm(l)),l&&(c.fields[uI]=l),{mapValue:c}})(n,e):t instanceof qu?II(t,e):t instanceof Hu?NI(t,e):t instanceof Gu?(function(o,l){const c=CI(o,l),f=Qd(c)+Qd(o.Ae);return zu(c)&&zu(o.Ae)?a0(f):km(o.serializer,f)})(t,e):t instanceof $d?(function(o,l){return XS(o,l,Math.min)})(t,e):t instanceof Kd?(function(o,l){return XS(o,l,Math.max)})(t,e):void 0}function SB(t,e,n){return t instanceof qu?II(t,e):t instanceof Hu?NI(t,e):n}function CI(t,e){return t instanceof Gu?mI(e)?e:{integerValue:0}:null}class Fu extends Vm{}class qu extends Vm{constructor(e){super(),this.elements=e}}function II(t,e){const n=PI(e);for(const s of t.elements)n.some((o=>li(o,s)))||n.push(s);return{arrayValue:{values:n}}}class Hu extends Vm{constructor(e){super(),this.elements=e}}function NI(t,e){let n=PI(e);for(const s of t.elements)n=n.filter((o=>!li(o,s)));return{arrayValue:{values:n}}}class l0 extends Vm{constructor(e,n){super(),this.serializer=e,this.Ae=n}}class Gu extends l0{}class $d extends l0{}class Kd extends l0{}function XS(t,e,n){if(!mI(e))return t.Ae;const s=n(Qd(e),Qd(t.Ae));return zu(e)&&zu(t.Ae)?a0(s):km(t.serializer,s)}function Qd(t){return At(t.integerValue||t.doubleValue)}function PI(t){return s0(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}class AB{constructor(e,n){this.field=e,this.transform=n}}function RB(t,e){return t.field.isEqual(e.field)&&(function(s,o){return s instanceof qu&&o instanceof qu||s instanceof Hu&&o instanceof Hu?Pl(s.elements,o.elements,li):s instanceof Gu&&o instanceof Gu||s instanceof $d&&o instanceof $d||s instanceof Kd&&o instanceof Kd?li(s.Ae,o.Ae):s instanceof Fu&&o instanceof Fu})(t.transform,e.transform)}class CB{constructor(e,n){this.version=e,this.transformResults=n}}class us{constructor(e,n){this.updateTime=e,this.exists=n}static none(){return new us}static exists(e){return new us(void 0,e)}static updateTime(e){return new us(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 gd(t,e){return t.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(t.updateTime):t.exists===void 0||t.exists===e.isFoundDocument()}class jm{}function DI(t,e){if(!t.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return t.isNoDocument()?new c0(t.key,us.none()):new af(t.key,t.data,us.none());{const n=t.data,s=Nn.empty();let o=new Bt(nn.comparator);for(let l of e.fields)if(!o.has(l)){let c=n.field(l);c===null&&l.length>1&&(l=l.popLast(),c=n.field(l)),c===null?s.delete(l):s.set(l,c),o=o.add(l)}return new lo(t.key,s,new qn(o.toArray()),us.none())}}function IB(t,e,n){t instanceof af?(function(o,l,c){const f=o.value.clone(),d=JS(o.fieldTransforms,l,c.transformResults);f.setAll(d),l.convertToFoundDocument(c.version,f).setHasCommittedMutations()})(t,e,n):t instanceof lo?(function(o,l,c){if(!gd(o.precondition,l))return void l.convertToUnknownDocument(c.version);const f=JS(o.fieldTransforms,l,c.transformResults),d=l.data;d.setAll(OI(o)),d.setAll(f),l.convertToFoundDocument(c.version,d).setHasCommittedMutations()})(t,e,n):(function(o,l,c){l.convertToNoDocument(c.version).setHasCommittedMutations()})(0,e,n)}function wu(t,e,n,s){return t instanceof af?(function(l,c,f,d){if(!gd(l.precondition,c))return f;const m=l.value.clone(),g=eA(l.fieldTransforms,d,c);return m.setAll(g),c.convertToFoundDocument(c.version,m).setHasLocalMutations(),null})(t,e,n,s):t instanceof lo?(function(l,c,f,d){if(!gd(l.precondition,c))return f;const m=eA(l.fieldTransforms,d,c),g=c.data;return g.setAll(OI(l)),g.setAll(m),c.convertToFoundDocument(c.version,g).setHasLocalMutations(),f===null?null:f.unionWith(l.fieldMask.fields).unionWith(l.fieldTransforms.map((v=>v.field)))})(t,e,n,s):(function(l,c,f){return gd(l.precondition,c)?(c.convertToNoDocument(c.version).setHasLocalMutations(),null):f})(t,e,n)}function NB(t,e){let n=null;for(const s of t.fieldTransforms){const o=e.data.field(s.field),l=CI(s.transform,o||null);l!=null&&(n===null&&(n=Nn.empty()),n.set(s.field,l))}return n||null}function ZS(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&!!(function(s,o){return s===void 0&&o===void 0||!(!s||!o)&&Pl(s,o,((l,c)=>RB(l,c)))})(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 af extends jm{constructor(e,n,s,o=[]){super(),this.key=e,this.value=n,this.precondition=s,this.fieldTransforms=o,this.type=0}getFieldMask(){return null}}class lo extends jm{constructor(e,n,s,o,l=[]){super(),this.key=e,this.data=n,this.fieldMask=s,this.precondition=o,this.fieldTransforms=l,this.type=1}getFieldMask(){return this.fieldMask}}function OI(t){const e=new Map;return t.fieldMask.fields.forEach((n=>{if(!n.isEmpty()){const s=t.data.field(n);e.set(n,s)}})),e}function JS(t,e,n){const s=new Map;We(t.length===n.length,32656,{Ve:n.length,de:t.length});for(let o=0;o{const l=e.get(o.key),c=l.overlayedDocument;let f=this.applyToLocalView(c,l.mutatedFields);f=n.has(o.key)?null:f;const d=DI(c,f);d!==null&&s.set(o.key,d),c.isValidDocument()||c.convertToNoDocument(Pe.min())})),s}keys(){return this.mutations.reduce(((e,n)=>e.add(n.key)),Be())}isEqual(e){return this.batchId===e.batchId&&Pl(this.mutations,e.mutations,((n,s)=>ZS(n,s)))&&Pl(this.baseMutations,e.baseMutations,((n,s)=>ZS(n,s)))}}class u0{constructor(e,n,s,o){this.batch=e,this.commitVersion=n,this.mutationResults=s,this.docVersions=o}static from(e,n,s){We(e.mutations.length===s.length,58842,{me:e.mutations.length,fe:s.length});let o=(function(){return bB})();const l=e.mutations;for(let c=0;c=8)throw new hu(`Invalid padding: ${n}`);if(s<0)throw new hu(`Invalid hash count: ${s}`);if(e.length>0&&this.hashCount===0)throw new hu(`Invalid hash count: ${s}`);if(e.length===0&&n!==0)throw new hu(`Invalid padding when bitmap length is 0: ${n}`);this.ge=8*e.length-n,this.pe=qr.fromNumber(this.ge)}ye(e,n,s){let o=e.add(n.multiply(qr.fromNumber(s)));return o.compare(jB)===1&&(o=new qr([o.getBits(0),o.getBits(1)],0)),o.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<c.insert(f))),c}insert(e){if(this.ge===0)return;const n=tA(e),[s,o]=nA(n);for(let l=0;l0&&(this.Oe=!0,this.Me=e)}ke(){let e=Be(),n=Be(),s=Be();return this.Fe.forEach(((o,l)=>{switch(l){case 0:e=e.add(o);break;case 2:n=n.add(o);break;case 1:s=s.add(o);break;default:Ie(38017,{changeType:l})}})),new cf(this.Me,this.xe,e,n,s)}qe(){this.Oe=!1,this.Fe=iA()}Ke(e,n){this.Oe=!0,this.Fe=this.Fe.insert(e,n)}Ue(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}$e(){this.ve+=1}We(){this.ve-=1,We(this.ve>=0,3241,{ve:this.ve,targetId:this.targetId})}Qe(){this.Oe=!0,this.xe=!0}}const iu="WatchChangeAggregator";class LB{constructor(e){this.Ge=e,this.ze=new Map,this.je=qi(),this.Je=Xh(),this.He=Xh(),this.Ze=new mt(ze)}Xe(e){for(const n of e.be)e.De&&e.De.isFoundDocument()?this.Ye(n,e.De):this.et(n,e.key,e.De);for(const n of e.removedTargetIds)this.et(n,e.key,e.De)}tt(e){this.forEachTarget(e,(n=>{const s=this.ze.get(n);if(s)switch(e.state){case 0:this.nt(n)&&s.Le(e.resumeToken);break;case 1:s.We(),s.Ne||s.qe(),s.Le(e.resumeToken);break;case 2:s.We(),s.Ne||this.removeTarget(n);break;case 3:this.nt(n)&&(s.Qe(),s.Le(e.resumeToken));break;case 4:this.nt(n)&&(this.rt(n),s.Le(e.resumeToken));break;default:Ie(56790,{state:e.state})}else me(iu,`handleTargetChange received targetChange for untracked target ID (${n}) with state (${e.state})`)}))}forEachTarget(e,n){e.targetIds.length>0?e.targetIds.forEach(n):this.ze.forEach(((s,o)=>{this.nt(o)&&n(o)}))}it(e){const n=e.targetId,s=e.Ce.count,o=this.st(n);if(o){const l=o.target;if(Vv(l))if(s===0){const c=new Se(l.path);this.et(n,c,dn.newNoDocument(c,Pe.min()))}else We(s===1,20013,{expectedCount:s});else{const c=this.ot(n);if(c!==s){const f=this._t(e),d=f?this.ut(f,e,c):1;if(d!==0){this.rt(n);const m=d===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ze=this.Ze.insert(n,m)}}}}}_t(e){const n=e.Ce.unchangedNames;if(!n||!n.bits)return null;const{bits:{bitmap:s="",padding:o=0},hashCount:l=0}=n;let c,f;try{c=Jr(s).toUint8Array()}catch(d){if(d instanceof aI)return ha("Decoding the base64 bloom filter in existence filter failed ("+d.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw d}try{f=new f0(c,o,l)}catch(d){return ha(d instanceof hu?"BloomFilter error: ":"Applying bloom filter failed: ",d),null}return f.ge===0?null:f}ut(e,n,s){return n.Ce.count===s-this.ht(e,n.targetId)?0:2}ht(e,n){const s=this.Ge.getRemoteKeysForTarget(n);let o=0;return s.forEach((l=>{const c=this.Ge.lt(),f=`projects/${c.projectId}/databases/${c.database}/documents/${l.path.canonicalString()}`;e.mightContain(f)||(this.et(n,l,null),o++)})),o}Pt(e){const n=new Map;this.ze.forEach(((l,c)=>{const f=this.st(c);if(f){if(l.current&&Vv(f.target)){const d=new Se(f.target.path);this.Tt(d).has(c)||this.It(c,d)||this.et(c,d,dn.newNoDocument(d,e))}l.Be&&(n.set(c,l.ke()),l.qe())}}));let s=Be();this.He.forEach(((l,c)=>{let f=!0;c.forEachWhile((d=>{const m=this.st(d);return!m||m.purpose==="TargetPurposeLimboResolution"||(f=!1,!1)})),f&&(s=s.add(l))})),this.je.forEach(((l,c)=>c.setReadTime(e)));const o=new lf(e,n,this.Ze,this.je,s);return this.je=qi(),this.Je=Xh(),this.He=Xh(),this.Ze=new mt(ze),o}Ye(e,n){const s=this.ze.get(e);if(!s||!this.nt(e))return void me(iu,`addDocumentToTarget received document for unknown inactive target (${e})`);const o=this.It(e,n.key)?2:0;s.Ke(n.key,o),this.je=this.je.insert(n.key,n),this.Je=this.Je.insert(n.key,this.Tt(n.key).add(e)),this.He=this.He.insert(n.key,this.Et(n.key).add(e))}et(e,n,s){const o=this.ze.get(e);o&&this.nt(e)?(this.It(e,n)?o.Ke(n,1):o.Ue(n),this.He=this.He.insert(n,this.Et(n).delete(e)),this.He=this.He.insert(n,this.Et(n).add(e)),s&&(this.je=this.je.insert(n,s))):me(iu,`removeDocumentFromTarget received document for unknown or inactive target (${e})`)}removeTarget(e){this.ze.delete(e)}ot(e){const n=this.ze.get(e);if(!n)return 0;const s=n.ke();return this.Ge.getRemoteKeysForTarget(e).size+s.addedDocuments.size-s.removedDocuments.size}$e(e){let n=this.ze.get(e);n||(me(iu,`recordPendingTargetRequest set up tracking for target ID ${e}`),n=new sA(e),this.ze.set(e,n)),n.$e()}Et(e){let n=this.He.get(e);return n||(n=new Bt(ze),this.He=this.He.insert(e,n)),n}Tt(e){let n=this.Je.get(e);return n||(n=new Bt(ze),this.Je=this.Je.insert(e,n)),n}nt(e){const n=this.st(e)!==null;return n||me(iu,"Detected inactive target",e),n}st(e){const n=this.ze.get(e);return n===void 0||n.Ne?null:this.Ge.Rt(e)}rt(e){this.ze.set(e,new sA(e)),this.Ge.getRemoteKeysForTarget(e).forEach((n=>{this.et(e,n,null)}))}It(e,n){return this.Ge.getRemoteKeysForTarget(e).has(n)}}function Xh(){return new mt(Se.comparator)}function iA(){return new mt(Se.comparator)}const UB={asc:"ASCENDING",desc:"DESCENDING"},zB={"<":"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"},BB={and:"AND",or:"OR"};class FB{constructor(e,n){this.databaseId=e,this.useProto3Json=n}}function Uv(t,e){return t.useProto3Json||Pm(e)?e:{value:e}}function Yd(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 jI(t,e){return t.useProto3Json?e.toBase64():e.toUint8Array()}function qB(t,e){return Yd(t,e.toTimestamp())}function ii(t){return We(!!t,49232),Pe.fromTimestamp((function(n){const s=Zr(n);return new ft(s.seconds,s.nanos)})(t))}function h0(t,e){return zv(t,e).canonicalString()}function zv(t,e){const n=(function(o){return new ct(["projects",o.projectId,"databases",o.database])})(t).child("documents");return e===void 0?n:n.child(e)}function LI(t){const e=ct.fromString(t);return We(qI(e),10190,{key:e.toString()}),e}function Bv(t,e){return h0(t.databaseId,e.path)}function My(t,e){const n=LI(e);if(n.get(1)!==t.databaseId.projectId)throw new ge(re.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 ge(re.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new Se(zI(n))}function UI(t,e){return h0(t.databaseId,e)}function HB(t){const e=LI(t);return e.length===4?ct.emptyPath():zI(e)}function Fv(t){return new ct(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function zI(t){return We(t.length>4&&t.get(4)==="documents",29091,{key:t.toString()}),t.popFirst(5)}function rA(t,e,n){return{name:Bv(t,e),fields:n.value.mapValue.fields}}function GB(t,e){let n;if("targetChange"in e){e.targetChange;const s=(function(m){return m==="NO_CHANGE"?0:m==="ADD"?1:m==="REMOVE"?2:m==="CURRENT"?3:m==="RESET"?4:Ie(39313,{state:m})})(e.targetChange.targetChangeType||"NO_CHANGE"),o=e.targetChange.targetIds||[],l=(function(m,g){return m.useProto3Json?(We(g===void 0||typeof g=="string",58123),rn.fromBase64String(g||"")):(We(g===void 0||g instanceof Buffer||g instanceof Uint8Array,16193),rn.fromUint8Array(g||new Uint8Array))})(t,e.targetChange.resumeToken),c=e.targetChange.cause,f=c&&(function(m){const g=m.code===void 0?re.UNKNOWN:MI(m.code);return new ge(g,m.message||"")})(c);n=new VI(s,o,l,f||null)}else if("documentChange"in e){e.documentChange;const s=e.documentChange;s.document,s.document.name,s.document.updateTime;const o=My(t,s.document.name),l=ii(s.document.updateTime),c=s.document.createTime?ii(s.document.createTime):Pe.min(),f=new Nn({mapValue:{fields:s.document.fields}}),d=dn.newFoundDocument(o,l,c,f),m=s.targetIds||[],g=s.removedTargetIds||[];n=new yd(m,g,d.key,d)}else if("documentDelete"in e){e.documentDelete;const s=e.documentDelete;s.document;const o=My(t,s.document),l=s.readTime?ii(s.readTime):Pe.min(),c=dn.newNoDocument(o,l),f=s.removedTargetIds||[];n=new yd([],f,c.key,c)}else if("documentRemove"in e){e.documentRemove;const s=e.documentRemove;s.document;const o=My(t,s.document),l=s.removedTargetIds||[];n=new yd([],l,o,null)}else{if(!("filter"in e))return Ie(11601,{At:e});{e.filter;const s=e.filter;s.targetId;const{count:o=0,unchangedNames:l}=s,c=new MB(o,l),f=s.targetId;n=new kI(f,c)}}return n}function $B(t,e){let n;if(e instanceof af)n={update:rA(t,e.key,e.value)};else if(e instanceof c0)n={delete:Bv(t,e.key)};else if(e instanceof lo)n={update:rA(t,e.key,e.data),updateMask:tF(e.fieldMask)};else{if(!(e instanceof PB))return Ie(16599,{Vt:e.type});n={verify:Bv(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map((s=>(function(l,c){const f=c.transform;if(f instanceof Fu)return{fieldPath:c.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(f instanceof qu)return{fieldPath:c.field.canonicalString(),appendMissingElements:{values:f.elements}};if(f instanceof Hu)return{fieldPath:c.field.canonicalString(),removeAllFromArray:{values:f.elements}};if(f instanceof Gu)return{fieldPath:c.field.canonicalString(),increment:f.Ae};if(f instanceof $d)return{fieldPath:c.field.canonicalString(),minimum:f.Ae};if(f instanceof Kd)return{fieldPath:c.field.canonicalString(),maximum:f.Ae};throw Ie(20930,{transform:c.transform})})(0,s)))),e.precondition.isNone||(n.currentDocument=(function(o,l){return l.updateTime!==void 0?{updateTime:qB(o,l.updateTime)}:l.exists!==void 0?{exists:l.exists}:Ie(27497)})(t,e.precondition)),n}function KB(t,e){return t&&t.length>0?(We(e!==void 0,14353),t.map((n=>(function(o,l){let c=o.updateTime?ii(o.updateTime):ii(l);return c.isEqual(Pe.min())&&(c=ii(l)),new CB(c,o.transformResults||[])})(n,e)))):[]}function QB(t,e){return{documents:[UI(t,e.path)]}}function YB(t,e){const n={structuredQuery:{}},s=e.path;let o;e.collectionGroup!==null?(o=s,n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(o=s.popLast(),n.structuredQuery.from=[{collectionId:s.lastSegment()}]),n.parent=UI(t,o);const l=(function(m){if(m.length!==0)return FI(ks.create(m,"and"))})(e.filters);l&&(n.structuredQuery.where=l);const c=(function(m){if(m.length!==0)return m.map((g=>(function(T){return{field:hl(T.field),direction:ZB(T.dir)}})(g)))})(e.orderBy);c&&(n.structuredQuery.orderBy=c);const f=Uv(t,e.limit);return f!==null&&(n.structuredQuery.limit=f),e.startAt&&(n.structuredQuery.startAt=(function(m){return{before:m.inclusive,values:m.position}})(e.startAt)),e.endAt&&(n.structuredQuery.endAt=(function(m){return{before:!m.inclusive,values:m.position}})(e.endAt)),{dt:n,parent:o}}function WB(t){let e=HB(t.parent);const n=t.structuredQuery,s=n.from?n.from.length:0;let o=null;if(s>0){We(s===1,65062);const g=n.from[0];g.allDescendants?o=g.collectionId:e=e.child(g.collectionId)}let l=[];n.where&&(l=(function(v){const T=BI(v);return T instanceof ks&&vI(T)?T.getFilters():[T]})(n.where));let c=[];n.orderBy&&(c=(function(v){return v.map((T=>(function(R){return new Bu(dl(R.field),(function(N){switch(N){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(R.direction))})(T)))})(n.orderBy));let f=null;n.limit&&(f=(function(v){let T;return T=typeof v=="object"?v.value:v,Pm(T)?null:T})(n.limit));let d=null;n.startAt&&(d=(function(v){const T=!!v.before,E=v.values||[];return new Gd(E,T)})(n.startAt));let m=null;return n.endAt&&(m=(function(v){const T=!v.before,E=v.values||[];return new Gd(E,T)})(n.endAt)),hB(e,o,c,l,f,"F",d,m)}function XB(t,e){const n=(function(o){switch(o){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return Ie(28987,{purpose:o})}})(e.purpose);return n==null?null:{"goog-listen-tags":n}}function BI(t){return t.unaryFilter!==void 0?(function(n){switch(n.unaryFilter.op){case"IS_NAN":const s=dl(n.unaryFilter.field);return Ot.create(s,"==",{doubleValue:NaN});case"IS_NULL":const o=dl(n.unaryFilter.field);return Ot.create(o,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const l=dl(n.unaryFilter.field);return Ot.create(l,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const c=dl(n.unaryFilter.field);return Ot.create(c,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return Ie(61313);default:return Ie(60726)}})(t):t.fieldFilter!==void 0?(function(n){return Ot.create(dl(n.fieldFilter.field),(function(o){switch(o){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return Ie(58110);default:return Ie(50506)}})(n.fieldFilter.op),n.fieldFilter.value)})(t):t.compositeFilter!==void 0?(function(n){return ks.create(n.compositeFilter.filters.map((s=>BI(s))),(function(o){switch(o){case"AND":return"and";case"OR":return"or";default:return Ie(1026)}})(n.compositeFilter.op))})(t):Ie(30097,{filter:t})}function ZB(t){return UB[t]}function JB(t){return zB[t]}function eF(t){return BB[t]}function hl(t){return{fieldPath:t.canonicalString()}}function dl(t){return nn.fromServerFormat(t.fieldPath)}function FI(t){return t instanceof Ot?(function(n){if(n.op==="=="){if($S(n.value))return{unaryFilter:{field:hl(n.field),op:"IS_NAN"}};if(GS(n.value))return{unaryFilter:{field:hl(n.field),op:"IS_NULL"}}}else if(n.op==="!="){if($S(n.value))return{unaryFilter:{field:hl(n.field),op:"IS_NOT_NAN"}};if(GS(n.value))return{unaryFilter:{field:hl(n.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:hl(n.field),op:JB(n.op),value:n.value}}})(t):t instanceof ks?(function(n){const s=n.getFilters().map((o=>FI(o)));return s.length===1?s[0]:{compositeFilter:{op:eF(n.op),filters:s}}})(t):Ie(54877,{filter:t})}function tF(t){const e=[];return t.fields.forEach((n=>e.push(n.canonicalString()))),{fieldPaths:e}}function qI(t){return t.length>=4&&t.get(0)==="projects"&&t.get(2)==="databases"}function HI(t){return!!t&&typeof t._toProto=="function"&&t._protoValueType==="ProtoValue"}class Mi{constructor(e,n,s,o,l=Pe.min(),c=Pe.min(),f=rn.EMPTY_BYTE_STRING,d=null){this.target=e,this.targetId=n,this.purpose=s,this.sequenceNumber=o,this.snapshotVersion=l,this.lastLimboFreeSnapshotVersion=c,this.resumeToken=f,this.expectedCount=d}withSequenceNumber(e){return new Mi(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,n){return new Mi(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new Mi(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new Mi(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class nF{constructor(e){this.gt=e}}function sF(t){const e=WB({parent:t.parent,structuredQuery:t.structuredQuery});return t.limitType==="LAST"?Lv(e,e.limit,"L"):e}class iF{constructor(){this.Sn=new rF}addToCollectionParentIndex(e,n){return this.Sn.add(n),ae.resolve()}getCollectionParents(e,n){return ae.resolve(this.Sn.getEntries(n))}addFieldIndex(e,n){return ae.resolve()}deleteFieldIndex(e,n){return ae.resolve()}deleteAllFieldIndexes(e){return ae.resolve()}createTargetIndexes(e,n){return ae.resolve()}getDocumentsMatchingTarget(e,n){return ae.resolve(null)}getIndexType(e,n){return ae.resolve(0)}getFieldIndexes(e,n){return ae.resolve([])}getNextCollectionGroupToUpdate(e){return ae.resolve(null)}getMinOffset(e,n){return ae.resolve(Xr.min())}getMinOffsetFromCollectionGroup(e,n){return ae.resolve(Xr.min())}updateCollectionGroup(e,n,s){return ae.resolve()}updateIndexEntries(e,n){return ae.resolve()}}class rF{constructor(){this.index={}}add(e){const n=e.lastSegment(),s=e.popLast(),o=this.index[n]||new Bt(ct.comparator),l=!o.has(s);return this.index[n]=o.add(s),l}has(e){const n=e.lastSegment(),s=e.popLast(),o=this.index[n];return o&&o.has(s)}getEntries(e){return(this.index[e]||new Bt(ct.comparator)).toArray()}}const oA={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},GI=41943040;class In{static withCacheSize(e){return new In(e,In.DEFAULT_COLLECTION_PERCENTILE,In.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,n,s){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=n,this.maximumSequenceNumbersToCollect=s}}In.DEFAULT_COLLECTION_PERCENTILE=10,In.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,In.DEFAULT=new In(GI,In.DEFAULT_COLLECTION_PERCENTILE,In.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),In.DISABLED=new In(-1,0,0);class to{constructor(e){this.ir=e}next(){return this.ir+=2,this.ir}static sr(){return new to(0)}static _r(){return new to(-1)}}const aA="LruGarbageCollector",oF=1048576;function lA([t,e],[n,s]){const o=ze(t,n);return o===0?ze(e,s):o}class aF{constructor(e){this.hr=e,this.buffer=new Bt(lA),this.Pr=0}Tr(){return++this.Pr}Ir(e){const n=[e,this.Tr()];if(this.buffer.size{this.Er=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(n){Gl(n)?me(aA,"Ignoring IndexedDB error during garbage collection: ",n):await Hl(n)}await this.Rr(3e5)}))}}class cF{constructor(e,n){this.Ar=e,this.params=n}calculateTargetCount(e,n){return this.Ar.Vr(e).next((s=>Math.floor(n/100*s)))}nthSequenceNumber(e,n){if(n===0)return ae.resolve(Nm.ce);const s=new aF(n);return this.Ar.forEachTarget(e,(o=>s.Ir(o.sequenceNumber))).next((()=>this.Ar.dr(e,(o=>s.Ir(o))))).next((()=>s.maxValue))}removeTargets(e,n,s){return this.Ar.removeTargets(e,n,s)}removeOrphanedDocuments(e,n){return this.Ar.removeOrphanedDocuments(e,n)}collect(e,n){return this.params.cacheSizeCollectionThreshold===-1?(me("LruGarbageCollector","Garbage collection skipped; disabled"),ae.resolve(oA)):this.getCacheSize(e).next((s=>s(v>this.params.maximumSequenceNumbersToCollect?(me("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${v}`),o=this.params.maximumSequenceNumbersToCollect):o=v,c=Date.now(),this.nthSequenceNumber(e,o)))).next((v=>(s=v,f=Date.now(),this.removeTargets(e,s,n)))).next((v=>(l=v,d=Date.now(),this.removeOrphanedDocuments(e,s)))).next((v=>(m=Date.now(),ul()<=Fe.DEBUG&&me("LruGarbageCollector",`LRU Garbage Collection Counted targets in ${c-g}ms Determined least recently used ${o} in `+(f-c)+`ms Removed ${l} targets in `+(d-f)+`ms Removed ${v} documents in `+(m-d)+`ms Total Duration: ${m-g}ms`),ae.resolve({didRun:!0,sequenceNumbersCollected:o,targetsRemoved:l,documentsRemoved:v}))))}}function uF(t,e){return new cF(t,e)}class fF{constructor(){this.changes=new ya((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,dn.newInvalidDocument(e).setReadTime(n))}getEntry(e,n){this.assertNotApplied();const s=this.changes.get(n);return s!==void 0?ae.resolve(s):this.getFromCache(e,n)}getEntries(e,n){return this.getAllFromCache(e,n)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}class hF{constructor(e,n){this.overlayedDocument=e,this.mutatedFields=n}}class dF{constructor(e,n,s,o){this.remoteDocumentCache=e,this.mutationQueue=n,this.documentOverlayCache=s,this.indexManager=o}getDocument(e,n){let s=null;return this.documentOverlayCache.getOverlay(e,n).next((o=>(s=o,this.remoteDocumentCache.getEntry(e,n)))).next((o=>(s!==null&&wu(s.mutation,o,qn.empty(),ft.now()),o)))}getDocuments(e,n){return this.remoteDocumentCache.getEntries(e,n).next((s=>this.getLocalViewOfDocuments(e,s,Be()).next((()=>s))))}getLocalViewOfDocuments(e,n,s=Be()){const o=sa();return this.populateOverlays(e,o,n).next((()=>this.computeViews(e,n,o,s).next((l=>{let c=fu();return l.forEach(((f,d)=>{c=c.insert(f,d.overlayedDocument)})),c}))))}getOverlayedDocuments(e,n){const s=sa();return this.populateOverlays(e,s,n).next((()=>this.computeViews(e,n,s,Be())))}populateOverlays(e,n,s){const o=[];return s.forEach((l=>{n.has(l)||o.push(l)})),this.documentOverlayCache.getOverlays(e,o).next((l=>{l.forEach(((c,f)=>{n.set(c,f)}))}))}computeViews(e,n,s,o){let l=qi();const c=Tu(),f=(function(){return Tu()})();return n.forEach(((d,m)=>{const g=s.get(m.key);o.has(m.key)&&(g===void 0||g.mutation instanceof lo)?l=l.insert(m.key,m):g!==void 0?(c.set(m.key,g.mutation.getFieldMask()),wu(g.mutation,m,g.mutation.getFieldMask(),ft.now())):c.set(m.key,qn.empty())})),this.recalculateAndSaveOverlays(e,l).next((d=>(d.forEach(((m,g)=>c.set(m,g))),n.forEach(((m,g)=>f.set(m,new hF(g,c.get(m)??null)))),f)))}recalculateAndSaveOverlays(e,n){const s=Tu();let o=new mt(((c,f)=>c-f)),l=Be();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,n).next((c=>{for(const f of c)f.keys().forEach((d=>{const m=n.get(d);if(m===null)return;let g=s.get(d)||qn.empty();g=f.applyToLocalView(m,g),s.set(d,g);const v=(o.get(f.batchId)||Be()).add(d);o=o.insert(f.batchId,v)}))})).next((()=>{const c=[],f=o.getReverseIterator();for(;f.hasNext();){const d=f.getNext(),m=d.key,g=d.value,v=RI();g.forEach((T=>{if(!l.has(T)){const E=DI(n.get(T),s.get(T));E!==null&&v.set(T,E),l=l.add(T)}})),c.push(this.documentOverlayCache.saveOverlays(e,m,v))}return ae.waitFor(c)})).next((()=>s))}recalculateAndSaveOverlaysForDocumentKeys(e,n){return this.remoteDocumentCache.getEntries(e,n).next((s=>this.recalculateAndSaveOverlays(e,s)))}getDocumentsMatchingQuery(e,n,s,o){return dB(n)?this.getDocumentsMatchingDocumentQuery(e,n.path):wI(n)?this.getDocumentsMatchingCollectionGroupQuery(e,n,s,o):this.getDocumentsMatchingCollectionQuery(e,n,s,o)}getNextDocuments(e,n,s,o){return this.remoteDocumentCache.getAllFromCollectionGroup(e,n,s,o).next((l=>{const c=o-l.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,n,s.largestBatchId,o-l.size):ae.resolve(sa());let f=Vu,d=l;return c.next((m=>ae.forEach(m,((g,v)=>(f{d=d.insert(g,T)}))))).next((()=>this.populateOverlays(e,m,l))).next((()=>this.computeViews(e,d,m,Be()))).next((g=>({batchId:f,changes:AI(g)})))))}))}getDocumentsMatchingDocumentQuery(e,n){return this.getDocument(e,new Se(n)).next((s=>{let o=fu();return s.isFoundDocument()&&(o=o.insert(s.key,s)),o}))}getDocumentsMatchingCollectionGroupQuery(e,n,s,o){const l=n.collectionGroup;let c=fu();return this.indexManager.getCollectionParents(e,l).next((f=>ae.forEach(f,(d=>{const m=(function(v,T){return new $l(T,null,v.explicitOrderBy.slice(),v.filters.slice(),v.limit,v.limitType,v.startAt,v.endAt)})(n,d.child(l));return this.getDocumentsMatchingCollectionQuery(e,m,s,o).next((g=>{g.forEach(((v,T)=>{c=c.insert(v,T)}))}))})).next((()=>c))))}getDocumentsMatchingCollectionQuery(e,n,s,o){let l;return this.documentOverlayCache.getOverlaysForCollection(e,n.path,s.largestBatchId).next((c=>(l=c,this.remoteDocumentCache.getDocumentsMatchingQuery(e,n,s,l,o)))).next((c=>{l.forEach(((d,m)=>{const g=m.getKey();c.get(g)===null&&(c=c.insert(g,dn.newInvalidDocument(g)))}));let f=fu();return c.forEach(((d,m)=>{const g=l.get(d);g!==void 0&&wu(g.mutation,m,qn.empty(),ft.now()),Mm(n,m)&&(f=f.insert(d,m))})),f}))}}class mF{constructor(e){this.serializer=e,this.Or=new Map,this.Nr=new Map}getBundleMetadata(e,n){return ae.resolve(this.Or.get(n))}saveBundleMetadata(e,n){return this.Or.set(n.id,(function(o){return{id:o.id,version:o.version,createTime:ii(o.createTime)}})(n)),ae.resolve()}getNamedQuery(e,n){return ae.resolve(this.Nr.get(n))}saveNamedQuery(e,n){return this.Nr.set(n.name,(function(o){return{name:o.name,query:sF(o.bundledQuery),readTime:ii(o.readTime)}})(n)),ae.resolve()}}class pF{constructor(){this.overlays=new mt(Se.comparator),this.Br=new Map}getOverlay(e,n){return ae.resolve(this.overlays.get(n))}getOverlays(e,n){const s=sa();return ae.forEach(n,(o=>this.getOverlay(e,o).next((l=>{l!==null&&s.set(o,l)})))).next((()=>s))}saveOverlays(e,n,s){return s.forEach(((o,l)=>{this.wt(e,n,l)})),ae.resolve()}removeOverlaysForBatchId(e,n,s){const o=this.Br.get(s);return o!==void 0&&(o.forEach((l=>this.overlays=this.overlays.remove(l))),this.Br.delete(s)),ae.resolve()}getOverlaysForCollection(e,n,s){const o=sa(),l=n.length+1,c=new Se(n.child("")),f=this.overlays.getIteratorFrom(c);for(;f.hasNext();){const d=f.getNext().value,m=d.getKey();if(!n.isPrefixOf(m.path))break;m.path.length===l&&d.largestBatchId>s&&o.set(d.getKey(),d)}return ae.resolve(o)}getOverlaysForCollectionGroup(e,n,s,o){let l=new mt(((m,g)=>m-g));const c=this.overlays.getIterator();for(;c.hasNext();){const m=c.getNext().value;if(m.getKey().getCollectionGroup()===n&&m.largestBatchId>s){let g=l.get(m.largestBatchId);g===null&&(g=sa(),l=l.insert(m.largestBatchId,g)),g.set(m.getKey(),m)}}const f=sa(),d=l.getIterator();for(;d.hasNext()&&(d.getNext().value.forEach(((m,g)=>f.set(m,g))),!(f.size()>=o)););return ae.resolve(f)}wt(e,n,s){const o=this.overlays.get(s.key);if(o!==null){const c=this.Br.get(o.largestBatchId).delete(s.key);this.Br.set(o.largestBatchId,c)}this.overlays=this.overlays.insert(s.key,new OB(n,s));let l=this.Br.get(n);l===void 0&&(l=Be(),this.Br.set(n,l)),this.Br.set(n,l.add(s.key))}}class gF{constructor(){this.sessionToken=rn.EMPTY_BYTE_STRING}getSessionToken(e){return ae.resolve(this.sessionToken)}setSessionToken(e,n){return this.sessionToken=n,ae.resolve()}}class d0{constructor(){this.Lr=new Bt(Qt.kr),this.qr=new Bt(Qt.Kr)}isEmpty(){return this.Lr.isEmpty()}addReference(e,n){const s=new Qt(e,n);this.Lr=this.Lr.add(s),this.qr=this.qr.add(s)}Ur(e,n){e.forEach((s=>this.addReference(s,n)))}removeReference(e,n){this.$r(new Qt(e,n))}Wr(e,n){e.forEach((s=>this.removeReference(s,n)))}Qr(e){const n=new Se(new ct([])),s=new Qt(n,e),o=new Qt(n,e+1),l=[];return this.qr.forEachInRange([s,o],(c=>{this.$r(c),l.push(c.key)})),l}Gr(){this.Lr.forEach((e=>this.$r(e)))}$r(e){this.Lr=this.Lr.delete(e),this.qr=this.qr.delete(e)}zr(e){const n=new Se(new ct([])),s=new Qt(n,e),o=new Qt(n,e+1);let l=Be();return this.qr.forEachInRange([s,o],(c=>{l=l.add(c.key)})),l}containsKey(e){const n=new Qt(e,0),s=this.Lr.firstAfterOrEqual(n);return s!==null&&e.isEqual(s.key)}}class Qt{constructor(e,n){this.key=e,this.jr=n}static kr(e,n){return Se.comparator(e.key,n.key)||ze(e.jr,n.jr)}static Kr(e,n){return ze(e.jr,n.jr)||Se.comparator(e.key,n.key)}}class yF{constructor(e,n){this.indexManager=e,this.referenceDelegate=n,this.mutationQueue=[],this.Xn=1,this.Jr=new Bt(Qt.kr)}checkEmpty(e){return ae.resolve(this.mutationQueue.length===0)}addMutationBatch(e,n,s,o){const l=this.Xn;this.Xn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const c=new DB(l,n,s,o);this.mutationQueue.push(c);for(const f of o)this.Jr=this.Jr.add(new Qt(f.key,l)),this.indexManager.addToCollectionParentIndex(e,f.key.path.popLast());return ae.resolve(c)}lookupMutationBatch(e,n){return ae.resolve(this.Hr(n))}getNextMutationBatchAfterBatchId(e,n){const s=n+1,o=this.Zr(s),l=o<0?0:o;return ae.resolve(this.mutationQueue.length>l?this.mutationQueue[l]:null)}getHighestUnacknowledgedBatchId(){return ae.resolve(this.mutationQueue.length===0?t0:this.Xn-1)}getAllMutationBatches(e){return ae.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,n){const s=new Qt(n,0),o=new Qt(n,Number.POSITIVE_INFINITY),l=[];return this.Jr.forEachInRange([s,o],(c=>{const f=this.Hr(c.jr);l.push(f)})),ae.resolve(l)}getAllMutationBatchesAffectingDocumentKeys(e,n){let s=new Bt(ze);return n.forEach((o=>{const l=new Qt(o,0),c=new Qt(o,Number.POSITIVE_INFINITY);this.Jr.forEachInRange([l,c],(f=>{s=s.add(f.jr)}))})),ae.resolve(this.Xr(s))}getAllMutationBatchesAffectingQuery(e,n){const s=n.path,o=s.length+1;let l=s;Se.isDocumentKey(l)||(l=l.child(""));const c=new Qt(new Se(l),0);let f=new Bt(ze);return this.Jr.forEachWhile((d=>{const m=d.key.path;return!!s.isPrefixOf(m)&&(m.length===o&&(f=f.add(d.jr)),!0)}),c),ae.resolve(this.Xr(f))}Xr(e){const n=[];return e.forEach((s=>{const o=this.Hr(s);o!==null&&n.push(o)})),n}removeMutationBatch(e,n){We(this.Yr(n.batchId,"removed")===0,55003),this.mutationQueue.shift();let s=this.Jr;return ae.forEach(n.mutations,(o=>{const l=new Qt(o.key,n.batchId);return s=s.delete(l),this.referenceDelegate.markPotentiallyOrphaned(e,o.key)})).next((()=>{this.Jr=s}))}tr(e){}containsKey(e,n){const s=new Qt(n,0),o=this.Jr.firstAfterOrEqual(s);return ae.resolve(n.isEqual(o&&o.key))}performConsistencyCheck(e){return this.mutationQueue.length,ae.resolve()}Yr(e,n){return this.Zr(e)}Zr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Hr(e){const n=this.Zr(e);return n<0||n>=this.mutationQueue.length?null:this.mutationQueue[n]}}class vF{constructor(e){this.ei=e,this.docs=(function(){return new mt(Se.comparator)})(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,n){const s=n.key,o=this.docs.get(s),l=o?o.size:0,c=this.ei(n);return this.docs=this.docs.insert(s,{document:n.mutableCopy(),size:c}),this.size+=c-l,this.indexManager.addToCollectionParentIndex(e,s.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 s=this.docs.get(n);return ae.resolve(s?s.document.mutableCopy():dn.newInvalidDocument(n))}getEntries(e,n){let s=qi();return n.forEach((o=>{const l=this.docs.get(o);s=s.insert(o,l?l.document.mutableCopy():dn.newInvalidDocument(o))})),ae.resolve(s)}getDocumentsMatchingQuery(e,n,s,o){let l=qi();const c=n.path,f=new Se(c.child("__id-9223372036854775808__")),d=this.docs.getIteratorFrom(f);for(;d.hasNext();){const{key:m,value:{document:g}}=d.getNext();if(!c.isPrefixOf(m.path))break;m.path.length>c.length+1||qz(Fz(g),s)<=0||(o.has(g.key)||Mm(n,g))&&(l=l.insert(g.key,g.mutableCopy()))}return ae.resolve(l)}getAllFromCollectionGroup(e,n,s,o){Ie(9500)}ti(e,n){return ae.forEach(this.docs,(s=>n(s)))}newChangeBuffer(e){return new bF(this)}getSize(e){return ae.resolve(this.size)}}class bF extends fF{constructor(e){super(),this.Fr=e}applyChanges(e){const n=[];return this.changes.forEach(((s,o)=>{o.isValidDocument()?n.push(this.Fr.addEntry(e,o)):this.Fr.removeEntry(s)})),ae.waitFor(n)}getFromCache(e,n){return this.Fr.getEntry(e,n)}getAllFromCache(e,n){return this.Fr.getEntries(e,n)}}class _F{constructor(e){this.persistence=e,this.ni=new ya((n=>i0(n)),r0),this.lastRemoteSnapshotVersion=Pe.min(),this.highestTargetId=0,this.ri=0,this.ii=new d0,this.targetCount=0,this.si=to.sr()}forEachTarget(e,n){return this.ni.forEach(((s,o)=>n(o))),ae.resolve()}getLastRemoteSnapshotVersion(e){return ae.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return ae.resolve(this.ri)}allocateTargetId(e){return this.highestTargetId=this.si.next(),ae.resolve(this.highestTargetId)}setTargetsMetadata(e,n,s){return s&&(this.lastRemoteSnapshotVersion=s),n>this.ri&&(this.ri=n),ae.resolve()}cr(e){this.ni.set(e.target,e);const n=e.targetId;n>this.highestTargetId&&(this.si=new to(n),this.highestTargetId=n),e.sequenceNumber>this.ri&&(this.ri=e.sequenceNumber)}addTargetData(e,n){return this.cr(n),this.targetCount+=1,ae.resolve()}updateTargetData(e,n){return this.cr(n),ae.resolve()}removeTargetData(e,n){return this.ni.delete(n.target),this.ii.Qr(n.targetId),this.targetCount-=1,ae.resolve()}removeTargets(e,n,s){let o=0;const l=[];return this.ni.forEach(((c,f)=>{f.sequenceNumber<=n&&s.get(f.targetId)===null&&(this.ni.delete(c),l.push(this.removeMatchingKeysForTargetId(e,f.targetId)),o++)})),ae.waitFor(l).next((()=>o))}getTargetCount(e){return ae.resolve(this.targetCount)}getTargetData(e,n){const s=this.ni.get(n)||null;return ae.resolve(s)}addMatchingKeys(e,n,s){return this.ii.Ur(n,s),ae.resolve()}removeMatchingKeys(e,n,s){this.ii.Wr(n,s);const o=this.persistence.referenceDelegate,l=[];return o&&n.forEach((c=>{l.push(o.markPotentiallyOrphaned(e,c))})),ae.waitFor(l)}removeMatchingKeysForTargetId(e,n){return this.ii.Qr(n),ae.resolve()}getMatchingKeysForTargetId(e,n){const s=this.ii.zr(n);return ae.resolve(s)}containsKey(e,n){return ae.resolve(this.ii.containsKey(n))}}class $I{constructor(e,n){this.oi={},this.overlays={},this._i=new Nm(0),this.ai=!1,this.ai=!0,this.ui=new gF,this.referenceDelegate=e(this),this.ci=new _F(this),this.indexManager=new iF,this.remoteDocumentCache=(function(o){return new vF(o)})((s=>this.referenceDelegate.li(s))),this.serializer=new nF(n),this.hi=new mF(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ai=!1,Promise.resolve()}get started(){return this.ai}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let n=this.overlays[e.toKey()];return n||(n=new pF,this.overlays[e.toKey()]=n),n}getMutationQueue(e,n){let s=this.oi[e.toKey()];return s||(s=new yF(n,this.referenceDelegate),this.oi[e.toKey()]=s),s}getGlobalsCache(){return this.ui}getTargetCache(){return this.ci}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.hi}runTransaction(e,n,s){me("MemoryPersistence","Starting transaction:",e);const o=new TF(this._i.next());return this.referenceDelegate.Pi(),s(o).next((l=>this.referenceDelegate.Ti(o).next((()=>l)))).toPromise().then((l=>(o.raiseOnCommittedEvent(),l)))}Ii(e,n){return ae.or(Object.values(this.oi).map((s=>()=>s.containsKey(e,n))))}}class TF extends Gz{constructor(e){super(),this.currentSequenceNumber=e}}class m0{constructor(e){this.persistence=e,this.Ei=new d0,this.Ri=null}static Ai(e){return new m0(e)}get Vi(){if(this.Ri)return this.Ri;throw Ie(60996)}addReference(e,n,s){return this.Ei.addReference(s,n),this.Vi.delete(s.toString()),ae.resolve()}removeReference(e,n,s){return this.Ei.removeReference(s,n),this.Vi.add(s.toString()),ae.resolve()}markPotentiallyOrphaned(e,n){return this.Vi.add(n.toString()),ae.resolve()}removeTarget(e,n){this.Ei.Qr(n.targetId).forEach((o=>this.Vi.add(o.toString())));const s=this.persistence.getTargetCache();return s.getMatchingKeysForTargetId(e,n.targetId).next((o=>{o.forEach((l=>this.Vi.add(l.toString())))})).next((()=>s.removeTargetData(e,n)))}Pi(){this.Ri=new Set}Ti(e){const n=this.persistence.getRemoteDocumentCache().newChangeBuffer();return ae.forEach(this.Vi,(s=>{const o=Se.fromPath(s);return this.di(e,o).next((l=>{l||n.removeEntry(o,Pe.min())}))})).next((()=>(this.Ri=null,n.apply(e))))}updateLimboDocument(e,n){return this.di(e,n).next((s=>{s?this.Vi.delete(n.toString()):this.Vi.add(n.toString())}))}li(e){return 0}di(e,n){return ae.or([()=>ae.resolve(this.Ei.containsKey(n)),()=>this.persistence.getTargetCache().containsKey(e,n),()=>this.persistence.Ii(e,n)])}}class Wd{constructor(e,n){this.persistence=e,this.mi=new ya((s=>Qz(s.path)),((s,o)=>s.isEqual(o))),this.garbageCollector=uF(this,n)}static Ai(e,n){return new Wd(e,n)}Pi(){}Ti(e){return ae.resolve()}forEachTarget(e,n){return this.persistence.getTargetCache().forEachTarget(e,n)}Vr(e){const n=this.gr(e);return this.persistence.getTargetCache().getTargetCount(e).next((s=>n.next((o=>s+o))))}gr(e){let n=0;return this.dr(e,(s=>{n++})).next((()=>n))}dr(e,n){return ae.forEach(this.mi,((s,o)=>this.yr(e,s,o).next((l=>l?ae.resolve():n(o)))))}removeTargets(e,n,s){return this.persistence.getTargetCache().removeTargets(e,n,s)}removeOrphanedDocuments(e,n){let s=0;const o=this.persistence.getRemoteDocumentCache(),l=o.newChangeBuffer();return o.ti(e,(c=>this.yr(e,c,n).next((f=>{f||(s++,l.removeEntry(c,Pe.min()))})))).next((()=>l.apply(e))).next((()=>s))}markPotentiallyOrphaned(e,n){return this.mi.set(n,e.currentSequenceNumber),ae.resolve()}removeTarget(e,n){const s=n.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,s)}addReference(e,n,s){return this.mi.set(s,e.currentSequenceNumber),ae.resolve()}removeReference(e,n,s){return this.mi.set(s,e.currentSequenceNumber),ae.resolve()}updateLimboDocument(e,n){return this.mi.set(n,e.currentSequenceNumber),ae.resolve()}li(e){let n=e.key.toString().length;return e.isFoundDocument()&&(n+=md(e.data.value)),n}yr(e,n,s){return ae.or([()=>this.persistence.Ii(e,n),()=>this.persistence.getTargetCache().containsKey(e,n),()=>{const o=this.mi.get(n);return ae.resolve(o!==void 0&&o>s)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class p0{constructor(e,n,s,o){this.targetId=e,this.fromCache=n,this.Ps=s,this.Ts=o}static Is(e,n){let s=Be(),o=Be();for(const l of n.docChanges)switch(l.type){case 0:s=s.add(l.doc.key);break;case 1:o=o.add(l.doc.key)}return new p0(e,n.fromCache,s,o)}}class wF{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class xF{constructor(){this.Es=!1,this.Rs=!1,this.As=100,this.Vs=(function(){return f5()?8:$z(mn())>0?6:4})()}initialize(e,n){this.ds=e,this.indexManager=n,this.Es=!0}getDocumentsMatchingQuery(e,n,s,o){const l={result:null};return this.fs(e,n).next((c=>{l.result=c})).next((()=>{if(!l.result)return this.gs(e,n,o,s).next((c=>{l.result=c}))})).next((()=>{if(l.result)return;const c=new wF;return this.ps(e,n,c).next((f=>{if(l.result=f,this.Rs)return this.ys(e,n,c,f.size)}))})).next((()=>l.result))}ys(e,n,s,o){return s.documentReadCountthis.Vs*o?(ul()<=Fe.DEBUG&&me("QueryEngine","The SDK decides to create cache indexes for query:",fl(n),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,si(n))):ae.resolve())}fs(e,n){if(WS(n))return ae.resolve(null);let s=si(n);return this.indexManager.getIndexType(e,s).next((o=>o===0?null:(n.limit!==null&&o===1&&(n=Lv(n,null,"F"),s=si(n)),this.indexManager.getDocumentsMatchingTarget(e,s).next((l=>{const c=Be(...l);return this.ds.getDocuments(e,c).next((f=>this.indexManager.getMinOffset(e,s).next((d=>{const m=this.ws(n,f);return this.Ss(n,m,c,d.readTime)?this.fs(e,Lv(n,null,"F")):this.bs(e,m,n,d)}))))})))))}gs(e,n,s,o){return WS(n)||o.isEqual(Pe.min())?ae.resolve(null):this.ds.getDocuments(e,s).next((l=>{const c=this.ws(n,l);return this.Ss(n,c,s,o)?ae.resolve(null):(ul()<=Fe.DEBUG&&me("QueryEngine","Re-using previous result from %s to execute query: %s",o.toString(),fl(n)),this.bs(e,c,n,Bz(o,Vu)).next((f=>f)))}))}ws(e,n){let s=new Bt(EI(e));return n.forEach(((o,l)=>{Mm(e,l)&&(s=s.add(l))})),s}Ss(e,n,s,o){if(e.limit===null)return!1;if(s.size!==n.size)return!0;const l=e.limitType==="F"?n.last():n.first();return!!l&&(l.hasPendingWrites||l.version.compareTo(o)>0)}ps(e,n,s){return ul()<=Fe.DEBUG&&me("QueryEngine","Using full collection scan to execute query:",fl(n)),this.ds.getDocumentsMatchingQuery(e,n,Xr.min(),s)}bs(e,n,s,o){return this.ds.getDocumentsMatchingQuery(e,s,o).next((l=>(n.forEach((c=>{l=l.insert(c.key,c)})),l)))}}const g0="LocalStore",EF=3e8;class SF{constructor(e,n,s,o){this.persistence=e,this.Ds=n,this.serializer=o,this.Cs=new mt(ze),this.vs=new ya((l=>i0(l)),r0),this.Fs=new Map,this.Ms=e.getRemoteDocumentCache(),this.ci=e.getTargetCache(),this.hi=e.getBundleCache(),this.xs(s)}xs(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new dF(this.Ms,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Ms.setIndexManager(this.indexManager),this.Ds.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(n=>e.collect(n,this.Cs)))}}function AF(t,e,n,s){return new SF(t,e,n,s)}async function KI(t,e){const n=Oe(t);return await n.persistence.runTransaction("Handle user change","readonly",(s=>{let o;return n.mutationQueue.getAllMutationBatches(s).next((l=>(o=l,n.xs(e),n.mutationQueue.getAllMutationBatches(s)))).next((l=>{const c=[],f=[];let d=Be();for(const m of o){c.push(m.batchId);for(const g of m.mutations)d=d.add(g.key)}for(const m of l){f.push(m.batchId);for(const g of m.mutations)d=d.add(g.key)}return n.localDocuments.getDocuments(s,d).next((m=>({Os:m,removedBatchIds:c,addedBatchIds:f})))}))}))}function RF(t,e){const n=Oe(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(s=>{const o=e.batch.keys(),l=n.Ms.newChangeBuffer({trackRemovals:!0});return(function(f,d,m,g){const v=m.batch,T=v.keys();let E=ae.resolve();return T.forEach((R=>{E=E.next((()=>g.getEntry(d,R))).next((P=>{const N=m.docVersions.get(R);We(N!==null,48541),P.version.compareTo(N)<0&&(v.applyToRemoteDocument(P,m),P.isValidDocument()&&(P.setReadTime(m.commitVersion),g.addEntry(P)))}))})),E.next((()=>f.mutationQueue.removeMutationBatch(d,v)))})(n,s,e,l).next((()=>l.apply(s))).next((()=>n.mutationQueue.performConsistencyCheck(s))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(s,o,e.batch.batchId))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(s,(function(f){let d=Be();for(let m=0;m0&&(d=d.add(f.batch.mutations[m].key));return d})(e)))).next((()=>n.localDocuments.getDocuments(s,o)))}))}function QI(t){const e=Oe(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(n=>e.ci.getLastRemoteSnapshotVersion(n)))}function CF(t,e){const n=Oe(t),s=e.snapshotVersion;let o=n.Cs;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(l=>{const c=n.Ms.newChangeBuffer({trackRemovals:!0});o=n.Cs;const f=[];e.targetChanges.forEach(((g,v)=>{const T=o.get(v);if(!T)return;f.push(n.ci.removeMatchingKeys(l,g.removedDocuments,v).next((()=>n.ci.addMatchingKeys(l,g.addedDocuments,v))));let E=T.withSequenceNumber(l.currentSequenceNumber);e.targetMismatches.get(v)!==null?E=E.withResumeToken(rn.EMPTY_BYTE_STRING,Pe.min()).withLastLimboFreeSnapshotVersion(Pe.min()):g.resumeToken.approximateByteSize()>0&&(E=E.withResumeToken(g.resumeToken,s)),o=o.insert(v,E),(function(P,N,L){return P.resumeToken.approximateByteSize()===0||N.snapshotVersion.toMicroseconds()-P.snapshotVersion.toMicroseconds()>=EF?!0:L.addedDocuments.size+L.modifiedDocuments.size+L.removedDocuments.size>0})(T,E,g)&&f.push(n.ci.updateTargetData(l,E))}));let d=qi(),m=Be();if(e.documentUpdates.forEach((g=>{e.resolvedLimboDocuments.has(g)&&f.push(n.persistence.referenceDelegate.updateLimboDocument(l,g))})),f.push(IF(l,c,e.documentUpdates).next((g=>{d=g.Ns,m=g.Bs}))),!s.isEqual(Pe.min())){const g=n.ci.getLastRemoteSnapshotVersion(l).next((v=>n.ci.setTargetsMetadata(l,l.currentSequenceNumber,s)));f.push(g)}return ae.waitFor(f).next((()=>c.apply(l))).next((()=>n.localDocuments.getLocalViewOfDocuments(l,d,m))).next((()=>d))})).then((l=>(n.Cs=o,l)))}function IF(t,e,n){let s=Be(),o=Be();return n.forEach((l=>s=s.add(l))),e.getEntries(t,s).next((l=>{let c=qi();return n.forEach(((f,d)=>{const m=l.get(f);d.isFoundDocument()!==m.isFoundDocument()&&(o=o.add(f)),d.isNoDocument()&&d.version.isEqual(Pe.min())?(e.removeEntry(f,d.readTime),c=c.insert(f,d)):!m.isValidDocument()||d.version.compareTo(m.version)>0||d.version.compareTo(m.version)===0&&m.hasPendingWrites?(e.addEntry(d),c=c.insert(f,d)):me(g0,"Ignoring outdated watch update for ",f,". Current version:",m.version," Watch version:",d.version)})),{Ns:c,Bs:o}}))}function NF(t,e){const n=Oe(t);return n.persistence.runTransaction("Get next mutation batch","readonly",(s=>(e===void 0&&(e=t0),n.mutationQueue.getNextMutationBatchAfterBatchId(s,e))))}function PF(t,e){const n=Oe(t);return n.persistence.runTransaction("Allocate target","readwrite",(s=>{let o;return n.ci.getTargetData(s,e).next((l=>l?(o=l,ae.resolve(o)):n.ci.allocateTargetId(s).next((c=>(o=new Mi(e,c,"TargetPurposeListen",s.currentSequenceNumber),n.ci.addTargetData(s,o).next((()=>o)))))))})).then((s=>{const o=n.Cs.get(s.targetId);return(o===null||s.snapshotVersion.compareTo(o.snapshotVersion)>0)&&(n.Cs=n.Cs.insert(s.targetId,s),n.vs.set(e,s.targetId)),s}))}async function qv(t,e,n){const s=Oe(t),o=s.Cs.get(e),l=n?"readwrite":"readwrite-primary";try{n||await s.persistence.runTransaction("Release target",l,(c=>s.persistence.referenceDelegate.removeTarget(c,o)))}catch(c){if(!Gl(c))throw c;me(g0,`Failed to update sequence numbers for target ${e}: ${c}`)}s.Cs=s.Cs.remove(e),s.vs.delete(o.target)}function cA(t,e,n){const s=Oe(t);let o=Pe.min(),l=Be();return s.persistence.runTransaction("Execute query","readwrite",(c=>(function(d,m,g){const v=Oe(d),T=v.vs.get(g);return T!==void 0?ae.resolve(v.Cs.get(T)):v.ci.getTargetData(m,g)})(s,c,si(e)).next((f=>{if(f)return o=f.lastLimboFreeSnapshotVersion,s.ci.getMatchingKeysForTargetId(c,f.targetId).next((d=>{l=d}))})).next((()=>s.Ds.getDocumentsMatchingQuery(c,e,n?o:Pe.min(),n?l:Be()))).next((f=>(DF(s,gB(e),f),{documents:f,Ls:l})))))}function DF(t,e,n){let s=t.Fs.get(e)||Pe.min();n.forEach(((o,l)=>{l.readTime.compareTo(s)>0&&(s=l.readTime)})),t.Fs.set(e,s)}class uA{constructor(){this.activeTargetIds=wB()}Ws(e){this.activeTargetIds=this.activeTargetIds.add(e)}Qs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}$s(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class OF{constructor(){this.Co=new uA,this.vo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,n,s){}addLocalQueryTarget(e,n=!0){return n&&this.Co.Ws(e),this.vo[e]||"not-current"}updateQueryState(e,n,s){this.vo[e]=n}removeLocalQueryTarget(e){this.Co.Qs(e)}isLocalQueryTarget(e){return this.Co.activeTargetIds.has(e)}clearQueryState(e){delete this.vo[e]}getAllActiveQueryTargets(){return this.Co.activeTargetIds}isActiveQueryTarget(e){return this.Co.activeTargetIds.has(e)}start(){return this.Co=new uA,Promise.resolve()}handleUserChange(e,n,s){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class MF{Fo(e){}shutdown(){}}const fA="ConnectivityMonitor";class hA{constructor(){this.Mo=()=>this.xo(),this.Oo=()=>this.No(),this.Bo=[],this.Lo()}Fo(e){this.Bo.push(e)}shutdown(){window.removeEventListener("online",this.Mo),window.removeEventListener("offline",this.Oo)}Lo(){window.addEventListener("online",this.Mo),window.addEventListener("offline",this.Oo)}xo(){me(fA,"Network connectivity changed: AVAILABLE");for(const e of this.Bo)e(0)}No(){me(fA,"Network connectivity changed: UNAVAILABLE");for(const e of this.Bo)e(1)}static v(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}let Zh=null;function Hv(){return Zh===null?Zh=(function(){return 268435456+Math.round(2147483648*Math.random())})():Zh++,"0x"+Zh.toString(16)}const ky="RestConnection",kF={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class VF{get ko(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const n=e.ssl?"https":"http",s=encodeURIComponent(this.databaseId.projectId),o=encodeURIComponent(this.databaseId.database);this.qo=n+"://"+e.host,this.Ko=`projects/${s}/databases/${o}`,this.Uo=this.databaseId.database===qd?`project_id=${s}`:`project_id=${s}&database_id=${o}`}$o(e,n,s,o,l){const c=Hv(),f=this.Wo(e,n.toUriEncodedString());me(ky,`Sending RPC '${e}' ${c}:`,f,s);const d={"google-cloud-resource-prefix":this.Ko,"x-goog-request-params":this.Uo};this.Qo(d,o,l);const{host:m}=new URL(f),g=rf(m);return this.Go(e,f,d,s,g).then((v=>(me(ky,`Received RPC '${e}' ${c}: `,v),v)),(v=>{throw ha(ky,`RPC '${e}' ${c} failed with error: `,v,"url: ",f,"request:",s),v}))}zo(e,n,s,o,l,c){return this.$o(e,n,s,o,l)}Qo(e,n,s){e["X-Goog-Api-Client"]=(function(){return"gl-js/ fire/"+ql})(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),n&&n.headers.forEach(((o,l)=>e[l]=o)),s&&s.headers.forEach(((o,l)=>e[l]=o))}Wo(e,n){const s=kF[e];let o=`${this.qo}/v1/${n}:${s}`;return this.databaseInfo.apiKey&&(o=`${o}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),o}terminate(){}}class jF{constructor(e){this.jo=e.jo,this.Jo=e.Jo}Ho(e){this.Zo=e}Xo(e){this.Yo=e}e_(e){this.t_=e}onMessage(e){this.n_=e}close(){this.Jo()}send(e){this.jo(e)}r_(){this.Zo()}i_(){this.Yo()}s_(e){this.t_(e)}o_(e){this.n_(e)}}const fn="WebChannelConnection",ru=(t,e,n)=>{t.listen(e,(s=>{try{n(s)}catch(o){setTimeout((()=>{throw o}),0)}}))};class vl extends VF{constructor(e){super(e),this.__=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static a_(){if(!vl.u_){const e=J2();ru(e,Z2.STAT_EVENT,(n=>{n.stat===Dv.PROXY?me(fn,"STAT_EVENT: detected buffering proxy"):n.stat===Dv.NOPROXY&&me(fn,"STAT_EVENT: detected no buffering proxy")})),vl.u_=!0}}Go(e,n,s,o,l){const c=Hv();return new Promise(((f,d)=>{const m=new W2;m.setWithCredentials(!0),m.listenOnce(X2.COMPLETE,(()=>{try{switch(m.getLastErrorCode()){case dd.NO_ERROR:const v=m.getResponseJson();me(fn,`XHR for RPC '${e}' ${c} received:`,JSON.stringify(v)),f(v);break;case dd.TIMEOUT:me(fn,`RPC '${e}' ${c} timed out`),d(new ge(re.DEADLINE_EXCEEDED,"Request time out"));break;case dd.HTTP_ERROR:const T=m.getStatus();if(me(fn,`RPC '${e}' ${c} failed with status:`,T,"response text:",m.getResponseText()),T>0){let E=m.getResponseJson();Array.isArray(E)&&(E=E[0]);const R=E?.error;if(R&&R.status&&R.message){const P=(function(L){const z=L.toLowerCase().replace(/_/g,"-");return Object.values(re).indexOf(z)>=0?z:re.UNKNOWN})(R.status);d(new ge(P,R.message))}else d(new ge(re.UNKNOWN,"Server responded with status "+m.getStatus()))}else d(new ge(re.UNAVAILABLE,"Connection failed."));break;default:Ie(9055,{c_:e,streamId:c,l_:m.getLastErrorCode(),h_:m.getLastError()})}}finally{me(fn,`RPC '${e}' ${c} completed.`)}}));const g=JSON.stringify(o);me(fn,`RPC '${e}' ${c} sending request:`,o),m.send(n,"POST",g,s,15)}))}P_(e,n,s){const o=Hv(),l=[this.qo,"/","google.firestore.v1.Firestore","/",e,"/channel"],c=this.createWebChannelTransport(),f={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},d=this.longPollingOptions.timeoutSeconds;d!==void 0&&(f.longPollingTimeout=Math.round(1e3*d)),this.useFetchStreams&&(f.useFetchStreams=!0),this.Qo(f.initMessageHeaders,n,s),f.encodeInitMessageHeaders=!0;const m=l.join("");me(fn,`Creating RPC '${e}' stream ${o}: ${m}`,f);const g=c.createWebChannel(m,f);this.T_(g);let v=!1,T=!1;const E=new jF({jo:R=>{T?me(fn,`Not sending because RPC '${e}' stream ${o} is closed:`,R):(v||(me(fn,`Opening RPC '${e}' stream ${o} transport.`),g.open(),v=!0),me(fn,`RPC '${e}' stream ${o} sending:`,R),g.send(R))},Jo:()=>g.close()});return ru(g,uu.EventType.OPEN,(()=>{T||(me(fn,`RPC '${e}' stream ${o} transport opened.`),E.r_())})),ru(g,uu.EventType.CLOSE,(()=>{T||(T=!0,me(fn,`RPC '${e}' stream ${o} transport closed`),E.s_(),this.I_(g))})),ru(g,uu.EventType.ERROR,(R=>{T||(T=!0,ha(fn,`RPC '${e}' stream ${o} transport errored. Name:`,R.name,"Message:",R.message),E.s_(new ge(re.UNAVAILABLE,"The operation could not be completed")))})),ru(g,uu.EventType.MESSAGE,(R=>{if(!T){const P=R.data[0];We(!!P,16349);const N=P,L=N?.error||N[0]?.error;if(L){me(fn,`RPC '${e}' stream ${o} received error:`,L);const z=L.status;let B=(function(te){const M=Nt[te];if(M!==void 0)return MI(M)})(z),H=L.message;z==="NOT_FOUND"&&H.includes("database")&&H.includes("does not exist")&&H.includes(this.databaseId.database)&&ha(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),B===void 0&&(B=re.INTERNAL,H="Unknown error status: "+z+" with message "+L.message),T=!0,E.s_(new ge(B,H)),g.close()}else me(fn,`RPC '${e}' stream ${o} received:`,P),E.o_(P)}})),vl.a_(),setTimeout((()=>{E.i_()}),0),E}terminate(){this.__.forEach((e=>e.close())),this.__=[]}T_(e){this.__.push(e)}I_(e){this.__=this.__.filter((n=>n===e))}Qo(e,n,s){super.Qo(e,n,s),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return eI()}}function LF(t){return new vl(t)}function Vy(){return typeof document<"u"?document:null}function Lm(t){return new FB(t,!0)}vl.u_=!1;class YI{constructor(e,n,s=1e3,o=1.5,l=6e4){this.Di=e,this.timerId=n,this.E_=s,this.R_=o,this.A_=l,this.V_=0,this.d_=null,this.m_=Date.now(),this.reset()}reset(){this.V_=0}f_(){this.V_=this.A_}g_(e){this.cancel();const n=Math.floor(this.V_+this.p_()),s=Math.max(0,Date.now()-this.m_),o=Math.max(0,n-s);o>0&&me("ExponentialBackoff",`Backing off for ${o} ms (base delay: ${this.V_} ms, delay with jitter: ${n} ms, last attempt: ${s} ms ago)`),this.d_=this.Di.enqueueAfterDelay(this.timerId,o,(()=>(this.m_=Date.now(),e()))),this.V_*=this.R_,this.V_this.A_&&(this.V_=this.A_)}y_(){this.d_!==null&&(this.d_.skipDelay(),this.d_=null)}cancel(){this.d_!==null&&(this.d_.cancel(),this.d_=null)}p_(){return(Math.random()-.5)*this.V_}}const dA="PersistentStream";class WI{constructor(e,n,s,o,l,c,f,d){this.Di=e,this.w_=s,this.S_=o,this.connection=l,this.authCredentialsProvider=c,this.appCheckCredentialsProvider=f,this.listener=d,this.state=0,this.b_=0,this.D_=null,this.C_=null,this.stream=null,this.v_=0,this.F_=new YI(e,n)}M_(){return this.state===1||this.state===5||this.x_()}x_(){return this.state===2||this.state===3}start(){this.v_=0,this.state!==4?this.auth():this.O_()}async stop(){this.M_()&&await this.close(0)}N_(){this.state=0,this.F_.reset()}B_(){this.x_()&&this.D_===null&&(this.D_=this.Di.enqueueAfterDelay(this.w_,6e4,(()=>this.L_())))}k_(e){this.q_(),this.stream.send(e)}async L_(){if(this.x_())return this.close(0)}q_(){this.D_&&(this.D_.cancel(),this.D_=null)}K_(){this.C_&&(this.C_.cancel(),this.C_=null)}async close(e,n){this.q_(),this.K_(),this.F_.cancel(),this.b_++,e!==4?this.F_.reset():n&&n.code===re.RESOURCE_EXHAUSTED?(Fi(n.toString()),Fi("Using maximum backoff delay to prevent overloading the backend."),this.F_.f_()):n&&n.code===re.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.U_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.e_(n)}U_(){}auth(){this.state=1;const e=this.W_(this.b_),n=this.b_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([s,o])=>{this.b_===n&&this.Q_(s,o)}),(s=>{e((()=>{const o=new ge(re.UNKNOWN,"Fetching auth token failed: "+s.message);return this.G_(o)}))}))}Q_(e,n){const s=this.W_(this.b_);this.stream=this.z_(e,n),this.stream.Ho((()=>{s((()=>this.listener.Ho()))})),this.stream.Xo((()=>{s((()=>(this.state=2,this.C_=this.Di.enqueueAfterDelay(this.S_,1e4,(()=>(this.x_()&&(this.state=3),Promise.resolve()))),this.listener.Xo())))})),this.stream.e_((o=>{s((()=>this.G_(o)))})),this.stream.onMessage((o=>{s((()=>++this.v_==1?this.j_(o):this.onNext(o)))}))}O_(){this.state=5,this.F_.g_((async()=>{this.state=0,this.start()}))}G_(e){return me(dA,`close with error: ${e}`),this.stream=null,this.close(4,e)}W_(e){return n=>{this.Di.enqueueAndForget((()=>this.b_===e?n():(me(dA,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class UF extends WI{constructor(e,n,s,o,l,c){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",n,s,o,c),this.serializer=l}z_(e,n){return this.connection.P_("Listen",e,n)}j_(e){return this.onNext(e)}onNext(e){this.F_.reset();const n=GB(this.serializer,e),s=(function(l){if(!("targetChange"in l))return Pe.min();const c=l.targetChange;return c.targetIds&&c.targetIds.length?Pe.min():c.readTime?ii(c.readTime):Pe.min()})(e);return this.listener.J_(n,s)}H_(e){const n={};n.database=Fv(this.serializer),n.addTarget=(function(l,c){let f;const d=c.target;if(f=Vv(d)?{documents:QB(l,d)}:{query:YB(l,d).dt},f.targetId=c.targetId,c.resumeToken.approximateByteSize()>0){f.resumeToken=jI(l,c.resumeToken);const m=Uv(l,c.expectedCount);m!==null&&(f.expectedCount=m)}else if(c.snapshotVersion.compareTo(Pe.min())>0){f.readTime=Yd(l,c.snapshotVersion.toTimestamp());const m=Uv(l,c.expectedCount);m!==null&&(f.expectedCount=m)}return f})(this.serializer,e);const s=XB(this.serializer,e);s&&(n.labels=s),this.k_(n)}Z_(e){const n={};n.database=Fv(this.serializer),n.removeTarget=e,this.k_(n)}}class zF extends WI{constructor(e,n,s,o,l,c){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",n,s,o,c),this.serializer=l}get X_(){return this.v_>0}start(){this.lastStreamToken=void 0,super.start()}U_(){this.X_&&this.Y_([])}z_(e,n){return this.connection.P_("Write",e,n)}j_(e){return We(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,We(!e.writeResults||e.writeResults.length===0,55816),this.listener.ea()}onNext(e){We(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.F_.reset();const n=KB(e.writeResults,e.commitTime),s=ii(e.commitTime);return this.listener.ta(s,n)}na(){const e={};e.database=Fv(this.serializer),this.k_(e)}Y_(e){const n={streamToken:this.lastStreamToken,writes:e.map((s=>$B(this.serializer,s)))};this.k_(n)}}class BF{}class FF extends BF{constructor(e,n,s,o){super(),this.authCredentials=e,this.appCheckCredentials=n,this.connection=s,this.serializer=o,this.ra=!1}ia(){if(this.ra)throw new ge(re.FAILED_PRECONDITION,"The client has already been terminated.")}$o(e,n,s,o){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([l,c])=>this.connection.$o(e,zv(n,s),o,l,c))).catch((l=>{throw l.name==="FirebaseError"?(l.code===re.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),l):new ge(re.UNKNOWN,l.toString())}))}zo(e,n,s,o,l){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([c,f])=>this.connection.zo(e,zv(n,s),o,c,f,l))).catch((c=>{throw c.name==="FirebaseError"?(c.code===re.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),c):new ge(re.UNKNOWN,c.toString())}))}terminate(){this.ra=!0,this.connection.terminate()}}function qF(t,e,n,s){return new FF(t,e,n,s)}class HF{constructor(e,n){this.asyncQueue=e,this.onlineStateHandler=n,this.state="Unknown",this.sa=0,this.oa=null,this._a=!0}aa(){this.sa===0&&(this.ua("Unknown"),this.oa=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this.oa=null,this.ca("Backend didn't respond within 10 seconds."),this.ua("Offline"),Promise.resolve()))))}la(e){this.state==="Online"?this.ua("Unknown"):(this.sa++,this.sa>=1&&(this.ha(),this.ca(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ua("Offline")))}set(e){this.ha(),this.sa=0,e==="Online"&&(this._a=!1),this.ua(e)}ua(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}ca(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._a?(Fi(n),this._a=!1):me("OnlineStateTracker",n)}ha(){this.oa!==null&&(this.oa.cancel(),this.oa=null)}}const ci="RemoteStore";class GF{constructor(e,n,s,o,l){this.localStore=e,this.datastore=n,this.asyncQueue=s,this.remoteSyncer={},this.Pa=[],this.Ta=new Map,this.Ia=new Map,this.Ea=new Map,this.Ra=new to(1e3),this.Aa=new to(1001),this.Va=new Set,this.da=[],this.ma=l,this.ma.Fo((c=>{s.enqueueAndForget((async()=>{va(this)&&(me(ci,"Restarting streams for network reachability change."),await(async function(d){const m=Oe(d);m.Va.add(4),await uf(m),m.fa.set("Unknown"),m.Va.delete(4),await Um(m)})(this))}))})),this.fa=new HF(s,o)}}async function Um(t){if(va(t))for(const e of t.da)await e(!0)}async function uf(t){for(const e of t.da)await e(!1)}function Gv(t,e){return t.Ia.get(e)||void 0}function XI(t,e){const n=Oe(t),s=Gv(n,e.targetId);if(s!==void 0&&n.Ta.has(s))return;const o=(function(f,d){const m=Gv(f,d);m!==void 0&&f.Ea.delete(m);const g=(function(T,E){return E%2!=0?T.Aa.next():T.Ra.next()})(f,d);return f.Ia.set(d,g),f.Ea.set(g,d),g})(n,e.targetId);me(ci,"remoteStoreListen mapping SDK target ID to remote",e.targetId,o);const l=new Mi(e.target,o,e.purpose,e.sequenceNumber,e.snapshotVersion,e.lastLimboFreeSnapshotVersion,e.resumeToken);n.Ta.set(o,l),_0(n)?b0(n):Kl(n).x_()&&v0(n,l)}function y0(t,e){const n=Oe(t),s=Kl(n),o=Gv(n,e);me(ci,"remoteStoreUnlisten removing mapping of SDK target ID to remote",e,o),n.Ta.delete(o),n.Ia.delete(e),n.Ea.delete(o),s.x_()&&ZI(n,o),n.Ta.size===0&&(s.x_()?s.B_():va(n)&&n.fa.set("Unknown"))}function v0(t,e){if(t.ga.$e(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(Pe.min())>0){const n=t.Ea.get(e.targetId);if(n===void 0)return void me(ci,"SDK target ID not found for remote ID: "+e.targetId);const s=t.remoteSyncer.getRemoteKeysForTarget(n).size;e=e.withExpectedCount(s)}Kl(t).H_(e)}function ZI(t,e){t.ga.$e(e),Kl(t).Z_(e)}function b0(t){t.ga=new LB({getRemoteKeysForTarget:e=>{const n=t.Ea.get(e);return n!==void 0?t.remoteSyncer.getRemoteKeysForTarget(n):Be()},Rt:e=>t.Ta.get(e)||null,lt:()=>t.datastore.serializer.databaseId}),Kl(t).start(),t.fa.aa()}function _0(t){return va(t)&&!Kl(t).M_()&&t.Ta.size>0}function va(t){return Oe(t).Va.size===0}function JI(t){t.ga=void 0}async function $F(t){t.fa.set("Online")}async function KF(t){t.Ta.forEach(((e,n)=>{v0(t,e)}))}async function QF(t,e){JI(t),_0(t)?(t.fa.la(e),b0(t)):t.fa.set("Unknown")}async function YF(t,e,n){if(t.fa.set("Online"),e instanceof VI&&e.state===2&&e.cause)try{await(async function(o,l){const c=l.cause;for(const f of l.targetIds){if(o.Ta.has(f)){const d=o.Ea.get(f);d!==void 0&&(await o.remoteSyncer.rejectListen(d,c),o.Ia.delete(d),o.Ea.delete(f)),o.Ta.delete(f)}o.ga.removeTarget(f)}})(t,e)}catch(s){me(ci,"Failed to remove targets %s: %s ",e.targetIds.join(","),s),await Xd(t,s)}else if(e instanceof yd?t.ga.Xe(e):e instanceof kI?t.ga.it(e):t.ga.tt(e),!n.isEqual(Pe.min()))try{const s=await QI(t.localStore);n.compareTo(s)>=0&&await(function(l,c){const f=l.ga.Pt(c);f.targetChanges.forEach(((m,g)=>{if(m.resumeToken.approximateByteSize()>0){const v=l.Ta.get(g);v&&l.Ta.set(g,v.withResumeToken(m.resumeToken,c))}})),f.targetMismatches.forEach(((m,g)=>{const v=l.Ta.get(m);if(!v)return;l.Ta.set(m,v.withResumeToken(rn.EMPTY_BYTE_STRING,v.snapshotVersion)),ZI(l,m);const T=new Mi(v.target,m,g,v.sequenceNumber);v0(l,T)}));const d=(function(g,v){const T=new Map;v.targetChanges.forEach(((R,P)=>{const N=g.Ea.get(P);N!==void 0&&T.set(N,R)}));let E=new mt(ze);return v.targetMismatches.forEach(((R,P)=>{const N=g.Ea.get(R);N!==void 0&&(E=E.insert(N,P))})),new lf(v.snapshotVersion,T,E,v.documentUpdates,v.resolvedLimboDocuments)})(l,f);return l.remoteSyncer.applyRemoteEvent(d)})(t,n)}catch(s){me(ci,"Failed to raise snapshot:",s),await Xd(t,s)}}async function Xd(t,e,n){if(!Gl(e))throw e;t.Va.add(1),await uf(t),t.fa.set("Offline"),n||(n=()=>QI(t.localStore)),t.asyncQueue.enqueueRetryable((async()=>{me(ci,"Retrying IndexedDB access"),await n(),t.Va.delete(1),await Um(t)}))}function eN(t,e){return e().catch((n=>Xd(t,n,e)))}async function zm(t){const e=Oe(t),n=no(e);let s=e.Pa.length>0?e.Pa[e.Pa.length-1].batchId:t0;for(;WF(e);)try{const o=await NF(e.localStore,s);if(o===null){e.Pa.length===0&&n.B_();break}s=o.batchId,XF(e,o)}catch(o){await Xd(e,o)}tN(e)&&nN(e)}function WF(t){return va(t)&&t.Pa.length<10}function XF(t,e){t.Pa.push(e);const n=no(t);n.x_()&&n.X_&&n.Y_(e.mutations)}function tN(t){return va(t)&&!no(t).M_()&&t.Pa.length>0}function nN(t){no(t).start()}async function ZF(t){no(t).na()}async function JF(t){const e=no(t);for(const n of t.Pa)e.Y_(n.mutations)}async function e7(t,e,n){const s=t.Pa.shift(),o=u0.from(s,e,n);await eN(t,(()=>t.remoteSyncer.applySuccessfulWrite(o))),await zm(t)}async function t7(t,e){e&&no(t).X_&&await(async function(s,o){if((function(c){return kB(c)&&c!==re.ABORTED})(o.code)){const l=s.Pa.shift();no(s).N_(),await eN(s,(()=>s.remoteSyncer.rejectFailedWrite(l.batchId,o))),await zm(s)}})(t,e),tN(t)&&nN(t)}async function mA(t,e){const n=Oe(t);n.asyncQueue.verifyOperationInProgress(),me(ci,"RemoteStore received new credentials");const s=va(n);n.Va.add(3),await uf(n),s&&n.fa.set("Unknown"),await n.remoteSyncer.handleCredentialChange(e),n.Va.delete(3),await Um(n)}async function n7(t,e){const n=Oe(t);e?(n.Va.delete(2),await Um(n)):e||(n.Va.add(2),await uf(n),n.fa.set("Unknown"))}function Kl(t){return t.pa||(t.pa=(function(n,s,o){const l=Oe(n);return l.ia(),new UF(s,l.connection,l.authCredentials,l.appCheckCredentials,l.serializer,o)})(t.datastore,t.asyncQueue,{Ho:$F.bind(null,t),Xo:KF.bind(null,t),e_:QF.bind(null,t),J_:YF.bind(null,t)}),t.da.push((async e=>{e?(t.pa.N_(),_0(t)?b0(t):t.fa.set("Unknown")):(await t.pa.stop(),JI(t))}))),t.pa}function no(t){return t.ya||(t.ya=(function(n,s,o){const l=Oe(n);return l.ia(),new zF(s,l.connection,l.authCredentials,l.appCheckCredentials,l.serializer,o)})(t.datastore,t.asyncQueue,{Ho:()=>Promise.resolve(),Xo:ZF.bind(null,t),e_:t7.bind(null,t),ea:JF.bind(null,t),ta:e7.bind(null,t)}),t.da.push((async e=>{e?(t.ya.N_(),await zm(t)):(await t.ya.stop(),t.Pa.length>0&&(me(ci,`Stopping write stream with ${t.Pa.length} pending writes`),t.Pa=[]))}))),t.ya}class T0{constructor(e,n,s,o,l){this.asyncQueue=e,this.timerId=n,this.targetTimeMs=s,this.op=o,this.removalCallback=l,this.deferred=new ji,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((c=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(e,n,s,o,l){const c=Date.now()+s,f=new T0(e,n,c,o,l);return f.start(s),f}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new ge(re.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 w0(t,e){if(Fi("AsyncQueue",`${e}: ${t}`),Gl(t))return new ge(re.UNAVAILABLE,`${e}: ${t}`);throw t}class bl{static emptySet(e){return new bl(e.comparator)}constructor(e){this.comparator=e?(n,s)=>e(n,s)||Se.comparator(n.key,s.key):(n,s)=>Se.comparator(n.key,s.key),this.keyedMap=fu(),this.sortedSet=new mt(this.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,s)=>(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 bl)||this.size!==e.size)return!1;const n=this.sortedSet.getIterator(),s=e.sortedSet.getIterator();for(;n.hasNext();){const o=n.getNext().key,l=s.getNext().key;if(!o.isEqual(l))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 s=new bl;return s.comparator=this.comparator,s.keyedMap=e,s.sortedSet=n,s}}class pA{constructor(){this.wa=new mt(Se.comparator)}track(e){const n=e.doc.key,s=this.wa.get(n);s?e.type!==0&&s.type===3?this.wa=this.wa.insert(n,e):e.type===3&&s.type!==1?this.wa=this.wa.insert(n,{type:s.type,doc:e.doc}):e.type===2&&s.type===2?this.wa=this.wa.insert(n,{type:2,doc:e.doc}):e.type===2&&s.type===0?this.wa=this.wa.insert(n,{type:0,doc:e.doc}):e.type===1&&s.type===0?this.wa=this.wa.remove(n):e.type===1&&s.type===2?this.wa=this.wa.insert(n,{type:1,doc:s.doc}):e.type===0&&s.type===1?this.wa=this.wa.insert(n,{type:2,doc:e.doc}):Ie(63341,{At:e,Sa:s}):this.wa=this.wa.insert(n,e)}ba(){const e=[];return this.wa.inorderTraversal(((n,s)=>{e.push(s)})),e}}class Ml{constructor(e,n,s,o,l,c,f,d,m){this.query=e,this.docs=n,this.oldDocs=s,this.docChanges=o,this.mutatedKeys=l,this.fromCache=c,this.syncStateChanged=f,this.excludesMetadataChanges=d,this.hasCachedResults=m}static fromInitialDocuments(e,n,s,o,l){const c=[];return n.forEach((f=>{c.push({type:0,doc:f})})),new Ml(e,n,bl.emptySet(n),c,s,o,!0,!1,l)}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)&&Om(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const n=this.docChanges,s=e.docChanges;if(n.length!==s.length)return!1;for(let o=0;oe.Fa()))}}class i7{constructor(){this.queries=gA(),this.onlineState="Unknown",this.Ma=new Set}terminate(){(function(n,s){const o=Oe(n),l=o.queries;o.queries=gA(),l.forEach(((c,f)=>{for(const d of f.Ca)d.onError(s)}))})(this,new ge(re.ABORTED,"Firestore shutting down"))}}function gA(){return new ya((t=>xI(t)),Om)}async function sN(t,e){const n=Oe(t);let s=3;const o=e.query;let l=n.queries.get(o);l?!l.va()&&e.Fa()&&(s=2):(l=new s7,s=e.Fa()?0:1);try{switch(s){case 0:l.Da=await n.onListen(o,!0);break;case 1:l.Da=await n.onListen(o,!1);break;case 2:await n.onFirstRemoteStoreListen(o)}}catch(c){const f=w0(c,`Initialization of query '${fl(e.query)}' failed`);return void e.onError(f)}n.queries.set(o,l),l.Ca.push(e),e.xa(n.onlineState),l.Da&&e.Oa(l.Da)&&x0(n)}async function iN(t,e){const n=Oe(t),s=e.query;let o=3;const l=n.queries.get(s);if(l){const c=l.Ca.indexOf(e);c>=0&&(l.Ca.splice(c,1),l.Ca.length===0?o=e.Fa()?0:1:!l.va()&&e.Fa()&&(o=2))}switch(o){case 0:return n.queries.delete(s),n.onUnlisten(s,!0);case 1:return n.queries.delete(s),n.onUnlisten(s,!1);case 2:return n.onLastRemoteStoreUnlisten(s);default:return}}function r7(t,e){const n=Oe(t);let s=!1;for(const o of e){const l=o.query,c=n.queries.get(l);if(c){for(const f of c.Ca)f.Oa(o)&&(s=!0);c.Da=o}}s&&x0(n)}function o7(t,e,n){const s=Oe(t),o=s.queries.get(e);if(o)for(const l of o.Ca)l.onError(n);s.queries.delete(e)}function x0(t){t.Ma.forEach((e=>{e.next()}))}var $v,yA;(yA=$v||($v={})).Na="default",yA.Cache="cache";class rN{constructor(e,n,s){this.query=e,this.Ba=n,this.La=!1,this.ka=null,this.onlineState="Unknown",this.options=s||{}}Oa(e){if(!this.options.includeMetadataChanges){const s=[];for(const o of e.docChanges)o.type!==3&&s.push(o);e=new Ml(e.query,e.docs,e.oldDocs,s,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let n=!1;return this.La?this.qa(e)&&(this.Ba.next(e),n=!0):this.Ka(e,this.onlineState)&&(this.Ua(e),n=!0),this.ka=e,n}onError(e){this.Ba.error(e)}xa(e){this.onlineState=e;let n=!1;return this.ka&&!this.La&&this.Ka(this.ka,e)&&(this.Ua(this.ka),n=!0),n}Ka(e,n){if(!e.fromCache||!this.Fa())return!0;const s=n!=="Offline";return(!this.options.$a||!s)&&(!e.docs.isEmpty()||e.hasCachedResults||n==="Offline")}qa(e){if(e.docChanges.length>0)return!0;const n=this.ka&&this.ka.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!n)&&this.options.includeMetadataChanges===!0}Ua(e){e=Ml.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.La=!0,this.Ba.next(e)}Fa(){return this.options.source!==$v.Cache}}class oN{constructor(e){this.key=e}}class aN{constructor(e){this.key=e}}class a7{constructor(e,n){this.query=e,this.eu=n,this.tu=null,this.hasCachedResults=!1,this.current=!1,this.nu=Be(),this.mutatedKeys=Be(),this.ru=EI(e),this.iu=new bl(this.ru)}get su(){return this.eu}ou(e,n){const s=n?n._u:new pA,o=n?n.iu:this.iu;let l=n?n.mutatedKeys:this.mutatedKeys,c=o,f=!1;const d=this.query.limitType==="F"&&o.size===this.query.limit?o.last():null,m=this.query.limitType==="L"&&o.size===this.query.limit?o.first():null;if(e.inorderTraversal(((g,v)=>{const T=o.get(g),E=Mm(this.query,v)?v:null,R=!!T&&this.mutatedKeys.has(T.key),P=!!E&&(E.hasLocalMutations||this.mutatedKeys.has(E.key)&&E.hasCommittedMutations);let N=!1;T&&E?T.data.isEqual(E.data)?R!==P&&(s.track({type:3,doc:E}),N=!0):this.au(T,E)||(s.track({type:2,doc:E}),N=!0,(d&&this.ru(E,d)>0||m&&this.ru(E,m)<0)&&(f=!0)):!T&&E?(s.track({type:0,doc:E}),N=!0):T&&!E&&(s.track({type:1,doc:T}),N=!0,(d||m)&&(f=!0)),N&&(E?(c=c.add(E),l=P?l.add(g):l.delete(g)):(c=c.delete(g),l=l.delete(g)))})),this.query.limit!==null)for(;c.size>this.query.limit;){const g=this.query.limitType==="F"?c.last():c.first();c=c.delete(g.key),l=l.delete(g.key),s.track({type:1,doc:g})}return{iu:c,_u:s,Ss:f,mutatedKeys:l}}au(e,n){return e.hasLocalMutations&&n.hasCommittedMutations&&!n.hasLocalMutations}applyChanges(e,n,s,o){const l=this.iu;this.iu=e.iu,this.mutatedKeys=e.mutatedKeys;const c=e._u.ba();c.sort(((g,v)=>(function(E,R){const P=N=>{switch(N){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return Ie(20277,{At:N})}};return P(E)-P(R)})(g.type,v.type)||this.ru(g.doc,v.doc))),this.uu(s),o=o??!1;const f=n&&!o?this.cu():[],d=this.nu.size===0&&this.current&&!o?1:0,m=d!==this.tu;return this.tu=d,c.length!==0||m?{snapshot:new Ml(this.query,e.iu,l,c,e.mutatedKeys,d===0,m,!1,!!s&&s.resumeToken.approximateByteSize()>0),lu:f}:{lu:f}}xa(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({iu:this.iu,_u:new pA,mutatedKeys:this.mutatedKeys,Ss:!1},!1)):{lu:[]}}hu(e){return!this.eu.has(e)&&!!this.iu.has(e)&&!this.iu.get(e).hasLocalMutations}uu(e){e&&(e.addedDocuments.forEach((n=>this.eu=this.eu.add(n))),e.modifiedDocuments.forEach((n=>{})),e.removedDocuments.forEach((n=>this.eu=this.eu.delete(n))),this.current=e.current)}cu(){if(!this.current)return[];const e=this.nu;this.nu=Be(),this.iu.forEach((s=>{this.hu(s.key)&&(this.nu=this.nu.add(s.key))}));const n=[];return e.forEach((s=>{this.nu.has(s)||n.push(new aN(s))})),this.nu.forEach((s=>{e.has(s)||n.push(new oN(s))})),n}Pu(e){this.eu=e.Ls,this.nu=Be();const n=this.ou(e.documents);return this.applyChanges(n,!0)}Tu(){return Ml.fromInitialDocuments(this.query,this.iu,this.mutatedKeys,this.tu===0,this.hasCachedResults)}}const E0="SyncEngine";class l7{constructor(e,n,s){this.query=e,this.targetId=n,this.view=s}}class c7{constructor(e){this.key=e,this.Iu=!1}}class u7{constructor(e,n,s,o,l,c){this.localStore=e,this.remoteStore=n,this.eventManager=s,this.sharedClientState=o,this.currentUser=l,this.maxConcurrentLimboResolutions=c,this.Eu={},this.Ru=new ya((f=>xI(f)),Om),this.Au=new Map,this.Vu=new Set,this.du=new mt(Se.comparator),this.mu=new Map,this.fu=new d0,this.gu={},this.pu=new Map,this.yu=to._r(),this.onlineState="Unknown",this.wu=void 0}get isPrimaryClient(){return this.wu===!0}}async function f7(t,e,n=!0){const s=dN(t);let o;const l=s.Ru.get(e);return l?(s.sharedClientState.addLocalQueryTarget(l.targetId),o=l.view.Tu()):o=await lN(s,e,n,!0),o}async function h7(t,e){const n=dN(t);await lN(n,e,!0,!1)}async function lN(t,e,n,s){const o=await PF(t.localStore,si(e)),l=o.targetId,c=t.sharedClientState.addLocalQueryTarget(l,n);let f;return s&&(f=await d7(t,e,l,c==="current",o.resumeToken)),t.isPrimaryClient&&n&&XI(t.remoteStore,o),f}async function d7(t,e,n,s,o){t.Su=(v,T,E)=>(async function(P,N,L,z){let B=N.view.ou(L);B.Ss&&(B=await cA(P.localStore,N.query,!1).then((({documents:M})=>N.view.ou(M,B))));const H=z&&z.targetChanges.get(N.targetId),K=z&&z.targetMismatches.get(N.targetId)!=null,te=N.view.applyChanges(B,P.isPrimaryClient,H,K);return bA(P,N.targetId,te.lu),te.snapshot})(t,v,T,E);const l=await cA(t.localStore,e,!0),c=new a7(e,l.Ls),f=c.ou(l.documents),d=cf.createSynthesizedTargetChangeForCurrentChange(n,s&&t.onlineState!=="Offline",o),m=c.applyChanges(f,t.isPrimaryClient,d);bA(t,n,m.lu);const g=new l7(e,n,c);return t.Ru.set(e,g),t.Au.has(n)?t.Au.get(n).push(e):t.Au.set(n,[e]),m.snapshot}async function m7(t,e,n){const s=Oe(t),o=s.Ru.get(e),l=s.Au.get(o.targetId);if(l.length>1)return s.Au.set(o.targetId,l.filter((c=>!Om(c,e)))),void s.Ru.delete(e);s.isPrimaryClient?(s.sharedClientState.removeLocalQueryTarget(o.targetId),s.sharedClientState.isActiveQueryTarget(o.targetId)||await qv(s.localStore,o.targetId,!1).then((()=>{s.sharedClientState.clearQueryState(o.targetId),n&&y0(s.remoteStore,o.targetId),Kv(s,o.targetId)})).catch(Hl)):(Kv(s,o.targetId),await qv(s.localStore,o.targetId,!0))}async function p7(t,e){const n=Oe(t),s=n.Ru.get(e),o=n.Au.get(s.targetId);n.isPrimaryClient&&o.length===1&&(n.sharedClientState.removeLocalQueryTarget(s.targetId),y0(n.remoteStore,s.targetId))}async function g7(t,e,n){const s=x7(t);try{const o=await(function(c,f){const d=Oe(c),m=ft.now(),g=f.reduce(((E,R)=>E.add(R.key)),Be());let v,T;return d.persistence.runTransaction("Locally write mutations","readwrite",(E=>{let R=qi(),P=Be();return d.Ms.getEntries(E,g).next((N=>{R=N,R.forEach(((L,z)=>{z.isValidDocument()||(P=P.add(L))}))})).next((()=>d.localDocuments.getOverlayedDocuments(E,R))).next((N=>{v=N;const L=[];for(const z of f){const B=NB(z,v.get(z.key).overlayedDocument);B!=null&&L.push(new lo(z.key,B,pI(B.value.mapValue),us.exists(!0)))}return d.mutationQueue.addMutationBatch(E,m,L,f)})).next((N=>{T=N;const L=N.applyToLocalDocumentSet(v,P);return d.documentOverlayCache.saveOverlays(E,N.batchId,L)}))})).then((()=>({batchId:T.batchId,changes:AI(v)})))})(s.localStore,e);s.sharedClientState.addPendingMutation(o.batchId),(function(c,f,d){let m=c.gu[c.currentUser.toKey()];m||(m=new mt(ze)),m=m.insert(f,d),c.gu[c.currentUser.toKey()]=m})(s,o.batchId,n),await ff(s,o.changes),await zm(s.remoteStore)}catch(o){const l=w0(o,"Failed to persist write");n.reject(l)}}async function cN(t,e){const n=Oe(t);try{const s=await CF(n.localStore,e);e.targetChanges.forEach(((o,l)=>{const c=n.mu.get(l);c&&(We(o.addedDocuments.size+o.modifiedDocuments.size+o.removedDocuments.size<=1,22616),o.addedDocuments.size>0?c.Iu=!0:o.modifiedDocuments.size>0?We(c.Iu,14607):o.removedDocuments.size>0&&(We(c.Iu,42227),c.Iu=!1))})),await ff(n,s,e)}catch(s){await Hl(s)}}function vA(t,e,n){const s=Oe(t);if(s.isPrimaryClient&&n===0||!s.isPrimaryClient&&n===1){const o=[];s.Ru.forEach(((l,c)=>{const f=c.view.xa(e);f.snapshot&&o.push(f.snapshot)})),(function(c,f){const d=Oe(c);d.onlineState=f;let m=!1;d.queries.forEach(((g,v)=>{for(const T of v.Ca)T.xa(f)&&(m=!0)})),m&&x0(d)})(s.eventManager,e),o.length&&s.Eu.J_(o),s.onlineState=e,s.isPrimaryClient&&s.sharedClientState.setOnlineState(e)}}async function y7(t,e,n){const s=Oe(t);s.sharedClientState.updateQueryState(e,"rejected",n);const o=s.mu.get(e),l=o&&o.key;if(l){let c=new mt(Se.comparator);c=c.insert(l,dn.newNoDocument(l,Pe.min()));const f=Be().add(l),d=new lf(Pe.min(),new Map,new mt(ze),c,f);await cN(s,d),s.du=s.du.remove(l),s.mu.delete(e),S0(s)}else await qv(s.localStore,e,!1).then((()=>Kv(s,e,n))).catch(Hl)}async function v7(t,e){const n=Oe(t),s=e.batch.batchId;try{const o=await RF(n.localStore,e);fN(n,s,null),uN(n,s),n.sharedClientState.updateMutationState(s,"acknowledged"),await ff(n,o)}catch(o){await Hl(o)}}async function b7(t,e,n){const s=Oe(t);try{const o=await(function(c,f){const d=Oe(c);return d.persistence.runTransaction("Reject batch","readwrite-primary",(m=>{let g;return d.mutationQueue.lookupMutationBatch(m,f).next((v=>(We(v!==null,37113),g=v.keys(),d.mutationQueue.removeMutationBatch(m,v)))).next((()=>d.mutationQueue.performConsistencyCheck(m))).next((()=>d.documentOverlayCache.removeOverlaysForBatchId(m,g,f))).next((()=>d.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(m,g))).next((()=>d.localDocuments.getDocuments(m,g)))}))})(s.localStore,e);fN(s,e,n),uN(s,e),s.sharedClientState.updateMutationState(e,"rejected",n),await ff(s,o)}catch(o){await Hl(o)}}function uN(t,e){(t.pu.get(e)||[]).forEach((n=>{n.resolve()})),t.pu.delete(e)}function fN(t,e,n){const s=Oe(t);let o=s.gu[s.currentUser.toKey()];if(o){const l=o.get(e);l&&(n?l.reject(n):l.resolve(),o=o.remove(e)),s.gu[s.currentUser.toKey()]=o}}function Kv(t,e,n=null){t.sharedClientState.removeLocalQueryTarget(e);for(const s of t.Au.get(e))t.Ru.delete(s),n&&t.Eu.bu(s,n);t.Au.delete(e),t.isPrimaryClient&&t.fu.Qr(e).forEach((s=>{t.fu.containsKey(s)||hN(t,s)}))}function hN(t,e){t.Vu.delete(e.path.canonicalString());const n=t.du.get(e);n!==null&&(y0(t.remoteStore,n),t.du=t.du.remove(e),t.mu.delete(n),S0(t))}function bA(t,e,n){for(const s of n)s instanceof oN?(t.fu.addReference(s.key,e),_7(t,s)):s instanceof aN?(me(E0,"Document no longer in limbo: "+s.key),t.fu.removeReference(s.key,e),t.fu.containsKey(s.key)||hN(t,s.key)):Ie(19791,{Du:s})}function _7(t,e){const n=e.key,s=n.path.canonicalString();t.du.get(n)||t.Vu.has(s)||(me(E0,"New document in limbo: "+n),t.Vu.add(s),S0(t))}function S0(t){for(;t.Vu.size>0&&t.du.size{c.push(s.Su(d,e,n).then((m=>{if((m||n)&&s.isPrimaryClient){const g=m?!m.fromCache:n?.targetChanges.get(d.targetId)?.current;s.sharedClientState.updateQueryState(d.targetId,g?"current":"not-current")}if(m){o.push(m);const g=p0.Is(d.targetId,m);l.push(g)}})))})),await Promise.all(c),s.Eu.J_(o),await(async function(d,m){const g=Oe(d);try{await g.persistence.runTransaction("notifyLocalViewChanges","readwrite",(v=>ae.forEach(m,(T=>ae.forEach(T.Ps,(E=>g.persistence.referenceDelegate.addReference(v,T.targetId,E))).next((()=>ae.forEach(T.Ts,(E=>g.persistence.referenceDelegate.removeReference(v,T.targetId,E)))))))))}catch(v){if(!Gl(v))throw v;me(g0,"Failed to update sequence numbers: "+v)}for(const v of m){const T=v.targetId;if(!v.fromCache){const E=g.Cs.get(T),R=E.snapshotVersion,P=E.withLastLimboFreeSnapshotVersion(R);g.Cs=g.Cs.insert(T,P)}}})(s.localStore,l))}async function T7(t,e){const n=Oe(t);if(!n.currentUser.isEqual(e)){me(E0,"User change. New user:",e.toKey());const s=await KI(n.localStore,e);n.currentUser=e,(function(l,c){l.pu.forEach((f=>{f.forEach((d=>{d.reject(new ge(re.CANCELLED,c))}))})),l.pu.clear()})(n,"'waitForPendingWrites' promise is rejected due to a user change."),n.sharedClientState.handleUserChange(e,s.removedBatchIds,s.addedBatchIds),await ff(n,s.Os)}}function w7(t,e){const n=Oe(t),s=n.mu.get(e);if(s&&s.Iu)return Be().add(s.key);{let o=Be();const l=n.Au.get(e);if(!l)return o;for(const c of l){const f=n.Ru.get(c);o=o.unionWith(f.view.su)}return o}}function dN(t){const e=Oe(t);return e.remoteStore.remoteSyncer.applyRemoteEvent=cN.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=w7.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=y7.bind(null,e),e.Eu.J_=r7.bind(null,e.eventManager),e.Eu.bu=o7.bind(null,e.eventManager),e}function x7(t){const e=Oe(t);return e.remoteStore.remoteSyncer.applySuccessfulWrite=v7.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=b7.bind(null,e),e}class Zd{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Lm(e.databaseInfo.databaseId),this.sharedClientState=this.Fu(e),this.persistence=this.Mu(e),await this.persistence.start(),this.localStore=this.xu(e),this.gcScheduler=this.Ou(e,this.localStore),this.indexBackfillerScheduler=this.Nu(e,this.localStore)}Ou(e,n){return null}Nu(e,n){return null}xu(e){return AF(this.persistence,new xF,e.initialUser,this.serializer)}Mu(e){return new $I(m0.Ai,this.serializer)}Fu(e){return new OF}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}Zd.provider={build:()=>new Zd};class E7 extends Zd{constructor(e){super(),this.cacheSizeBytes=e}Ou(e,n){We(this.persistence.referenceDelegate instanceof Wd,46915);const s=this.persistence.referenceDelegate.garbageCollector;return new lF(s,e.asyncQueue,n)}Mu(e){const n=this.cacheSizeBytes!==void 0?In.withCacheSize(this.cacheSizeBytes):In.DEFAULT;return new $I((s=>Wd.Ai(s,n)),this.serializer)}}class Qv{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=s=>vA(this.syncEngine,s,1),this.remoteStore.remoteSyncer.handleCredentialChange=T7.bind(null,this.syncEngine),await n7(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return(function(){return new i7})()}createDatastore(e){const n=Lm(e.databaseInfo.databaseId),s=LF(e.databaseInfo);return qF(e.authCredentials,e.appCheckCredentials,s,n)}createRemoteStore(e){return(function(s,o,l,c,f){return new GF(s,o,l,c,f)})(this.localStore,this.datastore,e.asyncQueue,(n=>vA(this.syncEngine,n,0)),(function(){return hA.v()?new hA:new MF})())}createSyncEngine(e,n){return(function(o,l,c,f,d,m,g){const v=new u7(o,l,c,f,d,m);return g&&(v.wu=!0),v})(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,n)}async terminate(){await(async function(n){const s=Oe(n);me(ci,"RemoteStore shutting down."),s.Va.add(5),await uf(s),s.ma.shutdown(),s.fa.set("Unknown")})(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}Qv.provider={build:()=>new Qv};class mN{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Lu(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Lu(this.observer.error,e):Fi("Uncaught Error in snapshot listener:",e.toString()))}ku(){this.muted=!0}Lu(e,n){setTimeout((()=>{this.muted||e(n)}),0)}}const so="FirestoreClient";class S7{constructor(e,n,s,o,l){this.authCredentials=e,this.appCheckCredentials=n,this.asyncQueue=s,this._databaseInfo=o,this.user=hn.UNAUTHENTICATED,this.clientId=e0.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=l,this.authCredentials.start(s,(async c=>{me(so,"Received user=",c.uid),await this.authCredentialListener(c),this.user=c})),this.appCheckCredentials.start(s,(c=>(me(so,"Received new app check token=",c),this.appCheckCredentialListener(c,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 ji;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 s=w0(n,"Failed to shutdown persistence");e.reject(s)}})),e.promise}}async function jy(t,e){t.asyncQueue.verifyOperationInProgress(),me(so,"Initializing OfflineComponentProvider");const n=t.configuration;await e.initialize(n);let s=n.initialUser;t.setCredentialChangeListener((async o=>{s.isEqual(o)||(await KI(e.localStore,o),s=o)})),e.persistence.setDatabaseDeletedListener((()=>t.terminate())),t._offlineComponents=e}async function _A(t,e){t.asyncQueue.verifyOperationInProgress();const n=await A7(t);me(so,"Initializing OnlineComponentProvider"),await e.initialize(n,t.configuration),t.setCredentialChangeListener((s=>mA(e.remoteStore,s))),t.setAppCheckTokenChangeListener(((s,o)=>mA(e.remoteStore,o))),t._onlineComponents=e}async function A7(t){if(!t._offlineComponents)if(t._uninitializedComponentsProvider){me(so,"Using user provided OfflineComponentProvider");try{await jy(t,t._uninitializedComponentsProvider._offline)}catch(e){const n=e;if(!(function(o){return o.name==="FirebaseError"?o.code===re.FAILED_PRECONDITION||o.code===re.UNIMPLEMENTED:!(typeof DOMException<"u"&&o instanceof DOMException)||o.code===22||o.code===20||o.code===11})(n))throw n;ha("Error using user provided cache. Falling back to memory cache: "+n),await jy(t,new Zd)}}else me(so,"Using default OfflineComponentProvider"),await jy(t,new E7(void 0));return t._offlineComponents}async function pN(t){return t._onlineComponents||(t._uninitializedComponentsProvider?(me(so,"Using user provided OnlineComponentProvider"),await _A(t,t._uninitializedComponentsProvider._online)):(me(so,"Using default OnlineComponentProvider"),await _A(t,new Qv))),t._onlineComponents}function R7(t){return pN(t).then((e=>e.syncEngine))}async function gN(t){const e=await pN(t),n=e.eventManager;return n.onListen=f7.bind(null,e.syncEngine),n.onUnlisten=m7.bind(null,e.syncEngine),n.onFirstRemoteStoreListen=h7.bind(null,e.syncEngine),n.onLastRemoteStoreUnlisten=p7.bind(null,e.syncEngine),n}function C7(t,e,n={}){const s=new ji;return t.asyncQueue.enqueueAndForget((async()=>(function(l,c,f,d,m){const g=new mN({next:T=>{g.ku(),c.enqueueAndForget((()=>iN(l,v)));const E=T.docs.has(f);!E&&T.fromCache?m.reject(new ge(re.UNAVAILABLE,"Failed to get document because the client is offline.")):E&&T.fromCache&&d&&d.source==="server"?m.reject(new ge(re.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.)')):m.resolve(T)},error:T=>m.reject(T)}),v=new rN(o0(f.path),g,{includeMetadataChanges:!0,$a:!0});return sN(l,v)})(await gN(t),t.asyncQueue,e,n,s))),s.promise}function I7(t,e,n={}){const s=new ji;return t.asyncQueue.enqueueAndForget((async()=>(function(l,c,f,d,m){const g=new mN({next:T=>{g.ku(),c.enqueueAndForget((()=>iN(l,v))),T.fromCache&&d.source==="server"?m.reject(new ge(re.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.)')):m.resolve(T)},error:T=>m.reject(T)}),v=new rN(f,g,{includeMetadataChanges:!0,$a:!0});return sN(l,v)})(await gN(t),t.asyncQueue,e,n,s))),s.promise}function N7(t,e){const n=new ji;return t.asyncQueue.enqueueAndForget((async()=>g7(await R7(t),e,n))),n.promise}function yN(t){const e={};return t.timeoutSeconds!==void 0&&(e.timeoutSeconds=t.timeoutSeconds),e}const P7="ComponentProvider",TA=new Map;function D7(t,e,n,s,o){return new Xz(t,e,n,o.host,o.ssl,o.experimentalForceLongPolling,o.experimentalAutoDetectLongPolling,yN(o.experimentalLongPollingOptions),o.useFetchStreams,o.isUsingEmulator,s)}const vN="firestore.googleapis.com",wA=!0;class xA{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new ge(re.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=vN,this.ssl=wA}else this.host=e.host,this.ssl=e.ssl??wA;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=GI;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes30)throw new ge(re.INVALID_ARGUMENT,`invalid long polling timeout: ${s.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(s,o){return s.timeoutSeconds===o.timeoutSeconds})(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class Bm{constructor(e,n,s,o){this._authCredentials=e,this._appCheckCredentials=n,this._databaseId=s,this._app=o,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new xA({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new ge(re.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 ge(re.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 xA(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=(function(s){if(!s)return new Nz;switch(s.type){case"firstParty":return new Mz(s.sessionIndex||"0",s.iamToken||null,s.authTokenFactory||null);case"provider":return s.client;default:throw new ge(re.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}})(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_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 s=TA.get(n);s&&(me(P7,"Removing Datastore"),TA.delete(n),s.terminate())})(this),Promise.resolve()}}function O7(t,e,n,s={}){t=Ms(t,Bm);const o=rf(e),l=t._getSettings(),c={...l,emulatorOptions:t._getEmulatorOptions()},f=`${e}:${n}`;o&&F2(`https://${f}`),l.host!==vN&&l.host!==f&&ha("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const d={...l,host:f,ssl:o,emulatorOptions:s};if(!ca(d,c)&&(t._setSettings(d),s.mockUserToken)){let m,g;if(typeof s.mockUserToken=="string")m=s.mockUserToken,g=hn.MOCK_USER;else{m=i5(s.mockUserToken,t._app?.options.projectId);const v=s.mockUserToken.sub||s.mockUserToken.user_id;if(!v)throw new ge(re.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");g=new hn(v)}t._authCredentials=new Pz(new nI(m,g))}}class ba{constructor(e,n,s){this.converter=n,this._query=s,this.type="query",this.firestore=e}withConverter(e){return new ba(this.firestore,e,this._query)}}class Rt{constructor(e,n,s){this.converter=n,this._key=s,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 Hr(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new Rt(this.firestore,e,this._key)}toJSON(){return{type:Rt._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,n,s){if(of(n,Rt._jsonSchema))return new Rt(e,s||null,new Se(ct.fromString(n.referencePath)))}}Rt._jsonSchemaVersion="firestore/documentReference/1.0",Rt._jsonSchema={type:Mt("string",Rt._jsonSchemaVersion),referencePath:Mt("string")};class Hr extends ba{constructor(e,n,s){super(e,n,o0(s)),this._path=s,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 Rt(this.firestore,null,new Se(e))}withConverter(e){return new Hr(this.firestore,e,this._path)}}function ea(t,e,...n){if(t=Ft(t),sI("collection","path",e),t instanceof Bm){const s=ct.fromString(e,...n);return VS(s),new Hr(t,null,s)}{if(!(t instanceof Rt||t instanceof Hr))throw new ge(re.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const s=t._path.child(ct.fromString(e,...n));return VS(s),new Hr(t.firestore,null,s)}}function _l(t,e,...n){if(t=Ft(t),arguments.length===1&&(e=e0.newId()),sI("doc","path",e),t instanceof Bm){const s=ct.fromString(e,...n);return kS(s),new Rt(t,null,new Se(s))}{if(!(t instanceof Rt||t instanceof Hr))throw new ge(re.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const s=t._path.child(ct.fromString(e,...n));return kS(s),new Rt(t.firestore,t instanceof Hr?t.converter:null,new Se(s))}}const EA="AsyncQueue";class SA{constructor(e=Promise.resolve()){this.nc=[],this.rc=!1,this.sc=[],this.oc=null,this._c=!1,this.ac=!1,this.uc=[],this.F_=new YI(this,"async_queue_retry"),this.cc=()=>{const s=Vy();s&&me(EA,"Visibility state changed to "+s.visibilityState),this.F_.y_()},this.lc=e;const n=Vy();n&&typeof n.addEventListener=="function"&&n.addEventListener("visibilitychange",this.cc)}get isShuttingDown(){return this.rc}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.hc(),this.Pc(e)}enterRestrictedMode(e){if(!this.rc){this.rc=!0,this.ac=e||!1;const n=Vy();n&&typeof n.removeEventListener=="function"&&n.removeEventListener("visibilitychange",this.cc)}}enqueue(e){if(this.hc(),this.rc)return new Promise((()=>{}));const n=new ji;return this.Pc((()=>this.rc&&this.ac?Promise.resolve():(e().then(n.resolve,n.reject),n.promise))).then((()=>n.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.nc.push(e),this.Tc())))}async Tc(){if(this.nc.length!==0){try{await this.nc[0](),this.nc.shift(),this.F_.reset()}catch(e){if(!Gl(e))throw e;me(EA,"Operation failed with retryable error: "+e)}this.nc.length>0&&this.F_.g_((()=>this.Tc()))}}Pc(e){const n=this.lc.then((()=>(this._c=!0,e().catch((s=>{throw this.oc=s,this._c=!1,Fi("INTERNAL UNHANDLED ERROR: ",AA(s)),s})).then((s=>(this._c=!1,s))))));return this.lc=n,n}enqueueAfterDelay(e,n,s){this.hc(),this.uc.indexOf(e)>-1&&(n=0);const o=T0.createAndSchedule(this,e,n,s,(l=>this.Ic(l)));return this.sc.push(o),o}hc(){this.oc&&Ie(47125,{Ec:AA(this.oc)})}verifyOperationInProgress(){}async Rc(){let e;do e=this.lc,await e;while(e!==this.lc)}Ac(e){for(const n of this.sc)if(n.timerId===e)return!0;return!1}Vc(e){return this.Rc().then((()=>{this.sc.sort(((n,s)=>n.targetTimeMs-s.targetTimeMs));for(const n of this.sc)if(n.skipDelay(),e!=="all"&&n.timerId===e)break;return this.Rc()}))}dc(e){this.uc.push(e)}Ic(e){const n=this.sc.indexOf(e);this.sc.splice(n,1)}}function AA(t){let e=t.message||"";return t.stack&&(e=t.stack.includes(t.message)?t.stack:t.message+` `+t.stack),e}class _a extends Bm{constructor(e,n,s,o){super(e,n,s,o),this.type="firestore",this._queue=new SA,this._persistenceKey=o?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new SA(e),this._firestoreClient=void 0,await e}}}function M7(t,e){const n=typeof t=="object"?t:$2(),s=typeof t=="string"?t:qd,o=Zb(n,"firestore").getImmediate({identifier:s});if(!o._initialized){const l=n5("firestore");l&&O7(o,...l)}return o}function A0(t){if(t._terminated)throw new ge(re.FAILED_PRECONDITION,"The client has already been terminated.");return t._firestoreClient||k7(t),t._firestoreClient}function k7(t){const e=t._freezeSettings(),n=D7(t._databaseId,t._app?.options.appId||"",t._persistenceKey,t._app?.options.apiKey,e);t._componentsProvider||e.localCache?._offlineComponentProvider&&e.localCache?._onlineComponentProvider&&(t._componentsProvider={_offline:e.localCache._offlineComponentProvider,_online:e.localCache._onlineComponentProvider}),t._firestoreClient=new S7(t._authCredentials,t._appCheckCredentials,t._queue,n,t._componentsProvider&&(function(o){const l=o?._online.build();return{_offline:o?._offline.build(l),_online:l}})(t._componentsProvider))}class as{constructor(e){this._byteString=e}static fromBase64String(e){try{return new as(rn.fromBase64String(e))}catch(n){throw new ge(re.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+n)}}static fromUint8Array(e){return new as(rn.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:as._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(of(e,as._jsonSchema))return as.fromBase64String(e.bytes)}}as._jsonSchemaVersion="firestore/bytes/1.0",as._jsonSchema={type:Mt("string",as._jsonSchemaVersion),bytes:Mt("string")};class R0{constructor(...e){for(let n=0;n90)throw new ge(re.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(n)||n<-180||n>180)throw new ge(re.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}_compareTo(e){return ze(this._lat,e._lat)||ze(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:ri._jsonSchemaVersion}}static fromJSON(e){if(of(e,ri._jsonSchema))return new ri(e.latitude,e.longitude)}}ri._jsonSchemaVersion="firestore/geoPoint/1.0",ri._jsonSchema={type:Mt("string",ri._jsonSchemaVersion),latitude:Mt("number"),longitude:Mt("number")};class Is{constructor(e){this._values=(e||[]).map((n=>n))}toArray(){return this._values.map((e=>e))}isEqual(e){return(function(s,o){if(s.length!==o.length)return!1;for(let l=0;ltypeof n=="number")))return new Is(e.vectorValues);throw new ge(re.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}Is._jsonSchemaVersion="firestore/vectorValue/1.0",Is._jsonSchema={type:Mt("string",Is._jsonSchemaVersion),vectorValues:Mt("object")};const V7=/^__.*__$/;class j7{constructor(e,n,s){this.data=e,this.fieldMask=n,this.fieldTransforms=s}toMutation(e,n){return this.fieldMask!==null?new lo(e,this.data,this.fieldMask,n,this.fieldTransforms):new af(e,this.data,n,this.fieldTransforms)}}class bN{constructor(e,n,s){this.data=e,this.fieldMask=n,this.fieldTransforms=s}toMutation(e,n){return new lo(e,this.data,this.fieldMask,n,this.fieldTransforms)}}function _N(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw Ie(40011,{dataSource:t})}}class C0{constructor(e,n,s,o,l,c){this.settings=e,this.databaseId=n,this.serializer=s,this.ignoreUndefinedProperties=o,l===void 0&&this.mc(),this.fieldTransforms=l||[],this.fieldMask=c||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}i(e){return new C0({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}gc(e){const n=this.path?.child(e),s=this.i({path:n,arrayElement:!1});return s.yc(e),s}wc(e){const n=this.path?.child(e),s=this.i({path:n,arrayElement:!1});return s.mc(),s}Sc(e){return this.i({path:void 0,arrayElement:!0})}bc(e){return Jd(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return this.fieldMask.find((n=>e.isPrefixOf(n)))!==void 0||this.fieldTransforms.find((n=>e.isPrefixOf(n.field)))!==void 0}mc(){if(this.path)for(let e=0;ed.covers(v.field)))}else d=null,m=c.fieldTransforms;return new j7(new Nn(f),d,m)}class Hm extends Fm{_toFieldTransform(e){if(e.dataSource!==2)throw e.dataSource===1?e.bc(`${this._methodName}() can only appear at the top level of your update data`):e.bc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof Hm}}class I0 extends Fm{_toFieldTransform(e){return new AB(e.path,new Fu)}isEqual(e){return e instanceof I0}}function U7(t,e,n,s){const o=t.V(1,e,n);N0("Data must be an object, but it was:",o,s);const l=[],c=Nn.empty();ao(s,((d,m)=>{const g=EN(e,d,n);m=Ft(m);const v=o.wc(g);if(m instanceof Hm)l.push(g);else{const T=hf(m,v);T!=null&&(l.push(g),c.set(g,T))}}));const f=new qn(l);return new bN(c,f,o.fieldTransforms)}function z7(t,e,n,s,o,l){const c=t.V(1,e,n),f=[da(e,s,n)],d=[o];if(l.length%2!=0)throw new ge(re.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let T=0;T=0;--T)if(!SN(m,f[T])){const E=f[T];let R=d[T];R=Ft(R);const P=c.wc(E);if(R instanceof Hm)m.push(E);else{const N=hf(R,P);N!=null&&(m.push(E),g.set(E,N))}}const v=new qn(m);return new bN(g,v,c.fieldTransforms)}function B7(t,e,n,s=!1){return hf(n,t.V(s?4:3,e))}function hf(t,e){if(xN(t=Ft(t)))return N0("Unsupported field value:",e,t),wN(t,e);if(t instanceof Fm)return(function(s,o){if(!_N(o.dataSource))throw o.bc(`${s._methodName}() can only be used with update() and set()`);if(!o.path)throw o.bc(`${s._methodName}() is not currently supported inside arrays`);const l=s._toFieldTransform(o);l&&o.fieldTransforms.push(l)})(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.arrayElement&&e.dataSource!==4)throw e.bc("Nested arrays are not supported");return(function(s,o){const l=[];let c=0;for(const f of s){let d=hf(f,o.Sc(c));d==null&&(d={nullValue:"NULL_VALUE"}),l.push(d),c++}return{arrayValue:{values:l}}})(t,e)}return(function(s,o){if((s=Ft(s))===null)return{nullValue:"NULL_VALUE"};if(typeof s=="number")return xB(o.serializer,s);if(typeof s=="boolean")return{booleanValue:s};if(typeof s=="string")return{stringValue:s};if(s instanceof Date){const l=ft.fromDate(s);return{timestampValue:Yd(o.serializer,l)}}if(s instanceof ft){const l=new ft(s.seconds,1e3*Math.floor(s.nanoseconds/1e3));return{timestampValue:Yd(o.serializer,l)}}if(s instanceof ri)return{geoPointValue:{latitude:s.latitude,longitude:s.longitude}};if(s instanceof as)return{bytesValue:jI(o.serializer,s._byteString)};if(s instanceof Rt){const l=o.databaseId,c=s.firestore._databaseId;if(!c.isEqual(l))throw o.bc(`Document reference is for database ${c.projectId}/${c.database} but should be for database ${l.projectId}/${l.database}`);return{referenceValue:h0(s.firestore._databaseId||o.databaseId,s._key.path)}}if(s instanceof Is)return(function(c,f){const d=c instanceof Is?c.toArray():c;return{mapValue:{fields:{[hI]:{stringValue:dI},[Hd]:{arrayValue:{values:d.map((g=>{if(typeof g!="number")throw f.bc("VectorValues must only contain numeric values.");return km(f.serializer,g)}))}}}}}})(s,o);if(HI(s))return s._toProto(o.serializer);throw o.bc(`Unsupported field value: ${Im(s)}`)})(t,e)}function wN(t,e){const n={};return oI(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):ao(t,((s,o)=>{const l=hf(o,e.gc(s));l!=null&&(n[s]=l)})),{mapValue:{fields:n}}}function xN(t){return!(typeof t!="object"||t===null||t instanceof Array||t instanceof Date||t instanceof ft||t instanceof ri||t instanceof as||t instanceof Rt||t instanceof Fm||t instanceof Is||HI(t))}function N0(t,e,n){if(!xN(n)||!iI(n)){const s=Im(n);throw s==="an object"?e.bc(t+" a custom object"):e.bc(t+" "+s)}}function da(t,e,n){if((e=Ft(e))instanceof R0)return e._internalPath;if(typeof e=="string")return EN(t,e);throw Jd("Field path arguments must be of type string or ",t,!1,void 0,n)}const F7=new RegExp("[~\\*/\\[\\]]");function EN(t,e,n){if(e.search(F7)>=0)throw Jd(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,n);try{return new R0(...e.split("."))._internalPath}catch{throw Jd(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,n)}}function Jd(t,e,n,s,o){const l=s&&!s.isEmpty(),c=o!==void 0;let f=`Function ${e}() called with invalid data`;n&&(f+=" (via `toFirestore()`)"),f+=". ";let d="";return(l||c)&&(d+=" (found",l&&(d+=` in field ${s}`),c&&(d+=` in document ${o}`),d+=")"),new ge(re.INVALID_ARGUMENT,f+t+d)}function SN(t,e){return t.some((n=>n.isEqual(e)))}class q7{convertValue(e,n="none"){switch(eo(e)){case 0:return null;case 1:return e.booleanValue;case 2:return At(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(Jr(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 Ie(62114,{value:e})}}convertObject(e,n){return this.convertObjectMap(e.fields,n)}convertObjectMap(e,n="none"){const s={};return ao(e,((o,l)=>{s[o]=this.convertValue(l,n)})),s}convertVectorValue(e){const n=e.fields?.[Hd].arrayValue?.values?.map((s=>At(s.doubleValue)));return new Is(n)}convertGeoPoint(e){return new ri(At(e.latitude),At(e.longitude))}convertArray(e,n){return(e.values||[]).map((s=>this.convertValue(s,n)))}convertServerTimestamp(e,n){switch(n){case"previous":const s=Dm(e);return s==null?null:this.convertValue(s,n);case"estimate":return this.convertTimestamp(ju(e));default:return null}}convertTimestamp(e){const n=Zr(e);return new ft(n.seconds,n.nanos)}convertDocumentKey(e,n){const s=ct.fromString(e);We(qI(s),9688,{name:e});const o=new Lu(s.get(1),s.get(3)),l=new Se(s.popFirst(5));return o.isEqual(n)||Fi(`Document ${l} contains a document reference within a different database (${o.projectId}/${o.database}) which is not supported. It will be treated as a reference in the current database (${n.projectId}/${n.database}) instead.`),l}}class AN extends q7{constructor(e){super(),this.firestore=e}convertBytes(e){return new as(e)}convertReference(e){const n=this.convertDocumentKey(e,this.firestore._databaseId);return new Rt(this.firestore,null,n)}}function Yv(){return new I0("serverTimestamp")}const RA="@firebase/firestore",CA="4.15.0";class RN{constructor(e,n,s,o,l){this._firestore=e,this._userDataWriter=n,this._key=s,this._document=o,this._converter=l}get id(){return this._key.path.lastSegment()}get ref(){return new Rt(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new H7(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){const n=this._document.data.field(da("DocumentSnapshot.get",e));if(n!==null)return this._userDataWriter.convertValue(n)}}}class H7 extends RN{data(){return super.data()}}function G7(t){if(t.limitType==="L"&&t.explicitOrderBy.length===0)throw new ge(re.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class P0{}class CN extends P0{}function D0(t,e,...n){let s=[];e instanceof P0&&s.push(e),s=s.concat(n),(function(l){const c=l.filter((d=>d instanceof O0)).length,f=l.filter((d=>d instanceof Gm)).length;if(c>1||c>0&&f>0)throw new ge(re.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(...)))`.")})(s);for(const o of s)t=o._apply(t);return t}class Gm extends CN{constructor(e,n,s){super(),this._field=e,this._op=n,this._value=s,this.type="where"}static _create(e,n,s){return new Gm(e,n,s)}_apply(e){const n=this._parse(e);return NN(e._query,n),new ba(e.firestore,e.converter,jv(e._query,n))}_parse(e){const n=qm(e.firestore);return(function(l,c,f,d,m,g,v){let T;if(m.isKeyField()){if(g==="array-contains"||g==="array-contains-any")throw new ge(re.INVALID_ARGUMENT,`Invalid Query. You can't perform '${g}' queries on documentId().`);if(g==="in"||g==="not-in"){PA(v,g);const R=[];for(const P of v)R.push(NA(d,l,P));T={arrayValue:{values:R}}}else T=NA(d,l,v)}else g!=="in"&&g!=="not-in"&&g!=="array-contains-any"||PA(v,g),T=B7(f,c,v,g==="in"||g==="not-in");return Ot.create(m,g,T)})(e._query,"where",n,e.firestore._databaseId,this._field,this._op,this._value)}}function IA(t,e,n){const s=e,o=da("where",t);return Gm._create(o,s,n)}class O0 extends P0{constructor(e,n){super(),this.type=e,this._queryConstraints=n}static _create(e,n){return new O0(e,n)}_parse(e){const n=this._queryConstraints.map((s=>s._parse(e))).filter((s=>s.getFilters().length>0));return n.length===1?n[0]:ks.create(n,this._getOperator())}_apply(e){const n=this._parse(e);return n.getFilters().length===0?e:((function(o,l){let c=o;const f=l.getFlattenedFilters();for(const d of f)NN(c,d),c=jv(c,d)})(e._query,n),new ba(e.firestore,e.converter,jv(e._query,n)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class M0 extends CN{constructor(e,n){super(),this._field=e,this._direction=n,this.type="orderBy"}static _create(e,n){return new M0(e,n)}_apply(e){const n=(function(o,l,c){if(o.startAt!==null)throw new ge(re.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(o.endAt!==null)throw new ge(re.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new Bu(l,c)})(e._query,this._field,this._direction);return new ba(e.firestore,e.converter,pB(e._query,n))}}function IN(t,e="asc"){const n=e,s=da("orderBy",t);return M0._create(s,n)}function NA(t,e,n){if(typeof(n=Ft(n))=="string"){if(n==="")throw new ge(re.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!wI(e)&&n.indexOf("/")!==-1)throw new ge(re.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const s=e.path.child(ct.fromString(n));if(!Se.isDocumentKey(s))throw new ge(re.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${s}' is not because it has an odd number of segments (${s.length}).`);return HS(t,new Se(s))}if(n instanceof Rt)return HS(t,n._key);throw new ge(re.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Im(n)}.`)}function PA(t,e){if(!Array.isArray(t)||t.length===0)throw new ge(re.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function NN(t,e){const n=(function(o,l){for(const c of o)for(const f of c.getFlattenedFilters())if(l.indexOf(f.op)>=0)return f.op;return null})(t.filters,(function(o){switch(o){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 ge(re.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new ge(re.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`)}function PN(t,e,n){let s;return s=t?t.toFirestore(e):e,s}class du{constructor(e,n){this.hasPendingWrites=e,this.fromCache=n}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class aa extends RN{constructor(e,n,s,o,l,c){super(e,n,s,o,c),this._firestore=e,this._firestoreImpl=e,this.metadata=l}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const n=new vd(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 s=this._document.data.field(da("DocumentSnapshot.get",e));if(s!==null)return this._userDataWriter.convertValue(s,n.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new ge(re.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,n={};return n.type=aa._jsonSchemaVersion,n.bundle="",n.bundleSource="DocumentSnapshot",n.bundleName=this._key.toString(),!e||!e.isValidDocument()||!e.isFoundDocument()?n:(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),n.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),n)}}aa._jsonSchemaVersion="firestore/documentSnapshot/1.0",aa._jsonSchema={type:Mt("string",aa._jsonSchemaVersion),bundleSource:Mt("string","DocumentSnapshot"),bundleName:Mt("string"),bundle:Mt("string")};class vd extends aa{data(e={}){return super.data(e)}}class Tl{constructor(e,n,s,o){this._firestore=e,this._userDataWriter=n,this._snapshot=o,this.metadata=new du(o.hasPendingWrites,o.fromCache),this.query=s}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((s=>{e.call(n,new vd(this._firestore,this._userDataWriter,s.key,s,new du(this._snapshot.mutatedKeys.has(s.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const n=!!e.includeMetadataChanges;if(n&&this._snapshot.excludesMetadataChanges)throw new ge(re.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(o,l){if(o._snapshot.oldDocs.isEmpty()){let c=0;return o._snapshot.docChanges.map((f=>{const d=new vd(o._firestore,o._userDataWriter,f.doc.key,f.doc,new du(o._snapshot.mutatedKeys.has(f.doc.key),o._snapshot.fromCache),o.query.converter);return f.doc,{type:"added",doc:d,oldIndex:-1,newIndex:c++}}))}{let c=o._snapshot.oldDocs;return o._snapshot.docChanges.filter((f=>l||f.type!==3)).map((f=>{const d=new vd(o._firestore,o._userDataWriter,f.doc.key,f.doc,new du(o._snapshot.mutatedKeys.has(f.doc.key),o._snapshot.fromCache),o.query.converter);let m=-1,g=-1;return f.type!==0&&(m=c.indexOf(f.doc.key),c=c.delete(f.doc.key)),f.type!==1&&(c=c.add(f.doc),g=c.indexOf(f.doc.key)),{type:$7(f.type),doc:d,oldIndex:m,newIndex:g}}))}})(this,n),this._cachedChangesIncludeMetadataChanges=n),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new ge(re.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=Tl._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=e0.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const n=[],s=[],o=[];return this.docs.forEach((l=>{l._document!==null&&(n.push(l._document),s.push(this._userDataWriter.convertObjectMap(l._document.data.value.mapValue.fields,"previous")),o.push(l.ref.path))})),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function $7(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return Ie(61501,{type:t})}}Tl._jsonSchemaVersion="firestore/querySnapshot/1.0",Tl._jsonSchema={type:Mt("string",Tl._jsonSchemaVersion),bundleSource:Mt("string","QuerySnapshot"),bundleName:Mt("string"),bundle:Mt("string")};function K7(t){t=Ms(t,Rt);const e=Ms(t.firestore,_a),n=A0(e);return C7(n,t._key).then((s=>W7(e,t,s)))}function xu(t){t=Ms(t,ba);const e=Ms(t.firestore,_a),n=A0(e),s=new AN(e);return G7(t._query),I7(n,t._query).then((o=>new Tl(e,s,t,o)))}function Q7(t,e,n){t=Ms(t,Rt);const s=Ms(t.firestore,_a),o=PN(t.converter,e),l=qm(s);return $m(s,[TN(l,"setDoc",t._key,o,t.converter!==null,n).toMutation(t._key,us.none())])}function Y7(t,e,n,...s){t=Ms(t,Rt);const o=Ms(t.firestore,_a),l=qm(o);let c;return c=typeof(e=Ft(e))=="string"||e instanceof R0?z7(l,"updateDoc",t._key,e,n,s):U7(l,"updateDoc",t._key,e),$m(o,[c.toMutation(t._key,us.exists(!0))])}function DA(t){return $m(Ms(t.firestore,_a),[new c0(t._key,us.none())])}function OA(t,e){const n=Ms(t.firestore,_a),s=_l(t),o=PN(t.converter,e),l=qm(t.firestore);return $m(n,[TN(l,"addDoc",s._key,o,t.converter!==null,{}).toMutation(s._key,us.exists(!1))]).then((()=>s))}function $m(t,e){const n=A0(t);return N7(n,e)}function W7(t,e,n){const s=n.docs.get(e._key),o=new AN(t);return new aa(t,o,e._key,s,new du(n.hasPendingWrites,n.fromCache),e.converter)}(function(e,n=!0){Iz(Fl),Nl(new ua("firestore",((s,{instanceIdentifier:o,options:l})=>{const c=s.getProvider("app").getImmediate(),f=new _a(new Dz(s.getProvider("auth-internal")),new kz(c,s.getProvider("app-check-internal")),Zz(c,o),c);return l={useFetchStreams:n,...l},f._setSettings(l),f}),"PUBLIC").setMultipleInstances(!0)),Fr(RA,CA,e),Fr(RA,CA,"esm2020")})();var X7="firebase",Z7="12.14.0";Fr(X7,Z7,"app");function DN(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const J7=DN,ON=new nf("auth","Firebase",DN());const em=new Wb("@firebase/auth");function e8(t,...e){em.logLevel<=Fe.WARN&&em.warn(`Auth (${Fl}): ${t}`,...e)}function bd(t,...e){em.logLevel<=Fe.ERROR&&em.error(`Auth (${Fl}): ${t}`,...e)}function fs(t,...e){throw V0(t,...e)}function Ns(t,...e){return V0(t,...e)}function k0(t,e,n){const s={...J7(),[e]:n};return new nf("auth","Firebase",s).create(e,{appName:t.name})}function Li(t){return k0(t,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function t8(t,e,n){const s=n;if(!(e instanceof s))throw s.name!==e.constructor.name&&fs(t,"argument-error"),k0(t,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function V0(t,...e){if(typeof t!="string"){const n=e[0],s=[...e.slice(1)];return s[0]&&(s[0].appName=t.name),t._errorFactory.create(n,...s)}return ON.create(t,...e)}function Ce(t,e,...n){if(!t)throw V0(e,...n)}function ki(t){const e="INTERNAL ASSERTION FAILED: "+t;throw bd(e),new Error(e)}function Hi(t,e){t||ki(e)}function Wv(){return typeof self<"u"&&self.location?.href||""}function n8(){return MA()==="http:"||MA()==="https:"}function MA(){return typeof self<"u"&&self.location?.protocol||null}function s8(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(n8()||l5()||"connection"in navigator)?navigator.onLine:!0}function i8(){if(typeof navigator>"u")return null;const t=navigator;return t.languages&&t.languages[0]||t.language||null}class df{constructor(e,n){this.shortDelay=e,this.longDelay=n,Hi(n>e,"Short delay should be less than long delay!"),this.isMobile=r5()||c5()}get(){return s8()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}function j0(t,e){Hi(t.emulator,"Emulator should always be set here");const{url:n}=t.emulator;return e?`${n}${e.startsWith("/")?e.slice(1):e}`:n}class MN{static initialize(e,n,s){this.fetchImpl=e,n&&(this.headersImpl=n),s&&(this.responseImpl=s)}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;ki("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;ki("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;ki("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const r8={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"};const o8=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],a8=new df(3e4,6e4);function co(t,e){return t.tenantId&&!e.tenantId?{...e,tenantId:t.tenantId}:e}async function Ki(t,e,n,s,o={}){return kN(t,o,async()=>{let l={},c={};s&&(e==="GET"?c=s:l={body:JSON.stringify(s)});const f=sf({key:t.config.apiKey,...c}).slice(1),d=await t._getAdditionalHeaders();d["Content-Type"]="application/json",t.languageCode&&(d["X-Firebase-Locale"]=t.languageCode);const m={method:e,headers:d,...l};return a5()||(m.referrerPolicy="no-referrer"),t.emulatorConfig&&rf(t.emulatorConfig.host)&&(m.credentials="include"),MN.fetch()(await VN(t,t.config.apiHost,n,f),m)})}async function kN(t,e,n){t._canInitEmulator=!1;const s={...r8,...e};try{const o=new c8(t),l=await Promise.race([n(),o.promise]);o.clearNetworkTimeout();const c=await l.json();if("needConfirmation"in c)throw Jh(t,"account-exists-with-different-credential",c);if(l.ok&&!("errorMessage"in c))return c;{const f=l.ok?c.errorMessage:c.error.message,[d,m]=f.split(" : ");if(d==="FEDERATED_USER_ID_ALREADY_LINKED")throw Jh(t,"credential-already-in-use",c);if(d==="EMAIL_EXISTS")throw Jh(t,"email-already-in-use",c);if(d==="USER_DISABLED")throw Jh(t,"user-disabled",c);const g=s[d]||d.toLowerCase().replace(/[_\s]+/g,"-");if(m)throw k0(t,g,m);fs(t,g)}}catch(o){if(o instanceof $i)throw o;fs(t,"network-request-failed",{message:String(o)})}}async function mf(t,e,n,s,o={}){const l=await Ki(t,e,n,s,o);return"mfaPendingCredential"in l&&fs(t,"multi-factor-auth-required",{_serverResponse:l}),l}async function VN(t,e,n,s){const o=`${e}${n}?${s}`,l=t,c=l.config.emulator?j0(t.config,o):`${t.config.apiScheme}://${o}`;return o8.includes(n)&&(await l._persistenceManagerAvailable,l._getPersistenceType()==="COOKIE")?l._getPersistence()._getFinalTarget(c).toString():c}function l8(t){switch(t){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class c8{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((n,s)=>{this.timer=setTimeout(()=>s(Ns(this.auth,"network-request-failed")),a8.get())})}}function Jh(t,e,n){const s={appName:t.name};n.email&&(s.email=n.email),n.phoneNumber&&(s.phoneNumber=n.phoneNumber);const o=Ns(t,e,s);return o.customData._tokenResponse=n,o}function kA(t){return t!==void 0&&t.enterprise!==void 0}class u8{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 l8(n.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)==="ENFORCE"||this.getProviderEnforcementState(e)==="AUDIT"}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function f8(t,e){return Ki(t,"GET","/v2/recaptchaConfig",co(t,e))}async function h8(t,e){return Ki(t,"POST","/v1/accounts:delete",e)}async function tm(t,e){return Ki(t,"POST","/v1/accounts:lookup",e)}function Eu(t){if(t)try{const e=new Date(Number(t));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function d8(t,e=!1){const n=Ft(t),s=await n.getIdToken(e),o=L0(s);Ce(o&&o.exp&&o.auth_time&&o.iat,n.auth,"internal-error");const l=typeof o.firebase=="object"?o.firebase:void 0,c=l?.sign_in_provider;return{claims:o,token:s,authTime:Eu(Ly(o.auth_time)),issuedAtTime:Eu(Ly(o.iat)),expirationTime:Eu(Ly(o.exp)),signInProvider:c||null,signInSecondFactor:l?.sign_in_second_factor||null}}function Ly(t){return Number(t)*1e3}function L0(t){const[e,n,s]=t.split(".");if(e===void 0||n===void 0||s===void 0)return bd("JWT malformed, contained fewer than 3 sections"),null;try{const o=L2(n);return o?JSON.parse(o):(bd("Failed to decode base64 JWT payload"),null)}catch(o){return bd("Caught error parsing JWT payload as JSON",o?.toString()),null}}function VA(t){const e=L0(t);return Ce(e,"internal-error"),Ce(typeof e.exp<"u","internal-error"),Ce(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}async function kl(t,e,n=!1){if(n)return e;try{return await e}catch(s){throw s instanceof $i&&m8(s)&&t.auth.currentUser===t&&await t.auth.signOut(),s}}function m8({code:t}){return t==="auth/user-disabled"||t==="auth/user-token-expired"}class p8{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){if(e){const n=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),n}else{this.errorBackoff=3e4;const s=(this.user.stsTokenManager.expirationTime??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?.code==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}class Xv{constructor(e,n){this.createdAt=e,this.lastLoginAt=n,this._initializeTime()}_initializeTime(){this.lastSignInTime=Eu(this.lastLoginAt),this.creationTime=Eu(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function nm(t){const e=t.auth,n=await t.getIdToken(),s=await kl(t,tm(e,{idToken:n}));Ce(s?.users.length,e,"internal-error");const o=s.users[0];t._notifyReloadListener(o);const l=o.providerUserInfo?.length?jN(o.providerUserInfo):[],c=y8(t.providerData,l),f=t.isAnonymous,d=!(t.email&&o.passwordHash)&&!c?.length,m=f?d:!1,g={uid:o.localId,displayName:o.displayName||null,photoURL:o.photoUrl||null,email:o.email||null,emailVerified:o.emailVerified||!1,phoneNumber:o.phoneNumber||null,tenantId:o.tenantId||null,providerData:c,metadata:new Xv(o.createdAt,o.lastLoginAt),isAnonymous:m};Object.assign(t,g)}async function g8(t){const e=Ft(t);await nm(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function y8(t,e){return[...t.filter(s=>!e.some(o=>o.providerId===s.providerId)),...e]}function jN(t){return t.map(({providerId:e,...n})=>({providerId:e,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}))}async function v8(t,e){const n=await kN(t,{},async()=>{const s=sf({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:o,apiKey:l}=t.config,c=await VN(t,o,"/v1/token",`key=${l}`),f=await t._getAdditionalHeaders();f["Content-Type"]="application/x-www-form-urlencoded";const d={method:"POST",headers:f,body:s};return t.emulatorConfig&&rf(t.emulatorConfig.host)&&(d.credentials="include"),MN.fetch()(c,d)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async function b8(t,e){return Ki(t,"POST","/v2/accounts:revokeToken",co(t,e))}class wl{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){Ce(e.idToken,"internal-error"),Ce(typeof e.idToken<"u","internal-error"),Ce(typeof e.refreshToken<"u","internal-error");const n="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):VA(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,n)}updateFromIdToken(e){Ce(e.length!==0,"internal-error");const n=VA(e);this.updateTokensAndExpiration(e,null,n)}async getToken(e,n=!1){return!n&&this.accessToken&&!this.isExpired?this.accessToken:(Ce(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:s,refreshToken:o,expiresIn:l}=await v8(e,n);this.updateTokensAndExpiration(s,o,Number(l))}updateTokensAndExpiration(e,n,s){this.refreshToken=n||null,this.accessToken=e||null,this.expirationTime=Date.now()+s*1e3}static fromJSON(e,n){const{refreshToken:s,accessToken:o,expirationTime:l}=n,c=new wl;return s&&(Ce(typeof s=="string","internal-error",{appName:e}),c.refreshToken=s),o&&(Ce(typeof o=="string","internal-error",{appName:e}),c.accessToken=o),l&&(Ce(typeof l=="number","internal-error",{appName:e}),c.expirationTime=l),c}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 wl,this.toJSON())}_performRefresh(){return ki("not implemented")}}function Mr(t,e){Ce(typeof t=="string"||typeof t>"u","internal-error",{appName:e})}class As{constructor({uid:e,auth:n,stsTokenManager:s,...o}){this.providerId="firebase",this.proactiveRefresh=new p8(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=n,this.stsTokenManager=s,this.accessToken=s.accessToken,this.displayName=o.displayName||null,this.email=o.email||null,this.emailVerified=o.emailVerified||!1,this.phoneNumber=o.phoneNumber||null,this.photoURL=o.photoURL||null,this.isAnonymous=o.isAnonymous||!1,this.tenantId=o.tenantId||null,this.providerData=o.providerData?[...o.providerData]:[],this.metadata=new Xv(o.createdAt||void 0,o.lastLoginAt||void 0)}async getIdToken(e){const n=await kl(this,this.stsTokenManager.getToken(this.auth,e));return Ce(n,this.auth,"internal-error"),this.accessToken!==n&&(this.accessToken=n,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),n}getIdTokenResult(e){return d8(this,e)}reload(){return g8(this)}_assign(e){this!==e&&(Ce(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=>({...n})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const n=new As({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return n.metadata._copy(this.metadata),n}_onReload(e){Ce(!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 s=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),s=!0),n&&await nm(this),await this.auth._persistUserIfCurrent(this),s&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Fn(this.auth.app))return Promise.reject(Li(this.auth));const e=await this.getIdToken();return await kl(this,h8(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>({...e})),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId,...this.metadata.toJSON(),apiKey:this.auth.config.apiKey,appName:this.auth.name}}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,n){const s=n.displayName??void 0,o=n.email??void 0,l=n.phoneNumber??void 0,c=n.photoURL??void 0,f=n.tenantId??void 0,d=n._redirectEventId??void 0,m=n.createdAt??void 0,g=n.lastLoginAt??void 0,{uid:v,emailVerified:T,isAnonymous:E,providerData:R,stsTokenManager:P}=n;Ce(v&&P,e,"internal-error");const N=wl.fromJSON(this.name,P);Ce(typeof v=="string",e,"internal-error"),Mr(s,e.name),Mr(o,e.name),Ce(typeof T=="boolean",e,"internal-error"),Ce(typeof E=="boolean",e,"internal-error"),Mr(l,e.name),Mr(c,e.name),Mr(f,e.name),Mr(d,e.name),Mr(m,e.name),Mr(g,e.name);const L=new As({uid:v,auth:e,email:o,emailVerified:T,displayName:s,isAnonymous:E,photoURL:c,phoneNumber:l,tenantId:f,stsTokenManager:N,createdAt:m,lastLoginAt:g});return R&&Array.isArray(R)&&(L.providerData=R.map(z=>({...z}))),d&&(L._redirectEventId=d),L}static async _fromIdTokenResponse(e,n,s=!1){const o=new wl;o.updateFromServerResponse(n);const l=new As({uid:n.localId,auth:e,stsTokenManager:o,isAnonymous:s});return await nm(l),l}static async _fromGetAccountInfoResponse(e,n,s){const o=n.users[0];Ce(o.localId!==void 0,"internal-error");const l=o.providerUserInfo!==void 0?jN(o.providerUserInfo):[],c=!(o.email&&o.passwordHash)&&!l?.length,f=new wl;f.updateFromIdToken(s);const d=new As({uid:o.localId,auth:e,stsTokenManager:f,isAnonymous:c}),m={uid:o.localId,displayName:o.displayName||null,photoURL:o.photoUrl||null,email:o.email||null,emailVerified:o.emailVerified||!1,phoneNumber:o.phoneNumber||null,tenantId:o.tenantId||null,providerData:l,metadata:new Xv(o.createdAt,o.lastLoginAt),isAnonymous:!(o.email&&o.passwordHash)&&!l?.length};return Object.assign(d,m),d}}const jA=new Map;function Vi(t){Hi(t instanceof Function,"Expected a class definition");let e=jA.get(t);return e?(Hi(e instanceof t,"Instance stored in cache mismatched with class"),e):(e=new t,jA.set(t,e),e)}class LN{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){}}LN.type="NONE";const LA=LN;function _d(t,e,n){return`firebase:${t}:${e}:${n}`}class xl{constructor(e,n,s){this.persistence=e,this.auth=n,this.userKey=s;const{config:o,name:l}=this.auth;this.fullUserKey=_d(this.userKey,o.apiKey,l),this.fullPersistenceKey=_d("persistence",o.apiKey,l),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);if(!e)return null;if(typeof e=="string"){const n=await tm(this.auth,{idToken:e}).catch(()=>{});return n?As._fromGetAccountInfoResponse(this.auth,n,e):null}return As._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;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,s="authUser"){if(!n.length)return new xl(Vi(LA),e,s);const o=(await Promise.all(n.map(async m=>{if(await m._isAvailable())return m}))).filter(m=>m);let l=o[0]||Vi(LA);const c=_d(s,e.config.apiKey,e.name);let f=null;for(const m of n)try{const g=await m._get(c);if(g){let v;if(typeof g=="string"){const T=await tm(e,{idToken:g}).catch(()=>{});if(!T)break;v=await As._fromGetAccountInfoResponse(e,T,g)}else v=As._fromJSON(e,g);m!==l&&(f=v),l=m;break}}catch{}const d=o.filter(m=>m._shouldAllowMigration);return!l._shouldAllowMigration||!d.length?new xl(l,e,s):(l=d[0],f&&await l._set(c,f.toJSON()),await Promise.all(n.map(async m=>{if(m!==l)try{await m._remove(c)}catch{}})),new xl(l,e,s))}}function UA(t){const e=t.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(FN(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(UN(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(HN(e))return"Blackberry";if(GN(e))return"Webos";if(zN(e))return"Safari";if((e.includes("chrome/")||BN(e))&&!e.includes("edge/"))return"Chrome";if(qN(e))return"Android";{const n=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,s=t.match(n);if(s?.length===2)return s[1]}return"Other"}function UN(t=mn()){return/firefox\//i.test(t)}function zN(t=mn()){const e=t.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function BN(t=mn()){return/crios\//i.test(t)}function FN(t=mn()){return/iemobile/i.test(t)}function qN(t=mn()){return/android/i.test(t)}function HN(t=mn()){return/blackberry/i.test(t)}function GN(t=mn()){return/webos/i.test(t)}function U0(t=mn()){return/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&/mobile/i.test(t)}function _8(t=mn()){return U0(t)&&!!window.navigator?.standalone}function T8(){return u5()&&document.documentMode===10}function $N(t=mn()){return U0(t)||qN(t)||GN(t)||HN(t)||/windows phone/i.test(t)||FN(t)}function KN(t,e=[]){let n;switch(t){case"Browser":n=UA(mn());break;case"Worker":n=`${UA(mn())}-${t}`;break;default:n=t}const s=e.length?e.join(","):"FirebaseCore-web";return`${n}/JsCore/${Fl}/${s}`}class w8{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,n){const s=l=>new Promise((c,f)=>{try{const d=e(l);c(d)}catch(d){f(d)}});s.onAbort=n,this.queue.push(s);const o=this.queue.length-1;return()=>{this.queue[o]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const n=[];try{for(const s of this.queue)await s(e),s.onAbort&&n.push(s.onAbort)}catch(s){n.reverse();for(const o of n)try{o()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:s?.message})}}}async function x8(t,e={}){return Ki(t,"GET","/v2/passwordPolicy",co(t,e))}const E8=6;class S8{constructor(e){const n=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=n.minPasswordLength??E8,n.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=n.maxPasswordLength),n.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=n.containsLowercaseCharacter),n.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=n.containsUppercaseCharacter),n.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=n.containsNumericCharacter),n.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=n.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=e.allowedNonAlphanumericCharacters?.join("")??"",this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){const n={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,n),this.validatePasswordCharacterOptions(e,n),n.isValid&&(n.isValid=n.meetsMinPasswordLength??!0),n.isValid&&(n.isValid=n.meetsMaxPasswordLength??!0),n.isValid&&(n.isValid=n.containsLowercaseLetter??!0),n.isValid&&(n.isValid=n.containsUppercaseLetter??!0),n.isValid&&(n.isValid=n.containsNumericCharacter??!0),n.isValid&&(n.isValid=n.containsNonAlphanumericCharacter??!0),n}validatePasswordLengthOptions(e,n){const s=this.customStrengthOptions.minPasswordLength,o=this.customStrengthOptions.maxPasswordLength;s&&(n.meetsMinPasswordLength=e.length>=s),o&&(n.meetsMaxPasswordLength=e.length<=o)}validatePasswordCharacterOptions(e,n){this.updatePasswordCharacterOptionsStatuses(n,!1,!1,!1,!1);let s;for(let o=0;o="a"&&s<="z",s>="A"&&s<="Z",s>="0"&&s<="9",this.allowedNonAlphanumericCharacters.includes(s))}updatePasswordCharacterOptionsStatuses(e,n,s,o,l){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=n)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=s)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=o)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=l))}}class A8{constructor(e,n,s,o){this.app=e,this.heartbeatServiceProvider=n,this.appCheckServiceProvider=s,this.config=o,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new zA(this),this.idTokenSubscription=new zA(this),this.beforeStateQueue=new w8(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=ON,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=o.sdkClientVersion,this._persistenceManagerAvailable=new Promise(l=>this._resolvePersistenceManagerAvailable=l)}_initializeWithPersistence(e,n){return n&&(this._popupRedirectResolver=Vi(n)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await xl.create(this,e),this._resolvePersistenceManagerAvailable?.(),!this._deleted)){if(this._popupRedirectResolver?._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(n),this.lastNotifiedUid=this.currentUser?.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 tm(this,{idToken:e}),s=await As._fromGetAccountInfoResponse(this,n,e);await this.directlySetCurrentUser(s)}catch(n){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",n),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){if(Fn(this.app)){const l=this.app.settings.authIdToken;return l?new Promise(c=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(l).then(c,c))}):this.directlySetCurrentUser(null)}const n=await this.assertedPersistence.getCurrentUser();let s=n,o=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const l=this.redirectUser?._redirectEventId,c=s?._redirectEventId,f=await this.tryRedirectSignIn(e);(!l||l===c)&&f?.user&&(s=f.user,o=!0)}if(!s)return this.directlySetCurrentUser(null);if(!s._redirectEventId){if(o)try{await this.beforeStateQueue.runMiddleware(s)}catch(l){s=n,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(l))}return s?this.reloadAndSetCurrentUserOrClear(s):this.directlySetCurrentUser(null)}return Ce(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 nm(e)}catch(n){if(n?.code!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=i8()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(Fn(this.app))return Promise.reject(Li(this));const n=e?Ft(e):null;return n&&Ce(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&&Ce(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 Fn(this.app)?Promise.reject(Li(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Fn(this.app)?Promise.reject(Li(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(Vi(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 x8(this),n=new S8(e);this.tenantId===null?this._projectPasswordPolicy=n:this._tenantPasswordPolicies[this.tenantId]=n}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new nf("auth","Firebase",e())}onAuthStateChanged(e,n,s){return this.registerStateListener(this.authStateSubscription,e,n,s)}beforeAuthStateChanged(e,n){return this.beforeStateQueue.pushCallback(e,n)}onIdTokenChanged(e,n,s){return this.registerStateListener(this.idTokenSubscription,e,n,s)}authStateReady(){return new Promise((e,n)=>{if(this.currentUser)e();else{const s=this.onAuthStateChanged(()=>{s(),e()},n)}})}async revokeAccessToken(e){if(this.currentUser){const n=await this.currentUser.getIdToken(),s={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:n};this.tenantId!=null&&(s.tenantId=this.tenantId),await b8(this,s)}}toJSON(){return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:this._currentUser?.toJSON()}}async _setRedirectUser(e,n){const s=await this.getOrInitRedirectPersistenceManager(n);return e===null?s.removeCurrentUser():s.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const n=e&&Vi(e)||this._popupRedirectResolver;Ce(n,this,"argument-error"),this.redirectPersistenceManager=await xl.create(this,[Vi(n._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){return this._isInitialized&&await this.queue(async()=>{}),this._currentUser?._redirectEventId===e?this._currentUser:this.redirectUser?._redirectEventId===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const e=this.currentUser?.uid??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,n,s,o){if(this._deleted)return()=>{};const l=typeof n=="function"?n:n.next.bind(n);let c=!1;const f=this._isInitialized?Promise.resolve():this._initializationPromise;if(Ce(f,this,"internal-error"),f.then(()=>{c||l(this.currentUser)}),typeof n=="function"){const d=e.addObserver(n,s,o);return()=>{c=!0,d()}}else{const d=e.addObserver(n);return()=>{c=!0,d()}}}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 Ce(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=KN(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){const e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);const n=await this.heartbeatServiceProvider.getImmediate({optional:!0})?.getHeartbeatsHeader();n&&(e["X-Firebase-Client"]=n);const s=await this._getAppCheckToken();return s&&(e["X-Firebase-AppCheck"]=s),e}async _getAppCheckToken(){if(Fn(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken();return e?.error&&e8(`Error while retrieving App Check token: ${e.error}`),e?.token}}function uo(t){return Ft(t)}class zA{constructor(e){this.auth=e,this.observer=null,this.addObserver=v5(n=>this.observer=n)}get next(){return Ce(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let Km={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function R8(t){Km=t}function QN(t){return Km.loadJS(t)}function C8(){return Km.recaptchaEnterpriseScript}function I8(){return Km.gapiScript}function N8(t){return`__${t}${Math.floor(Math.random()*1e6)}`}class P8{constructor(){this.enterprise=new D8}ready(e){e()}execute(e,n){return Promise.resolve("token")}render(e,n){return""}}class D8{ready(e){e()}execute(e,n){return Promise.resolve("token")}render(e,n){return""}}const O8="recaptcha-enterprise",YN="NO_RECAPTCHA";class M8{constructor(e){this.type=O8,this.auth=uo(e)}async verify(e="verify",n=!1){async function s(l){if(!n){if(l.tenantId==null&&l._agentRecaptchaConfig!=null)return l._agentRecaptchaConfig.siteKey;if(l.tenantId!=null&&l._tenantRecaptchaConfigs[l.tenantId]!==void 0)return l._tenantRecaptchaConfigs[l.tenantId].siteKey}return new Promise(async(c,f)=>{f8(l,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(d=>{if(d.recaptchaKey===void 0)f(new Error("recaptcha Enterprise site key undefined"));else{const m=new u8(d);return l.tenantId==null?l._agentRecaptchaConfig=m:l._tenantRecaptchaConfigs[l.tenantId]=m,c(m.siteKey)}}).catch(d=>{f(d)})})}function o(l,c,f){const d=window.grecaptcha;kA(d)?d.enterprise.ready(()=>{d.enterprise.execute(l,{action:e}).then(m=>{c(m)}).catch(()=>{c(YN)})}):f(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new P8().execute("siteKey",{action:"verify"}):new Promise((l,c)=>{s(this.auth).then(f=>{if(!n&&kA(window.grecaptcha))o(f,l,c);else{if(typeof window>"u"){c(new Error("RecaptchaVerifier is only supported in browser"));return}let d=C8();d.length!==0&&(d+=f),QN(d).then(()=>{o(f,l,c)}).catch(m=>{c(m)})}}).catch(f=>{c(f)})})}}async function BA(t,e,n,s=!1,o=!1){const l=new M8(t);let c;if(o)c=YN;else try{c=await l.verify(n)}catch{c=await l.verify(n,!0)}const f={...e};if(n==="mfaSmsEnrollment"||n==="mfaSmsSignIn"){if("phoneEnrollmentInfo"in f){const d=f.phoneEnrollmentInfo.phoneNumber,m=f.phoneEnrollmentInfo.recaptchaToken;Object.assign(f,{phoneEnrollmentInfo:{phoneNumber:d,recaptchaToken:m,captchaResponse:c,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in f){const d=f.phoneSignInInfo.recaptchaToken;Object.assign(f,{phoneSignInInfo:{recaptchaToken:d,captchaResponse:c,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return f}return s?Object.assign(f,{captchaResp:c}):Object.assign(f,{captchaResponse:c}),Object.assign(f,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(f,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),f}async function Zv(t,e,n,s,o){if(t._getRecaptchaConfig()?.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const l=await BA(t,e,n,n==="getOobCode");return s(t,l)}else return s(t,e).catch(async l=>{if(l.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 c=await BA(t,e,n,n==="getOobCode");return s(t,c)}else return Promise.reject(l)})}function k8(t,e){const n=Zb(t,"auth");if(n.isInitialized()){const o=n.getImmediate(),l=n.getOptions();if(ca(l,e??{}))return o;fs(o,"already-initialized")}return n.initialize({options:e})}function V8(t,e){const n=e?.persistence||[],s=(Array.isArray(n)?n:[n]).map(Vi);e?.errorMap&&t._updateErrorMap(e.errorMap),t._initializeWithPersistence(s,e?.popupRedirectResolver)}function j8(t,e,n){const s=uo(t);Ce(/^https?:\/\//.test(e),s,"invalid-emulator-scheme");const o=!1,l=WN(e),{host:c,port:f}=L8(e),d=f===null?"":`:${f}`,m={url:`${l}//${c}${d}/`},g=Object.freeze({host:c,port:f,protocol:l.replace(":",""),options:Object.freeze({disableWarnings:o})});if(!s._canInitEmulator){Ce(s.config.emulator&&s.emulatorConfig,s,"emulator-config-failed"),Ce(ca(m,s.config.emulator)&&ca(g,s.emulatorConfig),s,"emulator-config-failed");return}s.config.emulator=m,s.emulatorConfig=g,s.settings.appVerificationDisabledForTesting=!0,rf(c)?F2(`${l}//${c}${d}`):U8()}function WN(t){const e=t.indexOf(":");return e<0?"":t.substr(0,e+1)}function L8(t){const e=WN(t),n=/(\/\/)?([^?#/]+)/.exec(t.substr(e.length));if(!n)return{host:"",port:null};const s=n[2].split("@").pop()||"",o=/^(\[[^\]]+\])(:|$)/.exec(s);if(o){const l=o[1];return{host:l,port:FA(s.substr(l.length+1))}}else{const[l,c]=s.split(":");return{host:l,port:FA(c)}}}function FA(t){if(!t)return null;const e=Number(t);return isNaN(e)?null:e}function U8(){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())}class z0{constructor(e,n){this.providerId=e,this.signInMethod=n}toJSON(){return ki("not implemented")}_getIdTokenResponse(e){return ki("not implemented")}_linkToIdToken(e,n){return ki("not implemented")}_getReauthenticationResolver(e){return ki("not implemented")}}async function z8(t,e){return Ki(t,"POST","/v1/accounts:signUp",e)}async function B8(t,e){return mf(t,"POST","/v1/accounts:signInWithPassword",co(t,e))}async function F8(t,e){return mf(t,"POST","/v1/accounts:signInWithEmailLink",co(t,e))}async function q8(t,e){return mf(t,"POST","/v1/accounts:signInWithEmailLink",co(t,e))}class $u extends z0{constructor(e,n,s,o=null){super("password",s),this._email=e,this._password=n,this._tenantId=o}static _fromEmailAndPassword(e,n){return new $u(e,n,"password")}static _fromEmailAndCode(e,n,s=null){return new $u(e,n,"emailLink",s)}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?.email&&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 Zv(e,n,"signInWithPassword",B8);case"emailLink":return F8(e,{email:this._email,oobCode:this._password});default:fs(e,"internal-error")}}async _linkToIdToken(e,n){switch(this.signInMethod){case"password":const s={idToken:n,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return Zv(e,s,"signUpPassword",z8);case"emailLink":return q8(e,{idToken:n,email:this._email,oobCode:this._password});default:fs(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function El(t,e){return mf(t,"POST","/v1/accounts:signInWithIdp",co(t,e))}const H8="http://localhost";class ma extends z0{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const n=new ma(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):fs("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:s,signInMethod:o,...l}=n;if(!s||!o)return null;const c=new ma(s,o);return c.idToken=l.idToken||void 0,c.accessToken=l.accessToken||void 0,c.secret=l.secret,c.nonce=l.nonce,c.pendingToken=l.pendingToken||null,c}_getIdTokenResponse(e){const n=this.buildRequest();return El(e,n)}_linkToIdToken(e,n){const s=this.buildRequest();return s.idToken=n,El(e,s)}_getReauthenticationResolver(e){const n=this.buildRequest();return n.autoCreate=!1,El(e,n)}buildRequest(){const e={requestUri:H8,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=sf(n)}return e}}function G8(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 $8(t){const e=lu(cu(t)).link,n=e?lu(cu(e)).deep_link_id:null,s=lu(cu(t)).deep_link_id;return(s?lu(cu(s)).link:null)||s||n||e||t}class B0{constructor(e){const n=lu(cu(e)),s=n.apiKey??null,o=n.oobCode??null,l=G8(n.mode??null);Ce(s&&o&&l,"argument-error"),this.apiKey=s,this.operation=l,this.code=o,this.continueUrl=n.continueUrl??null,this.languageCode=n.lang??null,this.tenantId=n.tenantId??null}static parseLink(e){const n=$8(e);try{return new B0(n)}catch{return null}}}class Ql{constructor(){this.providerId=Ql.PROVIDER_ID}static credential(e,n){return $u._fromEmailAndPassword(e,n)}static credentialWithLink(e,n){const s=B0.parseLink(n);return Ce(s,"argument-error"),$u._fromEmailAndCode(e,s.code,s.tenantId)}}Ql.PROVIDER_ID="password";Ql.EMAIL_PASSWORD_SIGN_IN_METHOD="password";Ql.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class F0{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}class pf extends F0{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class Vr extends pf{constructor(){super("facebook.com")}static credential(e){return ma._fromParams({providerId:Vr.PROVIDER_ID,signInMethod:Vr.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Vr.credentialFromTaggedObject(e)}static credentialFromError(e){return Vr.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Vr.credential(e.oauthAccessToken)}catch{return null}}}Vr.FACEBOOK_SIGN_IN_METHOD="facebook.com";Vr.PROVIDER_ID="facebook.com";class Oi extends pf{constructor(){super("google.com"),this.addScope("profile")}static credential(e,n){return ma._fromParams({providerId:Oi.PROVIDER_ID,signInMethod:Oi.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:n})}static credentialFromResult(e){return Oi.credentialFromTaggedObject(e)}static credentialFromError(e){return Oi.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:n,oauthAccessToken:s}=e;if(!n&&!s)return null;try{return Oi.credential(n,s)}catch{return null}}}Oi.GOOGLE_SIGN_IN_METHOD="google.com";Oi.PROVIDER_ID="google.com";class jr extends pf{constructor(){super("github.com")}static credential(e){return ma._fromParams({providerId:jr.PROVIDER_ID,signInMethod:jr.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return jr.credentialFromTaggedObject(e)}static credentialFromError(e){return jr.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return jr.credential(e.oauthAccessToken)}catch{return null}}}jr.GITHUB_SIGN_IN_METHOD="github.com";jr.PROVIDER_ID="github.com";class Lr extends pf{constructor(){super("twitter.com")}static credential(e,n){return ma._fromParams({providerId:Lr.PROVIDER_ID,signInMethod:Lr.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:n})}static credentialFromResult(e){return Lr.credentialFromTaggedObject(e)}static credentialFromError(e){return Lr.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:n,oauthTokenSecret:s}=e;if(!n||!s)return null;try{return Lr.credential(n,s)}catch{return null}}}Lr.TWITTER_SIGN_IN_METHOD="twitter.com";Lr.PROVIDER_ID="twitter.com";async function K8(t,e){return mf(t,"POST","/v1/accounts:signUp",co(t,e))}class pa{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,n,s,o=!1){const l=await As._fromIdTokenResponse(e,s,o),c=qA(s);return new pa({user:l,providerId:c,_tokenResponse:s,operationType:n})}static async _forOperation(e,n,s){await e._updateTokensIfNecessary(s,!0);const o=qA(s);return new pa({user:e,providerId:o,_tokenResponse:s,operationType:n})}}function qA(t){return t.providerId?t.providerId:"phoneNumber"in t?"phone":null}class sm extends $i{constructor(e,n,s,o){super(n.code,n.message),this.operationType=s,this.user=o,Object.setPrototypeOf(this,sm.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:n.customData._serverResponse,operationType:s}}static _fromErrorAndOperation(e,n,s,o){return new sm(e,n,s,o)}}function XN(t,e,n,s){return(e==="reauthenticate"?n._getReauthenticationResolver(t):n._getIdTokenResponse(t)).catch(l=>{throw l.code==="auth/multi-factor-auth-required"?sm._fromErrorAndOperation(t,l,e,s):l})}async function Q8(t,e,n=!1){const s=await kl(t,e._linkToIdToken(t.auth,await t.getIdToken()),n);return pa._forOperation(t,"link",s)}async function Y8(t,e,n=!1){const{auth:s}=t;if(Fn(s.app))return Promise.reject(Li(s));const o="reauthenticate";try{const l=await kl(t,XN(s,o,e,t),n);Ce(l.idToken,s,"internal-error");const c=L0(l.idToken);Ce(c,s,"internal-error");const{sub:f}=c;return Ce(t.uid===f,s,"user-mismatch"),pa._forOperation(t,o,l)}catch(l){throw l?.code==="auth/user-not-found"&&fs(s,"user-mismatch"),l}}async function ZN(t,e,n=!1){if(Fn(t.app))return Promise.reject(Li(t));const s="signIn",o=await XN(t,s,e),l=await pa._fromIdTokenResponse(t,s,o);return n||await t._updateCurrentUser(l.user),l}async function W8(t,e){return ZN(uo(t),e)}async function JN(t){const e=uo(t);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}async function X8(t,e,n){if(Fn(t.app))return Promise.reject(Li(t));const s=uo(t),c=await Zv(s,{returnSecureToken:!0,email:e,password:n,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",K8).catch(d=>{throw d.code==="auth/password-does-not-meet-requirements"&&JN(t),d}),f=await pa._fromIdTokenResponse(s,"signIn",c);return await s._updateCurrentUser(f.user),f}function Z8(t,e,n){return Fn(t.app)?Promise.reject(Li(t)):W8(Ft(t),Ql.credential(e,n)).catch(async s=>{throw s.code==="auth/password-does-not-meet-requirements"&&JN(t),s})}async function J8(t,e){return Ki(t,"POST","/v1/accounts:update",e)}async function eq(t,{displayName:e,photoURL:n}){if(e===void 0&&n===void 0)return;const s=Ft(t),l={idToken:await s.getIdToken(),displayName:e,photoUrl:n,returnSecureToken:!0},c=await kl(s,J8(s.auth,l));s.displayName=c.displayName||null,s.photoURL=c.photoUrl||null;const f=s.providerData.find(({providerId:d})=>d==="password");f&&(f.displayName=s.displayName,f.photoURL=s.photoURL),await s._updateTokensIfNecessary(c)}function tq(t,e,n,s){return Ft(t).onIdTokenChanged(e,n,s)}function nq(t,e,n){return Ft(t).beforeAuthStateChanged(e,n)}function sq(t,e,n,s){return Ft(t).onAuthStateChanged(e,n,s)}function iq(t){return Ft(t).signOut()}const im="__sak";class eP{constructor(e,n){this.storageRetriever=e,this.type=n}_isAvailable(){try{return this.storage?(this.storage.setItem(im,"1"),this.storage.removeItem(im),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()}}const rq=1e3,oq=10;class tP extends eP{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,n)=>this.onStorageEvent(e,n),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=$N(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const n of Object.keys(this.listeners)){const s=this.storage.getItem(n),o=this.localCache[n];s!==o&&e(n,o,s)}}onStorageEvent(e,n=!1){if(!e.key){this.forAllChangedKeys((c,f,d)=>{this.notifyListeners(c,d)});return}const s=e.key;n?this.detachListener():this.stopPolling();const o=()=>{const c=this.storage.getItem(s);!n&&this.localCache[s]===c||this.notifyListeners(s,c)},l=this.storage.getItem(s);T8()&&l!==e.newValue&&e.newValue!==e.oldValue?setTimeout(o,oq):o()}notifyListeners(e,n){this.localCache[e]=n;const s=this.listeners[e];if(s)for(const o of Array.from(s))o(n&&JSON.parse(n))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,n,s)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:n,newValue:s}),!0)})},rq)}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]}}tP.type="LOCAL";const aq=tP;class nP extends eP{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,n){}_removeListener(e,n){}}nP.type="SESSION";const sP=nP;function lq(t){return Promise.all(t.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(n){return{fulfilled:!1,reason:n}}}))}class Qm{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const n=this.receivers.find(o=>o.isListeningto(e));if(n)return n;const s=new Qm(e);return this.receivers.push(s),s}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const n=e,{eventId:s,eventType:o,data:l}=n.data,c=this.handlersMap[o];if(!c?.size)return;n.ports[0].postMessage({status:"ack",eventId:s,eventType:o});const f=Array.from(c).map(async m=>m(n.origin,l)),d=await lq(f);n.ports[0].postMessage({status:"done",eventId:s,eventType:o,response:d})}_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)}}Qm.receivers=[];function q0(t="",e=10){let n="";for(let s=0;s{const m=q0("",20);o.port1.start();const g=setTimeout(()=>{d(new Error("unsupported_event"))},s);c={messageChannel:o,onMessage(v){const T=v;if(T.data.eventId===m)switch(T.data.status){case"ack":clearTimeout(g),l=setTimeout(()=>{d(new Error("timeout"))},3e3);break;case"done":clearTimeout(l),f(T.data.response);break;default:clearTimeout(g),clearTimeout(l),d(new Error("invalid_response"));break}}},this.handlers.add(c),o.port1.addEventListener("message",c.onMessage),this.target.postMessage({eventType:e,eventId:m,data:n},[o.port2])}).finally(()=>{c&&this.removeMessageHandler(c)})}}function oi(){return window}function uq(t){oi().location.href=t}function iP(){return typeof oi().WorkerGlobalScope<"u"&&typeof oi().importScripts=="function"}async function fq(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function hq(){return navigator?.serviceWorker?.controller||null}function dq(){return iP()?self:null}const rP="firebaseLocalStorageDb",mq=1,rm="firebaseLocalStorage",oP="fbase_key";class gf{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 Ym(t,e){return t.transaction([rm],e?"readwrite":"readonly").objectStore(rm)}function pq(){const t=indexedDB.deleteDatabase(rP);return new gf(t).toPromise()}function aP(){const t=indexedDB.open(rP,mq);return new Promise((e,n)=>{t.addEventListener("error",()=>{n(t.error)}),t.addEventListener("upgradeneeded",()=>{const s=t.result;try{s.createObjectStore(rm,{keyPath:oP})}catch(o){n(o)}}),t.addEventListener("success",async()=>{const s=t.result;s.objectStoreNames.contains(rm)?e(s):(s.close(),await pq(),e(await aP()))})})}async function HA(t,e,n){const s=Ym(t,!0).put({[oP]:e,value:n});return new gf(s).toPromise()}async function gq(t,e){const n=Ym(t,!1).get(e),s=await new gf(n).toPromise();return s===void 0?null:s.value}function GA(t,e){const n=Ym(t,!0).delete(e);return new gf(n).toPromise()}const yq=800,vq=3;class lP{constructor(){this.type="LOCAL",this.dbPromise=null,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.dbPromise?this.dbPromise:(this.dbPromise=aP(),this.dbPromise.catch(()=>{this.dbPromise=null}),this.dbPromise)}async _withRetries(e){let n=0;for(;;)try{const s=await this._openDb();return await e(s)}catch(s){if(n++>vq)throw s;this.dbPromise&&((await this.dbPromise).close(),this.dbPromise=null)}}async initializeServiceWorkerMessaging(){return iP()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Qm._getInstance(dq()),this.receiver._subscribe("keyChanged",async(e,n)=>({keyProcessed:(await this._poll()).includes(n.key)})),this.receiver._subscribe("ping",async(e,n)=>["keyChanged"])}async initializeSender(){if(this.activeServiceWorker=await fq(),!this.activeServiceWorker)return;this.sender=new cq(this.activeServiceWorker);const e=await this.sender._send("ping",{},800);e&&e[0]?.fulfilled&&e[0]?.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||hq()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{return indexedDB?(await this._withRetries(async e=>{await HA(e,im,"1"),await GA(e,im)}),!0):!1}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(s=>HA(s,e,n)),this.localCache[e]=n,this.notifyServiceWorker(e)))}async _get(e){const n=await this._withRetries(s=>gq(s,e));return this.localCache[e]=n,n}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(n=>GA(n,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(o=>{const l=Ym(o,!1).getAll();return new gf(l).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const n=[],s=new Set;if(e.length!==0)for(const{fbase_key:o,value:l}of e)s.add(o),JSON.stringify(this.localCache[o])!==JSON.stringify(l)&&(this.notifyListeners(o,l),n.push(o));for(const o of Object.keys(this.localCache))this.localCache[o]&&!s.has(o)&&(this.notifyListeners(o,null),n.push(o));return n}notifyListeners(e,n){this.localCache[e]=n;const s=this.listeners[e];if(s)for(const o of Array.from(s))o(n)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),yq)}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()}}lP.type="LOCAL";const bq=lP;new df(3e4,6e4);function cP(t,e){return e?Vi(e):(Ce(t._popupRedirectResolver,t,"argument-error"),t._popupRedirectResolver)}class H0 extends z0{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return El(e,this._buildIdpRequest())}_linkToIdToken(e,n){return El(e,this._buildIdpRequest(n))}_getReauthenticationResolver(e){return El(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 _q(t){return ZN(t.auth,new H0(t),t.bypassAuthState)}function Tq(t){const{auth:e,user:n}=t;return Ce(n,e,"internal-error"),Y8(n,new H0(t),t.bypassAuthState)}async function wq(t){const{auth:e,user:n}=t;return Ce(n,e,"internal-error"),Q8(n,new H0(t),t.bypassAuthState)}class uP{constructor(e,n,s,o,l=!1){this.auth=e,this.resolver=s,this.user=o,this.bypassAuthState=l,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(s){this.reject(s)}})}async onAuthEvent(e){const{urlResponse:n,sessionId:s,postBody:o,tenantId:l,error:c,type:f}=e;if(c){this.reject(c);return}const d={auth:this.auth,requestUri:n,sessionId:s,tenantId:l||void 0,postBody:o||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(f)(d))}catch(m){this.reject(m)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return _q;case"linkViaPopup":case"linkViaRedirect":return wq;case"reauthViaPopup":case"reauthViaRedirect":return Tq;default:fs(this.auth,"internal-error")}}resolve(e){Hi(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Hi(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()}}const xq=new df(2e3,1e4);async function Eq(t,e,n){if(Fn(t.app))return Promise.reject(Ns(t,"operation-not-supported-in-this-environment"));const s=uo(t);t8(t,e,F0);const o=cP(s,n);return new ia(s,"signInViaPopup",e,o).executeNotNull()}class ia extends uP{constructor(e,n,s,o,l){super(e,n,o,l),this.provider=s,this.authWindow=null,this.pollId=null,ia.currentPopupAction&&ia.currentPopupAction.cancel(),ia.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return Ce(e,this.auth,"internal-error"),e}async onExecution(){Hi(this.filter.length===1,"Popup operations only handle one event");const e=q0();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(Ns(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(Ns(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,ia.currentPopupAction=null}pollUserCancellation(){const e=()=>{if(this.authWindow?.window?.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Ns(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,xq.get())};e()}}ia.currentPopupAction=null;const Sq="pendingRedirect",Td=new Map;class Aq extends uP{constructor(e,n,s=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],n,void 0,s),this.eventId=null}async execute(){let e=Td.get(this.auth._key());if(!e){try{const s=await Rq(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(s)}catch(n){e=()=>Promise.reject(n)}Td.set(this.auth._key(),e)}return this.bypassAuthState||Td.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 Rq(t,e){const n=Nq(e),s=Iq(t);if(!await s._isAvailable())return!1;const o=await s._get(n)==="true";return await s._remove(n),o}function Cq(t,e){Td.set(t._key(),e)}function Iq(t){return Vi(t._redirectPersistence)}function Nq(t){return _d(Sq,t.config.apiKey,t.name)}async function Pq(t,e,n=!1){if(Fn(t.app))return Promise.reject(Li(t));const s=uo(t),o=cP(s,e),c=await new Aq(s,o,n).execute();return c&&!n&&(delete c.user._redirectEventId,await s._persistUserIfCurrent(c.user),await s._setRedirectUser(null,e)),c}const Dq=600*1e3;class Oq{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(s=>{this.isEventForConsumer(e,s)&&(n=!0,this.sendToConsumer(e,s),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!Mq(e)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=e,n=!0)),n}sendToConsumer(e,n){if(e.error&&!fP(e)){const s=e.error.code?.split("auth/")[1]||"internal-error";n.onError(Ns(this.auth,s))}else n.onAuthEvent(e)}isEventForConsumer(e,n){const s=n.eventId===null||!!e.eventId&&e.eventId===n.eventId;return n.filter.includes(e.type)&&s}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=Dq&&this.cachedEventUids.clear(),this.cachedEventUids.has($A(e))}saveEventToCache(e){this.cachedEventUids.add($A(e)),this.lastProcessedEventTime=Date.now()}}function $A(t){return[t.type,t.eventId,t.sessionId,t.tenantId].filter(e=>e).join("-")}function fP({type:t,error:e}){return t==="unknown"&&e?.code==="auth/no-auth-event"}function Mq(t){switch(t.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return fP(t);default:return!1}}async function kq(t,e={}){return Ki(t,"GET","/v1/projects",e)}const Vq=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,jq=/^https?/;async function Lq(t){if(t.config.emulator)return;const{authorizedDomains:e}=await kq(t);for(const n of e)try{if(Uq(n))return}catch{}fs(t,"unauthorized-domain")}function Uq(t){const e=Wv(),{protocol:n,hostname:s}=new URL(e);if(t.startsWith("chrome-extension://")){const c=new URL(t);return c.hostname===""&&s===""?n==="chrome-extension:"&&t.replace("chrome-extension://","")===e.replace("chrome-extension://",""):n==="chrome-extension:"&&c.hostname===s}if(!jq.test(n))return!1;if(Vq.test(t))return s===t;const o=t.replace(/\./g,"\\.");return new RegExp("^(.+\\."+o+"|"+o+")$","i").test(s)}const zq=new df(3e4,6e4);function KA(){const t=oi().___jsl;if(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{function s(){KA(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{KA(),n(Ns(t,"network-request-failed"))},timeout:zq.get()})}if(oi().gapi?.iframes?.Iframe)e(gapi.iframes.getContext());else if(oi().gapi?.load)s();else{const o=N8("iframefcb");return oi()[o]=()=>{gapi.load?s():n(Ns(t,"network-request-failed"))},QN(`${I8()}?onload=${o}`).catch(l=>n(l))}}).catch(e=>{throw wd=null,e})}let wd=null;function Fq(t){return wd=wd||Bq(t),wd}const qq=new df(5e3,15e3),Hq="__/auth/iframe",Gq="emulator/auth/iframe",$q={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},Kq=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function Qq(t){const e=t.config;Ce(e.authDomain,t,"auth-domain-config-required");const n=e.emulator?j0(e,Gq):`https://${t.config.authDomain}/${Hq}`,s={apiKey:e.apiKey,appName:t.name,v:Fl},o=Kq.get(t.config.apiHost);o&&(s.eid=o);const l=t._getFrameworks();return l.length&&(s.fw=l.join(",")),`${n}?${sf(s).slice(1)}`}async function Yq(t){const e=await Fq(t),n=oi().gapi;return Ce(n,t,"internal-error"),e.open({where:document.body,url:Qq(t),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:$q,dontclear:!0},s=>new Promise(async(o,l)=>{await s.restyle({setHideOnLeave:!1});const c=Ns(t,"network-request-failed"),f=oi().setTimeout(()=>{l(c)},qq.get());function d(){oi().clearTimeout(f),o(s)}s.ping(d).then(d,()=>{l(c)})}))}const Wq={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},Xq=500,Zq=600,Jq="_blank",eH="http://localhost";class QA{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function tH(t,e,n,s=Xq,o=Zq){const l=Math.max((window.screen.availHeight-o)/2,0).toString(),c=Math.max((window.screen.availWidth-s)/2,0).toString();let f="";const d={...Wq,width:s.toString(),height:o.toString(),top:l,left:c},m=mn().toLowerCase();n&&(f=BN(m)?Jq:n),UN(m)&&(e=e||eH,d.scrollbars="yes");const g=Object.entries(d).reduce((T,[E,R])=>`${T}${E}=${R},`,"");if(_8(m)&&f!=="_self")return nH(e||"",f),new QA(null);const v=window.open(e||"",f,g);Ce(v,t,"popup-blocked");try{v.focus()}catch{}return new QA(v)}function nH(t,e){const n=document.createElement("a");n.href=t,n.target=e;const s=document.createEvent("MouseEvent");s.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(s)}const sH="__/auth/handler",iH="emulator/auth/handler",rH=encodeURIComponent("fac");async function YA(t,e,n,s,o,l){Ce(t.config.authDomain,t,"auth-domain-config-required"),Ce(t.config.apiKey,t,"invalid-api-key");const c={apiKey:t.config.apiKey,appName:t.name,authType:n,redirectUrl:s,v:Fl,eventId:o};if(e instanceof F0){e.setDefaultLanguage(t.languageCode),c.providerId=e.providerId||"",y5(e.getCustomParameters())||(c.customParameters=JSON.stringify(e.getCustomParameters()));for(const[g,v]of Object.entries({}))c[g]=v}if(e instanceof pf){const g=e.getScopes().filter(v=>v!=="");g.length>0&&(c.scopes=g.join(","))}t.tenantId&&(c.tid=t.tenantId);const f=c;for(const g of Object.keys(f))f[g]===void 0&&delete f[g];const d=await t._getAppCheckToken(),m=d?`#${rH}=${encodeURIComponent(d)}`:"";return`${oH(t)}?${sf(f).slice(1)}${m}`}function oH({config:t}){return t.emulator?j0(t,iH):`https://${t.authDomain}/${sH}`}const Uy="webStorageSupport";class aH{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=sP,this._completeRedirectFn=Pq,this._overrideRedirectResult=Cq}async _openPopup(e,n,s,o){Hi(this.eventManagers[e._key()]?.manager,"_initialize() not called before _openPopup()");const l=await YA(e,n,s,Wv(),o);return tH(e,l,q0())}async _openRedirect(e,n,s,o){await this._originValidation(e);const l=await YA(e,n,s,Wv(),o);return uq(l),new Promise(()=>{})}_initialize(e){const n=e._key();if(this.eventManagers[n]){const{manager:o,promise:l}=this.eventManagers[n];return o?Promise.resolve(o):(Hi(l,"If manager is not set, promise should be"),l)}const s=this.initAndGetManager(e);return this.eventManagers[n]={promise:s},s.catch(()=>{delete this.eventManagers[n]}),s}async initAndGetManager(e){const n=await Yq(e),s=new Oq(e);return n.register("authEvent",o=>(Ce(o?.authEvent,e,"invalid-auth-event"),{status:s.onEvent(o.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:s},this.iframes[e._key()]=n,s}_isIframeWebStorageSupported(e,n){this.iframes[e._key()].send(Uy,{type:Uy},o=>{const l=o?.[0]?.[Uy];l!==void 0&&n(!!l),fs(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const n=e._key();return this.originValidationPromises[n]||(this.originValidationPromises[n]=Lq(e)),this.originValidationPromises[n]}get _shouldInitProactively(){return $N()||zN()||U0()}}const lH=aH;var WA="@firebase/auth",XA="1.13.2";class cH{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){return this.assertAuthConfigured(),this.auth.currentUser?.uid||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const n=this.auth.onIdTokenChanged(s=>{e(s?.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(){Ce(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function uH(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 fH(t){Nl(new ua("auth",(e,{options:n})=>{const s=e.getProvider("app").getImmediate(),o=e.getProvider("heartbeat"),l=e.getProvider("app-check-internal"),{apiKey:c,authDomain:f}=s.options;Ce(c&&!c.includes(":"),"invalid-api-key",{appName:s.name});const d={apiKey:c,authDomain:f,clientPlatform:t,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:KN(t)},m=new A8(s,o,l,d);return V8(m,n),m},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,n,s)=>{e.getProvider("auth-internal").initialize()})),Nl(new ua("auth-internal",e=>{const n=uo(e.getProvider("auth").getImmediate());return(s=>new cH(s))(n)},"PRIVATE").setInstantiationMode("EXPLICIT")),Fr(WA,XA,uH(t)),Fr(WA,XA,"esm2020")}const hH=300,dH=B2("authIdTokenMaxAge")||hH;let ZA=null;const mH=t=>async e=>{const n=e&&await e.getIdTokenResult(),s=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(s&&s>dH)return;const o=n?.token;ZA!==o&&(ZA=o,await fetch(t,{method:o?"POST":"DELETE",headers:o?{Authorization:`Bearer ${o}`}:{}}))};function pH(t=$2()){const e=Zb(t,"auth");if(e.isInitialized())return e.getImmediate();const n=k8(t,{popupRedirectResolver:lH,persistence:[bq,aq,sP]}),s=B2("authTokenSyncURL");if(s&&typeof isSecureContext=="boolean"&&isSecureContext){const l=new URL(s,location.origin);if(location.origin===l.origin){const c=mH(l.toString());nq(n,c,()=>c(n.currentUser)),tq(n,f=>c(f))}}const o=U2("auth");return o&&j8(n,`http://${o}`),n}function gH(){return document.getElementsByTagName("head")?.[0]??document}R8({loadJS(t){return new Promise((e,n)=>{const s=document.createElement("script");s.setAttribute("src",t),s.onload=e,s.onerror=o=>{const l=Ns("internal-error");l.customData=o,n(l)},s.type="text/javascript",s.charset="UTF-8",gH().appendChild(s)})},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="});fH("Browser");const yH={apiKey:"AIzaSyD0Mbnkf_DdWK4K1MjTXPnQ_VJTrTmVgEU",authDomain:"pr7store-f134f.firebaseapp.com",projectId:"pr7store-f134f",storageBucket:"pr7store-f134f.firebasestorage.app",messagingSenderId:"894492814543",appId:"1:894492814543:web:da3d455cf4e1a561c61bba",measurementId:"G-GQ7F3QCKHD"},hP=G2(yH),ou=pH(hP),rs=M7(hP),vH=new Oi,bH="medobytox@gmail.com";var _H=Symbol.for("react.lazy"),om=Jv[" use ".trim().toString()];function TH(t){return typeof t=="object"&&t!==null&&"then"in t}function dP(t){return t!=null&&typeof t=="object"&&"$typeof"in t&&t.$typeof===_H&&"_payload"in t&&TH(t._payload)}function wH(t){const e=EH(t),n=I.forwardRef((s,o)=>{let{children:l,...c}=s;dP(l)&&typeof om=="function"&&(l=om(l._payload));const f=I.Children.toArray(l),d=f.find(AH);if(d){const m=d.props.children,g=f.map(v=>v===d?I.Children.count(m)>1?I.Children.only(null):I.isValidElement(m)?m.props.children:null:v);return b.jsx(e,{...c,ref:o,children:I.isValidElement(m)?I.cloneElement(m,void 0,g):null})}return b.jsx(e,{...c,ref:o,children:l})});return n.displayName=`${t}.Slot`,n}var xH=wH("Slot");function EH(t){const e=I.forwardRef((n,s)=>{let{children:o,...l}=n;if(dP(o)&&typeof om=="function"&&(o=om(o._payload)),I.isValidElement(o)){const c=CH(o),f=RH(l,o.props);return o.type!==I.Fragment&&(f.ref=s?ib(s,c):c),I.cloneElement(o,f)}return I.Children.count(o)>1?I.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var SH=Symbol("radix.slottable");function AH(t){return I.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===SH}function RH(t,e){const n={...e};for(const s in e){const o=t[s],l=e[s];/^on[A-Z]/.test(s)?o&&l?n[s]=(...f)=>{const d=l(...f);return o(...f),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...l}:s==="className"&&(n[s]=[o,l].filter(Boolean).join(" "))}return{...t,...n}}function CH(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}const IH=G1("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover-elevate active-elevate-2",{variants:{variant:{default:"bg-primary text-primary-foreground border border-primary-border",destructive:"bg-destructive text-destructive-foreground shadow-sm border-destructive-border",outline:" border [border-color:var(--button-outline)] shadow-xs active:shadow-none ",secondary:"border bg-secondary text-secondary-foreground border border-secondary-border ",ghost:"border border-transparent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"min-h-9 px-4 py-2",sm:"min-h-8 rounded-md px-3 text-xs",lg:"min-h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Ps=I.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...o},l)=>{const c=s?xH:"button";return b.jsx(c,{className:Yt(IH({variant:e,size:n,className:t})),ref:l,...o})});Ps.displayName="Button";const Vl={bronze:{bg:"bg-gradient-to-br from-stone-300 to-stone-500",iconColor:"text-stone-700",badge:"bg-stone-600 text-white"},silver:{bg:"bg-gradient-to-br from-zinc-200 to-zinc-400",iconColor:"text-zinc-700",badge:"bg-zinc-500 text-white"},gold:{bg:"bg-gradient-to-br from-yellow-300 to-amber-500",iconColor:"text-yellow-900",badge:"bg-amber-600 text-white"},diamond:{bg:"bg-gradient-to-br from-cyan-200 to-sky-400",iconColor:"text-sky-900",badge:"bg-sky-600 text-white"},platinum:{bg:"bg-gradient-to-br from-gray-700 to-gray-900",iconColor:"text-gray-200",badge:"bg-gray-900 text-white"},legend:{bg:"bg-gradient-to-br from-red-700 via-gray-900 to-black",iconColor:"text-red-300",badge:"bg-black text-red-400 border border-red-800"},offer:{bg:"bg-gradient-to-br from-green-400 to-emerald-600",iconColor:"text-white",badge:"bg-emerald-700 text-white"}},mP=I.createContext(null);function NH({children:t}){const[e,n]=I.useState([]),[s,o]=I.useState(null),l=T=>{n(E=>E.find(P=>P.productId===T.productId)?E.map(P=>P.productId===T.productId?{...P,quantity:P.quantity+1}:P):[...E,{...T,quantity:1}])},c=T=>{n(E=>E.filter(R=>R.productId!==T))},f=()=>{n([]),o(null)},d=e.reduce((T,E)=>T+E.priceNum*E.quantity,0),m=s?Math.round(d*s.discount/100):0,g=d-m,v=e.reduce((T,E)=>T+E.quantity,0);return b.jsx(mP.Provider,{value:{items:e,addToCart:l,removeFromCart:c,clearCart:f,subtotal:d,count:v,coupon:s,setCoupon:o,discountAmount:m,total:g},children:t})}function yf(){const t=I.useContext(mP);if(!t)throw new Error("useCart must be used inside CartProvider");return t}function PH({product:t}){const[,e]=io(),{addToCart:n}=yf(),s=Vl[t.tier]??Vl.bronze,o=f=>{f.stopPropagation(),n({productId:t.id,name:t.name,amount:t.amount,priceNum:t.priceNum,imageUrl:t.imageUrl,tier:t.tier})},c=`https://wa.me/966500000000?text=${encodeURIComponent(`مرحباً، أريد طلب: ${t.name} - ${t.amount} GTA$ بسعر ${t.price}`)}`;return b.jsxs(Cs.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.3},className:"bg-card border border-card-border rounded-2xl overflow-hidden flex flex-col shadow-sm hover:shadow-md transition-shadow cursor-pointer","data-testid":`card-product-${t.id}`,onClick:()=>e(`/product/${t.id}`),children:[b.jsxs("div",{className:`relative w-full h-36 flex items-center justify-center ${t.imageUrl?"":s.bg}`,children:[t.imageUrl?b.jsx("img",{src:t.imageUrl,alt:t.name,className:"w-full h-full object-cover"}):b.jsx(Cu,{className:`w-14 h-14 ${s.iconColor} drop-shadow-lg`}),b.jsx("span",{className:`absolute top-3 right-3 text-[11px] font-bold px-2 py-0.5 rounded-full ${s.badge}`,children:t.category})]}),b.jsxs("div",{className:"flex flex-col gap-2 p-4 flex-1",children:[b.jsx("h3",{className:"font-black text-base leading-tight",children:t.name}),b.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed line-clamp-2",children:t.description}),b.jsxs("p",{className:"text-secondary text-sm font-semibold mt-1",children:[t.amount," GTA$"]}),b.jsxs("div",{className:"flex items-center justify-between mt-auto pt-3 border-t border-border",children:[b.jsx("span",{className:"font-black text-xl",children:t.price}),b.jsxs("div",{className:"flex gap-2",children:[b.jsx("button",{"data-testid":`btn-whatsapp-${t.id}`,onClick:f=>{f.stopPropagation(),window.open(c,"_blank")},className:"bg-[#25D366] hover:bg-[#1ebe5d] text-white rounded-full p-2 transition-colors",title:"اطلب عبر واتساب",children:b.jsx(Iu,{className:"w-4 h-4"})}),b.jsxs(Ps,{"data-testid":`btn-add-cart-${t.id}`,onClick:o,size:"sm",className:"rounded-full px-3 font-bold flex items-center gap-1",children:[b.jsx(pm,{className:"w-4 h-4"}),b.jsx("span",{className:"text-xs",children:"سلة"})]})]})]})]})]})}const DH="/assets/pr7-store-banner-DYfvBCWk.png",OH=["الكل","شحن مباشر","باقات","عروض","VIP"];function MH(t){const[e,n]=I.useState("الكل"),[s,o]=I.useState([]),[l,c]=I.useState(!0);I.useEffect(()=>{const d=D0(ea(rs,"products"),IN("createdAt","desc"));xu(d).then(m=>{o(m.docs.map(g=>({id:g.id,...g.data()})))}).finally(()=>c(!1))},[]);const f=e==="الكل"?s:s.filter(d=>d.category===e);return b.jsxs("div",{className:"flex flex-col min-h-screen",children:[b.jsx("div",{className:"w-full",children:b.jsx("img",{src:DH,alt:"Pr7 Store Banner",className:"w-full h-[180px] md:h-[260px] object-cover","data-testid":"img-banner"})}),b.jsxs("div",{className:"px-4 py-6 md:px-8 max-w-7xl mx-auto w-full",children:[b.jsx("div",{className:"flex overflow-x-auto pb-3 gap-2 no-scrollbar scroll-smooth","data-testid":"category-tabs",children:OH.map(d=>b.jsx("button",{"data-testid":`tab-category-${d}`,onClick:()=>n(d),className:Yt("px-5 py-2 rounded-full whitespace-nowrap text-sm font-bold transition-all border",e===d?"bg-primary text-primary-foreground border-primary":"bg-card text-foreground border-card-border hover:bg-card-border"),children:d},d))}),l?b.jsx("div",{className:"flex justify-center py-20",children:b.jsx(os,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):f.length===0?b.jsxs("div",{className:"flex flex-col items-center justify-center py-24 gap-4 text-muted-foreground",children:[b.jsx(Sl,{className:"w-14 h-14 opacity-20"}),b.jsx("p",{className:"font-bold text-base",children:"لا توجد منتجات في هذا القسم بعد"})]}):b.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 mt-4",children:f.map((d,m)=>b.jsx(Cs.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:m*.06,duration:.3},children:b.jsx(PH,{product:d})},d.id))})]})]})}function kH(){const{items:t,removeFromCart:e,coupon:n,setCoupon:s,subtotal:o,discountAmount:l,total:c}=yf(),[,f]=io(),[d,m]=I.useState(n?.code??""),[g,v]=I.useState(!1),[T,E]=I.useState(""),R=async()=>{if(d.trim()){v(!0),E(""),s(null);try{const N=D0(ea(rs,"coupons"),IA("code","==",d.toUpperCase().trim()),IA("active","==",!0)),L=await xu(N);if(L.empty)E("الكوبون غير صالح أو منتهي الصلاحية");else{const z=L.docs[0].data();s({code:z.code,discount:z.discount})}}catch{E("حدث خطأ، حاول مجدداً")}finally{v(!1)}}},P=()=>{s(null),m(""),E("")};return b.jsxs("div",{className:"px-4 py-6 md:px-8 max-w-3xl mx-auto w-full min-h-screen flex flex-col pb-28",children:[b.jsx("h1",{className:"text-2xl font-black mb-6",children:"السلة"}),t.length===0?b.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center gap-4 text-muted-foreground mt-20",children:[b.jsx("div",{className:"w-20 h-20 bg-muted rounded-full flex items-center justify-center",children:b.jsx(pm,{className:"w-10 h-10"})}),b.jsx("p",{className:"text-lg font-bold",children:"سلتك فارغة"}),b.jsx("p",{className:"text-sm",children:"أضف منتجات للسلة لإتمام طلبك"}),b.jsx(Ps,{onClick:()=>f("/"),className:"mt-2",children:"تصفح المنتجات"})]}):b.jsxs("div",{className:"flex flex-col gap-5",children:[b.jsx("div",{className:"flex flex-col gap-3",children:t.map(N=>{const L=Vl[N.tier]??Vl.bronze;return b.jsxs("div",{className:"bg-card border border-card-border p-4 rounded-xl flex items-center justify-between gap-3",children:[b.jsxs("div",{className:"flex items-center gap-3",children:[N.imageUrl?b.jsx("img",{src:N.imageUrl,alt:N.name,className:"w-12 h-12 rounded-lg object-cover border border-border"}):b.jsx("div",{className:`w-12 h-12 rounded-lg ${L.bg} flex items-center justify-center`,children:b.jsx(Cu,{className:`w-6 h-6 ${L.iconColor}`})}),b.jsxs("div",{children:[b.jsx("h3",{className:"font-bold text-sm",children:N.name}),b.jsxs("p",{className:"text-xs text-secondary",children:[N.amount," GTA$ × ",N.quantity]})]})]}),b.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[b.jsxs("span",{className:"font-bold",children:[N.priceNum*N.quantity," ريال"]}),b.jsx("button",{"data-testid":`btn-remove-${N.productId}`,onClick:()=>e(N.productId),className:"text-destructive hover:bg-destructive/10 p-2 rounded-lg transition-colors",children:b.jsx(Xy,{className:"w-4 h-4"})})]})]},N.productId)})}),b.jsxs("div",{className:"bg-card border border-card-border rounded-xl p-4 flex flex-col gap-3",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx(Wy,{className:"w-4 h-4 text-primary"}),b.jsx("span",{className:"font-bold text-sm",children:"كوبون الخصم"})]}),n?b.jsxs("div",{className:"flex items-center justify-between bg-green-50 border border-green-200 rounded-xl px-4 py-3",children:[b.jsxs("div",{className:"flex items-center gap-2 text-green-700",children:[b.jsx(Ru,{className:"w-4 h-4"}),b.jsx("span",{className:"font-bold text-sm font-mono",children:n.code}),b.jsxs("span",{className:"text-xs",children:["— خصم ",n.discount,"%"]})]}),b.jsx("button",{onClick:P,className:"text-green-700 hover:text-red-500",children:b.jsx(Vx,{className:"w-4 h-4"})})]}):b.jsxs("div",{className:"flex gap-2",children:[b.jsx("input",{"data-testid":"input-coupon",type:"text",placeholder:"أدخل كود الخصم",value:d,onChange:N=>{m(N.target.value.toUpperCase()),E("")},onKeyDown:N=>{N.key==="Enter"&&R()},className:"flex-1 bg-background border border-border rounded-xl px-4 py-2.5 text-sm font-mono font-bold focus:outline-none focus:ring-2 focus:ring-primary"}),b.jsx(Ps,{"data-testid":"btn-apply-coupon",onClick:R,disabled:g||!d.trim(),className:"rounded-xl px-4 font-bold",children:g?b.jsx(os,{className:"w-4 h-4 animate-spin"}):"تطبيق"})]}),T&&b.jsxs("p",{className:"text-destructive text-xs font-medium flex items-center gap-1",children:[b.jsx(Vx,{className:"w-3.5 h-3.5"})," ",T]})]}),b.jsxs("div",{className:"bg-card border border-card-border p-5 rounded-xl",children:[b.jsx("h3",{className:"font-bold mb-4",children:"ملخص الطلب"}),b.jsxs("div",{className:"flex flex-col gap-2 mb-4",children:[b.jsxs("div",{className:"flex justify-between text-sm",children:[b.jsx("span",{className:"text-muted-foreground",children:"المجموع الفرعي"}),b.jsxs("span",{className:"font-semibold",children:[o," ريال"]})]}),n&&b.jsxs("div",{className:"flex justify-between text-sm text-green-600",children:[b.jsxs("span",{children:["خصم (",n.discount,"%)"]}),b.jsxs("span",{className:"font-semibold",children:["- ",l," ريال"]})]}),b.jsx("div",{className:"h-px bg-border my-1"}),b.jsxs("div",{className:"flex justify-between",children:[b.jsx("span",{className:"font-black",children:"الإجمالي"}),b.jsxs("span",{className:"text-2xl font-black",children:[c," ريال"]})]})]}),b.jsx(Ps,{"data-testid":"btn-checkout",onClick:()=>f("/checkout"),className:"w-full font-bold text-lg h-14 rounded-xl",children:"إتمام الطلب وإنشاء فاتورة"})]})]})]})}function VH(t){const e=I.useRef({value:t,previous:t});return I.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var Wm="Switch",[jH]=Qu(Wm),[LH,UH]=jH(Wm),pP=I.forwardRef((t,e)=>{const{__scopeSwitch:n,name:s,checked:o,defaultChecked:l,required:c,disabled:f,value:d="on",onCheckedChange:m,form:g,...v}=t,[T,E]=I.useState(null),R=$n(e,B=>E(B)),P=I.useRef(!1),N=T?g||!!T.closest("form"):!0,[L,z]=x1({prop:o,defaultProp:l??!1,onChange:m,caller:Wm});return b.jsxs(LH,{scope:n,checked:L,disabled:f,children:[b.jsx(pn.button,{type:"button",role:"switch","aria-checked":L,"aria-required":c,"data-state":bP(L),"data-disabled":f?"":void 0,disabled:f,value:d,...v,ref:R,onClick:Dt(t.onClick,B=>{z(H=>!H),N&&(P.current=B.isPropagationStopped(),P.current||B.stopPropagation())})}),N&&b.jsx(vP,{control:T,bubbles:!P.current,name:s,value:d,checked:L,required:c,disabled:f,form:g,style:{transform:"translateX(-100%)"}})]})});pP.displayName=Wm;var gP="SwitchThumb",yP=I.forwardRef((t,e)=>{const{__scopeSwitch:n,...s}=t,o=UH(gP,n);return b.jsx(pn.span,{"data-state":bP(o.checked),"data-disabled":o.disabled?"":void 0,...s,ref:e})});yP.displayName=gP;var zH="SwitchBubbleInput",vP=I.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:s=!0,...o},l)=>{const c=I.useRef(null),f=$n(c,l),d=VH(n),m=AR(e);return I.useEffect(()=>{const g=c.current;if(!g)return;const v=window.HTMLInputElement.prototype,E=Object.getOwnPropertyDescriptor(v,"checked").set;if(d!==n&&E){const R=new Event("click",{bubbles:s});E.call(g,n),g.dispatchEvent(R)}},[d,n,s]),b.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:f,style:{...o.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});vP.displayName=zH;function bP(t){return t?"checked":"unchecked"}var _P=pP,BH=yP;const TP=I.forwardRef(({className:t,...e},n)=>b.jsx(_P,{className:Yt("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...e,ref:n,children:b.jsx(BH,{className:Yt("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));TP.displayName=_P.displayName;const wP=I.createContext(null);function FH({children:t}){const[e,n]=I.useState(null),[s,o]=I.useState(!0);I.useEffect(()=>sq(ou,v=>{n(v),o(!1)}),[]);const l=async(g,v)=>{await Z8(ou,g,v)},c=async(g,v,T)=>{const E=await X8(ou,g,v);await eq(E.user,{displayName:T})},f=async()=>{await Eq(ou,vH)},d=async()=>{await iq(ou)},m=e?.email===bH;return b.jsx(wP.Provider,{value:{user:e,loading:s,isAdmin:m,loginWithEmail:l,registerWithEmail:c,loginWithGoogle:f,logout:d},children:t})}function Xm(){const t=I.useContext(wP);if(!t)throw new Error("useAuth must be used inside AuthProvider");return t}function qH(){const{user:t,loading:e,isAdmin:n,logout:s}=Xm(),[,o]=io(),l=async()=>{await s()};return e?b.jsx("div",{className:"flex items-center justify-center min-h-screen",children:b.jsx(os,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):t?b.jsxs("div",{className:"px-4 py-6 md:px-8 max-w-3xl mx-auto w-full min-h-screen bg-card/30 pb-28",children:[b.jsx("h1",{className:"text-2xl font-black mb-6",children:"الحساب"}),b.jsxs("div",{className:"bg-card border border-card-border p-6 rounded-2xl flex items-center gap-4 mb-6",children:[t.photoURL?b.jsx("img",{src:t.photoURL,alt:"avatar",className:"w-16 h-16 rounded-full object-cover border-2 border-border shrink-0"}):b.jsx("div",{className:"w-16 h-16 bg-primary text-primary-foreground rounded-full flex items-center justify-center shrink-0 text-2xl font-black",children:(t.displayName||t.email||"U").charAt(0).toUpperCase()}),b.jsxs("div",{className:"min-w-0",children:[b.jsx("h2",{className:"text-xl font-bold truncate",children:t.displayName||"مستخدم"}),b.jsx("p",{className:"text-secondary text-sm truncate",children:t.email}),n&&b.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-primary text-primary-foreground px-2 py-0.5 rounded-full font-bold mt-1",children:[b.jsx(Yy,{className:"w-3 h-3"})," أدمن"]})]})]}),n&&b.jsxs("button",{"data-testid":"btn-admin-panel",onClick:()=>o("/admin"),className:"w-full bg-primary text-primary-foreground font-bold py-3 rounded-xl hover:opacity-90 transition-opacity mb-6 flex items-center justify-center gap-2",children:[b.jsx(Yy,{className:"w-5 h-5"}),"لوحة الأدمن — نشر المنتجات والكوبونات"]}),b.jsxs("div",{className:"flex flex-col gap-4",children:[b.jsxs("div",{className:"bg-card border border-card-border rounded-2xl overflow-hidden",children:[b.jsxs("div",{className:"p-4 border-b border-card-border flex items-center gap-3",children:[b.jsx(Sl,{className:"w-5 h-5 text-primary"}),b.jsx("h3",{className:"font-bold",children:"سجل الطلبات"})]}),b.jsxs("div",{className:"p-8 text-center text-muted-foreground flex flex-col items-center gap-2",children:[b.jsx(Sl,{className:"w-8 h-8 opacity-20"}),b.jsx("p",{className:"text-sm font-medium",children:"لا توجد طلبات بعد"})]})]}),b.jsxs("div",{className:"bg-card border border-card-border rounded-2xl overflow-hidden",children:[b.jsxs("div",{className:"p-4 border-b border-card-border flex items-center gap-3",children:[b.jsx($k,{className:"w-5 h-5 text-primary"}),b.jsx("h3",{className:"font-bold",children:"الإعدادات"})]}),b.jsx("div",{className:"p-4 flex flex-col gap-4",children:b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center gap-3",children:[b.jsx(uk,{className:"w-5 h-5 text-secondary"}),b.jsx("span",{className:"font-medium",children:"الإشعارات"})]}),b.jsx(TP,{defaultChecked:!0})]})})]}),b.jsx("div",{className:"bg-card border border-card-border rounded-2xl overflow-hidden mt-2",children:b.jsxs("button",{"data-testid":"btn-logout",onClick:l,className:"w-full p-4 flex items-center justify-between text-destructive hover:bg-destructive/5 transition-colors",children:[b.jsxs("div",{className:"flex items-center gap-3",children:[b.jsx(jk,{className:"w-5 h-5"}),b.jsx("span",{className:"font-bold",children:"تسجيل الخروج"})]}),b.jsx(mk,{className:"w-5 h-5 opacity-50"})]})})]})]}):b.jsxs("div",{className:"px-6 py-12 max-w-sm mx-auto flex flex-col items-center gap-6 text-center",children:[b.jsx("div",{className:"w-20 h-20 bg-muted rounded-full flex items-center justify-center",children:b.jsx(gm,{className:"w-10 h-10 text-muted-foreground"})}),b.jsxs("div",{children:[b.jsx("h2",{className:"text-xl font-black mb-1",children:"مرحباً بك في Pr7 Store"}),b.jsx("p",{className:"text-muted-foreground text-sm",children:"سجّل دخولك لمتابعة طلباتك والاستفادة من العروض"})]}),b.jsx("button",{"data-testid":"btn-go-login",onClick:()=>o("/auth"),className:"w-full bg-primary text-primary-foreground font-bold py-3 rounded-xl hover:opacity-90 transition-opacity",children:"تسجيل الدخول / إنشاء حساب"})]})}const Xo=[{id:1,name:"محمد العمري",rating:5,text:"خدمة ممتازة وسريعة جداً، تسليم فوري خلال دقائق",date:"منذ يومين"},{id:2,name:"سلطان الغامدي",rating:5,text:"أفضل متجر لشحن GTA، تسليم موثوق ومضمون 100%",date:"منذ أسبوع"},{id:3,name:"فيصل الشمري",rating:4,text:"تعامل راقي وأسعار منافسة، تسليم سريع أنصح الجميع",date:"منذ أسبوعين"},{id:4,name:"نواف القحطاني",rating:5,text:"ثالث مرة أشتري من هنا والتسليم دايم فوري",date:"منذ شهر"},{id:5,name:"خالد الزهراني",rating:5,text:"تسليم فوري وما في أي مشاكل، شكراً Pr7 Store",date:"منذ شهر"}];function HH({id:t}){const[,e]=io(),{addToCart:n}=yf(),[s,o]=I.useState(null),[l,c]=I.useState(!0),[f,d]=I.useState("PS5"),[m,g]=I.useState(!1);if(I.useEffect(()=>{K7(_l(rs,"products",t)).then(z=>{z.exists()&&o({id:z.id,...z.data()}),c(!1)})},[t]),l)return b.jsx("div",{className:"flex items-center justify-center min-h-screen",children:b.jsx(os,{className:"w-8 h-8 animate-spin text-muted-foreground"})});if(!s)return b.jsxs("div",{className:"flex flex-col items-center justify-center min-h-screen gap-4 text-center px-6",children:[b.jsx(Sl,{className:"w-16 h-16 opacity-20"}),b.jsx("p",{className:"text-2xl font-black",children:"المنتج غير موجود"}),b.jsx(Ps,{onClick:()=>e("/"),children:"العودة للرئيسية"})]});const v=Vl[s.tier]??Vl.bronze,T=(Xo.reduce((z,B)=>z+B.rating,0)/Xo.length).toFixed(1),E=m?Xo:Xo.slice(0,3),P=`https://wa.me/966500000000?text=${encodeURIComponent(`مرحباً، أريد طلب: ${s.name} الكمية: ${s.amount} GTA$ المنصة: ${f} السعر: ${s.price}`)}`,N=()=>{n({productId:s.id,name:s.name,amount:s.amount,priceNum:s.priceNum,imageUrl:s.imageUrl,tier:s.tier}),e("/cart")},L=s.platform??["PS4","PS5","Xbox","PC"];return b.jsxs("div",{className:"flex flex-col min-h-screen bg-background pb-28",children:[b.jsxs("div",{className:"sticky top-0 z-40 bg-background/95 backdrop-blur border-b border-border flex items-center gap-3 px-4 h-14",children:[b.jsx("button",{"data-testid":"btn-back",onClick:()=>e("/"),className:"p-2 rounded-full hover:bg-muted",children:b.jsx(mm,{className:"w-5 h-5"})}),b.jsx("span",{className:"font-bold text-base truncate flex-1",children:s.name})]}),b.jsx(Cs.div,{initial:{opacity:0},animate:{opacity:1},className:`w-full h-56 md:h-72 relative flex flex-col items-center justify-center gap-3 ${s.imageUrl?"":v.bg}`,children:s.imageUrl?b.jsx("img",{src:s.imageUrl,alt:s.name,className:"w-full h-full object-cover"}):b.jsxs(b.Fragment,{children:[b.jsx(Cu,{className:`w-20 h-20 ${v.iconColor} drop-shadow-2xl`}),b.jsx("span",{className:`text-xs font-bold px-3 py-1 rounded-full ${v.badge}`,children:s.category})]})}),b.jsx(Cs.div,{initial:{y:24,opacity:0},animate:{y:0,opacity:1},transition:{delay:.1},className:"mx-4 -mt-4 bg-background border border-border rounded-2xl shadow-md overflow-hidden",children:b.jsxs("div",{className:"p-5",children:[b.jsx("h1",{className:"text-2xl font-black mb-1",children:s.name}),b.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed mb-4",children:s.description}),b.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[b.jsx("div",{className:"flex gap-0.5",children:Array.from({length:5}).map((z,B)=>b.jsx(Ux,{className:`w-4 h-4 ${Bb.jsx("button",{"data-testid":`btn-platform-${z}`,onClick:()=>d(z),className:`px-4 py-2 rounded-xl text-sm font-bold border transition-all ${f===z?"bg-primary text-primary-foreground border-primary":"bg-card border-card-border hover:bg-muted"}`,children:z},z))})]}),s.details?.length>0&&b.jsxs("div",{className:"bg-card border border-card-border rounded-xl p-4 mb-5",children:[b.jsx("p",{className:"font-bold text-sm mb-3",children:"تفاصيل الباقة"}),b.jsx("ul",{className:"flex flex-col gap-2",children:s.details.map((z,B)=>b.jsxs("li",{className:"flex items-center gap-2 text-sm text-secondary",children:[b.jsx(Ru,{className:"w-4 h-4 text-primary flex-shrink-0"}),b.jsx("span",{children:z})]},B))})]}),b.jsx("div",{className:"grid grid-cols-3 gap-2 mb-5",children:[{icon:nV,label:"تسليم فوري"},{icon:Yy,label:"مضمون 100%"},{icon:Iu,label:"دعم واتساب"}].map(({icon:z,label:B})=>b.jsxs("div",{className:"flex flex-col items-center gap-1 bg-muted rounded-xl p-3",children:[b.jsx(z,{className:"w-5 h-5 text-primary"}),b.jsx("span",{className:"text-[11px] font-bold text-center",children:B})]},B))})]})}),b.jsxs("div",{className:"mx-4 mt-6",children:[b.jsxs("div",{className:"flex items-center justify-between mb-4",children:[b.jsx("h2",{className:"text-xl font-black",children:"تقييمات العملاء"}),b.jsxs("span",{className:"text-muted-foreground text-sm",children:[Xo.length," تقييم"]})]}),b.jsx("div",{className:"flex flex-col gap-3",children:E.map(z=>b.jsxs("div",{className:"bg-card border border-card-border p-4 rounded-xl flex flex-col gap-2",children:[b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center text-primary font-black text-sm",children:z.name.charAt(0)}),b.jsx("span",{className:"font-bold text-sm",children:z.name})]}),b.jsx("span",{className:"text-xs text-muted-foreground",children:z.date})]}),b.jsx("div",{className:"flex gap-0.5",children:Array.from({length:5}).map((B,H)=>b.jsx(Ux,{className:`w-3.5 h-3.5 ${H3&&b.jsx("button",{onClick:()=>g(z=>!z),className:"mt-3 w-full flex items-center justify-center gap-2 text-sm font-bold text-muted-foreground py-3 border border-border rounded-xl hover:bg-muted transition-colors",children:m?b.jsxs(b.Fragment,{children:["إخفاء ",b.jsx(gk,{className:"w-4 h-4"})]}):b.jsxs(b.Fragment,{children:["عرض كل التقييمات ",b.jsx(hk,{className:"w-4 h-4"})]})})]}),b.jsxs("div",{className:"fixed bottom-16 md:bottom-0 left-0 right-0 z-40 bg-background border-t border-border px-4 py-3 flex items-center gap-3",children:[b.jsxs("div",{className:"flex flex-col",children:[b.jsx("span",{className:"text-xs text-muted-foreground",children:"السعر"}),b.jsx("span",{className:"text-2xl font-black",children:s.price})]}),b.jsxs("div",{className:"flex gap-2 flex-1",children:[b.jsxs("button",{"data-testid":"btn-whatsapp-order",onClick:()=>window.open(P,"_blank"),className:"flex-1 bg-[#25D366] hover:bg-[#1ebe5d] text-white font-bold rounded-xl py-3 flex items-center justify-center gap-2 transition-colors",children:[b.jsx(Iu,{className:"w-5 h-5"}),b.jsx("span",{children:"اطلب الآن"})]}),b.jsxs(Ps,{"data-testid":"btn-add-cart-detail",onClick:N,className:"flex-1 rounded-xl py-3 font-bold flex items-center justify-center gap-2",children:[b.jsx(pm,{className:"w-5 h-5"}),b.jsx("span",{children:"أضف للسلة"})]})]})]})]})}function GH(){const[t,e]=I.useState("login"),[n,s]=I.useState(""),[o,l]=I.useState(""),[c,f]=I.useState(""),[d,m]=I.useState(!1),[g,v]=I.useState(!1),[T,E]=I.useState(""),[,R]=io(),{loginWithEmail:P,registerWithEmail:N,loginWithGoogle:L}=Xm(),z=async H=>{H.preventDefault(),E(""),v(!0);try{if(t==="login")await P(o,c);else{if(!n.trim()){E("أدخل اسمك"),v(!1);return}await N(o,c,n)}R("/account")}catch(K){const te=K?.code;E(te==="auth/user-not-found"||te==="auth/wrong-password"||te==="auth/invalid-credential"?"البريد الإلكتروني أو كلمة المرور غير صحيحة":te==="auth/email-already-in-use"?"البريد الإلكتروني مستخدم مسبقاً":te==="auth/weak-password"?"كلمة المرور يجب أن تكون 6 أحرف على الأقل":"حدث خطأ، حاول مجدداً")}finally{v(!1)}},B=async()=>{E(""),v(!0);try{await L(),R("/account")}catch{E("فشل تسجيل الدخول بجوجل، حاول فتح الموقع في تبويب جديد")}finally{v(!1)}};return b.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[b.jsxs("div",{className:"sticky top-0 z-40 bg-background/95 backdrop-blur border-b border-border flex items-center gap-3 px-4 h-14",children:[b.jsx("button",{onClick:()=>R("/"),className:"p-2 rounded-full hover:bg-muted transition-colors",children:b.jsx(mm,{className:"w-5 h-5"})}),b.jsx("span",{className:"font-bold text-base",children:t==="login"?"تسجيل الدخول":"إنشاء حساب"})]}),b.jsx("div",{className:"flex-1 flex flex-col items-center justify-center px-6 py-10",children:b.jsxs(Cs.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"w-full max-w-sm",children:[b.jsxs("div",{className:"text-center mb-8",children:[b.jsx("p",{className:"text-3xl font-black",children:"Pr7 Store"}),b.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:t==="login"?"أهلاً بعودتك":"أنشئ حسابك الآن"})]}),b.jsxs("button",{"data-testid":"btn-google-login",onClick:B,disabled:g,className:"w-full flex items-center justify-center gap-3 border border-border bg-card hover:bg-muted rounded-xl py-3 font-bold transition-colors mb-6 disabled:opacity-60",children:[b.jsx($j,{className:"w-5 h-5"}),"المتابعة مع Google"]}),b.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[b.jsx("div",{className:"flex-1 h-px bg-border"}),b.jsx("span",{className:"text-xs text-muted-foreground",children:"أو بالبريد الإلكتروني"}),b.jsx("div",{className:"flex-1 h-px bg-border"})]}),b.jsxs("form",{onSubmit:z,className:"flex flex-col gap-4",children:[b.jsx(zU,{children:t==="register"&&b.jsx(Cs.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"overflow-hidden",children:b.jsxs("div",{className:"relative",children:[b.jsx(gm,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground"}),b.jsx("input",{"data-testid":"input-display-name",type:"text",placeholder:"الاسم",value:n,onChange:H=>s(H.target.value),className:"w-full bg-card border border-card-border rounded-xl px-4 py-3 pr-10 text-sm font-medium focus:outline-none focus:ring-2 focus:ring-primary"})]})})}),b.jsxs("div",{className:"relative",children:[b.jsx(K1,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground"}),b.jsx("input",{"data-testid":"input-email",type:"email",placeholder:"البريد الإلكتروني",value:o,onChange:H=>l(H.target.value),required:!0,className:"w-full bg-card border border-card-border rounded-xl px-4 py-3 pr-10 text-sm font-medium focus:outline-none focus:ring-2 focus:ring-primary"})]}),b.jsxs("div",{className:"relative",children:[b.jsx(Uk,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground"}),b.jsx("input",{"data-testid":"input-password",type:d?"text":"password",placeholder:"كلمة المرور",value:c,onChange:H=>f(H.target.value),required:!0,className:"w-full bg-card border border-card-border rounded-xl px-4 py-3 pr-10 pl-10 text-sm font-medium focus:outline-none focus:ring-2 focus:ring-primary"}),b.jsx("button",{type:"button",onClick:()=>m(H=>!H),className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:d?b.jsx(Ak,{className:"w-5 h-5"}):b.jsx(Ck,{className:"w-5 h-5"})})]}),T&&b.jsx("p",{className:"text-destructive text-sm font-medium text-center",children:T}),b.jsx(Ps,{"data-testid":"btn-auth-submit",type:"submit",disabled:g,className:"w-full h-12 rounded-xl font-bold text-base",children:g?b.jsx(os,{className:"w-5 h-5 animate-spin"}):t==="login"?"تسجيل الدخول":"إنشاء الحساب"})]}),b.jsxs("p",{className:"text-center text-sm mt-6 text-muted-foreground",children:[t==="login"?"ليس لديك حساب؟":"لديك حساب بالفعل؟"," ",b.jsx("button",{onClick:()=>{e(t==="login"?"register":"login"),E("")},className:"font-bold text-foreground underline",children:t==="login"?"أنشئ حساباً":"سجّل دخولك"})]})]})})]})}const $H=["bronze","silver","gold","diamond","platinum","legend","offer"],KH={bronze:"برونزي",silver:"فضي",gold:"ذهبي",diamond:"ماسي",platinum:"بلاتيني",legend:"أسطورة",offer:"عرض"},QH=["شحن مباشر","باقات","عروض","VIP"],YH=["PS4","PS5","Xbox","PC"],ed={pending:{label:"قيد الانتظار",classes:"bg-yellow-100 text-yellow-800 border-yellow-300"},processing:{label:"قيد المعالجة",classes:"bg-blue-100 text-blue-800 border-blue-300"},completed:{label:"مكتمل",classes:"bg-green-100 text-green-800 border-green-300"},cancelled:{label:"ملغي",classes:"bg-red-100 text-red-800 border-red-300"}};function WH(){const{isAdmin:t}=Xm(),[,e]=io(),[n,s]=I.useState("orders"),[o,l]=I.useState([]),[c,f]=I.useState(!0),[d,m]=I.useState(!1),[g,v]=I.useState(!1),[T,E]=I.useState({name:"",description:"",amount:"",priceNum:0,category:"شحن مباشر",tier:"bronze",imageUrl:"",platform:["PS5"],details:""}),[R,P]=I.useState([]),[N,L]=I.useState(!0),[z,B]=I.useState(!1),[H,K]=I.useState(!1),[te,M]=I.useState({code:"",discount:10}),[A,O]=I.useState([]),[k,j]=I.useState(!0),[F,V]=I.useState(null);I.useEffect(()=>{t||e("/")},[t,e]),I.useEffect(()=>{xu(ea(rs,"products")).then(S=>{l(S.docs.map(Q=>({id:Q.id,...Q.data()}))),f(!1)})},[]),I.useEffect(()=>{xu(ea(rs,"coupons")).then(S=>{P(S.docs.map(Q=>({id:Q.id,...Q.data()}))),L(!1)})},[]),I.useEffect(()=>{const S=D0(ea(rs,"orders"),IN("createdAt","desc"));xu(S).then(Q=>{O(Q.docs.map(ce=>({id:ce.id,...ce.data()}))),j(!1)})},[]);const ue=S=>E(Q=>({...Q,platform:Q.platform.includes(S)?Q.platform.filter(ce=>ce!==S):[...Q.platform,S]})),ye=async S=>{S.preventDefault(),m(!0);const Q=T.details.split(` `).map(fe=>fe.trim()).filter(Boolean),ce=await OA(ea(rs,"products"),{name:T.name,description:T.description,amount:T.amount,price:`${T.priceNum} ريال`,priceNum:Number(T.priceNum),category:T.category,tier:T.tier,imageUrl:T.imageUrl,platform:T.platform,details:Q.length?Q:["تسليم فوري داخل اللعبة","مضمون 100%"],createdAt:Yv()});l(fe=>[{id:ce.id,name:T.name,description:T.description,amount:T.amount,price:`${T.priceNum} ريال`,priceNum:Number(T.priceNum),category:T.category,tier:T.tier,imageUrl:T.imageUrl,platform:T.platform,details:Q},...fe]),E({name:"",description:"",amount:"",priceNum:0,category:"شحن مباشر",tier:"bronze",imageUrl:"",platform:["PS5"],details:""}),m(!1),v(!0),setTimeout(()=>v(!1),3e3)},$=async S=>{await DA(_l(rs,"products",S)),l(Q=>Q.filter(ce=>ce.id!==S))},le=async S=>{if(S.preventDefault(),!te.code.trim())return;B(!0);const Q=await OA(ea(rs,"coupons"),{code:te.code.toUpperCase().trim(),discount:Number(te.discount),active:!0,createdAt:Yv()});P(ce=>[{id:Q.id,code:te.code.toUpperCase().trim(),discount:Number(te.discount),active:!0},...ce]),M({code:"",discount:10}),B(!1),K(!0),setTimeout(()=>K(!1),3e3)},se=async S=>{await DA(_l(rs,"coupons",S)),P(Q=>Q.filter(ce=>ce.id!==S))},pe=async(S,Q,ce)=>{V(S),await Y7(_l(rs,"orders",Q),{status:ce}),O(fe=>fe.map(de=>de.id===S?{...de,status:ce}:de)),V(null)};return t?b.jsxs("div",{className:"min-h-screen bg-background pb-28",children:[b.jsxs("div",{className:"sticky top-0 z-40 bg-background/95 backdrop-blur border-b border-border flex items-center gap-3 px-4 h-14",children:[b.jsx("button",{onClick:()=>e("/account"),className:"p-2 rounded-full hover:bg-muted",children:b.jsx(mm,{className:"w-5 h-5"})}),b.jsx("span",{className:"font-black text-base",children:"لوحة الأدمن"}),b.jsx("span",{className:"ms-auto text-xs bg-primary text-primary-foreground px-2 py-0.5 rounded-full font-bold",children:"Pr7 Store"})]}),b.jsx("div",{className:"flex border-b border-border",children:["orders","products","coupons"].map(S=>b.jsxs("button",{onClick:()=>s(S),className:`flex-1 py-3 text-xs font-bold flex items-center justify-center gap-1.5 transition-colors ${n===S?"border-b-2 border-primary text-primary":"text-muted-foreground"}`,children:[S==="orders"&&b.jsxs(b.Fragment,{children:[b.jsx(jx,{className:"w-4 h-4"}),"الطلبات ",A.length>0&&b.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-4 h-4 text-[10px] flex items-center justify-center",children:A.filter(Q=>Q.status==="pending").length||""})]}),S==="products"&&b.jsxs(b.Fragment,{children:[b.jsx(Sl,{className:"w-4 h-4"}),"المنتجات"]}),S==="coupons"&&b.jsxs(b.Fragment,{children:[b.jsx(Wy,{className:"w-4 h-4"}),"الكوبونات"]})]},S))}),b.jsxs("div",{className:"px-4 py-6 max-w-2xl mx-auto",children:[n==="orders"&&b.jsxs(Cs.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:[b.jsxs("h2",{className:"font-black text-lg mb-4",children:["الطلبات الواردة (",A.length,")"]}),k?b.jsx("div",{className:"flex justify-center py-12",children:b.jsx(os,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):A.length===0?b.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground",children:[b.jsx(jx,{className:"w-12 h-12 opacity-20"}),b.jsx("p",{className:"text-sm font-bold",children:"لا توجد طلبات بعد"})]}):b.jsx("div",{className:"flex flex-col gap-4",children:A.map(S=>{const Q=S.invoiceId?.replace(/-/g,"")??S.id,ce=ed[S.status]??ed.pending,fe=S.createdAt?new Date(S.createdAt.seconds*1e3).toLocaleDateString("ar-SA"):"—";return b.jsxs("div",{className:"bg-card border border-card-border rounded-2xl p-4 flex flex-col gap-3",children:[b.jsxs("div",{className:"flex items-start justify-between gap-2",children:[b.jsxs("div",{children:[b.jsx("p",{className:"font-mono font-black text-xs tracking-wider text-muted-foreground",children:S.invoiceId}),b.jsx("p",{className:"font-bold text-sm mt-0.5",children:S.customerName}),b.jsx("p",{className:"text-xs text-muted-foreground",children:fe})]}),b.jsx("span",{className:`text-[11px] font-bold px-2 py-1 rounded-full border ${ce.classes}`,children:ce.label})]}),b.jsxs("div",{className:"bg-background rounded-xl p-3 flex flex-col gap-1",children:[S.items?.map((de,Ee)=>b.jsxs("div",{className:"flex justify-between text-xs",children:[b.jsxs("span",{className:"text-muted-foreground",children:[de.name," × ",de.quantity]}),b.jsxs("span",{className:"font-bold",children:[de.priceNum*de.quantity," ريال"]})]},Ee)),(S.discountAmount??0)>0&&b.jsxs("div",{className:"flex justify-between text-xs text-green-600 pt-1 border-t border-border",children:[b.jsxs("span",{children:["خصم (",S.couponCode,")"]}),b.jsxs("span",{children:["- ",S.discountAmount," ريال"]})]}),b.jsxs("div",{className:"flex justify-between text-sm font-black pt-1 border-t border-border",children:[b.jsx("span",{children:"الإجمالي"}),b.jsxs("span",{children:[S.total," ريال"]})]})]}),b.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[b.jsxs("a",{href:`https://wa.me/${S.customerWhatsApp}?text=${encodeURIComponent(`مرحباً ${S.customerName}، بخصوص فاتورة ${S.invoiceId}`)}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-xs font-bold bg-[#25D366] text-white px-3 py-1.5 rounded-lg",children:[b.jsx(Iu,{className:"w-3.5 h-3.5"}),S.customerWhatsApp]}),S.userEmail&&b.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[b.jsx(Q1,{className:"w-3 h-3"}),S.userEmail]})]}),b.jsx("div",{className:"flex gap-2 flex-wrap",children:["pending","processing","completed","cancelled"].map(de=>b.jsx("button",{disabled:S.status===de||F===S.id,onClick:()=>pe(S.id,Q,de),className:`text-[11px] font-bold px-3 py-1 rounded-lg border transition-all ${S.status===de?`${ed[de].classes} opacity-100`:"border-border text-muted-foreground hover:bg-muted"}`,children:F===S.id&&S.status!==de?b.jsx(os,{className:"w-3 h-3 animate-spin inline"}):ed[de].label},de))})]},S.id)})})]}),n==="products"&&b.jsxs(Cs.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:[b.jsx("h2",{className:"font-black text-lg mb-4",children:"نشر منتج جديد"}),b.jsxs("form",{onSubmit:ye,className:"bg-card border border-card-border rounded-2xl p-5 flex flex-col gap-4 mb-8",children:[b.jsxs("div",{children:[b.jsx("label",{className:"text-xs font-bold text-muted-foreground mb-1 block",children:"رابط صورة المنتج"}),b.jsxs("div",{className:"relative",children:[b.jsx(Mk,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),b.jsx("input",{type:"url",placeholder:"https://...",value:T.imageUrl,onChange:S=>E(Q=>({...Q,imageUrl:S.target.value})),className:"w-full bg-background border border-border rounded-xl px-4 py-2.5 pr-9 text-sm focus:outline-none focus:ring-2 focus:ring-primary"})]}),T.imageUrl&&b.jsx("img",{src:T.imageUrl,alt:"preview",className:"mt-2 h-24 w-full object-cover rounded-xl border border-border",onError:S=>{S.target.style.display="none"}})]}),b.jsxs("div",{children:[b.jsx("label",{className:"text-xs font-bold text-muted-foreground mb-1 block",children:"اسم المنتج"}),b.jsx("input",{required:!0,type:"text",placeholder:"باقة ذهبية...",value:T.name,onChange:S=>E(Q=>({...Q,name:S.target.value})),className:"w-full bg-background border border-border rounded-xl px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary"})]}),b.jsxs("div",{children:[b.jsx("label",{className:"text-xs font-bold text-muted-foreground mb-1 block",children:"وصف المنتج"}),b.jsx("textarea",{required:!0,rows:2,placeholder:"وصف قصير...",value:T.description,onChange:S=>E(Q=>({...Q,description:S.target.value})),className:"w-full bg-background border border-border rounded-xl px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary resize-none"})]}),b.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[b.jsxs("div",{children:[b.jsx("label",{className:"text-xs font-bold text-muted-foreground mb-1 block",children:"الكمية (GTA$)"}),b.jsx("input",{required:!0,type:"text",placeholder:"2,000,000",value:T.amount,onChange:S=>E(Q=>({...Q,amount:S.target.value})),className:"w-full bg-background border border-border rounded-xl px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary"})]}),b.jsxs("div",{children:[b.jsx("label",{className:"text-xs font-bold text-muted-foreground mb-1 block",children:"السعر (ريال)"}),b.jsx("input",{required:!0,type:"number",min:1,placeholder:"45",value:T.priceNum||"",onChange:S=>E(Q=>({...Q,priceNum:Number(S.target.value)})),className:"w-full bg-background border border-border rounded-xl px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary"})]})]}),b.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[b.jsxs("div",{children:[b.jsx("label",{className:"text-xs font-bold text-muted-foreground mb-1 block",children:"القسم"}),b.jsx("select",{value:T.category,onChange:S=>E(Q=>({...Q,category:S.target.value})),className:"w-full bg-background border border-border rounded-xl px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary",children:QH.map(S=>b.jsx("option",{children:S},S))})]}),b.jsxs("div",{children:[b.jsx("label",{className:"text-xs font-bold text-muted-foreground mb-1 block",children:"نوع الكارت"}),b.jsx("select",{value:T.tier,onChange:S=>E(Q=>({...Q,tier:S.target.value})),className:"w-full bg-background border border-border rounded-xl px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary",children:$H.map(S=>b.jsx("option",{value:S,children:KH[S]},S))})]})]}),b.jsxs("div",{children:[b.jsx("label",{className:"text-xs font-bold text-muted-foreground mb-2 block",children:"المنصات"}),b.jsx("div",{className:"flex gap-2 flex-wrap",children:YH.map(S=>b.jsx("button",{type:"button",onClick:()=>ue(S),className:`px-3 py-1.5 rounded-lg text-xs font-bold border transition-all ${T.platform.includes(S)?"bg-primary text-primary-foreground border-primary":"bg-card border-card-border"}`,children:S},S))})]}),b.jsxs("div",{children:[b.jsx("label",{className:"text-xs font-bold text-muted-foreground mb-1 block",children:"تفاصيل الباقة (سطر لكل نقطة)"}),b.jsx("textarea",{rows:3,placeholder:`تسليم فوري مضمون 100% دعم واتساب`,value:T.details,onChange:S=>E(Q=>({...Q,details:S.target.value})),className:"w-full bg-background border border-border rounded-xl px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary resize-none"})]}),g&&b.jsxs("div",{className:"flex items-center gap-2 text-sm font-bold text-green-600",children:[b.jsx(Ru,{className:"w-4 h-4"})," تم نشر المنتج!"]}),b.jsxs(Ps,{type:"submit",disabled:d,className:"w-full h-11 rounded-xl font-bold flex items-center gap-2",children:[d?b.jsx(os,{className:"w-4 h-4 animate-spin"}):b.jsx(Lx,{className:"w-4 h-4"})," نشر المنتج"]})]}),b.jsxs("h2",{className:"font-black text-lg mb-4",children:["المنتجات (",o.length,")"]}),c?b.jsx("div",{className:"flex justify-center py-8",children:b.jsx(os,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):o.length===0?b.jsx("p",{className:"text-center text-muted-foreground py-8 text-sm",children:"لا توجد منتجات بعد"}):b.jsx("div",{className:"flex flex-col gap-3",children:o.map(S=>b.jsxs("div",{className:"bg-card border border-card-border rounded-xl p-4 flex items-center justify-between gap-3",children:[b.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[S.imageUrl?b.jsx("img",{src:S.imageUrl,alt:S.name,className:"w-12 h-12 rounded-lg object-cover border border-border flex-shrink-0"}):b.jsx("div",{className:"w-12 h-12 rounded-lg bg-muted flex items-center justify-center flex-shrink-0",children:b.jsx(Sl,{className:"w-6 h-6 text-muted-foreground"})}),b.jsxs("div",{className:"min-w-0",children:[b.jsx("p",{className:"font-bold text-sm truncate",children:S.name}),b.jsxs("p",{className:"text-xs text-muted-foreground",children:[S.amount," GTA$ — ",S.price]})]})]}),b.jsx("button",{onClick:()=>$(S.id),className:"text-destructive hover:bg-destructive/10 p-2 rounded-lg transition-colors flex-shrink-0",children:b.jsx(Xy,{className:"w-4 h-4"})})]},S.id))})]}),n==="coupons"&&b.jsxs(Cs.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:[b.jsx("h2",{className:"font-black text-lg mb-4",children:"إضافة كوبون خصم"}),b.jsxs("form",{onSubmit:le,className:"bg-card border border-card-border rounded-2xl p-5 flex flex-col gap-4 mb-8",children:[b.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[b.jsxs("div",{children:[b.jsx("label",{className:"text-xs font-bold text-muted-foreground mb-1 block",children:"كود الكوبون"}),b.jsx("input",{required:!0,type:"text",placeholder:"PR7OFF20",value:te.code,onChange:S=>M(Q=>({...Q,code:S.target.value.toUpperCase()})),className:"w-full bg-background border border-border rounded-xl px-4 py-2.5 text-sm font-mono font-bold focus:outline-none focus:ring-2 focus:ring-primary"})]}),b.jsxs("div",{children:[b.jsx("label",{className:"text-xs font-bold text-muted-foreground mb-1 block",children:"نسبة الخصم (%)"}),b.jsx("input",{required:!0,type:"number",min:1,max:100,placeholder:"20",value:te.discount,onChange:S=>M(Q=>({...Q,discount:Number(S.target.value)})),className:"w-full bg-background border border-border rounded-xl px-4 py-2.5 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-primary"})]})]}),H&&b.jsxs("div",{className:"flex items-center gap-2 text-sm font-bold text-green-600",children:[b.jsx(Ru,{className:"w-4 h-4"})," تم إضافة الكوبون!"]}),b.jsxs(Ps,{type:"submit",disabled:z,className:"w-full h-11 rounded-xl font-bold flex items-center gap-2",children:[z?b.jsx(os,{className:"w-4 h-4 animate-spin"}):b.jsx(Lx,{className:"w-4 h-4"})," إضافة الكوبون"]})]}),b.jsxs("h2",{className:"font-black text-lg mb-4",children:["الكوبونات (",R.length,")"]}),N?b.jsx("div",{className:"flex justify-center py-8",children:b.jsx(os,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):R.length===0?b.jsx("p",{className:"text-center text-muted-foreground py-8 text-sm",children:"لا توجد كوبونات بعد"}):b.jsx("div",{className:"flex flex-col gap-3",children:R.map(S=>b.jsxs("div",{className:"bg-card border border-card-border rounded-xl p-4 flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center gap-3",children:[b.jsx(Wy,{className:"w-5 h-5 text-primary"}),b.jsxs("div",{children:[b.jsx("p",{className:"font-black font-mono text-sm",children:S.code}),b.jsxs("p",{className:"text-xs text-muted-foreground",children:["خصم ",S.discount,"%"]})]})]}),b.jsx("button",{onClick:()=>se(S.id),className:"text-destructive hover:bg-destructive/10 p-2 rounded-lg transition-colors",children:b.jsx(Xy,{className:"w-4 h-4"})})]},S.id))})]})]})]}):null}const XH="966500000000";function ZH(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let e="";for(let n=0;n<24;n++)e+=t[Math.floor(Math.random()*t.length)];return`${e.slice(0,6)}-${e.slice(6,12)}-${e.slice(12,18)}-${e.slice(18,24)}`}function JH(){const[,t]=io(),{user:e}=Xm(),{items:n,coupon:s,subtotal:o,discountAmount:l,total:c,clearCart:f}=yf(),[d,m]=I.useState(e?.displayName??""),[g,v]=I.useState(""),[T,E]=I.useState(!1),[R,P]=I.useState(null),[N,L]=I.useState(!1);if(n.length===0&&!R)return t("/cart"),null;const z=R?encodeURIComponent(`مرحباً Pr7 Store، لدي فاتورة طلب جديدة: رقم الفاتورة: ${R} الاسم: ${d} الإجمالي: ${c} ريال أرجو التأكيد والإتمام.`):"",B=async K=>{if(K.preventDefault(),!d.trim()||!g.trim())return;E(!0);const te=ZH(),M=te.replace(/-/g,"");try{await Q7(_l(rs,"orders",M),{invoiceId:te,customerName:d.trim(),customerWhatsApp:g.trim(),items:n.map(A=>({productId:A.productId,name:A.name,amount:A.amount,priceNum:A.priceNum,quantity:A.quantity})),subtotal:o,couponCode:s?.code??null,couponDiscount:s?.discount??0,discountAmount:l,total:c,userId:e?.uid??null,userEmail:e?.email??null,status:"pending",createdAt:Yv()}),P(te),f()}catch(A){console.error(A)}finally{E(!1)}},H=()=>{R&&(navigator.clipboard.writeText(R),L(!0),setTimeout(()=>L(!1),2500))};return b.jsxs("div",{className:"min-h-screen bg-background pb-28",children:[b.jsxs("div",{className:"sticky top-0 z-40 bg-background/95 backdrop-blur border-b border-border flex items-center gap-3 px-4 h-14",children:[!R&&b.jsx("button",{onClick:()=>t("/cart"),className:"p-2 rounded-full hover:bg-muted",children:b.jsx(mm,{className:"w-5 h-5"})}),b.jsx("span",{className:"font-black text-base",children:R?"فاتورتك جاهزة":"إتمام الطلب"})]}),b.jsx("div",{className:"max-w-md mx-auto px-4 py-6",children:R?b.jsxs(Cs.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"flex flex-col gap-5",children:[b.jsxs("div",{className:"bg-card border-2 border-dashed border-border rounded-2xl p-6 flex flex-col items-center gap-4",children:[b.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center",children:b.jsx(Nk,{className:"w-8 h-8 text-green-600"})}),b.jsxs("div",{className:"text-center",children:[b.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"رقم الفاتورة"}),b.jsx("p",{className:"text-2xl font-black font-mono tracking-widest text-center break-all",children:R})]}),b.jsxs("button",{onClick:H,className:"flex items-center gap-2 text-sm font-bold border border-border rounded-xl px-4 py-2 hover:bg-muted transition-colors",children:[N?b.jsx(Ru,{className:"w-4 h-4 text-green-600"}):b.jsx(Ek,{className:"w-4 h-4"}),N?"تم النسخ!":"نسخ رقم الفاتورة"]})]}),b.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-2xl p-5 flex flex-col gap-3",children:[b.jsx("p",{className:"font-black text-base",children:"خطوات إتمام الطلب"}),b.jsxs("ol",{className:"flex flex-col gap-2 text-sm text-amber-900",children:[b.jsxs("li",{className:"flex items-start gap-2",children:[b.jsx("span",{className:"font-black w-5 shrink-0",children:"١."}),"انسخ رقم الفاتورة أعلاه"]}),b.jsxs("li",{className:"flex items-start gap-2",children:[b.jsx("span",{className:"font-black w-5 shrink-0",children:"٢."}),"أرسله على واتساب الخاص بنا"]}),b.jsxs("li",{className:"flex items-start gap-2",children:[b.jsx("span",{className:"font-black w-5 shrink-0",children:"٣."}),"سيتواصل معك فريقنا لإتمام الدفع وتسليم الطلب"]})]})]}),b.jsxs("div",{className:"bg-card border border-card-border rounded-2xl p-4",children:[b.jsx("p",{className:"font-bold mb-3",children:"ملخص الطلب"}),b.jsxs("div",{className:"flex flex-col gap-2 text-sm",children:[b.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[b.jsx("span",{children:"المجموع الفرعي"}),b.jsxs("span",{children:[o||c," ريال"]})]}),l>0&&b.jsxs("div",{className:"flex justify-between text-green-600",children:[b.jsx("span",{children:"خصم كوبون"}),b.jsxs("span",{children:["- ",l," ريال"]})]}),b.jsx("div",{className:"h-px bg-border"}),b.jsxs("div",{className:"flex justify-between font-black text-base",children:[b.jsx("span",{children:"الإجمالي"}),b.jsxs("span",{children:[c," ريال"]})]})]})]}),b.jsxs("a",{href:`https://wa.me/${XH}?text=${z}`,target:"_blank",rel:"noopener noreferrer",className:"w-full bg-[#25D366] hover:bg-[#1ebe5d] text-white font-bold rounded-2xl py-4 flex items-center justify-center gap-3 transition-colors text-lg",children:[b.jsx(Iu,{className:"w-6 h-6"}),"إرسال الفاتورة على واتساب"]}),b.jsx("button",{onClick:()=>t("/"),className:"text-center text-sm text-muted-foreground underline",children:"العودة للرئيسية"})]}):b.jsxs(Cs.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},className:"flex flex-col gap-5",children:[b.jsxs("div",{className:"bg-card border border-card-border rounded-2xl p-4",children:[b.jsxs("p",{className:"font-bold text-sm mb-3 text-muted-foreground",children:["طلبك (",n.length," منتج)"]}),b.jsxs("div",{className:"flex flex-col gap-2",children:[n.map(K=>b.jsxs("div",{className:"flex items-center justify-between text-sm",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx(Cu,{className:"w-4 h-4 text-muted-foreground"}),b.jsxs("span",{className:"font-medium",children:[K.name," × ",K.quantity]})]}),b.jsxs("span",{className:"font-bold",children:[K.priceNum*K.quantity," ريال"]})]},K.productId)),s&&b.jsxs("div",{className:"flex justify-between text-sm text-green-600 pt-1 border-t border-border",children:[b.jsxs("span",{children:["خصم ",s.code]}),b.jsxs("span",{children:["- ",l," ريال"]})]}),b.jsxs("div",{className:"flex justify-between font-black text-base pt-2 border-t border-border",children:[b.jsx("span",{children:"الإجمالي"}),b.jsxs("span",{children:[c," ريال"]})]})]})]}),b.jsxs("form",{onSubmit:B,className:"bg-card border border-card-border rounded-2xl p-5 flex flex-col gap-4",children:[b.jsx("h2",{className:"font-black text-base",children:"بيانات الطلب"}),b.jsxs("div",{children:[b.jsx("label",{className:"text-xs font-bold text-muted-foreground mb-1.5 block",children:"الاسم"}),b.jsxs("div",{className:"relative",children:[b.jsx(gm,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),b.jsx("input",{"data-testid":"input-checkout-name",required:!0,type:"text",placeholder:"اسمك الكامل",value:d,onChange:K=>m(K.target.value),className:"w-full bg-background border border-border rounded-xl px-4 py-3 pr-9 text-sm focus:outline-none focus:ring-2 focus:ring-primary"})]})]}),b.jsxs("div",{children:[b.jsx("label",{className:"text-xs font-bold text-muted-foreground mb-1.5 block",children:"رقم واتساب"}),b.jsxs("div",{className:"relative",children:[b.jsx(Q1,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),b.jsx("input",{"data-testid":"input-checkout-whatsapp",required:!0,type:"tel",placeholder:"966XXXXXXXXX",value:g,onChange:K=>v(K.target.value),className:"w-full bg-background border border-border rounded-xl px-4 py-3 pr-9 text-sm focus:outline-none focus:ring-2 focus:ring-primary"})]})]}),b.jsx("p",{className:"text-xs text-muted-foreground bg-muted rounded-xl p-3 leading-relaxed",children:"بعد تأكيد الطلب ستحصل على رقم فاتورة فريد من 24 حرفاً — أرسله لواتساب وسيتواصل معك فريقنا"}),b.jsx(Ps,{"data-testid":"btn-confirm-order",type:"submit",disabled:T,className:"w-full h-12 rounded-xl font-bold text-base",children:T?b.jsx(os,{className:"w-5 h-5 animate-spin"}):"تأكيد الطلب وإنشاء الفاتورة"})]})]})})]})}const eG=new nM;function tG(){return b.jsxs(RO,{children:[b.jsx(Pr,{path:"/",component:MH}),b.jsx(Pr,{path:"/product/:id",children:t=>b.jsx(HH,{id:t.id})}),b.jsx(Pr,{path:"/cart",component:kH}),b.jsx(Pr,{path:"/checkout",component:JH}),b.jsx(Pr,{path:"/account",component:qH}),b.jsx(Pr,{path:"/auth",component:GH}),b.jsx(Pr,{path:"/admin",component:WH}),b.jsx(Pr,{component:Mj})]})}function nG(){const{count:t}=yf();return b.jsxs(b.Fragment,{children:[b.jsx(tG,{}),b.jsx(Qj,{}),b.jsx(kj,{cartCount:t})]})}function sG(){return b.jsx("div",{dir:"rtl",className:"min-h-[100dvh] bg-background",children:b.jsx(iM,{client:eG,children:b.jsxs(Cj,{children:[b.jsx(FH,{children:b.jsx(NH,{children:b.jsx(c1,{base:"/".replace(/\/$/,""),children:b.jsx(nG,{})})})}),b.jsx(YV,{})]})})})}rO.createRoot(document.getElementById("root")).render(b.jsx(sG,{}));