import { AppObjectUC } from "@vived/core";
import { StateMachineEntity, } from "../../StateMachine";
import { BaseAppState } from "../Entity";
export class SerializeBaseAppState extends AppObjectUC {
    get baseAppState() {
        return this.getCachedSingleton(BaseAppState.type);
    }
    getSystemState() {
        if (!this.baseAppState)
            return {};
        const state = {
            slideText: this.baseAppState.slideText,
            slideInfoContentHeight: this.baseAppState.slideInfoContentHeight,
        };
        return state;
    }
    applySystemState(state, version) {
        if (version === 1) {
            this.applyStateV1(state);
        }
        else {
            this.applyDefaultState();
        }
    }
    applyStateV1(state) {
        if (!this.baseAppState)
            return;
        if (state.slideText === undefined ||
            state.slideInfoContentHeight === undefined) {
            this.applyDefaultState();
            return;
        }
        this.baseAppState.slideText = state.slideText;
        this.baseAppState.slideInfoContentHeight = state.slideInfoContentHeight;
    }
    applyDefaultState() {
        if (!this.baseAppState)
            return;
        this.baseAppState.slideText = "";
        this.baseAppState.slideInfoContentHeight = 0;
    }
    constructor(appObject) {
        super(appObject, SerializeBaseAppState.type);
        this.name = "base-app-state";
        this.seriliziationVersion = 1;
        const stateMachine = StateMachineEntity.get(appObject.appObjectRepo);
        if (stateMachine) {
            stateMachine.registerSerializedSystem(this);
        }
        else {
            this.warn("Unable to find StateMachineEntity");
        }
    }
}
SerializeBaseAppState.type = "SerializeBaseAppState";
//# sourceMappingURL=SerializeBaseAppState.js.map