from __future__ import annotations

"""Onboarding step policy for access requests."""

ONBOARDING_STEPS: tuple[str, ...] = (
    "vaultwarden_master_password",
    "vaultwarden_store_temp_password",
    "vaultwarden_browser_extension",
    "vaultwarden_mobile_app",
    "keycloak_password_rotated",
    "element_recovery_key",
    "element_mobile_app",
    "mail_client_setup",
    "nextcloud_web_access",
    "nextcloud_mail_integration",
    "nextcloud_desktop_app",
    "nextcloud_mobile_app",
    "budget_encryption_ack",
    "firefly_password_rotated",
    "firefly_mobile_app",
    "wger_password_rotated",
    "wger_mobile_app",
    "jellyfin_web_access",
    "jellyfin_mobile_app",
    "jellyfin_tv_setup",
)

ONBOARDING_OPTIONAL_STEPS: set[str] = {
    "element_mobile_app",
    "nextcloud_desktop_app",
    "nextcloud_mobile_app",
    "firefly_mobile_app",
    "jellyfin_mobile_app",
    "jellyfin_tv_setup",
}
ONBOARDING_REQUIRED_STEPS: tuple[str, ...] = (
    "vaultwarden_master_password",
    "vaultwarden_browser_extension",
    "vaultwarden_mobile_app",
    "keycloak_password_rotated",
    "element_recovery_key",
    "mail_client_setup",
    "nextcloud_web_access",
    "nextcloud_mail_integration",
    "budget_encryption_ack",
    "firefly_password_rotated",
    "wger_password_rotated",
    "jellyfin_web_access",
)

KEYCLOAK_MANAGED_STEPS: set[str] = {
    "keycloak_password_rotated",
    "nextcloud_mail_integration",
}
_KEYCLOAK_PASSWORD_ROTATION_REQUESTED_ARTIFACT = "keycloak_password_rotation_requested_at"

ONBOARDING_STEP_PREREQUISITES: dict[str, set[str]] = {
    "vaultwarden_master_password": set(),
    "vaultwarden_store_temp_password": {"vaultwarden_master_password"},
    "vaultwarden_browser_extension": {"vaultwarden_master_password"},
    "vaultwarden_mobile_app": {"vaultwarden_master_password"},
    "keycloak_password_rotated": {"vaultwarden_master_password"},
    "element_recovery_key": {"keycloak_password_rotated"},
    "element_mobile_app": {"element_recovery_key"},
    "mail_client_setup": {"vaultwarden_master_password"},
    "nextcloud_web_access": {"vaultwarden_master_password"},
    "nextcloud_mail_integration": {"nextcloud_web_access"},
    "nextcloud_desktop_app": {"nextcloud_web_access"},
    "nextcloud_mobile_app": {"nextcloud_web_access"},
    "budget_encryption_ack": {"nextcloud_mail_integration"},
    "firefly_password_rotated": {"element_recovery_key"},
    "wger_password_rotated": {"firefly_password_rotated"},
    "wger_mobile_app": {"wger_password_rotated"},
    "jellyfin_web_access": {"vaultwarden_master_password"},
    "jellyfin_mobile_app": {"jellyfin_web_access"},
    "jellyfin_tv_setup": {"jellyfin_web_access"},
}

VAULTWARDEN_GRANDFATHERED_FLAG = "vaultwarden_grandfathered"
_VAULTWARDEN_READY_STATUSES = {"already_present", "active", "ready", "grandfathered"}
