"""Builder for preprocess set summary section."""

from __future__ import annotations

from PyQt6.QtWidgets import QGroupBox, QLabel, QVBoxLayout

from python_app.gui.controllers.sections.layout_helpers import build_two_column_form_widget
from python_app.orchestration.preprocess_assets import VISIBLE_PREPROCESS_ASSET_KEYS, preprocess_asset_display_name


def build_preprocess_summary_group(owner) -> QGroupBox:
    """Create selected preprocess-set summary section."""
    group = QGroupBox("Selected Preprocess Sets")
    layout = QVBoxLayout(group)
    layout.setContentsMargins(10, 10, 10, 10)
    layout.setSpacing(8)

    owner._selected_preprocess_labels = {}
    rows = []
    for key in VISIBLE_PREPROCESS_ASSET_KEYS:
        label = QLabel("<not selected>")
        owner._selected_preprocess_labels[key] = label
        rows.append((preprocess_asset_display_name(key), label))

    layout.addWidget(build_two_column_form_widget(group, rows, split_index=(len(rows) + 1) // 2))
    return group
