"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ConditionOperator_1 = __importDefault(require("./ConditionOperator"));
const lodash_1 = __importDefault(require("lodash"));
class IsEqualTo extends ConditionOperator_1.default {
    static get operatorKey() {
        return 'isEqual';
    }
    static get displayedName() {
        return 'Is Equal To';
    }
    execute({ value, comparedValue }) {
        if ((value || value === false) &&
            comparedValue &&
            typeof value !== typeof comparedValue &&
            lodash_1.default.isString(comparedValue)) {
            try {
                comparedValue = JSON.parse(comparedValue);
            }
            catch (ignoreErr) {
                // ignore
            }
        }
        //special check for select boxes
        if (lodash_1.default.isObject(value) && comparedValue && lodash_1.default.isBoolean(value[comparedValue])) {
            return value[comparedValue];
        }
        const valuesAreObjects = typeof comparedValue === 'object' &&
            comparedValue !== null &&
            typeof value === 'object' &&
            value !== null;
        return valuesAreObjects ? lodash_1.default.isMatch(value, comparedValue) : lodash_1.default.isEqual(comparedValue, value);
    }
}
exports.default = IsEqualTo;
