export interface AuthUser {
  name: string;
  email: string;
}

export interface AuthResponse {
  user: AuthUser;
  token: string;
}

export interface OnboardingData {
  plan: string;
  watchlistItems: string[];
  familyInvites: string[];
}

function delay(ms: number): Promise<void> {
  return new Promise((resolve) => setTimeout(resolve, ms));
}

export async function login(
  email: string,
  password: string,
  _rememberMe: boolean,
): Promise<AuthResponse> {
  await delay(800);
  if (!email || !password) throw new Error("Invalid credentials");
  return { user: { name: "Test User", email }, token: "stub-token" };
}

export async function signup(
  name: string,
  email: string,
  password: string,
): Promise<AuthResponse> {
  await delay(800);
  if (!name || !email || !password)
    throw new Error("All fields are required");
  return { user: { name, email }, token: "stub-token" };
}

export async function forgotPassword(email: string): Promise<void> {
  await delay(800);
  if (!email) throw new Error("Email is required");
}

export async function resetPassword(
  token: string,
  password: string,
): Promise<void> {
  await delay(800);
  if (!token || !password) throw new Error("Invalid request");
}

export async function submitOnboarding(
  _data: OnboardingData,
): Promise<void> {
  await delay(800);
}
