"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Text = exports.TextTransform = exports.TextType = void 0;
const classnames_1 = __importDefault(require("classnames"));
const react_1 = __importStar(require("react"));
var TextType;
(function (TextType) {
    TextType["Body"] = "body";
    TextType["Small"] = "small";
    TextType["Caption"] = "caption";
    TextType["Label"] = "label";
})(TextType || (exports.TextType = TextType = {}));
// Refactor to globalize for Headings too
var TextTransform;
(function (TextTransform) {
    TextTransform["Uppercase"] = "u-uppercase";
})(TextTransform || (exports.TextTransform = TextTransform = {}));
exports.Text = (0, react_1.forwardRef)(function Text(props, ref) {
    const defaultProps = Object.assign({ type: TextType.Body }, props);
    const transformClasses = {};
    if (props.transforms) {
        props.transforms.forEach((transform) => (transformClasses[transform] = true));
    }
    const extraClasses = {};
    if (props.className) {
        props.className.split(' ').forEach((it) => (extraClasses[it] = true));
    }
    const classes = (0, classnames_1.default)(props.align, Object.assign(Object.assign({ [`text-${defaultProps.type}`]: defaultProps.type, 'u-inline-flex': props.inline, 'u-text-bold': props.bold, 'u-pre-wrap': props.preformatted, 'u-line-through': props.lineThrough }, extraClasses), transformClasses));
    const styles = Object.assign({}, (defaultProps.style || {}));
    if (defaultProps.color) {
        styles.color = defaultProps.color;
    }
    // Use <div> if asDiv is true, otherwise <p>
    const Wrapper = props.asDiv ? 'div' : 'p';
    return (react_1.default.createElement(Wrapper, { className: classes, style: styles, ref: ref }, props.children));
});
exports.default = exports.Text;
//# sourceMappingURL=Text.js.map