"""Shared data tables and constants for wcwidth.py, _wcwidth.py, and _wcswidth.py."""

# local
from .table_mc import CATEGORY_MC
from .table_wide import WIDE_EASTASIAN
from .table_zero import ZERO_WIDTH
from .table_grapheme import EXTENDED_PICTOGRAPHIC, GRAPHEME_REGIONAL_INDICATOR
from .table_ambiguous import AMBIGUOUS_EASTASIAN
from .unicode_versions import list_versions

__all__ = (
    "_REGIONAL_INDICATOR_SET",
    "_ISC_VIRAMA_SET",
    "_LATEST_VERSION",
    "_CATEGORY_MC_TABLE",
    "_EMOJI_ZWJ_SET",
    "_FITZPATRICK_RANGE",
    "_ZERO_WIDTH_TABLE",
    "_WIDE_EASTASIAN_TABLE",
    "_AMBIGUOUS_TABLE",
)

_REGIONAL_INDICATOR_SET = frozenset(
    range(GRAPHEME_REGIONAL_INDICATOR[0][0], GRAPHEME_REGIONAL_INDICATOR[0][1] + 1)
)
_ISC_VIRAMA_SET = frozenset((
    0x094D,   # DEVANAGARI SIGN VIRAMA
    0x09CD,   # BENGALI SIGN VIRAMA
    0x0A4D,   # GURMUKHI SIGN VIRAMA
    0x0ACD,   # GUJARATI SIGN VIRAMA
    0x0B4D,   # ORIYA SIGN VIRAMA
    0x0BCD,   # TAMIL SIGN VIRAMA
    0x0C4D,   # TELUGU SIGN VIRAMA
    0x0CCD,   # KANNADA SIGN VIRAMA
    0x0D4D,   # MALAYALAM SIGN VIRAMA
    0x0DCA,   # SINHALA SIGN AL-LAKUNA
    0x1B44,   # BALINESE ADEG ADEG
    0xA806,   # SYLOTI NAGRI SIGN HASANTA
    0xA8C4,   # SAURASHTRA SIGN VIRAMA
    0xA9C0,   # JAVANESE PANGKON
    0x11046,  # BRAHMI VIRAMA
    0x110B9,  # KAITHI SIGN VIRAMA
    0x111C0,  # SHARADA SIGN VIRAMA
    0x11235,  # KHOJKI SIGN VIRAMA
    0x1134D,  # GRANTHA SIGN VIRAMA
    0x11442,  # NEWA SIGN VIRAMA
    0x114C2,  # TIRHUTA SIGN VIRAMA
    0x115BF,  # SIDDHAM SIGN VIRAMA
    0x1163F,  # MODI SIGN VIRAMA
    0x116B6,  # TAKRI SIGN VIRAMA
    0x11839,  # DOGRA SIGN VIRAMA
    0x119E0,  # NANDINAGARI SIGN VIRAMA
    0x11C3F,  # BHAIKSUKI SIGN VIRAMA
))
# pylint: disable=invalid-name
_LATEST_VERSION = list_versions()[-1]
_CATEGORY_MC_TABLE = CATEGORY_MC[_LATEST_VERSION]
_EMOJI_ZWJ_SET = frozenset(
    cp for lo, hi in EXTENDED_PICTOGRAPHIC for cp in range(lo, hi + 1)
) | _REGIONAL_INDICATOR_SET
_FITZPATRICK_RANGE = (0x1F3FB, 0x1F3FF)

_ZERO_WIDTH_TABLE = ZERO_WIDTH[_LATEST_VERSION]
_WIDE_EASTASIAN_TABLE = WIDE_EASTASIAN[_LATEST_VERSION]
_AMBIGUOUS_TABLE = AMBIGUOUS_EASTASIAN[_LATEST_VERSION]
