"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isValidFlashingCellRules = void 0;
const Utilities_1 = require("../../Components/EntityRulesEditor/Utilities");
const isValidFlashingCellRules = (flashingCell, api, context) => {
    if (!flashingCell.Rule?.Predicates?.length && !flashingCell.Rule.BooleanExpression) {
        return 'A rule is required for the Flashing Cell.';
    }
    const isRuleValid = (0, Utilities_1.isAdaptableRuleValid)(flashingCell, api, context);
    if (typeof isRuleValid === 'string') {
        return isRuleValid;
    }
    // boolean expressions may also be saved as named queries
    if (context.namedQuery != false) {
        const isValidName = api.namedQueryApi.isValidNamedQuery(context.namedQuery);
        if (!isValidName.valid) {
            return isValidName.message;
        }
    }
    return true;
};
exports.isValidFlashingCellRules = isValidFlashingCellRules;
