import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _extends from "@babel/runtime/helpers/esm/extends";
import { roundedArrow } from './roundedArrow';

function connectArrowCls(classList) {
  var showArrowCls = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  return classList.map(function (cls) {
    return "".concat(showArrowCls).concat(cls);
  }).join(',');
}

export default function getArrowStyle(token, colorBg, showArrowCls) {
  var _componentCls;

  var componentCls = token.componentCls,
      sizePopupArrow = token.sizePopupArrow,
      marginXXS = token.marginXXS;
  var dropdownArrowOffset = sizePopupArrow / Math.sqrt(2) * 2;
  var dropdownArrowDistance = sizePopupArrow + marginXXS;
  return _defineProperty({}, componentCls, (_componentCls = {}, _defineProperty(_componentCls, "".concat(componentCls, "-arrow"), [_extends(_extends({
    position: 'absolute',
    zIndex: 1,
    display: 'block',
    width: sizePopupArrow,
    height: sizePopupArrow
  }, roundedArrow(sizePopupArrow, 5, colorBg)), {
    '&:before': {
      background: colorBg
    }
  })]), _defineProperty(_componentCls, ["&-placement-top ".concat(componentCls, "-arrow"), "&-placement-topLeft ".concat(componentCls, "-arrow"), "&-placement-topRight ".concat(componentCls, "-arrow")].join(','), {
    bottom: 0,
    boxShadow: token.boxShadowPopoverArrow,
    transform: 'translateY(50%) rotate(45deg)'
  }), _defineProperty(_componentCls, "&-placement-top ".concat(componentCls, "-arrow"), {
    left: {
      _skip_check_: true,
      value: '50%'
    },
    transform: 'translateX(-50%) translateY(50%) rotate(45deg)'
  }), _defineProperty(_componentCls, "&-placement-topLeft ".concat(componentCls, "-arrow"), {
    left: {
      _skip_check_: true,
      value: dropdownArrowOffset
    }
  }), _defineProperty(_componentCls, "&-placement-topRight ".concat(componentCls, "-arrow"), {
    right: {
      _skip_check_: true,
      value: dropdownArrowOffset
    }
  }), _defineProperty(_componentCls, ["&-placement-bottom ".concat(componentCls, "-arrow"), "&-placement-bottomLeft ".concat(componentCls, "-arrow"), "&-placement-bottomRight ".concat(componentCls, "-arrow")].join(','), {
    top: 0,
    boxShadow: token.boxShadowPopoverArrowBottom,
    transform: "translateY(-50%) rotate(-135deg)"
  }), _defineProperty(_componentCls, "&-placement-bottom ".concat(componentCls, "-arrow"), {
    left: {
      _skip_check_: true,
      value: '50%'
    },
    transform: "translateX(-50%) translateY(-50%) rotate(-135deg)"
  }), _defineProperty(_componentCls, "&-placement-bottomLeft ".concat(componentCls, "-arrow"), {
    left: {
      _skip_check_: true,
      value: dropdownArrowOffset
    }
  }), _defineProperty(_componentCls, "&-placement-bottomRight ".concat(componentCls, "-arrow"), {
    right: {
      _skip_check_: true,
      value: dropdownArrowOffset
    }
  }), _defineProperty(_componentCls, ["&-placement-left ".concat(componentCls, "-arrow"), "&-placement-leftTop ".concat(componentCls, "-arrow"), "&-placement-leftBottom ".concat(componentCls, "-arrow")].join(','), {
    right: {
      _skip_check_: true,
      value: 0
    },
    boxShadow: token.boxShadowPopoverArrow,
    transform: 'translateX(50%) rotate(-45deg)'
  }), _defineProperty(_componentCls, "&-placement-left ".concat(componentCls, "-arrow"), {
    top: {
      _skip_check_: true,
      value: '50%'
    },
    transform: 'translateY(-50%) translateX(50%) rotate(-45deg)'
  }), _defineProperty(_componentCls, "&-placement-leftTop ".concat(componentCls, "-arrow"), {
    top: dropdownArrowOffset
  }), _defineProperty(_componentCls, "&-placement-leftBottom ".concat(componentCls, "-arrow"), {
    bottom: dropdownArrowOffset
  }), _defineProperty(_componentCls, ["&-placement-right ".concat(componentCls, "-arrow"), "&-placement-rightTop ".concat(componentCls, "-arrow"), "&-placement-rightBottom ".concat(componentCls, "-arrow")].join(','), {
    left: {
      _skip_check_: true,
      value: 0
    },
    boxShadow: token.boxShadowPopoverArrow,
    transform: 'translateX(-50%) rotate(135deg)'
  }), _defineProperty(_componentCls, "&-placement-right ".concat(componentCls, "-arrow"), {
    top: {
      _skip_check_: true,
      value: '50%'
    },
    transform: 'translateY(-50%) translateX(-50%) rotate(135deg)'
  }), _defineProperty(_componentCls, "&-placement-rightTop ".concat(componentCls, "-arrow"), {
    top: dropdownArrowOffset
  }), _defineProperty(_componentCls, "&-placement-rightBottom ".concat(componentCls, "-arrow"), {
    bottom: dropdownArrowOffset
  }), _defineProperty(_componentCls, connectArrowCls(["&-placement-topLeft", "&-placement-top", "&-placement-topRight"], showArrowCls), {
    paddingBottom: dropdownArrowDistance
  }), _defineProperty(_componentCls, connectArrowCls(["&-placement-bottomLeft", "&-placement-bottom", "&-placement-bottomRight"], showArrowCls), {
    paddingTop: dropdownArrowDistance
  }), _defineProperty(_componentCls, connectArrowCls(["&-placement-leftTop", "&-placement-left", "&-placement-leftBottom"], showArrowCls), {
    paddingRight: {
      _skip_check_: true,
      value: dropdownArrowDistance
    }
  }), _defineProperty(_componentCls, connectArrowCls(["&-placement-rightTop", "&-placement-right", "&-placement-rightBottom"], showArrowCls), {
    paddingLeft: {
      _skip_check_: true,
      value: dropdownArrowDistance
    }
  }), _componentCls));
}