# 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


import re
import mgz
from mgz.util import Version
    encoding = 'unknown'
    name = 'Unknown'
    for pair in ENCODING_MARKERS:
        marker = pair[0]
        test_encoding = pair[1]
        e_m = marker.encode(test_encoding)
        for line in instructions.split(b'\n'):
            pos = line.find(e_m)
            if pos > -1:
                encoding = test_encoding
                name = line[pos+len(e_m):].decode(encoding).replace('.rms', '')
                language = pair[2]
                break

    # disambiguate certain languages
    if not language:
        language = 'unknown'
        for pair in LANGUAGE_MARKERS:
            if instructions.find(pair[0].encode(pair[1])) > -1:
                language = pair[2]
                break
    if encoding == 'unknown':
        raise ValueError('could not detect encoding')
    return encoding, language, name


def lookup_name(map_id, name, version, reference):
    """Lookup base game map if applicable."""
    custom = True
    is_de = version == Version.DE

# 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/common/map.py
import re
import mgz
from mgz.util import Version

    encoding = 'unknown'
    name = 'Unknown'
    for pair in ENCODING_MARKERS:
        marker = pair[0]
        test_encoding = pair[1]
        e_m = marker.encode(test_encoding)
        for line in instructions.split(b'\n'):
            pos = line.find(e_m)
            if pos > -1:
                encoding = test_encoding
                name = line[pos+len(e_m):].decode(encoding).replace('.rms', '')
                language = pair[2]
                break

    # disambiguate certain languages
    if not language:
        language = 'unknown'
        for pair in LANGUAGE_MARKERS:
            if instructions.find(pair[0].encode(pair[1])) > -1:
                language = pair[2]
                break
    if encoding == 'unknown':
        raise ValueError('could not detect encoding')
    return encoding, language, name


def lookup_name(map_id, name, version, reference):
    """Lookup base game map if applicable."""
    custom = True
    is_de = version == Version.DE

    is_hd = version == Version.HD