from typing import Dict, Iterator, List, Optional, Tuple

class Document:
    def __init__(self, url: str, doc: str): ...

class ContextExtractor:
    def __init__(
        self,
        ignored_tags: Optional[List[str]] = None,
        discard_tags: Optional[List[str]] = None,
        same_content_level_elements: Optional[List[str]] = None,
        header_elements: Optional[List[str]] = None,
        only_keep_inline_tags: bool = True,
    ): ...

class TableExtractor:
    def __init__(
        self,
        *,
        context_extractor: ContextExtractor,
        ignored_tags: Optional[List[str]] = None,
        discard_tags: Optional[List[str]] = None,
        only_keep_inline_tags: bool = True,
    ) -> None: ...
    def extract(
        self,
        url: str,
        doc: str,
        auto_span: bool = True,
        auto_pad: bool = True,
        extract_context: bool = True,
    ) -> List[Table]: ...

class Table:
    id: str
    url: str
    caption: str

    def __init__(
        self,
        id: str,
        url: str,
        caption: str,
        attrs: Dict[str, str],
        context: List[ContentHierarchy],
        rows: List[Row],
    ) -> None: ...
    @property
    def attrs(self) -> Dict[str, str]: ...
    @property
    def context(self) -> List[ContentHierarchy]: ...
    @property
    def rows(self) -> List[Row]: ...
    def span(self) -> Table: ...
    def pad(self) -> Optional[Table]: ...
    def n_rows(self) -> int: ...
    def shape(self) -> Tuple[int, int]: ...
    def get_row(self, ri: int) -> Row: ...
    def get_cell(self, ri: int, ci: int) -> Cell: ...
    def iter_cells(self) -> Iterator[Cell]: ...
    def enumerate_cells(self) -> Iterator[Tuple[int, int, Cell]]: ...
    def iter_rows(self) -> Iterator[Row]: ...
    def to_bytes(self) -> bytes: ...
    @staticmethod
    def from_bytes(dat: bytes) -> Table: ...
    def to_json(self) -> str: ...
    @staticmethod
    def from_json(dat: str) -> Table: ...
    def to_base64(self) -> str: ...
    @staticmethod
    def from_base64(dat: str) -> Table: ...
    def to_dict(self) -> dict: ...
    def to_list(self) -> List[List[str]]: ...

class Row:
    def __init__(self, cells: List[Cell], attrs: Dict[str, str]) -> None: ...
    @property
    def cells(self) -> List[Cell]: ...
    @property
    def attrs(self) -> Dict[str, str]: ...
    def get_cell(self, ci: int) -> Cell: ...
    def iter_cells(self) -> Iterator[Cell]: ...
    def to_dict(self) -> dict: ...
    def to_list(self) -> List[str]: ...

class Cell:
    is_header: bool
    rowspan: int
    colspan: int
    value: RichText

    def __init__(
        self, is_header: bool, rowspan: int, colspan: int, value: RichText
    ) -> None: ...
    @property
    def attrs(self) -> Dict[str, str]: ...
    def to_dict(self) -> dict: ...

class ContentHierarchy:
    level: int
    heading: RichText

    @property
    def content_before(self) -> List[RichText]: ...
    @property
    def content_after(self) -> List[RichText]: ...
    def to_dict(self) -> dict: ...
    @staticmethod
    def from_dict(c: dict) -> ContentHierarchy: ...

class RichText:
    @staticmethod
    def from_str(text: str) -> RichText: ...
    @property
    def text(self) -> str: ...
    def len(self) -> int: ...
    def iter_element_id(self) -> Iterator[int]: ...
    def iter_element_id_preorder(self) -> Iterator[int]: ...
    def get_element_tag_by_id(self, id: int) -> str: ...
    def get_element_attr_by_id(self, id: int, attr: str) -> Optional[str]: ...
    def set_element_attr_by_id(self, id: int, attr: str, value: str) -> None: ...
    def get_element_by_id(self, id: int) -> RichTextElement: ...
    def set_element_by_id(self, id: int, RichTextElement) -> None: ...
    def to_dict(self) -> dict: ...
    @staticmethod
    def from_dict(c: dict) -> RichText: ...

class RichTextElement:
    @property
    def tag(self) -> str: ...
    @property
    def start(self) -> int: ...
    @property
    def end(self) -> int: ...
    @property
    def attrs(self) -> Dict[str, str]: ...
    def get_attr(self, name: str) -> str: ...
    def has_attr(self, name: str) -> bool: ...
    def to_dict(self) -> dict: ...
    @staticmethod
    def from_dict(c: dict) -> RichTextElement: ...
