"""Security utilities for Local Deep Research."""

from .data_sanitizer import DataSanitizer, redact_data, sanitize_data
from .file_integrity import FileIntegrityManager, FAISSIndexVerifier
from .notification_validator import (
    NotificationURLValidator,
    NotificationURLValidationError,
)
from .safe_requests import safe_get, safe_post, SafeSession
from .security_headers import SecurityHeaders
from .ssrf_validator import validate_url, get_safe_url, is_ip_blocked
from .url_validator import URLValidator

# PathValidator requires werkzeug (Flask dependency), import conditionally
try:
    from .path_validator import PathValidator

    _has_path_validator = True
except ImportError:
    PathValidator = None  # type: ignore
    _has_path_validator = False

# FileUploadValidator requires pdfplumber, import conditionally
try:
    from .file_upload_validator import FileUploadValidator

    _has_file_upload_validator = True
except ImportError:
    FileUploadValidator = None  # type: ignore
    _has_file_upload_validator = False

# Rate limiter requires flask_limiter, import conditionally
try:
    from .rate_limiter import init_rate_limiter, upload_rate_limit

    _has_rate_limiter = True
except ImportError:
    init_rate_limiter = None  # type: ignore
    _has_rate_limiter = False

    # Provide a no-op decorator when flask_limiter is not available
    def upload_rate_limit(f):
        """No-op decorator when flask_limiter is not installed."""
        return f


__all__ = [
    "PathValidator",
    "DataSanitizer",
    "sanitize_data",
    "redact_data",
    "FileIntegrityManager",
    "FAISSIndexVerifier",
    "FileUploadValidator",
    "NotificationURLValidator",
    "NotificationURLValidationError",
    "SecurityHeaders",
    "URLValidator",
    "init_rate_limiter",
    "upload_rate_limit",
    "safe_get",
    "safe_post",
    "SafeSession",
    "validate_url",
    "get_safe_url",
    "is_ip_blocked",
]
