from Core.categories import Category
from Core.fields import Field, FieldValue
from Core.io import Input, Output, Display, DisplayDefinition, InputValue, OutputValue, FieldOrInputValue, DisplayValue, ArrayValue
from Core.translate import LocStr, LocStr1, LocStrFormatted

from Mafi.Core.Entities import Entity

class DefaultControllers:
    Controller = "ProgramableNetwork_Controller"

class ModuleStatusValue:
    pass

class ModuleStatus:
    Init = ModuleStatusValue()
    Running = ModuleStatusValue()
    Error = ModuleStatusValue()
    Paused = ModuleStatusValue()

class Module:
    name: str = "module display name"
    symbol: str = "short name"
    inputs: list[Input] = []
    outputs: list[Output] = []
    displays: list[DisplayDefinition] = []
    fields: list[Field] = []
    categories: list[Category] = []
    controllers: list[str] = []
    width: int = 0
    computing: float = 0

    def __init__(self):
        # defines an interface to data of input inside module
        self.Input = InputValue(self)
        # defines an interface to data of output inside module
        self.Output = OutputValue(self)
        # defines an interface to data of field inside module
        self.Field = FieldValue(self)
        # defines an interface to data of field inside module
        self.FieldOrInput = FieldOrInputValue(self)
        # defines an interface to data of displays inside module
        self.Display = DisplayValue(self)
        # per-module Fix32 scratch array (ring buffers, windows, history slices) —
        # use self.Array.resize(N) to size it, then self.Array[i] / .get(i, d) /
        # .set(i, v) for indexed access.  Persists with the save game.
        self.Array = ArrayValue(self)
        # defines an interface to raw data inside module
        self.NumberData = {}
        # defines an interface to raw data inside module
        self.StringData = {}
        # defines status of module
        self.Status = ModuleStatus.Init
        # defines an Tooltip/Error info
        self.Error = ""
        # set an display state to info
        self.Info = False
        # set an display state to warning
        self.Warning = False
        # accessor to prototype
        self.Prototype = None
        # accessor to controller
        self.Controller = None
    
    def Tr(key: str, default: str) -> LocStr | LocStr1 | LocStrFormatted:
      """Creates and translation string for modules"""
      pass

    def Init(self):
        pass

    def Action(self):
        pass
