import { __decorate, __metadata } from "tslib";
import { Input } from '@angular/core';
import { DynamicOutput, PureRelationsComponent } from '@anglr/dynamic/relations';
import { RelationsEditorMetadata } from '@anglr/dynamic/relations-editor';
import { isNumber, isPresent, nameof } from '@jscrpt/common';
import { MathSubtractRelationsMetadataLoader } from './subtract.metadata';
let MathSubtractRelations = class MathSubtractRelations {
    //######################### public methods #########################
    invalidateVisuals() {
    }
    ngOnChanges(changes) {
        if (nameof('input1') in changes ||
            nameof('input2') in changes) {
            if (isNumber(this.input1) &&
                isNumber(this.input2)) {
                this.result = this.input1 - this.input2;
                return;
            }
            if (!isPresent(this.input1) &&
                isNumber(this.input2)) {
                this.result = 0 - this.input2;
                return;
            }
            if (!isPresent(this.input2)) {
                this.result = this.input1;
                return;
            }
            this.result = null;
        }
    }
};
__decorate([
    Input(),
    __metadata("design:type", Object)
], MathSubtractRelations.prototype, "input1", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], MathSubtractRelations.prototype, "input2", void 0);
__decorate([
    DynamicOutput(),
    __metadata("design:type", Object)
], MathSubtractRelations.prototype, "result", void 0);
MathSubtractRelations = __decorate([
    PureRelationsComponent(),
    RelationsEditorMetadata(MathSubtractRelationsMetadataLoader)
], MathSubtractRelations);
export { MathSubtractRelations };
//# sourceMappingURL=subtract.relations.js.map