import Interface4UserView from "../application/Interface4UserView";
import ActionProbabilityView from "./ActionProbabilityView";
import ActionsPopupView from "./ActionsPopupView";
import EvaluationActionsBorderView from "./EvaluationActionsBorderView";
import UserView from "./UserView";
import ActionsAndElements from "../domain/ActionsAndElements";
import Comment from "../domain/Comment";
import ExplorationEvaluation from "../domain/ExplorationEvaluation";
import State from "../domain/State";
import ViewManagerService from "../domain/ViewManagerService";
import {logger} from "../framework/Logger";


export default class ViewManager implements ViewManagerService {
    private _actionProbabilityView : ActionProbabilityView;
    private _actionPopupView : ActionsPopupView;
    private _userView : UserView;
    private _evaluationActionsBorderView: EvaluationActionsBorderView;

    constructor(application: Interface4UserView) {
        this._actionPopupView = new ActionsPopupView();
        this._actionProbabilityView = new ActionProbabilityView();
        this._userView = new UserView(application);
        this._evaluationActionsBorderView = new EvaluationActionsBorderView();
    }

    refresh(state: State, elementListMatchedByRule: HTMLElement[], actionsAndElements: ActionsAndElements, evaluation: ExplorationEvaluation | undefined, commentList: Comment[]): void {
        logger.info('StyleManager refresh');
        this._actionProbabilityView.show(actionsAndElements, elementListMatchedByRule);
        this._actionPopupView.show(actionsAndElements);
        if (evaluation) {
            this._evaluationActionsBorderView.show(evaluation);
        }
        if (state.displayUserView) {
            this._userView.show(commentList, state.confirmedComments, evaluation, state.userTabPosition);
        } else {
            this._userView.hide();
        }
    }

    hide(): Promise<void> {
        this._actionPopupView.hide();
        this._actionProbabilityView.hide();
        this._userView.hide();
        return Promise.resolve();
    }
}
