"""MASH 신약 후보 vocabulary.

target mechanism: THR-beta / FGF21 / GLP-1 / GIP-GLP / GCG-GLP / PPAR /
ACC / SCD1 / FXR / FASN / DGAT2 등으로 분류. 모든 매핑은 공개된 일반
정보 기반의 학습용 합성 vocabulary이며 임상 권고가 아닙니다.
"""

from __future__ import annotations

from typing import Dict, List


# 50+ active candidates. (drug, mechanism, sponsor, modality)
MASH_DRUGS: List[Dict[str, str]] = [
    # THR-beta agonists
    {"drug": "resmetirom",     "mechanism": "THR-beta",      "sponsor": "Madrigal",          "modality": "oral small molecule"},
    {"drug": "VK2809",         "mechanism": "THR-beta",      "sponsor": "Viking",            "modality": "oral small molecule"},
    {"drug": "ASC41",          "mechanism": "THR-beta",      "sponsor": "Ascletis",          "modality": "oral small molecule"},
    {"drug": "TERN-501",       "mechanism": "THR-beta",      "sponsor": "Terns",             "modality": "oral small molecule"},
    {"drug": "HSK31679",       "mechanism": "THR-beta",      "sponsor": "Haisco",            "modality": "oral small molecule"},

    # FGF21 analogs
    {"drug": "efruxifermin",   "mechanism": "FGF21",         "sponsor": "Akero",             "modality": "Fc fusion"},
    {"drug": "pegozafermin",   "mechanism": "FGF21",         "sponsor": "89bio",             "modality": "glycoPEGylated"},
    {"drug": "BIO89-100",      "mechanism": "FGF21",         "sponsor": "89bio",             "modality": "glycoPEGylated"},
    {"drug": "BFKB8488A",      "mechanism": "FGF21",         "sponsor": "Genentech",         "modality": "Fc fusion"},

    # GLP-1
    {"drug": "semaglutide-2.4", "mechanism": "GLP-1",        "sponsor": "Novo Nordisk",      "modality": "subcutaneous peptide"},
    {"drug": "liraglutide",    "mechanism": "GLP-1",         "sponsor": "Novo Nordisk",      "modality": "subcutaneous peptide"},
    {"drug": "oral-semaglutide","mechanism": "GLP-1",        "sponsor": "Novo Nordisk",      "modality": "oral peptide"},

    # GIP/GLP-1 dual
    {"drug": "tirzepatide",    "mechanism": "GIP-GLP",       "sponsor": "Eli Lilly",         "modality": "subcutaneous peptide"},

    # GCG/GLP-1 dual
    {"drug": "survodutide",    "mechanism": "GCG-GLP",       "sponsor": "Boehringer",        "modality": "subcutaneous peptide"},
    {"drug": "pemvidutide",    "mechanism": "GCG-GLP",       "sponsor": "Altimmune",         "modality": "subcutaneous peptide"},
    {"drug": "cotadutide",     "mechanism": "GCG-GLP",       "sponsor": "AstraZeneca",       "modality": "subcutaneous peptide"},
    {"drug": "mazdutide",      "mechanism": "GCG-GLP",       "sponsor": "Innovent",          "modality": "subcutaneous peptide"},

    # GLP-1/GIP/GCG triple
    {"drug": "retatrutide",    "mechanism": "GIP-GLP-GCG",   "sponsor": "Eli Lilly",         "modality": "subcutaneous peptide"},
    {"drug": "VK2735",         "mechanism": "GIP-GLP",       "sponsor": "Viking",            "modality": "subcutaneous peptide"},

    # PPAR
    {"drug": "lanifibranor",   "mechanism": "PPAR",          "sponsor": "Inventiva",         "modality": "oral small molecule"},
    {"drug": "saroglitazar",   "mechanism": "PPAR",          "sponsor": "Zydus",             "modality": "oral small molecule"},
    {"drug": "elafibranor",    "mechanism": "PPAR",          "sponsor": "Ipsen",             "modality": "oral small molecule"},
    {"drug": "pioglitazone",   "mechanism": "PPAR",          "sponsor": "generic",           "modality": "oral small molecule"},

    # ACC
    {"drug": "firsocostat",    "mechanism": "ACC",           "sponsor": "Gilead",            "modality": "oral small molecule"},
    {"drug": "PF-05221304",    "mechanism": "ACC",           "sponsor": "Pfizer",            "modality": "oral small molecule"},
    {"drug": "MK-4074",        "mechanism": "ACC",           "sponsor": "Merck",             "modality": "oral small molecule"},

    # SCD1 / FASN / DGAT2
    {"drug": "aramchol",       "mechanism": "SCD1",          "sponsor": "Galmed",            "modality": "oral small molecule"},
    {"drug": "denifanstat",    "mechanism": "FASN",          "sponsor": "Sagimet",           "modality": "oral small molecule"},
    {"drug": "PF-06865571",    "mechanism": "DGAT2",         "sponsor": "Pfizer",            "modality": "oral small molecule"},
    {"drug": "ervogastat",     "mechanism": "DGAT2",         "sponsor": "Pfizer",            "modality": "oral small molecule"},
    {"drug": "miricorilant",   "mechanism": "GR-antagonist", "sponsor": "Corcept",           "modality": "oral small molecule"},

    # FXR
    {"drug": "obeticholic-acid","mechanism": "FXR",          "sponsor": "Intercept",         "modality": "oral small molecule"},
    {"drug": "tropifexor",     "mechanism": "FXR",           "sponsor": "Novartis",          "modality": "oral small molecule"},
    {"drug": "cilofexor",      "mechanism": "FXR",           "sponsor": "Gilead",            "modality": "oral small molecule"},
    {"drug": "vonafexor",      "mechanism": "FXR",           "sponsor": "Enyo",              "modality": "oral small molecule"},
    {"drug": "EDP-305",        "mechanism": "FXR",           "sponsor": "Enanta",            "modality": "oral small molecule"},

    # FGF19
    {"drug": "aldafermin",     "mechanism": "FGF19",         "sponsor": "NGM Bio",           "modality": "engineered FGF19"},

    # SGLT2
    {"drug": "empagliflozin",  "mechanism": "SGLT2",         "sponsor": "Boehringer",        "modality": "oral small molecule"},
    {"drug": "dapagliflozin",  "mechanism": "SGLT2",         "sponsor": "AstraZeneca",       "modality": "oral small molecule"},

    # ASK1 / CCR2-CCR5 / Cathepsin
    {"drug": "selonsertib",    "mechanism": "ASK1",          "sponsor": "Gilead",            "modality": "oral small molecule"},
    {"drug": "cenicriviroc",   "mechanism": "CCR2-CCR5",     "sponsor": "AbbVie",            "modality": "oral small molecule"},
    {"drug": "VBY-376",        "mechanism": "Cathepsin-B",   "sponsor": "Virobay",           "modality": "oral small molecule"},

    # apoptosis / NLRP3
    {"drug": "emricasan",      "mechanism": "Pan-caspase",   "sponsor": "Histogen",          "modality": "oral small molecule"},
    {"drug": "selnoflast",     "mechanism": "NLRP3",         "sponsor": "Roche",             "modality": "oral small molecule"},

    # Galectin-3
    {"drug": "belapectin",     "mechanism": "Galectin-3",    "sponsor": "Galectin Tx",       "modality": "infusion"},

    # PNPLA3 ASO
    {"drug": "ION224",         "mechanism": "PNPLA3-ASO",    "sponsor": "Ionis",             "modality": "antisense"},
    {"drug": "AZD2693",        "mechanism": "PNPLA3-siRNA",  "sponsor": "AstraZeneca",       "modality": "siRNA"},

    # HSD17B13
    {"drug": "ALN-HSD",        "mechanism": "HSD17B13-siRNA","sponsor": "Alnylam-Regeneron", "modality": "siRNA"},

    # MPC inhibitor
    {"drug": "azemiglitazone", "mechanism": "PPAR-MPC",      "sponsor": "MetaVia",           "modality": "oral small molecule"},

    # ApoC3 ASO (mixed dyslipidemia / MASH)
    {"drug": "olezarsen",      "mechanism": "ApoC3-ASO",     "sponsor": "Ionis",             "modality": "antisense"},

    # ANGPTL3
    {"drug": "evinacumab",     "mechanism": "ANGPTL3",       "sponsor": "Regeneron",         "modality": "monoclonal antibody"},
]


def get_drug_index() -> Dict[str, Dict[str, str]]:
    """drug name -> meta dict."""
    return {d["drug"]: d for d in MASH_DRUGS}


def get_mechanisms() -> List[str]:
    seen: List[str] = []
    for d in MASH_DRUGS:
        if d["mechanism"] not in seen:
            seen.append(d["mechanism"])
    return seen


def get_sponsors() -> List[str]:
    seen: List[str] = []
    for d in MASH_DRUGS:
        if d["sponsor"] not in seen:
            seen.append(d["sponsor"])
    return seen


def drugs_for_sponsor(sponsor: str) -> List[str]:
    return [d["drug"] for d in MASH_DRUGS if d["sponsor"].lower() == sponsor.lower()]


def drugs_for_mechanism(mechanism: str) -> List[str]:
    return [d["drug"] for d in MASH_DRUGS if d["mechanism"].lower() == mechanism.lower()]
