function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import { lightTheme, darkTheme, a11yTheme } from '@nordnet/design-tokens';
import { deprecate, isNumber } from '../common/utils';
import { createLightColors, getColorLightScheme } from './createLightColors';
import { createDarkColors, getColorDarkScheme } from './createDarkColors';
var breakpoints = {
  xs: {
    size: 360,
    offset: 0
  },
  sm: {
    size: 768,
    offset: 6
  },
  md: {
    size: 992,
    offset: 6
  },
  lg: {
    size: 1280,
    offset: 6
  },
  xl: {
    size: 1680,
    offset: 6
  }
};
var size = {
  xs: 360,
  sm: 768,
  md: 992,
  lg: 1280,
  xl: 1680
};
var zIndex = {
  footer: 100,
  header: 200,
  dropdown: 300,
  overlay: 400,
  modal: 500,
  overlayInModal: 600
};
var getTokens = function getTokens(theme) {
  if (theme === 'dark') return darkTheme;
  if (theme === 'a11y') return a11yTheme;
  return lightTheme;
};
var massageShadowTokens = function massageShadowTokens(shadowTokens) {
  var shadows = Object.entries(shadowTokens).reduce(function (acc, _ref) {
    var _ref2 = _slicedToArray(_ref, 2),
      key = _ref2[0],
      value = _ref2[1];
    acc[key] = Object.values(value).join(', ');
    return acc;
  }, {});
  return shadows;
};
var getBreakpointNumber = function getBreakpointNumber(s) {
  return isNumber(s) ? s : s.size;
};
export var createTheme = function createTheme() {
  var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  var _config$a11yColors = config.a11yColors,
    a11yColors = _config$a11yColors === void 0 ? false : _config$a11yColors,
    _config$darkColors = config.darkColors,
    darkColors = _config$darkColors === void 0 ? false : _config$darkColors,
    _config$tokensTheme = config.tokensTheme,
    tokensTheme = _config$tokensTheme === void 0 ? 'light' : _config$tokensTheme;
  var type = a11yColors ? 'a11y' : 'default';
  var color = darkColors ? createDarkColors(getColorDarkScheme(type)) : createLightColors(getColorLightScheme(type));
  var tokens = getTokens(tokensTheme);
  var GUTTER = 5;
  var UNIT = 4;
  var unit = function unit(times) {
    return times * UNIT;
  };
  unit.valueOf = function () {
    return UNIT;
  };
  unit.toString = function () {
    return UNIT.toString();
  };
  var spacing = {
    unit: unit,
    gutter: GUTTER
  };
  var RADIUS_XSMALL = 2;
  var RADIUS_SMALL = 4;
  var RADIUS_MEDIUM = 8;
  var RADIUS_LARGE = 20;
  var RADIUS_100 = 100;
  var borderRadius = function borderRadius(x) {
    return "".concat(x.toString(), "px");
  };
  var borderRadius2 = "".concat(RADIUS_XSMALL, "px");
  var borderRadius4 = "".concat(RADIUS_SMALL, "px");
  var borderRadius8 = "".concat(RADIUS_MEDIUM, "px");
  var borderRadius20 = "".concat(RADIUS_LARGE, "px");
  var borderRadius100 = "".concat(RADIUS_100, "px");
  return {
    animation: {
      easing: {},
      duration: {}
    },
    breakpoints: breakpoints,
    color: color,
    colorTokens: tokens.color,
    lightColor: createLightColors(getColorLightScheme(type)),
    darkColor: createDarkColors(getColorDarkScheme(type)),
    shadow: massageShadowTokens(tokens.effect.shadow),
    isHighContrastMode: a11yColors,
    isDarkMode: darkColors,
    media: {
      between: function between(s1, s2) {
        var number1 = getBreakpointNumber(s1);
        var number2 = getBreakpointNumber(s2);
        return "@media (min-width: ".concat(number1, "px) and (max-width: ").concat(number2 - 1, "px)");
      },
      greaterThan: function greaterThan(s) {
        var number = getBreakpointNumber(s);
        return "@media (min-width: ".concat(number, "px)");
      },
      lessThan: function lessThan(s) {
        var number = getBreakpointNumber(s);
        return "@media (max-width: ".concat(number - 1, "px)");
      }
    },
    size: deprecate('theme.size, please use theme.breakpoint instead.')(size),
    spacing: spacing,
    zIndex: zIndex,
    borderRadius: borderRadius,
    borderRadius2: borderRadius2,
    borderRadius4: borderRadius4,
    borderRadius8: borderRadius8,
    borderRadius20: borderRadius20,
    borderRadius100: borderRadius100
  };
};