import { MODES } from "../../modes";
import Connection from "./ConnectionCode";
import WebSite from "./Website";
import Exploration from "./Exploration";
import { CheckList } from "./CheckList";

export default class State {
	connection: Connection;
	followedConnection: Connection;

	
	mode: MODES;

	popupCommentPosition: { x: string; y: string };
	displayComments: boolean;
	commentsUp: any[];
	screenshotList: { image: string; interactionIndex: number }[];

	managedWindowId: number;

	explorationEvaluation: {fulfilled: any[], notFulfilled: any[]};
	objectiveCheckList: CheckList;
	isActive: boolean;

	constructor() {
		this.mode = MODES.STOP;
		
		this.commentsUp = [];
		this.screenshotList = []; // not in state because it is too heavy
		
		this.displayComments = false;
		this.popupCommentPosition = {
            x: "75%",
            y: "75%"
		};
	}

	/*get overview(): any {
		return {
			connection: this.connection,
			followedConnection: this.followedConnection,
			webSite: this.webSite,
			sessionBaseURL: this.sessionBaseURL,
			testerName: this.testerName,
			interactionList: this.exploration,
			mode: this.mode,
			popupCommentPosition: this.popupCommentPosition,
			displayComments: this.displayComments,
			commentsUp: this.commentsUp.slice(),
			managedWindowId: this.managedWindowId,
			objectiveCheckList: this.objectiveCheckList
		};
	}

	update(patch: {
		testerName?;
		displayComments?;
		popupCommentPosition?;
	}): Promise<void> {
		return new Promise((resolve, reject) => {
			const updateKeys = Object.getOwnPropertyNames(patch);
			updateKeys.forEach((key) => {
				switch (key) {
					case "testerName":
						this.testerName = patch.testerName;
						break;
					case "displayComments":
						this.displayComments = patch.displayComments;
						break;
					case "popupCommentPosition":
						this.popupCommentPosition = patch.popupCommentPosition;
						break;
					default:
						reject(
							new Error(`Invalid state update patch, key ${key} is invalid.`)
						);
				}
			});
			resolve();
		});
	}*/
}
