from typing import Any

from django.db import models
from django.db.models import QuerySet
from django.forms import BaseForm
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
from django.utils.functional import cached_property
from django.views.generic import TemplateView
from django.views.generic.edit import BaseCreateView, BaseDeleteView, BaseUpdateView
from wagtail.admin.compare import FieldComparison
from wagtail.admin.filters import WagtailFilterSet
from wagtail.admin.forms.models import WagtailAdminModelForm
from wagtail.admin.panels.base import Panel
from wagtail.admin.ui.components import MediaContainer
from wagtail.admin.ui.tables import Column
from wagtail.admin.views.generic.base import BaseListingView, WagtailAdminTemplateMixin
from wagtail.admin.views.generic.mixins import (
    BeforeAfterHookMixin,
    HookResponseMixin,
    LocaleMixin,
    PanelMixin,
)
from wagtail.admin.views.generic.permissions import PermissionCheckedMixin
from wagtail.admin.views.mixins import SpreadsheetExportMixin
from wagtail.admin.widgets.button import Button, ButtonWithDropdown, HeaderButton, ListingButton
from wagtail.models import Locale
from wagtail.models.audit_log import BaseLogEntry
from wagtail.models.reference_index import ReferenceGroups
from wagtail.models.revisions import Revision

class IndexView(
    SpreadsheetExportMixin,
    LocaleMixin,
    PermissionCheckedMixin,
    BaseListingView,
):
    model: type[models.Model] | None
    template_name: str
    results_template_name: str
    add_url_name: str | None
    edit_url_name: str | None
    copy_url_name: str | None
    inspect_url_name: str | None
    delete_url_name: str | None
    any_permission_required: list[str]
    list_filter: list[str] | None
    show_other_searches: bool
    @cached_property
    def is_searchable(self) -> bool: ...
    @cached_property
    def filterset_class(self) -> type[WagtailFilterSet] | None: ...
    def _annotate_queryset_updated_at(self, queryset: QuerySet[models.Model]) -> QuerySet[models.Model]: ...
    def order_queryset(self, queryset: QuerySet[models.Model]) -> QuerySet[models.Model]: ...
    def _get_title_column_class(self, column_class: type[Column]) -> type[Column]: ...
    def _get_title_column(self, field_name: str, column_class: type[Column] = ..., **kwargs: Any) -> Column: ...
    def _get_custom_column(self, field_name: str, column_class: type[Column] = ..., **kwargs: Any) -> Column: ...
    @cached_property
    def list_display(self) -> list[str | Column]: ...
    @cached_property
    def columns(self) -> list[Column]: ...
    def get_edit_url(self, instance: models.Model) -> str | None: ...
    def get_copy_url(self, instance: models.Model) -> str | None: ...
    def get_inspect_url(self, instance: models.Model) -> str | None: ...
    def get_delete_url(self, instance: models.Model) -> str | None: ...
    def get_add_url(self) -> str | None: ...
    @cached_property
    def add_url(self) -> str | None: ...
    def get_page_title(self) -> str: ...
    @cached_property
    def header_buttons(self) -> list[HeaderButton]: ...
    def get_list_more_buttons(self, instance: models.Model) -> list[ListingButton]: ...
    def get_list_buttons(self, instance: models.Model) -> list[ButtonWithDropdown]: ...
    @cached_property
    def add_item_label(self) -> str: ...
    @cached_property
    def verbose_name_plural(self) -> str | None: ...
    def get_context_data(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...
    def render_to_response(self, context: dict[str, Any], **response_kwargs: Any) -> HttpResponse: ...

class CreateView(
    LocaleMixin,
    PanelMixin,
    PermissionCheckedMixin,
    BeforeAfterHookMixin,
    WagtailAdminTemplateMixin,
    BaseCreateView,
):
    model: type[models.Model] | None
    form_class: type[WagtailAdminModelForm] | None
    index_url_name: str | None
    add_url_name: str | None
    edit_url_name: str | None
    template_name: str
    page_title: str
    permission_required: str
    success_message: str | None
    error_message: str | None
    submit_button_label: str
    submit_button_active_label: str
    actions: list[str]
    action: str
    object: models.Model
    form: WagtailAdminModelForm
    def setup(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...
    def get_action(self, request: HttpRequest) -> str: ...
    def get_available_actions(self) -> list[str]: ...
    def get_page_subtitle(self) -> str: ...
    def get_breadcrumbs_items(self) -> list[dict[str, str]]: ...
    def get_add_url(self) -> str: ...
    @cached_property
    def add_url(self) -> str: ...
    def get_edit_url(self) -> str: ...
    def get_success_url(self) -> str: ...
    def get_success_message(self, instance: models.Model) -> str | None: ...
    def get_success_buttons(self) -> list[tuple[str, str, bool]]: ...
    def get_error_message(self) -> str | None: ...
    @cached_property
    def has_unsaved_changes(self) -> bool: ...
    def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ...
    def get_side_panels(self) -> MediaContainer: ...
    def get_translations(self) -> list[dict[str, str | Locale]]: ...
    def get_initial_form_instance(self) -> models.Model | None: ...
    def get_form_kwargs(self) -> dict[str, Any]: ...
    def save_instance(self) -> models.Model: ...
    def save_action(self) -> HttpResponseRedirect: ...
    def form_valid(self, form: BaseForm) -> HttpResponse: ...
    def form_invalid(self, form: BaseForm) -> HttpResponse: ...

class CopyViewMixin:
    model: type[models.Model] | None
    pk_url_kwarg: str
    kwargs: dict[str, Any]
    def get_object(self, queryset: QuerySet[models.Model] | None = ...) -> models.Model: ...
    def get_initial_form_instance(self) -> models.Model: ...

class CopyView(CopyViewMixin, CreateView): ...

class EditView(
    LocaleMixin,
    PanelMixin,
    PermissionCheckedMixin,
    BeforeAfterHookMixin,
    WagtailAdminTemplateMixin,
    BaseUpdateView,
):
    model: type[models.Model] | None
    form_class: type[WagtailAdminModelForm] | None
    index_url_name: str | None
    edit_url_name: str | None
    copy_url_name: str | None
    delete_url_name: str | None
    history_url_name: str | None
    inspect_url_name: str | None
    usage_url_name: str | None
    page_title: str
    context_object_name: str | None
    template_name: str
    permission_required: str
    delete_item_label: str
    success_message: str | None
    error_message: str | None
    submit_button_label: str
    submit_button_active_label: str
    actions: list[str]
    action: str
    object: models.Model
    form: WagtailAdminModelForm
    has_content_changes: bool
    def setup(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...
    @cached_property
    def object_pk(self) -> str: ...
    def get_action(self, request: HttpRequest) -> str: ...
    def get_available_actions(self) -> list[str]: ...
    def get_object(self, queryset: QuerySet[models.Model] | None = ...) -> models.Model: ...
    def get_page_subtitle(self) -> str: ...
    def get_breadcrumbs_items(self) -> list[dict[str, str]]: ...
    def get_side_panels(self) -> MediaContainer: ...
    def get_last_updated_info(self) -> BaseLogEntry | None: ...
    @cached_property
    def can_delete(self) -> bool: ...
    @cached_property
    def header_more_buttons(self) -> list[Button]: ...
    def get_edit_url(self) -> str: ...
    def get_copy_url(self) -> str | None: ...
    def get_delete_url(self) -> str | None: ...
    def get_history_url(self) -> str | None: ...
    def get_inspect_url(self) -> str | None: ...
    def get_usage_url(self) -> str | None: ...
    def get_success_url(self) -> str: ...
    def get_translations(self) -> list[dict[str, str | Locale]]: ...
    def get_form_kwargs(self) -> dict[str, Any]: ...
    def save_instance(self) -> models.Model: ...
    def save_action(self) -> HttpResponseRedirect: ...
    def get_success_message(self) -> str | None: ...
    def get_success_buttons(self) -> list[tuple[str, str, bool]]: ...
    def get_error_message(self) -> str | None: ...
    def form_valid(self, form: BaseForm) -> HttpResponse: ...
    def form_invalid(self, form: BaseForm) -> HttpResponse: ...
    @cached_property
    def has_unsaved_changes(self) -> bool: ...
    def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ...

class DeleteView(
    LocaleMixin,
    PanelMixin,
    PermissionCheckedMixin,
    BeforeAfterHookMixin,
    WagtailAdminTemplateMixin,
    BaseDeleteView,
):
    model: type[models.Model] | None
    index_url_name: str | None
    edit_url_name: str | None
    delete_url_name: str | None
    usage_url_name: str | None
    template_name: str
    context_object_name: str | None
    permission_required: str
    page_title: str
    success_message: str | None
    object: models.Model
    usage_url: str | None
    usage: ReferenceGroups | None
    def setup(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...
    def get_object(self, queryset: QuerySet[models.Model] | None = ...) -> models.Model: ...
    def get_usage(self) -> ReferenceGroups | None: ...
    def get_success_url(self) -> str: ...
    def get_page_subtitle(self) -> str: ...
    def get_breadcrumbs_items(self) -> list[dict[str, str]]: ...
    def get_delete_url(self) -> str: ...
    def get_usage_url(self) -> str | None: ...
    @property
    def confirmation_message(self) -> str: ...
    def get_success_message(self) -> str | None: ...
    def delete_action(self) -> None: ...
    def form_valid(self, form: BaseForm) -> HttpResponse: ...
    def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ...

class InspectView(PermissionCheckedMixin, WagtailAdminTemplateMixin, TemplateView):
    any_permission_required: list[str]
    template_name: str
    page_title: str
    model: type[models.Model] | None
    index_url_name: str | None
    edit_url_name: str | None
    delete_url_name: str | None
    fields: list[str]
    fields_exclude: list[str]
    pk_url_kwarg: str
    pk: str
    object: models.Model
    def setup(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...
    def get_object(self, queryset: QuerySet[models.Model] | None = ...) -> models.Model: ...
    def get_page_subtitle(self) -> str: ...
    def get_breadcrumbs_items(self) -> list[dict[str, str]]: ...
    @cached_property
    def header_more_buttons(self) -> list[Button]: ...
    def get_fields(self) -> list[str]: ...
    def get_field_label(self, field_name: str, field: models.Field[Any, Any] | None) -> str: ...
    def get_field_display_value(self, field_name: str, field: models.Field[Any, Any] | None) -> Any: ...
    def get_context_for_field(self, field_name: str) -> dict[str, Any]: ...
    def get_fields_context(self) -> list[dict[str, Any]]: ...
    def get_edit_url(self) -> str | None: ...
    def get_delete_url(self) -> str | None: ...
    def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ...

class RevisionsCompareView(WagtailAdminTemplateMixin, TemplateView):
    edit_handler: Panel | None
    index_url_name: str | None
    edit_url_name: str | None
    history_url_name: str | None
    edit_label: str
    history_label: str
    page_title: str
    template_name: str
    model: type[models.Model] | None
    pk: str
    revision_id_a: str
    revision_id_b: str
    object: models.Model
    def get_breadcrumbs_items(self) -> list[dict[str, str]]: ...
    @cached_property
    def header_buttons(self) -> list[HeaderButton]: ...
    def setup(
        self, request: HttpRequest, pk: str, revision_id_a: str, revision_id_b: str, *args: Any, **kwargs: Any
    ) -> None: ...
    def get_object(self, queryset: QuerySet[models.Model] | None = ...) -> models.Model: ...
    def get_edit_handler(self) -> Panel: ...
    def get_page_subtitle(self) -> str: ...
    def get_index_url(self) -> str | None: ...
    def get_history_url(self) -> str | None: ...
    def get_edit_url(self) -> str | None: ...
    def _get_revision_and_heading(self, revision_id: str) -> tuple[models.Model, str]: ...
    def _get_comparison(self, revision_a: models.Model, revision_b: models.Model) -> list[FieldComparison]: ...
    def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ...

class RevisionsUnscheduleView(WagtailAdminTemplateMixin, TemplateView):
    model: type[models.Model] | None
    edit_url_name: str | None
    history_url_name: str | None
    revisions_unschedule_url_name: str | None
    success_message: str | None
    template_name: str
    page_title: str
    pk: str
    revision_id: str
    object: models.Model
    revision: Revision
    def setup(self, request: HttpRequest, pk: str, revision_id: str, *args: Any, **kwargs: Any) -> None: ...
    def get_object(self, queryset: QuerySet[models.Model] | None = ...) -> models.Model: ...
    def get_breadcrumbs_items(self) -> list[dict[str, str]]: ...
    def get_revision(self) -> Revision: ...
    def get_revisions_unschedule_url(self) -> str: ...
    def get_object_display_title(self) -> str: ...
    def get_success_message(self) -> str | None: ...
    def get_success_buttons(self) -> list[tuple[str, str, bool]]: ...
    def get_next_url(self) -> str: ...
    def get_page_subtitle(self) -> str: ...
    def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ...
    def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...

class UnpublishView(HookResponseMixin, WagtailAdminTemplateMixin, TemplateView):
    model: type[models.Model] | None
    index_url_name: str | None
    edit_url_name: str | None
    unpublish_url_name: str | None
    usage_url_name: str | None
    page_title: str
    success_message: str | None
    template_name: str
    pk: str
    object: models.Model
    objects_to_unpublish: list[models.Model]
    def setup(self, request: HttpRequest, pk: str, *args: Any, **kwargs: Any) -> None: ...
    def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
    def get_object(self, queryset: QuerySet[models.Model] | None = ...) -> models.Model: ...
    def get_usage(self) -> ReferenceGroups: ...
    def get_breadcrumbs_items(self) -> list[dict[str, str]]: ...
    def get_objects_to_unpublish(self) -> list[models.Model]: ...
    def get_page_subtitle(self) -> str: ...
    def get_success_message(self) -> str | None: ...
    def get_success_buttons(self) -> list[tuple[str, str, bool]] | None: ...
    def get_next_url(self) -> str: ...
    def get_unpublish_url(self) -> str: ...
    def get_usage_url(self) -> str | None: ...
    def unpublish(self) -> HttpResponse | None: ...
    def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
    def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ...
