PageSourceSearch

https://codmunity.gg/assets/auth-CnBIVdqN.js

js codmunity.gg collected 2026-09-24 11:58:56 UTC 5,181 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index.esm-BLcRfeZO.js","assets/index.esm-8v5vx5i8.js"])))=>i.map(i=>d[i]);
2import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-CwJFpaho.js";import{t as n}from"./jsx-runtime-NZYk81nU.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{Ia as i,ca as a,sa as o}from"./index-tjhSeuZg.js";var s=e(t(),1),c=class{sink;generation=0;disposed=!1;currentUid=null;constructor(e){this.sink=e}invalidate(){return this.generation+=1,this.generation}isCurrent(e,t){return!(this.disposed||e!==this.generation||t!==void 0&&this.currentUid!==t)}handleUser(e,t){if(this.disposed)return Promise.resolve();let n=this.invalidate(),r=e?.uid??null,i=this.currentUid!==r;return this.currentUid=r,i&&(this.sink.dropUserCaches(),this.sink.setSession(null)),this.sink.setTokenError(null),e?(this.sink.setLoading(!0),t().then(t=>{this.isCurrent(n,e.uid)&&(this.sink.setSession({uid:e.uid,token:t,email:e.email??null}),this.sink.setLoading(!1))},t=>{this.isCurrent(n,e.uid)&&(this.sink.setSession(null),this.sink.setTokenError(t instanceof Error&&t.message?t.message:`Your session token could not be refreshed. Please sign in again.`),this.sink.setLoading(!1))})):(this.sink.setSession(null),this.sink.setLoading(!1),Promise.resolve())}signOut(){this.disposed||(this.invalidate(),this.currentUid=null,this.sink.setSession(null),this.sink.setTokenError(null),this.sink.setLoading(!1),this.sink.dropUserCaches())}dispose(){this.invalidate(),this.disposed=!0,this.currentUid=null}},l=n(),u=class extends Error{uid;email;constructor(e,t,n){super(`The account was created, but signing you in did not complete.`,{cause:n}),this.name=`SignUpTokenError`,this.uid=e,this.email=t}};async function d(e){let{GoogleAuthProvider:t,FacebookAuthProvider:n,TwitterAuthProvider:i,OAuthProvider:a}=await r(async()=>{let{GoogleAuthProvider:e,FacebookAuthProvider:t,TwitterAuthProvider:n,OAuthProvider:r}=await import(`./index.esm-BLcRfeZO.js`);return{GoogleAuthProvider:e,FacebookAuthProvider:t,TwitterAuthProvider:n,OAuthProvider:r}},__vite__mapDeps([0,1]));switch(e){case`google.com`:return new t;case`facebook.com`:return new n;case`twitter.com`:return new i;case`apple.com`:return new a(`apple.com`)}}var f=(0,s.createContext)(null);function p({children:e}){let[t,n]=(0,s.useState)(null),[p,m]=(0,s.useState)(null),[h,g]=(0,s.useState)(null),[_,v]=(0,s.useState)(o),y=i(),b=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=new c({setSession:m,setTokenError:g,setLoading:v,dropUserCaches:()=>{for(let e of[`own-loadouts`,`own-tier-lists`,`creator-likes`,`comparator-account-presets`,`edit-loadout`,`user-sharing-style`,`own-meta`,`pro-loadouts-premium`])y.cancelQueries({queryKey:[e]}),y.removeQueries({queryKey:[e]});y.cancelQueries({queryKey:[`user`]}),y.removeQueries({queryKey:[`user`]}),y.cancelQueries({queryKey:[`mod-access`]}),y.removeQueries({queryKey:[`mod-access`]}),y.cancelQueries({queryKey:[`managed-loadouts`]}),y.removeQueries({queryKey:[`managed-loadouts`]})}});b.current=e;let t=!1,i=null;return(async()=>{let o=await a();if(t)return;if(!o){v(!1);return}let{onIdTokenChanged:s}=await r(async()=>{let{onIdTokenChanged:e}=await import(`./index.esm-BLcRfeZO.js`);return{onIdTokenChanged:e}},__vite__mapDeps([0,1]));t||(i=s(o,t=>{n(t),e.handleUser(t,()=>t.getIdToken())}))})(),()=>{t=!0,i?.(),e.dispose(),b.current=null}},[y]);let x=async()=>{let e=await a();if(!e)throw Error(`Firebase browser config is not available in this preview.`);return e},S=(0,s.useCallback)(async(e,t)=>{let[n,{signInWithEmailAndPassword:i}]=await Promise.all([x(),r(()=>import(`./index.esm-BLcRfeZO.js`),__vite__mapDeps([0,1]))]);await i(n,e,t)},[]),C=(0,s.useCallback)(async(e,t)=>{let[n,{createUserWithEmailAndPassword:i}]=await Promise.all([x(),r(()=>import(`./index.esm-BLcRfeZO.js`),__vite__mapDeps([0,1]))]),a=await i(n,e,t);try{let e=await a.user.getIdToken();return{uid:a.user.uid,token:e,email:a.user.email??null}}catch(e){throw new u(a.user.uid,a.user.email??null,e)}},[]),w=(0,s.useCallback)(async e=>{let[t,{sendPasswordResetEmail:n}]=await Promise.all([x(),r(()=>import(`./index.esm-BLcRfeZO.js`),__vite__mapDeps([0,1]))]);await n(t,e)},[]),T=(0,s.useCallback)(async e=>{let[t,n,{signInWithPopup:i,getAdditionalUserInfo:a,browserPopupRedirectResolver:o}]=await Promise.all([x(),d(e),r(()=>import(`./index.esm-BLcRfeZO.js`),__vite__mapDeps([0,1]))]),s=await i(t,n,o),c=await s.user.getIdToken();return{session:{uid:s.user.uid,token:c,email:s.user.email??null},email:s.user.email??``,displayName:s.user.displayName??null,isNewUser:!!a(s)?.isNewUser}},[]),E=(0,s.useCallback)(async()=>{let e=await a();if(b.current?.signOut(),n(null),e){let{signOut:t}=await r(async()=>{let{signOut:e}=await import(`./index.esm-BLcRfeZO.js`);return{signOut:e}},__vite__mapDeps([0,1]));await t(e)}},[]),D=(0,s.useMemo)(()=>
2({user:t,session:p,loading:_,configured:o,tokenError:h,signIn:S,signUp:C,resetPassword:w,signInWithProvider:T,logout:E}),[t,p,_,h,S,C,w,T,E]);return(0,l.jsx)(f.Provider,{value:D,children:e})}function m(){let e=(0,s.useContext)(f);if(!e)throw Error(`useAuth must be used inside AuthProvider`);return e}export{u as n,m as r,p as t};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.