"""ESI related function"""

from eve_sde.models import SolarSystem

from esi.openapi_clients import ESIClientProvider

from evescout import __version__, compatibility_date, repo_url, ua_appname

esi = ESIClientProvider(
    compatibility_date, ua_appname, __version__, repo_url, operations=["PostRoute"]
)


def esi_route(from_system: SolarSystem, to_system: SolarSystem) -> list[int]:
    """
    Calculates the shortest path between two solar systems.
    Returns a list of id that is the path between the two
    """
    return (
        esi.client.Routes.PostRoute(
            origin_system_id=from_system.id,
            destination_system_id=to_system.id,
            body={},
        )
        .result()
        .route
    )
