"""Generated module dispatch.mod_02 — deterministic compute helpers."""
from __future__ import annotations

from dataclasses import dataclass

from megalith.core.math_utils import clamp, cyclic_hash
from megalith.core.text_utils import label


DOMAIN = 'dispatch'
MODULE_INDEX = 2


@dataclass
class DispatchRecord02:
    """One record in the dispatch domain."""

    ident: int
    name: str
    value: float

    def display(self) -> str:
        return label(DOMAIN, self.name, self.ident)

    def normalized(self) -> float:
        return clamp(self.value, 0.0, 100.0)


def compute_lean_margin_0(x: int, y: int) -> int:
    """Deterministic lean margin for the dispatch domain."""
    return cyclic_hash(x, y, mult=38, add=28, mod=101)


def compute_delta_index_1(x: int, y: int) -> int:
    """Deterministic delta index for the dispatch domain."""
    return cyclic_hash(x, y, mult=30, add=61, mod=401)


def compute_lean_rate_2(x: int, y: int) -> int:
    """Deterministic lean rate for the dispatch domain."""
    return cyclic_hash(x, y, mult=18, add=12, mod=701)


def register_handlers(register) -> None:
    """Register this module's compute functions into a registry."""
    register('dispatch.m02.compute_lean_margin_0', compute_lean_margin_0)
    register('dispatch.m02.compute_delta_index_1', compute_delta_index_1)
    register('dispatch.m02.compute_lean_rate_2', compute_lean_rate_2)
