"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var core_1 = require("@material-ui/core");
var utils_1 = require("./utils");
function FormHelperTextWrapper(props) {
    var name = props.name, helperText = props.helperText, error = props.error, form = props.form, formHelperTextProps = props.formHelperTextProps;
    if (form &&
        form.errors &&
        Object.keys(form.errors).length === 0 &&
        !form.errors[name] &&
        !helperText) {
        return null;
    }
    return (React.createElement(React.Fragment, null,
        React.createElement(core_1.FormHelperText, __assign({ error: (0, utils_1.hasError)(name, form, error) }, formHelperTextProps), (0, utils_1.getHelperText)(name, form, helperText))));
}
exports.default = FormHelperTextWrapper;
