"""Static data constants extracted from Accordance parser modules.

This module contains large data structures that were previously inlined
in module.py, text_module.py, and commentary_module.py.  They are
extracted here to keep the source files focused on logic.

Every constant retains its exact original name, type, and value.
"""

# ── Mac Roman bytes 0x80-0xFF where Mac Roman differs from latin-1 ──────
# (from module.py)
# Used to clean up module titles which are stored in Mac Roman encoding.
#
# RELATED TABLES:
#   _MACROMAN_TO_LATIN1   (encoding.py) — MacRoman→Latin-1 byte values
#   _MACROMAN_TO_UNICODE  (this file)   — MacRoman→Unicode for verse text
# The 0x80-0x9F range is shared across all three tables.  Changes to
# byte mappings in one should be checked against the other two.
_TITLE_MAC_ROMAN_MAP = {
    0x80: "\u00c4",
    0x81: "\u00c5",
    0x82: "\u00c7",
    0x83: "\u00c9",
    0x84: "\u00d1",
    0x85: "\u00d6",
    0x86: "\u00dc",
    0x87: "\u00e1",
    0x88: "\u00e0",
    0x89: "\u00e2",
    0x8A: "\u00e4",
    0x8B: "\u00e3",
    0x8C: "\u00e5",
    0x8D: "\u00e7",
    0x8E: "\u00e9",
    0x8F: "\u00e8",
    0x90: "\u00ea",
    0x91: "\u00eb",
    0x92: "\u00ed",
    0x93: "\u00ec",
    0x94: "\u00ee",
    0x95: "\u00ef",
    0x96: "\u00f1",
    0x97: "\u00f3",
    0x98: "\u00f2",
    0x99: "\u00f4",
    0x9A: "\u00f6",
    0x9B: "\u00f5",
    0x9C: "\u00fa",
    0x9D: "\u00f9",
    0x9E: "\u00fb",
    0x9F: "\u00fc",
    0xAA: "\u2122",
    0xC6: "\u00c6",
    0xD0: "\u2013",
    0xD1: "\u2014",
    0xD2: "\u201c",
    0xD3: "\u201d",
    0xD4: "\u2018",
    0xD5: "\u2019",
    0xD6: "\u00d6",
    0xD7: "\u2021",
    0xDB: "\u2026",
    0xE0: "\u2020",
    0xE5: "\u2022",
    0xE6: "\u00b6",
    0xFA: "\u00fa",
}

