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/pro/Cards/components/SKUCard/index.tsx
var SKUCard_exports = {};
__export(SKUCard_exports, {
  default: () => SKUCard_default
});
module.exports = __toCommonJS(SKUCard_exports);
var import_react = __toESM(require("react"));
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_classnames = __toESM(require("classnames"));
var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
var import_locales = __toESM(require("./locales"));
var import_useThemeTokens = __toESM(require("../../../../hooks/useThemeTokens"));
var import_index = require("./index.less");
var SKUCard = ({
  cover,
  title,
  subtitle,
  price,
  arrow,
  selected,
  disabled,
  onClick,
  renderRight,
  skuCardConfig,
  skuDisabled,
  theme
}) => {
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
  const { colorPrimary, colorPrimaryBg } = (0, import_useThemeTokens.default)(theme);
  const context = (0, import_useEngineContext.default)();
  const language = ((_c = (_b = (_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils) == null ? void 0 : _b.storage) == null ? void 0 : _c.get("umi_locale")) || "en";
  import_utils.locales.init(import_locales.default, language);
  const titleStyle = (0, import_react.useMemo)(() => {
    const config = skuCardConfig == null ? void 0 : skuCardConfig.title;
    const style = {};
    if (disabled) {
      style.color = "#98A2B3";
    } else if (config == null ? void 0 : config.color) {
      style.color = config.color;
    }
    if (config == null ? void 0 : config.fontSize) {
      style.fontSize = config.fontSize;
    }
    if (config == null ? void 0 : config.fontWeight) {
      style.fontWeight = config.fontWeight;
    }
    if ((config == null ? void 0 : config.lineClamp) && (config == null ? void 0 : config.lineClamp) > 0) {
      style.display = "-webkit-box";
      style.WebkitLineClamp = config.lineClamp;
      style.lineClamp = config.lineClamp;
      style.WebkitBoxOrient = "vertical";
      style.overflow = "hidden";
    }
    return style;
  }, [skuCardConfig == null ? void 0 : skuCardConfig.title, disabled]);
  const subTitleStyle = (0, import_react.useMemo)(() => {
    const config = skuCardConfig == null ? void 0 : skuCardConfig.subTitle;
    const style = {};
    if (disabled) {
      style.color = "#98A2B3";
    } else if (config == null ? void 0 : config.color) {
      style.color = config.color;
    }
    if (config == null ? void 0 : config.fontSize) {
      style.fontSize = config.fontSize;
    }
    if (config == null ? void 0 : config.fontWeight) {
      style.fontWeight = config.fontWeight;
    }
    if ((config == null ? void 0 : config.lineClamp) && (config == null ? void 0 : config.lineClamp) > 0) {
      style.WebkitLineClamp = config.lineClamp;
      style.lineClamp = config.lineClamp;
    }
    return style;
  }, [skuCardConfig == null ? void 0 : skuCardConfig.subTitle, disabled]);
  const priceStyle = (0, import_react.useMemo)(() => {
    const config = skuCardConfig == null ? void 0 : skuCardConfig.price;
    const style = {};
    if (disabled) {
      style.color = "#98A2B3";
    } else if (config == null ? void 0 : config.color) {
      style.color = config.color;
    }
    if (config == null ? void 0 : config.fontSize) {
      style.fontSize = config.fontSize;
    }
    if (config == null ? void 0 : config.fontWeight) {
      style.fontWeight = config.fontWeight;
    }
    return style;
  }, [skuCardConfig == null ? void 0 : skuCardConfig.price, disabled]);
  const imageStyle = (0, import_react.useMemo)(() => {
    const config = skuCardConfig == null ? void 0 : skuCardConfig.image;
    const style = {};
    if (config == null ? void 0 : config.width) {
      style.width = config.width;
    }
    if (config == null ? void 0 : config.height) {
      style.height = config.height;
    }
    if ((config == null ? void 0 : config.borderRadius) !== void 0) {
      style.borderRadius = typeof config.borderRadius === "number" ? `${config.borderRadius}px` : config.borderRadius;
    }
    if (config == null ? void 0 : config.border) {
      style.border = config.border;
    }
    return style;
  }, [skuCardConfig == null ? void 0 : skuCardConfig.image]);
  const disabledTextStyle = (0, import_react.useMemo)(() => {
    const config = skuCardConfig == null ? void 0 : skuCardConfig.disabledText;
    const style = {};
    if (config == null ? void 0 : config.color) {
      style.color = config.color;
    }
    if (config == null ? void 0 : config.fontSize) {
      style.fontSize = config.fontSize;
    }
    if (config == null ? void 0 : config.fontWeight) {
      style.fontWeight = config.fontWeight;
    }
    return style;
  }, [skuCardConfig == null ? void 0 : skuCardConfig.disabledText]);
  const showTitle = ((_d = skuCardConfig == null ? void 0 : skuCardConfig.title) == null ? void 0 : _d.visible) !== false;
  const showSubTitle = ((_e = skuCardConfig == null ? void 0 : skuCardConfig.subTitle) == null ? void 0 : _e.visible) !== false;
  const showPrice = ((_f = skuCardConfig == null ? void 0 : skuCardConfig.price) == null ? void 0 : _f.visible) !== false;
  const showImage = ((_g = skuCardConfig == null ? void 0 : skuCardConfig.image) == null ? void 0 : _g.visible) !== false;
  const showDisabledText = ((_h = skuCardConfig == null ? void 0 : skuCardConfig.disabledText) == null ? void 0 : _h.visible) !== false;
  const titleText = (0, import_react.useMemo)(() => {
    if (!title) return "";
    if (title.length < 2) {
      return title.toUpperCase();
    }
    return title.substring(0, 2).toUpperCase();
  }, [title]);
  console.log("disabledTextStyle >>>>>>>>>", disabledTextStyle);
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)("pisell-pro-cards-sku-card", {
        "pisell-pro-cards-sku-card-active": selected,
        "pisell-pro-cards-sku-card-with-image": showImage,
        "pisell-pro-cards-sku-card-no-image": !showImage,
        "pisell-pro-cards-sku-card-disabled": disabled
      }),
      onClick: () => {
        if (disabled) return;
        onClick == null ? void 0 : onClick();
      },
      style: {
        cursor: disabled ? "not-allowed" : "pointer",
        ["--color-primary"]: colorPrimary,
        ["--color-primary-bg"]: colorPrimaryBg
      }
    },
    !!skuDisabled && !!showDisabledText && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-pro-cards-sku-card-disabled-mask" }, /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: "pisell-pro-cards-sku-card-disabled-text",
        style: disabledTextStyle
      },
      ((_i = skuCardConfig == null ? void 0 : skuCardConfig.disabledText) == null ? void 0 : _i.text) || import_utils.locales.getText("pisell2.pro.cards.skuCard.disabledText")
    )),
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-pro-cards-sku-card-left" }, showImage && /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: "pisell-pro-cards-sku-card-image-container",
        style: imageStyle
      },
      !!cover ? /* @__PURE__ */ import_react.default.createElement(
        "img",
        {
          src: import_utils.image.ali(cover, 360),
          alt: title,
          className: "pisell-pro-cards-sku-card-image"
        }
      ) : /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-pro-cards-sku-card-image-default" }, titleText)
    ), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-pro-cards-sku-card-content" }, showTitle && title && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-pro-cards-sku-card-title", style: titleStyle }, title), showSubTitle && subtitle && /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: "pisell-pro-cards-sku-card-subtitle",
        style: subTitleStyle
      },
      subtitle
    ), showPrice && price && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-pro-cards-sku-card-price", style: priceStyle }, price))),
    arrow || renderRight ? /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: "pisell-pro-cards-sku-card-right",
        style: renderRight ? {} : { padding: "0 8px", alignItems: "center" }
      },
      renderRight ? typeof renderRight === "function" ? renderRight() : renderRight : /* @__PURE__ */ import_react.default.createElement(
        import_materials.Iconfont,
        {
          type: "pisell2-chevron-right",
          style: {
            fontSize: "28px",
            color: disabled ? "#f2f2f2" : "#475467"
          }
        }
      )
    ) : null
  );
};
var SKUCard_default = SKUCard;
