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 { isBlank, isPresent, nameof } from '@jscrpt/common';
import { MathRoundRelationsMetadataLoader } from './round.metadata';
let MathRoundRelations = class MathRoundRelations {
    //######################### public methods #########################
    invalidateVisuals() {
    }
    ngOnChanges(changes) {
        var _a;
        if (nameof('input') in changes ||
            nameof('decimalPlace') in changes) {
            if (!isPresent(this.input)) {
                this.result = 0;
                return;
            }
            if (!isPresent(this.relationsOptions) ||
                isBlank((_a = this.relationsOptions) === null || _a === void 0 ? void 0 : _a.decimalPlace)) {
                this.result = this.input;
                return;
            }
            const pow10 = Math.pow(10, this.relationsOptions.decimalPlace);
            this.result = Math.round(this.input * pow10) / pow10;
        }
    }
};
__decorate([
    Input(),
    __metadata("design:type", Object)
], MathRoundRelations.prototype, "input", void 0);
__decorate([
    DynamicOutput(),
    __metadata("design:type", Object)
], MathRoundRelations.prototype, "result", void 0);
MathRoundRelations = __decorate([
    PureRelationsComponent(),
    RelationsEditorMetadata(MathRoundRelationsMetadataLoader)
], MathRoundRelations);
export { MathRoundRelations };
//# sourceMappingURL=round.relations.js.map