from typing import Any, List, Optional, Union, Dict, Iterator
from ._openxlsx import XLDocument, XLWorkbook, XLStyles, XLProperty, XLDefinedNames
from .worksheet import Worksheet
from .styles import Font, Fill, Border, Alignment, Style, Protection

class DocumentProperties:
    def __init__(self, doc: XLDocument) -> None: ...
    def __getitem__(self, key: Union[XLProperty, str]) -> Any: ...
    def __setitem__(self, key: Union[XLProperty, str], value: Any) -> None: ...
    def __delitem__(self, key: Union[XLProperty, str]) -> None: ...
    @property
    def title(self) -> str: ...
    @title.setter
    def title(self, value: str) -> None: ...
    @property
    def creator(self) -> str: ...
    @creator.setter
    def creator(self, value: str) -> None: ...
    @property
    def last_modified_by(self) -> str: ...
    @last_modified_by.setter
    def last_modified_by(self, value: str) -> None: ...
    @property
    def subject(self) -> str: ...
    @subject.setter
    def subject(self, value: str) -> None: ...
    @property
    def description(self) -> str: ...
    @description.setter
    def description(self, value: str) -> None: ...
    @property
    def keywords(self) -> str: ...
    @keywords.setter
    def keywords(self, value: str) -> None: ...
    @property
    def category(self) -> str: ...
    @category.setter
    def category(self, value: str) -> None: ...
    @property
    def company(self) -> str: ...
    @company.setter
    def company(self, value: str) -> None: ...

class CustomProperties:
    def __init__(self, doc: XLDocument) -> None: ...
    def __getitem__(self, name: str) -> str: ...
    def __setitem__(self, name: str, value: Any) -> None: ...
    def __delitem__(self, name: str) -> None: ...
    def __contains__(self, name: str) -> bool: ...

class Workbook:
    _doc: XLDocument
    _sheets: Dict[str, Worksheet]
    
    @property
    def defined_names(self) -> XLDefinedNames: ...
    
    def __init__(
        self, filename: Optional[str] = None, force_overwrite: bool = True
    ) -> None: ...
    def save(
        self, filename: Optional[str] = None, force_overwrite: bool = True
    ) -> None: ...
    async def save_async(
        self, filename: Optional[str] = None, force_overwrite: bool = True
    ) -> None: ...
    def close(self) -> None: ...
    async def close_async(self) -> None: ...
    def __enter__(self) -> Workbook: ...
    def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None: ...
    async def __aenter__(self) -> Workbook: ...
    async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None: ...
    @property
    def styles(self) -> XLStyles: ...
    @property
    def properties(self) -> DocumentProperties: ...
    @property
    def custom_properties(self) -> CustomProperties: ...
    def add_style(
        self,
        font: Optional[Union[Font, Style, int]] = None,
        fill: Optional[Union[Fill, int]] = None,
        border: Optional[Union[Border, int]] = None,
        alignment: Optional[Alignment] = None,
        number_format: Optional[Union[str, int]] = None,
        protection: Optional[Protection] = None,
    ) -> int: ...
    async def add_style_async(
        self,
        font: Optional[Union[Font, Style, int]] = None,
        fill: Optional[Union[Fill, int]] = None,
        border: Optional[Union[Border, int]] = None,
        alignment: Optional[Alignment] = None,
        number_format: Optional[Union[str, int]] = None,
        protection: Optional[Protection] = None,
    ) -> int: ...
    @property
    def workbook(self) -> XLWorkbook: ...
    @property
    def active(self) -> Worksheet: ...
    @active.setter
    def active(self, ws: Worksheet) -> None: ...
    def create_sheet(
        self, title: Optional[str] = None, index: Optional[int] = None
    ) -> Worksheet: ...
    async def create_sheet_async(
        self, title: Optional[str] = None, index: Optional[int] = None
    ) -> Worksheet: ...
    def remove(self, worksheet: Worksheet) -> None: ...
    async def remove_async(self, worksheet: Worksheet) -> None: ...
    def copy_worksheet(self, from_worksheet: Worksheet) -> Worksheet: ...
    async def copy_worksheet_async(self, from_worksheet: Worksheet) -> Worksheet: ...
    @property
    def sheetnames(self) -> List[str]: ...
    def __getitem__(self, key: str) -> Worksheet: ...
    def __delitem__(self, key: str) -> None: ...
    def __iter__(self) -> Iterator[Worksheet]: ...
    def __len__(self) -> int: ...
    def __contains__(self, key: str) -> bool: ...
    def get_archive_entries(self) -> List[str]: ...
    def has_archive_entry(self, path: str) -> bool: ...
    def get_archive_entry(self, path: str) -> bytes: ...
    def get_embedded_images(self) -> List[Any]: ...
    def get_image_data(self, image_path_or_name: str) -> bytes: ...
    def extract_images(self, output_dir: str) -> List[str]: ...
    async def extract_images_async(self, output_dir: str) -> List[str]: ...

def load_workbook(filename: str) -> Workbook: ...
async def load_workbook_async(filename: str) -> Workbook: ...
