import { invoke } from "@tauri-apps/api/core";

export interface AccountInfo {
  email: string;
  name: string | null;
  picture: string | null;
  subscription_status: string | null;
}

export async function startOAuth(): Promise<string> {
  return invoke<string>("start_oauth");
}

export async function refreshAuthToken(): Promise<AccountInfo> {
  return invoke<AccountInfo>("refresh_auth_token");
}

export async function getAccountInfo(): Promise<AccountInfo | null> {
  return invoke<AccountInfo | null>("get_account_info");
}

export async function checkSubscriptionStatus(): Promise<AccountInfo | null> {
  return invoke<AccountInfo | null>("check_subscription_status");
}

export async function logoutAccount(): Promise<void> {
  return invoke<void>("logout");
}

export type TokenStoreMode = "keychain" | "file";

export async function getTokenStoreMode(): Promise<TokenStoreMode | null> {
  return invoke<TokenStoreMode | null>("get_token_store_mode");
}
