"""LaTeX constants and simple normalization data for math parsing."""
from typing import List
from typing import Dict as T_Dict


STR2NUM = {
    "zero": 0, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5,
    "six": 6, "seven": 7, "eight": 8, "nine": 9, "ten": 10,
    "eleven": 11, "twelve": 12, "thirteen": 13, "fourteen": 14,
    "fifteen": 15, "sixteen": 16, "seventeen": 17, "eighteen": 18,
    "nineteen": 19, "twenty": 20,
}


def rm_latex_env(s: str, env: str) -> str:
    """Remove LaTeX environment from a string.

    Parameters
    ----------
    s : str
        The input string.
    env : str
        The LaTeX environment name to remove.

    Returns
    -------
    str
        The string with the specified LaTeX environment removed.
    """
    s = s.replace(f"\\begin{{{env}}}", "")
    s = s.replace(f"\\end{{{env}}}", "")
    return s


LATEX_CMDS: List[str] = [
    "\\textbf", "\\textit", "\\textsl", "\\texttt", "\\textsc",
    "\\textsf", "\\textrm", "\\mathrm", "\\mathbf", "\\mathit",
    "\\mathsf", "\\mathtt", "\\mathbb", "\\mathcal", "\\mathscr",
    "\\mathfrak", "\\bm", "\\em", "\\emph", "\\underline",
    "\\overline", "\\tiny", "\\scriptsize", "\\footnotesize",
    "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE",
    "\\huge", "\\Huge", "\\newline", "\\par", "\\noindent",
    "\\indent", "\\footnote", "\\cite", "\\ref", "\\label",
    "\\textsuperscript", "\\textsubscript", "\\text", "\\mbox",
    "\\renewcommand{\\arraystretch}",
]

LATEX_FMT_ENVS: List[str] = [
    "align", "align*", "center", "flushleft", "flushright",
]
LATEX_LIST_ENVS: List[str] = [
    "itemize", "enumerate", "description",
]


SIMPLE_RM_STRS: List[str] = [
    "\n", "\t", "approximately", "'", '"', "\\$", "$",
    "\uffe5", "\u00a3", "\u20ac", "{,}", "\\!", "\\,", "\\:", "\\;",
    "\\quad", "\\qquad", "\\space", "\\thinspace", "\\medspace",
    "\\thickspace", "~,", "\\ ",
    # Note the order
    "\\\\%", "\\%", "%",
    "\\left", "\\right", "^{\\circ}", "^\\circ",
]

SIMPLE_REPLACE_MAP: T_Dict[str, str] = {
    "\u222a": "\\cup",
    "\u03c0": "\\pi",
    "\u221e": "\\infty",
    "\u2208": "\\in",
    "\u2229": "\\cap",
    "\u2212": "-",
    "\\item": ",",
    "and": ",",
    ";": ",",
    "infinity": "\\infty",
    "+\\infty": "\\infty",
    "tfrac": "frac",
    "dfrac": "frac",
    "\\approx": "=",
    "\\times": "*",
    "\\cdot": "*",
    "{.": "{0.",
    " .": " 0.",
    ":": "/",
}
