import { AppObjectPM, getSingletonComponent, } from "@vived/core";
import { FeatureFlagsEntity } from "../Entity/FeatureFlagEntity";
export class FeatureFlagsPM extends AppObjectPM {
    static get(appObjects) {
        return getSingletonComponent(FeatureFlagsPM.type, appObjects);
    }
}
FeatureFlagsPM.type = "FeatureFlagsPM";
export function makeFeatureFlagsPM(appObject) {
    return new FeatureFlagsPMImp(appObject);
}
class FeatureFlagsPMImp extends FeatureFlagsPM {
    get featureFlagsEntity() {
        return this.getCachedSingleton(FeatureFlagsEntity.type);
    }
    vmsAreEqual(a, b) {
        if (a.length !== b.length)
            return false;
        let areEqual = true;
        a.forEach((flagA, i) => {
            const flagB = b[i];
            if (flagA !== flagB) {
                areEqual = false;
            }
        });
        return areEqual;
    }
    constructor(appObject) {
        super(appObject, FeatureFlagsPM.type);
        this.onEntityChange = () => {
            if (!this.featureFlagsEntity)
                return;
            this.doUpdateView(this.featureFlagsEntity.flags);
        };
        this.onEntityChange();
        this.featureFlagsEntity?.addChangeObserver(this.onEntityChange);
        this.appObjects.registerSingleton(this);
    }
}
//# sourceMappingURL=FeatureFlagsPM.js.map