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 { MathDivideRelationsMetadataLoader } from './divide.metadata';
let MathDivideRelations = class MathDivideRelations {
    //######################### public methods #########################
    invalidateVisuals() {
    }
    ngOnChanges(changes) {
        if (nameof('input1') in changes ||
            nameof('input2') in changes) {
            if (isNumber(this.input1) &&
                isNumber(this.input2)) {
                if (this.input2 === 0) {
                    this.result = null;
                    return;
                }
                this.result = this.input1 / this.input2;
                return;
            }
            if (!isPresent(this.input1)) {
                this.result = 0;
                return;
            }
            if (!isPresent(this.input2)) {
                this.result = this.input1;
                return;
            }
            this.result = null;
        }
    }
};
__decorate([
    Input(),
    __metadata("design:type", Object)
], MathDivideRelations.prototype, "input1", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], MathDivideRelations.prototype, "input2", void 0);
__decorate([
    DynamicOutput(),
    __metadata("design:type", Object)
], MathDivideRelations.prototype, "result", void 0);
MathDivideRelations = __decorate([
    PureRelationsComponent(),
    RelationsEditorMetadata(MathDivideRelationsMetadataLoader)
], MathDivideRelations);
export { MathDivideRelations };
//# sourceMappingURL=divide.relations.js.map