# ── MacRoman byte → proper Unicode character mapping ────────────────────
# (from text_module.py)
# Verse text in many Accordance modules (CEB, MESSAGE, LSV, LBLA, NBLH,
# RVR09S, etc.) stores punctuation and accented characters as MacRoman
# bytes (0x80-0xFF).  Without pre-conversion, these bytes fail UTF-8
# decoding and become U+FFFD replacement characters.
#
# This table maps each MacRoman byte to its correct Unicode character.
# It is used by _prep_macroman_bytes() to convert raw verse text into
# valid UTF-8 before decoding.
#
# Based on standard Mac OS Roman encoding, verified against Accordance
# module data.  See also _TITLE_MAC_ROMAN_MAP (above) and
# _MACROMAN_TO_LATIN1 in encoding.py — all three share the 0x80-0x9F range.
_MACROMAN_TO_UNICODE = {
    # ── Accented Latin characters (0x80-0x9F) ──
    0x80: "\u00c4",  # Ä
    0x81: "\u00c5",  # Å
    0x82: "\u00c7",  # Ç
    0x83: "\u00c9",  # É
    0x84: "\u00d1",  # Ñ
    0x85: "\u00d6",  # Ö
    0x86: "\u00dc",  # Ü
    0x87: "\u00e1",  # á
    0x88: "\u00e0",  # à
    0x89: "\u00e2",  # â
    0x8A: "\u00e4",  # ä
    0x8B: "\u00e3",  # ã
    0x8C: "\u00e5",  # å
    0x8D: "\u00e7",  # ç
    0x8E: "\u00e9",  # é
    0x8F: "\u00e8",  # è
    0x90: "\u00ea",  # ê
    0x91: "\u00eb",  # ë
    0x92: "\u00ed",  # í
    0x93: "\u00ec",  # ì
    0x94: "\u00ee",  # î
    0x95: "\u00ef",  # ï
    0x96: "\u00f1",  # ñ
    0x97: "\u00f3",  # ó
    0x98: "\u00f2",  # ò
    0x99: "\u00f4",  # ô
    0x9A: "\u00f6",  # ö
    0x9B: "\u00f5",  # õ
    0x9C: "\u00fa",  # ú
    0x9D: "\u00f9",  # ù
    0x9E: "\u00fb",  # û
    0x9F: "\u00fc",  # ü
    # ── Symbols and punctuation (0xA0-0xFF) ──
    0xA0: "\u00b0",  # ° (degree)
    0xA4: "\u00a7",  # § (section)
    0xA6: "\u00b6",  # ¶ (pilcrow)
    0xA7: "\u00df",  # ß (sharp s) — NOT the Accordance final-sigma marker
    0xAA: "\u2122",  # ™ (trademark)
    0xAB: "\u00b4",  # ´ (acute accent)
    0xAC: "\u00a8",  # ¨ (diaeresis)
    0xAE: "\u00c6",  # Æ
    0xAF: "\u00d8",  # Ø
    0xB0: "\u221e",  # ∞ (infinity) — also used as … (ellipsis) in practice
    0xB1: "\u00b1",  # ± (plus-minus)
    0xB4: "\u00a5",  # ¥ (yen)
    0xB5: "\u00b5",  # µ (micro)
    0xBB: "\u00aa",  # ª (feminine ordinal)
    0xBC: "\u00ba",  # º (masculine ordinal)
    0xBE: "\u00e6",  # æ
    0xBF: "\u00f8",  # ø
    0xC1: "\u00a1",  # ¡ (inverted exclamation) — used in Spanish modules
    0xC2: "\u00ac",  # ¬ (not sign)
    0xC6: "\u00c6",  # Æ (capital)
    0xC7: "\u00ab",  # « (left guillemet)
    0xC8: "\u00bb",  # » (right guillemet)
    0xC9: "\u2026",  # … (ellipsis)
    0xCA: "\u00a0",  # non-breaking space
    0xCB: "\u00c0",  # À (A-grave)
    0xCC: "\u00c3",  # Ã (A-tilde)
    0xCD: "\u00d5",  # Õ (O-tilde)
    0xCE: "\u0152",  # Œ (OE ligature)
    0xCF: "\u0153",  # œ (oe ligature)
    0xD0: "\u2013",  # – (en dash)
    0xD1: "\u2014",  # — (em dash)
    0xD2: "\u201c",  # " (left double quote)
    0xD3: "\u201d",  # " (right double quote)
    0xD4: "\u2018",  # ' (left single quote)
    0xD5: "\u2019",  # ' (right single quote)
    0xD6: "\u00f7",  # ÷ (division)
    0xD7: "\u2021",  # ‡ (double dagger)
    0xD8: "\u00ff",  # ÿ (y-diaeresis)
    0xDA: "\u2044",  # ⁄ (fraction slash)
    0xDB: "\u20ac",  # € (euro) — also used as … (ellipsis) in Accordance
    0xDC: "\u2039",  # ‹ (single left guillemet)
    0xDD: "\u203a",  # › (single right guillemet)
    0xDE: "\ufb01",  # ﬁ (fi ligature)
    0xDF: "\ufb02",  # ﬂ (fl ligature)
    0xE0: "\u2020",  # † (dagger)
    0xE1: "\u00b7",  # · (middle dot)
    0xE5: "\u2022",  # • (bullet)
    0xE6: "\u00b6",  # ¶ (pilcrow) — duplicate of 0xA6
    0xE7: "\u00c1",  # Á (A-acute)
    0xE8: "\u00cb",  # Ë (E-diaeresis)
    0xE9: "\u00c8",  # È (E-grave)
    0xEA: "\u00cd",  # Í (I-acute)
    0xEB: "\u00ce",  # Î (I-circumflex)
    0xEC: "\u00cf",  # Ï (I-diaeresis)
    0xED: "\u00cc",  # Ì (I-grave)
    0xEF: "\u00d4",  # Ô (O-circumflex)
    0xF1: "\u00d2",  # Ò (O-grave)
    0xF2: "\u00da",  # Ú (U-acute)
    0xF3: "\u00db",  # Û (U-circumflex)
    0xF4: "\u00d9",  # Ù (U-grave)
    0xF8: "\u00af",  # ¯ (macron)
    0xFA: "\u00da",  # Ú (U-acute) — duplicate
    0xFC: "\u00b8",  # ¸ (cedilla)
}

