import bpy
from ..utils_debug import debug_log


def importAnimatorController(self, data: dict) -> bpy.types.NodeTree:
    name = data.get("name", None)
    if name is None:
        debug_log("AnimatorController has no name!")
        return None
    
    debug_log(">>>>> TODO: implement animator controller import")

    node_tree = bpy.data.node_groups.new(name, 'NEEDLE_AnimatorController')

    layers = data.get("layers", None)
    if layers:
        for layer in layers:
            state_machine = layer.get("stateMachine", None)
            if state_machine:
                states = state_machine.get("states", None)
                if states:
                    for state in states:
                        stateNode = node_tree.nodes.new("AnimatorState")
                        # TODO: we need to register this state node to resolve the animation action AFTER the import is done / the action has been created
                        pass


    return node_tree