export type EmailRecipient = {
  email: string;
  name?: string;
};

export type EmailReplyTo = {
  email: string;
  name?: string;
};

export type WelcomeEmailRecipient = EmailRecipient;
export type PasswordSetupEmailRecipient = EmailRecipient;

/**
 * A provider-neutral transactional email request for future feature modules.
 * It supports either inline content or a template configured in Brevo.
 */
export type TransactionalEmailInput = {
  to: EmailRecipient[];
  subject?: string;
  htmlContent?: string;
  textContent?: string;
  templateId?: number;
  params?: Record<string, unknown>;
  replyTo?: EmailReplyTo;
  tags?: string[];
};

export type EmailSendResult =
  | {
      status: 'sent';
      messageId?: string;
      messageIds?: string[];
    }
  | {
      status: 'skipped';
      reason: 'email_disabled';
    }
  | {
      status: 'failed';
      reason: 'provider_error';
    };
