"""Button element model."""
from libraries import logger
from libraries.workitems import INPUTS
from t_page_object.base_element import BaseElement


class ButtonElement(BaseElement):
    """Class for button element model."""

    def __init__(self, xpath: str, dev_safe_sensitive: bool = False, wait: bool = True, timeout: int = 10):
        """
        Initializes a button element with specified parameters.

        Args:
            xpath (str): The XPath expression used to locate the button element.
            dev_safe_sensitive (bool, optional): Indicates whether the button is
            sensitive to development-safe operations. Defaults to False.
            wait (bool, optional): Whether to wait for the button element to be present. Defaults to True.

        Returns:
            None
        """
        super().__init__(xpath=xpath, wait=wait, timeout=timeout)
        self.dev_safe_sensitive = dev_safe_sensitive

    def click(self) -> None:
        """Main click method for button element."""
        if self.dev_safe_sensitive and INPUTS.DEV_SAFE_MODE:
            logger.info("Button not clicked: The element is dev safe sensitive, and DEV_SAFE_MODE is enabled")
        else:
            super().__getattr__("click_element_if_visible")()
            logger.info("Button clicked: DEV_SAFE_MODE is disabled")

    def click_button(self) -> None:
        """Redirects to click method."""
        self.click()

    def click_button_when_visible(self) -> None:
        """Redirects to click method."""
        self.click()

    def click_button_if_visible(self) -> None:
        """Redirects to click method."""
        self.click()

    def click_element(self) -> None:
        """Redirects to click method."""
        self.click()

    def click_element_if_visible(self) -> None:
        """Redirects to click method."""
        self.click()

    def click_element_when_visible(self) -> None:
        """Redirects to click method."""
        self.click()

    def click_element_when_clickable(self) -> None:
        """Redirects to click method."""
        self.click()
