"""
This type stub file was generated by pyright.
"""

from functools import cached_property
from typing import Generic, TypeVar
from tree_sitter import Node as TSNode
from graph_sitter.codebase.codebase_graph import CodebaseGraph
from graph_sitter.core.autocommit import reader, writer
from graph_sitter.core.expressions import Expression
from graph_sitter.core.expressions.name import Name
from graph_sitter.core.interfaces.editable import Editable
from graph_sitter.core.interfaces.has_name import HasName
from graph_sitter.core.node_id_factory import NodeId
from graph_sitter.typescript.detached_symbols.jsx.expression import JSXExpression
from graph_sitter.typescript.detached_symbols.jsx.prop import JSXProp
from graph_sitter.writer_decorators import ts_apidoc

Parent = TypeVar("Parent", bound="Editable")
@ts_apidoc
class JSXElement(Expression[Parent], HasName, Generic[Parent]):
    """Abstract representation of TSX/JSX elements, e.g. `<MyComponent />`. This allows for many React-specific modifications, like adding props, changing the name, etc."""
    _name_node: Name | None
    def __init__(self, ts_node: TSNode, file_node_id: NodeId, G: CodebaseGraph, parent: Parent) -> None:
        ...
    
    @cached_property
    @reader
    def jsx_elements(self) -> list[JSXElement]:
        """Returns a list of JSX elements nested within the current element.

        Gets all JSX elements that are descendants of this element in the syntax tree, excluding the element itself.
        This includes both regular JSX elements (`<Tag>...</Tag>`) and self-closing elements (`<Tag />`).

        Args:
            None

        Returns:
            list[JSXElement]: A list of JSXElement objects representing all nested JSX elements.
        """
        ...
    
    @cached_property
    @reader
    def expressions(self) -> list[JSXExpression]:
        """Gets all JSX expressions within the JSX element.

        Retrieves all JSX expressions that are descendant nodes of the current JSX element, including expressions in child elements and attributes.

        Returns:
            list[JSXExpression]: A list of JSX expression objects found within this element, excluding the current element itself.
        """
        ...
    
    @property
    @reader
    def props(self) -> list[JSXProp]:
        """Retrieves all JSXProps (attributes) from a JSX element.

        Gets all props (attributes) on the current JSX element. For example, in `<MyComponent prop1="value" />`, this would return a list with one JSXProp object representing `prop1="value"`.

        Args:
            self: The JSXElement instance.

        Returns:
            list[JSXProp]: A list of JSXProp objects representing each attribute on the element.
        """
        ...
    
    @reader
    def get_prop(self, name: str) -> JSXProp | None:
        """Returns the JSXProp with the given name from the JSXElement.

        Searches through the element's props to find a prop with a matching name.

        Args:
            name (str): The name of the prop to find.

        Returns:
            JSXProp | None: The matching JSXProp object if found, None if not found.
        """
        ...
    
    @property
    def attributes(self) -> list[JSXProp]:
        """Returns all JSXProp on this JSXElement, an alias for JSXElement.props.

        Returns all JSXProp attributes (props) on this JSXElement. For example, for a JSX element like
        `<MyComponent prop1="value" />`, this would return a list containing one JSXProp object.

        Returns:
            list[JSXProp]: A list of JSXProp objects representing each attribute/prop on the JSXElement.
        """
        ...
    
    @writer
    def set_name(self, name: str) -> None:
        """Sets the name of a JSXElement by modifying both opening and closing tags.

        Updates the name of a JSX element, affecting both self-closing tags (`<Tag />`) and elements with closing tags (`<Tag></Tag>`).

        Args:
            name (str): The new name to set for the JSX element.

        Returns:
            None: The method modifies the JSXElement in place.
        """
        ...
    
    @writer
    def add_prop(self, prop_name: str, prop_value: str) -> None:
        """Adds a new prop to a JSXElement.

        Adds a prop with the specified name and value to the JSXElement. If the element already has props,
        the new prop is added after the last existing prop. If the element has no props, the new prop is
        added immediately after the element name.

        Args:
            prop_name (str): The name of the prop to add.
            prop_value (str): The value of the prop to add.

        Returns:
            None
        """
        ...
    
    @writer
    def wrap(self, opening_tag: str, closing_tag: str) -> None:
        """Wraps the current JSXElement with the provided opening and closing tags, properly handling indentation.

        Args:
            opening_tag (str): The opening JSX tag to wrap around the current element (e.g. `<div prop={value}>`)
            closing_tag (str): The closing JSX tag to wrap around the current element (e.g. `</div>`)
        """
        ...
    


