from typing import (
    Dict,
    List,
    Union,
)

from nreports.repository import (
    I18NRepository,
    L10NRepository,
)
from nreports_api.shared import JSON
from ._TextLine import TextLine


class ImageLine(TextLine):

    def inner_format(
        self,
        data: Dict[str, JSON],
        i18n_repository: I18NRepository,
        l10n_repository: L10NRepository,
    ) -> List[Dict[str, Union[str, Dict[str, str]]]]:

        formatted = [
            {
                self._text_attr: self.format_variables(
                    variables=data,
                    text=self.line[self._text_attr],
                )
            }
        ]

        if "textList" in self.line:
            formatted[0]["textList"] = self._format_text_list(
                data=data,
                i18n_repository=i18n_repository,
                l10n_repository=l10n_repository,
            )

        for line in formatted:
            if "customization" in self.line:
                line["customization"] = self.line.get("customization")

        return formatted
