import typing as T

from pycs.interfaces.LabelProvider import LabelProvider as BaseProvider

class LabelProvider(BaseProvider):

    def __init__(self, root_folder: str, configuration: dict):
        self.hierarchical = configuration["hierarchical"]

    def close(self):
        pass

    def get_labels(self) -> T.List[dict]:

        labels = []
        for i, _ in enumerate(range(10), 1):

            label = self.create_label(
                reference=f"label{i}",
                name=f"Label{i}",
                hierarchy_level="root"
            )
            labels.append(label)

            if not self.hierarchical:
                continue

            parent = label
            for j, _ in enumerate(range(3), 1):

                label = self.create_label(
                    reference=f"label{i}_{j}",
                    name=f"Label{i}_{j}",
                    parent_reference=parent["reference"],
                    hierarchy_level="intermediate",
                )

                labels.append(label)

                second_parent = label
                for k, _ in enumerate(range(3), 1):
                    label = self.create_label(
                        reference=f"label{i}_{j}_{k}",
                        name=f"Label{i}_{j}_{k}",
                        parent_reference=second_parent["reference"],
                        hierarchy_level="leaf",
                    )

                    labels.append(label)

        return labels
