"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ɵ0 = exports.LabelRendererTester = exports.LabelRenderer = void 0;
var tslib_1 = require("tslib");
/*
  The MIT License

  Copyright (c) 2017-2019 EclipseSource Munich
  https://github.com/eclipsesource/jsonforms

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
*/
var core_1 = require("@angular/core");
var angular_1 = require("@jsonforms/angular");
var core_2 = require("@jsonforms/core");
var mapStateToProps = function (state, ownProps) {
    var visible = ownProps.visible !== undefined
        ? ownProps.visible
        : core_2.isVisible(ownProps.uischema, core_2.getData(state), undefined, core_2.getAjv(state));
    return {
        visible: visible
    };
};
var ɵ0 = mapStateToProps;
exports.ɵ0 = ɵ0;
var LabelRenderer = /** @class */ (function (_super) {
    tslib_1.__extends(LabelRenderer, _super);
    function LabelRenderer(jsonFormsService) {
        var _this = _super.call(this) || this;
        _this.jsonFormsService = jsonFormsService;
        return _this;
    }
    LabelRenderer.prototype.ngOnInit = function () {
        var _this = this;
        var labelElement = this.uischema;
        this.label =
            labelElement.text !== undefined &&
                labelElement.text !== null &&
                labelElement.text;
        this.subscription = this.jsonFormsService.$state.subscribe({
            next: function (state) {
                var props = mapStateToProps(state, _this.getOwnProps());
                _this.visible = props.visible;
            }
        });
    };
    LabelRenderer.prototype.ngOnDestroy = function () {
        if (this.subscription) {
            this.subscription.unsubscribe();
        }
    };
    LabelRenderer.prototype.mapAdditionalProps = function () {
        this.label = this.uischema.text;
    };
    LabelRenderer.decorators = [
        { type: core_1.Component, args: [{
                    selector: 'LabelRenderer',
                    template: "\n    <label class=\"mat-title\" fxFlex> {{ label }} </label>\n  "
                },] }
    ];
    LabelRenderer.ctorParameters = function () { return [
        { type: angular_1.JsonFormsAngularService }
    ]; };
    return LabelRenderer;
}(angular_1.JsonFormsBaseRenderer));
exports.LabelRenderer = LabelRenderer;
exports.LabelRendererTester = core_2.rankWith(4, core_2.uiTypeIs('Label'));
//# sourceMappingURL=label.renderer.js.map