"""Bible-specific constants."""

import re

__all__ = [
    "BOOK_ABBREVIATIONS",
    "DEFAULT_TRANSLATION",
    "PARTIAL_REFERENCE_PATTERNS",
    "REFERENCE_PATTERNS",
    "SUPPORTED_TRANSLATIONS",
    "TRANSLATION_ESV",
    "TRANSLATION_KJV",
]

# Bible translation constants
DEFAULT_TRANSLATION = "kjv"
SUPPORTED_TRANSLATIONS = ("kjv", "esv")

# Translation identifiers
TRANSLATION_ESV = "esv"
TRANSLATION_KJV = "kjv"

# Regular expression patterns
_TX = "|".join(SUPPORTED_TRANSLATIONS)
REFERENCE_PATTERNS = [
    # Book + chapter:verse[- (U+2011-U+2015) verse] [translation]
    re.compile(
        rf"^(?P<book>[\w\s]+?)\s+(?P<ref>\d+:\d+(?:\s*[-\u2011-\u2015]\s*\d+)?)\s*(?P<translation>{_TX})?$",
        re.IGNORECASE,
    ),
    # Book + chapter [translation]
    re.compile(
        rf"^(?P<book>[\w\s]+?)\s+(?P<ref>\d+)\s*(?P<translation>{_TX})?$",
        re.IGNORECASE,
    ),
]

# Partial matching patterns (for detect_references_anywhere mode)
# More restrictive patterns to reduce false positives
_PARTIAL_BOOK_PATTERN_STR = (
    r"(?:[1-3]\s+[A-Za-z]+(?:\s+[A-Za-z]+)?|[A-Za-z]+(?:\s+of\s+[A-Za-z]+)?)"
)
PARTIAL_REFERENCE_PATTERNS = [
    # Book + chapter:verse[- (U+2011-U+2015) verse] [translation] (anywhere in message)
    # Matches specific Bible book patterns to reduce false positives
    re.compile(
        rf"\b(?P<book>{_PARTIAL_BOOK_PATTERN_STR})\s+(?P<ref>\d+:\d+(?:\s*[-\u2011-\u2015]\s*\d+)?)\s*(?P<translation>{_TX})?\b",
        re.IGNORECASE,
    ),
    # Book + chapter [translation] (anywhere in message)
    # Matches specific Bible book patterns to reduce false positives
    re.compile(
        rf"\b(?P<book>{_PARTIAL_BOOK_PATTERN_STR})\s+(?P<ref>\d+)\s*(?P<translation>{_TX})?\b",
        re.IGNORECASE,
    ),
]

