import pandas as pd

from typing import Union
from PyQt5.QtWidgets import QWidget

from src.utils.base.base import BaseMediator, BaseDirectoryMonitor, BaseDataConverter, BasePlotWidget


class Mediator(BaseMediator):

    def notify(self,
               source: Union[BaseDirectoryMonitor, BaseDataConverter, BasePlotWidget],
               data: Union[list[str], list[pd.DataFrame], list[QWidget]]):
        if issubclass(source.__class__, BaseDirectoryMonitor):
            self._converter.convert_data(data)

        if issubclass(source.__class__, BaseDataConverter):
            self._plot.build(data)

        if issubclass(source.__class__, BasePlotWidget):
            self._controller.send_widgets(data)
        
    def push_settings(self, settings: list[dict]):
        self._monitor.update_settings(settings)
        self._plot.update_settings(settings)
        self._monitor.force_all_dir()


