// The probe's alert as quarry's email card (internal/markup/emaildoc.go is
// the original; this is the same design, hand-carried, because the probe
// runs on Cloudflare and must not depend on the forge it watches). An
// application email: the Q logo and the QUARRY wordmark, which are images
// served by the forge. The forge may be the thing that is down, so the
// images may not load; their alt text says the same words.
const HOME = "https://zeitforge.app";
const FONT = "'IBM Plex Sans',-apple-system,'Segoe UI',Helvetica,Arial,sans-serif";
const MONO = "'IBM Plex Mono',ui-monospace,Menlo,Consolas,monospace";
export function esc(s) {
return String(s).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
}
// rows: [label, value] pairs shown as a small table; open: {label, url}.
export function probeCard({ subject, context, rows, open, why }) {
const facts = rows
.map(
([k, v], i) =>
`<tr><td class="q-muted" style="padding:5px 16px 5px 0;font-size:13px;color:#665c54;">${esc(k)}</td>` +
`<td style="padding:5px 0;font-family:${MONO};font-size:13px;">${esc(v)}</td></tr>`,
)
.join("");
return `<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light dark">
<meta name="supported-color-schemes" content="light dark">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;600;700&family=IBM+Plex+Mono&display=swap">
<title>${esc(subject)}</title>
<style>
@media (prefers-color-scheme: dark) {
.q-page { background:#141617 !important; }
.q-card { background:#1d2021 !important; border-color:#504945 !important; }
.q-text, .q-text td, .q-text p { color:#f0ece4 !important; }
.q-muted { color:#bdb6ab !important; }
.q-rule { border-color:#504945 !important; }
.q-a { color:#d99058 !important; }
.q-btn { background:#d99058 !important; color:#1d2021 !important; }
}
</style>
</head>
<body style="margin:0;padding:0;">
<table role="presentation" class="q-page" width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f4;padding:24px 12px;">
<tr><td align="center">
<table role="presentation" class="q-card" width="100%" cellpadding="0" cellspacing="0" style="max-width:600px;background:#fffcf5;border:1px solid #d5c4a1;border-radius:10px;">
<tr><td class="q-rule" style="padding:18px 24px 14px;border-bottom:1px solid #e6dcc0;font-family:${FONT};">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0"><tr>
<td style="line-height:0;font-size:0;"><img src="${HOME}/lockup.png" alt="QUARRY" width="92" height="28" style="display:block;width:92px;height:28px;border:0;border-radius:6px;font-size:14px;font-weight:700;color:#282828;"></td>
<td align="right" class="q-muted" style="font-size:12px;color:#665c54;">probe</td>
</tr></table>
</td></tr>
<tr><td style="padding:18px 24px 4px;font-family:${FONT};">
<div class="q-text" style="font-size:15px;color:#282828;">${context}</div>
</td></tr>
<tr><td class="q-text" style="padding:12px 24px 8px;font-family:${FONT};font-size:15px;line-height:1.55;color:#282828;">
<table role="presentation" cellpadding="0" cellspacing="0" style="margin:0 0 12px;">${facts}</table>
</td></tr>
<tr><td style="padding:6px 24px 22px;font-family:${FONT};">
<a class="q-btn" href="${esc(open.url)}" style="display:inline-block;background:#a04412;color:#fffcf5;text-decoration:none;font-weight:600;font-size:14px;padding:9px 16px;border-radius:6px;">${esc(open.label)}</a>
</td></tr>
<tr><td class="q-rule q-muted" style="padding:14px 24px 18px;border-top:1px solid #e6dcc0;font-family:${FONT};font-size:12px;line-height:1.5;color:#665c54;">
${esc(why)}
<table role="presentation" cellpadding="0" cellspacing="0" style="margin-top:8px;"><tr>
<td style="vertical-align:middle;padding-right:6px;line-height:0;font-size:0;"><img src="${HOME}/lockup-sm.png" alt="QUARRY" width="59" height="18" style="display:block;width:59px;height:18px;border:0;border-radius:4px;font-size:11px;font-weight:700;color:#665c54;"></td>
<td class="q-muted" style="vertical-align:middle;font-size:12px;line-height:1.5;color:#665c54;">· <a class="q-a" href="${HOME}" style="color:#a04412;">zeitforge.app</a></td>
</tr></table>
</td></tr>
</table>
</td></tr>
</table>
</body>
</html>
`;
}