"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.StyledRoot = exports.StyledPositioner = exports.StyledNotificationCircle = exports.StyledHintDot = exports.StyledBadge = void 0;

var _styles = require("../styles");

var _constants = require("./constants");

var _ROLE$badge, _ROLE$notificationCir, _ROLE$hintDot, _Object$freeze;

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

// @ts-ignore
function getColorStyles(_ref) {
  var _HIERARCHY$primary, _HIERARCHY$secondary, _COLOR_STYLES;

  var $theme = _ref.$theme,
      $hierarchy = _ref.$hierarchy,
      $color = _ref.$color;
  var COLOR_STYLES = (_COLOR_STYLES = {}, _defineProperty(_COLOR_STYLES, _constants.HIERARCHY.primary, (_HIERARCHY$primary = {}, _defineProperty(_HIERARCHY$primary, _constants.COLOR.accent, {
    color: $theme.colors.contentOnColor,
    backgroundColor: $theme.colors.backgroundAccent
  }), _defineProperty(_HIERARCHY$primary, _constants.COLOR.primary, {
    color: $theme.colors.contentInversePrimary,
    backgroundColor: $theme.colors.backgroundInversePrimary
  }), _defineProperty(_HIERARCHY$primary, _constants.COLOR.positive, {
    color: $theme.colors.contentOnColor,
    backgroundColor: $theme.colors.backgroundPositive
  }), _defineProperty(_HIERARCHY$primary, _constants.COLOR.negative, {
    color: $theme.colors.contentOnColor,
    backgroundColor: $theme.colors.backgroundNegative
  }), _defineProperty(_HIERARCHY$primary, _constants.COLOR.warning, {
    color: $theme.colors.contentOnColorInverse,
    backgroundColor: $theme.colors.backgroundWarning
  }), _HIERARCHY$primary)), _defineProperty(_COLOR_STYLES, _constants.HIERARCHY.secondary, (_HIERARCHY$secondary = {}, _defineProperty(_HIERARCHY$secondary, _constants.COLOR.accent, {
    color: $theme.colors.contentAccent,
    backgroundColor: $theme.colors.backgroundAccentLight
  }), _defineProperty(_HIERARCHY$secondary, _constants.COLOR.primary, {
    color: $theme.colors.contentPrimary,
    backgroundColor: $theme.colors.backgroundSecondary
  }), _defineProperty(_HIERARCHY$secondary, _constants.COLOR.positive, {
    color: $theme.colors.contentPositive,
    backgroundColor: $theme.colors.backgroundPositiveLight
  }), _defineProperty(_HIERARCHY$secondary, _constants.COLOR.negative, {
    color: $theme.colors.contentNegative,
    backgroundColor: $theme.colors.backgroundNegativeLight
  }), _defineProperty(_HIERARCHY$secondary, _constants.COLOR.warning, {
    color: $theme.colors.contentWarning,
    backgroundColor: $theme.colors.backgroundWarningLight
  }), _HIERARCHY$secondary)), _COLOR_STYLES); // @ts-ignore

  return COLOR_STYLES[$hierarchy][$color];
}

var DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT = {
  top: '-10px',
  right: '-10px'
};
var DEFAULT_HINT_DOT_PLACEMENT = {
  top: '-4px',
  right: '-4px'
};
var POSITION_STYLES = Object.freeze((_Object$freeze = {}, _defineProperty(_Object$freeze, _constants.ROLE.badge, (_ROLE$badge = {}, _defineProperty(_ROLE$badge, _constants.PLACEMENT.topEdge, {
  top: '-8px',
  left: '50%',
  transform: 'translateX(-50%)'
}), _defineProperty(_ROLE$badge, _constants.PLACEMENT.bottomEdge, {
  bottom: '-8px',
  left: '50%',
  transform: 'translateX(-50%)'
}), _defineProperty(_ROLE$badge, _constants.PLACEMENT.topLeft, {
  top: '16px',
  left: '16px'
}), _defineProperty(_ROLE$badge, _constants.PLACEMENT.topRight, {
  top: '16px',
  right: '16px'
}), _defineProperty(_ROLE$badge, _constants.PLACEMENT.bottomRight, {
  bottom: '16px',
  right: '16px'
}), _defineProperty(_ROLE$badge, _constants.PLACEMENT.bottomLeft, {
  bottom: '16px',
  left: '16px'
}), _defineProperty(_ROLE$badge, _constants.PLACEMENT.topLeftEdge, {
  top: '-8px',
  left: '16px'
}), _defineProperty(_ROLE$badge, _constants.PLACEMENT.topRightEdge, {
  top: '-8px',
  right: '16px'
}), _defineProperty(_ROLE$badge, _constants.PLACEMENT.bottomRightEdge, {
  bottom: '-8px',
  right: '16px'
}), _defineProperty(_ROLE$badge, _constants.PLACEMENT.bottomLeftEdge, {
  bottom: '-8px',
  left: '16px'
}), _defineProperty(_ROLE$badge, _constants.PLACEMENT.leftTopEdge, {
  top: '16px',
  left: '-8px'
}), _defineProperty(_ROLE$badge, _constants.PLACEMENT.rightTopEdge, {
  top: '16px',
  right: '-8px'
}), _defineProperty(_ROLE$badge, _constants.PLACEMENT.rightBottomEdge, {
  bottom: '16px',
  right: '-8px'
}), _defineProperty(_ROLE$badge, _constants.PLACEMENT.leftBottomEdge, {
  bottom: '16px',
  left: '-8px'
}), _ROLE$badge)), _defineProperty(_Object$freeze, _constants.ROLE.notificationCircle, (_ROLE$notificationCir = {}, _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.topLeft, {
  top: '-10px',
  left: '-10px'
}), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.topRight, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.topEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.bottomEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.bottomRight, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.bottomLeft, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.topLeftEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.topRightEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.bottomRightEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.bottomLeftEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.leftTopEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.rightTopEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.rightBottomEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.leftBottomEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _ROLE$notificationCir)), _defineProperty(_Object$freeze, _constants.ROLE.hintDot, (_ROLE$hintDot = {}, _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.topLeft, {
  top: '-4px',
  left: '-4px'
}), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.topRight, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.topEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.bottomEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.bottomRight, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.bottomLeft, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.topLeftEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.topRightEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.bottomRightEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.bottomLeftEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.leftTopEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.rightTopEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.rightBottomEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.leftBottomEdge, DEFAULT_HINT_DOT_PLACEMENT), _ROLE$hintDot)), _Object$freeze));
var StyledRoot = (0, _styles.styled)('div', function () {
  return {
    position: 'relative',
    display: 'inline-block',
    lineHeight: 'initial'
  };
});
exports.StyledRoot = StyledRoot;
StyledRoot.displayName = "StyledRoot";
StyledRoot.displayName = 'StyledRoot';
var TOP_PLACEMENTS = [_constants.PLACEMENT.topLeft, _constants.PLACEMENT.topRight, _constants.PLACEMENT.topLeftEdge, _constants.PLACEMENT.topEdge, _constants.PLACEMENT.topRightEdge, _constants.PLACEMENT.leftTopEdge, _constants.PLACEMENT.rightTopEdge];
var BOTTOM_PLACEMENTS = [_constants.PLACEMENT.bottomLeft, _constants.PLACEMENT.bottomRight, _constants.PLACEMENT.bottomLeftEdge, _constants.PLACEMENT.bottomEdge, _constants.PLACEMENT.bottomRightEdge, _constants.PLACEMENT.leftBottomEdge, _constants.PLACEMENT.rightBottomEdge];
var LEFT_PLACEMENTS = [_constants.PLACEMENT.topLeft, _constants.PLACEMENT.topLeftEdge, _constants.PLACEMENT.topEdge, _constants.PLACEMENT.bottomLeft, _constants.PLACEMENT.bottomLeftEdge, _constants.PLACEMENT.bottomEdge, _constants.PLACEMENT.leftTopEdge, _constants.PLACEMENT.leftBottomEdge];
var RIGHT_PLACEMENTS = [_constants.PLACEMENT.topRight, _constants.PLACEMENT.topRightEdge, _constants.PLACEMENT.bottomRight, _constants.PLACEMENT.bottomRightEdge, _constants.PLACEMENT.rightTopEdge, _constants.PLACEMENT.rightBottomEdge];
var StyledPositioner = (0, _styles.styled)('div', function (_ref2) {
  var $theme = _ref2.$theme,
      $role = _ref2.$role,
      $placement = _ref2.$placement,
      $horizontalOffset = _ref2.$horizontalOffset,
      $verticalOffset = _ref2.$verticalOffset;
  var positionStyle = POSITION_STYLES[$role][$placement];

  if ($verticalOffset) {
    if (TOP_PLACEMENTS.includes($placement)) {
      positionStyle = _objectSpread(_objectSpread({}, positionStyle), {}, {
        top: $verticalOffset
      });
    }

    if (BOTTOM_PLACEMENTS.includes($placement)) {
      positionStyle = _objectSpread(_objectSpread({}, positionStyle), {}, {
        bottom: $verticalOffset
      });
    }
  }

  if ($horizontalOffset) {
    if (LEFT_PLACEMENTS.includes($placement)) {
      positionStyle = _objectSpread(_objectSpread({}, positionStyle), {}, {
        left: $horizontalOffset
      });
    }

    if (RIGHT_PLACEMENTS.includes($placement)) {
      positionStyle = _objectSpread(_objectSpread({}, positionStyle), {}, {
        right: $horizontalOffset
      });
    }
  }

  return _objectSpread(_objectSpread({}, positionStyle), {}, {
    position: 'absolute',
    lineHeight: 'initial'
  });
});
exports.StyledPositioner = StyledPositioner;
StyledPositioner.displayName = "StyledPositioner";
StyledPositioner.displayName = 'StyledPositioner';
var StyledBadge = (0, _styles.styled)('div', function (_ref3) {
  var $theme = _ref3.$theme,
      _ref3$$shape = _ref3.$shape,
      $shape = _ref3$$shape === void 0 ? _constants.SHAPE.rectangle : _ref3$$shape,
      _ref3$$color = _ref3.$color,
      $color = _ref3$$color === void 0 ? _constants.COLOR.accent : _ref3$$color,
      _ref3$$hierarchy = _ref3.$hierarchy,
      $hierarchy = _ref3$$hierarchy === void 0 ? _constants.HIERARCHY.primary : _ref3$$hierarchy,
      $hidden = _ref3.$hidden;
  return _objectSpread(_objectSpread({
    visibility: $hidden ? 'hidden' : 'inherit',
    boxSizing: 'border-box',
    height: $theme.sizing.scale700,
    borderRadius: $shape === _constants.SHAPE.rectangle ? $theme.borders.radius200 : $theme.borders.radius500,
    paddingRight: $shape === _constants.SHAPE.rectangle ? $theme.sizing.scale100 : $theme.sizing.scale300,
    paddingLeft: $shape === _constants.SHAPE.rectangle ? $theme.sizing.scale100 : $theme.sizing.scale300,
    display: 'inline-flex',
    alignItems: 'center'
  }, getColorStyles({
    $theme: $theme,
    $hierarchy: $hierarchy,
    $color: $color
  })), $hierarchy === _constants.HIERARCHY.primary ? $theme.typography.LabelSmall : $theme.typography.ParagraphSmall);
});
exports.StyledBadge = StyledBadge;
StyledBadge.displayName = "StyledBadge";
StyledBadge.displayName = 'StyledBadge';
var StyledNotificationCircle = (0, _styles.styled)('div', function (_ref4) {
  var $theme = _ref4.$theme,
      _ref4$$color = _ref4.$color,
      $color = _ref4$$color === void 0 ? _constants.COLOR.accent : _ref4$$color,
      $hidden = _ref4.$hidden;
  return _objectSpread(_objectSpread({
    visibility: $hidden ? 'hidden' : 'inherit',
    height: $theme.sizing.scale700,
    width: $theme.sizing.scale700,
    borderRadius: '20px',
    display: 'inline-flex',
    alignItems: 'center',
    justifyContent: 'center'
  }, getColorStyles({
    $theme: $theme,
    $hierarchy: _constants.HIERARCHY.primary,
    $color: $color
  })), $theme.typography.LabelXSmall);
});
exports.StyledNotificationCircle = StyledNotificationCircle;
StyledNotificationCircle.displayName = "StyledNotificationCircle";
StyledNotificationCircle.displayName = 'StyledNotificationCircle';
var StyledHintDot = (0, _styles.styled)('div', function (_ref5) {
  var $theme = _ref5.$theme,
      _ref5$$color = _ref5.$color,
      $color = _ref5$$color === void 0 ? _constants.COLOR.accent : _ref5$$color,
      $hidden = _ref5.$hidden;
  return _objectSpread({
    visibility: $hidden ? 'hidden' : 'inherit',
    // @ts-ignore
    backgroundColor: $theme.colors[$color],
    boxSizing: 'content-box',
    height: '8px',
    width: '8px',
    borderRadius: '50%',
    border: "4px solid ".concat($theme.colors.backgroundPrimary)
  }, getColorStyles({
    $theme: $theme,
    $hierarchy: _constants.HIERARCHY.primary,
    $color: $color
  }));
});
exports.StyledHintDot = StyledHintDot;
StyledHintDot.displayName = "StyledHintDot";
StyledHintDot.displayName = 'StyledHintDot';