"""
Everything specific to the GSYS "Test före Sommarcupen" Race 1 demo race.

This is the ONLY file you edit to point the broadcast demo at a different race —
the exporter (export_team_race.py), the scoring engine and the render page are
all generic. The one-off scripts that were used to discover the values below
(instance id, device ids, window) live in export/discovery/.
"""
from datetime import UTC, datetime


def _ms(y, mo, d, h, mi, s):
    return int(datetime(y, mo, d, h, mi, s, tzinfo=UTC).timestamp() * 1000)


PROJECT = "apps-viewregatta"
INSTANCE = "hUokC5BxKlkPmzbfUmqj"          # raceInstance "14:50-15:50", course = digital 8
USER = "GSYS"
TITLE = "Test före Sommarcupen — Race 1 · Digital 8  (Red Hats v Blue Socks)"

# race window in UTC (= 15:06:30–15:19:00 CEST, gun 15:09:45)
TRACK_START = _ms(2026, 5, 22, 13, 6, 30)
GUN = _ms(2026, 5, 22, 13, 9, 45)
TRACK_END = _ms(2026, 5, 22, 13, 19, 0)

# Explicit device mapping — the boat->device metadata is broken (V2 reuse bug), so
# devices are assigned by which ones actually have GPS in the window (see discovery/).
# nameLang (BCP-47, optional): the language the team NAME is pronounced in, when it differs from the
# commentary language — these names are English, so the Swedish TTS says them in English instead of
# spelling them out Swedish-style. Omit for names that read natively in the commentary language.
TEAMS = [
    {"teamId": "den", "name": "Red Hats", "nameLang": "en", "color": "#C8102E",
     "boats": [{"sail": "2", "dev": "7e15dd080af4077e"}, {"sail": "4", "dev": "01f90652416aaa2e"}]},
    {"teamId": "usa", "name": "Blue Socks", "nameLang": "en", "color": "#5BB8E8",
     "boats": [{"sail": "5", "dev": "e95e24a14fa12cc4"}, {"sail": "6", "dev": "e14dc5c42d7d015f"}]},
]

# Wind for the race. The exporter now pulls the **real** wind that blew over the race window from the
# Open-Meteo ERA5 archive at the course centre (wind_archive.backfill / nearest_sample) — so the arrow
# + wind-dependent commentary (point-of-sail leg labels, upwind/downwind phase lines, gassing/
# wind-shadow) track the genuine, time-varying breeze instead of one frozen guess.
#
# WIND below is the **offline fallback** only: used verbatim when the archive can't be reached (no
# network) or has no data yet (race younger than ERA5's ~5-day lag). Recorded on the day: from the west
# at ~4 m/s. fromDeg = direction the wind blows FROM (deg true); kts = knots (4 m/s ≈ 7.8 kn). Set
# fromDeg=None to leave wind unset when offline (disables wind-dependent commentary).
WIND = {"fromDeg": 270, "kts": 7.8}

# director timing for the single-race demo (winner + grace held before the replay)
PARAMS = {"winnerGraceS": 40, "preStartS": 30, "fastReplayX": 5}
