from collections.abc import Iterable

from django.contrib.auth.models import AbstractBaseUser
from django.db.models import QuerySet
from wagtail.models import GroupPagePermission, Page
from wagtail.permission_policies.base import OwnershipPermissionPolicy

class PagePermissionPolicy(OwnershipPermissionPolicy):
    permission_cache_name: str

    def __init__(self, model: type[Page] = ...) -> None: ...
    def get_all_permissions_for_user(self, user: AbstractBaseUser) -> QuerySet[GroupPagePermission]: ...
    def user_has_permission(self, user: AbstractBaseUser, action: str) -> bool: ...
    def user_has_any_permission(self, user: AbstractBaseUser, actions: Iterable[str]) -> bool: ...
    def users_with_any_permission(
        self, actions: Iterable[str], include_superusers: bool = True
    ) -> QuerySet[AbstractBaseUser]: ...
    def users_with_permission(self, action: str, include_superusers: bool = True) -> QuerySet[AbstractBaseUser]: ...
    def user_has_permission_for_instance(self, user: AbstractBaseUser, action: str, instance: Page) -> bool: ...
    def user_has_any_permission_for_instance(
        self, user: AbstractBaseUser, actions: Iterable[str], instance: Page
    ) -> bool: ...
    def instances_user_has_any_permission_for(
        self, user: AbstractBaseUser, actions: Iterable[str]
    ) -> QuerySet[Page]: ...
    def users_with_any_permission_for_instance(
        self, actions: Iterable[str], instance: Page, include_superusers: bool = True
    ) -> QuerySet[AbstractBaseUser]: ...
    def users_with_permission_for_instance(
        self, action: str, instance: Page, include_superusers: bool = True
    ) -> QuerySet[AbstractBaseUser]: ...
    def instances_with_direct_explore_permission(self, user: AbstractBaseUser) -> QuerySet[Page] | list[Page]: ...
    def explorable_root_instance(self, user: AbstractBaseUser) -> Page | None: ...
    def explorable_instances(self, user: AbstractBaseUser) -> QuerySet[Page]: ...
