"""Data models for sweep and processing payload collections."""

from __future__ import annotations

from dataclasses import dataclass, field

import numpy as np


@dataclass(frozen=True, slots=True)
class ComboKey:
    """Switch combination key: input position + output position."""

    input_pos: int
    output_pos: int


@dataclass(slots=True)
class TraceData:
    """One frequency-domain S21 trace for a specific switch combination."""

    combo: ComboKey
    frequency_hz: np.ndarray
    s21: np.ndarray


@dataclass(slots=True)
class SweepCollection:
    """Raw or preprocessed collection containing multiple combo traces."""

    collection_id: int
    monotonic_ns: int
    traces: list[TraceData] = field(default_factory=list)


@dataclass(slots=True)
class ResultPayload:
    """Processed payload item (trace-like or scalar) produced by processor stage."""

    processing_name: str
    kind: int
    frequency_hz: np.ndarray
    trace: np.ndarray
    scalar_value: float = 0.0


@dataclass(slots=True)
class ResultBlock:
    """Result payload block grouped by one switch combination."""

    combo: ComboKey
    payloads: list[ResultPayload] = field(default_factory=list)


@dataclass(slots=True)
class ResultCollection:
    """Collection of processed payload blocks for one acquisition cycle."""

    collection_id: int
    monotonic_ns: int
    blocks: list[ResultBlock] = field(default_factory=list)
