"""Event input panel.""" from __future__ import annotations from datetime import date import streamlit as st EUROPEAN_COUNTRIES = { "AUT": "Austria", "BEL": "Belgium", "BGR": "Bulgaria", "HRV": "Croatia", "CZE": "Czech Republic", "DNK": "Denmark", "EST": "Estonia", "FIN": "Finland", "FRA": "France", "DEU": "Germany", "GRC": "Greece", "HUN": "Hungary", "ISL": "Iceland", "IRL": "Ireland", "ITA": "Italy", "LVA": "Latvia", "LTU": "Lithuania", "NLD": "Netherlands", "NOR": "Norway", "POL": "Poland", "PRT": "Portugal", "ROU": "Romania", "SVK": "Slovakia", "SVN": "Slovenia", "ESP": "Spain", "SWE": "Sweden", "CHE": "Switzerland", "GBR": "United Kingdom", "SRB": "Serbia", "UKR": "Ukraine", "MDA": "Moldova", "BIH": "Bosnia and Herzegovina", "ALB": "Albania", "MKD": "North Macedonia", "MNE": "Montenegro", } COUNTRY_TO_ISO = {v: k for k, v in EUROPEAN_COUNTRIES.items()} def render_event_input() -> dict | None: """Render the event input form. Returns input dict on submit.""" country_names = sorted(EUROPEAN_COUNTRIES.values()) country = st.selectbox( "Country", country_names, index=country_names.index("United Kingdom"), ) iso = COUNTRY_TO_ISO.get(country, "GBR") location = st.text_input( "Region / Location", placeholder="e.g. Greater Manchester", ) col_a, col_b = st.columns(2) with col_a: event_date = st.date_input("Event date", value=date.today()) with col_b: severity = st.select_slider( "Severity", options=["low", "medium", "high", "critical"], value="high", ) description = st.text_area( "Event description", placeholder=( "Cause, scale, affected area — e.g. heavy rain, river overflow, " "damaged embankments, affected population…" ), height=140, ) submit = st.button( "Run Cascade Forecast →", type="primary", use_container_width=True, ) if submit: if not location or not description: st.warning("Location and description are both required.") return None return { "country": country, "iso": iso, "location": location, "date": str(event_date), "severity": severity, "description": description, } return None