import { __decorate, __metadata } from "tslib";
import { DynamicOutput, PureRelationsComponent } from '@anglr/dynamic/relations';
import { RelationsEditorMetadata } from '@anglr/dynamic/relations-editor';
import { isString, nameof } from '@jscrpt/common';
import isEqual from 'lodash-es/isEqual';
import { MatchRelationsMetadataLoader } from './match.metadata';
/**
 * Match relations component
 */
let MatchRelations = class MatchRelations {
    //######################### public methods - implementation of RelationsComponent #########################
    /**
     * @inheritdoc
     */
    ngOnChanges(changes) {
        if (nameof('value') in changes ||
            nameof('valueToMatch') in changes) {
            if (this.valueToMatch instanceof RegExp &&
                isString(this.value)) {
                this.result = this.valueToMatch.test(this.value);
                return;
            }
            if (isString(this.value) ||
                isString(this.valueToMatch)) {
                this.result = this.value == this.valueToMatch;
                return;
            }
            this.result = isEqual(this.value, this.valueToMatch);
        }
    }
    /**
     * @inheritdoc
     */
    invalidateVisuals() {
    }
};
__decorate([
    DynamicOutput(),
    __metadata("design:type", Object)
], MatchRelations.prototype, "result", void 0);
MatchRelations = __decorate([
    PureRelationsComponent(),
    RelationsEditorMetadata(MatchRelationsMetadataLoader)
], MatchRelations);
export { MatchRelations };
//# sourceMappingURL=match.relations.js.map