import './db_Du3AmLCY.mjs';

const __vite_import_meta_env__ = {"ASSETS_PREFIX": undefined, "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SITE": undefined, "SSR": true};
const RESEND_API_KEY = process.env.RESEND_API_KEY || Object.assign(__vite_import_meta_env__, { OS: process.env.OS })?.RESEND_API_KEY || "";
const BASE_URL = process.env.SITE_URL || Object.assign(__vite_import_meta_env__, { OS: process.env.OS })?.SITE_URL || "https://sneakerpicks.nl";
const FROM_EMAIL = "SneakerPicks <alerts@sneakerpicks.nl>";
async function sendEmail(to, subject, html) {
  if (!RESEND_API_KEY) {
    console.error("RESEND_API_KEY not set");
    return { error: { message: "RESEND_API_KEY not configured" } };
  }
  const res = await fetch("https://api.resend.com/emails", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${RESEND_API_KEY}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({ from: FROM_EMAIL, to: [to], subject, html })
  });
  return res.json();
}
async function sendVerificationEmail(email, token) {
  const verifyUrl = `${BASE_URL}/api/auth/verify?token=${token}`;
  const html = emailLayout("Bevestig je email", `
    <h2 style="color:#fff;margin:0 0 16px">Welkom bij SneakerPicks! 👟</h2>
    <p style="color:#aaa;margin:0 0 24px">Klik op de knop hieronder om je email te bevestigen en je watchlist te activeren.</p>
    ${buttonHtml(verifyUrl, "Email bevestigen")}
    <p style="color:#666;font-size:12px;margin-top:24px">Of kopieer deze link: ${verifyUrl}</p>
  `);
  return sendEmail(email, "Bevestig je email - SneakerPicks", html);
}
async function sendMagicLinkEmail(email, token) {
  const loginUrl = `${BASE_URL}/api/auth/verify?token=${token}&login=1`;
  const html = emailLayout("Inloggen bij SneakerPicks", `
    <h2 style="color:#fff;margin:0 0 16px">Log in bij SneakerPicks 🔑</h2>
    <p style="color:#aaa;margin:0 0 24px">Klik op de knop hieronder om in te loggen. Deze link is 1 uur geldig.</p>
    ${buttonHtml(loginUrl, "Inloggen")}
    <p style="color:#666;font-size:12px;margin-top:24px">Of kopieer deze link: ${loginUrl}</p>
  `);
  return sendEmail(email, "Inloglink - SneakerPicks", html);
}
function buttonHtml(url, text) {
  return `<a href="${url}" style="display:inline-block;background:#00FF6A;color:#000;padding:12px 32px;border-radius:12px;text-decoration:none;font-weight:bold;font-size:16px">${text}</a>`;
}
function emailLayout(title, body, userId) {
  const unsubLink = "";
  return `<!DOCTYPE html><html><head><meta charset="utf-8"></head>
<body style="margin:0;padding:0;background:#0a0a0a;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif">
  <div style="max-width:560px;margin:0 auto;padding:32px 16px">
    <div style="text-align:center;margin-bottom:24px">
      <span style="font-size:24px;font-weight:900;color:#fff">Sneaker</span><span style="font-size:24px;font-weight:900;color:#00FF6A">Picks</span>
    </div>
    <div style="background:#141414;border-radius:16px;padding:24px;border:1px solid #222">
      ${body}
    </div>
    ${unsubLink}
    <p style="text-align:center;color:#444;font-size:11px;margin-top:16px">© ${(/* @__PURE__ */ new Date()).getFullYear()} SneakerPicks.nl</p>
  </div>
</body></html>`;
}

export { sendVerificationEmail as a, sendMagicLinkEmail as s };
