from __future__ import annotations

from app.schemas.analyze import AnalyzeItem
from app.services.analyze.base import AnalyzerContribution, AnalyzeContext
from app.services.analyze.radio_test import run_radio_test


class RadioTestAnalyzer:
    key = "radio_test"
    ttl_seconds = 60 * 60 * 24 * 7  # deterministic, effectively stable

    async def analyze(self, ctx: AnalyzeContext) -> list[AnalyzerContribution]:
        radio = run_radio_test(ctx.domain)
        item = AnalyzeItem(
            key="radio_test",
            label="Radio Test",
            value=radio.status,
            status=radio.status,
            source="internal",
            details={
                "sld": radio.sld,
                "syllables": radio.syllables,
                "length": radio.length,
                "has_hyphen": radio.has_hyphen,
                "has_digits": radio.has_digits,
                "rationale": radio.rationale,
            },
        )
        return [AnalyzerContribution(quadrant="authority", items=[item])]

