"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultSlideNavigationVM = exports.SlideNavigationPM = void 0;
exports.makeSlideNavigationPM = makeSlideNavigationPM;
const core_1 = require("@vived/core");
const Entity_1 = require("../Entity");
class SlideNavigationPM extends core_1.AppObjectPM {
}
exports.SlideNavigationPM = SlideNavigationPM;
SlideNavigationPM.type = "SlideNavigationPM";
SlideNavigationPM.get = (appObjects) => (0, core_1.getSingletonComponent)(SlideNavigationPM.type, appObjects);
exports.defaultSlideNavigationVM = {
    hasNextState: true,
    hasPreviousState: false,
    hideNavigation: false,
};
function makeSlideNavigationPM(appObject) {
    return new SlideNavigationPMImp(appObject);
}
class SlideNavigationPMImp extends SlideNavigationPM {
    get baseAppState() {
        return this.getCachedSingleton(Entity_1.BaseAppState.type);
    }
    vmsAreEqual(a, b) {
        if (a.hasNextState !== b.hasNextState)
            return false;
        if (a.hasPreviousState !== b.hasPreviousState)
            return false;
        if (a.hideNavigation !== b.hideNavigation)
            return false;
        return true;
    }
    constructor(appObject) {
        super(appObject, SlideNavigationPM.type);
        this.onAppStateChange = () => {
            if (!this.baseAppState)
                return;
            const hasNextState = this.baseAppState.hasNextState;
            const hasPreviousState = this.baseAppState.hasPreviousState;
            const hideNavigation = this.baseAppState.hideSlideNavigation;
            const vm = { hasNextState, hasPreviousState, hideNavigation };
            this.doUpdateView(vm);
        };
        this.baseAppState?.addChangeObserver(this.onAppStateChange);
        this.onAppStateChange();
        this.appObjects.registerSingleton(this);
    }
}
//# sourceMappingURL=SlideNavigationPM.js.map