import { getTranslatableField } from '@sentecacommerce-theme/lib';
var LabelDTOLocationEnum;

(function (LabelDTOLocationEnum) {
  LabelDTOLocationEnum["TopLeft"] = "top-left";
  LabelDTOLocationEnum["TopRight"] = "top-right";
  LabelDTOLocationEnum["BottomLeft"] = "bottom-left";
  LabelDTOLocationEnum["BottomRight"] = "bottom-right";
})(LabelDTOLocationEnum || (LabelDTOLocationEnum = {}));

export var mapLabels = (_ref) => {
  var {
    labels,
    isListing = false,
    discountedPrice
  } = _ref;
  var positionCounter = discountedPrice ? 1 : 0;
  var mappedLabels = labels.map((el, i) => {
    return {
      _id: el._id,
      version: el.version,
      key: el.key,
      name: getTranslatableField(el.name),
      // getTranslatableField
      description: getTranslatableField(el.description),
      // getTranslatableField
      location: getPosition(el.location, discountedPrice && isListing ? i + 1 : i, isListing, Boolean(el.icon)),
      // LocationEnum
      isIcon: Boolean(el.icon),
      icon: el.icon,
      appearance: getAppearance(el),
      backgroundColor: el.backgroundColor,
      color: el.color
    };
  });
  return mappedLabels;
};

var getPosition = (location, positionCounter, isListing, isIcon) => {
  var res = '';
  var shift = isListing ? positionCounter * 3 + 1 : positionCounter * 3.5 + 2;

  if (isListing) {
    res += "bottom: " + shift + "rem; left: 0;";
    positionCounter++;
  } else {
    res += "top: " + shift + "rem; left: 1.3rem;";
    positionCounter++;
  } // switch (location) {
  //   case LabelDTOLocationEnum.BottomLeft:
  //     res += `bottom: 1rem; left: ${shift}rem;`
  //     positionCounter++
  //     break
  //   case LabelDTOLocationEnum.BottomRight:
  //     res += `bottom: 1rem; right: ${shift}rem;`
  //     positionCounter++
  //     break
  //   case LabelDTOLocationEnum.TopLeft:
  //     res += `top: ${isListing ? 1 : 2}rem; left: ${shift}rem;`
  //     positionCounter++
  //     break
  //   case LabelDTOLocationEnum.TopRight:
  //     res += `top: ${isListing ? 1 : 2}rem; right: ${shift}rem;`
  //     positionCounter++
  //     break
  //   default:
  //     res += ''
  //     break
  // }


  return res;
};

var getAppearance = el => {
  var appearance = "";
  appearance += "width: 10rem; height: fit-content;";

  if (!el.icon) {
    appearance += "color: " + el.color + "; background: " + el.backgroundColor + ";"; // if (el.shape === 'circle') {
    //   appearance += `border-radius: 50%;`
    // }
  }

  return appearance;
};
//# sourceMappingURL=LabelUtils.js.map