"use strict";

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

exports.__esModule = true;
exports.default = void 0;

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

var _preset = _interopRequireDefault(require("@rebass/preset"));

var _ramdaExtension = require("ramda-extension");

var _tinycolor = _interopRequireDefault(require("tinycolor2"));

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 fontSizes = [12, 14, 18, 20, 22, 24, 27, 36, 49, 85];
var space = [0, 4, 8, 16, 32, 64, 96, 128, 256];
var breakpoints = ['40em', '52em', '76em'];
breakpoints.sm = breakpoints[0];
breakpoints.md = breakpoints[1];
breakpoints.lg = breakpoints[2];
var letterSpacings = ['-.5px', '0'];
letterSpacings.mono = letterSpacings[0];
letterSpacings.normal = letterSpacings[1];
var lightGray = '#e7e7e7';
var gray = '#b4b4b4';
var transparentStripesColor = (0, _tinycolor.default)(lightGray);

var getThumbStyles = function getThumbStyles(color) {
  return {
    color: color,
    width: ['18px', '18px', '24px'],
    height: ['18px', '18px', '24px']
  };
};

var getSliderStyles = function getSliderStyles(color) {
  return {
    height: '2px',
    color: color,
    '&:focus': {
      color: color
    },
    '&::-ms-thumb': getThumbStyles(color),
    '&::-moz-range-thumb': getThumbStyles(color),
    '&::-webkit-slider-thumb': getThumbStyles(color)
  };
};

var getStripesGradient = function getStripesGradient(width, alpha) {
  if (alpha === void 0) {
    alpha = 1;
  }

  return "repeating-linear-gradient(\n\t\t90deg, " + transparentStripesColor.setAlpha(alpha).toRgbString() + ",\n\t\t" + transparentStripesColor.setAlpha(alpha).toRgbString() + " 1px,\n\t\ttransparent 1px,\n\t\ttransparent " + width + "\n\t)";
};

var componentsPreset = {
  fonts: {
    body: 'Roboto',
    heading: 'Open Sans',
    mono: 'Roboto Mono'
  },
  breakpoints: breakpoints,
  space: space,
  fontSizes: fontSizes,
  colors: {
    background: '#f6f6f6',
    primary: '#0018ff',
    secondary: '#33d08e',
    muted: '#e7e7e7',
    contrast: '#ffffff',
    body: '#3b3b3b',
    danger: '#ff0000',
    gray: gray,
    lightGray: lightGray,
    highlight: 'hsla(205, 100%, 40%, 0.125)'
  },
  letterSpacings: ['-.5px', '0'],
  forms: {
    input: {
      fontFamily: 'body'
    },
    checkbox: {
      'input:checked ~ &': {
        color: 'secondary'
      },
      'input:focus ~ &': {
        color: 'secondary'
      }
    },
    label: {
      color: 'inherit'
    },
    switch: {
      thumb: 'secondary'
    },
    slider: _objectSpread({}, getSliderStyles('body'), {
      danger: getSliderStyles('danger'),
      disabled: _objectSpread({
        cursor: 'default'
      }, getSliderStyles('gray')),
      default: getSliderStyles('secondary')
    }),
    radio: {
      'input:checked ~ &': {
        color: 'secondary'
      },
      'input:focus ~ &': {
        color: 'secondary'
      }
    }
  },
  variants: {
    danger: {
      color: 'danger',
      'input:checked ~ *': {
        color: 'danger'
      },
      'input:focus ~ *': {
        color: 'danger'
      }
    },
    disabled: {
      color: 'gray',
      'input:checked ~ *': {
        color: 'gray'
      },
      'input:focus ~ *': {
        color: 'gray'
      }
    },
    secondary: {
      color: 'secondary'
    },
    stripes: {
      backgroundImage: [getStripesGradient('25%'), getStripesGradient('17%'), getStripesGradient('10%')]
    },
    transparentStripes: {
      backgroundImage: [getStripesGradient('25%', 0.2), getStripesGradient('17%', 0.2), getStripesGradient('10%', 0.2)]
    },
    nav: {
      transition: 'color .175s ease-in-out',
      fontSize: 2,
      fontWeight: 'bold',
      fontFamily: 'heading',
      display: 'inline-block',
      p: [3, 3, 0],
      color: ['#fff', '#fff', 'inherit'],
      textTransform: 'uppercase',
      textDecoration: 'none',
      ':hover,:focus,.active': {
        color: ['#fff', '#fff', 'primary']
      }
    },
    table: {
      overflowX: 'auto',
      border: '1px solid',
      borderCollapse: 'collapse'
    },
    tableCol: {
      p: [1, 2],
      border: '1px solid',
      fontSize: [0, 1, 2],
      wordWrap: 'break-word',
      maxWidth: '240px'
    },
    tableRow: {
      border: '1px solid'
    }
  }
};

var _default = function _default(userTheme) {
  return (0, _ramdaExtension.mergeDeepRightAll)([_preset.default, componentsPreset, {
    breakpointAliases: ['sm', 'md', 'lg', 'xl']
  }, userTheme]);
};

exports.default = _default;