# ── Built-in fallback: common English words ──────────────────────────────
# (from text_module.py)
# Used as a fallback when the system dictionary (/usr/share/dict/words) is
# unavailable.  Provides a set of common biblical and general English words
# for footnote-marker detection and word-boundary analysis.
_BUILTIN_WORDS = frozenset(
    {
        # 2-letter
        "to",
        "of",
        "in",
        "it",
        "is",
        "be",
        "he",
        "we",
        "go",
        "no",
        "so",
        "do",
        "my",
        "by",
        "if",
        "or",
        "an",
        "as",
        "at",
        "on",
        "up",
        "us",
        "am",
        "me",
        "hi",
        "oh",
        "ah",
        "ha",
        "lo",
        # 3-letter
        "the",
        "and",
        "for",
        "you",
        "not",
        "but",
        "are",
        "his",
        "was",
        "her",
        "all",
        "can",
        "had",
        "has",
        "one",
        "our",
        "out",
        "who",
        "its",
        "may",
        "she",
        "new",
        "now",
        "how",
        "see",
        "man",
        "any",
        "day",
        "way",
        "set",
        "put",
        "say",
        "let",
        "use",
        "get",
        "yet",
        "old",
        "end",
        "too",
        "big",
        "own",
        "few",
        "run",
        "far",
        "men",
        "yes",
        "god",
        "son",
        "sin",
        "law",
        "off",
        "far",
        "did",
        "lie",
        "sit",
        "saw",
        "try",
        "eat",
        "ran",
        "eye",
        "ear",
        "arm",
        "joy",
        "air",
        "art",
        "ask",
        "bad",
        "bed",
        "box",
        "boy",
        "cry",
        "cup",
        "die",
        "dry",
        "due",
        "egg",
        "fit",
        "fly",
        "fun",
        "gas",
        "gun",
        "guy",
        "hat",
        "hit",
        "hot",
        "ice",
        "ill",
        "job",
        "key",
        "kid",
        "leg",
        "lip",
        "lot",
        "low",
        "mad",
        "map",
        "mix",
        "net",
        "nor",
        "nut",
        "odd",
        "oil",
        "owe",
        "pay",
        "pot",
        "raw",
        "red",
        "row",
        "sad",
        "sea",
        "shy",
        "sky",
        "sum",
        "tea",
        "ten",
        "tie",
        "tip",
        "top",
        "van",
        "war",
        "win",
        "won",
        "yes",
        "yet",
        # 4-letter
        "that",
        "with",
        "this",
        "they",
        "from",
        "have",
        "will",
        "your",
        "been",
        "were",
        "them",
        "when",
        "what",
        "than",
        "then",
        "also",
        "make",
        "like",
        "just",
        "over",
        "such",
        "back",
        "only",
        "most",
        "work",
        "know",
        "year",
        "look",
        "come",
        "want",
        "give",
        "take",
        "must",
        "good",
        "well",
        "even",
        "many",
        "much",
        "part",
        "life",
        "name",
        "home",
        "same",
        "does",
        "each",
        "both",
        "last",
        "long",
        "here",
        "made",
        "said",
        "away",
        "hand",
        "tell",
        "keep",
        "high",
        "hard",
        "next",
        "find",
        "side",
        "need",
        "face",
        "head",
        "open",
        "door",
        "body",
        "city",
        "four",
        "five",
        "love",
        "call",
        "turn",
        "left",
        "help",
        "room",
        "fall",
        "hope",
        "hold",
        "read",
        "land",
        "tree",
        "tree",
        "fear",
        "hear",
        "walk",
        "word",
        "draw",
        "line",
        "food",
        "fire",
        "king",
        "foot",
        "mile",
        "play",
        "week",
        "girl",
        "gold",
        "plan",
        "poor",
        "rich",
        "save",
        "talk",
        "show",
        "mind",
        "sent",
        "took",
        "live",
        "dead",
        "full",
        "lost",
        "holy",
        "born",
        "bear",
        "true",
        "wine",
        "seed",
        "gate",
        "wall",
        "ship",
        "skin",
        "wind",
        "rain",
        "moon",
        "star",
        "bird",
        "fish",
        "root",
        "dark",
        "deep",
        "rest",
        "ride",
        "rule",
        "gift",
        "song",
        "sign",
        "safe",
        "stop",
        "rise",
        "rose",
        "pass",
        "lead",
        "born",
        "past",
        "lost",
        "none",
        "hour",
        "hair",
        "skin",
        "dust",
        "clay",
        "rock",
        "sand",
        "hill",
        "edge",
        "drop",
        "lack",
        "glad",
        "kind",
        "like",
        "bind",
        "hide",
        "lift",
        "fill",
        "sell",
        "pull",
        "push",
        "join",
        "meet",
        "feed",
        "bend",
        "bless",
        # 5-letter
        "there",
        "their",
        "which",
        "would",
        "shall",
        "after",
        "could",
        "being",
        "first",
        "other",
        "great",
        "these",
        "those",
        "where",
        "world",
        "every",
        "still",
        "power",
        "might",
        "water",
        "place",
        "thing",
        "house",
        "heart",
        "light",
        "night",
        "earth",
        "death",
        "three",
        "among",
        "glory",
        "right",
        "voice",
        "peace",
        "sheep",
        "grace",
        "faith",
        "truth",
        "sight",
        "woman",
        "child",
        "until",
        "cried",
        "began",
        "stood",
        "known",
        "alone",
        "fight",
        "short",
        "under",
        "above",
        "white",
        "seven",
        "field",
        "serve",
        "blood",
        "flesh",
        "stone",
        "souls",
        "bread",
        "enter",
        "judge",
        "mouth",
        "price",
        "ready",
        "watch",
        "story",
        "whole",
        "music",
        "sense",
        "small",
        "south",
        "north",
        "stand",
        "bring",
        "cause",
        "force",
        "river",
        "break",
        "build",
        "speak",
        "learn",
        "carry",
        "point",
        "plant",
        "cover",
        "order",
        "offer",
        "spend",
        "prove",
        "train",
        "guard",
        "laugh",
        "dream",
        "green",
        "sweet",
        "watch",
        "count",
        "clean",
        "angry",
        "young",
        "happy",
        "sorry",
        "tower",
        "begin",
        "enemy",
        "sword",
        "glory",
        "honor",
        "crown",
        "cross",
        "daily",
        "table",
        "fruit",
        "grass",
        "flock",
        "flood",
        "cloud",
        "storm",
        "angel",
        "throne",
        "heaven",
        "mount",
        "devil",
        "satan",
        "demon",
        "spoil",
        "serve",
        "wrath",
        "mercy",
        "saint",
        "alter",
        "temple",
        # 6-letter
        "should",
        "people",
        "spirit",
        "before",
        "things",
        "father",
        "mother",
        "become",
        "always",
        "cannot",
        "better",
        "within",
        "little",
        "number",
        "across",
        "nation",
        "family",
        "school",
        "church",
        "return",
        "toward",
        "matter",
        "behind",
        "enough",
        "second",
        "summer",
        "inside",
        "though",
        "change",
        "almost",
        "either",
        "nature",
        "reason",
        "remain",
        "figure",
        "season",
        "certain",
        "person",
        "report",
        "single",
        "minute",
        "record",
        "middle",
        "garden",
        "motion",
        "desire",
        "sister",
        "answer",
        "moment",
        "leader",
        "result",
        "wonder",
        "indeed",
        "entire",
        "hardly",
        "beauty",
        "follow",
        "travel",
        "appear",
        "strong",
        "forest",
        "border",
        "market",
        "finish",
        "demand",
        "master",
        "attend",
        "heaven",
        "temple",
        "spirit",
        "writer",
        "action",
        "accept",
        "decide",
        "weight",
        "murder",
        "charge",
        "prison",
        "winter",
        "author",
        "prayer",
        "praise",
        "thirst",
        "hunger",
        "wisdom",
        "secret",
        "public",
        "suffer",
        "forget",
        "forgive",
        # 7-letter
        "between",
        "through",
        "nothing",
        "because",
        "believe",
        "against",
        "himself",
        "husband",
        "morning",
        "herself",
        "however",
        "evening",
        "certain",
        "brother",
        "without",
        "already",
        "several",
        "whether",
        "perhaps",
        "another",
        "trouble",
        "benefit",
        "attempt",
        "subject",
        "picture",
        "village",
        "century",
        "machine",
        "support",
        "culture",
        "officer",
        "prevent",
        "meeting",
        "pattern",
        "success",
        "message",
        "quality",
        "project",
        "provide",
        "purpose",
        "special",
        "achieve",
        "account",
        "finally",
        "similar",
        "average",
        "concern",
        "produce",
        "however",
        "control",
        "mention",
        "primary",
        "realize",
        "protect",
        "shepherd",
        "pasture",
        "pastures",
        "command",
        "servant",
        "kingdom",
        "nations",
        "eternal",
        "promise",
        # 8+ letter
        "children",
        "together",
        "thought",
        "possible",
        "anything",
        "himself",
        "daughter",
        "interest",
        "whatever",
        "continue",
        "consider",
        "position",
        "question",
        "exercise",
        "complete",
        "language",
        "building",
        "mountain",
        "beautiful",
        "president",
        "everyone",
        "research",
        "remember",
        "strength",
        "property",
        "movement",
        "pressure",
        "probably",
        "material",
        "suddenly",
        "everybody",
        "direction",
        "beginning",
        "according",
        "knowledge",
        "attention",
        "condition",
        "character",
        "statement",
        "religious",
        "political",
        "business",
        "something",
        "community",
        "available",
        "including",
        "important",
        "different",
        "sometimes",
        "therefore",
        "thousand",
        "shall",
        "blessed",
        "everlasting",
        "understanding",
        "diligently",
        "generation",
        "salvation",
        "deliverance",
        "tabernacle",
        "transgression",
        "righteousness",
    }
)

