from typing import Dict
from typing import Any


def response_state_from_mediation_record(record: Dict[str, Any]):
    """Maps from acapy mediation role and state to AATH state"""
    state = record["state"]

    mediator_states = {
        "request": "request-received",
        "granted": "grant-sent",
        "denied": "deny-sent",
    }

    recipient_states = {
        "request": "request-sent",
        "granted": "grant-received",
        "denied": "deny-received",
    }

    # recipient
    if record["role"] == "client":
        return recipient_states[state]
    # mediator
    else:
        return mediator_states[state]