import { AppObjectPM, getSingletonComponent, } from "@vived/core";
import { HoverLabelEntity, HoverLabelMode } from "../Entities/HoverLabelEntity";
export class WorldHoverLabelPM extends AppObjectPM {
    static get(appObjects) {
        return getSingletonComponent(WorldHoverLabelPM.type, appObjects);
    }
}
WorldHoverLabelPM.type = "WorldHoverLabelPM";
export function makeWorldHoverLabelPM(appObject) {
    return new WorldHoverLabelPMImp(appObject);
}
class WorldHoverLabelPMImp extends WorldHoverLabelPM {
    get hoverLabelEntity() {
        return this.getCachedSingleton(HoverLabelEntity.type);
    }
    vmsAreEqual(a, b) {
        if (a.show !== b.show)
            return false;
        if (a.text !== b.text)
            return false;
        return true;
    }
    constructor(appObject) {
        super(appObject, WorldHoverLabelPM.type);
        this.onEntityChange = () => {
            if (!this.hoverLabelEntity)
                return;
            const vm = {
                show: false,
                text: "",
            };
            if (this.hoverLabelEntity.mode === HoverLabelMode.WORLD &&
                this.hoverLabelEntity.show) {
                vm.show = true;
                vm.text = this.hoverLabelEntity.label;
            }
            this.doUpdateView(vm);
        };
        this.hoverLabelEntity?.addChangeObserver(this.onEntityChange);
        this.onEntityChange();
        this.appObjects.registerSingleton(this);
    }
}
export const defaultWorldHoverLabelVM = {
    show: false,
    text: "",
};
//# sourceMappingURL=WorldHoverLabelPM.js.map