"""
erasus.metrics — Evaluation and Privacy Metrics.
"""

from erasus.core.registry import metric_registry

# Import and register — core metrics
from erasus.metrics.accuracy import AccuracyMetric
from erasus.metrics.membership_inference import MembershipInferenceMetric
from erasus.metrics.perplexity import PerplexityMetric
from erasus.metrics.fid import FIDMetric
from erasus.metrics.retrieval_metrics import ZeroShotAccuracyMetric

# New metric modules
from erasus.metrics.metric_suite import MetricSuite
from erasus.metrics.forgetting.mia import MIAMetric
from erasus.metrics.forgetting.mia_variants import (
    GradNormMIAMetric,
    LabelOnlyMIAMetric,
    LiRAMetric,
    MinKProbMetric,
    MinKPlusPlusMetric,
    ReferenceMIAMetric,
    ZLibMIAMetric,
)
from erasus.metrics.forgetting.confidence import ConfidenceMetric
from erasus.metrics.forgetting.feature_distance import FeatureDistanceMetric
from erasus.metrics.efficiency.time_complexity import TimeComplexityMetric
from erasus.metrics.efficiency.memory_usage import MemoryUsageMetric
from erasus.metrics.privacy.differential_privacy import DPEvaluationMetric
from erasus.metrics.privacy.privacy_leakage import PrivacyLeakageMetric
from erasus.metrics.privacy.rag_leakage import RAGLeakageMetric

# Sprint A metrics
from erasus.metrics.forgetting.activation_analysis import ActivationAnalysis
from erasus.metrics.forgetting.backdoor_activation import BackdoorActivation
from erasus.metrics.efficiency.speedup import SpeedupMetric
from erasus.metrics.efficiency.flops import FLOPsMetric

# Sprint F metrics
from erasus.metrics.forgetting.extraction_attack import ExtractionAttackMetric
from erasus.metrics.utility.clip_score import CLIPScoreMetric
from erasus.metrics.utility.bleu import BLEUMetric
from erasus.metrics.utility.rouge import ROUGEMetric
from erasus.metrics.utility.inception_score import InceptionScoreMetric
from erasus.metrics.utility.downstream_tasks import DownstreamTaskMetric
from erasus.metrics.privacy.epsilon_delta import EpsilonDeltaMetric
from erasus.metrics.privacy.privacy_audit import PrivacyAuditMetric
from erasus.metrics.benchmarks import ErasusBenchmark

# Verification metrics (MIA suite, memorization)
from erasus.metrics.forgetting.mia_suite import MIASuite
from erasus.metrics.forgetting.memorization import (
    ExtractionStrengthMetric,
    ExactMemorizationMetric,
    VerbatimMemorizationMetric,
)
from erasus.metrics.forgetting.knowmem import KnowMemMetric

# Issue #41: Cross-prompt leakage test
from erasus.metrics.forgetting.cross_prompt_leakage import CrossPromptLeakageMetric

# Issue #46: Benign fine-tuning attack
from erasus.metrics.forgetting.benign_finetuning import BenignFinetuningMetric

# Register all metrics for CLI / registry-based resolution
for name, cls in [
    ("accuracy", AccuracyMetric),
    ("mia", MembershipInferenceMetric),
    ("perplexity", PerplexityMetric),
    ("fid", FIDMetric),
    ("zero_shot", ZeroShotAccuracyMetric),
    ("mia_full", MIAMetric),
    ("lira", LiRAMetric),
    ("label_only_mia", LabelOnlyMIAMetric),
    ("reference_mia", ReferenceMIAMetric),
    ("gradnorm_mia", GradNormMIAMetric),
    ("zlib_mia", ZLibMIAMetric),
    ("mink", MinKProbMetric),
    ("mink_pp", MinKPlusPlusMetric),
    ("confidence", ConfidenceMetric),
    ("feature_distance", FeatureDistanceMetric),
    ("time_complexity", TimeComplexityMetric),
    ("memory_usage", MemoryUsageMetric),
    ("dp_evaluation", DPEvaluationMetric),
    ("privacy_leakage", PrivacyLeakageMetric),
    ("rag_leakage", RAGLeakageMetric),
    ("mia_suite", MIASuite),
    ("extraction_strength", ExtractionStrengthMetric),
    ("exact_memorization", ExactMemorizationMetric),
    ("verbatim_memorization", VerbatimMemorizationMetric),
    ("knowmem", KnowMemMetric),
    ("cross_prompt_leakage", CrossPromptLeakageMetric),
    ("benign_finetuning", BenignFinetuningMetric),
]:
    try:
        metric_registry.register(name)(cls)
    except ValueError:
        pass  # Already registered

__all__ = [
    "AccuracyMetric",
    "MembershipInferenceMetric",
    "PerplexityMetric",
    "FIDMetric",
    "ZeroShotAccuracyMetric",
    "MetricSuite",
    "MIAMetric",
    "LiRAMetric",
    "LabelOnlyMIAMetric",
    "ReferenceMIAMetric",
    "GradNormMIAMetric",
    "ZLibMIAMetric",
    "MinKProbMetric",
    "MinKPlusPlusMetric",
    "ConfidenceMetric",
    "FeatureDistanceMetric",
    "TimeComplexityMetric",
    "MemoryUsageMetric",
    "DPEvaluationMetric",
    "PrivacyLeakageMetric",
    "RAGLeakageMetric",
    # Sprint A
    "ActivationAnalysis",
    "BackdoorActivation",
    "SpeedupMetric",
    "FLOPsMetric",
    # Sprint F
    "ExtractionAttackMetric",
    "CLIPScoreMetric",
    "BLEUMetric",
    "ROUGEMetric",
    "InceptionScoreMetric",
    "DownstreamTaskMetric",
    "EpsilonDeltaMetric",
    "PrivacyAuditMetric",
    "ErasusBenchmark",
    # Verification metrics
    "MIASuite",
    "ExtractionStrengthMetric",
    "ExactMemorizationMetric",
    "VerbatimMemorizationMetric",
    "KnowMemMetric",
    # Issue #41
    "CrossPromptLeakageMetric",
    # Issue #46
    "BenignFinetuningMetric",
]
