var Gte=Object.defineProperty;var qte=(e,t,n)=>t in e?Gte(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var yd=(e,t,n)=>qte(e,typeof t!="symbol"?t+"":t,n);function Wte(e,t){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var av=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Hu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var k_={exports:{}},_x={};/** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var P6;function Kte(){if(P6)return _x;P6=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,i,a){var o=null;if(a!==void 0&&(o=""+a),i.key!==void 0&&(o=""+i.key),"key"in i){a={};for(var c in i)c!=="key"&&(a[c]=i[c])}else a=i;return i=a.ref,{$$typeof:e,type:r,key:o,ref:i!==void 0?i:null,props:a}}return _x.Fragment=t,_x.jsx=n,_x.jsxs=n,_x}var R6;function Yte(){return R6||(R6=1,k_.exports=Kte()),k_.exports}var s=Yte(),C_={exports:{}},Cr={};/** * @license React * react.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var D6;function Xte(){if(D6)return Cr;D6=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),w=Symbol.iterator;function A(ie){return ie===null||typeof ie!="object"?null:(ie=w&&ie[w]||ie["@@iterator"],typeof ie=="function"?ie:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},I=Object.assign,T={};function D(ie,xe,ae){this.props=ie,this.context=xe,this.refs=T,this.updater=ae||k}D.prototype.isReactComponent={},D.prototype.setState=function(ie,xe){if(typeof ie!="object"&&typeof ie!="function"&&ie!=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,ie,xe,"setState")},D.prototype.forceUpdate=function(ie){this.updater.enqueueForceUpdate(this,ie,"forceUpdate")};function F(){}F.prototype=D.prototype;function L(ie,xe,ae){this.props=ie,this.context=xe,this.refs=T,this.updater=ae||k}var q=L.prototype=new F;q.constructor=L,I(q,D.prototype),q.isPureReactComponent=!0;var Z=Array.isArray;function K(){}var z={H:null,A:null,T:null,S:null},B=Object.prototype.hasOwnProperty;function V(ie,xe,ae){var Fe=ae.ref;return{$$typeof:e,type:ie,key:xe,ref:Fe!==void 0?Fe:null,props:ae}}function $(ie,xe){return V(ie.type,xe,ie.props)}function Q(ie){return typeof ie=="object"&&ie!==null&&ie.$$typeof===e}function Y(ie){var xe={"=":"=0",":":"=2"};return"$"+ie.replace(/[=:]/g,function(ae){return xe[ae]})}var G=/\/+/g;function he(ie,xe){return typeof ie=="object"&&ie!==null&&ie.key!=null?Y(""+ie.key):xe.toString(36)}function te(ie){switch(ie.status){case"fulfilled":return ie.value;case"rejected":throw ie.reason;default:switch(typeof ie.status=="string"?ie.then(K,K):(ie.status="pending",ie.then(function(xe){ie.status==="pending"&&(ie.status="fulfilled",ie.value=xe)},function(xe){ie.status==="pending"&&(ie.status="rejected",ie.reason=xe)})),ie.status){case"fulfilled":return ie.value;case"rejected":throw ie.reason}}throw ie}function le(ie,xe,ae,Fe,pt){var Ue=typeof ie;(Ue==="undefined"||Ue==="boolean")&&(ie=null);var Ct=!1;if(ie===null)Ct=!0;else switch(Ue){case"bigint":case"string":case"number":Ct=!0;break;case"object":switch(ie.$$typeof){case e:case t:Ct=!0;break;case m:return Ct=ie._init,le(Ct(ie._payload),xe,ae,Fe,pt)}}if(Ct)return pt=pt(ie),Ct=Fe===""?"."+he(ie,0):Fe,Z(pt)?(ae="",Ct!=null&&(ae=Ct.replace(G,"$&/")+"/"),le(pt,xe,ae,"",function(Ye){return Ye})):pt!=null&&(Q(pt)&&(pt=$(pt,ae+(pt.key==null||ie&&ie.key===pt.key?"":(""+pt.key).replace(G,"$&/")+"/")+Ct)),xe.push(pt)),1;Ct=0;var Tt=Fe===""?".":Fe+":";if(Z(ie))for(var ht=0;ht>>1,J=le[Be];if(0>>1;Bei(ae,ke))Fei(pt,ae)?(le[Be]=pt,le[Fe]=ke,Be=Fe):(le[Be]=ae,le[xe]=ke,Be=xe);else if(Fei(pt,ke))le[Be]=pt,le[Fe]=ke,Be=Fe;else break e}}return ve}function i(le,ve){var ke=le.sortIndex-ve.sortIndex;return ke!==0?ke:le.id-ve.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,c=o.now();e.unstable_now=function(){return o.now()-c}}var h=[],f=[],m=1,y=null,w=3,A=!1,k=!1,I=!1,T=!1,D=typeof setTimeout=="function"?setTimeout:null,F=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function q(le){for(var ve=n(f);ve!==null;){if(ve.callback===null)r(f);else if(ve.startTime<=le)r(f),ve.sortIndex=ve.expirationTime,t(h,ve);else break;ve=n(f)}}function Z(le){if(I=!1,q(le),!k)if(n(h)!==null)k=!0,K||(K=!0,Y());else{var ve=n(f);ve!==null&&te(Z,ve.startTime-le)}}var K=!1,z=-1,B=5,V=-1;function $(){return T?!0:!(e.unstable_now()-Vle&&$());){var Be=y.callback;if(typeof Be=="function"){y.callback=null,w=y.priorityLevel;var J=Be(y.expirationTime<=le);if(le=e.unstable_now(),typeof J=="function"){y.callback=J,q(le),ve=!0;break t}y===n(h)&&r(h),q(le)}else r(h);y=n(h)}if(y!==null)ve=!0;else{var ie=n(f);ie!==null&&te(Z,ie.startTime-le),ve=!1}}break e}finally{y=null,w=ke,A=!1}ve=void 0}}finally{ve?Y():K=!1}}}var Y;if(typeof L=="function")Y=function(){L(Q)};else if(typeof MessageChannel<"u"){var G=new MessageChannel,he=G.port2;G.port1.onmessage=Q,Y=function(){he.postMessage(null)}}else Y=function(){D(Q,0)};function te(le,ve){z=D(function(){le(e.unstable_now())},ve)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(le){le.callback=null},e.unstable_forceFrameRate=function(le){0>le||125Be?(le.sortIndex=ke,t(f,le),n(h)===null&&le===n(f)&&(I?(F(z),z=-1):I=!0,te(Z,ke-Be))):(le.sortIndex=J,t(h,le),k||A||(k=!0,K||(K=!0,Y()))),le},e.unstable_shouldYield=$,e.unstable_wrapCallback=function(le){var ve=w;return function(){var ke=w;w=ve;try{return le.apply(this,arguments)}finally{w=ke}}}})(T_)),T_}var U6;function Jte(){return U6||(U6=1,j_.exports=Zte()),j_.exports}var O_={exports:{}},xo={};/** * @license React * react-dom.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var B6;function ene(){if(B6)return xo;B6=1;var e=Ag();function t(h){var f="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),O_.exports=ene(),O_.exports}/** * @license React * react-dom-client.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var V6;function tne(){if(V6)return Sx;V6=1;var e=Jte(),t=Ag(),n=WV();function r(l){var d="https://react.dev/errors/"+l;if(1J||(l.current=Be[J],Be[J]=null,J--)}function ae(l,d){J++,Be[J]=l.current,l.current=d}var Fe=ie(null),pt=ie(null),Ue=ie(null),Ct=ie(null);function Tt(l,d){switch(ae(Ue,d),ae(pt,l),ae(Fe,null),d.nodeType){case 9:case 11:l=(l=d.documentElement)&&(l=l.namespaceURI)?n6(l):0;break;default:if(l=d.tagName,d=d.namespaceURI)d=n6(d),l=r6(d,l);else switch(l){case"svg":l=1;break;case"math":l=2;break;default:l=0}}xe(Fe),ae(Fe,l)}function ht(){xe(Fe),xe(pt),xe(Ue)}function Ye(l){l.memoizedState!==null&&ae(Ct,l);var d=Fe.current,x=r6(d,l.type);d!==x&&(ae(pt,l),ae(Fe,x))}function Yt(l){pt.current===l&&(xe(Fe),xe(pt)),Ct.current===l&&(xe(Ct),wx._currentValue=ke)}var dt,sn;function pn(l){if(dt===void 0)try{throw Error()}catch(x){var d=x.stack.trim().match(/\n( *(at )?)/);dt=d&&d[1]||"",sn=-1)":-1C||Ee[N]!==rt[C]){var wt=` `+Ee[N].replace(" at new "," at ");return l.displayName&&wt.includes("")&&(wt=wt.replace("",l.displayName)),wt}while(1<=N&&0<=C);break}}}finally{Fn=!1,Error.prepareStackTrace=x}return(x=l?l.displayName||l.name:"")?pn(x):""}function Dt(l,d){switch(l.tag){case 26:case 27:case 5:return pn(l.type);case 16:return pn("Lazy");case 13:return l.child!==d&&d!==null?pn("Suspense Fallback"):pn("Suspense");case 19:return pn("SuspenseList");case 0:case 15:return Ft(l.type,!1);case 11:return Ft(l.type.render,!1);case 1:return Ft(l.type,!0);case 31:return pn("Activity");default:return""}}function Ht(l){try{var d="",x=null;do d+=Dt(l,x),x=l,l=l.return;while(l);return d}catch(N){return` Error generating stack: `+N.message+` `+N.stack}}var Ze=Object.prototype.hasOwnProperty,Wt=e.unstable_scheduleCallback,It=e.unstable_cancelCallback,ln=e.unstable_shouldYield,Kn=e.unstable_requestPaint,un=e.unstable_now,xr=e.unstable_getCurrentPriorityLevel,Ve=e.unstable_ImmediatePriority,Ot=e.unstable_UserBlockingPriority,nn=e.unstable_NormalPriority,mn=e.unstable_LowPriority,dr=e.unstable_IdlePriority,hr=e.log,Ui=e.unstable_setDisableYieldValue,$n=null,be=null;function je(l){if(typeof hr=="function"&&Ui(l),be&&typeof be.setStrictMode=="function")try{be.setStrictMode($n,l)}catch{}}var ze=Math.clz32?Math.clz32:Bt,tt=Math.log,fn=Math.LN2;function Bt(l){return l>>>=0,l===0?32:31-(tt(l)/fn|0)|0}var jn=256,jt=262144,on=4194304;function Ir(l){var d=l&42;if(d!==0)return d;switch(l&-l){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:return l&261888;case 262144:case 524288:case 1048576:case 2097152:return l&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function pr(l,d,x){var N=l.pendingLanes;if(N===0)return 0;var C=0,R=l.suspendedLanes,X=l.pingedLanes;l=l.warmLanes;var ce=N&134217727;return ce!==0?(N=ce&~R,N!==0?C=Ir(N):(X&=ce,X!==0?C=Ir(X):x||(x=ce&~l,x!==0&&(C=Ir(x))))):(ce=N&~R,ce!==0?C=Ir(ce):X!==0?C=Ir(X):x||(x=N&~l,x!==0&&(C=Ir(x)))),C===0?0:d!==0&&d!==C&&(d&R)===0&&(R=C&-C,x=d&-d,R>=x||R===32&&(x&4194048)!==0)?d:C}function ue(l,d){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&d)===0}function Se(l,d){switch(l){case 1:case 2:case 4:case 8:case 64:return d+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 d+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 Xe(){var l=on;return on<<=1,(on&62914560)===0&&(on=4194304),l}function Vt(l){for(var d=[],x=0;31>x;x++)d.push(l);return d}function gn(l,d){l.pendingLanes|=d,d!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function xn(l,d,x,N,C,R){var X=l.pendingLanes;l.pendingLanes=x,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=x,l.entangledLanes&=x,l.errorRecoveryDisabledLanes&=x,l.shellSuspendCounter=0;var ce=l.entanglements,Ee=l.expirationTimes,rt=l.hiddenUpdates;for(x=X&~x;0"u")return null;try{return l.activeElement||l.body}catch{return l.body}}var Mn=/[\n"\\]/g;function Pn(l){return l.replace(Mn,function(d){return"\\"+d.charCodeAt(0).toString(16)+" "})}function vr(l,d,x,N,C,R,X,ce){l.name="",X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"?l.type=X:l.removeAttribute("type"),d!=null?X==="number"?(d===0&&l.value===""||l.value!=d)&&(l.value=""+vt(d)):l.value!==""+vt(d)&&(l.value=""+vt(d)):X!=="submit"&&X!=="reset"||l.removeAttribute("value"),d!=null?fe(l,X,vt(d)):x!=null?fe(l,X,vt(x)):N!=null&&l.removeAttribute("value"),C==null&&R!=null&&(l.defaultChecked=!!R),C!=null&&(l.checked=C&&typeof C!="function"&&typeof C!="symbol"),ce!=null&&typeof ce!="function"&&typeof ce!="symbol"&&typeof ce!="boolean"?l.name=""+vt(ce):l.removeAttribute("name")}function Me(l,d,x,N,C,R,X,ce){if(R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"&&(l.type=R),d!=null||x!=null){if(!(R!=="submit"&&R!=="reset"||d!=null)){Le(l);return}x=x!=null?""+vt(x):"",d=d!=null?""+vt(d):x,ce||d===l.value||(l.value=d),l.defaultValue=d}N=N??C,N=typeof N!="function"&&typeof N!="symbol"&&!!N,l.checked=ce?l.checked:!!N,l.defaultChecked=!!N,X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"&&(l.name=X),Le(l)}function fe(l,d,x){d==="number"&&On(l.ownerDocument)===l||l.defaultValue===""+x||(l.defaultValue=""+x)}function rn(l,d,x,N){if(l=l.options,d){d={};for(var C=0;C"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),To=!1;if(li)try{var zr={};Object.defineProperty(zr,"passive",{get:function(){To=!0}}),window.addEventListener("test",zr,zr),window.removeEventListener("test",zr,zr)}catch{To=!1}var Ka=null,Us=null,Qo=null;function Ya(){if(Qo)return Qo;var l,d=Us,x=d.length,N,C="value"in Ka?Ka.value:Ka.textContent,R=C.length;for(l=0;l=Jn),Qr=" ",Kr=!1;function Xs(l,d){switch(l){case"keyup":return qn.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Da(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Ci=!1;function js(l,d){switch(l){case"compositionend":return Da(d);case"keypress":return d.which!==32?null:(Kr=!0,Qr);case"textInput":return l=d.data,l===Qr&&Kr?null:l;default:return null}}function Po(l,d){if(Ci)return l==="compositionend"||!Nn&&Xs(l,d)?(l=Ya(),Qo=Us=Ka=null,Ci=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(d.ctrlKey||d.altKey||d.metaKey)||d.ctrlKey&&d.altKey){if(d.char&&1=d)return{node:x,offset:d-l};l=N}e:{for(;x;){if(x.nextSibling){x=x.nextSibling;break e}x=x.parentNode}x=void 0}x=O(x)}}function W(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?W(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function ne(l){l=l!=null&&l.ownerDocument!=null&&l.ownerDocument.defaultView!=null?l.ownerDocument.defaultView:window;for(var d=On(l.document);d instanceof l.HTMLIFrameElement;){try{var x=typeof d.contentWindow.location.href=="string"}catch{x=!1}if(x)l=d.contentWindow;else break;d=On(l.document)}return d}function oe(l){var d=l&&l.nodeName&&l.nodeName.toLowerCase();return d&&(d==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||d==="textarea"||l.contentEditable==="true")}var ye=li&&"documentMode"in document&&11>=document.documentMode,_e=null,Ie=null,Ke=null,ct=!1;function Gt(l,d,x){var N=x.window===x?x.document:x.nodeType===9?x:x.ownerDocument;ct||_e==null||_e!==On(N)||(N=_e,"selectionStart"in N&&oe(N)?N={start:N.selectionStart,end:N.selectionEnd}:(N=(N.ownerDocument&&N.ownerDocument.defaultView||window).getSelection(),N={anchorNode:N.anchorNode,anchorOffset:N.anchorOffset,focusNode:N.focusNode,focusOffset:N.focusOffset}),Ke&&S(Ke,N)||(Ke=N,N=Gb(Ie,"onSelect"),0>=X,C-=X,bc=1<<32-ze(d)+C|x<Mr?(ti=Wn,Wn=null):ti=Wn.sibling;var Ni=at(He,Wn,nt[Mr],St);if(Ni===null){Wn===null&&(Wn=ti);break}l&&Wn&&Ni.alternate===null&&d(He,Wn),Pe=R(Ni,Pe,Mr),wi===null?nr=Ni:wi.sibling=Ni,wi=Ni,Wn=ti}if(Mr===nt.length)return x(He,Wn),Zr&&Qc(He,Mr),nr;if(Wn===null){for(;MrMr?(ti=Wn,Wn=null):ti=Wn.sibling;var kh=at(He,Wn,Ni.value,St);if(kh===null){Wn===null&&(Wn=ti);break}l&&Wn&&kh.alternate===null&&d(He,Wn),Pe=R(kh,Pe,Mr),wi===null?nr=kh:wi.sibling=kh,wi=kh,Wn=ti}if(Ni.done)return x(He,Wn),Zr&&Qc(He,Mr),nr;if(Wn===null){for(;!Ni.done;Mr++,Ni=nt.next())Ni=kt(He,Ni.value,St),Ni!==null&&(Pe=R(Ni,Pe,Mr),wi===null?nr=Ni:wi.sibling=Ni,wi=Ni);return Zr&&Qc(He,Mr),nr}for(Wn=N(Wn);!Ni.done;Mr++,Ni=nt.next())Ni=ft(Wn,He,Mr,Ni.value,St),Ni!==null&&(l&&Ni.alternate!==null&&Wn.delete(Ni.key===null?Mr:Ni.key),Pe=R(Ni,Pe,Mr),wi===null?nr=Ni:wi.sibling=Ni,wi=Ni);return l&&Wn.forEach(function(Hte){return d(He,Hte)}),Zr&&Qc(He,Mr),nr}function Wi(He,Pe,nt,St){if(typeof nt=="object"&&nt!==null&&nt.type===I&&nt.key===null&&(nt=nt.props.children),typeof nt=="object"&&nt!==null){switch(nt.$$typeof){case A:e:{for(var nr=nt.key;Pe!==null;){if(Pe.key===nr){if(nr=nt.type,nr===I){if(Pe.tag===7){x(He,Pe.sibling),St=C(Pe,nt.props.children),St.return=He,He=St;break e}}else if(Pe.elementType===nr||typeof nr=="object"&&nr!==null&&nr.$$typeof===B&&Nc(nr)===Pe.type){x(He,Pe.sibling),St=C(Pe,nt.props),Ff(St,nt),St.return=He,He=St;break e}x(He,Pe);break}else d(He,Pe);Pe=Pe.sibling}nt.type===I?(St=Ii(nt.props.children,He.mode,St,nt.key),St.return=He,He=St):(St=Sm(nt.type,nt.key,nt.props,null,He.mode,St),Ff(St,nt),St.return=He,He=St)}return X(He);case k:e:{for(nr=nt.key;Pe!==null;){if(Pe.key===nr)if(Pe.tag===4&&Pe.stateNode.containerInfo===nt.containerInfo&&Pe.stateNode.implementation===nt.implementation){x(He,Pe.sibling),St=C(Pe,nt.children||[]),St.return=He,He=St;break e}else{x(He,Pe);break}else d(He,Pe);Pe=Pe.sibling}St=Yg(nt,He.mode,St),St.return=He,He=St}return X(He);case B:return nt=Nc(nt),Wi(He,Pe,nt,St)}if(te(nt))return Dn(He,Pe,nt,St);if(Y(nt)){if(nr=Y(nt),typeof nr!="function")throw Error(r(150));return nt=nr.call(nt),fr(He,Pe,nt,St)}if(typeof nt.then=="function")return Wi(He,Pe,Lm(nt),St);if(nt.$$typeof===L)return Wi(He,Pe,zf(He,nt),St);Um(He,nt)}return typeof nt=="string"&&nt!==""||typeof nt=="number"||typeof nt=="bigint"?(nt=""+nt,Pe!==null&&Pe.tag===6?(x(He,Pe.sibling),St=C(Pe,nt),St.return=He,He=St):(x(He,Pe),St=Lf(nt,He.mode,St),St.return=He,He=St),X(He)):x(He,Pe)}return function(He,Pe,nt,St){try{id=0;var nr=Wi(He,Pe,nt,St);return rd=null,nr}catch(Wn){if(Wn===nu||Wn===dh)throw Wn;var wi=Mo(29,Wn,null,He.mode);return wi.lanes=St,wi.return=He,wi}finally{}}}var sd=yb(!0),bb=yb(!1),ru=!1;function Jg(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function vb(l,d){l=l.updateQueue,d.updateQueue===l&&(d.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function ad(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function Uo(l,d,x){var N=l.updateQueue;if(N===null)return null;if(N=N.shared,(Oi&2)!==0){var C=N.pending;return C===null?d.next=d:(d.next=C.next,C.next=d),N.pending=d,d=_m(l),ub(l,null,x),d}return Am(l,N,d,x),_m(l)}function od(l,d,x){if(d=d.updateQueue,d!==null&&(d=d.shared,(x&4194048)!==0)){var N=d.lanes;N&=l.pendingLanes,x|=N,d.lanes=x,gt(l,x)}}function ld(l,d){var x=l.updateQueue,N=l.alternate;if(N!==null&&(N=N.updateQueue,x===N)){var C=null,R=null;if(x=x.firstBaseUpdate,x!==null){do{var X={lane:x.lane,tag:x.tag,payload:x.payload,callback:null,next:null};R===null?C=R=X:R=R.next=X,x=x.next}while(x!==null);R===null?C=R=d:R=R.next=d}else C=R=d;x={baseState:N.baseState,firstBaseUpdate:C,lastBaseUpdate:R,shared:N.shared,callbacks:N.callbacks},l.updateQueue=x;return}l=x.lastBaseUpdate,l===null?x.firstBaseUpdate=d:l.next=d,x.lastBaseUpdate=d}var iu=!1;function Ac(){if(iu){var l=tu;if(l!==null)throw l}}function $f(l,d,x,N){iu=!1;var C=l.updateQueue;ru=!1;var R=C.firstBaseUpdate,X=C.lastBaseUpdate,ce=C.shared.pending;if(ce!==null){C.shared.pending=null;var Ee=ce,rt=Ee.next;Ee.next=null,X===null?R=rt:X.next=rt,X=Ee;var wt=l.alternate;wt!==null&&(wt=wt.updateQueue,ce=wt.lastBaseUpdate,ce!==X&&(ce===null?wt.firstBaseUpdate=rt:ce.next=rt,wt.lastBaseUpdate=Ee))}if(R!==null){var kt=C.baseState;X=0,wt=rt=Ee=null,ce=R;do{var at=ce.lane&-536870913,ft=at!==ce.lane;if(ft?(ei&at)===at:(N&at)===at){at!==0&&at===eu&&(iu=!0),wt!==null&&(wt=wt.next={lane:0,tag:ce.tag,payload:ce.payload,callback:null,next:null});e:{var Dn=l,fr=ce;at=d;var Wi=x;switch(fr.tag){case 1:if(Dn=fr.payload,typeof Dn=="function"){kt=Dn.call(Wi,kt,at);break e}kt=Dn;break e;case 3:Dn.flags=Dn.flags&-65537|128;case 0:if(Dn=fr.payload,at=typeof Dn=="function"?Dn.call(Wi,kt,at):Dn,at==null)break e;kt=y({},kt,at);break e;case 2:ru=!0}}at=ce.callback,at!==null&&(l.flags|=64,ft&&(l.flags|=8192),ft=C.callbacks,ft===null?C.callbacks=[at]:ft.push(at))}else ft={lane:at,tag:ce.tag,payload:ce.payload,callback:ce.callback,next:null},wt===null?(rt=wt=ft,Ee=kt):wt=wt.next=ft,X|=at;if(ce=ce.next,ce===null){if(ce=C.shared.pending,ce===null)break;ft=ce,ce=ft.next,ft.next=null,C.lastBaseUpdate=ft,C.shared.pending=null}}while(!0);wt===null&&(Ee=kt),C.baseState=Ee,C.firstBaseUpdate=rt,C.lastBaseUpdate=wt,R===null&&(C.shared.lanes=0),xh|=X,l.lanes=X,l.memoizedState=kt}}function wb(l,d){if(typeof l!="function")throw Error(r(191,l));l.call(d)}function Nb(l,d){var x=l.callbacks;if(x!==null)for(l.callbacks=null,l=0;lR?R:8;var X=le.T,ce={};le.T=ce,_A(l,!1,d,x);try{var Ee=C(),rt=le.S;if(rt!==null&&rt(ce,Ee),Ee!==null&&typeof Ee=="object"&&typeof Ee.then=="function"){var wt=Zg(Ee,N);ix(l,d,wt,Il(l))}else ix(l,d,N,Il(l))}catch(kt){ix(l,d,{then:function(){},status:"rejected",reason:kt},Il())}finally{ve.p=R,X!==null&&ce.types!==null&&(X.types=ce.types),le.T=X}}function Bee(){}function EA(l,d,x,N){if(l.tag!==5)throw Error(r(476));var C=CO(l).queue;kO(l,C,d,ke,x===null?Bee:function(){return IO(l),x(N)})}function CO(l){var d=l.memoizedState;if(d!==null)return d;d={memoizedState:ke,baseState:ke,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ts,lastRenderedState:ke},next:null};var x={};return d.next={memoizedState:x,baseState:x,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ts,lastRenderedState:x},next:null},l.memoizedState=d,l=l.alternate,l!==null&&(l.memoizedState=d),d}function IO(l){var d=CO(l);d.next===null&&(d=l.alternate.memoizedState),ix(l,d.next.queue,{},Il())}function AA(){return Zs(wx)}function jO(){return hs().memoizedState}function TO(){return hs().memoizedState}function zee(l){for(var d=l.return;d!==null;){switch(d.tag){case 24:case 3:var x=Il();l=ad(x);var N=Uo(d,l,x);N!==null&&(dl(N,d,x),od(N,d,x)),d={cache:jm()},l.payload=d;return}d=d.return}}function Vee(l,d,x){var N=Il();x={lane:N,revertLane:0,gesture:null,action:x,hasEagerState:!1,eagerState:null,next:null},Sb(l)?PO(d,x):(x=Wg(l,d,x,N),x!==null&&(dl(x,l,N),RO(x,d,N)))}function OO(l,d,x){var N=Il();ix(l,d,x,N)}function ix(l,d,x,N){var C={lane:N,revertLane:0,gesture:null,action:x,hasEagerState:!1,eagerState:null,next:null};if(Sb(l))PO(d,C);else{var R=l.alternate;if(l.lanes===0&&(R===null||R.lanes===0)&&(R=d.lastRenderedReducer,R!==null))try{var X=d.lastRenderedState,ce=R(X,x);if(C.hasEagerState=!0,C.eagerState=ce,E(ce,X))return Am(l,d,C,0),Ji===null&&Em(),!1}catch{}finally{}if(x=Wg(l,d,C,N),x!==null)return dl(x,l,N),RO(x,d,N),!0}return!1}function _A(l,d,x,N){if(N={lane:2,revertLane:r_(),gesture:null,action:N,hasEagerState:!1,eagerState:null,next:null},Sb(l)){if(d)throw Error(r(479))}else d=Wg(l,x,N,2),d!==null&&dl(d,l,2)}function Sb(l){var d=l.alternate;return l===Ar||d!==null&&d===Ar}function PO(l,d){De=de=!0;var x=l.pending;x===null?d.next=d:(d.next=x.next,x.next=d),l.pending=d}function RO(l,d,x){if((x&4194048)!==0){var N=d.lanes;N&=l.pendingLanes,x|=N,d.lanes=x,gt(l,x)}}var sx={readContext:Zs,use:Vm,useCallback:dn,useContext:dn,useEffect:dn,useImperativeHandle:dn,useLayoutEffect:dn,useInsertionEffect:dn,useMemo:dn,useReducer:dn,useRef:dn,useState:dn,useDebugValue:dn,useDeferredValue:dn,useTransition:dn,useSyncExternalStore:dn,useId:dn,useHostTransitionStatus:dn,useFormState:dn,useActionState:dn,useOptimistic:dn,useMemoCache:dn,useCacheRefresh:dn};sx.useEffectEvent=dn;var DO={readContext:Zs,use:Vm,useCallback:function(l,d){return Zi().memoizedState=[l,d===void 0?null:d],l},useContext:Zs,useEffect:yO,useImperativeHandle:function(l,d,x){x=x!=null?x.concat([l]):null,Ab(4194308,4,NO.bind(null,d,l),x)},useLayoutEffect:function(l,d){return Ab(4194308,4,l,d)},useInsertionEffect:function(l,d){Ab(4,2,l,d)},useMemo:function(l,d){var x=Zi();d=d===void 0?null:d;var N=l();if(xt){je(!0);try{l()}finally{je(!1)}}return x.memoizedState=[N,d],N},useReducer:function(l,d,x){var N=Zi();if(x!==void 0){var C=x(d);if(xt){je(!0);try{x(d)}finally{je(!1)}}}else C=d;return N.memoizedState=N.baseState=C,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:C},N.queue=l,l=l.dispatch=Vee.bind(null,Ar,l),[N.memoizedState,l]},useRef:function(l){var d=Zi();return l={current:l},d.memoizedState=l},useState:function(l){l=yA(l);var d=l.queue,x=OO.bind(null,Ar,d);return d.dispatch=x,[l.memoizedState,x]},useDebugValue:wA,useDeferredValue:function(l,d){var x=Zi();return NA(x,l,d)},useTransition:function(){var l=yA(!1);return l=kO.bind(null,Ar,l.queue,!0,!1),Zi().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,d,x){var N=Ar,C=Zi();if(Zr){if(x===void 0)throw Error(r(407));x=x()}else{if(x=d(),Ji===null)throw Error(r(349));(ei&127)!==0||nO(N,d,x)}C.memoizedState=x;var R={value:x,getSnapshot:d};return C.queue=R,yO(iO.bind(null,N,R,l),[l]),N.flags|=2048,Fm(9,{destroy:void 0},rO.bind(null,N,R,x,d),null),x},useId:function(){var l=Zi(),d=Ji.identifierPrefix;if(Zr){var x=vc,N=bc;x=(N&~(1<<32-ze(N)-1)).toString(32)+x,d="_"+d+"R_"+x,x=qt++,0<\/script>",R=R.removeChild(R.firstChild);break;case"select":R=typeof N.is=="string"?X.createElement("select",{is:N.is}):X.createElement("select"),N.multiple?R.multiple=!0:N.size&&(R.size=N.size);break;default:R=typeof N.is=="string"?X.createElement(C,{is:N.is}):X.createElement(C)}}R[Pt]=d,R[Sn]=N;e:for(X=d.child;X!==null;){if(X.tag===5||X.tag===6)R.appendChild(X.stateNode);else if(X.tag!==4&&X.tag!==27&&X.child!==null){X.child.return=X,X=X.child;continue}if(X===d)break e;for(;X.sibling===null;){if(X.return===null||X.return===d)break e;X=X.return}X.sibling.return=X.return,X=X.sibling}d.stateNode=R;e:switch(Ja(R,C,N),C){case"button":case"input":case"select":case"textarea":N=!!N.autoFocus;break e;case"img":N=!0;break e;default:N=!1}N&&ud(d)}}return fs(d),BA(d,d.type,l===null?null:l.memoizedProps,d.pendingProps,x),null;case 6:if(l&&d.stateNode!=null)l.memoizedProps!==N&&ud(d);else{if(typeof N!="string"&&d.stateNode===null)throw Error(r(166));if(l=Ue.current,Bf(d)){if(l=d.stateNode,x=d.memoizedProps,N=null,C=Ma,C!==null)switch(C.tag){case 27:case 5:N=C.memoizedProps}l[Pt]=d,l=!!(l.nodeValue===x||N!==null&&N.suppressHydrationWarning===!0||e6(l.nodeValue,x)),l||Zu(d,!0)}else l=qb(l).createTextNode(N),l[Pt]=d,d.stateNode=l}return fs(d),null;case 31:if(x=d.memoizedState,l===null||l.memoizedState!==null){if(N=Bf(d),x!==null){if(l===null){if(!N)throw Error(r(318));if(l=d.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(r(557));l[Pt]=d}else Sl(),(d.flags&128)===0&&(d.memoizedState=null),d.flags|=4;fs(d),l=!1}else x=oh(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=x),l=!0;if(!l)return d.flags&256?(go(d),d):(go(d),null);if((d.flags&128)!==0)throw Error(r(558))}return fs(d),null;case 13:if(N=d.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(C=Bf(d),N!==null&&N.dehydrated!==null){if(l===null){if(!C)throw Error(r(318));if(C=d.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(r(317));C[Pt]=d}else Sl(),(d.flags&128)===0&&(d.memoizedState=null),d.flags|=4;fs(d),C=!1}else C=oh(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=C),C=!0;if(!C)return d.flags&256?(go(d),d):(go(d),null)}return go(d),(d.flags&128)!==0?(d.lanes=x,d):(x=N!==null,l=l!==null&&l.memoizedState!==null,x&&(N=d.child,C=null,N.alternate!==null&&N.alternate.memoizedState!==null&&N.alternate.memoizedState.cachePool!==null&&(C=N.alternate.memoizedState.cachePool.pool),R=null,N.memoizedState!==null&&N.memoizedState.cachePool!==null&&(R=N.memoizedState.cachePool.pool),R!==C&&(N.flags|=2048)),x!==l&&x&&(d.child.flags|=8192),Tb(d,d.updateQueue),fs(d),null);case 4:return ht(),l===null&&o_(d.stateNode.containerInfo),fs(d),null;case 10:return Qa(d.type),fs(d),null;case 19:if(xe(Ns),N=d.memoizedState,N===null)return fs(d),null;if(C=(d.flags&128)!==0,R=N.rendering,R===null)if(C)ox(N,!1);else{if(Bs!==0||l!==null&&(l.flags&128)!==0)for(l=d.child;l!==null;){if(R=Hf(l),R!==null){for(d.flags|=128,ox(N,!1),l=R.updateQueue,d.updateQueue=l,Tb(d,l),d.subtreeFlags=0,l=x,x=d.child;x!==null;)db(x,l),x=x.sibling;return ae(Ns,Ns.current&1|2),Zr&&Qc(d,N.treeForkCount),d.child}l=l.sibling}N.tail!==null&&un()>Mb&&(d.flags|=128,C=!0,ox(N,!1),d.lanes=4194304)}else{if(!C)if(l=Hf(R),l!==null){if(d.flags|=128,C=!0,l=l.updateQueue,d.updateQueue=l,Tb(d,l),ox(N,!0),N.tail===null&&N.tailMode==="hidden"&&!R.alternate&&!Zr)return fs(d),null}else 2*un()-N.renderingStartTime>Mb&&x!==536870912&&(d.flags|=128,C=!0,ox(N,!1),d.lanes=4194304);N.isBackwards?(R.sibling=d.child,d.child=R):(l=N.last,l!==null?l.sibling=R:d.child=R,N.last=R)}return N.tail!==null?(l=N.tail,N.rendering=l,N.tail=l.sibling,N.renderingStartTime=un(),l.sibling=null,x=Ns.current,ae(Ns,C?x&1|2:x&1),Zr&&Qc(d,N.treeForkCount),l):(fs(d),null);case 22:case 23:return go(d),tx(),N=d.memoizedState!==null,l!==null?l.memoizedState!==null!==N&&(d.flags|=8192):N&&(d.flags|=8192),N?(x&536870912)!==0&&(d.flags&128)===0&&(fs(d),d.subtreeFlags&6&&(d.flags|=8192)):fs(d),x=d.updateQueue,x!==null&&Tb(d,x.retryQueue),x=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(x=l.memoizedState.cachePool.pool),N=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(N=d.memoizedState.cachePool.pool),N!==x&&(d.flags|=2048),l!==null&&xe(sl),null;case 24:return x=null,l!==null&&(x=l.memoizedState.cache),d.memoizedState.cache!==x&&(d.flags|=2048),Qa(ws),fs(d),null;case 25:return null;case 30:return null}throw Error(r(156,d.tag))}function qee(l,d){switch(fb(d),d.tag){case 1:return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return Qa(ws),ht(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 26:case 27:case 5:return Yt(d),null;case 31:if(d.memoizedState!==null){if(go(d),d.alternate===null)throw Error(r(340));Sl()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 13:if(go(d),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(r(340));Sl()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return xe(Ns),null;case 4:return ht(),null;case 10:return Qa(d.type),null;case 22:case 23:return go(d),tx(),l!==null&&xe(sl),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 24:return Qa(ws),null;case 25:return null;default:return null}}function sP(l,d){switch(fb(d),d.tag){case 3:Qa(ws),ht();break;case 26:case 27:case 5:Yt(d);break;case 4:ht();break;case 31:d.memoizedState!==null&&go(d);break;case 13:go(d);break;case 19:xe(Ns);break;case 10:Qa(d.type);break;case 22:case 23:go(d),tx(),l!==null&&xe(sl);break;case 24:Qa(ws)}}function lx(l,d){try{var x=d.updateQueue,N=x!==null?x.lastEffect:null;if(N!==null){var C=N.next;x=C;do{if((x.tag&l)===l){N=void 0;var R=x.create,X=x.inst;N=R(),X.destroy=N}x=x.next}while(x!==C)}}catch(ce){zi(d,d.return,ce)}}function mh(l,d,x){try{var N=d.updateQueue,C=N!==null?N.lastEffect:null;if(C!==null){var R=C.next;N=R;do{if((N.tag&l)===l){var X=N.inst,ce=X.destroy;if(ce!==void 0){X.destroy=void 0,C=d;var Ee=x,rt=ce;try{rt()}catch(wt){zi(C,Ee,wt)}}}N=N.next}while(N!==R)}}catch(wt){zi(d,d.return,wt)}}function aP(l){var d=l.updateQueue;if(d!==null){var x=l.stateNode;try{Nb(d,x)}catch(N){zi(l,l.return,N)}}}function oP(l,d,x){x.props=Wf(l.type,l.memoizedProps),x.state=l.memoizedState;try{x.componentWillUnmount()}catch(N){zi(l,d,N)}}function cx(l,d){try{var x=l.ref;if(x!==null){switch(l.tag){case 26:case 27:case 5:var N=l.stateNode;break;case 30:N=l.stateNode;break;default:N=l.stateNode}typeof x=="function"?l.refCleanup=x(N):x.current=N}}catch(C){zi(l,d,C)}}function su(l,d){var x=l.ref,N=l.refCleanup;if(x!==null)if(typeof N=="function")try{N()}catch(C){zi(l,d,C)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof x=="function")try{x(null)}catch(C){zi(l,d,C)}else x.current=null}function lP(l){var d=l.type,x=l.memoizedProps,N=l.stateNode;try{e:switch(d){case"button":case"input":case"select":case"textarea":x.autoFocus&&N.focus();break e;case"img":x.src?N.src=x.src:x.srcSet&&(N.srcset=x.srcSet)}}catch(C){zi(l,l.return,C)}}function zA(l,d,x){try{var N=l.stateNode;pte(N,l.type,x,d),N[Sn]=d}catch(C){zi(l,l.return,C)}}function cP(l){return l.tag===5||l.tag===3||l.tag===26||l.tag===27&&Nh(l.type)||l.tag===4}function VA(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||cP(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.tag===27&&Nh(l.type)||l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function FA(l,d,x){var N=l.tag;if(N===5||N===6)l=l.stateNode,d?(x.nodeType===9?x.body:x.nodeName==="HTML"?x.ownerDocument.body:x).insertBefore(l,d):(d=x.nodeType===9?x.body:x.nodeName==="HTML"?x.ownerDocument.body:x,d.appendChild(l),x=x._reactRootContainer,x!=null||d.onclick!==null||(d.onclick=ks));else if(N!==4&&(N===27&&Nh(l.type)&&(x=l.stateNode,d=null),l=l.child,l!==null))for(FA(l,d,x),l=l.sibling;l!==null;)FA(l,d,x),l=l.sibling}function Ob(l,d,x){var N=l.tag;if(N===5||N===6)l=l.stateNode,d?x.insertBefore(l,d):x.appendChild(l);else if(N!==4&&(N===27&&Nh(l.type)&&(x=l.stateNode),l=l.child,l!==null))for(Ob(l,d,x),l=l.sibling;l!==null;)Ob(l,d,x),l=l.sibling}function uP(l){var d=l.stateNode,x=l.memoizedProps;try{for(var N=l.type,C=d.attributes;C.length;)d.removeAttributeNode(C[0]);Ja(d,N,x),d[Pt]=l,d[Sn]=x}catch(R){zi(l,l.return,R)}}var dd=!1,oa=!1,$A=!1,dP=typeof WeakSet=="function"?WeakSet:Set,Ua=null;function Wee(l,d){if(l=l.containerInfo,u_=Jb,l=ne(l),oe(l)){if("selectionStart"in l)var x={start:l.selectionStart,end:l.selectionEnd};else e:{x=(x=l.ownerDocument)&&x.defaultView||window;var N=x.getSelection&&x.getSelection();if(N&&N.rangeCount!==0){x=N.anchorNode;var C=N.anchorOffset,R=N.focusNode;N=N.focusOffset;try{x.nodeType,R.nodeType}catch{x=null;break e}var X=0,ce=-1,Ee=-1,rt=0,wt=0,kt=l,at=null;t:for(;;){for(var ft;kt!==x||C!==0&&kt.nodeType!==3||(ce=X+C),kt!==R||N!==0&&kt.nodeType!==3||(Ee=X+N),kt.nodeType===3&&(X+=kt.nodeValue.length),(ft=kt.firstChild)!==null;)at=kt,kt=ft;for(;;){if(kt===l)break t;if(at===x&&++rt===C&&(ce=X),at===R&&++wt===N&&(Ee=X),(ft=kt.nextSibling)!==null)break;kt=at,at=kt.parentNode}kt=ft}x=ce===-1||Ee===-1?null:{start:ce,end:Ee}}else x=null}x=x||{start:0,end:0}}else x=null;for(d_={focusedElem:l,selectionRange:x},Jb=!1,Ua=d;Ua!==null;)if(d=Ua,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,Ua=l;else for(;Ua!==null;){switch(d=Ua,R=d.alternate,l=d.flags,d.tag){case 0:if((l&4)!==0&&(l=d.updateQueue,l=l!==null?l.events:null,l!==null))for(x=0;x title"))),Ja(R,N,x),R[Pt]=l,si(R),N=R;break e;case"link":var X=x6("link","href",C).get(N+(x.href||""));if(X){for(var ce=0;ceWi&&(X=Wi,Wi=fr,fr=X);var He=M(ce,fr),Pe=M(ce,Wi);if(He&&Pe&&(ft.rangeCount!==1||ft.anchorNode!==He.node||ft.anchorOffset!==He.offset||ft.focusNode!==Pe.node||ft.focusOffset!==Pe.offset)){var nt=kt.createRange();nt.setStart(He.node,He.offset),ft.removeAllRanges(),fr>Wi?(ft.addRange(nt),ft.extend(Pe.node,Pe.offset)):(nt.setEnd(Pe.node,Pe.offset),ft.addRange(nt))}}}}for(kt=[],ft=ce;ft=ft.parentNode;)ft.nodeType===1&&kt.push({element:ft,left:ft.scrollLeft,top:ft.scrollTop});for(typeof ce.focus=="function"&&ce.focus(),ce=0;cex?32:x,le.T=null,x=XA,XA=null;var R=bh,X=gd;if(ba=0,Wm=bh=null,gd=0,(Oi&6)!==0)throw Error(r(331));var ce=Oi;if(Oi|=4,NP(R.current),bP(R,R.current,X,x),Oi=ce,mx(0,!1),be&&typeof be.onPostCommitFiberRoot=="function")try{be.onPostCommitFiberRoot($n,R)}catch{}return!0}finally{ve.p=C,le.T=N,zP(l,d)}}function FP(l,d,x){d=Lo(x,d),d=IA(l.stateNode,d,2),l=Uo(l,d,2),l!==null&&(gn(l,2),au(l))}function zi(l,d,x){if(l.tag===3)FP(l,l,x);else for(;d!==null;){if(d.tag===3){FP(d,l,x);break}else if(d.tag===1){var N=d.stateNode;if(typeof d.type.getDerivedStateFromError=="function"||typeof N.componentDidCatch=="function"&&(yh===null||!yh.has(N))){l=Lo(x,l),x=$O(2),N=Uo(d,x,2),N!==null&&(HO(x,N,d,l),gn(N,2),au(N));break}}d=d.return}}function e_(l,d,x){var N=l.pingCache;if(N===null){N=l.pingCache=new Xee;var C=new Set;N.set(d,C)}else C=N.get(d),C===void 0&&(C=new Set,N.set(d,C));C.has(x)||(qA=!0,C.add(x),l=tte.bind(null,l,d,x),d.then(l,l))}function tte(l,d,x){var N=l.pingCache;N!==null&&N.delete(d),l.pingedLanes|=l.suspendedLanes&x,l.warmLanes&=~x,Ji===l&&(ei&x)===x&&(Bs===4||Bs===3&&(ei&62914560)===ei&&300>un()-Db?(Oi&2)===0&&Km(l,0):WA|=x,qm===ei&&(qm=0)),au(l)}function $P(l,d){d===0&&(d=Xe()),l=Ku(l,d),l!==null&&(gn(l,d),au(l))}function nte(l){var d=l.memoizedState,x=0;d!==null&&(x=d.retryLane),$P(l,x)}function rte(l,d){var x=0;switch(l.tag){case 31:case 13:var N=l.stateNode,C=l.memoizedState;C!==null&&(x=C.retryLane);break;case 19:N=l.stateNode;break;case 22:N=l.stateNode._retryCache;break;default:throw Error(r(314))}N!==null&&N.delete(d),$P(l,x)}function ite(l,d){return Wt(l,d)}var Fb=null,Xm=null,t_=!1,$b=!1,n_=!1,wh=0;function au(l){l!==Xm&&l.next===null&&(Xm===null?Fb=Xm=l:Xm=Xm.next=l),$b=!0,t_||(t_=!0,ate())}function mx(l,d){if(!n_&&$b){n_=!0;do for(var x=!1,N=Fb;N!==null;){if(l!==0){var C=N.pendingLanes;if(C===0)var R=0;else{var X=N.suspendedLanes,ce=N.pingedLanes;R=(1<<31-ze(42|l)+1)-1,R&=C&~(X&~ce),R=R&201326741?R&201326741|1:R?R|2:0}R!==0&&(x=!0,WP(N,R))}else R=ei,R=pr(N,N===Ji?R:0,N.cancelPendingCommit!==null||N.timeoutHandle!==-1),(R&3)===0||ue(N,R)||(x=!0,WP(N,R));N=N.next}while(x);n_=!1}}function ste(){HP()}function HP(){$b=t_=!1;var l=0;wh!==0&>e()&&(l=wh);for(var d=un(),x=null,N=Fb;N!==null;){var C=N.next,R=GP(N,d);R===0?(N.next=null,x===null?Fb=C:x.next=C,C===null&&(Xm=x)):(x=N,(l!==0||(R&3)!==0)&&($b=!0)),N=C}ba!==0&&ba!==5||mx(l),wh!==0&&(wh=0)}function GP(l,d){for(var x=l.suspendedLanes,N=l.pingedLanes,C=l.expirationTimes,R=l.pendingLanes&-62914561;0ce)break;var wt=Ee.transferSize,kt=Ee.initiatorType;wt&&t6(kt)&&(Ee=Ee.responseEnd,X+=wt*(Ee"u"?null:document;function f6(l,d,x){var N=Qm;if(N&&typeof d=="string"&&d){var C=Pn(d);C='link[rel="'+l+'"][href="'+C+'"]',typeof x=="string"&&(C+='[crossorigin="'+x+'"]'),h6.has(C)||(h6.add(C),l={rel:l,crossOrigin:x,href:d},N.querySelector(C)===null&&(d=N.createElement("link"),Ja(d,"link",l),si(d),N.head.appendChild(d)))}}function _te(l){xd.D(l),f6("dns-prefetch",l,null)}function Ste(l,d){xd.C(l,d),f6("preconnect",l,d)}function kte(l,d,x){xd.L(l,d,x);var N=Qm;if(N&&l&&d){var C='link[rel="preload"][as="'+Pn(d)+'"]';d==="image"&&x&&x.imageSrcSet?(C+='[imagesrcset="'+Pn(x.imageSrcSet)+'"]',typeof x.imageSizes=="string"&&(C+='[imagesizes="'+Pn(x.imageSizes)+'"]')):C+='[href="'+Pn(l)+'"]';var R=C;switch(d){case"style":R=Zm(l);break;case"script":R=Jm(l)}Zl.has(R)||(l=y({rel:"preload",href:d==="image"&&x&&x.imageSrcSet?void 0:l,as:d},x),Zl.set(R,l),N.querySelector(C)!==null||d==="style"&&N.querySelector(bx(R))||d==="script"&&N.querySelector(vx(R))||(d=N.createElement("link"),Ja(d,"link",l),si(d),N.head.appendChild(d)))}}function Cte(l,d){xd.m(l,d);var x=Qm;if(x&&l){var N=d&&typeof d.as=="string"?d.as:"script",C='link[rel="modulepreload"][as="'+Pn(N)+'"][href="'+Pn(l)+'"]',R=C;switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":R=Jm(l)}if(!Zl.has(R)&&(l=y({rel:"modulepreload",href:l},d),Zl.set(R,l),x.querySelector(C)===null)){switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(x.querySelector(vx(R)))return}N=x.createElement("link"),Ja(N,"link",l),si(N),x.head.appendChild(N)}}}function Ite(l,d,x){xd.S(l,d,x);var N=Qm;if(N&&l){var C=ss(N).hoistableStyles,R=Zm(l);d=d||"default";var X=C.get(R);if(!X){var ce={loading:0,preload:null};if(X=N.querySelector(bx(R)))ce.loading=5;else{l=y({rel:"stylesheet",href:l,"data-precedence":d},x),(x=Zl.get(R))&&y_(l,x);var Ee=X=N.createElement("link");si(Ee),Ja(Ee,"link",l),Ee._p=new Promise(function(rt,wt){Ee.onload=rt,Ee.onerror=wt}),Ee.addEventListener("load",function(){ce.loading|=1}),Ee.addEventListener("error",function(){ce.loading|=2}),ce.loading|=4,Kb(X,d,N)}X={type:"stylesheet",instance:X,count:1,state:ce},C.set(R,X)}}}function jte(l,d){xd.X(l,d);var x=Qm;if(x&&l){var N=ss(x).hoistableScripts,C=Jm(l),R=N.get(C);R||(R=x.querySelector(vx(C)),R||(l=y({src:l,async:!0},d),(d=Zl.get(C))&&b_(l,d),R=x.createElement("script"),si(R),Ja(R,"link",l),x.head.appendChild(R)),R={type:"script",instance:R,count:1,state:null},N.set(C,R))}}function Tte(l,d){xd.M(l,d);var x=Qm;if(x&&l){var N=ss(x).hoistableScripts,C=Jm(l),R=N.get(C);R||(R=x.querySelector(vx(C)),R||(l=y({src:l,async:!0,type:"module"},d),(d=Zl.get(C))&&b_(l,d),R=x.createElement("script"),si(R),Ja(R,"link",l),x.head.appendChild(R)),R={type:"script",instance:R,count:1,state:null},N.set(C,R))}}function p6(l,d,x,N){var C=(C=Ue.current)?Wb(C):null;if(!C)throw Error(r(446));switch(l){case"meta":case"title":return null;case"style":return typeof x.precedence=="string"&&typeof x.href=="string"?(d=Zm(x.href),x=ss(C).hoistableStyles,N=x.get(d),N||(N={type:"style",instance:null,count:0,state:null},x.set(d,N)),N):{type:"void",instance:null,count:0,state:null};case"link":if(x.rel==="stylesheet"&&typeof x.href=="string"&&typeof x.precedence=="string"){l=Zm(x.href);var R=ss(C).hoistableStyles,X=R.get(l);if(X||(C=C.ownerDocument||C,X={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},R.set(l,X),(R=C.querySelector(bx(l)))&&!R._p&&(X.instance=R,X.state.loading=5),Zl.has(l)||(x={rel:"preload",as:"style",href:x.href,crossOrigin:x.crossOrigin,integrity:x.integrity,media:x.media,hrefLang:x.hrefLang,referrerPolicy:x.referrerPolicy},Zl.set(l,x),R||Ote(C,l,x,X.state))),d&&N===null)throw Error(r(528,""));return X}if(d&&N!==null)throw Error(r(529,""));return null;case"script":return d=x.async,x=x.src,typeof x=="string"&&d&&typeof d!="function"&&typeof d!="symbol"?(d=Jm(x),x=ss(C).hoistableScripts,N=x.get(d),N||(N={type:"script",instance:null,count:0,state:null},x.set(d,N)),N):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,l))}}function Zm(l){return'href="'+Pn(l)+'"'}function bx(l){return'link[rel="stylesheet"]['+l+"]"}function m6(l){return y({},l,{"data-precedence":l.precedence,precedence:null})}function Ote(l,d,x,N){l.querySelector('link[rel="preload"][as="style"]['+d+"]")?N.loading=1:(d=l.createElement("link"),N.preload=d,d.addEventListener("load",function(){return N.loading|=1}),d.addEventListener("error",function(){return N.loading|=2}),Ja(d,"link",x),si(d),l.head.appendChild(d))}function Jm(l){return'[src="'+Pn(l)+'"]'}function vx(l){return"script[async]"+l}function g6(l,d,x){if(d.count++,d.instance===null)switch(d.type){case"style":var N=l.querySelector('style[data-href~="'+Pn(x.href)+'"]');if(N)return d.instance=N,si(N),N;var C=y({},x,{"data-href":x.href,"data-precedence":x.precedence,href:null,precedence:null});return N=(l.ownerDocument||l).createElement("style"),si(N),Ja(N,"style",C),Kb(N,x.precedence,l),d.instance=N;case"stylesheet":C=Zm(x.href);var R=l.querySelector(bx(C));if(R)return d.state.loading|=4,d.instance=R,si(R),R;N=m6(x),(C=Zl.get(C))&&y_(N,C),R=(l.ownerDocument||l).createElement("link"),si(R);var X=R;return X._p=new Promise(function(ce,Ee){X.onload=ce,X.onerror=Ee}),Ja(R,"link",N),d.state.loading|=4,Kb(R,x.precedence,l),d.instance=R;case"script":return R=Jm(x.src),(C=l.querySelector(vx(R)))?(d.instance=C,si(C),C):(N=x,(C=Zl.get(R))&&(N=y({},x),b_(N,C)),l=l.ownerDocument||l,C=l.createElement("script"),si(C),Ja(C,"link",N),l.head.appendChild(C),d.instance=C);case"void":return null;default:throw Error(r(443,d.type))}else d.type==="stylesheet"&&(d.state.loading&4)===0&&(N=d.instance,d.state.loading|=4,Kb(N,x.precedence,l));return d.instance}function Kb(l,d,x){for(var N=x.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),C=N.length?N[N.length-1]:null,R=C,X=0;X title"):null)}function Pte(l,d,x){if(x===1||d.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof d.precedence!="string"||typeof d.href!="string"||d.href==="")break;return!0;case"link":if(typeof d.rel!="string"||typeof d.href!="string"||d.href===""||d.onLoad||d.onError)break;switch(d.rel){case"stylesheet":return l=d.disabled,typeof d.precedence=="string"&&l==null;default:return!0}case"script":if(d.async&&typeof d.async!="function"&&typeof d.async!="symbol"&&!d.onLoad&&!d.onError&&d.src&&typeof d.src=="string")return!0}return!1}function b6(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function Rte(l,d,x,N){if(x.type==="stylesheet"&&(typeof N.media!="string"||matchMedia(N.media).matches!==!1)&&(x.state.loading&4)===0){if(x.instance===null){var C=Zm(N.href),R=d.querySelector(bx(C));if(R){d=R._p,d!==null&&typeof d=="object"&&typeof d.then=="function"&&(l.count++,l=Xb.bind(l),d.then(l,l)),x.state.loading|=4,x.instance=R,si(R);return}R=d.ownerDocument||d,N=m6(N),(C=Zl.get(C))&&y_(N,C),R=R.createElement("link"),si(R);var X=R;X._p=new Promise(function(ce,Ee){X.onload=ce,X.onerror=Ee}),Ja(R,"link",N),x.instance=R}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(x,d),(d=x.state.preload)&&(x.state.loading&3)===0&&(l.count++,x=Xb.bind(l),d.addEventListener("load",x),d.addEventListener("error",x))}}var v_=0;function Dte(l,d){return l.stylesheets&&l.count===0&&Zb(l,l.stylesheets),0v_?50:800)+d);return l.unsuspend=x,function(){l.unsuspend=null,clearTimeout(N),clearTimeout(C)}}:null}function Xb(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Zb(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var Qb=null;function Zb(l,d){l.stylesheets=null,l.unsuspend!==null&&(l.count++,Qb=new Map,d.forEach(Mte,l),Qb=null,Xb.call(l))}function Mte(l,d){if(!(d.state.loading&4)){var x=Qb.get(l);if(x)var N=x.get(null);else{x=new Map,Qb.set(l,x);for(var C=l.querySelectorAll("link[data-precedence],style[data-precedence]"),R=0;R"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),I_.exports=tne(),I_.exports}var rne=nne(),KV=(e=>(e.BASE="base",e.BODY="body",e.HEAD="head",e.HTML="html",e.LINK="link",e.META="meta",e.NOSCRIPT="noscript",e.SCRIPT="script",e.STYLE="style",e.TITLE="title",e.FRAGMENT="Symbol(react.fragment)",e))(KV||{}),P_={link:{rel:["amphtml","canonical","alternate"]},script:{type:["application/ld+json"]},meta:{charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]}};Object.values(KV);var JI={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"};Object.entries(JI).reduce((e,[t,n])=>(e[n]=t,e),{});var M1="data-rh",ine=e=>Array.isArray(e)?e.join(""):e,sne=(e,t)=>{const n=Object.keys(e);for(let r=0;rArray.isArray(e)?e.reduce((n,r)=>(sne(r,t)?n.priority.push(r):n.default.push(r),n),{priority:[],default:[]}):{default:e,priority:[]},ane=["noscript","script","style"],yk=(e,t=!0)=>t===!1?String(e):String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),YV=e=>Object.keys(e).reduce((t,n)=>{const r=typeof e[n]<"u"?`${n}="${e[n]}"`:`${n}`;return t?`${t} ${r}`:r},""),one=(e,t,n,r)=>{const i=YV(n),a=ine(t);return i?`<${e} ${M1}="true" ${i}>${yk(a,r)}`:`<${e} ${M1}="true">${yk(a,r)}`},lne=(e,t,n=!0)=>t.reduce((r,i)=>{const a=i,o=Object.keys(a).filter(f=>!(f==="innerHTML"||f==="cssText")).reduce((f,m)=>{const y=typeof a[m]>"u"?m:`${m}="${yk(a[m],n)}"`;return f?`${f} ${y}`:y},""),c=a.innerHTML||a.cssText||"",h=ane.indexOf(e)===-1;return`${r}<${e} ${M1}="true" ${o}${h?"/>":`>${c}`}`},""),XV=(e,t={})=>Object.keys(e).reduce((n,r)=>{const i=JI[r];return n[i||r]=e[r],n},t),cne=(e,t,n)=>{const r={key:t,[M1]:!0},i=XV(n,r);return[se.createElement("title",i,t)]},Zv=(e,t)=>t.map((n,r)=>{const i={key:r,[M1]:!0};return Object.keys(n).forEach(a=>{const c=JI[a]||a;if(c==="innerHTML"||c==="cssText"){const h=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:h}}else i[c]=n[a]}),se.createElement(e,i)}),rc=(e,t,n=!0)=>{switch(e){case"title":return{toComponent:()=>cne(e,t.title,t.titleAttributes),toString:()=>one(e,t.title,t.titleAttributes,n)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>XV(t),toString:()=>YV(t)};default:return{toComponent:()=>Zv(e,t),toString:()=>lne(e,t,n)}}},une=({metaTags:e,linkTags:t,scriptTags:n,encode:r})=>{const i=R_(e,P_.meta),a=R_(t,P_.link),o=R_(n,P_.script);return{priorityMethods:{toComponent:()=>[...Zv("meta",i.priority),...Zv("link",a.priority),...Zv("script",o.priority)],toString:()=>`${rc("meta",i.priority,r)} ${rc("link",a.priority,r)} ${rc("script",o.priority,r)}`},metaTags:i.default,linkTags:a.default,scriptTags:o.default}},dne=e=>{const{baseTag:t,bodyAttributes:n,encode:r=!0,htmlAttributes:i,noscriptTags:a,styleTags:o,title:c="",titleAttributes:h,prioritizeSeoTags:f}=e;let{linkTags:m,metaTags:y,scriptTags:w}=e,A={toComponent:()=>[],toString:()=>""};return f&&({priorityMethods:A,linkTags:m,metaTags:y,scriptTags:w}=une(e)),{priority:A,base:rc("base",t,r),bodyAttributes:rc("bodyAttributes",n,r),htmlAttributes:rc("htmlAttributes",i,r),link:rc("link",m,r),meta:rc("meta",y,r),noscript:rc("noscript",a,r),script:rc("script",w,r),style:rc("style",o,r),title:rc("title",{title:c,titleAttributes:h},r)}},hne=dne,ov=[],QV=!!(typeof window<"u"&&window.document&&window.document.createElement),fne=class{constructor(e,t){yd(this,"instances",[]);yd(this,"canUseDOM",QV);yd(this,"context");yd(this,"value",{setHelmet:e=>{this.context.helmet=e},helmetInstances:{get:()=>this.canUseDOM?ov:this.instances,add:e=>{(this.canUseDOM?ov:this.instances).push(e)},remove:e=>{const t=(this.canUseDOM?ov:this.instances).indexOf(e);(this.canUseDOM?ov:this.instances).splice(t,1)}}});this.context=e,this.canUseDOM=t||!1,t||(e.helmet=hne({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},pne=parseInt(se.version.split(".")[0],10),$6=pne>=19,mne={},gne=se.createContext(mne),Cp,ZV=(Cp=class extends j.Component{constructor(n){super(n);yd(this,"helmetData");$6?this.helmetData=null:this.helmetData=new fne(this.props.context||{},Cp.canUseDOM)}render(){return $6?se.createElement(se.Fragment,null,this.props.children):se.createElement(gne.Provider,{value:this.helmetData.value},this.props.children)}},yd(Cp,"canUseDOM",QV),Cp),CN=WV();/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xne=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),yne=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),H6=e=>{const t=yne(e);return t.charAt(0).toUpperCase()+t.slice(1)},JV=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),bne=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var vne={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wne=j.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...c},h)=>j.createElement("svg",{ref:h,...vne,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:JV("lucide",i),...!a&&!bne(c)&&{"aria-hidden":"true"},...c},[...o.map(([f,m])=>j.createElement(f,m)),...Array.isArray(a)?a:[a]]));/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lt=(e,t)=>{const n=j.forwardRef(({className:r,...i},a)=>j.createElement(wne,{ref:a,iconNode:t,className:JV(`lucide-${xne(H6(e))}`,`lucide-${e}`,r),...i}));return n.displayName=H6(e),n};/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nne=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ene=Lt("activity",Nne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ane=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],_ne=Lt("arrow-left",Ane);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sne=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],ej=Lt("arrow-right",Sne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kne=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],eF=Lt("at-sign",kne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cne=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Su=Lt("bell",Cne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ine=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],jne=Lt("bookmark",Ine);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tne=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],One=Lt("bot",Tne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pne=[["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3",key:"cabbwy"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2",key:"1uxh74"}]],Rne=Lt("building",Pne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dne=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],H0=Lt("calendar",Dne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mne=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],bk=Lt("camera",Mne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lne=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],xp=Lt("chart-column",Lne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Une=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],Bne=Lt("check-check",Une);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zne=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Pu=Lt("check",zne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vne=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Md=Lt("chevron-down",Vne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fne=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Vp=Lt("chevron-left",Fne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ne=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Fp=Lt("chevron-right",$ne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hne=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],uf=Lt("chevron-up",Hne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gne=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],qne=Lt("chevrons-left",Gne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wne=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],Kne=Lt("chevrons-right",Wne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],tF=Lt("circle-alert",Yne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Xh=Lt("circle-check",Xne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],nF=Lt("circle-question-mark",Qne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zne=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],G6=Lt("clock",Zne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jne=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Pw=Lt("copy",Jne);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ere=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],q6=Lt("corner-down-left",ere);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tre=[["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}],["path",{d:"M9 14 4 9l5-5",key:"102s5s"}]],nre=Lt("corner-up-left",tre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rre=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],ire=Lt("cpu",rre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sre=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],lv=Lt("database",sre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const are=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],IN=Lt("download",are);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ore=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],lre=Lt("ellipsis",ore);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cre=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Va=Lt("external-link",cre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ure=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],W6=Lt("eye-off",ure);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dre=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Rw=Lt("eye",dre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hre=[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]],rF=Lt("facebook",hre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fre=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],E0=Lt("file-text",fre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pre=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],mre=Lt("film",pre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gre=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],iF=Lt("globe",gre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xre=[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]],yre=Lt("grip-horizontal",xre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bre=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],vre=Lt("hard-drive",bre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wre=[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]],Qh=Lt("headphones",wre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nre=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],ku=Lt("heart",Nre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ere=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],K6=Lt("house",Ere);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Are=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Bh=Lt("image",Are);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _re=[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]],sF=Lt("instagram",_re);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sre=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],kre=Lt("key",Sre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cre=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],wd=Lt("link",Cre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ire=[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]],aF=Lt("linkedin",Ire);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jre=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Pr=Lt("loader-circle",jre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tre=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],oF=Lt("lock",Tre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ore=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Js=Lt("mail",Ore);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pre=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],vk=Lt("map-pin",Pre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rre=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Dw=Lt("maximize-2",Rre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dre=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],hu=Lt("megaphone",Dre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mre=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],jN=Lt("menu",Mre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lre=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],G0=Lt("message-circle",Lre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ure=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Yi=Lt("message-square",Ure);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bre=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M16.95 16.95A7 7 0 0 1 5 12v-2",key:"cqa7eg"}],["path",{d:"M18.89 13.23A7 7 0 0 0 19 12v-2",key:"16hl24"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}]],zre=Lt("mic-off",Bre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vre=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],Fre=Lt("mic",Vre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $re=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],tj=Lt("minimize-2",$re);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hre=[["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-4 0v-9a2 2 0 0 1 2-2h2",key:"39pd36"}],["rect",{width:"8",height:"4",x:"10",y:"6",rx:"1",key:"aywv1n"}]],zh=Lt("newspaper",Hre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gre=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],qre=Lt("paperclip",Gre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wre=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],Y6=Lt("pause",Wre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kre=[["path",{d:"M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272",key:"1wngk7"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}],["path",{d:"M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473",key:"10hv5p"}]],lF=Lt("phone-off",Kre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yre=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],wk=Lt("phone",Yre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xre=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],g0=Lt("pin",Xre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qre=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],$p=Lt("play",Qre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zre=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],fu=Lt("plus",Zre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jre=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],eie=Lt("qr-code",Jre);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tie=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],sc=Lt("radio",tie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nie=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],rie=Lt("refresh-cw",nie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iie=[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]],X6=Lt("reply",iie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sie=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],cF=Lt("rotate-cw",sie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aie=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Q6=Lt("save",aie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oie=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ip=Lt("search",oie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lie=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],fl=Lt("send",lie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cie=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Nk=Lt("settings",cie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uie=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],df=Lt("share-2",uie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const die=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],hie=Lt("shield-alert",die);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fie=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],pl=Lt("shield-check",fie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pie=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],nj=Lt("shield",pie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mie=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],gie=Lt("shopping-bag",mie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xie=[["path",{d:"M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z",key:"15892j"}],["path",{d:"M3 20V4",key:"1ptbpl"}]],yie=Lt("skip-back",xie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bie=[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]],vie=Lt("skip-forward",bie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wie=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Nie=Lt("smartphone",wie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],uF=Lt("smile",Eie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aie=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],es=Lt("sparkles",Aie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ie=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],Ed=Lt("square-pen",_ie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sie=[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]],kie=Lt("thumbs-up",Sie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cie=[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]],No=Lt("ticket",Cie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iie=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],As=Lt("trash-2",Iie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jie=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],mu=Lt("trending-up",jie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tie=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],bu=Lt("triangle-alert",Tie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oie=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],dF=Lt("upload",Oie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pie=[["path",{d:"m16 11 2 2 4-4",key:"9rsbq5"}],["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],L1=Lt("user-check",Pie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rie=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],yp=Lt("user-plus",Rie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Die=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],TN=Lt("user",Die);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mie=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Ao=Lt("users",Mie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lie=[["path",{d:"M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196",key:"w8jjjt"}],["path",{d:"M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"1xawa7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Uie=Lt("video-off",Lie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bie=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Aa=Lt("video",Bie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zie=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],Vie=Lt("volume-2",zie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fie=[["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}],["path",{d:"M5 7c0-1.1.9-2 2-2h10a2 2 0 0 1 2 2v12H5V7Z",key:"1ezoue"}],["path",{d:"M22 19H2",key:"nuriw5"}]],Ek=Lt("vote",Fie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ie=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Hie=Lt("wifi-off",$ie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gie=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],qie=Lt("wifi",Gie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wie=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],er=Lt("x",Wie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kie=[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]],hF=Lt("youtube",Kie);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yie=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],fF=Lt("zap",Yie),Xie=()=>{};var Z6={};/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const pF=function(e){const t=[];let n=0;for(let r=0;r>6|192,t[n++]=i&63|128):(i&64512)===55296&&r+1>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128)}return t},Qie=function(e){const t=[];let n=0,r=0;for(;n191&&i<224){const a=e[n++];t[r++]=String.fromCharCode((i&31)<<6|a&63)}else if(i>239&&i<365){const a=e[n++],o=e[n++],c=e[n++],h=((i&7)<<18|(a&63)<<12|(o&63)<<6|c&63)-65536;t[r++]=String.fromCharCode(55296+(h>>10)),t[r++]=String.fromCharCode(56320+(h&1023))}else{const a=e[n++],o=e[n++];t[r++]=String.fromCharCode((i&15)<<12|(a&63)<<6|o&63)}}return t.join("")},mF={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(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let i=0;i>2,y=(a&3)<<4|c>>4;let w=(c&15)<<2|f>>6,A=f&63;h||(A=64,o||(w=64)),r.push(n[m],n[y],n[w],n[A])}return r.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(pF(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):Qie(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let i=0;i>4;if(r.push(w),f!==64){const A=c<<4&240|f>>2;if(r.push(A),y!==64){const k=f<<6&192|y;r.push(k)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class Zie extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const Jie=function(e){const t=pF(e);return mF.encodeByteArray(t,!0)},gF=function(e){return Jie(e).replace(/\./g,"")},xF=function(e){try{return mF.decodeString(e,!0)}catch(t){console.error("base64Decode failed: ",t)}return null};/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function yF(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const ese=()=>yF().__FIREBASE_DEFAULTS__,tse=()=>{if(typeof process>"u"||typeof Z6>"u")return;const e=Z6.__FIREBASE_DEFAULTS__;if(e)return JSON.parse(e)},nse=()=>{if(typeof document>"u")return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const t=e&&xF(e[1]);return t&&JSON.parse(t)},ON=()=>{try{return Xie()||ese()||tse()||nse()}catch(e){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`);return}},rse=e=>{var t,n;return(n=(t=ON())==null?void 0:t.emulatorHosts)==null?void 0:n[e]},bF=()=>{var e;return(e=ON())==null?void 0:e.config},vF=e=>{var t;return(t=ON())==null?void 0:t[`_${e}`]};/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class ise{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((t,n)=>{this.resolve=t,this.reject=n})}wrapCallback(t){return(n,r)=>{n?this.reject(n):this.resolve(r),typeof t=="function"&&(this.promise.catch(()=>{}),t.length===1?t(n):t(n,r))}}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function ka(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function sse(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(ka())}function wF(){var t;const e=(t=ON())==null?void 0:t.forceEnvironment;if(e==="node")return!0;if(e==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function ase(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function ose(){const e=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof e=="object"&&e.id!==void 0}function lse(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function cse(){const e=ka();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0}function NF(){return!wF()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function EF(){return!wF()&&!!navigator.userAgent&&(navigator.userAgent.includes("Safari")||navigator.userAgent.includes("WebKit"))&&!navigator.userAgent.includes("Chrome")}function AF(){try{return typeof indexedDB=="object"}catch{return!1}}function use(){return new Promise((e,t)=>{try{let n=!0;const r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),e(!0)},i.onupgradeneeded=()=>{n=!1},i.onerror=()=>{var a;t(((a=i.error)==null?void 0:a.message)||"")}}catch(n){t(n)}})}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const dse="FirebaseError";class Wd extends Error{constructor(t,n,r){super(n),this.code=t,this.customData=r,this.name=dse,Object.setPrototypeOf(this,Wd.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,yy.prototype.create)}}class yy{constructor(t,n,r){this.service=t,this.serviceName=n,this.errors=r}create(t,...n){const r=n[0]||{},i=`${this.service}/${t}`,a=this.errors[t],o=a?hse(a,r):"Error",c=`${this.serviceName}: ${o} (${i}).`;return new Wd(i,c,r)}}function hse(e,t){return e.replace(fse,(n,r)=>{const i=t[r];return i!=null?String(i):`<${r}?>`})}const fse=/\{\$([^}]+)}/g;function pse(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function Ld(e,t){if(e===t)return!0;const n=Object.keys(e),r=Object.keys(t);for(const i of n){if(!r.includes(i))return!1;const a=e[i],o=t[i];if(J6(a)&&J6(o)){if(!Ld(a,o))return!1}else if(a!==o)return!1}for(const i of r)if(!n.includes(i))return!1;return!0}function J6(e){return e!==null&&typeof e=="object"}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function by(e){const t=[];for(const[n,r]of Object.entries(e))Array.isArray(r)?r.forEach(i=>{t.push(encodeURIComponent(n)+"="+encodeURIComponent(i))}):t.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return t.length?"&"+t.join("&"):""}function e1(e){const t={};return e.replace(/^\?/,"").split("&").forEach(r=>{if(r){const[i,a]=r.split("=");t[decodeURIComponent(i)]=decodeURIComponent(a)}}),t}function t1(e){const t=e.indexOf("?");if(!t)return"";const n=e.indexOf("#",t);return e.substring(t,n>0?n:void 0)}function mse(e,t){const n=new gse(e,t);return n.subscribe.bind(n)}class gse{constructor(t,n){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=n,this.task.then(()=>{t(this)}).catch(r=>{this.error(r)})}next(t){this.forEachObserver(n=>{n.next(t)})}error(t){this.forEachObserver(n=>{n.error(t)}),this.close(t)}complete(){this.forEachObserver(t=>{t.complete()}),this.close()}subscribe(t,n,r){let i;if(t===void 0&&n===void 0&&r===void 0)throw new Error("Missing Observer.");xse(t,["next","error","complete"])?i=t:i={next:t,error:n,complete:r},i.next===void 0&&(i.next=D_),i.error===void 0&&(i.error=D_),i.complete===void 0&&(i.complete=D_);const a=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?i.error(this.finalError):i.complete()}catch{}}),this.observers.push(i),a}unsubscribeOne(t){this.observers===void 0||this.observers[t]===void 0||(delete this.observers[t],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(t){if(!this.finalized)for(let n=0;n{if(this.observers!==void 0&&this.observers[t]!==void 0)try{n(this.observers[t])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(t){this.finalized||(this.finalized=!0,t!==void 0&&(this.finalError=t),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function xse(e,t){if(typeof e!="object"||e===null)return!1;for(const n of t)if(n in e&&typeof e[n]=="function")return!0;return!1}function D_(){}/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Ca(e){return e&&e._delegate?e._delegate:e}/** * @license * Copyright 2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function vy(e){try{return(e.startsWith("http://")||e.startsWith("https://")?new URL(e).hostname:e).endsWith(".cloudworkstations.dev")}catch{return!1}}async function _F(e){return(await fetch(e,{credentials:"include"})).ok}class Hp{constructor(t,n,r){this.name=t,this.instanceFactory=n,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const ip="[DEFAULT]";/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */let yse=class{constructor(t,n){this.name=t,this.container=n,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(t){const n=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(n)){const r=new ise;if(this.instancesDeferred.set(n,r),this.isInitialized(n)||this.shouldAutoInitialize())try{const i=this.getOrInitializeService({instanceIdentifier:n});i&&r.resolve(i)}catch{}}return this.instancesDeferred.get(n).promise}getImmediate(t){const n=this.normalizeInstanceIdentifier(t==null?void 0:t.identifier),r=(t==null?void 0:t.optional)??!1;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(i){if(r)return null;throw i}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(t){if(t.name!==this.name)throw Error(`Mismatching Component ${t.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=t,!!this.shouldAutoInitialize()){if(vse(t))try{this.getOrInitializeService({instanceIdentifier:ip})}catch{}for(const[n,r]of this.instancesDeferred.entries()){const i=this.normalizeInstanceIdentifier(n);try{const a=this.getOrInitializeService({instanceIdentifier:i});r.resolve(a)}catch{}}}}clearInstance(t=ip){this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)}async delete(){const t=Array.from(this.instances.values());await Promise.all([...t.filter(n=>"INTERNAL"in n).map(n=>n.INTERNAL.delete()),...t.filter(n=>"_delete"in n).map(n=>n._delete())])}isComponentSet(){return this.component!=null}isInitialized(t=ip){return this.instances.has(t)}getOptions(t=ip){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:n={}}=t,r=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const i=this.getOrInitializeService({instanceIdentifier:r,options:n});for(const[a,o]of this.instancesDeferred.entries()){const c=this.normalizeInstanceIdentifier(a);r===c&&o.resolve(i)}return i}onInit(t,n){const r=this.normalizeInstanceIdentifier(n),i=this.onInitCallbacks.get(r)??new Set;i.add(t),this.onInitCallbacks.set(r,i);const a=this.instances.get(r);return a&&t(a,r),()=>{i.delete(t)}}invokeOnInitCallbacks(t,n){const r=this.onInitCallbacks.get(n);if(r)for(const i of r)try{i(t,n)}catch{}}getOrInitializeService({instanceIdentifier:t,options:n={}}){let r=this.instances.get(t);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:bse(t),options:n}),this.instances.set(t,r),this.instancesOptions.set(t,n),this.invokeOnInitCallbacks(r,t),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,t,r)}catch{}return r||null}normalizeInstanceIdentifier(t=ip){return this.component?this.component.multipleInstances?t:ip:t}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}};function bse(e){return e===ip?void 0:e}function vse(e){return e.instantiationMode==="EAGER"}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class wse{constructor(t){this.name=t,this.providers=new Map}addComponent(t){const n=this.getProvider(t.name);if(n.isComponentSet())throw new Error(`Component ${t.name} has already been registered with ${this.name}`);n.setComponent(t)}addOrOverwriteComponent(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)}getProvider(t){if(this.providers.has(t))return this.providers.get(t);const n=new yse(t,this);return this.providers.set(t,n),n}getProviders(){return Array.from(this.providers.values())}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var ri;(function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"})(ri||(ri={}));const Nse={debug:ri.DEBUG,verbose:ri.VERBOSE,info:ri.INFO,warn:ri.WARN,error:ri.ERROR,silent:ri.SILENT},Ese=ri.INFO,Ase={[ri.DEBUG]:"log",[ri.VERBOSE]:"log",[ri.INFO]:"info",[ri.WARN]:"warn",[ri.ERROR]:"error"},_se=(e,t,...n)=>{if(tt.some(n=>e instanceof n);let eR,tR;function kse(){return eR||(eR=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Cse(){return tR||(tR=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const SF=new WeakMap,Ak=new WeakMap,kF=new WeakMap,M_=new WeakMap,ij=new WeakMap;function Ise(e){const t=new Promise((n,r)=>{const i=()=>{e.removeEventListener("success",a),e.removeEventListener("error",o)},a=()=>{n(tf(e.result)),i()},o=()=>{r(e.error),i()};e.addEventListener("success",a),e.addEventListener("error",o)});return t.then(n=>{n instanceof IDBCursor&&SF.set(n,e)}).catch(()=>{}),ij.set(t,e),t}function jse(e){if(Ak.has(e))return;const t=new Promise((n,r)=>{const i=()=>{e.removeEventListener("complete",a),e.removeEventListener("error",o),e.removeEventListener("abort",o)},a=()=>{n(),i()},o=()=>{r(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",a),e.addEventListener("error",o),e.addEventListener("abort",o)});Ak.set(e,t)}let _k={get(e,t,n){if(e instanceof IDBTransaction){if(t==="done")return Ak.get(e);if(t==="objectStoreNames")return e.objectStoreNames||kF.get(e);if(t==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return tf(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function Tse(e){_k=e(_k)}function Ose(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...n){const r=e.call(L_(this),t,...n);return kF.set(r,t.sort?t.sort():[t]),tf(r)}:Cse().includes(e)?function(...t){return e.apply(L_(this),t),tf(SF.get(this))}:function(...t){return tf(e.apply(L_(this),t))}}function Pse(e){return typeof e=="function"?Ose(e):(e instanceof IDBTransaction&&jse(e),Sse(e,kse())?new Proxy(e,_k):e)}function tf(e){if(e instanceof IDBRequest)return Ise(e);if(M_.has(e))return M_.get(e);const t=Pse(e);return t!==e&&(M_.set(e,t),ij.set(t,e)),t}const L_=e=>ij.get(e);function Rse(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){const o=indexedDB.open(e,t),c=tf(o);return r&&o.addEventListener("upgradeneeded",h=>{r(tf(o.result),h.oldVersion,h.newVersion,tf(o.transaction),h)}),n&&o.addEventListener("blocked",h=>n(h.oldVersion,h.newVersion,h)),c.then(h=>{a&&h.addEventListener("close",()=>a()),i&&h.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),c}const Dse=["get","getKey","getAll","getAllKeys","count"],Mse=["put","add","delete","clear"],U_=new Map;function nR(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(U_.get(t))return U_.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=Mse.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||Dse.includes(n)))return;const a=async function(o,...c){const h=this.transaction(o,i?"readwrite":"readonly");let f=h.store;return r&&(f=f.index(c.shift())),(await Promise.all([f[n](...c),i&&h.done]))[0]};return U_.set(t,a),a}Tse(e=>({...e,get:(t,n,r)=>nR(t,n)||e.get(t,n,r),has:(t,n)=>!!nR(t,n)||e.has(t,n)}));/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Lse{constructor(t){this.container=t}getPlatformInfoString(){return this.container.getProviders().map(n=>{if(Use(n)){const r=n.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(n=>n).join(" ")}}function Use(e){const t=e.getComponent();return(t==null?void 0:t.type)==="VERSION"}const Sk="@firebase/app",rR="0.14.10";/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Ud=new rj("@firebase/app"),Bse="@firebase/app-compat",zse="@firebase/analytics-compat",Vse="@firebase/analytics",Fse="@firebase/app-check-compat",$se="@firebase/app-check",Hse="@firebase/auth",Gse="@firebase/auth-compat",qse="@firebase/database",Wse="@firebase/data-connect",Kse="@firebase/database-compat",Yse="@firebase/functions",Xse="@firebase/functions-compat",Qse="@firebase/installations",Zse="@firebase/installations-compat",Jse="@firebase/messaging",eae="@firebase/messaging-compat",tae="@firebase/performance",nae="@firebase/performance-compat",rae="@firebase/remote-config",iae="@firebase/remote-config-compat",sae="@firebase/storage",aae="@firebase/storage-compat",oae="@firebase/firestore",lae="@firebase/ai",cae="@firebase/firestore-compat",uae="firebase",dae="12.11.0";/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const kk="[DEFAULT]",hae={[Sk]:"fire-core",[Bse]:"fire-core-compat",[Vse]:"fire-analytics",[zse]:"fire-analytics-compat",[$se]:"fire-app-check",[Fse]:"fire-app-check-compat",[Hse]:"fire-auth",[Gse]:"fire-auth-compat",[qse]:"fire-rtdb",[Wse]:"fire-data-connect",[Kse]:"fire-rtdb-compat",[Yse]:"fire-fn",[Xse]:"fire-fn-compat",[Qse]:"fire-iid",[Zse]:"fire-iid-compat",[Jse]:"fire-fcm",[eae]:"fire-fcm-compat",[tae]:"fire-perf",[nae]:"fire-perf-compat",[rae]:"fire-rc",[iae]:"fire-rc-compat",[sae]:"fire-gcs",[aae]:"fire-gcs-compat",[oae]:"fire-fst",[cae]:"fire-fst-compat",[lae]:"fire-vertex","fire-js":"fire-js",[uae]:"fire-js-all"};/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Mw=new Map,fae=new Map,Ck=new Map;function iR(e,t){try{e.container.addComponent(t)}catch(n){Ud.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function q0(e){const t=e.name;if(Ck.has(t))return Ud.debug(`There were multiple attempts to register component ${t}.`),!1;Ck.set(t,e);for(const n of Mw.values())iR(n,e);for(const n of fae.values())iR(n,e);return!0}function sj(e,t){const n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function Pl(e){return e==null?!1:e.settings!==void 0}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const pae={"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."},nf=new yy("app","Firebase",pae);/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class mae{constructor(t,n,r){this._isDeleted=!1,this._options={...t},this._config={...n},this._name=n.name,this._automaticDataCollectionEnabled=n.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new Hp("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(t){this.checkDestroyed(),this._automaticDataCollectionEnabled=t}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(t){this._isDeleted=t}checkDestroyed(){if(this.isDeleted)throw nf.create("app-deleted",{appName:this._name})}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const _g=dae;function CF(e,t={}){let n=e;typeof t!="object"&&(t={name:t});const r={name:kk,automaticDataCollectionEnabled:!0,...t},i=r.name;if(typeof i!="string"||!i)throw nf.create("bad-app-name",{appName:String(i)});if(n||(n=bF()),!n)throw nf.create("no-options");const a=Mw.get(i);if(a){if(Ld(n,a.options)&&Ld(r,a.config))return a;throw nf.create("duplicate-app",{appName:i})}const o=new wse(i);for(const h of Ck.values())o.addComponent(h);const c=new mae(n,r,o);return Mw.set(i,c),c}function gae(e=kk){const t=Mw.get(e);if(!t&&e===kk&&bF())return CF();if(!t)throw nf.create("no-app",{appName:e});return t}function rf(e,t,n){let r=hae[e]??e;n&&(r+=`-${n}`);const i=r.match(/\s|\//),a=t.match(/\s|\//);if(i||a){const o=[`Unable to register library "${r}" with version "${t}":`];i&&o.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&a&&o.push("and"),a&&o.push(`version name "${t}" contains illegal characters (whitespace or "/")`),Ud.warn(o.join(" "));return}q0(new Hp(`${r}-version`,()=>({library:r,version:t}),"VERSION"))}/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const xae="firebase-heartbeat-database",yae=1,U1="firebase-heartbeat-store";let B_=null;function IF(){return B_||(B_=Rse(xae,yae,{upgrade:(e,t)=>{switch(t){case 0:try{e.createObjectStore(U1)}catch(n){console.warn(n)}}}}).catch(e=>{throw nf.create("idb-open",{originalErrorMessage:e.message})})),B_}async function bae(e){try{const n=(await IF()).transaction(U1),r=await n.objectStore(U1).get(jF(e));return await n.done,r}catch(t){if(t instanceof Wd)Ud.warn(t.message);else{const n=nf.create("idb-get",{originalErrorMessage:t==null?void 0:t.message});Ud.warn(n.message)}}}async function sR(e,t){try{const r=(await IF()).transaction(U1,"readwrite");await r.objectStore(U1).put(t,jF(e)),await r.done}catch(n){if(n instanceof Wd)Ud.warn(n.message);else{const r=nf.create("idb-set",{originalErrorMessage:n==null?void 0:n.message});Ud.warn(r.message)}}}function jF(e){return`${e.name}!${e.options.appId}`}/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const vae=1024,wae=30;class Nae{constructor(t){this.container=t,this._heartbeatsCache=null;const n=this.container.getProvider("app").getImmediate();this._storage=new Aae(n),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){var t,n;try{const i=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),a=aR();if(((t=this._heartbeatsCache)==null?void 0:t.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((n=this._heartbeatsCache)==null?void 0:n.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===a||this._heartbeatsCache.heartbeats.some(o=>o.date===a))return;if(this._heartbeatsCache.heartbeats.push({date:a,agent:i}),this._heartbeatsCache.heartbeats.length>wae){const o=_ae(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(o,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(r){Ud.warn(r)}}async getHeartbeatsHeader(){var t;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((t=this._heartbeatsCache)==null?void 0:t.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const n=aR(),{heartbeatsToSend:r,unsentEntries:i}=Eae(this._heartbeatsCache.heartbeats),a=gF(JSON.stringify({version:2,heartbeats:r}));return this._heartbeatsCache.lastSentHeartbeatDate=n,i.length>0?(this._heartbeatsCache.heartbeats=i,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),a}catch(n){return Ud.warn(n),""}}}function aR(){return new Date().toISOString().substring(0,10)}function Eae(e,t=vae){const n=[];let r=e.slice();for(const i of e){const a=n.find(o=>o.agent===i.agent);if(a){if(a.dates.push(i.date),oR(n)>t){a.dates.pop();break}}else if(n.push({agent:i.agent,dates:[i.date]}),oR(n)>t){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}class Aae{constructor(t){this.app=t,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return AF()?use().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const n=await bae(this.app);return n!=null&&n.heartbeats?n:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(t){if(await this._canUseIndexedDBPromise){const r=await this.read();return sR(this.app,{lastSentHeartbeatDate:t.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:t.heartbeats})}else return}async add(t){if(await this._canUseIndexedDBPromise){const r=await this.read();return sR(this.app,{lastSentHeartbeatDate:t.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...t.heartbeats]})}else return}}function oR(e){return gF(JSON.stringify({version:2,heartbeats:e})).length}function _ae(e){if(e.length===0)return-1;let t=0,n=e[0].date;for(let r=1;rnew Lse(t),"PRIVATE")),q0(new Hp("heartbeat",t=>new Nae(t),"PRIVATE")),rf(Sk,rR,e),rf(Sk,rR,"esm2020"),rf("fire-js","")}Sae("");var kae="firebase",Cae="12.11.0";/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */rf(kae,Cae,"app");function TF(){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 Iae=TF,OF=new yy("auth","Firebase",TF());/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Lw=new rj("@firebase/auth");function jae(e,...t){Lw.logLevel<=ri.WARN&&Lw.warn(`Auth (${_g}): ${e}`,...t)}function Jv(e,...t){Lw.logLevel<=ri.ERROR&&Lw.error(`Auth (${_g}): ${e}`,...t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function dc(e,...t){throw oj(e,...t)}function Lc(e,...t){return oj(e,...t)}function aj(e,t,n){const r={...Iae(),[t]:n};return new yy("auth","Firebase",r).create(t,{appName:e.name})}function Od(e){return aj(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function Tae(e,t,n){const r=n;if(!(t instanceof r))throw r.name!==t.constructor.name&&dc(e,"argument-error"),aj(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function oj(e,...t){if(typeof e!="string"){const n=t[0],r=[...t.slice(1)];return r[0]&&(r[0].appName=e.name),e._errorFactory.create(n,...r)}return OF.create(e,...t)}function gr(e,t,...n){if(!e)throw oj(t,...n)}function kd(e){const t="INTERNAL ASSERTION FAILED: "+e;throw Jv(t),new Error(t)}function Bd(e,t){e||kd(t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Ik(){var e;return typeof self<"u"&&((e=self.location)==null?void 0:e.href)||""}function Oae(){return lR()==="http:"||lR()==="https:"}function lR(){var e;return typeof self<"u"&&((e=self.location)==null?void 0:e.protocol)||null}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Pae(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(Oae()||ose()||"connection"in navigator)?navigator.onLine:!0}function Rae(){if(typeof navigator>"u")return null;const e=navigator;return e.languages&&e.languages[0]||e.language||null}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class wy{constructor(t,n){this.shortDelay=t,this.longDelay=n,Bd(n>t,"Short delay should be less than long delay!"),this.isMobile=sse()||lse()}get(){return Pae()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function lj(e,t){Bd(e.emulator,"Emulator should always be set here");const{url:n}=e.emulator;return t?`${n}${t.startsWith("/")?t.slice(1):t}`:n}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class PF{static initialize(t,n,r){this.fetchImpl=t,n&&(this.headersImpl=n),r&&(this.responseImpl=r)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;kd("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;kd("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;kd("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Dae={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Mae=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],Lae=new wy(3e4,6e4);function vf(e,t){return e.tenantId&&!t.tenantId?{...t,tenantId:e.tenantId}:t}async function Kd(e,t,n,r,i={}){return RF(e,i,async()=>{let a={},o={};r&&(t==="GET"?o=r:a={body:JSON.stringify(r)});const c=by({key:e.config.apiKey,...o}).slice(1),h=await e._getAdditionalHeaders();h["Content-Type"]="application/json",e.languageCode&&(h["X-Firebase-Locale"]=e.languageCode);const f={method:t,headers:h,...a};return ase()||(f.referrerPolicy="no-referrer"),e.emulatorConfig&&vy(e.emulatorConfig.host)&&(f.credentials="include"),PF.fetch()(await DF(e,e.config.apiHost,n,c),f)})}async function RF(e,t,n){e._canInitEmulator=!1;const r={...Dae,...t};try{const i=new Bae(e),a=await Promise.race([n(),i.promise]);i.clearNetworkTimeout();const o=await a.json();if("needConfirmation"in o)throw cv(e,"account-exists-with-different-credential",o);if(a.ok&&!("errorMessage"in o))return o;{const c=a.ok?o.errorMessage:o.error.message,[h,f]=c.split(" : ");if(h==="FEDERATED_USER_ID_ALREADY_LINKED")throw cv(e,"credential-already-in-use",o);if(h==="EMAIL_EXISTS")throw cv(e,"email-already-in-use",o);if(h==="USER_DISABLED")throw cv(e,"user-disabled",o);const m=r[h]||h.toLowerCase().replace(/[_\s]+/g,"-");if(f)throw aj(e,m,f);dc(e,m)}}catch(i){if(i instanceof Wd)throw i;dc(e,"network-request-failed",{message:String(i)})}}async function Ny(e,t,n,r,i={}){const a=await Kd(e,t,n,r,i);return"mfaPendingCredential"in a&&dc(e,"multi-factor-auth-required",{_serverResponse:a}),a}async function DF(e,t,n,r){const i=`${t}${n}?${r}`,a=e,o=a.config.emulator?lj(e.config,i):`${e.config.apiScheme}://${i}`;return Mae.includes(n)&&(await a._persistenceManagerAvailable,a._getPersistenceType()==="COOKIE")?a._getPersistence()._getFinalTarget(o).toString():o}function Uae(e){switch(e){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class Bae{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(t){this.auth=t,this.timer=null,this.promise=new Promise((n,r)=>{this.timer=setTimeout(()=>r(Lc(this.auth,"network-request-failed")),Lae.get())})}}function cv(e,t,n){const r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=Lc(e,t,r);return i.customData._tokenResponse=n,i}function cR(e){return e!==void 0&&e.enterprise!==void 0}class zae{constructor(t){if(this.siteKey="",this.recaptchaEnforcementState=[],t.recaptchaKey===void 0)throw new Error("recaptchaKey undefined");this.siteKey=t.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=t.recaptchaEnforcementState}getProviderEnforcementState(t){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(const n of this.recaptchaEnforcementState)if(n.provider&&n.provider===t)return Uae(n.enforcementState);return null}isProviderEnabled(t){return this.getProviderEnforcementState(t)==="ENFORCE"||this.getProviderEnforcementState(t)==="AUDIT"}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function Vae(e,t){return Kd(e,"GET","/v2/recaptchaConfig",vf(e,t))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function Fae(e,t){return Kd(e,"POST","/v1/accounts:delete",t)}async function Uw(e,t){return Kd(e,"POST","/v1/accounts:lookup",t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function p1(e){if(e)try{const t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch{}}async function $ae(e,t=!1){const n=Ca(e),r=await n.getIdToken(t),i=cj(r);gr(i&&i.exp&&i.auth_time&&i.iat,n.auth,"internal-error");const a=typeof i.firebase=="object"?i.firebase:void 0,o=a==null?void 0:a.sign_in_provider;return{claims:i,token:r,authTime:p1(z_(i.auth_time)),issuedAtTime:p1(z_(i.iat)),expirationTime:p1(z_(i.exp)),signInProvider:o||null,signInSecondFactor:(a==null?void 0:a.sign_in_second_factor)||null}}function z_(e){return Number(e)*1e3}function cj(e){const[t,n,r]=e.split(".");if(t===void 0||n===void 0||r===void 0)return Jv("JWT malformed, contained fewer than 3 sections"),null;try{const i=xF(n);return i?JSON.parse(i):(Jv("Failed to decode base64 JWT payload"),null)}catch(i){return Jv("Caught error parsing JWT payload as JSON",i==null?void 0:i.toString()),null}}function uR(e){const t=cj(e);return gr(t,"internal-error"),gr(typeof t.exp<"u","internal-error"),gr(typeof t.iat<"u","internal-error"),Number(t.exp)-Number(t.iat)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function W0(e,t,n=!1){if(n)return t;try{return await t}catch(r){throw r instanceof Wd&&Hae(r)&&e.auth.currentUser===e&&await e.auth.signOut(),r}}function Hae({code:e}){return e==="auth/user-disabled"||e==="auth/user-token-expired"}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Gae{constructor(t){this.user=t,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(t){if(t){const n=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),n}else{this.errorBackoff=3e4;const r=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,r)}}schedule(t=!1){if(!this.isRunning)return;const n=this.getInterval(t);this.timerId=setTimeout(async()=>{await this.iteration()},n)}async iteration(){try{await this.user.getIdToken(!0)}catch(t){(t==null?void 0:t.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class jk{constructor(t,n){this.createdAt=t,this.lastLoginAt=n,this._initializeTime()}_initializeTime(){this.lastSignInTime=p1(this.lastLoginAt),this.creationTime=p1(this.createdAt)}_copy(t){this.createdAt=t.createdAt,this.lastLoginAt=t.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function Bw(e){var y;const t=e.auth,n=await e.getIdToken(),r=await W0(e,Uw(t,{idToken:n}));gr(r==null?void 0:r.users.length,t,"internal-error");const i=r.users[0];e._notifyReloadListener(i);const a=(y=i.providerUserInfo)!=null&&y.length?MF(i.providerUserInfo):[],o=Wae(e.providerData,a),c=e.isAnonymous,h=!(e.email&&i.passwordHash)&&!(o!=null&&o.length),f=c?h:!1,m={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:o,metadata:new jk(i.createdAt,i.lastLoginAt),isAnonymous:f};Object.assign(e,m)}async function qae(e){const t=Ca(e);await Bw(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}function Wae(e,t){return[...e.filter(r=>!t.some(i=>i.providerId===r.providerId)),...t]}function MF(e){return e.map(({providerId:t,...n})=>({providerId:t,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function Kae(e,t){const n=await RF(e,{},async()=>{const r=by({grant_type:"refresh_token",refresh_token:t}).slice(1),{tokenApiHost:i,apiKey:a}=e.config,o=await DF(e,i,"/v1/token",`key=${a}`),c=await e._getAdditionalHeaders();c["Content-Type"]="application/x-www-form-urlencoded";const h={method:"POST",headers:c,body:r};return e.emulatorConfig&&vy(e.emulatorConfig.host)&&(h.credentials="include"),PF.fetch()(o,h)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async function Yae(e,t){return Kd(e,"POST","/v2/accounts:revokeToken",vf(e,t))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class P0{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(t){gr(t.idToken,"internal-error"),gr(typeof t.idToken<"u","internal-error"),gr(typeof t.refreshToken<"u","internal-error");const n="expiresIn"in t&&typeof t.expiresIn<"u"?Number(t.expiresIn):uR(t.idToken);this.updateTokensAndExpiration(t.idToken,t.refreshToken,n)}updateFromIdToken(t){gr(t.length!==0,"internal-error");const n=uR(t);this.updateTokensAndExpiration(t,null,n)}async getToken(t,n=!1){return!n&&this.accessToken&&!this.isExpired?this.accessToken:(gr(this.refreshToken,t,"user-token-expired"),this.refreshToken?(await this.refresh(t,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(t,n){const{accessToken:r,refreshToken:i,expiresIn:a}=await Kae(t,n);this.updateTokensAndExpiration(r,i,Number(a))}updateTokensAndExpiration(t,n,r){this.refreshToken=n||null,this.accessToken=t||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(t,n){const{refreshToken:r,accessToken:i,expirationTime:a}=n,o=new P0;return r&&(gr(typeof r=="string","internal-error",{appName:t}),o.refreshToken=r),i&&(gr(typeof i=="string","internal-error",{appName:t}),o.accessToken=i),a&&(gr(typeof a=="number","internal-error",{appName:t}),o.expirationTime=a),o}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(t){this.accessToken=t.accessToken,this.refreshToken=t.refreshToken,this.expirationTime=t.expirationTime}_clone(){return Object.assign(new P0,this.toJSON())}_performRefresh(){return kd("not implemented")}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Ch(e,t){gr(typeof e=="string"||typeof e>"u","internal-error",{appName:t})}class Mc{constructor({uid:t,auth:n,stsTokenManager:r,...i}){this.providerId="firebase",this.proactiveRefresh=new Gae(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=n,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=i.displayName||null,this.email=i.email||null,this.emailVerified=i.emailVerified||!1,this.phoneNumber=i.phoneNumber||null,this.photoURL=i.photoURL||null,this.isAnonymous=i.isAnonymous||!1,this.tenantId=i.tenantId||null,this.providerData=i.providerData?[...i.providerData]:[],this.metadata=new jk(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(t){const n=await W0(this,this.stsTokenManager.getToken(this.auth,t));return gr(n,this.auth,"internal-error"),this.accessToken!==n&&(this.accessToken=n,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),n}getIdTokenResult(t){return $ae(this,t)}reload(){return qae(this)}_assign(t){this!==t&&(gr(this.uid===t.uid,this.auth,"internal-error"),this.displayName=t.displayName,this.photoURL=t.photoURL,this.email=t.email,this.emailVerified=t.emailVerified,this.phoneNumber=t.phoneNumber,this.isAnonymous=t.isAnonymous,this.tenantId=t.tenantId,this.providerData=t.providerData.map(n=>({...n})),this.metadata._copy(t.metadata),this.stsTokenManager._assign(t.stsTokenManager))}_clone(t){const n=new Mc({...this,auth:t,stsTokenManager:this.stsTokenManager._clone()});return n.metadata._copy(this.metadata),n}_onReload(t){gr(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=t,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(t){this.reloadListener?this.reloadListener(t):this.reloadUserInfo=t}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(t,n=!1){let r=!1;t.idToken&&t.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(t),r=!0),n&&await Bw(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Pl(this.auth.app))return Promise.reject(Od(this.auth));const t=await this.getIdToken();return await W0(this,Fae(this.auth,{idToken:t})),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(t=>({...t})),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(t,n){const r=n.displayName??void 0,i=n.email??void 0,a=n.phoneNumber??void 0,o=n.photoURL??void 0,c=n.tenantId??void 0,h=n._redirectEventId??void 0,f=n.createdAt??void 0,m=n.lastLoginAt??void 0,{uid:y,emailVerified:w,isAnonymous:A,providerData:k,stsTokenManager:I}=n;gr(y&&I,t,"internal-error");const T=P0.fromJSON(this.name,I);gr(typeof y=="string",t,"internal-error"),Ch(r,t.name),Ch(i,t.name),gr(typeof w=="boolean",t,"internal-error"),gr(typeof A=="boolean",t,"internal-error"),Ch(a,t.name),Ch(o,t.name),Ch(c,t.name),Ch(h,t.name),Ch(f,t.name),Ch(m,t.name);const D=new Mc({uid:y,auth:t,email:i,emailVerified:w,displayName:r,isAnonymous:A,photoURL:o,phoneNumber:a,tenantId:c,stsTokenManager:T,createdAt:f,lastLoginAt:m});return k&&Array.isArray(k)&&(D.providerData=k.map(F=>({...F}))),h&&(D._redirectEventId=h),D}static async _fromIdTokenResponse(t,n,r=!1){const i=new P0;i.updateFromServerResponse(n);const a=new Mc({uid:n.localId,auth:t,stsTokenManager:i,isAnonymous:r});return await Bw(a),a}static async _fromGetAccountInfoResponse(t,n,r){const i=n.users[0];gr(i.localId!==void 0,"internal-error");const a=i.providerUserInfo!==void 0?MF(i.providerUserInfo):[],o=!(i.email&&i.passwordHash)&&!(a!=null&&a.length),c=new P0;c.updateFromIdToken(r);const h=new Mc({uid:i.localId,auth:t,stsTokenManager:c,isAnonymous:o}),f={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:a,metadata:new jk(i.createdAt,i.lastLoginAt),isAnonymous:!(i.email&&i.passwordHash)&&!(a!=null&&a.length)};return Object.assign(h,f),h}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const dR=new Map;function Cd(e){Bd(e instanceof Function,"Expected a class definition");let t=dR.get(e);return t?(Bd(t instanceof e,"Instance stored in cache mismatched with class"),t):(t=new e,dR.set(e,t),t)}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class LF{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(t,n){this.storage[t]=n}async _get(t){const n=this.storage[t];return n===void 0?null:n}async _remove(t){delete this.storage[t]}_addListener(t,n){}_removeListener(t,n){}}LF.type="NONE";const hR=LF;/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function ew(e,t,n){return`firebase:${e}:${t}:${n}`}class R0{constructor(t,n,r){this.persistence=t,this.auth=n,this.userKey=r;const{config:i,name:a}=this.auth;this.fullUserKey=ew(this.userKey,i.apiKey,a),this.fullPersistenceKey=ew("persistence",i.apiKey,a),this.boundEventHandler=n._onStorageEvent.bind(n),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(t){return this.persistence._set(this.fullUserKey,t.toJSON())}async getCurrentUser(){const t=await this.persistence._get(this.fullUserKey);if(!t)return null;if(typeof t=="string"){const n=await Uw(this.auth,{idToken:t}).catch(()=>{});return n?Mc._fromGetAccountInfoResponse(this.auth,n,t):null}return Mc._fromJSON(this.auth,t)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(t){if(this.persistence===t)return;const n=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=t,n)return this.setCurrentUser(n)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(t,n,r="authUser"){if(!n.length)return new R0(Cd(hR),t,r);const i=(await Promise.all(n.map(async f=>{if(await f._isAvailable())return f}))).filter(f=>f);let a=i[0]||Cd(hR);const o=ew(r,t.config.apiKey,t.name);let c=null;for(const f of n)try{const m=await f._get(o);if(m){let y;if(typeof m=="string"){const w=await Uw(t,{idToken:m}).catch(()=>{});if(!w)break;y=await Mc._fromGetAccountInfoResponse(t,w,m)}else y=Mc._fromJSON(t,m);f!==a&&(c=y),a=f;break}}catch{}const h=i.filter(f=>f._shouldAllowMigration);return!a._shouldAllowMigration||!h.length?new R0(a,t,r):(a=h[0],c&&await a._set(o,c.toJSON()),await Promise.all(n.map(async f=>{if(f!==a)try{await f._remove(o)}catch{}})),new R0(a,t,r))}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function fR(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(VF(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(UF(t))return"Firefox";if(t.includes("silk/"))return"Silk";if($F(t))return"Blackberry";if(HF(t))return"Webos";if(BF(t))return"Safari";if((t.includes("chrome/")||zF(t))&&!t.includes("edge/"))return"Chrome";if(FF(t))return"Android";{const n=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=e.match(n);if((r==null?void 0:r.length)===2)return r[1]}return"Other"}function UF(e=ka()){return/firefox\//i.test(e)}function BF(e=ka()){const t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function zF(e=ka()){return/crios\//i.test(e)}function VF(e=ka()){return/iemobile/i.test(e)}function FF(e=ka()){return/android/i.test(e)}function $F(e=ka()){return/blackberry/i.test(e)}function HF(e=ka()){return/webos/i.test(e)}function uj(e=ka()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function Xae(e=ka()){var t;return uj(e)&&!!((t=window.navigator)!=null&&t.standalone)}function Qae(){return cse()&&document.documentMode===10}function GF(e=ka()){return uj(e)||FF(e)||HF(e)||$F(e)||/windows phone/i.test(e)||VF(e)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function qF(e,t=[]){let n;switch(e){case"Browser":n=fR(ka());break;case"Worker":n=`${fR(ka())}-${e}`;break;default:n=e}const r=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${_g}/${r}`}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Zae{constructor(t){this.auth=t,this.queue=[]}pushCallback(t,n){const r=a=>new Promise((o,c)=>{try{const h=t(a);o(h)}catch(h){c(h)}});r.onAbort=n,this.queue.push(r);const i=this.queue.length-1;return()=>{this.queue[i]=()=>Promise.resolve()}}async runMiddleware(t){if(this.auth.currentUser===t)return;const n=[];try{for(const r of this.queue)await r(t),r.onAbort&&n.push(r.onAbort)}catch(r){n.reverse();for(const i of n)try{i()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r==null?void 0:r.message})}}}/** * @license * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function Jae(e,t={}){return Kd(e,"GET","/v2/passwordPolicy",vf(e,t))}/** * @license * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const eoe=6;class toe{constructor(t){var r;const n=t.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=n.minPasswordLength??eoe,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=t.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=((r=t.allowedNonAlphanumericCharacters)==null?void 0:r.join(""))??"",this.forceUpgradeOnSignin=t.forceUpgradeOnSignin??!1,this.schemaVersion=t.schemaVersion}validatePassword(t){const n={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(t,n),this.validatePasswordCharacterOptions(t,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(t,n){const r=this.customStrengthOptions.minPasswordLength,i=this.customStrengthOptions.maxPasswordLength;r&&(n.meetsMinPasswordLength=t.length>=r),i&&(n.meetsMaxPasswordLength=t.length<=i)}validatePasswordCharacterOptions(t,n){this.updatePasswordCharacterOptionsStatuses(n,!1,!1,!1,!1);let r;for(let i=0;i="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(t,n,r,i,a){this.customStrengthOptions.containsLowercaseLetter&&(t.containsLowercaseLetter||(t.containsLowercaseLetter=n)),this.customStrengthOptions.containsUppercaseLetter&&(t.containsUppercaseLetter||(t.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(t.containsNumericCharacter||(t.containsNumericCharacter=i)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(t.containsNonAlphanumericCharacter||(t.containsNonAlphanumericCharacter=a))}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class noe{constructor(t,n,r,i){this.app=t,this.heartbeatServiceProvider=n,this.appCheckServiceProvider=r,this.config=i,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new pR(this),this.idTokenSubscription=new pR(this),this.beforeStateQueue=new Zae(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=OF,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=t.name,this.clientVersion=i.sdkClientVersion,this._persistenceManagerAvailable=new Promise(a=>this._resolvePersistenceManagerAvailable=a)}_initializeWithPersistence(t,n){return n&&(this._popupRedirectResolver=Cd(n)),this._initializationPromise=this.queue(async()=>{var r,i,a;if(!this._deleted&&(this.persistenceManager=await R0.create(this,t),(r=this._resolvePersistenceManagerAvailable)==null||r.call(this),!this._deleted)){if((i=this._popupRedirectResolver)!=null&&i._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(n),this.lastNotifiedUid=((a=this.currentUser)==null?void 0:a.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const t=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!t)){if(this.currentUser&&t&&this.currentUser.uid===t.uid){this._currentUser._assign(t),await this.currentUser.getIdToken();return}await this._updateCurrentUser(t,!0)}}async initializeCurrentUserFromIdToken(t){try{const n=await Uw(this,{idToken:t}),r=await Mc._fromGetAccountInfoResponse(this,n,t);await this.directlySetCurrentUser(r)}catch(n){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",n),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(t){var a;if(Pl(this.app)){const o=this.app.settings.authIdToken;return o?new Promise(c=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(o).then(c,c))}):this.directlySetCurrentUser(null)}const n=await this.assertedPersistence.getCurrentUser();let r=n,i=!1;if(t&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const o=(a=this.redirectUser)==null?void 0:a._redirectEventId,c=r==null?void 0:r._redirectEventId,h=await this.tryRedirectSignIn(t);(!o||o===c)&&(h!=null&&h.user)&&(r=h.user,i=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(i)try{await this.beforeStateQueue.runMiddleware(r)}catch(o){r=n,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(o))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return gr(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(t){let n=null;try{n=await this._popupRedirectResolver._completeRedirectFn(this,t,!0)}catch{await this._setRedirectUser(null)}return n}async reloadAndSetCurrentUserOrClear(t){try{await Bw(t)}catch(n){if((n==null?void 0:n.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(t)}useDeviceLanguage(){this.languageCode=Rae()}async _delete(){this._deleted=!0}async updateCurrentUser(t){if(Pl(this.app))return Promise.reject(Od(this));const n=t?Ca(t):null;return n&&gr(n.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(n&&n._clone(this))}async _updateCurrentUser(t,n=!1){if(!this._deleted)return t&&gr(this.tenantId===t.tenantId,this,"tenant-id-mismatch"),n||await this.beforeStateQueue.runMiddleware(t),this.queue(async()=>{await this.directlySetCurrentUser(t),this.notifyAuthListeners()})}async signOut(){return Pl(this.app)?Promise.reject(Od(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(t){return Pl(this.app)?Promise.reject(Od(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(Cd(t))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(t){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(t)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const t=await Jae(this),n=new toe(t);this.tenantId===null?this._projectPasswordPolicy=n:this._tenantPasswordPolicies[this.tenantId]=n}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(t){this._errorFactory=new yy("auth","Firebase",t())}onAuthStateChanged(t,n,r){return this.registerStateListener(this.authStateSubscription,t,n,r)}beforeAuthStateChanged(t,n){return this.beforeStateQueue.pushCallback(t,n)}onIdTokenChanged(t,n,r){return this.registerStateListener(this.idTokenSubscription,t,n,r)}authStateReady(){return new Promise((t,n)=>{if(this.currentUser)t();else{const r=this.onAuthStateChanged(()=>{r(),t()},n)}})}async revokeAccessToken(t){if(this.currentUser){const n=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:t,idToken:n};this.tenantId!=null&&(r.tenantId=this.tenantId),await Yae(this,r)}}toJSON(){var t;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(t=this._currentUser)==null?void 0:t.toJSON()}}async _setRedirectUser(t,n){const r=await this.getOrInitRedirectPersistenceManager(n);return t===null?r.removeCurrentUser():r.setCurrentUser(t)}async getOrInitRedirectPersistenceManager(t){if(!this.redirectPersistenceManager){const n=t&&Cd(t)||this._popupRedirectResolver;gr(n,this,"argument-error"),this.redirectPersistenceManager=await R0.create(this,[Cd(n._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(t){var n,r;return this._isInitialized&&await this.queue(async()=>{}),((n=this._currentUser)==null?void 0:n._redirectEventId)===t?this._currentUser:((r=this.redirectUser)==null?void 0:r._redirectEventId)===t?this.redirectUser:null}async _persistUserIfCurrent(t){if(t===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(t))}_notifyListenersIfCurrent(t){t===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var n;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const t=((n=this.currentUser)==null?void 0:n.uid)??null;this.lastNotifiedUid!==t&&(this.lastNotifiedUid=t,this.authStateSubscription.next(this.currentUser))}registerStateListener(t,n,r,i){if(this._deleted)return()=>{};const a=typeof n=="function"?n:n.next.bind(n);let o=!1;const c=this._isInitialized?Promise.resolve():this._initializationPromise;if(gr(c,this,"internal-error"),c.then(()=>{o||a(this.currentUser)}),typeof n=="function"){const h=t.addObserver(n,r,i);return()=>{o=!0,h()}}else{const h=t.addObserver(n);return()=>{o=!0,h()}}}async directlySetCurrentUser(t){this.currentUser&&this.currentUser!==t&&this._currentUser._stopProactiveRefresh(),t&&this.isProactiveRefreshEnabled&&t._startProactiveRefresh(),this.currentUser=t,t?await this.assertedPersistence.setCurrentUser(t):await this.assertedPersistence.removeCurrentUser()}queue(t){return this.operations=this.operations.then(t,t),this.operations}get assertedPersistence(){return gr(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(t){!t||this.frameworks.includes(t)||(this.frameworks.push(t),this.frameworks.sort(),this.clientVersion=qF(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var i;const t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const n=await((i=this.heartbeatServiceProvider.getImmediate({optional:!0}))==null?void 0:i.getHeartbeatsHeader());n&&(t["X-Firebase-Client"]=n);const r=await this._getAppCheckToken();return r&&(t["X-Firebase-AppCheck"]=r),t}async _getAppCheckToken(){var n;if(Pl(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const t=await((n=this.appCheckServiceProvider.getImmediate({optional:!0}))==null?void 0:n.getToken());return t!=null&&t.error&&jae(`Error while retrieving App Check token: ${t.error}`),t==null?void 0:t.token}}function wf(e){return Ca(e)}class pR{constructor(t){this.auth=t,this.observer=null,this.addObserver=mse(n=>this.observer=n)}get next(){return gr(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */let PN={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function roe(e){PN=e}function WF(e){return PN.loadJS(e)}function ioe(){return PN.recaptchaEnterpriseScript}function soe(){return PN.gapiScript}function aoe(e){return`__${e}${Math.floor(Math.random()*1e6)}`}class ooe{constructor(){this.enterprise=new loe}ready(t){t()}execute(t,n){return Promise.resolve("token")}render(t,n){return""}}class loe{ready(t){t()}execute(t,n){return Promise.resolve("token")}render(t,n){return""}}const coe="recaptcha-enterprise",KF="NO_RECAPTCHA";class uoe{constructor(t){this.type=coe,this.auth=wf(t)}async verify(t="verify",n=!1){async function r(a){if(!n){if(a.tenantId==null&&a._agentRecaptchaConfig!=null)return a._agentRecaptchaConfig.siteKey;if(a.tenantId!=null&&a._tenantRecaptchaConfigs[a.tenantId]!==void 0)return a._tenantRecaptchaConfigs[a.tenantId].siteKey}return new Promise(async(o,c)=>{Vae(a,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(h=>{if(h.recaptchaKey===void 0)c(new Error("recaptcha Enterprise site key undefined"));else{const f=new zae(h);return a.tenantId==null?a._agentRecaptchaConfig=f:a._tenantRecaptchaConfigs[a.tenantId]=f,o(f.siteKey)}}).catch(h=>{c(h)})})}function i(a,o,c){const h=window.grecaptcha;cR(h)?h.enterprise.ready(()=>{h.enterprise.execute(a,{action:t}).then(f=>{o(f)}).catch(()=>{o(KF)})}):c(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new ooe().execute("siteKey",{action:"verify"}):new Promise((a,o)=>{r(this.auth).then(c=>{if(!n&&cR(window.grecaptcha))i(c,a,o);else{if(typeof window>"u"){o(new Error("RecaptchaVerifier is only supported in browser"));return}let h=ioe();h.length!==0&&(h+=c),WF(h).then(()=>{i(c,a,o)}).catch(f=>{o(f)})}}).catch(c=>{o(c)})})}}async function mR(e,t,n,r=!1,i=!1){const a=new uoe(e);let o;if(i)o=KF;else try{o=await a.verify(n)}catch{o=await a.verify(n,!0)}const c={...t};if(n==="mfaSmsEnrollment"||n==="mfaSmsSignIn"){if("phoneEnrollmentInfo"in c){const h=c.phoneEnrollmentInfo.phoneNumber,f=c.phoneEnrollmentInfo.recaptchaToken;Object.assign(c,{phoneEnrollmentInfo:{phoneNumber:h,recaptchaToken:f,captchaResponse:o,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in c){const h=c.phoneSignInInfo.recaptchaToken;Object.assign(c,{phoneSignInInfo:{recaptchaToken:h,captchaResponse:o,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return c}return r?Object.assign(c,{captchaResp:o}):Object.assign(c,{captchaResponse:o}),Object.assign(c,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(c,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),c}async function Tk(e,t,n,r,i){var a;if((a=e._getRecaptchaConfig())!=null&&a.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const o=await mR(e,t,n,n==="getOobCode");return r(e,o)}else return r(e,t).catch(async o=>{if(o.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 mR(e,t,n,n==="getOobCode");return r(e,c)}else return Promise.reject(o)})}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function doe(e,t){const n=sj(e,"auth");if(n.isInitialized()){const i=n.getImmediate(),a=n.getOptions();if(Ld(a,t??{}))return i;dc(i,"already-initialized")}return n.initialize({options:t})}function hoe(e,t){const n=(t==null?void 0:t.persistence)||[],r=(Array.isArray(n)?n:[n]).map(Cd);t!=null&&t.errorMap&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,t==null?void 0:t.popupRedirectResolver)}function foe(e,t,n){const r=wf(e);gr(/^https?:\/\//.test(t),r,"invalid-emulator-scheme");const i=!1,a=YF(t),{host:o,port:c}=poe(t),h=c===null?"":`:${c}`,f={url:`${a}//${o}${h}/`},m=Object.freeze({host:o,port:c,protocol:a.replace(":",""),options:Object.freeze({disableWarnings:i})});if(!r._canInitEmulator){gr(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),gr(Ld(f,r.config.emulator)&&Ld(m,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=f,r.emulatorConfig=m,r.settings.appVerificationDisabledForTesting=!0,vy(o)?_F(`${a}//${o}${h}`):moe()}function YF(e){const t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function poe(e){const t=YF(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);if(i){const a=i[1];return{host:a,port:gR(r.substr(a.length+1))}}else{const[a,o]=r.split(":");return{host:a,port:gR(o)}}}function gR(e){if(!e)return null;const t=Number(e);return isNaN(t)?null:t}function moe(){function e(){const t=document.createElement("p"),n=t.style;t.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",t.classList.add("firebase-emulator-warning"),document.body.appendChild(t)}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",e):e())}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class dj{constructor(t,n){this.providerId=t,this.signInMethod=n}toJSON(){return kd("not implemented")}_getIdTokenResponse(t){return kd("not implemented")}_linkToIdToken(t,n){return kd("not implemented")}_getReauthenticationResolver(t){return kd("not implemented")}}async function goe(e,t){return Kd(e,"POST","/v1/accounts:signUp",t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function xoe(e,t){return Ny(e,"POST","/v1/accounts:signInWithPassword",vf(e,t))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function yoe(e,t){return Ny(e,"POST","/v1/accounts:signInWithEmailLink",vf(e,t))}async function boe(e,t){return Ny(e,"POST","/v1/accounts:signInWithEmailLink",vf(e,t))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class B1 extends dj{constructor(t,n,r,i=null){super("password",r),this._email=t,this._password=n,this._tenantId=i}static _fromEmailAndPassword(t,n){return new B1(t,n,"password")}static _fromEmailAndCode(t,n,r=null){return new B1(t,n,"emailLink",r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(t){const n=typeof t=="string"?JSON.parse(t):t;if(n!=null&&n.email&&(n!=null&&n.password)){if(n.signInMethod==="password")return this._fromEmailAndPassword(n.email,n.password);if(n.signInMethod==="emailLink")return this._fromEmailAndCode(n.email,n.password,n.tenantId)}return null}async _getIdTokenResponse(t){switch(this.signInMethod){case"password":const n={returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return Tk(t,n,"signInWithPassword",xoe);case"emailLink":return yoe(t,{email:this._email,oobCode:this._password});default:dc(t,"internal-error")}}async _linkToIdToken(t,n){switch(this.signInMethod){case"password":const r={idToken:n,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return Tk(t,r,"signUpPassword",goe);case"emailLink":return boe(t,{idToken:n,email:this._email,oobCode:this._password});default:dc(t,"internal-error")}}_getReauthenticationResolver(t){return this._getIdTokenResponse(t)}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function D0(e,t){return Ny(e,"POST","/v1/accounts:signInWithIdp",vf(e,t))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const voe="http://localhost";class Gp extends dj{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(t){const n=new Gp(t.providerId,t.signInMethod);return t.idToken||t.accessToken?(t.idToken&&(n.idToken=t.idToken),t.accessToken&&(n.accessToken=t.accessToken),t.nonce&&!t.pendingToken&&(n.nonce=t.nonce),t.pendingToken&&(n.pendingToken=t.pendingToken)):t.oauthToken&&t.oauthTokenSecret?(n.accessToken=t.oauthToken,n.secret=t.oauthTokenSecret):dc("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(t){const n=typeof t=="string"?JSON.parse(t):t,{providerId:r,signInMethod:i,...a}=n;if(!r||!i)return null;const o=new Gp(r,i);return o.idToken=a.idToken||void 0,o.accessToken=a.accessToken||void 0,o.secret=a.secret,o.nonce=a.nonce,o.pendingToken=a.pendingToken||null,o}_getIdTokenResponse(t){const n=this.buildRequest();return D0(t,n)}_linkToIdToken(t,n){const r=this.buildRequest();return r.idToken=n,D0(t,r)}_getReauthenticationResolver(t){const n=this.buildRequest();return n.autoCreate=!1,D0(t,n)}buildRequest(){const t={requestUri:voe,returnSecureToken:!0};if(this.pendingToken)t.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),t.postBody=by(n)}return t}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function woe(e){switch(e){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 Noe(e){const t=e1(t1(e)).link,n=t?e1(t1(t)).deep_link_id:null,r=e1(t1(e)).deep_link_id;return(r?e1(t1(r)).link:null)||r||n||t||e}class hj{constructor(t){const n=e1(t1(t)),r=n.apiKey??null,i=n.oobCode??null,a=woe(n.mode??null);gr(r&&i&&a,"argument-error"),this.apiKey=r,this.operation=a,this.code=i,this.continueUrl=n.continueUrl??null,this.languageCode=n.lang??null,this.tenantId=n.tenantId??null}static parseLink(t){const n=Noe(t);try{return new hj(n)}catch{return null}}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Sg{constructor(){this.providerId=Sg.PROVIDER_ID}static credential(t,n){return B1._fromEmailAndPassword(t,n)}static credentialWithLink(t,n){const r=hj.parseLink(n);return gr(r,"argument-error"),B1._fromEmailAndCode(t,r.code,r.tenantId)}}Sg.PROVIDER_ID="password";Sg.EMAIL_PASSWORD_SIGN_IN_METHOD="password";Sg.EMAIL_LINK_SIGN_IN_METHOD="emailLink";/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class fj{constructor(t){this.providerId=t,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(t){this.defaultLanguageCode=t}setCustomParameters(t){return this.customParameters=t,this}getCustomParameters(){return this.customParameters}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Ey extends fj{constructor(){super(...arguments),this.scopes=[]}addScope(t){return this.scopes.includes(t)||this.scopes.push(t),this}getScopes(){return[...this.scopes]}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class $h extends Ey{constructor(){super("facebook.com")}static credential(t){return Gp._fromParams({providerId:$h.PROVIDER_ID,signInMethod:$h.FACEBOOK_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return $h.credentialFromTaggedObject(t)}static credentialFromError(t){return $h.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!("oauthAccessToken"in t)||!t.oauthAccessToken)return null;try{return $h.credential(t.oauthAccessToken)}catch{return null}}}$h.FACEBOOK_SIGN_IN_METHOD="facebook.com";$h.PROVIDER_ID="facebook.com";/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class _d extends Ey{constructor(){super("google.com"),this.addScope("profile")}static credential(t,n){return Gp._fromParams({providerId:_d.PROVIDER_ID,signInMethod:_d.GOOGLE_SIGN_IN_METHOD,idToken:t,accessToken:n})}static credentialFromResult(t){return _d.credentialFromTaggedObject(t)}static credentialFromError(t){return _d.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthIdToken:n,oauthAccessToken:r}=t;if(!n&&!r)return null;try{return _d.credential(n,r)}catch{return null}}}_d.GOOGLE_SIGN_IN_METHOD="google.com";_d.PROVIDER_ID="google.com";/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Hh extends Ey{constructor(){super("github.com")}static credential(t){return Gp._fromParams({providerId:Hh.PROVIDER_ID,signInMethod:Hh.GITHUB_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return Hh.credentialFromTaggedObject(t)}static credentialFromError(t){return Hh.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!("oauthAccessToken"in t)||!t.oauthAccessToken)return null;try{return Hh.credential(t.oauthAccessToken)}catch{return null}}}Hh.GITHUB_SIGN_IN_METHOD="github.com";Hh.PROVIDER_ID="github.com";/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Gh extends Ey{constructor(){super("twitter.com")}static credential(t,n){return Gp._fromParams({providerId:Gh.PROVIDER_ID,signInMethod:Gh.TWITTER_SIGN_IN_METHOD,oauthToken:t,oauthTokenSecret:n})}static credentialFromResult(t){return Gh.credentialFromTaggedObject(t)}static credentialFromError(t){return Gh.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthAccessToken:n,oauthTokenSecret:r}=t;if(!n||!r)return null;try{return Gh.credential(n,r)}catch{return null}}}Gh.TWITTER_SIGN_IN_METHOD="twitter.com";Gh.PROVIDER_ID="twitter.com";/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function Eoe(e,t){return Ny(e,"POST","/v1/accounts:signUp",vf(e,t))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class qp{constructor(t){this.user=t.user,this.providerId=t.providerId,this._tokenResponse=t._tokenResponse,this.operationType=t.operationType}static async _fromIdTokenResponse(t,n,r,i=!1){const a=await Mc._fromIdTokenResponse(t,r,i),o=xR(r);return new qp({user:a,providerId:o,_tokenResponse:r,operationType:n})}static async _forOperation(t,n,r){await t._updateTokensIfNecessary(r,!0);const i=xR(r);return new qp({user:t,providerId:i,_tokenResponse:r,operationType:n})}}function xR(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class zw extends Wd{constructor(t,n,r,i){super(n.code,n.message),this.operationType=r,this.user=i,Object.setPrototypeOf(this,zw.prototype),this.customData={appName:t.name,tenantId:t.tenantId??void 0,_serverResponse:n.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(t,n,r,i){return new zw(t,n,r,i)}}function XF(e,t,n,r){return(t==="reauthenticate"?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch(a=>{throw a.code==="auth/multi-factor-auth-required"?zw._fromErrorAndOperation(e,a,t,r):a})}async function Aoe(e,t,n=!1){const r=await W0(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return qp._forOperation(e,"link",r)}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function _oe(e,t,n=!1){const{auth:r}=e;if(Pl(r.app))return Promise.reject(Od(r));const i="reauthenticate";try{const a=await W0(e,XF(r,i,t,e),n);gr(a.idToken,r,"internal-error");const o=cj(a.idToken);gr(o,r,"internal-error");const{sub:c}=o;return gr(e.uid===c,r,"user-mismatch"),qp._forOperation(e,i,a)}catch(a){throw(a==null?void 0:a.code)==="auth/user-not-found"&&dc(r,"user-mismatch"),a}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function QF(e,t,n=!1){if(Pl(e.app))return Promise.reject(Od(e));const r="signIn",i=await XF(e,r,t),a=await qp._fromIdTokenResponse(e,r,i);return n||await e._updateCurrentUser(a.user),a}async function Soe(e,t){return QF(wf(e),t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function ZF(e){const t=wf(e);t._getPasswordPolicyInternal()&&await t._updatePasswordPolicy()}async function koe(e,t,n){if(Pl(e.app))return Promise.reject(Od(e));const r=wf(e),o=await Tk(r,{returnSecureToken:!0,email:t,password:n,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",Eoe).catch(h=>{throw h.code==="auth/password-does-not-meet-requirements"&&ZF(e),h}),c=await qp._fromIdTokenResponse(r,"signIn",o);return await r._updateCurrentUser(c.user),c}function Coe(e,t,n){return Pl(e.app)?Promise.reject(Od(e)):Soe(Ca(e),Sg.credential(t,n)).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&ZF(e),r})}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function Ioe(e,t){return Kd(e,"POST","/v1/accounts:update",t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function JF(e,{displayName:t,photoURL:n}){if(t===void 0&&n===void 0)return;const r=Ca(e),a={idToken:await r.getIdToken(),displayName:t,photoUrl:n,returnSecureToken:!0},o=await W0(r,Ioe(r.auth,a));r.displayName=o.displayName||null,r.photoURL=o.photoUrl||null;const c=r.providerData.find(({providerId:h})=>h==="password");c&&(c.displayName=r.displayName,c.photoURL=r.photoURL),await r._updateTokensIfNecessary(o)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function joe(e,t){return Ca(e).setPersistence(t)}function Toe(e,t,n,r){return Ca(e).onIdTokenChanged(t,n,r)}function Ooe(e,t,n){return Ca(e).beforeAuthStateChanged(t,n)}const Vw="__sak";/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class e${constructor(t,n){this.storageRetriever=t,this.type=n}_isAvailable(){try{return this.storage?(this.storage.setItem(Vw,"1"),this.storage.removeItem(Vw),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(t,n){return this.storage.setItem(t,JSON.stringify(n)),Promise.resolve()}_get(t){const n=this.storage.getItem(t);return Promise.resolve(n?JSON.parse(n):null)}_remove(t){return this.storage.removeItem(t),Promise.resolve()}get storage(){return this.storageRetriever()}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Poe=1e3,Roe=10;class t$ extends e${constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(t,n)=>this.onStorageEvent(t,n),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=GF(),this._shouldAllowMigration=!0}forAllChangedKeys(t){for(const n of Object.keys(this.listeners)){const r=this.storage.getItem(n),i=this.localCache[n];r!==i&&t(n,i,r)}}onStorageEvent(t,n=!1){if(!t.key){this.forAllChangedKeys((o,c,h)=>{this.notifyListeners(o,h)});return}const r=t.key;n?this.detachListener():this.stopPolling();const i=()=>{const o=this.storage.getItem(r);!n&&this.localCache[r]===o||this.notifyListeners(r,o)},a=this.storage.getItem(r);Qae()&&a!==t.newValue&&t.newValue!==t.oldValue?setTimeout(i,Roe):i()}notifyListeners(t,n){this.localCache[t]=n;const r=this.listeners[t];if(r)for(const i of Array.from(r))i(n&&JSON.parse(n))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((t,n,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:t,oldValue:n,newValue:r}),!0)})},Poe)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(t,n){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[t]||(this.listeners[t]=new Set,this.localCache[t]=this.storage.getItem(t)),this.listeners[t].add(n)}_removeListener(t,n){this.listeners[t]&&(this.listeners[t].delete(n),this.listeners[t].size===0&&delete this.listeners[t]),Object.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(t,n){await super._set(t,n),this.localCache[t]=JSON.stringify(n)}async _get(t){const n=await super._get(t);return this.localCache[t]=JSON.stringify(n),n}async _remove(t){await super._remove(t),delete this.localCache[t]}}t$.type="LOCAL";const n$=t$;/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class r$ extends e${constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(t,n){}_removeListener(t,n){}}r$.type="SESSION";const i$=r$;/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Doe(e){return Promise.all(e.map(async t=>{try{return{fulfilled:!0,value:await t}}catch(n){return{fulfilled:!1,reason:n}}}))}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class RN{constructor(t){this.eventTarget=t,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(t){const n=this.receivers.find(i=>i.isListeningto(t));if(n)return n;const r=new RN(t);return this.receivers.push(r),r}isListeningto(t){return this.eventTarget===t}async handleEvent(t){const n=t,{eventId:r,eventType:i,data:a}=n.data,o=this.handlersMap[i];if(!(o!=null&&o.size))return;n.ports[0].postMessage({status:"ack",eventId:r,eventType:i});const c=Array.from(o).map(async f=>f(n.origin,a)),h=await Doe(c);n.ports[0].postMessage({status:"done",eventId:r,eventType:i,response:h})}_subscribe(t,n){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[t]||(this.handlersMap[t]=new Set),this.handlersMap[t].add(n)}_unsubscribe(t,n){this.handlersMap[t]&&n&&this.handlersMap[t].delete(n),(!n||this.handlersMap[t].size===0)&&delete this.handlersMap[t],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}RN.receivers=[];/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function pj(e="",t=10){let n="";for(let r=0;r{const f=pj("",20);i.port1.start();const m=setTimeout(()=>{h(new Error("unsupported_event"))},r);o={messageChannel:i,onMessage(y){const w=y;if(w.data.eventId===f)switch(w.data.status){case"ack":clearTimeout(m),a=setTimeout(()=>{h(new Error("timeout"))},3e3);break;case"done":clearTimeout(a),c(w.data.response);break;default:clearTimeout(m),clearTimeout(a),h(new Error("invalid_response"));break}}},this.handlers.add(o),i.port1.addEventListener("message",o.onMessage),this.target.postMessage({eventType:t,eventId:f,data:n},[i.port2])}).finally(()=>{o&&this.removeMessageHandler(o)})}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Cu(){return window}function Loe(e){Cu().location.href=e}/** * @license * Copyright 2020 Google LLC. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function s$(){return typeof Cu().WorkerGlobalScope<"u"&&typeof Cu().importScripts=="function"}async function Uoe(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function Boe(){var e;return((e=navigator==null?void 0:navigator.serviceWorker)==null?void 0:e.controller)||null}function zoe(){return s$()?self:null}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const a$="firebaseLocalStorageDb",Voe=1,Fw="firebaseLocalStorage",o$="fbase_key";class Ay{constructor(t){this.request=t}toPromise(){return new Promise((t,n)=>{this.request.addEventListener("success",()=>{t(this.request.result)}),this.request.addEventListener("error",()=>{n(this.request.error)})})}}function DN(e,t){return e.transaction([Fw],t?"readwrite":"readonly").objectStore(Fw)}function Foe(){const e=indexedDB.deleteDatabase(a$);return new Ay(e).toPromise()}function Ok(){const e=indexedDB.open(a$,Voe);return new Promise((t,n)=>{e.addEventListener("error",()=>{n(e.error)}),e.addEventListener("upgradeneeded",()=>{const r=e.result;try{r.createObjectStore(Fw,{keyPath:o$})}catch(i){n(i)}}),e.addEventListener("success",async()=>{const r=e.result;r.objectStoreNames.contains(Fw)?t(r):(r.close(),await Foe(),t(await Ok()))})})}async function yR(e,t,n){const r=DN(e,!0).put({[o$]:t,value:n});return new Ay(r).toPromise()}async function $oe(e,t){const n=DN(e,!1).get(t),r=await new Ay(n).toPromise();return r===void 0?null:r.value}function bR(e,t){const n=DN(e,!0).delete(t);return new Ay(n).toPromise()}const Hoe=800,Goe=3;class l${constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await Ok(),this.db)}async _withRetries(t){let n=0;for(;;)try{const r=await this._openDb();return await t(r)}catch(r){if(n++>Goe)throw r;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return s$()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=RN._getInstance(zoe()),this.receiver._subscribe("keyChanged",async(t,n)=>({keyProcessed:(await this._poll()).includes(n.key)})),this.receiver._subscribe("ping",async(t,n)=>["keyChanged"])}async initializeSender(){var n,r;if(this.activeServiceWorker=await Uoe(),!this.activeServiceWorker)return;this.sender=new Moe(this.activeServiceWorker);const t=await this.sender._send("ping",{},800);t&&(n=t[0])!=null&&n.fulfilled&&(r=t[0])!=null&&r.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(t){if(!(!this.sender||!this.activeServiceWorker||Boe()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:t},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const t=await Ok();return await yR(t,Vw,"1"),await bR(t,Vw),!0}catch{}return!1}async _withPendingWrite(t){this.pendingWrites++;try{await t()}finally{this.pendingWrites--}}async _set(t,n){return this._withPendingWrite(async()=>(await this._withRetries(r=>yR(r,t,n)),this.localCache[t]=n,this.notifyServiceWorker(t)))}async _get(t){const n=await this._withRetries(r=>$oe(r,t));return this.localCache[t]=n,n}async _remove(t){return this._withPendingWrite(async()=>(await this._withRetries(n=>bR(n,t)),delete this.localCache[t],this.notifyServiceWorker(t)))}async _poll(){const t=await this._withRetries(i=>{const a=DN(i,!1).getAll();return new Ay(a).toPromise()});if(!t)return[];if(this.pendingWrites!==0)return[];const n=[],r=new Set;if(t.length!==0)for(const{fbase_key:i,value:a}of t)r.add(i),JSON.stringify(this.localCache[i])!==JSON.stringify(a)&&(this.notifyListeners(i,a),n.push(i));for(const i of Object.keys(this.localCache))this.localCache[i]&&!r.has(i)&&(this.notifyListeners(i,null),n.push(i));return n}notifyListeners(t,n){this.localCache[t]=n;const r=this.listeners[t];if(r)for(const i of Array.from(r))i(n)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),Hoe)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(t,n){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[t]||(this.listeners[t]=new Set,this._get(t)),this.listeners[t].add(n)}_removeListener(t,n){this.listeners[t]&&(this.listeners[t].delete(n),this.listeners[t].size===0&&delete this.listeners[t]),Object.keys(this.listeners).length===0&&this.stopPolling()}}l$.type="LOCAL";const qoe=l$;new wy(3e4,6e4);/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function c$(e,t){return t?Cd(t):(gr(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class mj extends dj{constructor(t){super("custom","custom"),this.params=t}_getIdTokenResponse(t){return D0(t,this._buildIdpRequest())}_linkToIdToken(t,n){return D0(t,this._buildIdpRequest(n))}_getReauthenticationResolver(t){return D0(t,this._buildIdpRequest())}_buildIdpRequest(t){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 t&&(n.idToken=t),n}}function Woe(e){return QF(e.auth,new mj(e),e.bypassAuthState)}function Koe(e){const{auth:t,user:n}=e;return gr(n,t,"internal-error"),_oe(n,new mj(e),e.bypassAuthState)}async function Yoe(e){const{auth:t,user:n}=e;return gr(n,t,"internal-error"),Aoe(n,new mj(e),e.bypassAuthState)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class u${constructor(t,n,r,i,a=!1){this.auth=t,this.resolver=r,this.user=i,this.bypassAuthState=a,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(n)?n:[n]}execute(){return new Promise(async(t,n)=>{this.pendingPromise={resolve:t,reject:n};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(r){this.reject(r)}})}async onAuthEvent(t){const{urlResponse:n,sessionId:r,postBody:i,tenantId:a,error:o,type:c}=t;if(o){this.reject(o);return}const h={auth:this.auth,requestUri:n,sessionId:r,tenantId:a||void 0,postBody:i||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(c)(h))}catch(f){this.reject(f)}}onError(t){this.reject(t)}getIdpTask(t){switch(t){case"signInViaPopup":case"signInViaRedirect":return Woe;case"linkViaPopup":case"linkViaRedirect":return Yoe;case"reauthViaPopup":case"reauthViaRedirect":return Koe;default:dc(this.auth,"internal-error")}}resolve(t){Bd(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(t),this.unregisterAndCleanUp()}reject(t){Bd(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(t),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Xoe=new wy(2e3,1e4);async function Qoe(e,t,n){if(Pl(e.app))return Promise.reject(Lc(e,"operation-not-supported-in-this-environment"));const r=wf(e);Tae(e,t,fj);const i=c$(r,n);return new bp(r,"signInViaPopup",t,i).executeNotNull()}class bp extends u${constructor(t,n,r,i,a){super(t,n,i,a),this.provider=r,this.authWindow=null,this.pollId=null,bp.currentPopupAction&&bp.currentPopupAction.cancel(),bp.currentPopupAction=this}async executeNotNull(){const t=await this.execute();return gr(t,this.auth,"internal-error"),t}async onExecution(){Bd(this.filter.length===1,"Popup operations only handle one event");const t=pj();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],t),this.authWindow.associatedEvent=t,this.resolver._originValidation(this.auth).catch(n=>{this.reject(n)}),this.resolver._isIframeWebStorageSupported(this.auth,n=>{n||this.reject(Lc(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var t;return((t=this.authWindow)==null?void 0:t.associatedEvent)||null}cancel(){this.reject(Lc(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,bp.currentPopupAction=null}pollUserCancellation(){const t=()=>{var n,r;if((r=(n=this.authWindow)==null?void 0:n.window)!=null&&r.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Lc(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(t,Xoe.get())};t()}}bp.currentPopupAction=null;/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Zoe="pendingRedirect",tw=new Map;class Joe extends u${constructor(t,n,r=!1){super(t,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],n,void 0,r),this.eventId=null}async execute(){let t=tw.get(this.auth._key());if(!t){try{const r=await ele(this.resolver,this.auth)?await super.execute():null;t=()=>Promise.resolve(r)}catch(n){t=()=>Promise.reject(n)}tw.set(this.auth._key(),t)}return this.bypassAuthState||tw.set(this.auth._key(),()=>Promise.resolve(null)),t()}async onAuthEvent(t){if(t.type==="signInViaRedirect")return super.onAuthEvent(t);if(t.type==="unknown"){this.resolve(null);return}if(t.eventId){const n=await this.auth._redirectUserForId(t.eventId);if(n)return this.user=n,super.onAuthEvent(t);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function ele(e,t){const n=rle(t),r=nle(e);if(!await r._isAvailable())return!1;const i=await r._get(n)==="true";return await r._remove(n),i}function tle(e,t){tw.set(e._key(),t)}function nle(e){return Cd(e._redirectPersistence)}function rle(e){return ew(Zoe,e.config.apiKey,e.name)}async function ile(e,t,n=!1){if(Pl(e.app))return Promise.reject(Od(e));const r=wf(e),i=c$(r,t),o=await new Joe(r,i,n).execute();return o&&!n&&(delete o.user._redirectEventId,await r._persistUserIfCurrent(o.user),await r._setRedirectUser(null,t)),o}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const sle=600*1e3;class ale{constructor(t){this.auth=t,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(t){this.consumers.add(t),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,t)&&(this.sendToConsumer(this.queuedRedirectEvent,t),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(t){this.consumers.delete(t)}onEvent(t){if(this.hasEventBeenHandled(t))return!1;let n=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(t,r)&&(n=!0,this.sendToConsumer(t,r),this.saveEventToCache(t))}),this.hasHandledPotentialRedirect||!ole(t)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=t,n=!0)),n}sendToConsumer(t,n){var r;if(t.error&&!d$(t)){const i=((r=t.error.code)==null?void 0:r.split("auth/")[1])||"internal-error";n.onError(Lc(this.auth,i))}else n.onAuthEvent(t)}isEventForConsumer(t,n){const r=n.eventId===null||!!t.eventId&&t.eventId===n.eventId;return n.filter.includes(t.type)&&r}hasEventBeenHandled(t){return Date.now()-this.lastProcessedEventTime>=sle&&this.cachedEventUids.clear(),this.cachedEventUids.has(vR(t))}saveEventToCache(t){this.cachedEventUids.add(vR(t)),this.lastProcessedEventTime=Date.now()}}function vR(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(t=>t).join("-")}function d$({type:e,error:t}){return e==="unknown"&&(t==null?void 0:t.code)==="auth/no-auth-event"}function ole(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return d$(e);default:return!1}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function lle(e,t={}){return Kd(e,"GET","/v1/projects",t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const cle=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,ule=/^https?/;async function dle(e){if(e.config.emulator)return;const{authorizedDomains:t}=await lle(e);for(const n of t)try{if(hle(n))return}catch{}dc(e,"unauthorized-domain")}function hle(e){const t=Ik(),{protocol:n,hostname:r}=new URL(t);if(e.startsWith("chrome-extension://")){const o=new URL(e);return o.hostname===""&&r===""?n==="chrome-extension:"&&e.replace("chrome-extension://","")===t.replace("chrome-extension://",""):n==="chrome-extension:"&&o.hostname===r}if(!ule.test(n))return!1;if(cle.test(e))return r===e;const i=e.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)}/** * @license * Copyright 2020 Google LLC. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const fle=new wy(3e4,6e4);function wR(){const e=Cu().___jsl;if(e!=null&&e.H){for(const t of Object.keys(e.H))if(e.H[t].r=e.H[t].r||[],e.H[t].L=e.H[t].L||[],e.H[t].r=[...e.H[t].L],e.CP)for(let n=0;n{var i,a,o;function r(){wR(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{wR(),n(Lc(e,"network-request-failed"))},timeout:fle.get()})}if((a=(i=Cu().gapi)==null?void 0:i.iframes)!=null&&a.Iframe)t(gapi.iframes.getContext());else if((o=Cu().gapi)!=null&&o.load)r();else{const c=aoe("iframefcb");return Cu()[c]=()=>{gapi.load?r():n(Lc(e,"network-request-failed"))},WF(`${soe()}?onload=${c}`).catch(h=>n(h))}}).catch(t=>{throw nw=null,t})}let nw=null;function mle(e){return nw=nw||ple(e),nw}/** * @license * Copyright 2020 Google LLC. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const gle=new wy(5e3,15e3),xle="__/auth/iframe",yle="emulator/auth/iframe",ble={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},vle=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function wle(e){const t=e.config;gr(t.authDomain,e,"auth-domain-config-required");const n=t.emulator?lj(t,yle):`https://${e.config.authDomain}/${xle}`,r={apiKey:t.apiKey,appName:e.name,v:_g},i=vle.get(e.config.apiHost);i&&(r.eid=i);const a=e._getFrameworks();return a.length&&(r.fw=a.join(",")),`${n}?${by(r).slice(1)}`}async function Nle(e){const t=await mle(e),n=Cu().gapi;return gr(n,e,"internal-error"),t.open({where:document.body,url:wle(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:ble,dontclear:!0},r=>new Promise(async(i,a)=>{await r.restyle({setHideOnLeave:!1});const o=Lc(e,"network-request-failed"),c=Cu().setTimeout(()=>{a(o)},gle.get());function h(){Cu().clearTimeout(c),i(r)}r.ping(h).then(h,()=>{a(o)})}))}/** * @license * Copyright 2020 Google LLC. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Ele={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},Ale=500,_le=600,Sle="_blank",kle="http://localhost";class NR{constructor(t){this.window=t,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function Cle(e,t,n,r=Ale,i=_le){const a=Math.max((window.screen.availHeight-i)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString();let c="";const h={...Ele,width:r.toString(),height:i.toString(),top:a,left:o},f=ka().toLowerCase();n&&(c=zF(f)?Sle:n),UF(f)&&(t=t||kle,h.scrollbars="yes");const m=Object.entries(h).reduce((w,[A,k])=>`${w}${A}=${k},`,"");if(Xae(f)&&c!=="_self")return Ile(t||"",c),new NR(null);const y=window.open(t||"",c,m);gr(y,e,"popup-blocked");try{y.focus()}catch{}return new NR(y)}function Ile(e,t){const n=document.createElement("a");n.href=e,n.target=t;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r)}/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const jle="__/auth/handler",Tle="emulator/auth/handler",Ole=encodeURIComponent("fac");async function ER(e,t,n,r,i,a){gr(e.config.authDomain,e,"auth-domain-config-required"),gr(e.config.apiKey,e,"invalid-api-key");const o={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:r,v:_g,eventId:i};if(t instanceof fj){t.setDefaultLanguage(e.languageCode),o.providerId=t.providerId||"",pse(t.getCustomParameters())||(o.customParameters=JSON.stringify(t.getCustomParameters()));for(const[m,y]of Object.entries({}))o[m]=y}if(t instanceof Ey){const m=t.getScopes().filter(y=>y!=="");m.length>0&&(o.scopes=m.join(","))}e.tenantId&&(o.tid=e.tenantId);const c=o;for(const m of Object.keys(c))c[m]===void 0&&delete c[m];const h=await e._getAppCheckToken(),f=h?`#${Ole}=${encodeURIComponent(h)}`:"";return`${Ple(e)}?${by(c).slice(1)}${f}`}function Ple({config:e}){return e.emulator?lj(e,Tle):`https://${e.authDomain}/${jle}`}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const V_="webStorageSupport";class Rle{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=i$,this._completeRedirectFn=ile,this._overrideRedirectResult=tle}async _openPopup(t,n,r,i){var o;Bd((o=this.eventManagers[t._key()])==null?void 0:o.manager,"_initialize() not called before _openPopup()");const a=await ER(t,n,r,Ik(),i);return Cle(t,a,pj())}async _openRedirect(t,n,r,i){await this._originValidation(t);const a=await ER(t,n,r,Ik(),i);return Loe(a),new Promise(()=>{})}_initialize(t){const n=t._key();if(this.eventManagers[n]){const{manager:i,promise:a}=this.eventManagers[n];return i?Promise.resolve(i):(Bd(a,"If manager is not set, promise should be"),a)}const r=this.initAndGetManager(t);return this.eventManagers[n]={promise:r},r.catch(()=>{delete this.eventManagers[n]}),r}async initAndGetManager(t){const n=await Nle(t),r=new ale(t);return n.register("authEvent",i=>(gr(i==null?void 0:i.authEvent,t,"invalid-auth-event"),{status:r.onEvent(i.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[t._key()]={manager:r},this.iframes[t._key()]=n,r}_isIframeWebStorageSupported(t,n){this.iframes[t._key()].send(V_,{type:V_},i=>{var o;const a=(o=i==null?void 0:i[0])==null?void 0:o[V_];a!==void 0&&n(!!a),dc(t,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(t){const n=t._key();return this.originValidationPromises[n]||(this.originValidationPromises[n]=dle(t)),this.originValidationPromises[n]}get _shouldInitProactively(){return GF()||BF()||uj()}}const Dle=Rle;var AR="@firebase/auth",_R="1.12.2";/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Mle{constructor(t){this.auth=t,this.internalListeners=new Map}getUid(){var t;return this.assertAuthConfigured(),((t=this.auth.currentUser)==null?void 0:t.uid)||null}async getToken(t){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(t)}:null}addAuthTokenListener(t){if(this.assertAuthConfigured(),this.internalListeners.has(t))return;const n=this.auth.onIdTokenChanged(r=>{t((r==null?void 0:r.stsTokenManager.accessToken)||null)});this.internalListeners.set(t,n),this.updateProactiveRefresh()}removeAuthTokenListener(t){this.assertAuthConfigured();const n=this.internalListeners.get(t);n&&(this.internalListeners.delete(t),n(),this.updateProactiveRefresh())}assertAuthConfigured(){gr(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Lle(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function Ule(e){q0(new Hp("auth",(t,{options:n})=>{const r=t.getProvider("app").getImmediate(),i=t.getProvider("heartbeat"),a=t.getProvider("app-check-internal"),{apiKey:o,authDomain:c}=r.options;gr(o&&!o.includes(":"),"invalid-api-key",{appName:r.name});const h={apiKey:o,authDomain:c,clientPlatform:e,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:qF(e)},f=new noe(r,i,a,h);return hoe(f,n),f},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((t,n,r)=>{t.getProvider("auth-internal").initialize()})),q0(new Hp("auth-internal",t=>{const n=wf(t.getProvider("auth").getImmediate());return(r=>new Mle(r))(n)},"PRIVATE").setInstantiationMode("EXPLICIT")),rf(AR,_R,Lle(e)),rf(AR,_R,"esm2020")}/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Ble=300,zle=vF("authIdTokenMaxAge")||Ble;let SR=null;const Vle=e=>async t=>{const n=t&&await t.getIdTokenResult(),r=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(r&&r>zle)return;const i=n==null?void 0:n.token;SR!==i&&(SR=i,await fetch(e,{method:i?"POST":"DELETE",headers:i?{Authorization:`Bearer ${i}`}:{}}))};function Fle(e=gae()){const t=sj(e,"auth");if(t.isInitialized())return t.getImmediate();const n=doe(e,{popupRedirectResolver:Dle,persistence:[qoe,n$,i$]}),r=vF("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const a=new URL(r,location.origin);if(location.origin===a.origin){const o=Vle(a.toString());Ooe(n,o,()=>o(n.currentUser)),Toe(n,c=>o(c))}}const i=rse("auth");return i&&foe(n,`http://${i}`),n}function $le(){var e;return((e=document.getElementsByTagName("head"))==null?void 0:e[0])??document}roe({loadJS(e){return new Promise((t,n)=>{const r=document.createElement("script");r.setAttribute("src",e),r.onload=t,r.onerror=i=>{const a=Lc("internal-error");a.customData=i,n(a)},r.type="text/javascript",r.charset="UTF-8",$le().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});Ule("Browser");var kR=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license Copyright The Closure Library Authors. SPDX-License-Identifier: Apache-2.0 */var sf,h$;(function(){var e;/** @license Copyright The Closure Library Authors. SPDX-License-Identifier: Apache-2.0 */function t(z,B){function V(){}V.prototype=B.prototype,z.F=B.prototype,z.prototype=new V,z.prototype.constructor=z,z.D=function($,Q,Y){for(var G=Array(arguments.length-2),he=2;he>>25),G=Y+(Q^B&(V^Q))+$[1]+3905402710&4294967295,Y=B+(G<<12&4294967295|G>>>20),G=Q+(V^Y&(B^V))+$[2]+606105819&4294967295,Q=Y+(G<<17&4294967295|G>>>15),G=V+(B^Q&(Y^B))+$[3]+3250441966&4294967295,V=Q+(G<<22&4294967295|G>>>10),G=B+(Y^V&(Q^Y))+$[4]+4118548399&4294967295,B=V+(G<<7&4294967295|G>>>25),G=Y+(Q^B&(V^Q))+$[5]+1200080426&4294967295,Y=B+(G<<12&4294967295|G>>>20),G=Q+(V^Y&(B^V))+$[6]+2821735955&4294967295,Q=Y+(G<<17&4294967295|G>>>15),G=V+(B^Q&(Y^B))+$[7]+4249261313&4294967295,V=Q+(G<<22&4294967295|G>>>10),G=B+(Y^V&(Q^Y))+$[8]+1770035416&4294967295,B=V+(G<<7&4294967295|G>>>25),G=Y+(Q^B&(V^Q))+$[9]+2336552879&4294967295,Y=B+(G<<12&4294967295|G>>>20),G=Q+(V^Y&(B^V))+$[10]+4294925233&4294967295,Q=Y+(G<<17&4294967295|G>>>15),G=V+(B^Q&(Y^B))+$[11]+2304563134&4294967295,V=Q+(G<<22&4294967295|G>>>10),G=B+(Y^V&(Q^Y))+$[12]+1804603682&4294967295,B=V+(G<<7&4294967295|G>>>25),G=Y+(Q^B&(V^Q))+$[13]+4254626195&4294967295,Y=B+(G<<12&4294967295|G>>>20),G=Q+(V^Y&(B^V))+$[14]+2792965006&4294967295,Q=Y+(G<<17&4294967295|G>>>15),G=V+(B^Q&(Y^B))+$[15]+1236535329&4294967295,V=Q+(G<<22&4294967295|G>>>10),G=B+(Q^Y&(V^Q))+$[1]+4129170786&4294967295,B=V+(G<<5&4294967295|G>>>27),G=Y+(V^Q&(B^V))+$[6]+3225465664&4294967295,Y=B+(G<<9&4294967295|G>>>23),G=Q+(B^V&(Y^B))+$[11]+643717713&4294967295,Q=Y+(G<<14&4294967295|G>>>18),G=V+(Y^B&(Q^Y))+$[0]+3921069994&4294967295,V=Q+(G<<20&4294967295|G>>>12),G=B+(Q^Y&(V^Q))+$[5]+3593408605&4294967295,B=V+(G<<5&4294967295|G>>>27),G=Y+(V^Q&(B^V))+$[10]+38016083&4294967295,Y=B+(G<<9&4294967295|G>>>23),G=Q+(B^V&(Y^B))+$[15]+3634488961&4294967295,Q=Y+(G<<14&4294967295|G>>>18),G=V+(Y^B&(Q^Y))+$[4]+3889429448&4294967295,V=Q+(G<<20&4294967295|G>>>12),G=B+(Q^Y&(V^Q))+$[9]+568446438&4294967295,B=V+(G<<5&4294967295|G>>>27),G=Y+(V^Q&(B^V))+$[14]+3275163606&4294967295,Y=B+(G<<9&4294967295|G>>>23),G=Q+(B^V&(Y^B))+$[3]+4107603335&4294967295,Q=Y+(G<<14&4294967295|G>>>18),G=V+(Y^B&(Q^Y))+$[8]+1163531501&4294967295,V=Q+(G<<20&4294967295|G>>>12),G=B+(Q^Y&(V^Q))+$[13]+2850285829&4294967295,B=V+(G<<5&4294967295|G>>>27),G=Y+(V^Q&(B^V))+$[2]+4243563512&4294967295,Y=B+(G<<9&4294967295|G>>>23),G=Q+(B^V&(Y^B))+$[7]+1735328473&4294967295,Q=Y+(G<<14&4294967295|G>>>18),G=V+(Y^B&(Q^Y))+$[12]+2368359562&4294967295,V=Q+(G<<20&4294967295|G>>>12),G=B+(V^Q^Y)+$[5]+4294588738&4294967295,B=V+(G<<4&4294967295|G>>>28),G=Y+(B^V^Q)+$[8]+2272392833&4294967295,Y=B+(G<<11&4294967295|G>>>21),G=Q+(Y^B^V)+$[11]+1839030562&4294967295,Q=Y+(G<<16&4294967295|G>>>16),G=V+(Q^Y^B)+$[14]+4259657740&4294967295,V=Q+(G<<23&4294967295|G>>>9),G=B+(V^Q^Y)+$[1]+2763975236&4294967295,B=V+(G<<4&4294967295|G>>>28),G=Y+(B^V^Q)+$[4]+1272893353&4294967295,Y=B+(G<<11&4294967295|G>>>21),G=Q+(Y^B^V)+$[7]+4139469664&4294967295,Q=Y+(G<<16&4294967295|G>>>16),G=V+(Q^Y^B)+$[10]+3200236656&4294967295,V=Q+(G<<23&4294967295|G>>>9),G=B+(V^Q^Y)+$[13]+681279174&4294967295,B=V+(G<<4&4294967295|G>>>28),G=Y+(B^V^Q)+$[0]+3936430074&4294967295,Y=B+(G<<11&4294967295|G>>>21),G=Q+(Y^B^V)+$[3]+3572445317&4294967295,Q=Y+(G<<16&4294967295|G>>>16),G=V+(Q^Y^B)+$[6]+76029189&4294967295,V=Q+(G<<23&4294967295|G>>>9),G=B+(V^Q^Y)+$[9]+3654602809&4294967295,B=V+(G<<4&4294967295|G>>>28),G=Y+(B^V^Q)+$[12]+3873151461&4294967295,Y=B+(G<<11&4294967295|G>>>21),G=Q+(Y^B^V)+$[15]+530742520&4294967295,Q=Y+(G<<16&4294967295|G>>>16),G=V+(Q^Y^B)+$[2]+3299628645&4294967295,V=Q+(G<<23&4294967295|G>>>9),G=B+(Q^(V|~Y))+$[0]+4096336452&4294967295,B=V+(G<<6&4294967295|G>>>26),G=Y+(V^(B|~Q))+$[7]+1126891415&4294967295,Y=B+(G<<10&4294967295|G>>>22),G=Q+(B^(Y|~V))+$[14]+2878612391&4294967295,Q=Y+(G<<15&4294967295|G>>>17),G=V+(Y^(Q|~B))+$[5]+4237533241&4294967295,V=Q+(G<<21&4294967295|G>>>11),G=B+(Q^(V|~Y))+$[12]+1700485571&4294967295,B=V+(G<<6&4294967295|G>>>26),G=Y+(V^(B|~Q))+$[3]+2399980690&4294967295,Y=B+(G<<10&4294967295|G>>>22),G=Q+(B^(Y|~V))+$[10]+4293915773&4294967295,Q=Y+(G<<15&4294967295|G>>>17),G=V+(Y^(Q|~B))+$[1]+2240044497&4294967295,V=Q+(G<<21&4294967295|G>>>11),G=B+(Q^(V|~Y))+$[8]+1873313359&4294967295,B=V+(G<<6&4294967295|G>>>26),G=Y+(V^(B|~Q))+$[15]+4264355552&4294967295,Y=B+(G<<10&4294967295|G>>>22),G=Q+(B^(Y|~V))+$[6]+2734768916&4294967295,Q=Y+(G<<15&4294967295|G>>>17),G=V+(Y^(Q|~B))+$[13]+1309151649&4294967295,V=Q+(G<<21&4294967295|G>>>11),G=B+(Q^(V|~Y))+$[4]+4149444226&4294967295,B=V+(G<<6&4294967295|G>>>26),G=Y+(V^(B|~Q))+$[11]+3174756917&4294967295,Y=B+(G<<10&4294967295|G>>>22),G=Q+(B^(Y|~V))+$[2]+718787259&4294967295,Q=Y+(G<<15&4294967295|G>>>17),G=V+(Y^(Q|~B))+$[9]+3951481745&4294967295,z.g[0]=z.g[0]+B&4294967295,z.g[1]=z.g[1]+(Q+(G<<21&4294967295|G>>>11))&4294967295,z.g[2]=z.g[2]+Q&4294967295,z.g[3]=z.g[3]+Y&4294967295}r.prototype.v=function(z,B){B===void 0&&(B=z.length);const V=B-this.blockSize,$=this.C;let Q=this.h,Y=0;for(;Y>>$&255;return z};function a(z,B){var V=c;return Object.prototype.hasOwnProperty.call(V,z)?V[z]:V[z]=B(z)}function o(z,B){this.h=B;const V=[];let $=!0;for(let Q=z.length-1;Q>=0;Q--){const Y=z[Q]|0;$&&Y==B||(V[Q]=Y,$=!1)}this.g=V}var c={};function h(z){return-128<=z&&z<128?a(z,function(B){return new o([B|0],B<0?-1:0)}):new o([z|0],z<0?-1:0)}function f(z){if(isNaN(z)||!isFinite(z))return y;if(z<0)return T(f(-z));const B=[];let V=1;for(let $=0;z>=V;$++)B[$]=z/V|0,V*=4294967296;return new o(B,0)}function m(z,B){if(z.length==0)throw Error("number format error: empty string");if(B=B||10,B<2||36=0)throw Error('number format error: interior "-" character');const V=f(Math.pow(B,8));let $=y;for(let Y=0;Y=0?$:4294967296+$)*B,B*=4294967296}return z},e.toString=function(z){if(z=z||10,z<2||360?V.g[0]:V.h)>>>0).toString(z);if(V=Q,k(V))return Y+$;for(;Y.length<6;)Y="0"+Y;$=Y+$}},e.i=function(z){return z<0?0:z>>16)+(this.i(Q)>>>16)+(z.i(Q)>>>16);$=G>>>16,Y&=65535,G&=65535,V[Q]=G<<16|Y}return new o(V,V[V.length-1]&-2147483648?-1:0)};function D(z,B){return z.add(T(B))}e.j=function(z){if(k(this)||k(z))return y;if(I(this))return I(z)?T(this).j(T(z)):T(T(this).j(z));if(I(z))return T(this.j(T(z)));if(this.l(A)<0&&z.l(A)<0)return f(this.m()*z.m());const B=this.g.length+z.g.length,V=[];for(var $=0;$<2*B;$++)V[$]=0;for($=0;$>>16,G=this.i($)&65535,he=z.i(Q)>>>16,te=z.i(Q)&65535;V[2*$+2*Q]+=G*te,F(V,2*$+2*Q),V[2*$+2*Q+1]+=Y*te,F(V,2*$+2*Q+1),V[2*$+2*Q+1]+=G*he,F(V,2*$+2*Q+1),V[2*$+2*Q+2]+=Y*he,F(V,2*$+2*Q+2)}for(z=0;z>>16,z[B]&=65535,B++}function L(z,B){this.g=z,this.h=B}function q(z,B){if(k(B))throw Error("division by zero");if(k(z))return new L(y,y);if(I(z))return B=q(T(z),B),new L(T(B.g),T(B.h));if(I(B))return B=q(z,T(B)),new L(T(B.g),B.h);if(z.g.length>30){if(I(z)||I(B))throw Error("slowDivide_ only works with positive integers.");for(var V=w,$=B;$.l(z)<=0;)V=Z(V),$=Z($);var Q=K(V,1),Y=K($,1);for($=K($,2),V=K(V,2);!k($);){var G=Y.add($);G.l(z)<=0&&(Q=Q.add(V),Y=G),$=K($,1),V=K(V,1)}return B=D(z,Q.j(B)),new L(Q,B)}for(Q=y;z.l(B)>=0;){for(V=Math.max(1,Math.floor(z.m()/B.m())),$=Math.ceil(Math.log(V)/Math.LN2),$=$<=48?1:Math.pow(2,$-48),Y=f(V),G=Y.j(B);I(G)||G.l(z)>0;)V-=$,Y=f(V),G=Y.j(B);k(Y)&&(Y=w),Q=Q.add(Y),z=D(z,G)}return new L(Q,z)}e.B=function(z){return q(this,z).h},e.and=function(z){const B=Math.max(this.g.length,z.g.length),V=[];for(let $=0;$>>31;return new o(V,z.h)}function K(z,B){const V=B>>5;B%=32;const $=z.g.length-V,Q=[];for(let Y=0;Y<$;Y++)Q[Y]=B>0?z.i(Y+V)>>>B|z.i(Y+V+1)<<32-B:z.i(Y+V);return new o(Q,z.h)}r.prototype.digest=r.prototype.A,r.prototype.reset=r.prototype.u,r.prototype.update=r.prototype.v,h$=r,o.prototype.add=o.prototype.add,o.prototype.multiply=o.prototype.j,o.prototype.modulo=o.prototype.B,o.prototype.compare=o.prototype.l,o.prototype.toNumber=o.prototype.m,o.prototype.toString=o.prototype.toString,o.prototype.getBits=o.prototype.i,o.fromNumber=f,o.fromString=m,sf=o}).apply(typeof kR<"u"?kR:typeof self<"u"?self:typeof window<"u"?window:{});var uv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license Copyright The Closure Library Authors. SPDX-License-Identifier: Apache-2.0 */var f$,n1,p$,rw,Pk,m$,g$,x$;(function(){var e,t=Object.defineProperty;function n(_){_=[typeof globalThis=="object"&&globalThis,_,typeof window=="object"&&window,typeof self=="object"&&self,typeof uv=="object"&&uv];for(var U=0;U<_.length;++U){var H=_[U];if(H&&H.Math==Math)return H}throw Error("Cannot find global object")}var r=n(this);function i(_,U){if(U)e:{var H=r;_=_.split(".");for(var re=0;re<_.length-1;re++){var Oe=_[re];if(!(Oe in H))break e;H=H[Oe]}_=_[_.length-1],re=H[_],U=U(re),U!=re&&U!=null&&t(H,_,{configurable:!0,writable:!0,value:U})}}i("Symbol.dispose",function(_){return _||Symbol("Symbol.dispose")}),i("Array.prototype.values",function(_){return _||function(){return this[Symbol.iterator]()}}),i("Object.entries",function(_){return _||function(U){var H=[],re;for(re in U)Object.prototype.hasOwnProperty.call(U,re)&&H.push([re,U[re]]);return H}});/** @license Copyright The Closure Library Authors. SPDX-License-Identifier: Apache-2.0 */var a=a||{},o=this||self;function c(_){var U=typeof _;return U=="object"&&_!=null||U=="function"}function h(_,U,H){return _.call.apply(_.bind,arguments)}function f(_,U,H){return f=h,f.apply(null,arguments)}function m(_,U){var H=Array.prototype.slice.call(arguments,1);return function(){var re=H.slice();return re.push.apply(re,arguments),_.apply(this,re)}}function y(_,U){function H(){}H.prototype=U.prototype,_.Z=U.prototype,_.prototype=new H,_.prototype.constructor=_,_.Ob=function(re,Oe,We){for(var Ce=Array(arguments.length-2),_t=2;_t_&&AsyncContext.Snapshot.wrap(_):_=>_;function A(_){const U=_.length;if(U>0){const H=Array(U);for(let re=0;re0?(this.h--,U=this.g,this.g=U.next,U.next=null):U=this.i(),U}}function T(_){o.setTimeout(()=>{throw _},0)}function D(){var _=z;let U=null;return _.g&&(U=_.g,_.g=_.g.next,_.g||(_.h=null),U.next=null),U}class F{constructor(){this.h=this.g=null}add(U,H){const re=L.get();re.set(U,H),this.h?this.h.next=re:this.g=re,this.h=re}}var L=new I(()=>new q,_=>_.reset());class q{constructor(){this.next=this.g=this.h=null}set(U,H){this.h=U,this.g=H,this.next=null}reset(){this.next=this.g=this.h=null}}let Z,K=!1,z=new F,B=()=>{const _=Promise.resolve(void 0);Z=()=>{_.then(V)}};function V(){for(var _;_=D();){try{_.h.call(_.g)}catch(H){T(H)}var U=L;U.j(_),U.h<100&&(U.h++,_.next=U.g,U.g=_)}K=!1}function $(){this.u=this.u,this.C=this.C}$.prototype.u=!1,$.prototype.dispose=function(){this.u||(this.u=!0,this.N())},$.prototype[Symbol.dispose]=function(){this.dispose()},$.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function Q(_,U){this.type=_,this.g=this.target=U,this.defaultPrevented=!1}Q.prototype.h=function(){this.defaultPrevented=!0};var Y=(function(){if(!o.addEventListener||!Object.defineProperty)return!1;var _=!1,U=Object.defineProperty({},"passive",{get:function(){_=!0}});try{const H=()=>{};o.addEventListener("test",H,U),o.removeEventListener("test",H,U)}catch{}return _})();function G(_){return/^[\s\xa0]*$/.test(_)}function he(_,U){Q.call(this,_?_.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,_&&this.init(_,U)}y(he,Q),he.prototype.init=function(_,U){const H=this.type=_.type,re=_.changedTouches&&_.changedTouches.length?_.changedTouches[0]:null;this.target=_.target||_.srcElement,this.g=U,U=_.relatedTarget,U||(H=="mouseover"?U=_.fromElement:H=="mouseout"&&(U=_.toElement)),this.relatedTarget=U,re?(this.clientX=re.clientX!==void 0?re.clientX:re.pageX,this.clientY=re.clientY!==void 0?re.clientY:re.pageY,this.screenX=re.screenX||0,this.screenY=re.screenY||0):(this.clientX=_.clientX!==void 0?_.clientX:_.pageX,this.clientY=_.clientY!==void 0?_.clientY:_.pageY,this.screenX=_.screenX||0,this.screenY=_.screenY||0),this.button=_.button,this.key=_.key||"",this.ctrlKey=_.ctrlKey,this.altKey=_.altKey,this.shiftKey=_.shiftKey,this.metaKey=_.metaKey,this.pointerId=_.pointerId||0,this.pointerType=_.pointerType,this.state=_.state,this.i=_,_.defaultPrevented&&he.Z.h.call(this)},he.prototype.h=function(){he.Z.h.call(this);const _=this.i;_.preventDefault?_.preventDefault():_.returnValue=!1};var te="closure_listenable_"+(Math.random()*1e6|0),le=0;function ve(_,U,H,re,Oe){this.listener=_,this.proxy=null,this.src=U,this.type=H,this.capture=!!re,this.ha=Oe,this.key=++le,this.da=this.fa=!1}function ke(_){_.da=!0,_.listener=null,_.proxy=null,_.src=null,_.ha=null}function Be(_,U,H){for(const re in _)U.call(H,_[re],re,_)}function J(_,U){for(const H in _)U.call(void 0,_[H],H,_)}function ie(_){const U={};for(const H in _)U[H]=_[H];return U}const xe="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function ae(_,U){let H,re;for(let Oe=1;Oe-1?(U=_[Ce],H||(U.fa=!1)):(U=new ve(U,this.src,We,!!re,Oe),U.fa=H,_.push(U)),U};function pt(_,U){const H=U.type;if(H in _.g){var re=_.g[H],Oe=Array.prototype.indexOf.call(re,U,void 0),We;(We=Oe>=0)&&Array.prototype.splice.call(re,Oe,1),We&&(ke(U),_.g[H].length==0&&(delete _.g[H],_.h--))}}function Ue(_,U,H,re){for(let Oe=0;Oe<_.length;++Oe){const We=_[Oe];if(!We.da&&We.listener==U&&We.capture==!!H&&We.ha==re)return Oe}return-1}var Ct="closure_lm_"+(Math.random()*1e6|0),Tt={};function ht(_,U,H,re,Oe){if(Array.isArray(U)){for(let We=0;We-1&&(ke(U[H]),Array.prototype.splice.call(U,H,1),U.length==0&&(delete _.g[We],_.h--)))):_&&(_=Ft(_))&&(U=_.g[U.toString()],_=-1,U&&(_=Ue(U,H,re,Oe)),(H=_>-1?U[_]:null)&&sn(H))}function sn(_){if(typeof _!="number"&&_&&!_.da){var U=_.src;if(U&&U[te])pt(U.i,_);else{var H=_.type,re=_.proxy;U.removeEventListener?U.removeEventListener(H,re,_.capture):U.detachEvent?U.detachEvent(pn(H),re):U.addListener&&U.removeListener&&U.removeListener(re),(H=Ft(U))?(pt(H,_),H.h==0&&(H.src=null,U[Ct]=null)):ke(_)}}}function pn(_){return _ in Tt?Tt[_]:Tt[_]="on"+_}function Fn(_,U){if(_.da)_=!0;else{U=new he(U,this);const H=_.listener,re=_.ha||_.src;_.fa&&sn(_),_=H.call(re,U)}return _}function Ft(_){return _=_[Ct],_ instanceof Fe?_:null}var Dt="__closure_events_fn_"+(Math.random()*1e9>>>0);function Ht(_){return typeof _=="function"?_:(_[Dt]||(_[Dt]=function(U){return _.handleEvent(U)}),_[Dt])}function Ze(){$.call(this),this.i=new Fe(this),this.M=this,this.G=null}y(Ze,$),Ze.prototype[te]=!0,Ze.prototype.removeEventListener=function(_,U,H,re){dt(this,_,U,H,re)};function Wt(_,U){var H,re=_.G;if(re)for(H=[];re;re=re.G)H.push(re);if(_=_.M,re=U.type||U,typeof U=="string")U=new Q(U,_);else if(U instanceof Q)U.target=U.target||_;else{var Oe=U;U=new Q(re,_),ae(U,Oe)}Oe=!0;let We,Ce;if(H)for(Ce=H.length-1;Ce>=0;Ce--)We=U.g=H[Ce],Oe=It(We,re,!0,U)&&Oe;if(We=U.g=_,Oe=It(We,re,!0,U)&&Oe,Oe=It(We,re,!1,U)&&Oe,H)for(Ce=0;Ce2147483647?-1:o.setTimeout(_,U||0)}function Kn(_){_.g=ln(()=>{_.g=null,_.i&&(_.i=!1,Kn(_))},_.l);const U=_.h;_.h=null,_.m.apply(null,U)}class un extends ${constructor(U,H){super(),this.m=U,this.l=H,this.h=null,this.i=!1,this.g=null}j(U){this.h=arguments,this.g?this.i=!0:Kn(this)}N(){super.N(),this.g&&(o.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function xr(_){$.call(this),this.h=_,this.g={}}y(xr,$);var Ve=[];function Ot(_){Be(_.g,function(U,H){this.g.hasOwnProperty(H)&&sn(U)},_),_.g={}}xr.prototype.N=function(){xr.Z.N.call(this),Ot(this)},xr.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var nn=o.JSON.stringify,mn=o.JSON.parse,dr=class{stringify(_){return o.JSON.stringify(_,void 0)}parse(_){return o.JSON.parse(_,void 0)}};function hr(){}function Ui(){}var $n={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function be(){Q.call(this,"d")}y(be,Q);function je(){Q.call(this,"c")}y(je,Q);var ze={},tt=null;function fn(){return tt=tt||new Ze}ze.Ia="serverreachability";function Bt(_){Q.call(this,ze.Ia,_)}y(Bt,Q);function jn(_){const U=fn();Wt(U,new Bt(U))}ze.STAT_EVENT="statevent";function jt(_,U){Q.call(this,ze.STAT_EVENT,_),this.stat=U}y(jt,Q);function on(_){const U=fn();Wt(U,new jt(U,_))}ze.Ja="timingevent";function Ir(_,U){Q.call(this,ze.Ja,_),this.size=U}y(Ir,Q);function pr(_,U){if(typeof _!="function")throw Error("Fn must not be null and must be a function");return o.setTimeout(function(){_()},U)}function ue(){this.g=!0}ue.prototype.ua=function(){this.g=!1};function Se(_,U,H,re,Oe,We){_.info(function(){if(_.g)if(We){var Ce="",_t=We.split("&");for(let Nn=0;Nn<_t.length;Nn++){var qn=_t[Nn].split("=");if(qn.length>1){const Jn=qn[0];qn=qn[1];const Br=Jn.split("_");Ce=Br.length>=2&&Br[1]=="type"?Ce+(Jn+"="+qn+"&"):Ce+(Jn+"=redacted&")}}}else Ce=null;else Ce=We;return"XMLHTTP REQ ("+re+") [attempt "+Oe+"]: "+U+` `+H+` `+Ce})}function Xe(_,U,H,re,Oe,We,Ce){_.info(function(){return"XMLHTTP RESP ("+re+") [ attempt "+Oe+"]: "+U+` `+H+` `+We+" "+Ce})}function Vt(_,U,H,re){_.info(function(){return"XMLHTTP TEXT ("+U+"): "+xn(_,H)+(re?" "+re:"")})}function gn(_,U){_.info(function(){return"TIMEOUT: "+U})}ue.prototype.info=function(){};function xn(_,U){if(!_.g)return U;if(!U)return null;try{const We=JSON.parse(U);if(We){for(_=0;_0&&_.length;)H.push(_.shift()),U--;return _.length&&H.push(_.join(":")),H}function yt(_,U,H,re){this.j=_,this.i=U,this.l=H,this.S=re||1,this.V=new xr(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 cn}function cn(){this.i=null,this.g="",this.h=!1}var Pt={},Sn={};function _r(_,U,H){_.M=1,_.A=Ut(Je(U)),_.u=H,_.R=!0,xi(_,null)}function xi(_,U){_.F=Date.now(),is(_),_.B=Je(_.A);var H=_.B,re=_.S;Array.isArray(re)||(re=[String(re)]),wr(H.i,"t",re),_.C=0,H=_.j.L,_.h=new cn,_.g=lt(_.j,H?U:null,!_.u),_.P>0&&(_.O=new un(f(_.Y,_,_.g),_.P)),U=_.V,H=_.g,re=_.ba;var Oe="readystatechange";Array.isArray(Oe)||(Oe&&(Ve[0]=Oe.toString()),Oe=Ve);for(let We=0;We0&&!this.W){this.W=!0;var Ce=this.j;Ce.g==this&&Ce.aa&&!Ce.P&&(Ce.j.info("Great, no buffering proxy detected. Bytes received: "+H.length),st(Ce),Ce.P=!0,on(11))}}else Vt(this.i,this.l,H,null),ss(this,H);_t==4&&Qi(this),this.o&&!this.K&&(_t==4?ge(this.j,this):(this.o=!1,is(this)))}else Ys(this.g),U==400&&H.indexOf("Unknown SID")>0?(this.m=3,on(12)):(this.m=0,on(13)),Qi(this),Sr(this)}}}catch{}finally{}};function rs(_){if(!mi(_))return _.g.la();const U=Vr(_.g);if(U==="")return"";let H="";const re=U.length,Oe=ma(_.g)==4;if(!_.h.i){if(typeof TextDecoder>"u")return Qi(_),Sr(_),"";_.h.i=new o.TextDecoder}for(let We=0;WeU.length?Sn:(U=U.slice(re,re+H),_.C=re+H,U)))}yt.prototype.cancel=function(){this.K=!0,Qi(this)};function is(_){_.T=Date.now()+_.H,hi(_,_.H)}function hi(_,U){if(_.D!=null)throw Error("WatchDog timer not null");_.D=pr(f(_.aa,_),U)}function Wr(_){_.D&&(o.clearTimeout(_.D),_.D=null)}yt.prototype.aa=function(){this.D=null;const _=Date.now();_-this.T>=0?(gn(this.i,this.B),this.M!=2&&(jn(),on(17)),Qi(this),this.m=2,Sr(this)):hi(this,this.T-_)};function Sr(_){_.j.I==0||_.K||ge(_.j,_)}function Qi(_){Wr(_);var U=_.O;U&&typeof U.dispose=="function"&&U.dispose(),_.O=null,Ot(_.V),_.g&&(U=_.g,_.g=null,U.abort(),U.dispose())}function ss(_,U){try{var H=_.j;if(H.I!=0&&(H.g==_||Hi(H.h,_))){if(!_.L&&Hi(H.h,_)&&H.I==3){try{var re=H.Ba.g.parse(U)}catch{re=null}if(Array.isArray(re)&&re.length==3){var Oe=re;if(Oe[0]==0){e:if(!H.v){if(H.g)if(H.g.F+3e3<_.F)Mi(H),Xa(H);else break e;Zo(H),on(18)}}else H.xa=Oe[1],00&&(re=1.5*Qr,H.O=re,H.j.info("backChannelRequestTimeoutMs_="+re)),re=H;const Kr=_.g;if(Kr){const Xs=Kr.g?Kr.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(Xs){var We=re.h;We.g||Xs.indexOf("spdy")==-1&&Xs.indexOf("quic")==-1&&Xs.indexOf("h2")==-1||(We.j=We.l,We.g=new Set,We.h&&(jo(We,We.h),We.h=null))}if(re.G){const Da=Kr.g?Kr.g.getResponseHeader("X-HTTP-Session-Id"):null;Da&&(re.wa=Da,Le(re.J,re.G,Da))}}H.I=3,H.l&&H.l.ra(),H.aa&&(H.T=Date.now()-_.F,H.j.info("Handshake RTT: "+H.T+"ms")),re=H;var Ce=_;if(re.na=ut(re,re.L?re.ba:null,re.W),Ce.L){or(re.h,Ce);var _t=Ce,qn=re.O;qn&&(_t.H=qn),_t.D&&(Wr(_t),is(_t)),re.g=Ce}else ia(re);H.i.length>0&&ra(H)}else Nn[0]!="stop"&&Nn[0]!="close"||Te(H,7);else H.I==3&&(Nn[0]=="stop"||Nn[0]=="close"?Nn[0]=="stop"?Te(H,7):El(H):Nn[0]!="noop"&&H.l&&H.l.qa(Nn),H.A=0)}}jn(4)}catch{}}var si=class{constructor(_,U){this.g=_,this.map=U}};function Et(_){this.l=_||10,o.PerformanceNavigationTiming?(_=o.performance.getEntriesByType("navigation"),_=_.length>0&&(_[0].nextHopProtocol=="hq"||_[0].nextHopProtocol=="h2")):_=!!(o.chrome&&o.chrome.loadTimes&&o.chrome.loadTimes()&&o.chrome.loadTimes().wasFetchedViaSpdy),this.j=_?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function Oa(_){return _.h?!0:_.g?_.g.size>=_.j:!1}function Tr(_){return _.h?1:_.g?_.g.size:0}function Hi(_,U){return _.h?_.h==U:_.g?_.g.has(U):!1}function jo(_,U){_.g?_.g.add(U):_.h=U}function or(_,U){_.h&&_.h==U?_.h=null:_.g&&_.g.has(U)&&_.g.delete(U)}Et.prototype.cancel=function(){if(this.i=kr(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const _ of this.g.values())_.cancel();this.g.clear()}};function kr(_){if(_.h!=null)return _.i.concat(_.h.G);if(_.g!=null&&_.g.size!==0){let U=_.i;for(const H of _.g.values())U=U.concat(H.G);return U}return A(_.i)}var lr=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Re(_,U){if(_){_=_.split("&");for(let H=0;H<_.length;H++){const re=_[H].indexOf("=");let Oe,We=null;re>=0?(Oe=_[H].substring(0,re),We=_[H].substring(re+1)):Oe=_[H],U(Oe,We?decodeURIComponent(We.replace(/\+/g," ")):"")}}}function mt(_){this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1;let U;_ instanceof mt?(this.l=_.l,vt(this,_.j),this.o=_.o,this.g=_.g,Zt(this,_.u),this.h=_.h,wn(this,na(_.i)),this.m=_.m):_&&(U=String(_).match(lr))?(this.l=!1,vt(this,U[1]||"",!0),this.o=On(U[2]||""),this.g=On(U[3]||"",!0),Zt(this,U[4]),this.h=On(U[5]||"",!0),wn(this,U[6]||"",!0),this.m=On(U[7]||"")):(this.l=!1,this.i=new oi(null,this.l))}mt.prototype.toString=function(){const _=[];var U=this.j;U&&_.push(Mn(U,vr,!0),":");var H=this.g;return(H||U=="file")&&(_.push("//"),(U=this.o)&&_.push(Mn(U,vr,!0),"@"),_.push(Ae(H).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),H=this.u,H!=null&&_.push(":",String(H))),(H=this.h)&&(this.g&&H.charAt(0)!="/"&&_.push("/"),_.push(Mn(H,H.charAt(0)=="/"?fe:Me,!0))),(H=this.i.toString())&&_.push("?",H),(H=this.m)&&_.push("#",Mn(H,ai)),_.join("")},mt.prototype.resolve=function(_){const U=Je(this);let H=!!_.j;H?vt(U,_.j):H=!!_.o,H?U.o=_.o:H=!!_.g,H?U.g=_.g:H=_.u!=null;var re=_.h;if(H)Zt(U,_.u);else if(H=!!_.h){if(re.charAt(0)!="/")if(this.g&&!this.h)re="/"+re;else{var Oe=U.h.lastIndexOf("/");Oe!=-1&&(re=U.h.slice(0,Oe+1)+re)}if(Oe=re,Oe==".."||Oe==".")re="";else if(Oe.indexOf("./")!=-1||Oe.indexOf("/.")!=-1){re=Oe.lastIndexOf("/",0)==0,Oe=Oe.split("/");const We=[];for(let Ce=0;Ce1||We.length==1&&We[0]!="")&&We.pop(),re&&Ce==Oe.length&&We.push("")):(We.push(_t),re=!0)}re=We.join("/")}else re=Oe}return H?U.h=re:H=_.i.toString()!=="",H?wn(U,na(_.i)):H=!!_.m,H&&(U.m=_.m),U};function Je(_){return new mt(_)}function vt(_,U,H){_.j=H?On(U,!0):U,_.j&&(_.j=_.j.replace(/:$/,""))}function Zt(_,U){if(U){if(U=Number(U),isNaN(U)||U<0)throw Error("Bad port number "+U);_.u=U}else _.u=null}function wn(_,U,H){U instanceof oi?(_.i=U,Pa(_.i,_.l)):(H||(U=Mn(U,rn)),_.i=new oi(U,_.l))}function Le(_,U,H){_.i.set(U,H)}function Ut(_){return Le(_,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),_}function On(_,U){return _?U?decodeURI(_.replace(/%25/g,"%2525")):decodeURIComponent(_):""}function Mn(_,U,H){return typeof _=="string"?(_=encodeURI(_).replace(U,Pn),H&&(_=_.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),_):null}function Pn(_){return _=_.charCodeAt(0),"%"+(_>>4&15).toString(16)+(_&15).toString(16)}var vr=/[#\/\?@]/g,Me=/[#\?:]/g,fe=/[#\?]/g,rn=/[#\?@]/g,ai=/#/g;function oi(_,U){this.h=this.g=null,this.i=_||null,this.j=!!U}function yi(_){_.g||(_.g=new Map,_.h=0,_.i&&Re(_.i,function(U,H){_.add(decodeURIComponent(U.replace(/\+/g," ")),H)}))}e=oi.prototype,e.add=function(_,U){yi(this),this.i=null,_=Ms(this,_);let H=this.g.get(_);return H||this.g.set(_,H=[]),H.push(U),this.h+=1,this};function gi(_,U){yi(_),U=Ms(_,U),_.g.has(U)&&(_.i=null,_.h-=_.g.get(U).length,_.g.delete(U))}function Gi(_,U){return yi(_),U=Ms(_,U),_.g.has(U)}e.forEach=function(_,U){yi(this),this.g.forEach(function(H,re){H.forEach(function(Oe){_.call(U,Oe,re,this)},this)},this)};function en(_,U){yi(_);let H=[];if(typeof U=="string")Gi(_,U)&&(H=H.concat(_.g.get(Ms(_,U))));else for(_=Array.from(_.g.values()),U=0;U<_.length;U++)H=H.concat(_[U]);return H}e.set=function(_,U){return yi(this),this.i=null,_=Ms(this,_),Gi(this,_)&&(this.h-=this.g.get(_).length),this.g.set(_,[U]),this.h+=1,this},e.get=function(_,U){return _?(_=en(this,_),_.length>0?String(_[0]):U):U};function wr(_,U,H){gi(_,U),H.length>0&&(_.i=null,_.g.set(Ms(_,U),A(H)),_.h+=H.length)}e.toString=function(){if(this.i)return this.i;if(!this.g)return"";const _=[],U=Array.from(this.g.keys());for(let re=0;re{re.abort(),Ks(H,"TestPingServer: timeout",!1,U)},1e4);fetch(_,{signal:re.signal}).then(We=>{clearTimeout(Oe),We.ok?Ks(H,"TestPingServer: ok",!0,U):Ks(H,"TestPingServer: server error",!1,U)}).catch(()=>{clearTimeout(Oe),Ks(H,"TestPingServer: error",!1,U)})}function Ks(_,U,H,re,Oe){try{Oe&&(Oe.onload=null,Oe.onerror=null,Oe.onabort=null,Oe.ontimeout=null),re(H)}catch{}}function Si(){this.g=new dr}function Cs(_){this.i=_.Sb||null,this.h=_.ab||!1}y(Cs,hr),Cs.prototype.g=function(){return new Is(this.i,this.h)};function Is(_,U){Ze.call(this),this.H=_,this.o=U,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}y(Is,Ze),e=Is.prototype,e.open=function(_,U){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.F=_,this.D=U,this.readyState=1,Yn(this)},e.send=function(_){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 U={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};_&&(U.body=_),(this.H||o).fetch(new Request(this.D,U)).then(this.Pa.bind(this),this.ga.bind(this))},e.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,Ls(this)),this.readyState=0},e.Pa=function(_){if(this.g&&(this.l=_,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=_.headers,this.readyState=2,Yn(this)),this.g&&(this.readyState=3,Yn(this),this.g)))if(this.responseType==="arraybuffer")_.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(typeof o.ReadableStream<"u"&&"body"in _){if(this.j=_.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;Gn(this)}else _.text().then(this.Oa.bind(this),this.ga.bind(this))};function Gn(_){_.j.read().then(_.Ma.bind(_)).catch(_.ga.bind(_))}e.Ma=function(_){if(this.g){if(this.o&&_.value)this.response.push(_.value);else if(!this.o){var U=_.value?_.value:new Uint8Array(0);(U=this.B.decode(U,{stream:!_.done}))&&(this.response=this.responseText+=U)}_.done?Ls(this):Yn(this),this.readyState==3&&Gn(this)}},e.Oa=function(_){this.g&&(this.response=this.responseText=_,Ls(this))},e.Na=function(_){this.g&&(this.response=_,Ls(this))},e.ga=function(){this.g&&Ls(this)};function Ls(_){_.readyState=4,_.l=null,_.j=null,_.B=null,Yn(_)}e.setRequestHeader=function(_,U){this.A.append(_,U)},e.getResponseHeader=function(_){return this.h&&this.h.get(_.toLowerCase())||""},e.getAllResponseHeaders=function(){if(!this.h)return"";const _=[],U=this.h.entries();for(var H=U.next();!H.done;)H=H.value,_.push(H[0]+": "+H[1]),H=U.next();return _.join(`\r `)};function Yn(_){_.onreadystatechange&&_.onreadystatechange.call(_)}Object.defineProperty(Is.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(_){this.m=_?"include":"same-origin"}});function li(_){let U="";return Be(_,function(H,re){U+=re,U+=":",U+=H,U+=`\r `}),U}function To(_,U,H){e:{for(re in H){var re=!1;break e}re=!0}re||(H=li(H),typeof _=="string"?H!=null&&Ae(H):Le(_,U,H))}function zr(_){Ze.call(this),this.headers=new Map,this.L=_||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}y(zr,Ze);var Ka=/^https?$/i,Us=["POST","PUT"];e=zr.prototype,e.Fa=function(_){this.H=_},e.ea=function(_,U,H,re){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+_);U=U?U.toUpperCase():"GET",this.D=_,this.l="",this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():Tn.g(),this.g.onreadystatechange=w(f(this.Ca,this));try{this.B=!0,this.g.open(U,String(_),!0),this.B=!1}catch(We){Qo(this,We);return}if(_=H||"",H=new Map(this.headers),re)if(Object.getPrototypeOf(re)===Object.prototype)for(var Oe in re)H.set(Oe,re[Oe]);else if(typeof re.keys=="function"&&typeof re.get=="function")for(const We of re.keys())H.set(We,re.get(We));else throw Error("Unknown input type for opt_headers: "+String(re));re=Array.from(H.keys()).find(We=>We.toLowerCase()=="content-type"),Oe=o.FormData&&_ instanceof o.FormData,!(Array.prototype.indexOf.call(Us,U,void 0)>=0)||re||Oe||H.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[We,Ce]of H)this.g.setRequestHeader(We,Ce);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(_),this.v=!1}catch(We){Qo(this,We)}};function Qo(_,U){_.h=!1,_.g&&(_.j=!0,_.g.abort(),_.j=!1),_.l=U,_.o=5,Ya(_),bs(_)}function Ya(_){_.A||(_.A=!0,Wt(_,"complete"),Wt(_,"error"))}e.abort=function(_){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=_||7,Wt(this,"complete"),Wt(this,"abort"),bs(this))},e.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),bs(this,!0)),zr.Z.N.call(this)},e.Ca=function(){this.u||(this.B||this.v||this.j?pa(this):this.Xa())},e.Xa=function(){pa(this)};function pa(_){if(_.h&&typeof a<"u"){if(_.v&&ma(_)==4)setTimeout(_.Ca.bind(_),0);else if(Wt(_,"readystatechange"),ma(_)==4){_.h=!1;try{const We=_.ca();e:switch(We){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var U=!0;break e;default:U=!1}var H;if(!(H=U)){var re;if(re=We===0){let Ce=String(_.D).match(lr)[1]||null;!Ce&&o.self&&o.self.location&&(Ce=o.self.location.protocol.slice(0,-1)),re=!Ka.test(Ce?Ce.toLowerCase():"")}H=re}if(H)Wt(_,"complete"),Wt(_,"success");else{_.o=6;try{var Oe=ma(_)>2?_.g.statusText:""}catch{Oe=""}_.l=Oe+" ["+_.ca()+"]",Ya(_)}}finally{bs(_)}}}}function bs(_,U){if(_.g){_.m&&(clearTimeout(_.m),_.m=null);const H=_.g;_.g=null,U||Wt(_,"ready");try{H.onreadystatechange=null}catch{}}}e.isActive=function(){return!!this.g};function ma(_){return _.g?_.g.readyState:0}e.ca=function(){try{return ma(this)>2?this.g.status:-1}catch{return-1}},e.la=function(){try{return this.g?this.g.responseText:""}catch{return""}},e.La=function(_){if(this.g){var U=this.g.responseText;return _&&U.indexOf(_)==0&&(U=U.substring(_.length)),mn(U)}};function Vr(_){try{if(!_.g)return null;if("response"in _.g)return _.g.response;switch(_.F){case"":case"text":return _.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in _.g)return _.g.mozResponseArrayBuffer}return null}catch{return null}}function Ys(_){const U={};_=(_.g&&ma(_)>=2&&_.g.getAllResponseHeaders()||"").split(`\r `);for(let re=0;re<_.length;re++){if(G(_[re]))continue;var H=tn(_[re]);const Oe=H[0];if(H=H[1],typeof H!="string")continue;H=H.trim();const We=U[Oe]||[];U[Oe]=We,We.push(H)}J(U,function(re){return re.join(", ")})}e.ya=function(){return this.o},e.Ha=function(){return typeof this.l=="string"?this.l:String(this.l)};function bi(_,U,H){return H&&H.internalChannelParams&&H.internalChannelParams[_]||U}function co(_){this.za=0,this.i=[],this.j=new ue,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=bi("failFast",!1,_),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=bi("baseRetryDelayMs",5e3,_),this.Za=bi("retryDelaySeedMs",1e4,_),this.Ta=bi("forwardChannelMaxRetries",2,_),this.va=bi("forwardChannelRequestTimeoutMs",2e4,_),this.ma=_&&_.xmlHttpFactory||void 0,this.Ua=_&&_.Rb||void 0,this.Aa=_&&_.useFetchStreams||!1,this.O=void 0,this.L=_&&_.supportsCrossDomainXhr||!1,this.M="",this.h=new Et(_&&_.concurrentRequestLimit),this.Ba=new Si,this.S=_&&_.fastHandshake||!1,this.R=_&&_.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=_&&_.Pb||!1,_&&_.ua&&this.j.ua(),_&&_.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&_&&_.detectBufferingProxy||!1,this.ia=void 0,_&&_.longPollingTimeout&&_.longPollingTimeout>0&&(this.ia=_.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}e=co.prototype,e.ka=8,e.I=1,e.connect=function(_,U,H,re){on(0),this.W=_,this.H=U||{},H&&re!==void 0&&(this.H.OSID=H,this.H.OAID=re),this.F=this.X,this.J=ut(this,null,this.W),ra(this)};function El(_){if(Ra(_),_.I==3){var U=_.V++,H=Je(_.J);if(Le(H,"SID",_.M),Le(H,"RID",U),Le(H,"TYPE","terminate"),uo(_,H),U=new yt(_,_.j,U),U.M=2,U.A=Ut(Je(H)),H=!1,o.navigator&&o.navigator.sendBeacon)try{H=o.navigator.sendBeacon(U.A.toString(),"")}catch{}!H&&o.Image&&(new Image().src=U.A,H=!0),H||(U.g=lt(U.j,null),U.g.ea(U.A)),U.F=Date.now(),is(U)}$e(_)}function Xa(_){_.g&&(st(_),_.g.cancel(),_.g=null)}function Ra(_){Xa(_),_.v&&(o.clearTimeout(_.v),_.v=null),Mi(_),_.h.cancel(),_.m&&(typeof _.m=="number"&&o.clearTimeout(_.m),_.m=null)}function ra(_){if(!Oa(_.h)&&!_.m){_.m=!0;var U=_.Ea;Z||B(),K||(Z(),K=!0),z.add(U,_),_.D=0}}function Oo(_,U){return Tr(_.h)>=_.h.j-(_.m?1:0)?!1:_.m?(_.i=U.G.concat(_.i),!0):_.I==1||_.I==2||_.D>=(_.Sa?0:_.Ta)?!1:(_.m=pr(f(_.Ea,_,U),we(_,_.D)),_.D++,!0)}e.Ea=function(_){if(this.m)if(this.m=null,this.I==1){if(!_){this.V=Math.floor(Math.random()*1e5),_=this.V++;const Oe=new yt(this,this.j,_);let We=this.o;if(this.U&&(We?(We=ie(We),ae(We,this.U)):We=this.U),this.u!==null||this.R||(Oe.J=We,We=null),this.S)e:{for(var U=0,H=0;H4096){U=H;break e}if(U===4096||H===this.i.length-1){U=H+1;break e}}U=1e3}else U=1e3;U=ci(this,Oe,U),H=Je(this.J),Le(H,"RID",_),Le(H,"CVER",22),this.G&&Le(H,"X-HTTP-Session-Id",this.G),uo(this,H),We&&(this.R?U="headers="+Ae(li(We))+"&"+U:this.u&&To(H,this.u,We)),jo(this.h,Oe),this.Ra&&Le(H,"TYPE","init"),this.S?(Le(H,"$req",U),Le(H,"SID","null"),Oe.U=!0,_r(Oe,H,null)):_r(Oe,H,U),this.I=2}}else this.I==3&&(_?Fr(this,_):this.i.length==0||Oa(this.h)||Fr(this))};function Fr(_,U){var H;U?H=U.l:H=_.V++;const re=Je(_.J);Le(re,"SID",_.M),Le(re,"RID",H),Le(re,"AID",_.K),uo(_,re),_.u&&_.o&&To(re,_.u,_.o),H=new yt(_,_.j,H,_.D+1),_.u===null&&(H.J=_.o),U&&(_.i=U.G.concat(_.i)),U=ci(_,H,1e3),H.H=Math.round(_.va*.5)+Math.round(_.va*.5*Math.random()),jo(_.h,H),_r(H,re,U)}function uo(_,U){_.H&&Be(_.H,function(H,re){Le(U,re,H)}),_.l&&Be({},function(H,re){Le(U,re,H)})}function ci(_,U,H){H=Math.min(_.i.length,H);const re=_.l?f(_.l.Ka,_.l,_):null;e:{var Oe=_.i;let _t=-1;for(;;){const qn=["count="+H];_t==-1?H>0?(_t=Oe[0].g,qn.push("ofs="+_t)):_t=0:qn.push("ofs="+_t);let Nn=!0;for(let Jn=0;Jn=3?!1:(_.Y++,_.v=pr(f(_.Da,_),we(_,_.A)),_.A++,!0)}e.Da=function(){if(this.v=null,mr(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var _=4*this.T;this.j.info("BP detection timer enabled: "+_),this.B=pr(f(this.Wa,this),_)}},e.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,on(10),Xa(this),mr(this))};function st(_){_.B!=null&&(o.clearTimeout(_.B),_.B=null)}function mr(_){_.g=new yt(_,_.j,"rpc",_.Y),_.u===null&&(_.g.J=_.o),_.g.P=0;var U=Je(_.na);Le(U,"RID","rpc"),Le(U,"SID",_.M),Le(U,"AID",_.K),Le(U,"CI",_.F?"0":"1"),!_.F&&_.ia&&Le(U,"TO",_.ia),Le(U,"TYPE","xmlhttp"),uo(_,U),_.u&&_.o&&To(U,_.u,_.o),_.O&&(_.g.H=_.O);var H=_.g;_=_.ba,H.M=1,H.A=Ut(Je(U)),H.u=null,H.R=!0,xi(H,_)}e.Va=function(){this.C!=null&&(this.C=null,Xa(this),Zo(this),on(19))};function Mi(_){_.C!=null&&(o.clearTimeout(_.C),_.C=null)}function ge(_,U){var H=null;if(_.g==U){Mi(_),st(_),_.g=null;var re=2}else if(Hi(_.h,U))H=U.G,or(_.h,U),re=1;else return;if(_.I!=0){if(U.o)if(re==1){H=U.u?U.u.length:0,U=Date.now()-U.F;var Oe=_.D;re=fn(),Wt(re,new Ir(re,H)),ra(_)}else ia(_);else if(Oe=U.m,Oe==3||Oe==0&&U.X>0||!(re==1&&Oo(_,U)||re==2&&Zo(_)))switch(H&&H.length>0&&(U=_.h,U.i=U.i.concat(H)),Oe){case 1:Te(_,5);break;case 4:Te(_,10);break;case 3:Te(_,6);break;default:Te(_,2)}}}function we(_,U){let H=_.Qa+Math.floor(Math.random()*_.Za);return _.isActive()||(H*=2),H*U}function Te(_,U){if(_.j.info("Error code "+U),U==2){var H=f(_.bb,_),re=_.Ua;const Oe=!re;re=new mt(re||"//www.google.com/images/cleardot.gif"),o.location&&o.location.protocol=="http"||vt(re,"https"),Ut(re),Oe?ks(re.toString(),H):Nl(re.toString(),H)}else on(2);_.I=0,_.l&&_.l.pa(U),$e(_),Ra(_)}e.bb=function(_){_?(this.j.info("Successfully pinged google.com"),on(2)):(this.j.info("Failed to ping google.com"),on(1))};function $e(_){if(_.I=0,_.ja=[],_.l){const U=kr(_.h);(U.length!=0||_.i.length!=0)&&(k(_.ja,U),k(_.ja,_.i),_.h.i.length=0,A(_.i),_.i.length=0),_.l.oa()}}function ut(_,U,H){var re=H instanceof mt?Je(H):new mt(H);if(re.g!="")U&&(re.g=U+"."+re.g),Zt(re,re.u);else{var Oe=o.location;re=Oe.protocol,U=U?U+"."+Oe.hostname:Oe.hostname,Oe=+Oe.port;const We=new mt(null);re&&vt(We,re),U&&(We.g=U),Oe&&Zt(We,Oe),H&&(We.h=H),re=We}return H=_.G,U=_.wa,H&&U&&Le(re,H,U),Le(re,"VER",_.ka),uo(_,re),re}function lt(_,U,H){if(U&&!_.L)throw Error("Can't create secondary domain capable XhrIo object.");return U=_.Aa&&!_.ma?new zr(new Cs({ab:H})):new zr(_.ma),U.Fa(_.L),U}e.isActive=function(){return!!this.l&&this.l.isActive(this)};function At(){}e=At.prototype,e.ra=function(){},e.qa=function(){},e.pa=function(){},e.oa=function(){},e.isActive=function(){return!0},e.Ka=function(){};function bn(){}bn.prototype.g=function(_,U){return new Mt(_,U)};function Mt(_,U){Ze.call(this),this.g=new co(U),this.l=_,this.h=U&&U.messageUrlParams||null,_=U&&U.messageHeaders||null,U&&U.clientProtocolHeaderRequired&&(_?_["X-Client-Protocol"]="webchannel":_={"X-Client-Protocol":"webchannel"}),this.g.o=_,_=U&&U.initMessageHeaders||null,U&&U.messageContentType&&(_?_["X-WebChannel-Content-Type"]=U.messageContentType:_={"X-WebChannel-Content-Type":U.messageContentType}),U&&U.sa&&(_?_["X-WebChannel-Client-Profile"]=U.sa:_={"X-WebChannel-Client-Profile":U.sa}),this.g.U=_,(_=U&&U.Qb)&&!G(_)&&(this.g.u=_),this.A=U&&U.supportsCrossDomainXhr||!1,this.v=U&&U.sendRawJson||!1,(U=U&&U.httpSessionIdParam)&&!G(U)&&(this.g.G=U,_=this.h,_!==null&&U in _&&(_=this.h,U in _&&delete _[U])),this.j=new qe(this)}y(Mt,Ze),Mt.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},Mt.prototype.close=function(){El(this.g)},Mt.prototype.o=function(_){var U=this.g;if(typeof _=="string"){var H={};H.__data__=_,_=H}else this.v&&(H={},H.__data__=nn(_),_=H);U.i.push(new si(U.Ya++,_)),U.I==3&&ra(U)},Mt.prototype.N=function(){this.g.l=null,delete this.j,El(this.g),delete this.g,Mt.Z.N.call(this)};function An(_){be.call(this),_.__headers__&&(this.headers=_.__headers__,this.statusCode=_.__status__,delete _.__headers__,delete _.__status__);var U=_.__sm__;if(U){e:{for(const H in U){_=H;break e}_=void 0}(this.i=_)&&(_=this.i,U=U!==null&&_ in U?U[_]:void 0),this.data=U}else this.data=_}y(An,be);function Rn(){je.call(this),this.status=1}y(Rn,je);function qe(_){this.g=_}y(qe,At),qe.prototype.ra=function(){Wt(this.g,"a")},qe.prototype.qa=function(_){Wt(this.g,new An(_))},qe.prototype.pa=function(_){Wt(this.g,new Rn)},qe.prototype.oa=function(){Wt(this.g,"b")},bn.prototype.createWebChannel=bn.prototype.g,Mt.prototype.send=Mt.prototype.o,Mt.prototype.open=Mt.prototype.m,Mt.prototype.close=Mt.prototype.close,x$=function(){return new bn},g$=function(){return fn()},m$=ze,Pk={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},yn.NO_ERROR=0,yn.TIMEOUT=8,yn.HTTP_ERROR=6,rw=yn,gt.COMPLETE="complete",p$=gt,Ui.EventType=$n,$n.OPEN="a",$n.CLOSE="b",$n.ERROR="c",$n.MESSAGE="d",Ze.prototype.listen=Ze.prototype.J,n1=Ui,zr.prototype.listenOnce=zr.prototype.K,zr.prototype.getLastError=zr.prototype.Ha,zr.prototype.getLastErrorCode=zr.prototype.ya,zr.prototype.getStatus=zr.prototype.ca,zr.prototype.getResponseJson=zr.prototype.La,zr.prototype.getResponseText=zr.prototype.la,zr.prototype.send=zr.prototype.ea,zr.prototype.setWithCredentials=zr.prototype.Fa,f$=zr}).apply(typeof uv<"u"?uv:typeof self<"u"?self:typeof window<"u"?window:{});/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class vo{constructor(t){this.uid=t}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(t){return t.uid===this.uid}}vo.UNAUTHENTICATED=new vo(null),vo.GOOGLE_CREDENTIALS=new vo("google-credentials-uid"),vo.FIRST_PARTY=new vo("first-party-uid"),vo.MOCK_USER=new vo("mock-user");/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */let kg="12.11.0";function Hle(e){kg=e}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *//** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Wp=new rj("@firebase/firestore");function x0(){return Wp.logLevel}function zt(e,...t){if(Wp.logLevel<=ri.DEBUG){const n=t.map(gj);Wp.debug(`Firestore (${kg}): ${e}`,...n)}}function ea(e,...t){if(Wp.logLevel<=ri.ERROR){const n=t.map(gj);Wp.error(`Firestore (${kg}): ${e}`,...n)}}function K0(e,...t){if(Wp.logLevel<=ri.WARN){const n=t.map(gj);Wp.warn(`Firestore (${kg}): ${e}`,...n)}}function gj(e){if(typeof e=="string")return e;try{return(function(n){return JSON.stringify(n)})(e)}catch{return e}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Cn(e,t,n){let r="Unexpected state";typeof t=="string"?r=t:n=t,y$(e,r,n)}function y$(e,t,n){let r=`FIRESTORE (${kg}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(n!==void 0)try{r+=" CONTEXT: "+JSON.stringify(n)}catch{r+=" CONTEXT: "+n}throw ea(r),new Error(r)}function Xn(e,t,n,r){let i="Unexpected state";typeof n=="string"?i=n:r=n,e||y$(t,i,r)}function zn(e,t){return e}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const bt={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 Jt extends Wd{constructor(t,n){super(t,n),this.code=t,this.message=n,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Uc{constructor(){this.promise=new Promise(((t,n)=>{this.resolve=t,this.reject=n}))}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Gle{constructor(t,n){this.user=n,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}}class qle{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,n){t.enqueueRetryable((()=>n(vo.UNAUTHENTICATED)))}shutdown(){}}class Wle{constructor(t){this.t=t,this.currentUser=vo.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,n){Xn(this.o===void 0,42304);let r=this.i;const i=h=>this.i!==r?(r=this.i,n(h)):Promise.resolve();let a=new Uc;this.o=()=>{this.i++,this.currentUser=this.u(),a.resolve(),a=new Uc,t.enqueueRetryable((()=>i(this.currentUser)))};const o=()=>{const h=a;t.enqueueRetryable((async()=>{await h.promise,await i(this.currentUser)}))},c=h=>{zt("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=h,this.o&&(this.auth.addAuthTokenListener(this.o),o())};this.t.onInit((h=>c(h))),setTimeout((()=>{if(!this.auth){const h=this.t.getImmediate({optional:!0});h?c(h):(zt("FirebaseAuthCredentialsProvider","Auth not yet detected"),a.resolve(),a=new Uc)}}),0),o()}getToken(){const t=this.i,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then((r=>this.i!==t?(zt("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(Xn(typeof r.accessToken=="string",31837,{l:r}),new Gle(r.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const t=this.auth&&this.auth.getUid();return Xn(t===null||typeof t=="string",2055,{h:t}),new vo(t)}}class Kle{constructor(t,n,r){this.P=t,this.T=n,this.I=r,this.type="FirstParty",this.user=vo.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set("X-Goog-AuthUser",this.P);const t=this.A();return t&&this.R.set("Authorization",t),this.T&&this.R.set("X-Goog-Iam-Authorization-Token",this.T),this.R}}class Yle{constructor(t,n,r){this.P=t,this.T=n,this.I=r}getToken(){return Promise.resolve(new Kle(this.P,this.T,this.I))}start(t,n){t.enqueueRetryable((()=>n(vo.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class CR{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class Xle{constructor(t,n){this.V=n,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,Pl(t)&&t.settings.appCheckToken&&(this.p=t.settings.appCheckToken)}start(t,n){Xn(this.o===void 0,3512);const r=a=>{a.error!=null&&zt("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${a.error.message}`);const o=a.token!==this.m;return this.m=a.token,zt("FirebaseAppCheckTokenProvider",`Received ${o?"new":"existing"} token.`),o?n(a.token):Promise.resolve()};this.o=a=>{t.enqueueRetryable((()=>r(a)))};const i=a=>{zt("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=a,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((a=>i(a))),setTimeout((()=>{if(!this.appCheck){const a=this.V.getImmediate({optional:!0});a?i(a):zt("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){if(this.p)return Promise.resolve(new CR(this.p));const t=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(t).then((n=>n?(Xn(typeof n.token=="string",44558,{tokenResult:n}),this.m=n.token,new CR(n.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Qle(e){const t=typeof self<"u"&&(self.crypto||self.msCrypto),n=new Uint8Array(e);if(t&&typeof t.getRandomValues=="function")t.getRandomValues(n);else for(let r=0;rt?1:0}function Rk(e,t){const n=Math.min(e.length,t.length);for(let r=0;r=Zle&&t<=Jle}function Y0(e,t,n){return e.length===t.length&&e.every(((r,i)=>n(r,t[i])))}function b$(e){return e+"\0"}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const IR="__name__";class pu{constructor(t,n,r){n===void 0?n=0:n>t.length&&Cn(637,{offset:n,range:t.length}),r===void 0?r=t.length-n:r>t.length-n&&Cn(1746,{length:r,range:t.length-n}),this.segments=t,this.offset=n,this.len=r}get length(){return this.len}isEqual(t){return pu.comparator(this,t)===0}child(t){const n=this.segments.slice(this.offset,this.limit());return t instanceof pu?t.forEach((r=>{n.push(r)})):n.push(t),this.construct(n)}limit(){return this.offset+this.length}popFirst(t){return t=t===void 0?1:t,this.construct(this.segments,this.offset+t,this.length-t)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(t){return this.segments[this.offset+t]}isEmpty(){return this.length===0}isPrefixOf(t){if(t.length=0)throw new Jt(bt.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);n.push(...r.split("/").filter((i=>i.length>0)))}return new Ei(n)}static emptyPath(){return new Ei([])}}const ece=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class Rs extends pu{construct(t,n,r){return new Rs(t,n,r)}static isValidIdentifier(t){return ece.test(t)}canonicalString(){return this.toArray().map((t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),Rs.isValidIdentifier(t)||(t="`"+t+"`"),t))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===IR}static keyField(){return new Rs([IR])}static fromServerFormat(t){const n=[];let r="",i=0;const a=()=>{if(r.length===0)throw new Jt(bt.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);n.push(r),r=""};let o=!1;for(;i=2&&this.path.get(this.path.length-2)===t}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(t){return t!==null&&Ei.comparator(this.path,t.path)===0}toString(){return this.path.toString()}static comparator(t,n){return Ei.comparator(t.path,n.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(t){return new hn(new Ei(t.slice()))}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function yj(e,t,n){if(!n)throw new Jt(bt.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function tce(e,t,n,r){if(t===!0&&r===!0)throw new Jt(bt.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function jR(e){if(!hn.isDocumentKey(e))throw new Jt(bt.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function TR(e){if(hn.isDocumentKey(e))throw new Jt(bt.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function v$(e){return typeof e=="object"&&e!==null&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)}function MN(e){if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="string")return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean")return""+e;if(typeof e=="object"){if(e instanceof Array)return"an array";{const t=(function(r){return r.constructor?r.constructor.name:null})(e);return t?`a custom ${t} object`:"an object"}}return typeof e=="function"?"a function":Cn(12329,{type:typeof e})}function qo(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new Jt(bt.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=MN(e);throw new Jt(bt.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function nce(e,t){if(t<=0)throw new Jt(bt.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}/** * @license * Copyright 2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function da(e,t){const n={typeString:e};return t&&(n.value=t),n}function _y(e,t){if(!v$(e))throw new Jt(bt.INVALID_ARGUMENT,"JSON must be an object");let n;for(const r in t)if(t[r]){const i=t[r].typeString,a="value"in t[r]?{value:t[r].value}:void 0;if(!(r in e)){n=`JSON missing required field: '${r}'`;break}const o=e[r];if(i&&typeof o!==i){n=`JSON field '${r}' must be a ${i}.`;break}if(a!==void 0&&o!==a.value){n=`Expected '${r}' field to equal '${a.value}'`;break}}if(n)throw new Jt(bt.INVALID_ARGUMENT,n);return!0}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const OR=-62135596800,PR=1e6;class jr{static now(){return jr.fromMillis(Date.now())}static fromDate(t){return jr.fromMillis(t.getTime())}static fromMillis(t){const n=Math.floor(t/1e3),r=Math.floor((t-1e3*n)*PR);return new jr(n,r)}constructor(t,n){if(this.seconds=t,this.nanoseconds=n,n<0)throw new Jt(bt.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(n>=1e9)throw new Jt(bt.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(t=253402300800)throw new Jt(bt.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/PR}_compareTo(t){return this.seconds===t.seconds?Er(this.nanoseconds,t.nanoseconds):Er(this.seconds,t.seconds)}isEqual(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:jr._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(t){if(_y(t,jr._jsonSchema))return new jr(t.seconds,t.nanoseconds)}valueOf(){const t=this.seconds-OR;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}jr._jsonSchemaVersion="firestore/timestamp/1.0",jr._jsonSchema={type:da("string",jr._jsonSchemaVersion),seconds:da("number"),nanoseconds:da("number")};/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class rr{static fromTimestamp(t){return new rr(t)}static min(){return new rr(new jr(0,0))}static max(){return new rr(new jr(253402300799,999999999))}constructor(t){this.timestamp=t}compareTo(t){return this.timestamp._compareTo(t.timestamp)}isEqual(t){return this.timestamp.isEqual(t.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const X0=-1;class $w{constructor(t,n,r,i){this.indexId=t,this.collectionGroup=n,this.fields=r,this.indexState=i}}function Dk(e){return e.fields.find((t=>t.kind===2))}function sp(e){return e.fields.filter((t=>t.kind!==2))}$w.UNKNOWN_ID=-1;class iw{constructor(t,n){this.fieldPath=t,this.kind=n}}class z1{constructor(t,n){this.sequenceNumber=t,this.offset=n}static empty(){return new z1(0,$l.min())}}function w$(e,t){const n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1,i=rr.fromTimestamp(r===1e9?new jr(n+1,0):new jr(n,r));return new $l(i,hn.empty(),t)}function N$(e){return new $l(e.readTime,e.key,X0)}class $l{constructor(t,n,r){this.readTime=t,this.documentKey=n,this.largestBatchId=r}static min(){return new $l(rr.min(),hn.empty(),X0)}static max(){return new $l(rr.max(),hn.empty(),X0)}}function bj(e,t){let n=e.readTime.compareTo(t.readTime);return n!==0?n:(n=hn.comparator(e.documentKey,t.documentKey),n!==0?n:Er(e.largestBatchId,t.largestBatchId))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const E$="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class A${constructor(){this.onCommittedListeners=[]}addOnCommittedListener(t){this.onCommittedListeners.push(t)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((t=>t()))}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */async function Nf(e){if(e.code!==bt.FAILED_PRECONDITION||e.message!==E$)throw e;zt("LocalStore","Unexpectedly lost primary lease")}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Qe{constructor(t){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t((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(t){return this.next(void 0,t)}next(t,n){return this.callbackAttached&&Cn(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(t,this.result):new Qe(((r,i)=>{this.nextCallback=a=>{this.wrapSuccess(t,a).next(r,i)},this.catchCallback=a=>{this.wrapFailure(n,a).next(r,i)}}))}toPromise(){return new Promise(((t,n)=>{this.next(t,n)}))}wrapUserFunction(t){try{const n=t();return n instanceof Qe?n:Qe.resolve(n)}catch(n){return Qe.reject(n)}}wrapSuccess(t,n){return t?this.wrapUserFunction((()=>t(n))):Qe.resolve(n)}wrapFailure(t,n){return t?this.wrapUserFunction((()=>t(n))):Qe.reject(n)}static resolve(t){return new Qe(((n,r)=>{n(t)}))}static reject(t){return new Qe(((n,r)=>{r(t)}))}static waitFor(t){return new Qe(((n,r)=>{let i=0,a=0,o=!1;t.forEach((c=>{++i,c.next((()=>{++a,o&&a===i&&n()}),(h=>r(h)))})),o=!0,a===i&&n()}))}static or(t){let n=Qe.resolve(!1);for(const r of t)n=n.next((i=>i?Qe.resolve(i):r()));return n}static forEach(t,n){const r=[];return t.forEach(((i,a)=>{r.push(n.call(this,i,a))})),this.waitFor(r)}static mapArray(t,n){return new Qe(((r,i)=>{const a=t.length,o=new Array(a);let c=0;for(let h=0;h{o[f]=m,++c,c===a&&r(o)}),(m=>i(m)))}}))}static doWhile(t,n){return new Qe(((r,i)=>{const a=()=>{t()===!0?n().next((()=>{a()}),i):r()};a()}))}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Ol="SimpleDb";class LN{static open(t,n,r,i){try{return new LN(n,t.transaction(i,r))}catch(a){throw new m1(n,a)}}constructor(t,n){this.action=t,this.transaction=n,this.aborted=!1,this.S=new Uc,this.transaction.oncomplete=()=>{this.S.resolve()},this.transaction.onabort=()=>{n.error?this.S.reject(new m1(t,n.error)):this.S.resolve()},this.transaction.onerror=r=>{const i=vj(r.target.error);this.S.reject(new m1(t,i))}}get D(){return this.S.promise}abort(t){t&&this.S.reject(t),this.aborted||(zt(Ol,"Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}C(){const t=this.transaction;this.aborted||typeof t.commit!="function"||t.commit()}store(t){const n=this.transaction.objectStore(t);return new ice(n)}}class af{static delete(t){return zt(Ol,"Removing database:",t),hp(yF().indexedDB.deleteDatabase(t)).toPromise()}static v(){if(!AF())return!1;if(af.F())return!0;const t=ka(),n=af.M(t),r=00||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||r||a)}static F(){var t;return typeof process<"u"&&((t=process.__PRIVATE_env)==null?void 0:t.__PRIVATE_USE_MOCK_PERSISTENCE)==="YES"}static O(t,n){return t.store(n)}static M(t){const n=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),r=n?n[1].split("_").slice(0,2).join("."):"-1";return Number(r)}constructor(t,n,r){this.name=t,this.version=n,this.N=r,this.B=null,af.M(ka())===12.2&&ea("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}async L(t){return this.db||(zt(Ol,"Opening database:",this.name),this.db=await new Promise(((n,r)=>{const i=indexedDB.open(this.name,this.version);i.onsuccess=a=>{const o=a.target.result;n(o)},i.onblocked=()=>{r(new m1(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=a=>{const o=a.target.error;o.name==="VersionError"?r(new Jt(bt.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):o.name==="InvalidStateError"?r(new Jt(bt.FAILED_PRECONDITION,"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: "+o)):r(new m1(t,o))},i.onupgradeneeded=a=>{zt(Ol,'Database "'+this.name+'" requires upgrade from version:',a.oldVersion);const o=a.target.result;this.N.k(o,i.transaction,a.oldVersion,this.version).next((()=>{zt(Ol,"Database upgrade to version "+this.version+" complete")}))}}))),this.q&&(this.db.onversionchange=n=>this.q(n)),this.db}K(t){this.q=t,this.db&&(this.db.onversionchange=n=>t(n))}async runTransaction(t,n,r,i){const a=n==="readonly";let o=0;for(;;){++o;try{this.db=await this.L(t);const c=LN.open(this.db,t,a?"readonly":"readwrite",r),h=i(c).next((f=>(c.C(),f))).catch((f=>(c.abort(f),Qe.reject(f)))).toPromise();return h.catch((()=>{})),await c.D,h}catch(c){const h=c,f=h.name!=="FirebaseError"&&o<3;if(zt(Ol,"Transaction failed with error:",h.message,"Retrying:",f),this.close(),!f)return Promise.reject(h)}}}close(){this.db&&this.db.close(),this.db=void 0}}function _$(e){const t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(n)}class rce{constructor(t){this.U=t,this.$=!1,this.W=null}get isDone(){return this.$}get G(){return this.W}set cursor(t){this.U=t}done(){this.$=!0}j(t){this.W=t}delete(){return hp(this.U.delete())}}class m1 extends Jt{constructor(t,n){super(bt.UNAVAILABLE,`IndexedDB transaction '${t}' failed: ${n}`),this.name="IndexedDbTransactionError"}}function Ef(e){return e.name==="IndexedDbTransactionError"}class ice{constructor(t){this.store=t}put(t,n){let r;return n!==void 0?(zt(Ol,"PUT",this.store.name,t,n),r=this.store.put(n,t)):(zt(Ol,"PUT",this.store.name,"",t),r=this.store.put(t)),hp(r)}add(t){return zt(Ol,"ADD",this.store.name,t,t),hp(this.store.add(t))}get(t){return hp(this.store.get(t)).next((n=>(n===void 0&&(n=null),zt(Ol,"GET",this.store.name,t,n),n)))}delete(t){return zt(Ol,"DELETE",this.store.name,t),hp(this.store.delete(t))}count(){return zt(Ol,"COUNT",this.store.name),hp(this.store.count())}J(t,n){const r=this.options(t,n),i=r.index?this.store.index(r.index):this.store;if(typeof i.getAll=="function"){const a=i.getAll(r.range);return new Qe(((o,c)=>{a.onerror=h=>{c(h.target.error)},a.onsuccess=h=>{o(h.target.result)}}))}{const a=this.cursor(r),o=[];return this.H(a,((c,h)=>{o.push(h)})).next((()=>o))}}Z(t,n){const r=this.store.getAll(t,n===null?void 0:n);return new Qe(((i,a)=>{r.onerror=o=>{a(o.target.error)},r.onsuccess=o=>{i(o.target.result)}}))}X(t,n){zt(Ol,"DELETE ALL",this.store.name);const r=this.options(t,n);r.Y=!1;const i=this.cursor(r);return this.H(i,((a,o,c)=>c.delete()))}ee(t,n){let r;n?r=t:(r={},n=t);const i=this.cursor(r);return this.H(i,n)}te(t){const n=this.cursor({});return new Qe(((r,i)=>{n.onerror=a=>{const o=vj(a.target.error);i(o)},n.onsuccess=a=>{const o=a.target.result;o?t(o.primaryKey,o.value).next((c=>{c?o.continue():r()})):r()}}))}H(t,n){const r=[];return new Qe(((i,a)=>{t.onerror=o=>{a(o.target.error)},t.onsuccess=o=>{const c=o.target.result;if(!c)return void i();const h=new rce(c),f=n(c.primaryKey,c.value,h);if(f instanceof Qe){const m=f.catch((y=>(h.done(),Qe.reject(y))));r.push(m)}h.isDone?i():h.G===null?c.continue():c.continue(h.G)}})).next((()=>Qe.waitFor(r)))}options(t,n){let r;return t!==void 0&&(typeof t=="string"?r=t:n=t),{index:r,range:n}}cursor(t){let n="next";if(t.reverse&&(n="prev"),t.index){const r=this.store.index(t.index);return t.Y?r.openKeyCursor(t.range,n):r.openCursor(t.range,n)}return this.store.openCursor(t.range,n)}}function hp(e){return new Qe(((t,n)=>{e.onsuccess=r=>{const i=r.target.result;t(i)},e.onerror=r=>{const i=vj(r.target.error);n(i)}}))}let RR=!1;function vj(e){const t=af.M(ka());if(t>=12.2&&t<13){const n="An internal error was encountered in the Indexed Database server";if(e.message.indexOf(n)>=0){const r=new Jt("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${n}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return RR||(RR=!0,setTimeout((()=>{throw r}),0)),r}}return e}const g1="IndexBackfiller";class sce{constructor(t,n){this.asyncQueue=t,this.ne=n,this.task=null}start(){this.re(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return this.task!==null}re(t){zt(g1,`Scheduled in ${t}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",t,(async()=>{this.task=null;try{const n=await this.ne.ie();zt(g1,`Documents written: ${n}`)}catch(n){Ef(n)?zt(g1,"Ignoring IndexedDB error during index backfill: ",n):await Nf(n)}await this.re(6e4)}))}}class ace{constructor(t,n){this.localStore=t,this.persistence=n}async ie(t=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",(n=>this.se(n,t)))}se(t,n){const r=new Set;let i=n,a=!0;return Qe.doWhile((()=>a===!0&&i>0),(()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(t).next((o=>{if(o!==null&&!r.has(o))return zt(g1,`Processing collection: ${o}`),this.oe(t,o,i).next((c=>{i-=c,r.add(o)}));a=!1})))).next((()=>n-i))}oe(t,n,r){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(t,n).next((i=>this.localStore.localDocuments.getNextDocuments(t,n,i,r).next((a=>{const o=a.changes;return this.localStore.indexManager.updateIndexEntries(t,o).next((()=>this._e(i,a))).next((c=>(zt(g1,`Updating offset: ${c}`),this.localStore.indexManager.updateCollectionGroup(t,n,c)))).next((()=>o.size))}))))}_e(t,n){let r=t;return n.changes.forEach(((i,a)=>{const o=N$(a);bj(o,r)>0&&(r=o)})),new $l(r.readTime,r.documentKey,Math.max(n.batchId,t.largestBatchId))}}/** * @license * Copyright 2018 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class ml{constructor(t,n){this.previousValue=t,n&&(n.sequenceNumberHandler=r=>this.ae(r),this.ue=r=>n.writeSequenceNumber(r))}ae(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){const t=++this.previousValue;return this.ue&&this.ue(t),t}}ml.ce=-1;/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const jp=-1;function UN(e){return e==null}function V1(e){return e===0&&1/e==-1/0}function S$(e){return typeof e=="number"&&Number.isInteger(e)&&!V1(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Hw="";function So(e){let t="";for(let n=0;n0&&(t=DR(t)),t=oce(e.get(n),t);return DR(t)}function oce(e,t){let n=t;const r=e.length;for(let i=0;i=2,64408,{path:e}),t===2)return Xn(e.charAt(0)===Hw&&e.charAt(1)==="",56145,{path:e}),Ei.emptyPath();const n=t-2,r=[];let i="";for(let a=0;an)&&Cn(50515,{path:e}),e.charAt(o+1)){case"":const c=e.substring(a,o);let h;i.length===0?h=c:(i+=c,h=i,i=""),r.push(h);break;case"":i+=e.substring(a,o),i+="\0";break;case"":i+=e.substring(a,o+1);break;default:Cn(61167,{path:e})}a=o+2}return new Ei(r)}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const ap="remoteDocuments",Sy="owner",t0="owner",F1="mutationQueues",lce="userId",Oc="mutations",MR="batchId",vp="userMutationsIndex",LR=["userId","batchId"];/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function sw(e,t){return[e,So(t)]}function k$(e,t,n){return[e,So(t),n]}const cce={},Q0="documentMutations",Gw="remoteDocumentsV14",uce=["prefixPath","collectionGroup","readTime","documentId"],aw="documentKeyIndex",dce=["prefixPath","collectionGroup","documentId"],C$="collectionGroupIndex",hce=["collectionGroup","readTime","prefixPath","documentId"],$1="remoteDocumentGlobal",Mk="remoteDocumentGlobalKey",Z0="targets",I$="queryTargetsIndex",fce=["canonicalId","targetId"],J0="targetDocuments",pce=["targetId","path"],wj="documentTargetsIndex",mce=["path","targetId"],qw="targetGlobalKey",Tp="targetGlobal",H1="collectionParents",gce=["collectionId","parent"],eg="clientMetadata",xce="clientId",BN="bundles",yce="bundleId",zN="namedQueries",bce="name",Nj="indexConfiguration",vce="indexId",Lk="collectionGroupIndex",wce="collectionGroup",x1="indexState",Nce=["indexId","uid"],j$="sequenceNumberIndex",Ece=["uid","sequenceNumber"],y1="indexEntries",Ace=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],T$="documentKeyIndex",_ce=["indexId","uid","orderedDocumentKey"],VN="documentOverlays",Sce=["userId","collectionPath","documentId"],Uk="collectionPathOverlayIndex",kce=["userId","collectionPath","largestBatchId"],O$="collectionGroupOverlayIndex",Cce=["userId","collectionGroup","largestBatchId"],Ej="globals",Ice="name",P$=[F1,Oc,Q0,ap,Z0,Sy,Tp,J0,eg,$1,H1,BN,zN],jce=[...P$,VN],R$=[F1,Oc,Q0,Gw,Z0,Sy,Tp,J0,eg,$1,H1,BN,zN,VN],D$=R$,Aj=[...D$,Nj,x1,y1],Tce=Aj,M$=[...Aj,Ej],Oce=M$;/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Bk extends A${constructor(t,n){super(),this.le=t,this.currentSequenceNumber=n}}function Ia(e,t){const n=zn(e);return af.O(n.le,t)}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function UR(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function Af(e,t){for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function Pce(e,t){const n=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.push(t(e[r],r,e));return n}function L$(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class ds{constructor(t,n){this.comparator=t,this.root=n||ro.EMPTY}insert(t,n){return new ds(this.comparator,this.root.insert(t,n,this.comparator).copy(null,null,ro.BLACK,null,null))}remove(t){return new ds(this.comparator,this.root.remove(t,this.comparator).copy(null,null,ro.BLACK,null,null))}get(t){let n=this.root;for(;!n.isEmpty();){const r=this.comparator(t,n.key);if(r===0)return n.value;r<0?n=n.left:r>0&&(n=n.right)}return null}indexOf(t){let n=0,r=this.root;for(;!r.isEmpty();){const i=this.comparator(t,r.key);if(i===0)return n+r.left.size;i<0?r=r.left:(n+=r.left.size+1,r=r.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(t){return this.root.inorderTraversal(t)}forEach(t){this.inorderTraversal(((n,r)=>(t(n,r),!1)))}toString(){const t=[];return this.inorderTraversal(((n,r)=>(t.push(`${n}:${r}`),!1))),`{${t.join(", ")}}`}reverseTraversal(t){return this.root.reverseTraversal(t)}getIterator(){return new dv(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new dv(this.root,t,this.comparator,!1)}getReverseIterator(){return new dv(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new dv(this.root,t,this.comparator,!0)}}class dv{constructor(t,n,r,i){this.isReverse=i,this.nodeStack=[];let a=1;for(;!t.isEmpty();)if(a=n?r(t.key,n):1,n&&i&&(a*=-1),a<0)t=this.isReverse?t.left:t.right;else{if(a===0){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}getNext(){let t=this.nodeStack.pop();const n={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return n}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}}}class ro{constructor(t,n,r,i,a){this.key=t,this.value=n,this.color=r??ro.RED,this.left=i??ro.EMPTY,this.right=a??ro.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,n,r,i,a){return new ro(t??this.key,n??this.value,r??this.color,i??this.left,a??this.right)}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(t,n,r){let i=this;const a=r(t,i.key);return i=a<0?i.copy(null,null,null,i.left.insert(t,n,r),null):a===0?i.copy(null,n,null,null,null):i.copy(null,null,null,null,i.right.insert(t,n,r)),i.fixUp()}removeMin(){if(this.left.isEmpty())return ro.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,n){let r,i=this;if(n(t,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(t,n),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),n(t,i.key)===0){if(i.right.isEmpty())return ro.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(t,n))}return i.fixUp()}isRed(){return this.color}fixUp(){let t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t}moveRedLeft(){let t=this.colorFlip();return t.right.left.isRed()&&(t=t.copy(null,null,null,null,t.right.rotateRight()),t=t.rotateLeft(),t=t.colorFlip()),t}moveRedRight(){let t=this.colorFlip();return t.left.left.isRed()&&(t=t.rotateRight(),t=t.colorFlip()),t}rotateLeft(){const t=this.copy(null,null,ro.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){const t=this.copy(null,null,ro.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){const t=this.left.copy(null,null,!this.left.color,null,null),n=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,n)}checkMaxDepth(){const t=this.check();return Math.pow(2,t)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw Cn(43730,{key:this.key,value:this.value});if(this.right.isRed())throw Cn(14113,{key:this.key,value:this.value});const t=this.left.check();if(t!==this.right.check())throw Cn(27949);return t+(this.isRed()?0:1)}}ro.EMPTY=null,ro.RED=!0,ro.BLACK=!1;ro.EMPTY=new class{constructor(){this.size=0}get key(){throw Cn(57766)}get value(){throw Cn(16141)}get color(){throw Cn(16727)}get left(){throw Cn(29726)}get right(){throw Cn(36894)}copy(t,n,r,i,a){return this}insert(t,n,r){return new ro(t,n)}remove(t,n){return this}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class $i{constructor(t){this.comparator=t,this.data=new ds(this.comparator)}has(t){return this.data.get(t)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal(((n,r)=>(t(n),!1)))}forEachInRange(t,n){const r=this.data.getIteratorFrom(t[0]);for(;r.hasNext();){const i=r.getNext();if(this.comparator(i.key,t[1])>=0)return;n(i.key)}}forEachWhile(t,n){let r;for(r=n!==void 0?this.data.getIteratorFrom(n):this.data.getIterator();r.hasNext();)if(!t(r.getNext().key))return}firstAfterOrEqual(t){const n=this.data.getIteratorFrom(t);return n.hasNext()?n.getNext().key:null}getIterator(){return new BR(this.data.getIterator())}getIteratorFrom(t){return new BR(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let n=this;return n.size{n=n.add(r)})),n}isEqual(t){if(!(t instanceof $i)||this.size!==t.size)return!1;const n=this.data.getIterator(),r=t.data.getIterator();for(;n.hasNext();){const i=n.getNext().key,a=r.getNext().key;if(this.comparator(i,a)!==0)return!1}return!0}toArray(){const t=[];return this.forEach((n=>{t.push(n)})),t}toString(){const t=[];return this.forEach((n=>t.push(n))),"SortedSet("+t.toString()+")"}copy(t){const n=new $i(this.comparator);return n.data=t,n}}class BR{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function n0(e){return e.hasNext()?e.getNext():void 0}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class gl{constructor(t){this.fields=t,t.sort(Rs.comparator)}static empty(){return new gl([])}unionWith(t){let n=new $i(Rs.comparator);for(const r of this.fields)n=n.add(r);for(const r of t)n=n.add(r);return new gl(n.toArray())}covers(t){for(const n of this.fields)if(n.isPrefixOf(t))return!0;return!1}isEqual(t){return Y0(this.fields,t.fields,((n,r)=>n.isEqual(r)))}}/** * @license * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class U$ extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class ta{constructor(t){this.binaryString=t}static fromBase64String(t){const n=(function(i){try{return atob(i)}catch(a){throw typeof DOMException<"u"&&a instanceof DOMException?new U$("Invalid base64 string: "+a):a}})(t);return new ta(n)}static fromUint8Array(t){const n=(function(i){let a="";for(let o=0;otRu(n,t)))!==void 0}function ff(e,t){if(e===t)return 0;const n=hf(e),r=hf(t);if(n!==r)return Er(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return Er(e.booleanValue,t.booleanValue);case 2:return(function(a,o){const c=_s(a.integerValue||a.doubleValue),h=_s(o.integerValue||o.doubleValue);return ch?1:c===h?0:isNaN(c)?isNaN(h)?0:-1:1})(e,t);case 3:return zR(e.timestampValue,t.timestampValue);case 4:return zR(G1(e),G1(t));case 5:return Rk(e.stringValue,t.stringValue);case 6:return(function(a,o){const c=Vd(a),h=Vd(o);return c.compareTo(h)})(e.bytesValue,t.bytesValue);case 7:return(function(a,o){const c=a.split("/"),h=o.split("/");for(let f=0;fi+lw(a)),0)})(e.arrayValue);case 10:case 11:return(function(r){let i=0;return Af(r.fields,((a,o)=>{i+=a.length+lw(o)})),i})(e.mapValue);default:throw Cn(13486,{value:e})}}function W1(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function Fk(e){return!!e&&"integerValue"in e}function K1(e){return!!e&&"arrayValue"in e}function FR(e){return!!e&&"nullValue"in e}function $R(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function cw(e){return!!e&&"mapValue"in e}function $N(e){var n,r;return((r=(((n=e==null?void 0:e.mapValue)==null?void 0:n.fields)||{})[Sj])==null?void 0:r.stringValue)===kj}function b1(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&typeof e.timestampValue=="object")return{timestampValue:{...e.timestampValue}};if(e.mapValue){const t={mapValue:{fields:{}}};return Af(e.mapValue.fields,((n,r)=>t.mapValue.fields[n]=b1(r))),t}if(e.arrayValue){const t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=b1(e.arrayValue.values[n]);return t}return{...e}}function H$(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===$$}const G$={mapValue:{fields:{[Sj]:{stringValue:kj},[tg]:{arrayValue:{}}}}};function Lce(e){return"nullValue"in e?ow:"booleanValue"in e?{booleanValue:!1}:"integerValue"in e||"doubleValue"in e?{doubleValue:NaN}:"timestampValue"in e?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in e?{stringValue:""}:"bytesValue"in e?{bytesValue:""}:"referenceValue"in e?W1(Kp.empty(),hn.empty()):"geoPointValue"in e?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in e?{arrayValue:{}}:"mapValue"in e?$N(e)?G$:{mapValue:{}}:Cn(35942,{value:e})}function Uce(e){return"nullValue"in e?{booleanValue:!1}:"booleanValue"in e?{doubleValue:NaN}:"integerValue"in e||"doubleValue"in e?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in e?{stringValue:""}:"stringValue"in e?{bytesValue:""}:"bytesValue"in e?W1(Kp.empty(),hn.empty()):"referenceValue"in e?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in e?{arrayValue:{}}:"arrayValue"in e?G$:"mapValue"in e?$N(e)?{mapValue:{}}:Zh:Cn(61959,{value:e})}function HR(e,t){const n=ff(e.value,t.value);return n!==0?n:e.inclusive&&!t.inclusive?-1:!e.inclusive&&t.inclusive?1:0}function GR(e,t){const n=ff(e.value,t.value);return n!==0?n:e.inclusive&&!t.inclusive?1:!e.inclusive&&t.inclusive?-1:0}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class io{constructor(t){this.value=t}static empty(){return new io({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let n=this.value;for(let r=0;r{if(!n.isImmediateParentOf(c)){const h=this.getFieldsMap(n);this.applyChanges(h,r,i),r={},i=[],n=c.popLast()}o?r[c.lastSegment()]=b1(o):i.push(c.lastSegment())}));const a=this.getFieldsMap(n);this.applyChanges(a,r,i)}delete(t){const n=this.field(t.popLast());cw(n)&&n.mapValue.fields&&delete n.mapValue.fields[t.lastSegment()]}isEqual(t){return Ru(this.value,t.value)}getFieldsMap(t){let n=this.value;n.mapValue.fields||(n.mapValue={fields:{}});for(let r=0;rt[i]=a));for(const i of r)delete t[i]}clone(){return new io(b1(this.value))}}function q$(e){const t=[];return Af(e.fields,((n,r)=>{const i=new Rs([n]);if(cw(r)){const a=q$(r.mapValue).fields;if(a.length===0)t.push(i);else for(const o of a)t.push(i.child(o))}else t.push(i)})),new gl(t)}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class qs{constructor(t,n,r,i,a,o,c){this.key=t,this.documentType=n,this.version=r,this.readTime=i,this.createTime=a,this.data=o,this.documentState=c}static newInvalidDocument(t){return new qs(t,0,rr.min(),rr.min(),rr.min(),io.empty(),0)}static newFoundDocument(t,n,r,i){return new qs(t,1,n,rr.min(),r,i,0)}static newNoDocument(t,n){return new qs(t,2,n,rr.min(),rr.min(),io.empty(),0)}static newUnknownDocument(t,n){return new qs(t,3,n,rr.min(),rr.min(),io.empty(),2)}convertToFoundDocument(t,n){return!this.createTime.isEqual(rr.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=t),this.version=t,this.documentType=1,this.data=n,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=io.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=io.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=rr.min(),this}setReadTime(t){return this.readTime=t,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(t){return t instanceof qs&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new qs(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class rg{constructor(t,n){this.position=t,this.inclusive=n}}function qR(e,t,n){let r=0;for(let i=0;i":return t>0;case">=":return t>=0;default:return Cn(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class Fi extends W${constructor(t,n){super(),this.filters=t,this.op=n,this.Pe=null}static create(t,n){return new Fi(t,n)}matches(t){return ig(this)?this.filters.find((n=>!n.matches(t)))===void 0:this.filters.find((n=>n.matches(t)))!==void 0}getFlattenedFilters(){return this.Pe!==null||(this.Pe=this.filters.reduce(((t,n)=>t.concat(n.getFlattenedFilters())),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function ig(e){return e.op==="and"}function $k(e){return e.op==="or"}function Cj(e){return K$(e)&&ig(e)}function K$(e){for(const t of e.filters)if(t instanceof Fi)return!1;return!0}function Hk(e){if(e instanceof ii)return e.field.canonicalString()+e.op.toString()+ng(e.value);if(Cj(e))return e.filters.map((t=>Hk(t))).join(",");{const t=e.filters.map((n=>Hk(n))).join(",");return`${e.op}(${t})`}}function Y$(e,t){return e instanceof ii?(function(r,i){return i instanceof ii&&r.op===i.op&&r.field.isEqual(i.field)&&Ru(r.value,i.value)})(e,t):e instanceof Fi?(function(r,i){return i instanceof Fi&&r.op===i.op&&r.filters.length===i.filters.length?r.filters.reduce(((a,o,c)=>a&&Y$(o,i.filters[c])),!0):!1})(e,t):void Cn(19439)}function X$(e,t){const n=e.filters.concat(t);return Fi.create(n,e.op)}function Q$(e){return e instanceof ii?(function(n){return`${n.field.canonicalString()} ${n.op} ${ng(n.value)}`})(e):e instanceof Fi?(function(n){return n.op.toString()+" {"+n.getFilters().map(Q$).join(" ,")+"}"})(e):"Filter"}class zce extends ii{constructor(t,n,r){super(t,n,r),this.key=hn.fromName(r.referenceValue)}matches(t){const n=hn.comparator(t.key,this.key);return this.matchesComparison(n)}}class Vce extends ii{constructor(t,n){super(t,"in",n),this.keys=Z$("in",n)}matches(t){return this.keys.some((n=>n.isEqual(t.key)))}}class Fce extends ii{constructor(t,n){super(t,"not-in",n),this.keys=Z$("not-in",n)}matches(t){return!this.keys.some((n=>n.isEqual(t.key)))}}function Z$(e,t){var n;return(((n=t.arrayValue)==null?void 0:n.values)||[]).map((r=>hn.fromName(r.referenceValue)))}class $ce extends ii{constructor(t,n){super(t,"array-contains",n)}matches(t){const n=t.data.field(this.field);return K1(n)&&q1(n.arrayValue,this.value)}}class J$ extends ii{constructor(t,n){super(t,"in",n)}matches(t){const n=t.data.field(this.field);return n!==null&&q1(this.value.arrayValue,n)}}class Hce extends ii{constructor(t,n){super(t,"not-in",n)}matches(t){if(q1(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const n=t.data.field(this.field);return n!==null&&n.nullValue===void 0&&!q1(this.value.arrayValue,n)}}class Gce extends ii{constructor(t,n){super(t,"array-contains-any",n)}matches(t){const n=t.data.field(this.field);return!(!K1(n)||!n.arrayValue.values)&&n.arrayValue.values.some((r=>q1(this.value.arrayValue,r)))}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class qce{constructor(t,n=null,r=[],i=[],a=null,o=null,c=null){this.path=t,this.collectionGroup=n,this.orderBy=r,this.filters=i,this.limit=a,this.startAt=o,this.endAt=c,this.Te=null}}function Gk(e,t=null,n=[],r=[],i=null,a=null,o=null){return new qce(e,t,n,r,i,a,o)}function Yp(e){const t=zn(e);if(t.Te===null){let n=t.path.canonicalString();t.collectionGroup!==null&&(n+="|cg:"+t.collectionGroup),n+="|f:",n+=t.filters.map((r=>Hk(r))).join(","),n+="|ob:",n+=t.orderBy.map((r=>(function(a){return a.field.canonicalString()+a.dir})(r))).join(","),UN(t.limit)||(n+="|l:",n+=t.limit),t.startAt&&(n+="|lb:",n+=t.startAt.inclusive?"b:":"a:",n+=t.startAt.position.map((r=>ng(r))).join(",")),t.endAt&&(n+="|ub:",n+=t.endAt.inclusive?"a:":"b:",n+=t.endAt.position.map((r=>ng(r))).join(",")),t.Te=n}return t.Te}function ky(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(let n=0;nn instanceof ii&&n.field.isEqual(t)))}function KR(e,t,n){let r=ow,i=!0;for(const a of Kw(e,t)){let o=ow,c=!0;switch(a.op){case"<":case"<=":o=Lce(a.value);break;case"==":case"in":case">=":o=a.value;break;case">":o=a.value,c=!1;break;case"!=":case"not-in":o=ow}HR({value:r,inclusive:i},{value:o,inclusive:c})<0&&(r=o,i=c)}if(n!==null){for(let a=0;a=":case">":o=Uce(a.value),c=!1;break;case"==":case"in":case"<=":o=a.value;break;case"<":o=a.value,c=!1;break;case"!=":case"not-in":o=Zh}GR({value:r,inclusive:i},{value:o,inclusive:c})>0&&(r=o,i=c)}if(n!==null){for(let a=0;a0&&(r=o,i=n.inclusive);break}}return{value:r,inclusive:i}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class hm{constructor(t,n=null,r=[],i=[],a=null,o="F",c=null,h=null){this.path=t,this.collectionGroup=n,this.explicitOrderBy=r,this.filters=i,this.limit=a,this.limitType=o,this.startAt=c,this.endAt=h,this.Ee=null,this.Ie=null,this.Re=null,this.startAt,this.endAt}}function eH(e,t,n,r,i,a,o,c){return new hm(e,t,n,r,i,a,o,c)}function Cy(e){return new hm(e)}function XR(e){return e.filters.length===0&&e.limit===null&&e.startAt==null&&e.endAt==null&&(e.explicitOrderBy.length===0||e.explicitOrderBy.length===1&&e.explicitOrderBy[0].field.isKeyField())}function Wce(e){return hn.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}function tH(e){return e.collectionGroup!==null}function v1(e){const t=zn(e);if(t.Ee===null){t.Ee=[];const n=new Set;for(const a of t.explicitOrderBy)t.Ee.push(a),n.add(a.field.canonicalString());const r=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";(function(o){let c=new $i(Rs.comparator);return o.filters.forEach((h=>{h.getFlattenedFilters().forEach((f=>{f.isInequality()&&(c=c.add(f.field))}))})),c})(t).forEach((a=>{n.has(a.canonicalString())||a.isKeyField()||t.Ee.push(new Y1(a,r))})),n.has(Rs.keyField().canonicalString())||t.Ee.push(new Y1(Rs.keyField(),r))}return t.Ee}function zl(e){const t=zn(e);return t.Ie||(t.Ie=nH(t,v1(e))),t.Ie}function Kce(e){const t=zn(e);return t.Re||(t.Re=nH(t,e.explicitOrderBy)),t.Re}function nH(e,t){if(e.limitType==="F")return Gk(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map((i=>{const a=i.dir==="desc"?"asc":"desc";return new Y1(i.field,a)}));const n=e.endAt?new rg(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new rg(e.startAt.position,e.startAt.inclusive):null;return Gk(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function qk(e,t){const n=e.filters.concat([t]);return new hm(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function Yce(e,t){const n=e.explicitOrderBy.concat([t]);return new hm(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}function Yw(e,t,n){return new hm(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function HN(e,t){return ky(zl(e),zl(t))&&e.limitType===t.limitType}function rH(e){return`${Yp(zl(e))}|lt:${e.limitType}`}function y0(e){return`Query(target=${(function(n){let r=n.path.canonicalString();return n.collectionGroup!==null&&(r+=" collectionGroup="+n.collectionGroup),n.filters.length>0&&(r+=`, filters: [${n.filters.map((i=>Q$(i))).join(", ")}]`),UN(n.limit)||(r+=", limit: "+n.limit),n.orderBy.length>0&&(r+=`, orderBy: [${n.orderBy.map((i=>(function(o){return`${o.field.canonicalString()} (${o.dir})`})(i))).join(", ")}]`),n.startAt&&(r+=", startAt: ",r+=n.startAt.inclusive?"b:":"a:",r+=n.startAt.position.map((i=>ng(i))).join(",")),n.endAt&&(r+=", endAt: ",r+=n.endAt.inclusive?"a:":"b:",r+=n.endAt.position.map((i=>ng(i))).join(",")),`Target(${r})`})(zl(e))}; limitType=${e.limitType})`}function Iy(e,t){return t.isFoundDocument()&&(function(r,i){const a=i.key.path;return r.collectionGroup!==null?i.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(a):hn.isDocumentKey(r.path)?r.path.isEqual(a):r.path.isImmediateParentOf(a)})(e,t)&&(function(r,i){for(const a of v1(r))if(!a.field.isKeyField()&&i.data.field(a.field)===null)return!1;return!0})(e,t)&&(function(r,i){for(const a of r.filters)if(!a.matches(i))return!1;return!0})(e,t)&&(function(r,i){return!(r.startAt&&!(function(o,c,h){const f=qR(o,c,h);return o.inclusive?f<=0:f<0})(r.startAt,v1(r),i)||r.endAt&&!(function(o,c,h){const f=qR(o,c,h);return o.inclusive?f>=0:f>0})(r.endAt,v1(r),i))})(e,t)}function iH(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function sH(e){return(t,n)=>{let r=!1;for(const i of v1(e)){const a=Xce(i,t,n);if(a!==0)return a;r=r||i.field.isKeyField()}return 0}}function Xce(e,t,n){const r=e.field.isKeyField()?hn.comparator(t.key,n.key):(function(a,o,c){const h=o.data.field(a),f=c.data.field(a);return h!==null&&f!==null?ff(h,f):Cn(42886)})(e.field,t,n);switch(e.dir){case"asc":return r;case"desc":return-1*r;default:return Cn(19790,{direction:e.dir})}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Yd{constructor(t,n){this.mapKeyFn=t,this.equalsFn=n,this.inner={},this.innerSize=0}get(t){const n=this.mapKeyFn(t),r=this.inner[n];if(r!==void 0){for(const[i,a]of r)if(this.equalsFn(i,t))return a}}has(t){return this.get(t)!==void 0}set(t,n){const r=this.mapKeyFn(t),i=this.inner[r];if(i===void 0)return this.inner[r]=[[t,n]],void this.innerSize++;for(let a=0;a{for(const[i,a]of r)t(i,a)}))}isEmpty(){return L$(this.inner)}size(){return this.innerSize}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Qce=new ds(hn.comparator);function Ml(){return Qce}const aH=new ds(hn.comparator);function r1(...e){let t=aH;for(const n of e)t=t.insert(n.key,n);return t}function oH(e){let t=aH;return e.forEach(((n,r)=>t=t.insert(n,r.overlayedDocument))),t}function Nu(){return w1()}function lH(){return w1()}function w1(){return new Yd((e=>e.toString()),((e,t)=>e.isEqual(t)))}const Zce=new ds(hn.comparator),Jce=new $i(hn.comparator);function Gr(...e){let t=Jce;for(const n of e)t=t.add(n);return t}const eue=new $i(Er);function Ij(){return eue}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function jj(e,t){if(e.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:V1(t)?"-0":t}}function cH(e){return{integerValue:""+e}}function uH(e,t){return S$(t)?cH(t):jj(e,t)}/** * @license * Copyright 2018 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class GN{constructor(){this._=void 0}}function tue(e,t,n){return e instanceof sg?(function(i,a){const o={fields:{[z$]:{stringValue:B$},[F$]:{timestampValue:{seconds:i.seconds,nanos:i.nanoseconds}}}};return a&&_j(a)&&(a=FN(a)),a&&(o.fields[V$]=a),{mapValue:o}})(n,t):e instanceof Xp?hH(e,t):e instanceof Qp?fH(e,t):(function(i,a){const o=dH(i,a),c=QR(o)+QR(i.Ae);return Fk(o)&&Fk(i.Ae)?cH(c):jj(i.serializer,c)})(e,t)}function nue(e,t,n){return e instanceof Xp?hH(e,t):e instanceof Qp?fH(e,t):n}function dH(e,t){return e instanceof ag?(function(r){return Fk(r)||(function(a){return!!a&&"doubleValue"in a})(r)})(t)?t:{integerValue:0}:null}class sg extends GN{}class Xp extends GN{constructor(t){super(),this.elements=t}}function hH(e,t){const n=pH(t);for(const r of e.elements)n.some((i=>Ru(i,r)))||n.push(r);return{arrayValue:{values:n}}}class Qp extends GN{constructor(t){super(),this.elements=t}}function fH(e,t){let n=pH(t);for(const r of e.elements)n=n.filter((i=>!Ru(i,r)));return{arrayValue:{values:n}}}class ag extends GN{constructor(t,n){super(),this.serializer=t,this.Ae=n}}function QR(e){return _s(e.integerValue||e.doubleValue)}function pH(e){return K1(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class jy{constructor(t,n){this.field=t,this.transform=n}}function rue(e,t){return e.field.isEqual(t.field)&&(function(r,i){return r instanceof Xp&&i instanceof Xp||r instanceof Qp&&i instanceof Qp?Y0(r.elements,i.elements,Ru):r instanceof ag&&i instanceof ag?Ru(r.Ae,i.Ae):r instanceof sg&&i instanceof sg})(e.transform,t.transform)}class iue{constructor(t,n){this.version=t,this.transformResults=n}}class _o{constructor(t,n){this.updateTime=t,this.exists=n}static none(){return new _o}static exists(t){return new _o(void 0,t)}static updateTime(t){return new _o(t)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}function uw(e,t){return e.updateTime!==void 0?t.isFoundDocument()&&t.version.isEqual(e.updateTime):e.exists===void 0||e.exists===t.isFoundDocument()}class qN{}function mH(e,t){if(!e.hasLocalMutations||t&&t.fields.length===0)return null;if(t===null)return e.isNoDocument()?new WN(e.key,_o.none()):new Cg(e.key,e.data,_o.none());{const n=e.data,r=io.empty();let i=new $i(Rs.comparator);for(let a of t.fields)if(!i.has(a)){let o=n.field(a);o===null&&a.length>1&&(a=a.popLast(),o=n.field(a)),o===null?r.delete(a):r.set(a,o),i=i.add(a)}return new Xd(e.key,r,new gl(i.toArray()),_o.none())}}function sue(e,t,n){e instanceof Cg?(function(i,a,o){const c=i.value.clone(),h=JR(i.fieldTransforms,a,o.transformResults);c.setAll(h),a.convertToFoundDocument(o.version,c).setHasCommittedMutations()})(e,t,n):e instanceof Xd?(function(i,a,o){if(!uw(i.precondition,a))return void a.convertToUnknownDocument(o.version);const c=JR(i.fieldTransforms,a,o.transformResults),h=a.data;h.setAll(gH(i)),h.setAll(c),a.convertToFoundDocument(o.version,h).setHasCommittedMutations()})(e,t,n):(function(i,a,o){a.convertToNoDocument(o.version).setHasCommittedMutations()})(0,t,n)}function N1(e,t,n,r){return e instanceof Cg?(function(a,o,c,h){if(!uw(a.precondition,o))return c;const f=a.value.clone(),m=eD(a.fieldTransforms,h,o);return f.setAll(m),o.convertToFoundDocument(o.version,f).setHasLocalMutations(),null})(e,t,n,r):e instanceof Xd?(function(a,o,c,h){if(!uw(a.precondition,o))return c;const f=eD(a.fieldTransforms,h,o),m=o.data;return m.setAll(gH(a)),m.setAll(f),o.convertToFoundDocument(o.version,m).setHasLocalMutations(),c===null?null:c.unionWith(a.fieldMask.fields).unionWith(a.fieldTransforms.map((y=>y.field)))})(e,t,n,r):(function(a,o,c){return uw(a.precondition,o)?(o.convertToNoDocument(o.version).setHasLocalMutations(),null):c})(e,t,n)}function aue(e,t){let n=null;for(const r of e.fieldTransforms){const i=t.data.field(r.field),a=dH(r.transform,i||null);a!=null&&(n===null&&(n=io.empty()),n.set(r.field,a))}return n||null}function ZR(e,t){return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&!!(function(r,i){return r===void 0&&i===void 0||!(!r||!i)&&Y0(r,i,((a,o)=>rue(a,o)))})(e.fieldTransforms,t.fieldTransforms)&&(e.type===0?e.value.isEqual(t.value):e.type!==1||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class Cg extends qN{constructor(t,n,r,i=[]){super(),this.key=t,this.value=n,this.precondition=r,this.fieldTransforms=i,this.type=0}getFieldMask(){return null}}class Xd extends qN{constructor(t,n,r,i,a=[]){super(),this.key=t,this.data=n,this.fieldMask=r,this.precondition=i,this.fieldTransforms=a,this.type=1}getFieldMask(){return this.fieldMask}}function gH(e){const t=new Map;return e.fieldMask.fields.forEach((n=>{if(!n.isEmpty()){const r=e.data.field(n);t.set(n,r)}})),t}function JR(e,t,n){const r=new Map;Xn(e.length===n.length,32656,{Ve:n.length,de:e.length});for(let i=0;i{const a=t.get(i.key),o=a.overlayedDocument;let c=this.applyToLocalView(o,a.mutatedFields);c=n.has(i.key)?null:c;const h=mH(o,c);h!==null&&r.set(i.key,h),o.isValidDocument()||o.convertToNoDocument(rr.min())})),r}keys(){return this.mutations.reduce(((t,n)=>t.add(n.key)),Gr())}isEqual(t){return this.batchId===t.batchId&&Y0(this.mutations,t.mutations,((n,r)=>ZR(n,r)))&&Y0(this.baseMutations,t.baseMutations,((n,r)=>ZR(n,r)))}}class Oj{constructor(t,n,r,i){this.batch=t,this.commitVersion=n,this.mutationResults=r,this.docVersions=i}static from(t,n,r){Xn(t.mutations.length===r.length,58842,{me:t.mutations.length,fe:r.length});let i=(function(){return Zce})();const a=t.mutations;for(let o=0;o=8)throw new i1(`Invalid padding: ${n}`);if(r<0)throw new i1(`Invalid hash count: ${r}`);if(t.length>0&&this.hashCount===0)throw new i1(`Invalid hash count: ${r}`);if(t.length===0&&n!==0)throw new i1(`Invalid padding when bitmap length is 0: ${n}`);this.ge=8*t.length-n,this.pe=sf.fromNumber(this.ge)}ye(t,n,r){let i=t.add(n.multiply(sf.fromNumber(r)));return i.compare(due)===1&&(i=new sf([i.getBits(0),i.getBits(1)],0)),i.modulo(this.pe).toNumber()}we(t){return!!(this.bitmap[Math.floor(t/8)]&1<o.insert(c))),o}insert(t){if(this.ge===0)return;const n=tD(t),[r,i]=nD(n);for(let a=0;a0&&(this.Oe=!0,this.Me=t)}ke(){let t=Gr(),n=Gr(),r=Gr();return this.Fe.forEach(((i,a)=>{switch(a){case 0:t=t.add(i);break;case 2:n=n.add(i);break;case 1:r=r.add(i);break;default:Cn(38017,{changeType:a})}})),new Oy(this.Me,this.xe,t,n,r)}qe(){this.Oe=!1,this.Fe=iD()}Ke(t,n){this.Oe=!0,this.Fe=this.Fe.insert(t,n)}Ue(t){this.Oe=!0,this.Fe=this.Fe.remove(t)}$e(){this.ve+=1}We(){this.ve-=1,Xn(this.ve>=0,3241,{ve:this.ve})}Qe(){this.Oe=!0,this.xe=!0}}class hue{constructor(t){this.Ge=t,this.ze=new Map,this.je=Ml(),this.Je=hv(),this.He=hv(),this.Ze=new ds(Er)}Xe(t){for(const n of t.be)t.De&&t.De.isFoundDocument()?this.Ye(n,t.De):this.et(n,t.key,t.De);for(const n of t.removedTargetIds)this.et(n,t.key,t.De)}tt(t){this.forEachTarget(t,(n=>{const r=this.nt(n);switch(t.state){case 0:this.rt(n)&&r.Le(t.resumeToken);break;case 1:r.We(),r.Ne||r.qe(),r.Le(t.resumeToken);break;case 2:r.We(),r.Ne||this.removeTarget(n);break;case 3:this.rt(n)&&(r.Qe(),r.Le(t.resumeToken));break;case 4:this.rt(n)&&(this.it(n),r.Le(t.resumeToken));break;default:Cn(56790,{state:t.state})}}))}forEachTarget(t,n){t.targetIds.length>0?t.targetIds.forEach(n):this.ze.forEach(((r,i)=>{this.rt(i)&&n(i)}))}st(t){const n=t.targetId,r=t.Ce.count,i=this.ot(n);if(i){const a=i.target;if(Ww(a))if(r===0){const o=new hn(a.path);this.et(n,o,qs.newNoDocument(o,rr.min()))}else Xn(r===1,20013,{expectedCount:r});else{const o=this._t(n);if(o!==r){const c=this.ut(t),h=c?this.ct(c,t,o):1;if(h!==0){this.it(n);const f=h===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ze=this.Ze.insert(n,f)}}}}}ut(t){const n=t.Ce.unchangedNames;if(!n||!n.bits)return null;const{bits:{bitmap:r="",padding:i=0},hashCount:a=0}=n;let o,c;try{o=Vd(r).toUint8Array()}catch(h){if(h instanceof U$)return K0("Decoding the base64 bloom filter in existence filter failed ("+h.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw h}try{c=new Rj(o,i,a)}catch(h){return K0(h instanceof i1?"BloomFilter error: ":"Applying bloom filter failed: ",h),null}return c.ge===0?null:c}ct(t,n,r){return n.Ce.count===r-this.Pt(t,n.targetId)?0:2}Pt(t,n){const r=this.Ge.getRemoteKeysForTarget(n);let i=0;return r.forEach((a=>{const o=this.Ge.ht(),c=`projects/${o.projectId}/databases/${o.database}/documents/${a.path.canonicalString()}`;t.mightContain(c)||(this.et(n,a,null),i++)})),i}Tt(t){const n=new Map;this.ze.forEach(((a,o)=>{const c=this.ot(o);if(c){if(a.current&&Ww(c.target)){const h=new hn(c.target.path);this.Et(h).has(o)||this.It(o,h)||this.et(o,h,qs.newNoDocument(h,t))}a.Be&&(n.set(o,a.ke()),a.qe())}}));let r=Gr();this.He.forEach(((a,o)=>{let c=!0;o.forEachWhile((h=>{const f=this.ot(h);return!f||f.purpose==="TargetPurposeLimboResolution"||(c=!1,!1)})),c&&(r=r.add(a))})),this.je.forEach(((a,o)=>o.setReadTime(t)));const i=new Ty(t,n,this.Ze,this.je,r);return this.je=Ml(),this.Je=hv(),this.He=hv(),this.Ze=new ds(Er),i}Ye(t,n){if(!this.rt(t))return;const r=this.It(t,n.key)?2:0;this.nt(t).Ke(n.key,r),this.je=this.je.insert(n.key,n),this.Je=this.Je.insert(n.key,this.Et(n.key).add(t)),this.He=this.He.insert(n.key,this.Rt(n.key).add(t))}et(t,n,r){if(!this.rt(t))return;const i=this.nt(t);this.It(t,n)?i.Ke(n,1):i.Ue(n),this.He=this.He.insert(n,this.Rt(n).delete(t)),this.He=this.He.insert(n,this.Rt(n).add(t)),r&&(this.je=this.je.insert(n,r))}removeTarget(t){this.ze.delete(t)}_t(t){const n=this.nt(t).ke();return this.Ge.getRemoteKeysForTarget(t).size+n.addedDocuments.size-n.removedDocuments.size}$e(t){this.nt(t).$e()}nt(t){let n=this.ze.get(t);return n||(n=new rD,this.ze.set(t,n)),n}Rt(t){let n=this.He.get(t);return n||(n=new $i(Er),this.He=this.He.insert(t,n)),n}Et(t){let n=this.Je.get(t);return n||(n=new $i(Er),this.Je=this.Je.insert(t,n)),n}rt(t){const n=this.ot(t)!==null;return n||zt("WatchChangeAggregator","Detected inactive target",t),n}ot(t){const n=this.ze.get(t);return n&&n.Ne?null:this.Ge.At(t)}it(t){this.ze.set(t,new rD),this.Ge.getRemoteKeysForTarget(t).forEach((n=>{this.et(t,n,null)}))}It(t,n){return this.Ge.getRemoteKeysForTarget(t).has(n)}}function hv(){return new ds(hn.comparator)}function iD(){return new ds(hn.comparator)}const fue={asc:"ASCENDING",desc:"DESCENDING"},pue={"<":"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"},mue={and:"AND",or:"OR"};class gue{constructor(t,n){this.databaseId=t,this.useProto3Json=n}}function Wk(e,t){return e.useProto3Json||UN(t)?t:{value:t}}function og(e,t){return e.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function wH(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function xue(e,t){return og(e,t.toTimestamp())}function Wo(e){return Xn(!!e,49232),rr.fromTimestamp((function(n){const r=zd(n);return new jr(r.seconds,r.nanos)})(e))}function Dj(e,t){return Kk(e,t).canonicalString()}function Kk(e,t){const n=(function(i){return new Ei(["projects",i.projectId,"databases",i.database])})(e).child("documents");return t===void 0?n:n.child(t)}function NH(e){const t=Ei.fromString(e);return Xn(jH(t),10190,{key:t.toString()}),t}function Xw(e,t){return Dj(e.databaseId,t.path)}function Op(e,t){const n=NH(t);if(n.get(1)!==e.databaseId.projectId)throw new Jt(bt.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+e.databaseId.projectId);if(n.get(3)!==e.databaseId.database)throw new Jt(bt.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new hn(_H(n))}function EH(e,t){return Dj(e.databaseId,t)}function AH(e){const t=NH(e);return t.length===4?Ei.emptyPath():_H(t)}function Yk(e){return new Ei(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function _H(e){return Xn(e.length>4&&e.get(4)==="documents",29091,{key:e.toString()}),e.popFirst(5)}function sD(e,t,n){return{name:Xw(e,t),fields:n.value.mapValue.fields}}function yue(e,t,n){const r=Op(e,t.name),i=Wo(t.updateTime),a=t.createTime?Wo(t.createTime):rr.min(),o=new io({mapValue:{fields:t.fields}}),c=qs.newFoundDocument(r,i,a,o);return n&&c.setHasCommittedMutations(),n?c.setHasCommittedMutations():c}function bue(e,t){let n;if("targetChange"in t){t.targetChange;const r=(function(f){return f==="NO_CHANGE"?0:f==="ADD"?1:f==="REMOVE"?2:f==="CURRENT"?3:f==="RESET"?4:Cn(39313,{state:f})})(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],a=(function(f,m){return f.useProto3Json?(Xn(m===void 0||typeof m=="string",58123),ta.fromBase64String(m||"")):(Xn(m===void 0||m instanceof Buffer||m instanceof Uint8Array,16193),ta.fromUint8Array(m||new Uint8Array))})(e,t.targetChange.resumeToken),o=t.targetChange.cause,c=o&&(function(f){const m=f.code===void 0?bt.UNKNOWN:yH(f.code);return new Jt(m,f.message||"")})(o);n=new vH(r,i,a,c||null)}else if("documentChange"in t){t.documentChange;const r=t.documentChange;r.document,r.document.name,r.document.updateTime;const i=Op(e,r.document.name),a=Wo(r.document.updateTime),o=r.document.createTime?Wo(r.document.createTime):rr.min(),c=new io({mapValue:{fields:r.document.fields}}),h=qs.newFoundDocument(i,a,o,c),f=r.targetIds||[],m=r.removedTargetIds||[];n=new dw(f,m,h.key,h)}else if("documentDelete"in t){t.documentDelete;const r=t.documentDelete;r.document;const i=Op(e,r.document),a=r.readTime?Wo(r.readTime):rr.min(),o=qs.newNoDocument(i,a),c=r.removedTargetIds||[];n=new dw([],c,o.key,o)}else if("documentRemove"in t){t.documentRemove;const r=t.documentRemove;r.document;const i=Op(e,r.document),a=r.removedTargetIds||[];n=new dw([],a,i,null)}else{if(!("filter"in t))return Cn(11601,{Vt:t});{t.filter;const r=t.filter;r.targetId;const{count:i=0,unchangedNames:a}=r,o=new lue(i,a),c=r.targetId;n=new bH(c,o)}}return n}function Qw(e,t){let n;if(t instanceof Cg)n={update:sD(e,t.key,t.value)};else if(t instanceof WN)n={delete:Xw(e,t.key)};else if(t instanceof Xd)n={update:sD(e,t.key,t.data),updateMask:Sue(t.fieldMask)};else{if(!(t instanceof xH))return Cn(16599,{dt:t.type});n={verify:Xw(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map((r=>(function(a,o){const c=o.transform;if(c instanceof sg)return{fieldPath:o.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(c instanceof Xp)return{fieldPath:o.field.canonicalString(),appendMissingElements:{values:c.elements}};if(c instanceof Qp)return{fieldPath:o.field.canonicalString(),removeAllFromArray:{values:c.elements}};if(c instanceof ag)return{fieldPath:o.field.canonicalString(),increment:c.Ae};throw Cn(20930,{transform:o.transform})})(0,r)))),t.precondition.isNone||(n.currentDocument=(function(i,a){return a.updateTime!==void 0?{updateTime:xue(i,a.updateTime)}:a.exists!==void 0?{exists:a.exists}:Cn(27497)})(e,t.precondition)),n}function Xk(e,t){const n=t.currentDocument?(function(a){return a.updateTime!==void 0?_o.updateTime(Wo(a.updateTime)):a.exists!==void 0?_o.exists(a.exists):_o.none()})(t.currentDocument):_o.none(),r=t.updateTransforms?t.updateTransforms.map((i=>(function(o,c){let h=null;if("setToServerValue"in c)Xn(c.setToServerValue==="REQUEST_TIME",16630,{proto:c}),h=new sg;else if("appendMissingElements"in c){const m=c.appendMissingElements.values||[];h=new Xp(m)}else if("removeAllFromArray"in c){const m=c.removeAllFromArray.values||[];h=new Qp(m)}else"increment"in c?h=new ag(o,c.increment):Cn(16584,{proto:c});const f=Rs.fromServerFormat(c.fieldPath);return new jy(f,h)})(e,i))):[];if(t.update){t.update.name;const i=Op(e,t.update.name),a=new io({mapValue:{fields:t.update.fields}});if(t.updateMask){const o=(function(h){const f=h.fieldPaths||[];return new gl(f.map((m=>Rs.fromServerFormat(m))))})(t.updateMask);return new Xd(i,a,o,n,r)}return new Cg(i,a,n,r)}if(t.delete){const i=Op(e,t.delete);return new WN(i,n)}if(t.verify){const i=Op(e,t.verify);return new xH(i,n)}return Cn(1463,{proto:t})}function vue(e,t){return e&&e.length>0?(Xn(t!==void 0,14353),e.map((n=>(function(i,a){let o=i.updateTime?Wo(i.updateTime):Wo(a);return o.isEqual(rr.min())&&(o=Wo(a)),new iue(o,i.transformResults||[])})(n,t)))):[]}function SH(e,t){return{documents:[EH(e,t.path)]}}function Mj(e,t){const n={structuredQuery:{}},r=t.path;let i;t.collectionGroup!==null?(i=r,n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=r.popLast(),n.structuredQuery.from=[{collectionId:r.lastSegment()}]),n.parent=EH(e,i);const a=(function(f){if(f.length!==0)return IH(Fi.create(f,"and"))})(t.filters);a&&(n.structuredQuery.where=a);const o=(function(f){if(f.length!==0)return f.map((m=>(function(w){return{field:qh(w.field),direction:Eue(w.dir)}})(m)))})(t.orderBy);o&&(n.structuredQuery.orderBy=o);const c=Wk(e,t.limit);return c!==null&&(n.structuredQuery.limit=c),t.startAt&&(n.structuredQuery.startAt=(function(f){return{before:f.inclusive,values:f.position}})(t.startAt)),t.endAt&&(n.structuredQuery.endAt=(function(f){return{before:!f.inclusive,values:f.position}})(t.endAt)),{ft:n,parent:i}}function wue(e,t,n,r){const{ft:i,parent:a}=Mj(e,t),o={},c=[];let h=0;return n.forEach((f=>{const m="aggregate_"+h++;o[m]=f.alias,f.aggregateType==="count"?c.push({alias:m,count:{}}):f.aggregateType==="avg"?c.push({alias:m,avg:{field:qh(f.fieldPath)}}):f.aggregateType==="sum"&&c.push({alias:m,sum:{field:qh(f.fieldPath)}})})),{request:{structuredAggregationQuery:{aggregations:c,structuredQuery:i.structuredQuery},parent:i.parent},gt:o,parent:a}}function kH(e){let t=AH(e.parent);const n=e.structuredQuery,r=n.from?n.from.length:0;let i=null;if(r>0){Xn(r===1,65062);const m=n.from[0];m.allDescendants?i=m.collectionId:t=t.child(m.collectionId)}let a=[];n.where&&(a=(function(y){const w=CH(y);return w instanceof Fi&&Cj(w)?w.getFilters():[w]})(n.where));let o=[];n.orderBy&&(o=(function(y){return y.map((w=>(function(k){return new Y1(b0(k.field),(function(T){switch(T){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(k.direction))})(w)))})(n.orderBy));let c=null;n.limit&&(c=(function(y){let w;return w=typeof y=="object"?y.value:y,UN(w)?null:w})(n.limit));let h=null;n.startAt&&(h=(function(y){const w=!!y.before,A=y.values||[];return new rg(A,w)})(n.startAt));let f=null;return n.endAt&&(f=(function(y){const w=!y.before,A=y.values||[];return new rg(A,w)})(n.endAt)),eH(t,i,o,a,c,"F",h,f)}function Nue(e,t){const n=(function(i){switch(i){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return Cn(28987,{purpose:i})}})(t.purpose);return n==null?null:{"goog-listen-tags":n}}function CH(e){return e.unaryFilter!==void 0?(function(n){switch(n.unaryFilter.op){case"IS_NAN":const r=b0(n.unaryFilter.field);return ii.create(r,"==",{doubleValue:NaN});case"IS_NULL":const i=b0(n.unaryFilter.field);return ii.create(i,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const a=b0(n.unaryFilter.field);return ii.create(a,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const o=b0(n.unaryFilter.field);return ii.create(o,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return Cn(61313);default:return Cn(60726)}})(e):e.fieldFilter!==void 0?(function(n){return ii.create(b0(n.fieldFilter.field),(function(i){switch(i){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 Cn(58110);default:return Cn(50506)}})(n.fieldFilter.op),n.fieldFilter.value)})(e):e.compositeFilter!==void 0?(function(n){return Fi.create(n.compositeFilter.filters.map((r=>CH(r))),(function(i){switch(i){case"AND":return"and";case"OR":return"or";default:return Cn(1026)}})(n.compositeFilter.op))})(e):Cn(30097,{filter:e})}function Eue(e){return fue[e]}function Aue(e){return pue[e]}function _ue(e){return mue[e]}function qh(e){return{fieldPath:e.canonicalString()}}function b0(e){return Rs.fromServerFormat(e.fieldPath)}function IH(e){return e instanceof ii?(function(n){if(n.op==="=="){if($R(n.value))return{unaryFilter:{field:qh(n.field),op:"IS_NAN"}};if(FR(n.value))return{unaryFilter:{field:qh(n.field),op:"IS_NULL"}}}else if(n.op==="!="){if($R(n.value))return{unaryFilter:{field:qh(n.field),op:"IS_NOT_NAN"}};if(FR(n.value))return{unaryFilter:{field:qh(n.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:qh(n.field),op:Aue(n.op),value:n.value}}})(e):e instanceof Fi?(function(n){const r=n.getFilters().map((i=>IH(i)));return r.length===1?r[0]:{compositeFilter:{op:_ue(n.op),filters:r}}})(e):Cn(54877,{filter:e})}function Sue(e){const t=[];return e.fields.forEach((n=>t.push(n.canonicalString()))),{fieldPaths:t}}function jH(e){return e.length>=4&&e.get(0)==="projects"&&e.get(2)==="databases"}function TH(e){return!!e&&typeof e._toProto=="function"&&e._protoValueType==="ProtoValue"}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Id{constructor(t,n,r,i,a=rr.min(),o=rr.min(),c=ta.EMPTY_BYTE_STRING,h=null){this.target=t,this.targetId=n,this.purpose=r,this.sequenceNumber=i,this.snapshotVersion=a,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=c,this.expectedCount=h}withSequenceNumber(t){return new Id(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(t,n){return new Id(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,t,null)}withExpectedCount(t){return new Id(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,t)}withLastLimboFreeSnapshotVersion(t){return new Id(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken,this.expectedCount)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class OH{constructor(t){this.yt=t}}function kue(e,t){let n;if(t.document)n=yue(e.yt,t.document,!!t.hasCommittedMutations);else if(t.noDocument){const r=hn.fromSegments(t.noDocument.path),i=Jp(t.noDocument.readTime);n=qs.newNoDocument(r,i),t.hasCommittedMutations&&n.setHasCommittedMutations()}else{if(!t.unknownDocument)return Cn(56709);{const r=hn.fromSegments(t.unknownDocument.path),i=Jp(t.unknownDocument.version);n=qs.newUnknownDocument(r,i)}}return t.readTime&&n.setReadTime((function(i){const a=new jr(i[0],i[1]);return rr.fromTimestamp(a)})(t.readTime)),n}function aD(e,t){const n=t.key,r={prefixPath:n.getCollectionPath().popLast().toArray(),collectionGroup:n.collectionGroup,documentId:n.path.lastSegment(),readTime:Zw(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument())r.document=(function(a,o){return{name:Xw(a,o.key),fields:o.data.value.mapValue.fields,updateTime:og(a,o.version.toTimestamp()),createTime:og(a,o.createTime.toTimestamp())}})(e.yt,t);else if(t.isNoDocument())r.noDocument={path:n.path.toArray(),readTime:Zp(t.version)};else{if(!t.isUnknownDocument())return Cn(57904,{document:t});r.unknownDocument={path:n.path.toArray(),version:Zp(t.version)}}return r}function Zw(e){const t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function Zp(e){const t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function Jp(e){const t=new jr(e.seconds,e.nanoseconds);return rr.fromTimestamp(t)}function fp(e,t){const n=(t.baseMutations||[]).map((a=>Xk(e.yt,a)));for(let a=0;aXk(e.yt,a))),i=jr.fromMillis(t.localWriteTimeMs);return new Tj(t.batchId,i,n,r)}function s1(e){const t=Jp(e.readTime),n=e.lastLimboFreeSnapshotVersion!==void 0?Jp(e.lastLimboFreeSnapshotVersion):rr.min();let r;return r=(function(a){return a.documents!==void 0})(e.query)?(function(a){const o=a.documents.length;return Xn(o===1,1966,{count:o}),zl(Cy(AH(a.documents[0])))})(e.query):(function(a){return zl(kH(a))})(e.query),new Id(r,e.targetId,"TargetPurposeListen",e.lastListenSequenceNumber,t,n,ta.fromBase64String(e.resumeToken))}function PH(e,t){const n=Zp(t.snapshotVersion),r=Zp(t.lastLimboFreeSnapshotVersion);let i;i=Ww(t.target)?SH(e.yt,t.target):Mj(e.yt,t.target).ft;const a=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:Yp(t.target),readTime:n,resumeToken:a,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:r,query:i}}function RH(e){const t=kH({parent:e.parent,structuredQuery:e.structuredQuery});return e.limitType==="LAST"?Yw(t,t.limit,"L"):t}function $_(e,t){return new Pj(t.largestBatchId,Xk(e.yt,t.overlayMutation))}function oD(e,t){const n=t.path.lastSegment();return[e,So(t.path.popLast()),n]}function lD(e,t,n,r){return{indexId:e,uid:t,sequenceNumber:n,readTime:Zp(r.readTime),documentKey:So(r.documentKey.path),largestBatchId:r.largestBatchId}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Cue{getBundleMetadata(t,n){return cD(t).get(n).next((r=>{if(r)return(function(a){return{id:a.bundleId,createTime:Jp(a.createTime),version:a.version}})(r)}))}saveBundleMetadata(t,n){return cD(t).put((function(i){return{bundleId:i.id,createTime:Zp(Wo(i.createTime)),version:i.version}})(n))}getNamedQuery(t,n){return uD(t).get(n).next((r=>{if(r)return(function(a){return{name:a.name,query:RH(a.bundledQuery),readTime:Jp(a.readTime)}})(r)}))}saveNamedQuery(t,n){return uD(t).put((function(i){return{name:i.name,readTime:Zp(Wo(i.readTime)),bundledQuery:i.bundledQuery}})(n))}}function cD(e){return Ia(e,BN)}function uD(e){return Ia(e,zN)}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class KN{constructor(t,n){this.serializer=t,this.userId=n}static wt(t,n){const r=n.uid||"";return new KN(t,r)}getOverlay(t,n){return kx(t).get(oD(this.userId,n)).next((r=>r?$_(this.serializer,r):null))}getOverlays(t,n){const r=Nu();return Qe.forEach(n,(i=>this.getOverlay(t,i).next((a=>{a!==null&&r.set(i,a)})))).next((()=>r))}saveOverlays(t,n,r){const i=[];return r.forEach(((a,o)=>{const c=new Pj(n,o);i.push(this.St(t,c))})),Qe.waitFor(i)}removeOverlaysForBatchId(t,n,r){const i=new Set;n.forEach((o=>i.add(So(o.getCollectionPath()))));const a=[];return i.forEach((o=>{const c=IDBKeyRange.bound([this.userId,o,r],[this.userId,o,r+1],!1,!0);a.push(kx(t).X(Uk,c))})),Qe.waitFor(a)}getOverlaysForCollection(t,n,r){const i=Nu(),a=So(n),o=IDBKeyRange.bound([this.userId,a,r],[this.userId,a,Number.POSITIVE_INFINITY],!0);return kx(t).J(Uk,o).next((c=>{for(const h of c){const f=$_(this.serializer,h);i.set(f.getKey(),f)}return i}))}getOverlaysForCollectionGroup(t,n,r,i){const a=Nu();let o;const c=IDBKeyRange.bound([this.userId,n,r],[this.userId,n,Number.POSITIVE_INFINITY],!0);return kx(t).ee({index:O$,range:c},((h,f,m)=>{const y=$_(this.serializer,f);a.size()a))}St(t,n){return kx(t).put((function(i,a,o){const[c,h,f]=oD(a,o.mutation.key);return{userId:a,collectionPath:h,documentId:f,collectionGroup:o.mutation.key.getCollectionGroup(),largestBatchId:o.largestBatchId,overlayMutation:Qw(i.yt,o.mutation)}})(this.serializer,this.userId,n))}}function kx(e){return Ia(e,VN)}/** * @license * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Iue{bt(t){return Ia(t,Ej)}getSessionToken(t){return this.bt(t).get("sessionToken").next((n=>{const r=n==null?void 0:n.value;return r?ta.fromUint8Array(r):ta.EMPTY_BYTE_STRING}))}setSessionToken(t,n){return this.bt(t).put({name:"sessionToken",value:n.toUint8Array()})}}/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class pp{constructor(){}Dt(t,n){this.Ct(t,n),n.vt()}Ct(t,n){if("nullValue"in t)this.Ft(n,5);else if("booleanValue"in t)this.Ft(n,10),n.Mt(t.booleanValue?1:0);else if("integerValue"in t)this.Ft(n,15),n.Mt(_s(t.integerValue));else if("doubleValue"in t){const r=_s(t.doubleValue);isNaN(r)?this.Ft(n,13):(this.Ft(n,15),V1(r)?n.Mt(0):n.Mt(r))}else if("timestampValue"in t){let r=t.timestampValue;this.Ft(n,20),typeof r=="string"&&(r=zd(r)),n.xt(`${r.seconds||""}`),n.Mt(r.nanos||0)}else if("stringValue"in t)this.Ot(t.stringValue,n),this.Nt(n);else if("bytesValue"in t)this.Ft(n,30),n.Bt(Vd(t.bytesValue)),this.Nt(n);else if("referenceValue"in t)this.Lt(t.referenceValue,n);else if("geoPointValue"in t){const r=t.geoPointValue;this.Ft(n,45),n.Mt(r.latitude||0),n.Mt(r.longitude||0)}else"mapValue"in t?H$(t)?this.Ft(n,Number.MAX_SAFE_INTEGER):$N(t)?this.kt(t.mapValue,n):(this.qt(t.mapValue,n),this.Nt(n)):"arrayValue"in t?(this.Kt(t.arrayValue,n),this.Nt(n)):Cn(19022,{Ut:t})}Ot(t,n){this.Ft(n,25),this.$t(t,n)}$t(t,n){n.xt(t)}qt(t,n){const r=t.fields||{};this.Ft(n,55);for(const i of Object.keys(r))this.Ot(i,n),this.Ct(r[i],n)}kt(t,n){var o,c;const r=t.fields||{};this.Ft(n,53);const i=tg,a=((c=(o=r[i].arrayValue)==null?void 0:o.values)==null?void 0:c.length)||0;this.Ft(n,15),n.Mt(_s(a)),this.Ot(i,n),this.Ct(r[i],n)}Kt(t,n){const r=t.values||[];this.Ft(n,50);for(const i of r)this.Ct(i,n)}Lt(t,n){this.Ft(n,37),hn.fromName(t).path.forEach((r=>{this.Ft(n,60),this.$t(r,n)}))}Ft(t,n){t.Mt(n)}Nt(t){t.Mt(2)}}pp.Wt=new pp;/** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law | agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES | CONDITIONS OF ANY KIND, either express | implied. * See the License for the specific language governing permissions and * limitations under the License. */const r0=255;function jue(e){if(e===0)return 8;let t=0;return e>>4||(t+=4,e<<=4),e>>6||(t+=2,e<<=2),e>>7||(t+=1),t}function dD(e){const t=64-(function(r){let i=0;for(let a=0;a<8;++a){const o=jue(255&r[a]);if(i+=o,o!==8)break}return i})(e);return Math.ceil(t/8)}class Tue{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Qt(t){const n=t[Symbol.iterator]();let r=n.next();for(;!r.done;)this.Gt(r.value),r=n.next();this.zt()}jt(t){const n=t[Symbol.iterator]();let r=n.next();for(;!r.done;)this.Jt(r.value),r=n.next();this.Ht()}Zt(t){for(const n of t){const r=n.charCodeAt(0);if(r<128)this.Gt(r);else if(r<2048)this.Gt(960|r>>>6),this.Gt(128|63&r);else if(n<"\uD800"||"\uDBFF">>12),this.Gt(128|63&r>>>6),this.Gt(128|63&r);else{const i=n.codePointAt(0);this.Gt(240|i>>>18),this.Gt(128|63&i>>>12),this.Gt(128|63&i>>>6),this.Gt(128|63&i)}}this.zt()}Xt(t){for(const n of t){const r=n.charCodeAt(0);if(r<128)this.Jt(r);else if(r<2048)this.Jt(960|r>>>6),this.Jt(128|63&r);else if(n<"\uD800"||"\uDBFF">>12),this.Jt(128|63&r>>>6),this.Jt(128|63&r);else{const i=n.codePointAt(0);this.Jt(240|i>>>18),this.Jt(128|63&i>>>12),this.Jt(128|63&i>>>6),this.Jt(128|63&i)}}this.Ht()}Yt(t){const n=this.en(t),r=dD(n);this.tn(1+r),this.buffer[this.position++]=255&r;for(let i=n.length-r;iRs.comparator(n.field,r.field))),this.collectionId=t.collectionGroup!=null?t.collectionGroup:t.path.lastSegment(),this.dn=t.orderBy,this.mn=[];for(const n of t.filters){const r=n;r.isInequality()?this.Vn=this.Vn.add(r):this.mn.push(r)}}get fn(){return this.Vn.size>1}gn(t){if(Xn(t.collectionGroup===this.collectionId,49279),this.fn)return!1;const n=Dk(t);if(n!==void 0&&!this.pn(n))return!1;const r=sp(t);let i=new Set,a=0,o=0;for(;a0){const c=this.Vn.getIterator().getNext();if(!i.has(c.field.canonicalString())){const h=r[a];if(!this.yn(c,h)||!this.wn(this.dn[o++],h))return!1}++a}for(;a=this.dn.length||!this.wn(this.dn[o++],c))return!1}return!0}Sn(){if(this.fn)return null;let t=new $i(Rs.comparator);const n=[];for(const r of this.mn)if(!r.field.isKeyField())if(r.op==="array-contains"||r.op==="array-contains-any")n.push(new iw(r.field,2));else{if(t.has(r.field))continue;t=t.add(r.field),n.push(new iw(r.field,0))}for(const r of this.dn)r.field.isKeyField()||t.has(r.field)||(t=t.add(r.field),n.push(new iw(r.field,r.dir==="asc"?0:1)));return new $w($w.UNKNOWN_ID,this.collectionId,n,z1.empty())}pn(t){for(const n of this.mn)if(this.yn(n,t))return!0;return!1}yn(t,n){if(t===void 0||!t.field.isEqual(n.fieldPath))return!1;const r=t.op==="array-contains"||t.op==="array-contains-any";return n.kind===2===r}wn(t,n){return!!t.field.isEqual(n.fieldPath)&&(n.kind===0&&t.dir==="asc"||n.kind===1&&t.dir==="desc")}}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function DH(e){var n,r;if(Xn(e instanceof ii||e instanceof Fi,20012),e instanceof ii){if(e instanceof J$){const i=((r=(n=e.value.arrayValue)==null?void 0:n.values)==null?void 0:r.map((a=>ii.create(e.field,"==",a))))||[];return Fi.create(i,"or")}return e}const t=e.filters.map((i=>DH(i)));return Fi.create(t,e.op)}function Rue(e){if(e.getFilters().length===0)return[];const t=Jk(DH(e));return Xn(MH(t),7391),Qk(t)||Zk(t)?[t]:t.getFilters()}function Qk(e){return e instanceof ii}function Zk(e){return e instanceof Fi&&Cj(e)}function MH(e){return Qk(e)||Zk(e)||(function(n){if(n instanceof Fi&&$k(n)){for(const r of n.getFilters())if(!Qk(r)&&!Zk(r))return!1;return!0}return!1})(e)}function Jk(e){if(Xn(e instanceof ii||e instanceof Fi,34018),e instanceof ii)return e;if(e.filters.length===1)return Jk(e.filters[0]);const t=e.filters.map((r=>Jk(r)));let n=Fi.create(t,e.op);return n=Jw(n),MH(n)?n:(Xn(n instanceof Fi,64498),Xn(ig(n),40251),Xn(n.filters.length>1,57927),n.filters.reduce(((r,i)=>Lj(r,i))))}function Lj(e,t){let n;return Xn(e instanceof ii||e instanceof Fi,38388),Xn(t instanceof ii||t instanceof Fi,25473),n=e instanceof ii?t instanceof ii?(function(i,a){return Fi.create([i,a],"and")})(e,t):mD(e,t):t instanceof ii?mD(t,e):(function(i,a){if(Xn(i.filters.length>0&&a.filters.length>0,48005),ig(i)&&ig(a))return X$(i,a.getFilters());const o=$k(i)?i:a,c=$k(i)?a:i,h=o.filters.map((f=>Lj(f,c)));return Fi.create(h,"or")})(e,t),Jw(n)}function mD(e,t){if(ig(t))return X$(t,e.getFilters());{const n=t.filters.map((r=>Lj(e,r)));return Fi.create(n,"or")}}function Jw(e){if(Xn(e instanceof ii||e instanceof Fi,11850),e instanceof ii)return e;const t=e.getFilters();if(t.length===1)return Jw(t[0]);if(K$(e))return e;const n=t.map((i=>Jw(i))),r=[];return n.forEach((i=>{i instanceof ii?r.push(i):i instanceof Fi&&(i.op===e.op?r.push(...i.filters):r.push(i))})),r.length===1?r[0]:Fi.create(r,e.op)}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Due{constructor(){this.bn=new Uj}addToCollectionParentIndex(t,n){return this.bn.add(n),Qe.resolve()}getCollectionParents(t,n){return Qe.resolve(this.bn.getEntries(n))}addFieldIndex(t,n){return Qe.resolve()}deleteFieldIndex(t,n){return Qe.resolve()}deleteAllFieldIndexes(t){return Qe.resolve()}createTargetIndexes(t,n){return Qe.resolve()}getDocumentsMatchingTarget(t,n){return Qe.resolve(null)}getIndexType(t,n){return Qe.resolve(0)}getFieldIndexes(t,n){return Qe.resolve([])}getNextCollectionGroupToUpdate(t){return Qe.resolve(null)}getMinOffset(t,n){return Qe.resolve($l.min())}getMinOffsetFromCollectionGroup(t,n){return Qe.resolve($l.min())}updateCollectionGroup(t,n,r){return Qe.resolve()}updateIndexEntries(t,n){return Qe.resolve()}}class Uj{constructor(){this.index={}}add(t){const n=t.lastSegment(),r=t.popLast(),i=this.index[n]||new $i(Ei.comparator),a=!i.has(r);return this.index[n]=i.add(r),a}has(t){const n=t.lastSegment(),r=t.popLast(),i=this.index[n];return i&&i.has(r)}getEntries(t){return(this.index[t]||new $i(Ei.comparator)).toArray()}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const gD="IndexedDbIndexManager",fv=new Uint8Array(0);class Mue{constructor(t,n){this.databaseId=n,this.Dn=new Uj,this.Cn=new Yd((r=>Yp(r)),((r,i)=>ky(r,i))),this.uid=t.uid||""}addToCollectionParentIndex(t,n){if(!this.Dn.has(n)){const r=n.lastSegment(),i=n.popLast();t.addOnCommittedListener((()=>{this.Dn.add(n)}));const a={collectionId:r,parent:So(i)};return xD(t).put(a)}return Qe.resolve()}getCollectionParents(t,n){const r=[],i=IDBKeyRange.bound([n,""],[b$(n),""],!1,!0);return xD(t).J(i).next((a=>{for(const o of a){if(o.collectionId!==n)break;r.push(wu(o.parent))}return r}))}addFieldIndex(t,n){const r=Ix(t),i=(function(c){return{indexId:c.indexId,collectionGroup:c.collectionGroup,fields:c.fields.map((h=>[h.fieldPath.canonicalString(),h.kind]))}})(n);delete i.indexId;const a=r.add(i);if(n.indexState){const o=s0(t);return a.next((c=>{o.put(lD(c,this.uid,n.indexState.sequenceNumber,n.indexState.offset))}))}return a.next()}deleteFieldIndex(t,n){const r=Ix(t),i=s0(t),a=i0(t);return r.delete(n.indexId).next((()=>i.delete(IDBKeyRange.bound([n.indexId],[n.indexId+1],!1,!0)))).next((()=>a.delete(IDBKeyRange.bound([n.indexId],[n.indexId+1],!1,!0))))}deleteAllFieldIndexes(t){const n=Ix(t),r=i0(t),i=s0(t);return n.X().next((()=>r.X())).next((()=>i.X()))}createTargetIndexes(t,n){return Qe.forEach(this.vn(n),(r=>this.getIndexType(t,r).next((i=>{if(i===0||i===1){const a=new pD(r).Sn();if(a!=null)return this.addFieldIndex(t,a)}}))))}getDocumentsMatchingTarget(t,n){const r=i0(t);let i=!0;const a=new Map;return Qe.forEach(this.vn(n),(o=>this.Fn(t,o).next((c=>{i&&(i=!!c),a.set(o,c)})))).next((()=>{if(i){let o=Gr();const c=[];return Qe.forEach(a,((h,f)=>{zt(gD,`Using index ${(function(L){return`id=${L.indexId}|cg=${L.collectionGroup}|f=${L.fields.map((q=>`${q.fieldPath}:${q.kind}`)).join(",")}`})(h)} to execute ${Yp(n)}`);const m=(function(L,q){const Z=Dk(q);if(Z===void 0)return null;for(const K of Kw(L,Z.fieldPath))switch(K.op){case"array-contains-any":return K.value.arrayValue.values||[];case"array-contains":return[K.value]}return null})(f,h),y=(function(L,q){const Z=new Map;for(const K of sp(q))for(const z of Kw(L,K.fieldPath))switch(z.op){case"==":case"in":Z.set(K.fieldPath.canonicalString(),z.value);break;case"not-in":case"!=":return Z.set(K.fieldPath.canonicalString(),z.value),Array.from(Z.values())}return null})(f,h),w=(function(L,q){const Z=[];let K=!0;for(const z of sp(q)){const B=z.kind===0?KR(L,z.fieldPath,L.startAt):YR(L,z.fieldPath,L.startAt);Z.push(B.value),K&&(K=B.inclusive)}return new rg(Z,K)})(f,h),A=(function(L,q){const Z=[];let K=!0;for(const z of sp(q)){const B=z.kind===0?YR(L,z.fieldPath,L.endAt):KR(L,z.fieldPath,L.endAt);Z.push(B.value),K&&(K=B.inclusive)}return new rg(Z,K)})(f,h),k=this.Mn(h,f,w),I=this.Mn(h,f,A),T=this.xn(h,f,y),D=this.On(h.indexId,m,k,w.inclusive,I,A.inclusive,T);return Qe.forEach(D,(F=>r.Z(F,n.limit).next((L=>{L.forEach((q=>{const Z=hn.fromSegments(q.documentKey);o.has(Z)||(o=o.add(Z),c.push(Z))}))}))))})).next((()=>c))}return Qe.resolve(null)}))}vn(t){let n=this.Cn.get(t);return n||(t.filters.length===0?n=[t]:n=Rue(Fi.create(t.filters,"and")).map((r=>Gk(t.path,t.collectionGroup,t.orderBy,r.getFilters(),t.limit,t.startAt,t.endAt))),this.Cn.set(t,n),n)}On(t,n,r,i,a,o,c){const h=(n!=null?n.length:1)*Math.max(r.length,a.length),f=h/(n!=null?n.length:1),m=[];for(let y=0;ythis.Bn(t,w,T,!0)));m.push(...this.createRange(A,k,I))}return m}Bn(t,n,r,i){const a=new mp(t,hn.empty(),n,r);return i?a:a.In()}Ln(t,n,r,i){const a=new mp(t,hn.empty(),n,r);return i?a.In():a}Fn(t,n){const r=new pD(n),i=n.collectionGroup!=null?n.collectionGroup:n.path.lastSegment();return this.getFieldIndexes(t,i).next((a=>{let o=null;for(const c of a)r.gn(c)&&(!o||c.fields.length>o.fields.length)&&(o=c);return o}))}getIndexType(t,n){let r=2;const i=this.vn(n);return Qe.forEach(i,(a=>this.Fn(t,a).next((o=>{o?r!==0&&o.fields.length<(function(h){let f=new $i(Rs.comparator),m=!1;for(const y of h.filters)for(const w of y.getFlattenedFilters())w.field.isKeyField()||(w.op==="array-contains"||w.op==="array-contains-any"?m=!0:f=f.add(w.field));for(const y of h.orderBy)y.field.isKeyField()||(f=f.add(y.field));return f.size+(m?1:0)})(a)&&(r=1):r=0})))).next((()=>(function(o){return o.limit!==null})(n)&&i.length>1&&r===2?1:r))}kn(t,n){const r=new Cx;for(const i of sp(t)){const a=n.data.field(i.fieldPath);if(a==null)return null;const o=r.ln(i.kind);pp.Wt.Dt(a,o)}return r.un()}Nn(t){const n=new Cx;return pp.Wt.Dt(t,n.ln(0)),n.un()}qn(t,n){const r=new Cx;return pp.Wt.Dt(W1(this.databaseId,n),r.ln((function(a){const o=sp(a);return o.length===0?0:o[o.length-1].kind})(t))),r.un()}xn(t,n,r){if(r===null)return[];let i=[];i.push(new Cx);let a=0;for(const o of sp(t)){const c=r[a++];for(const h of i)if(this.Kn(n,o.fieldPath)&&K1(c))i=this.Un(i,o,c);else{const f=h.ln(o.kind);pp.Wt.Dt(c,f)}}return this.$n(i)}Mn(t,n,r){return this.xn(t,n,r.position)}$n(t){const n=[];for(let r=0;rr instanceof ii&&r.field.isEqual(n)&&(r.op==="in"||r.op==="not-in")))}getFieldIndexes(t,n){const r=Ix(t),i=s0(t);return(n?r.J(Lk,IDBKeyRange.bound(n,n)):r.J()).next((a=>{const o=[];return Qe.forEach(a,(c=>i.get([c.indexId,this.uid]).next((h=>{o.push((function(m,y){const w=y?new z1(y.sequenceNumber,new $l(Jp(y.readTime),new hn(wu(y.documentKey)),y.largestBatchId)):z1.empty(),A=m.fields.map((([k,I])=>new iw(Rs.fromServerFormat(k),I)));return new $w(m.indexId,m.collectionGroup,A,w)})(c,h))})))).next((()=>o))}))}getNextCollectionGroupToUpdate(t){return this.getFieldIndexes(t).next((n=>n.length===0?null:(n.sort(((r,i)=>{const a=r.indexState.sequenceNumber-i.indexState.sequenceNumber;return a!==0?a:Er(r.collectionGroup,i.collectionGroup)})),n[0].collectionGroup)))}updateCollectionGroup(t,n,r){const i=Ix(t),a=s0(t);return this.Wn(t).next((o=>i.J(Lk,IDBKeyRange.bound(n,n)).next((c=>Qe.forEach(c,(h=>a.put(lD(h.indexId,this.uid,o,r))))))))}updateIndexEntries(t,n){const r=new Map;return Qe.forEach(n,((i,a)=>{const o=r.get(i.collectionGroup);return(o?Qe.resolve(o):this.getFieldIndexes(t,i.collectionGroup)).next((c=>(r.set(i.collectionGroup,c),Qe.forEach(c,(h=>this.Qn(t,i,h).next((f=>{const m=this.Gn(a,h);return f.isEqual(m)?Qe.resolve():this.zn(t,a,h,f,m)})))))))}))}jn(t,n,r,i){return i0(t).put(i.Rn(this.uid,this.qn(r,n.key),n.key))}Jn(t,n,r,i){return i0(t).delete(i.An(this.uid,this.qn(r,n.key),n.key))}Qn(t,n,r){const i=i0(t);let a=new $i(Ih);return i.ee({index:T$,range:IDBKeyRange.only([r.indexId,this.uid,hw(this.qn(r,n))])},((o,c)=>{a=a.add(new mp(r.indexId,n,fD(c.arrayValue),fD(c.directionalValue)))})).next((()=>a))}Gn(t,n){let r=new $i(Ih);const i=this.kn(n,t);if(i==null)return r;const a=Dk(n);if(a!=null){const o=t.data.field(a.fieldPath);if(K1(o))for(const c of o.arrayValue.values||[])r=r.add(new mp(n.indexId,t.key,this.Nn(c),i))}else r=r.add(new mp(n.indexId,t.key,fv,i));return r}zn(t,n,r,i,a){zt(gD,"Updating index entries for document '%s'",n.key);const o=[];return(function(h,f,m,y,w){const A=h.getIterator(),k=f.getIterator();let I=n0(A),T=n0(k);for(;I||T;){let D=!1,F=!1;if(I&&T){const L=m(I,T);L<0?F=!0:L>0&&(D=!0)}else I!=null?F=!0:D=!0;D?(y(T),T=n0(k)):F?(w(I),I=n0(A)):(I=n0(A),T=n0(k))}})(i,a,Ih,(c=>{o.push(this.jn(t,n,r,c))}),(c=>{o.push(this.Jn(t,n,r,c))})),Qe.waitFor(o)}Wn(t){let n=1;return s0(t).ee({index:j$,reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},((r,i,a)=>{a.done(),n=i.sequenceNumber+1})).next((()=>n))}createRange(t,n,r){r=r.sort(((o,c)=>Ih(o,c))).filter(((o,c,h)=>!c||Ih(o,h[c-1])!==0));const i=[];i.push(t);for(const o of r){const c=Ih(o,t),h=Ih(o,n);if(c===0)i[0]=t.In();else if(c>0&&h<0)i.push(o),i.push(o.In());else if(h>0)break}i.push(n);const a=[];for(let o=0;o0}getMinOffsetFromCollectionGroup(t,n){return this.getFieldIndexes(t,n).next(yD)}getMinOffset(t,n){return Qe.mapArray(this.vn(n),(r=>this.Fn(t,r).next((i=>i||Cn(44426))))).next(yD)}}function xD(e){return Ia(e,H1)}function i0(e){return Ia(e,y1)}function Ix(e){return Ia(e,Nj)}function s0(e){return Ia(e,x1)}function yD(e){Xn(e.length!==0,28825);let t=e[0].indexState.offset,n=t.largestBatchId;for(let r=1;r(c++,w.delete())));a.push(h.next((()=>{Xn(c===1,47070,{batchId:n.batchId})})));const f=[];for(const m of n.mutations){const y=k$(t,m.key.path,n.batchId);a.push(i.delete(y)),f.push(m.key)}return Qe.waitFor(a).next((()=>f))}function e2(e){if(!e)return 0;let t;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw Cn(14731);t=e.noDocument}return JSON.stringify(t).length}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */wo.DEFAULT_COLLECTION_PERCENTILE=10,wo.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,wo.DEFAULT=new wo(LH,wo.DEFAULT_COLLECTION_PERCENTILE,wo.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),wo.DISABLED=new wo(-1,0,0);class YN{constructor(t,n,r,i){this.userId=t,this.serializer=n,this.indexManager=r,this.referenceDelegate=i,this.Zn={}}static wt(t,n,r,i){Xn(t.uid!=="",64387);const a=t.isAuthenticated()?t.uid:"";return new YN(a,n,r,i)}checkEmpty(t){let n=!0;const r=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return jh(t).ee({index:vp,range:r},((i,a,o)=>{n=!1,o.done()})).next((()=>n))}addMutationBatch(t,n,r,i){const a=v0(t),o=jh(t);return o.add({}).next((c=>{Xn(typeof c=="number",49019);const h=new Tj(c,n,r,i),f=(function(A,k,I){const T=I.baseMutations.map((F=>Qw(A.yt,F))),D=I.mutations.map((F=>Qw(A.yt,F)));return{userId:k,batchId:I.batchId,localWriteTimeMs:I.localWriteTime.toMillis(),baseMutations:T,mutations:D}})(this.serializer,this.userId,h),m=[];let y=new $i(((w,A)=>Er(w.canonicalString(),A.canonicalString())));for(const w of i){const A=k$(this.userId,w.key.path,c);y=y.add(w.key.path.popLast()),m.push(o.put(f)),m.push(a.put(A,cce))}return y.forEach((w=>{m.push(this.indexManager.addToCollectionParentIndex(t,w))})),t.addOnCommittedListener((()=>{this.Zn[c]=h.keys()})),Qe.waitFor(m).next((()=>h))}))}lookupMutationBatch(t,n){return jh(t).get(n).next((r=>r?(Xn(r.userId===this.userId,48,"Unexpected user for mutation batch",{userId:r.userId,batchId:n}),fp(this.serializer,r)):null))}Xn(t,n){return this.Zn[n]?Qe.resolve(this.Zn[n]):this.lookupMutationBatch(t,n).next((r=>{if(r){const i=r.keys();return this.Zn[n]=i,i}return null}))}getNextMutationBatchAfterBatchId(t,n){const r=n+1,i=IDBKeyRange.lowerBound([this.userId,r]);let a=null;return jh(t).ee({index:vp,range:i},((o,c,h)=>{c.userId===this.userId&&(Xn(c.batchId>=r,47524,{Yn:r}),a=fp(this.serializer,c)),h.done()})).next((()=>a))}getHighestUnacknowledgedBatchId(t){const n=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let r=jp;return jh(t).ee({index:vp,range:n,reverse:!0},((i,a,o)=>{r=a.batchId,o.done()})).next((()=>r))}getAllMutationBatches(t){const n=IDBKeyRange.bound([this.userId,jp],[this.userId,Number.POSITIVE_INFINITY]);return jh(t).J(vp,n).next((r=>r.map((i=>fp(this.serializer,i)))))}getAllMutationBatchesAffectingDocumentKey(t,n){const r=sw(this.userId,n.path),i=IDBKeyRange.lowerBound(r),a=[];return v0(t).ee({range:i},((o,c,h)=>{const[f,m,y]=o,w=wu(m);if(f===this.userId&&n.path.isEqual(w))return jh(t).get(y).next((A=>{if(!A)throw Cn(61480,{er:o,batchId:y});Xn(A.userId===this.userId,10503,"Unexpected user for mutation batch",{userId:A.userId,batchId:y}),a.push(fp(this.serializer,A))}));h.done()})).next((()=>a))}getAllMutationBatchesAffectingDocumentKeys(t,n){let r=new $i(Er);const i=[];return n.forEach((a=>{const o=sw(this.userId,a.path),c=IDBKeyRange.lowerBound(o),h=v0(t).ee({range:c},((f,m,y)=>{const[w,A,k]=f,I=wu(A);w===this.userId&&a.path.isEqual(I)?r=r.add(k):y.done()}));i.push(h)})),Qe.waitFor(i).next((()=>this.tr(t,r)))}getAllMutationBatchesAffectingQuery(t,n){const r=n.path,i=r.length+1,a=sw(this.userId,r),o=IDBKeyRange.lowerBound(a);let c=new $i(Er);return v0(t).ee({range:o},((h,f,m)=>{const[y,w,A]=h,k=wu(w);y===this.userId&&r.isPrefixOf(k)?k.length===i&&(c=c.add(A)):m.done()})).next((()=>this.tr(t,c)))}tr(t,n){const r=[],i=[];return n.forEach((a=>{i.push(jh(t).get(a).next((o=>{if(o===null)throw Cn(35274,{batchId:a});Xn(o.userId===this.userId,9748,"Unexpected user for mutation batch",{userId:o.userId,batchId:a}),r.push(fp(this.serializer,o))})))})),Qe.waitFor(i).next((()=>r))}removeMutationBatch(t,n){return UH(t.le,this.userId,n).next((r=>(t.addOnCommittedListener((()=>{this.nr(n.batchId)})),Qe.forEach(r,(i=>this.referenceDelegate.markPotentiallyOrphaned(t,i))))))}nr(t){delete this.Zn[t]}performConsistencyCheck(t){return this.checkEmpty(t).next((n=>{if(!n)return Qe.resolve();const r=IDBKeyRange.lowerBound((function(o){return[o]})(this.userId)),i=[];return v0(t).ee({range:r},((a,o,c)=>{if(a[0]===this.userId){const h=wu(a[1]);i.push(h)}else c.done()})).next((()=>{Xn(i.length===0,56720,{rr:i.map((a=>a.canonicalString()))})}))}))}containsKey(t,n){return BH(t,this.userId,n)}ir(t){return zH(t).get(this.userId).next((n=>n||{userId:this.userId,lastAcknowledgedBatchId:jp,lastStreamToken:""}))}}function BH(e,t,n){const r=sw(t,n.path),i=r[1],a=IDBKeyRange.lowerBound(r);let o=!1;return v0(e).ee({range:a,Y:!0},((c,h,f)=>{const[m,y,w]=c;m===t&&y===i&&(o=!0),f.done()})).next((()=>o))}function jh(e){return Ia(e,Oc)}function v0(e){return Ia(e,Q0)}function zH(e){return Ia(e,F1)}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class em{constructor(t){this.sr=t}next(){return this.sr+=2,this.sr}static _r(){return new em(0)}static ar(){return new em(-1)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Lue{constructor(t,n){this.referenceDelegate=t,this.serializer=n}allocateTargetId(t){return this.ur(t).next((n=>{const r=new em(n.highestTargetId);return n.highestTargetId=r.next(),this.cr(t,n).next((()=>n.highestTargetId))}))}getLastRemoteSnapshotVersion(t){return this.ur(t).next((n=>rr.fromTimestamp(new jr(n.lastRemoteSnapshotVersion.seconds,n.lastRemoteSnapshotVersion.nanoseconds))))}getHighestSequenceNumber(t){return this.ur(t).next((n=>n.highestListenSequenceNumber))}setTargetsMetadata(t,n,r){return this.ur(t).next((i=>(i.highestListenSequenceNumber=n,r&&(i.lastRemoteSnapshotVersion=r.toTimestamp()),n>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=n),this.cr(t,i))))}addTargetData(t,n){return this.lr(t,n).next((()=>this.ur(t).next((r=>(r.targetCount+=1,this.hr(n,r),this.cr(t,r))))))}updateTargetData(t,n){return this.lr(t,n)}removeTargetData(t,n){return this.removeMatchingKeysForTargetId(t,n.targetId).next((()=>a0(t).delete(n.targetId))).next((()=>this.ur(t))).next((r=>(Xn(r.targetCount>0,8065),r.targetCount-=1,this.cr(t,r))))}removeTargets(t,n,r){let i=0;const a=[];return a0(t).ee(((o,c)=>{const h=s1(c);h.sequenceNumber<=n&&r.get(h.targetId)===null&&(i++,a.push(this.removeTargetData(t,h)))})).next((()=>Qe.waitFor(a))).next((()=>i))}forEachTarget(t,n){return a0(t).ee(((r,i)=>{const a=s1(i);n(a)}))}ur(t){return vD(t).get(qw).next((n=>(Xn(n!==null,2888),n)))}cr(t,n){return vD(t).put(qw,n)}lr(t,n){return a0(t).put(PH(this.serializer,n))}hr(t,n){let r=!1;return t.targetId>n.highestTargetId&&(n.highestTargetId=t.targetId,r=!0),t.sequenceNumber>n.highestListenSequenceNumber&&(n.highestListenSequenceNumber=t.sequenceNumber,r=!0),r}getTargetCount(t){return this.ur(t).next((n=>n.targetCount))}getTargetData(t,n){const r=Yp(n),i=IDBKeyRange.bound([r,Number.NEGATIVE_INFINITY],[r,Number.POSITIVE_INFINITY]);let a=null;return a0(t).ee({range:i,index:I$},((o,c,h)=>{const f=s1(c);ky(n,f.target)&&(a=f,h.done())})).next((()=>a))}addMatchingKeys(t,n,r){const i=[],a=Wh(t);return n.forEach((o=>{const c=So(o.path);i.push(a.put({targetId:r,path:c})),i.push(this.referenceDelegate.addReference(t,r,o))})),Qe.waitFor(i)}removeMatchingKeys(t,n,r){const i=Wh(t);return Qe.forEach(n,(a=>{const o=So(a.path);return Qe.waitFor([i.delete([r,o]),this.referenceDelegate.removeReference(t,r,a)])}))}removeMatchingKeysForTargetId(t,n){const r=Wh(t),i=IDBKeyRange.bound([n],[n+1],!1,!0);return r.delete(i)}getMatchingKeysForTargetId(t,n){const r=IDBKeyRange.bound([n],[n+1],!1,!0),i=Wh(t);let a=Gr();return i.ee({range:r,Y:!0},((o,c,h)=>{const f=wu(o[1]),m=new hn(f);a=a.add(m)})).next((()=>a))}containsKey(t,n){const r=So(n.path),i=IDBKeyRange.bound([r],[b$(r)],!1,!0);let a=0;return Wh(t).ee({index:wj,Y:!0,range:i},(([o,c],h,f)=>{o!==0&&(a++,f.done())})).next((()=>a>0))}At(t,n){return a0(t).get(n).next((r=>r?s1(r):null))}}function a0(e){return Ia(e,Z0)}function vD(e){return Ia(e,Tp)}function Wh(e){return Ia(e,J0)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const wD="LruGarbageCollector",VH=1048576;function ND([e,t],[n,r]){const i=Er(e,n);return i===0?Er(t,r):i}class Uue{constructor(t){this.Pr=t,this.buffer=new $i(ND),this.Tr=0}Er(){return++this.Tr}Ir(t){const n=[t,this.Er()];if(this.buffer.size{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(n){Ef(n)?zt(wD,"Ignoring IndexedDB error during garbage collection: ",n):await Nf(n)}await this.Ar(3e5)}))}}class Bue{constructor(t,n){this.Vr=t,this.params=n}calculateTargetCount(t,n){return this.Vr.dr(t).next((r=>Math.floor(n/100*r)))}nthSequenceNumber(t,n){if(n===0)return Qe.resolve(ml.ce);const r=new Uue(n);return this.Vr.forEachTarget(t,(i=>r.Ir(i.sequenceNumber))).next((()=>this.Vr.mr(t,(i=>r.Ir(i))))).next((()=>r.maxValue))}removeTargets(t,n,r){return this.Vr.removeTargets(t,n,r)}removeOrphanedDocuments(t,n){return this.Vr.removeOrphanedDocuments(t,n)}collect(t,n){return this.params.cacheSizeCollectionThreshold===-1?(zt("LruGarbageCollector","Garbage collection skipped; disabled"),Qe.resolve(bD)):this.getCacheSize(t).next((r=>r(y>this.params.maximumSequenceNumbersToCollect?(zt("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${y}`),i=this.params.maximumSequenceNumbersToCollect):i=y,o=Date.now(),this.nthSequenceNumber(t,i)))).next((y=>(r=y,c=Date.now(),this.removeTargets(t,r,n)))).next((y=>(a=y,h=Date.now(),this.removeOrphanedDocuments(t,r)))).next((y=>(f=Date.now(),x0()<=ri.DEBUG&&zt("LruGarbageCollector",`LRU Garbage Collection Counted targets in ${o-m}ms Determined least recently used ${i} in `+(c-o)+`ms Removed ${a} targets in `+(h-c)+`ms Removed ${y} documents in `+(f-h)+`ms Total Duration: ${f-m}ms`),Qe.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:a,documentsRemoved:y}))))}}function $H(e,t){return new Bue(e,t)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class zue{constructor(t,n){this.db=t,this.garbageCollector=$H(this,n)}dr(t){const n=this.pr(t);return this.db.getTargetCache().getTargetCount(t).next((r=>n.next((i=>r+i))))}pr(t){let n=0;return this.mr(t,(r=>{n++})).next((()=>n))}forEachTarget(t,n){return this.db.getTargetCache().forEachTarget(t,n)}mr(t,n){return this.yr(t,((r,i)=>n(i)))}addReference(t,n,r){return pv(t,r)}removeReference(t,n,r){return pv(t,r)}removeTargets(t,n,r){return this.db.getTargetCache().removeTargets(t,n,r)}markPotentiallyOrphaned(t,n){return pv(t,n)}wr(t,n){return(function(i,a){let o=!1;return zH(i).te((c=>BH(i,c,a).next((h=>(h&&(o=!0),Qe.resolve(!h)))))).next((()=>o))})(t,n)}removeOrphanedDocuments(t,n){const r=this.db.getRemoteDocumentCache().newChangeBuffer(),i=[];let a=0;return this.yr(t,((o,c)=>{if(c<=n){const h=this.wr(t,o).next((f=>{if(!f)return a++,r.getEntry(t,o).next((()=>(r.removeEntry(o,rr.min()),Wh(t).delete((function(y){return[0,So(y.path)]})(o)))))}));i.push(h)}})).next((()=>Qe.waitFor(i))).next((()=>r.apply(t))).next((()=>a))}removeTarget(t,n){const r=n.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,r)}updateLimboDocument(t,n){return pv(t,n)}yr(t,n){const r=Wh(t);let i,a=ml.ce;return r.ee({index:wj},(([o,c],{path:h,sequenceNumber:f})=>{o===0?(a!==ml.ce&&n(new hn(wu(i)),a),a=f,i=h):a=ml.ce})).next((()=>{a!==ml.ce&&n(new hn(wu(i)),a)}))}getCacheSize(t){return this.db.getRemoteDocumentCache().getSize(t)}}function pv(e,t){return Wh(e).put((function(r,i){return{targetId:0,path:So(r.path),sequenceNumber:i}})(t,e.currentSequenceNumber))}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class HH{constructor(){this.changes=new Yd((t=>t.toString()),((t,n)=>t.isEqual(n))),this.changesApplied=!1}addEntry(t){this.assertNotApplied(),this.changes.set(t.key,t)}removeEntry(t,n){this.assertNotApplied(),this.changes.set(t,qs.newInvalidDocument(t).setReadTime(n))}getEntry(t,n){this.assertNotApplied();const r=this.changes.get(n);return r!==void 0?Qe.resolve(r):this.getFromCache(t,n)}getEntries(t,n){return this.getAllFromCache(t,n)}apply(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)}assertNotApplied(){}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Vue{constructor(t){this.serializer=t}setIndexManager(t){this.indexManager=t}addEntry(t,n,r){return Xf(t).put(r)}removeEntry(t,n,r){return Xf(t).delete((function(a,o){const c=a.path.toArray();return[c.slice(0,c.length-2),c[c.length-2],Zw(o),c[c.length-1]]})(n,r))}updateMetadata(t,n){return this.getMetadata(t).next((r=>(r.byteSize+=n,this.Sr(t,r))))}getEntry(t,n){let r=qs.newInvalidDocument(n);return Xf(t).ee({index:aw,range:IDBKeyRange.only(jx(n))},((i,a)=>{r=this.br(n,a)})).next((()=>r))}Dr(t,n){let r={size:0,document:qs.newInvalidDocument(n)};return Xf(t).ee({index:aw,range:IDBKeyRange.only(jx(n))},((i,a)=>{r={document:this.br(n,a),size:e2(a)}})).next((()=>r))}getEntries(t,n){let r=Ml();return this.Cr(t,n,((i,a)=>{const o=this.br(i,a);r=r.insert(i,o)})).next((()=>r))}vr(t,n){let r=Ml(),i=new ds(hn.comparator);return this.Cr(t,n,((a,o)=>{const c=this.br(a,o);r=r.insert(a,c),i=i.insert(a,e2(o))})).next((()=>({documents:r,Fr:i})))}Cr(t,n,r){if(n.isEmpty())return Qe.resolve();let i=new $i(_D);n.forEach((h=>i=i.add(h)));const a=IDBKeyRange.bound(jx(i.first()),jx(i.last())),o=i.getIterator();let c=o.getNext();return Xf(t).ee({index:aw,range:a},((h,f,m)=>{const y=hn.fromSegments([...f.prefixPath,f.collectionGroup,f.documentId]);for(;c&&_D(c,y)<0;)r(c,null),c=o.getNext();c&&c.isEqual(y)&&(r(c,f),c=o.hasNext()?o.getNext():null),c?m.j(jx(c)):m.done()})).next((()=>{for(;c;)r(c,null),c=o.hasNext()?o.getNext():null}))}getDocumentsMatchingQuery(t,n,r,i,a){const o=n.path,c=[o.popLast().toArray(),o.lastSegment(),Zw(r.readTime),r.documentKey.path.isEmpty()?"":r.documentKey.path.lastSegment()],h=[o.popLast().toArray(),o.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return Xf(t).J(IDBKeyRange.bound(c,h,!0)).next((f=>{a==null||a.incrementDocumentReadCount(f.length);let m=Ml();for(const y of f){const w=this.br(hn.fromSegments(y.prefixPath.concat(y.collectionGroup,y.documentId)),y);w.isFoundDocument()&&(Iy(n,w)||i.has(w.key))&&(m=m.insert(w.key,w))}return m}))}getAllFromCollectionGroup(t,n,r,i){let a=Ml();const o=AD(n,r),c=AD(n,$l.max());return Xf(t).ee({index:C$,range:IDBKeyRange.bound(o,c,!0)},((h,f,m)=>{const y=this.br(hn.fromSegments(f.prefixPath.concat(f.collectionGroup,f.documentId)),f);a=a.insert(y.key,y),a.size===i&&m.done()})).next((()=>a))}newChangeBuffer(t){return new Fue(this,!!t&&t.trackRemovals)}getSize(t){return this.getMetadata(t).next((n=>n.byteSize))}getMetadata(t){return ED(t).get(Mk).next((n=>(Xn(!!n,20021),n)))}Sr(t,n){return ED(t).put(Mk,n)}br(t,n){if(n){const r=kue(this.serializer,n);if(!(r.isNoDocument()&&r.version.isEqual(rr.min())))return r}return qs.newInvalidDocument(t)}}function GH(e){return new Vue(e)}class Fue extends HH{constructor(t,n){super(),this.Mr=t,this.trackRemovals=n,this.Or=new Yd((r=>r.toString()),((r,i)=>r.isEqual(i)))}applyChanges(t){const n=[];let r=0,i=new $i(((a,o)=>Er(a.canonicalString(),o.canonicalString())));return this.changes.forEach(((a,o)=>{const c=this.Or.get(a);if(n.push(this.Mr.removeEntry(t,a,c.readTime)),o.isValidDocument()){const h=aD(this.Mr.serializer,o);i=i.add(a.path.popLast());const f=e2(h);r+=f-c.size,n.push(this.Mr.addEntry(t,a,h))}else if(r-=c.size,this.trackRemovals){const h=aD(this.Mr.serializer,o.convertToNoDocument(rr.min()));n.push(this.Mr.addEntry(t,a,h))}})),i.forEach((a=>{n.push(this.Mr.indexManager.addToCollectionParentIndex(t,a))})),n.push(this.Mr.updateMetadata(t,r)),Qe.waitFor(n)}getFromCache(t,n){return this.Mr.Dr(t,n).next((r=>(this.Or.set(n,{size:r.size,readTime:r.document.readTime}),r.document)))}getAllFromCache(t,n){return this.Mr.vr(t,n).next((({documents:r,Fr:i})=>(i.forEach(((a,o)=>{this.Or.set(a,{size:o,readTime:r.get(a).readTime})})),r)))}}function ED(e){return Ia(e,$1)}function Xf(e){return Ia(e,Gw)}function jx(e){const t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function AD(e,t){const n=t.documentKey.path.toArray();return[e,Zw(t.readTime),n.slice(0,n.length-2),n.length>0?n[n.length-1]:""]}function _D(e,t){const n=e.path.toArray(),r=t.path.toArray();let i=0;for(let a=0;a(r=i,this.remoteDocumentCache.getEntry(t,n)))).next((i=>(r!==null&&N1(r.mutation,i,gl.empty(),jr.now()),i)))}getDocuments(t,n){return this.remoteDocumentCache.getEntries(t,n).next((r=>this.getLocalViewOfDocuments(t,r,Gr()).next((()=>r))))}getLocalViewOfDocuments(t,n,r=Gr()){const i=Nu();return this.populateOverlays(t,i,n).next((()=>this.computeViews(t,n,i,r).next((a=>{let o=r1();return a.forEach(((c,h)=>{o=o.insert(c,h.overlayedDocument)})),o}))))}getOverlayedDocuments(t,n){const r=Nu();return this.populateOverlays(t,r,n).next((()=>this.computeViews(t,n,r,Gr())))}populateOverlays(t,n,r){const i=[];return r.forEach((a=>{n.has(a)||i.push(a)})),this.documentOverlayCache.getOverlays(t,i).next((a=>{a.forEach(((o,c)=>{n.set(o,c)}))}))}computeViews(t,n,r,i){let a=Ml();const o=w1(),c=(function(){return w1()})();return n.forEach(((h,f)=>{const m=r.get(f.key);i.has(f.key)&&(m===void 0||m.mutation instanceof Xd)?a=a.insert(f.key,f):m!==void 0?(o.set(f.key,m.mutation.getFieldMask()),N1(m.mutation,f,m.mutation.getFieldMask(),jr.now())):o.set(f.key,gl.empty())})),this.recalculateAndSaveOverlays(t,a).next((h=>(h.forEach(((f,m)=>o.set(f,m))),n.forEach(((f,m)=>c.set(f,new $ue(m,o.get(f)??null)))),c)))}recalculateAndSaveOverlays(t,n){const r=w1();let i=new ds(((o,c)=>o-c)),a=Gr();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(t,n).next((o=>{for(const c of o)c.keys().forEach((h=>{const f=n.get(h);if(f===null)return;let m=r.get(h)||gl.empty();m=c.applyToLocalView(f,m),r.set(h,m);const y=(i.get(c.batchId)||Gr()).add(h);i=i.insert(c.batchId,y)}))})).next((()=>{const o=[],c=i.getReverseIterator();for(;c.hasNext();){const h=c.getNext(),f=h.key,m=h.value,y=lH();m.forEach((w=>{if(!a.has(w)){const A=mH(n.get(w),r.get(w));A!==null&&y.set(w,A),a=a.add(w)}})),o.push(this.documentOverlayCache.saveOverlays(t,f,y))}return Qe.waitFor(o)})).next((()=>r))}recalculateAndSaveOverlaysForDocumentKeys(t,n){return this.remoteDocumentCache.getEntries(t,n).next((r=>this.recalculateAndSaveOverlays(t,r)))}getDocumentsMatchingQuery(t,n,r,i){return Wce(n)?this.getDocumentsMatchingDocumentQuery(t,n.path):tH(n)?this.getDocumentsMatchingCollectionGroupQuery(t,n,r,i):this.getDocumentsMatchingCollectionQuery(t,n,r,i)}getNextDocuments(t,n,r,i){return this.remoteDocumentCache.getAllFromCollectionGroup(t,n,r,i).next((a=>{const o=i-a.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(t,n,r.largestBatchId,i-a.size):Qe.resolve(Nu());let c=X0,h=a;return o.next((f=>Qe.forEach(f,((m,y)=>(c{h=h.insert(m,w)}))))).next((()=>this.populateOverlays(t,f,a))).next((()=>this.computeViews(t,h,f,Gr()))).next((m=>({batchId:c,changes:oH(m)})))))}))}getDocumentsMatchingDocumentQuery(t,n){return this.getDocument(t,new hn(n)).next((r=>{let i=r1();return r.isFoundDocument()&&(i=i.insert(r.key,r)),i}))}getDocumentsMatchingCollectionGroupQuery(t,n,r,i){const a=n.collectionGroup;let o=r1();return this.indexManager.getCollectionParents(t,a).next((c=>Qe.forEach(c,(h=>{const f=(function(y,w){return new hm(w,null,y.explicitOrderBy.slice(),y.filters.slice(),y.limit,y.limitType,y.startAt,y.endAt)})(n,h.child(a));return this.getDocumentsMatchingCollectionQuery(t,f,r,i).next((m=>{m.forEach(((y,w)=>{o=o.insert(y,w)}))}))})).next((()=>o))))}getDocumentsMatchingCollectionQuery(t,n,r,i){let a;return this.documentOverlayCache.getOverlaysForCollection(t,n.path,r.largestBatchId).next((o=>(a=o,this.remoteDocumentCache.getDocumentsMatchingQuery(t,n,r,a,i)))).next((o=>{a.forEach(((h,f)=>{const m=f.getKey();o.get(m)===null&&(o=o.insert(m,qs.newInvalidDocument(m)))}));let c=r1();return o.forEach(((h,f)=>{const m=a.get(h);m!==void 0&&N1(m.mutation,f,gl.empty(),jr.now()),Iy(n,f)&&(c=c.insert(h,f))})),c}))}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Hue{constructor(t){this.serializer=t,this.Nr=new Map,this.Br=new Map}getBundleMetadata(t,n){return Qe.resolve(this.Nr.get(n))}saveBundleMetadata(t,n){return this.Nr.set(n.id,(function(i){return{id:i.id,version:i.version,createTime:Wo(i.createTime)}})(n)),Qe.resolve()}getNamedQuery(t,n){return Qe.resolve(this.Br.get(n))}saveNamedQuery(t,n){return this.Br.set(n.name,(function(i){return{name:i.name,query:RH(i.bundledQuery),readTime:Wo(i.readTime)}})(n)),Qe.resolve()}}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Gue{constructor(){this.overlays=new ds(hn.comparator),this.Lr=new Map}getOverlay(t,n){return Qe.resolve(this.overlays.get(n))}getOverlays(t,n){const r=Nu();return Qe.forEach(n,(i=>this.getOverlay(t,i).next((a=>{a!==null&&r.set(i,a)})))).next((()=>r))}saveOverlays(t,n,r){return r.forEach(((i,a)=>{this.St(t,n,a)})),Qe.resolve()}removeOverlaysForBatchId(t,n,r){const i=this.Lr.get(r);return i!==void 0&&(i.forEach((a=>this.overlays=this.overlays.remove(a))),this.Lr.delete(r)),Qe.resolve()}getOverlaysForCollection(t,n,r){const i=Nu(),a=n.length+1,o=new hn(n.child("")),c=this.overlays.getIteratorFrom(o);for(;c.hasNext();){const h=c.getNext().value,f=h.getKey();if(!n.isPrefixOf(f.path))break;f.path.length===a&&h.largestBatchId>r&&i.set(h.getKey(),h)}return Qe.resolve(i)}getOverlaysForCollectionGroup(t,n,r,i){let a=new ds(((f,m)=>f-m));const o=this.overlays.getIterator();for(;o.hasNext();){const f=o.getNext().value;if(f.getKey().getCollectionGroup()===n&&f.largestBatchId>r){let m=a.get(f.largestBatchId);m===null&&(m=Nu(),a=a.insert(f.largestBatchId,m)),m.set(f.getKey(),f)}}const c=Nu(),h=a.getIterator();for(;h.hasNext()&&(h.getNext().value.forEach(((f,m)=>c.set(f,m))),!(c.size()>=i)););return Qe.resolve(c)}St(t,n,r){const i=this.overlays.get(r.key);if(i!==null){const o=this.Lr.get(i.largestBatchId).delete(r.key);this.Lr.set(i.largestBatchId,o)}this.overlays=this.overlays.insert(r.key,new Pj(n,r));let a=this.Lr.get(n);a===void 0&&(a=Gr(),this.Lr.set(n,a)),this.Lr.set(n,a.add(r.key))}}/** * @license * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class que{constructor(){this.sessionToken=ta.EMPTY_BYTE_STRING}getSessionToken(t){return Qe.resolve(this.sessionToken)}setSessionToken(t,n){return this.sessionToken=n,Qe.resolve()}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Bj{constructor(){this.kr=new $i(Ba.qr),this.Kr=new $i(Ba.Ur)}isEmpty(){return this.kr.isEmpty()}addReference(t,n){const r=new Ba(t,n);this.kr=this.kr.add(r),this.Kr=this.Kr.add(r)}$r(t,n){t.forEach((r=>this.addReference(r,n)))}removeReference(t,n){this.Wr(new Ba(t,n))}Qr(t,n){t.forEach((r=>this.removeReference(r,n)))}Gr(t){const n=new hn(new Ei([])),r=new Ba(n,t),i=new Ba(n,t+1),a=[];return this.Kr.forEachInRange([r,i],(o=>{this.Wr(o),a.push(o.key)})),a}zr(){this.kr.forEach((t=>this.Wr(t)))}Wr(t){this.kr=this.kr.delete(t),this.Kr=this.Kr.delete(t)}jr(t){const n=new hn(new Ei([])),r=new Ba(n,t),i=new Ba(n,t+1);let a=Gr();return this.Kr.forEachInRange([r,i],(o=>{a=a.add(o.key)})),a}containsKey(t){const n=new Ba(t,0),r=this.kr.firstAfterOrEqual(n);return r!==null&&t.isEqual(r.key)}}class Ba{constructor(t,n){this.key=t,this.Jr=n}static qr(t,n){return hn.comparator(t.key,n.key)||Er(t.Jr,n.Jr)}static Ur(t,n){return Er(t.Jr,n.Jr)||hn.comparator(t.key,n.key)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Wue{constructor(t,n){this.indexManager=t,this.referenceDelegate=n,this.mutationQueue=[],this.Yn=1,this.Hr=new $i(Ba.qr)}checkEmpty(t){return Qe.resolve(this.mutationQueue.length===0)}addMutationBatch(t,n,r,i){const a=this.Yn;this.Yn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const o=new Tj(a,n,r,i);this.mutationQueue.push(o);for(const c of i)this.Hr=this.Hr.add(new Ba(c.key,a)),this.indexManager.addToCollectionParentIndex(t,c.key.path.popLast());return Qe.resolve(o)}lookupMutationBatch(t,n){return Qe.resolve(this.Zr(n))}getNextMutationBatchAfterBatchId(t,n){const r=n+1,i=this.Xr(r),a=i<0?0:i;return Qe.resolve(this.mutationQueue.length>a?this.mutationQueue[a]:null)}getHighestUnacknowledgedBatchId(){return Qe.resolve(this.mutationQueue.length===0?jp:this.Yn-1)}getAllMutationBatches(t){return Qe.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(t,n){const r=new Ba(n,0),i=new Ba(n,Number.POSITIVE_INFINITY),a=[];return this.Hr.forEachInRange([r,i],(o=>{const c=this.Zr(o.Jr);a.push(c)})),Qe.resolve(a)}getAllMutationBatchesAffectingDocumentKeys(t,n){let r=new $i(Er);return n.forEach((i=>{const a=new Ba(i,0),o=new Ba(i,Number.POSITIVE_INFINITY);this.Hr.forEachInRange([a,o],(c=>{r=r.add(c.Jr)}))})),Qe.resolve(this.Yr(r))}getAllMutationBatchesAffectingQuery(t,n){const r=n.path,i=r.length+1;let a=r;hn.isDocumentKey(a)||(a=a.child(""));const o=new Ba(new hn(a),0);let c=new $i(Er);return this.Hr.forEachWhile((h=>{const f=h.key.path;return!!r.isPrefixOf(f)&&(f.length===i&&(c=c.add(h.Jr)),!0)}),o),Qe.resolve(this.Yr(c))}Yr(t){const n=[];return t.forEach((r=>{const i=this.Zr(r);i!==null&&n.push(i)})),n}removeMutationBatch(t,n){Xn(this.ei(n.batchId,"removed")===0,55003),this.mutationQueue.shift();let r=this.Hr;return Qe.forEach(n.mutations,(i=>{const a=new Ba(i.key,n.batchId);return r=r.delete(a),this.referenceDelegate.markPotentiallyOrphaned(t,i.key)})).next((()=>{this.Hr=r}))}nr(t){}containsKey(t,n){const r=new Ba(n,0),i=this.Hr.firstAfterOrEqual(r);return Qe.resolve(n.isEqual(i&&i.key))}performConsistencyCheck(t){return this.mutationQueue.length,Qe.resolve()}ei(t,n){return this.Xr(t)}Xr(t){return this.mutationQueue.length===0?0:t-this.mutationQueue[0].batchId}Zr(t){const n=this.Xr(t);return n<0||n>=this.mutationQueue.length?null:this.mutationQueue[n]}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Kue{constructor(t){this.ti=t,this.docs=(function(){return new ds(hn.comparator)})(),this.size=0}setIndexManager(t){this.indexManager=t}addEntry(t,n){const r=n.key,i=this.docs.get(r),a=i?i.size:0,o=this.ti(n);return this.docs=this.docs.insert(r,{document:n.mutableCopy(),size:o}),this.size+=o-a,this.indexManager.addToCollectionParentIndex(t,r.path.popLast())}removeEntry(t){const n=this.docs.get(t);n&&(this.docs=this.docs.remove(t),this.size-=n.size)}getEntry(t,n){const r=this.docs.get(n);return Qe.resolve(r?r.document.mutableCopy():qs.newInvalidDocument(n))}getEntries(t,n){let r=Ml();return n.forEach((i=>{const a=this.docs.get(i);r=r.insert(i,a?a.document.mutableCopy():qs.newInvalidDocument(i))})),Qe.resolve(r)}getDocumentsMatchingQuery(t,n,r,i){let a=Ml();const o=n.path,c=new hn(o.child("__id-9223372036854775808__")),h=this.docs.getIteratorFrom(c);for(;h.hasNext();){const{key:f,value:{document:m}}=h.getNext();if(!o.isPrefixOf(f.path))break;f.path.length>o.length+1||bj(N$(m),r)<=0||(i.has(m.key)||Iy(n,m))&&(a=a.insert(m.key,m.mutableCopy()))}return Qe.resolve(a)}getAllFromCollectionGroup(t,n,r,i){Cn(9500)}ni(t,n){return Qe.forEach(this.docs,(r=>n(r)))}newChangeBuffer(t){return new Yue(this)}getSize(t){return Qe.resolve(this.size)}}class Yue extends HH{constructor(t){super(),this.Mr=t}applyChanges(t){const n=[];return this.changes.forEach(((r,i)=>{i.isValidDocument()?n.push(this.Mr.addEntry(t,i)):this.Mr.removeEntry(r)})),Qe.waitFor(n)}getFromCache(t,n){return this.Mr.getEntry(t,n)}getAllFromCache(t,n){return this.Mr.getEntries(t,n)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Xue{constructor(t){this.persistence=t,this.ri=new Yd((n=>Yp(n)),ky),this.lastRemoteSnapshotVersion=rr.min(),this.highestTargetId=0,this.ii=0,this.si=new Bj,this.targetCount=0,this.oi=em._r()}forEachTarget(t,n){return this.ri.forEach(((r,i)=>n(i))),Qe.resolve()}getLastRemoteSnapshotVersion(t){return Qe.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return Qe.resolve(this.ii)}allocateTargetId(t){return this.highestTargetId=this.oi.next(),Qe.resolve(this.highestTargetId)}setTargetsMetadata(t,n,r){return r&&(this.lastRemoteSnapshotVersion=r),n>this.ii&&(this.ii=n),Qe.resolve()}lr(t){this.ri.set(t.target,t);const n=t.targetId;n>this.highestTargetId&&(this.oi=new em(n),this.highestTargetId=n),t.sequenceNumber>this.ii&&(this.ii=t.sequenceNumber)}addTargetData(t,n){return this.lr(n),this.targetCount+=1,Qe.resolve()}updateTargetData(t,n){return this.lr(n),Qe.resolve()}removeTargetData(t,n){return this.ri.delete(n.target),this.si.Gr(n.targetId),this.targetCount-=1,Qe.resolve()}removeTargets(t,n,r){let i=0;const a=[];return this.ri.forEach(((o,c)=>{c.sequenceNumber<=n&&r.get(c.targetId)===null&&(this.ri.delete(o),a.push(this.removeMatchingKeysForTargetId(t,c.targetId)),i++)})),Qe.waitFor(a).next((()=>i))}getTargetCount(t){return Qe.resolve(this.targetCount)}getTargetData(t,n){const r=this.ri.get(n)||null;return Qe.resolve(r)}addMatchingKeys(t,n,r){return this.si.$r(n,r),Qe.resolve()}removeMatchingKeys(t,n,r){this.si.Qr(n,r);const i=this.persistence.referenceDelegate,a=[];return i&&n.forEach((o=>{a.push(i.markPotentiallyOrphaned(t,o))})),Qe.waitFor(a)}removeMatchingKeysForTargetId(t,n){return this.si.Gr(n),Qe.resolve()}getMatchingKeysForTargetId(t,n){const r=this.si.jr(n);return Qe.resolve(r)}containsKey(t,n){return Qe.resolve(this.si.containsKey(n))}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class zj{constructor(t,n){this._i={},this.overlays={},this.ai=new ml(0),this.ui=!1,this.ui=!0,this.ci=new que,this.referenceDelegate=t(this),this.li=new Xue(this),this.indexManager=new Due,this.remoteDocumentCache=(function(i){return new Kue(i)})((r=>this.referenceDelegate.hi(r))),this.serializer=new OH(n),this.Pi=new Hue(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ui=!1,Promise.resolve()}get started(){return this.ui}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(t){return this.indexManager}getDocumentOverlayCache(t){let n=this.overlays[t.toKey()];return n||(n=new Gue,this.overlays[t.toKey()]=n),n}getMutationQueue(t,n){let r=this._i[t.toKey()];return r||(r=new Wue(n,this.referenceDelegate),this._i[t.toKey()]=r),r}getGlobalsCache(){return this.ci}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Pi}runTransaction(t,n,r){zt("MemoryPersistence","Starting transaction:",t);const i=new Que(this.ai.next());return this.referenceDelegate.Ti(),r(i).next((a=>this.referenceDelegate.Ei(i).next((()=>a)))).toPromise().then((a=>(i.raiseOnCommittedEvent(),a)))}Ii(t,n){return Qe.or(Object.values(this._i).map((r=>()=>r.containsKey(t,n))))}}class Que extends A${constructor(t){super(),this.currentSequenceNumber=t}}class XN{constructor(t){this.persistence=t,this.Ri=new Bj,this.Ai=null}static Vi(t){return new XN(t)}get di(){if(this.Ai)return this.Ai;throw Cn(60996)}addReference(t,n,r){return this.Ri.addReference(r,n),this.di.delete(r.toString()),Qe.resolve()}removeReference(t,n,r){return this.Ri.removeReference(r,n),this.di.add(r.toString()),Qe.resolve()}markPotentiallyOrphaned(t,n){return this.di.add(n.toString()),Qe.resolve()}removeTarget(t,n){this.Ri.Gr(n.targetId).forEach((i=>this.di.add(i.toString())));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(t,n.targetId).next((i=>{i.forEach((a=>this.di.add(a.toString())))})).next((()=>r.removeTargetData(t,n)))}Ti(){this.Ai=new Set}Ei(t){const n=this.persistence.getRemoteDocumentCache().newChangeBuffer();return Qe.forEach(this.di,(r=>{const i=hn.fromPath(r);return this.mi(t,i).next((a=>{a||n.removeEntry(i,rr.min())}))})).next((()=>(this.Ai=null,n.apply(t))))}updateLimboDocument(t,n){return this.mi(t,n).next((r=>{r?this.di.delete(n.toString()):this.di.add(n.toString())}))}hi(t){return 0}mi(t,n){return Qe.or([()=>Qe.resolve(this.Ri.containsKey(n)),()=>this.persistence.getTargetCache().containsKey(t,n),()=>this.persistence.Ii(t,n)])}}class t2{constructor(t,n){this.persistence=t,this.fi=new Yd((r=>So(r.path)),((r,i)=>r.isEqual(i))),this.garbageCollector=$H(this,n)}static Vi(t,n){return new t2(t,n)}Ti(){}Ei(t){return Qe.resolve()}forEachTarget(t,n){return this.persistence.getTargetCache().forEachTarget(t,n)}dr(t){const n=this.pr(t);return this.persistence.getTargetCache().getTargetCount(t).next((r=>n.next((i=>r+i))))}pr(t){let n=0;return this.mr(t,(r=>{n++})).next((()=>n))}mr(t,n){return Qe.forEach(this.fi,((r,i)=>this.wr(t,r,i).next((a=>a?Qe.resolve():n(i)))))}removeTargets(t,n,r){return this.persistence.getTargetCache().removeTargets(t,n,r)}removeOrphanedDocuments(t,n){let r=0;const i=this.persistence.getRemoteDocumentCache(),a=i.newChangeBuffer();return i.ni(t,(o=>this.wr(t,o,n).next((c=>{c||(r++,a.removeEntry(o,rr.min()))})))).next((()=>a.apply(t))).next((()=>r))}markPotentiallyOrphaned(t,n){return this.fi.set(n,t.currentSequenceNumber),Qe.resolve()}removeTarget(t,n){const r=n.withSequenceNumber(t.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(t,r)}addReference(t,n,r){return this.fi.set(r,t.currentSequenceNumber),Qe.resolve()}removeReference(t,n,r){return this.fi.set(r,t.currentSequenceNumber),Qe.resolve()}updateLimboDocument(t,n){return this.fi.set(n,t.currentSequenceNumber),Qe.resolve()}hi(t){let n=t.key.toString().length;return t.isFoundDocument()&&(n+=lw(t.data.value)),n}wr(t,n,r){return Qe.or([()=>this.persistence.Ii(t,n),()=>this.persistence.getTargetCache().containsKey(t,n),()=>{const i=this.fi.get(n);return Qe.resolve(i!==void 0&&i>r)}])}getCacheSize(t){return this.persistence.getRemoteDocumentCache().getSize(t)}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Zue{constructor(t){this.serializer=t}k(t,n,r,i){const a=new LN("createOrUpgrade",n);r<1&&i>=1&&((function(h){h.createObjectStore(Sy)})(t),(function(h){h.createObjectStore(F1,{keyPath:lce}),h.createObjectStore(Oc,{keyPath:MR,autoIncrement:!0}).createIndex(vp,LR,{unique:!0}),h.createObjectStore(Q0)})(t),SD(t),(function(h){h.createObjectStore(ap)})(t));let o=Qe.resolve();return r<3&&i>=3&&(r!==0&&((function(h){h.deleteObjectStore(J0),h.deleteObjectStore(Z0),h.deleteObjectStore(Tp)})(t),SD(t)),o=o.next((()=>(function(h){const f=h.store(Tp),m={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:rr.min().toTimestamp(),targetCount:0};return f.put(qw,m)})(a)))),r<4&&i>=4&&(r!==0&&(o=o.next((()=>(function(h,f){return f.store(Oc).J().next((y=>{h.deleteObjectStore(Oc),h.createObjectStore(Oc,{keyPath:MR,autoIncrement:!0}).createIndex(vp,LR,{unique:!0});const w=f.store(Oc),A=y.map((k=>w.put(k)));return Qe.waitFor(A)}))})(t,a)))),o=o.next((()=>{(function(h){h.createObjectStore(eg,{keyPath:xce})})(t)}))),r<5&&i>=5&&(o=o.next((()=>this.gi(a)))),r<6&&i>=6&&(o=o.next((()=>((function(h){h.createObjectStore($1)})(t),this.pi(a))))),r<7&&i>=7&&(o=o.next((()=>this.yi(a)))),r<8&&i>=8&&(o=o.next((()=>this.wi(t,a)))),r<9&&i>=9&&(o=o.next((()=>{(function(h){h.objectStoreNames.contains("remoteDocumentChanges")&&h.deleteObjectStore("remoteDocumentChanges")})(t)}))),r<10&&i>=10&&(o=o.next((()=>this.Si(a)))),r<11&&i>=11&&(o=o.next((()=>{(function(h){h.createObjectStore(BN,{keyPath:yce})})(t),(function(h){h.createObjectStore(zN,{keyPath:bce})})(t)}))),r<12&&i>=12&&(o=o.next((()=>{(function(h){const f=h.createObjectStore(VN,{keyPath:Sce});f.createIndex(Uk,kce,{unique:!1}),f.createIndex(O$,Cce,{unique:!1})})(t)}))),r<13&&i>=13&&(o=o.next((()=>(function(h){const f=h.createObjectStore(Gw,{keyPath:uce});f.createIndex(aw,dce),f.createIndex(C$,hce)})(t))).next((()=>this.bi(t,a))).next((()=>t.deleteObjectStore(ap)))),r<14&&i>=14&&(o=o.next((()=>this.Di(t,a)))),r<15&&i>=15&&(o=o.next((()=>(function(h){h.createObjectStore(Nj,{keyPath:vce,autoIncrement:!0}).createIndex(Lk,wce,{unique:!1}),h.createObjectStore(x1,{keyPath:Nce}).createIndex(j$,Ece,{unique:!1}),h.createObjectStore(y1,{keyPath:Ace}).createIndex(T$,_ce,{unique:!1})})(t)))),r<16&&i>=16&&(o=o.next((()=>{n.objectStore(x1).clear()})).next((()=>{n.objectStore(y1).clear()}))),r<17&&i>=17&&(o=o.next((()=>{(function(h){h.createObjectStore(Ej,{keyPath:Ice})})(t)}))),r<18&&i>=18&&EF()&&(o=o.next((()=>{n.objectStore(x1).clear()})).next((()=>{n.objectStore(y1).clear()}))),o}pi(t){let n=0;return t.store(ap).ee(((r,i)=>{n+=e2(i)})).next((()=>{const r={byteSize:n};return t.store($1).put(Mk,r)}))}gi(t){const n=t.store(F1),r=t.store(Oc);return n.J().next((i=>Qe.forEach(i,(a=>{const o=IDBKeyRange.bound([a.userId,jp],[a.userId,a.lastAcknowledgedBatchId]);return r.J(vp,o).next((c=>Qe.forEach(c,(h=>{Xn(h.userId===a.userId,18650,"Cannot process batch from unexpected user",{batchId:h.batchId});const f=fp(this.serializer,h);return UH(t,a.userId,f).next((()=>{}))}))))}))))}yi(t){const n=t.store(J0),r=t.store(ap);return t.store(Tp).get(qw).next((i=>{const a=[];return r.ee(((o,c)=>{const h=new Ei(o),f=(function(y){return[0,So(y)]})(h);a.push(n.get(f).next((m=>m?Qe.resolve():(y=>n.put({targetId:0,path:So(y),sequenceNumber:i.highestListenSequenceNumber}))(h))))})).next((()=>Qe.waitFor(a)))}))}wi(t,n){t.createObjectStore(H1,{keyPath:gce});const r=n.store(H1),i=new Uj,a=o=>{if(i.add(o)){const c=o.lastSegment(),h=o.popLast();return r.put({collectionId:c,parent:So(h)})}};return n.store(ap).ee({Y:!0},((o,c)=>{const h=new Ei(o);return a(h.popLast())})).next((()=>n.store(Q0).ee({Y:!0},(([o,c,h],f)=>{const m=wu(c);return a(m.popLast())}))))}Si(t){const n=t.store(Z0);return n.ee(((r,i)=>{const a=s1(i),o=PH(this.serializer,a);return n.put(o)}))}bi(t,n){const r=n.store(ap),i=[];return r.ee(((a,o)=>{const c=n.store(Gw),h=(function(y){return y.document?new hn(Ei.fromString(y.document.name).popFirst(5)):y.noDocument?hn.fromSegments(y.noDocument.path):y.unknownDocument?hn.fromSegments(y.unknownDocument.path):Cn(36783)})(o).path.toArray(),f={prefixPath:h.slice(0,h.length-2),collectionGroup:h[h.length-2],documentId:h[h.length-1],readTime:o.readTime||[0,0],unknownDocument:o.unknownDocument,noDocument:o.noDocument,document:o.document,hasCommittedMutations:!!o.hasCommittedMutations};i.push(c.put(f))})).next((()=>Qe.waitFor(i)))}Di(t,n){const r=n.store(Oc),i=GH(this.serializer),a=new zj(XN.Vi,this.serializer.yt);return r.J().next((o=>{const c=new Map;return o.forEach((h=>{let f=c.get(h.userId)??Gr();fp(this.serializer,h).keys().forEach((m=>f=f.add(m))),c.set(h.userId,f)})),Qe.forEach(c,((h,f)=>{const m=new vo(f),y=KN.wt(this.serializer,m),w=a.getIndexManager(m),A=YN.wt(m,this.serializer,w,a.referenceDelegate);return new qH(i,A,y,w).recalculateAndSaveOverlaysForDocumentKeys(new Bk(n,ml.ce),h).next()}))}))}}function SD(e){e.createObjectStore(J0,{keyPath:pce}).createIndex(wj,mce,{unique:!0}),e.createObjectStore(Z0,{keyPath:"targetId"}).createIndex(I$,fce,{unique:!0}),e.createObjectStore(Tp)}const Th="IndexedDbPersistence",H_=18e5,G_=5e3,q_="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",Jue="main";class Vj{constructor(t,n,r,i,a,o,c,h,f,m,y=18){if(this.allowTabSynchronization=t,this.persistenceKey=n,this.clientId=r,this.Ci=a,this.window=o,this.document=c,this.Fi=f,this.Mi=m,this.xi=y,this.ai=null,this.ui=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Oi=null,this.inForeground=!1,this.Ni=null,this.Bi=null,this.Li=Number.NEGATIVE_INFINITY,this.ki=w=>Promise.resolve(),!Vj.v())throw new Jt(bt.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new zue(this,i),this.qi=n+Jue,this.serializer=new OH(h),this.Ki=new af(this.qi,this.xi,new Zue(this.serializer)),this.ci=new Iue,this.li=new Lue(this.referenceDelegate,this.serializer),this.remoteDocumentCache=GH(this.serializer),this.Pi=new Cue,this.window&&this.window.localStorage?this.Ui=this.window.localStorage:(this.Ui=null,m===!1&&ea(Th,"LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.$i().then((()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new Jt(bt.FAILED_PRECONDITION,q_);return this.Wi(),this.Qi(),this.Gi(),this.runTransaction("getHighestListenSequenceNumber","readonly",(t=>this.li.getHighestSequenceNumber(t)))})).then((t=>{this.ai=new ml(t,this.Fi)})).then((()=>{this.ui=!0})).catch((t=>(this.Ki&&this.Ki.close(),Promise.reject(t))))}zi(t){return this.ki=async n=>{if(this.started)return t(n)},t(this.isPrimary)}setDatabaseDeletedListener(t){this.Ki.K((async n=>{n.newVersion===null&&await t()}))}setNetworkEnabled(t){this.networkEnabled!==t&&(this.networkEnabled=t,this.Ci.enqueueAndForget((async()=>{this.started&&await this.$i()})))}$i(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",(t=>mv(t).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next((()=>{if(this.isPrimary)return this.ji(t).next((n=>{n||(this.isPrimary=!1,this.Ci.enqueueRetryable((()=>this.ki(!1))))}))})).next((()=>this.Ji(t))).next((n=>this.isPrimary&&!n?this.Hi(t).next((()=>!1)):!!n&&this.Zi(t).next((()=>!0)))))).catch((t=>{if(Ef(t))return zt(Th,"Failed to extend owner lease: ",t),this.isPrimary;if(!this.allowTabSynchronization)throw t;return zt(Th,"Releasing owner lease after error during lease refresh",t),!1})).then((t=>{this.isPrimary!==t&&this.Ci.enqueueRetryable((()=>this.ki(t))),this.isPrimary=t}))}ji(t){return Tx(t).get(t0).next((n=>Qe.resolve(this.Xi(n))))}Yi(t){return mv(t).delete(this.clientId)}async es(){if(this.isPrimary&&!this.ts(this.Li,H_)){this.Li=Date.now();const t=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",(n=>{const r=Ia(n,eg);return r.J().next((i=>{const a=this.ns(i,H_),o=i.filter((c=>a.indexOf(c)===-1));return Qe.forEach(o,(c=>r.delete(c.clientId))).next((()=>o))}))})).catch((()=>[]));if(this.Ui)for(const n of t)this.Ui.removeItem(this.rs(n.clientId))}}Gi(){this.Bi=this.Ci.enqueueAfterDelay("client_metadata_refresh",4e3,(()=>this.$i().then((()=>this.es())).then((()=>this.Gi()))))}Xi(t){return!!t&&t.ownerId===this.clientId}Ji(t){return this.Mi?Qe.resolve(!0):Tx(t).get(t0).next((n=>{if(n!==null&&this.ts(n.leaseTimestampMs,G_)&&!this.ss(n.ownerId)){if(this.Xi(n)&&this.networkEnabled)return!0;if(!this.Xi(n)){if(!n.allowTabSynchronization)throw new Jt(bt.FAILED_PRECONDITION,q_);return!1}}return!(!this.networkEnabled||!this.inForeground)||mv(t).J().next((r=>this.ns(r,G_).find((i=>{if(this.clientId!==i.clientId){const a=!this.networkEnabled&&i.networkEnabled,o=!this.inForeground&&i.inForeground,c=this.networkEnabled===i.networkEnabled;if(a||o&&c)return!0}return!1}))===void 0))})).next((n=>(this.isPrimary!==n&&zt(Th,`Client ${n?"is":"is not"} eligible for a primary lease.`),n)))}async shutdown(){this.ui=!1,this._s(),this.Bi&&(this.Bi.cancel(),this.Bi=null),this.us(),this.cs(),await this.Ki.runTransaction("shutdown","readwrite",[Sy,eg],(t=>{const n=new Bk(t,ml.ce);return this.Hi(n).next((()=>this.Yi(n)))})),this.Ki.close(),this.ls()}ns(t,n){return t.filter((r=>this.ts(r.updateTimeMs,n)&&!this.ss(r.clientId)))}hs(){return this.runTransaction("getActiveClients","readonly",(t=>mv(t).J().next((n=>this.ns(n,H_).map((r=>r.clientId))))))}get started(){return this.ui}getGlobalsCache(){return this.ci}getMutationQueue(t,n){return YN.wt(t,this.serializer,n,this.referenceDelegate)}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(t){return new Mue(t,this.serializer.yt.databaseId)}getDocumentOverlayCache(t){return KN.wt(this.serializer,t)}getBundleCache(){return this.Pi}runTransaction(t,n,r){zt(Th,"Starting transaction:",t);const i=n==="readonly"?"readonly":"readwrite",a=(function(h){return h===18?Oce:h===17?M$:h===16?Tce:h===15?Aj:h===14?D$:h===13?R$:h===12?jce:h===11?P$:void Cn(60245)})(this.xi);let o;return this.Ki.runTransaction(t,i,a,(c=>(o=new Bk(c,this.ai?this.ai.next():ml.ce),n==="readwrite-primary"?this.ji(o).next((h=>!!h||this.Ji(o))).next((h=>{if(!h)throw ea(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.Ci.enqueueRetryable((()=>this.ki(!1))),new Jt(bt.FAILED_PRECONDITION,E$);return r(o)})).next((h=>this.Zi(o).next((()=>h)))):this.Ps(o).next((()=>r(o)))))).then((c=>(o.raiseOnCommittedEvent(),c)))}Ps(t){return Tx(t).get(t0).next((n=>{if(n!==null&&this.ts(n.leaseTimestampMs,G_)&&!this.ss(n.ownerId)&&!this.Xi(n)&&!(this.Mi||this.allowTabSynchronization&&n.allowTabSynchronization))throw new Jt(bt.FAILED_PRECONDITION,q_)}))}Zi(t){const n={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return Tx(t).put(t0,n)}static v(){return af.v()}Hi(t){const n=Tx(t);return n.get(t0).next((r=>this.Xi(r)?(zt(Th,"Releasing primary lease."),n.delete(t0)):Qe.resolve()))}ts(t,n){const r=Date.now();return!(tr)||(ea(`Detected an update time that is in the future: ${t} > ${r}`),!1))}Wi(){this.document!==null&&typeof this.document.addEventListener=="function"&&(this.Ni=()=>{this.Ci.enqueueAndForget((()=>(this.inForeground=this.document.visibilityState==="visible",this.$i())))},this.document.addEventListener("visibilitychange",this.Ni),this.inForeground=this.document.visibilityState==="visible")}us(){this.Ni&&(this.document.removeEventListener("visibilitychange",this.Ni),this.Ni=null)}Qi(){var t;typeof((t=this.window)==null?void 0:t.addEventListener)=="function"&&(this.Oi=()=>{this._s();const n=/(?:Version|Mobile)\/1[456]/;NF()&&(navigator.appVersion.match(n)||navigator.userAgent.match(n))&&this.Ci.enterRestrictedMode(!0),this.Ci.enqueueAndForget((()=>this.shutdown()))},this.window.addEventListener("pagehide",this.Oi))}cs(){this.Oi&&(this.window.removeEventListener("pagehide",this.Oi),this.Oi=null)}ss(t){var n;try{const r=((n=this.Ui)==null?void 0:n.getItem(this.rs(t)))!==null;return zt(Th,`Client '${t}' ${r?"is":"is not"} zombied in LocalStorage`),r}catch(r){return ea(Th,"Failed to get zombied client id.",r),!1}}_s(){if(this.Ui)try{this.Ui.setItem(this.rs(this.clientId),String(Date.now()))}catch(t){ea("Failed to set zombie client id.",t)}}ls(){if(this.Ui)try{this.Ui.removeItem(this.rs(this.clientId))}catch{}}rs(t){return`firestore_zombie_${this.persistenceKey}_${t}`}}function Tx(e){return Ia(e,Sy)}function mv(e){return Ia(e,eg)}function WH(e,t){let n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Fj{constructor(t,n,r,i){this.targetId=t,this.fromCache=n,this.Ts=r,this.Es=i}static Is(t,n){let r=Gr(),i=Gr();for(const a of n.docChanges)switch(a.type){case 0:r=r.add(a.doc.key);break;case 1:i=i.add(a.doc.key)}return new Fj(t,n.fromCache,r,i)}}/** * @license * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class ede{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(t){this._documentReadCount+=t}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class KH{constructor(){this.Rs=!1,this.As=!1,this.Vs=100,this.ds=(function(){return NF()?8:_$(ka())>0?6:4})()}initialize(t,n){this.fs=t,this.indexManager=n,this.Rs=!0}getDocumentsMatchingQuery(t,n,r,i){const a={result:null};return this.gs(t,n).next((o=>{a.result=o})).next((()=>{if(!a.result)return this.ps(t,n,i,r).next((o=>{a.result=o}))})).next((()=>{if(a.result)return;const o=new ede;return this.ys(t,n,o).next((c=>{if(a.result=c,this.As)return this.ws(t,n,o,c.size)}))})).next((()=>a.result))}ws(t,n,r,i){return r.documentReadCountthis.ds*i?(x0()<=ri.DEBUG&&zt("QueryEngine","The SDK decides to create cache indexes for query:",y0(n),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(t,zl(n))):Qe.resolve())}gs(t,n){if(XR(n))return Qe.resolve(null);let r=zl(n);return this.indexManager.getIndexType(t,r).next((i=>i===0?null:(n.limit!==null&&i===1&&(n=Yw(n,null,"F"),r=zl(n)),this.indexManager.getDocumentsMatchingTarget(t,r).next((a=>{const o=Gr(...a);return this.fs.getDocuments(t,o).next((c=>this.indexManager.getMinOffset(t,r).next((h=>{const f=this.Ss(n,c);return this.bs(n,f,o,h.readTime)?this.gs(t,Yw(n,null,"F")):this.Ds(t,f,n,h)}))))})))))}ps(t,n,r,i){return XR(n)||i.isEqual(rr.min())?Qe.resolve(null):this.fs.getDocuments(t,r).next((a=>{const o=this.Ss(n,a);return this.bs(n,o,r,i)?Qe.resolve(null):(x0()<=ri.DEBUG&&zt("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),y0(n)),this.Ds(t,o,n,w$(i,X0)).next((c=>c)))}))}Ss(t,n){let r=new $i(sH(t));return n.forEach(((i,a)=>{Iy(t,a)&&(r=r.add(a))})),r}bs(t,n,r,i){if(t.limit===null)return!1;if(r.size!==n.size)return!0;const a=t.limitType==="F"?n.last():n.first();return!!a&&(a.hasPendingWrites||a.version.compareTo(i)>0)}ys(t,n,r){return x0()<=ri.DEBUG&&zt("QueryEngine","Using full collection scan to execute query:",y0(n)),this.fs.getDocumentsMatchingQuery(t,n,$l.min(),r)}Ds(t,n,r,i){return this.fs.getDocumentsMatchingQuery(t,r,i).next((a=>(n.forEach((o=>{a=a.insert(o.key,o)})),a)))}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const $j="LocalStore",tde=3e8;class nde{constructor(t,n,r,i){this.persistence=t,this.Cs=n,this.serializer=i,this.vs=new ds(Er),this.Fs=new Yd((a=>Yp(a)),ky),this.Ms=new Map,this.xs=t.getRemoteDocumentCache(),this.li=t.getTargetCache(),this.Pi=t.getBundleCache(),this.Os(r)}Os(t){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(t),this.indexManager=this.persistence.getIndexManager(t),this.mutationQueue=this.persistence.getMutationQueue(t,this.indexManager),this.localDocuments=new qH(this.xs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.xs.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(n=>t.collect(n,this.vs)))}}function YH(e,t,n,r){return new nde(e,t,n,r)}async function XH(e,t){const n=zn(e);return await n.persistence.runTransaction("Handle user change","readonly",(r=>{let i;return n.mutationQueue.getAllMutationBatches(r).next((a=>(i=a,n.Os(t),n.mutationQueue.getAllMutationBatches(r)))).next((a=>{const o=[],c=[];let h=Gr();for(const f of i){o.push(f.batchId);for(const m of f.mutations)h=h.add(m.key)}for(const f of a){c.push(f.batchId);for(const m of f.mutations)h=h.add(m.key)}return n.localDocuments.getDocuments(r,h).next((f=>({Ns:f,removedBatchIds:o,addedBatchIds:c})))}))}))}function rde(e,t){const n=zn(e);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(r=>{const i=t.batch.keys(),a=n.xs.newChangeBuffer({trackRemovals:!0});return(function(c,h,f,m){const y=f.batch,w=y.keys();let A=Qe.resolve();return w.forEach((k=>{A=A.next((()=>m.getEntry(h,k))).next((I=>{const T=f.docVersions.get(k);Xn(T!==null,48541),I.version.compareTo(T)<0&&(y.applyToRemoteDocument(I,f),I.isValidDocument()&&(I.setReadTime(f.commitVersion),m.addEntry(I)))}))})),A.next((()=>c.mutationQueue.removeMutationBatch(h,y)))})(n,r,t,a).next((()=>a.apply(r))).next((()=>n.mutationQueue.performConsistencyCheck(r))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(r,i,t.batch.batchId))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,(function(c){let h=Gr();for(let f=0;f0&&(h=h.add(c.batch.mutations[f].key));return h})(t)))).next((()=>n.localDocuments.getDocuments(r,i)))}))}function QH(e){const t=zn(e);return t.persistence.runTransaction("Get last remote snapshot version","readonly",(n=>t.li.getLastRemoteSnapshotVersion(n)))}function ide(e,t){const n=zn(e),r=t.snapshotVersion;let i=n.vs;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(a=>{const o=n.xs.newChangeBuffer({trackRemovals:!0});i=n.vs;const c=[];t.targetChanges.forEach(((m,y)=>{const w=i.get(y);if(!w)return;c.push(n.li.removeMatchingKeys(a,m.removedDocuments,y).next((()=>n.li.addMatchingKeys(a,m.addedDocuments,y))));let A=w.withSequenceNumber(a.currentSequenceNumber);t.targetMismatches.get(y)!==null?A=A.withResumeToken(ta.EMPTY_BYTE_STRING,rr.min()).withLastLimboFreeSnapshotVersion(rr.min()):m.resumeToken.approximateByteSize()>0&&(A=A.withResumeToken(m.resumeToken,r)),i=i.insert(y,A),(function(I,T,D){return I.resumeToken.approximateByteSize()===0||T.snapshotVersion.toMicroseconds()-I.snapshotVersion.toMicroseconds()>=tde?!0:D.addedDocuments.size+D.modifiedDocuments.size+D.removedDocuments.size>0})(w,A,m)&&c.push(n.li.updateTargetData(a,A))}));let h=Ml(),f=Gr();if(t.documentUpdates.forEach((m=>{t.resolvedLimboDocuments.has(m)&&c.push(n.persistence.referenceDelegate.updateLimboDocument(a,m))})),c.push(sde(a,o,t.documentUpdates).next((m=>{h=m.Bs,f=m.Ls}))),!r.isEqual(rr.min())){const m=n.li.getLastRemoteSnapshotVersion(a).next((y=>n.li.setTargetsMetadata(a,a.currentSequenceNumber,r)));c.push(m)}return Qe.waitFor(c).next((()=>o.apply(a))).next((()=>n.localDocuments.getLocalViewOfDocuments(a,h,f))).next((()=>h))})).then((a=>(n.vs=i,a)))}function sde(e,t,n){let r=Gr(),i=Gr();return n.forEach((a=>r=r.add(a))),t.getEntries(e,r).next((a=>{let o=Ml();return n.forEach(((c,h)=>{const f=a.get(c);h.isFoundDocument()!==f.isFoundDocument()&&(i=i.add(c)),h.isNoDocument()&&h.version.isEqual(rr.min())?(t.removeEntry(c,h.readTime),o=o.insert(c,h)):!f.isValidDocument()||h.version.compareTo(f.version)>0||h.version.compareTo(f.version)===0&&f.hasPendingWrites?(t.addEntry(h),o=o.insert(c,h)):zt($j,"Ignoring outdated watch update for ",c,". Current version:",f.version," Watch version:",h.version)})),{Bs:o,Ls:i}}))}function ade(e,t){const n=zn(e);return n.persistence.runTransaction("Get next mutation batch","readonly",(r=>(t===void 0&&(t=jp),n.mutationQueue.getNextMutationBatchAfterBatchId(r,t))))}function n2(e,t){const n=zn(e);return n.persistence.runTransaction("Allocate target","readwrite",(r=>{let i;return n.li.getTargetData(r,t).next((a=>a?(i=a,Qe.resolve(i)):n.li.allocateTargetId(r).next((o=>(i=new Id(t,o,"TargetPurposeListen",r.currentSequenceNumber),n.li.addTargetData(r,i).next((()=>i)))))))})).then((r=>{const i=n.vs.get(r.targetId);return(i===null||r.snapshotVersion.compareTo(i.snapshotVersion)>0)&&(n.vs=n.vs.insert(r.targetId,r),n.Fs.set(t,r.targetId)),r}))}async function lg(e,t,n){const r=zn(e),i=r.vs.get(t),a=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",a,(o=>r.persistence.referenceDelegate.removeTarget(o,i)))}catch(o){if(!Ef(o))throw o;zt($j,`Failed to update sequence numbers for target ${t}: ${o}`)}r.vs=r.vs.remove(t),r.Fs.delete(i.target)}function eC(e,t,n){const r=zn(e);let i=rr.min(),a=Gr();return r.persistence.runTransaction("Execute query","readwrite",(o=>(function(h,f,m){const y=zn(h),w=y.Fs.get(m);return w!==void 0?Qe.resolve(y.vs.get(w)):y.li.getTargetData(f,m)})(r,o,zl(t)).next((c=>{if(c)return i=c.lastLimboFreeSnapshotVersion,r.li.getMatchingKeysForTargetId(o,c.targetId).next((h=>{a=h}))})).next((()=>r.Cs.getDocumentsMatchingQuery(o,t,n?i:rr.min(),n?a:Gr()))).next((c=>(eG(r,iH(t),c),{documents:c,ks:a})))))}function ZH(e,t){const n=zn(e),r=zn(n.li),i=n.vs.get(t);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",(a=>r.At(a,t).next((o=>o?o.target:null))))}function JH(e,t){const n=zn(e),r=n.Ms.get(t)||rr.min();return n.persistence.runTransaction("Get new document changes","readonly",(i=>n.xs.getAllFromCollectionGroup(i,t,w$(r,X0),Number.MAX_SAFE_INTEGER))).then((i=>(eG(n,t,i),i)))}function eG(e,t,n){let r=e.Ms.get(t)||rr.min();n.forEach(((i,a)=>{a.readTime.compareTo(r)>0&&(r=a.readTime)})),e.Ms.set(t,r)}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const tG="firestore_clients";function kD(e,t){return`${tG}_${e}_${t}`}const nG="firestore_mutations";function CD(e,t,n){let r=`${nG}_${e}_${n}`;return t.isAuthenticated()&&(r+=`_${t.uid}`),r}const rG="firestore_targets";function W_(e,t){return`${rG}_${e}_${t}`}/** * @license * Copyright 2018 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const gu="SharedClientState";class r2{constructor(t,n,r,i){this.user=t,this.batchId=n,this.state=r,this.error=i}static $s(t,n,r){const i=JSON.parse(r);let a,o=typeof i=="object"&&["pending","acknowledged","rejected"].indexOf(i.state)!==-1&&(i.error===void 0||typeof i.error=="object");return o&&i.error&&(o=typeof i.error.message=="string"&&typeof i.error.code=="string",o&&(a=new Jt(i.error.code,i.error.message))),o?new r2(t,n,i.state,a):(ea(gu,`Failed to parse mutation state for ID '${n}': ${r}`),null)}Ws(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class E1{constructor(t,n,r){this.targetId=t,this.state=n,this.error=r}static $s(t,n){const r=JSON.parse(n);let i,a=typeof r=="object"&&["not-current","current","rejected"].indexOf(r.state)!==-1&&(r.error===void 0||typeof r.error=="object");return a&&r.error&&(a=typeof r.error.message=="string"&&typeof r.error.code=="string",a&&(i=new Jt(r.error.code,r.error.message))),a?new E1(t,r.state,i):(ea(gu,`Failed to parse target state for ID '${t}': ${n}`),null)}Ws(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class i2{constructor(t,n){this.clientId=t,this.activeTargetIds=n}static $s(t,n){const r=JSON.parse(n);let i=typeof r=="object"&&r.activeTargetIds instanceof Array,a=Ij();for(let o=0;i&&othis.shutdown())),this.started=!0}writeSequenceNumber(t){this.setItem(this.Ys,JSON.stringify(t))}getAllActiveQueryTargets(){return this.uo(this.Hs)}isActiveQueryTarget(t){let n=!1;return this.Hs.forEach(((r,i)=>{i.activeTargetIds.has(t)&&(n=!0)})),n}addPendingMutation(t){this.co(t,"pending")}updateMutationState(t,n,r){this.co(t,n,r),this.lo(t)}addLocalQueryTarget(t,n=!0){let r="not-current";if(this.isActiveQueryTarget(t)){const i=this.storage.getItem(W_(this.persistenceKey,t));if(i){const a=E1.$s(t,i);a&&(r=a.state)}}return n&&this.ho.Qs(t),this.oo(),r}removeLocalQueryTarget(t){this.ho.Gs(t),this.oo()}isLocalQueryTarget(t){return this.ho.activeTargetIds.has(t)}clearQueryState(t){this.removeItem(W_(this.persistenceKey,t))}updateQueryState(t,n,r){this.Po(t,n,r)}handleUserChange(t,n,r){n.forEach((i=>{this.lo(i)})),this.currentUser=t,r.forEach((i=>{this.addPendingMutation(i)}))}setOnlineState(t){this.To(t)}notifyBundleLoaded(t){this.Eo(t)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.js),this.removeItem(this.Xs),this.started=!1)}getItem(t){const n=this.storage.getItem(t);return zt(gu,"READ",t,n),n}setItem(t,n){zt(gu,"SET",t,n),this.storage.setItem(t,n)}removeItem(t){zt(gu,"REMOVE",t),this.storage.removeItem(t)}Js(t){const n=t;if(n.storageArea===this.storage){if(zt(gu,"EVENT",n.key,n.newValue),n.key===this.Xs)return void ea("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Ci.enqueueRetryable((async()=>{if(this.started){if(n.key!==null){if(this.eo.test(n.key)){if(n.newValue==null){const r=this.Io(n.key);return this.Ro(r,null)}{const r=this.Ao(n.key,n.newValue);if(r)return this.Ro(r.clientId,r)}}else if(this.no.test(n.key)){if(n.newValue!==null){const r=this.Vo(n.key,n.newValue);if(r)return this.mo(r)}}else if(this.ro.test(n.key)){if(n.newValue!==null){const r=this.fo(n.key,n.newValue);if(r)return this.po(r)}}else if(n.key===this.io){if(n.newValue!==null){const r=this._o(n.newValue);if(r)return this.ao(r)}}else if(n.key===this.Ys){const r=(function(a){let o=ml.ce;if(a!=null)try{const c=JSON.parse(a);Xn(typeof c=="number",30636,{yo:a}),o=c}catch(c){ea(gu,"Failed to read sequence number from WebStorage",c)}return o})(n.newValue);r!==ml.ce&&this.sequenceNumberHandler(r)}else if(n.key===this.so){const r=this.wo(n.newValue);await Promise.all(r.map((i=>this.syncEngine.So(i))))}}}else this.Zs.push(n)}))}}get ho(){return this.Hs.get(this.zs)}oo(){this.setItem(this.Xs,this.ho.Ws())}co(t,n,r){const i=new r2(this.currentUser,t,n,r),a=CD(this.persistenceKey,this.currentUser,t);this.setItem(a,i.Ws())}lo(t){const n=CD(this.persistenceKey,this.currentUser,t);this.removeItem(n)}To(t){const n={clientId:this.zs,onlineState:t};this.storage.setItem(this.io,JSON.stringify(n))}Po(t,n,r){const i=W_(this.persistenceKey,t),a=new E1(t,n,r);this.setItem(i,a.Ws())}Eo(t){const n=JSON.stringify(Array.from(t));this.setItem(this.so,n)}Io(t){const n=this.eo.exec(t);return n?n[1]:null}Ao(t,n){const r=this.Io(t);return i2.$s(r,n)}Vo(t,n){const r=this.no.exec(t),i=Number(r[1]),a=r[2]!==void 0?r[2]:null;return r2.$s(new vo(a),i,n)}fo(t,n){const r=this.ro.exec(t),i=Number(r[1]);return E1.$s(i,n)}_o(t){return Hj.$s(t)}wo(t){return JSON.parse(t)}async mo(t){if(t.user.uid===this.currentUser.uid)return this.syncEngine.bo(t.batchId,t.state,t.error);zt(gu,`Ignoring mutation for non-active user ${t.user.uid}`)}po(t){return this.syncEngine.Do(t.targetId,t.state,t.error)}Ro(t,n){const r=n?this.Hs.insert(t,n):this.Hs.remove(t),i=this.uo(this.Hs),a=this.uo(r),o=[],c=[];return a.forEach((h=>{i.has(h)||o.push(h)})),i.forEach((h=>{a.has(h)||c.push(h)})),this.syncEngine.Co(o,c).then((()=>{this.Hs=r}))}ao(t){this.Hs.get(t.clientId)&&this.onlineStateHandler(t.onlineState)}uo(t){let n=Ij();return t.forEach(((r,i)=>{n=n.unionWith(i.activeTargetIds)})),n}}class iG{constructor(){this.vo=new tC,this.Fo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,n,r){}addLocalQueryTarget(t,n=!0){return n&&this.vo.Qs(t),this.Fo[t]||"not-current"}updateQueryState(t,n,r){this.Fo[t]=n}removeLocalQueryTarget(t){this.vo.Gs(t)}isLocalQueryTarget(t){return this.vo.activeTargetIds.has(t)}clearQueryState(t){delete this.Fo[t]}getAllActiveQueryTargets(){return this.vo.activeTargetIds}isActiveQueryTarget(t){return this.vo.activeTargetIds.has(t)}start(){return this.vo=new tC,Promise.resolve()}handleUserChange(t,n,r){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(t){}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class ode{Mo(t){}shutdown(){}}/** * @license * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const ID="ConnectivityMonitor";class jD{constructor(){this.xo=()=>this.Oo(),this.No=()=>this.Bo(),this.Lo=[],this.ko()}Mo(t){this.Lo.push(t)}shutdown(){window.removeEventListener("online",this.xo),window.removeEventListener("offline",this.No)}ko(){window.addEventListener("online",this.xo),window.addEventListener("offline",this.No)}Oo(){zt(ID,"Network connectivity changed: AVAILABLE");for(const t of this.Lo)t(0)}Bo(){zt(ID,"Network connectivity changed: UNAVAILABLE");for(const t of this.Lo)t(1)}static v(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/** * @license * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */let gv=null;function nC(){return gv===null?gv=(function(){return 268435456+Math.round(2147483648*Math.random())})():gv++,"0x"+gv.toString(16)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const Y_="RestConnection",lde={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class cde{get qo(){return!1}constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const n=t.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),i=encodeURIComponent(this.databaseId.database);this.Ko=n+"://"+t.host,this.Uo=`projects/${r}/databases/${i}`,this.$o=this.databaseId.database===zk?`project_id=${r}`:`project_id=${r}&database_id=${i}`}Wo(t,n,r,i,a){const o=nC(),c=this.Qo(t,n.toUriEncodedString());zt(Y_,`Sending RPC '${t}' ${o}:`,c,r);const h={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.$o};this.Go(h,i,a);const{host:f}=new URL(c),m=vy(f);return this.zo(t,c,h,r,m).then((y=>(zt(Y_,`Received RPC '${t}' ${o}: `,y),y)),(y=>{throw K0(Y_,`RPC '${t}' ${o} failed with error: `,y,"url: ",c,"request:",r),y}))}jo(t,n,r,i,a,o){return this.Wo(t,n,r,i,a)}Go(t,n,r){t["X-Goog-Api-Client"]=(function(){return"gl-js/ fire/"+kg})(),t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),n&&n.headers.forEach(((i,a)=>t[a]=i)),r&&r.headers.forEach(((i,a)=>t[a]=i))}Qo(t,n){const r=lde[t];let i=`${this.Ko}/v1/${n}:${r}`;return this.databaseInfo.apiKey&&(i=`${i}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),i}terminate(){}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class ude{constructor(t){this.Jo=t.Jo,this.Ho=t.Ho}Zo(t){this.Xo=t}Yo(t){this.e_=t}t_(t){this.n_=t}onMessage(t){this.r_=t}close(){this.Ho()}send(t){this.Jo(t)}i_(){this.Xo()}s_(){this.e_()}o_(t){this.n_(t)}__(t){this.r_(t)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const yo="WebChannelConnection",Ox=(e,t,n)=>{e.listen(t,(r=>{try{n(r)}catch(i){setTimeout((()=>{throw i}),0)}}))};class M0 extends cde{constructor(t){super(t),this.a_=[],this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams,this.longPollingOptions=t.longPollingOptions}static u_(){if(!M0.c_){const t=g$();Ox(t,m$.STAT_EVENT,(n=>{n.stat===Pk.PROXY?zt(yo,"STAT_EVENT: detected buffering proxy"):n.stat===Pk.NOPROXY&&zt(yo,"STAT_EVENT: detected no buffering proxy")})),M0.c_=!0}}zo(t,n,r,i,a){const o=nC();return new Promise(((c,h)=>{const f=new f$;f.setWithCredentials(!0),f.listenOnce(p$.COMPLETE,(()=>{try{switch(f.getLastErrorCode()){case rw.NO_ERROR:const y=f.getResponseJson();zt(yo,`XHR for RPC '${t}' ${o} received:`,JSON.stringify(y)),c(y);break;case rw.TIMEOUT:zt(yo,`RPC '${t}' ${o} timed out`),h(new Jt(bt.DEADLINE_EXCEEDED,"Request time out"));break;case rw.HTTP_ERROR:const w=f.getStatus();if(zt(yo,`RPC '${t}' ${o} failed with status:`,w,"response text:",f.getResponseText()),w>0){let A=f.getResponseJson();Array.isArray(A)&&(A=A[0]);const k=A==null?void 0:A.error;if(k&&k.status&&k.message){const I=(function(D){const F=D.toLowerCase().replace(/_/g,"-");return Object.values(bt).indexOf(F)>=0?F:bt.UNKNOWN})(k.status);h(new Jt(I,k.message))}else h(new Jt(bt.UNKNOWN,"Server responded with status "+f.getStatus()))}else h(new Jt(bt.UNAVAILABLE,"Connection failed."));break;default:Cn(9055,{l_:t,streamId:o,h_:f.getLastErrorCode(),P_:f.getLastError()})}}finally{zt(yo,`RPC '${t}' ${o} completed.`)}}));const m=JSON.stringify(i);zt(yo,`RPC '${t}' ${o} sending request:`,i),f.send(n,"POST",m,r,15)}))}T_(t,n,r){const i=nC(),a=[this.Ko,"/","google.firestore.v1.Firestore","/",t,"/channel"],o=this.createWebChannelTransport(),c={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},h=this.longPollingOptions.timeoutSeconds;h!==void 0&&(c.longPollingTimeout=Math.round(1e3*h)),this.useFetchStreams&&(c.useFetchStreams=!0),this.Go(c.initMessageHeaders,n,r),c.encodeInitMessageHeaders=!0;const f=a.join("");zt(yo,`Creating RPC '${t}' stream ${i}: ${f}`,c);const m=o.createWebChannel(f,c);this.E_(m);let y=!1,w=!1;const A=new ude({Jo:k=>{w?zt(yo,`Not sending because RPC '${t}' stream ${i} is closed:`,k):(y||(zt(yo,`Opening RPC '${t}' stream ${i} transport.`),m.open(),y=!0),zt(yo,`RPC '${t}' stream ${i} sending:`,k),m.send(k))},Ho:()=>m.close()});return Ox(m,n1.EventType.OPEN,(()=>{w||(zt(yo,`RPC '${t}' stream ${i} transport opened.`),A.i_())})),Ox(m,n1.EventType.CLOSE,(()=>{w||(w=!0,zt(yo,`RPC '${t}' stream ${i} transport closed`),A.o_(),this.I_(m))})),Ox(m,n1.EventType.ERROR,(k=>{w||(w=!0,K0(yo,`RPC '${t}' stream ${i} transport errored. Name:`,k.name,"Message:",k.message),A.o_(new Jt(bt.UNAVAILABLE,"The operation could not be completed")))})),Ox(m,n1.EventType.MESSAGE,(k=>{var I;if(!w){const T=k.data[0];Xn(!!T,16349);const D=T,F=(D==null?void 0:D.error)||((I=D[0])==null?void 0:I.error);if(F){zt(yo,`RPC '${t}' stream ${i} received error:`,F);const L=F.status;let q=(function(z){const B=la[z];if(B!==void 0)return yH(B)})(L),Z=F.message;L==="NOT_FOUND"&&Z.includes("database")&&Z.includes("does not exist")&&Z.includes(this.databaseId.database)&&K0(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),q===void 0&&(q=bt.INTERNAL,Z="Unknown error status: "+L+" with message "+F.message),w=!0,A.o_(new Jt(q,Z)),m.close()}else zt(yo,`RPC '${t}' stream ${i} received:`,T),A.__(T)}})),M0.u_(),setTimeout((()=>{A.s_()}),0),A}terminate(){this.a_.forEach((t=>t.close())),this.a_=[]}E_(t){this.a_.push(t)}I_(t){this.a_=this.a_.filter((n=>n===t))}Go(t,n,r){super.Go(t,n,r),this.databaseInfo.apiKey&&(t["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return x$()}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function dde(e){return new M0(e)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function sG(){return typeof window<"u"?window:null}function fw(){return typeof document<"u"?document:null}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function QN(e){return new gue(e,!0)}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */M0.c_=!1;class aG{constructor(t,n,r=1e3,i=1.5,a=6e4){this.Ci=t,this.timerId=n,this.R_=r,this.A_=i,this.V_=a,this.d_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.d_=0}g_(){this.d_=this.V_}p_(t){this.cancel();const n=Math.floor(this.d_+this.y_()),r=Math.max(0,Date.now()-this.f_),i=Math.max(0,n-r);i>0&&zt("ExponentialBackoff",`Backing off for ${i} ms (base delay: ${this.d_} ms, delay with jitter: ${n} ms, last attempt: ${r} ms ago)`),this.m_=this.Ci.enqueueAfterDelay(this.timerId,i,(()=>(this.f_=Date.now(),t()))),this.d_*=this.A_,this.d_this.V_&&(this.d_=this.V_)}w_(){this.m_!==null&&(this.m_.skipDelay(),this.m_=null)}cancel(){this.m_!==null&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.d_}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const TD="PersistentStream";class oG{constructor(t,n,r,i,a,o,c,h){this.Ci=t,this.S_=r,this.b_=i,this.connection=a,this.authCredentialsProvider=o,this.appCheckCredentialsProvider=c,this.listener=h,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new aG(t,n)}x_(){return this.state===1||this.state===5||this.O_()}O_(){return this.state===2||this.state===3}start(){this.F_=0,this.state!==4?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&this.C_===null&&(this.C_=this.Ci.enqueueAfterDelay(this.S_,6e4,(()=>this.k_())))}q_(t){this.K_(),this.stream.send(t)}async k_(){if(this.O_())return this.close(0)}K_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(t,n){this.K_(),this.U_(),this.M_.cancel(),this.D_++,t!==4?this.M_.reset():n&&n.code===bt.RESOURCE_EXHAUSTED?(ea(n.toString()),ea("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):n&&n.code===bt.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.W_(),this.stream.close(),this.stream=null),this.state=t,await this.listener.t_(n)}W_(){}auth(){this.state=1;const t=this.Q_(this.D_),n=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([r,i])=>{this.D_===n&&this.G_(r,i)}),(r=>{t((()=>{const i=new Jt(bt.UNKNOWN,"Fetching auth token failed: "+r.message);return this.z_(i)}))}))}G_(t,n){const r=this.Q_(this.D_);this.stream=this.j_(t,n),this.stream.Zo((()=>{r((()=>this.listener.Zo()))})),this.stream.Yo((()=>{r((()=>(this.state=2,this.v_=this.Ci.enqueueAfterDelay(this.b_,1e4,(()=>(this.O_()&&(this.state=3),Promise.resolve()))),this.listener.Yo())))})),this.stream.t_((i=>{r((()=>this.z_(i)))})),this.stream.onMessage((i=>{r((()=>++this.F_==1?this.J_(i):this.onNext(i)))}))}N_(){this.state=5,this.M_.p_((async()=>{this.state=0,this.start()}))}z_(t){return zt(TD,`close with error: ${t}`),this.stream=null,this.close(4,t)}Q_(t){return n=>{this.Ci.enqueueAndForget((()=>this.D_===t?n():(zt(TD,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class hde extends oG{constructor(t,n,r,i,a,o){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",n,r,i,o),this.serializer=a}j_(t,n){return this.connection.T_("Listen",t,n)}J_(t){return this.onNext(t)}onNext(t){this.M_.reset();const n=bue(this.serializer,t),r=(function(a){if(!("targetChange"in a))return rr.min();const o=a.targetChange;return o.targetIds&&o.targetIds.length?rr.min():o.readTime?Wo(o.readTime):rr.min()})(t);return this.listener.H_(n,r)}Z_(t){const n={};n.database=Yk(this.serializer),n.addTarget=(function(a,o){let c;const h=o.target;if(c=Ww(h)?{documents:SH(a,h)}:{query:Mj(a,h).ft},c.targetId=o.targetId,o.resumeToken.approximateByteSize()>0){c.resumeToken=wH(a,o.resumeToken);const f=Wk(a,o.expectedCount);f!==null&&(c.expectedCount=f)}else if(o.snapshotVersion.compareTo(rr.min())>0){c.readTime=og(a,o.snapshotVersion.toTimestamp());const f=Wk(a,o.expectedCount);f!==null&&(c.expectedCount=f)}return c})(this.serializer,t);const r=Nue(this.serializer,t);r&&(n.labels=r),this.q_(n)}X_(t){const n={};n.database=Yk(this.serializer),n.removeTarget=t,this.q_(n)}}class fde extends oG{constructor(t,n,r,i,a,o){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",n,r,i,o),this.serializer=a}get Y_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}W_(){this.Y_&&this.ea([])}j_(t,n){return this.connection.T_("Write",t,n)}J_(t){return Xn(!!t.streamToken,31322),this.lastStreamToken=t.streamToken,Xn(!t.writeResults||t.writeResults.length===0,55816),this.listener.ta()}onNext(t){Xn(!!t.streamToken,12678),this.lastStreamToken=t.streamToken,this.M_.reset();const n=vue(t.writeResults,t.commitTime),r=Wo(t.commitTime);return this.listener.na(r,n)}ra(){const t={};t.database=Yk(this.serializer),this.q_(t)}ea(t){const n={streamToken:this.lastStreamToken,writes:t.map((r=>Qw(this.serializer,r)))};this.q_(n)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class pde{}class mde extends pde{constructor(t,n,r,i){super(),this.authCredentials=t,this.appCheckCredentials=n,this.connection=r,this.serializer=i,this.ia=!1}sa(){if(this.ia)throw new Jt(bt.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(t,n,r,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,o])=>this.connection.Wo(t,Kk(n,r),i,a,o))).catch((a=>{throw a.name==="FirebaseError"?(a.code===bt.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new Jt(bt.UNKNOWN,a.toString())}))}jo(t,n,r,i,a){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([o,c])=>this.connection.jo(t,Kk(n,r),i,o,c,a))).catch((o=>{throw o.name==="FirebaseError"?(o.code===bt.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),o):new Jt(bt.UNKNOWN,o.toString())}))}terminate(){this.ia=!0,this.connection.terminate()}}function gde(e,t,n,r){return new mde(e,t,n,r)}class xde{constructor(t,n){this.asyncQueue=t,this.onlineStateHandler=n,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){this.oa===0&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve()))))}ha(t){this.state==="Online"?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${t.toString()}`),this.ca("Offline")))}set(t){this.Pa(),this.oa=0,t==="Online"&&(this.aa=!1),this.ca(t)}ca(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))}la(t){const n=`Could not reach Cloud Firestore backend. ${t} 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.aa?(ea(n),this.aa=!1):zt("OnlineStateTracker",n)}Pa(){this._a!==null&&(this._a.cancel(),this._a=null)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const tm="RemoteStore";class yde{constructor(t,n,r,i,a){this.localStore=t,this.datastore=n,this.asyncQueue=r,this.remoteSyncer={},this.Ta=[],this.Ea=new Map,this.Ia=new Set,this.Ra=[],this.Aa=a,this.Aa.Mo((o=>{r.enqueueAndForget((async()=>{fm(this)&&(zt(tm,"Restarting streams for network reachability change."),await(async function(h){const f=zn(h);f.Ia.add(4),await Py(f),f.Va.set("Unknown"),f.Ia.delete(4),await ZN(f)})(this))}))})),this.Va=new xde(r,i)}}async function ZN(e){if(fm(e))for(const t of e.Ra)await t(!0)}async function Py(e){for(const t of e.Ra)await t(!1)}function JN(e,t){const n=zn(e);n.Ea.has(t.targetId)||(n.Ea.set(t.targetId,t),Wj(n)?qj(n):jg(n).O_()&&Gj(n,t))}function cg(e,t){const n=zn(e),r=jg(n);n.Ea.delete(t),r.O_()&&lG(n,t),n.Ea.size===0&&(r.O_()?r.L_():fm(n)&&n.Va.set("Unknown"))}function Gj(e,t){if(e.da.$e(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(rr.min())>0){const n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}jg(e).Z_(t)}function lG(e,t){e.da.$e(t),jg(e).X_(t)}function qj(e){e.da=new hue({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),At:t=>e.Ea.get(t)||null,ht:()=>e.datastore.serializer.databaseId}),jg(e).start(),e.Va.ua()}function Wj(e){return fm(e)&&!jg(e).x_()&&e.Ea.size>0}function fm(e){return zn(e).Ia.size===0}function cG(e){e.da=void 0}async function bde(e){e.Va.set("Online")}async function vde(e){e.Ea.forEach(((t,n)=>{Gj(e,t)}))}async function wde(e,t){cG(e),Wj(e)?(e.Va.ha(t),qj(e)):e.Va.set("Unknown")}async function Nde(e,t,n){if(e.Va.set("Online"),t instanceof vH&&t.state===2&&t.cause)try{await(async function(i,a){const o=a.cause;for(const c of a.targetIds)i.Ea.has(c)&&(await i.remoteSyncer.rejectListen(c,o),i.Ea.delete(c),i.da.removeTarget(c))})(e,t)}catch(r){zt(tm,"Failed to remove targets %s: %s ",t.targetIds.join(","),r),await s2(e,r)}else if(t instanceof dw?e.da.Xe(t):t instanceof bH?e.da.st(t):e.da.tt(t),!n.isEqual(rr.min()))try{const r=await QH(e.localStore);n.compareTo(r)>=0&&await(function(a,o){const c=a.da.Tt(o);return c.targetChanges.forEach(((h,f)=>{if(h.resumeToken.approximateByteSize()>0){const m=a.Ea.get(f);m&&a.Ea.set(f,m.withResumeToken(h.resumeToken,o))}})),c.targetMismatches.forEach(((h,f)=>{const m=a.Ea.get(h);if(!m)return;a.Ea.set(h,m.withResumeToken(ta.EMPTY_BYTE_STRING,m.snapshotVersion)),lG(a,h);const y=new Id(m.target,h,f,m.sequenceNumber);Gj(a,y)})),a.remoteSyncer.applyRemoteEvent(c)})(e,n)}catch(r){zt(tm,"Failed to raise snapshot:",r),await s2(e,r)}}async function s2(e,t,n){if(!Ef(t))throw t;e.Ia.add(1),await Py(e),e.Va.set("Offline"),n||(n=()=>QH(e.localStore)),e.asyncQueue.enqueueRetryable((async()=>{zt(tm,"Retrying IndexedDB access"),await n(),e.Ia.delete(1),await ZN(e)}))}function uG(e,t){return t().catch((n=>s2(e,n,t)))}async function Ig(e){const t=zn(e),n=pf(t);let r=t.Ta.length>0?t.Ta[t.Ta.length-1].batchId:jp;for(;Ede(t);)try{const i=await ade(t.localStore,r);if(i===null){t.Ta.length===0&&n.L_();break}r=i.batchId,Ade(t,i)}catch(i){await s2(t,i)}dG(t)&&hG(t)}function Ede(e){return fm(e)&&e.Ta.length<10}function Ade(e,t){e.Ta.push(t);const n=pf(e);n.O_()&&n.Y_&&n.ea(t.mutations)}function dG(e){return fm(e)&&!pf(e).x_()&&e.Ta.length>0}function hG(e){pf(e).start()}async function _de(e){pf(e).ra()}async function Sde(e){const t=pf(e);for(const n of e.Ta)t.ea(n.mutations)}async function kde(e,t,n){const r=e.Ta.shift(),i=Oj.from(r,t,n);await uG(e,(()=>e.remoteSyncer.applySuccessfulWrite(i))),await Ig(e)}async function Cde(e,t){t&&pf(e).Y_&&await(async function(r,i){if((function(o){return cue(o)&&o!==bt.ABORTED})(i.code)){const a=r.Ta.shift();pf(r).B_(),await uG(r,(()=>r.remoteSyncer.rejectFailedWrite(a.batchId,i))),await Ig(r)}})(e,t),dG(e)&&hG(e)}async function OD(e,t){const n=zn(e);n.asyncQueue.verifyOperationInProgress(),zt(tm,"RemoteStore received new credentials");const r=fm(n);n.Ia.add(3),await Py(n),r&&n.Va.set("Unknown"),await n.remoteSyncer.handleCredentialChange(t),n.Ia.delete(3),await ZN(n)}async function rC(e,t){const n=zn(e);t?(n.Ia.delete(2),await ZN(n)):t||(n.Ia.add(2),await Py(n),n.Va.set("Unknown"))}function jg(e){return e.ma||(e.ma=(function(n,r,i){const a=zn(n);return a.sa(),new hde(r,a.connection,a.authCredentials,a.appCheckCredentials,a.serializer,i)})(e.datastore,e.asyncQueue,{Zo:bde.bind(null,e),Yo:vde.bind(null,e),t_:wde.bind(null,e),H_:Nde.bind(null,e)}),e.Ra.push((async t=>{t?(e.ma.B_(),Wj(e)?qj(e):e.Va.set("Unknown")):(await e.ma.stop(),cG(e))}))),e.ma}function pf(e){return e.fa||(e.fa=(function(n,r,i){const a=zn(n);return a.sa(),new fde(r,a.connection,a.authCredentials,a.appCheckCredentials,a.serializer,i)})(e.datastore,e.asyncQueue,{Zo:()=>Promise.resolve(),Yo:_de.bind(null,e),t_:Cde.bind(null,e),ta:Sde.bind(null,e),na:kde.bind(null,e)}),e.Ra.push((async t=>{t?(e.fa.B_(),await Ig(e)):(await e.fa.stop(),e.Ta.length>0&&(zt(tm,`Stopping write stream with ${e.Ta.length} pending writes`),e.Ta=[]))}))),e.fa}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Kj{constructor(t,n,r,i,a){this.asyncQueue=t,this.timerId=n,this.targetTimeMs=r,this.op=i,this.removalCallback=a,this.deferred=new Uc,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((o=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(t,n,r,i,a){const o=Date.now()+r,c=new Kj(t,n,o,i,a);return c.start(r),c}start(t){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new Jt(bt.CANCELLED,"Operation cancelled"+(t?": "+t:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then((t=>this.deferred.resolve(t)))):Promise.resolve()))}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function Yj(e,t){if(ea("AsyncQueue",`${t}: ${e}`),Ef(e))return new Jt(bt.UNAVAILABLE,`${t}: ${e}`);throw e}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class L0{static emptySet(t){return new L0(t.comparator)}constructor(t){this.comparator=t?(n,r)=>t(n,r)||hn.comparator(n.key,r.key):(n,r)=>hn.comparator(n.key,r.key),this.keyedMap=r1(),this.sortedSet=new ds(this.comparator)}has(t){return this.keyedMap.get(t)!=null}get(t){return this.keyedMap.get(t)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(t){const n=this.keyedMap.get(t);return n?this.sortedSet.indexOf(n):-1}get size(){return this.sortedSet.size}forEach(t){this.sortedSet.inorderTraversal(((n,r)=>(t(n),!1)))}add(t){const n=this.delete(t.key);return n.copy(n.keyedMap.insert(t.key,t),n.sortedSet.insert(t,null))}delete(t){const n=this.get(t);return n?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(n)):this}isEqual(t){if(!(t instanceof L0)||this.size!==t.size)return!1;const n=this.sortedSet.getIterator(),r=t.sortedSet.getIterator();for(;n.hasNext();){const i=n.getNext().key,a=r.getNext().key;if(!i.isEqual(a))return!1}return!0}toString(){const t=[];return this.forEach((n=>{t.push(n.toString())})),t.length===0?"DocumentSet ()":`DocumentSet ( `+t.join(` `)+` )`}copy(t,n){const r=new L0;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=n,r}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class PD{constructor(){this.ga=new ds(hn.comparator)}track(t){const n=t.doc.key,r=this.ga.get(n);r?t.type!==0&&r.type===3?this.ga=this.ga.insert(n,t):t.type===3&&r.type!==1?this.ga=this.ga.insert(n,{type:r.type,doc:t.doc}):t.type===2&&r.type===2?this.ga=this.ga.insert(n,{type:2,doc:t.doc}):t.type===2&&r.type===0?this.ga=this.ga.insert(n,{type:0,doc:t.doc}):t.type===1&&r.type===0?this.ga=this.ga.remove(n):t.type===1&&r.type===2?this.ga=this.ga.insert(n,{type:1,doc:r.doc}):t.type===0&&r.type===1?this.ga=this.ga.insert(n,{type:2,doc:t.doc}):Cn(63341,{Vt:t,pa:r}):this.ga=this.ga.insert(n,t)}ya(){const t=[];return this.ga.inorderTraversal(((n,r)=>{t.push(r)})),t}}class ug{constructor(t,n,r,i,a,o,c,h,f){this.query=t,this.docs=n,this.oldDocs=r,this.docChanges=i,this.mutatedKeys=a,this.fromCache=o,this.syncStateChanged=c,this.excludesMetadataChanges=h,this.hasCachedResults=f}static fromInitialDocuments(t,n,r,i,a){const o=[];return n.forEach((c=>{o.push({type:0,doc:c})})),new ug(t,n,L0.emptySet(n),o,r,i,!0,!1,a)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(t){if(!(this.fromCache===t.fromCache&&this.hasCachedResults===t.hasCachedResults&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&HN(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;const n=this.docChanges,r=t.docChanges;if(n.length!==r.length)return!1;for(let i=0;it.Da()))}}class jde{constructor(){this.queries=RD(),this.onlineState="Unknown",this.Ca=new Set}terminate(){(function(n,r){const i=zn(n),a=i.queries;i.queries=RD(),a.forEach(((o,c)=>{for(const h of c.Sa)h.onError(r)}))})(this,new Jt(bt.ABORTED,"Firestore shutting down"))}}function RD(){return new Yd((e=>rH(e)),HN)}async function Xj(e,t){const n=zn(e);let r=3;const i=t.query;let a=n.queries.get(i);a?!a.ba()&&t.Da()&&(r=2):(a=new Ide,r=t.Da()?0:1);try{switch(r){case 0:a.wa=await n.onListen(i,!0);break;case 1:a.wa=await n.onListen(i,!1);break;case 2:await n.onFirstRemoteStoreListen(i)}}catch(o){const c=Yj(o,`Initialization of query '${y0(t.query)}' failed`);return void t.onError(c)}n.queries.set(i,a),a.Sa.push(t),t.va(n.onlineState),a.wa&&t.Fa(a.wa)&&Zj(n)}async function Qj(e,t){const n=zn(e),r=t.query;let i=3;const a=n.queries.get(r);if(a){const o=a.Sa.indexOf(t);o>=0&&(a.Sa.splice(o,1),a.Sa.length===0?i=t.Da()?0:1:!a.ba()&&t.Da()&&(i=2))}switch(i){case 0:return n.queries.delete(r),n.onUnlisten(r,!0);case 1:return n.queries.delete(r),n.onUnlisten(r,!1);case 2:return n.onLastRemoteStoreUnlisten(r);default:return}}function Tde(e,t){const n=zn(e);let r=!1;for(const i of t){const a=i.query,o=n.queries.get(a);if(o){for(const c of o.Sa)c.Fa(i)&&(r=!0);o.wa=i}}r&&Zj(n)}function Ode(e,t,n){const r=zn(e),i=r.queries.get(t);if(i)for(const a of i.Sa)a.onError(n);r.queries.delete(t)}function Zj(e){e.Ca.forEach((t=>{t.next()}))}var iC,DD;(DD=iC||(iC={})).Ma="default",DD.Cache="cache";class Jj{constructor(t,n,r){this.query=t,this.xa=n,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=r||{}}Fa(t){if(!this.options.includeMetadataChanges){const r=[];for(const i of t.docChanges)i.type!==3&&r.push(i);t=new ug(t.query,t.docs,t.oldDocs,r,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0,t.hasCachedResults)}let n=!1;return this.Oa?this.Ba(t)&&(this.xa.next(t),n=!0):this.La(t,this.onlineState)&&(this.ka(t),n=!0),this.Na=t,n}onError(t){this.xa.error(t)}va(t){this.onlineState=t;let n=!1;return this.Na&&!this.Oa&&this.La(this.Na,t)&&(this.ka(this.Na),n=!0),n}La(t,n){if(!t.fromCache||!this.Da())return!0;const r=n!=="Offline";return(!this.options.qa||!r)&&(!t.docs.isEmpty()||t.hasCachedResults||n==="Offline")}Ba(t){if(t.docChanges.length>0)return!0;const n=this.Na&&this.Na.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!n)&&this.options.includeMetadataChanges===!0}ka(t){t=ug.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache,t.hasCachedResults),this.Oa=!0,this.xa.next(t)}Da(){return this.options.source!==iC.Cache}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class fG{constructor(t){this.key=t}}class pG{constructor(t){this.key=t}}class Pde{constructor(t,n){this.query=t,this.Za=n,this.Xa=null,this.hasCachedResults=!1,this.current=!1,this.Ya=Gr(),this.mutatedKeys=Gr(),this.eu=sH(t),this.tu=new L0(this.eu)}get nu(){return this.Za}ru(t,n){const r=n?n.iu:new PD,i=n?n.tu:this.tu;let a=n?n.mutatedKeys:this.mutatedKeys,o=i,c=!1;const h=this.query.limitType==="F"&&i.size===this.query.limit?i.last():null,f=this.query.limitType==="L"&&i.size===this.query.limit?i.first():null;if(t.inorderTraversal(((m,y)=>{const w=i.get(m),A=Iy(this.query,y)?y:null,k=!!w&&this.mutatedKeys.has(w.key),I=!!A&&(A.hasLocalMutations||this.mutatedKeys.has(A.key)&&A.hasCommittedMutations);let T=!1;w&&A?w.data.isEqual(A.data)?k!==I&&(r.track({type:3,doc:A}),T=!0):this.su(w,A)||(r.track({type:2,doc:A}),T=!0,(h&&this.eu(A,h)>0||f&&this.eu(A,f)<0)&&(c=!0)):!w&&A?(r.track({type:0,doc:A}),T=!0):w&&!A&&(r.track({type:1,doc:w}),T=!0,(h||f)&&(c=!0)),T&&(A?(o=o.add(A),a=I?a.add(m):a.delete(m)):(o=o.delete(m),a=a.delete(m)))})),this.query.limit!==null)for(;o.size>this.query.limit;){const m=this.query.limitType==="F"?o.last():o.first();o=o.delete(m.key),a=a.delete(m.key),r.track({type:1,doc:m})}return{tu:o,iu:r,bs:c,mutatedKeys:a}}su(t,n){return t.hasLocalMutations&&n.hasCommittedMutations&&!n.hasLocalMutations}applyChanges(t,n,r,i){const a=this.tu;this.tu=t.tu,this.mutatedKeys=t.mutatedKeys;const o=t.iu.ya();o.sort(((m,y)=>(function(A,k){const I=T=>{switch(T){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return Cn(20277,{Vt:T})}};return I(A)-I(k)})(m.type,y.type)||this.eu(m.doc,y.doc))),this.ou(r),i=i??!1;const c=n&&!i?this._u():[],h=this.Ya.size===0&&this.current&&!i?1:0,f=h!==this.Xa;return this.Xa=h,o.length!==0||f?{snapshot:new ug(this.query,t.tu,a,o,t.mutatedKeys,h===0,f,!1,!!r&&r.resumeToken.approximateByteSize()>0),au:c}:{au:c}}va(t){return this.current&&t==="Offline"?(this.current=!1,this.applyChanges({tu:this.tu,iu:new PD,mutatedKeys:this.mutatedKeys,bs:!1},!1)):{au:[]}}uu(t){return!this.Za.has(t)&&!!this.tu.has(t)&&!this.tu.get(t).hasLocalMutations}ou(t){t&&(t.addedDocuments.forEach((n=>this.Za=this.Za.add(n))),t.modifiedDocuments.forEach((n=>{})),t.removedDocuments.forEach((n=>this.Za=this.Za.delete(n))),this.current=t.current)}_u(){if(!this.current)return[];const t=this.Ya;this.Ya=Gr(),this.tu.forEach((r=>{this.uu(r.key)&&(this.Ya=this.Ya.add(r.key))}));const n=[];return t.forEach((r=>{this.Ya.has(r)||n.push(new pG(r))})),this.Ya.forEach((r=>{t.has(r)||n.push(new fG(r))})),n}cu(t){this.Za=t.ks,this.Ya=Gr();const n=this.ru(t.documents);return this.applyChanges(n,!0)}lu(){return ug.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Xa===0,this.hasCachedResults)}}const Tg="SyncEngine";class Rde{constructor(t,n,r){this.query=t,this.targetId=n,this.view=r}}class Dde{constructor(t){this.key=t,this.hu=!1}}class Mde{constructor(t,n,r,i,a,o){this.localStore=t,this.remoteStore=n,this.eventManager=r,this.sharedClientState=i,this.currentUser=a,this.maxConcurrentLimboResolutions=o,this.Pu={},this.Tu=new Yd((c=>rH(c)),HN),this.Eu=new Map,this.Iu=new Set,this.Ru=new ds(hn.comparator),this.Au=new Map,this.Vu=new Bj,this.du={},this.mu=new Map,this.fu=em.ar(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return this.gu===!0}}async function Lde(e,t,n=!0){const r=eE(e);let i;const a=r.Tu.get(t);return a?(r.sharedClientState.addLocalQueryTarget(a.targetId),i=a.view.lu()):i=await mG(r,t,n,!0),i}async function Ude(e,t){const n=eE(e);await mG(n,t,!0,!1)}async function mG(e,t,n,r){const i=await n2(e.localStore,zl(t)),a=i.targetId,o=e.sharedClientState.addLocalQueryTarget(a,n);let c;return r&&(c=await eT(e,t,a,o==="current",i.resumeToken)),e.isPrimaryClient&&n&&JN(e.remoteStore,i),c}async function eT(e,t,n,r,i){e.pu=(y,w,A)=>(async function(I,T,D,F){let L=T.view.ru(D);L.bs&&(L=await eC(I.localStore,T.query,!1).then((({documents:z})=>T.view.ru(z,L))));const q=F&&F.targetChanges.get(T.targetId),Z=F&&F.targetMismatches.get(T.targetId)!=null,K=T.view.applyChanges(L,I.isPrimaryClient,q,Z);return sC(I,T.targetId,K.au),K.snapshot})(e,y,w,A);const a=await eC(e.localStore,t,!0),o=new Pde(t,a.ks),c=o.ru(a.documents),h=Oy.createSynthesizedTargetChangeForCurrentChange(n,r&&e.onlineState!=="Offline",i),f=o.applyChanges(c,e.isPrimaryClient,h);sC(e,n,f.au);const m=new Rde(t,n,o);return e.Tu.set(t,m),e.Eu.has(n)?e.Eu.get(n).push(t):e.Eu.set(n,[t]),f.snapshot}async function Bde(e,t,n){const r=zn(e),i=r.Tu.get(t),a=r.Eu.get(i.targetId);if(a.length>1)return r.Eu.set(i.targetId,a.filter((o=>!HN(o,t)))),void r.Tu.delete(t);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedClientState.isActiveQueryTarget(i.targetId)||await lg(r.localStore,i.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(i.targetId),n&&cg(r.remoteStore,i.targetId),dg(r,i.targetId)})).catch(Nf)):(dg(r,i.targetId),await lg(r.localStore,i.targetId,!0))}async function zde(e,t){const n=zn(e),r=n.Tu.get(t),i=n.Eu.get(r.targetId);n.isPrimaryClient&&i.length===1&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),cg(n.remoteStore,r.targetId))}async function Vde(e,t,n){const r=iT(e);try{const i=await(function(o,c){const h=zn(o),f=jr.now(),m=c.reduce(((A,k)=>A.add(k.key)),Gr());let y,w;return h.persistence.runTransaction("Locally write mutations","readwrite",(A=>{let k=Ml(),I=Gr();return h.xs.getEntries(A,m).next((T=>{k=T,k.forEach(((D,F)=>{F.isValidDocument()||(I=I.add(D))}))})).next((()=>h.localDocuments.getOverlayedDocuments(A,k))).next((T=>{y=T;const D=[];for(const F of c){const L=aue(F,y.get(F.key).overlayedDocument);L!=null&&D.push(new Xd(F.key,L,q$(L.value.mapValue),_o.exists(!0)))}return h.mutationQueue.addMutationBatch(A,f,D,c)})).next((T=>{w=T;const D=T.applyToLocalDocumentSet(y,I);return h.documentOverlayCache.saveOverlays(A,T.batchId,D)}))})).then((()=>({batchId:w.batchId,changes:oH(y)})))})(r.localStore,t);r.sharedClientState.addPendingMutation(i.batchId),(function(o,c,h){let f=o.du[o.currentUser.toKey()];f||(f=new ds(Er)),f=f.insert(c,h),o.du[o.currentUser.toKey()]=f})(r,i.batchId,n),await _f(r,i.changes),await Ig(r.remoteStore)}catch(i){const a=Yj(i,"Failed to persist write");n.reject(a)}}async function gG(e,t){const n=zn(e);try{const r=await ide(n.localStore,t);t.targetChanges.forEach(((i,a)=>{const o=n.Au.get(a);o&&(Xn(i.addedDocuments.size+i.modifiedDocuments.size+i.removedDocuments.size<=1,22616),i.addedDocuments.size>0?o.hu=!0:i.modifiedDocuments.size>0?Xn(o.hu,14607):i.removedDocuments.size>0&&(Xn(o.hu,42227),o.hu=!1))})),await _f(n,r,t)}catch(r){await Nf(r)}}function MD(e,t,n){const r=zn(e);if(r.isPrimaryClient&&n===0||!r.isPrimaryClient&&n===1){const i=[];r.Tu.forEach(((a,o)=>{const c=o.view.va(t);c.snapshot&&i.push(c.snapshot)})),(function(o,c){const h=zn(o);h.onlineState=c;let f=!1;h.queries.forEach(((m,y)=>{for(const w of y.Sa)w.va(c)&&(f=!0)})),f&&Zj(h)})(r.eventManager,t),i.length&&r.Pu.H_(i),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function Fde(e,t,n){const r=zn(e);r.sharedClientState.updateQueryState(t,"rejected",n);const i=r.Au.get(t),a=i&&i.key;if(a){let o=new ds(hn.comparator);o=o.insert(a,qs.newNoDocument(a,rr.min()));const c=Gr().add(a),h=new Ty(rr.min(),new Map,new ds(Er),o,c);await gG(r,h),r.Ru=r.Ru.remove(a),r.Au.delete(t),rT(r)}else await lg(r.localStore,t,!1).then((()=>dg(r,t,n))).catch(Nf)}async function $de(e,t){const n=zn(e),r=t.batch.batchId;try{const i=await rde(n.localStore,t);nT(n,r,null),tT(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await _f(n,i)}catch(i){await Nf(i)}}async function Hde(e,t,n){const r=zn(e);try{const i=await(function(o,c){const h=zn(o);return h.persistence.runTransaction("Reject batch","readwrite-primary",(f=>{let m;return h.mutationQueue.lookupMutationBatch(f,c).next((y=>(Xn(y!==null,37113),m=y.keys(),h.mutationQueue.removeMutationBatch(f,y)))).next((()=>h.mutationQueue.performConsistencyCheck(f))).next((()=>h.documentOverlayCache.removeOverlaysForBatchId(f,m,c))).next((()=>h.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(f,m))).next((()=>h.localDocuments.getDocuments(f,m)))}))})(r.localStore,t);nT(r,t,n),tT(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),await _f(r,i)}catch(i){await Nf(i)}}function tT(e,t){(e.mu.get(t)||[]).forEach((n=>{n.resolve()})),e.mu.delete(t)}function nT(e,t,n){const r=zn(e);let i=r.du[r.currentUser.toKey()];if(i){const a=i.get(t);a&&(n?a.reject(n):a.resolve(),i=i.remove(t)),r.du[r.currentUser.toKey()]=i}}function dg(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(const r of e.Eu.get(t))e.Tu.delete(r),n&&e.Pu.yu(r,n);e.Eu.delete(t),e.isPrimaryClient&&e.Vu.Gr(t).forEach((r=>{e.Vu.containsKey(r)||xG(e,r)}))}function xG(e,t){e.Iu.delete(t.path.canonicalString());const n=e.Ru.get(t);n!==null&&(cg(e.remoteStore,n),e.Ru=e.Ru.remove(t),e.Au.delete(n),rT(e))}function sC(e,t,n){for(const r of n)r instanceof fG?(e.Vu.addReference(r.key,t),Gde(e,r)):r instanceof pG?(zt(Tg,"Document no longer in limbo: "+r.key),e.Vu.removeReference(r.key,t),e.Vu.containsKey(r.key)||xG(e,r.key)):Cn(19791,{wu:r})}function Gde(e,t){const n=t.key,r=n.path.canonicalString();e.Ru.get(n)||e.Iu.has(r)||(zt(Tg,"New document in limbo: "+n),e.Iu.add(r),rT(e))}function rT(e){for(;e.Iu.size>0&&e.Ru.size{o.push(r.pu(h,t,n).then((f=>{var m;if((f||n)&&r.isPrimaryClient){const y=f?!f.fromCache:(m=n==null?void 0:n.targetChanges.get(h.targetId))==null?void 0:m.current;r.sharedClientState.updateQueryState(h.targetId,y?"current":"not-current")}if(f){i.push(f);const y=Fj.Is(h.targetId,f);a.push(y)}})))})),await Promise.all(o),r.Pu.H_(i),await(async function(h,f){const m=zn(h);try{await m.persistence.runTransaction("notifyLocalViewChanges","readwrite",(y=>Qe.forEach(f,(w=>Qe.forEach(w.Ts,(A=>m.persistence.referenceDelegate.addReference(y,w.targetId,A))).next((()=>Qe.forEach(w.Es,(A=>m.persistence.referenceDelegate.removeReference(y,w.targetId,A)))))))))}catch(y){if(!Ef(y))throw y;zt($j,"Failed to update sequence numbers: "+y)}for(const y of f){const w=y.targetId;if(!y.fromCache){const A=m.vs.get(w),k=A.snapshotVersion,I=A.withLastLimboFreeSnapshotVersion(k);m.vs=m.vs.insert(w,I)}}})(r.localStore,a))}async function qde(e,t){const n=zn(e);if(!n.currentUser.isEqual(t)){zt(Tg,"User change. New user:",t.toKey());const r=await XH(n.localStore,t);n.currentUser=t,(function(a,o){a.mu.forEach((c=>{c.forEach((h=>{h.reject(new Jt(bt.CANCELLED,o))}))})),a.mu.clear()})(n,"'waitForPendingWrites' promise is rejected due to a user change."),n.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),await _f(n,r.Ns)}}function Wde(e,t){const n=zn(e),r=n.Au.get(t);if(r&&r.hu)return Gr().add(r.key);{let i=Gr();const a=n.Eu.get(t);if(!a)return i;for(const o of a){const c=n.Tu.get(o);i=i.unionWith(c.view.nu)}return i}}async function Kde(e,t){const n=zn(e),r=await eC(n.localStore,t.query,!0),i=t.view.cu(r);return n.isPrimaryClient&&sC(n,t.targetId,i.au),i}async function Yde(e,t){const n=zn(e);return JH(n.localStore,t).then((r=>_f(n,r)))}async function Xde(e,t,n,r){const i=zn(e),a=await(function(c,h){const f=zn(c),m=zn(f.mutationQueue);return f.persistence.runTransaction("Lookup mutation documents","readonly",(y=>m.Xn(y,h).next((w=>w?f.localDocuments.getDocuments(y,w):Qe.resolve(null)))))})(i.localStore,t);a!==null?(n==="pending"?await Ig(i.remoteStore):n==="acknowledged"||n==="rejected"?(nT(i,t,r||null),tT(i,t),(function(c,h){zn(zn(c).mutationQueue).nr(h)})(i.localStore,t)):Cn(6720,"Unknown batchState",{Su:n}),await _f(i,a)):zt(Tg,"Cannot apply mutation batch with id: "+t)}async function Qde(e,t){const n=zn(e);if(eE(n),iT(n),t===!0&&n.gu!==!0){const r=n.sharedClientState.getAllActiveQueryTargets(),i=await LD(n,r.toArray());n.gu=!0,await rC(n.remoteStore,!0);for(const a of i)JN(n.remoteStore,a)}else if(t===!1&&n.gu!==!1){const r=[];let i=Promise.resolve();n.Eu.forEach(((a,o)=>{n.sharedClientState.isLocalQueryTarget(o)?r.push(o):i=i.then((()=>(dg(n,o),lg(n.localStore,o,!0)))),cg(n.remoteStore,o)})),await i,await LD(n,r),(function(o){const c=zn(o);c.Au.forEach(((h,f)=>{cg(c.remoteStore,f)})),c.Vu.zr(),c.Au=new Map,c.Ru=new ds(hn.comparator)})(n),n.gu=!1,await rC(n.remoteStore,!1)}}async function LD(e,t,n){const r=zn(e),i=[],a=[];for(const o of t){let c;const h=r.Eu.get(o);if(h&&h.length!==0){c=await n2(r.localStore,zl(h[0]));for(const f of h){const m=r.Tu.get(f),y=await Kde(r,m);y.snapshot&&a.push(y.snapshot)}}else{const f=await ZH(r.localStore,o);c=await n2(r.localStore,f),await eT(r,yG(f),o,!1,c.resumeToken)}i.push(c)}return r.Pu.H_(a),i}function yG(e){return eH(e.path,e.collectionGroup,e.orderBy,e.filters,e.limit,"F",e.startAt,e.endAt)}function Zde(e){return(function(n){return zn(zn(n).persistence).hs()})(zn(e).localStore)}async function Jde(e,t,n,r){const i=zn(e);if(i.gu)return void zt(Tg,"Ignoring unexpected query state notification.");const a=i.Eu.get(t);if(a&&a.length>0)switch(n){case"current":case"not-current":{const o=await JH(i.localStore,iH(a[0])),c=Ty.createSynthesizedRemoteEventForCurrentChange(t,n==="current",ta.EMPTY_BYTE_STRING);await _f(i,o,c);break}case"rejected":await lg(i.localStore,t,!0),dg(i,t,r);break;default:Cn(64155,n)}}async function ehe(e,t,n){const r=eE(e);if(r.gu){for(const i of t){if(r.Eu.has(i)&&r.sharedClientState.isActiveQueryTarget(i)){zt(Tg,"Adding an already active target "+i);continue}const a=await ZH(r.localStore,i),o=await n2(r.localStore,a);await eT(r,yG(a),o.targetId,!1,o.resumeToken),JN(r.remoteStore,o)}for(const i of n)r.Eu.has(i)&&await lg(r.localStore,i,!1).then((()=>{cg(r.remoteStore,i),dg(r,i)})).catch(Nf)}}function eE(e){const t=zn(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=gG.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=Wde.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=Fde.bind(null,t),t.Pu.H_=Tde.bind(null,t.eventManager),t.Pu.yu=Ode.bind(null,t.eventManager),t}function iT(e){const t=zn(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=$de.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Hde.bind(null,t),t}class X1{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(t){this.serializer=QN(t.databaseInfo.databaseId),this.sharedClientState=this.Du(t),this.persistence=this.Cu(t),await this.persistence.start(),this.localStore=this.vu(t),this.gcScheduler=this.Fu(t,this.localStore),this.indexBackfillerScheduler=this.Mu(t,this.localStore)}Fu(t,n){return null}Mu(t,n){return null}vu(t){return YH(this.persistence,new KH,t.initialUser,this.serializer)}Cu(t){return new zj(XN.Vi,this.serializer)}Du(t){return new iG}async terminate(){var t,n;(t=this.gcScheduler)==null||t.stop(),(n=this.indexBackfillerScheduler)==null||n.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}X1.provider={build:()=>new X1};class bG extends X1{constructor(t){super(),this.cacheSizeBytes=t}Fu(t,n){Xn(this.persistence.referenceDelegate instanceof t2,46915);const r=this.persistence.referenceDelegate.garbageCollector;return new FH(r,t.asyncQueue,n)}Cu(t){const n=this.cacheSizeBytes!==void 0?wo.withCacheSize(this.cacheSizeBytes):wo.DEFAULT;return new zj((r=>t2.Vi(r,n)),this.serializer)}}class vG extends X1{constructor(t,n,r){super(),this.xu=t,this.cacheSizeBytes=n,this.forceOwnership=r,this.kind="persistent",this.synchronizeTabs=!1}async initialize(t){await super.initialize(t),await this.xu.initialize(this,t),await iT(this.xu.syncEngine),await Ig(this.xu.remoteStore),await this.persistence.zi((()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve())))}vu(t){return YH(this.persistence,new KH,t.initialUser,this.serializer)}Fu(t,n){const r=this.persistence.referenceDelegate.garbageCollector;return new FH(r,t.asyncQueue,n)}Mu(t,n){const r=new ace(n,this.persistence);return new sce(t.asyncQueue,r)}Cu(t){const n=WH(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),r=this.cacheSizeBytes!==void 0?wo.withCacheSize(this.cacheSizeBytes):wo.DEFAULT;return new Vj(this.synchronizeTabs,n,t.clientId,r,t.asyncQueue,sG(),fw(),this.serializer,this.sharedClientState,!!this.forceOwnership)}Du(t){return new iG}}class the extends vG{constructor(t,n){super(t,n,!1),this.xu=t,this.cacheSizeBytes=n,this.synchronizeTabs=!0}async initialize(t){await super.initialize(t);const n=this.xu.syncEngine;this.sharedClientState instanceof K_&&(this.sharedClientState.syncEngine={bo:Xde.bind(null,n),Do:Jde.bind(null,n),Co:ehe.bind(null,n),hs:Zde.bind(null,n),So:Yde.bind(null,n)},await this.sharedClientState.start()),await this.persistence.zi((async r=>{await Qde(this.xu.syncEngine,r),this.gcScheduler&&(r&&!this.gcScheduler.started?this.gcScheduler.start():r||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(r&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():r||this.indexBackfillerScheduler.stop())}))}Du(t){const n=sG();if(!K_.v(n))throw new Jt(bt.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const r=WH(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new K_(n,t.asyncQueue,r,t.clientId,t.initialUser)}}class hg{async initialize(t,n){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(n),this.remoteStore=this.createRemoteStore(n),this.eventManager=this.createEventManager(n),this.syncEngine=this.createSyncEngine(n,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>MD(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=qde.bind(null,this.syncEngine),await rC(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return(function(){return new jde})()}createDatastore(t){const n=QN(t.databaseInfo.databaseId),r=dde(t.databaseInfo);return gde(t.authCredentials,t.appCheckCredentials,r,n)}createRemoteStore(t){return(function(r,i,a,o,c){return new yde(r,i,a,o,c)})(this.localStore,this.datastore,t.asyncQueue,(n=>MD(this.syncEngine,n,0)),(function(){return jD.v()?new jD:new ode})())}createSyncEngine(t,n){return(function(i,a,o,c,h,f,m){const y=new Mde(i,a,o,c,h,f);return m&&(y.gu=!0),y})(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,n)}async terminate(){var t,n;await(async function(i){const a=zn(i);zt(tm,"RemoteStore shutting down."),a.Ia.add(5),await Py(a),a.Aa.shutdown(),a.Va.set("Unknown")})(this.remoteStore),(t=this.datastore)==null||t.terminate(),(n=this.eventManager)==null||n.terminate()}}hg.provider={build:()=>new hg};/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *//** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class sT{constructor(t){this.observer=t,this.muted=!1}next(t){this.muted||this.observer.next&&this.Ou(this.observer.next,t)}error(t){this.muted||(this.observer.error?this.Ou(this.observer.error,t):ea("Uncaught Error in snapshot listener:",t.toString()))}Nu(){this.muted=!0}Ou(t,n){setTimeout((()=>{this.muted||t(n)}),0)}}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const mf="FirestoreClient";class nhe{constructor(t,n,r,i,a){this.authCredentials=t,this.appCheckCredentials=n,this.asyncQueue=r,this._databaseInfo=i,this.user=vo.UNAUTHENTICATED,this.clientId=xj.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=a,this.authCredentials.start(r,(async o=>{zt(mf,"Received user=",o.uid),await this.authCredentialListener(o),this.user=o})),this.appCheckCredentials.start(r,(o=>(zt(mf,"Received new app check token=",o),this.appCheckCredentialListener(o,this.user))))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this._databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(t){this.authCredentialListener=t}setAppCheckTokenChangeListener(t){this.appCheckCredentialListener=t}terminate(){this.asyncQueue.enterRestrictedMode();const t=new Uc;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),t.resolve()}catch(n){const r=Yj(n,"Failed to shutdown persistence");t.reject(r)}})),t.promise}}async function X_(e,t){e.asyncQueue.verifyOperationInProgress(),zt(mf,"Initializing OfflineComponentProvider");const n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async i=>{r.isEqual(i)||(await XH(t.localStore,i),r=i)})),t.persistence.setDatabaseDeletedListener((()=>e.terminate())),e._offlineComponents=t}async function UD(e,t){e.asyncQueue.verifyOperationInProgress();const n=await rhe(e);zt(mf,"Initializing OnlineComponentProvider"),await t.initialize(n,e.configuration),e.setCredentialChangeListener((r=>OD(t.remoteStore,r))),e.setAppCheckTokenChangeListener(((r,i)=>OD(t.remoteStore,i))),e._onlineComponents=t}async function rhe(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){zt(mf,"Using user provided OfflineComponentProvider");try{await X_(e,e._uninitializedComponentsProvider._offline)}catch(t){const n=t;if(!(function(i){return i.name==="FirebaseError"?i.code===bt.FAILED_PRECONDITION||i.code===bt.UNIMPLEMENTED:!(typeof DOMException<"u"&&i instanceof DOMException)||i.code===22||i.code===20||i.code===11})(n))throw n;K0("Error using user provided cache. Falling back to memory cache: "+n),await X_(e,new X1)}}else zt(mf,"Using default OfflineComponentProvider"),await X_(e,new bG(void 0));return e._offlineComponents}async function aT(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(zt(mf,"Using user provided OnlineComponentProvider"),await UD(e,e._uninitializedComponentsProvider._online)):(zt(mf,"Using default OnlineComponentProvider"),await UD(e,new hg))),e._onlineComponents}function ihe(e){return aT(e).then((t=>t.syncEngine))}function she(e){return aT(e).then((t=>t.datastore))}async function a2(e){const t=await aT(e),n=t.eventManager;return n.onListen=Lde.bind(null,t.syncEngine),n.onUnlisten=Bde.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=Ude.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=zde.bind(null,t.syncEngine),n}function ahe(e,t,n,r){const i=new sT(r),a=new Jj(t,i,n);return e.asyncQueue.enqueueAndForget((async()=>Xj(await a2(e),a))),()=>{i.Nu(),e.asyncQueue.enqueueAndForget((async()=>Qj(await a2(e),a)))}}function ohe(e,t,n={}){const r=new Uc;return e.asyncQueue.enqueueAndForget((async()=>(function(a,o,c,h,f){const m=new sT({next:w=>{m.Nu(),o.enqueueAndForget((()=>Qj(a,y)));const A=w.docs.has(c);!A&&w.fromCache?f.reject(new Jt(bt.UNAVAILABLE,"Failed to get document because the client is offline.")):A&&w.fromCache&&h&&h.source==="server"?f.reject(new Jt(bt.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.)')):f.resolve(w)},error:w=>f.reject(w)}),y=new Jj(Cy(c.path),m,{includeMetadataChanges:!0,qa:!0});return Xj(a,y)})(await a2(e),e.asyncQueue,t,n,r))),r.promise}function lhe(e,t,n={}){const r=new Uc;return e.asyncQueue.enqueueAndForget((async()=>(function(a,o,c,h,f){const m=new sT({next:w=>{m.Nu(),o.enqueueAndForget((()=>Qj(a,y))),w.fromCache&&h.source==="server"?f.reject(new Jt(bt.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.)')):f.resolve(w)},error:w=>f.reject(w)}),y=new Jj(c,m,{includeMetadataChanges:!0,qa:!0});return Xj(a,y)})(await a2(e),e.asyncQueue,t,n,r))),r.promise}function che(e,t,n){const r=new Uc;return e.asyncQueue.enqueueAndForget((async()=>{try{const i=await she(e);r.resolve((async function(o,c,h){var I;const f=zn(o),{request:m,gt:y,parent:w}=wue(f.serializer,Kce(c),h);f.connection.qo||delete m.parent;const A=(await f.jo("RunAggregationQuery",f.serializer.databaseId,w,m,1)).filter((T=>!!T.result));Xn(A.length===1,64727);const k=(I=A[0].result)==null?void 0:I.aggregateFields;return Object.keys(k).reduce(((T,D)=>(T[y[D]]=k[D],T)),{})})(i,t,n))}catch(i){r.reject(i)}})),r.promise}function uhe(e,t){const n=new Uc;return e.asyncQueue.enqueueAndForget((async()=>Vde(await ihe(e),t,n))),n.promise}/** * @license * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function wG(e){const t={};return e.timeoutSeconds!==void 0&&(t.timeoutSeconds=e.timeoutSeconds),t}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const dhe="ComponentProvider",BD=new Map;function hhe(e,t,n,r,i){return new Dce(e,t,n,i.host,i.ssl,i.experimentalForceLongPolling,i.experimentalAutoDetectLongPolling,wG(i.experimentalLongPollingOptions),i.useFetchStreams,i.isUsingEmulator,r)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const fhe="firestore.googleapis.com",zD=!0;class VD{constructor(t){if(t.host===void 0){if(t.ssl!==void 0)throw new Jt(bt.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=fhe,this.ssl=zD}else this.host=t.host,this.ssl=t.ssl??zD;if(this.isUsingEmulator=t.emulatorOptions!==void 0,this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,this.localCache=t.localCache,t.cacheSizeBytes===void 0)this.cacheSizeBytes=LH;else{if(t.cacheSizeBytes!==-1&&t.cacheSizeBytes30)throw new Jt(bt.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (maximum allowed value is 30)`)}})(this.experimentalLongPollingOptions),this.useFetchStreams=!!t.useFetchStreams}isEqual(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&(function(r,i){return r.timeoutSeconds===i.timeoutSeconds})(this.experimentalLongPollingOptions,t.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}}class tE{constructor(t,n,r,i){this._authCredentials=t,this._appCheckCredentials=n,this._databaseId=r,this._app=i,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new VD({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new Jt(bt.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(t){if(this._settingsFrozen)throw new Jt(bt.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 VD(t),this._emulatorOptions=t.emulatorOptions||{},t.credentials!==void 0&&(this._authCredentials=(function(r){if(!r)return new qle;switch(r.type){case"firstParty":return new Yle(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new Jt(bt.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}})(t.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 r=BD.get(n);r&&(zt(dhe,"Removing Datastore"),BD.delete(n),r.terminate())})(this),Promise.resolve()}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Gu{constructor(t,n,r){this.converter=n,this._query=r,this.type="query",this.firestore=t}withConverter(t){return new Gu(this.firestore,t,this._query)}}class Ws{constructor(t,n,r){this.converter=n,this._key=r,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new of(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new Ws(this.firestore,t,this._key)}toJSON(){return{type:Ws._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(t,n,r){if(_y(n,Ws._jsonSchema))return new Ws(t,r||null,new hn(Ei.fromString(n.referencePath)))}}Ws._jsonSchemaVersion="firestore/documentReference/1.0",Ws._jsonSchema={type:da("string",Ws._jsonSchemaVersion),referencePath:da("string")};class of extends Gu{constructor(t,n,r){super(t,n,Cy(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new Ws(this.firestore,null,new hn(t))}withConverter(t){return new of(this.firestore,t,this._path)}}function it(e,t,...n){if(e=Ca(e),yj("collection","path",t),e instanceof tE){const r=Ei.fromString(t,...n);return TR(r),new of(e,null,r)}{if(!(e instanceof Ws||e instanceof of))throw new Jt(bt.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(Ei.fromString(t,...n));return TR(r),new of(e.firestore,null,r)}}function phe(e,t){if(e=qo(e,tE),yj("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new Jt(bt.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new Gu(e,null,(function(r){return new hm(Ei.emptyPath(),r)})(t))}function ot(e,t,...n){if(e=Ca(e),arguments.length===1&&(t=xj.newId()),yj("doc","path",t),e instanceof tE){const r=Ei.fromString(t,...n);return jR(r),new Ws(e,null,new hn(r))}{if(!(e instanceof Ws||e instanceof of))throw new Jt(bt.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(Ei.fromString(t,...n));return jR(r),new Ws(e.firestore,e instanceof of?e.converter:null,new hn(r))}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const FD="AsyncQueue";class $D{constructor(t=Promise.resolve()){this.Yu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new aG(this,"async_queue_retry"),this._c=()=>{const r=fw();r&&zt(FD,"Visibility state changed to "+r.visibilityState),this.M_.w_()},this.ac=t;const n=fw();n&&typeof n.addEventListener=="function"&&n.addEventListener("visibilitychange",this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.uc(),this.cc(t)}enterRestrictedMode(t){if(!this.ec){this.ec=!0,this.sc=t||!1;const n=fw();n&&typeof n.removeEventListener=="function"&&n.removeEventListener("visibilitychange",this._c)}}enqueue(t){if(this.uc(),this.ec)return new Promise((()=>{}));const n=new Uc;return this.cc((()=>this.ec&&this.sc?Promise.resolve():(t().then(n.resolve,n.reject),n.promise))).then((()=>n.promise))}enqueueRetryable(t){this.enqueueAndForget((()=>(this.Yu.push(t),this.lc())))}async lc(){if(this.Yu.length!==0){try{await this.Yu[0](),this.Yu.shift(),this.M_.reset()}catch(t){if(!Ef(t))throw t;zt(FD,"Operation failed with retryable error: "+t)}this.Yu.length>0&&this.M_.p_((()=>this.lc()))}}cc(t){const n=this.ac.then((()=>(this.rc=!0,t().catch((r=>{throw this.nc=r,this.rc=!1,ea("INTERNAL UNHANDLED ERROR: ",HD(r)),r})).then((r=>(this.rc=!1,r))))));return this.ac=n,n}enqueueAfterDelay(t,n,r){this.uc(),this.oc.indexOf(t)>-1&&(n=0);const i=Kj.createAndSchedule(this,t,n,r,(a=>this.hc(a)));return this.tc.push(i),i}uc(){this.nc&&Cn(47125,{Pc:HD(this.nc)})}verifyOperationInProgress(){}async Tc(){let t;do t=this.ac,await t;while(t!==this.ac)}Ec(t){for(const n of this.tc)if(n.timerId===t)return!0;return!1}Ic(t){return this.Tc().then((()=>{this.tc.sort(((n,r)=>n.targetTimeMs-r.targetTimeMs));for(const n of this.tc)if(n.skipDelay(),t!=="all"&&n.timerId===t)break;return this.Tc()}))}Rc(t){this.oc.push(t)}hc(t){const n=this.tc.indexOf(t);this.tc.splice(n,1)}}function HD(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+` `+e.stack),t}class Du extends tE{constructor(t,n,r,i){super(t,n,r,i),this.type="firestore",this._queue=new $D,this._persistenceKey=(i==null?void 0:i.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const t=this._firestoreClient.terminate();this._queue=new $D(t),this._firestoreClient=void 0,await t}}}function mhe(e,t,n){const r=sj(e,"firestore");if(r.isInitialized(n)){const i=r.getImmediate({identifier:n}),a=r.getOptions(n);if(Ld(a,t))return i;throw new Jt(bt.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(t.cacheSizeBytes!==void 0&&t.localCache!==void 0)throw new Jt(bt.INVALID_ARGUMENT,"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");if(t.cacheSizeBytes!==void 0&&t.cacheSizeBytes!==-1&&t.cacheSizeBytes90)throw new Jt(bt.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(n)||n<-180||n>180)throw new Jt(bt.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+n);this._lat=t,this._long=n}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}_compareTo(t){return Er(this._lat,t._lat)||Er(this._long,t._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:Iu._jsonSchemaVersion}}static fromJSON(t){if(_y(t,Iu._jsonSchema))return new Iu(t.latitude,t.longitude)}}Iu._jsonSchemaVersion="firestore/geoPoint/1.0",Iu._jsonSchema={type:da("string",Iu._jsonSchemaVersion),latitude:da("number"),longitude:da("number")};/** * @license * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Bc{constructor(t){this._values=(t||[]).map((n=>n))}toArray(){return this._values.map((t=>t))}isEqual(t){return(function(r,i){if(r.length!==i.length)return!1;for(let a=0;atypeof n=="number")))return new Bc(t.vectorValues);throw new Jt(bt.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}Bc._jsonSchemaVersion="firestore/vectorValue/1.0",Bc._jsonSchema={type:da("string",Bc._jsonSchemaVersion),vectorValues:da("object")};/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */const xhe=/^__.*__$/;class yhe{constructor(t,n,r){this.data=t,this.fieldMask=n,this.fieldTransforms=r}toMutation(t,n){return this.fieldMask!==null?new Xd(t,this.data,this.fieldMask,n,this.fieldTransforms):new Cg(t,this.data,n,this.fieldTransforms)}}class NG{constructor(t,n,r){this.data=t,this.fieldMask=n,this.fieldTransforms=r}toMutation(t,n){return new Xd(t,this.data,this.fieldMask,n,this.fieldTransforms)}}function EG(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw Cn(40011,{dataSource:e})}}class nE{constructor(t,n,r,i,a,o){this.settings=t,this.databaseId=n,this.serializer=r,this.ignoreUndefinedProperties=i,a===void 0&&this.Ac(),this.fieldTransforms=a||[],this.fieldMask=o||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}i(t){return new nE({...this.settings,...t},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}dc(t){var i;const n=(i=this.path)==null?void 0:i.child(t),r=this.i({path:n,arrayElement:!1});return r.mc(t),r}fc(t){var i;const n=(i=this.path)==null?void 0:i.child(t),r=this.i({path:n,arrayElement:!1});return r.Ac(),r}gc(t){return this.i({path:void 0,arrayElement:!0})}yc(t){return o2(t,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(t){return this.fieldMask.find((n=>t.isPrefixOf(n)))!==void 0||this.fieldTransforms.find((n=>t.isPrefixOf(n.field)))!==void 0}Ac(){if(this.path)for(let t=0;th.covers(y.field)))}else h=null,f=o.fieldTransforms;return new yhe(new io(c),h,f)}class iE extends pm{_toFieldTransform(t){if(t.dataSource!==2)throw t.dataSource===1?t.yc(`${this._methodName}() can only appear at the top level of your update data`):t.yc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof iE}}function _G(e,t,n){return new nE({dataSource:3,targetDoc:t.settings.targetDoc,methodName:e._methodName,arrayElement:n},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class lT extends pm{_toFieldTransform(t){return new jy(t.path,new sg)}isEqual(t){return t instanceof lT}}class cT extends pm{constructor(t,n){super(t),this.Sc=n}_toFieldTransform(t){const n=_G(this,t,!0),r=this.Sc.map((a=>mm(a,n))),i=new Xp(r);return new jy(t.path,i)}isEqual(t){return t instanceof cT&&Ld(this.Sc,t.Sc)}}class uT extends pm{constructor(t,n){super(t),this.Sc=n}_toFieldTransform(t){const n=_G(this,t,!0),r=this.Sc.map((a=>mm(a,n))),i=new Qp(r);return new jy(t.path,i)}isEqual(t){return t instanceof uT&&Ld(this.Sc,t.Sc)}}class dT extends pm{constructor(t,n){super(t),this.bc=n}_toFieldTransform(t){const n=new ag(t.serializer,uH(t.serializer,this.bc));return new jy(t.path,n)}isEqual(t){return t instanceof dT&&this.bc===t.bc}}function vhe(e,t,n,r){const i=e.A(1,t,n);hT("Data must be an object, but it was:",i,r);const a=[],o=io.empty();Af(r,((h,f)=>{const m=CG(t,h,n);f=Ca(f);const y=i.fc(m);if(f instanceof iE)a.push(m);else{const w=mm(f,y);w!=null&&(a.push(m),o.set(m,w))}}));const c=new gl(a);return new NG(o,c,i.fieldTransforms)}function whe(e,t,n,r,i,a){const o=e.A(1,t,n),c=[nm(t,r,n)],h=[i];if(a.length%2!=0)throw new Jt(bt.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let w=0;w=0;--w)if(!IG(f,c[w])){const A=c[w];let k=h[w];k=Ca(k);const I=o.fc(A);if(k instanceof iE)f.push(A);else{const T=mm(k,I);T!=null&&(f.push(A),m.set(A,T))}}const y=new gl(f);return new NG(m,y,o.fieldTransforms)}function Nhe(e,t,n,r=!1){return mm(n,e.A(r?4:3,t))}function mm(e,t){if(kG(e=Ca(e)))return hT("Unsupported field value:",t,e),SG(e,t);if(e instanceof pm)return(function(r,i){if(!EG(i.dataSource))throw i.yc(`${r._methodName}() can only be used with update() and set()`);if(!i.path)throw i.yc(`${r._methodName}() is not currently supported inside arrays`);const a=r._toFieldTransform(i);a&&i.fieldTransforms.push(a)})(e,t),null;if(e===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.arrayElement&&t.dataSource!==4)throw t.yc("Nested arrays are not supported");return(function(r,i){const a=[];let o=0;for(const c of r){let h=mm(c,i.gc(o));h==null&&(h={nullValue:"NULL_VALUE"}),a.push(h),o++}return{arrayValue:{values:a}}})(e,t)}return(function(r,i){if((r=Ca(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return uH(i.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){const a=jr.fromDate(r);return{timestampValue:og(i.serializer,a)}}if(r instanceof jr){const a=new jr(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:og(i.serializer,a)}}if(r instanceof Iu)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof ac)return{bytesValue:wH(i.serializer,r._byteString)};if(r instanceof Ws){const a=i.databaseId,o=r.firestore._databaseId;if(!o.isEqual(a))throw i.yc(`Document reference is for database ${o.projectId}/${o.database} but should be for database ${a.projectId}/${a.database}`);return{referenceValue:Dj(r.firestore._databaseId||i.databaseId,r._key.path)}}if(r instanceof Bc)return(function(o,c){const h=o instanceof Bc?o.toArray():o;return{mapValue:{fields:{[Sj]:{stringValue:kj},[tg]:{arrayValue:{values:h.map((m=>{if(typeof m!="number")throw c.yc("VectorValues must only contain numeric values.");return jj(c.serializer,m)}))}}}}}})(r,i);if(TH(r))return r._toProto(i.serializer);throw i.yc(`Unsupported field value: ${MN(r)}`)})(e,t)}function SG(e,t){const n={};return L$(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):Af(e,((r,i)=>{const a=mm(i,t.dc(r));a!=null&&(n[r]=a)})),{mapValue:{fields:n}}}function kG(e){return!(typeof e!="object"||e===null||e instanceof Array||e instanceof Date||e instanceof jr||e instanceof Iu||e instanceof ac||e instanceof Ws||e instanceof pm||e instanceof Bc||TH(e))}function hT(e,t,n){if(!kG(n)||!v$(n)){const r=MN(n);throw r==="an object"?t.yc(e+" a custom object"):t.yc(e+" "+r)}}function nm(e,t,n){if((t=Ca(t))instanceof oT)return t._internalPath;if(typeof t=="string")return CG(e,t);throw o2("Field path arguments must be of type string or ",e,!1,void 0,n)}const Ehe=new RegExp("[~\\*/\\[\\]]");function CG(e,t,n){if(t.search(Ehe)>=0)throw o2(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new oT(...t.split("."))._internalPath}catch{throw o2(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function o2(e,t,n,r,i){const a=r&&!r.isEmpty(),o=i!==void 0;let c=`Function ${t}() called with invalid data`;n&&(c+=" (via `toFirestore()`)"),c+=". ";let h="";return(a||o)&&(h+=" (found",a&&(h+=` in field ${r}`),o&&(h+=` in document ${i}`),h+=")"),new Jt(bt.INVALID_ARGUMENT,c+e+h)}function IG(e,t){return e.some((n=>n.isEqual(t)))}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class Ahe{convertValue(t,n="none"){switch(hf(t)){case 0:return null;case 1:return t.booleanValue;case 2:return _s(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,n);case 5:return t.stringValue;case 6:return this.convertBytes(Vd(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,n);case 11:return this.convertObject(t.mapValue,n);case 10:return this.convertVectorValue(t.mapValue);default:throw Cn(62114,{value:t})}}convertObject(t,n){return this.convertObjectMap(t.fields,n)}convertObjectMap(t,n="none"){const r={};return Af(t,((i,a)=>{r[i]=this.convertValue(a,n)})),r}convertVectorValue(t){var r,i,a;const n=(a=(i=(r=t.fields)==null?void 0:r[tg].arrayValue)==null?void 0:i.values)==null?void 0:a.map((o=>_s(o.doubleValue)));return new Bc(n)}convertGeoPoint(t){return new Iu(_s(t.latitude),_s(t.longitude))}convertArray(t,n){return(t.values||[]).map((r=>this.convertValue(r,n)))}convertServerTimestamp(t,n){switch(n){case"previous":const r=FN(t);return r==null?null:this.convertValue(r,n);case"estimate":return this.convertTimestamp(G1(t));default:return null}}convertTimestamp(t){const n=zd(t);return new jr(n.seconds,n.nanos)}convertDocumentKey(t,n){const r=Ei.fromString(t);Xn(jH(r),9688,{name:t});const i=new Kp(r.get(1),r.get(3)),a=new hn(r.popFirst(5));return i.isEqual(n)||ea(`Document ${a} contains a document reference within a different database (${i.projectId}/${i.database}) which is not supported. It will be treated as a reference in the current database (${n.projectId}/${n.database}) instead.`),a}}/** * @license * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class sE extends Ahe{constructor(t){super(),this.firestore=t}convertBytes(t){return new ac(t)}convertReference(t){const n=this.convertDocumentKey(t,this.firestore._databaseId);return new Ws(this.firestore,null,n)}}function Bn(){return new lT("serverTimestamp")}function GD(...e){return new cT("arrayUnion",e)}function qD(...e){return new uT("arrayRemove",e)}function Ur(e){return new dT("increment",e)}const WD="@firebase/firestore",KD="4.13.0";/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function YD(e){return(function(n,r){if(typeof n!="object"||n===null)return!1;const i=n;for(const a of r)if(a in i&&typeof i[a]=="function")return!0;return!1})(e,["next","error","complete"])}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class _he{constructor(t="count",n){this._internalFieldPath=n,this.type="AggregateField",this.aggregateType=t}}class She{constructor(t,n,r){this._userDataWriter=n,this._data=r,this.type="AggregateQuerySnapshot",this.query=t}data(){return this._userDataWriter.convertObjectMap(this._data)}_fieldsProto(){return new io({mapValue:{fields:this._data}}).clone().value.mapValue.fields}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */class jG{constructor(t,n,r,i,a){this._firestore=t,this._userDataWriter=n,this._key=r,this._document=i,this._converter=a}get id(){return this._key.path.lastSegment()}get ref(){return new Ws(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const t=new khe(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){var t;return((t=this._document)==null?void 0:t.data.clone().value.mapValue.fields)??void 0}get(t){if(this._document){const n=this._document.data.field(nm("DocumentSnapshot.get",t));if(n!==null)return this._userDataWriter.convertValue(n)}}}class khe extends jG{data(){return super.data()}}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function TG(e){if(e.limitType==="L"&&e.explicitOrderBy.length===0)throw new Jt(bt.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class fT{}class pT extends fT{}function Qt(e,t,...n){let r=[];t instanceof fT&&r.push(t),r=r.concat(n),(function(a){const o=a.filter((h=>h instanceof mT)).length,c=a.filter((h=>h instanceof aE)).length;if(o>1||o>0&&c>0)throw new Jt(bt.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")})(r);for(const i of r)e=i._apply(e);return e}class aE extends pT{constructor(t,n,r){super(),this._field=t,this._op=n,this._value=r,this.type="where"}static _create(t,n,r){return new aE(t,n,r)}_apply(t){const n=this._parse(t);return OG(t._query,n),new Gu(t.firestore,t.converter,qk(t._query,n))}_parse(t){const n=rE(t.firestore);return(function(a,o,c,h,f,m,y){let w;if(f.isKeyField()){if(m==="array-contains"||m==="array-contains-any")throw new Jt(bt.INVALID_ARGUMENT,`Invalid Query. You can't perform '${m}' queries on documentId().`);if(m==="in"||m==="not-in"){QD(y,m);const k=[];for(const I of y)k.push(XD(h,a,I));w={arrayValue:{values:k}}}else w=XD(h,a,y)}else m!=="in"&&m!=="not-in"&&m!=="array-contains-any"||QD(y,m),w=Nhe(c,o,y,m==="in"||m==="not-in");return ii.create(f,m,w)})(t._query,"where",n,t.firestore._databaseId,this._field,this._op,this._value)}}function Nr(e,t,n){const r=t,i=nm("where",e);return aE._create(i,r,n)}class mT extends fT{constructor(t,n){super(),this.type=t,this._queryConstraints=n}static _create(t,n){return new mT(t,n)}_parse(t){const n=this._queryConstraints.map((r=>r._parse(t))).filter((r=>r.getFilters().length>0));return n.length===1?n[0]:Fi.create(n,this._getOperator())}_apply(t){const n=this._parse(t);return n.getFilters().length===0?t:((function(i,a){let o=i;const c=a.getFlattenedFilters();for(const h of c)OG(o,h),o=qk(o,h)})(t._query,n),new Gu(t.firestore,t.converter,qk(t._query,n)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class gT extends pT{constructor(t,n){super(),this._field=t,this._direction=n,this.type="orderBy"}static _create(t,n){return new gT(t,n)}_apply(t){const n=(function(i,a,o){if(i.startAt!==null)throw new Jt(bt.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(i.endAt!==null)throw new Jt(bt.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new Y1(a,o)})(t._query,this._field,this._direction);return new Gu(t.firestore,t.converter,Yce(t._query,n))}}function pi(e,t="asc"){const n=t,r=nm("orderBy",e);return gT._create(r,n)}class xT extends pT{constructor(t,n,r){super(),this.type=t,this._limit=n,this._limitType=r}static _create(t,n,r){return new xT(t,n,r)}_apply(t){return new Gu(t.firestore,t.converter,Yw(t._query,this._limit,this._limitType))}}function Pi(e){return nce("limit",e),xT._create("limit",e,"F")}function XD(e,t,n){if(typeof(n=Ca(n))=="string"){if(n==="")throw new Jt(bt.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!tH(t)&&n.indexOf("/")!==-1)throw new Jt(bt.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=t.path.child(Ei.fromString(n));if(!hn.isDocumentKey(r))throw new Jt(bt.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return W1(e,new hn(r))}if(n instanceof Ws)return W1(e,n._key);throw new Jt(bt.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${MN(n)}.`)}function QD(e,t){if(!Array.isArray(e)||e.length===0)throw new Jt(bt.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function OG(e,t){const n=(function(i,a){for(const o of i)for(const c of o.getFlattenedFilters())if(a.indexOf(c.op)>=0)return c.op;return null})(e.filters,(function(i){switch(i){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[]}})(t.op));if(n!==null)throw n===t.op?new Jt(bt.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new Jt(bt.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}function PG(e,t,n){let r;return r=e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t,r}function Che(){return new _he("count")}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Px(e){return Ihe(e,{count:Che()})}function Ihe(e,t){const n=qo(e.firestore,Du),r=Ry(n),i=Pce(t,((a,o)=>new oue(o,a.aggregateType,a._internalFieldPath)));return che(r,e._query,i).then((a=>(function(c,h,f){const m=new sE(c);return new She(h,m,f)})(n,e,a)))}class jhe{constructor(t){this.kind="memory",this._onlineComponentProvider=hg.provider,this._offlineComponentProvider=t!=null&&t.garbageCollector?t.garbageCollector._offlineComponentProvider:{build:()=>new bG(void 0)}}toJSON(){return{kind:this.kind}}}class The{constructor(t){let n;this.kind="persistent",t!=null&&t.tabManager?(t.tabManager._initialize(t),n=t.tabManager):(n=Mhe(void 0),n._initialize(t)),this._onlineComponentProvider=n._onlineComponentProvider,this._offlineComponentProvider=n._offlineComponentProvider}toJSON(){return{kind:this.kind}}}function Ohe(e){return new jhe(e)}function Phe(e){return new The(e)}class Rhe{constructor(t){this.forceOwnership=t,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(t){this._onlineComponentProvider=hg.provider,this._offlineComponentProvider={build:n=>new vG(n,t==null?void 0:t.cacheSizeBytes,this.forceOwnership)}}}class Dhe{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(t){this._onlineComponentProvider=hg.provider,this._offlineComponentProvider={build:n=>new the(n,t==null?void 0:t.cacheSizeBytes)}}}function Mhe(e){return new Rhe(e==null?void 0:e.forceOwnership)}function Lhe(){return new Dhe}class a1{constructor(t,n){this.hasPendingWrites=t,this.fromCache=n}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}}class Pp extends jG{constructor(t,n,r,i,a,o){super(t,n,r,i,o),this._firestore=t,this._firestoreImpl=t,this.metadata=a}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){const n=new pw(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(n,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}}get(t,n={}){if(this._document){const r=this._document.data.field(nm("DocumentSnapshot.get",t));if(r!==null)return this._userDataWriter.convertValue(r,n.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new Jt(bt.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const t=this._document,n={};return n.type=Pp._jsonSchemaVersion,n.bundle="",n.bundleSource="DocumentSnapshot",n.bundleName=this._key.toString(),!t||!t.isValidDocument()||!t.isFoundDocument()?n:(this._userDataWriter.convertObjectMap(t.data.value.mapValue.fields,"previous"),n.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),n)}}Pp._jsonSchemaVersion="firestore/documentSnapshot/1.0",Pp._jsonSchema={type:da("string",Pp._jsonSchemaVersion),bundleSource:da("string","DocumentSnapshot"),bundleName:da("string"),bundle:da("string")};class pw extends Pp{data(t={}){return super.data(t)}}class Rp{constructor(t,n,r,i){this._firestore=t,this._userDataWriter=n,this._snapshot=i,this.metadata=new a1(i.hasPendingWrites,i.fromCache),this.query=r}get docs(){const t=[];return this.forEach((n=>t.push(n))),t}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(t,n){this._snapshot.docs.forEach((r=>{t.call(n,new pw(this._firestore,this._userDataWriter,r.key,r,new a1(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(t={}){const n=!!t.includeMetadataChanges;if(n&&this._snapshot.excludesMetadataChanges)throw new Jt(bt.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(i,a){if(i._snapshot.oldDocs.isEmpty()){let o=0;return i._snapshot.docChanges.map((c=>{const h=new pw(i._firestore,i._userDataWriter,c.doc.key,c.doc,new a1(i._snapshot.mutatedKeys.has(c.doc.key),i._snapshot.fromCache),i.query.converter);return c.doc,{type:"added",doc:h,oldIndex:-1,newIndex:o++}}))}{let o=i._snapshot.oldDocs;return i._snapshot.docChanges.filter((c=>a||c.type!==3)).map((c=>{const h=new pw(i._firestore,i._userDataWriter,c.doc.key,c.doc,new a1(i._snapshot.mutatedKeys.has(c.doc.key),i._snapshot.fromCache),i.query.converter);let f=-1,m=-1;return c.type!==0&&(f=o.indexOf(c.doc.key),o=o.delete(c.doc.key)),c.type!==1&&(o=o.add(c.doc),m=o.indexOf(c.doc.key)),{type:Uhe(c.type),doc:h,oldIndex:f,newIndex:m}}))}})(this,n),this._cachedChangesIncludeMetadataChanges=n),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new Jt(bt.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const t={};t.type=Rp._jsonSchemaVersion,t.bundleSource="QuerySnapshot",t.bundleName=xj.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const n=[],r=[],i=[];return this.docs.forEach((a=>{a._document!==null&&(n.push(a._document),r.push(this._userDataWriter.convertObjectMap(a._document.data.value.mapValue.fields,"previous")),i.push(a.ref.path))})),t.bundle=(this._firestore,this.query._query,t.bundleName,"NOT SUPPORTED"),t}}function Uhe(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return Cn(61501,{type:e})}}/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */Rp._jsonSchemaVersion="firestore/querySnapshot/1.0",Rp._jsonSchema={type:da("string",Rp._jsonSchemaVersion),bundleSource:da("string","QuerySnapshot"),bundleName:da("string"),bundle:da("string")};/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function cs(e){e=qo(e,Ws);const t=qo(e.firestore,Du),n=Ry(t);return ohe(n,e._key).then((r=>RG(t,e,r)))}function vn(e){e=qo(e,Gu);const t=qo(e.firestore,Du),n=Ry(t),r=new sE(t);return TG(e._query),lhe(n,e._query).then((i=>new Rp(t,r,e,i)))}function Hr(e,t,n){e=qo(e,Ws);const r=qo(e.firestore,Du),i=PG(e.converter,t,n),a=rE(r);return oE(r,[AG(a,"setDoc",e._key,i,e.converter!==null,n).toMutation(e._key,_o.none())])}function Hn(e,t,n,...r){e=qo(e,Ws);const i=qo(e.firestore,Du),a=rE(i);let o;return o=typeof(t=Ca(t))=="string"||t instanceof oT?whe(a,"updateDoc",e._key,t,n,r):vhe(a,"updateDoc",e._key,t),oE(i,[o.toMutation(e._key,_o.exists(!0))])}function ni(e){return oE(qo(e.firestore,Du),[new WN(e._key,_o.none())])}function ur(e,t){const n=qo(e.firestore,Du),r=ot(e),i=PG(e.converter,t),a=rE(e.firestore);return oE(n,[AG(a,"addDoc",r._key,i,e.converter!==null,{}).toMutation(r._key,_o.exists(!1))]).then((()=>r))}function di(e,...t){var f,m,y;e=Ca(e);let n={includeMetadataChanges:!1,source:"default"},r=0;typeof t[r]!="object"||YD(t[r])||(n=t[r++]);const i={includeMetadataChanges:n.includeMetadataChanges,source:n.source};if(YD(t[r])){const w=t[r];t[r]=(f=w.next)==null?void 0:f.bind(w),t[r+1]=(m=w.error)==null?void 0:m.bind(w),t[r+2]=(y=w.complete)==null?void 0:y.bind(w)}let a,o,c;if(e instanceof Ws)o=qo(e.firestore,Du),c=Cy(e._key.path),a={next:w=>{t[r]&&t[r](RG(o,e,w))},error:t[r+1],complete:t[r+2]};else{const w=qo(e,Gu);o=qo(w.firestore,Du),c=w._query;const A=new sE(o);a={next:k=>{t[r]&&t[r](new Rp(o,A,w,k))},error:t[r+1],complete:t[r+2]},TG(e._query)}const h=Ry(o);return ahe(h,c,i,a)}function oE(e,t){const n=Ry(e);return uhe(n,t)}function RG(e,t,n){const r=n.docs.get(t._key),i=new sE(e);return new Pp(e,i,t._key,r,new a1(n.hasPendingWrites,n.fromCache),t.converter)}(function(t,n=!0){Hle(_g),q0(new Hp("firestore",((r,{instanceIdentifier:i,options:a})=>{const o=r.getProvider("app").getImmediate(),c=new Du(new Wle(r.getProvider("auth-internal")),new Xle(o,r.getProvider("app-check-internal")),Mce(o,i),o);return a={useFetchStreams:n,...a},c._setSettings(a),c}),"PUBLIC").setMultipleInstances(!0)),rf(WD,KD,t),rf(WD,KD,"esm2020")})();const Bhe="AIzaSyCtxUx4H2ZQqg30wPZnyskPGJQE4kGefXQ",zhe="campus-eye-media-app.firebaseapp.com",Vhe="campus-eye-media-app",Fhe="campus-eye-media-app.firebasestorage.app",$he="612194200932",Hhe="1:612194200932:web:f23853033adf101b5e5e71",Ghe="G-8WM12QQDWG",qhe="(default)",l2={apiKey:Bhe,authDomain:zhe,projectId:Vhe,storageBucket:Fhe,messagingSenderId:$he,appId:Hhe,measurementId:Ghe,firestoreDatabaseId:qhe},Whe={...l2,authDomain:l2.authDomain},DG=CF(Whe),Ne=Fle(DG);joe(Ne,n$).catch(()=>{});let aC;try{aC=Phe({tabManager:Lhe()})}catch{aC=Ohe()}const pe=mhe(DG,{localCache:aC,experimentalAutoDetectLongPolling:!0},l2.firestoreDatabaseId),MG=new _d;MG.setCustomParameters({prompt:"select_account"});var Ps=(e=>(e.CREATE="create",e.UPDATE="update",e.DELETE="delete",e.LIST="list",e.GET="get",e.WRITE="write",e))(Ps||{});function Gs(e,t,n){var o,c,h,f,m,y;const r=e instanceof Error?e.message:String(e),i={error:r,authInfo:{userId:(o=Ne.currentUser)==null?void 0:o.uid,email:(c=Ne.currentUser)==null?void 0:c.email,emailVerified:(h=Ne.currentUser)==null?void 0:h.emailVerified,isAnonymous:(f=Ne.currentUser)==null?void 0:f.isAnonymous,tenantId:(m=Ne.currentUser)==null?void 0:m.tenantId,providerInfo:((y=Ne.currentUser)==null?void 0:y.providerData.map(w=>({providerId:w.providerId,displayName:w.displayName,email:w.email,photoUrl:w.photoURL})))||[]},operationType:t,path:n};r.toLowerCase().includes("offline")||r.toLowerCase().includes("could not reach")||r.toLowerCase().includes("unavailable")||r.toLowerCase().includes("network")?console.warn("Firestore Handling [Offline State]: ",JSON.stringify(i)):console.error("Firestore Error: ",JSON.stringify(i))}let Khe={data:""},Yhe=e=>{if(typeof window=="object"){let t=(e?e.querySelector("#_goober"):window._goober)||Object.assign(document.createElement("style"),{innerHTML:" ",id:"_goober"});return t.nonce=window.__nonce__,t.parentNode||(e||document.head).appendChild(t),t.firstChild}return e||Khe},Xhe=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,Qhe=/\/\*[^]*?\*\/| +/g,ZD=/\n+/g,Kh=(e,t)=>{let n="",r="",i="";for(let a in e){let o=e[a];a[0]=="@"?a[1]=="i"?n=a+" "+o+";":r+=a[1]=="f"?Kh(o,a):a+"{"+Kh(o,a[1]=="k"?"":t)+"}":typeof o=="object"?r+=Kh(o,t?t.replace(/([^,])+/g,c=>a.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,h=>/&/.test(h)?h.replace(/&/g,c):c?c+" "+h:h)):a):o!=null&&(a=/^--/.test(a)?a:a.replace(/[A-Z]/g,"-$&").toLowerCase(),i+=Kh.p?Kh.p(a,o):a+":"+o+";")}return n+(t&&i?t+"{"+i+"}":i)+r},bd={},LG=e=>{if(typeof e=="object"){let t="";for(let n in e)t+=n+LG(e[n]);return t}return e},Zhe=(e,t,n,r,i)=>{let a=LG(e),o=bd[a]||(bd[a]=(h=>{let f=0,m=11;for(;f>>0;return"go"+m})(a));if(!bd[o]){let h=a!==e?e:(f=>{let m,y,w=[{}];for(;m=Xhe.exec(f.replace(Qhe,""));)m[4]?w.shift():m[3]?(y=m[3].replace(ZD," ").trim(),w.unshift(w[0][y]=w[0][y]||{})):w[0][m[1]]=m[2].replace(ZD," ").trim();return w[0]})(e);bd[o]=Kh(i?{["@keyframes "+o]:h}:h,n?"":"."+o)}let c=n&&bd.g?bd.g:null;return n&&(bd.g=bd[o]),((h,f,m,y)=>{y?f.data=f.data.replace(y,h):f.data.indexOf(h)===-1&&(f.data=m?h+f.data:f.data+h)})(bd[o],t,r,c),o},Jhe=(e,t,n)=>e.reduce((r,i,a)=>{let o=t[a];if(o&&o.call){let c=o(n),h=c&&c.props&&c.props.className||/^go/.test(c)&&c;o=h?"."+h:c&&typeof c=="object"?c.props?"":Kh(c,""):c===!1?"":c}return r+i+(o??"")},"");function lE(e){let t=this||{},n=e.call?e(t.p):e;return Zhe(n.unshift?n.raw?Jhe(n,[].slice.call(arguments,1),t.p):n.reduce((r,i)=>Object.assign(r,i&&i.call?i(t.p):i),{}):n,Yhe(t.target),t.g,t.o,t.k)}let UG,oC,lC;lE.bind({g:1});let Fd=lE.bind({k:1});function efe(e,t,n,r){Kh.p=t,UG=e,oC=n,lC=r}function Sf(e,t){let n=this||{};return function(){let r=arguments;function i(a,o){let c=Object.assign({},a),h=c.className||i.className;n.p=Object.assign({theme:oC&&oC()},c),n.o=/ *go\d+/.test(h),c.className=lE.apply(n,r)+(h?" "+h:"");let f=e;return e[0]&&(f=c.as||e,delete c.as),lC&&f[0]&&lC(c),UG(f,c)}return i}}var tfe=e=>typeof e=="function",c2=(e,t)=>tfe(e)?e(t):e,nfe=(()=>{let e=0;return()=>(++e).toString()})(),BG=(()=>{let e;return()=>{if(e===void 0&&typeof window<"u"){let t=matchMedia("(prefers-reduced-motion: reduce)");e=!t||t.matches}return e}})(),rfe=20,yT="default",zG=(e,t)=>{let{toastLimit:n}=e.settings;switch(t.type){case 0:return{...e,toasts:[t.toast,...e.toasts].slice(0,n)};case 1:return{...e,toasts:e.toasts.map(o=>o.id===t.toast.id?{...o,...t.toast}:o)};case 2:let{toast:r}=t;return zG(e,{type:e.toasts.find(o=>o.id===r.id)?1:0,toast:r});case 3:let{toastId:i}=t;return{...e,toasts:e.toasts.map(o=>o.id===i||i===void 0?{...o,dismissed:!0,visible:!1}:o)};case 4:return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(o=>o.id!==t.toastId)};case 5:return{...e,pausedAt:t.time};case 6:let a=t.time-(e.pausedAt||0);return{...e,pausedAt:void 0,toasts:e.toasts.map(o=>({...o,pauseDuration:o.pauseDuration+a}))}}},mw=[],VG={toasts:[],pausedAt:void 0,settings:{toastLimit:rfe}},Eu={},FG=(e,t=yT)=>{Eu[t]=zG(Eu[t]||VG,e),mw.forEach(([n,r])=>{n===t&&r(Eu[t])})},$G=e=>Object.keys(Eu).forEach(t=>FG(e,t)),ife=e=>Object.keys(Eu).find(t=>Eu[t].toasts.some(n=>n.id===e)),cE=(e=yT)=>t=>{FG(t,e)},sfe={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},afe=(e={},t=yT)=>{let[n,r]=j.useState(Eu[t]||VG),i=j.useRef(Eu[t]);j.useEffect(()=>(i.current!==Eu[t]&&r(Eu[t]),mw.push([t,r]),()=>{let o=mw.findIndex(([c])=>c===t);o>-1&&mw.splice(o,1)}),[t]);let a=n.toasts.map(o=>{var c,h,f;return{...e,...e[o.type],...o,removeDelay:o.removeDelay||((c=e[o.type])==null?void 0:c.removeDelay)||(e==null?void 0:e.removeDelay),duration:o.duration||((h=e[o.type])==null?void 0:h.duration)||(e==null?void 0:e.duration)||sfe[o.type],style:{...e.style,...(f=e[o.type])==null?void 0:f.style,...o.style}}});return{...n,toasts:a}},ofe=(e,t="blank",n)=>({createdAt:Date.now(),visible:!0,dismissed:!1,type:t,ariaProps:{role:"status","aria-live":"polite"},message:e,pauseDuration:0,...n,id:(n==null?void 0:n.id)||nfe()}),Dy=e=>(t,n)=>{let r=ofe(t,e,n);return cE(r.toasterId||ife(r.id))({type:2,toast:r}),r.id},me=(e,t)=>Dy("blank")(e,t);me.error=Dy("error");me.success=Dy("success");me.loading=Dy("loading");me.custom=Dy("custom");me.dismiss=(e,t)=>{let n={type:3,toastId:e};t?cE(t)(n):$G(n)};me.dismissAll=e=>me.dismiss(void 0,e);me.remove=(e,t)=>{let n={type:4,toastId:e};t?cE(t)(n):$G(n)};me.removeAll=e=>me.remove(void 0,e);me.promise=(e,t,n)=>{let r=me.loading(t.loading,{...n,...n==null?void 0:n.loading});return typeof e=="function"&&(e=e()),e.then(i=>{let a=t.success?c2(t.success,i):void 0;return a?me.success(a,{id:r,...n,...n==null?void 0:n.success}):me.dismiss(r),i}).catch(i=>{let a=t.error?c2(t.error,i):void 0;a?me.error(a,{id:r,...n,...n==null?void 0:n.error}):me.dismiss(r)}),e};var lfe=1e3,cfe=(e,t="default")=>{let{toasts:n,pausedAt:r}=afe(e,t),i=j.useRef(new Map).current,a=j.useCallback((y,w=lfe)=>{if(i.has(y))return;let A=setTimeout(()=>{i.delete(y),o({type:4,toastId:y})},w);i.set(y,A)},[]);j.useEffect(()=>{if(r)return;let y=Date.now(),w=n.map(A=>{if(A.duration===1/0)return;let k=(A.duration||0)+A.pauseDuration-(y-A.createdAt);if(k<0){A.visible&&me.dismiss(A.id);return}return setTimeout(()=>me.dismiss(A.id,t),k)});return()=>{w.forEach(A=>A&&clearTimeout(A))}},[n,r,t]);let o=j.useCallback(cE(t),[t]),c=j.useCallback(()=>{o({type:5,time:Date.now()})},[o]),h=j.useCallback((y,w)=>{o({type:1,toast:{id:y,height:w}})},[o]),f=j.useCallback(()=>{r&&o({type:6,time:Date.now()})},[r,o]),m=j.useCallback((y,w)=>{let{reverseOrder:A=!1,gutter:k=8,defaultPosition:I}=w||{},T=n.filter(L=>(L.position||I)===(y.position||I)&&L.height),D=T.findIndex(L=>L.id===y.id),F=T.filter((L,q)=>qL.visible).slice(...A?[F+1]:[0,F]).reduce((L,q)=>L+(q.height||0)+k,0)},[n]);return j.useEffect(()=>{n.forEach(y=>{if(y.dismissed)a(y.id,y.removeDelay);else{let w=i.get(y.id);w&&(clearTimeout(w),i.delete(y.id))}})},[n,a]),{toasts:n,handlers:{updateHeight:h,startPause:c,endPause:f,calculateOffset:m}}},ufe=Fd` from { transform: scale(0) rotate(45deg); opacity: 0; } to { transform: scale(1) rotate(45deg); opacity: 1; }`,dfe=Fd` from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; }`,hfe=Fd` from { transform: scale(0) rotate(90deg); opacity: 0; } to { transform: scale(1) rotate(90deg); opacity: 1; }`,ffe=Sf("div")` width: 20px; opacity: 0; height: 20px; border-radius: 10px; background: ${e=>e.primary||"#ff4b4b"}; position: relative; transform: rotate(45deg); animation: ${ufe} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; animation-delay: 100ms; &:after, &:before { content: ''; animation: ${dfe} 0.15s ease-out forwards; animation-delay: 150ms; position: absolute; border-radius: 3px; opacity: 0; background: ${e=>e.secondary||"#fff"}; bottom: 9px; left: 4px; height: 2px; width: 12px; } &:before { animation: ${hfe} 0.15s ease-out forwards; animation-delay: 180ms; transform: rotate(90deg); } `,pfe=Fd` from { transform: rotate(0deg); } to { transform: rotate(360deg); } `,mfe=Sf("div")` width: 12px; height: 12px; box-sizing: border-box; border: 2px solid; border-radius: 100%; border-color: ${e=>e.secondary||"#e0e0e0"}; border-right-color: ${e=>e.primary||"#616161"}; animation: ${pfe} 1s linear infinite; `,gfe=Fd` from { transform: scale(0) rotate(45deg); opacity: 0; } to { transform: scale(1) rotate(45deg); opacity: 1; }`,xfe=Fd` 0% { height: 0; width: 0; opacity: 0; } 40% { height: 0; width: 6px; opacity: 1; } 100% { opacity: 1; height: 10px; }`,yfe=Sf("div")` width: 20px; opacity: 0; height: 20px; border-radius: 10px; background: ${e=>e.primary||"#61d345"}; position: relative; transform: rotate(45deg); animation: ${gfe} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; animation-delay: 100ms; &:after { content: ''; box-sizing: border-box; animation: ${xfe} 0.2s ease-out forwards; opacity: 0; animation-delay: 200ms; position: absolute; border-right: 2px solid; border-bottom: 2px solid; border-color: ${e=>e.secondary||"#fff"}; bottom: 6px; left: 6px; height: 10px; width: 6px; } `,bfe=Sf("div")` position: absolute; `,vfe=Sf("div")` position: relative; display: flex; justify-content: center; align-items: center; min-width: 20px; min-height: 20px; `,wfe=Fd` from { transform: scale(0.6); opacity: 0.4; } to { transform: scale(1); opacity: 1; }`,Nfe=Sf("div")` position: relative; transform: scale(0.6); opacity: 0.4; min-width: 20px; animation: ${wfe} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; `,Efe=({toast:e})=>{let{icon:t,type:n,iconTheme:r}=e;return t!==void 0?typeof t=="string"?j.createElement(Nfe,null,t):t:n==="blank"?null:j.createElement(vfe,null,j.createElement(mfe,{...r}),n!=="loading"&&j.createElement(bfe,null,n==="error"?j.createElement(ffe,{...r}):j.createElement(yfe,{...r})))},Afe=e=>` 0% {transform: translate3d(0,${e*-200}%,0) scale(.6); opacity:.5;} 100% {transform: translate3d(0,0,0) scale(1); opacity:1;} `,_fe=e=>` 0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;} 100% {transform: translate3d(0,${e*-150}%,-1px) scale(.6); opacity:0;} `,Sfe="0%{opacity:0;} 100%{opacity:1;}",kfe="0%{opacity:1;} 100%{opacity:0;}",Cfe=Sf("div")` display: flex; align-items: center; background: #fff; color: #363636; line-height: 1.3; will-change: transform; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05); max-width: 350px; pointer-events: auto; padding: 8px 10px; border-radius: 8px; `,Ife=Sf("div")` display: flex; justify-content: center; margin: 4px 10px; color: inherit; flex: 1 1 auto; white-space: pre-line; `,jfe=(e,t)=>{let n=e.includes("top")?1:-1,[r,i]=BG()?[Sfe,kfe]:[Afe(n),_fe(n)];return{animation:t?`${Fd(r)} 0.35s cubic-bezier(.21,1.02,.73,1) forwards`:`${Fd(i)} 0.4s forwards cubic-bezier(.06,.71,.55,1)`}},Tfe=j.memo(({toast:e,position:t,style:n,children:r})=>{let i=e.height?jfe(e.position||t||"top-center",e.visible):{opacity:0},a=j.createElement(Efe,{toast:e}),o=j.createElement(Ife,{...e.ariaProps},c2(e.message,e));return j.createElement(Cfe,{className:e.className,style:{...i,...n,...e.style}},typeof r=="function"?r({icon:a,message:o}):j.createElement(j.Fragment,null,a,o))});efe(j.createElement);var Ofe=({id:e,className:t,style:n,onHeightUpdate:r,children:i})=>{let a=j.useCallback(o=>{if(o){let c=()=>{let h=o.getBoundingClientRect().height;r(e,h)};c(),new MutationObserver(c).observe(o,{subtree:!0,childList:!0,characterData:!0})}},[e,r]);return j.createElement("div",{ref:a,className:t,style:n},i)},Pfe=(e,t)=>{let n=e.includes("top"),r=n?{top:0}:{bottom:0},i=e.includes("center")?{justifyContent:"center"}:e.includes("right")?{justifyContent:"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:BG()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${t*(n?1:-1)}px)`,...r,...i}},Rfe=lE` z-index: 9999; > * { pointer-events: auto; } `,xv=16,JD=({reverseOrder:e,position:t="top-center",toastOptions:n,gutter:r,children:i,toasterId:a,containerStyle:o,containerClassName:c})=>{let{toasts:h,handlers:f}=cfe(n,a);return j.createElement("div",{"data-rht-toaster":a||"",style:{position:"fixed",zIndex:9999,top:xv,left:xv,right:xv,bottom:xv,pointerEvents:"none",...o},className:c,onMouseEnter:f.startPause,onMouseLeave:f.endPause},h.map(m=>{let y=m.position||t,w=f.calculateOffset(m,{reverseOrder:e,gutter:r,defaultPosition:t}),A=Pfe(y,w);return j.createElement(Ofe,{id:m.id,key:m.id,onHeightUpdate:f.updateHeight,className:m.visible?Rfe:"",style:A},m.type==="custom"?c2(m.message,m):i?i(m):j.createElement(Tfe,{toast:m,position:y}))}))},sr=me;function HG(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t{const n=new Array(e.length+t.length);for(let r=0;r({classGroupId:e,validator:t}),GG=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),u2="-",e8=[],Lfe="arbitrary..",Ufe=e=>{const t=zfe(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return Bfe(o);const c=o.split(u2),h=c[0]===""&&c.length>1?1:0;return qG(c,h,t)},getConflictingClassGroupIds:(o,c)=>{if(c){const h=r[o],f=n[o];return h?f?Dfe(f,h):h:f||e8}return n[o]||e8}}},qG=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],a=n.nextPart.get(i);if(a){const f=qG(e,t+1,a);if(f)return f}const o=n.validators;if(o===null)return;const c=t===0?e.join(u2):e.slice(t).join(u2),h=o.length;for(let f=0;fe.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?Lfe+r:void 0})(),zfe=e=>{const{theme:t,classGroups:n}=e;return Vfe(n,t)},Vfe=(e,t)=>{const n=GG();for(const r in e){const i=e[r];bT(i,n,r,t)}return n},bT=(e,t,n,r)=>{const i=e.length;for(let a=0;a{if(typeof e=="string"){$fe(e,t,n);return}if(typeof e=="function"){Hfe(e,t,n,r);return}Gfe(e,t,n,r)},$fe=(e,t,n)=>{const r=e===""?t:WG(t,e);r.classGroupId=n},Hfe=(e,t,n,r)=>{if(qfe(e)){bT(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Mfe(n,e))},Gfe=(e,t,n,r)=>{const i=Object.entries(e),a=i.length;for(let o=0;o{let n=e;const r=t.split(u2),i=r.length;for(let a=0;a"isThemeGetter"in e&&e.isThemeGetter===!0,Wfe=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(a,o)=>{n[a]=o,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(a){let o=n[a];if(o!==void 0)return o;if((o=r[a])!==void 0)return i(a,o),o},set(a,o){a in n?n[a]=o:i(a,o)}}},cC="!",t8=":",Kfe=[],n8=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Yfe=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const a=[];let o=0,c=0,h=0,f;const m=i.length;for(let I=0;Ih?f-h:void 0;return n8(a,A,w,k)};if(t){const i=t+t8,a=r;r=o=>o.startsWith(i)?a(o.slice(i.length)):n8(Kfe,!1,o,void 0,!0)}if(n){const i=r;r=a=>n({className:a,parseClassName:i})}return r},Xfe=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let a=0;a0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},Qfe=e=>({cache:Wfe(e.cacheSize),parseClassName:Yfe(e),sortModifiers:Xfe(e),...Ufe(e)}),Zfe=/\s+/,Jfe=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],c=e.trim().split(Zfe);let h="";for(let f=c.length-1;f>=0;f-=1){const m=c[f],{isExternal:y,modifiers:w,hasImportantModifier:A,baseClassName:k,maybePostfixModifierPosition:I}=n(m);if(y){h=m+(h.length>0?" "+h:h);continue}let T=!!I,D=r(T?k.substring(0,I):k);if(!D){if(!T){h=m+(h.length>0?" "+h:h);continue}if(D=r(k),!D){h=m+(h.length>0?" "+h:h);continue}T=!1}const F=w.length===0?"":w.length===1?w[0]:a(w).join(":"),L=A?F+cC:F,q=L+D;if(o.indexOf(q)>-1)continue;o.push(q);const Z=i(D,T);for(let K=0;K0?" "+h:h)}return h},epe=(...e)=>{let t=0,n,r,i="";for(;t{if(typeof e=="string")return e;let t,n="";for(let r=0;r{let n,r,i,a;const o=h=>{const f=t.reduce((m,y)=>y(m),e());return n=Qfe(f),r=n.cache.get,i=n.cache.set,a=c,c(h)},c=h=>{const f=r(h);if(f)return f;const m=Jfe(h,n);return i(h,m),m};return a=o,(...h)=>a(epe(...h))},npe=[],va=e=>{const t=n=>n[e]||npe;return t.isThemeGetter=!0,t},YG=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,XG=/^\((?:(\w[\w-]*):)?(.+)\)$/i,rpe=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ipe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,spe=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ape=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ope=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,lpe=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Oh=e=>rpe.test(e),$r=e=>!!e&&!Number.isNaN(Number(e)),Ph=e=>!!e&&Number.isInteger(Number(e)),Q_=e=>e.endsWith("%")&&$r(e.slice(0,-1)),vd=e=>ipe.test(e),QG=()=>!0,cpe=e=>spe.test(e)&&!ape.test(e),vT=()=>!1,upe=e=>ope.test(e),dpe=e=>lpe.test(e),hpe=e=>!Ln(e)&&!Vn(e),fpe=e=>kf(e,eq,vT),Ln=e=>YG.test(e),Qf=e=>kf(e,tq,cpe),r8=e=>kf(e,wpe,$r),ppe=e=>kf(e,rq,QG),mpe=e=>kf(e,nq,vT),i8=e=>kf(e,ZG,vT),gpe=e=>kf(e,JG,dpe),yv=e=>kf(e,iq,upe),Vn=e=>XG.test(e),Rx=e=>gm(e,tq),xpe=e=>gm(e,nq),s8=e=>gm(e,ZG),ype=e=>gm(e,eq),bpe=e=>gm(e,JG),bv=e=>gm(e,iq,!0),vpe=e=>gm(e,rq,!0),kf=(e,t,n)=>{const r=YG.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},gm=(e,t,n=!1)=>{const r=XG.exec(e);return r?r[1]?t(r[1]):n:!1},ZG=e=>e==="position"||e==="percentage",JG=e=>e==="image"||e==="url",eq=e=>e==="length"||e==="size"||e==="bg-size",tq=e=>e==="length",wpe=e=>e==="number",nq=e=>e==="family-name",rq=e=>e==="number"||e==="weight",iq=e=>e==="shadow",Npe=()=>{const e=va("color"),t=va("font"),n=va("text"),r=va("font-weight"),i=va("tracking"),a=va("leading"),o=va("breakpoint"),c=va("container"),h=va("spacing"),f=va("radius"),m=va("shadow"),y=va("inset-shadow"),w=va("text-shadow"),A=va("drop-shadow"),k=va("blur"),I=va("perspective"),T=va("aspect"),D=va("ease"),F=va("animate"),L=()=>["auto","avoid","all","avoid-page","page","left","right","column"],q=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],Z=()=>[...q(),Vn,Ln],K=()=>["auto","hidden","clip","visible","scroll"],z=()=>["auto","contain","none"],B=()=>[Vn,Ln,h],V=()=>[Oh,"full","auto",...B()],$=()=>[Ph,"none","subgrid",Vn,Ln],Q=()=>["auto",{span:["full",Ph,Vn,Ln]},Ph,Vn,Ln],Y=()=>[Ph,"auto",Vn,Ln],G=()=>["auto","min","max","fr",Vn,Ln],he=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],te=()=>["start","end","center","stretch","center-safe","end-safe"],le=()=>["auto",...B()],ve=()=>[Oh,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...B()],ke=()=>[Oh,"screen","full","dvw","lvw","svw","min","max","fit",...B()],Be=()=>[Oh,"screen","full","lh","dvh","lvh","svh","min","max","fit",...B()],J=()=>[e,Vn,Ln],ie=()=>[...q(),s8,i8,{position:[Vn,Ln]}],xe=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ae=()=>["auto","cover","contain",ype,fpe,{size:[Vn,Ln]}],Fe=()=>[Q_,Rx,Qf],pt=()=>["","none","full",f,Vn,Ln],Ue=()=>["",$r,Rx,Qf],Ct=()=>["solid","dashed","dotted","double"],Tt=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ht=()=>[$r,Q_,s8,i8],Ye=()=>["","none",k,Vn,Ln],Yt=()=>["none",$r,Vn,Ln],dt=()=>["none",$r,Vn,Ln],sn=()=>[$r,Vn,Ln],pn=()=>[Oh,"full",...B()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[vd],breakpoint:[vd],color:[QG],container:[vd],"drop-shadow":[vd],ease:["in","out","in-out"],font:[hpe],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[vd],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[vd],shadow:[vd],spacing:["px",$r],text:[vd],"text-shadow":[vd],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Oh,Ln,Vn,T]}],container:["container"],columns:[{columns:[$r,Ln,Vn,c]}],"break-after":[{"break-after":L()}],"break-before":[{"break-before":L()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:Z()}],overflow:[{overflow:K()}],"overflow-x":[{"overflow-x":K()}],"overflow-y":[{"overflow-y":K()}],overscroll:[{overscroll:z()}],"overscroll-x":[{"overscroll-x":z()}],"overscroll-y":[{"overscroll-y":z()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:V()}],"inset-x":[{"inset-x":V()}],"inset-y":[{"inset-y":V()}],start:[{"inset-s":V(),start:V()}],end:[{"inset-e":V(),end:V()}],"inset-bs":[{"inset-bs":V()}],"inset-be":[{"inset-be":V()}],top:[{top:V()}],right:[{right:V()}],bottom:[{bottom:V()}],left:[{left:V()}],visibility:["visible","invisible","collapse"],z:[{z:[Ph,"auto",Vn,Ln]}],basis:[{basis:[Oh,"full","auto",c,...B()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[$r,Oh,"auto","initial","none",Ln]}],grow:[{grow:["",$r,Vn,Ln]}],shrink:[{shrink:["",$r,Vn,Ln]}],order:[{order:[Ph,"first","last","none",Vn,Ln]}],"grid-cols":[{"grid-cols":$()}],"col-start-end":[{col:Q()}],"col-start":[{"col-start":Y()}],"col-end":[{"col-end":Y()}],"grid-rows":[{"grid-rows":$()}],"row-start-end":[{row:Q()}],"row-start":[{"row-start":Y()}],"row-end":[{"row-end":Y()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":G()}],"auto-rows":[{"auto-rows":G()}],gap:[{gap:B()}],"gap-x":[{"gap-x":B()}],"gap-y":[{"gap-y":B()}],"justify-content":[{justify:[...he(),"normal"]}],"justify-items":[{"justify-items":[...te(),"normal"]}],"justify-self":[{"justify-self":["auto",...te()]}],"align-content":[{content:["normal",...he()]}],"align-items":[{items:[...te(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...te(),{baseline:["","last"]}]}],"place-content":[{"place-content":he()}],"place-items":[{"place-items":[...te(),"baseline"]}],"place-self":[{"place-self":["auto",...te()]}],p:[{p:B()}],px:[{px:B()}],py:[{py:B()}],ps:[{ps:B()}],pe:[{pe:B()}],pbs:[{pbs:B()}],pbe:[{pbe:B()}],pt:[{pt:B()}],pr:[{pr:B()}],pb:[{pb:B()}],pl:[{pl:B()}],m:[{m:le()}],mx:[{mx:le()}],my:[{my:le()}],ms:[{ms:le()}],me:[{me:le()}],mbs:[{mbs:le()}],mbe:[{mbe:le()}],mt:[{mt:le()}],mr:[{mr:le()}],mb:[{mb:le()}],ml:[{ml:le()}],"space-x":[{"space-x":B()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":B()}],"space-y-reverse":["space-y-reverse"],size:[{size:ve()}],"inline-size":[{inline:["auto",...ke()]}],"min-inline-size":[{"min-inline":["auto",...ke()]}],"max-inline-size":[{"max-inline":["none",...ke()]}],"block-size":[{block:["auto",...Be()]}],"min-block-size":[{"min-block":["auto",...Be()]}],"max-block-size":[{"max-block":["none",...Be()]}],w:[{w:[c,"screen",...ve()]}],"min-w":[{"min-w":[c,"screen","none",...ve()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...ve()]}],h:[{h:["screen","lh",...ve()]}],"min-h":[{"min-h":["screen","lh","none",...ve()]}],"max-h":[{"max-h":["screen","lh",...ve()]}],"font-size":[{text:["base",n,Rx,Qf]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,vpe,ppe]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Q_,Ln]}],"font-family":[{font:[xpe,mpe,t]}],"font-features":[{"font-features":[Ln]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,Vn,Ln]}],"line-clamp":[{"line-clamp":[$r,"none",Vn,r8]}],leading:[{leading:[a,...B()]}],"list-image":[{"list-image":["none",Vn,Ln]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Vn,Ln]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:J()}],"text-color":[{text:J()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Ct(),"wavy"]}],"text-decoration-thickness":[{decoration:[$r,"from-font","auto",Vn,Qf]}],"text-decoration-color":[{decoration:J()}],"underline-offset":[{"underline-offset":[$r,"auto",Vn,Ln]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:B()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Vn,Ln]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Vn,Ln]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ie()}],"bg-repeat":[{bg:xe()}],"bg-size":[{bg:ae()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ph,Vn,Ln],radial:["",Vn,Ln],conic:[Ph,Vn,Ln]},bpe,gpe]}],"bg-color":[{bg:J()}],"gradient-from-pos":[{from:Fe()}],"gradient-via-pos":[{via:Fe()}],"gradient-to-pos":[{to:Fe()}],"gradient-from":[{from:J()}],"gradient-via":[{via:J()}],"gradient-to":[{to:J()}],rounded:[{rounded:pt()}],"rounded-s":[{"rounded-s":pt()}],"rounded-e":[{"rounded-e":pt()}],"rounded-t":[{"rounded-t":pt()}],"rounded-r":[{"rounded-r":pt()}],"rounded-b":[{"rounded-b":pt()}],"rounded-l":[{"rounded-l":pt()}],"rounded-ss":[{"rounded-ss":pt()}],"rounded-se":[{"rounded-se":pt()}],"rounded-ee":[{"rounded-ee":pt()}],"rounded-es":[{"rounded-es":pt()}],"rounded-tl":[{"rounded-tl":pt()}],"rounded-tr":[{"rounded-tr":pt()}],"rounded-br":[{"rounded-br":pt()}],"rounded-bl":[{"rounded-bl":pt()}],"border-w":[{border:Ue()}],"border-w-x":[{"border-x":Ue()}],"border-w-y":[{"border-y":Ue()}],"border-w-s":[{"border-s":Ue()}],"border-w-e":[{"border-e":Ue()}],"border-w-bs":[{"border-bs":Ue()}],"border-w-be":[{"border-be":Ue()}],"border-w-t":[{"border-t":Ue()}],"border-w-r":[{"border-r":Ue()}],"border-w-b":[{"border-b":Ue()}],"border-w-l":[{"border-l":Ue()}],"divide-x":[{"divide-x":Ue()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Ue()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Ct(),"hidden","none"]}],"divide-style":[{divide:[...Ct(),"hidden","none"]}],"border-color":[{border:J()}],"border-color-x":[{"border-x":J()}],"border-color-y":[{"border-y":J()}],"border-color-s":[{"border-s":J()}],"border-color-e":[{"border-e":J()}],"border-color-bs":[{"border-bs":J()}],"border-color-be":[{"border-be":J()}],"border-color-t":[{"border-t":J()}],"border-color-r":[{"border-r":J()}],"border-color-b":[{"border-b":J()}],"border-color-l":[{"border-l":J()}],"divide-color":[{divide:J()}],"outline-style":[{outline:[...Ct(),"none","hidden"]}],"outline-offset":[{"outline-offset":[$r,Vn,Ln]}],"outline-w":[{outline:["",$r,Rx,Qf]}],"outline-color":[{outline:J()}],shadow:[{shadow:["","none",m,bv,yv]}],"shadow-color":[{shadow:J()}],"inset-shadow":[{"inset-shadow":["none",y,bv,yv]}],"inset-shadow-color":[{"inset-shadow":J()}],"ring-w":[{ring:Ue()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:J()}],"ring-offset-w":[{"ring-offset":[$r,Qf]}],"ring-offset-color":[{"ring-offset":J()}],"inset-ring-w":[{"inset-ring":Ue()}],"inset-ring-color":[{"inset-ring":J()}],"text-shadow":[{"text-shadow":["none",w,bv,yv]}],"text-shadow-color":[{"text-shadow":J()}],opacity:[{opacity:[$r,Vn,Ln]}],"mix-blend":[{"mix-blend":[...Tt(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Tt()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[$r]}],"mask-image-linear-from-pos":[{"mask-linear-from":ht()}],"mask-image-linear-to-pos":[{"mask-linear-to":ht()}],"mask-image-linear-from-color":[{"mask-linear-from":J()}],"mask-image-linear-to-color":[{"mask-linear-to":J()}],"mask-image-t-from-pos":[{"mask-t-from":ht()}],"mask-image-t-to-pos":[{"mask-t-to":ht()}],"mask-image-t-from-color":[{"mask-t-from":J()}],"mask-image-t-to-color":[{"mask-t-to":J()}],"mask-image-r-from-pos":[{"mask-r-from":ht()}],"mask-image-r-to-pos":[{"mask-r-to":ht()}],"mask-image-r-from-color":[{"mask-r-from":J()}],"mask-image-r-to-color":[{"mask-r-to":J()}],"mask-image-b-from-pos":[{"mask-b-from":ht()}],"mask-image-b-to-pos":[{"mask-b-to":ht()}],"mask-image-b-from-color":[{"mask-b-from":J()}],"mask-image-b-to-color":[{"mask-b-to":J()}],"mask-image-l-from-pos":[{"mask-l-from":ht()}],"mask-image-l-to-pos":[{"mask-l-to":ht()}],"mask-image-l-from-color":[{"mask-l-from":J()}],"mask-image-l-to-color":[{"mask-l-to":J()}],"mask-image-x-from-pos":[{"mask-x-from":ht()}],"mask-image-x-to-pos":[{"mask-x-to":ht()}],"mask-image-x-from-color":[{"mask-x-from":J()}],"mask-image-x-to-color":[{"mask-x-to":J()}],"mask-image-y-from-pos":[{"mask-y-from":ht()}],"mask-image-y-to-pos":[{"mask-y-to":ht()}],"mask-image-y-from-color":[{"mask-y-from":J()}],"mask-image-y-to-color":[{"mask-y-to":J()}],"mask-image-radial":[{"mask-radial":[Vn,Ln]}],"mask-image-radial-from-pos":[{"mask-radial-from":ht()}],"mask-image-radial-to-pos":[{"mask-radial-to":ht()}],"mask-image-radial-from-color":[{"mask-radial-from":J()}],"mask-image-radial-to-color":[{"mask-radial-to":J()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":q()}],"mask-image-conic-pos":[{"mask-conic":[$r]}],"mask-image-conic-from-pos":[{"mask-conic-from":ht()}],"mask-image-conic-to-pos":[{"mask-conic-to":ht()}],"mask-image-conic-from-color":[{"mask-conic-from":J()}],"mask-image-conic-to-color":[{"mask-conic-to":J()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ie()}],"mask-repeat":[{mask:xe()}],"mask-size":[{mask:ae()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Vn,Ln]}],filter:[{filter:["","none",Vn,Ln]}],blur:[{blur:Ye()}],brightness:[{brightness:[$r,Vn,Ln]}],contrast:[{contrast:[$r,Vn,Ln]}],"drop-shadow":[{"drop-shadow":["","none",A,bv,yv]}],"drop-shadow-color":[{"drop-shadow":J()}],grayscale:[{grayscale:["",$r,Vn,Ln]}],"hue-rotate":[{"hue-rotate":[$r,Vn,Ln]}],invert:[{invert:["",$r,Vn,Ln]}],saturate:[{saturate:[$r,Vn,Ln]}],sepia:[{sepia:["",$r,Vn,Ln]}],"backdrop-filter":[{"backdrop-filter":["","none",Vn,Ln]}],"backdrop-blur":[{"backdrop-blur":Ye()}],"backdrop-brightness":[{"backdrop-brightness":[$r,Vn,Ln]}],"backdrop-contrast":[{"backdrop-contrast":[$r,Vn,Ln]}],"backdrop-grayscale":[{"backdrop-grayscale":["",$r,Vn,Ln]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[$r,Vn,Ln]}],"backdrop-invert":[{"backdrop-invert":["",$r,Vn,Ln]}],"backdrop-opacity":[{"backdrop-opacity":[$r,Vn,Ln]}],"backdrop-saturate":[{"backdrop-saturate":[$r,Vn,Ln]}],"backdrop-sepia":[{"backdrop-sepia":["",$r,Vn,Ln]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":B()}],"border-spacing-x":[{"border-spacing-x":B()}],"border-spacing-y":[{"border-spacing-y":B()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Vn,Ln]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[$r,"initial",Vn,Ln]}],ease:[{ease:["linear","initial",D,Vn,Ln]}],delay:[{delay:[$r,Vn,Ln]}],animate:[{animate:["none",F,Vn,Ln]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[I,Vn,Ln]}],"perspective-origin":[{"perspective-origin":Z()}],rotate:[{rotate:Yt()}],"rotate-x":[{"rotate-x":Yt()}],"rotate-y":[{"rotate-y":Yt()}],"rotate-z":[{"rotate-z":Yt()}],scale:[{scale:dt()}],"scale-x":[{"scale-x":dt()}],"scale-y":[{"scale-y":dt()}],"scale-z":[{"scale-z":dt()}],"scale-3d":["scale-3d"],skew:[{skew:sn()}],"skew-x":[{"skew-x":sn()}],"skew-y":[{"skew-y":sn()}],transform:[{transform:[Vn,Ln,"","none","gpu","cpu"]}],"transform-origin":[{origin:Z()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:pn()}],"translate-x":[{"translate-x":pn()}],"translate-y":[{"translate-y":pn()}],"translate-z":[{"translate-z":pn()}],"translate-none":["translate-none"],accent:[{accent:J()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:J()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Vn,Ln]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":B()}],"scroll-mx":[{"scroll-mx":B()}],"scroll-my":[{"scroll-my":B()}],"scroll-ms":[{"scroll-ms":B()}],"scroll-me":[{"scroll-me":B()}],"scroll-mbs":[{"scroll-mbs":B()}],"scroll-mbe":[{"scroll-mbe":B()}],"scroll-mt":[{"scroll-mt":B()}],"scroll-mr":[{"scroll-mr":B()}],"scroll-mb":[{"scroll-mb":B()}],"scroll-ml":[{"scroll-ml":B()}],"scroll-p":[{"scroll-p":B()}],"scroll-px":[{"scroll-px":B()}],"scroll-py":[{"scroll-py":B()}],"scroll-ps":[{"scroll-ps":B()}],"scroll-pe":[{"scroll-pe":B()}],"scroll-pbs":[{"scroll-pbs":B()}],"scroll-pbe":[{"scroll-pbe":B()}],"scroll-pt":[{"scroll-pt":B()}],"scroll-pr":[{"scroll-pr":B()}],"scroll-pb":[{"scroll-pb":B()}],"scroll-pl":[{"scroll-pl":B()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Vn,Ln]}],fill:[{fill:["none",...J()]}],"stroke-w":[{stroke:[$r,Rx,Qf,r8]}],stroke:[{stroke:["none",...J()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Epe=tpe(Npe);function Ge(...e){return Epe(Di(e))}function Tc(e){return e>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+"M":e>=1e3?(e/1e3).toFixed(1).replace(/\.0$/,"")+"k":e.toString()}function A0(e){return e?e.toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):""}function sq(e){if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof(e==null?void 0:e.toDate)=="function"){const t=e.toDate();return isNaN(t.getTime())?null:t}if(typeof e=="object"&&typeof e.seconds=="number"){const t=new Date(e.seconds*1e3);return isNaN(t.getTime())?null:t}if(typeof e=="number"){const t=new Date(e);return isNaN(t.getTime())?null:t}if(typeof e=="string"){const t=new Date(e);return isNaN(t.getTime())?null:t}return null}function Ape(e){const t=sq(e);return t?t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):""}function gw(e){const t=sq(e);if(!t)return"now";const r=new Date().getTime()-t.getTime();if(r<0)return"now";const i=Math.floor(r/6e4);if(i<60)return`${i||1}m`;const a=Math.floor(i/60);if(a<24)return`${a}hr`;const o=Math.floor(a/24);if(o<7)return`${o}d`;const c=t.getDate(),h=t.getMonth()+1,f=String(t.getFullYear()).substring(2);return`${c}/${h}/${f}`}async function Pd(e){try{window.focus()}catch(t){console.warn("Could not focus window:",t)}try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(e),!0}catch(t){console.warn("Modern Clipboard API failed, trying fallback textarea copy...",t)}try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.fontSize="12pt",t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.width="2em",t.style.height="2em",t.style.padding="0",t.style.border="none",t.style.outline="none",t.style.boxShadow="none",t.style.background="transparent",document.body.appendChild(t);const n=document.activeElement;t.focus(),t.select(),t.setSelectionRange(0,999999);const r=document.execCommand("copy");if(n&&typeof n.focus=="function"&&n.focus(),document.body.removeChild(t),r)return!0}catch(t){console.error("All fallback copy methods failed:",t)}return!1}function _pe(e,t=700,n=80){var o;if(!e||typeof e!="string")return"";if(e.startsWith("data:")||e.startsWith("blob:")||e.endsWith(".svg"))return e;const r=typeof navigator<"u"&&((o=navigator.connection)==null?void 0:o.saveData),i=r?Math.min(t,480):t,a=r?Math.min(n,65):n;if(e.includes("images.unsplash.com"))try{const c=new URL(e);return c.searchParams.set("auto","format"),c.searchParams.set("fit","crop"),c.searchParams.set("w",i.toString()),c.searchParams.set("q",a.toString()),c.toString()}catch{return e}if(e.includes("res.cloudinary.com"))try{return e.includes("/upload/")&&!e.includes("/f_auto")?e.replace("/upload/",`/upload/f_auto,q_auto,w_${i}/`):e}catch{return e}return e.includes("googleusercontent.com")&&e.includes("=s")?e.replace(/=s\d+(-c)?/i,`=s${Math.min(i,200)}-c`):e}const aq=({size:e=20,className:t=""})=>s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",style:{width:e,height:e},className:Ge("fill-current",t),children:s.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),oq=({size:e=20,className:t=""})=>s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",style:{width:e,height:e},className:Ge("fill-current",t),children:s.jsx("path",{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-.17-2.89-.6-4.13-1.47-.13-.09-.26-.18-.38-.28v6.51c.02 2.44-.95 4.93-2.91 6.41-1.96 1.48-4.71 1.94-7.01 1.16-2.31-.78-4.12-2.83-4.76-5.19-.64-2.36-.14-5.04 1.41-6.95 1.55-1.91 4.11-2.97 6.54-2.73v4.07c-1.21-.11-2.47.23-3.41 1.01-.94.78-1.44 2.01-1.31 3.23.13 1.22.95 2.32 2.06 2.86 1.11.54 2.5.47 3.54-.21.93-.61 1.48-1.68 1.46-2.79V.02z"})}),uC=({size:e=16,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{width:e,height:e},className:Ge("shrink-0",t),children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsxs("g",{fill:"none",children:[s.jsx("path",{fill:"url(#SVGv76srdyf_opt)",d:"M12.252 18.506a10.4 10.4 0 0 0 1.875-.302a5.2 5.2 0 0 0 2.342.151a1 1 0 0 1 .094-.007c.279 0 .645.16 1.179.497v-.554a.54.54 0 0 1 .28-.472q.349-.197.645-.443c.778-.65 1.217-1.518 1.217-2.436c0-.303-.048-.605-.143-.893a7 7 0 0 0 .564-1.359c.45.665.692 1.45.695 2.252c0 1.248-.588 2.412-1.607 3.263q-.256.213-.535.392v1.298c0 .446-.522.703-.89.437a14 14 0 0 0-1.08-.72a3 3 0 0 0-.332-.165a6.4 6.4 0 0 1-.935.069c-1.27 0-2.445-.377-3.37-1.008m-6.72-2.595C3.927 14.568 3 12.737 3 10.775c0-4.008 3.832-7.213 8.511-7.213c4.68 0 8.513 3.204 8.513 7.213s-3.833 7.212-8.513 7.212a10 10 0 0 1-1.555-.12c-.22.051-1.102.568-2.372 1.483c-.46.332-1.112.012-1.112-.547V16.59a8 8 0 0 1-.94-.68m4.455.592q.058 0 .117.009q.69.114 1.407.115c3.953 0 7.116-2.645 7.116-5.852c0-3.206-3.163-5.85-7.115-5.85s-7.117 2.644-7.117 5.85c0 1.55.74 3.01 2.046 4.103q.494.412 1.076.74a.68.68 0 0 1 .35.589v1.276c1.005-.665 1.666-.98 2.12-.98"}),s.jsx("path",{fill:"url(#SVGv76srdyf_opt)",d:"M8.062 12a1.125 1.125 0 1 0 0-2.25a1.125 1.125 0 0 0 0 2.25"}),s.jsx("path",{fill:"url(#SVGv76srdyf_opt)",d:"M11.719 12a1.125 1.125 0 1 0 0-2.25a1.125 1.125 0 0 0 0 2.25"}),s.jsx("path",{fill:"url(#SVGohGBlcQN_opt)",d:"M15.375 12a1.125 1.125 0 1 0 0-2.25a1.125 1.125 0 0 0 0 2.25"}),s.jsxs("defs",{children:[s.jsxs("linearGradient",{id:"SVGv76srdyf_opt",x1:"12",x2:"12",y1:"3.562",y2:"20.438",gradientUnits:"userSpaceOnUse",children:[s.jsx("stop",{stopColor:"#1bc9fa"}),s.jsx("stop",{offset:"1",stopColor:"#1778f0"})]}),s.jsxs("linearGradient",{id:"SVGohGBlcQN_opt",x1:"12",x2:"12",y1:"3.561",y2:"20.437",gradientUnits:"userSpaceOnUse",children:[s.jsx("stop",{stopColor:"#1bc9fa"}),s.jsx("stop",{offset:"1",stopColor:"#1778f0"})]})]})]})]}),lq=({size:e=16,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 14 14",style:{width:e,height:e},className:Ge("shrink-0",t),children:[s.jsx("path",{d:"M0 0h14v14H0z",fill:"none"}),s.jsxs("g",{fill:"none",fillRule:"evenodd",clipRule:"evenodd",children:[s.jsx("path",{fill:"#8fbffa",d:"M6.45 1.418a1.504 1.504 0 0 1 2.72 1.073L8.973 3.89h1.915c.567 0 1.327.268 1.944.762C13.466 5.158 14 5.944 14 7c0 .986-.477 2.502-1.169 3.755c-.35.634-.77 1.233-1.245 1.681c-.469.442-1.043.786-1.687.786c-2.447 0-4.304-.313-7.155-1.44a1 1 0 0 0 .006-.129v-5.05z"}),s.jsx("path",{fill:"#2859c5",d:"M1.375 4.528C.615 4.528 0 5.144 0 5.903v5.75a1.375 1.375 0 1 0 2.75 0v-5.75c0-.76-.616-1.375-1.375-1.375"})]})]}),a8=({size:e=16,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{width:e,height:e},className:Ge("shrink-0",t),children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsx("path",{fill:"#2233ca",fillOpacity:".25",d:"M20.188 10.934c.388.472.582.707.582 1.066s-.194.594-.582 1.066C18.768 14.79 15.636 18 12 18s-6.768-3.21-8.188-4.934c-.388-.472-.582-.707-.582-1.066s.194-.594.582-1.066C5.232 9.21 8.364 6 12 6s6.768 3.21 8.188 4.934"}),s.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"#2233ca"})]}),cq=({size:e=16,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",style:{width:e,height:e},className:Ge("shrink-0",t),children:[s.jsx("path",{d:"M0 0h16v16H0z",fill:"none"}),s.jsxs("g",{fill:"none",children:[s.jsx("path",{fill:"url(#SVGznV2abgm_opt)",d:"M3.78 13.919a.5.5 0 0 1-.778-.416V4.012a2 2 0 0 1 1.996-2l6-.011a2 2 0 0 1 2.004 1.996v9.506a.5.5 0 0 1-.778.416l-4.222-2.82z"}),s.jsx("defs",{children:s.jsxs("linearGradient",{id:"SVGznV2abgm_opt",x1:"3.002",x2:"9.302",y1:"3.019",y2:"11.914",gradientUnits:"userSpaceOnUse",children:[s.jsx("stop",{stopColor:"#f97dbd"}),s.jsx("stop",{offset:"1",stopColor:"#d7257d"})]})})]})]}),dC=({size:e=16,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{width:e,height:e},className:Ge("shrink-0",t),children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsx("path",{fill:"#2233ca",d:"M14 5v4C7 10 4 15 3 20c2.5-3.5 6-5.1 11-5.1V19l7-7zm2 4.83L18.17 12L16 14.17V12.9h-2c-2.07 0-3.93.38-5.66.95c1.4-1.39 3.2-2.48 5.94-2.85l1.72-.27z"})]}),Ll=({size:e=14,className:t="",tooltipText:n="Verified User"})=>{const[r,i]=se.useState(!1),a=o=>{o.stopPropagation(),o.preventDefault(),i(c=>!c),sr.success("Verified Account: This user's identity and editorial credentials have been fully verified by Campus Eye.",{icon:"🛡️",duration:3500})};return s.jsxs("span",{onClick:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),className:Ge("relative inline-flex items-center justify-center cursor-pointer select-none transition-transform duration-300 hover:scale-125 active:scale-90",t),children:[r&&s.jsxs("span",{className:"absolute bottom-full mb-2 left-1/2 -translate-x-1/2 z-50 pointer-events-none flex flex-col items-center animate-in fade-in zoom-in-95 duration-150",children:[s.jsx("span",{className:"bg-white text-gray-900 text-[11px] font-semibold px-2.5 py-1 rounded-md shadow-xl border border-gray-200/90 whitespace-nowrap leading-tight",children:n}),s.jsx("span",{className:"w-0 h-0 border-x-4 border-x-transparent border-t-4 border-t-white -mt-[0.5px] filter drop-shadow-xs"})]}),s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{width:e,height:e},className:"shrink-0",children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsx("path",{fill:"#1d9bf0",fillRule:"evenodd",d:"M15.418 5.643a1.25 1.25 0 0 0-1.34-.555l-1.798.413a1.25 1.25 0 0 1-.56 0l-1.798-.413a1.25 1.25 0 0 0-1.34-.555l-.98 1.564c-.1.16-.235.295-.395.396l-1.564.98a1.25 1.25 0 0 0-.555 1.338l.413 1.8a1.25 1.25 0 0 1 0 .559l-.413 1.799a1.25 1.25 0 0 0 .555 1.339l1.564.98c.16.1.295.235.396.395l.98 1.564c.282.451.82.674 1.339.555l1.798-.413a1.25 1.25 0 0 1 .56 0l1.799.413a1.25 1.25 0 0 0 1.339-.555l.98-1.564c.1-.16.235-.295.395-.395l1.565-.98a1.25 1.25 0 0 0 .554-1.34L18.5 12.28a1.25 1.25 0 0 1 0-.56l.413-1.799a1.25 1.25 0 0 0-.554-1.339l-1.565-.98a1.25 1.25 0 0 1-.395-.395zm-.503 4.127a.5.5 0 0 0-.86-.509l-2.615 4.426l-1.579-1.512a.5.5 0 1 0-.691.722l2.034 1.949a.5.5 0 0 0 .776-.107z",clipRule:"evenodd"})]})]})},Spe=({size:e=16,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",style:{width:e,height:e},className:Ge("shrink-0",t),children:[s.jsx("path",{d:"M0 0h16v16H0z",fill:"none"}),s.jsx("path",{fill:"none",stroke:"#ea0e21",d:"M2 2.5h12M7.979 13.906V4.957m4.13 3.889L7.98 4.715l-4.131 4.13"})]}),kpe=({size:e=18,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",style:{width:e,height:e},className:Ge("shrink-0",t),children:[s.jsx("path",{d:"M0 0h512v512H0z",fill:"none"}),s.jsx("path",{fill:"#af00ea",d:"M108.56 342.78a60.34 60.34 0 1 0 60.56 60.44a60.63 60.63 0 0 0-60.56-60.44"}),s.jsx("path",{fill:"#af00ea",d:"M48 186.67v86.55c52 0 101.94 15.39 138.67 52.11s52 86.56 52 138.67h86.66c0-151.56-125.66-277.33-277.33-277.33"}),s.jsx("path",{fill:"#af00ea",d:"M48 48v86.56c185.25 0 329.22 144.08 329.22 329.44H464C464 234.66 277.67 48 48 48"})]}),Cpe=({size:e=18,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 80 80",style:{width:e,height:e},className:t,children:[s.jsx("path",{d:"M0 0h80v80H0z",fill:"none"}),s.jsxs("g",{fill:"none",children:[s.jsx("path",{fill:"#f2994a",d:"M65.368 67.848a2 2 0 0 0 2.828-2.829zm-9.634-15.29a2 2 0 0 0-2.828 2.828zm12.462 12.461L55.734 52.557l-2.828 2.829l12.462 12.462z"}),s.jsx("path",{fill:"#56ccf2",stroke:"#2f80ed",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"4",d:"M13.578 30.724a24.249 24.249 0 1 1 46.844 12.552a24.249 24.249 0 0 1-46.844-12.552"})]})]}),d2=({size:e=18,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",style:{width:e,height:e},className:t,children:[s.jsx("path",{d:"M0 0h64v64H0z",fill:"none"}),s.jsx("path",{fill:"#454749",d:"M47.5 45.1c-6.6 12.1-6.5 13.1-9.6 11.3S33.6 53 40.3 41S48.9 29.1 52 30.9c3 1.7 2.1 2.2-4.5 14.2"}),s.jsx("path",{fill:"#258399",d:"M53.7 48.7c-4.2 7.7-9.4 11.4-11.9 10c-3.1-1.8-1.5-1.8 5.1-13.9s5.8-13.5 8.9-11.7c2.5 1.4 2.1 7.9-2.1 15.6"}),s.jsx("path",{fill:"#454749",d:"M16.5 45.1c6.6 12.1 6.5 13.1 9.6 11.3S30.4 53 23.7 41S15.1 29.1 12 30.9c-3 1.7-2.1 2.2 4.5 14.2"}),s.jsx("path",{fill:"#258399",d:"M10.3 48.7c4.2 7.7 9.4 11.4-11.9 10c3.1-1.8 1.5-1.8-5.1-13.9s-5.8-13.5-8.9-11.7c-2.5 1.4-2.1 7.9 2.1 15.6"}),s.jsx("path",{fill:"#3baacf",d:"M11.3 57.7s5.4 1.4 5.8 0c2.5-8.1-11.4-12.9-11.4-22.1C5.7 20.8 17.5 8.8 32 8.8s26.3 12 26.3 26.8c0 9.2-13.9 14-11.4 22.1c.4 1.4 5.8 0 5.8 0c5.7-5.6 9.3-13.4 9.3-22.1C62 18.7 48.6 5 32 5S2 18.7 2 35.6c0 8.7 3.6 16.5 9.3 22.1"}),s.jsx("path",{fill:"#454749",d:"M14.9 17.6c3.5-.7 8-5.7 17.1-5.7s13.7 5.1 17.1 5.7c1.4.3 3.8-1.9 3.8-1.9c-5.5-6.3-12-9.5-20.9-9.5s-15.4 3.2-20.9 9.5c0 .1 2.4 2.2 3.8 1.9"})]}),hC=({size:e=18,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{width:e,height:e},className:t,children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsxs("g",{fill:"none",children:[s.jsx("path",{fill:"#ff808c",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M16.304 14.391a1.435 1.435 0 1 0 0-2.87a1.435 1.435 0 0 0 0 2.87",strokeWidth:"0"}),s.jsx("path",{stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M2.915 16.304V8.498m18.171 0v7.806",strokeWidth:"0"}),s.jsx("path",{fill:"#c9f7ca",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.827V1.002H6.74l-.956 3.825zm10.999 0l-1.65-3.296a.96.96 0 0 0-.854-.53H17.26l.957 3.826z",strokeWidth:"0"}),s.jsx("path",{fill:"#fff9bf",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M6.74 1.002H3.505a.96.96 0 0 0-.855.529L1.001 4.827h4.782zm11.476 3.825l-.956-3.825H12v3.825z",strokeWidth:"0"}),s.jsx("path",{fill:"#78eb7b",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M18.216 4.827v2.87c1.398 1.575 3.977 1.048 4.643-.95c.104-.31.15-.637.14-.963v-.957z",strokeWidth:"0"}),s.jsx("path",{fill:"#ffef5e",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M1.002 4.827v.957C.93 7.89 3.167 9.284 5.026 8.292a2.7 2.7 0 0 0 .758-.596V4.827zm10.998 0v3.481c1.746 1.95 4.884 1.641 6.216-.612V4.827z",strokeWidth:"0"}),s.jsx("path",{fill:"#78eb7b",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M5.784 4.827v2.87c1.333 2.252 4.47 2.562 6.217.611v-3.48z",strokeWidth:"0"}),s.jsx("path",{fill:"#c77f67",d:"M22.042 16.304H1.958A.956.956 0 0 0 1 17.26v2.87c0 .527.429.956.957.956h20.084a.956.956 0 0 0 .956-.957V17.26a.956.956 0 0 0-.956-.956"}),s.jsx("path",{fill:"#e3bfb3",d:"M22.042 16.304H1.958A.956.956 0 0 0 1 17.26v1.913c0-.528.429-.957.957-.957h20.084c.528 0 .956.429.956.957V17.26a.956.956 0 0 0-.956-.956"}),s.jsx("path",{stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M22.042 16.304H1.958A.956.956 0 0 0 1 17.26v2.87c0 .527.429.956.957.956h20.084a.956.956 0 0 0 .956-.957V17.26a.956.956 0 0 0-.956-.956M2.915 21.086v1.912m18.171-1.912v1.912",strokeWidth:"0"}),s.jsx("path",{fill:"#ff808c",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M6.261 16.304a1.435 1.435 0 1 0 0-2.87a1.435 1.435 0 0 0 0 2.87",strokeWidth:"0"}),s.jsx("path",{fill:"#ff808c",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M9.131 16.304a1.435 1.435 0 1 0 0-2.87a1.435 1.435 0 0 0 0 2.87m5.738 0a1.435 1.435 0 1 0 0-2.87a1.435 1.435 0 0 0 0 2.87",strokeWidth:"0"}),s.jsx("path",{fill:"#ff808c",stroke:"#191919",strokeLinecap:"round",strokeLinejoin:"round",d:"M17.739 16.304a1.435 1.435 0 1 0 0-2.87a1.435 1.435 0 0 0 0 2.87",strokeWidth:"0"})]})]}),Ipe=({size:e=18,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",style:{width:e,height:e},className:t,children:[s.jsx("path",{d:"M0 0h48v48H0z",fill:"none"}),s.jsxs("g",{fill:"none",children:[s.jsx("path",{fill:"url(#SVGqLAKpbTS)",d:"M18.067 27h12v16h-12z"}),s.jsx("path",{fill:"url(#SVGN23V5vIj)",d:"M26.461 7.855a3.78 3.78 0 0 0-4.787 0L8.499 18.597a3.91 3.91 0 0 0-1.432 3.031v17.485C7.067 41.26 8.78 43 10.892 43h8.175V30.5a2.5 2.5 0 0 1 2.5-2.5h5a2.5 2.5 0 0 1 2.5 2.5V43h8.175c2.113 0 3.825-1.74 3.825-3.887V21.628a3.91 3.91 0 0 0-1.43-3.031z"}),s.jsx("path",{fill:"url(#SVGTLMWwcZy)",fillRule:"evenodd",d:"m24.068 9.329l-16 13.215a2.054 2.054 0 0 1-2.852-.262a1.956 1.956 0 0 1 .267-2.794L22.28 5.628a2.83 2.83 0 0 1 3.523-.024l16.805 13.588a1.957 1.957 0 0 1 .307 2.79a2.054 2.054 0 0 1-2.848.3z",clipRule:"evenodd"}),s.jsxs("defs",{children:[s.jsxs("linearGradient",{id:"SVGqLAKpbTS",x1:"24.067",x2:"13.481",y1:"27",y2:"44.65",gradientUnits:"userSpaceOnUse",children:[s.jsx("stop",{stopColor:"#944600"}),s.jsx("stop",{offset:"1",stopColor:"#cd8e02"})]}),s.jsxs("linearGradient",{id:"SVGN23V5vIj",x1:"10.313",x2:"45.173",y1:"5.24",y2:"32",gradientUnits:"userSpaceOnUse",children:[s.jsx("stop",{stopColor:"#ffd394"}),s.jsx("stop",{offset:"1",stopColor:"#ffb357"})]}),s.jsxs("linearGradient",{id:"SVGTLMWwcZy",x1:"17.817",x2:"25.308",y1:".725",y2:"22.452",gradientUnits:"userSpaceOnUse",children:[s.jsx("stop",{stopColor:"#ff921f"}),s.jsx("stop",{offset:"1",stopColor:"#eb4824"})]})]})]})]}),o8=({size:e=18,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{width:e,height:e},className:Ge("shrink-0",t),children:[s.jsx("path",{fill:"none",d:"M0 0h24v24H0z"}),s.jsx("path",{fill:"currentColor",d:"M19 6h-3c0-2.21-1.79-4-4-4S8 3.79 8 6H5c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-7-2c1.1 0 2 .9 2 2h-4c0-1.1.9-2 2-2zm0 10c-2.76 0-5-2.24-5-5h2c0 1.66 1.34 3 3 3s3-1.34 3-3h2c0 2.76-2.24 5-5 5z"})]}),l8=({size:e=20,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 80 80",style:{width:e,height:e},className:Ge("shrink-0",t),children:[s.jsx("path",{d:"M0 0h80v80H0z",fill:"none"}),s.jsxs("g",{fill:"none",strokeLinejoin:"round",strokeWidth:"4",children:[s.jsx("path",{fill:"#f2c94c",stroke:"#f2c94c",strokeLinecap:"square",d:"M60 70H20a4 4 0 0 1-4-4a15.87 15.87 0 0 1 10.3-14.86l1.23-.462a35.53 35.53 0 0 1 24.94 0l1.23.462A15.87 15.87 0 0 1 64 66a4 4 0 0 1-4 4Z"}),s.jsx("path",{fill:"#f2994a",stroke:"#f2994a",strokeLinecap:"round",d:"M33.902 38.867a13.347 13.347 0 0 0 19.15-9.08l.223-1.044a14.2 14.2 0 0 0-2.51-11.466l-.36-.48a12.992 12.992 0 0 0-20.81 0l-.36.48a14.2 14.2 0 0 0-2.51 11.465l.223 1.046a13.35 13.35 0 0 0 6.953 9.08"})]})]}),jpe=({size:e=22,className:t=""})=>s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",style:{width:e,height:e},className:Ge("shrink-0 hover:scale-110 transition-transform",t),children:[s.jsx("path",{d:"M0 0h32v32H0z",fill:"none"}),s.jsxs("g",{fill:"none",children:[s.jsx("path",{fill:"#ac5810",d:"M19.343 4.83C11.708.802 4.757 3.672 2.253 7.595C1.432 8.877.852 11.21.874 13.06c.045 3.807 2.152 8.05 6.7 12.33c5.595 5.265 11.305 4.805 13.12 4.363c2.285-.558 3.817-1.033 3.582-3.163c-.03-.28-.27-.788-.632-1.01c-1.162-.705-3.59-1.072-4.732-2.77c-1.66-2.472.404-2.597 2.382-1.54c2.117 1.133 3.327 1.84 5.452 1.645c1.558-.142 3.823-1.082 4.13-3.71c.276-2.377-3.194-9.975-11.534-14.375m3.117 12.92c-.585.89-2.03.585-2.977-.255s-1.07-2.24-.456-2.79c.625-.557 1.8-.43 2.748.41c.945.842 1.143 1.935.685 2.635"}),s.jsx("path",{fill:"#f2a259",d:"M19.678 3.923C12.042-.105 5.074 3.01 2.57 6.933c-2.507 3.925-1.417 11.192 5.338 17.55c5.594 5.264 11.305 4.805 13.12 4.362c2.285-.557 3.897-1.645 2.892-3.032c-.693-.958-3.175-1.68-4.673-3.91c-1.66-2.473.406-2.598 2.383-1.54c2.117 1.132 3.328 1.84 5.453 1.645c1.557-.143 3.912-1.348 3.842-3.783c-.073-2.393-2.908-9.9-11.248-14.302m3.514 13.757c-.712.77-2.23.56-3.39-.465c-1.157-1.027-1.52-2.482-.807-3.25c.712-.77 2.23-.56 3.39.465s1.52 2.483.807 3.25"}),s.jsx("path",{fill:"#eee",d:"M11.905 21.165c.288-.735 2.333-1.54 4.213-.203c.527.375 1.187 1.33 1.12 2.53c-.22 3.92-6.653 1.055-5.333-2.327"}),s.jsx("path",{fill:"#2686c6",d:"M5.933 14.518c.657-1.05 2.255-1.17 3.652-.263c1.245.807 2.285 2.795.75 4.095c-.822.697-2.245.265-3.122-.408c-1.065-.812-1.988-2.294-1.28-3.424"}),s.jsx("path",{fill:"#ffee58",d:"M14.418 5.355c.202-.832 1.614-.975 2.614-.602c1.728.645 2.51 2.355 1.873 3.307c-.933 1.393-2.965.915-3.735.118c-1.307-1.35-.922-2.125-.752-2.823"}),s.jsx("path",{fill:"#7cb342",d:"M24.428 9.43c1.384.63 1.564 1.627 1.3 2.355c-.166.45-.503 1.067-1.193 1.123c-1.168.095-1.33-.87-2.163-1.135c-.7-.223-.985-1.18-.71-1.823c.256-.592 1-1.325 2.765-.52"}),s.jsx("path",{fill:"#b0b0b0",d:"M16.743 24.24c-.345.313-1.543.698-3.063-.252c-.515-.323-1.008-.79-1.285-1.49c-.217-.55-.17-1.08-.072-1.315c.28-.678.707-.803.707-.803c-.43-.03-1.242.54-1.377 1.288c-.043.235-.346 1.704 1.602 3.037c1.677 1.15 4.158 1.043 3.995-1.272a1.8 1.8 0 0 1-.508.807"}),s.jsx("path",{fill:"#01579b",d:"M11.065 16.43c-.047.893-1.093 1.363-1.675 1.365c-1.648.002-3.128-1.033-3.23-2.875c-.018-.33.145-.807.145-.807c-.218.092-.525.562-.59.827c-.385 1.59 1.217 3.443 2.905 3.818c.855.19 1.933-.103 2.325-.868c.28-.545.225-1.012.12-1.46"}),s.jsx("path",{fill:"#df7f14",d:"M16.83 8.18c-1.12-.128-1.74-.86-1.902-1.028c-.446-.465-.72-.917-.56-1.587c.05-.215.172-.49.322-.645c-.182.06-.477.452-.57.665c-.095.212-.44 1.01.3 1.992c.457.61 1.255 1.298 2.435 1.463c.837.117 1.438-.183 1.938-.67c.34-.333.49-1.083.287-1.47c.033.282-.485 1.482-2.25 1.28"}),s.jsx("path",{fill:"#558b2f",d:"M26.043 11.213a2.4 2.4 0 0 0-.425-.79c.127.245.38.98-.15 1.694c-.268.36-1.073.803-2.023.033c-.28-.228-.505-.453-1.01-.638c-1.282-.472-.723-1.777-.277-2.182c-.35.183-.668.51-.8 1.01c-.186.697.272 1.428.967 1.777c.79.398 1.045 1.165 2.128 1.165q.082 0 .175-.007c.73-.062 1.037-.345 1.26-.69c.272-.43.28-.918.154-1.373"}),s.jsx("path",{fill:"#f44336",d:"M6.455 6.448c.57-.563 1.562-1.158 3.015-.4c.875.455 1.893.99 1.432 2.84c-.284 1.147-1.955 1.755-3.35.477C7 8.86 4.9 7.982 6.455 6.447"}),s.jsx("path",{fill:"#c62828",d:"M11.235 8.64c.018-.437-.207-.97-.285-1.15c.013.262.24.925-.802 1.802a1.73 1.73 0 0 1-1.738.255c-.367-.145-.895-.752-1.272-.905c-1.403-.564-.798-2.067-.6-2.272a1.7 1.7 0 0 0-.688 1.095c-.13.678-.01 1.318.92 2.05c2.64 2.082 3.45.827 3.738.508c.362-.39.707-.9.727-1.383"}),s.jsx("path",{fill:"#fff",d:"M16.435 4.84c-.367-.172-1.417-.122-1.62.753c-.122.525.263 1.057.625.995c.412-.07.193-.713.44-.895c.377-.275 1.07-.61.555-.853M8.69 6.115c-.362-.24-1.52-.242-1.867.645c-.21.533.117 1.15.51 1.14c.447-.01.232-.537.604-.872c.47-.423 1.26-.578.753-.913m-.172 8.01c-.343-.217-1.358-.303-1.778.492c-.308.585.115 1.23.482 1.213c.418-.02.278-.685.545-.835c.408-.227 1.23-.565.75-.87m5.832 6.657c-.367-.172-1.418-.122-1.62.753c-.123.525.262 1.058.625.995c.412-.07.192-.713.44-.895c.375-.275 1.068-.61.555-.853m9.42-11.27c-.33-.234-1.372-.372-1.727.453c-.213.495.07 1.088.437 1.09c.418.002.315-.668.593-.803c.417-.202 1.16-.41.697-.74"})]})]}),Vo='data:image/svg+xml;utf8,';async function h2(e,t,n,r){const i=e?/@(mega\s*(ai)?|me)\b/i.test(e):!1,a=e?/\?/.test(e):!1,o=e?/^(what|how|why|where|when|who|is|can|will|does|should|could|explain|tell|is there|how to)\b/i.test(e.trim()):!1;if(!e||!i&&!a&&!o)return null;const c=e.replace(/@(mega\s*(ai)?|me)\b/gi,"").trim(),h=c.toLowerCase();try{let f=null;try{(await vn(it(pe,"mega_ai_knowledge"))).forEach(k=>{const I=k.data(),T=I.keywords||[],D=(I.question||"").toLowerCase(),F=D&&(h.includes(D)||D.length>5&&h.includes(D.slice(0,15))),L=T.length>0&&T.some(q=>q&&q.length>2&&h.includes(q.toLowerCase()));(F||L)&&(f=I.answer)})}catch(A){console.warn("Could not query mega_ai_knowledge collection:",A)}let m=f||"";if(!m)try{let A="";try{const T=Qt(it(pe,"posts"),pi("createdAt","desc"),Pi(12)),D=await vn(T);D.empty||(A=` [LIVE CAMPUS ARTICLES & SITEMAP KNOWLEDGE BASE]: Sitemap Root: https://campuseyemedia.netlify.app/sitemap.xml Categories: News, Sports, Politics, Entertainment, Tech, Campus Life, Opinion Latest Articles Knowledge: ${D.docs.map((L,q)=>{const Z=L.data();return`${q+1}. [Article Title]: "${Z.title||"Campus Update"}" | Category: ${Z.category||"General"} | Category URL: https://campuseyemedia.netlify.app/?category=${encodeURIComponent(Z.category||"General")} [Excerpt]: ${(Z.content||"").slice(0,180)}... [Link]: https://campuseyemedia.netlify.app/article/${L.id}`}).join(` `)}`)}catch(T){console.warn("Could not load live articles for Mega AI context:",T)}const I=await(await fetch("/api/mega-ai",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,context:`Question asked by ${t} in ${r.type}${A}`,articleTitle:r.articleTitle,articleContent:r.articleContent,postContent:r.postContent})})).json();I.reply&&(m=I.reply)}catch(A){console.error("Mega AI API fetch error:",A)}m||(m=`Hello @${t}! I am Mega AI, Campus Eye's smart neural assistant. I've processed your query: "${c||e}" and I am here to assist you! 🎓`);const y=c||e,w=`🧵 [Connected Thread | Question by @${t}]: "${y}" 🧠 [Mega AI Neural Response]: ${m}`;if(n&&n!=="guest")try{await ur(it(pe,"notifications"),{userId:n,type:"mega_ai_reply",title:"✨ Mega AI Replied to your Question!",message:`Mega AI: "${m.slice(0,110)}${m.length>110?"...":""}"`,fullAnswer:w,userQuery:y,targetType:r.type,postId:r.postId||null,articleId:r.articleId||null,commentId:r.commentId||null,used:!1,playSound:!0,isAiGenerated:!0,createdAt:Bn()})}catch(A){console.error("Could not send student inbox notification for Mega AI reply:",A)}if(!f)try{const A=(y||"").toLowerCase().split(" ").filter(k=>k.length>3);await ur(it(pe,"mega_ai_knowledge"),{question:y.trim(),answer:m.trim(),keywords:A,source:"ai_generated",askedBy:t||"Student",createdAt:Bn()})}catch(A){console.warn("Could not auto-save AI response into mega_ai_knowledge:",A)}try{await ur(it(pe,"notifications"),{type:"mega_ai_query",forAdmin:!0,isAdminNotification:!0,title:`🤖 Mega AI Response to @${t}`,message:`@${t} asked: "${y.slice(0,60)}${y.length>60?"...":""}" ➔ AI replied: "${m.slice(0,90)}${m.length>90?"...":""}"`,userQuery:e,generatedReply:m,fullAnswer:w,userUid:n||"guest",userName:t||"Student Peer",targetType:r.type,postId:r.postId||null,commentId:r.commentId||null,articleId:r.articleId||null,used:!1,playSound:!0,createdAt:Bn()}),(await vn(it(pe,"admins"))).forEach(async k=>{const I=k.id;if(I&&I!==n)try{await ur(it(pe,"notifications"),{userId:I,type:"mega_ai_admin_log",forAdmin:!0,isAdminNotification:!0,title:`🤖 Mega AI Answered @${t}`,message:`AI Response sent: "${m.slice(0,100)}${m.length>100?"...":""}"`,userQuery:y,generatedReply:m,fullAnswer:w,targetType:r.type,postId:r.postId||null,articleId:r.articleId||null,commentId:r.commentId||null,used:!1,playSound:!0,isAiGenerated:!0,createdAt:Bn()})}catch{}})}catch(A){console.error("Could not add admin notification for Mega AI query:",A)}return w}catch(f){return console.error("Error in triggerMegaAiAutoReply:",f),null}}const xw=({className:e,size:t="sm"})=>s.jsxs("span",{className:Ge("inline-flex items-center gap-1 font-extrabold bg-gradient-to-r from-amber-500/10 via-purple-500/10 to-red-500/10 border border-amber-500/30 text-amber-700 uppercase tracking-wider rounded-full shadow-2xs shrink-0 select-none",t==="sm"?"text-[8.5px] px-2 py-0.5":"text-[9.5px] px-2.5 py-1",e),children:[s.jsx(es,{size:t==="sm"?10:12,className:"text-amber-500 shrink-0"}),s.jsx("span",{children:"AI Generated"})]}),f2=(e,t)=>{if(!e)return null;const n=e.match(/^(?:💬\s*)?(?:\[Replying to @([^\]]+)\]|Replying to @([^\s:]+)):\s*"([^"]+)"\s*(?:\n+|⚡\s*|\s+)([\s\S]*)/i);if(n){const a=n[1]||n[2],o=n[3],c=n[4];return s.jsxs("div",{className:"space-y-2 my-1 text-left w-full",children:[s.jsxs("div",{className:"bg-slate-950/90 text-cyan-100 p-2.5 rounded-xl border border-cyan-500/40 shadow-sm backdrop-blur-xs",children:[s.jsxs("div",{className:"flex items-center justify-between text-[8.5px] font-mono font-bold text-cyan-400 uppercase tracking-wider mb-1 pb-1 border-b border-cyan-500/20",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-cyan-400 animate-pulse"}),s.jsxs("span",{children:["QUESTION THREAD — ASKED BY @",a.toUpperCase()]})]}),s.jsx("span",{className:"text-[7.5px] text-cyan-400/80 font-mono",children:"CONNECTED"})]}),s.jsxs("p",{className:"text-[10.5px] font-sans text-cyan-100/90 italic border-l-2 border-cyan-400 pl-2 py-0.5 leading-relaxed break-words",children:['"',o,'"']})]}),s.jsx("div",{className:"leading-relaxed font-sans text-inherit",children:f2(c)})]})}const r=/(https?:\/\/[^\s]+|#[a-zA-Z0-9_\-]+|@Mega\s+AI|@Mega|@megaai|@Me|@[a-zA-Z0-9_\-]+)/gi,i=e.split(r);return s.jsx(s.Fragment,{children:i.map((a,o)=>a?a.startsWith("http://")||a.startsWith("https://")?s.jsx("a",{href:a,onClick:c=>{c.preventDefault(),c.stopPropagation(),window.open(a,"_blank","noopener,noreferrer")},className:"text-blue-600 font-bold hover:underline select-text inline-flex items-center gap-0.5 break-all cursor-pointer",children:a},o):/^@(Mega\s+AI|Mega|megaai|Me)$/i.test(a)?s.jsxs("span",{className:"inline-flex items-center gap-1 text-cyan-300 font-extrabold bg-gradient-to-r from-slate-950 via-cyan-950 to-purple-950 border border-cyan-400/50 px-2 py-0.5 rounded-lg shadow-cyan-500/20 mx-0.5 text-[0.95em] select-none",children:[s.jsx(es,{size:11,className:"text-cyan-400 shrink-0"}),s.jsx("span",{children:a})]},o):a.startsWith("@")?s.jsx("span",{className:"text-blue-600 font-bold bg-blue-50/80 border border-blue-100 px-1 py-0.2 rounded hover:underline cursor-pointer inline-flex items-center transition-colors mx-0.5",children:a},o):a.startsWith("#")?s.jsx("span",{className:"text-red-650 font-bold bg-red-50/70 hover:bg-red-100/80 border border-red-150/60 px-1.5 py-0.5 rounded-md hover:underline cursor-pointer inline-flex items-center transition-colors mx-0.5",children:a},o):s.jsx(se.Fragment,{children:a},o):null)})},wT=j.createContext({});function NT(e){const t=j.useRef(null);return t.current===null&&(t.current=e()),t.current}const Tpe=typeof window<"u",uq=Tpe?j.useLayoutEffect:j.useEffect,uE=j.createContext(null);function ET(e,t){e.indexOf(t)===-1&&e.push(t)}function p2(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const Mu=(e,t,n)=>n>t?t:n{};const gf={},dq=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function hq(e){return typeof e=="object"&&e!==null}const fq=e=>/^0[^.\s]+$/u.test(e);function pq(e){let t;return()=>(t===void 0&&(t=e()),t)}const uc=e=>e,Ope=(e,t)=>n=>t(e(n)),My=(...e)=>e.reduce(Ope),Q1=(e,t,n)=>{const r=t-e;return r===0?1:(n-e)/r};class _T{constructor(){this.subscriptions=[]}add(t){return ET(this.subscriptions,t),()=>p2(this.subscriptions,t)}notify(t,n,r){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,r);else for(let a=0;ae*1e3,oc=e=>e/1e3;function mq(e,t){return t?e*(1e3/t):0}const gq=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Ppe=1e-7,Rpe=12;function Dpe(e,t,n,r,i){let a,o,c=0;do o=t+(n-t)/2,a=gq(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>Ppe&&++cDpe(a,0,1,e,n);return a=>a===0||a===1?a:gq(i(a),t,r)}const xq=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,yq=e=>t=>1-e(1-t),bq=Ly(.33,1.53,.69,.99),ST=yq(bq),vq=xq(ST),wq=e=>e>=1?1:(e*=2)<1?.5*ST(e):.5*(2-Math.pow(2,-10*(e-1))),kT=e=>1-Math.sin(Math.acos(e)),Nq=yq(kT),Eq=xq(kT),Mpe=Ly(.42,0,1,1),Lpe=Ly(0,0,.58,1),Aq=Ly(.42,0,.58,1),Upe=e=>Array.isArray(e)&&typeof e[0]!="number",_q=e=>Array.isArray(e)&&typeof e[0]=="number",Bpe={linear:uc,easeIn:Mpe,easeInOut:Aq,easeOut:Lpe,circIn:kT,circInOut:Eq,circOut:Nq,backIn:ST,backInOut:vq,backOut:bq,anticipate:wq},zpe=e=>typeof e=="string",c8=e=>{if(_q(e)){AT(e.length===4);const[t,n,r,i]=e;return Ly(t,n,r,i)}else if(zpe(e))return Bpe[e];return e},vv=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Vpe(e,t){let n=new Set,r=new Set,i=!1,a=!1;const o=new WeakSet;let c={delta:0,timestamp:0,isProcessing:!1};function h(m){o.has(m)&&(f.schedule(m),e()),m(c)}const f={schedule:(m,y=!1,w=!1)=>{const k=w&&i?n:r;return y&&o.add(m),k.add(m),m},cancel:m=>{r.delete(m),o.delete(m)},process:m=>{if(c=m,i){a=!0;return}i=!0;const y=n;n=r,r=y,n.forEach(h),n.clear(),i=!1,a&&(a=!1,f.process(m))}};return f}const Fpe=40;function Sq(e,t){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=vv.reduce((L,q)=>(L[q]=Vpe(a),L),{}),{setup:c,read:h,resolveKeyframes:f,preUpdate:m,update:y,preRender:w,render:A,postRender:k}=o,I=()=>{const L=gf.useManualTiming,q=L?i.timestamp:performance.now();n=!1,L||(i.delta=r?1e3/60:Math.max(Math.min(q-i.timestamp,Fpe),1)),i.timestamp=q,i.isProcessing=!0,c.process(i),h.process(i),f.process(i),m.process(i),y.process(i),w.process(i),A.process(i),k.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(I))},T=()=>{n=!0,r=!0,i.isProcessing||e(I)};return{schedule:vv.reduce((L,q)=>{const Z=o[q];return L[q]=(K,z=!1,B=!1)=>(n||T(),Z.schedule(K,z,B)),L},{}),cancel:L=>{for(let q=0;q(yw===void 0&&$o.set(to.isProcessing||gf.useManualTiming?to.timestamp:performance.now()),yw),set:e=>{yw=e,queueMicrotask($pe)}},kq=e=>t=>typeof t=="string"&&t.startsWith(e),Cq=kq("--"),Hpe=kq("var(--"),CT=e=>Hpe(e)?Gpe.test(e.split("/*")[0].trim()):!1,Gpe=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function u8(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const Og={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Z1={...Og,transform:e=>Mu(0,1,e)},wv={...Og,default:1},A1=e=>Math.round(e*1e5)/1e5,IT=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function qpe(e){return e==null}const Wpe=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,jT=(e,t)=>n=>!!(typeof n=="string"&&Wpe.test(n)&&n.startsWith(e)||t&&!qpe(n)&&Object.prototype.hasOwnProperty.call(n,t)),Iq=(e,t,n)=>r=>{if(typeof r!="string")return r;const[i,a,o,c]=r.match(IT);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:c!==void 0?parseFloat(c):1}},Kpe=e=>Mu(0,255,e),J_={...Og,transform:e=>Math.round(Kpe(e))},wp={test:jT("rgb","red"),parse:Iq("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+J_.transform(e)+", "+J_.transform(t)+", "+J_.transform(n)+", "+A1(Z1.transform(r))+")"};function Ype(e){let t="",n="",r="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}const fC={test:jT("#"),parse:Ype,transform:wp.transform},Uy=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Lh=Uy("deg"),ju=Uy("%"),Un=Uy("px"),Xpe=Uy("vh"),Qpe=Uy("vw"),d8={...ju,parse:e=>ju.parse(e)/100,transform:e=>ju.transform(e*100)},_0={test:jT("hsl","hue"),parse:Iq("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+ju.transform(A1(t))+", "+ju.transform(A1(n))+", "+A1(Z1.transform(r))+")"},ua={test:e=>wp.test(e)||fC.test(e)||_0.test(e),parse:e=>wp.test(e)?wp.parse(e):_0.test(e)?_0.parse(e):fC.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?wp.transform(e):_0.transform(e),getAnimatableNone:e=>{const t=ua.parse(e);return t.alpha=0,ua.transform(t)}},Zpe=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Jpe(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(IT))==null?void 0:t.length)||0)+(((n=e.match(Zpe))==null?void 0:n.length)||0)>0}const jq="number",Tq="color",eme="var",tme="var(",h8="${}",nme=/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 fg(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[];let a=0;const c=t.replace(nme,h=>(ua.test(h)?(r.color.push(a),i.push(Tq),n.push(ua.parse(h))):h.startsWith(tme)?(r.var.push(a),i.push(eme),n.push(h)):(r.number.push(a),i.push(jq),n.push(parseFloat(h))),++a,h8)).split(h8);return{values:n,split:c,indexes:r,types:i}}function rme(e){return fg(e).values}function Oq({split:e,types:t}){const n=e.length;return r=>{let i="";for(let a=0;atypeof e=="number"?0:ua.test(e)?ua.getAnimatableNone(e):e,ame=(e,t)=>typeof e=="number"?t!=null&&t.trim().endsWith("/")?e:0:sme(e);function ome(e){const t=fg(e);return Oq(t)(t.values.map((r,i)=>ame(r,t.split[i])))}const zc={test:Jpe,parse:rme,createTransformer:ime,getAnimatableNone:ome};function eS(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function lme({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{const c=n<.5?n*(1+t):n+t-n*t,h=2*n-c;i=eS(h,c,e+1/3),a=eS(h,c,e),o=eS(h,c,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function m2(e,t){return n=>n>0?t:e}const gs=(e,t,n)=>e+(t-e)*n,tS=(e,t,n)=>{const r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},cme=[fC,wp,_0],ume=e=>cme.find(t=>t.test(e));function f8(e){const t=ume(e);if(!t)return!1;let n=t.parse(e);return t===_0&&(n=lme(n)),n}const p8=(e,t)=>{const n=f8(e),r=f8(t);if(!n||!r)return m2(e,t);const i={...n};return a=>(i.red=tS(n.red,r.red,a),i.green=tS(n.green,r.green,a),i.blue=tS(n.blue,r.blue,a),i.alpha=gs(n.alpha,r.alpha,a),wp.transform(i))},pC=new Set(["none","hidden"]);function dme(e,t){return pC.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function hme(e,t){return n=>gs(e,t,n)}function TT(e){return typeof e=="number"?hme:typeof e=="string"?CT(e)?m2:ua.test(e)?p8:mme:Array.isArray(e)?Pq:typeof e=="object"?ua.test(e)?p8:fme:m2}function Pq(e,t){const n=[...e],r=n.length,i=e.map((a,o)=>TT(a)(a,t[o]));return a=>{for(let o=0;o{for(const a in r)n[a]=r[a](i);return n}}function pme(e,t){const n=[],r={color:0,var:0,number:0};for(let i=0;i{const n=zc.createTransformer(t),r=fg(e),i=fg(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?pC.has(e)&&!i.values.length||pC.has(t)&&!r.values.length?dme(e,t):My(Pq(pme(r,i),i.values),n):m2(e,t)};function Rq(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?gs(e,t,n):TT(e)(e,t)}const gme=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ts.update(t,n),stop:()=>xf(t),now:()=>to.isProcessing?to.timestamp:$o.now()}},Dq=(e,t,n=10)=>{let r="";const i=Math.max(Math.round(t/n),2);for(let a=0;a=g2?1/0:t}function xme(e,t=100,n){const r=n({...e,keyframes:[0,t]}),i=Math.min(OT(r),g2);return{type:"keyframes",ease:a=>r.next(i*a).value/t,duration:oc(i)}}const $s={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 mC(e,t){return e*Math.sqrt(1-t*t)}const yme=12;function bme(e,t,n){let r=n;for(let i=1;i{const m=f*o,y=m*e,w=m-n,A=mC(f,o),k=Math.exp(-y);return nS-w/A*k},a=f=>{const y=f*o*e,w=y*n+n,A=Math.pow(o,2)*Math.pow(f,2)*e,k=Math.exp(-y),I=mC(Math.pow(f,2),o);return(-i(f)+nS>0?-1:1)*((w-A)*k)/I}):(i=f=>{const m=Math.exp(-f*e),y=(f-n)*e+1;return-nS+m*y},a=f=>{const m=Math.exp(-f*e),y=(n-f)*(e*e);return m*y});const c=5/e,h=bme(i,a,c);if(e=Vl(e),isNaN(h))return{stiffness:$s.stiffness,damping:$s.damping,duration:e};{const f=Math.pow(h,2)*r;return{stiffness:f,damping:o*2*Math.sqrt(r*f),duration:e}}}const wme=["duration","bounce"],Nme=["stiffness","damping","mass"];function m8(e,t){return t.some(n=>e[n]!==void 0)}function Eme(e){let t={velocity:$s.velocity,stiffness:$s.stiffness,damping:$s.damping,mass:$s.mass,isResolvedFromDuration:!1,...e};if(!m8(e,Nme)&&m8(e,wme))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Mu(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:$s.mass,stiffness:i,damping:a}}else{const n=vme({...e,velocity:0});t={...t,...n,mass:$s.mass},t.isResolvedFromDuration=!0}return t}function x2(e=$s.visualDuration,t=$s.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:r,restDelta:i}=n;const a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],c={done:!1,value:a},{stiffness:h,damping:f,mass:m,duration:y,velocity:w,isResolvedFromDuration:A}=Eme({...n,velocity:-oc(n.velocity||0)}),k=w||0,I=f/(2*Math.sqrt(h*m)),T=o-a,D=oc(Math.sqrt(h/m)),F=Math.abs(T)<5;r||(r=F?$s.restSpeed.granular:$s.restSpeed.default),i||(i=F?$s.restDelta.granular:$s.restDelta.default);let L,q,Z,K,z,B;if(I<1)Z=mC(D,I),K=(k+I*D*T)/Z,L=$=>{const Q=Math.exp(-I*D*$);return o-Q*(K*Math.sin(Z*$)+T*Math.cos(Z*$))},z=I*D*K+T*Z,B=I*D*T-K*Z,q=$=>Math.exp(-I*D*$)*(z*Math.sin(Z*$)+B*Math.cos(Z*$));else if(I===1){L=Q=>o-Math.exp(-D*Q)*(T+(k+D*T)*Q);const $=k+D*T;q=Q=>Math.exp(-D*Q)*(D*$*Q-k)}else{const $=D*Math.sqrt(I*I-1);L=he=>{const te=Math.exp(-I*D*he),le=Math.min($*he,300);return o-te*((k+I*D*T)*Math.sinh(le)+$*T*Math.cosh(le))/$};const Q=(k+I*D*T)/$,Y=I*D*Q-T*$,G=I*D*T-Q*$;q=he=>{const te=Math.exp(-I*D*he),le=Math.min($*he,300);return te*(Y*Math.sinh(le)+G*Math.cosh(le))}}const V={calculatedDuration:A&&y||null,velocity:$=>Vl(q($)),next:$=>{if(!A&&I<1){const Y=Math.exp(-I*D*$),G=Math.sin(Z*$),he=Math.cos(Z*$),te=o-Y*(K*G+T*he),le=Vl(Y*(z*G+B*he));return c.done=Math.abs(le)<=r&&Math.abs(o-te)<=i,c.value=c.done?o:te,c}const Q=L($);if(A)c.done=$>=y;else{const Y=Vl(q($));c.done=Math.abs(Y)<=r&&Math.abs(o-Q)<=i}return c.value=c.done?o:Q,c},toString:()=>{const $=Math.min(OT(V),g2),Q=Dq(Y=>V.next($*Y).value,$,30);return $+"ms "+Q},toTransition:()=>{}};return V}x2.applyToOptions=e=>{const t=xme(e,100,x2);return e.ease=t.ease,e.duration=Vl(t.duration),e.type="keyframes",e};const Ame=5;function Mq(e,t,n){const r=Math.max(t-Ame,0);return mq(n-e(r),t-r)}function gC({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:c,max:h,restDelta:f=.5,restSpeed:m}){const y=e[0],w={done:!1,value:y},A=B=>c!==void 0&&Bh,k=B=>c===void 0?h:h===void 0||Math.abs(c-B)-I*Math.exp(-B/r),L=B=>D+F(B),q=B=>{const V=F(B),$=L(B);w.done=Math.abs(V)<=f,w.value=w.done?D:$};let Z,K;const z=B=>{A(w.value)&&(Z=B,K=x2({keyframes:[w.value,k(w.value)],velocity:Mq(L,B,w.value),damping:i,stiffness:a,restDelta:f,restSpeed:m}))};return z(0),{calculatedDuration:null,next:B=>{let V=!1;return!K&&Z===void 0&&(V=!0,q(B),z(B)),Z!==void 0&&B>=Z?K.next(B-Z):(!V&&q(B),w)}}}function _me(e,t,n){const r=[],i=n||gf.mix||Rq,a=e.length-1;for(let o=0;ot[0];if(a===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());const c=_me(t,r,i),h=c.length,f=m=>{if(o&&m1)for(;yf(Mu(e[0],e[a-1],m)):f}function kme(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const i=Q1(0,t,r);e.push(gs(n,1,i))}}function Cme(e){const t=[0];return kme(t,e.length-1),t}function Ime(e,t){return e.map(n=>n*t)}function jme(e,t){return e.map(()=>t||Aq).splice(0,e.length-1)}function _1({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const i=Upe(r)?r.map(c8):c8(r),a={done:!1,value:t[0]},o=Ime(n&&n.length===t.length?n:Cme(t),e),c=Sme(o,t,{ease:Array.isArray(i)?i:jme(t,i)});return{calculatedDuration:e,next:h=>(a.value=c(h),a.done=h>=e,a)}}const Tme=e=>e!==null;function dE(e,{repeat:t,repeatType:n="loop"},r,i=1){const a=e.filter(Tme),c=i<0||t&&n!=="loop"&&t%2===1?0:a.length-1;return!c||r===void 0?a[c]:r}const Ome={decay:gC,inertia:gC,tween:_1,keyframes:_1,spring:x2};function Lq(e){typeof e.type=="string"&&(e.type=Ome[e.type])}class PT{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const Pme=e=>e/100;class y2 extends PT{constructor(t){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=()=>{var r,i;const{motionValue:n}=this.options;n&&n.updatedAt!==$o.now()&&this.tick($o.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(i=(r=this.options).onStop)==null||i.call(r))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;Lq(t);const{type:n=_1,repeat:r=0,repeatDelay:i=0,repeatType:a,velocity:o=0}=t;let{keyframes:c}=t;const h=n||_1;h!==_1&&typeof c[0]!="number"&&(this.mixKeyframes=My(Pme,Rq(c[0],c[1])),c=[0,100]);const f=h({...t,keyframes:c});a==="mirror"&&(this.mirroredGenerator=h({...t,keyframes:[...c].reverse(),velocity:-o})),f.calculatedDuration===null&&(f.calculatedDuration=OT(f));const{calculatedDuration:m}=f;this.calculatedDuration=m,this.resolvedDuration=m+i,this.totalDuration=this.resolvedDuration*(r+1)-i,this.generator=f}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:r,totalDuration:i,mixKeyframes:a,mirroredGenerator:o,resolvedDuration:c,calculatedDuration:h}=this;if(this.startTime===null)return r.next(0);const{delay:f=0,keyframes:m,repeat:y,repeatType:w,repeatDelay:A,type:k,onUpdate:I,finalKeyframe:T}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-i/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const D=this.currentTime-f*(this.playbackSpeed>=0?1:-1),F=this.playbackSpeed>=0?D<0:D>i;this.currentTime=Math.max(D,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let L=this.currentTime,q=r;if(y){const B=Math.min(this.currentTime,i)/c;let V=Math.floor(B),$=B%1;!$&&B>=1&&($=1),$===1&&V--,V=Math.min(V,y+1),!!(V%2)&&(w==="reverse"?($=1-$,A&&($-=A/c)):w==="mirror"&&(q=o)),L=Mu(0,1,$)*c}let Z;F?(this.delayState.value=m[0],Z=this.delayState):Z=q.next(L),a&&!F&&(Z.value=a(Z.value));let{done:K}=Z;!F&&h!==null&&(K=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const z=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&K);return z&&k!==gC&&(Z.value=dE(m,this.options,T,this.speed)),I&&I(Z.value),z&&this.finish(),Z}then(t,n){return this.finished.then(t,n)}get duration(){return oc(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+oc(t)}get time(){return oc(this.currentTime)}set time(t){t=Vl(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);const n=this.generator.next(t).value;return Mq(r=>this.generator.next(r).value,t,n)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;n&&this.driver&&this.updateTime($o.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=oc(this.currentTime))}play(){var i,a;if(this.isStopped)return;const{driver:t=gme,startTime:n}=this.options;this.driver||(this.driver=t(o=>this.tick(o))),(a=(i=this.options).onPlay)==null||a.call(i);const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),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($o.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(t=this.options).onComplete)==null||n.call(t)}cancel(){var t,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(t=this.options).onCancel)==null||n.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),t.observe(this)}}function Rme(e){for(let t=1;te*180/Math.PI,xC=e=>{const t=Np(Math.atan2(e[1],e[0]));return yC(t)},Dme={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:xC,rotateZ:xC,skewX:e=>Np(Math.atan(e[1])),skewY:e=>Np(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},yC=e=>(e=e%360,e<0&&(e+=360),e),g8=xC,x8=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),y8=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Mme={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:x8,scaleY:y8,scale:e=>(x8(e)+y8(e))/2,rotateX:e=>yC(Np(Math.atan2(e[6],e[5]))),rotateY:e=>yC(Np(Math.atan2(-e[2],e[0]))),rotateZ:g8,rotate:g8,skewX:e=>Np(Math.atan(e[4])),skewY:e=>Np(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function bC(e){return e.includes("scale")?1:0}function vC(e,t){if(!e||e==="none")return bC(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=Mme,i=n;else{const c=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Dme,i=c}if(!i)return bC(t);const a=r[t],o=i[1].split(",").map(Ume);return typeof a=="function"?a(o):o[a]}const Lme=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return vC(n,t)};function Ume(e){return parseFloat(e.trim())}const Pg=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Rg=new Set(Pg),b8=e=>e===Og||e===Un,Bme=new Set(["x","y","z"]),zme=Pg.filter(e=>!Bme.has(e));function Vme(e){const t=[];return zme.forEach(n=>{const r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}const Jh={width:({x:e},{paddingLeft:t="0",paddingRight:n="0",boxSizing:r})=>{const i=e.max-e.min;return r==="border-box"?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t="0",paddingBottom:n="0",boxSizing:r})=>{const i=e.max-e.min;return r==="border-box"?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>vC(t,"x"),y:(e,{transform:t})=>vC(t,"y")};Jh.translateX=Jh.x;Jh.translateY=Jh.y;const Dp=new Set;let wC=!1,NC=!1,EC=!1;function Uq(){if(NC){const e=Array.from(Dp).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),n=new Map;t.forEach(r=>{const i=Vme(r);i.length&&(n.set(r,i),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();const i=n.get(r);i&&i.forEach(([a,o])=>{var c;(c=r.getValue(a))==null||c.set(o)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}NC=!1,wC=!1,Dp.forEach(e=>e.complete(EC)),Dp.clear()}function Bq(){Dp.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(NC=!0)})}function Fme(){EC=!0,Bq(),Uq(),EC=!1}class RT{constructor(t,n,r,i,a,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=r,this.motionValue=i,this.element=a,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(Dp.add(this),wC||(wC=!0,ts.read(Bq),ts.resolveKeyframes(Uq))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:r,motionValue:i}=this;if(t[0]===null){const a=i==null?void 0:i.get(),o=t[t.length-1];if(a!==void 0)t[0]=a;else if(r&&n){const c=r.readValue(n,o);c!=null&&(t[0]=c)}t[0]===void 0&&(t[0]=o),i&&a===void 0&&i.set(t[0])}Rme(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Dp.delete(this)}cancel(){this.state==="scheduled"&&(Dp.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const $me=e=>e.startsWith("--");function zq(e,t,n){$me(t)?e.style.setProperty(t,n):e.style[t]=n}const Hme={};function Vq(e,t){const n=pq(e);return()=>Hme[t]??n()}const Gme=Vq(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),Fq=Vq(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),o1=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,v8={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:o1([0,.65,.55,1]),circOut:o1([.55,0,1,.45]),backIn:o1([.31,.01,.66,-.59]),backOut:o1([.33,1.53,.69,.99])};function $q(e,t){if(e)return typeof e=="function"?Fq()?Dq(e,t):"ease-out":_q(e)?o1(e):Array.isArray(e)?e.map(n=>$q(n,t)||v8.easeOut):v8[e]}function qme(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o="loop",ease:c="easeOut",times:h}={},f=void 0){const m={[t]:n};h&&(m.offset=h);const y=$q(c,i);Array.isArray(y)&&(m.easing=y);const w={delay:r,duration:i,easing:Array.isArray(y)?"linear":y,fill:"both",iterations:a+1,direction:o==="reverse"?"alternate":"normal"};return f&&(w.pseudoElement=f),e.animate(m,w)}function Hq(e){return typeof e=="function"&&"applyToOptions"in e}function Wme({type:e,...t}){return Hq(e)&&Fq()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class Gq extends PT{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:r,keyframes:i,pseudoElement:a,allowFlatten:o=!1,finalKeyframe:c,onComplete:h}=t;this.isPseudoElement=!!a,this.allowFlatten=o,this.options=t,AT(typeof t.type!="string");const f=Wme(t);this.animation=qme(n,r,i,f,a),f.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!a){const m=dE(i,this.options,c,this.speed);this.updateMotionValue&&this.updateMotionValue(m),zq(n,r,m),this.animation.cancel()}h==null||h(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,n;(n=(t=this.animation).finish)==null||n.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var n,r,i;const t=(n=this.options)==null?void 0:n.element;!this.isPseudoElement&&(t!=null&&t.isConnected)&&((i=(r=this.animation).commitStyles)==null||i.call(r))}get duration(){var n,r;const t=((r=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:r.call(n).duration)||0;return oc(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+oc(t)}get time(){return oc(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Vl(t),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:n,rangeEnd:r,observe:i}){var a;return this.allowFlatten&&((a=this.animation.effect)==null||a.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&Gme()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),r&&(this.animation.rangeEnd=r),uc):i(this)}}const qq={anticipate:wq,backInOut:vq,circInOut:Eq};function Kme(e){return e in qq}function Yme(e){typeof e.ease=="string"&&Kme(e.ease)&&(e.ease=qq[e.ease])}const rS=10;class Xme extends Gq{constructor(t){Yme(t),Lq(t),super(t),t.startTime!==void 0&&t.autoplay!==!1&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:r,onComplete:i,element:a,...o}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const c=new y2({...o,autoplay:!1}),h=Math.max(rS,$o.now()-this.startTime),f=Mu(0,rS,h-rS),m=c.sample(h).value,{name:y}=this.options;a&&y&&zq(a,y,m),n.setWithVelocity(c.sample(Math.max(0,h-f)).value,m,f),c.stop()}}const w8=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(zc.test(e)||e==="0")&&!e.startsWith("url("));function Qme(e){const t=e[0];if(e.length===1)return!0;for(let n=0;nObject.hasOwnProperty.call(Element.prototype,"animate"));function r0e(e){var y;const{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:c}=e;if(!(((y=t==null?void 0:t.owner)==null?void 0:y.current)instanceof HTMLElement))return!1;const{onUpdate:f,transformTemplate:m}=t.owner.getProps();return n0e()&&n&&(Wq.has(n)||t0e.has(n)&&e0e(c))&&(n!=="transform"||!m)&&!f&&!r&&i!=="mirror"&&a!==0&&o!=="inertia"}const i0e=40;class s0e extends PT{constructor({autoplay:t=!0,delay:n=0,type:r="keyframes",repeat:i=0,repeatDelay:a=0,repeatType:o="loop",keyframes:c,name:h,motionValue:f,element:m,...y}){var k;super(),this.stop=()=>{var I,T;this._animation&&(this._animation.stop(),(I=this.stopTimeline)==null||I.call(this)),(T=this.keyframeResolver)==null||T.cancel()},this.createdAt=$o.now();const w={autoplay:t,delay:n,type:r,repeat:i,repeatDelay:a,repeatType:o,name:h,motionValue:f,element:m,...y},A=(m==null?void 0:m.KeyframeResolver)||RT;this.keyframeResolver=new A(c,(I,T,D)=>this.onKeyframesResolved(I,T,w,!D),h,f,m),(k=this.keyframeResolver)==null||k.scheduleResolve()}onKeyframesResolved(t,n,r,i){var D,F;this.keyframeResolver=void 0;const{name:a,type:o,velocity:c,delay:h,isHandoff:f,onUpdate:m}=r;this.resolvedAt=$o.now();let y=!0;Zme(t,a,o,c)||(y=!1,(gf.instantAnimations||!h)&&(m==null||m(dE(t,r,n))),t[0]=t[t.length-1],AC(r),r.repeat=0);const A={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>i0e?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:t},k=y&&!f&&r0e(A),I=(F=(D=A.motionValue)==null?void 0:D.owner)==null?void 0:F.current;let T;if(k)try{T=new Xme({...A,element:I})}catch{T=new y2(A)}else T=new y2(A);T.finished.then(()=>{this.notifyFinished()}).catch(uc),this.pendingTimeline&&(this.stopTimeline=T.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=T}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),Fme()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}function Kq(e,t,n,r=0,i=1){const a=Array.from(e).sort((f,m)=>f.sortNodePosition(m)).indexOf(t),o=e.size,c=(o-1)*r;return typeof n=="function"?n(a,o):i===1?a*r:c-a*r}const a0e=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function o0e(e){const t=a0e.exec(e);if(!t)return[,];const[,n,r,i]=t;return[`--${n??r}`,i]}function Yq(e,t,n=1){const[r,i]=o0e(e);if(!r)return;const a=window.getComputedStyle(t).getPropertyValue(r);if(a){const o=a.trim();return dq(o)?parseFloat(o):o}return CT(i)?Yq(i,t,n+1):i}const l0e={type:"spring",stiffness:500,damping:25,restSpeed:10},c0e=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),u0e={type:"keyframes",duration:.8},d0e={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},h0e=(e,{keyframes:t})=>t.length>2?u0e:Rg.has(e)?e.startsWith("scale")?c0e(t[1]):l0e:d0e;function Xq(e,t){if(e!=null&&e.inherit&&t){const{inherit:n,...r}=e;return{...t,...r}}return e}function DT(e,t){const n=(e==null?void 0:e[t])??(e==null?void 0:e.default)??e;return n!==e?Xq(n,e):n}const f0e=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function p0e(e){for(const t in e)if(!f0e.has(t))return!0;return!1}const MT=(e,t,n,r={},i,a)=>o=>{const c=DT(r,e)||{},h=c.delay||r.delay||0;let{elapsed:f=0}=r;f=f-Vl(h);const m={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...c,delay:-f,onUpdate:w=>{t.set(w),c.onUpdate&&c.onUpdate(w)},onComplete:()=>{o(),c.onComplete&&c.onComplete()},name:e,motionValue:t,element:a?void 0:i};p0e(c)||Object.assign(m,h0e(e,m)),m.duration&&(m.duration=Vl(m.duration)),m.repeatDelay&&(m.repeatDelay=Vl(m.repeatDelay)),m.from!==void 0&&(m.keyframes[0]=m.from);let y=!1;if((m.type===!1||m.duration===0&&!m.repeatDelay)&&(AC(m),m.delay===0&&(y=!0)),(gf.instantAnimations||gf.skipAnimations||i!=null&&i.shouldSkipAnimations)&&(y=!0,AC(m),m.delay=0),m.allowFlatten=!c.type&&!c.ease,y&&!a&&t.get()!==void 0){const w=dE(m.keyframes,c);if(w!==void 0){ts.update(()=>{m.onUpdate(w),m.onComplete()});return}}return c.isSync?new y2(m):new s0e(m)};function N8(e){const t=[{},{}];return e==null||e.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function LT(e,t,n,r){if(typeof t=="function"){const[i,a]=N8(r);t=t(n!==void 0?n:e.custom,i,a)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,a]=N8(r);t=t(n!==void 0?n:e.custom,i,a)}return t}function Mp(e,t,n){const r=e.getProps();return LT(r,t,n!==void 0?n:r.custom,e)}const Qq=new Set(["width","height","top","left","right","bottom",...Pg]),E8=30,m0e=e=>!isNaN(parseFloat(e));class g0e{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{var a;const i=$o.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&((a=this.events.change)==null||a.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=$o.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=m0e(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new _T);const r=this.events[t].add(n);return t==="change"?()=>{r(),ts.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=$o.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>E8)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,E8);return mq(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(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(){var t,n;(t=this.dependents)==null||t.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function pg(e,t){return new g0e(e,t)}const _C=e=>Array.isArray(e);function x0e(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,pg(n))}function y0e(e){return _C(e)?e[e.length-1]||0:e}function b0e(e,t){const n=Mp(e,t);let{transitionEnd:r={},transition:i={},...a}=n||{};a={...a,...r};for(const o in a){const c=y0e(a[o]);x0e(e,o,c)}}const so=e=>!!(e&&e.getVelocity);function v0e(e){return!!(so(e)&&e.add)}function SC(e,t){const n=e.getValue("willChange");if(v0e(n))return n.add(t);if(!n&&gf.WillChange){const r=new gf.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function UT(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const w0e="framerAppearId",Zq="data-"+UT(w0e);function Jq(e){return e.props[Zq]}function N0e({protectedKeys:e,needsAnimating:t},n){const r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function eW(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...c}=t;const h=e.getDefaultTransition();a=a?Xq(a,h):h;const f=a==null?void 0:a.reduceMotion;r&&(a=r);const m=[],y=i&&e.animationState&&e.animationState.getState()[i];for(const w in c){const A=e.getValue(w,e.latestValues[w]??null),k=c[w];if(k===void 0||y&&N0e(y,w))continue;const I={delay:n,...DT(a||{},w)},T=A.get();if(T!==void 0&&!A.isAnimating()&&!Array.isArray(k)&&k===T&&!I.velocity){ts.update(()=>A.set(k));continue}let D=!1;if(window.MotionHandoffAnimation){const q=Jq(e);if(q){const Z=window.MotionHandoffAnimation(q,w,ts);Z!==null&&(I.startTime=Z,D=!0)}}SC(e,w);const F=f??e.shouldReduceMotion;A.start(MT(w,A,k,F&&Qq.has(w)?{type:!1}:I,e,D));const L=A.animation;L&&m.push(L)}if(o){const w=()=>ts.update(()=>{o&&b0e(e,o)});m.length?Promise.all(m).then(w):w()}return m}function kC(e,t,n={}){var h;const r=Mp(e,t,n.type==="exit"?(h=e.presenceContext)==null?void 0:h.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);const a=r?()=>Promise.all(eW(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(f=0)=>{const{delayChildren:m=0,staggerChildren:y,staggerDirection:w}=i;return E0e(e,t,f,m,y,w,n)}:()=>Promise.resolve(),{when:c}=i;if(c){const[f,m]=c==="beforeChildren"?[a,o]:[o,a];return f().then(()=>m())}else return Promise.all([a(),o(n.delay)])}function E0e(e,t,n=0,r=0,i=0,a=1,o){const c=[];for(const h of e.variantChildren)h.notify("AnimationStart",t),c.push(kC(h,t,{...o,delay:n+(typeof r=="function"?0:r)+Kq(e.variantChildren,h,r,i,a)}).then(()=>h.notify("AnimationComplete",t)));return Promise.all(c)}function A0e(e,t,n={}){e.notify("AnimationStart",t);let r;if(Array.isArray(t)){const i=t.map(a=>kC(e,a,n));r=Promise.all(i)}else if(typeof t=="string")r=kC(e,t,n);else{const i=typeof t=="function"?Mp(e,t,n.custom):t;r=Promise.all(eW(e,i,n))}return r.then(()=>{e.notify("AnimationComplete",t)})}const _0e={test:e=>e==="auto",parse:e=>e},tW=e=>t=>t.test(e),nW=[Og,Un,ju,Lh,Qpe,Xpe,_0e],A8=e=>nW.find(tW(e));function S0e(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||fq(e):!0}const k0e=new Set(["brightness","contrast","saturate","opacity"]);function C0e(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(IT)||[];if(!r)return e;const i=n.replace(r,"");let a=k0e.has(t)?1:0;return r!==n&&(a*=100),t+"("+a+i+")"}const I0e=/\b([a-z-]*)\(.*?\)/gu,CC={...zc,getAnimatableNone:e=>{const t=e.match(I0e);return t?t.map(C0e).join(" "):e}},IC={...zc,getAnimatableNone:e=>{const t=zc.parse(e);return zc.createTransformer(e)(t.map(r=>typeof r=="number"?0:typeof r=="object"?{...r,alpha:1}:r))}},_8={...Og,transform:Math.round},j0e={rotate:Lh,rotateX:Lh,rotateY:Lh,rotateZ:Lh,scale:wv,scaleX:wv,scaleY:wv,scaleZ:wv,skew:Lh,skewX:Lh,skewY:Lh,distance:Un,translateX:Un,translateY:Un,translateZ:Un,x:Un,y:Un,z:Un,perspective:Un,transformPerspective:Un,opacity:Z1,originX:d8,originY:d8,originZ:Un},BT={borderWidth:Un,borderTopWidth:Un,borderRightWidth:Un,borderBottomWidth:Un,borderLeftWidth:Un,borderRadius:Un,borderTopLeftRadius:Un,borderTopRightRadius:Un,borderBottomRightRadius:Un,borderBottomLeftRadius:Un,width:Un,maxWidth:Un,height:Un,maxHeight:Un,top:Un,right:Un,bottom:Un,left:Un,inset:Un,insetBlock:Un,insetBlockStart:Un,insetBlockEnd:Un,insetInline:Un,insetInlineStart:Un,insetInlineEnd:Un,padding:Un,paddingTop:Un,paddingRight:Un,paddingBottom:Un,paddingLeft:Un,paddingBlock:Un,paddingBlockStart:Un,paddingBlockEnd:Un,paddingInline:Un,paddingInlineStart:Un,paddingInlineEnd:Un,margin:Un,marginTop:Un,marginRight:Un,marginBottom:Un,marginLeft:Un,marginBlock:Un,marginBlockStart:Un,marginBlockEnd:Un,marginInline:Un,marginInlineStart:Un,marginInlineEnd:Un,fontSize:Un,backgroundPositionX:Un,backgroundPositionY:Un,...j0e,zIndex:_8,fillOpacity:Z1,strokeOpacity:Z1,numOctaves:_8},T0e={...BT,color:ua,backgroundColor:ua,outlineColor:ua,fill:ua,stroke:ua,borderColor:ua,borderTopColor:ua,borderRightColor:ua,borderBottomColor:ua,borderLeftColor:ua,filter:CC,WebkitFilter:CC,mask:IC,WebkitMask:IC},rW=e=>T0e[e],O0e=new Set([CC,IC]);function iW(e,t){let n=rW(e);return O0e.has(n)||(n=zc),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const P0e=new Set(["auto","none","0"]);function R0e(e,t,n){let r=0,i;for(;r{t.getValue(h).set(f)}),this.resolveNoneKeyframes()}}function sW(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let r=document;const i=(n==null?void 0:n[e])??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(r=>r!=null)}const aW=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function bw(e){return hq(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:zT}=Sq(queueMicrotask,!1),jc={x:!1,y:!1};function oW(){return jc.x||jc.y}function M0e(e){return e==="x"||e==="y"?jc[e]?null:(jc[e]=!0,()=>{jc[e]=!1}):jc.x||jc.y?null:(jc.x=jc.y=!0,()=>{jc.x=jc.y=!1})}function lW(e,t){const n=sW(e),r=new AbortController,i={passive:!0,...t,signal:r.signal};return[n,i,()=>r.abort()]}function L0e(e){return!(e.pointerType==="touch"||oW())}function U0e(e,t,n={}){const[r,i,a]=lW(e,n);return r.forEach(o=>{let c=!1,h=!1,f;const m=()=>{o.removeEventListener("pointerleave",k)},y=T=>{f&&(f(T),f=void 0),m()},w=T=>{c=!1,window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w),h&&(h=!1,y(T))},A=()=>{c=!0,window.addEventListener("pointerup",w,i),window.addEventListener("pointercancel",w,i)},k=T=>{if(T.pointerType!=="touch"){if(c){h=!0;return}y(T)}},I=T=>{if(!L0e(T))return;h=!1;const D=t(o,T);typeof D=="function"&&(f=D,o.addEventListener("pointerleave",k,i))};o.addEventListener("pointerenter",I,i),o.addEventListener("pointerdown",A,i)}),a}const cW=(e,t)=>t?e===t?!0:cW(e,t.parentElement):!1,VT=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,B0e=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function z0e(e){return B0e.has(e.tagName)||e.isContentEditable===!0}const V0e=new Set(["INPUT","SELECT","TEXTAREA"]);function F0e(e){return V0e.has(e.tagName)||e.isContentEditable===!0}const vw=new WeakSet;function S8(e){return t=>{t.key==="Enter"&&e(t)}}function iS(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const $0e=(e,t)=>{const n=e.currentTarget;if(!n)return;const r=S8(()=>{if(vw.has(n))return;iS(n,"down");const i=S8(()=>{iS(n,"up")}),a=()=>iS(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",a,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function k8(e){return VT(e)&&!oW()}const C8=new WeakSet;function H0e(e,t,n={}){const[r,i,a]=lW(e,n),o=c=>{const h=c.currentTarget;if(!k8(c)||C8.has(c))return;vw.add(h),n.stopPropagation&&C8.add(c);const f=t(h,c),m=(A,k)=>{window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",w),vw.has(h)&&vw.delete(h),k8(A)&&typeof f=="function"&&f(A,{success:k})},y=A=>{m(A,h===window||h===document||n.useGlobalTarget||cW(h,A.target))},w=A=>{m(A,!1)};window.addEventListener("pointerup",y,i),window.addEventListener("pointercancel",w,i)};return r.forEach(c=>{(n.useGlobalTarget?window:c).addEventListener("pointerdown",o,i),bw(c)&&(c.addEventListener("focus",f=>$0e(f,i)),!z0e(c)&&!c.hasAttribute("tabindex")&&(c.tabIndex=0))}),a}function FT(e){return hq(e)&&"ownerSVGElement"in e}const ww=new WeakMap;let Uh;const uW=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+"Size"]:FT(r)&&"getBBox"in r?r.getBBox()[t]:r[n],G0e=uW("inline","width","offsetWidth"),q0e=uW("block","height","offsetHeight");function W0e({target:e,borderBoxSize:t}){var n;(n=ww.get(e))==null||n.forEach(r=>{r(e,{get width(){return G0e(e,t)},get height(){return q0e(e,t)}})})}function K0e(e){e.forEach(W0e)}function Y0e(){typeof ResizeObserver>"u"||(Uh=new ResizeObserver(K0e))}function X0e(e,t){Uh||Y0e();const n=sW(e);return n.forEach(r=>{let i=ww.get(r);i||(i=new Set,ww.set(r,i)),i.add(t),Uh==null||Uh.observe(r)}),()=>{n.forEach(r=>{const i=ww.get(r);i==null||i.delete(t),i!=null&&i.size||Uh==null||Uh.unobserve(r)})}}const Nw=new Set;let S0;function Q0e(){S0=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Nw.forEach(t=>t(e))},window.addEventListener("resize",S0)}function Z0e(e){return Nw.add(e),S0||Q0e(),()=>{Nw.delete(e),!Nw.size&&typeof S0=="function"&&(window.removeEventListener("resize",S0),S0=void 0)}}function I8(e,t){return typeof e=="function"?Z0e(e):X0e(e,t)}function J0e(e){return FT(e)&&e.tagName==="svg"}const ege=[...nW,ua,zc],tge=e=>ege.find(tW(e)),j8=()=>({translate:0,scale:1,origin:0,originPoint:0}),k0=()=>({x:j8(),y:j8()}),T8=()=>({min:0,max:0}),Ea=()=>({x:T8(),y:T8()}),nge=new WeakMap;function hE(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function J1(e){return typeof e=="string"||Array.isArray(e)}const $T=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],HT=["initial",...$T];function fE(e){return hE(e.animate)||HT.some(t=>J1(e[t]))}function dW(e){return!!(fE(e)||e.variants)}function rge(e,t,n){for(const r in t){const i=t[r],a=n[r];if(so(i))e.addValue(r,i);else if(so(a))e.addValue(r,pg(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){const o=e.getValue(r);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=e.getStaticValue(r);e.addValue(r,pg(o!==void 0?o:i,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}const jC={current:null},hW={current:!1},ige=typeof window<"u";function sge(){if(hW.current=!0,!!ige)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>jC.current=e.matches;e.addEventListener("change",t),t()}else jC.current=!1}const O8=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let b2={};function fW(e){b2=e}function age(){return b2}class oge{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:i,skipAnimations:a,blockInitialAnimation:o,visualState:c},h={}){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=RT,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 A=$o.now();this.renderScheduledAtthis.bindToMotionValue(a,i)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(hW.current||sge(),this.shouldReduceMotion=jC.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(r=this.parent)==null||r.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var t;this.projection&&this.projection.unmount(),xf(this.notifyUpdate),xf(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(t=this.parent)==null||t.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const r=this.features[n];r&&(r.unmount(),r.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),n.accelerate&&Wq.has(t)&&this.current instanceof HTMLElement){const{factory:o,keyframes:c,times:h,ease:f,duration:m}=n.accelerate,y=new Gq({element:this.current,name:t,keyframes:c,times:h,ease:f,duration:Vl(m)}),w=o(y);this.valueSubscriptions.set(t,()=>{w(),y.cancel()});return}const r=Rg.has(t);r&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",o=>{this.latestValues[t]=o,this.props.onUpdate&&ts.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let a;typeof window<"u"&&window.MotionCheckAppearSync&&(a=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),a&&a(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in b2){const n=b2[t];if(!n)continue;const{isEnabled:r,Feature:i}=n;if(!this.features[t]&&i&&r(this.props)&&(this.features[t]=new i(this)),this.features[t]){const a=this.features[t];a.isMounted?a.update():(a.mount(),a.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Ea()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;rn.variantChildren.delete(t)}addValue(t,n){const r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=pg(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){let r=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return r!=null&&(typeof r=="string"&&(dq(r)||fq(r))?r=parseFloat(r):!tge(r)&&zc.test(n)&&(r=iW(t,n)),this.setBaseTarget(t,so(r)?r.get():r)),so(r)?r.get():r}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var a;const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const o=LT(this.props,n,(a=this.presenceContext)==null?void 0:a.custom);o&&(r=o[t])}if(n&&r!==void 0)return r;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!so(i)?i:this.initialValues[t]!==void 0&&r===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new _T),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){zT.render(this.render)}}class pW extends oge{constructor(){super(...arguments),this.KeyframeResolver=D0e}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const r=t.style;return r?r[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;so(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class Cf{constructor(t){this.isMounted=!1,this.node=t}update(){}}function mW({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function lge({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function cge(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function sS(e){return e===void 0||e===1}function TC({scale:e,scaleX:t,scaleY:n}){return!sS(e)||!sS(t)||!sS(n)}function op(e){return TC(e)||gW(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function gW(e){return P8(e.x)||P8(e.y)}function P8(e){return e&&e!=="0%"}function v2(e,t,n){const r=e-n,i=t*r;return n+i}function R8(e,t,n,r,i){return i!==void 0&&(e=v2(e,i,r)),v2(e,n,r)+t}function OC(e,t=0,n=1,r,i){e.min=R8(e.min,t,n,r,i),e.max=R8(e.max,t,n,r,i)}function xW(e,{x:t,y:n}){OC(e.x,t.translate,t.scale,t.originPoint),OC(e.y,n.translate,n.scale,n.originPoint)}const D8=.999999999999,M8=1.0000000000001;function uge(e,t,n,r=!1){var c;const i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let h=0;hD8&&(t.x=1),t.yD8&&(t.y=1)}function xu(e,t){e.min+=t,e.max+=t}function L8(e,t,n,r,i=.5){const a=gs(e.min,e.max,i);OC(e,t,n,a,r)}function U8(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Ew(e,t,n){const r=n??e;L8(e.x,U8(t.x,r.x),t.scaleX,t.scale,t.originX),L8(e.y,U8(t.y,r.y),t.scaleY,t.scale,t.originY)}function yW(e,t){return mW(cge(e.getBoundingClientRect(),t))}function dge(e,t,n){const r=yW(e,n),{scroll:i}=t;return i&&(xu(r.x,i.offset.x),xu(r.y,i.offset.y)),r}const hge={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},fge=Pg.length;function pge(e,t,n){let r="",i=!0;for(let a=0;a{if(!t.target)return e;if(typeof e=="string")if(Un.test(e))e=parseFloat(e);else return e;const n=B8(e,t.target.x),r=B8(e,t.target.y);return`${n}% ${r}%`}},mge={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,i=zc.parse(e);if(i.length>5)return r;const a=zc.createTransformer(e),o=typeof i[0]!="number"?1:0,c=n.x.scale*t.x,h=n.y.scale*t.y;i[0+o]/=c,i[1+o]/=h;const f=gs(c,h,.5);return typeof i[2+o]=="number"&&(i[2+o]/=f),typeof i[3+o]=="number"&&(i[3+o]/=f),a(i)}},PC={borderRadius:{...Dx,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Dx,borderTopRightRadius:Dx,borderBottomLeftRadius:Dx,borderBottomRightRadius:Dx,boxShadow:mge};function vW(e,{layout:t,layoutId:n}){return Rg.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!PC[e]||e==="opacity")}function qT(e,t,n){var o;const r=e.style,i=t==null?void 0:t.style,a={};if(!r)return a;for(const c in r)(so(r[c])||i&&so(i[c])||vW(c,e)||((o=n==null?void 0:n.getValue(c))==null?void 0:o.liveStyle)!==void 0)&&(a[c]=r[c]);return a}function gge(e){return window.getComputedStyle(e)}class xge extends pW{constructor(){super(...arguments),this.type="html",this.renderInstance=bW}readValueFromInstance(t,n){var r;if(Rg.has(n))return(r=this.projection)!=null&&r.isProjecting?bC(n):Lme(t,n);{const i=gge(t),a=(Cq(n)?i.getPropertyValue(n):i[n])||0;return typeof a=="string"?a.trim():a}}measureInstanceViewportBox(t,{transformPagePoint:n}){return yW(t,n)}build(t,n,r){GT(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return qT(t,n,r)}}const yge={offset:"stroke-dashoffset",array:"stroke-dasharray"},bge={offset:"strokeDashoffset",array:"strokeDasharray"};function vge(e,t,n=1,r=0,i=!0){e.pathLength=1;const a=i?yge:bge;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}const wge=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function wW(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...c},h,f,m){if(GT(e,c,f),h){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:y,style:w}=e;y.transform&&(w.transform=y.transform,delete y.transform),(w.transform||y.transformOrigin)&&(w.transformOrigin=y.transformOrigin??"50% 50%",delete y.transformOrigin),w.transform&&(w.transformBox=(m==null?void 0:m.transformBox)??"fill-box",delete y.transformBox);for(const A of wge)y[A]!==void 0&&(w[A]=y[A],delete y[A]);t!==void 0&&(y.x=t),n!==void 0&&(y.y=n),r!==void 0&&(y.scale=r),i!==void 0&&vge(y,i,a,o,!1)}const NW=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"]),EW=e=>typeof e=="string"&&e.toLowerCase()==="svg";function Nge(e,t,n,r){bW(e,t,void 0,r);for(const i in t.attrs)e.setAttribute(NW.has(i)?i:UT(i),t.attrs[i])}function AW(e,t,n){const r=qT(e,t,n);for(const i in e)if(so(e[i])||so(t[i])){const a=Pg.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[a]=e[i]}return r}class Ege extends pW{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Ea}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Rg.has(n)){const r=rW(n);return r&&r.default||0}return n=NW.has(n)?n:UT(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return AW(t,n,r)}build(t,n,r){wW(t,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(t,n,r,i){Nge(t,n,r,i)}mount(t){this.isSVGTag=EW(t.tagName),super.mount(t)}}const Age=HT.length;function _W(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?_W(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;nPromise.all(t.map(({animation:n,options:r})=>A0e(e,n,r)))}function Cge(e){let t=kge(e),n=z8(),r=!0,i=!1;const a=f=>(m,y)=>{var A;const w=Mp(e,y,f==="exit"?(A=e.presenceContext)==null?void 0:A.custom:void 0);if(w){const{transition:k,transitionEnd:I,...T}=w;m={...m,...T,...I}}return m};function o(f){t=f(e)}function c(f){const{props:m}=e,y=_W(e.parent)||{},w=[],A=new Set;let k={},I=1/0;for(let D=0;DI&&Z,$=!1;const Q=Array.isArray(q)?q:[q];let Y=Q.reduce(a(F),{});K===!1&&(Y={});const{prevResolvedValues:G={}}=L,he={...G,...Y},te=ke=>{V=!0,A.has(ke)&&($=!0,A.delete(ke)),L.needsAnimating[ke]=!0;const Be=e.getValue(ke);Be&&(Be.liveStyle=!1)};for(const ke in he){const Be=Y[ke],J=G[ke];if(k.hasOwnProperty(ke))continue;let ie=!1;_C(Be)&&_C(J)?ie=!SW(Be,J):ie=Be!==J,ie?Be!=null?te(ke):A.add(ke):Be!==void 0&&A.has(ke)?te(ke):L.protectedKeys[ke]=!0}L.prevProp=q,L.prevResolvedValues=Y,L.isActive&&(k={...k,...Y}),(r||i)&&e.blockInitialAnimation&&(V=!1);const le=z&&B;V&&(!le||$)&&w.push(...Q.map(ke=>{const Be={type:F};if(typeof ke=="string"&&(r||i)&&!le&&e.manuallyAnimateOnMount&&e.parent){const{parent:J}=e,ie=Mp(J,ke);if(J.enteringChildren&&ie){const{delayChildren:xe}=ie.transition||{};Be.delay=Kq(J.enteringChildren,e,xe)}}return{animation:ke,options:Be}}))}if(A.size){const D={};if(typeof m.initial!="boolean"){const F=Mp(e,Array.isArray(m.initial)?m.initial[0]:m.initial);F&&F.transition&&(D.transition=F.transition)}A.forEach(F=>{const L=e.getBaseTarget(F),q=e.getValue(F);q&&(q.liveStyle=!0),D[F]=L??null}),w.push({animation:D})}let T=!!w.length;return r&&(m.initial===!1||m.initial===m.animate)&&!e.manuallyAnimateOnMount&&(T=!1),r=!1,i=!1,T?t(w):Promise.resolve()}function h(f,m){var w;if(n[f].isActive===m)return Promise.resolve();(w=e.variantChildren)==null||w.forEach(A=>{var k;return(k=A.animationState)==null?void 0:k.setActive(f,m)}),n[f].isActive=m;const y=c(f);for(const A in n)n[A].protectedKeys={};return y}return{animateChanges:c,setActive:h,setAnimateFunction:o,getState:()=>n,reset:()=>{n=z8(),i=!0}}}function Ige(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!SW(t,e):!1}function Zf(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function z8(){return{animate:Zf(!0),whileInView:Zf(),whileHover:Zf(),whileTap:Zf(),whileDrag:Zf(),whileFocus:Zf(),exit:Zf()}}function RC(e,t){e.min=t.min,e.max=t.max}function Ic(e,t){RC(e.x,t.x),RC(e.y,t.y)}function V8(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const kW=1e-4,jge=1-kW,Tge=1+kW,CW=.01,Oge=0-CW,Pge=0+CW;function Ho(e){return e.max-e.min}function Rge(e,t,n){return Math.abs(e-t)<=n}function F8(e,t,n,r=.5){e.origin=r,e.originPoint=gs(t.min,t.max,e.origin),e.scale=Ho(n)/Ho(t),e.translate=gs(n.min,n.max,e.origin)-e.originPoint,(e.scale>=jge&&e.scale<=Tge||isNaN(e.scale))&&(e.scale=1),(e.translate>=Oge&&e.translate<=Pge||isNaN(e.translate))&&(e.translate=0)}function S1(e,t,n,r){F8(e.x,t.x,n.x,r?r.originX:void 0),F8(e.y,t.y,n.y,r?r.originY:void 0)}function $8(e,t,n,r=0){const i=r?gs(n.min,n.max,r):n.min;e.min=i+t.min,e.max=e.min+Ho(t)}function Dge(e,t,n,r){$8(e.x,t.x,n.x,r==null?void 0:r.x),$8(e.y,t.y,n.y,r==null?void 0:r.y)}function H8(e,t,n,r=0){const i=r?gs(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+Ho(t)}function w2(e,t,n,r){H8(e.x,t.x,n.x,r==null?void 0:r.x),H8(e.y,t.y,n.y,r==null?void 0:r.y)}function G8(e,t,n,r,i){return e-=t,e=v2(e,1/n,r),i!==void 0&&(e=v2(e,1/i,r)),e}function Mge(e,t=0,n=1,r=.5,i,a=e,o=e){if(ju.test(t)&&(t=parseFloat(t),t=gs(o.min,o.max,t/100)-o.min),typeof t!="number")return;let c=gs(a.min,a.max,r);e===a&&(c-=t),e.min=G8(e.min,t,n,c,i),e.max=G8(e.max,t,n,c,i)}function q8(e,t,[n,r,i],a,o){Mge(e,t[n],t[r],t[i],t.scale,a,o)}const Lge=["x","scaleX","originX"],Uge=["y","scaleY","originY"];function W8(e,t,n,r){q8(e.x,t,Lge,n?n.x:void 0,r?r.x:void 0),q8(e.y,t,Uge,n?n.y:void 0,r?r.y:void 0)}function K8(e){return e.translate===0&&e.scale===1}function IW(e){return K8(e.x)&&K8(e.y)}function Y8(e,t){return e.min===t.min&&e.max===t.max}function Bge(e,t){return Y8(e.x,t.x)&&Y8(e.y,t.y)}function X8(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function jW(e,t){return X8(e.x,t.x)&&X8(e.y,t.y)}function Q8(e){return Ho(e.x)/Ho(e.y)}function Z8(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function uu(e){return[e("x"),e("y")]}function zge(e,t,n){let r="";const i=e.x.translate/t.x,a=e.y.translate/t.y,o=(n==null?void 0:n.z)||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:f,rotate:m,rotateX:y,rotateY:w,skewX:A,skewY:k}=n;f&&(r=`perspective(${f}px) ${r}`),m&&(r+=`rotate(${m}deg) `),y&&(r+=`rotateX(${y}deg) `),w&&(r+=`rotateY(${w}deg) `),A&&(r+=`skewX(${A}deg) `),k&&(r+=`skewY(${k}deg) `)}const c=e.x.scale*t.x,h=e.y.scale*t.y;return(c!==1||h!==1)&&(r+=`scale(${c}, ${h})`),r||"none"}const TW=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],Vge=TW.length,J8=e=>typeof e=="string"?parseFloat(e):e,eM=e=>typeof e=="number"||Un.test(e);function Fge(e,t,n,r,i,a){i?(e.opacity=gs(0,n.opacity??1,$ge(r)),e.opacityExit=gs(t.opacity??1,0,Hge(r))):a&&(e.opacity=gs(t.opacity??1,n.opacity??1,r));for(let o=0;ort?1:n(Q1(e,t,r))}function Gge(e,t,n){const r=so(e)?e:pg(e);return r.start(MT("",r,t,n)),r.animation}function ey(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}const qge=(e,t)=>e.depth-t.depth;class Wge{constructor(){this.children=[],this.isDirty=!1}add(t){ET(this.children,t),this.isDirty=!0}remove(t){p2(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(qge),this.isDirty=!1,this.children.forEach(t)}}function Kge(e,t){const n=$o.now(),r=({timestamp:i})=>{const a=i-n;a>=t&&(xf(r),e(a-t))};return ts.setup(r,!0),()=>xf(r)}function Aw(e){return so(e)?e.get():e}class Yge{constructor(){this.members=[]}add(t){ET(this.members,t);for(let n=this.members.length-1;n>=0;n--){const r=this.members[n];if(r===t||r===this.lead||r===this.prevLead)continue;const i=r.instance;(!i||i.isConnected===!1)&&!r.snapshot&&(p2(this.members,r),r.unmount())}t.scheduleRender()}remove(t){if(p2(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){var n;for(let r=this.members.indexOf(t)-1;r>=0;r--){const i=this.members[r];if(i.isPresent!==!1&&((n=i.instance)==null?void 0:n.isConnected)!==!1)return this.promote(i),!0}return!1}promote(t,n){var i;const r=this.lead;if(t!==r&&(this.prevLead=r,this.lead=t,t.show(),r)){r.updateSnapshot(),t.scheduleRender();const{layoutDependency:a}=r.options,{layoutDependency:o}=t.options;(a===void 0||a!==o)&&(t.resumeFrom=r,n&&(r.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues),(i=t.root)!=null&&i.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(t=>{var n,r,i,a,o;(r=(n=t.options).onExitComplete)==null||r.call(n),(o=(i=t.resumingFrom)==null?void 0:(a=i.options).onExitComplete)==null||o.call(a)})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){var t;(t=this.lead)!=null&&t.snapshot&&(this.lead.snapshot=void 0)}}const _w={hasAnimatedSinceResize:!0,hasEverUpdated:!1},aS=["","X","Y","Z"],Xge=1e3;let Qge=0;function oS(e,t,n,r){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function PW(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Jq(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:a}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",ts,!(i||a))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&PW(r)}function RW({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(o={},c=t==null?void 0:t()){this.id=Qge++,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(exe),this.nodes.forEach(axe),this.nodes.forEach(oxe),this.nodes.forEach(txe)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=c?c.root||c:this,this.path=c?[...c.path,c]:[],this.parent=c,this.depth=c?c.depth+1:0;for(let h=0;hthis.root.updateBlockedByResize=!1;ts.read(()=>{y=window.innerWidth}),e(o,()=>{const A=window.innerWidth;A!==y&&(y=A,this.root.updateBlockedByResize=!0,m&&m(),m=Kge(w,250),_w.hasAnimatedSinceResize&&(_w.hasAnimatedSinceResize=!1,this.nodes.forEach(iM)))})}c&&this.root.registerSharedNode(c,this),this.options.animate!==!1&&f&&(c||h)&&this.addEventListener("didUpdate",({delta:m,hasLayoutChanged:y,hasRelativeLayoutChanged:w,layout:A})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const k=this.options.transition||f.getDefaultTransition()||hxe,{onLayoutAnimationStart:I,onLayoutAnimationComplete:T}=f.getProps(),D=!this.targetLayout||!jW(this.targetLayout,A),F=!y&&w;if(this.options.layoutRoot||this.resumeFrom||F||y&&(D||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const L={...DT(k,"layout"),onPlay:I,onComplete:T};(f.shouldReduceMotion||this.options.layoutRoot)&&(L.delay=0,L.type=!1),this.startAnimation(L),this.setAnimationOrigin(m,F)}else y||iM(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=A})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),xf(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(lxe),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&PW(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let m=0;m{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Ho(this.snapshot.measuredBox.x)&&!Ho(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 h=0;h{const Z=q/1e3;sM(y.x,o.x,Z),sM(y.y,o.y,Z),this.setTargetDelta(y),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(w2(w,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),uxe(this.relativeTarget,this.relativeTargetOrigin,w,Z),L&&Bge(this.relativeTarget,L)&&(this.isProjectionDirty=!1),L||(L=Ea()),Ic(L,this.relativeTarget)),I&&(this.animationValues=m,Fge(m,f,this.latestValues,Z,F,D)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=Z},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){var c,h,f;this.notifyListeners("animationStart"),(c=this.currentAnimation)==null||c.stop(),(f=(h=this.resumingFrom)==null?void 0:h.currentAnimation)==null||f.stop(),this.pendingAnimation&&(xf(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ts.update(()=>{_w.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=pg(0)),this.motionValue.jump(0,!1),this.currentAnimation=Gge(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:m=>{this.mixTargetDelta(m),o.onUpdate&&o.onUpdate(m)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.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 o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Xge),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:c,target:h,layout:f,latestValues:m}=o;if(!(!c||!h||!f)){if(this!==o&&this.layout&&f&&DW(this.options.animationType,this.layout.layoutBox,f.layoutBox)){h=this.target||Ea();const y=Ho(this.layout.layoutBox.x);h.x.min=o.target.x.min,h.x.max=h.x.min+y;const w=Ho(this.layout.layoutBox.y);h.y.min=o.target.y.min,h.y.max=h.y.min+w}Ic(c,h),Ew(c,m),S1(this.projectionDeltaWithTransform,this.layoutCorrected,c,m)}}registerSharedNode(o,c){this.sharedNodes.has(o)||this.sharedNodes.set(o,new Yge),this.sharedNodes.get(o).add(c);const f=c.options.initialPromotionConfig;c.promote({transition:f?f.transition:void 0,preserveFollowOpacity:f&&f.shouldPreserveFollowOpacity?f.shouldPreserveFollowOpacity(c):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var c;const{layoutId:o}=this.options;return o?((c=this.getStack())==null?void 0:c.lead)||this:this}getPrevLead(){var c;const{layoutId:o}=this.options;return o?(c=this.getStack())==null?void 0:c.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:c,preserveFollowOpacity:h}={}){const f=this.getStack();f&&f.promote(this,h),o&&(this.projectionDelta=void 0,this.needsReset=!0),c&&this.setOptions({transition:c})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let c=!1;const{latestValues:h}=o;if((h.z||h.rotate||h.rotateX||h.rotateY||h.rotateZ||h.skewX||h.skewY)&&(c=!0),!c)return;const f={};h.z&&oS("z",o,f,this.animationValues);for(let m=0;m{var c;return(c=o.currentAnimation)==null?void 0:c.stop()}),this.root.nodes.forEach(nM),this.root.sharedNodes.clear()}}}function Zge(e){e.updateLayout()}function Jge(e){var n;const t=((n=e.resumeFrom)==null?void 0:n.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:r,measuredBox:i}=e.layout,{animationType:a}=e.options,o=t.source!==e.layout.source;if(a==="size")uu(y=>{const w=o?t.measuredBox[y]:t.layoutBox[y],A=Ho(w);w.min=r[y].min,w.max=w.min+A});else if(a==="x"||a==="y"){const y=a==="x"?"y":"x";RC(o?t.measuredBox[y]:t.layoutBox[y],r[y])}else DW(a,t.layoutBox,r)&&uu(y=>{const w=o?t.measuredBox[y]:t.layoutBox[y],A=Ho(r[y]);w.max=w.min+A,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[y].max=e.relativeTarget[y].min+A)});const c=k0();S1(c,r,t.layoutBox);const h=k0();o?S1(h,e.applyTransform(i,!0),t.measuredBox):S1(h,r,t.layoutBox);const f=!IW(c);let m=!1;if(!e.resumeFrom){const y=e.getClosestProjectingParent();if(y&&!y.resumeFrom){const{snapshot:w,layout:A}=y;if(w&&A){const k=e.options.layoutAnchor||void 0,I=Ea();w2(I,t.layoutBox,w.layoutBox,k);const T=Ea();w2(T,r,A.layoutBox,k),jW(I,T)||(m=!0),y.options.layoutRoot&&(e.relativeTarget=T,e.relativeTargetOrigin=I,e.relativeParent=y)}}}e.notifyListeners("didUpdate",{layout:r,snapshot:t,delta:h,layoutDelta:c,hasLayoutChanged:f,hasRelativeLayoutChanged:m})}else if(e.isLead()){const{onExitComplete:r}=e.options;r&&r()}e.options.transition=void 0}function exe(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function txe(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function nxe(e){e.clearSnapshot()}function nM(e){e.clearMeasurements()}function rxe(e){e.isLayoutDirty=!0,e.updateLayout()}function rM(e){e.isLayoutDirty=!1}function ixe(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function sxe(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function iM(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function axe(e){e.resolveTargetDelta()}function oxe(e){e.calcProjection()}function lxe(e){e.resetSkewAndRotation()}function cxe(e){e.removeLeadSnapshot()}function sM(e,t,n){e.translate=gs(t.translate,0,n),e.scale=gs(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function aM(e,t,n,r){e.min=gs(t.min,n.min,r),e.max=gs(t.max,n.max,r)}function uxe(e,t,n,r){aM(e.x,t.x,n.x,r),aM(e.y,t.y,n.y,r)}function dxe(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const hxe={duration:.45,ease:[.4,0,.1,1]},oM=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),lM=oM("applewebkit/")&&!oM("chrome/")?Math.round:uc;function cM(e){e.min=lM(e.min),e.max=lM(e.max)}function fxe(e){cM(e.x),cM(e.y)}function DW(e,t,n){return e==="position"||e==="preserve-aspect"&&!Rge(Q8(t),Q8(n),.2)}function pxe(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const mxe=RW({attachResizeListener:(e,t)=>ey(e,"resize",t),measureScroll:()=>{var e,t;return{x:document.documentElement.scrollLeft||((e=document.body)==null?void 0:e.scrollLeft)||0,y:document.documentElement.scrollTop||((t=document.body)==null?void 0:t.scrollTop)||0}},checkIsScrollRoot:()=>!0}),lS={current:void 0},MW=RW({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!lS.current){const e=new mxe({});e.mount(window),e.setOptions({layoutScroll:!0}),lS.current=e}return lS.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),WT=j.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function uM(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function gxe(...e){return t=>{let n=!1;const r=e.map(i=>{const a=uM(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i{const{width:A,height:k,top:I,left:T,right:D,bottom:F}=h.current;if(t||a===!1||!c.current||!A||!k)return;const L=n==="left"?`left: ${T}`:`right: ${D}`,q=r==="bottom"?`bottom: ${F}`:`top: ${I}`;c.current.dataset.motionPopId=o;const Z=document.createElement("style");f&&(Z.nonce=f);const K=i??document.head;return K.appendChild(Z),Z.sheet&&Z.sheet.insertRule(` [data-motion-pop-id="${o}"] { position: absolute !important; width: ${A}px !important; height: ${k}px !important; ${L}px !important; ${q}px !important; } `),()=>{var z;(z=c.current)==null||z.removeAttribute("data-motion-pop-id"),K.contains(Z)&&K.removeChild(Z)}},[t]),s.jsx(yxe,{isPresent:t,childRef:c,sizeRef:h,pop:a,children:a===!1?e:j.cloneElement(e,{ref:y})})}const vxe=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:c,anchorY:h,root:f})=>{const m=NT(wxe),y=j.useId();let w=!0,A=j.useMemo(()=>(w=!1,{id:y,initial:t,isPresent:n,custom:i,onExitComplete:k=>{m.set(k,!0);for(const I of m.values())if(!I)return;r&&r()},register:k=>(m.set(k,!1),()=>m.delete(k))}),[n,m,r]);return a&&w&&(A={...A}),j.useMemo(()=>{m.forEach((k,I)=>m.set(I,!1))},[n]),j.useEffect(()=>{!n&&!m.size&&r&&r()},[n]),e=s.jsx(bxe,{pop:o==="popLayout",isPresent:n,anchorX:c,anchorY:h,root:f,children:e}),s.jsx(uE.Provider,{value:A,children:e})};function wxe(){return new Map}function LW(e=!0){const t=j.useContext(uE);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:i}=t,a=j.useId();j.useEffect(()=>{if(e)return i(a)},[e]);const o=j.useCallback(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}const Nv=e=>e.key||"";function dM(e){const t=[];return j.Children.forEach(e,n=>{j.isValidElement(n)&&t.push(n)}),t}const ar=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a="sync",propagate:o=!1,anchorX:c="left",anchorY:h="top",root:f})=>{const[m,y]=LW(o),w=j.useMemo(()=>dM(e),[e]),A=o&&!m?[]:w.map(Nv),k=j.useRef(!0),I=j.useRef(w),T=NT(()=>new Map),D=j.useRef(new Set),[F,L]=j.useState(w),[q,Z]=j.useState(w);uq(()=>{k.current=!1,I.current=w;for(let B=0;B{const V=Nv(B),$=o&&!m?!1:w===q||A.includes(V),Q=()=>{if(D.current.has(V))return;if(T.has(V))D.current.add(V),T.set(V,!0);else return;let Y=!0;T.forEach(G=>{G||(Y=!1)}),Y&&(z==null||z(),Z(I.current),o&&(y==null||y()),r&&r())};return s.jsx(vxe,{isPresent:$,initial:!k.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:f,onExitComplete:$?void 0:Q,anchorX:c,anchorY:h,children:B},V)})})},UW=j.createContext({strict:!1}),hM={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 fM=!1;function Nxe(){if(fM)return;const e={};for(const t in hM)e[t]={isEnabled:n=>hM[t].some(r=>!!n[r])};fW(e),fM=!0}function BW(){return Nxe(),age()}function Exe(e){const t=BW();for(const n in e)t[n]={...t[n],...e[n]};fW(t)}const Axe=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 N2(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Axe.has(e)}let zW=e=>!N2(e);function _xe(e){typeof e=="function"&&(zW=t=>t.startsWith("on")?!N2(t):e(t))}try{_xe(require("@emotion/is-prop-valid").default)}catch{}function Sxe(e,t,n){const r={};for(const i in e)i==="values"&&typeof e.values=="object"||so(e[i])||(zW(i)||n===!0&&N2(i)||!t&&!N2(i)||e.draggable&&i.startsWith("onDrag"))&&(r[i]=e[i]);return r}const pE=j.createContext({});function kxe(e,t){if(fE(e)){const{initial:n,animate:r}=e;return{initial:n===!1||J1(n)?n:void 0,animate:J1(r)?r:void 0}}return e.inherit!==!1?t:{}}function Cxe(e){const{initial:t,animate:n}=kxe(e,j.useContext(pE));return j.useMemo(()=>({initial:t,animate:n}),[pM(t),pM(n)])}function pM(e){return Array.isArray(e)?e.join(" "):e}const KT=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function VW(e,t,n){for(const r in t)!so(t[r])&&!vW(r,n)&&(e[r]=t[r])}function Ixe({transformTemplate:e},t){return j.useMemo(()=>{const n=KT();return GT(n,t,e),Object.assign({},n.vars,n.style)},[t])}function jxe(e,t){const n=e.style||{},r={};return VW(r,n,e),Object.assign(r,Ixe(e,t)),r}function Txe(e,t){const n={},r=jxe(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}const FW=()=>({...KT(),attrs:{}});function Oxe(e,t,n,r){const i=j.useMemo(()=>{const a=FW();return wW(a,t,EW(r),e.transformTemplate,e.style),{...a.attrs,style:{...a.style}}},[t]);if(e.style){const a={};VW(a,e.style,e),i.style={...a,...i.style}}return i}const Pxe=["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 YT(e){return typeof e!="string"||e.includes("-")?!1:!!(Pxe.indexOf(e)>-1||/[A-Z]/u.test(e))}function Rxe(e,t,n,{latestValues:r},i,a=!1,o){const h=(o??YT(e)?Oxe:Txe)(t,r,i,e),f=Sxe(t,typeof e=="string",a),m=e!==j.Fragment?{...f,...h,ref:n}:{},{children:y}=t,w=j.useMemo(()=>so(y)?y.get():y,[y]);return j.createElement(e,{...m,children:w})}function Dxe({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Mxe(n,r,i,e),renderState:t()}}function Mxe(e,t,n,r){const i={},a=r(e,{});for(const w in a)i[w]=Aw(a[w]);let{initial:o,animate:c}=e;const h=fE(e),f=dW(e);t&&f&&!h&&e.inherit!==!1&&(o===void 0&&(o=t.initial),c===void 0&&(c=t.animate));let m=n?n.initial===!1:!1;m=m||o===!1;const y=m?c:o;if(y&&typeof y!="boolean"&&!hE(y)){const w=Array.isArray(y)?y:[y];for(let A=0;A(t,n)=>{const r=j.useContext(pE),i=j.useContext(uE),a=()=>Dxe(e,t,r,i);return n?a():NT(a)},Lxe=$W({scrapeMotionValuesFromProps:qT,createRenderState:KT}),Uxe=$W({scrapeMotionValuesFromProps:AW,createRenderState:FW}),Bxe=Symbol.for("motionComponentSymbol");function zxe(e,t,n){const r=j.useRef(n);j.useInsertionEffect(()=>{r.current=n});const i=j.useRef(null);return j.useCallback(a=>{var c;a&&((c=e.onMount)==null||c.call(e,a));const o=r.current;if(typeof o=="function")if(a){const h=o(a);typeof h=="function"&&(i.current=h)}else i.current?(i.current(),i.current=null):o(a);else o&&(o.current=a);t&&(a?t.mount(a):t.unmount())},[t])}const HW=j.createContext({});function w0(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Vxe(e,t,n,r,i,a){var L,q;const{visualElement:o}=j.useContext(pE),c=j.useContext(UW),h=j.useContext(uE),f=j.useContext(WT),m=f.reducedMotion,y=f.skipAnimations,w=j.useRef(null),A=j.useRef(!1);r=r||c.renderer,!w.current&&r&&(w.current=r(e,{visualState:t,parent:o,props:n,presenceContext:h,blockInitialAnimation:h?h.initial===!1:!1,reducedMotionConfig:m,skipAnimations:y,isSVG:a}),A.current&&w.current&&(w.current.manuallyAnimateOnMount=!0));const k=w.current,I=j.useContext(HW);k&&!k.projection&&i&&(k.type==="html"||k.type==="svg")&&Fxe(w.current,n,i,I);const T=j.useRef(!1);j.useInsertionEffect(()=>{k&&T.current&&k.update(n,h)});const D=n[Zq],F=j.useRef(!!D&&typeof window<"u"&&!((L=window.MotionHandoffIsComplete)!=null&&L.call(window,D))&&((q=window.MotionHasOptimisedAnimation)==null?void 0:q.call(window,D)));return uq(()=>{A.current=!0,k&&(T.current=!0,window.MotionIsMounted=!0,k.updateFeatures(),k.scheduleRenderMicrotask(),F.current&&k.animationState&&k.animationState.animateChanges())}),j.useEffect(()=>{k&&(!F.current&&k.animationState&&k.animationState.animateChanges(),F.current&&(queueMicrotask(()=>{var Z;(Z=window.MotionHandoffMarkAsComplete)==null||Z.call(window,D)}),F.current=!1),k.enteringChildren=void 0)}),k}function Fxe(e,t,n,r){const{layoutId:i,layout:a,drag:o,dragConstraints:c,layoutScroll:h,layoutRoot:f,layoutAnchor:m,layoutCrossfade:y}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:GW(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||c&&w0(c),visualElement:e,animationType:typeof a=="string"?a:"both",initialPromotionConfig:r,crossfade:y,layoutScroll:h,layoutRoot:f,layoutAnchor:m})}function GW(e){if(e)return e.options.allowProjection!==!1?e.projection:GW(e.parent)}function cS(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&Exe(r);const a=n?n==="svg":YT(e),o=a?Uxe:Lxe;function c(f,m){let y;const w={...j.useContext(WT),...f,layoutId:$xe(f)},{isStatic:A}=w,k=Cxe(f),I=o(f,A);if(!A&&typeof window<"u"){Hxe();const T=Gxe(w);y=T.MeasureLayout,k.visualElement=Vxe(e,I,w,i,T.ProjectionNode,a)}return s.jsxs(pE.Provider,{value:k,children:[y&&k.visualElement?s.jsx(y,{visualElement:k.visualElement,...w}):null,Rxe(e,f,zxe(I,k.visualElement,m),I,A,t,a)]})}c.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const h=j.forwardRef(c);return h[Bxe]=e,h}function $xe({layoutId:e}){const t=j.useContext(wT).id;return t&&e!==void 0?t+"-"+e:e}function Hxe(e,t){j.useContext(UW).strict}function Gxe(e){const t=BW(),{drag:n,layout:r}=t;if(!n&&!r)return{};const i={...n,...r};return{MeasureLayout:n!=null&&n.isEnabled(e)||r!=null&&r.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}function qxe(e,t){if(typeof Proxy>"u")return cS;const n=new Map,r=(a,o)=>cS(a,o,e,t),i=(a,o)=>r(a,o);return new Proxy(i,{get:(a,o)=>o==="create"?r:(n.has(o)||n.set(o,cS(o,void 0,e,t)),n.get(o))})}const Wxe=(e,t)=>t.isSVG??YT(e)?new Ege(t):new xge(t,{allowProjection:e!==j.Fragment});class Kxe extends Cf{constructor(t){super(t),t.animationState||(t.animationState=Cge(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();hE(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let Yxe=0;class Xxe extends Cf{constructor(){super(...arguments),this.id=Yxe++,this.isExitComplete=!1}update(){var a;if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;if(t&&r===!1){if(this.isExitComplete){const{initial:o,custom:c}=this.node.getProps();if(typeof o=="string"){const h=Mp(this.node,o,c);if(h){const{transition:f,transitionEnd:m,...y}=h;for(const w in y)(a=this.node.getValue(w))==null||a.jump(y[w])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Qxe={animation:{Feature:Kxe},exit:{Feature:Xxe}};function By(e){return{point:{x:e.pageX,y:e.pageY}}}const Zxe=e=>t=>VT(t)&&e(t,By(t));function k1(e,t,n,r){return ey(e,t,Zxe(n),r)}const qW=({current:e})=>e?e.ownerDocument.defaultView:null,mM=(e,t)=>Math.abs(e-t);function Jxe(e,t){const n=mM(e.x,t.x),r=mM(e.y,t.y);return Math.sqrt(n**2+r**2)}const gM=new Set(["auto","scroll"]);class WW{constructor(t,n,{transformPagePoint:r,contextWindow:i=window,dragSnapToOrigin:a=!1,distanceThreshold:o=3,element:c}={}){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=A=>{this.handleScroll(A.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Ev(this.lastRawMoveEventInfo,this.transformPagePoint));const A=uS(this.lastMoveEventInfo,this.history),k=this.startEvent!==null,I=Jxe(A.offset,{x:0,y:0})>=this.distanceThreshold;if(!k&&!I)return;const{point:T}=A,{timestamp:D}=to;this.history.push({...T,timestamp:D});const{onStart:F,onMove:L}=this.handlers;k||(F&&F(this.lastMoveEvent,A),this.startEvent=this.lastMoveEvent),L&&L(this.lastMoveEvent,A)},this.handlePointerMove=(A,k)=>{this.lastMoveEvent=A,this.lastRawMoveEventInfo=k,this.lastMoveEventInfo=Ev(k,this.transformPagePoint),ts.update(this.updatePoint,!0)},this.handlePointerUp=(A,k)=>{this.end();const{onEnd:I,onSessionEnd:T,resumeAnimation:D}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&D&&D(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const F=uS(A.type==="pointercancel"?this.lastMoveEventInfo:Ev(k,this.transformPagePoint),this.history);this.startEvent&&I&&I(A,F),T&&T(A,F)},!VT(t))return;this.dragSnapToOrigin=a,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=o,this.contextWindow=i||window;const h=By(t),f=Ev(h,this.transformPagePoint),{point:m}=f,{timestamp:y}=to;this.history=[{...m,timestamp:y}];const{onSessionStart:w}=n;w&&w(t,uS(f,this.history)),this.removeListeners=My(k1(this.contextWindow,"pointermove",this.handlePointerMove),k1(this.contextWindow,"pointerup",this.handlePointerUp),k1(this.contextWindow,"pointercancel",this.handlePointerUp)),c&&this.startScrollTracking(c)}startScrollTracking(t){let n=t.parentElement;for(;n;){const r=getComputedStyle(n);(gM.has(r.overflowX)||gM.has(r.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(t){const n=this.scrollPositions.get(t);if(!n)return;const r=t===window,i=r?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},a={x:i.x-n.x,y:i.y-n.y};a.x===0&&a.y===0||(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=a.x,this.lastMoveEventInfo.point.y+=a.y):this.history.length>0&&(this.history[0].x-=a.x,this.history[0].y-=a.y),this.scrollPositions.set(t,i),ts.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),xf(this.updatePoint)}}function Ev(e,t){return t?{point:t(e.point)}:e}function xM(e,t){return{x:e.x-t.x,y:e.y-t.y}}function uS({point:e},t){return{point:e,delta:xM(e,KW(t)),offset:xM(e,e1e(t)),velocity:t1e(t,.1)}}function e1e(e){return e[0]}function KW(e){return e[e.length-1]}function t1e(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const i=KW(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Vl(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Vl(t)*2&&(r=e[1]);const a=oc(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};const o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function n1e(e,{min:t,max:n},r){return t!==void 0&&en&&(e=r?gs(n,e,r.max):Math.min(e,n)),e}function yM(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function r1e(e,{top:t,left:n,bottom:r,right:i}){return{x:yM(e.x,n,i),y:yM(e.y,t,r)}}function bM(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.minr?n=Q1(t.min,t.max-r,e.min):r>i&&(n=Q1(e.min,e.max-i,t.min)),Mu(0,1,n)}function a1e(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const DC=.35;function o1e(e=DC){return e===!1?e=0:e===!0&&(e=DC),{x:vM(e,"left","right"),y:vM(e,"top","bottom")}}function vM(e,t,n){return{min:wM(e,t),max:wM(e,n)}}function wM(e,t){return typeof e=="number"?e:e[t]||0}const l1e=new WeakMap;class c1e{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Ea(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const a=y=>{n&&this.snapToCursor(By(y).point),this.stopAnimation()},o=(y,w)=>{const{drag:A,dragPropagation:k,onDragStart:I}=this.getProps();if(A&&!k&&(this.openDragLock&&this.openDragLock(),this.openDragLock=M0e(A),!this.openDragLock))return;this.latestPointerEvent=y,this.latestPanInfo=w,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),uu(D=>{let F=this.getAxisMotionValue(D).get()||0;if(ju.test(F)){const{projection:L}=this.visualElement;if(L&&L.layout){const q=L.layout.layoutBox[D];q&&(F=Ho(q)*(parseFloat(F)/100))}}this.originPoint[D]=F}),I&&ts.update(()=>I(y,w),!1,!0),SC(this.visualElement,"transform");const{animationState:T}=this.visualElement;T&&T.setActive("whileDrag",!0)},c=(y,w)=>{this.latestPointerEvent=y,this.latestPanInfo=w;const{dragPropagation:A,dragDirectionLock:k,onDirectionLock:I,onDrag:T}=this.getProps();if(!A&&!this.openDragLock)return;const{offset:D}=w;if(k&&this.currentDirection===null){this.currentDirection=d1e(D),this.currentDirection!==null&&I&&I(this.currentDirection);return}this.updateAxis("x",w.point,D),this.updateAxis("y",w.point,D),this.visualElement.render(),T&&ts.update(()=>T(y,w),!1,!0)},h=(y,w)=>{this.latestPointerEvent=y,this.latestPanInfo=w,this.stop(y,w),this.latestPointerEvent=null,this.latestPanInfo=null},f=()=>{const{dragSnapToOrigin:y}=this.getProps();(y||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:m}=this.getProps();this.panSession=new WW(t,{onSessionStart:a,onStart:o,onMove:c,onSessionEnd:h,resumeAnimation:f},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:m,distanceThreshold:r,contextWindow:qW(this.visualElement),element:this.visualElement.current})}stop(t,n){const r=t||this.latestPointerEvent,i=n||this.latestPanInfo,a=this.isDragging;if(this.cancel(),!a||!i||!r)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:c}=this.getProps();c&&ts.postRender(()=>c(r,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,r){const{drag:i}=this.getProps();if(!r||!Av(t,i,this.currentDirection))return;const a=this.getAxisMotionValue(t);let o=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(o=n1e(o,this.constraints[t],this.elastic[t])),a.set(o)}resolveConstraints(){var a;const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(a=this.visualElement.projection)==null?void 0:a.layout,i=this.constraints;t&&w0(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=r1e(r.layoutBox,t):this.constraints=!1,this.elastic=o1e(n),i!==this.constraints&&!w0(t)&&r&&this.constraints&&!this.hasMutatedConstraints&&uu(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=a1e(r.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!w0(t))return!1;const r=t.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const a=dge(r,i.root,this.visualElement.getTransformPagePoint());let o=i1e(i.layout.layoutBox,a);if(n){const c=n(lge(o));this.hasMutatedConstraints=!!c,c&&(o=mW(c))}return o}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:i,dragTransition:a,dragSnapToOrigin:o,onDragTransitionEnd:c}=this.getProps(),h=this.constraints||{},f=uu(m=>{if(!Av(m,n,this.currentDirection))return;let y=h&&h[m]||{};(o===!0||o===m)&&(y={min:0,max:0});const w=i?200:1e6,A=i?40:1e7,k={type:"inertia",velocity:r?t[m]:0,bounceStiffness:w,bounceDamping:A,timeConstant:750,restDelta:1,restSpeed:10,...a,...y};return this.startAxisValueAnimation(m,k)});return Promise.all(f).then(c)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return SC(this.visualElement,t),r.start(MT(t,r,0,n,this.visualElement,!1))}stopAnimation(){uu(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps(),i=r[n];return i||this.visualElement.getValue(t,(r.initial?r.initial[t]:void 0)||0)}snapToCursor(t){uu(n=>{const{drag:r}=this.getProps();if(!Av(n,r,this.currentDirection))return;const{projection:i}=this.visualElement,a=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:c}=i.layout.layoutBox[n],h=a.get()||0;a.set(t[n]-gs(o,c,.5)+h)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!w0(n)||!r||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};uu(o=>{const c=this.getAxisMotionValue(o);if(c&&this.constraints!==!1){const h=c.get();i[o]=s1e({min:h,max:h},this.constraints[o])}});const{transformTemplate:a}=this.visualElement.getProps();this.visualElement.current.style.transform=a?a({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.constraints=!1,this.resolveConstraints(),uu(o=>{if(!Av(o,t,null))return;const c=this.getAxisMotionValue(o),{min:h,max:f}=this.constraints[o];c.set(gs(h,f,i[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;l1e.set(this.visualElement,this);const t=this.visualElement.current,n=k1(t,"pointerdown",f=>{const{drag:m,dragListener:y=!0}=this.getProps(),w=f.target,A=w!==t&&F0e(w);m&&y&&!A&&this.start(f)});let r;const i=()=>{const{dragConstraints:f}=this.getProps();w0(f)&&f.current&&(this.constraints=this.resolveRefConstraints(),r||(r=u1e(t,f.current,()=>this.scalePositionWithinConstraints())))},{projection:a}=this.visualElement,o=a.addEventListener("measure",i);a&&!a.layout&&(a.root&&a.root.updateScroll(),a.updateLayout()),ts.read(i);const c=ey(window,"resize",()=>this.scalePositionWithinConstraints()),h=a.addEventListener("didUpdate",(({delta:f,hasLayoutChanged:m})=>{this.isDragging&&m&&(uu(y=>{const w=this.getAxisMotionValue(y);w&&(this.originPoint[y]+=f[y].translate,w.set(w.get()+f[y].translate))}),this.visualElement.render())}));return()=>{c(),n(),o(),h&&h(),r&&r()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:i=!1,dragConstraints:a=!1,dragElastic:o=DC,dragMomentum:c=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:i,dragConstraints:a,dragElastic:o,dragMomentum:c}}}function NM(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function u1e(e,t,n){const r=I8(e,NM(n)),i=I8(t,NM(n));return()=>{r(),i()}}function Av(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function d1e(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class h1e extends Cf{constructor(t){super(t),this.removeGroupControls=uc,this.removeListeners=uc,this.controls=new c1e(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||uc}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const dS=e=>(t,n)=>{e&&ts.update(()=>e(t,n),!1,!0)};class f1e extends Cf{constructor(){super(...arguments),this.removePointerDownListener=uc}onPointerDown(t){this.session=new WW(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:qW(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:i}=this.node.getProps();return{onSessionStart:dS(t),onStart:dS(n),onMove:dS(r),onEnd:(a,o)=>{delete this.session,i&&ts.postRender(()=>i(a,o))}}}mount(){this.removePointerDownListener=k1(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let hS=!1;class p1e extends j.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:i}=this.props,{projection:a}=t;a&&(n.group&&n.group.add(a),r&&r.register&&i&&r.register(a),hS&&a.root.didUpdate(),a.addEventListener("animationComplete",()=>{this.safeToRemove()}),a.setOptions({...a.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),_w.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:i,isPresent:a}=this.props,{projection:o}=r;return o&&(o.isPresent=a,t.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),hS=!0,i||t.layoutDependency!==n||n===void 0||t.isPresent!==a?o.willUpdate():this.safeToRemove(),t.isPresent!==a&&(a?o.promote():o.relegate()||ts.postRender(()=>{const c=o.getStack();(!c||!c.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:r}=t;r&&(r.options.layoutAnchor=n,r.root.didUpdate(),zT.postRender(()=>{!r.currentAnimation&&r.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:i}=t;hS=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),r&&r.deregister&&r.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function YW(e){const[t,n]=LW(),r=j.useContext(wT);return s.jsx(p1e,{...e,layoutGroup:r,switchLayoutGroup:j.useContext(HW),isPresent:t,safeToRemove:n})}const m1e={pan:{Feature:f1e},drag:{Feature:h1e,ProjectionNode:MW,MeasureLayout:YW}};function EM(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,a=r[i];a&&ts.postRender(()=>a(t,By(t)))}class g1e extends Cf{mount(){const{current:t}=this.node;t&&(this.unmount=U0e(t,(n,r)=>(EM(this.node,r,"Start"),i=>EM(this.node,i,"End"))))}unmount(){}}class x1e extends Cf{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!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=My(ey(this.node.current,"focus",()=>this.onFocus()),ey(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function AM(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),a=r[i];a&&ts.postRender(()=>a(t,By(t)))}class y1e extends Cf{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:r}=this.node.props;this.unmount=H0e(t,(i,a)=>(AM(this.node,a,"Start"),(o,{success:c})=>AM(this.node,o,c?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(r==null?void 0:r.tap)===!1})}unmount(){}}const MC=new WeakMap,fS=new WeakMap,b1e=e=>{const t=MC.get(e.target);t&&t(e)},v1e=e=>{e.forEach(b1e)};function w1e({root:e,...t}){const n=e||document;fS.has(n)||fS.set(n,{});const r=fS.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(v1e,{root:e,...t})),r[i]}function N1e(e,t,n){const r=w1e(t);return MC.set(e,n),r.observe(e),()=>{MC.delete(e),r.unobserve(e)}}const E1e={some:0,all:1};class A1e extends Cf{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var h;(h=this.stopObserver)==null||h.call(this);const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:i="some",once:a}=t,o={root:n?n.current:void 0,rootMargin:r,threshold:typeof i=="number"?i:E1e[i]},c=f=>{const{isIntersecting:m}=f;if(this.isInView===m||(this.isInView=m,a&&!m&&this.hasEnteredView))return;m&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",m);const{onViewportEnter:y,onViewportLeave:w}=this.node.getProps(),A=m?y:w;A&&A(f)};this.stopObserver=N1e(this.node.current,o,c)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(_1e(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function _1e({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const S1e={inView:{Feature:A1e},tap:{Feature:y1e},focus:{Feature:x1e},hover:{Feature:g1e}},k1e={layout:{ProjectionNode:MW,MeasureLayout:YW}},C1e={...Qxe,...S1e,...m1e,...k1e},Kt=qxe(C1e,Wxe),XW=({isOpen:e,imagesList:t=[],initialIndex:n=0,imageUrl:r,title:i,onClose:a})=>{const[o,c]=j.useState(n),h=t.length>0?t:r?[r]:[];j.useEffect(()=>{e&&c(n)},[e,n]);const f=h[o]||r||"",m=async A=>{A.stopPropagation();try{sr.loading("Preparing image for download...",{id:"download-prep"});const k=`/api/proxy-image?url=${encodeURIComponent(f)}`,I=await fetch(k);if(!I.ok)throw new Error("Proxy image download failed");const T=await I.blob(),D=window.URL.createObjectURL(T),F=document.createElement("a");F.href=D,F.download=`${i.toLowerCase().replace(/[^a-z0-9]/g,"-")||"campus-eye-image"}-${o+1}.jpg`,document.body.appendChild(F),F.click(),document.body.removeChild(F),window.URL.revokeObjectURL(D),sr.success("Download started successfully!",{id:"download-prep"})}catch(k){console.warn("Proxy download failed, trying standard open in new tab...",k);try{const I=document.createElement("a");I.href=f,I.target="_blank",I.rel="noopener noreferrer",I.download=`${i||"image"}-${o+1}.jpg`,document.body.appendChild(I),I.click(),document.body.removeChild(I),sr.success("Opening original in new tab...",{id:"download-prep"})}catch{sr.error("Could not download image, please save manually.",{id:"download-prep"})}}},y=A=>{A==null||A.stopPropagation(),h.length>1&&c(k=>k===0?h.length-1:k-1)},w=A=>{A==null||A.stopPropagation(),h.length>1&&c(k=>k===h.length-1?0:k+1)};return j.useEffect(()=>{const A=k=>{e&&(k.key==="ArrowLeft"?y():k.key==="ArrowRight"?w():k.key==="Escape"&&a())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[e,h.length]),s.jsx(ar,{children:e&&s.jsxs(Kt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[5000] bg-black/95 backdrop-blur-xl flex flex-col justify-between p-4",onClick:a,children:[s.jsxs("div",{className:"w-full h-14 flex items-center justify-between px-2 max-w-7xl mx-auto z-50",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase tracking-widest text-gray-400 truncate max-w-xs sm:max-w-md",children:["👁️ Photo Desk • ",i," ",h.length>1&&`(${o+1} of ${h.length})`]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("button",{onClick:m,className:"flex items-center gap-1.5 px-3 py-1.5 bg-white/10 hover:bg-white/25 active:bg-white/30 text-white border border-white/10 hover:border-white/20 rounded-full text-[10px] font-black uppercase tracking-widest transition-all cursor-pointer shadow-lg",title:"Download high resolution copy",children:[s.jsx(IN,{size:13}),s.jsx("span",{children:"Download"})]}),s.jsx("button",{onClick:A=>{A.stopPropagation(),a()},className:"w-9 h-9 bg-red-650 hover:bg-black text-white rounded-full flex items-center justify-center transition-all cursor-pointer shadow-lg border border-red-500/20",title:"Exit lightbox view",children:s.jsx(er,{size:16})})]})]}),s.jsxs("div",{className:"flex-1 flex items-center justify-center relative p-2 md:p-6 w-full max-w-5xl mx-auto select-none gap-4",children:[h.length>1&&s.jsx("button",{type:"button",onClick:y,className:"w-10 h-10 rounded-full bg-black/50 border border-white/15 hover:bg-white/20 hover:border-white/40 text-white flex items-center justify-center transition-all cursor-pointer hidden md:flex shrink-0",children:s.jsx(Vp,{size:20})}),s.jsxs("div",{className:"relative flex-1 flex justify-center max-w-full",children:[s.jsx(Kt.img,{initial:{opacity:0,scale:.95,y:15},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:15},transition:{type:"spring",damping:25},src:f,alt:i,className:"max-w-full max-h-[75vh] object-contain rounded-xl shadow-2.5xl ring-1 ring-white/15 cursor-zoom-out",onClick:A=>{A.stopPropagation(),a()},referrerPolicy:"no-referrer"},o),h.length>1&&s.jsxs("div",{className:"absolute inset-y-0 inset-x-0 flex justify-between items-center pointer-events-none md:hidden",children:[s.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),y(A)},className:"w-12 h-12 rounded-r-full bg-black/40 text-white flex items-center justify-start pl-2 pointer-events-auto",children:s.jsx(Vp,{size:18})}),s.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),w(A)},className:"w-12 h-12 rounded-l-full bg-black/40 text-white flex items-center justify-end pr-2 pointer-events-auto",children:s.jsx(Fp,{size:18})})]})]}),h.length>1&&s.jsx("button",{type:"button",onClick:w,className:"w-10 h-10 rounded-full bg-black/50 border border-white/15 hover:bg-white/20 hover:border-white/40 text-white flex items-center justify-center transition-all cursor-pointer hidden md:flex shrink-0",children:s.jsx(Fp,{size:20})})]}),s.jsx("div",{className:"w-full text-center py-4 z-50",children:s.jsx("p",{className:"text-[9px] font-medium text-gray-400 uppercase tracking-widest mb-1",children:h.length>1?"Use ← and → keys or tap arrows to navigate":"Click anywhere on the background or tap X to return"})})]})})},I1e=[{index:1,emoji:"🔥",label:"Lit"},{index:2,emoji:"🤯",label:"Shocked"},{index:3,emoji:"😢",label:"Sad"},{index:4,emoji:"👏",label:"Solid"},{index:5,emoji:"❤️",label:"Love"},{index:6,emoji:"😂",label:"Funny"},{index:7,emoji:"👍",label:"Like"}],Vi=({src:e,alt:t="",className:n="",priority:r=!1,title:i="",fallbackInitial:a="",...o})=>{const[c,h]=j.useState(()=>r),[f,m]=j.useState(!1),[y,w]=j.useState(0),A=se.useRef(null);j.useEffect(()=>{var D,F;m(!1),w(0),(D=A.current)!=null&&D.complete&&((F=A.current)==null?void 0:F.naturalWidth)!==0?h(!0):h(r)},[e,r]);const I=(a||i||t||"Campus").trim().charAt(0).toUpperCase()||"C",T=e?_pe(e,r?900:650,80):"";return s.jsxs("div",{className:Ge("relative overflow-hidden bg-gradient-to-br from-neutral-900 via-slate-900 to-indigo-950 flex items-center justify-center w-full h-full min-h-[50px] select-none",n),children:[(!c||f||!e)&&s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-2 z-10 pointer-events-none transition-opacity duration-300",children:[s.jsx("div",{className:"w-9 h-9 sm:w-11 sm:h-11 rounded-2xl bg-white/10 backdrop-blur-md border border-white/20 flex items-center justify-center text-white font-serif font-black text-lg sm:text-xl shadow-md",children:I}),(i||t)&&s.jsx("span",{className:"text-[8px] sm:text-[9px] font-bold text-gray-300 uppercase tracking-widest mt-1.5 px-3 text-center line-clamp-1 opacity-75 max-w-[85%]",children:i||t})]}),T&&!f&&s.jsx("img",{ref:A,src:T,alt:t||i,onLoad:()=>h(!0),onError:()=>{y<1?w(D=>D+1):(m(!0),h(!0))},loading:r?"eager":"lazy",decoding:"async",...r?{fetchPriority:"high"}:{},className:Ge("w-full h-full object-cover transition-all duration-500 transform-gpu relative z-20",c?"opacity-100 blur-none scale-100":"opacity-90 blur-[3px] scale-102"),referrerPolicy:"no-referrer",...o})]})},pS=({article:e,onClick:t,variant:n="social",onAuthorClick:r,priority:i=!1})=>{var sn,pn,Fn;const[a,o]=j.useState(!1),[c,h]=j.useState([]),[f,m]=j.useState(""),[y,w]=j.useState(!1),[A,k]=j.useState(!1),[I,T]=j.useState(e.likeCount||0),[D,F]=j.useState(e.commentCount||0),[L,q]=j.useState(e.viewCount||0),[Z,K]=j.useState(e.saveCount||0),[z,B]=j.useState(e.shareCount||0),[V,$]=j.useState(!1),[Q,Y]=j.useState(!1),[G,he]=j.useState(null),[te,le]=j.useState({}),[ve,ke]=j.useState(0),[Be,J]=j.useState(!1),[ie,xe]=j.useState(!1),[ae,Fe]=j.useState(null),pt=[e.featuredImageUrl,e.featuredImageUrl1,e.featuredImageUrl2].filter(Boolean);j.useEffect(()=>{T(e.likeCount||0),F(e.commentCount||0),q(e.viewCount||0),K(e.saveCount||0),B(e.shareCount||0);const Ft={};for(let Dt=1;Dt<=7;Dt++){const Ht=`reaction${Dt}`;e[Ht]&&(Ft[`reaction${Dt}`]=e[Ht])}if(le(Ft),Ne.currentUser){const Dt=`reacted_${e.id}_${Ne.currentUser.uid}`,Ht=localStorage.getItem(Dt);he(Ht?parseInt(Ht):null)}},[e,Ne.currentUser]);const Ue=async Ft=>{if(!Ne.currentUser){sr.error("Please login to react to this story"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{Ue(Ft)});return}const Dt=ot(pe,"articles",e.id),Ht=`reacted_${e.id}_${Ne.currentUser.uid}`,Ze=localStorage.getItem(Ht),Wt=Ze?parseInt(Ze):null;try{const It={},ln=["🔥","🤯","😢","👏","❤️","😂","👍"],Kn=ln[Ft-1];Wt===Ft?(It[`reaction${Ft}.count`]=Ur(-1),It[`reaction${Ft}.emoji`]=Kn,localStorage.removeItem(Ht),he(null)):(Wt!==null&&(It[`reaction${Wt}.count`]=Ur(-1),It[`reaction${Wt}.emoji`]=ln[Wt-1]),It[`reaction${Ft}.count`]=Ur(1),It[`reaction${Ft}.emoji`]=Kn,localStorage.setItem(Ht,Ft.toString()),he(Ft)),await Hn(Dt,It),sr.success("Reaction updated!")}catch(It){console.error("Error updating reaction:",It)}};j.useEffect(()=>{if(Ne.currentUser){const Ft=`liked_${e.id}_${Ne.currentUser.uid}`,Dt=localStorage.getItem(Ft);if(Dt!==null)w(Dt==="true");else{const Ze=ot(pe,"articles",e.id,"likes",Ne.currentUser.uid);cs(Ze).then(Wt=>{const It=Wt.exists();w(It);try{localStorage.setItem(Ft,It?"true":"false")}catch{}}).catch(()=>{})}const Ht=`saved_${e.id}_${Ne.currentUser.uid}`;k(localStorage.getItem(Ht)==="true")}},[e.id,Ne.currentUser]),j.useEffect(()=>{if(!a)return;const Ft=Qt(it(pe,"articles",e.id,"comments"),pi("createdAt","desc"),Pi(20)),Dt=di(Ft,Ht=>{const Ze=Ht.docs.map(Wt=>({id:Wt.id,...Wt.data()}));h(Ze),Ze.length>0&&F(Ze.length)},Ht=>{console.warn("Silent ignored comments fetch error for article",Ht)});return()=>Dt()},[e.id,a]);const Ct=async Ft=>{if(Ft.stopPropagation(),!Ne.currentUser){sr.error("Please sign in to solidarily support this dispatch!"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{Ct({stopPropagation:()=>{}})});return}const Dt=ot(pe,"articles",e.id,"likes",Ne.currentUser.uid),Ht=ot(pe,"articles",e.id),Ze=`liked_${e.id}_${Ne.currentUser.uid}`;try{if(y){w(!1),T(Wt=>Math.max(0,Wt-1));try{localStorage.setItem(Ze,"false")}catch{}await ni(Dt),await Hn(Ht,{likeCount:Ur(-1)})}else{w(!0),T(Wt=>Wt+1);try{localStorage.setItem(Ze,"true")}catch{}await Hr(Dt,{userId:Ne.currentUser.uid,createdAt:Bn()}),await Hn(Ht,{likeCount:Ur(1)}),sr.success("Solidarity registered!")}}catch(Wt){console.error("Error liking article:",Wt)}},Tt=async Ft=>{if(Ft.stopPropagation(),!Ne.currentUser){sr.error("Please sign in to bookmark dispatches!"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{Tt({stopPropagation:()=>{}})});return}const Dt=ot(pe,"articles",e.id),Ht=`saved_${e.id}_${Ne.currentUser.uid}`,Ze=A;try{Ze?(k(!1),K(Wt=>Math.max(0,Wt-1)),localStorage.removeItem(Ht),await Hn(Dt,{saveCount:Ur(-1)}),sr.success("Successfully unbookmarked")):(k(!0),K(Wt=>Wt+1),localStorage.setItem(Ht,"true"),await Hn(Dt,{saveCount:Ur(1)}),sr.success("Secured in Bookmarks!"))}catch(Wt){console.error("Error saving article:",Wt)}},ht=async Ft=>{Ft.stopPropagation();const Dt=e.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),Ht=`${window.location.origin}/articles=${Dt}/${e.id}`,Ze=e.title,Wt=e.summary||(e.content?e.content.substring(0,140)+"...":""),It=`${e.title} ${Wt} Read More: ${Ht}`,ln=[e.featuredImageUrl,e.featuredImageUrl1,e.featuredImageUrl2,e.imageUrl].find(un=>un&&typeof un=="string"&&!un.startsWith("data:")&&un.length>5)||"";try{fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:Ht,title:Ze,image:ln})}).catch(()=>{})}catch{}let Kn=!1;if(navigator.share)try{const un={title:Ze,text:`${e.title} ${Wt}`,url:Ht};await navigator.share(un),Kn=!0;const xr=ot(pe,"articles",e.id);await Hn(xr,{shareCount:Ur(1)}).catch(()=>{});return}catch(un){console.warn("Shared sheet native cancel or fail:",un)}if(!Kn){try{await Pd(It);const un=ot(pe,"articles",e.id);await Hn(un,{shareCount:Ur(1)}).catch(()=>{})}catch{}xe(!0)}},Ye=async Ft=>{var Dt,Ht;if(Ft.preventDefault(),!!f.trim()){if(!Ne.currentUser){sr.error("Please sign in to publish your thoughts."),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{Ye({preventDefault:()=>{}})});return}$(!0);try{const Ze=ae?ae.parentId||ae.id:null,Wt=ae?ae.authorName:null,It={content:f,userId:Ne.currentUser.uid,authorName:Ne.currentUser.displayName||"Campus Member",photoURL:Ne.currentUser.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Ne.currentUser.displayName||"Member")}`,createdAt:new Date,parentId:Ze,replyToAuthor:Wt},ln=await ur(it(pe,"articles",e.id,"comments"),{content:f,userId:Ne.currentUser.uid,authorName:Ne.currentUser.displayName||"Campus Member",photoURL:Ne.currentUser.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Ne.currentUser.displayName||"Member")}`,createdAt:Bn(),parentId:Ze,replyToAuthor:Wt});h(xr=>[{id:ln.id,...It},...xr]),F(xr=>xr+1);const Kn=ot(pe,"articles",e.id);await Hn(Kn,{commentCount:Ur(1)});const un=f;m(""),Fe(null),sr.success("Thought dispatched!"),/@(mega\s*(ai)?|me)\b/i.test(un)&&h2(un,((Dt=Ne.currentUser)==null?void 0:Dt.displayName)||"Campus Member",((Ht=Ne.currentUser)==null?void 0:Ht.uid)||"guest",{type:"article_comment",articleId:e.id}).then(async xr=>{var Ve;if(xr){const Ot=await ur(it(pe,"articles",e.id,"comments"),{content:xr,userId:"mega-ai-bot",authorName:"Mega AI 🤖",photoURL:Vo,createdAt:Bn(),parentId:Ze,replyToAuthor:((Ve=Ne.currentUser)==null?void 0:Ve.displayName)||"Campus Member"});h(nn=>{var mn;return[...nn,{id:Ot.id,content:xr,userId:"mega-ai-bot",authorName:"Mega AI 🤖",photoURL:Vo,createdAt:new Date,parentId:Ze,replyToAuthor:((mn=Ne.currentUser)==null?void 0:mn.displayName)||"Campus Member"}]}),F(nn=>nn+1),await Hn(ot(pe,"articles",e.id),{commentCount:Ur(1)}),sr.success("Mega AI auto-replied to your commentary!",{icon:"✨"})}}).catch(xr=>console.error("Mega AI auto reply error:",xr))}catch(Ze){console.error("Comment submission error:",Ze)}finally{$(!1)}}},Yt=()=>{var Ze,Wt,It;const Ft=e.isSponsoredAd||((Ze=e.category)==null?void 0:Ze.toLowerCase().includes("ad"))||((Wt=e.category)==null?void 0:Wt.toLowerCase().includes("sponsor"))||((It=e.category)==null?void 0:It.toLowerCase().includes("promote")),Dt=[];if(e.featuredImageUrl&&Dt.push(e.featuredImageUrl),e.featuredImageUrl1&&Dt.push(e.featuredImageUrl1),e.featuredImageUrl2&&Dt.push(e.featuredImageUrl2),Dt.length===0)return null;const Ht=Ft&&s.jsx("div",{className:"absolute top-2.5 left-2.5 bg-black/85 backdrop-blur-md text-[#FF2D55] text-[7.5px] font-black uppercase tracking-widest px-3 py-1 rounded-md border border-red-500/20 flex items-center gap-1 z-10 pointer-events-none shadow-lg",children:"📢 SPONSORED AD"});return Dt.length===3?s.jsxs("div",{className:"relative group/ad w-full select-none",onClick:ln=>ln.stopPropagation(),children:[Ht,s.jsxs("div",{className:"flex gap-1 rounded-2xl overflow-hidden border border-gray-150 aspect-[16/10] w-full bg-gray-50",children:[s.jsx("div",{onClick:ln=>{ln.preventDefault(),ke(0),J(!0)},className:"w-[60%] overflow-hidden relative group/img cursor-pointer h-full",children:s.jsx(Vi,{src:Dt[0],alt:"Support View 1",priority:i,className:"w-full h-full object-cover transition-transform duration-500 hover:scale-[1.03]"})}),s.jsxs("div",{className:"w-[40%] flex flex-col gap-1 h-full",children:[s.jsx("div",{onClick:ln=>{ln.preventDefault(),ke(1),J(!0)},className:"h-[calc(50%-2px)] overflow-hidden relative group/img cursor-pointer",children:s.jsx(Vi,{src:Dt[1],alt:"Support View 2",priority:i,className:"w-full h-full object-cover transition-transform duration-500 hover:scale-[1.03]"})}),s.jsx("div",{onClick:ln=>{ln.preventDefault(),ke(2),J(!0)},className:"h-[calc(50%-2px)] overflow-hidden relative group/img cursor-pointer",children:s.jsx(Vi,{src:Dt[2],alt:"Support View 3",priority:i,className:"w-full h-full object-cover transition-transform duration-500 hover:scale-[1.03]"})})]})]})]}):Dt.length===2?s.jsxs("div",{className:"relative group/ad w-full select-none",onClick:ln=>ln.stopPropagation(),children:[Ht,s.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-2xl overflow-hidden border border-gray-150 aspect-[16/10] sm:aspect-[16/9] w-full bg-gray-50",children:Dt.map((ln,Kn)=>s.jsx("div",{className:"overflow-hidden relative group/img cursor-pointer h-full w-full",onClick:un=>{un.preventDefault(),ke(Kn),J(!0)},children:s.jsx(Vi,{src:ln,alt:`Support View ${Kn+1}`,priority:i,className:"w-full h-full object-cover transition-transform duration-500 hover:scale-[1.03]"})},Kn))})]}):s.jsxs("div",{className:"relative group/ad w-full select-none",onClick:ln=>ln.stopPropagation(),children:[Ht,s.jsx("div",{onClick:ln=>{ln.preventDefault(),ke(0),J(!0)},className:"rounded-xl overflow-hidden border border-gray-150/70 w-full bg-gray-50 flex items-center justify-center relative group/img cursor-pointer shadow-2xs",children:s.jsx(Vi,{src:e.featuredImageUrl,alt:e.title,priority:i,className:"w-full h-auto max-h-[42rem] object-cover transition-transform duration-500 hover:scale-[1.02]"})})]})},dt=Ft=>s.jsxs(s.Fragment,{children:[Ft,s.jsx(XW,{isOpen:Be,imagesList:pt,initialIndex:ve,imageUrl:pt[ve]||"",title:e.title,onClose:()=>J(!1)}),ie&&s.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-md z-[200] flex items-end sm:items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200",onClick:Dt=>{Dt.stopPropagation(),xe(!1)},children:s.jsxs("div",{className:"bg-white/95 dark:bg-neutral-900/95 backdrop-blur-2xl border border-gray-200/80 dark:border-white/10 rounded-3xl p-5 sm:p-6 w-full max-w-sm shadow-2xl space-y-4 text-center relative animate-in slide-in-from-bottom-5 duration-200",onClick:Dt=>Dt.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 dark:border-neutral-800 pb-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-left",children:[s.jsx("div",{className:"p-2 bg-red-50 text-red-650 rounded-full",children:s.jsx(df,{size:16})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-bold text-gray-900 dark:text-white",children:"Share Dispatch"}),s.jsx("p",{className:"text-[10px] text-gray-500 lowercase tracking-tight",children:"Choose your preferred social platform"})]})]}),s.jsx("button",{onClick:()=>xe(!1),className:"p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-full transition-all cursor-pointer",children:s.jsx(er,{size:18})})]}),s.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-neutral-800/60 rounded-2xl border border-gray-100 dark:border-neutral-700/50 text-left space-y-1",children:[s.jsx("p",{className:"text-[11px] font-extrabold text-gray-900 dark:text-white line-clamp-1",children:e.title}),s.jsx("p",{className:"text-[9px] text-gray-500 font-mono truncate",children:`${window.location.origin}/article/${e.id}`})]}),s.jsxs("div",{className:"grid grid-cols-4 gap-2 pt-1",children:[s.jsxs("a",{href:`https://api.whatsapp.com/send?text=${encodeURIComponent(e.title+` Read more: ${window.location.origin}/article/${e.id}`)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>xe(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-emerald-50 text-emerald-700 rounded-2xl hover:bg-emerald-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"💬"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"WhatsApp"})]}),s.jsxs("a",{href:`https://twitter.com/intent/tweet?text=${encodeURIComponent(e.title)}&url=${encodeURIComponent(`${window.location.origin}/article/${e.id}`)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>xe(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-sky-50 text-sky-700 rounded-2xl hover:bg-sky-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"🐦"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"Twitter/X"})]}),s.jsxs("a",{href:`https://t.me/share/url?url=${encodeURIComponent(`${window.location.origin}/article/${e.id}`)}&text=${encodeURIComponent(e.title)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>xe(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-blue-50 text-blue-700 rounded-2xl hover:bg-blue-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"✈️"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"Telegram"})]}),s.jsxs("a",{href:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(`${window.location.origin}/article/${e.id}`)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>xe(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-indigo-50 text-indigo-700 rounded-2xl hover:bg-indigo-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"📘"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"Facebook"})]})]}),s.jsx("div",{className:"pt-2",children:s.jsx("button",{onClick:async()=>{const Dt=`${window.location.origin}/article/${e.id}`;await Pd(`${e.title} ${Dt}`),sr.success("Link copied to clipboard!"),xe(!1)},className:"w-full py-3 bg-red-650 hover:bg-red-700 text-white font-bold text-xs uppercase tracking-widest rounded-2xl transition-all shadow-md active:scale-98 flex items-center justify-center gap-2 cursor-pointer",children:s.jsx("span",{children:"Copy Direct Link"})})})]})})]});if(n==="social"){const Ft=Object.values(te).filter(Ze=>Ze&&Ze.count>0),Dt=Ft.reduce((Ze,Wt)=>Ze+Wt.count,0),Ht=e.isSponsoredAd||((sn=e.category)==null?void 0:sn.toLowerCase().includes("ad"))||((pn=e.category)==null?void 0:pn.toLowerCase().includes("sponsor"))||((Fn=e.category)==null?void 0:Fn.toLowerCase().includes("promote"));return dt(s.jsx("div",{className:Ge("border-b border-gray-100 p-2 sm:p-4 md:p-6 text-left hover:bg-gray-50/50 transition-colors duration-300",Ht?"bg-amber-50/20 border-l-4 border-l-amber-500":"bg-white"),children:s.jsxs("div",{className:"flex gap-3 md:gap-4",children:[s.jsx("div",{onClick:Ze=>{r&&e.authorId&&(Ze.stopPropagation(),r(e.authorId))},onMouseEnter:Ze=>{r&&e.authorId&&window.matchMedia("(min-width: 1024px)").matches&&r(e.authorId)},className:Ge("w-8 h-8 md:w-9 md:h-9 rounded-full overflow-hidden border border-gray-150 shrink-0",r&&"cursor-pointer hover:opacity-80 hover:scale-105 active:scale-95 transition-all"),title:"Click or hover to view peer credentials",children:s.jsx(Vi,{src:e.authorProfile||`https://ui-avatars.com/api/?name=${encodeURIComponent(e.authorName)}&background=random`,className:"w-full h-full object-cover",alt:e.authorName})}),s.jsxs("div",{className:"flex-1 space-y-2.5 min-w-0",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-wrap",children:[s.jsx("span",{className:"text-gray-400 font-bold text-xs",children:"@"}),s.jsx("span",{className:Ge("font-bold text-xs text-black hover:underline cursor-pointer tracking-tight",r?"hover:text-red-650":""),onClick:Ze=>{r&&e.authorId?(Ze.stopPropagation(),r(e.authorId)):t(e)},onMouseEnter:Ze=>{r&&e.authorId&&window.matchMedia("(min-width: 1024px)").matches&&r(e.authorId)},title:"Click or hover to view peer credentials",children:e.authorName&&e.authorName.includes("@")?e.authorName.split("@")[0]:e.authorName}),s.jsx(Ll,{size:12,className:"shrink-0"}),s.jsx("span",{className:"text-[10px] font-bold text-gray-400",children:"•"}),s.jsx("span",{className:Ge("text-[8px] font-black tracking-[0.14em] uppercase shrink-0",Ht?"text-amber-600 bg-amber-50 px-1.5 py-0.5 rounded border border-amber-200":"text-red-650"),children:Ht?"SPONSORED PROMO":e.category}),e.publishDate&&s.jsxs("span",{className:"text-[9.5px] font-bold text-gray-500 font-mono flex items-center gap-1 shrink-0 bg-gray-50 px-1.5 py-0.5 rounded border border-gray-150",children:[s.jsx(H0,{size:10,className:"text-red-600"}),s.jsx("span",{children:gw(e.publishDate)})]}),e.isOfflineCached&&s.jsx("span",{className:"text-teal-600 bg-teal-50 p-1 rounded-full border border-teal-200 shrink-0 flex items-center justify-center cursor-help",title:"Offline Cached",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"shrink-0 w-3 h-3",children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsx("path",{fill:"currentColor",d:"M12.05 20q-3.35 0-5.7-2.325T4 12v-.175l-1.6 1.6l-1.4-1.4l4-4l4 4l-1.4 1.4l-1.6-1.6V12q0 2.5 1.763 4.25T12.05 18q.65 0 1.275-.15t1.225-.45l1.5 1.5q-.95.55-1.95.825T12.05 20M19 15.975l-4-4l1.4-1.4l1.6 1.6V12q0-2.5-1.763-4.25T11.95 6q-.65 0-1.275.15T9.45 6.6l-1.5-1.5q.95-.55 1.95-.825T11.95 4q3.35 0 5.7 2.325T20 12v.175l1.6-1.6l1.4 1.4z"})]})})]})}),s.jsx("h4",{onClick:()=>t(e),className:"text-base md:text-lg font-black text-black hover:text-red-600 transition-colors tracking-tight leading-snug cursor-pointer select-none line-clamp-2 underline underline-offset-2 decoration-1 hover:decoration-2",children:A0(e.title)}),s.jsxs("div",{className:"text-[13px] md:text-sm text-gray-800 leading-relaxed font-sans text-left speak-normal hyphens-auto",children:[s.jsxs("span",{children:[(e.summary||e.content).substring(0,80),"..."]}),s.jsx("button",{onClick:()=>t(e),className:"text-red-600 hover:text-red-700 font-extrabold ml-1.5 hover:underline text-[11px] uppercase inline-block font-sans",children:"Read More"})]}),(e.ctaUrl||e.Links&&e.Links.trim())&&s.jsx("div",{className:"pt-1 text-left",children:s.jsxs("button",{onClick:Ze=>{Ze.stopPropagation();const Wt=e.ctaUrl||e.Links.trim();window.open(Wt,"_blank","noopener,noreferrer")},className:"inline-flex items-center gap-1.5 px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-[9.5px] font-black uppercase tracking-wider rounded-lg transition-all active:scale-95 shadow-xs cursor-pointer select-none mt-1",children:[s.jsx("span",{children:e.ctaText||"Discover More"}),s.jsx(Va,{size:10,strokeWidth:3})]})}),Yt(),s.jsxs("div",{className:"flex items-center justify-between pt-2 max-w-md text-gray-500 text-[11px] font-bold select-none border-t border-gray-50 mt-4",children:[s.jsxs("button",{onClick:Ze=>{Ze.stopPropagation(),o(!a)},className:Ge("flex items-center gap-2 hover:text-blue-600 group transition-all p-1.5 -m-1.5 rounded-full hover:bg-blue-50/50 cursor-pointer",a&&"text-blue-600"),children:[s.jsx("div",{className:"w-7 h-7 flex items-center justify-center rounded-full group-hover:bg-blue-100/50 transition-colors",children:s.jsx(uC,{size:15,className:a?"fill-blue-500 text-blue-500":""})}),s.jsx("span",{children:Tc(D)})]}),s.jsxs("div",{className:"relative flex items-center gap-1",children:[s.jsxs("button",{onClick:Ct,className:Ge("flex items-center gap-2 group transition-all p-1.5 -m-1.5 rounded-full hover:bg-gray-50/50 cursor-pointer",y?"text-blue-600 font-extrabold":"text-gray-500 hover:text-blue-600"),title:"Solidarity support",children:[s.jsx("div",{className:"w-7 h-7 flex items-center justify-center rounded-full transition-transform group-hover:scale-115",children:s.jsx(lq,{size:15,className:y?"fill-blue-600 text-blue-600":"text-gray-500"})}),s.jsx("span",{children:Tc(I)})]}),Ft.length>0&&s.jsxs("div",{className:"flex items-center gap-0.5 bg-gray-100/80 px-2 py-0.5 rounded-full border border-gray-250 text-[10px] text-gray-650 font-bold ml-1.5 shrink-0 select-none",children:[s.jsx("span",{className:"flex -space-x-1 font-sans",children:Ft.slice(0,3).map((Ze,Wt)=>s.jsx("span",{className:"scale-90",children:Ze.emoji},Wt))}),s.jsx("span",{className:"ml-1 text-[9px] font-black",children:Dt})]}),s.jsx(ar,{children:Q&&s.jsx(Kt.div,{initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},className:"absolute bottom-10 left-0 bg-white border border-gray-150 p-1.5 shadow-2xl flex gap-1.5 z-50 rounded-full",onClick:Ze=>Ze.stopPropagation(),children:I1e.map(Ze=>s.jsx("button",{onClick:()=>{Ue(Ze.index),Y(!1)},className:Ge("w-7.5 h-7.5 rounded-full flex items-center justify-center hover:scale-130 hover:bg-red-50 transition-all text-sm",G===Ze.index&&"bg-red-50 text-base"),title:Ze.label,children:Ze.emoji},Ze.index))})})]}),s.jsxs("div",{className:"flex items-center gap-2 transition-all p-1.5 -m-1.5",children:[s.jsx("div",{className:"w-7 h-7 flex items-center justify-center",children:s.jsx(a8,{size:15})}),s.jsx("span",{children:Tc(L)})]}),s.jsxs("button",{onClick:Tt,className:Ge("flex items-center gap-2 hover:text-yellow-600 group transition-all p-1.5 -m-1.5 rounded-full hover:bg-yellow-50/50",A&&"text-yellow-600"),children:[s.jsx("div",{className:"w-7 h-7 flex items-center justify-center rounded-full group-hover:bg-yellow-100/50 transition-colors",children:s.jsx(cq,{size:15,className:A?"fill-yellow-500 text-yellow-500":""})}),s.jsx("span",{children:Tc(Z)})]}),s.jsxs("button",{onClick:ht,className:"flex items-center gap-2 hover:text-green-600 group transition-all p-1.5 -m-1.5 rounded-full hover:bg-green-50/50",children:[s.jsx("div",{className:"w-7 h-7 flex items-center justify-center rounded-full group-hover:bg-green-100/50 transition-colors",children:s.jsx(dC,{size:15})}),s.jsx("span",{children:Tc(z)})]})]}),s.jsx(ar,{children:a&&s.jsxs(Kt.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"w-full bg-[#0f1419] text-white p-3.5 sm:p-4 rounded-2xl border border-gray-800 shadow-lg text-left overflow-hidden break-words min-w-0 mt-3",onClick:Ze=>Ze.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-1.5 h-3.5 bg-indigo-500 rounded-full"}),s.jsxs("span",{className:"text-[10px] font-black tracking-widest text-gray-200 uppercase",children:["Comments (",c.length,")"]})]}),s.jsx("button",{onClick:()=>o(!1),className:"text-gray-400 hover:text-white text-xs font-bold px-2 py-0.5 rounded-full hover:bg-gray-800",children:"✕"})]}),s.jsxs("form",{onSubmit:Ye,className:"space-y-2 mb-4",children:[ae&&s.jsxs("div",{className:"flex items-center justify-between bg-indigo-950/80 border border-indigo-500/40 px-3 py-1.5 rounded-xl text-xs text-indigo-200 font-bold animate-fade-in",children:[s.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[s.jsx("span",{className:"uppercase text-[9px] font-black tracking-widest text-indigo-400 shrink-0",children:"Replying to"}),s.jsxs("span",{className:"font-extrabold font-mono text-white text-[11px] truncate",children:["@",ae.authorName]})]}),s.jsx("button",{type:"button",onClick:()=>Fe(null),className:"text-gray-400 hover:text-red-400 font-extrabold text-xs px-1 rounded cursor-pointer shrink-0 ml-2",title:"Cancel reply",children:"✕"})]}),s.jsxs("div",{className:"flex gap-2 bg-[#15181c] border border-gray-800 rounded-full p-1 pl-4 items-center focus-within:border-indigo-500/50 transition-all",children:[s.jsx("input",{type:"text",placeholder:ae?`Replying to @${ae.authorName}...`:"Type comment or mention @Mega AI...",value:f,onChange:Ze=>m(Ze.target.value),className:"flex-1 bg-transparent text-white text-xs outline-none focus:outline-none placeholder-gray-500 border-none py-1.5 focus:ring-0"}),s.jsx("button",{type:"submit",disabled:V||!f.trim(),className:"bg-indigo-600 hover:bg-indigo-700 disabled:opacity-40 text-white font-extrabold uppercase px-3 h-7 rounded-full text-[9px] tracking-wider transition-colors shrink-0 cursor-pointer",children:"Reply"})]}),s.jsx("div",{className:"flex items-center gap-1.5 px-1",children:s.jsxs("button",{type:"button",onClick:()=>{f.includes("@Mega AI")||m(Ze=>(Ze.trim()+" @Mega AI ").trimStart())},className:"text-[9px] font-black uppercase tracking-wider text-amber-400 bg-amber-500/10 hover:bg-amber-500/20 border border-amber-500/30 px-2 py-0.5 rounded-full flex items-center gap-1 transition-all cursor-pointer",children:[s.jsx(es,{size:10,className:"text-amber-400"})," Mention @Mega AI"]})})]}),s.jsx("div",{className:"space-y-4 max-h-72 overflow-y-auto pr-1",children:c.length>0?(()=>{const Ze=ln=>({A:"bg-red-500",B:"bg-pink-500",C:"bg-purple-500",D:"bg-indigo-500",E:"bg-blue-500",F:"bg-cyan-500",G:"bg-teal-500",H:"bg-emerald-500",I:"bg-green-500",J:"bg-yellow-500",K:"bg-amber-500",L:"bg-orange-500",M:"bg-rose-500",N:"bg-red-600",O:"bg-indigo-600",P:"bg-purple-600",Q:"bg-pink-600",R:"bg-blue-600",S:"bg-violet-600",T:"bg-rose-600",U:"bg-teal-600",V:"bg-emerald-600",W:"bg-indigo-700",X:"bg-purple-700",Y:"bg-sky-500",Z:"bg-fuchsia-600"})[ln]||"bg-slate-600",Wt=async(ln,Kn)=>{if(!Ne.currentUser)return;const un=ot(pe,"articles",e.id,"comments",ln),xr=`liked_comment_${ln}_${Ne.currentUser.uid}`;localStorage.getItem(xr)==="true"?(await Hn(un,{likeCount:Ur(-1)}),localStorage.removeItem(xr)):(await Hn(un,{likeCount:Ur(1)}),localStorage.setItem(xr,"true"))};return c.filter(ln=>!ln.parentId).map(ln=>{const Kn=ln.authorName?ln.authorName.charAt(0).toUpperCase():"?",un=Ne.currentUser?localStorage.getItem(`liked_comment_${ln.id}_${Ne.currentUser.uid}`)==="true":!1,xr=c.filter(Ve=>Ve.parentId===ln.id);return s.jsxs("div",{className:"border-b border-gray-800/80 pb-3 last:border-0 last:pb-0 text-left animate-fade-in",children:[s.jsxs("div",{className:"flex gap-2.5 text-xs",children:[ln.photoURL?s.jsx(Vi,{src:ln.photoURL,className:"w-7 h-7 rounded-full border border-gray-800 object-cover shrink-0 mt-0.5",alt:""}):s.jsx("div",{className:Ge("w-7 h-7 rounded-full flex items-center justify-center text-white font-extrabold text-[10px] uppercase shrink-0 shadow-md",Ze(Kn)),children:Kn}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[s.jsx("span",{className:"font-extrabold text-[#cbd5e1] text-[11px] truncate",children:ln.authorName}),ln.userId==="mega-ai-bot"&&s.jsx("span",{className:"text-[8px] bg-indigo-500/20 text-indigo-300 px-1.5 py-0.5 rounded-full font-black uppercase tracking-wider border border-indigo-500/30",children:"AI"})]}),s.jsxs("button",{type:"button",onClick:Ve=>{Ve.stopPropagation(),Wt(ln.id,ln.likeCount||0)},className:Ge("flex items-center gap-1 p-0.5 text-gray-400 hover:text-red-500 transition-all cursor-pointer shrink-0 ml-2",un&&"text-red-500"),children:[s.jsx("span",{className:"text-[9px] text-gray-400",children:(ln.likeCount||0)>0?Tc(ln.likeCount):""}),s.jsx(ku,{size:12,className:Ge("transition-transform hover:scale-110",un?"fill-red-500 text-red-500 ":"text-gray-500")})]})]}),s.jsx("div",{className:"text-gray-200 font-sans leading-relaxed text-[11px] mt-0.5 text-left break-words",children:f2(ln.content)}),s.jsx("div",{className:"flex items-center gap-3 mt-1.5",children:s.jsxs("button",{type:"button",onClick:()=>Fe({id:ln.id,parentId:ln.id,authorName:ln.authorName}),className:"text-[9.5px] font-black text-indigo-400 hover:text-indigo-300 uppercase tracking-wider cursor-pointer hover:underline flex items-center gap-1",children:[s.jsx(X6,{size:10}),s.jsx("span",{children:"Reply"})]})})]})]}),xr.length>0&&s.jsx("div",{className:"ml-4 pl-3 border-l-2 border-indigo-500/30 space-y-2.5 mt-2.5",children:xr.map(Ve=>{const Ot=Ve.authorName?Ve.authorName.charAt(0).toUpperCase():"?",nn=Ne.currentUser?localStorage.getItem(`liked_comment_${Ve.id}_${Ne.currentUser.uid}`)==="true":!1;return s.jsxs("div",{className:"flex gap-2 text-xs text-left bg-indigo-950/20 p-2 rounded-xl border border-indigo-900/30",children:[Ve.photoURL?s.jsx(Vi,{src:Ve.photoURL,className:"w-5.5 h-5.5 rounded-full border border-gray-800 object-cover shrink-0 mt-0.5",alt:""}):s.jsx("div",{className:Ge("w-5.5 h-5.5 rounded-full flex items-center justify-center text-white font-extrabold text-[9px] uppercase shrink-0 shadow-md",Ze(Ot)),children:Ot}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap truncate",children:[s.jsx("span",{className:"font-extrabold text-[#e2e8f0] text-[10px] truncate",children:Ve.authorName}),Ve.replyToAuthor&&s.jsxs("span",{className:"text-[8.5px] text-indigo-300 font-mono font-bold",children:["replying to @",Ve.replyToAuthor]})]}),s.jsxs("button",{type:"button",onClick:mn=>{mn.stopPropagation(),Wt(Ve.id,Ve.likeCount||0)},className:Ge("flex items-center gap-1 p-0.5 text-gray-400 hover:text-red-500 transition-all cursor-pointer shrink-0 ml-1",nn&&"text-red-500"),children:[s.jsx("span",{className:"text-[8.5px] text-gray-400",children:(Ve.likeCount||0)>0?Tc(Ve.likeCount):""}),s.jsx(ku,{size:10,className:Ge(nn?"fill-red-500 text-red-500":"text-gray-500")})]})]}),s.jsx("div",{className:"text-gray-200 font-sans leading-relaxed text-[10.5px] mt-0.5 break-words",children:f2(Ve.content)}),s.jsx("div",{className:"flex items-center gap-3 mt-1",children:s.jsxs("button",{type:"button",onClick:()=>Fe({id:Ve.id,parentId:ln.id,authorName:Ve.authorName}),className:"text-[8.5px] font-black text-indigo-400 hover:text-indigo-300 uppercase tracking-wider cursor-pointer hover:underline flex items-center gap-0.5",children:[s.jsx(X6,{size:9}),s.jsx("span",{children:"Reply"})]})})]})]},Ve.id)})})]},ln.id)})})():s.jsx("p",{className:"text-[10px] text-gray-500 font-bold uppercase italic py-4 text-center",children:"No commentary yet. Let's talk about it!"})})]})})]})]})}))}return dt(n==="big"||n==="featured"?s.jsxs("div",{onClick:()=>t(e),className:"group cursor-pointer bg-white border border-gray-100 hover:shadow-xl transition-all duration-300 overflow-hidden flex flex-col text-left",children:[s.jsxs("div",{className:"relative aspect-[16/9] md:aspect-[21/10] overflow-hidden bg-gray-950",children:[s.jsx(Vi,{src:e.featuredImageUrl,className:"w-full h-full object-cover transition-all duration-[4000ms] group-hover:scale-105",alt:e.title}),s.jsxs("div",{className:"absolute top-4 left-4 flex gap-1.5",children:[s.jsx("span",{className:"bg-red-600 text-white px-3 py-1.5 text-[9px] font-black uppercase tracking-widest shadow-lg",children:e.category}),e.isOfflineCached&&s.jsx("span",{className:"bg-teal-600 text-white p-2.5 shadow-lg flex items-center justify-center cursor-help",title:"Offline Cached",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"shrink-0 w-3.5 h-3.5",children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsx("path",{fill:"currentColor",d:"M12.05 20q-3.35 0-5.7-2.325T4 12v-.175l-1.6 1.6l-1.4-1.4l4-4l4 4l-1.4 1.4l-1.6-1.6V12q0 2.5 1.763 4.25T12.05 18q.65 0 1.275-.15t1.225-.45l1.5 1.5q-.95.55-1.95.825T12.05 20M19 15.975l-4-4l1.4-1.4l1.6 1.6V12q0-2.5-1.763-4.25T11.95 6q-.65 0-1.275.15T9.45 6.6l-1.5-1.5q.95-.55 1.95-.825T11.95 4q3.35 0 5.7 2.325T20 12v.175l1.6-1.6l1.4 1.4z"})]})})]})]}),s.jsxs("div",{className:"p-6 md:p-8 space-y-4",children:[s.jsx("h3",{className:"text-xl md:text-3xl font-serif font-black tracking-tight leading-tight text-black group-hover:text-red-650 transition-colors italic underline underline-offset-4 decoration-2",children:A0(e.title)}),s.jsx("p",{className:"text-sm border-l-2 border-red-500 pl-4 font-serif text-gray-750 italic",children:e.summary}),s.jsx("p",{className:"text-xs text-gray-650 leading-relaxed font-sans line-clamp-3",children:e.content}),s.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-100 flex-wrap gap-2",children:[s.jsxs("div",{onClick:Ft=>{r&&e.authorId&&(Ft.stopPropagation(),r(e.authorId))},onMouseEnter:Ft=>{r&&e.authorId&&window.matchMedia("(min-width: 1024px)").matches&&r(e.authorId)},className:Ge("flex items-center gap-2 select-none",r&&"cursor-pointer hover:opacity-80 hover:scale-103 active:scale-97 transition-all"),title:"Click or hover to view peer credentials",children:[s.jsx(Vi,{src:e.authorProfile||`https://ui-avatars.com/api/?name=${encodeURIComponent(e.authorName)}&background=random`,className:"w-6 h-6 rounded-full border border-gray-200 shrink-0",alt:e.authorName}),s.jsxs("span",{className:"text-[9px] font-black uppercase text-black hover:underline",children:["By ",e.authorName&&e.authorName.includes("@")?e.authorName.split("@")[0]:e.authorName]}),e.publishDate&&s.jsxs("span",{className:"text-[9px] font-bold text-gray-500 font-mono flex items-center gap-1 shrink-0 ml-1",children:[s.jsx(H0,{size:10,className:"text-red-600"}),s.jsx("span",{children:Ape(e.publishDate)})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[e.Links&&e.Links.trim()&&s.jsxs("button",{onClick:Ft=>{Ft.stopPropagation(),window.open(e.Links.trim(),"_blank","noopener,noreferrer")},className:"inline-flex items-center gap-1.5 px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-[9.5px] font-black uppercase tracking-wider rounded-lg transition-all active:scale-95 shadow-xs cursor-pointer select-none",children:[s.jsx("span",{children:e.ctaText||"Discover More"}),s.jsx(Va,{size:10,strokeWidth:3})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-red-600 font-bold tracking-widest text-[9px] uppercase hover:underline",children:["Read dispatch ",s.jsx(ej,{size:11})]})]})]})]})]}):n==="magazine"||n==="small"?s.jsxs("div",{onClick:()=>t(e),className:"group cursor-pointer space-y-4 pb-6 border-b border-gray-100 last:border-0 text-left",children:[s.jsx("div",{className:"aspect-[4/3] overflow-hidden bg-gray-50 rounded-xl border border-gray-100",children:s.jsx(Vi,{src:e.featuredImageUrl,className:"w-full h-full object-[center_top] object-cover transition-all duration-1000 group-hover:scale-103",alt:e.title})}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[9px] font-extrabold font-mono text-red-600 shrink-0 flex-wrap",children:[s.jsx("span",{className:"uppercase tracking-widest",children:e.category}),e.isOfflineCached&&s.jsx("span",{className:"text-teal-600 bg-teal-50 p-1 rounded-full border border-teal-200 flex items-center justify-center cursor-help",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"shrink-0 w-3 h-3",children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsx("path",{fill:"currentColor",d:"M12.05 20q-3.35 0-5.7-2.325T4 12v-.175l-1.6 1.6l-1.4-1.4l4-4l4 4l-1.4 1.4l-1.6-1.6V12q0 2.5 1.763 4.25T12.05 18q.65 0 1.275-.15t1.225-.45l1.5 1.5q-.95.55-1.95.825T12.05 20M19 15.975l-4-4l1.4-1.4l1.6 1.6V12q0-2.5-1.763-4.25T11.95 6q-.65 0-1.275.15T9.45 6.6l-1.5-1.5q.95-.55 1.95-.825T11.95 4q3.35 0 5.7 2.325T20 12v.175l1.6-1.6l1.4 1.4z"})]})}),e.publishDate&&s.jsxs("span",{className:"text-[9px] font-semibold text-gray-400 lowercase normal-case tracking-normal",children:["• ",gw(e.publishDate)]})]}),s.jsx("div",{className:"flex items-center gap-1.5 text-[10px] text-gray-400 font-bold",children:s.jsxs("span",{className:"flex items-center gap-0.5",children:[s.jsx(a8,{size:10})," ",Tc(L)]})})]}),s.jsx("h4",{className:"text-base font-serif font-black text-black leading-snug group-hover:text-red-600 transition-colors underline underline-offset-2 decoration-1",children:A0(e.title)}),s.jsx("p",{className:"text-xs text-gray-650 line-clamp-2 italic font-serif",children:e.summary}),e.Links&&e.Links.trim()&&s.jsx("div",{className:"pt-1 text-left",children:s.jsxs("button",{onClick:Ft=>{Ft.stopPropagation(),window.open(e.Links.trim(),"_blank","noopener,noreferrer")},className:"inline-flex items-center gap-1.5 px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-[9.5px] font-black uppercase tracking-wider rounded-lg transition-all active:scale-95 shadow-xs cursor-pointer select-none",children:[s.jsx("span",{children:e.ctaText||"Discover More"}),s.jsx(Va,{size:10,strokeWidth:3})]})})]})]}):s.jsxs("div",{onClick:()=>t(e),className:"group cursor-pointer flex gap-4 py-4 border-b border-gray-50 last:border-0 text-left",children:[s.jsxs("div",{className:"flex-1 space-y-1.5 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[8px] font-black font-mono text-red-600 shrink-0 flex-wrap",children:[s.jsx("span",{className:"uppercase tracking-wider",children:e.category}),e.isOfflineCached&&s.jsx("span",{className:"text-teal-600 bg-teal-50 p-1 rounded-full border border-teal-200 flex items-center justify-center cursor-help",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"shrink-0 w-3 h-3",children:[s.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),s.jsx("path",{fill:"currentColor",d:"M12.05 20q-3.35 0-5.7-2.325T4 12v-.175l-1.6 1.6l-1.4-1.4l4-4l4 4l-1.4 1.4l-1.6-1.6V12q0 2.5 1.763 4.25T12.05 18q.65 0 1.275-.15t1.225-.45l1.5 1.5q-.95.55-1.95.825T12.05 20M19 15.975l-4-4l1.4-1.4l1.6 1.6V12q0-2.5-1.763-4.25T11.95 6q-.65 0-1.275.15T9.45 6.6l-1.5-1.5q.95-.55 1.95-.825T11.95 4q3.35 0 5.7 2.325T20 12v.175l1.6-1.6l1.4 1.4z"})]})}),e.publishDate&&s.jsxs("span",{className:"text-[9px] font-medium text-gray-400 lowercase normal-case tracking-normal",children:["• ",gw(e.publishDate)]})]}),s.jsx("h5",{className:"text-xs font-serif font-black text-black leading-snug truncate group-hover:text-red-600 transition-colors underline decoration-1",children:A0(e.title)}),s.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[s.jsxs("p",{onClick:Ft=>{r&&e.authorId&&(Ft.stopPropagation(),r(e.authorId))},onMouseEnter:Ft=>{r&&e.authorId&&window.matchMedia("(min-width: 1024px)").matches&&r(e.authorId)},className:Ge("text-[9px] font-black text-gray-400 uppercase tracking-widest select-none",r&&"cursor-pointer hover:text-black hover:underline active:scale-97 transition-all"),title:"Click or hover to view peer credentials",children:["By ",e.authorName&&e.authorName.includes("@")?e.authorName.split("@")[0]:e.authorName]}),e.Links&&e.Links.trim()&&s.jsxs("button",{onClick:Ft=>{Ft.stopPropagation(),window.open(e.Links.trim(),"_blank","noopener,noreferrer")},className:"inline-flex items-center gap-1 px-2 py-1 bg-red-650 hover:bg-red-700 text-white text-[8px] font-black uppercase tracking-wider rounded transition-all active:scale-95 shadow-xs cursor-pointer select-none",children:[s.jsx("span",{children:"Discover"}),s.jsx(Va,{size:8,strokeWidth:3})]})]})]}),s.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded overflow-hidden shrink-0 border border-gray-100",children:s.jsx(Vi,{src:e.featuredImageUrl,className:"w-full h-full object-cover",alt:""})})]}))};var Mx={exports:{}},mS={},gS,_M;function j1e(){if(_M)return gS;_M=1;function e(t,n){typeof n=="boolean"&&(n={forever:n}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=n||{},this._maxRetryTime=n&&n.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}return gS=e,e.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},e.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},e.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var n=new Date().getTime();if(t&&n-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var i=this;return this._timer=setTimeout(function(){i._attempts++,i._operationTimeoutCb&&(i._timeout=setTimeout(function(){i._operationTimeoutCb(i._attempts)},i._operationTimeout),i._options.unref&&i._timeout.unref()),i._fn(i._attempts)},r),this._options.unref&&this._timer.unref(),!0},e.prototype.attempt=function(t,n){this._fn=t,n&&(n.timeout&&(this._operationTimeout=n.timeout),n.cb&&(this._operationTimeoutCb=n.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},e.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)},e.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)},e.prototype.start=e.prototype.try,e.prototype.errors=function(){return this._errors},e.prototype.attempts=function(){return this._attempts},e.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},n=null,r=0,i=0;i=r&&(n=a,r=c)}return n},gS}var SM;function T1e(){return SM||(SM=1,(function(e){var t=j1e();e.operation=function(n){var r=e.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(n){if(n instanceof Array)return[].concat(n);var r={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var i in n)r[i]=n[i];if(r.minTimeout>r.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var a=[],o=0;o{const f=h.retries-(c-1);return o.attemptNumber=c,o.retriesLeft=f,o},i=o=>t.includes(o),a=(o,c)=>new Promise((h,f)=>{c={onFailedAttempt:()=>{},retries:10,...c};const m=e.operation(c);m.attempt(async y=>{try{h(await o(y))}catch(w){if(!(w instanceof Error)){f(new TypeError(`Non-error was thrown: "${w}". You should only throw errors.`));return}if(w instanceof n)m.stop(),f(w.originalError);else if(w instanceof TypeError&&!i(w.message))m.stop(),f(w);else{r(w,y,c);try{await c.onFailedAttempt(w)}catch(A){f(A);return}m.retry(w)||f(m.mainError())}}})});return Mx.exports=a,Mx.exports.default=a,Mx.exports.AbortError=n,Mx.exports}P1e();var R1e={};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var IM;(function(e){e.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",e.PYTHON="PYTHON"})(IM||(IM={}));var jM;(function(e){e.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",e.OUTCOME_OK="OUTCOME_OK",e.OUTCOME_FAILED="OUTCOME_FAILED",e.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(jM||(jM={}));var TM;(function(e){e.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",e.SILENT="SILENT",e.WHEN_IDLE="WHEN_IDLE",e.INTERRUPT="INTERRUPT"})(TM||(TM={}));var OM;(function(e){e.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",e.STRING="STRING",e.NUMBER="NUMBER",e.INTEGER="INTEGER",e.BOOLEAN="BOOLEAN",e.ARRAY="ARRAY",e.OBJECT="OBJECT",e.NULL="NULL"})(OM||(OM={}));var PM;(function(e){e.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",e.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",e.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",e.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(PM||(PM={}));var RM;(function(e){e.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",e.NO_AUTH="NO_AUTH",e.API_KEY_AUTH="API_KEY_AUTH",e.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",e.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",e.OAUTH="OAUTH",e.OIDC_AUTH="OIDC_AUTH"})(RM||(RM={}));var DM;(function(e){e.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",e.HTTP_IN_QUERY="HTTP_IN_QUERY",e.HTTP_IN_HEADER="HTTP_IN_HEADER",e.HTTP_IN_PATH="HTTP_IN_PATH",e.HTTP_IN_BODY="HTTP_IN_BODY",e.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(DM||(DM={}));var MM;(function(e){e.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",e.SIMPLE_SEARCH="SIMPLE_SEARCH",e.ELASTIC_SEARCH="ELASTIC_SEARCH"})(MM||(MM={}));var LM;(function(e){e.UNSPECIFIED="UNSPECIFIED",e.BLOCKING="BLOCKING",e.NON_BLOCKING="NON_BLOCKING"})(LM||(LM={}));var UM;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.MODE_DYNAMIC="MODE_DYNAMIC"})(UM||(UM={}));var BM;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.AUTO="AUTO",e.ANY="ANY",e.NONE="NONE",e.VALIDATED="VALIDATED"})(BM||(BM={}));var zM;(function(e){e.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH",e.MINIMAL="MINIMAL"})(zM||(zM={}));var VM;(function(e){e.DONT_ALLOW="DONT_ALLOW",e.ALLOW_ADULT="ALLOW_ADULT",e.ALLOW_ALL="ALLOW_ALL"})(VM||(VM={}));var FM;(function(e){e.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",e.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",e.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",e.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",e.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",e.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",e.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",e.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",e.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",e.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",e.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(FM||(FM={}));var $M;(function(e){e.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",e.SEVERITY="SEVERITY",e.PROBABILITY="PROBABILITY"})($M||($M={}));var HM;(function(e){e.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",e.BLOCK_NONE="BLOCK_NONE",e.OFF="OFF"})(HM||(HM={}));var GM;(function(e){e.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",e.STOP="STOP",e.MAX_TOKENS="MAX_TOKENS",e.SAFETY="SAFETY",e.RECITATION="RECITATION",e.LANGUAGE="LANGUAGE",e.OTHER="OTHER",e.BLOCKLIST="BLOCKLIST",e.PROHIBITED_CONTENT="PROHIBITED_CONTENT",e.SPII="SPII",e.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",e.IMAGE_SAFETY="IMAGE_SAFETY",e.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",e.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",e.NO_IMAGE="NO_IMAGE",e.IMAGE_RECITATION="IMAGE_RECITATION",e.IMAGE_OTHER="IMAGE_OTHER"})(GM||(GM={}));var qM;(function(e){e.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",e.NEGLIGIBLE="NEGLIGIBLE",e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"})(qM||(qM={}));var WM;(function(e){e.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",e.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",e.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",e.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",e.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(WM||(WM={}));var KM;(function(e){e.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",e.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",e.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",e.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",e.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(KM||(KM={}));var YM;(function(e){e.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",e.SAFETY="SAFETY",e.OTHER="OTHER",e.BLOCKLIST="BLOCKLIST",e.PROHIBITED_CONTENT="PROHIBITED_CONTENT",e.IMAGE_SAFETY="IMAGE_SAFETY",e.MODEL_ARMOR="MODEL_ARMOR",e.JAILBREAK="JAILBREAK"})(YM||(YM={}));var XM;(function(e){e.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",e.ON_DEMAND="ON_DEMAND",e.ON_DEMAND_PRIORITY="ON_DEMAND_PRIORITY",e.ON_DEMAND_FLEX="ON_DEMAND_FLEX",e.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(XM||(XM={}));var QM;(function(e){e.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",e.TEXT="TEXT",e.IMAGE="IMAGE",e.AUDIO="AUDIO"})(QM||(QM={}));var ZM;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",e.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",e.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",e.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(ZM||(ZM={}));var JM;(function(e){e.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",e.TUNING_MODE_FULL="TUNING_MODE_FULL",e.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(JM||(JM={}));var e9;(function(e){e.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",e.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",e.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",e.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",e.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",e.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",e.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(e9||(e9={}));var t9;(function(e){e.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",e.JOB_STATE_QUEUED="JOB_STATE_QUEUED",e.JOB_STATE_PENDING="JOB_STATE_PENDING",e.JOB_STATE_RUNNING="JOB_STATE_RUNNING",e.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",e.JOB_STATE_FAILED="JOB_STATE_FAILED",e.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",e.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",e.JOB_STATE_PAUSED="JOB_STATE_PAUSED",e.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",e.JOB_STATE_UPDATING="JOB_STATE_UPDATING",e.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(t9||(t9={}));var n9;(function(e){e.TUNING_JOB_STATE_UNSPECIFIED="TUNING_JOB_STATE_UNSPECIFIED",e.TUNING_JOB_STATE_WAITING_FOR_QUOTA="TUNING_JOB_STATE_WAITING_FOR_QUOTA",e.TUNING_JOB_STATE_PROCESSING_DATASET="TUNING_JOB_STATE_PROCESSING_DATASET",e.TUNING_JOB_STATE_WAITING_FOR_CAPACITY="TUNING_JOB_STATE_WAITING_FOR_CAPACITY",e.TUNING_JOB_STATE_TUNING="TUNING_JOB_STATE_TUNING",e.TUNING_JOB_STATE_POST_PROCESSING="TUNING_JOB_STATE_POST_PROCESSING"})(n9||(n9={}));var r9;(function(e){e.AGGREGATION_METRIC_UNSPECIFIED="AGGREGATION_METRIC_UNSPECIFIED",e.AVERAGE="AVERAGE",e.MODE="MODE",e.STANDARD_DEVIATION="STANDARD_DEVIATION",e.VARIANCE="VARIANCE",e.MINIMUM="MINIMUM",e.MAXIMUM="MAXIMUM",e.MEDIAN="MEDIAN",e.PERCENTILE_P90="PERCENTILE_P90",e.PERCENTILE_P95="PERCENTILE_P95",e.PERCENTILE_P99="PERCENTILE_P99"})(r9||(r9={}));var i9;(function(e){e.PAIRWISE_CHOICE_UNSPECIFIED="PAIRWISE_CHOICE_UNSPECIFIED",e.BASELINE="BASELINE",e.CANDIDATE="CANDIDATE",e.TIE="TIE"})(i9||(i9={}));var s9;(function(e){e.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",e.TUNING_TASK_I2V="TUNING_TASK_I2V",e.TUNING_TASK_T2V="TUNING_TASK_T2V",e.TUNING_TASK_R2V="TUNING_TASK_R2V"})(s9||(s9={}));var a9;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",e.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",e.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",e.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",e.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH"})(a9||(a9={}));var o9;(function(e){e.TOOL_TYPE_UNSPECIFIED="TOOL_TYPE_UNSPECIFIED",e.GOOGLE_SEARCH_WEB="GOOGLE_SEARCH_WEB",e.GOOGLE_SEARCH_IMAGE="GOOGLE_SEARCH_IMAGE",e.URL_CONTEXT="URL_CONTEXT",e.GOOGLE_MAPS="GOOGLE_MAPS",e.FILE_SEARCH="FILE_SEARCH"})(o9||(o9={}));var l9;(function(e){e.COLLECTION="COLLECTION"})(l9||(l9={}));var c9;(function(e){e.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",e.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",e.BALANCED="BALANCED",e.PRIORITIZE_COST="PRIORITIZE_COST"})(c9||(c9={}));var u9;(function(e){e.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",e.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(u9||(u9={}));var d9;(function(e){e.PROMINENT_PEOPLE_UNSPECIFIED="PROMINENT_PEOPLE_UNSPECIFIED",e.ALLOW_PROMINENT_PEOPLE="ALLOW_PROMINENT_PEOPLE",e.BLOCK_PROMINENT_PEOPLE="BLOCK_PROMINENT_PEOPLE"})(d9||(d9={}));var h9;(function(e){e.PREDICT="PREDICT",e.EMBED_CONTENT="EMBED_CONTENT"})(h9||(h9={}));var f9;(function(e){e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",e.BLOCK_NONE="BLOCK_NONE"})(f9||(f9={}));var p9;(function(e){e.auto="auto",e.en="en",e.ja="ja",e.ko="ko",e.hi="hi",e.zh="zh",e.pt="pt",e.es="es"})(p9||(p9={}));var m9;(function(e){e.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",e.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",e.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",e.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",e.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(m9||(m9={}));var g9;(function(e){e.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",e.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",e.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",e.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(g9||(g9={}));var x9;(function(e){e.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",e.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",e.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",e.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(x9||(x9={}));var y9;(function(e){e.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",e.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",e.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",e.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",e.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",e.EDIT_MODE_STYLE="EDIT_MODE_STYLE",e.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",e.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(y9||(y9={}));var b9;(function(e){e.FOREGROUND="FOREGROUND",e.BACKGROUND="BACKGROUND",e.PROMPT="PROMPT",e.SEMANTIC="SEMANTIC",e.INTERACTIVE="INTERACTIVE"})(b9||(b9={}));var v9;(function(e){e.ASSET="ASSET",e.STYLE="STYLE"})(v9||(v9={}));var w9;(function(e){e.INSERT="INSERT",e.REMOVE="REMOVE",e.REMOVE_STATIC="REMOVE_STATIC",e.OUTPAINT="OUTPAINT"})(w9||(w9={}));var N9;(function(e){e.OPTIMIZED="OPTIMIZED",e.LOSSLESS="LOSSLESS"})(N9||(N9={}));var E9;(function(e){e.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",e.PREFERENCE_TUNING="PREFERENCE_TUNING",e.DISTILLATION="DISTILLATION"})(E9||(E9={}));var A9;(function(e){e.STATE_UNSPECIFIED="STATE_UNSPECIFIED",e.STATE_PENDING="STATE_PENDING",e.STATE_ACTIVE="STATE_ACTIVE",e.STATE_FAILED="STATE_FAILED"})(A9||(A9={}));var _9;(function(e){e.STATE_UNSPECIFIED="STATE_UNSPECIFIED",e.PROCESSING="PROCESSING",e.ACTIVE="ACTIVE",e.FAILED="FAILED"})(_9||(_9={}));var S9;(function(e){e.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",e.UPLOADED="UPLOADED",e.GENERATED="GENERATED",e.REGISTERED="REGISTERED"})(S9||(S9={}));var k9;(function(e){e.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",e.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",e.RESPONSE_REJECTED="RESPONSE_REJECTED",e.NEED_MORE_INPUT="NEED_MORE_INPUT"})(k9||(k9={}));var C9;(function(e){e.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",e.TEXT="TEXT",e.IMAGE="IMAGE",e.VIDEO="VIDEO",e.AUDIO="AUDIO",e.DOCUMENT="DOCUMENT"})(C9||(C9={}));var I9;(function(e){e.VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",e.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",e.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS"})(I9||(I9={}));var j9;(function(e){e.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",e.ACTIVITY_START="ACTIVITY_START",e.ACTIVITY_END="ACTIVITY_END"})(j9||(j9={}));var T9;(function(e){e.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",e.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",e.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(T9||(T9={}));var O9;(function(e){e.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",e.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",e.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(O9||(O9={}));var P9;(function(e){e.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",e.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",e.NO_INTERRUPTION="NO_INTERRUPTION"})(P9||(P9={}));var R9;(function(e){e.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",e.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",e.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(R9||(R9={}));var D9;(function(e){e.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",e.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",e.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",e.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",e.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",e.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",e.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",e.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",e.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",e.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",e.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",e.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",e.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(D9||(D9={}));var M9;(function(e){e.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",e.QUALITY="QUALITY",e.DIVERSITY="DIVERSITY",e.VOCALIZATION="VOCALIZATION"})(M9||(M9={}));var L9;(function(e){e.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",e.PLAY="PLAY",e.PAUSE="PAUSE",e.STOP="STOP",e.RESET_CONTEXT="RESET_CONTEXT"})(L9||(L9={}));/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var U9;(function(e){e.PAGED_ITEM_BATCH_JOBS="batchJobs",e.PAGED_ITEM_MODELS="models",e.PAGED_ITEM_TUNING_JOBS="tuningJobs",e.PAGED_ITEM_FILES="files",e.PAGED_ITEM_CACHED_CONTENTS="cachedContents",e.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",e.PAGED_ITEM_DOCUMENTS="documents"})(U9||(U9={}));function E2(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function zs(e){return this instanceof zs?(this.v=e,this):new zs(e)}function C1(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(A){return function(k){return Promise.resolve(k).then(A,y)}}function c(A,k){r[A]&&(i[A]=function(I){return new Promise(function(T,D){a.push([A,I,T,D])>1||h(A,I)})},k&&(i[A]=k(i[A])))}function h(A,k){try{f(r[A](k))}catch(I){w(a[0][3],I)}}function f(A){A.value instanceof zs?Promise.resolve(A.value.v).then(m,y):w(a[0][2],A)}function m(A){h("next",A)}function y(A){h("throw",A)}function w(A,k){A(k),a.shift(),a.length&&h(a[0][0],a[0][1])}}function U0(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof B9=="function"?B9(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(a){n[a]=e[a]&&function(o){return new Promise(function(c,h){o=e[a](o),i(c,h,o.done,o.value)})}}function i(a,o,c,h){Promise.resolve(h).then(function(f){a({value:f,done:c})},o)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */let QW=function(){const{crypto:e}=globalThis;if(e!=null&&e.randomUUID)return QW=e.randomUUID.bind(e),e.randomUUID();const t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^n()&15>>+r/4).toString(16))};const D1e=()=>QW();/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function LC(e){return typeof e=="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}const UC=e=>{if(e instanceof Error)return e;if(typeof e=="object"&&e!==null){try{if(Object.prototype.toString.call(e)==="[object Error]"){const t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class hc extends Error{}class Ko extends hc{constructor(t,n,r,i){super(`${Ko.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.error=n}static makeMessage(t,n,r){const i=n!=null&&n.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):r;return t&&i?`${t} ${i}`:t?`${t} status code (no body)`:i||"(no status code or body)"}static generate(t,n,r,i){if(!t||!i)return new mE({message:r,cause:UC(n)});const a=n;return t===400?new JW(t,a,r,i):t===401?new eK(t,a,r,i):t===403?new tK(t,a,r,i):t===404?new nK(t,a,r,i):t===409?new rK(t,a,r,i):t===422?new iK(t,a,r,i):t===429?new sK(t,a,r,i):t>=500?new aK(t,a,r,i):new Ko(t,a,r,i)}}class BC extends Ko{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}}class mE extends Ko{constructor({message:t,cause:n}){super(void 0,void 0,t||"Connection error.",void 0),n&&(this.cause=n)}}class ZW extends mE{constructor({message:t}={}){super({message:t??"Request timed out."})}}class JW extends Ko{}class eK extends Ko{}class tK extends Ko{}class nK extends Ko{}class rK extends Ko{}class iK extends Ko{}class sK extends Ko{}class aK extends Ko{}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const M1e=/^[a-z][a-z0-9+.-]*:/i,L1e=e=>M1e.test(e);let zC=e=>(zC=Array.isArray,zC(e));const U1e=zC;let B1e=U1e;const z9=B1e;function V9(e){if(!e)return!0;for(const t in e)return!1;return!0}function z1e(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const V1e=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new hc(`${e} must be an integer`);if(t<0)throw new hc(`${e} must be a positive integer`);return t},F1e=e=>{try{return JSON.parse(e)}catch{return}};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const $1e=e=>new Promise(t=>setTimeout(t,e));/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function H1e(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new GeminiNextGenAPIClient({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function oK(...e){const t=globalThis.ReadableStream;if(typeof t>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function G1e(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return oK({start(){},async pull(n){const{done:r,value:i}=await t.next();r?n.close():n.enqueue(i)},async cancel(){var n;await((n=t.return)===null||n===void 0?void 0:n.call(t))}})}function lK(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const n=await t.read();return n!=null&&n.done&&t.releaseLock(),n}catch(n){throw t.releaseLock(),n}},async return(){const n=t.cancel();return t.releaseLock(),await n,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function q1e(e){var t,n;if(e===null||typeof e!="object")return;if(e[Symbol.asyncIterator]){await((n=(t=e[Symbol.asyncIterator]()).return)===null||n===void 0?void 0:n.call(t));return}const r=e.getReader(),i=r.cancel();r.releaseLock(),await i}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const W1e=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function K1e(e){return Object.entries(e).filter(([t,n])=>typeof n<"u").map(([t,n])=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(n===null)return`${encodeURIComponent(t)}=`;throw new hc(`Cannot stringify type ${typeof n}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const Y1e="0.0.1";/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const cK=()=>{var e;if(typeof File>"u"){const{process:t}=globalThis,n=typeof((e=t==null?void 0:t.versions)===null||e===void 0?void 0:e.node)=="string"&&parseInt(t.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(n?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function yS(e,t,n){return cK(),new File(e,t??"unknown_file",n)}function X1e(e){return(typeof e=="object"&&e!==null&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}const Q1e=e=>e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function";/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const uK=e=>e!=null&&typeof e=="object"&&typeof e.size=="number"&&typeof e.type=="string"&&typeof e.text=="function"&&typeof e.slice=="function"&&typeof e.arrayBuffer=="function",Z1e=e=>e!=null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.lastModified=="number"&&uK(e),J1e=e=>e!=null&&typeof e=="object"&&typeof e.url=="string"&&typeof e.blob=="function";async function eye(e,t,n){if(cK(),e=await e,Z1e(e))return e instanceof File?e:yS([await e.arrayBuffer()],e.name);if(J1e(e)){const i=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),yS(await VC(i),t,n)}const r=await VC(e);if(t||(t=X1e(e)),!(n!=null&&n.type)){const i=r.find(a=>typeof a=="object"&&"type"in a&&a.type);typeof i=="string"&&(n=Object.assign(Object.assign({},n),{type:i}))}return yS(r,t,n)}async function VC(e){var t,n,r,i,a;let o=[];if(typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)o.push(e);else if(uK(e))o.push(e instanceof Blob?e:await e.arrayBuffer());else if(Q1e(e))try{for(var c=!0,h=U0(e),f;f=await h.next(),t=f.done,!t;c=!0){i=f.value,c=!1;const m=i;o.push(...await VC(m))}}catch(m){n={error:m}}finally{try{!c&&!t&&(r=h.return)&&await r.call(h)}finally{if(n)throw n.error}}else{const m=(a=e==null?void 0:e.constructor)===null||a===void 0?void 0:a.name;throw new Error(`Unexpected data type: ${typeof e}${m?`; constructor: ${m}`:""}${tye(e)}`)}return o}function tye(e){return typeof e!="object"||e===null?"":`; props: [${Object.getOwnPropertyNames(e).map(n=>`"${n}"`).join(", ")}]`}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class dK{constructor(t){this._client=t}}dK._key=[];/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function hK(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const F9=Object.freeze(Object.create(null)),nye=(e=hK)=>(function(n,...r){if(n.length===1)return n[0];let i=!1;const a=[],o=n.reduce((m,y,w)=>{var A,k,I;/[?#]/.test(y)&&(i=!0);const T=r[w];let D=(i?encodeURIComponent:e)(""+T);return w!==r.length&&(T==null||typeof T=="object"&&T.toString===((I=Object.getPrototypeOf((k=Object.getPrototypeOf((A=T.hasOwnProperty)!==null&&A!==void 0?A:F9))!==null&&k!==void 0?k:F9))===null||I===void 0?void 0:I.toString))&&(D=T+"",a.push({start:m.length+y.length,length:D.length,error:`Value of type ${Object.prototype.toString.call(T).slice(8,-1)} is not a valid path parameter`})),m+y+(w===r.length?"":D)},""),c=o.split(/[?#]/,1)[0],h=/(^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;let f;for(;(f=h.exec(c))!==null;){const m=f[0].startsWith("/"),y=m?1:0,w=m?f[0].slice(1):f[0];a.push({start:f.index+y,length:w.length,error:`Value "${w}" can't be safely passed as a path parameter`})}if(a.sort((m,y)=>m.start-y.start),a.length>0){let m=0;const y=a.reduce((w,A)=>{const k=" ".repeat(A.start-m),I="^".repeat(A.length);return m=A.start+A.length,w+k+I},"");throw new hc(`Path parameters result in path with invalid segments: ${a.map(w=>w.error).join(` `)} ${o} ${y}`)}return o}),_v=nye(hK);/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class fK extends dK{create(t,n){var r;const{api_version:i=this._client.apiVersion}=t,a=E2(t,["api_version"]);if("model"in a&&"agent_config"in a)throw new hc("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");if("agent"in a&&"generation_config"in a)throw new hc("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");return this._client.post(_v`/${i}/interactions`,Object.assign(Object.assign({body:a},n),{stream:(r=t.stream)!==null&&r!==void 0?r:!1}))}delete(t,n={},r){const{api_version:i=this._client.apiVersion}=n??{};return this._client.delete(_v`/${i}/interactions/${t}`,r)}cancel(t,n={},r){const{api_version:i=this._client.apiVersion}=n??{};return this._client.post(_v`/${i}/interactions/${t}/cancel`,r)}get(t,n={},r){var i;const a=n??{},{api_version:o=this._client.apiVersion}=a,c=E2(a,["api_version"]);return this._client.get(_v`/${o}/interactions/${t}`,Object.assign(Object.assign({query:c},r),{stream:(i=n==null?void 0:n.stream)!==null&&i!==void 0?i:!1}))}}fK._key=Object.freeze(["interactions"]);class pK extends fK{}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function rye(e){let t=0;for(const i of e)t+=i.length;const n=new Uint8Array(t);let r=0;for(const i of e)n.set(i,r),r+=i.length;return n}let Sv;function XT(e){let t;return(Sv??(t=new globalThis.TextEncoder,Sv=t.encode.bind(t)))(e)}let kv;function $9(e){let t;return(kv??(t=new globalThis.TextDecoder,kv=t.decode.bind(t)))(e)}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class gE{constructor(){this.buffer=new Uint8Array,this.carriageReturnIndex=null,this.searchIndex=0}decode(t){var n;if(t==null)return[];const r=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?XT(t):t;this.buffer=rye([this.buffer,r]);const i=[];let a;for(;(a=iye(this.buffer,(n=this.carriageReturnIndex)!==null&&n!==void 0?n:this.searchIndex))!=null;){if(a.carriage&&this.carriageReturnIndex==null){this.carriageReturnIndex=a.index;continue}if(this.carriageReturnIndex!=null&&(a.index!==this.carriageReturnIndex+1||a.carriage)){i.push($9(this.buffer.subarray(0,this.carriageReturnIndex-1))),this.buffer=this.buffer.subarray(this.carriageReturnIndex),this.carriageReturnIndex=null,this.searchIndex=0;continue}const o=this.carriageReturnIndex!==null?a.preceding-1:a.preceding,c=$9(this.buffer.subarray(0,o));i.push(c),this.buffer=this.buffer.subarray(a.index),this.carriageReturnIndex=null,this.searchIndex=0}return this.searchIndex=Math.max(0,this.buffer.length-1),i}flush(){return this.buffer.length?this.decode(` `):[]}}gE.NEWLINE_CHARS=new Set([` `,"\r"]);gE.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function iye(e,t){const i=t??0,a=e.indexOf(10,i),o=e.indexOf(13,i);if(a===-1&&o===-1)return null;let c;return a!==-1&&o!==-1?c=Math.min(a,o):c=a!==-1?a:o,e[c]===10?{preceding:c,index:c+1,carriage:!1}:{preceding:c,index:c+1,carriage:!0}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const A2={off:0,error:200,warn:300,info:400,debug:500},H9=(e,t,n)=>{if(e){if(z1e(A2,e))return e;zo(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(A2))}`)}};function l1(){}function Cv(e,t,n){return!t||A2[e]>A2[n]?l1:t[e].bind(t)}const sye={error:l1,warn:l1,info:l1,debug:l1};let G9=new WeakMap;function zo(e){var t;const n=e.logger,r=(t=e.logLevel)!==null&&t!==void 0?t:"off";if(!n)return sye;const i=G9.get(n);if(i&&i[0]===r)return i[1];const a={error:Cv("error",n,r),warn:Cv("warn",n,r),info:Cv("info",n,r),debug:Cv("debug",n,r)};return G9.set(n,[r,a]),a}const lp=e=>(e.options&&(e.options=Object.assign({},e.options),delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([t,n])=>[t,t.toLowerCase()==="x-goog-api-key"||t.toLowerCase()==="authorization"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class C0{constructor(t,n,r){this.iterator=t,this.controller=n,this.client=r}static fromSSEResponse(t,n,r){let i=!1;const a=r?zo(r):console;function o(){return C1(this,arguments,function*(){var h,f,m,y;if(i)throw new hc("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let w=!1;try{try{for(var A=!0,k=U0(aye(t,n)),I;I=yield zs(k.next()),h=I.done,!h;A=!0){y=I.value,A=!1;const T=y;if(!w)if(T.data.startsWith("[DONE]")){w=!0;continue}else try{yield yield zs(JSON.parse(T.data))}catch(D){throw a.error("Could not parse message into JSON:",T.data),a.error("From chunk:",T.raw),D}}}catch(T){f={error:T}}finally{try{!A&&!h&&(m=k.return)&&(yield zs(m.call(k)))}finally{if(f)throw f.error}}w=!0}catch(T){if(LC(T))return yield zs(void 0);throw T}finally{w||n.abort()}})}return new C0(o,n,r)}static fromReadableStream(t,n,r){let i=!1;function a(){return C1(this,arguments,function*(){var h,f,m,y;const w=new gE,A=lK(t);try{for(var k=!0,I=U0(A),T;T=yield zs(I.next()),h=T.done,!h;k=!0){y=T.value,k=!1;const D=y;for(const F of w.decode(D))yield yield zs(F)}}catch(D){f={error:D}}finally{try{!k&&!h&&(m=I.return)&&(yield zs(m.call(I)))}finally{if(f)throw f.error}}for(const D of w.flush())yield yield zs(D)})}function o(){return C1(this,arguments,function*(){var h,f,m,y;if(i)throw new hc("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let w=!1;try{try{for(var A=!0,k=U0(a()),I;I=yield zs(k.next()),h=I.done,!h;A=!0){y=I.value,A=!1;const T=y;w||T&&(yield yield zs(JSON.parse(T)))}}catch(T){f={error:T}}finally{try{!A&&!h&&(m=k.return)&&(yield zs(m.call(k)))}finally{if(f)throw f.error}}w=!0}catch(T){if(LC(T))return yield zs(void 0);throw T}finally{w||n.abort()}})}return new C0(o,n,r)}[Symbol.asyncIterator](){return this.iterator()}tee(){const t=[],n=[],r=this.iterator(),i=a=>({next:()=>{if(a.length===0){const o=r.next();t.push(o),n.push(o)}return a.shift()}});return[new C0(()=>i(t),this.controller,this.client),new C0(()=>i(n),this.controller,this.client)]}toReadableStream(){const t=this;let n;return oK({async start(){n=t[Symbol.asyncIterator]()},async pull(r){try{const{value:i,done:a}=await n.next();if(a)return r.close();const o=XT(JSON.stringify(i)+` `);r.enqueue(o)}catch(i){r.error(i)}},async cancel(){var r;await((r=n.return)===null||r===void 0?void 0:r.call(n))}})}}function aye(e,t){return C1(this,arguments,function*(){var r,i,a,o;if(!e.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new hc("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new hc("Attempted to iterate over a response with no body");const c=new lye,h=new gE,f=lK(e.body);try{for(var m=!0,y=U0(oye(f)),w;w=yield zs(y.next()),r=w.done,!r;m=!0){o=w.value,m=!1;const A=o;for(const k of h.decode(A)){const I=c.decode(k);I&&(yield yield zs(I))}}}catch(A){i={error:A}}finally{try{!m&&!r&&(a=y.return)&&(yield zs(a.call(y)))}finally{if(i)throw i.error}}for(const A of h.flush()){const k=c.decode(A);k&&(yield yield zs(k))}})}function oye(e){return C1(this,arguments,function*(){var n,r,i,a;try{for(var o=!0,c=U0(e),h;h=yield zs(c.next()),n=h.done,!n;o=!0){a=h.value,o=!1;const f=a;if(f==null)continue;const m=f instanceof ArrayBuffer?new Uint8Array(f):typeof f=="string"?XT(f):f;yield yield zs(m)}}catch(f){r={error:f}}finally{try{!o&&!n&&(i=c.return)&&(yield zs(i.call(c)))}finally{if(r)throw r.error}}})}class lye{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(t){if(t.endsWith("\r")&&(t=t.substring(0,t.length-1)),!t){if(!this.event&&!this.data.length)return null;const a={event:this.event,data:this.data.join(` `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],a}if(this.chunks.push(t),t.startsWith(":"))return null;let[n,r,i]=cye(t,":");return i.startsWith(" ")&&(i=i.substring(1)),n==="event"?this.event=i:n==="data"&&this.data.push(i),null}}function cye(e,t){const n=e.indexOf(t);return n!==-1?[e.substring(0,n),t,e.substring(n+t.length)]:[e,"",""]}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */async function uye(e,t){const{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:a}=t,o=await(async()=>{var c;if(t.options.stream)return zo(e).debug("response",n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller,e):C0.fromSSEResponse(n,t.controller,e);if(n.status===204)return null;if(t.options.__binaryResponse)return n;const h=n.headers.get("content-type"),f=(c=h==null?void 0:h.split(";")[0])===null||c===void 0?void 0:c.trim();return(f==null?void 0:f.includes("application/json"))||(f==null?void 0:f.endsWith("+json"))?n.headers.get("content-length")==="0"?void 0:await n.json():await n.text()})();return zo(e).debug(`[${r}] response parsed`,lp({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-a})),o}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class QT extends Promise{constructor(t,n,r=uye){super(i=>{i(null)}),this.responsePromise=n,this.parseResponse=r,this.client=t}_thenUnwrap(t){return new QT(this.client,this.responsePromise,async(n,r)=>t(await this.parseResponse(n,r),r))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){const[t,n]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:n}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(this.client,t))),this.parsedPromise}then(t,n){return this.parse().then(t,n)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const mK=Symbol("brand.privateNullableHeaders");function*dye(e){if(!e)return;if(mK in e){const{values:r,nulls:i}=e;yield*r.entries();for(const a of i)yield[a,null];return}let t=!1,n;e instanceof Headers?n=e.entries():z9(e)?n=e:(t=!0,n=Object.entries(e??{}));for(let r of n){const i=r[0];if(typeof i!="string")throw new TypeError("expected header name to be a string");const a=z9(r[1])?r[1]:[r[1]];let o=!1;for(const c of a)c!==void 0&&(t&&!o&&(o=!0,yield[i,null]),yield[i,c])}}const Lx=e=>{const t=new Headers,n=new Set;for(const r of e){const i=new Set;for(const[a,o]of dye(r)){const c=a.toLowerCase();i.has(c)||(t.delete(a),i.add(c)),o===null?(t.delete(a),n.add(c)):(t.append(a,o),n.delete(c))}}return{[mK]:!0,values:t,nulls:n}};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const bS=e=>{var t,n,r,i,a,o;if(typeof globalThis.process<"u")return(r=(n=(t=R1e)===null||t===void 0?void 0:t[e])===null||n===void 0?void 0:n.trim())!==null&&r!==void 0?r:void 0;if(typeof globalThis.Deno<"u")return(o=(a=(i=globalThis.Deno.env)===null||i===void 0?void 0:i.get)===null||a===void 0?void 0:a.call(i,e))===null||o===void 0?void 0:o.trim()};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var gK;class xE{constructor(t){var n,r,i,a,o,c,h,{baseURL:f=bS("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:m=(n=bS("GEMINI_API_KEY"))!==null&&n!==void 0?n:null,apiVersion:y="v1beta"}=t,w=E2(t,["baseURL","apiKey","apiVersion"]);const A=Object.assign(Object.assign({apiKey:m,apiVersion:y},w),{baseURL:f||"https://generativelanguage.googleapis.com"});this.baseURL=A.baseURL,this.timeout=(r=A.timeout)!==null&&r!==void 0?r:xE.DEFAULT_TIMEOUT,this.logger=(i=A.logger)!==null&&i!==void 0?i:console;const k="warn";this.logLevel=k,this.logLevel=(o=(a=H9(A.logLevel,"ClientOptions.logLevel",this))!==null&&a!==void 0?a:H9(bS("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&o!==void 0?o:k,this.fetchOptions=A.fetchOptions,this.maxRetries=(c=A.maxRetries)!==null&&c!==void 0?c:2,this.fetch=(h=A.fetch)!==null&&h!==void 0?h:H1e(),this.encoder=W1e,this._options=A,this.apiKey=m,this.apiVersion=y,this.clientAdapter=A.clientAdapter}withOptions(t){return new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),t))}baseURLOverridden(){return this.baseURL!=="https://generativelanguage.googleapis.com"}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:n}){if(!(t.has("authorization")||t.has("x-goog-api-key"))&&!(this.apiKey&&t.get("x-goog-api-key"))&&!n.has("x-goog-api-key"))throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted')}async authHeaders(t){const n=Lx([t.headers]);if(!(n.values.has("authorization")||n.values.has("x-goog-api-key"))){if(this.apiKey)return Lx([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return Lx([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(t){return K1e(t)}getUserAgent(){return`${this.constructor.name}/JS ${Y1e}`}defaultIdempotencyKey(){return`stainless-node-retry-${D1e()}`}makeStatusError(t,n,r,i){return Ko.generate(t,n,r,i)}buildURL(t,n,r){const i=!this.baseURLOverridden()&&r||this.baseURL,a=L1e(t)?new URL(t):new URL(i+(i.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),o=this.defaultQuery(),c=Object.fromEntries(a.searchParams);return(!V9(o)||!V9(c))&&(n=Object.assign(Object.assign(Object.assign({},c),o),n)),typeof n=="object"&&n&&!Array.isArray(n)&&(a.search=this.stringifyQuery(n)),a.toString()}async prepareOptions(t){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!t.path.startsWith(`/${this.apiVersion}/projects/`)){const n=t.path.slice(this.apiVersion.length+1);t.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${n}`}}async prepareRequest(t,{url:n,options:r}){}get(t,n){return this.methodRequest("get",t,n)}post(t,n){return this.methodRequest("post",t,n)}patch(t,n){return this.methodRequest("patch",t,n)}put(t,n){return this.methodRequest("put",t,n)}delete(t,n){return this.methodRequest("delete",t,n)}methodRequest(t,n,r){return this.request(Promise.resolve(r).then(i=>Object.assign({method:t,path:n},i)))}request(t,n=null){return new QT(this,this.makeRequest(t,n,void 0))}async makeRequest(t,n,r){var i,a,o;const c=await t,h=(i=c.maxRetries)!==null&&i!==void 0?i:this.maxRetries;n==null&&(n=h),await this.prepareOptions(c);const{req:f,url:m,timeout:y}=await this.buildRequest(c,{retryCount:h-n});await this.prepareRequest(f,{url:m,options:c});const w="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),A=r===void 0?"":`, retryOf: ${r}`,k=Date.now();if(zo(this).debug(`[${w}] sending request`,lp({retryOfRequestLogID:r,method:c.method,url:m,options:c,headers:f.headers})),!((a=c.signal)===null||a===void 0)&&a.aborted)throw new BC;const I=new AbortController,T=await this.fetchWithTimeout(m,f,y,I).catch(UC),D=Date.now();if(T instanceof globalThis.Error){const L=`retrying, ${n} attempts remaining`;if(!((o=c.signal)===null||o===void 0)&&o.aborted)throw new BC;const q=LC(T)||/timed? ?out/i.test(String(T)+("cause"in T?String(T.cause):""));if(n)return zo(this).info(`[${w}] connection ${q?"timed out":"failed"} - ${L}`),zo(this).debug(`[${w}] connection ${q?"timed out":"failed"} (${L})`,lp({retryOfRequestLogID:r,url:m,durationMs:D-k,message:T.message})),this.retryRequest(c,n,r??w);throw zo(this).info(`[${w}] connection ${q?"timed out":"failed"} - error; no more retries left`),zo(this).debug(`[${w}] connection ${q?"timed out":"failed"} (error; no more retries left)`,lp({retryOfRequestLogID:r,url:m,durationMs:D-k,message:T.message})),q?new ZW:new mE({cause:T})}const F=`[${w}${A}] ${f.method} ${m} ${T.ok?"succeeded":"failed"} with status ${T.status} in ${D-k}ms`;if(!T.ok){const L=await this.shouldRetry(T);if(n&&L){const V=`retrying, ${n} attempts remaining`;return await q1e(T.body),zo(this).info(`${F} - ${V}`),zo(this).debug(`[${w}] response error (${V})`,lp({retryOfRequestLogID:r,url:T.url,status:T.status,headers:T.headers,durationMs:D-k})),this.retryRequest(c,n,r??w,T.headers)}const q=L?"error; no more retries left":"error; not retryable";zo(this).info(`${F} - ${q}`);const Z=await T.text().catch(V=>UC(V).message),K=F1e(Z),z=K?void 0:Z;throw zo(this).debug(`[${w}] response error (${q})`,lp({retryOfRequestLogID:r,url:T.url,status:T.status,headers:T.headers,message:z,durationMs:Date.now()-k})),this.makeStatusError(T.status,K,z,T.headers)}return zo(this).info(F),zo(this).debug(`[${w}] response start`,lp({retryOfRequestLogID:r,url:T.url,status:T.status,headers:T.headers,durationMs:D-k})),{response:T,options:c,controller:I,requestLogID:w,retryOfRequestLogID:r,startTime:k}}async fetchWithTimeout(t,n,r,i){const a=n||{},{signal:o,method:c}=a,h=E2(a,["signal","method"]),f=this._makeAbort(i);o&&o.addEventListener("abort",f,{once:!0});const m=setTimeout(f,r),y=globalThis.ReadableStream&&h.body instanceof globalThis.ReadableStream||typeof h.body=="object"&&h.body!==null&&Symbol.asyncIterator in h.body,w=Object.assign(Object.assign(Object.assign({signal:i.signal},y?{duplex:"half"}:{}),{method:"GET"}),h);c&&(w.method=c.toUpperCase());try{return await this.fetch.call(void 0,t,w)}finally{clearTimeout(m)}}async shouldRetry(t){const n=t.headers.get("x-should-retry");return n==="true"?!0:n==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,n,r,i){var a;let o;const c=i==null?void 0:i.get("retry-after-ms");if(c){const f=parseFloat(c);Number.isNaN(f)||(o=f)}const h=i==null?void 0:i.get("retry-after");if(h&&!o){const f=parseFloat(h);Number.isNaN(f)?o=Date.parse(h)-Date.now():o=f*1e3}if(o===void 0){const f=(a=t.maxRetries)!==null&&a!==void 0?a:this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(n,f)}return await $1e(o),this.makeRequest(t,n-1,r)}calculateDefaultRetryTimeoutMillis(t,n){const a=n-t,o=Math.min(.5*Math.pow(2,a),8),c=1-Math.random()*.25;return o*c*1e3}async buildRequest(t,{retryCount:n=0}={}){var r,i,a;const o=Object.assign({},t),{method:c,path:h,query:f,defaultBaseURL:m}=o,y=this.buildURL(h,f,m);"timeout"in o&&V1e("timeout",o.timeout),o.timeout=(r=o.timeout)!==null&&r!==void 0?r:this.timeout;const{bodyHeaders:w,body:A}=this.buildBody({options:o}),k=await this.buildHeaders({options:t,method:c,bodyHeaders:w,retryCount:n});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:c,headers:k},o.signal&&{signal:o.signal}),globalThis.ReadableStream&&A instanceof globalThis.ReadableStream&&{duplex:"half"}),A&&{body:A}),(i=this.fetchOptions)!==null&&i!==void 0?i:{}),(a=o.fetchOptions)!==null&&a!==void 0?a:{}),url:y,timeout:o.timeout}}async buildHeaders({options:t,method:n,bodyHeaders:r,retryCount:i}){let a={};this.idempotencyHeader&&n!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),a[this.idempotencyHeader]=t.idempotencyKey);const o=await this.authHeaders(t);let c=Lx([a,{Accept:"application/json","User-Agent":this.getUserAgent()},this._options.defaultHeaders,r,t.headers,o]);return this.validateHeaders(c),c.values}_makeAbort(t){return()=>t.abort()}buildBody({options:{body:t,headers:n}}){if(!t)return{bodyHeaders:void 0,body:void 0};const r=Lx([n]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&r.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||globalThis.ReadableStream&&t instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:t}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:G1e(t)}:typeof t=="object"&&r.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(t)}:this.encoder({body:t,headers:r})}}xE.DEFAULT_TIMEOUT=6e4;class lo extends xE{constructor(){super(...arguments),this.interactions=new pK(this)}}gK=lo;lo.GeminiNextGenAPIClient=gK;lo.GeminiNextGenAPIClientError=hc;lo.APIError=Ko;lo.APIConnectionError=mE;lo.APIConnectionTimeoutError=ZW;lo.APIUserAbortError=BC;lo.NotFoundError=nK;lo.ConflictError=rK;lo.RateLimitError=sK;lo.BadRequestError=JW;lo.AuthenticationError=eK;lo.InternalServerError=aK;lo.PermissionDeniedError=tK;lo.UnprocessableEntityError=iK;lo.toFile=eye;lo.Interactions=pK;const hye=()=>(console.warn("GEMINI_API_KEY is missing. Search suggestions will be disabled."),null),fye=async(e,t)=>{if(!e||e.length<2)return[];const n=hye();if(!n)return[];try{const r=await n.models.generateContent({model:"gemini-3.1-flash-lite",contents:`User is searching for: "${e}". Available article titles: ${t.join(", ")}. Suggest 5 relevant search terms or short phrases that help the user find what they are looking for based on the titles. Return strictly as a JSON array of strings.`,config:{responseMimeType:"application/json"}}),i=JSON.parse(r.text||"[]");return Array.isArray(i)?i:[]}catch(r){return console.error("Gemini Search Suggester Error:",r),[]}};let q9=0;function xK(e="random"){try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;const n=new t;n.state==="suspended"&&n.resume().catch(()=>null);const r=n.currentTime,i=(o,c,h,f=.25,m="sine")=>{const y=n.createOscillator(),w=n.createGain();y.type=m,y.frequency.setValueAtTime(o,c),w.gain.setValueAtTime(0,c),w.gain.linearRampToValueAtTime(f,c+.008),w.gain.exponentialRampToValueAtTime(1e-4,c+h),y.connect(w),w.connect(n.destination),y.start(c),y.stop(c+h);const A=n.createOscillator(),k=n.createGain();A.type="sine",A.frequency.setValueAtTime(o*2,c),k.gain.setValueAtTime(0,c),k.gain.linearRampToValueAtTime(f*.15,c+.005),k.gain.exponentialRampToValueAtTime(1e-4,c+h*.6),A.connect(k),k.connect(n.destination),A.start(c),A.stop(c+h*.6)};let a=e;if(a==="random"){const o=["marimba","crystal","harmonic_bell","chime_triad"];a=o[q9%o.length],q9++}switch(a){case"marimba":i(1046.5,r,.18,.22,"triangle"),i(1318.51,r+.08,.2,.22,"triangle"),i(1567.98,r+.16,.22,.25,"sine"),i(2093,r+.24,.4,.28,"sine");break;case"crystal":i(1318.51,r,.22,.2,"sine"),i(1760,r+.1,.25,.24,"sine"),i(2217.46,r+.2,.45,.28,"sine");break;case"harmonic_bell":i(880,r,.45,.18,"sine"),i(1108.73,r+.05,.45,.2,"sine"),i(1318.51,r+.1,.5,.22,"sine"),i(1760,r+.15,.6,.25,"sine");break;case"chime_triad":default:i(783.99,r,.15,.2,"sine"),i(1174.66,r+.08,.18,.22,"sine"),i(1567.98,r+.16,.22,.25,"sine"),i(1975.53,r+.24,.42,.28,"sine");break}}catch(t){console.warn("Sweet audio chime play error:",t)}}function pye(e){xK("random")}async function yK(){if(typeof window>"u"||!("Notification"in window))return!1;if("serviceWorker"in navigator)try{await navigator.serviceWorker.register("/sw.js")}catch(e){console.warn("SW Registration attempt:",e)}return Notification.permission==="granted"?!0:Notification.permission!=="denied"?await Notification.requestPermission()==="granted":!1}function c1(e,t){if(xK((t==null?void 0:t.toneStyle)||"random"),typeof navigator<"u"&&"vibrate"in navigator)try{navigator.vibrate([120,80,120])}catch{}if(typeof window>"u"||!("Notification"in window))return;const n={icon:(t==null?void 0:t.icon)||"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",badge:(t==null?void 0:t.badge)||"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",vibrate:[120,80,120],requireInteraction:!1,...t!=null&&t.image?{image:t.image}:{},...t},r=async()=>{if("serviceWorker"in navigator)try{const i=await navigator.serviceWorker.ready;if(i&&"showNotification"in i){await i.showNotification(e,n);return}}catch(i){console.warn("ServiceWorker showNotification fallback:",i)}try{new Notification(e,n)}catch(i){console.warn("Native Notification error:",i)}};Notification.permission==="granted"?r():Notification.permission!=="denied"&&Notification.requestPermission().then(i=>{i==="granted"&&r()})}const mye=({onSearch:e,activeTab:t,setActiveTab:n,isAdmin:r,onAdminClick:i,latestArticles:a=[],openAuth:o,customPagesList:c=[],setSelectedCustomPage:h,selectedCustomPage:f,onScanClick:m,onOpenChat:y})=>{const[w,A]=j.useState(!1),[k,I]=j.useState(!1),[T,D]=j.useState(""),F=async()=>{try{window.open("https://link.thelocalrent.com/v?t=1786099107&tk=07c43b29b01fcaf275f96eea938d430f","_blank"),me.success("Opening Campus Eye Mobile App Link...",{icon:"📱"})}catch{me.error("Failed to open App download link.")}},L=()=>{const ue=localStorage.getItem("campus_eye_theme")||"light";let Se="light";ue==="light"?Se="dark":ue==="dark"?Se="sepia":Se="light",localStorage.setItem("campus_eye_theme",Se),window.dispatchEvent(new CustomEvent("theme-changed",{detail:{theme:Se}}));const Xe=Se.charAt(0).toUpperCase()+Se.slice(1);me.success(`${Xe} theme applied successfully.`)},[q,Z]=j.useState([]),[K,z]=j.useState([]),[B,V]=j.useState(!1),[$,Q]=j.useState(Ne.currentUser),[Y,G]=j.useState(!navigator.onLine);j.useEffect(()=>{const ue=()=>G(!1),Se=()=>G(!0);return window.addEventListener("online",ue),window.addEventListener("offline",Se),()=>{window.removeEventListener("online",ue),window.removeEventListener("offline",Se)}},[]),j.useEffect(()=>{const ue=Ne.onAuthStateChanged(Xe=>{Q(Xe)}),Se=()=>A(!0);return window.addEventListener("openGlobalSearch",Se),()=>{ue(),window.removeEventListener("openGlobalSearch",Se)}},[]);const[he,te]=j.useState([]),[le,ve]=j.useState([]),[ke,Be]=j.useState([]),[J,ie]=j.useState(!1),[xe,ae]=j.useState("inbox"),[Fe,pt]=j.useState("all"),[Ue,Ct]=j.useState(!1),[Tt,ht]=j.useState(!1),[Ye,Yt]=j.useState({}),[dt,sn]=j.useState({}),[pn,Fn]=j.useState({});j.useEffect(()=>{const ue=()=>{ie(!1)};return window.addEventListener("open-imessage-friend",ue),()=>window.removeEventListener("open-imessage-friend",ue)},[]);const Ft=(ue,Se)=>{Se&&Se.stopPropagation(),Yt(Xe=>({...Xe,[ue]:!Xe[ue]}))},Dt=async(ue,Se)=>{var gn;Se&&Se.stopPropagation();const Xe=(gn=dt[ue.id])==null?void 0:gn.trim(),Vt=ue.senderId||(ue.type==="direct_message"?ue.userId:null);if(!(!Xe||!Vt||!$)){Fn(xn=>({...xn,[ue.id]:!0}));try{const xn=$.displayName||"Campus Peer",yn=($.displayName||"member").toLowerCase().replace(/\s+/g,"");await ur(it(pe,"notifications"),{userId:Vt,senderId:$.uid,senderName:xn,senderUsername:yn,senderPhotoURL:$.photoURL||"",title:`💬 Direct Reply from ${xn}`,message:Xe,type:"direct_message",canReply:!0,used:!1,replyToTitle:ue.title||"Inbox Message",createdAt:new Date}),me.success(`Reply sent to ${ue.senderName||"friend"}!`,{icon:"📩"}),sn(gt=>({...gt,[ue.id]:""})),Bt(ue)}catch(xn){me.error("Failed to send reply: "+xn.message)}finally{Fn(xn=>({...xn,[ue.id]:!1}))}}},Ht=ue=>{if(!ue)return"Recent";const Se=ue instanceof Date?ue:new Date(ue);if(isNaN(Se.getTime()))return"Recent";const Vt=Math.floor((new Date().getTime()-Se.getTime())/1e3);if(Vt<60)return"Just now";const gn=Math.floor(Vt/60);if(gn<60)return`${gn}m ago`;const xn=Math.floor(gn/60);if(xn<24)return`${xn}h ago`;const yn=Math.floor(xn/24);return yn<7?`${yn}d ago`:Se.toLocaleDateString([],{month:"short",day:"numeric"})},Ze=ue=>{const Se=ue.type==="direct_message",Xe=ue.userId==="all"||ue.type==="broadcast"||ue.type==="broadcast_announcement"||ue.isBroadcast,Vt=ue.type==="invite"||ue.type==="lounge_invite",gn=!!ue.code||ue.type==="ticket"||ue.type==="ticket_code"||ue.type==="pass",xn=ue.forAdmin||ue.type==="unlimited_posting_request"||ue.type==="mega_ai_query"||ue.type==="admin_alert",yn=ue.type==="mega_ai_reply"||ue.type==="admin_mega_reply"||ue.type==="mega_ai",gt=ue.type==="like"||ue.type==="reaction"||ue.title&&ue.title.toLowerCase().includes("like"),Tn=ue.type==="comment"||ue.type==="reply"||ue.type==="dispatch_reply"||ue.title&&(ue.title.toLowerCase().includes("comment")||ue.title.toLowerCase().includes("replied")||ue.title.toLowerCase().includes("dispatch")),Nt=ue.type==="follow"||ue.type==="follower",Ae=ue.type==="article"||ue.type==="new_post";return Se?{category:"social",typeLabel:"💬 DIRECT INBOX",borderClass:"border-l-4 border-l-indigo-600",bgClass:ue.used?"bg-indigo-50/20 border-indigo-200/50 opacity-75":"bg-indigo-50/80 border-indigo-300 shadow-2xs",badgeClass:"bg-indigo-600 text-white font-black",iconBg:"bg-indigo-100 text-indigo-700",IconComponent:Js}:Xe?{category:"broadcast",typeLabel:"📢 BROADCAST",borderClass:"border-l-4 border-l-amber-500",bgClass:ue.used?"bg-amber-50/20 border-amber-200/50 opacity-75":"bg-amber-50/70 border-amber-300 shadow-2xs",badgeClass:"bg-amber-500 text-white font-black",iconBg:"bg-amber-100 text-amber-700",IconComponent:hu}:Vt?{category:"social",typeLabel:"🤝 INVITE",borderClass:"border-l-4 border-l-emerald-500",bgClass:ue.used?"bg-emerald-50/20 border-emerald-200/50 opacity-75":"bg-emerald-50/70 border-emerald-300 shadow-2xs",badgeClass:"bg-emerald-600 text-white font-black",iconBg:"bg-emerald-100 text-emerald-700",IconComponent:yp}:gn?{category:"passes",typeLabel:"🎟️ PASS KEY",borderClass:"border-l-4 border-l-purple-500",bgClass:ue.used?"bg-purple-50/20 border-purple-200/50 opacity-75":"bg-purple-50/70 border-purple-300 shadow-2xs",badgeClass:"bg-purple-600 text-white font-black",iconBg:"bg-purple-100 text-purple-700",IconComponent:No}:xn?{category:"system",typeLabel:"🛡️ ADMIN ALERT",borderClass:"border-l-4 border-l-red-600",bgClass:ue.used?"bg-red-50/20 border-red-200/50 opacity-75":"bg-red-50/80 border-red-300 shadow-2xs",badgeClass:"bg-red-700 text-white font-black",iconBg:"bg-red-100 text-red-700",IconComponent:hie}:yn?{category:"system",typeLabel:"🤖 MEGA AI",borderClass:"border-l-4 border-l-cyan-500",bgClass:ue.used?"bg-cyan-50/20 border-cyan-200/50 opacity-75":"bg-cyan-50/70 border-cyan-300 shadow-2xs",badgeClass:"bg-cyan-700 text-white font-black",iconBg:"bg-cyan-100 text-cyan-700",IconComponent:One}:gt?{category:"social",typeLabel:"❤️ REACTION",borderClass:"border-l-4 border-l-rose-500",bgClass:ue.used?"bg-rose-50/20 border-rose-200/50 opacity-75":"bg-rose-50/70 border-rose-300 shadow-2xs",badgeClass:"bg-rose-600 text-white font-black",iconBg:"bg-rose-100 text-rose-700",IconComponent:ku}:Tn?{category:"social",typeLabel:"💬 DISPATCH REPLY",borderClass:"border-l-4 border-l-indigo-500",bgClass:ue.used?"bg-indigo-50/20 border-indigo-200/50 opacity-75":"bg-indigo-50/70 border-indigo-300 shadow-2xs",badgeClass:"bg-indigo-600 text-white font-black",iconBg:"bg-indigo-100 text-indigo-700",IconComponent:G0}:Nt?{category:"social",typeLabel:"👥 FOLLOWER",borderClass:"border-l-4 border-l-blue-500",bgClass:ue.used?"bg-blue-50/20 border-blue-200/50 opacity-75":"bg-blue-50/70 border-blue-300 shadow-2xs",badgeClass:"bg-blue-600 text-white font-black",iconBg:"bg-blue-100 text-blue-700",IconComponent:L1}:Ae?{category:"broadcast",typeLabel:"📰 FRESH STORY",borderClass:"border-l-4 border-l-sky-500",bgClass:ue.used?"bg-sky-50/20 border-sky-200/50 opacity-75":"bg-sky-50/70 border-sky-300 shadow-2xs",badgeClass:"bg-sky-600 text-white font-black",iconBg:"bg-sky-100 text-sky-700",IconComponent:zh}:{category:"social",typeLabel:ue.type?`🔔 ${ue.type.toUpperCase()}`:"🔔 NOTIFICATION",borderClass:"border-l-4 border-l-gray-400",bgClass:ue.used?"bg-gray-50/40 border-gray-150 opacity-75":"bg-white border-gray-200 shadow-2xs",badgeClass:"bg-gray-800 text-white font-black",iconBg:"bg-gray-100 text-gray-700",IconComponent:Su}},[Wt,It]=j.useState(()=>{try{const ue=localStorage.getItem("clicked_notification_links");return ue?JSON.parse(ue):{}}catch{return{}}}),ln=ue=>{ue&&It(Se=>{const Xe={...Se,[ue]:!0};try{localStorage.setItem("clicked_notification_links",JSON.stringify(Xe))}catch(Vt){console.warn("Could not save clicked links:",Vt)}return Xe})},[Kn,un]=j.useState([]),[xr,Ve]=j.useState([]),[Ot,nn]=j.useState([]),[mn,dr]=j.useState([]),[hr,Ui]=j.useState({}),[$n,be]=j.useState("");j.useEffect(()=>{if(!$){un([]),Ui({}),Ve([]),nn([]),dr([]);return}(async()=>{try{const Se=Qt(it(pe,"users"),Pi(50)),Xe=Qt(it(pe,"invitations"),Pi(50)),Vt=Qt(it(pe,"posts"),Pi(45)),gn=Qt(it(pe,"adverts"),Pi(30)),xn=Qt(it(pe,"pinned_announcements"),Pi(15)),[yn,gt,Tn,Nt,Ae]=await Promise.all([vn(Se),vn(Xe),vn(Vt),vn(gn),vn(xn)]),yt=yn.docs.map(Pt=>({uid:Pt.id,...Pt.data()})).filter(Pt=>Pt.uid!==($==null?void 0:$.uid));un(yt);const cn={};gt.docs.forEach(Pt=>{const Sn=Pt.data();Sn.senderId===($==null?void 0:$.uid)&&(cn[Sn.receiverId]=!0)}),Ui(cn),Ve(Tn.docs.map(Pt=>({id:Pt.id,...Pt.data()}))),nn(Nt.docs.map(Pt=>({id:Pt.id,...Pt.data()}))),dr(Ae.docs.map(Pt=>({id:Pt.id,...Pt.data()})))}catch(Se){console.warn("Silent ignored database initial fetches inside navbar:",Se)}})()},[$]);const je=async ue=>{var Xe,Vt;if(!$){me.error("Please sign in to invite peers!");return}const Se=`${$.uid}_${ue.uid}`;try{Ui(gn=>({...gn,[ue.uid]:!0})),await Hr(ot(pe,"invitations",Se),{id:Se,senderId:$.uid,senderName:$.displayName||((Xe=$.email)==null?void 0:Xe.split("@")[0])||"Peer",senderPhotoURL:$.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent($.displayName||"Peer")}&background=random`,receiverId:ue.uid,receiverName:ue.displayName||((Vt=ue.email)==null?void 0:Vt.split("@")[0])||"Peer",status:"pending",createdAt:Bn()}),me.success(`Lounge invite sent to @${(ue.displayName||"peer").toLowerCase().replace(/\s+/g,"")}!`,{icon:"🚀"})}catch(gn){me.error("Failed to send invite: "+gn.message)}};j.useEffect(()=>{if(!$){te([]),ve([]);return}const ue=Qt(it(pe,"notifications"),Nr("userId","==",$.uid));let Se=!0,Xe={},Vt={};const gn=()=>{const yt={...Xe,...Vt},cn=Object.values(yt);cn.sort((Pt,Sn)=>Sn.createdAt.getTime()-Pt.createdAt.getTime()),ve(cn)},xn=di(ue,yt=>{yt.docs.forEach(cn=>{var Sn;const Pt=cn.data();Xe[cn.id]={id:cn.id,...Pt,createdAt:(Sn=Pt.createdAt)!=null&&Sn.toDate?Pt.createdAt.toDate():new Date(Pt.createdAt||Date.now())}}),Se||yt.docChanges().forEach(cn=>{if(cn.type==="added"){const Pt=cn.doc.data();c1(Pt.title||"✨ Campus Eye Notification",{body:Pt.message||"You have a new dispatch notification in your inbox.",senderId:Pt.senderId,senderName:Pt.senderName,id:cn.doc.id,tag:`notif-${cn.doc.id}`})}}),Se=!1,gn()},yt=>{console.warn("Silent notification snapshot error:",yt)}),yn=Qt(it(pe,"notifications"),Nr("userId","==","all"));let gt=!0;const Tn=di(yn,yt=>{yt.docs.forEach(cn=>{var Sn;const Pt=cn.data();Xe[cn.id]={id:cn.id,...Pt,createdAt:(Sn=Pt.createdAt)!=null&&Sn.toDate?Pt.createdAt.toDate():new Date(Pt.createdAt||Date.now())}}),gt||yt.docChanges().forEach(cn=>{if(cn.type==="added"){const Pt=cn.doc.data();c1(Pt.title||"📢 Campus Eye Broadcast",{body:Pt.message||"New broadcast announcement released on Campus Eye."})}}),gt=!1,gn()},yt=>{console.warn("Silent broadcast notification snapshot error:",yt)});let Nt=null;if(r){let yt=!0;const cn=Qt(it(pe,"notifications"),Nr("forAdmin","==",!0));Nt=di(cn,Pt=>{Pt.docs.forEach(Sn=>{var xi;const _r=Sn.data();Vt[Sn.id]={id:Sn.id,..._r,createdAt:(xi=_r.createdAt)!=null&&xi.toDate?_r.createdAt.toDate():new Date(_r.createdAt||Date.now())}}),yt||Pt.docChanges().forEach(Sn=>{if(Sn.type==="added"){const _r=Sn.doc.data();c1(_r.title||"🛡️ Admin Alert",{body:_r.message||"New system alert or dispatch query in Admin Console."})}}),yt=!1,gn()},Pt=>{console.warn("Silent admin notification snapshot error:",Pt)})}const Ae=Qt(it(pe,"invitations"),Nr("receiverId","==",$.uid),Nr("status","==","pending")),tn=di(Ae,yt=>{const cn=yt.docs.map(Pt=>({id:Pt.id,...Pt.data()}));te(cn)},yt=>{console.warn("Silent invites snapshot error:",yt)});return()=>{xn(),Tn(),Nt&&Nt(),tn()}},[$]),j.useEffect(()=>{if(!$){Be([]);return}const ue=Qt(it(pe,"direct_messages"),Nr("senderId","==",$.uid)),Se=Qt(it(pe,"direct_messages"),Nr("receiverId","==",$.uid));let Xe=[],Vt=[];const gn=()=>{const gt=[...Xe,...Vt],Tn=new Map;gt.forEach(Ae=>{var xi,rs;const tn=Ae.senderId===$.uid,yt=tn?Ae.receiverId:Ae.senderId;if(!yt)return;const cn=(xi=Ae.createdAt)!=null&&xi.toDate?Ae.createdAt.toDate():(rs=Ae.createdAt)!=null&&rs.seconds?new Date(Ae.createdAt.seconds*1e3):new Date(Ae.createdAt||Date.now()),Pt=Tn.get(yt),Sn=Pt!=null&&Pt.lastTimestamp?Pt.lastTimestamp instanceof Date?Pt.lastTimestamp:new Date(Pt.lastTimestamp):new Date(0),_r=!tn&&!Ae.read;if(!Pt||cn.getTime()>Sn.getTime()){const mi=Kn.find(fa=>fa.uid===yt);Tn.set(yt,{peerUid:yt,peerName:(mi==null?void 0:mi.displayName)||Ae.senderName||"Campus Friend",peerUsername:(mi==null?void 0:mi.username)||Ae.senderUsername||"peer",peerPhoto:(mi==null?void 0:mi.photoURL)||Ae.senderPhotoURL||`https://api.dicebear.com/7.x/bottts/svg?seed=${yt}`,lastMessage:Ae.text||(Ae.imageUrl?"📷 Photo Attachment":"Message"),lastTimestamp:cn,unreadCount:((Pt==null?void 0:Pt.unreadCount)||0)+(_r?1:0)})}else _r&&(Pt.unreadCount+=1)});const Nt=Array.from(Tn.values()).sort((Ae,tn)=>tn.lastTimestamp.getTime()-Ae.lastTimestamp.getTime());Be(Nt)},xn=di(ue,gt=>{Xe=gt.docs.map(Tn=>({id:Tn.id,...Tn.data()})),gn()},gt=>console.warn("Sent direct_messages sub error:",gt)),yn=di(Se,gt=>{Vt=gt.docs.map(Tn=>({id:Tn.id,...Tn.data()})),gn()},gt=>console.warn("Recv direct_messages sub error:",gt));return()=>{xn(),yn()}},[$,Kn]);const ze=async ue=>{try{await Hn(ot(pe,"invitations",ue.id),{status:"accepted"});const Se=Bn();await Hr(ot(pe,"follows",`${$==null?void 0:$.uid}_${ue.senderId}`),{followerId:$==null?void 0:$.uid,followedId:ue.senderId,createdAt:Se}),await Hr(ot(pe,"follows",`${ue.senderId}_${$==null?void 0:$.uid}`),{followerId:ue.senderId,followedId:$==null?void 0:$.uid,createdAt:Se}),me.success(`Connected in Lounge with @${ue.senderName.toLowerCase().replace(/\s+/g,"")}!`,{icon:"🤝"}),n("posts"),ie(!1)}catch(Se){me.error("Failed to accept invitation: "+Se.message)}},tt=async ue=>{try{await ni(ot(pe,"invitations",ue.id)),me.success("Invitation declined.")}catch(Se){me.error("Failed to decline: "+Se.message)}},fn=async(ue,Se)=>{Se==null||Se.stopPropagation();try{await ni(ot(pe,"notifications",ue)),ve(Xe=>Xe.filter(Vt=>Vt.id!==ue)),me.success("Notification removed",{icon:"🗑️"})}catch(Xe){me.error("Failed to delete notification: "+Xe.message)}},Bt=async ue=>{if(!ue.used)try{await Hn(ot(pe,"notifications",ue.id),{used:!0}),ve(Se=>Se.map(Xe=>Xe.id===ue.id?{...Xe,used:!0}:Xe))}catch(Se){console.warn("Failed to mark notification read:",Se)}},jn=async ue=>{if(Bt(ue),ie(!1),ue.type==="direct_message"||ue.senderId&&!ue.postId&&!ue.articleId){const Se={uid:ue.senderId,displayName:ue.senderName||"Campus Peer",username:ue.senderUsername||(ue.senderName||"peer").toLowerCase().replace(/\s+/g,""),photoURL:ue.senderPhotoURL||""};y&&y(Se),window.dispatchEvent(new CustomEvent("open-imessage-friend",{detail:Se}));return}ue.postId?(n("posts"),setTimeout(()=>{const Se=ue.commentId?`comment-${ue.commentId}`:`post-card-${ue.postId}`,Xe=document.getElementById(Se)||document.getElementById(`post-card-${ue.postId}`);Xe&&(Xe.scrollIntoView({behavior:"smooth",block:"center"}),Xe.classList.add("ring-4","ring-amber-500","ring-offset-2"),setTimeout(()=>Xe.classList.remove("ring-4","ring-amber-500","ring-offset-2"),3500))},500)):ue.articleId&&(n("home"),setTimeout(()=>{const Se=ue.commentId?`comment-${ue.commentId}`:`article-${ue.articleId}`,Xe=document.getElementById(Se)||document.getElementById(`article-${ue.articleId}`);Xe&&(Xe.scrollIntoView({behavior:"smooth",block:"center"}),Xe.classList.add("ring-4","ring-amber-500","ring-offset-2"),setTimeout(()=>Xe.classList.remove("ring-4","ring-amber-500","ring-offset-2"),3500))},500))},jt=async()=>{if($)if(xe==="inbox"){if(le.length===0||!window.confirm("Are you sure you want to completely delete all inbox alerts?"))return;try{await Promise.all(le.map(ue=>ni(ot(pe,"notifications",ue.id)))),me.success("Inbox notifications cleared!",{icon:"🗑️"})}catch(ue){me.error("Failed to empty inbox: "+ue.message)}}else{if(he.length===0||!window.confirm("Are you sure you want to dismiss all pending invites?"))return;try{await Promise.all(he.map(ue=>ni(ot(pe,"invitations",ue.id)))),me.success("Invites dismissed!",{icon:"🗑️"})}catch(ue){me.error("Failed to empty invites: "+ue.message)}}};j.useEffect(()=>{const ue=(Xe,Vt)=>{const gn=Xe?Xe.slice(0,2).trim().toUpperCase():"CE",xn=(Vt==null?void 0:Vt.toLowerCase())||"news";let yn="%23ef4444";return xn==="sports"&&(yn="%233b82f6"),xn==="opinion"&&(yn="%2310b981"),xn==="lifestyle"&&(yn="%238b5cf6"),xn==="entertainment"&&(yn="%23f59e0b"),`data:image/svg+xml;utf8,${gn}`},Se=setTimeout(async()=>{if(T.trim().length>1){const Xe=T.toLowerCase(),Vt=[];if(a.forEach(gt=>{var cn,Pt,Sn,_r,xi,rs;const Tn=(cn=gt.title)==null?void 0:cn.toLowerCase().includes(Xe),Nt=(Pt=gt.content)==null?void 0:Pt.toLowerCase().includes(Xe),Ae=(Sn=gt.summary)==null?void 0:Sn.toLowerCase().includes(Xe),tn=(_r=gt.category)==null?void 0:_r.toLowerCase().includes(Xe),yt=(xi=gt.authorName)==null?void 0:xi.toLowerCase().includes(Xe);(Tn||Nt||Ae||tn||yt)&&Vt.push({id:gt.id,type:"article",title:gt.title,subtitle:gt.summary||((rs=gt.content)==null?void 0:rs.slice(0,80)),category:gt.category||"Opinion",imageUrl:gt.featuredImageUrl||ue(gt.title,gt.category),originalObject:gt})}),xr.forEach(gt=>{var tn,yt,cn,Pt;const Tn=(tn=gt.text)==null?void 0:tn.toLowerCase().includes(Xe),Nt=(yt=gt.authorName)==null?void 0:yt.toLowerCase().includes(Xe),Ae=(cn=gt.category)==null?void 0:cn.toLowerCase().includes(Xe);(Tn||Nt||Ae)&&Vt.push({id:gt.id,type:"post",title:((Pt=gt.text)==null?void 0:Pt.slice(0,50))||"Lounge Conversation",subtitle:`Active discussion by @${(gt.authorName||"peer").toLowerCase().replace(/\s+/g,"")}`,category:`Forum • ${gt.category||"Opinion"}`,imageUrl:gt.imageUrl||gt.authorPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(gt.authorName||"Peer")}`,originalObject:gt})}),Kn.forEach(gt=>{var tn,yt,cn,Pt;const Tn=(tn=gt.displayName)==null?void 0:tn.toLowerCase().includes(Xe),Nt=(yt=gt.email)==null?void 0:yt.toLowerCase().includes(Xe),Ae=(cn=gt.role)==null?void 0:cn.toLowerCase().includes(Xe);(Tn||Nt||Ae)&&Vt.push({id:gt.uid,type:"user",title:gt.displayName||((Pt=gt.email)==null?void 0:Pt.split("@")[0])||"User Profile",subtitle:`${gt.role==="admin"?"🛡️ Campus Administrator":"🎓 Lounge Member"} • @${(gt.displayName||"user").toLowerCase().replace(/\s+/g,"")}`,category:gt.role==="admin"?"Admins":"Users",imageUrl:gt.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(gt.displayName||"u")}`,originalObject:gt})}),Ot.forEach(gt=>{var tn,yt,cn;const Tn=(tn=gt.title)==null?void 0:tn.toLowerCase().includes(Xe),Nt=(yt=gt.brand)==null?void 0:yt.toLowerCase().includes(Xe),Ae=(cn=gt.description)==null?void 0:cn.toLowerCase().includes(Xe);(Tn||Nt||Ae)&&Vt.push({id:gt.id,type:"advert",title:gt.title||"Brand Advertisement Offer",subtitle:`${gt.brand||"Promotional Offer"} — ${gt.description||"Sponsored partnership dispatch"}`,category:"Business Adverts",imageUrl:gt.imageUrl||ue(gt.title,"Business Adverts"),originalObject:gt})}),mn.forEach(gt=>{var Ae,tn;const Tn=(Ae=gt.title)==null?void 0:Ae.toLowerCase().includes(Xe),Nt=(tn=gt.description)==null?void 0:tn.toLowerCase().includes(Xe);(Tn||Nt)&&Vt.push({id:gt.id,type:"pinned",title:gt.title||"Pinned notice announcement",subtitle:gt.description||"Pinned global campus broadcast notice",category:"Pinned Highlights",imageUrl:gt.imageUrl||ue(gt.title,"Pinned Highlights"),originalObject:gt})}),c.forEach(gt=>{var Ae,tn;const Tn=(Ae=gt.title)==null?void 0:Ae.toLowerCase().includes(Xe),Nt=(tn=gt.content)==null?void 0:tn.toLowerCase().includes(Xe);(Tn||Nt)&&Vt.push({id:gt.id,type:"customPage",title:gt.title||"Dynamic Publication Tab",subtitle:"Custom institutional publication page",category:"Custom Pages",imageUrl:ue(gt.title,"Custom Pages"),originalObject:gt})}),Vt.length<5)try{(await vn(Qt(it(pe,"articles"),Pi(80)))).docs.forEach(Tn=>{var tn,yt,cn,Pt,Sn,_r;const Nt={id:Tn.id,...Tn.data()};if(!Vt.some(xi=>xi.id===Tn.id)){const xi=(tn=Nt.title)==null?void 0:tn.toLowerCase().includes(Xe),rs=(yt=Nt.content)==null?void 0:yt.toLowerCase().includes(Xe),mi=(cn=Nt.summary)==null?void 0:cn.toLowerCase().includes(Xe),fa=(Pt=Nt.category)==null?void 0:Pt.toLowerCase().includes(Xe),is=(Sn=Nt.authorName)==null?void 0:Sn.toLowerCase().includes(Xe);if((xi||rs||mi||fa||is)&&(Vt.push({id:Tn.id,type:"article",title:Nt.title,subtitle:Nt.summary||((_r=Nt.content)==null?void 0:_r.slice(0,80)),category:Nt.category||"Opinion",imageUrl:Nt.featuredImageUrl||ue(Nt.title,Nt.category),originalObject:Nt}),Nt.title)){const hi=Nt.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),Wr=`${window.location.origin}/articles=${hi}/${Tn.id}`;fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:Wr,title:Nt.title,image:Nt.featuredImageUrl})}).catch(()=>{})}}})}catch(gt){console.warn("Deep Firestore search lookup notice:",gt)}const gn=["campus","eye","media","campuseyemedia"];if(Xe.split(/\s+/).filter(Boolean).some(gt=>gn.includes(gt))&&Vt.length<5&&a.forEach(gt=>{var Nt;!Vt.some(Ae=>Ae.id===gt.id&&Ae.type==="article")&&Vt.length<10&&Vt.push({id:gt.id,type:"article",title:gt.title,subtitle:gt.summary||((Nt=gt.content)==null?void 0:Nt.slice(0,80)),category:gt.category||"Feature",imageUrl:gt.featuredImageUrl||ue(gt.title,gt.category),originalObject:gt})}),Z(Vt.slice(0,12)),w){V(!0);const gt=a.map(Nt=>Nt.title).concat(Vt.slice(0,3).map(Nt=>Nt.title)),Tn=await fye(T,gt);z(Tn),V(!1)}}else Z([]),z([]);e(T)},500);return()=>clearTimeout(Se)},[T,a,xr,Kn,Ot,mn,c,e,w]);const on=()=>{D(""),Z([]),e("")},Ir=ue=>{if(D(""),Z([]),A(!1),e(""),ue.type==="article"){const Se=new CustomEvent("selectArticle",{detail:ue.originalObject});window.dispatchEvent(Se)}else if(ue.type==="customPage")h&&h(ue.originalObject);else if(ue.type==="post"){const Se=new CustomEvent("selectPost",{detail:ue.originalObject});window.dispatchEvent(Se)}else if(ue.type==="user"){const Se=new CustomEvent("selectUser",{detail:ue.originalObject});window.dispatchEvent(Se)}else if(ue.type==="advert")if(ue.originalObject.link)window.open(ue.originalObject.link,"_blank","noopener,noreferrer");else{const Se=new CustomEvent("selectAdvert",{detail:ue.originalObject});window.dispatchEvent(Se)}else if(ue.type==="pinned")if(ue.originalObject.link)window.open(ue.originalObject.link,"_blank","noopener,noreferrer");else{const Se=new CustomEvent("selectPinned",{detail:ue.originalObject});window.dispatchEvent(Se)}},pr=se.useMemo(()=>{const ue=xn=>{if(!xn)return"";let yn=xn.toLowerCase().trim().replace(/[^a-z0-9]/g,"");return(yn==="campusnews"||yn==="news"||yn==="campus-news")&&(yn="news"),(yn==="sports"||yn==="sport")&&(yn="sport"),yn},Xe=Array.from(new Set(a.map(xn=>xn.category).filter(Boolean))).map(xn=>({id:ue(xn),label:xn})),Vt=new Set,gn=[];return gn.push({id:"for-you",label:"For You"}),Vt.add("for-you"),gn.push({id:"home",label:"Home"}),Vt.add("home"),Xe.forEach(xn=>{!Vt.has(xn.id)&&gn.length<6&&(Vt.add(xn.id),gn.push(xn))}),gn.length<=2?[{id:"for-you",label:"For You"},{id:"home",label:"Home"},{id:"news",label:"News"},{id:"sport",label:"Sports"},{id:"business",label:"Business"}]:gn},[a]);return s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"fixed top-0 left-0 right-0 z-50 bg-white/40 dark:bg-neutral-950/40 backdrop-blur-xl border-b border-white/20 dark:border-white/10 shadow-lg shadow-black/5 backdrop-saturate-150 transition-all duration-300",children:[s.jsxs("div",{className:"w-full max-w-[1680px] xl:max-w-[1780px] 2xl:max-w-[1880px] mx-auto px-2 sm:px-4 lg:px-6 xl:px-8 h-8.5 sm:h-9.5 flex items-center justify-between",children:[s.jsxs("div",{onClick:()=>{n("home"),h&&h(null),window.scrollTo({top:0,behavior:"smooth"})},className:"flex items-center gap-1 sm:gap-1.5 cursor-pointer hover:opacity-80 transition-opacity select-none h-6.5 sm:h-7.5",title:"Campus Eye Media - Scroll to top",children:[s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"Campus Eye Logo",className:"h-5 w-5 sm:h-6 sm:w-6 rounded-full border border-gray-950 bg-white object-cover aspect-square shrink-0",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"flex flex-col justify-center text-left select-none -space-y-1",children:[s.jsxs("span",{className:"text-[10.5px] sm:text-[11.5px] md:text-[12.5px] font-serif font-black tracking-custom italic",children:[s.jsx("span",{className:"text-red-650",children:"Campus"})," ",s.jsx("span",{className:"text-blue-600",children:"Eye"})]}),s.jsx("span",{className:"text-[5.5px] sm:text-[6px] md:text-[6.5px] font-sans font-extrabold uppercase tracking-[0.22em] text-black text-right pr-0.5 block select-none",children:"Media"})]})]}),s.jsx("nav",{className:"hidden lg:flex items-center space-x-1",children:pr.map(ue=>{const Se=ue.id==="home";return s.jsxs(se.Fragment,{children:[s.jsx("button",{onClick:()=>{n(ue.id),h&&h(null)},className:Ge("text-[10px] font-black tracking-wider px-2.5 py-1.5 rounded-full transition-all duration-200 uppercase cursor-pointer",t===ue.id&&!f?"bg-gray-100 text-gray-950 font-black":"text-gray-500 hover:text-gray-950 hover:bg-gray-50"),children:ue.label}),Se&&c&&c.length>0&&(()=>{var Tn;const Xe=c[0],gn=Date.now()-((Tn=Xe.createdAt)!=null&&Tn.seconds?Xe.createdAt.seconds*1e3:Date.now())<10080*60*1e3,xn=(f==null?void 0:f.id)===Xe.id,yn=c.slice(1),gt=yn.find(Nt=>(f==null?void 0:f.id)===Nt.id);return s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsxs("button",{onClick:()=>h&&h(Xe),className:Ge("text-[9.5px] font-black tracking-wider px-2.5 py-1.5 rounded-full uppercase flex items-center gap-1.5 cursor-pointer transition-all duration-200 relative border shrink-0",xn?"bg-red-650 border-red-650 text-white shadow-xs":"bg-red-50/70 border-red-150 text-red-650 hover:bg-red-100/40"),title:`Open ${Xe.name} pop-out`,children:[Xe.svgIcon?s.jsx("span",{className:Ge("shrink-0 w-2.5 h-2.5 flex items-center justify-center",xn?"text-white":"text-red-655"),dangerouslySetInnerHTML:{__html:Xe.svgIcon.includes("${Xe.svgIcon}`}}):s.jsx("span",{className:Ge("w-1 h-1 rounded-full shrink-0",xn?"bg-white":"bg-red-655")}),s.jsx("span",{children:Xe.name}),gn&&s.jsx("span",{className:"absolute -top-1 -right-1 bg-red-600 text-white text-[5px] font-bold uppercase px-1 py-0.2 rounded-full scale-90 select-none shrink-0",children:"New"})]}),yn.length>0&&s.jsxs("div",{className:"relative shrink-0 z-[999]",children:[s.jsxs("button",{onClick:()=>Ct(!Ue),className:Ge("text-[9.5px] font-black tracking-wider px-2.5 py-1.5 rounded-full uppercase flex items-center gap-1 cursor-pointer transition-all duration-250 border",gt?"bg-red-650 border-red-650 text-white shadow-xs":"bg-gray-100 border-gray-200 text-gray-700 hover:bg-gray-150"),children:[s.jsx("span",{children:"More"}),gt&&s.jsxs("span",{className:"text-[8px] opacity-90 mx-0.5",children:["(",gt.name,")"]}),s.jsx("svg",{className:Ge("w-2.5 h-2.5 transition-transform duration-200",Ue?"rotate-180":"rotate-0"),fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),s.jsx(ar,{children:Ue&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[49] bg-transparent",onClick:()=>Ct(!1)}),s.jsx(Kt.div,{initial:{opacity:0,scale:.95,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:4},transition:{duration:.12},className:"absolute left-0 mt-1.5 w-44 bg-white border border-gray-150 rounded-xl shadow-2xl z-[99999] py-1 overflow-hidden",children:yn.map(Nt=>{const Ae=(f==null?void 0:f.id)===Nt.id;return s.jsxs("button",{onClick:()=>{h&&h(Nt),Ct(!1)},className:Ge("w-full text-left px-3.5 py-2 hover:bg-gray-50 text-[9px] font-black uppercase tracking-wider flex items-center justify-between transition-colors",Ae?"text-red-650 bg-red-50/40":"text-gray-750 hover:text-black"),children:[s.jsx("span",{className:"truncate pr-2",children:Nt.name}),Ae&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-650 shrink-0"})]},Nt.id)})})]})})]})]},"custom-nav-group")})()]},ue.id)})}),s.jsxs("div",{className:"flex items-center gap-2.5 sm:gap-3 relative",children:[$&&r&&s.jsx("button",{onClick:m,className:"text-gray-750 hover:text-red-650 p-1 rounded-full hover:bg-gray-100/60 transition-colors flex items-center justify-center cursor-pointer",title:"Passes & Ticket Verification",children:s.jsx(bk,{size:14,className:"text-gray-700 hover:text-red-650"})}),s.jsx("button",{onClick:L,className:"text-gray-750 hover:text-red-650 p-1 rounded-full hover:bg-gray-100/60 transition-colors flex items-center justify-center cursor-pointer",title:"Switch Theme",children:s.jsx(jpe,{size:15})}),s.jsx("button",{onClick:()=>A(!0),className:"text-gray-750 hover:text-red-650 p-1 rounded-full hover:bg-gray-100/60 transition-colors flex items-center justify-center cursor-pointer",title:"Search Stories & Communities",children:s.jsx(Cpe,{size:15})}),$&&s.jsxs("div",{className:"relative",children:[(()=>{const ue=le.filter(Xe=>!Xe.used).length,Se=ue+he.length;return s.jsxs("button",{onClick:()=>ie(!J),className:"text-gray-700 hover:text-gray-950 p-1.5 rounded-full hover:bg-gray-50 transition-all flex items-center justify-center relative cursor-pointer font-sans",title:`${he.length} Invites, ${ue} Unread Alerts`,children:[s.jsx(Su,{size:14,className:Ge(Se>0&&"animate-bounce text-red-650")}),Se>0&&s.jsx("span",{className:"absolute -top-1 -right-1.5 px-1 py-0.2 bg-red-650 text-white font-black text-[8px] leading-none rounded-full border-2 border-white shadow-xs flex items-center justify-center min-w-[15px] h-[15px]",children:Se>99?"99+":Se})]})})(),s.jsx(ar,{children:J&&s.jsxs(Kt.div,{initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},className:"fixed sm:absolute top-14 sm:top-auto left-2.5 sm:left-auto right-2.5 sm:right-0 mt-0 sm:mt-2.5 w-[calc(100vw-1.25rem)] sm:w-96 max-w-sm sm:max-w-md bg-white border border-gray-150 rounded-2xl shadow-2xl z-[200] p-3 text-left space-y-3 max-h-[82vh] overflow-y-auto",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between border-b border-gray-100 pb-2 gap-1.5",children:[s.jsx("button",{onClick:()=>n("account"),className:"hidden"}),s.jsxs("div",{className:"flex flex-1 min-w-[190px] gap-1 p-0.5 bg-gray-50 border border-gray-100 rounded-xl",children:[s.jsxs("button",{onClick:()=>ae("inbox"),id:"notif-tab-inbox",className:Ge("flex-1 py-1.5 rounded-lg text-center text-[9px] font-black uppercase tracking-wider transition-all cursor-pointer truncate",xe==="inbox"?"bg-white text-gray-950 shadow-2xs":"text-gray-400 hover:text-gray-955"),children:["📩 Inbox (",le.filter(ue=>!ue.used).length,")"]}),s.jsxs("button",{onClick:()=>ae("messages"),id:"notif-tab-messages",className:Ge("flex-1 py-1.5 rounded-lg text-center text-[9px] font-black uppercase tracking-wider transition-all cursor-pointer flex items-center justify-center gap-1 truncate",xe==="messages"?"bg-white text-gray-950 shadow-2xs":"text-gray-400 hover:text-gray-955"),children:[s.jsx("span",{children:"💬 Chat"}),ke.length>0&&s.jsx("span",{className:"px-1 py-0.2 bg-blue-100 text-blue-700 text-[8px] font-extrabold rounded-full",children:ke.length})]}),s.jsxs("button",{onClick:()=>ae("invites"),id:"notif-tab-invites",className:Ge("flex-1 py-1.5 rounded-lg text-center text-[9px] font-black uppercase tracking-wider transition-all cursor-pointer truncate",xe==="invites"?"bg-white text-gray-950 shadow-2xs":"text-gray-400 hover:text-gray-955"),children:["🤝 Invites (",he.length,")"]})]}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0 ml-auto",children:[s.jsxs("button",{onClick:async()=>{await yK()?(c1("🔔 Push Notifications Active!",{body:"Campus Eye system notifications will pop up directly on your device screen!",toneStyle:"crystal"}),me.success("Native Device Push Notifications Enabled!",{icon:"🔔"})):me("Acoustic chimes active! Allow notifications in browser settings for native popups.",{icon:"🎵"})},className:"px-2 py-1 bg-blue-50 hover:bg-blue-100 text-blue-700 rounded-xl transition-all cursor-pointer shrink-0 border border-blue-200 flex items-center gap-1 text-[9px] font-black uppercase tracking-wider shadow-2xs",title:"Enable Device System Push Notifications & Test Audio Chime",children:[s.jsx(Su,{size:11,className:"text-blue-600"}),s.jsx("span",{children:"Push"})]}),(xe==="inbox"&&le.length>0||xe==="invites"&&he.length>0)&&s.jsx("button",{onClick:jt,className:"p-1.5 bg-gray-50 hover:bg-red-50 text-gray-500 hover:text-red-650 rounded-xl transition-all cursor-pointer shrink-0 border border-transparent hover:border-red-150",title:xe==="inbox"?"Empty and delete all alerts":"Decline and dismiss all invites",children:s.jsx(As,{size:13})})]})]}),xe==="inbox"&&le.length>0&&s.jsx("div",{className:"flex items-center gap-1 overflow-x-auto pb-1 no-scrollbar border-b border-gray-100",children:[{id:"all",label:"All",icon:"📬"},{id:"broadcast",label:"Broadcasts",icon:"📢"},{id:"social",label:"Social & Replies",icon:"💬"},{id:"passes",label:"Pass Keys",icon:"🎟️"},{id:"system",label:"System & AI",icon:"🛡️"}].map(ue=>{const Se=le.filter(Xe=>ue.id==="all"?!0:Ze(Xe).category===ue.id).length;return s.jsxs("button",{onClick:()=>pt(ue.id),className:Ge("px-2 py-1 rounded-lg text-[8px] font-black uppercase tracking-wider whitespace-nowrap transition-all flex items-center gap-1 cursor-pointer shrink-0",Fe===ue.id?"bg-gray-950 text-white shadow-2xs":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:[s.jsx("span",{children:ue.icon}),s.jsx("span",{children:ue.label}),s.jsxs("span",{className:"opacity-70 font-mono",children:["(",Se,")"]})]},ue.id)})}),he.length===0&&le.length===0?s.jsx("div",{className:"py-8 text-center text-gray-400 text-[10px] font-bold uppercase tracking-wider",children:"Inbox Terminal Empty"}):xe==="inbox"?s.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto pr-1",children:(()=>{const ue=le.filter(Se=>Fe==="all"?!0:Ze(Se).category===Fe);return ue.length===0?s.jsxs("div",{className:"py-8 text-center text-xs text-gray-400 uppercase font-bold",children:["No ",Fe," notifications found."]}):ue.slice(0,20).map((Se,Xe)=>{var Tn;const Vt=Ze(Se),gn=Vt.IconComponent,xn=!!Ye[Se.id],yn=Se.imageUrl||Se.image,gt=Se.message||Se.fullAnswer||"";return s.jsxs(Kt.div,{drag:"x",dragConstraints:{left:-60,right:60},dragElastic:.15,onDragEnd:(Nt,Ae)=>{Math.abs(Ae.offset.x)>35&&(Ye[Se.id]||Ft(Se.id),me.success(`Swiped to reply to ${Se.senderName||"notification"}!`,{icon:"💬"}))},onClick:()=>{xn?jn(Se):Ft(Se.id)},className:Ge("p-3 rounded-2xl border transition-all text-left flex flex-col gap-2 cursor-pointer relative group/notif overflow-hidden shadow-2xs hover:shadow-md touch-pan-y",Vt.borderClass,Vt.bgClass),children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("div",{className:Ge("w-6 h-6 rounded-lg flex items-center justify-center shrink-0 shadow-2xs",Vt.iconBg),children:s.jsx(gn,{size:13})}),s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[!Se.used&&s.jsx("span",{className:"w-2 h-2 bg-red-600 rounded-full animate-pulse shrink-0",title:"Unread"}),s.jsx("span",{className:Ge("text-[8.5px] font-black uppercase px-2 py-0.5 rounded-md tracking-wider shrink-0 shadow-2xs",Vt.badgeClass),children:Vt.typeLabel})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("span",{className:"text-[8px] font-mono font-bold text-gray-500 bg-white/80 px-1.5 py-0.5 rounded border border-gray-100",children:Ht(Se.createdAt)}),s.jsx("button",{onClick:Nt=>Ft(Se.id,Nt),className:"p-1 bg-white/80 hover:bg-white text-gray-700 hover:text-black rounded-lg transition-all cursor-pointer border border-gray-200/80 shadow-2xs flex items-center gap-1 text-[9px] font-black uppercase px-1.5",title:xn?"Minimize notification":"Expand notification details",children:xn?s.jsxs(s.Fragment,{children:[s.jsx(uf,{size:12,strokeWidth:2.5,className:"text-red-600"}),s.jsx("span",{className:"text-[8px] font-bold hidden sm:inline",children:"Minimize"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Md,{size:12,strokeWidth:2.5,className:"text-indigo-600"}),s.jsx("span",{className:"text-[8px] font-bold hidden sm:inline",children:"Expand"})]})}),s.jsx("button",{onClick:Nt=>fn(Se.id,Nt),className:"p-1 text-gray-400 hover:text-red-600 hover:bg-white rounded-md transition-all cursor-pointer opacity-80 group-hover/notif:opacity-100",title:"Delete notification",children:s.jsx(er,{size:12})})]})]}),s.jsxs("div",{className:"flex items-start gap-2.5 justify-between min-w-0",children:[s.jsxs("div",{className:"flex-1 min-w-0 break-words",children:[s.jsx("h5",{className:"text-[11px] font-black uppercase text-gray-950 leading-snug tracking-tight break-words",children:Se.title}),s.jsx("div",{className:Ge("text-[10px] text-gray-700 leading-relaxed mt-0.5 font-medium break-words overflow-hidden",!xn&&"line-clamp-2"),children:(()=>{const Nt=/(https?:\/\/[^\s]+)/g;return gt.split(Nt).map((tn,yt)=>{if(tn.match(Nt)){const cn=Wt[tn];return s.jsxs("a",{href:tn,target:"_blank",rel:"noopener noreferrer",onClick:Pt=>{Pt.stopPropagation(),ln(tn),Bt(Se)},className:Ge("inline-flex items-center gap-0.5 font-bold underline transition-all mx-0.5 px-1.5 py-0.5 rounded text-[9px]",cn?"text-emerald-800 bg-emerald-100 border border-emerald-300 font-extrabold":"text-indigo-600 hover:text-indigo-800 bg-indigo-50 border border-indigo-200"),children:[s.jsx(wd,{size:9,className:"shrink-0"}),cn?"✓ Visited Link":tn.length>28?tn.substring(0,25)+"...":tn]},yt)}return tn})})()})]}),!xn&&yn&&s.jsx("div",{onClick:Nt=>Ft(Se.id,Nt),className:"w-12 h-12 rounded-xl overflow-hidden border border-gray-200 shrink-0 shadow-2xs relative bg-gray-100 cursor-pointer hover:scale-105 transition-transform",title:"Click to expand image",children:s.jsx(Vi,{src:yn,alt:Se.title||"Notification thumbnail",className:"w-full h-full object-cover"})})]}),xn&&s.jsxs("div",{className:"space-y-2 mt-1 animate-in fade-in slide-in-from-top-1 duration-200",children:[yn&&s.jsxs("div",{className:"rounded-xl overflow-hidden border border-gray-200/90 h-44 sm:h-52 w-full relative shadow-sm group/img bg-black/5",children:[s.jsx(Vi,{src:yn,alt:Se.title||"Broadcast image",title:Se.title,className:"w-full h-full object-cover"}),s.jsx("div",{className:"absolute top-2 right-2 px-2 py-1 bg-black/70 backdrop-blur-md text-white text-[8px] font-black uppercase rounded-lg tracking-wider border border-white/20",children:"Full Preview"})]}),Se.code&&!Se.used&&s.jsxs("div",{className:"p-2.5 bg-purple-900/10 border border-purple-200 rounded-xl flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(No,{size:14,className:"text-purple-700 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-[7.5px] font-black uppercase text-purple-900 tracking-wider",children:"Pass Verification Pin"}),s.jsx("code",{className:"text-xs font-black font-mono text-purple-950 tracking-widest",children:Se.code})]})]}),s.jsxs("button",{onClick:Nt=>{Nt.stopPropagation(),Pd(Se.code),me.success("Verification pin copied!",{icon:"📋"}),Bt(Se)},className:"px-2.5 py-1 bg-purple-700 hover:bg-purple-800 text-white rounded-lg transition-all flex items-center gap-1 text-[8.5px] font-black uppercase tracking-wider shrink-0 cursor-pointer shadow-xs",children:[s.jsx(Pw,{size:10})," Copy Pin"]})]}),(Se.canReply||Se.type==="direct_message"||Se.senderId)&&Se.senderId!==($==null?void 0:$.uid)&&s.jsxs("div",{onClick:Nt=>Nt.stopPropagation(),className:"p-2.5 bg-indigo-50/80 border border-indigo-200/90 rounded-xl space-y-2 mt-2 shadow-2xs text-left",children:[s.jsxs("div",{className:"flex items-center justify-between gap-1 text-[9px] font-black uppercase tracking-wider text-indigo-900",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(Js,{size:12,className:"text-indigo-600 shrink-0"}),s.jsxs("span",{className:"truncate",children:["Reply to ",Se.senderName?`@${Se.senderName.toLowerCase().replace(/\s+/g,"")}`:"Friend"]})]}),Se.senderId&&s.jsxs("button",{onClick:Nt=>{Nt.stopPropagation(),window.dispatchEvent(new CustomEvent("open-imessage-friend",{detail:{uid:Se.senderId,displayName:Se.senderName||"Campus Friend",username:Se.senderUsername||"friend",photoURL:Se.senderPhotoURL||""}}))},className:"px-2 py-0.5 bg-[#007AFF] hover:bg-blue-600 text-white rounded-md text-[8px] font-black uppercase tracking-wider flex items-center gap-1 shrink-0 cursor-pointer shadow-2xs",children:[s.jsx(Yi,{size:9})," iMessage Chat"]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("input",{type:"text",value:dt[Se.id]||"",onChange:Nt=>{Nt.stopPropagation();const Ae=Nt.target.value;sn(tn=>({...tn,[Se.id]:Ae}))},onClick:Nt=>Nt.stopPropagation(),placeholder:"Type inbox reply...",className:"flex-1 text-[11px] font-sans px-2.5 py-1.5 bg-white border border-indigo-200 rounded-lg outline-none focus:border-indigo-600 transition-all text-gray-900 placeholder:text-gray-400",onKeyDown:Nt=>{Nt.key==="Enter"&&Dt(Se,Nt)}}),s.jsxs("button",{onClick:Nt=>Dt(Se,Nt),disabled:pn[Se.id]||!((Tn=dt[Se.id])!=null&&Tn.trim()),className:"px-3 py-1.5 bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 text-white text-[9px] font-black uppercase tracking-wider rounded-lg flex items-center gap-1 cursor-pointer transition-all shrink-0 shadow-xs",children:[s.jsx(fl,{size:10})," Reply"]})]})]}),s.jsxs("div",{className:"pt-2 border-t border-gray-200/60 flex items-center justify-between gap-2 flex-wrap",children:[(Se.link||Se.actionUrl)&&s.jsxs("a",{href:Se.link||Se.actionUrl,target:(Se.link||Se.actionUrl).startsWith("http")?"_blank":"_self",rel:"noopener noreferrer",onClick:Nt=>{Nt.stopPropagation();const Ae=Se.link||Se.actionUrl;ln(Ae),Bt(Se)},className:Ge("px-3 py-1.5 text-[9px] font-black uppercase tracking-wider rounded-lg transition-all flex items-center gap-1.5 shadow-xs cursor-pointer",Wt[Se.link||Se.actionUrl]?"bg-emerald-100 text-emerald-800 border border-emerald-300 hover:bg-emerald-200":"bg-indigo-600 hover:bg-indigo-700 text-white border border-indigo-700"),children:[s.jsx(Va,{size:11}),Wt[Se.link||Se.actionUrl]?"✓ Link Visited":"Open Target Link"]}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[s.jsx("button",{onClick:Nt=>{Nt.stopPropagation(),Bt(Se)},className:"px-2 py-1 text-[8.5px] font-bold text-gray-600 hover:text-black bg-white/90 hover:bg-gray-100 rounded-lg border border-gray-200 transition-all cursor-pointer",children:"Mark Read"}),s.jsxs("button",{onClick:Nt=>Ft(Se.id,Nt),className:"px-2.5 py-1 text-[8.5px] font-black uppercase tracking-wider text-gray-700 hover:text-black bg-white hover:bg-gray-100 rounded-lg border border-gray-200 transition-all flex items-center gap-1 cursor-pointer",children:[s.jsx(tj,{size:10})," Minimize"]})]})]})]})]},`navnotif-${Se.id}-${Xe}`)})})()}):xe==="messages"?s.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto pr-1",children:ke.length===0?s.jsxs("div",{className:"py-8 text-center text-xs text-gray-400 uppercase font-bold flex flex-col items-center justify-center gap-2",children:[s.jsx(Yi,{size:22,className:"text-gray-300"}),s.jsx("p",{className:"text-[10px] text-gray-500",children:"No Message Threads Yet"}),s.jsx("p",{className:"text-[9px] text-gray-400 font-normal normal-case max-w-xs",children:"People you have messaged or who have messaged you will show here. Tap any peer to open inbox!"})]}):ke.map((ue,Se)=>s.jsxs("div",{onClick:()=>{const Xe={uid:ue.peerUid,displayName:ue.peerName,username:ue.peerUsername,photoURL:ue.peerPhoto};y&&y(Xe),window.dispatchEvent(new CustomEvent("open-imessage-friend",{detail:Xe})),ie(!1)},className:"flex items-center justify-between p-2 rounded-xl bg-gray-50/80 hover:bg-blue-50/90 border border-gray-200 hover:border-blue-300 transition-all cursor-pointer group shadow-2xs",children:[s.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("img",{src:ue.peerPhoto,alt:"",className:"w-8 h-8 rounded-full object-cover border border-white shadow-xs",referrerPolicy:"no-referrer"}),s.jsx("span",{className:"absolute bottom-0 right-0 w-2.5 h-2.5 bg-emerald-500 rounded-full border-2 border-white"})]}),s.jsxs("div",{className:"min-w-0 text-left",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("p",{className:"text-[11px] font-black uppercase text-gray-900 truncate group-hover:text-blue-600 transition-colors",children:ue.peerName}),s.jsxs("span",{className:"text-[9px] font-medium text-gray-400 truncate",children:["@",ue.peerUsername]})]}),s.jsx("p",{className:"text-[10px] text-gray-600 truncate font-normal",children:ue.lastMessage})]})]}),s.jsxs("div",{className:"flex flex-col items-end shrink-0 gap-1 ml-2",children:[s.jsx("span",{className:"text-[8px] font-bold text-gray-400",children:Ht(ue.lastTimestamp)}),ue.unreadCount>0&&s.jsx("span",{className:"px-1.5 py-0.5 bg-[#2AABEE] text-white text-[8px] font-black rounded-full shadow-2xs",children:ue.unreadCount})]})]},`navconv-${ue.peerUid}-${Se}`))}):s.jsxs("div",{className:"space-y-3 max-h-72 overflow-y-auto pr-1",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"text-[8px] font-black uppercase text-gray-400 tracking-wider mb-1.5",children:["Incoming requests (",he.length,")"]}),he.length===0?s.jsx("p",{className:"text-[9px] text-gray-400 font-medium py-1.5 px-2 bg-gray-50/50 rounded-xl leading-snug",children:"No incoming lounge invites right now."}):s.jsx("div",{className:"space-y-2",children:he.map(ue=>s.jsxs("div",{className:"flex items-center justify-between p-2 bg-gray-50/55 rounded-xl border border-gray-150 gap-2 hover:bg-gray-50 transition-all",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("img",{src:ue.senderPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(ue.senderName)}&background=random`,className:"w-7 h-7 rounded-full object-cover shrink-0 border border-gray-100",alt:"",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-[10px] font-black uppercase text-gray-950 truncate tracking-tight",children:ue.senderName}),s.jsxs("p",{className:"text-[8px] text-gray-400 truncate",children:["@",ue.senderName.toLowerCase().replace(/\s+/g,"")]})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("button",{onClick:()=>ze(ue),className:"w-5 h-5 rounded-full bg-emerald-50 text-emerald-650 hover:bg-emerald-600 hover:text-white flex items-center justify-center transition-all cursor-pointer border border-emerald-150/45 shadow-xs",title:"Accept Connection & Start Chatting",children:s.jsx(Pu,{size:10,strokeWidth:3})}),s.jsx("button",{onClick:()=>tt(ue),className:"w-5 h-5 rounded-full bg-red-50 text-red-600 hover:bg-red-600 hover:text-white flex items-center justify-center transition-all cursor-pointer border border-red-150/45 shadow-xs",title:"Decline Connection Request",children:s.jsx(er,{size:10,strokeWidth:3})})]})]},ue.id))})]}),s.jsxs("div",{className:"pt-2 border-t border-gray-100",children:[s.jsxs("div",{className:"text-[8px] font-black uppercase text-gray-400 tracking-wider mb-2 flex items-center justify-between",children:[s.jsx("span",{children:"Lounge Peer Directory"}),s.jsx("span",{className:"text-[7.5px] font-mono bg-red-50 text-red-600 px-1 rounded-md py-0.2 tracking-normal",children:"Direct Invite"})]}),s.jsxs("div",{className:"mb-2 relative",children:[s.jsx("input",{type:"text",placeholder:"Search classmate name...",value:$n,onChange:ue=>be(ue.target.value),className:"w-full text-[9px] bg-gray-55/15 border border-transparent rounded-lg px-2.5 py-1 text-gray-800 outline-none focus:bg-white focus:border-red-600/30 transition-all font-sans font-bold"}),$n&&s.jsx("button",{onClick:()=>be(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-red-650",children:s.jsx(er,{size:10})})]}),Kn.length===0?s.jsx("p",{className:"text-[8.5px] text-gray-400 font-bold py-3 text-center uppercase tracking-wider",children:"No other registered users"}):s.jsx("div",{className:"space-y-1.5 max-h-40 overflow-y-auto scrollbar-thin pr-0.5",children:Kn.filter(ue=>{if(!$n.trim())return!0;const Se=(ue.displayName||"").toLowerCase(),Xe=(ue.username||"").toLowerCase(),Vt=$n.toLowerCase();return Se.includes(Vt)||Xe.includes(Vt)}).slice(0,$n.trim()?15:3).map(ue=>{const Se=hr[ue.uid];return s.jsxs("div",{className:"flex items-center justify-between p-1 px-1.5 bg-gray-50/30 rounded-xl border border-gray-100 hover:bg-gray-50/70 transition-all gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("img",{src:ue.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(ue.displayName||"P")}&background=random`,className:"w-5.5 h-5.5 rounded-full object-cover shrink-0 border border-gray-100",alt:"",referrerPolicy:"no-referrer"}),(ue.isVerified||ue.isPremium||ue.blueCheck)&&s.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 bg-white rounded-full p-0.2 shadow-2xs",children:s.jsx(Ll,{size:8})})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("p",{className:"text-[9.5px] font-extrabold uppercase text-gray-950 truncate tracking-tight",children:ue.displayName||"Faculty peer"}),(ue.isVerified||ue.isPremium||ue.blueCheck)&&s.jsx(Ll,{size:9,className:"shrink-0 text-blue-500"})]}),s.jsxs("p",{className:"text-[7.5px] text-gray-400 truncate -mt-0.5",children:["@",(ue.username||ue.displayName||"").toLowerCase().replace(/\s+/g,"")]})]})]}),s.jsx("button",{onClick:()=>je(ue),disabled:Se,className:Ge("text-[7px] font-sans font-black uppercase tracking-wider px-2 py-1 rounded-md border cursor-pointer transition-all active:scale-95 flex items-center gap-0.5 shrink-0 select-none",Se?"bg-gray-50 text-gray-400 border-gray-200 cursor-not-allowed":"bg-red-50 text-red-650 border-red-150 hover:bg-red-600 hover:text-white"),children:Se?"Invited":"Invite"})]},ue.uid)})})]})]})]})})]}),s.jsx("button",{onClick:()=>{$?(n("account"),window.scrollTo({top:0,behavior:"smooth"})):o()},className:"flex items-center gap-1.5 text-gray-700 hover:text-gray-950 transition-colors group cursor-pointer",title:"My Account Profile",children:$?s.jsx("div",{className:"w-5 h-5 rounded-full overflow-hidden border border-gray-200 group-hover:border-red-600 transition-colors flex items-center justify-center bg-amber-50/50",children:$.photoURL?s.jsx("img",{src:$.photoURL,alt:"Profile",className:"w-full h-full object-cover",referrerPolicy:"no-referrer"}):s.jsx(l8,{size:20,className:"w-full h-full"})}):s.jsxs("div",{className:"flex items-center gap-1.5 bg-gray-55/10 border border-gray-150 rounded-full py-1.5 px-3 hover:bg-gray-100 hover:text-red-650 hover:border-red-150 transition-all text-gray-700",children:[s.jsx(l8,{size:14,className:"w-3.5 h-3.5 shrink-0"}),s.jsx("span",{className:"hidden xl:inline text-[9.5px] font-black uppercase tracking-wider",children:"Sign In"})]})}),s.jsx("button",{onClick:()=>I(!0),className:"p-1.5 text-gray-700 hover:text-red-650 hover:bg-gray-100 rounded-lg transition-all cursor-pointer border border-gray-200/60 shadow-2xs flex items-center justify-center ml-1",title:"Open Main Menu & App Tools",children:s.jsx(jN,{size:16,strokeWidth:2.5})})]})]}),typeof document<"u"&&CN.createPortal(s.jsx(ar,{children:k&&s.jsxs(s.Fragment,{children:[s.jsx(Kt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>I(!1),className:"fixed inset-0 bg-black/60 backdrop-blur-xs z-[1000000]"}),s.jsxs(Kt.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:25,stiffness:220},className:"fixed top-0 right-0 bottom-0 w-80 max-w-[85vw] bg-white text-gray-900 z-[1000001] shadow-2xl border-l border-gray-200 flex flex-col justify-between overflow-y-auto text-left select-none p-5",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between pb-4 border-b border-gray-100 mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"",className:"w-7 h-7 rounded-full border border-gray-900 object-cover",referrerPolicy:"no-referrer"}),s.jsx("span",{className:"text-xs font-serif font-black uppercase tracking-wide",children:"Campus Eye Media"})]}),s.jsx("button",{onClick:()=>I(!1),className:"p-1.5 text-gray-400 hover:text-gray-950 rounded-full hover:bg-gray-100 transition-colors cursor-pointer",children:s.jsx(er,{size:16})})]}),s.jsxs("div",{className:"p-3 bg-gradient-to-br from-red-650 to-red-700 text-white rounded-2xl shadow-md mb-5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx(Nie,{size:16,className:"text-amber-300"}),s.jsx("span",{className:"text-[11px] font-black uppercase tracking-wide",children:"Campus Eye Lite App"})]}),s.jsx("p",{className:"text-[9.5px] text-white/90 leading-tight mb-3 font-medium",children:"Install or download a lightweight web shortcut for instant 1-tap campus access!"}),s.jsxs("button",{onClick:()=>{F(),I(!1)},className:"w-full py-2 px-3 bg-white text-red-650 hover:bg-amber-50 font-black text-[10px] uppercase tracking-wider rounded-xl shadow-xs transition-all flex items-center justify-center gap-1.5 cursor-pointer",children:[s.jsx(IN,{size:13,strokeWidth:2.5}),s.jsx("span",{children:"Download Lite App"})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"text-[9px] font-black uppercase text-gray-400 tracking-wider px-2 mb-1",children:"Navigation"}),s.jsxs("button",{onClick:()=>{n("home"),I(!1)},className:"w-full text-left px-3 py-2.5 rounded-xl text-xs font-bold text-gray-800 hover:bg-gray-50 flex items-center gap-3 transition-colors cursor-pointer",children:[s.jsx(zh,{size:15,className:"text-red-600"}),s.jsx("span",{children:"Main Newsfeed"})]}),s.jsxs("button",{onClick:()=>{n("posts"),I(!1)},className:"w-full text-left px-3 py-2.5 rounded-xl text-xs font-bold text-gray-800 hover:bg-gray-50 flex items-center gap-3 transition-colors cursor-pointer",children:[s.jsx(Yi,{size:15,className:"text-blue-600"}),s.jsx("span",{children:"Student Lounge & Posts"})]}),s.jsxs("button",{onClick:()=>{n("podcasts"),I(!1)},className:"w-full text-left px-3 py-2.5 rounded-xl text-xs font-bold text-gray-800 hover:bg-gray-50 flex items-center gap-3 transition-colors cursor-pointer",children:[s.jsx(sc,{size:15,className:"text-emerald-600"}),s.jsx("span",{children:"Audio Podcasts"})]}),s.jsxs("button",{onClick:()=>{n("tickets"),I(!1)},className:"w-full text-left px-3 py-2.5 rounded-xl text-xs font-bold text-gray-800 hover:bg-gray-50 flex items-center gap-3 transition-colors cursor-pointer",children:[s.jsx(No,{size:15,className:"text-purple-600"}),s.jsx("span",{children:"Event Tickets Store"})]}),r&&s.jsxs("button",{onClick:()=>{i==null||i(),I(!1)},className:"w-full text-left px-3 py-2.5 rounded-xl text-xs font-black uppercase tracking-wider text-amber-600 bg-amber-50 hover:bg-amber-100 flex items-center gap-3 transition-colors mt-2 cursor-pointer",children:[s.jsx(nj,{size:15,className:"text-amber-600"}),s.jsx("span",{children:"Admin Control Center"})]})]})]}),s.jsxs("div",{className:"pt-4 border-t border-gray-100 text-[9px] text-gray-400 font-mono font-bold flex justify-between items-center",children:[s.jsx("span",{children:"v2.5 Lite Ready"}),s.jsx("span",{children:"Campus Eye Media"})]})]})]})}),document.body),s.jsx("div",{className:"lg:hidden flex items-center space-x-1.5 overflow-x-auto px-2.5 py-1 border-t border-gray-100/70 scrollbar-none",children:pr.map(ue=>{const Se=ue.id==="home";return s.jsxs(se.Fragment,{children:[s.jsx("button",{onClick:()=>{n(ue.id),h&&h(null)},className:Ge("text-[8.5px] font-extrabold tracking-wider px-2 py-0.5 rounded-full shrink-0 uppercase transition-all",t===ue.id&&!f?"bg-gray-950 text-white":"bg-gray-50 text-gray-500 border border-gray-100"),children:ue.label}),Se&&c&&c.length>0&&(()=>{const Xe=c[0],Vt=(f==null?void 0:f.id)===Xe.id,gn=c.slice(1),xn=gn.find(yn=>(f==null?void 0:f.id)===yn.id);return s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("button",{onClick:()=>h&&h(Xe),className:Ge("text-[9px] font-extrabold tracking-wider px-2.5 py-1 rounded-full shrink-0 uppercase flex items-center gap-1.2 transition-all border",Vt?"bg-red-650 border-red-650 text-white":"bg-red-50/70 border-red-150 text-red-655"),children:Xe.name},Xe.id),gn.length>0&&s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("button",{onClick:()=>ht(!Tt),className:Ge("p-1.5 rounded-full shrink-0 flex items-center justify-center transition-all border",xn?"bg-red-655 border-red-655 text-white":"bg-gray-100 border-gray-200 text-gray-650"),title:"More Channels",children:s.jsx("svg",{className:"w-2.5 h-2.5",fill:"none",stroke:"currentColor",strokeWidth:"3.5",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}),s.jsx(ar,{children:Tt&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[49] bg-transparent",onClick:()=>ht(!1)}),s.jsx(Kt.div,{initial:{opacity:0,scale:.95,y:3},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:3},transition:{duration:.1},className:"fixed right-4 top-[86px] min-w-[130px] max-w-[170px] bg-white border border-gray-150 rounded-xl shadow-2xl z-[99999] py-1 text-left",children:gn.map(yn=>{const gt=(f==null?void 0:f.id)===yn.id;return s.jsxs("button",{onClick:()=>{h&&h(yn),ht(!1)},className:Ge("w-full text-left px-3 py-1.5 hover:bg-gray-50 text-[8.5px] font-extrabold uppercase tracking-wider flex items-center justify-between transition-colors",gt?"text-red-650 bg-red-50/45":"text-gray-750 hover:text-black"),children:[s.jsx("span",{className:"truncate pr-1",children:yn.name}),gt&&s.jsx("span",{className:"w-1 h-1 rounded-full bg-red-650 shrink-0"})]},yn.id)})})]})})]})]},"mobile-custom-nav-group")})()]},ue.id)})})]}),s.jsx(ar,{children:w&&s.jsxs(Kt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[99999] bg-white flex flex-col text-gray-900 select-none overflow-y-auto",children:[s.jsxs("div",{className:"w-full max-w-[1680px] xl:max-w-[1780px] 2xl:max-w-[1880px] mx-auto px-6 pt-6 flex justify-between items-center select-none",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-red-650"}),s.jsx("span",{className:"text-[10px] font-black tracking-[0.2em] text-gray-500 uppercase",children:"CAMPUS SEARCHING ROOM"})]}),s.jsx(Kt.button,{whileHover:{rotate:90,scale:1.1},whileTap:{scale:.9},onClick:()=>A(!1),className:"p-2 text-gray-500 hover:text-gray-950 transition-colors bg-gray-50 hover:bg-gray-100 rounded-full border border-gray-250 cursor-pointer animate-fade-in -subtle",title:"Exit Searching Room",children:s.jsx(er,{size:18})})]}),s.jsx("div",{className:"flex-1 flex flex-col items-center justify-start pt-14 px-4 pb-12 overflow-y-auto w-full",children:s.jsxs(Kt.div,{initial:{y:25,opacity:0},animate:{y:0,opacity:1},transition:{type:"spring",damping:25,stiffness:200},className:"w-full max-w-4xl space-y-8",children:[s.jsxs("div",{className:"relative group flex items-center bg-gray-50 p-1 rounded-2xl border border-gray-200 focus-within:border-red-650 focus-within:bg-white focus-within:shadow-[0_0_25px_rgba(220,38,38,0.08)] transition-all duration-300",children:[s.jsx("div",{className:"flex items-center justify-center w-12 h-12 text-gray-400 pl-2",children:s.jsx(Ip,{size:22,className:"group-focus-within:text-red-500 transition-colors"})}),s.jsx("input",{type:"text",value:T,onChange:ue=>D(ue.target.value),placeholder:"Query articles, categories, debates, archives...",className:"flex-1 bg-transparent py-4 pl-3 pr-8 text-sm sm:text-base font-bold outline-none text-gray-900 placeholder-gray-400 min-w-0"}),T&&s.jsx("button",{onClick:on,className:"p-2.5 text-gray-500 hover:text-gray-900 transition-colors mr-2 cursor-pointer bg-gray-200 rounded-full hover:bg-gray-300 shrink-0",title:"Clear Search Query",children:s.jsx(er,{size:16})})]}),K.length>0?s.jsxs(Kt.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},className:"flex flex-col items-center gap-3.5 py-1 select-none",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[9px] font-black text-red-650 uppercase tracking-widest bg-red-50 px-3.5 py-1.5 rounded-full border border-red-150",children:[s.jsx(es,{size:11,className:"text-red-500 "})," Live Smart Concept Recommendations"]}),s.jsx("div",{className:"flex flex-wrap gap-2 justify-center",children:K.map((ue,Se)=>s.jsx("button",{onClick:()=>D(ue),className:"px-4 py-2 bg-gray-50 hover:bg-red-650 text-gray-700 hover:text-white text-[9px] font-extrabold uppercase tracking-wider border border-gray-200 hover:border-red-650 transition-all rounded-full cursor-pointer shadow-xs hover:scale-105",children:ue},Se))})]}):s.jsxs("div",{className:"flex items-center justify-center gap-2 py-1 select-none",children:[s.jsx("span",{className:"text-[9px] font-black tracking-widest text-gray-400 uppercase",children:"Suggested Terms:"}),s.jsx("div",{className:"flex gap-1.5",children:["News","Sports","Elections","Tickets","Debates"].map(ue=>s.jsx("button",{onClick:()=>D(ue),className:"text-[9px] font-black uppercase tracking-wider text-gray-500 hover:text-red-650 px-2.5 py-1.5 bg-gray-50 hover:bg-gray-100 rounded-md border border-gray-200 cursor-pointer",children:ue},ue))})]}),s.jsx("div",{className:"max-h-[50vh] overflow-y-auto pr-2 scrollbar-thin scrollbar-thumb-gray-200 scrollbar-track-transparent",children:s.jsx(ar,{mode:"popLayout",children:q.length>0?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"text-[10px] font-black tracking-widest text-gray-500 uppercase select-none pb-1 border-b border-gray-150 flex items-center justify-between",children:[s.jsxs("span",{children:["Matching Campus & Archival Catalog (",q.length,")"]}),s.jsx("span",{className:"text-[8px] font-bold text-gray-400 capitalize",children:"Real-time instant index"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:q.map((ue,Se)=>{const Xe={article:"bg-red-50 text-red-650 border-red-150",post:"bg-purple-50 text-purple-650 border-purple-150",user:"bg-blue-50 text-blue-650 border-blue-150",advert:"bg-amber-50 text-amber-650 border-amber-150",pinned:"bg-rose-50 text-rose-650 border-rose-150",customPage:"bg-teal-50 text-teal-650 border-teal-150"};return s.jsxs(Kt.button,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:Se*.03},onClick:()=>Ir(ue),className:"flex gap-4 p-3 bg-white hover:bg-gray-50 hover:shadow-md transition-all duration-200 group border border-gray-150 rounded-xl text-left select-none outline-none",children:[s.jsxs("div",{className:"w-16 h-16 overflow-hidden bg-gray-50 flex-shrink-0 border border-gray-150 rounded-lg relative",children:[s.jsx("img",{src:ue.imageUrl||void 0,alt:"",className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-103",referrerPolicy:"no-referrer"}),s.jsx("span",{className:`absolute bottom-1 right-1 text-[6.5px] font-black tracking-widest uppercase px-1 py-0.2 rounded-xs border shadow-3xs ${Xe[ue.type]||"bg-gray-100 text-gray-500 border-gray-200"}`,children:ue.type})]}),s.jsxs("div",{className:"flex-1 space-y-0.5 min-w-0 text-left",children:[s.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest text-gray-400",children:ue.category}),s.jsx("h4",{className:"text-xs sm:text-xs font-black text-gray-950 uppercase tracking-tight group-hover:text-red-650 transition-colors leading-snug line-clamp-2",children:ue.title}),s.jsx("p",{className:"text-[10px] text-gray-500 line-clamp-1 italic leading-relaxed",children:ue.subtitle})]})]},`${ue.type}-${ue.id}`)})})]}):T.length>1&&s.jsxs(Kt.div,{initial:{opacity:0},animate:{opacity:1},className:"text-center py-16 flex flex-col items-center select-none",children:[s.jsx("p",{className:"text-gray-500 font-extrabold uppercase tracking-widest text-sm mb-1",children:"No matching dispatches found"}),s.jsx("p",{className:"text-gray-400 text-xs font-bold",children:"Refine your inquiry above dynamically"})]})})})]})})]})})]})},gye=({activeTab:e,setActiveTab:t,onProfileClick:n,isAdmin:r,onAdminClick:i,openAuth:a,onMenuClick:o,onPodcastClick:c,isPodcastModalOpen:h})=>{const[f,m]=se.useState(!1),[y,w]=j.useState(Ne.currentUser);j.useEffect(()=>{const T=Ne.onAuthStateChanged(D=>{w(D)});return()=>T()},[]);const A=typeof window<"u"?window.location.origin:"https://campuseyemedia.com",k=[...r?[{id:"live",label:"Live Stream",icon:es,url:`${A}/live`}]:[],{id:"teams",label:"Teams",icon:Ao},{id:"marketplace",label:"Marketplace",icon:hC},{id:"feedback",label:"Feedback",icon:G0},...r?[{id:"main-site",label:"Main Site",icon:lre,url:"https://campuseyemedia.com"}]:[]],I=T=>{T.url?window.open(T.url,"_blank"):t(T.id),m(!1)};return s.jsxs(s.Fragment,{children:[s.jsx(ar,{children:f&&s.jsxs(Kt.div,{initial:{opacity:0,y:100},animate:{opacity:1,y:0},exit:{opacity:0,y:100},className:"fixed bottom-20 left-4 right-4 bg-white/70 backdrop-blur-2xl border border-white/50 z-[60] p-6 shadow-2xl rounded-3xl",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsx("h3",{className:"text-sm font-black uppercase tracking-widest text-red-650",children:"Explore More"}),s.jsx("button",{onClick:()=>m(!1),className:"text-gray-500",children:s.jsx(er,{size:20})})]}),s.jsx("div",{className:"grid grid-cols-4 gap-4",children:k.map(T=>s.jsxs("button",{onClick:()=>I(T),className:"flex flex-col items-center gap-2 group",children:[s.jsx("div",{className:"p-3 bg-gray-50 group-hover:bg-red-650 group-hover:text-white transition-all",children:s.jsx(T.icon,{size:20})}),s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-500",children:T.label})]},T.id))})]})}),s.jsx("nav",{className:"fixed bottom-2 left-1/2 -translate-x-1/2 z-[1001] w-[88%] max-w-sm md:max-w-md",children:s.jsxs("div",{className:"relative group overflow-hidden rounded-full p-[1px] isolate",children:[s.jsx("div",{className:"absolute inset-0 z-[-1] overflow-hidden",children:s.jsx(Kt.div,{animate:{scale:[1,1.15,.95,1.05,1],x:[-3,7,-7,3,-3],y:[1,-5,3,-1,1],rotate:[0,90,180,270,360]},transition:{duration:12,repeat:1/0,ease:"easeInOut"},className:"absolute -inset-[100%] opacity-35 blur-[20px] bg-gradient-to-tr from-[#FF3B30]/30 via-[#34C759]/25 to-[#007AFF]/35"})}),s.jsxs("div",{className:"relative bg-white/35 dark:bg-neutral-900/35 backdrop-blur-[35px] border border-white/40 dark:border-white/10 shadow-[0_12px_36px_rgba(0,0,0,0.12)] h-11 rounded-full overflow-hidden transition-all duration-500 hover:bg-white/50 dark:hover:bg-neutral-900/50",children:[s.jsx(Kt.div,{animate:{opacity:[.35,.75,.35],scale:[.97,1.03,.97]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},className:"absolute inset-x-0 bottom-0 h-[1.5px] bg-gradient-to-r from-transparent via-[#FF2D55]/60 to-transparent blur-xs"}),s.jsxs("div",{className:"grid grid-cols-5 h-full relative z-10 px-1 items-center",children:[s.jsxs("button",{onClick:()=>t("home"),className:Ge("flex flex-col items-center justify-center h-full space-y-0.2 transition-all duration-500",e==="home"?"text-red-600 scale-105 drop-shadow-sm":"text-red-500/75 hover:text-red-600"),children:[s.jsxs("div",{className:"relative",children:[s.jsx(Ipe,{size:16,className:"shrink-0"}),e==="home"&&s.jsx(Kt.div,{layoutId:"nav-dot",className:"absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-0.5 h-0.5 bg-red-600 rounded-full"})]}),s.jsx("span",{className:"text-[6px] font-black uppercase tracking-widest mt-0.2 opacity-95",children:"Home"})]}),s.jsxs("button",{onClick:()=>{t("posts")},className:Ge("flex flex-col items-center justify-center h-full space-y-0.2 transition-all duration-500",e==="posts"?"text-blue-600 scale-105":"text-blue-500/75 hover:text-blue-600"),children:[s.jsxs("div",{className:"relative",children:[s.jsx(hC,{size:16,className:"shrink-0"}),e==="posts"&&s.jsx(Kt.div,{layoutId:"nav-dot",className:"absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-0.5 h-0.5 bg-blue-600 rounded-full"})]}),s.jsx("span",{className:"text-[6px] font-black uppercase tracking-widest mt-0.2 opacity-95",children:"Market"})]}),s.jsx("div",{className:"relative flex justify-center items-center h-full",children:s.jsxs(Kt.button,{whileHover:{scale:1.08},whileTap:{scale:.92},onClick:o,className:"w-8 h-8 bg-gray-950 text-white rounded-full shadow-[0_6px_15px_rgba(0,0,0,0.35)] flex items-center justify-center border border-white/15 transition-all z-20 group/btn overflow-hidden cursor-pointer",title:"Open Dashboard Drawer",children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-tr from-red-600/20 to-transparent opacity-0 group-hover/btn:opacity-100 transition-opacity"}),s.jsx(jN,{className:"text-white w-3.5 h-3.5 z-10"})]})}),s.jsxs("button",{onClick:()=>{c?c():t("podcasts")},className:Ge("flex flex-col items-center justify-center h-full space-y-0.2 transition-all duration-500",e==="podcasts"||h?"text-emerald-600 scale-105 font-bold":"text-emerald-500/75 hover:text-emerald-600"),children:[s.jsx(d2,{size:16,className:"shrink-0"}),s.jsx("span",{className:"text-[6px] font-black uppercase tracking-widest mt-0.2 opacity-95",children:"Podcast"})]}),s.jsxs("button",{onClick:()=>y?n():a(),className:Ge("flex flex-col items-center justify-center h-full space-y-0.2 transition-all duration-500",e==="account"?"text-amber-550 scale-105":"text-amber-500/75 hover:text-amber-550"),children:[y?s.jsx("div",{className:"relative p-0.5 rounded-full bg-amber-500/20 border border-amber-500/50 shadow-sm",children:s.jsx("img",{src:y.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(y.displayName||"User")}&background=random`,className:"w-3.5 h-3.5 rounded-full object-cover",alt:"",referrerPolicy:"no-referrer"})}):s.jsx(TN,{size:13,className:"text-amber-500",strokeWidth:e==="account"?2.5:2}),s.jsx("span",{className:"text-[6px] font-black uppercase tracking-widest mt-0.2 opacity-95",children:y?"Me":"Join"})]})]})]})]})})]})},xye=({articles:e,onClick:t})=>{const n=e.slice(0,3),r=j.useRef(null),[i,a]=j.useState({}),[o,c]=j.useState(null),[h,f]=j.useState(!1);se.useEffect(()=>{cs(ot(pe,"settings","pinned")).then(I=>{if(I.exists()){const T=I.data();T.active?c({title:T.title||"",description:T.description||"",link:T.link||"",imageUrl:T.imageUrl||"",active:!!T.active}):c(null)}else c(null)}).catch(I=>{Gs(I,Ps.GET,"settings/pinned")})},[]);const[m,y]=j.useState(!1);if(se.useEffect(()=>{const I=()=>{if(!o)return;const T=`dismiss_forever_pinned_${encodeURIComponent("fallback_legacy")}`,D=o.title?encodeURIComponent(o.title):"",F=`dismiss_forever_pinned_${D}`;localStorage.getItem(T)==="true"||D&&localStorage.getItem(F)==="true"?y(!0):y(!1)};return I(),window.addEventListener("pinned-dismissed",I),window.addEventListener("storage",I),()=>{window.removeEventListener("pinned-dismissed",I),window.removeEventListener("storage",I)}},[o]),se.useEffect(()=>{f(!!(o&&!m))},[o,m]),se.useEffect(()=>{if(n.length<=1)return;const I=setInterval(()=>{if(!r.current)return;const{scrollLeft:T,scrollWidth:D,clientWidth:F}=r.current,q=T+F>=D-15?0:T+F;r.current.scrollTo({left:q,behavior:"smooth"})},2e4);return()=>clearInterval(I)},[n.length]),n.length===0)return null;const w=(I,T)=>{T.stopPropagation(),a(D=>({...D,[I]:!D[I]}))},A=I=>{if(!r.current)return;const{scrollLeft:T,clientWidth:D}=r.current,F=D*.75;r.current.scrollTo({left:I==="left"?T-F:T+F,behavior:"smooth"})},k=[{gradient:"from-purple-950 via-purple-900 to-indigo-950 hover:from-purple-900 hover:to-indigo-900 border-purple-500/30",accentBg:"bg-purple-500/20 text-purple-200 border-purple-400/20",textAccent:"text-purple-300",type:"Breaking Story"},{gradient:"from-rose-950 via-rose-900 to-red-950 hover:from-rose-900 hover:to-red-900 border-red-500/30",accentBg:"bg-red-500/20 text-red-200 border-red-400/20",textAccent:"text-red-300",type:"Hot Broadcast"},{gradient:"from-emerald-950 via-emerald-900 to-teal-950 hover:from-emerald-900 hover:to-teal-900 border-emerald-500/30",accentBg:"bg-emerald-500/20 text-emerald-200 border-emerald-400/20",textAccent:"text-emerald-300",type:"Exclusive Update"}];return s.jsxs("div",{className:"relative group/nav px-4 pt-1 pb-4 select-none",children:[n.length>1&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>A("left"),className:"absolute left-1.5 top-1/2 -translate-y-1/2 z-40 w-8 h-8 bg-black/80 hover:bg-black text-white hover:scale-105 transition-all rounded-full flex items-center justify-center border border-white/10 shadow-lg cursor-pointer opacity-0 group-hover/nav:opacity-100 hidden sm:flex",title:"Scroll Left",children:s.jsx(Vp,{size:16})}),s.jsx("button",{onClick:()=>A("right"),className:"absolute right-1.5 top-1/2 -translate-y-1/2 z-40 w-8 h-8 bg-black/80 hover:bg-black text-white hover:scale-105 transition-all rounded-full flex items-center justify-center border border-white/10 shadow-lg cursor-pointer opacity-0 group-hover/nav:opacity-100 hidden sm:flex",title:"Scroll Right",children:s.jsx(Fp,{size:16})})]}),s.jsx("div",{ref:r,className:"flex gap-4 overflow-x-auto scrollbar-none snap-x snap-mandatory px-0.5 py-0.5 touch-pan-x",style:{scrollBehavior:"smooth"},children:n.map((I,T)=>{var Z;const D=k[T%k.length],F=!!i[T],L=I.likeCount?`${I.likeCount}+`:"24+",q=I.commentCount?`${I.commentCount}`:"4";return T===0&&h&&o?s.jsx("div",{onClick:()=>{o.link&&window.open(o.link,"_blank")},className:"snap-start shrink-0 w-[91%] sm:w-[50%] lg:w-[32.3%] cursor-pointer transition-all animate-fade-in",children:s.jsx(Kt.div,{layout:!0,className:"w-full bg-[#0a0b0d] text-white p-[2px] rounded-full relative overflow-hidden select-none flex flex-col justify-center shadow-lg",style:{borderRadius:F?"18px":"9999px",backgroundImage:"linear-gradient(to right, #fbbf24, #ec4899, #3b82f6)"},children:s.jsxs("div",{className:"w-full h-full bg-[#0d0e12] px-3.5 py-2.5 rounded-full flex flex-col justify-center",style:{borderRadius:F?"16px":"9999px"},children:[s.jsxs("div",{className:"flex items-center justify-between w-full",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o.imageUrl?s.jsx("div",{className:"w-6 h-6 rounded-full overflow-hidden bg-gray-800 border-2 border-amber-400 shrink-0 shadow-sm flex items-center justify-center",children:s.jsx("img",{src:o.imageUrl,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer"})}):s.jsx("div",{className:"w-6 h-6 rounded-full bg-amber-400/20 border-2 border-amber-400 shrink-0 flex items-center justify-center text-amber-400",children:s.jsx(Su,{size:11,className:"animate-bounce"})}),s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 text-[10.5px] font-bold",children:[s.jsxs("span",{className:"text-[8.5px] font-black uppercase tracking-widest px-1.5 py-0.5 rounded bg-amber-400/20 text-amber-300 shrink-0 flex items-center gap-0.5",children:[s.jsx(Su,{size:9})," PINNED"]}),s.jsx("span",{className:"text-white/60",children:"•"}),s.jsx("span",{className:"truncate text-white tracking-tight leading-none font-extrabold",children:o.title})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0 pl-1.5",children:[s.jsx("button",{onClick:K=>{K.stopPropagation();const B=`dismiss_forever_pinned_${o.title?encodeURIComponent(o.title):""}`;localStorage.setItem(B,"true"),localStorage.setItem("dismiss_forever_pinned_settings_pinned","true"),y(!0),f(!1),window.dispatchEvent(new Event("pinned-dismissed")),sr.success("Pinned announcement dismissed!")},className:"w-5 h-5 bg-white/10 hover:bg-red-600 hover:text-white text-white rounded-full flex items-center justify-center transition-all cursor-pointer active:scale-95 shrink-0",title:"Dismiss forever",children:s.jsx(er,{size:10,className:"stroke-[2.5]"})}),s.jsx("button",{onClick:K=>w(T,K),className:"w-5 h-5 bg-white/10 hover:bg-white/20 text-white rounded-full flex items-center justify-center transition-all cursor-pointer active:scale-95 shrink-0",title:F?"Collapse announcement":"Expand announcement",children:s.jsx(Kt.div,{animate:{rotate:F?180:0},transition:{duration:.2},children:s.jsx(Md,{size:11,className:"stroke-[2.5]"})})})]})]}),s.jsx(ar,{initial:!1,children:F&&s.jsx(Kt.div,{initial:{height:0,opacity:0,marginTop:0},animate:{height:"auto",opacity:1,marginTop:10},exit:{height:0,opacity:0,marginTop:0},transition:{duration:.25,ease:"easeInOut"},className:"overflow-hidden w-full text-left",children:s.jsxs("div",{className:"pt-2.5 border-t border-white/10 flex gap-3 items-start",children:[o.imageUrl&&s.jsx("div",{className:"w-12 h-12 rounded-lg overflow-hidden bg-gray-900 border border-white/10 shrink-0",children:s.jsx("img",{src:o.imageUrl,className:"w-full h-full object-cover",alt:"",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[10px] text-white/90 font-bold leading-snug",children:o.description||"Click link to view details of this announcement!"}),o.link&&s.jsx("p",{className:"text-[8.5px] font-black uppercase text-amber-300 tracking-wider mt-2 flex items-center gap-1",children:s.jsx("span",{children:"Tap Action Link →"})})]})]})})})]})})},"pinned-announcement-overlay"):s.jsx("div",{onClick:()=>t(I),className:"snap-start shrink-0 w-[91%] sm:w-[50%] lg:w-[32.3%] cursor-pointer transition-all",children:s.jsxs(Kt.div,{layout:!0,className:`w-full bg-gradient-to-r ${D.gradient} text-white px-3.5 py-2.5 rounded-full border shadow-md hover:shadow-lg transition-all duration-300 relative overflow-hidden select-none flex flex-col justify-center`,style:{borderRadius:F?"18px":"9999px"},children:[s.jsx("div",{className:"absolute top-0 right-0 w-24 h-24 bg-white/2 rounded-full blur-xl pointer-events-none"}),s.jsxs("div",{className:"flex items-center justify-between w-full",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx("div",{className:"w-6 h-6 rounded-full overflow-hidden bg-gray-800 border-2 border-white/20 shrink-0 shadow-sm",children:s.jsx("img",{src:I.featuredImageUrl||"https://picsum.photos/seed/news/50/50",alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 text-[10.5px] font-bold",children:[s.jsx("span",{className:`text-[8.5px] font-black uppercase tracking-widest px-1.5 py-0.5 rounded ${D.accentBg} shrink-0`,children:L}),s.jsx("span",{className:"text-white/60",children:"•"}),s.jsx("span",{className:"truncate text-white/90 tracking-tight",children:A0(I.title)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0 pl-1.5",children:[!F&&s.jsxs("div",{className:"flex gap-0.5 items-end h-2 w-3 pr-0.5",children:[s.jsx("div",{className:"w-0.5 bg-white/70 animate-[pulse_0.6s_infinite_alternate]",style:{height:"50%"}}),s.jsx("div",{className:"w-0.5 bg-white/70 animate-[pulse_0.8s_infinite_alternate]",style:{height:"90%"}}),s.jsx("div",{className:"w-0.5 bg-white/70 animate-[pulse_0.5s_infinite_alternate]",style:{height:"35%"}})]}),s.jsx("button",{onClick:K=>w(T,K),className:"w-5 h-5 bg-white/10 hover:bg-white/20 text-white rounded-full flex items-center justify-center transition-all cursor-pointer border border-white/5 active:scale-90",title:F?"Collapse Banner":"Expand Banner",children:s.jsx(Kt.div,{animate:{rotate:F?180:0},transition:{duration:.2},children:s.jsx(Md,{size:11,className:"stroke-[2.5]"})})})]})]}),s.jsx(ar,{initial:!1,children:F&&s.jsx(Kt.div,{initial:{height:0,opacity:0,marginTop:0},animate:{height:"auto",opacity:1,marginTop:10},exit:{height:0,opacity:0,marginTop:0},transition:{duration:.25,ease:"easeInOut"},className:"overflow-hidden w-full text-left",children:s.jsxs("div",{className:"pt-2.5 border-t border-white/10 flex gap-3 items-start",children:[s.jsx("div",{className:"w-14 h-14 rounded-lg overflow-hidden bg-gray-900 border border-white/10 shrink-0",children:s.jsx("img",{src:I.featuredImageUrl||"https://picsum.photos/seed/news/150/150",alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[s.jsx("span",{className:"text-[8px] font-black uppercase text-red-400 tracking-widest",children:I.category}),s.jsx("span",{className:"text-white/35 text-[8px]",children:"•"}),s.jsx("span",{className:"text-[8px] font-black uppercase text-white/50 tracking-widest",children:D.type})]}),s.jsxs("p",{className:"text-[10px] text-white/80 line-clamp-2 leading-relaxed",children:[I.summary||((Z=I.content)==null?void 0:Z.substring(0,80))||"Tune in for deep coverage on this topic","..."]}),s.jsxs("div",{className:"flex items-center gap-2.5 pt-1 select-none",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[8.5px] text-white/60",children:[s.jsx(G0,{size:9}),s.jsxs("span",{children:[q," comments"]})]}),s.jsx("span",{className:"text-[8.5px] font-extrabold text-white/80 hover:text-white transition-colors uppercase tracking-wider flex items-center gap-0.5",children:"Open Story →"})]})]})]})})})]})},I.id)})})]})},Sw=({advert:e,className:t})=>{const[n,r]=j.useState(!1),[i,a]=j.useState(!1),o=e.type==="video"||e.videoUrl&&!e.imageUrl,c=y=>{const w=/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/,A=y.match(w);return A&&A[2].length===11?A[2]:null},h=e.videoUrl?c(e.videoUrl):null,f=y=>{y.preventDefault(),y.stopPropagation(),a(!i)},m=y=>{y.preventDefault(),y.stopPropagation(),r(!n)};return s.jsxs("div",{className:`group relative overflow-hidden bg-gray-950 border border-zinc-800 rounded-xl transition-all duration-500 hover:border-red-500/30 ${t}`,children:[s.jsxs("div",{className:"absolute top-2 w-full px-3 flex justify-between items-center z-[30] pointer-events-none",children:[s.jsxs("div",{className:"flex items-center gap-1 bg-black/45 backdrop-blur-md px-2.5 py-1 rounded-full border border-white/10 pointer-events-auto select-none",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[8.5px] font-black uppercase text-white tracking-widest",children:[s.jsx(hu,{size:10,className:"text-red-500 shrink-0"}),s.jsx("span",{children:"Ad"})]}),s.jsx("button",{onClick:f,className:"text-white/60 hover:text-white ml-1.5 transition-colors focus:outline-none cursor-pointer",title:"Ad Placement Info",children:s.jsx(nF,{size:11})})]}),s.jsx("div",{className:"pointer-events-auto select-none",children:s.jsxs("button",{onClick:m,className:"flex items-center gap-1 bg-black/45 backdrop-blur-md text-white/90 hover:text-white px-2.5 py-1 rounded-full border border-white/10 text-[8.5px] font-black uppercase tracking-widest transition-all cursor-pointer focus:outline-none",children:[s.jsx("span",{children:n?"Minimize":"Enlarge"}),n?s.jsx(uf,{size:11}):s.jsx(Md,{size:11})]})})]}),s.jsx("a",{href:e.link,target:"_blank",rel:"noopener noreferrer",className:"block cursor-pointer overflow-hidden",children:s.jsxs(Kt.div,{style:{aspectRatio:n?o?"16/9":"1.6":o?"18/8":"2.6"},transition:{type:"spring",damping:20,stiffness:100},className:"overflow-hidden bg-black flex items-center justify-center relative w-full h-full min-h-[140px] transition-[aspect-ratio] duration-300 ease-in-out",children:[s.jsx(ar,{mode:"wait",children:s.jsx(Kt.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},transition:{duration:.6,ease:[.16,1,.3,1]},className:"absolute inset-0 w-full h-full flex items-center justify-center",children:o&&e.videoUrl?h?s.jsx("div",{className:"absolute inset-0 pointer-events-none scale-150",children:s.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${h}?autoplay=1&mute=1&loop=1&playlist=${h}&controls=0&showinfo=0&rel=0&iv_load_policy=3&modestbranding=1&enablejsapi=1`,className:"w-full h-full",allow:"autoplay; encrypted-media",title:e.title||"Advertisement"})}):s.jsx("video",{src:e.videoUrl||void 0,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"w-full h-full object-contain bg-neutral-950"}):s.jsx("img",{src:e.imageUrl||void 0,alt:e.title||"Advertisement",className:"w-full h-full object-contain bg-neutral-950 transition-transform duration-700 group-hover:scale-103",referrerPolicy:"no-referrer",loading:"eager",decoding:"async"})},e.id||e.title||e.imageUrl)}),o&&s.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-10 h-10 bg-white/10 backdrop-blur-md rounded-full flex items-center justify-center text-white/40 opacity-0 group-hover:opacity-100 transition-all duration-750 scale-75 group-hover:scale-100 pointer-events-none z-10",children:s.jsx($p,{size:18,fill:"currentColor"})}),s.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-4 bg-gradient-to-t from-black/90 via-black/30 to-transparent opacity-0 group-hover:opacity-100 transition-all duration-500 translate-y-2 group-hover:translate-y-0 flex items-center justify-between pointer-events-none z-10",children:[s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("span",{className:"block text-[9px] font-black text-white uppercase tracking-widest",children:e.title||"Official Advertisement"}),s.jsx("p",{className:"text-[7.5px] font-bold text-gray-300 uppercase tracking-wider",children:"Click image to open redirect link"})]}),s.jsx("div",{className:"w-6 h-6 bg-white/10 backdrop-blur-md rounded-full flex items-center justify-center border border-white/10 shrink-0",children:s.jsx(Va,{size:12,className:"text-white"})})]})]})}),s.jsx(ar,{children:i&&s.jsxs(Kt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 bg-black/90 backdrop-blur-md flex flex-col justify-center p-5 z-[40]",children:[s.jsx("button",{onClick:f,className:"absolute top-3 right-3 text-white/60 hover:text-white p-1 cursor-pointer focus:outline-none",children:s.jsx(er,{size:15})}),s.jsxs("div",{className:"space-y-2 select-text",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-red-500",children:[s.jsx(es,{size:14}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"Ad Placement Guarantee"})]}),s.jsx("h4",{className:"text-[11px] font-black text-white uppercase tracking-wide leading-tight",children:e.title||"Official Ad Placement"}),s.jsx("p",{className:"text-[9px] text-gray-400 font-sans leading-normal",children:"This verification card is served directly by the Campus Eye Editorial Board. It is an independent advertisement. Click on the image to visit the external destination safely."}),s.jsxs("div",{className:"pt-1.5 flex gap-2",children:[s.jsxs("span",{className:"text-[7px] text-zinc-500 bg-zinc-900 border border-zinc-800 px-2 py-0.5 rounded-md font-mono select-none",children:["REF: AD-",e.id.substring(0,6).toUpperCase()]}),s.jsx("span",{className:"text-[7px] text-zinc-500 bg-zinc-900 border border-zinc-800 px-2 py-0.5 rounded-md font-mono select-none",children:"STATUS: LIVE"})]})]})]})})]})},Bo=({className:e,variant:t="rect"})=>s.jsx("div",{className:Ge("skeleton",t==="circle"&&"rounded-full",e)}),Ep=({variant:e="big"})=>e==="social"?s.jsx("div",{className:"border-b border-gray-100 p-4 md:p-6 bg-white text-left space-y-3",children:s.jsxs("div",{className:"flex gap-3 md:gap-4",children:[s.jsx("div",{className:"w-8 h-8 md:w-9 md:h-9 rounded-full bg-gray-200 shrink-0"}),s.jsxs("div",{className:"flex-1 space-y-3 min-w-0",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap w-full",children:[s.jsx("div",{className:"h-3 w-3 bg-gray-200 rounded-full"}),s.jsx("div",{className:"h-3 w-20 bg-gray-250 rounded"}),s.jsx("div",{className:"h-2 w-2 rounded-full bg-gray-200 shrink-0"}),s.jsx("div",{className:"h-3 w-16 bg-gray-200 rounded"}),s.jsx("div",{className:"h-2 w-2 rounded-full bg-gray-200 shrink-0"}),s.jsx("div",{className:"h-3 w-12 bg-gray-150 rounded"})]})}),s.jsxs("div",{className:"space-y-2 pt-1",children:[s.jsx("div",{className:"h-4.5 w-[94%] bg-gray-250 rounded-md"}),s.jsx("div",{className:"h-4.5 w-3/4 bg-gray-200 rounded-md"})]}),s.jsxs("div",{className:"space-y-1.5 pt-1",children:[s.jsx("div",{className:"h-3 w-full bg-slate-100 rounded"}),s.jsx("div",{className:"h-3 w-[88%] bg-slate-100 rounded"}),s.jsx("div",{className:"h-3.5 w-16 bg-red-100 rounded"})," "]}),s.jsxs("div",{className:"h-48 md:h-56 bg-slate-50 border border-slate-100 rounded-2xl flex items-center justify-center relative overflow-hidden mt-3",children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-tr from-slate-100 to-slate-50/50"}),s.jsx("div",{className:"w-12 h-12 rounded-full bg-slate-200/50 flex items-center justify-center",children:s.jsx("div",{className:"w-4 h-4 bg-slate-300 rounded-full"})})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 max-w-md border-t border-gray-100 mt-4 text-gray-300",children:[s.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-150 flex items-center justify-center"}),s.jsx("div",{className:"h-2.5 w-5 bg-gray-200 rounded"})]}),s.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-150 flex items-center justify-center"}),s.jsx("div",{className:"h-2.5 w-7 bg-gray-200 rounded"})]}),s.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-150 flex items-center justify-center"}),s.jsx("div",{className:"h-2.5 w-8 bg-gray-200 rounded"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-100"}),s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-100"})]})]})]})]})}):e==="magazine"?s.jsxs("div",{className:"flex flex-col gap-8 p-6 border border-gray-100",children:[s.jsx(Bo,{className:"aspect-[4/5] w-full"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx(Bo,{className:"h-3 w-20"}),s.jsx(Bo,{className:"h-8 w-full"}),s.jsx(Bo,{className:"h-8 w-3/4"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Bo,{className:"h-4 w-full"}),s.jsx(Bo,{className:"h-4 w-full"}),s.jsx(Bo,{className:"h-4 w-2/3"})]})]})]}):e==="compact"?s.jsxs("div",{className:"flex items-start gap-4 pb-4 border-b border-gray-100",children:[s.jsx(Bo,{className:"w-20 h-20 shrink-0"}),s.jsxs("div",{className:"flex-1 space-y-2",children:[s.jsx(Bo,{className:"h-2 w-12"}),s.jsx(Bo,{className:"h-4 w-full"}),s.jsx(Bo,{className:"h-4 w-3/4"})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsx(Bo,{className:"aspect-video w-full"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Bo,{className:"h-4 w-24"}),s.jsx(Bo,{className:"h-8 w-full"}),s.jsx(Bo,{className:"h-8 w-1/2"})]})]});function yye(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const bye=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,vye=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,wye={};function W9(e,t){return(wye.jsx?vye:bye).test(e)}const Nye=/[ \t\n\f\r]/g;function Eye(e){return typeof e=="object"?e.type==="text"?K9(e.value):!1:K9(e)}function K9(e){return e.replace(Nye,"")===""}class zy{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}zy.prototype.normal={};zy.prototype.property={};zy.prototype.space=void 0;function bK(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new zy(n,r,t)}function FC(e){return e.toLowerCase()}class wl{constructor(t,n){this.attribute=n,this.property=t}}wl.prototype.attribute="";wl.prototype.booleanish=!1;wl.prototype.boolean=!1;wl.prototype.commaOrSpaceSeparated=!1;wl.prototype.commaSeparated=!1;wl.prototype.defined=!1;wl.prototype.mustUseProperty=!1;wl.prototype.number=!1;wl.prototype.overloadedBoolean=!1;wl.prototype.property="";wl.prototype.spaceSeparated=!1;wl.prototype.space=void 0;let Aye=0;const Lr=xm(),ca=xm(),$C=xm(),Xt=xm(),os=xm(),B0=xm(),jl=xm();function xm(){return 2**++Aye}const HC=Object.freeze(Object.defineProperty({__proto__:null,boolean:Lr,booleanish:ca,commaOrSpaceSeparated:jl,commaSeparated:B0,number:Xt,overloadedBoolean:$C,spaceSeparated:os},Symbol.toStringTag,{value:"Module"})),vS=Object.keys(HC);class ZT extends wl{constructor(t,n,r,i){let a=-1;if(super(t,n),Y9(this,"space",i),typeof r=="number")for(;++a4&&n.slice(0,4)==="data"&&Iye.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(X9,Oye);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!X9.test(a)){let o=a.replace(Cye,Tye);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=ZT}return new i(r,t)}function Tye(e){return"-"+e.toLowerCase()}function Oye(e){return e.charAt(1).toUpperCase()}const Pye=bK([vK,_ye,EK,AK,_K],"html"),JT=bK([vK,Sye,EK,AK,_K],"svg");function Rye(e){return e.join(" ").trim()}var o0={},wS,Q9;function Dye(){if(Q9)return wS;Q9=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,c=/^\s+|\s+$/g,h=` `,f="/",m="*",y="",w="comment",A="declaration";function k(T,D){if(typeof T!="string")throw new TypeError("First argument must be a string");if(!T)return[];D=D||{};var F=1,L=1;function q(he){var te=he.match(t);te&&(F+=te.length);var le=he.lastIndexOf(h);L=~le?he.length-le:L+he.length}function Z(){var he={line:F,column:L};return function(te){return te.position=new K(he),V(),te}}function K(he){this.start=he,this.end={line:F,column:L},this.source=D.source}K.prototype.content=T;function z(he){var te=new Error(D.source+":"+F+":"+L+": "+he);if(te.reason=he,te.filename=D.source,te.line=F,te.column=L,te.source=T,!D.silent)throw te}function B(he){var te=he.exec(T);if(te){var le=te[0];return q(le),T=T.slice(le.length),te}}function V(){B(n)}function $(he){var te;for(he=he||[];te=Q();)te!==!1&&he.push(te);return he}function Q(){var he=Z();if(!(f!=T.charAt(0)||m!=T.charAt(1))){for(var te=2;y!=T.charAt(te)&&(m!=T.charAt(te)||f!=T.charAt(te+1));)++te;if(te+=2,y===T.charAt(te-1))return z("End of comment missing");var le=T.slice(2,te-2);return L+=2,q(le),T=T.slice(te),L+=2,he({type:w,comment:le})}}function Y(){var he=Z(),te=B(r);if(te){if(Q(),!B(i))return z("property missing ':'");var le=B(a),ve=he({type:A,property:I(te[0].replace(e,y)),value:le?I(le[0].replace(e,y)):y});return B(o),ve}}function G(){var he=[];$(he);for(var te;te=Y();)te!==!1&&(he.push(te),$(he));return he}return V(),G()}function I(T){return T?T.replace(c,y):y}return wS=k,wS}var Z9;function Mye(){if(Z9)return o0;Z9=1;var e=o0&&o0.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(o0,"__esModule",{value:!0}),o0.default=n;const t=e(Dye());function n(r,i){let a=null;if(!r||typeof r!="string")return a;const o=(0,t.default)(r),c=typeof i=="function";return o.forEach(h=>{if(h.type!=="declaration")return;const{property:f,value:m}=h;c?i(f,m,h):m&&(a=a||{},a[f]=m)}),a}return o0}var Ux={},J9;function Lye(){if(J9)return Ux;J9=1,Object.defineProperty(Ux,"__esModule",{value:!0}),Ux.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,a=function(f){return!f||n.test(f)||e.test(f)},o=function(f,m){return m.toUpperCase()},c=function(f,m){return"".concat(m,"-")},h=function(f,m){return m===void 0&&(m={}),a(f)?f:(f=f.toLowerCase(),m.reactCompat?f=f.replace(i,c):f=f.replace(r,c),f.replace(t,o))};return Ux.camelCase=h,Ux}var Bx,eL;function Uye(){if(eL)return Bx;eL=1;var e=Bx&&Bx.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Mye()),n=Lye();function r(i,a){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(c,h){c&&h&&(o[(0,n.camelCase)(c,a)]=h)}),o}return r.default=r,Bx=r,Bx}var Bye=Uye();const zye=Hu(Bye),SK=kK("end"),e4=kK("start");function kK(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Vye(e){const t=e4(e),n=SK(e);if(t&&n)return{start:t,end:n}}function I1(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?tL(e.position):"start"in e||"end"in e?tL(e):"line"in e||"column"in e?GC(e):""}function GC(e){return nL(e&&e.line)+":"+nL(e&&e.column)}function tL(e){return GC(e&&e.start)+"-"+GC(e&&e.end)}function nL(e){return e&&typeof e=="number"?e:1}class Co extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",a={},o=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?i=t:!a.cause&&t&&(o=!0,i=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof r=="string"){const h=r.indexOf(":");h===-1?a.ruleId=r:(a.source=r.slice(0,h),a.ruleId=r.slice(h+1))}if(!a.place&&a.ancestors&&a.ancestors){const h=a.ancestors[a.ancestors.length-1];h&&(a.place=h.position)}const c=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=c?c.line:void 0,this.name=I1(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=o&&a.cause&&typeof a.cause.stack=="string"?a.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Co.prototype.file="";Co.prototype.name="";Co.prototype.reason="";Co.prototype.message="";Co.prototype.stack="";Co.prototype.column=void 0;Co.prototype.line=void 0;Co.prototype.ancestors=void 0;Co.prototype.cause=void 0;Co.prototype.fatal=void 0;Co.prototype.place=void 0;Co.prototype.ruleId=void 0;Co.prototype.source=void 0;const t4={}.hasOwnProperty,Fye=new Map,$ye=/[A-Z]/g,Hye=new Set(["table","tbody","thead","tfoot","tr"]),Gye=new Set(["td","th"]),CK="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function qye(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=ebe(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Jye(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?JT:Pye,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=IK(i,e,void 0);return a&&typeof a!="string"?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function IK(e,t,n){if(t.type==="element")return Wye(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Kye(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Xye(e,t,n);if(t.type==="mdxjsEsm")return Yye(e,t);if(t.type==="root")return Qye(e,t,n);if(t.type==="text")return Zye(e,t)}function Wye(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=JT,e.schema=i),e.ancestors.push(t);const a=TK(e,t.tagName,!1),o=tbe(e,t);let c=r4(e,t);return Hye.has(t.tagName)&&(c=c.filter(function(h){return typeof h=="string"?!Eye(h):!0})),jK(e,o,a,t),n4(o,c),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Kye(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ty(e,t.position)}function Yye(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ty(e,t.position)}function Xye(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=JT,e.schema=i),e.ancestors.push(t);const a=t.name===null?e.Fragment:TK(e,t.name,!0),o=nbe(e,t),c=r4(e,t);return jK(e,o,a,t),n4(o,c),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Qye(e,t,n){const r={};return n4(r,r4(e,t)),e.create(t,e.Fragment,r,n)}function Zye(e,t){return t.value}function jK(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function n4(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Jye(e,t,n){return r;function r(i,a,o,c){const f=Array.isArray(o.children)?n:t;return c?f(a,o,c):f(a,o)}}function ebe(e,t){return n;function n(r,i,a,o){const c=Array.isArray(a.children),h=e4(r);return t(i,a,o,c,{columnNumber:h?h.column-1:void 0,fileName:e,lineNumber:h?h.line:void 0},void 0)}}function tbe(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&t4.call(t.properties,i)){const a=rbe(e,i,t.properties[i]);if(a){const[o,c]=a;e.tableCellAlignToStyle&&o==="align"&&typeof c=="string"&&Gye.has(t.tagName)?r=c:n[o]=c}}if(r){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function nbe(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const o=a.expression;o.type;const c=o.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else ty(e,t.position);else{const i=r.name;let a;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const c=r.value.data.estree.body[0];c.type,a=e.evaluater.evaluateExpression(c.expression)}else ty(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function r4(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Fye;for(;++ri?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a0?(Lu(e,e.length,0,t),e):t}const sL={}.hasOwnProperty;function dbe(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function z0(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const vu=If(/[A-Za-z]/),Ul=If(/[\dA-Za-z]/),pbe=If(/[#-'*+\--9=?A-Z^-~]/);function qC(e){return e!==null&&(e<32||e===127)}const WC=If(/\d/),mbe=If(/[\dA-Fa-f]/),gbe=If(/[!-/:-@[-`{-~]/);function br(e){return e!==null&&e<-2}function vl(e){return e!==null&&(e<0||e===32)}function Ri(e){return e===-2||e===-1||e===32}const xbe=If(new RegExp("\\p{P}|\\p{S}","u")),ybe=If(/\s/);function If(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Mg(e){const t=[];let n=-1,r=0,i=0;for(;++n55295&&a<57344){const c=e.charCodeAt(n+1);a<56320&&c>56319&&c<57344?(o=String.fromCharCode(a,c),i=1):o="�"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function us(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(h){return Ri(h)?(e.enter(n),c(h)):t(h)}function c(h){return Ri(h)&&a++o))return;const z=t.events.length;let B=z,V,$;for(;B--;)if(t.events[B][0]==="exit"&&t.events[B][1].type==="chunkFlow"){if(V){$=t.events[B][1].end;break}V=!0}for(D(r),K=z;KL;){const Z=n[q];t.containerState=Z[1],Z[0].exit.call(t,e)}n.length=L}function F(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Ebe(e,t,n){return us(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function oL(e){if(e===null||vl(e)||ybe(e))return 1;if(xbe(e))return 2}function s4(e,t,n){const r=[];let i=-1;for(;++i1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const y={...e[r][1].end},w={...e[n][1].start};lL(y,-h),lL(w,h),o={type:h>1?"strongSequence":"emphasisSequence",start:y,end:{...e[r][1].end}},c={type:h>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:w},a={type:h>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:h>1?"strong":"emphasis",start:{...o.start},end:{...c.end}},e[r][1].end={...o.start},e[n][1].start={...c.end},f=[],e[r][1].end.offset-e[r][1].start.offset&&(f=ic(f,[["enter",e[r][1],t],["exit",e[r][1],t]])),f=ic(f,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",a,t]]),f=ic(f,s4(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),f=ic(f,[["exit",a,t],["enter",c,t],["exit",c,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(m=2,f=ic(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):m=0,Lu(e,r-1,n-r+3,f),n=r+f.length-m-2;break}}for(n=-1;++n0&&Ri(K)?us(e,F,"linePrefix",a+1)(K):F(K)}function F(K){return K===null||br(K)?e.check(cL,I,q)(K):(e.enter("codeFlowValue"),L(K))}function L(K){return K===null||br(K)?(e.exit("codeFlowValue"),F(K)):(e.consume(K),L)}function q(K){return e.exit("codeFenced"),t(K)}function Z(K,z,B){let V=0;return $;function $(te){return K.enter("lineEnding"),K.consume(te),K.exit("lineEnding"),Q}function Q(te){return K.enter("codeFencedFence"),Ri(te)?us(K,Y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(te):Y(te)}function Y(te){return te===c?(K.enter("codeFencedFenceSequence"),G(te)):B(te)}function G(te){return te===c?(V++,K.consume(te),G):V>=o?(K.exit("codeFencedFenceSequence"),Ri(te)?us(K,he,"whitespace")(te):he(te)):B(te)}function he(te){return te===null||br(te)?(K.exit("codeFencedFence"),z(te)):B(te)}}}function Dbe(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const ES={name:"codeIndented",tokenize:Lbe},Mbe={partial:!0,tokenize:Ube};function Lbe(e,t,n){const r=this;return i;function i(f){return e.enter("codeIndented"),us(e,a,"linePrefix",5)(f)}function a(f){const m=r.events[r.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?o(f):n(f)}function o(f){return f===null?h(f):br(f)?e.attempt(Mbe,o,h)(f):(e.enter("codeFlowValue"),c(f))}function c(f){return f===null||br(f)?(e.exit("codeFlowValue"),o(f)):(e.consume(f),c)}function h(f){return e.exit("codeIndented"),t(f)}}function Ube(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):br(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):us(e,a,"linePrefix",5)(o)}function a(o){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(o):br(o)?i(o):n(o)}}const Bbe={name:"codeText",previous:Vbe,resolve:zbe,tokenize:Fbe};function zbe(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&zx(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),zx(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),zx(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function UK(e,t,n,r,i,a,o,c,h){const f=h||Number.POSITIVE_INFINITY;let m=0;return y;function y(D){return D===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(D),e.exit(a),w):D===null||D===32||D===41||qC(D)?n(D):(e.enter(r),e.enter(o),e.enter(c),e.enter("chunkString",{contentType:"string"}),I(D))}function w(D){return D===62?(e.enter(a),e.consume(D),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),A(D))}function A(D){return D===62?(e.exit("chunkString"),e.exit(c),w(D)):D===null||D===60||br(D)?n(D):(e.consume(D),D===92?k:A)}function k(D){return D===60||D===62||D===92?(e.consume(D),A):A(D)}function I(D){return!m&&(D===null||D===41||vl(D))?(e.exit("chunkString"),e.exit(c),e.exit(o),e.exit(r),t(D)):m999||A===null||A===91||A===93&&!h||A===94&&!c&&"_hiddenFootnoteSupport"in o.parser.constructs?n(A):A===93?(e.exit(a),e.enter(i),e.consume(A),e.exit(i),e.exit(r),t):br(A)?(e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),y(A))}function y(A){return A===null||A===91||A===93||br(A)||c++>999?(e.exit("chunkString"),m(A)):(e.consume(A),h||(h=!Ri(A)),A===92?w:y)}function w(A){return A===91||A===92||A===93?(e.consume(A),c++,y):y(A)}}function zK(e,t,n,r,i,a){let o;return c;function c(w){return w===34||w===39||w===40?(e.enter(r),e.enter(i),e.consume(w),e.exit(i),o=w===40?41:w,h):n(w)}function h(w){return w===o?(e.enter(i),e.consume(w),e.exit(i),e.exit(r),t):(e.enter(a),f(w))}function f(w){return w===o?(e.exit(a),h(o)):w===null?n(w):br(w)?(e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),us(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(w))}function m(w){return w===o||w===null||br(w)?(e.exit("chunkString"),f(w)):(e.consume(w),w===92?y:m)}function y(w){return w===o||w===92?(e.consume(w),m):m(w)}}function j1(e,t){let n;return r;function r(i){return br(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ri(i)?us(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Xbe={name:"definition",tokenize:Zbe},Qbe={partial:!0,tokenize:Jbe};function Zbe(e,t,n){const r=this;let i;return a;function a(A){return e.enter("definition"),o(A)}function o(A){return BK.call(r,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(A)}function c(A){return i=z0(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),A===58?(e.enter("definitionMarker"),e.consume(A),e.exit("definitionMarker"),h):n(A)}function h(A){return vl(A)?j1(e,f)(A):f(A)}function f(A){return UK(e,m,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(A)}function m(A){return e.attempt(Qbe,y,y)(A)}function y(A){return Ri(A)?us(e,w,"whitespace")(A):w(A)}function w(A){return A===null||br(A)?(e.exit("definition"),r.parser.defined.push(i),t(A)):n(A)}}function Jbe(e,t,n){return r;function r(c){return vl(c)?j1(e,i)(c):n(c)}function i(c){return zK(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function a(c){return Ri(c)?us(e,o,"whitespace")(c):o(c)}function o(c){return c===null||br(c)?t(c):n(c)}}const eve={name:"hardBreakEscape",tokenize:tve};function tve(e,t,n){return r;function r(a){return e.enter("hardBreakEscape"),e.consume(a),i}function i(a){return br(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const nve={name:"headingAtx",resolve:rve,tokenize:ive};function rve(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},a={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Lu(e,r,n-r+1,[["enter",i,t],["enter",a,t],["exit",a,t],["exit",i,t]])),e}function ive(e,t,n){let r=0;return i;function i(m){return e.enter("atxHeading"),a(m)}function a(m){return e.enter("atxHeadingSequence"),o(m)}function o(m){return m===35&&r++<6?(e.consume(m),o):m===null||vl(m)?(e.exit("atxHeadingSequence"),c(m)):n(m)}function c(m){return m===35?(e.enter("atxHeadingSequence"),h(m)):m===null||br(m)?(e.exit("atxHeading"),t(m)):Ri(m)?us(e,c,"whitespace")(m):(e.enter("atxHeadingText"),f(m))}function h(m){return m===35?(e.consume(m),h):(e.exit("atxHeadingSequence"),c(m))}function f(m){return m===null||m===35||vl(m)?(e.exit("atxHeadingText"),c(m)):(e.consume(m),f)}}const sve=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],dL=["pre","script","style","textarea"],ave={concrete:!0,name:"htmlFlow",resolveTo:cve,tokenize:uve},ove={partial:!0,tokenize:hve},lve={partial:!0,tokenize:dve};function cve(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function uve(e,t,n){const r=this;let i,a,o,c,h;return f;function f(ae){return m(ae)}function m(ae){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(ae),y}function y(ae){return ae===33?(e.consume(ae),w):ae===47?(e.consume(ae),a=!0,I):ae===63?(e.consume(ae),i=3,r.interrupt?t:J):vu(ae)?(e.consume(ae),o=String.fromCharCode(ae),T):n(ae)}function w(ae){return ae===45?(e.consume(ae),i=2,A):ae===91?(e.consume(ae),i=5,c=0,k):vu(ae)?(e.consume(ae),i=4,r.interrupt?t:J):n(ae)}function A(ae){return ae===45?(e.consume(ae),r.interrupt?t:J):n(ae)}function k(ae){const Fe="CDATA[";return ae===Fe.charCodeAt(c++)?(e.consume(ae),c===Fe.length?r.interrupt?t:Y:k):n(ae)}function I(ae){return vu(ae)?(e.consume(ae),o=String.fromCharCode(ae),T):n(ae)}function T(ae){if(ae===null||ae===47||ae===62||vl(ae)){const Fe=ae===47,pt=o.toLowerCase();return!Fe&&!a&&dL.includes(pt)?(i=1,r.interrupt?t(ae):Y(ae)):sve.includes(o.toLowerCase())?(i=6,Fe?(e.consume(ae),D):r.interrupt?t(ae):Y(ae)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(ae):a?F(ae):L(ae))}return ae===45||Ul(ae)?(e.consume(ae),o+=String.fromCharCode(ae),T):n(ae)}function D(ae){return ae===62?(e.consume(ae),r.interrupt?t:Y):n(ae)}function F(ae){return Ri(ae)?(e.consume(ae),F):$(ae)}function L(ae){return ae===47?(e.consume(ae),$):ae===58||ae===95||vu(ae)?(e.consume(ae),q):Ri(ae)?(e.consume(ae),L):$(ae)}function q(ae){return ae===45||ae===46||ae===58||ae===95||Ul(ae)?(e.consume(ae),q):Z(ae)}function Z(ae){return ae===61?(e.consume(ae),K):Ri(ae)?(e.consume(ae),Z):L(ae)}function K(ae){return ae===null||ae===60||ae===61||ae===62||ae===96?n(ae):ae===34||ae===39?(e.consume(ae),h=ae,z):Ri(ae)?(e.consume(ae),K):B(ae)}function z(ae){return ae===h?(e.consume(ae),h=null,V):ae===null||br(ae)?n(ae):(e.consume(ae),z)}function B(ae){return ae===null||ae===34||ae===39||ae===47||ae===60||ae===61||ae===62||ae===96||vl(ae)?Z(ae):(e.consume(ae),B)}function V(ae){return ae===47||ae===62||Ri(ae)?L(ae):n(ae)}function $(ae){return ae===62?(e.consume(ae),Q):n(ae)}function Q(ae){return ae===null||br(ae)?Y(ae):Ri(ae)?(e.consume(ae),Q):n(ae)}function Y(ae){return ae===45&&i===2?(e.consume(ae),le):ae===60&&i===1?(e.consume(ae),ve):ae===62&&i===4?(e.consume(ae),ie):ae===63&&i===3?(e.consume(ae),J):ae===93&&i===5?(e.consume(ae),Be):br(ae)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(ove,xe,G)(ae)):ae===null||br(ae)?(e.exit("htmlFlowData"),G(ae)):(e.consume(ae),Y)}function G(ae){return e.check(lve,he,xe)(ae)}function he(ae){return e.enter("lineEnding"),e.consume(ae),e.exit("lineEnding"),te}function te(ae){return ae===null||br(ae)?G(ae):(e.enter("htmlFlowData"),Y(ae))}function le(ae){return ae===45?(e.consume(ae),J):Y(ae)}function ve(ae){return ae===47?(e.consume(ae),o="",ke):Y(ae)}function ke(ae){if(ae===62){const Fe=o.toLowerCase();return dL.includes(Fe)?(e.consume(ae),ie):Y(ae)}return vu(ae)&&o.length<8?(e.consume(ae),o+=String.fromCharCode(ae),ke):Y(ae)}function Be(ae){return ae===93?(e.consume(ae),J):Y(ae)}function J(ae){return ae===62?(e.consume(ae),ie):ae===45&&i===2?(e.consume(ae),J):Y(ae)}function ie(ae){return ae===null||br(ae)?(e.exit("htmlFlowData"),xe(ae)):(e.consume(ae),ie)}function xe(ae){return e.exit("htmlFlow"),t(ae)}}function dve(e,t,n){const r=this;return i;function i(o){return br(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function hve(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(yE,t,n)}}const fve={name:"htmlText",tokenize:pve};function pve(e,t,n){const r=this;let i,a,o;return c;function c(J){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(J),h}function h(J){return J===33?(e.consume(J),f):J===47?(e.consume(J),Z):J===63?(e.consume(J),L):vu(J)?(e.consume(J),B):n(J)}function f(J){return J===45?(e.consume(J),m):J===91?(e.consume(J),a=0,k):vu(J)?(e.consume(J),F):n(J)}function m(J){return J===45?(e.consume(J),A):n(J)}function y(J){return J===null?n(J):J===45?(e.consume(J),w):br(J)?(o=y,ve(J)):(e.consume(J),y)}function w(J){return J===45?(e.consume(J),A):y(J)}function A(J){return J===62?le(J):J===45?w(J):y(J)}function k(J){const ie="CDATA[";return J===ie.charCodeAt(a++)?(e.consume(J),a===ie.length?I:k):n(J)}function I(J){return J===null?n(J):J===93?(e.consume(J),T):br(J)?(o=I,ve(J)):(e.consume(J),I)}function T(J){return J===93?(e.consume(J),D):I(J)}function D(J){return J===62?le(J):J===93?(e.consume(J),D):I(J)}function F(J){return J===null||J===62?le(J):br(J)?(o=F,ve(J)):(e.consume(J),F)}function L(J){return J===null?n(J):J===63?(e.consume(J),q):br(J)?(o=L,ve(J)):(e.consume(J),L)}function q(J){return J===62?le(J):L(J)}function Z(J){return vu(J)?(e.consume(J),K):n(J)}function K(J){return J===45||Ul(J)?(e.consume(J),K):z(J)}function z(J){return br(J)?(o=z,ve(J)):Ri(J)?(e.consume(J),z):le(J)}function B(J){return J===45||Ul(J)?(e.consume(J),B):J===47||J===62||vl(J)?V(J):n(J)}function V(J){return J===47?(e.consume(J),le):J===58||J===95||vu(J)?(e.consume(J),$):br(J)?(o=V,ve(J)):Ri(J)?(e.consume(J),V):le(J)}function $(J){return J===45||J===46||J===58||J===95||Ul(J)?(e.consume(J),$):Q(J)}function Q(J){return J===61?(e.consume(J),Y):br(J)?(o=Q,ve(J)):Ri(J)?(e.consume(J),Q):V(J)}function Y(J){return J===null||J===60||J===61||J===62||J===96?n(J):J===34||J===39?(e.consume(J),i=J,G):br(J)?(o=Y,ve(J)):Ri(J)?(e.consume(J),Y):(e.consume(J),he)}function G(J){return J===i?(e.consume(J),i=void 0,te):J===null?n(J):br(J)?(o=G,ve(J)):(e.consume(J),G)}function he(J){return J===null||J===34||J===39||J===60||J===61||J===96?n(J):J===47||J===62||vl(J)?V(J):(e.consume(J),he)}function te(J){return J===47||J===62||vl(J)?V(J):n(J)}function le(J){return J===62?(e.consume(J),e.exit("htmlTextData"),e.exit("htmlText"),t):n(J)}function ve(J){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(J),e.exit("lineEnding"),ke}function ke(J){return Ri(J)?us(e,Be,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(J):Be(J)}function Be(J){return e.enter("htmlTextData"),o(J)}}const a4={name:"labelEnd",resolveAll:yve,resolveTo:bve,tokenize:vve},mve={tokenize:wve},gve={tokenize:Nve},xve={tokenize:Eve};function yve(e){let t=-1;const n=[];for(;++t=3&&(f===null||br(f))?(e.exit("thematicBreak"),t(f)):n(f)}function h(f){return f===i?(e.consume(f),r++,h):(e.exit("thematicBreakSequence"),Ri(f)?us(e,c,"whitespace")(f):c(f))}}const hl={continuation:{tokenize:Pve},exit:Dve,name:"list",tokenize:Ove},jve={partial:!0,tokenize:Mve},Tve={partial:!0,tokenize:Rve};function Ove(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return c;function c(A){const k=r.containerState.type||(A===42||A===43||A===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!r.containerState.marker||A===r.containerState.marker:WC(A)){if(r.containerState.type||(r.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),A===42||A===45?e.check(kw,n,f)(A):f(A);if(!r.interrupt||A===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),h(A)}return n(A)}function h(A){return WC(A)&&++o<10?(e.consume(A),h):(!r.interrupt||o<2)&&(r.containerState.marker?A===r.containerState.marker:A===41||A===46)?(e.exit("listItemValue"),f(A)):n(A)}function f(A){return e.enter("listItemMarker"),e.consume(A),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||A,e.check(yE,r.interrupt?n:m,e.attempt(jve,w,y))}function m(A){return r.containerState.initialBlankLine=!0,a++,w(A)}function y(A){return Ri(A)?(e.enter("listItemPrefixWhitespace"),e.consume(A),e.exit("listItemPrefixWhitespace"),w):n(A)}function w(A){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(A)}}function Pve(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(yE,i,a);function i(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,us(e,t,"listItemIndent",r.containerState.size+1)(c)}function a(c){return r.containerState.furtherBlankLines||!Ri(c)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(c)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Tve,t,o)(c))}function o(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,us(e,e.attempt(hl,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function Rve(e,t,n){const r=this;return us(e,i,"listItemIndent",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function Dve(e){e.exit(this.containerState.type)}function Mve(e,t,n){const r=this;return us(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!Ri(a)&&o&&o[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const hL={name:"setextUnderline",resolveTo:Lve,tokenize:Uve};function Lve(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!a&&e[n][1].type==="definition"&&(a=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",a?(e.splice(i,0,["enter",o,t]),e.splice(a+1,0,["exit",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Uve(e,t,n){const r=this;let i;return a;function a(f){let m=r.events.length,y;for(;m--;)if(r.events[m][1].type!=="lineEnding"&&r.events[m][1].type!=="linePrefix"&&r.events[m][1].type!=="content"){y=r.events[m][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||y)?(e.enter("setextHeadingLine"),i=f,o(f)):n(f)}function o(f){return e.enter("setextHeadingLineSequence"),c(f)}function c(f){return f===i?(e.consume(f),c):(e.exit("setextHeadingLineSequence"),Ri(f)?us(e,h,"lineSuffix")(f):h(f))}function h(f){return f===null||br(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const Bve={tokenize:zve};function zve(e){const t=this,n=e.attempt(yE,r,e.attempt(this.parser.constructs.flowInitial,i,us(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Gbe,i)),"linePrefix")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Vve={resolveAll:FK()},Fve=VK("string"),$ve=VK("text");function VK(e){return{resolveAll:FK(e==="text"?Hve:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,c);return o;function o(m){return f(m)?a(m):c(m)}function c(m){if(m===null){n.consume(m);return}return n.enter("data"),n.consume(m),h}function h(m){return f(m)?(n.exit("data"),a(m)):(n.consume(m),h)}function f(m){if(m===null)return!0;const y=i[m];let w=-1;if(y)for(;++w-1){const c=o[0];typeof c=="string"?o[0]=c.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function rwe(e,t){let n=-1;const r=[];let i;for(;++n0){const hr=nn.tokenStack[nn.tokenStack.length-1];(hr[1]||pL).call(nn,void 0,hr[0])}for(Ot.position={start:Rh(Ve.length>0?Ve[0][1].start:{line:1,column:1,offset:0}),end:Rh(Ve.length>0?Ve[Ve.length-2][1].end:{line:1,column:1,offset:0})},dr=-1;++dr0&&(r.className=["language-"+i[0]]);let a={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:"element",tagName:"pre",properties:{},children:[a]},e.patch(t,a),a}function xwe(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ywe(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function bwe(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Mg(r.toLowerCase()),a=e.footnoteOrder.indexOf(r);let o,c=e.footnoteCounts.get(r);c===void 0?(c=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,c+=1,e.footnoteCounts.set(r,c);const h={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,h);const f={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(t,f),e.applyData(t,f)}function vwe(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function wwe(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function GK(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),a=i[0];a&&a.type==="text"?a.value="["+a.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function Nwe(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return GK(e,t);const i={src:Mg(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const a={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function Ewe(e,t){const n={src:Mg(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Awe(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function _we(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return GK(e,t);const i={href:Mg(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const a={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function Swe(e,t){const n={href:Mg(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function kwe(e,t,n){const r=e.all(t),i=n?Cwe(n):qK(t),a={},o=[];if(typeof t.checked=="boolean"){const m=r[0];let y;m&&m.type==="element"&&m.tagName==="p"?y=m:(y={type:"element",tagName:"p",properties:{},children:[]},r.unshift(y)),y.children.length>0&&y.children.unshift({type:"text",value:" "}),y.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let c=-1;for(;++c1}function Iwe(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},c=e4(t.children[1]),h=SK(t.children[t.children.length-1]);c&&h&&(o.position={start:c,end:h}),i.push(o)}const a={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function Rwe(e,t,n){const r=n?n.children:void 0,a=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,c=o?o.length:t.children.length;let h=-1;const f=[];for(;++h0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(xL(t.slice(i),i>0,!1)),a.join("")}function xL(e,t,n){let r=0,i=e.length;if(t){let a=e.codePointAt(r);for(;a===mL||a===gL;)r++,a=e.codePointAt(r)}if(n){let a=e.codePointAt(i-1);for(;a===mL||a===gL;)i--,a=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Lwe(e,t){const n={type:"text",value:Mwe(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Uwe(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Bwe={blockquote:pwe,break:mwe,code:gwe,delete:xwe,emphasis:ywe,footnoteReference:bwe,heading:vwe,html:wwe,imageReference:Nwe,image:Ewe,inlineCode:Awe,linkReference:_we,link:Swe,listItem:kwe,list:Iwe,paragraph:jwe,root:Twe,strong:Owe,table:Pwe,tableCell:Dwe,tableRow:Rwe,text:Lwe,thematicBreak:Uwe,toml:Iv,yaml:Iv,definition:Iv,footnoteDefinition:Iv};function Iv(){}const WK=-1,bE=0,T1=1,_2=2,o4=3,l4=4,c4=5,u4=6,KK=7,YK=8,yL=typeof self=="object"?self:globalThis,zwe=(e,t)=>{const n=(i,a)=>(e.set(a,i),i),r=i=>{if(e.has(i))return e.get(i);const[a,o]=t[i];switch(a){case bE:case WK:return n(o,i);case T1:{const c=n([],i);for(const h of o)c.push(r(h));return c}case _2:{const c=n({},i);for(const[h,f]of o)c[r(h)]=r(f);return c}case o4:return n(new Date(o),i);case l4:{const{source:c,flags:h}=o;return n(new RegExp(c,h),i)}case c4:{const c=n(new Map,i);for(const[h,f]of o)c.set(r(h),r(f));return c}case u4:{const c=n(new Set,i);for(const h of o)c.add(r(h));return c}case KK:{const{name:c,message:h}=o;return n(new yL[c](h),i)}case YK:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:c}=new Uint8Array(o);return n(new DataView(c),o)}}return n(new yL[a](o),i)};return r},bL=e=>zwe(new Map,e)(0),l0="",{toString:Vwe}={},{keys:Fwe}=Object,Vx=e=>{const t=typeof e;if(t!=="object"||!e)return[bE,t];const n=Vwe.call(e).slice(8,-1);switch(n){case"Array":return[T1,l0];case"Object":return[_2,l0];case"Date":return[o4,l0];case"RegExp":return[l4,l0];case"Map":return[c4,l0];case"Set":return[u4,l0];case"DataView":return[T1,n]}return n.includes("Array")?[T1,n]:n.includes("Error")?[KK,n]:[_2,n]},jv=([e,t])=>e===bE&&(t==="function"||t==="symbol"),$we=(e,t,n,r)=>{const i=(o,c)=>{const h=r.push(o)-1;return n.set(c,h),h},a=o=>{if(n.has(o))return n.get(o);let[c,h]=Vx(o);switch(c){case bE:{let m=o;switch(h){case"bigint":c=YK,m=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+h);m=null;break;case"undefined":return i([WK],o)}return i([c,m],o)}case T1:{if(h){let w=o;return h==="DataView"?w=new Uint8Array(o.buffer):h==="ArrayBuffer"&&(w=new Uint8Array(o)),i([h,[...w]],o)}const m=[],y=i([c,m],o);for(const w of o)m.push(a(w));return y}case _2:{if(h)switch(h){case"BigInt":return i([h,o.toString()],o);case"Boolean":case"Number":case"String":return i([h,o.valueOf()],o)}if(t&&"toJSON"in o)return a(o.toJSON());const m=[],y=i([c,m],o);for(const w of Fwe(o))(e||!jv(Vx(o[w])))&&m.push([a(w),a(o[w])]);return y}case o4:return i([c,o.toISOString()],o);case l4:{const{source:m,flags:y}=o;return i([c,{source:m,flags:y}],o)}case c4:{const m=[],y=i([c,m],o);for(const[w,A]of o)(e||!(jv(Vx(w))||jv(Vx(A))))&&m.push([a(w),a(A)]);return y}case u4:{const m=[],y=i([c,m],o);for(const w of o)(e||!jv(Vx(w)))&&m.push(a(w));return y}}const{message:f}=o;return i([c,{name:h,message:f}],o)};return a},vL=(e,{json:t,lossy:n}={})=>{const r=[];return $we(!(t||n),!!t,new Map,r)(e),r},S2=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?bL(vL(e,t)):structuredClone(e):(e,t)=>bL(vL(e,t));function Hwe(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Gwe(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function qwe(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Hwe,r=e.options.footnoteBackLabel||Gwe,i=e.options.footnoteLabel||"Footnotes",a=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let h=-1;for(;++h0&&k.push({type:"text",value:" "});let F=typeof n=="string"?n:n(h,A);typeof F=="string"&&(F={type:"text",value:F}),k.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+w+(A>1?"-"+A:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(h,A),className:["data-footnote-backref"]},children:Array.isArray(F)?F:[F]})}const T=m[m.length-1];if(T&&T.type==="element"&&T.tagName==="p"){const F=T.children[T.children.length-1];F&&F.type==="text"?F.value+=" ":T.children.push({type:"text",value:" "}),T.children.push(...k)}else m.push(...k);const D={type:"element",tagName:"li",properties:{id:t+"fn-"+w},children:e.wrap(m,!0)};e.patch(f,D),c.push(D)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{...S2(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:` `},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:` `}]}}const XK=(function(e){if(e==null)return Xwe;if(typeof e=="function")return vE(e);if(typeof e=="object")return Array.isArray(e)?Wwe(e):Kwe(e);if(typeof e=="string")return Ywe(e);throw new Error("Expected function, string, or object as test")});function Wwe(e){const t=[];let n=-1;for(;++n":""))+")"})}return w;function w(){let A=QK,k,I,T;if((!t||a(h,f,m[m.length-1]||void 0))&&(A=t2e(n(h,m)),A[0]===wL))return A;if("children"in h&&h.children){const D=h;if(D.children&&A[0]!==Jwe)for(I=(r?D.children.length:-1)+o,T=m.concat(D);I>-1&&I0&&n.push({type:"text",value:` `}),n}function NL(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function EL(e,t){const n=r2e(e,t),r=n.one(e,void 0),i=qwe(n),a=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&a.children.push({type:"text",value:` `},i),a}function l2e(e,t){return e&&"run"in e?async function(n,r){const i=EL(n,{file:r,...t});await e.run(i,r)}:function(n,r){return EL(n,{file:r,...e||t})}}function AL(e){if(e)throw e}var _S,_L;function c2e(){if(_L)return _S;_L=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},a=function(f){if(!f||t.call(f)!=="[object Object]")return!1;var m=e.call(f,"constructor"),y=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!m&&!y)return!1;var w;for(w in f);return typeof w>"u"||e.call(f,w)},o=function(f,m){n&&m.name==="__proto__"?n(f,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):f[m.name]=m.newValue},c=function(f,m){if(m==="__proto__")if(e.call(f,m)){if(r)return r(f,m).value}else return;return f[m]};return _S=function h(){var f,m,y,w,A,k,I=arguments[0],T=1,D=arguments.length,F=!1;for(typeof I=="boolean"&&(F=I,I=arguments[1]||{},T=2),(I==null||typeof I!="object"&&typeof I!="function")&&(I={});To.length;let h;c&&o.push(i);try{h=e.apply(this,o)}catch(f){const m=f;if(c&&n)throw m;return i(m)}c||(h&&h.then&&typeof h.then=="function"?h.then(a,i):h instanceof Error?i(h):a(h))}function i(o,...c){n||(n=!0,t(o,...c))}function a(o){i(null,o)}}const du={basename:f2e,dirname:p2e,extname:m2e,join:g2e,sep:"/"};function f2e(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Vy(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,c=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),c>-1&&(e.codePointAt(i)===t.codePointAt(c--)?c<0&&(r=i):(c=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function p2e(e){if(Vy(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function m2e(e){Vy(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){const c=e.codePointAt(t);if(c===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),c===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function g2e(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function y2e(e,t){let n="",r=0,i=-1,a=0,o=-1,c,h;for(;++o<=e.length;){if(o2){if(h=n.lastIndexOf("/"),h!==n.length-1){h<0?(n="",r=0):(n=n.slice(0,h),r=n.length-1-n.lastIndexOf("/")),i=o,a=0;continue}}else if(n.length>0){n="",r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else c===46&&a>-1?a++:a=-1}return n}function Vy(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const b2e={cwd:v2e};function v2e(){return"/"}function QC(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function w2e(e){if(typeof e=="string")e=new URL(e);else if(!QC(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return N2e(e)}function N2e(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n0){let[A,...k]=m;const I=r[w][1];XC(I)&&XC(A)&&(A=SS(!0,I,A)),r[w]=[f,A,...k]}}}}const S2e=new d4().freeze();function jS(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function TS(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function OS(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function kL(e){if(!XC(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function CL(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Tv(e){return k2e(e)?e:new JK(e)}function k2e(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function C2e(e){return typeof e=="string"||I2e(e)}function I2e(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const j2e="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",IL=[],jL={allowDangerousHtml:!0},T2e=/^(https?|ircs?|mailto|xmpp)$/i,O2e=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function O1(e){const t=P2e(e),n=R2e(e);return D2e(t.runSync(t.parse(n),n),e)}function P2e(e){const t=e.rehypePlugins||IL,n=e.remarkPlugins||IL,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...jL}:jL;return S2e().use(fwe).use(n).use(l2e,r).use(t)}function R2e(e){const t=e.children||"",n=new JK;return typeof t=="string"&&(n.value=t),n}function D2e(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,c=t.unwrapDisallowed,h=t.urlTransform||M2e;for(const m of O2e)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+j2e+m.id,void 0);return ZK(e,f),qye(e,{Fragment:s.Fragment,components:i,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function f(m,y,w){if(m.type==="raw"&&w&&typeof y=="number")return o?w.children.splice(y,1):w.children[y]={type:"text",value:m.value},y;if(m.type==="element"){let A;for(A in NS)if(Object.hasOwn(NS,A)&&Object.hasOwn(m.properties,A)){const k=m.properties[A],I=NS[A];(I===null||I.includes(m.tagName))&&(m.properties[A]=h(String(k||""),A,m))}}if(m.type==="element"){let A=n?!n.includes(m.tagName):a?a.includes(m.tagName):!1;if(!A&&r&&typeof y=="number"&&(A=!r(m,y,w)),A&&w&&typeof y=="number")return c&&m.children?w.children.splice(y,1,...m.children):w.children.splice(y,1),y}}}function M2e(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||T2e.test(e.slice(0,t))?e:""}const ZC=()=>{const[e,t]=j.useState([]),[n,r]=j.useState(!0),[i,a]=j.useState(null),[o,c]=j.useState(1),[h,f]=j.useState(""),[m,y]=j.useState(!1),[w,A]=j.useState(!1),[k,I]=j.useState(null),[T,D]=j.useState(null),[F,L]=j.useState(!1);j.useEffect(()=>{(async()=>{var V,$,Q,Y;if(Ne.currentUser){const G=["atwiinevictor2@gmail.com","campuseye@gmail.com"];try{const he=await cs(ot(pe,"admins",Ne.currentUser.uid)),te=await cs(ot(pe,"users",Ne.currentUser.uid)),le=he.exists()&&((V=he.data())==null?void 0:V.isAdmin)===!0||te.exists()&&((($=te.data())==null?void 0:$.isAdmin)===!0||((Q=te.data())==null?void 0:Q.role)==="admin")||G.includes(Ne.currentUser.email||"");L(le)}catch{L(G.includes(((Y=Ne.currentUser)==null?void 0:Y.email)||""))}}else L(!1)})()},[]),j.useEffect(()=>{const B=Qt(it(pe,"tickets"),pi("createdAt","desc"));vn(B).then(V=>{const $=V.docs.map(Q=>({id:Q.id,...Q.data()}));t($),r(!1)}).catch(V=>{console.warn("Failed to load tickets for feed embed:",V),r(!1)})},[]);const q=async B=>{if(!Ne.currentUser){me.error("Please sign in to book event passes");return}y(!0);try{const V=Math.floor(1e5+Math.random()*9e5),$=Math.random().toString(36).substring(2,5).toUpperCase(),Q=`TKT-${V}-${$}`;await ur(it(pe,"notifications"),{userId:Ne.currentUser.uid,title:`🔑 Ticket Security Code: ${B.title}`,message:`Your requested security verification code for "${B.title}" is ready. Enter this code to confirm your seat allocation. Note: This security key works once and is confidential.`,code:Q,used:!1,type:"verification_code",createdAt:new Date}),D(B.id),me.success("Security code dispatched to your System Inbox! Check bell menu or profile.",{duration:5e3})}catch(V){console.error("Error creating verification code:",V),me.error("Failed to issue security code. Please try again.")}finally{y(!1)}},Z=async()=>{var B,V,$;if(!(!Ne.currentUser||!i)){if(!h.trim()){me.error("Please paste the ticket confirmation code");return}A(!0);try{const Q=h.trim().toUpperCase(),Y=Qt(it(pe,"notifications"),Nr("userId","==",Ne.currentUser.uid),Nr("code","==",Q),Nr("used","==",!1)),G=await vn(Y);if(G.empty){me.error("Invalid, used, or expired security code. Please check your inbox."),A(!1);return}const he=G.docs[0],te=ot(pe,"notifications",he.id),le=ot(pe,"tickets",i.id),ve=await cs(le);if(!ve.exists()){me.error("Selected event session could not be located."),A(!1);return}const ke=ve.data();if(o>ke.remainingQuantity){me.error(`Not enough tickets remaining. Only ${ke.remainingQuantity} available.`),A(!1);return}if(await Hn(te,{used:!0}),await Hn(le,{remainingQuantity:Ur(-o)}),!Ne.currentUser){me.error("Please sign in to complete your ticket purchase"),A(!1);return}const Be={ticketId:i.id,ticketTitle:i.title,userId:((B=Ne.currentUser)==null?void 0:B.uid)||"",userName:((V=Ne.currentUser)==null?void 0:V.displayName)||"Campus Citizen",userEmail:(($=Ne.currentUser)==null?void 0:$.email)||"",price:i.price,totalAmount:i.price*o,quantity:o,purchaseDate:new Date,status:"confirmed"},J=await ur(it(pe,"purchases"),Be),ie={id:J.id,verificationCode:Q,venue:i.venue,eventDate:i.eventDate,...Be};I(ie),me.success(`Passes allocated under confirmation ID #${J.id.slice(-6).toUpperCase()}!`,{icon:"🎉"}),A(!1)}catch(Q){console.error("Verification sequence failed:",Q),me.error("Ticketing verification failed: "+Q.message),A(!1)}}},K=B=>{var V;if(B)try{const $=B.id.toUpperCase(),Q=B.verificationCode||"CONFIRMED",Y=` ============================================================ CAMPUS EYE DIGITAL EVENT PASS ============================================================ TICKET SERIAL: ${$} CONFIRMATION: ${Q} STATUS: VALID / ONE-TIME ENTRY ONLY ------------------------------------------------------------ EVENT DETAILS: Title: ${B.ticketTitle.toUpperCase()} Date: ${(V=B.eventDate)!=null&&V.toDate?B.eventDate.toDate().toLocaleString():new Date(B.eventDate).toLocaleString()} Venue: ${B.venue.toUpperCase()} Quantity: ${B.quantity} PASS(ES) Total Paid: UGX ${(B.totalAmount||0).toLocaleString()} ------------------------------------------------------------ HOLDER METADATA: Name: ${B.userName} Email: ${B.userEmail} Auth Class: STUDENT MEMBER / COMMUNITY REPORT ------------------------------------------------------------ SECURITY NOTICE: Present the numeric QR serial sequence on entrance. Do not share this offline ticket copy. It must match your in-app digital identification profile. ============================================================ `,G=new Blob([Y.trim()],{type:"text/plain;charset=utf-8"}),he=URL.createObjectURL(G),te=document.createElement("a");te.href=he,te.download=`EventPass-${B.ticketTitle.replace(/\s+/g,"-")}-${$.slice(-6)}.txt`,document.body.appendChild(te),te.click(),document.body.removeChild(te),URL.revokeObjectURL(he),me.success("Offline Text Ticket downloaded successfully!")}catch($){me.error("Download failed: "+$.message)}},z=B=>{let V=0;for(let Q=0;Q8||Q>8&&G<3;let le=!1;te?le=Q===0||Q===2||G===0||G===2||Q===0&&G===11||Q===2&&G===11||G===9&&(Q===0||Q===2)||Q===9&&G===0||Q===11&&G===0||G===2&&(Q===9||Q===11):le=Math.abs((V^he*7)%11)<4,Y.push(le)}$.push(Y)}return s.jsx("svg",{viewBox:"0 0 120 120",className:"w-32 h-32 bg-white p-2 border border-gray-150 rounded-xl shadow-inner mx-auto",children:$.map((Q,Y)=>Q.map((G,he)=>s.jsx("rect",{x:he*10,y:Y*10,width:9,height:9,rx:1.5,fill:G?"#0F172A":"transparent"},`${Y}-${he}`)))})};return n?null:e.length===0?s.jsx("div",{className:"p-8 text-center bg-gray-50 border border-gray-100 rounded-2xl select-none",children:s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"No Active Box Office Events Posted by Admin"})}):s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:e.slice(0,3).map(B=>{var $;i==null||i.id,B.id;const V=B.remainingQuantity<=0;return s.jsxs("div",{className:"bg-gray-55/5 border border-gray-150 rounded-2xl p-4 text-left flex flex-col justify-between hover:border-accent transition-colors relative overflow-hidden group",children:[V?s.jsx("div",{className:"absolute top-3 right-3 bg-gray-900 text-white text-[8px] font-black px-2 py-0.5 rounded-full uppercase",children:"Sold Out"}):B.remainingQuantity<10?s.jsxs("div",{className:"absolute top-3 right-3 bg-red-650 text-white text-[8px] font-black px-2 py-0.5 rounded-full uppercase",children:["Only ",B.remainingQuantity," Left!"]}):s.jsxs("div",{className:"absolute top-3 right-3 bg-accent text-white text-[8px] font-black px-2 py-0.5 rounded-full uppercase",children:[B.remainingQuantity," Remaining"]}),s.jsxs("div",{className:"flex gap-3 items-start w-full",children:[B.imageUrl&&s.jsx(Vi,{src:B.imageUrl,alt:B.title,className:"w-14 h-14 rounded-xl object-cover shrink-0 border border-gray-100/80 bg-gray-50 shadow-xs"}),s.jsxs("div",{className:"space-y-1 flex-1 min-w-0",children:[s.jsx("p",{className:"text-[8px] font-black text-accent uppercase tracking-widest leading-none mb-0.5",children:B.category}),s.jsx("h4",{className:"text-sm font-black text-gray-950 uppercase tracking-tight leading-snug group-hover:text-accent transition-colors line-clamp-2",children:B.title}),s.jsxs("div",{className:"flex flex-col gap-0.5 pt-1 text-gray-500 text-[9px] font-bold",children:[s.jsxs("span",{className:"flex items-center gap-1.5 truncate",children:[s.jsx(H0,{size:10,className:"shrink-0 text-gray-400"}),($=B.eventDate)!=null&&$.toDate?B.eventDate.toDate().toLocaleDateString(void 0,{dateStyle:"short"}):"TBA"]}),s.jsxs("span",{className:"flex items-center gap-1.5 truncate",children:[s.jsx(vk,{size:10,className:"shrink-0 text-gray-400"}),B.venue]})]}),B.link&&s.jsx("div",{className:"pt-1",children:s.jsxs("a",{href:B.link,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 text-[9px] text-blue-650 font-black uppercase tracking-wider hover:underline",onClick:Q=>Q.stopPropagation(),children:[s.jsx("span",{children:"Event Link"}),s.jsx(ej,{size:10,className:"text-blue-650"})]})})]})]}),s.jsxs("div",{className:"pt-4 border-t border-gray-100/60 mt-4 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[7.5px] font-black text-gray-400 uppercase tracking-widest leading-none mb-0.5",children:"Event Rate"}),s.jsxs("p",{className:"text-sm font-black text-gray-950",children:[s.jsx("span",{className:"text-[9px]",children:"UGX"})," ",B.price.toLocaleString()]})]}),s.jsx("button",{onClick:()=>{if(!Ne.currentUser){me.error("Please login to reserve coordinates");return}a(B),I(null),f(""),c(1)},disabled:V,className:"px-3.5 py-1.5 bg-gray-950 hover:bg-accent text-white disabled:bg-gray-100 disabled:text-gray-400 rounded-lg text-[9px] font-black uppercase tracking-widest transition-all cursor-pointer shadow-xs whitespace-nowrap",children:"Book Secure Pass"})]}),F&&s.jsxs("div",{className:"pt-3 border-t border-dashed border-gray-150 mt-3 flex gap-2 w-full",children:[s.jsx("button",{onClick:Q=>{Q.stopPropagation(),localStorage.setItem("edit_ticket_item",JSON.stringify(B));const Y=new CustomEvent("setTab",{detail:"admin"});window.dispatchEvent(Y),setTimeout(()=>{window.dispatchEvent(new CustomEvent("checkPendingTicketEdit"))},100)},className:"flex-1 py-1 px-2 bg-blue-50 text-blue-600 rounded-lg text-[8.5px] font-black uppercase tracking-wider hover:bg-blue-600 hover:text-white transition-all text-center cursor-pointer",children:"Edit"}),F&&s.jsx("button",{onClick:async Q=>{if(Q.stopPropagation(),!F){me.error("Access Denied: Only admins can delete tickets.");return}if(window.confirm("Are you sure you want to permanently delete this event ticket?"))try{await ni(ot(pe,"tickets",B.id)),me.success("Ticket deleted successfully")}catch(Y){me.error("Failed to delete ticket: "+Y.message)}},className:"flex-1 py-1 px-2 bg-red-50 text-red-650 rounded-lg text-[8.5px] font-black uppercase tracking-wider hover:bg-red-650 hover:text-white transition-all text-center cursor-pointer",title:"Delete Ticket (Master Admin)",children:"Delete"})]})]},B.id)})}),s.jsx(ar,{children:i&&s.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[s.jsx(Kt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>{!w&&!m&&(a(null),I(null))},className:"absolute inset-0 bg-black/60 backdrop-blur-xs"}),s.jsxs(Kt.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"relative bg-white w-full max-w-md rounded-2xl shadow-2xl p-6 text-left space-y-5 border border-gray-100 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-gray-100",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"p-1.5 bg-red-100 text-red-650 rounded-lg shrink-0",children:s.jsx(No,{size:14})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-black uppercase text-gray-950 tracking-wide",children:"SECURE EVENT GATEWAY"}),s.jsx("p",{className:"text-[8.5px] font-bold text-gray-400 uppercase tracking-wider",children:"Allocations require physical verification key"})]})]}),s.jsx("button",{onClick:()=>a(null),className:"p-1 text-gray-400 hover:text-black hover:bg-gray-50 rounded-full transition-all",children:"✕"})]}),k?s.jsxs("div",{className:"space-y-4 text-center",children:[s.jsxs("div",{className:"py-2",children:[s.jsx("div",{className:"w-12 h-12 bg-green-100 text-green-600 rounded-full flex items-center justify-center mx-auto mb-2 scale-110",children:s.jsx(Pu,{size:28,id:"ticket-success-check"})}),s.jsx("h4",{className:"text-sm font-black text-gray-950 uppercase tracking-tight leading-none mb-1",children:"Pass Issued Successfully"}),s.jsxs("p",{className:"text-[9px] text-gray-400 font-bold uppercase tracking-wider",children:["Secure Serial: #",k.id.slice(-6).toUpperCase()]})]}),s.jsxs("div",{className:"p-4 bg-gray-50 border border-gray-150 rounded-xl space-y-3",children:[z(`ticket_serial_${k.id}`),s.jsxs("div",{className:"space-y-0.5 text-center mt-2",children:[s.jsx("p",{className:"text-[11px] font-semibold text-gray-800 leading-tight truncate uppercase",children:i.title}),s.jsx("p",{className:"text-[8px] font-bold text-gray-400 uppercase tracking-widest",children:i.venue}),s.jsxs("p",{className:"text-[8px] font-black text-gray-500 mt-1 uppercase",children:["Pass Quantity: ",k.quantity," • Verified Conf"]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:()=>K(k),className:"w-full py-3 bg-black hover:bg-gray-950 text-white font-black uppercase text-[9px] tracking-widest rounded-lg flex items-center justify-center gap-1.5 transition-colors cursor-pointer",children:[s.jsx(IN,{size:12}),"Download Pass"]}),s.jsx("button",{onClick:()=>a(null),className:"w-full py-3 bg-gray-100 hover:bg-gray-200 text-gray-800 font-black uppercase text-[9px] tracking-widest rounded-lg transition-colors cursor-pointer",children:"Done"})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"bg-gray-50 border border-gray-150 p-3.5 rounded-xl space-y-2",children:[s.jsx("p",{className:"text-[8.5px] font-bold text-gray-400 uppercase tracking-widest leading-none",children:"Selected Event Coordinates"}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-black text-gray-950 uppercase tracking-tight",children:i.title}),s.jsxs("div",{className:"flex items-center gap-4 mt-1 text-[9px] font-black text-accent uppercase font-mono",children:[s.jsxs("span",{children:["UGX ",i.price.toLocaleString()," RATE"]}),s.jsx("span",{children:"•"}),s.jsxs("span",{children:[i.remainingQuantity," SEATS REMAINING"]})]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-gray-200/50",children:[s.jsx("span",{className:"text-[10px] font-black text-gray-600 uppercase",children:"Quantity"}),s.jsxs("div",{className:"flex items-center gap-3 bg-white border border-gray-150 rounded-lg p-1",children:[s.jsx("button",{onClick:()=>c(Math.max(1,o-1)),className:"w-6 h-6 flex items-center justify-center text-xs font-bold hover:bg-gray-100 rounded",children:"-"}),s.jsx("span",{className:"text-xs font-black text-gray-850 w-5 text-center",children:o}),s.jsx("button",{onClick:()=>c(Math.min(i.remainingQuantity,o+1)),className:"w-6 h-6 flex items-center justify-center text-xs font-bold hover:bg-gray-100 rounded",children:"+"})]})]})]}),s.jsxs("div",{className:"space-y-2 text-center py-1",children:[s.jsx("p",{className:"text-[9px] text-gray-500 font-medium",children:"Ticketing is locked to prevent fraud. Send a secure confirmation OTP to your system index, then verify below to authorize."}),s.jsx("button",{onClick:()=>q(i),disabled:m,className:"px-4 py-2 bg-red-50 hover:bg-red-100 text-red-650 rounded-xl text-[9.5px] font-black uppercase tracking-wider transition-colors inline-flex items-center gap-1.5 cursor-pointer disabled:opacity-50",children:m?s.jsxs(s.Fragment,{children:[s.jsx(Pr,{className:"animate-spin",size:12}),"Broadcasting Key..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Js,{size:12}),"Request Verification Code (System Inbox)"]})})]}),s.jsxs("div",{className:"space-y-2 pt-2 border-t border-gray-100",children:[s.jsx("label",{className:"text-[9.5px] font-black text-gray-900 uppercase tracking-wide block",children:"CONFIRMATION CODE KEY"}),s.jsx("div",{className:"relative",children:s.jsx("input",{type:"text",value:h,onChange:B=>f(B.target.value),placeholder:"e.g. TKT-94285-ABC",className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 focus:border-black focus:bg-white rounded-xl text-xs font-black placeholder:text-gray-300 outline-none uppercase tracking-widest text-center"})})]}),s.jsx("button",{onClick:Z,disabled:w||!h.trim(),className:"w-full py-4 bg-gray-950 hover:bg-accent disabled:bg-gray-100 disabled:text-gray-400 text-white rounded-xl text-[10px] font-black uppercase tracking-widest transition-all shadow-md flex items-center justify-center gap-2 cursor-pointer",children:w?s.jsxs(s.Fragment,{children:[s.jsx(Pr,{className:"animate-spin",size:14}),"Authorizing Digital Stamp..."]}):s.jsxs(s.Fragment,{children:[s.jsx(pl,{size:14}),"Verify Confirmation Key & Issue Pass"]})})]})]})]})})]})},eY=({value:e,onSelectMention:t,className:n})=>{const r=e.match(/@([a-zA-Z0-9_]*)$/);if(!r)return null;const i=r[1].toLowerCase();if(!["","m","me","meg","mega","megaai","ai","bot"].some(c=>c.startsWith(i)||i.startsWith(c)))return null;const o=()=>{const c=e.replace(/@([a-zA-Z0-9_]*)$/,"@Mega AI ");t(c)};return s.jsx("div",{className:Ge("relative z-30 my-1.5",n),children:s.jsxs("div",{onClick:o,className:"bg-gradient-to-r from-amber-50 via-white to-red-50 border border-amber-300 rounded-2xl p-2.5 shadow-lg shadow-amber-500/10 flex items-center justify-between cursor-pointer hover:border-amber-500 transition-all group animate-in fade-in slide-in-from-bottom-2 duration-150",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("img",{src:Vo,alt:"Mega AI",className:"w-8 h-8 rounded-xl object-cover border border-amber-400/50 shadow-xs shrink-0 group-hover:scale-105 transition-transform"}),s.jsxs("div",{className:"text-left",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-xs font-black uppercase text-gray-950 tracking-tight",children:"Mega AI"}),s.jsx("span",{className:"text-[9px] font-mono font-bold text-amber-700 bg-amber-100/80 px-1.5 py-0.2 rounded",children:"@Mega AI"})]}),s.jsxs("p",{className:"text-[9.5px] font-medium text-gray-500 flex items-center gap-1",children:[s.jsx(es,{size:10,className:"text-amber-500 shrink-0"}),s.jsx("span",{children:"Tap to mention for an instant AI smart response"})]})]})]}),s.jsxs("div",{className:"px-2.5 py-1 bg-amber-500 hover:bg-amber-600 text-white rounded-xl text-[9.5px] font-black uppercase tracking-wider shrink-0 transition-colors flex items-center gap-1 shadow-2xs",children:[s.jsx("span",{children:"Mention"}),s.jsx(Pu,{size:11})]})]})})},TL=["🔥","🤯","😢","👏","❤️","😂","👍","🎉","😡","✨","💯","👀","🚀","💡","🙌","🔊","⚽","🎮","💡","🎓","📢","💀","💩","💪","👑","❌"],L2e=({article:e,onClose:t,isAdmin:n,allArticles:r=[],onArticleSelect:i,onCategorySelect:a})=>{var Ui,$n;const[o,c]=j.useState(e);j.useEffect(()=>{if(c(e),!(e!=null&&e.id))return;const be=di(ot(pe,"articles",e.id),je=>{je.exists()&&c({id:je.id,...je.data()})},je=>{console.warn("Realtime article sync error:",je)});return()=>be()},[e==null?void 0:e.id]);const[h,f]=j.useState([]),[m,y]=j.useState(""),[w,A]=j.useState(null),[k,I]=j.useState(!1),[T,D]=j.useState(!1),F=be=>{if(be.clipboardData&&be.clipboardData.files&&be.clipboardData.files.length>0){const je=be.clipboardData.files[0];if(je&&je.type.startsWith("image/")){const ze=new FileReader;ze.onload=tt=>{var fn;(fn=tt.target)!=null&&fn.result&&(A(tt.target.result),sr.success("Sticker / device image attached!"))},ze.readAsDataURL(je)}}},L=be=>{var ze;const je=(ze=be.target.files)==null?void 0:ze[0];if(je){if(je.size>10*1024*1024){sr.error("Please select an image smaller than 10MB");return}const tt=new FileReader;tt.onload=fn=>{var Bt;(Bt=fn.target)!=null&&Bt.result&&(A(fn.target.result),sr.success("Device sticker/image attached!"))},tt.readAsDataURL(je)}},[q,Z]=j.useState(!1),[K,z]=j.useState(!1),[B,V]=j.useState(null),[$,Q]=j.useState(null),[Y,G]=j.useState(!0),[he,te]=j.useState(!1),[le,ve]=j.useState(!1),[ke,Be]=j.useState(null),[J,ie]=j.useState(0),[xe,ae]=j.useState(!1),[Fe,pt]=j.useState(!1),[Ue,Ct]=j.useState([]),[Tt,ht]=j.useState([]),[Ye,Yt]=j.useState(!1);j.useEffect(()=>{const be=Qt(it(pe,"sponsors")),je=Qt(it(pe,"adverts"),Pi(20));Promise.all([vn(be).catch(()=>null),vn(je).catch(()=>null)]).then(([ze,tt])=>{const fn=[];ze&&!ze.empty&&ze.docs.forEach(Bt=>fn.push({id:Bt.id,...Bt.data()})),tt&&!tt.empty&&tt.docs.forEach(Bt=>{const jn=Bt.data();(jn.imageUrl||jn.mediaUrl)&&fn.push({id:Bt.id,name:jn.company||jn.title||"Partner",imageUrl:jn.imageUrl||jn.mediaUrl||"",link:jn.targetUrl||jn.link||"#"})}),ht(fn)})},[]),j.useEffect(()=>{const be=Qt(it(pe,"custom_pages"),pi("createdAt","desc"));vn(be).then(je=>{Ct(je.docs.map(ze=>({id:ze.id,...ze.data()})))}).catch(je=>{console.warn("Silent ignore custom pages in article view:",je)})},[]);const dt=[o.featuredImageUrl,o.featuredImageUrl1,o.featuredImageUrl2].filter(Boolean),[sn,pn]=j.useState("newest"),[Fn,Ft]=j.useState(null),[Dt,Ht]=j.useState([]),[Ze,Wt]=j.useState(0);j.useEffect(()=>{const be=Qt(it(pe,"adverts"),Pi(10));vn(be).then(je=>{const ze=je.docs.map(tt=>({id:tt.id,...tt.data()}));Ht(ze.filter(tt=>tt.status==="active"))}).catch(je=>{console.warn("Failed to load adverts for article inline placements:",je)})},[]),j.useEffect(()=>{if(Dt.length<=1)return;const be=setInterval(()=>{Wt(je=>(je+1)%Dt.length)},5e3);return()=>clearInterval(be)},[Dt.length]),j.useEffect(()=>{if(o){document.title=`${o.title} | Campus Eye Media`;const be=o.summary||(o.content?o.content.substring(0,160)+"...":""),je=(ue,Se,Xe)=>{let Vt=document.querySelector(`meta[${ue}="${Se}"]`);Vt||(Vt=document.createElement("meta"),Vt.setAttribute(ue,Se),document.head.appendChild(Vt)),Vt.setAttribute("content",Xe)},ze=(ue,Se)=>{let Xe=document.querySelector(`link[rel="${ue}"]`);Xe||(Xe=document.createElement("link"),Xe.setAttribute("rel",ue),document.head.appendChild(Xe)),Xe.setAttribute("href",Se)},tt=o.title,fn=be,Bt=[o.featuredImageUrl,o.featuredImageUrl1,o.featuredImageUrl2,o.featuredImage,o.imageUrl,o.image,o.photo,o.coverImage,o.cover,o.thumbnail,o.mediaUrl,o.bannerUrl];let jn="";const jt=[o.video,o.videoUrl,o.Links].filter(Boolean);for(const ue of jt){const Se=ue.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|shorts\/)([^#\&\?]*).*/);if(Se&&Se[2].length===11){jn=`https://img.youtube.com/vi/${Se[2]}/hqdefault.jpg`;break}}let on="";if(o.content){const ue=o.content.match(/]+src=["'](https?:\/\/[^"'\s]+)["']/i)||o.content.match(/!\[.*?\]\((https?:\/\/[^\s\)]+)\)/i);ue&&ue[1]&&(on=ue[1])}const Ir=Bt.find(ue=>ue&&typeof ue=="string"&&ue.trim().length>5)||jn||on,pr=Ir?Ir.startsWith("data:")?`${window.location.origin}/api/article-image/${o.id}`:Ir:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg";je("property","og:title",tt),je("property","og:image",pr),je("property","og:image:url",pr),je("property","og:image:secure_url",pr),je("property","og:description",fn),je("property","og:url",window.location.href),je("name","description",fn),je("name","twitter:title",tt),je("name","twitter:description",fn),je("name","twitter:image",pr),je("name","twitter:image:src",pr),pr&&ze("image_src",pr)}},[o]),j.useEffect(()=>{var tt,fn,Bt;if(!o)return;const be=document.createElement("script");be.setAttribute("type","application/ld+json"),be.id=`seo-schema-${o.id}`;const je={"@context":"https://schema.org","@type":"NewsArticle",headline:o.title,image:[o.featuredImageUrl||"https://campuseye.media/placeholder.png"],datePublished:(tt=o.publishDate)!=null&&tt.toDate?new Date(o.publishDate.toDate()).toISOString():new Date().toISOString(),dateModified:(fn=o.publishDate)!=null&&fn.toDate?new Date(o.publishDate.toDate()).toISOString():new Date().toISOString(),author:[{"@type":"Person",name:o.authorName||"Campus Eye Reporter",jobTitle:"Campus Eyewitness Journalist"}],publisher:{"@type":"Organization",name:"Campus Eye Media",logo:{"@type":"ImageObject",url:"https://campuseye.media/logo.png"}},description:o.summary||((Bt=o.content)==null?void 0:Bt.substring(0,160))||""};be.textContent=JSON.stringify(je),document.head.appendChild(be);const ze=document.title;return document.title=`${o.title} | Campus Eye News`,()=>{const jn=document.getElementById(`seo-schema-${o.id}`);jn&&jn.remove(),document.title=ze}},[o]),j.useEffect(()=>{const be=document.getElementById("full-article-modal-container");be&&be.scrollTo({top:0})},[e.id]),j.useEffect(()=>{if(e){const be=e.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),je=`${window.location.origin}/articles=${be}/${e.id}`;fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:je,title:e.title,image:e.featuredImageUrl||""})}).catch(ze=>console.warn("Failed to notify sitemap update:",ze))}},[e.id]),j.useEffect(()=>{const be=ot(pe,"articles",e.id);if(Hn(be,{viewCount:Ur(1)}).catch(je=>{console.warn("View counter update skipped:",je)}),cs(be).then(je=>{je.exists()&&c({id:je.id,...je.data()})}).catch(je=>{Gs(je,Ps.GET,`articles/${e.id}`)}),Ne.currentUser){const je=ot(pe,"articles",e.id,"likes",Ne.currentUser.uid);cs(je).then(jt=>{Z(jt.exists())}).catch(jt=>console.warn("Could not check if user liked article offline:",jt));const ze=`reacted_${e.id}_${Ne.currentUser.uid}`,tt=localStorage.getItem(ze);if(tt){V(parseInt(tt));const on=["🔥","🤯","😢","👏","❤️","😂","👍"][parseInt(tt)-1];on&&Q(on)}const fn=`reacted_emoji_${e.id}_${Ne.currentUser.uid}`,Bt=localStorage.getItem(fn);Bt&&Q(Bt);const jn=`saved_${e.id}_${Ne.currentUser.uid}`;z(localStorage.getItem(jn)==="true")}},[e.id,Ne.currentUser]);const It=()=>{const be={};o.reactions&&Object.entries(o.reactions).forEach(([ze,tt])=>{typeof tt=="number"&&tt>0&&(be[ze]=(be[ze]||0)+tt)});const je=["🔥","🤯","😢","👏","❤️","😂","👍"];for(let ze=1;ze<=7;ze++){const tt=o[`reaction${ze}`];if(tt&&tt.count>0){const fn=tt.emoji||je[ze-1];fn&&(be[fn]=(be[fn]||0)+tt.count)}}return be};j.useEffect(()=>{const be=Qt(it(pe,"articles",e.id,"comments"),pi("createdAt","desc")),je=di(be,ze=>{const tt=ze.docs.map(fn=>({id:fn.id,...fn.data()}));f(tt)},ze=>{Gs(ze,Ps.LIST,`articles/${e.id}/comments`)});return()=>je()},[e.id]);const ln=()=>{const be=!Y;G(be),be&&setTimeout(()=>{const je=document.getElementById("full-article-comments-section");je&&je.scrollIntoView({behavior:"smooth",block:"nearest"})},30)},Kn=async be=>{if(!Ne.currentUser){sr.error("Please login to register solidarity on comments!"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{Kn(be)});return}const je=ot(pe,"articles",e.id,"comments",be),ze=`liked_comment_${be}_${Ne.currentUser.uid}`,tt=localStorage.getItem(ze)==="true";try{tt?(localStorage.removeItem(ze),await Hn(je,{likeCount:Ur(-1)})):(localStorage.setItem(ze,"true"),await Hn(je,{likeCount:Ur(1)}),sr.success("Solidarity added to comment!"))}catch(fn){console.warn("Could not save comment like in db, performing local fallback:",fn)}},un=async()=>{if(!Ne.currentUser){sr.error("Please login to support this post!"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{un()});return}const be=ot(pe,"articles",e.id,"likes",Ne.currentUser.uid),je=ot(pe,"articles",e.id);try{q?(Z(!1),await ni(be),await Hn(je,{likeCount:Ur(-1)})):(Z(!0),await Hr(be,{userId:Ne.currentUser.uid,createdAt:Bn()}),await Hn(je,{likeCount:Ur(1)}),sr.success("Solidarity registered!"))}catch(ze){console.error("Error on like operation:",ze)}},xr=async()=>{if(!Ne.currentUser){sr.error("Please login to bookmark dispatches"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{xr()});return}const be=ot(pe,"articles",e.id),je=`saved_${e.id}_${Ne.currentUser.uid}`,ze=K;try{ze?(z(!1),localStorage.removeItem(je),await Hn(be,{saveCount:Ur(-1)}),sr.success("Bookmark removed")):(z(!0),localStorage.setItem(je,"true"),await Hn(be,{saveCount:Ur(1)}),sr.success("Secured in Bookmarks!"))}catch(tt){console.error("Save error:",tt)}},Ve=async be=>{if(!Ne.currentUser){sr.error("Please login to register a reaction"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{Ve(be)});return}const je=ot(pe,"articles",e.id),ze=`reacted_emoji_${e.id}_${Ne.currentUser.uid}`,tt=`reacted_${e.id}_${Ne.currentUser.uid}`,fn=localStorage.getItem(ze);try{const Bt={};if(fn===be)Bt[`reactions.${be}`]=Ur(-1),localStorage.removeItem(ze),Q(null),localStorage.removeItem(tt),V(null);else{if(fn)Bt[`reactions.${fn}`]=Ur(-1);else{const jn=localStorage.getItem(tt);if(jn){const jt=parseInt(jn),Ir=["🔥","🤯","😢","👏","❤️","😂","👍"][jt-1];Ir&&(Bt[`reactions.${Ir}`]=Ur(-1)),localStorage.removeItem(tt),V(null)}}Bt[`reactions.${be}`]=Ur(1),localStorage.setItem(ze,be),Q(be)}await Hn(je,Bt),sr.success("Reaction logged dynamically!")}catch(Bt){console.warn("Reaction updater error:",Bt)}},Ot=async be=>{var je,ze;if(be.preventDefault(),!(!m.trim()&&!w)){if(!Ne.currentUser){sr.error("Please login to submit commentary"),typeof window.triggerAuthWithCallback=="function"&&window.triggerAuthWithCallback(()=>{Ot({preventDefault:()=>{}})});return}ve(!0);try{const tt=Fn?Fn.parentId||Fn.id:null,fn={content:m,stickerUrl:w||null,userId:Ne.currentUser.uid,authorName:Ne.currentUser.displayName||"Campus Member",photoURL:Ne.currentUser.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Ne.currentUser.displayName||"Member")}`,createdAt:new Date,parentId:tt,replyToAuthor:Fn?Fn.authorName:null},Bt=await ur(it(pe,"articles",e.id,"comments"),{content:m,stickerUrl:w||null,userId:Ne.currentUser.uid,authorName:Ne.currentUser.displayName||"Campus Member",photoURL:Ne.currentUser.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Ne.currentUser.displayName||"Member")}`,createdAt:Bn(),parentId:tt,replyToAuthor:Fn?Fn.authorName:null});f(on=>[{id:Bt.id,...fn},...on]),c(on=>({...on,commentCount:(on.commentCount||0)+1}));const jn=ot(pe,"articles",e.id);await Hn(jn,{commentCount:Ur(1)});const jt=m;y(""),A(null),I(!1),Ft(null),sr.success("Comment added!"),/@(mega\s*(ai)?|me)\b/i.test(jt)&&h2(jt,((je=Ne.currentUser)==null?void 0:je.displayName)||"Campus Member",((ze=Ne.currentUser)==null?void 0:ze.uid)||"guest",{type:"article_comment",articleId:e.id,articleTitle:e.title,articleContent:e.content}).then(async on=>{if(on){const Ir=await ur(it(pe,"articles",e.id,"comments"),{content:on,userId:"mega-ai-bot",authorName:"Mega AI 🤖",photoURL:Vo,createdAt:Bn(),parentId:null});f(pr=>[{id:Ir.id,content:on,userId:"mega-ai-bot",authorName:"Mega AI 🤖",photoURL:Vo,createdAt:new Date,parentId:null},...pr]),c(pr=>({...pr,commentCount:(pr.commentCount||0)+1})),await Hn(ot(pe,"articles",e.id),{commentCount:Ur(1)}),sr.success("Mega AI auto-replied to your commentary!",{icon:"✨"})}}).catch(on=>console.error("Mega AI auto reply error:",on))}catch(tt){console.error("Comment submit error:",tt)}finally{ve(!1)}}},nn=async()=>{const be=e.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),je=`${window.location.origin}/articles=${be}/${e.id}`,ze=e.title,tt=e.summary||(e.content?e.content.substring(0,140)+"...":""),fn=`${e.title} ${tt}`,Bt=[e.featuredImageUrl,e.featuredImageUrl1,e.featuredImageUrl2,e.imageUrl].find(on=>on&&typeof on=="string"&&on.length>5)||"",jn=Bt.startsWith("data:")?`${window.location.origin}/api/article-image/${e.id}`:Bt;try{fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:je,title:ze,image:jn})}).catch(()=>{})}catch{}let jt=!1;if(navigator.share)try{const on={title:ze,text:`${fn} Read dispatch:`,url:je};await navigator.share(on),jt=!0;const Ir=ot(pe,"articles",e.id);await Hn(Ir,{shareCount:Ur(1)}).catch(console.error);return}catch(on){console.warn("Native share canceled or unsuccessful:",on)}if(!jt){try{const on=`${ze} ${tt} Read More: ${je}`;await Pd(on);const Ir=ot(pe,"articles",e.id);await Hn(Ir,{shareCount:Ur(1)}).catch(console.error)}catch{}D(!0)}},mn=async()=>{var be,je;if(!n&&((je=(be=Ne.currentUser)==null?void 0:be.email)==null?void 0:je.toLowerCase())!=="atwiinevictor2@gmail.com"){sr.error("Access Denied: Only administrators can delete articles.");return}if(window.confirm("Are you sure you want to permanently delete this article/post? This action is irreversible."))try{sr.loading("Deleting dispatch...",{id:"delete-dispatch"});const ze=ot(pe,"articles",o.id);await ni(ze),sr.success("Dispatch has been permanently deleted from Campus Eye.",{id:"delete-dispatch"}),t()}catch(ze){console.error(ze),sr.error(`Failed to delete dispatch: ${ze.message||ze}`,{id:"delete-dispatch"})}},dr=()=>e.featuredImageUrl?s.jsx("div",{className:"rounded-xl overflow-hidden border border-gray-150 w-full bg-gray-50 flex items-center justify-center relative shadow-sm cursor-zoom-in",onClick:()=>{ie(0),ae(!0)},children:s.jsx(Vi,{src:e.featuredImageUrl,alt:e.title,priority:!0,className:"w-full h-auto max-h-[50rem] object-cover sm:object-contain hover:scale-[1.01] transition-transform duration-500 rounded-xl"})}):null,hr=r.findIndex(be=>be.id===e.id);return s.jsxs(Kt.div,{initial:{opacity:0,scale:.88},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.88},transition:{type:"spring",damping:22,stiffness:220},id:"full-article-modal-container",className:"fixed inset-0 z-[2000] bg-white overflow-y-auto w-full h-full text-left pb-24",children:[s.jsxs("div",{className:"sticky top-0 z-50 bg-white/95 backdrop-blur-md border-b border-gray-100 h-15 flex items-center px-4 justify-between shadow-sm shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:t,className:"p-2 bg-red-50 text-red-650 border border-red-150 hover:bg-red-600 hover:text-white hover:rotate-90 rounded-full transition-all duration-300 shadow-3xs flex items-center justify-center shrink-0 cursor-pointer",title:"Close details",children:s.jsx(er,{size:15,strokeWidth:3})}),s.jsx("div",{className:"h-6 w-px bg-gray-250 hidden xs:block"}),s.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 select-none",children:[s.jsx("button",{onClick:()=>pt(!0),className:"p-1 hover:text-red-650 text-gray-750 transition-all cursor-pointer flex items-center justify-center shrink-0",title:"Open Site Menu",children:s.jsx(jN,{size:14,strokeWidth:2.5})}),s.jsxs("div",{className:"flex items-center gap-1 cursor-pointer",onClick:()=>pt(!0),children:[s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"Campus Eye Logo",className:"h-5.5 w-5.5 sm:h-6 sm:w-6 rounded-full border border-gray-950 bg-white object-cover aspect-square shrink-0",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"hidden md:flex flex-col justify-center text-left -space-y-1",children:[s.jsxs("span",{className:"text-[10px] sm:text-[11px] font-serif font-black tracking-normal italic leading-none",children:[s.jsx("span",{className:"text-red-650",children:"Campus"})," ",s.jsx("span",{className:"text-blue-600",children:"Eye"})]}),s.jsx("span",{className:"text-[5px] sm:text-[5.5px] font-sans font-extrabold uppercase tracking-[0.24em] text-black text-right pr-0.2 block select-none leading-none",children:"Media"})]})]})]})]}),r.length>0&&hr!==-1&&(()=>{const be=o.publishDate;let je=1;if(be){const ze=be.toDate?be.toDate():be.seconds?new Date(be.seconds*1e3):new Date(be),tt=new Date;tt.setHours(0,0,0,0);const fn=new Date(ze);fn.setHours(0,0,0,0);const Bt=tt.getTime()-fn.getTime();je=Math.floor(Bt/(1e3*60*60*24))+1}return s.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 bg-gray-50 border border-gray-150 px-2 sm:px-3 py-1 rounded-full text-xs font-bold text-gray-700 select-none max-w-[50vw] sm:max-w-none justify-center",children:[s.jsx("button",{onClick:()=>{hr>0&&(i==null||i(r[hr-1]))},disabled:hr===0,className:"p-0.5 sm:p-1 text-gray-400 hover:text-red-650 disabled:opacity-30 disabled:hover:text-gray-400 transition-colors cursor-pointer select-none flex items-center justify-center shrink-0",title:"Previous story",children:s.jsx(Vp,{size:14,strokeWidth:2.5})}),s.jsxs("span",{className:"font-mono text-[8.5px] sm:text-[9px] uppercase tracking-wider font-black text-gray-655 block text-center truncate",children:[s.jsxs("span",{className:"hidden md:inline",children:["DAY ",je," — "]}),"DISPATCH ",hr+1]}),s.jsx("button",{onClick:()=>{hr{const be=o.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),je=`${window.location.origin}/articles=${be}/${o.id}`,ze=o.title;return s.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-3 border-b border-gray-100",children:[s.jsxs("a",{href:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(je)}`,target:"_blank",rel:"noopener noreferrer",className:"px-3.5 py-2 bg-[#1877F2] hover:bg-[#155fc5] text-white font-extrabold text-[10px] uppercase tracking-widest rounded-lg flex items-center gap-1.5 shadow-sm transition-all cursor-pointer hover:scale-[1.02]",children:[s.jsx("svg",{className:"w-3.5 h-3.5 fill-current",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M22 12c0-5.52-4.48-10-10-10S2 6.48 2 12c0 4.84 3.44 8.87 8 9.8V15H8v-3h2V9.5C10 7.57 11.57 6 13.5 6H16v3h-2c-.55 0-1 .45-1 1v2h3v3h-3v6.95c4.56-.93 8-4.96 8-9.75z"})}),s.jsx("span",{children:"Share"})]}),s.jsxs("a",{href:`https://twitter.com/intent/tweet?url=${encodeURIComponent(je)}&text=${encodeURIComponent(ze)}`,target:"_blank",rel:"noopener noreferrer",className:"px-3.5 py-2 bg-black hover:bg-zinc-900 text-white font-extrabold text-[10px] uppercase tracking-widest rounded-lg flex items-center gap-1.5 shadow-sm transition-all cursor-pointer hover:scale-[1.02]",children:[s.jsx("svg",{className:"w-3.5 h-3.5 fill-current",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),s.jsx("span",{children:"Tweet"})]}),s.jsxs("a",{href:`https://api.whatsapp.com/send?text=${encodeURIComponent(ze+" "+je)}`,target:"_blank",rel:"noopener noreferrer",className:"px-3.5 py-2 bg-[#25D366] hover:bg-[#20ba59] text-white font-extrabold text-[10px] uppercase tracking-widest rounded-lg flex items-center gap-1.5 shadow-sm transition-all cursor-pointer hover:scale-[1.02]",children:[s.jsx("svg",{className:"w-3.5 h-3.5 fill-current",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M.057 24l1.687-6.163c-1.041-1.804-1.588-3.849-1.587-5.946C.06 5.348 5.397.01 12.008.01c3.202.001 6.212 1.246 8.477 3.514 2.266 2.268 3.507 5.28 3.505 8.484-.004 6.657-5.34 11.997-11.953 11.997-2.005-.001-3.973-.502-5.724-1.457L0 24zm6.59-4.846c1.6.95 3.1 1.45 4.8 1.45 5.4 0 9.8-4.4 9.8-9.8s-4.4-9.8-9.8-9.8c-5.4 0-9.8 4.4-9.8 9.8 0 1.9.5 3.7 1.5 5.3l-.9 3.5 3.4-.9z"})}),s.jsx("span",{children:"WhatsApp"})]}),s.jsx("button",{onClick:nn,className:"p-2 bg-gray-55 hover:bg-gray-100 border border-gray-150 rounded-lg text-gray-500 hover:text-gray-900 transition-colors cursor-pointer hover:scale-[1.02] shadow-sm ml-auto",title:"Copy text & browser link to clipboard",children:s.jsx(dC,{size:13,className:"stroke-[2.5]"})})]})})(),s.jsx("article",{className:Ge("prose prose-red text-gray-900 leading-relaxed font-serif max-w-none text-base border-b border-gray-100 pb-8 selection:bg-red-50 transition-opacity duration-150",Y&&"opacity-90"),children:(()=>{const be=o.content||"";let je=be;try{const ue=[];je=je.replace(/@([a-zA-Z0-9_\-]+)/g,(Se,Xe)=>(ue.push(`[@${Xe}](mention:${Xe})`),`___MD_PLACEHOLDER_${ue.length-1}___`)),je=je.replace(/\[([^\]]*)\]\((https?:\/\/[^\s\)]+)\)/gi,Se=>(ue.push(Se),`___MD_PLACEHOLDER_${ue.length-1}___`)),je=je.replace(/"([^"]+)"\s*\((https?:\/\/[^\s\)]+)\)/gi,(Se,Xe,Vt)=>(ue.push(`[${Xe.trim()}](${Vt})`),`___MD_PLACEHOLDER_${ue.length-1}___`)),je=je.replace(/\((https?:\/\/[^\s\)]+)\)/gi,(Se,Xe)=>(ue.push(`([${Xe}](${Xe}))`),`___MD_PLACEHOLDER_${ue.length-1}___`)),je=je.replace(/(https?:\/\/[^\s\)\>\]]+)/gi,Se=>(ue.push(`[${Se}](${Se})`),`___MD_PLACEHOLDER_${ue.length-1}___`));for(let Se=ue.length-1;Se>=0;Se--)je=je.replace(`___MD_PLACEHOLDER_${Se}___`,ue[Se])}catch{je=be}const ze=je.split(/\n\s*\n/).filter(ue=>ue.trim()!=="");if(ze.length<=1)return s.jsx(O1,{components:{a:({node:ue,...Se})=>Se.href&&Se.href.startsWith("mention:")?s.jsx("span",{className:"text-blue-600 font-extrabold select-text hover:underline",title:"Mentioned peer",children:Se.children}):s.jsx("a",{...Se,className:"text-blue-650 hover:text-blue-800 font-bold underline transition-all font-sans break-all hover:scale-[1.01]",target:"_blank",rel:"noopener noreferrer"})},children:je});const tt=Math.ceil(ze.length/2),fn=ze.slice(0,tt).join(` `),Bt=ze.slice(tt).join(` `),jn=Dt.length>0?Dt[Ze%Dt.length]:null,jt=o.video||o.videoUrl,Ir=jt?(ue=>{if(!ue)return null;const Se=/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/,Xe=ue.match(Se);return Xe&&Xe[2].length===11?Xe[2]:null})(jt):null,pr=o.featuredImageUrl1||o.featuredImageUrl2;return s.jsxs("div",{className:"space-y-6",children:[s.jsx(O1,{components:{a:({node:ue,...Se})=>Se.href&&Se.href.startsWith("mention:")?s.jsx("span",{className:"text-blue-600 font-extrabold select-text hover:underline",title:"Mentioned peer",children:Se.children}):s.jsx("a",{...Se,className:"text-blue-600 hover:text-blue-800 font-bold underline transition-all font-sans break-all",target:"_blank",rel:"noopener noreferrer"})},children:fn}),s.jsx("div",{className:"my-8 py-6 border-y border-gray-100 flex flex-col gap-6 bg-[#fcfcfc] -mx-4 px-4 sm:mx-0 sm:px-6 sm:rounded-2xl",children:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("span",{className:"text-[9px] font-black uppercase text-gray-400 tracking-[0.25em] text-center mb-1",children:"Campus Sponsor Announcement"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-6 items-center",children:[s.jsx("div",{className:Ge("col-span-1",pr?"md:col-span-6":"md:col-span-12"),children:jn?s.jsx("div",{className:"shadow-md rounded-xl overflow-hidden border border-gray-150",children:s.jsx(Sw,{advert:jn})}):s.jsxs("div",{className:"bg-gradient-to-br from-indigo-50/40 to-rose-50/40 border border-gray-150 rounded-xl p-6 text-center shadow-xs",children:[s.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-[#9B2C2C] mb-1",children:"Advertise on Campus Eye"}),s.jsx("p",{className:"text-xs text-gray-600 font-medium leading-relaxed mb-4",children:"Reach thousands of student readers daily with full-bleed interstitial slots."}),s.jsx("a",{href:"mailto:atwiinevictor2@gmail.com",className:"inline-flex items-center gap-1.5 bg-black hover:bg-gray-800 text-white font-black uppercase tracking-widest text-[9px] px-4 py-2 rounded shadow-sm transition-colors",children:"Book Sponsor Space"})]})}),(o.featuredImageUrl1||o.featuredImageUrl2)&&s.jsxs("div",{className:"col-span-1 md:col-span-6 flex flex-col gap-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.featuredImageUrl1&&s.jsx("div",{onClick:()=>{const ue=dt.indexOf(o.featuredImageUrl1);ie(ue>=0?ue:1),ae(!0)},className:"rounded-xl overflow-hidden border border-gray-150 aspect-square bg-gray-100 relative shadow-sm cursor-zoom-in group",children:s.jsx(Vi,{src:o.featuredImageUrl1,className:"w-full h-full object-cover group-hover:scale-102 transition-transform duration-300",alt:"Supporting Evidence 1"})}),o.featuredImageUrl2&&s.jsx("div",{onClick:()=>{const ue=dt.indexOf(o.featuredImageUrl2);ie(ue>=0?ue:2),ae(!0)},className:"rounded-xl overflow-hidden border border-gray-150 aspect-square bg-gray-100 relative shadow-sm cursor-zoom-in group",children:s.jsx(Vi,{src:o.featuredImageUrl2,className:"w-full h-full object-cover group-hover:scale-102 transition-transform duration-300",alt:"Supporting Evidence 2"})})]}),s.jsx("span",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider italic text-right block",children:"Distributed documentation assets"})]})]}),jt&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-200/80 flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-[9.5px] font-black uppercase text-gray-700 tracking-wider",children:[s.jsx(Aa,{size:13,className:"text-red-600"}),s.jsx("span",{children:"Article Video Frame"})]}),s.jsx("div",{className:"relative aspect-video w-full rounded-2xl overflow-hidden border border-gray-200 shadow-md bg-black",children:Ir?s.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${Ir}?rel=0`,className:"w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:o.title||"Story Video"}):jt.includes("Se.href&&Se.href.startsWith("mention:")?s.jsx("span",{className:"text-blue-600 font-extrabold select-text hover:underline",title:"Mentioned peer",children:Se.children}):s.jsx("a",{...Se,className:"text-blue-650 hover:text-blue-800 font-bold underline transition-all font-sans break-all",target:"_blank",rel:"noopener noreferrer"})},children:Bt})]})})()}),s.jsx("div",{className:"flex items-center justify-between py-3 border-b border-gray-100 text-gray-500 text-xs font-bold px-1 select-none",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("button",{onClick:un,className:Ge("flex items-center gap-1.5 hover:text-red-650 transition-colors cursor-pointer",q&&"text-red-600"),children:[s.jsx(lq,{size:16,className:q?"fill-red-500 text-red-500 animate-heartbeat":""}),s.jsxs("span",{children:[Tc(o.likeCount||0)," Solidarity"]})]}),s.jsxs("button",{onClick:ln,className:Ge("flex items-center gap-1.5 hover:text-indigo-600 transition-colors cursor-pointer font-black text-indigo-600",Y&&"text-indigo-600"),children:[s.jsx(uC,{size:16,className:Y?"fill-indigo-500 text-indigo-600":""}),s.jsxs("span",{children:[Tc(h.length)," Comments ",Y?"(Open)":""]})]}),s.jsxs("button",{onClick:xr,className:Ge("flex items-center gap-1.5 hover:text-yellow-600 transition-colors cursor-pointer",K&&"text-yellow-600"),children:[s.jsx(cq,{size:16,className:K?"fill-yellow-500 text-yellow-500":""}),s.jsx("span",{children:"Secure Bookmark"})]}),s.jsxs("div",{className:"relative inline-block",children:[s.jsxs("button",{onClick:()=>te(!he),className:"flex items-center gap-1.5 hover:text-rose-600 transition-colors cursor-pointer text-gray-500 select-none font-bold",children:[s.jsx("span",{className:"text-sm shrink-0 leading-none",children:$||"😊"}),s.jsx("span",{children:$?"Reacted":"React"})]}),s.jsx(ar,{children:he&&s.jsxs(Kt.div,{initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},className:"absolute bottom-full mb-2 left-1/2 -translate-x-1/2 bg-white border border-gray-150 p-2.5 shadow-2xl z-[150] rounded-2xl w-64 text-left space-y-2",onClick:be=>be.stopPropagation(),children:[s.jsx("div",{className:"text-[8px] font-black uppercase text-gray-400 tracking-wider",children:"Popular Reactions"}),s.jsx("div",{className:"grid grid-cols-6 gap-1.5",children:TL.map(be=>s.jsx("button",{onClick:()=>{Ve(be),te(!1)},className:Ge("w-8 h-8 rounded-full flex items-center justify-center hover:scale-125 transition-transform text-base hover:bg-gray-50 cursor-pointer",$===be&&"bg-rose-50 border border-rose-200"),title:be,children:be},be))}),s.jsx("div",{className:"border-t border-gray-100 pt-2 flex items-center gap-1",children:s.jsx("input",{type:"text",maxLength:6,placeholder:"Or custom...",className:"w-full px-2 py-1 text-[10px] border border-gray-250 rounded-lg text-center focus:ring-0 focus:border-gray-400 bg-white",onChange:be=>{const je=be.target.value.trim();je&&(Ve(je),te(!1),be.target.value="")}})})]})})]})]})}),s.jsxs("div",{id:"full-article-comments-section",className:Ge("space-y-4 my-6 p-4 sm:p-7 md:p-8 bg-[#0a0d12] text-white rounded-2xl sm:rounded-3xl border border-indigo-500/40 shadow-2xl relative z-30 transition-opacity duration-150 w-full ring-1 ring-indigo-500/20 max-w-full overflow-hidden",!Y&&"hidden"),children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 border-b border-gray-800/80 pb-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-6 bg-indigo-500 rounded-full"}),s.jsxs("h4",{className:"text-sm sm:text-base font-black text-gray-100 uppercase tracking-wider block text-left",children:["All Comments (",h.length,")"]})]}),s.jsx("div",{className:"flex items-center gap-1 bg-[#15181c] p-1 rounded-full border border-gray-800 self-start sm:self-auto",children:["newest","oldest","liked"].map(be=>s.jsx("button",{type:"button",onClick:()=>pn(be),className:Ge("px-2.5 py-1 text-[9px] font-black uppercase tracking-wider rounded-full transition-all cursor-pointer select-none",sn===be?"bg-indigo-600 text-white shadow-sm":"text-gray-400 hover:text-gray-200"),children:be==="liked"?"Most Liked":be},be))})]}),Fn&&s.jsxs("div",{className:"flex items-center justify-between bg-[#15181c] border border-gray-800 rounded-xl px-4 py-2.5 mb-1.5 text-xs text-gray-300 animate-slide-down",children:[s.jsxs("div",{className:"flex items-center gap-2 truncate text-left",children:[s.jsx("span",{className:"text-indigo-400 font-extrabold uppercase text-[9px] tracking-wider shrink-0 bg-indigo-950/40 px-1.5 py-0.5 rounded border border-indigo-800/40",children:"Replying to"}),s.jsxs("span",{className:"font-extrabold text-blue-400 shrink-0",children:["@",Fn.authorName]}),s.jsxs("span",{className:"text-gray-500 truncate italic",children:['"',Fn.content,'"']})]}),s.jsx("button",{type:"button",onClick:()=>Ft(null),className:"text-gray-400 hover:text-white transition-colors p-1 cursor-pointer",title:"Cancel reply",children:s.jsx(er,{size:14})})]}),w&&s.jsxs("div",{className:"p-2 bg-gray-900 border border-gray-800 my-2 flex items-center justify-between rounded-xl",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("img",{src:w,alt:"Sticker attachment",className:"h-14 max-w-[100px] object-contain rounded-lg border border-gray-700 bg-black p-1 shadow-sm"}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"text-[10px] font-bold text-gray-200 uppercase tracking-wider",children:"Sticker Attached"}),s.jsx("span",{className:"text-[9px] text-gray-400",children:"Ready to post"})]})]}),s.jsx("button",{type:"button",onClick:()=>A(null),className:"p-1.5 text-red-400 hover:bg-red-950/40 rounded-full transition-colors",title:"Remove sticker",children:s.jsx(As,{size:16})})]}),s.jsxs("form",{id:"comment-form",onSubmit:Ot,className:"flex flex-col gap-2 bg-[#15181c] border border-gray-800 rounded-2xl p-2.5 focus-within:border-indigo-500/50 transition-all",children:[s.jsx(eY,{value:m,onSelectMention:be=>y(be)}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",placeholder:Fn?`Replying to @${Fn.authorName}...`:"Let's talk about it or paste keyboard stickers...",value:m,onChange:be=>y(be.target.value),onPaste:F,className:"flex-1 bg-transparent text-white text-xs sm:text-sm outline-none focus:outline-none border-none py-1.5 px-2 placeholder-gray-500"}),s.jsx("button",{type:"submit",disabled:le||!m.trim()&&!w,className:"bg-indigo-600 hover:bg-indigo-700 disabled:opacity-40 text-white font-extrabold uppercase px-4 h-8 rounded-full text-[10px] tracking-wider transition-colors shrink-0 cursor-pointer",children:"Reply"})]}),s.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-gray-800/60 px-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{htmlFor:"fullpage-sticker-upload",className:"flex items-center gap-1.5 px-2.5 py-1 bg-gray-900 border border-gray-700 rounded-full text-[10px] font-bold text-gray-300 hover:border-indigo-500 hover:text-white transition-all cursor-pointer",title:"Upload device sticker / photo",children:[s.jsx(qre,{size:12,className:"text-indigo-400"}),s.jsx("span",{children:"Device Sticker"}),s.jsx("input",{id:"fullpage-sticker-upload",type:"file",accept:"image/*,video/*",onChange:L,className:"hidden"})]}),s.jsxs("button",{type:"button",onClick:()=>I(!k),className:"flex items-center gap-1.5 px-2.5 py-1 bg-gray-900 border border-gray-700 rounded-full text-[10px] font-bold text-gray-300 hover:border-indigo-500 hover:text-white transition-all cursor-pointer",children:[s.jsx(uF,{size:12,className:"text-amber-400"}),s.jsx("span",{children:"Stickers"})]})]}),s.jsx("span",{className:"text-[8px] text-gray-500 italic",children:"Keyboard stickers supported"})]}),k&&s.jsx("div",{className:"p-2 bg-gray-900 border border-gray-800 shadow-xl rounded-xl mt-1 flex flex-wrap gap-1.5 animate-in fade-in duration-150 z-20",children:["👍","🔥","❤️","🎯","💯","👏","🚀","⚡","😍","🙌","🤩","🎉","💡","📌","🎓","📣"].map(be=>s.jsx("button",{type:"button",onClick:()=>{y(je=>`${je} ${be}`.trim()),I(!1)},className:"w-8 h-8 text-base flex items-center justify-center hover:bg-gray-800 rounded-lg transition-transform hover:scale-125 cursor-pointer",children:be},be))})]}),s.jsx("div",{className:"space-y-4 pt-2",children:h.length>0?(()=>{const be=[...h].sort((Bt,jn)=>{var Ir,pr,ue,Se;const jt=(Ir=Bt.createdAt)!=null&&Ir.toDate?Bt.createdAt.toDate().getTime():((pr=Bt.createdAt)==null?void 0:pr.seconds)*1e3||0,on=(ue=jn.createdAt)!=null&&ue.toDate?jn.createdAt.toDate().getTime():((Se=jn.createdAt)==null?void 0:Se.seconds)*1e3||0;if(sn==="oldest")return jt-on;if(sn==="liked"){const Xe=Bt.likeCount||0,Vt=jn.likeCount||0;return Vt!==Xe?Vt-Xe:on-jt}else return on-jt}),je=be.filter(Bt=>!Bt.parentId),ze=be.filter(Bt=>Bt.parentId),tt=Bt=>({A:"bg-red-500",B:"bg-pink-500",C:"bg-purple-500",D:"bg-indigo-500",E:"bg-blue-500",F:"bg-cyan-500",G:"bg-teal-500",H:"bg-emerald-500",I:"bg-green-500",J:"bg-yellow-500",K:"bg-amber-500",L:"bg-orange-500",M:"bg-rose-500",N:"bg-red-650",O:"bg-indigo-600",P:"bg-purple-600",Q:"bg-pink-600",R:"bg-blue-600",S:"bg-violet-600",T:"bg-rose-600",U:"bg-teal-600",V:"bg-emerald-600",W:"bg-indigo-700",X:"bg-purple-700",Y:"bg-sky-500",Z:"bg-fuchsia-600"})[Bt]||"bg-slate-600",fn=(Bt,jn=!1)=>{var pr;const jt=Ne.currentUser?localStorage.getItem(`liked_comment_${Bt.id}_${Ne.currentUser.uid}`)==="true":!1,on=Bt.createdAt?(()=>{const ue=Bt.createdAt.toDate?Bt.createdAt.toDate():new Date(Bt.createdAt.seconds*1e3),Se=Date.now()-ue.getTime(),Xe=Math.floor(Se/(1e3*60*60));if(Xe===0){const Vt=Math.floor(Se/6e4);return Vt<=1?"just now":`${Vt}m ago`}else return Xe<24?`${Xe} hours ago`:ue.toLocaleDateString(void 0,{month:"short",day:"numeric"})})():"Just now",Ir=Bt.authorName?Bt.authorName.charAt(0).toUpperCase():"?";return s.jsxs("div",{id:`comment-${Bt.id}`,className:Ge("flex gap-3 text-xs pt-1.5 transition-all",jn?"pb-1":"pb-3"),children:[Bt.photoURL?s.jsx("img",{src:Bt.photoURL,className:"w-8 h-8 rounded-full object-cover border border-gray-800 shrink-0",alt:"",referrerPolicy:"no-referrer"}):s.jsx("div",{className:Ge("w-8 h-8 rounded-full flex items-center justify-center text-white font-extrabold text-[10px] uppercase shrink-0 shadow-md",tt(Ir)),children:Ir}),s.jsxs("div",{className:"flex-1 space-y-1 text-left min-w-0 pr-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-extrabold text-[#f3f4f6] text-[12px] tracking-tight",children:Bt.authorName}),(Bt.isAIGenerated||Bt.isAiGenerated||Bt.userId==="mega-ai-bot"||((pr=Bt.authorName)==null?void 0:pr.toLowerCase().includes("mega ai")))&&s.jsx(xw,{})]}),Bt.replyToAuthor&&s.jsxs("span",{className:"text-[9px] text-[#9ca3af] font-bold uppercase mt-0.5",children:["Replying to ",s.jsxs("span",{className:"text-amber-500",children:["@",Bt.replyToAuthor]})]})]}),s.jsxs("button",{type:"button",onClick:()=>Kn(Bt.id),className:Ge("flex items-center gap-1.5 p-1 text-gray-400 hover:text-red-500 transition-all cursor-pointer",jt&&"text-red-500"),children:[s.jsx("span",{className:"text-[10px] text-gray-400",children:(Bt.likeCount||0)>0?Tc(Bt.likeCount):""}),s.jsx(ku,{size:12,className:Ge("transition-transform hover:scale-110",jt?"fill-red-500 text-red-500":"text-gray-400")})]})]}),s.jsx("p",{className:"text-[#e5e7eb] font-sans leading-relaxed text-[12px] whitespace-pre-line pr-2 break-words max-w-full overflow-hidden",children:f2(Bt.content)}),(Bt.stickerUrl||Bt.imageUrl)&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:Bt.stickerUrl||Bt.imageUrl,alt:"Comment sticker",className:"max-h-48 max-w-xs object-contain rounded-xl border border-gray-800 bg-black p-1 shadow-md hover:scale-105 transition-transform"})}),s.jsxs("div",{className:"flex items-center gap-3 pt-1 text-[9px] text-gray-500 font-bold select-none",children:[s.jsx("span",{children:on}),s.jsx("button",{type:"button",onClick:()=>{var Se,Xe;Ft(Bt);const ue=(Se=document.getElementById("comment-form"))==null?void 0:Se.querySelector("input");ue&&ue.focus(),(Xe=document.getElementById("comment-form"))==null||Xe.scrollIntoView({behavior:"smooth"})},className:"hover:text-amber-500 hover:scale-102 transition-all cursor-pointer bg-transparent border-0 text-[10px] font-black text-gray-400 uppercase tracking-widest block pl-0",children:"Reply"})]})]})]},Bt.id)};return je.map(Bt=>{const jn=ze.filter(jt=>jt.parentId===Bt.id);return s.jsxs("div",{className:"border-b border-gray-900 last:border-0 pb-4",children:[fn(Bt,!1),jn.length>0&&s.jsx("div",{className:"pl-8 border-l border-zinc-700/50 mt-1.5 space-y-2.5",children:jn.map(jt=>fn(jt,!0))})]},Bt.id)})})():s.jsxs("div",{className:"text-center py-10 bg-[#15181c] border border-dashed border-gray-800 rounded-2xl",children:[s.jsx(uC,{size:24,className:"text-gray-600 mx-auto mb-2 opacity-50"}),s.jsx("p",{className:"text-[10.5px] text-gray-400 font-bold uppercase tracking-wider",children:"No verified commentary published. Start the conversation!"})]})})]}),s.jsx("div",{className:Ge("my-8 pt-8 border-t border-gray-100 transition-opacity duration-150",Y&&"opacity-90"),children:s.jsxs("div",{className:"flex flex-col gap-2 select-none text-left",children:[s.jsx("span",{className:"text-[9px] font-black tracking-[0.25em] text-gray-400 uppercase",children:"Strategic Partners & Sponsors"}),s.jsx("div",{className:"flex flex-wrap items-center gap-4 py-3",children:Tt.length>0?s.jsx("div",{className:"flex flex-wrap items-center gap-4 sm:gap-6",children:Tt.map(be=>s.jsxs("a",{href:be.link||be.targetUrl||"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 bg-gray-50 hover:bg-white px-3.5 py-2 rounded-2xl border border-gray-200/80 shadow-2xs hover:shadow-md hover:border-red-300 transition-all group",children:[be.imageUrl&&s.jsx("img",{src:be.imageUrl,className:"h-9 sm:h-10 object-contain max-h-9 sm:max-h-10 rounded-lg",alt:be.name,referrerPolicy:"no-referrer"}),s.jsx("span",{className:"text-xs sm:text-sm font-black uppercase tracking-wide text-gray-800 group-hover:text-red-650 transition-colors",children:be.name})]},be.id))}):s.jsxs("div",{className:"p-3 bg-gray-50 border border-gray-150 rounded-xl flex items-center justify-between gap-4 w-full",children:[s.jsx("span",{className:"text-[9.5px] font-mono text-gray-500 uppercase tracking-wider font-bold",children:"Partner with Campus Eye Media"}),s.jsx("span",{className:"text-[9px] font-black text-red-650 uppercase tracking-widest bg-white px-2.5 py-1 rounded border border-gray-200 shadow-2xs",children:"Get Featured"})]})})]})}),s.jsxs("div",{className:Ge("my-8 p-5 bg-gray-50/50 border border-gray-150 rounded-2xl text-left transition-opacity duration-150",Y&&"opacity-90"),children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx("span",{className:"text-[10px] font-black text-red-650 bg-red-50 border border-red-100 px-2 py-0.5 rounded-md uppercase tracking-wide",children:"Event Booking Embed"}),s.jsx("span",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-widest",children:"Secure Reservation Desk"})]}),s.jsx("p",{className:"text-[10.5px] text-gray-500 mb-4 italic leading-relaxed",children:"Reading about this exclusive college event? You can secure your active box office entry pass directly below with our digital verification key protocol."}),s.jsx(ZC,{})]}),s.jsxs("div",{className:Ge("py-6 border-b border-gray-100 text-center space-y-3.5 transition-opacity duration-150",Y&&"opacity-90"),children:[s.jsx("div",{className:"flex flex-wrap items-center justify-center gap-4 mb-3",children:s.jsxs("div",{className:"relative inline-block",children:[s.jsxs("button",{onClick:()=>te(!he),className:"flex items-center gap-2 px-5 py-2.5 bg-black hover:bg-neutral-800 text-white font-extrabold text-[10px] uppercase tracking-widest transition-all rounded-full shadow-lg cursor-pointer",children:[s.jsx("span",{children:$||"😊"}),s.jsx("span",{children:$?"Change Reaction":"React"})]}),s.jsx(ar,{children:he&&s.jsxs(Kt.div,{initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},className:"absolute bottom-12 left-1/2 -translate-x-1/2 bg-white border border-gray-150 p-3 shadow-2xl z-[150] rounded-3xl w-72 text-left space-y-2.5",onClick:be=>be.stopPropagation(),children:[s.jsx("div",{className:"text-[9px] font-black uppercase text-gray-400 tracking-wider mb-1",children:"Popular Reactions"}),s.jsx("div",{className:"grid grid-cols-6 gap-2",children:TL.map(be=>s.jsx("button",{onClick:()=>{Ve(be),te(!1)},className:Ge("w-8 h-8 rounded-full flex items-center justify-center hover:scale-125 transition-transform text-lg hover:bg-gray-50",$===be&&"bg-indigo-50 border border-indigo-200"),title:be,children:be},be))}),s.jsx("div",{className:"border-t border-gray-100 pt-2.5 flex items-center gap-1.5",children:s.jsx("input",{type:"text",maxLength:6,placeholder:"Or write yours...",className:"w-full px-2.5 py-1.5 text-xs border border-gray-200 rounded-xl text-center focus:ring-0 focus:border-gray-400 bg-white",onChange:be=>{const je=be.target.value.trim();je&&(Ve(je),te(!1),be.target.value="")}})})]})})]})}),s.jsx("div",{className:"flex flex-wrap items-center justify-center gap-2 pt-2.5",children:Object.entries(It()).map(([be,je])=>{const ze=$===be;return s.jsxs("div",{onClick:()=>Ve(be),className:Ge("flex items-center gap-1 hover:scale-105 px-3 py-1.5 border rounded-full text-[12px] font-bold select-none cursor-pointer transition-all",ze?"bg-red-50 border-red-300 text-red-600 font-extrabold ring-1 ring-red-300/40":"bg-white border-gray-150 text-gray-600 hover:border-gray-300 hover:bg-gray-50/50"),children:[s.jsx("span",{className:"text-sm leading-none shrink-0",children:be}),s.jsx("span",{className:"font-mono text-[9px] font-black text-gray-500 bg-gray-100 px-1 rounded-sm leading-none shrink-0 min-w-[12px] text-center",children:je})]},be)})})]}),s.jsxs("div",{className:Ge("space-y-6 pt-2 pb-6 text-left transition-opacity duration-150",Y&&"opacity-90"),children:[(()=>{const be=["News","Sports","Music","Entertainment","Innovation","Culture","Business"].map(je=>{const ze=r==null?void 0:r.find(tt=>(tt.category||"").toLowerCase().trim()===je.toLowerCase().trim());return{cat:je,presentingArticle:ze}}).filter(je=>je.presentingArticle);return be.length===0?null:s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 font-black text-gray-950 text-[10px] tracking-wider uppercase mb-3 select-none",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-650"}),s.jsx("span",{children:"Explore Categories"})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:be.map(({cat:je,presentingArticle:ze})=>s.jsxs("div",{onClick:()=>{if(i&&ze){i(ze);const tt=document.getElementById("full-article-modal-container");tt&&tt.scrollTo({top:0,behavior:"smooth"})}},className:"group flex items-center gap-3 p-2 bg-gray-50/70 hover:bg-white border border-gray-150 hover:border-red-350 hover:shadow-xs transition-all rounded-xl cursor-pointer text-left",children:[s.jsx("div",{className:"w-11 h-11 rounded-lg overflow-hidden bg-gray-200 shrink-0 border border-gray-150",children:s.jsx("img",{src:ze.featuredImageUrl,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500",alt:"",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsx("span",{className:"bg-red-50 text-red-655 px-1.5 py-0.5 text-[8px] font-black uppercase tracking-widest border border-red-100/70 rounded-xs",children:je})}),s.jsx("h5",{className:"font-serif font-black text-[10.5px] text-gray-950 truncate group-hover:text-red-655 transition-colors underline decoration-gray-150",children:ze.title})]})]},je))})]})})(),r&&r.length>0&&s.jsxs("div",{className:"space-y-3 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 font-black text-gray-950 text-[10px] tracking-wider uppercase border-b border-gray-100 pb-2 select-none",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-650"}),s.jsx("span",{children:"Related Campus Stories"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:(()=>{const be=(e.category||"").toLowerCase().trim(),je=r.filter(tt=>tt.id!==e.id&&(tt.category||"").toLowerCase().trim()===be),ze=r.filter(tt=>tt.id!==e.id&&(tt.category||"").toLowerCase().trim()!==be);return[...je,...ze].slice(0,4)})().map(be=>s.jsxs("div",{onClick:()=>{if(i){i(be);const je=document.getElementById("full-article-modal-container");je&&je.scrollTo({top:0,behavior:"smooth"})}},className:"group flex gap-3 p-3 bg-gray-50/50 hover:bg-white border border-gray-100/70 hover:border-red-200 hover:shadow-md transition-all rounded-2xl cursor-pointer text-left focus:outline-hidden",children:[be.featuredImageUrl?s.jsx("img",{src:be.featuredImageUrl,alt:"",className:"w-16 h-16 rounded-xl object-cover border border-gray-100 shrink-0 select-none group-hover:scale-105 transition-transform",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"w-16 h-16 rounded-xl bg-gray-100 flex items-center justify-center shrink-0 text-gray-400 select-none font-black text-xs uppercase tracking-widest border border-gray-100",children:"EYE"}),s.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-between py-0.5 font-sans",children:[s.jsx("span",{className:"text-[7.5px] font-black uppercase tracking-widest text-red-650",children:be.category||"General"}),s.jsx("h5",{className:"font-extrabold text-[11px] text-gray-950 group-hover:text-red-650 transition-colors tracking-tight leading-snug line-clamp-2",children:be.title}),s.jsx("span",{className:"text-[7.5px] font-mono text-gray-400 font-bold uppercase tracking-widest",children:"Read dispatch →"})]})]},be.id))})]})]})]}),s.jsx(XW,{isOpen:xe,imagesList:dt,initialIndex:J,imageUrl:dt[J]||"",title:o.title,onClose:()=>ae(!1)}),s.jsx(ar,{children:Fe&&s.jsxs("div",{className:"fixed inset-0 z-[2500] flex",children:[s.jsx(Kt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>pt(!1),className:"fixed inset-0 bg-black/60 backdrop-blur-sm"}),s.jsxs(Kt.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",damping:25,stiffness:220},className:"relative w-80 max-w-[85vw] bg-white h-full shadow-2xl overflow-y-auto flex flex-col pt-5 px-6 border-r border-gray-150 z-[2600] text-left text-gray-900",children:[s.jsxs("div",{className:"flex items-center justify-between pb-4 border-b border-gray-100 mb-6",children:[s.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"Campus Eye Logo",className:"h-7 w-7 rounded-full border border-gray-950 bg-white object-cover aspect-square shrink-0",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"flex flex-col justify-center text-left -space-y-1",children:[s.jsxs("span",{className:"text-[11px] font-serif font-black tracking-normal italic leading-none",children:[s.jsx("span",{className:"text-red-650",children:"Campus"})," ",s.jsx("span",{className:"text-blue-600",children:"Eye"})]}),s.jsx("span",{className:"text-[5.5px] font-sans font-extrabold uppercase tracking-[0.24em] text-black text-right pr-0.2 block select-none leading-none",children:"Media"})]})]}),s.jsx("button",{onClick:()=>pt(!1),className:"p-1.5 rounded-full hover:bg-gray-100 text-gray-400 hover:text-gray-950 transition-all cursor-pointer flex items-center justify-center shrink-0",children:s.jsx(er,{size:16})})]}),s.jsxs("div",{className:"flex-1 space-y-1.5 font-sans",children:[[{id:"home",label:"Home",icon:()=>s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})})},{id:"news",label:"Campus News",icon:()=>s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1M19 20a2 2 0 002-2V8a2 2 0 00-2-2h-5a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h1.5m-1.5 3h1.5m3-3H15m-1.5 3H15m-3.5 3H15"})})},{id:"discussions",label:"Public Debates",icon:()=>s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})},{id:"tickets",label:"Ticket Store",icon:()=>s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z"})})},{id:"podcasts",label:"Audio Podcasts",icon:()=>s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})},{id:"feedback",label:"Feedback Desk",icon:()=>s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})},{id:"account",label:"My Account",icon:()=>s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}].map(be=>s.jsxs("button",{onClick:()=>{pt(!1),t(),window.dispatchEvent(new CustomEvent("setTab",{detail:be.id}))},className:"flex items-center gap-3 w-full px-4 py-2.5 rounded-xl transition-all font-bold text-xs uppercase tracking-wider text-left text-gray-700 hover:bg-gray-50 hover:text-black cursor-pointer",children:[s.jsx(be.icon,{}),s.jsx("span",{children:be.label})]},be.id)),Ue&&Ue.length>0&&Ue.map(be=>s.jsxs("button",{onClick:()=>{pt(!1),t(),window.dispatchEvent(new CustomEvent("selectCustomPage",{detail:be}))},className:"flex items-center gap-3 w-full px-4 py-2.5 rounded-xl transition-all font-bold text-xs uppercase tracking-wider text-left text-gray-700 hover:bg-gray-50 hover:text-black cursor-pointer",children:[s.jsx("svg",{className:"w-4 h-4 text-gray-500 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),s.jsx("span",{className:"truncate",children:be.name})]},be.id))]})]})]})}),T&&s.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-md z-[200] flex items-end sm:items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200",onClick:be=>{be.stopPropagation(),D(!1)},children:s.jsxs("div",{className:"bg-white/95 dark:bg-neutral-900/95 backdrop-blur-2xl border border-gray-200/80 dark:border-white/10 rounded-3xl p-5 sm:p-6 w-full max-w-sm shadow-2xl space-y-4 text-center relative animate-in slide-in-from-bottom-5 duration-200",onClick:be=>be.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 dark:border-neutral-800 pb-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-left",children:[s.jsx("div",{className:"p-2 bg-red-50 text-red-650 rounded-full",children:s.jsx(df,{size:16})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-bold text-gray-900 dark:text-white",children:"Share Article"}),s.jsx("p",{className:"text-[10px] text-gray-500 lowercase tracking-tight",children:"Choose your preferred social platform"})]})]}),s.jsx("button",{onClick:()=>D(!1),className:"p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-full transition-all cursor-pointer",children:s.jsx(er,{size:18})})]}),s.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-neutral-800/60 rounded-2xl border border-gray-100 dark:border-neutral-700/50 text-left space-y-1",children:[s.jsx("p",{className:"text-[11px] font-extrabold text-gray-900 dark:text-white line-clamp-1",children:e.title}),s.jsx("p",{className:"text-[9px] text-gray-500 font-mono truncate",children:`${window.location.origin}/article/${e.id}`})]}),s.jsxs("div",{className:"grid grid-cols-4 gap-2 pt-1",children:[s.jsxs("a",{href:`https://api.whatsapp.com/send?text=${encodeURIComponent(e.title+` Read more: ${window.location.origin}/article/${e.id}`)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>D(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-emerald-50 text-emerald-700 rounded-2xl hover:bg-emerald-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"💬"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"WhatsApp"})]}),s.jsxs("a",{href:`https://twitter.com/intent/tweet?text=${encodeURIComponent(e.title)}&url=${encodeURIComponent(`${window.location.origin}/article/${e.id}`)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>D(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-sky-50 text-sky-700 rounded-2xl hover:bg-sky-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"🐦"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"Twitter/X"})]}),s.jsxs("a",{href:`https://t.me/share/url?url=${encodeURIComponent(`${window.location.origin}/article/${e.id}`)}&text=${encodeURIComponent(e.title)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>D(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-blue-50 text-blue-700 rounded-2xl hover:bg-blue-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"✈️"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"Telegram"})]}),s.jsxs("a",{href:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(`${window.location.origin}/article/${e.id}`)}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>D(!1),className:"flex flex-col items-center gap-1.5 p-2.5 bg-indigo-50 text-indigo-700 rounded-2xl hover:bg-indigo-100 transition-all active:scale-95 cursor-pointer",children:[s.jsx("span",{className:"text-xl",children:"📘"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider",children:"Facebook"})]})]}),s.jsx("div",{className:"pt-2",children:s.jsx("button",{onClick:async()=>{const be=`${window.location.origin}/article/${e.id}`;await Pd(`${e.title} ${be}`),sr.success("Link copied to clipboard!"),D(!1)},className:"w-full py-3 bg-red-650 hover:bg-red-700 text-white font-bold text-xs uppercase tracking-widest rounded-2xl transition-all shadow-md active:scale-98 flex items-center justify-center gap-2 cursor-pointer",children:s.jsx("span",{children:"Copy Direct Link"})})})]})})]})};async function OL(e,t,n,r){return new Promise((i,a)=>{const o=new FileReader;o.onload=c=>{var f;const h=new Image;h.onload=()=>{const m=document.createElement("canvas");let y=h.width,w=h.height;y>w?y>t&&(w=Math.round(w*t/y),y=t):w>n&&(y=Math.round(y*n/w),w=n),m.width=y,m.height=w;const A=m.getContext("2d");if(!A){a(new Error("Failed to get 2D canvas context"));return}A.drawImage(h,0,0,y,w),m.toBlob(k=>{k?i(k):a(new Error("Canvas export to blob failed"))},"image/jpeg",r)},h.onerror=()=>a(new Error("Failed to load image in Canvas pre-compressor")),h.src=(f=c.target)==null?void 0:f.result},o.onerror=()=>a(new Error("FileReader error in pre-compressor")),o.readAsDataURL(e)})}function U2e(e){return new Promise((t,n)=>{const r=new FileReader;r.onloadend=()=>{typeof r.result=="string"?t(r.result):n(new Error("Failed to convert blob to base64"))},r.onerror=()=>n(new Error("FileReader blob error")),r.readAsDataURL(e)})}function tY(){if(typeof window<"u"){const e=localStorage.getItem("campus_eye_imgbb_active_key");if(e&&e.trim().length>5)return e.trim()}return"857eaaf2b7571ee437db8ee3f6ee8670"}async function h4(e){const t=tY(),n=Array.from(new Set([t,"857eaaf2b7571ee437db8ee3f6ee8670","3b3f20f2693897b69c4fae1ff05d9852","f3a6776e0a442398246cb321152a5ec2"])).filter(Boolean);let r;try{r=await OL(e,1200,1200,.78)}catch(i){console.warn("Client-side pre-compression failed, uploading original payload:",i),r=e}for(const i of n)try{const a=new FormData,o=e.name.replace(/\.[^/.]+$/,"")+".jpg",c=new File([r],o,{type:"image/jpeg"});a.append("image",c);const f=await(await fetch(`https://api.imgbb.com/1/upload?key=${i}`,{method:"POST",body:a})).json();if(f.success&&f.data&&f.data.url)return f.data.url}catch{}try{const i=await OL(e,700,700,.72);return await U2e(i)}catch{return new Promise((a,o)=>{const c=new FileReader;c.onloadend=()=>{typeof c.result=="string"?a(c.result):o(new Error("Image encoding failed"))},c.onerror=()=>o(new Error("FileReader error")),c.readAsDataURL(e)})}}const nY="campus_expansion_dbs",rY="campus_active_write_db_slot",JC="campus_custom_auth_domain";function B2e(){try{const e=localStorage.getItem(nY);return e?JSON.parse(e):[]}catch(e){return console.warn("Failed to load expansion slots:",e),[]}}function PL(e){try{localStorage.setItem(nY,JSON.stringify(e))}catch(t){console.error("Failed to save expansion slots:",t)}}function z2e(){return localStorage.getItem(rY)||"default"}function RL(e){localStorage.setItem(rY,e)}function V2e(){return localStorage.getItem(JC)||l2.authDomain}function F2e(e){e.trim()?localStorage.setItem(JC,e.trim()):localStorage.removeItem(JC)}function $2e(e){const t=e.trim();if(!t)throw new Error("Empty Firebase config input provided.");try{const a=JSON.parse(t);if(typeof a=="object"&&a!==null)return{apiKey:a.apiKey||"",authDomain:a.authDomain||"",projectId:a.projectId||"",storageBucket:a.storageBucket||"",messagingSenderId:a.messagingSenderId||"",appId:a.appId||"",measurementId:a.measurementId||"",firestoreDatabaseId:a.firestoreDatabaseId||"(default)"}}catch{}const n=["apiKey","authDomain","projectId","storageBucket","messagingSenderId","appId","measurementId","firestoreDatabaseId"],r={apiKey:"",authDomain:"",projectId:"",storageBucket:"",messagingSenderId:"",appId:"",measurementId:"",firestoreDatabaseId:"(default)"};let i=0;for(const a of n){const o=new RegExp(`${a}\\s*:\\s*["'\`]([^"'\`]+)["'\`]`,"i"),c=t.match(o);c&&c[1]&&(r[a]=c[1].trim(),i++)}if(i===0||!r.apiKey)throw new Error("Could not detect valid Firebase config fields (apiKey, projectId, etc.). Please check the pasted snippet.");return r}function H2e(e,t="https://campuseyemedia.com"){const n=t.replace(/\/$/,""),r=new Date().toISOString(),i=e.map(a=>{var f,m,y;const o=a.id,c=(f=a.updatedAt)!=null&&f.toDate?a.updatedAt.toDate().toISOString():(m=a.publishDate)!=null&&m.toDate?a.publishDate.toDate().toISOString():(y=a.createdAt)!=null&&y.toDate?a.createdAt.toDate().toISOString():r,h=a.featuredImageUrl||"";return` ${n}/#article-${o} ${c} daily 0.8 ${h?` ${DL(h)} ${DL(a.title)} `:""} `}).join(` `);return` ${n}/ ${r} always 1.0 ${i} `}function DL(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}var G2e=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"];function f4(e){if(typeof e!="string")return!1;var t=G2e;return t.includes(e)}var q2e=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],W2e=new Set(q2e);function iY(e){return typeof e!="string"?!1:W2e.has(e)}function sY(e){return typeof e=="string"&&e.startsWith("data-")}function Hl(e){if(typeof e!="object"||e===null)return{};var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(iY(n)||sY(n))&&(t[n]=e[n]);return t}function Fy(e){if(e==null)return null;if(j.isValidElement(e)&&typeof e.props=="object"&&e.props!==null){var t=e.props;return Hl(t)}return typeof e=="object"&&!Array.isArray(e)?Hl(e):null}function ko(e){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(iY(n)||sY(n)||f4(n))&&(t[n]=e[n]);return t}function K2e(e){return e==null?null:j.isValidElement(e)?ko(e.props):typeof e=="object"&&!Array.isArray(e)?ko(e):null}var Y2e=["children","width","height","viewBox","className","style","title","desc"];function eI(){return eI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:n,width:r,height:i,viewBox:a,className:o,style:c,title:h,desc:f}=e,m=X2e(e,Y2e),y=a||{width:r,height:i,x:0,y:0},w=Di("recharts-surface",o);return j.createElement("svg",eI({},ko(m),{className:w,width:r,height:i,style:c,viewBox:"".concat(y.x," ").concat(y.y," ").concat(y.width," ").concat(y.height),ref:t}),j.createElement("title",null,h),j.createElement("desc",null,f),n)}),Z2e=["children","className"];function tI(){return tI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:n,className:r}=e,i=J2e(e,Z2e),a=Di("recharts-layer",r);return j.createElement("g",tI({className:a},ko(i),{ref:t}),n)}),aY=j.createContext(null),tNe=()=>j.useContext(aY);function ls(e){return function(){return e}}const oY=Math.cos,k2=Math.sin,Hc=Math.sqrt,C2=Math.PI,wE=2*C2,nI=Math.PI,rI=2*nI,cp=1e-6,nNe=rI-cp;function lY(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return lY;const n=10**t;return function(r){this._+=r[0];for(let i=1,a=r.length;icp)if(!(Math.abs(y*h-f*m)>cp)||!a)this._append`L${this._x1=t},${this._y1=n}`;else{let A=r-o,k=i-c,I=h*h+f*f,T=A*A+k*k,D=Math.sqrt(I),F=Math.sqrt(w),L=a*Math.tan((nI-Math.acos((I+w-T)/(2*D*F)))/2),q=L/F,Z=L/D;Math.abs(q-1)>cp&&this._append`L${t+q*m},${n+q*y}`,this._append`A${a},${a},0,0,${+(y*A>m*k)},${this._x1=t+Z*h},${this._y1=n+Z*f}`}}arc(t,n,r,i,a,o){if(t=+t,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let c=r*Math.cos(i),h=r*Math.sin(i),f=t+c,m=n+h,y=1^o,w=o?i-a:a-i;this._x1===null?this._append`M${f},${m}`:(Math.abs(this._x1-f)>cp||Math.abs(this._y1-m)>cp)&&this._append`L${f},${m}`,r&&(w<0&&(w=w%rI+rI),w>nNe?this._append`A${r},${r},0,1,${y},${t-c},${n-h}A${r},${r},0,1,${y},${this._x1=f},${this._y1=m}`:w>cp&&this._append`A${r},${r},0,${+(w>=nI)},${y},${this._x1=t+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function m4(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new iNe(t)}function g4(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function cY(e){this._context=e}cY.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function NE(e){return new cY(e)}function uY(e){return e[0]}function dY(e){return e[1]}function hY(e,t){var n=ls(!0),r=null,i=NE,a=null,o=m4(c);e=typeof e=="function"?e:e===void 0?uY:ls(e),t=typeof t=="function"?t:t===void 0?dY:ls(t);function c(h){var f,m=(h=g4(h)).length,y,w=!1,A;for(r==null&&(a=i(A=o())),f=0;f<=m;++f)!(f=A;--k)c.point(L[k],q[k]);c.lineEnd(),c.areaEnd()}D&&(L[w]=+e(T,w,y),q[w]=+t(T,w,y),c.point(r?+r(T,w,y):L[w],n?+n(T,w,y):q[w]))}if(F)return c=null,F+""||null}function m(){return hY().defined(i).curve(o).context(a)}return f.x=function(y){return arguments.length?(e=typeof y=="function"?y:ls(+y),r=null,f):e},f.x0=function(y){return arguments.length?(e=typeof y=="function"?y:ls(+y),f):e},f.x1=function(y){return arguments.length?(r=y==null?null:typeof y=="function"?y:ls(+y),f):r},f.y=function(y){return arguments.length?(t=typeof y=="function"?y:ls(+y),n=null,f):t},f.y0=function(y){return arguments.length?(t=typeof y=="function"?y:ls(+y),f):t},f.y1=function(y){return arguments.length?(n=y==null?null:typeof y=="function"?y:ls(+y),f):n},f.lineX0=f.lineY0=function(){return m().x(e).y(t)},f.lineY1=function(){return m().x(e).y(n)},f.lineX1=function(){return m().x(r).y(t)},f.defined=function(y){return arguments.length?(i=typeof y=="function"?y:ls(!!y),f):i},f.curve=function(y){return arguments.length?(o=y,a!=null&&(c=o(a)),f):o},f.context=function(y){return arguments.length?(y==null?a=c=null:c=o(a=y),f):a},f}class fY{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n);break}}this._x0=t,this._y0=n}}function sNe(e){return new fY(e,!0)}function aNe(e){return new fY(e,!1)}const x4={draw(e,t){const n=Hc(t/C2);e.moveTo(n,0),e.arc(0,0,n,0,wE)}},oNe={draw(e,t){const n=Hc(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},pY=Hc(1/3),lNe=pY*2,cNe={draw(e,t){const n=Hc(t/lNe),r=n*pY;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},uNe={draw(e,t){const n=Hc(t),r=-n/2;e.rect(r,r,n,n)}},dNe=.8908130915292852,mY=k2(C2/10)/k2(7*C2/10),hNe=k2(wE/10)*mY,fNe=-oY(wE/10)*mY,pNe={draw(e,t){const n=Hc(t*dNe),r=hNe*n,i=fNe*n;e.moveTo(0,-n),e.lineTo(r,i);for(let a=1;a<5;++a){const o=wE*a/5,c=oY(o),h=k2(o);e.lineTo(h*n,-c*n),e.lineTo(c*r-h*i,h*r+c*i)}e.closePath()}},PS=Hc(3),mNe={draw(e,t){const n=-Hc(t/(PS*3));e.moveTo(0,n*2),e.lineTo(-PS*n,-n),e.lineTo(PS*n,-n),e.closePath()}},Jl=-.5,ec=Hc(3)/2,iI=1/Hc(12),gNe=(iI/2+1)*3,xNe={draw(e,t){const n=Hc(t/gNe),r=n/2,i=n*iI,a=r,o=n*iI+n,c=-a,h=o;e.moveTo(r,i),e.lineTo(a,o),e.lineTo(c,h),e.lineTo(Jl*r-ec*i,ec*r+Jl*i),e.lineTo(Jl*a-ec*o,ec*a+Jl*o),e.lineTo(Jl*c-ec*h,ec*c+Jl*h),e.lineTo(Jl*r+ec*i,Jl*i-ec*r),e.lineTo(Jl*a+ec*o,Jl*o-ec*a),e.lineTo(Jl*c+ec*h,Jl*h-ec*c),e.closePath()}};function yNe(e,t){let n=null,r=m4(i);e=typeof e=="function"?e:ls(e||x4),t=typeof t=="function"?t:ls(t===void 0?64:+t);function i(){let a;if(n||(n=a=r()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),a)return n=null,a+""||null}return i.type=function(a){return arguments.length?(e=typeof a=="function"?a:ls(a),i):e},i.size=function(a){return arguments.length?(t=typeof a=="function"?a:ls(+a),i):t},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function I2(){}function j2(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function gY(e){this._context=e}gY.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:j2(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:j2(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function bNe(e){return new gY(e)}function xY(e){this._context=e}xY.prototype={areaStart:I2,areaEnd:I2,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:j2(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function vNe(e){return new xY(e)}function yY(e){this._context=e}yY.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:j2(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function wNe(e){return new yY(e)}function bY(e){this._context=e}bY.prototype={areaStart:I2,areaEnd:I2,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function NNe(e){return new bY(e)}function ML(e){return e<0?-1:1}function LL(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),c=(a*i+o*r)/(r+i);return(ML(a)+ML(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(c))||0}function UL(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function RS(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,c=(a-r)/3;e._context.bezierCurveTo(r+c,i+c*t,a-c,o-c*n,a,o)}function T2(e){this._context=e}T2.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:RS(this,this._t0,UL(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,RS(this,UL(this,n=LL(this,e,t)),n);break;default:RS(this,this._t0,n=LL(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function vY(e){this._context=new wY(e)}(vY.prototype=Object.create(T2.prototype)).point=function(e,t){T2.prototype.point.call(this,t,e)};function wY(e){this._context=e}wY.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function ENe(e){return new T2(e)}function ANe(e){return new vY(e)}function NY(e){this._context=e}NY.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=BL(e),i=BL(t),a=0,o=1;o=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function SNe(e){return new EE(e,.5)}function kNe(e){return new EE(e,0)}function CNe(e){return new EE(e,1)}function rm(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,c=a.length;n=0;)n[t]=t;return n}function INe(e,t){return e[t]}function jNe(e){const t=[];return t.key=e,t}function TNe(){var e=ls([]),t=sI,n=rm,r=INe;function i(a){var o=Array.from(e.apply(this,arguments),jNe),c,h=o.length,f=-1,m;for(const y of a)for(c=0,++f;c0){for(var n,r,i=0,a=e[0].length,o;i0){for(var n=0,r=e[t[0]],i,a=r.length;n0)||!((a=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,a,o;r1&&arguments[1]!==void 0?arguments[1]:BNe,n=10**t,r=Math.round(e*n)/n;return Object.is(r,-0)?0:r}function Hs(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{var c=n[o-1];return typeof c=="string"?i+c+a:c!==void 0?i+ef(c)+a:i+a},"")}var xl=e=>e===0?0:e>0?1:-1,Vc=e=>typeof e=="number"&&e!=+e,im=e=>typeof e=="string"&&e.indexOf("%")===e.length-1,En=e=>(typeof e=="number"||e instanceof Number)&&!Vc(e),Uu=e=>En(e)||typeof e=="string",zNe=0,ny=e=>{var t=++zNe;return"".concat(e||"").concat(t)},Fc=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!En(t)&&typeof t!="string")return r;var a;if(im(t)){if(n==null)return r;var o=t.indexOf("%");a=n*parseFloat(t.slice(0,o))/100}else a=+t;return Vc(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},AY=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;rr&&(typeof t=="function"?t(r):mg(r,t))===n)}var xs=e=>e===null||typeof e>"u",$y=e=>xs(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function yl(e){return e!=null}function jf(){}var VNe=["type","size","sizeType"];function aI(){return aI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t="symbol".concat($y(e));return SY[t]||x4},YNe=(e,t,n)=>{if(t==="area")return e;switch(n){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var r=18*WNe;return 1.25*e*e*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2)}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},XNe=(e,t)=>{SY["symbol".concat($y(e))]=t},w4=e=>{var{type:t="circle",size:n=64,sizeType:r="area"}=e,i=GNe(e,VNe),a=KL(KL({},i),{},{type:t,size:n,sizeType:r}),o="circle";typeof t=="string"&&(o=t);var c=()=>{var w=KNe(o),A=yNe().type(w).size(YNe(n,r,o)),k=A();if(k!==null)return k},{className:h,cx:f,cy:m}=a,y=ko(a);return En(f)&&En(m)&&En(n)?j.createElement("path",aI({},y,{className:Di("recharts-symbols",h),transform:"translate(".concat(f,", ").concat(m,")"),d:c()})):null};w4.registerSymbol=XNe;var kY=e=>"radius"in e&&"startAngle"in e&&"endAngle"in e,N4=(e,t)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var n=e;if(j.isValidElement(e)&&(n=e.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{f4(i)&&typeof n[i]=="function"&&(r[i]=(a=>n[i](n,a)))}),r},QNe=(e,t,n)=>r=>(e(t,n,r),null),AE=(e,t,n)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var r=null;return Object.keys(e).forEach(i=>{var a=e[i];f4(i)&&typeof a=="function"&&(r||(r={}),r[i]=QNe(a,t,n))}),r};function YL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function ZNe(e){for(var t=1;t(o[c]===void 0&&r[c]!==void 0&&(o[c]=r[c]),o),n);return a}function O2(){return O2=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var A=y.formatter||i,k=Di({"recharts-legend-item":!0,["legend-item-".concat(w)]:!0,inactive:y.inactive});if(y.type==="none")return null;var I=typeof c=="object"?CY({},c):{};I.color=y.inactive?a:I.color||y.color;var T=A?A(y.value,y,w):y.value;return j.createElement("li",O2({className:k,style:f,key:"legend-item-".concat(w)},AE(e,y,w)),j.createElement(p4,{width:n,height:n,viewBox:h,style:m,"aria-label":"".concat(y.value," legend icon")},j.createElement(oEe,{data:y,iconType:o,inactiveColor:a})),j.createElement("span",{className:"recharts-legend-item-text",style:I},T))})}var cEe=e=>{var t=Fa(e,sEe),{payload:n,layout:r,align:i}=t;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return j.createElement("ul",{className:"recharts-default-legend",style:a},j.createElement(lEe,O2({},t,{payload:n})))},FS={},$S={},QL;function uEe(){return QL||(QL=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r){const i=new Map;for(let a=0;a=0}e.isLength=t})(KS)),KS}var t7;function jY(){return t7||(t7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=hEe();function n(r){return r!=null&&typeof r!="function"&&t.isLength(r.length)}e.isArrayLike=n})(WS)),WS}var YS={},n7;function fEe(){return n7||(n7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return typeof n=="object"&&n!==null}e.isObjectLike=t})(YS)),YS}var r7;function pEe(){return r7||(r7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=jY(),n=fEe();function r(i){return n.isObjectLike(i)&&t.isArrayLike(i)}e.isArrayLikeObject=r})(qS)),qS}var XS={},QS={},i7;function mEe(){return i7||(i7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=v4();function n(r){return function(i){return t.get(i,r)}}e.property=n})(QS)),QS}var ZS={},JS={},e5={},t5={},s7;function TY(){return s7||(s7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n!==null&&(typeof n=="object"||typeof n=="function")}e.isObject=t})(t5)),t5}var n5={},a7;function OY(){return a7||(a7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n==null||typeof n!="object"&&typeof n!="function"}e.isPrimitive=t})(n5)),n5}var r5={},o7;function PY(){return o7||(o7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r){return n===r||Number.isNaN(n)&&Number.isNaN(r)}e.isEqualsSameValueZero=t})(r5)),r5}var l7;function gEe(){return l7||(l7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=TY(),n=OY(),r=PY();function i(m,y,w){return typeof w!="function"?i(m,y,()=>{}):a(m,y,function A(k,I,T,D,F,L){const q=w(k,I,T,D,F,L);return q!==void 0?!!q:a(k,I,A,L)},new Map)}function a(m,y,w,A){if(y===m)return!0;switch(typeof y){case"object":return o(m,y,w,A);case"function":return Object.keys(y).length>0?a(m,{...y},w,A):r.isEqualsSameValueZero(m,y);default:return t.isObject(m)?typeof y=="string"?y==="":!0:r.isEqualsSameValueZero(m,y)}}function o(m,y,w,A){if(y==null)return!0;if(Array.isArray(y))return h(m,y,w,A);if(y instanceof Map)return c(m,y,w,A);if(y instanceof Set)return f(m,y,w,A);const k=Object.keys(y);if(m==null||n.isPrimitive(m))return k.length===0;if(k.length===0)return!0;if(A!=null&&A.has(y))return A.get(y)===m;A==null||A.set(y,m);try{for(let I=0;I{})}e.isMatch=n})(JS)),JS}var i5={},s5={},a5={},u7;function xEe(){return u7||(u7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return Object.getOwnPropertySymbols(n).filter(r=>Object.prototype.propertyIsEnumerable.call(n,r))}e.getSymbols=t})(a5)),a5}var o5={},d7;function E4(){return d7||(d7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}e.getTag=t})(o5)),o5}var l5={},h7;function DY(){return h7||(h7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",a="[object Arguments]",o="[object Symbol]",c="[object Date]",h="[object Map]",f="[object Set]",m="[object Array]",y="[object Function]",w="[object ArrayBuffer]",A="[object Object]",k="[object Error]",I="[object DataView]",T="[object Uint8Array]",D="[object Uint8ClampedArray]",F="[object Uint16Array]",L="[object Uint32Array]",q="[object BigUint64Array]",Z="[object Int8Array]",K="[object Int16Array]",z="[object Int32Array]",B="[object BigInt64Array]",V="[object Float32Array]",$="[object Float64Array]";e.argumentsTag=a,e.arrayBufferTag=w,e.arrayTag=m,e.bigInt64ArrayTag=B,e.bigUint64ArrayTag=q,e.booleanTag=i,e.dataViewTag=I,e.dateTag=c,e.errorTag=k,e.float32ArrayTag=V,e.float64ArrayTag=$,e.functionTag=y,e.int16ArrayTag=K,e.int32ArrayTag=z,e.int8ArrayTag=Z,e.mapTag=h,e.numberTag=r,e.objectTag=A,e.regexpTag=t,e.setTag=f,e.stringTag=n,e.symbolTag=o,e.uint16ArrayTag=F,e.uint32ArrayTag=L,e.uint8ArrayTag=T,e.uint8ClampedArrayTag=D})(l5)),l5}var c5={},f7;function yEe(){return f7||(f7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}e.isTypedArray=t})(c5)),c5}var p7;function MY(){return p7||(p7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=xEe(),n=E4(),r=DY(),i=OY(),a=yEe();function o(m,y){return c(m,void 0,m,new Map,y)}function c(m,y,w,A=new Map,k=void 0){const I=k==null?void 0:k(m,y,w,A);if(I!==void 0)return I;if(i.isPrimitive(m))return m;if(A.has(m))return A.get(m);if(Array.isArray(m)){const T=new Array(m.length);A.set(m,T);for(let D=0;Dt.isMatch(a,i)}e.matches=r})(ZS)),ZS}var u5={},d5={},h5={},x7;function wEe(){return x7||(x7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=MY(),n=E4(),r=DY();function i(a,o){return t.cloneDeepWith(a,(c,h,f,m)=>{const y=o==null?void 0:o(c,h,f,m);if(y!==void 0)return y;if(typeof a=="object"){if(n.getTag(a)===r.objectTag&&typeof a.constructor!="function"){const w={};return m.set(a,w),t.copyProperties(w,a,f,m),w}switch(Object.prototype.toString.call(a)){case r.numberTag:case r.stringTag:case r.booleanTag:{const w=new a.constructor(a==null?void 0:a.valueOf());return t.copyProperties(w,a),w}case r.argumentsTag:{const w={};return t.copyProperties(w,a),w.length=a.length,w[Symbol.iterator]=a[Symbol.iterator],w}default:return}}})}e.cloneDeepWith=i})(h5)),h5}var y7;function NEe(){return y7||(y7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=wEe();function n(r){return t.cloneDeepWith(r)}e.cloneDeep=n})(d5)),d5}var f5={},p5={},b7;function LY(){return b7||(b7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=/^(?:0|[1-9]\d*)$/;function n(r,i=Number.MAX_SAFE_INTEGER){switch(typeof r){case"number":return Number.isInteger(r)&&r>=0&&r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return v5.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,v5}var C7;function TEe(){return C7||(C7=1,b5.exports=jEe()),b5.exports}/** * @license React * use-sync-external-store-shim/with-selector.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var I7;function OEe(){if(I7)return y5;I7=1;var e=Ag(),t=TEe();function n(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,a=e.useRef,o=e.useEffect,c=e.useMemo,h=e.useDebugValue;return y5.useSyncExternalStoreWithSelector=function(f,m,y,w,A){var k=a(null);if(k.current===null){var I={hasValue:!1,value:null};k.current=I}else I=k.current;k=c(function(){function D(K){if(!F){if(F=!0,L=K,K=w(K),A!==void 0&&I.hasValue){var z=I.value;if(A(z,K))return q=z}return q=K}if(z=q,r(L,K))return z;var B=w(K);return A!==void 0&&A(z,B)?(L=K,z):(L=K,q=B)}var F=!1,L,q,Z=y===void 0?null:y;return[function(){return D(m())},Z===null?void 0:function(){return D(Z())}]},[m,y,w,A]);var T=i(f,k[0],k[1]);return o(function(){I.hasValue=!0,I.value=T},[T]),h(T),T},y5}var j7;function PEe(){return j7||(j7=1,x5.exports=OEe()),x5.exports}var REe=PEe(),A4=j.createContext(null),DEe=e=>e,ys=()=>{var e=j.useContext(A4);return e?e.store.dispatch:DEe},Cw=()=>{},MEe=()=>Cw,LEe=(e,t)=>e===t;function Qn(e){var t=j.useContext(A4),n=j.useMemo(()=>t?r=>{if(r!=null)return e(r)}:Cw,[t,e]);return REe.useSyncExternalStoreWithSelector(t?t.subscription.addNestedSub:MEe,t?t.store.getState:Cw,t?t.store.getState:Cw,n,LEe)}function UEe(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function BEe(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function zEe(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var T7=e=>Array.isArray(e)?e:[e];function VEe(e){const t=Array.isArray(e[0])?e[0]:e;return zEe(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function FEe(e,t){const n=[],{length:r}=e;for(let i=0;i{n=Pv(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function qEe(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...i)=>{let a=0,o=0,c,h={},f=i.pop();typeof f=="object"&&(h=f,f=i.pop()),UEe(f,`createSelector expects an output function after the inputs, but received: [${typeof f}]`);const m={...n,...h},{memoize:y,memoizeOptions:w=[],argsMemoize:A=BY,argsMemoizeOptions:k=[]}=m,I=T7(w),T=T7(k),D=VEe(i),F=y(function(){return a++,f.apply(null,arguments)},...I),L=A(function(){o++;const Z=FEe(D,arguments);return c=F.apply(null,Z),c},...T);return Object.assign(L,{resultFunc:f,memoizedResultFunc:F,dependencies:D,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>c,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:y,argsMemoize:A})};return Object.assign(r,{withTypes:()=>r}),r}var et=qEe(BY),WEe=Object.assign((e,t=et)=>{BEe(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const n=Object.keys(e),r=n.map(a=>e[a]);return t(r,(...a)=>a.reduce((o,c,h)=>(o[n[h]]=c,o),{}))},{withTypes:()=>WEe}),w5={},N5={},E5={},P7;function KEe(){return P7||(P7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,a)=>{if(r!==i){const o=t(r),c=t(i);if(o===c&&o===0){if(ri)return a==="desc"?-1:1}return a==="desc"?c-o:o-c}return 0};e.compareValues=n})(E5)),E5}var A5={},_5={},R7;function zY(){return R7||(R7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return typeof n=="symbol"||n instanceof Symbol}e.isSymbol=t})(_5)),_5}var D7;function YEe(){return D7||(D7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=zY(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,o){return Array.isArray(a)?!1:typeof a=="number"||typeof a=="boolean"||a==null||t.isSymbol(a)?!0:typeof a=="string"&&(r.test(a)||!n.test(a))||o!=null&&Object.hasOwn(o,a)}e.isKey=i})(A5)),A5}var M7;function XEe(){return M7||(M7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=KEe(),n=YEe(),r=b4();function i(a,o,c,h){if(a==null)return[];c=h?void 0:c,Array.isArray(a)||(a=Object.values(a)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(c)||(c=c==null?[]:[c]),c=c.map(A=>String(A));const f=(A,k)=>{let I=A;for(let T=0;Tk==null||A==null?k:typeof A=="object"&&"key"in A?Object.hasOwn(k,A.key)?k[A.key]:f(k,A.path):typeof A=="function"?A(k):Array.isArray(A)?f(k,A):typeof k=="object"?k[A]:k,y=o.map(A=>(Array.isArray(A)&&A.length===1&&(A=A[0]),A==null||typeof A=="function"||Array.isArray(A)||n.isKey(A)?A:{key:A,path:r.toPath(A)}));return a.map(A=>({original:A,criteria:y.map(k=>m(k,A))})).slice().sort((A,k)=>{for(let I=0;IA.original)}e.orderBy=i})(N5)),N5}var S5={},L7;function QEe(){return L7||(L7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r=1){const i=[],a=Math.floor(r),o=(c,h)=>{for(let f=0;f1&&r.isIterateeCall(a,o[0],o[1])?o=[]:c>2&&r.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),t.orderBy(a,n.flatten(o),["asc"])}e.sortBy=i})(w5)),w5}var C5,z7;function JEe(){return z7||(z7=1,C5=ZEe().sortBy),C5}var eAe=JEe();const _E=Hu(eAe);var FY=e=>e.legend.settings,tAe=e=>e.legend.size,nAe=e=>e.legend.payload,rAe=et([nAe,FY],(e,t)=>{var{itemSorter:n}=t,r=e.flat(1);return n?_E(r,n):r});function iAe(){return Qn(rAe)}var Rv=1;function $Y(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[t,n]=j.useState({height:0,left:0,top:0,width:0}),r=j.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),o={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(o.height-t.height)>Rv||Math.abs(o.left-t.left)>Rv||Math.abs(o.top-t.top)>Rv||Math.abs(o.width-t.width)>Rv)&&n({height:o.height,left:o.left,top:o.top,width:o.width})}},[t.width,t.height,t.top,t.left,...e]);return[t,r]}function eo(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var sAe=typeof Symbol=="function"&&Symbol.observable||"@@observable",V7=sAe,I5=()=>Math.random().toString(36).substring(7).split("").join("."),aAe={INIT:`@@redux/INIT${I5()}`,REPLACE:`@@redux/REPLACE${I5()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${I5()}`},P2=aAe;function _4(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function HY(e,t,n){if(typeof e!="function")throw new Error(eo(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(eo(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(eo(1));return n(HY)(e,t)}let r=e,i=t,a=new Map,o=a,c=0,h=!1;function f(){o===a&&(o=new Map,a.forEach((T,D)=>{o.set(D,T)}))}function m(){if(h)throw new Error(eo(3));return i}function y(T){if(typeof T!="function")throw new Error(eo(4));if(h)throw new Error(eo(5));let D=!0;f();const F=c++;return o.set(F,T),function(){if(D){if(h)throw new Error(eo(6));D=!1,f(),o.delete(F),a=null}}}function w(T){if(!_4(T))throw new Error(eo(7));if(typeof T.type>"u")throw new Error(eo(8));if(typeof T.type!="string")throw new Error(eo(17));if(h)throw new Error(eo(9));try{h=!0,i=r(i,T)}finally{h=!1}return(a=o).forEach(F=>{F()}),T}function A(T){if(typeof T!="function")throw new Error(eo(10));r=T,w({type:P2.REPLACE})}function k(){const T=y;return{subscribe(D){if(typeof D!="object"||D===null)throw new Error(eo(11));function F(){const q=D;q.next&&q.next(m())}return F(),{unsubscribe:T(F)}},[V7](){return this}}}return w({type:P2.INIT}),{dispatch:w,subscribe:y,getState:m,replaceReducer:A,[V7]:k}}function oAe(e){Object.keys(e).forEach(t=>{const n=e[t];if(typeof n(void 0,{type:P2.INIT})>"u")throw new Error(eo(12));if(typeof n(void 0,{type:P2.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(eo(13))})}function GY(e){const t=Object.keys(e),n={};for(let a=0;a"u")throw c&&c.type,new Error(eo(14));f[y]=k,h=h||k!==A}return h=h||r.length!==Object.keys(o).length,h?f:o}}function R2(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function lAe(...e){return t=>(n,r)=>{const i=t(n,r);let a=()=>{throw new Error(eo(15))};const o={getState:i.getState,dispatch:(h,...f)=>a(h,...f)},c=e.map(h=>h(o));return a=R2(...c)(i.dispatch),{...i,dispatch:a}}}function qY(e){return _4(e)&&"type"in e&&typeof e.type=="string"}var WY=Symbol.for("immer-nothing"),F7=Symbol.for("immer-draftable"),Yo=Symbol.for("immer-state");function Pc(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Bl=Object,gg=Bl.getPrototypeOf,D2="constructor",SE="prototype",oI="configurable",M2="enumerable",Iw="writable",ry="value",$d=e=>!!e&&!!e[Yo];function $c(e){var t;return e?KY(e)||CE(e)||!!e[F7]||!!((t=e[D2])!=null&&t[F7])||IE(e)||jE(e):!1}var cAe=Bl[SE][D2].toString(),$7=new WeakMap;function KY(e){if(!e||!S4(e))return!1;const t=gg(e);if(t===null||t===Bl[SE])return!0;const n=Bl.hasOwnProperty.call(t,D2)&&t[D2];if(n===Object)return!0;if(!N0(n))return!1;let r=$7.get(n);return r===void 0&&(r=Function.toString.call(n),$7.set(n,r)),r===cAe}function kE(e,t,n=!0){Hy(e)===0?(n?Reflect.ownKeys(e):Bl.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function Hy(e){const t=e[Yo];return t?t.type_:CE(e)?1:IE(e)?2:jE(e)?3:0}var H7=(e,t,n=Hy(e))=>n===2?e.has(t):Bl[SE].hasOwnProperty.call(e,t),lI=(e,t,n=Hy(e))=>n===2?e.get(t):e[t],L2=(e,t,n,r=Hy(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function uAe(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var CE=Array.isArray,IE=e=>e instanceof Map,jE=e=>e instanceof Set,S4=e=>typeof e=="object",N0=e=>typeof e=="function",j5=e=>typeof e=="boolean";function dAe(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Ad=e=>e.copy_||e.base_,k4=e=>e.modified_?e.copy_:e.base_;function cI(e,t){if(IE(e))return new Map(e);if(jE(e))return new Set(e);if(CE(e))return Array[SE].slice.call(e);const n=KY(e);if(t===!0||t==="class_only"&&!n){const r=Bl.getOwnPropertyDescriptors(e);delete r[Yo];let i=Reflect.ownKeys(r);for(let a=0;a1&&Bl.defineProperties(e,{set:Dv,add:Dv,clear:Dv,delete:Dv}),Bl.freeze(e),t&&kE(e,(n,r)=>{C4(r,!0)},!1)),e}function hAe(){Pc(2)}var Dv={[ry]:hAe};function TE(e){return e===null||!S4(e)?!0:Bl.isFrozen(e)}var U2="MapSet",uI="Patches",G7="ArrayMethods",YY={};function sm(e){const t=YY[e];return t||Pc(0,e),t}var q7=e=>!!YY[e],iy,XY=()=>iy,fAe=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:q7(U2)?sm(U2):void 0,arrayMethodsPlugin_:q7(G7)?sm(G7):void 0});function W7(e,t){t&&(e.patchPlugin_=sm(uI),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function dI(e){hI(e),e.drafts_.forEach(pAe),e.drafts_=null}function hI(e){e===iy&&(iy=e.parent_)}var K7=e=>iy=fAe(iy,e);function pAe(e){const t=e[Yo];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Y7(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[Yo].modified_&&(dI(t),Pc(4)),$c(e)&&(e=X7(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[Yo].base_,e,t)}else e=X7(t,n);return mAe(t,e,!0),dI(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==WY?e:void 0}function X7(e,t){if(TE(t))return t;const n=t[Yo];if(!n)return B2(t,e.handledSet_,e);if(!OE(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);JY(n,e)}return n.copy_}function mAe(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&C4(t,n)}function QY(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var OE=(e,t)=>e.scope_===t,gAe=[];function ZY(e,t,n,r){const i=Ad(e),a=e.type_;if(r!==void 0&&lI(i,r,a)===t){L2(i,r,n,a);return}if(!e.draftLocations_){const c=e.draftLocations_=new Map;kE(i,(h,f)=>{if($d(f)){const m=c.get(f)||[];m.push(h),c.set(f,m)}})}const o=e.draftLocations_.get(t)??gAe;for(const c of o)L2(i,c,n,a)}function xAe(e,t,n){e.callbacks_.push(function(i){var c;const a=t;if(!a||!OE(a,i))return;(c=i.mapSetPlugin_)==null||c.fixSetContents(a);const o=k4(a);ZY(e,a.draft_??a,o,n),JY(a,i)})}function JY(e,t){var r;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((r=e.assigned_)==null?void 0:r.size)??0)>0)){const{patchPlugin_:i}=t;if(i){const a=i.getPath(e);a&&i.generatePatches_(e,a,t)}QY(e)}}function yAe(e,t,n){const{scope_:r}=e;if($d(n)){const i=n[Yo];OE(i,r)&&i.callbacks_.push(function(){jw(e);const o=k4(i);ZY(e,n,o,t)})}else $c(n)&&e.callbacks_.push(function(){const a=Ad(e);e.type_===3?a.has(n)&&B2(n,r.handledSet_,r):lI(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&B2(lI(e.copy_,t,e.type_),r.handledSet_,r)})}function B2(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||$d(e)||t.has(e)||!$c(e)||TE(e)||(t.add(e),kE(e,(r,i)=>{if($d(i)){const a=i[Yo];if(OE(a,n)){const o=k4(a);L2(e,r,o,e.type_),QY(a)}}else $c(i)&&B2(i,t,n)})),e}function bAe(e,t){const n=CE(e),r={type_:n?1:0,scope_:t?t.scope_:XY(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=z2;n&&(i=[r],a=sy);const{revoke:o,proxy:c}=Proxy.revocable(i,a);return r.draft_=c,r.revoke_=o,[c,r]}var z2={get(e,t){if(t===Yo)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t=="string";if(r&&n!=null&&n.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=Ad(e);if(!H7(i,t,e.type_))return vAe(e,i,t);const a=i[t];if(e.finalized_||!$c(a)||r&&e.operationMethod&&(n!=null&&n.isMutatingArrayMethod(e.operationMethod))&&dAe(t))return a;if(a===T5(e.base_,t)){jw(e);const o=e.type_===1?+t:t,c=pI(e.scope_,a,e,o);return e.copy_[o]=c}return a},has(e,t){return t in Ad(e)},ownKeys(e){return Reflect.ownKeys(Ad(e))},set(e,t,n){const r=eX(Ad(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=T5(Ad(e),t),a=i==null?void 0:i[Yo];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(uAe(n,i)&&(n!==void 0||H7(e.base_,t,e.type_)))return!0;jw(e),fI(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),yAe(e,t,n)),!0},deleteProperty(e,t){return jw(e),T5(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),fI(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Ad(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Iw]:!0,[oI]:e.type_!==1||t!=="length",[M2]:r[M2],[ry]:n[t]}},defineProperty(){Pc(11)},getPrototypeOf(e){return gg(e.base_)},setPrototypeOf(){Pc(12)}},sy={};for(let e in z2){let t=z2[e];sy[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}sy.deleteProperty=function(e,t){return sy.set.call(this,e,t,void 0)};sy.set=function(e,t,n){return z2.set.call(this,e[0],t,n,e[0])};function T5(e,t){const n=e[Yo];return(n?Ad(n):e)[t]}function vAe(e,t,n){var i;const r=eX(t,n);return r?ry in r?r[ry]:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function eX(e,t){if(!(t in e))return;let n=gg(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=gg(n)}}function fI(e){e.modified_||(e.modified_=!0,e.parent_&&fI(e.parent_))}function jw(e){e.copy_||(e.assigned_=new Map,e.copy_=cI(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var wAe=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(N0(n)&&!N0(r)){const o=r;r=n;const c=this;return function(f=o,...m){return c.produce(f,y=>r.call(this,y,...m))}}N0(r)||Pc(6),i!==void 0&&!N0(i)&&Pc(7);let a;if($c(n)){const o=K7(this),c=pI(o,n,void 0);let h=!0;try{a=r(c),h=!1}finally{h?dI(o):hI(o)}return W7(o,i),Y7(a,o)}else if(!n||!S4(n)){if(a=r(n),a===void 0&&(a=n),a===WY&&(a=void 0),this.autoFreeze_&&C4(a,!0),i){const o=[],c=[];sm(uI).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:c}),i(o,c)}return a}else Pc(1,n)},this.produceWithPatches=(n,r)=>{if(N0(n))return(c,...h)=>this.produceWithPatches(c,f=>n(f,...h));let i,a;return[this.produce(n,r,(c,h)=>{i=c,a=h}),i,a]},j5(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),j5(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),j5(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){$c(t)||Pc(8),$d(t)&&(t=lc(t));const n=K7(this),r=pI(n,t,void 0);return r[Yo].isManual_=!0,hI(n),r}finishDraft(t,n){const r=t&&t[Yo];(!r||!r.isManual_)&&Pc(9);const{scope_:i}=r;return W7(i,n),Y7(void 0,i)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,n){let r;for(r=n.length-1;r>=0;r--){const a=n[r];if(a.path.length===0&&a.op==="replace"){t=a.value;break}}r>-1&&(n=n.slice(r+1));const i=sm(uI).applyPatches_;return $d(t)?i(t,n):this.produce(t,a=>i(a,n))}};function pI(e,t,n,r){const[i,a]=IE(t)?sm(U2).proxyMap_(t,n):jE(t)?sm(U2).proxySet_(t,n):bAe(t,n);return((n==null?void 0:n.scope_)??XY()).drafts_.push(i),a.callbacks_=(n==null?void 0:n.callbacks_)??[],a.key_=r,n&&r!==void 0?xAe(n,a,r):a.callbacks_.push(function(h){var m;(m=h.mapSetPlugin_)==null||m.fixSetContents(a);const{patchPlugin_:f}=h;a.modified_&&f&&f.generatePatches_(a,[],h)}),i}function lc(e){return $d(e)||Pc(10,e),tX(e)}function tX(e){if(!$c(e)||TE(e))return e;const t=e[Yo];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=cI(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=cI(e,!0);return kE(n,(i,a)=>{L2(n,i,tX(a))},r),t&&(t.finalized_=!1),n}var NAe=new wAe,nX=NAe.produce;function rX(e){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,e):i(a)}var EAe=rX(),AAe=rX,_Ae=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?R2:R2.apply(null,arguments)};function Gl(e,t){function n(...r){if(t){let i=t(...r);if(!i)throw new Error(Fl(0));return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>qY(r)&&r.type===e,n}var iX=class u1 extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,u1.prototype)}static get[Symbol.species](){return u1}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new u1(...t[0].concat(this)):new u1(...t.concat(this))}};function Q7(e){return $c(e)?nX(e,()=>{}):e}function Mv(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function SAe(e){return typeof e=="boolean"}var kAe=()=>function(t){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=t??{};let o=new iX;return n&&(SAe(n)?o.push(EAe):o.push(AAe(n.extraArgument))),o},sX="RTK_autoBatch",ps=()=>e=>({payload:e,meta:{[sX]:!0}}),Z7=e=>t=>{setTimeout(t,e)},aX=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let i=!0,a=!1,o=!1;const c=new Set,h=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:Z7(10):e.type==="callback"?e.queueNotification:Z7(e.timeout),f=()=>{o=!1,a&&(a=!1,c.forEach(m=>m()))};return Object.assign({},r,{subscribe(m){const y=()=>i&&m(),w=r.subscribe(y);return c.add(m),()=>{w(),c.delete(m)}},dispatch(m){var y;try{return i=!((y=m==null?void 0:m.meta)!=null&&y[sX]),a=!i,a&&(o||(o=!0,h(f))),r.dispatch(m)}finally{i=!0}}})},CAe=e=>function(n){const{autoBatch:r=!0}=n??{};let i=new iX(e);return r&&i.push(aX(typeof r=="object"?r:void 0)),i};function IAe(e){const t=kAe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:o=void 0}=e||{};let c;if(typeof n=="function")c=n;else if(_4(n))c=GY(n);else throw new Error(Fl(1));let h;typeof r=="function"?h=r(t):h=t();let f=R2;i&&(f=_Ae({trace:!1,...typeof i=="object"&&i}));const m=lAe(...h),y=CAe(m);let w=typeof o=="function"?o(y):y();const A=f(...w);return HY(c,a,A)}function oX(e){const t={},n=[];let r;const i={addCase(a,o){const c=typeof a=="string"?a:a.type;if(!c)throw new Error(Fl(28));if(c in t)throw new Error(Fl(29));return t[c]=o,i},addAsyncThunk(a,o){return o.pending&&(t[a.pending.type]=o.pending),o.rejected&&(t[a.rejected.type]=o.rejected),o.fulfilled&&(t[a.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:a.settled,reducer:o.settled}),i},addMatcher(a,o){return n.push({matcher:a,reducer:o}),i},addDefaultCase(a){return r=a,i}};return e(i),[t,n,r]}function jAe(e){return typeof e=="function"}function TAe(e,t){let[n,r,i]=oX(t),a;if(jAe(e))a=()=>Q7(e());else{const c=Q7(e);a=()=>c}function o(c=a(),h){let f=[n[h.type],...r.filter(({matcher:m})=>m(h)).map(({reducer:m})=>m)];return f.filter(m=>!!m).length===0&&(f=[i]),f.reduce((m,y)=>{if(y)if($d(m)){const A=y(m,h);return A===void 0?m:A}else{if($c(m))return nX(m,w=>y(w,h));{const w=y(m,h);if(w===void 0){if(m===null)return m;throw Error("A case reducer on a non-draftable value must not return undefined")}return w}}return m},c)}return o.getInitialState=a,o}var OAe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",PAe=(e=21)=>{let t="",n=e;for(;n--;)t+=OAe[Math.random()*64|0];return t},RAe=Symbol.for("rtk-slice-createasyncthunk");function DAe(e,t){return`${e}/${t}`}function MAe({creators:e}={}){var n;const t=(n=e==null?void 0:e.asyncThunk)==null?void 0:n[RAe];return function(i){const{name:a,reducerPath:o=a}=i;if(!a)throw new Error(Fl(11));const c=(typeof i.reducers=="function"?i.reducers(UAe()):i.reducers)||{},h=Object.keys(c),f={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},m={addCase(q,Z){const K=typeof q=="string"?q:q.type;if(!K)throw new Error(Fl(12));if(K in f.sliceCaseReducersByType)throw new Error(Fl(13));return f.sliceCaseReducersByType[K]=Z,m},addMatcher(q,Z){return f.sliceMatchers.push({matcher:q,reducer:Z}),m},exposeAction(q,Z){return f.actionCreators[q]=Z,m},exposeCaseReducer(q,Z){return f.sliceCaseReducersByName[q]=Z,m}};h.forEach(q=>{const Z=c[q],K={reducerName:q,type:DAe(a,q),createNotation:typeof i.reducers=="function"};zAe(Z)?FAe(K,Z,m,t):BAe(K,Z,m)});function y(){const[q={},Z=[],K=void 0]=typeof i.extraReducers=="function"?oX(i.extraReducers):[i.extraReducers],z={...q,...f.sliceCaseReducersByType};return TAe(i.initialState,B=>{for(let V in z)B.addCase(V,z[V]);for(let V of f.sliceMatchers)B.addMatcher(V.matcher,V.reducer);for(let V of Z)B.addMatcher(V.matcher,V.reducer);K&&B.addDefaultCase(K)})}const w=q=>q,A=new Map,k=new WeakMap;let I;function T(q,Z){return I||(I=y()),I(q,Z)}function D(){return I||(I=y()),I.getInitialState()}function F(q,Z=!1){function K(B){let V=B[q];return typeof V>"u"&&Z&&(V=Mv(k,K,D)),V}function z(B=w){const V=Mv(A,Z,()=>new WeakMap);return Mv(V,B,()=>{const $={};for(const[Q,Y]of Object.entries(i.selectors??{}))$[Q]=LAe(Y,B,()=>Mv(k,B,D),Z);return $})}return{reducerPath:q,getSelectors:z,get selectors(){return z(K)},selectSlice:K}}const L={name:a,reducer:T,actions:f.actionCreators,caseReducers:f.sliceCaseReducersByName,getInitialState:D,...F(o),injectInto(q,{reducerPath:Z,...K}={}){const z=Z??o;return q.inject({reducerPath:z,reducer:T},K),{...L,...F(z,!0)}}};return L}}function LAe(e,t,n,r){function i(a,...o){let c=t(a);return typeof c>"u"&&r&&(c=n()),e(c,...o)}return i.unwrapped=e,i}var Io=MAe();function UAe(){function e(t,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...n}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function BAe({type:e,reducerName:t,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!VAe(r))throw new Error(Fl(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,o?Gl(e,o):Gl(e))}function zAe(e){return e._reducerDefinitionType==="asyncThunk"}function VAe(e){return e._reducerDefinitionType==="reducerWithPrepare"}function FAe({type:e,reducerName:t},n,r,i){if(!i)throw new Error(Fl(18));const{payloadCreator:a,fulfilled:o,pending:c,rejected:h,settled:f,options:m}=n,y=i(e,a,m);r.exposeAction(t,y),o&&r.addCase(y.fulfilled,o),c&&r.addCase(y.pending,c),h&&r.addCase(y.rejected,h),f&&r.addMatcher(y.settled,f),r.exposeCaseReducer(t,{fulfilled:o||Lv,pending:c||Lv,rejected:h||Lv,settled:f||Lv})}function Lv(){}var $Ae="task",lX="listener",cX="completed",I4="cancelled",HAe=`task-${I4}`,GAe=`task-${cX}`,mI=`${lX}-${I4}`,qAe=`${lX}-${cX}`,PE=class{constructor(e){yd(this,"name","TaskAbortError");yd(this,"message");this.code=e,this.message=`${$Ae} ${I4} (reason: ${e})`}},j4=(e,t)=>{if(typeof e!="function")throw new TypeError(Fl(32))},V2=()=>{},uX=(e,t=V2)=>(e.catch(t),e),dX=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),Lp=e=>{if(e.aborted)throw new PE(e.reason)};function hX(e,t){let n=V2;return new Promise((r,i)=>{const a=()=>i(new PE(e.reason));if(e.aborted){a();return}n=dX(e,a),t.finally(()=>n()).then(r,i)}).finally(()=>{n=V2})}var WAe=async(e,t)=>{try{return await Promise.resolve(),{status:"ok",value:await e()}}catch(n){return{status:n instanceof PE?"cancelled":"rejected",error:n}}finally{t==null||t()}},F2=e=>t=>uX(hX(e,t).then(n=>(Lp(e),n))),fX=e=>{const t=F2(e);return n=>t(new Promise(r=>setTimeout(r,n)))},{assign:V0}=Object,J7={},RE="listenerMiddleware",KAe=(e,t)=>{const n=r=>dX(e,()=>r.abort(e.reason));return(r,i)=>{j4(r);const a=new AbortController;n(a);const o=WAe(async()=>{Lp(e),Lp(a.signal);const c=await r({pause:F2(a.signal),delay:fX(a.signal),signal:a.signal});return Lp(a.signal),c},()=>a.abort(GAe));return i!=null&&i.autoJoin&&t.push(o.catch(V2)),{result:F2(e)(o),cancel(){a.abort(HAe)}}}},YAe=(e,t)=>{const n=async(r,i)=>{Lp(t);let a=()=>{};const c=[new Promise((h,f)=>{let m=e({predicate:r,effect:(y,w)=>{w.unsubscribe(),h([y,w.getState(),w.getOriginalState()])}});a=()=>{m(),f()}})];i!=null&&c.push(new Promise(h=>setTimeout(h,i,null)));try{const h=await hX(t,Promise.race(c));return Lp(t),h}finally{a()}};return(r,i)=>uX(n(r,i))},pX=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:a}=e;if(t)i=Gl(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Fl(21));return j4(a),{predicate:i,type:t,effect:a}},mX=V0(e=>{const{type:t,predicate:n,effect:r}=pX(e);return{id:PAe(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Fl(22))}}},{withTypes:()=>mX}),eU=(e,t)=>{const{type:n,effect:r,predicate:i}=pX(t);return Array.from(e.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},gI=e=>{e.pending.forEach(t=>{t.abort(mI)})},XAe=(e,t)=>()=>{for(const n of t.keys())gI(n);e.clear()},tU=(e,t,n)=>{try{e(t,n)}catch(r){setTimeout(()=>{throw r},0)}},gX=V0(Gl(`${RE}/add`),{withTypes:()=>gX}),QAe=Gl(`${RE}/removeAll`),xX=V0(Gl(`${RE}/remove`),{withTypes:()=>xX}),ZAe=(...e)=>{console.error(`${RE}/error`,...e)},Gy=(e={})=>{const t=new Map,n=new Map,r=A=>{const k=n.get(A)??0;n.set(A,k+1)},i=A=>{const k=n.get(A)??1;k===1?n.delete(A):n.set(A,k-1)},{extra:a,onError:o=ZAe}=e;j4(o);const c=A=>(A.unsubscribe=()=>t.delete(A.id),t.set(A.id,A),k=>{A.unsubscribe(),k!=null&&k.cancelActive&&gI(A)}),h=A=>{const k=eU(t,A)??mX(A);return c(k)};V0(h,{withTypes:()=>h});const f=A=>{const k=eU(t,A);return k&&(k.unsubscribe(),A.cancelActive&&gI(k)),!!k};V0(f,{withTypes:()=>f});const m=async(A,k,I,T)=>{const D=new AbortController,F=YAe(h,D.signal),L=[];try{A.pending.add(D),r(A),await Promise.resolve(A.effect(k,V0({},I,{getOriginalState:T,condition:(q,Z)=>F(q,Z).then(Boolean),take:F,delay:fX(D.signal),pause:F2(D.signal),extra:a,signal:D.signal,fork:KAe(D.signal,L),unsubscribe:A.unsubscribe,subscribe:()=>{t.set(A.id,A)},cancelActiveListeners:()=>{A.pending.forEach((q,Z,K)=>{q!==D&&(q.abort(mI),K.delete(q))})},cancel:()=>{D.abort(mI),A.pending.delete(D)},throwIfCancelled:()=>{Lp(D.signal)}})))}catch(q){q instanceof PE||tU(o,q,{raisedBy:"effect"})}finally{await Promise.all(L),D.abort(qAe),i(A),A.pending.delete(D)}},y=XAe(t,n);return{middleware:A=>k=>I=>{if(!qY(I))return k(I);if(gX.match(I))return h(I.payload);if(QAe.match(I)){y();return}if(xX.match(I))return f(I.payload);let T=A.getState();const D=()=>{if(T===J7)throw new Error(Fl(23));return T};let F;try{if(F=k(I),t.size>0){const L=A.getState(),q=Array.from(t.values());for(const Z of q){let K=!1;try{K=Z.predicate(I,L,T)}catch(z){K=!1,tU(o,z,{raisedBy:"predicate"})}K&&m(Z,I,A,D)}}}finally{T=J7}return F},startListening:h,stopListening:f,clearListeners:y}};function Fl(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var JAe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},yX=Io({name:"chartLayout",initialState:JAe,reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){var n,r,i,a;e.margin.top=(n=t.payload.top)!==null&&n!==void 0?n:0,e.margin.right=(r=t.payload.right)!==null&&r!==void 0?r:0,e.margin.bottom=(i=t.payload.bottom)!==null&&i!==void 0?i:0,e.margin.left=(a=t.payload.left)!==null&&a!==void 0?a:0},setScale(e,t){e.scale=t.payload}}}),{setMargin:e_e,setLayout:t_e,setChartSize:n_e,setScale:r_e}=yX.actions,i_e=yX.reducer;function bX(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function qr(e){return Number.isFinite(e)}function Bu(e){return typeof e=="number"&&e>0&&Number.isFinite(e)}function nU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function I0(e){for(var t=1;t{if(t&&n){var{width:r,height:i}=n,{align:a,verticalAlign:o,layout:c}=t;if((c==="vertical"||c==="horizontal"&&o==="middle")&&a!=="center"&&En(e[a]))return I0(I0({},e),{},{[a]:e[a]+(r||0)});if((c==="horizontal"||c==="vertical"&&a==="center")&&o!=="middle"&&En(e[o]))return I0(I0({},e),{},{[o]:e[o]+(i||0)})}return e},Gc=(e,t)=>e==="horizontal"&&t==="xAxis"||e==="vertical"&&t==="yAxis"||e==="centric"&&t==="angleAxis"||e==="radial"&&t==="radiusAxis",vX=(e,t,n,r)=>{if(r)return e.map(c=>c.coordinate);var i,a,o=e.map(c=>(c.coordinate===t&&(i=!0),c.coordinate===n&&(a=!0),c.coordinate));return i||o.push(t),a||o.push(n),o},wX=(e,t,n)=>{if(!e)return null;var{duplicateDomain:r,type:i,range:a,scale:o,realScaleType:c,isCategorical:h,categoricalDomain:f,tickCount:m,ticks:y,niceTicks:w,axisType:A}=e;if(!o)return null;var k=c==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,I=i==="category"&&o.bandwidth?o.bandwidth()/k:0;if(I=A==="angleAxis"&&a&&a.length>=2?xl(a[0]-a[1])*2*I:I,y||w){var T=(y||w||[]).map((D,F)=>{var L=r?r.indexOf(D):D,q=o.map(L);return qr(q)?{coordinate:q+I,value:D,offset:I,index:F}:null}).filter(yl);return T}return h&&f?f.map((D,F)=>{var L=o.map(D);return qr(L)?{coordinate:L+I,value:D,index:F,offset:I}:null}).filter(yl):o.ticks&&m!=null?o.ticks(m).map((D,F)=>{var L=o.map(D);return qr(L)?{coordinate:L+I,value:D,index:F,offset:I}:null}).filter(yl):o.domain().map((D,F)=>{var L=o.map(D);return qr(L)?{coordinate:L+I,value:r?r[D]:D,index:F,offset:I}:null}).filter(yl)},c_e=(e,t)=>{if(!t||t.length!==2||!En(t[0])||!En(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),i=[e[0],e[1]];return(!En(e[0])||e[0]r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]{var t,n=e.length;if(!(n<=0)){var r=(t=e[0])===null||t===void 0?void 0:t.length;if(!(r==null||r<=0))for(var i=0;i=0?(f[0]=a,a+=w,f[1]=a):(f[0]=o,o+=w,f[1]=o)}}}},d_e=e=>{var t,n=e.length;if(!(n<=0)){var r=(t=e[0])===null||t===void 0?void 0:t.length;if(!(r==null||r<=0))for(var i=0;i=0?(h[0]=a,a+=f,h[1]=a):(h[0]=0,h[1]=0)}}}},h_e={sign:u_e,expand:ONe,none:rm,silhouette:PNe,wiggle:RNe,positive:d_e},f_e=(e,t,n)=>{var r,i=(r=h_e[n])!==null&&r!==void 0?r:rm,a=TNe().keys(t).value((c,h)=>Number(Ds(c,h,0))).order(sI).offset(i),o=a(e);return o.forEach((c,h)=>{c.forEach((f,m)=>{var y=Ds(e[m],t[h],0);Array.isArray(y)&&y.length===2&&En(y[0])&&En(y[1])&&(f[0]=y[0],f[1]=y[1])})}),o};function NX(e){return e==null?void 0:String(e)}function $2(e){var{axis:t,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=e;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!xs(i[t.dataKey])){var c=_Y(n,"value",i[t.dataKey]);if(c)return c.coordinate+r/2}return n!=null&&n[a]?n[a].coordinate+r/2:null}var h=Ds(i,xs(o)?t.dataKey:o),f=t.scale.map(h);return En(f)?f:null}var rU=e=>{var{axis:t,ticks:n,offset:r,bandSize:i,entry:a,index:o}=e;if(t.type==="category")return n[o]?n[o].coordinate+r:null;var c=Ds(a,t.dataKey,t.scale.domain()[o]);if(xs(c))return null;var h=t.scale.map(c);return En(h)?h-i/2+r:null},p_e=e=>{var{numericAxis:t}=e,n=t.scale.domain();if(t.type==="number"){var r=Math.min(n[0],n[1]),i=Math.max(n[0],n[1]);return r<=0&&i>=0?0:i<0?i:r}return n[0]},m_e=e=>{var t=e.flat(2).filter(En);return[Math.min(...t),Math.max(...t)]},g_e=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],x_e=(e,t,n)=>{if(e!=null)return g_e(Object.keys(e).reduce((r,i)=>{var a=e[i];if(!a)return r;var{stackedData:o}=a,c=o.reduce((h,f)=>{var m=bX(f,t,n),y=m_e(m);return!qr(y[0])||!qr(y[1])?h:[Math.min(h[0],y[0]),Math.max(h[1],y[1])]},[1/0,-1/0]);return[Math.min(c[0],r[0]),Math.max(c[1],r[1])]},[1/0,-1/0]))},iU=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,sU=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,yf=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var i=_E(t,m=>m.coordinate),a=1/0,o=1,c=i.length;o{if(t==="horizontal")return e.relativeX;if(t==="vertical")return e.relativeY},b_e=(e,t)=>t==="centric"?e.angle:e.radius,Qd=e=>e.layout.width,Zd=e=>e.layout.height,v_e=e=>e.layout.scale,EX=e=>e.layout.margin,DE=et(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),ME=et(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),w_e="data-recharts-item-index",N_e="data-recharts-item-id",qy=60;function oU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Uv(e){for(var t=1;te.brush.height;function k_e(e){var t=ME(e);return t.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:qy;return n+i}return n},0)}function C_e(e){var t=ME(e);return t.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:qy;return n+i}return n},0)}function I_e(e){var t=DE(e);return t.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function j_e(e){var t=DE(e);return t.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var $a=et([Qd,Zd,EX,S_e,k_e,C_e,I_e,j_e,FY,tAe],(e,t,n,r,i,a,o,c,h,f)=>{var m={left:(n.left||0)+i,right:(n.right||0)+a},y={top:(n.top||0)+o,bottom:(n.bottom||0)+c},w=Uv(Uv({},y),m),A=w.bottom;w.bottom+=r,w=l_e(w,h,f);var k=e-w.left-w.right,I=t-w.top-w.bottom;return Uv(Uv({brushBottom:A},w),{},{width:Math.max(k,0),height:Math.max(I,0)})}),T_e=et($a,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),T4=et(Qd,Zd,(e,t)=>({x:0,y:0,width:e,height:t})),O_e=j.createContext(null),Ha=()=>j.useContext(O_e)!=null,LE=e=>e.brush,UE=et([LE,$a,EX],(e,t,n)=>({height:e.height,x:En(e.x)?e.x:t.left,y:En(e.y)?e.y:t.top+t.height+t.brushBottom-((n==null?void 0:n.bottom)||0),width:En(e.width)?e.width:t.width})),O5={},P5={},R5={},lU;function P_e(){return lU||(lU=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r,{signal:i,edges:a}={}){let o,c=null;const h=a!=null&&a.includes("leading"),f=a==null||a.includes("trailing"),m=()=>{c!==null&&(n.apply(o,c),o=void 0,c=null)},y=()=>{f&&m(),I()};let w=null;const A=()=>{w!=null&&clearTimeout(w),w=setTimeout(()=>{w=null,y()},r)},k=()=>{w!==null&&(clearTimeout(w),w=null)},I=()=>{k(),o=void 0,c=null},T=()=>{m()},D=function(...F){if(i!=null&&i.aborted)return;o=this,c=F;const L=w==null;A(),h&&L&&m()};return D.schedule=A,D.cancel=I,D.flush=T,i==null||i.addEventListener("abort",I,{once:!0}),D}e.debounce=t})(R5)),R5}var cU;function R_e(){return cU||(cU=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=P_e();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:o=!1,trailing:c=!0,maxWait:h}=a,f=Array(2);o&&(f[0]="leading"),c&&(f[1]="trailing");let m,y=null;const w=t.debounce(function(...I){m=r.apply(this,I),y=null},i,{edges:f}),A=function(...I){return h!=null&&(y===null&&(y=Date.now()),Date.now()-y>=h)?(m=r.apply(this,I),y=Date.now(),w.cancel(),w.schedule(),m):(w.apply(this,I),m)},k=()=>(w.flush(),m);return A.cancel=w.cancel,A.flush=k,A}e.debounce=n})(P5)),P5}var uU;function D_e(){return uU||(uU=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=R_e();function n(r,i=0,a={}){const{leading:o=!0,trailing:c=!0}=a;return t.debounce(r,i,{leading:o,maxWait:i,trailing:c})}e.throttle=n})(O5)),O5}var D5,dU;function M_e(){return dU||(dU=1,D5=D_e().throttle),D5}var L_e=M_e();const U_e=Hu(L_e);var H2=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;ai[o++]))}},Au={width:"100%",height:"100%",debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},AX=(e,t,n)=>{var{width:r=Au.width,height:i=Au.height,aspect:a,maxHeight:o}=n,c=im(r)?e:Number(r),h=im(i)?t:Number(i);return a&&a>0&&(c?h=c/a:h&&(c=h*a),o&&h!=null&&h>o&&(h=o)),{calculatedWidth:c,calculatedHeight:h}},B_e={width:0,height:0,overflow:"visible"},z_e={width:0,overflowX:"visible"},V_e={height:0,overflowY:"visible"},F_e={},$_e=e=>{var{width:t,height:n}=e,r=im(t),i=im(n);return r&&i?B_e:r?z_e:i?V_e:F_e};function H_e(e){var{width:t,height:n,aspect:r}=e,i=t,a=n;return i===void 0&&a===void 0?(i=Au.width,a=Au.height):i===void 0?i=r&&r>0?void 0:Au.width:a===void 0&&(a=r&&r>0?void 0:Au.height),{width:i,height:a}}function xI(){return xI=Object.assign?Object.assign.bind():function(e){for(var t=1;t({width:n,height:r}),[n,r]);return K_e(i)?j.createElement(_X.Provider,{value:i},t):null}var O4=()=>j.useContext(_X),Y_e=j.forwardRef((e,t)=>{var{aspect:n,initialDimension:r=Au.initialDimension,width:i,height:a,minWidth:o=Au.minWidth,minHeight:c,maxHeight:h,children:f,debounce:m=Au.debounce,id:y,className:w,onResize:A,style:k={}}=e,I=j.useRef(null),T=j.useRef();T.current=A,j.useImperativeHandle(t,()=>I.current);var[D,F]=j.useState({containerWidth:r.width,containerHeight:r.height}),L=j.useCallback((B,V)=>{F($=>{var Q=Math.round(B),Y=Math.round(V);return $.containerWidth===Q&&$.containerHeight===Y?$:{containerWidth:Q,containerHeight:Y}})},[]);j.useEffect(()=>{if(I.current==null||typeof ResizeObserver>"u")return jf;var B=Y=>{var G,he=Y[0];if(he!=null){var{width:te,height:le}=he.contentRect;L(te,le),(G=T.current)===null||G===void 0||G.call(T,te,le)}};m>0&&(B=U_e(B,m,{trailing:!0,leading:!1}));var V=new ResizeObserver(B),{width:$,height:Q}=I.current.getBoundingClientRect();return L($,Q),V.observe(I.current),()=>{V.disconnect()}},[L,m]);var{containerWidth:q,containerHeight:Z}=D;H2(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:K,calculatedHeight:z}=AX(q,Z,{width:i,height:a,aspect:n,maxHeight:h});return H2(K!=null&&K>0||z!=null&&z>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the height and width.`,K,z,i,a,o,c,n),j.createElement("div",{id:y?"".concat(y):void 0,className:Di("recharts-responsive-container",w),style:fU(fU({},k),{},{width:i,height:a,minWidth:o,minHeight:c,maxHeight:h}),ref:I},j.createElement("div",{style:$_e({width:i,height:a})},j.createElement(SX,{width:K,height:z},f)))}),X_e=j.forwardRef((e,t)=>{var n=O4();if(Bu(n.width)&&Bu(n.height))return e.children;var{width:r,height:i}=H_e({width:e.width,height:e.height,aspect:e.aspect}),{calculatedWidth:a,calculatedHeight:o}=AX(void 0,void 0,{width:r,height:i,aspect:e.aspect,maxHeight:e.maxHeight});return En(a)&&En(o)?j.createElement(SX,{width:a,height:o},e.children):j.createElement(Y_e,xI({},e,{width:r,height:i,ref:t}))});function P4(e){if(e)return{x:e.x,y:e.y,upperWidth:"upperWidth"in e?e.upperWidth:e.width,lowerWidth:"lowerWidth"in e?e.lowerWidth:e.width,width:e.width,height:e.height}}var BE=()=>{var e,t=Ha(),n=Qn(T_e),r=Qn(UE),i=(e=Qn(LE))===null||e===void 0?void 0:e.padding;return!t||!r||!i?n:{width:r.width-i.left-i.right,height:r.height-i.top-i.bottom,x:i.left,y:i.top}},Q_e={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},kX=()=>{var e;return(e=Qn($a))!==null&&e!==void 0?e:Q_e},R4=()=>Qn(Qd),D4=()=>Qn(Zd),Z_e=()=>Qn(e=>e.layout.margin),_i=e=>e.layout.layoutType,Tf=()=>Qn(_i),M4=()=>{var e=Tf();if(e==="horizontal"||e==="vertical")return e},CX=e=>{var t=e.layout.layoutType;if(t==="centric"||t==="radial")return t},J_e=()=>{var e=Tf();return e!==void 0},Wy=e=>{var t=ys(),n=Ha(),{width:r,height:i}=e,a=O4(),o=r,c=i;return a&&(o=a.width>0?a.width:r,c=a.height>0?a.height:i),j.useEffect(()=>{!n&&Bu(o)&&Bu(c)&&t(n_e({width:o,height:c}))},[t,n,o,c]),null},IX=Symbol.for("immer-nothing"),pU=Symbol.for("immer-draftable"),ql=Symbol.for("immer-state");function Rc(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ay=Object.getPrototypeOf;function xg(e){return!!e&&!!e[ql]}function am(e){var t;return e?jX(e)||Array.isArray(e)||!!e[pU]||!!((t=e.constructor)!=null&&t[pU])||Ky(e)||VE(e):!1}var eSe=Object.prototype.constructor.toString(),mU=new WeakMap;function jX(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=mU.get(n);return r===void 0&&(r=Function.toString.call(n),mU.set(n,r)),r===eSe}function G2(e,t,n=!0){zE(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function zE(e){const t=e[ql];return t?t.type_:Array.isArray(e)?1:Ky(e)?2:VE(e)?3:0}function yI(e,t){return zE(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function TX(e,t,n){const r=zE(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function tSe(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Ky(e){return e instanceof Map}function VE(e){return e instanceof Set}function up(e){return e.copy_||e.base_}function bI(e,t){if(Ky(e))return new Map(e);if(VE(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=jX(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[ql];let i=Reflect.ownKeys(r);for(let a=0;a1&&Object.defineProperties(e,{set:Bv,add:Bv,clear:Bv,delete:Bv}),Object.freeze(e),t&&Object.values(e).forEach(n=>L4(n,!0))),e}function nSe(){Rc(2)}var Bv={value:nSe};function FE(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var rSe={};function om(e){const t=rSe[e];return t||Rc(0,e),t}var oy;function OX(){return oy}function iSe(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function gU(e,t){t&&(om("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function vI(e){wI(e),e.drafts_.forEach(sSe),e.drafts_=null}function wI(e){e===oy&&(oy=e.parent_)}function xU(e){return oy=iSe(oy,e)}function sSe(e){const t=e[ql];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function yU(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[ql].modified_&&(vI(t),Rc(4)),am(e)&&(e=q2(t,e),t.parent_||W2(t,e)),t.patches_&&om("Patches").generateReplacementPatches_(n[ql].base_,e,t.patches_,t.inversePatches_)):e=q2(t,n,[]),vI(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==IX?e:void 0}function q2(e,t,n){if(FE(t))return t;const r=e.immer_.shouldUseStrictIteration(),i=t[ql];if(!i)return G2(t,(a,o)=>bU(e,i,t,a,o,n),r),t;if(i.scope_!==e)return t;if(!i.modified_)return W2(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let o=a,c=!1;i.type_===3&&(o=new Set(a),a.clear(),c=!0),G2(o,(h,f)=>bU(e,i,a,h,f,n,c),r),W2(e,a,!1),n&&e.patches_&&om("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function bU(e,t,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const c=FE(i);if(!(c&&!o)){if(xg(i)){const h=a&&t&&t.type_!==3&&!yI(t.assigned_,r)?a.concat(r):void 0,f=q2(e,i,h);if(TX(n,r,f),xg(f))e.canAutoFreeze_=!1;else return}else o&&n.add(i);if(am(i)&&!c){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===i&&c)return;q2(e,i),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&(Ky(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&W2(e,i)}}}function W2(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&L4(t,n)}function aSe(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:OX(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=U4;n&&(i=[r],a=ly);const{revoke:o,proxy:c}=Proxy.revocable(i,a);return r.draft_=c,r.revoke_=o,c}var U4={get(e,t){if(t===ql)return e;const n=up(e);if(!yI(n,t))return oSe(e,n,t);const r=n[t];return e.finalized_||!am(r)?r:r===M5(e.base_,t)?(L5(e),e.copy_[t]=EI(r,e)):r},has(e,t){return t in up(e)},ownKeys(e){return Reflect.ownKeys(up(e))},set(e,t,n){const r=PX(up(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=M5(up(e),t),a=i==null?void 0:i[ql];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(tSe(n,i)&&(n!==void 0||yI(e.base_,t)))return!0;L5(e),NI(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return M5(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,L5(e),NI(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=up(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){Rc(11)},getPrototypeOf(e){return ay(e.base_)},setPrototypeOf(){Rc(12)}},ly={};G2(U4,(e,t)=>{ly[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});ly.deleteProperty=function(e,t){return ly.set.call(this,e,t,void 0)};ly.set=function(e,t,n){return U4.set.call(this,e[0],t,n,e[0])};function M5(e,t){const n=e[ql];return(n?up(n):e)[t]}function oSe(e,t,n){var i;const r=PX(t,n);return r?"value"in r?r.value:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function PX(e,t){if(!(t in e))return;let n=ay(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=ay(n)}}function NI(e){e.modified_||(e.modified_=!0,e.parent_&&NI(e.parent_))}function L5(e){e.copy_||(e.copy_=bI(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var lSe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const a=n;n=t;const o=this;return function(h=a,...f){return o.produce(h,m=>n.call(this,m,...f))}}typeof n!="function"&&Rc(6),r!==void 0&&typeof r!="function"&&Rc(7);let i;if(am(t)){const a=xU(this),o=EI(t,void 0);let c=!0;try{i=n(o),c=!1}finally{c?vI(a):wI(a)}return gU(a,r),yU(i,a)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===IX&&(i=void 0),this.autoFreeze_&&L4(i,!0),r){const a=[],o=[];om("Patches").generateReplacementPatches_(t,i,a,o),r(a,o)}return i}else Rc(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(o,...c)=>this.produceWithPatches(o,h=>t(h,...c));let r,i;return[this.produce(t,n,(o,c)=>{r=o,i=c}),r,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){am(e)||Rc(8),xg(e)&&(e=cSe(e));const t=xU(this),n=EI(e,void 0);return n[ql].isManual_=!0,wI(t),n}finishDraft(e,t){const n=e&&e[ql];(!n||!n.isManual_)&&Rc(9);const{scope_:r}=n;return gU(r,t),yU(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=om("Patches").applyPatches_;return xg(e)?r(e,t):this.produce(e,i=>r(i,t))}};function EI(e,t){const n=Ky(e)?om("MapSet").proxyMap_(e,t):VE(e)?om("MapSet").proxySet_(e,t):aSe(e,t);return(t?t.scope_:OX()).drafts_.push(n),n}function cSe(e){return xg(e)||Rc(10,e),RX(e)}function RX(e){if(!am(e)||FE(e))return e;const t=e[ql];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=bI(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=bI(e,!0);return G2(n,(i,a)=>{TX(n,i,RX(a))},r),t&&(t.finalized_=!1),n}var uSe=new lSe;uSe.produce;var dSe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},DX=Io({name:"legend",initialState:dSe,reducers:{setLegendSize(e,t){e.size.width=t.payload.width,e.size.height=t.payload.height},setLegendSettings(e,t){e.settings.align=t.payload.align,e.settings.layout=t.payload.layout,e.settings.verticalAlign=t.payload.verticalAlign,e.settings.itemSorter=t.payload.itemSorter},addLegendPayload:{reducer(e,t){e.payload.push(t.payload)},prepare:ps()},replaceLegendPayload:{reducer(e,t){var{prev:n,next:r}=t.payload,i=lc(e).payload.indexOf(n);i>-1&&(e.payload[i]=r)},prepare:ps()},removeLegendPayload:{reducer(e,t){var n=lc(e).payload.indexOf(t.payload);n>-1&&e.payload.splice(n,1)},prepare:ps()}}}),{setLegendSize:vU,setLegendSettings:hSe,addLegendPayload:fSe,replaceLegendPayload:pSe,removeLegendPayload:mSe}=DX.actions,gSe=DX.reducer,U5={exports:{}},B5={};/** * @license React * use-sync-external-store-with-selector.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var wU;function xSe(){if(wU)return B5;wU=1;var e=Ag();function t(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,i=e.useRef,a=e.useEffect,o=e.useMemo,c=e.useDebugValue;return B5.useSyncExternalStoreWithSelector=function(h,f,m,y,w){var A=i(null);if(A.current===null){var k={hasValue:!1,value:null};A.current=k}else k=A.current;A=o(function(){function T(Z){if(!D){if(D=!0,F=Z,Z=y(Z),w!==void 0&&k.hasValue){var K=k.value;if(w(K,Z))return L=K}return L=Z}if(K=L,n(F,Z))return K;var z=y(Z);return w!==void 0&&w(K,z)?(F=Z,K):(F=Z,L=z)}var D=!1,F,L,q=m===void 0?null:m;return[function(){return T(f())},q===null?void 0:function(){return T(q())}]},[f,m,y,w]);var I=r(h,A[0],A[1]);return a(function(){k.hasValue=!0,k.value=I},[I]),c(I),I},B5}var NU;function ySe(){return NU||(NU=1,U5.exports=xSe()),U5.exports}ySe();function bSe(e){e()}function vSe(){let e=null,t=null;return{clear(){e=null,t=null},notify(){bSe(()=>{let n=e;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=e;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const i=t={callback:n,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!r||e===null||(r=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var EU={notify(){},get:()=>[]};function wSe(e,t){let n,r=EU,i=0,a=!1;function o(I){m();const T=r.subscribe(I);let D=!1;return()=>{D||(D=!0,T(),y())}}function c(){r.notify()}function h(){k.onStateChange&&k.onStateChange()}function f(){return a}function m(){i++,n||(n=e.subscribe(h),r=vSe())}function y(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=EU)}function w(){a||(a=!0,m())}function A(){a&&(a=!1,y())}const k={addNestedSub:o,notifyNestedSubs:c,handleChangeWrapper:h,isSubscribed:f,trySubscribe:w,tryUnsubscribe:A,getListeners:()=>r};return k}var NSe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ESe=NSe(),ASe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",_Se=ASe(),SSe=()=>ESe||_Se?j.useLayoutEffect:j.useEffect,kSe=SSe();function AU(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function CSe(e,t){if(AU(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i=0;i{const h=wSe(i);return{store:i,subscription:h,getServerState:r?()=>r:void 0}},[i,r]),o=j.useMemo(()=>i.getState(),[i]);kSe(()=>{const{subscription:h}=a;return h.onStateChange=h.notifyNestedSubs,h.trySubscribe(),o!==i.getState()&&h.notifyNestedSubs(),()=>{h.tryUnsubscribe(),h.onStateChange=void 0}},[a,o]);const c=n||jSe;return j.createElement(c.Provider,{value:a},t)}var OSe=TSe,PSe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle","radius","throttledEvents"]);function RSe(e,t){return e==null&&t==null?!0:typeof e=="number"&&typeof t=="number"?e===t||e!==e&&t!==t:e===t}function ym(e,t){var n=new Set([...Object.keys(e),...Object.keys(t)]);for(var r of n)if(PSe.has(r)){if(e[r]==null&&t[r]==null)continue;if(!CSe(e[r],t[r]))return!1}else if(!RSe(e[r],t[r]))return!1;return!0}var DSe=["contextPayload"];function AI(){return AI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{t(hSe(e))},[t,e]),null}function GSe(e){var t=ys();return j.useEffect(()=>(t(vU(e)),()=>{t(vU({width:0,height:0}))}),[t,e]),null}function qSe(e,t,n,r){return e==="vertical"&&t!=null?{height:t}:e==="horizontal"?{width:n||r}:null}var WSe={align:"center",iconSize:14,inactiveColor:"#ccc",itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function KSe(e){var t=Fa(e,WSe),n=iAe(),r=tNe(),i=Z_e(),{width:a,height:o,wrapperStyle:c,portal:h}=t,[f,m]=$Y([n]),y=R4(),w=D4();if(y==null||w==null)return null;var A=y-((i==null?void 0:i.left)||0)-((i==null?void 0:i.right)||0),k=qSe(t.layout,o,a,A),I=h?c:yg(yg({position:"absolute",width:(k==null?void 0:k.width)||a||"auto",height:(k==null?void 0:k.height)||o||"auto"},$Se(c,t,i,y,w,f)),c),T=h??r;if(T==null||n==null)return null;var D=j.createElement("div",{className:"recharts-legend-wrapper",style:I,ref:m},j.createElement(HSe,{layout:t.layout,align:t.align,verticalAlign:t.verticalAlign,itemSorter:t.itemSorter}),!h&&j.createElement(GSe,{width:f.width,height:f.height}),j.createElement(FSe,AI({},t,k,{margin:i,chartWidth:y,chartHeight:w,contextPayload:n})));return CN.createPortal(D,T)}var MX=j.memo(KSe,ym);MX.displayName="Legend";function _I(){return _I=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{separator:t=c0.separator,contentStyle:n,itemStyle:r,labelStyle:i=c0.labelStyle,payload:a,formatter:o,itemSorter:c,wrapperClassName:h,labelClassName:f,label:m,labelFormatter:y,accessibilityLayer:w=c0.accessibilityLayer}=e,A=()=>{if(a&&a.length){var Z={padding:0,margin:0},K=JSe(a,c),z=K.map((B,V)=>{if(!B||B.type==="none")return null;var $=B.formatter||o||ZSe,{value:Q,name:Y}=B,G=Q,he=Y;if($){var te=$(Q,Y,B,V,a);if(Array.isArray(te))[G,he]=te;else if(te!=null)G=te;else return null}var le=Fx(Fx({},c0.itemStyle),{},{color:B.color||c0.itemStyle.color},r);return j.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(V),style:le},Uu(he)?j.createElement("span",{className:"recharts-tooltip-item-name"},he):null,Uu(he)?j.createElement("span",{className:"recharts-tooltip-item-separator"},t):null,j.createElement("span",{className:"recharts-tooltip-item-value"},G),j.createElement("span",{className:"recharts-tooltip-item-unit"},B.unit||""))});return j.createElement("ul",{className:"recharts-tooltip-item-list",style:Z},z)}return null},k=Fx(Fx({},c0.contentStyle),n),I=Fx({margin:0},i),T=!xs(m),D=T?m:"",F=Di("recharts-default-tooltip",h),L=Di("recharts-tooltip-label",f);T&&y&&a!==void 0&&a!==null&&(D=y(m,a));var q=w?{role:"status","aria-live":"assertive"}:{};return j.createElement("div",_I({className:F,style:k},q),j.createElement("p",{className:L,style:I},j.isValidElement(D)?D:"".concat(D)),A())},$x="recharts-tooltip-wrapper",t5e={visibility:"hidden"};function n5e(e){var{coordinate:t,translateX:n,translateY:r}=e;return Di($x,{["".concat($x,"-right")]:En(n)&&t&&En(t.x)&&n>=t.x,["".concat($x,"-left")]:En(n)&&t&&En(t.x)&&n=t.y,["".concat($x,"-top")]:En(r)&&t&&En(t.y)&&r0?i:0),y=n[r]+i;if(t[r])return o[r]?m:y;var w=h[r];if(w==null)return 0;if(o[r]){var A=m,k=w;return AT?Math.max(m,w):Math.max(y,w)}function r5e(e){var{translateX:t,translateY:n,useTranslate3d:r}=e;return{transform:r?"translate3d(".concat(t,"px, ").concat(n,"px, 0)"):"translate(".concat(t,"px, ").concat(n,"px)")}}function i5e(e){var{allowEscapeViewBox:t,coordinate:n,offsetTop:r,offsetLeft:i,position:a,reverseDirection:o,tooltipBox:c,useTranslate3d:h,viewBox:f}=e,m,y,w;return c.height>0&&c.width>0&&n?(y=kU({allowEscapeViewBox:t,coordinate:n,key:"x",offset:i,position:a,reverseDirection:o,tooltipDimension:c.width,viewBox:f,viewBoxDimension:f.width}),w=kU({allowEscapeViewBox:t,coordinate:n,key:"y",offset:r,position:a,reverseDirection:o,tooltipDimension:c.height,viewBox:f,viewBoxDimension:f.height}),m=r5e({translateX:y,translateY:w,useTranslate3d:h})):m=t5e,{cssProperties:m,cssClasses:n5e({translateX:y,translateY:w,coordinate:n})}}var s5e=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Yy={isSsr:s5e()};function LX(){var[e,t]=j.useState(()=>Yy.isSsr||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return j.useEffect(()=>{if(window.matchMedia){var n=window.matchMedia("(prefers-reduced-motion: reduce)"),r=()=>{t(n.matches)};return n.addEventListener("change",r),()=>{n.removeEventListener("change",r)}}},[]),e}function CU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function u0(e){for(var t=1;t({dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}));j.useEffect(()=>{var k=I=>{if(I.key==="Escape"){var T,D,F,L;f({dismissed:!0,dismissedAtCoordinate:{x:(T=(D=e.coordinate)===null||D===void 0?void 0:D.x)!==null&&T!==void 0?T:0,y:(F=(L=e.coordinate)===null||L===void 0?void 0:L.y)!==null&&F!==void 0?F:0}})}};return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[(t=e.coordinate)===null||t===void 0?void 0:t.x,(n=e.coordinate)===null||n===void 0?void 0:n.y]),h.dismissed&&(((r=(i=e.coordinate)===null||i===void 0?void 0:i.x)!==null&&r!==void 0?r:0)!==h.dismissedAtCoordinate.x||((a=(o=e.coordinate)===null||o===void 0?void 0:o.y)!==null&&a!==void 0?a:0)!==h.dismissedAtCoordinate.y)&&f(u0(u0({},h),{},{dismissed:!1}));var{cssClasses:m,cssProperties:y}=i5e({allowEscapeViewBox:e.allowEscapeViewBox,coordinate:e.coordinate,offsetLeft:typeof e.offset=="number"?e.offset:e.offset.x,offsetTop:typeof e.offset=="number"?e.offset:e.offset.y,position:e.position,reverseDirection:e.reverseDirection,tooltipBox:{height:e.lastBoundingBox.height,width:e.lastBoundingBox.width},useTranslate3d:e.useTranslate3d,viewBox:e.viewBox}),w=e.hasPortalFromProps?{}:u0(u0({transition:c5e({prefersReducedMotion:c,isAnimationActive:e.isAnimationActive,active:e.active,animationDuration:e.animationDuration,animationEasing:e.animationEasing})},y),{},{pointerEvents:"none",position:"absolute",top:0,left:0}),A=u0(u0({},w),{},{visibility:!h.dismissed&&e.active&&e.hasPayload?"visible":"hidden"},e.wrapperStyle);return j.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:m,style:A,ref:e.innerRef},e.children)}var d5e=j.memo(u5e),UX=()=>{var e;return(e=Qn(t=>t.rootProps.accessibilityLayer))!==null&&e!==void 0?e:!0};function SI(){return SI=Object.assign?Object.assign.bind():function(e){for(var t=1;tqr(e.x)&&qr(e.y),OU=e=>e.base!=null&&K2(e.base)&&K2(e),Hx=e=>e.x,Gx=e=>e.y,m5e=(e,t)=>{if(typeof e=="function")return e;var n="curve".concat($y(e));if((n==="curveMonotone"||n==="curveBump")&&t){var r=TU["".concat(n).concat(t==="vertical"?"Y":"X")];if(r)return r}return TU[n]||NE},PU={connectNulls:!1,type:"linear"},g5e=e=>{var{type:t=PU.type,points:n=[],baseLine:r,layout:i,connectNulls:a=PU.connectNulls}=e,o=m5e(t,i),c=a?n.filter(K2):n;if(Array.isArray(r)){var h,f=n.map((k,I)=>jU(jU({},k),{},{base:r[I]}));i==="vertical"?h=Ov().y(Gx).x1(Hx).x0(k=>k.base.x):h=Ov().x(Hx).y1(Gx).y0(k=>k.base.y);var m=h.defined(OU).curve(o),y=a?f.filter(OU):f;return m(y)}var w;i==="vertical"&&En(r)?w=Ov().y(Gx).x1(Hx).x0(r):En(r)?w=Ov().x(Hx).y1(Gx).y0(r):w=hY().x(Hx).y(Gx);var A=w.defined(K2).curve(o);return A(c)},P1=e=>{var{className:t,points:n,path:r,pathRef:i}=e,a=Tf();if((!n||!n.length)&&!r)return null;var o={type:e.type,points:e.points,baseLine:e.baseLine,layout:e.layout||a,connectNulls:e.connectNulls},c=n&&n.length?g5e(o):r;return j.createElement("path",SI({},Hl(e),N4(e),{className:Di("recharts-curve",t),d:c===null?void 0:c,ref:i}))},x5e=["x","y","top","left","width","height","className"];function kI(){return kI=Object.assign?Object.assign.bind():function(e){for(var t=1;t"M".concat(e,",").concat(i,"v").concat(r,"M").concat(a,",").concat(t,"h").concat(n),_5e=e=>{var{x:t=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:c}=e,h=N5e(e,x5e),f=y5e({x:t,y:n,top:r,left:i,width:a,height:o},h);return!En(t)||!En(n)||!En(a)||!En(o)||!En(r)||!En(i)?null:j.createElement("path",kI({},ko(f),{className:Di("recharts-cross",c),d:A5e(t,n,a,o,r,i)}))};function S5e(e,t,n,r){var i=r/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?t.x-i:n.left+.5,y:e==="horizontal"?n.top+.5:t.y-i,width:e==="horizontal"?r:n.width-1,height:e==="horizontal"?n.height-1:r}}function DU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function MU(e){for(var t=1;te.replace(/([A-Z])/g,t=>"-".concat(t.toLowerCase())),BX=(e,t,n)=>e.map(r=>"".concat(j5e(r)," ").concat(t,"ms ").concat(n)).join(","),T5e=(e,t)=>[Object.keys(e),Object.keys(t)].reduce((n,r)=>n.filter(i=>r.includes(i))),cy=(e,t)=>Object.keys(t).reduce((n,r)=>MU(MU({},n),{},{[r]:e(r,t[r])}),{});function LU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function _a(e){for(var t=1;te+(t-e)*n,CI=e=>{var{from:t,to:n}=e;return t!==n},zX=(e,t,n)=>{var r=cy((i,a)=>{if(CI(a)){var[o,c]=e(a.from,a.to,a.velocity);return _a(_a({},a),{},{from:o,velocity:c})}return a},t);return n<1?cy((i,a)=>CI(a)&&r[i]!=null?_a(_a({},a),{},{velocity:Y2(a.velocity,r[i].velocity,n),from:Y2(a.from,r[i].from,n)}):a,t):zX(e,r,n-1)};function D5e(e,t,n,r,i,a){var o,c=r.reduce((w,A)=>_a(_a({},w),{},{[A]:{from:e[A],velocity:0,to:t[A]}}),{}),h=()=>cy((w,A)=>A.from,c),f=()=>!Object.values(c).filter(CI).length,m=null,y=w=>{o||(o=w);var A=w-o,k=A/n.dt;c=zX(n,c,k),i(_a(_a(_a({},e),t),h())),o=w,f()||(m=a.setTimeout(y))};return()=>(m=a.setTimeout(y),()=>{var w;(w=m)===null||w===void 0||w()})}function M5e(e,t,n,r,i,a,o){var c=null,h=i.reduce((y,w)=>{var A=e[w],k=t[w];return A==null||k==null?y:_a(_a({},y),{},{[w]:[A,k]})},{}),f,m=y=>{f||(f=y);var w=(y-f)/r,A=cy((I,T)=>Y2(...T,n(w)),h);if(a(_a(_a(_a({},e),t),A)),w<1)c=o.setTimeout(m);else{var k=cy((I,T)=>Y2(...T,n(1)),h);a(_a(_a(_a({},e),t),k))}};return()=>(c=o.setTimeout(m),()=>{var y;(y=c)===null||y===void 0||y()})}const L5e=(e,t,n,r,i,a)=>{var o=T5e(e,t);return n==null?()=>(i(_a(_a({},e),t)),()=>{}):n.isStepper===!0?D5e(e,t,n,o,i,a):M5e(e,t,n,r,o,i,a)};var X2=1e-4,VX=(e,t)=>[0,3*e,3*t-6*e,3*e-3*t+1],FX=(e,t)=>e.map((n,r)=>n*t**r).reduce((n,r)=>n+r),UU=(e,t)=>n=>{var r=VX(e,t);return FX(r,n)},U5e=(e,t)=>n=>{var r=VX(e,t),i=[...r.map((a,o)=>a*o).slice(1),0];return FX(i,n)},B5e=e=>{var t,n=e.split("(");if(n.length!==2||n[0]!=="cubic-bezier")return null;var r=(t=n[1])===null||t===void 0||(t=t.split(")")[0])===null||t===void 0?void 0:t.split(",");if(r==null||r.length!==4)return null;var i=r.map(a=>parseFloat(a));return[i[0],i[1],i[2],i[3]]},z5e=function(){for(var t=arguments.length,n=new Array(t),r=0;r{var i=UU(e,n),a=UU(t,r),o=U5e(e,n),c=f=>f>1?1:f<0?0:f,h=f=>{for(var m=f>1?1:f,y=m,w=0;w<8;++w){var A=i(y)-m,k=o(y);if(Math.abs(A-m)0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=t,a=(o,c,h)=>{var f=-(o-c)*n,m=h*r,y=h+(f-m)*i/1e3,w=h*i/1e3+o;return Math.abs(w-c){if(typeof e=="string")switch(e){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return BU(e);case"spring":return F5e();default:if(e.split("(")[0]==="cubic-bezier")return BU(e)}return typeof e=="function"?e:null};function H5e(e){var t,n=()=>null,r=!1,i=null,a=o=>{if(!r){if(Array.isArray(o)){if(!o.length)return;var c=o,[h,...f]=c;if(typeof h=="number"){i=e.setTimeout(a.bind(null,f),h);return}a(h),i=e.setTimeout(a.bind(null,f));return}typeof o=="string"&&(t=o,n(t)),typeof o=="object"&&(t=o,n(t)),typeof o=="function"&&o()}};return{stop:()=>{r=!0},start:o=>{r=!1,i&&(i(),i=null),a(o)},subscribe:o=>(n=o,()=>{n=()=>null}),getTimeoutController:()=>e}}class G5e{setTimeout(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,a=o=>{o-r>=n?t(o):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(a))};return i=requestAnimationFrame(a),()=>{i!=null&&cancelAnimationFrame(i)}}}function q5e(){return H5e(new G5e)}var W5e=j.createContext(q5e);function K5e(e,t){var n=j.useContext(W5e);return j.useMemo(()=>t??n(e),[e,t,n])}var Y5e={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},zU={t:0},F5={t:1};function Xy(e){var t=Fa(e,Y5e),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:c,onAnimationStart:h,children:f}=t,m=LX(),y=n==="auto"?!Yy.isSsr&&!m:n,w=K5e(t.animationId,t.animationManager),[A,k]=j.useState(y?zU:F5),I=j.useRef(null);return j.useEffect(()=>{y||k(F5)},[y]),j.useEffect(()=>{if(!y||!r)return jf;var T=L5e(zU,F5,$5e(a),i,k,w.getTimeoutController()),D=()=>{I.current=T()};return w.start([h,o,D,i,c]),()=>{w.stop(),I.current&&I.current(),c()}},[y,r,i,a,o,h,c,w]),f(A.t)}function Qy(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=j.useRef(ny(t)),r=j.useRef(e);return r.current!==e&&(n.current=ny(t),r.current=e),n.current}var X5e=["radius"],Q5e=["radius"],VU,FU,$U,HU,GU,qU,WU,KU,YU,XU;function QU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function ZU(e){for(var t=1;t{var a=ef(n),o=ef(r),c=Math.min(Math.abs(a)/2,Math.abs(o)/2),h=o>=0?1:-1,f=a>=0?1:-1,m=o>=0&&a>=0||o<0&&a<0?1:0,y;if(c>0&&Array.isArray(i)){for(var w=[0,0,0,0],A=0,k=4;Ac?c:T}y=Hs(VU||(VU=ou(["M",",",""])),e,t+h*w[0]),w[0]>0&&(y+=Hs(FU||(FU=ou(["A ",",",",0,0,",",",",",""])),w[0],w[0],m,e+f*w[0],t)),y+=Hs($U||($U=ou(["L ",",",""])),e+n-f*w[1],t),w[1]>0&&(y+=Hs(HU||(HU=ou(["A ",",",",0,0,",`, `,",",""])),w[1],w[1],m,e+n,t+h*w[1])),y+=Hs(GU||(GU=ou(["L ",",",""])),e+n,t+r-h*w[2]),w[2]>0&&(y+=Hs(qU||(qU=ou(["A ",",",",0,0,",`, `,",",""])),w[2],w[2],m,e+n-f*w[2],t+r)),y+=Hs(WU||(WU=ou(["L ",",",""])),e+f*w[3],t+r),w[3]>0&&(y+=Hs(KU||(KU=ou(["A ",",",",0,0,",`, `,",",""])),w[3],w[3],m,e,t+r-h*w[3])),y+="Z"}else if(c>0&&i===+i&&i>0){var D=Math.min(c,i);y=Hs(YU||(YU=ou(["M ",",",` A `,",",",0,0,",",",",",` L `,",",` A `,",",",0,0,",",",",",` L `,",",` A `,",",",0,0,",",",",",` L `,",",` A `,",",",0,0,",",",","," Z"])),e,t+h*D,D,D,m,e+f*D,t,e+n-f*D,t,D,D,m,e+n,t+h*D,e+n,t+r-h*D,D,D,m,e+n-f*D,t+r,e+f*D,t+r,D,D,m,e,t+r-h*D)}else y=Hs(XU||(XU=ou(["M ",","," h "," v "," h "," Z"])),e,t,n,r,-n);return y},tB={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},$X=e=>{var t=Fa(e,tB),n=j.useRef(null),[r,i]=j.useState(-1);j.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var ve=n.current.getTotalLength();ve&&i(ve)}catch{}},[]);var{x:a,y:o,width:c,height:h,radius:f,className:m}=t,{animationEasing:y,animationDuration:w,animationBegin:A,isAnimationActive:k,isUpdateAnimationActive:I}=t,T=j.useRef(c),D=j.useRef(h),F=j.useRef(a),L=j.useRef(o),q=j.useMemo(()=>({x:a,y:o,width:c,height:h,radius:f}),[a,o,c,h,f]),Z=Qy(q,"rectangle-");if(a!==+a||o!==+o||c!==+c||h!==+h||c===0||h===0)return null;var K=Di("recharts-rectangle",m);if(!I){var z=ko(t),{radius:B}=z,V=JU(z,X5e);return j.createElement("path",Q2({},V,{x:ef(a),y:ef(o),width:ef(c),height:ef(h),radius:typeof f=="number"?f:void 0,className:K,d:eB(a,o,c,h,f)}))}var $=T.current,Q=D.current,Y=F.current,G=L.current,he="0px ".concat(r===-1?1:r,"px"),te="".concat(r,"px ").concat(r,"px"),le=BX(["strokeDasharray"],w,typeof y=="string"?y:tB.animationEasing);return j.createElement(Xy,{animationId:Z,key:Z,canBegin:r>0,duration:w,easing:y,isActive:I,begin:A},ve=>{var ke=Xi($,c,ve),Be=Xi(Q,h,ve),J=Xi(Y,a,ve),ie=Xi(G,o,ve);n.current&&(T.current=ke,D.current=Be,F.current=J,L.current=ie);var xe;k?ve>0?xe={transition:le,strokeDasharray:te}:xe={strokeDasharray:he}:xe={strokeDasharray:te};var ae=ko(t),{radius:Fe}=ae,pt=JU(ae,Q5e);return j.createElement("path",Q2({},pt,{radius:typeof f=="number"?f:void 0,className:K,d:eB(J,ie,ke,Be,f),ref:n,style:ZU(ZU({},xe),t.style)}))})};function nB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function rB(e){for(var t=1;te*180/Math.PI,ao=(e,t,n,r)=>({x:e+Math.cos(-Z2*r)*n,y:t+Math.sin(-Z2*r)*n}),ake=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(t-(r.left||0)-(r.right||0)),Math.abs(n-(r.top||0)-(r.bottom||0)))/2},oke=(e,t)=>{var{x:n,y:r}=e,{x:i,y:a}=t;return Math.sqrt((n-i)**2+(r-a)**2)},lke=(e,t)=>{var{x:n,y:r}=e,{cx:i,cy:a}=t,o=oke({x:n,y:r},{x:i,y:a});if(o<=0)return{radius:o,angle:0};var c=(n-i)/o,h=Math.acos(c);return r>a&&(h=2*Math.PI-h),{radius:o,angle:ske(h),angleInRadian:h}},cke=e=>{var{startAngle:t,endAngle:n}=e,r=Math.floor(t/360),i=Math.floor(n/360),a=Math.min(r,i);return{startAngle:t-a*360,endAngle:n-a*360}},uke=(e,t)=>{var{startAngle:n,endAngle:r}=t,i=Math.floor(n/360),a=Math.floor(r/360),o=Math.min(i,a);return e+o*360},dke=(e,t)=>{var{relativeX:n,relativeY:r}=e,{radius:i,angle:a}=lke({x:n,y:r},t),{innerRadius:o,outerRadius:c}=t;if(ic||i===0)return null;var{startAngle:h,endAngle:f}=cke(t),m=a,y;if(h<=f){for(;m>f;)m-=360;for(;m=h&&m<=f}else{for(;m>h;)m-=360;for(;m=f&&m<=h}return y?rB(rB({},t),{},{radius:i,angle:uke(m,t)}):null};function HX(e){var{cx:t,cy:n,radius:r,startAngle:i,endAngle:a}=e,o=ao(t,n,r,i),c=ao(t,n,r,a);return{points:[o,c],cx:t,cy:n,radius:r,startAngle:i,endAngle:a}}var iB,sB,aB,oB,lB,cB,uB;function II(){return II=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=xl(t-e),r=Math.min(Math.abs(t-e),359.999);return n*r},zv=e=>{var{cx:t,cy:n,radius:r,angle:i,sign:a,isExternal:o,cornerRadius:c,cornerIsExternal:h}=e,f=c*(o?1:-1)+r,m=Math.asin(c/f)/Z2,y=h?i:i+a*m,w=ao(t,n,f,y),A=ao(t,n,r,y),k=h?i-a*m:i,I=ao(t,n,f*Math.cos(m*Z2),k);return{center:w,circleTangency:A,lineTangency:I,theta:m}},GX=e=>{var{cx:t,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=e,c=hke(a,o),h=a+c,f=ao(t,n,i,a),m=ao(t,n,i,h),y=Hs(iB||(iB=Ap(["M ",",",` A `,",",`,0, `,",",`, `,",",` `])),f.x,f.y,i,i,+(Math.abs(c)>180),+(a>h),m.x,m.y);if(r>0){var w=ao(t,n,r,a),A=ao(t,n,r,h);y+=Hs(sB||(sB=Ap(["L ",",",` A `,",",`,0, `,",",`, `,","," Z"])),A.x,A.y,r,r,+(Math.abs(c)>180),+(a<=h),w.x,w.y)}else y+=Hs(aB||(aB=Ap(["L ",","," Z"])),t,n);return y},fke=e=>{var{cx:t,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:c,startAngle:h,endAngle:f}=e,m=xl(f-h),{circleTangency:y,lineTangency:w,theta:A}=zv({cx:t,cy:n,radius:i,angle:h,sign:m,cornerRadius:a,cornerIsExternal:c}),{circleTangency:k,lineTangency:I,theta:T}=zv({cx:t,cy:n,radius:i,angle:f,sign:-m,cornerRadius:a,cornerIsExternal:c}),D=c?Math.abs(h-f):Math.abs(h-f)-A-T;if(D<0)return o?Hs(oB||(oB=Ap(["M ",",",` a`,",",",0,0,1,",`,0 a`,",",",0,0,1,",`,0 `])),w.x,w.y,a,a,a*2,a,a,-a*2):GX({cx:t,cy:n,innerRadius:r,outerRadius:i,startAngle:h,endAngle:f});var F=Hs(lB||(lB=Ap(["M ",",",` A`,",",",0,0,",",",",",` A`,",",",0,",",",",",",",` A`,",",",0,0,",",",",",` `])),w.x,w.y,a,a,+(m<0),y.x,y.y,i,i,+(D>180),+(m<0),k.x,k.y,a,a,+(m<0),I.x,I.y);if(r>0){var{circleTangency:L,lineTangency:q,theta:Z}=zv({cx:t,cy:n,radius:r,angle:h,sign:m,isExternal:!0,cornerRadius:a,cornerIsExternal:c}),{circleTangency:K,lineTangency:z,theta:B}=zv({cx:t,cy:n,radius:r,angle:f,sign:-m,isExternal:!0,cornerRadius:a,cornerIsExternal:c}),V=c?Math.abs(h-f):Math.abs(h-f)-Z-B;if(V<0&&a===0)return"".concat(F,"L").concat(t,",").concat(n,"Z");F+=Hs(cB||(cB=Ap(["L",",",` A`,",",",0,0,",",",",",` A`,",",",0,",",",",",",",` A`,",",",0,0,",",",",","Z"])),z.x,z.y,a,a,+(m<0),K.x,K.y,r,r,+(V>180),+(m>0),L.x,L.y,a,a,+(m<0),q.x,q.y)}else F+=Hs(uB||(uB=Ap(["L",",","Z"])),t,n);return F},pke={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},qX=e=>{var t=Fa(e,pke),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:o,forceCornerRadius:c,cornerIsExternal:h,startAngle:f,endAngle:m,className:y}=t;if(a0&&Math.abs(f-m)<360?I=fke({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(k,A/2),forceCornerRadius:c,cornerIsExternal:h,startAngle:f,endAngle:m}):I=GX({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:f,endAngle:m}),j.createElement("path",II({},ko(t),{className:w,d:I}))};function mke(e,t,n){if(e==="horizontal")return[{x:t.x,y:n.top},{x:t.x,y:n.top+n.height}];if(e==="vertical")return[{x:n.left,y:t.y},{x:n.left+n.width,y:t.y}];if(kY(t)){if(e==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:c}=t,h=ao(r,i,a,c),f=ao(r,i,o,c);return[{x:h.x,y:h.y},{x:f.x,y:f.y}]}return HX(t)}}var $5={},H5={},G5={},dB;function gke(){return dB||(dB=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=zY();function n(r){return t.isSymbol(r)?NaN:Number(r)}e.toNumber=n})(G5)),G5}var hB;function xke(){return hB||(hB=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=gke();function n(r){return r?(r=t.toNumber(r),r===1/0||r===-1/0?(r<0?-1:1)*Number.MAX_VALUE:r===r?r:0):r===0?r:0}e.toFinite=n})(H5)),H5}var fB;function yke(){return fB||(fB=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=VY(),n=xke();function r(i,a,o){o&&typeof o!="number"&&t.isIterateeCall(i,a,o)&&(a=o=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),o=o===void 0?ie.chartData,B4=et([qc],e=>{var t=e.chartData!=null?e.chartData.length-1:0;return{chartData:e.chartData,computedData:e.computedData,dataEndIndex:t,dataStartIndex:0}}),Zy=(e,t,n,r)=>r?B4(e):qc(e),KX=(e,t,n)=>n?B4(e):qc(e),wke=et([Zy],e=>{var{chartData:t,dataStartIndex:n,dataEndIndex:r}=e;return t!=null?t.slice(n,r+1):[]});et([B4],e=>{var{chartData:t,dataStartIndex:n,dataEndIndex:r}=e;return t!=null?t.slice(n,r+1):[]});var Nke=et([qc],e=>{var{chartData:t,dataStartIndex:n,dataEndIndex:r}=e;return t!=null?t.slice(n,r+1):[]});function Tu(e){if(Array.isArray(e)&&e.length===2){var[t,n]=e;if(qr(t)&&qr(n))return!0}return!1}function mB(e,t,n){return n?e:[Math.min(e[0],t[0]),Math.max(e[1],t[1])]}function YX(e,t){if(t&&typeof e!="function"&&Array.isArray(e)&&e.length===2){var[n,r]=e,i,a;if(qr(n))i=n;else if(typeof n=="function")return;if(qr(r))a=r;else if(typeof r=="function")return;var o=[i,a];if(Tu(o))return o}}function Eke(e,t,n){if(!(!n&&t==null)){if(typeof e=="function"&&t!=null)try{var r=e(t,n);if(Tu(r))return mB(r,t,n)}catch{}if(Array.isArray(e)&&e.length===2){var[i,a]=e,o,c;if(i==="auto")t!=null&&(o=Math.min(...t));else if(En(i))o=i;else if(typeof i=="function")try{t!=null&&(o=i(t==null?void 0:t[0]))}catch{}else if(typeof i=="string"&&iU.test(i)){var h=iU.exec(i);if(h==null||h[1]==null||t==null)o=void 0;else{var f=+h[1];o=t[0]-f}}else o=t==null?void 0:t[0];if(a==="auto")t!=null&&(c=Math.max(...t));else if(En(a))c=a;else if(typeof a=="function")try{t!=null&&(c=a(t==null?void 0:t[1]))}catch{}else if(typeof a=="string"&&sU.test(a)){var m=sU.exec(a);if(m==null||m[1]==null||t==null)c=void 0;else{var y=+m[1];c=t[1]+y}}else c=t==null?void 0:t[1];var w=[o,c];if(Tu(w))return t==null?w:mB(w,t,n)}}}var Ug=1e9,Ake={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},V4,Ss=!0,fc="[DecimalError] ",Up=fc+"Invalid argument: ",z4=fc+"Exponent out of range: ",Bg=Math.floor,dp=Math.pow,_ke=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Rl,za=1e7,ms=7,XX=9007199254740991,J2=Bg(XX/ms),In={};In.absoluteValue=In.abs=function(){var e=new this.constructor(this);return e.s&&(e.s=1),e};In.comparedTo=In.cmp=function(e){var t,n,r,i,a=this;if(e=new a.constructor(e),a.s!==e.s)return a.s||-e.s;if(a.e!==e.e)return a.e>e.e^a.s<0?1:-1;for(r=a.d.length,i=e.d.length,t=0,n=re.d[t]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1};In.decimalPlaces=In.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*ms;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n};In.dividedBy=In.div=function(e){return Rd(this,new this.constructor(e))};In.dividedToIntegerBy=In.idiv=function(e){var t=this,n=t.constructor;return ns(Rd(t,new n(e),0,1),n.precision)};In.equals=In.eq=function(e){return!this.cmp(e)};In.exponent=function(){return ha(this)};In.greaterThan=In.gt=function(e){return this.cmp(e)>0};In.greaterThanOrEqualTo=In.gte=function(e){return this.cmp(e)>=0};In.isInteger=In.isint=function(){return this.e>this.d.length-2};In.isNegative=In.isneg=function(){return this.s<0};In.isPositive=In.ispos=function(){return this.s>0};In.isZero=function(){return this.s===0};In.lessThan=In.lt=function(e){return this.cmp(e)<0};In.lessThanOrEqualTo=In.lte=function(e){return this.cmp(e)<1};In.logarithm=In.log=function(e){var t,n=this,r=n.constructor,i=r.precision,a=i+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(Rl))throw Error(fc+"NaN");if(n.s<1)throw Error(fc+(n.s?"NaN":"-Infinity"));return n.eq(Rl)?new r(0):(Ss=!1,t=Rd(uy(n,a),uy(e,a),a),Ss=!0,ns(t,i))};In.minus=In.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?JX(t,e):QX(t,(e.s=-e.s,e))};In.modulo=In.mod=function(e){var t,n=this,r=n.constructor,i=r.precision;if(e=new r(e),!e.s)throw Error(fc+"NaN");return n.s?(Ss=!1,t=Rd(n,e,0,1).times(e),Ss=!0,n.minus(t)):ns(new r(n),i)};In.naturalExponential=In.exp=function(){return ZX(this)};In.naturalLogarithm=In.ln=function(){return uy(this)};In.negated=In.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};In.plus=In.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?QX(t,e):JX(t,(e.s=-e.s,e))};In.precision=In.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Up+e);if(t=ha(i)+1,r=i.d.length-1,n=r*ms+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n};In.squareRoot=In.sqrt=function(){var e,t,n,r,i,a,o,c=this,h=c.constructor;if(c.s<1){if(!c.s)return new h(0);throw Error(fc+"NaN")}for(e=ha(c),Ss=!1,i=Math.sqrt(+c),i==0||i==1/0?(t=_u(c.d),(t.length+e)%2==0&&(t+="0"),i=Math.sqrt(t),e=Bg((e+1)/2)-(e<0||e%2),i==1/0?t="5e"+e:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),r=new h(t)):r=new h(i.toString()),n=h.precision,i=o=n+3;;)if(a=r,r=a.plus(Rd(c,a,o+2)).times(.5),_u(a.d).slice(0,o)===(t=_u(r.d)).slice(0,o)){if(t=t.slice(o-3,o+1),i==o&&t=="4999"){if(ns(a,n+1,0),a.times(a).eq(c)){r=a;break}}else if(t!="9999")break;o+=4}return Ss=!0,ns(r,n)};In.times=In.mul=function(e){var t,n,r,i,a,o,c,h,f,m=this,y=m.constructor,w=m.d,A=(e=new y(e)).d;if(!m.s||!e.s)return new y(0);for(e.s*=m.s,n=m.e+e.e,h=w.length,f=A.length,h=0;){for(t=0,i=h+r;i>r;)c=a[i]+A[r]*w[i-r-1]+t,a[i--]=c%za|0,t=c/za|0;a[i]=(a[i]+t)%za|0}for(;!a[--o];)a.pop();return t?++n:a.shift(),e.d=a,e.e=n,Ss?ns(e,y.precision):e};In.toDecimalPlaces=In.todp=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(zu(e,0,Ug),t===void 0?t=r.rounding:zu(t,0,8),ns(n,e+ha(n)+1,t))};In.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=lm(r,!0):(zu(e,0,Ug),t===void 0?t=i.rounding:zu(t,0,8),r=ns(new i(r),e+1,t),n=lm(r,!0,e+1)),n};In.toFixed=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?lm(i):(zu(e,0,Ug),t===void 0?t=a.rounding:zu(t,0,8),r=ns(new a(i),e+ha(i)+1,t),n=lm(r.abs(),!1,e+ha(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};In.toInteger=In.toint=function(){var e=this,t=e.constructor;return ns(new t(e),ha(e)+1,t.rounding)};In.toNumber=function(){return+this};In.toPower=In.pow=function(e){var t,n,r,i,a,o,c=this,h=c.constructor,f=12,m=+(e=new h(e));if(!e.s)return new h(Rl);if(c=new h(c),!c.s){if(e.s<1)throw Error(fc+"Infinity");return c}if(c.eq(Rl))return c;if(r=h.precision,e.eq(Rl))return ns(c,r);if(t=e.e,n=e.d.length-1,o=t>=n,a=c.s,o){if((n=m<0?-m:m)<=XX){for(i=new h(Rl),t=Math.ceil(r/ms+4),Ss=!1;n%2&&(i=i.times(c),xB(i.d,t)),n=Bg(n/2),n!==0;)c=c.times(c),xB(c.d,t);return Ss=!0,e.s<0?new h(Rl).div(i):ns(i,r)}}else if(a<0)throw Error(fc+"NaN");return a=a<0&&e.d[Math.max(t,n)]&1?-1:1,c.s=1,Ss=!1,i=e.times(uy(c,r+f)),Ss=!0,i=ZX(i),i.s=a,i};In.toPrecision=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?(n=ha(i),r=lm(i,n<=a.toExpNeg||n>=a.toExpPos)):(zu(e,1,Ug),t===void 0?t=a.rounding:zu(t,0,8),i=ns(new a(i),e,t),n=ha(i),r=lm(i,e<=n||n<=a.toExpNeg,e)),r};In.toSignificantDigits=In.tosd=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(zu(e,1,Ug),t===void 0?t=r.rounding:zu(t,0,8)),ns(new r(n),e,t)};In.toString=In.valueOf=In.val=In.toJSON=In[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=ha(e),n=e.constructor;return lm(e,t<=n.toExpNeg||t>=n.toExpPos)};function QX(e,t){var n,r,i,a,o,c,h,f,m=e.constructor,y=m.precision;if(!e.s||!t.s)return t.s||(t=new m(e)),Ss?ns(t,y):t;if(h=e.d,f=t.d,o=e.e,i=t.e,h=h.slice(),a=o-i,a){for(a<0?(r=h,a=-a,c=f.length):(r=f,i=o,c=h.length),o=Math.ceil(y/ms),c=o>c?o+1:c+1,a>c&&(a=c,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(c=h.length,a=f.length,c-a<0&&(a=c,r=f,f=h,h=r),n=0;a;)n=(h[--a]=h[a]+f[a]+n)/za|0,h[a]%=za;for(n&&(h.unshift(n),++i),c=h.length;h[--c]==0;)h.pop();return t.d=h,t.e=i,Ss?ns(t,y):t}function zu(e,t,n){if(e!==~~e||en)throw Error(Up+e)}function _u(e){var t,n,r,i=e.length-1,a="",o=e[0];if(i>0){for(a+=o,t=1;to?1:-1;else for(c=h=0;ci[c]?1:-1;break}return h}function n(r,i,a){for(var o=0;a--;)r[a]-=o,o=r[a]1;)r.shift()}return function(r,i,a,o){var c,h,f,m,y,w,A,k,I,T,D,F,L,q,Z,K,z,B,V=r.constructor,$=r.s==i.s?1:-1,Q=r.d,Y=i.d;if(!r.s)return new V(r);if(!i.s)throw Error(fc+"Division by zero");for(h=r.e-i.e,z=Y.length,Z=Q.length,A=new V($),k=A.d=[],f=0;Y[f]==(Q[f]||0);)++f;if(Y[f]>(Q[f]||0)&&--h,a==null?F=a=V.precision:o?F=a+(ha(r)-ha(i))+1:F=a,F<0)return new V(0);if(F=F/ms+2|0,f=0,z==1)for(m=0,Y=Y[0],F++;(f1&&(Y=e(Y,m),Q=e(Q,m),z=Y.length,Z=Q.length),q=z,I=Q.slice(0,z),T=I.length;T=za/2&&++K;do m=0,c=t(Y,I,z,T),c<0?(D=I[0],z!=T&&(D=D*za+(I[1]||0)),m=D/K|0,m>1?(m>=za&&(m=za-1),y=e(Y,m),w=y.length,T=I.length,c=t(y,I,w,T),c==1&&(m--,n(y,z16)throw Error(z4+ha(e));if(!e.s)return new m(Rl);for(Ss=!1,c=y,o=new m(.03125);e.abs().gte(.1);)e=e.times(o),f+=5;for(r=Math.log(dp(2,f))/Math.LN10*2+5|0,c+=r,n=i=a=new m(Rl),m.precision=c;;){if(i=ns(i.times(e),c),n=n.times(++h),o=a.plus(Rd(i,n,c)),_u(o.d).slice(0,c)===_u(a.d).slice(0,c)){for(;f--;)a=ns(a.times(a),c);return m.precision=y,t==null?(Ss=!0,ns(a,y)):a}a=o}}function ha(e){for(var t=e.e*ms,n=e.d[0];n>=10;n/=10)t++;return t}function W5(e,t,n){if(t>e.LN10.sd())throw Ss=!0,n&&(e.precision=n),Error(fc+"LN10 precision limit exceeded");return ns(new e(e.LN10),t)}function Vh(e){for(var t="";e--;)t+="0";return t}function uy(e,t){var n,r,i,a,o,c,h,f,m,y=1,w=10,A=e,k=A.d,I=A.constructor,T=I.precision;if(A.s<1)throw Error(fc+(A.s?"NaN":"-Infinity"));if(A.eq(Rl))return new I(0);if(t==null?(Ss=!1,f=T):f=t,A.eq(10))return t==null&&(Ss=!0),W5(I,f);if(f+=w,I.precision=f,n=_u(k),r=n.charAt(0),a=ha(A),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)A=A.times(e),n=_u(A.d),r=n.charAt(0),y++;a=ha(A),r>1?(A=new I("0."+n),a++):A=new I(r+"."+n.slice(1))}else return h=W5(I,f+2,T).times(a+""),A=uy(new I(r+"."+n.slice(1)),f-w).plus(h),I.precision=T,t==null?(Ss=!0,ns(A,T)):A;for(c=o=A=Rd(A.minus(Rl),A.plus(Rl),f),m=ns(A.times(A),f),i=3;;){if(o=ns(o.times(m),f),h=c.plus(Rd(o,new I(i),f)),_u(h.d).slice(0,f)===_u(c.d).slice(0,f))return c=c.times(2),a!==0&&(c=c.plus(W5(I,f+2,T).times(a+""))),c=Rd(c,new I(y),f),I.precision=T,t==null?(Ss=!0,ns(c,T)):c;c=h,i+=2}}function gB(e,t){var n,r,i;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(i=t.length;t.charCodeAt(i-1)===48;)--i;if(t=t.slice(r,i),t){if(i-=r,n=n-r-1,e.e=Bg(n/ms),e.d=[],r=(n+1)%ms,n<0&&(r+=ms),rJ2||e.e<-J2))throw Error(z4+n)}else e.s=0,e.e=0,e.d=[0];return e}function ns(e,t,n){var r,i,a,o,c,h,f,m,y=e.d;for(o=1,a=y[0];a>=10;a/=10)o++;if(r=t-o,r<0)r+=ms,i=t,f=y[m=0];else{if(m=Math.ceil((r+1)/ms),a=y.length,m>=a)return e;for(f=a=y[m],o=1;a>=10;a/=10)o++;r%=ms,i=r-ms+o}if(n!==void 0&&(a=dp(10,o-i-1),c=f/a%10|0,h=t<0||y[m+1]!==void 0||f%a,h=n<4?(c||h)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||h||n==6&&(r>0?i>0?f/dp(10,o-i):0:y[m-1])%10&1||n==(e.s<0?8:7))),t<1||!y[0])return h?(a=ha(e),y.length=1,t=t-a-1,y[0]=dp(10,(ms-t%ms)%ms),e.e=Bg(-t/ms)||0):(y.length=1,y[0]=e.e=e.s=0),e;if(r==0?(y.length=m,a=1,m--):(y.length=m+1,a=dp(10,ms-r),y[m]=i>0?(f/dp(10,o-i)%dp(10,i)|0)*a:0),h)for(;;)if(m==0){(y[0]+=a)==za&&(y[0]=1,++e.e);break}else{if(y[m]+=a,y[m]!=za)break;y[m--]=0,a=1}for(r=y.length;y[--r]===0;)y.pop();if(Ss&&(e.e>J2||e.e<-J2))throw Error(z4+ha(e));return e}function JX(e,t){var n,r,i,a,o,c,h,f,m,y,w=e.constructor,A=w.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new w(e),Ss?ns(t,A):t;if(h=e.d,y=t.d,r=t.e,f=e.e,h=h.slice(),o=f-r,o){for(m=o<0,m?(n=h,o=-o,c=y.length):(n=y,r=f,c=h.length),i=Math.max(Math.ceil(A/ms),c)+2,o>i&&(o=i,n.length=1),n.reverse(),i=o;i--;)n.push(0);n.reverse()}else{for(i=h.length,c=y.length,m=i0;--i)h[c++]=0;for(i=y.length;i>o;){if(h[--i]0?a=a.charAt(0)+"."+a.slice(1)+Vh(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+Vh(-i-1)+a,n&&(r=n-o)>0&&(a+=Vh(r))):i>=o?(a+=Vh(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+Vh(r))):((r=i+1)0&&(i+1===o&&(a+="."),a+=Vh(r))),e.s<0?"-"+a:a}function xB(e,t){if(e.length>t)return e.length=t,!0}function eQ(e){var t,n,r;function i(a){var o=this;if(!(o instanceof i))return new i(a);if(o.constructor=i,a instanceof i){o.s=a.s,o.e=a.e,o.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error(Up+a);if(a>0)o.s=1;else if(a<0)a=-a,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(a===~~a&&a<1e7){o.e=0,o.d=[a];return}return gB(o,a.toString())}else if(typeof a!="string")throw Error(Up+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,_ke.test(a))gB(o,a);else throw Error(Up+a)}if(i.prototype=In,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=eQ,i.config=i.set=Ske,e===void 0&&(e={}),e)for(r=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=i[t+1]&&r<=i[t+2])this[n]=r;else throw Error(Up+n+": "+r);if((r=e[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Up+n+": "+r);return this}var V4=eQ(Ake);Rl=new V4(1);const ui=V4;function tQ(e){var t;return e===0?t=1:t=Math.floor(new ui(e).abs().log(10).toNumber())+1,t}function nQ(e,t,n){for(var r=new ui(e),i=0,a=[];r.lt(t)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var rQ=e=>{var[t,n]=e,[r,i]=[t,n];return t>n&&([r,i]=[n,t]),[r,i]},F4=(e,t,n)=>{if(e.lte(0))return new ui(0);var r=tQ(e.toNumber()),i=new ui(10).pow(r),a=e.div(i),o=r!==1?.05:.1,c=new ui(Math.ceil(a.div(o).toNumber())).add(n).mul(o),h=c.mul(i);return t?new ui(h.toNumber()):new ui(Math.ceil(h.toNumber()))},iQ=(e,t,n)=>{var r;if(e.lte(0))return new ui(0);var i=[1,2,2.5,5],a=e.toNumber(),o=Math.floor(new ui(a).abs().log(10).toNumber()),c=new ui(10).pow(o),h=e.div(c).toNumber(),f=i.findIndex(A=>A>=h-1e-10);if(f===-1&&(c=c.mul(10),f=0),f+=n,f>=i.length){var m=Math.floor(f/i.length);f%=i.length,c=c.mul(new ui(10).pow(m))}var y=(r=i[f])!==null&&r!==void 0?r:1,w=new ui(y).mul(c);return t?w:new ui(Math.ceil(w.toNumber()))},kke=(e,t,n)=>{var r=new ui(1),i=new ui(e);if(!i.isint()&&n){var a=Math.abs(e);a<1?(r=new ui(10).pow(tQ(e)-1),i=new ui(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new ui(Math.floor(e)))}else e===0?i=new ui(Math.floor((t-1)/2)):n||(i=new ui(Math.floor(e)));for(var o=Math.floor((t-1)/2),c=[],h=0;h4&&arguments[4]!==void 0?arguments[4]:0,o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:F4;if(!Number.isFinite((n-t)/(r-1)))return{step:new ui(0),tickMin:new ui(0),tickMax:new ui(0)};var c=o(new ui(n).sub(t).div(r-1),i,a),h;t<=0&&n>=0?h=new ui(0):(h=new ui(t).add(n).div(2),h=h.sub(new ui(h).mod(c)));var f=Math.ceil(h.sub(t).div(c).toNumber()),m=Math.ceil(new ui(n).sub(h).div(c).toNumber()),y=f+m+1;return y>r?sQ(t,n,r,i,a+1,o):(y0?m+(r-y):m,f=n>0?f:f+(r-y)),{step:c,tickMin:h.sub(new ui(f).mul(c)),tickMax:h.add(new ui(m).mul(c))})},yB=function(t){var[n,r]=t,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"auto",c=Math.max(i,2),[h,f]=rQ([n,r]);if(h===-1/0||f===1/0){var m=f===1/0?[h,...Array(i-1).fill(1/0)]:[...Array(i-1).fill(-1/0),f];return n>r?m.reverse():m}if(h===f)return kke(h,i,a);var y=o==="snap125"?iQ:F4,{step:w,tickMin:A,tickMax:k}=sQ(h,f,c,a,0,y),I=nQ(A,k.add(new ui(.1).mul(w)),w);return n>r?I.reverse():I},bB=function(t,n){var[r,i]=t,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"auto",[c,h]=rQ([r,i]);if(c===-1/0||h===1/0)return[r,i];if(c===h)return[c];var f=o==="snap125"?iQ:F4,m=Math.max(n,2),y=f(new ui(h).sub(c).div(m-1),a,0),w=[...nQ(new ui(c),new ui(h),y),h];return a===!1&&(w=w.map(A=>Math.round(A))),r>i?w.reverse():w},aQ=e=>e.rootProps.maxBarSize,Cke=e=>e.rootProps.barGap,oQ=e=>e.rootProps.barCategoryGap,Ike=e=>e.rootProps.barSize,$E=e=>e.rootProps.stackOffset,lQ=e=>e.rootProps.reverseStackOrder,$4=e=>e.options.chartName,H4=e=>e.rootProps.syncId,cQ=e=>e.rootProps.syncMethod,G4=e=>e.options.eventEmitter,jke=e=>e.rootProps.baseValue,Sa={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Jf={allowDecimals:!1,allowDataOverflow:!1,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"auto"},lu={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,includeHidden:!1,radiusAxisId:0,reversed:!1,scale:"auto",tick:!0,tickCount:5,type:"auto"},HE=(e,t)=>{if(!(!e||!t))return e!=null&&e.reversed?[t[1],t[0]]:t};function GE(e,t,n){if(n!=="auto")return n;if(e!=null)return Gc(e,t)?"category":"number"}function vB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function eN(e){for(var t=1;t{if(t!=null)return e.polarAxis.angleAxis[t]},q4=et([Rke,CX],(e,t)=>{var n;if(e!=null)return e;var r=(n=GE(t,"angleAxis",wB.type))!==null&&n!==void 0?n:"category";return eN(eN({},wB),{},{type:r})}),Dke=(e,t)=>e.polarAxis.radiusAxis[t],W4=et([Dke,CX],(e,t)=>{var n;if(e!=null)return e;var r=(n=GE(t,"radiusAxis",NB.type))!==null&&n!==void 0?n:"category";return eN(eN({},NB),{},{type:r})}),qE=e=>e.polarOptions,K4=et([Qd,Zd,$a],ake),uQ=et([qE,K4],(e,t)=>{if(e!=null)return Fc(e.innerRadius,t,0)}),dQ=et([qE,K4],(e,t)=>{if(e!=null)return Fc(e.outerRadius,t,t*.8)}),Mke=e=>{if(e==null)return[0,0];var{startAngle:t,endAngle:n}=e;return[t,n]},hQ=et([qE],Mke);et([q4,hQ],HE);var fQ=et([K4,uQ,dQ],(e,t,n)=>{if(!(e==null||t==null||n==null))return[t,n]});et([W4,fQ],HE);var pQ=et([_i,qE,uQ,dQ,Qd,Zd],(e,t,n,r,i,a)=>{if(!(e!=="centric"&&e!=="radial"||t==null||n==null||r==null)){var{cx:o,cy:c,startAngle:h,endAngle:f}=t;return{cx:Fc(o,i,i/2),cy:Fc(c,a,a/2),innerRadius:n,outerRadius:r,startAngle:h,endAngle:f,clockWise:!1}}}),Ga=(e,t)=>t,WE=(e,t,n)=>n;function KE(e){return e==null?void 0:e.id}function mQ(e,t,n){var{chartData:r=[]}=t,{allowDuplicatedCategory:i,dataKey:a}=n,o=new Map;return e.forEach(c=>{var h,f=(h=c.data)!==null&&h!==void 0?h:r;if(!(f==null||f.length===0)){var m=KE(c);f.forEach((y,w)=>{var A=a==null||i?w:String(Ds(y,a,null)),k=Ds(y,c.dataKey,0),I;o.has(A)?I=o.get(A):I={},Object.assign(I,{[m]:k}),o.set(A,I)})}}),Array.from(o.values())}function YE(e){return"stackId"in e&&e.stackId!=null&&e.dataKey!=null}var XE=(e,t)=>e===t?!0:e==null||t==null?!1:e[0]===t[0]&&e[1]===t[1];function QE(e,t){return Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t}function Lke(e,t){if(e.length===t.length){for(var n=0;n{var t=_i(e);return t==="horizontal"?"xAxis":t==="vertical"?"yAxis":t==="centric"?"angleAxis":"radiusAxis"},zg=e=>e.tooltip.settings.axisId;function Y4(e){if(e!=null){var t=e.ticks,n=e.bandwidth,r=e.range(),i=[Math.min(...r),Math.max(...r)];return{domain:()=>e.domain(),range:(function(a){function o(){return a.apply(this,arguments)}return o.toString=function(){return a.toString()},o})(()=>i),rangeMin:()=>i[0],rangeMax:()=>i[1],isInRange(a){var o=i[0],c=i[1];return o<=c?a>=o&&a<=c:a>=c&&a<=o},bandwidth:n?()=>n.call(e):void 0,ticks:t?a=>t.call(e,a):void 0,map:(a,o)=>{var c=e(a);if(c!=null){if(e.bandwidth&&o!==null&&o!==void 0&&o.position){var h=e.bandwidth();switch(o.position){case"middle":c+=h/2;break;case"end":c+=h;break}}return c}}}}}var Uke=(e,t)=>{if(t!=null)switch(e){case"linear":{if(!Tu(t)){for(var n,r,i=0;ir)&&(r=a))}return n!==void 0&&r!==void 0?[n,r]:void 0}return t}default:return t}};function lf(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}function Bke(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function X4(e){let t,n,r;e.length!==2?(t=lf,n=(c,h)=>lf(e(c),h),r=(c,h)=>e(c)-h):(t=e===lf||e===Bke?e:zke,n=e,r=e);function i(c,h,f=0,m=c.length){if(f>>1;n(c[y],h)<0?f=y+1:m=y}while(f>>1;n(c[y],h)<=0?f=y+1:m=y}while(ff&&r(c[y-1],h)>-r(c[y],h)?y-1:y}return{left:i,center:o,right:a}}function zke(){return 0}function gQ(e){return e===null?NaN:+e}function*Vke(e,t){for(let n of e)n!=null&&(n=+n)>=n&&(yield n)}const Fke=X4(lf),Jy=Fke.right;X4(gQ).center;class EB extends Map{constructor(t,n=Gke){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[r,i]of t)this.set(r,i)}get(t){return super.get(AB(this,t))}has(t){return super.has(AB(this,t))}set(t,n){return super.set($ke(this,t),n)}delete(t){return super.delete(Hke(this,t))}}function AB({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function $ke({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function Hke({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function Gke(e){return e!==null&&typeof e=="object"?e.valueOf():e}function qke(e=lf){if(e===lf)return xQ;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,n)=>{const r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function xQ(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}const Wke=Math.sqrt(50),Kke=Math.sqrt(10),Yke=Math.sqrt(2);function tN(e,t,n){const r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),o=a>=Wke?10:a>=Kke?5:a>=Yke?2:1;let c,h,f;return i<0?(f=Math.pow(10,-i)/o,c=Math.round(e*f),h=Math.round(t*f),c/ft&&--h,f=-f):(f=Math.pow(10,i)*o,c=Math.round(e/f),h=Math.round(t/f),c*ft&&--h),h0))return[];if(e===t)return[e];const r=t=i))return[];const c=a-i+1,h=new Array(c);if(r)if(o<0)for(let f=0;f=r)&&(n=r);return n}function SB(e,t){let n;for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function yQ(e,t,n=0,r=1/0,i){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=t&&t<=r))return e;for(i=i===void 0?xQ:qke(i);r>n;){if(r-n>600){const h=r-n+1,f=t-n+1,m=Math.log(h),y=.5*Math.exp(2*m/3),w=.5*Math.sqrt(m*y*(h-y)/h)*(f-h/2<0?-1:1),A=Math.max(n,Math.floor(t-f*y/h+w)),k=Math.min(r,Math.floor(t+(h-f)*y/h+w));yQ(e,t,A,k,i)}const a=e[t];let o=n,c=r;for(qx(e,n,t),i(e[r],a)>0&&qx(e,n,r);o0;)--c}i(e[n],a)===0?qx(e,n,c):(++c,qx(e,c,r)),c<=t&&(n=c+1),t<=c&&(r=c-1)}return e}function qx(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Xke(e,t,n){if(e=Float64Array.from(Vke(e)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return SB(e);if(t>=1)return _B(e);var r,i=(r-1)*t,a=Math.floor(i),o=_B(yQ(e,a).subarray(0,a+1)),c=SB(e.subarray(a+1));return o+(c-o)*(i-a)}}function Qke(e,t,n=gQ){if(!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,a=Math.floor(i),o=+n(e[a],a,e),c=+n(e[a+1],a+1,e);return o+(c-o)*(i-a)}}function Zke(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=new Array(i);++r>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Vv(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Vv(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=tCe.exec(e))?new bl(t[1],t[2],t[3],1):(t=nCe.exec(e))?new bl(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=rCe.exec(e))?Vv(t[1],t[2],t[3],t[4]):(t=iCe.exec(e))?Vv(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=sCe.exec(e))?PB(t[1],t[2]/100,t[3]/100,1):(t=aCe.exec(e))?PB(t[1],t[2]/100,t[3]/100,t[4]):kB.hasOwnProperty(e)?jB(kB[e]):e==="transparent"?new bl(NaN,NaN,NaN,0):null}function jB(e){return new bl(e>>16&255,e>>8&255,e&255,1)}function Vv(e,t,n,r){return r<=0&&(e=t=n=NaN),new bl(e,t,n,r)}function cCe(e){return e instanceof eb||(e=fy(e)),e?(e=e.rgb(),new bl(e.r,e.g,e.b,e.opacity)):new bl}function RI(e,t,n,r){return arguments.length===1?cCe(e):new bl(e,t,n,r??1)}function bl(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}J4(bl,RI,vQ(eb,{brighter(e){return e=e==null?nN:Math.pow(nN,e),new bl(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?dy:Math.pow(dy,e),new bl(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new bl(Bp(this.r),Bp(this.g),Bp(this.b),rN(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:TB,formatHex:TB,formatHex8:uCe,formatRgb:OB,toString:OB}));function TB(){return`#${_p(this.r)}${_p(this.g)}${_p(this.b)}`}function uCe(){return`#${_p(this.r)}${_p(this.g)}${_p(this.b)}${_p((isNaN(this.opacity)?1:this.opacity)*255)}`}function OB(){const e=rN(this.opacity);return`${e===1?"rgb(":"rgba("}${Bp(this.r)}, ${Bp(this.g)}, ${Bp(this.b)}${e===1?")":`, ${e})`}`}function rN(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Bp(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function _p(e){return e=Bp(e),(e<16?"0":"")+e.toString(16)}function PB(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Dc(e,t,n,r)}function wQ(e){if(e instanceof Dc)return new Dc(e.h,e.s,e.l,e.opacity);if(e instanceof eb||(e=fy(e)),!e)return new Dc;if(e instanceof Dc)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,c=a-i,h=(a+i)/2;return c?(t===a?o=(n-r)/c+(n0&&h<1?0:o,new Dc(o,c,h,e.opacity)}function dCe(e,t,n,r){return arguments.length===1?wQ(e):new Dc(e,t,n,r??1)}function Dc(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}J4(Dc,dCe,vQ(eb,{brighter(e){return e=e==null?nN:Math.pow(nN,e),new Dc(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?dy:Math.pow(dy,e),new Dc(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new bl(K5(e>=240?e-240:e+120,i,r),K5(e,i,r),K5(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Dc(RB(this.h),Fv(this.s),Fv(this.l),rN(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=rN(this.opacity);return`${e===1?"hsl(":"hsla("}${RB(this.h)}, ${Fv(this.s)*100}%, ${Fv(this.l)*100}%${e===1?")":`, ${e})`}`}}));function RB(e){return e=(e||0)%360,e<0?e+360:e}function Fv(e){return Math.max(0,Math.min(1,e||0))}function K5(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const e3=e=>()=>e;function hCe(e,t){return function(n){return e+n*t}}function fCe(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function pCe(e){return(e=+e)==1?NQ:function(t,n){return n-t?fCe(t,n,e):e3(isNaN(t)?n:t)}}function NQ(e,t){var n=t-e;return n?hCe(e,n):e3(isNaN(e)?t:e)}const DB=(function e(t){var n=pCe(t);function r(i,a){var o=n((i=RI(i)).r,(a=RI(a)).r),c=n(i.g,a.g),h=n(i.b,a.b),f=NQ(i.opacity,a.opacity);return function(m){return i.r=o(m),i.g=c(m),i.b=h(m),i.opacity=f(m),i+""}}return r.gamma=e,r})(1);function mCe(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;in&&(a=t.slice(n,a),c[o]?c[o]+=a:c[++o]=a),(r=r[0])===(i=i[0])?c[o]?c[o]+=i:c[++o]=i:(c[++o]=null,h.push({i:o,x:iN(r,i)})),n=Y5.lastIndex;return nt&&(n=e,e=t,t=n),function(r){return Math.max(e,Math.min(t,r))}}function SCe(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i2?kCe:SCe,h=f=null,y}function y(w){return w==null||isNaN(w=+w)?a:(h||(h=c(e.map(r),t,n)))(r(o(w)))}return y.invert=function(w){return o(i((f||(f=c(t,e.map(r),iN)))(w)))},y.domain=function(w){return arguments.length?(e=Array.from(w,sN),m()):e.slice()},y.range=function(w){return arguments.length?(t=Array.from(w),m()):t.slice()},y.rangeRound=function(w){return t=Array.from(w),n=t3,m()},y.clamp=function(w){return arguments.length?(o=w?!0:Go,m()):o!==Go},y.interpolate=function(w){return arguments.length?(n=w,m()):n},y.unknown=function(w){return arguments.length?(a=w,y):a},function(w,A){return r=w,i=A,m()}}function n3(){return ZE()(Go,Go)}function CCe(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function aN(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function bg(e){return e=aN(Math.abs(e)),e?e[1]:NaN}function ICe(e,t){return function(n,r){for(var i=n.length,a=[],o=0,c=e[0],h=0;i>0&&c>0&&(h+c+1>r&&(c=Math.max(1,r-h)),a.push(n.substring(i-=c,i+c)),!((h+=c+1)>r));)c=e[o=(o+1)%e.length];return a.reverse().join(t)}}function jCe(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var TCe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function py(e){if(!(t=TCe.exec(e)))throw new Error("invalid format: "+e);var t;return new r3({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}py.prototype=r3.prototype;function r3(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}r3.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function OCe(e){e:for(var t=e.length,n=1,r=-1,i;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var oN;function PCe(e,t){var n=aN(e,t);if(!n)return oN=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(oN=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+aN(e,Math.max(0,t+a-1))[0]}function LB(e,t){var n=aN(e,t);if(!n)return e+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const UB={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:CCe,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>LB(e*100,t),r:LB,s:PCe,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function BB(e){return e}var zB=Array.prototype.map,VB=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function RCe(e){var t=e.grouping===void 0||e.thousands===void 0?BB:ICe(zB.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",i=e.decimal===void 0?".":e.decimal+"",a=e.numerals===void 0?BB:jCe(zB.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",c=e.minus===void 0?"−":e.minus+"",h=e.nan===void 0?"NaN":e.nan+"";function f(y,w){y=py(y);var A=y.fill,k=y.align,I=y.sign,T=y.symbol,D=y.zero,F=y.width,L=y.comma,q=y.precision,Z=y.trim,K=y.type;K==="n"?(L=!0,K="g"):UB[K]||(q===void 0&&(q=12),Z=!0,K="g"),(D||A==="0"&&k==="=")&&(D=!0,A="0",k="=");var z=(w&&w.prefix!==void 0?w.prefix:"")+(T==="$"?n:T==="#"&&/[boxX]/.test(K)?"0"+K.toLowerCase():""),B=(T==="$"?r:/[%p]/.test(K)?o:"")+(w&&w.suffix!==void 0?w.suffix:""),V=UB[K],$=/[defgprs%]/.test(K);q=q===void 0?6:/[gprs]/.test(K)?Math.max(1,Math.min(21,q)):Math.max(0,Math.min(20,q));function Q(Y){var G=z,he=B,te,le,ve;if(K==="c")he=V(Y)+he,Y="";else{Y=+Y;var ke=Y<0||1/Y<0;if(Y=isNaN(Y)?h:V(Math.abs(Y),q),Z&&(Y=OCe(Y)),ke&&+Y==0&&I!=="+"&&(ke=!1),G=(ke?I==="("?I:c:I==="-"||I==="("?"":I)+G,he=(K==="s"&&!isNaN(Y)&&oN!==void 0?VB[8+oN/3]:"")+he+(ke&&I==="("?")":""),$){for(te=-1,le=Y.length;++teve||ve>57){he=(ve===46?i+Y.slice(te+1):Y.slice(te))+he,Y=Y.slice(0,te);break}}}L&&!D&&(Y=t(Y,1/0));var Be=G.length+Y.length+he.length,J=Be>1)+G+Y+he+J.slice(Be);break;default:Y=J+G+Y+he;break}return a(Y)}return Q.toString=function(){return y+""},Q}function m(y,w){var A=Math.max(-8,Math.min(8,Math.floor(bg(w)/3)))*3,k=Math.pow(10,-A),I=f((y=py(y),y.type="f",y),{suffix:VB[8+A/3]});return function(T){return I(k*T)}}return{format:f,formatPrefix:m}}var $v,i3,EQ;DCe({thousands:",",grouping:[3],currency:["$",""]});function DCe(e){return $v=RCe(e),i3=$v.format,EQ=$v.formatPrefix,$v}function MCe(e){return Math.max(0,-bg(Math.abs(e)))}function LCe(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(bg(t)/3)))*3-bg(Math.abs(e)))}function UCe(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,bg(t)-bg(e))+1}function AQ(e,t,n,r){var i=OI(e,t,n),a;switch(r=py(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=LCe(i,o))&&(r.precision=a),EQ(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=UCe(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=MCe(i))&&(r.precision=a-(r.type==="%")*2);break}}return i3(r)}function Of(e){var t=e.domain;return e.ticks=function(n){var r=t();return jI(r[0],r[r.length-1],n??10)},e.tickFormat=function(n,r){var i=t();return AQ(i[0],i[i.length-1],n??10,r)},e.nice=function(n){n==null&&(n=10);var r=t(),i=0,a=r.length-1,o=r[i],c=r[a],h,f,m=10;for(c0;){if(f=TI(o,c,n),f===h)return r[i]=o,r[a]=c,t(r);if(f>0)o=Math.floor(o/f)*f,c=Math.ceil(c/f)*f;else if(f<0)o=Math.ceil(o*f)/f,c=Math.floor(c*f)/f;else break;h=f}return e},e}function _Q(){var e=n3();return e.copy=function(){return tb(e,_Q())},pc.apply(e,arguments),Of(e)}function SQ(e){var t;function n(r){return r==null||isNaN(r=+r)?t:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(e=Array.from(r,sN),n):e.slice()},n.unknown=function(r){return arguments.length?(t=r,n):t},n.copy=function(){return SQ(e).unknown(t)},e=arguments.length?Array.from(e,sN):[0,1],Of(n)}function kQ(e,t){e=e.slice();var n=0,r=e.length-1,i=e[n],a=e[r],o;return aMath.pow(e,t)}function $Ce(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function HB(e){return(t,n)=>-e(-t,n)}function s3(e){const t=e(FB,$B),n=t.domain;let r=10,i,a;function o(){return i=$Ce(r),a=FCe(r),n()[0]<0?(i=HB(i),a=HB(a),e(BCe,zCe)):e(FB,$B),t}return t.base=function(c){return arguments.length?(r=+c,o()):r},t.domain=function(c){return arguments.length?(n(c),o()):n()},t.ticks=c=>{const h=n();let f=h[0],m=h[h.length-1];const y=m0){for(;w<=A;++w)for(k=1;km)break;D.push(I)}}else for(;w<=A;++w)for(k=r-1;k>=1;--k)if(I=w>0?k/a(-w):k*a(w),!(Im)break;D.push(I)}D.length*2{if(c==null&&(c=10),h==null&&(h=r===10?"s":","),typeof h!="function"&&(!(r%1)&&(h=py(h)).precision==null&&(h.trim=!0),h=i3(h)),c===1/0)return h;const f=Math.max(1,r*c/t.ticks().length);return m=>{let y=m/a(Math.round(i(m)));return y*rn(kQ(n(),{floor:c=>a(Math.floor(i(c))),ceil:c=>a(Math.ceil(i(c)))})),t}function CQ(){const e=s3(ZE()).domain([1,10]);return e.copy=()=>tb(e,CQ()).base(e.base()),pc.apply(e,arguments),e}function GB(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function qB(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function a3(e){var t=1,n=e(GB(t),qB(t));return n.constant=function(r){return arguments.length?e(GB(t=+r),qB(t)):t},Of(n)}function IQ(){var e=a3(ZE());return e.copy=function(){return tb(e,IQ()).constant(e.constant())},pc.apply(e,arguments)}function WB(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function HCe(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function GCe(e){return e<0?-e*e:e*e}function o3(e){var t=e(Go,Go),n=1;function r(){return n===1?e(Go,Go):n===.5?e(HCe,GCe):e(WB(n),WB(1/n))}return t.exponent=function(i){return arguments.length?(n=+i,r()):n},Of(t)}function l3(){var e=o3(ZE());return e.copy=function(){return tb(e,l3()).exponent(e.exponent())},pc.apply(e,arguments),e}function qCe(){return l3.apply(null,arguments).exponent(.5)}function KB(e){return Math.sign(e)*e*e}function WCe(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function jQ(){var e=n3(),t=[0,1],n=!1,r;function i(a){var o=WCe(e(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return e.invert(KB(a))},i.domain=function(a){return arguments.length?(e.domain(a),i):e.domain()},i.range=function(a){return arguments.length?(e.range((t=Array.from(a,sN)).map(KB)),i):t.slice()},i.rangeRound=function(a){return i.range(a).round(!0)},i.round=function(a){return arguments.length?(n=!!a,i):n},i.clamp=function(a){return arguments.length?(e.clamp(a),i):e.clamp()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return jQ(e.domain(),t).round(n).clamp(e.clamp()).unknown(r)},pc.apply(i,arguments),Of(i)}function TQ(){var e=[],t=[],n=[],r;function i(){var o=0,c=Math.max(1,t.length);for(n=new Array(c-1);++o0?n[c-1]:e[0],c=n?[r[n-1],t]:[r[f-1],r[f]]},o.unknown=function(h){return arguments.length&&(a=h),o},o.thresholds=function(){return r.slice()},o.copy=function(){return OQ().domain([e,t]).range(i).unknown(a)},pc.apply(Of(o),arguments)}function PQ(){var e=[.5],t=[0,1],n,r=1;function i(a){return a!=null&&a<=a?t[Jy(e,a,0,r)]:n}return i.domain=function(a){return arguments.length?(e=Array.from(a),r=Math.min(e.length,t.length-1),i):e.slice()},i.range=function(a){return arguments.length?(t=Array.from(a),r=Math.min(e.length,t.length-1),i):t.slice()},i.invertExtent=function(a){var o=t.indexOf(a);return[e[o-1],e[o]]},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return PQ().domain(e).range(t).unknown(n)},pc.apply(i,arguments)}const X5=new Date,Q5=new Date;function ja(e,t,n,r){function i(a){return e(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(e(a=new Date(+a)),a),i.ceil=a=>(e(a=new Date(a-1)),t(a,1),e(a),a),i.round=a=>{const o=i(a),c=i.ceil(a);return a-o(t(a=new Date(+a),o==null?1:Math.floor(o)),a),i.range=(a,o,c)=>{const h=[];if(a=i.ceil(a),c=c==null?1:Math.floor(c),!(a0))return h;let f;do h.push(f=new Date(+a)),t(a,c),e(a);while(fja(o=>{if(o>=o)for(;e(o),!a(o);)o.setTime(o-1)},(o,c)=>{if(o>=o)if(c<0)for(;++c<=0;)for(;t(o,-1),!a(o););else for(;--c>=0;)for(;t(o,1),!a(o););}),n&&(i.count=(a,o)=>(X5.setTime(+a),Q5.setTime(+o),e(X5),e(Q5),Math.floor(n(X5,Q5))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?o=>r(o)%a===0:o=>i.count(0,o)%a===0):i)),i}const lN=ja(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);lN.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?ja(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):lN);lN.range;const jd=1e3,cc=jd*60,Td=cc*60,Hd=Td*24,c3=Hd*7,YB=Hd*30,Z5=Hd*365,Sp=ja(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*jd)},(e,t)=>(t-e)/jd,e=>e.getUTCSeconds());Sp.range;const u3=ja(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*jd)},(e,t)=>{e.setTime(+e+t*cc)},(e,t)=>(t-e)/cc,e=>e.getMinutes());u3.range;const d3=ja(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*cc)},(e,t)=>(t-e)/cc,e=>e.getUTCMinutes());d3.range;const h3=ja(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*jd-e.getMinutes()*cc)},(e,t)=>{e.setTime(+e+t*Td)},(e,t)=>(t-e)/Td,e=>e.getHours());h3.range;const f3=ja(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*Td)},(e,t)=>(t-e)/Td,e=>e.getUTCHours());f3.range;const nb=ja(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*cc)/Hd,e=>e.getDate()-1);nb.range;const JE=ja(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Hd,e=>e.getUTCDate()-1);JE.range;const RQ=ja(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Hd,e=>Math.floor(e/Hd));RQ.range;function bm(e){return ja(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,n)=>{t.setDate(t.getDate()+n*7)},(t,n)=>(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*cc)/c3)}const eA=bm(0),cN=bm(1),KCe=bm(2),YCe=bm(3),vg=bm(4),XCe=bm(5),QCe=bm(6);eA.range;cN.range;KCe.range;YCe.range;vg.range;XCe.range;QCe.range;function vm(e){return ja(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCDate(t.getUTCDate()+n*7)},(t,n)=>(n-t)/c3)}const tA=vm(0),uN=vm(1),ZCe=vm(2),JCe=vm(3),wg=vm(4),eIe=vm(5),tIe=vm(6);tA.range;uN.range;ZCe.range;JCe.range;wg.range;eIe.range;tIe.range;const p3=ja(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());p3.range;const m3=ja(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());m3.range;const Gd=ja(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());Gd.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:ja(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)});Gd.range;const qd=ja(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());qd.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:ja(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)});qd.range;function DQ(e,t,n,r,i,a){const o=[[Sp,1,jd],[Sp,5,5*jd],[Sp,15,15*jd],[Sp,30,30*jd],[a,1,cc],[a,5,5*cc],[a,15,15*cc],[a,30,30*cc],[i,1,Td],[i,3,3*Td],[i,6,6*Td],[i,12,12*Td],[r,1,Hd],[r,2,2*Hd],[n,1,c3],[t,1,YB],[t,3,3*YB],[e,1,Z5]];function c(f,m,y){const w=mT).right(o,w);if(A===o.length)return e.every(OI(f/Z5,m/Z5,y));if(A===0)return lN.every(Math.max(OI(f,m,y),1));const[k,I]=o[w/o[A-1][2]53)return null;"w"in dt||(dt.w=1),"Z"in dt?(pn=ek(Wx(dt.y,0,1)),Fn=pn.getUTCDay(),pn=Fn>4||Fn===0?uN.ceil(pn):uN(pn),pn=JE.offset(pn,(dt.V-1)*7),dt.y=pn.getUTCFullYear(),dt.m=pn.getUTCMonth(),dt.d=pn.getUTCDate()+(dt.w+6)%7):(pn=J5(Wx(dt.y,0,1)),Fn=pn.getDay(),pn=Fn>4||Fn===0?cN.ceil(pn):cN(pn),pn=nb.offset(pn,(dt.V-1)*7),dt.y=pn.getFullYear(),dt.m=pn.getMonth(),dt.d=pn.getDate()+(dt.w+6)%7)}else("W"in dt||"U"in dt)&&("w"in dt||(dt.w="u"in dt?dt.u%7:"W"in dt?1:0),Fn="Z"in dt?ek(Wx(dt.y,0,1)).getUTCDay():J5(Wx(dt.y,0,1)).getDay(),dt.m=0,dt.d="W"in dt?(dt.w+6)%7+dt.W*7-(Fn+5)%7:dt.w+dt.U*7-(Fn+6)%7);return"Z"in dt?(dt.H+=dt.Z/100|0,dt.M+=dt.Z%100,ek(dt)):J5(dt)}}function B(ht,Ye,Yt,dt){for(var sn=0,pn=Ye.length,Fn=Yt.length,Ft,Dt;sn=Fn)return-1;if(Ft=Ye.charCodeAt(sn++),Ft===37){if(Ft=Ye.charAt(sn++),Dt=Z[Ft in XB?Ye.charAt(sn++):Ft],!Dt||(dt=Dt(ht,Yt,dt))<0)return-1}else if(Ft!=Yt.charCodeAt(dt++))return-1}return dt}function V(ht,Ye,Yt){var dt=f.exec(Ye.slice(Yt));return dt?(ht.p=m.get(dt[0].toLowerCase()),Yt+dt[0].length):-1}function $(ht,Ye,Yt){var dt=A.exec(Ye.slice(Yt));return dt?(ht.w=k.get(dt[0].toLowerCase()),Yt+dt[0].length):-1}function Q(ht,Ye,Yt){var dt=y.exec(Ye.slice(Yt));return dt?(ht.w=w.get(dt[0].toLowerCase()),Yt+dt[0].length):-1}function Y(ht,Ye,Yt){var dt=D.exec(Ye.slice(Yt));return dt?(ht.m=F.get(dt[0].toLowerCase()),Yt+dt[0].length):-1}function G(ht,Ye,Yt){var dt=I.exec(Ye.slice(Yt));return dt?(ht.m=T.get(dt[0].toLowerCase()),Yt+dt[0].length):-1}function he(ht,Ye,Yt){return B(ht,t,Ye,Yt)}function te(ht,Ye,Yt){return B(ht,n,Ye,Yt)}function le(ht,Ye,Yt){return B(ht,r,Ye,Yt)}function ve(ht){return o[ht.getDay()]}function ke(ht){return a[ht.getDay()]}function Be(ht){return h[ht.getMonth()]}function J(ht){return c[ht.getMonth()]}function ie(ht){return i[+(ht.getHours()>=12)]}function xe(ht){return 1+~~(ht.getMonth()/3)}function ae(ht){return o[ht.getUTCDay()]}function Fe(ht){return a[ht.getUTCDay()]}function pt(ht){return h[ht.getUTCMonth()]}function Ue(ht){return c[ht.getUTCMonth()]}function Ct(ht){return i[+(ht.getUTCHours()>=12)]}function Tt(ht){return 1+~~(ht.getUTCMonth()/3)}return{format:function(ht){var Ye=K(ht+="",L);return Ye.toString=function(){return ht},Ye},parse:function(ht){var Ye=z(ht+="",!1);return Ye.toString=function(){return ht},Ye},utcFormat:function(ht){var Ye=K(ht+="",q);return Ye.toString=function(){return ht},Ye},utcParse:function(ht){var Ye=z(ht+="",!0);return Ye.toString=function(){return ht},Ye}}}var XB={"-":"",_:" ",0:"0"},Wa=/^\s*\d+/,oIe=/^%/,lIe=/[\\^$*+?|[\]().{}]/g;function Ai(e,t,n){var r=e<0?"-":"",i=(r?-e:e)+"",a=i.length;return r+(a[t.toLowerCase(),n]))}function uIe(e,t,n){var r=Wa.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function dIe(e,t,n){var r=Wa.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function hIe(e,t,n){var r=Wa.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function fIe(e,t,n){var r=Wa.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function pIe(e,t,n){var r=Wa.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function QB(e,t,n){var r=Wa.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function ZB(e,t,n){var r=Wa.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function mIe(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function gIe(e,t,n){var r=Wa.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function xIe(e,t,n){var r=Wa.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function JB(e,t,n){var r=Wa.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function yIe(e,t,n){var r=Wa.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function ez(e,t,n){var r=Wa.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function bIe(e,t,n){var r=Wa.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function vIe(e,t,n){var r=Wa.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function wIe(e,t,n){var r=Wa.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function NIe(e,t,n){var r=Wa.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function EIe(e,t,n){var r=oIe.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function AIe(e,t,n){var r=Wa.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function _Ie(e,t,n){var r=Wa.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function tz(e,t){return Ai(e.getDate(),t,2)}function SIe(e,t){return Ai(e.getHours(),t,2)}function kIe(e,t){return Ai(e.getHours()%12||12,t,2)}function CIe(e,t){return Ai(1+nb.count(Gd(e),e),t,3)}function MQ(e,t){return Ai(e.getMilliseconds(),t,3)}function IIe(e,t){return MQ(e,t)+"000"}function jIe(e,t){return Ai(e.getMonth()+1,t,2)}function TIe(e,t){return Ai(e.getMinutes(),t,2)}function OIe(e,t){return Ai(e.getSeconds(),t,2)}function PIe(e){var t=e.getDay();return t===0?7:t}function RIe(e,t){return Ai(eA.count(Gd(e)-1,e),t,2)}function LQ(e){var t=e.getDay();return t>=4||t===0?vg(e):vg.ceil(e)}function DIe(e,t){return e=LQ(e),Ai(vg.count(Gd(e),e)+(Gd(e).getDay()===4),t,2)}function MIe(e){return e.getDay()}function LIe(e,t){return Ai(cN.count(Gd(e)-1,e),t,2)}function UIe(e,t){return Ai(e.getFullYear()%100,t,2)}function BIe(e,t){return e=LQ(e),Ai(e.getFullYear()%100,t,2)}function zIe(e,t){return Ai(e.getFullYear()%1e4,t,4)}function VIe(e,t){var n=e.getDay();return e=n>=4||n===0?vg(e):vg.ceil(e),Ai(e.getFullYear()%1e4,t,4)}function FIe(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+Ai(t/60|0,"0",2)+Ai(t%60,"0",2)}function nz(e,t){return Ai(e.getUTCDate(),t,2)}function $Ie(e,t){return Ai(e.getUTCHours(),t,2)}function HIe(e,t){return Ai(e.getUTCHours()%12||12,t,2)}function GIe(e,t){return Ai(1+JE.count(qd(e),e),t,3)}function UQ(e,t){return Ai(e.getUTCMilliseconds(),t,3)}function qIe(e,t){return UQ(e,t)+"000"}function WIe(e,t){return Ai(e.getUTCMonth()+1,t,2)}function KIe(e,t){return Ai(e.getUTCMinutes(),t,2)}function YIe(e,t){return Ai(e.getUTCSeconds(),t,2)}function XIe(e){var t=e.getUTCDay();return t===0?7:t}function QIe(e,t){return Ai(tA.count(qd(e)-1,e),t,2)}function BQ(e){var t=e.getUTCDay();return t>=4||t===0?wg(e):wg.ceil(e)}function ZIe(e,t){return e=BQ(e),Ai(wg.count(qd(e),e)+(qd(e).getUTCDay()===4),t,2)}function JIe(e){return e.getUTCDay()}function eje(e,t){return Ai(uN.count(qd(e)-1,e),t,2)}function tje(e,t){return Ai(e.getUTCFullYear()%100,t,2)}function nje(e,t){return e=BQ(e),Ai(e.getUTCFullYear()%100,t,2)}function rje(e,t){return Ai(e.getUTCFullYear()%1e4,t,4)}function ije(e,t){var n=e.getUTCDay();return e=n>=4||n===0?wg(e):wg.ceil(e),Ai(e.getUTCFullYear()%1e4,t,4)}function sje(){return"+0000"}function rz(){return"%"}function iz(e){return+e}function sz(e){return Math.floor(+e/1e3)}var d0,zQ,VQ;aje({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function aje(e){return d0=aIe(e),zQ=d0.format,d0.parse,VQ=d0.utcFormat,d0.utcParse,d0}function oje(e){return new Date(e)}function lje(e){return e instanceof Date?+e:+new Date(+e)}function g3(e,t,n,r,i,a,o,c,h,f){var m=n3(),y=m.invert,w=m.domain,A=f(".%L"),k=f(":%S"),I=f("%I:%M"),T=f("%I %p"),D=f("%a %d"),F=f("%b %d"),L=f("%B"),q=f("%Y");function Z(K){return(h(K)t(i/(e.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,a)=>Xke(e,a/r))},n.copy=function(){return GQ(t).domain(e)},Jd.apply(n,arguments)}function rA(){var e=0,t=.5,n=1,r=1,i,a,o,c,h,f=Go,m,y=!1,w;function A(I){return isNaN(I=+I)?w:(I=.5+((I=+m(I))-a)*(r*I{if(e!=null){var{scale:r,type:i}=e;if(r==="auto")return i==="category"&&n&&(n.indexOf("LineChart")>=0||n.indexOf("AreaChart")>=0||n.indexOf("ComposedChart")>=0&&!t)?"point":i==="category"?"band":"linear";if(typeof r=="string")return mje(r)?r:"point"}};function gje(e,t){for(var n=0,r=e.length,i=e[0]t)?n=a+1:r=a}return n}function QQ(e,t){if(e){var n=t??e.domain(),r=n.map(a=>{var o;return(o=e(a))!==null&&o!==void 0?o:0}),i=e.range();if(!(n.length===0||i.length<2))return a=>{var o,c,h=gje(r,a);if(h<=0)return n[0];if(h>=n.length)return n[n.length-1];var f=(o=r[h-1])!==null&&o!==void 0?o:0,m=(c=r[h])!==null&&c!==void 0?c:0;return Math.abs(a-f)<=Math.abs(a-m)?n[h-1]:n[h]}}}function xje(e){if(e!=null)return"invert"in e&&typeof e.invert=="function"?e.invert.bind(e):QQ(e,void 0)}function oz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function dN(e){for(var t=1;te.cartesianAxis.xAxis[t],eh=(e,t)=>{var n=ZQ(e,t);return n??wa},Na={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:LI,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"left",padding:{top:0,bottom:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"number",unit:void 0,niceTicks:"auto",width:qy},JQ=(e,t)=>e.cartesianAxis.yAxis[t],th=(e,t)=>{var n=JQ(e,t);return n??Na},wje={domain:[0,"auto"],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:"",range:[64,64],scale:"auto",type:"number",unit:""},v3=(e,t)=>{var n=e.cartesianAxis.zAxis[t];return n??wje},Xo=(e,t,n)=>{switch(t){case"xAxis":return eh(e,n);case"yAxis":return th(e,n);case"zAxis":return v3(e,n);case"angleAxis":return q4(e,n);case"radiusAxis":return W4(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},Nje=(e,t,n)=>{switch(t){case"xAxis":return eh(e,n);case"yAxis":return th(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},rb=(e,t,n)=>{switch(t){case"xAxis":return eh(e,n);case"yAxis":return th(e,n);case"angleAxis":return q4(e,n);case"radiusAxis":return W4(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},eZ=e=>e.graphicalItems.cartesianItems.some(t=>t.type==="bar")||e.graphicalItems.polarItems.some(t=>t.type==="radialBar");function tZ(e,t){return n=>{switch(e){case"xAxis":return"xAxisId"in n&&n.xAxisId===t;case"yAxis":return"yAxisId"in n&&n.yAxisId===t;case"zAxis":return"zAxisId"in n&&n.zAxisId===t;case"angleAxis":return"angleAxisId"in n&&n.angleAxisId===t;case"radiusAxis":return"radiusAxisId"in n&&n.radiusAxisId===t;default:return!1}}}var ib=e=>e.graphicalItems.cartesianItems,Eje=et([Ga,WE],tZ),nZ=(e,t,n)=>e.filter(n).filter(r=>(t==null?void 0:t.includeHidden)===!0?!0:!r.hide),Fg=et([ib,Xo,Eje],nZ,{memoizeOptions:{resultEqualityCheck:QE}}),rZ=et([Fg],e=>e.filter(t=>t.type==="area"||t.type==="bar").filter(YE)),iZ=e=>e.filter(t=>!("stackId"in t)||t.stackId===void 0),Aje=et([Fg],iZ),sZ=e=>e.map(t=>t.data).filter(Boolean).flat(1),_je=et([Fg],e=>e.some(t=>!t.data)),aZ=et([Fg],sZ,{memoizeOptions:{resultEqualityCheck:QE}}),oZ=(e,t)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=t;return e.length>0?e:n.slice(r,i+1)},w3=et([aZ,Zy],oZ),Sje=(e,t,n)=>(t==null?void 0:t.dataKey)!=null?e.map(r=>({value:Ds(r,t.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>e.map(i=>({value:Ds(i,r)}))):e.map(r=>({value:r})),lZ=(e,t,n,r,i,a)=>{var{chartData:o=[],dataStartIndex:c,dataEndIndex:h}=r,f=Sje(e,t,n);if(i&&(t==null?void 0:t.dataKey)!=null&&a.length>0){var m=o.slice(c,h+1),y=m.map(w=>({value:Ds(w,t.dataKey)})).filter(w=>w.value!=null);return[...y,...f]}return f},sb=et([w3,Xo,Fg,Zy,_je,aZ],lZ);function $0(e){if(Uu(e)||e instanceof Date){var t=Number(e);if(qr(t))return t}}function lz(e){if(Array.isArray(e)){var t=[$0(e[0]),$0(e[1])];return Tu(t)?t:void 0}var n=$0(e);if(n!=null)return[n,n]}function Vu(e){return e.map($0).filter(yl)}function kje(e,t){var n=$0(e),r=$0(t);return n==null&&r==null?0:n==null?-1:r==null?1:n-r}var Cje=et([sb],e=>e==null?void 0:e.map(t=>t.value).sort(kje));function cZ(e,t){switch(e){case"xAxis":return t.direction==="x";case"yAxis":return t.direction==="y";default:return!1}}function Ije(e,t,n){if(!n)return[];if(!n.length)return[];var r;if(typeof t=="number"&&!Vc(t))r=t;else if(Array.isArray(t)){var i=Vu(t);i.length>0&&(r=Math.max(...i))}return r==null?[]:Vu(n.flatMap(a=>{var o=Ds(e,a.dataKey),c,h;if(Array.isArray(o)?[c,h]=o:c=h=o,!(!qr(c)||!qr(h)))return[r-c,r+h]}))}var Ta=e=>{var t=qa(e),n=zg(e);return rb(e,t,n)},Ng=et([Ta],e=>e==null?void 0:e.dataKey),jje=et([rZ,Zy,Ta],mQ),uZ=(e,t,n,r)=>{var i={},a=t.reduce((o,c)=>{if(c.stackId==null)return o;var h=o[c.stackId];return h==null&&(h=[]),h.push(c),o[c.stackId]=h,o},i);return Object.fromEntries(Object.entries(a).map(o=>{var[c,h]=o,f=r?[...h].reverse():h,m=f.map(KE);return[c,{stackedData:f_e(e,m,n),graphicalItems:f}]}))},hN=et([jje,rZ,$E,lQ],uZ),dZ=(e,t,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=t;if(r==null&&n!=="zAxis"){var o=x_e(e,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},Tje=et([Xo],e=>e.allowDataOverflow),N3=e=>{var t;if(e==null||!("domain"in e))return LI;if(e.domain!=null)return e.domain;if("ticks"in e&&e.ticks!=null){if(e.type==="number"){var n=Vu(e.ticks);return[Math.min(...n),Math.max(...n)]}if(e.type==="category")return e.ticks.map(String)}return(t=e==null?void 0:e.domain)!==null&&t!==void 0?t:LI},hZ=et([Xo],N3),fZ=et([hZ,Tje],YX),Oje=et([hN,qc,Ga,fZ],dZ,{memoizeOptions:{resultEqualityCheck:XE}}),E3=e=>e.errorBars,Pje=(e,t,n)=>e.flatMap(r=>t[r.id]).filter(Boolean).filter(r=>cZ(n,r)),fN=function(){for(var t=arguments.length,n=new Array(t),r=0;r5&&arguments[5]!==void 0?arguments[5]:[],c,h;if(r.length>0&&r.forEach(f=>{var m,y=f.data!=null?[...f.data]:o,w=(m=i[f.id])===null||m===void 0?void 0:m.filter(A=>cZ(a,A));y.forEach(A=>{var k,I=Ds(A,(k=n.dataKey)!==null&&k!==void 0?k:f.dataKey),T=Ije(A,I,w);if(T.length>=2){var D=Math.min(...T),F=Math.max(...T);(c==null||Dh)&&(h=F)}var L=lz(I);L!=null&&(c=c==null?L[0]:Math.min(c,L[0]),h=h==null?L[1]:Math.max(h,L[1]))})}),(n==null?void 0:n.dataKey)!=null&&r.length===0&&t.forEach(f=>{var m=lz(Ds(f,n.dataKey));m!=null&&(c=c==null?m[0]:Math.min(c,m[0]),h=h==null?m[1]:Math.max(h,m[1]))}),qr(c)&&qr(h))return[c,h]},Rje=et([w3,Xo,Aje,E3,Ga,wke],pZ,{memoizeOptions:{resultEqualityCheck:XE}});function Dje(e){var{value:t}=e;if(Uu(t)||t instanceof Date)return t}var Mje=(e,t,n)=>{var r=e.map(Dje).filter(i=>i!=null);return n&&(t.dataKey==null||t.allowDuplicatedCategory&&AY(r))?WX(0,e.length):t.allowDuplicatedCategory?r:Array.from(new Set(r))},mZ=e=>e.referenceElements.dots,$g=(e,t,n)=>e.filter(r=>r.ifOverflow==="extendDomain").filter(r=>t==="xAxis"?r.xAxisId===n:r.yAxisId===n),Lje=et([mZ,Ga,WE],$g),gZ=e=>e.referenceElements.areas,Uje=et([gZ,Ga,WE],$g),xZ=e=>e.referenceElements.lines,Bje=et([xZ,Ga,WE],$g),yZ=(e,t)=>{if(e!=null){var n=Vu(e.map(r=>t==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},zje=et(Lje,Ga,yZ),bZ=(e,t)=>{if(e!=null){var n=Vu(e.flatMap(r=>[t==="xAxis"?r.x1:r.y1,t==="xAxis"?r.x2:r.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},Vje=et([Uje,Ga],bZ);function Fje(e){var t;if(e.x!=null)return Vu([e.x]);var n=(t=e.segment)===null||t===void 0?void 0:t.map(r=>r.x);return n==null||n.length===0?[]:Vu(n)}function $je(e){var t;if(e.y!=null)return Vu([e.y]);var n=(t=e.segment)===null||t===void 0?void 0:t.map(r=>r.y);return n==null||n.length===0?[]:Vu(n)}var vZ=(e,t)=>{if(e!=null){var n=e.flatMap(r=>t==="xAxis"?Fje(r):$je(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},Hje=et([Bje,Ga],vZ),Gje=et(zje,Hje,Vje,(e,t,n)=>fN(e,n,t)),wZ=(e,t,n,r,i,a,o,c)=>{if(n!=null)return n;var h=o==="vertical"&&c==="xAxis"||o==="horizontal"&&c==="yAxis",f=h?fN(r,a,i):fN(a,i);return Eke(t,f,e.allowDataOverflow)},qje=et([Xo,hZ,fZ,Oje,Rje,Gje,_i,Ga],wZ,{memoizeOptions:{resultEqualityCheck:XE}}),Wje=[0,1],NZ=(e,t,n,r,i,a,o)=>{if(!((e==null||n==null||n.length===0)&&o===void 0)){var{dataKey:c,type:h}=e,f=Gc(t,a);if(f&&c==null){var m;return WX(0,(m=n==null?void 0:n.length)!==null&&m!==void 0?m:0)}return h==="category"?Mje(r,e,f):i==="expand"&&!f?Wje:o}},A3=et([Xo,_i,w3,sb,$E,Ga,qje],NZ),Hg=et([Xo,eZ,$4],XQ),EZ=(e,t,n)=>{var{niceTicks:r}=t;if(r!=="none"){var i=N3(t),a=Array.isArray(i)&&(i[0]==="auto"||i[1]==="auto");if((r==="snap125"||r==="adaptive")&&t!=null&&t.tickCount&&Tu(e)){if(a)return yB(e,t.tickCount,t.allowDecimals,r);if(t.type==="number")return bB(e,t.tickCount,t.allowDecimals,r)}if(r==="auto"&&n==="linear"&&t!=null&&t.tickCount){if(a&&Tu(e))return yB(e,t.tickCount,t.allowDecimals,"adaptive");if(t.type==="number"&&Tu(e))return bB(e,t.tickCount,t.allowDecimals,"adaptive")}}},_3=et([A3,rb,Hg],EZ),AZ=(e,t,n,r)=>{if(r!=="angleAxis"&&(e==null?void 0:e.type)==="number"&&Tu(t)&&Array.isArray(n)&&n.length>0){var i,a,o=t[0],c=(i=n[0])!==null&&i!==void 0?i:0,h=t[1],f=(a=n[n.length-1])!==null&&a!==void 0?a:0;return[Math.min(o,c),Math.max(h,f)]}return t},Kje=et([Xo,A3,_3,Ga],AZ),Yje=et(sb,Xo,(e,t)=>{if(!(!t||t.type!=="number")){var n=1/0,r=Array.from(Vu(e.map(y=>y.value))).sort((y,w)=>y-w),i=r[0],a=r[r.length-1];if(i==null||a==null)return 1/0;var o=a-i;if(o===0)return 1/0;for(var c=0;ci,(e,t,n,r,i)=>{if(!qr(e))return 0;var a=t==="vertical"?r.height:r.width;if(i==="gap")return e*a/2;if(i==="no-gap"){var o=Fc(n,e*a),c=e*a/2;return c-o-(c-o)/a*o}return 0}),Xje=(e,t,n)=>{var r=eh(e,t);return r==null||typeof r.padding!="string"?0:_Z(e,"xAxis",t,n,r.padding)},Qje=(e,t,n)=>{var r=th(e,t);return r==null||typeof r.padding!="string"?0:_Z(e,"yAxis",t,n,r.padding)},Zje=et(eh,Xje,(e,t)=>{var n,r;if(e==null)return{left:0,right:0};var{padding:i}=e;return typeof i=="string"?{left:t,right:t}:{left:((n=i.left)!==null&&n!==void 0?n:0)+t,right:((r=i.right)!==null&&r!==void 0?r:0)+t}}),Jje=et(th,Qje,(e,t)=>{var n,r;if(e==null)return{top:0,bottom:0};var{padding:i}=e;return typeof i=="string"?{top:t,bottom:t}:{top:((n=i.top)!==null&&n!==void 0?n:0)+t,bottom:((r=i.bottom)!==null&&r!==void 0?r:0)+t}}),eTe=et([$a,Zje,UE,LE,(e,t,n)=>n],(e,t,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[e.left+t.left,e.left+e.width-t.right]}),tTe=et([$a,_i,Jje,UE,LE,(e,t,n)=>n],(e,t,n,r,i,a)=>{var{padding:o}=i;return a?[r.height-o.bottom,o.top]:t==="horizontal"?[e.top+e.height-n.bottom,e.top+n.top]:[e.top+n.top,e.top+e.height-n.bottom]}),ab=(e,t,n,r)=>{var i;switch(t){case"xAxis":return eTe(e,n,r);case"yAxis":return tTe(e,n,r);case"zAxis":return(i=v3(e,n))===null||i===void 0?void 0:i.range;case"angleAxis":return hQ(e);case"radiusAxis":return fQ(e,n);default:return}},SZ=et([Xo,ab],HE),nTe=et([Hg,Kje],Uke),S3=et([Xo,Hg,nTe,SZ],b3),kZ=(e,t,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=Gc(e,r);if(o&&(i==="number"||a!=="auto"))return t.map(c=>c.value)}},k3=et([_i,sb,rb,Ga],kZ),iA=et([S3],Y4);et([S3],xje);et([S3,Cje],QQ);et([Fg,E3,Ga],Pje);function CZ(e,t){return e.idt.id?1:0}var sA=(e,t)=>t,aA=(e,t,n)=>n,rTe=et(DE,sA,aA,(e,t,n)=>e.filter(r=>r.orientation===t).filter(r=>r.mirror===n).sort(CZ)),iTe=et(ME,sA,aA,(e,t,n)=>e.filter(r=>r.orientation===t).filter(r=>r.mirror===n).sort(CZ)),IZ=(e,t)=>({width:e.width,height:t.height}),sTe=(e,t)=>{var n=typeof t.width=="number"?t.width:qy;return{width:n,height:e.height}},jZ=et($a,eh,IZ),aTe=(e,t,n)=>{switch(t){case"top":return e.top;case"bottom":return n-e.bottom;default:return 0}},oTe=(e,t,n)=>{switch(t){case"left":return e.left;case"right":return n-e.right;default:return 0}},lTe=et(Zd,$a,rTe,sA,aA,(e,t,n,r,i)=>{var a={},o;return n.forEach(c=>{var h=IZ(t,c);o==null&&(o=aTe(t,r,e));var f=r==="top"&&!i||r==="bottom"&&i;a[c.id]=o-Number(f)*h.height,o+=(f?-1:1)*h.height}),a}),cTe=et(Qd,$a,iTe,sA,aA,(e,t,n,r,i)=>{var a={},o;return n.forEach(c=>{var h=sTe(t,c);o==null&&(o=oTe(t,r,e));var f=r==="left"&&!i||r==="right"&&i;a[c.id]=o-Number(f)*h.width,o+=(f?-1:1)*h.width}),a}),uTe=(e,t)=>{var n=eh(e,t);if(n!=null)return lTe(e,n.orientation,n.mirror)},dTe=et([$a,eh,uTe,(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n==null?void 0:n[r];return i==null?{x:e.left,y:0}:{x:e.left,y:i}}}),hTe=(e,t)=>{var n=th(e,t);if(n!=null)return cTe(e,n.orientation,n.mirror)},fTe=et([$a,th,hTe,(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n==null?void 0:n[r];return i==null?{x:0,y:e.top}:{x:i,y:e.top}}}),TZ=et($a,th,(e,t)=>{var n=typeof t.width=="number"?t.width:qy;return{width:n,height:e.height}}),cz=(e,t,n)=>{switch(t){case"xAxis":return jZ(e,n).width;case"yAxis":return TZ(e,n).height;default:return}},OZ=(e,t,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,c=Gc(e,r),h=t.map(m=>m.value),f=h.filter(m=>m!=null);if(o&&c&&a==="category"&&i&&AY(f))return h}},C3=et([_i,sb,Xo,Ga],OZ),uz=et([_i,Nje,Hg,iA,C3,k3,ab,_3,Ga],(e,t,n,r,i,a,o,c,h)=>{if(t!=null){var f=Gc(e,h);return{angle:t.angle,interval:t.interval,minTickGap:t.minTickGap,orientation:t.orientation,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,axisType:h,categoricalDomain:a,duplicateDomain:i,isCategorical:f,niceTicks:c,range:o,realScaleType:n,scale:r}}}),pTe=(e,t,n,r,i,a,o,c,h)=>{if(!(t==null||r==null)){var f=Gc(e,h),{type:m,ticks:y,tickCount:w}=t,A=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,k=m==="category"&&r.bandwidth?r.bandwidth()/A:0;k=h==="angleAxis"&&a!=null&&a.length>=2?xl(a[0]-a[1])*2*k:k;var I=y||i;return I?I.map((T,D)=>{var F=o?o.indexOf(T):T,L=r.map(F);return qr(L)?{index:D,coordinate:L+k,value:T,offset:k}:null}).filter(yl):f&&c?c.map((T,D)=>{var F=r.map(T);return qr(F)?{coordinate:F+k,value:T,index:D,offset:k}:null}).filter(yl):r.ticks?r.ticks(w).map((T,D)=>{var F=r.map(T);return qr(F)?{coordinate:F+k,value:T,index:D,offset:k}:null}).filter(yl):r.domain().map((T,D)=>{var F=r.map(T);return qr(F)?{coordinate:F+k,value:o?o[T]:T,index:D,offset:k}:null}).filter(yl)}},PZ=et([_i,rb,Hg,iA,_3,ab,C3,k3,Ga],pTe),mTe=(e,t,n,r,i,a,o)=>{if(!(t==null||n==null||r==null||r[0]===r[1])){var c=Gc(e,o),{tickCount:h}=t,f=0;return f=o==="angleAxis"&&(r==null?void 0:r.length)>=2?xl(r[0]-r[1])*2*f:f,c&&a?a.map((m,y)=>{var w=n.map(m);return qr(w)?{coordinate:w+f,value:m,index:y,offset:f}:null}).filter(yl):n.ticks?n.ticks(h).map((m,y)=>{var w=n.map(m);return qr(w)?{coordinate:w+f,value:m,index:y,offset:f}:null}).filter(yl):n.domain().map((m,y)=>{var w=n.map(m);return qr(w)?{coordinate:w+f,value:i?i[m]:m,index:y,offset:f}:null}).filter(yl)}},Fu=et([_i,rb,iA,ab,C3,k3,Ga],mTe),$u=et(Xo,iA,(e,t)=>{if(!(e==null||t==null))return dN(dN({},e),{},{scale:t})}),gTe=et([Xo,Hg,A3,SZ],b3),xTe=et([gTe],Y4);et((e,t,n)=>v3(e,n),xTe,(e,t)=>{if(!(e==null||t==null))return dN(dN({},e),{},{scale:t})});var yTe=et([_i,DE,ME],(e,t,n)=>{switch(e){case"horizontal":return t.some(r=>r.reversed)?"right-to-left":"left-to-right";case"vertical":return n.some(r=>r.reversed)?"bottom-to-top":"top-to-bottom";case"centric":case"radial":return"left-to-right";default:return}}),bTe=(e,t,n)=>{var r;return(r=e.renderedTicks[t])===null||r===void 0?void 0:r[n]};et([bTe],e=>{if(!(!e||e.length===0))return t=>{var n,r=1/0,i=e[0];for(var a of e){var o=Math.abs(a.coordinate-t);oe.options.defaultTooltipEventType,DZ=e=>e.options.validateTooltipEventTypes;function MZ(e,t,n){if(e==null)return t;var r=e?"axis":"item";return n==null?t:n.includes(r)?r:t}function ob(e,t){var n=RZ(e),r=DZ(e);return MZ(t,n,r)}function vTe(e){return Qn(t=>ob(t,e))}var LZ=(e,t)=>{var n,r=Number(t);if(!(Vc(r)||t==null))return r>=0?e==null||(n=e[r])===null||n===void 0?void 0:n.value:void 0},wTe=e=>e.tooltip.settings,Yh={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},NTe={itemInteraction:{click:Yh,hover:Yh},axisInteraction:{click:Yh,hover:Yh},keyboardInteraction:Yh,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:"hover",axisId:0,active:!1,defaultIndex:void 0}},UZ=Io({name:"tooltip",initialState:NTe,reducers:{addTooltipEntrySettings:{reducer(e,t){e.tooltipItemPayloads.push(t.payload)},prepare:ps()},replaceTooltipEntrySettings:{reducer(e,t){var{prev:n,next:r}=t.payload,i=lc(e).tooltipItemPayloads.indexOf(n);i>-1&&(e.tooltipItemPayloads[i]=r)},prepare:ps()},removeTooltipEntrySettings:{reducer(e,t){var n=lc(e).tooltipItemPayloads.indexOf(t.payload);n>-1&&e.tooltipItemPayloads.splice(n,1)},prepare:ps()},setTooltipSettingsState(e,t){e.settings=t.payload},setActiveMouseOverItemIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.itemInteraction.hover.active=!0,e.itemInteraction.hover.index=t.payload.activeIndex,e.itemInteraction.hover.dataKey=t.payload.activeDataKey,e.itemInteraction.hover.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.hover.coordinate=t.payload.activeCoordinate},mouseLeaveChart(e){e.itemInteraction.hover.active=!1,e.axisInteraction.hover.active=!1},mouseLeaveItem(e){e.itemInteraction.hover.active=!1},setActiveClickItemIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.itemInteraction.click.active=!0,e.keyboardInteraction.active=!1,e.itemInteraction.click.index=t.payload.activeIndex,e.itemInteraction.click.dataKey=t.payload.activeDataKey,e.itemInteraction.click.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.click.coordinate=t.payload.activeCoordinate},setMouseOverAxisIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.axisInteraction.hover.active=!0,e.keyboardInteraction.active=!1,e.axisInteraction.hover.index=t.payload.activeIndex,e.axisInteraction.hover.dataKey=t.payload.activeDataKey,e.axisInteraction.hover.coordinate=t.payload.activeCoordinate},setMouseClickAxisIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.axisInteraction.click.active=!0,e.axisInteraction.click.index=t.payload.activeIndex,e.axisInteraction.click.dataKey=t.payload.activeDataKey,e.axisInteraction.click.coordinate=t.payload.activeCoordinate},setSyncInteraction(e,t){e.syncInteraction=t.payload},setKeyboardInteraction(e,t){e.keyboardInteraction.active=t.payload.active,e.keyboardInteraction.index=t.payload.activeIndex,e.keyboardInteraction.coordinate=t.payload.activeCoordinate}}}),{addTooltipEntrySettings:ETe,replaceTooltipEntrySettings:ATe,removeTooltipEntrySettings:_Te,setTooltipSettingsState:STe,setActiveMouseOverItemIndex:BZ,mouseLeaveItem:kTe,mouseLeaveChart:zZ,setActiveClickItemIndex:CTe,setMouseOverAxisIndex:VZ,setMouseClickAxisIndex:ITe,setSyncInteraction:d1,setKeyboardInteraction:pN}=UZ.actions,jTe=UZ.reducer;function dz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Hv(e){for(var t=1;t{if(t==null)return Yh;var i=RTe(e,t,n);if(i==null)return Yh;if(i.active)return i;if(e.keyboardInteraction.active)return e.keyboardInteraction;if(e.syncInteraction.active&&e.syncInteraction.index!=null)return e.syncInteraction;var a=e.settings.active===!0;if(DTe(i)){if(a)return Hv(Hv({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return Hv(Hv({},Yh),{},{coordinate:i.coordinate})};function MTe(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(e instanceof Date){var t=e.valueOf();return Number.isFinite(t)?t:void 0}var n=Number(e);return Number.isFinite(n)?n:void 0}function LTe(e,t){var n=MTe(e),r=t[0],i=t[1];if(n===void 0)return!1;var a=Math.min(r,i),o=Math.max(r,i);return n>=a&&n<=o}function UTe(e,t,n){if(n==null||t==null)return!0;var r=Ds(e,t);return r==null||!Tu(n)?!0:LTe(r,n)}var R1=(e,t,n,r)=>{var i=e==null?void 0:e.index;if(i==null)return null;var a=Number(i);if(!qr(a))return i;var o=0,c=1/0;t.length>0&&(c=t.length-1);var h=Math.max(o,Math.min(a,c)),f=t[h];return f==null||UTe(f,n,r)?String(h):null},$Z=(e,t,n,r,i,a,o)=>{if(a!=null){var c=o[0],h=c==null?void 0:c.getPosition(a);if(h!=null)return h;var f=i==null?void 0:i[Number(a)];if(f)switch(n){case"horizontal":return{x:f.coordinate,y:(r.top+t)/2};default:return{x:(r.left+e)/2,y:f.coordinate}}}},HZ=(e,t,n,r)=>{if(t==="axis")return e.tooltipItemPayloads;if(e.tooltipItemPayloads.length===0)return[];var i;if(n==="hover"?i=e.itemInteraction.hover.graphicalItemId:i=e.itemInteraction.click.graphicalItemId,e.syncInteraction.active&&i==null)return e.tooltipItemPayloads;if(i==null&&(r!=null||e.keyboardInteraction.active)){var a=e.tooltipItemPayloads[0];return a!=null?[a]:[]}return e.tooltipItemPayloads.filter(o=>{var c;return((c=o.settings)===null||c===void 0?void 0:c.graphicalItemId)===i})},GZ=e=>e.options.tooltipPayloadSearcher,Gg=e=>e.tooltip;function hz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function fz(e){for(var t=1;te(t)}function pz(e){if(typeof e=="string")return e}function GTe(e){if(!(e==null||typeof e!="object")){var t="name"in e?FTe(e.name):void 0,n="unit"in e?$Te(e.unit):void 0,r="dataKey"in e?HTe(e.dataKey):void 0,i="payload"in e?e.payload:void 0,a="color"in e?pz(e.color):void 0,o="fill"in e?pz(e.fill):void 0;return{name:t,unit:n,dataKey:r,payload:i,color:a,fill:o}}}function qTe(e,t){return e??t}var qZ=(e,t,n,r,i,a,o)=>{if(!(t==null||a==null)){var{chartData:c,computedData:h,dataStartIndex:f,dataEndIndex:m}=n,y=[];return e.reduce((w,A)=>{var k,{dataDefinedOnItem:I,settings:T}=A,D=qTe(I,c),F=Array.isArray(D)?bX(D,f,m):D,L=(k=T==null?void 0:T.dataKey)!==null&&k!==void 0?k:r,q=T==null?void 0:T.nameKey,Z;if(r&&Array.isArray(F)&&!Array.isArray(F[0])&&o==="axis"?Z=_Y(F,r,i):Z=a(F,t,h,q),Array.isArray(Z))Z.forEach(z=>{var B,V,$=GTe(z),Q=$==null?void 0:$.name,Y=$==null?void 0:$.dataKey,G=$==null?void 0:$.payload,he=fz(fz({},T),{},{name:Q,unit:$==null?void 0:$.unit,color:(B=$==null?void 0:$.color)!==null&&B!==void 0?B:T==null?void 0:T.color,fill:(V=$==null?void 0:$.fill)!==null&&V!==void 0?V:T==null?void 0:T.fill});w.push(aU({tooltipEntrySettings:he,dataKey:Y,payload:G,value:Ds(G,Y),name:Q==null?void 0:String(Q)}))});else{var K;w.push(aU({tooltipEntrySettings:T,dataKey:L,payload:Z,value:Ds(Z,L),name:(K=Ds(Z,q))!==null&&K!==void 0?K:T==null?void 0:T.name}))}return w},y)}},I3=et([Ta,eZ,$4],XQ),WTe=et([e=>e.graphicalItems.cartesianItems,e=>e.graphicalItems.polarItems],(e,t)=>[...e,...t]),KTe=et([qa,zg],tZ),wm=et([WTe,Ta,KTe],nZ,{memoizeOptions:{resultEqualityCheck:QE}}),YTe=et([wm],e=>e.filter(YE)),WZ=et([wm],sZ,{memoizeOptions:{resultEqualityCheck:QE}}),XTe=et([wm],e=>e.some(t=>!t.data)),cm=et([WZ,qc],oZ),QTe=et([YTe,qc,Ta],mQ),j3=et([cm,Ta,wm,qc,XTe,WZ],lZ),KZ=et([Ta],N3),ZTe=et([Ta],e=>e.allowDataOverflow),YZ=et([KZ,ZTe],YX),JTe=et([wm],e=>e.filter(YE)),e4e=et([QTe,JTe,$E,lQ],uZ),t4e=et([e4e,qc,qa,YZ],dZ),n4e=et([wm],iZ),r4e=et([cm,Ta,n4e,E3,qa,Nke],pZ,{memoizeOptions:{resultEqualityCheck:XE}}),i4e=et([mZ,qa,zg],$g),s4e=et([i4e,qa],yZ),a4e=et([gZ,qa,zg],$g),o4e=et([a4e,qa],bZ),l4e=et([xZ,qa,zg],$g),c4e=et([l4e,qa],vZ),u4e=et([s4e,c4e,o4e],fN),d4e=et([Ta,KZ,YZ,t4e,r4e,u4e,_i,qa],wZ),Eg=et([Ta,_i,cm,j3,$E,qa,d4e],NZ),h4e=et([Eg,Ta,I3],EZ),f4e=et([Ta,Eg,h4e,qa],AZ),XZ=e=>{var t=qa(e),n=zg(e),r=!1;return ab(e,t,n,r)},QZ=et([Ta,XZ],HE),p4e=et([Ta,I3,f4e,QZ],b3),ZZ=et([p4e],Y4),m4e=et([_i,j3,Ta,qa],OZ),g4e=et([_i,j3,Ta,qa],kZ),x4e=(e,t,n,r,i,a,o,c)=>{if(t){var{type:h}=t,f=Gc(e,c);if(r){var m=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,y=h==="category"&&r.bandwidth?r.bandwidth()/m:0;return y=c==="angleAxis"&&i!=null&&(i==null?void 0:i.length)>=2?xl(i[0]-i[1])*2*y:y,f&&o?o.map((w,A)=>{var k=r.map(w);return qr(k)?{coordinate:k+y,value:w,index:A,offset:y}:null}).filter(yl):r.domain().map((w,A)=>{var k=r.map(w);return qr(k)?{coordinate:k+y,value:a?a[w]:w,index:A,offset:y}:null}).filter(yl)}}},nh=et([_i,Ta,I3,ZZ,XZ,m4e,g4e,qa],x4e),T3=et([RZ,DZ,wTe],(e,t,n)=>MZ(n.shared,e,t)),JZ=e=>e.tooltip.settings.trigger,O3=e=>e.tooltip.settings.defaultIndex,lb=et([Gg,T3,JZ,O3],FZ),um=et([lb,cm,Ng,Eg],R1),eJ=et([nh,um],LZ),tJ=et([lb],e=>{if(e)return e.dataKey}),y4e=et([lb],e=>{if(e)return e.graphicalItemId}),nJ=et([Gg,T3,JZ,O3],HZ),b4e=et([Qd,Zd,_i,$a,nh,O3,nJ],$Z),v4e=et([lb,b4e],(e,t)=>e!=null&&e.coordinate?e.coordinate:t),w4e=et([lb],e=>{var t;return(t=e==null?void 0:e.active)!==null&&t!==void 0?t:!1}),N4e=et([nJ,um,qc,Ng,eJ,GZ,T3],qZ),E4e=et([N4e],e=>{if(e!=null){var t=e.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(t))}});function mz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function gz(e){for(var t=1;tQn(Ta),C4e=()=>{var e=k4e(),t=Qn(nh),n=Qn(ZZ);return yf(!e||!n?void 0:gz(gz({},e),{},{scale:n}),t)};function xz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function h0(e){for(var t=1;t{var i=t.find(a=>a&&a.index===n);if(i){if(e==="horizontal")return{x:i.coordinate,y:r.relativeY};if(e==="vertical")return{x:r.relativeX,y:i.coordinate}}return{x:0,y:0}},P4e=(e,t,n,r)=>{var i=t.find(f=>f&&f.index===n);if(i){if(e==="centric"){var a=i.coordinate,{radius:o}=r;return h0(h0(h0({},r),ao(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var c=i.coordinate,{angle:h}=r;return h0(h0(h0({},r),ao(r.cx,r.cy,c,h)),{},{angle:h,radius:c})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function R4e(e,t){var{relativeX:n,relativeY:r}=e;return n>=t.left&&n<=t.left+t.width&&r>=t.top&&r<=t.top+t.height}var rJ=(e,t,n,r,i)=>{var a,o=(a=t==null?void 0:t.length)!==null&&a!==void 0?a:0;if(o<=1||e==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c0?(h=n[c-1])===null||h===void 0?void 0:h.coordinate:(f=n[o-1])===null||f===void 0?void 0:f.coordinate,k=(m=n[c])===null||m===void 0?void 0:m.coordinate,I=c>=o-1?(y=n[0])===null||y===void 0?void 0:y.coordinate:(w=n[c+1])===null||w===void 0?void 0:w.coordinate,T=void 0;if(!(A==null||k==null||I==null))if(xl(k-A)!==xl(I-k)){var D=[];if(xl(I-k)===xl(i[1]-i[0])){T=I;var F=k+i[1]-i[0];D[0]=Math.min(F,(F+A)/2),D[1]=Math.max(F,(F+A)/2)}else{T=A;var L=I+i[1]-i[0];D[0]=Math.min(k,(L+k)/2),D[1]=Math.max(k,(L+k)/2)}var q=[Math.min(k,(T+k)/2),Math.max(k,(T+k)/2)];if(e>q[0]&&e<=q[1]||e>=D[0]&&e<=D[1]){var Z;return(Z=n[c])===null||Z===void 0?void 0:Z.index}}else{var K=Math.min(A,I),z=Math.max(A,I);if(e>(K+k)/2&&e<=(z+k)/2){var B;return(B=n[c])===null||B===void 0?void 0:B.index}}}else if(t)for(var V=0;V($.coordinate+Y.coordinate)/2||V>0&&V($.coordinate+Y.coordinate)/2&&e<=($.coordinate+Q.coordinate)/2)return $.index}}return-1},iJ=()=>Qn($4),P3=(e,t)=>t,sJ=(e,t,n)=>n,R3=(e,t,n,r)=>r,D4e=et(nh,e=>_E(e,t=>t.coordinate)),D3=et([Gg,P3,sJ,R3],FZ),M3=et([D3,cm,Ng,Eg],R1),M4e=(e,t,n)=>{if(t!=null){var r=Gg(e);return t==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},aJ=et([Gg,P3,sJ,R3],HZ),mN=et([Qd,Zd,_i,$a,nh,R3,aJ],$Z),L4e=et([D3,mN],(e,t)=>{var n;return(n=e.coordinate)!==null&&n!==void 0?n:t}),oJ=et([nh,M3],LZ),U4e=et([aJ,M3,qc,Ng,oJ,GZ,P3],qZ),B4e=et([D3,M3],(e,t)=>({isActive:e.active&&t!=null,activeIndex:t})),z4e=(e,t,n,r,i,a,o)=>{if(!(!e||!n||!r||!i)&&R4e(e,o)){var c=y_e(e,t),h=rJ(c,a,i,n,r),f=O4e(t,i,h,e);return{activeIndex:String(h),activeCoordinate:f}}},V4e=(e,t,n,r,i,a,o)=>{if(!(!e||!r||!i||!a||!n)){var c=dke(e,n);if(c){var h=b_e(c,t),f=rJ(h,o,a,r,i),m=P4e(t,a,f,c);return{activeIndex:String(f),activeCoordinate:m}}}},F4e=(e,t,n,r,i,a,o,c)=>{if(!(!e||!t||!r||!i||!a))return t==="horizontal"||t==="vertical"?z4e(e,t,r,i,a,o,c):V4e(e,t,n,r,i,a,o)},$4e=et(e=>e.zIndex.zIndexMap,(e,t)=>t,(e,t,n)=>n,(e,t,n)=>{if(t!=null){var r=e[t];if(r!=null)return n?r.panoramaElement:r.element}}),H4e=et(e=>e.zIndex.zIndexMap,e=>{var t=Object.keys(e).map(r=>parseInt(r,10)).concat(Object.values(Sa)),n=Array.from(new Set(t));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:Lke}});function yz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function bz(e){for(var t=1;tbz(bz({},e),{},{[t]:{element:void 0,panoramaElement:void 0,consumers:0}}),K4e)},X4e=new Set(Object.values(Sa));function Q4e(e){return X4e.has(e)}var lJ=Io({name:"zIndex",initialState:Y4e,reducers:{registerZIndexPortal:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]?e.zIndexMap[n].consumers+=1:e.zIndexMap[n]={consumers:1,element:void 0,panoramaElement:void 0}},prepare:ps()},unregisterZIndexPortal:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]&&(e.zIndexMap[n].consumers-=1,e.zIndexMap[n].consumers<=0&&!Q4e(n)&&delete e.zIndexMap[n])},prepare:ps()},registerZIndexPortalElement:{reducer:(e,t)=>{var{zIndex:n,element:r,isPanorama:i}=t.payload;e.zIndexMap[n]?i?e.zIndexMap[n].panoramaElement=r:e.zIndexMap[n].element=r:e.zIndexMap[n]={consumers:0,element:i?void 0:r,panoramaElement:i?r:void 0}},prepare:ps()},unregisterZIndexPortalElement:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]&&(t.payload.isPanorama?e.zIndexMap[n].panoramaElement=void 0:e.zIndexMap[n].element=void 0)},prepare:ps()}}}),{registerZIndexPortal:Z4e,unregisterZIndexPortal:tk,registerZIndexPortalElement:J4e,unregisterZIndexPortalElement:e3e}=lJ.actions,t3e=lJ.reducer;function Wl(e){var{zIndex:t,children:n}=e,r=J_e(),i=r&&t!==void 0&&t!==0,a=Ha(),o=j.useRef(void 0),c=j.useRef(new Set),h=ys(),f=Qn(y=>$4e(y,t,a));if(j.useLayoutEffect(()=>{if(!i){var y=c.current;y.forEach(A=>{h(tk({zIndex:A}))}),y.clear(),o.current=void 0;return}if(c.current.has(t)||(h(Z4e({zIndex:t})),c.current.add(t)),f){o.current=f;var w=c.current;w.forEach(A=>{A!==t&&(h(tk({zIndex:A})),w.delete(A))})}},[h,t,i,f]),j.useLayoutEffect(()=>{var y=c.current;return()=>{y.forEach(w=>{h(tk({zIndex:w}))}),y.clear()}},[h]),!i)return n;var m=f??o.current;return m?CN.createPortal(n,m):null}function UI(){return UI=Object.assign?Object.assign.bind():function(e){for(var t=1;tj.useContext(cJ),nk={exports:{}},wz;function c3e(){return wz||(wz=1,(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(h,f,m){this.fn=h,this.context=f,this.once=m||!1}function a(h,f,m,y,w){if(typeof m!="function")throw new TypeError("The listener must be a function");var A=new i(m,y||h,w),k=n?n+f:f;return h._events[k]?h._events[k].fn?h._events[k]=[h._events[k],A]:h._events[k].push(A):(h._events[k]=A,h._eventsCount++),h}function o(h,f){--h._eventsCount===0?h._events=new r:delete h._events[f]}function c(){this._events=new r,this._eventsCount=0}c.prototype.eventNames=function(){var f=[],m,y;if(this._eventsCount===0)return f;for(y in m=this._events)t.call(m,y)&&f.push(n?y.slice(1):y);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(m)):f},c.prototype.listeners=function(f){var m=n?n+f:f,y=this._events[m];if(!y)return[];if(y.fn)return[y.fn];for(var w=0,A=y.length,k=new Array(A);w{if(t&&Array.isArray(e)){var n=Number.parseInt(t,10);if(!Vc(n))return e[n]}},f3e={chartName:"",tooltipPayloadSearcher:()=>{},eventEmitter:void 0,defaultTooltipEventType:"axis"},uJ=Io({name:"options",initialState:f3e,reducers:{createEventEmitter:e=>{e.eventEmitter==null&&(e.eventEmitter=Symbol("rechartsEventEmitter"))}}}),p3e=uJ.reducer,{createEventEmitter:m3e}=uJ.actions;function g3e(e){return e.tooltip.syncInteraction}var x3e={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},dJ=Io({name:"chartData",initialState:x3e,reducers:{setChartData(e,t){if(e.chartData=t.payload,t.payload==null){e.dataStartIndex=0,e.dataEndIndex=0;return}t.payload.length>0&&e.dataEndIndex!==t.payload.length-1&&(e.dataEndIndex=t.payload.length-1)},setComputedData(e,t){e.computedData=t.payload},setDataStartEndIndexes(e,t){var{startIndex:n,endIndex:r}=t.payload;n!=null&&(e.dataStartIndex=n),r!=null&&(e.dataEndIndex=r)}}}),{setChartData:Ez,setDataStartEndIndexes:y3e,setComputedData:O9e}=dJ.actions,b3e=dJ.reducer,v3e=["x","y"];function Az(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function f0(e){for(var t=1;th.rootProps.className);j.useEffect(()=>{if(e==null)return jf;var h=(f,m,y)=>{if(t!==y&&e===f){if(m.payload.active===!1){n(d1({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(r==="index"){var w;if(o&&m!==null&&m!==void 0&&(w=m.payload)!==null&&w!==void 0&&w.coordinate&&m.payload.sourceViewBox){var A=m.payload.coordinate,{x:k,y:I}=A,T=A3e(A,v3e),{x:D,y:F,width:L,height:q}=m.payload.sourceViewBox,Z=f0(f0({},T),{},{x:o.x+(L?(k-D)/L:0)*o.width,y:o.y+(q?(I-F)/q:0)*o.height});n(f0(f0({},m),{},{payload:f0(f0({},m.payload),{},{coordinate:Z})}))}else n(m);return}if(i!=null){var K;if(typeof r=="function"){var z={activeTooltipIndex:m.payload.index==null?void 0:Number(m.payload.index),isTooltipActive:m.payload.active,activeIndex:m.payload.index==null?void 0:Number(m.payload.index),activeLabel:m.payload.label,activeDataKey:m.payload.dataKey,activeCoordinate:m.payload.coordinate},B=r(i,z);K=i[B]}else r==="value"&&(K=i.find(le=>String(le.value)===m.payload.label));var{coordinate:V}=m.payload;if(V==null||o==null){n(d1({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(K==null){n(d1({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:m.payload.sourceViewBox,graphicalItemId:void 0}));return}var{x:$,y:Q}=V,Y=Math.min($,o.x+o.width),G=Math.min(Q,o.y+o.height),he={x:a==="horizontal"?K.coordinate:Y,y:a==="horizontal"?G:K.coordinate},te=d1({active:m.payload.active,coordinate:he,dataKey:m.payload.dataKey,index:String(K.index),label:m.payload.label,sourceViewBox:m.payload.sourceViewBox,graphicalItemId:m.payload.graphicalItemId});n(te)}}};return my.on(BI,h),()=>{my.off(BI,h)}},[c,n,t,e,r,i,a,o])}function k3e(){var e=Qn(H4),t=Qn(G4),n=ys();j.useEffect(()=>{if(e==null)return jf;var r=(i,a,o)=>{t!==o&&e===i&&n(y3e(a))};return my.on(Nz,r),()=>{my.off(Nz,r)}},[n,t,e])}function C3e(){var e=ys();j.useEffect(()=>{e(m3e())},[e]),S3e(),k3e()}function I3e(e,t,n,r,i,a){var o=Qn(k=>M4e(k,e,t)),c=Qn(y4e),h=Qn(G4),f=Qn(H4),m=Qn(cQ),y=Qn(g3e),w=(y==null?void 0:y.sourceViewBox)!=null,A=BE();j.useEffect(()=>{if(!w&&f!=null&&h!=null){var k=d1({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:A,graphicalItemId:c});my.emit(BI,f,k,h)}},[w,n,o,c,i,r,h,f,m,a,A])}function _z(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Sz(e){for(var t=1;t{z(STe({shared:F,trigger:L,axisId:K,active:i,defaultIndex:B}))},[z,F,L,K,i,B]);var V=BE(),$=UX(),Q=vTe(F),{activeIndex:Y,isActive:G}=(t=Qn(Tt=>B4e(Tt,Q,L,B)))!==null&&t!==void 0?t:{},he=Qn(Tt=>U4e(Tt,Q,L,B)),te=Qn(Tt=>oJ(Tt,Q,L,B)),le=Qn(Tt=>L4e(Tt,Q,L,B)),ve=he,ke=l3e(),Be=(n=i??G)!==null&&n!==void 0?n:!1,[J,ie]=$Y([ve,Be]),xe=Q==="axis"?te:void 0;I3e(Q,L,le,xe,Y,Be);var ae=Z??ke;if(ae==null||V==null||Q==null)return null;var Fe=ve??kz;Be||(Fe=kz),f&&Fe.length&&(Fe=UY(Fe.filter(Tt=>Tt.value!=null&&(Tt.hide!==!0||r.includeHidden)),w,P3e));var pt=Fe.length>0,Ue=Sz(Sz({},r),{},{payload:Fe,label:xe,active:Be,activeIndex:Y,coordinate:le,accessibilityLayer:$}),Ct=j.createElement(d5e,{allowEscapeViewBox:a,animationDuration:o,animationEasing:c,isAnimationActive:m,active:Be,coordinate:le,hasPayload:pt,offset:y,position:A,reverseDirection:k,useTranslate3d:I,viewBox:V,wrapperStyle:T,lastBoundingBox:J,innerRef:ie,hasPortalFromProps:!!Z},R3e(h,Ue));return j.createElement(j.Fragment,null,CN.createPortal(Ct,ae),Be&&j.createElement(o3e,{cursor:D,tooltipEventType:Q,coordinate:le,payload:Fe,index:Y}))}var hJ=e=>null;hJ.displayName="Cell";function L3e(e,t,n){return(t=U3e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function U3e(e){var t=B3e(e,"string");return typeof t=="symbol"?t:t+""}function B3e(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}class z3e{constructor(t){L3e(this,"cache",new Map),this.maxSize=t}get(t){var n=this.cache.get(t);return n!==void 0&&(this.cache.delete(t),this.cache.set(t,n)),n}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.maxSize){var r=this.cache.keys().next().value;r!=null&&this.cache.delete(r)}this.cache.set(t,n)}clear(){this.cache.clear()}size(){return this.cache.size}}function Cz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function V3e(e){for(var t=1;t{try{var n=document.getElementById(jz);n||(n=document.createElement("span"),n.setAttribute("id",jz),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,q3e,t),n.textContent="".concat(e);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},D1=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||Yy.isSsr)return{width:0,height:0};if(!fJ.enableCache)return Tz(t,n);var r=W3e(t,n),i=Iz.get(r);if(i)return i;var a=Tz(t,n);return Iz.set(r,a),a},pJ;function K3e(e,t,n){return(t=Y3e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Y3e(e){var t=X3e(e,"string");return typeof t=="symbol"?t:t+""}function X3e(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Oz=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Pz=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Q3e=/^(px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q)$/,Z3e=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,J3e={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},eOe=["cm","mm","pt","pc","in","Q","px"];function tOe(e){return eOe.includes(e)}var j0="NaN";function nOe(e,t){return e*J3e[t]}class no{static parse(t){var n,[,r,i]=(n=Z3e.exec(t))!==null&&n!==void 0?n:[];return r==null?no.NaN:new no(parseFloat(r),i??"")}constructor(t,n){this.num=t,this.unit=n,this.num=t,this.unit=n,Vc(t)&&(this.unit=""),n!==""&&!Q3e.test(n)&&(this.num=NaN,this.unit=""),tOe(n)&&(this.num=nOe(t,n),this.unit="px")}add(t){return this.unit!==t.unit?new no(NaN,""):new no(this.num+t.num,this.unit)}subtract(t){return this.unit!==t.unit?new no(NaN,""):new no(this.num-t.num,this.unit)}multiply(t){return this.unit!==""&&t.unit!==""&&this.unit!==t.unit?new no(NaN,""):new no(this.num*t.num,this.unit||t.unit)}divide(t){return this.unit!==""&&t.unit!==""&&this.unit!==t.unit?new no(NaN,""):new no(this.num/t.num,this.unit||t.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Vc(this.num)}}pJ=no;K3e(no,"NaN",new pJ(NaN,""));function mJ(e){if(e==null||e.includes(j0))return j0;for(var t=e;t.includes("*")||t.includes("/");){var n,[,r,i,a]=(n=Oz.exec(t))!==null&&n!==void 0?n:[],o=no.parse(r??""),c=no.parse(a??""),h=i==="*"?o.multiply(c):o.divide(c);if(h.isNaN())return j0;t=t.replace(Oz,h.toString())}for(;t.includes("+")||/.-\d+(?:\.\d+)?/.test(t);){var f,[,m,y,w]=(f=Pz.exec(t))!==null&&f!==void 0?f:[],A=no.parse(m??""),k=no.parse(w??""),I=y==="+"?A.add(k):A.subtract(k);if(I.isNaN())return j0;t=t.replace(Pz,I.toString())}return t}var Rz=/\(([^()]*)\)/;function rOe(e){for(var t=e,n;(n=Rz.exec(t))!=null;){var[,r]=n;t=t.replace(Rz,mJ(r))}return t}function iOe(e){var t=e.replace(/\s+/g,"");return t=rOe(t),t=mJ(t),t}function sOe(e){try{return iOe(e)}catch{return j0}}function rk(e){var t=sOe(e.slice(5,-1));return t===j0?"":t}var aOe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],oOe=["dx","dy","angle","className","breakAll"];function zI(){return zI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:t,breakAll:n,style:r}=e;try{var i=[];xs(t)||(n?i=t.toString().split(""):i=t.toString().split(gJ));var a=i.map(c=>({word:c,width:D1(c,r).width})),o=n?0:D1(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function yJ(e){return e==="start"||e==="middle"||e==="end"||e==="inherit"}function cOe(e){return xs(e)||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var bJ=(e,t,n,r)=>e.reduce((i,a)=>{var{word:o,width:c}=a,h=i[i.length-1];if(h&&c!=null&&(t==null||r||h.width+c+ne.reduce((t,n)=>t.width>n.width?t:n),uOe="…",Mz=(e,t,n,r,i,a,o,c)=>{var h=e.slice(0,t),f=xJ({breakAll:n,style:r,children:h+uOe});if(!f)return[!1,[]];var m=bJ(f.wordsWithComputedWidth,a,o,c),y=m.length>i||vJ(m).width>Number(a);return[y,m]},dOe=(e,t,n,r,i)=>{var{maxLines:a,children:o,style:c,breakAll:h}=e,f=En(a),m=String(o),y=bJ(t,r,n,i);if(!f||i)return y;var w=y.length>a||vJ(y).width>Number(r);if(!w)return y;for(var A=0,k=m.length-1,I=0,T;A<=k&&I<=m.length-1;){var D=Math.floor((A+k)/2),F=D-1,[L,q]=Mz(m,F,h,c,a,r,n,i),[Z]=Mz(m,D,h,c,a,r,n,i);if(!L&&!Z&&(A=D+1),L&&Z&&(k=D-1),!L&&Z){T=q;break}I++}return T||y},Lz=e=>{var t=xs(e)?[]:e.toString().split(gJ);return[{words:t,width:void 0}]},hOe=e=>{var{width:t,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=e;if((t||n)&&!Yy.isSsr){var c,h,f=xJ({breakAll:a,children:r,style:i});if(f){var{wordsWithComputedWidth:m,spaceWidth:y}=f;c=m,h=y}else return Lz(r);return dOe({breakAll:a,children:r,maxLines:o,style:i},c,h,t,!!n)}return Lz(r)},wJ="#808080",fOe={angle:0,breakAll:!1,capHeight:"0.71em",fill:wJ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},L3=j.forwardRef((e,t)=>{var n=Fa(e,fOe),{x:r,y:i,lineHeight:a,capHeight:o,fill:c,scaleToFit:h,textAnchor:f,verticalAnchor:m}=n,y=Dz(n,aOe),w=j.useMemo(()=>hOe({breakAll:y.breakAll,children:y.children,maxLines:y.maxLines,scaleToFit:h,style:y.style,width:y.width}),[y.breakAll,y.children,y.maxLines,h,y.style,y.width]),{dx:A,dy:k,angle:I,className:T,breakAll:D}=y,F=Dz(y,oOe);if(!Uu(r)||!Uu(i)||w.length===0)return null;var L=Number(r)+(En(A)?A:0),q=Number(i)+(En(k)?k:0);if(!qr(L)||!qr(q))return null;var Z;switch(m){case"start":Z=rk("calc(".concat(o,")"));break;case"middle":Z=rk("calc(".concat((w.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:Z=rk("calc(".concat(w.length-1," * -").concat(a,")"));break}var K=[],z=w[0];if(h&&z!=null){var B=z.width,{width:V}=y;K.push("scale(".concat(En(V)&&En(B)?V/B:1,")"))}return I&&K.push("rotate(".concat(I,", ").concat(L,", ").concat(q,")")),K.length&&(F.transform=K.join(" ")),j.createElement("text",zI({},ko(F),{ref:t,x:L,y:q,className:Di("recharts-text",T),textAnchor:f,fill:c.includes("url")?wJ:c}),w.map(($,Q)=>{var Y=$.words.join(D?"":" ");return j.createElement("tspan",{x:L,dy:Q===0?Z:a,key:"".concat(Y,"-").concat(Q)},Y)}))});L3.displayName="Text";function Uz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function cu(e){for(var t=1;t{var{viewBox:t,position:n,offset:r=0,parentViewBox:i}=e,{x:a,y:o,height:c,upperWidth:h,lowerWidth:f}=P4(t),m=a,y=a+(h-f)/2,w=(m+y)/2,A=(h+f)/2,k=m+h/2,I=c>=0?1:-1,T=I*r,D=I>0?"end":"start",F=I>0?"start":"end",L=h>=0?1:-1,q=L*r,Z=L>0?"end":"start",K=L>0?"start":"end",z=i;if(n==="top"){var B={x:m+h/2,y:o-T,horizontalAnchor:"middle",verticalAnchor:D};return z&&(B.height=Math.max(o-z.y,0),B.width=h),B}if(n==="bottom"){var V={x:y+f/2,y:o+c+T,horizontalAnchor:"middle",verticalAnchor:F};return z&&(V.height=Math.max(z.y+z.height-(o+c),0),V.width=f),V}if(n==="left"){var $={x:w-q,y:o+c/2,horizontalAnchor:Z,verticalAnchor:"middle"};return z&&($.width=Math.max($.x-z.x,0),$.height=c),$}if(n==="right"){var Q={x:w+A+q,y:o+c/2,horizontalAnchor:K,verticalAnchor:"middle"};return z&&(Q.width=Math.max(z.x+z.width-Q.x,0),Q.height=c),Q}var Y=z?{width:A,height:c}:{};return n==="insideLeft"?cu({x:w+q,y:o+c/2,horizontalAnchor:K,verticalAnchor:"middle"},Y):n==="insideRight"?cu({x:w+A-q,y:o+c/2,horizontalAnchor:Z,verticalAnchor:"middle"},Y):n==="insideTop"?cu({x:m+h/2,y:o+T,horizontalAnchor:"middle",verticalAnchor:F},Y):n==="insideBottom"?cu({x:y+f/2,y:o+c-T,horizontalAnchor:"middle",verticalAnchor:D},Y):n==="insideTopLeft"?cu({x:m+q,y:o+T,horizontalAnchor:K,verticalAnchor:F},Y):n==="insideTopRight"?cu({x:m+h-q,y:o+T,horizontalAnchor:Z,verticalAnchor:F},Y):n==="insideBottomLeft"?cu({x:y+q,y:o+c-T,horizontalAnchor:K,verticalAnchor:D},Y):n==="insideBottomRight"?cu({x:y+f-q,y:o+c-T,horizontalAnchor:Z,verticalAnchor:D},Y):n&&typeof n=="object"&&(En(n.x)||im(n.x))&&(En(n.y)||im(n.y))?cu({x:a+Fc(n.x,A),y:o+Fc(n.y,c),horizontalAnchor:"end",verticalAnchor:"end"},Y):cu({x:k,y:o+c/2,horizontalAnchor:"middle",verticalAnchor:"middle"},Y)},yOe=["labelRef"],bOe=["content"];function Bz(e,t){if(e==null)return{};var n,r,i=vOe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var{x:t,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:c}=e,h=j.useMemo(()=>({x:t,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[t,n,r,i,a,o]);return j.createElement(NJ.Provider,{value:h},c)},EJ=()=>{var e=j.useContext(NJ),t=BE();return e||(t?P4(t):void 0)},_Oe=j.createContext(null),SOe=()=>{var e=j.useContext(_Oe),t=Qn(pQ);return e||t},kOe=e=>{var{value:t,formatter:n}=e,r=xs(e.children)?t:e.children;return typeof n=="function"?n(r):r},U3=e=>e!=null&&typeof e=="function",COe=(e,t)=>{var n=xl(t-e),r=Math.min(Math.abs(t-e),360);return n*r},IOe=(e,t,n,r,i)=>{var{offset:a,className:o}=e,{cx:c,cy:h,innerRadius:f,outerRadius:m,startAngle:y,endAngle:w,clockWise:A}=i,k=(f+m)/2,I=COe(y,w),T=I>=0?1:-1,D,F;switch(t){case"insideStart":D=y+T*a,F=A;break;case"insideEnd":D=w-T*a,F=!A;break;case"end":D=w+T*a,F=A;break;default:throw new Error("Unsupported position ".concat(t))}F=I<=0?F:!F;var L=ao(c,h,k,D),q=ao(c,h,k,D+(F?1:-1)*359),Z="M".concat(L.x,",").concat(L.y,` A`).concat(k,",").concat(k,",0,1,").concat(F?0:1,`, `).concat(q.x,",").concat(q.y),K=xs(e.id)?ny("recharts-radial-line-"):e.id;return j.createElement("text",Sd({},r,{dominantBaseline:"central",className:Di("recharts-radial-bar-label",o)}),j.createElement("defs",null,j.createElement("path",{id:K,d:Z})),j.createElement("textPath",{xlinkHref:"#".concat(K)},n))},jOe=(e,t,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:o,startAngle:c,endAngle:h}=e,f=(c+h)/2;if(n==="outside"){var{x:m,y}=ao(r,i,o+t,f);return{x:m,y,textAnchor:m>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var w=(a+o)/2,{x:A,y:k}=ao(r,i,w,f);return{x:A,y:k,textAnchor:"middle",verticalAnchor:"middle"}},Tw=e=>e!=null&&"cx"in e&&En(e.cx),TOe={angle:0,offset:5,zIndex:Sa.label,position:"middle",textBreakAll:!1};function OOe(e){if(!Tw(e))return e;var{cx:t,cy:n,outerRadius:r}=e,i=r*2;return{x:t-r,y:n-r,width:i,upperWidth:i,lowerWidth:i,height:i}}function Fh(e){var t=Fa(e,TOe),{viewBox:n,parentViewBox:r,position:i,value:a,children:o,content:c,className:h="",textBreakAll:f,labelRef:m}=t,y=SOe(),w=EJ(),A=i==="center"?w:y??w,k,I,T;n==null?k=A:Tw(n)?k=n:k=P4(n);var D=OOe(k);if(!k||xs(a)&&xs(o)&&!j.isValidElement(c)&&typeof c!="function")return null;var F=h1(h1({},t),{},{viewBox:k});if(j.isValidElement(c)){var{labelRef:L}=F,q=Bz(F,yOe);return j.cloneElement(c,q)}if(typeof c=="function"){var{content:Z}=F,K=Bz(F,bOe);if(I=j.createElement(c,K),j.isValidElement(I))return I}else I=kOe(t);var z=ko(t);if(Tw(k)){if(i==="insideStart"||i==="insideEnd"||i==="end")return IOe(t,i,I,z,k);T=jOe(k,t.offset,t.position)}else{if(!D)return null;var B=xOe({viewBox:D,position:i,offset:t.offset,parentViewBox:Tw(r)?void 0:r});T=h1(h1({x:B.x,y:B.y,textAnchor:B.horizontalAnchor,verticalAnchor:B.verticalAnchor},B.width!==void 0?{width:B.width}:{}),B.height!==void 0?{height:B.height}:{})}return j.createElement(Wl,{zIndex:t.zIndex},j.createElement(L3,Sd({ref:m,className:Di("recharts-label",h)},z,T,{textAnchor:yJ(z.textAnchor)?z.textAnchor:T.textAnchor,breakAll:f}),I))}Fh.displayName="Label";var POe=(e,t,n)=>{if(!e)return null;var r={viewBox:t,labelRef:n};return e===!0?j.createElement(Fh,Sd({key:"label-implicit"},r)):Uu(e)?j.createElement(Fh,Sd({key:"label-implicit",value:e},r)):j.isValidElement(e)?e.type===Fh?j.cloneElement(e,h1({key:"label-implicit"},r)):j.createElement(Fh,Sd({key:"label-implicit",content:e},r)):U3(e)?j.createElement(Fh,Sd({key:"label-implicit",content:e},r)):e&&typeof e=="object"?j.createElement(Fh,Sd({},e,{key:"label-implicit"},r)):null};function ROe(e){var{label:t,labelRef:n}=e,r=EJ();return POe(t,r,n)||null}var DOe=["valueAccessor"],MOe=["dataKey","clockWise","id","textBreakAll","zIndex"];function gN(){return gN=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t=Array.isArray(e.value)?e.value[e.value.length-1]:e.value;if(cOe(t))return t},AJ=j.createContext(void 0),B3=AJ.Provider,_J=j.createContext(void 0);_J.Provider;function BOe(){return j.useContext(AJ)}function zOe(){return j.useContext(_J)}function Ow(e){var{valueAccessor:t=UOe}=e,n=Vz(e,DOe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:c}=n,h=Vz(n,MOe),f=BOe(),m=zOe(),y=f||m;return!y||!y.length?null:j.createElement(Wl,{zIndex:c??Sa.label},j.createElement(oo,{className:"recharts-label-list"},y.map((w,A)=>{var k,I=xs(r)?t(w,A):Ds(w.payload,r),T=xs(a)?{}:{id:"".concat(a,"-").concat(A)};return j.createElement(Fh,gN({key:"label-".concat(A)},ko(w),h,T,{fill:(k=n.fill)!==null&&k!==void 0?k:w.fill,parentViewBox:w.parentViewBox,value:I,textBreakAll:o,viewBox:w.viewBox,index:A,zIndex:0}))})))}Ow.displayName="LabelList";function z3(e){var{label:t}=e;return t?t===!0?j.createElement(Ow,{key:"labelList-implicit"}):j.isValidElement(t)||U3(t)?j.createElement(Ow,{key:"labelList-implicit",content:t}):typeof t=="object"?j.createElement(Ow,gN({key:"labelList-implicit"},t,{type:String(t.type)})):null:null}function VI(){return VI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{cx:t,cy:n,r,className:i}=e,a=Di("recharts-dot",i);return En(t)&&En(n)&&En(r)?j.createElement("circle",VI({},Hl(e),N4(e),{className:a,cx:t,cy:n,r})):null},VOe={radiusAxis:{},angleAxis:{}},kJ=Io({name:"polarAxis",initialState:VOe,reducers:{addRadiusAxis(e,t){e.radiusAxis[t.payload.id]=t.payload},removeRadiusAxis(e,t){delete e.radiusAxis[t.payload.id]},addAngleAxis(e,t){e.angleAxis[t.payload.id]=t.payload},removeAngleAxis(e,t){delete e.angleAxis[t.payload.id]}}}),{addRadiusAxis:P9e,removeRadiusAxis:R9e,addAngleAxis:D9e,removeAngleAxis:M9e}=kJ.actions,FOe=kJ.reducer;function $Oe(e){return e&&typeof e=="object"&&"className"in e&&typeof e.className=="string"?e.className:""}var ik={exports:{}},Ki={};/** * @license React * react-is.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Fz;function HOe(){if(Fz)return Ki;Fz=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),w=Symbol.for("react.view_transition"),A=Symbol.for("react.client.reference");function k(I){if(typeof I=="object"&&I!==null){var T=I.$$typeof;switch(T){case e:switch(I=I.type,I){case n:case i:case r:case h:case f:case w:return I;default:switch(I=I&&I.$$typeof,I){case o:case c:case y:case m:return I;case a:return I;default:return T}}case t:return T}}}return Ki.ContextConsumer=a,Ki.ContextProvider=o,Ki.Element=e,Ki.ForwardRef=c,Ki.Fragment=n,Ki.Lazy=y,Ki.Memo=m,Ki.Portal=t,Ki.Profiler=i,Ki.StrictMode=r,Ki.Suspense=h,Ki.SuspenseList=f,Ki.isContextConsumer=function(I){return k(I)===a},Ki.isContextProvider=function(I){return k(I)===o},Ki.isElement=function(I){return typeof I=="object"&&I!==null&&I.$$typeof===e},Ki.isForwardRef=function(I){return k(I)===c},Ki.isFragment=function(I){return k(I)===n},Ki.isLazy=function(I){return k(I)===y},Ki.isMemo=function(I){return k(I)===m},Ki.isPortal=function(I){return k(I)===t},Ki.isProfiler=function(I){return k(I)===i},Ki.isStrictMode=function(I){return k(I)===r},Ki.isSuspense=function(I){return k(I)===h},Ki.isSuspenseList=function(I){return k(I)===f},Ki.isValidElementType=function(I){return typeof I=="string"||typeof I=="function"||I===n||I===i||I===r||I===h||I===f||typeof I=="object"&&I!==null&&(I.$$typeof===y||I.$$typeof===m||I.$$typeof===o||I.$$typeof===a||I.$$typeof===c||I.$$typeof===A||I.getModuleId!==void 0)},Ki.typeOf=k,Ki}var $z;function GOe(){return $z||($z=1,ik.exports=HOe()),ik.exports}var qOe=GOe(),Hz=e=>typeof e=="string"?e:e?e.displayName||e.name||"Component":"",Gz=null,sk=null,CJ=e=>{if(e===Gz&&Array.isArray(sk))return sk;var t=[];return j.Children.forEach(e,n=>{xs(n)||(qOe.isFragment(n)?t=t.concat(CJ(n.props.children)):t.push(n))}),sk=t,Gz=e,t};function WOe(e,t){var n=[],r=[];return Array.isArray(t)?r=t.map(i=>Hz(i)):r=[Hz(t)],CJ(e).forEach(i=>{var a=mg(i,"type.displayName")||mg(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var V3=e=>e&&typeof e=="object"&&"clipDot"in e?!!e.clipDot:!0,ak={},qz;function KOe(){return qz||(qz=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){var i;if(typeof n!="object"||n==null)return!1;if(Object.getPrototypeOf(n)===null)return!0;if(Object.prototype.toString.call(n)!=="[object Object]"){const a=n[Symbol.toStringTag];return a==null||!((i=Object.getOwnPropertyDescriptor(n,Symbol.toStringTag))!=null&&i.writable)?!1:n.toString()===`[object ${a}]`}let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r}e.isPlainObject=t})(ak)),ak}var ok,Wz;function YOe(){return Wz||(Wz=1,ok=KOe().isPlainObject),ok}var XOe=YOe();const QOe=Hu(XOe);var Kz,Yz,Xz,Qz,Zz;function Jz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function eV(e){for(var t=1;t{var a=n-r,o;return o=Hs(Kz||(Kz=Xx(["M ",",",""])),e,t),o+=Hs(Yz||(Yz=Xx(["L ",",",""])),e+n,t),o+=Hs(Xz||(Xz=Xx(["L ",",",""])),e+n-a/2,t+i),o+=Hs(Qz||(Qz=Xx(["L ",",",""])),e+n-a/2-r,t+i),o+=Hs(Zz||(Zz=Xx(["L ",","," Z"])),e,t),o},tPe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},nPe=e=>{var t=Fa(e,tPe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:c}=t,{animationEasing:h,animationDuration:f,animationBegin:m,isUpdateAnimationActive:y}=t,w=j.useRef(null),[A,k]=j.useState(-1),I=j.useRef(i),T=j.useRef(a),D=j.useRef(o),F=j.useRef(n),L=j.useRef(r),q=Qy(e,"trapezoid-");if(j.useEffect(()=>{if(w.current&&w.current.getTotalLength)try{var he=w.current.getTotalLength();he&&k(he)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var Z=Di("recharts-trapezoid",c);if(!y)return j.createElement("g",null,j.createElement("path",xN({},ko(t),{className:Z,d:tV(n,r,i,a,o)})));var K=I.current,z=T.current,B=D.current,V=F.current,$=L.current,Q="0px ".concat(A===-1?1:A,"px"),Y="".concat(A,"px ").concat(A,"px"),G=BX(["strokeDasharray"],f,h);return j.createElement(Xy,{animationId:q,key:q,canBegin:A>0,duration:f,easing:h,isActive:y,begin:m},he=>{var te=Xi(K,i,he),le=Xi(z,a,he),ve=Xi(B,o,he),ke=Xi(V,n,he),Be=Xi($,r,he);w.current&&(I.current=te,T.current=le,D.current=ve,F.current=ke,L.current=Be);var J=he>0?{transition:G,strokeDasharray:Y}:{strokeDasharray:Q};return j.createElement("path",xN({},ko(t),{className:Z,d:tV(ke,Be,te,le,ve),ref:w,style:eV(eV({},J),t.style)}))})},rPe=["option","shapeType","activeClassName","inActiveClassName"];function iPe(e,t){if(e==null)return{};var n,r,i=sPe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var r=ys();return(i,a)=>o=>{e==null||e(i,a,o),r(BZ({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},TJ=e=>{var t=ys();return(n,r)=>i=>{e==null||e(n,r,i),t(kTe())}},OJ=(e,t,n)=>{var r=ys();return(i,a)=>o=>{e==null||e(i,a,o),r(CTe({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function F3(e){var{tooltipEntrySettings:t}=e,n=ys(),r=Ha(),i=j.useRef(null);return j.useLayoutEffect(()=>{r||(i.current===null?n(ETe(t)):i.current!==t&&n(ATe({prev:i.current,next:t})),i.current=t)},[t,n,r]),j.useLayoutEffect(()=>()=>{i.current&&(n(_Te(i.current)),i.current=null)},[n]),null}function $3(e){var{legendPayload:t}=e,n=ys(),r=Ha(),i=j.useRef(null);return j.useLayoutEffect(()=>{r||(i.current===null?n(fSe(t)):i.current!==t&&n(pSe({prev:i.current,next:t})),i.current=t)},[n,r,t]),j.useLayoutEffect(()=>()=>{i.current&&(n(mSe(i.current)),i.current=null)},[n]),null}var lk,hPe=()=>{var[e]=j.useState(()=>ny("uid-"));return e},fPe=(lk=Qte.useId)!==null&&lk!==void 0?lk:hPe;function pPe(e,t){var n=fPe();return t||(e?"".concat(e,"-").concat(n):n)}var mPe=j.createContext(void 0),H3=e=>{var{id:t,type:n,children:r}=e,i=pPe("recharts-".concat(n),t);return j.createElement(mPe.Provider,{value:i},r(i))},gPe={cartesianItems:[],polarItems:[]},PJ=Io({name:"graphicalItems",initialState:gPe,reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(t.payload)},prepare:ps()},replaceCartesianGraphicalItem:{reducer(e,t){var{prev:n,next:r}=t.payload,i=lc(e).cartesianItems.indexOf(n);i>-1&&(e.cartesianItems[i]=r)},prepare:ps()},removeCartesianGraphicalItem:{reducer(e,t){var n=lc(e).cartesianItems.indexOf(t.payload);n>-1&&e.cartesianItems.splice(n,1)},prepare:ps()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(t.payload)},prepare:ps()},removePolarGraphicalItem:{reducer(e,t){var n=lc(e).polarItems.indexOf(t.payload);n>-1&&e.polarItems.splice(n,1)},prepare:ps()},replacePolarGraphicalItem:{reducer(e,t){var{prev:n,next:r}=t.payload,i=lc(e).polarItems.indexOf(n);i>-1&&(e.polarItems[i]=r)},prepare:ps()}}}),{addCartesianGraphicalItem:xPe,replaceCartesianGraphicalItem:yPe,removeCartesianGraphicalItem:bPe,addPolarGraphicalItem:L9e,removePolarGraphicalItem:U9e,replacePolarGraphicalItem:B9e}=PJ.actions,vPe=PJ.reducer,wPe=e=>{var t=ys(),n=j.useRef(null);return j.useLayoutEffect(()=>{n.current===null?t(xPe(e)):n.current!==e&&t(yPe({prev:n.current,next:e})),n.current=e},[t,e]),j.useLayoutEffect(()=>()=>{n.current&&(t(bPe(n.current)),n.current=null)},[t]),null},G3=j.memo(wPe),NPe=["points"];function iV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function ck(e){for(var t=1;t{var T,D,F=ck(ck(ck({r:3},o),y),{},{index:I,cx:(T=k.x)!==null&&T!==void 0?T:void 0,cy:(D=k.y)!==null&&D!==void 0?D:void 0,dataKey:a,value:k.value,payload:k.payload,points:t});return j.createElement(CPe,{key:"dot-".concat(I),option:n,dotProps:F,className:i})}),A={};return c&&h!=null&&(A.clipPath="url(#clipPath-".concat(m?"":"dots-").concat(h,")")),j.createElement(Wl,{zIndex:f},j.createElement(oo,bN({className:r},A),w))}function sV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function aV(e){for(var t=1;t({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),$Pe=et([FPe,Qd,Zd],(e,t,n)=>{if(!(!e||t==null||n==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,n-e.top-e.bottom)}}),oA=()=>Qn($Pe),HPe=()=>Qn(E4e);function oV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function uk(e){for(var t=1;t{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var c={index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:t.payload,value:t.value},h=uk(uk(uk({},c),Fy(i)),N4(i)),f;return j.isValidElement(i)?f=j.cloneElement(i,h):typeof i=="function"?f=i(h):f=j.createElement(SJ,h),j.createElement(oo,{className:"recharts-active-dot",clipPath:o},f)};function FI(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=Sa.activeDot}=e,c=Qn(um),h=HPe();if(t==null||h==null)return null;var f=t.find(m=>h.includes(m.payload));return xs(f)?null:j.createElement(Wl,{zIndex:o},j.createElement(KPe,{point:f,childIndex:Number(c),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var lV=(e,t,n)=>{var r=n??e;if(!xs(r))return Fc(r,t,0)},YPe=(e,t,n)=>{var r={},i=e.filter(YE),a=e.filter(f=>f.stackId==null),o=i.reduce((f,m)=>{var y=f[m.stackId];return y==null&&(y=[]),y.push(m),f[m.stackId]=y,f},r),c=Object.entries(o).map(f=>{var m,[y,w]=f,A=w.map(I=>I.dataKey),k=lV(t,n,(m=w[0])===null||m===void 0?void 0:m.barSize);return{stackId:y,dataKeys:A,barSize:k}}),h=a.map(f=>{var m=[f.dataKey].filter(w=>w!=null),y=lV(t,n,f.barSize);return{stackId:void 0,dataKeys:m,barSize:y}});return[...c,...h]};function cV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function qv(e){for(var t=1;tF+(L.barSize||0),0);w+=(o-1)*c,w>=n&&(w-=(o-1)*c,c=0),w>=n&&y>0&&(m=!0,y*=.9,w=o*y);var A=(n-w)/2>>0,k={offset:A-c,size:0};h=r.reduce((F,L)=>{var q,Z={stackId:L.stackId,dataKeys:L.dataKeys,position:{offset:k.offset+k.size+c,size:m?y:(q=L.barSize)!==null&&q!==void 0?q:0}},K=[...F,Z];return k=Z.position,K},f)}else{var I=Fc(t,n,0,!0);n-2*I-(o-1)*c<=0&&(c=0);var T=(n-2*I-(o-1)*c)/o;T>1&&(T>>=0);var D=qr(i)?Math.min(T,i):T;h=r.reduce((F,L,q)=>[...F,{stackId:L.stackId,dataKeys:L.dataKeys,position:{offset:I+(T+c)*q+(T-D)/2,size:D}}],f)}return h}}var e6e=(e,t,n,r,i,a,o)=>{var c=xs(o)?t:o,h=JPe(n,r,i!==a?i:a,e,c);return i!==a&&h!=null&&(h=h.map(f=>qv(qv({},f),{},{position:qv(qv({},f.position),{},{offset:f.position.offset-i/2})}))),h},t6e=(e,t)=>{var n=KE(t);if(!(!e||n==null||t==null)){var{stackId:r}=t;if(r!=null){var i=e[r];if(i){var{stackedData:a}=i;if(a)return a.find(o=>o.key===n)}}}},n6e=(e,t)=>{if(!(e==null||t==null)){var n=e.find(r=>r.stackId===t.stackId&&t.dataKey!=null&&r.dataKeys.includes(t.dataKey));if(n!=null)return n.position}};function r6e(e,t){return e&&typeof e=="object"&&"zIndex"in e&&typeof e.zIndex=="number"&&qr(e.zIndex)?e.zIndex:t}var i6e=e=>{var{chartData:t}=e,n=ys(),r=Ha();return j.useEffect(()=>r?()=>{}:(n(Ez(t)),()=>{n(Ez(void 0))}),[t,n,r]),null},uV={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},LJ=Io({name:"brush",initialState:uV,reducers:{setBrushSettings(e,t){return t.payload==null?uV:t.payload}}}),{setBrushSettings:$9e}=LJ.actions,s6e=LJ.reducer;function a6e(e){return(e%180+180)%180}var o6e=function(t){var{width:n,height:r}=t,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=a6e(i),o=a*Math.PI/180,c=Math.atan(r/n),h=o>c&&o{e.dots.push(t.payload)},removeDot:(e,t)=>{var n=lc(e).dots.findIndex(r=>r===t.payload);n!==-1&&e.dots.splice(n,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var n=lc(e).areas.findIndex(r=>r===t.payload);n!==-1&&e.areas.splice(n,1)},addLine:(e,t)=>{e.lines.push(t.payload)},removeLine:(e,t)=>{var n=lc(e).lines.findIndex(r=>r===t.payload);n!==-1&&e.lines.splice(n,1)}}}),{addDot:H9e,removeDot:G9e,addArea:q9e,removeArea:W9e,addLine:K9e,removeLine:Y9e}=UJ.actions,c6e=UJ.reducer,u6e=j.createContext(void 0),d6e=e=>{var{children:t}=e,[n]=j.useState("".concat(ny("recharts"),"-clip")),r=oA();if(r==null)return null;var{x:i,y:a,width:o,height:c}=r;return j.createElement(u6e.Provider,{value:n},j.createElement("defs",null,j.createElement("clipPath",{id:n},j.createElement("rect",{x:i,y:a,height:c,width:o}))),t)};function BJ(e,t){if(t<1)return[];if(t===1)return e;for(var n=[],r=0;re*i)return!1;var a=n();return e*(t-e*a/2-r)>=0&&e*(t+e*a/2-i)<=0}function p6e(e,t){return BJ(e,t+1)}function m6e(e,t,n,r,i){for(var a=(r||[]).slice(),{start:o,end:c}=t,h=0,f=1,m=o,y=function(){var k=r==null?void 0:r[h];if(k===void 0)return{v:BJ(r,f)};var I=h,T,D=()=>(T===void 0&&(T=n(k,I)),T),F=k.coordinate,L=h===0||gy(e,F,D,m,c);L||(h=0,m=o,f+=1),L&&(m=F+e*(D()/2+i),h+=f)},w;f<=a.length;)if(w=y(),w)return w.v;return[]}function g6e(e,t,n,r,i){var a=(r||[]).slice(),o=a.length;if(o===0)return[];for(var{start:c,end:h}=t,f=1;f<=o;f++){for(var m=(o-1)%f,y=c,w=!0,A=function(){var q=r[I];if(q==null)return 0;var Z=I,K,z=()=>(K===void 0&&(K=n(q,Z)),K),B=q.coordinate,V=I===m||gy(e,B,z,y,h);if(!V)return w=!1,1;V&&(y=B+e*(z()/2+i))},k,I=m;I(I===void 0&&(I=n(A,w)),I);if(w===o-1){var D=e*(k.coordinate+e*T()/2-h);a[w]=k=bo(bo({},k),{},{tickCoord:D>0?k.coordinate-D*e:k.coordinate})}else a[w]=k=bo(bo({},k),{},{tickCoord:k.coordinate});if(k.tickCoord!=null){var F=gy(e,k.tickCoord,T,c,h);F&&(h=k.tickCoord-e*(T()/2+i),a[w]=bo(bo({},k),{},{isShow:!0}))}},m=o-1;m>=0;m--)f(m);return a}function w6e(e,t,n,r,i,a){var o=(r||[]).slice(),c=o.length,{start:h,end:f}=t;if(a){var m=r[c-1];if(m!=null){var y=n(m,c-1),w=e*(m.coordinate+e*y/2-f);if(o[c-1]=m=bo(bo({},m),{},{tickCoord:w>0?m.coordinate-w*e:m.coordinate}),m.tickCoord!=null){var A=gy(e,m.tickCoord,()=>y,h,f);A&&(f=m.tickCoord-e*(y/2+i),o[c-1]=bo(bo({},m),{},{isShow:!0}))}}}for(var k=a?c-1:c,I=function(F){var L=o[F];if(L==null)return 1;var q=L,Z,K=()=>(Z===void 0&&(Z=n(L,F)),Z);if(F===0){var z=e*(q.coordinate-e*K()/2-h);o[F]=q=bo(bo({},q),{},{tickCoord:z<0?q.coordinate-z*e:q.coordinate})}else o[F]=q=bo(bo({},q),{},{tickCoord:q.coordinate});if(q.tickCoord!=null){var B=gy(e,q.tickCoord,K,h,f);B&&(h=q.tickCoord+e*(K()/2+i),o[F]=bo(bo({},q),{},{isShow:!0}))}},T=0;T{var z=typeof f=="function"?f(Z.value,K):Z.value;return k==="width"?h6e(D1(z,{fontSize:t,letterSpacing:n}),I,y):D1(z,{fontSize:t,letterSpacing:n})[k]},D=i[0],F=i[1],L=i.length>=2&&D!=null&&F!=null?xl(F.coordinate-D.coordinate):1,q=f6e(a,L,k);return h==="equidistantPreserveStart"?m6e(L,q,T,i,o):h==="equidistantPreserveEnd"?g6e(L,q,T,i,o):(h==="preserveStart"||h==="preserveStartEnd"?A=w6e(L,q,T,i,o,h==="preserveStartEnd"):A=v6e(L,q,T,i,o),A.filter(Z=>Z.isShow))}var N6e=e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=e,o=0;if(t){Array.from(t).forEach(m=>{if(m){var y=m.getBoundingClientRect();y.width>o&&(o=y.width)}});var c=n?n.getBoundingClientRect().width:0,h=i+a,f=o+h+c+(n?r:0);return Math.round(f)}return 0},E6e={xAxis:{},yAxis:{}},zJ=Io({name:"renderedTicks",initialState:E6e,reducers:{setRenderedTicks:(e,t)=>{var{axisType:n,axisId:r,ticks:i}=t.payload;e[n][r]=i},removeRenderedTicks:(e,t)=>{var{axisType:n,axisId:r}=t.payload;delete e[n][r]}}}),{setRenderedTicks:A6e,removeRenderedTicks:_6e}=zJ.actions,S6e=zJ.reducer,k6e=["axisLine","width","height","className","hide","ticks","axisType","axisId"];function C6e(e,t){if(e==null)return{};var n,r,i=I6e(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{if(r==null||n==null)return jf;var a=t.map(o=>({value:o.value,coordinate:o.coordinate,offset:o.offset,index:o.index}));return i(A6e({ticks:a,axisId:r,axisType:n})),()=>{i(_6e({axisId:r,axisType:n}))}},[i,t,r,n]),null}var B6e=j.forwardRef((e,t)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:o,unit:c,padding:h,tickTextProps:f,orientation:m,mirror:y,x:w,y:A,width:k,height:I,tickSize:T,tickMargin:D,fontSize:F,letterSpacing:L,getTicksConfig:q,events:Z,axisType:K,axisId:z}=e,B=q3(Fs(Fs({},q),{},{ticks:n}),F,L),V=Hl(q),$=Fy(r),Q=yJ(V.textAnchor)?V.textAnchor:D6e(m,y),Y=M6e(m,y),G={};typeof i=="object"&&(G=i);var he=Fs(Fs({},V),{},{fill:"none"},G),te=B.map(ke=>Fs({entry:ke},R6e(ke,w,A,k,I,m,T,y,D))),le=te.map(ke=>{var{entry:Be,line:J}=ke;return j.createElement(oo,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Be.value,"-").concat(Be.coordinate,"-").concat(Be.tickCoord)},i&&j.createElement("line",dm({},he,J,{className:Di("recharts-cartesian-axis-tick-line",mg(i,"className"))})))}),ve=te.map((ke,Be)=>{var J,ie,{entry:xe,tick:ae}=ke,Fe=Fs(Fs(Fs(Fs({verticalAnchor:Y},V),{},{textAnchor:Q,stroke:"none",fill:a},ae),{},{index:Be,payload:xe,visibleTicksCount:B.length,tickFormatter:o,padding:h},f),{},{angle:(J=(ie=f==null?void 0:f.angle)!==null&&ie!==void 0?ie:V.angle)!==null&&J!==void 0?J:0}),pt=Fs(Fs({},Fe),$);return j.createElement(oo,dm({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(xe.value,"-").concat(xe.coordinate,"-").concat(xe.tickCoord)},AE(Z,xe,Be)),r&&j.createElement(L6e,{option:r,tickProps:pt,value:"".concat(typeof o=="function"?o(xe.value,Be):xe.value).concat(c||"")}))});return j.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(K,"-ticks")},j.createElement(U6e,{ticks:B,axisId:z,axisType:K}),ve.length>0&&j.createElement(Wl,{zIndex:Sa.label},j.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(K,"-tick-labels"),ref:t},ve)),le.length>0&&j.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(K,"-tick-lines")},le))}),z6e=j.forwardRef((e,t)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:c,axisType:h,axisId:f}=e,m=C6e(e,k6e),[y,w]=j.useState(""),[A,k]=j.useState(""),I=j.useRef(null);j.useImperativeHandle(t,()=>({getCalculatedWidth:()=>{var D;return N6e({ticks:I.current,label:(D=e.labelRef)===null||D===void 0?void 0:D.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var T=j.useCallback(D=>{if(D){var F=D.getElementsByClassName("recharts-cartesian-axis-tick-value");I.current=F;var L=F[0];if(L){var q=window.getComputedStyle(L),Z=q.fontSize,K=q.letterSpacing;(Z!==y||K!==A)&&(w(Z),k(K))}}},[y,A]);return o||r!=null&&r<=0||i!=null&&i<=0?null:j.createElement(Wl,{zIndex:e.zIndex},j.createElement(oo,{className:Di("recharts-cartesian-axis",a)},j.createElement(P6e,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:Hl(e)}),j.createElement(B6e,{ref:T,axisType:h,events:m,fontSize:y,getTicksConfig:e,height:e.height,letterSpacing:A,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:c,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:f}),j.createElement(AOe,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},j.createElement(ROe,{label:e.label,labelRef:e.labelRef}),e.children)))}),W3=j.forwardRef((e,t)=>{var n=Fa(e,Dd);return j.createElement(z6e,dm({},n,{ref:t}))});W3.displayName="CartesianAxis";var V6e=["x1","y1","x2","y2","key"],F6e=["offset"],$6e=["xAxisId","yAxisId"],H6e=["xAxisId","yAxisId"];function fV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Eo(e){for(var t=1;t{var{fill:t}=e;if(!t||t==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:c}=e;return j.createElement("rect",{x:r,y:i,ry:c,width:a,height:o,stroke:"none",fill:t,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function VJ(e){var{option:t,lineItemProps:n}=e,r;if(j.isValidElement(t))r=j.cloneElement(t,n);else if(typeof t=="function")r=t(n);else{var i,{x1:a,y1:o,x2:c,y2:h,key:f}=n,m=vN(n,V6e),y=(i=Hl(m))!==null&&i!==void 0?i:{},{offset:w}=y,A=vN(y,F6e);r=j.createElement("line",kp({},A,{x1:a,y1:o,x2:c,y2:h,fill:"none",key:f}))}return r}function X6e(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,c=vN(e,$6e),h=i.map((f,m)=>{var y=Eo(Eo({},c),{},{x1:t,y1:f,x2:t+n,y2:f,key:"line-".concat(m),index:m});return j.createElement(VJ,{key:"line-".concat(m),option:r,lineItemProps:y})});return j.createElement("g",{className:"recharts-cartesian-grid-horizontal"},h)}function Q6e(e){var{y:t,height:n,vertical:r=!0,verticalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,c=vN(e,H6e),h=i.map((f,m)=>{var y=Eo(Eo({},c),{},{x1:f,y1:t,x2:f,y2:t+n,key:"line-".concat(m),index:m});return j.createElement(VJ,{option:r,lineItemProps:y,key:"line-".concat(m)})});return j.createElement("g",{className:"recharts-cartesian-grid-vertical"},h)}function Z6e(e){var{horizontalFill:t,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:c,horizontal:h=!0}=e;if(!h||!t||!t.length||c==null)return null;var f=c.map(y=>Math.round(y+i-i)).sort((y,w)=>y-w);i!==f[0]&&f.unshift(0);var m=f.map((y,w)=>{var A=f[w+1],k=A==null,I=k?i+o-y:A-y;if(I<=0)return null;var T=w%t.length;return j.createElement("rect",{key:"react-".concat(w),y,x:r,height:I,width:a,stroke:"none",fill:t[T],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return j.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},m)}function J6e(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:c,verticalPoints:h}=e;if(!t||!n||!n.length)return null;var f=h.map(y=>Math.round(y+i-i)).sort((y,w)=>y-w);i!==f[0]&&f.unshift(0);var m=f.map((y,w)=>{var A=f[w+1],k=A==null,I=k?i+o-y:A-y;if(I<=0)return null;var T=w%n.length;return j.createElement("rect",{key:"react-".concat(w),x:y,y:a,width:I,height:c,stroke:"none",fill:n[T],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return j.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},m)}var eRe=(e,t)=>{var{xAxis:n,width:r,height:i,offset:a}=e;return vX(q3(Eo(Eo(Eo({},Dd),n),{},{ticks:wX(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},tRe=(e,t)=>{var{yAxis:n,width:r,height:i,offset:a}=e;return vX(q3(Eo(Eo(Eo({},Dd),n),{},{ticks:wX(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},nRe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Sa.grid};function FJ(e){var t=R4(),n=D4(),r=kX(),i=Eo(Eo({},Fa(e,nRe)),{},{x:En(e.x)?e.x:r.left,y:En(e.y)?e.y:r.top,width:En(e.width)?e.width:r.width,height:En(e.height)?e.height:r.height}),{xAxisId:a,yAxisId:o,x:c,y:h,width:f,height:m,syncWithTicks:y,horizontalValues:w,verticalValues:A}=i,k=Ha(),I=Qn(V=>uz(V,"xAxis",a,k)),T=Qn(V=>uz(V,"yAxis",o,k));if(!Bu(f)||!Bu(m)||!En(c)||!En(h))return null;var D=i.verticalCoordinatesGenerator||eRe,F=i.horizontalCoordinatesGenerator||tRe,{horizontalPoints:L,verticalPoints:q}=i;if((!L||!L.length)&&typeof F=="function"){var Z=w&&w.length,K=F({yAxis:T?Eo(Eo({},T),{},{ticks:Z?w:T.ticks}):void 0,width:t??f,height:n??m,offset:r},Z?!0:y);H2(Array.isArray(K),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof K,"]")),Array.isArray(K)&&(L=K)}if((!q||!q.length)&&typeof D=="function"){var z=A&&A.length,B=D({xAxis:I?Eo(Eo({},I),{},{ticks:z?A:I.ticks}):void 0,width:t??f,height:n??m,offset:r},z?!0:y);H2(Array.isArray(B),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof B,"]")),Array.isArray(B)&&(q=B)}return j.createElement(Wl,{zIndex:i.zIndex},j.createElement("g",{className:"recharts-cartesian-grid"},j.createElement(Y6e,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),j.createElement(Z6e,kp({},i,{horizontalPoints:L})),j.createElement(J6e,kp({},i,{verticalPoints:q})),j.createElement(X6e,kp({},i,{offset:r,horizontalPoints:L,xAxis:I,yAxis:T})),j.createElement(Q6e,kp({},i,{offset:r,verticalPoints:q,xAxis:I,yAxis:T}))))}FJ.displayName="CartesianGrid";var rRe={},$J=Io({name:"errorBars",initialState:rRe,reducers:{addErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]||(e[n]=[]),e[n].push(r)},replaceErrorBar:(e,t)=>{var{itemId:n,prev:r,next:i}=t.payload;e[n]&&(e[n]=e[n].map(a=>a.dataKey===r.dataKey&&a.direction===r.direction?i:a))},removeErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]&&(e[n]=e[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:X9e,replaceErrorBar:Q9e,removeErrorBar:Z9e}=$J.actions,iRe=$J.reducer,sRe=["children"];function aRe(e,t){if(e==null)return{};var n,r,i=oRe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0},cRe=j.createContext(lRe);function HJ(e){var{children:t}=e,n=aRe(e,sRe);return j.createElement(cRe.Provider,{value:n},t)}function lA(e,t){var n,r,i=Qn(f=>eh(f,e)),a=Qn(f=>th(f,t)),o=(n=i==null?void 0:i.allowDataOverflow)!==null&&n!==void 0?n:wa.allowDataOverflow,c=(r=a==null?void 0:a.allowDataOverflow)!==null&&r!==void 0?r:Na.allowDataOverflow,h=o||c;return{needClip:h,needClipX:o,needClipY:c}}function K3(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,i=oA(),{needClipX:a,needClipY:o,needClip:c}=lA(t,n);if(!c||!i)return null;var{x:h,y:f,width:m,height:y}=i;return j.createElement("clipPath",{id:"clipPath-".concat(r)},j.createElement("rect",{x:a?h:h-m/2,y:o?f:f-y/2,width:a?m:m*2,height:o?y:y*2}))}var GJ=(e,t,n,r)=>$u(e,"xAxis",t,r),qJ=(e,t,n,r)=>Fu(e,"xAxis",t,r),WJ=(e,t,n,r)=>$u(e,"yAxis",n,r),KJ=(e,t,n,r)=>Fu(e,"yAxis",n,r),uRe=et([_i,GJ,WJ,qJ,KJ],(e,t,n,r,i)=>Gc(e,"xAxis")?yf(t,r,!1):yf(n,i,!1)),dRe=(e,t,n,r,i)=>i;function hRe(e){return e.type==="line"}var fRe=et([ib,dRe],(e,t)=>e.filter(hRe).find(n=>n.id===t)),pRe=et([_i,GJ,WJ,qJ,KJ,fRe,uRe,Zy],(e,t,n,r,i,a,o,c)=>{var{chartData:h,dataStartIndex:f,dataEndIndex:m}=c;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!=="horizontal"&&e!=="vertical")){var{dataKey:y,data:w}=a,A;if(w!=null&&w.length>0?A=w:A=h==null?void 0:h.slice(f,m+1),A!=null)return RRe({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:y,bandSize:o,displayedData:A})}});function YJ(e){var t=Fy(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),c=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(c)||c<0)&&(c=r),{r:o,strokeWidth:c}}return{r:n,strokeWidth:r}}var mRe=["id"],gRe=["type","layout","connectNulls","needClip","shape"],xRe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function xy(){return xy=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:Lg(n,t),payload:e}]},ERe=j.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:c,unit:h,tooltipType:f,id:m}=e,y={dataDefinedOnItem:n,getPosition:jf,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Lg(o,t),hide:c,type:f,color:r,unit:h,graphicalItemId:m}};return j.createElement(F3,{tooltipEntrySettings:y})}),XJ=(e,t)=>"".concat(t,"px ").concat(e,"px");function ARe(e,t){for(var n=e.length%2!==0?[...e,0]:e,r=[],i=0;i{var r=n.reduce((w,A)=>w+A,0);if(!r)return XJ(t,e);for(var i=Math.floor(e/r),a=e%r,o=[],c=0,h=0;ca){o=[...n.slice(0,c),a-h];break}}var y=o.length%2===0?[0,t]:[t];return[...ARe(n,i),...o,...y].map(w=>"".concat(w,"px")).join(", ")};function SRe(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:c}=r,h=Y3(r,mRe),f=Hl(h);return j.createElement(RJ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:f,needClip:o,clipPathId:t})}function kRe(e){var{showLabels:t,children:n,points:r}=e,i=j.useMemo(()=>r==null?void 0:r.map(a=>{var o,c,h={x:(o=a.x)!==null&&o!==void 0?o:0,y:(c=a.y)!==null&&c!==void 0?c:0,width:0,lowerWidth:0,upperWidth:0,height:0};return yu(yu({},h),{},{value:a.value,payload:a.payload,viewBox:h,parentViewBox:void 0,fill:void 0})}),[r]);return j.createElement(B3,{value:t?i:void 0},n)}function mV(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:c,connectNulls:h,needClip:f,shape:m}=a,y=Y3(a,gRe),w=yu(yu({},ko(y)),{},{fill:"none",className:"recharts-line-curve",clipPath:f?"url(#clipPath-".concat(t,")"):void 0,points:r,type:o,layout:c,connectNulls:h,strokeDasharray:i??a.strokeDasharray});return j.createElement(j.Fragment,null,(r==null?void 0:r.length)>1&&j.createElement(IJ,xy({shapeType:"curve",option:m},w,{pathRef:n})),j.createElement(SRe,{points:r,clipPathId:t,props:a}))}function CRe(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function IRe(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:c,isAnimationActive:h,animationBegin:f,animationDuration:m,animationEasing:y,animateNewValues:w,width:A,height:k,onAnimationEnd:I,onAnimationStart:T}=n,D=i.current,F=Qy(o,"recharts-line-"),L=j.useRef(F),[q,Z]=j.useState(!1),K=!q,z=j.useCallback(()=>{typeof I=="function"&&I(),Z(!1)},[I]),B=j.useCallback(()=>{typeof T=="function"&&T(),Z(!0)},[T]),V=CRe(r.current),$=j.useRef(0);L.current!==F&&($.current=a.current,L.current=F);var Q=$.current;return j.createElement(kRe,{points:o,showLabels:K},n.children,j.createElement(Xy,{animationId:F,begin:f,duration:m,isActive:h,easing:y,onAnimationEnd:z,onAnimationStart:B,key:F},Y=>{var G=Xi(Q,V+Q,Y),he=Math.min(G,V),te;if(h)if(c){var le="".concat(c).split(/[,\s]+/gim).map(Be=>parseFloat(Be));te=_Re(he,V,le)}else te=XJ(V,he);else te=c==null?void 0:String(c);if(Y>0&&V>0&&(i.current=o,a.current=Math.max(a.current,he)),D){var ve=D.length/o.length,ke=Y===1?o:o.map((Be,J)=>{var ie=Math.floor(J*ve);if(D[ie]){var xe=D[ie];return yu(yu({},Be),{},{x:Xi(xe.x,Be.x,Y),y:Xi(xe.y,Be.y,Y)})}return w?yu(yu({},Be),{},{x:Xi(A*2,Be.x,Y),y:Xi(k/2,Be.y,Y)}):yu(yu({},Be),{},{x:Be.x,y:Be.y})});return i.current=ke,j.createElement(mV,{props:n,points:ke,clipPathId:t,pathRef:r,strokeDasharray:te})}return j.createElement(mV,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:te})}),j.createElement(z3,{label:n.label}))}function jRe(e){var{clipPathId:t,props:n}=e,r=j.useRef(null),i=j.useRef(0),a=j.useRef(null);return j.createElement(IRe,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var TRe=(e,t)=>{var n,r;return{x:(n=e.x)!==null&&n!==void 0?n:void 0,y:(r=e.y)!==null&&r!==void 0?r:void 0,value:e.value,errorVal:Ds(e.payload,t)}};class ORe extends j.Component{render(){var{hide:t,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:c,left:h,width:f,height:m,id:y,needClip:w,zIndex:A}=this.props;if(t)return null;var k=Di("recharts-line",i),I=y,{r:T,strokeWidth:D}=YJ(n),F=V3(n),L=T*2+D,q=w?"url(#clipPath-".concat(F?"":"dots-").concat(I,")"):void 0;return j.createElement(Wl,{zIndex:A},j.createElement(oo,{className:k},w&&j.createElement("defs",null,j.createElement(K3,{clipPathId:I,xAxisId:a,yAxisId:o}),!F&&j.createElement("clipPath",{id:"clipPath-dots-".concat(I)},j.createElement("rect",{x:h-L/2,y:c-L/2,width:f+L,height:m+L}))),j.createElement(HJ,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:TRe,errorBarOffset:0},j.createElement(jRe,{props:this.props,clipPathId:I}))),j.createElement(FI,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:q}))}}var QJ={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:Sa.line,type:"linear"};function PRe(e){var t=Fa(e,QJ),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:c,dot:h,hide:f,isAnimationActive:m,label:y,legendType:w,xAxisId:A,yAxisId:k,id:I}=t,T=Y3(t,xRe),{needClip:D}=lA(A,k),F=oA(),L=Tf(),q=Ha(),Z=Qn($=>pRe($,A,k,q,I));if(L!=="horizontal"&&L!=="vertical"||Z==null||F==null)return null;var{height:K,width:z,x:B,y:V}=F;return j.createElement(ORe,xy({},T,{id:I,connectNulls:c,dot:h,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:m,hide:f,label:y,legendType:w,xAxisId:A,yAxisId:k,points:Z,layout:L,height:K,width:z,left:B,top:V,needClip:D}))}function RRe(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:c,displayedData:h}=e;return h.map((f,m)=>{var y=Ds(f,o);if(t==="horizontal"){var w=$2({axis:n,ticks:i,bandSize:c,entry:f,index:m}),A=xs(y)?null:r.scale.map(y);return{x:w,y:A??null,value:y,payload:f}}var k=xs(y)?null:n.scale.map(y),I=$2({axis:r,ticks:a,bandSize:c,entry:f,index:m});return k==null||I==null?null:{x:k,y:I,value:y,payload:f}}).filter(Boolean)}function DRe(e){var t=Fa(e,QJ),n=Ha();return j.createElement(H3,{id:t.id,type:"line"},r=>j.createElement(j.Fragment,null,j.createElement($3,{legendPayload:NRe(t)}),j.createElement(ERe,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:r}),j.createElement(G3,{type:"line",id:r,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),j.createElement(PRe,xy({},t,{id:r}))))}var ZJ=j.memo(DRe,ym);ZJ.displayName="Line";function qu(e,t){var n,r;return(n=(r=e.graphicalItems.cartesianItems.find(i=>i.id===t))===null||r===void 0?void 0:r.xAxisId)!==null&&n!==void 0?n:DJ}function Wu(e,t){var n,r;return(n=(r=e.graphicalItems.cartesianItems.find(i=>i.id===t))===null||r===void 0?void 0:r.yAxisId)!==null&&n!==void 0?n:DJ}var JJ=(e,t,n)=>$u(e,"xAxis",qu(e,t),n),eee=(e,t,n)=>Fu(e,"xAxis",qu(e,t),n),tee=(e,t,n)=>$u(e,"yAxis",Wu(e,t),n),nee=(e,t,n)=>Fu(e,"yAxis",Wu(e,t),n),MRe=et([_i,JJ,tee,eee,nee],(e,t,n,r,i)=>Gc(e,"xAxis")?yf(t,r,!1):yf(n,i,!1)),LRe=(e,t)=>t,ree=et([ib,LRe],(e,t)=>e.filter(n=>n.type==="area").find(n=>n.id===t)),iee=e=>{var t=_i(e),n=Gc(t,"xAxis");return n?"yAxis":"xAxis"},URe=(e,t)=>{var n=iee(e);return n==="yAxis"?Wu(e,t):qu(e,t)},BRe=(e,t,n)=>hN(e,iee(e),URe(e,t),n),zRe=et([ree,BRe],(e,t)=>{var n;if(!(e==null||t==null)){var{stackId:r}=e,i=KE(e);if(!(r==null||i==null)){var a=(n=t[r])===null||n===void 0?void 0:n.stackedData,o=a==null?void 0:a.find(c=>c.key===i);if(o!=null)return o.map(c=>[c[0],c[1]])}}}),VRe=et([_i,JJ,tee,eee,nee,zRe,KX,MRe,ree,jke],(e,t,n,r,i,a,o,c,h,f)=>{var{chartData:m,dataStartIndex:y,dataEndIndex:w}=o;if(!(h==null||e!=="horizontal"&&e!=="vertical"||t==null||n==null||r==null||i==null||r.length===0||i.length===0||c==null)){var{data:A}=h,k;if(A&&A.length>0?k=A:k=m==null?void 0:m.slice(y,w+1),k!=null)return oDe({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:y,areaSettings:h,stackedData:a,displayedData:k,chartBaseValue:f,bandSize:c})}}),FRe=["id"],$Re=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function zp(){return zp=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,stroke:r,fill:i,legendType:a,hide:o}=e;return[{inactive:o,dataKey:t,type:a,color:wN(r,i),value:Lg(n,t),payload:e}]},YRe=j.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:c,unit:h,tooltipType:f,id:m}=e,y={dataDefinedOnItem:n,getPosition:jf,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Lg(o,t),hide:c,type:f,color:wN(r,a),unit:h,graphicalItemId:m}};return j.createElement(F3,{tooltipEntrySettings:y})});function XRe(e){var{clipPathId:t,points:n,props:r}=e,{needClip:i,dot:a,dataKey:o}=r,c=Hl(r);return j.createElement(RJ,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:c,needClip:i,clipPathId:t})}function QRe(e){var{showLabels:t,children:n,points:r}=e,i=r.map(a=>{var o,c,h={x:(o=a.x)!==null&&o!==void 0?o:0,y:(c=a.y)!==null&&c!==void 0?c:0,width:0,lowerWidth:0,upperWidth:0,height:0};return T0(T0({},h),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:h,fill:void 0})});return j.createElement(B3,{value:t?i:void 0},n)}function xV(e){var{points:t,baseLine:n,needClip:r,clipPathId:i,props:a}=e,{layout:o,type:c,stroke:h,connectNulls:f,isRange:m}=a,{id:y}=a,w=see(a,FRe),A=Hl(w),k=ko(w);return j.createElement(j.Fragment,null,(t==null?void 0:t.length)>1&&j.createElement(oo,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},j.createElement(P1,zp({},k,{id:y,points:t,connectNulls:f,type:c,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),h!=="none"&&j.createElement(P1,zp({},A,{className:"recharts-area-curve",layout:o,type:c,connectNulls:f,fill:"none",points:t})),h!=="none"&&m&&Array.isArray(n)&&j.createElement(P1,zp({},A,{className:"recharts-area-curve",layout:o,type:c,connectNulls:f,fill:"none",points:n}))),j.createElement(XRe,{points:t,props:w,clipPathId:i}))}function ZRe(e){var t,n,{alpha:r,baseLine:i,points:a,strokeWidth:o}=e,c=(t=a[0])===null||t===void 0?void 0:t.y,h=(n=a[a.length-1])===null||n===void 0?void 0:n.y;if(!qr(c)||!qr(h))return null;var f=r*Math.abs(c-h),m=Math.max(...a.map(y=>y.x||0));return En(i)?m=Math.max(i,m):i&&Array.isArray(i)&&i.length&&(m=Math.max(...i.map(y=>y.x||0),m)),En(m)?j.createElement("rect",{x:0,y:cy.y||0));return En(i)?m=Math.max(i,m):i&&Array.isArray(i)&&i.length&&(m=Math.max(...i.map(y=>y.y||0),m)),En(m)?j.createElement("rect",{x:c({points:o,baseLine:c}),[o,c]),I=Qy(k,"recharts-area-"),T=M4(),[D,F]=j.useState(!1),L=!D,q=j.useCallback(()=>{typeof A=="function"&&A(),F(!1)},[A]),Z=j.useCallback(()=>{typeof w=="function"&&w(),F(!0)},[w]);if(T==null)return null;var K=i.current,z=a.current;return j.createElement(QRe,{showLabels:L,points:o},r.children,j.createElement(Xy,{animationId:I,begin:f,duration:m,isActive:h,easing:y,onAnimationEnd:q,onAnimationStart:Z,key:I},B=>{if(K){var V=K.length/o.length,$=B===1?o:o.map((Y,G)=>{var he=Math.floor(G*V);if(K[he]){var te=K[he];return T0(T0({},Y),{},{x:Xi(te.x,Y.x,B),y:Xi(te.y,Y.y,B)})}return Y}),Q;return En(c)?Q=Xi(z,c,B):xs(c)||Vc(c)?Q=Xi(z,0,B):Q=c.map((Y,G)=>{var he=Math.floor(G*V);if(Array.isArray(z)&&z[he]){var te=z[he];return T0(T0({},Y),{},{x:Xi(te.x,Y.x,B),y:Xi(te.y,Y.y,B)})}return Y}),B>0&&(i.current=$,a.current=Q),j.createElement(xV,{points:$,baseLine:Q,needClip:t,clipPathId:n,props:r})}return B>0&&(i.current=o,a.current=c),j.createElement(oo,null,h&&j.createElement("defs",null,j.createElement("clipPath",{id:"animationClipPath-".concat(n)},j.createElement(eDe,{alpha:B,points:o,baseLine:c,layout:T,strokeWidth:r.strokeWidth}))),j.createElement(oo,{clipPath:"url(#animationClipPath-".concat(n,")")},j.createElement(xV,{points:o,baseLine:c,needClip:t,clipPathId:n,props:r})))}),j.createElement(z3,{label:r.label}))}function nDe(e){var{needClip:t,clipPathId:n,props:r}=e,i=j.useRef(null),a=j.useRef();return j.createElement(tDe,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class rDe extends j.PureComponent{render(){var{hide:t,dot:n,points:r,className:i,top:a,left:o,needClip:c,xAxisId:h,yAxisId:f,width:m,height:y,id:w,baseLine:A,zIndex:k}=this.props;if(t)return null;var I=Di("recharts-area",i),T=w,{r:D,strokeWidth:F}=YJ(n),L=V3(n),q=D*2+F,Z=c?"url(#clipPath-".concat(L?"":"dots-").concat(T,")"):void 0;return j.createElement(Wl,{zIndex:k},j.createElement(oo,{className:I},c&&j.createElement("defs",null,j.createElement(K3,{clipPathId:T,xAxisId:h,yAxisId:f}),!L&&j.createElement("clipPath",{id:"clipPath-dots-".concat(T)},j.createElement("rect",{x:o-q/2,y:a-q/2,width:m+q,height:y+q}))),j.createElement(nDe,{needClip:c,clipPathId:T,props:this.props})),j.createElement(FI,{points:r,mainColor:wN(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:Z}),this.props.isRange&&Array.isArray(A)&&j.createElement(FI,{points:A,mainColor:wN(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:Z}))}}var iDe={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:Sa.area};function sDe(e){var t,{activeDot:n,animationBegin:r,animationDuration:i,animationEasing:a,connectNulls:o,dot:c,fill:h,fillOpacity:f,hide:m,isAnimationActive:y,legendType:w,stroke:A,xAxisId:k,yAxisId:I}=e,T=see(e,$Re),D=Tf(),F=iJ(),{needClip:L}=lA(k,I),q=Ha(),{points:Z,isRange:K,baseLine:z}=(t=Qn(G=>VRe(G,e.id,q)))!==null&&t!==void 0?t:{},B=oA();if(D!=="horizontal"&&D!=="vertical"||B==null||F!=="AreaChart"&&F!=="ComposedChart")return null;var{height:V,width:$,x:Q,y:Y}=B;return!Z||!Z.length?null:j.createElement(rDe,zp({},T,{activeDot:n,animationBegin:r,animationDuration:i,animationEasing:a,baseLine:z,connectNulls:o,dot:c,fill:h,fillOpacity:f,height:V,hide:m,layout:D,isAnimationActive:y,isRange:K,legendType:w,needClip:L,points:Z,stroke:A,width:$,left:Q,top:Y,xAxisId:k,yAxisId:I}))}var aDe=(e,t,n,r,i)=>{var a=n??t;if(En(a))return a;var o=e==="horizontal"?i:r,c=o.scale.domain();if(o.type==="number"){var h=Math.max(c[0],c[1]),f=Math.min(c[0],c[1]);return a==="dataMin"?f:a==="dataMax"||h<0?h:Math.max(Math.min(c[0],c[1]),0)}return a==="dataMin"?c[0]:a==="dataMax"?c[1]:c[0]};function oDe(e){var{areaSettings:{connectNulls:t,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:c,yAxis:h,displayedData:f,dataStartIndex:m,xAxisTicks:y,yAxisTicks:w,bandSize:A}=e,k=i&&i.length,I=aDe(a,o,n,c,h),T=a==="horizontal",D=!1,F=f.map((q,Z)=>{var K,z,B,V;if(k)V=i[m+Z];else{var $=Ds(q,r);Array.isArray($)?(V=$,D=!0):V=[I,$]}var Q=(K=(z=V)===null||z===void 0?void 0:z[1])!==null&&K!==void 0?K:null,Y=Q==null||k&&!t&&Ds(q,r)==null;if(T){var G;return{x:$2({axis:c,ticks:y,bandSize:A,entry:q,index:Z}),y:Y?null:(G=h.scale.map(Q))!==null&&G!==void 0?G:null,value:V,payload:q}}return{x:Y?null:(B=c.scale.map(Q))!==null&&B!==void 0?B:null,y:$2({axis:h,ticks:w,bandSize:A,entry:q,index:Z}),value:V,payload:q}}),L;return k||D?L=F.map(q=>{var Z,K=Array.isArray(q.value)?q.value[0]:null;if(T){var z;return{x:q.x,y:K!=null&&q.y!=null&&(z=h.scale.map(K))!==null&&z!==void 0?z:null,payload:q.payload}}return{x:K!=null&&(Z=c.scale.map(K))!==null&&Z!==void 0?Z:null,y:q.y,payload:q.payload}}):L=T?h.scale.map(I):c.scale.map(I),{points:F,baseLine:L??0,isRange:D}}function lDe(e){var t=Fa(e,iDe),n=Ha();return j.createElement(H3,{id:t.id,type:"area"},r=>j.createElement(j.Fragment,null,j.createElement($3,{legendPayload:KRe(t)}),j.createElement(YRe,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:r}),j.createElement(G3,{type:"area",id:r,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:NX(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),j.createElement(sDe,zp({},t,{id:r}))))}var $I=j.memo(lDe,ym);$I.displayName="Area";var cDe="Invariant failed";function uDe(e,t){throw new Error(cDe)}function HI(){return HI=Object.assign?Object.assign.bind():function(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(En(t))return t;var a=En(r)||xs(r);return a?t(r,i):(a||uDe(),n)}},hDe=(e,t,n)=>n,fDe=(e,t)=>t,cb=et([ib,fDe],(e,t)=>e.filter(n=>n.type==="bar").find(n=>n.id===t)),pDe=et([cb],e=>e==null?void 0:e.maxBarSize),mDe=(e,t,n,r)=>r,gDe=et([_i,ib,qu,Wu,hDe],(e,t,n,r,i)=>t.filter(a=>e==="horizontal"?a.xAxisId===n:a.yAxisId===r).filter(a=>a.isPanorama===i).filter(a=>a.hide===!1).filter(a=>a.type==="bar")),xDe=(e,t,n)=>{var r=_i(e),i=qu(e,t),a=Wu(e,t);if(!(i==null||a==null))return r==="horizontal"?hN(e,"yAxis",a,n):hN(e,"xAxis",i,n)},yDe=(e,t)=>{var n=_i(e),r=qu(e,t),i=Wu(e,t);if(!(r==null||i==null))return n==="horizontal"?cz(e,"xAxis",r):cz(e,"yAxis",i)},bDe=et([gDe,Ike,yDe],YPe),vDe=(e,t,n)=>{var r,i,a=cb(e,t);if(a==null)return 0;var o=qu(e,t),c=Wu(e,t);if(o==null||c==null)return 0;var h=_i(e),f=aQ(e),{maxBarSize:m}=a,y=xs(m)?f:m,w,A;return h==="horizontal"?(w=$u(e,"xAxis",o,n),A=Fu(e,"xAxis",o,n)):(w=$u(e,"yAxis",c,n),A=Fu(e,"yAxis",c,n)),(r=(i=yf(w,A,!0))!==null&&i!==void 0?i:y)!==null&&r!==void 0?r:0},aee=(e,t,n)=>{var r=_i(e),i=qu(e,t),a=Wu(e,t);if(!(i==null||a==null)){var o,c;return r==="horizontal"?(o=$u(e,"xAxis",i,n),c=Fu(e,"xAxis",i,n)):(o=$u(e,"yAxis",a,n),c=Fu(e,"yAxis",a,n)),yf(o,c)}},wDe=et([bDe,aQ,Cke,oQ,vDe,aee,pDe],e6e),NDe=(e,t,n)=>{var r=qu(e,t);if(r!=null)return $u(e,"xAxis",r,n)},EDe=(e,t,n)=>{var r=Wu(e,t);if(r!=null)return $u(e,"yAxis",r,n)},ADe=(e,t,n)=>{var r=qu(e,t);if(r!=null)return Fu(e,"xAxis",r,n)},_De=(e,t,n)=>{var r=Wu(e,t);if(r!=null)return Fu(e,"yAxis",r,n)},SDe=et([wDe,cb],n6e),kDe=et([xDe,cb],t6e),CDe=et([$a,T4,NDe,EDe,ADe,_De,SDe,_i,KX,aee,kDe,cb,mDe],(e,t,n,r,i,a,o,c,h,f,m,y,w)=>{var{chartData:A,dataStartIndex:k,dataEndIndex:I}=h;if(!(y==null||o==null||t==null||c!=="horizontal"&&c!=="vertical"||n==null||r==null||i==null||a==null||f==null)){var{data:T}=y,D;if(T!=null&&T.length>0?D=T:D=A==null?void 0:A.slice(k,I+1),D!=null)return n8e({layout:c,barSettings:y,pos:o,parentViewBox:t,bandSize:f,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:m,displayedData:D,offset:e,cells:w,dataStartIndex:k})}}),IDe=["index"];function GI(){return GI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t=j.useContext(oee);if(t!=null)return t.stackId;if(e!=null)return NX(e)},PDe=(e,t)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(t),RDe=e=>{var t=j.useContext(oee);if(t!=null){var{stackId:n}=t;return"url(#".concat(PDe(n,e),")")}},lee=e=>{var{index:t}=e,n=jDe(e,IDe),r=RDe(t);return j.createElement(oo,GI({className:"recharts-bar-stack-layer",clipPath:r},n))},DDe=["onMouseEnter","onMouseLeave","onClick"],MDe=["value","background","tooltipPosition"],LDe=["id"],UDe=["onMouseEnter","onClick","onMouseLeave"];function bf(){return bf=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:Lg(n,t),payload:e}]},HDe=j.memo(e=>{var{dataKey:t,stroke:n,strokeWidth:r,fill:i,name:a,hide:o,unit:c,tooltipType:h,id:f}=e,m={dataDefinedOnItem:void 0,getPosition:jf,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:t,nameKey:void 0,name:Lg(a,t),hide:o,type:h,color:i,unit:c,graphicalItemId:f}};return j.createElement(F3,{tooltipEntrySettings:m})});function GDe(e){var t=Qn(um),{data:n,dataKey:r,background:i,allOtherBarProps:a}=e,{onMouseEnter:o,onMouseLeave:c,onClick:h}=a,f=NN(a,DDe),m=jJ(o,r,a.id),y=TJ(c),w=OJ(h,r,a.id);if(!i||n==null)return null;var A=Fy(i);return j.createElement(Wl,{zIndex:r6e(i,Sa.barBackground)},n.map((k,I)=>{var{value:T,background:D,tooltipPosition:F}=k,L=NN(k,MDe);if(!D)return null;var q=m(k,I),Z=y(k,I),K=w(k,I),z=Fo(Fo(Fo(Fo(Fo({option:i,isActive:String(I)===t},L),{},{fill:"#eee"},D),A),AE(f,k,I)),{},{onMouseEnter:q,onMouseLeave:Z,onClick:K,dataKey:r,index:I,className:"recharts-bar-background-rectangle"});return j.createElement(X3,bf({key:"background-bar-".concat(I)},z))}))}function qDe(e){var{showLabels:t,children:n,rects:r}=e,i=r==null?void 0:r.map(a=>{var o={x:a.x,y:a.y,width:a.width,lowerWidth:a.width,upperWidth:a.width,height:a.height};return Fo(Fo({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return j.createElement(B3,{value:t?i:void 0},n)}function WDe(e){var{shape:t,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=e,c=Qn(um),h=Qn(tJ),f=n&&String(i.originalDataIndex)===c&&(h==null||o===h),[m,y]=j.useState(!1),[w,A]=j.useState(!1);j.useEffect(()=>{var L;return f?(y(!0),L=requestAnimationFrame(()=>{A(!0)})):A(!1),()=>{cancelAnimationFrame(L)}},[f]);var k=j.useCallback(()=>{f||y(!1)},[f]),I=f&&w,T=f||m,D;f?n===!0?D=t:D=n:D=t;var F=j.createElement(X3,bf({},r,{name:String(r.name)},i,{isActive:I,option:D,index:a,dataKey:o,onTransitionEnd:k}));return T?j.createElement(Wl,{zIndex:Sa.activeBar},j.createElement(lee,{index:i.originalDataIndex},F)):F}function KDe(e){var{shape:t,baseProps:n,entry:r,index:i,dataKey:a}=e;return j.createElement(X3,bf({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:i,dataKey:a}))}function YDe(e){var t,{data:n,props:r}=e,i=(t=Hl(r))!==null&&t!==void 0?t:{},{id:a}=i,o=NN(i,LDe),{shape:c,dataKey:h,activeBar:f}=r,{onMouseEnter:m,onClick:y,onMouseLeave:w}=r,A=NN(r,UDe),k=jJ(m,h,a),I=TJ(w),T=OJ(y,h,a);return n?j.createElement(j.Fragment,null,n.map((D,F)=>j.createElement(lee,bf({index:D.originalDataIndex,key:"rectangle-".concat(D==null?void 0:D.x,"-").concat(D==null?void 0:D.y,"-").concat(D==null?void 0:D.value,"-").concat(F),className:"recharts-bar-rectangle"},AE(A,D,F),{onMouseEnter:k(D,F),onMouseLeave:I(D,F),onClick:T(D,F)}),f?j.createElement(WDe,{shape:c,activeBar:f,baseProps:o,entry:D,index:F,dataKey:h}):j.createElement(KDe,{shape:c,baseProps:o,entry:D,index:F,dataKey:h})))):null}function XDe(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:i,isAnimationActive:a,animationBegin:o,animationDuration:c,animationEasing:h,onAnimationEnd:f,onAnimationStart:m}=t,y=n.current,w=Qy(t,"recharts-bar-"),[A,k]=j.useState(!1),I=!A,T=j.useCallback(()=>{typeof f=="function"&&f(),k(!1)},[f]),D=j.useCallback(()=>{typeof m=="function"&&m(),k(!0)},[m]);return j.createElement(qDe,{showLabels:I,rects:r},j.createElement(Xy,{animationId:w,begin:o,duration:c,isActive:a,easing:h,onAnimationEnd:T,onAnimationStart:D,key:w},F=>{var L=F===1?r:r==null?void 0:r.map((q,Z)=>{var K=y&&y[Z];if(K)return Fo(Fo({},q),{},{x:Xi(K.x,q.x,F),y:Xi(K.y,q.y,F),width:Xi(K.width,q.width,F),height:Xi(K.height,q.height,F)});if(i==="horizontal"){var z=Xi(0,q.height,F),B=Xi(q.stackedBarStart,q.y,F);return Fo(Fo({},q),{},{y:B,height:z})}var V=Xi(0,q.width,F),$=Xi(q.stackedBarStart,q.x,F);return Fo(Fo({},q),{},{width:V,x:$})});return F>0&&(n.current=L??null),L==null?null:j.createElement(oo,null,j.createElement(YDe,{props:t,data:L}))}),j.createElement(z3,{label:t.label}),t.children)}function QDe(e){var t=j.useRef(null);return j.createElement(XDe,{previousRectanglesRef:t,props:e})}var cee=0,ZDe=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:Ds(e,t)}};class JDe extends j.PureComponent{render(){var{hide:t,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:o,needClip:c,background:h,id:f}=this.props;if(t||n==null)return null;var m=Di("recharts-bar",i),y=f;return j.createElement(oo,{className:m,id:f},c&&j.createElement("defs",null,j.createElement(K3,{clipPathId:y,xAxisId:a,yAxisId:o})),j.createElement(oo,{className:"recharts-bar-rectangles",clipPath:c?"url(#clipPath-".concat(y,")"):void 0},j.createElement(GDe,{data:n,dataKey:r,background:h,allOtherBarProps:this.props}),j.createElement(QDe,this.props)))}}var e8e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:cee,xAxisId:0,yAxisId:0,zIndex:Sa.bar};function t8e(e){var{xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:c,animationDuration:h,animationEasing:f,isAnimationActive:m}=e,{needClip:y}=lA(t,n),w=Tf(),A=Ha(),k=WOe(e.children,hJ),I=Qn(F=>CDe(F,e.id,A,k));if(w!=="vertical"&&w!=="horizontal")return null;var T,D=I==null?void 0:I[0];return D==null||D.height==null||D.width==null?T=0:T=w==="vertical"?D.height/2:D.width/2,j.createElement(HJ,{xAxisId:t,yAxisId:n,data:I,dataPointFormatter:ZDe,errorBarOffset:T},j.createElement(JDe,bf({},e,{layout:w,needClip:y,data:I,xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:c,animationDuration:h,animationEasing:f,isAnimationActive:m})))}function n8e(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r,hasCustomShape:i},pos:a,bandSize:o,xAxis:c,yAxis:h,xAxisTicks:f,yAxisTicks:m,stackedData:y,displayedData:w,offset:A,cells:k,parentViewBox:I,dataStartIndex:T}=e,D=t==="horizontal"?h:c,F=y?D.scale.domain():null,L=p_e({numericAxis:D}),q=D.scale.map(L);return w.map((Z,K)=>{var z,B,V,$,Q,Y;if(y){var G=y[K+T];if(G==null)return null;z=c_e(G,F)}else z=Ds(Z,n),Array.isArray(z)||(z=[L,z]);var he=dDe(r,cee)(z[1],K);if(t==="horizontal"){var te,le=h.scale.map(z[0]),ve=h.scale.map(z[1]);if(le==null||ve==null)return null;B=rU({axis:c,ticks:f,bandSize:o,offset:a.offset,entry:Z,index:K}),V=(te=ve??le)!==null&&te!==void 0?te:void 0,$=a.size;var ke=le-ve;if(Q=Vc(ke)?0:ke,Y={x:B,y:A.top,width:$,height:A.height},Math.abs(he)>0&&Math.abs(Q)0&&Math.abs($)j.createElement(j.Fragment,null,j.createElement($3,{legendPayload:$De(t)}),j.createElement(HDe,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:i}),j.createElement(G3,{type:"bar",id:i,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:n,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:r,hasCustomShape:t.shape!=null}),j.createElement(Wl,{zIndex:t.zIndex},j.createElement(t8e,bf({},t,{id:i})))))}var uee=j.memo(r8e,ym);uee.displayName="Bar";var i8e=["domain","range"],s8e=["domain","range"];function bV(e,t){if(e==null)return{};var n,r,i=a8e(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{if(o!=null)return NV(NV({},a),{},{type:o})},[a,o]);return j.useLayoutEffect(()=>{c!=null&&(n.current===null?t(RPe(c)):n.current!==c&&t(DPe({prev:n.current,next:c})),n.current=c)},[c,t]),j.useLayoutEffect(()=>()=>{n.current&&(t(MPe(n.current)),n.current=null)},[t]),null}var m8e=e=>{var{xAxisId:t,className:n}=e,r=Qn(T4),i=Ha(),a="xAxis",o=Qn(D=>PZ(D,a,t,i)),c=Qn(D=>jZ(D,t)),h=Qn(D=>dTe(D,t)),f=Qn(D=>ZQ(D,t));if(c==null||h==null||f==null)return null;var{dangerouslySetInnerHTML:m,ticks:y,scale:w}=e,A=WI(e,l8e),{id:k,scale:I}=f,T=WI(f,c8e);return j.createElement(W3,qI({},A,T,{x:h.x,y:h.y,width:c.width,height:c.height,className:Di("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:o,axisType:a,axisId:t}))},g8e={allowDataOverflow:wa.allowDataOverflow,allowDecimals:wa.allowDecimals,allowDuplicatedCategory:wa.allowDuplicatedCategory,angle:wa.angle,axisLine:Dd.axisLine,height:wa.height,hide:!1,includeHidden:wa.includeHidden,interval:wa.interval,label:!1,minTickGap:wa.minTickGap,mirror:wa.mirror,orientation:wa.orientation,padding:wa.padding,reversed:wa.reversed,scale:wa.scale,tick:wa.tick,tickCount:wa.tickCount,tickLine:Dd.tickLine,tickSize:Dd.tickSize,type:wa.type,niceTicks:wa.niceTicks,xAxisId:0},x8e=e=>{var t=Fa(e,g8e);return j.createElement(j.Fragment,null,j.createElement(p8e,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),j.createElement(m8e,t))},hee=j.memo(x8e,dee);hee.displayName="XAxis";var y8e=["type"],b8e=["dangerouslySetInnerHTML","ticks","scale"],v8e=["id","scale"];function KI(){return KI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{if(o!=null)return AV(AV({},a),{},{type:o})},[o,a]);return j.useLayoutEffect(()=>{c!=null&&(n.current===null?t(LPe(c)):n.current!==c&&t(UPe({prev:n.current,next:c})),n.current=c)},[c,t]),j.useLayoutEffect(()=>()=>{n.current&&(t(BPe(n.current)),n.current=null)},[t]),null}function S8e(e){var{yAxisId:t,className:n,width:r,label:i}=e,a=j.useRef(null),o=j.useRef(null),c=Qn(T4),h=Ha(),f=ys(),m="yAxis",y=Qn(K=>TZ(K,t)),w=Qn(K=>fTe(K,t)),A=Qn(K=>PZ(K,m,t,h)),k=Qn(K=>JQ(K,t));if(j.useLayoutEffect(()=>{if(!(r!=="auto"||!y||U3(i)||j.isValidElement(i)||k==null)){var K=a.current;if(K){var z=K.getCalculatedWidth();Math.round(y.width)!==Math.round(z)&&f(zPe({id:t,width:z}))}}},[A,y,f,i,t,r,k]),y==null||w==null||k==null)return null;var{dangerouslySetInnerHTML:I,ticks:T,scale:D}=e,F=YI(e,b8e),{id:L,scale:q}=k,Z=YI(k,v8e);return j.createElement(W3,KI({},F,Z,{ref:a,labelRef:o,x:w.x,y:w.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:y.width,height:y.height,className:Di("recharts-".concat(m," ").concat(m),n),viewBox:c,ticks:A,axisType:m,axisId:t}))}var k8e={allowDataOverflow:Na.allowDataOverflow,allowDecimals:Na.allowDecimals,allowDuplicatedCategory:Na.allowDuplicatedCategory,angle:Na.angle,axisLine:Dd.axisLine,hide:!1,includeHidden:Na.includeHidden,interval:Na.interval,label:!1,minTickGap:Na.minTickGap,mirror:Na.mirror,orientation:Na.orientation,padding:Na.padding,reversed:Na.reversed,scale:Na.scale,tick:Na.tick,tickCount:Na.tickCount,tickLine:Dd.tickLine,tickSize:Dd.tickSize,type:Na.type,niceTicks:Na.niceTicks,width:Na.width,yAxisId:0},C8e=e=>{var t=Fa(e,k8e);return j.createElement(j.Fragment,null,j.createElement(_8e,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),j.createElement(S8e,t))},fee=j.memo(C8e,dee);fee.displayName="YAxis";var I8e=(e,t)=>t,Q3=et([I8e,_i,pQ,qa,QZ,nh,D4e,$a],F4e);function j8e(e){return"getBBox"in e.currentTarget&&typeof e.currentTarget.getBBox=="function"}function Z3(e){var t=e.currentTarget.getBoundingClientRect(),n,r;if(j8e(e)){var i=e.currentTarget.getBBox();n=i.width>0?t.width/i.width:1,r=i.height>0?t.height/i.height:1}else{var a=e.currentTarget;n=a.offsetWidth>0?t.width/a.offsetWidth:1,r=a.offsetHeight>0?t.height/a.offsetHeight:1}var o=(c,h)=>({relativeX:Math.round((c-t.left)/n),relativeY:Math.round((h-t.top)/r)});return"touches"in e?Array.from(e.touches).map(c=>o(c.clientX,c.clientY)):o(e.clientX,e.clientY)}var pee=Gl("mouseClick"),mee=Gy();mee.startListening({actionCreator:pee,effect:(e,t)=>{var n=e.payload,r=Q3(t.getState(),Z3(n));(r==null?void 0:r.activeIndex)!=null&&t.dispatch(ITe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var XI=Gl("mouseMove"),gee=Gy(),p0=null,ep=null,dk=null;gee.startListening({actionCreator:XI,effect:(e,t)=>{var n=e.payload,r=t.getState(),{throttleDelay:i,throttledEvents:a}=r.eventSettings,o=a==="all"||(a==null?void 0:a.includes("mousemove"));p0!==null&&(cancelAnimationFrame(p0),p0=null),ep!==null&&(typeof i!="number"||!o)&&(clearTimeout(ep),ep=null),dk=Z3(n);var c=()=>{var h=t.getState(),f=ob(h,h.tooltip.settings.shared);if(!dk){p0=null,ep=null;return}if(f==="axis"){var m=Q3(h,dk);(m==null?void 0:m.activeIndex)!=null?t.dispatch(VZ({activeIndex:m.activeIndex,activeDataKey:void 0,activeCoordinate:m.activeCoordinate})):t.dispatch(zZ())}p0=null,ep=null};if(!o){c();return}i==="raf"?p0=requestAnimationFrame(c):typeof i=="number"&&ep===null&&(ep=setTimeout(c,i))}});function T8e(e,t){return t instanceof HTMLElement?"HTMLElement <".concat(t.tagName,' class="').concat(t.className,'">'):t===window?"global.window":e==="children"&&typeof t=="object"&&t!==null?"<>":t}var _V={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},xee=Io({name:"rootProps",initialState:_V,reducers:{updateOptions:(e,t)=>{var n;e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=(n=t.payload.barGap)!==null&&n!==void 0?n:_V.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),O8e=xee.reducer,{updateOptions:P8e}=xee.actions,R8e=null,D8e={updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)},yee=Io({name:"polarOptions",initialState:R8e,reducers:D8e}),{updatePolarOptions:J9e}=yee.actions,M8e=yee.reducer,bee=Gl("keyDown"),vee=Gl("focus"),wee=Gl("blur"),cA=Gy(),m0=null,tp=null,Wv=null;cA.startListening({actionCreator:bee,effect:(e,t)=>{Wv=e.payload,m0!==null&&(cancelAnimationFrame(m0),m0=null);var n=t.getState(),{throttleDelay:r,throttledEvents:i}=n.eventSettings,a=i==="all"||i.includes("keydown");tp!==null&&(typeof r!="number"||!a)&&(clearTimeout(tp),tp=null);var o=()=>{try{var c=t.getState(),h=c.rootProps.accessibilityLayer!==!1;if(!h)return;var{keyboardInteraction:f}=c.tooltip,m=Wv;if(m!=="ArrowRight"&&m!=="ArrowLeft"&&m!=="Enter")return;var y=R1(f,cm(c),Ng(c),Eg(c)),w=y==null?-1:Number(y),A=!Number.isFinite(w)||w<0,k=nh(c),I=cm(c),T=ob(c,c.tooltip.settings.shared);if(m==="Enter"){if(A)return;var D=mN(c,T,"hover",String(f.index));t.dispatch(pN({active:!f.active,activeIndex:f.index,activeCoordinate:D}));return}var F=yTe(c),L=F==="left-to-right"?1:-1,q=m==="ArrowRight"?1:-1,Z;if(A){var K=Ng(c),z=Eg(c),B=q*L,V=he=>({active:!1,index:String(he),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(Z=-1,B>0){for(var $=0;$=0;Q--)if(R1(V(Q),I,K,z)!=null){Z=Q;break}if(Z<0)return}else{Z=w+q*L;var Y=(k==null?void 0:k.length)||I.length;if(Y===0||Z>=Y||Z<0)return}var G=mN(c,T,"hover",String(Z));t.dispatch(pN({active:!0,activeIndex:Z.toString(),activeCoordinate:G}))}finally{m0=null,tp=null}};if(!a){o();return}r==="raf"?m0=requestAnimationFrame(o):typeof r=="number"&&tp===null&&(o(),Wv=null,tp=setTimeout(()=>{Wv?o():(tp=null,m0=null)},r))}});cA.startListening({actionCreator:vee,effect:(e,t)=>{var n=t.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var a="0",o=ob(n,n.tooltip.settings.shared),c=mN(n,o,"hover",String(a));t.dispatch(pN({active:!0,activeIndex:a,activeCoordinate:c}))}}}});cA.startListening({actionCreator:wee,effect:(e,t)=>{var n=t.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;i.active&&t.dispatch(pN({active:!1,activeIndex:i.index,activeCoordinate:i.coordinate}))}}});function Nee(e){e.persist();var{currentTarget:t}=e;return new Proxy(e,{get:(n,r)=>{if(r==="currentTarget")return t;var i=Reflect.get(n,r);return typeof i=="function"?i.bind(n):i}})}var tc=Gl("externalEvent"),Eee=Gy(),Kv=new Map,Qx=new Map,hk=new Map;Eee.startListening({actionCreator:tc,effect:(e,t)=>{var{handler:n,reactEvent:r}=e.payload;if(n!=null){var i=r.type,a=Nee(r);hk.set(i,{handler:n,reactEvent:a});var o=Kv.get(i);o!==void 0&&(cancelAnimationFrame(o),Kv.delete(i));var c=t.getState(),{throttleDelay:h,throttledEvents:f}=c.eventSettings,m=f,y=m==="all"||(m==null?void 0:m.includes(i)),w=Qx.get(i);w!==void 0&&(typeof h!="number"||!y)&&(clearTimeout(w),Qx.delete(i));var A=()=>{var T=hk.get(i);try{if(!T)return;var{handler:D,reactEvent:F}=T,L=t.getState(),q={activeCoordinate:v4e(L),activeDataKey:tJ(L),activeIndex:um(L),activeLabel:eJ(L),activeTooltipIndex:um(L),isTooltipActive:w4e(L)};D&&D(q,F)}finally{Kv.delete(i),Qx.delete(i),hk.delete(i)}};if(!y){A();return}if(h==="raf"){var k=requestAnimationFrame(A);Kv.set(i,k)}else if(typeof h=="number"){if(!Qx.has(i)){A();var I=setTimeout(A,h);Qx.set(i,I)}}else A()}}});var L8e=et([Gg],e=>e.tooltipItemPayloads),U8e=et([L8e,(e,t)=>t,(e,t,n)=>n],(e,t,n)=>{if(t!=null){var r=e.find(a=>a.settings.graphicalItemId===n);if(r!=null){var{getPosition:i}=r;if(i!=null)return i(t)}}}),Aee=Gl("touchMove"),_ee=Gy(),np=null,Dh=null,SV=null,Zx=null;_ee.startListening({actionCreator:Aee,effect:(e,t)=>{var n=e.payload;if(!(n.touches==null||n.touches.length===0)){Zx=Nee(n);var r=t.getState(),{throttleDelay:i,throttledEvents:a}=r.eventSettings,o=a==="all"||a.includes("touchmove");np!==null&&(cancelAnimationFrame(np),np=null),Dh!==null&&(typeof i!="number"||!o)&&(clearTimeout(Dh),Dh=null),SV=Array.from(n.touches).map(h=>Z3({clientX:h.clientX,clientY:h.clientY,currentTarget:n.currentTarget}));var c=()=>{if(Zx!=null){var h=t.getState(),f=ob(h,h.tooltip.settings.shared);if(f==="axis"){var m,y=(m=SV)===null||m===void 0?void 0:m[0];if(y==null){np=null,Dh=null;return}var w=Q3(h,y);(w==null?void 0:w.activeIndex)!=null&&t.dispatch(VZ({activeIndex:w.activeIndex,activeDataKey:void 0,activeCoordinate:w.activeCoordinate}))}else if(f==="item"){var A,k=Zx.touches[0];if(document.elementFromPoint==null||k==null)return;var I=document.elementFromPoint(k.clientX,k.clientY);if(!I||!I.getAttribute)return;var T=I.getAttribute(w_e),D=(A=I.getAttribute(N_e))!==null&&A!==void 0?A:void 0,F=wm(h).find(Z=>Z.id===D);if(T==null||F==null||D==null)return;var{dataKey:L}=F,q=U8e(h,T,D);t.dispatch(BZ({activeDataKey:L,activeIndex:T,activeCoordinate:q,activeGraphicalItemId:D}))}np=null,Dh=null}};if(!o){c();return}i==="raf"?np=requestAnimationFrame(c):typeof i=="number"&&Dh===null&&(c(),Zx=null,Dh=setTimeout(()=>{Zx?c():(Dh=null,np=null)},i))}}});var See={throttleDelay:"raf",throttledEvents:["mousemove","touchmove","pointermove","scroll","wheel"]},kee=Io({name:"eventSettings",initialState:See,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=t.payload.throttledEvents)}}}),{setEventSettings:B8e}=kee.actions,z8e=kee.reducer,V8e=GY({brush:s6e,cartesianAxis:VPe,chartData:b3e,errorBars:iRe,eventSettings:z8e,graphicalItems:vPe,layout:i_e,legend:gSe,options:p3e,polarAxis:FOe,polarOptions:M8e,referenceElements:c6e,renderedTicks:S6e,rootProps:O8e,tooltip:jTe,zIndex:t3e}),F8e=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return IAe({reducer:V8e,preloadedState:t,middleware:r=>{var i;return r({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((i="es6")!==null&&i!==void 0?i:"")}).concat([mee.middleware,gee.middleware,cA.middleware,Eee.middleware,_ee.middleware])},enhancers:r=>{var i=r;return typeof r=="function"&&(i=r()),i.concat(aX({type:"raf"}))},devTools:{serialize:{replacer:T8e},name:"recharts-".concat(n)}})};function $8e(e){var{preloadedState:t,children:n,reduxStoreName:r}=e,i=Ha(),a=j.useRef(null);if(i)return n;a.current==null&&(a.current=F8e(t,r));var o=A4;return j.createElement(OSe,{context:o,store:a.current},n)}function H8e(e){var{layout:t,margin:n}=e,r=ys(),i=Ha();return j.useEffect(()=>{i||(r(t_e(t)),r(e_e(n)))},[r,i,t,n]),null}var G8e=j.memo(H8e,ym);function q8e(e){var t=ys();return j.useEffect(()=>{t(P8e(e))},[t,e]),null}var W8e=e=>{var t=ys();return j.useEffect(()=>{t(B8e(e))},[t,e]),null},K8e=j.memo(W8e,ym);function kV(e){var{zIndex:t,isPanorama:n}=e,r=j.useRef(null),i=ys();return j.useLayoutEffect(()=>(r.current&&i(J4e({zIndex:t,element:r.current,isPanorama:n})),()=>{i(e3e({zIndex:t,isPanorama:n}))}),[i,t,n]),j.createElement("g",{tabIndex:-1,ref:r,className:"recharts-zIndex-layer_".concat(t)})}function CV(e){var{children:t,isPanorama:n}=e,r=Qn(H4e);if(!r||r.length===0)return t;var i=r.filter(o=>o<0),a=r.filter(o=>o>0);return j.createElement(j.Fragment,null,i.map(o=>j.createElement(kV,{key:o,zIndex:o,isPanorama:n})),t,a.map(o=>j.createElement(kV,{key:o,zIndex:o,isPanorama:n})))}var Y8e=["children"];function X8e(e,t){if(e==null)return{};var n,r,i=Q8e(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var n=R4(),r=D4(),i=UX();if(!Bu(n)||!Bu(r))return null;var{children:a,otherAttributes:o,title:c,desc:h}=e,f,m;return o!=null&&(typeof o.tabIndex=="number"?f=o.tabIndex:f=i?0:void 0,typeof o.role=="string"?m=o.role:m=i?"application":void 0),j.createElement(p4,EN({},o,{title:c,desc:h,role:m,tabIndex:f,width:n,height:r,style:Z8e,ref:t}),a)}),eMe=e=>{var{children:t}=e,n=Qn(UE);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return j.createElement(p4,{width:r,height:i,x:o,y:a},t)},IV=j.forwardRef((e,t)=>{var{children:n}=e,r=X8e(e,Y8e),i=Ha();return i?j.createElement(eMe,null,j.createElement(CV,{isPanorama:!0},n)):j.createElement(J8e,EN({ref:t},r),j.createElement(CV,{isPanorama:!1},n))});function tMe(){var e=ys(),[t,n]=j.useState(null),r=Qn(v_e);return j.useEffect(()=>{if(t!=null){var i=t.getBoundingClientRect(),a=i.width/t.offsetWidth;qr(a)&&a!==r&&e(r_e(a))}},[t,e,r]),n}function jV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function nMe(e){for(var t=1;t(C3e(),null);function AN(e){if(typeof e=="number")return e;if(typeof e=="string"){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var oMe=j.forwardRef((e,t)=>{var n,r,i=j.useRef(null),[a,o]=j.useState({containerWidth:AN((n=e.style)===null||n===void 0?void 0:n.width),containerHeight:AN((r=e.style)===null||r===void 0?void 0:r.height)}),c=j.useCallback((f,m)=>{o(y=>{var w=Math.round(f),A=Math.round(m);return y.containerWidth===w&&y.containerHeight===A?y:{containerWidth:w,containerHeight:A}})},[]),h=j.useCallback(f=>{if(typeof t=="function"&&t(f),i.current!=null&&(i.current.disconnect(),i.current=null),f!=null&&typeof ResizeObserver<"u"){var{width:m,height:y}=f.getBoundingClientRect();c(m,y);var w=k=>{var I=k[0];if(I!=null){var{width:T,height:D}=I.contentRect;c(T,D)}},A=new ResizeObserver(w);A.observe(f),i.current=A}},[t,c]);return j.useEffect(()=>()=>{var f=i.current;f!=null&&f.disconnect()},[c]),j.createElement(j.Fragment,null,j.createElement(Wy,{width:a.containerWidth,height:a.containerHeight}),j.createElement("div",cf({ref:h},e)))}),lMe=j.forwardRef((e,t)=>{var{width:n,height:r}=e,[i,a]=j.useState({containerWidth:AN(n),containerHeight:AN(r)}),o=j.useCallback((h,f)=>{a(m=>{var y=Math.round(h),w=Math.round(f);return m.containerWidth===y&&m.containerHeight===w?m:{containerWidth:y,containerHeight:w}})},[]),c=j.useCallback(h=>{if(typeof t=="function"&&t(h),h!=null){var{width:f,height:m}=h.getBoundingClientRect();o(f,m)}},[t,o]);return j.createElement(j.Fragment,null,j.createElement(Wy,{width:i.containerWidth,height:i.containerHeight}),j.createElement("div",cf({ref:c},e)))}),cMe=j.forwardRef((e,t)=>{var{width:n,height:r}=e;return j.createElement(j.Fragment,null,j.createElement(Wy,{width:n,height:r}),j.createElement("div",cf({ref:t},e)))}),uMe=j.forwardRef((e,t)=>{var{width:n,height:r}=e;return typeof n=="string"||typeof r=="string"?j.createElement(lMe,cf({},e,{ref:t})):typeof n=="number"&&typeof r=="number"?j.createElement(cMe,cf({},e,{width:n,height:r,ref:t})):j.createElement(j.Fragment,null,j.createElement(Wy,{width:n,height:r}),j.createElement("div",cf({ref:t},e)))});function dMe(e){return e?oMe:uMe}var hMe=j.forwardRef((e,t)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:o,onDoubleClick:c,onMouseDown:h,onMouseEnter:f,onMouseLeave:m,onMouseMove:y,onMouseUp:w,onTouchEnd:A,onTouchMove:k,onTouchStart:I,style:T,width:D,responsive:F,dispatchTouchEvents:L=!0}=e,q=j.useRef(null),Z=ys(),[K,z]=j.useState(null),[B,V]=j.useState(null),$=tMe(),Q=O4(),Y=(Q==null?void 0:Q.width)>0?Q.width:D,G=(Q==null?void 0:Q.height)>0?Q.height:i,he=j.useCallback(Ye=>{$(Ye),typeof t=="function"&&t(Ye),z(Ye),V(Ye),Ye!=null&&(q.current=Ye)},[$,t,z,V]),te=j.useCallback(Ye=>{Z(pee(Ye)),Z(tc({handler:a,reactEvent:Ye}))},[Z,a]),le=j.useCallback(Ye=>{Z(XI(Ye)),Z(tc({handler:f,reactEvent:Ye}))},[Z,f]),ve=j.useCallback(Ye=>{Z(zZ()),Z(tc({handler:m,reactEvent:Ye}))},[Z,m]),ke=j.useCallback(Ye=>{Z(XI(Ye)),Z(tc({handler:y,reactEvent:Ye}))},[Z,y]),Be=j.useCallback(()=>{Z(vee())},[Z]),J=j.useCallback(()=>{Z(wee())},[Z]),ie=j.useCallback(Ye=>{Z(bee(Ye.key))},[Z]),xe=j.useCallback(Ye=>{Z(tc({handler:o,reactEvent:Ye}))},[Z,o]),ae=j.useCallback(Ye=>{Z(tc({handler:c,reactEvent:Ye}))},[Z,c]),Fe=j.useCallback(Ye=>{Z(tc({handler:h,reactEvent:Ye}))},[Z,h]),pt=j.useCallback(Ye=>{Z(tc({handler:w,reactEvent:Ye}))},[Z,w]),Ue=j.useCallback(Ye=>{Z(tc({handler:I,reactEvent:Ye}))},[Z,I]),Ct=j.useCallback(Ye=>{L&&Z(Aee(Ye)),Z(tc({handler:k,reactEvent:Ye}))},[Z,L,k]),Tt=j.useCallback(Ye=>{Z(tc({handler:A,reactEvent:Ye}))},[Z,A]),ht=dMe(F);return j.createElement(cJ.Provider,{value:K},j.createElement(aY.Provider,{value:B},j.createElement(ht,{width:Y??(T==null?void 0:T.width),height:G??(T==null?void 0:T.height),className:Di("recharts-wrapper",r),style:nMe({position:"relative",cursor:"default",width:Y,height:G},T),onClick:te,onContextMenu:xe,onDoubleClick:ae,onFocus:Be,onBlur:J,onKeyDown:ie,onMouseDown:Fe,onMouseEnter:le,onMouseLeave:ve,onMouseMove:ke,onMouseUp:pt,onTouchEnd:Tt,onTouchMove:Ct,onTouchStart:Ue,ref:he},j.createElement(aMe,null),n)))}),fMe=["width","height","responsive","children","className","style","compact","title","desc"];function pMe(e,t){if(e==null)return{};var n,r,i=mMe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var{width:n,height:r,responsive:i,children:a,className:o,style:c,compact:h,title:f,desc:m}=e,y=pMe(e,fMe),w=Hl(y);return h?j.createElement(j.Fragment,null,j.createElement(Wy,{width:n,height:r}),j.createElement(IV,{otherAttributes:w,title:f,desc:m},a)):j.createElement(hMe,{className:o,style:c,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},j.createElement(IV,{otherAttributes:w,title:f,desc:m,ref:t},j.createElement(d6e,null,a)))});function QI(){return QI=Object.assign?Object.assign.bind():function(e){for(var t=1;tj.createElement(EMe,{chartName:"ComposedChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:AMe,tooltipPayloadSearcher:h3e,categoricalChartProps:e,ref:t}));const Cee=({className:e})=>s.jsx("div",{className:`flex flex-col items-center gap-1 ${e}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-6 h-6 border border-gray-950 overflow-hidden bg-white rounded-full",children:s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"Logo",className:"w-full h-full object-cover",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("span",{className:"text-lg md:text-xl font-serif font-black tracking-tighter text-gray-950 uppercase leading-none italic",children:"CAMPUS EYE"}),s.jsx("span",{className:"text-[6px] font-black tracking-[0.5em] text-gray-400 uppercase leading-none mt-0.5",children:"MEDIA"})]})]})}),Iee=({stats:e,compact:t=!1})=>{const[n,r]=j.useState(null),i=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],a=(e.engagementScore||10)+e.articlesCount*5+e.postsCount*2,o=e.weeklyActivity||i.map((w,A)=>{const k=Math.floor(Math.abs(Math.sin(a+A*1.5)*40)+(A%2===0?12:5));return Math.max(2,k)}),c=Math.max(...o,1),h=Math.max(1,e.articlesCount*10+e.postsCount*3+e.purchasesCount*5),f=Math.min(100,Math.round(e.articlesCount*10/h*100)),m=Math.min(100,Math.round(e.postsCount*3/h*100)),y=Math.min(100,Math.max(0,100-f-m));return s.jsxs("div",{className:"bg-gradient-to-br from-gray-900 via-gray-950 to-black text-white p-5 sm:p-6 rounded-3xl border border-gray-800/80 shadow-2xl space-y-6 select-none font-sans",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-white/10 pb-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-gradient-to-tr from-accent to-purple-600 rounded-2xl shadow-lg shadow-accent/20 text-white",children:s.jsx(xp,{size:20})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-black uppercase tracking-widest text-gray-200 flex items-center gap-2",children:"Citizen Statistics & Engagement Graph"}),s.jsx("p",{className:"text-[10px] text-gray-400 font-semibold tracking-wider uppercase mt-0.5",children:"Live Activity Analytics Engine"})]})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs("span",{className:"px-3 py-1 bg-white/10 border border-white/15 text-amber-300 rounded-xl text-[9.5px] font-black uppercase tracking-widest flex items-center gap-1 shadow-sm",children:[s.jsx(es,{size:11,className:"text-amber-400"}),e.tier||"Active Citizen"]})})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-[9.5px] font-black uppercase tracking-widest text-gray-400 flex items-center gap-1.5",children:[s.jsx(H0,{size:12,className:"text-accent"})," Weekly Contribution Volume (Mon - Sun)"]}),s.jsxs("span",{className:"text-[9px] font-mono font-bold text-gray-400",children:["Total Points: ",s.jsx("strong",{className:"text-white",children:e.engagementScore})]})]}),s.jsx("div",{className:"bg-white/5 border border-white/10 p-4 rounded-2xl relative",children:s.jsx("div",{className:"h-32 flex items-end justify-between gap-2 pt-6 pb-1 px-1",children:o.map((w,A)=>{const k=Math.max(12,Math.round(w/c*100)),I=n===A;return s.jsxs("div",{onMouseEnter:()=>r(A),onMouseLeave:()=>r(null),className:"flex-1 flex flex-col items-center h-full justify-end group cursor-pointer relative",children:[I&&s.jsxs("div",{className:"absolute -top-8 bg-accent text-white px-2 py-0.5 rounded-lg text-[9px] font-black font-mono shadow-xl z-20 whitespace-nowrap animate-fadeIn",children:[w," pts (",i[A],")"]}),s.jsx("div",{className:"w-full bg-white/10 rounded-t-lg h-full flex items-end overflow-hidden p-0.5",children:s.jsx("div",{style:{height:`${k}%`},className:`w-full rounded-t-md transition-all duration-500 ${I?"bg-gradient-to-t from-red-600 via-accent to-amber-400 shadow-lg shadow-accent/50":"bg-gradient-to-t from-accent/80 to-purple-500/80 group-hover:from-accent group-hover:to-purple-400"}`})}),s.jsx("span",{className:`text-[9px] font-extrabold uppercase mt-2 font-mono transition-colors ${I?"text-accent font-black":"text-gray-400"}`,children:i[A]})]},A)})})})]}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[s.jsxs("div",{className:"p-3 bg-white/5 border border-white/10 rounded-2xl flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between text-gray-400",children:[s.jsx("span",{className:"text-[8.5px] font-black uppercase tracking-widest",children:"Articles"}),s.jsx(E0,{size:13,className:"text-blue-400"})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("span",{className:"text-base font-black font-mono text-white",children:e.articlesCount}),s.jsx("span",{className:"text-[8px] text-gray-400 block font-semibold",children:"Dispatches"})]})]}),s.jsxs("div",{className:"p-3 bg-white/5 border border-white/10 rounded-2xl flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between text-gray-400",children:[s.jsx("span",{className:"text-[8.5px] font-black uppercase tracking-widest",children:"Lounge Posts"}),s.jsx(Yi,{size:13,className:"text-purple-400"})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("span",{className:"text-base font-black font-mono text-white",children:e.postsCount}),s.jsx("span",{className:"text-[8px] text-gray-400 block font-semibold",children:"Feed Shares"})]})]}),s.jsxs("div",{className:"p-3 bg-white/5 border border-white/10 rounded-2xl flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between text-gray-400",children:[s.jsx("span",{className:"text-[8.5px] font-black uppercase tracking-widest",children:"Passes"}),s.jsx(No,{size:13,className:"text-emerald-400"})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("span",{className:"text-base font-black font-mono text-white",children:e.purchasesCount}),s.jsx("span",{className:"text-[8px] text-gray-400 block font-semibold",children:"Event Tickets"})]})]}),s.jsxs("div",{className:"p-3 bg-white/5 border border-white/10 rounded-2xl flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between text-gray-400",children:[s.jsx("span",{className:"text-[8.5px] font-black uppercase tracking-widest",children:"Score"}),s.jsx(mu,{size:13,className:"text-amber-400"})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("span",{className:"text-base font-black font-mono text-amber-300",children:e.engagementScore}),s.jsx("span",{className:"text-[8px] text-gray-400 block font-semibold",children:"Influence Pts"})]})]})]}),!t&&s.jsxs("div",{className:"space-y-2 pt-1 border-t border-white/10",children:[s.jsxs("div",{className:"flex justify-between items-center text-[9px] font-black uppercase tracking-widest text-gray-400",children:[s.jsx("span",{children:"Contribution Mix Breakdown"}),s.jsxs("span",{className:"text-gray-300 font-mono",children:["UGX ",(e.totalSpent||0).toLocaleString()," Spent"]})]}),s.jsxs("div",{className:"w-full bg-white/10 h-3 rounded-full overflow-hidden flex p-0.5 gap-0.5",children:[s.jsx("div",{style:{width:`${f}%`},className:"bg-blue-500 h-full rounded-l-sm",title:`Articles: ${f}%`}),s.jsx("div",{style:{width:`${m}%`},className:"bg-purple-500 h-full",title:`Lounge Posts: ${m}%`}),s.jsx("div",{style:{width:`${y}%`},className:"bg-emerald-500 h-full rounded-r-sm",title:`Tickets: ${y}%`})]}),s.jsxs("div",{className:"flex items-center justify-between text-[8px] font-extrabold uppercase text-gray-400 pt-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-500 inline-block"})," Articles (",f,"%)"]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-purple-500 inline-block"})," Lounge (",m,"%)"]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-500 inline-block"})," Tickets (",y,"%)"]})]})]})]})};function uA(e){if(!e||typeof e!="string")return null;const t=e.trim(),n=/(?:youtube(?:-nocookie)?\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?|shorts)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,r=t.match(n);return r?r[1]:null}function gp(e){return!!uA(e)}function Yv(e,t="hq"){const n=uA(e)||e;return!n||n.length!==11?"https://images.unsplash.com/photo-1590602847861-f357a9332bbc?auto=format&fit=crop&q=80&w=600":`https://img.youtube.com/vi/${n}/${t==="maxres"?"maxresdefault":"hqdefault"}.jpg`}function SMe(e,t=!0){const n=uA(e)||e;return n?`https://www.youtube-nocookie.com/embed/${n}?autoplay=${t?1:0}&rel=0&modestbranding=1&enablejsapi=1`:""}function Dl(e){if(!e)return!1;if(e.mediaType==="video")return!0;if(e.mediaType==="audio")return!1;const t=(e.videoUrl||e.mediaUrl||e.audioUrl||"").toLowerCase();return gp(t)?!0:[".mp4",".webm",".ogg",".mov",".m3u8",".mkv","vimeo.com","dailymotion.com","drive.google.com/file"].some(r=>t.includes(r))}function kMe(e){return e&&(e.videoUrl||e.mediaUrl||e.audioUrl)||""}const J3=({podcast:e,onClose:t,relatedPodcasts:n=[],onSelectPodcast:r})=>{var T;const[i,a]=j.useState(e||null),[o,c]=j.useState(!1),[h,f]=j.useState(!1);j.useEffect(()=>{e&&a(e)},[e]),j.useEffect(()=>{const D=F=>{const L=F;L.detail&&a(L.detail)};return window.addEventListener("play-video-podcast",D),()=>{window.removeEventListener("play-video-podcast",D)}},[]),j.useEffect(()=>{const D=F=>{F.key==="Escape"&&i&&m()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[i]);const m=()=>{a(null),t&&t()};if(!i)return null;const y=kMe(i),w=gp(y);uA(y);const A=w?SMe(y,!0):null,k=async()=>{const D=typeof window<"u"?`${window.location.origin}/?podcast=${i.id}`:"";if(`${i.title}${D}`,navigator.share)try{await navigator.share({title:i.title,text:`Watch this Campus Eye Video Episode: ${i.title}`,url:D||y}),me.success("Shared video episode!",{icon:"🎬"});return}catch{}Pd(D||y),c(!0),me.success("Video episode link copied to clipboard!",{icon:"📋"}),setTimeout(()=>c(!1),2e3)},I=D=>{Dl(D)?(a(D),r&&r(D)):(window.dispatchEvent(new CustomEvent("play-podcast",{detail:D})),me.success(`Playing audio episode: ${D.title}`,{icon:"🎧"}))};return s.jsx(ar,{children:s.jsxs("div",{className:"fixed inset-0 z-[6000] flex items-center justify-center p-2 sm:p-4 md:p-6 overflow-y-auto bg-black/85 backdrop-blur-md",children:[s.jsx("div",{className:"fixed inset-0",onClick:m}),s.jsxs(Kt.div,{initial:{opacity:0,scale:.94,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.94,y:20},transition:{type:"spring",damping:25,stiffness:300},className:`relative z-10 w-full ${h?"max-w-6xl":"max-w-4xl"} bg-gray-950 text-white rounded-3xl border border-white/15 shadow-[0_25px_70px_rgba(0,0,0,0.9)] overflow-hidden transition-all duration-300 my-auto`,children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-white/10 bg-gray-900/60 backdrop-blur-xl",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5 px-3 py-1 bg-red-600/90 text-white rounded-xl text-[10px] font-black uppercase tracking-widest shadow-sm",children:[s.jsx(Aa,{size:12,className:"animate-pulse"})," Video Podcast"]}),s.jsx("span",{className:"text-[10px] font-mono font-bold text-gray-400 bg-white/5 px-2.5 py-1 rounded-xl border border-white/5",children:i.category||"Campus Broadcast"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>f(!h),className:"p-2 rounded-xl text-gray-400 hover:text-white hover:bg-white/10 transition-colors cursor-pointer",title:h?"Exit Theatre Mode":"Theatre Mode",children:h?s.jsx(tj,{size:16}):s.jsx(Dw,{size:16})}),s.jsx("button",{onClick:k,className:"p-2 rounded-xl text-gray-400 hover:text-white hover:bg-white/10 transition-colors flex items-center gap-1.5 text-xs font-bold cursor-pointer",title:"Share Episode",children:o?s.jsx(Pu,{size:16,className:"text-emerald-400"}):s.jsx(df,{size:16})}),s.jsx("button",{onClick:m,className:"p-2 rounded-xl bg-white/5 hover:bg-red-600 hover:text-white text-gray-400 transition-all cursor-pointer ml-1",title:"Close Video (Esc)",children:s.jsx(er,{size:18})})]})]}),s.jsx("div",{className:"relative w-full aspect-video bg-black flex items-center justify-center overflow-hidden",children:w&&A?s.jsx("iframe",{src:A,title:i.title,className:"w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0}):y?s.jsx("video",{src:y,controls:!0,autoPlay:!0,playsInline:!0,poster:i.thumbnail,className:"w-full h-full object-contain",children:"Your browser does not support the video tag."}):s.jsxs("div",{className:"text-center p-8 text-gray-400",children:[s.jsx(Aa,{size:40,className:"mx-auto mb-2 text-red-500 opacity-60"}),s.jsx("p",{className:"text-xs font-bold uppercase tracking-wider",children:"Video stream not available"})]})}),s.jsxs("div",{className:"p-5 md:p-6 bg-gradient-to-b from-gray-950 to-gray-900 text-left space-y-4",children:[s.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase text-red-500 tracking-wider flex items-center gap-1",children:[s.jsx(TN,{size:12})," Host: ",i.author||"Campus Eye Desk"]}),s.jsx("span",{className:"text-gray-600",children:"•"}),s.jsxs("span",{className:"text-[10px] font-mono text-gray-400",children:["⏱️ ",i.duration||"Full Episode"]}),i.publishDate&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-gray-600",children:"•"}),s.jsx("span",{className:"text-[10px] font-mono text-gray-400",children:(T=i.publishDate)!=null&&T.seconds?new Date(i.publishDate.seconds*1e3).toLocaleDateString():"Published Episode"})]})]}),s.jsx("h2",{className:"text-lg md:text-2xl font-black text-white uppercase tracking-tight font-serif leading-tight",children:i.title})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[y&&s.jsxs("a",{href:y,target:"_blank",rel:"noreferrer",className:"px-4 py-2 bg-white/10 hover:bg-white/20 text-white rounded-xl text-[10px] font-black uppercase tracking-wider transition-all flex items-center gap-1.5 cursor-pointer border border-white/10",children:[s.jsx(Va,{size:12})," ",w?"Open on YouTube":"Open Video Link"]}),s.jsxs("button",{onClick:k,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-xl text-[10px] font-black uppercase tracking-wider transition-all flex items-center gap-1.5 cursor-pointer shadow-lg shadow-red-900/20",children:[s.jsx(df,{size:12})," Share"]})]})]}),i.description&&s.jsxs("div",{className:"p-4 bg-white/5 rounded-2xl border border-white/5 text-xs text-gray-300 leading-relaxed",children:[s.jsx("p",{className:"font-bold text-[9px] uppercase tracking-wider text-gray-400 mb-1",children:"Episode Notes"}),s.jsx("p",{className:"whitespace-pre-wrap",children:i.description})]}),n.length>0&&s.jsxs("div",{className:"pt-2 border-t border-white/10",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h4",{className:"text-[10px] font-black uppercase tracking-widest text-gray-400 flex items-center gap-1.5",children:[s.jsx(es,{size:12,className:"text-red-500"})," More Campus Episodes"]}),s.jsxs("span",{className:"text-[9px] font-mono text-gray-500 font-bold",children:[n.length," Available"]})]}),s.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:n.slice(0,4).map(D=>{const F=Dl(D),L=D.id===i.id;return s.jsxs("div",{onClick:()=>I(D),className:`group relative bg-white/5 hover:bg-white/10 p-2.5 rounded-2xl border transition-all cursor-pointer flex flex-col justify-between ${L?"border-red-600 bg-red-950/20 ring-1 ring-red-600":"border-white/5 hover:border-white/20"}`,children:[s.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden mb-2 bg-black",children:[s.jsx("img",{src:D.thumbnail||"https://images.unsplash.com/photo-1590602847861-f357a9332bbc?auto=format&fit=crop&q=80&w=300",alt:D.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"}),s.jsxs("span",{className:`absolute top-1.5 left-1.5 text-[7px] font-black uppercase tracking-wider px-1.5 py-0.5 rounded flex items-center gap-0.5 shadow-sm text-white ${F?"bg-red-600":"bg-emerald-600"}`,children:[F?s.jsx(Aa,{size:8}):s.jsx(Qh,{size:8}),F?"VIDEO":"AUDIO"]})]}),s.jsx("h5",{className:"text-[10px] font-black uppercase text-white truncate group-hover:text-red-400 transition-colors",children:D.title}),s.jsx("p",{className:"text-[8px] text-gray-400 font-bold uppercase tracking-wider mt-0.5",children:D.author})]},D.id)})})]})]})]})]})})},fk=({initialTab:e})=>{var _c,zm,nx,Sc,go,Ns,Hf,Xl,Ar,ji;const[t,n]=se.useState(!1),[r,i]=se.useState(!0),[a,o]=se.useState(e||"dashboard");se.useEffect(()=>{e&&o(e)},[e]),se.useEffect(()=>{const P=()=>{const de=localStorage.getItem("edit_ticket_item");if(de)try{const De=JSON.parse(de);vt(De),is(De.title||""),Qi(De.description||""),si((De.price||0).toString()),Hi(De.venue||""),or((De.totalQuantity||100).toString()),lr(De.category||"Entertainment"),iu(De.imageUrl||""),wn(De.link||"");const xt=(()=>{const qt=De.eventDate;if(!qt)return"";const cr=typeof qt.toDate=="function"?qt.toDate():qt instanceof Date?qt:qt.seconds?new Date(qt.seconds*1e3):new Date(qt);try{return cr.toISOString().slice(0,16)}catch{return""}})();Oa(xt),o("manage-tickets"),localStorage.removeItem("edit_ticket_item")}catch(De){console.warn("Failed to restore editing ticket:",De)}};return P(),window.addEventListener("checkPendingTicketEdit",P),()=>window.removeEventListener("checkPendingTicketEdit",P)},[]);const[c,h]=se.useState([]),[f,m]=se.useState(()=>B2e()),[y,w]=se.useState(()=>z2e()),[A,k]=se.useState(()=>V2e()),[I,T]=se.useState(""),[D,F]=se.useState(""),[L,q]=se.useState(""),[Z,K]=se.useState([]),[z,B]=se.useState([]),[V,$]=se.useState([]),[Q,Y]=se.useState([]),[G,he]=se.useState(""),[te,le]=se.useState(""),[ve,ke]=se.useState(""),[Be,J]=se.useState("link"),[ie,xe]=se.useState(""),[ae,Fe]=se.useState(!1),[pt,Ue]=se.useState(null),[Ct,Tt]=se.useState(!1),[ht,Ye]=se.useState(null),[Yt,dt]=se.useState(!1),[sn,pn]=se.useState([]),[Fn,Ft]=se.useState([]),[Dt,Ht]=se.useState([]),[Ze,Wt]=se.useState(""),[It,ln]=se.useState({}),[Kn,un]=se.useState({}),[xr,Ve]=se.useState({}),[Ot,nn]=se.useState(""),[mn,dr]=se.useState(""),[hr,Ui]=se.useState(""),[$n,be]=se.useState(""),[je,ze]=se.useState(!1),[tt,fn]=se.useState([]),[Bt,jn]=se.useState(!0),[jt,on]=se.useState("");se.useEffect(()=>{if(!t)return;const P=Qt(it(pe,"notifications"),Nr("userId","==","all")),de=di(P,De=>{const xt=De.docs.map(qt=>({id:qt.id,...qt.data()}));xt.sort((qt,cr)=>{var dn,Dr;const ir=qt.timestamp||((dn=qt.createdAt)!=null&&dn.toMillis?qt.createdAt.toMillis():0);return(cr.timestamp||((Dr=cr.createdAt)!=null&&Dr.toMillis?cr.createdAt.toMillis():0))-ir}),fn(xt),jn(!1)},De=>{console.warn("Failed to subscribe to broadcast notifications:",De),jn(!1)});return()=>de()},[t]);const Ir=async P=>{if(window.confirm("Are you sure you want to delete this broadcast message? It will be removed from all users' inboxes."))try{await ni(ot(pe,"notifications",P)),me.success("Broadcast message deleted successfully!",{icon:"🗑️"})}catch(de){me.error("Failed to delete broadcast: "+de.message)}},pr=async()=>{if(tt.length&&window.confirm(`Are you sure you want to delete ALL ${tt.length} broadcast messages from the database?`))try{await Promise.all(tt.map(P=>ni(ot(pe,"notifications",P.id)))),me.success("All broadcast messages cleared from database!",{icon:"🧹"})}catch(P){me.error("Failed to clear broadcasts: "+P.message)}},ue=async P=>{var De,xt,qt;if(P.preventDefault(),!(((xt=(De=Ne.currentUser)==null?void 0:De.email)==null?void 0:xt.toLowerCase())==="atwiinevictor2@gmail.com")){me.error("Access Denied: Only Top Master Admin (atwiinevictor2@gmail.com) can dispatch broadcast messages.");return}if(!Ot.trim()||!mn.trim()){me.error("Please enter both a title and message for the broadcast!");return}ze(!0);try{const cr=`broadcast_${Date.now()}_${Math.random().toString(36).substring(2,7)}`;await Hr(ot(pe,"notifications",cr),{userId:"all",isBroadcast:!0,title:Ot.trim(),message:mn.trim(),imageUrl:hr.trim()||null,link:$n.trim()||null,senderName:((qt=Ne.currentUser)==null?void 0:qt.displayName)||"Campus Admin",used:!1,playSound:!0,createdAt:Bn(),type:"broadcast_announcement"}),me.success("Broadcast message successfully dispatched to everyone's inbox!",{icon:"📢"}),nn(""),dr(""),Ui(""),be("")}catch(cr){me.error("Failed to send broadcast: "+cr.message)}finally{ze(!1)}},Se=async P=>{if(!(Kn[P]||xr[P])){Ve(de=>({...de,[P]:!0}));try{const[de,De,xt,qt,cr]=await Promise.all([vn(Qt(it(pe,"articles"),Nr("authorId","==",P))),vn(Qt(it(pe,"posts"),Nr("authorId","==",P))),vn(Qt(it(pe,"purchases"),Nr("userId","==",P))),vn(Qt(it(pe,"follows"),Nr("followedId","==",P))),vn(Qt(it(pe,"follows"),Nr("followerId","==",P)))]),ir=de.size,Jr=De.size,dn=xt.size,Dr=qt.size,_n=cr.size,an=xt.docs.reduce((Zi,hs)=>Zi+(hs.data().totalAmount||0),0),tr=ir*15+Jr*8+dn*12+Dr*3;let Zn="New Citizen",Li="bg-gray-50 text-gray-500 border-gray-100";tr>=100?(Zn="Legendary Champion",Li="bg-amber-50 text-amber-700 border-amber-200"):tr>=50?(Zn="Super Citizen",Li="bg-indigo-50 text-accent border-indigo-200"):tr>=15&&(Zn="Active Contributor",Li="bg-emerald-50 text-emerald-700 border-emerald-200");const Ti=de.docs.slice(0,3).map(Zi=>({id:Zi.id,title:Zi.data().title})),al=De.docs.slice(0,3).map(Zi=>({id:Zi.id,content:Zi.data().content}));un(Zi=>({...Zi,[P]:{articlesCount:ir,postsCount:Jr,purchasesCount:dn,followersCount:Dr,followingCount:_n,totalSpent:an,engagementScore:tr,tier:Zn,tierColor:Li,recentArticles:Ti,recentPosts:al}}))}catch(de){console.error("Error fetching individual user analytics:",de)}finally{Ve(de=>({...de,[P]:!1}))}}},[Xe,Vt]=se.useState(""),[gn,xn]=se.useState(null),[yn,gt]=se.useState(""),[Tn,Nt]=se.useState("all"),[Ae,tn]=se.useState({totalViews:0,totalLikes:0,totalComments:0,totalArticles:0,totalPosts:0,totalUsers:0,activeAds:0,pendingAds:0,flaggedCount:0,totalTicketsSold:0,totalRevenue:0,viewsByDay:[]}),[yt,cn]=se.useState(tY()),[Pt,Sn]=se.useState(["857eaaf2b7571ee437db8ee3f6ee8670"]),[_r,xi]=se.useState(""),[rs,mi]=se.useState([]),[fa,is]=se.useState(""),[hi,Wr]=se.useState([]),[Sr,Qi]=se.useState(""),[ss,si]=se.useState(""),[Et,Oa]=se.useState(""),[Tr,Hi]=se.useState(""),[jo,or]=se.useState(""),[kr,lr]=se.useState("Entertainment"),[Re,mt]=se.useState(null),[Je,vt]=se.useState(null),[Zt,wn]=se.useState(""),[Le,Ut]=se.useState(["General","Campus News","Sports","Entertainment","Politics"]),[On,Mn]=se.useState(""),[Pn,vr]=se.useState(!1),[Me,fe]=se.useState(""),[rn,ai]=se.useState(""),[oi,yi]=se.useState(""),[gi,Gi]=se.useState(null),[en,wr]=se.useState(0),[na,Ms]=se.useState("General"),[Pa,ks]=se.useState([]),[Nl,Ks]=se.useState(""),[Si,Cs]=se.useState(""),[Is,Gn]=se.useState("Discover More"),[Ls,Yn]=se.useState(""),[li,To]=se.useState(!1),[zr,Ka]=se.useState(""),[Us,Qo]=se.useState(""),[Ya,pa]=se.useState(null),[bs,ma]=se.useState(""),[Vr,Ys]=se.useState("image"),[bi,co]=se.useState("7"),[El,Xa]=se.useState(""),[Ra,ra]=se.useState(["",""]),[Oo,Fr]=se.useState("active"),[uo,ci]=se.useState(!1),[ia,Zo]=se.useState([]),[st,mr]=se.useState(""),[Mi,ge]=se.useState(""),[we,Te]=se.useState(""),[$e,ut]=se.useState(!1),[lt,At]=se.useState(""),[bn,Mt]=se.useState(!1);se.useEffect(()=>{if(!t||a!=="polls")return;const P=Qt(it(pe,"debates"),pi("createdAt","desc"));vn(P).then(de=>{Zo(de.docs.map(De=>({id:De.id,...De.data()})))}).catch(de=>{console.error("Failed to load debates in Admin Dashboard:",de)})},[t,a]);const An=async P=>{if(P.preventDefault(),!st.trim()){me.error("Please enter a debate title.");return}if($e&&!lt.trim()){me.error("Please enter an external link for discussion.");return}Mt(!0);try{const de=we.trim()||"https://images.unsplash.com/photo-1541872703-74c5e44368f9?auto=format&fit=crop&q=80&w=800";await ur(it(pe,"debates"),{title:st.trim(),description:Mi.trim(),bannerUrl:de,isExternal:$e,externalUrl:$e?lt.trim():"",createdAt:Bn(),commentsCount:0}),me.success("Debate published successfully!"),mr(""),ge(""),Te(""),ut(!1),At("")}catch(de){me.error("Failed to publish debate: "+de.message)}finally{Mt(!1)}},Rn=async P=>{if(!t){me.error("Access Denied: Only administrators can delete debates.");return}if(window.confirm("Are you sure you want to delete this debate?"))try{await ni(ot(pe,"debates",P)),me.success("Debate deleted successfully!")}catch(de){me.error("Failed to delete debate: "+de.message)}},[qe,_]=se.useState(""),[U,H]=se.useState(""),[re,Oe]=se.useState("audio"),[We,Ce]=se.useState(""),[_t,qn]=se.useState(""),[Nn,Jn]=se.useState("5:40"),[Br,ki]=se.useState("Campus Vibe"),[Qr,Kr]=se.useState(""),[Xs,Da]=se.useState(""),[Ci,js]=se.useState(!1),[Po,ga]=se.useState([]),[Ro,ho]=se.useState(null),[Wc,Kl]=se.useState(null),[Rf,mc]=se.useState([]),[xa,rh]=se.useState([]),[Do,Jo]=se.useState([]),[Rr,Kc]=se.useState(""),[ee,u]=se.useState(""),[p,g]=se.useState(""),[b,v]=se.useState(!1),[E,S]=se.useState({}),[O,M]=se.useState(null),[W,ne]=se.useState(""),[oe,ye]=se.useState(""),[_e,Ie]=se.useState(""),[Ke,ct]=se.useState(!1);se.useEffect(()=>{if(!t||a!=="mega-ai-knowledge")return;const P=Qt(it(pe,"mega_ai_knowledge")),de=di(P,ir=>{const Jr=ir.docs.map(dn=>({id:dn.id,...dn.data()}));Jr.sort((dn,Dr)=>{var tr,Zn,Li,Ti;const _n=((tr=dn.createdAt)==null?void 0:tr.seconds)||((Zn=dn.updatedAt)==null?void 0:Zn.seconds)||0;return(((Li=Dr.createdAt)==null?void 0:Li.seconds)||((Ti=Dr.updatedAt)==null?void 0:Ti.seconds)||0)-_n}),mc(Jr)},ir=>console.error("Error subscribing to mega_ai_knowledge:",ir)),De=Qt(it(pe,"notifications"),Nr("type","==","mega_ai_query")),xt=di(De,ir=>{const Jr=ir.docs.map(dn=>({id:dn.id,...dn.data()}));Jr.sort((dn,Dr)=>{var _n,an;return(((_n=Dr.createdAt)==null?void 0:_n.seconds)||0)-(((an=dn.createdAt)==null?void 0:an.seconds)||0)}),rh(Jr)},ir=>console.error("Error subscribing to mega_ai_query tickets:",ir)),qt=Qt(it(pe,"notifications"),Nr("type","==","unlimited_posting_request")),cr=di(qt,ir=>{const Jr=ir.docs.map(dn=>({id:dn.id,...dn.data()}));Jr.sort((dn,Dr)=>{var _n,an;return(((_n=Dr.createdAt)==null?void 0:_n.seconds)||0)-(((an=dn.createdAt)==null?void 0:an.seconds)||0)}),Jo(Jr)},ir=>console.error("Error subscribing to unlimited posting requests:",ir));return()=>{de(),xt(),cr()}},[t,a]);const Gt=async P=>{const de=P.requestAuthorId||P.userId;if(!de){me.error("User ID not found on request.");return}try{await Hr(ot(pe,"users",de),{isPremiumPostUser:!0},{merge:!0}),await ur(it(pe,"notifications"),{userId:de,type:"unlimited_posting_approved",title:"🎉 Unlimited Posting Approved!",message:"An administrator has approved your account for unlimited dispatches and postings on Campus Eye!",used:!1,playSound:!0,createdAt:Bn()}),P.id&&await ni(ot(pe,"notifications",P.id)),Jo(De=>De.filter(xt=>xt.id!==P.id)),me.success(`Approved @${P.requestAuthorName||"Student"} for unlimited posting! Notification removed.`,{icon:"🎉"})}catch(De){me.error("Failed to approve user: "+De.message)}},$t=async P=>{try{await ni(ot(pe,"notifications",P)),Jo(de=>de.filter(De=>De.id!==P)),me.success("Request dismissed and permanently deleted.",{icon:"🗑️"})}catch(de){me.error("Failed to dismiss request: "+de.message)}},Rt=async()=>{if(Do.length!==0&&window.confirm("Permanently clear and delete ALL unlimited posting approval requests?"))try{await Promise.all(Do.map(P=>ni(ot(pe,"notifications",P.id)))),Jo([]),me.success("All posting approval requests permanently cleared!",{icon:"✨"})}catch(P){me.error("Error clearing requests: "+P.message)}},Or=async P=>{try{await ni(ot(pe,"notifications",P)),rh(de=>de.filter(De=>De.id!==P)),me.success("Query ticket deleted permanently.",{icon:"🗑️"})}catch(de){me.error("Failed to delete ticket: "+de.message)}},yr=async P=>{if(P.preventDefault(),!Rr.trim()||!ee.trim()){me.error("Please fill in both the Question and Answer fields.");return}v(!0);try{const de=p.split(",").map(xt=>xt.trim()).filter(Boolean),De=await ur(it(pe,"mega_ai_knowledge"),{question:Rr.trim(),answer:ee.trim(),keywords:de,createdAt:Bn()});mc(xt=>[{id:De.id,question:Rr.trim(),answer:ee.trim(),keywords:de},...xt]),Kc(""),u(""),g(""),me.success("Added smart reply to Mega AI Knowledge Base!")}catch(de){me.error("Failed to add AI knowledge: "+de.message)}finally{v(!1)}},vs=async P=>{if(window.confirm("Remove this entry from Mega AI knowledge base?"))try{await ni(ot(pe,"mega_ai_knowledge",P)),mc(de=>de.filter(De=>De.id!==P)),me.success("Removed entry from Mega AI Knowledge Base.")}catch(de){me.error("Error deleting knowledge item: "+de.message)}},fo=P=>{M(P),ne(P.question||""),ye(P.answer||""),Ie(Array.isArray(P.keywords)?P.keywords.join(", "):P.keywords||"")},sa=()=>{M(null),ne(""),ye(""),Ie("")},vi=async P=>{if(P.preventDefault(),!O||!W.trim()||!oe.trim()){me.error("Please fill in both the Question and Answer fields.");return}ct(!0);try{const de=_e.split(",").map(De=>De.trim()).filter(Boolean);await Hn(ot(pe,"mega_ai_knowledge",O.id),{question:W.trim(),answer:oe.trim(),keywords:de,updatedAt:Bn()}),M(null),me.success("AI Knowledge Base entry updated successfully!",{icon:"✨"})}catch(de){me.error("Failed to update AI knowledge: "+de.message)}finally{ct(!1)}},Qs=async P=>{const de=E[P.id]||P.generatedReply||"";if(!de.trim()){me.error("Please enter a reply before submitting.");return}try{P.postId?(await ur(it(pe,"posts",P.postId,"comments"),{postId:P.postId,content:de.trim(),authorId:"mega-ai-bot",authorName:"Mega AI",authorPhotoURL:Vo,createdAt:Bn(),likeCount:0,likedBy:[],isAIGenerated:!0}),await Hn(ot(pe,"posts",P.postId),{commentCount:Ur(1)})):P.articleId&&(await ur(it(pe,"articles",P.articleId,"comments"),{content:de.trim(),userId:"mega-ai-bot",authorName:"Mega AI",photoURL:Vo,createdAt:Bn(),articleId:P.articleId,likeCount:0,isAIGenerated:!0}),await Hn(ot(pe,"articles",P.articleId),{commentCount:Ur(1)}));const De=(P.userQuery||"").toLowerCase().split(" ").filter(xt=>xt.length>3);if(await ur(it(pe,"mega_ai_knowledge"),{question:P.userQuery||"",answer:de.trim(),keywords:De,createdAt:Bn()}),P.userUid&&P.userUid!=="guest")try{await ur(it(pe,"notifications"),{userId:P.userUid,type:"admin_mega_reply",title:"🤖 Admin / Mega AI Replied to your Query!",message:`Response: "${de.trim().slice(0,120)}${de.trim().length>120?"...":""}"`,fullAnswer:de.trim(),userQuery:P.userQuery||"",targetType:P.targetType||"post",postId:P.postId||null,articleId:P.articleId||null,commentId:P.commentId||null,used:!1,playSound:!0,createdAt:Bn()})}catch(xt){console.warn("Could not dispatch user inbox notification:",xt)}P.id&&(await Hn(ot(pe,"notifications",P.id),{used:!0}),rh(xt=>xt.map(qt=>qt.id===P.id?{...qt,used:!0}:qt))),me.success("Replied to user as Mega AI & saved response into Knowledge Base! ✨")}catch(De){me.error("Error replying to Mega AI query: "+De.message)}},ya=P=>{var De;return P.username?P.username:(P.displayName||((De=P.email)==null?void 0:De.split("@")[0])||"peer").toLowerCase().replace(/[^a-z0-9]/g,"")},gc=se.useMemo(()=>gi===null?[]:Z.filter(P=>{const de=(P.username||ya(P)).toLowerCase(),De=(P.displayName||"").toLowerCase(),xt=gi.toLowerCase();return de.includes(xt)||De.includes(xt)}).slice(0,5),[gi,Z]),xc=P=>{const de=P.target.value;yi(de);const De=P.target.selectionStart,qt=de.substring(0,De).split(/[\s]/),cr=qt[qt.length-1];cr.startsWith("@")?(Gi(cr.substring(1)),wr(De)):Gi(null)};se.useEffect(()=>{if(!t||a!=="manage-podcasts")return;const P=Qt(it(pe,"podcasts"),pi("publishDate","desc"));vn(P).then(de=>{ga(de.docs.map(De=>({id:De.id,...De.data()})))}).catch(de=>{console.error("Failed to load podcasts in Admin Dashboard:",de)})},[t,a]);const Df=()=>{_(""),H(""),Oe("audio"),Ce(""),qn(""),Jn("5:40"),ki("Campus Vibe"),Kr(""),Da(""),ho(null)},Mf=async P=>{P.preventDefault();const de=(re==="video"?_t:We).trim();if(!qe.trim()||!U.trim()||!de){me.error(`Please fill out podcast title, host name, and ${re==="video"?"video":"audio"} link.`);return}js(!0);try{let De=Qr.trim();De||(re==="video"&&gp(de)?De=Yv(de,"hq"):re==="video"?De="https://images.unsplash.com/photo-1578022761797-b8636ac1773c?auto=format&fit=crop&q=80&w=500":De="https://images.unsplash.com/photo-1590602847861-f357a9332bbc?auto=format&fit=crop&q=80&w=500");const xt={title:qe.trim(),author:U.trim(),mediaType:re,audioUrl:re==="audio"?de:"",videoUrl:re==="video"?de:"",mediaUrl:de,duration:Nn.trim()||(re==="video"?"Video":"5:40"),category:Br,thumbnail:De,description:Xs.trim(),publishDate:Bn()};if(Ro)await Hn(ot(pe,"podcasts",Ro),xt),me.success(`${re==="video"?"🎬 Video":"📻 Audio"} podcast updated successfully!`,{icon:re==="video"?"🎬":"📻"});else{const qt=await ur(it(pe,"podcasts"),xt);me.success(`New ${re==="video"?"🎬 Video":"📻 Audio"} episode published successfully!`,{icon:re==="video"?"🎬":"📻"});try{const cr=(qe||"podcast").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:`${window.location.origin}/podcast/${cr}/${qt.id}`,title:qe,image:Qr||""})}).catch(()=>{})}catch{}}Df()}catch(De){console.error(De),me.error("Failed to save podcast: "+De.message)}finally{js(!1)}},Al=P=>{const de=Dl(P);_(P.title||""),H(P.author||""),Oe(de?"video":"audio"),Ce(P.audioUrl||(de?"":P.mediaUrl)||""),qn(P.videoUrl||(de?P.mediaUrl:"")||""),Jn(P.duration||(de?"Video":"5:40")),ki(P.category||"Campus Vibe"),Kr(P.thumbnail||""),Da(P.description||""),ho(P.id),window.scrollTo({top:0,behavior:"smooth"})},Nm=async P=>{if(!t){me.error("Access Denied: Only administrators can delete podcasts.");return}if(window.confirm("Are you sure you want to permanently delete this podcast episode?"))try{await ni(ot(pe,"podcasts",P)),me.success("Podcast episode deleted permanently.")}catch(de){me.error("Failed to delete podcast: "+de.message)}},el=P=>{Dl(P)?(Kl(P),window.dispatchEvent(new CustomEvent("play-video-podcast",{detail:P})),me.success(`Previewing Video: ${P.title}`,{icon:"🎬"})):(window.dispatchEvent(new CustomEvent("play-podcast",{detail:P})),me.success(`Broadcasting Audio: ${P.title}`,{icon:"📻"}))},Yc=["atwiinevictor2@gmail.com","campuseye@gmail.com"];se.useEffect(()=>{const P=Ne.currentUser;localStorage.getItem("is_admin_cached")==="true"?(n(!0),i(!1)):P&&Yc.includes(P.email||"")&&(n(!0),localStorage.setItem("is_admin_cached","true"),i(!1));const De=setTimeout(()=>{i(!1)},1200);let xt=null,qt=null;const cr=Ne.onAuthStateChanged(async ir=>{if(xt&&(xt(),xt=null),qt&&(qt(),qt=null),ir){if(Yc.includes(ir.email||"")){n(!0),localStorage.setItem("is_admin_cached","true"),i(!1),clearTimeout(De);return}let Jr=!1,dn=!1;const Dr=()=>{const _n=Jr||dn||Yc.includes(ir.email||"");n(_n),localStorage.setItem("is_admin_cached",_n?"true":"false"),i(!1),clearTimeout(De)};xt=di(ot(pe,"users",ir.uid),_n=>{if(_n.exists()){const an=_n.data();Jr=an.isAdmin===!0||an.role==="admin"}Dr()},_n=>{console.warn("User doc admin snapshot error:",_n),Dr()}),qt=di(ot(pe,"admins",ir.uid),_n=>{_n.exists()&&(dn=_n.data().isAdmin===!0),Dr()},_n=>{console.warn("Admin doc snapshot error:",_n),Dr()})}else n(!1),localStorage.removeItem("is_admin_cached"),i(!1),clearTimeout(De)});return()=>{cr(),xt&&xt(),qt&&qt(),clearTimeout(De)}},[]),se.useEffect(()=>{if(!t)return;const P=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],de=[1850,2460,2100,3120,2890,4150,4800],De=[1250,1680,1520,1890,1720,2150,2420],xt=[15,24,18,32,28,45,54],qt=[12,18,15,25,22,38,48],cr=P.map((dn,Dr)=>({name:dn,visitors:de[Dr],indigo:De[Dr],engagement:De[Dr],posts:xt[Dr],tickets:qt[Dr]})),ir=async()=>{try{const[dn,Dr,_n,an,tr]=await Promise.all([Px(it(pe,"articles")).catch(()=>null),Px(it(pe,"posts")).catch(()=>null),Px(it(pe,"users")).catch(()=>null),Px(it(pe,"adverts")).catch(()=>null),Px(it(pe,"purchases")).catch(()=>null)]);tn(Zn=>({...Zn,totalArticles:(dn==null?void 0:dn.data().count)??Zn.totalArticles??0,totalPosts:(Dr==null?void 0:Dr.data().count)??Zn.totalPosts??0,totalUsers:(_n==null?void 0:_n.data().count)??Zn.totalUsers??0,activeAds:(an==null?void 0:an.data().count)??Zn.activeAds??0,totalTicketsSold:(tr==null?void 0:tr.data().count)??Zn.totalTicketsSold??0,viewsByDay:cr}))}catch(dn){console.warn("Silent ignore stats count error:",dn)}};ir();const Jr=setInterval(ir,3e4);return()=>{clearInterval(Jr)}},[t]),se.useEffect(()=>{const P=a==="dashboard"||a==="article"||a==="manage-articles",de=a==="dashboard"||a==="manage-ads"||a==="advert",De=a==="dashboard"||a==="manage-articles"||a==="article",xt=a==="users",qt=a==="flagged-comments",cr=a==="manage-tickets"||a==="ticket-purchases",ir=a==="dashboard"||a==="ticket-purchases",Jr=a==="manage-posts",dn=a==="custom-links",Dr=a==="feedback-inbox";if(P){const _n=Qt(it(pe,"categories"),pi("name","asc"));vn(_n).then(an=>{const tr=an.docs.map(Zn=>Zn.data().name);if(tr.length>0){const Zn=Array.from(new Set(["General","Campus News","Sports","Entertainment","Politics",...tr]));Ut(Zn)}}).catch(an=>{Gs(an,Ps.LIST,"categories")})}if(Ne.currentUser&&de){const _n=Qt(it(pe,"adverts"),pi("createdAt","desc"),Pi(30));vn(_n).then(an=>{const tr=an.docs.map(Ti=>({id:Ti.id,...Ti.data()}));pn(tr);const Zn=tr.filter(Ti=>Ti.status==="active").length,Li=tr.filter(Ti=>Ti.status==="hidden").length;tn(Ti=>({...Ti,activeAds:Zn,pendingAds:Li}))}).catch(an=>{Gs(an,Ps.LIST,"adverts")})}if(Ne.currentUser&&De){const _n=a==="dashboard"?30:60,an=Qt(it(pe,"articles"),pi("publishDate","desc"),Pi(_n));vn(an).then(tr=>{const Zn=tr.docs.map(Ts=>({id:Ts.id,...Ts.data()}));h(Zn);const Li=Zn.reduce((Ts,La)=>Ts+(La.viewCount||La.views||0),0),Ti=Zn.reduce((Ts,La)=>Ts+(La.likeCount||La.likes||0),0),al=Zn.reduce((Ts,La)=>Ts+(La.commentCount||0),0),Zi=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],hs=[1850,2460,2100,3120,2890,4150,4800],Gf=[1250,1680,1520,1890,1720,2150,2420],qf=[15,24,18,32,28,45,54],Vm=[12,18,15,25,22,38,48],rx=Zi.map((Ts,La)=>({name:Ts,visitors:hs[La],indigo:Gf[La],engagement:Gf[La],posts:qf[La],tickets:Vm[La]}));tn(Ts=>({...Ts,totalViews:Li,totalLikes:Ti,totalArticles:Ts.totalArticles||Zn.length,totalComments:al,viewsByDay:rx}))},tr=>{Gs(tr,Ps.LIST,"articles")})}if(Ne.currentUser&&t&&a==="dashboard"&&(vn(it(pe,"posts")).then(_n=>{const an=_n.docs.map(Li=>({id:Li.id,...Li.data()})),tr=an.filter(Li=>Li.flagged===!0||Li.isFlagged===!0),Zn=an.reduce((Li,Ti)=>{var al;return Li+(Ti.commentsCount||((al=Ti.comments)==null?void 0:al.length)||0)},0);tn(Li=>({...Li,totalPosts:_n.docs.length,totalComments:Li.totalComments+Zn,flaggedCount:Li.flaggedCount+tr.length}))}).catch(_n=>console.error("Error fetching posts stats:",_n)),vn(it(pe,"users")).then(_n=>{tn(an=>({...an,totalUsers:_n.docs.length}))}).catch(_n=>console.error("Error fetching users stats:",_n))),Ne.currentUser&&t&&xt&&vn(Qt(it(pe,"users"),Pi(50))).then(_n=>{K(_n.docs.map(an=>({id:an.id,...an.data()})))}).catch(_n=>{console.error("Error loading users:",_n),Gs(_n,Ps.LIST,"users")}),Ne.currentUser&&t&&(qt||a==="dashboard")){const _n=Qt(phe(pe,"comments"),Pi(50));vn(_n).then(an=>{const tr=an.docs.map(Zn=>({id:Zn.id,...Zn.data()})).filter(Zn=>Zn.flagged===!0);B(tr),tn(Zn=>({...Zn,flaggedCount:tr.length}))}).catch(an=>{Gs(an,Ps.LIST,"comments-group")}),vn(Qt(it(pe,"posts"),Pi(100))).then(an=>{const tr=an.docs.map(Zn=>({id:Zn.id,...Zn.data()})).filter(Zn=>Zn.flagged===!0||Zn.isFlagged===!0);mi(tr)}).catch(an=>console.error("Error fetching flagged posts:",an))}if(Ne.currentUser&&a==="imgbb-settings"&&cs(ot(pe,"settings","imgbb")).then(_n=>{if(_n.exists()){const an=_n.data();an.activeKey&&(cn(an.activeKey),localStorage.setItem("campus_eye_imgbb_active_key",an.activeKey)),Array.isArray(an.savedKeys)&&an.savedKeys.length>0&&Sn(an.savedKeys)}}).catch(_n=>console.error("Error loading imgbb settings:",_n)),Ne.currentUser&&cr){const _n=Qt(it(pe,"tickets"),pi("createdAt","desc"),Pi(30));vn(_n).then(an=>{Ft(an.docs.map(tr=>({id:tr.id,...tr.data()})))}).catch(an=>{Gs(an,Ps.LIST,"tickets")})}if(Ne.currentUser&&t&&ir){const _n=Qt(it(pe,"purchases"),pi("purchaseDate","desc"),Pi(45));vn(_n).then(an=>{const tr=an.docs.map(Ti=>({id:Ti.id,...Ti.data()}));Ht(tr);const Zn=tr.reduce((Ti,al)=>Ti+(al.quantity||0),0),Li=tr.reduce((Ti,al)=>Ti+(al.totalAmount||0),0);tn(Ti=>({...Ti,totalTicketsSold:Zn,totalRevenue:Li}))}).catch(an=>{Gs(an,Ps.LIST,"purchases")})}if(Ne.currentUser&&Jr){const _n=Qt(it(pe,"posts"),pi("createdAt","desc"),Pi(40));vn(_n).then(an=>{const tr=an.docs.map(Zn=>({id:Zn.id,...Zn.data()}));$(tr)}).catch(an=>{console.warn("Silent ignore admin lounge posts list issue:",an)})}if(Ne.currentUser&&t&&dn){const _n=Qt(it(pe,"custom_pages"),pi("createdAt","desc"),Pi(20));vn(_n).then(an=>{const tr=an.docs.map(Zn=>({id:Zn.id,...Zn.data()}));Y(tr)}).catch(an=>{console.error("Silent ignore admin custom pages list issue:",an)})}if(Ne.currentUser&&t&&Dr){const _n=Qt(it(pe,"feedback"),pi("createdAt","desc"),Pi(30));vn(_n).then(an=>{const tr=an.docs.map(Zn=>({id:Zn.id,...Zn.data()}));Wr(tr)}).catch(an=>{console.error("Silent ignore admin feedbacks list issue:",an)})}return()=>{}},[t,a]);const qg=async P=>{if(P.preventDefault(),!(!Ne.currentUser||!t)){if(!G.trim()||!te.trim()){me.error("Please fill in all details for the page!");return}Tt(!0);try{pt?(await Hn(ot(pe,"custom_pages",pt.id),{name:G.trim(),url:te.trim(),svgIcon:ve.trim(),type:Be,description:ie.trim(),isPinnedStyle:ae}),me.success("Page updated successfully in everyone's menu!"),Ue(null)):(await ur(it(pe,"custom_pages"),{name:G.trim(),url:te.trim(),svgIcon:ve.trim(),type:Be,description:ie.trim(),isPinnedStyle:ae,createdAt:Bn()}),me.success("New page loaded to everyone's menu!")),he(""),le(""),ke(""),J("link"),xe(""),Fe(!1)}catch(de){me.error("Database operation failed: "+de.message)}finally{Tt(!1)}}},Em=P=>{Ue(P),he(P.name),le(P.url),ke(P.svgIcon||""),J(P.type||"link"),xe(P.description||""),Fe(!!P.isPinnedStyle)},Am=async P=>{if(!t){me.error("Access Denied: Only administrators can delete custom pages.");return}if(window.confirm("Are you sure you want to permanently delete this custom page from everyone's menu?"))try{await ni(ot(pe,"custom_pages",P)),me.success("Custom page removed successfully."),(pt==null?void 0:pt.id)===P&&(Ue(null),he(""),le(""),ke(""),J("link"),xe(""),Fe(!1))}catch(de){me.error("Failed to delete page: "+de.message)}},Wg=async P=>{if(P.preventDefault(),!(!Ne.currentUser||!t)){Tt(!0),Ye(null),dt(!1);try{const de=ld||(Je==null?void 0:Je.imageUrl)||"https://picsum.photos/seed/ticket/300/200",De=fa.trim()||"Untitled Campus Event",xt=parseFloat(ss)||0,qt=parseInt(jo)||100,cr={title:De,description:Sr||"Join us for this amazing university experience.",price:xt,eventDate:Et?jr.fromDate(new Date(Et)):Bn(),venue:Tr||"Campus Hall",imageUrl:de,totalQuantity:qt,remainingQuantity:Je?Je.remainingQuantity+(qt-Je.totalQuantity):qt,category:kr||"Entertainment",status:"available",createdAt:Je?Je.createdAt:Bn(),authorId:Ne.currentUser.uid,link:Zt||""};Je?(await Hn(ot(pe,"tickets",Je.id),cr),me.success("Ticket updated successfully!")):(await ur(it(pe,"tickets"),cr),me.success("Ticket created successfully!")),dt(!0),is(""),Qi(""),si(""),Oa(""),Hi(""),or(""),mt(null),iu(""),vt(null),wn("")}catch(de){Ye(de.message||"Failed to save ticket"),me.error("Failed to save ticket")}finally{Tt(!1)}}},Ku=async P=>{if(!(!t||!window.confirm("Are you sure you want to delete this ticket?")))try{await ni(ot(pe,"tickets",P)),me.success("Ticket deleted")}catch(de){console.error("Error deleting ticket:",de),me.error("Failed to delete ticket")}},ub=async(P,de)=>{if(!(!t||!window.confirm("Are you sure you want to delete this comment?")))try{await ni(ot(pe,"articles",P,"comments",de)),me.success("Comment deleted")}catch(De){console.error("Error deleting comment:",De),Ye("Failed to delete comment. Make sure it has an articleId.")}},_m=async(P,de)=>{if(t)try{await Hn(ot(pe,"articles",P,"comments",de),{flagged:!1})}catch(De){console.error("Error unflagging comment:",De),Ye("Failed to unflag comment. Make sure it has an articleId.")}},ih=async P=>{if(t)try{await Hn(ot(pe,"posts",P),{flagged:!1}),me.success("Post flag dismissed!")}catch(de){console.error("Error unflagging post:",de),me.error("Failed to unflag post.")}},dA=async P=>{if(!(!t||!window.confirm("Are you sure you want to delete this post?")))try{await ni(ot(pe,"posts",P)),me.success("Post deleted successfully!")}catch(de){console.error("Error deleting post:",de),me.error("Failed to delete post.")}},Mo=async(P,de)=>{var ir,Jr;if(!t)return;const De="atwiinevictor2@gmail.com",xt=((ir=Ne.currentUser)==null?void 0:ir.email)||"",qt=Z.find(dn=>dn.id===P),cr=(qt==null?void 0:qt.email)||"";if(cr.toLowerCase()===De.toLowerCase()&&de===!0&&xt.toLowerCase()!==De.toLowerCase()){try{if(Ne.currentUser){await Hn(ot(pe,"users",Ne.currentUser.uid),{isAdmin:!1,role:"user"});try{await ni(ot(pe,"admins",Ne.currentUser.uid))}catch{}}}catch(dn){console.error("Failed to strip rogue admin privileges:",dn)}try{const dn=((Jr=Ne.currentUser)==null?void 0:Jr.displayName)||xt||"An Administrator",Dr=`alert_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;await Hr(ot(pe,"notifications",Dr),{userId:P,title:"🛡️ Unauthorized Admin Dismissal Blocked",message:`${dn} (${xt}) attempted to dismiss you from being admin. They have been immediately removed from admins.`,used:!1,createdAt:new Date,type:"admin_security"})}catch(dn){console.error("Failed to push alert inbox notification:",dn)}return}try{const dn=!de;if(await Hn(ot(pe,"users",P),{isAdmin:dn,role:dn?"admin":"user"}),dn){await Hr(ot(pe,"admins",P),{isAdmin:!0,email:cr||"",grantedBy:xt,updatedAt:Bn()},{merge:!0});try{const Dr=`admin_grant_${P}_${Date.now()}`;await Hr(ot(pe,"notifications",Dr),{userId:P,title:"👑 Admin & Reporter Privileges Granted!",message:`Congratulations! Main Admin (${xt}) has granted you Admin & Reporter privileges. You can now post articles, edit stories, and manage dispatches in the Admin Dashboard.`,used:!1,createdAt:new Date,type:"admin_security"})}catch{}me.success(`Granted Admin privileges to ${cr||"user"}! They can now post articles.`)}else{try{await ni(ot(pe,"admins",P))}catch{}me.success(`Revoked Admin privileges for ${cr||"user"}.`)}}catch(dn){Ye(dn.message||"Failed to update user status"),me.error("Failed to change admin role status")}},Kg=async(P,de)=>{if(t)try{await Hn(ot(pe,"users",P),{isVerified:!de,isPremium:!de,blueCheck:!de,isPremiumPostUser:!de}),me.success(de?"Removed Blue Check (Premium) badge!":"Granted Blue Check (Premium) badge!")}catch(De){me.error("Failed to update user verification status: "+De.message)}},yc=async P=>{if(!(!t||!window.confirm("Are you sure you want to delete this article?")))try{await ni(ot(pe,"articles",P)),me.success("Article deleted")}catch(de){console.error("Error deleting article:",de)}},db=async P=>{var xt,qt,cr,ir;const de=((qt=(xt=Ne.currentUser)==null?void 0:xt.email)==null?void 0:qt.toLowerCase())==="atwiinevictor2@gmail.com"||((ir=(cr=Ne.currentUser)==null?void 0:cr.email)==null?void 0:ir.toLowerCase())==="campuseye@gmail.com";if(!(t||de||!!Ne.currentUser)){me.error("Please log in as admin or user to delete adverts");return}if(window.confirm("Are you sure you want to delete this advert?"))try{pn(Jr=>Jr.filter(dn=>dn.id!==P)),await ni(ot(pe,"adverts",P)),me.success("Advert deleted successfully!")}catch(Jr){console.error("Error deleting advert:",Jr),me.error("Failed to delete advert: "+Jr.message)}},Sm=async P=>{if(P.preventDefault(),!!On.trim()){Tt(!0);try{await ur(it(pe,"categories"),{name:On.trim(),createdAt:Bn()}),Mn(""),vr(!1)}catch(de){Ye(de.message||"Failed to add category")}finally{Tt(!1)}}},[Ii,Lf]=se.useState(null),[Yu,Yg]=se.useState(!1),[sh,Lo]=se.useState(""),[Xc,ah]=se.useState("all"),[km,Uf]=se.useState(null),[tl,nl]=se.useState(null),[Xu,bc]=se.useState(null),[vc,Qc]=se.useState(""),[hA,hb]=se.useState(""),[fb,fA]=se.useState(""),[Ma,as]=se.useState("General"),[Zr,Qu]=se.useState(""),[_l,pb]=se.useState(""),[Zu,pA]=se.useState("published"),[mA,Bf]=se.useState(!1),[Sl,oh]=se.useState(""),[Ju,lh]=se.useState(""),[wc,rl]=se.useState(""),[il,Qa]=se.useState(""),[Cm,ed]=se.useState(""),[Zc,td]=se.useState(""),[Jc,Zs]=se.useState(0),[zf,Im]=se.useState(0),[mb,Xg]=se.useState(0),[gb,ws]=se.useState(0),[jm,nd]=se.useState(0),[ch,Vf]=se.useState("published"),[eu,tu]=se.useState(""),[Qg,Tm]=se.useState(""),[Zg,Om]=se.useState(""),[sl,uh]=se.useState(""),[Yl,Pm]=se.useState(!0),[nu,Rm]=se.useState(!1),[dh,hh]=se.useState(5),[fh,Dm]=se.useState(!1),[Nc,Ec]=se.useState(""),[Mm,xb]=se.useState([]),[rd,id]=se.useState(!1),[Lm,Ff]=se.useState(!1),[Um,yb]=se.useState(!1),[sd,bb]=se.useState(!1),[ru,Jg]=se.useState(!1),[vb,ad]=se.useState(!1),[Uo,od]=se.useState(""),[ld,iu]=se.useState(""),Ac=async(P,de,De)=>{De(!0);const xt=me.loading("Uploading image...");try{const qt=await h4(P);de(qt),me.success("Image successfully uploaded and linked!",{id:xt})}catch(qt){console.error(qt),me.error(`Upload failed: ${qt.message||qt}`,{id:xt})}finally{De(!1)}};se.useEffect(()=>{Ne.currentUser&&!Ii&&(Qa(Ne.currentUser.displayName||"Anonymous"),ed(Ne.currentUser.photoURL||""))},[Ne.currentUser,Ii]),se.useEffect(()=>{t&&cs(ot(pe,"settings","pinned")).then(P=>{if(P.exists()){const de=P.data();tu(de.title||""),Tm(de.description||""),Om(de.link||""),uh(de.imageUrl||""),Pm(!!de.active),hh(de.durationSeconds||5),Dm(!!de.isLiveStream),Ec(de.liveEmbedUrl||"")}}).catch(P=>{console.warn("Silent ignored settings/pinned load error in admin panel:",P)})},[t]),se.useEffect(()=>{if(!t)return;const P=Qt(it(pe,"pinned_announcements"),pi("createdAt","desc"));vn(P).then(de=>{const De=de.docs.map(xt=>({id:xt.id,...xt.data()}));xb(De)}).catch(de=>{Gs(de,Ps.LIST,"pinned_announcements")})},[t]);const $f=async P=>{if(P.preventDefault(),!!t){Rm(!0);try{await Hr(ot(pe,"settings","pinned"),{title:eu.trim()||"Important Notice",description:Qg.trim()||"No detailed content provided.",link:Zg.trim(),imageUrl:sl.trim(),active:Yl,durationSeconds:Number(dh)||5,isLiveStream:fh,liveEmbedUrl:Nc.trim(),updatedAt:Bn()},{merge:!0}),await ur(it(pe,"pinned_announcements"),{title:eu.trim()||"Important Notice",description:Qg.trim()||"No detailed content provided.",link:Zg.trim(),imageUrl:sl.trim(),active:Yl,durationSeconds:Number(dh)||5,isLiveStream:fh,liveEmbedUrl:Nc.trim(),createdAt:Bn()}),me.success("Pinned Announcement published successfully!"),tu(""),Tm(""),Om(""),uh(""),Pm(!0),hh(5),Dm(!1),Ec("")}catch(de){console.error(de),me.error(`Failed to publish pinned announcement: ${de.message||de}`)}finally{Rm(!1)}}},wb=async P=>{if(!t){me.error("Access Denied: Only administrators can delete announcements.");return}if(window.confirm("Are you sure you want to permanently delete this announcement?"))try{await ni(ot(pe,"pinned_announcements",P)),me.success("Pinned Announcement deleted successfully.")}catch(de){me.error("Failed to delete announcement: "+de.message)}},Nb=P=>{if(Lf(P),fe(P.title||""),ai(P.summary||""),yi(P.content||""),Ms(P.category||"General"),Ks(P.video||""),Cs(P.Links||""),To(P.isSponsoredAd||!1),oh(P.featuredImageUrl||""),lh(P.featuredImageUrl1||""),rl(P.featuredImageUrl2||""),Qa(P.authorName||""),ed(P.authorProfile||""),P.publishDate){const de=P.publishDate instanceof jr?P.publishDate.toDate():new Date(P.publishDate),De=de.getTimezoneOffset()*6e4,xt=new Date(de.getTime()-De).toISOString().slice(0,16);td(xt)}else td("");Zs(P.viewCount||0),Im(P.likeCount||0),Xg(P.commentCount||0),ws(P.saveCount||0),nd(P.shareCount||0),Vf(P.status||"published"),o("article")},ph=()=>{var P,de;Lf(null),fe(""),ai(""),yi(""),Ms("General"),ks([]),Ks(""),Cs(""),To(!1),oh(""),lh(""),rl(""),Qa(((P=Ne.currentUser)==null?void 0:P.displayName)||"Anonymous"),ed(((de=Ne.currentUser)==null?void 0:de.photoURL)||""),td(""),Zs(0),Im(0),Xg(0),ws(0),nd(0),Vf("published")},Bm=async P=>{var de,De;if(P.preventDefault(),!(!Ne.currentUser||!t)){if(!Me.trim()){me.error("Article Title is required. Cannot publish an empty article.");return}if(!oi.trim()){me.error("Article Content is required. Cannot publish an empty article.");return}Tt(!0),Ye(null),dt(!1);try{const xt=Me.trim(),qt=rn.trim()||"No preview summary provided for this story.",cr=oi.trim();let ir;Zc?ir=jr.fromDate(new Date(Zc)):Ii!=null&&Ii.publishDate?ir=Ii.publishDate:ir=Bn();const Jr={title:xt,summary:qt,content:cr,category:na||"General",featuredImageUrl:Sl||"",featuredImageUrl1:Ju||"",featuredImageUrl2:wc||"",authorId:Ii?Ii.authorId:Ne.currentUser.uid,authorName:il||Ne.currentUser.displayName||"Anonymous",authorProfile:Cm||Ne.currentUser.photoURL||"",publishDate:ir,updatedAt:Bn(),viewCount:Number(Jc)||0,likeCount:Number(zf)||0,commentCount:Number(mb)||0,saveCount:Number(gb)||0,shareCount:Number(jm)||0,video:Nl||"",Links:Si||"",ctaText:Is||"Discover More",ctaUrl:Ls||"",status:ch||"published",isSponsoredAd:li||!1};let dn="";if(Ii)await Hn(ot(pe,"articles",Ii.id),Jr),dn=Ii.id;else{const an=await ur(it(pe,"articles"),Jr);dn=an.id;try{await fetch("/api/notify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"New Article Published",message:xt,url:`${window.location.origin}/article/${an.id}`,imageUrl:Sl||""})})}catch(tr){console.error("Failed to trigger notification:",tr)}}try{const an=xt.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),tr=`${window.location.origin}/articles=${an}/${dn}`;await fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:tr,title:xt,image:Sl||""})})}catch(an){console.warn("Silent sitemap write fail on publish:",an)}const Dr=cr.match(/@([a-zA-Z0-9_\-]+)/g)||[],_n=Array.from(new Set(Dr.map(an=>an.substring(1).toLowerCase())));for(const an of _n){const tr=Z.find(Zn=>(Zn.username||ya(Zn)).toLowerCase()===an);if(tr&&tr.id!==((de=Ne.currentUser)==null?void 0:de.uid)&&tr.uid!==((De=Ne.currentUser)==null?void 0:De.uid))try{await ur(it(pe,"notifications"),{userId:tr.id||tr.uid,title:"📰 Admin mentioned you in an article",message:`You were mentioned in the story "${xt}": "${cr.substring(0,60)}..."`,used:!1,type:"mention",createdAt:Bn()})}catch(Zn){console.warn("Art mention notify failed:",Zn)}}dt(!0),ph()}catch(xt){Ye(xt.message||"Failed to publish article"),Gs(xt,Ps.WRITE,Ii?`articles/${Ii.id}`:"articles")}finally{Tt(!1)}}},Eb=async P=>{var de,De;if(P.preventDefault(),!!Ne.currentUser){if(Vr==="image"&&!Uo){me.error("Please upload or provide an image link for the advert");return}if(Vr==="video"&&!bs){me.error("Please provide a video link for the motion advert");return}Tt(!0),Ye(null),dt(!1);try{const xt=Vr==="image"?Uo:"",qt=new Date;qt.setDate(qt.getDate()+parseInt(bi));const ir={id:(await ur(it(pe,"adverts"),{title:zr||"Sponsored Campaign",imageUrl:xt,videoUrl:bs,type:Vr,link:Us||"#",authorId:((de=Ne.currentUser)==null?void 0:de.uid)||"admin",createdAt:Bn(),expiresAt:jr.fromDate(qt),durationDays:parseInt(bi),status:"active"})).id,title:zr||"Sponsored Campaign",imageUrl:xt,videoUrl:bs,type:Vr,link:Us||"#",authorId:((De=Ne.currentUser)==null?void 0:De.uid)||"admin",durationDays:parseInt(bi),status:"active"};if(pn(Jr=>[ir,...Jr]),t)try{await fetch("/api/notify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"New Sponsored Update",message:zr||"Check out this new update!",url:Us||window.location.origin,imageUrl:xt||""})})}catch(Jr){console.error("Failed to trigger notification:",Jr)}dt(!0),Ka(""),Qo(""),pa(null),od(""),ma(""),Ys("image"),co("7")}catch(xt){Ye(xt.message||"Failed to publish advert")}finally{Tt(!1)}}},ex=async(P,de)=>{if(t)try{await Hn(ot(pe,"adverts",P),{status:de==="active"?"hidden":"active"})}catch(De){Ye(De.message||"Failed to update advert status")}},tx=async P=>{if(P.preventDefault(),!!t){Tt(!0);try{const de=Ra.filter(De=>De.trim().length>0).map(De=>({text:De.trim(),votes:0}));if(de.length<2)throw new Error("At least 2 options are required");if(Oo==="active"){const De=Qt(it(pe,"polls"),Nr("status","==","active")),xt=await vn(De);for(const qt of xt.docs)await Hn(ot(pe,"polls",qt.id),{status:"closed"})}await ur(it(pe,"polls"),{question:El,options:de,totalVotes:0,status:Oo,expiresAt:null,createdAt:Bn()}),me.success("Poll created successfully!"),Xa(""),ra(["",""])}catch(de){Ye(de.message||"Failed to create poll"),me.error("Poll creation failed")}finally{Tt(!1)}}},po=se.useMemo(()=>Dt.filter(P=>{const de=!!(P.taken||P.used);if(Tn==="unclaimed"&&de||Tn==="taken"&&!de)return!1;if(yn.trim()){const De=yn.trim().toLowerCase(),xt=(P.userName||"").toLowerCase().includes(De),qt=(P.userEmail||"").toLowerCase().includes(De),cr=(P.ticketTitle||"").toLowerCase().includes(De),ir=(P.id||"").toLowerCase().includes(De);return xt||qt||cr||ir}return!0}),[Dt,yn,Tn]),mo=async P=>{const de=!(P.taken||P.used);try{await Hn(ot(pe,"purchases",P.id),{taken:de,used:de}),de?(await ur(it(pe,"notifications"),{userId:P.userId,title:`✔️ Ticket Ticked & Used: ${P.ticketTitle}`,message:`Your event entry pass (ID #${P.id.slice(-6).toUpperCase()}) for "${P.ticketTitle}" has been officially marked as ticked and used by the administrators. Welcome to the event!`,used:!1,createdAt:new Date,type:"entrance_checkin",code:P.id}),me.success(`Ticket marked as used & ticked for ${P.userName}!`,{icon:"✔️"})):me.success(`Ticket for ${P.userName} is now reverted to active status.`)}catch(De){console.error("Failed to toggle purchase status:",De),me.error("Failed to update purchase code: "+De.message)}};return r?s.jsxs("div",{className:"flex flex-col items-center justify-center min-h-screen bg-white",children:[s.jsx(Pr,{className:"animate-spin text-accent",size:32}),s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-[0.2em] mt-4",children:"Verifying editorial credentials..."})]}):s.jsxs("div",{className:"w-full min-h-screen bg-[#f8f9fa] transition-colors",children:[s.jsxs("div",{className:"fixed left-0 top-0 h-full w-20 bg-white border-r border-gray-100 z-40 hidden lg:flex flex-col items-center",children:[s.jsx("div",{className:"p-4 py-6 border-b border-gray-50 flex flex-col items-center justify-center w-full",children:s.jsx(pl,{className:"text-accent",size:24})}),s.jsxs("nav",{className:"flex-1 p-3 py-6 space-y-3 overflow-y-auto w-full flex flex-col items-center",children:[t&&s.jsx("button",{onClick:()=>o("dashboard"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="dashboard"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Dashboard",children:s.jsx(xp,{size:18})}),t&&s.jsx("button",{onClick:()=>o("article"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="article"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"New Article",children:s.jsx(fu,{size:18})}),t&&s.jsx("button",{onClick:()=>o("manage-articles"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="manage-articles"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Articles",children:s.jsx(E0,{size:18})}),s.jsx("button",{onClick:()=>o("advert"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="advert"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Submit Advert",children:s.jsx(hu,{size:18})}),t&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>o("manage-ads"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="manage-ads"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Adverts",children:s.jsx(mu,{size:18})}),s.jsx("button",{onClick:()=>o("users"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="users"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Users",children:s.jsx(Ao,{size:18})}),s.jsxs("button",{onClick:()=>o("flagged-comments"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all relative shrink-0",a==="flagged-comments"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Flagged Comments",children:[s.jsx(bu,{size:18}),z.length>0&&s.jsx("span",{className:"absolute -top-1 -right-1 bg-red-600 text-white min-w-[15px] h-[15px] rounded-full text-[8px] font-black flex items-center justify-center px-0.5",children:z.length})]}),s.jsx("button",{onClick:()=>o("polls"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="polls"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Polls & Debates",children:s.jsx(Ek,{size:18})}),s.jsx("button",{onClick:()=>o("pinned-board"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="pinned-board"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Pinned Board",children:s.jsx(g0,{size:18})}),s.jsx("button",{onClick:()=>o("manage-posts"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="manage-posts"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Lounge Posts",children:s.jsx(Yi,{size:18})}),s.jsx("button",{onClick:()=>o("custom-links"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="custom-links"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Global Menu Pages",children:s.jsx(wd,{size:18})}),s.jsx("button",{onClick:()=>o("manage-podcasts"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="manage-podcasts"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Audio Podcasts",children:s.jsx(sc,{size:18})}),s.jsxs("button",{onClick:()=>o("feedback-inbox"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all relative shrink-0",a==="feedback-inbox"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Feedback Inbox",children:[s.jsx(Js,{size:18}),hi.length>0&&s.jsx("span",{className:"absolute -top-1 -right-1 bg-red-600 text-white min-w-[15px] h-[15px] rounded-full text-[8px] font-black flex items-center justify-center px-0.5",children:hi.length})]}),s.jsxs("div",{className:"pt-2 mt-2 border-t border-gray-100 w-full flex flex-col gap-3 items-center",children:[s.jsx("button",{onClick:()=>o("manage-tickets"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="manage-tickets"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Manage Events",children:s.jsx(No,{size:18})}),s.jsx("button",{onClick:()=>o("ticket-purchases"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0",a==="ticket-purchases"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"Sales Records",children:s.jsx(lv,{size:18})}),((zm=(_c=Ne.currentUser)==null?void 0:_c.email)==null?void 0:zm.toLowerCase())==="atwiinevictor2@gmail.com"&&s.jsx("button",{onClick:()=>o("imgbb-settings"),className:Ge("w-12 h-11 flex items-center justify-center rounded-xl transition-all shrink-0 mt-2",a==="imgbb-settings"?"bg-accent text-white shadow-lg shadow-accent/20":"text-gray-500 hover:bg-gray-50"),title:"API & Storage Settings (Top Admin Only)",children:s.jsx(Nk,{size:18,className:"text-blue-500"})})]})]})]}),s.jsx("div",{className:"p-4 border-t border-gray-50 flex items-center justify-center w-full",children:s.jsx("button",{onClick:()=>window.dispatchEvent(new CustomEvent("setTab",{detail:"home"})),className:"w-12 h-12 flex items-center justify-center bg-gray-950 text-white rounded-xl hover:bg-black transition-all cursor-pointer",title:"Back to Site",children:s.jsx(Vp,{size:18})})})]}),uo&&s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 lg:hidden transition-opacity",onClick:()=>ci(!1)}),s.jsxs("div",{className:Ge("fixed left-0 top-0 h-full w-64 bg-white border-r border-gray-100 z-50 lg:hidden flex flex-col transition-transform duration-300 shadow-2xl",uo?"translate-x-0":"-translate-x-full"),children:[s.jsxs("div",{className:"p-6 border-b border-gray-50 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx(Cee,{className:"scale-[0.85] origin-left"}),s.jsx("p",{className:"text-[9px] font-black text-black uppercase tracking-[0.25em] mt-1",children:"Management Drawer"})]}),s.jsx("button",{onClick:()=>ci(!1),className:"p-1.5 text-gray-405 hover:bg-gray-100 rounded-lg",children:s.jsx(er,{size:18})})]}),s.jsxs("nav",{className:"flex-1 p-5 overflow-y-auto space-y-1.5",children:[t&&s.jsxs("button",{onClick:()=>{o("dashboard"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="dashboard"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(xp,{size:16})," Dashboard"]}),t&&s.jsxs("button",{onClick:()=>{o("article"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="article"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(fu,{size:16})," New Article"]}),t&&s.jsxs("button",{onClick:()=>{o("manage-articles"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="manage-articles"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(E0,{size:16})," Articles"]}),s.jsxs("button",{onClick:()=>{o("advert"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="advert"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(hu,{size:16})," Submit Advert"]}),t&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:()=>{o("manage-ads"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="manage-ads"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(mu,{size:16})," Adverts"]}),s.jsxs("button",{onClick:()=>{o("users"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="users"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(Ao,{size:16})," Users"]}),((Sc=(nx=Ne.currentUser)==null?void 0:nx.email)==null?void 0:Sc.toLowerCase())==="atwiinevictor2@gmail.com"&&s.jsxs("button",{onClick:()=>{o("broadcast"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="broadcast"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(hu,{size:16,className:"text-amber-500"})," Broadcast Message"]}),s.jsxs("button",{onClick:()=>{o("flagged-comments"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="flagged-comments"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(bu,{size:16})," Flagged"]}),s.jsxs("button",{onClick:()=>{o("polls"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="polls"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(Ek,{size:16})," Polls & Debates"]}),s.jsxs("button",{onClick:()=>{o("pinned-board"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="pinned-board"?"bg-accent text-white shadow shadow-accent/15":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(g0,{size:16})," Pinned Board"]}),s.jsxs("button",{onClick:()=>{o("manage-posts"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="manage-posts"?"bg-accent text-white shadow shadow-accent/15":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(Yi,{size:16})," Lounge Posts"]}),s.jsxs("button",{onClick:()=>{o("custom-links"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="custom-links"?"bg-accent text-white shadow shadow-accent/15":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(wd,{size:16})," Global Menu Pages"]}),s.jsxs("button",{onClick:()=>{o("manage-podcasts"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="manage-podcasts"?"bg-accent text-white shadow shadow-accent/15":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(sc,{size:16})," Audio Podcasts"]}),s.jsxs("button",{onClick:()=>{o("feedback-inbox"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all relative",a==="feedback-inbox"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(Js,{size:16})," Feedback Inbox",hi.length>0&&s.jsx("span",{className:"absolute right-3 px-1.5 py-0.5 rounded-full text-[8px] font-black bg-red-600 text-white flex items-center justify-center",children:hi.length})]}),s.jsxs("button",{onClick:()=>{o("mega-ai-knowledge"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all relative",a==="mega-ai-knowledge"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(es,{size:16,className:"text-amber-500"})," Mega AI Knowledge",xa.filter(P=>!P.used).length>0&&s.jsx("span",{className:"absolute right-3 px-1.5 py-0.5 rounded-full text-[8px] font-black bg-amber-500 text-white flex items-center justify-center",children:xa.filter(P=>!P.used).length})]}),s.jsxs("div",{className:"pt-3 mt-3 border-t border-gray-50",children:[s.jsx("p",{className:"text-[8px] font-black text-gray-400 uppercase tracking-widest px-3 mb-1.5",children:"Ticketing"}),s.jsxs("button",{onClick:()=>{o("manage-tickets"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="manage-tickets"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(No,{size:16})," Manage Events"]}),s.jsxs("button",{onClick:()=>{o("ticket-purchases"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",a==="ticket-purchases"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(lv,{size:16})," Sales Records"]}),((Ns=(go=Ne.currentUser)==null?void 0:go.email)==null?void 0:Ns.toLowerCase())==="atwiinevictor2@gmail.com"&&s.jsxs("button",{onClick:()=>{o("imgbb-settings"),ci(!1)},className:Ge("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all mt-1",a==="imgbb-settings"?"bg-accent text-white shadow":"text-gray-500 hover:bg-gray-50"),children:[s.jsx(Nk,{size:16,className:"text-blue-500"})," API & Storage Settings"]})]})]})]}),s.jsx("div",{className:"p-6 border-t border-gray-50",children:s.jsxs("button",{onClick:()=>{ci(!1),window.dispatchEvent(new CustomEvent("setTab",{detail:"home"}))},className:"w-full flex items-center justify-center gap-2 px-3 py-2.5 bg-gray-950 text-white text-[9px] font-black uppercase tracking-widest rounded-xl hover:bg-black transition-all",children:[s.jsx(Vp,{size:12})," Back to Site"]})})]}),s.jsxs("div",{className:"lg:pl-20 min-h-screen",children:[s.jsxs("header",{className:"sticky top-0 z-30 bg-white/80 backdrop-blur-md border-b border-gray-100 px-8 py-6 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("button",{onClick:()=>ci(!0),className:"lg:hidden p-2 text-gray-500 hover:bg-gray-100 rounded-lg transition-all",title:"Open Navigation",children:s.jsx(jN,{size:20})}),s.jsx("h2",{className:"text-xl font-bold text-gray-900 tracking-tight capitalize",children:a.replace("-"," ")})]}),s.jsx("div",{className:"flex items-center gap-4",children:(Hf=Ne.currentUser)!=null&&Hf.photoURL?s.jsx("img",{src:(Xl=Ne.currentUser)==null?void 0:Xl.photoURL,className:"w-10 h-10 rounded-full object-cover shadow-lg border-2 border-accent/25 ring-2 ring-accent/10",alt:"",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"w-10 h-10 rounded-full bg-accent flex items-center justify-center text-white font-bold text-sm shadow-lg shadow-accent/20",children:((ji=(Ar=Ne.currentUser)==null?void 0:Ar.displayName)==null?void 0:ji[0])||"A"})})]}),s.jsxs("main",{className:"p-8 space-y-8",children:[ht&&s.jsxs("div",{className:"mb-6 p-4 bg-blue-900/10 border-l-4 border-black text-black text-sm font-bold flex items-center justify-between",children:[ht,s.jsx("button",{onClick:()=>Ye(null),children:s.jsx(er,{size:16})})]}),Yt&&s.jsxs("div",{className:"mb-6 p-4 bg-green-900/20 border-l-4 border-green-600 text-green-400 text-sm font-bold flex items-center justify-between",children:[t?"Operation successful!":"Submitted for review!",s.jsx("button",{onClick:()=>dt(!1),children:s.jsx(er,{size:16})})]}),a==="dashboard"&&t?s.jsxs("div",{className:"space-y-8",children:[s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-4 gap-4 lg:gap-6",children:[{label:"Total Views",value:(Ae.totalViews||0).toLocaleString(),icon:mu,color:"text-blue-600",bg:"bg-blue-50"},{label:"Total Likes",value:(Ae.totalLikes||0).toLocaleString(),icon:ku,color:"text-red-500",bg:"bg-red-50"},{label:"Articles",value:(Ae.totalArticles||c.length).toString(),icon:E0,color:"text-gray-900",bg:"bg-gray-100"},{label:"Total Posts",value:(Ae.totalPosts||0).toString(),icon:Yi,color:"text-purple-600",bg:"bg-purple-50"},{label:"Total Comments",value:(Ae.totalComments||0).toLocaleString(),icon:Yi,color:"text-emerald-600",bg:"bg-emerald-50"},{label:"Active Ads",value:(Ae.activeAds||0).toString(),icon:hu,color:"text-amber-600",bg:"bg-amber-50"},{label:"Members",value:(Ae.totalUsers||Z.length).toString(),icon:Ao,color:"text-indigo-600",bg:"bg-indigo-50"},{label:"Flagged Items",value:(Ae.flaggedCount||0).toString(),icon:bu,color:"text-rose-600",bg:"bg-rose-50",onClick:()=>o("flagged-comments")}].map((P,de)=>s.jsxs("div",{onClick:P.onClick,className:Ge("bg-white p-5 rounded-2xl border border-gray-100 shadow-sm flex items-center gap-4 transition-all hover:border-gray-200",P.onClick&&"cursor-pointer hover:shadow-md"),children:[s.jsx("div",{className:Ge("p-3 rounded-xl shrink-0",P.bg,P.color),children:s.jsx(P.icon,{size:20})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest mb-1",children:P.label}),s.jsx("p",{className:"text-xl font-black text-gray-900",children:P.value})]})]},de))}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[s.jsxs("div",{className:"lg:col-span-2 bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsx("h3",{className:"text-lg font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"Engagement Trends"}),s.jsxs("select",{className:"bg-gray-50 border border-gray-100 rounded-xl px-4 py-2 text-[10px] font-black uppercase tracking-widest text-gray-500 outline-none",children:[s.jsx("option",{children:"Last 7 Days"}),s.jsx("option",{children:"Last 30 Days"})]})]}),s.jsx("div",{className:"h-[300px] w-full relative overflow-hidden",children:s.jsx(X_e,{width:"100%",height:"100%",children:s.jsxs(_Me,{data:Ae.viewsByDay,children:[s.jsxs("defs",{children:[s.jsxs("linearGradient",{id:"colorVisitors",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"5%",stopColor:"#4F46E5",stopOpacity:.25}),s.jsx("stop",{offset:"95%",stopColor:"#4F46E5",stopOpacity:0})]}),s.jsxs("linearGradient",{id:"colorEngagement",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"5%",stopColor:"#EF4444",stopOpacity:.15}),s.jsx("stop",{offset:"95%",stopColor:"#EF4444",stopOpacity:0})]})]}),s.jsx(FJ,{strokeDasharray:"3 3",vertical:!1,stroke:"#f3f4f6"}),s.jsx(hee,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fontSize:9,fontWeight:900,fill:"#9ca3af"},dy:10}),s.jsx(fee,{axisLine:!1,tickLine:!1,tick:{fontSize:9,fontWeight:900,fill:"#9ca3af"}}),s.jsx(M3e,{contentStyle:{borderRadius:"1.25rem",border:"1px solid #f3f4f6",boxShadow:"0 20px 25px -5px rgb(0 0 0 / 0.05)",padding:"1.25rem"},labelStyle:{fontWeight:900,marginBottom:"0.5rem",textTransform:"uppercase",fontSize:"10px",color:"#111827"}}),s.jsx(MX,{verticalAlign:"top",height:36,iconType:"circle",wrapperStyle:{fontSize:"10px",fontWeight:900,textTransform:"uppercase",letterSpacing:"0.05em"}}),s.jsx($I,{name:"Daily Active Visitors",type:"monotone",dataKey:"visitors",stroke:"#4F46E5",strokeWidth:3,fillOpacity:1,fill:"url(#colorVisitors)"}),s.jsx($I,{name:"Interactive Engagement",type:"monotone",dataKey:"engagement",stroke:"#EF4444",strokeWidth:2,fillOpacity:1,fill:"url(#colorEngagement)"}),s.jsx(uee,{name:"Lounge Dispatches",dataKey:"posts",barSize:12,fill:"#8B5CF6",radius:[4,4,0,0]}),s.jsx(ZJ,{name:"Ticket Sales Run",type:"monotone",dataKey:"tickets",stroke:"#10B981",strokeWidth:2.5,dot:{r:3,strokeWidth:2}})]})})})]}),s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"bg-gray-900 p-10 rounded-[2.5rem] shadow-xl shadow-gray-200/50",children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-white mb-6",children:"Quick Actions"}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("button",{onClick:()=>o("article"),className:"flex flex-col items-center justify-center p-4 bg-white/5 hover:bg-white/10 rounded-2xl transition-all group",children:[s.jsx("div",{className:"w-10 h-10 bg-accent rounded-xl flex items-center justify-center text-white mb-3 group-hover:scale-110 transition-transform",children:s.jsx(fu,{size:20})}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-white",children:"New Article"})]}),s.jsxs("button",{onClick:()=>o("advert"),className:"flex flex-col items-center justify-center p-4 bg-white/5 hover:bg-white/10 rounded-2xl transition-all group",children:[s.jsx("div",{className:"w-10 h-10 bg-blue-600 rounded-xl flex items-center justify-center text-white mb-3 group-hover:scale-110 transition-transform",children:s.jsx(mu,{size:20})}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-white",children:"New Ad"})]}),s.jsxs("button",{onClick:async()=>{try{const de=await(await fetch("/api/notify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"Test Notification",message:"Push notifications are working!",url:window.location.origin})})).json();de.id?me.success("Notification Sent!"):me.error("Failed: "+(de.message||"Check console"))}catch{me.error("Network Error")}},className:"flex flex-col items-center justify-center p-4 bg-white/5 hover:bg-white/10 rounded-2xl transition-all group",children:[s.jsx("div",{className:"w-10 h-10 bg-orange-600 rounded-xl flex items-center justify-center text-white mb-3 group-hover:scale-110 transition-transform",children:s.jsx(Su,{size:20})}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-white",children:"Test Push"})]})]})]}),s.jsxs("div",{className:"bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsx("h3",{className:"text-lg font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"Recent Activity"}),s.jsx("button",{className:"text-[10px] font-black uppercase tracking-widest text-accent hover:underline",children:"View All"})]}),s.jsx("div",{className:"space-y-6",children:c.slice(0,5).map(P=>s.jsxs("div",{className:"flex items-center gap-4 group cursor-pointer",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl overflow-hidden bg-gray-100 flex-shrink-0",children:s.jsx("img",{src:P.featuredImageUrl||void 0,alt:"",className:"w-full h-full object-cover group-hover:scale-110 transition-transform"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[10px] font-black text-accent uppercase tracking-widest mb-0.5",children:P.category}),s.jsx("h4",{className:"text-sm font-bold text-gray-900 truncate group-hover:text-accent transition-colors",children:P.title}),s.jsxs("p",{className:"text-[10px] text-gray-400 font-medium",children:["Published ",P.publishDate instanceof jr?P.publishDate.toDate().toLocaleDateString():"Recently"]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-xs font-black text-gray-900",children:P.viewCount||0}),s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Views"})]})]},P.id))})]})]})]})]}):a==="article"&&t?s.jsxs("div",{className:"max-w-6xl mx-auto space-y-8",children:[s.jsxs("div",{className:"flex items-center justify-between bg-white p-6 rounded-3xl border border-gray-100 shadow-sm",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-xl font-black uppercase italic tracking-tight text-gray-900",children:Ii?"Edit Article":"Create New Article"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:Ii?"Update existing story":"Draft a new campus story"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("button",{onClick:()=>Yg(!Yu),className:Ge("flex items-center gap-2 px-4 py-2 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all",Yu?"bg-accent text-white shadow-lg shadow-accent/20":"bg-gray-100 text-gray-500 hover:bg-gray-200"),children:[Yu?s.jsx(Ed,{size:14}):s.jsx(Rw,{size:14}),Yu?"Edit Mode":"Preview Mode"]}),Ii&&s.jsx("button",{onClick:()=>{Lf(null),fe(""),ai(""),yi(""),ks([]),Ks(""),Cs("")},className:"text-[10px] font-black text-gray-400 uppercase tracking-widest hover:text-accent transition-all",children:"Cancel Editing"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsx("div",{className:Ge("bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm space-y-8",Yu?"hidden lg:block":"block"),children:s.jsxs("form",{onSubmit:Bm,className:"space-y-8",children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-end mb-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Article Title"}),s.jsxs("span",{className:Ge("text-[10px] font-bold tracking-widest",Me.length>90?"text-accent":"text-gray-400"),children:[Me.length,"/100"]})]}),s.jsx("input",{type:"text",value:Me,onChange:P=>fe(P.target.value.slice(0,100)),className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-bold rounded-xl",placeholder:"Enter headline..."})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Category"}),s.jsx("button",{type:"button",onClick:()=>vr(!Pn),className:"text-[9px] font-black text-accent uppercase tracking-widest hover:underline",children:Pn?"Cancel":"+ Add New"})]}),Pn?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:On,onChange:P=>Mn(P.target.value),className:"flex-1 p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 rounded-xl",placeholder:"New category..."}),s.jsx("button",{type:"button",onClick:Sm,disabled:Ct||!On.trim(),className:"px-4 bg-accent text-white font-black uppercase tracking-widest text-[10px] hover:bg-accent-700 transition-all disabled:opacity-50 rounded-xl",children:"Add"})]}):s.jsx("select",{value:na,onChange:P=>Ms(P.target.value),className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none appearance-none text-gray-900 font-bold rounded-xl",children:Le.map(P=>s.jsx("option",{value:P,children:P},P))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Author / Desk Dropdown"}),s.jsxs("select",{value:["Campus Eye Desk","Guild Media Team","Victor Atwiine","Chief Editor","Campus Reporter","Sports Desk","Student Affairs"].includes(il)?il:"Custom",onChange:P=>{P.target.value!=="Custom"&&Qa(P.target.value)},className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none appearance-none text-gray-900 font-bold rounded-xl cursor-pointer",children:[s.jsx("option",{value:"Campus Eye Desk",children:"Campus Eye Desk"}),s.jsx("option",{value:"Guild Media Team",children:"Guild Media Team"}),s.jsx("option",{value:"Victor Atwiine",children:"Victor Atwiine"}),s.jsx("option",{value:"Chief Editor",children:"Chief Editor"}),s.jsx("option",{value:"Campus Reporter",children:"Campus Reporter"}),s.jsx("option",{value:"Sports Desk",children:"Sports Desk"}),s.jsx("option",{value:"Student Affairs",children:"Student Affairs"}),s.jsx("option",{value:"Custom",children:"Custom Author Name (Enter below)..."})]}),s.jsx("input",{type:"text",value:il,onChange:P=>Qa(P.target.value),className:"w-full p-3 bg-gray-50 border border-gray-100 text-xs focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-medium rounded-xl",placeholder:"e.g. Victor Atwiine, Guild Press..."})]})]}),s.jsxs("div",{className:"flex items-center gap-3 bg-amber-500/10 p-4 border border-amber-500/25 rounded-2xl",children:[s.jsx("input",{type:"checkbox",id:"is-sponsored-ad",checked:li,onChange:P=>To(P.target.checked),className:"w-4 h-4 text-amber-500 border-gray-300 rounded focus:ring-amber-500 checked:bg-amber-500 cursor-pointer"}),s.jsx("label",{htmlFor:"is-sponsored-ad",className:"text-xs font-black text-amber-700 uppercase tracking-wider cursor-pointer select-none",children:"📢 Mark as Sponsored Ad (Enables premium yellow borders & highlights)"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-end mb-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Summary"}),s.jsxs("span",{className:Ge("text-[10px] font-bold tracking-widest",rn.length>230?"text-accent":"text-gray-400"),children:[rn.length,"/250"]})]}),s.jsx("textarea",{value:rn,onChange:P=>ai(P.target.value.slice(0,250)),className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none h-24 resize-none text-gray-900 font-medium rounded-xl",placeholder:"Brief overview..."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Content (Markdown supported)"}),s.jsx("textarea",{value:oi||"",onChange:xc,className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none h-96 resize-none text-gray-900 font-mono rounded-xl",placeholder:"The full story..."}),gi!==null&&gc.length>0&&s.jsxs("div",{className:"bg-white border border-gray-150 rounded-xl shadow-lg p-1 max-h-48 overflow-y-auto mb-2 space-y-0.5 divide-y divide-gray-50 z-50",children:[s.jsx("div",{className:"px-3 py-1 text-[9px] font-black uppercase text-gray-400 tracking-wider",children:"Mention a Peer in Article Content"}),gc.map(P=>{const de=P.username||ya(P);return s.jsxs("button",{type:"button",onClick:()=>{const De=oi.substring(0,en-gi.length-1),xt=oi.substring(en),qt=`${De}@${de} ${xt}`;yi(qt),Gi(null)},className:"w-full text-left flex items-center gap-2 px-3 py-1.5 hover:bg-neutral-50 rounded-lg transition-colors cursor-pointer",children:[s.jsx("img",{src:P.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(P.displayName||"Peer")}&background=random`,className:"w-6 h-6 rounded-full border border-gray-100 object-cover",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[11px] font-extrabold text-gray-955 truncate",children:P.displayName||"Peer"}),s.jsxs("p",{className:"text-[9px] font-mono font-bold text-blue-600 truncate",children:["@",de]})]})]},P.id)})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"External Link URL"}),s.jsx("input",{type:"url",value:Si,onChange:P=>Cs(P.target.value),className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-medium rounded-xl",placeholder:"e.g. https://forms.gle/..."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Link Button Label (Display Text)"}),s.jsxs("select",{value:["Discover More","Apply Now","Register Here","Read Full Story","Visit Portal","Book Pass","Download Document","Learn More"].includes(Is)?Is:"Custom",onChange:P=>{P.target.value!=="Custom"&&Gn(P.target.value)},className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none appearance-none text-gray-900 font-bold rounded-xl cursor-pointer mb-1.5",children:[s.jsx("option",{value:"Discover More",children:"Discover More"}),s.jsx("option",{value:"Apply Now",children:"Apply Now"}),s.jsx("option",{value:"Register Here",children:"Register Here"}),s.jsx("option",{value:"Read Full Story",children:"Read Full Story"}),s.jsx("option",{value:"Visit Portal",children:"Visit Portal"}),s.jsx("option",{value:"Book Pass",children:"Book Pass"}),s.jsx("option",{value:"Download Document",children:"Download Document"}),s.jsx("option",{value:"Learn More",children:"Learn More"}),s.jsx("option",{value:"Custom",children:"Custom Label (Enter below)..."})]}),s.jsx("input",{type:"text",value:Is,onChange:P=>Gn(P.target.value),className:"w-full p-3 bg-gray-50 border border-gray-100 text-xs focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-medium rounded-xl",placeholder:"Type custom button text..."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Video Embed/URL (Optional)"}),s.jsx("input",{type:"url",value:Nl,onChange:P=>Ks(P.target.value),className:"w-full p-4 bg-gray-50 border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-medium rounded-xl",placeholder:"e.g. https://youtube.com/..."})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("label",{className:"text-xs font-black text-gray-405 uppercase tracking-widest block",children:"Article Images (Direct Upload & Link-saving)"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[{label:"Cover Image / Primary",state:Sl,setState:oh,loading:rd,setLoading:id},{label:"Optional Second Image",state:Ju,setState:lh,loading:Lm,setLoading:Ff},{label:"Optional Third Image",state:wc,setState:rl,loading:Um,setLoading:yb}].map((P,de)=>s.jsxs("div",{className:"bg-gray-50 border border-gray-100 p-4 rounded-2xl flex flex-col justify-between space-y-3",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-gray-400 block mb-2",children:P.label}),P.state?s.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden border border-gray-100 bg-white group mb-3 shadow-inner",children:[s.jsx("img",{src:P.state,className:"w-full h-full object-cover transition-transform group-hover:scale-105",alt:"",referrerPolicy:"no-referrer"}),s.jsx("button",{type:"button",onClick:()=>P.setState(""),className:"absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center text-white",title:"Remove image",children:s.jsx(er,{size:20,className:"stroke-[3px]"})})]}):s.jsxs("label",{className:"flex flex-col items-center justify-center aspect-video rounded-xl border-2 border-dashed border-gray-200 cursor-pointer hover:border-accent hover:bg-white transition-all mb-3 text-gray-400 hover:text-accent",children:[P.loading?s.jsx(Pr,{className:"animate-spin text-accent",size:24}):s.jsxs(s.Fragment,{children:[s.jsx(fu,{size:24,className:"stroke-[3px]"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest mt-1",children:"Upload JPEG/PNG"})]}),s.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:P.loading,onChange:De=>{var qt;const xt=(qt=De.target.files)==null?void 0:qt[0];xt&&Ac(xt,P.setState,P.setLoading)}})]})]}),s.jsx("input",{type:"text",value:P.state,onChange:De=>P.setState(De.target.value),placeholder:"Or paste asset link directly...",className:"w-full px-3 py-2 bg-white border border-gray-100 text-[10px] text-gray-700 font-mono rounded-lg outline-none focus:border-accent"})]},de))})]})]}),s.jsxs("div",{className:"border-t border-gray-150 pt-8 mt-8 space-y-6",children:[s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-red-600 flex items-center gap-2",children:[s.jsx(pl,{size:16}),s.jsx("span",{children:"Advanced Fields & Analytics (Admin Control)"})]}),s.jsx("p",{className:"text-[10px] text-gray-400 font-semibold uppercase tracking-wider -mt-4",children:"Directly override any metadata, counts, author info, or status."}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 bg-gray-50/50 p-6 border border-gray-100/80 rounded-2xl text-left",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Author Name (Select or Type)"}),s.jsxs("div",{className:"flex gap-2",children:[Z&&Z.length>0&&s.jsxs("select",{onChange:P=>{if(P.target.value){Qa(P.target.value);const de=Z.find(De=>(De.displayName||De.email)===P.target.value);de&&de.photoURL&&ed(de.photoURL)}},className:"p-3 bg-white border border-gray-100 text-xs font-bold rounded-xl outline-none text-gray-800",children:[s.jsx("option",{value:"",children:"Select Author..."}),Z.map(P=>s.jsx("option",{value:P.displayName||P.email||"User",children:P.displayName||P.email||"User"},P.id))]}),s.jsx("input",{type:"text",value:il,onChange:P=>Qa(P.target.value),className:"flex-1 p-3 bg-white border border-gray-100 text-xs focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-bold rounded-xl",placeholder:"Reporter / Team name"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Author Profile Photo URL"}),s.jsx("input",{type:"text",value:Cm,onChange:P=>ed(P.target.value),className:"w-full p-3 bg-white border border-gray-100 text-xs focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-medium rounded-xl",placeholder:"Avatar image URL"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 bg-gray-50/50 p-6 border border-gray-100/80 rounded-2xl text-left",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"CTA Action Button Text"}),s.jsx("input",{type:"text",value:Is,onChange:P=>Gn(P.target.value),placeholder:"Discover More",className:"w-full p-3 bg-white border border-gray-100 text-xs focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-bold rounded-xl"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"CTA Action Target URL (Optional)"}),s.jsx("input",{type:"url",value:Ls,onChange:P=>Yn(P.target.value),placeholder:"https://... (Leave blank for standard view)",className:"w-full p-3 bg-white border border-gray-100 text-xs focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-bold rounded-xl"})]})]}),s.jsxs("div",{className:"bg-gray-50/50 p-6 border border-gray-100/80 rounded-2xl space-y-4 text-left",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest block",children:"Engagement Counts Override"}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Views"}),s.jsx("input",{type:"number",value:Jc,onChange:P=>Zs(Number(P.target.value)),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-900 font-black rounded-xl text-center"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Likes"}),s.jsx("input",{type:"number",value:zf,onChange:P=>Im(Number(P.target.value)),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-900 font-black rounded-xl text-center"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Comments"}),s.jsx("input",{type:"number",value:mb,onChange:P=>Xg(Number(P.target.value)),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-900 font-black rounded-xl text-center"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Saves"}),s.jsx("input",{type:"number",value:gb,onChange:P=>ws(Number(P.target.value)),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-900 font-black rounded-xl text-center"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Shares"}),s.jsx("input",{type:"number",value:jm,onChange:P=>nd(Number(P.target.value)),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-900 font-black rounded-xl text-center"})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 bg-gray-50/50 p-6 border border-gray-100/80 rounded-2xl text-left",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Publish Status"}),s.jsxs("select",{value:ch,onChange:P=>Vf(P.target.value),className:"w-full p-4 bg-white border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-bold rounded-xl",children:[s.jsx("option",{value:"published",children:"Published"}),s.jsx("option",{value:"draft",children:"Draft"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Publish Date/Time"}),s.jsx("input",{type:"datetime-local",value:Zc,onChange:P=>td(P.target.value),className:"w-full p-4 bg-white border border-gray-100 text-sm focus:ring-2 focus:ring-accent/20 transition-all outline-none text-gray-900 font-bold rounded-xl"}),s.jsx("p",{className:"text-[9px] text-gray-400 font-medium",children:"Leave blank to use current time or preserve original date."})]})]}),s.jsxs("div",{className:"bg-gray-50/50 p-6 border border-gray-100/80 rounded-2xl space-y-4 text-left",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest block",children:"Manual Image URL Overrides (Alternative to upload)"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Featured Image URL (Primary)"}),s.jsx("input",{type:"text",value:Sl,onChange:P=>oh(P.target.value),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-905 w-full rounded-xl",placeholder:"Paste primary image web URL"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Second Image URL"}),s.jsx("input",{type:"text",value:Ju,onChange:P=>lh(P.target.value),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-905 w-full rounded-xl",placeholder:"Paste second image web URL"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-wider",children:"Third Image URL"}),s.jsx("input",{type:"text",value:wc,onChange:P=>rl(P.target.value),className:"w-full p-3 bg-white border border-gray-100 text-xs text-gray-905 w-full rounded-xl",placeholder:"Paste third image web URL"})]})]})]})]}),s.jsxs("button",{type:"submit",disabled:Ct,className:"w-full py-5 bg-accent text-white font-black uppercase tracking-widest hover:bg-accent-700 transition-all disabled:opacity-50 flex items-center justify-center gap-2 shadow-xl shadow-accent/20 rounded-2xl text-[11px]",children:[Ct?s.jsx(Pr,{className:"animate-spin"}):Ii?s.jsx(Q6,{size:18}):s.jsx(fl,{size:18}),Ct?Ii?"Updating...":"Publishing...":Ii?"Update Article":"Publish Article"]})]})}),s.jsxs("div",{className:Ge("bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm space-y-8 overflow-y-auto max-h-[1000px] custom-scrollbar",Yu?"block lg:block":"hidden lg:block"),children:[s.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[s.jsx(Rw,{size:16,className:"text-accent"}),s.jsx("h4",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Live Preview"})]}),s.jsxs("div",{className:"prose prose-blue max-w-none",children:[Pa.length>0?s.jsx("img",{src:URL.createObjectURL(Pa[0]),alt:"Preview",className:"w-full aspect-video object-cover rounded-3xl mb-8 shadow-xl"}):Ii!=null&&Ii.featuredImageUrl?s.jsx("img",{src:Ii.featuredImageUrl,alt:"Preview",className:"w-full aspect-video object-cover rounded-3xl mb-8 shadow-xl"}):s.jsxs("div",{className:"w-full aspect-video bg-gray-50 rounded-3xl mb-8 flex flex-col items-center justify-center text-gray-300 border-2 border-dashed border-gray-100",children:[s.jsx(Bh,{size:48}),s.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest mt-4",children:"No image uploaded"})]}),s.jsxs("div",{className:"space-y-4 mb-8",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"px-3 py-1 bg-accent text-white text-[10px] font-black uppercase tracking-widest rounded-full",children:na}),s.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:new Date().toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})})]}),s.jsx("h1",{className:"text-4xl font-sans font-black uppercase tracking-tight leading-[0.9] text-gray-900",children:Me||"Your Headline Here"}),s.jsx("p",{className:"text-lg font-sans text-gray-500 leading-relaxed border-l-4 border-accent pl-6",children:rn||"The summary will appear here..."})]}),s.jsx("div",{className:"markdown-body text-gray-700 leading-relaxed font-sans text-base",children:s.jsx(O1,{children:oi||"*Start writing your story to see the preview...*"})})]})]})]})]}):a==="manage-articles"&&t?s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6 bg-white p-6 rounded-3xl border border-gray-100 shadow-sm",children:[s.jsx("div",{className:"relative flex-1 max-w-2xl group",children:s.jsxs("div",{className:"flex items-center bg-gray-50 hover:bg-gray-100 focus-within:bg-white focus-within:ring-2 focus-within:ring-accent/20 border-2 border-transparent focus-within:border-accent transition-all px-6 py-3 rounded-2xl",children:[s.jsx(Ip,{size:20,className:"text-gray-400 group-focus-within:text-accent transition-colors"}),s.jsx("input",{type:"text",placeholder:"Search articles by title, category, or author...",value:sh,onChange:P=>Lo(P.target.value),className:"bg-transparent border-none outline-none pl-4 text-sm font-bold text-gray-900 w-full placeholder-gray-400"}),sh&&s.jsx("button",{onClick:()=>Lo(""),className:"p-1 text-gray-400 hover:text-accent transition-colors",children:s.jsx(er,{size:18})})]})}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"flex bg-gray-100 p-1 rounded-xl",children:["all","published","draft"].map(P=>s.jsx("button",{onClick:()=>ah(P),className:`px-4 py-2 rounded-lg text-[10px] font-black uppercase tracking-widest transition-all ${Xc===P?"bg-white text-accent shadow-sm":"text-gray-500 hover:text-gray-900"}`,children:P},P))}),s.jsxs("button",{onClick:()=>o("article"),className:"flex items-center gap-2 bg-black text-white px-6 py-3 rounded-2xl font-black uppercase tracking-widest text-[10px] hover:bg-accent transition-all shadow-lg shadow-black/10",children:[s.jsx(fu,{size:16})," New Article"]})]})]}),s.jsx("div",{className:"grid grid-cols-1 gap-6",children:c.filter(P=>{const de=P.title.toLowerCase().includes(sh.toLowerCase())||P.category.toLowerCase().includes(sh.toLowerCase())||P.authorName.toLowerCase().includes(sh.toLowerCase()),De=Xc==="all"||P.status===Xc;return de&&De}).map(P=>{const de=km===P.id,De=tl===P.id;return s.jsxs("div",{className:Ge("bg-white rounded-[2rem] border overflow-hidden transition-all duration-300 shadow-sm hover:shadow-md",de?"border-accent/30 ring-4 ring-accent/5 animate-fadeIn":"border-gray-100 hover:border-gray-200"),children:[s.jsxs("div",{onClick:()=>Uf(de?null:P.id),className:"p-6 flex flex-col md:flex-row items-start md:items-center gap-6 cursor-pointer select-none",children:[s.jsxs("div",{className:"w-full md:w-40 aspect-video rounded-2xl overflow-hidden bg-gray-100 flex-shrink-0 relative group",children:[s.jsx("img",{src:P.featuredImageUrl||void 0,alt:"",className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"}),P.status==="draft"&&s.jsx("div",{className:"absolute top-2 left-2 bg-amber-500 text-white font-black uppercase text-[8px] tracking-widest px-2 py-0.5 rounded shadow-sm",children:"Draft"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[s.jsx("span",{className:"px-2.5 py-0.5 bg-blue-50 text-accent text-[9px] font-black uppercase tracking-widest rounded-lg",children:P.category}),s.jsx("span",{className:Ge("px-2.5 py-0.5 text-[9px] font-black uppercase tracking-widest rounded-lg border",P.status==="draft"?"bg-amber-50 text-amber-600 border-amber-100":"bg-emerald-50 text-emerald-600 border-emerald-100"),children:P.status||"published"}),s.jsxs("span",{className:"text-[10px] font-bold text-gray-400 flex items-center gap-1",children:[s.jsx(G6,{size:10}),P.publishDate instanceof jr?P.publishDate.toDate().toLocaleDateString():"Just now"]})]}),s.jsx("h4",{className:"text-base sm:text-lg font-black text-gray-900 uppercase tracking-tight line-clamp-2 md:line-clamp-1",children:P.title}),s.jsxs("div",{className:"flex flex-wrap items-center gap-4 mt-3",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10px] font-black text-gray-400 uppercase tracking-widest flex items-center gap-1",children:[s.jsx(mu,{size:12,className:"text-accent"}),P.viewCount||0," Views"]}),s.jsxs("div",{className:"flex items-center gap-1 text-[10px] font-black text-gray-400 uppercase tracking-widest flex items-center gap-1",children:[s.jsx(Xh,{size:12,className:"text-green-500"}),P.likeCount||0," Likes"]}),s.jsxs("div",{className:"flex items-center gap-1 text-[10px] font-black text-[#9c0dec] uppercase tracking-widest flex items-center gap-1",children:[s.jsx(Yi,{size:12}),P.commentCount||0," Comments"]})]})]}),s.jsx("div",{className:"self-end md:self-center flex items-center gap-2 mt-4 md:mt-0",children:s.jsx("div",{className:"p-2.5 rounded-full bg-gray-50 text-gray-400 hover:text-accent hover:bg-blue-50 transition-colors",children:de?s.jsx(uf,{size:20}):s.jsx(Md,{size:20})})})]}),de&&s.jsxs("div",{className:"px-6 pb-6 border-t border-gray-50 bg-gray-50/25 space-y-5",children:[s.jsxs("div",{className:"pt-5 flex flex-wrap items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[P.authorProfile?s.jsx("img",{src:P.authorProfile,alt:P.authorName,className:"w-8 h-8 rounded-full object-cover ring-2 ring-gray-100"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-accent/10 text-accent flex items-center justify-center font-black text-xs uppercase",children:P.authorName?P.authorName.charAt(0):"A"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-black text-gray-800 uppercase tracking-tight",children:P.authorName||"Anonymous"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-wider",children:"Reporter / Author"})]})]}),s.jsxs("div",{className:"flex items-center gap-3 bg-white px-4 py-2 rounded-2xl border border-gray-100 shadow-xs",children:[s.jsxs("div",{className:"text-center px-2",children:[s.jsx("p",{className:"text-xs font-black text-gray-900",children:P.saveCount||0}),s.jsx("p",{className:"text-[8px] font-black text-gray-400 uppercase tracking-widest",children:"Saves"})]}),s.jsx("div",{className:"w-[1px] h-6 bg-gray-150"}),s.jsxs("div",{className:"text-center px-2",children:[s.jsx("p",{className:"text-xs font-black text-gray-900",children:P.shareCount||0}),s.jsx("p",{className:"text-[8px] font-black text-gray-400 uppercase tracking-widest",children:"Shares"})]})]})]}),P.summary&&s.jsxs("div",{className:"bg-yellow-50/45 border-l-4 border-accent p-4 rounded-r-2xl",children:[s.jsx("p",{className:"text-[9px] font-black text-accent uppercase tracking-widest mb-1",children:"Dispatch Summary"}),s.jsxs("p",{className:"text-xs font-bold text-gray-600 leading-relaxed italic",children:['"',P.summary,'"']})]}),s.jsxs("div",{className:"space-y-3 bg-white p-5 rounded-2xl border border-gray-100 shadow-xs",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Story Content Preview"}),s.jsx("button",{onClick:xt=>{xt.stopPropagation(),nl(De?null:P.id)},className:"text-[10px] bg-gray-50 hover:bg-accent hover:text-white text-gray-600 font-black uppercase tracking-widest px-3 py-1.5 rounded-xl border border-gray-100 transition-all flex items-center gap-1",children:De?"View Less Text":"View Full Text (All)"})]}),s.jsxs("div",{className:Ge("markdown-body text-sm leading-relaxed text-gray-750 overflow-hidden transition-all duration-300 relative",De?"max-h-none":"max-h-24"),children:[s.jsx(O1,{children:P.content||"*No written content in this article.*"}),!De&&P.content&&P.content.length>150&&s.jsx("div",{className:"absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-white to-transparent pointer-events-none"})]})]}),(P.featuredImageUrl1||P.featuredImageUrl2||P.video||P.Links)&&s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(P.featuredImageUrl1||P.featuredImageUrl2)&&s.jsxs("div",{className:"bg-white p-4 rounded-2xl border border-gray-100 space-y-2",children:[s.jsx("span",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"Gallery Media Uploads"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[P.featuredImageUrl1&&s.jsx("div",{className:"aspect-video rounded-xl overflow-hidden bg-gray-50 border border-gray-100",children:s.jsx("img",{src:P.featuredImageUrl1,alt:"",className:"w-full h-full object-cover"})}),P.featuredImageUrl2&&s.jsx("div",{className:"aspect-video rounded-xl overflow-hidden bg-gray-50 border border-gray-100",children:s.jsx("img",{src:P.featuredImageUrl2,alt:"",className:"w-full h-full object-cover"})})]})]}),(P.video||P.Links)&&s.jsxs("div",{className:"bg-white p-4 rounded-2xl border border-gray-100 space-y-2",children:[s.jsx("span",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1 text-[#9c0dec]",children:"Attached Links & Video"}),s.jsxs("div",{className:"space-y-1.5 text-xs font-semibold text-gray-600",children:[P.video&&s.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[s.jsx(Aa,{size:12,className:"text-red-500"}),s.jsx("span",{className:"text-[10px] font-black text-gray-400 uppercase tracking-wider",children:"Video:"}),s.jsx("a",{href:P.video,target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent underline truncate",children:P.video})]}),P.Links&&s.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[s.jsx(wd,{size:12,className:"text-blue-500"}),s.jsx("span",{className:"text-[10px] font-black text-gray-400 uppercase tracking-wider",children:"Resources:"}),s.jsx("a",{href:P.Links,target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent underline truncate",children:P.Links})]})]})]})]}),s.jsxs("div",{className:"pt-4 flex items-center justify-end gap-3 border-t border-gray-100",children:[s.jsxs("button",{onClick:xt=>{xt.stopPropagation(),Nb(P)},className:"flex items-center gap-2 px-5 py-2.5 bg-accent hover:bg-opacity-95 text-white rounded-xl font-black uppercase tracking-widest text-[10px] transition-all shadow-md shadow-accent/15 hover:-translate-y-0.5",children:[s.jsx(Ed,{size:14})," Edit Mode"]}),s.jsxs("button",{onClick:xt=>{xt.stopPropagation(),yc(P.id)},className:"flex items-center gap-2 px-5 py-2.5 bg-red-50 text-red-600 hover:bg-red-600 hover:text-white rounded-xl font-black uppercase tracking-widest text-[10px] transition-all",children:[s.jsx(As,{size:14})," Delete"]})]})]})]},P.id)})})]}):a==="advert"?s.jsxs("div",{className:"max-w-2xl mx-auto bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsxs("div",{className:"text-center mb-10",children:[s.jsx("h3",{className:"text-2xl font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"Promote Your Brand"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-[0.3em] mt-2",children:"Reach thousands of campus citizens daily"})]}),s.jsxs("form",{onSubmit:Eb,className:"space-y-8",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Campaign Title"}),s.jsx("input",{type:"text",required:!0,value:zr,onChange:P=>Ka(P.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold text-gray-900 focus:bg-white focus:ring-4 focus:ring-accent/10 focus:border-accent transition-all",placeholder:"e.g. Summer Festival 2024"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Advert Type"}),s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("button",{type:"button",onClick:()=>Ys("image"),className:Ge("flex-1 py-4 rounded-2xl border text-[10px] font-black uppercase tracking-widest transition-all gap-2 flex items-center justify-center",Vr==="image"?"bg-accent text-white border-accent shadow-lg shadow-accent/20":"bg-gray-50 text-gray-400 border-gray-100 hover:bg-white"),children:[s.jsx(Bh,{size:16})," Image"]}),s.jsxs("button",{type:"button",onClick:()=>Ys("video"),className:Ge("flex-1 py-4 rounded-2xl border text-[10px] font-black uppercase tracking-widest transition-all gap-2 flex items-center justify-center",Vr==="video"?"bg-accent text-white border-accent shadow-lg shadow-accent/20":"bg-gray-50 text-gray-400 border-gray-100 hover:bg-white"),children:[s.jsx(Aa,{size:16})," Motion"]})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Duration"}),s.jsxs("select",{value:bi,onChange:P=>co(P.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold text-gray-900 focus:bg-white focus:ring-4 focus:ring-accent/10 focus:border-accent transition-all appearance-none",children:[s.jsx("option",{value:"7",children:"7 Days (Standard)"}),s.jsx("option",{value:"14",children:"14 Days (Premium)"}),s.jsx("option",{value:"30",children:"30 Days (Professional)"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Target Link"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"url",required:!0,value:Us,onChange:P=>Qo(P.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold text-gray-900 focus:bg-white focus:ring-4 focus:ring-accent/10 focus:border-accent transition-all pl-12",placeholder:"https://your-site.com"}),s.jsx(wd,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400",size:18})]})]})]}),Vr==="image"?s.jsxs("div",{className:"space-y-4",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Advert Banner (Instant Uploaded)"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"md:col-span-2 relative group",children:[s.jsx("input",{type:"file",accept:"image/*",onChange:P=>{var De;const de=(De=P.target.files)==null?void 0:De[0];de&&(pa(de),Ac(de,od,bb))},className:"hidden",id:"advert-image"}),s.jsx("label",{htmlFor:"advert-image",className:Ge("flex flex-col items-center justify-center aspect-[21/9] rounded-2xl border-2 border-dashed transition-all cursor-pointer bg-gray-50",Uo?"border-accent":"border-gray-100 hover:border-accent hover:bg-white"),children:sd?s.jsxs("div",{className:"text-center p-4",children:[s.jsx(Pr,{className:"mx-auto text-accent mb-2 animate-spin",size:32}),s.jsx("p",{className:"text-[10px] font-black text-accent uppercase tracking-widest leading-none",children:"Uploading image..."})]}):Uo?s.jsxs("div",{className:"w-full h-full relative rounded-2xl overflow-hidden group",children:[s.jsx("img",{src:Uo,className:"w-full h-full object-cover",alt:"Advert Campaign",referrerPolicy:"no-referrer"}),s.jsx("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center text-white",children:s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest",children:"Change Banner Image"})})]}):s.jsxs(s.Fragment,{children:[s.jsx(Bh,{className:"text-gray-400 mb-2",size:32}),s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Select Image (21:9 Recommended)"})]})})]}),s.jsxs("div",{className:"bg-gray-50 border border-gray-100 p-4 rounded-2xl flex flex-col justify-center space-y-2",children:[s.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest text-gray-450 block",children:"Direct Banner Link"}),s.jsx("input",{type:"text",value:Uo,onChange:P=>od(P.target.value),placeholder:"Or paste banner image URL...",className:"w-full px-3 py-2 bg-white border border-gray-100 text-[10px] text-gray-700 font-mono rounded-lg outline-none focus:border-accent"}),s.jsx("p",{className:"text-[8px] text-gray-400 font-bold uppercase tracking-wider leading-tight",children:"Your campaigns will save and render this URL instantly across the platform."})]})]})]}):s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Video Link (Direct MP4/Link)"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"url",required:Vr==="video",value:bs,onChange:P=>ma(P.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold text-gray-900 focus:bg-white focus:ring-4 focus:ring-accent/10 focus:border-accent transition-all pl-12",placeholder:"https://example.com/ad.mp4"}),s.jsx(Aa,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400",size:18})]}),s.jsx("p",{className:"px-4 text-[9px] font-bold text-gray-400 uppercase tracking-widest",children:"Ensure the link is a direct video file or an embeddable URL."})]}),s.jsx("div",{className:"p-6 bg-gray-50 rounded-2xl border border-gray-100",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(tF,{className:"text-accent flex-shrink-0",size:20}),s.jsx("p",{className:"text-[10px] font-bold text-gray-500 uppercase leading-relaxed",children:"Your advert will be reviewed by our team before going live. This usually takes less than 24 hours."})]})}),s.jsx("button",{type:"submit",disabled:Ct,className:"w-full py-5 bg-accent text-white rounded-2xl text-sm font-black uppercase tracking-[0.2em] hover:bg-accent-700 transition-all shadow-xl shadow-accent/20 disabled:opacity-50 flex items-center justify-center gap-3",children:Ct?s.jsxs(s.Fragment,{children:[s.jsx(Pr,{className:"animate-spin",size:20}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(fl,{size:20}),"Submit for Review"]})})]})]}):a==="manage-ads"&&t?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"Advert Management"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{className:"px-4 py-2 bg-accent text-white rounded-xl text-[10px] font-black uppercase tracking-widest shadow-lg shadow-accent/20",children:"Pending Review"}),s.jsx("button",{className:"px-4 py-2 bg-white border border-gray-100 rounded-xl text-[10px] font-black uppercase tracking-widest text-gray-500 hover:bg-gray-50 transition-all",children:"Active"})]})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:sn.map(P=>s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-sm hover:shadow-md transition-all flex flex-col gap-4",children:[s.jsx("div",{className:"aspect-[21/9] rounded-2xl overflow-hidden bg-gray-100",children:s.jsx("img",{src:P.imageUrl||void 0,alt:"",className:"w-full h-full object-cover"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:Ge("px-2 py-0.5 text-[9px] font-black uppercase tracking-widest rounded",P.status==="active"?"bg-green-50 text-green-600":"bg-blue-50 text-accent"),children:P.status}),s.jsxs("span",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:[P.durationDays," Days"]})]}),s.jsx("h4",{className:"text-lg font-black text-gray-900 uppercase tracking-tight truncate",children:P.title}),s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest truncate mt-1",children:P.link})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-4 border-t border-gray-50",children:[s.jsx("button",{onClick:()=>ex(P.id,P.status),className:Ge("flex-1 py-3 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all",P.status==="active"?"bg-gray-100 text-gray-900 hover:bg-gray-200":"bg-green-600 text-white hover:bg-green-700"),children:P.status==="active"?"Deactivate":"Approve & Activate"}),s.jsx("button",{onClick:()=>db(P.id),className:"p-3 bg-blue-50 text-black rounded-xl hover:bg-black hover:text-white transition-all",children:s.jsx(As,{size:18})})]})]},P.id))})]}):a==="flagged-comments"&&t?s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-4",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:[s.jsx(bu,{className:"text-rose-500",size:22})," Flagged Content Moderation Hub"]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Review and moderate flagged comments and lounge dispatches"})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs("span",{className:"px-3 py-1 bg-rose-50 text-rose-600 border border-rose-100 rounded-full text-[10px] font-black uppercase tracking-widest",children:[z.length+rs.length," Total Flagged"]})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("h4",{className:"text-sm font-black text-gray-900 uppercase tracking-wider flex items-center gap-2",children:[s.jsx(Yi,{size:16,className:"text-accent"})," Flagged Comments (",z.length,")"]}),z.length===0?s.jsx("div",{className:"bg-white p-8 rounded-2xl border border-gray-100 text-center text-xs text-gray-400 font-bold uppercase tracking-wider",children:"No flagged comments awaiting moderation"}):s.jsx("div",{className:"grid grid-cols-1 gap-4",children:z.map(P=>s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-sm hover:shadow-md transition-all",children:[s.jsxs("div",{className:"flex items-start gap-4 mb-4",children:[s.jsx("img",{src:P.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(P.authorName)}&background=random`,alt:"",className:"w-10 h-10 rounded-xl object-cover"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("h4",{className:"font-black text-gray-900 uppercase tracking-tight",children:P.authorName}),s.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:P.createdAt instanceof jr?P.createdAt.toDate().toLocaleString():"Recently"})]}),s.jsxs("p",{className:"text-sm text-gray-600 font-medium bg-gray-50 p-4 rounded-2xl border border-gray-100 italic",children:['"',P.content,'"']})]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-50",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Yi,{size:14,className:"text-gray-400"}),s.jsxs("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:["On: ",s.jsx("span",{className:"text-accent",children:P.articleTitle||"Article Comment"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>P.articleId&&_m(P.articleId,P.id),className:"px-3 py-2 bg-emerald-50 hover:bg-emerald-500 text-emerald-600 hover:text-white rounded-xl transition-all text-xs font-bold uppercase tracking-wider flex items-center gap-1 cursor-pointer",title:"Dismiss Flag",children:[s.jsx(Pu,{size:14})," Dismiss Flag"]}),s.jsxs("button",{onClick:()=>P.articleId&&ub(P.articleId,P.id),className:"px-3 py-2 bg-red-50 hover:bg-red-600 text-red-600 hover:text-white rounded-xl transition-all text-xs font-bold uppercase tracking-wider flex items-center gap-1 cursor-pointer",title:"Delete Comment",children:[s.jsx(As,{size:14})," Delete"]})]})]})]},P.id))})]}),s.jsxs("div",{className:"space-y-4 pt-6 border-t border-gray-100",children:[s.jsxs("h4",{className:"text-sm font-black text-gray-900 uppercase tracking-wider flex items-center gap-2",children:[s.jsx(E0,{size:16,className:"text-purple-600"})," Flagged Lounge Dispatches (",rs.length,")"]}),rs.length===0?s.jsx("div",{className:"bg-white p-8 rounded-2xl border border-gray-100 text-center text-xs text-gray-400 font-bold uppercase tracking-wider",children:"No flagged posts awaiting moderation"}):s.jsx("div",{className:"grid grid-cols-1 gap-4",children:rs.map(P=>s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-sm hover:shadow-md transition-all",children:[s.jsxs("div",{className:"flex items-start gap-4 mb-4",children:[s.jsx("img",{src:P.authorPhoto||P.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(P.authorName||"Student")}&background=random`,alt:"",className:"w-10 h-10 rounded-xl object-cover"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("h4",{className:"font-black text-gray-900 uppercase tracking-tight",children:P.authorName||"Anonymous Student"}),s.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:P.createdAt instanceof jr?P.createdAt.toDate().toLocaleString():"Recently"})]}),s.jsx("p",{className:"text-sm text-gray-800 font-medium bg-gray-50 p-4 rounded-2xl border border-gray-100 whitespace-pre-wrap",children:P.content}),P.imageUrl&&s.jsx("img",{src:P.imageUrl,alt:"",className:"mt-3 rounded-2xl max-h-48 object-cover border border-gray-100"})]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-50",children:[s.jsx("span",{className:"text-[10px] font-black text-rose-500 uppercase tracking-widest",children:"Reported Content"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>ih(P.id),className:"px-3 py-2 bg-emerald-50 hover:bg-emerald-500 text-emerald-600 hover:text-white rounded-xl transition-all text-xs font-bold uppercase tracking-wider flex items-center gap-1 cursor-pointer",children:[s.jsx(Pu,{size:14})," Dismiss Flag"]}),s.jsxs("button",{onClick:()=>dA(P.id),className:"px-3 py-2 bg-red-50 hover:bg-red-600 text-red-600 hover:text-white rounded-xl transition-all text-xs font-bold uppercase tracking-wider flex items-center gap-1 cursor-pointer",children:[s.jsx(As,{size:14})," Delete Post"]})]})]})]},P.id))})]})]}):a==="imgbb-settings"&&t?s.jsxs("div",{className:"space-y-8 max-w-4xl",children:[s.jsx("div",{className:"border-b border-gray-100 pb-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-3 bg-blue-50 text-blue-600 rounded-2xl border border-blue-100",children:s.jsx(kre,{size:24})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:"ImgBB API Key Settings"}),s.jsxs("p",{className:"text-xs text-gray-500 font-medium",children:["Admin Access (",s.jsx("span",{className:"text-accent font-bold",children:"Image Hosting Credentials"}),")"]})]})]})}),s.jsxs("div",{className:"bg-gradient-to-r from-gray-900 to-black text-white p-6 rounded-3xl border border-gray-800 shadow-xl space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase tracking-widest text-emerald-400 flex items-center gap-1.5",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 inline-block"})," Active ImgBB API Key"]}),s.jsxs("button",{onClick:()=>{navigator.clipboard.writeText(yt),me.success("ImgBB API key copied to clipboard!")},className:"px-3 py-1 bg-white/10 hover:bg-white/20 text-white rounded-xl text-[10px] font-black uppercase tracking-widest flex items-center gap-1 transition-all",children:[s.jsx(Pw,{size:12})," Copy Key"]})]}),s.jsx("div",{className:"font-mono text-sm md:text-base font-bold bg-white/5 p-4 rounded-2xl border border-white/10 break-all text-emerald-300",children:yt})]}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-sm space-y-4",children:[s.jsxs("h4",{className:"text-sm font-black text-gray-900 uppercase tracking-wider flex items-center gap-2",children:[s.jsx(fu,{size:16,className:"text-accent"})," Add & Activate New ImgBB API Key"]}),s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[s.jsx("input",{type:"text",value:_r,onChange:P=>xi(P.target.value),placeholder:"Paste new ImgBB API key here (e.g. 857eaaf2b7571ee437db8ee3f6ee8670)...",className:"flex-1 bg-gray-50 border border-gray-200 rounded-2xl px-4 py-3 text-xs font-mono text-gray-900 outline-none focus:border-accent"}),s.jsx("button",{onClick:async()=>{var De;if(!_r.trim()){me.error("Please enter an API key");return}const P=_r.trim(),de=Array.from(new Set([P,...Pt]));Sn(de),cn(P),localStorage.setItem("campus_eye_imgbb_active_key",P);try{await Hr(ot(pe,"settings","imgbb"),{activeKey:P,savedKeys:de,updatedAt:Bn(),updatedBy:(De=Ne.currentUser)==null?void 0:De.email},{merge:!0})}catch(xt){console.error("Firestore update error:",xt)}xi(""),me.success("New ImgBB API key saved & activated!")},className:"px-6 py-3 bg-accent text-white rounded-2xl text-xs font-black uppercase tracking-widest hover:bg-accent/90 transition-all shrink-0 cursor-pointer",children:"Save & Activate Key"})]})]}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-sm space-y-4",children:[s.jsxs("h4",{className:"text-sm font-black text-gray-900 uppercase tracking-wider",children:["Saved API Keys Pool (",Pt.length,")"]}),s.jsx("div",{className:"space-y-3",children:Pt.map((P,de)=>{const De=P===yt;return s.jsxs("div",{className:Ge("p-4 rounded-2xl border flex items-center justify-between gap-4 transition-all",De?"bg-emerald-50/50 border-emerald-200":"bg-gray-50 border-gray-100"),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("input",{type:"radio",name:"active_imgbb_key",checked:De,onChange:()=>{var xt;cn(P),localStorage.setItem("campus_eye_imgbb_active_key",P),Hr(ot(pe,"settings","imgbb"),{activeKey:P,savedKeys:Pt,updatedAt:Bn(),updatedBy:(xt=Ne.currentUser)==null?void 0:xt.email},{merge:!0}),me.success("Switched active ImgBB key!")},className:"w-4 h-4 text-accent cursor-pointer"}),s.jsx("span",{className:"font-mono text-xs font-bold text-gray-800 truncate",children:P}),De&&s.jsx("span",{className:"px-2 py-0.5 bg-emerald-500 text-white text-[9px] font-black uppercase tracking-widest rounded-full shrink-0",children:"Active"})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[!De&&s.jsx("button",{onClick:()=>{var xt;cn(P),localStorage.setItem("campus_eye_imgbb_active_key",P),Hr(ot(pe,"settings","imgbb"),{activeKey:P,savedKeys:Pt,updatedAt:Bn(),updatedBy:(xt=Ne.currentUser)==null?void 0:xt.email},{merge:!0}),me.success("Switched active ImgBB key!")},className:"px-3 py-1.5 bg-white border border-gray-200 text-gray-700 hover:bg-gray-100 rounded-xl text-[10px] font-bold uppercase tracking-wider transition-all",children:"Switch to this"}),s.jsx("button",{onClick:async()=>{var cr;const xt=Pt.filter(ir=>ir!==P);Sn(xt);let qt=yt;yt===P&&(qt=xt[0]||"857eaaf2b7571ee437db8ee3f6ee8670",cn(qt),localStorage.setItem("campus_eye_imgbb_active_key",qt));try{await Hr(ot(pe,"settings","imgbb"),{activeKey:qt,savedKeys:xt,updatedAt:Bn(),updatedBy:(cr=Ne.currentUser)==null?void 0:cr.email},{merge:!0})}catch(ir){console.error(ir)}me.success("Removed ImgBB key")},className:"p-1.5 text-gray-400 hover:text-red-600 rounded-lg hover:bg-red-50 transition-all",title:"Remove Key",children:s.jsx(As,{size:16})})]})]},de)})})]}),s.jsxs("div",{className:"bg-white p-6 sm:p-8 rounded-3xl border border-gray-100 shadow-sm space-y-6 text-left",children:[s.jsx("div",{className:"flex items-center justify-between border-b border-gray-100 pb-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-3 bg-red-50 text-red-600 rounded-2xl border border-red-100",children:s.jsx(vre,{size:22})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-base font-black text-gray-900 uppercase tracking-tight",children:"Database Expansion Slots (Multi-Database System)"}),s.jsxs("p",{className:"text-[11px] text-gray-500 font-medium",children:["Add extra Firebase Databases (",s.jsx("span",{className:"text-red-650 font-bold",children:"Db 1, Db 2, Db 3..."}),"). All databases display together on the site simultaneously!"]})]})]})}),s.jsxs("div",{className:"p-5 bg-gradient-to-r from-gray-900 to-black text-white rounded-2xl border border-gray-800 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase tracking-widest text-amber-400 flex items-center gap-2",children:[s.jsx(lv,{size:14})," Active Target Write Database Slot"]}),s.jsx("span",{className:"text-[9px] font-mono text-emerald-400 font-bold uppercase bg-emerald-950/80 px-2.5 py-1 rounded-md border border-emerald-800",children:"LIVE WRITE ACTIVE"})]}),s.jsx("div",{className:"flex flex-col sm:flex-row items-center gap-3",children:s.jsxs("select",{value:y,onChange:P=>{const de=P.target.value;w(de),RL(de),me.success(`Active write target switched to ${de==="default"?"Default Primary DB":de.toUpperCase()}!`)},className:"w-full bg-white/10 text-white font-mono text-xs font-bold p-3 rounded-xl border border-white/20 outline-none cursor-pointer focus:border-amber-400",children:[s.jsx("option",{value:"default",className:"bg-gray-900 text-white",children:"Default Primary Firebase DB (Main System)"}),f.map(P=>s.jsxs("option",{value:P.id,className:"bg-gray-900 text-white",children:[P.name," (",P.projectId||"Custom Config",")"]},P.id))]})}),s.jsxs("p",{className:"text-[10px] text-gray-300 font-sans leading-relaxed",children:["New articles, comments, and uploaded media will be saved directly into the selected active slot. Readers will always see articles from ",s.jsx("b",{children:"ALL"})," databases aggregated automatically!"]})]}),s.jsxs("div",{className:"space-y-4 pt-2",children:[s.jsxs("h5",{className:"text-xs font-black uppercase tracking-wider text-gray-800 flex items-center gap-2",children:[s.jsx(fu,{size:14,className:"text-red-600"})," Add New Expansion Database Slot"]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-3",children:[s.jsx("div",{className:"md:col-span-4",children:s.jsx("input",{type:"text",value:I,onChange:P=>T(P.target.value),placeholder:"Slot Name e.g. Db 1, Db 2...",className:"w-full bg-gray-50 border border-gray-200 rounded-xl px-4 py-3 text-xs font-bold text-gray-900 outline-none focus:border-red-600"})}),s.jsx("div",{className:"md:col-span-8",children:s.jsx("textarea",{value:D,onChange:P=>F(P.target.value),placeholder:'Paste Firebase JSON Config snippet here (e.g. {"apiKey": "...", "projectId": "...", "authDomain": "..."})',className:"w-full bg-gray-50 border border-gray-200 rounded-xl px-4 py-3 text-xs font-mono text-gray-900 outline-none focus:border-red-600 min-h-[70px]"})})]}),s.jsx("button",{onClick:()=>{if(!I.trim()){me.error("Please enter a slot name e.g. Db 1");return}if(!D.trim()){me.error("Please paste the Firebase configuration JSON");return}try{const P=$2e(D),De={id:`db_${Date.now()}`,name:I.trim(),apiKey:P.apiKey||"",authDomain:P.authDomain||"",projectId:P.projectId||"",storageBucket:P.storageBucket||"",messagingSenderId:P.messagingSenderId||"",appId:P.appId||"",firestoreDatabaseId:P.firestoreDatabaseId||"(default)",customConfigJson:D.trim()},xt=[...f,De];m(xt),PL(xt),T(""),F(""),me.success(`Expansion slot "${De.name}" added successfully!`)}catch(P){me.error("Could not parse Firebase Config: "+P.message)}},className:"px-6 py-3 bg-red-650 text-white rounded-xl text-xs font-black uppercase tracking-wider hover:bg-black transition-all cursor-pointer shadow-sm",children:"Save Expansion Database Slot"})]}),f.length>0&&s.jsxs("div",{className:"space-y-3 pt-3 border-t border-gray-100",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase tracking-widest text-gray-400 block",children:["Registered Expansion Slots (",f.length,")"]}),f.map(P=>s.jsxs("div",{className:"p-4 bg-gray-50 border border-gray-200 rounded-2xl flex items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-black text-xs text-gray-900 uppercase tracking-wide block",children:P.name}),s.jsx("span",{className:"text-[10px] font-mono text-gray-500",children:P.projectId?`Project ID: ${P.projectId}`:"Custom Config"})]}),s.jsx("button",{onClick:()=>{const de=f.filter(De=>De.id!==P.id);m(de),PL(de),y===P.id&&(w("default"),RL("default")),me.success(`Removed ${P.name}`)},className:"p-2 text-gray-400 hover:text-red-600 rounded-lg hover:bg-red-50 transition-all cursor-pointer",title:"Delete Slot",children:s.jsx(As,{size:16})})]},P.id))]})]}),s.jsxs("div",{className:"bg-white p-6 sm:p-8 rounded-3xl border border-gray-100 shadow-sm space-y-4 text-left",children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-100 pb-4",children:[s.jsx("div",{className:"p-3 bg-indigo-50 text-indigo-600 rounded-2xl border border-indigo-100",children:s.jsx(iF,{size:22})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-base font-black text-gray-900 uppercase tracking-tight",children:"Google Redirect & Custom Authorization Domain"}),s.jsxs("p",{className:"text-[11px] text-gray-500 font-medium",children:["Configure your official domain link for Google Authentication redirects (e.g. ",s.jsx("span",{className:"text-indigo-600 font-bold",children:"campuseyemedia.com"}),")."]})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"text-xs font-black uppercase tracking-wider text-gray-700 block",children:"Website Authorized Auth Domain"}),s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[s.jsx("input",{type:"text",value:A,onChange:P=>k(P.target.value),placeholder:"e.g. campuseyemedia.com or custom domain...",className:"flex-1 bg-gray-50 border border-gray-200 rounded-xl px-4 py-3 text-xs font-mono text-gray-900 outline-none focus:border-indigo-600"}),s.jsx("button",{onClick:()=>{F2e(A),me.success("Saved Custom Auth Domain!")},className:"px-6 py-3 bg-indigo-600 text-white rounded-xl text-xs font-black uppercase tracking-wider hover:bg-indigo-700 transition-all cursor-pointer shrink-0",children:"Save Auth Domain"})]})]})]}),s.jsxs("div",{className:"bg-white p-6 sm:p-8 rounded-3xl border border-gray-100 shadow-sm space-y-4 text-left",children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-100 pb-4",children:[s.jsx("div",{className:"p-3 bg-emerald-50 text-emerald-600 rounded-2xl border border-emerald-100",children:s.jsx(es,{size:22})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-base font-black text-gray-900 uppercase tracking-tight",children:"Permanent SEO Sitemap (sitemap.xml) Generator"}),s.jsx("p",{className:"text-[11px] text-gray-500 font-medium",children:"Auto-generates compliant XML sitemaps for all published articles with titles, summaries, and images for Google Search indexing."})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.jsxs("button",{onClick:()=>{const P=H2e(c);q(P),me.success(`Generated sitemap.xml for ${c.length} articles!`)},className:"px-6 py-3 bg-emerald-600 text-white rounded-xl text-xs font-black uppercase tracking-wider hover:bg-emerald-700 transition-all cursor-pointer flex items-center gap-2",children:[s.jsx(es,{size:14})," Generate Sitemap XML"]}),L&&s.jsxs("button",{onClick:()=>{navigator.clipboard.writeText(L),me.success("Sitemap XML copied to clipboard!")},className:"px-6 py-3 bg-gray-900 text-white rounded-xl text-xs font-black uppercase tracking-wider hover:bg-black transition-all cursor-pointer flex items-center gap-2",children:[s.jsx(Pw,{size:14})," Copy XML Code"]})]}),L&&s.jsx("div",{className:"pt-2",children:s.jsx("textarea",{readOnly:!0,value:L,rows:8,className:"w-full bg-gray-950 text-emerald-400 font-mono text-[10px] p-4 rounded-2xl border border-gray-800 outline-none select-all"})})]})]})]}):a==="broadcast"&&t?s.jsxs("div",{className:"space-y-8 max-w-4xl font-sans text-left",children:[s.jsxs("div",{className:"border-b border-gray-100 pb-4",children:[s.jsxs("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:[s.jsx(hu,{className:"text-amber-500",size:24})," Official Admin Broadcast Center"]}),s.jsx("p",{className:"text-[11px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Dispatch instant broadcast notifications directly to every user's inbox on the website and mobile app."})]}),s.jsx("div",{className:"bg-white p-6 sm:p-8 rounded-3xl border border-gray-100 shadow-sm space-y-6",children:s.jsxs("form",{onSubmit:ue,className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-600 mb-1.5",children:"Broadcast Title / Headline *"}),s.jsx("input",{type:"text",required:!0,value:Ot,onChange:P=>nn(P.target.value),placeholder:"e.g., 📢 Urgent Campus Update: End of Semester Timetable Released!",className:"w-full p-3.5 bg-gray-50 border border-gray-200 rounded-2xl text-sm font-bold text-gray-900 outline-none focus:border-amber-500 focus:bg-white transition-all"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-600 mb-1.5",children:"Broadcast Message Content *"}),s.jsx("textarea",{rows:4,required:!0,value:mn,onChange:P=>dr(P.target.value),placeholder:"Type the full announcement details here. You can include text, or paste URLs directly...",className:"w-full p-4 bg-gray-50 border border-gray-200 rounded-2xl text-xs font-medium text-gray-900 outline-none focus:border-amber-500 focus:bg-white transition-all leading-relaxed"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-600 mb-1.5",children:"Attach Image URL (Optional)"}),s.jsx("input",{type:"url",value:hr,onChange:P=>Ui(P.target.value),placeholder:"https://images.unsplash.com/... (Image URL)",className:"w-full p-3 bg-gray-50 border border-gray-200 rounded-2xl text-xs font-mono text-gray-900 outline-none focus:border-amber-500 focus:bg-white transition-all"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-600 mb-1.5",children:"Action Target Link (Optional)"}),s.jsx("input",{type:"url",value:$n,onChange:P=>be(P.target.value),placeholder:"https://... or /articles/...",className:"w-full p-3 bg-gray-50 border border-gray-200 rounded-2xl text-xs font-mono text-gray-900 outline-none focus:border-amber-500 focus:bg-white transition-all"})]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-amber-600 bg-amber-50 px-3 py-1.5 rounded-xl border border-amber-200/50",children:[s.jsx(es,{size:14})," Reaches all citizens instantly in real-time"]}),s.jsxs("button",{type:"submit",disabled:je||!Ot.trim()||!mn.trim(),className:"flex items-center gap-2 px-6 py-3 bg-amber-500 hover:bg-amber-600 disabled:opacity-40 text-white text-xs font-black uppercase tracking-widest rounded-2xl transition-all shadow-md cursor-pointer active:scale-95",children:[s.jsx(fl,{size:14})," Dispatch Broadcast to All Inboxes"]})]})]})}),s.jsxs("div",{className:"bg-white p-6 sm:p-8 rounded-3xl border border-gray-100 shadow-sm space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 pb-4 border-b border-gray-100",children:[s.jsxs("div",{children:[s.jsxs("h4",{className:"text-base font-black text-gray-950 uppercase tracking-tight flex items-center gap-2",children:[s.jsx(sc,{className:"text-amber-500 animate-pulse",size:20}),s.jsxs("span",{children:["Sent Broadcast History (",tt.length,")"]})]}),s.jsx("p",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-widest mt-0.5",children:"Review, manage and delete past broadcast notifications delivered to user inboxes"})]}),tt.length>0&&s.jsxs("button",{onClick:pr,className:"flex items-center gap-1.5 px-4 py-2 bg-red-50 hover:bg-red-100 text-red-600 text-[10px] font-black uppercase tracking-wider rounded-xl transition-all border border-red-200 cursor-pointer self-start sm:self-auto",children:[s.jsx(As,{size:13}),s.jsx("span",{children:"Delete All Broadcasts"})]})]}),tt.length>3&&s.jsxs("div",{className:"relative",children:[s.jsx(Ip,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-gray-400",size:14}),s.jsx("input",{type:"text",value:jt,onChange:P=>on(P.target.value),placeholder:"Search sent broadcasts by title or keyword...",className:"w-full pl-9 pr-4 py-2.5 bg-gray-50 border border-gray-200 rounded-xl text-xs text-gray-800 outline-none focus:border-amber-500 focus:bg-white transition-all"})]}),Bt?s.jsxs("div",{className:"py-12 flex flex-col items-center justify-center text-gray-400 gap-2",children:[s.jsx(Pr,{className:"animate-spin text-amber-500",size:24}),s.jsx("p",{className:"text-xs font-bold uppercase tracking-widest",children:"Loading broadcast history..."})]}):tt.length===0?s.jsxs("div",{className:"p-10 border rounded-2xl text-center bg-gray-50/50 border-dashed border-gray-200 text-gray-400 select-none",children:[s.jsx(hu,{className:"mx-auto mb-2 text-gray-300",size:32}),s.jsx("p",{className:"text-xs font-bold uppercase tracking-wider text-gray-500",children:"No sent broadcast messages found."}),s.jsx("p",{className:"text-[10px] uppercase tracking-widest mt-1 text-gray-400",children:"Use the form above to dispatch your first official announcement."})]}):s.jsx("div",{className:"space-y-4",children:tt.filter(P=>{if(!jt.trim())return!0;const de=jt.toLowerCase();return(P.title||"").toLowerCase().includes(de)||(P.message||"").toLowerCase().includes(de)}).map(P=>{var De;const de=P.timestamp?new Date(P.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):(De=P.createdAt)!=null&&De.toDate?P.createdAt.toDate().toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):"Recently dispatched";return s.jsxs("div",{className:"p-4 sm:p-5 bg-gray-50/70 hover:bg-white border border-gray-200 rounded-2xl transition-all shadow-2xs hover:shadow-sm space-y-3 relative group",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex items-start gap-3 min-w-0 flex-1",children:[s.jsx("div",{className:"w-9 h-9 rounded-xl bg-amber-50 text-amber-600 border border-amber-200/60 flex items-center justify-center shrink-0 mt-0.5",children:s.jsx(hu,{size:18})}),s.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h5",{className:"text-sm font-black text-gray-950 tracking-tight leading-snug",children:P.title}),s.jsxs("span",{className:"text-[9px] font-mono font-bold text-gray-400 bg-white px-2 py-0.5 rounded-md border border-gray-200 flex items-center gap-1",children:[s.jsx(G6,{size:10})," ",de]})]}),s.jsx("p",{className:"text-xs text-gray-600 mt-1 leading-relaxed whitespace-pre-wrap",children:P.message})]})]}),s.jsx("button",{onClick:()=>Ir(P.id),title:"Delete this broadcast",className:"p-2 bg-white hover:bg-red-50 text-gray-400 hover:text-red-600 rounded-xl border border-gray-200 hover:border-red-200 transition-all cursor-pointer shrink-0 shadow-2xs active:scale-95",children:s.jsx(As,{size:16})})]}),(P.imageUrl||P.link)&&s.jsxs("div",{className:"pt-2 border-t border-gray-200/60 flex flex-wrap items-center gap-3",children:[P.imageUrl&&s.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-gray-500 font-mono bg-white px-2.5 py-1 rounded-lg border border-gray-200 max-w-xs truncate",children:[s.jsx(Bh,{size:12,className:"text-amber-500 shrink-0"}),s.jsx("span",{className:"truncate",children:P.imageUrl})]}),P.link&&s.jsxs("a",{href:P.link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-[10px] font-bold text-indigo-600 bg-indigo-50 hover:bg-indigo-100 px-2.5 py-1 rounded-lg border border-indigo-200 transition-all",children:[s.jsx(wd,{size:12}),s.jsx("span",{className:"truncate max-w-[200px]",children:P.link})]})]})]},P.id)})})]})]}):a==="users"&&t?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"bg-blue-50/40 border border-blue-100/50 p-5 rounded-3xl flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"p-3 bg-blue-50 text-accent rounded-2xl border border-blue-100",children:s.jsx(lv,{size:20})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-black text-blue-900 uppercase tracking-widest",children:"Citizen Data Saver Mode Active"}),s.jsxs("p",{className:"text-[11px] text-blue-700/80 mt-0.5",children:["To optimize loading times and reduce your data usage by ",s.jsx("strong",{children:"99.9%"}),", deep engagement profiles are calculated on-demand. Click ",s.jsx("strong",{children:"Analyze Profile"})," on any citizen below."]})]})]}),Object.keys(Kn).length>0&&s.jsx("button",{onClick:()=>{un({}),ln({})},className:"px-4 py-2 bg-white hover:bg-gray-50 border border-gray-100 rounded-xl text-[9px] font-black uppercase tracking-widest transition-all text-gray-600 shadow-sm cursor-pointer",children:"Clear Analytics Cache"})]}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-100 shadow-sm flex items-center gap-4",children:[s.jsx("div",{className:"p-3 bg-blue-50 text-accent rounded-xl",children:s.jsx(Ao,{size:20})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] text-gray-400 uppercase font-black tracking-widest",children:"Total Citizens"}),s.jsx("h4",{className:"text-xl font-extrabold text-gray-900",children:Z.length})]})]}),s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-100 shadow-sm flex items-center gap-4",children:[s.jsx("div",{className:"p-3 bg-emerald-50 text-emerald-600 rounded-xl",children:s.jsx(Xh,{size:20})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] text-gray-400 uppercase font-black tracking-widest",children:"Active Contributors"}),s.jsx("h4",{className:"text-xl font-extrabold text-gray-900",children:Object.values(Kn).filter(P=>(P.engagementScore||0)>=15).length})]})]}),s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-100 shadow-sm flex items-center gap-4",children:[s.jsx("div",{className:"p-3 bg-amber-50 text-amber-600 rounded-xl",children:s.jsx(mu,{size:20})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] text-gray-400 uppercase font-black tracking-widest",children:"Avg Engagement Score"}),s.jsxs("h4",{className:"text-xl font-extrabold text-gray-900",children:[Object.values(Kn).length?Math.round(Object.values(Kn).reduce((P,de)=>P+(de.engagementScore||0),0)/Object.values(Kn).length):0," pts"]})]})]}),s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-100 shadow-sm flex items-center gap-4",children:[s.jsx("div",{className:"p-3 bg-purple-50 text-purple-600 rounded-xl",children:s.jsx(xp,{size:20})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] text-gray-400 uppercase font-black tracking-widest",children:"Analyzed Citizens"}),s.jsxs("h4",{className:"text-xl font-extrabold text-gray-900",children:[Object.keys(Kn).length," / ",Z.length]})]})]})]}),s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"User Engagement Directory"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Real-time citizen contributions, purchases, and influence scores."})]}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",value:Ze,onChange:P=>Wt(P.target.value),placeholder:"Search citizens...",className:"px-6 py-3 bg-white border border-gray-100 rounded-xl text-[10px] font-black uppercase tracking-widest outline-none focus:ring-4 focus:ring-accent/10 focus:border-accent transition-all w-64"}),s.jsx(Ip,{size:14,className:"absolute right-4 top-1/2 -translate-y-1/2 text-gray-400"})]})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Z.filter(P=>{const de=Ze.toLowerCase();return(P.displayName||"").toLowerCase().includes(de)||(P.email||"").toLowerCase().includes(de)}).map(P=>{const de=Kn[P.id],De=xr[P.id],xt=It[P.id];return s.jsxs("div",{className:"bg-white p-6 rounded-[2rem] border border-gray-100 shadow-sm hover:shadow-md transition-all flex flex-col justify-between group",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-5",children:[s.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[s.jsxs("div",{className:"relative",children:[s.jsx("img",{src:P.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(P.displayName||"User")}&background=random`,alt:"",className:"w-14 h-14 rounded-2xl object-cover border-2 border-gray-50 shadow-sm"}),(P.isAdmin||P.role==="admin")&&s.jsx("div",{className:"absolute -top-1.5 -right-1.5 bg-black text-white p-1 rounded-lg shadow-md",children:s.jsx(pl,{size:11})})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("h4",{className:"font-extrabold text-sm text-gray-900 truncate uppercase tracking-tight",children:P.displayName||"Anonymous"}),s.jsx("p",{className:"text-[9px] text-gray-400 uppercase font-bold tracking-widest truncate",children:P.email})]})]}),s.jsx("span",{className:Ge("px-2.5 py-1 rounded-lg text-[9px] font-black uppercase tracking-wider border",(de==null?void 0:de.tierColor)||"bg-gray-50 text-gray-500 border-gray-100"),children:(de==null?void 0:de.tier)||"New Citizen"})]}),de?s.jsxs("div",{className:"space-y-4",children:[s.jsx(Iee,{stats:{userId:P.id,userName:P.displayName||"Citizen",userEmail:P.email||"",userPhoto:P.photoURL,engagementScore:de.engagementScore||0,articlesCount:de.articlesCount||0,postsCount:de.postsCount||0,purchasesCount:de.purchasesCount||0,totalSpent:de.totalSpent||0,followersCount:de.followersCount||0,followingCount:de.followingCount||0,tier:de.engagementScore>80?"Titan Publisher":de.engagementScore>30?"Senior Reporter":"Campus Citizen"}}),de.recentArticles&&de.recentArticles.length>0||de.recentPosts&&de.recentPosts.length>0?s.jsxs("div",{className:"mb-5 border-t border-dashed border-gray-100 pt-4",children:[s.jsxs("button",{type:"button",onClick:()=>ln(qt=>({...qt,[P.id]:!xt})),className:"flex items-center justify-between w-full text-[9px] font-black uppercase tracking-widest text-gray-500 hover:text-accent transition-all cursor-pointer",children:[s.jsx("span",{children:"Recent Citizen Action"}),xt?s.jsx(uf,{size:12}):s.jsx(Md,{size:12})]}),xt&&s.jsxs("div",{className:"mt-3 space-y-2 bg-gray-50/30 p-3 rounded-xl border border-gray-100/50 animate-fadeIn",children:[de.recentArticles&&de.recentArticles.length>0&&s.jsxs("div",{children:[s.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest text-gray-400 block mb-1",children:"Articles"}),s.jsx("ul",{className:"space-y-1",children:de.recentArticles.map(qt=>s.jsxs("li",{className:"text-[10px] text-gray-700 font-medium truncate",children:["• ",qt.title]},qt.id))})]}),de.recentPosts&&de.recentPosts.length>0&&s.jsxs("div",{className:Ge(de.recentArticles&&de.recentArticles.length>0?"mt-2 pt-2 border-t border-gray-100":""),children:[s.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest text-gray-400 block mb-1",children:"Lounge Posts"}),s.jsx("ul",{className:"space-y-1",children:de.recentPosts.map(qt=>s.jsxs("li",{className:"text-[10px] text-gray-600 font-medium truncate italic",children:['"',qt.content,'"']},qt.id))})]})]})]}):s.jsx("div",{className:"mb-5 border-t border-dashed border-gray-100 pt-4 text-center",children:s.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest text-gray-400",children:"No active content recorded"})})]}):s.jsx("div",{className:"mb-5 py-4",children:s.jsx("button",{onClick:()=>Se(P.id),disabled:De,className:"w-full py-5 bg-gray-50/50 hover:bg-gray-50 hover:border-accent active:bg-gray-100/80 border border-dashed border-gray-200 rounded-2xl flex flex-col items-center justify-center gap-2 transition-all cursor-pointer group/btn",children:De?s.jsx(Pr,{size:16,className:"animate-spin text-accent"}):s.jsxs(s.Fragment,{children:[s.jsx(xp,{size:18,className:"text-gray-400 group-hover/btn:text-accent transition-all"}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-gray-500 group-hover/btn:text-gray-800 transition-all",children:"Analyze Engagement Profile"})]})})})]}),s.jsxs("div",{className:"space-y-3 pt-3 border-t border-gray-50",children:[s.jsxs("div",{className:"flex items-center justify-between text-[10px] font-black uppercase tracking-widest",children:[s.jsx("span",{className:"text-gray-400",children:"Current Role"}),s.jsx("span",{className:Ge("px-2 py-0.5 rounded",P.isAdmin||P.role==="admin"?"bg-blue-50 text-accent":"bg-gray-50 text-gray-500"),children:P.isAdmin||P.role==="admin"?"Administrator":"Member"})]}),s.jsxs("div",{className:"flex items-center justify-between text-[10px] font-black uppercase tracking-widest",children:[s.jsx("span",{className:"text-gray-400",children:"Blue Check (Premium)"}),s.jsx("span",{className:Ge("px-2 py-0.5 rounded font-black",P.isVerified||P.isPremium||P.blueCheck||P.isPremiumPostUser?"bg-blue-600 text-white":"bg-gray-100 text-gray-400"),children:P.isVerified||P.isPremium||P.blueCheck||P.isPremiumPostUser?"✓ Verified Premium":"Standard"})]}),s.jsxs("div",{className:"flex flex-col gap-2 pt-1",children:[s.jsx("button",{onClick:()=>Kg(P.id,!!(P.isVerified||P.isPremium||P.blueCheck||P.isPremiumPostUser)),className:Ge("w-full py-2.5 rounded-xl text-[9.5px] font-black uppercase tracking-widest transition-all border-2 cursor-pointer flex items-center justify-center gap-1.5",P.isVerified||P.isPremium||P.blueCheck||P.isPremiumPostUser?"border-red-600 text-red-600 hover:bg-red-600 hover:text-white":"border-blue-600 text-blue-600 hover:bg-blue-600 hover:text-white"),children:P.isVerified||P.isPremium||P.blueCheck||P.isPremiumPostUser?"Revoke Blue Check (Premium)":"Grant Blue Check (Premium)"}),s.jsx("button",{onClick:()=>Mo(P.id,P.isAdmin||P.role==="admin"),className:Ge("w-full py-2.5 rounded-xl text-[9.5px] font-black uppercase tracking-widest transition-all border-2 cursor-pointer",P.isAdmin||P.role==="admin"?"border-black text-black hover:bg-black hover:text-white":"border-gray-900 text-gray-900 hover:bg-accent hover:border-accent hover:text-white"),children:P.isAdmin||P.role==="admin"?"Revoke Admin":"Make Admin"})]})]})]},P.id)})})]}):a==="manage-tickets"&&t?s.jsx("div",{className:"space-y-8",children:s.jsxs("div",{className:"flex flex-col md:flex-row gap-8",children:[s.jsxs("div",{className:"flex-1 bg-white p-8 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 mb-6",children:Je?"Edit Event Ticket":"Create New Event"}),s.jsxs("form",{onSubmit:Wg,className:"space-y-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Event Title"}),s.jsx("input",{type:"text",required:!0,value:fa,onChange:P=>is(P.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold",placeholder:"e.g. Annual Mid-Semester Bash"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Price (UGX)"}),s.jsx("input",{type:"number",required:!0,value:ss,onChange:P=>si(P.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold",placeholder:"e.g. 20000"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Quantity"}),s.jsx("input",{type:"number",required:!0,value:jo,onChange:P=>or(P.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold",placeholder:"e.g. 500"})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Event Date"}),s.jsx("input",{type:"datetime-local",required:!0,value:Et,onChange:P=>Oa(P.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Venue"}),s.jsx("input",{type:"text",required:!0,value:Tr,onChange:P=>Hi(P.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold",placeholder:"e.g. Main Hall"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Description"}),s.jsx("textarea",{required:!0,value:Sr,onChange:P=>Qi(P.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold min-h-[120px]",placeholder:"Detail what students should expect..."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"External Event Link (Optional)"}),s.jsx("input",{type:"url",value:Zt,onChange:P=>wn(P.target.value),className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl outline-none text-sm font-bold",placeholder:"e.g. https://example.com/event-details"})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-4",children:"Poster Image (Instant Uploaded)"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"bg-gray-50 border border-gray-100 p-4 rounded-2xl flex flex-col justify-center space-y-2",children:[s.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400 block",children:"Direct Image Link"}),s.jsx("input",{type:"text",value:ld,onChange:P=>iu(P.target.value),placeholder:"Paste poster image URL or upload details...",className:"w-full px-3 py-2 bg-white border border-gray-100 text-[10px] text-gray-700 font-mono rounded-lg outline-none focus:border-accent"})]}),s.jsxs("div",{className:"relative group",children:[s.jsx("input",{type:"file",accept:"image/*",onChange:P=>{var De;const de=(De=P.target.files)==null?void 0:De[0];de&&(mt(de),Ac(de,iu,Jg))},className:"hidden",id:"ticket-image"}),s.jsx("label",{htmlFor:"ticket-image",className:Ge("flex flex-col items-center justify-center aspect-video rounded-2xl border-2 border-dashed transition-all cursor-pointer bg-gray-50",ld?"border-accent":"border-gray-100 hover:border-accent hover:bg-white"),children:ru?s.jsxs("div",{className:"text-center p-2",children:[s.jsx(Pr,{className:"mx-auto text-accent mb-1 animate-spin",size:24}),s.jsx("p",{className:"text-[8px] font-black text-accent uppercase tracking-widest leading-none",children:"Uploading..."})]}):ld?s.jsxs("div",{className:"w-full h-full relative rounded-2xl overflow-hidden group",children:[s.jsx("img",{src:ld,className:"w-full h-full object-cover",alt:"Ticket Poster",referrerPolicy:"no-referrer"}),s.jsx("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center text-white",children:s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest",children:"Change Poster"})})]}):s.jsxs(s.Fragment,{children:[s.jsx(Bh,{className:"text-gray-400 mb-1",size:24}),s.jsx("p",{className:"text-[8.5px] font-black text-gray-400 uppercase tracking-widest",children:"Select file"})]})})]})]})]}),s.jsxs("div",{className:"flex gap-4",children:[Je&&s.jsx("button",{type:"button",onClick:()=>{vt(null),is(""),Qi(""),si(""),Oa(""),Hi(""),or(""),wn(""),iu("")},className:"flex-1 py-4 bg-gray-100 text-gray-600 rounded-2xl text-[10px] font-black uppercase tracking-widest",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:Ct,className:"flex-[2] py-4 bg-accent text-white rounded-2xl text-[10px] font-black uppercase tracking-widest shadow-lg shadow-accent/20",children:Ct?"Processing...":Je?"Update Ticket":"Launch Event"})]})]})]}),s.jsxs("div",{className:"w-full md:w-96 space-y-4",children:[s.jsx("h3",{className:"text-sm font-black uppercase tracking-widest text-gray-400 ml-2",children:"Active Event Tickets"}),Fn.map(P=>s.jsxs("div",{className:"bg-white p-5 rounded-3xl border border-gray-100 shadow-sm group",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsx("div",{className:"w-20 h-20 rounded-2xl overflow-hidden bg-gray-100 flex-shrink-0",children:s.jsx("img",{src:P.imageUrl||void 0,alt:"",className:"w-full h-full object-cover"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h4",{className:"text-sm font-black text-gray-900 truncate uppercase tracking-tight",children:P.title}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase mt-1",children:P.venue}),s.jsxs("div",{className:"flex items-center justify-between mt-3",children:[s.jsxs("span",{className:"text-xs font-black text-accent",children:["UGX ",P.price.toLocaleString()]}),s.jsxs("span",{className:"text-[9px] font-black px-2 py-1 bg-gray-100 rounded-lg text-gray-500",children:[P.remainingQuantity,"/",P.totalQuantity," LEFT"]})]})]})]}),s.jsxs("div",{className:"flex gap-2 mt-4 opacity-0 group-hover:opacity-100 transition-all",children:[s.jsx("button",{onClick:()=>{vt(P),is(P.title),Qi(P.description),si(P.price.toString());const de=(()=>{const De=P.eventDate;if(!De)return"";const xt=typeof De.toDate=="function"?De.toDate():De instanceof Date?De:De.seconds?new Date(De.seconds*1e3):new Date(De);try{return xt.toISOString().slice(0,16)}catch{return""}})();Oa(de),Hi(P.venue),or(P.totalQuantity.toString()),lr(P.category),iu(P.imageUrl||""),wn(P.link||"")},className:"flex-1 py-2 bg-blue-50 text-blue-600 rounded-xl text-[10px] font-black uppercase tracking-widest hover:bg-blue-600 hover:text-white transition-all",children:"Edit"}),s.jsx("button",{onClick:()=>Ku(P.id),className:"flex-1 py-2 bg-blue-50 text-black rounded-xl text-[10px] font-black uppercase tracking-widest hover:bg-black hover:text-white transition-all",children:"Delete"})]})]},P.id))]})]})}):a==="ticket-purchases"&&t?s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"bg-white p-8 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest mb-1",children:"Total Tickets Sold"}),s.jsx("h3",{className:"text-2xl font-black text-gray-900",children:Ae.totalTicketsSold})]}),s.jsxs("div",{className:"bg-white p-8 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest mb-1",children:"Total Revenue"}),s.jsxs("h3",{className:"text-2xl font-black text-accent",children:["UGX ",Ae.totalRevenue.toLocaleString()]})]}),s.jsxs("div",{className:"bg-white p-8 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest mb-1",children:"Recent Transactions"}),s.jsx("h3",{className:"text-2xl font-black text-gray-900",children:Dt.length})]})]}),s.jsxs("div",{className:"bg-gray-50/70 p-6 rounded-[2.5rem] border border-gray-150 space-y-4 text-left",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400 shrink-0"}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-gray-500 font-mono",children:"Simulated Gate Scan & Barcode Lookup"})]}),s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[s.jsx("input",{type:"text",placeholder:"Type or paste scanned Purchase ID (e.g. h6SndA4v...)",value:Xe,onChange:P=>Vt(P.target.value),className:"flex-1 px-6 py-3.5 bg-white border border-gray-250 rounded-2xl text-xs font-bold outline-none focus:border-red-600 transition-all font-mono"}),s.jsx("button",{onClick:()=>{if(!Xe.trim()){me.error("Please enter a ticket ID to query!");return}const P=Dt.find(de=>de.id===Xe.trim()||de.id.slice(-6).toLowerCase()===Xe.trim().toLowerCase());P?(me.success(`Ticket found: ${P.ticketTitle}!`),xn(P)):(me.error("Ticket purchase record not found in data sheets!"),xn(null))},className:"px-8 py-3.5 bg-black text-white hover:bg-red-655 rounded-2xl text-[10px] font-black uppercase tracking-widest transition-colors cursor-pointer",children:"Lookup Code"})]}),gn&&s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-150 shadow-xs mt-3 flex flex-col md:flex-row items-start md:items-center justify-between gap-4 animate-in fade-in slide-in-from-top-2 duration-200",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("span",{className:"text-[8px] font-black text-gray-400 uppercase tracking-widest font-mono",children:"Scanned Ticket Match"}),s.jsx("h4",{className:"text-sm font-black text-gray-950 uppercase tracking-tight leading-tight",children:gn.ticketTitle}),s.jsxs("div",{className:"flex flex-wrap gap-2 text-[9px] font-bold text-gray-500 uppercase mt-1",children:[s.jsxs("span",{children:["Guest: ",s.jsx("strong",{className:"text-gray-900",children:gn.userName})]}),s.jsx("span",{children:"•"}),s.jsxs("span",{children:["Qty: ",s.jsxs("strong",{className:"text-gray-900",children:[gn.quantity," Pax"]})]}),s.jsx("span",{children:"•"}),s.jsxs("span",{children:["Code: ",s.jsxs("strong",{className:"text-gray-900 font-mono select-all",children:["#",gn.id.substring(0,10),"..."]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-3 bg-gray-50 px-4 py-2.5 rounded-2xl border border-gray-100 shrink-0",children:[s.jsx("input",{type:"checkbox",id:"dashboard-scanned-taken",checked:!!gn.taken||!!gn.used,onChange:async()=>{const P=!(gn.taken||gn.used);try{await Hn(ot(pe,"purchases",gn.id),{taken:P,used:P}),xn(de=>de?{...de,taken:P,used:P}:null),P?(await ur(it(pe,"notifications"),{userId:gn.userId,title:`✔️ Ticket Ticked & Used: ${gn.ticketTitle}`,message:`Your entry pass (ID #${gn.id.slice(-6).toUpperCase()}) has been officially scanned and ticked as used. Enjoy the event!`,used:!1,createdAt:new Date,type:"entrance_checkin",code:gn.id}),me.success("Ticket marked as used! Buyer's inbox is updated.",{icon:"✔️"})):me.success("Entry pass reactivated.")}catch(de){console.error("Dashboard verify gate error:",de),me.error("Verify failed: "+de.message)}},className:"w-4.5 h-4.5 rounded border-gray-300 text-red-650 cursor-pointer accent-red-650"}),s.jsx("label",{htmlFor:"dashboard-scanned-taken",className:"text-[10px] font-black uppercase tracking-wider text-gray-950 cursor-pointer select-none",children:gn.taken||gn.used?"✔️ TICKED & USED":"✉️ MARK USED / TICKED"})]})]})]}),s.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 items-center justify-between bg-white p-5 rounded-[2rem] border border-gray-100 shadow-sm text-left",children:[s.jsxs("div",{className:"relative w-full lg:max-w-md",children:[s.jsx("input",{type:"text",value:yn,onChange:P=>gt(P.target.value),placeholder:"Search by name, email, event title or ticket ID...",className:"w-full pl-6 pr-10 py-3 bg-gray-50/50 border border-gray-200 focus:border-red-650 rounded-2xl text-xs font-bold outline-none transition-all placeholder:text-gray-400"}),yn&&s.jsx("button",{onClick:()=>gt(""),className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-650 font-black text-[10px] uppercase tracking-wider",children:"Clear"})]}),s.jsx("div",{className:"flex items-center gap-1.5 p-1 bg-gray-105 border border-gray-150 rounded-2xl w-full lg:w-auto shrink-0 overflow-x-auto",children:[{key:"all",label:"All Bookings"},{key:"unclaimed",label:"🎫 Active / Unused"},{key:"taken",label:"✔️ Ticked / Used"}].map(P=>s.jsx("button",{type:"button",onClick:()=>Nt(P.key),className:Ge("px-4 py-2 rounded-xl text-[10px] font-black uppercase tracking-wider transition-all cursor-pointer whitespace-nowrap",Tn===P.key?"bg-white text-gray-950 shadow-xs":"text-gray-550 hover:text-gray-900"),children:P.label},P.key))})]}),s.jsx("div",{className:"bg-white rounded-[2.5rem] border border-gray-100 shadow-sm overflow-hidden",children:s.jsxs("table",{className:"w-full text-left",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-gray-50 border-b border-gray-100",children:[s.jsx("th",{className:"px-8 py-4 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Transaction ID"}),s.jsx("th",{className:"px-8 py-4 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Customer"}),s.jsx("th",{className:"px-8 py-4 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Event"}),s.jsx("th",{className:"px-8 py-4 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Qty"}),s.jsx("th",{className:"px-8 py-4 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Amount"}),s.jsx("th",{className:"px-8 py-4 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Date"}),s.jsx("th",{className:"px-8 py-4 text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Taken / Checked In"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-50",children:po.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:7,className:"text-center py-12 text-xs font-bold text-gray-400 uppercase tracking-wider select-none font-mono",children:"No booking transactions match your search filter criteria."})}):po.map(P=>{const de=!!(P.taken||P.used);return s.jsxs("tr",{onClick:()=>mo(P),className:Ge("transition-all cursor-pointer hover:bg-red-50/20 active:bg-gray-100/60 select-none",de?"bg-green-50/15":"hover:bg-gray-50/80"),title:"Click anywhere on this row to tick/untick this pass",children:[s.jsx("td",{className:"px-8 py-4 text-[10px] font-black text-gray-900 uppercase font-mono",children:s.jsxs("span",{className:Ge(de?"line-through text-gray-400":""),children:["#",P.id.slice(-6).toUpperCase()]})}),s.jsxs("td",{className:"px-8 py-4",children:[s.jsx("p",{className:Ge("text-sm font-bold text-gray-900",de&&"line-through text-gray-450"),children:P.userName}),s.jsx("p",{className:"text-[10px] text-gray-400 truncate max-w-[200px]",children:P.userEmail})]}),s.jsx("td",{className:Ge("px-8 py-4 text-sm font-bold text-gray-900 uppercase tracking-tight",de&&"line-through text-gray-400"),children:P.ticketTitle}),s.jsx("td",{className:Ge("px-8 py-4 text-sm font-black text-gray-900",de&&"text-gray-400"),children:P.quantity}),s.jsxs("td",{className:Ge("px-8 py-4 text-sm font-black text-accent",de&&"text-gray-400"),children:["UGX ",P.totalAmount.toLocaleString()]}),s.jsx("td",{className:"px-8 py-4 text-[10px] font-bold text-gray-400 uppercase",children:P.purchaseDate instanceof jr?P.purchaseDate.toDate().toLocaleString():"Recently"}),s.jsx("td",{className:"px-8 py-4 text-[10px]",onClick:De=>De.stopPropagation(),children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:de,onChange:()=>mo(P),className:"w-4 h-4 rounded border-gray-350 text-red-650 focus:ring-red-655 accent-red-600 cursor-pointer",id:`taken-${P.id}`}),s.jsx("label",{htmlFor:`taken-${P.id}`,onClick:De=>{De.stopPropagation(),mo(P)},className:Ge("text-[9px] font-black uppercase tracking-wider select-none cursor-pointer",de?"text-green-600 font-mono":"text-gray-400 font-mono"),children:de?"✔️ Ticked":"Mark Used"})]})})]},P.id)})})]})})]}):a==="polls"&&t?s.jsxs("div",{className:"max-w-4xl mx-auto space-y-8",children:[s.jsxs("div",{className:"bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"Manage Campus Poll"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Create or reset the active university poll"})]}),s.jsxs("form",{onSubmit:tx,className:"space-y-8",children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Question"}),s.jsx("input",{type:"text",value:El,onChange:P=>Xa(P.target.value),placeholder:"e.g., Who is your favorite Guild Presidential candidate?",className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all",required:!0})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest flex items-center justify-between",children:["Options",s.jsx("button",{type:"button",onClick:()=>ra([...Ra,""]),className:"text-accent hover:underline",children:"Add Option"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Ra.map((P,de)=>s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:P,onChange:De=>{const xt=[...Ra];xt[de]=De.target.value,ra(xt)},placeholder:`Option ${de+1}`,className:"flex-1 px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all",required:!0}),Ra.length>2&&s.jsx("button",{type:"button",onClick:()=>ra(Ra.filter((De,xt)=>xt!==de)),className:"p-4 text-gray-300 hover:text-accent transition-colors",children:s.jsx(As,{size:18})})]},de))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Poll Status"}),s.jsx("div",{className:"flex gap-4",children:["active","closed"].map(P=>s.jsx("button",{type:"button",onClick:()=>Fr(P),className:Ge("flex-1 py-4 px-6 rounded-2xl text-[10px] font-black uppercase tracking-widest border-2 transition-all",Oo===P?"border-accent bg-blue-50 text-accent":"border-gray-100 text-gray-400 hover:border-gray-200"),children:P},P))})]})]})," ",s.jsxs("button",{type:"submit",disabled:Ct,className:"w-full py-5 bg-accent text-white rounded-2xl text-xs font-black uppercase tracking-[0.2em] shadow-xl shadow-accent/20 hover:bg-accent-700 transition-all disabled:opacity-50 flex items-center justify-center gap-2",children:[Ct?s.jsx(Pr,{className:"animate-spin",size:18}):s.jsx(Xh,{size:18}),Ct?"Processing...":"Update Campus Poll"]})]}),s.jsxs("div",{className:"mt-12 p-6 bg-blue-50 rounded-2xl border border-blue-100 flex items-start gap-4",children:[s.jsx(bu,{className:"text-accent shrink-0",size:20}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-[10px] font-black text-accent uppercase tracking-widest leading-none",children:"Safe Storage Archiving"}),s.jsx("p",{className:"text-[10px] font-bold text-accent/80 uppercase tracking-tight leading-tight",children:"This action will post a brand-new poll and close previous active ones. Existing votes for old polls are securely preserved and stored in historical archives."})]})]})]}),s.jsxs("div",{id:"admin-debates-section",className:"bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm space-y-8",children:[s.jsxs("div",{className:"border-b border-gray-100 pb-5",children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"Manage Public Debates"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Create debate topics (link to external discussion or internal built-in discussion threads)"})]}),s.jsxs("form",{onSubmit:An,className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Debate Topic Title"}),s.jsx("input",{type:"text",value:st,onChange:P=>mr(P.target.value),placeholder:"e.g. Is remote learning more effective than in-person lectures?",className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all",required:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Banner Image URL"}),s.jsx("input",{type:"text",value:we,onChange:P=>Te(P.target.value),placeholder:"Leave blank for smart defaults",className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Description / Content"}),s.jsx("textarea",{value:Mi,onChange:P=>ge(P.target.value),placeholder:"Brief introduction or guidelines for this debate thread...",rows:3,className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all"})]}),s.jsxs("div",{className:"flex items-center gap-3 p-4 bg-gray-50 rounded-2xl border border-gray-100",children:[s.jsx("input",{type:"checkbox",id:"debateIsExternal",checked:$e,onChange:P=>ut(P.target.checked),className:"w-4.5 h-4.5 text-accent border-gray-300 rounded focus:ring-accent accent-accent"}),s.jsx("label",{htmlFor:"debateIsExternal",className:"text-xs font-black uppercase tracking-wider text-gray-700 select-none cursor-pointer",children:"This is an external discussion link (redirect user to external URL)"})]}),$e&&s.jsxs("div",{className:"space-y-2 pt-2 animate-fade-in",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"External Link URL"}),s.jsx("input",{type:"text",value:lt,onChange:P=>At(P.target.value),placeholder:"https://example.com/discussion",className:"w-full px-6 py-4 bg-gray-50 border border-gray-150 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all",required:$e})]}),s.jsxs("button",{type:"submit",disabled:bn,className:"w-full py-5 bg-stone-950 text-white rounded-2xl text-xs font-black uppercase tracking-[0.2em] shadow-xl hover:bg-black transition-all disabled:opacity-50 flex items-center justify-center gap-2 cursor-pointer",children:[bn?s.jsx(Pr,{className:"animate-spin",size:18}):s.jsx(Yi,{size:18}),bn?"Publishing...":"Publish Public Debate Topic"]})]}),s.jsx("div",{className:"space-y-4 pt-6",children:s.jsxs("div",{className:"border-t border-gray-100 pt-6",children:[s.jsxs("h4",{className:"text-sm font-black uppercase tracking-wider text-gray-900 mb-4",children:["Active Debates (",ia.length,")"]}),ia.length===0?s.jsx("p",{className:"text-xs font-bold text-gray-400 uppercase tracking-widest text-center py-4",children:"No active debates listed yet."}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:ia.map(P=>s.jsxs("div",{className:"p-4 bg-gray-50 rounded-2xl border border-gray-100 flex gap-3 relative justify-between items-start min-w-0",children:[s.jsxs("div",{className:"flex gap-2.5 items-start min-w-0",children:[s.jsx("img",{src:P.bannerUrl||void 0,alt:"",className:"w-12 h-12 rounded-xl object-cover border border-gray-150 shrink-0",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"min-w-0 text-left",children:[s.jsx("span",{className:`text-[8px] font-black uppercase tracking-wider px-2 py-0.5 rounded ${P.isExternal?"bg-orange-50 text-orange-600 border border-orange-100":"bg-green-50 text-green-600 border border-green-100"}`,children:P.isExternal?"External":"Built-in"}),s.jsx("h5",{className:"text-xs font-black text-gray-950 mt-1 truncate uppercase tracking-tight",children:P.title}),s.jsx("p",{className:"text-[9px] text-gray-500 line-clamp-1 mt-0.5",children:P.description||"No description provided."})]})]}),s.jsx("button",{onClick:()=>Rn(P.id),className:"p-2 text-gray-400 hover:text-red-650 hover:bg-red-50 rounded-xl transition-all cursor-pointer shrink-0",title:"Delete debate topic",children:s.jsx(As,{size:16})})]},P.id))})]})})]})]}):a==="pinned-board"&&t?s.jsx("div",{className:"max-w-4xl mx-auto space-y-8",children:s.jsxs("div",{className:"bg-white p-10 rounded-[2.5rem] border border-gray-100 shadow-sm",children:[s.jsxs("div",{className:"mb-8 flex items-center justify-between border-b border-gray-50 pb-6",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:[s.jsx(g0,{className:"text-accent stroke-[3px]",size:20}),s.jsx("span",{children:"Pinned Announcements Board"})]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Supercharge articles, events, or programs with a high-impact sliding announcement"})]}),s.jsxs("div",{className:"flex items-center gap-3 bg-gray-50 px-4 py-2 rounded-2xl border border-gray-100",children:[s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-gray-400",children:"Status"}),s.jsx("button",{type:"button",onClick:()=>Pm(!Yl),className:Ge("relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-250 ease-in-out outline-none",Yl?"bg-accent":"bg-gray-250"),children:s.jsx("span",{className:Ge("pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-250 ease-in-out",Yl?"translate-x-5":"translate-x-0")})}),s.jsx("span",{className:Ge("text-[9px] font-black uppercase tracking-widest",Yl?"text-accent":"text-gray-400"),children:Yl?"ACTIVE":"INACTIVE"})]})]}),s.jsxs("form",{onSubmit:$f,className:"space-y-8",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1",children:"Announcement Title"}),s.jsx("input",{type:"text",value:eu,onChange:P=>tu(P.target.value),placeholder:"e.g. 🎉 SPECIAL FREE TICKET GIVEAWAY!",className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all",required:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1",children:"Target Action Link (Clickable Destination)"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"url",value:Zg,onChange:P=>Om(P.target.value),placeholder:"https://campus-eye.com/tickets/giveaway-id",className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all pl-12"}),s.jsx(wd,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400",size:18})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1",children:"Display duration on page load (seconds)"}),s.jsx("input",{type:"number",min:"1",max:"60",value:dh,onChange:P=>hh(Number(P.target.value)||5),placeholder:"Default is 5 seconds",className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all",required:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1 block",children:"Live Streaming / Embed Option"}),s.jsxs("div",{className:"flex items-center gap-3 p-4 bg-gray-50 border border-gray-100 rounded-2xl",children:[s.jsx("input",{type:"checkbox",id:"pinned-is-live",checked:fh,onChange:P=>Dm(P.target.checked),className:"w-4 h-4 text-red-600 border-gray-300 rounded focus:ring-red-500 cursor-pointer"}),s.jsx("label",{htmlFor:"pinned-is-live",className:"text-xs font-black text-gray-700 uppercase tracking-wider cursor-pointer select-none",children:"Enable Live Embed / Stream Page"})]})]})]}),fh&&s.jsx("div",{className:"grid grid-cols-1 gap-6 animate-fade-in",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-red-650 uppercase tracking-widest ml-1 block",children:"Live Streaming / IFrame Embed URL"}),s.jsx("input",{type:"url",value:Nc,onChange:P=>Ec(P.target.value),placeholder:"e.g., https://www.youtube.com/embed/... or any dynamic webpage embed code link",className:"w-full px-6 py-4 bg-red-50/20 border border-red-200 rounded-2xl text-sm font-bold focus:bg-white focus:border-red-650 outline-none transition-all text-red-950 placeholder-red-300",required:fh}),s.jsx("span",{className:"text-[9px] text-gray-400 block ml-1 uppercase font-black tracking-widest",children:"🛡️ If enabled, a reside interactive preview will load instead of the static mock picture. Let clicked, the stream pops up fullscreen!"})]})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1",children:"Short Description / Subtitle"}),s.jsx("textarea",{value:Qg,onChange:P=>Tm(P.target.value),placeholder:"e.g. Claim free registration passes to the upcoming Guild Presidential Debate! Only for verified campus citizens.",className:"w-full px-6 py-4 bg-gray-50 border border-gray-100 rounded-2xl text-sm font-bold focus:bg-white focus:border-accent outline-none transition-all min-h-[90px] resize-none"})]}),s.jsxs("div",{className:"space-y-4 pt-4 border-t border-gray-50",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest ml-1 block",children:"Accompanying Image / Photo Asset"}),s.jsx("span",{className:"text-[9px] font-medium text-gray-400 uppercase tracking-wider",children:"Fast Cloud Image Storage"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"md:col-span-2 relative",children:[s.jsx("input",{type:"file",accept:"image/*",onChange:P=>{var De;const de=(De=P.target.files)==null?void 0:De[0];de&&(id(!0),Ac(de,uh,id))},className:"hidden",id:"pinned-banner-image"}),s.jsx("label",{htmlFor:"pinned-banner-image",className:Ge("flex flex-col items-center justify-center aspect-[16/6] rounded-2xl border-2 border-dashed transition-all cursor-pointer bg-gray-50",sl?"border-accent":"border-gray-150 hover:border-accent hover:bg-white"),children:rd?s.jsxs("div",{className:"text-center p-4",children:[s.jsx(Pr,{className:"mx-auto text-accent mb-2 animate-spin",size:28}),s.jsx("p",{className:"text-[10px] font-black text-accent uppercase tracking-widest block leading-none",children:"Uploading Asset..."})]}):sl?s.jsxs("div",{className:"w-full h-full relative rounded-2xl overflow-hidden group",children:[s.jsx("img",{src:sl,className:"w-full h-full object-cover animate-fade-in",alt:"Pinned Asset",referrerPolicy:"no-referrer"}),s.jsx("div",{className:"absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center text-white",children:s.jsxs("span",{className:"text-[10px] font-black uppercase tracking-widest flex items-center gap-1",children:[s.jsx(g0,{size:14})," Change Announcement Photo"]})})]}):s.jsxs(s.Fragment,{children:[s.jsx(Bh,{className:"text-gray-400 mb-2",size:28}),s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block text-center leading-none",children:"Upload Announcement Photo"})]})})]}),s.jsxs("div",{className:"bg-gray-50 border border-gray-100 p-5 rounded-2xl flex flex-col justify-center space-y-3 shadow-inner",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400 block mb-1",children:"Direct Asset URI"}),s.jsx("input",{type:"text",value:sl,onChange:P=>uh(P.target.value),placeholder:"Or paste asset address here...",className:"w-full px-3 py-2 bg-white border border-gray-100 text-[10px] text-gray-700 font-mono rounded-lg outline-none focus:border-accent"})]}),s.jsx("p",{className:"text-[8px] text-gray-400 font-bold uppercase tracking-wider leading-relaxed",children:"This image resides inside the sliding high-attention banner replacing the top banner briefly with streamlined design specs."})]})]})]}),s.jsx("div",{className:"border-t border-gray-50 pt-8 mt-8",children:s.jsxs("button",{type:"submit",disabled:nu,className:"w-full py-5 bg-accent text-white rounded-2xl text-xs font-black uppercase tracking-[0.2em] shadow-xl shadow-accent/20 hover:bg-accent-700 transition-all disabled:opacity-50 flex items-center justify-center gap-2",children:[nu?s.jsx(Pr,{className:"animate-spin",size:18}):s.jsx(Xh,{size:18}),nu?"Saving changes...":"Publish Pinned Announcement"]})})]}),s.jsxs("div",{className:"mt-12 pt-8 border-t border-gray-100 space-y-6",children:[s.jsxs("div",{children:[s.jsxs("h4",{className:"text-sm font-black uppercase tracking-wider text-gray-950 flex items-center gap-2",children:[s.jsx(g0,{size:16,className:"text-red-650"}),s.jsxs("span",{children:["Active database broadcasts (",Mm.length,")"]})]}),s.jsx("p",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-widest mt-0.5",children:"Admins can review, monitor and delete active broadcasts on the campus banner"})]}),Mm.length===0?s.jsxs("div",{className:"p-10 border rounded-2xl text-center bg-gray-50 border-gray-100 text-gray-400 select-none",children:[s.jsx("p",{className:"text-xs font-bold uppercase tracking-wider",children:"No active broadcasts registered in database."}),s.jsx("p",{className:"text-[9px] uppercase tracking-widest mt-1",children:"Submit the form above to post your first broadcast."})]}):s.jsx("div",{className:"grid grid-cols-1 gap-4",children:Mm.map(P=>s.jsxs("div",{className:"flex items-center justify-between p-4 bg-white border border-gray-150 rounded-2xl hover:border-red-650/40 transition-all shadow-xs",children:[s.jsxs("div",{className:"flex items-center gap-4 min-w-0 flex-1",children:[P.imageUrl?s.jsx("img",{src:P.imageUrl,alt:"",className:"w-12 h-12 rounded-xl object-cover border border-gray-100",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"w-12 h-12 bg-red-50 text-red-600 rounded-xl flex items-center justify-center font-bold",children:s.jsx(Su,{size:18})}),s.jsxs("div",{className:"min-w-0 pr-4 text-left",children:[s.jsx("h5",{className:"text-xs font-black text-gray-900 truncate uppercase tracking-tight",children:P.title}),s.jsx("p",{className:"text-[10px] text-gray-500 line-clamp-1 mt-0.5",children:P.description||"No description provided."}),s.jsxs("span",{className:"text-[8px] font-black font-mono text-gray-400 uppercase tracking-widest block mt-1",children:[P.durationSeconds||5,"s • link: ",P.link?"configured":"none"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:async()=>{try{const de=ot(pe,"pinned_announcements",P.id);await Hn(de,{active:!P.active}),P.active||await Hr(ot(pe,"settings","pinned"),{title:P.title,description:P.description||"",link:P.link||"",imageUrl:P.imageUrl||"",active:!0,durationSeconds:P.durationSeconds||5,isLiveStream:!!P.isLiveStream,liveEmbedUrl:P.liveEmbedUrl||"",updatedAt:Bn()},{merge:!0}),me.success(`Announcement set to ${P.active?"Inactive":"Active"}`)}catch(de){me.error("Failed to update status: "+de.message)}},className:Ge("text-[8px] font-mono font-black uppercase px-2 py-1.5 rounded-lg cursor-pointer transition-all active:scale-95 border",P.active?"bg-green-50 text-green-700 border-green-200 hover:bg-green-150 hover:text-green-800":"bg-gray-50 text-gray-400 border-gray-200 hover:bg-gray-100 hover:text-gray-600"),title:"Click to toggle active status",children:P.active?"● ACTIVE":"○ INACTIVE"}),s.jsx("button",{onClick:()=>wb(P.id),className:"p-2 text-gray-400 hover:text-red-650 hover:bg-red-50 rounded-lg transition-colors cursor-pointer",title:"Delete announcement",children:s.jsx(As,{size:16})})]})]},P.id))})]}),s.jsxs("div",{className:"mt-8 p-6 bg-blue-50/70 border border-blue-100 rounded-2xl flex items-start gap-4",children:[s.jsx(Su,{className:"text-accent shrink-0 animate-bounce",size:20}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-[10px] font-black text-accent uppercase tracking-widest leading-none",children:"Visual Carousel Mechanics"}),s.jsx("p",{className:"text-[10px] font-medium text-accent/80 uppercase tracking-tight leading-relaxed",children:"If active, this announcement slides overlay style onto the first banner rotation on the homepage. To support clean aesthetics, it has beautifully rounded edges, custom colored border halo, slides in with Streamlined fluid transitions, displays for exactly 2 seconds, and then automatically returns to the original carousel."})]})]})]})}):a==="manage-posts"&&t?s.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto animate-fade-in text-left",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row justify-between sm:items-center border-b border-gray-105 pb-4 gap-3",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:[s.jsx(Yi,{className:"text-accent stroke-[3px]",size:19}),s.jsx("span",{children:"Manage Lounge Posts"})]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Review, moderate, and delete student-generated posts in the lounge"})]}),s.jsxs("div",{className:"text-[10px] bg-red-50 text-red-750 px-3 py-1.5 border border-red-150/50 rounded-xl font-mono shrink-0 w-fit",children:["Total Posts: ",V.length]})]}),V.length===0?s.jsxs("div",{className:"bg-white p-20 rounded-[2.5rem] border border-gray-100 shadow-sm text-center",children:[s.jsx("div",{className:"w-16 h-16 bg-gray-50 text-gray-450 rounded-full flex items-center justify-center mx-auto mb-4",children:s.jsx(Yi,{size:32})}),s.jsx("h4",{className:"text-lg font-sans font-extrabold text-gray-900 uppercase tracking-tight",children:"No Posts Found"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-2",children:"Lounge database is currently empty."})]}):s.jsx("div",{className:"grid grid-cols-1 gap-4",children:V.map(P=>{var de,De,xt;return s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-sm hover:shadow-md transition-all flex flex-col md:flex-row gap-5",children:[s.jsxs("div",{className:"flex-1 space-y-3 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[P.authorPhotoURL?s.jsx("img",{src:P.authorPhotoURL,className:"w-8 h-8 rounded-full object-cover border border-gray-250 shrink-0",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-red-100 text-red-750 flex items-center justify-center font-black text-xs shrink-0 select-none",children:((de=P.authorName)==null?void 0:de.charAt(0))||"P"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"text-[10.5px] font-black uppercase tracking-tight text-gray-950 block truncate",children:P.authorName||"Peer"}),s.jsxs("span",{className:"text-[8px] font-semibold text-gray-450 block uppercase font-mono tracking-wider",children:["ID: #",P.id.slice(-6).toUpperCase()]})]})]}),s.jsx("p",{className:"text-xs text-gray-800 font-sans leading-relaxed whitespace-pre-wrap",children:P.content}),P.imageUrl&&s.jsx("div",{className:"max-w-xs rounded-xl overflow-hidden border border-gray-150 max-h-40 bg-gray-50",children:s.jsx("img",{src:P.imageUrl,className:"w-full h-full object-cover",referrerPolicy:"no-referrer"})})]}),(t||((xt=(De=Ne.currentUser)==null?void 0:De.email)==null?void 0:xt.toLowerCase())==="atwiinevictor2@gmail.com")&&s.jsx("div",{className:"shrink-0 flex md:flex-col items-end justify-between md:justify-center gap-3",children:s.jsx("button",{onClick:async()=>{if(!t){me.error("Access Denied: Only administrators can delete posts.");return}if(window.confirm("Are you sure you want to delete this lounge post? This action is permanent."))try{await ni(ot(pe,"posts",P.id)),me.success("Lounge post deleted successfully.")}catch(qt){me.error("Failed to delete lounge post: "+qt.message)}},className:"p-3 bg-red-50 hover:bg-red-650 text-red-650 hover:text-white rounded-xl transition-all cursor-pointer shadow-xs active:scale-95",title:"Delete Post (Master Admin)",children:s.jsx(As,{size:16})})})]},P.id)})})]}):a==="custom-links"&&t?s.jsxs("div",{className:"space-y-8 max-w-4xl mx-auto animate-fade-in text-left",children:[s.jsx("div",{className:"flex border-b border-gray-100 pb-4 justify-between items-center",children:s.jsxs("div",{children:[s.jsxs("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:[s.jsx(wd,{className:"text-accent stroke-[3px]",size:19}),s.jsx("span",{children:"Global Menu Pages Manager"})]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Add, edit, or delete external links that render as immersive full-screen popups in every user's menu."})]})}),s.jsxs("div",{className:"bg-white p-6 md:p-8 rounded-[2rem] border border-gray-105 shadow-sm space-y-4",children:[s.jsx("h4",{className:"text-sm font-sans font-extrabold uppercase tracking-tight text-gray-900 border-b border-gray-50 pb-2",children:pt?"⚡ Modify Existing Page":"➕ Add Custom Dynamic Page link"}),s.jsxs("form",{onSubmit:qg,className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-450 block",children:"Page Display Name"}),s.jsx("input",{required:!0,type:"text",value:G,onChange:P=>he(P.target.value),placeholder:"e.g. Student Varsity Store",className:"w-full px-4 py-3 bg-gray-50 border border-gray-250 rounded-xl outline-none text-sm font-bold placeholder:text-gray-300 focus:border-red-600 focus:bg-white transition-all"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-450 block",children:"Redirect / Iframe Destination URL"}),s.jsx("input",{required:!0,type:"url",value:te,onChange:P=>le(P.target.value),placeholder:"https://example.com/varsity-store",className:"w-full px-4 py-3 bg-gray-50 border border-gray-250 rounded-xl outline-none text-sm font-bold placeholder:text-gray-300 focus:border-red-600 focus:bg-white transition-all"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-450 block",children:"SVG Icon Code or Preset Name (e.g. HTML SVG or SVG path code)"}),s.jsx("textarea",{value:ve,onChange:P=>ke(P.target.value),placeholder:"Paste your SVG tag structure or path code here, or tap preset clickers...",rows:2,className:"w-full px-4 py-3 bg-gray-50 border border-gray-250 rounded-xl outline-none text-xs font-mono placeholder:text-gray-300 focus:border-red-600 focus:bg-white transition-all resize-none"}),s.jsx("div",{className:"flex flex-wrap gap-1.5 pt-1",children:[{label:"⭐ Star",code:''},{label:"🔥 Hot",code:''},{label:"🏆 Trophy",code:''},{label:"🎓 Academy",code:''},{label:"🎫 Ticket",code:''}].map(P=>s.jsx("button",{type:"button",onClick:()=>ke(P.code),className:"px-2 py-1 bg-gray-100 hover:bg-black hover:text-white rounded-md text-[8px] font-black uppercase tracking-wider transition-all cursor-pointer border border-transparent hover:border-gray-300",children:P.label},P.label))})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 bg-gray-50/50 p-4 rounded-2xl border border-gray-150/40",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-red-650 block",children:"Experience Type / Media Format"}),s.jsxs("select",{value:Be,onChange:P=>J(P.target.value),className:"w-full px-4 py-3 bg-white border border-gray-250 rounded-xl outline-none text-xs font-bold focus:border-red-600 transition-all cursor-pointer",children:[s.jsx("option",{value:"link",children:"📎 Standard Embedded Page (IFrame Resource)"}),s.jsx("option",{value:"youtube",children:"🔴 YouTube Live Stream / Video Player (Theatre Layout)"}),s.jsx("option",{value:"custom_stream",children:"📺 Other Live Stream or Broadcast URL"})]})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-4 md:pt-6 pl-1",children:[s.jsx("input",{type:"checkbox",id:"custom-page-is-pinned",checked:ae,onChange:P=>Fe(P.target.checked),className:"w-4 h-4 text-red-650 border-gray-300 rounded focus:ring-red-500 cursor-pointer accent-red-650"}),s.jsx("label",{htmlFor:"custom-page-is-pinned",className:"text-[10px] font-black text-gray-700 uppercase tracking-wider cursor-pointer select-none",children:"📌 Pin as Live Stream Spotlight post"})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-450 block",children:"Short Overview description (shown beneath player)"}),s.jsx("input",{type:"text",value:ie,onChange:P=>xe(P.target.value),placeholder:"e.g. Catch the official live stream covering our campus tech marathon finals.",className:"w-full px-4 py-3 bg-gray-50 border border-gray-250 rounded-xl outline-none text-sm font-bold placeholder:text-gray-300 focus:border-red-600 focus:bg-white transition-all"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{type:"submit",disabled:Ct,className:"flex-1 py-3 bg-black hover:bg-red-650 text-white text-[10px] font-black uppercase tracking-widest rounded-xl transition-all disabled:opacity-50 flex items-center justify-center gap-2 cursor-pointer",children:Ct?"Processing...":pt?"Update Page Link":"Deploy Page to Menu"}),pt&&s.jsx("button",{type:"button",onClick:()=>{Ue(null),he(""),le("")},className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 text-gray-750 text-[10px] font-black uppercase tracking-widest rounded-xl transition-all cursor-pointer",children:"Cancel"})]})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-450",children:"Configured Global Pages"}),Q.length===0?s.jsxs("div",{className:"bg-white py-12 px-6 rounded-3xl border border-gray-100 text-center text-gray-400",children:[s.jsx(wd,{size:24,className:"mx-auto text-gray-300 mb-2"}),s.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider",children:"No custom pages are currently configured for user menus."})]}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Q.map(P=>{var xt;const De=Date.now()-((xt=P.createdAt)!=null&&xt.seconds?P.createdAt.seconds*1e3:Date.now())<10080*60*1e3;return s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-105 shadow-xs flex flex-col justify-between gap-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h5",{className:"font-extrabold text-sm text-gray-900",children:P.name}),De&&s.jsx("span",{className:"bg-red-100 text-red-750 px-2 py-0.5 rounded-full text-[8px] font-extrabold uppercase",children:"New"})]}),s.jsx("p",{className:"text-[10px] text-gray-400 font-mono truncate select-all",children:P.url})]}),s.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-50 pt-3",children:[s.jsx("button",{onClick:()=>Em(P),className:"p-2.5 bg-gray-50 hover:bg-gray-100 text-gray-700 hover:text-gray-950 rounded-lg transition-all cursor-pointer border border-gray-150",title:"Edit Custom Page",children:s.jsx(Ed,{size:12})}),s.jsx("button",{onClick:()=>Am(P.id),className:"p-2.5 bg-red-50 hover:bg-red-100 text-red-650 rounded-lg transition-all cursor-pointer border border-red-150",title:"Delete Custom Page",children:s.jsx(As,{size:12})})]})]},P.id)})})]})]}):a==="feedback-inbox"&&t?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"border-b border-gray-100 pb-4 max-w-3xl",children:[s.jsxs("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:[s.jsx(Js,{className:"text-accent",size:22})," User Feedback Inbox"]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Received comments, critiques, proposals, & systemic reports from campus readers"})]}),hi.length===0?s.jsxs("div",{className:"bg-white py-14 px-6 rounded-[2rem] border border-gray-150 text-center max-w-3xl",children:[s.jsx("div",{className:"w-16 h-16 bg-gray-50 rounded-full flex items-center justify-center mx-auto mb-4",children:s.jsx(Js,{size:24,className:"text-gray-300"})}),s.jsx("h4",{className:"text-sm font-black uppercase tracking-wider text-gray-900",children:"Inbox is empty"}),s.jsx("p",{className:"text-[10px] uppercase font-bold tracking-widest text-gray-400 mt-1",children:"No general user feedback submissions have been received yet."})]}):s.jsx("div",{className:"space-y-4 max-w-3xl",children:hi.map(P=>{var de,De,xt;return s.jsxs("div",{className:"bg-white p-6 rounded-[2rem] border border-gray-150 shadow-sm hover:shadow-md transition-all flex flex-col gap-4 text-left font-sans",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap pb-3 border-b border-gray-50",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-extrabold text-xs text-gray-900 uppercase tracking-wider",children:P.name||"Anonymous Reader"}),P.email&&s.jsx("span",{className:"text-[9px] font-mono text-gray-450 bg-gray-55/15 px-2 py-0.5 rounded-lg border border-gray-100",children:P.email})]}),s.jsxs("div",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-widest mt-0.5",children:["Subject: ",s.jsx("span",{className:"text-gray-700",children:P.subject||"General Feedback"})]})]}),(t||((De=(de=Ne.currentUser)==null?void 0:de.email)==null?void 0:De.toLowerCase())==="atwiinevictor2@gmail.com")&&s.jsx("button",{onClick:async()=>{if(!t){me.error("Access Denied: Only administrators can delete feedback.");return}if(window.confirm("Are you sure you want to permanently delete this user feedback entry?"))try{await ni(ot(pe,"feedback",P.id)),me.success("Feedback deleted successfully.")}catch(qt){me.error("Failed to delete feedback: "+qt.message)}},className:"p-2.5 bg-red-50 hover:bg-red-500 hover:text-white text-red-650 rounded-lg transition-all cursor-pointer border border-red-150",title:"Dismiss Feedback (Master Admin)",children:s.jsx(As,{size:12})})]}),s.jsx("div",{className:"text-xs text-gray-650 leading-relaxed whitespace-pre-wrap",children:P.message}),s.jsxs("div",{className:"text-[8px] font-black uppercase tracking-widest text-gray-400 font-mono text-right leading-none",children:["Received: ",(xt=P.createdAt)!=null&&xt.seconds?new Date(P.createdAt.seconds*1e3).toLocaleString():"Just now"]})]},P.id)})})]}):a==="manage-podcasts"&&t?s.jsxs("div",{className:"space-y-8 font-sans text-left",children:[s.jsx("div",{className:"border-b border-gray-100 pb-4 max-w-3xl",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"p-2 bg-red-50 text-red-600 rounded-xl",children:s.jsx(sc,{size:20})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:"Podcasts & Video Broadcasts Hub"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-0.5",children:"Publish Audio podcasts & Video episodes (YouTube, MP4, direct links) with visual media badges"})]})]})}),s.jsxs("div",{className:"bg-white p-6 rounded-[2rem] border border-gray-150 shadow-sm max-w-3xl",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4 pb-3 border-b border-gray-100",children:[s.jsx("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:Ro?`⚡ Edit ${re==="video"?"Video":"Audio"} Podcast`:`➕ Create New ${re==="video"?"Video":"Audio"} Podcast`}),Ro&&s.jsx("span",{className:"text-[9px] font-mono font-bold text-amber-700 bg-amber-50 px-2 py-0.5 rounded-lg border border-amber-200",children:"Editing Mode"})]}),s.jsxs("form",{onSubmit:Mf,className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500 flex items-center gap-1.5",children:["Select Media Format ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 p-1 bg-gray-50 rounded-2xl border border-gray-150",children:[s.jsxs("button",{type:"button",onClick:()=>{Oe("audio")},className:`flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl text-xs font-black uppercase tracking-wider transition-all cursor-pointer ${re==="audio"?"bg-emerald-600 text-white shadow-md":"text-gray-600 hover:text-gray-950 hover:bg-white/60"}`,children:[s.jsx(Qh,{size:15})," Audio Podcast"]}),s.jsxs("button",{type:"button",onClick:()=>{Oe("video")},className:`flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl text-xs font-black uppercase tracking-wider transition-all cursor-pointer ${re==="video"?"bg-red-600 text-white shadow-md":"text-gray-600 hover:text-gray-950 hover:bg-white/60"}`,children:[s.jsx(Aa,{size:15})," Video Podcast (YouTube/MP4)"]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsxs("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500",children:["Episode Title ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",required:!0,value:qe,onChange:P=>_(P.target.value),placeholder:re==="video"?"e.g. GUILD PRESIDENTIAL DEBATE HIGHLIGHTS":"e.g. THE TRUTH OF CAMPUS BUDGETS",className:"w-full px-4 py-2.5 rounded-xl border border-gray-150 text-xs text-gray-900 font-bold focus:border-accent focus:ring-0 outline-hidden bg-gray-50/50"})]}),s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsxs("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500",children:["Host / Presenter / Channel ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",required:!0,value:U,onChange:P=>H(P.target.value),placeholder:"e.g. Editorial Board / Campus TV",className:"w-full px-4 py-2.5 rounded-xl border border-gray-150 text-xs text-gray-900 font-bold focus:border-accent focus:ring-0 outline-hidden bg-gray-50/50"})]})]}),s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500 flex items-center gap-1.5",children:re==="video"?s.jsxs(s.Fragment,{children:[s.jsx(Aa,{size:12,className:"text-red-600"})," Video URL (YouTube, MP4, WebM, Google Drive, Direct Link) ",s.jsx("span",{className:"text-red-500",children:"*"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Qh,{size:12,className:"text-emerald-600"})," Audio Stream / MP3 / WAV Link ",s.jsx("span",{className:"text-red-500",children:"*"})]})}),re==="video"&&gp(_t)&&s.jsx("span",{className:"text-[8px] font-black uppercase text-red-600 bg-red-50 px-2 py-0.5 rounded border border-red-200",children:"✓ YouTube Link Detected"})]}),s.jsx("div",{className:"relative",children:s.jsx("input",{type:"url",required:!0,value:re==="video"?_t:We,onChange:P=>{const de=P.target.value;re==="video"?(qn(de),gp(de)&&!Qr&&Kr(Yv(de,"hq"))):(Ce(de),gp(de)&&(Oe("video"),qn(de),Ce(""),Qr||Kr(Yv(de,"hq")),me.success("YouTube link detected! Switched to Video Podcast format.",{icon:"🎬"})))},placeholder:re==="video"?"e.g. https://www.youtube.com/watch?v=... or https://youtu.be/... or .mp4 link":"e.g. https://example.com/podcast.mp3 or audio stream URL",className:"w-full px-4 py-2.5 rounded-xl border border-gray-150 text-xs text-gray-900 font-bold focus:border-accent focus:ring-0 outline-hidden bg-gray-50/50"})})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500",children:"Duration / Timestamp"}),s.jsx("input",{type:"text",required:!0,value:Nn,onChange:P=>Jn(P.target.value),placeholder:"e.g. 15:30 or 1h 05m",className:"w-full px-4 py-2.5 rounded-xl border border-gray-150 text-xs text-gray-900 font-bold focus:border-accent focus:ring-0 outline-hidden bg-gray-50/50"})]}),s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500",children:"Category"}),s.jsxs("select",{value:Br,onChange:P=>ki(P.target.value),className:"w-full px-4 py-2.5 rounded-xl border border-gray-150 text-xs text-gray-900 font-bold focus:border-accent focus:ring-0 outline-hidden bg-gray-50/50",children:[s.jsx("option",{value:"Campus News",children:"Campus News"}),s.jsx("option",{value:"Campus Vibe",children:"Campus Vibe"}),s.jsx("option",{value:"Investigation",children:"Investigation"}),s.jsx("option",{value:"Sports Desk",children:"Sports Desk"}),s.jsx("option",{value:"Lifestyle",children:"Lifestyle"}),s.jsx("option",{value:"Entertainment",children:"Entertainment"}),s.jsx("option",{value:"Special Report",children:"Special Report"})]})]})]}),s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500",children:"Episode Summary / Show Notes (Optional)"}),s.jsx("textarea",{rows:2,value:Xs,onChange:P=>Da(P.target.value),placeholder:"Add brief highlights, key interviewees, or discussion topics...",className:"w-full px-4 py-2.5 rounded-xl border border-gray-150 text-xs text-gray-900 font-medium focus:border-accent focus:ring-0 outline-hidden bg-gray-50/50"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 pt-1.5",children:[s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500",children:"Cover Picture (Upload)"}),s.jsx("input",{type:"file",accept:"image/*",onChange:P=>{var De;const de=(De=P.target.files)==null?void 0:De[0];de&&Ac(de,Kr,js)},className:"w-full text-xs text-gray-400 file:mr-4 file:py-2 file:px-4 file:rounded-xl file:border-0 file:text-[10px] file:font-black file:uppercase file:bg-gray-100 file:text-gray-700 hover:file:bg-gray-200 transition-all cursor-pointer"})]}),s.jsxs("div",{className:"space-y-1.5 text-left",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500",children:"Or Cover Picture Direct URL"}),re==="video"&&gp(_t)&&s.jsx("button",{type:"button",onClick:()=>{const P=Yv(_t,"maxres");Kr(P),me.success("Loaded HD YouTube thumbnail!",{icon:"🖼️"})},className:"text-[8px] font-black uppercase text-red-600 hover:underline cursor-pointer",children:"⚡ Auto-Fetch YouTube Thumbnail"})]}),s.jsx("input",{type:"url",value:Qr,onChange:P=>Kr(P.target.value),placeholder:"e.g. https://images.unsplash.com/photo-...",className:"w-full px-4 py-2.5 rounded-xl border border-gray-150 text-xs text-gray-950 font-bold focus:border-accent focus:ring-0 outline-hidden bg-gray-50/50"})]})]}),Qr&&s.jsxs("div",{className:"pt-2 flex items-center gap-3 bg-gray-50 p-2.5 rounded-2xl border border-gray-150",children:[s.jsx("img",{src:Qr,className:"w-16 h-12 rounded-xl object-cover border border-gray-150 shadow-xs",alt:"Preview cover",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[s.jsx("p",{className:"text-[9px] font-black text-gray-700 uppercase tracking-wider truncate",children:"Cover Image Loaded"}),s.jsx("p",{className:"text-[8px] font-mono text-gray-400 truncate",children:Qr})]}),s.jsx("button",{type:"button",onClick:()=>Kr(""),className:"text-[9px] font-black text-red-600 bg-red-50 hover:bg-red-100 px-3 py-1.5 rounded-lg uppercase tracking-wider transition-colors cursor-pointer",children:"Remove"})]}),s.jsxs("div",{className:"pt-4 flex items-center gap-3",children:[s.jsx("button",{type:"submit",disabled:Ci,className:"px-6 py-3 bg-red-600 text-white text-[10px] font-black uppercase tracking-widest rounded-xl hover:bg-red-700 transition-all flex items-center gap-2 cursor-pointer disabled:opacity-50 shadow-sm font-sans",children:Ci?s.jsxs(s.Fragment,{children:[s.jsx(Pr,{size:13,className:"animate-spin"})," Saving..."]}):s.jsxs(s.Fragment,{children:[re==="video"?s.jsx(Aa,{size:13}):s.jsx(sc,{size:13}),Ro?`Update ${re==="video"?"Video":"Audio"} Podcast`:`Publish ${re==="video"?"Video":"Audio"} Episode`]})}),Ro&&s.jsx("button",{type:"button",onClick:Df,className:"px-4 py-3 bg-gray-100 text-gray-700 text-[10px] font-black uppercase tracking-widest rounded-xl hover:bg-gray-200 transition-all cursor-pointer font-sans",children:"Cancel Edit"})]})]})]}),s.jsxs("div",{className:"max-w-3xl",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:["📻 Active Episodes (",Po.length,")"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-[9px] font-mono font-bold text-emerald-700 bg-emerald-50 px-2 py-0.5 rounded-md border border-emerald-200",children:["🎧 ",Po.filter(P=>!Dl(P)).length," Audio"]}),s.jsxs("span",{className:"text-[9px] font-mono font-bold text-red-700 bg-red-50 px-2 py-0.5 rounded-md border border-red-200",children:["🎬 ",Po.filter(P=>Dl(P)).length," Video"]})]})]}),Po.length===0?s.jsx("div",{className:"bg-gray-50 p-8 rounded-2xl border border-gray-150 text-center text-gray-400 text-[10px] font-bold uppercase tracking-wider",children:"No podcasts have been posted yet. Use the form above to add audio or video podcasts."}):s.jsx("div",{className:"space-y-3",children:Po.map(P=>{const de=Dl(P);return s.jsxs("div",{className:`bg-white p-4 rounded-2xl border transition-all text-left flex items-center gap-4 hover:shadow-xs ${de?"border-red-100 hover:border-red-300":"border-gray-150 hover:border-gray-300"}`,children:[s.jsxs("div",{className:"relative w-14 h-14 shrink-0 rounded-xl overflow-hidden bg-gray-900 border border-gray-100 shadow-3xs",children:[s.jsx("img",{src:P.thumbnail||(de?"https://images.unsplash.com/photo-1578022761797-b8636ac1773c?auto=format&fit=crop&q=80&w=200":"https://images.unsplash.com/photo-1590602847861-f357a9332bbc?auto=format&fit=crop&q=80&w=200"),className:"w-full h-full object-cover",alt:"",referrerPolicy:"no-referrer"}),s.jsxs("span",{className:`absolute bottom-1 right-1 text-[7px] font-black uppercase px-1 py-0.5 rounded flex items-center gap-0.5 text-white ${de?"bg-red-600":"bg-emerald-600"}`,children:[de?s.jsx(Aa,{size:7}):s.jsx(Qh,{size:7}),de?"VID":"AUD"]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-0.5 flex-wrap",children:[s.jsxs("span",{className:`text-[8px] font-black uppercase tracking-wider px-2 py-0.5 rounded-md flex items-center gap-1 border ${de?"bg-red-50 text-red-700 border-red-200":"bg-emerald-50 text-emerald-700 border-emerald-200"}`,children:[de?s.jsx(Aa,{size:10,className:"text-red-600"}):s.jsx(Qh,{size:10,className:"text-emerald-600"}),de?"Video Podcast":"Audio Podcast"]}),s.jsx("span",{className:"text-[8px] font-black text-gray-600 bg-gray-100 rounded px-1.5 py-0.5 uppercase tracking-wide",children:P.category||"Campus Vibe"}),s.jsxs("span",{className:"text-[8px] font-mono font-bold text-gray-400",children:["⏱️ ",P.duration||(de?"Video":"5:40")]})]}),s.jsx("h5",{className:"text-[12px] font-extrabold text-gray-950 truncate uppercase tracking-tight",children:P.title}),s.jsxs("p",{className:"text-[9px] text-gray-400 font-bold uppercase tracking-widest mt-0.5 truncate",children:["Host: ",P.author]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("button",{onClick:()=>el(P),className:`p-2.5 rounded-xl hover:scale-105 transition-all cursor-pointer border ${de?"bg-red-50 hover:bg-red-100 text-red-600 border-red-200":"bg-emerald-50 hover:bg-emerald-100 text-emerald-700 border-emerald-200"}`,title:de?"Watch Video Episode":"Listen to Audio Episode",children:de?s.jsx(Aa,{size:13}):s.jsx($p,{size:13,fill:"currentColor"})}),s.jsx("button",{onClick:()=>Al(P),className:"p-2.5 bg-gray-50 hover:bg-gray-100 text-gray-700 rounded-xl transition-all cursor-pointer border border-gray-200",title:"Edit podcast details",children:s.jsx(Ed,{size:13})}),s.jsx("button",{onClick:()=>Nm(P.id),className:"p-2.5 bg-red-50 hover:bg-red-100 text-red-650 rounded-xl transition-all cursor-pointer border border-red-150",title:"Delete podcast forever",children:s.jsx(As,{size:13})})]})]},P.id)})})]}),Wc&&s.jsx(J3,{podcast:Wc,onClose:()=>Kl(null)})]}):a==="mega-ai-knowledge"&&t?s.jsxs("div",{className:"space-y-8 font-sans text-left",children:[s.jsxs("div",{className:"border-b border-gray-100 pb-4 max-w-4xl",children:[s.jsxs("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900 flex items-center gap-2",children:[s.jsx(es,{className:"text-amber-500",size:22})," Mega AI Knowledge Base & Query Inbox"]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-1",children:"Manage collected smart replies for @Mega mentions, review missing query alerts, and reply to students directly."})]}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-xs space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-4",children:[s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:[s.jsx(Js,{size:16,className:"text-red-600"})," Pending Student @Mega Queries (",xa.filter(P=>!P.used).length,")"]}),s.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"Auto-notified on missing responses"})]}),xa.length===0?s.jsx("div",{className:"p-8 text-center text-gray-400 text-xs font-bold uppercase tracking-wider bg-gray-50/50 rounded-2xl border border-dashed border-gray-150",children:"No student @Mega queries pending review!"}):s.jsx("div",{className:"space-y-4",children:xa.map(P=>{var de;return s.jsxs("div",{className:Ge("p-5 rounded-2xl border transition-all space-y-3",P.used?"bg-gray-50/50 border-gray-150 opacity-75":"bg-amber-50/30 border-amber-200/80 shadow-xs"),children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase tracking-wider bg-amber-500 text-white px-2 py-0.5 rounded-full",children:["@",P.userName||"Student"]}),s.jsx("span",{className:"text-[10px] font-bold text-gray-400 font-mono",children:(de=P.createdAt)!=null&&de.seconds?new Date(P.createdAt.seconds*1e3).toLocaleString():"Recent"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:Ge("text-[9px] font-black uppercase tracking-widest px-2 py-0.5 rounded-md",P.used?"bg-emerald-100 text-emerald-800":"bg-red-100 text-red-800"),children:P.used?"Answered & Learned":"Pending Response"}),s.jsx("button",{type:"button",onClick:()=>Or(P.id),className:"p-1 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors cursor-pointer",title:"Dismiss & Delete Ticket Forever",children:s.jsx(As,{size:14})})]})]}),s.jsxs("div",{className:"bg-white p-3 rounded-xl border border-gray-150 text-xs text-gray-900 font-medium",children:[s.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest text-amber-600 block mb-1",children:"User Query:"}),'"',P.userQuery,'"']}),!P.used&&s.jsxs("div",{className:"space-y-2 pt-2",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-500 block",children:"Official Response (Will post to student as Mega AI & save into system smart replies):"}),s.jsx("textarea",{rows:2,value:E[P.id]!==void 0?E[P.id]:P.generatedReply||"",onChange:De=>S(xt=>({...xt,[P.id]:De.target.value})),placeholder:"Type the official answer here...",className:"w-full p-3 bg-white border border-gray-200 rounded-xl text-xs font-medium text-gray-900 focus:ring-2 focus:ring-amber-500/20 outline-none"}),s.jsx("div",{className:"flex justify-end",children:s.jsxs("button",{type:"button",onClick:()=>Qs(P),className:"inline-flex items-center gap-1.5 px-4 py-2 bg-amber-500 hover:bg-amber-600 text-white text-[10px] font-black uppercase tracking-wider rounded-xl transition-all shadow-xs cursor-pointer active:scale-95",children:[s.jsx(fl,{size:12})," Post Reply & Save to Smart Replies"]})})]})]},P.id)})})]}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-xs space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-4 flex-wrap gap-2",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:[s.jsx(pl,{size:18,className:"text-amber-600"})," Requests for Unlimited Posting Approval (",Do.length,")"]})}),Do.length>0&&s.jsxs("button",{type:"button",onClick:Rt,className:"px-3 py-1.5 bg-red-50 hover:bg-red-100 text-red-650 font-black text-[9px] uppercase tracking-wider rounded-xl transition-all cursor-pointer flex items-center gap-1 border border-red-200",children:[s.jsx(As,{size:12})," Clear All Requests (",Do.length,")"]})]}),Do.length===0?s.jsx("div",{className:"p-8 text-center text-gray-400 text-xs font-bold uppercase tracking-wider bg-gray-50/50 rounded-2xl border border-dashed border-gray-150",children:"No pending requests for unlimited posting approval."}):s.jsx("div",{className:"space-y-4",children:Do.map(P=>{var de;return s.jsxs("div",{className:"p-5 bg-amber-50/30 border border-amber-200/80 rounded-2xl space-y-3 shadow-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase tracking-wider bg-gray-900 text-amber-300 px-2 py-0.5 rounded-full",children:["@",P.requestAuthorName||P.userName||"Student"]}),s.jsxs("span",{className:"text-[9px] text-gray-400 font-mono",children:["UID: ",P.requestAuthorId||P.userId||"N/A"]})]}),s.jsx("span",{className:"text-[9px] font-bold text-gray-400 font-mono",children:(de=P.createdAt)!=null&&de.seconds?new Date(P.createdAt.seconds*1e3).toLocaleString():"Recent"})]}),s.jsx("div",{className:"bg-white p-3 rounded-xl border border-gray-150 text-xs text-gray-800 font-medium leading-relaxed",children:P.message||`User @${P.requestAuthorName||"Student"} requested admin approval to unlock unlimited posting on Campus Eye.`}),s.jsxs("div",{className:"flex items-center justify-end gap-2 pt-1",children:[s.jsxs("button",{type:"button",onClick:()=>$t(P.id),className:"px-3 py-1.5 bg-gray-100 hover:bg-gray-200 text-gray-700 font-black text-[9px] uppercase tracking-wider rounded-xl transition-all cursor-pointer flex items-center gap-1",children:[s.jsx(As,{size:12})," Dismiss & Delete"]}),s.jsxs("button",{type:"button",onClick:()=>Gt(P),className:"px-4 py-1.5 bg-amber-600 hover:bg-amber-700 text-white font-black text-[9px] uppercase tracking-wider rounded-xl shadow-xs transition-all cursor-pointer flex items-center gap-1.5 active:scale-95",children:[s.jsx(pl,{size:13})," Approve User for Unlimited Posting"]})]})]},P.id)})})]}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-xs space-y-4",children:[s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2 border-b border-gray-100 pb-3",children:[s.jsx(es,{size:16,className:"text-amber-500"})," Add New Smart Reply to Mega AI Knowledge Base"]}),s.jsxs("form",{onSubmit:yr,className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400 block",children:"Question / Trigger Prompt"}),s.jsx("input",{type:"text",value:Rr,onChange:P=>Kc(P.target.value),placeholder:"e.g. How do I register for KIU exams?",className:"w-full p-3 bg-gray-50 border border-gray-150 rounded-xl text-xs font-medium text-gray-900 focus:bg-white outline-none"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400 block",children:"Matching Keywords (Comma Separated)"}),s.jsx("input",{type:"text",value:p,onChange:P=>g(P.target.value),placeholder:"e.g. kiu, exam, registration, portal, schedule",className:"w-full p-3 bg-gray-50 border border-gray-150 rounded-xl text-xs font-medium text-gray-900 focus:bg-white outline-none"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400 block",children:"Smart Automated Answer"}),s.jsx("textarea",{rows:3,value:ee,onChange:P=>u(P.target.value),placeholder:"e.g. KIU exam registration is completed through the student portal under Academic Services before Week 8.",className:"w-full p-3 bg-gray-50 border border-gray-150 rounded-xl text-xs font-medium text-gray-900 focus:bg-white outline-none"})]}),s.jsx("div",{className:"flex justify-end",children:s.jsxs("button",{type:"submit",disabled:b,className:"inline-flex items-center gap-2 px-5 py-2.5 bg-black hover:bg-gray-800 text-white text-[10px] font-black uppercase tracking-wider rounded-xl transition-all shadow-sm cursor-pointer disabled:opacity-50",children:[s.jsx(es,{size:14,className:"text-amber-400"})," Save Smart Reply Entry"]})})]})]}),O&&s.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-xs z-50 flex items-center justify-center p-4",children:s.jsxs("div",{className:"bg-white rounded-3xl p-6 max-w-2xl w-full border border-gray-100 shadow-2xl space-y-5 animate-in fade-in zoom-in-95 duration-150",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-3",children:[s.jsxs("h4",{className:"text-sm font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:[s.jsx(Ed,{size:18,className:"text-indigo-600"})," Edit & Correct AI Knowledge Entry"]}),s.jsx("button",{type:"button",onClick:sa,className:"p-1.5 text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded-full transition-colors",children:s.jsx(er,{size:18})})]}),s.jsxs("form",{onSubmit:vi,className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-500 block",children:"Question / User Query"}),s.jsx("input",{type:"text",value:W,onChange:P=>ne(P.target.value),className:"w-full p-3 bg-gray-50 border border-gray-200 rounded-xl text-xs font-medium text-gray-900 focus:bg-white focus:ring-2 focus:ring-indigo-500/20 outline-none",placeholder:"e.g. How do I register for KIU exams?"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-500 block",children:"Matching Keywords (Comma Separated)"}),s.jsx("input",{type:"text",value:_e,onChange:P=>Ie(P.target.value),className:"w-full p-3 bg-gray-50 border border-gray-200 rounded-xl text-xs font-medium text-gray-900 focus:bg-white focus:ring-2 focus:ring-indigo-500/20 outline-none",placeholder:"e.g. kiu, exam, registration, portal"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-gray-500 block",children:"Corrected Official Answer"}),s.jsx("textarea",{rows:4,value:oe,onChange:P=>ye(P.target.value),className:"w-full p-3 bg-gray-50 border border-gray-200 rounded-xl text-xs font-medium text-gray-900 focus:bg-white focus:ring-2 focus:ring-indigo-500/20 outline-none leading-relaxed",placeholder:"Type the accurate smart answer here..."})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 pt-2",children:[s.jsx("button",{type:"button",onClick:sa,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 text-[10px] font-black uppercase tracking-wider rounded-xl transition-all",children:"Cancel"}),s.jsxs("button",{type:"submit",disabled:Ke,className:"inline-flex items-center gap-1.5 px-5 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-[10px] font-black uppercase tracking-wider rounded-xl transition-all shadow-sm disabled:opacity-50 cursor-pointer",children:[s.jsx(Q6,{size:14})," Update Knowledge Entry"]})]})]})]})}),s.jsxs("div",{className:"bg-white p-6 rounded-3xl border border-gray-100 shadow-xs space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-3 flex-wrap gap-2",children:[s.jsxs("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:[s.jsx(es,{size:16,className:"text-amber-500"})," System-Wide AI Knowledge & Responses (",Rf.length,")"]}),s.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase",children:"Editable by Admin in Realtime"})]}),Rf.length===0?s.jsx("p",{className:"text-xs font-bold text-gray-400 text-center py-6",children:"No smart replies or AI responses added yet. Add one above or trigger an @Mega AI query!"}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Rf.map(P=>s.jsxs("div",{className:"p-4 bg-gray-50/70 border border-gray-150 rounded-2xl flex flex-col justify-between space-y-3 hover:shadow-xs transition-shadow",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest px-2 py-0.5 rounded-full bg-amber-100 text-amber-900 border border-amber-200/60",children:P.source==="ai_generated"?"🤖 AI Generated":P.source==="admin_ticket_reply"?"👤 Admin Reply":"✨ Knowledge Base"}),P.askedBy&&s.jsxs("span",{className:"text-[8px] font-bold text-gray-400",children:["by @",P.askedBy]})]}),s.jsxs("span",{className:"text-[10px] font-black uppercase text-gray-900 tracking-wider block",children:["Q: ",P.question]})]}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.jsxs("button",{type:"button",onClick:()=>fo(P),className:"p-1.5 text-indigo-600 hover:text-indigo-800 hover:bg-indigo-50 rounded-lg transition-colors cursor-pointer flex items-center gap-1 text-[9px] font-black uppercase tracking-wider",title:"Edit & Update response",children:[s.jsx(Ed,{size:13})," Edit"]}),s.jsx("button",{type:"button",onClick:()=>vs(P.id),className:"p-1.5 text-red-500 hover:text-red-700 hover:bg-red-50 rounded-lg transition-colors cursor-pointer",title:"Delete response",children:s.jsx(As,{size:13})})]})]}),s.jsx("p",{className:"text-xs text-gray-800 font-medium leading-relaxed bg-white p-3 rounded-xl border border-gray-100",children:P.answer})]}),P.keywords&&P.keywords.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:P.keywords.map((de,De)=>s.jsxs("span",{className:"text-[8px] font-black uppercase tracking-widest bg-gray-200/60 text-gray-700 px-2 py-0.5 rounded-full",children:["#",de]},De))})]},P.id))})]})]}):s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[s.jsx("div",{className:"w-20 h-20 bg-gray-50 rounded-full flex items-center justify-center text-gray-300 mb-6",children:s.jsx(pl,{size:40})}),s.jsx("h3",{className:"text-xl font-sans font-extrabold uppercase tracking-tight text-gray-900",children:"Access Restricted"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-2 max-w-xs",children:"You don't have the necessary permissions to view this section. Please contact the administrator."})]})]})]})]})};let pk=null;const CMe=()=>{const[e,t]=se.useState(pk||[]),[n,r]=se.useState(!pk),[i,a]=se.useState(null),[o,c]=se.useState(1),[h,f]=se.useState(!1),[m,y]=se.useState(!1),[w,A]=se.useState(!1);se.useEffect(()=>{(async()=>{var q,Z,K,z;if(Ne.currentUser){const B=["atwiinevictor2@gmail.com","campuseye@gmail.com"];try{const V=await cs(ot(pe,"admins",Ne.currentUser.uid)),$=await cs(ot(pe,"users",Ne.currentUser.uid)),Q=V.exists()&&((q=V.data())==null?void 0:q.isAdmin)===!0||$.exists()&&(((Z=$.data())==null?void 0:Z.isAdmin)===!0||((K=$.data())==null?void 0:K.role)==="admin")||B.includes(Ne.currentUser.email||"");A(Q)}catch{A(B.includes(((z=Ne.currentUser)==null?void 0:z.email)||""))}}else A(!1)})()},[]);const k=L=>L?typeof L.toDate=="function"?L.toDate():L instanceof Date?L:L.seconds!==void 0?new Date(L.seconds*1e3):typeof L=="string"||typeof L=="number"?new Date(L):null:null,I=L=>{const q=k(L);if(!q)return"EVT";try{return q.toLocaleString("default",{month:"short"}).toUpperCase()}catch{return"EVT"}},T=L=>{const q=k(L);if(!q)return"00";try{return q.getDate()}catch{return"01"}},D=L=>{const q=k(L);if(!q)return"TBA";try{return q.toLocaleString([],{dateStyle:"medium",timeStyle:"short"})}catch{return"TBA"}};se.useEffect(()=>{const L=Qt(it(pe,"tickets"),pi("createdAt","desc"));vn(L).then(q=>{const Z=q.docs.map(K=>({id:K.id,...K.data()}));t(Z),pk=Z,r(!1)}).catch(q=>{Gs(q,Ps.LIST,"tickets"),r(!1)})},[]);const F=async()=>{var L,q,Z;if(!Ne.currentUser||!i){me.error("Please login to purchase tickets");return}if(o>i.remainingQuantity){me.error("Not enough tickets remaining");return}if(!Ne.currentUser){me.error("Please sign in to purchase tickets");return}f(!0);try{const K={ticketId:i.id,ticketTitle:i.title,userId:((L=Ne.currentUser)==null?void 0:L.uid)||"",userName:((q=Ne.currentUser)==null?void 0:q.displayName)||"Anonymous",userEmail:((Z=Ne.currentUser)==null?void 0:Z.email)||"",price:i.price,totalAmount:i.price*o,quantity:o,purchaseDate:jr.now(),status:"confirmed"};await ur(it(pe,"purchases"),K),await Hn(ot(pe,"tickets",i.id),{remainingQuantity:Ur(-o)}),me.success("Ticket purchased successfully!"),y(!0),setTimeout(()=>{y(!1),a(null),c(1)},3e3)}catch(K){console.error("Purchase error:",K),me.error("Failed to process purchase")}finally{f(!1)}};return n?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 gap-4",children:[s.jsx(Pr,{className:"animate-spin text-red-600",size:40}),s.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.2em] text-gray-400",children:"Loading Campus Events..."})]}):s.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:[s.jsxs("div",{className:"flex flex-col md:flex-row md:items-end justify-between gap-6 mb-12",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h2",{className:"text-4xl font-black uppercase italic tracking-tighter text-gray-900 flex items-center gap-4",children:["Campus Box Office ",s.jsx(No,{className:"text-red-600",size:32})]}),s.jsx("p",{className:"text-xs font-bold text-gray-400 uppercase tracking-[0.3em]",children:"Official portal for university events & experiences"})]}),s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:"bg-white px-6 py-4 border border-gray-100 rounded-3xl shadow-sm text-center min-w-[120px]",children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest mb-1",children:"Available Events"}),s.jsx("p",{className:"text-xl font-black text-gray-900",children:e.length})]}),s.jsxs("div",{className:"bg-black px-6 py-4 rounded-3xl shadow-xl shadow-black/10 text-center min-w-[120px]",children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest mb-1",children:"Status"}),s.jsx("p",{className:"text-xl font-black text-green-400",children:"SECURE"})]})]})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8",children:e.map(L=>s.jsxs(Kt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"group bg-white rounded-[2.5rem] border border-gray-100 shadow-sm hover:shadow-xl hover:-translate-y-1 transition-all overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"relative aspect-[4/3] overflow-hidden",children:[s.jsx(Vi,{src:L.imageUrl,alt:L.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"}),s.jsx("div",{className:"absolute top-4 right-4 px-3 py-1 bg-white/90 backdrop-blur-sm rounded-full text-[10px] font-black uppercase tracking-widest text-red-600 shadow-sm",children:L.category}),L.remainingQuantity<10&&L.remainingQuantity>0&&s.jsxs("div",{className:"absolute bottom-4 left-4 px-3 py-1 bg-red-600 text-white rounded-full text-[9px] font-black uppercase tracking-widest",children:["Only ",L.remainingQuantity," Left!"]}),L.remainingQuantity<=0&&s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-[2px] flex items-center justify-center",children:s.jsx("span",{className:"px-6 py-2 bg-white text-black text-sm font-black uppercase tracking-[0.3em] rounded-full",children:"Sold Out"})})]}),s.jsxs("div",{className:"p-8 flex-1 flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsxs("div",{className:"w-10 h-10 bg-red-50 text-red-600 rounded-xl flex flex-col items-center justify-center",children:[s.jsx("span",{className:"text-[10px] font-black leading-none",children:I(L.eventDate)}),s.jsx("span",{className:"text-sm font-black leading-none",children:T(L.eventDate)})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-xl font-black text-gray-900 uppercase tracking-tight truncate leading-tight",children:L.title}),s.jsxs("div",{className:"flex items-center gap-2 text-gray-400 mt-0.5",children:[s.jsx(vk,{size:12}),s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider truncate",children:L.venue})]})]})]}),s.jsx("p",{className:"text-sm text-gray-500 font-medium line-clamp-2 mb-6",children:L.description}),L.link&&s.jsx("div",{className:"mb-6 -mt-3",children:s.jsxs("a",{href:L.link,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-blue-650 font-black uppercase tracking-wider hover:underline",onClick:q=>q.stopPropagation(),children:[s.jsx("span",{children:"Visit Event Link"}),s.jsx(Fp,{size:14,className:"text-blue-600"})]})}),s.jsxs("div",{className:"mt-auto pt-6 border-t border-gray-50 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest mb-1 leading-none",children:"Public Price"}),s.jsxs("p",{className:"text-2xl font-black text-gray-900 leading-none",children:[s.jsx("span",{className:"text-sm",children:"UGX"})," ",L.price.toLocaleString()]})]}),s.jsx("button",{onClick:()=>a(L),disabled:L.remainingQuantity<=0,className:Ge("px-6 py-4 rounded-2xl text-[10px] font-black uppercase tracking-widest transition-all",L.remainingQuantity>0?"bg-red-600 text-white hover:bg-red-700 shadow-lg shadow-red-200":"bg-gray-100 text-gray-400 cursor-not-allowed"),children:"Book Ticket"})]}),w&&s.jsxs("div",{className:"mt-6 pt-4 border-t border-dashed border-gray-150 flex gap-3",children:[s.jsx("button",{onClick:q=>{q.stopPropagation(),localStorage.setItem("edit_ticket_item",JSON.stringify(L));const Z=new CustomEvent("setTab",{detail:"admin"});window.dispatchEvent(Z),setTimeout(()=>{window.dispatchEvent(new CustomEvent("checkPendingTicketEdit"))},100)},className:"flex-1 py-3 bg-blue-50 text-blue-600 rounded-xl text-[10px] font-black uppercase tracking-widest hover:bg-blue-600 hover:text-white transition-all text-center",children:"Edit Event"}),w&&s.jsx("button",{onClick:async q=>{if(q.stopPropagation(),!w){me.error("Access Denied: Only admins can delete tickets.");return}if(window.confirm("Are you sure you want to permanently delete this event ticket?"))try{await ni(ot(pe,"tickets",L.id)),me.success("Event ticket deleted successfully"),t(Z=>Z.filter(K=>K.id!==L.id))}catch(Z){me.error("Failed to delete event ticket: "+Z.message)}},className:"flex-1 py-3 bg-red-50 text-red-650 rounded-xl text-[10px] font-black uppercase tracking-widest hover:bg-red-600 hover:text-white transition-all text-center",title:"Delete Ticket (Master Admin)",children:"Delete"})]})]})]},L.id))}),s.jsx(ar,{children:i&&s.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[s.jsx(Kt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>!h&&a(null),className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),s.jsx(Kt.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},className:"relative w-full max-w-xl bg-white rounded-[3rem] shadow-2xl overflow-hidden",children:m?s.jsxs("div",{className:"p-12 text-center space-y-6",children:[s.jsx("div",{className:"w-20 h-20 bg-green-100 text-green-600 rounded-full flex items-center justify-center mx-auto scale-110",children:s.jsx(Pu,{size:48,strokeWidth:3})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"text-3xl font-black uppercase italic tracking-tighter text-gray-900",children:"Ticket Secured!"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-[0.3em]",children:"Transaction verified & recorded"})]}),s.jsx("p",{className:"text-sm text-gray-600 font-medium max-w-xs mx-auto",children:"Your digital ticket has been sent to your account. Please present the QR code at the venue."}),s.jsx("div",{className:"pt-4",children:s.jsx("button",{onClick:()=>a(null),className:"px-8 py-4 bg-black text-white rounded-2xl text-[10px] font-black uppercase tracking-widest hover:bg-gray-900 transition-all",children:"Close Window"})})]}):s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"relative h-48",children:[s.jsx(Vi,{src:i.imageUrl,className:"w-full h-full object-cover",alt:""}),s.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-white via-white/20 to-transparent"}),s.jsx("button",{onClick:()=>a(null),disabled:h,className:"absolute top-6 right-6 p-3 bg-white/90 backdrop-blur-sm rounded-2xl text-gray-900 hover:bg-white transition-all shadow-lg",children:s.jsx(er,{size:20})})]}),s.jsx("div",{className:"p-10 -mt-20 relative",children:s.jsxs("div",{className:"bg-white p-8 rounded-[2rem] border border-gray-100 shadow-xl space-y-6",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-[10px] font-black text-red-600 uppercase tracking-[0.2em]",children:i.category}),s.jsx("h2",{className:"text-3xl font-black text-gray-900 uppercase tracking-tighter leading-tight",children:i.title})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-gray-50 rounded-xl",children:s.jsx(H0,{size:18,className:"text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Date & Time"}),s.jsx("p",{className:"text-xs font-black text-gray-900 uppercase",children:D(i.eventDate)})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-gray-50 rounded-xl",children:s.jsx(vk,{size:18,className:"text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Location"}),s.jsx("p",{className:"text-xs font-black text-gray-900 uppercase",children:i.venue})]})]})]}),s.jsxs("div",{className:"space-y-4 pt-6 border-t border-gray-100",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm font-black text-gray-900 uppercase tracking-widest",children:"Select Quantity"}),s.jsxs("div",{className:"flex items-center gap-4 bg-gray-50 p-2 rounded-2xl border border-gray-100",children:[s.jsx("button",{onClick:()=>c(Math.max(1,o-1)),className:"w-10 h-10 flex items-center justify-center text-xl font-bold bg-white text-gray-900 rounded-xl hover:bg-gray-200 transition-all shadow-sm",children:"-"}),s.jsx("span",{className:"text-xl font-black text-gray-900 w-8 text-center",children:o}),s.jsx("button",{onClick:()=>c(Math.min(i.remainingQuantity,o+1)),className:"w-10 h-10 flex items-center justify-center text-xl font-bold bg-white text-gray-900 rounded-xl hover:bg-gray-200 transition-all shadow-sm",children:"+"})]})]}),s.jsxs("div",{className:"bg-red-50 p-6 rounded-2xl border border-red-100 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-black text-red-400 uppercase tracking-widest mb-1 leading-none",children:"Total Payable"}),s.jsxs("p",{className:"text-3xl font-black text-red-600 leading-none tracking-tighter",children:[s.jsx("span",{className:"text-sm",children:"UGX"})," ",(i.price*o).toLocaleString()]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-[10px] font-black text-red-600/50 uppercase tracking-widest",children:"Digital Entry"}),s.jsx("div",{className:"flex gap-1 mt-1",children:[1,2,3].map(L=>s.jsx("div",{className:"w-6 h-1 bg-red-600/20 rounded-full"},L))})]})]})]}),s.jsx("button",{onClick:F,disabled:h,className:"w-full py-5 bg-red-600 text-white rounded-2xl text-[10px] font-black uppercase tracking-[0.3em] hover:bg-red-700 transition-all shadow-xl shadow-red-200 disabled:opacity-50 flex items-center justify-center gap-3",children:h?s.jsxs(s.Fragment,{children:[s.jsx(Pr,{className:"animate-spin",size:20}),"Authorizing Transaction..."]}):s.jsxs(s.Fragment,{children:[s.jsx(pl,{size:20}),"Confirm Booking"]})})]})})]})})]})})]})},OV=({onAuthSuccess:e,onClose:t,className:n,isAdmin:r,onAdminClick:i})=>{const[a,o]=se.useState(Ne.currentUser),[c,h]=se.useState(null);se.useEffect(()=>{try{const Ye=localStorage.getItem("pending_follow_name");Ye&&h(Ye)}catch{}},[]);const[f,m]=se.useState(!1),[y,w]=se.useState("signin"),[A,k]=se.useState(""),[I,T]=se.useState(""),[D,F]=se.useState(!1),[L,q]=se.useState(""),[Z,K]=se.useState(!1),[z,B]=se.useState(""),[V,$]=se.useState(""),[Q,Y]=se.useState(""),[G,he]=se.useState(!1),[te,le]=se.useState(null),[ve,ke]=se.useState(null),[Be,J]=se.useState(!1);se.useEffect(()=>{if(y!=="signup"||!V.trim()){ke(null),J(!1);return}const Yt=setTimeout(async()=>{J(!0);try{const dt=V.trim().toLowerCase();if(dt.length<3){ke(!1),J(!1);return}const sn=Qt(it(pe,"users"),Nr("username","==",dt)),pn=await vn(sn);ke(pn.empty)}catch(dt){console.warn("Username availability check bypassed:",dt),ke(!0)}finally{J(!1)}},400);return()=>clearTimeout(Yt)},[V,y]);const ie=A.includes("@")&&A.includes("."),xe=I.length===0?0:I.length<6?1:I.length<10?2:3,ae=I.length>=6,Fe=I===L,pt=y==="signin"?ie&&ae:ie&&ae&&V.trim().length>=3&&ve===!0&&Fe;se.useEffect(()=>Ne.onAuthStateChanged(Ye=>o(Ye)),[]);const Ue=async()=>{m(!0),le(null);try{const Ye=await Qoe(Ne,MG);await Tt(Ye.user),e&&e()}catch(Ye){if(console.error("Error signing in with Google:",Ye),Ye.code==="auth/popup-closed-by-user")le("Sign-in popup was closed. Please try again or create an Email account below.");else if(Ye.code==="auth/popup-blocked"||Ye.code==="auth/disallowed_useragent")le(s.jsxs("div",{className:"space-y-3 text-left",children:[s.jsx("p",{className:"font-bold text-gray-900 text-xs",children:"Google OAuth is restricted inside embedded preview frames or mobile WebViews."}),s.jsxs("p",{className:"text-[10px] text-gray-600 leading-relaxed",children:["Please open the app in a new browser window/tab to sign in with Google, or log in using ",s.jsx("b",{className:"text-red-600",children:"Email & Password"})," below."]}),s.jsxs("div",{className:"flex flex-col gap-2 pt-1",children:[s.jsx("button",{type:"button",onClick:()=>window.open(window.location.href,"_blank"),className:"w-full py-2 bg-indigo-600 text-white text-[10px] font-black uppercase tracking-widest rounded-lg hover:bg-indigo-700 transition-all cursor-pointer shadow-sm",children:"Open App in New Tab to Sign In"}),s.jsx("button",{type:"button",onClick:()=>w("signup"),className:"w-full py-2 bg-gray-100 text-gray-800 text-[10px] font-black uppercase tracking-widest rounded-lg hover:bg-gray-200 transition-all cursor-pointer",children:"Create Email Account (Instant Login)"})]})]}));else if(Ye.code==="auth/unauthorized-domain")le(s.jsxs("div",{className:"space-y-2 text-left",children:[s.jsx("p",{className:"font-bold text-red-600 text-xs",children:"Domain authorization check required."}),s.jsxs("p",{className:"text-[10px] text-gray-600 leading-relaxed",children:["Security policy requires running from an authorized domain (",window.location.hostname,"). You can log in using ",s.jsx("b",{className:"text-red-600",children:"Email & Password"})," below."]})]}));else if(Ye.code==="auth/internal-error"||Ye.code==="auth/network-request-failed")le(s.jsxs("div",{className:"space-y-3 text-left",children:[s.jsx("p",{className:"text-xs text-gray-800",children:"Connection error. If using an embedded frame, try opening in a new browser tab."}),s.jsxs("div",{className:"flex flex-col gap-2 pt-1",children:[s.jsx("button",{type:"button",onClick:()=>window.open(window.location.href,"_blank"),className:"w-full py-2 bg-indigo-600 text-white text-[10px] font-black uppercase tracking-widest rounded-lg hover:bg-indigo-700 transition-all cursor-pointer shadow-sm",children:"Open in New Tab & Try Google Login"}),s.jsx("button",{type:"button",onClick:()=>w("signup"),className:"w-full py-2 bg-gray-100 text-gray-800 text-[10px] font-black uppercase tracking-widest rounded-lg hover:bg-gray-200 transition-all cursor-pointer",children:"Sign Up with Email & Password"})]})]}));else if(Ye.code==="auth/operation-not-allowed")le("Google Sign-In is temporarily disabled on this domain. Please log in or register with Email & Password.");else{const Yt=(Ye.message||"").replace(/firebase/gi,"Campus Eye Auth").replace(/auth\/[a-z-]+/gi,"Login Service");le(Yt||"An unexpected error occurred during Google Sign-In.")}}finally{m(!1)}},Ct=async Ye=>{Ye.preventDefault(),m(!0),le(null);try{if(y==="signup"){const Yt=V.trim().toLowerCase(),dt=await koe(Ne,A,I),sn=`https://ui-avatars.com/api/?name=${encodeURIComponent(Yt||"User")}&background=random`;await JF(dt.user,{displayName:Yt,photoURL:sn}),await Tt({...dt.user,photoURL:sn},Yt,Yt),localStorage.setItem("just_signed_up","true")}else{const Yt=await Coe(Ne,A,I);await Tt(Yt.user)}e&&e()}catch(Yt){console.error("Email auth error:",Yt),le(y==="signin"?"Wrong password or email":Yt.message||"An error occurred during registration.")}finally{m(!1)}},Tt=async(Ye,Yt,dt)=>{var sn,pn,Fn,Ft,Dt,Ht,Ze,Wt,It,ln;try{const Kn=ot(pe,"users",Ye.uid),un=await cs(Kn),Ve=["atwiinevictor2@gmail.com","campuseye@gmail.com"].includes(Ye.email||""),Ot={uid:Ye.uid,email:Ye.email||"",displayName:Yt||Ye.displayName||((sn=un.data())==null?void 0:sn.displayName)||"Campus Member",username:dt||((pn=un.data())==null?void 0:pn.username)||((Fn=Ye.email)==null?void 0:Fn.split("@")[0])||"user",photoURL:Ye.photoURL||((Ft=un.data())==null?void 0:Ft.photoURL)||`https://ui-avatars.com/api/?name=${encodeURIComponent(Yt||Ye.displayName||"User")}&background=random`,role:((Dt=un.data())==null?void 0:Dt.role)||(Ve?"admin":"user"),isAdmin:((Ht=un.data())==null?void 0:Ht.isAdmin)??Ve,createdAt:((Ze=un.data())==null?void 0:Ze.createdAt)||Bn(),updatedAt:Bn()};await Hr(Kn,Ot,{merge:!0}),(Ve||(Wt=un.data())!=null&&Wt.isAdmin)&&await Hr(ot(pe,"admins",Ye.uid),{email:Ye.email||"",isAdmin:!0,createdAt:((It=un.data())==null?void 0:It.createdAt)||Bn()},{merge:!0})}catch(Kn){if(Kn.code==="permission-denied"||(ln=Kn.message)!=null&&ln.includes("insufficient permissions")){const un={error:Kn.message,operationType:"write",path:`users/${Ye.uid}`,authInfo:{userId:Ye.uid,email:Ye.email,emailVerified:Ye.emailVerified}};console.error("Firestore Permission Error:",JSON.stringify(un))}else console.error("Error syncing user to Firestore:",Kn)}},ht=se.useRef(!1);return se.useEffect(()=>{a&&!ht.current&&(ht.current=!0,e?e():t&&t())},[a]),a?s.jsxs("div",{className:"flex flex-col items-center justify-center p-12 bg-white rounded-3xl shadow-xl border border-gray-100 min-h-[300px]",children:[s.jsx(Pr,{className:"animate-spin text-red-650 mb-3",size:32}),s.jsx("p",{className:"text-xs font-black uppercase tracking-widest text-[#9B2C2C]",children:"Accessing Campus Feed..."})]}):s.jsxs("div",{className:Ge("flex flex-col w-full max-w-lg mx-auto bg-white overflow-y-auto max-h-[88vh] custom-scrollbar relative shadow-2xl rounded-3xl border border-gray-100",n),children:[t&&s.jsx("button",{onClick:t,className:"absolute top-4 right-4 p-2 text-gray-400 hover:text-red-600 transition-all hover:rotate-90 z-30 bg-gray-50 hover:bg-red-50 rounded-full",title:"Close Modal",children:s.jsx(er,{size:20})}),s.jsxs("div",{className:"relative z-10 flex flex-col items-center p-6 md:p-8 space-y-5",children:[s.jsxs(Kt.div,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},className:"flex flex-col items-center space-y-2 text-center",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1 select-none",children:[s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"Campus Eye Media Logo",className:"h-11 w-11 rounded-full border border-gray-950 object-cover shadow-sm shrink-0",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"flex flex-col text-left -space-y-1",children:[s.jsxs("span",{className:"text-base font-serif font-black italic",children:[s.jsx("span",{className:"text-red-650",children:"Campus"})," ",s.jsx("span",{className:"text-blue-600",children:"Eye"})]}),s.jsx("span",{className:"text-[7.5px] font-sans font-extrabold uppercase tracking-[0.25em] text-black",children:"Media"})]})]}),s.jsx("h3",{className:"text-2xl font-bold text-gray-900 tracking-tight",children:y==="signin"?"Welcome Back":"Create Account"}),s.jsx("p",{className:"text-sm text-gray-500",children:y==="signin"?"Enter your details to access your account":"Join our community of campus citizens"})]}),s.jsxs("div",{className:"flex w-full bg-gray-50 rounded-xl p-1 border border-gray-100",children:[s.jsx("button",{onClick:()=>w("signin"),className:Ge("flex-1 py-2.5 text-xs font-semibold rounded-lg transition-all duration-300",y==="signin"?"bg-white text-red-600 shadow-sm":"text-gray-500 hover:text-gray-700"),children:"Login"}),s.jsx("button",{onClick:()=>w("signup"),className:Ge("flex-1 py-2.5 text-xs font-semibold rounded-lg transition-all duration-300",y==="signup"?"bg-white text-red-600 shadow-sm":"text-gray-500 hover:text-gray-700"),children:"Sign Up"})]}),s.jsxs("div",{className:"w-full space-y-8",children:[c&&s.jsxs(Kt.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"p-3.5 bg-emerald-50 text-emerald-800 text-[10px] font-bold tracking-tight rounded-2xl flex items-start gap-2.5 border border-emerald-100 text-left",children:[s.jsx("span",{className:"text-sm shrink-0",children:"🤝"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-extrabold uppercase text-[7.5px] tracking-[0.15em] text-emerald-600 mb-0.5",children:"Connection Action Pending"}),s.jsxs("p",{className:"font-sans text-gray-700 leading-snug",children:["Follow relation with ",s.jsxs("b",{className:"text-gray-950 font-black",children:["@",c.toLowerCase().replace(/\s+/g,"")]})," will activate instantly across all services as soon as you continue and log in below."]})]})]}),te&&s.jsx(Kt.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"p-4 bg-red-50 text-red-600 text-[10px] font-black uppercase tracking-widest leading-relaxed rounded-2xl text-center shadow-sm border border-red-100",children:te}),s.jsxs("form",{onSubmit:Ct,className:"space-y-5",children:[y==="signup"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"username",className:"text-xs font-semibold text-gray-700 ml-1",children:"Username"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",id:"username",required:!0,value:V,onChange:Ye=>$(Ye.target.value),className:Ge("w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl outline-none text-sm transition-all text-gray-900 focus:bg-white focus:border-red-600 placeholder:text-gray-400",V&&ve===!1&&"border-red-500 bg-red-50/30",V&&ve===!0&&"border-green-500 bg-green-50/30"),placeholder:"e.g. campus_hero"}),V.trim()&&s.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2",children:Be?s.jsx(Pr,{className:"animate-spin text-gray-400",size:16}):ve===!0?s.jsx("span",{className:"text-green-600 font-bold uppercase text-[9px] tracking-wider",children:"Available"}):ve===!1?s.jsx("span",{className:"text-red-500 font-bold uppercase text-[9px] tracking-wider",children:"Taken"}):null})]}),V.trim()&&!Be&&s.jsx("p",{className:Ge("text-[10px] font-medium ml-1",ve===!0?"text-green-600":"text-red-500"),children:ve===!0?"✓ Username is available!":"✗ This username is already taken. Try another!"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"email",className:"text-xs font-semibold text-gray-700 ml-1",children:y==="signin"?"Email / Username":"Email Address"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"email",id:"email",required:!0,value:A,onChange:Ye=>k(Ye.target.value),className:Ge("w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl outline-none text-sm transition-all text-gray-900 focus:bg-white focus:border-red-600 placeholder:text-gray-400",A&&!ie&&"border-red-500 bg-red-50/30"),placeholder:"Enter your email address"}),A&&s.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2",children:ie?s.jsx(Xh,{className:"text-green-500",size:16}):s.jsx(tF,{className:"text-red-500",size:16})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"password",className:"text-xs font-semibold text-gray-700 ml-1",children:"Password"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:D?"text":"password",id:"password",required:!0,value:I,onChange:Ye=>T(Ye.target.value),className:"w-full px-4 py-3 pr-11 bg-gray-50 border border-gray-200 rounded-xl outline-none text-sm transition-all text-gray-900 focus:bg-white focus:border-red-600 placeholder:text-gray-400",placeholder:"••••••••"}),s.jsx("button",{type:"button",onClick:()=>F(!D),className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700 p-1 transition-colors cursor-pointer",title:D?"Hide Password":"Show Password",children:D?s.jsx(W6,{size:18}):s.jsx(Rw,{size:18})})]}),y==="signup"&&I.length>0&&s.jsxs("div",{className:"px-2 space-y-1",children:[s.jsx("div",{className:"flex gap-1 h-1",children:[1,2,3].map(Ye=>s.jsx("div",{className:Ge("flex-1 rounded-full transition-all duration-500",xe>=Ye?xe===1?"bg-red-500":xe===2?"bg-yellow-500":"bg-green-500":"bg-gray-100")},Ye))}),s.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400",children:xe===1?"Weak":xe===2?"Good":"Strong"})]})]}),y==="signup"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"confirmPassword",className:"text-xs font-semibold text-gray-700 ml-1",children:"Confirm Password"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:Z?"text":"password",id:"confirmPassword",required:!0,value:L,onChange:Ye=>q(Ye.target.value),className:Ge("w-full px-4 py-3 pr-11 bg-gray-50 border border-gray-200 rounded-xl outline-none text-sm transition-all text-gray-900 focus:bg-white focus:border-red-600 placeholder:text-gray-400",L&&!Fe&&"border-red-500 bg-red-50/30",L&&Fe&&"border-green-500 bg-green-50/30"),placeholder:"••••••••"}),s.jsx("button",{type:"button",onClick:()=>K(!Z),className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700 p-1 transition-colors cursor-pointer",title:Z?"Hide Password":"Show Password",children:Z?s.jsx(W6,{size:18}):s.jsx(Rw,{size:18})})]}),L&&s.jsx("p",{className:Ge("text-[10px] font-medium ml-1",Fe?"text-green-600":"text-red-500"),children:Fe?"✓ Passwords match!":"✗ Passwords do not match"})]}),y==="signin"&&s.jsx("div",{className:"flex justify-end px-2",children:s.jsx("button",{type:"button",className:"text-[10px] font-black uppercase tracking-widest text-gray-400 hover:text-red-600 transition-colors",children:"Forgot Password?"})}),s.jsx("div",{className:"pt-2",children:s.jsx(Kt.button,{whileHover:pt?{scale:1.01}:{},whileTap:pt?{scale:.99}:{},type:"submit",disabled:f||!pt,className:Ge("w-full flex items-center justify-center gap-3 py-4 px-8 rounded-xl transition-all font-bold text-sm tracking-wide disabled:opacity-50",pt?"bg-red-600 text-white hover:bg-red-700 shadow-lg shadow-red-600/20":"bg-gray-100 text-gray-400 cursor-not-allowed"),children:f?s.jsx(Pr,{className:"animate-spin",size:20}):s.jsx("span",{children:y==="signin"?"Login":"Create Account"})})})]}),s.jsxs("div",{className:"text-center space-y-6",children:[s.jsxs("div",{className:"relative flex items-center py-4",children:[s.jsx("div",{className:"flex-grow border-t border-gray-100"}),s.jsx("span",{className:"flex-shrink mx-6 text-[10px] uppercase font-black tracking-[0.4em] text-gray-300",children:"Or"}),s.jsx("div",{className:"flex-grow border-t border-gray-100"})]}),s.jsxs(Kt.button,{whileHover:{backgroundColor:"rgba(0, 0, 0, 0.02)"},onClick:Ue,disabled:f,className:"w-full flex items-center justify-center gap-3 bg-white border border-gray-200 text-gray-700 py-3.5 px-8 rounded-xl transition-all font-semibold text-sm",children:[s.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[s.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),s.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),s.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l3.66-2.84z"}),s.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),s.jsx("span",{className:"font-black uppercase text-[11px] tracking-[0.2em]",children:"Continue with Google"})]}),c&&s.jsxs("div",{className:"pt-2 flex flex-col items-center justify-center space-y-2 select-none",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-red-100 flex items-center justify-center shadow-xs border border-red-200",children:s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",className:"w-6 h-6 rounded-full object-cover border border-gray-900",alt:"Campus Eye Logo",referrerPolicy:"no-referrer"})}),s.jsx("p",{className:"text-[7.5px] font-mono text-gray-400 uppercase tracking-widest leading-none",children:"Authorized Redirect Portal"})]})]})]})]})]})},IMe=()=>{const[e,t]=j.useState(!1),[n,r]=j.useState(!1);j.useEffect(()=>{const o=()=>{r(window.innerWidth<768)};return o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]);const i=[{name:"Threads",url:"https://www.threads.com/@campuseyemedia_",color:"bg-black text-white hover:bg-zinc-800 border-zinc-700",icon:s.jsx(eF,{size:16,strokeWidth:2.5})},{name:"YouTube",url:"https://youtube.com/@campuseye_media?si=gLddUotgI7D0n3cL",color:"bg-[#FF0000] text-white hover:bg-[#CC0000] border-red-500",icon:s.jsx(hF,{size:16})},{name:"LinkedIn",url:"https://www.linkedin.com/in/campuseyemedia?utm_source=share_via&utm_content=profile&utm_medium=member_android",color:"bg-[#0077B5] text-white hover:bg-[#005582] border-blue-600",icon:s.jsx(aF,{size:16})},{name:"Instagram",url:"https://www.instagram.com/campuseyemedia_?igsh=MXV6ejUyM2J3MnhsNA==",color:"bg-gradient-to-tr from-[#f9ce34] via-[#ee2a7b] to-[#6228d7] text-white hover:brightness-110 border-pink-500",icon:s.jsx(sF,{size:16})},{name:"X",url:"https://x.com/campuseye_media",color:"bg-black text-white hover:bg-zinc-800 border-zinc-700",icon:s.jsx(aq,{size:14,className:"text-white"})},{name:"Facebook",url:"https://www.facebook.com/share/1FivBManaT/",color:"bg-[#1877F2] text-white hover:bg-[#1258b3] border-blue-500",icon:s.jsx(rF,{size:16})},{name:"TikTok",url:"https://www.tiktok.com/@campuseye_media?_r=1&_t=ZS-96ci42CXliv",color:"bg-[#000000] text-white hover:bg-zinc-900 border-red-500",icon:s.jsx(oq,{size:14,className:"text-white"})},{name:"WhatsApp",url:"https://whatsapp.com/channel/0029Vb6OR49CXC3C5hCVlv3Q",color:"bg-[#25D366] text-white hover:bg-[#1ebe5d] border-green-500",icon:s.jsx(G0,{size:16})}],a=(o,c)=>{const h=n?145:195,f=180,y=270-f,A=(f+o/(c-1)*y)*Math.PI/180;return{x:h*Math.cos(A),y:h*Math.sin(A)}};return s.jsxs("div",{className:"fixed bottom-18 md:bottom-8 right-6 md:right-8 z-[1051] flex items-center justify-center",children:[e&&s.jsx("div",{onClick:()=>t(!1),className:"fixed inset-0 bg-transparent cursor-default"}),s.jsx(ar,{children:e&&i.map((o,c)=>{const{x:h,y:f}=a(c,i.length);return s.jsxs(Kt.a,{href:o.url,target:"_blank",rel:"noopener noreferrer",initial:{x:0,y:0,scale:0,opacity:0},animate:{x:h,y:f,scale:1,opacity:1,transition:{type:"spring",stiffness:300,damping:18,delay:c*.035}},exit:{x:0,y:0,scale:0,opacity:0,transition:{duration:.15,delay:(i.length-1-c)*.02}},whileHover:{scale:1.15,zIndex:100},whileTap:{scale:.9},className:Ge("absolute w-10 h-10 md:w-11 md:h-11 rounded-full flex items-center justify-center border border-white/25 shadow-lg shadow-black/30 cursor-pointer text-white hover:scale-110 active:scale-95 transition-shadow select-none",o.color),children:[s.jsx("div",{className:"absolute opacity-0 hover:opacity-100 md:group-hover:opacity-100 transition-opacity bg-black/80 backdrop-blur-md text-white text-[9px] font-black uppercase tracking-wider py-1 px-2 rounded-md -top-8 pointer-events-none whitespace-nowrap border border-zinc-700 shadow-xl",children:o.name}),o.icon]},o.name)})}),s.jsx(Kt.button,{onClick:()=>t(!e),whileHover:{scale:1.08},whileTap:{scale:.92},className:Ge("w-10 h-10 md:w-11 md:h-11 rounded-full flex items-center justify-center cursor-pointer shadow-xl select-none transition-all border outline-none duration-300 z-[1052]",e?"bg-red-600 border-red-500 text-white shadow-red-600/30 rotate-180":"bg-white border-gray-150 text-[#af05ea] hover:bg-gray-50 shadow-purple-600/10"),children:s.jsx(ar,{mode:"wait",children:e?s.jsx(Kt.div,{initial:{rotate:-90,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:90,opacity:0},transition:{duration:.2},children:s.jsx(er,{size:16,strokeWidth:2.5})},"close-icon"):s.jsx(Kt.div,{initial:{rotate:90,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:-90,opacity:0},transition:{duration:.2},className:"relative flex items-center justify-center p-0.5",children:s.jsx(kpe,{size:18,className:"relative z-10"})},"share-icon")})})]})},jMe=({articles:e})=>{const[t,n]=se.useState(0),r=se.useMemo(()=>e.filter(h=>h&&h.id),[e]);if(se.useEffect(()=>{if(r.length<2)return;const h=setInterval(()=>{n(f=>(f+2)%r.length)},6e3);return()=>clearInterval(h)},[r]),r.length<2)return null;const i=r[t%r.length],a=r[(t+1)%r.length],o=[i,a].filter(Boolean),c=h=>{const f=new CustomEvent("selectArticle",{detail:h});window.dispatchEvent(f)};return s.jsx("div",{className:"w-full bg-gradient-to-r from-gray-50 via-white to-gray-50 border-b border-gray-100 py-3.5 select-none",children:s.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 flex flex-col md:flex-row items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-2.5 shrink-0 self-start md:self-auto",children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1 bg-red-50 text-red-650 rounded-lg border border-red-200/60 shadow-2xs",children:[s.jsx(fF,{size:13,className:"animate-pulse"}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest",children:"Live Wire"})]}),s.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-gray-500 hidden lg:inline",children:"Campus Dispatches"})]}),s.jsx(ar,{mode:"wait",children:s.jsx(Kt.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.35,ease:"easeOut"},className:"flex-1 flex flex-col sm:flex-row items-stretch justify-around gap-3 w-full",children:o.map((h,f)=>h?s.jsxs("div",{onClick:()=>c(h),className:"flex items-center gap-3 bg-white px-3.5 py-2 rounded-xl border border-gray-200/70 hover:border-red-300 flex-1 cursor-pointer transition-all group shadow-2xs hover:shadow-xs",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg overflow-hidden shrink-0 bg-gray-100 border border-gray-100",children:s.jsx(Vi,{src:h.featuredImageUrl||`data:image/svg+xml;utf8,${(h.title||"CE").substring(0,2).toUpperCase()}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",alt:""})}),s.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[s.jsx("p",{className:"text-xs font-bold text-gray-900 truncate leading-snug group-hover:text-red-650 transition-colors",children:h.title||"Dispatch"}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[9px] font-black text-red-650 uppercase tracking-wider",children:h.category||"News"}),s.jsx("span",{className:"text-gray-300 text-[10px]",children:"•"}),s.jsx("span",{className:"text-[9px] font-semibold text-gray-400",children:h.authorName||"Campus Eye"})]})]}),s.jsx(Fp,{size:14,className:"text-gray-300 group-hover:text-red-650 group-hover:translate-x-0.5 transition-all shrink-0"})]},h.id||f):null)},t)})]})})},TMe=({setActiveTab:e,articles:t=[],isAdmin:n})=>{var G,he;const[r,i]=se.useState(""),[a,o]=se.useState(!1),[c,h]=se.useState(null),f=new Date().getFullYear(),m=!!(n||Ne.currentUser&&(((G=Ne.currentUser.email)==null?void 0:G.toLowerCase())==="atwiinevictor2@gmail.com"||((he=Ne.currentUser.email)==null?void 0:he.toLowerCase())==="campuseye@gmail.com")),[y,w]=se.useState([]),[A,k]=se.useState(!1),[I,T]=se.useState(""),[D,F]=se.useState(""),[L,q]=se.useState(null),[Z,K]=se.useState(""),[z,B]=se.useState(!1);se.useEffect(()=>{const te=Qt(it(pe,"sponsors"),Pi(15)),le=Qt(it(pe,"adverts"),Pi(20));Promise.all([vn(te).catch(()=>null),vn(le).catch(()=>null)]).then(([ve,ke])=>{const Be=[];ve&&!ve.empty&&ve.docs.forEach(J=>Be.push({id:J.id,targetCollection:"sponsors",...J.data()})),ke&&!ke.empty&&ke.docs.forEach(J=>{const ie=J.data();(ie.imageUrl||ie.mediaUrl)&&Be.push({id:J.id,targetCollection:"adverts",name:ie.company||ie.title||"Partner",imageUrl:ie.imageUrl||ie.mediaUrl||"",link:ie.targetUrl||ie.link||"#"})}),w(Be)})},[]);const V=async te=>{if(te.preventDefault(),!m){me.error("Access Denied: Only administrators can add sponsors.");return}if(!I.trim()){me.error("Please enter a sponsor name");return}B(!0);try{let le=Z.trim();if(L&&(me.loading("Uploading sponsor logo...",{id:"sponsor-upload"}),le=await h4(L),me.dismiss("sponsor-upload")),!le){me.error("Please upload an image file or enter an image URL"),B(!1);return}const ke={id:(await ur(it(pe,"sponsors"),{name:I.trim(),imageUrl:le,link:D.trim()||"#",status:"active",createdAt:Bn()})).id,name:I.trim(),imageUrl:le,link:D.trim()||"#",targetCollection:"sponsors"};w(Be=>[ke,...Be]),me.success(`Sponsor "${I}" added successfully!`),T(""),F(""),q(null),K(""),k(!1)}catch(le){console.error("Failed to add sponsor:",le),me.error("Failed to add sponsor: "+le.message)}finally{B(!1)}},$=async(te,le,ve="sponsors")=>{if(!m){me.error("Access Denied: Only administrators can delete sponsors.");return}if(window.confirm(`Are you sure you want to delete sponsor "${le}"?`))try{w(ke=>ke.filter(Be=>Be.id!==te)),await ni(ot(pe,ve||"sponsors",te)),me.success(`Deleted "${le}" successfully!`)}catch(ke){console.error("Failed to delete sponsor:",ke),me.error("Failed to delete sponsor: "+ke.message)}},Q=te=>{te.preventDefault(),r&&(o(!0),me.success("Thank you for subscribing to Campus Eye Dispatch!",{icon:"📬"}),i(""),setTimeout(()=>o(!1),4e3))},Y=[{name:"X (Twitter)",icon:s.jsx(aq,{size:14,className:"text-gray-600 group-hover:text-black"}),href:"https://x.com/campuseye_media",hoverClass:"hover:bg-black/5 hover:border-black"},{name:"WhatsApp Channel",icon:s.jsx(G0,{size:15,className:"text-emerald-600 group-hover:text-emerald-700"}),href:"https://whatsapp.com/channel/0029Vb6OR49CXC3C5hCVlv3Q",hoverClass:"hover:bg-emerald-50 hover:border-emerald-400"},{name:"YouTube",icon:s.jsx(hF,{size:15,className:"text-red-600 group-hover:text-red-700"}),href:"https://youtube.com/@campuseye_media?si=gLddUotgI7D0n3cL",hoverClass:"hover:bg-red-50 hover:border-red-400"},{name:"Instagram",icon:s.jsx(sF,{size:15,className:"text-pink-600 group-hover:text-pink-700"}),href:"https://www.instagram.com/campuseyemedia_?igsh=MXV6ejUyM2J3MnhsNA==",hoverClass:"hover:bg-pink-50 hover:border-pink-400"},{name:"LinkedIn",icon:s.jsx(aF,{size:15,className:"text-blue-600 group-hover:text-blue-700"}),href:"https://www.linkedin.com/in/campuseyemedia?utm_source=share_via&utm_content=profile&utm_medium=member_android",hoverClass:"hover:bg-blue-50 hover:border-blue-400"},{name:"TikTok",icon:s.jsx(oq,{size:14,className:"text-gray-800 group-hover:text-black"}),href:"https://www.tiktok.com/@campuseye_media?_r=1&_t=ZS-96ci42CXliv",hoverClass:"hover:bg-gray-100 hover:border-gray-800"},{name:"Threads",icon:s.jsx(eF,{size:15,className:"text-gray-700 group-hover:text-black"}),href:"https://www.threads.com/@campuseyemedia_",hoverClass:"hover:bg-gray-100 hover:border-gray-800"},{name:"Facebook",icon:s.jsx(rF,{size:15,className:"text-blue-700 group-hover:text-blue-800"}),href:"https://www.facebook.com/share/1FivBManaT/",hoverClass:"hover:bg-blue-50 hover:border-blue-500"}];return s.jsxs("footer",{className:"bg-white border-t border-gray-100 mt-16 relative overflow-hidden font-sans select-none",children:[s.jsxs("div",{className:"w-full max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pt-12 pb-16",children:[t.length>0&&s.jsxs("div",{className:"pb-12 border-b border-gray-100 mb-12",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4 mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-red-650 animate-ping"}),s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-900",children:"Recommended For You"})]}),s.jsx("span",{className:"text-[11px] font-semibold text-gray-400",children:"Curated Student Headlines"})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-4",children:t.slice(0,6).map(te=>s.jsxs("div",{className:"group cursor-pointer flex flex-col bg-gray-50/70 hover:bg-white rounded-2xl p-2.5 border border-gray-200/60 hover:border-red-200 hover:shadow-md transition-all duration-300 text-left",onClick:()=>{const le=new CustomEvent("selectArticle",{detail:te});window.dispatchEvent(le)},children:[s.jsxs("div",{className:"aspect-[16/10] bg-gray-100 overflow-hidden rounded-xl mb-2.5 border border-gray-100 relative",children:[s.jsx(Vi,{src:te.featuredImageUrl||void 0,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500",alt:te.title}),s.jsx("span",{className:"absolute top-2 left-2 px-2 py-0.5 bg-black/75 backdrop-blur-xs text-white text-[9px] font-black uppercase tracking-wider rounded-md",children:te.category||"News"})]}),s.jsx("h4",{className:"text-xs font-bold text-gray-900 line-clamp-2 leading-snug group-hover:text-red-650 transition-colors mb-1.5",children:te.title}),s.jsxs("p",{className:"text-[10px] font-medium text-gray-400 mt-auto truncate",children:["By ",te.authorName||"Campus Eye"]})]},te.id))})]}),s.jsxs("div",{className:"pb-10 border-b border-gray-100 mb-12 text-left",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-5",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(es,{size:14,className:"text-red-650"}),s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-900",children:"Our Strategic Partners & Sponsors"})]}),s.jsx("p",{className:"text-[11px] font-medium text-gray-500 mt-0.5",children:"Supporting independent university journalism & student media innovation"})]}),m&&s.jsxs("button",{onClick:()=>k(!0),className:"px-3.5 py-1.5 bg-red-650 hover:bg-red-700 text-white rounded-xl text-[11px] font-black uppercase tracking-wider flex items-center gap-1.5 transition-all shadow-xs cursor-pointer shrink-0 self-start sm:self-auto",children:[s.jsx(fu,{size:13}),s.jsx("span",{children:"Add Sponsor"})]})]}),s.jsx("div",{className:"flex flex-wrap items-center gap-3",children:y.length>0?y.map(te=>s.jsxs("div",{className:"flex items-center gap-2.5 bg-gray-50/90 hover:bg-white px-3.5 py-2 rounded-xl border border-gray-200 hover:border-red-300 hover:shadow-xs transition-all group/sps",children:[te.link&&te.link!=="#"?s.jsxs("a",{href:te.link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2.5 hover:opacity-90 transition-opacity",children:[te.imageUrl&&s.jsx("img",{src:te.imageUrl,className:"h-6 w-auto max-w-[80px] object-contain rounded",alt:te.name,referrerPolicy:"no-referrer"}),s.jsx("span",{className:"text-xs font-bold text-gray-800 group-hover/sps:text-red-650 transition-colors",children:te.name}),s.jsx(Va,{size:11,className:"text-gray-400 group-hover/sps:text-red-650"})]}):s.jsxs("div",{className:"flex items-center gap-2.5",children:[te.imageUrl&&s.jsx("img",{src:te.imageUrl,className:"h-6 w-auto max-w-[80px] object-contain rounded",alt:te.name,referrerPolicy:"no-referrer"}),s.jsx("span",{className:"text-xs font-bold text-gray-800",children:te.name})]}),m&&s.jsx("button",{onClick:()=>$(te.id,te.name,te.targetCollection),className:"w-5 h-5 bg-gray-200/70 hover:bg-red-650 text-gray-600 hover:text-white rounded-full flex items-center justify-center transition-all cursor-pointer shrink-0 ml-1",title:`Delete ${te.name}`,children:s.jsx(As,{size:10})})]},te.id)):s.jsxs("div",{className:"p-4 bg-gray-50 border border-gray-200/80 rounded-2xl flex flex-col sm:flex-row items-center justify-between gap-3 w-full",children:[s.jsx("span",{className:"text-xs text-gray-600 font-medium",children:"Partner with Campus Eye Media to reach over 100,000+ university students and scholars across Africa."}),s.jsx("button",{onClick:()=>h("advertise"),className:"text-xs font-black text-red-650 uppercase tracking-wider bg-white px-3.5 py-1.5 rounded-xl border border-gray-200 shadow-2xs hover:bg-red-50 cursor-pointer shrink-0",children:"Become a Sponsor"})]})})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-12 gap-8 lg:gap-10 text-left",children:[s.jsxs("div",{className:"lg:col-span-4 space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-11 h-11 rounded-full overflow-hidden border-2 border-red-600 p-[1.5px] bg-white shrink-0 shadow-2xs",children:s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"Campus Eye Logo",className:"w-full h-full object-cover rounded-full",referrerPolicy:"no-referrer"})}),s.jsxs("div",{children:[s.jsxs("h2",{className:"text-base font-black tracking-tight text-gray-950 uppercase italic leading-none",children:["CAMPUS ",s.jsx("span",{className:"text-red-650",children:"EYE"})," MEDIA"]}),s.jsx("p",{className:"text-[9px] font-black uppercase tracking-[0.2em] text-red-650 mt-1",children:"Where stories unfold"})]})]}),s.jsx("p",{className:"text-xs text-gray-600 leading-relaxed font-normal max-w-sm",children:"The premier digital destination for university journalism, student dispatches, culture, investigative reports, and collegiate sports across higher institutions."}),s.jsxs("div",{className:"space-y-2.5 pt-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-bold uppercase tracking-wider text-gray-700",children:[s.jsx(Js,{size:13,className:"text-red-650"}),s.jsx("span",{children:"Join Our Campus Newsletter"})]}),s.jsxs("form",{onSubmit:Q,className:"flex gap-2 max-w-sm",children:[s.jsx("input",{type:"email",placeholder:"Enter your university email...",value:r,onChange:te=>i(te.target.value),className:"flex-1 px-3.5 py-2.5 text-xs border border-gray-200 rounded-xl focus:outline-none focus:border-red-600 transition-colors bg-gray-50/70",required:!0}),s.jsx("button",{type:"submit",className:"px-4 py-2.5 bg-gray-950 hover:bg-red-650 text-white font-bold text-xs uppercase tracking-wider rounded-xl transition-all flex items-center gap-1.5 shrink-0 shadow-xs cursor-pointer",children:a?s.jsx(Xh,{size:14,className:"text-emerald-400"}):s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"Join"}),s.jsx(ej,{size:13})]})})]})]})]}),s.jsxs("div",{className:"lg:col-span-3 space-y-4",children:[s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-900 border-l-2 border-red-650 pl-2.5",children:"Explore Newsroom"}),s.jsxs("ul",{className:"space-y-2.5 text-xs font-semibold text-gray-600",children:[s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("home"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Campus News"})})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("podcasts"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Podcasts & Broadcasts"})})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("posts"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Peer Dispatches & Lounge"})})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("sport"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Sports Arena"})})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("entertainment"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Entertainment & Culture"})})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("politics"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Politics & Governance"})})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("campus-debates"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Campus Debates & Polls"})})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>e==null?void 0:e("market"),className:"hover:text-red-650 transition-colors flex items-center gap-1.5 cursor-pointer",children:s.jsx("span",{children:"Student Market Hub"})})})]})]}),s.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-900 border-l-2 border-red-650 pl-2.5",children:"Information"}),s.jsxs("ul",{className:"space-y-2.5 text-xs font-semibold text-gray-600",children:[s.jsx("li",{children:s.jsx("button",{onClick:()=>h("about"),className:"hover:text-red-650 transition-colors cursor-pointer text-left",children:"About Campus Eye"})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>h("contact"),className:"hover:text-red-650 transition-colors cursor-pointer text-left",children:"Contact & Tips"})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>h("privacy"),className:"hover:text-red-650 transition-colors cursor-pointer text-left",children:"Privacy Policy"})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>h("terms"),className:"hover:text-red-650 transition-colors cursor-pointer text-left",children:"Terms of Service"})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>h("guidelines"),className:"hover:text-red-650 transition-colors cursor-pointer text-left",children:"Editorial Guidelines"})}),s.jsx("li",{children:s.jsx("button",{onClick:()=>h("advertise"),className:"hover:text-red-650 transition-colors cursor-pointer text-left",children:"Advertise With Us"})})]})]}),s.jsxs("div",{className:"lg:col-span-3 space-y-5",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-900 border-l-2 border-red-650 pl-2.5",children:"Download App"}),s.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Enjoy offline reader mode, breaking push alerts, and audio dispatches on your phone."}),s.jsxs("div",{className:"flex flex-col sm:flex-row lg:flex-col gap-2 pt-1",children:[s.jsxs("a",{href:"https://link.thelocalrent.com/v?t=1786099107&tk=07c43b29b01fcaf275f96eea938d430f",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 px-3.5 py-2 bg-gray-950 text-white hover:bg-neutral-800 transition-all rounded-xl border border-gray-800 shadow-xs group shrink-0",title:"Download Campus Eye Android App",children:[s.jsx("svg",{className:"w-5 h-5 text-white shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M3,5.27V18.73L16.55,12L3,5.27M17.87,11.33L19.5,12.15L17.87,12.97L16.93,12.5L17.87,11.33M3,19.53L16.27,12.89L13.87,15.29L3,19.53M3,4.47L13.87,8.71L16.27,11.11L3,4.47Z"})}),s.jsxs("div",{className:"text-left leading-none",children:[s.jsx("p",{className:"text-[8px] text-gray-400 font-bold uppercase tracking-wider",children:"Get it on"}),s.jsx("p",{className:"text-xs font-black tracking-tight mt-0.5",children:"Google Play"})]})]}),s.jsxs("a",{href:"https://link.thelocalrent.com/v?t=1786099107&tk=07c43b29b01fcaf275f96eea938d430f",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 px-3.5 py-2 bg-gray-950 text-white hover:bg-neutral-800 transition-all rounded-xl border border-gray-800 shadow-xs group shrink-0",title:"Download Campus Eye iOS App",children:[s.jsx("svg",{className:"w-5 h-5 text-white shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M18.71,19.5C17.88,20.74 17,21.95 15.66,21.97C14.32,22 13.89,21.18 12.37,21.18C10.84,21.18 10.37,21.95 9.1,22C7.79,22.05 6.8,20.68 5.96,19.47C4.25,17 2.94,12.45 4.7,9.39C5.57,7.87 7.13,6.91 8.82,6.88C10.1,6.86 11.32,7.75 12.11,7.75C12.89,7.75 14.37,6.68 15.92,6.84C16.57,6.87 18.39,7.1 19.56,8.82C19.47,8.88 17.39,10.1 17.41,12.63C17.44,15.65 20.06,16.66 20.1,16.67C20.08,16.74 19.67,18.11 18.71,19.5M15.97,4.17C16.63,3.37 17.07,2.28 16.95,1C16,1.04 14.9,1.6 14.24,2.38C13.68,3.04 13.19,4.14 13.34,5.39C14.39,5.47 15.4,4.88 15.97,4.17Z"})}),s.jsxs("div",{className:"text-left leading-none",children:[s.jsx("p",{className:"text-[8px] text-gray-400 font-bold uppercase tracking-wider",children:"Download on the"}),s.jsx("p",{className:"text-xs font-black tracking-tight mt-0.5",children:"App Store"})]})]})]})]}),s.jsxs("div",{className:"space-y-2 pt-2 border-t border-gray-100",children:[s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 block",children:"Connect With Us"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Y.map(te=>s.jsx("a",{href:te.href,target:"_blank",rel:"noopener noreferrer",className:`w-8 h-8 rounded-xl border border-gray-200 bg-gray-50 flex items-center justify-center transition-all duration-200 group hover:scale-105 shadow-2xs ${te.hoverClass}`,title:te.name,children:te.icon},te.name))})]})]})]}),s.jsxs("div",{className:"mt-14 pt-8 border-t border-gray-200/80 flex flex-col md:flex-row justify-between items-center gap-4 text-[11px] font-bold text-gray-600",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-2 text-center sm:text-left",children:[s.jsxs("span",{className:"uppercase tracking-wider",children:["© ",f," CAMPUS EYE MEDIA. ALL RIGHTS RESERVED."]}),s.jsx("span",{className:"hidden sm:inline text-gray-300",children:"•"}),s.jsxs("span",{className:"text-gray-500 font-medium",children:["Designed with 💙 by"," ",s.jsx("a",{href:"https://cybertechsoftwares.netlify.app",target:"_blank",rel:"noopener noreferrer",className:"hover:underline text-blue-650 font-bold",children:"Cyber Tech softwares"})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-x-5 gap-y-2 justify-center text-gray-500",children:[s.jsx("button",{onClick:()=>h("careers"),className:"hover:text-red-650 transition-colors cursor-pointer",children:"Careers"}),s.jsx("button",{onClick:()=>h("staff"),className:"hover:text-red-650 transition-colors cursor-pointer",children:"Staff Directory"}),s.jsx("button",{onClick:()=>h("advertise"),className:"hover:text-red-650 transition-colors cursor-pointer",children:"Advertise"}),s.jsx("a",{href:"/sitemap.xml",target:"_blank",rel:"noopener noreferrer",className:"hover:text-red-650 transition-colors",children:"Sitemap XML"}),n&&s.jsx("button",{onClick:()=>e==null?void 0:e("admin"),className:"hover:text-red-650 transition-colors font-black text-red-650 cursor-pointer",children:"Admin Panel"})]})]})]}),s.jsx(ar,{children:A&&s.jsx("div",{className:"fixed inset-0 z-[10000] bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",children:s.jsxs(Kt.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"bg-white rounded-3xl p-6 md:p-8 max-w-md w-full shadow-2xl border border-gray-100 text-left space-y-5 relative",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-red-50 text-red-650 rounded-2xl",children:s.jsx(fu,{size:20})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-black uppercase tracking-tight text-gray-900",children:"Add Footer Sponsor"}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-wider",children:"Logo & Partner Listing"})]})]}),s.jsx("button",{onClick:()=>k(!1),className:"p-2 text-gray-400 hover:text-gray-900 rounded-full hover:bg-gray-100 transition-colors cursor-pointer",children:s.jsx(er,{size:18})})]}),s.jsxs("form",{onSubmit:V,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-500 mb-1",children:"Sponsor / Partner Name *"}),s.jsx("input",{type:"text",required:!0,value:I,onChange:te=>T(te.target.value),placeholder:"e.g. MTN Uganda, Stanbic, Makerere Guild",className:"w-full bg-gray-50 border border-gray-200 rounded-xl px-4 py-2.5 text-xs font-bold text-gray-900 outline-none focus:border-red-600"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-500 mb-1",children:"Sponsor Logo (File Upload)"}),s.jsxs("label",{className:"flex items-center gap-3 p-3 bg-gray-50 border border-dashed border-gray-300 rounded-xl cursor-pointer hover:bg-gray-100 transition-colors",children:[s.jsx(dF,{size:18,className:"text-red-650 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-xs font-bold text-gray-700 truncate",children:L?L.name:"Choose Logo File..."}),s.jsx("p",{className:"text-[9px] text-gray-400 font-medium",children:"Automatic cloud storage upload"})]}),s.jsx("input",{type:"file",accept:"image/*",onChange:te=>{te.target.files&&te.target.files[0]&&(q(te.target.files[0]),K(""))},className:"hidden"})]})]}),s.jsxs("div",{className:"relative flex items-center justify-center",children:[s.jsx("div",{className:"border-t border-gray-100 w-full"}),s.jsx("span",{className:"bg-white px-3 text-[9px] font-black text-gray-400 uppercase tracking-widest absolute",children:"OR"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-500 mb-1",children:"Sponsor Logo Image URL"}),s.jsx("input",{type:"url",value:Z,onChange:te=>{K(te.target.value),te.target.value&&q(null)},placeholder:"https://i.ibb.co/example/logo.png",className:"w-full bg-gray-50 border border-gray-200 rounded-xl px-4 py-2.5 text-xs font-mono text-gray-900 outline-none focus:border-red-600"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-500 mb-1",children:"Website / Partner URL (Optional)"}),s.jsx("input",{type:"text",value:D,onChange:te=>F(te.target.value),placeholder:"https://sponsorwebsite.com",className:"w-full bg-gray-50 border border-gray-200 rounded-xl px-4 py-2.5 text-xs font-mono text-gray-900 outline-none focus:border-red-600"})]}),s.jsxs("div",{className:"pt-2 flex items-center justify-end gap-3",children:[s.jsx("button",{type:"button",onClick:()=>k(!1),className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-xl text-xs font-bold uppercase tracking-wider transition-colors cursor-pointer",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:z,className:"px-5 py-2.5 bg-red-650 hover:bg-red-700 text-white rounded-xl text-xs font-black uppercase tracking-wider shadow-sm transition-all flex items-center gap-2 cursor-pointer disabled:opacity-50",children:z?"Saving...":"Save Sponsor"})]})]})]})})}),s.jsx(ar,{children:c&&s.jsx("div",{className:"fixed inset-0 z-[10000] bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",children:s.jsxs(Kt.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"bg-white rounded-3xl max-w-2xl w-full max-h-[85vh] overflow-hidden shadow-2xl border border-gray-100 flex flex-col text-left",children:[s.jsxs("div",{className:"p-6 border-b border-gray-100 flex items-center justify-between bg-gray-50/50",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"w-10 h-10 rounded-2xl bg-red-50 text-red-650 flex items-center justify-center",children:[c==="about"&&s.jsx(Rne,{size:20}),c==="contact"&&s.jsx(Js,{size:20}),c==="privacy"&&s.jsx(pl,{size:20}),c==="terms"&&s.jsx(E0,{size:20}),c==="guidelines"&&s.jsx(nF,{size:20}),c==="careers"&&s.jsx(Ao,{size:20}),c==="staff"&&s.jsx(Ao,{size:20}),c==="advertise"&&s.jsx(hu,{size:20})]}),s.jsxs("div",{children:[s.jsxs("h3",{className:"text-base font-black text-gray-900 uppercase tracking-tight",children:[c==="about"&&"About Campus Eye Media",c==="contact"&&"Contact & Editorial Desk",c==="privacy"&&"Privacy Policy",c==="terms"&&"Terms of Service",c==="guidelines"&&"Editorial Guidelines",c==="careers"&&"Join Our Newsroom (Careers)",c==="staff"&&"Staff Directory & Leadership",c==="advertise"&&"Advertising & Strategic Partnerships"]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-wider",children:"Campus Eye Media Digital Newsroom"})]})]}),s.jsx("button",{onClick:()=>h(null),className:"p-2 text-gray-400 hover:text-gray-900 rounded-full hover:bg-gray-200/60 transition-colors cursor-pointer",children:s.jsx(er,{size:20})})]}),s.jsxs("div",{className:"p-6 overflow-y-auto space-y-4 text-xs text-gray-600 leading-relaxed",children:[c==="about"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"font-semibold text-gray-900 text-sm",children:"Campus Eye Media is the premier independent digital news organization covering higher education, student culture, campus politics, athletics, and investigative journalism."}),s.jsx("p",{children:"Founded to empower student voices and foster accountable leadership across African colleges and universities, Campus Eye brings together aspiring student reporters, photographers, podcast hosts, and digital creators."}),s.jsxs("div",{className:"bg-red-50/60 border border-red-200/80 p-4 rounded-2xl text-red-950 space-y-1",children:[s.jsx("h4",{className:"font-black text-xs uppercase tracking-wider text-red-650",children:"Our Mission"}),s.jsx("p",{className:"text-xs",children:"To deliver fearless, accurate, and uplifting journalism that bridges students, university administrators, and the wider society."})]})]}),c==="contact"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Have a breaking news tip, story pitch, press release, or campus query? Reach out directly to our editorial and reporting desk:"}),s.jsxs("div",{className:"space-y-3 bg-gray-50 p-4 rounded-2xl border border-gray-200",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 block",children:"General Inquiries & News Desk"}),s.jsx("a",{href:"mailto:campuseye@gmail.com",className:"text-sm font-bold text-red-650 hover:underline",children:"campuseye@gmail.com"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 block",children:"WhatsApp News Tip Hotline"}),s.jsxs("a",{href:"https://whatsapp.com/channel/0029Vb6OR49CXC3C5hCVlv3Q",target:"_blank",rel:"noopener noreferrer",className:"text-xs font-bold text-emerald-600 hover:underline flex items-center gap-1.5 mt-0.5",children:[s.jsx(G0,{size:14}),s.jsx("span",{children:"Campus Eye WhatsApp Channel"})]})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 block",children:"Headquarters"}),s.jsx("span",{className:"text-xs text-gray-800 font-medium",children:"Kampala International University / Makerere / Regional Bureaus"})]})]})]}),c==="privacy"&&s.jsxs(s.Fragment,{children:[s.jsx("h4",{className:"font-bold text-gray-900",children:"1. Data Privacy Commitment"}),s.jsx("p",{children:"Campus Eye Media respects your privacy. We do not sell personal identification information or share private account records with third-party data brokers."}),s.jsx("h4",{className:"font-bold text-gray-900",children:"2. Local Storage & Offline Cache"}),s.jsx("p",{children:"Our Progressive Web Application uses local browser storage to save offline bookmarked articles and caching preferences to minimize your mobile data consumption."}),s.jsx("h4",{className:"font-bold text-gray-900",children:"3. Authentication & Comments"}),s.jsx("p",{children:"When you sign in using Google or email credentials, only your public name, email, and avatar are stored to authenticate your community posts and comments."})]}),c==="terms"&&s.jsxs(s.Fragment,{children:[s.jsx("h4",{className:"font-bold text-gray-900",children:"1. Acceptance of Terms"}),s.jsx("p",{children:"By accessing Campus Eye Media, reader services, podcasts, and community dispatches, you agree to adhere to our civil engagement standards and applicable copyright laws."}),s.jsx("h4",{className:"font-bold text-gray-900",children:"2. Community Guidelines & Hate Speech"}),s.jsx("p",{children:"We enforce zero tolerance for hate speech, targeted harassment, defamation, or unauthorized commercial spam. Violating accounts are subject to immediate suspension."}),s.jsx("h4",{className:"font-bold text-gray-900",children:"3. Content Attribution"}),s.jsx("p",{children:"All original articles, podcast recordings, and photographs remain the intellectual property of Campus Eye Media and their respective student contributors."})]}),c==="guidelines"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Our newsroom adheres to standard journalistic integrity and verification protocols:"}),s.jsxs("ul",{className:"list-disc pl-5 space-y-1.5",children:[s.jsxs("li",{children:[s.jsx("strong",{children:"Accuracy:"})," All factual claims must be corroborated by multiple independent primary sources."]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Fairness:"})," Individuals or institutions facing critical claims must be offered fair opportunity to comment prior to publication."]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Corrections:"})," Factual errors are updated promptly with transparent editorial correction notices."]})]})]}),c==="careers"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Are you a student passionate about journalism, digital photography, video editing, social media management, or podcast production?"}),s.jsxs("div",{className:"p-4 bg-gray-50 border border-gray-200 rounded-2xl space-y-2",children:[s.jsx("h4",{className:"font-bold text-gray-900",children:"Open Positions for Semester Interns & Reporters:"}),s.jsxs("ul",{className:"list-disc pl-5 space-y-1",children:[s.jsx("li",{children:"Campus Beat Reporter (Politics & Guild)"}),s.jsx("li",{children:"Sports Correspondent (University Leagues & Tournaments)"}),s.jsx("li",{children:"Podcast Host & Audio Producer"}),s.jsx("li",{children:"Social Media & TikTok Video Creator"})]}),s.jsxs("p",{className:"text-xs pt-2",children:["Send your CV or writing samples to ",s.jsx("a",{href:"mailto:campuseye@gmail.com",className:"text-red-650 font-bold hover:underline",children:"campuseye@gmail.com"}),"."]})]})]}),c==="staff"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Campus Eye Media is directed by a dedicated editorial and technology team:"}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 pt-1",children:[s.jsxs("div",{className:"p-3 bg-gray-50 border border-gray-200 rounded-xl",children:[s.jsx("p",{className:"font-black text-gray-900 text-xs uppercase",children:"Editor-in-Chief"}),s.jsx("p",{className:"text-gray-500 text-[11px]",children:"Editorial Board"})]}),s.jsxs("div",{className:"p-3 bg-gray-50 border border-gray-200 rounded-xl",children:[s.jsx("p",{className:"font-black text-gray-900 text-xs uppercase",children:"Lead Developer"}),s.jsx("p",{className:"text-gray-500 text-[11px]",children:"Cyber Tech softwares"})]})]})]}),c==="advertise"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Promote your brand, student discounts, campus events, or product launches to an engaged audience of over 100,000+ university students."}),s.jsxs("div",{className:"bg-red-50/70 border border-red-200 p-4 rounded-2xl space-y-2 text-gray-800",children:[s.jsx("h4",{className:"font-black text-xs uppercase text-red-650",children:"Available Advertising Formats:"}),s.jsxs("ul",{className:"list-disc pl-5 space-y-1 text-xs",children:[s.jsx("li",{children:"Sponsored Featured Articles & Product Reviews"}),s.jsx("li",{children:"Homepage & In-Article Banner Advertisements"}),s.jsx("li",{children:"Podcast Audio & Video Episode Sponsorships"}),s.jsx("li",{children:"Direct WhatsApp & Push Notification Dispatches"})]}),s.jsxs("p",{className:"text-xs pt-2 font-semibold",children:["Contact our partnership team: ",s.jsx("a",{href:"mailto:campuseye@gmail.com",className:"text-red-650 font-bold hover:underline",children:"campuseye@gmail.com"})]})]})]})]}),s.jsx("div",{className:"p-4 border-t border-gray-100 bg-gray-50/60 flex justify-end",children:s.jsx("button",{onClick:()=>h(null),className:"px-5 py-2 bg-gray-950 hover:bg-gray-800 text-white rounded-xl text-xs font-bold uppercase tracking-wider cursor-pointer",children:"Close"})})]})})})]})},OMe=()=>(j.useEffect(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{})},[]),null),jee=({currentPage:e,totalPages:t,totalItems:n,itemsPerPage:r,onPageChange:i,onItemsPerPageChange:a,itemLabel:o="items",itemsPerPageOptions:c=[10,20,30,50],className:h=""})=>{if(n===0)return null;const f=Math.max(1,t),m=Math.min(Math.max(1,e),f),y=(m-1)*r+1,w=Math.min(m*r,n),k=f<=7?Array.from({length:f},(I,T)=>T+1):m<=3?[1,2,3,4,5,"...",f]:m>=f-2?[1,"...",f-4,f-3,f-2,f-1,f]:[1,"...",m-1,m,m+1,"...",f];return s.jsxs("div",{className:`p-3.5 bg-gray-900 text-white rounded-2xl shadow-lg border border-gray-800 flex flex-col sm:flex-row items-center justify-between gap-3 select-none ${h}`,children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 text-xs text-gray-300",children:[s.jsxs("span",{children:["Showing ",s.jsxs("b",{className:"text-white font-mono",children:[y,"–",w]})," of ",s.jsx("b",{className:"text-white font-mono",children:n})," ",o]}),a&&s.jsxs("div",{className:"flex items-center gap-1.5 border-l border-gray-700 pl-2.5 my-0.5",children:[s.jsx("span",{className:"text-[10px] uppercase font-bold text-gray-400 font-mono",children:"Per page:"}),s.jsx("select",{value:r,onChange:I=>{a(Number(I.target.value)),i(1)},className:"bg-gray-800 text-white text-xs font-bold font-mono px-2 py-1 rounded-lg border border-gray-700 focus:outline-none focus:border-blue-500 cursor-pointer",children:c.map(I=>s.jsx("option",{value:I,children:I},I))})]})]}),s.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto max-w-full py-0.5 font-mono",children:[s.jsx("button",{type:"button",onClick:()=>i(1),disabled:m===1,className:"min-w-[32px] h-[32px] rounded-lg bg-gray-800 hover:bg-gray-700 disabled:opacity-30 disabled:cursor-not-allowed text-gray-200 transition-colors cursor-pointer flex items-center justify-center shrink-0",title:"First Page",children:s.jsx(qne,{size:15})}),s.jsxs("button",{type:"button",onClick:()=>i(m-1),disabled:m===1,className:"px-2.5 h-[32px] rounded-lg bg-gray-800 hover:bg-gray-700 disabled:opacity-30 disabled:cursor-not-allowed text-gray-200 text-xs font-bold transition-colors cursor-pointer flex items-center gap-1 shrink-0",title:"Previous Page",children:[s.jsx(Vp,{size:14}),s.jsx("span",{className:"hidden sm:inline font-sans text-[11px]",children:"Prev"})]}),k.map((I,T)=>{if(I==="...")return s.jsx("span",{className:"px-1.5 text-gray-500 font-mono font-bold text-xs select-none",children:"..."},`ellipsis-${T}`);const D=I,F=D===m;return s.jsx("button",{type:"button",onClick:()=>i(D),className:`min-w-[32px] h-[32px] px-2 rounded-lg text-xs font-bold transition-all cursor-pointer flex items-center justify-center shrink-0 ${F?"bg-blue-600 text-white font-black shadow-md shadow-blue-500/30 ring-1 ring-blue-400":"bg-gray-800 text-gray-300 hover:bg-gray-700 hover:text-white border border-gray-700/50"}`,children:D},D)}),s.jsxs("button",{type:"button",onClick:()=>i(m+1),disabled:m===f,className:"px-2.5 h-[32px] rounded-lg bg-gray-800 hover:bg-gray-700 disabled:opacity-30 disabled:cursor-not-allowed text-gray-200 text-xs font-bold transition-colors cursor-pointer flex items-center gap-1 shrink-0",title:"Next Page",children:[s.jsx("span",{className:"hidden sm:inline font-sans text-[11px]",children:"Next"}),s.jsx(Fp,{size:14})]}),s.jsx("button",{type:"button",onClick:()=>i(f),disabled:m===f,className:"min-w-[32px] h-[32px] rounded-lg bg-gray-800 hover:bg-gray-700 disabled:opacity-30 disabled:cursor-not-allowed text-gray-200 transition-colors cursor-pointer flex items-center justify-center shrink-0",title:"Last Page",children:s.jsx(Kne,{size:15})})]})]})},PMe=()=>{const[e,t]=j.useState([]),[n,r]=j.useState(0),[i,a]=j.useState(!1),[o,c]=j.useState(!1),[h,f]=j.useState(!1),[m,y]=j.useState(!1),[w,A]=j.useState(0),[k,I]=j.useState("0:00"),[T,D]=j.useState("0:00"),F=j.useRef(null);j.useEffect(()=>{const $=Qt(it(pe,"podcasts"),pi("publishDate","desc"),Pi(15));vn($).then(Q=>{const Y=Q.docs.map(G=>({id:G.id,...G.data()}));t(Y)}).catch(Q=>{Gs(Q,Ps.LIST,"podcasts")})},[]),j.useEffect(()=>{const $=Q=>{const G=Q.detail;if(G){if(Dl(G)){window.dispatchEvent(new CustomEvent("play-video-podcast",{detail:G}));return}y(!0),f(!1),t(he=>{const te=he.findIndex(le=>le.id===G.id);if(te>-1)return r(te),a(!0),setTimeout(()=>{F.current&&F.current.play().then(()=>{a(!0)}).catch(console.error)},150),he;{const le=[G,...he];return r(0),a(!0),setTimeout(()=>{F.current&&F.current.play().then(()=>{a(!0)}).catch(console.error)},150),le}})}};return window.addEventListener("play-podcast",$),()=>{window.removeEventListener("play-podcast",$)}},[]),j.useEffect(()=>{F.current&&m&&(i?F.current.play().catch($=>{console.warn("Autoplay was prevented or source invalid:",$),a(!1)}):F.current.pause())},[n,e,m]);const L=()=>{F.current&&(i?(F.current.pause(),a(!1)):F.current.play().then(()=>{a(!0)}).catch(console.error))},q=()=>{if(F.current){const $=F.current.currentTime,Q=F.current.duration||0,Y=$/Q*100;A(Y||0);const G=he=>{if(isNaN(he))return"0:00";const te=Math.floor(he/60),le=Math.floor(he%60);return`${te}:${le<10?"0":""}${le}`};I(G($)),D(G(Q))}},Z=$=>{if(F.current&&F.current.duration){const Q=parseFloat($.target.value),Y=Q/100*F.current.duration;F.current.currentTime=Y,A(Q)}},K=()=>{e.length!==0&&(r($=>($+1)%e.length),a(!0))},z=()=>{e.length!==0&&(r($=>($-1+e.length)%e.length),a(!0))},B=()=>{F.current&&F.current.pause(),a(!1),y(!1),me.success("Podcast Player closed.",{position:"bottom-right"})};if(!m||e.length===0)return null;const V=e[n];return s.jsxs("div",{className:"fixed inset-0 pointer-events-none z-[5000]",children:[s.jsx("audio",{ref:F,src:V.audioUrl||V.mediaUrl||"",onTimeUpdate:q,onEnded:K,preload:"none",hidden:!0}),s.jsx(ar,{children:h?s.jsxs(Kt.div,{drag:!0,dragMomentum:!1,dragElastic:.05,initial:{opacity:0,scale:.8,y:50},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.8,y:50},transition:{type:"spring",damping:15},className:"absolute bottom-24 right-4 pointer-events-auto w-18 h-18 rounded-full bg-gray-950/95 backdrop-blur-xl border border-red-500/40 shadow-2xl flex items-center justify-center cursor-grab active:cursor-grabbing select-none group text-white h-18",title:"Draggable Podcast: Double-click to expand or drag anywhere",onDoubleClick:()=>f(!1),children:[s.jsxs("div",{className:"absolute inset-0.5 rounded-full overflow-hidden",children:[s.jsx("img",{src:V.thumbnail,className:`w-full h-full object-cover transition-transform ${i?"animate-[spin_20s_linear_infinite]":""}`,alt:""}),s.jsx("div",{className:"absolute inset-0 bg-black/60 flex flex-col items-center justify-center gap-1 opacity-100 group-hover:opacity-100 transition-opacity",children:s.jsx("button",{onClick:$=>{$.stopPropagation(),L()},className:"p-1.5 bg-red-600 rounded-full text-white hover:scale-110 transition-transform shadow-lg cursor-pointer",title:i?"Pause":"Play",children:i?s.jsx(Y6,{size:10,fill:"currentColor"}):s.jsx($p,{size:10,fill:"currentColor",className:"ml-0.2"})})})]}),i&&s.jsx("span",{className:"absolute -inset-1 rounded-full border border-red-500/30"}),s.jsxs("div",{className:"absolute -top-1 -right-1 flex gap-1 items-center z-10 pointer-events-auto",children:[s.jsx("button",{onClick:$=>{$.stopPropagation(),f(!1)},className:"w-4.5 h-4.5 bg-blue-600 rounded-full flex items-center justify-center text-white text-[8px] hover:bg-blue-700 cursor-pointer shadow-sm",title:"Restore Player",children:s.jsx(Dw,{size:8,strokeWidth:3})}),s.jsx("button",{onClick:$=>{$.stopPropagation(),B()},className:"w-4.5 h-4.5 bg-red-650 rounded-full flex items-center justify-center text-white text-[8px] hover:bg-red-700 cursor-pointer shadow-sm",title:"Close Podcast",children:s.jsx(er,{size:8,strokeWidth:3})})]})]}):s.jsxs(Kt.div,{drag:!0,dragMomentum:!1,dragElastic:.05,initial:{opacity:0,scale:.9,y:100},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:100},transition:{type:"spring",stiffness:260,damping:24},className:"absolute bottom-24 right-4 pointer-events-auto bg-gray-950/95 backdrop-blur-2xl border border-white/10 rounded-[2.5rem] shadow-[0_25px_60px_rgba(0,0,0,0.8)] p-5 select-none text-white overflow-hidden transition-all duration-300 w-80 md:w-88 flex flex-col justify-between",style:{maxHeight:o?"460px":"230px"},children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 border-b border-white/5 pb-2 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(sc,{size:11,className:"text-red-500"}),s.jsx("span",{className:"text-[8.5px] font-black text-gray-400 uppercase tracking-widest leading-none",children:"Broadcast Widget"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>c(!o),className:"p-1 hover:bg-white/10 rounded-lg text-gray-405 hover:text-white transition-all cursor-pointer",title:o?"Show Compact Player":"Show Up Next Queue",children:o?s.jsx(Md,{size:14}):s.jsx(uf,{size:14})}),s.jsx("button",{onClick:()=>f(!0),className:"p-1 hover:bg-white/10 rounded-lg text-gray-405 hover:text-white transition-all cursor-pointer",title:"Minimize to Bubble",children:s.jsx(tj,{size:13})}),s.jsx("button",{onClick:B,className:"p-1 hover:bg-red-900/40 rounded-lg text-red-405 hover:text-red-500 transition-all cursor-pointer",title:"Close and Exit",children:s.jsx(er,{size:13})})]})]}),s.jsx("div",{className:"flex justify-center py-1 cursor-grab active:cursor-grabbing text-gray-600 hover:text-gray-400 mb-2",children:s.jsx(yre,{size:16})}),s.jsxs("div",{className:"flex items-center gap-3.5 text-left min-w-0",children:[s.jsx("img",{src:V.thumbnail,className:"w-13 h-13 rounded-2xl object-cover border border-white/10 shrink-0 shadow-xl",alt:""}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[7.5px] font-black uppercase text-red-500 tracking-wider bg-red-950/40 border border-red-900/30 px-1.5 py-0.2 rounded",children:V.category||"CAMPUS"}),s.jsxs("span",{className:"text-[7.5px] font-mono font-bold text-gray-400",children:["Host: ",V.author||"Broadcaster"]})]}),s.jsx("h4",{className:"text-xs font-black text-white truncate uppercase tracking-tight mt-1 leading-snug",children:V.title}),i&&s.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[s.jsx(Ene,{size:9,className:"text-red-500 animate-[bounce_1s_infinite]"}),s.jsx("span",{className:"text-[7px] font-mono font-bold uppercase tracking-wider text-red-500",children:"Live Frequency Tuning..."})]})]})]}),s.jsxs("div",{className:"mt-4 shrink-0",children:[s.jsx("input",{type:"range",min:"0",max:"100",value:w,onChange:Z,className:"w-full h-1 bg-white/10 rounded-lg appearance-none cursor-pointer accent-red-600 focus:outline-none"}),s.jsxs("div",{className:"flex justify-between items-center text-[7.5px] font-mono font-bold text-gray-400 mt-1 uppercase tracking-wider",children:[s.jsx("span",{children:k}),s.jsx("span",{children:T})]})]}),s.jsxs("div",{className:"flex items-center justify-center gap-5 mt-3 shrink-0",children:[s.jsx("button",{onClick:z,className:"text-gray-400 hover:text-white hover:scale-105 transition-all p-1.5 bg-white/5 rounded-xl border border-white/5 cursor-pointer",title:"Previous Story",children:s.jsx(yie,{size:14,fill:"currentColor"})}),s.jsx("button",{onClick:L,className:"w-10 h-10 bg-red-600 text-white rounded-2xl flex items-center justify-center hover:scale-110 active:scale-95 transition-all shadow-xl shadow-red-900/20 cursor-pointer",title:i?"Pause":"Play Episode",children:i?s.jsx(Y6,{size:16,fill:"currentColor"}):s.jsx($p,{size:16,className:"ml-0.5",fill:"currentColor"})}),s.jsx("button",{onClick:K,className:"text-gray-400 hover:text-white hover:scale-105 transition-all p-1.5 bg-white/5 rounded-xl border border-white/5 cursor-pointer",title:"Next Story",children:s.jsx(vie,{size:14,fill:"currentColor"})})]}),s.jsx(ar,{children:o&&s.jsxs(Kt.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"overflow-hidden border-t border-white/5 mt-4 pt-3 text-left",children:[s.jsx("h5",{className:"text-[7.5px] font-black text-red-500 uppercase tracking-[0.25em] mb-2",children:"Playlist Queue"}),s.jsx("div",{className:"space-y-1.5 max-h-40 overflow-y-auto scrollbar-thin pr-1",children:e.slice(0,5).map(($,Q)=>s.jsxs("div",{onClick:()=>{r(Q),a(!0)},className:`flex items-center gap-2 p-1.5 rounded-xl cursor-pointer transition-all border ${Q===n?"bg-red-950/20 border-red-900/40":"bg-transparent border-transparent hover:bg-white/5"}`,children:[s.jsx("img",{src:$.thumbnail,className:"w-6 h-6 rounded-md object-cover",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[9px] font-black text-white truncate uppercase tracking-tight",children:$.title}),s.jsx("p",{className:"text-[7px] text-gray-400 truncate -mt-0.5",children:$.duration||"5m"})]}),Q===n&&i&&s.jsx("span",{className:"w-1.5 h-1.5 bg-red-600 rounded-full shrink-0 mr-1"})]},$.id))})]})})]})})]})},PV=()=>{const[e,t]=se.useState([]),[n,r]=se.useState(!0),[i,a]=se.useState(""),[o,c]=se.useState("All"),[h,f]=se.useState("all"),[m,y]=se.useState(null),[w,A]=se.useState(null);se.useEffect(()=>{const L=Qt(it(pe,"podcasts"),pi("publishDate","desc"),Pi(40));vn(L).then(Z=>{const K=Z.docs.map(z=>({id:z.id,...z.data()}));t(K),r(!1)}).catch(Z=>{console.error("Failed to load podcasts:",Z),r(!1)});const q=Z=>{var z;const K=Z;(z=K.detail)!=null&&z.id&&y(K.detail.id)};return window.addEventListener("play-podcast",q),()=>window.removeEventListener("play-podcast",q)},[]);const k=L=>{Dl(L)?(A(L),window.dispatchEvent(new CustomEvent("play-video-podcast",{detail:L})),me.success(`Playing Video Episode: ${L.title}`,{icon:"🎬",position:"bottom-right",duration:3500})):(y(L.id),window.dispatchEvent(new CustomEvent("play-podcast",{detail:L})),me.success(`Streaming Audio: ${L.title}`,{icon:"🎧",position:"bottom-right",duration:3500}))},I=e.filter(L=>!Dl(L)).length,T=e.filter(L=>Dl(L)).length,D=["All",...Array.from(new Set(e.map(L=>L.category).filter(Boolean)))],F=e.filter(L=>{var z,B,V,$;const q=Dl(L);if(h==="audio"&&q||h==="video"&&!q)return!1;const Z=((z=L.title)==null?void 0:z.toLowerCase().includes(i.toLowerCase()))||((B=L.author)==null?void 0:B.toLowerCase().includes(i.toLowerCase()))||((V=L.category)==null?void 0:V.toLowerCase().includes(i.toLowerCase()))||(($=L.description)==null?void 0:$.toLowerCase().includes(i.toLowerCase())),K=o==="All"||L.category===o;return Z&&K});return s.jsxs("div",{className:"py-6 px-4 md:px-8 max-w-7xl mx-auto",children:[s.jsxs("div",{className:"bg-gradient-to-r from-gray-950 via-gray-900 to-black text-white p-5 md:p-6 rounded-3xl mb-8 border border-white/10 shadow-xl relative overflow-hidden flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-4 text-left",children:[s.jsx("div",{className:"p-3 bg-red-600/20 text-red-500 border border-red-500/30 rounded-2xl shrink-0",children:s.jsx(d2,{size:26})}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-xl md:text-3xl font-serif font-black tracking-tight text-white uppercase italic",children:"Campus Podcasts"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider px-2 py-0.5 rounded-md bg-white/10 text-gray-300",children:"Audio & Video Hub"})]}),s.jsx("p",{className:"text-[11px] text-gray-400 font-medium mt-0.5",children:"Official Investigative Audio Newsroom, Direct Video Dispatches & YouTube Episodes"})]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("div",{className:"px-3.5 py-1.5 bg-white/5 border border-white/10 text-white rounded-xl flex items-center gap-2",children:[s.jsx(sc,{size:14,className:"text-red-500"}),s.jsxs("span",{className:"text-xs font-mono font-black",children:[e.length," Total"]})]}),s.jsxs("div",{className:"px-3.5 py-1.5 bg-emerald-500/10 border border-emerald-500/30 text-emerald-400 rounded-xl flex items-center gap-2",children:[s.jsx(Qh,{size:14,className:"text-emerald-400"}),s.jsxs("span",{className:"text-xs font-mono font-black",children:[I," Audio"]})]}),s.jsxs("div",{className:"px-3.5 py-1.5 bg-red-500/10 border border-red-500/30 text-red-400 rounded-xl flex items-center gap-2",children:[s.jsx(Aa,{size:14,className:"text-red-400"}),s.jsxs("span",{className:"text-xs font-mono font-black",children:[T," Video"]})]})]})]}),s.jsxs("div",{className:"space-y-4 mb-8",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-1.5 bg-gray-100 p-1 rounded-2xl",children:[s.jsxs("button",{onClick:()=>f("all"),className:`px-3.5 py-1.5 rounded-xl text-xs font-black uppercase tracking-wider transition-all cursor-pointer ${h==="all"?"bg-gray-900 text-white shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:["All Formats (",e.length,")"]}),s.jsxs("button",{onClick:()=>f("audio"),className:`flex items-center gap-1.5 px-3.5 py-1.5 rounded-xl text-xs font-black uppercase tracking-wider transition-all cursor-pointer ${h==="audio"?"bg-emerald-600 text-white shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Qh,{size:13})," Audio (",I,")"]}),s.jsxs("button",{onClick:()=>f("video"),className:`flex items-center gap-1.5 px-3.5 py-1.5 rounded-xl text-xs font-black uppercase tracking-wider transition-all cursor-pointer ${h==="video"?"bg-red-600 text-white shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Aa,{size:13})," Video (",T,")"]})]}),s.jsxs("div",{className:"relative w-full sm:w-80",children:[s.jsx("input",{type:"text",placeholder:"Search audio or video episodes...",value:i,onChange:L=>a(L.target.value),className:"w-full pl-10 pr-4 py-2.5 rounded-xl border border-gray-200 text-xs font-bold text-gray-900 focus:border-red-600 focus:ring-0 outline-none bg-white shadow-xs"}),s.jsx(Ip,{size:14,className:"absolute left-3.5 top-3.5 text-gray-400"})]})]}),s.jsx("div",{className:"flex items-center gap-2 overflow-x-auto pb-2 scrollbar-none",children:D.map(L=>s.jsx("button",{onClick:()=>c(L),className:`px-3.5 py-1.5 rounded-xl text-xs font-black uppercase tracking-wider transition-all whitespace-nowrap cursor-pointer ${o===L?"bg-red-650 text-white shadow-md":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:L},L))})]}),n?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20",children:[s.jsx(Pr,{size:32,className:"text-red-600 animate-spin mb-4"}),s.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-gray-400",children:"Tuning broadcast channels..."})]}):F.length===0?s.jsxs("div",{className:"bg-white py-16 px-6 rounded-3xl border border-gray-200 shadow-xs max-w-xl mx-auto text-center",children:[s.jsx(d2,{size:32,className:"mx-auto mb-4 text-gray-300"}),s.jsx("h4",{className:"text-sm font-black uppercase tracking-wider text-gray-900",children:"No matching episodes found"}),s.jsx("p",{className:"text-[10px] uppercase font-bold tracking-widest text-gray-400 mt-2",children:"Try switching format filter or adjusting your search keyword."})]}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:F.map(L=>{var z;const q=Dl(L),Z=m===L.id&&!q,K=(w==null?void 0:w.id)===L.id;return s.jsxs("div",{onClick:()=>k(L),className:`group bg-white p-4 rounded-3xl border transition-all duration-300 text-left flex flex-col justify-between cursor-pointer relative overflow-hidden ${Z||K?q?"border-red-600 shadow-xl ring-2 ring-red-500/30":"border-emerald-500 shadow-lg ring-2 ring-emerald-500/20":"border-gray-150 hover:border-red-600 hover:shadow-md"}`,children:[s.jsxs("div",{children:[s.jsxs("div",{className:"aspect-square bg-gray-950 mb-4 relative overflow-hidden flex items-center justify-center rounded-2xl group-hover:scale-[1.01] transition-transform duration-500",children:[s.jsx(Vi,{src:L.thumbnail||(q?"https://images.unsplash.com/photo-1578022761797-b8636ac1773c?auto=format&fit=crop&q=80&w=500":"https://images.unsplash.com/photo-1590602847861-f357a9332bbc?auto=format&fit=crop&q=80&w=500"),className:"absolute inset-0 w-full h-full object-cover opacity-90 group-hover:opacity-100 transition-opacity",alt:L.title}),s.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/85 via-black/25 to-transparent"}),s.jsx("span",{className:"absolute top-3 left-3 text-[8px] font-black uppercase tracking-widest px-2.5 py-1 bg-black/60 text-white rounded-lg backdrop-blur-xs shadow-sm border border-white/10",children:L.category||"Campus Vibe"}),s.jsx("span",{className:`absolute top-3 right-3 text-[8.5px] font-black uppercase tracking-widest px-2.5 py-1 rounded-lg flex items-center gap-1.5 shadow-md border ${q?"bg-red-600 text-white border-red-500/50 animate-pulse":"bg-emerald-600 text-white border-emerald-500/50"}`,children:q?s.jsxs(s.Fragment,{children:[s.jsx(Aa,{size:11,className:"shrink-0"})," VIDEO"]}):s.jsxs(s.Fragment,{children:[s.jsx(Qh,{size:11,className:"shrink-0"})," AUDIO"]})}),Z&&s.jsxs("span",{className:"absolute top-11 right-3 text-[8px] font-black uppercase tracking-widest px-2 py-0.5 bg-emerald-500 text-white rounded-md flex items-center gap-1 shadow-md",children:[s.jsx(Vie,{size:9})," Playing Audio"]}),s.jsx("button",{className:`absolute bottom-4 right-4 w-11 h-11 rounded-2xl flex items-center justify-center shadow-xl group-hover:scale-110 transition-all cursor-pointer ${q?"bg-red-600 text-white shadow-red-900/30":"bg-white text-red-650 shadow-gray-900/20"}`,title:q?"Watch Video Episode":"Listen Audio Podcast",children:q?s.jsx($p,{size:16,fill:"currentColor",className:"ml-0.5"}):s.jsx($p,{size:16,fill:"currentColor",className:"ml-0.5"})}),s.jsxs("span",{className:"absolute bottom-4 left-4 text-[9px] font-mono font-bold text-white/95 bg-black/50 px-2.5 py-1 rounded-lg backdrop-blur-xs border border-white/10 flex items-center gap-1",children:["⏱️ ",L.duration||(q?"Video":"5:00")]})]}),s.jsx("div",{className:"flex items-center justify-between mb-1",children:s.jsxs("p",{className:"text-[9px] font-black text-red-655 uppercase tracking-widest leading-none truncate",children:["Host: ",L.author||"Campus Desk"]})}),s.jsx("h3",{className:"text-base font-serif font-black text-gray-950 leading-tight group-hover:text-red-655 transition-colors uppercase tracking-tight line-clamp-2 mt-1",children:L.title}),L.description&&s.jsx("p",{className:"text-[10px] text-gray-500 line-clamp-2 mt-1.5 leading-relaxed",children:L.description})]}),s.jsxs("div",{className:"pt-3 mt-4 border-t border-gray-100 flex items-center justify-between",children:[s.jsx("span",{className:"text-[8.5px] font-mono font-black uppercase tracking-wider flex items-center gap-1.5 text-gray-600",children:q?s.jsxs(s.Fragment,{children:[s.jsx(mre,{size:12,className:"text-red-600"})," Video Broadcast"]}):s.jsxs(s.Fragment,{children:[s.jsx(sc,{size:12,className:"text-emerald-600"})," Audio Story"]})}),s.jsx("span",{className:"text-[8px] font-mono font-bold text-gray-400",children:(z=L.publishDate)!=null&&z.seconds?new Date(L.publishDate.seconds*1e3).toLocaleDateString():"Active"})]})]},L.id)})}),w&&s.jsx(J3,{podcast:w,onClose:()=>A(null),relatedPodcasts:e.filter(L=>L.id!==w.id),onSelectPodcast:L=>A(L)})]})},RMe=({debateId:e})=>{const[t,n]=j.useState([]),[r,i]=j.useState(""),[a,o]=j.useState(!1),[c,h]=j.useState(!1);j.useEffect(()=>{o(!0);const m=Qt(it(pe,"debates",e,"comments"),pi("createdAt","desc"));vn(m).then(y=>{const w=y.docs.map(A=>{const k=A.data();return{id:A.id,...k,createdAt:k.createdAt?k.createdAt.toDate?k.createdAt.toDate():new Date(k.createdAt):new Date}});n(w),o(!1)}).catch(y=>{console.warn("Failed to subscriber to debate comments",y),o(!1)})},[e]);const f=async m=>{if(m.preventDefault(),!Ne.currentUser){me.error("Please log in to participate in the debate!");return}if(r.trim()){h(!0);try{const y=Ne.currentUser;if(!y){me.error("Please log in to participate in the debate!"),h(!1);return}const w={text:r.trim(),userId:y.uid,author:y.displayName||(y.email?y.email.split("@")[0]:"Anonymous Participant"),createdAt:Bn()},A=await ur(it(pe,"debates",e,"comments"),w);n(k=>[{id:A.id,text:r.trim(),userId:y.uid,author:y.displayName||(y.email?y.email.split("@")[0]:"Anonymous Participant"),createdAt:new Date},...k]);try{await Hn(ot(pe,"debates",e),{commentsCount:Ur(1)})}catch(k){console.warn("Could not increment denormalized debate comment counter:",k)}i(""),me.success("Argument posted!")}catch(y){me.error("Failed to post comment: "+y.message)}finally{h(!1)}}};return s.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Yi,{size:16,className:"text-gray-500"}),s.jsxs("h4",{className:"text-[10px] font-black uppercase tracking-widest text-gray-500",children:["Discourse Thread (",t.length,")"]})]}),Ne.currentUser?s.jsxs("form",{onSubmit:f,className:"flex gap-2",children:[s.jsx("input",{type:"text",value:r,onChange:m=>i(m.target.value),placeholder:"State your position/stance...",className:"flex-1 px-4 py-2.5 bg-gray-50 border border-gray-150 rounded-xl text-xs font-bold focus:bg-white focus:border-accent outline-none transition-all placeholder:text-gray-400"}),s.jsx("button",{type:"submit",disabled:c||!r.trim(),className:"px-4 bg-accent hover:bg-opacity-90 disabled:opacity-50 text-white rounded-xl transition-all flex items-center justify-center cursor-pointer",children:c?s.jsx(Pr,{size:14,className:"animate-spin"}):s.jsx(fl,{size:14})})]}):s.jsx("div",{className:"bg-amber-50 border border-amber-100 p-3 rounded-xl text-center",children:s.jsx("p",{className:"text-[10px] font-bold text-amber-800 uppercase tracking-wide",children:"🔒 Log in to participate in academic discourse."})}),a?s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(Pr,{className:"animate-spin text-gray-400",size:16})}):t.length===0?s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest text-center py-2",children:"Be the first to make a point!"}):s.jsx("div",{className:"space-y-2.5 max-h-60 overflow-y-auto pr-1",children:t.map(m=>s.jsxs("div",{className:"p-3 bg-gray-50 rounded-xl space-y-1 text-left",children:[s.jsxs("div",{className:"flex items-center justify-between text-[9px] font-black uppercase tracking-wider text-gray-500",children:[s.jsxs("span",{className:"flex items-center gap-1 text-accent",children:[s.jsx(TN,{size:10}),m.author]}),s.jsx("span",{children:m.createdAt.toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),s.jsx("p",{className:"text-xs font-medium text-gray-850 leading-relaxed break-words",children:m.text})]},m.id))})]})},mk={id:"current-campus-poll",question:"Should university lecture attendance be strictly tracked via biometric scanners, or should it remain fully optional?",options:[{text:"Strictly tracked (Biometrics)",votes:142},{text:"Fully optional / Student autonomy",votes:289},{text:"Hybrid (Only for key lab sessions)",votes:95}],totalVotes:526,expiresAt:null,status:"active"},DMe=()=>{var $,Q,Y;const[e,t]=j.useState(mk),[n,r]=j.useState(!1),[i,a]=j.useState(null),[o,c]=j.useState(!1),[h,f]=j.useState({});j.useEffect(()=>{if(!e)return;(async()=>{try{const te=(await vn(Qt(it(pe,"articles"),pi("publishDate","desc"),Pi(15)))).docs.map(ve=>({id:ve.id,...ve.data()})),le={};e.options.forEach(ve=>{const ke=ve.text.replace(/^(support|vote\s+for|vote|elect)\s+/i,"").trim().toLowerCase(),Be=te.find(J=>{const ie=J.title.toLowerCase().replace(/^(support|vote\s+for|vote|elect)\s+/i,"").trim();return ie===ke||J.title.toLowerCase().includes(ke)||ke.includes(ie)});Be&&(le[ve.text]={bio:Be.summary||Be.content||"",votes:Be.likeCount||0,image:Be.featuredImageUrl||"",id:Be.id})}),f(le)}catch(he){console.warn("Silent ignore bio fetching error:",he)}})()},[e]);const[m,y]=j.useState(!1),[w,A]=j.useState([]),[k,I]=j.useState(""),[T,D]=j.useState(!1),[F,L]=j.useState(null),[q,Z]=j.useState(""),[K,z]=j.useState(0);j.useEffect(()=>{if(!e)return;const G=Qt(it(pe,"polls",e.id,"comments"));vn(G).then(he=>{z(he.size)}).catch(he=>{console.warn("Silent ignore count fetch error:",he)})},[e]),j.useEffect(()=>{if(!e||!m)return;const G=Qt(it(pe,"polls",e.id,"comments"),pi("createdAt","desc"));vn(G).then(he=>{const te=he.docs.map(le=>({id:le.id,...le.data()}));A(te)}).catch(he=>{Gs(he,Ps.LIST,`polls/${e.id}/comments`)})},[e,m]);const B=async(G,he=null)=>{var le,ve;if(G.preventDefault(),!Ne.currentUser||!e)return;const te=he?q:k;if(te.trim()){D(!0);try{const ke=it(pe,"polls",e.id,"comments");let Be={};if(he){const xe=w.find(ae=>ae.id===he);xe&&(Be={parentId:he,replyToAuthor:xe.authorName,replyToContent:xe.content.substring(0,50)})}const J={content:te.trim(),userId:Ne.currentUser.uid,authorName:Ne.currentUser.displayName||((le=Ne.currentUser.email)==null?void 0:le.split("@")[0])||"Peer",photoURL:Ne.currentUser.photoURL||"",createdAt:new Date,...Be},ie=await ur(ke,{content:te.trim(),userId:Ne.currentUser.uid,authorName:Ne.currentUser.displayName||((ve=Ne.currentUser.email)==null?void 0:ve.split("@")[0])||"Peer",photoURL:Ne.currentUser.photoURL||"",createdAt:Bn(),...Be});A(xe=>[{id:ie.id,...J},...xe]),z(xe=>xe+1),he?(Z(""),L(null)):I("")}catch(ke){console.error("Error dispatching poll comment:",ke)}finally{D(!1)}}};j.useEffect(()=>{const G=it(pe,"polls"),he=Qt(G,pi("createdAt","desc"),Pi(15));vn(he).then(te=>{if(!te.empty){const le=te.docs.find(ve=>{var ke;return((ke=ve.data())==null?void 0:ke.status)==="active"})||te.docs[0];if(le){t({...le.data(),id:le.id});return}}t(mk)}).catch(te=>{console.warn("Falling back to default poll on query error:",te),t(mk)})},[]),j.useEffect(()=>{Ne.currentUser&&e&&(async()=>{try{const he=ot(pe,"polls",e.id,"userVotes",Ne.currentUser.uid),te=await cs(he);te.exists()&&(r(!0),a(te.data().optionIndex))}catch(he){he.code!=="permission-denied"&&console.error("Error checking vote status:",he)}})()},[e]);const V=async G=>{if(Ne.currentUser&&!(n||o||!e)){c(!0);try{const he=ot(pe,"polls",e.id),te=ot(pe,"polls",e.id,"userVotes",Ne.currentUser.uid);await Hr(te,{userId:Ne.currentUser.uid,optionIndex:G,timestamp:new Date});const le=await cs(he);if(le.exists()){const ke=[...le.data().options];ke[G].votes+=1,await Hn(he,{options:ke,totalVotes:Ur(1)})}r(!0),a(G)}catch(he){console.error("Error voting:",he),he.code==="permission-denied"&&t(null)}finally{c(!1)}}};return e?s.jsxs("div",{className:"bg-white border border-gray-100 overflow-hidden group",children:[s.jsxs("div",{className:"bg-gray-900 p-6 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ek,{className:"text-red-500",size:24}),s.jsx("h3",{className:"text-xl font-black text-white uppercase tracking-tighter italic",children:"Campus Pulse Poll"})]}),s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1 bg-white/10 rounded-full",children:[s.jsx("span",{className:"w-1.5 h-1.5 bg-green-500 rounded-full"}),s.jsx("span",{className:"text-[8px] font-black text-white uppercase tracking-widest",children:"Ongoing"})]})]}),s.jsxs("div",{className:"p-8 space-y-6",children:[s.jsx("h4",{className:"text-2xl font-bold text-gray-900 leading-tight tracking-tight",children:e.question}),s.jsx("div",{className:"space-y-3",children:e.options.map((G,he)=>{const te=e.totalVotes>0?Math.round(G.votes/e.totalVotes*100):0,le=i===he,ve=G.text.replace(/^(support|vote\s+for|vote|elect)\s+/i,"").trim(),ke=h[G.text],Be=ke?`${ve} (${ke.votes} Votes)`:ve;return s.jsx("button",{disabled:n||o||!Ne.currentUser,onClick:()=>V(he),className:`w-full relative group/option flex flex-col transition-all overflow-hidden rounded-2xl border border-gray-150/80 shadow-3xs ${n?"cursor-default bg-white":"hover:scale-[1.01] cursor-pointer bg-gray-50"}`,children:s.jsxs("div",{className:`w-full p-5 flex flex-col gap-2.5 transition-colors ${le?"bg-red-50/15":"bg-transparent"}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex items-start gap-3 w-full",children:[s.jsx("div",{className:`w-5 h-5 rounded-full border-2 flex items-center justify-center transition-all shrink-0 mt-0.5 ${le?"border-accent bg-accent":"border-gray-300"}`,children:le&&s.jsx(Xh,{size:12,className:"text-white"})}),ke!=null&&ke.image?s.jsx("img",{src:ke.image||void 0,alt:"",className:"w-10 h-10 rounded-lg object-cover shrink-0 border border-gray-150"}):null,s.jsxs("div",{className:"flex-1 text-left",children:[s.jsx("span",{className:`text-[13px] font-extrabold leading-snug transition-colors uppercase tracking-tight block ${le?"text-accent":"text-gray-900"}`,children:Be}),(ke==null?void 0:ke.bio)&&s.jsx("p",{className:"text-[11px] text-gray-500 font-medium line-clamp-2 leading-relaxed mt-1 select-text",children:ke.bio}),(ke==null?void 0:ke.id)&&s.jsx("button",{onClick:J=>{J.stopPropagation();const ie=new CustomEvent("open-article",{detail:{id:ke.id}});window.dispatchEvent(ie)},className:"text-[9px] font-black text-red-650 hover:underline uppercase tracking-widest mt-1.5 inline-block cursor-pointer",children:"View Candidate Profile →"})]})]}),n&&s.jsxs("div",{className:"text-right shrink-0",children:[s.jsxs("span",{className:"text-sm font-black text-gray-950 font-mono italic block",children:[te,"%"]}),s.jsxs("span",{className:"text-[8px] font-bold text-gray-400 font-mono uppercase tracking-widest",children:[G.votes," votes"]})]})]}),n&&s.jsx("div",{className:"w-full h-3 bg-gray-100 rounded-full overflow-hidden mt-1 relative border border-gray-150/40",children:s.jsx(Kt.div,{initial:{width:0},animate:{width:`${te}%`},transition:{duration:.8,ease:"easeOut"},className:`h-full rounded-full transition-all ${le?"bg-accent":"bg-gray-400"}`})})]})},he)})}),s.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-100 select-none",children:[s.jsxs("div",{className:"flex items-center gap-2 text-gray-450 text-[10px] font-bold uppercase tracking-wider",children:[s.jsx(Ao,{size:14,className:"text-gray-450"}),s.jsxs("span",{children:[e.totalVotes," Votes"]})]}),s.jsxs("button",{onClick:()=>y(!m),className:"flex items-center gap-1.5 text-red-650 hover:text-red-700 font-extrabold cursor-pointer transition-colors",children:[s.jsx(Yi,{size:14}),s.jsx("span",{className:"text-[10px] uppercase tracking-widest",children:m?"Close Debates":`Discuss (${K})`})]})]}),s.jsx(ar,{children:m&&s.jsxs(Kt.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mt-6 pt-6 border-t border-gray-100 overflow-hidden text-left",children:[Ne.currentUser?s.jsx("form",{onSubmit:G=>B(G,null),className:"mb-6",children:s.jsxs("div",{className:"flex gap-2.5 items-start",children:[s.jsx("img",{src:(($=Ne.currentUser)==null?void 0:$.photoURL)||`https://ui-avatars.com/api/?name=${encodeURIComponent(((Q=Ne.currentUser)==null?void 0:Q.displayName)||((Y=Ne.currentUser)==null?void 0:Y.email)||"Peer")}&background=random`,className:"w-8 h-8 rounded-full border border-gray-150 object-cover mt-0.5",alt:""}),s.jsxs("div",{className:"flex-1 space-y-2",children:[s.jsx("textarea",{value:k,onChange:G=>I(G.target.value),placeholder:"State your stance on this debate...",rows:2,className:"w-full text-xs font-sans p-3 bg-gray-50 border border-gray-150 rounded-xl outline-none focus:outline-none focus:ring-1 focus:ring-red-500/20 focus:border-red-500 transition-all resize-none placeholder-gray-400"}),s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{type:"submit",disabled:T||!k.trim(),className:"bg-gray-950 text-white font-extrabold text-[9px] uppercase tracking-wider h-7 px-4 rounded-full hover:bg-red-650 transition-colors disabled:opacity-40 select-none cursor-pointer",children:"Dispatch Thought"})})]})]})}):s.jsx("div",{className:"bg-gray-50 rounded-xl p-3 text-center mb-6 border border-gray-100",children:s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Sign in to join the discussion"})}),s.jsx("div",{className:"space-y-4 max-h-96 overflow-y-auto pr-1",children:w.filter(G=>!G.parentId).length>0?w.filter(G=>!G.parentId).map(G=>{var le;const he=w.filter(ve=>ve.parentId===G.id),te=F===G.id;return s.jsxs("div",{className:"space-y-3.5 border-b border-gray-50 pb-4 last:border-0 last:pb-0",children:[s.jsxs("div",{className:"flex gap-2.5 items-start",children:[s.jsx("img",{src:G.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(G.authorName)}&background=random`,className:"w-7 h-7 rounded-full border border-gray-150 object-cover",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] font-black text-gray-950 uppercase tracking-tight",children:G.authorName}),s.jsx("span",{className:"text-[8px] font-bold text-gray-400 uppercase tracking-wider",children:(le=G.createdAt)!=null&&le.toDate?new Date(G.createdAt.toDate().getTime()).toLocaleDateString():"Now"})]}),s.jsx("p",{className:"text-xs text-gray-750 leading-relaxed font-sans mt-1",children:G.content}),Ne.currentUser&&s.jsx("div",{className:"flex items-center gap-4 mt-2",children:s.jsx("button",{type:"button",onClick:()=>{L(F===G.id?null:G.id),Z("")},className:"text-[9px] font-extrabold text-blue-600 hover:text-blue-700 uppercase tracking-widest cursor-pointer hover:underline",children:te?"Cancel":"Reply"})})]})]}),he.length>0&&s.jsx("div",{className:"ml-7 pl-3 border-l-2 border-gray-100/80 space-y-3",children:he.map(ve=>{var ke;return s.jsxs("div",{className:"flex gap-2.5 items-start",children:[s.jsx("img",{src:ve.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(ve.authorName)}&background=random`,className:"w-6 h-6 rounded-full border border-gray-150 object-cover mt-0.5",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] font-black text-gray-950 uppercase tracking-tight",children:ve.authorName}),s.jsx("span",{className:"text-[8px] font-bold text-gray-400 uppercase tracking-wider",children:(ke=ve.createdAt)!=null&&ke.toDate?new Date(ve.createdAt.toDate().getTime()).toLocaleDateString():"Now"})]}),s.jsxs("p",{className:"text-xs text-gray-750 leading-relaxed font-sans mt-0.5",children:[s.jsxs("span",{className:"text-blue-650 font-bold mr-1",children:["@",ve.replyToAuthor]}),ve.content]})]})]},ve.id)})}),te&&s.jsx("form",{onSubmit:ve=>B(ve,G.id),className:"ml-7 pl-3 border-l-2 border-red-100",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:q,onChange:ve=>Z(ve.target.value),placeholder:`Reply to @${G.authorName}...`,className:"flex-1 text-xs font-sans p-2 bg-gray-50 border border-gray-150 rounded-lg outline-none focus:ring-1 focus:ring-red-500/20 focus:border-red-500 transition-all placeholder-gray-400"}),s.jsx("button",{type:"submit",disabled:T||!q.trim(),className:"bg-red-600 text-white font-extrabold text-[8.5px] uppercase tracking-wider px-3 rounded-lg hover:bg-gray-950 transition-colors disabled:opacity-40 cursor-pointer",children:"Send"})]})})]},G.id)}):s.jsx("div",{className:"text-center py-6",children:s.jsx("p",{className:"text-[10px] font-black text-gray-350 uppercase tracking-widest italic",children:"The comments are silent. Dispatch your voice."})})})]})})]})]}):null},MMe=({url:e,isOpen:t,onClose:n,title:r})=>{const[i,a]=j.useState(e||""),[o,c]=j.useState(0),[h,f]=j.useState(!1),[m,y]=j.useState(!0);if(se.useEffect(()=>{if(e){let T=e;!T.startsWith("http://")&&!T.startsWith("https://")&&(T="https://"+T),a(T),y(!0);const D=setTimeout(()=>{y(!1)},1500);return()=>clearTimeout(D)}},[e,o]),!t||!e)return null;const w=()=>{y(!0),c(T=>T+1)},A=()=>{navigator.clipboard.writeText(i),f(!0),me.success("URL copied to clipboard!",{id:"browser-copy"}),setTimeout(()=>f(!1),2e3)},k=()=>{window.open(i,"_blank","noopener,noreferrer")};let I="web.page";try{I=new URL(i).hostname}catch{I=i}return s.jsx(ar,{children:s.jsxs("div",{className:"fixed inset-0 z-[9990] flex flex-col bg-zinc-950/90 backdrop-blur-xl animate-fade-in",children:[s.jsxs("div",{className:"bg-zinc-900 border-b border-zinc-800 px-3 py-2.5 flex items-center justify-between gap-2 shadow-lg shrink-0 text-white",children:[s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("button",{onClick:n,className:"p-2 rounded-xl bg-zinc-800 hover:bg-red-600 text-zinc-300 hover:text-white transition-colors cursor-pointer",title:"Close In-App Browser",children:s.jsx(er,{size:16})}),s.jsx("button",{onClick:w,className:"p-2 rounded-xl bg-zinc-800 hover:bg-zinc-700 text-zinc-300 hover:text-white transition-colors cursor-pointer",title:"Reload Page",children:s.jsx(cF,{size:14,className:m?"animate-spin":""})})]}),s.jsxs("div",{className:"flex-1 max-w-2xl bg-zinc-950 border border-zinc-800 hover:border-zinc-700 rounded-xl px-3 py-1.5 flex items-center gap-2 transition-all",children:[s.jsx(oF,{size:12,className:"text-emerald-500 shrink-0"}),s.jsx("span",{className:"text-[10px] font-mono font-bold text-emerald-400 shrink-0 uppercase tracking-wider hidden sm:inline",children:"HTTPS"}),s.jsx("span",{className:"text-zinc-500 text-[11px] font-mono",children:"|"}),s.jsx("input",{type:"text",readOnly:!0,value:i,className:"w-full bg-transparent text-xs font-mono text-zinc-200 outline-none truncate"}),s.jsx("button",{onClick:A,className:"text-zinc-400 hover:text-white p-1 rounded transition-colors shrink-0 cursor-pointer",title:"Copy URL",children:h?s.jsx(Pu,{size:13,className:"text-emerald-400"}):s.jsx(Pw,{size:13})})]}),s.jsx("div",{className:"flex items-center gap-2 shrink-0",children:s.jsxs("button",{onClick:k,className:"px-3 py-1.5 rounded-xl bg-zinc-800 hover:bg-zinc-700 text-zinc-200 hover:text-white text-xs font-mono font-bold flex items-center gap-1.5 transition-colors cursor-pointer",title:"Open in new browser window",children:[s.jsx(Va,{size:13}),s.jsx("span",{className:"hidden md:inline text-[10px] uppercase tracking-wider",children:"External"})]})})]}),s.jsxs("div",{className:"flex-1 relative bg-white w-full h-full overflow-hidden",children:[m&&s.jsxs("div",{onClick:()=>y(!1),className:"absolute inset-0 bg-zinc-950/20 backdrop-blur-sm z-10 flex flex-col items-center justify-center cursor-pointer space-y-3 transition-opacity duration-300",title:"Click to dismiss overlay",children:[s.jsx("div",{className:"w-10 h-10 border-3 border-red-600 border-t-transparent rounded-full animate-spin"}),s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-zinc-900/90 text-white rounded-full border border-zinc-800 shadow-xl",children:[s.jsx(iF,{size:14,className:"text-red-500 "}),s.jsxs("span",{className:"text-xs font-mono uppercase tracking-widest font-bold",children:["Connecting to ",I,"..."]})]})]}),s.jsx("iframe",{src:i,onLoad:()=>y(!1),className:"w-full h-full border-0",title:r||"Inbuilt App Browser",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; camera; microphone; geolocation",sandbox:"allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"},o)]})]})})},LMe=({size:e="md",showBadge:t=!1,className:n=""})=>{const r={xs:"w-6 h-6 text-[10px]",sm:"w-8 h-8 text-xs",md:"w-10 h-10 text-sm",lg:"w-14 h-14 text-base"};return s.jsxs("div",{className:Ge("relative inline-flex items-center gap-2 group select-none",n),children:[s.jsxs("div",{className:Ge("relative rounded-2xl flex items-center justify-center shrink-0 overflow-hidden shadow-lg","bg-gradient-to-br from-cyan-950 via-slate-900 to-purple-950 border border-cyan-400/50","shadow-cyan-500/25",r[e]),children:[s.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-cyan-400 via-blue-500 to-purple-500 rounded-2xl opacity-40 blur-xs group-hover:opacity-80 transition-opacity"}),s.jsx("img",{src:Vo,alt:"Mega AI Avatar",className:"w-full h-full object-cover rounded-2xl relative z-10"}),s.jsx("div",{className:"absolute top-0.5 right-0.5 w-1.5 h-1.5 bg-cyan-400 rounded-full shadow-[0_0_6px_#38bdf8] z-20 animate-pulse"})]}),t&&s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-extrabold text-xs tracking-tight bg-gradient-to-r from-cyan-400 via-blue-400 to-purple-400 bg-clip-text text-transparent",children:"Mega AI"}),s.jsxs("span",{className:"bg-gradient-to-r from-cyan-950 to-blue-900 border border-cyan-500/40 text-cyan-300 text-[8px] font-mono font-black px-1.5 py-0.5 rounded-md flex items-center gap-1 shadow-2xs",children:[s.jsx(fF,{size:9,className:"text-cyan-400 shrink-0"}),s.jsx("span",{children:"NEURAL CORE"})]})]}),s.jsxs("span",{className:"text-[9px] font-mono text-cyan-500/80 flex items-center gap-1",children:[s.jsx(ire,{size:9})," Autonomous Quantum Intelligence"]})]})]})};let rp=null,RV=null,gk=null;const Xv=e=>{var n;return e.username?e.username:(e.displayName||((n=e.email)==null?void 0:n.split("@")[0])||"peer").toLowerCase().replace(/[^a-z0-9]/g,"")},UMe=e=>{if(!e)return[];const t=/(https?:\/\/[^\s]+)/g;return e.match(t)||[]},Jx=(e,t)=>{if(!e)return"";const n=/(https?:\/\/[^\s]+|@Mega\s+AI|@Mega|@megaai|@Me|@[a-zA-Z0-9_\-]+|#[a-zA-Z0-9_\-]+)/gi;return e.split(n).map((i,a)=>i?i.startsWith("http://")||i.startsWith("https://")?s.jsx("a",{href:i,onClick:o=>{o.preventDefault(),o.stopPropagation(),t?t(i):window.open(i,"_blank","noopener,noreferrer")},className:"text-blue-600 font-bold hover:underline select-text inline-flex items-center gap-0.5 break-all cursor-pointer",children:i},a):/^@(Mega\s+AI|Mega|megaai|Me)$/i.test(i)?s.jsxs("span",{className:"bg-gradient-to-r from-amber-500 via-purple-600 to-red-600 text-white font-extrabold text-[10px] px-2 py-0.5 rounded-full inline-flex items-center gap-1 shadow-xs my-0.5 select-none",children:[s.jsx(es,{size:10,className:"text-amber-200 shrink-0"})," ",i]},a):i.startsWith("@")?s.jsx("span",{className:"text-blue-600 font-extrabold hover:underline select-text bg-blue-50/80 border border-blue-100 px-1 py-0.2 rounded mx-0.5",children:i},a):i.startsWith("#")?s.jsx("span",{className:"text-red-650 font-black hover:underline select-text bg-red-50/80 px-1.5 py-0.5 rounded-md border border-red-200/80 mx-0.5 inline-block",children:i},a):i:null)},Qv={},BMe=({url:e,onOpenUrl:t})=>{const[n,r]=j.useState(()=>{if(Qv[e])return Qv[e];try{const f=localStorage.getItem(`lp_${e}`);if(f){const m=JSON.parse(f);return Qv[e]=m,m}}catch{}return null});j.useEffect(()=>{if(n)return;let f=!0;return(async()=>{var y,w,A;try{const k=await fetch(`https://api.microlink.io?url=${encodeURIComponent(e)}`);if(k.ok){const I=await k.json();if(I.status==="success"&&I.data){const T={title:I.data.title||I.data.publisher||e,description:I.data.description||"",image:((y=I.data.image)==null?void 0:y.url)||((w=I.data.logo)==null?void 0:w.url)||"",logo:((A=I.data.logo)==null?void 0:A.url)||`https://www.google.com/s2/favicons?domain=${e}&sz=64`,publisher:I.data.publisher||""};Qv[e]=T;try{localStorage.setItem(`lp_${e}`,JSON.stringify(T))}catch{}f&&r(T)}}}catch(k){console.warn("Link preview fetch failed:",k)}})(),()=>{f=!1}},[e,n]);let i=e;try{i=new URL(e).hostname.replace(/^www\./,"")}catch{}const a=(n==null?void 0:n.title)||e,o=(n==null?void 0:n.description)||"",c=(n==null?void 0:n.image)||"",h=(n==null?void 0:n.logo)||`https://www.google.com/s2/favicons?domain=${e}&sz=64`;return s.jsxs("div",{onClick:f=>{f.stopPropagation(),t(e)},className:"my-3.5 rounded-2xl border border-slate-800 bg-[#0f172a] text-white overflow-hidden cursor-pointer group transition-all hover:border-slate-600 shadow-lg text-left",children:[c?s.jsxs("div",{className:"relative w-full max-h-[300px] bg-slate-950 overflow-hidden flex items-center justify-center",children:[s.jsx("img",{src:c,alt:"",loading:"lazy",decoding:"async",className:"w-full h-auto max-h-[300px] object-cover group-hover:scale-102 transition-transform duration-300",onError:f=>{f.target.style.display="none"}}),s.jsxs("div",{className:"absolute top-3 left-3 flex items-center gap-1.5 px-3 py-1 bg-black/80 backdrop-blur-md rounded-full text-white text-[10px] font-mono font-bold border border-white/10 shadow-sm",children:[s.jsx("img",{src:h,alt:"",className:"w-3.5 h-3.5 rounded-full object-contain shrink-0",onError:f=>{f.target.src="https://ui-avatars.com/api/?name=Web&background=0D8ABC&color=fff"}}),s.jsx("span",{className:"truncate max-w-[160px]",children:i})]}),s.jsx("div",{className:"absolute top-3 right-3 p-2 bg-black/80 hover:bg-black backdrop-blur-md rounded-full text-white transition-colors border border-white/10 shadow-sm",children:s.jsx(Va,{size:13})})]}):s.jsxs("div",{className:"p-3 bg-slate-900 border-b border-slate-800 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:h,className:"w-4 h-4 rounded-full object-contain",alt:""}),s.jsx("span",{className:"text-[10px] font-mono text-slate-300 font-bold",children:i})]}),s.jsx(Va,{size:12,className:"text-slate-400"})]}),s.jsxs("div",{className:"p-4 space-y-1.5 bg-[#0f172a]",children:[s.jsx("h4",{className:"text-sm font-extrabold text-white leading-snug line-clamp-2 group-hover:text-blue-400 transition-colors font-sans",children:a}),o&&s.jsx("p",{className:"text-xs text-slate-300 leading-relaxed line-clamp-2 font-normal font-sans",children:o}),s.jsxs("div",{className:"pt-2 flex items-center gap-1.5 text-[10px] font-mono text-slate-400 font-bold uppercase tracking-wider",children:[s.jsx("img",{src:h,className:"w-3.5 h-3.5 rounded-full object-contain",alt:""}),s.jsxs("span",{children:["from ",i]})]})]})]})},zMe=({isAdmin:e=!1,onUserProfileClick:t,sharedPostId:n})=>{var Et,Oa,Tr,Hi,jo,or,kr,lr;const[r,i]=j.useState(rp||[]),[a,o]=j.useState(RV||{}),[c,h]=j.useState(!rp),[f,m]=j.useState(""),[y,w]=j.useState(1),[A,k]=j.useState(10),[I,T]=j.useState(100),D=j.useRef(r.length);j.useEffect(()=>{D.current=r.length},[r.length]);const F=j.useRef(null),L=se.useCallback(Re=>{F.current&&F.current.disconnect(),Re&&(F.current=new IntersectionObserver(mt=>{var Je;(Je=mt[0])!=null&&Je.isIntersecting&&T(vt=>Math.max(vt+10,100))},{rootMargin:"250px"}),F.current.observe(Re))},[]),[q,Z]=j.useState([]),K=j.useRef(!0),z=j.useRef(rp||[]);j.useEffect(()=>{z.current=r},[r]);const[B,V]=j.useState(n||null),[$,Q]=j.useState(null),[Y,G]=j.useState(!1),[he,te]=j.useState(""),[le,ve]=j.useState(!1),[ke,Be]=j.useState(null),[J,ie]=j.useState(!1);j.useRef(null);const[xe,ae]=j.useState(gk||[]),[Fe,pt]=j.useState(!gk),[Ue,Ct]=j.useState(!1),[Tt,ht]=j.useState(null),[Ye,Yt]=j.useState(0),dt=se.useMemo(()=>Tt===null?[]:xe.filter(Re=>{const mt=(Re.username||Xv(Re)).toLowerCase(),Je=(Re.displayName||"").toLowerCase(),vt=Tt.toLowerCase();return mt.includes(vt)||Je.includes(vt)}).slice(0,5),[Tt,xe]),sn=Re=>{const mt=Re.target.value;te(mt);const Je=Re.target.selectionStart,Zt=mt.substring(0,Je).split(/[\s]/),wn=Zt[Zt.length-1];wn.startsWith("@")?(ht(wn.substring(1)),Yt(Je)):ht(null)},[pn,Fn]=j.useState(null),[Ft,Dt]=j.useState(!1),Ht=Re=>{let mt=Re;!mt.startsWith("http://")&&!mt.startsWith("https://")&&(mt="https://"+mt),Fn(mt),Dt(!0)},[Ze,Wt]=j.useState({}),[It,ln]=j.useState({}),[Kn,un]=j.useState({}),[xr,Ve]=j.useState({}),[Ot,nn]=j.useState({}),[mn,dr]=j.useState({}),[hr,Ui]=j.useState({}),[$n,be]=j.useState({}),[je,ze]=j.useState({}),[tt,fn]=j.useState(null),[Bt,jn]=j.useState({}),[jt,on]=j.useState({}),[Ir,pr]=j.useState(!1),[ue,Se]=j.useState(""),[Xe,Vt]=j.useState(!1),[gn,xn]=j.useState({}),[yn,gt]=j.useState(null),[Tn,Nt]=j.useState(null),Ae=Ne.currentUser,[tn,yt]=j.useState(null),[cn,Pt]=j.useState(new Set);j.useEffect(()=>{if(!Ae)return;const Re=di(ot(pe,"users",Ae.uid),mt=>{mt.exists()&&yt(mt.data())});return()=>Re()},[Ae]),j.useEffect(()=>{if(!Ae)return;const Re=Qt(it(pe,"invitations"),Nr("senderId","==",Ae.uid)),mt=Qt(it(pe,"invitations"),Nr("receiverId","==",Ae.uid));let Je=[],vt=[];const Zt=()=>{const Ut=new Set;[...Je,...vt].forEach(On=>{On.status==="accepted"&&(On.senderId===Ae.uid?(On.receiverId&&Ut.add(On.receiverId),On.targetUserId&&Ut.add(On.targetUserId)):(On.receiverId===Ae.uid||On.targetUserId===Ae.uid)&&On.senderId&&Ut.add(On.senderId))}),Pt(Ut)},wn=di(Re,Ut=>{Je=Ut.docs.map(On=>On.data()),Zt()}),Le=di(mt,Ut=>{vt=Ut.docs.map(On=>On.data()),Zt()});return()=>{wn(),Le()}},[Ae]),j.useEffect(()=>{const Re=Qt(it(pe,"posts"),pi("createdAt","desc"),Pi(I)),mt=di(Re,Je=>{const vt=Je.docs.map(Ut=>({id:Ut.id,...Ut.data()})).filter(Ut=>!Ut.flagged);if(K.current){K.current=!1,i(vt),rp=vt,z.current=vt,h(!1);return}const Zt=new Map(z.current.map(Ut=>[Ut.id,Ut])),wn=[],Le=[];for(const Ut of vt)if(Zt.has(Ut.id)){const On=Zt.get(Ut.id);JSON.stringify(On)!==JSON.stringify(Ut)&&Le.push(Ut)}else wn.push(Ut);if(Le.length>0&&i(Ut=>{const On=Ut.map(Mn=>{const Pn=Le.find(vr=>vr.id===Mn.id);return Pn||Mn});return z.current=On,rp=On,On}),wn.length>0){const Ut=wn.filter(Mn=>Ae&&Mn.authorId===Ae.uid),On=wn.filter(Mn=>!Ae||Mn.authorId!==Ae.uid);Ut.length>0&&i(Mn=>{const Pn=new Set(Mn.map(fe=>fe.id)),Me=[...Ut.filter(fe=>!Pn.has(fe.id)),...Mn];return z.current=Me,rp=Me,Me}),On.length>0&&Z(Mn=>{const Pn=new Set(Mn.map(Me=>Me.id)),vr=On.filter(Me=>!Pn.has(Me.id));return vr.length===0?Mn:[...vr,...Mn]})}h(!1)},Je=>{Gs(Je,Ps.LIST,"posts"),h(!1)});return()=>mt()},[Ae,n,I]);const Sn=()=>{q.length!==0&&(i(Re=>{const mt=[...q,...Re];return z.current=mt,rp=mt,mt}),Z([]),window.scrollTo({top:0,behavior:"smooth"}))};j.useEffect(()=>{if(!Ae)return;const Re=Qt(it(pe,"follows")),mt=di(Re,Je=>{const vt={};Je.docs.forEach(Zt=>{const wn=Zt.data();wn.followerId===Ae.uid&&(vt[wn.followedId]=!0)}),o(vt),RV=vt},Je=>{console.warn("Silent ignored follows fetch error:",Je)});return()=>mt()},[Ae]),j.useEffect(()=>{if(!Ae)return;pt(!0);const Re=Qt(it(pe,"users"),Pi(20));vn(Re).then(vt=>{const wn=vt.docs.map(Le=>({uid:Le.id,...Le.data()})).filter(Le=>Le.uid!==Ae.uid);ae(wn),gk=wn,pt(!1)}).catch(vt=>{console.warn("Silent ignore users list fetch error:",vt),pt(!1)});const mt=Qt(it(pe,"invitations"),Nr("senderId","==",Ae.uid)),Je=di(mt,vt=>{const Zt={};vt.docs.forEach(wn=>{const Le=wn.data();Le.senderId===Ae.uid&&(Zt[Le.receiverId]=!0)}),xn(Zt)},vt=>{console.warn("Silent ignore invitations fetch error:",vt)});return()=>{Je()}},[Ae]),j.useEffect(()=>{n&&r.some(Re=>Re.id===n)&&(ze(Re=>({...Re,[n]:!0})),$n[n]||_r(n),setTimeout(()=>{const Re=document.getElementById(`post-card-${n}`);Re&&Re.scrollIntoView({behavior:"smooth",block:"center"})},600))},[n,r]),j.useEffect(()=>{n&&V(n)},[n]),j.useEffect(()=>{if(!B){Q(null);return}const Re=r.find(mt=>mt.id===B);Re?Q(Re):(G(!0),cs(ot(pe,"posts",B)).then(mt=>{mt.exists()?Q({id:mt.id,...mt.data()}):Q(null),G(!1)}).catch(mt=>{console.error("Failed to load custom shared post:",mt),G(!1)}))},[B,r]),j.useEffect(()=>{if(!B)return;const Re=Qt(it(pe,"posts",B,"comments"),pi("createdAt","asc")),mt=di(Re,Je=>{const vt=Je.docs.map(Zt=>({id:Zt.id,...Zt.data()}));Wt(Zt=>({...Zt,[B]:vt}))},Je=>{console.warn("Error tracking focused post comments:",Je)});return()=>mt()},[B]),j.useEffect(()=>{if(!tt)return;const Re=Qt(it(pe,"posts",tt,"comments"),pi("createdAt","asc")),mt=di(Re,Je=>{const vt=Je.docs.map(Zt=>({id:Zt.id,...Zt.data()}));Wt(Zt=>({...Zt,[tt]:vt}))},Je=>{console.warn("Error tracking active comment post comments:",Je)});return()=>mt()},[tt]);const _r=Re=>{fn(Re);const mt=!$n[Re];if(be(Je=>({...Je,[Re]:mt})),!Ze[Re]){const Je=Qt(it(pe,"posts",Re,"comments"),pi("createdAt","asc"));di(Je,vt=>{const Zt=vt.docs.map(wn=>({id:wn.id,...wn.data()}));Wt(wn=>({...wn,[Re]:Zt}))},vt=>{Gs(vt,Ps.LIST,`posts/${Re}/comments`)})}},xi=(Re,mt)=>{const vt=!!!je[Re];ze(Zt=>({...Zt,[Re]:vt}));try{const Zt=new URL(window.location.href);vt?(Zt.searchParams.set("post",Re),document.title=`${mt.substring(0,30)}... | Student Lounge`):(Zt.searchParams.delete("post"),document.title="Student Lounge Feed | Campus Eye"),window.history.replaceState({},"",Zt.toString())}catch(Zt){console.warn("History push error on post expand:",Zt)}},rs=async Re=>{var Je;const mt=(Je=Re.target.files)==null?void 0:Je[0];if(mt){ve(!0);try{const vt=await h4(mt);Be(vt),me.success("Image uploaded successfully!")}catch(vt){me.error(vt.message||"Failed to upload image")}finally{ve(!1)}}},mi=async Re=>{var Zt,wn,Le,Ut;if(Re.preventDefault(),!Ae){me.error("Please sign in to post");return}if(!he.trim()&&!ke){me.error("Add some text or an image to post!");return}const mt=!!(tn!=null&&tn.isPremiumPostUser||tn!=null&&tn.isVerified||tn!=null&&tn.isPremium||tn!=null&&tn.blueCheck||e),Je=(tn==null?void 0:tn.freePostsRemaining)??1;if(!mt&&Je<=0){try{await ur(it(pe,"notifications"),{userId:"admin_all",type:"unlimited_posting_request",title:`🎟️ Unlimited Posting Request from @${Ae.displayName||((Zt=Ae.email)==null?void 0:Zt.split("@")[0])||"Peer"}`,message:`@${Ae.displayName||((wn=Ae.email)==null?void 0:wn.split("@")[0])||"Peer"} (UID: ${Ae.uid}) has requested admin approval to unlock unlimited posting on Campus Eye.`,requestAuthorId:Ae.uid,requestAuthorName:Ae.displayName||((Le=Ae.email)==null?void 0:Le.split("@")[0])||"Peer",used:!1,createdAt:Bn()})}catch(On){console.error("Error creating posting approval request:",On)}me.error("You have used your 1 Free Trial Post! An approval request has been sent to Campus Eye admins to unlock unlimited posting.",{duration:6e3});return}const vt=me.loading("Dispatching post...");try{const On=he.trim(),Mn=await ur(it(pe,"posts"),{content:On,imageUrl:ke||null,authorId:Ae.uid,authorName:Ae.displayName||((Ut=Ae.email)==null?void 0:Ut.split("@")[0])||"Peer",authorPhotoURL:Ae.photoURL||"",createdAt:Bn(),likeCount:0,commentCount:0,likedBy:[],reportsCount:0,flagged:!1,isTrialPost:!mt,isApprovedByAdmin:mt});try{const Me=`${window.location.origin}/p/post/${Mn.id}`;fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:Me,title:`Campus Dispatch by ${Ae.displayName||"Peer"}`,image:ke||""})}).catch(()=>{})}catch{}!mt&&Je>0&&await Hr(ot(pe,"users",Ae.uid),{freePostsRemaining:0,isPremiumPostUser:!1},{merge:!0}),(On.toLowerCase().includes("@mega")||On.toLowerCase().includes("@megaai"))&&h2(On,Ae.displayName||"Peer Student",Ae.uid,{type:"post",postId:Mn.id}).then(async Me=>{Me&&(await ur(it(pe,"posts",Mn.id,"comments"),{postId:Mn.id,content:Me,authorId:"mega-ai-bot",authorName:"Mega AI",authorPhotoURL:Vo,createdAt:Bn(),likeCount:0,likedBy:[],isAIGenerated:!0}),await Hn(ot(pe,"posts",Mn.id),{commentCount:Ur(1)}),me.success("Mega AI auto-replied to your mention!",{icon:"✨"}))}).catch(Me=>console.error("Mega AI post trigger error:",Me));const Pn=On.match(/@([a-zA-Z0-9_\-]+)/g)||[],vr=Array.from(new Set(Pn.map(Me=>Me.substring(1).toLowerCase())));for(const Me of vr){const fe=xe.find(rn=>(rn.username||Xv(rn)).toLowerCase()===Me);if(fe&&fe.uid!==Ae.uid)try{await ur(it(pe,"notifications"),{userId:fe.uid,title:`👋 @${Xv(Ae)} mentioned you`,message:`${Ae.displayName||"A peer"} mentioned you in a Lounge dispatch: "${On.substring(0,60)}..."`,used:!1,type:"mention",createdAt:Bn()})}catch(rn){console.warn("Silent ignored notification creation error:",rn)}}te(""),Be(null),me.success("Post dispatched successfully!",{id:vt})}catch(On){me.error("Failed to post: "+On.message,{id:vt})}},fa=async(Re,mt=[])=>{if(!Ae)return;const Je=mt.includes(Ae.uid),vt=ot(pe,"posts",Re);try{Je?await Hn(vt,{likedBy:qD(Ae.uid),likeCount:Ur(-1)}):await Hn(vt,{likedBy:GD(Ae.uid),likeCount:Ur(1)})}catch(Zt){console.error("Like toggle exception:",Zt)}},is=async(Re,mt)=>{if(!Ae){me.error("Sign in with Google to react to comments!",{icon:"🔒"});return}const Je=jt[mt];on(vt=>({...vt,[mt]:!Je}));try{const vt=ot(pe,"posts",Re,"comments",mt);await Hn(vt,{likeCount:Ur(Je?-1:1),likedBy:Je?qD(Ae.uid):GD(Ae.uid)})}catch(vt){console.error("Error liking post comment:",vt),on(Zt=>({...Zt,[mt]:Je}))}},hi=async Re=>{var Le;if(!Ae)return;const mt=It[Re]||"",Je=Kn[Re]||null,vt=xr[Re]||null,Zt=Ot[Re]||null;if(!mt.trim()&&!Je&&!vt&&!Zt)return;const wn=Bt[Re];Ui(Ut=>({...Ut,[Re]:!0}));try{const Ut=it(pe,"posts",Re,"comments");await ur(Ut,{postId:Re,content:mt.trim()||(Je?`[Sticker ${Je}]`:"[Attachment]"),authorId:Ae.uid,authorName:Ae.displayName||((Le=Ae.email)==null?void 0:Le.split("@")[0])||"Peer",authorPhotoURL:Ae.photoURL||"",createdAt:Bn(),parentId:(wn==null?void 0:wn.commentId)||null,replyToAuthor:(wn==null?void 0:wn.authorName)||null,likeCount:0,likedBy:[],...Je?{stickerEmoji:Je}:{},...vt?{imageUrl:vt}:{},...Zt?{audioUrl:Zt}:{}});const On=ot(pe,"posts",Re);await Hn(On,{commentCount:Ur(1)}),ln(Mn=>({...Mn,[Re]:""})),un(Mn=>({...Mn,[Re]:""})),Ve(Mn=>({...Mn,[Re]:""})),nn(Mn=>({...Mn,[Re]:""})),jn(Mn=>({...Mn,[Re]:null})),dr(Mn=>({...Mn,[Re]:!1})),(mt.toLowerCase().includes("@mega")||mt.toLowerCase().includes("@megaai"))&&h2(mt,Ae.displayName||"Peer Student",Ae.uid,{type:"post_comment",postId:Re,commentId:wn==null?void 0:wn.commentId}).then(async Mn=>{Mn&&(await ur(it(pe,"posts",Re,"comments"),{postId:Re,content:Mn,authorId:"mega-ai-bot",authorName:"Mega AI",authorPhotoURL:Vo,createdAt:Bn(),parentId:(wn==null?void 0:wn.commentId)||null,replyToAuthor:Ae.displayName||"Peer",likeCount:0,likedBy:[],isAIGenerated:!0}),await Hn(ot(pe,"posts",Re),{commentCount:Ur(1)}),me.success("Mega AI auto-replied to your comment!",{icon:"✨"}))}).catch(Mn=>console.error("Mega AI comment trigger error:",Mn))}catch(Ut){console.error("Error creating post comment:",Ut)}finally{Ui(Ut=>({...Ut,[Re]:!1}))}},Wr=async Re=>{if(!Ae)return;const mt=ot(pe,"posts",Re);me.success("Thank you. Post flagged and hidden from view.",{icon:"🛡️"});try{await Hn(mt,{reportsCount:Ur(1),flagged:!0})}catch(Je){console.error("Error reporting post:",Je)}},Sr=async Re=>{var mt;if(Ae){if(!e&&((mt=Ae.email)==null?void 0:mt.toLowerCase())!=="atwiinevictor2@gmail.com"){me.error("Access Denied: Only administrators can delete posts.");return}if(yn!==Re){gt(Re),setTimeout(()=>{gt(Je=>Je===Re?null:Je)},4e3);return}try{await ni(ot(pe,"posts",Re)),me.success("Post deleted successfully!"),gt(null)}catch(Je){me.error("Failed to delete post: "+Je.message)}}},Qi=async(Re,mt)=>{if(!Ae){localStorage.setItem("pending_follow_uid",Re),localStorage.setItem("pending_follow_name",mt),me.success(`Complete google sign-up to follow @${mt.toLowerCase().replace(/\s+/g,"")}!`,{icon:"🔐"}),window.dispatchEvent(new CustomEvent("open-lounge-auth"));return}const Je=`${Ae.uid}_${Re}`,vt=ot(pe,"follows",Je),Zt=a[Re];try{if(Zt){await ni(vt),me.success(`Unfollowed @${mt.toLowerCase().replace(/\s+/g,"")}`);const wn=Ae.displayName?`@${Ae.displayName.toLowerCase().replace(/\s+/g,"")}`:"A peer";try{const Le=`notif_unfollow_${Ae.uid}_${Re}`;await Hr(ot(pe,"notifications",Le),{userId:Re,title:"💔 Lounge Unfollow",message:`${wn} unfollowed you.`,type:"social",used:!0,createdAt:new Date})}catch(Le){console.warn("Failed to create unfollow notification:",Le)}}else{await Hr(vt,{followerId:Ae.uid,followedId:Re,createdAt:Bn()}),me.success(`Following @${mt.toLowerCase().replace(/\s+/g,"")}!`,{icon:"🤝"});const wn=Ae.displayName?`@${Ae.displayName.toLowerCase().replace(/\s+/g,"")}`:"A peer";try{const Le=`notif_follow_${Ae.uid}_${Re}`;await Hr(ot(pe,"notifications",Le),{userId:Re,title:"👥 New Lounge Follower!",message:`${wn} is now following you. They will receive your latest dispatches!`,type:"social",createdAt:new Date})}catch(Le){console.warn("Failed to create follow notification from lounge:",Le)}}}catch(wn){console.error("Follow toggling issue:",wn)}},ss=async(Re,mt,Je)=>{const vt=`${window.location.origin}/p/post/${Re}`,Zt=mt||"Check out this Post on Campus Eye",wn=Zt.length>140?`${Zt.substring(0,140)}...`:Zt;try{fetch("/api/append-sitemap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:vt,title:"Campus Dispatch | Campus Eye Lounge",image:Je||""})}).catch(()=>{})}catch{}try{if(navigator.share){const Le={title:"Campus Dispatch | Campus Eye Lounge",text:`📣 Campus Dispatch: "${wn}"${Je?` Preview: ${Je}`:""} Read dispatch:`,url:vt};await navigator.share(Le),me.success("Post shared successfully!")}else{const Le=`📣 Campus Dispatch: "${wn}"${Je?` 🖼️ Preview Image: ${Je}`:""} 🔗 Open direct post: ${vt}`;await Pd(Le),me.success("Post preview link & image copied to clipboard!")}}catch(Le){if(Le.name!=="AbortError")try{const Ut=`📣 Campus Dispatch: "${wn}"${Je?` 🖼️ Preview Image: ${Je}`:""} 🔗 Open direct post: ${vt}`;await Pd(Ut),me.success("Post link copied to clipboard!")}catch{}}},si=async Re=>{var Je,vt;if(!Ae){me.error("Please sign in to invite peers!");return}const mt=`${Ae.uid}_${Re.uid}`;try{await Hr(ot(pe,"invitations",mt),{id:mt,senderId:Ae.uid,senderName:Ae.displayName||((Je=Ae.email)==null?void 0:Je.split("@")[0])||"Peer",senderPhotoURL:Ae.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Ae.displayName||"Peer")}&background=random`,receiverId:Re.uid,receiverName:Re.displayName||((vt=Re.email)==null?void 0:vt.split("@")[0])||"Peer",status:"pending",createdAt:Bn()}),me.success(`Lounge invite sent to @${(Re.displayName||"peer").toLowerCase().replace(/\s+/g,"")}!`,{icon:"🚀"})}catch(Zt){me.error("Failed to send invite: "+Zt.message)}};return s.jsxs("div",{className:"bg-gray-50/50 min-h-screen py-3 sm:py-6 px-1 sm:px-6 w-full max-w-[1680px] xl:max-w-[1780px] 2xl:max-w-[1880px] mx-auto text-left select-none pb-24",children:[s.jsx("div",{className:"flex justify-end items-center mb-4",children:s.jsxs("button",{onClick:()=>pr(!0),className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-650 hover:bg-red-700 text-white rounded-xl text-[10px] font-black uppercase tracking-wider transition-all shadow-md active:scale-95 cursor-pointer shrink-0",children:[s.jsx(Ao,{size:12,strokeWidth:2.5}),s.jsx("span",{children:"Invite Peers"})]})}),Ae?s.jsx("div",{className:"bg-white border border-gray-150 rounded-2xl p-4 shadow-sm mb-6 transition-all duration-350",children:s.jsx("form",{onSubmit:mi,children:s.jsxs("div",{className:"flex gap-3",children:[s.jsx("img",{src:(Ae==null?void 0:Ae.photoURL)||`https://ui-avatars.com/api/?name=${encodeURIComponent((Ae==null?void 0:Ae.displayName)||"Peer")}&background=random`,className:"w-10 h-10 rounded-full border border-gray-100 object-cover shrink-0 mt-1",alt:""}),s.jsxs("div",{className:"flex-1 space-y-3",children:[s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("textarea",{value:he,onFocus:()=>ie(!0),onChange:sn,placeholder:"What's on your mind? Share it.",rows:J?3:1,className:"w-full text-xs font-sans placeholder-gray-400 bg-transparent border-0 resize-none focus:ring-0 focus:outline-none pt-2 transition-all duration-300"}),!J&&s.jsx("button",{type:"button",onClick:()=>ie(!0),className:"p-2 text-red-650 hover:bg-red-50 rounded-full transition-all cursor-pointer shrink-0",title:"Write post",children:s.jsx(fl,{size:15})})]}),Tt!==null&&dt.length>0&&s.jsxs("div",{className:"bg-white border border-gray-150 rounded-xl shadow-lg p-1 max-h-48 overflow-y-auto mb-2 space-y-0.5 divide-y divide-gray-50 z-50",children:[s.jsx("div",{className:"px-3 py-1 text-[9px] font-black uppercase text-gray-400 tracking-wider",children:"Mention a Peer"}),dt.map(Re=>{const mt=Re.username||Xv(Re);return s.jsxs("button",{type:"button",onClick:()=>{const Je=he.substring(0,Ye-Tt.length-1),vt=he.substring(Ye),Zt=`${Je}@${mt} ${vt}`;te(Zt),ht(null)},className:"w-full text-left flex items-center gap-2 px-3 py-1.5 hover:bg-neutral-55 rounded-lg transition-colors cursor-pointer",children:[s.jsx("img",{src:Re.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Re.displayName||"Peer")}&background=random`,className:"w-6 h-6 rounded-full border border-gray-100 object-cover",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[11px] font-extrabold text-gray-905 truncate",children:Re.displayName||"Peer"}),s.jsxs("p",{className:"text-[9px] font-mono font-bold text-blue-600 truncate",children:["@",mt]})]})]},Re.uid)})]}),J&&s.jsxs("div",{className:"space-y-3",children:[ke&&s.jsxs("div",{className:"relative rounded-xl overflow-hidden border border-gray-150 max-h-56 bg-gray-50",children:[s.jsx("img",{src:ke,className:"w-full h-full object-cover",alt:"Selected Preview"}),s.jsx("button",{type:"button",onClick:()=>Be(null),className:"absolute top-2.5 right-2.5 w-6 h-6 rounded-full bg-black/70 text-white flex items-center justify-center hover:bg-black transition-colors",children:s.jsx(er,{size:13})})]}),s.jsxs("div",{className:"space-y-2 border-t border-gray-100 pt-3",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("input",{type:"url",placeholder:"Or paste post imageUrl (https://...) for instant preview",value:ke||"",onChange:Re=>Be(Re.target.value.trim()||null),className:"w-full text-[10px] font-mono bg-gray-50 border border-gray-200 rounded-xl px-3 py-1.5 focus:bg-white focus:border-red-600 outline-none text-gray-800"})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs("label",{htmlFor:"posts-page-file-upload",className:"text-gray-600 hover:text-red-650 p-2 rounded-full hover:bg-gray-100 transition-colors flex items-center justify-center cursor-pointer gap-1.5 text-[10px] font-extrabold border border-gray-200 shadow-2xs bg-white",title:"Add Image or Video File",children:[s.jsx("input",{id:"posts-page-file-upload",type:"file",accept:"image/*,video/*",onChange:rs,className:"hidden"}),le?s.jsx(Pr,{size:16,className:"animate-spin text-red-650"}):s.jsxs(s.Fragment,{children:[s.jsx(Bh,{size:16,className:"text-red-600"}),s.jsx("span",{className:"text-[9.5px] uppercase font-black text-gray-700",children:"Upload Media"})]})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{ie(!1),te(""),Be(null)},className:"text-[9px] font-black uppercase tracking-wider text-gray-550 border border-gray-200 h-8 px-4 rounded-full hover:bg-gray-50 transition-colors cursor-pointer",children:"Collapse"}),s.jsx("button",{type:"submit",disabled:le||!he.trim()&&!ke,className:"bg-gray-950 text-white font-extrabold text-[10px] uppercase tracking-wider h-8 px-5 rounded-full hover:bg-red-650 transition-colors cursor-pointer disabled:opacity-40",children:"Dispatch Debate"})]})]})]})]})]})]})})}):s.jsx("div",{className:"bg-white border border-dashed border-gray-150 rounded-2xl p-5 text-center mb-6 shadow-3xs select-none",children:s.jsx("p",{className:"text-[10px] font-black text-gray-500 uppercase tracking-widest leading-none flex items-center justify-center gap-2",children:"📢 Sign in to publish public updates, mention peers and join student lounge dispatches!"})}),s.jsxs("div",{className:"relative mb-5",children:[s.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:s.jsx(Ip,{size:14,className:"text-gray-400"})}),s.jsx("input",{type:"text",value:f,onChange:Re=>{m(Re.target.value),w(1)},placeholder:"Search campus dispatches by text or author name...",className:"block w-full pl-9 pr-8 py-2.5 bg-white border border-gray-150 focus:border-red-650 focus:bg-white text-xs font-bold rounded-xl outline-none placeholder-gray-400 text-gray-900 transition-all shadow-xs"}),f&&s.jsx("button",{type:"button",onClick:()=>{m(""),w(1)},className:"absolute inset-y-0 right-0 pr-3 flex items-center cursor-pointer text-gray-400 hover:text-black",title:"Clear Post Search",children:s.jsx(er,{size:13})})]}),s.jsx(ar,{children:q.length>0&&s.jsx(Kt.div,{initial:{opacity:0,y:-15,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.95},className:"flex justify-center mb-5 sticky top-4 z-40",children:s.jsxs("button",{onClick:Sn,className:"flex items-center gap-2 px-5 py-2.5 bg-blue-600 hover:bg-blue-700 text-white rounded-full text-xs font-black uppercase tracking-widest transition-all duration-200 cursor-pointer shadow-lg active:scale-95 group hover:shadow-cyan-100/10",children:[s.jsx("span",{className:"relative flex h-2 w-2",children:s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-400"})}),s.jsxs("span",{children:["View ",q.length," New Post",q.length>1?"s":""]})]})})}),(()=>{const Re=r.filter(Le=>{var Pn,vr;if(!f.trim())return!0;const Ut=f.toLowerCase(),On=(Pn=Le.content)==null?void 0:Pn.toLowerCase().includes(Ut),Mn=(vr=Le.authorName)==null?void 0:vr.toLowerCase().includes(Ut);return On||Mn}),mt=Array.from(new Map(Re.map(Le=>[Le.id,Le])).values()),Je=Math.max(1,Math.ceil(mt.length/A)),Zt=(Math.min(y,Je)-1)*A,wn=mt.slice(Zt,Zt+A);return c&&r.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 space-y-2",children:[s.jsx(Pr,{className:"w-8 h-8 text-red-650 animate-spin"}),s.jsx("p",{className:"text-[10px] font-black uppercase text-gray-400 tracking-widest leading-none",children:"Connecting Lounge Updates"})]}):Re.length===0?s.jsxs("div",{className:"bg-white border border-gray-150 rounded-2xl py-14 text-center p-6 shadow-sm",children:[s.jsx(es,{className:"w-8 h-8 text-gray-300 mx-auto mb-2.5"}),s.jsx("p",{className:"text-xs font-black uppercase text-gray-950 tracking-wider",children:"No matching lounge posts found"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1 font-sans",children:"Try searching with a different user name or keyword phrase."})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-6",children:wn.map((Le,Ut)=>{var fe,rn,ai,oi,yi,gi,Gi;const On=(fe=Le.likedBy)==null?void 0:fe.includes((Ae==null?void 0:Ae.uid)||""),Mn=a[Le.authorId],Pn=(Ae==null?void 0:Ae.uid)===Le.authorId,vr=gn[Le.authorId],Me=Ut===Math.max(2,wn.length-2);return s.jsxs(Kt.div,{ref:Me?L:void 0,id:`post-card-${Le.id}`,layout:!0,className:Ge("bg-white border rounded-2xl p-4 md:p-5 shadow-sm space-y-3 flex flex-col justify-between transition-all duration-500",Le.id===n?"border-red-650 ring-2 ring-red-650/15 shadow-md scale-[1.01]":"border-gray-150"),children:[s.jsxs("div",{children:[e&&Le.isTrialPost&&!Le.isApprovedByAdmin&&s.jsxs("div",{className:"mb-3 p-3 bg-gradient-to-r from-amber-50 to-orange-50 border border-amber-200 rounded-2xl flex flex-wrap items-center justify-between gap-2 text-left",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"p-1.5 bg-amber-500 text-white rounded-xl shadow-2xs shrink-0",children:s.jsx(nj,{size:14})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-black uppercase text-amber-900 tracking-wider",children:"🎟️ Admin Approval Ticket (1st Free Trial Post)"}),s.jsxs("p",{className:"text-[9px] text-amber-700 font-medium",children:["Approve @",Le.authorName," to unlock unlimited posting on Campus Eye."]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:async()=>{try{await Hr(ot(pe,"users",Le.authorId),{isPremiumPostUser:!0},{merge:!0}),await Hn(ot(pe,"posts",Le.id),{isApprovedByAdmin:!0}),me.success(`Approved @${Le.authorName} for unlimited posting!`,{icon:"🎉"})}catch(en){me.error("Failed to approve user: "+en.message)}},className:"px-3 py-1.5 bg-amber-600 hover:bg-amber-700 text-white font-black text-[9px] uppercase tracking-wider rounded-xl shadow-xs transition-all cursor-pointer shrink-0",children:"Approve User for Unlimited Posting"}),s.jsx("button",{onClick:async()=>{try{await Hn(ot(pe,"posts",Le.id),{isApprovedByAdmin:!0}),me.success(`Dismissed request for @${Le.authorName}`,{icon:"🗑️"})}catch(en){me.error("Error dismissing request: "+en.message)}},className:"px-2.5 py-1.5 bg-gray-200 hover:bg-gray-300 text-gray-700 font-black text-[9px] uppercase tracking-wider rounded-xl transition-all cursor-pointer shrink-0",children:"Dismiss"})]})]}),s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{onClick:()=>t==null?void 0:t(Le.authorId),className:"flex items-center gap-2.5 min-w-0 cursor-pointer hover:opacity-85 transition-opacity duration-150",title:"Click to view peer credentials",children:[Le.isAIGenerated||Le.isAiGenerated||Le.authorId==="mega-ai-bot"||(rn=Le.authorName)!=null&&rn.toLowerCase().includes("mega ai")?s.jsx(LMe,{size:"sm"}):s.jsx("img",{src:Le.authorPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Le.authorName)}&background=random`,className:"w-7 h-7 rounded-full border border-gray-100 object-cover shrink-0",alt:""}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1 leading-none truncate",children:[s.jsx("span",{className:"text-[10px] font-black uppercase tracking-tight text-gray-950 truncate",children:Le.authorName}),s.jsx(Ll,{size:12,className:"shrink-0"}),(Le.isAIGenerated||Le.isAiGenerated||Le.authorId==="mega-ai-bot"||((ai=Le.authorName)==null?void 0:ai.toLowerCase().includes("mega ai")))&&s.jsx(xw,{}),s.jsxs("span",{className:"text-[8px] text-gray-400 font-bold truncate",children:["@",Le.authorName.toLowerCase().replace(/\s+/g,"")]})]}),s.jsx("span",{className:"text-[7.5px] font-black uppercase tracking-wider text-gray-400 mt-0.5 block",children:(oi=Le.createdAt)!=null&&oi.toDate?new Date(Le.createdAt.toDate().getTime()).toLocaleDateString():"Now"})]})]}),!Pn&&Ae&&s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[cn.has(Le.authorId)&&s.jsxs("button",{onClick:en=>{en.stopPropagation(),window.dispatchEvent(new CustomEvent("open-imessage-friend",{detail:{uid:Le.authorId,displayName:Le.authorName,username:Le.authorName.toLowerCase().replace(/\s+/g,""),photoURL:Le.authorPhotoURL||""}}))},className:"p-1 px-2.5 bg-[#007AFF] hover:bg-blue-600 text-white rounded-full transition-all cursor-pointer flex items-center gap-1 text-[8.5px] font-black uppercase tracking-wider shrink-0 shadow-2xs",title:`Open iMessage chat with connected friend ${Le.authorName}`,children:[s.jsx(Js,{size:11,strokeWidth:2.5}),s.jsx("span",{className:"hidden sm:inline",children:"iMessage"})]}),s.jsxs("button",{onClick:async()=>{const en={uid:Le.authorId,displayName:Le.authorName,email:""};await si(en)},disabled:vr,className:Ge("text-[7.5px] font-black uppercase tracking-wider h-5 px-1.5 rounded-full flex items-center gap-0.5 transition-all cursor-pointer shadow-none border",vr?"bg-gray-100 border-gray-200 text-gray-400 cursor-not-allowed":"bg-emerald-600 border-emerald-500 text-white hover:bg-emerald-750"),title:"Send Mutual Lounge Invitation",children:[s.jsx(yp,{size:8,strokeWidth:2.5}),s.jsx("span",{className:"hidden sm:inline",children:vr?"Invited":"Invite"})]}),s.jsx("button",{onClick:()=>Qi(Le.authorId,Le.authorName),className:`text-[7.5px] font-black uppercase tracking-widest h-5 px-1.5 rounded-full flex items-center gap-0.5 cursor-pointer transition-colors ${Mn?"bg-gray-100 text-gray-650 border border-gray-200 hover:bg-red-50 hover:text-red-650 hover:border-red-150":"bg-red-50 text-red-650 border border-red-150/50 hover:bg-red-100"}`,children:Mn?s.jsxs(s.Fragment,{children:[s.jsx(L1,{size:8}),s.jsx("span",{className:"hidden sm:inline",children:"Following"})]}):s.jsxs(s.Fragment,{children:[s.jsx(yp,{size:8}),s.jsx("span",{className:"hidden sm:inline",children:"Follow"})]})})]})]}),s.jsx("p",{className:"text-[11px] text-gray-800 font-sans leading-relaxed whitespace-pre-wrap text-left mb-2",children:(()=>{const wr=Le.content&&Le.content.length>160,na=!!je[Le.id];return!wr||na?s.jsxs(s.Fragment,{children:[Jx(Le.content,Ht),wr&&s.jsx("button",{onClick:Ms=>{Ms.stopPropagation(),xi(Le.id,Le.content)},className:"ml-1 text-[#EE1B24] font-black cursor-pointer hover:underline text-[9px] uppercase whitespace-nowrap inline-block",children:"Read less"})]}):s.jsxs(s.Fragment,{children:[Jx(Le.content.substring(0,160),Ht),"...",s.jsx("button",{onClick:Ms=>{Ms.stopPropagation(),xi(Le.id,Le.content)},className:"ml-1 text-[#EE1B24] font-black cursor-pointer hover:underline text-[9px] uppercase whitespace-nowrap inline-block",children:"Read more"})]})})()}),(()=>{const en=UMe(Le.content);if(en.length===0)return null;const wr=en[0];return s.jsx(BMe,{url:wr,onOpenUrl:Ht})})(),Le.imageUrl&&s.jsxs("div",{onClick:()=>Nt(Le.imageUrl),className:"rounded-2xl overflow-hidden border border-gray-200/80 bg-black/5 cursor-pointer relative group transition-all my-3 max-h-[650px] w-full flex items-center justify-center shadow-xs",children:[s.jsx(Vi,{src:Le.imageUrl,className:"w-full h-auto max-h-[650px] object-contain mx-auto group-hover:opacity-95 transition-opacity duration-200 rounded-2xl",alt:"Post graphic asset"}),s.jsx("div",{className:"absolute top-3 right-3 opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsxs("div",{className:"px-2.5 py-1 bg-black/75 backdrop-blur-md text-white rounded-full text-[8px] font-black uppercase tracking-wider flex items-center gap-1 shadow-md",children:[s.jsx(Dw,{size:9})," Full Size"]})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 pt-2 select-none",children:[s.jsxs("button",{onClick:()=>fa(Le.id,Le.likedBy),className:`flex items-center gap-1 text-[8.5px] font-bold uppercase tracking-wider transition-colors cursor-pointer ${On?"text-blue-600 font-extrabold":"text-gray-450 hover:text-blue-500"}`,children:[s.jsx(Kt.div,{animate:On?{scale:[1,1.45,.9,1.15,1]}:{scale:1},transition:{duration:.4},children:s.jsx(kie,{size:12,className:On?"fill-current":""})}),s.jsx("span",{children:Le.likeCount||0})]}),s.jsxs("button",{onClick:()=>_r(Le.id),className:`flex items-center gap-1 text-[8.5px] font-bold uppercase tracking-wider transition-colors cursor-pointer ${$n[Le.id]?"text-gray-950 font-black":"text-gray-450 hover:text-gray-950"}`,children:[s.jsx(Yi,{size:12}),s.jsxs("span",{children:[Le.commentCount||0," Discussions"]})]}),s.jsxs("button",{onClick:()=>ss(Le.id,Le.content,Le.imageUrl),className:"flex items-center gap-1 text-[8.5px] font-bold uppercase tracking-wider text-gray-450 hover:text-gray-950 transition-colors cursor-pointer",children:[s.jsx(df,{size:12}),s.jsx("span",{children:"Share"})]}),Ae&&(e||((yi=Ae.email)==null?void 0:yi.toLowerCase())==="atwiinevictor2@gmail.com"?s.jsxs("button",{onClick:()=>Sr(Le.id),className:`flex items-center gap-0.5 select-none cursor-pointer py-0.5 px-2 rounded-full border transition-all ${yn===Le.id?"bg-red-650 border-red-650 text-white shadow-xs":"bg-transparent border-transparent text-gray-300 hover:text-red-650"}`,title:yn===Le.id?"Click again to confirm delete":"Delete Post (Master Admin)",children:[s.jsx(er,{size:11,className:"stroke-[3]"}),s.jsx("span",{className:`text-[8px] uppercase font-black tracking-tight ${yn===Le.id?"text-white":"text-gray-400 hover:text-red-650"}`,children:yn===Le.id?"Confirm?":"Delete"})]}):Pn?null:s.jsx("button",{onClick:()=>Wr(Le.id),className:"text-gray-300 hover:text-amber-500 transition-colors flex items-center gap-1 select-none cursor-pointer",title:"Report Abuse / Inappropriate",children:s.jsx(bu,{size:12})}))]}),s.jsx(ar,{children:$n[Le.id]&&s.jsxs(Kt.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"border-t border-gray-100 pt-2.5 mt-1 overflow-hidden",children:[s.jsx("div",{className:"space-y-2 mb-3.5 max-h-40 overflow-y-auto pr-1",children:((gi=Ze[Le.id])==null?void 0:gi.length)===0?s.jsx("p",{className:"text-[8px] font-bold uppercase text-gray-350 italic text-center py-1",children:"No statements dispatched. Formulate your thought."}):(Gi=Ze[Le.id])==null?void 0:Gi.map(en=>{var wr,na;return s.jsxs("div",{className:"flex gap-1.5 items-start py-0.5",children:[s.jsx("img",{src:en.authorId==="mega-ai-bot"||(wr=en.authorName)!=null&&wr.toLowerCase().includes("mega ai")?Vo:en.authorPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(en.authorName)}&background=random`,className:"w-5 h-5 rounded-full border border-gray-100 object-cover mt-0.5 animate-fade-in",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0 bg-gray-50/70 rounded-xl p-2 border border-gray-100",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-[8px] font-black uppercase text-gray-950 tracking-tight",children:en.authorName}),s.jsx(Ll,{size:10,className:"shrink-0"})]}),s.jsx("span",{className:"text-[7px] font-bold text-gray-400",children:(na=en.createdAt)!=null&&na.toDate?new Date(en.createdAt.toDate().getTime()).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"Now"})]}),s.jsx("p",{className:"text-[10px] text-gray-700 font-sans leading-relaxed mt-0.5",children:en.content})]})]},en.id)})}),Ae?s.jsxs("div",{className:"flex gap-1.5 items-center",children:[s.jsx("input",{type:"text",value:It[Le.id]||"",onChange:en=>{const wr=en.target.value;ln(na=>({...na,[Le.id]:wr}))},placeholder:"What's on your mind? Share it.",className:"flex-1 bg-gray-50 p-1.5 rounded-lg text-[10px] font-sans outline-none focus:outline-none focus:ring-1 focus:ring-red-500/25 border border-gray-150 placeholder-gray-400"}),s.jsx("button",{onClick:()=>hi(Le.id),disabled:hr[Le.id]||!(It[Le.id]||"").trim(),className:"bg-gray-950 text-white rounded-full w-6 h-6 flex items-center justify-center hover:bg-red-650 transition-colors disabled:opacity-30 cursor-pointer text-[10px] shrink-0",children:s.jsx(fl,{size:10})})]}):s.jsx("div",{className:"bg-gray-50 rounded-xl p-2 border border-gray-100 text-center",children:s.jsx("p",{className:"text-[8px] font-black uppercase tracking-widest text-gray-400",children:"Sign in with Google to reply"})})]})})]})]},`${Le.id}-${Ut}`)})}),Re.length>0&&s.jsx("div",{className:"mt-6",children:s.jsx(jee,{currentPage:y,totalPages:Je,totalItems:Re.length,itemsPerPage:A,onPageChange:Le=>{w(Le),Le*A>I-10&&T(Ut=>Math.max(Ut,Le*A+50)),window.scrollTo({top:0,behavior:"smooth"})},onItemsPerPageChange:Le=>{k(Le),w(1),Le>I&&T(Le+50)},itemLabel:"posts"})})]})})(),s.jsx(ar,{children:Ir&&s.jsxs("div",{className:"fixed inset-0 z-[3500] flex items-center justify-center p-4",children:[s.jsx(Kt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>pr(!1),className:"absolute inset-0 bg-black/60 backdrop-blur-md"}),s.jsxs(Kt.div,{initial:{opacity:0,scale:.95,y:15},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:15},transition:{type:"spring",damping:25,stiffness:300},className:"relative w-full max-w-md bg-white border border-gray-150 rounded-2xl shadow-2xl p-6 overflow-hidden max-h-[85vh] flex flex-col text-left",children:[s.jsxs("div",{className:"flex items-center justify-between pb-3.5 border-b border-gray-100 mb-5 relative",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"p-1.5 bg-red-50 rounded-lg text-red-650 shrink-0",children:s.jsx(Ao,{size:16,strokeWidth:2.5})}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-sans font-black text-xs uppercase tracking-wider text-gray-950",children:"Invite Lounge Peers"}),s.jsx("p",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-tight font-mono",children:"Expand your campus digital board"})]})]}),s.jsx("button",{onClick:()=>pr(!1),className:"p-1 rounded-full hover:bg-gray-100 text-gray-405 hover:text-gray-950 transition-colors cursor-pointer",title:"Close panel",children:s.jsx(er,{size:16})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5 pr-1 py-1",children:[s.jsxs("div",{className:"bg-gray-50/70 rounded-xl p-4 border border-gray-100 flex flex-col gap-3",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(es,{size:13,className:"text-red-650 shrink-0"}),s.jsx("span",{className:"text-[10px] font-black uppercase text-gray-900 tracking-wider",children:"Share Lounge Join Link"})]}),s.jsx("p",{className:"text-[10px] font-semibold text-gray-550 leading-relaxed",children:"Copy the Student Lounge direct referral channel URL to hand to custom circles via WhatsApp, Slack or external dispatches."}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",readOnly:!0,value:(()=>{var mt;const Re=Ae?(Ae.displayName||((mt=Ae.email)==null?void 0:mt.split("@")[0])||"peer").trim().toLowerCase().replace(/[^a-z0-9]/g,"-"):"peer";return`${window.location.origin}?invite=${Re}-invites-you`})(),className:"flex-1 bg-white border border-gray-200 rounded-lg px-3 py-1.5 text-[10px] font-mono text-gray-500 outline-none select-all select-none"}),s.jsx("button",{onClick:()=>{var Je;const Re=Ae?(Ae.displayName||((Je=Ae.email)==null?void 0:Je.split("@")[0])||"peer").trim().toLowerCase().replace(/[^a-z0-9]/g,"-"):"peer",mt=`${window.location.origin}?invite=${Re}-invites-you`;Pd(mt),me.success("Your unique Lounge invitation link copied!",{icon:"🔗"})},className:"px-3 py-1.5 bg-gray-950 hover:bg-red-650 text-white rounded-lg text-[9px] font-black uppercase tracking-wider transition-colors cursor-pointer active:scale-95 shrink-0",children:"Copy Link"})]})]}),s.jsxs("form",{onSubmit:async Re=>{if(Re.preventDefault(),!ue.trim()){me.error("Please enter a valid student or faculty email");return}Vt(!0);try{await ur(it(pe,"invitations"),{senderId:(Ae==null?void 0:Ae.uid)||"guest",senderName:(Ae==null?void 0:Ae.displayName)||"Peer",senderPhotoURL:(Ae==null?void 0:Ae.photoURL)||"",receiverEmail:ue.trim().toLowerCase(),status:"pending",type:"email",createdAt:Bn()}),me.success(`Broadcasting dispatch invite to ${ue.trim().toLowerCase()}!`,{icon:"✉️"}),Se("")}catch(mt){me.error("Failed to dispatcher invitation: "+mt.message)}finally{Vt(!1)}},className:"space-y-2.5 pb-2 border-b border-gray-100",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Js,{size:13,className:"text-red-650 shrink-0"}),s.jsx("span",{className:"text-[10px] font-black uppercase text-gray-900 tracking-wider",children:"Email Dispatch Invitation"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"email",required:!0,placeholder:"Enter peer's email address",value:ue,onChange:Re=>Se(Re.target.value),className:"flex-1 bg-gray-50/50 border border-gray-200 rounded-lg px-3 py-1.5 text-xs font-sans outline-none focus:bg-white focus:ring-1 focus:ring-red-550/20 transition-all placeholder-gray-400"}),s.jsxs("button",{type:"submit",disabled:Xe,className:"px-4 py-1.5 bg-red-650 hover:bg-red-700 disabled:bg-gray-300 text-white rounded-lg text-[9px] font-black uppercase tracking-wider transition-colors cursor-pointer active:scale-95 shrink-0 flex items-center gap-1",children:[Xe?s.jsx(Pr,{size:10,className:"className animate-spin"}):s.jsx(fl,{size:10}),s.jsx("span",{children:"Dispatch"})]})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase text-gray-900 tracking-wider",children:["Lounge Fellow Citizens (",xe.length,")"]}),s.jsx("span",{className:"text-[8px] font-mono font-black uppercase tracking-widest text-emerald-650 bg-emerald-50 px-1.5 py-0.5 rounded-md",children:"Live Stream"})]}),Fe?s.jsx("div",{className:"flex justify-center items-center py-6",children:s.jsx(Pr,{size:18,className:"animate-spin text-red-650"})}):xe.length===0?s.jsx("p",{className:"text-[9.5px] font-bold uppercase text-gray-400 font-sans py-4 text-center leading-relaxed",children:"No other registered peers discovered yet. Disperse invitations to propagate!"}):s.jsx("div",{className:"space-y-2 max-h-52 overflow-y-auto pr-1",children:xe.map(Re=>{const mt=gn[Re.uid];return s.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-gray-150 hover:border-gray-200 hover:bg-gray-100/10 transition-colors gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("img",{src:Re.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Re.displayName||"P")}&background=random`,className:"w-7 h-7 rounded-full border border-gray-100 object-cover shrink-0",alt:""}),s.jsxs("div",{className:"min-w-0 leading-tight",children:[s.jsx("span",{className:"text-[10px] font-black uppercase tracking-tight text-gray-950 block truncate",children:Re.displayName||"Peer"}),s.jsxs("span",{className:"text-[8px] font-semibold text-gray-400 block truncate",children:["@",(Re.displayName||"peer").toLowerCase().replace(/\s+/g,"")]})]})]}),s.jsx("button",{onClick:()=>si(Re),disabled:mt,className:Ge("text-[8px] font-sans font-black uppercase tracking-widest px-2.5 py-1.5 rounded-lg border cursor-pointer transition-all active:scale-95 flex items-center gap-1 shrink-0",mt?"bg-gray-100 text-gray-400 border-gray-200 cursor-not-allowed":"bg-emerald-600 text-white border-emerald-500 hover:bg-emerald-700"),children:mt?s.jsxs(s.Fragment,{children:[s.jsx(Pu,{size:9,strokeWidth:3}),s.jsx("span",{children:"Invited"})]}):s.jsxs(s.Fragment,{children:[s.jsx(yp,{size:9,strokeWidth:3}),s.jsx("span",{children:"Invite"})]})})]},Re.uid)})})]})]}),s.jsx("div",{className:"border-t border-gray-100 pt-3.5 mt-5 text-center text-gray-400",children:s.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest font-mono",children:"Campus Eye Network Connection Protocol"})})]})]})}),s.jsx(ar,{children:Tn&&s.jsxs("div",{className:"fixed inset-0 bg-slate-950/95 backdrop-blur-md flex flex-col items-center justify-center p-4 z-[9999] select-none",children:[s.jsxs("div",{className:"absolute top-4 right-4 flex items-center gap-3",children:[s.jsxs("button",{onClick:async()=>{try{const mt=await(await fetch(Tn)).blob(),Je=URL.createObjectURL(mt),vt=document.createElement("a");vt.href=Je,vt.download="posts_image.jpg",document.body.appendChild(vt),vt.click(),document.body.removeChild(vt),URL.revokeObjectURL(Je),me.success("Download started!")}catch{window.open(Tn,"_blank"),me.success("Opened photo page! Tap and hold to download.")}},className:"px-4 py-2 bg-white/10 hover:bg-white text-white hover:text-black rounded-xl text-[10px] font-black uppercase tracking-widest flex items-center gap-1.5 transition-all cursor-pointer",title:"Download image asset",children:[s.jsx(IN,{size:12,strokeWidth:2.5}),s.jsx("span",{children:"Download"})]}),s.jsx("button",{onClick:()=>Nt(null),className:"w-10 h-10 rounded-full bg-white/10 hover:bg-red-650 text-white flex items-center justify-center transition-all cursor-pointer",title:"Dismiss image viewer",children:s.jsx(er,{size:20,strokeWidth:2.5})})]}),s.jsx(Kt.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"max-w-4xl max-h-[85vh] w-full flex items-center justify-center overflow-hidden",children:s.jsx("img",{src:Tn,className:"max-w-full max-h-[80vh] object-contain rounded-2xl shadow-2xl border border-white/15 select-all",alt:"Enlarged campus attachment",referrerPolicy:"no-referrer"})}),s.jsx("p",{className:"text-[10px] text-gray-400 uppercase tracking-widest mt-4 font-bold",children:"Tip: Long-touch or right-click picture to download directly"})]})}),s.jsx(ar,{children:B&&s.jsx("div",{className:"fixed inset-0 bg-zinc-950/80 backdrop-blur-sm flex items-center justify-center p-4 z-[9900] select-none text-left animate-fade-in",children:s.jsxs(Kt.div,{initial:{scale:.95,opacity:0,y:15},animate:{scale:1,opacity:1,y:0},exit:{scale:.95,opacity:0,y:15},transition:{type:"spring",duration:.5},className:"bg-white rounded-[2.5rem] p-6 md:p-8 w-full max-w-2xl shadow-2xl relative overflow-hidden border border-gray-100 flex flex-col max-h-[90vh]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4 shrink-0 pb-3 border-b border-gray-100 relative z-20",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"p-2 bg-red-100 text-red-650 rounded-xl",children:s.jsx(es,{size:16})}),s.jsxs("div",{children:[s.jsx("span",{className:"text-red-650 font-black text-[9px] uppercase tracking-widest block font-mono",children:"Spotlight Dispatch"}),s.jsx("h3",{className:"text-md font-serif font-black text-gray-950 uppercase tracking-tight",children:"Direct Shared Lounge Post"})]})]}),s.jsx("button",{onClick:()=>{V(null);const Re=new URL(window.location.href);Re.searchParams.delete("postId"),Re.searchParams.delete("post"),window.history.replaceState({},"",Re.toString())},className:"p-2.5 bg-gray-50 hover:bg-red-50 text-gray-900 hover:text-red-650 rounded-full transition-all cursor-pointer border border-transparent hover:border-red-100 flex items-center justify-center",title:"Close spotlight focus and browse full feed",children:s.jsx(er,{size:16,strokeWidth:2.5})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto space-y-4 pr-1 select-text relative z-10",children:Y?s.jsxs("div",{className:"py-16 flex flex-col items-center justify-center space-y-2",children:[s.jsx(Pr,{className:"w-8 h-8 text-red-650 animate-spin"}),s.jsx("span",{className:"text-[10px] font-black uppercase text-gray-400 tracking-widest",children:"Retrieving shared post details..."})]}):$?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{onClick:()=>{t==null||t($.authorId),V(null)},className:"flex items-center gap-2.5 cursor-pointer hover:opacity-85 transition-opacity duration-150",title:"Click to view peer credentials",children:[s.jsx("img",{src:$.authorId==="mega-ai-bot"||(Et=$.authorName)!=null&&Et.toLowerCase().includes("mega ai")?Vo:$.authorPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent($.authorName)}&background=random`,className:"w-8 h-8 rounded-full border border-gray-100 object-cover shrink-0",alt:""}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1 leading-none",children:[s.jsx("span",{className:"text-[11px] font-black uppercase tracking-tight text-gray-950",children:$.authorName}),s.jsxs("span",{className:"text-[8.5px] text-gray-400 font-bold",children:["@",$.authorName.toLowerCase().replace(/\s+/g,"")]})]}),s.jsx("span",{className:"text-[8px] font-black uppercase tracking-wider text-gray-400 mt-0.5 block",children:(Oa=$.createdAt)!=null&&Oa.toDate?new Date($.createdAt.toDate().getTime()).toLocaleDateString():"Recently"})]})]}),Ae&&Ae.uid!==$.authorId&&s.jsxs("div",{className:"flex items-center gap-1",children:[cn.has($.authorId)&&s.jsxs("button",{onClick:Re=>{Re.stopPropagation(),window.dispatchEvent(new CustomEvent("open-imessage-friend",{detail:{uid:$.authorId,displayName:$.authorName,username:$.authorName.toLowerCase().replace(/\s+/g,""),photoURL:$.authorPhotoURL||""}}))},className:"p-1 px-2.5 bg-[#007AFF] hover:bg-blue-600 text-white rounded-full transition-all cursor-pointer flex items-center gap-1 text-[8.5px] font-black uppercase tracking-wider shrink-0 shadow-2xs",title:`Open iMessage chat with connected friend ${$.authorName}`,children:[s.jsx(Js,{size:11,strokeWidth:2.5}),s.jsx("span",{children:"iMessage"})]}),s.jsx("button",{onClick:()=>Qi($.authorId,$.authorName),className:`text-[8px] font-black uppercase tracking-widest h-6 px-2 rounded-full flex items-center gap-0.5 cursor-pointer transition-colors ${a[$.authorId]?"bg-gray-100 text-gray-650 border border-gray-200 hover:bg-red-50 hover:text-red-500":"bg-red-50 text-red-650 border border-red-150/50 hover:bg-red-100"}`,children:a[$.authorId]?s.jsxs(s.Fragment,{children:[s.jsx(L1,{size:9}),s.jsx("span",{children:"Following"})]}):s.jsxs(s.Fragment,{children:[s.jsx(yp,{size:9}),s.jsx("span",{children:"Follow"})]})})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-gray-800 leading-relaxed whitespace-pre-wrap select-text",children:Jx($.content)}),$.imageUrl&&s.jsxs("div",{onClick:()=>Nt($.imageUrl),className:"relative aspect-video max-h-72 w-full rounded-2xl border border-gray-100 overflow-hidden cursor-pointer group bg-gray-50",children:[s.jsx(Vi,{src:$.imageUrl,className:"w-full h-full object-contain mx-auto group-hover:opacity-95 duration-200",alt:""}),s.jsx("div",{className:"absolute inset-0 bg-black/10 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:s.jsx(Dw,{className:"text-white drop-shadow-sm w-5 h-5"})})]})]}),s.jsxs("div",{className:"flex items-center justify-between border-y border-gray-100 py-3 mt-4 text-[10px] font-black uppercase tracking-wider font-mono shrink-0",children:[s.jsx("div",{className:"flex gap-4",children:s.jsxs("button",{onClick:()=>fa($.id,$.likedBy),className:`flex items-center gap-1.5 cursor-pointer ${(Tr=$.likedBy)!=null&&Tr.includes((Ae==null?void 0:Ae.uid)||"")?"text-red-650 font-black":"text-gray-450 hover:text-gray-950"}`,children:[s.jsx(ku,{size:14,className:(Hi=$.likedBy)!=null&&Hi.includes((Ae==null?void 0:Ae.uid)||"")?"fill-current":""}),s.jsxs("span",{children:[$.likeCount||0," Likes"]})]})}),s.jsxs("button",{onClick:()=>ss($.id,$.content,$.imageUrl),className:"flex items-center gap-1.5 text-gray-450 hover:text-gray-950 transition-colors cursor-pointer",children:[s.jsx(df,{size:13}),s.jsx("span",{children:"Share with Image"})]})]}),s.jsxs("div",{className:"space-y-4 pt-2",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] font-black uppercase tracking-widest text-gray-400 font-mono",children:[s.jsx(Yi,{size:13}),s.jsxs("span",{children:["Discussions (",((jo=Ze[$.id])==null?void 0:jo.length)||$.commentCount||0,")"]})]})}),s.jsx("div",{className:"space-y-3 max-h-[25vh] overflow-y-auto pr-1",children:!Ze[$.id]||Ze[$.id].length===0?s.jsx("div",{className:"py-4 text-center bg-gray-50/50 rounded-xl border border-dashed border-gray-100",children:s.jsx("span",{className:"text-[10px] font-black uppercase tracking-wider text-gray-400 font-mono",children:"No feedback published yet"})}):Ze[$.id].map(Re=>{var mt,Je;return s.jsxs("div",{className:"p-3 bg-gray-50/60 rounded-2xl border border-gray-100 flex items-start gap-2.5 transition-all",children:[s.jsx("img",{src:Re.authorId==="mega-ai-bot"||(mt=Re.authorName)!=null&&mt.toLowerCase().includes("mega ai")?Vo:Re.authorPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Re.authorName)}&background=random`,className:"w-6 h-6 rounded-full border border-gray-100 object-cover shrink-0 mt-0.5",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[9.5px] font-black uppercase tracking-tight text-gray-950",children:Re.authorName}),s.jsx("span",{className:"text-[7.5px] font-bold text-gray-400 font-mono",children:(Je=Re.createdAt)!=null&&Je.toDate?new Date(Re.createdAt.toDate().getTime()).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"Recently"})]}),s.jsx("p",{className:"text-[10.5px] text-gray-800 leading-relaxed font-sans mt-0.5 select-text",children:Re.content})]})]},Re.id)})}),Ae?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",placeholder:"Add your perspective...",value:It[$.id]||"",onChange:Re=>ln(mt=>({...mt,[$.id]:Re.target.value})),onKeyDown:Re=>{Re.key==="Enter"&&hi($.id)},className:"flex-1 px-4 py-2.5 bg-gray-50 border border-gray-250 focus:border-red-650 rounded-xl text-xs font-bold outline-none transition-all placeholder:text-gray-400"}),s.jsx("button",{onClick:()=>hi($.id),disabled:hr[$.id],className:"p-2.5 bg-zinc-950 hover:bg-red-650 disabled:bg-gray-200 text-white rounded-xl transition-all flex items-center justify-center cursor-pointer active:scale-95 duration-100",children:hr[$.id]?s.jsx(Pr,{className:"w-4 h-4 animate-spin text-white"}):s.jsx(fl,{size:14})})]}):s.jsx("div",{className:"p-3 bg-red-50/40 border border-red-100/40 rounded-xl text-center",children:s.jsx("span",{className:"text-[9px] font-black uppercase text-red-650 tracking-wider font-mono",children:"Authenticate to contribute opinions"})})]})]}):s.jsxs("div",{className:"py-16 text-center",children:[s.jsx(bu,{className:"w-10 h-10 text-amber-500 mx-auto mb-2"}),s.jsx("p",{className:"text-xs font-black uppercase text-gray-950 tracking-wider",children:"Lounge post not found or removed"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"This shared dispatch may have been deleted or flagged by administrators."})]})}),s.jsx("div",{className:"pt-4 border-t border-gray-100 shrink-0 mt-3 relative z-25",children:s.jsxs("button",{type:"button",onClick:()=>{V(null);const Re=new URL(window.location.href);Re.searchParams.delete("postId"),Re.searchParams.delete("post"),window.history.replaceState({},"",Re.toString())},className:"w-full py-3 bg-zinc-950 hover:bg-red-650 text-white rounded-2xl text-[10px] font-black uppercase tracking-widest transition-colors duration-200 cursor-pointer shadow-sm hover:shadow-md flex items-center justify-center gap-1.5",children:[s.jsx(Ao,{size:12,strokeWidth:2.5}),s.jsx("span",{children:"Dismiss Focus & Browse Lounge Feed"})]})})]})})}),s.jsx(ar,{children:tt&&s.jsxs("div",{className:"fixed inset-0 z-[9950] flex items-end md:items-center justify-center p-0 md:p-4 animate-fade-in",children:[s.jsx("div",{className:"fixed inset-0 bg-zinc-950/75 backdrop-blur-md transition-opacity duration-300",onClick:()=>{fn(null),jn(Re=>({...Re,[tt]:null}))}}),s.jsxs(Kt.div,{initial:{y:"100%",opacity:0},animate:{y:0,opacity:1},exit:{y:"100%",opacity:0},transition:{type:"spring",damping:25,stiffness:280},className:"relative z-10 bg-white rounded-t-[2.5rem] md:rounded-[2.5rem] w-full max-w-xl max-h-[85vh] flex flex-col shadow-2xl border border-gray-150 overflow-hidden",children:[s.jsxs("div",{className:"p-4 md:p-5 border-b border-gray-100 flex items-center justify-between bg-gray-50/50",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"p-2 bg-red-100 text-red-650 rounded-xl",children:s.jsx(Yi,{size:16})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-950 font-mono",children:"Lounge Discussion Thread"}),s.jsxs("p",{className:"text-[9px] text-gray-400 font-sans",children:[((or=Ze[tt])==null?void 0:or.length)||0," peer responses • Threaded conversations"]})]})]}),s.jsx("button",{onClick:()=>{fn(null),jn(Re=>({...Re,[tt]:null}))},className:"w-8 h-8 rounded-full bg-gray-100 hover:bg-red-50 text-gray-600 hover:text-red-650 flex items-center justify-center transition-colors cursor-pointer",children:s.jsx(er,{size:16})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4 md:p-5 space-y-4",children:!Ze[tt]||Ze[tt].length===0?s.jsxs("div",{className:"py-12 text-center bg-gray-50/50 rounded-2xl border border-dashed border-gray-200",children:[s.jsx(Yi,{className:"w-8 h-8 text-gray-300 mx-auto mb-2 animate-bounce"}),s.jsx("p",{className:"text-xs font-black uppercase text-gray-500 tracking-wider font-mono",children:"No responses yet"}),s.jsx("p",{className:"text-[10px] text-gray-400 mt-1",children:"Be the first to share your thoughts and start a discussion thread!"})]}):(()=>{const Re=Ze[tt]||[];return Re.filter(Je=>!Je.parentId).map(Je=>{var Zt,wn,Le;const vt=Re.filter(Ut=>Ut.parentId===Je.id);return s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{id:`comment-${Je.id}`,className:"p-3 bg-gray-50/80 rounded-2xl border border-gray-150 relative group transition-all",children:s.jsxs("div",{className:"flex items-start gap-2.5",children:[s.jsx("img",{src:Je.authorId==="mega-ai-bot"||Je.userId==="mega-ai-bot"||(Zt=Je.authorName)!=null&&Zt.toLowerCase().includes("mega ai")?Vo:Je.authorPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Je.authorName)}&background=random`,className:"w-7 h-7 rounded-full border border-gray-100 object-cover mt-0.5 shrink-0",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-[10px] font-black uppercase tracking-tight text-gray-950",children:Je.authorName}),s.jsx(Ll,{size:11,className:"shrink-0"}),(Je.isAIGenerated||Je.isAiGenerated||Je.authorId==="mega-ai-bot"||Je.userId==="mega-ai-bot"||((wn=Je.authorName)==null?void 0:wn.toLowerCase().includes("mega ai")))&&s.jsx(xw,{})]}),s.jsx("span",{className:"text-[8px] font-bold text-gray-400 font-mono",children:(Le=Je.createdAt)!=null&&Le.toDate?new Date(Je.createdAt.toDate().getTime()).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"Just now"})]}),s.jsx("p",{className:"text-[11px] text-gray-800 leading-relaxed font-sans mt-1",children:Jx(Je.content,Ht)}),Je.stickerEmoji&&s.jsx("div",{className:"my-1.5 p-1 bg-amber-50 rounded-xl inline-block border border-amber-200",children:s.jsx("span",{className:"text-2xl",children:Je.stickerEmoji})}),Je.imageUrl&&s.jsx("div",{className:"my-1.5 rounded-xl overflow-hidden border border-gray-200 max-h-40 bg-gray-50",children:s.jsx("img",{src:Je.imageUrl,className:"w-full h-full object-cover",alt:"Attachment"})}),Je.audioUrl&&s.jsx("div",{className:"my-1.5 p-1 bg-gray-100 rounded-xl",children:s.jsx("audio",{controls:!0,src:Je.audioUrl,className:"w-full h-8"})}),s.jsxs("div",{className:"flex items-center gap-4 mt-2 pt-1 border-t border-gray-100/60",children:[s.jsxs("button",{onClick:()=>is(tt,Je.id),className:`flex items-center gap-1 text-[9px] font-black uppercase tracking-wider font-mono cursor-pointer transition-colors ${jt[Je.id]||Je.likedBy&&Ae&&Je.likedBy.includes(Ae.uid)?"text-red-650":"text-gray-400 hover:text-red-650"}`,children:[s.jsx(ku,{size:12,fill:jt[Je.id]||Je.likedBy&&Ae&&Je.likedBy.includes(Ae.uid)?"currentColor":"none"}),s.jsx("span",{children:Je.likeCount||0})]}),s.jsxs("button",{onClick:()=>jn(Ut=>({...Ut,[tt]:{commentId:Je.id,authorName:Je.authorName}})),className:"flex items-center gap-1 text-[9px] font-black uppercase tracking-wider font-mono text-gray-400 hover:text-red-650 cursor-pointer transition-colors",children:[s.jsx(fl,{size:10,className:"rotate-45"}),s.jsx("span",{children:"Reply"})]})]})]})]})}),vt.length>0&&s.jsx("div",{className:"border-l-2 border-red-500/30 pl-3 ml-4 space-y-2 pt-1",children:vt.map(Ut=>{var On,Mn,Pn;return s.jsxs("div",{id:`comment-${Ut.id}`,className:"p-2.5 bg-red-50/30 rounded-xl border border-red-100/50 flex items-start gap-2 transition-all",children:[s.jsx("img",{src:Ut.authorId==="mega-ai-bot"||Ut.userId==="mega-ai-bot"||(On=Ut.authorName)!=null&&On.toLowerCase().includes("mega ai")?Vo:Ut.authorPhotoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Ut.authorName)}&background=random`,className:"w-5 h-5 rounded-full border border-gray-100 object-cover mt-0.5 shrink-0",alt:""}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[s.jsx("span",{className:"text-[9px] font-black uppercase tracking-tight text-gray-950",children:Ut.authorName}),s.jsx(Ll,{size:10,className:"shrink-0"}),(Ut.isAIGenerated||Ut.isAiGenerated||Ut.authorId==="mega-ai-bot"||Ut.userId==="mega-ai-bot"||((Mn=Ut.authorName)==null?void 0:Mn.toLowerCase().includes("mega ai")))&&s.jsx(xw,{}),Ut.replyToAuthor&&s.jsxs("span",{className:"text-[8px] font-mono text-red-650 font-bold",children:["replying to @",Ut.replyToAuthor]})]}),s.jsx("span",{className:"text-[7.5px] font-bold text-gray-400 font-mono",children:(Pn=Ut.createdAt)!=null&&Pn.toDate?new Date(Ut.createdAt.toDate().getTime()).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"Just now"})]}),s.jsx("div",{className:"text-[10px] text-gray-800 font-sans leading-relaxed mt-0.5",children:Jx(Ut.content,Ht)}),s.jsxs("div",{className:"flex items-center gap-3 mt-1.5 pt-1 border-t border-red-100/30",children:[s.jsxs("button",{onClick:()=>is(tt,Ut.id),className:`flex items-center gap-1 text-[8.5px] font-black uppercase tracking-wider font-mono cursor-pointer transition-colors ${jt[Ut.id]||Ut.likedBy&&Ae&&Ut.likedBy.includes(Ae.uid)?"text-red-650":"text-gray-400 hover:text-red-650"}`,children:[s.jsx(ku,{size:11,fill:jt[Ut.id]||Ut.likedBy&&Ae&&Ut.likedBy.includes(Ae.uid)?"currentColor":"none"}),s.jsx("span",{children:Ut.likeCount||0})]}),s.jsx("button",{onClick:()=>jn(vr=>({...vr,[tt]:{commentId:Je.id,authorName:Ut.authorName}})),className:"text-[8.5px] font-black uppercase tracking-wider font-mono text-gray-400 hover:text-red-650 cursor-pointer transition-colors",children:"Reply"})]})]})]},Ut.id)})})]},Je.id)})})()}),s.jsxs("div",{className:"p-3 md:p-4 border-t border-gray-150 bg-gray-50/80",children:[Bt[tt]&&s.jsxs("div",{className:"flex items-center justify-between bg-red-100/80 px-3 py-1 rounded-lg mb-2 text-[9px] font-mono text-red-700",children:[s.jsxs("span",{className:"font-bold",children:["Replying to @",(kr=Bt[tt])==null?void 0:kr.authorName]}),s.jsx("button",{onClick:()=>jn(Re=>({...Re,[tt]:null})),className:"hover:text-red-900 font-black cursor-pointer",children:"✕"})]}),Ae?s.jsxs("div",{className:"space-y-2",children:[mn[tt]&&s.jsxs("div",{className:"flex items-center gap-1.5 p-2 bg-amber-50/80 border border-amber-200 rounded-xl overflow-x-auto",children:[s.jsx("span",{className:"text-[9px] font-black uppercase text-amber-800 font-mono shrink-0 mr-1",children:"Stickers:"}),["🔥","🎓","👏","💯","📌","❤️","🚀","💡","💎","🎉","🌟","🏆","📢"].map(Re=>s.jsx("button",{type:"button",onClick:()=>{un(mt=>({...mt,[tt]:Re})),dr(mt=>({...mt,[tt]:!1})),me.success(`Sticker ${Re} selected!`,{id:"stk-selected"})},className:"text-lg hover:scale-125 transition-transform p-1 cursor-pointer shrink-0",children:Re},Re))]}),Kn[tt]&&s.jsxs("div",{className:"flex items-center gap-2 bg-amber-100 px-2.5 py-1 rounded-lg text-xs font-bold text-amber-900 w-fit",children:[s.jsxs("span",{children:["Active Sticker: ",Kn[tt]]}),s.jsx("button",{type:"button",onClick:()=>un(Re=>({...Re,[tt]:""})),className:"hover:text-red-700 font-black cursor-pointer text-xs",children:"✕"})]}),s.jsx(eY,{value:It[tt]||"",onSelectMention:Re=>ln(mt=>({...mt,[tt]:Re}))}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("button",{type:"button",onClick:()=>dr(Re=>({...Re,[tt]:!Re[tt]})),className:"p-2 bg-amber-100 text-amber-800 hover:bg-amber-200 rounded-xl transition-colors cursor-pointer shrink-0",title:"Attach Sticker",children:s.jsx(uF,{size:16})}),s.jsx("input",{type:"text",value:It[tt]||"",onChange:Re=>ln(mt=>({...mt,[tt]:Re.target.value})),onKeyDown:Re=>{Re.key==="Enter"&&hi(tt)},placeholder:Bt[tt]?`Write reply to @${(lr=Bt[tt])==null?void 0:lr.authorName}...`:"Write a statement, reply, or attach sticker...",className:"flex-1 px-3.5 py-2.5 bg-white border border-gray-250 focus:border-red-650 rounded-xl text-xs font-medium outline-none transition-all placeholder:text-gray-400 shadow-inner"}),s.jsx("button",{onClick:()=>hi(tt),disabled:hr[tt]||!(It[tt]||"").trim()&&!Kn[tt],className:"p-2.5 bg-zinc-950 hover:bg-red-650 disabled:bg-gray-200 text-white rounded-xl transition-all flex items-center justify-center cursor-pointer active:scale-95 shrink-0",children:hr[tt]?s.jsx(Pr,{className:"w-4 h-4 animate-spin text-white"}):s.jsx(fl,{size:14})})]})]}):s.jsx("div",{className:"p-2.5 bg-gray-100 rounded-xl text-center",children:s.jsx("span",{className:"text-[9px] font-black uppercase tracking-wider text-gray-500 font-mono",children:"Sign in with Google to post replies"})})]})]})]})}),s.jsx(MMe,{isOpen:Ft,url:pn,onClose:()=>{Dt(!1),Fn(null)}})]})},VMe={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"},{urls:"stun:stun2.l.google.com:19302"}]},Tee=({isOpen:e,onClose:t,peer:n,callType:r,isIncoming:i=!1,existingCallId:a})=>{const o=Ne.currentUser,[c,h]=j.useState("calling"),[f,m]=j.useState(!1),[y,w]=j.useState(r==="audio"),[A,k]=j.useState(0),[I,T]=j.useState(a||null),D=j.useRef(null),F=j.useRef(null),L=j.useRef(null),q=j.useRef(null),Z=j.useRef(null),K=j.useRef(null);j.useRef(null),j.useEffect(()=>!e||!o?void 0:((async()=>{try{const G={audio:!0,video:r==="video"?{width:{ideal:1280},height:{ideal:720},facingMode:"user"}:!1},he=await navigator.mediaDevices.getUserMedia(G);q.current=he,D.current&&r==="video"&&(D.current.srcObject=he);const te=new RTCPeerConnection(VMe);if(Z.current=te,he.getTracks().forEach(le=>{te.addTrack(le,he)}),te.ontrack=le=>{le.streams&&le.streams[0]&&(F.current&&r==="video"?F.current.srcObject=le.streams[0]:L.current&&(L.current.srcObject=le.streams[0]))},i&&a){h("connected");const le=ot(pe,"calls",a),ve=await cs(le);if(ve.exists()){const Be=ve.data();if(Be.offer){await te.setRemoteDescription(new RTCSessionDescription(Be.offer));const J=await te.createAnswer();await te.setLocalDescription(J),await Hn(le,{answer:{type:J.type,sdp:J.sdp},status:"connected"})}}const ke=it(pe,"calls",a,"callerCandidates");di(ke,Be=>{Be.docChanges().forEach(async J=>{if(J.type==="added"){const ie=new RTCIceCandidate(J.doc.data());await te.addIceCandidate(ie)}})}),te.onicecandidate=Be=>{if(Be.candidate){const J=it(pe,"calls",a,"calleeCandidates");ur(J,Be.candidate.toJSON())}}}else{const le=ot(it(pe,"calls"));T(le.id);const ve=it(pe,"calls",le.id,"callerCandidates");te.onicecandidate=J=>{J.candidate&&ur(ve,J.candidate.toJSON())};const ke=await te.createOffer();await te.setLocalDescription(ke),await Hr(le,{callerId:o.uid,callerName:o.displayName||"Campus Peer",callerPhoto:o.photoURL||"",receiverId:n.uid,receiverName:n.displayName,receiverPhoto:n.photoURL||"",type:r,status:"ringing",offer:{type:ke.type,sdp:ke.sdp},createdAt:new Date}),await ur(it(pe,"notifications"),{userId:n.uid,senderId:o.uid,senderName:o.displayName||"Campus Peer",senderUsername:(o.displayName||"peer").toLowerCase().replace(/\s+/g,""),senderPhotoURL:o.photoURL||"",title:`📞 Incoming ${r==="video"?"FaceTime Video":"Audio"} Call from ${o.displayName}`,message:`Tap to accept ${r} call now!`,type:"incoming_call",callId:le.id,callType:r,used:!1,createdAt:new Date}),h("ringing"),di(le,async J=>{if(!J.exists())return;const ie=J.data();if(ie.status==="rejected"||ie.status==="ended")z(),h("ended"),sr.error("Call ended by user"),setTimeout(()=>t(),1200);else if(ie.answer&&!te.currentRemoteDescription){const xe=new RTCSessionDescription(ie.answer);await te.setRemoteDescription(xe),h("connected")}});const Be=it(pe,"calls",le.id,"calleeCandidates");di(Be,J=>{J.docChanges().forEach(async ie=>{if(ie.type==="added"){const xe=new RTCIceCandidate(ie.doc.data());await te.addIceCandidate(xe)}})})}}catch(G){console.error("Call media error:",G),sr.error("Could not access microphone/camera: "+(G.message||"Permission denied")),z(),t()}})(),()=>{z()}),[e]),j.useEffect(()=>(c==="connected"?K.current=setInterval(()=>{k(Y=>Y+1)},1e3):K.current&&clearInterval(K.current),()=>{K.current&&clearInterval(K.current)}),[c]);const z=()=>{q.current&&(q.current.getTracks().forEach(Y=>Y.stop()),q.current=null),Z.current&&(Z.current.close(),Z.current=null),K.current&&clearInterval(K.current)},B=async()=>{if(h("ended"),I)try{await Hn(ot(pe,"calls",I),{status:"ended"})}catch{}z(),sr.success("Call ended",{icon:"📵"}),t()},V=()=>{if(q.current){const Y=q.current.getAudioTracks()[0];Y&&(Y.enabled=!Y.enabled,m(!Y.enabled))}},$=()=>{if(q.current){const Y=q.current.getVideoTracks()[0];Y&&(Y.enabled=!Y.enabled,w(!Y.enabled))}},Q=Y=>{const G=Math.floor(Y/60),he=Y%60;return`${G}:${he<10?"0":""}${he}`};return e?s.jsx(ar,{children:s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-2 sm:p-4 bg-black/85 backdrop-blur-md",children:s.jsxs(Kt.div,{initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:20},className:"bg-neutral-900 border border-neutral-800 rounded-3xl shadow-2xl w-full max-w-md h-[80vh] max-h-[620px] flex flex-col justify-between overflow-hidden relative text-white",children:[s.jsxs("div",{className:"p-4 flex items-center justify-between border-b border-white/10 bg-black/40 backdrop-blur-md z-20",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500 animate-pulse"}),s.jsx("span",{className:"text-xs font-black uppercase tracking-wider text-neutral-300",children:r==="video"?"FaceTime HD Video":"HD Voice Call"})]}),c==="connected"&&s.jsx("span",{className:"text-xs font-mono font-bold bg-white/10 px-2.5 py-0.5 rounded-full text-emerald-400 border border-emerald-500/30",children:Q(A)})]}),s.jsxs("div",{className:"flex-1 relative flex flex-col items-center justify-center p-6 text-center overflow-hidden",children:[r==="video"&&s.jsxs("div",{className:"absolute inset-0 bg-black z-0",children:[s.jsx("video",{ref:F,autoPlay:!0,playsInline:!0,className:"w-full h-full object-cover"}),s.jsxs("div",{className:"absolute top-4 right-4 w-28 h-40 bg-neutral-800 rounded-2xl overflow-hidden border-2 border-white/20 shadow-xl z-20",children:[s.jsx("video",{ref:D,autoPlay:!0,playsInline:!0,muted:!0,className:"w-full h-full object-cover"}),y&&s.jsx("div",{className:"absolute inset-0 bg-neutral-900 flex items-center justify-center text-xs text-neutral-500 font-bold",children:"Camera Off"})]})]}),s.jsx("audio",{ref:L,autoPlay:!0}),s.jsxs("div",{className:"relative z-10 flex flex-col items-center",children:[s.jsxs("div",{className:"relative mb-4",children:[s.jsx("div",{className:"w-24 h-24 sm:w-28 sm:h-28 rounded-full overflow-hidden border-4 border-white/20 shadow-2xl relative",children:s.jsx("img",{src:n.photoURL||`https://api.dicebear.com/7.x/bottts/svg?seed=${n.username}`,alt:"",className:"w-full h-full object-cover"})}),c==="ringing"&&s.jsx("span",{className:"absolute -inset-2 rounded-full border-2 border-emerald-500 animate-ping opacity-75"})]}),s.jsx("h2",{className:"text-xl font-black text-white tracking-tight",children:n.displayName}),s.jsxs("p",{className:"text-xs text-neutral-400 font-bold mt-1 uppercase tracking-wider",children:["@",n.username]}),s.jsxs("div",{className:"mt-4 px-3 py-1 bg-white/10 rounded-full text-xs font-semibold tracking-wide text-neutral-200 border border-white/10 backdrop-blur-sm",children:[c==="calling"&&"Connecting...",c==="ringing"&&"Ringing Peer...",c==="connected"&&"Connected • Secure HD Voice",c==="ended"&&"Call Terminated"]}),r==="audio"&&c==="connected"&&s.jsx("div",{className:"flex items-center gap-1 mt-6",children:[40,70,30,90,50,80,40,60].map((Y,G)=>s.jsx(Kt.span,{animate:{height:[10,Y,10]},transition:{repeat:1/0,duration:.8,delay:G*.1},className:"w-1 bg-[#007AFF] rounded-full"},G))})]})]}),s.jsxs("div",{className:"p-6 bg-black/60 backdrop-blur-xl border-t border-white/10 flex items-center justify-around z-20",children:[s.jsx("button",{onClick:V,className:`p-4 rounded-full transition-all cursor-pointer ${f?"bg-red-500/80 text-white shadow-lg":"bg-white/15 hover:bg-white/25 text-white"}`,title:f?"Unmute":"Mute",children:f?s.jsx(zre,{size:22}):s.jsx(Fre,{size:22})}),s.jsx("button",{onClick:B,className:"p-5 bg-red-600 hover:bg-red-700 text-white rounded-full transition-all cursor-pointer shadow-xl scale-110 active:scale-95",title:"End Call",children:s.jsx(lF,{size:26})}),r==="video"&&s.jsx("button",{onClick:$,className:`p-4 rounded-full transition-all cursor-pointer ${y?"bg-red-500/80 text-white shadow-lg":"bg-white/15 hover:bg-white/25 text-white"}`,title:y?"Turn Camera On":"Turn Camera Off",children:y?s.jsx(Uie,{size:22}):s.jsx(Aa,{size:22})})]})]})})}):null},FMe=["❤️","👍","👎","😂","‼️","❓"],$Me=["🔥","🚀","🎉","💯","😴","🧠","👑","🥳","🍕","🎯","⚡️","🌟","🤩","💬","💩","🤡","🦄","🌈","🏆","💎","🙏","🤝"],Oee=({isOpen:e,onClose:t,friend:n,currentUserId:r,currentUserProfile:i})=>{const[a,o]=j.useState([]),[c,h]=j.useState(""),[f,m]=j.useState(!1),[y,w]=j.useState(null),[A,k]=j.useState(!1),[I,T]=j.useState(null),[D,F]=j.useState(null),[L,q]=j.useState(""),[Z,K]=j.useState(null),[z,B]=j.useState(!0),[V,$]=j.useState(null),Q=j.useRef(null),Y=j.useRef(null),G=j.useRef(null),he=n?[r,n.uid].sort().join("_"):"",te=()=>{var ie;(ie=Q.current)==null||ie.scrollIntoView({behavior:"smooth"})};if(j.useEffect(()=>{a.length>0&&te()},[a]),j.useEffect(()=>{if(!e||!n||!he){o([]);return}B(!0);const ie=Qt(it(pe,"direct_messages"),Nr("conversationId","==",he)),xe=di(ie,ae=>{const Fe=ae.docs.map(pt=>({id:pt.id,...pt.data()}));Fe.sort((pt,Ue)=>{var ht,Ye;const Ct=(ht=pt.createdAt)!=null&&ht.seconds?pt.createdAt.seconds*1e3:pt.createdAt?new Date(pt.createdAt).getTime():0,Tt=(Ye=Ue.createdAt)!=null&&Ye.seconds?Ue.createdAt.seconds*1e3:Ue.createdAt?new Date(Ue.createdAt).getTime():0;return Ct-Tt}),o(Fe),B(!1)},ae=>{console.warn("Realtime message listener fallback:",ae),B(!1)});return()=>xe()},[e,n==null?void 0:n.uid,he]),!e||!n)return null;const le=async ie=>{var pt,Ue;if(ie&&ie.preventDefault(),!c.trim()&&!y||f||!r)return;m(!0);const xe=c.trim(),ae=y,Fe=Z;h(""),w(null),K(null);try{const Ct=(i==null?void 0:i.displayName)||((pt=Ne.currentUser)==null?void 0:pt.displayName)||"Campus Friend",Tt=(i==null?void 0:i.username)||"peer";await ur(it(pe,"direct_messages"),{conversationId:he,senderId:r,receiverId:n.uid,participants:[r,n.uid],text:xe,imageUrl:ae||"",replyToText:Fe?Fe.text||"Image":"",createdAt:new Date}),await ur(it(pe,"notifications"),{userId:n.uid,senderId:r,senderName:Ct,senderUsername:Tt,senderPhotoURL:(i==null?void 0:i.photoURL)||((Ue=Ne.currentUser)==null?void 0:Ue.photoURL)||"",title:`💬 Direct Message from ${Ct}`,message:xe||"Sent an image attachment 📷",type:"direct_message",canReply:!0,used:!1,createdAt:new Date})}catch(Ct){sr.error("Failed to send message: "+Ct.message)}finally{m(!1)}},ve=async(ie,xe)=>{try{const ae=a.find(pt=>pt.id===ie),Fe=(ae==null?void 0:ae.reaction)===xe?"":xe;await Hn(ot(pe,"direct_messages",ie),{reaction:Fe}),T(null),F(null)}catch(ae){sr.error("Failed to update reaction: "+ae.message)}},ke=ie=>{var xe;K(ie),sr.success("Swiped to reply!",{icon:"↩️"}),(xe=G.current)==null||xe.focus()},Be=ie=>{var Fe;const xe=(Fe=ie.target.files)==null?void 0:Fe[0];if(!xe)return;if(xe.size>5*1024*1024){sr.error("Image must be under 5MB");return}k(!0);const ae=new FileReader;ae.onload=()=>{w(ae.result),k(!1)},ae.onerror=()=>{sr.error("Failed to load image"),k(!1)},ae.readAsDataURL(xe)},J=ie=>{if(!ie)return"Just now";let xe;return ie.seconds?xe=new Date(ie.seconds*1e3):xe=new Date(ie),isNaN(xe.getTime())?"Just now":xe.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})};return s.jsxs(ar,{children:[s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-2 sm:p-4 bg-black/65 backdrop-blur-sm",children:s.jsxs(Kt.div,{initial:{opacity:0,scale:.94,y:12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.94,y:12},transition:{type:"spring",damping:25,stiffness:300},className:"bg-white border border-gray-200/80 rounded-3xl shadow-2xl w-full max-w-lg h-[88vh] max-h-[700px] flex flex-col overflow-hidden relative font-sans",children:[s.jsxs("div",{className:"bg-white/90 backdrop-blur-md border-b border-gray-200/80 px-4 py-3 flex items-center justify-between shrink-0 z-10 shadow-2xs",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("img",{src:n.photoURL||`https://api.dicebear.com/7.x/bottts/svg?seed=${n.username}`,alt:"",className:"w-10 h-10 rounded-full object-cover border border-gray-200 shadow-xs",referrerPolicy:"no-referrer"}),s.jsx("span",{className:"absolute bottom-0 right-0 w-3 h-3 bg-emerald-500 border-2 border-white rounded-full shadow-2xs"})]}),s.jsxs("div",{className:"min-w-0 text-left",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("h3",{className:"text-sm font-extrabold text-gray-950 truncate tracking-tight",children:n.displayName}),s.jsx("span",{className:"px-1.5 py-0.2 bg-blue-50 text-[#007AFF] border border-blue-200/60 text-[8px] font-black uppercase rounded-full tracking-wider shrink-0",children:"iMessage"})]}),s.jsxs("p",{className:"text-[10px] text-gray-400 font-semibold truncate leading-tight",children:["@",n.username.toLowerCase()," • ",s.jsx("span",{className:"text-emerald-600 font-bold",children:"Connected Friend"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.jsx("button",{onClick:()=>$("audio"),className:"p-2 text-gray-500 hover:text-[#007AFF] hover:bg-blue-50 rounded-full transition-all cursor-pointer",title:"Start Audio Call",children:s.jsx(wk,{size:17})}),s.jsx("button",{onClick:()=>$("video"),className:"p-2 text-gray-500 hover:text-[#007AFF] hover:bg-blue-50 rounded-full transition-all cursor-pointer",title:"Start FaceTime Video",children:s.jsx(Aa,{size:17})}),s.jsx("button",{onClick:t,className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-full transition-all cursor-pointer ml-1",title:"Close Chat",children:s.jsx(er,{size:18})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 bg-[#0f172a] dark:bg-[#0e1621] space-y-3.5 relative scroll-smooth bg-cover bg-center",children:[s.jsx("div",{className:"absolute inset-0 opacity-[0.07] pointer-events-none z-0",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='1'%3E%3Cpath d='M0 0h40v40H0z' fill='none'/%3E%3Cpath d='M20 10l-4 8h8l-4-8zm-8 12l-4 8h8l-4-8zm16 0l-4 8h8l-4-8zm-8 12l-4 8h8l-4-8zM60 50l-4 8h8l-4-8zm-8 12l-4 8h8l-4-8zm16 0l-4 8h8l-4-8zm-8 12l-4 8h8l-4-8z'/%3E%3C/g%3E%3C/svg%3E")`}}),s.jsx("div",{className:"flex justify-center my-1 shrink-0 z-10 relative",children:s.jsxs("div",{className:"bg-[#182533]/90 text-emerald-300 border border-emerald-500/30 rounded-2xl px-3.5 py-2 text-[10.5px] font-medium text-center shadow-lg flex items-center gap-2 max-w-xs sm:max-w-sm backdrop-blur-md",children:[s.jsx(oF,{size:13,className:"text-emerald-400 shrink-0 animate-pulse"}),s.jsxs("span",{className:"text-gray-200 leading-snug",children:[s.jsx("strong",{className:"text-emerald-400 font-extrabold",children:"End-to-End Encrypted"})," • Messages and calls are end-to-end encrypted. No one outside of this chat, not even Campus Eye, can read or listen to them."]})]})}),z?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-400 gap-2 relative z-10",children:[s.jsx(Pr,{size:24,className:"animate-spin text-[#2AABEE]"}),s.jsx("p",{className:"text-xs font-bold uppercase tracking-wider text-gray-300",children:"Loading end-to-end encrypted chat..."})]}):a.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center px-6 py-8 my-auto relative z-10",children:[s.jsx("div",{className:"w-14 h-14 bg-[#2AABEE]/20 text-[#2AABEE] rounded-full flex items-center justify-center shadow-md mb-3 border border-[#2AABEE]/30",children:s.jsx(es,{size:26})}),s.jsx("h4",{className:"text-sm font-black text-white uppercase tracking-tight",children:"Telegram Secure Direct Chat"}),s.jsxs("p",{className:"text-xs text-gray-300 max-w-xs mt-1 leading-relaxed",children:["Start a private conversation with your peer friend ",s.jsxs("span",{className:"font-bold text-white",children:["@",n.username.toLowerCase()]}),"."]}),s.jsx("div",{className:"mt-4 flex flex-wrap gap-1.5 justify-center",children:["Hey! 👋","What campus event is today?","Are you studying in the library?"].map(ie=>s.jsx("button",{onClick:()=>{h(ie)},className:"text-[11px] font-semibold bg-[#17212b] border border-gray-700/80 text-gray-200 hover:bg-[#2AABEE] hover:text-white hover:border-[#2AABEE] px-3 py-1.5 rounded-full transition-all shadow-xs cursor-pointer",children:ie},ie))})]}):a.map((ie,xe)=>{const ae=ie.senderId===r,Fe=I===ie.id,pt=D===ie.id;return s.jsxs(Kt.div,{drag:"x",dragConstraints:{left:-50,right:50},dragElastic:.15,onDragEnd:(Ue,Ct)=>{Math.abs(Ct.offset.x)>30&&ke(ie)},className:`flex flex-col ${ae?"items-end":"items-start"} group relative z-10`,children:[xe===0&&s.jsx("div",{className:"w-full text-center my-1.5",children:s.jsx("span",{className:"text-[9.5px] font-bold text-gray-300 uppercase tracking-wider bg-[#17212b]/90 px-2.5 py-0.5 rounded-full border border-gray-700/60 shadow-xs",children:J(ie.createdAt)})}),s.jsxs("div",{className:"relative flex items-end gap-1.5 max-w-[85%]",children:[!ae&&s.jsx("img",{src:n.photoURL||`https://api.dicebear.com/7.x/bottts/svg?seed=${n.username}`,alt:"",className:"w-6 h-6 rounded-full object-cover border border-gray-700 shadow-xs shrink-0 mb-1"}),s.jsxs("div",{onClick:()=>{T(Fe?null:ie.id),F(null)},className:`relative cursor-pointer transition-transform active:scale-[0.98] ${ae?"bg-[#2AABEE] text-white rounded-2xl rounded-br-xs shadow-md px-3.5 py-2 text-[13.5px] font-normal leading-snug":"bg-[#182533] text-gray-100 border border-gray-700/60 rounded-2xl rounded-bl-xs shadow-md px-3.5 py-2 text-[13.5px] font-normal leading-snug"}`,children:[ie.replyToText&&s.jsxs("div",{className:`text-[10px] italic px-2 py-1 rounded-lg mb-1.5 border-l-2 ${ae?"bg-white/15 border-white text-white/90":"bg-gray-100 border-[#007AFF] text-gray-600"}`,children:[s.jsx("span",{className:"font-bold",children:"Replying:"}),' "',ie.replyToText,'"']}),ie.imageUrl&&s.jsx("div",{className:"mb-2 rounded-xl overflow-hidden border border-black/10",children:s.jsx("img",{src:ie.imageUrl,alt:"Attached",className:"max-h-52 w-full object-cover"})}),s.jsx("p",{className:"whitespace-pre-wrap break-words",children:ie.text}),ie.reaction&&s.jsx("div",{className:`absolute -bottom-2.5 ${ae?"-left-2":"-right-2"} bg-white border border-gray-200 rounded-full px-1.5 py-0.2 text-[12px] shadow-sm flex items-center gap-0.5 animate-bounce`,children:s.jsx("span",{children:ie.reaction})})]})]}),s.jsx(ar,{children:Fe&&s.jsxs(Kt.div,{initial:{opacity:0,scale:.8,y:-5},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.8,y:-5},className:`absolute z-20 top-0 ${ae?"right-0":"left-8"} -translate-y-full mb-1 bg-white/95 backdrop-blur-md border border-gray-200 rounded-full px-2 py-1 shadow-lg flex items-center gap-1.5`,children:[FMe.map(Ue=>s.jsx("button",{onClick:Ct=>{Ct.stopPropagation(),ve(ie.id,Ue)},className:"text-base hover:scale-125 transition-transform p-0.5 cursor-pointer",children:Ue},Ue)),s.jsxs("button",{type:"button",onClick:Ue=>{Ue.stopPropagation(),F(ie.id),T(null)},className:"text-xs font-bold bg-blue-50 text-[#007AFF] hover:bg-blue-100 rounded-full p-1 px-1.5 transition-all flex items-center gap-0.5 cursor-pointer",title:"Choose custom emoji reaction",children:[s.jsx(fu,{size:12}),s.jsx("span",{children:"Emoji"})]})]})}),s.jsx(ar,{children:pt&&s.jsxs(Kt.div,{initial:{opacity:0,scale:.9,y:-5},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:-5},className:`absolute z-30 top-0 ${ae?"right-0":"left-8"} -translate-y-full mb-1 bg-white border border-gray-200 rounded-2xl p-2 shadow-2xl w-64 text-left`,children:[s.jsxs("div",{className:"flex items-center justify-between pb-1.5 border-b border-gray-100",children:[s.jsx("span",{className:"text-[10px] font-black uppercase text-gray-700 tracking-wider",children:"Choose Custom Emoji Reaction"}),s.jsx("button",{onClick:()=>F(null),className:"text-gray-400 hover:text-black p-0.5 cursor-pointer",children:s.jsx(er,{size:12})})]}),s.jsx("div",{className:"grid grid-cols-6 gap-1 py-2 max-h-32 overflow-y-auto",children:$Me.map(Ue=>s.jsx("button",{onClick:Ct=>{Ct.stopPropagation(),ve(ie.id,Ue)},className:"text-lg hover:scale-125 p-1 rounded-lg hover:bg-blue-50 transition-all cursor-pointer flex items-center justify-center",children:Ue},Ue))}),s.jsxs("div",{className:"flex items-center gap-1 pt-1.5 border-t border-gray-100",children:[s.jsx("input",{type:"text",value:L,onChange:Ue=>q(Ue.target.value),placeholder:"Type any emoji...",className:"flex-1 text-xs px-2 py-1 bg-gray-50 border border-gray-200 rounded-lg outline-none focus:border-[#007AFF]"}),s.jsx("button",{type:"button",onClick:()=>{L.trim()&&(ve(ie.id,L.trim()),q(""))},className:"px-2 py-1 bg-[#007AFF] text-white text-[9px] font-bold uppercase rounded-lg cursor-pointer shrink-0",children:"Set"})]})]})}),s.jsxs("div",{className:"flex items-center gap-2 text-[9px] text-gray-400 font-semibold px-1 mt-0.5",children:[s.jsx("span",{children:J(ie.createdAt)}),ae&&s.jsx(Bne,{size:11,className:"text-[#007AFF]"}),s.jsxs("button",{type:"button",onClick:()=>ke(ie),className:"text-[8px] font-bold text-gray-400 hover:text-[#007AFF] transition-colors flex items-center gap-0.5 cursor-pointer",children:[s.jsx(q6,{size:9}),s.jsx("span",{children:"Reply"})]})]})]},`msg-${ie.id||xe}-${xe}`)}),s.jsx("div",{ref:Q})]}),Z&&s.jsxs("div",{className:"p-2 px-3 bg-blue-50 border-t border-blue-200 flex items-center justify-between gap-2 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(q6,{size:14,className:"text-[#007AFF] shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-[9px] font-bold text-blue-900 uppercase tracking-wider",children:"Swiped to Reply"}),s.jsxs("p",{className:"text-[11px] text-gray-700 truncate font-medium",children:['"',Z.text||"Image attachment",'"']})]})]}),s.jsx("button",{type:"button",onClick:()=>K(null),className:"p-1 text-gray-400 hover:text-red-600 rounded-full cursor-pointer",children:s.jsx(er,{size:14})})]}),y&&s.jsxs("div",{className:"p-2 bg-gray-100 border-t border-gray-200 flex items-center justify-between gap-2 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("img",{src:y,alt:"Preview",className:"w-10 h-10 rounded-lg object-cover border border-gray-300"}),s.jsx("span",{className:"text-[10px] font-bold text-gray-600 truncate",children:"Ready to send photo"})]}),s.jsx("button",{type:"button",onClick:()=>w(null),className:"p-1 text-gray-500 hover:text-red-600 rounded-full hover:bg-gray-200 cursor-pointer",children:s.jsx(er,{size:14})})]}),s.jsxs("form",{onSubmit:le,className:"bg-gray-100/90 border-t border-gray-200/90 p-2.5 px-3.5 flex items-center gap-2 shrink-0",children:[s.jsx("input",{type:"file",ref:Y,accept:"image/*",onChange:Be,className:"hidden"}),s.jsx("button",{type:"button",onClick:()=>{var ie;return(ie=Y.current)==null?void 0:ie.click()},disabled:A,className:"p-2 text-[#007AFF] hover:bg-blue-50 rounded-full transition-all cursor-pointer shrink-0",title:"Attach Image",children:A?s.jsx(Pr,{size:18,className:"animate-spin"}):s.jsx(Bh,{size:19})}),s.jsxs("div",{className:"flex-1 relative flex items-center",children:[s.jsx("input",{ref:G,type:"text",value:c,onChange:ie=>h(ie.target.value),placeholder:Z?"Reply to message...":"iMessage",className:"w-full text-sm font-sans bg-white border border-gray-300 focus:border-[#007AFF] focus:ring-1 focus:ring-[#007AFF] rounded-full px-4 py-2 pr-9 outline-none text-gray-900 placeholder:text-gray-400 transition-all shadow-2xs"}),s.jsx("button",{type:"button",onClick:()=>h(ie=>ie+" ❤️"),className:"absolute right-2.5 text-gray-400 hover:text-red-500 transition-colors p-0.5 cursor-pointer",children:s.jsx(ku,{size:15})})]}),s.jsx("button",{type:"submit",disabled:!c.trim()&&!y||f,className:"p-2.5 bg-[#007AFF] hover:bg-blue-600 active:scale-95 disabled:opacity-40 text-white rounded-full transition-all cursor-pointer shrink-0 shadow-xs flex items-center justify-center",title:"Send iMessage",children:f?s.jsx(Pr,{size:16,className:"animate-spin"}):s.jsx(fl,{size:15,className:"translate-x-0.2"})})]})]})}),V&&n&&s.jsx(Tee,{isOpen:!0,onClose:()=>$(null),peer:n,callType:V})]})},HMe=({isOpen:e,onClose:t,currentUserId:n,viewingUserId:r,initialTab:i,onUserProfileClick:a})=>{const[o,c]=j.useState(i),[h,f]=j.useState({}),[m,y]=j.useState([]),[w,A]=j.useState([]),[k,I]=j.useState(""),[T,D]=j.useState(!0),[F,L]=j.useState(null),[q,Z]=j.useState(null),[K,z]=j.useState(""),[B,V]=j.useState(!1);j.useEffect(()=>{const J=ie=>{ie.detail&&Z(ie.detail)};return window.addEventListener("open-imessage-friend",J),()=>window.removeEventListener("open-imessage-friend",J)},[]);const $=r||n,Q=J=>o==="connections"?!0:w.some(ie=>ie.status==="accepted"&&(ie.senderId===n&&(ie.receiverId===J||ie.targetUserId===J)||(ie.senderId===J||ie.receiverId===J)&&(ie.receiverId===n||ie.targetUserId===n))),Y=async()=>{if(!(!F||!K.trim()||!n)){V(!0);try{const J=h[n],ie=J?J.displayName:"A Campus Friend",xe=J?J.username:"member";await ur(it(pe,"notifications"),{userId:F.uid,senderId:n,senderName:ie,senderUsername:xe,senderPhotoURL:(J==null?void 0:J.photoURL)||"",title:`📩 Direct Inbox Message from ${ie}`,message:K.trim(),type:"direct_message",canReply:!0,used:!1,createdAt:new Date}),sr.success(`Inbox message sent to @${F.username.toLowerCase()}!`,{icon:"✉️"}),L(null),z("")}catch(J){sr.error("Failed to send direct message: "+J.message)}finally{V(!1)}}};j.useEffect(()=>{e&&c(i)},[e,i]),j.useEffect(()=>{if(!e||!n)return;D(!0),(async()=>{try{const[ie,xe,ae]=await Promise.all([vn(it(pe,"users")),vn(it(pe,"follows")),vn(it(pe,"invitations"))]),Fe={};ie.docs.forEach(Ct=>{const Tt=Ct.data();Fe[Ct.id]={uid:Ct.id,displayName:Tt.displayName||"Campus Member",username:Tt.username||"member",photoURL:Tt.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(Tt.displayName||"U")}&background=random`,email:Tt.email,role:Tt.role}}),f(Fe);const pt=xe.docs.map(Ct=>Ct.data());y(pt);const Ue=ae.docs.map(Ct=>Ct.data());A(Ue)}catch(ie){console.warn("Error fetching connections directory inside modal:",ie)}finally{D(!1)}})()},[e,n]);const G=async(J,ie)=>{if(!n||!J)return;const xe=`${n}_${J}`,ae=m.some(Fe=>Fe.followerId===n&&Fe.followedId===J);try{if(ae){y(Ue=>Ue.filter(Ct=>!(Ct.followerId===n&&Ct.followedId===J))),await ni(ot(pe,"follows",xe));const Fe=h[n],pt=Fe?`@${(Fe.displayName||"a peer").replace(/\s+/g,"").toLowerCase()}`:"A peer";try{const Ue=`notif_unfollow_${n}_${J}`;await Hr(ot(pe,"notifications",Ue),{userId:J,title:"💔 Lounge Unfollow",message:`${pt} unfollowed you.`,type:"social",used:!0,createdAt:new Date})}catch(Ue){console.warn("Failed to create unfollow notification:",Ue)}}else{const Fe={followerId:n,followedId:J,createdAt:new Date};y(Ct=>[...Ct,Fe]),await Hr(ot(pe,"follows",xe),{followerId:n,followedId:J,createdAt:new Date});const pt=h[n],Ue=pt?`@${(pt.displayName||"a peer").replace(/\s+/g,"").toLowerCase()}`:"A peer";try{const Ct=`notif_follow_${n}_${J}`;await Hr(ot(pe,"notifications",Ct),{userId:J,title:"👥 New Lounge Follower!",message:`${Ue} is now following you. They will receive your latest dispatches!`,type:"social",createdAt:new Date})}catch(Ct){console.warn("Failed to create follow notification from modal:",Ct)}}}catch(Fe){console.error("Error toggling follow inside modal modal:",Fe)}},he=()=>m.filter(ie=>ie.followedId===$).map(ie=>ie.followerId).map(ie=>h[ie]).filter(ie=>!!ie),te=()=>m.filter(ie=>ie.followerId===$).map(ie=>ie.followedId).map(ie=>h[ie]).filter(ie=>!!ie),le=()=>{const J=w.filter(xe=>xe.status==="accepted"&&(xe.senderId===$||xe.receiverId===$)).map(xe=>xe.senderId===$?xe.receiverId:xe.senderId);return Array.from(new Set(J)).map(xe=>h[xe]).filter(xe=>!!xe)},ke=(()=>{switch(o){case"followers":return he();case"following":return te();case"connections":return le()}})(),Be=ke.filter(J=>J.displayName.toLowerCase().includes(k.toLowerCase())||J.username.toLowerCase().includes(k.toLowerCase()));return s.jsxs(ar,{children:[e&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx(Kt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:t,className:"absolute inset-0 bg-black/60 backdrop-blur-xs"}),s.jsxs(Kt.div,{initial:{scale:.95,opacity:0,y:15},animate:{scale:1,opacity:1,y:0},exit:{scale:.95,opacity:0,y:15},transition:{type:"spring",damping:25,stiffness:350},className:"bg-white border border-gray-150 rounded-3xl w-full max-w-md h-[480px] flex flex-col overflow-hidden shadow-2xl relative z-10 select-none",id:"user-connections-dialog",children:[s.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ao,{size:16,className:"text-red-650"}),s.jsx("h3",{className:"text-xs font-black uppercase tracking-widest text-gray-950",children:"Campus Relations"})]}),s.jsx("button",{onClick:t,className:"w-7 h-7 text-gray-400 hover:text-gray-950 rounded-full hover:bg-gray-100 flex items-center justify-center transition-colors cursor-pointer",title:"Close Window",id:"close-connections-modal",children:s.jsx(er,{size:14,strokeWidth:2.5})})]}),s.jsx("div",{className:"grid grid-cols-3 border-b border-gray-100 bg-gray-50/50 p-1",children:["followers","following","connections"].map(J=>{const ie=o===J,xe=J==="followers"?"Followers":J==="following"?"Following":"Lounge",ae=J==="followers"?he().length:J==="following"?te().length:le().length;return s.jsxs("button",{onClick:()=>c(J),className:`py-2 text-[10px] font-extrabold uppercase tracking-widest rounded-xl transition-all cursor-pointer flex flex-col items-center justify-center gap-0.5 ${ie?"bg-white text-red-650 shadow-xs border border-gray-150/45":"text-gray-400 hover:text-gray-700 hover:bg-white/40"}`,children:[s.jsx("span",{children:xe}),s.jsx("span",{className:`text-[8.5px] font-black font-mono ${ie?"text-red-650":"text-gray-400"}`,children:ae})]},J)})}),ke.length>0&&s.jsx("div",{className:"px-4 pt-3 pb-1 border-b border-gray-100/30",children:s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",value:k,onChange:J=>I(J.target.value),placeholder:"Search connection directory...",className:"w-full text-[11px] placeholder-gray-400 font-bold font-sans bg-gray-50 border border-gray-100 px-8 py-2 rounded-xl focus:bg-white focus:border-red-650/45 outline-none transition-all"}),s.jsx(Ip,{size:11,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"})]})}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3.5 scrollbar-thin",children:T?s.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-2",children:[s.jsx(Pr,{className:"animate-spin text-red-650",size:24}),s.jsx("span",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Resolving user accounts..."})]}):Be.length===0?s.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center space-y-2 p-6",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-gray-100 flex items-center justify-center text-gray-400",children:s.jsx(Ao,{size:16})}),s.jsx("h4",{className:"text-[11px] font-black text-gray-900 uppercase tracking-wide",children:k?"No Matches Found":"No Directory Records"}),s.jsx("p",{className:"text-[9.5px] text-gray-400 leading-normal max-w-xs",children:k?"Refine your keyword to lookup active university profiles.":o==="followers"?"Register original columns or news reports to gather active campus followers!":o==="following"?"Follow varsity writers, reporters, or editors to customize your custom news stream.":"Connect in Lounge from posts to establish personal direct active debate capabilities."})]}):Be.map(J=>{const ie=m.some(Fe=>Fe.followerId===n&&Fe.followedId===J.uid),xe=J.uid===n,ae=Q(J.uid);return s.jsxs(Kt.div,{layout:!0,className:"flex items-center justify-between p-2 rounded-2xl hover:bg-gray-50/70 border border-transparent hover:border-gray-100/50 transition-all gap-2",children:[s.jsxs("div",{onClick:()=>{a&&(a(J.uid),t())},className:"flex items-center gap-2.5 min-w-0 flex-1 cursor-pointer group/item",children:[s.jsx("img",{src:J.photoURL,alt:"",className:"w-10 h-10 rounded-full object-cover border border-white shadow-xs group-hover/item:ring-2 group-hover/item:ring-red-650/40 transition-all shrink-0",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"text-left min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("h5",{className:"text-[11px] font-black text-gray-950 uppercase tracking-tight truncate group-hover/item:text-red-650 transition-colors",children:J.displayName}),ae&&!xe&&s.jsxs("span",{className:"px-1.5 py-0.2 bg-emerald-50 text-emerald-700 border border-emerald-200 text-[7px] font-black uppercase rounded tracking-wider flex items-center gap-0.5",title:"Accepted Friend",children:[s.jsx(Xh,{size:8})," Connected"]})]}),s.jsxs("p",{className:"text-[9px] text-gray-400 font-semibold truncate leading-none",children:["@",J.username.toLowerCase()]}),J.role&&s.jsx("span",{className:"inline-block mt-1 text-[7.5px] font-black tracking-widest px-1 py-0.2 rounded bg-gray-100 text-gray-500 uppercase",children:J.role==="admin"?"Editorial Board":"Reporter"})]})]}),!xe&&ae&&s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.jsxs("button",{onClick:Fe=>{Fe.stopPropagation(),Z(J)},className:"p-1.5 px-2.5 bg-[#007AFF] hover:bg-blue-600 text-white rounded-xl shadow-xs transition-all cursor-pointer flex items-center gap-1 text-[8.5px] font-black uppercase tracking-wider shrink-0",title:`Open iMessage conversation thread with ${J.displayName}`,children:[s.jsx(Yi,{size:12,strokeWidth:2.5}),s.jsx("span",{children:"iMessage"})]}),s.jsxs("button",{onClick:Fe=>{Fe.stopPropagation(),L(J)},className:"p-1.5 px-2 bg-indigo-50 hover:bg-indigo-600 text-indigo-700 hover:text-white rounded-xl border border-indigo-200/80 transition-all cursor-pointer flex items-center gap-1 text-[8.5px] font-black uppercase tracking-wider shrink-0 shadow-2xs",title:`Send direct inbox alert to ${J.displayName}`,children:[s.jsx(Js,{size:12,strokeWidth:2.5}),s.jsx("span",{className:"hidden sm:inline",children:"Inbox"})]})]}),!xe&&s.jsx("button",{onClick:()=>G(J.uid,J.displayName),className:`text-[8.5px] h-7 px-2.5 rounded-lg font-black uppercase tracking-wider flex items-center gap-1 cursor-pointer transition-colors shrink-0 ${ie?"bg-gray-100 text-gray-650 border border-gray-150 hover:bg-red-50 hover:text-red-650 hover:border-red-150":"bg-red-50 text-red-650 border border-red-150/40 hover:bg-red-650 hover:text-white"}`,children:ie?s.jsxs(s.Fragment,{children:[s.jsx(L1,{size:9,strokeWidth:2.5}),s.jsx("span",{className:"hidden sm:inline",children:"Following"})]}):s.jsxs(s.Fragment,{children:[s.jsx(yp,{size:9,strokeWidth:2.5}),s.jsx("span",{children:"Follow"})]})})]},J.uid)})}),s.jsx(ar,{children:F&&s.jsx("div",{className:"absolute inset-0 z-50 bg-black/60 backdrop-blur-xs flex items-center justify-center p-4",children:s.jsxs(Kt.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:"bg-white border border-gray-200 rounded-2xl p-4 w-full max-w-sm shadow-2xl text-left space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Js,{size:16,className:"text-indigo-600"}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-black uppercase tracking-wider text-gray-950",children:"Campus Direct Message"}),s.jsxs("p",{className:"text-[9px] text-gray-400 font-medium",children:["To connected friend @",F.username.toLowerCase()]})]})]}),s.jsx("button",{onClick:()=>L(null),className:"p-1 text-gray-400 hover:text-black rounded-lg hover:bg-gray-100 transition-all cursor-pointer",children:s.jsx(er,{size:14})})]}),s.jsxs("div",{className:"flex items-center gap-2.5 p-2 bg-indigo-50/50 rounded-xl border border-indigo-100/60",children:[s.jsx("img",{src:F.photoURL,alt:"",className:"w-8 h-8 rounded-full object-cover border border-indigo-200 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-[10px] font-black uppercase text-gray-900 truncate",children:F.displayName}),s.jsx("p",{className:"text-[8px] text-indigo-700 font-bold uppercase tracking-wider",children:"Connected Friend"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[9px] font-black uppercase text-gray-500 tracking-wider block mb-1",children:"Your Message:"}),s.jsx("textarea",{value:K,onChange:J=>z(J.target.value),placeholder:`Write your inbox message for ${F.displayName}...`,rows:3,className:"w-full text-xs font-sans p-2.5 bg-gray-50 border border-gray-200 rounded-xl outline-none focus:bg-white focus:border-indigo-600 transition-all resize-none"})]}),s.jsxs("div",{className:"flex items-center justify-end gap-2 pt-1",children:[s.jsx("button",{onClick:()=>L(null),className:"px-3 py-1.5 text-[9.5px] font-bold text-gray-600 hover:text-black bg-gray-100 hover:bg-gray-200 rounded-xl transition-all cursor-pointer",children:"Cancel"}),s.jsxs("button",{onClick:Y,disabled:B||!K.trim(),className:"px-4 py-1.5 text-[9.5px] font-black uppercase tracking-wider bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 text-white rounded-xl transition-all flex items-center gap-1.5 shadow-xs cursor-pointer",children:[B?s.jsx(Pr,{size:12,className:"animate-spin"}):s.jsx(fl,{size:12}),s.jsx("span",{children:"Send Message"})]})]})]})})})]})]}),s.jsx(Oee,{isOpen:!!q,onClose:()=>Z(null),friend:q,currentUserId:n,currentUserProfile:h[n]||null})]})},GMe=({isOpen:e,onClose:t,userId:n,currentUserId:r})=>{const[i,a]=j.useState(!0),[o,c]=j.useState(null),[h,f]=j.useState(null),[m,y]=j.useState(!1);j.useEffect(()=>{if(!e||!n)return;a(!0),(async()=>{try{const k=ot(pe,"users",n),I=await cs(k);let T={id:n,displayName:"Campus Citizen",email:""};I.exists()&&(T={id:n,...I.data()}),c(T);const[D,F,L,q,Z]=await Promise.all([vn(Qt(it(pe,"articles"),Nr("authorId","==",n))),vn(Qt(it(pe,"posts"),Nr("userId","==",n))),vn(Qt(it(pe,"purchases"),Nr("userId","==",n))),vn(Qt(it(pe,"follows"),Nr("followedId","==",n))),vn(Qt(it(pe,"follows"),Nr("followerId","==",n)))]),K=D.size,z=F.size,B=L.size,V=q.size,$=Z.size;let Q=0;L.docs.forEach(te=>{const le=te.data();Q+=(Number(le.amount)||Number(le.ticketPrice)||0)*(Number(le.quantity)||1)});const Y=K*25+z*8+B*15+V*5;let G="Campus Scholar",he="text-blue-400";if(Y>=100?(G="Editorial Titan",he="text-purple-400"):Y>=50?(G="Senior Dispatcher",he="text-amber-400"):Y>=20&&(G="Active Reporter",he="text-emerald-400"),f({userId:n,userName:T.displayName||"Campus Citizen",userEmail:T.email||"",userPhoto:T.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(T.displayName||"U")}&background=random`,engagementScore:Y,articlesCount:K,postsCount:z,purchasesCount:B,totalSpent:Q,followersCount:V,followingCount:$,tier:G,tierColor:he}),r&&r!==n){const te=`${r}_${n}`,le=await cs(ot(pe,"follows",te));y(le.exists())}}catch(k){console.error("Error fetching user profile stats:",k)}finally{a(!1)}})()},[e,n,r]);const w=async()=>{if(!r||!n)return;const A=`${r}_${n}`;try{m?(y(!1),await ni(ot(pe,"follows",A)),me.success(`Unfollowed @${((o==null?void 0:o.displayName)||"citizen").toLowerCase().replace(/\s+/g,"")}`)):(y(!0),await Hr(ot(pe,"follows",A),{followerId:r,followedId:n,createdAt:new Date}),me.success(`Now following @${((o==null?void 0:o.displayName)||"citizen").toLowerCase().replace(/\s+/g,"")}!`))}catch(k){console.error(k),me.error("Failed to update follow status")}};return!e||!n?null:s.jsx(ar,{children:s.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4",children:[s.jsx(Kt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:t,className:"absolute inset-0 bg-black/75 backdrop-blur-sm"}),s.jsxs(Kt.div,{initial:{scale:.95,opacity:0,y:15},animate:{scale:1,opacity:1,y:0},exit:{scale:.95,opacity:0,y:15},transition:{type:"spring",damping:25,stiffness:350},className:"bg-white border border-gray-150 rounded-3xl w-full max-w-lg max-h-[90vh] flex flex-col overflow-hidden shadow-2xl relative z-10 select-none",children:[s.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/50",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xp,{size:16,className:"text-red-650"}),s.jsx("h3",{className:"text-xs font-black uppercase tracking-widest text-gray-950",children:"Citizen Engagement Profile"})]}),s.jsx("button",{onClick:t,className:"w-7 h-7 text-gray-400 hover:text-gray-950 rounded-full hover:bg-gray-100 flex items-center justify-center transition-colors cursor-pointer",children:s.jsx(er,{size:14,strokeWidth:2.5})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-5 space-y-5 scrollbar-thin",children:i?s.jsxs("div",{className:"py-16 flex flex-col items-center justify-center gap-2",children:[s.jsx(Pr,{className:"animate-spin text-red-650",size:28}),s.jsx("span",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest",children:"Calculating live citizen analytics & graphs..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"bg-gradient-to-r from-gray-900 to-black text-white p-5 rounded-3xl flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 border border-gray-800 shadow-lg",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("img",{src:(o==null?void 0:o.photoURL)||`https://ui-avatars.com/api/?name=${encodeURIComponent((o==null?void 0:o.displayName)||"User")}&background=random`,alt:"",className:"w-16 h-16 rounded-2xl object-cover border-2 border-white/20 shadow-md",referrerPolicy:"no-referrer"}),((o==null?void 0:o.isAdmin)||(o==null?void 0:o.role)==="admin")&&s.jsx("div",{className:"absolute -top-1.5 -right-1.5 bg-accent text-white p-1 rounded-lg shadow-md",children:s.jsx(pl,{size:12})})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("h4",{className:"font-extrabold text-base text-white uppercase tracking-tight truncate",children:(o==null?void 0:o.displayName)||"Campus Citizen"}),((o==null?void 0:o.isVerified)||(o==null?void 0:o.isPremium)||(o==null?void 0:o.blueCheck)||(o==null?void 0:o.isPremiumPostUser))&&s.jsx(Ll,{size:16})]}),s.jsxs("p",{className:"text-[10px] text-gray-400 uppercase font-bold tracking-widest truncate",children:["@",((o==null?void 0:o.username)||(o==null?void 0:o.displayName)||"member").toLowerCase().replace(/\s+/g,"")]}),s.jsx("div",{className:"mt-1.5 flex items-center gap-2",children:s.jsx("span",{className:"px-2 py-0.5 bg-white/10 rounded text-[8px] font-black uppercase tracking-wider text-gray-300",children:o!=null&&o.isAdmin||(o==null?void 0:o.role)==="admin"?"Editorial Board":"Citizen Reporter"})})]})]}),r&&r!==n&&s.jsx("button",{onClick:w,className:`px-4 py-2.5 rounded-xl text-[10px] font-black uppercase tracking-widest flex items-center gap-1.5 cursor-pointer transition-all shrink-0 ${m?"bg-white/10 text-white border border-white/20 hover:bg-red-600/80 hover:border-red-600":"bg-red-650 text-white hover:bg-red-700 shadow-lg shadow-red-650/30"}`,children:m?s.jsxs(s.Fragment,{children:[s.jsx(L1,{size:13}),s.jsx("span",{children:"Following"})]}):s.jsxs(s.Fragment,{children:[s.jsx(yp,{size:13}),s.jsx("span",{children:"Follow Citizen"})]})})]}),h&&s.jsx(Iee,{stats:h})]})})]})]})})},qMe=()=>{const[e,t]=j.useState(navigator.onLine),[n,r]=j.useState(!navigator.onLine),[i,a]=j.useState(navigator.onLine?"online":"offline");return j.useEffect(()=>{let o;const c=()=>{t(!0),a("online"),r(!0),o=setTimeout(()=>{r(!1)},3500)},h=()=>{t(!1),a("offline"),r(!0)};return window.addEventListener("online",c),window.addEventListener("offline",h),navigator.onLine||(r(!0),a("offline")),()=>{window.removeEventListener("online",c),window.removeEventListener("offline",h),o&&clearTimeout(o)}},[]),s.jsx(ar,{children:n&&s.jsx("div",{className:"fixed top-2.5 sm:top-3 left-1/2 -translate-x-1/2 z-[10000] pointer-events-none select-none font-sans",children:s.jsxs(Kt.div,{initial:{y:-50,scale:.6,opacity:0},animate:{y:0,scale:1,opacity:1},exit:{y:-50,scale:.6,opacity:0},transition:{type:"spring",damping:25,stiffness:380},className:`pointer-events-auto flex items-center gap-2 px-3 py-1 sm:py-1.5 rounded-full border shadow-lg backdrop-blur-xl transition-all ${i==="online"?"bg-black/95 border-emerald-500/30 text-white":"bg-black/95 border-red-500/30 text-white"}`,children:[s.jsx("div",{className:"flex items-center justify-center shrink-0",children:s.jsx("span",{className:`w-2 h-2 rounded-full ${i==="online"?"bg-emerald-500":"bg-red-500"}`})}),s.jsx("div",{className:"shrink-0",children:i==="online"?s.jsx(qie,{size:12,className:"text-emerald-400"}):s.jsx(Hie,{size:12,className:"text-red-400"})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:`text-[9px] font-black uppercase tracking-widest font-mono ${i==="online"?"text-emerald-400":"text-red-400"}`,children:i==="online"?"Online":"Offline"}),s.jsx("span",{className:"text-[8.5px] text-gray-300 font-bold uppercase tracking-wider hidden sm:inline-block",children:i==="online"?"Connected":"No Network"})]}),i==="online"&&s.jsx("button",{onClick:()=>r(!1),className:"ml-0.5 text-gray-400 hover:text-white text-[8px] font-bold px-1 py-0.2 rounded-full hover:bg-white/10 transition-colors cursor-pointer",title:"Dismiss",children:"✕"})]})})})},WMe=()=>{const e=Ne.currentUser,[t,n]=j.useState(null),[r,i]=j.useState(null);j.useEffect(()=>{if(!e){n(null);return}const c=Qt(it(pe,"calls"),Nr("receiverId","==",e.uid),Nr("status","==","ringing")),h=di(c,f=>{if(f.empty)n(null);else{const m=f.docs[0],y={id:m.id,...m.data()};n(y),pye()}});return()=>h()},[e]);const a=()=>{t&&(i({peer:{uid:t.callerId,displayName:t.callerName,username:(t.callerName||"peer").toLowerCase().replace(/\s+/g,""),photoURL:t.callerPhoto},callType:t.type||"audio",existingCallId:t.id}),n(null))},o=async()=>{if(t){try{await Hn(ot(pe,"calls",t.id),{status:"rejected"})}catch{}n(null)}};return s.jsxs(s.Fragment,{children:[s.jsx(ar,{children:t&&s.jsx("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 z-50 w-full max-w-sm px-3 pointer-events-auto",children:s.jsxs(Kt.div,{initial:{opacity:0,y:-40,scale:.9},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-40,scale:.9},className:"bg-neutral-900/95 text-white border border-neutral-700/80 rounded-2xl p-3.5 shadow-2xl backdrop-blur-xl flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("img",{src:t.callerPhoto||`https://api.dicebear.com/7.x/bottts/svg?seed=${t.callerName}`,alt:"",className:"w-11 h-11 rounded-full object-cover border-2 border-emerald-500 shadow-md"}),s.jsx("span",{className:"absolute -inset-1 rounded-full border border-emerald-400 animate-ping opacity-60"})]}),s.jsxs("div",{className:"min-w-0 text-left",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("h4",{className:"text-sm font-black text-white truncate",children:t.callerName}),s.jsx("span",{className:"px-1.5 py-0.2 bg-emerald-500/20 text-emerald-400 border border-emerald-500/30 text-[8px] font-black uppercase rounded-full shrink-0",children:"Ringing"})]}),s.jsxs("p",{className:"text-[10px] text-neutral-300 font-medium truncate flex items-center gap-1",children:[t.type==="video"?s.jsx(Aa,{size:10,className:"text-blue-400"}):s.jsx(wk,{size:10,className:"text-emerald-400"}),s.jsxs("span",{children:["Incoming ",t.type==="video"?"FaceTime Video":"Audio"," Call"]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("button",{onClick:o,className:"p-2.5 bg-red-600 hover:bg-red-700 text-white rounded-full transition-all cursor-pointer shadow-md active:scale-90",title:"Decline Call",children:s.jsx(lF,{size:16})}),s.jsx("button",{onClick:a,className:"p-2.5 bg-emerald-500 hover:bg-emerald-600 text-white rounded-full transition-all cursor-pointer shadow-md active:scale-90 animate-bounce",title:"Accept Call",children:s.jsx(wk,{size:16})})]})]})})}),r&&s.jsx(Tee,{isOpen:!0,onClose:()=>i(null),peer:r.peer,callType:r.callType,isIncoming:!0,existingCallId:r.existingCallId})]})},KMe=({page:e,onClose:t})=>{const n=f=>{if(!f)return"";let m=f.trim();return/^https?:\/\//i.test(m)||(m="https://"+m),m},r=f=>{if(!f)return"";try{const m=f.trim();if(m.includes("youtube.com/watch")){const y=/[?&]v=([^&#]*)/,w=m.match(y);if(w&&w[1])return`https://www.youtube.com/embed/${w[1]}?autoplay=1&mute=0&rel=0`}else if(m.includes("youtu.be/")){const y=m.split("youtu.be/");if(y[1])return`https://www.youtube.com/embed/${y[1].split(/[?#&]/)[0]}?autoplay=1&mute=0&rel=0`}else if(m.includes("youtube.com/live/")){const y=m.split("youtube.com/live/");if(y[1])return`https://www.youtube.com/embed/${y[1].split(/[?#&]/)[0]}?autoplay=1&mute=0&rel=0`}else if(m.includes("/shorts/")){const y=m.split("/shorts/");if(y[1])return`https://www.youtube.com/embed/${y[1].split(/[?#&]/)[0]}?autoplay=1&mute=0&rel=0`}else{if(m.includes("youtube.com/embed/"))return m;if(m.includes("youtube-nocookie.com/embed/"))return m}return m}catch{return f}},i=n(e.url),a=r(i),[o,c]=se.useState(0),h=()=>{c(f=>f+1)};return s.jsxs("div",{className:"fixed inset-0 z-[10000] flex flex-col bg-zinc-950 overflow-hidden select-none",id:"custom-media-theater-root",children:[s.jsxs("div",{className:"bg-zinc-900 border-b border-zinc-800 px-4 py-3 flex items-center justify-between text-white shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-red-600 shrink-0"}),s.jsx("div",{className:"truncate",children:s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-white",children:e.name||"Live Channel"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:h,className:"p-2 rounded-lg bg-zinc-800 hover:bg-zinc-700 text-zinc-300 transition-colors cursor-pointer flex items-center justify-center",title:"Reload Frame",children:s.jsx(rie,{size:14})}),s.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg bg-zinc-800 hover:bg-zinc-700 text-zinc-300 transition-colors flex items-center justify-center",title:"Open in native browser tab",children:s.jsx(Va,{size:14})}),s.jsx("button",{onClick:t,className:"p-2 rounded-lg bg-red-600 hover:bg-red-700 text-white cursor-pointer flex items-center justify-center transition-all duration-200",title:"Close Channels",children:s.jsx(er,{size:14,strokeWidth:2.5})})]})]}),s.jsx("div",{className:"flex-1 bg-black relative",children:s.jsx("iframe",{src:a||void 0,className:"w-full h-full border-0 block bg-black",title:e.name,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; camera; microphone; geolocation",allowFullScreen:!0,referrerPolicy:"strict-origin-when-cross-origin"},o)})]})};var kn;(function(e){e[e.QR_CODE=0]="QR_CODE",e[e.AZTEC=1]="AZTEC",e[e.CODABAR=2]="CODABAR",e[e.CODE_39=3]="CODE_39",e[e.CODE_93=4]="CODE_93",e[e.CODE_128=5]="CODE_128",e[e.DATA_MATRIX=6]="DATA_MATRIX",e[e.MAXICODE=7]="MAXICODE",e[e.ITF=8]="ITF",e[e.EAN_13=9]="EAN_13",e[e.EAN_8=10]="EAN_8",e[e.PDF_417=11]="PDF_417",e[e.RSS_14=12]="RSS_14",e[e.RSS_EXPANDED=13]="RSS_EXPANDED",e[e.UPC_A=14]="UPC_A",e[e.UPC_E=15]="UPC_E",e[e.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(kn||(kn={}));var DV=new Map([[kn.QR_CODE,"QR_CODE"],[kn.AZTEC,"AZTEC"],[kn.CODABAR,"CODABAR"],[kn.CODE_39,"CODE_39"],[kn.CODE_93,"CODE_93"],[kn.CODE_128,"CODE_128"],[kn.DATA_MATRIX,"DATA_MATRIX"],[kn.MAXICODE,"MAXICODE"],[kn.ITF,"ITF"],[kn.EAN_13,"EAN_13"],[kn.EAN_8,"EAN_8"],[kn.PDF_417,"PDF_417"],[kn.RSS_14,"RSS_14"],[kn.RSS_EXPANDED,"RSS_EXPANDED"],[kn.UPC_A,"UPC_A"],[kn.UPC_E,"UPC_E"],[kn.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]),MV;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.URL=1]="URL"})(MV||(MV={}));function YMe(e){return Object.values(kn).includes(e)}var _N;(function(e){e[e.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",e[e.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"})(_N||(_N={}));var XMe=(function(){function e(){}return e.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",e.SCAN_DEFAULT_FPS=2,e.DEFAULT_DISABLE_FLIP=!1,e.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,e.DEFAULT_SUPPORTED_SCAN_TYPE=[_N.SCAN_TYPE_CAMERA,_N.SCAN_TYPE_FILE],e})(),Pee=(function(){function e(t,n){this.format=t,this.formatName=n}return e.prototype.toString=function(){return this.formatName},e.create=function(t){if(!DV.has(t))throw"".concat(t," not in html5QrcodeSupportedFormatsTextMap");return new e(t,DV.get(t))},e})(),LV=(function(){function e(){}return e.createFromText=function(t){var n={text:t};return{decodedText:t,result:n}},e.createFromQrcodeResult=function(t){return{decodedText:t.text,result:t}},e})(),ZI;(function(e){e[e.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",e[e.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",e[e.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"})(ZI||(ZI={}));var QMe=(function(){function e(){}return e.createFrom=function(t){return{errorMessage:t,type:ZI.UNKWOWN_ERROR}},e})(),ZMe=(function(){function e(t){this.verbose=t}return e.prototype.log=function(t){this.verbose&&console.log(t)},e.prototype.warn=function(t){this.verbose&&console.warn(t)},e.prototype.logError=function(t,n){(this.verbose||n===!0)&&console.error(t)},e.prototype.logErrors=function(t){if(t.length===0)throw"Logger#logError called without arguments";this.verbose&&console.error(t)},e})();function Nd(e){return typeof e>"u"||e===null}var O0=(function(){function e(){}return e.codeParseError=function(t){return"QR code parse error, error = ".concat(t)},e.errorGettingUserMedia=function(t){return"Error getting userMedia, error = ".concat(t)},e.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},e.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},e.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},e.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},e.scannerPaused=function(){return"Scanner paused"},e})(),Ree=(function(){function e(){}return e.isMediaStreamConstraintsValid=function(t,n){if(typeof t!="object"){var r=typeof t;return n.logError("videoConstraints should be of type object, the "+"object passed is of type ".concat(r,"."),!0),!1}for(var i=["autoGainControl","channelCount","echoCancellation","latency","noiseSuppression","sampleRate","sampleSize","volume"],a=new Set(i),o=Object.keys(t),c=0,h=o;cg)throw new y("fromIndex("+p+") > toIndex("+g+")");if(p<0)throw new D(p);if(g>u)throw new D(g)}static asList(...u){return u}static create(u,p,g){return Array.from({length:u}).map(v=>Array.from({length:p}).fill(g))}static createInt32Array(u,p,g){return Array.from({length:u}).map(v=>Int32Array.from({length:p}).fill(g))}static equals(u,p){if(!u||!p||!u.length||!p.length||u.length!==p.length)return!1;for(let g=0,b=u.length;g>1,S=g(p,u[E]);if(S>0)b=E+1;else if(S<0)v=E-1;else return E}return-b-1}static numberComparator(u,p){return u-p}}class L{static numberOfTrailingZeros(u){let p;if(u===0)return 32;let g=31;return p=u<<16,p!==0&&(g-=16,u=p),p=u<<8,p!==0&&(g-=8,u=p),p=u<<4,p!==0&&(g-=4,u=p),p=u<<2,p!==0&&(g-=2,u=p),g-(u<<1>>>31)}static numberOfLeadingZeros(u){if(u===0)return 32;let p=1;return u>>>16||(p+=16,u<<=16),u>>>24||(p+=8,u<<=8),u>>>28||(p+=4,u<<=4),u>>>30||(p+=2,u<<=2),p-=u>>>31,p}static toHexString(u){return u.toString(16)}static toBinaryString(u){return String(parseInt(String(u),2))}static bitCount(u){return u=u-(u>>>1&1431655765),u=(u&858993459)+(u>>>2&858993459),u=u+(u>>>4)&252645135,u=u+(u>>>8),u=u+(u>>>16),u&63}static truncDivision(u,p){return Math.trunc(u/p)}static parseInt(u,p=void 0){return parseInt(u,p)}}L.MIN_VALUE_32_BITS=-2147483648,L.MAX_VALUE=Number.MAX_SAFE_INTEGER;class q{constructor(u,p){u===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=u,p==null?this.bits=q.makeArray(u):this.bits=p)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(u){if(u>this.bits.length*32){const p=q.makeArray(u);I.arraycopy(this.bits,0,p,0,this.bits.length),this.bits=p}}get(u){return(this.bits[Math.floor(u/32)]&1<<(u&31))!==0}set(u){this.bits[Math.floor(u/32)]|=1<<(u&31)}flip(u){this.bits[Math.floor(u/32)]^=1<<(u&31)}getNextSet(u){const p=this.size;if(u>=p)return p;const g=this.bits;let b=Math.floor(u/32),v=g[b];v&=~((1<<(u&31))-1);const E=g.length;for(;v===0;){if(++b===E)return p;v=g[b]}const S=b*32+L.numberOfTrailingZeros(v);return S>p?p:S}getNextUnset(u){const p=this.size;if(u>=p)return p;const g=this.bits;let b=Math.floor(u/32),v=~g[b];v&=~((1<<(u&31))-1);const E=g.length;for(;v===0;){if(++b===E)return p;v=~g[b]}const S=b*32+L.numberOfTrailingZeros(v);return S>p?p:S}setBulk(u,p){this.bits[Math.floor(u/32)]=p}setRange(u,p){if(pthis.size)throw new y;if(p===u)return;p--;const g=Math.floor(u/32),b=Math.floor(p/32),v=this.bits;for(let E=g;E<=b;E++){const S=E>g?0:u&31,M=(2<<(Ethis.size)throw new y;if(p===u)return!0;p--;const b=Math.floor(u/32),v=Math.floor(p/32),E=this.bits;for(let S=b;S<=v;S++){const O=S>b?0:u&31,W=(2<<(S32)throw new y("Num bits must be between 0 and 32");this.ensureCapacity(this.size+p);for(let g=p;g>0;g--)this.appendBit((u>>g-1&1)===1)}appendBitArray(u){const p=u.size;this.ensureCapacity(this.size+p);for(let g=0;g>1&1431655765|(E&1431655765)<<1,E=E>>2&858993459|(E&858993459)<<2,E=E>>4&252645135|(E&252645135)<<4,E=E>>8&16711935|(E&16711935)<<8,E=E>>16&65535|(E&65535)<<16,u[p-v]=E}if(this.size!==g*32){const v=g*32-this.size;let E=u[0]>>>v;for(let S=1;S>>v}u[g-1]=E}this.bits=u}static makeArray(u){return new Int32Array(Math.floor((u+31)/32))}equals(u){if(!(u instanceof q))return!1;const p=u;return this.size===p.size&&F.equals(this.bits,p.bits)}hashCode(){return 31*this.size+F.hashCode(this.bits)}toString(){let u="";for(let p=0,g=this.size;p=900)throw new z("incorect value");const p=V.VALUES_TO_ECI.get(u);if(p===void 0)throw new z("incorect value");return p}static getCharacterSetECIByName(u){const p=V.NAME_TO_ECI.get(u);if(p===void 0)throw new z("incorect value");return p}equals(u){if(!(u instanceof V))return!1;const p=u;return this.getName()===p.getName()}}V.VALUE_IDENTIFIER_TO_ECI=new Map,V.VALUES_TO_ECI=new Map,V.NAME_TO_ECI=new Map,V.Cp437=new V(B.Cp437,Int32Array.from([0,2]),"Cp437"),V.ISO8859_1=new V(B.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),V.ISO8859_2=new V(B.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),V.ISO8859_3=new V(B.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),V.ISO8859_4=new V(B.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),V.ISO8859_5=new V(B.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),V.ISO8859_6=new V(B.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),V.ISO8859_7=new V(B.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),V.ISO8859_8=new V(B.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),V.ISO8859_9=new V(B.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),V.ISO8859_10=new V(B.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),V.ISO8859_11=new V(B.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),V.ISO8859_13=new V(B.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),V.ISO8859_14=new V(B.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),V.ISO8859_15=new V(B.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),V.ISO8859_16=new V(B.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),V.SJIS=new V(B.SJIS,20,"SJIS","Shift_JIS"),V.Cp1250=new V(B.Cp1250,21,"Cp1250","windows-1250"),V.Cp1251=new V(B.Cp1251,22,"Cp1251","windows-1251"),V.Cp1252=new V(B.Cp1252,23,"Cp1252","windows-1252"),V.Cp1256=new V(B.Cp1256,24,"Cp1256","windows-1256"),V.UnicodeBigUnmarked=new V(B.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),V.UTF8=new V(B.UTF8,26,"UTF8","UTF-8"),V.ASCII=new V(B.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),V.Big5=new V(B.Big5,28,"Big5"),V.GB18030=new V(B.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),V.EUC_KR=new V(B.EUC_KR,30,"EUC_KR","EUC-KR");class $ extends f{}$.kind="UnsupportedOperationException";class Q{static decode(u,p){const g=this.encodingName(p);return this.customDecoder?this.customDecoder(u,g):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(g)?this.decodeFallback(u,g):new TextDecoder(g).decode(u)}static shouldDecodeOnFallback(u){return!Q.isBrowser()&&u==="ISO-8859-1"}static encode(u,p){const g=this.encodingName(p);return this.customEncoder?this.customEncoder(u,g):typeof TextEncoder>"u"?this.encodeFallback(u):new TextEncoder().encode(u)}static isBrowser(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"}static encodingName(u){return typeof u=="string"?u:u.getName()}static encodingCharacterSet(u){return u instanceof V?u:V.getCharacterSetECIByName(u)}static decodeFallback(u,p){const g=this.encodingCharacterSet(p);if(Q.isDecodeFallbackSupported(g)){let b="";for(let v=0,E=u.length;v3&&u[0]===239&&u[1]===187&&u[2]===191;for(let $t=0;$t0?(Rt&128)===0?E=!1:S--:(Rt&128)!==0&&((Rt&64)===0?E=!1:(S++,(Rt&32)===0?O++:(S++,(Rt&16)===0?M++:(S++,(Rt&8)===0?W++:E=!1))))),b&&(Rt>127&&Rt<160?b=!1:Rt>159&&(Rt<192||Rt===215||Rt===247)&&ct++),v&&(ne>0?Rt<64||Rt===127||Rt>252?v=!1:ne--:Rt===128||Rt===160||Rt>239?v=!1:Rt>160&&Rt<224?(oe++,_e=0,ye++,ye>Ie&&(Ie=ye)):Rt>127?(ne++,ye=0,_e++,_e>Ke&&(Ke=_e)):(ye=0,_e=0))}return E&&S>0&&(E=!1),v&&ne>0&&(v=!1),E&&(Gt||O+M+W>0)?Y.UTF8:v&&(Y.ASSUME_SHIFT_JIS||Ie>=3||Ke>=3)?Y.SHIFT_JIS:b&&v?Ie===2&&oe===2||ct*10>=g?Y.SHIFT_JIS:Y.ISO88591:b?Y.ISO88591:v?Y.SHIFT_JIS:E?Y.UTF8:Y.PLATFORM_DEFAULT_ENCODING}static format(u,...p){let g=-1;function b(E,S,O,M,W,ne){if(E==="%%")return"%";if(p[++g]===void 0)return;E=M?parseInt(M.substr(1)):void 0;let oe=W?parseInt(W.substr(1)):void 0,ye;switch(ne){case"s":ye=p[g];break;case"c":ye=p[g][0];break;case"f":ye=parseFloat(p[g]).toFixed(E);break;case"p":ye=parseFloat(p[g]).toPrecision(E);break;case"e":ye=parseFloat(p[g]).toExponential(E);break;case"x":ye=parseInt(p[g]).toString(oe||16);break;case"d":ye=parseFloat(parseInt(p[g],oe||10).toPrecision(E)).toFixed(0);break}ye=typeof ye=="object"?JSON.stringify(ye):(+ye).toString(oe);let _e=parseInt(O),Ie=O&&O[0]+""=="0"?"0":" ";for(;ye.length<_e;)ye=S!==void 0?ye+Ie:Ie+ye;return ye}let v=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return u.replace(v,b)}static getBytes(u,p){return Q.encode(u,p)}static getCharCode(u,p=0){return u.charCodeAt(p)}static getCharAt(u){return String.fromCharCode(u)}}Y.SHIFT_JIS=V.SJIS.getName(),Y.GB2312="GB2312",Y.ISO88591=V.ISO8859_1.getName(),Y.EUC_JP="EUC_JP",Y.UTF8=V.UTF8.getName(),Y.PLATFORM_DEFAULT_ENCODING=Y.UTF8,Y.ASSUME_SHIFT_JIS=!1;class G{constructor(u=""){this.value=u}enableDecoding(u){return this.encoding=u,this}append(u){return typeof u=="string"?this.value+=u.toString():this.encoding?this.value+=Y.castAsNonUtf8Char(u,this.encoding):this.value+=String.fromCharCode(u),this}appendChars(u,p,g){for(let b=p;pE){if(S===-1)S=v-E;else if(v-E!==S)throw new y("row lengths do not match");E=v,O++}M++}else if(u.substring(M,M+p.length)===p)M+=p.length,b[v]=!0,v++;else if(u.substring(M,M+g.length)===g)M+=g.length,b[v]=!1,v++;else throw new y("illegal character encountered: "+u.substring(M));if(v>E){if(S===-1)S=v-E;else if(v-E!==S)throw new y("row lengths do not match");O++}const W=new he(S,O);for(let ne=0;ne>>(u&31)&1)!==0}set(u,p){const g=p*this.rowSize+Math.floor(u/32);this.bits[g]|=1<<(u&31)&4294967295}unset(u,p){const g=p*this.rowSize+Math.floor(u/32);this.bits[g]&=~(1<<(u&31)&4294967295)}flip(u,p){const g=p*this.rowSize+Math.floor(u/32);this.bits[g]^=1<<(u&31)&4294967295}xor(u){if(this.width!==u.getWidth()||this.height!==u.getHeight()||this.rowSize!==u.getRowSize())throw new y("input matrix dimensions do not match");const p=new q(Math.floor(this.width/32)+1),g=this.rowSize,b=this.bits;for(let v=0,E=this.height;vthis.height||v>this.width)throw new y("The region must fit inside the matrix");const S=this.rowSize,O=this.bits;for(let M=p;MO&&(O=M),W*32S){let oe=31;for(;!(ne>>>oe);)oe--;W*32+oe>S&&(S=W*32+oe)}}}return S=0&&p[g]===0;)g--;if(g<0)return null;const b=Math.floor(g/u);let v=Math.floor(g%u)*32;const E=p[g];let S=31;for(;!(E>>>S);)S--;return v+=S,Int32Array.from([v,b])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(u){if(!(u instanceof he))return!1;const p=u;return this.width===p.width&&this.height===p.height&&this.rowSize===p.rowSize&&F.equals(this.bits,p.bits)}hashCode(){let u=this.width;return u=31*u+this.width,u=31*u+this.height,u=31*u+this.rowSize,u=31*u+F.hashCode(this.bits),u}toString(u="X ",p=" ",g=` `){return this.buildToString(u,p,g)}buildToString(u,p,g){let b=new G;for(let v=0,E=this.height;v>le.LUMINANCE_SHIFT]++;const S=le.estimateBlackPoint(E);if(b<3)for(let O=0;O>le.LUMINANCE_SHIFT]++}}const E=le.estimateBlackPoint(v),S=u.getMatrix();for(let O=0;Ov&&(b=W,v=u[W]),u[W]>g&&(g=u[W]);let E=0,S=0;for(let W=0;WS&&(E=W,S=oe)}if(b>E){const W=b;b=E,E=W}if(E-b<=p/16)throw new te;let O=E-1,M=-1;for(let W=E-1;W>b;W--){const ne=W-b,oe=ne*ne*(E-W)*(g-u[W]);oe>M&&(O=W,M=oe)}return O<=ve.MINIMUM_DIMENSION&&g>=ve.MINIMUM_DIMENSION){const b=u.getMatrix();let v=p>>ve.BLOCK_SIZE_POWER;(p&ve.BLOCK_SIZE_MASK)!==0&&v++;let E=g>>ve.BLOCK_SIZE_POWER;(g&ve.BLOCK_SIZE_MASK)!==0&&E++;const S=ve.calculateBlackPoints(b,v,E,p,g),O=new he(p,g);ve.calculateThresholdForBlock(b,v,E,p,g,S,O),this.matrix=O}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(u){return new ve(u)}static calculateThresholdForBlock(u,p,g,b,v,E,S){const O=v-ve.BLOCK_SIZE,M=b-ve.BLOCK_SIZE;for(let W=0;WO&&(ne=O);const oe=ve.cap(W,2,g-3);for(let ye=0;yeM&&(_e=M);const Ie=ve.cap(ye,2,p-3);let Ke=0;for(let Gt=-2;Gt<=2;Gt++){const $t=E[oe+Gt];Ke+=$t[Ie-2]+$t[Ie-1]+$t[Ie]+$t[Ie+1]+$t[Ie+2]}const ct=Ke/25;ve.thresholdBlock(u,_e,ne,ct,b,S)}}}static cap(u,p,g){return ug?g:u}static thresholdBlock(u,p,g,b,v,E){for(let S=0,O=g*v+p;SE&&(W=E);for(let ne=0;neS&&(oe=S);let ye=0,_e=255,Ie=0;for(let ct=0,Gt=W*b+oe;ctIe&&(Ie=Rt)}if(Ie-_e>ve.MIN_DYNAMIC_RANGE)for(ct++,Gt+=b;ct>ve.BLOCK_SIZE_POWER*2;if(Ie-_e<=ve.MIN_DYNAMIC_RANGE&&(Ke=_e/2,M>0&&ne>0)){const ct=(O[M-1][ne]+2*O[M][ne-1]+O[M-1][ne-1])/4;_e>10}b[E]=O}return b}getRow(u,p){if(u<0||u>=this.getHeight())throw new y("Requested row is outside the image: "+u);const g=this.getWidth(),b=u*g;return p===null?p=this.buffer.slice(b,b+g):(p.lengthnew ie(p.deviceId,p.label))})}findDeviceById(u){return xe(this,void 0,void 0,function*(){const p=yield this.listVideoInputDevices();return p?p.find(g=>g.deviceId===u):null})}decodeFromInputVideoDevice(u,p){return xe(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(u,p)})}decodeOnceFromVideoDevice(u,p){return xe(this,void 0,void 0,function*(){this.reset();let g;u?g={deviceId:{exact:u}}:g={facingMode:"environment"};const b={video:g};return yield this.decodeOnceFromConstraints(b,p)})}decodeOnceFromConstraints(u,p){return xe(this,void 0,void 0,function*(){const g=yield navigator.mediaDevices.getUserMedia(u);return yield this.decodeOnceFromStream(g,p)})}decodeOnceFromStream(u,p){return xe(this,void 0,void 0,function*(){this.reset();const g=yield this.attachStreamToVideo(u,p);return yield this.decodeOnce(g)})}decodeFromInputVideoDeviceContinuously(u,p,g){return xe(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(u,p,g)})}decodeFromVideoDevice(u,p,g){return xe(this,void 0,void 0,function*(){let b;u?b={deviceId:{exact:u}}:b={facingMode:"environment"};const v={video:b};return yield this.decodeFromConstraints(v,p,g)})}decodeFromConstraints(u,p,g){return xe(this,void 0,void 0,function*(){const b=yield navigator.mediaDevices.getUserMedia(u);return yield this.decodeFromStream(b,p,g)})}decodeFromStream(u,p,g){return xe(this,void 0,void 0,function*(){this.reset();const b=yield this.attachStreamToVideo(u,p);return yield this.decodeContinuously(b,g)})}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(u,p){return xe(this,void 0,void 0,function*(){const g=this.prepareVideoElement(p);return this.addVideoSource(g,u),this.videoElement=g,this.stream=u,yield this.playVideoOnLoadAsync(g),g})}playVideoOnLoadAsync(u){return new Promise((p,g)=>this.playVideoOnLoad(u,()=>p()))}playVideoOnLoad(u,p){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(u),u.addEventListener("ended",this.videoEndedListener),u.addEventListener("canplay",this.videoCanPlayListener),u.addEventListener("playing",p),this.tryPlayVideo(u)}isVideoPlaying(u){return u.currentTime>0&&!u.paused&&!u.ended&&u.readyState>2}tryPlayVideo(u){return xe(this,void 0,void 0,function*(){if(this.isVideoPlaying(u)){console.warn("Trying to play video that is already playing.");return}try{yield u.play()}catch{console.warn("It was not possible to play the video.")}})}getMediaElement(u,p){const g=document.getElementById(u);if(!g)throw new m(`element with id '${u}' not found`);if(g.nodeName.toLowerCase()!==p.toLowerCase())throw new m(`element with id '${u}' must be an ${p} element`);return g}decodeFromImage(u,p){if(!u&&!p)throw new m("either imageElement with a src set or an url must be provided");return p&&!u?this.decodeFromImageUrl(p):this.decodeFromImageElement(u)}decodeFromVideo(u,p){if(!u&&!p)throw new m("Either an element with a src set or an URL must be provided");return p&&!u?this.decodeFromVideoUrl(p):this.decodeFromVideoElement(u)}decodeFromVideoContinuously(u,p,g){if(u===void 0&&p===void 0)throw new m("Either an element with a src set or an URL must be provided");return p&&!u?this.decodeFromVideoUrlContinuously(p,g):this.decodeFromVideoElementContinuously(u,g)}decodeFromImageElement(u){if(!u)throw new m("An image element must be provided.");this.reset();const p=this.prepareImageElement(u);this.imageElement=p;let g;return this.isImageLoaded(p)?g=this.decodeOnce(p,!1,!0):g=this._decodeOnLoadImage(p),g}decodeFromVideoElement(u){const p=this._decodeFromVideoElementSetup(u);return this._decodeOnLoadVideo(p)}decodeFromVideoElementContinuously(u,p){const g=this._decodeFromVideoElementSetup(u);return this._decodeOnLoadVideoContinuously(g,p)}_decodeFromVideoElementSetup(u){if(!u)throw new m("A video element must be provided.");this.reset();const p=this.prepareVideoElement(u);return this.videoElement=p,p}decodeFromImageUrl(u){if(!u)throw new m("An URL must be provided.");this.reset();const p=this.prepareImageElement();this.imageElement=p;const g=this._decodeOnLoadImage(p);return p.src=u,g}decodeFromVideoUrl(u){if(!u)throw new m("An URL must be provided.");this.reset();const p=this.prepareVideoElement(),g=this.decodeFromVideoElement(p);return p.src=u,g}decodeFromVideoUrlContinuously(u,p){if(!u)throw new m("An URL must be provided.");this.reset();const g=this.prepareVideoElement(),b=this.decodeFromVideoElementContinuously(g,p);return g.src=u,b}_decodeOnLoadImage(u){return new Promise((p,g)=>{this.imageLoadedListener=()=>this.decodeOnce(u,!1,!0).then(p,g),u.addEventListener("load",this.imageLoadedListener)})}_decodeOnLoadVideo(u){return xe(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(u),yield this.decodeOnce(u)})}_decodeOnLoadVideoContinuously(u,p){return xe(this,void 0,void 0,function*(){yield this.playVideoOnLoadAsync(u),this.decodeContinuously(u,p)})}isImageLoaded(u){return!(!u.complete||u.naturalWidth===0)}prepareImageElement(u){let p;return typeof u>"u"&&(p=document.createElement("img"),p.width=200,p.height=200),typeof u=="string"&&(p=this.getMediaElement(u,"img")),u instanceof HTMLImageElement&&(p=u),p}prepareVideoElement(u){let p;return!u&&typeof document<"u"&&(p=document.createElement("video"),p.width=200,p.height=200),typeof u=="string"&&(p=this.getMediaElement(u,"video")),u instanceof HTMLVideoElement&&(p=u),p.setAttribute("autoplay","true"),p.setAttribute("muted","true"),p.setAttribute("playsinline","true"),p}decodeOnce(u,p=!0,g=!0){this._stopAsyncDecode=!1;const b=(v,E)=>{if(this._stopAsyncDecode){E(new te("Video stream has ended before any code could be detected.")),this._stopAsyncDecode=void 0;return}try{const S=this.decode(u);v(S)}catch(S){const O=p&&S instanceof te,W=(S instanceof A||S instanceof z)&&g;if(O||W)return setTimeout(b,this._timeBetweenDecodingAttempts,v,E);E(S)}};return new Promise((v,E)=>b(v,E))}decodeContinuously(u,p){this._stopContinuousDecode=!1;const g=()=>{if(this._stopContinuousDecode){this._stopContinuousDecode=void 0;return}try{const b=this.decode(u);p(b,null),setTimeout(g,this.timeBetweenScansMillis)}catch(b){p(null,b);const v=b instanceof A||b instanceof z,E=b instanceof te;(v||E)&&setTimeout(g,this._timeBetweenDecodingAttempts)}};g()}decode(u){const p=this.createBinaryBitmap(u);return this.decodeBitmap(p)}_isHTMLVideoElement(u){return u.videoWidth!==0}drawFrameOnCanvas(u,p,g){p||(p={sx:0,sy:0,sWidth:u.videoWidth,sHeight:u.videoHeight,dx:0,dy:0,dWidth:u.videoWidth,dHeight:u.videoHeight}),g||(g=this.captureCanvasContext),g.drawImage(u,p.sx,p.sy,p.sWidth,p.sHeight,p.dx,p.dy,p.dWidth,p.dHeight)}drawImageOnCanvas(u,p,g=this.captureCanvasContext){p||(p={sx:0,sy:0,sWidth:u.naturalWidth,sHeight:u.naturalHeight,dx:0,dy:0,dWidth:u.naturalWidth,dHeight:u.naturalHeight}),g||(g=this.captureCanvasContext),g.drawImage(u,p.sx,p.sy,p.sWidth,p.sHeight,p.dx,p.dy,p.dWidth,p.dHeight)}createBinaryBitmap(u){this.getCaptureCanvasContext(u),this._isHTMLVideoElement(u)?this.drawFrameOnCanvas(u):this.drawImageOnCanvas(u);const p=this.getCaptureCanvas(u),g=new J(p),b=new ve(g);return new w(b)}getCaptureCanvasContext(u){if(!this.captureCanvasContext){const g=this.getCaptureCanvas(u).getContext("2d");this.captureCanvasContext=g}return this.captureCanvasContext}getCaptureCanvas(u){if(!this.captureCanvas){const p=this.createCaptureCanvas(u);this.captureCanvas=p}return this.captureCanvas}decodeBitmap(u){return this.reader.decode(u,this._hints)}createCaptureCanvas(u){if(typeof document>"u")return this._destroyCaptureCanvas(),null;const p=document.createElement("canvas");let g,b;return typeof u<"u"&&(u instanceof HTMLVideoElement?(g=u.videoWidth,b=u.videoHeight):u instanceof HTMLImageElement&&(g=u.naturalWidth||u.width,b=u.naturalHeight||u.height)),p.style.width=g+"px",p.style.height=b+"px",p.width=g,p.height=b,p}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach(u=>u.stop()),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(typeof this.videoEndedListener<"u"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener<"u"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener<"u"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)}_destroyCaptureCanvas(){this.captureCanvasContext=void 0,this.captureCanvas=void 0}addVideoSource(u,p){try{u.srcObject=p}catch{u.src=URL.createObjectURL(p)}}cleanVideoSource(u){try{u.srcObject=null}catch{u.src=""}this.videoElement.removeAttribute("src")}}class Fe{constructor(u,p,g=p==null?0:8*p.length,b,v,E=I.currentTimeMillis()){this.text=u,this.rawBytes=p,this.numBits=g,this.resultPoints=b,this.format=v,this.timestamp=E,this.text=u,this.rawBytes=p,g==null?this.numBits=p==null?0:8*p.length:this.numBits=g,this.resultPoints=b,this.format=v,this.resultMetadata=null,E==null?this.timestamp=I.currentTimeMillis():this.timestamp=E}getText(){return this.text}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}getResultPoints(){return this.resultPoints}getBarcodeFormat(){return this.format}getResultMetadata(){return this.resultMetadata}putMetadata(u,p){this.resultMetadata===null&&(this.resultMetadata=new Map),this.resultMetadata.set(u,p)}putAllMetadata(u){u!==null&&(this.resultMetadata===null?this.resultMetadata=u:this.resultMetadata=new Map(u))}addResultPoints(u){const p=this.resultPoints;if(p===null)this.resultPoints=u;else if(u!==null&&u.length>0){const g=new Array(p.length+u.length);I.arraycopy(p,0,g,0,p.length),I.arraycopy(u,0,g,p.length,u.length),this.resultPoints=g}}getTimestamp(){return this.timestamp}toString(){return this.text}}var pt;(function(ee){ee[ee.AZTEC=0]="AZTEC",ee[ee.CODABAR=1]="CODABAR",ee[ee.CODE_39=2]="CODE_39",ee[ee.CODE_93=3]="CODE_93",ee[ee.CODE_128=4]="CODE_128",ee[ee.DATA_MATRIX=5]="DATA_MATRIX",ee[ee.EAN_8=6]="EAN_8",ee[ee.EAN_13=7]="EAN_13",ee[ee.ITF=8]="ITF",ee[ee.MAXICODE=9]="MAXICODE",ee[ee.PDF_417=10]="PDF_417",ee[ee.QR_CODE=11]="QR_CODE",ee[ee.RSS_14=12]="RSS_14",ee[ee.RSS_EXPANDED=13]="RSS_EXPANDED",ee[ee.UPC_A=14]="UPC_A",ee[ee.UPC_E=15]="UPC_E",ee[ee.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(pt||(pt={}));var Ue=pt,Ct;(function(ee){ee[ee.OTHER=0]="OTHER",ee[ee.ORIENTATION=1]="ORIENTATION",ee[ee.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",ee[ee.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",ee[ee.ISSUE_NUMBER=4]="ISSUE_NUMBER",ee[ee.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",ee[ee.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",ee[ee.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",ee[ee.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",ee[ee.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",ee[ee.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(Ct||(Ct={}));var Tt=Ct;class ht{constructor(u,p,g,b,v=-1,E=-1){this.rawBytes=u,this.text=p,this.byteSegments=g,this.ecLevel=b,this.structuredAppendSequenceNumber=v,this.structuredAppendParity=E,this.numBits=u==null?0:8*u.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(u){this.numBits=u}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(u){this.errorsCorrected=u}getErasures(){return this.erasures}setErasures(u){this.erasures=u}getOther(){return this.other}setOther(u){this.other=u}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class Ye{exp(u){return this.expTable[u]}log(u){if(u===0)throw new y;return this.logTable[u]}static addOrSubtract(u,p){return u^p}}class Yt{constructor(u,p){if(p.length===0)throw new y;this.field=u;const g=p.length;if(g>1&&p[0]===0){let b=1;for(;bg.length){const E=p;p=g,g=E}let b=new Int32Array(g.length);const v=g.length-p.length;I.arraycopy(g,0,b,0,v);for(let E=v;E=u.getDegree()&&!b.isZero();){const S=b.getDegree()-u.getDegree(),O=p.multiply(b.getCoefficient(b.getDegree()),E),M=u.multiplyByMonomial(S,O),W=p.buildMonomial(S,O);g=g.addOrSubtract(W),b=b.addOrSubtract(M)}return[g,b]}toString(){let u="";for(let p=this.getDegree();p>=0;p--){let g=this.getCoefficient(p);if(g!==0){if(g<0?(u+=" - ",g=-g):u.length>0&&(u+=" + "),p===0||g!==1){const b=this.field.log(g);b===0?u+="1":b===1?u+="a":(u+="a^",u+=b)}p!==0&&(p===1?u+="x":(u+="x^",u+=p))}}return u}}class dt extends f{}dt.kind="ArithmeticException";class sn extends Ye{constructor(u,p,g){super(),this.primitive=u,this.size=p,this.generatorBase=g;const b=new Int32Array(p);let v=1;for(let S=0;S=p&&(v^=u,v&=p-1);this.expTable=b;const E=new Int32Array(p);for(let S=0;S=(g/2|0);){let ye=v,_e=S;if(v=E,S=O,v.isZero())throw new pn("r_{i-1} was zero");E=ye;let Ie=b.getZero();const Ke=v.getCoefficient(v.getDegree()),ct=b.inverse(Ke);for(;E.getDegree()>=v.getDegree()&&!E.isZero();){const Gt=E.getDegree()-v.getDegree(),$t=b.multiply(E.getCoefficient(E.getDegree()),ct);Ie=Ie.addOrSubtract(b.buildMonomial(Gt,$t)),E=E.addOrSubtract(v.multiplyByMonomial(Gt,$t))}if(O=Ie.multiply(S).addOrSubtract(_e),E.getDegree()>=v.getDegree())throw new Fn("Division algorithm failed to reduce polynomial?")}const M=O.getCoefficient(0);if(M===0)throw new pn("sigmaTilde(0) was zero");const W=b.inverse(M),ne=O.multiplyScalar(W),oe=E.multiplyScalar(W);return[ne,oe]}findErrorLocations(u){const p=u.getDegree();if(p===1)return Int32Array.from([u.getCoefficient(1)]);const g=new Int32Array(p);let b=0;const v=this.field;for(let E=1;E1,ne,ne+g-1),ne+=g-1;else for(let _e=g-1;_e>=0;--_e)W[ne++]=(ye&1<<_e)!==0}return W}extractBits(u){let p=this.ddata.isCompact(),g=this.ddata.getNbLayers(),b=(p?11:14)+g*4,v=new Int32Array(b),E=new Array(this.totalBitsInLayer(g,p));if(p)for(let S=0;S=8?Ht.readCode(u,p,8):Ht.readCode(u,p,g)<<8-g}static convertBoolArrayToByteArray(u){let p=new Uint8Array((u.length+7)/8);for(let g=0;g","?","[","]","{","}","CTRL_UL"],Ht.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class Ze{constructor(){}static round(u){return u===NaN?0:u<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:u>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:u+(u<0?-.5:.5)|0}static distance(u,p,g,b){const v=u-g,E=p-b;return Math.sqrt(v*v+E*E)}static sum(u){let p=0;for(let g=0,b=u.length;g!==b;g++){const v=u[g];p+=v}return p}}class Wt{static floatToIntBits(u){return u}}Wt.MAX_VALUE=Number.MAX_SAFE_INTEGER;class It{constructor(u,p){this.x=u,this.y=p}getX(){return this.x}getY(){return this.y}equals(u){if(u instanceof It){const p=u;return this.x===p.x&&this.y===p.y}return!1}hashCode(){return 31*Wt.floatToIntBits(this.x)+Wt.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(u){const p=this.distance(u[0],u[1]),g=this.distance(u[1],u[2]),b=this.distance(u[0],u[2]);let v,E,S;if(g>=p&&g>=b?(E=u[0],v=u[1],S=u[2]):b>=g&&b>=p?(E=u[1],v=u[0],S=u[2]):(E=u[2],v=u[0],S=u[1]),this.crossProductZ(v,E,S)<0){const O=v;v=S,S=O}u[0]=v,u[1]=E,u[2]=S}static distance(u,p){return Ze.distance(u.x,u.y,p.x,p.y)}static crossProductZ(u,p,g){const b=p.x,v=p.y;return(g.x-b)*(u.y-v)-(g.y-v)*(u.x-b)}}class ln{constructor(u,p){this.bits=u,this.points=p}getBits(){return this.bits}getPoints(){return this.points}}class Kn extends ln{constructor(u,p,g,b,v){super(u,p),this.compact=g,this.nbDatablocks=b,this.nbLayers=v}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class un{constructor(u,p,g,b){this.image=u,this.height=u.getHeight(),this.width=u.getWidth(),p==null&&(p=un.INIT_SIZE),g==null&&(g=u.getWidth()/2|0),b==null&&(b=u.getHeight()/2|0);const v=p/2|0;if(this.leftInit=g-v,this.rightInit=g+v,this.upInit=b-v,this.downInit=b+v,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new te}detect(){let u=this.leftInit,p=this.rightInit,g=this.upInit,b=this.downInit,v=!1,E=!0,S=!1,O=!1,M=!1,W=!1,ne=!1;const oe=this.width,ye=this.height;for(;E;){E=!1;let _e=!0;for(;(_e||!O)&&p=oe){v=!0;break}let Ie=!0;for(;(Ie||!M)&&b=ye){v=!0;break}let Ke=!0;for(;(Ke||!W)&&u>=0;)Ke=this.containsBlackPoint(g,b,u,!1),Ke?(u--,E=!0,W=!0):W||u--;if(u<0){v=!0;break}let ct=!0;for(;(ct||!ne)&&g>=0;)ct=this.containsBlackPoint(u,p,g,!0),ct?(g--,E=!0,ne=!0):ne||g--;if(g<0){v=!0;break}E&&(S=!0)}if(!v&&S){const _e=p-u;let Ie=null;for(let $t=1;Ie===null&&$t<_e;$t++)Ie=this.getBlackPointOnSegment(u,b-$t,u+$t,b);if(Ie==null)throw new te;let Ke=null;for(let $t=1;Ke===null&&$t<_e;$t++)Ke=this.getBlackPointOnSegment(u,g+$t,u+$t,g);if(Ke==null)throw new te;let ct=null;for(let $t=1;ct===null&&$t<_e;$t++)ct=this.getBlackPointOnSegment(p,g+$t,p-$t,g);if(ct==null)throw new te;let Gt=null;for(let $t=1;Gt===null&&$t<_e;$t++)Gt=this.getBlackPointOnSegment(p,b-$t,p-$t,b);if(Gt==null)throw new te;return this.centerEdges(Gt,Ie,ct,Ke)}else throw new te}getBlackPointOnSegment(u,p,g,b){const v=Ze.round(Ze.distance(u,p,g,b)),E=(g-u)/v,S=(b-p)/v,O=this.image;for(let M=0;Mg||O<-1||O>b)throw new te;v=!1,S===-1?(p[E]=0,v=!0):S===g&&(p[E]=g-1,v=!0),O===-1?(p[E+1]=0,v=!0):O===b&&(p[E+1]=b-1,v=!0)}v=!0;for(let E=p.length-2;E>=0&&v;E-=2){const S=Math.floor(p[E]),O=Math.floor(p[E+1]);if(S<-1||S>g||O<-1||O>b)throw new te;v=!1,S===-1?(p[E]=0,v=!0):S===g&&(p[E]=g-1,v=!0),O===-1?(p[E+1]=0,v=!0):O===b&&(p[E+1]=b-1,v=!0)}}}class Ve{constructor(u,p,g,b,v,E,S,O,M){this.a11=u,this.a21=p,this.a31=g,this.a12=b,this.a22=v,this.a32=E,this.a13=S,this.a23=O,this.a33=M}static quadrilateralToQuadrilateral(u,p,g,b,v,E,S,O,M,W,ne,oe,ye,_e,Ie,Ke){const ct=Ve.quadrilateralToSquare(u,p,g,b,v,E,S,O);return Ve.squareToQuadrilateral(M,W,ne,oe,ye,_e,Ie,Ke).times(ct)}transformPoints(u){const p=u.length,g=this.a11,b=this.a12,v=this.a13,E=this.a21,S=this.a22,O=this.a23,M=this.a31,W=this.a32,ne=this.a33;for(let oe=0;oe>1&127):(b<<=10,b+=(S>>2&992)+(S>>1&31))}let v=this.getCorrectedParameterData(b,this.compact);this.compact?(this.nbLayers=(v>>6)+1,this.nbDataBlocks=(v&63)+1):(this.nbLayers=(v>>11)+1,this.nbDataBlocks=(v&2047)+1)}getRotation(u,p){let g=0;u.forEach((b,v,E)=>{let S=(b>>p-2<<1)+(b&1);g=(g<<3)+S}),g=((g&1)<<11)+(g>>1);for(let b=0;b<4;b++)if(L.bitCount(g^this.EXPECTED_CORNER_BITS[b])<=2)return b;throw new te}getCorrectedParameterData(u,p){let g,b;p?(g=7,b=2):(g=10,b=4);let v=g-b,E=new Int32Array(g);for(let O=g-1;O>=0;--O)E[O]=u&15,u>>=4;try{new Ft(sn.AZTEC_PARAM).decode(E,v)}catch{throw new te}let S=0;for(let O=0;O2){let Ie=this.distancePoint(_e,ne)*this.nbCenterLayers/(this.distancePoint(v,p)*(this.nbCenterLayers+2));if(Ie<.75||Ie>1.25||!this.isWhiteOrBlackRectangle(ne,oe,ye,_e))break}p=ne,g=oe,b=ye,v=_e,E=!E}if(this.nbCenterLayers!==5&&this.nbCenterLayers!==7)throw new te;this.compact=this.nbCenterLayers===5;let S=new It(p.getX()+.5,p.getY()-.5),O=new It(g.getX()+.5,g.getY()+.5),M=new It(b.getX()-.5,b.getY()+.5),W=new It(v.getX()-.5,v.getY()-.5);return this.expandSquare([S,O,M,W],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let u,p,g,b;try{let S=new un(this.image).detect();u=S[0],p=S[1],g=S[2],b=S[3]}catch{let O=this.image.getWidth()/2,M=this.image.getHeight()/2;u=this.getFirstDifferent(new mn(O+7,M-7),!1,1,-1).toResultPoint(),p=this.getFirstDifferent(new mn(O+7,M+7),!1,1,1).toResultPoint(),g=this.getFirstDifferent(new mn(O-7,M+7),!1,-1,1).toResultPoint(),b=this.getFirstDifferent(new mn(O-7,M-7),!1,-1,-1).toResultPoint()}let v=Ze.round((u.getX()+b.getX()+p.getX()+g.getX())/4),E=Ze.round((u.getY()+b.getY()+p.getY()+g.getY())/4);try{let S=new un(this.image,15,v,E).detect();u=S[0],p=S[1],g=S[2],b=S[3]}catch{u=this.getFirstDifferent(new mn(v+7,E-7),!1,1,-1).toResultPoint(),p=this.getFirstDifferent(new mn(v+7,E+7),!1,1,1).toResultPoint(),g=this.getFirstDifferent(new mn(v-7,E+7),!1,-1,1).toResultPoint(),b=this.getFirstDifferent(new mn(v-7,E-7),!1,-1,-1).toResultPoint()}return v=Ze.round((u.getX()+b.getX()+p.getX()+g.getX())/4),E=Ze.round((u.getY()+b.getY()+p.getY()+g.getY())/4),new mn(v,E)}getMatrixCornerPoints(u){return this.expandSquare(u,2*this.nbCenterLayers,this.getDimension())}sampleGrid(u,p,g,b,v){let E=nn.getInstance(),S=this.getDimension(),O=S/2-this.nbCenterLayers,M=S/2+this.nbCenterLayers;return E.sampleGrid(u,S,S,O,O,M,O,M,M,O,M,p.getX(),p.getY(),g.getX(),g.getY(),b.getX(),b.getY(),v.getX(),v.getY())}sampleLine(u,p,g){let b=0,v=this.distanceResultPoint(u,p),E=v/g,S=u.getX(),O=u.getY(),M=E*(p.getX()-u.getX())/v,W=E*(p.getY()-u.getY())/v;for(let ne=0;ne.1&&ne<.9?0:ne<=.1===M?1:-1}getFirstDifferent(u,p,g,b){let v=u.getX()+g,E=u.getY()+b;for(;this.isValid(v,E)&&this.image.get(v,E)===p;)v+=g,E+=b;for(v-=g,E-=b;this.isValid(v,E)&&this.image.get(v,E)===p;)v+=g;for(v-=g;this.isValid(v,E)&&this.image.get(v,E)===p;)E+=b;return E-=b,new mn(v,E)}expandSquare(u,p,g){let b=g/(2*p),v=u[0].getX()-u[2].getX(),E=u[0].getY()-u[2].getY(),S=(u[0].getX()+u[2].getX())/2,O=(u[0].getY()+u[2].getY())/2,M=new It(S+b*v,O+b*E),W=new It(S-b*v,O-b*E);v=u[1].getX()-u[3].getX(),E=u[1].getY()-u[3].getY(),S=(u[1].getX()+u[3].getX())/2,O=(u[1].getY()+u[3].getY())/2;let ne=new It(S+b*v,O+b*E),oe=new It(S-b*v,O-b*E);return[M,ne,W,oe]}isValid(u,p){return u>=0&&u0&&p{g.foundPossibleResultPoint(b)})}}reset(){}}class Ui extends ae{constructor(u=500){super(new hr,u)}}class $n{decode(u,p){try{return this.doDecode(u,p)}catch{if(p&&p.get(K.TRY_HARDER)===!0&&u.isRotateSupported()){const v=u.rotateCounterClockwise(),E=this.doDecode(v,p),S=E.getResultMetadata();let O=270;S!==null&&S.get(Tt.ORIENTATION)===!0&&(O=O+S.get(Tt.ORIENTATION)%360),E.putMetadata(Tt.ORIENTATION,O);const M=E.getResultPoints();if(M!==null){const W=v.getHeight();for(let ne=0;ne>(E?8:5));let O;E?O=b:O=15;const M=Math.trunc(b/2);for(let W=0;W=b)break;try{v=u.getBlackRow(ye,v)}catch{continue}for(let _e=0;_e<2;_e++){if(_e===1&&(v.reverse(),p&&p.get(K.NEED_RESULT_POINT_CALLBACK)===!0)){const Ie=new Map;p.forEach((Ke,ct)=>Ie.set(ct,Ke)),Ie.delete(K.NEED_RESULT_POINT_CALLBACK),p=Ie}try{const Ie=this.decodeRow(ye,v,p);if(_e===1){Ie.putMetadata(Tt.ORIENTATION,180);const Ke=Ie.getResultPoints();Ke!==null&&(Ke[0]=new It(g-Ke[0].getX()-1,Ke[0].getY()),Ke[1]=new It(g-Ke[1].getX()-1,Ke[1].getY()))}return Ie}catch{}}}throw new te}static recordPattern(u,p,g){const b=g.length;for(let M=0;M=v)throw new te;let E=!u.get(p),S=0,O=p;for(;O0&&b>=0;)u.get(--p)!==v&&(b--,v=!v);if(b>=0)throw new te;$n.recordPattern(u,p+1,g)}static patternMatchVariance(u,p,g){const b=u.length;let v=0,E=0;for(let M=0;Mne?W-ne:ne-W;if(oe>g)return Number.POSITIVE_INFINITY;O+=oe}return O/v}}class be extends $n{static findStartPattern(u){const p=u.getSize(),g=u.getNextSet(0);let b=0,v=Int32Array.from([0,0,0,0,0,0]),E=g,S=!1;const O=6;for(let M=g;M=0&&u.isRange(Math.max(0,E-(M-E)/2),E,!1))return Int32Array.from([E,M,ne]);E+=v[0]+v[1],v=v.slice(2,v.length-1),v[b-1]=0,v[b]=0,b--}else b++;v[b]=1,S=!S}throw new te}static decodeCode(u,p,g){$n.recordPattern(u,g,p);let b=be.MAX_AVG_VARIANCE,v=-1;for(let E=0;E=0)return v;throw new te}decodeRow(u,p,g){const b=g&&g.get(K.ASSUME_GS1)===!0,v=be.findStartPattern(p),E=v[2];let S=0;const O=new Uint8Array(20);O[S++]=E;let M;switch(E){case be.CODE_START_A:M=be.CODE_CODE_A;break;case be.CODE_START_B:M=be.CODE_CODE_B;break;case be.CODE_START_C:M=be.CODE_CODE_C;break;default:throw new z}let W=!1,ne=!1,oe="",ye=v[0],_e=v[1];const Ie=Int32Array.from([0,0,0,0,0,0]);let Ke=0,ct=0,Gt=E,$t=0,Rt=!0,Or=!1,yr=!1;for(;!W;){const xc=ne;switch(ne=!1,Ke=ct,ct=be.decodeCode(p,Ie,_e),O[S++]=ct,ct!==be.CODE_STOP&&(Rt=!0),ct!==be.CODE_STOP&&($t++,Gt+=$t*ct),ye=_e,_e+=Ie.reduce((Df,Mf)=>Df+Mf,0),ct){case be.CODE_START_A:case be.CODE_START_B:case be.CODE_START_C:throw new z}switch(M){case be.CODE_CODE_A:if(ct<64)yr===Or?oe+=String.fromCharCode(32+ct):oe+=String.fromCharCode(32+ct+128),yr=!1;else if(ct<96)yr===Or?oe+=String.fromCharCode(ct-64):oe+=String.fromCharCode(ct+64),yr=!1;else switch(ct!==be.CODE_STOP&&(Rt=!1),ct){case be.CODE_FNC_1:b&&(oe.length===0?oe+="]C1":oe+="");break;case be.CODE_FNC_2:case be.CODE_FNC_3:break;case be.CODE_FNC_4_A:!Or&&yr?(Or=!0,yr=!1):Or&&yr?(Or=!1,yr=!1):yr=!0;break;case be.CODE_SHIFT:ne=!0,M=be.CODE_CODE_B;break;case be.CODE_CODE_B:M=be.CODE_CODE_B;break;case be.CODE_CODE_C:M=be.CODE_CODE_C;break;case be.CODE_STOP:W=!0;break}break;case be.CODE_CODE_B:if(ct<96)yr===Or?oe+=String.fromCharCode(32+ct):oe+=String.fromCharCode(32+ct+128),yr=!1;else switch(ct!==be.CODE_STOP&&(Rt=!1),ct){case be.CODE_FNC_1:b&&(oe.length===0?oe+="]C1":oe+="");break;case be.CODE_FNC_2:case be.CODE_FNC_3:break;case be.CODE_FNC_4_B:!Or&&yr?(Or=!0,yr=!1):Or&&yr?(Or=!1,yr=!1):yr=!0;break;case be.CODE_SHIFT:ne=!0,M=be.CODE_CODE_A;break;case be.CODE_CODE_A:M=be.CODE_CODE_A;break;case be.CODE_CODE_C:M=be.CODE_CODE_C;break;case be.CODE_STOP:W=!0;break}break;case be.CODE_CODE_C:if(ct<100)ct<10&&(oe+="0"),oe+=ct;else switch(ct!==be.CODE_STOP&&(Rt=!1),ct){case be.CODE_FNC_1:b&&(oe.length===0?oe+="]C1":oe+="");break;case be.CODE_CODE_A:M=be.CODE_CODE_A;break;case be.CODE_CODE_B:M=be.CODE_CODE_B;break;case be.CODE_STOP:W=!0;break}break}xc&&(M=M===be.CODE_CODE_A?be.CODE_CODE_B:be.CODE_CODE_A)}const vs=_e-ye;if(_e=p.getNextUnset(_e),!p.isRange(_e,Math.min(p.getSize(),_e+(_e-ye)/2),!1))throw new te;if(Gt-=$t*Ke,Gt%103!==Ke)throw new A;const fo=oe.length;if(fo===0)throw new te;fo>0&&Rt&&(M===be.CODE_CODE_C?oe=oe.substring(0,fo-2):oe=oe.substring(0,fo-1));const sa=(v[1]+v[0])/2,vi=ye+vs/2,Qs=O.length,ya=new Uint8Array(Qs);for(let xc=0;xcg&&(v=O);g=v,b=0;let E=0,S=0;for(let O=0;Og&&(S|=1<0;O++){let M=u[O];if(M>g&&(b--,M*2>=E))return-1}return S}}while(b>3);return-1}static patternToChar(u){for(let p=0;p="A"&&E<="Z")S=String.fromCharCode(E.charCodeAt(0)+32);else throw new z;break;case"$":if(E>="A"&&E<="Z")S=String.fromCharCode(E.charCodeAt(0)-64);else throw new z;break;case"%":if(E>="A"&&E<="E")S=String.fromCharCode(E.charCodeAt(0)-38);else if(E>="F"&&E<="J")S=String.fromCharCode(E.charCodeAt(0)-11);else if(E>="K"&&E<="O")S=String.fromCharCode(E.charCodeAt(0)+16);else if(E>="P"&&E<="T")S=String.fromCharCode(E.charCodeAt(0)+43);else if(E==="U")S="\0";else if(E==="V")S="@";else if(E==="W")S="`";else if(E==="X"||E==="Y"||E==="Z")S="";else throw new z;break;case"/":if(E>="A"&&E<="O")S=String.fromCharCode(E.charCodeAt(0)-32);else if(E==="Z")S=":";else throw new z;break}g+=S,b++}else g+=v}return g}}je.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",je.CHARACTER_ENCODINGS=[52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,168,162,138,42],je.ASTERISK_ENCODING=148;class ze extends $n{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(u,p,g){let b=this.decodeStart(p),v=this.decodeEnd(p),E=new G;ze.decodeMiddle(p,b[1],v[0],E);let S=E.toString(),O=null;g!=null&&(O=g.get(K.ALLOWED_LENGTHS)),O==null&&(O=ze.DEFAULT_ALLOWED_LENGTHS);let M=S.length,W=!1,ne=0;for(let _e of O){if(M===_e){W=!0;break}_e>ne&&(ne=_e)}if(!W&&M>ne&&(W=!0),!W)throw new z;const oe=[new It(b[1],u),new It(v[0],u)];return new Fe(S,null,0,oe,Ue.ITF,new Date().getTime())}static decodeMiddle(u,p,g,b){let v=new Int32Array(10),E=new Int32Array(5),S=new Int32Array(5);for(v.fill(0),E.fill(0),S.fill(0);p0&&b>=0&&!u.get(b);b--)g--;if(g!==0)throw new te}static skipWhiteSpace(u){const p=u.getSize(),g=u.getNextSet(0);if(g===p)throw new te;return g}decodeEnd(u){u.reverse();try{let p=ze.skipWhiteSpace(u),g;try{g=ze.findGuardPattern(u,p,ze.END_PATTERN_REVERSED[0])}catch(v){v instanceof te&&(g=ze.findGuardPattern(u,p,ze.END_PATTERN_REVERSED[1]))}this.validateQuietZone(u,g[0]);let b=g[0];return g[0]=u.getSize()-g[1],g[1]=u.getSize()-b,g}finally{u.reverse()}}static findGuardPattern(u,p,g){let b=g.length,v=new Int32Array(b),E=u.getSize(),S=!1,O=0,M=p;v.fill(0);for(let W=p;W=0)return g%10;throw new te}}ze.PATTERNS=[Int32Array.from([1,1,2,2,1]),Int32Array.from([2,1,1,1,2]),Int32Array.from([1,2,1,1,2]),Int32Array.from([2,2,1,1,1]),Int32Array.from([1,1,2,1,2]),Int32Array.from([2,1,2,1,1]),Int32Array.from([1,2,2,1,1]),Int32Array.from([1,1,1,2,2]),Int32Array.from([2,1,1,2,1]),Int32Array.from([1,2,1,2,1]),Int32Array.from([1,1,3,3,1]),Int32Array.from([3,1,1,1,3]),Int32Array.from([1,3,1,1,3]),Int32Array.from([3,3,1,1,1]),Int32Array.from([1,1,3,1,3]),Int32Array.from([3,1,3,1,1]),Int32Array.from([1,3,3,1,1]),Int32Array.from([1,1,1,3,3]),Int32Array.from([3,1,1,3,1]),Int32Array.from([1,3,1,3,1])],ze.MAX_AVG_VARIANCE=.38,ze.MAX_INDIVIDUAL_VARIANCE=.5,ze.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],ze.START_PATTERN=Int32Array.from([1,1,1,1]),ze.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class tt extends $n{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(u){let p=!1,g,b=0,v=Int32Array.from([0,0,0]);for(;!p;){v=Int32Array.from([0,0,0]),g=tt.findGuardPattern(u,b,!1,this.START_END_PATTERN,v);let E=g[0];b=g[1];let S=E-(b-E);S>=0&&(p=u.isRange(S,E,!1))}return g}static checkChecksum(u){return tt.checkStandardUPCEANChecksum(u)}static checkStandardUPCEANChecksum(u){let p=u.length;if(p===0)return!1;let g=parseInt(u.charAt(p-1),10);return tt.getStandardUPCEANChecksum(u.substring(0,p-1))===g}static getStandardUPCEANChecksum(u){let p=u.length,g=0;for(let b=p-1;b>=0;b-=2){let v=u.charAt(b).charCodeAt(0)-48;if(v<0||v>9)throw new z;g+=v}g*=3;for(let b=p-2;b>=0;b-=2){let v=u.charAt(b).charCodeAt(0)-48;if(v<0||v>9)throw new z;g+=v}return(1e3-g)%10}static decodeEnd(u,p){return tt.findGuardPattern(u,p,!1,tt.START_END_PATTERN,new Int32Array(tt.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(u,p,g,b){return this.findGuardPattern(u,p,g,b,new Int32Array(b.length))}static findGuardPattern(u,p,g,b,v){let E=u.getSize();p=g?u.getNextUnset(p):u.getNextSet(p);let S=0,O=p,M=b.length,W=g;for(let ne=p;ne=0)return E;throw new te}}tt.MAX_AVG_VARIANCE=.48,tt.MAX_INDIVIDUAL_VARIANCE=.7,tt.START_END_PATTERN=Int32Array.from([1,1,1]),tt.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),tt.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),tt.L_PATTERNS=[Int32Array.from([3,2,1,1]),Int32Array.from([2,2,2,1]),Int32Array.from([2,1,2,2]),Int32Array.from([1,4,1,1]),Int32Array.from([1,1,3,2]),Int32Array.from([1,2,3,1]),Int32Array.from([1,1,1,4]),Int32Array.from([1,3,1,2]),Int32Array.from([1,2,1,3]),Int32Array.from([3,1,1,2])];class fn{constructor(){this.CHECK_DIGIT_ENCODINGS=[24,20,18,17,12,6,3,10,9,5],this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(u,p,g){let b=this.decodeRowStringBuffer,v=this.decodeMiddle(p,g,b),E=b.toString(),S=fn.parseExtensionString(E),O=[new It((g[0]+g[1])/2,u),new It(v,u)],M=new Fe(E,null,0,O,Ue.UPC_EAN_EXTENSION,new Date().getTime());return S!=null&&M.putAllMetadata(S),M}decodeMiddle(u,p,g){let b=this.decodeMiddleCounters;b[0]=0,b[1]=0,b[2]=0,b[3]=0;let v=u.getSize(),E=p[1],S=0;for(let M=0;M<5&&E=10&&(S|=1<<4-M),M!==4&&(E=u.getNextSet(E),E=u.getNextUnset(E))}if(g.length!==5)throw new te;let O=this.determineCheckDigit(S);if(fn.extensionChecksum(g.toString())!==O)throw new te;return E}static extensionChecksum(u){let p=u.length,g=0;for(let b=p-2;b>=0;b-=2)g+=u.charAt(b).charCodeAt(0)-48;g*=3;for(let b=p-1;b>=0;b-=2)g+=u.charAt(b).charCodeAt(0)-48;return g*=3,g%10}determineCheckDigit(u){for(let p=0;p<10;p++)if(u===this.CHECK_DIGIT_ENCODINGS[p])return p;throw new te}static parseExtensionString(u){if(u.length!==5)return null;let p=fn.parseExtension5String(u);return p==null?null:new Map([[Tt.SUGGESTED_PRICE,p]])}static parseExtension5String(u){let p;switch(u.charAt(0)){case"0":p="£";break;case"5":p="$";break;case"9":switch(u){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}p="";break;default:p="";break}let g=parseInt(u.substring(1)),b=(g/100).toString(),v=g%100,E=v<10?"0"+v:v.toString();return p+b+"."+E}}class Bt{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(u,p,g){let b=this.decodeRowStringBuffer,v=this.decodeMiddle(p,g,b),E=b.toString(),S=Bt.parseExtensionString(E),O=[new It((g[0]+g[1])/2,u),new It(v,u)],M=new Fe(E,null,0,O,Ue.UPC_EAN_EXTENSION,new Date().getTime());return S!=null&&M.putAllMetadata(S),M}decodeMiddle(u,p,g){let b=this.decodeMiddleCounters;b[0]=0,b[1]=0,b[2]=0,b[3]=0;let v=u.getSize(),E=p[1],S=0;for(let O=0;O<2&&E=10&&(S|=1<<1-O),O!==1&&(E=u.getNextSet(E),E=u.getNextUnset(E))}if(g.length!==2)throw new te;if(parseInt(g.toString())%4!==S)throw new te;return E}static parseExtensionString(u){return u.length!==2?null:new Map([[Tt.ISSUE_NUMBER,parseInt(u)]])}}class jn{static decodeRow(u,p,g){let b=tt.findGuardPattern(p,g,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new fn().decodeRow(u,p,b)}catch{return new Bt().decodeRow(u,p,b)}}}jn.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class jt extends tt{constructor(){super(),this.decodeRowStringBuffer="",jt.L_AND_G_PATTERNS=jt.L_PATTERNS.map(u=>Int32Array.from(u));for(let u=10;u<20;u++){let p=jt.L_PATTERNS[u-10],g=new Int32Array(p.length);for(let b=0;b=p.getSize()||!p.isRange(W,ne,!1))throw new te;let oe=O.toString();if(oe.length<8)throw new z;if(!jt.checkChecksum(oe))throw new A;let ye=(b[1]+b[0])/2,_e=(M[1]+M[0])/2,Ie=this.getBarcodeFormat(),Ke=[new It(ye,u),new It(_e,u)],ct=new Fe(oe,null,0,Ke,Ie,new Date().getTime()),Gt=0;try{let Rt=jn.decodeRow(u,p,M[1]);ct.putMetadata(Tt.UPC_EAN_EXTENSION,Rt.getText()),ct.putAllMetadata(Rt.getResultMetadata()),ct.addResultPoints(Rt.getResultPoints()),Gt=Rt.getText().length}catch{}let $t=g==null?null:g.get(K.ALLOWED_EAN_EXTENSIONS);if($t!=null){let Rt=!1;for(let Or in $t)if(Gt.toString()===Or){Rt=!0;break}if(!Rt)throw new te}return ct}decodeEnd(u,p){return jt.findGuardPattern(u,p,!1,jt.START_END_PATTERN,new Int32Array(jt.START_END_PATTERN.length).fill(0))}static checkChecksum(u){return jt.checkStandardUPCEANChecksum(u)}static checkStandardUPCEANChecksum(u){let p=u.length;if(p===0)return!1;let g=parseInt(u.charAt(p-1),10);return jt.getStandardUPCEANChecksum(u.substring(0,p-1))===g}static getStandardUPCEANChecksum(u){let p=u.length,g=0;for(let b=p-1;b>=0;b-=2){let v=u.charAt(b).charCodeAt(0)-48;if(v<0||v>9)throw new z;g+=v}g*=3;for(let b=p-2;b>=0;b-=2){let v=u.charAt(b).charCodeAt(0)-48;if(v<0||v>9)throw new z;g+=v}return(1e3-g)%10}}class on extends jt{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(u,p,g){let b=this.decodeMiddleCounters;b[0]=0,b[1]=0,b[2]=0,b[3]=0;let v=u.getSize(),E=p[1],S=0;for(let M=0;M<6&&E=10&&(S|=1<<5-M)}g=on.determineFirstDigit(g,S),E=jt.findGuardPattern(u,E,!0,jt.MIDDLE_PATTERN,new Int32Array(jt.MIDDLE_PATTERN.length).fill(0))[1];for(let M=0;M<6&&EM);b[0]=0,b[1]=0,b[2]=0,b[3]=0;const v=u.getSize();let E=p[1],S=0;for(let M=0;M<6&&E=10&&(S|=1<<5-M)}let O=ue.determineNumSysAndCheckDigit(g,S);return{rowOffset:E,resultString:O}}decodeEnd(u,p){return ue.findGuardPatternWithoutCounters(u,p,!0,ue.MIDDLE_END_PATTERN)}checkChecksum(u){return jt.checkChecksum(ue.convertUPCEtoUPCA(u))}static determineNumSysAndCheckDigit(u,p){for(let g=0;g<=1;g++)for(let b=0;b<10;b++)if(p===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[g][b]){let v=String.fromCharCode(48+g),E=String.fromCharCode(48+b);return v+u+E}throw te.getNotFoundInstance()}getBarcodeFormat(){return Ue.UPC_E}static convertUPCEtoUPCA(u){const p=u.slice(1,7).split("").map(v=>v.charCodeAt(0)),g=new G;g.append(u.charAt(0));let b=p[5];switch(b){case 0:case 1:case 2:g.appendChars(p,0,2),g.append(b),g.append("0000"),g.appendChars(p,2,3);break;case 3:g.appendChars(p,0,3),g.append("00000"),g.appendChars(p,3,2);break;case 4:g.appendChars(p,0,4),g.append("00000"),g.append(p[4]);break;default:g.appendChars(p,0,5),g.append("0000"),g.append(b);break}return u.length>=8&&g.append(u.charAt(7)),g.toString()}}ue.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),ue.NUMSYS_AND_CHECK_DIGIT_PATTERNS=[Int32Array.from([56,52,50,49,44,38,35,42,41,37]),Int32Array.from([7,11,13,14,19,25,28,21,22,26])];class Se extends $n{constructor(u){super();let p=u==null?null:u.get(K.POSSIBLE_FORMATS),g=[];r(p)?(g.push(new on),g.push(new pr),g.push(new Ir),g.push(new ue)):(p.indexOf(Ue.EAN_13)>-1&&g.push(new on),p.indexOf(Ue.UPC_A)>-1&&g.push(new pr),p.indexOf(Ue.EAN_8)>-1&&g.push(new Ir),p.indexOf(Ue.UPC_E)>-1&&g.push(new ue)),this.readers=g}decodeRow(u,p,g){for(let b of this.readers)try{const v=b.decodeRow(u,p,g),E=v.getBarcodeFormat()===Ue.EAN_13&&v.getText().charAt(0)==="0",S=g==null?null:g.get(K.POSSIBLE_FORMATS),O=S==null||S.includes(Ue.UPC_A);if(E&&O){const M=v.getRawBytes(),W=new Fe(v.getText().substring(1),M,M?M.length:null,v.getResultPoints(),Ue.UPC_A);return W.putAllMetadata(v.getResultMetadata()),W}return v}catch{}throw new te}reset(){for(let u of this.readers)u.reset()}}class Xe extends $n{constructor(){super(),this.decodeFinderCounters=new Int32Array(4),this.dataCharacterCounters=new Int32Array(8),this.oddRoundingErrors=new Array(4),this.evenRoundingErrors=new Array(4),this.oddCounts=new Array(this.dataCharacterCounters.length/2),this.evenCounts=new Array(this.dataCharacterCounters.length/2)}getDecodeFinderCounters(){return this.decodeFinderCounters}getDataCharacterCounters(){return this.dataCharacterCounters}getOddRoundingErrors(){return this.oddRoundingErrors}getEvenRoundingErrors(){return this.evenRoundingErrors}getOddCounts(){return this.oddCounts}getEvenCounts(){return this.evenCounts}parseFinderValue(u,p){for(let g=0;gb&&(b=p[v],g=v);u[g]++}static decrement(u,p){let g=0,b=p[0];for(let v=1;v=Xe.MIN_FINDER_PATTERN_RATIO&&b<=Xe.MAX_FINDER_PATTERN_RATIO){let v=Number.MAX_SAFE_INTEGER,E=Number.MIN_SAFE_INTEGER;for(let S of u)S>E&&(E=S),S=S-O-1&&(W-=xn.combins(b-M-(S-O),S-O-2)),S-O-1>1){let ne=0;for(let oe=b-M-(S-O-2);oe>p;oe--)ne+=xn.combins(b-M-oe-1,S-O-3);W-=ne*(S-1-O)}else b-M>p&&W--;v+=W}b-=M}return v}static combins(u,p){let g,b;u-p>p?(b=p,g=u-p):(b=u-p,g=p);let v=1,E=1;for(let S=u;S>g;S--)v*=S,E<=b&&(v/=E,E++);for(;E<=b;)v/=E,E++;return v}}class yn{static buildBitArray(u){let p=u.length*2-1;u[u.length-1].getRightChar()==null&&(p-=1);let g=12*p,b=new q(g),v=0,S=u[0].getRightChar().getValue();for(let O=11;O>=0;--O)(S&1<=0;--ne)(W&1<=0;--oe)(ne&1<10||g<0||g>10)throw new z;this.firstDigit=p,this.secondDigit=g}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return this.firstDigit*10+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===tn.FNC1}isSecondDigitFNC1(){return this.secondDigit===tn.FNC1}isAnyFNC1(){return this.firstDigit===tn.FNC1||this.secondDigit===tn.FNC1}}tn.FNC1=10;class yt{constructor(){}static parseFieldsInGeneralPurpose(u){if(!u)return null;if(u.length<2)throw new te;let p=u.substring(0,2);for(let v of yt.TWO_DIGIT_DATA_LENGTH)if(v[0]===p)return v[1]===yt.VARIABLE_LENGTH?yt.processVariableAI(2,v[2],u):yt.processFixedAI(2,v[1],u);if(u.length<3)throw new te;let g=u.substring(0,3);for(let v of yt.THREE_DIGIT_DATA_LENGTH)if(v[0]===g)return v[1]===yt.VARIABLE_LENGTH?yt.processVariableAI(3,v[2],u):yt.processFixedAI(3,v[1],u);for(let v of yt.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(v[0]===g)return v[1]===yt.VARIABLE_LENGTH?yt.processVariableAI(4,v[2],u):yt.processFixedAI(4,v[1],u);if(u.length<4)throw new te;let b=u.substring(0,4);for(let v of yt.FOUR_DIGIT_DATA_LENGTH)if(v[0]===b)return v[1]===yt.VARIABLE_LENGTH?yt.processVariableAI(4,v[2],u):yt.processFixedAI(4,v[1],u);throw new te}static processFixedAI(u,p,g){if(g.lengththis.information.getSize())return u+4<=this.information.getSize();for(let p=u;pthis.information.getSize()){let v=this.extractNumericValueFromBitArray(u,4);return v===0?new tn(this.information.getSize(),tn.FNC1,tn.FNC1):new tn(this.information.getSize(),v-1,tn.FNC1)}let p=this.extractNumericValueFromBitArray(u,7),g=(p-8)/11,b=(p-8)%11;return new tn(u+7,g,b)}extractNumericValueFromBitArray(u,p){return cn.extractNumericValueFromBitArray(this.information,u,p)}static extractNumericValueFromBitArray(u,p,g){let b=0;for(let v=0;vthis.information.getSize())return!1;let p=this.extractNumericValueFromBitArray(u,5);if(p>=5&&p<16)return!0;if(u+7>this.information.getSize())return!1;let g=this.extractNumericValueFromBitArray(u,7);if(g>=64&&g<116)return!0;if(u+8>this.information.getSize())return!1;let b=this.extractNumericValueFromBitArray(u,8);return b>=232&&b<253}decodeIsoIec646(u){let p=this.extractNumericValueFromBitArray(u,5);if(p===15)return new Nt(u+5,Nt.FNC1);if(p>=5&&p<15)return new Nt(u+5,"0"+(p-5));let g=this.extractNumericValueFromBitArray(u,7);if(g>=64&&g<90)return new Nt(u+7,""+(g+1));if(g>=90&&g<116)return new Nt(u+7,""+(g+7));let b=this.extractNumericValueFromBitArray(u,8),v;switch(b){case 232:v="!";break;case 233:v='"';break;case 234:v="%";break;case 235:v="&";break;case 236:v="'";break;case 237:v="(";break;case 238:v=")";break;case 239:v="*";break;case 240:v="+";break;case 241:v=",";break;case 242:v="-";break;case 243:v=".";break;case 244:v="/";break;case 245:v=":";break;case 246:v=";";break;case 247:v="<";break;case 248:v="=";break;case 249:v=">";break;case 250:v="?";break;case 251:v="_";break;case 252:v=" ";break;default:throw new z}return new Nt(u+8,v)}isStillAlpha(u){if(u+5>this.information.getSize())return!1;let p=this.extractNumericValueFromBitArray(u,5);if(p>=5&&p<16)return!0;if(u+6>this.information.getSize())return!1;let g=this.extractNumericValueFromBitArray(u,6);return g>=16&&g<63}decodeAlphanumeric(u){let p=this.extractNumericValueFromBitArray(u,5);if(p===15)return new Nt(u+5,Nt.FNC1);if(p>=5&&p<15)return new Nt(u+5,"0"+(p-5));let g=this.extractNumericValueFromBitArray(u,6);if(g>=32&&g<58)return new Nt(u+6,""+(g+33));let b;switch(g){case 58:b="*";break;case 59:b=",";break;case 60:b="-";break;case 61:b=".";break;case 62:b="/";break;default:throw new Fn("Decoding invalid alphanumeric value: "+g)}return new Nt(u+6,b)}isAlphaTo646ToAlphaLatch(u){if(u+1>this.information.getSize())return!1;for(let p=0;p<5&&p+uthis.information.getSize())return!1;for(let p=u;pthis.information.getSize())return!1;for(let p=0;p<4&&p+u{p.forEach(E=>{b.getLeftChar().getValue()===E.getLeftChar().getValue()&&b.getRightChar().getValue()===E.getRightChar().getValue()&&b.getFinderPatter().getValue()===E.getFinderPatter().getValue()&&(g=!0)})}),g}}class Et extends Xe{constructor(u){super(...arguments),this.pairs=new Array(Et.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=u===!0}decodeRow(u,p,g){this.pairs.length=0,this.startFromEven=!1;try{return Et.constructResult(this.decodeRow2pairs(u,p))}catch(b){this.verbose&&console.log(b)}return this.pairs.length=0,this.startFromEven=!0,Et.constructResult(this.decodeRow2pairs(u,p))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(u,p){let g=!1;for(;!g;)try{this.pairs.push(this.retrieveNextPair(p,this.pairs,u))}catch(v){if(v instanceof te){if(!this.pairs.length)throw new te;g=!0}}if(this.checkChecksum())return this.pairs;let b;if(this.rows.length?b=!0:b=!1,this.storeRow(u,!1),b){let v=this.checkRowsBoolean(!1);if(v!=null||(v=this.checkRowsBoolean(!0),v!=null))return v}throw new te}checkRowsBoolean(u){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,u&&(this.rows=this.rows.reverse());let p=null;try{p=this.checkRows(new Array,0)}catch(g){this.verbose&&console.log(g)}return u&&(this.rows=this.rows.reverse()),p}checkRows(u,p){for(let g=p;gp.length)continue;let g=!0;for(let b=0;bu){v=E.isEquivalent(this.pairs);break}b=E.isEquivalent(this.pairs),g++}v||b||Et.isPartialRow(this.pairs,this.rows)||(this.rows.push(g,new si(this.pairs,u,p)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(u,p){for(let g of p)if(g.getPairs().length!==u.length){for(let b of g.getPairs())for(let v of u)if(ss.equals(b,v))break}}static isPartialRow(u,p){for(let g of p){let b=!0;for(let v of u){let E=!1;for(let S of g.getPairs())if(v.equals(S)){E=!0;break}if(!E){b=!1;break}}if(b)return!0}return!1}getRows(){return this.rows}static constructResult(u){let p=yn.buildBitArray(u),b=Qi(p).parseInformation(),v=u[0].getFinderPattern().getResultPoints(),E=u[u.length-1].getFinderPattern().getResultPoints(),S=[v[0],v[1],E[0],E[1]];return new Fe(b,null,null,S,Ue.RSS_EXPANDED,null)}checkChecksum(){let u=this.pairs.get(0),p=u.getLeftChar(),g=u.getRightChar();if(g==null)return!1;let b=g.getChecksumPortion(),v=2;for(let S=1;S=0?E=g:this.isEmptyPair(p)?E=0:E=p[p.length-1].getFinderPattern().getStartEnd()[1];let S=p.length%2!=0;this.startFromEven&&(S=!S);let O=!1;for(;E=0&&!u.get(M);)M--;M++,b=this.startEnd[0]-M,v=M,E=this.startEnd[1]}else v=this.startEnd[0],E=u.getNextUnset(this.startEnd[1]+1),b=E-this.startEnd[1];let S=this.getDecodeFinderCounters();I.arraycopy(S,0,S,1,S.length-1),S[0]=b;let O;try{O=this.parseFinderValue(S,Et.FINDER_PATTERNS)}catch{return null}return new gn(O,[v,E],v,E,p)}decodeDataCharacter(u,p,g,b){let v=this.getDataCharacterCounters();for(let vi=0;vi.3)throw new te;let M=this.getOddCounts(),W=this.getEvenCounts(),ne=this.getOddRoundingErrors(),oe=this.getEvenRoundingErrors();for(let vi=0;vi8){if(Qs>8.7)throw new te;ya=8}let gc=vi/2;(vi&1)==0?(M[gc]=ya,ne[gc]=Qs-ya):(W[gc]=ya,oe[gc]=Qs-ya)}this.adjustOddEvenCounts(E);let ye=4*p.getValue()+(g?0:2)+(b?0:1)-1,_e=0,Ie=0;for(let vi=M.length-1;vi>=0;vi--){if(Et.isNotA1left(p,g,b)){let Qs=Et.WEIGHTS[ye][2*vi];Ie+=M[vi]*Qs}_e+=M[vi]}let Ke=0;for(let vi=W.length-1;vi>=0;vi--)if(Et.isNotA1left(p,g,b)){let Qs=Et.WEIGHTS[ye][2*vi+1];Ke+=W[vi]*Qs}let ct=Ie+Ke;if((_e&1)!=0||_e>13||_e<4)throw new te;let Gt=(13-_e)/2,$t=Et.SYMBOL_WIDEST[Gt],Rt=9-$t,Or=xn.getRSSvalue(M,$t,!0),yr=xn.getRSSvalue(W,Rt,!1),vs=Et.EVEN_TOTAL_SUBSET[Gt],fo=Et.GSUM[Gt],sa=Or*vs+yr+fo;return new Vt(sa,ct)}static isNotA1left(u,p,g){return!(u.getValue()==0&&p&&g)}adjustOddEvenCounts(u){let p=Ze.sum(new Int32Array(this.getOddCounts())),g=Ze.sum(new Int32Array(this.getEvenCounts())),b=!1,v=!1;p>13?v=!0:p<4&&(b=!0);let E=!1,S=!1;g>13?S=!0:g<4&&(E=!0);let O=p+g-u,M=(p&1)==1,W=(g&1)==0;if(O==1)if(M){if(W)throw new te;v=!0}else{if(!W)throw new te;S=!0}else if(O==-1)if(M){if(W)throw new te;b=!0}else{if(!W)throw new te;E=!0}else if(O==0){if(M){if(!W)throw new te;p1){for(let S of this.possibleRightPairs)if(S.getCount()>1&&Tr.checkChecksum(E,S))return Tr.constructResult(E,S)}throw new te}static addOrTally(u,p){if(p==null)return;let g=!1;for(let b of u)if(b.getValue()===p.getValue()){b.incrementCount(),g=!0;break}g||u.push(p)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(u,p){let g=4537077*u.getValue()+p.getValue(),b=new String(g).toString(),v=new G;for(let M=13-b.length;M>0;M--)v.append("0");v.append(b);let E=0;for(let M=0;M<13;M++){let W=v.charAt(M).charCodeAt(0)-48;E+=(M&1)===0?3*W:W}E=10-E%10,E===10&&(E=0),v.append(E.toString());let S=u.getFinderPattern().getResultPoints(),O=p.getFinderPattern().getResultPoints();return new Fe(v.toString(),null,0,[S[0],S[1],O[0],O[1]],Ue.RSS_14,new Date().getTime())}static checkChecksum(u,p){let g=(u.getChecksumPortion()+16*p.getChecksumPortion())%79,b=9*u.getFinderPattern().getValue()+p.getFinderPattern().getValue();return b>72&&b--,b>8&&b--,g===b}decodePair(u,p,g,b){try{let v=this.findFinderPattern(u,p),E=this.parseFoundFinderPattern(u,g,p,v),S=b==null?null:b.get(K.NEED_RESULT_POINT_CALLBACK);if(S!=null){let W=(v[0]+v[1])/2;p&&(W=u.getSize()-1-W),S.foundPossibleResultPoint(new It(W,g))}let O=this.decodeDataCharacter(u,E,!0),M=this.decodeDataCharacter(u,E,!1);return new Oa(1597*O.getValue()+M.getValue(),O.getChecksumPortion()+4*M.getChecksumPortion(),E)}catch{return null}}decodeDataCharacter(u,p,g){let b=this.getDataCharacterCounters();for(let Ke=0;Ke8&&(Gt=8);let $t=Math.floor(Ke/2);(Ke&1)===0?(S[$t]=Gt,M[$t]=ct-Gt):(O[$t]=Gt,W[$t]=ct-Gt)}this.adjustOddEvenCounts(g,v);let ne=0,oe=0;for(let Ke=S.length-1;Ke>=0;Ke--)oe*=9,oe+=S[Ke],ne+=S[Ke];let ye=0,_e=0;for(let Ke=O.length-1;Ke>=0;Ke--)ye*=9,ye+=O[Ke],_e+=O[Ke];let Ie=oe+3*ye;if(g){if((ne&1)!==0||ne>12||ne<4)throw new te;let Ke=(12-ne)/2,ct=Tr.OUTSIDE_ODD_WIDEST[Ke],Gt=9-ct,$t=xn.getRSSvalue(S,ct,!1),Rt=xn.getRSSvalue(O,Gt,!0),Or=Tr.OUTSIDE_EVEN_TOTAL_SUBSET[Ke],yr=Tr.OUTSIDE_GSUM[Ke];return new Vt($t*Or+Rt+yr,Ie)}else{if((_e&1)!==0||_e>10||_e<4)throw new te;let Ke=(10-_e)/2,ct=Tr.INSIDE_ODD_WIDEST[Ke],Gt=9-ct,$t=xn.getRSSvalue(S,ct,!0),Rt=xn.getRSSvalue(O,Gt,!1),Or=Tr.INSIDE_ODD_TOTAL_SUBSET[Ke],yr=Tr.INSIDE_GSUM[Ke];return new Vt(Rt*Or+$t+yr,Ie)}}findFinderPattern(u,p){let g=this.getDecodeFinderCounters();g[0]=0,g[1]=0,g[2]=0,g[3]=0;let b=u.getSize(),v=!1,E=0;for(;E=0&&v!==u.get(E);)E--;E++;const S=b[0]-E,O=this.getDecodeFinderCounters(),M=new Int32Array(O.length);I.arraycopy(O,0,M,1,O.length-1),M[0]=S;const W=this.parseFinderValue(M,Tr.FINDER_PATTERNS);let ne=E,oe=b[1];return g&&(ne=u.getSize()-1-ne,oe=u.getSize()-1-oe),new gn(W,[E,b[1]],ne,oe,p)}adjustOddEvenCounts(u,p){let g=Ze.sum(new Int32Array(this.getOddCounts())),b=Ze.sum(new Int32Array(this.getEvenCounts())),v=!1,E=!1,S=!1,O=!1;u?(g>12?E=!0:g<4&&(v=!0),b>12?O=!0:b<4&&(S=!0)):(g>11?E=!0:g<5&&(v=!0),b>10?O=!0:b<4&&(S=!0));let M=g+b-p,W=(g&1)===(u?1:0),ne=(b&1)===1;if(M===1)if(W){if(ne)throw new te;E=!0}else{if(!ne)throw new te;O=!0}else if(M===-1)if(W){if(ne)throw new te;v=!0}else{if(!ne)throw new te;S=!0}else if(M===0){if(W){if(!ne)throw new te;gu.reset())}}class jo extends ae{constructor(u=500,p){super(new Hi(p),u,p)}}class or{constructor(u,p,g){this.ecCodewords=u,this.ecBlocks=[p],g&&this.ecBlocks.push(g)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class kr{constructor(u,p){this.count=u,this.dataCodewords=p}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class lr{constructor(u,p,g,b,v,E){this.versionNumber=u,this.symbolSizeRows=p,this.symbolSizeColumns=g,this.dataRegionSizeRows=b,this.dataRegionSizeColumns=v,this.ecBlocks=E;let S=0;const O=E.getECCodewords(),M=E.getECBlocks();for(let W of M)S+=W.getCount()*(W.getDataCodewords()+O);this.totalCodewords=S}getVersionNumber(){return this.versionNumber}getSymbolSizeRows(){return this.symbolSizeRows}getSymbolSizeColumns(){return this.symbolSizeColumns}getDataRegionSizeRows(){return this.dataRegionSizeRows}getDataRegionSizeColumns(){return this.dataRegionSizeColumns}getTotalCodewords(){return this.totalCodewords}getECBlocks(){return this.ecBlocks}static getVersionForDimensions(u,p){if((u&1)!==0||(p&1)!==0)throw new z;for(let g of lr.VERSIONS)if(g.symbolSizeRows===u&&g.symbolSizeColumns===p)return g;throw new z}toString(){return""+this.versionNumber}static buildVersions(){return[new lr(1,10,10,8,8,new or(5,new kr(1,3))),new lr(2,12,12,10,10,new or(7,new kr(1,5))),new lr(3,14,14,12,12,new or(10,new kr(1,8))),new lr(4,16,16,14,14,new or(12,new kr(1,12))),new lr(5,18,18,16,16,new or(14,new kr(1,18))),new lr(6,20,20,18,18,new or(18,new kr(1,22))),new lr(7,22,22,20,20,new or(20,new kr(1,30))),new lr(8,24,24,22,22,new or(24,new kr(1,36))),new lr(9,26,26,24,24,new or(28,new kr(1,44))),new lr(10,32,32,14,14,new or(36,new kr(1,62))),new lr(11,36,36,16,16,new or(42,new kr(1,86))),new lr(12,40,40,18,18,new or(48,new kr(1,114))),new lr(13,44,44,20,20,new or(56,new kr(1,144))),new lr(14,48,48,22,22,new or(68,new kr(1,174))),new lr(15,52,52,24,24,new or(42,new kr(2,102))),new lr(16,64,64,14,14,new or(56,new kr(2,140))),new lr(17,72,72,16,16,new or(36,new kr(4,92))),new lr(18,80,80,18,18,new or(48,new kr(4,114))),new lr(19,88,88,20,20,new or(56,new kr(4,144))),new lr(20,96,96,22,22,new or(68,new kr(4,174))),new lr(21,104,104,24,24,new or(56,new kr(6,136))),new lr(22,120,120,18,18,new or(68,new kr(6,175))),new lr(23,132,132,20,20,new or(62,new kr(8,163))),new lr(24,144,144,22,22,new or(62,new kr(8,156),new kr(2,155))),new lr(25,8,18,6,16,new or(7,new kr(1,5))),new lr(26,8,32,6,14,new or(11,new kr(1,10))),new lr(27,12,26,10,24,new or(14,new kr(1,16))),new lr(28,12,36,10,16,new or(18,new kr(1,22))),new lr(29,16,36,14,16,new or(24,new kr(1,32))),new lr(30,16,48,14,22,new or(28,new kr(1,49)))]}}lr.VERSIONS=lr.buildVersions();class Re{constructor(u){const p=u.getHeight();if(p<8||p>144||(p&1)!==0)throw new z;this.version=Re.readVersion(u),this.mappingBitMatrix=this.extractDataRegion(u),this.readMappingMatrix=new he(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(u){const p=u.getHeight(),g=u.getWidth();return lr.getVersionForDimensions(p,g)}readCodewords(){const u=new Int8Array(this.version.getTotalCodewords());let p=0,g=4,b=0;const v=this.mappingBitMatrix.getHeight(),E=this.mappingBitMatrix.getWidth();let S=!1,O=!1,M=!1,W=!1;do if(g===v&&b===0&&!S)u[p++]=this.readCorner1(v,E)&255,g-=2,b+=2,S=!0;else if(g===v-2&&b===0&&(E&3)!==0&&!O)u[p++]=this.readCorner2(v,E)&255,g-=2,b+=2,O=!0;else if(g===v+4&&b===2&&(E&7)===0&&!M)u[p++]=this.readCorner3(v,E)&255,g-=2,b+=2,M=!0;else if(g===v-2&&b===0&&(E&7)===4&&!W)u[p++]=this.readCorner4(v,E)&255,g-=2,b+=2,W=!0;else{do g=0&&!this.readMappingMatrix.get(b,g)&&(u[p++]=this.readUtah(g,b,v,E)&255),g-=2,b+=2;while(g>=0&&b=0&&b=0);g+=3,b+=1}while(g7?Ie-1:Ie;E[ct].codewords[Gt]=u[ne++]}if(ne!==u.length)throw new y;return E}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class Je{constructor(u){this.bytes=u,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(u){if(u<1||u>32||u>this.available())throw new y(""+u);let p=0,g=this.bitOffset,b=this.byteOffset;const v=this.bytes;if(g>0){const E=8-g,S=u>8-S<>O,u-=S,g+=S,g===8&&(g=0,b++)}if(u>0){for(;u>=8;)p=p<<8|v[b]&255,b++,u-=8;if(u>0){const E=8-u,S=255>>E<>E,g+=u}}return this.bitOffset=g,this.byteOffset=b,p}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var vt;(function(ee){ee[ee.PAD_ENCODE=0]="PAD_ENCODE",ee[ee.ASCII_ENCODE=1]="ASCII_ENCODE",ee[ee.C40_ENCODE=2]="C40_ENCODE",ee[ee.TEXT_ENCODE=3]="TEXT_ENCODE",ee[ee.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",ee[ee.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",ee[ee.BASE256_ENCODE=6]="BASE256_ENCODE"})(vt||(vt={}));class Zt{static decode(u){const p=new Je(u),g=new G,b=new G,v=new Array;let E=vt.ASCII_ENCODE;do if(E===vt.ASCII_ENCODE)E=this.decodeAsciiSegment(p,g,b);else{switch(E){case vt.C40_ENCODE:this.decodeC40Segment(p,g);break;case vt.TEXT_ENCODE:this.decodeTextSegment(p,g);break;case vt.ANSIX12_ENCODE:this.decodeAnsiX12Segment(p,g);break;case vt.EDIFACT_ENCODE:this.decodeEdifactSegment(p,g);break;case vt.BASE256_ENCODE:this.decodeBase256Segment(p,g,v);break;default:throw new z}E=vt.ASCII_ENCODE}while(E!==vt.PAD_ENCODE&&p.available()>0);return b.length()>0&&g.append(b.toString()),new ht(u,g.toString(),v.length===0?null:v,null)}static decodeAsciiSegment(u,p,g){let b=!1;do{let v=u.readBits(8);if(v===0)throw new z;if(v<=128)return b&&(v+=128),p.append(String.fromCharCode(v-1)),vt.ASCII_ENCODE;if(v===129)return vt.PAD_ENCODE;if(v<=229){const E=v-130;E<10&&p.append("0"),p.append(""+E)}else switch(v){case 230:return vt.C40_ENCODE;case 231:return vt.BASE256_ENCODE;case 232:p.append("");break;case 233:case 234:break;case 235:b=!0;break;case 236:p.append("[)>05"),g.insert(0,"");break;case 237:p.append("[)>06"),g.insert(0,"");break;case 238:return vt.ANSIX12_ENCODE;case 239:return vt.TEXT_ENCODE;case 240:return vt.EDIFACT_ENCODE;case 241:break;default:if(v!==254||u.available()!==0)throw new z;break}}while(u.available()>0);return vt.ASCII_ENCODE}static decodeC40Segment(u,p){let g=!1;const b=[];let v=0;do{if(u.available()===8)return;const E=u.readBits(8);if(E===254)return;this.parseTwoBytes(E,u.readBits(8),b);for(let S=0;S<3;S++){const O=b[S];switch(v){case 0:if(O<3)v=O+1;else if(O0)}static decodeTextSegment(u,p){let g=!1,b=[],v=0;do{if(u.available()===8)return;const E=u.readBits(8);if(E===254)return;this.parseTwoBytes(E,u.readBits(8),b);for(let S=0;S<3;S++){const O=b[S];switch(v){case 0:if(O<3)v=O+1;else if(O0)}static decodeAnsiX12Segment(u,p){const g=[];do{if(u.available()===8)return;const b=u.readBits(8);if(b===254)return;this.parseTwoBytes(b,u.readBits(8),g);for(let v=0;v<3;v++){const E=g[v];switch(E){case 0:p.append("\r");break;case 1:p.append("*");break;case 2:p.append(">");break;case 3:p.append(" ");break;default:if(E<14)p.append(String.fromCharCode(E+44));else if(E<40)p.append(String.fromCharCode(E+51));else throw new z;break}}}while(u.available()>0)}static parseTwoBytes(u,p,g){let b=(u<<8)+p-1,v=Math.floor(b/1600);g[0]=v,b-=v*1600,v=Math.floor(b/40),g[1]=v,g[2]=b-v*40}static decodeEdifactSegment(u,p){do{if(u.available()<=16)return;for(let g=0;g<4;g++){let b=u.readBits(6);if(b===31){const v=8-u.getBitOffset();v!==8&&u.readBits(v);return}(b&32)===0&&(b|=64),p.append(String.fromCharCode(b))}}while(u.available()>0)}static decodeBase256Segment(u,p,g){let b=1+u.getByteOffset();const v=this.unrandomize255State(u.readBits(8),b++);let E;if(v===0?E=u.available()/8|0:v<250?E=v:E=250*(v-249)+this.unrandomize255State(u.readBits(8),b++),E<0)throw new z;const S=new Uint8Array(E);for(let O=0;O=0?b:b+256}}Zt.C40_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],Zt.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],Zt.TEXT_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],Zt.TEXT_SHIFT2_SET_CHARS=Zt.C40_SHIFT2_SET_CHARS,Zt.TEXT_SHIFT3_SET_CHARS=["`","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","|","}","~",""];class wn{constructor(){this.rsDecoder=new Ft(sn.DATA_MATRIX_FIELD_256)}decode(u){const p=new Re(u),g=p.getVersion(),b=p.readCodewords(),v=mt.getDataBlocks(b,g);let E=0;for(let M of v)E+=M.getNumDataCodewords();const S=new Uint8Array(E),O=v.length;for(let M=0;MS&&(W=S,ne[0]=p,ne[1]=g,ne[2]=b,ne[3]=v),W>O&&(W=O,ne[0]=g,ne[1]=b,ne[2]=v,ne[3]=p),W>M&&(ne[0]=b,ne[1]=v,ne[2]=p,ne[3]=g),ne}detectSolid2(u){let p=u[0],g=u[1],b=u[2],v=u[3],E=this.transitionsBetween(p,v),S=Le.shiftPoint(g,b,(E+1)*4),O=Le.shiftPoint(b,g,(E+1)*4),M=this.transitionsBetween(S,p),W=this.transitionsBetween(O,v);return Mye?W:ne}shiftToModuleCenter(u){let p=u[0],g=u[1],b=u[2],v=u[3],E=this.transitionsBetween(p,v)+1,S=this.transitionsBetween(b,v)+1,O=Le.shiftPoint(p,g,S*4),M=Le.shiftPoint(b,g,E*4);E=this.transitionsBetween(O,v)+1,S=this.transitionsBetween(M,v)+1,(E&1)===1&&(E+=1),(S&1)===1&&(S+=1);let W=(p.getX()+g.getX()+b.getX()+v.getX())/4,ne=(p.getY()+g.getY()+b.getY()+v.getY())/4;p=Le.moveAway(p,W,ne),g=Le.moveAway(g,W,ne),b=Le.moveAway(b,W,ne),v=Le.moveAway(v,W,ne);let oe,ye;return O=Le.shiftPoint(p,g,S*4),O=Le.shiftPoint(O,v,E*4),oe=Le.shiftPoint(g,p,S*4),oe=Le.shiftPoint(oe,b,E*4),M=Le.shiftPoint(b,v,S*4),M=Le.shiftPoint(M,g,E*4),ye=Le.shiftPoint(v,b,S*4),ye=Le.shiftPoint(ye,p,E*4),[O,oe,M,ye]}isValid(u){return u.getX()>=0&&u.getX()0&&u.getY()Math.abs(v-g);if(S){let Ie=g;g=b,b=Ie,Ie=v,v=E,E=Ie}let O=Math.abs(v-g),M=Math.abs(E-b),W=-O/2,ne=b0){if(Ke===E)break;Ke+=ne,W-=O}}return ye}}class Ut{constructor(){this.decoder=new wn}decode(u,p=null){let g,b;if(p!=null&&p.has(K.PURE_BARCODE)){const M=Ut.extractPureBits(u.getBlackMatrix());g=this.decoder.decode(M),b=Ut.NO_POINTS}else{const M=new Le(u.getBlackMatrix()).detect();g=this.decoder.decode(M.getBits()),b=M.getPoints()}const v=g.getRawBytes(),E=new Fe(g.getText(),v,8*v.length,b,Ue.DATA_MATRIX,I.currentTimeMillis()),S=g.getByteSegments();S!=null&&E.putMetadata(Tt.BYTE_SEGMENTS,S);const O=g.getECLevel();return O!=null&&E.putMetadata(Tt.ERROR_CORRECTION_LEVEL,O),E}reset(){}static extractPureBits(u){const p=u.getTopLeftOnBit(),g=u.getBottomRightOnBit();if(p==null||g==null)throw new te;const b=this.moduleSize(p,u);let v=p[1];const E=g[1];let S=p[0];const M=(g[0]-S+1)/b,W=(E-v+1)/b;if(M<=0||W<=0)throw new te;const ne=b/2;v+=ne,S+=ne;const oe=new he(M,W);for(let ye=0;ye=Pn.FOR_BITS.size)throw new y;return Pn.FOR_BITS.get(u)}}Pn.FOR_BITS=new Map,Pn.FOR_VALUE=new Map,Pn.L=new Pn(Mn.L,"L",1),Pn.M=new Pn(Mn.M,"M",0),Pn.Q=new Pn(Mn.Q,"Q",3),Pn.H=new Pn(Mn.H,"H",2);class vr{constructor(u){this.errorCorrectionLevel=Pn.forBits(u>>3&3),this.dataMask=u&7}static numBitsDiffering(u,p){return L.bitCount(u^p)}static decodeFormatInformation(u,p){const g=vr.doDecodeFormatInformation(u,p);return g!==null?g:vr.doDecodeFormatInformation(u^vr.FORMAT_INFO_MASK_QR,p^vr.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(u,p){let g=Number.MAX_SAFE_INTEGER,b=0;for(const v of vr.FORMAT_INFO_DECODE_LOOKUP){const E=v[0];if(E===u||E===p)return new vr(v[1]);let S=vr.numBitsDiffering(u,E);S40)throw new y;return rn.VERSIONS[u-1]}static decodeVersionInformation(u){let p=Number.MAX_SAFE_INTEGER,g=0;for(let b=0;b6&&(p.setRegion(u-11,0,3,6),p.setRegion(0,u-11,6,3)),p}toString(){return""+this.versionNumber}}rn.VERSION_DECODE_INFO=Int32Array.from([31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017]),rn.VERSIONS=[new rn(1,new Int32Array(0),new Me(7,new fe(1,19)),new Me(10,new fe(1,16)),new Me(13,new fe(1,13)),new Me(17,new fe(1,9))),new rn(2,Int32Array.from([6,18]),new Me(10,new fe(1,34)),new Me(16,new fe(1,28)),new Me(22,new fe(1,22)),new Me(28,new fe(1,16))),new rn(3,Int32Array.from([6,22]),new Me(15,new fe(1,55)),new Me(26,new fe(1,44)),new Me(18,new fe(2,17)),new Me(22,new fe(2,13))),new rn(4,Int32Array.from([6,26]),new Me(20,new fe(1,80)),new Me(18,new fe(2,32)),new Me(26,new fe(2,24)),new Me(16,new fe(4,9))),new rn(5,Int32Array.from([6,30]),new Me(26,new fe(1,108)),new Me(24,new fe(2,43)),new Me(18,new fe(2,15),new fe(2,16)),new Me(22,new fe(2,11),new fe(2,12))),new rn(6,Int32Array.from([6,34]),new Me(18,new fe(2,68)),new Me(16,new fe(4,27)),new Me(24,new fe(4,19)),new Me(28,new fe(4,15))),new rn(7,Int32Array.from([6,22,38]),new Me(20,new fe(2,78)),new Me(18,new fe(4,31)),new Me(18,new fe(2,14),new fe(4,15)),new Me(26,new fe(4,13),new fe(1,14))),new rn(8,Int32Array.from([6,24,42]),new Me(24,new fe(2,97)),new Me(22,new fe(2,38),new fe(2,39)),new Me(22,new fe(4,18),new fe(2,19)),new Me(26,new fe(4,14),new fe(2,15))),new rn(9,Int32Array.from([6,26,46]),new Me(30,new fe(2,116)),new Me(22,new fe(3,36),new fe(2,37)),new Me(20,new fe(4,16),new fe(4,17)),new Me(24,new fe(4,12),new fe(4,13))),new rn(10,Int32Array.from([6,28,50]),new Me(18,new fe(2,68),new fe(2,69)),new Me(26,new fe(4,43),new fe(1,44)),new Me(24,new fe(6,19),new fe(2,20)),new Me(28,new fe(6,15),new fe(2,16))),new rn(11,Int32Array.from([6,30,54]),new Me(20,new fe(4,81)),new Me(30,new fe(1,50),new fe(4,51)),new Me(28,new fe(4,22),new fe(4,23)),new Me(24,new fe(3,12),new fe(8,13))),new rn(12,Int32Array.from([6,32,58]),new Me(24,new fe(2,92),new fe(2,93)),new Me(22,new fe(6,36),new fe(2,37)),new Me(26,new fe(4,20),new fe(6,21)),new Me(28,new fe(7,14),new fe(4,15))),new rn(13,Int32Array.from([6,34,62]),new Me(26,new fe(4,107)),new Me(22,new fe(8,37),new fe(1,38)),new Me(24,new fe(8,20),new fe(4,21)),new Me(22,new fe(12,11),new fe(4,12))),new rn(14,Int32Array.from([6,26,46,66]),new Me(30,new fe(3,115),new fe(1,116)),new Me(24,new fe(4,40),new fe(5,41)),new Me(20,new fe(11,16),new fe(5,17)),new Me(24,new fe(11,12),new fe(5,13))),new rn(15,Int32Array.from([6,26,48,70]),new Me(22,new fe(5,87),new fe(1,88)),new Me(24,new fe(5,41),new fe(5,42)),new Me(30,new fe(5,24),new fe(7,25)),new Me(24,new fe(11,12),new fe(7,13))),new rn(16,Int32Array.from([6,26,50,74]),new Me(24,new fe(5,98),new fe(1,99)),new Me(28,new fe(7,45),new fe(3,46)),new Me(24,new fe(15,19),new fe(2,20)),new Me(30,new fe(3,15),new fe(13,16))),new rn(17,Int32Array.from([6,30,54,78]),new Me(28,new fe(1,107),new fe(5,108)),new Me(28,new fe(10,46),new fe(1,47)),new Me(28,new fe(1,22),new fe(15,23)),new Me(28,new fe(2,14),new fe(17,15))),new rn(18,Int32Array.from([6,30,56,82]),new Me(30,new fe(5,120),new fe(1,121)),new Me(26,new fe(9,43),new fe(4,44)),new Me(28,new fe(17,22),new fe(1,23)),new Me(28,new fe(2,14),new fe(19,15))),new rn(19,Int32Array.from([6,30,58,86]),new Me(28,new fe(3,113),new fe(4,114)),new Me(26,new fe(3,44),new fe(11,45)),new Me(26,new fe(17,21),new fe(4,22)),new Me(26,new fe(9,13),new fe(16,14))),new rn(20,Int32Array.from([6,34,62,90]),new Me(28,new fe(3,107),new fe(5,108)),new Me(26,new fe(3,41),new fe(13,42)),new Me(30,new fe(15,24),new fe(5,25)),new Me(28,new fe(15,15),new fe(10,16))),new rn(21,Int32Array.from([6,28,50,72,94]),new Me(28,new fe(4,116),new fe(4,117)),new Me(26,new fe(17,42)),new Me(28,new fe(17,22),new fe(6,23)),new Me(30,new fe(19,16),new fe(6,17))),new rn(22,Int32Array.from([6,26,50,74,98]),new Me(28,new fe(2,111),new fe(7,112)),new Me(28,new fe(17,46)),new Me(30,new fe(7,24),new fe(16,25)),new Me(24,new fe(34,13))),new rn(23,Int32Array.from([6,30,54,78,102]),new Me(30,new fe(4,121),new fe(5,122)),new Me(28,new fe(4,47),new fe(14,48)),new Me(30,new fe(11,24),new fe(14,25)),new Me(30,new fe(16,15),new fe(14,16))),new rn(24,Int32Array.from([6,28,54,80,106]),new Me(30,new fe(6,117),new fe(4,118)),new Me(28,new fe(6,45),new fe(14,46)),new Me(30,new fe(11,24),new fe(16,25)),new Me(30,new fe(30,16),new fe(2,17))),new rn(25,Int32Array.from([6,32,58,84,110]),new Me(26,new fe(8,106),new fe(4,107)),new Me(28,new fe(8,47),new fe(13,48)),new Me(30,new fe(7,24),new fe(22,25)),new Me(30,new fe(22,15),new fe(13,16))),new rn(26,Int32Array.from([6,30,58,86,114]),new Me(28,new fe(10,114),new fe(2,115)),new Me(28,new fe(19,46),new fe(4,47)),new Me(28,new fe(28,22),new fe(6,23)),new Me(30,new fe(33,16),new fe(4,17))),new rn(27,Int32Array.from([6,34,62,90,118]),new Me(30,new fe(8,122),new fe(4,123)),new Me(28,new fe(22,45),new fe(3,46)),new Me(30,new fe(8,23),new fe(26,24)),new Me(30,new fe(12,15),new fe(28,16))),new rn(28,Int32Array.from([6,26,50,74,98,122]),new Me(30,new fe(3,117),new fe(10,118)),new Me(28,new fe(3,45),new fe(23,46)),new Me(30,new fe(4,24),new fe(31,25)),new Me(30,new fe(11,15),new fe(31,16))),new rn(29,Int32Array.from([6,30,54,78,102,126]),new Me(30,new fe(7,116),new fe(7,117)),new Me(28,new fe(21,45),new fe(7,46)),new Me(30,new fe(1,23),new fe(37,24)),new Me(30,new fe(19,15),new fe(26,16))),new rn(30,Int32Array.from([6,26,52,78,104,130]),new Me(30,new fe(5,115),new fe(10,116)),new Me(28,new fe(19,47),new fe(10,48)),new Me(30,new fe(15,24),new fe(25,25)),new Me(30,new fe(23,15),new fe(25,16))),new rn(31,Int32Array.from([6,30,56,82,108,134]),new Me(30,new fe(13,115),new fe(3,116)),new Me(28,new fe(2,46),new fe(29,47)),new Me(30,new fe(42,24),new fe(1,25)),new Me(30,new fe(23,15),new fe(28,16))),new rn(32,Int32Array.from([6,34,60,86,112,138]),new Me(30,new fe(17,115)),new Me(28,new fe(10,46),new fe(23,47)),new Me(30,new fe(10,24),new fe(35,25)),new Me(30,new fe(19,15),new fe(35,16))),new rn(33,Int32Array.from([6,30,58,86,114,142]),new Me(30,new fe(17,115),new fe(1,116)),new Me(28,new fe(14,46),new fe(21,47)),new Me(30,new fe(29,24),new fe(19,25)),new Me(30,new fe(11,15),new fe(46,16))),new rn(34,Int32Array.from([6,34,62,90,118,146]),new Me(30,new fe(13,115),new fe(6,116)),new Me(28,new fe(14,46),new fe(23,47)),new Me(30,new fe(44,24),new fe(7,25)),new Me(30,new fe(59,16),new fe(1,17))),new rn(35,Int32Array.from([6,30,54,78,102,126,150]),new Me(30,new fe(12,121),new fe(7,122)),new Me(28,new fe(12,47),new fe(26,48)),new Me(30,new fe(39,24),new fe(14,25)),new Me(30,new fe(22,15),new fe(41,16))),new rn(36,Int32Array.from([6,24,50,76,102,128,154]),new Me(30,new fe(6,121),new fe(14,122)),new Me(28,new fe(6,47),new fe(34,48)),new Me(30,new fe(46,24),new fe(10,25)),new Me(30,new fe(2,15),new fe(64,16))),new rn(37,Int32Array.from([6,28,54,80,106,132,158]),new Me(30,new fe(17,122),new fe(4,123)),new Me(28,new fe(29,46),new fe(14,47)),new Me(30,new fe(49,24),new fe(10,25)),new Me(30,new fe(24,15),new fe(46,16))),new rn(38,Int32Array.from([6,32,58,84,110,136,162]),new Me(30,new fe(4,122),new fe(18,123)),new Me(28,new fe(13,46),new fe(32,47)),new Me(30,new fe(48,24),new fe(14,25)),new Me(30,new fe(42,15),new fe(32,16))),new rn(39,Int32Array.from([6,26,54,82,110,138,166]),new Me(30,new fe(20,117),new fe(4,118)),new Me(28,new fe(40,47),new fe(7,48)),new Me(30,new fe(43,24),new fe(22,25)),new Me(30,new fe(10,15),new fe(67,16))),new rn(40,Int32Array.from([6,30,58,86,114,142,170]),new Me(30,new fe(19,118),new fe(6,119)),new Me(28,new fe(18,47),new fe(31,48)),new Me(30,new fe(34,24),new fe(34,25)),new Me(30,new fe(20,15),new fe(61,16)))];var ai;(function(ee){ee[ee.DATA_MASK_000=0]="DATA_MASK_000",ee[ee.DATA_MASK_001=1]="DATA_MASK_001",ee[ee.DATA_MASK_010=2]="DATA_MASK_010",ee[ee.DATA_MASK_011=3]="DATA_MASK_011",ee[ee.DATA_MASK_100=4]="DATA_MASK_100",ee[ee.DATA_MASK_101=5]="DATA_MASK_101",ee[ee.DATA_MASK_110=6]="DATA_MASK_110",ee[ee.DATA_MASK_111=7]="DATA_MASK_111"})(ai||(ai={}));class oi{constructor(u,p){this.value=u,this.isMasked=p}unmaskBitMatrix(u,p){for(let g=0;g(ee+u&1)===0)],[ai.DATA_MASK_001,new oi(ai.DATA_MASK_001,(ee,u)=>(ee&1)===0)],[ai.DATA_MASK_010,new oi(ai.DATA_MASK_010,(ee,u)=>u%3===0)],[ai.DATA_MASK_011,new oi(ai.DATA_MASK_011,(ee,u)=>(ee+u)%3===0)],[ai.DATA_MASK_100,new oi(ai.DATA_MASK_100,(ee,u)=>(Math.floor(ee/2)+Math.floor(u/3)&1)===0)],[ai.DATA_MASK_101,new oi(ai.DATA_MASK_101,(ee,u)=>ee*u%6===0)],[ai.DATA_MASK_110,new oi(ai.DATA_MASK_110,(ee,u)=>ee*u%6<3)],[ai.DATA_MASK_111,new oi(ai.DATA_MASK_111,(ee,u)=>(ee+u+ee*u%3&1)===0)]]);class yi{constructor(u){const p=u.getHeight();if(p<21||(p&3)!==1)throw new z;this.bitMatrix=u}readFormatInformation(){if(this.parsedFormatInfo!==null&&this.parsedFormatInfo!==void 0)return this.parsedFormatInfo;let u=0;for(let v=0;v<6;v++)u=this.copyBit(v,8,u);u=this.copyBit(7,8,u),u=this.copyBit(8,8,u),u=this.copyBit(8,7,u);for(let v=5;v>=0;v--)u=this.copyBit(8,v,u);const p=this.bitMatrix.getHeight();let g=0;const b=p-7;for(let v=p-1;v>=b;v--)g=this.copyBit(8,v,g);for(let v=p-8;v=0;E--)for(let S=u-9;S>=b;S--)g=this.copyBit(S,E,g);let v=rn.decodeVersionInformation(g);if(v!==null&&v.getDimensionForVersion()===u)return this.parsedVersion=v,v;g=0;for(let E=5;E>=0;E--)for(let S=u-9;S>=b;S--)g=this.copyBit(E,S,g);if(v=rn.decodeVersionInformation(g),v!==null&&v.getDimensionForVersion()===u)return this.parsedVersion=v,v;throw new z}copyBit(u,p,g){return(this.isMirror?this.bitMatrix.get(p,u):this.bitMatrix.get(u,p))?g<<1|1:g<<1}readCodewords(){const u=this.readFormatInformation(),p=this.readVersion(),g=oi.values.get(u.getDataMask()),b=this.bitMatrix.getHeight();g.unmaskBitMatrix(this.bitMatrix,b);const v=p.buildFunctionPattern();let E=!0;const S=new Uint8Array(p.getTotalCodewords());let O=0,M=0,W=0;for(let ne=b-1;ne>0;ne-=2){ne===6&&ne--;for(let oe=0;oe=0&&S[W].codewords.length!==M;)W--;W++;const ne=M-b.getECCodewordsPerBlock();let oe=0;for(let _e=0;_eu.available())throw new z;const b=new Uint8Array(2*g);let v=0;for(;g>0;){const E=u.readBits(13);let S=E/96<<8&4294967295|E%96;S<959?S+=41377:S+=42657,b[v]=S>>8&255,b[v+1]=S&255,v+=2,g--}try{p.append(Q.decode(b,Y.GB2312))}catch(E){throw new z(E)}}static decodeKanjiSegment(u,p,g){if(g*13>u.available())throw new z;const b=new Uint8Array(2*g);let v=0;for(;g>0;){const E=u.readBits(13);let S=E/192<<8&4294967295|E%192;S<7936?S+=33088:S+=49472,b[v]=S>>8,b[v+1]=S,v+=2,g--}try{p.append(Q.decode(b,Y.SHIFT_JIS))}catch(E){throw new z(E)}}static decodeByteSegment(u,p,g,b,v,E){if(8*g>u.available())throw new z;const S=new Uint8Array(g);for(let M=0;M=wr.ALPHANUMERIC_CHARS.length)throw new z;return wr.ALPHANUMERIC_CHARS[u]}static decodeAlphanumericSegment(u,p,g,b){const v=p.length();for(;g>1;){if(u.available()<11)throw new z;const E=u.readBits(11);p.append(wr.toAlphaNumericChar(Math.floor(E/45))),p.append(wr.toAlphaNumericChar(E%45)),g-=2}if(g===1){if(u.available()<6)throw new z;p.append(wr.toAlphaNumericChar(u.readBits(6)))}if(b)for(let E=v;E=3;){if(u.available()<10)throw new z;const b=u.readBits(10);if(b>=1e3)throw new z;p.append(wr.toAlphaNumericChar(Math.floor(b/100))),p.append(wr.toAlphaNumericChar(Math.floor(b/10)%10)),p.append(wr.toAlphaNumericChar(b%10)),g-=3}if(g===2){if(u.available()<7)throw new z;const b=u.readBits(7);if(b>=100)throw new z;p.append(wr.toAlphaNumericChar(Math.floor(b/10))),p.append(wr.toAlphaNumericChar(b%10))}else if(g===1){if(u.available()<4)throw new z;const b=u.readBits(4);if(b>=10)throw new z;p.append(wr.toAlphaNumericChar(b))}}static parseECIValue(u){const p=u.readBits(8);if((p&128)===0)return p&127;if((p&192)===128){const g=u.readBits(8);return(p&63)<<8&4294967295|g}if((p&224)===192){const g=u.readBits(16);return(p&31)<<16&4294967295|g}throw new z}}wr.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",wr.GB2312_SUBSET=1;class na{constructor(u){this.mirrored=u}isMirrored(){return this.mirrored}applyMirroredCorrection(u){if(!this.mirrored||u===null||u.length<3)return;const p=u[0];u[0]=u[2],u[2]=p}}class Ms{constructor(){this.rsDecoder=new Ft(sn.QR_CODE_FIELD_256)}decodeBooleanArray(u,p){return this.decodeBitMatrix(he.parseFromBooleanArray(u),p)}decodeBitMatrix(u,p){const g=new yi(u);let b=null;try{return this.decodeBitMatrixParser(g,p)}catch(v){b=v}try{g.remask(),g.setMirror(!0),g.readVersion(),g.readFormatInformation(),g.mirror();const v=this.decodeBitMatrixParser(g,p);return v.setOther(new na(!0)),v}catch(v){throw b!==null?b:v}}decodeBitMatrixParser(u,p){const g=u.readVersion(),b=u.readFormatInformation().getErrorCorrectionLevel(),v=u.readCodewords(),E=gi.getDataBlocks(v,g,b);let S=0;for(const W of E)S+=W.getNumDataCodewords();const O=new Uint8Array(S);let M=0;for(const W of E){const ne=W.getCodewords(),oe=W.getNumDataCodewords();this.correctErrors(ne,oe);for(let ye=0;ye=g)return!1;return!0}crossCheckVertical(u,p,g,b){const v=this.image,E=v.getHeight(),S=this.crossCheckStateCount;S[0]=0,S[1]=0,S[2]=0;let O=u;for(;O>=0&&v.get(p,O)&&S[1]<=g;)S[1]++,O--;if(O<0||S[1]>g)return NaN;for(;O>=0&&!v.get(p,O)&&S[0]<=g;)S[0]++,O--;if(S[0]>g)return NaN;for(O=u+1;Og)return NaN;for(;Og)return NaN;const M=S[0]+S[1]+S[2];return 5*Math.abs(M-b)>=2*b?NaN:this.foundPatternCross(S)?ks.centerFromEnd(S,O):NaN}handlePossibleCenter(u,p,g){const b=u[0]+u[1]+u[2],v=ks.centerFromEnd(u,g),E=this.crossCheckVertical(p,v,2*u[1],b);if(!isNaN(E)){const S=(u[0]+u[1]+u[2])/3;for(const M of this.possibleCenters)if(M.aboutEquals(S,E,v))return M.combineEstimate(E,v,S);const O=new Pa(v,E,S);this.possibleCenters.push(O),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(O)}return null}}class Nl extends It{constructor(u,p,g,b){super(u,p),this.estimatedModuleSize=g,this.count=b,b===void 0&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(u,p,g){if(Math.abs(p-this.getY())<=u&&Math.abs(g-this.getX())<=u){const b=Math.abs(u-this.estimatedModuleSize);return b<=1||b<=this.estimatedModuleSize}return!1}combineEstimate(u,p,g){const b=this.count+1,v=(this.count*this.getX()+p)/b,E=(this.count*this.getY()+u)/b,S=(this.count*this.estimatedModuleSize+g)/b;return new Nl(v,E,S,b)}}class Ks{constructor(u){this.bottomLeft=u[0],this.topLeft=u[1],this.topRight=u[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class Si{constructor(u,p){this.image=u,this.resultPointCallback=p,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=p}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(u){const p=u!=null&&u.get(K.TRY_HARDER)!==void 0,g=u!=null&&u.get(K.PURE_BARCODE)!==void 0,b=this.image,v=b.getHeight(),E=b.getWidth();let S=Math.floor(3*v/(4*Si.MAX_MODULES));(SM[2]&&(ne+=Ie-M[2]-S,ye=E-1)}else{M[0]=M[2],M[1]=M[3],M[2]=M[4],M[3]=1,M[4]=0,oe=3;continue}oe=0,M[0]=0,M[1]=0,M[2]=0,M[3]=0,M[4]=0}else M[0]=M[2],M[1]=M[3],M[2]=M[4],M[3]=1,M[4]=0,oe=3;else M[++oe]++;else M[oe]++;Si.foundPatternCross(M)&&this.handlePossibleCenter(M,ne,E,g)===!0&&(S=M[0],this.hasSkipped&&(O=this.haveMultiplyConfirmedCenters()))}const W=this.selectBestPatterns();return It.orderBestPatterns(W),new Ks(W)}static centerFromEnd(u,p){return p-u[4]-u[3]-u[2]/2}static foundPatternCross(u){let p=0;for(let v=0;v<5;v++){const E=u[v];if(E===0)return!1;p+=E}if(p<7)return!1;const g=p/7,b=g/2;return Math.abs(g-u[0])=E&&p>=E&&S.get(p-E,u-E);)v[2]++,E++;if(u=E&&p>=E&&!S.get(p-E,u-E)&&v[1]<=g;)v[1]++,E++;if(ug)return!1;for(;u>=E&&p>=E&&S.get(p-E,u-E)&&v[0]<=g;)v[0]++,E++;if(v[0]>g)return!1;const O=S.getHeight(),M=S.getWidth();for(E=1;u+E=O||p+E>=M)return!1;for(;u+E=O||p+E>=M||v[3]>=g)return!1;for(;u+E=g)return!1;const W=v[0]+v[1]+v[2]+v[3]+v[4];return Math.abs(W-b)<2*b&&Si.foundPatternCross(v)}crossCheckVertical(u,p,g,b){const v=this.image,E=v.getHeight(),S=this.getCrossCheckStateCount();let O=u;for(;O>=0&&v.get(p,O);)S[2]++,O--;if(O<0)return NaN;for(;O>=0&&!v.get(p,O)&&S[1]<=g;)S[1]++,O--;if(O<0||S[1]>g)return NaN;for(;O>=0&&v.get(p,O)&&S[0]<=g;)S[0]++,O--;if(S[0]>g)return NaN;for(O=u+1;O=g)return NaN;for(;O=g)return NaN;const M=S[0]+S[1]+S[2]+S[3]+S[4];return 5*Math.abs(M-b)>=2*b?NaN:Si.foundPatternCross(S)?Si.centerFromEnd(S,O):NaN}crossCheckHorizontal(u,p,g,b){const v=this.image,E=v.getWidth(),S=this.getCrossCheckStateCount();let O=u;for(;O>=0&&v.get(O,p);)S[2]++,O--;if(O<0)return NaN;for(;O>=0&&!v.get(O,p)&&S[1]<=g;)S[1]++,O--;if(O<0||S[1]>g)return NaN;for(;O>=0&&v.get(O,p)&&S[0]<=g;)S[0]++,O--;if(S[0]>g)return NaN;for(O=u+1;O=g)return NaN;for(;O=g)return NaN;const M=S[0]+S[1]+S[2]+S[3]+S[4];return 5*Math.abs(M-b)>=b?NaN:Si.foundPatternCross(S)?Si.centerFromEnd(S,O):NaN}handlePossibleCenter(u,p,g,b){const v=u[0]+u[1]+u[2]+u[3]+u[4];let E=Si.centerFromEnd(u,g),S=this.crossCheckVertical(p,Math.floor(E),u[2],v);if(!isNaN(S)&&(E=this.crossCheckHorizontal(Math.floor(E),Math.floor(S),u[2],v),!isNaN(E)&&(!b||this.crossCheckDiagonal(Math.floor(S),Math.floor(E),u[2],v)))){const O=v/7;let M=!1;const W=this.possibleCenters;for(let ne=0,oe=W.length;ne=Si.CENTER_QUORUM)if(p==null)p=g;else return this.hasSkipped=!0,Math.floor((Math.abs(p.getX()-g.getX())-Math.abs(p.getY()-g.getY()))/2);return 0}haveMultiplyConfirmedCenters(){let u=0,p=0;const g=this.possibleCenters.length;for(const E of this.possibleCenters)E.getCount()>=Si.CENTER_QUORUM&&(u++,p+=E.getEstimatedModuleSize());if(u<3)return!1;const b=p/g;let v=0;for(const E of this.possibleCenters)v+=Math.abs(E.getEstimatedModuleSize()-b);return v<=.05*p}selectBestPatterns(){const u=this.possibleCenters.length;if(u<3)throw new te;const p=this.possibleCenters;let g;if(u>3){let b=0,v=0;for(const O of this.possibleCenters){const M=O.getEstimatedModuleSize();b+=M,v+=M*M}g=b/u;let E=Math.sqrt(v/u-g*g);p.sort((O,M)=>{const W=Math.abs(M.getEstimatedModuleSize()-g),ne=Math.abs(O.getEstimatedModuleSize()-g);return Wne?1:0});const S=Math.max(.2*g,E);for(let O=0;O3;O++){const M=p[O];Math.abs(M.getEstimatedModuleSize()-g)>S&&(p.splice(O,1),O--)}}if(p.length>3){let b=0;for(const v of p)b+=v.getEstimatedModuleSize();g=b/p.length,p.sort((v,E)=>{if(E.getCount()===v.getCount()){const S=Math.abs(E.getEstimatedModuleSize()-g),O=Math.abs(v.getEstimatedModuleSize()-g);return SO?-1:0}else return E.getCount()-v.getCount()}),p.splice(3)}return[p[0],p[1],p[2]]}}Si.CENTER_QUORUM=2,Si.MIN_SKIP=3,Si.MAX_MODULES=57;class Cs{constructor(u){this.image=u}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(u){this.resultPointCallback=u==null?null:u.get(K.NEED_RESULT_POINT_CALLBACK);const g=new Si(this.image,this.resultPointCallback).find(u);return this.processFinderPatternInfo(g)}processFinderPatternInfo(u){const p=u.getTopLeft(),g=u.getTopRight(),b=u.getBottomLeft(),v=this.calculateModuleSize(p,g,b);if(v<1)throw new te("No pattern found in proccess finder.");const E=Cs.computeDimension(p,g,b,v),S=rn.getProvisionalVersionForDimension(E),O=S.getDimensionForVersion()-7;let M=null;if(S.getAlignmentPatternCenters().length>0){const ye=g.getX()-p.getX()+b.getX(),_e=g.getY()-p.getY()+b.getY(),Ie=1-3/O,Ke=Math.floor(p.getX()+Ie*(ye-p.getX())),ct=Math.floor(p.getY()+Ie*(_e-p.getY()));for(let Gt=4;Gt<=16;Gt<<=1)try{M=this.findAlignmentInRegion(v,Ke,ct,Gt);break}catch($t){if(!($t instanceof te))throw $t}}const W=Cs.createTransform(p,g,b,M,E),ne=Cs.sampleGrid(this.image,W,E);let oe;return M===null?oe=[b,p,g]:oe=[b,p,g,M],new ln(ne,oe)}static createTransform(u,p,g,b,v){const E=v-3.5;let S,O,M,W;return b!==null?(S=b.getX(),O=b.getY(),M=E-3,W=M):(S=p.getX()-u.getX()+g.getX(),O=p.getY()-u.getY()+g.getY(),M=E,W=E),Ve.quadrilateralToQuadrilateral(3.5,3.5,E,3.5,M,W,3.5,E,u.getX(),u.getY(),p.getX(),p.getY(),S,O,g.getX(),g.getY())}static sampleGrid(u,p,g){return nn.getInstance().sampleGridWithTransform(u,g,g,p)}static computeDimension(u,p,g,b){const v=Ze.round(It.distance(u,p)/b),E=Ze.round(It.distance(u,g)/b);let S=Math.floor((v+E)/2)+7;switch(S&3){case 0:S++;break;case 2:S--;break;case 3:throw new te("Dimensions could be not found.")}return S}calculateModuleSize(u,p,g){return(this.calculateModuleSizeOneWay(u,p)+this.calculateModuleSizeOneWay(u,g))/2}calculateModuleSizeOneWay(u,p){const g=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(u.getX()),Math.floor(u.getY()),Math.floor(p.getX()),Math.floor(p.getY())),b=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(p.getX()),Math.floor(p.getY()),Math.floor(u.getX()),Math.floor(u.getY()));return isNaN(g)?b/7:isNaN(b)?g/7:(g+b)/14}sizeOfBlackWhiteBlackRunBothWays(u,p,g,b){let v=this.sizeOfBlackWhiteBlackRun(u,p,g,b),E=1,S=u-(g-u);S<0?(E=u/(u-S),S=0):S>=this.image.getWidth()&&(E=(this.image.getWidth()-1-u)/(S-u),S=this.image.getWidth()-1);let O=Math.floor(p-(b-p)*E);return E=1,O<0?(E=p/(p-O),O=0):O>=this.image.getHeight()&&(E=(this.image.getHeight()-1-p)/(O-p),O=this.image.getHeight()-1),S=Math.floor(u+(S-u)*E),v+=this.sizeOfBlackWhiteBlackRun(u,p,S,O),v-1}sizeOfBlackWhiteBlackRun(u,p,g,b){const v=Math.abs(b-p)>Math.abs(g-u);if(v){let ye=u;u=p,p=ye,ye=g,g=b,b=ye}const E=Math.abs(g-u),S=Math.abs(b-p);let O=-E/2;const M=u0){if(_e===b)break;_e+=W,O-=E}}return ne===2?Ze.distance(g+M,b,u,p):NaN}findAlignmentInRegion(u,p,g,b){const v=Math.floor(b*u),E=Math.max(0,p-v),S=Math.min(this.image.getWidth()-1,p+v);if(S-E=O||v>=E)throw new te;if(E-v!==O-S&&(O=S+(E-v),O>=u.getWidth()))throw new te;const M=Math.round((O-S+1)/b),W=Math.round((E-v+1)/b);if(M<=0||W<=0)throw new te;if(W!==M)throw new te;const ne=Math.floor(b/2);v+=ne,S+=ne;const oe=S+Math.floor((M-1)*b)-O;if(oe>0){if(oe>ne)throw new te;S-=oe}const ye=v+Math.floor((W-1)*b)-E;if(ye>0){if(ye>ne)throw new te;v-=ye}const _e=new he(M,W);for(let Ie=0;Ie0;){const oe=Yn.findGuardPattern(u,v,--b,g,!1,E,M);if(oe!=null)ne=oe;else{b++;break}}S[0]=new It(ne[0],b),S[1]=new It(ne[1],b),O=!0;break}}let W=b+1;if(O){let ne=0,oe=Int32Array.from([Math.trunc(S[0].getX()),Math.trunc(S[1].getX())]);for(;WYn.SKIPPED_ROW_COUNT_MAX)break;ne++}}W-=ne+1,S[2]=new It(oe[0],W),S[3]=new It(oe[1],W)}return W-b0&&M++ne?W-ne:ne-W;if(oe>g)return 1/0;O+=oe}return O/v}}Yn.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),Yn.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),Yn.MAX_AVG_VARIANCE=.42,Yn.MAX_INDIVIDUAL_VARIANCE=.8,Yn.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),Yn.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),Yn.MAX_PIXEL_DRIFT=3,Yn.MAX_PATTERN_DRIFT=5,Yn.SKIPPED_ROW_COUNT_MAX=25,Yn.ROW_STEP=5,Yn.BARCODE_MIN_HEIGHT=10;class li{constructor(u,p){if(p.length===0)throw new y;this.field=u;let g=p.length;if(g>1&&p[0]===0){let b=1;for(;bg.length){let E=p;p=g,g=E}let b=new Int32Array(g.length),v=g.length-p.length;I.arraycopy(g,0,b,0,v);for(let E=v;E=0;p--){let g=this.getCoefficient(p);g!==0&&(g<0?(u.append(" - "),g=-g):u.length()>0&&u.append(" + "),(p===0||g!==1)&&u.append(g),p!==0&&(p===1?u.append("x"):(u.append("x^"),u.append(p))))}return u.toString()}}class To{add(u,p){return(u+p)%this.modulus}subtract(u,p){return(this.modulus+u-p)%this.modulus}exp(u){return this.expTable[u]}log(u){if(u===0)throw new y;return this.logTable[u]}inverse(u){if(u===0)throw new dt;return this.expTable[this.modulus-this.logTable[u]-1]}multiply(u,p){return u===0||p===0?0:this.expTable[(this.logTable[u]+this.logTable[p])%(this.modulus-1)]}getSize(){return this.modulus}equals(u){return u===this}}class zr extends To{constructor(u,p){super(),this.modulus=u,this.expTable=new Int32Array(u),this.logTable=new Int32Array(u);let g=1;for(let b=0;b0;_e--){let Ie=b.evaluateAt(this.field.exp(_e));v[p-_e]=Ie,Ie!==0&&(E=!0)}if(!E)return 0;let S=this.field.getOne();if(g!=null)for(const _e of g){let Ie=this.field.exp(u.length-1-_e),Ke=new li(this.field,new Int32Array([this.field.subtract(0,Ie),1]));S=S.multiply(Ke)}let O=new li(this.field,v),M=this.runEuclideanAlgorithm(this.field.buildMonomial(p,1),O,p),W=M[0],ne=M[1],oe=this.findErrorLocations(W),ye=this.findErrorMagnitudes(ne,W,oe);for(let _e=0;_e=Math.round(g/2);){let oe=b,ye=E;if(b=v,E=S,b.isZero())throw A.getChecksumInstance();v=oe;let _e=this.field.getZero(),Ie=b.getCoefficient(b.getDegree()),Ke=this.field.inverse(Ie);for(;v.getDegree()>=b.getDegree()&&!v.isZero();){let ct=v.getDegree()-b.getDegree(),Gt=this.field.multiply(v.getCoefficient(v.getDegree()),Ke);_e=_e.add(this.field.buildMonomial(ct,Gt)),v=v.subtract(b.multiplyByMonomial(ct,Gt))}S=_e.multiply(E).subtract(ye).negative()}let O=S.getCoefficient(0);if(O===0)throw A.getChecksumInstance();let M=this.field.inverse(O),W=S.multiply(M),ne=v.multiply(M);return[W,ne]}findErrorLocations(u){let p=u.getDegree(),g=new Int32Array(p),b=0;for(let v=1;v0){let O=g?this.topLeft:this.topRight,M=Math.trunc(O.getY()-u);M<0&&(M=0);let W=new It(O.getX(),M);g?b=W:E=W}if(p>0){let O=g?this.bottomLeft:this.bottomRight,M=Math.trunc(O.getY()+p);M>=this.image.getHeight()&&(M=this.image.getHeight()-1);let W=new It(O.getX(),M);g?v=W:S=W}return new Us(this.image,b,v,E,S)}getMinX(){return this.minX}getMaxX(){return this.maxX}getMinY(){return this.minY}getMaxY(){return this.maxY}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}getBottomLeft(){return this.bottomLeft}getBottomRight(){return this.bottomRight}}class Qo{constructor(u,p,g,b){this.columnCount=u,this.errorCorrectionLevel=b,this.rowCountUpperPart=p,this.rowCountLowerPart=g,this.rowCount=p+g}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class Ya{constructor(){this.buffer=""}static form(u,p){let g=-1;function b(E,S,O,M,W,ne){if(E==="%%")return"%";if(p[++g]===void 0)return;E=M?parseInt(M.substr(1)):void 0;let oe=W?parseInt(W.substr(1)):void 0,ye;switch(ne){case"s":ye=p[g];break;case"c":ye=p[g][0];break;case"f":ye=parseFloat(p[g]).toFixed(E);break;case"p":ye=parseFloat(p[g]).toPrecision(E);break;case"e":ye=parseFloat(p[g]).toExponential(E);break;case"x":ye=parseInt(p[g]).toString(oe||16);break;case"d":ye=parseFloat(parseInt(p[g],oe||10).toPrecision(E)).toFixed(0);break}ye=typeof ye=="object"?JSON.stringify(ye):(+ye).toString(oe);let _e=parseInt(O),Ie=O&&O[0]+""=="0"?"0":" ";for(;ye.length<_e;)ye=S!==void 0?ye+Ie:Ie+ye;return ye}let v=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return u.replace(v,b)}format(u,...p){this.buffer+=Ya.form(u,p)}toString(){return this.buffer}}class pa{constructor(u){this.boundingBox=new Us(u),this.codewords=new Array(u.getMaxY()-u.getMinY()+1)}getCodewordNearby(u){let p=this.getCodeword(u);if(p!=null)return p;for(let g=1;g=0&&(p=this.codewords[b],p!=null)||(b=this.imageRowToCodewordIndex(u)+g,bg,getValue:()=>b};v.getValue()>u?(u=v.getValue(),p=[],p.push(v.getKey())):v.getValue()===u&&p.push(v.getKey())}return Gn.toIntArray(p)}getConfidence(u){return this.values.get(u)}}class ma extends pa{constructor(u,p){super(u),this._isLeft=p}setRowNumbers(){for(let u of this.getCodewords())u!=null&&u.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(u){let p=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(p,u);let g=this.getBoundingBox(),b=this._isLeft?g.getTopLeft():g.getTopRight(),v=this._isLeft?g.getBottomLeft():g.getBottomRight(),E=this.imageRowToCodewordIndex(Math.trunc(b.getY())),S=this.imageRowToCodewordIndex(Math.trunc(v.getY())),O=-1,M=1,W=0;for(let ne=E;ne=u.getRowCount()||ye>ne)p[ne]=null;else{let _e;M>2?_e=(M-2)*ye:_e=ye;let Ie=_e>=ne;for(let Ke=1;Ke<=_e&&!Ie;Ke++)Ie=p[ne-Ke]!=null;Ie?p[ne]=null:(O=oe.getRowNumber(),W=1)}}}getRowHeights(){let u=this.getBarcodeMetadata();if(u==null)return null;this.adjustIncompleteIndicatorColumnRowNumbers(u);let p=new Int32Array(u.getRowCount());for(let g of this.getCodewords())if(g!=null){let b=g.getRowNumber();if(b>=p.length)continue;p[b]++}return p}adjustIncompleteIndicatorColumnRowNumbers(u){let p=this.getBoundingBox(),g=this._isLeft?p.getTopLeft():p.getTopRight(),b=this._isLeft?p.getBottomLeft():p.getBottomRight(),v=this.imageRowToCodewordIndex(Math.trunc(g.getY())),E=this.imageRowToCodewordIndex(Math.trunc(b.getY())),S=this.getCodewords(),O=-1;for(let M=v;M=u.getRowCount()?S[M]=null:O=W.getRowNumber())}}getBarcodeMetadata(){let u=this.getCodewords(),p=new bs,g=new bs,b=new bs,v=new bs;for(let S of u){if(S==null)continue;S.setRowNumberAsRowIndicatorColumn();let O=S.getValue()%30,M=S.getRowNumber();switch(this._isLeft||(M+=2),M%3){case 0:g.setValue(O*3+1);break;case 1:v.setValue(O/3),b.setValue(O%3);break;case 2:p.setValue(O+1);break}}if(p.getValue().length===0||g.getValue().length===0||b.getValue().length===0||v.getValue().length===0||p.getValue()[0]<1||g.getValue()[0]+b.getValue()[0]Gn.MAX_ROWS_IN_BARCODE)return null;let E=new Qo(p.getValue()[0],g.getValue()[0],b.getValue()[0],v.getValue()[0]);return this.removeIncorrectCodewords(u,E),E}removeIncorrectCodewords(u,p){for(let g=0;gp.getRowCount()){u[g]=null;continue}switch(this._isLeft||(E+=2),E%3){case 0:v*3+1!==p.getRowCountUpperPart()&&(u[g]=null);break;case 1:(Math.trunc(v/3)!==p.getErrorCorrectionLevel()||v%3!==p.getRowCountLowerPart())&&(u[g]=null);break;case 2:v+1!==p.getColumnCount()&&(u[g]=null);break}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+` `+super.toString()}}class Vr{constructor(u,p){this.ADJUST_ROW_NUMBER_SKIP=2,this.barcodeMetadata=u,this.barcodeColumnCount=u.getColumnCount(),this.boundingBox=p,this.detectionResultColumns=new Array(this.barcodeColumnCount+2)}getDetectionResultColumns(){this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]),this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount+1]);let u=Gn.MAX_CODEWORDS_IN_BARCODE,p;do p=u,u=this.adjustRowNumbersAndGetCount();while(u>0&&u0&&v0&&(S[0]=g[p-1],S[4]=v[p-1],S[5]=E[p-1]),p>1&&(S[8]=g[p-2],S[10]=v[p-2],S[11]=E[p-2]),p>=1;g=p&1,bi.RATIOS_TABLE[u]||(bi.RATIOS_TABLE[u]=new Array(Gn.BARS_IN_MODULE)),bi.RATIOS_TABLE[u][Gn.BARS_IN_MODULE-b-1]=Math.fround(v/Gn.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(u){let p=bi.getDecodedCodewordValue(bi.sampleBitCounts(u));return p!==-1?p:bi.getClosestDecodedValue(u)}static sampleBitCounts(u){let p=Ze.sum(u),g=new Int32Array(Gn.BARS_IN_MODULE),b=0,v=0;for(let E=0;E1)for(let E=0;E=b)break}Snew Array(Gn.BARS_IN_MODULE));class co{constructor(){this.segmentCount=-1,this.fileSize=-1,this.timestamp=-1,this.checksum=-1}getSegmentIndex(){return this.segmentIndex}setSegmentIndex(u){this.segmentIndex=u}getFileId(){return this.fileId}setFileId(u){this.fileId=u}getOptionalData(){return this.optionalData}setOptionalData(u){this.optionalData=u}isLastSegment(){return this.lastSegment}setLastSegment(u){this.lastSegment=u}getSegmentCount(){return this.segmentCount}setSegmentCount(u){this.segmentCount=u}getSender(){return this.sender||null}setSender(u){this.sender=u}getAddressee(){return this.addressee||null}setAddressee(u){this.addressee=u}getFileName(){return this.fileName}setFileName(u){this.fileName=u}getFileSize(){return this.fileSize}setFileSize(u){this.fileSize=u}getChecksum(){return this.checksum}setChecksum(u){this.checksum=u}getTimestamp(){return this.timestamp}setTimestamp(u){this.timestamp=u}}class El{static parseLong(u,p=void 0){return parseInt(u,p)}}class Xa extends f{}Xa.kind="NullPointerException";class Ra{writeBytes(u){this.writeBytesOffset(u,0,u.length)}writeBytesOffset(u,p,g){if(u==null)throw new Xa;if(p<0||p>u.length||g<0||p+g>u.length||p+g<0)throw new T;if(g===0)return;for(let b=0;b0&&this.grow(u)}grow(u){let g=this.buf.length<<1;if(g-u<0&&(g=u),g<0){if(u<0)throw new ra;g=L.MAX_VALUE}this.buf=F.copyOfUint8Array(this.buf,g)}write(u){this.ensureCapacity(this.count+1),this.buf[this.count]=u,this.count+=1}writeBytesOffset(u,p,g){if(p<0||p>u.length||g<0||p+g-u.length>0)throw new T;this.ensureCapacity(this.count+g),I.arraycopy(u,p,this.buf,this.count,g),this.count+=g}writeTo(u){u.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return F.copyOfUint8Array(this.buf,this.count)}size(){return this.count}toString(u){return u?typeof u=="string"?this.toString_string(u):this.toString_number(u):this.toString_void()}toString_void(){return new String(this.buf).toString()}toString_string(u){return new String(this.buf).toString()}toString_number(u){return new String(this.buf).toString()}close(){}}var Fr;(function(ee){ee[ee.ALPHA=0]="ALPHA",ee[ee.LOWER=1]="LOWER",ee[ee.MIXED=2]="MIXED",ee[ee.PUNCT=3]="PUNCT",ee[ee.ALPHA_SHIFT=4]="ALPHA_SHIFT",ee[ee.PUNCT_SHIFT=5]="PUNCT_SHIFT"})(Fr||(Fr={}));function uo(){if(typeof window<"u")return window.BigInt||null;if(typeof av<"u")return av.BigInt||null;if(typeof self<"u")return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let ci;function ia(ee){if(typeof ci>"u"&&(ci=uo()),ci===null)throw new Error("BigInt is not supported!");return ci(ee)}function Zo(){let ee=[];ee[0]=ia(1);let u=ia(900);ee[1]=u;for(let p=2;p<16;p++)ee[p]=ee[p-1]*u;return ee}class st{static decode(u,p){let g=new G(""),b=V.ISO8859_1;g.enableDecoding(b);let v=1,E=u[v++],S=new co;for(;vu[0])throw z.getFormatInstance();let b=new Int32Array(st.NUMBER_OF_SEQUENCE_CODEWORDS);for(let S=0;S0){for(let oe=0;oe<6;++oe)E.write(Number(ia(O)>>ia(8*(5-oe))));O=0,S=0}break}b===p[0]&&ne0){for(let ye=0;ye<6;++ye)E.write(Number(ia(O)>>ia(8*(5-ye))));O=0,S=0}}break}return v.append(Q.decode(E.toByteArray(),g)),b}static numericCompaction(u,p,g){let b=0,v=!1,E=new Int32Array(st.MAX_NUMERIC_CODEWORDS);for(;p0&&(g.append(st.decodeBase900toBase10(E,b)),b=0)}return p}static decodeBase900toBase10(u,p){let g=ia(0);for(let v=0;v@[\\]_\`~!\r ,: -.$/"|*()?{}'`,st.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",st.EXP900=uo()?Zo():[],st.NUMBER_OF_SEQUENCE_CODEWORDS=2;class mr{constructor(){}static decode(u,p,g,b,v,E,S){let O=new Us(u,p,g,b,v),M=null,W=null,ne;for(let _e=!0;;_e=!1){if(p!=null&&(M=mr.getRowIndicatorColumn(u,O,p,!0,E,S)),b!=null&&(W=mr.getRowIndicatorColumn(u,O,b,!1,E,S)),ne=mr.merge(M,W),ne==null)throw te.getNotFoundInstance();let Ie=ne.getBoundingBox();if(_e&&Ie!=null&&(Ie.getMinY()O.getMaxY()))O=Ie;else break}ne.setBoundingBox(O);let oe=ne.getBarcodeColumnCount()+1;ne.setDetectionResultColumn(0,M),ne.setDetectionResultColumn(oe,W);let ye=M!=null;for(let _e=1;_e<=oe;_e++){let Ie=ye?_e:oe-_e;if(ne.getDetectionResultColumn(Ie)!==void 0)continue;let Ke;Ie===0||Ie===oe?Ke=new ma(O,Ie===0):Ke=new pa(O),ne.setDetectionResultColumn(Ie,Ke);let ct=-1,Gt=ct;for(let $t=O.getMinY();$t<=O.getMaxY();$t++){if(ct=mr.getStartColumn(ne,Ie,$t,ye),ct<0||ct>O.getMaxX()){if(Gt===-1)continue;ct=Gt}let Rt=mr.detectCodeword(u,O.getMinX(),O.getMaxX(),ye,ct,$t,E,S);Rt!=null&&(Ke.setCodeword($t,Rt),Gt=ct,E=Math.min(E,Rt.getWidth()),S=Math.max(S,Rt.getWidth()))}}return mr.createDecoderResult(ne)}static merge(u,p){if(u==null&&p==null)return null;let g=mr.getBarcodeMetadata(u,p);if(g==null)return null;let b=Us.merge(mr.adjustBoundingBox(u),mr.adjustBoundingBox(p));return new Vr(g,b)}static adjustBoundingBox(u){if(u==null)return null;let p=u.getRowHeights();if(p==null)return null;let g=mr.getMax(p),b=0;for(let S of p)if(b+=g-S,S>0)break;let v=u.getCodewords();for(let S=0;b>0&&v[S]==null;S++)b--;let E=0;for(let S=p.length-1;S>=0&&(E+=g-p[S],!(p[S]>0));S--);for(let S=v.length-1;E>0&&v[S]==null;S--)E--;return u.getBoundingBox().addMissingRows(b,E,u.isLeft())}static getMax(u){let p=-1;for(let g of u)p=Math.max(p,g);return p}static getBarcodeMetadata(u,p){let g;if(u==null||(g=u.getBarcodeMetadata())==null)return p==null?null:p.getBarcodeMetadata();let b;return p==null||(b=p.getBarcodeMetadata())==null?g:g.getColumnCount()!==b.getColumnCount()&&g.getErrorCorrectionLevel()!==b.getErrorCorrectionLevel()&&g.getRowCount()!==b.getRowCount()?null:g}static getRowIndicatorColumn(u,p,g,b,v,E){let S=new ma(p,b);for(let O=0;O<2;O++){let M=O===0?1:-1,W=Math.trunc(Math.trunc(g.getX()));for(let ne=Math.trunc(Math.trunc(g.getY()));ne<=p.getMaxY()&&ne>=p.getMinY();ne+=M){let oe=mr.detectCodeword(u,0,u.getWidth(),b,W,ne,v,E);oe!=null&&(S.setCodeword(ne,oe),b?W=oe.getStartX():W=oe.getEndX())}}return S}static adjustCodewordCount(u,p){let g=p[0][1],b=g.getValue(),v=u.getBarcodeColumnCount()*u.getBarcodeRowCount()-mr.getNumberOfECCodeWords(u.getBarcodeECLevel());if(b.length===0){if(v<1||v>Gn.MAX_CODEWORDS_IN_BARCODE)throw te.getNotFoundInstance();g.setValue(v)}else b[0]!==v&&g.setValue(v)}static createDecoderResult(u){let p=mr.createBarcodeMatrix(u);mr.adjustCodewordCount(u,p);let g=new Array,b=new Int32Array(u.getBarcodeRowCount()*u.getBarcodeColumnCount()),v=[],E=new Array;for(let O=0;O0;){for(let O=0;Onew Array(u.getBarcodeColumnCount()+2));for(let b=0;b=0){if(E>=p.length)continue;p[E][g].setValue(v.getValue())}}}g++}return p}static isValidBarcodeColumn(u,p){return p>=0&&p<=u.getBarcodeColumnCount()+1}static getStartColumn(u,p,g,b){let v=b?1:-1,E=null;if(mr.isValidBarcodeColumn(u,p-v)&&(E=u.getDetectionResultColumn(p-v).getCodeword(g)),E!=null)return b?E.getEndX():E.getStartX();if(E=u.getDetectionResultColumn(p).getCodewordNearby(g),E!=null)return b?E.getStartX():E.getEndX();if(mr.isValidBarcodeColumn(u,p-v)&&(E=u.getDetectionResultColumn(p-v).getCodewordNearby(g)),E!=null)return b?E.getEndX():E.getStartX();let S=0;for(;mr.isValidBarcodeColumn(u,p-v);){p-=v;for(let O of u.getDetectionResultColumn(p).getCodewords())if(O!=null)return(b?O.getEndX():O.getStartX())+v*S*(O.getEndX()-O.getStartX());S++}return b?u.getBoundingBox().getMinX():u.getBoundingBox().getMaxX()}static detectCodeword(u,p,g,b,v,E,S,O){v=mr.adjustCodewordStartColumn(u,p,g,b,v,E);let M=mr.getModuleBitCount(u,p,g,b,v,E);if(M==null)return null;let W,ne=Ze.sum(M);if(b)W=v+ne;else{for(let _e=0;_e=p)&&M=p:Smr.CODEWORD_SKEW_SIZE)return v;S+=O}O=-O,b=!b}return S}static checkCodewordSkew(u,p,g){return p-mr.CODEWORD_SKEW_SIZE<=u&&u<=g+mr.CODEWORD_SKEW_SIZE}static decodeCodewords(u,p,g){if(u.length===0)throw z.getFormatInstance();let b=1<g/2+mr.MAX_ERRORS||g<0||g>mr.MAX_EC_CODEWORDS)throw A.getChecksumInstance();return mr.errorCorrection.decode(u,g,p)}static verifyCodewordCount(u,p){if(u.length<4)throw z.getFormatInstance();let g=u[0];if(g>u.length)throw z.getFormatInstance();if(g===0)if(p>=1;return p}static getCodewordBucketNumber(u){return u instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(u):this.getCodewordBucketNumber_number(u)}static getCodewordBucketNumber_number(u){return mr.getCodewordBucketNumber(mr.getBitCountForCodeword(u))}static getCodewordBucketNumber_Int32Array(u){return(u[0]-u[2]+u[4]-u[6]+9)%9}static toString(u){let p=new Ya;for(let g=0;gE)}static getMaxWidth(u,p){return u==null||p==null?0:Math.trunc(Math.abs(u.getX()-p.getX()))}static getMinWidth(u,p){return u==null||p==null?L.MAX_VALUE:Math.trunc(Math.abs(u.getX()-p.getX()))}static getMaxCodewordWidth(u){return Math.floor(Math.max(Math.max(Mi.getMaxWidth(u[0],u[4]),Mi.getMaxWidth(u[6],u[2])*Gn.MODULES_IN_CODEWORD/Gn.MODULES_IN_STOP_PATTERN),Math.max(Mi.getMaxWidth(u[1],u[5]),Mi.getMaxWidth(u[7],u[3])*Gn.MODULES_IN_CODEWORD/Gn.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(u){return Math.floor(Math.min(Math.min(Mi.getMinWidth(u[0],u[4]),Mi.getMinWidth(u[6],u[2])*Gn.MODULES_IN_CODEWORD/Gn.MODULES_IN_STOP_PATTERN),Math.min(Mi.getMinWidth(u[1],u[5]),Mi.getMinWidth(u[7],u[3])*Gn.MODULES_IN_CODEWORD/Gn.MODULES_IN_STOP_PATTERN)))}reset(){}}class ge extends f{}ge.kind="ReaderException";class we{constructor(u,p){this.verbose=u===!0,p&&this.setHints(p)}decode(u,p){return p&&this.setHints(p),this.decodeInternal(u)}decodeWithState(u){return(this.readers===null||this.readers===void 0)&&this.setHints(null),this.decodeInternal(u)}setHints(u){this.hints=u;const p=!r(u)&&u.get(K.TRY_HARDER)===!0,g=r(u)?null:u.get(K.POSSIBLE_FORMATS),b=new Array;if(!r(g)){const v=g.some(E=>E===Ue.UPC_A||E===Ue.UPC_E||E===Ue.EAN_13||E===Ue.EAN_8||E===Ue.CODABAR||E===Ue.CODE_39||E===Ue.CODE_93||E===Ue.CODE_128||E===Ue.ITF||E===Ue.RSS_14||E===Ue.RSS_EXPANDED);v&&!p&&b.push(new Hi(u,this.verbose)),g.includes(Ue.QR_CODE)&&b.push(new Is),g.includes(Ue.DATA_MATRIX)&&b.push(new Ut),g.includes(Ue.AZTEC)&&b.push(new hr),g.includes(Ue.PDF_417)&&b.push(new Mi),v&&p&&b.push(new Hi(u,this.verbose))}b.length===0&&(p||b.push(new Hi(u,this.verbose)),b.push(new Is),b.push(new Ut),b.push(new hr),b.push(new Mi),p&&b.push(new Hi(u,this.verbose))),this.readers=b}reset(){if(this.readers!==null)for(const u of this.readers)u.reset()}decodeInternal(u){if(this.readers===null)throw new ge("No readers where selected, nothing can be read.");for(const p of this.readers)try{return p.decode(u,this.hints)}catch(g){if(g instanceof ge)continue}throw new te("No MultiFormat Readers were able to detect the code.")}}class Te extends ae{constructor(u=null,p=500){const g=new we;g.setHints(u),super(g,p)}decodeBitmap(u){return this.reader.decodeWithState(u)}}class $e extends ae{constructor(u=500){super(new Mi,u)}}class ut extends ae{constructor(u=500){super(new Is,u)}}var lt;(function(ee){ee[ee.ERROR_CORRECTION=0]="ERROR_CORRECTION",ee[ee.CHARACTER_SET=1]="CHARACTER_SET",ee[ee.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",ee[ee.MIN_SIZE=3]="MIN_SIZE",ee[ee.MAX_SIZE=4]="MAX_SIZE",ee[ee.MARGIN=5]="MARGIN",ee[ee.PDF417_COMPACT=6]="PDF417_COMPACT",ee[ee.PDF417_COMPACTION=7]="PDF417_COMPACTION",ee[ee.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",ee[ee.AZTEC_LAYERS=9]="AZTEC_LAYERS",ee[ee.QR_VERSION=10]="QR_VERSION"})(lt||(lt={}));var At=lt;class bn{constructor(u){this.field=u,this.cachedGenerators=[],this.cachedGenerators.push(new Yt(u,Int32Array.from([1])))}buildGenerator(u){const p=this.cachedGenerators;if(u>=p.length){let g=p[p.length-1];const b=this.field;for(let v=p.length;v<=u;v++){const E=g.multiply(new Yt(b,Int32Array.from([1,b.exp(v-1+b.getGeneratorBase())])));p.push(E),g=E}}return p[u]}encode(u,p){if(p===0)throw new y("No error correction bytes");const g=u.length-p;if(g<=0)throw new y("No data bytes provided");const b=this.buildGenerator(p),v=new Int32Array(g);I.arraycopy(u,0,v,0,g);let E=new Yt(this.field,v);E=E.multiplyByMonomial(p,1);const O=E.divide(b)[1].getCoefficients(),M=p-O.length;for(let W=0;W=5&&(g+=Mt.N1+(O-5)),O=1,M=ne)}O>=5&&(g+=Mt.N1+(O-5))}return g}}Mt.N1=3,Mt.N2=3,Mt.N3=40,Mt.N4=10;class An{constructor(u,p){this.width=u,this.height=p;const g=new Array(p);for(let b=0;b!==p;b++)g[b]=new Uint8Array(u);this.bytes=g}getHeight(){return this.height}getWidth(){return this.width}get(u,p){return this.bytes[p][u]}getArray(){return this.bytes}setNumber(u,p,g){this.bytes[p][u]=g}setBoolean(u,p,g){this.bytes[p][u]=g?1:0}clear(u){for(const p of this.bytes)F.fill(p,u)}equals(u){if(!(u instanceof An))return!1;const p=u;if(this.width!==p.width||this.height!==p.height)return!1;for(let g=0,b=this.height;g> `),u.toString()}setMode(u){this.mode=u}setECLevel(u){this.ecLevel=u}setVersion(u){this.version=u}setMaskPattern(u){this.maskPattern=u}setMatrix(u){this.matrix=u}static isValidMaskPattern(u){return u>=0&&u0;){for(E===6&&(E-=1);S>=0&&S=g;)u^=p<<_.findMSBSet(u)-g;return u}static makeTypeInfoBits(u,p,g){if(!Rn.isValidMaskPattern(p))throw new qe("Invalid mask pattern");const b=u.getBits()<<3|p;g.appendBits(b,5);const v=_.calculateBCHCode(b,_.TYPE_INFO_POLY);g.appendBits(v,10);const E=new q;if(E.appendBits(_.TYPE_INFO_MASK_PATTERN,15),g.xor(E),g.getSize()!==15)throw new qe("should not happen but we got: "+g.getSize())}static makeVersionInfoBits(u,p){p.appendBits(u.getVersionNumber(),6);const g=_.calculateBCHCode(u.getVersionNumber(),_.VERSION_INFO_POLY);if(p.appendBits(g,12),p.getSize()!==18)throw new qe("should not happen but we got: "+p.getSize())}static isEmpty(u){return u===255}static embedTimingPatterns(u){for(let p=8;p=0)for(let O=0;O!==E;O++){const M=b[O];M>=0&&_.isEmpty(p.get(M,S))&&_.embedPositionAdjustmentPattern(M-2,S-2,p)}}}}_.POSITION_DETECTION_PATTERN=Array.from([Int32Array.from([1,1,1,1,1,1,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,1,1,1,1,1,1])]),_.POSITION_ADJUSTMENT_PATTERN=Array.from([Int32Array.from([1,1,1,1,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,0,1,0,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,1,1,1,1])]),_.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE=Array.from([Int32Array.from([-1,-1,-1,-1,-1,-1,-1]),Int32Array.from([6,18,-1,-1,-1,-1,-1]),Int32Array.from([6,22,-1,-1,-1,-1,-1]),Int32Array.from([6,26,-1,-1,-1,-1,-1]),Int32Array.from([6,30,-1,-1,-1,-1,-1]),Int32Array.from([6,34,-1,-1,-1,-1,-1]),Int32Array.from([6,22,38,-1,-1,-1,-1]),Int32Array.from([6,24,42,-1,-1,-1,-1]),Int32Array.from([6,26,46,-1,-1,-1,-1]),Int32Array.from([6,28,50,-1,-1,-1,-1]),Int32Array.from([6,30,54,-1,-1,-1,-1]),Int32Array.from([6,32,58,-1,-1,-1,-1]),Int32Array.from([6,34,62,-1,-1,-1,-1]),Int32Array.from([6,26,46,66,-1,-1,-1]),Int32Array.from([6,26,48,70,-1,-1,-1]),Int32Array.from([6,26,50,74,-1,-1,-1]),Int32Array.from([6,30,54,78,-1,-1,-1]),Int32Array.from([6,30,56,82,-1,-1,-1]),Int32Array.from([6,30,58,86,-1,-1,-1]),Int32Array.from([6,34,62,90,-1,-1,-1]),Int32Array.from([6,28,50,72,94,-1,-1]),Int32Array.from([6,26,50,74,98,-1,-1]),Int32Array.from([6,30,54,78,102,-1,-1]),Int32Array.from([6,28,54,80,106,-1,-1]),Int32Array.from([6,32,58,84,110,-1,-1]),Int32Array.from([6,30,58,86,114,-1,-1]),Int32Array.from([6,34,62,90,118,-1,-1]),Int32Array.from([6,26,50,74,98,122,-1]),Int32Array.from([6,30,54,78,102,126,-1]),Int32Array.from([6,26,52,78,104,130,-1]),Int32Array.from([6,30,56,82,108,134,-1]),Int32Array.from([6,34,60,86,112,138,-1]),Int32Array.from([6,30,58,86,114,142,-1]),Int32Array.from([6,34,62,90,118,146,-1]),Int32Array.from([6,30,54,78,102,126,150]),Int32Array.from([6,24,50,76,102,128,154]),Int32Array.from([6,28,54,80,106,132,158]),Int32Array.from([6,32,58,84,110,136,162]),Int32Array.from([6,26,54,82,110,138,166]),Int32Array.from([6,30,58,86,114,142,170])]),_.TYPE_INFO_COORDINATES=Array.from([Int32Array.from([8,0]),Int32Array.from([8,1]),Int32Array.from([8,2]),Int32Array.from([8,3]),Int32Array.from([8,4]),Int32Array.from([8,5]),Int32Array.from([8,7]),Int32Array.from([8,8]),Int32Array.from([7,8]),Int32Array.from([5,8]),Int32Array.from([4,8]),Int32Array.from([3,8]),Int32Array.from([2,8]),Int32Array.from([1,8]),Int32Array.from([0,8])]),_.VERSION_INFO_POLY=7973,_.TYPE_INFO_POLY=1335,_.TYPE_INFO_MASK_PATTERN=21522;class U{constructor(u,p){this.dataBytes=u,this.errorCorrectionBytes=p}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class H{constructor(){}static calculateMaskPenalty(u){return Mt.applyMaskPenaltyRule1(u)+Mt.applyMaskPenaltyRule2(u)+Mt.applyMaskPenaltyRule3(u)+Mt.applyMaskPenaltyRule4(u)}static encode(u,p,g=null){let b=H.DEFAULT_BYTE_MODE_ENCODING;const v=g!==null&&g.get(At.CHARACTER_SET)!==void 0;v&&(b=g.get(At.CHARACTER_SET).toString());const E=this.chooseMode(u,b),S=new q;if(E===en.BYTE&&(v||H.DEFAULT_BYTE_MODE_ENCODING!==b)){const $t=V.getCharacterSetECIByName(b);$t!==void 0&&this.appendECI($t,S)}this.appendModeInfo(E,S);const O=new q;this.appendBytes(u,E,O,b);let M;if(g!==null&&g.get(At.QR_VERSION)!==void 0){const $t=Number.parseInt(g.get(At.QR_VERSION).toString(),10);M=rn.getVersionForNumber($t);const Rt=this.calculateBitsNeeded(E,S,O,M);if(!this.willFit(Rt,M,p))throw new qe("Data too big for requested version")}else M=this.recommendVersion(p,E,S,O);const W=new q;W.appendBitArray(S);const ne=E===en.BYTE?O.getSizeInBytes():u.length;this.appendLengthInfo(ne,M,E,W),W.appendBitArray(O);const oe=M.getECBlocksForLevel(p),ye=M.getTotalCodewords()-oe.getTotalECCodewords();this.terminateBits(ye,W);const _e=this.interleaveWithECBytes(W,M.getTotalCodewords(),ye,oe.getNumBlocks()),Ie=new Rn;Ie.setECLevel(p),Ie.setMode(E),Ie.setVersion(M);const Ke=M.getDimensionForVersion(),ct=new An(Ke,Ke),Gt=this.chooseMaskPattern(_e,p,M,ct);return Ie.setMaskPattern(Gt),_.buildMatrix(_e,p,M,Gt,ct),Ie.setMatrix(ct),Ie}static recommendVersion(u,p,g,b){const v=this.calculateBitsNeeded(p,g,b,rn.getVersionForNumber(1)),E=this.chooseVersion(v,u),S=this.calculateBitsNeeded(p,g,b,E);return this.chooseVersion(S,u)}static calculateBitsNeeded(u,p,g,b){return p.getSize()+u.getCharacterCountBits(b)+g.getSize()}static getAlphanumericCode(u){return u159)&&(v<224||v>235))return!1}return!0}static chooseMaskPattern(u,p,g,b){let v=Number.MAX_SAFE_INTEGER,E=-1;for(let S=0;S=O}static terminateBits(u,p){const g=u*8;if(p.getSize()>g)throw new qe("data bits cannot fit in the QR Code"+p.getSize()+" > "+g);for(let E=0;E<4&&p.getSize()0)for(let E=b;E<8;E++)p.appendBit(!1);const v=u-p.getSizeInBytes();for(let E=0;E=g)throw new qe("Block ID too large");const S=u%g,O=g-S,M=Math.floor(u/g),W=M+1,ne=Math.floor(p/g),oe=ne+1,ye=M-ne,_e=W-oe;if(ye!==_e)throw new qe("EC bytes mismatch");if(g!==O+S)throw new qe("RS blocks mismatch");if(u!==(ne+ye)*O+(oe+_e)*S)throw new qe("Total bytes mismatch");b=1<=0&&p<=9}static appendNumericBytes(u,p){const g=u.length;let b=0;for(;b=33088&&O<=40956?M=O-33088:O>=57408&&O<=60351&&(M=O-49472),M===-1)throw new qe("Invalid byte sequence");const W=(M>>8)*192+(M&255);p.appendBits(W,13)}}static appendECI(u,p){p.appendBits(en.ECI.getBits(),4),p.appendBits(u.getValue(),8)}}H.ALPHANUMERIC_TABLE=Int32Array.from([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,36,-1,-1,-1,37,38,-1,-1,-1,-1,39,40,-1,41,42,43,0,1,2,3,4,5,6,7,8,9,44,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1]),H.DEFAULT_BYTE_MODE_ENCODING=V.UTF8.getName();class re{write(u,p,g,b=null){if(u.length===0)throw new y("Found empty contents");if(p<0||g<0)throw new y("Requested dimensions are too small: "+p+"x"+g);let v=Pn.L,E=re.QUIET_ZONE_SIZE;b!==null&&(b.get(At.ERROR_CORRECTION)!==void 0&&(v=Pn.fromString(b.get(At.ERROR_CORRECTION).toString())),b.get(At.MARGIN)!==void 0&&(E=Number.parseInt(b.get(At.MARGIN).toString(),10)));const S=H.encode(u,v,b);return this.renderResult(S,p,g,E)}writeToDom(u,p,g,b,v=null){typeof u=="string"&&(u=document.querySelector(u));const E=this.write(p,g,b,v);u&&u.appendChild(E)}renderResult(u,p,g,b){const v=u.getMatrix();if(v===null)throw new Fn;const E=v.getWidth(),S=v.getHeight(),O=E+b*2,M=S+b*2,W=Math.max(p,O),ne=Math.max(g,M),oe=Math.min(Math.floor(W/O),Math.floor(ne/M)),ye=Math.floor((W-E*oe)/2),_e=Math.floor((ne-S*oe)/2),Ie=this.createSVGElement(W,ne);for(let Ke=0,ct=_e;Kep||v+S>g)throw new y("Crop rectangle does not fit within image data.");O&&this.reverseHorizontal(E,S)}getRow(u,p){if(u<0||u>=this.getHeight())throw new y("Requested row is outside the image: "+u);const g=this.getWidth();(p==null||p.length>16&255,ye=ne>>7&510,_e=ne&255;M[W]=(oe+ye+_e)/4&255}this.luminances=M}else this.luminances=u;if(b===void 0&&(this.dataWidth=p),v===void 0&&(this.dataHeight=g),E===void 0&&(this.left=0),S===void 0&&(this.top=0),this.left+p>this.dataWidth||this.top+g>this.dataHeight)throw new y("Crop rectangle does not fit within image data.")}getRow(u,p){if(u<0||u>=this.getHeight())throw new y("Requested row is outside the image: "+u);const g=this.getWidth();(p==null||p.length"}}class Kr extends Qr{constructor(u,p,g){super(u,0,0),this.binaryShiftStart=p,this.binaryShiftByteCount=g}appendTo(u,p){for(let g=0;g62?u.appendBits(this.binaryShiftByteCount-31,16):g===0?u.appendBits(Math.min(this.binaryShiftByteCount,31),5):u.appendBits(this.binaryShiftByteCount-31,5)),u.appendBits(p[this.binaryShiftStart+g],8)}addBinaryShift(u,p){return new Kr(this,u,p)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function Xs(ee,u,p){return new Kr(ee,u,p)}function Da(ee,u,p){return new Qr(ee,u,p)}const Ci=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],js=0,Po=1,ga=2,Ro=3,ho=4,Wc=new Qr(null,0,0),Kl=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,932798]),Int32Array.from([(5<<16)+29,(5<<16)+28,656318,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,656380,656382,656381,0])];function Rf(ee){for(let u of ee)F.fill(u,-1);return ee[js][ho]=0,ee[Po][ho]=0,ee[Po][js]=28,ee[Ro][ho]=0,ee[ga][ho]=0,ee[ga][js]=15,ee}const mc=Rf(F.createInt32Array(6,6));class xa{constructor(u,p,g,b){this.token=u,this.mode=p,this.binaryShiftByteCount=g,this.bitCount=b}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(u,p){let g=this.bitCount,b=this.token;if(u!==this.mode){let E=Kl[this.mode][u];b=Da(b,E&65535,E>>16),g+=E>>16}let v=u===ga?4:5;return b=Da(b,p,v),new xa(b,u,0,g+v)}shiftAndAppend(u,p){let g=this.token,b=this.mode===ga?4:5;return g=Da(g,mc[this.mode][u],b),g=Da(g,p,5),new xa(g,this.mode,0,this.bitCount+b+5)}addBinaryShiftChar(u){let p=this.token,g=this.mode,b=this.bitCount;if(this.mode===ho||this.mode===ga){let S=Kl[g][js];p=Da(p,S&65535,S>>16),b+=S>>16,g=js}let v=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,E=new xa(p,g,this.binaryShiftByteCount+1,b+v);return E.binaryShiftByteCount===2078&&(E=E.endBinaryShift(u+1)),E}endBinaryShift(u){if(this.binaryShiftByteCount===0)return this;let p=this.token;return p=Xs(p,u-this.binaryShiftByteCount,this.binaryShiftByteCount),new xa(p,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(u){let p=this.bitCount+(Kl[this.mode][u.mode]>>16);return this.binaryShiftByteCountu.binaryShiftByteCount&&u.binaryShiftByteCount>0&&(p+=10),p<=u.bitCount}toBitArray(u){let p=[];for(let b=this.endBinaryShift(u.length).token;b!==null;b=b.getPrevious())p.unshift(b);let g=new q;for(const b of p)b.appendTo(g,u);return g}toString(){return Y.format("%s bits=%d bytes=%d",Ci[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(u){return u.binaryShiftByteCount>62?21:u.binaryShiftByteCount>31?20:u.binaryShiftByteCount>0?10:0}}xa.INITIAL_STATE=new xa(Wc,js,0,0);function rh(ee){const u=Y.getCharCode(" "),p=Y.getCharCode("."),g=Y.getCharCode(",");ee[js][u]=1;const b=Y.getCharCode("Z"),v=Y.getCharCode("A");for(let oe=v;oe<=b;oe++)ee[js][oe]=oe-v+2;ee[Po][u]=1;const E=Y.getCharCode("z"),S=Y.getCharCode("a");for(let oe=S;oe<=E;oe++)ee[Po][oe]=oe-S+2;ee[ga][u]=1;const O=Y.getCharCode("9"),M=Y.getCharCode("0");for(let oe=M;oe<=O;oe++)ee[ga][oe]=oe-M+2;ee[ga][g]=12,ee[ga][p]=13;const W=["\0"," ","","","","","","","\x07","\b"," ",` `,"\v","\f","\r","\x1B","","","","","@","\\","^","_","`","|","~",""];for(let oe=0;oe","?","[","]","{","}"];for(let oe=0;oe0&&(ee[ho][Y.getCharCode(ne[oe])]=oe);return ee}const Do=rh(F.createInt32Array(5,256));class Jo{constructor(u){this.text=u}encode(){const u=Y.getCharCode(" "),p=Y.getCharCode(` `);let g=Br.singletonList(xa.INITIAL_STATE);for(let v=0;v0?(g=Jo.updateStateListForPair(g,v,E),v++):g=this.updateStateListForChar(g,v)}return Br.min(g,(v,E)=>v.getBitCount()-E.getBitCount()).toBitArray(this.text)}updateStateListForChar(u,p){const g=[];for(let b of u)this.updateStateForChar(b,p,g);return Jo.simplifyStates(g)}updateStateForChar(u,p,g){let b=this.text[p]&255,v=Do[u.getMode()][b]>0,E=null;for(let S=0;S<=ho;S++){let O=Do[S][b];if(O>0){if(E==null&&(E=u.endBinaryShift(p)),!v||S===u.getMode()||S===ga){const M=E.latchAndAppend(S,O);g.push(M)}if(!v&&mc[u.getMode()][S]>=0){const M=E.shiftAndAppend(S,O);g.push(M)}}}if(u.getBinaryShiftByteCount()>0||Do[u.getMode()][b]===0){let S=u.addBinaryShiftChar(p);g.push(S)}}static updateStateListForPair(u,p,g){const b=[];for(let v of u)this.updateStateForPair(v,p,g,b);return this.simplifyStates(b)}static updateStateForPair(u,p,g,b){let v=u.endBinaryShift(p);if(b.push(v.latchAndAppend(ho,g)),u.getMode()!==ho&&b.push(v.shiftAndAppend(ho,g)),g===3||g===4){let E=v.latchAndAppend(ga,16-g).latchAndAppend(ga,1);b.push(E)}if(u.getBinaryShiftByteCount()>0){let E=u.addBinaryShiftChar(p).addBinaryShiftChar(p+1);b.push(E)}}static simplifyStates(u){let p=[];for(const g of u){let b=!0;for(const v of p){if(v.isBetterThanOrEqualTo(g)){b=!1;break}g.isBetterThanOrEqualTo(v)&&(p=p.filter(E=>E!==v))}b&&p.push(g)}return p}}class Rr{constructor(){}static encodeBytes(u){return Rr.encode(u,Rr.DEFAULT_EC_PERCENT,Rr.DEFAULT_AZTEC_LAYERS)}static encode(u,p,g){let b=new Jo(u).encode(),v=L.truncDivision(b.getSize()*p,100)+11,E=b.getSize()+v,S,O,M,W,ne;if(g!==Rr.DEFAULT_AZTEC_LAYERS){if(S=g<0,O=Math.abs(g),O>(S?Rr.MAX_NB_BITS_COMPACT:Rr.MAX_NB_BITS))throw new y(Y.format("Illegal value %s for layers",g));M=Rr.totalBitsInLayer(O,S),W=Rr.WORD_SIZE[O];let Rt=M-M%W;if(ne=Rr.stuffBits(b,W),ne.getSize()+v>Rt)throw new y("Data to large for user specified layer");if(S&&ne.getSize()>W*64)throw new y("Data to large for user specified layer")}else{W=0,ne=null;for(let Rt=0;;Rt++){if(Rt>Rr.MAX_NB_BITS)throw new y("Data too large for an Aztec code");if(S=Rt<=3,O=S?Rt+1:Rt,M=Rr.totalBitsInLayer(O,S),E>M)continue;(ne==null||W!==Rr.WORD_SIZE[O])&&(W=Rr.WORD_SIZE[O],ne=Rr.stuffBits(b,W));let Or=M-M%W;if(!(S&&ne.getSize()>W*64)&&ne.getSize()+v<=Or)break}}let oe=Rr.generateCheckWords(ne,M,W),ye=ne.getSize()/W,_e=Rr.generateModeMessage(S,O,ye),Ie=(S?11:14)+O*4,Ke=new Int32Array(Ie),ct;if(S){ct=Ie;for(let Rt=0;Rt=b||u.get(E+O))&&(S|=1<0&&a[a.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!a||f[1]>a[0]&&f[1]r&&(r=c,n=o)}if(!n)throw"No largest barcode found";return n},e.prototype.createBarcodeDetectorFormats=function(t){for(var n=[],r=0,i=t;r0&&a[a.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!a||f[1]>a[0]&&f[1]0&&a[a.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!a||f[1]>a[0]&&f[1]=a&&(t.isClosed=!0,t.parentElement.removeChild(t.surface),n())})})},e.prototype.getCapabilities=function(){return new l9e(this.getFirstTrackOrFail())},e})(),u9e=(function(){function e(t){this.mediaStream=t}return e.prototype.render=function(t,n,r){return SN(this,void 0,void 0,function(){return kN(this,function(i){return[2,c9e.create(t,this.mediaStream,n,r)]})})},e.create=function(t){return SN(this,void 0,void 0,function(){var n,r;return kN(this,function(i){switch(i.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return n={audio:!1,video:t},[4,navigator.mediaDevices.getUserMedia(n)];case 1:return r=i.sent(),[2,new e(r)]}})})},e})(),$V=function(e,t,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function c(m){try{f(r.next(m))}catch(y){o(y)}}function h(m){try{f(r.throw(m))}catch(y){o(y)}}function f(m){m.done?a(m.value):i(m.value).then(c,h)}f((r=r.apply(e,t||[])).next())})},HV=function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(f){return function(m){return h([f,m])}}function h(f){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,f[0]&&(n=0)),n;)try{if(r=1,i&&(a=f[0]&2?i.return:f[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,f[1])).done)return a;switch(i=0,a&&(f=[f[0]&2,a.value]),f[0]){case 0:case 1:a=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,i=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(a=n.trys,!(a=a.length>0&&a[a.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!a||f[1]>a[0]&&f[1]0&&a[a.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!a||f[1]>a[0]&&f[1]t&&(i.logger.warn("`qrbox.width` or `qrbox` is larger than the width of the root element. The width will be truncated to the width of root element."),f=t),f};c(o.width),c(o.height),o.width=h(o.width)},e.prototype.validateQrboxConfig=function(t){if(typeof t!="number"&&typeof t!="function"&&(t.width===void 0||t.height===void 0))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},e.prototype.toQrdimensions=function(t,n,r){if(typeof r=="number")return{width:r,height:r};if(typeof r=="function")try{return r(t,n)}catch(i){throw new Error("qrbox config was passed as a function but it failed with unknown error"+i)}return r},e.prototype.setupUi=function(t,n,r){r.isShadedBoxEnabled()&&this.validateQrboxSize(t,n,r);var i=Nd(r.qrbox)?{width:t,height:n}:r.qrbox;this.validateQrboxConfig(i);var a=this.toQrdimensions(t,n,i);a.height>n&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var o=r.isShadedBoxEnabled()&&a.height<=n,c={x:0,y:0,width:t,height:n},h=o?this.getShadedRegionBounds(t,n,a):c,f=this.createCanvasElement(h.width,h.height),m={willReadFrequently:!0},y=f.getContext("2d",m);y.canvas.width=h.width,y.canvas.height=h.height,this.element.append(f),o&&this.possiblyInsertShadingElement(this.element,t,n,a),this.createScannerPausedUiElement(this.element),this.qrRegion=h,this.context=y,this.canvasElement=f},e.prototype.createScannerPausedUiElement=function(t){var n=document.createElement("div");n.innerText=O0.scannerPaused(),n.style.display="none",n.style.position="absolute",n.style.top="0px",n.style.zIndex="1",n.style.background="rgba(9, 9, 9, 0.46)",n.style.color="#FFECEC",n.style.textAlign="center",n.style.width="100%",t.appendChild(n),this.scannerPausedUiElement=n},e.prototype.scanContext=function(t,n){var r=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then(function(i){return t(i.text,LV.createFromQrcodeResult(i)),r.possiblyUpdateShaders(!0),!0}).catch(function(i){r.possiblyUpdateShaders(!1);var a=O0.codeParseError(i);return n(a,QMe.createFrom(a)),!1})},e.prototype.foreverScan=function(t,n,r){var i=this;if(this.shouldScan&&this.renderedCamera){var a=this.renderedCamera.getSurface(),o=a.videoWidth/a.clientWidth,c=a.videoHeight/a.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var h=this.qrRegion.width*o,f=this.qrRegion.height*c,m=this.qrRegion.x*o,y=this.qrRegion.y*c;this.context.drawImage(a,m,y,h,f,0,0,this.qrRegion.width,this.qrRegion.height);var w=function(){i.foreverScanTimeout=setTimeout(function(){i.foreverScan(t,n,r)},i.getTimeoutFps(t.fps))};this.scanContext(n,r).then(function(A){!A&&t.disableFlip!==!0?(i.context.translate(i.context.canvas.width,0),i.context.scale(-1,1),i.scanContext(n,r).finally(function(){w()})):w()}).catch(function(A){i.logger.logError("Error happend while scanning context",A),w()})}},e.prototype.createVideoConstraints=function(t){if(typeof t=="string")return{deviceId:{exact:t}};if(typeof t=="object"){var n="facingMode",r="deviceId",i={user:!0,environment:!0},a="exact",o=function(k){if(k in i)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(k,"'")},c=Object.keys(t);if(c.length!==1)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(c.length," keys");var h=Object.keys(t)[0];if(h!==n&&h!==r)throw"Only '".concat(n,"' and '").concat(r,"' ")+" are supported for 'cameraIdOrConfig'";if(h===n){var f=t.facingMode;if(typeof f=="string"){if(o(f))return{facingMode:f}}else if(typeof f=="object")if(a in f){if(o(f["".concat(a)]))return{facingMode:{exact:f["".concat(a)]}}}else throw"'facingMode' should be string or object with"+" ".concat(a," as key.");else{var m=typeof f;throw"Invalid type of 'facingMode' = ".concat(m)}}else{var y=t.deviceId;if(typeof y=="string")return{deviceId:y};if(typeof y=="object"){if(a in y)return{deviceId:{exact:y["".concat(a)]}};throw"'deviceId' should be string or object with"+" ".concat(a," as key.")}else{var w=typeof y;throw"Invalid type of 'deviceId' = ".concat(w)}}}var A=typeof t;throw"Invalid type of 'cameraIdOrConfig' = ".concat(A)},e.prototype.computeCanvasDrawConfig=function(t,n,r,i){if(t<=r&&n<=i){var a=(r-t)/2,o=(i-n)/2;return{x:a,y:o,width:t,height:n}}else{var c=t,h=n;return t>r&&(n=r/t*n,t=r),n>i&&(t=i/n*t,n=i),this.logger.log("Image downsampled from "+"".concat(c,"X").concat(h)+" to ".concat(t,"X").concat(n,".")),this.computeCanvasDrawConfig(t,n,r,i)}},e.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var t=document.getElementById(this.elementId);t&&(t.innerHTML="")},e.prototype.possiblyUpdateShaders=function(t){this.qrMatch!==t&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach(function(n){n.style.backgroundColor=t?Tl.BORDER_SHADER_MATCH_COLOR:Tl.BORDER_SHADER_DEFAULT_COLOR}),this.qrMatch=t)},e.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},e.prototype.createCanvasElement=function(t,n,r){var i=t,a=n,o=document.createElement("canvas");return o.style.width="".concat(i,"px"),o.style.height="".concat(a,"px"),o.style.display="none",o.id=Nd(r)?"qr-canvas":r,o},e.prototype.getShadedRegionBounds=function(t,n,r){if(r.width>t||r.height>n)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(t-r.width)/2,y:(n-r.height)/2,width:r.width,height:r.height}},e.prototype.possiblyInsertShadingElement=function(t,n,r,i){if(!(n-i.width<1||r-i.height<1)){var a=document.createElement("div");a.style.position="absolute";var o=(n-i.width)/2,c=(r-i.height)/2;if(a.style.borderLeft="".concat(o,"px solid rgba(0, 0, 0, 0.48)"),a.style.borderRight="".concat(o,"px solid rgba(0, 0, 0, 0.48)"),a.style.borderTop="".concat(c,"px solid rgba(0, 0, 0, 0.48)"),a.style.borderBottom="".concat(c,"px solid rgba(0, 0, 0, 0.48)"),a.style.boxSizing="border-box",a.style.top="0px",a.style.bottom="0px",a.style.left="0px",a.style.right="0px",a.id="".concat(Tl.SHADED_REGION_ELEMENT_ID),n-i.width<11||r-i.height<11)this.hasBorderShaders=!1;else{var h=5,f=40;this.insertShaderBorders(a,f,h,-h,null,0,!0),this.insertShaderBorders(a,f,h,-h,null,0,!1),this.insertShaderBorders(a,f,h,null,-h,0,!0),this.insertShaderBorders(a,f,h,null,-h,0,!1),this.insertShaderBorders(a,h,f+h,-h,null,-h,!0),this.insertShaderBorders(a,h,f+h,null,-h,-h,!0),this.insertShaderBorders(a,h,f+h,-h,null,-h,!1),this.insertShaderBorders(a,h,f+h,null,-h,-h,!1),this.hasBorderShaders=!0}t.append(a)}},e.prototype.insertShaderBorders=function(t,n,r,i,a,o,c){var h=document.createElement("div");h.style.position="absolute",h.style.backgroundColor=Tl.BORDER_SHADER_DEFAULT_COLOR,h.style.width="".concat(n,"px"),h.style.height="".concat(r,"px"),i!==null&&(h.style.top="".concat(i,"px")),a!==null&&(h.style.bottom="".concat(a,"px")),c?h.style.left="".concat(o,"px"):h.style.right="".concat(o,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(h),t.appendChild(h)},e.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},e.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},e.prototype.getTimeoutFps=function(t){return 1e3/t},e})(),GV;(function(e){e[e.STATUS_DEFAULT=0]="STATUS_DEFAULT",e[e.STATUS_SUCCESS=1]="STATUS_SUCCESS",e[e.STATUS_WARNING=2]="STATUS_WARNING",e[e.STATUS_REQUESTING_PERMISSION=3]="STATUS_REQUESTING_PERMISSION"})(GV||(GV={}));const v9e=({isOpen:e,onClose:t,onScanSuccess:n})=>{const[r,i]=j.useState([]),[a,o]=j.useState(""),[c,h]=j.useState(!0),[f,m]=j.useState(null),[y,w]=j.useState(""),[A,k]=j.useState(!1),I="qr-camera-scanner-viewport",T=j.useRef(null),D=j.useRef(null);j.useEffect(()=>{if(e)return h(!0),m(null),xk.getCameras().then(Z=>{if(Z&&Z.length>0){i(Z);const K=Z.find(z=>z.label.toLowerCase().includes("back")||z.label.toLowerCase().includes("rear")||z.label.toLowerCase().includes("environment"));o(K?K.id:Z[0].id)}else m("No camera devices detected on this device.");h(!1)}).catch(Z=>{console.warn("Camera detection warning:",Z),m("Failed to launch real-time lens. Chrome regularly restricts live camera access inside sandboxed iframes."),h(!1)}),()=>{F()}},[e]);const F=async()=>{if(T.current&&T.current.isScanning)try{await T.current.stop()}catch(Z){console.warn("Error stopping scanner:",Z)}};j.useEffect(()=>{if(!e||!a||c)return;let Z=!0;return(async()=>{if(await F(),!Z)return;const z=new xk(I);T.current=z;try{await z.start(a,{fps:15,qrbox:(B,V)=>{const $=Math.min(B,V)*.7;return{width:$,height:$}}},B=>{console.log("QR Decoded successfully:",B);let V=B;try{if(B.includes("scan="))V=new URL(B).searchParams.get("scan")||B;else if(B.startsWith("http")){const $=new URL(B);V=$.searchParams.get("scan")||$.searchParams.get("ticket")||B}}catch{}V&&(n(V.trim()),sr.success("Ticket Code decrypted successfully!"),t())},()=>{})}catch(B){console.error("Failed to start scanner:",B),Z&&m("Could not initiate live viewport. Browser sandbox permissions may be restricted.")}})(),()=>{Z=!1,F()}},[e,a,c]);const L=async Z=>{var B;const K=(B=Z.target.files)==null?void 0:B[0];if(!K)return;k(!0);const z=sr.loading("Processing image and executing optic logic...");try{await F();const $=await new xk(I).scanFile(K,!0);console.log("File QR decoded:",$);let Q=$;try{if($.includes("scan="))Q=new URL($).searchParams.get("scan")||$;else if($.startsWith("http")){const Y=new URL($);Q=Y.searchParams.get("scan")||Y.searchParams.get("ticket")||$}}catch{}Q?(sr.dismiss(z),n(Q.trim()),sr.success("Optical Code verified from photo!",{icon:"📸"}),t()):sr.error("Could not find a valid Ticket ID prefix in that code.",{id:z})}catch(V){console.warn("QR decode error from file:",V),sr.error("Decouple optical fail. Make sure the QR Code is highly contrast and fits the viewfinder.",{id:z})}finally{k(!1),D.current&&(D.current.value="")}},q=Z=>{Z.preventDefault(),y.trim()&&(n(y.trim()),sr.success("Manual booking pass lookup triggered!"),t())};return e?s.jsx("div",{className:"fixed inset-0 z-[12000] flex items-center justify-center p-4 bg-zinc-950/90 backdrop-blur-sm animate-fade-in text-left",children:s.jsxs("div",{className:"bg-white rounded-[2.5rem] p-8 w-full max-w-lg shadow-2xl relative overflow-hidden border border-gray-100 flex flex-col max-h-[90vh]",children:[s.jsx("div",{className:"absolute inset-0 bg-grid-zinc-100/30 opacity-20 pointer-events-none"}),s.jsxs("div",{className:"relative flex items-center justify-between mb-6 z-10",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-red-600 font-black text-[9px] uppercase tracking-widest font-mono",children:[s.jsx(es,{size:11,className:"animate-spin duration-3000 text-red-500"}),"Passes & Ticket Scanner"]}),s.jsx("h3",{className:"text-lg font-serif font-black text-gray-950 tracking-tight leading-tight uppercase mt-0.5",children:"Rapid QR Verification"})]}),s.jsx("button",{onClick:t,className:"p-2 bg-gray-50 text-gray-900 hover:bg-gray-100 rounded-full transition-all cursor-pointer border border-transparent hover:border-gray-200 flex items-center justify-center",title:"Terminate scanning session",children:s.jsx(er,{size:15,className:"stroke-[2.5]"})})]}),s.jsx("input",{type:"file",ref:D,onChange:L,accept:"image/*",capture:"environment",className:"hidden"}),s.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-5 relative z-10 pr-1",children:[s.jsxs("div",{className:"relative aspect-video bg-zinc-950 rounded-2xl border border-zinc-800 overflow-hidden flex flex-col items-center justify-center",children:[s.jsx("div",{id:I,className:"absolute inset-0 w-full h-full object-cover [&>video]:object-cover"}),c?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-zinc-950 gap-3 text-zinc-400",children:[s.jsx(Pr,{className:"animate-spin text-red-500 animate-duration-1000",size:32}),s.jsx("span",{className:"text-[10px] uppercase font-black tracking-widest text-zinc-500",children:"Initializing Optical Feed..."})]}):f?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-zinc-950 p-6 text-center gap-2",children:[s.jsx(bu,{className:"text-orange-500",size:30}),s.jsx("p",{className:"text-[10px] font-black text-zinc-300 uppercase tracking-tight",children:f}),s.jsx("p",{className:"text-[9px] text-zinc-500 max-w-xs leading-relaxed mb-2",children:"Browser sandboxing regularly halts cameras in frames. Snap a snapshot photo instead to decrypt instantly!"}),s.jsxs("button",{type:"button",onClick:()=>{var Z;return(Z=D.current)==null?void 0:Z.click()},className:"px-4 py-2.5 bg-red-650 hover:bg-red-700 text-white rounded-lg text-[9px] font-black uppercase tracking-widest shadow-md hover:shadow-lg transition-all flex items-center gap-2 cursor-pointer",children:[s.jsx(bk,{size:12}),"Snap QR Photo 📷"]})]}):s.jsxs("div",{className:"absolute inset-0 pointer-events-none flex flex-col justify-between p-6",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("div",{className:"w-5 h-5 border-t-2 border-l-2 border-red-500"}),s.jsx("div",{className:"w-5 h-5 border-t-2 border-r-2 border-red-500"})]}),s.jsx("div",{className:"w-full h-0.5 bg-gradient-to-r from-transparent via-red-500 to-transparent shadow-[0_0_12px_rgba(239,68,68,0.8)] ",style:{animationDuration:"1.2s"}}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("div",{className:"w-5 h-5 border-b-2 border-l-2 border-red-500"}),s.jsx("div",{className:"w-5 h-5 border-b-2 border-r-2 border-red-500"})]})]}),A&&s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-zinc-950/80 p-6 text-center gap-2 z-20",children:[s.jsx(Pr,{className:"animate-spin text-red-500",size:32}),s.jsx("p",{className:"text-xs font-bold text-zinc-200",children:"Decoding Optical Pass file..."})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>{var Z;return(Z=D.current)==null?void 0:Z.click()},className:"px-4 py-3 bg-red-50 hover:bg-red-100 text-red-650 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all inline-flex items-center justify-center gap-2 border border-red-200/50 cursor-pointer",children:[s.jsx(bk,{size:13}),"Snap Code 📷"]}),s.jsxs("button",{type:"button",onClick:()=>{var Z,K;(Z=D.current)==null||Z.removeAttribute("capture"),(K=D.current)==null||K.click(),setTimeout(()=>{var z;return(z=D.current)==null?void 0:z.setAttribute("capture","environment")},500)},className:"px-4 py-3 bg-gray-50 hover:bg-gray-100 text-gray-700 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all inline-flex items-center justify-center gap-2 border border-gray-200 cursor-pointer",children:[s.jsx(dF,{size:13}),"Pick Image File"]})]}),!c&&r.length>1&&s.jsxs("div",{className:"flex items-center gap-1.5 p-1 bg-gray-50 border border-gray-150 rounded-xl",children:[s.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest text-gray-400 pl-3 shrink-0",children:"Switch Camera:"}),s.jsx("div",{className:"flex-1 flex gap-1 justify-end",children:r.map((Z,K)=>s.jsxs("button",{onClick:()=>o(Z.id),className:`px-3 py-1.5 rounded-lg text-[9px] font-black uppercase tracking-wider transition-all cursor-pointer ${a===Z.id?"bg-white text-gray-950 shadow-xs ring-1 ring-gray-150":"text-gray-550 hover:text-gray-900"}`,children:["Feed ",K+1]},Z.id))})]}),s.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),s.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest text-gray-450",children:"Stuck? Manual Pass Code Keyer"})]}),s.jsxs("form",{onSubmit:q,className:"flex gap-2",children:[s.jsx("input",{type:"text",placeholder:"Paste or enter ticket ID (e.g. h6SndA4v...)",value:y,onChange:Z=>w(Z.target.value),className:"flex-1 px-4 py-3 bg-gray-50 border border-gray-250 focus:border-red-650 rounded-xl text-xs font-bold font-mono outline-none transition-all placeholder:text-gray-400"}),s.jsx("button",{type:"submit",className:"px-5 py-3 bg-zinc-950 hover:bg-zinc-900 text-white rounded-xl text-[9px] font-black uppercase tracking-wider transition-colors cursor-pointer whitespace-nowrap",children:"Verify Code"})]})]})]})]})}):null};class w9e extends se.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){const n=(t==null?void 0:t.message)||String(t),r=n.toLowerCase();return r.includes("script error")||r.includes("unexpected token")||r.includes("failed to fetch")||r.includes("networkerror")||r.includes("loading chunk")||r.includes("cors")||r.includes("weather")||r.includes("permission")||r.includes("can only be used on")||r.includes("campuseyemedia")||r.includes("onesignal")||r.includes("could not reach cloud firestore backend")||r.includes("firestore")?(console.warn("Recovered from background glitch silently:",n),{hasError:!1,error:null}):{hasError:!0,error:t}}componentDidCatch(t,n){const r=((t==null?void 0:t.message)||String(t)).toLowerCase();if(r.includes("script error")||r.includes("unexpected token")||r.includes("failed to fetch")||r.includes("networkerror")||r.includes("weather")){console.warn("Recoverable silent error tracked:",t);return}console.error("FATAL APP ERROR:",t,n)}render(){var t,n,r;if(this.state.hasError){const i=((t=this.state.error)==null?void 0:t.message)==="Script error."||((r=(n=this.state.error)==null?void 0:n.message)==null?void 0:r.includes("Script error."));return s.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-white p-10 text-center animate-fade-in relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",style:{backgroundImage:"radial-gradient(#000 1px, transparent 1px)",backgroundSize:"20px 20px"}}),s.jsxs("div",{className:"relative z-10",children:[s.jsx("div",{className:"w-24 h-24 bg-red-50 text-red-600 rounded-3xl flex items-center justify-center mb-8 shadow-xl shadow-red-100 mx-auto",children:s.jsx(bu,{size:48})}),s.jsx("h1",{className:"text-4xl md:text-5xl font-black text-gray-900 uppercase tracking-tighter italic mb-6 leading-none",children:i?"Connection Issue":"System Glitch"}),s.jsx("p",{className:"text-gray-500 font-bold max-w-md mx-auto mb-10 leading-relaxed uppercase tracking-wider text-xs",children:i?"An external service (possibly OneSignal or Google AdSense) was briefly blocked. This is common and shouldn't stop your reading.":"We've hit a minor roadblock in the newsroom. Don't worry, we're fixing it live."}),s.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[s.jsx("button",{onClick:()=>window.location.reload(),className:"px-10 py-5 bg-red-600 text-white font-black uppercase tracking-[0.2em] hover:bg-black transition-all rounded-2xl shadow-2xl shadow-red-200 text-xs",children:"Reboot Newsroom"}),s.jsx("button",{onClick:()=>this.setState({hasError:!1,error:null}),className:"px-10 py-5 bg-gray-100 text-gray-500 font-black uppercase tracking-[0.2em] hover:bg-gray-200 transition-all rounded-2xl text-xs",children:"Try to Ignore"})]}),this.state.error&&!i&&s.jsxs("div",{className:"mt-16 text-left max-w-2xl mx-auto",children:[s.jsx("p",{className:"text-[10px] font-black text-gray-300 uppercase tracking-widest mb-4",children:"Diagnostic Trace"}),s.jsx("pre",{className:"p-6 bg-gray-50 border border-gray-100 rounded-2xl text-[10px] text-gray-400 font-mono overflow-auto custom-scrollbar",children:this.state.error.stack||this.state.error.message})]})]})]})}return this.props.children}}function N9e(){return s.jsx(ZV,{children:s.jsx(w9e,{children:s.jsx(S9e,{})})})}const qV=({className:e})=>s.jsxs("div",{className:Ge("flex flex-col items-center justify-center space-y-3.5 py-6 px-8 bg-white/90 backdrop-blur-md border border-gray-150 rounded-[2rem] shadow-xl animate-fade-in relative z-50 max-w-xs",e),children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("span",{className:"w-4 h-4 bg-red-650 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),s.jsx("span",{className:"w-4 h-4 bg-blue-600 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),s.jsx("span",{className:"w-4 h-4 bg-emerald-500 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]}),s.jsx("span",{className:"text-[10px] font-sans font-black uppercase tracking-custom text-gray-500 select-none",children:"Gathering campus reports..."})]}),E9e=()=>s.jsx("div",{className:"w-full max-w-[1680px] xl:max-w-[1780px] 2xl:max-w-[1880px] mx-auto pt-4 pb-20 px-2 sm:px-4 lg:px-6 xl:px-8",children:s.jsxs("div",{className:"grid grid-cols-12 gap-4 lg:gap-5 xl:gap-6 2xl:gap-8",children:[s.jsxs("aside",{className:"hidden lg:block lg:col-span-3 space-y-4 text-left",children:[s.jsxs("div",{className:"bg-white border border-gray-150 shadow-xs rounded-2xl p-4 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-1.5 font-black text-gray-400 text-[10px] tracking-widest pb-2 border-b border-gray-100 uppercase",children:[s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-gray-200 shrink-0 "}),s.jsx("span",{children:"Latest News"})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2 pt-1 ",children:[1,2].map(e=>s.jsxs("div",{className:"border border-gray-150 rounded-xl overflow-hidden bg-white flex flex-col space-y-2 pb-2",children:[s.jsx("div",{className:"aspect-[1.4] bg-gray-200 w-full"}),s.jsxs("div",{className:"px-2 space-y-1.5",children:[s.jsx("div",{className:"h-2.5 bg-gray-250 w-full rounded"}),s.jsx("div",{className:"h-2 bg-gray-200 w-2/3 rounded"})]})]},e))})]}),s.jsxs("div",{className:"bg-gradient-to-tr from-gray-955 via-gray-900 to-gray-955 p-4 rounded-2xl text-white border border-white/10 space-y-3.5 shadow-md ",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-200 shrink-0"}),s.jsx("span",{className:"text-[8.5px] font-mono font-black uppercase text-gray-400 tracking-[0.2em]",children:"Latest Lounge Updates"})]}),s.jsx("div",{className:"space-y-3 pt-1",children:[1,2,3].map(e=>s.jsxs("div",{className:"flex items-start gap-2.5 p-2 rounded-xl bg-white/5 border border-white/5",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-white/10 shrink-0"}),s.jsxs("div",{className:"flex-1 space-y-1",children:[s.jsx("div",{className:"h-2.5 bg-white/20 rounded w-1/3"}),s.jsx("div",{className:"h-2 bg-white/10 rounded w-5/6"})]})]},e))})]})]}),s.jsxs("main",{className:"col-span-12 lg:col-span-6 space-y-5 px-0 bg-white border-r border-l border-gray-100/60",children:[s.jsx("div",{className:"border-b border-gray-100 pb-3 px-4 flex items-center justify-between",children:s.jsx("div",{className:"h-4 w-36 bg-gray-200 rounded "})}),s.jsxs("div",{className:"divide-y divide-gray-100",children:[s.jsx(Ep,{variant:"social"}),s.jsx(Ep,{variant:"social"}),s.jsx(Ep,{variant:"social"})]})]}),s.jsxs("aside",{className:"col-span-12 lg:col-span-3 space-y-4 text-left",children:[s.jsxs("div",{className:"bg-white border border-gray-150 rounded-3xl p-5 shadow-sm space-y-4 ",children:[s.jsx("div",{className:"flex items-center gap-2 font-black text-gray-400 text-[10px] tracking-widest pb-3 border-b border-gray-100 uppercase",children:s.jsx("span",{children:"Trending Sagas"})}),s.jsx("div",{className:"space-y-3.5 pt-1",children:[1,2,3,4].map(e=>s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-2 bg-gray-200 rounded w-1/4"}),s.jsx("div",{className:"h-3.5 bg-gray-255 rounded w-3/4"})]},e))})]}),s.jsxs("div",{className:"bg-gradient-to-br from-indigo-950 via-slate-900 to-black rounded-3xl p-4 shadow-md space-y-3 border border-white/10 text-white ",children:[s.jsx("div",{className:"h-2.5 bg-indigo-300/30 rounded w-1/3"}),s.jsx("div",{className:"flex justify-center py-2",children:s.jsx("div",{className:"h-10 bg-white/10 rounded-xl w-3/4"})})]})]})]})}),A9e=({userId:e})=>{const[t,n]=se.useState([]),[r,i]=se.useState(!0),[a,o]=se.useState(null);return se.useEffect(()=>{if(!e)return;const c=Qt(it(pe,"purchases"),Nr("userId","==",e));vn(c).then(h=>{n(h.docs.map(f=>({id:f.id,...f.data()}))),i(!1)}).catch(h=>{Gs(h,Ps.LIST,"purchases"),n([]),i(!1)})},[e]),r?s.jsx("div",{className:"flex justify-center p-4",children:s.jsx(Pr,{className:"animate-spin text-red-600",size:20})}):t.length===0?s.jsx("div",{className:"bg-gray-50 rounded-2xl p-8 text-center text-left",children:s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest leading-loose",children:"No active tickets found in your inventory."})}):s.jsxs("div",{className:"space-y-3 text-left",children:[t.map(c=>s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-gray-50 rounded-2xl border border-gray-100 group transition-all hover:bg-white hover:shadow-xs",children:[s.jsx("button",{onClick:()=>o(c),className:"shrink-0 relative overflow-hidden bg-white p-1 rounded-xl border border-gray-150 shadow-2xs hover:border-red-200 transition-colors cursor-zoom-in",type:"button",title:"Click to zoom in on pass QR code",children:s.jsx("img",{src:`https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=${encodeURIComponent(window.location.origin+"?scan="+c.id)}`,alt:"Scan Gate Pass QR",className:"w-12 h-12 rounded-lg object-contain",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>o(c),children:[s.jsx("h4",{className:"text-xs font-black text-gray-900 uppercase tracking-tight truncate",children:c.ticketTitle}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[c.taken||c.used?s.jsx("span",{className:"text-[9px] font-black text-green-700 bg-green-50 border border-green-200 rounded px-2 py-0.5 uppercase flex items-center gap-1 select-none font-mono",children:"✔️ Ticked & Used"}):s.jsx("span",{className:"text-[9px] font-black text-red-650 bg-red-50 border border-red-150 rounded px-2 py-0.5 uppercase flex items-center gap-1 font-mono",children:"🎟️ Confirmed (Active)"}),s.jsxs("span",{className:"text-[9px] font-bold text-gray-500 bg-gray-100 rounded px-1.5 py-0.5 uppercase font-mono",children:["Qty: ",c.quantity]})]})]}),s.jsxs("div",{className:"text-right shrink-0 cursor-pointer",onClick:()=>o(c),children:[s.jsxs("p",{className:"text-[9px] font-black text-gray-900",children:["#",c.id.slice(-6).toUpperCase()]}),s.jsx("p",{className:"text-[8px] font-bold text-gray-400 uppercase",children:c.purchaseDate instanceof jr?c.purchaseDate.toDate().toLocaleDateString():"Recent"})]})]},c.id)),a&&s.jsx("div",{className:"fixed inset-0 bg-black/85 backdrop-blur-md flex items-center justify-center p-4 z-[9999]",onClick:()=>o(null),children:s.jsxs("div",{className:"bg-white p-8 rounded-[2.5rem] border border-gray-100 w-full max-w-sm text-center relative shadow-2xl animate-in fade-in zoom-in-95 duration-200",onClick:c=>c.stopPropagation(),children:[s.jsx("button",{className:"absolute top-6 right-6 p-1.5 bg-gray-50 text-gray-900 hover:bg-gray-100 rounded-full transition-all cursor-pointer",onClick:()=>o(null),children:s.jsx(er,{size:16,className:"stroke-[2.5]"})}),s.jsx("p",{className:"text-[10px] font-black text-red-600 uppercase tracking-widest mb-1.5 font-mono",children:"Live Event Entry Pass"}),s.jsx("h3",{className:"text-sm font-serif font-black text-gray-950 uppercase tracking-tight leading-tight mb-6",children:a.ticketTitle}),s.jsx("div",{className:"bg-white p-4 rounded-[2.2rem] border border-gray-150 inline-block shadow-inner mb-6 mx-auto",children:s.jsx("img",{src:`https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=${encodeURIComponent(window.location.origin+"?scan="+a.id)}`,alt:"Verification QR code",className:"w-48 h-48 rounded-2xl object-contain mx-auto",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"bg-gray-50 p-4 rounded-2xl border border-gray-100",children:[s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest mb-1",children:"Unique Ticket Pass ID"}),s.jsx("code",{className:"text-[10px] font-mono font-black text-gray-950 uppercase select-all",children:a.id})]}),s.jsxs("div",{className:"flex items-center justify-between text-left text-[10px] font-bold text-gray-500 uppercase px-1",children:[s.jsxs("span",{children:["Quantity: ",s.jsxs("strong",{className:"text-gray-900",children:[a.quantity," Pax"]})]}),s.jsxs("span",{children:["Status: ",s.jsx("strong",{className:a.taken||a.used?"text-green-600 font-mono font-black":"text-red-650 font-mono font-black",children:a.taken||a.used?"✔️ TICKED / USED":"🎟️ ACTIVE"})]})]})]}),s.jsx("p",{className:"text-[8px] font-black uppercase tracking-[0.25em] text-gray-400 mt-8 font-mono",children:"Scan at gate to check in"})]})})]})},_9e=({userId:e})=>{const[t,n]=se.useState([]),[r,i]=se.useState(!0),[a,o]=se.useState({}),c=(h,f)=>{f&&f.stopPropagation(),o(m=>({...m,[h]:!m[h]}))};return se.useEffect(()=>{if(!e)return;const h=Qt(it(pe,"notifications"),Nr("userId","==",e));vn(h).then(f=>{const m=f.docs.map(y=>{var A;const w=y.data();return{id:y.id,...w,createdAt:(A=w.createdAt)!=null&&A.toDate?w.createdAt.toDate():new Date(w.createdAt||Date.now())}});m.sort((y,w)=>w.createdAt.getTime()-y.createdAt.getTime()),n(m),i(!1)}).catch(f=>{console.warn("Silent ignore feedback notifications error:",f),i(!1)})},[e]),r?s.jsx("div",{className:"flex justify-center p-4",children:s.jsx(Pr,{className:"animate-spin text-red-600",size:20})}):t.length===0?s.jsx("div",{className:"bg-gray-50 rounded-2xl p-8 text-center text-left",children:s.jsx("p",{className:"text-[10px] font-black text-gray-400 uppercase tracking-widest leading-loose",children:"No active notification dispatches found in your inbox."})}):s.jsx("div",{className:"space-y-3 text-left",children:t.map((h,f)=>{const m=!!a[h.id],y=h.imageUrl||h.image,w=h.fullAnswer||h.message||"";return s.jsxs("div",{className:Ge("p-4 rounded-2xl border transition-all flex flex-col gap-2 relative group overflow-hidden break-words min-w-0",h.used?"bg-gray-50/50 border-gray-100 opacity-80":"bg-red-50/20 border-red-200 shadow-xs"),children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("span",{className:Ge("text-[8px] font-black uppercase px-2 py-0.5 rounded-md flex items-center gap-1",h.used?"bg-gray-100 text-gray-500":"bg-red-650 text-white shadow-2xs"),children:h.type==="admin_mega_reply"||h.type==="mega_ai_reply"?"🤖 AI / Admin Reply":h.used?"Opened":"Unread Dispatch"}),s.jsx("span",{className:"text-[8px] font-mono text-gray-400 leading-none",children:h.createdAt instanceof Date?h.createdAt.toLocaleString([],{dateStyle:"short",timeStyle:"short"}):"Recent"})]}),s.jsx("button",{onClick:A=>c(h.id,A),className:"px-2 py-1 bg-white hover:bg-gray-100 text-gray-700 hover:text-black rounded-lg transition-all cursor-pointer border border-gray-200 shadow-2xs flex items-center gap-1 text-[8.5px] font-black uppercase tracking-wider shrink-0",title:m?"Minimize notification":"Expand notification details",children:m?s.jsxs(s.Fragment,{children:[s.jsx(uf,{size:12,className:"text-red-600"}),s.jsx("span",{children:"Minimize"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Md,{size:12,className:"text-indigo-600"}),s.jsx("span",{children:"Expand"})]})})]}),s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("h4",{className:"text-xs font-black text-gray-900 uppercase tracking-tight flex items-center gap-1.5",children:[s.jsx(es,{size:12,className:"text-amber-500 shrink-0"}),s.jsx("span",{className:"truncate",children:h.title})]}),!m&&s.jsx("p",{className:"text-[10px] text-gray-600 leading-relaxed font-sans mt-1 line-clamp-2 bg-white/60 p-2 rounded-xl border border-gray-100/80",children:w})]}),!m&&y&&s.jsx("div",{onClick:A=>c(h.id,A),className:"w-12 h-12 rounded-xl overflow-hidden border border-gray-200 shrink-0 shadow-2xs relative bg-gray-100 cursor-pointer hover:scale-105 transition-transform",title:"Click to expand image",children:s.jsx(Vi,{src:y,alt:h.title||"Broadcast thumbnail",className:"w-full h-full object-cover"})})]}),m&&s.jsxs("div",{className:"space-y-2.5 mt-1 animate-in fade-in slide-in-from-top-1 duration-200",children:[s.jsx("p",{className:"text-[10.5px] text-gray-700 leading-relaxed font-sans bg-white p-3 rounded-xl border border-gray-200/80 shadow-2xs whitespace-pre-wrap",children:w}),h.userQuery&&s.jsxs("div",{className:"text-[9px] text-gray-500 italic font-mono px-2 py-1.5 bg-gray-50 rounded-lg border border-gray-100",children:[s.jsx("span",{className:"font-bold not-italic text-gray-600",children:"Your Question:"})," ",'"',h.userQuery,'"']}),y&&s.jsxs("div",{className:"rounded-xl overflow-hidden border border-gray-200/90 h-44 sm:h-52 w-full relative shadow-xs bg-black/5",children:[s.jsx(Vi,{src:y,alt:h.title||"Broadcast image",title:h.title,className:"w-full h-full object-cover"}),s.jsx("div",{className:"absolute top-2 right-2 px-2 py-0.5 bg-black/70 backdrop-blur-md text-white text-[8px] font-black uppercase rounded-md tracking-wider border border-white/20",children:"Full Preview"})]}),h.code&&!h.used&&s.jsxs("div",{className:"p-2.5 bg-purple-900/10 border border-purple-200 rounded-xl flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(No,{size:14,className:"text-purple-700 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-[7.5px] font-black uppercase text-purple-900 tracking-wider",children:"Pass Verification Key Code"}),s.jsx("code",{className:"text-xs font-black font-mono text-purple-950 tracking-widest",children:h.code})]})]}),s.jsx("button",{onClick:()=>{navigator.clipboard.writeText(h.code),me.success("Security OTP copied to clipboard!",{icon:"📋"})},className:"px-2.5 py-1 text-[8.5px] font-black uppercase tracking-widest bg-purple-700 hover:bg-purple-800 text-white rounded-lg flex items-center gap-1 cursor-pointer transition-all shadow-xs shrink-0",children:"Copy Key Code"})]}),s.jsxs("div",{className:"pt-2 border-t border-gray-200/60 flex items-center justify-between gap-2 flex-wrap",children:[h.link||h.actionUrl?s.jsxs("a",{href:h.link||h.actionUrl,target:(h.link||h.actionUrl).startsWith("http")?"_blank":"_self",rel:"noopener noreferrer",onClick:()=>{try{const A=localStorage.getItem("clicked_notification_links"),k=A?JSON.parse(A):{};k[h.link||h.actionUrl]=!0,localStorage.setItem("clicked_notification_links",JSON.stringify(k))}catch{}},className:"px-3 py-1.5 bg-indigo-600 hover:bg-indigo-700 text-white text-[9.5px] font-black uppercase tracking-wider rounded-xl transition-all inline-flex items-center gap-1.5 shadow-2xs",children:[s.jsx(Va,{size:11}),s.jsx("span",{children:"Open Attached Link"})]}):s.jsx("div",{}),s.jsxs("button",{onClick:A=>c(h.id,A),className:"px-2.5 py-1 text-[8.5px] font-black uppercase tracking-wider text-gray-700 hover:text-black bg-white hover:bg-gray-100 rounded-lg border border-gray-200 transition-all flex items-center gap-1 cursor-pointer ml-auto",children:[s.jsx(uf,{size:10})," Minimize"]})]})]})]},`notif-${h.id}-${f}`)})})},Mh=e=>{if(!e)return"";let t=e.toLowerCase().trim().replace(/[^a-z0-9]/g,"");return(t==="campusnews"||t==="news"||t==="campus-news")&&(t="news"),(t==="sports"||t==="sport")&&(t="sport"),t};function S9e(){var Xa,Ra,ra,Oo,Fr,uo,ci,ia,Zo,st,mr,Mi;const[e,t]=se.useState(!0),[n,r]=se.useState(!navigator.onLine);se.useEffect(()=>{const ge=()=>{t(document.visibilityState==="visible")};return document.addEventListener("visibilitychange",ge),()=>document.removeEventListener("visibilitychange",ge)},[]),se.useEffect(()=>{const ge=()=>{r(!1),me.success("Connection restored! Syncing latest campus reports...",{icon:"⚡"})},we=()=>{r(!0),me.error("You are currently offline. Accessing previously loaded reports...",{icon:"📦"})};return window.addEventListener("online",ge),window.addEventListener("offline",we),()=>{window.removeEventListener("online",ge),window.removeEventListener("offline",we)}},[]),se.useEffect(()=>{const ge=we=>{if(we.target&&we.target!==window)return;let Te="";if(we instanceof PromiseRejectionEvent){const $e=we.reason;if($e){const ut=String($e.message||$e).toLowerCase();if(ut.includes("offline")||ut.includes("could not reach"))return;Te=$e.message||String($e)}}else if(we instanceof ErrorEvent)Te=we.message||"";else return;!Te||Te==="Script error."||Te.includes("Script error.")||Te.toLowerCase().includes("offline")||Te.toLowerCase().includes("backend didn't respond")||Te.toLowerCase().includes("websocket")||Te.toLowerCase().includes("closed without opened")||console.error("Fatal App Error:",Te)};return window.addEventListener("error",ge),window.addEventListener("unhandledrejection",ge),()=>{window.removeEventListener("error",ge),window.removeEventListener("unhandledrejection",ge)}},[]);const i=(ge,we)=>{const Te=ge?ge.slice(0,2).trim().toUpperCase():"CE",$e=(we==null?void 0:we.toLowerCase())||"news";let ut="%23ef4444";return $e==="sports"&&(ut="%233b82f6"),$e==="opinion"&&(ut="%2310b981"),$e==="lifestyle"&&(ut="%238b5cf6"),$e==="entertainment"&&(ut="%23f59e0b"),`data:image/svg+xml;utf8,${Te}${$e.toUpperCase()}`},a=["atwiinevictor2@gmail.com","campuseye@gmail.com"],[o,c]=se.useState(()=>{try{const ge=localStorage.getItem("campus_eye_articles_cache");return ge?JSON.parse(ge).map(Te=>({...Te,isOfflineCached:!0})):[]}catch{return[]}}),[h,f]=se.useState(()=>{try{const ge=localStorage.getItem("campus_eye_articles_cache");return ge?JSON.parse(ge).map(Te=>({...Te,isOfflineCached:!0})):[]}catch{return[]}}),[m,y]=se.useState(()=>{try{const ge=localStorage.getItem("campus_eye_articles_cache");return ge?JSON.parse(ge).length===0:!0}catch{return!0}}),[w,A]=se.useState(()=>{try{const ge=localStorage.getItem("campus_eye_articles_cache");return ge?JSON.parse(ge).length>0:!1}catch{return!1}}),[k,I]=se.useState(!1),[T,D]=se.useState(1),[F,L]=se.useState(10),[q,Z]=se.useState(25),K=se.useRef(25);K.current=q;const z=se.useRef(o.length);se.useEffect(()=>{z.current=o.length},[o.length]);const B=se.useCallback((ge=15)=>{Z(we=>we+ge)},[]),V=se.useRef(null),$=se.useCallback(ge=>{V.current&&V.current.disconnect(),ge&&(V.current=new IntersectionObserver(we=>{var Te;(Te=we[0])!=null&&Te.isIntersecting&&B()},{rootMargin:"250px"}),V.current.observe(ge))},[B]);se.useCallback(ge=>{if(!ge)return;const we=new IntersectionObserver(Te=>{var $e;($e=Te[0])!=null&&$e.isIntersecting&&B()},{rootMargin:"350px"});return we.observe(ge),()=>we.disconnect()},[B]),se.useEffect(()=>{let ge=null;const we=()=>{ge||(ge=setTimeout(()=>{ge=null,window.innerHeight+window.scrollY>=document.documentElement.scrollHeight-1e3&&B()},100))};return window.addEventListener("scroll",we,{passive:!0}),()=>{window.removeEventListener("scroll",we),ge&&clearTimeout(ge)}},[B]);const[Q,Y]=se.useState([]),[G,he]=se.useState(()=>{try{const ge=window.location.pathname,we=new URLSearchParams(window.location.search);let Te=null,$e=null;if(ge.startsWith("/p/share/")){const lt=ge.split("/p/share/")[1];lt&&(Te=lt.split("/")[0])}else if(ge.includes("/articles=")||ge.startsWith("/articles/")){const At=ge.replace(/^\/articles=?/,"").split("/").filter(Boolean);At.length>=2?($e=At[0],Te=At[1]):At[0]&&(/^[a-zA-Z0-9_-]{15,30}$/.test(At[0])?Te=At[0]:$e=At[0])}else if(ge.startsWith("/poll/")&&ge.includes("/candidate/")){const lt=ge.split("/candidate/");lt[1]&&($e=lt[1].split("/")[0])}Te||(Te=we.get("id")||we.get("articleId")),$e||($e=we.get("articles")||we.get("article"));const ut=localStorage.getItem("campus_eye_articles_cache");if(ut){const lt=JSON.parse(ut);if(Te){const At=lt.find(bn=>bn.id===Te);if(At)return At}if($e){const At=$e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),bn=lt.find(Mt=>{const An=Mt.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return An===At||An.replace(/-/g,".")===At});if(bn)return bn}}}catch{}return null}),[te,le]=se.useState(()=>{try{const ge=window.location.pathname,we=new URLSearchParams(window.location.search);let Te=null,$e=null;if(ge.startsWith("/p/share/")){const ut=ge.split("/p/share/")[1];ut&&(Te=ut.split("/")[0])}else if(ge.includes("/articles=")||ge.startsWith("/articles/")){const lt=ge.replace(/^\/articles=?/,"").split("/").filter(Boolean);lt.length>=2?($e=lt[0],Te=lt[1]):lt[0]&&(/^[a-zA-Z0-9_-]{15,30}$/.test(lt[0])?Te=lt[0]:$e=lt[0])}else if(ge.startsWith("/poll/")&&ge.includes("/candidate/")){const ut=ge.split("/candidate/");ut[1]&&($e=ut[1].split("/")[0])}if(Te||(Te=we.get("id")||we.get("articleId")),$e||($e=we.get("articles")||we.get("article")),Te||$e){const ut=localStorage.getItem("campus_eye_articles_cache");if(ut){const lt=JSON.parse(ut);if(Te&<.some(At=>At.id===Te))return!1;if($e){const At=$e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(lt.some(bn=>{const Mt=bn.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return Mt===At||Mt.replace(/-/g,".")===At}))return!1}}return!0}}catch{}return!1}),[ve,ke]=se.useState(()=>{try{const ge=localStorage.getItem("campus_eye_custom_pages_cache");return ge?JSON.parse(ge):[]}catch{return[]}}),[Be,J]=se.useState(null),[ie,xe]=se.useState(!1),[ae,Fe]=se.useState(!1),[pt,Ue]=se.useState(null);se.useEffect(()=>{const ge=we=>{const Te=we;Te.detail&&Ue(Te.detail)};return window.addEventListener("play-video-podcast",ge),()=>{window.removeEventListener("play-video-podcast",ge)}},[]);const[Ct,Tt]=se.useState(null),[ht,Ye]=se.useState(null),[Yt,dt]=se.useState(null),[sn,pn]=se.useState(!1),[Fn,Ft]=se.useState(!1),[Dt,Ht]=se.useState(null),[Ze,Wt]=se.useState(null),[It,ln]=se.useState(!1),[Kn,un]=se.useState(!1),[xr,Ve]=se.useState(null),[Ot,nn]=se.useState(null),[mn,dr]=se.useState(null);se.useEffect(()=>{const ge=new URLSearchParams(window.location.search),we=ge.get("scan");we&&Ht(we);const Te=window.location.pathname;let $e=ge.get("postId")||ge.get("post"),ut=ge.get("pinnedId")||ge.get("pinned"),lt=ge.get("advertId")||ge.get("advert");if(Te.startsWith("/p/post/")){const bn=Te.split("/p/post/")[1];$e=bn?bn.split("/")[0]:null}else if(Te.startsWith("/p/pinned/")){const bn=Te.split("/p/pinned/")[1];ut=bn?bn.split("/")[0]:null}else if(Te.startsWith("/p/ad/")){const bn=Te.split("/p/ad/")[1];lt=bn?bn.split("/")[0]:null}$e&&(Tt($e),je("posts"),me.success("Shared campus dispatch loaded!",{icon:"📣"})),ut&&(Ye(ut),je("home"),me.success("Shared pinned announcement loaded!",{icon:"📌"})),lt&&(dt(lt),je("home"),me.success("Partnership offer loaded!",{icon:"⭐"}));const At=ge.get("invite");if(At){let bn="A peer";At.endsWith("-invites-you")?bn=At.replace("-invites-you","").split("-").map(Rn=>Rn.charAt(0).toUpperCase()+Rn.slice(1)).join(" "):At!=="student-lounge"&&(bn=At.split("-").map(An=>An.charAt(0).toUpperCase()+An.slice(1)).join(" ")),je("posts"),me.success(`Welcome! ${bn} has invited you to join the Campus Eye Student Lounge! 🤝`,{duration:6e3,icon:"👋"});const Mt=new URL(window.location.href);Mt.searchParams.delete("invite"),window.history.replaceState({},"",Mt.toString())}},[]),se.useEffect(()=>{const ge=()=>{xe(!0)};return window.addEventListener("open-lounge-auth",ge),()=>{window.removeEventListener("open-lounge-auth",ge)}},[]),se.useEffect(()=>{if(!Dt){Wt(null);return}ln(!0),cs(ot(pe,"purchases",Dt)).then(ge=>{ge.exists()?Wt({id:ge.id,...ge.data()}):(me.error("Ticket purchase record not found!"),Ht(null)),ln(!1)}).catch(ge=>{console.error("Error fetching scanned ticket:",ge),me.error("Error retrieving scanned ticket."),ln(!1),Ht(null)})},[Dt]);const[hr,Ui]=se.useState(()=>{try{const ge=window.location.pathname;if(ge==="/u/dashboard")return"admin";if(ge.startsWith("/u/profile"))return"account";const Te=new URLSearchParams(window.location.search).get("tab");if(Te)return Te==="news"||Te==="campusnews"||Te==="campus-news"?"home":Te}catch{}return"home"}),[$n,be]=se.useState("home"),je=ge=>{const we=ge==="news"||ge==="campusnews"||ge==="campus-news"?"home":ge;be(hr),Ui(we)},ze=hr,[tt,fn]=se.useState("all"),[Bt,jn]=se.useState(null),[jt,on]=se.useState(null),[Ir,pr]=se.useState(!1),[ue,Se]=se.useState(0),[Xe,Vt]=se.useState(0),[gn,xn]=se.useState(!1),[yn,gt]=se.useState("dashboard"),[Tn,Nt]=se.useState(()=>{try{return localStorage.getItem("just_signed_up")==="true"}catch{return!1}}),[Ae,tn]=se.useState([]),[yt,cn]=se.useState(!1);se.useEffect(()=>{try{const ge=new URL(window.location.href),we=ge.pathname;if(hr==="admin")we!=="/u/dashboard"&&window.history.replaceState({},"","/u/dashboard");else if(hr==="account")if(jt){const Te=`/u/profile/${jt.id}`;we!==Te&&window.history.replaceState({},"",Te)}else we!=="/u/profile"&&window.history.replaceState({},"","/u/profile");else if(G){const Te=G.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),$e=`/p/share/${G.id}/${Te}`;we!==$e&&window.history.replaceState({},"",$e)}else{const Te=new URLSearchParams(window.location.search);hr==="home"?Te.delete("tab"):Te.set("tab",hr);const $e=Te.toString(),ut="/"+($e?`?${$e}`:"");(we!=="/"||ge.search!==($e?`?${$e}`:""))&&window.history.replaceState({},"",ut)}}catch(ge){console.warn("Path sync fail:",ge)}},[hr,jt,G]),se.useEffect(()=>{const ge=Ne.onAuthStateChanged(async we=>{var Te,$e;if(we)try{const ut=ot(pe,"users",we.uid),lt=["atwiinevictor2@gmail.com","campuseye@gmail.com"],At=await cs(ut),bn=At.exists()?At.data():{},An=lt.includes(we.email||"")||bn.isAdmin===!0||bn.role==="admin";await Hr(ut,{uid:we.uid,email:we.email||"",displayName:bn.displayName||we.displayName||((Te=we.email)==null?void 0:Te.split("@")[0])||"Campus Member",username:bn.username||(($e=we.email)==null?void 0:$e.split("@")[0])||"user",photoURL:bn.photoURL||we.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(we.displayName||"User")}&background=random`,role:An?"admin":bn.role||"user",isAdmin:An,updatedAt:Bn()},{merge:!0});const Rn=localStorage.getItem("campus_eye_personalization_v1");if(Rn&&JSON.parse(Rn).interests){Nt(!1),await Hr(ut,{interests:JSON.parse(Rn).interests},{merge:!0});return}if(At.exists()){const _=At.data();if(_!=null&&_.interests&&Array.isArray(_.interests)&&_.interests.length>0){const U={interests:_.interests,categories:{}};_.interests.forEach(H=>{U.categories[H]=150}),localStorage.setItem("campus_eye_personalization_v1",JSON.stringify(U)),localStorage.removeItem("just_signed_up"),Nt(!1);return}}localStorage.getItem("just_signed_up")==="true"&&Nt(!0)}catch{}});return()=>ge()},[]),se.useEffect(()=>{try{const ge=window.location.pathname;let we=null;if(ge.startsWith("/u/profile/")?we=ge.split("/u/profile/")[1]:we=new URLSearchParams(window.location.search).get("uid"),we&&Ne.currentUser&&we===Ne.currentUser.uid){on(null);return}hr==="account"&&we?(pr(!0),cs(ot(pe,"users",we)).then(Te=>{Te.exists()?on({id:Te.id,...Te.data()}):(me.error("Requested peer profile was not found on Campus Eye.",{id:"profile-not-found"}),on(null)),pr(!1)}).catch(Te=>{console.warn("Shared user fetch fail:",Te),pr(!1)})):on(null)}catch{}},[hr,(Xa=Ne.currentUser)==null?void 0:Xa.uid]);const Pt=ge=>{var we;try{if(!ge)return;if(ge===((we=Ne.currentUser)==null?void 0:we.uid)){on(null),je("account");return}pr(!0),cs(ot(pe,"users",ge)).then(Te=>{Te.exists()?(on({id:Te.id,...Te.data()}),je("account")):(me.error("Requested peer profile was not found on Campus Eye.",{id:"profile-not-found"}),on(null)),pr(!1)}).catch(Te=>{console.warn("Shared user fetch fail:",Te),pr(!1)})}catch(Te){console.warn("Navigate to profile failed:",Te)}};se.useEffect(()=>{if(!jt){Se(0),Vt(0),xn(!1);return}try{const ge=it(pe,"follows");vn(ge).then(we=>{let Te=0,$e=0,ut=!1;we.docs.forEach(lt=>{const At=lt.data();At.followerId===jt.id&&Te++,At.followedId===jt.id&&$e++,Ne.currentUser&&At.followerId===Ne.currentUser.uid&&At.followedId===jt.id&&(ut=!0)}),Se(Te),Vt($e),xn(ut)}).catch(we=>console.warn("Quiet ignore query follows constraint:",we))}catch(ge){console.warn("Silent follows fail:",ge)}},[jt,(Ra=Ne.currentUser)==null?void 0:Ra.uid]),se.useEffect(()=>(window.triggerAuthWithCallback=ge=>{ge?window.onAuthPendingAction=ge:window.onAuthPendingAction=void 0,xe(!0)},()=>{window.triggerAuthWithCallback=void 0,window.onAuthPendingAction=void 0}),[]);const[Sn,_r]=se.useState(0),[xi,rs]=se.useState(0),[mi,fa]=se.useState(0),[is,hi]=se.useState([]),Wr=se.useMemo(()=>[...ve.filter(we=>we.isPinnedStyle===!0).map(we=>{var ut,lt,At,bn;let Te="";try{we.url.includes("v=")?Te=((ut=we.url.split("v=")[1])==null?void 0:ut.split("&")[0])||"":we.url.includes("youtu.be/")?Te=((lt=we.url.split("youtu.be/")[1])==null?void 0:lt.split("?")[0])||"":we.url.includes("embed/")&&(Te=((At=we.url.split("embed/")[1])==null?void 0:At.split("?")[0])||"")}catch{}const $e=Te?`https://img.youtube.com/vi/${Te}/maxresdefault.jpg`:i(we.name,"Custom Tab");return{id:`custom-page-${we.id}`,title:we.name,description:we.description||"Interactive broadcast and real-time live chat channel.",isLiveStream:we.type==="youtube"||we.type==="custom_stream",liveEmbedUrl:we.url,link:"",active:!0,durationSeconds:15,imageUrl:we.type==="youtube"?$e:i(we.name,"Custom Tab"),createdAt:(bn=we.createdAt)!=null&&bn.seconds?new Date(we.createdAt.seconds*1e3):new Date,isCustomPagePromo:!0,originalPage:we}}),...is],[ve,is]),[Sr,Qi]=se.useState([]);se.useEffect(()=>{const ge=Qt(it(pe,"debates"),pi("createdAt","desc"));vn(ge).then(we=>{const Te=we.docs.map($e=>{const ut=$e.data();return{id:$e.id,...ut,createdAt:ut.createdAt?ut.createdAt.toDate?ut.createdAt.toDate():new Date(ut.createdAt):new Date}});Qi(Te)}).catch(we=>{console.warn("Silent ignored debates fetch error:",we)})},[]);const[ss,si]=se.useState(null),[Et,Oa]=se.useState(!1),[Tr,Hi]=se.useState([]);se.useEffect(()=>{const ge=Qt(it(pe,"posts"),pi("createdAt","desc"),Pi(25)),we=di(ge,Te=>{const $e=Te.docs.map(ut=>({id:ut.id,...ut.data()})).filter(ut=>!ut.flagged);Hi($e)},Te=>{console.warn("Silent ignored sidebar posts subscription error:",Te)});return()=>we()},[]),se.useEffect(()=>{const ge=we=>{we.preventDefault(),window.deferredPrompt=we,si(we),Oa(!0)};return window.addEventListener("beforeinstallprompt",ge),()=>{window.removeEventListener("beforeinstallprompt",ge)}},[]),se.useEffect(()=>{window.scrollTo({top:0,behavior:"auto"}),document.querySelectorAll(".overflow-y-auto").forEach(we=>{we.scrollTop=0})},[ze,yn]),se.useEffect(()=>{const ge=Qt(it(pe,"pinned_announcements"));vn(ge).then(we=>{const Te=we.docs.map($e=>{const ut=$e.data();return{id:$e.id,...ut,createdAt:ut.createdAt?ut.createdAt.toDate?ut.createdAt.toDate():new Date(ut.createdAt):new Date(0)}}).filter($e=>$e.active===!0).sort(($e,ut)=>ut.createdAt.getTime()-$e.createdAt.getTime());hi(Te)}).catch(we=>{console.warn("Failed to load pinned announcements for home feed:",we)})},[]),se.useEffect(()=>{const ge=Qt(it(pe,"custom_pages"),pi("createdAt","desc"));vn(ge).then(we=>{const Te=we.docs.map($e=>({id:$e.id,...$e.data()}));ke(Te);try{localStorage.setItem("campus_eye_custom_pages_cache",JSON.stringify(Te))}catch($e){console.warn("Failed to cache custom pages:",$e)}}).catch(we=>{console.warn("Silent ignore custom menus loading issue:",we)})},[]);const[jo,or]=se.useState(!1),[kr,lr]=se.useState("followers"),[Re,mt]=se.useState(null),[Je,vt]=se.useState(null);se.useEffect(()=>{const ge=we=>{we.detail&&vt(we.detail)};return window.addEventListener("open-imessage-friend",ge),()=>window.removeEventListener("open-imessage-friend",ge)},[]),se.useEffect(()=>{if(typeof window<"u"&&"serviceWorker"in navigator){const ge=async we=>{if(we.data&&we.data.type==="NOTIFICATION_REPLY"){const{notifData:Te,replyText:$e}=we.data,ut=Ne.currentUser;if(!ut||!$e)return;try{const lt=ut.displayName||"Campus Peer",At=(ut.displayName||"member").toLowerCase().replace(/\s+/g,""),bn=(Te==null?void 0:Te.senderId)||(Te==null?void 0:Te.userId);bn&&(await ur(it(pe,"notifications"),{userId:bn,senderId:ut.uid,senderName:lt,senderUsername:At,senderPhotoURL:ut.photoURL||"",title:`💬 Lockscreen Direct Reply from ${lt}`,message:String($e).trim(),type:"direct_message",canReply:!0,used:!1,createdAt:new Date}),me.success("Lockscreen direct reply sent!",{icon:"📲"}))}catch(lt){console.error("Lockscreen reply handler error:",lt)}}};return navigator.serviceWorker.addEventListener("message",ge),()=>navigator.serviceWorker.removeEventListener("message",ge)}},[]),se.useEffect(()=>{const ge=Ne.onAuthStateChanged(we=>{if(we){const Te=we.uid;try{const $e=Qt(it(pe,"follows"),Nr("followedId","==",Te)),ut=Qt(it(pe,"follows"),Nr("followerId","==",Te));Promise.all([vn($e),vn(ut)]).then(([lt,At])=>{rs(lt.size),_r(At.size)}).catch(lt=>console.warn("Follows count error:",lt))}catch($e){console.warn("Follows collection hook error:",$e)}try{const $e=Qt(it(pe,"invitations"),Nr("status","==","accepted"));vn($e).then(ut=>{let lt=0;ut.docs.forEach(At=>{const bn=At.data();(bn.senderId===Te||bn.receiverId===Te)&<++}),fa(lt)}).catch(ut=>console.warn("Invites fetch error:",ut))}catch($e){console.warn("Invites collection hook error:",$e)}}else _r(0),rs(0),fa(0)});return()=>{ge()}},[]),se.useEffect(()=>{ze!=="account"&&ze!=="admin"&&be(ze),window.scrollTo({top:0,behavior:"auto"})},[ze]);const[Zt,wn]=se.useState(""),[Le,Ut]=se.useState(""),[On,Mn]=se.useState(null),[Pn,vr]=se.useState([]),[Me,fe]=se.useState(null),[rn,ai]=se.useState(null),[oi,yi]=se.useState(!1),[gi,Gi]=se.useState(!1),[en,wr]=se.useState(!1),[na,Ms]=se.useState(!1),[Pa,ks]=se.useState("");se.useEffect(()=>{Ne.currentUser&&ks(Ne.currentUser.displayName||"")},[(ra=Ne.currentUser)==null?void 0:ra.displayName]);const[Nl,Ks]=se.useState(0),[Si,Cs]=se.useState(0),[Is,Gn]=se.useState("recent"),[Ls,Yn]=se.useState({name:"",email:((Oo=Ne.currentUser)==null?void 0:Oo.email)||"",subject:"General Feedback",message:""}),[li,To]=se.useState(!0),[zr,Ka]=se.useState(!1),[Us,Qo]=se.useState(localStorage.getItem("pinnedSize")||"small"),[Ya,pa]=se.useState(1),bs=ge=>{Qo(ge),localStorage.setItem("pinnedSize",ge)};se.useEffect(()=>{const ge=()=>{To(window.scrollY<12)};return window.addEventListener("scroll",ge,{passive:!0}),()=>window.removeEventListener("scroll",ge)},[]),se.useEffect(()=>{if(o.length>0&&e){const ge=setInterval(()=>{Ks(we=>(we+1)%Math.min(5,o.length))},5e3);return()=>clearInterval(ge)}},[o,e]),se.useEffect(()=>{if(o.length>0&&e){const ge=setInterval(()=>{Cs(we=>(we+1)%Math.min(6,o.length))},4e3);return()=>clearInterval(ge)}},[o,e]),se.useEffect(()=>{const ge=lt=>{lt.detail==="tickets"?Ft(!0):(je(lt.detail),J(null))},we=lt=>he(lt.detail),Te=lt=>J(lt.detail),$e=lt=>{const At=lt.detail;At&&At.id&&(Tt(At.id),je("posts"),me.success(`Opening conversation by @${(At.authorName||"peer").toLowerCase().replace(/\s+/g,"")}...`,{icon:"📣"}))},ut=lt=>{const At=lt.detail;At&&At.uid&&(Pt(At.uid),me.success(`Opening profile of @${(At.displayName||"peer").toLowerCase().replace(/\s+/g,"")}...`,{icon:"👤"}))};return window.addEventListener("setTab",ge),window.addEventListener("selectArticle",we),window.addEventListener("selectCustomPage",Te),window.addEventListener("selectPost",$e),window.addEventListener("selectUser",ut),()=>{window.removeEventListener("setTab",ge),window.removeEventListener("selectArticle",we),window.removeEventListener("selectCustomPage",Te),window.removeEventListener("selectPost",$e),window.removeEventListener("selectUser",ut)}},[]),se.useEffect(()=>{var bn,Mt;let ge="Campus Newsroom - Live Social Hub & Archival Feeds",we="Discover real-time student conversations, official dispatches, ticketing services, live streams, and our complete historical publication archive.",Te="https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",$e="website",ut=null;if(G){ge=`${G.title} | Campus Newsroom`,we=G.summary||((bn=G.content)==null?void 0:bn.slice(0,150))||we;const An=[G.featuredImageUrl,G.featuredImageUrl1,G.featuredImageUrl2,G.featuredImage,G.imageUrl,G.image,G.photo,G.coverImage,G.thumbnail,G.mediaUrl,G.bannerUrl];let Rn="";const qe=[G.video,G.videoUrl,G.Links].filter(Boolean);for(const H of qe){const re=H.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|shorts\/)([^#\&\?]*).*/);if(re&&re[2].length===11){Rn=`https://img.youtube.com/vi/${re[2]}/hqdefault.jpg`;break}}let _="";if(G.content){const H=G.content.match(/]+src=["'](https?:\/\/[^"'\s]+)["']/i)||G.content.match(/!\[.*?\]\((https?:\/\/[^\s\)]+)\)/i);H&&H[1]&&(_=H[1])}const U=An.find(H=>H&&typeof H=="string"&&H.trim().length>5)||Rn||_;Te=U?U.startsWith("data:")?`${window.location.origin}/api/article-image/${G.id}`:U:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",$e="article",ut={"@context":"https://schema.org","@type":"NewsArticle",headline:G.title,description:G.summary,image:[Te],datePublished:G.publishDate||new Date().toISOString(),author:{"@type":"Person",name:G.authorName||"News Editor"}}}else Be?(ge=`${Be.title} | Campus Publication`,we=((Mt=Be.content)==null?void 0:Mt.slice(0,150))||we,$e="article"):ze==="posts"&&(ge="Student Lounge Feed | Live Conversations",we="Browse real-time announcements, debates, and posts shared directly by students and admins on our campus social forum.");document.title=ge;const lt=(An,Rn,qe=!1)=>{let _=document.querySelector(qe?`meta[name="${An}"]`:`meta[property="${An}"]`);_||(_=document.createElement("meta"),qe?_.setAttribute("name",An):_.setAttribute("property",An),document.head.appendChild(_)),_.setAttribute("content",Rn)};lt("description",we,!0),lt("og:title",ge),lt("og:description",we),lt("og:image",Te),lt("og:type",$e),lt("twitter:card","summary_large_image",!0),lt("twitter:title",ge,!0),lt("twitter:description",we,!0),lt("twitter:image",Te,!0);const At=document.getElementById("json-ld-seo");if(At&&At.remove(),ut){const An=document.createElement("script");An.id="json-ld-seo",An.type="application/ld+json",An.innerHTML=JSON.stringify(ut),document.head.appendChild(An)}},[G,Be,ze]),se.useEffect(()=>{},[]),se.useEffect(()=>{const ge=Ne.onAuthStateChanged(async we=>{var Te;if(we){try{const Mt=ot(pe,"users",we.uid);if(!(await cs(Mt)).exists()){const Rn=a.includes(we.email||"");await Hr(Mt,{uid:we.uid,email:we.email||"",displayName:we.displayName||"Campus Member",photoURL:we.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(we.displayName||"User")}&background=random`,role:Rn?"admin":"user",isAdmin:Rn,createdAt:Bn(),updatedAt:Bn()},{merge:!0}),Rn&&await Hr(ot(pe,"admins",we.uid),{email:we.email||"",isAdmin:!0,createdAt:Bn()},{merge:!0})}}catch(Mt){if(Mt.code==="permission-denied"||(Te=Mt.message)!=null&&Te.includes("insufficient permissions")){const An={error:Mt.message,operationType:"write",path:`users/${we.uid}`,authInfo:{userId:we.uid,email:we.email,emailVerified:we.emailVerified}};console.error("Firestore Permission Error:",JSON.stringify(An))}else{const An=String((Mt==null?void 0:Mt.message)||Mt);An.toLowerCase().includes("offline")||An.toLowerCase().includes("could not reach")?console.warn("Error in safety user sync (offline):",Mt):console.error("Error in safety user sync:",Mt)}}try{const Mt=localStorage.getItem("pending_follow_uid"),An=localStorage.getItem("pending_follow_name");if(Mt&&Mt!==we.uid){const Rn=`${we.uid}_${Mt}`;await Hr(ot(pe,"follows",Rn),{followerId:we.uid,followedId:Mt,createdAt:new Date});const qe=we.displayName?`@${we.displayName.toLowerCase().replace(/\s+/g,"")}`:"A peer";await Hr(ot(pe,"notifications",`notif_follow_${we.uid}_${Mt}`),{userId:Mt,title:"🤝 Lounge Connect",message:`${qe} followed you!`,type:"social",used:!0,createdAt:new Date}),me.success(`You are now successfully following ${An||"peer"}!`,{icon:"🎉"}),localStorage.removeItem("pending_follow_uid"),localStorage.removeItem("pending_follow_name"),je("home")}}catch(Mt){console.error("Failed to complete pending follow on auth transition:",Mt)}const $e=ot(pe,"users",we.uid),ut=ot(pe,"admins",we.uid);let lt=!1,At=!1;const bn=()=>{const Mt=lt||At||a.includes(we.email||"");Gi(Mt),localStorage.setItem("is_admin_cached",Mt?"true":"false")};di($e,Mt=>{if(Mt.exists()){const An=Mt.data();lt=(An==null?void 0:An.isAdmin)===!0||(An==null?void 0:An.role)==="admin"}bn()},Mt=>console.warn("App user doc admin snapshot fail:",Mt)),di(ut,Mt=>{if(Mt.exists()){const An=Mt.data();At=(An==null?void 0:An.isAdmin)===!0}bn()},Mt=>console.warn("App admin doc snapshot fail:",Mt))}else Yn($e=>({...$e,email:(we==null?void 0:we.email)||$e.email})),Gi(!1),je("home")});return()=>{ge()}},[]),se.useEffect(()=>{I(!0);const ge=setTimeout(()=>{I(!1)},250);return()=>clearTimeout(ge)},[]),se.useEffect(()=>{if(!G)return;const ge=Date.now(),we=G.category||"General";return()=>{const Te=Date.now(),$e=Math.round((Te-ge)/1e3);if($e>=1)try{const ut=localStorage.getItem("campus_eye_personalization_v1"),lt=ut?JSON.parse(ut):{categories:{}};lt.categories||(lt.categories={}),lt.categories[we]||(lt.categories[we]=0),lt.categories[we]+=$e,lt.readArticles||(lt.readArticles=[]),lt.readArticles.includes(G.id)||lt.readArticles.push(G.id),localStorage.setItem("campus_eye_personalization_v1",JSON.stringify(lt))}catch(ut){console.warn("Personalization tracking quiet fail:",ut)}}},[G]),se.useEffect(()=>{if(!te)if(G){const we=`/articles=${G.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}/${G.id}`,Te=`${G.title} | Campus Eye Media`;window.location.pathname!==we&&window.history.pushState({articleId:G.id},"",we),document.title=Te;const $e=(U,H,re)=>{let Oe=document.querySelector(`meta[${U}="${H}"]`);Oe||(Oe=document.createElement("meta"),Oe.setAttribute(U,H),document.head.appendChild(Oe)),Oe.setAttribute("content",re)},ut=(U,H)=>{let re=document.querySelector(`link[rel="${U}"]`);re||(re=document.createElement("link"),re.setAttribute("rel",U),document.head.appendChild(re)),re.setAttribute("href",H)},lt=G.title,At=G.summary||G.title,bn=[G.featuredImageUrl,G.featuredImageUrl1,G.featuredImageUrl2,G.featuredImage,G.imageUrl,G.image,G.photo,G.coverImage,G.cover,G.thumbnail,G.mediaUrl,G.bannerUrl];let Mt="";const An=[G.video,G.videoUrl,G.Links].filter(Boolean);for(const U of An){const H=U.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|shorts\/)([^#\&\?]*).*/);if(H&&H[2].length===11){Mt=`https://img.youtube.com/vi/${H[2]}/hqdefault.jpg`;break}}let Rn="";if(G.content){const U=G.content.match(/]+src=["'](https?:\/\/[^"'\s]+)["']/i)||G.content.match(/!\[.*?\]\((https?:\/\/[^\s\)]+)\)/i);U&&U[1]&&(Rn=U[1])}const qe=bn.find(U=>U&&typeof U=="string"&&U.trim().length>5)||Mt||Rn,_=qe?qe.startsWith("data:")?`${window.location.origin}/api/article-image/${G.id}`:qe:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg";$e("property","og:title",lt),$e("property","og:image",_),$e("property","og:image:url",_),$e("property","og:image:secure_url",_),$e("property","og:description",At),$e("property","og:url",window.location.href),$e("name","description",At),$e("name","twitter:title",lt),$e("name","twitter:description",At),$e("name","twitter:image",_),$e("name","twitter:image:src",_),_&&ut("image_src",_);try{let U=document.getElementById("article-seo-schema");U||(U=document.createElement("script"),U.setAttribute("id","article-seo-schema"),U.setAttribute("type","application/ld+json"),document.head.appendChild(U));let H=new Date().toISOString();if(G.publishDate)try{const re=G.publishDate;typeof re.toDate=="function"?H=re.toDate().toISOString():re instanceof Date?H=re.toISOString():typeof re=="string"||typeof re=="number"?H=new Date(re).toISOString():re.seconds!==void 0&&(H=new Date(re.seconds*1e3).toISOString())}catch{}U.textContent=JSON.stringify({"@context":"https://schema.org","@type":"NewsArticle",headline:G.title,image:[G.featuredImageUrl].filter(Boolean),datePublished:H,dateModified:H,author:{"@type":"Person",name:G.authorName||"Campus Eye Reporter"},publisher:{"@type":"Organization",name:"Campus Eye Media",url:window.location.origin,logo:{"@type":"ImageObject",url:`${window.location.origin}/logo.png`}},description:G.summary||G.title})}catch(U){console.warn("Schema injection failed:",U)}}else{(window.location.pathname.includes("/articles=")||window.location.pathname.startsWith("/articles/")||window.location.pathname.startsWith("/poll/")&&window.location.pathname.includes("/candidate/")||window.location.search.includes("articles=")||window.location.search.includes("article="))&&window.history.pushState({},"","/"),document.title="Campus Eye Media | Latest News, Sports, and Campus Updates";const ge=document.getElementById("article-seo-schema");ge&&ge.remove()}},[G,te]),se.useEffect(()=>{const ge=localStorage.getItem("campus_eye_theme")||"light";document.body.classList.remove("theme-dark","theme-sepia"),ge!=="light"&&document.body.classList.add(`theme-${ge}`);const we=$e=>{const ut=$e.detail.theme;document.body.classList.remove("theme-dark","theme-sepia"),ut!=="light"&&document.body.classList.add(`theme-${ut}`)};window.addEventListener("theme-changed",we);const Te=$e=>{const ut=$e.detail;if(ut&&ut.id){const lt=o.find(At=>At.id===ut.id);lt?he(lt):cs(ot(pe,"articles",ut.id)).then(At=>{At.exists()&&he({id:At.id,...At.data()})}).catch(At=>console.warn("Could not load article offline:",At))}};return window.addEventListener("open-article",Te),()=>{window.removeEventListener("theme-changed",we),window.removeEventListener("open-article",Te)}},[o]),se.useEffect(()=>{o.length===0&&y(!0);const ge=Qt(it(pe,"articles"),pi("publishDate","desc"),Pi(q)),we=setTimeout(()=>{y(!1),A(!0)},150),Te=di(ge,$e=>{const ut=$e.metadata.fromCache,lt=$e.docs.map(At=>({id:At.id,...At.data(),isOfflineCached:ut||!navigator.onLine}));c(lt);try{const Mt=lt.map(({isOfflineCached:An,...Rn})=>Rn).slice(0,25).map(An=>{const Rn={...An};return Rn.featuredImageUrl&&Rn.featuredImageUrl.startsWith("data:")&&Rn.featuredImageUrl.length>75e3&&(Rn.featuredImageUrl=i(Rn.title,Rn.category)),Rn.imageUrl&&Rn.imageUrl.startsWith("data:")&&(Rn.imageUrl=""),Rn.content&&(Rn.content=Rn.content.length>1e3?Rn.content.slice(0,1e3):Rn.content),Rn});try{localStorage.setItem("campus_eye_articles_cache",JSON.stringify(Mt))}catch{try{const Rn=Mt.map(qe=>({id:qe.id,title:qe.title,summary:qe.summary,category:qe.category,publishDate:qe.publishDate,authorName:qe.authorName}));localStorage.setItem("campus_eye_articles_cache",JSON.stringify(Rn.slice(0,10)))}catch{localStorage.removeItem("campus_eye_articles_cache"),console.warn("Storage quota exceeded. Cleared articles cache key.")}}}catch(At){console.warn("Failed to cache articles:",At)}y(!1),A(!0),clearTimeout(we)},$e=>{const ut=$e instanceof Error?$e.message:String($e);if(ut.toLowerCase().includes("offline")||ut.toLowerCase().includes("permission")||ut.toLowerCase().includes("failed-precondition"))console.warn("Firestore collection list offline fallback initiated:",$e);else try{Gs($e,Ps.LIST,"articles")}catch(lt){console.error("Firestore Error in articles stream:",lt)}y(!1),A(!0),clearTimeout(we)});return()=>{Te(),clearTimeout(we)}},[q]),se.useEffect(()=>{let ge=o;const $e=Array.from(new Set(o.map(ut=>ut.category).filter(Boolean))).map(ut=>Mh(ut)).includes(Mh(ze));if(Zt.trim()){const ut=Zt.toLowerCase();ge=o.filter(lt=>lt.title&<.title.toLowerCase().includes(ut)||lt.content&<.content.toLowerCase().includes(ut)||lt.summary&<.summary.toLowerCase().includes(ut)||lt.category&<.category.toLowerCase().includes(ut))}else $e&&(ge=o.filter(ut=>Mh(ut.category)===Mh(ze)));f(ge)},[o,ze,Zt]),se.useEffect(()=>{if(o.length>0){const we=[...o.length>3?o.slice(3):o].sort(()=>Math.random()-.5);Y(we.slice(0,8))}},[o]),se.useEffect(()=>{var Rn;const ge=Qt(it(pe,"adverts"),Nr("status","==","active"));vn(ge).then(qe=>{const _=qe.docs.map(Nn=>({id:Nn.id,...Nn.data()})),U=Date.now(),re=[..._.filter(Nn=>!Nn.expiresAt||Nn.expiresAt.toMillis()>U)].sort((Nn,Jn)=>{var Qr,Kr;const Br=(Qr=Nn.createdAt)!=null&&Qr.toMillis?Nn.createdAt.toMillis():0;return((Kr=Jn.createdAt)!=null&&Kr.toMillis?Jn.createdAt.toMillis():0)-Br});vr(re);const Oe=re.filter(Nn=>Nn.type==="image"||!Nn.type&&Nn.imageUrl),We=re.filter(Nn=>Nn.type==="video"),Ce=Nn=>{if(Nn.length===0)return null;const Jn=Math.floor(Math.pow(Math.random(),1.8)*Nn.length);return Nn[Jn]},_t=Ce(Oe),qn=Ce(We);_t&&fe(_t),qn&&ai(qn)}).catch(qe=>{Gs(qe,Ps.LIST,"adverts")});const we=setTimeout(()=>y(!1),1e3),Te=setInterval(()=>{document.visibilityState==="visible"&&vr(qe=>{const _=qe.filter(We=>We.type==="image"||!We.type&&We.imageUrl),U=qe.filter(We=>We.type==="video"),H=We=>{if(We.length===0)return null;const Ce=Math.floor(Math.pow(Math.random(),1.8)*We.length);return We[Ce]},re=H(_),Oe=H(U);return re&&fe(re),Oe&&ai(Oe),qe})},5e3);di(Qt(it(pe,"notifications"),Nr("userId","==",((Rn=Ne.currentUser)==null?void 0:Rn.uid)||"guest")),qe=>{qe.docChanges().forEach(_=>{if(_.type==="added"){const U=_.doc.data();if(!U.used&&(U.type==="admin_mega_reply"||U.type==="mega_ai_reply"||U.playSound)){try{const H=window.AudioContext||window.webkitAudioContext;if(H){const re=new H,Oe=re.createOscillator(),We=re.createGain();Oe.type="sine",Oe.frequency.setValueAtTime(587.33,re.currentTime),Oe.frequency.exponentialRampToValueAtTime(880,re.currentTime+.12),We.gain.setValueAtTime(.25,re.currentTime),We.gain.exponentialRampToValueAtTime(.001,re.currentTime+.3),Oe.connect(We),We.connect(re.destination),Oe.start(),Oe.stop(re.currentTime+.3)}}catch{}me.custom(H=>s.jsxs("div",{onClick:()=>{me.dismiss(H.id),je("account")},className:`${H.visible?"animate-enter":"animate-leave"} cursor-pointer max-w-md w-full bg-white shadow-2xl rounded-2xl border border-red-200 p-4 flex items-center gap-3 ring-1 ring-black/5`,children:[s.jsx("div",{className:"p-2.5 bg-red-100 text-red-650 rounded-xl shrink-0",children:s.jsx(es,{size:18})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-xs font-black uppercase text-gray-950 tracking-tight",children:U.title||"🤖 Admin / AI Replied!"}),s.jsx("p",{className:"text-[10px] text-gray-600 line-clamp-2 mt-0.5",children:U.message||U.fullAnswer})]})]}),{duration:7500,position:"top-right"})}}})},qe=>{console.warn("Silent notification listener info:",qe)}),yK().catch(()=>null);const $e=new Date(Date.now()-300*1e3),ut=new Set,lt=Qt(it(pe,"articles"),Nr("publishDate",">",jr.fromDate($e)),pi("publishDate","desc")),At=di(lt,qe=>{qe.docs.forEach(_=>{const U=_.id;if(ut.has(U))return;ut.add(U);const H=_.data();c1(H.title||"Campus Eye Dispatch",{body:H.summary||H.category||"A new article was uploaded to Campus Eye! Tap to read.",tag:`article-${U}`,renotify:!0}),me.custom(re=>s.jsxs("div",{className:`${re.visible?"animate-enter":"animate-leave"} max-w-md w-full bg-white shadow-2xl pointer-events-auto flex ring-1 ring-black ring-opacity-5 border-l-4 border-red-600`,children:[s.jsx("div",{className:"flex-1 w-0 p-4",children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"flex-shrink-0 pt-0.5",children:s.jsx(zh,{className:"h-10 w-10 text-red-600"})}),s.jsxs("div",{className:"ml-3 flex-1",children:[s.jsx("p",{className:"text-sm font-bold text-gray-900 uppercase tracking-tight",children:"New Article Published (< 5 mins)"}),s.jsx("p",{className:"mt-1 text-sm text-gray-500 line-clamp-2 font-serif italic",children:H.title})]})]})}),s.jsx("div",{className:"flex border-l border-gray-200",children:s.jsx("button",{onClick:()=>{he({id:_.id,...H}),me.dismiss(re.id)},className:"w-full border border-transparent rounded-none rounded-r-lg p-4 flex items-center justify-center text-xs font-black text-red-600 hover:text-red-700 uppercase tracking-widest",children:"View"})})]}),{duration:7e3,position:"top-right"})})},qe=>{Gs(qe,Ps.LIST,"articles/new")}),bn=new Date(Date.now()-600*1e3),Mt=new Set,An=Qt(it(pe,"adverts"),Nr("createdAt",">",jr.fromDate(bn)),pi("createdAt","desc"));return vn(An).then(qe=>{qe.docs.forEach(_=>{const U=_.id;if(Mt.has(U))return;Mt.add(U);const H=_.data();me.custom(re=>s.jsxs("div",{className:`${re.visible?"animate-enter":"animate-leave"} max-w-md w-full bg-white shadow-2xl pointer-events-auto flex ring-1 ring-black ring-opacity-5 border-l-4 border-blue-600`,children:[s.jsx("div",{className:"flex-1 w-0 p-4",children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"flex-shrink-0 pt-0.5",children:s.jsx(No,{className:"h-10 w-10 text-blue-600"})}),s.jsxs("div",{className:"ml-3 flex-1",children:[s.jsx("p",{className:"text-sm font-bold text-gray-900 uppercase tracking-tight",children:"New Sponsored Update"}),s.jsx("p",{className:"mt-1 text-sm text-gray-500 line-clamp-2",children:H.title||"Check out this new update!"})]})]})}),s.jsx("div",{className:"flex border-l border-gray-200",children:s.jsx("button",{onClick:()=>{H.link&&window.open(H.link,"_blank"),me.dismiss(re.id)},className:"w-full border border-transparent rounded-none rounded-r-lg p-4 flex items-center justify-center text-xs font-black text-blue-600 hover:text-blue-700 uppercase tracking-widest",children:"Open"})})]}),{duration:6e3,position:"top-right"})})}).catch(qe=>{Gs(qe,Ps.LIST,"adverts/new")}),()=>{At(),clearInterval(Te),clearTimeout(we)}},[]),se.useEffect(()=>{const ge=window.location.pathname;let we=null,Te=null;if(ge.startsWith("/p/share/")){const ut=ge.split("/p/share/")[1];we=ut?ut.split("/")[0]:null}else if(ge.includes("/articles=")||ge.startsWith("/articles/")){const lt=ge.replace(/^\/articles=?/,"").split("/").filter(Boolean);lt.length>=2?(Te=lt[0],we=lt[1]):lt[0]&&(Te=lt[0])}else if(ge.startsWith("/poll/")&&ge.includes("/candidate/")){const lt=ge.split("/candidate/")[1];lt&&(Te=lt)}else we=new URLSearchParams(window.location.search).get("id");const $e=new URLSearchParams(window.location.search);if(Te||(Te=$e.get("articles")||$e.get("article")),we){let ut=!1;try{const lt=localStorage.getItem("campus_eye_articles_cache");if(lt){const bn=JSON.parse(lt).find(Mt=>Mt.id===we);bn&&(he(bn),le(!1),ut=!0)}}catch(lt){console.warn("Error checking fast article cache:",lt)}cs(ot(pe,"articles",we)).then(lt=>{if(lt.exists()){const At={id:lt.id,...lt.data()};he(At)}le(!1)}).catch(lt=>{console.warn("Direct priority fetch by ID failed:",lt),le(!1)})}else if(Te){const ut=o.find(lt=>{const At=lt.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),bn=Te.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return At===bn||lt.title.toLowerCase()===Te.toLowerCase()});if(ut)he(ut),le(!1);else{const lt=Qt(it(pe,"articles"),pi("publishDate","desc"),Pi(25));vn(lt).then(At=>{const Mt=At.docs.map(An=>({id:An.id,...An.data()})).find(An=>{const Rn=An.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),qe=Te.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return Rn===qe||An.title.toLowerCase()===Te.toLowerCase()||Rn.replace(/-/g,".")===qe});Mt&&he(Mt),le(!1)}).catch(At=>{console.warn("Direct priority fetch by slug failed:",At),le(!1)})}}else le(!1)},[]),se.useEffect(()=>{const ge=()=>{const we=new URLSearchParams(window.location.search),Te=we.get("articles")||we.get("article"),$e=we.get("id");if(!Te&&!$e)he(null);else{const ut=o.find(lt=>lt.id===$e||Te&<.title.toLowerCase().replace(/[^a-z0-9]/g,"-")===Te.toLowerCase());ut?he(ut):$e&&cs(ot(pe,"articles",$e)).then(lt=>{lt.exists()&&he({id:lt.id,...lt.data()})}).catch(console.error)}};return window.addEventListener("popstate",ge),()=>window.removeEventListener("popstate",ge)},[o]);const ma=ge=>{wn(ge),ge.trim()&&(je("home"),window.scrollTo({top:0,behavior:"auto"}))},Vr=ge=>{je("admin"),wr(!0),gt(ge||"dashboard"),window.scrollTo({top:0,behavior:"auto"})},Ys=async ge=>{var Te;const we=(Te=ge.target.files)==null?void 0:Te[0];if(!(!we||!Ne.currentUser))try{yi(!0);const $e=new FileReader;$e.onloadend=async()=>{if(Ne.currentUser){const ut=$e.result;await Hr(ot(pe,"users",Ne.currentUser.uid),{photoURL:ut,updatedAt:Bn()},{merge:!0}),me.success("Profile picture updated!")}},$e.readAsDataURL(we)}catch($e){console.error("Error updating profile:",$e),me.error("Failed to update profile pic")}finally{yi(!1)}},bi=async()=>{if(!(!Pa.trim()||!Ne.currentUser))try{yi(!0),await JF(Ne.currentUser,{displayName:Pa.trim()}),await Hr(ot(pe,"users",Ne.currentUser.uid),{displayName:Pa.trim(),updatedAt:Bn()},{merge:!0}),Ms(!1),me.success("Username successfully authenticated and saved!")}catch(ge){console.error("Error updating name:",ge),me.error("Failed to update display name")}finally{yi(!1)}},co=async ge=>{var we,Te;if(ge.preventDefault(),!!Ls.message.trim())try{yi(!0),await ur(it(pe,"feedback"),{...Ls,userId:((we=Ne.currentUser)==null?void 0:we.uid)||null,createdAt:Bn()}),me.success("Feedback transmitted. Thank you!"),Yn({name:"",email:((Te=Ne.currentUser)==null?void 0:Te.email)||"",subject:"General Feedback",message:""}),je("home")}catch($e){console.error("Error submitting feedback:",$e),me.error("Failed to send feedback.")}finally{yi(!1)}},El=()=>{var ut,lt,At,bn,Mt,An,Rn;if(!w||k)return s.jsxs("div",{className:"relative w-full min-h-[75vh] overflow-hidden",children:[s.jsx("div",{className:"filter blur-[4px] opacity-40 select-none pointer-events-none",children:s.jsx(E9e,{})}),s.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center p-4",children:s.jsx(qV,{})})]});const ge=Array.from(new Set(o.map(qe=>qe.category).filter(Boolean))),Te=ge.map(qe=>Mh(qe)).includes(Mh(ze)),$e=Zt.trim()?h:Te?o.filter(qe=>Mh(qe.category)===Mh(ze)):h;if(ze==="home"||ze==="for-you"||Te){let qe=[...$e];if(Bt!==null&&(qe=qe.filter(Ce=>{const _t=Ce.publishDate;if(!_t)return!1;const qn=_t.toDate?_t.toDate():_t.seconds?new Date(_t.seconds*1e3):new Date(_t),Nn=new Date;Nn.setHours(0,0,0,0);const Jn=new Date(qn);Jn.setHours(0,0,0,0);const Br=Nn.getTime()-Jn.getTime();return Math.floor(Br/(1e3*60*60*24))+1===Bt})),ze==="for-you")try{const Ce=localStorage.getItem("campus_eye_personalization_v1");let _t={};if(Ce){const Jn=JSON.parse(Ce);Jn&&Jn.categories&&(_t={...Jn.categories})}const qn=(ut=Ne.currentUser)==null?void 0:ut.uid,Nn=new Set;if(qn)for(let Jn=0;Jn=3){const Qr=ki.slice(1,ki.length-1).join("_");Nn.add(Qr);const Kr=o.find(Xs=>Xs.id===Qr);if(Kr&&Kr.category){const Xs=Kr.category;_t[Xs]=(_t[Xs]||0)+25}}}}if(tt==="saved")qe=qe.filter(Jn=>Nn.has(Jn.id));else{const Jn=qe.map(Br=>{let ki=0;Nn.has(Br.id)&&(ki+=1e6);const Kr=Br.category||"General";_t[Kr]&&(ki+=_t[Kr]*2.5);const Xs=Br.publishDate&&typeof Br.publishDate.toMillis=="function"?Br.publishDate.toMillis():0;return ki+=Xs/1e11,{article:Br,score:ki}});Jn.sort((Br,ki)=>ki.score-Br.score),qe=Jn.map(Br=>Br.article)}}catch(Ce){console.warn("Failed to sort personalized articles:",Ce)}else qe.sort((Ce,_t)=>{const qn=Ce.publishDate&&typeof Ce.publishDate.toMillis=="function"?Ce.publishDate.toMillis():0;return(_t.publishDate&&typeof _t.publishDate.toMillis=="function"?_t.publishDate.toMillis():0)-qn});const _=Math.max(1,Math.ceil(qe.length/F)),U=Math.min(T,_),H=qe.slice((U-1)*F,U*F),re=H.slice(0,Math.min(H.length,8)),Oe=H.length>8?H.slice(8,Math.min(H.length,10)):[],We=H.length>10?H.slice(10):[];return s.jsx("div",{className:"w-full max-w-[1680px] xl:max-w-[1780px] 2xl:max-w-[1880px] mx-auto pt-1 sm:pt-4 pb-20 px-1 sm:px-4 lg:px-6 xl:px-8",children:s.jsxs("div",{className:"grid grid-cols-12 gap-4 lg:gap-5 xl:gap-6 2xl:gap-8",children:[s.jsxs("aside",{className:"hidden lg:block lg:col-span-3 xl:col-span-3 2xl:col-span-3 space-y-4 pr-1 text-left select-none sticky top-24 self-start max-h-[calc(100vh-8rem)] overflow-y-auto no-scrollbar scroll-smooth",children:[s.jsxs("div",{className:"bg-white border border-gray-150/90 rounded-2xl p-4 shadow-xs space-y-3.5 text-left relative resize-y overflow-auto min-h-[320px] max-h-[75vh] [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:bg-gray-200 [&::-webkit-scrollbar-thumb]:rounded-full",children:[s.jsxs("div",{className:"flex items-center justify-between pb-2.5 border-b border-gray-100 sticky top-0 bg-white/95 backdrop-blur-sm z-10",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(o8,{size:16,className:"text-red-650 shrink-0"}),s.jsx("span",{className:"text-[10px] font-mono font-black uppercase text-red-650 tracking-[0.15em]",children:"Market"})]}),s.jsx("button",{onClick:()=>{je("posts"),window.scrollTo({top:0,behavior:"auto"})},className:"text-[8px] font-black uppercase tracking-wider px-2 py-1 bg-red-50 text-red-650 hover:bg-red-650 hover:text-white rounded-lg transition-all cursor-pointer",children:"Open Market"})]}),Tr.length===0?s.jsxs("div",{className:"py-6 text-center text-gray-400 space-y-1",children:[s.jsx(o8,{size:20,className:"mx-auto text-gray-300 mb-1"}),s.jsx("p",{className:"text-[9px] font-bold uppercase tracking-wider",children:"No Market Listings"}),s.jsx("p",{className:"text-[8px] text-gray-400",children:"Be the first to list an item in the Market!"})]}):s.jsx("div",{className:"space-y-3 divide-y divide-gray-100",children:Tr.map((Ce,_t)=>{var qn;return s.jsxs("div",{onClick:()=>{je("posts"),window.scrollTo({top:0,behavior:"auto"})},className:"pt-3 first:pt-0 group cursor-pointer hover:bg-gray-50/70 p-2 rounded-xl transition-all",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[s.jsxs("div",{onClick:Nn=>{Nn.stopPropagation(),Ce.authorId&&Pt(Ce.authorId)},className:"flex items-center gap-2 min-w-0 hover:underline",children:[Ce.authorPhotoURL?s.jsx(Vi,{src:Ce.authorPhotoURL,alt:"",className:"w-6 h-6 rounded-full object-cover border border-gray-200 shrink-0 overflow-hidden"}):s.jsx("div",{className:"w-6 h-6 rounded-full bg-red-650 text-white flex items-center justify-center text-[9px] font-black uppercase shrink-0",children:((qn=Ce.authorName)==null?void 0:qn.charAt(0))||"M"}),s.jsxs("span",{className:"text-[9.5px] font-extrabold text-gray-950 truncate max-w-[110px] flex items-center gap-1",children:[Ce.authorName,s.jsx(Ll,{size:12,className:"shrink-0"})]})]}),s.jsx("span",{className:"text-[7.5px] font-mono text-gray-400 shrink-0",children:Ce.createdAt instanceof jr?gw(Ce.createdAt):"Recent"})]}),s.jsx("p",{className:"text-[9.5px] font-medium text-gray-750 leading-relaxed line-clamp-3 select-text font-sans",children:Ce.content}),Ce.imageUrl&&s.jsx("div",{className:"mt-2 h-28 w-full rounded-lg overflow-hidden border border-gray-150 bg-gray-950 relative",children:s.jsx(Vi,{src:Ce.imageUrl,alt:"",className:"w-full h-full object-cover group-hover:scale-102 transition-transform duration-300"})}),s.jsxs("div",{className:"mt-2 flex items-center gap-3 text-[8px] font-mono font-bold text-gray-400",children:[s.jsxs("span",{className:"flex items-center gap-1 hover:text-red-500",children:[s.jsx(ku,{size:10,className:Ce.likeCount?"fill-red-500 text-red-500":""}),Ce.likeCount||0]}),s.jsxs("span",{className:"flex items-center gap-1 hover:text-blue-500",children:[s.jsx(Yi,{size:10}),Ce.commentCount||0]})]})]},`sidebar-${Ce.id}-${_t}`)})})]}),rn&&s.jsxs("div",{className:"bg-white border border-gray-150 rounded-2xl p-3 shadow-xs space-y-2 text-left",children:[s.jsx("div",{className:"flex items-center justify-between border-b border-gray-100 pb-1.5 mb-1.5",children:s.jsxs("span",{className:"text-[9px] font-black tracking-[0.12em] text-red-655 uppercase flex items-center gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-650 shrink-0"}),s.jsx("span",{children:"Promotional Partner"})]})}),s.jsx(Sw,{advert:rn})]})]}),s.jsxs("main",{className:"col-span-12 lg:col-span-6 space-y-5 px-0 min-h-screen border-r border-l border-gray-100/60 bg-white",children:[ze!=="home"&&s.jsx("div",{className:"border-b border-gray-100 pb-3 px-4 flex items-center justify-between sticky top-11 bg-white/95 backdrop-blur-md z-30",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-650 shrink-0"}),s.jsx("h3",{className:"text-[10px] font-extrabold tracking-wider text-red-650 uppercase font-mono px-2 py-1 rounded-md bg-red-50 border border-red-150/55 shadow-xs flex items-center gap-1.5 shrink-0 select-none",children:Zt.trim()?s.jsxs("div",{className:"flex items-center gap-1 leading-none uppercase text-[9px]",children:[s.jsxs("span",{children:["Search:"," ",s.jsxs("span",{className:"text-red-750 italic",children:['"',Zt,'"']})]}),s.jsx("button",{onClick:()=>{wn(""),window.dispatchEvent(new CustomEvent("clearSearchQuery"))},className:"p-0.5 text-red-400 hover:text-red-650 hover:bg-white rounded-full transition-colors cursor-pointer ml-1 inline-flex items-center justify-center shrink-0",title:"Clear Search",children:s.jsx(er,{size:10,strokeWidth:2.5})})]}):ze==="for-you"?s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 w-full pr-2",children:[s.jsx("span",{children:"Curated For You"}),s.jsxs("div",{className:"flex items-center gap-1 bg-gray-100/80 p-0.5 rounded-xl text-[9px] font-extrabold uppercase tracking-wider",children:[s.jsx("button",{type:"button",onClick:()=>fn("all"),className:Ge("px-2.5 py-1 rounded-lg transition-all cursor-pointer",tt==="all"?"bg-white text-gray-950 shadow-xs":"text-gray-500 hover:text-gray-800"),children:"All Feed"}),s.jsxs("button",{type:"button",onClick:()=>fn("saved"),className:Ge("px-2.5 py-1 rounded-lg transition-all cursor-pointer flex items-center gap-1",tt==="saved"?"bg-red-650 text-white shadow-xs":"text-gray-500 hover:text-gray-800"),children:[s.jsx(jne,{size:10,className:"fill-current"}),s.jsx("span",{children:"Saved Stories"})]})]})]}):Te?`${ge.find(Ce=>{let _t=Ce.toLowerCase().replace(/\s+/g,"-");return(_t==="campus-news"||_t==="news")&&(_t="news"),(_t==="sports"||_t==="sport")&&(_t="sport"),_t===ze.toLowerCase()})||ze} Feed`:"Campus News"})]})}),s.jsx(ar,{children:li&&o.length>0&&ze==="home"&&s.jsx(Kt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3},className:"overflow-hidden",children:s.jsx(xye,{articles:o,onClick:he})})}),zr&&Wr.length>0&&ze==="home"&&s.jsxs("div",{className:"px-4 py-1 space-y-2 relative group",children:[Wr.slice(0,Ya).map(Ce=>{const _t=Us==="small",qn=Us==="large",Nn=_t?"p-1.5 py-1 px-3 rounded-lg gap-2 text-left animate-fade-in border-red-150":qn?"p-4.5 px-6 rounded-2xl gap-4.5 text-left animate-fade-in":"p-3 px-4 rounded-xl gap-3.5 text-left animate-fade-in",Jn=_t?"w-7 h-7 rounded-md":qn?"w-14 h-14 rounded-xl shadow-xs":"w-11 h-11 rounded-lg",Br=_t?10:qn?15:13,ki=_t?"text-[9px]/[10px] font-black tracking-custom":qn?"text-[12.5px]/[15px] font-black tracking-custom":"text-[11px]/[13px] font-black tracking-custom",Qr=_t?"text-[8px]/[9.5px] text-gray-500 mt-0.5 line-clamp-1":qn?"text-[10.5px]/[14px] text-gray-500 mt-1 line-clamp-3 leading-relaxed":"text-[9.5px]/[12px] text-gray-500 mt-0.5 line-clamp-2 leading-relaxed",Kr=_t?"text-[6.5px]/none px-2 py-0.5 mt-0.5 font-black rounded gap-0.5":qn?"text-[9.5px]/none px-4 py-2 mt-2 font-black rounded-xl gap-1.5":"text-[8.5px]/none px-3 py-1.5 mt-1.5 font-black rounded-lg gap-1",Xs=_t?5:qn?9:7,Da=_t?"pr-24":qn?"pr-36":"pr-32";return s.jsxs("div",{onClick:()=>{Ce.isCustomPagePromo?J(Ce.originalPage):Ce.isLiveStream&&Ce.liveEmbedUrl&&(nn(Ce.liveEmbedUrl),dr(Ce.title))},className:`bg-red-50/70 border border-red-150/80 flex flex-row items-center relative overflow-hidden hover:border-red-650 transition-all duration-300 ${Ce.isLiveStream&&Ce.liveEmbedUrl||Ce.isCustomPagePromo?"cursor-pointer hover:bg-red-100/30":""} ${Nn}`,children:[s.jsxs("div",{className:"absolute top-2 right-2 flex items-center gap-1.5 z-10 select-none",children:[s.jsxs("div",{className:"flex items-center bg-white border border-gray-150 rounded-md p-0.5 shadow-3xs text-[7px] font-black uppercase text-gray-500 overflow-hidden shrink-0",children:[s.jsx("button",{onClick:Ci=>{Ci.stopPropagation(),bs("small")},className:`px-1 py-0.2 rounded-xs transition-all cursor-pointer ${_t?"bg-red-600 text-white font-black animate-scale-in":"hover:bg-gray-100 text-gray-400"}`,title:"Set compact size",children:"-"}),s.jsx("button",{onClick:Ci=>{Ci.stopPropagation(),bs("medium")},className:`px-1 py-0.2 rounded-xs transition-all cursor-pointer ${Us==="medium"?"bg-red-600 text-white font-black animate-scale-in":"hover:bg-gray-100 text-gray-400"}`,title:"Set regular size",children:"A"}),s.jsx("button",{onClick:Ci=>{Ci.stopPropagation(),bs("large")},className:`px-1 py-0.2 rounded-xs transition-all cursor-pointer ${qn?"bg-red-600 text-white font-black animate-scale-in":"hover:bg-gray-100 text-gray-400"}`,title:"Set large size",children:"+"})]}),s.jsxs("div",{className:"px-1.5 py-0.5 bg-red-600 text-white rounded-full text-[6.5px] font-black uppercase tracking-wider flex items-center gap-0.5 shadow-2xs shrink-0",children:[s.jsx(g0,{size:6})," Pinned"]}),gi&&s.jsx("button",{onClick:async Ci=>{if(Ci.stopPropagation(),!gi){me.error("Access Denied: Only admins can delete announcements.");return}if(window.confirm("Are you sure you want to delete this pinned announcement?"))try{me.loading("Deleting pinned notice...",{id:`delete-pinned-${Ce.id}`}),await ni(ot(pe,"pinned_announcements",Ce.id)),me.success("Notice deleted!",{id:`delete-pinned-${Ce.id}`})}catch(js){me.error(js.message||String(js),{id:`delete-pinned-${Ce.id}`})}},className:"p-1 bg-white hover:bg-red-50 text-red-650 border border-gray-150 rounded-md transition-all cursor-pointer shadow-3xs shrink-0 flex items-center justify-center h-4.5 w-4.5",title:"Delete announcement permanently (Master Admin)",children:s.jsx(As,{size:9})})]}),Ce.isLiveStream&&Ce.liveEmbedUrl?s.jsxs("div",{onClick:Ci=>{Ci.stopPropagation(),nn(Ce.liveEmbedUrl),dr(Ce.title)},className:`relative border border-red-200/40 shrink-0 overflow-hidden bg-gray-905 select-none cursor-pointer hover:border-red-650 transition-colors ${Jn}`,title:"Click to watch live stream",children:[s.jsx("img",{src:(()=>{var Po,ga,Ro;const Ci=Ce.liveEmbedUrl;if(!Ci)return Ce.imageUrl||i(Ce.title,"Announcement");let js="";return Ci.includes("embed/")?js=((Po=Ci.split("embed/")[1])==null?void 0:Po.split(/[?#]/)[0])||"":Ci.includes("v=")?js=((ga=Ci.split("v=")[1])==null?void 0:ga.split(/[?&#]/)[0])||"":Ci.includes("youtu.be/")&&(js=((Ro=Ci.split("youtu.be/")[1])==null?void 0:Ro.split(/[?#]/)[0])||""),js?`https://img.youtube.com/vi/${js}/hqdefault.jpg`:Ce.imageUrl||i(Ce.title,"Announcement")})(),className:"absolute inset-0 w-full h-full object-cover border-0",alt:"Live stream thumbnail",referrerPolicy:"no-referrer"}),s.jsx("div",{className:"absolute inset-0 bg-black/40 hover:bg-black/20 transition-all flex items-center justify-center",children:s.jsx("span",{className:"bg-red-650 text-white font-black text-[8px] uppercase tracking-[0.16em] px-2 py-1 rounded shadow-md border border-red-500",children:"🔴 LIVE SOURCE"})})]}):Ce.imageUrl?s.jsx("img",{src:Ce.imageUrl,alt:"",className:`object-cover border border-red-100/40 shrink-0 ${Jn}`,referrerPolicy:"no-referrer"}):s.jsx("div",{className:`bg-red-150 text-red-600 flex items-center justify-center font-black shrink-0 ${Jn}`,children:s.jsx(Su,{size:Br})}),s.jsxs("div",{className:`flex-1 text-left min-w-0 ${Da}`,children:[s.jsx("h4",{className:`text-gray-950 uppercase tracking-tight leading-snug truncate ${ki}`,children:Ce.title}),Ce.description&&s.jsx("p",{className:`${Qr}`,children:Ce.description}),Ce.isLiveStream&&Ce.liveEmbedUrl?s.jsx("button",{onClick:Ci=>{Ci.stopPropagation(),Ce.isCustomPagePromo?J(Ce.originalPage):(nn(Ce.liveEmbedUrl),dr(Ce.title))},className:`font-black bg-red-650 text-white hover:bg-red-700 inline-flex items-center uppercase tracking-wider cursor-pointer border border-red-700 shadow-sm active:scale-95 transition-all ${Kr}`,children:s.jsx("span",{children:"🔴 Watch Stream Live"})}):Ce.link?s.jsxs("button",{onClick:()=>{Ce.link&&window.open(Ce.link,"_blank","noopener,noreferrer")},className:`font-black bg-neutral-950 text-white hover:bg-neutral-800 inline-flex items-center uppercase tracking-wider cursor-pointer border border-neutral-800 shadow-sm active:scale-95 transition-all ${Kr}`,children:[s.jsx("span",{children:Ce.ctaText||Ce.buttonText||"Discover More"}),s.jsx(Va,{size:Xs,strokeWidth:3})]}):null]})]},Ce.id)}),Wr.length>Ya&&s.jsxs("button",{type:"button",onClick:()=>pa(Wr.length),className:"w-full py-1.5 bg-red-50/50 hover:bg-red-100 border border-dashed border-red-200 hover:border-red-400 rounded-lg flex items-center justify-center gap-1.5 text-[8.5px]/none font-black uppercase text-red-655 transition-all duration-150 cursor-pointer shadow-3xs",children:[s.jsx(Md,{size:11,className:"stroke-[2.5]"}),s.jsxs("span",{children:["Show Other Pinned Announcements (",Wr.length-Ya," more)"]})]}),Ya>1&&s.jsxs("button",{type:"button",onClick:()=>pa(1),className:"w-full py-1.5 text-gray-400 hover:text-red-650 text-[8px]/none font-bold uppercase tracking-wider flex items-center justify-center gap-1 transition-colors duration-150 cursor-pointer",children:[s.jsx(uf,{size:10}),s.jsx("span",{children:"Collapse Pinned List"})]})]}),ze==="for-you"&&yt?s.jsxs("div",{className:"py-20 flex flex-col items-center justify-center text-center space-y-4",children:[s.jsx(qV,{}),s.jsx("p",{className:"text-[10px] font-sans font-black uppercase tracking-custom text-gray-500 mt-2",children:"Crafting your custom campus feed..."})]}):ze==="for-you"&&Tn?s.jsxs("div",{className:"max-w-md mx-auto py-8 px-4 text-center",children:[s.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400 mb-6 bg-red-50 py-1.5 px-3 rounded-full inline-block",children:"📢 Interest Personalization"}),s.jsxs("div",{className:"bg-white border border-gray-150 rounded-3xl p-6.5 shadow-xs space-y-6",children:[s.jsxs("div",{className:"space-y-1.5 text-center",children:[s.jsx("div",{className:"w-9 h-9 bg-black text-white rounded-2xl flex items-center justify-center font-black text-sm mx-auto shadow-xs tracking-tighter",children:"★"}),s.jsx("h3",{className:"font-serif font-black text-lg tracking-tight text-neutral-900 uppercase",children:"Tune Your Dispatch Stream"}),s.jsx("p",{className:"text-[10px] text-neutral-500 font-semibold tracking-normal leading-relaxed max-w-xs mx-auto",children:"Select up to 3 core campus categories. We'll curate your news feed and learn your preferences live in this space."})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:[{id:"news",label:"📰 News",category:"News"},{id:"sports",label:"⚽ Sports",category:"Sports"},{id:"music",label:"🎵 Music",category:"Music"},{id:"entertainment",label:"🎭 Entertainment",category:"Entertainment"},{id:"innovation",label:"💡 Innovation",category:"Innovation"},{id:"culture",label:"🏛️ Culture",category:"Culture"},{id:"business",label:"💼 Business",category:"Business"}].map(Ce=>{const _t=Ae.includes(Ce.category);return s.jsxs("button",{onClick:()=>{if(_t)tn(qn=>qn.filter(Nn=>Nn!==Ce.category));else{if(Ae.length>=3){me.error("Please pick up to just 3 interests!",{id:"interest-limit"});return}tn(qn=>[...qn,Ce.category])}},className:`p-3 rounded-2xl border text-left font-sans text-xs font-semibold transition-all duration-200 cursor-pointer flex flex-col justify-between h-[4.5rem] select-none ${_t?"border-black bg-black text-white shadow-xs scale-[1.02]":"border-gray-200 bg-white text-gray-700 hover:border-gray-300 hover:bg-gray-50/50"}`,children:[s.jsx("span",{className:"text-base leading-none",children:Ce.label.split(" ")[0]}),s.jsx("span",{className:"font-sans uppercase text-[8.5px] font-black tracking-wider leading-none",children:Ce.label.split(" ").slice(1).join(" ")})]},Ce.id)})}),s.jsxs("div",{className:"pt-2 text-center",children:[s.jsxs("span",{className:"text-[8.5px] font-sans font-black text-gray-400 uppercase tracking-widest block mb-3.5",children:[Ae.length," of 3 Selected"]}),s.jsx("button",{onClick:()=>{if(Ae.length===0){me.error("Please select at least 1 interest to customize your feed!");return}try{const Ce=localStorage.getItem("campus_eye_personalization_v1"),_t=Ce?JSON.parse(Ce):{categories:{}};_t.interests=[...Ae],_t.categories||(_t.categories={}),Ae.forEach(qn=>{_t.categories[qn]=(_t.categories[qn]||0)+150}),localStorage.setItem("campus_eye_personalization_v1",JSON.stringify(_t)),localStorage.removeItem("just_signed_up"),cn(!0),setTimeout(()=>{cn(!1),Nt(!1),me.success("Newsroom personalized live! Welcome.")},1800)}catch(Ce){console.warn(Ce),Nt(!1)}},disabled:Ae.length===0,className:`w-full py-4.5 rounded-xl font-sans font-black uppercase text-[11px] tracking-[0.2em] transition-all duration-350 border select-none ${Ae.length===0?"bg-gray-100 text-gray-400 border-gray-150 cursor-not-allowed":"bg-black hover:bg-neutral-900 text-white border-black cursor-pointer active:scale-[0.98]"}`,children:"Save & Continue"})]})]})]}):re.length>0?s.jsx("div",{className:"divide-y divide-gray-100",children:re.map((Ce,_t)=>{const qn=_t===Math.max(2,re.length-3);return s.jsxs(se.Fragment,{children:[s.jsx("div",{ref:qn?$:void 0,children:s.jsx(pS,{article:Ce,onClick:he,variant:"social",priority:_t<2,onAuthorClick:Pt})}),_t===2&&rn&&s.jsx("div",{className:"p-4 bg-gray-50/50 border-b border-gray-100",children:s.jsx(Sw,{advert:rn})}),_t===1&&s.jsxs("div",{className:"p-5 bg-white border border-gray-150/60 rounded-2xl text-left my-4 shadow-sm mx-4",children:[s.jsx("span",{className:"text-[9px] font-black tracking-[0.2em] text-accent uppercase block mb-3 text-left",children:"🎟️ LIVE EVENT DISPATCH & TICKET PASSES"}),s.jsx(ZC,{})]}),_t===5&&Me&&s.jsx("div",{className:"p-4 bg-gray-50/50 border-b border-gray-100",children:s.jsx(Sw,{advert:Me})})]},`feed-${Ce.id}-${_t}`)})}):s.jsxs("div",{className:"space-y-5 px-4 py-2",children:[s.jsxs("div",{className:"p-5 bg-white border border-gray-150/60 rounded-2xl text-left shadow-sm",children:[s.jsx("span",{className:"text-[9px] font-black tracking-[0.2em] text-accent uppercase block mb-3 text-left",children:"🎟️ LIVE EVENT DISPATCH & TICKET PASSES"}),s.jsx(ZC,{})]}),s.jsxs("div",{className:"space-y-4 pt-2",children:[s.jsx("div",{className:"flex items-center gap-2 text-[10px] font-black text-gray-400 uppercase tracking-widest px-1 pb-2 border-b border-gray-50",children:s.jsx("span",{children:"📰 Articles Feed & Dispatches"})}),s.jsx(Ep,{variant:"social"}),s.jsx(Ep,{variant:"social"}),s.jsx(Ep,{variant:"social"})]}),s.jsxs("div",{className:"p-8 text-center bg-gray-50 border border-gray-100/60 rounded-2xl select-none",children:[s.jsx(zh,{size:24,className:"text-gray-300 mx-auto mb-2"}),s.jsx("p",{className:"text-[10px] font-black uppercase text-gray-400 tracking-wider",children:"Silent Dispatch Feed"}),s.jsx("p",{className:"text-[9px] text-gray-400 mt-1 max-w-xs mx-auto",children:"No general journalism postings currently active. Check the student lounge, announcements, debates or purchase passes above!"})]})]}),Oe.length>0&&s.jsxs("div",{className:"p-4 space-y-4 bg-gray-50/30 border-t border-b border-gray-100",children:[s.jsx("span",{className:"text-[10px] font-black tracking-widest text-red-650 uppercase block text-left",children:"🔥 Spotlight Feature Postings"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Oe.map((Ce,_t)=>s.jsx(pS,{article:Ce,onClick:he,variant:"big",onAuthorClick:Pt},`spotlight-${Ce.id}-${_t}`))})]}),We.length>0&&s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("span",{className:"text-[10px] font-black tracking-widest text-gray-400 uppercase block text-left",children:"📰 Support Micro-Dispatches"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:We.map((Ce,_t)=>s.jsx(pS,{article:Ce,onClick:he,variant:"magazine",onAuthorClick:Pt},`small-${Ce.id}-${_t}`))})]}),qe.length>0&&s.jsx("div",{className:"my-6",children:s.jsx(jee,{currentPage:T,totalPages:Math.ceil(qe.length/F),totalItems:qe.length,itemsPerPage:F,onPageChange:Ce=>{D(Ce),Ce*F>q-10&&Z(_t=>Math.max(_t,Ce*F+50)),window.scrollTo({top:0,behavior:"smooth"})},onItemsPerPageChange:Ce=>{L(Ce),D(1),Ce>q&&Z(Ce+50)},itemLabel:"articles"})})]}),s.jsxs("aside",{className:"hidden lg:block lg:col-span-3 xl:col-span-3 2xl:col-span-3 space-y-5 pl-1 text-left sticky top-24 self-start max-h-[calc(100vh-8rem)] overflow-y-auto no-scrollbar scroll-smooth",children:[s.jsxs("div",{className:"bg-white border border-gray-150 rounded-2xl p-4 shadow-xs space-y-3 text-left",children:[s.jsx("div",{className:"flex items-center justify-end pb-2 border-b border-gray-100 select-none",children:s.jsxs("button",{onClick:()=>{if(o.length>0){const _t=[...o.length>3?o.slice(3):o].sort(()=>Math.random()-.5);Y(_t.slice(0,8)),me.success("Shuffled archives!",{id:"shuffle-articles"})}},className:"text-[8px] font-black uppercase tracking-wider text-gray-500 hover:text-red-650 flex items-center gap-1.5 transition-colors cursor-pointer px-2.5 py-1 bg-gray-50 hover:bg-red-50 rounded-lg border border-gray-100",title:"Shuffle older articles",children:[s.jsx(cF,{size:11}),s.jsx("span",{children:"Shuffle"})]})}),Q.length===0?s.jsx("p",{className:"text-[8.5px] text-gray-400 py-3 text-center",children:"Loading vintage archives..."}):s.jsx("div",{className:"divide-y divide-gray-100 space-y-2.5",children:Q.map((Ce,_t)=>s.jsxs("div",{onClick:()=>{he(Ce),window.scrollTo({top:0,behavior:"auto"})},className:"pt-2.5 group cursor-pointer flex gap-3 items-start first:pt-0 hover:bg-gray-50/60 p-1.5 rounded-xl transition-all",children:[s.jsx("div",{className:"w-11 h-11 rounded-lg overflow-hidden relative shrink-0 bg-gray-100 border border-gray-150/80",children:s.jsx("img",{src:Ce.featuredImageUrl||i(Ce.title,Ce.category),alt:"",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}),s.jsxs("div",{className:"flex-1 min-w-0 text-left space-y-0.5",children:[s.jsx("span",{className:"text-[7.5px] font-mono font-black text-red-650 uppercase tracking-widest block",children:Ce.category||"Archive"}),s.jsx("h5",{className:"font-extrabold text-[10px] text-gray-950 uppercase tracking-tight leading-snug group-hover:text-red-650 transition-colors line-clamp-2 font-sans",children:Ce.title})]})]},`archive-${Ce.id}-${_t}`))})]}),s.jsxs("div",{className:"bg-white border border-gray-100 rounded-2xl p-4 shadow-xs space-y-3",children:[s.jsx("span",{className:"text-[10px] font-black tracking-[0.15em] text-gray-900 uppercase block",children:"⚡ QUICK PORTAL"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-left select-none",children:[s.jsxs("button",{onClick:()=>{je("posts"),window.scrollTo({top:0,behavior:"auto"})},className:"p-3 bg-gray-50 hover:bg-red-50 text-gray-900 hover:text-red-650 font-black uppercase text-[9px] tracking-wider rounded-xl transition-all border border-gray-100 text-center cursor-pointer flex flex-col items-center gap-1.5",children:[s.jsx(Yi,{size:14,className:"stroke-[2.5]"}),s.jsx("span",{children:"Lounge Feed"})]}),s.jsxs("button",{onClick:()=>{Fe(!0)},className:"p-3 bg-gray-50 hover:bg-amber-50 text-gray-900 hover:text-amber-600 font-black uppercase text-[9px] tracking-wider rounded-xl transition-all border border-gray-100 text-center cursor-pointer flex flex-col items-center gap-1.5",children:[s.jsx(sc,{size:14,className:"stroke-[2.5]"}),s.jsx("span",{children:"Podcasts"})]}),s.jsxs("button",{onClick:()=>{Ft(!0)},className:"p-3 bg-gray-50 hover:bg-green-50 text-gray-900 hover:text-green-655 font-black uppercase text-[9px] tracking-wider rounded-xl transition-all border border-gray-100 text-center cursor-pointer flex flex-col items-center gap-1.5",children:[s.jsx(No,{size:14,className:"stroke-[2.5]"}),s.jsx("span",{children:"Buy Tickets"})]}),s.jsxs("button",{onClick:()=>{je("account"),window.scrollTo({top:0,behavior:"auto"})},className:"p-3 bg-gray-50 hover:bg-purple-50 text-gray-900 hover:text-purple-650 font-black uppercase text-[9px] tracking-wider rounded-xl transition-all border border-gray-100 text-center cursor-pointer flex flex-col items-center gap-1.5",children:[s.jsx(Ao,{size:14,className:"stroke-[2.5]"}),s.jsx("span",{children:"Connections"})]})]})]})]})]})})}switch(ze){case"auth":{const qe=new URLSearchParams(window.location.search),_=qe.get("pending_follow_uid"),U=qe.get("pending_follow_name")||"";return s.jsx("div",{className:"min-h-[85vh] py-16 px-4 bg-slate-50 flex flex-col items-center justify-center font-sans",children:s.jsxs("div",{className:"w-full max-w-lg bg-white p-8 md:p-12 border border-gray-150 rounded-3xl shadow-lg relative overflow-hidden",children:[s.jsx("div",{className:"absolute top-0 left-0 w-full h-1.5 bg-[#EE1B24]"}),_&&s.jsxs("div",{className:"mb-8 p-4 bg-red-50/50 border border-red-100 rounded-2xl text-left select-none",children:[s.jsx("p",{className:"text-[9px] font-black uppercase text-[#EE1B24] tracking-widest mb-1",children:"Peer Connection Request"}),s.jsxs("p",{className:"text-xs text-gray-700 leading-relaxed font-semibold",children:["Sign up or log in below to automatically build your peer connection with ",s.jsxs("span",{className:"font-extrabold text-[#EE1B24]",children:["@",U.toLowerCase().replace(/\s+/g,"")]}),"."]})]}),s.jsx(OV,{onAuthSuccess:async()=>{const H=_||localStorage.getItem("pending_follow_uid"),re=U||localStorage.getItem("pending_follow_name")||"this peer";if(H&&Ne.currentUser)try{const We=Qt(it(pe,"follows"),Nr("followerId","==",Ne.currentUser.uid),Nr("followedId","==",H));(await vn(We)).empty&&(await ur(it(pe,"follows"),{followerId:Ne.currentUser.uid,followedId:H,createdAt:Bn()}),me.success(`Successfully followed ${re}!`))}catch(We){console.warn("Auto-follow check failed:",We)}finally{localStorage.removeItem("pending_follow_uid"),localStorage.removeItem("pending_follow_name")}me.success("Successfully authenticated. Welcome to Campus Eye!",{id:"auth-success-toast"});const Oe=new URL(window.location.href);Oe.searchParams.delete("tab"),Oe.searchParams.delete("pending_follow_uid"),Oe.searchParams.delete("pending_follow_name"),window.history.replaceState({},"",Oe.toString()),je("home")},onClose:()=>{je("home")}}),s.jsxs("div",{className:"mt-8 flex flex-col items-center justify-center space-y-2 pt-6 border-t border-gray-100",children:[s.jsx("div",{className:"w-10 h-10 bg-red-650 rounded-full flex items-center justify-center shadow-md",children:s.jsx(zh,{className:"text-white",size:20})}),s.jsx("span",{className:"text-[10px] font-serif font-black uppercase tracking-[0.2em] text-gray-950",children:"Campus Eye"}),s.jsx("span",{className:"text-[8px] font-mono uppercase tracking-widest text-gray-400",children:"Official Student Media Network"})]})]})})}case"podcasts":return s.jsx(PV,{});case"events":return s.jsxs("div",{className:"news-container py-12 px-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-12 border-b border-black pb-4",children:[s.jsx("h2",{className:"text-4xl font-serif font-black text-gray-950 tracking-tighter uppercase italic",children:"Events"}),s.jsx("button",{className:"px-6 py-2 bg-black text-white text-[10px] font-bold uppercase tracking-widest hover:bg-accent transition-all",children:"Submit Event"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[{title:"Freshers Gala",date:"25 APR",loc:"Main Hall",type:"Social"},{title:"Innovation Summit",date:"02 MAY",loc:"Tech Center",type:"Academy"},{title:"Varsity Finals",date:"15 MAY",loc:"Sports Complex",type:"Sports"}].map((qe,_)=>s.jsxs("div",{className:"group overflow-hidden border border-gray-150 rounded-2xl bg-white hover:bg-gray-50 transition-all p-3.5 flex gap-4 items-center",children:[s.jsxs("div",{className:"w-20 h-20 sm:w-24 sm:h-24 rounded-xl overflow-hidden bg-gray-950 relative shrink-0",children:[s.jsx("img",{src:`https://picsum.photos/seed/event${_}/300/300`,className:"w-full h-full object-cover opacity-85 group-hover:opacity-100 transition-all duration-700",alt:"",referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"absolute bottom-1 right-1 bg-white px-1.5 py-0.5 text-center shadow-md rounded",children:[s.jsx("p",{className:"text-[9px] font-black text-accent leading-none",children:qe.date.split(" ")[0]}),s.jsx("p",{className:"text-[7px] font-black text-gray-400 uppercase leading-none",children:qe.date.split(" ")[1]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[s.jsx("p",{className:"text-[8px] font-black text-accent uppercase tracking-widest mb-1",children:qe.type}),s.jsx("h3",{className:"text-sm font-serif font-black text-gray-950 mb-2 truncate leading-tight",children:qe.title}),s.jsxs("div",{className:"flex flex-col gap-1 text-gray-400 text-[8.5px] font-bold uppercase tracking-widest leading-none",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(H0,{size:10})," ",qe.date]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(mu,{size:10})," ",qe.loc]})]})]})]},_))})]});case"discussions":{const _=Sr.filter(U=>{if(!Le.trim())return!0;const H=Le.toLowerCase();return(U.title||"").toLowerCase().includes(H)||(U.description||"").toLowerCase().includes(H)});return s.jsxs("div",{className:"news-container py-12 px-4 max-w-4xl mx-auto space-y-8 animate-fade-in",children:[s.jsxs("div",{className:"text-center md:text-left space-y-2 border-b border-gray-100 pb-6 w-full",children:[s.jsxs("h2",{className:"text-3xl font-serif font-black text-gray-950 tracking-tighter uppercase italic flex items-center justify-center md:justify-start gap-2",children:[s.jsx(Yi,{className:"text-red-650 shrink-0",size:28}),s.jsx("span",{children:"Public Debates Lobby"})]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:"Active intellectual forums and critical arguments across our university"})]}),s.jsx("div",{className:"w-full rounded-[2rem] overflow-hidden border border-gray-150 shadow-md bg-white",children:s.jsx(DMe,{})}),s.jsxs("div",{className:"border-t border-gray-100 pt-8 mt-4 text-left",children:[s.jsx("h3",{className:"text-lg font-serif font-black text-gray-950 uppercase italic tracking-tight mb-2",children:"Ongoing Debate Threads"}),s.jsx("p",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-widest mb-6",children:"Explore individual debate channels or join dynamic arguments below"})]}),s.jsxs("div",{className:"relative w-full",children:[s.jsx("input",{type:"text",value:Le,onChange:U=>Ut(U.target.value),placeholder:"Search active debate threads by title or keywords...",className:"w-full px-5 py-3.5 pl-12 bg-white border border-gray-200 rounded-2xl text-xs font-bold shadow-sm focus:border-red-650 outline-none transition-all placeholder:text-gray-400 font-mono"}),s.jsx("span",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-440",children:s.jsx(Yi,{size:16})}),Le&&s.jsx("button",{onClick:()=>Ut(""),className:"absolute right-4 top-1/2 -translate-y-1/2 text-xs font-black uppercase text-gray-400 hover:text-red-500 font-mono transition-colors",children:"Clear"})]}),_.length===0?s.jsxs("div",{className:"bg-white p-12 text-center rounded-3xl border border-gray-100 shadow-sm space-y-3 w-full",children:[s.jsx("p",{className:"text-xs font-bold text-gray-400 uppercase tracking-widest font-mono",children:"No active debate topics match your search"}),s.jsx("button",{onClick:()=>Ut(""),className:"px-6 py-2.5 bg-gray-950 text-white text-[9px] font-black uppercase tracking-widest rounded-xl hover:bg-black transition-all cursor-pointer",children:"Reset Directory"})]}):s.jsx("div",{className:"space-y-6 w-full",children:_.map(U=>{const H=On===U.id;return s.jsxs("div",{className:"group bg-white rounded-3xl border border-gray-150 shadow-md hover:shadow-xl transition-all p-6 md:p-8 flex flex-col gap-6 relative overflow-hidden text-left",children:[s.jsxs("div",{className:"relative w-full h-40 md:h-52 bg-gray-50 overflow-hidden rounded-2xl border border-gray-100",children:[s.jsx("img",{src:U.bannerUrl||"https://images.unsplash.com/photo-1541872703-74c5e44368f9?auto=format&fit=crop&q=80&w=800",alt:"",className:"w-full h-full object-cover group-hover:scale-102 transition-transform duration-500",referrerPolicy:"no-referrer"}),s.jsx("div",{className:"absolute top-4 right-4 bg-gray-950/95 backdrop-blur-sm text-white text-[8px] font-black uppercase tracking-widest px-3 py-1.5 rounded-lg border border-white/10 shadow",children:U.isExternal?"External":"Built-In"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"text-xl md:text-2xl font-serif font-black text-gray-950 leading-tight",children:U.title}),U.description&&s.jsx("p",{className:"text-xs font-medium text-gray-500 leading-relaxed",children:U.description})]}),s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 pt-4 border-t border-gray-100",children:[s.jsxs("span",{className:"text-[9px] font-mono font-black text-gray-400 uppercase tracking-wider",children:["Created ",U.createdAt?U.createdAt.toDate?U.createdAt.toDate().toLocaleDateString():U.createdAt instanceof Date?U.createdAt.toLocaleDateString():new Date(U.createdAt).toLocaleDateString():"recently"]}),U.isExternal?s.jsxs("a",{href:U.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center gap-2 px-6 py-3 bg-accent hover:bg-red-700 text-white text-[10px] font-black uppercase tracking-[0.1em] rounded-xl shadow-lg shadow-accent/15 group-hover:scale-102 transition-all cursor-pointer",children:[s.jsx("span",{children:"Continue to Discussion"}),s.jsx(Va,{size:12})]}):s.jsxs("button",{onClick:()=>Mn(H?null:U.id),className:`inline-flex items-center justify-center gap-2 px-6 py-3 text-[10px] font-black uppercase tracking-[0.1em] rounded-xl transition-all cursor-pointer ${H?"bg-gray-100 text-gray-850 hover:bg-gray-200":"bg-accent hover:bg-red-700 text-white shadow-lg shadow-accent/15"}`,children:[s.jsx("span",{children:H?"Collapse arguments":"View & Join Debate"}),s.jsx(Yi,{size:12})]})]}),!U.isExternal&&H&&s.jsx("div",{className:"border-t border-gray-100 mt-2",children:s.jsx(RMe,{debateId:U.id})})]},U.id)})})]})}case"posts":return s.jsx(zMe,{isAdmin:gi,onUserProfileClick:Pt,sharedPostId:Ct});case"marketplace":return s.jsxs("div",{className:"news-container py-8 px-4 font-sans text-left space-y-8",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 border-b border-gray-200 pb-4",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-3xl font-serif font-black text-gray-950 tracking-tighter uppercase italic flex items-center gap-3",children:[s.jsx(hC,{size:30}),"Marketplace & Verified Affiliates"]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-500 uppercase tracking-wider mt-1",children:"Shop student items, explore verified affiliate accounts, and earn commission rewards on sales dispatches."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("a",{href:"https://link.thelocalrent.com/v?t=1786099107&tk=07c43b29b01fcaf275f96eea938d430f",target:"_blank",rel:"noopener noreferrer",className:"px-4 py-2 bg-gradient-to-r from-amber-500 to-orange-500 text-white text-[10px] font-extrabold uppercase tracking-widest rounded-xl hover:opacity-95 transition-all shadow-md flex items-center gap-1.5",children:[s.jsx(es,{size:14})," Join Affiliate Program"]}),s.jsx("button",{onClick:()=>me.success("To post items on Marketplace, open the Campus Eye App or contact an Admin!"),className:"px-4 py-2 bg-gray-950 text-white text-[10px] font-extrabold uppercase tracking-widest rounded-xl hover:bg-black transition-all shadow-sm",children:"Post Item"})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-900 flex items-center gap-2",children:[s.jsx(Ll,{size:16})," Verified Affiliate Accounts in Market"]}),s.jsx("span",{className:"text-[9px] font-bold text-emerald-600 bg-emerald-50 px-2.5 py-1 rounded-full border border-emerald-200/60 uppercase tracking-wider",children:"✓ Verified Merchants & Affiliates"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[{name:"Campus Tech Hub",handle:"@campustech",category:"Laptops & Electronics",commission:"10% Affiliate Reward",verified:!0,productsCount:24,rating:"4.9 ★"},{name:"Hostel Essentials Ltd",handle:"@hostelitems",category:"Furniture & Appliances",commission:"8% Affiliate Reward",verified:!0,productsCount:18,rating:"4.8 ★"},{name:"Varsity Books & Stationery",handle:"@varsitybooks",category:"Academic Coursework",commission:"12% Affiliate Reward",verified:!0,productsCount:42,rating:"5.0 ★"}].map((qe,_)=>s.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-gray-150 shadow-xs hover:border-amber-400 hover:shadow-md transition-all space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-tr from-amber-500 to-indigo-600 text-white font-extrabold text-sm flex items-center justify-center uppercase shadow-sm",children:qe.name.charAt(0)}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("h4",{className:"text-xs font-black text-gray-900",children:qe.name}),s.jsx(Ll,{size:12})]}),s.jsx("p",{className:"text-[10px] text-gray-400 font-bold",children:qe.handle})]})]}),s.jsx("span",{className:"text-[9px] font-black text-amber-700 bg-amber-50 border border-amber-200 px-2 py-0.5 rounded-md uppercase",children:qe.rating})]}),s.jsxs("div",{className:"text-[11px] text-gray-600 font-medium",children:["Category: ",s.jsx("span",{className:"font-bold text-gray-900",children:qe.category})," (",qe.productsCount," items)"]}),s.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-gray-100",children:[s.jsxs("span",{className:"text-[10px] font-black uppercase text-emerald-600 tracking-wide",children:["💰 ",qe.commission]}),s.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(`https://link.thelocalrent.com/v?t=1786099107&tk=07c43b29b01fcaf275f96eea938d430f&ref=${qe.handle.replace("@","")}`),me.success(`Copied Affiliate Link for ${qe.name}! Earn rewards on referrals.`,{icon:"🔗"})},className:"text-[9px] font-black uppercase tracking-wider text-indigo-600 bg-indigo-50 hover:bg-indigo-100 px-3 py-1.5 rounded-lg transition-colors cursor-pointer",children:"Get Affiliate Link"})]})]},_))})]}),s.jsxs("div",{className:"space-y-4 pt-4",children:[s.jsx("h3",{className:"text-xs font-black uppercase tracking-wider text-gray-900",children:"Featured Campus Listings"}),s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:[{name:"Scientific Calculator FX-991EX",price:"UGX 40,000",cat:"Academic",seller:"Campus Tech Hub",affiliate:"10% Reward"},{name:"Orthopedic Mattress & Bed Frame",price:"UGX 150,000",cat:"Hostel",seller:"Hostel Essentials Ltd",affiliate:"8% Reward"},{name:"Apple MacBook Pro M1 16GB",price:"UGX 3,500,000",cat:"Electronics",seller:"Campus Tech Hub",affiliate:"10% Reward"},{name:"Ergonomic Study Desk & Chair",price:"UGX 60,000",cat:"Hostel",seller:"Hostel Essentials Ltd",affiliate:"8% Reward"}].map((qe,_)=>s.jsxs("div",{className:"group bg-white border border-gray-150 rounded-2xl shadow-xs overflow-hidden flex flex-col hover:shadow-md transition-all",children:[s.jsxs("div",{className:"aspect-square bg-gray-50 flex items-center justify-center relative overflow-hidden",children:[s.jsx(gie,{size:40,className:"text-gray-300 group-hover:scale-110 transition-transform"}),s.jsxs("div",{className:"absolute top-3 right-3 bg-amber-500 text-white px-2.5 py-0.5 text-[8px] font-black uppercase tracking-widest rounded-full shadow-xs flex items-center gap-1",children:[s.jsx(Ll,{size:10,className:"text-white"})," Verified"]})]}),s.jsxs("div",{className:"p-4 flex-1 flex flex-col justify-between space-y-2",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-[9px] font-extrabold text-gray-400 uppercase tracking-widest",children:qe.cat}),s.jsx("span",{className:"text-[8px] font-black text-emerald-600 bg-emerald-50 px-1.5 py-0.5 rounded",children:qe.affiliate})]}),s.jsx("h3",{className:"text-xs font-black text-gray-950 mt-1 line-clamp-1",children:qe.name}),s.jsxs("p",{className:"text-[10px] font-bold text-gray-500 mt-0.5",children:["Seller: ",qe.seller]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-gray-100 gap-1",children:[s.jsx("p",{className:"text-xs font-black text-indigo-600 truncate",children:qe.price}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.jsxs("button",{type:"button",onClick:U=>{U.stopPropagation(),window.dispatchEvent(new CustomEvent("open-imessage-friend",{detail:{uid:qe.sellerId||`seller_${_}`,displayName:qe.seller,username:qe.seller.toLowerCase().replace(/\s+/g,""),photoURL:""}}))},className:"p-1 px-2 bg-[#007AFF] hover:bg-blue-600 text-white rounded-lg transition-all cursor-pointer flex items-center gap-1 text-[8.5px] font-black uppercase tracking-wider shrink-0 shadow-2xs",title:`Direct messaging envelope icon: Chat with connected seller ${qe.seller}`,children:[s.jsx(Js,{size:10,strokeWidth:2.5}),s.jsx("span",{className:"hidden sm:inline",children:"Message"})]}),s.jsx("button",{onClick:()=>{window.open("https://link.thelocalrent.com/v?t=1786099107&tk=07c43b29b01fcaf275f96eea938d430f","_blank")},className:"text-[9px] font-black uppercase tracking-wider text-white bg-black hover:bg-neutral-800 px-2.5 py-1 rounded-lg transition-colors cursor-pointer",children:"Buy Item"})]})]})]})]},_))})]})]});case"teams":return s.jsxs("div",{className:"news-container py-12 px-4",children:[s.jsx("h2",{className:"text-4xl font-serif font-black text-gray-950 tracking-tighter uppercase italic mb-12 border-b border-black pb-4",children:"University Teams"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8",children:["Basketball","Football","Rugby"].map((qe,_)=>s.jsxs("div",{className:"bg-white p-10 border border-gray-100 shadow-xl text-center group hover:bg-black hover:text-white transition-all duration-500",children:[s.jsx("div",{className:"w-24 h-24 bg-gray-50 rounded-full mx-auto mb-8 flex items-center justify-center text-gray-300 group-hover:bg-accent group-hover:text-white transition-all scale-110 shadow-inner",children:s.jsx(Ao,{size:40})}),s.jsxs("h3",{className:"text-2xl font-serif font-black uppercase italic tracking-tighter mb-2",children:[qe," Team"]}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-[0.3em] mb-8",children:"Varsity Div 1"}),s.jsx("button",{className:"w-full py-4 bg-black text-white text-[10px] font-black uppercase tracking-widest hover:bg-white hover:text-black border border-transparent hover:border-gray-200 transition-all",children:"Join Team"})]},_))})]});case"feedback":return s.jsx("div",{className:"news-container py-12 px-4 min-h-[70vh]",children:s.jsxs("div",{className:"flex flex-col lg:flex-row gap-16",children:[s.jsxs("div",{className:"lg:w-1/3 space-y-8",children:[s.jsxs("h2",{className:"text-5xl font-serif font-black text-gray-950 leading-[0.85] uppercase italic tracking-tighter",children:["Voice Your ",s.jsx("span",{className:"text-accent block",children:"Opinion."})]}),s.jsx("p",{className:"text-gray-500 font-bold leading-relaxed italic border-l-4 border-accent pl-6",children:`"Your feedback is the heart of our evolution. Tell us what we're missing."`}),s.jsx("div",{className:"pt-8 border-t border-gray-100 flex flex-col gap-6",children:s.jsxs("div",{className:"flex items-center gap-4 text-gray-400 group",children:[s.jsx("div",{className:"w-10 h-10 bg-gray-50 flex items-center justify-center text-accent group-hover:bg-accent group-hover:text-white transition-all",children:s.jsx(Js,{size:16})}),s.jsx("span",{className:"text-xs font-bold uppercase tracking-widest text-gray-950",children:"feedback@campuseye.media"})]})})]}),s.jsxs("div",{className:"flex-1 bg-white p-8 md:p-12 shadow-2xl border border-gray-100 relative overflow-hidden",children:[s.jsx("div",{className:"absolute top-0 right-0 w-32 h-32 bg-accent/5 rounded-full -mr-16 -mt-16 blur-3xl"}),s.jsxs("form",{onSubmit:co,className:"space-y-8 relative z-10",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:"Full Identity"}),s.jsx("input",{required:!0,type:"text",value:Ls.name,onChange:qe=>Yn({...Ls,name:qe.target.value}),className:"w-full px-6 py-4 bg-gray-50 border-2 border-transparent focus:border-accent transition-all outline-none text-sm font-bold placeholder:text-gray-300",placeholder:"e.g. Victor Atwiine"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:"Digital Address"}),s.jsx("input",{required:!0,type:"email",value:Ls.email,onChange:qe=>Yn({...Ls,email:qe.target.value}),className:"w-full px-6 py-4 bg-gray-50 border-2 border-transparent focus:border-accent transition-all outline-none text-sm font-bold placeholder:text-gray-300",placeholder:"Enter your email address"})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:"Detailed Critique"}),s.jsx("textarea",{required:!0,value:Ls.message,onChange:qe=>Yn({...Ls,message:qe.target.value}),className:"w-full px-6 py-4 bg-gray-50 border-2 border-transparent focus:border-accent transition-all outline-none text-sm font-bold placeholder:text-gray-300 min-h-[200px] resize-none",placeholder:"How can we sharpen our eye?"})]}),s.jsx("button",{type:"submit",disabled:oi,className:"w-full py-5 bg-black text-white text-[11px] font-black uppercase tracking-[0.3em] hover:bg-accent transition-all disabled:opacity-50",children:oi?"TRANSMITTING...":"DISPATCH FEEDBACK"})]})]})]})});case"account":return Ir?s.jsxs("div",{className:"news-container py-20 px-4 min-h-[50vh] flex flex-col items-center justify-center",children:[s.jsx(Pr,{className:"animate-spin text-gray-500 mb-2",size:24}),s.jsx("p",{className:"text-[10px] font-sans font-black uppercase tracking-widest text-gray-400",children:"Retrieving Member Profile..."})]}):jt?s.jsx("div",{className:"news-container py-10 px-4 min-h-[70vh] max-w-2xl mx-auto relative font-sans",children:s.jsxs("div",{className:"bg-white p-10 border border-gray-100 relative overflow-hidden text-left shadow-sm rounded-2xl",children:[s.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-[#EE1B24]"}),s.jsx("button",{onClick:()=>{const qe=new URL(window.location.href);qe.searchParams.delete("uid"),window.history.replaceState({},"",qe.toString()),on(null),je("home"),window.scrollTo({top:0,behavior:"auto"})},className:"absolute top-5 right-5 p-2 text-gray-400 hover:text-black hover:bg-gray-50 rounded-full transition-all border border-transparent hover:border-gray-150 cursor-pointer flex items-center justify-center",title:"Close Profile & Return Home",children:s.jsx(er,{size:16})}),s.jsxs("div",{className:"flex flex-col items-center text-center relative z-10 mb-12",children:[s.jsx("div",{className:"relative mb-6",children:s.jsx("div",{className:"w-32 h-32 border border-gray-200 overflow-hidden ring-4 ring-gray-50 rounded-full",children:s.jsx("img",{src:jt.photoURL||`https://ui-avatars.com/api/?name=${encodeURIComponent(jt.displayName||"User")}&background=random`,className:"w-full h-full object-cover rounded-full",alt:"",referrerPolicy:"no-referrer"})})}),s.jsxs("div",{className:"flex items-center gap-2 mt-2 select-none",children:[s.jsx("h2",{className:"text-3xl font-sans font-extrabold text-gray-950 tracking-tight uppercase",children:(()=>{const qe=jt.displayName||"Campus Peer";return qe.includes("@")?qe.split("@")[0]:qe})()}),jt.role==="admin"&&s.jsx("span",{className:"text-[7.5px] font-black uppercase tracking-widest text-[#9B2C2C] bg-[#FFF5F5] border border-red-100 px-2 py-0.5 rounded-full inline-block",children:"Staff"})]}),s.jsxs("div",{className:"flex items-center justify-center gap-6 mt-6 py-4.5 px-6 border border-gray-100 rounded-2xl bg-gray-50/40 w-full max-w-sm select-none",children:[s.jsxs("div",{onClick:()=>{lr("following"),mt(jt.id),or(!0)},className:"text-center font-sans cursor-pointer hover:opacity-80 transition-all",title:"View Following list",children:[s.jsx("p",{className:"text-xl font-black text-gray-950",children:ue}),s.jsx("p",{className:"text-[8.5px] font-black uppercase text-gray-450 tracking-widest mt-0.5",children:"Following"})]}),s.jsx("div",{className:"h-8 w-[1px] bg-gray-150"}),s.jsxs("div",{onClick:()=>{lr("followers"),mt(jt.id),or(!0)},className:"text-center font-sans cursor-pointer hover:opacity-80 transition-all",title:"View Followers list",children:[s.jsx("p",{className:"text-xl font-black text-gray-950",children:Xe}),s.jsx("p",{className:"text-[8.5px] font-black uppercase text-gray-450 tracking-widest mt-0.5",children:"Followers"})]})]}),s.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-3 w-full max-w-md mt-8",children:[s.jsxs("button",{onClick:async()=>{if(!Ne.currentUser){localStorage.setItem("pending_follow_uid",jt.id),localStorage.setItem("pending_follow_name",jt.displayName||"Campus Member");const qe=`${window.location.origin}/?tab=auth&pending_follow_uid=${jt.id}&pending_follow_name=${encodeURIComponent(jt.displayName||"Campus Member")}`;window.open(qe,"_blank"),me.success("Opening connection setup dashboard in a new tab!",{id:"login-to-follow"});return}try{const qe=Qt(it(pe,"follows"),Nr("followerId","==",Ne.currentUser.uid),Nr("followedId","==",jt.id)),_=await vn(qe);_.empty?(await ur(it(pe,"follows"),{followerId:Ne.currentUser.uid,followedId:jt.id,createdAt:Bn()}),me.success(`Following ${jt.displayName||"User"}`)):(await ni(ot(pe,"follows",_.docs[0].id)),me.success(`Unfollowed ${jt.displayName||"User"} successfully`))}catch(qe){console.warn("Follow toggle failed:",qe)}},className:"w-full py-4.5 bg-neutral-950 hover:bg-neutral-900 border border-neutral-800 text-white font-black uppercase tracking-widest text-xs transition-all active:scale-[0.98] cursor-pointer flex items-center justify-center gap-2 rounded-xl",children:[gn?"UNFOLLOW ":"★ FOLLOW "," MEMBERS"]}),s.jsxs("button",{onClick:()=>{const qe=`${window.location.origin}/?tab=account&uid=${jt.id}`;navigator.clipboard.writeText(qe).then(()=>me.success("Copied profile sharing link to clipboard!",{id:"profile-copied"})).catch(()=>me.error("Failed to copy link. Please copy URL from browser address bar.",{id:"profile-copy-fail"}))},className:"w-full py-4.5 bg-white hover:bg-gray-50 border border-gray-200 text-gray-800 font-black uppercase tracking-widest text-xs transition-all active:scale-[0.98] cursor-pointer flex items-center justify-center gap-2 rounded-xl",children:[s.jsx(df,{size:13})," SHARE PROFILE"]}),s.jsxs("button",{onClick:()=>Ve(jt.id),className:"w-full py-4 bg-gray-950 hover:bg-black border border-gray-800 text-amber-300 font-black uppercase tracking-widest text-xs transition-all active:scale-[0.98] cursor-pointer flex items-center justify-center gap-2 rounded-xl",children:[s.jsx(xp,{size:14,className:"text-amber-400"})," VIEW CITIZEN STATS & GRAPH"]})]}),!Ne.currentUser&&s.jsxs("div",{className:"w-full max-w-sm mt-8 p-6 bg-slate-50 border border-gray-150/80 rounded-2xl text-center space-y-4 shadow-xs select-none",children:[s.jsx("p",{className:"text-[11px] font-sans font-bold uppercase tracking-wider text-gray-500",children:"✨ Peer linkage Invitation"}),s.jsxs("p",{className:"text-xs text-gray-600 leading-relaxed font-medium",children:["Connect with ",s.jsx("span",{className:"font-extrabold text-black",children:(()=>{const qe=jt.displayName||"Campus Peer";return qe.includes("@")?qe.split("@")[0]:qe})()})," to monitor peer announcements and student lounge dispatches!"]}),s.jsxs("div",{className:"flex flex-col gap-2 pt-1",children:[s.jsx("button",{onClick:()=>{localStorage.setItem("pending_follow_uid",jt.id),localStorage.setItem("pending_follow_name",jt.displayName||"this peer"),xe(!0)},className:"w-full py-3 bg-[#EE1B24] hover:bg-red-700 text-white font-black uppercase tracking-widest text-[9.5px] rounded-xl transition-all active:scale-95 flex items-center justify-center gap-2 cursor-pointer shadow-sm",children:"Continue with Google / Sign Up"}),s.jsxs("button",{onClick:()=>{window.open(window.location.href,"_blank")},className:"w-full py-2.5 bg-white hover:bg-gray-50 border border-gray-200 text-gray-700 font-black uppercase tracking-widest text-[8.5px] rounded-xl transition-all flex items-center justify-center gap-1.5 cursor-pointer",children:[s.jsx(Va,{size:11,className:"mr-1"})," Open in New Tab"]})]}),s.jsxs("div",{className:"pt-4 border-t border-gray-150/60 flex flex-col items-center",children:[s.jsx(Cee,{className:"scale-[0.8] opacity-75"}),s.jsx("p",{className:"text-[7px] font-mono font-bold tracking-[0.25em] text-gray-400 uppercase mt-2",children:"Autonomous Student Journalism System"})]})]}),s.jsxs("div",{className:"mt-8 text-center pt-6 border-t border-gray-100 w-full max-w-sm",children:[s.jsx("span",{className:"text-[8.5px] font-sans font-black text-gray-400 uppercase tracking-widest block mb-3.5",children:"🤝 Peer-to-Peer Lounge Linkages"}),s.jsx("button",{onClick:()=>{if(!Ne.currentUser){me.error("Please login to access Peer Lounge connect systems."),xe(!0);return}lr("connections"),or(!0),me.success("Opened Peer connections board!")},className:"px-5 py-2 hover:bg-[#EEF2F6] text-[#2B6CB0] font-black uppercase text-[9px] tracking-widest rounded-full border border-blue-150 bg-[#F7FAFC] transition-colors",children:"Browse Mutual Collaborators"})]})]})]})}):gi&&en?s.jsx("div",{className:"news-container py-10 px-4 min-h-[90vh] max-w-5xl mx-auto",children:s.jsxs("div",{className:"bg-white p-6 md:p-10 border border-gray-150 rounded-2xl relative shadow-md overflow-hidden text-left",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 pb-4 border-b border-gray-150 mb-8 select-none",children:[s.jsx("button",{onClick:()=>wr(!1),className:"p-1.5 border border-gray-200 hover:border-black text-gray-650 hover:text-black rounded-lg cursor-pointer transition-colors",title:"Back to User Profile Info",children:s.jsx(_ne,{size:14,className:"shrink-0"})}),s.jsx("div",{className:"flex items-center gap-2",title:"Editorial Director Console",children:s.jsx("div",{className:"p-1.5 bg-[#FFF5F5] text-[#9B2C2C] rounded-lg border border-red-100",children:s.jsx(nj,{size:14,className:"shrink-0"})})})]}),s.jsx(fk,{initialTab:yn})]})}):s.jsx("div",{className:"news-container py-10 px-4 min-h-[70vh] max-w-2xl mx-auto relative",children:s.jsxs("div",{className:"bg-white p-10 border border-gray-100 relative overflow-hidden text-left shadow-sm rounded-2xl",children:[s.jsx("button",{onClick:()=>{je($n),window.scrollTo({top:0,behavior:"auto"})},className:"absolute top-5 right-5 p-2 text-gray-400 hover:text-black hover:bg-gray-50 rounded-full transition-all border border-transparent hover:border-gray-150 cursor-pointer flex items-center justify-center p-2.5 z-50",title:"Exit Profile & Return",children:s.jsx(er,{size:16})}),s.jsxs("div",{className:"flex flex-col items-center text-center relative z-10 mb-12",children:[s.jsxs("div",{className:"relative mb-6 group",children:[s.jsx("div",{className:"w-32 h-32 border border-gray-200 overflow-hidden ring-4 ring-gray-50",children:s.jsx("img",{src:((lt=Ne.currentUser)==null?void 0:lt.photoURL)||`https://ui-avatars.com/api/?name=${encodeURIComponent(((At=Ne.currentUser)==null?void 0:At.displayName)||"User")}&background=random`,className:"w-full h-full object-cover",alt:""})}),s.jsxs("label",{className:"absolute bottom-1 right-1 p-2 bg-black text-white cursor-pointer hover:bg-accent transition-all rounded-full border border-white shadow-md",title:"Change Avatar Photo",children:[s.jsx(Ed,{size:14}),s.jsx("input",{type:"file",className:"hidden",accept:"image/*",onChange:Ys})]})]}),na?s.jsxs("div",{className:"flex items-center gap-2 mt-2 w-full max-w-xs",children:[s.jsx("input",{type:"text",value:Pa,onChange:qe=>ks(qe.target.value),className:"border-2 border-accent px-3 py-1.5 rounded-lg text-sm text-center font-bold outline-none flex-1 tracking-tight min-w-0",placeholder:"Enter new username",required:!0}),s.jsx("button",{onClick:bi,disabled:oi,className:"p-2 bg-accent hover:bg-black text-white rounded-lg transition-colors cursor-pointer flex items-center justify-center w-8 h-8",title:"Save Name",children:s.jsx(Pu,{size:14,className:"stroke-[3]"})}),s.jsx("button",{onClick:()=>Ms(!1),className:"p-2 bg-gray-100 hover:bg-gray-200 text-gray-600 rounded-lg transition-colors cursor-pointer flex items-center justify-center w-8 h-8",title:"Cancel Edit",children:s.jsx(er,{size:14})})]}):s.jsxs("div",{className:"flex items-center gap-2.5 mt-2 group select-none",children:[s.jsx("h2",{className:"text-3xl font-sans font-extrabold text-gray-950 tracking-tight uppercase",children:((bn=Ne.currentUser)==null?void 0:bn.displayName)||"Campus Member"}),s.jsxs("div",{className:"flex items-center gap-1 opacity-100 transition-opacity",children:[s.jsx("button",{onClick:()=>{var qe;ks(((qe=Ne.currentUser)==null?void 0:qe.displayName)||""),Ms(!0)},className:"p-1.5 text-gray-400 hover:text-accent border border-gray-150 hover:border-accent rounded-full bg-white hover:scale-105 transition-all text-[10px] cursor-pointer flex items-center justify-center shadow-xs",title:"Edit Display Name",children:s.jsx(Ed,{size:11})}),s.jsx("button",{onClick:()=>{var _;const qe=`${window.location.origin}/u/profile/${(_=Ne.currentUser)==null?void 0:_.uid}`;navigator.clipboard.writeText(qe).then(()=>me.success("Copied profile sharing link to clipboard!",{id:"profile-copied"})).catch(()=>me.error("Failed to copy link. Please copy URL from browser address bar.",{id:"profile-copy-fail"}))},className:"p-1.5 text-gray-400 hover:text-accent border border-gray-150 hover:border-accent rounded-full bg-white hover:scale-105 transition-all text-[10px] cursor-pointer flex items-center justify-center shadow-xs",title:"Share profile next to editing icon",children:s.jsx(df,{size:11})})]})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[s.jsx(Js,{size:14,className:"text-gray-400"}),s.jsx("p",{className:"text-gray-400 font-bold uppercase tracking-widest text-[10px]",children:(Mt=Ne.currentUser)==null?void 0:Mt.email})]})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-8 text-center select-none relative z-10",children:[s.jsxs("div",{onClick:()=>{lr("followers"),or(!0)},className:"p-4 bg-gray-50 border border-gray-100/80 rounded-xl hover:border-red-650/30 hover:bg-red-50/10 cursor-pointer hover:scale-[1.02] active:scale-98 transition-all",title:"Click to view Followers",id:"profile-followers-box",children:[s.jsx("span",{className:"block text-2xl font-sans font-extrabold text-gray-950",children:xi}),s.jsx("span",{className:"text-[9px] font-black uppercase text-gray-400 tracking-widest font-mono",children:"Followers"})]}),s.jsxs("div",{onClick:()=>{lr("following"),or(!0)},className:"p-4 bg-gray-50 border border-gray-100/80 rounded-xl hover:border-red-650/30 hover:bg-red-50/10 cursor-pointer hover:scale-[1.02] active:scale-98 transition-all",title:"Click to view Following",id:"profile-following-box",children:[s.jsx("span",{className:"block text-2xl font-sans font-extrabold text-gray-950",children:Sn}),s.jsx("span",{className:"text-[9px] font-black uppercase text-gray-400 tracking-widest font-mono",children:"Following"})]}),s.jsxs("div",{onClick:()=>{lr("connections"),or(!0)},className:"p-4 bg-gray-50 border border-gray-100/80 rounded-xl hover:border-red-650/30 hover:bg-red-50/10 cursor-pointer hover:scale-[1.02] active:scale-98 transition-all",title:"Click to view Peer Lounge Connections",id:"profile-connections-box",children:[s.jsx("span",{className:"block text-2xl font-sans font-extrabold text-[#9B2C2C]",children:mi}),s.jsx("span",{className:"text-[9px] font-black uppercase text-gray-400 tracking-widest font-mono",children:"Peer Lounge"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 relative z-10",children:[s.jsxs("div",{className:"p-6 bg-gray-50 border border-gray-100",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[s.jsx("div",{className:"p-2 bg-white border border-gray-200 text-black",children:s.jsx(mu,{size:16})}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:"Active Role"})]}),s.jsx("p",{className:"font-sans font-extrabold text-gray-950 uppercase tracking-tight text-xl",children:gi?"Editorial Board":"Student Reporter"})]}),s.jsxs("div",{className:"p-6 bg-gray-50 border border-gray-100",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[s.jsx("div",{className:"p-2 bg-white border border-gray-200 text-accent",children:s.jsx(pl,{size:16})}),s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:"Trust Rating"})]}),s.jsx("p",{className:"font-sans font-extrabold text-accent uppercase tracking-tight text-xl",children:"Verified Member"})]})]}),s.jsx("div",{className:"mt-10 pt-10 border-t border-gray-100 relative z-10 font-sans",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8 text-left",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("h3",{className:"text-sm font-sans font-extrabold uppercase tracking-wider text-gray-950 flex items-center gap-2",children:[s.jsx(No,{size:16,className:"text-accent"})," My Event Tickets"]}),s.jsx("button",{onClick:()=>Ft(!0),className:"text-[10px] font-black uppercase tracking-widest text-accent hover:underline cursor-pointer",children:"Browse Events"})]}),s.jsx(A9e,{userId:((An=Ne.currentUser)==null?void 0:An.uid)||""})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("h3",{className:"text-sm font-sans font-extrabold uppercase tracking-wider text-gray-950 flex items-center gap-2",children:[s.jsx(Js,{size:16,className:"text-red-650"})," System Inbox & Keys"]}),s.jsx("span",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-widest",children:"Confidential OTP Center"})]}),s.jsx(_9e,{userId:((Rn=Ne.currentUser)==null?void 0:Rn.uid)||""})]})]})}),s.jsxs("div",{className:"mt-10 pt-10 border-t border-gray-100 text-left relative z-10",children:[s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsxs("h3",{className:"text-sm font-sans font-extrabold uppercase tracking-wider text-gray-950 flex items-center gap-2",children:[s.jsx(Ao,{size:16,className:"text-red-650"})," Member Portal Desk"]}),s.jsx("span",{className:"text-[9px] font-black text-gray-400 tracking-wider uppercase",children:"Active Dispatch Terminals"})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3.5",children:[{id:"home",label:"Home",icon:K6,desc:"Central Dispatches"},{id:"news",label:"Campus News",icon:zh,desc:"Hot editorial stream"},{id:"discussions",label:"Public Debates",icon:Yi,desc:"Forum spaces & polls"},{id:"tickets",label:"Ticket Store",icon:No,desc:"Browse latest event passes"},{id:"podcasts",label:"Audio Podcasts",icon:sc,desc:"Listen to radio dispatches"},{id:"feedback",label:"Feedback Desk",icon:Js,desc:"Critiques, tips, & suggestions"}].map(qe=>s.jsxs("button",{onClick:()=>{je(qe.id),he(null),window.scrollTo({top:0,behavior:"smooth"})},className:"group flex flex-col p-4 bg-gray-50/50 hover:bg-red-50/30 border border-gray-100 hover:border-red-600/20 transition-all rounded-xl text-left gap-1 cursor-pointer",children:[s.jsxs("div",{className:"flex items-center gap-2 text-gray-900 group-hover:text-red-650 font-black text-xs uppercase tracking-wider transition-colors",children:[s.jsx(qe.icon,{size:13}),s.jsx("span",{children:qe.label})]}),s.jsx("span",{className:"text-[9.5px] text-gray-400 group-hover:text-gray-500 font-bold uppercase tracking-wider leading-none transition-colors",children:qe.desc})]},qe.id))})]}),s.jsxs("div",{className:"mt-10 pt-10 border-t border-gray-100 flex flex-col gap-4 relative z-10",children:[s.jsx("button",{onClick:async()=>{try{je("home"),await Ne.signOut(),me.success("Successfully logged out!",{icon:"👋"})}catch(qe){me.error("Logout error: "+qe.message)}},className:"w-full py-4 bg-gray-950 text-white font-black uppercase tracking-[0.2em] text-xs hover:bg-black transition-all cursor-pointer",children:"Logout"}),gi&&s.jsxs("button",{onClick:()=>Vr(),className:"w-full py-4 bg-accent text-white font-black uppercase tracking-[0.2em] text-xs hover:bg-black transition-all shadow-xl shadow-blue-100 flex items-center justify-center gap-2 cursor-pointer",children:[s.jsx(pl,{size:16})," Admins Dashboard"]})]})]})});case"admin":return gi?s.jsx(fk,{initialTab:yn}):null;default:return null}};return te?s.jsxs("div",{className:"fixed inset-0 z-[99999] bg-white flex flex-col min-h-screen",children:[s.jsx(JD,{}),s.jsxs("div",{className:"h-14 border-b border-gray-100 px-4 flex items-center justify-between bg-white backdrop-blur-md",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:"https://i.ibb.co/qLbqdWNm/f244d6ea7cd7.jpg",alt:"Logo",className:"h-7 w-7 rounded-full object-cover",referrerPolicy:"no-referrer"}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-[#000000]",children:"Campus Eye Media"})]}),s.jsx("div",{className:"h-2 w-2 rounded-full bg-red-650"})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50/30 p-4 md:p-6 max-w-3xl mx-auto w-full space-y-6 pt-10",children:[s.jsxs("div",{className:"space-y-3 ",children:[s.jsx("div",{className:"h-3 bg-red-100 rounded w-20"}),s.jsx("div",{className:"h-8 bg-gray-200 rounded-lg w-[90%]"}),s.jsx("div",{className:"h-8 bg-gray-200 rounded-lg w-[60%]"})]}),s.jsxs("div",{className:"flex items-center gap-3 pt-2 pb-6 border-b border-gray-150",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-gray-200"}),s.jsxs("div",{className:"space-y-2 flex-1",children:[s.jsx("div",{className:"h-3 bg-gray-200 rounded w-28"}),s.jsx("div",{className:"h-2.5 bg-gray-150 rounded w-16"})]})]}),s.jsxs("div",{className:"space-y-4 pt-4",children:[s.jsx("div",{className:"h-56 bg-gray-150 rounded-2xl w-full"}),s.jsxs("div",{className:"space-y-2.5 pt-4",children:[s.jsx("div",{className:"h-3.5 bg-gray-100 rounded w-full"}),s.jsx("div",{className:"h-3.5 bg-gray-100 rounded w-[96%]"}),s.jsx("div",{className:"h-3.5 bg-gray-100 rounded w-[98%]"}),s.jsx("div",{className:"h-3.5 bg-gray-100 rounded w-[92%]"})]})]})]})]}):s.jsxs("div",{className:"min-h-screen bg-white pb-32 overflow-x-clip",children:[s.jsx(JD,{}),s.jsx(HMe,{isOpen:jo,onClose:()=>{or(!1),mt(null)},currentUserId:((Fr=Ne.currentUser)==null?void 0:Fr.uid)||"",viewingUserId:Re||((uo=Ne.currentUser)==null?void 0:uo.uid)||"",initialTab:kr,onUserProfileClick:ge=>{Pt(ge)}}),s.jsx(Oee,{isOpen:!!Je,onClose:()=>vt(null),friend:Je,currentUserId:((ci=Ne.currentUser)==null?void 0:ci.uid)||"",currentUserProfile:{uid:((ia=Ne.currentUser)==null?void 0:ia.uid)||"",displayName:((Zo=Ne.currentUser)==null?void 0:Zo.displayName)||"Campus Peer",username:(((st=Ne.currentUser)==null?void 0:st.displayName)||"peer").toLowerCase().replace(/\s+/g,""),photoURL:((mr=Ne.currentUser)==null?void 0:mr.photoURL)||""}}),s.jsx(mye,{onSearch:ma,isAdmin:gi,onAdminClick:Vr,activeTab:ze,setActiveTab:je,latestArticles:o,openAuth:()=>xe(!0),customPagesList:ve,setSelectedCustomPage:J,selectedCustomPage:Be,onScanClick:()=>un(!0),onOpenChat:ge=>vt(ge)}),s.jsx(gye,{activeTab:ze,setActiveTab:je,onProfileClick:()=>Ne.currentUser?je("account"):xe(!0),isAdmin:gi,onAdminClick:Vr,openAuth:()=>xe(!0),onMenuClick:()=>pn(!0),onPodcastClick:()=>Fe(!0),isPodcastModalOpen:ae}),s.jsx(IMe,{}),s.jsx("main",{className:"news-container pt-16 sm:pt-20 md:pt-22 pb-20",children:s.jsx("div",{children:El()||s.jsx("div",{className:"text-center py-10",children:s.jsx(Ep,{variant:"magazine"})})})}),s.jsx(ar,{children:sn&&s.jsxs("div",{className:"fixed inset-0 z-[2500] flex",children:[s.jsx(Kt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>pn(!1),className:"fixed inset-0 bg-black/40 backdrop-blur-sm"}),s.jsxs(Kt.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",damping:25,stiffness:220},className:"relative w-80 max-w-[85vw] bg-white h-full shadow-2xl overflow-y-auto flex flex-col pt-5 px-6 border-r border-gray-150 z-50 text-left",children:[s.jsxs("div",{className:"flex items-center justify-between pb-4 border-b border-gray-100 mb-6",children:[s.jsxs("div",{className:"flex items-center gap-1.5 font-black text-gray-950 text-[11px] tracking-wider",children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full bg-red-600 shrink-0"}),s.jsx("span",{children:"CITIZEN DASHBOARD"})]}),s.jsx("button",{onClick:()=>pn(!1),className:"p-1.5 rounded-full hover:bg-gray-100 text-gray-400 hover:text-gray-950 transition-all cursor-pointer",children:s.jsx(er,{size:16})})]}),s.jsxs("div",{className:"flex-1 space-y-1.5",children:[[{id:"home",label:"Home",icon:K6},{id:"news",label:"Campus News",icon:zh},{id:"discussions",label:"Public Debates",icon:Yi},{id:"tickets",label:"Ticket Store",icon:No},{id:"podcasts",label:"Audio Podcasts",icon:sc},{id:"feedback",label:"Feedback Desk",icon:Js},{id:"account",label:"My Account",icon:TN}].map(ge=>s.jsxs("button",{onClick:()=>{ge.id==="tickets"?Ft(!0):ge.id==="podcasts"?Fe(!0):(je(ge.id),J(null)),pn(!1),he(null)},className:Ge("flex items-center gap-3 w-full px-4 py-2.5 rounded-xl transition-all font-bold text-xs uppercase tracking-wider text-left",ze===ge.id&&!Be?"bg-red-650 text-white shadow-md font-black":"text-gray-550 hover:bg-gray-50 hover:text-black"),children:[s.jsx(ge.icon,{size:14}),s.jsx("span",{children:ge.label})]},ge.id)),ve&&ve.length>0&&ve.map(ge=>{var Te;const we=(Te=ge.createdAt)!=null&&Te.seconds?Date.now()-ge.createdAt.seconds*1e3<6048e5:!1;return s.jsxs("button",{onClick:()=>{J(ge),pn(!1)},className:Ge("flex items-center gap-3 w-full px-4 py-2.5 rounded-xl transition-all font-bold text-xs uppercase tracking-wider text-left cursor-pointer",(Be==null?void 0:Be.id)===ge.id?"bg-red-650 text-white shadow-md font-black [&_svg]:!stroke-white [&_path]:!stroke-white [&_svg]:!fill-white [&_path]:!fill-white":"text-gray-550 hover:bg-gray-50 hover:text-black"),children:[ge.svgIcon?s.jsx("span",{className:"shrink-0 w-3.5 h-3.5 flex items-center justify-center text-current [&>svg]:w-full [&>svg]:h-full [&>svg]:shrink-0 transition-colors",dangerouslySetInnerHTML:{__html:ge.svgIcon.includes("${ge.svgIcon}`}}):s.jsx(Va,{size:14,className:"text-red-550 shrink-0"}),s.jsx("span",{className:"truncate",children:ge.name}),we&&s.jsx("span",{className:"bg-red-500 text-white text-[7px] font-black uppercase px-1.5 py-0.5 rounded-full select-none shrink-0 ml-auto",children:"New"})]},ge.id)}),gi&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100/80 space-y-1 select-none text-left",children:[s.jsxs("div",{className:"px-4 py-1.5 flex items-center gap-1.5",children:[s.jsx(pl,{size:12,className:"text-red-650"}),s.jsx("span",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest",children:"Editorial Board Control"})]}),[{subTab:"dashboard",label:"Dashboard Stats",desc:"Track traffic & revenue metrics",icon:mu},{subTab:"article",label:"Write New Dispatch",desc:"Draft and deploy live articles",icon:Ed},{subTab:"manage-articles",label:"Manage Store & Articles",desc:"Revise or withdraw stories",icon:zh},{subTab:"advert",label:"Sponsor Advert Upload",desc:"Configure video or flyer ads",icon:$p},{subTab:"manage-ads",label:"Manage Sponser Ads",desc:"Monitor active and draft campaigns",icon:Su},{subTab:"flagged-comments",label:"Censor comments",desc:"Approve or delete flagged text",icon:bu},{subTab:"manage-tickets",label:"Configure Tickets",desc:"Publish event store entries",icon:No},{subTab:"ticket-purchases",label:"Passes & Ticket Sales",desc:"Verify passes & view sales records",icon:eie}].map(ge=>s.jsxs("button",{onClick:()=>{Vr(ge.subTab),pn(!1)},className:"w-full flex items-start gap-3 px-4 py-2 hover:bg-red-50/30 rounded-lg transition-all text-left group border border-transparent hover:border-red-100/10 cursor-pointer",children:[s.jsx(ge.icon,{size:13,className:"text-gray-400 group-hover:text-red-650 transition-colors mt-0.5 shrink-0"}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-700 uppercase tracking-wider group-hover:text-red-650 transition-colors",children:ge.label}),s.jsx("span",{className:"text-[8.5px] text-gray-400 font-bold uppercase tracking-tight leading-none mt-0.5",children:ge.desc})]})]},ge.subTab))]})]}),s.jsx("div",{className:"pt-6 border-t border-gray-100 pb-8 mt-6",children:s.jsx("p",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest text-center",children:"CAMPUS EYE V2.5 • MOBILE PLUG"})})]})]})}),ze==="admin"&&gi&&s.jsxs("div",{className:"fixed inset-0 z-[100] bg-white overflow-y-auto",children:[s.jsxs("div",{className:"w-full mx-auto px-6 py-4 flex justify-between items-center border-b border-gray-100 mb-4 select-none",children:[s.jsx("div",{className:"flex items-center gap-1.5 font-black text-[#9B2C2C] text-[10px] tracking-wider uppercase",title:"Editorial Desk Hub",children:s.jsx(pl,{size:16})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>{wr(!0),je("account")},className:"p-2 border border-gray-200 hover:border-black text-gray-650 hover:text-black rounded-lg cursor-pointer transition-colors",title:"Go to Account Controls",children:s.jsx(Nk,{size:15,className:"shrink-0"})}),s.jsx("button",{onClick:()=>{je($n),window.scrollTo({top:0,behavior:"smooth"})},className:"p-2 bg-black hover:bg-neutral-900 text-white rounded-lg cursor-pointer transition-colors",title:"Exit and Return to Feed",children:s.jsx(nre,{size:15,className:"shrink-0"})})]})]}),s.jsx(fk,{initialTab:yn})]}),s.jsx(ar,{children:ie&&s.jsx("div",{onClick:()=>{xe(!1),window.onAuthPendingAction=void 0},className:"fixed inset-0 z-[3000] flex items-center justify-center p-4 bg-black/80 backdrop-blur-md overflow-y-auto cursor-pointer",children:s.jsx(Kt.div,{onClick:ge=>ge.stopPropagation(),initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:20},className:"w-full max-w-lg relative cursor-default my-auto",children:s.jsx(OV,{onAuthSuccess:async()=>{xe(!1);const ge=localStorage.getItem("pending_follow_uid"),we=localStorage.getItem("pending_follow_name")||"this peer";if(ge&&Ne.currentUser)try{const $e=Qt(it(pe,"follows"),Nr("followerId","==",Ne.currentUser.uid),Nr("followedId","==",ge));(await vn($e)).empty&&(await ur(it(pe,"follows"),{followerId:Ne.currentUser.uid,followedId:ge,createdAt:Bn()}),me.success(`Successfully followed ${we}!`),on(null))}catch($e){console.warn("Auto-follow pending action failed:",$e)}finally{localStorage.removeItem("pending_follow_uid"),localStorage.removeItem("pending_follow_name")}localStorage.getItem("just_signed_up")==="true"&&Nt(!0),je("home")},onClose:()=>{xe(!1),window.onAuthPendingAction=void 0},isAdmin:gi,onAdminClick:Vr})})})}),s.jsxs("div",{className:"mt-20 border-t border-gray-100",children:[s.jsx(jMe,{articles:o}),s.jsx(TMe,{setActiveTab:je,adverts:Pn,articles:o,isAdmin:gi})]}),s.jsx("button",{onClick:()=>{window.scrollTo({top:0,behavior:"smooth"})},className:"fixed bottom-3 left-4 z-40 w-8 h-8 bg-white/95 hover:bg-gray-50 rounded-full border border-gray-200 shadow-xs transition-all transform hover:scale-110 active:scale-95 flex items-center justify-center cursor-pointer outline-none select-none font-black",title:"Back to Top",children:s.jsx(Spe,{size:11})}),s.jsx(ar,{children:Be&&s.jsx(KMe,{page:Be,onClose:()=>J(null),openAuth:()=>xe(!0)})}),s.jsx(ar,{children:Ot&&s.jsx("div",{className:"fixed inset-0 z-[11000] flex items-center justify-center p-0 bg-black/95 backdrop-blur-2xl",children:s.jsxs(Kt.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.25},className:"w-screen h-screen flex flex-col overflow-hidden relative",children:[s.jsxs("div",{className:"absolute top-0 left-0 right-0 z-50 bg-black/85 backdrop-blur-md px-6 py-3.5 flex items-center justify-between border-b border-white/10 text-white select-none",children:[s.jsx("div",{className:"flex items-center gap-3.5 text-left min-w-0 flex-1 pr-6",children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs("h3",{className:"font-serif font-black text-xs sm:text-sm uppercase tracking-wider truncate text-gray-100 m-0",children:["LIVE BROADCAST: ",mn||"Campus Broadcast"]}),s.jsx("p",{className:"text-[9px] font-mono font-black uppercase text-gray-400 tracking-widest mt-0.5 hidden sm:block",children:"🔄 Recommendation: Landscape view is highly recommended for the best broadcast experience! Rotate your screen."}),s.jsx("p",{className:"text-[8px] font-mono font-black uppercase text-gray-400 tracking-widest mt-0.5 block sm:hidden",children:"🔄 RECOMMENDATION: ROTATE DEVICE FOR LANDSCAPE"})]})}),s.jsx("button",{onClick:()=>nn(null),className:"p-2 sm:p-2.5 rounded-full bg-white/10 hover:bg-gray-850 text-white border border-white/15 hover:rotate-90 transition-all duration-300 shadow-lg cursor-pointer flex items-center justify-center shrink-0",title:"Close Live Broadcast",children:s.jsx(er,{size:15,strokeWidth:3})})]}),s.jsx("div",{className:"pointer-events-none absolute top-18 left-1/2 -translate-x-1/2 z-40 bg-gray-850/90 border border-gray-700 text-white px-4 py-2 rounded-xl text-[8.5px] font-black uppercase tracking-widest shadow-lg flex items-center gap-2 animate-bounce md:hidden select-none",children:s.jsx("span",{children:"🔄 rotate device to landscape for full view"})}),s.jsx("div",{className:"flex-1 w-full h-full bg-black",children:s.jsx("iframe",{src:(()=>{const ge=Ot;if(ge)try{let we="";const Te=ge.trim();if(Te.includes("youtube.com/watch")){const $e=/[?&]v=([^&#]*)/,ut=Te.match($e);ut&&ut[1]&&(we=ut[1])}else if(Te.includes("youtu.be/")){const $e=Te.split("youtu.be/");$e[1]&&(we=$e[1].split(/[?#&]/)[0])}else if(Te.includes("youtube.com/live/")){const $e=Te.split("youtube.com/live/");$e[1]&&(we=$e[1].split(/[?#&]/)[0])}else if(Te.includes("/shorts/")){const $e=Te.split("/shorts/");$e[1]&&(we=$e[1].split(/[?#&]/)[0])}else if(Te.includes("youtube.com/embed/")){const $e=Te.split("youtube.com/embed/");$e[1]&&(we=$e[1].split(/[?#&]/)[0])}else if(Te.includes("youtube-nocookie.com/embed/")){const $e=Te.split("youtube-nocookie.com/embed/");$e[1]&&(we=$e[1].split(/[?#&]/)[0])}return we?`https://www.youtube.com/embed/${we}?autoplay=1&mute=0&rel=0`:Te}catch{return ge}})(),className:"w-full h-full border-0 bg-black pt-16 sm:pt-16",title:mn||"Live Stream Grid",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen",allowFullScreen:!0,referrerPolicy:"strict-origin-when-cross-origin"})})]})})}),s.jsx(ar,{children:G&&s.jsx(L2e,{article:G,onClose:()=>{const ge=new URL(window.location.href);ge.searchParams.delete("articles"),ge.searchParams.delete("id"),window.history.pushState({},"",ge.toString()),he(null),le(!1)},isAdmin:gi,allArticles:o,onArticleSelect:ge=>{const we=new URL(window.location.href),Te=ge.title.toLowerCase().replace(/[^a-z0-9]/g,"-");we.searchParams.set("articles",Te),we.searchParams.set("id",ge.id),window.history.pushState({articleId:ge.id},"",we.toString()),he(ge)},onCategorySelect:ge=>{je(ge),he(null),le(!1);const we=new URL(window.location.href);we.searchParams.delete("articles"),we.searchParams.delete("id"),we.searchParams.set("tab",ge),window.history.pushState({},"",we.toString()),window.scrollTo({top:0,behavior:"auto"})}})}),s.jsx(ar,{children:ae&&s.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-md z-[5000] flex items-center justify-center p-4",children:s.jsxs(Kt.div,{initial:{scale:.95,opacity:0,y:30},animate:{scale:1,opacity:1,y:0},exit:{scale:.95,opacity:0,y:30},transition:{type:"spring",damping:25,stiffness:350},className:"bg-white rounded-3xl w-full max-w-6xl md:max-w-7xl max-h-[92vh] flex flex-col shadow-2xl overflow-hidden border border-gray-150",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100 bg-gray-50/50",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-emerald-50 text-emerald-600 flex items-center justify-center shrink-0",children:s.jsx(d2,{size:18})}),s.jsxs("div",{className:"text-left",children:[s.jsx("h3",{className:"text-xs font-black text-gray-950 uppercase tracking-tight",children:"Campus Audio Newsroom & Podcasts"}),s.jsx("p",{className:"text-[8px] text-gray-400 font-bold uppercase tracking-wider",children:"Independent Campus Dispatches • Wide Broadcast Hub"})]})]}),s.jsx("button",{onClick:()=>Fe(!1),className:"p-1.5 bg-gray-100 hover:bg-gray-200 text-gray-600 rounded-full transition-colors cursor-pointer flex items-center justify-center",title:"Close Podcasts",children:s.jsx(er,{size:13})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4 bg-white text-left",children:s.jsx(PV,{})})]})})}),s.jsx(PMe,{}),pt&&s.jsx(J3,{podcast:pt,onClose:()=>Ue(null)}),s.jsx(ar,{children:Fn&&s.jsxs("div",{className:"fixed inset-0 z-[3000] flex items-center justify-center p-2 sm:p-4",children:[s.jsx(Kt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>Ft(!1),className:"fixed inset-0 bg-black/60 backdrop-blur-xl"}),s.jsxs(Kt.div,{initial:{scale:.95,y:15,opacity:0},animate:{scale:1,y:0,opacity:1},exit:{scale:.95,y:15,opacity:0},transition:{type:"spring",damping:30,stiffness:350},className:"relative w-full h-[98%] max-w-7xl bg-white rounded-[2.5rem] shadow-2xl flex flex-col overflow-hidden border border-gray-150 z-10",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100 bg-gray-50/50 shrink-0 text-left",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400 shrink-0"}),s.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-gray-450 font-mono",children:"CAMPUS PASSES & EVENTS"})]}),s.jsx("button",{onClick:()=>Ft(!1),className:"p-2 rounded-full hover:bg-gray-150 text-gray-500 hover:text-black transition-all cursor-pointer border border-transparent hover:border-gray-200",title:"Close Ticket Store",children:s.jsx(er,{size:18})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 bg-white",children:s.jsx(CMe,{})})]})]})}),s.jsx(ar,{children:(Dt||It||Ze)&&s.jsx("div",{className:"fixed inset-0 z-[11000] flex items-center justify-center p-4 bg-black/85 backdrop-blur-md",children:s.jsxs(Kt.div,{initial:{scale:.95,opacity:0,y:15},animate:{scale:1,y:0,opacity:1},exit:{scale:.95,y:15,opacity:0},className:"bg-white rounded-[2.5rem] border border-gray-150 p-8 w-full max-w-md shadow-2xl relative text-center",children:[s.jsx("button",{onClick:()=>{Ht(null),Wt(null);const ge=new URL(window.location.href);ge.searchParams.delete("scan"),window.history.pushState({},"",ge.toString())},className:"absolute top-6 right-6 p-2 bg-gray-50 text-gray-900 hover:bg-gray-100 rounded-full transition-all cursor-pointer border border-transparent hover:border-gray-200 flex items-center justify-center",title:"Close Scanner",children:s.jsx(er,{size:15,className:"stroke-[2.5]"})}),s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("div",{className:"w-12 h-12 bg-red-50 text-red-600 rounded-full flex items-center justify-center mb-4",children:s.jsx(No,{size:24})}),s.jsx("h3",{className:"text-xs font-black text-red-650 uppercase tracking-widest font-mono mb-1",children:"Gate Check-In Protocol"}),s.jsx("h2",{className:"text-xl font-serif font-black text-gray-950 tracking-tight leading-tight mb-5 uppercase",children:"Verification Console"}),It?s.jsxs("div",{className:"py-8 flex flex-col items-center gap-3",children:[s.jsx(Pr,{className:"animate-spin text-red-600",size:24}),s.jsx("span",{className:"text-[10px] uppercase font-black text-gray-400",children:"Loading Pass Records..."})]}):Ze?s.jsxs("div",{className:"w-full space-y-6",children:[s.jsxs("div",{className:"bg-gray-50 p-5 rounded-3xl border border-gray-100 text-left space-y-3",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-[8px] font-black text-gray-400 uppercase tracking-wider block",children:"Event Pass Name"}),s.jsx("span",{className:"text-sm font-black text-gray-950 uppercase tracking-tight",children:Ze.ticketTitle})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-[8px] font-black text-gray-400 uppercase tracking-wider block",children:"Attendee"}),s.jsx("span",{className:"text-xs font-bold text-gray-800",children:Ze.userName})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-[8px] font-black text-gray-400 uppercase tracking-wider block",children:"Order ID"}),s.jsxs("span",{className:"text-xs font-mono font-black text-gray-800 uppercase",children:["#",Ze.id.slice(-6).toUpperCase()]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-1.5 border-t border-gray-100/70",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-[8px] font-black text-gray-400 uppercase tracking-wider block",children:"Guest Count"}),s.jsxs("span",{className:"text-xs font-bold text-gray-800",children:[Ze.quantity," Pax"]})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-[8px] font-black text-gray-400 uppercase tracking-wider block",children:"Admission Status"}),Ze.taken||Ze.used?s.jsx("span",{className:"text-[9px] font-black text-green-600 uppercase bg-green-50 border border-green-200 px-1.5 py-0.5 rounded inline-block mt-0.5",children:"✔️ Used / Ticked"}):s.jsx("span",{className:"text-[9px] font-black text-red-655 uppercase bg-red-50 border border-red-200 px-1.5 py-0.5 rounded inline-block mt-0.5",children:"Active / Unused"})]})]})]}),gi?s.jsxs("div",{className:"bg-red-50/50 p-5 rounded-3xl border border-red-100/50 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3 justify-center select-none",children:[s.jsx("input",{type:"checkbox",id:"scan-gate-taken",checked:!!Ze.taken||!!Ze.used,onChange:async()=>{const ge=!(Ze.taken||Ze.used);try{await Hn(ot(pe,"purchases",Ze.id),{taken:ge,used:ge}),Wt(we=>we?{...we,taken:ge,used:ge}:null),ge?(await ur(it(pe,"notifications"),{userId:Ze.userId,title:`🎟️ Entrance Gate Ticked: ${Ze.ticketTitle}`,message:`Your entry pass (ID #${Ze.id.slice(-6).toUpperCase()}) has been officially scanned and ticked as used at the gate. Enjoy the event!`,used:!1,createdAt:new Date,type:"entrance_checkin",code:Ze.id}),me.success("Check-in complete! Pass marked as used.",{icon:"🎟️"})):me.success("Gate admission check reverted to active.")}catch(we){console.error("Gate scanning error update:",we),me.error("Fail to update: "+we.message)}},className:"w-5 h-5 rounded border-gray-300 text-red-650 focus:ring-red-550 cursor-pointer accent-red-650"}),s.jsx("label",{htmlFor:"scan-gate-taken",className:"text-xs font-black uppercase tracking-wider text-gray-950 cursor-pointer select-none",children:Ze.taken||Ze.used?"Used (Ticket Ticked)":"Mark Ticket Used"})]}),s.jsx("p",{className:"text-[9px] font-bold text-gray-400 uppercase leading-normal",children:"Ticking this checkbox invalidates this pass QR code for future entries, and dispatches a notification to the user's inbox in real-time."})]}):s.jsxs("div",{className:"bg-green-50/50 p-5 rounded-3xl border border-green-100/70 space-y-3",children:[s.jsx("span",{className:"text-[11px] font-black uppercase tracking-wider text-green-700 flex items-center justify-center gap-1.5 select-none font-mono",children:"🎉 Secure Entry Pass Verified"}),s.jsxs("div",{className:"space-y-1.5 text-center",children:[s.jsx("p",{className:"text-[10px] text-gray-650 font-bold uppercase leading-normal",children:Ze.taken||Ze.used?s.jsx("span",{className:"text-green-650 font-black",children:"✔️ Ticked & Used. You are checked in."}):s.jsx("span",{className:"text-gray-500 font-extrabold",children:"Active and ready. Please show this to the gate attendant."})}),s.jsx("p",{className:"text-[9px] text-gray-400 font-bold uppercase leading-none mt-1 font-mono",children:"Only administrators can check-in or tick this pass."})]})]}),s.jsx("button",{onClick:()=>{Ht(null),Wt(null);const ge=new URL(window.location.href);ge.searchParams.delete("scan"),window.history.pushState({},"",ge.toString())},className:"w-full py-4.5 bg-gray-950 text-white hover:bg-red-650 rounded-2xl text-[10px] font-black uppercase tracking-widest transition-all shadow-md cursor-pointer outline-none select-none",children:"Process Completed"})]}):s.jsx("div",{className:"py-6 space-y-4",children:s.jsxs("span",{className:"text-xs font-bold text-gray-500",children:["Retrieving pass ticket ID #",Dt==null?void 0:Dt.slice(-6).toUpperCase(),"..."]})})]})]})})}),s.jsx(v9e,{isOpen:Kn,onClose:()=>un(!1),onScanSuccess:ge=>{Ht(ge)}}),s.jsx(ar,{children:Tn&&s.jsx("div",{className:"fixed inset-0 z-[100000] flex items-center justify-center p-4 bg-black/75 backdrop-blur-md",children:s.jsxs(Kt.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"bg-white border border-gray-150 rounded-[2.5rem] p-8 shadow-2xl max-w-md w-full relative overflow-hidden",children:[s.jsx("div",{className:"absolute top-0 left-0 w-full h-[3px] bg-red-650"}),s.jsxs("div",{className:"space-y-1.5 text-center mb-6",children:[s.jsx("div",{className:"w-10 h-10 bg-black text-white rounded-2xl flex items-center justify-center font-black text-sm mx-auto shadow-sm tracking-tighter mt-2",children:"★"}),s.jsx("h3",{className:"font-serif font-black text-lg tracking-tight text-neutral-900 uppercase",children:"Welcome! Tune Your Dispatch"}),s.jsx("p",{className:"text-[10px] text-neutral-500 font-semibold tracking-normal leading-relaxed max-w-xs mx-auto",children:"Pick up to 3 core categories below so we can curate your feed and learn your preferences live!"})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:[{id:"news",label:"📰 News",category:"News"},{id:"sports",label:"⚽ Sports",category:"Sports"},{id:"music",label:"🎵 Music",category:"Music"},{id:"entertainment",label:"🎭 Entertainment",category:"Entertainment"},{id:"innovation",label:"💡 Innovation",category:"Innovation"},{id:"culture",label:"🏛️ Culture",category:"Culture"},{id:"business",label:"💼 Business",category:"Business"}].map(ge=>{const we=Ae.includes(ge.category);return s.jsxs("button",{onClick:()=>{if(we)tn(Te=>Te.filter($e=>$e!==ge.category));else{if(Ae.length>=3){me.error("Please pick up to just 3 interests!",{id:"interest-limit"});return}tn(Te=>[...Te,ge.category])}},className:`p-3 rounded-2xl border text-left font-sans text-xs font-semibold transition-all duration-200 cursor-pointer flex flex-col justify-between h-[4.5rem] select-none ${we?"border-black bg-black text-white shadow-sm scale-[1.02]":"border-gray-205 bg-white text-gray-700 hover:border-gray-350 hover:bg-gray-50/50"}`,children:[s.jsx("span",{className:"text-base leading-none",children:ge.label.split(" ")[0]}),s.jsx("span",{className:"font-sans uppercase text-[8.5px] font-black tracking-wider leading-none",children:ge.label.split(" ").slice(1).join(" ")})]},ge.id)})}),s.jsxs("div",{className:"pt-6 text-center",children:[s.jsxs("span",{className:"text-[8.5px] font-sans font-black text-gray-400 uppercase tracking-widest block mb-3.5",children:[Ae.length," of 3 Selected"]}),s.jsx("button",{onClick:async()=>{if(Ae.length===0){me.error("Please select at least 1 interest to customize your feed!");return}try{const ge=localStorage.getItem("campus_eye_personalization_v1"),we=ge?JSON.parse(ge):{categories:{}};if(we.interests=[...Ae],we.categories||(we.categories={}),Ae.forEach(Te=>{we.categories[Te]=(we.categories[Te]||0)+150}),localStorage.setItem("campus_eye_personalization_v1",JSON.stringify(we)),localStorage.removeItem("just_signed_up"),Ne.currentUser){const Te=ot(pe,"users",Ne.currentUser.uid);await Hr(Te,{interests:[...Ae]},{merge:!0})}cn(!0),setTimeout(()=>{cn(!1),Nt(!1),me.success("Newsroom personalized live! Welcome.")},1200)}catch{Nt(!1)}},className:"w-full py-4 bg-red-650 hover:bg-black transition-all cursor-pointer font-black text-xs uppercase tracking-widest text-white rounded-xl",children:yt?"BUILDING YOUR FEED...":"START EXPLORING"})]})]})})}),s.jsx(GMe,{isOpen:!!xr,onClose:()=>Ve(null),userId:xr,currentUserId:(Mi=Ne.currentUser)==null?void 0:Mi.uid}),s.jsx(qMe,{}),s.jsx(WMe,{}),s.jsx(OMe,{})]})}rne.createRoot(document.getElementById("root")).render(s.jsx(j.StrictMode,{children:s.jsx(ZV,{children:s.jsx(N9e,{})})}));