var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pisellMetricCard/PisellMetricCard.tsx
var PisellMetricCard_exports = {};
__export(PisellMetricCard_exports, {
  default: () => PisellMetricCard_default
});
module.exports = __toCommonJS(PisellMetricCard_exports);
var import_react = __toESM(require("react"));
var import_pisellCard = __toESM(require("../pisellCard"));
var import_components = require("./components");
var import_utils = require("./utils");
var import_PisellMetricCard = require("./PisellMetricCard.less");
var PisellMetricCard = (props) => {
  const {
    // 核心数据
    title,
    subtitle,
    value,
    tag,
    tooltip,
    // 配置对象
    format,
    comparison,
    styleConfig,
    // 简单开关
    showSubtitle = false,
    showTag = false,
    showTooltip = false,
    loading = false,
    hoverable = true,
    // 通用属性
    className,
    style,
    onClick
  } = props;
  const formatConfig = (0, import_react.useMemo)(() => ({
    precision: (format == null ? void 0 : format.precision) ?? 0,
    useGrouping: (format == null ? void 0 : format.useGrouping) ?? false,
    showCurrencySymbol: (format == null ? void 0 : format.showCurrencySymbol) ?? false,
    currencySymbol: (format == null ? void 0 : format.currencySymbol) ?? "",
    formatter: format == null ? void 0 : format.formatter,
    hideDecimalForWholeNumbers: (format == null ? void 0 : format.hideDecimalForWholeNumbers) ?? true
  }), [format]);
  const cardStyle = (0, import_react.useMemo)(() => {
    var _a, _b, _c, _d, _e, _f;
    return {
      bordered: ((_a = styleConfig == null ? void 0 : styleConfig.card) == null ? void 0 : _a.bordered) ?? true,
      borderRadius: ((_b = styleConfig == null ? void 0 : styleConfig.card) == null ? void 0 : _b.borderRadius) ?? 12,
      padding: ((_c = styleConfig == null ? void 0 : styleConfig.card) == null ? void 0 : _c.padding) ?? 16,
      shadow: ((_d = styleConfig == null ? void 0 : styleConfig.card) == null ? void 0 : _d.shadow) ?? true,
      background: ((_e = styleConfig == null ? void 0 : styleConfig.card) == null ? void 0 : _e.background) ?? "#ffffff",
      width: ((_f = styleConfig == null ? void 0 : styleConfig.card) == null ? void 0 : _f.width) ?? "auto"
    };
  }, [styleConfig]);
  const titleStyle = (0, import_react.useMemo)(() => {
    var _a, _b, _c;
    return {
      size: ((_a = styleConfig == null ? void 0 : styleConfig.title) == null ? void 0 : _a.size) ?? 14,
      weight: ((_b = styleConfig == null ? void 0 : styleConfig.title) == null ? void 0 : _b.weight) ?? 400,
      color: ((_c = styleConfig == null ? void 0 : styleConfig.title) == null ? void 0 : _c.color) ?? "rgba(0, 0, 0, 0.45)"
    };
  }, [styleConfig]);
  const valueStyle = (0, import_react.useMemo)(() => {
    var _a, _b, _c;
    return {
      size: ((_a = styleConfig == null ? void 0 : styleConfig.value) == null ? void 0 : _a.size) ?? 30,
      weight: ((_b = styleConfig == null ? void 0 : styleConfig.value) == null ? void 0 : _b.weight) ?? 600,
      color: ((_c = styleConfig == null ? void 0 : styleConfig.value) == null ? void 0 : _c.color) ?? "rgba(0, 0, 0, 0.85)"
    };
  }, [styleConfig]);
  const formattedValue = (0, import_react.useMemo)(() => {
    return (0, import_utils.formatMetricValue)(value, formatConfig);
  }, [value, formatConfig]);
  const comparisonConfig = (0, import_react.useMemo)(() => {
    if (!(comparison == null ? void 0 : comparison.value)) return null;
    return {
      value: comparison.value,
      text: comparison.text ?? "v.s. pre",
      showTrendIcon: comparison.showTrendIcon ?? true,
      positiveColor: comparison.positiveColor ?? "#52c41a",
      negativeColor: comparison.negativeColor ?? "#ff4d4f",
      size: comparison.size ?? 14
    };
  }, [comparison]);
  return /* @__PURE__ */ import_react.default.createElement(
    import_pisellCard.default,
    {
      bordered: cardStyle.bordered,
      borderRadius: cardStyle.borderRadius,
      padding: cardStyle.padding,
      loading,
      isClickable: !!onClick,
      onClick,
      style: {
        width: typeof cardStyle.width === "number" ? `${cardStyle.width}px` : cardStyle.width,
        background: cardStyle.background,
        boxShadow: typeof cardStyle.shadow === "string" ? cardStyle.shadow : cardStyle.shadow ? "0px 1px 2px 0px rgba(16, 24, 40, 0.05)" : "none",
        ...style
      },
      className: `pisell-metric-card ${className || ""}`
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_components.MetricTitle,
      {
        title,
        subtitle: showSubtitle ? subtitle : void 0,
        tooltip: showTooltip ? tooltip : void 0,
        titleSize: titleStyle.size,
        titleWeight: titleStyle.weight,
        titleColor: titleStyle.color
      }
    ),
    /* @__PURE__ */ import_react.default.createElement(
      import_components.MetricValue,
      {
        value: formattedValue,
        valueSize: valueStyle.size,
        valueWeight: valueStyle.weight,
        valueColor: valueStyle.color
      }
    ),
    comparisonConfig && /* @__PURE__ */ import_react.default.createElement(
      import_components.MetricComparison,
      {
        comparison: comparisonConfig.value,
        comparisonText: comparisonConfig.text,
        showTrendIcon: comparisonConfig.showTrendIcon,
        positiveColor: comparisonConfig.positiveColor,
        negativeColor: comparisonConfig.negativeColor,
        comparisonSize: comparisonConfig.size,
        precision: formatConfig.precision,
        showCurrencySymbol: formatConfig.showCurrencySymbol,
        currencySymbol: formatConfig.currencySymbol
      }
    ),
    showTag && tag && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-metric-card-tag" }, tag)
  );
};
var PisellMetricCard_default = PisellMetricCard;
