"""FikoYT Seed Control — fixed / random / increment seed üretici."""
import random


class FikoYTSeedControl:
    # Her execution'da yeniden değerlendirilir (random mode için).
    @classmethod
    def IS_CHANGED(cls, mode, seed, **kwargs):
        if mode == "random":
            return random.random()
        return f"{mode}:{seed}"

    @classmethod
    def INPUT_TYPES(cls):
        return {
            "required": {
                "mode": (["fixed", "random", "increment"], {"default": "fixed"}),
                "seed": ("INT", {"default": 0, "min": 0, "max": 2**32 - 1}),
            }
        }

    RETURN_TYPES = ("INT",)
    RETURN_NAMES = ("seed",)
    FUNCTION = "next_seed"
    CATEGORY = "FikoYT/util"

    # Class-level counter for increment mode (per-process).
    _counter = {}

    def next_seed(self, mode, seed):
        if mode == "random":
            return (random.randint(0, 2**32 - 1),)
        if mode == "increment":
            key = id(self)
            current = self._counter.get(key, int(seed))
            self._counter[key] = current + 1
            return (int(current) % (2**32),)
        return (int(seed) % (2**32),)


NODE_CLASS_MAPPINGS = {"FikoYTSeedControl": FikoYTSeedControl}
NODE_DISPLAY_NAME_MAPPINGS = {"FikoYTSeedControl": "FikoYT • Seed Control"}
