"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const intl_1 = require("../../intl");
const react_1 = tslib_1.__importDefault(require("react"));
const getComponent_1 = require("../../getComponent");
class FormattedMessage extends react_1.default.PureComponent {
    render() {
        const _a = this.props, { children, component } = _a, rest = tslib_1.__rest(_a, ["children", "component"]);
        const { __ } = this.context;
        const Component = component;
        if (typeof children !== 'string') {
            return react_1.default.createElement(Component, rest, children);
        }
        return react_1.default.createElement(Component, rest, __(children));
    }
}
FormattedMessage.contextType = intl_1.IntlContext;
FormattedMessage.defaultProps = {
    component: getComponent_1.Text
};
exports.FormattedMessage = FormattedMessage;
