"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.useAlertIconStyle = exports.alertStyle = void 0;

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _ThemeProvider = require("../ThemeProvider");

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

var alertStyle = function alertStyle(_ref, _ref2) {
  var color = _ref.color,
      status = _ref.status;
  var colors = _ref2.colors;
  var alertColor = color || status;
  var bg = colors[alertColor][50] === colors['white'] ? colors[alertColor][100] : colors[alertColor][50];
  return {
    style: {
      display: 'flex',
      alignItems: 'center',
      position: 'relative',
      overflow: 'hidden',
      rounded: 'radius',
      p: 'spacing'
    },
    variants: {
      subtle: {
        bg: bg
      },
      solid: {
        bg: "".concat(alertColor, ".500"),
        color: 'white'
      },
      'left-accent': {
        bg: colors.pageBg,
        color: colors.titleText,
        borderLeft: '2px',
        borderColor: "".concat(alertColor, ".500"),
        roundedTopLeft: 0,
        roundedBottomLeft: 0
      },
      'top-accent': {
        bg: colors.pageBg,
        color: colors.titleText,
        borderTop: '2px',
        borderColor: "".concat(alertColor, ".500"),
        roundedTopLeft: 0,
        roundedTopRight: 0
      }
    },
    statuses: {
      info: {
        icon: 'info',
        color: 'info'
      },
      warning: {
        icon: 'warning-2',
        color: 'warning'
      },
      success: {
        icon: 'check-circle',
        color: 'success'
      },
      error: {
        icon: 'warning',
        color: 'error'
      }
    }
  };
};

exports.alertStyle = alertStyle;

var useAlertStyle = function useAlertStyle(props) {
  var theme = (0, _ThemeProvider.useTheme)();
  var styles = theme['styles'].alert ? theme['styles'].alert(props, theme) : alertStyle(props, theme);
  return {
    root: _objectSpread(_objectSpread({}, styles.style), styles.variants[props.variant || 'leftAccent']),
    status: styles.statuses[props.status]
  };
};

var useAlertIconStyle = function useAlertIconStyle(_ref3) {
  var variant = _ref3.variant,
      color = _ref3.color;

  if (['left-accent', 'top-accent', 'subtle'].includes(variant)) {
    return {
      height: '100%',
      color: "".concat(color, ".500")
    };
  }

  return {
    height: '100%'
  };
};

exports.useAlertIconStyle = useAlertIconStyle;
var _default = useAlertStyle;
exports["default"] = _default;
//# sourceMappingURL=styles.js.map