from typing import Dict

from peek_abstract_chunked_index.private.tuples.ACIUpdateDateTupleABC import (
    ACIUpdateDateTupleABC,
)
from peek_plugin_diagram._private.PluginNames import diagramTuplePrefix
from vortex.Tuple import addTupleType, TupleField, Tuple


@addTupleType
class BranchIndexUpdateDateTuple(Tuple, ACIUpdateDateTupleABC):
    """BranchIndex Object Update Date Tuple

    This tuple represents the state of the chunks in the cache.
    Each chunkKey has a lastUpdateDate as a string, this is used for offline caching
    all the chunks.
    """

    __tupleType__ = diagramTuplePrefix + "BranchIndexUpdateDateTuple"

    # Improve performance of the JSON serialisation
    __rawJonableFields__ = ("initialLoadComplete", "updateDateByChunkKey")

    initialLoadComplete: bool = TupleField()
    updateDateByChunkKey: Dict[str, str] = TupleField({})

    @property
    def ckiUpdateDateByChunkKey(self):
        return self.updateDateByChunkKey

    def ckiSetUpdateDateByChunkKey(self, value: Dict[str, str]) -> None:
        self.updateDateByChunkKey = value

    @property
    def ckiInitialLoadComplete(self) -> bool:
        return self.initialLoadComplete

    def ckiSetInitialLoadComplete(self, value: bool) -> None:
        self.initialLoadComplete = value
