import React, { useMemo } from 'react';
import { PisellEntityCard } from "../pisellEntityCard";
import "./PisellCustomerBrief.less";

/**
 * PisellCustomerBrief 客户简要卡片
 * 基于 PisellEntityCard，用于展示客户（Customer）实体的核心识别信息与客户级属性。
 * 设计文档：Customer Info (pcl_customerInfon_V1.0)
 *
 * - 无头像时显示默认占位 Avatar
 * - 文本过长按配置省略
 * - Actions 为空时不占位
 *
 * @param props 组件 Props
 */
export function PisellCustomerBrief(_ref) {
  var name = _ref.name,
    subtitle = _ref.subtitle,
    avatar = _ref.avatar,
    email = _ref.email,
    address = _ref.address,
    company = _ref.company,
    date = _ref.date,
    _ref$extendedFields = _ref.extendedFields,
    extendedFields = _ref$extendedFields === void 0 ? [] : _ref$extendedFields,
    _ref$tags = _ref.tags,
    tags = _ref$tags === void 0 ? [] : _ref$tags,
    _ref$actions = _ref.actions,
    actions = _ref$actions === void 0 ? [] : _ref$actions,
    _ref$showActions = _ref.showActions,
    showActions = _ref$showActions === void 0 ? false : _ref$showActions,
    _ref$showAvatar = _ref.showAvatar,
    showAvatar = _ref$showAvatar === void 0 ? true : _ref$showAvatar,
    _ref$showPrimaryText = _ref.showPrimaryText,
    showPrimaryText = _ref$showPrimaryText === void 0 ? true : _ref$showPrimaryText,
    _ref$showSubtitle = _ref.showSubtitle,
    showSubtitle = _ref$showSubtitle === void 0 ? true : _ref$showSubtitle,
    _ref$showExtended = _ref.showExtended,
    showExtended = _ref$showExtended === void 0 ? true : _ref$showExtended,
    _ref$showTags = _ref.showTags,
    showTags = _ref$showTags === void 0 ? true : _ref$showTags,
    _ref$density = _ref.density,
    density = _ref$density === void 0 ? 'B2' : _ref$density,
    _ref$layout = _ref.layout,
    layout = _ref$layout === void 0 ? 'horizontal' : _ref$layout,
    _ref$width = _ref.width,
    width = _ref$width === void 0 ? 'content' : _ref$width,
    _ref$swipeToDelete = _ref.swipeToDelete,
    swipeToDelete = _ref$swipeToDelete === void 0 ? false : _ref$swipeToDelete,
    onDelete = _ref.onDelete,
    _ref$tagPosition = _ref.tagPosition,
    tagPosition = _ref$tagPosition === void 0 ? 'below' : _ref$tagPosition,
    contentGap = _ref.contentGap,
    primaryLineClamp = _ref.primaryLineClamp,
    secondaryLineClamp = _ref.secondaryLineClamp,
    renderMedia = _ref.renderMedia,
    renderPrimary = _ref.renderPrimary,
    renderSubtitle = _ref.renderSubtitle,
    renderSecondary = _ref.renderSecondary,
    renderTags = _ref.renderTags,
    renderActions = _ref.renderActions,
    className = _ref.className,
    style = _ref.style,
    hoverStyle = _ref.hoverStyle,
    activeStyle = _ref.activeStyle,
    disabledStyle = _ref.disabledStyle,
    _ref$clickable = _ref.clickable,
    clickable = _ref$clickable === void 0 ? true : _ref$clickable,
    _ref$disabled = _ref.disabled,
    disabled = _ref$disabled === void 0 ? false : _ref$disabled,
    onClick = _ref.onClick;
  /** 媒体区：头像，无 src 时 EntityCard 会显示默认占位 */
  var media = useMemo(function () {
    if (!showAvatar) return undefined;
    return {
      type: 'avatar',
      src: avatar,
      alt: name,
      size: 40,
      shape: 'circle'
    };
  }, [showAvatar, avatar, name]);

  /** 扩展信息 → 次级文案列表，顺序：email、address、company、date、extendedFields */
  var secondaryTexts = useMemo(function () {
    if (!showExtended) return [];
    var list = [];
    if (email) list.push({
      text: email
    });
    if (address) list.push({
      text: address
    });
    if (company) list.push({
      text: company
    });
    if (date) list.push({
      text: date
    });
    extendedFields.forEach(function (f) {
      return list.push({
        text: f.text,
        showTooltip: f.showTooltip
      });
    });
    return list;
  }, [showExtended, email, address, company, date, extendedFields]);
  return /*#__PURE__*/React.createElement(PisellEntityCard, {
    className: "pisell-customer-brief-root ".concat(className !== null && className !== void 0 ? className : '').trim(),
    style: style,
    hoverStyle: hoverStyle,
    activeStyle: activeStyle,
    disabledStyle: disabledStyle,
    clickable: clickable,
    disabled: disabled,
    onClick: onClick,
    media: media,
    primaryText: name,
    subtitleText: subtitle,
    secondaryTexts: secondaryTexts,
    tags: tags,
    actions: actions,
    showMedia: showAvatar,
    showPrimaryText: showPrimaryText,
    showSubtitle: showSubtitle,
    showSecondaryText: showExtended,
    showTags: showTags,
    showActions: showActions,
    density: density,
    layout: layout,
    width: width,
    swipeToDelete: swipeToDelete,
    onDelete: onDelete,
    tagPosition: tagPosition,
    contentGap: contentGap,
    primaryLineClamp: primaryLineClamp,
    secondaryLineClamp: secondaryLineClamp,
    renderMedia: renderMedia,
    renderPrimary: renderPrimary,
    renderSubtitle: renderSubtitle,
    renderSecondary: renderSecondary,
    renderTags: renderTags,
    renderActions: renderActions
  });
}