# ── Hermeneia-style title fragment map ────────────────────────────────────
# (from commentary_module.py)
# NT first, then OT special cases.
HERMENEIA_TITLE_MAP = [
    # NT (specific first)
    ("1 Corinthians", "1Corinthians"),
    ("2 Corinthians", "2Corinthians"),
    ("1 Thessalonians", "1Thessalonians"),
    ("2 Thessalonians", "2Thessalonians"),
    ("1 Timothy", "1Timothy"),
    ("2 Timothy", "2Timothy"),
    ("1 Peter", "1Peter"),
    ("2 Peter", "2Peter"),
    ("1 John", "1John"),
    ("2 John", "2John"),
    ("3 John", "3John"),
    ("Matthew", "Matthew"),
    ("Mark", "Mark"),
    ("Luke", "Luke"),
    ("John", "John"),
    ("Acts", "Acts"),
    ("Romans", "Romans"),
    ("Corinthians", "1Corinthians"),
    ("Galatians", "Galatians"),
    ("Ephesians", "Ephesians"),
    ("Philippians", "Philippians"),
    ("Colossians", "Colossians"),
    ("Philemon", "Philemon"),
    ("Thessalonians", "1Thessalonians"),
    ("Timothy", "1Timothy"),
    ("Titus", "Titus"),
    ("Hebrews", "Hebrews"),
    ("James", "James"),
    ("Peter", "1Peter"),
    ("Johannine", "1John"),
    ("Pastoral", "1Timothy"),
    ("Jude", "Jude"),
    ("Revelation", "Revelation"),
    # OT (Hermeneia-specific title forms)
    ("1 Chronicles", "1Chronicles"),
    ("2 Chronicles", "2Chronicles"),
    ("1 Kings", "1Kings"),
    ("2 Kings", "2Kings"),
    ("1 Samuel", "1Samuel"),
    ("2 Samuel", "2Samuel"),
    ("Qoheleth", "Ecclesiastes"),
    ("Song of Songs", "SongofSolomon"),
    ("Joel and Amos", "Joel"),
    # OT books (explicit entries for robustness, fallback handles most)
    ("Fourth Ezra", None),  # apocryphal, not canonical Ezra
    ("Jeremiah", "Jeremiah"),
    ("Ezekiel", "Ezekiel"),
    ("Daniel", "Daniel"),
    ("Hosea", "Hosea"),
    ("Micah", "Micah"),
    ("Zephaniah", "Zephaniah"),
    ("Amos", "Amos"),
    ("Obadiah", "Obadiah"),
    ("Jonah", "Jonah"),
    ("Nahum", "Nahum"),
    ("Habakkuk", "Habakkuk"),
    ("Haggai", "Haggai"),
    ("Zechariah", "Zechariah"),
    ("Malachi", "Malachi"),
    ("Psalms", "Psalms"),
    ("Proverbs", "Proverbs"),
    ("Job", "Job"),
    ("Ruth", "Ruth"),
    ("Lamentations", "Lamentations"),
    ("Esther", "Esther"),
    ("Ezra", "Ezra"),
    ("Nehemiah", "Nehemiah"),
    ("Genesis", "Genesis"),
    ("Exodus", "Exodus"),
    ("Leviticus", "Leviticus"),
    ("Numbers", "Numbers"),
    ("Deuteronomy", "Deuteronomy"),
    ("Joshua", "Joshua"),
    ("Judges", "Judges"),
    ("Isaiah", "Isaiah"),
    # NT alternate / special titles
    ("Sermon on the Mount", "Matthew"),
]

