PageSourceSearch

https://ama-d14.web.app/chunk-AUKIETH2.js

js ama-d14.web.app collected 2026-10-03 12:16:21 UTC 5,530 bytes, 1 lines download raw bytes

1import{l as w}from"./chunk-GL4YR33V.js";import{b as P}from"./chunk-JXLBD2WL.js";import{d as b}from"./chunk-NKL6YEJH.js";import{V as S,_ as l,g,p as m}from"./chunk-4IAM5SFH.js";import{j as a}from"./chunk-5TH5JFSU.js";var j=(()=>{let o=class o{constructor(e,s,i){this.supabaseService=e,this.toastr=s,this.router=i,this.authSubject=new g(this.getStoredSession()),this.auth$=this.authSubject.asObservable(),this.profileSubject=new g(this.getStoredProfile()),this.profile$=this.profileSubject.asObservable(),this.role$=this.profile$.pipe(m(r=>r?.role??null)),this.isAdmin=!1,this.isMember=!1,this.isProfileBeingFetched=!1,this.skipProfileFetch=!1,this.isNewLogin=!1,this.isResettingPassword=!1,this.supabaseService.supabase.auth.onAuthStateChange((r,t)=>{if(r==="PASSWORD_RECOVERY"){this.isResettingPassword=!0,console.log("THIS SHOULD BE SKIPPING EVERYTHINGGGGGGG:",r);return}this.isResettingPassword||(this.authSubject.next(t),this.storeSession(t),t&&!this.skipProfileFetch&&this.getProfile()),this.skipProfileFetch=!1})}storeSession(e){e?localStorage.setItem("auth_session",JSON.stringify(e)):localStorage.removeItem("auth_session")}getStoredSession(){let e=localStorage.getItem("auth_session");return e?JSON.parse(e):null}storeProfile(e){e?localStorage.setItem("user_profile",JSON.stringify(e)):localStorage.removeItem("user_profile")}getStoredProfile(){let e=localStorage.getItem("user_profile");return e?JSON.parse(e):null}get session(){return this.authSubject.value}getProfile(){return a(this,null,function*(){if(this.isResettingPassword)return null;if(!this.session)throw new Error("Cannot fetch profile without session");let e=this.getStoredProfile();if(e)return this.profileSubject.next(e),this.isAdmin=e?.role==="admin",this.isMember=e?.member_type==="Regular",e;if(window.location.href.includes("type=recovery")||this.isProfileBeingFetched)return null;this.isProfileBeingFetched=!0;try{let{data:i,error:r}=yield this.supabaseService.supabase.from("profiles").select("*").eq("id",this.session.user.id).single();if(r)if(r.code==="PGRST116"){let{user:c}=this.session;if(c&&c.app_metadata?.provider==="google"){let{id:f,email:p}=c,{error:d}=yield this.supabaseService.supabase.from("profiles").insert([{id:f,email:p}]);if(d)return console.error("Error inserting new profile:",d.message),this.toastr.error("Error creating user profile. Please try again.","Error"),null;let h={id:f,email:p};return this.profileSubject.next(h),this.storeProfile(h),h}else return console.warn("No profile found, and user is not logged in with Google."),null}else return console.error("Error fetching profile:",r.message),this.toastr.error("Error fetching user profile. Please try again.","Error"),null;let t=i;this.profileSubject.next(t),this.storeProfile(t),this.isAdmin=t?.role==="admin",this.isMember=t?.member_type==="Regular";let n=window.location.pathname.startsWith("/secure/checkout/complete");return t?.member_type===null&&!this.isResettingPassword&&!this.isAdmin&&!n?(this.router.navigate(["/secure/membership"]),null):t}catch(i){return console.error("Unexpected error fetching profile:",i),this.toastr.error("An unexpected error occurred. Please try again.","Error"),null}finally{this.isProfileBeingFetched=!1}})}logout(){return a(this,null,function*(){let{error:e}=yield this.supabaseService.supabase.auth.signOut();e?(console.error("Error during logout:",e),this.toastr.error("Error logging out. Please try again.","Logout Error")):(localStorage.removeItem("auth_session"),localStorage.removeItem("user_profile"),this.toastr.success("You have been logged out.","Goodbye"))})}login(e,s){return a(this,null,function*(){this.isNewLogin=!0;let{data:i,error:r}=yield this.supabaseService.supabase.auth.signInWithPassword({email:e,password:s});if(r)throw console.error("Error logging in:",r.message),this.toastr.error("Login failed. Please check your credentials.","Login Error"),r;this.toastr.success("Login successful!","Welcome")})}getAndClearNewLoginFlag(){let e=this.isNewLogin;return this.isNewLogin=!1,e}register(e,s){return a(this,null,function*(){this.skipProfileFetch=!0;let{data:i,error:r}=yield this.supabaseService.supabase.auth.signUp({email:e,password:s});return r?(console.error("Error during registration:",r),this.toastr.error(`Registration failed: ${r.message}`,"Error"),{user:null,error:r}):(this.toastr.success("Registration successful! Please log in.","Welcome"),{user:i,error:null})})}googleSignIn(){return a(this,null,function*(){let{data:e,error:s}=yield this.supabaseService.supabase.auth.signInWithOAuth({provider:"google"});s?(console.error("Error logging in with Google:",s.message),this.toastr.error("Google sign-in failed. Please try again.","Error")):this.toastr.success("Login successful with Google!","Welcome")})}getChairmanInformation(e){return a(this,null,function*(){let{data:s,error:i}=yield this.supabaseService.supabase.from("divisions").select("id").eq("chairman_id",e).single();if(i)return console.error("Error fetching chairman information:",i),this.toastr.error("Error fetching chairman information.","Chairman Error"),null;let r=s?.id;if(r){let{data:t,error:n}=yield this.supabaseService.supabase.from("rules").select("id").eq("division_id",r).single();return n?(console.error("Error fetching rules information:",n),this.toastr.error("Error fetching rules information.","Rules Error"),null):{divisionID:r,rulesID:t?.id}}return null})}};o.\u0275fac=function(s){return new(s||o)(l(P),l(w),l(b))}
1,o.\u0275prov=S({token:o,factory:o.\u0275fac,providedIn:"root"});let u=o;return u})();export{j as a};

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.