#!/usr/bin/env bash
# Wraps the real captured output of test/e2e.sh and test/checks.sh into out/terminal.html,
# a plain page for screenshots. The tool itself has no visual surface: this is its terminal output.
set -eu
cd "$(dirname "$0")/.."
esc() { sed -e 's/&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g' "$1"; }
pane() { printf '<section><p class="cmd">$ %s</p><pre class="%s">' "$1" "${3:-}"; esc "$2"; printf '</pre></section>\n'; }
{
  cat <<'X'
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<title>bedtime</title><style>
:root { --cream: #FCF0DD; --ink: #1A1A1A; --soft: #5B5B5B; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 14px/1.5 ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace; }
main { max-width: 1120px; margin: 0 auto; padding: 32px 16px 48px; }
section { margin: 0 0 32px; }
.cmd { margin: 0 0 4px; color: var(--soft); }
pre { margin: 0; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
pre.table { white-space: pre; overflow-wrap: normal; overflow-x: auto; }
@media (max-width: 600px) { body { font-size: 12px; } main { padding-top: 20px; } }
</style></head><body><main>
X
  pane "BEDTIME_LEDGER=ledger.tsv bedtime 23:00 --clock-start 2026-10-13T22:58:00 --clock-speed 60 --then 'date +%s > done'" out/e2e-transcript.txt
  pane "bedtime log" out/e2e-log.txt table
  pane "bedtime 23:00 --dry-run --clock-start 2026-10-13T21:00:00" out/dry-run.txt
  pane "bedtime 23:00 --dry-run --clock-start 2026-10-13T23:01:00" out/restart-2-dry-run.txt
  pane "bedtime --help" out/help.txt
  printf '</main></body></html>\n'
} > out/terminal.html