# ── Skip/unparseable module patterns ──────────────────────────────────────
# (from commentary_module.py)
# Only skip modules with truly unparseable binary formats.
# All previously-skipped patterns (Crossrefs, AF, APOL, Philo,
# Qumran, Josephus, ORIGEN, Treasury, Hermeneia AF/Q/2, GNT Notes,
# Outlines, Apparatus) have been verified readable with the
# existing format detection logic.
_SKIP_PATTERNS: list[str] = []

# ── Non-English module patterns ───────────────────────────────────────────
# (from commentary_module.py)
# All non-English modules (LBLA, NBLH, VDC2014) confirmed readable
# with the existing Mac Roman decoder.  Leave empty as a reserved
# slot for future genuine non-parseable encodings.
_NONENG_PATTERNS: list[str] = []

# ── Notes module whitelist ────────────────────────────────────────────────
# (from commentary_module.py)
_NOTES_WHITELIST = {
    "NABRE Notes",
    "ESV Notes",
    "NET Notes",
    "NRSVue Notes",
    "NAS95S Notes",
    "AF-E Notes",
    "AF-T Notes",
    "APOL-T Notes",
    "ASV Notes",
    "CEB Notes",
    "CEB2 Notes",
    "GNT Notes",
    "LBLA Notes",
    "MESSAGE Notes",
    "NAS Notes",
    "NBLH Notes",
    "NETS Notes",
    "NETS2 Notes",
    "NRSVue2 Notes",
    "ORIGEN Notes",
    "VDC2014 Note",
    "WEB Notes",
}
