/** @format */

import type { SocialAuthService } from "./types";
import { googleAuthService, isGoogleAuthConfigured } from "./googleAuthService";
import {
  facebookAuthService,
  isFacebookAuthConfigured,
} from "./facebookAuthService";

export type { SocialAuthResult } from "./types";

const providers: Record<string, SocialAuthService> = {
  google: googleAuthService,
  facebook: facebookAuthService,
};

const providerAvailability: Record<string, boolean> = {
  google: isGoogleAuthConfigured,
  facebook: isFacebookAuthConfigured,
};

export function getAuthService(provider: string): SocialAuthService {
  const service = providers[provider];
  if (!service) {
    throw new Error(`No native auth service for provider: ${provider}`);
  }
  return service;
}

export function isAuthServiceConfigured(provider: string): boolean {
  return providerAvailability[provider] ?? false;
}
