import numpy as np

ON_SEASON = [3, 4, 5, 6, 7, 8, 9]

ON_SEASON_2 = [
    (np.datetime64('2017-04-02'), np.datetime64('2017-11-01')),
    (np.datetime64('2018-03-29'), np.datetime64('2018-10-28')),
    (np.datetime64('2019-03-20'), np.datetime64('2019-10-30')),
    (np.datetime64('2020-07-23'), np.datetime64('2020-10-28')),
    (np.datetime64('2021-02-28'), np.datetime64('2021-10-31'))
]

LABELS = {
    'award': {
        'MILBORGAS': 0,
        'FSLMSAS': 1,
        'MWLMSAS': 2,
        'SLMSAS': 3,
        'TLMSAS': 4,
        'ELMSAS': 5,
        'MEXMSAS': 6,
        'SALMSAS': 7,
        'CARMSAS': 8,
        'AFLRS': 9,
        'CALMSAS': 10,
        'FUTURES': 11,
        'ALPBMSAS': 12,
        'DSLMSAS': 13,
        'ILMSAS': 14,
        'WSCHAMP': 15,
        'ALAS': 16,
        'NLAS': 17,
        'PCLMSAS': 18,
        'ALPOW': 19,
        'NLPOW': 20,
        'NORMSAS': 21,
        'PIOLGAS': 22,
        'NYPMSAS': 23,
        'BAMLART': 24,
        'TEXPOWP': 25,
        'CALPOWP': 26,
        'MIDPOWH': 27,
        'INTPOWH': 28,
        'FSLPOWP': 29,
        'CALPOWH': 30,
        'FSLPOWH': 31,
        'PCLPOWH': 32,
        'INTPOWP': 33,
        'CARPOWP': 34,
        'PCLPOWP': 35,
        'TEXPOWH': 36,
        'CARPOWH': 37,
        'SALPOWH': 38,
        'MIDPOWP': 39,
        'EASPOWH': 40,
        'SALPOWP': 41,
        'EASPOWP': 42,
        'SOUPOWP': 43,
        'SOUPOWH': 44,
        'MLBPLAYOW': 45,
        'FSLPSAS': 46,
        'CSAS': 47,
        'MLBSECOND': 48,
        'MLBAFIRST': 49,
        'SLPSAS': 50,
        'BAAAAAS': 51,
        'BAMILAS': 52,
        'BASSAS': 53,
        'BAHAXXAS': 54,
        'BADSLAS': 55,
        'BAROAS': 56,
        'BAAAXAS': 57,
        'TLPSAS': 58,
        'BALAXXAS': 59,
        'NLGG': 60,
        'APPPSAS': 61,
        'CALPSAS': 62,
        'NWLPSAS': 63,
        'SALPSAS': 64,
        'NLSS': 65,
        'ELPSAS': 66,
        'ALGG': 67,
        'PIOPSAS': 68,
        'AZLPSAS': 69,
        'MWLPSAS': 70,
        'ALSS': 71,
        'CARPSAS': 72,
        'DSLPSAS': 73,
        'ALPBEOSAS': 74,
        'GCLPSAS': 75,
        'PCLPSAS': 76,
        'PWLPSAS': 77,
        'ILPSAS': 78,
        'NORPOWH': 79,
        'APPPOWP': 80,
        'NORPOWP': 81,
        'NYPPOWH': 82,
        'NYPPOWP': 83,
        'PIOPOWH': 84,
        'APPPOWH': 85,
        'AFLPSAS': 86,
        'PIOPOWP': 87,
        'MILBGG': 88,
        'WDPOY': 89,
        'MLBHOF': 90,
        'HRDERBY': 91,
        'NLPOM': 92,
        'ALPOM': 93,
        'ALPITOM': 94,
        'NLPITOM': 95,
        'ALROM': 96,
        'NLRRELMON': 97,
        'NLROM': 98,
        'ALRRELMON': 99
    },
    'statusCode': {
        'A': 0,
        'RM': 1,
        'D60': 2,
        'D10': 3,
        'D7': 4,
        'PL': 5,
        'SU': 6,
        'BRV': 7,
        'FME': 8,
        'RES': 9,
        'DEC': 10
    },
    'typeCode': {
        'ASG': 0,
        'SFA': 1,
        'SC': 2,
        'OPT': 3,
        'CU': 4,
        'SGN': 5,
        'SE': 6,
        'TR': 7,
        'DES': 8,
        'OUT': 9,
        'DFA': 10,
        'NUM': 11,
        'REL': 12,
        'CLW': 13,
        'RTN': 14,
        'RET': 15
    },
    'positionName': {
        'Pitcher': 1,
        'Outfielder': 2,
        'Catcher': 3,
        'First Base': 4,
        'Second Base': 5,
        'Third Base': 6,
        'Shortstop': 7,
        'Pinch Hitter': 8,
        'Designated Hitter': 9,
        'Pinch Runner': 10
    },
    'positionType': {
        'Infielder': 1,
        'Pitcher': 2,
        'Outfielder': 3,
        'Hitter': 4,
        'Catcher': 5,
        'Runner': 6
    },
    'gameType': {
        'R': 0,
        'S': 1,
        'D': 2,
        'L': 3,
        'E': 4,
        'F': 5,
        'W': 6,
        'A': 6
    },
    'positionCode': {
        '1': 0,
        '2': 1,
        '3': 2,
        '4': 3,
        '5': 4,
        '6': 5,
        '7': 6,
        '8': 7,
        '9': 8,
        '10': 9,
        'O': 10
    },
    'birthCountry': {
        'USA': 0,
        'Dominican Republic': 1,
        'Venezuela': 2,
        'Cuba': 3,
        'Puerto Rico': 4,
        'Mexico': 5,
        'Canada': 6,
        'Japan': 7,
        'Colombia': 8,
        'Panama': 9
    }
}

