"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultChallengeAuthorHelpVM = exports.ChallengeAuthorHelpPM = void 0;
exports.makeChallengeAuthorHelpPM = makeChallengeAuthorHelpPM;
const core_1 = require("@vived/core");
const ChallengeEntity_1 = require("../Entities/ChallengeEntity");
class ChallengeAuthorHelpPM extends core_1.AppObjectPM {
    static get(appObjects) {
        return (0, core_1.getSingletonComponent)(ChallengeAuthorHelpPM.type, appObjects);
    }
}
exports.ChallengeAuthorHelpPM = ChallengeAuthorHelpPM;
ChallengeAuthorHelpPM.type = "ChallengeAuthorHelpPM";
function makeChallengeAuthorHelpPM(appObject) {
    return new ChallengeAuthorHelpPMImp(appObject);
}
class ChallengeAuthorHelpPMImp extends core_1.AppObjectPM {
    get challengeEntity() {
        return this.getCachedSingleton(ChallengeEntity_1.ChallengeEntity.type);
    }
    vmsAreEqual(a, b) {
        if (a.heading !== b.heading)
            return false;
        if (a.text !== b.text)
            return false;
        return true;
    }
    constructor(appObject) {
        super(appObject, ChallengeAuthorHelpPM.type);
        this.onEntityChange = () => {
            if (!this.challengeEntity)
                return;
            const text = this.challengeEntity.selectedChallengeAuthorHelp;
            const heading = this.challengeEntity.selectedChallengeName;
            const vm = {
                heading,
                text,
            };
            this.doUpdateView(vm);
        };
        this.challengeEntity?.addChangeObserver(this.onEntityChange);
        this.onEntityChange();
        this.appObjects.registerSingleton(this);
    }
}
exports.defaultChallengeAuthorHelpVM = {
    heading: "",
    text: "",
};
//# sourceMappingURL=ChallengeAuthorHelpPM.js.map