import { publicApi } from './http'

export async function fetchEmailVerifyStatus() {
  const { data } = await publicApi.get('/email/verify-status')
  return data
}

export async function generateCaptcha() {
  const { data } = await publicApi.post('/generate_captcha', {})
  return data
}

export async function login(payload) {
  const { data } = await publicApi.post('/login', payload)
  return data
}

export async function passkeyLoginOptions(payload) {
  const { data } = await publicApi.post('/passkeys/login/options', payload)
  return data
}

export async function passkeyLoginVerify(payload) {
  const { data } = await publicApi.post('/passkeys/login/verify', payload)
  return data
}

export async function register(payload) {
  const { data } = await publicApi.post('/register', payload)
  return data
}

export async function resendVerifyEmail(payload) {
  const { data } = await publicApi.post('/resend-verify-email', payload)
  return data
}

export async function forgotPassword(payload) {
  const { data } = await publicApi.post('/forgot-password', payload)
  return data
}

export async function confirmPasswordReset(payload) {
  const { data } = await publicApi.post('/reset-password-confirm', payload)
  return data
}

export async function fetchSocialConfig() {
  const { data } = await publicApi.get('/auth/social/config')
  return data
}

export async function socialLoginUrl(payload) {
  const { data } = await publicApi.post('/auth/social/login-url', payload || {})
  return data
}

export async function socialPoll(payload) {
  const { data } = await publicApi.post('/auth/social/poll', payload || {})
  return data
}

export async function socialCallback(payload) {
  const { data } = await publicApi.post('/auth/social/callback', payload || {})
  return data
}