# Bible book abbreviations mapping
BOOK_ABBREVIATIONS = {
    # Old Testament
    "gen": "Genesis",
    "ge": "Genesis",
    "gn": "Genesis",
    "exo": "Exodus",
    "ex": "Exodus",
    "lev": "Leviticus",
    "le": "Leviticus",
    "lv": "Leviticus",
    "num": "Numbers",
    "nu": "Numbers",
    "nm": "Numbers",
    "deut": "Deuteronomy",
    "de": "Deuteronomy",
    "dt": "Deuteronomy",
    "josh": "Joshua",
    "jos": "Joshua",
    "judg": "Judges",
    "jdg": "Judges",
    "jg": "Judges",
    "ruth": "Ruth",
    "ru": "Ruth",
    "1 sam": "1 Samuel",
    "1sa": "1 Samuel",
    "1s": "1 Samuel",
    "2 sam": "2 Samuel",
    "2sa": "2 Samuel",
    "2s": "2 Samuel",
    "1 kings": "1 Kings",
    "1ki": "1 Kings",
    "1k": "1 Kings",
    "2 kings": "2 Kings",
    "2ki": "2 Kings",
    "2k": "2 Kings",
    "1 chron": "1 Chronicles",
    "1ch": "1 Chronicles",
    "2 chron": "2 Chronicles",
    "2ch": "2 Chronicles",
    "ezra": "Ezra",
    "ezr": "Ezra",
    "neh": "Nehemiah",
    "ne": "Nehemiah",
    "est": "Esther",
    "es": "Esther",
    "job": "Job",
    "jb": "Job",
    "psalm": "Psalms",
    "psalms": "Psalms",
    "psa": "Psalms",
    "ps": "Psalms",
    "prov": "Proverbs",
    "pro": "Proverbs",
    "pr": "Proverbs",
    "eccles": "Ecclesiastes",
    "ecc": "Ecclesiastes",
    "ec": "Ecclesiastes",
    "song": "Song of Solomon",
    "sos": "Song of Solomon",
    "so": "Song of Solomon",
    "song of songs": "Song of Solomon",
    "cant": "Song of Solomon",
    "canticles": "Song of Solomon",
    "isa": "Isaiah",
    "is": "Isaiah",
    "jer": "Jeremiah",
    "je": "Jeremiah",
    "lam": "Lamentations",
    "la": "Lamentations",
    "ezek": "Ezekiel",
    "eze": "Ezekiel",
    "ez": "Ezekiel",
    "dan": "Daniel",
    "da": "Daniel",
    "dn": "Daniel",
    "hos": "Hosea",
    "ho": "Hosea",
    "joel": "Joel",
    "joe": "Joel",
    "jl": "Joel",
    "amos": "Amos",
    "am": "Amos",
    "obad": "Obadiah",
    "ob": "Obadiah",
    "jonah": "Jonah",
    "jon": "Jonah",
    "mic": "Micah",
    "mi": "Micah",
    "nah": "Nahum",
    "na": "Nahum",
    "hab": "Habakkuk",
    "ha": "Habakkuk",
    "zeph": "Zephaniah",
    "zep": "Zephaniah",
    "zp": "Zephaniah",
    "hag": "Haggai",
    "hg": "Haggai",
    "zech": "Zechariah",
    "zec": "Zechariah",
    "zc": "Zechariah",
    "mal": "Malachi",
    "ml": "Malachi",
    # New Testament
    "matt": "Matthew",
    "mt": "Matthew",
    "mark": "Mark",
    "mar": "Mark",
    "mk": "Mark",
    "luke": "Luke",
    "lk": "Luke",
    "john": "John",
    "jn": "John",
    "acts": "Acts",
    "ac": "Acts",
    "rom": "Romans",
    "ro": "Romans",
    "1 cor": "1 Corinthians",
    "1co": "1 Corinthians",
    "2 cor": "2 Corinthians",
    "2co": "2 Corinthians",
    "gal": "Galatians",
    "ga": "Galatians",
    "eph": "Ephesians",
    "ep": "Ephesians",
    "phil": "Philippians",
    "phi": "Philippians",
    "php": "Philippians",
    "col": "Colossians",
    "co": "Colossians",
    "1 thess": "1 Thessalonians",
    "1th": "1 Thessalonians",
    "2 thess": "2 Thessalonians",
    "2th": "2 Thessalonians",
    "1 tim": "1 Timothy",
    "1ti": "1 Timothy",
    "2 tim": "2 Timothy",
    "2ti": "2 Timothy",
    "titus": "Titus",
    "ti": "Titus",
    "philem": "Philemon",
    "phm": "Philemon",
    "pm": "Philemon",
    "heb": "Hebrews",
    "he": "Hebrews",
    "james": "James",
    "jm": "James",
    "1 pet": "1 Peter",
    "1pe": "1 Peter",
    "1pt": "1 Peter",
    "2 pet": "2 Peter",
    "2pe": "2 Peter",
    "2pt": "2 Peter",
    "1 john": "1 John",
    "1jn": "1 John",
    "2 john": "2 John",
    "2jn": "2 John",
    "3 john": "3 John",
    "3jn": "3 John",
    "jude": "Jude",
    "jd": "Jude",
    "rev": "Revelation",
    "re": "Revelation",
}
