from typing import Any

from django.db import models
from django.forms import Form
from django.http import HttpRequest, HttpResponse
from django.utils.functional import cached_property
from wagtail.admin.panels import Panel
from wagtail.admin.ui.editing_sessions import EditingSessionsModule
from wagtail.admin.ui.tables import Column
from wagtail.locks import BaseLock
from wagtail.models import Locale, Revision, Task, Workflow, WorkflowState

class HookResponseMixin:
    def run_hook(self, hook_name: str, *args: Any, **kwargs: Any) -> HttpResponse | None: ...

class BeforeAfterHookMixin(HookResponseMixin):
    def run_before_hook(self) -> HttpResponse | None: ...
    def run_after_hook(self) -> HttpResponse | None: ...
    def dispatch(self, *args: Any, **kwargs: Any) -> HttpResponse: ...
    def form_valid(self, form: Form) -> HttpResponse: ...

class LocaleMixin:
    @cached_property
    def i18n_enabled(self) -> bool: ...
    @cached_property
    def locale(self) -> Locale | None: ...
    @cached_property
    def translations(self) -> list[dict[str, Any]]: ...
    def get_locale(self) -> Locale | None: ...
    def get_translations(self) -> list[dict[str, Any]]: ...
    def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ...
    def _set_locale_query_param(self, url: str, locale: Locale | None = ...) -> str: ...

class PanelMixin:
    panel: Panel | None
    def setup(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...
    def get_panel(self) -> Panel | None: ...
    def get_bound_panel(self, form: Form) -> Panel.BoundPanel | None: ...
    def get_form_class(self) -> type[Form]: ...
    def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ...

class IndexViewOptionalFeaturesMixin:
    def _get_title_column(
        self,
        field_name: str,
        column_class: type[Column] = ...,
        **kwargs: Any,
    ) -> Column: ...
    def _annotate_queryset_updated_at(
        self, queryset: models.QuerySet[models.Model]
    ) -> models.QuerySet[models.Model]: ...
    @cached_property
    def list_display(self) -> list[str | Column]: ...

class CreateEditViewOptionalFeaturesMixin:
    view_name: str
    preview_url_name: str | None
    lock_url_name: str | None
    unlock_url_name: str | None
    revisions_unschedule_url_name: str | None
    revisions_compare_url_name: str | None
    workflow_history_url_name: str | None
    confirm_workflow_cancellation_url_name: str | None
    preview_enabled: bool
    revision_enabled: bool
    draftstate_enabled: bool
    locking_enabled: bool
    object: models.Model | None
    lock: BaseLock | None
    locked_for_user: bool
    saving_as_draft: bool
    live_object: models.Model
    form: Form
    has_content_changes: bool
    new_revision: Revision | None
    workflow_action: str
    def setup(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...
    @cached_property
    def workflow(self) -> Workflow | None: ...
    @cached_property
    def workflow_enabled(self) -> bool: ...
    @cached_property
    def workflow_state(self) -> WorkflowState | None: ...
    @cached_property
    def current_workflow_task(self) -> Task | None: ...
    @cached_property
    def workflow_tasks(self) -> list[Task]: ...
    def user_has_permission(self, permission: str) -> bool: ...
    def workflow_action_is_valid(self) -> bool: ...
    def get_available_actions(self) -> list[str]: ...
    def get_object(self, queryset: models.QuerySet[models.Model] | None = ...) -> models.Model | None: ...
    def get_lock(self) -> BaseLock | None: ...
    def get_lock_url(self) -> str | None: ...
    def get_unlock_url(self) -> str | None: ...
    def get_preview_url(self) -> str | None: ...
    def get_workflow_history_url(self) -> str | None: ...
    def get_confirm_workflow_cancellation_url(self) -> str | None: ...
    def get_error_message(self) -> str | None: ...
    def get_success_message(self, instance: models.Model | None = ...) -> str: ...
    def get_success_url(self) -> str: ...
    def save_instance(self) -> models.Model: ...
    def publish_action(self) -> HttpResponse | None: ...
    def submit_action(self) -> None: ...
    def restart_workflow_action(self) -> None: ...
    def cancel_workflow_action(self) -> None: ...
    def workflow_action_action(self) -> None: ...
    def run_action_method(self) -> HttpResponse | None: ...
    def form_valid(self, form: Form) -> HttpResponse: ...
    def form_invalid(self, form: Form) -> HttpResponse: ...
    def get_last_updated_info(self) -> dict[str, Any] | None: ...
    def get_lock_context(self) -> dict[str, Any]: ...
    def get_editing_sessions(self) -> EditingSessionsModule | None: ...
    def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ...
    def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...

class RevisionsRevertMixin:
    revision_id_kwarg: str
    revisions_revert_url_name: str | None
    revision_id: str | None
    revision: Revision
    def setup(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...
    def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
    def get_revisions_revert_url(self) -> str: ...
    def get_warning_message(self) -> str: ...
    def _add_warning_message(self) -> None: ...
    def get_object(self, queryset: models.QuerySet[models.Model] | None = ...) -> models.Model: ...
    def save_instance(self) -> models.Model: ...
    def get_success_message(self) -> str: ...
    def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ...
