import { Resend } from "resend";

let cachedClient: Resend | null = null;

export function isResendConfigured() {
  return Boolean(process.env.RESEND_API_KEY && process.env.RESEND_FROM_EMAIL);
}

export function getResendClient() {
  if (!cachedClient) {
    cachedClient = new Resend(process.env.RESEND_API_KEY);
  }
  return cachedClient;
}

export function getFromAddress() {
  return process.env.RESEND_FROM_EMAIL || "";
}

export function getReplyToAddress() {
  return process.env.RESEND_REPLY_TO_EMAIL || undefined;
}
