#
#   Imandra Inc.
#
#   speclogician/presentation/preview/fixtures/scenario.py
#

from __future__ import annotations

from speclogician.presentation.ctx import RenderCtx
from speclogician.presentation.models.scenario import (
    ScenarioPM,
    ScenarioStatusPM,
)

# -----------------------------------------------------------------------------
# variants
# -----------------------------------------------------------------------------

def _minimal() -> ScenarioPM:
    return ScenarioPM(
        comp_id="sc:0000",
        name="",
        status=ScenarioStatusPM(kind="valid"),
        given=[],
        when=[],
        then=[],
        given_preds_consistent=True,
        when_preds_consistent=True,
        all_preds_consistent=True,
    )


def _typical() -> ScenarioPM:
    return ScenarioPM(
        comp_id="sc:0001",
        name="scenario_1",
        status=ScenarioStatusPM(kind="valid"),
        given=["pred_eq_ten", "pred_ne_ten"],
        when=["act_gt_x"],
        then=["step1"],
        given_preds_consistent=True,
        when_preds_consistent=True,
        all_preds_consistent=True,
    )


def _edge() -> ScenarioPM:
    return ScenarioPM(
        comp_id="sc:9999",
        name="scenario_" + ("very_long_name_" * 6) + "end",
        status=ScenarioStatusPM(
            kind="missing",
            missing_preds=["pred_missing_1", "pred_missing_2"],
            missing_trans=["step_missing"],
        ),
        given=["pred_eq_ten", "pred_missing_1"],
        when=["act_gt_x", "act_weird_pred"],
        then=["step1", "step_missing"],
        given_preds_consistent=False,
        when_preds_consistent=False,
        all_preds_consistent=False,
    )


# -----------------------------------------------------------------------------
# public fixture entrypoint (matches PreviewSpec.make)
# -----------------------------------------------------------------------------

def make_scenario_pm(ctx: RenderCtx, variant: str = "typical") -> ScenarioPM:
    v = (variant or "typical").lower().strip()
    if v == "minimal":
        return _minimal()
    if v == "edge":
        return _edge()
    return _typical()


# -----------------------------------------------------------------------------
# renderer adapter (matches other fixtures style)
# -----------------------------------------------------------------------------

def render(pm: ScenarioPM, ctx: RenderCtx):
    from speclogician.presentation.renderers.scenario import render_scenario
    return render_scenario(pm, ctx=ctx)