"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StateStore = void 0;
const messages_1 = require("../sharedUtils/messages");
class StateStore {
    constructor() {
        this.state = {
            activeRecording: true,
            hover: {
                hoverXpathToIndex: {},
            },
            mainUI: {
                isOnRootPath: true,
            },
            recordingState: {
                present: {
                    activeRecording: true,
                },
            },
            replay: {
                running: false,
            },
            training: {
                configuration: {
                    captureHovers: false,
                    customTestIdAttributes: [],
                },
            },
            walkthrough: {
                isInProgress: false,
            },
        };
    }
    getState() {
        return this.state;
    }
    dispatch(action) {
        void window.__mabl.bridge.sendToMain({
            action: messages_1.DISPATCH_ACTION,
            dispatchAction: action,
        });
    }
    setRecordingState(recordingIsActive) {
        this.state.activeRecording = recordingIsActive;
        this.state.recordingState.present.activeRecording = recordingIsActive;
    }
    setWalkthroughState(walkthroughState) {
        this.state.walkthrough.activeContext = walkthroughState.activeContext;
        this.state.walkthrough.isInProgress = walkthroughState.isInProgress;
        this.state.walkthrough.isReplaying = walkthroughState.isReplaying;
        this.state.walkthrough.isTransitioning = walkthroughState.isTransitioning;
    }
    setReplayState(replayIsActive) {
        this.state.replay.running = replayIsActive;
    }
    setCaptureHoversState(captureHovers) {
        this.state.training.configuration.captureHovers = captureHovers;
    }
    setCustomTestIdAttributes(customTestIdAttributes) {
        this.state.training.configuration.customTestIdAttributes =
            customTestIdAttributes;
    }
    setHoverXpathToIndexState(hoverXpathToIndexState) {
        this.state.hover.hoverXpathToIndex = hoverXpathToIndexState;
    }
}
exports.StateStore = StateStore;
