import { env, isProductionRuntime } from "@/server/env";
import { ProviderConfigurationError } from "@/server/errors";

export type ProviderKind = "odds" | "payment" | "kyc";

export function assertProviderAllowed(provider: string, kind: ProviderKind) {
  if (provider === "local" && isProductionRuntime(env())) {
    throw new ProviderConfigurationError(
      `${kind} provider "local" is not allowed in production. Configure a real provider adapter.`
    );
  }
}

export function requireProviderEndpoint(kind: ProviderKind, baseUrl?: string, apiKey?: string) {
  if (!baseUrl || !apiKey) {
    throw new ProviderConfigurationError(`${kind} provider is missing base URL or API key.`);
  }
}
