from collections.abc import Iterable
from typing import Any, Self

from django.db import models
from django.db.models import QuerySet

class Node(models.Model):
    TREEBEARD_IDENTIFYING_FIELD: str | None
    MOVENODE_FORM_EXCLUDED_FIELDS: tuple[str, ...]
    node_order_by: list[str] | tuple[str, ...] | None

    @classmethod
    def add_root(cls, **kwargs: Any) -> Self: ...
    @classmethod
    def load_bulk(
        cls, bulk_data: list[dict[str, Any]], parent: Self | None = ..., keep_ids: bool = ...
    ) -> list[int]: ...
    @classmethod
    def dump_bulk(cls, parent: Self | None = ..., keep_ids: bool = ...) -> list[dict[str, Any]]: ...
    @classmethod
    def get_root_nodes(cls) -> QuerySet[Self]: ...
    @classmethod
    def get_first_root_node(cls) -> Self | None: ...
    @classmethod
    def get_last_root_node(cls) -> Self | None: ...
    @classmethod
    def find_problems(cls) -> tuple[list[int], list[int], list[int], list[int], list[int]]: ...
    @classmethod
    def fix_tree(cls) -> None: ...
    @classmethod
    def get_tree(cls, parent: Self | None = ...) -> QuerySet[Self] | list[Self]: ...
    @classmethod
    def get_descendants_group_count(cls, parent: Self | None = ...) -> QuerySet[Self] | list[Self]: ...
    def get_depth(self) -> int: ...
    def get_siblings(self) -> QuerySet[Self]: ...
    def get_children(self) -> QuerySet[Self]: ...
    def get_children_count(self) -> int: ...
    def get_descendants(self) -> QuerySet[Self] | list[Self]: ...
    def get_descendant_count(self) -> int: ...
    def get_first_child(self) -> Self | None: ...
    def get_last_child(self) -> Self | None: ...
    def get_first_sibling(self) -> Self | None: ...
    def get_last_sibling(self) -> Self | None: ...
    def get_prev_sibling(self) -> Self | None: ...
    def get_next_sibling(self) -> Self | None: ...
    def is_sibling_of(self, node: Self) -> bool: ...
    def is_child_of(self, node: Self) -> bool: ...
    def is_descendant_of(self, node: Self) -> bool: ...
    def add_child(self, **kwargs: Any) -> Self: ...
    def add_sibling(self, pos: str | None = ..., **kwargs: Any) -> Self: ...
    def get_root(self) -> Self: ...
    def is_root(self) -> bool: ...
    def is_leaf(self) -> bool: ...
    def get_ancestors(self) -> QuerySet[Self] | list[Self]: ...
    def get_parent(self, update: bool = ...) -> Self | None: ...
    def move(self, target: Self, pos: str | None = ...) -> None: ...
    def delete(self, *args: Any, **kwargs: Any) -> tuple[int, dict[str, int]]: ...
    def get_sorted_pos_queryset(self, siblings: QuerySet[Self], newobj: Self) -> QuerySet[Self]: ...
    def refresh_from_db(
        self,
        using: str | None = ...,
        fields: Iterable[str] | None = ...,
        from_queryset: QuerySet[Self] | None = ...,
    ) -> None: ...
    @classmethod
    def get_annotated_list_qs(cls, qs: QuerySet[Self]) -> list[tuple[Self, dict[str, Any]]]: ...
    @classmethod
    def get_annotated_list(
        cls, parent: Self | None = ..., max_depth: int | None = ...
    ) -> list[tuple[Self, dict[str, Any]]]: ...
    @classmethod
    def tree_model(cls) -> type[Self]: ...

    class Meta:
        abstract: bool
