import { __assign, __rest } from "tslib";
import React, { useContext } from 'react';
import classNames from 'classnames';
import { ConfigContext } from '../config-provider/config-context';
import { getPrefixCls } from '../_utils/general';
var headingGenerator = function (htmlType, displayName) {
    var Component = React.forwardRef(function (props, ref) {
        var customisedCls = props.prefixCls, className = props.className, children = props.children, otherProps = __rest(props, ["prefixCls", "className", "children"]);
        var configContext = useContext(ConfigContext);
        var prefixCls = getPrefixCls('typography', configContext.prefixCls, customisedCls);
        var cls = classNames(prefixCls, className);
        return React.createElement(htmlType, __assign(__assign({}, otherProps), { ref: ref, className: cls }), children);
    });
    Component.displayName = displayName;
    return Component;
};
var Heading = function (props) {
    var _a = props.level, level = _a === void 0 ? 1 : _a, otherProps = __rest(props, ["level"]);
    if (level < 1 || level > 6) {
        console.warn('The heading level parameter is invalid.');
        return null;
    }
    var Component = headingGenerator("h" + level, "H" + level);
    return React.createElement(Component, __assign({}, otherProps));
};
export default Heading;
//# sourceMappingURL=heading.js.map