"use strict";
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 (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var utils_1 = require("../../utils");
var _ = require("lodash");
var __SERVICES = new Set();
var __loaded = false;
var default_1 = /** @class */ (function (_super) {
    __extends(default_1, _super);
    function default_1() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    default_1.prototype.componentWillMount = function () {
        var _this = this;
        if (!__loaded) {
            utils_1.Ajax.GET('/api-common/services', function (json) {
                __loaded = true;
                if (_.isArray(json.data) && json.data.length > 0) {
                    json.data.map(function (serviceId) { return __SERVICES.add(_.trim(_.toLower(serviceId))); });
                }
                _this.setState({ t: new Date().getTime() });
            });
        }
    };
    default_1.prototype.renderMiss = function () {
        return this.props.miss || [];
    };
    default_1.prototype.renderContent = function () {
        return this.props.children;
    };
    default_1.prototype.render = function () {
        if (!__loaded) {
            return [];
        }
        return __SERVICES.has(_.toLower(this.props.id)) ? this.renderContent() : this.renderMiss();
    };
    return default_1;
}(React.PureComponent));
exports.default = default_1;
