"use strict";

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

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.generateShades = exports.generateStripe = exports.colorEmphasis = exports.generateAlphaColors = exports.diminish = exports.intensify = exports.isDarkColor = exports.addBlack = exports.addWhite = exports.addOpacity = exports.get = void 0;

var _react = require("@emotion/react");

var _color = _interopRequireDefault(require("color"));

var get = function get(color, hue) {
  return "".concat(color, ".").concat(hue);
};

exports.get = get;

var addOpacity = function addOpacity(color, opacity) {
  return (0, _color["default"])(color).fade(1 - opacity).rgb().string();
};

exports.addOpacity = addOpacity;

var addWhite = function addWhite(color, opacity) {
  return (0, _color["default"])(color).mix((0, _color["default"])('#fff'), opacity).hex();
};

exports.addWhite = addWhite;

var addBlack = function addBlack(color, opacity) {
  return (0, _color["default"])(color).mix((0, _color["default"])('#000'), opacity).hex();
};

exports.addBlack = addBlack;

var isDarkColor = function isDarkColor(color) {
  return (0, _color["default"])(color).isDark();
};

exports.isDarkColor = isDarkColor;

var intensify = function intensify(color) {
  var factor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.2;
  var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'light';
  var p = (0, _color["default"])(color);

  if (mode === 'light') {
    return p.darken(factor);
  }

  return p.lighten(factor);
};

exports.intensify = intensify;

var diminish = function diminish(color) {
  var factor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.2;
  var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'light';
  var p = (0, _color["default"])(color);

  if (mode === 'light') {
    return p.lighten(factor);
  }

  return p.darken(factor);
};

exports.diminish = diminish;

var generateAlphaColors = function generateAlphaColors(color) {
  return {
    900: addOpacity(color, 0.92),
    800: addOpacity(color, 0.8),
    700: addOpacity(color, 0.6),
    600: addOpacity(color, 0.48),
    500: addOpacity(color, 0.38),
    400: addOpacity(color, 0.24),
    300: addOpacity(color, 0.16),
    200: addOpacity(color, 0.12),
    100: addOpacity(color, 0.08),
    50: addOpacity(color, 0.04)
  };
};

exports.generateAlphaColors = generateAlphaColors;

var colorEmphasis = function colorEmphasis(color, emphasis) {
  switch (emphasis) {
    case 'high':
      return color;

    case 'medium':
      return generateAlphaColors(color)[700];

    case 'low':
      return generateAlphaColors(color)[500];

    case 'lowest':
      return generateAlphaColors(color)[300];

    default:
      return null;
  }
};

exports.colorEmphasis = colorEmphasis;

var generateStripe = function generateStripe(_ref) {
  var _ref$size = _ref.size,
      size = _ref$size === void 0 ? '1rem' : _ref$size,
      _ref$color = _ref.color,
      color = _ref$color === void 0 ? 'rgba(255, 255, 255, 0.15)' : _ref$color;
  return /*#__PURE__*/(0, _react.css)("background-image:linear-gradient(\n        45deg,\n        ", color, " 25%,\n        transparent 25%,\n        transparent 50%,\n        ", color, " 50%,\n        ", color, " 75%,\n        transparent 75%,\n        transparent\n    );background-size:", size, " ", size, ";" + (process.env.NODE_ENV === "production" ? "" : ";label:generateStripe;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90aGVtZS9jb2xvcnMtdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBc0U2RiIsImZpbGUiOiIuLi8uLi9zcmMvdGhlbWUvY29sb3JzLXV0aWxzLnRzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuaW1wb3J0IENvbG9yIGZyb20gJ2NvbG9yJztcblxuZXhwb3J0IGNvbnN0IGdldCA9IChjb2xvciwgaHVlKSA9PiBgJHtjb2xvcn0uJHtodWV9YDtcblxuZXhwb3J0IGNvbnN0IGFkZE9wYWNpdHkgPSAoY29sb3IsIG9wYWNpdHkpID0+XG4gICAgQ29sb3IoY29sb3IpXG4gICAgICAgIC5mYWRlKDEgLSBvcGFjaXR5KVxuICAgICAgICAucm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A9PiBjc3NgXG4gICAgYmFja2dyb3VuZC1pbWFnZTogbGluZWFyLWdyYWRpZW50KFxuICAgICAgICA0NWRlZyxcbiAgICAgICAgJHtjb2xvcn0gMjUlLFxuICAgICAgICB0cmFuc3BhcmVudCAyNSUsXG4gICAgICAgIHRyYW5zcGFyZW50IDUwJSxcbiAgICAgICAgJHtjb2xvcn0gNTAlLFxuICAgICAgICAke2NvbG9yfSA3NSUsXG4gICAgICAgIHRyYW5zcGFyZW50IDc1JSxcbiAgICAgICAgdHJhbnNwYXJlbnRcbiAgICApO1xuICAgIGJhY2tncm91bmQtc2l6ZTogJHtzaXplfSAke3NpemV9O1xuYDtcblxuZXhwb3J0IGNvbnN0IGdlbmVyYXRlU2hhZGVzID0gcHJpbWFyeSA9PiB7XG4gICAgY29uc3QgcCA9IENvbG9yKHByaW1hcnkpO1xuXG4gICAgY29uc3Qgc2hhZGVzID0ge1xuICAgICAgICA1MDogcC5saWdodGVuKDAuOCksXG4gICAgICAgIDEwMDogcC5saWdodGVuKDAuNCksXG4gICAgICAgIDIwMDogcC5saWdodGVuKDAuMyksXG4gICAgICAgIDMwMDogcC5saWdodGVuKDAuMiksXG4gICAgICAgIDQwMDogcC5saWdodGVuKDAuMSksXG4gICAgICAgIDUwMDogcCxcbiAgICAgICAgNjAwOiBwLmRhcmtlbigwLjEpLFxuICAgICAgICA3MDA6IHAuZGFya2VuKDAuMiksXG4gICAgICAgIDgwMDogcC5kYXJrZW4oMC4zKSxcbiAgICAgICAgOTAwOiBwLmRhcmtlbigwLjQpLFxuICAgIH07XG5cbiAgICBmb3IgKGNvbnN0IGtleSBpbiBzaGFkZXMpIHtcbiAgICAgICAgc2hhZGVzW2tleV0gPSBzaGFkZXNba2V5XS5oZXgoKTtcbiAgICB9XG5cbiAgICByZXR1cm4gc2hhZGVzO1xufTtcbiJdfQ== */");
};

exports.generateStripe = generateStripe;

var generateShades = function generateShades(primary) {
  var p = (0, _color["default"])(primary);
  var shades = {
    50: p.lighten(0.8),
    100: p.lighten(0.4),
    200: p.lighten(0.3),
    300: p.lighten(0.2),
    400: p.lighten(0.1),
    500: p,
    600: p.darken(0.1),
    700: p.darken(0.2),
    800: p.darken(0.3),
    900: p.darken(0.4)
  };

  for (var key in shades) {
    shades[key] = shades[key].hex();
  }

  return shades;
};

exports.generateShades = generateShades;
//# sourceMappingURL=colors-utils.js.map