# Path: athlib/utils.py
# def normalize_gender(gender: Any) -> str:
#     """
#     Return M, F or raise a ValueError
# 
#     :param gender: M or F (case variations and suffixes accepted)
#     :returns: M or F
#     :raises ValueError: raises an exception
# 
#     """
#     if gender and isStr(gender):
#         g = gender.upper().strip()
#         if g:
#             g = g[0]
#             if g in ('M','F'):
#                 return g
#     raise ValueError('cannot normalize gender = %s' % repr(gender))
# 
# def parse_hms(t: Union[int, float, str]) -> Union[int, float]:
#     """
#     Parse a time duration with 0, 1 or 2 colons and return seconds.
# 
#     >>> from .utils import parse_hms
#     >>> parse_hms('10')
#     10
#     >>> parse_hms('1:10')
#     70
#     >>> parse_hms('1:1:10')
#     3670
#     >>> parse_hms('1:1:10.1')
#     3670.1
#     >>> parse_hms(3670.1)
#     3670.1
#     """
#     if isinstance(t, (float, int)):
#         return t
# 
#     # Try : and ; separators
#     for sep in ':;':
#         if sep not in t:
#             continue
# 
#         sec = 0
# 
#         for s in t.split(sep):
#             sec *= 60
# 
#             try:
#                 sec += str2num(s)
#             except ValueError:
#                 raise ValueError('cannot parse seconds from %s' % repr(t))
# 
#         return sec
#     try:
#         return str2num(t)
#     except ValueError:
#         raise ValueError('cannot parse seconds from %s' % repr(t))
# 
# def normalize_event_code(c : str) -> str:
#     c = c.strip()   #remove excess whitespace
#     m =  PAT_EVENT_CODE.match(c)
#     if not m:
#         raise ValueError('cannot normalize event code %r' % c)
#     rm = PAT_RELAYS.match(c)
#     if rm:
#         c = '%sx%s' % (rm.group(1),rm.group(2).upper())
#     else:
#         R = [].append
#         for k, v in m.groupdict().items():
#             if v is None or k not in _gnorms: continue
#             s = v.strip()
#             if not s: continue
#             R((m.span(k),_gnorms[k](s)))
#         R = R.__self__
#         c = c.upper()
#         for ((start,end),repl) in sorted(R, reverse=True):
#             c = c[:start] + repl + c[end:] 
#     return c.replace(' ','')
# 
# def is_hand_timing(perf: Any) -> bool:
#     if isStr(perf):
#         perf = nativeStr(perf)
#         dp = perf.rfind('.')
#         return dp<0 or len(perf)-dp<3
#     return False
# 
# Path: athlib/codes.py
# PAT_RUN = re.compile(_orjoin(PAT_TRACK, PAT_ROAD, PAT_RELAYS))


import typing
from athlib import parse_hms, normalize_gender, normalize_event_code, is_hand_timing
from athlib.codes import PAT_RUN
from typing import Union, Dict, Tuple
__all__ = 'tyrving_score'


class TyrvingCalculator:
    def __init__(self, gender, event_code, kind, args):
        self.gender = gender
        self.event_code = event_code    #so we can talk about it
        self.kind = kind    #race jump pv & throw

# Path: athlib/utils.py
# def normalize_gender(gender: Any) -> str:
#     """
#     Return M, F or raise a ValueError
# 
#     :param gender: M or F (case variations and suffixes accepted)
#     :returns: M or F
#     :raises ValueError: raises an exception
# 
#     """
#     if gender and isStr(gender):
#         g = gender.upper().strip()
#         if g:
#             g = g[0]
#             if g in ('M','F'):
#                 return g
#     raise ValueError('cannot normalize gender = %s' % repr(gender))
# 
# def parse_hms(t: Union[int, float, str]) -> Union[int, float]:
#     """
#     Parse a time duration with 0, 1 or 2 colons and return seconds.
# 
#     >>> from .utils import parse_hms
#     >>> parse_hms('10')
#     10
#     >>> parse_hms('1:10')
#     70
#     >>> parse_hms('1:1:10')
#     3670
#     >>> parse_hms('1:1:10.1')
#     3670.1
#     >>> parse_hms(3670.1)
#     3670.1
#     """
#     if isinstance(t, (float, int)):
#         return t
# 
#     # Try : and ; separators
#     for sep in ':;':
#         if sep not in t:
#             continue
# 
#         sec = 0
# 
#         for s in t.split(sep):
#             sec *= 60
# 
#             try:
#                 sec += str2num(s)
#             except ValueError:
#                 raise ValueError('cannot parse seconds from %s' % repr(t))
# 
#         return sec
#     try:
#         return str2num(t)
#     except ValueError:
#         raise ValueError('cannot parse seconds from %s' % repr(t))
# 
# def normalize_event_code(c : str) -> str:
#     c = c.strip()   #remove excess whitespace
#     m =  PAT_EVENT_CODE.match(c)
#     if not m:
#         raise ValueError('cannot normalize event code %r' % c)
#     rm = PAT_RELAYS.match(c)
#     if rm:
#         c = '%sx%s' % (rm.group(1),rm.group(2).upper())
#     else:
#         R = [].append
#         for k, v in m.groupdict().items():
#             if v is None or k not in _gnorms: continue
#             s = v.strip()
#             if not s: continue
#             R((m.span(k),_gnorms[k](s)))
#         R = R.__self__
#         c = c.upper()
#         for ((start,end),repl) in sorted(R, reverse=True):
#             c = c[:start] + repl + c[end:] 
#     return c.replace(' ','')
# 
# def is_hand_timing(perf: Any) -> bool:
#     if isStr(perf):
#         perf = nativeStr(perf)
#         dp = perf.rfind('.')
#         return dp<0 or len(perf)-dp<3
#     return False
# 
# Path: athlib/codes.py
# PAT_RUN = re.compile(_orjoin(PAT_TRACK, PAT_ROAD, PAT_RELAYS))


# Path: athlib/tyrving_score.py
import typing
from athlib import parse_hms, normalize_gender, normalize_event_code, is_hand_timing
from athlib.codes import PAT_RUN
from typing import Union, Dict, Tuple

__all__ = 'tyrving_score'


class TyrvingCalculator:
    def __init__(self, gender, event_code, kind, args):
        self.gender = gender
        self.event_code = event_code    #so we can talk about it
        self.kind = kind    #race jump pv & throw

        self.args = args