import { AppObjectPM, getSingletonComponent, } from "@vived/core";
import { ChallengeEntity } from "../Entities/ChallengeEntity";
export class ChallengeAuthorHelpPM extends AppObjectPM {
    static get(appObjects) {
        return getSingletonComponent(ChallengeAuthorHelpPM.type, appObjects);
    }
}
ChallengeAuthorHelpPM.type = "ChallengeAuthorHelpPM";
export function makeChallengeAuthorHelpPM(appObject) {
    return new ChallengeAuthorHelpPMImp(appObject);
}
class ChallengeAuthorHelpPMImp extends AppObjectPM {
    get challengeEntity() {
        return this.getCachedSingleton(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);
    }
}
export const defaultChallengeAuthorHelpVM = {
    heading: "",
    text: "",
};
//# sourceMappingURL=ChallengeAuthorHelpPM.js.map