#!/usr/bin/env bash
set -euo pipefail

BASE_URL="${TREY_SEAT_URL:-https://trey.marcusx.fun}"
DEST="${1:-$HOME/trey-field-desk}"
mkdir -p "$DEST/build"
curl -fsSL "$BASE_URL/build/" -o "$DEST/build/index.html"
cat > "$DEST/README.txt" <<EOF
TREY FIELD DESK

The live seat is at: $BASE_URL/build/
The downloaded build is: $DEST/build/index.html

Open it directly in a browser, or serve the folder with:
  cd "$DEST" && python3 -m http.server 8080
EOF
printf 'Trey Field Desk downloaded to %s\n' "$DEST"