CATEGORICAL_COLS = {
    'player_statusCode': 12,
    'primaryPositionCode': 12,
    'player_transactions_typeCode': 17
}


def is_on_season(dt: np.datetime64) -> bool:
    for season_start, season_end in ON_SEASON_2:
        if (dt >= season_start) and (dt <= season_end):
            return True
    return False

import numpy as np

ON_SEASON = [3, 4, 5, 6, 7, 8, 9]

ON_SEASON_2 = [
    (np.datetime64('2017-04-02'), np.datetime64('2017-11-01')),
    (np.datetime64('2018-03-29'), np.datetime64('2018-10-28')),
    (np.datetime64('2019-03-20'), np.datetime64('2019-10-30')),
    (np.datetime64('2020-07-23'), np.datetime64('2020-10-28')),
    (np.datetime64('2021-02-28'), np.datetime64('2021-10-31'))
]

LABELS = {
    'award': {
        'MILBORGAS': 0,
        'FSLMSAS': 1,
        'MWLMSAS': 2,
        'SLMSAS': 3,
        'TLMSAS': 4,
        'ELMSAS': 5,
        'MEXMSAS': 6,
        'SALMSAS': 7,
        'CARMSAS': 8,
        'AFLRS': 9,
        'CALMSAS': 10,
        'FUTURES': 11,
        'ALPBMSAS': 12,
        'DSLMSAS': 13,
        'ILMSAS': 14,
        'WSCHAMP': 15,
        'ALAS': 16,
        'NLAS': 17,
        'PCLMSAS': 18,
        'ALPOW': 19,
        'NLPOW': 20,
        'NORMSAS': 21,
        'PIOLGAS': 22,
        'NYPMSAS': 23,
        'BAMLART': 24,
        'TEXPOWP': 25,
        'CALPOWP': 26,
        'MIDPOWH': 27,
        'INTPOWH': 28,
        'FSLPOWP': 29,
        'CALPOWH': 30,
        'FSLPOWH': 31,
        'PCLPOWH': 32,
        'INTPOWP': 33,
        'CARPOWP': 34,
        'PCLPOWP': 35,
        'TEXPOWH': 36,
        'CARPOWH': 37,
        'SALPOWH': 38,
        'MIDPOWP': 39,
        'EASPOWH': 40,
        'SALPOWP': 41,
        'EASPOWP': 42,
        'SOUPOWP': 43,
        'SOUPOWH': 44,
        'MLBPLAYOW': 45,
        'FSLPSAS': 46,
        'CSAS': 47,
        'MLBSECOND': 48,
        'MLBAFIRST': 49,
        'SLPSAS': 50,
        'BAAAAAS': 51,
        'BAMILAS': 52,
        'BASSAS': 53,
        'BAHAXXAS': 54,
        'BADSLAS': 55,
        'BAROAS': 56,
        'BAAAXAS': 57,
        'TLPSAS': 58,
        'BALAXXAS': 59,
        'NLGG': 60,
        'APPPSAS': 61,
        'CALPSAS': 62,
        'NWLPSAS': 63,
        'SALPSAS': 64,
        'NLSS': 65,
        'ELPSAS': 66,
        'ALGG': 67,
        'PIOPSAS': 68,
        'AZLPSAS': 69,
        'MWLPSAS': 70,
        'ALSS': 71,
        'CARPSAS': 72,
        'DSLPSAS': 73,
        'ALPBEOSAS': 74,
        'GCLPSAS': 75,
        'PCLPSAS': 76,
        'PWLPSAS': 77,
        'ILPSAS': 78,
        'NORPOWH': 79,
        'APPPOWP': 80,
        'NORPOWP': 81,
        'NYPPOWH': 82,
        'NYPPOWP': 83,
        'PIOPOWH': 84,
        'APPPOWH': 85,
        'AFLPSAS': 86,
        'PIOPOWP': 87,
        'MILBGG': 88,
        'WDPOY': 89,
        'MLBHOF': 90,
        'HRDERBY': 91,
        'NLPOM': 92,
        'ALPOM': 93,
        'ALPITOM': 94,
        'NLPITOM': 95,
        'ALROM': 96,
        'NLRRELMON': 97,
        'NLROM': 98,
        'ALRRELMON': 99
    },
    'statusCode': {
        'A': 0,
        'RM': 1,
        'D60': 2,
        'D10': 3,
        'D7': 4,
        'PL': 5,
        'SU': 6,
        'BRV': 7,
        'FME': 8,
        'RES': 9,
        'DEC': 10
    },
    'typeCode': {
        'ASG': 0,
        'SFA': 1,
        'SC': 2,
        'OPT': 3,
        'CU': 4,
        'SGN': 5,
        'SE': 6,
        'TR': 7,
        'DES': 8,
        'OUT': 9,
        'DFA': 10,
        'NUM': 11,
        'REL': 12,
        'CLW': 13,
        'RTN': 14,
        'RET': 15
    },
    'positionName': {
        'Pitcher': 1,
        'Outfielder': 2,
        'Catcher': 3,
        'First Base': 4,
        'Second Base': 5,
        'Third Base': 6,
        'Shortstop': 7,
        'Pinch Hitter': 8,
        'Designated Hitter': 9,
        'Pinch Runner': 10
    },
    'positionType': {
        'Infielder': 1,
        'Pitcher': 2,
        'Outfielder': 3,
        'Hitter': 4,
        'Catcher': 5,
        'Runner': 6
    },
    'gameType': {
        'R': 0,
        'S': 1,
        'D': 2,
        'L': 3,
        'E': 4,
        'F': 5,
        'W': 6,
        'A': 6
    },
    'positionCode': {
        '1': 0,
        '2': 1,
        '3': 2,
        '4': 3,
        '5': 4,
        '6': 5,
        '7': 6,
        '8': 7,
        '9': 8,
        '10': 9,
        'O': 10
    },
    'birthCountry': {
        'USA': 0,
        'Dominican Republic': 1,
        'Venezuela': 2,
        'Cuba': 3,
        'Puerto Rico': 4,
        'Mexico': 5,
        'Canada': 6,
        'Japan': 7,
        'Colombia': 8,
        'Panama': 9
    }
}

CATEGORICAL_COLS = {
    'player_statusCode': 12,
    'primaryPositionCode': 12,
    'player_transactions_typeCode': 17
}


def is_on_season(dt: np.datetime64) -> bool:
    for season_start, season_end in ON_SEASON_2:
        if (dt >= season_start) and (dt <= season_end):
            return True
    return False
