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/plus/productSelect/ProductCard/SkuCard/components/Favorite/index.tsx
var Favorite_exports = {};
__export(Favorite_exports, {
  default: () => Favorite_default
});
module.exports = __toCommonJS(Favorite_exports);
var import_react = __toESM(require("react"));
var import_materials = require("@pisell/materials");
var import_index = require("./index.less");
var import_status = require("../../status");
var PADDING = 4;
var Favorite = ({ props }) => {
  var _a;
  const { skuExtraConfig, className, dataSource, onFavorite } = props;
  const {
    isOpen,
    favoritePosition,
    favoriteIcon,
    favoriteBackground,
    favoritePaddingY,
    favoritePaddingX,
    favoriteRadius,
    isFavoriteBorder,
    favoriteBorderWidth,
    favoriteBorderColor,
    isFavorite
  } = skuExtraConfig || ((_a = import_status.productCardDefault) == null ? void 0 : _a.skuExtraConfig) || {};
  if (!isOpen || !isFavorite) return null;
  const finalStyle = (0, import_react.useMemo)(() => {
    const isLeft = favoritePosition === "left_top" || favoritePosition === "left_bottom";
    const isRight = favoritePosition === "right_top" || favoritePosition === "right_bottom";
    const isTop = favoritePosition === "left_top" || favoritePosition === "right_top";
    const isBottom = favoritePosition === "left_bottom" || favoritePosition === "right_bottom";
    return {
      background: favoriteBackground,
      padding: `${favoritePaddingY}px ${favoritePaddingX}px`,
      border: isFavoriteBorder ? `${favoriteBorderWidth}px solid ${favoriteBorderColor}` : "none",
      borderRadius: `${favoriteRadius}px`,
      top: isTop ? PADDING : "auto",
      bottom: isBottom ? PADDING : "auto",
      left: isLeft ? PADDING : "auto",
      right: isRight ? PADDING : "auto"
    };
  }, [
    favoriteBackground,
    favoritePaddingX,
    favoritePaddingY,
    isFavoriteBorder,
    favoriteBorderWidth,
    favoriteBorderColor,
    favoriteRadius,
    favoritePosition
  ]);
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: `${import_status.PREFIX}__card-favorite  ${className}`,
      style: finalStyle,
      onClick: (e) => {
        e.stopPropagation();
        onFavorite == null ? void 0 : onFavorite(dataSource);
      }
    },
    favoriteIcon || /* @__PURE__ */ import_react.default.createElement(import_materials.Icon, { type: "HeartFilled", size: 20, rotate: 0, spin: false, color: "#DC6803" })
  );
};
var Favorite_default = Favorite;
