import React, { useMemo } from 'react';
import classNames from 'classnames';
/**
 * TextContent 文本内容组件
 * 负责渲染主文本内容，处理文本省略逻辑
 *
 * @example
 * ```tsx
 * <TextContent
 *   text="这是一段很长的文本内容"
 *   textConfig={{
 *     maxLines: 2,
 *     ellipsis: true,
 *     fontSize: 14,
 *     color: '#333'
 *   }}
 * />
 * ```
 */
var TextContent = function TextContent(props) {
  var text = props.text,
    _props$textConfig = props.textConfig,
    textConfig = _props$textConfig === void 0 ? {} : _props$textConfig,
    className = props.className,
    active = props.active;
  var _textConfig$maxLines = textConfig.maxLines,
    maxLines = _textConfig$maxLines === void 0 ? 1 : _textConfig$maxLines,
    _textConfig$ellipsis = textConfig.ellipsis,
    ellipsis = _textConfig$ellipsis === void 0 ? true : _textConfig$ellipsis,
    fontSize = textConfig.fontSize,
    fontWeight = textConfig.fontWeight,
    color = textConfig.color,
    _textConfig$textAlign = textConfig.textAlign,
    textAlign = _textConfig$textAlign === void 0 ? 'left' : _textConfig$textAlign,
    flex = textConfig.flex;

  /**
   * 计算文本样式
   * 处理字体大小、粗细、颜色和省略号
   */
  var textStyle = useMemo(function () {
    var _active$style, _active$style3;
    var style = {
      textAlign: textAlign,
      flex: flex !== null && flex !== void 0 ? flex : 1
    };

    // 基础样式
    if (fontSize) style.fontSize = fontSize;
    if (fontWeight) style.fontWeight = fontWeight;
    if (color) style.color = color;
    if (active !== null && active !== void 0 && active.value && active !== null && active !== void 0 && (_active$style = active.style) !== null && _active$style !== void 0 && _active$style.color) {
      var _active$style2;
      style.color = active === null || active === void 0 || (_active$style2 = active.style) === null || _active$style2 === void 0 ? void 0 : _active$style2.color;
    }
    if (active !== null && active !== void 0 && active.value && active !== null && active !== void 0 && (_active$style3 = active.style) !== null && _active$style3 !== void 0 && _active$style3.fontWeight) {
      var _active$style4;
      style.fontWeight = active === null || active === void 0 || (_active$style4 = active.style) === null || _active$style4 === void 0 ? void 0 : _active$style4.fontWeight;
    }

    // 单行省略
    if (ellipsis && maxLines === 1) {
      style.overflow = 'hidden';
      style.textOverflow = 'ellipsis';
      style.whiteSpace = 'nowrap';
    }

    // 多行省略
    if (ellipsis && maxLines > 1) {
      style.overflow = 'hidden';
      style.textOverflow = '-o-ellipsis-lastline';
      style.textOverflow = 'ellipsis';
      style.display = '-webkit-box';
      style.WebkitLineClamp = maxLines;
      style.lineClamp = maxLines;
      style.WebkitBoxOrient = 'vertical';
      style.whiteSpace = 'normal';
    }
    return style;
  }, [active, fontSize, fontWeight, color, ellipsis, maxLines]);
  if (active !== null && active !== void 0 && active.value) {
    console.log('textStyle11', textStyle);
  }
  return /*#__PURE__*/React.createElement("div", {
    className: classNames('text-card__content', className),
    style: textStyle
  }, text);
};
export default TextContent;