from imports import *
# --- wrapper with unit conversions ---
def radial_travel(
    starting_velocity: float = None,
    start_altitude: float = None,
    input_dist_unit: str = DEFAULT_DIST_UNIT,
    input_time_unit: str = DEFAULT_TIME_UNIT,
    output_dist_unit: str = DEFAULT_DIST_UNIT,
    output_time_unit: str = DEFAULT_TIME_UNIT,
    *,
    planet: str = DEFAULT_PLANET,
    dt_s: float = 1.0,
    max_steps: int = 5_000_000,
    target_distance: float = None
) -> dict:
    """Wrapper: handles units, runs SI integrator, converts outputs."""
    norm = normalize_inputs(
        planet=planet, start_altitude=start_altitude, starting_velocity=starting_velocity,
        input_dist_unit=input_dist_unit, input_time_unit=input_time_unit, target_distance=target_distance
    )

    sim = simulate_radial_flight_si(
        v0_mps=norm["v0_mps"],
        start_alt_m=norm["start_alt_m"],
        planet=planet,
        dt_s=dt_s,
        max_steps=max_steps,
        target_alt_m=norm["target_alt_m"],
    )
    if not sim.get("ok"):
        return sim

    # Output conversions
    sec_per_out = seconds_per(output_time_unit)
    conv = lambda m: dconvert(m, DEFAULT_DIST_UNIT, output_dist_unit)

    return {
        "ok": True,
        "planet": planet,
        "inputs": {
            "start_altitude": start_altitude,
            "starting_velocity": starting_velocity,
            "input_dist_unit": input_dist_unit,
            "input_time_unit": input_time_unit,
            "output_dist_unit": output_dist_unit,
            "output_time_unit": output_time_unit,
            "target_distance": target_distance,
        },
        # final state
        "altitude": conv(sim["altitude_m"]),
        "radius_from_center": conv(sim["r_m"]),
        "distance_traveled": conv(sim["traveled_m"]),
        "velocity": mul(dconvert(sim["vEnd_mps"], DEFAULT_DIST_UNIT, output_dist_unit), sec_per_out),
        "velocity_escape_end": mul(dconvert(sim["vesc_end_mps"], DEFAULT_DIST_UNIT, output_dist_unit), sec_per_out),
        "time": div(sim["time_s"], sec_per_out),
        "time_unit": output_time_unit,
        "g_end_mps2": sim["g_end_mps2"],
        "g_ratio_surface": sim["g_ratio_surface"],
        "steps": sim["steps"],
        "hit_surface": sim["hit_surface"],
        "hit_target": sim["hit_target"],
        "turned_back": sim["turned_back"],

        # extended stats (converted)
        "furthest_distance": conv(sim["furthest_altitude_m"]),
        "furthest_radius": conv(sim["furthest_r"]),
        "time_at_furthest": div(sim["time_at_furthest"], sec_per_out),
        "total_distance": conv(sim["total_distance_m"]),
    }


(5)
