from typing import Mapping
from typing import Any
from typing import Dict


def pack_parameters(*args: Mapping[str, Any]) -> Dict[str, Any]:
    """Consolidate the arguments (sets of parameters) into a single dictionary of parameters."""
    # Mapping of names:
    #  - from econometric estimation in this script (keys)
    #  - to model parameters in the solution script (values)
    replacements = {
        'consumption_Intercept':   'alpha_0',
        'consumption_P':           'alpha_1',
        'consumption_P.shift()':   'alpha_2',
        'consumption_W':           'alpha_3',

        'investment_Intercept':    'beta_0',
        'investment_P':            'beta_1',
        'investment_P.shift()':    'beta_2',
        'investment_K.shift()':    'beta_3',

        'private_wages_Intercept': 'gamma_0',
        'private_wages_X':         'gamma_1',
        'private_wages_X.shift()': 'gamma_2',
        'private_wages_time':      'gamma_3',
    }

    # Rename the parameters and store to a single dictionary
    parameters = {}

    for group in args:
        parameters.update({replacements[k]: v for k, v in group.items()})

    return parameters