# Path: mgz/util.py
# class Version(Enum):
#     """Version enumeration.
# 
#     Using consts from https://github.com/goto-bus-stop/recanalyst/blob/master/src/Model/Version.php
#     for consistency.
#     """
#     AOK = 1
#     AOC = 4
#     AOC10 = 5
#     AOC10C = 8
#     USERPATCH12 = 12
#     USERPATCH13 = 13
#     USERPATCH14 = 11
#     USERPATCH15 = 20
#     DE = 21
#     USERPATCH14RC2 = 22
#     MCP = 30
#     HD = 19
# 
# Path: mgz/reference.py
# def get_dataset(version, mod):
#     """Fetch dataset reference data."""
#     if version is Version.DE:
#         dataset_id = 100
#     elif version is Version.HD:
#         dataset_id = 300
#     elif mod:
#         dataset_id = mod[0]
#     else:
#         dataset_id = 0
#     return dataset_id, json.loads(pkgutil.get_data(REF_PACKAGE, f'data/datasets/{dataset_id}.json'))


import mgz
from mgz.util import Version
from mgz.reference import get_dataset

def resolve_hd_version(hd, save_version):
    """Best guess at HD version."""
    if hd.version == 1006:
        if 'test_57' in hd and hd.test_57.is_57:
            return '5.7'
        else:
            return '5.8'
    if hd.version == 1005:
        return '>=5.0,<5.7'
    if hd.version == 1004:
        return '4.8'
    if save_version >= 12.36:
        return '>=4.6,<4.8'
    return None


def get_dataset_data(header):
    """Get dataset."""
    sample = header.initial.players[0].attributes.player_stats
    mod = None
    if 'mod' in sample:
        mod = (sample.mod.get('id'), sample.mod.get('version'))
    _, ref = get_dataset(header.version, mod)
    if header.version == Version.DE:
        return {
            'id': 100,
            'name': 'Definitive Edition',
            'version': None
        }, ref

# Path: mgz/util.py
# class Version(Enum):
#     """Version enumeration.
# 
#     Using consts from https://github.com/goto-bus-stop/recanalyst/blob/master/src/Model/Version.php
#     for consistency.
#     """
#     AOK = 1
#     AOC = 4
#     AOC10 = 5
#     AOC10C = 8
#     USERPATCH12 = 12
#     USERPATCH13 = 13
#     USERPATCH14 = 11
#     USERPATCH15 = 20
#     DE = 21
#     USERPATCH14RC2 = 22
#     MCP = 30
#     HD = 19
# 
# Path: mgz/reference.py
# def get_dataset(version, mod):
#     """Fetch dataset reference data."""
#     if version is Version.DE:
#         dataset_id = 100
#     elif version is Version.HD:
#         dataset_id = 300
#     elif mod:
#         dataset_id = mod[0]
#     else:
#         dataset_id = 0
#     return dataset_id, json.loads(pkgutil.get_data(REF_PACKAGE, f'data/datasets/{dataset_id}.json'))


# Path: mgz/summary/dataset.py
import mgz
from mgz.util import Version
from mgz.reference import get_dataset


def resolve_hd_version(hd, save_version):
    """Best guess at HD version."""
    if hd.version == 1006:
        if 'test_57' in hd and hd.test_57.is_57:
            return '5.7'
        else:
            return '5.8'
    if hd.version == 1005:
        return '>=5.0,<5.7'
    if hd.version == 1004:
        return '4.8'
    if save_version >= 12.36:
        return '>=4.6,<4.8'
    return None


def get_dataset_data(header):
    """Get dataset."""
    sample = header.initial.players[0].attributes.player_stats
    mod = None
    if 'mod' in sample:
        mod = (sample.mod.get('id'), sample.mod.get('version'))
    _, ref = get_dataset(header.version, mod)
    if header.version == Version.DE:
        return {
            'id': 100,
            'name': 'Definitive Edition',
            'version': None
        }, ref

    elif header.version == Version.HD: