var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __values = (this && this.__values) || function(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
import BaseRenderer from "./base-renderer";
var TagRenderer = (function (_super) {
    __extends(TagRenderer, _super);
    function TagRenderer() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    TagRenderer.prototype.init = function (params) {
        _super.prototype.init.call(this, params);
        _super.prototype.setupGui.call(this);
    };
    TagRenderer.prototype.setupContentGui = function () {
        var e_1, _a;
        var _b;
        if (this.params.data == null || ((_b = this.params.colDef) === null || _b === void 0 ? void 0 : _b.field) == null) {
            return '';
        }
        var fields = this.params.colDef.field.split('.');
        var label = this.params.data;
        try {
            for (var fields_1 = __values(fields), fields_1_1 = fields_1.next(); !fields_1_1.done; fields_1_1 = fields_1.next()) {
                var field = fields_1_1.value;
                label = label[field];
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (fields_1_1 && !fields_1_1.done && (_a = fields_1.return)) _a.call(fields_1);
            }
            finally { if (e_1) throw e_1.error; }
        }
        return "<ui-tag label=\"".concat(label, "\" text-color=\"").concat(this.getColor("textColor", "#ffffff"), "\" background-color=\"").concat(this.getColor("backgroundColor", "#6d7277"), "\" size=\"md\" type=\"solid\"></ui-tag>");
    };
    TagRenderer.prototype.getColor = function (property, defaultColor) {
        var e_2, _a;
        var _b;
        var color;
        if (((_b = this.params.colDef.filterParams) === null || _b === void 0 ? void 0 : _b[property]) == null) {
            color = defaultColor;
        }
        else {
            var colorParts = this.params.colDef.filterParams[property].split('.');
            color = this.params.data;
            try {
                for (var colorParts_1 = __values(colorParts), colorParts_1_1 = colorParts_1.next(); !colorParts_1_1.done; colorParts_1_1 = colorParts_1.next()) {
                    var part = colorParts_1_1.value;
                    color = color[part];
                }
            }
            catch (e_2_1) { e_2 = { error: e_2_1 }; }
            finally {
                try {
                    if (colorParts_1_1 && !colorParts_1_1.done && (_a = colorParts_1.return)) _a.call(colorParts_1);
                }
                finally { if (e_2) throw e_2.error; }
            }
            if (color == null || typeof color != 'string') {
                color = this.params.colDef.filterParams[property];
            }
        }
        return color;
    };
    return TagRenderer;
}(BaseRenderer));
export default TagRenderer;

//# sourceMappingURL=tag-renderer.js.map
