/**
 * Placeholder e-mail for customers without a known address (orders still require one):
 * `kunde-<10 random base36 chars>@logyou.de`. Mails to it land in the LogYou catch-all, never at a customer.
 */
export const RANDOM_EMAIL_DOMAIN = 'logyou.de'

export const randomLogyouEmail = (): string => {
  const alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789'
  let out = ''
  const bytes = new Uint8Array(10)
  if (typeof crypto !== 'undefined' && crypto.getRandomValues) crypto.getRandomValues(bytes)
  else for (let i = 0; i < bytes.length; i++) bytes[i] = Math.floor(Math.random() * 256)
  for (const b of bytes) out += alphabet[b % alphabet.length]
  return `kunde-${out}@${RANDOM_EMAIL_DOMAIN}`
}
