"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.BaseTheme = BaseTheme;
exports.BaseThemeWrapper = BaseThemeWrapper;
exports.mapBreakpointToLayoutMaxWidth = mapBreakpointToLayoutMaxWidth;
var _react = _interopRequireWildcard(require("react"));
var _react2 = require("@emotion/react");
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
var _constants = require("@atlaskit/theme/constants");
var _WidthProvider = require("../WidthProvider");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function mapBreakpointToLayoutMaxWidth(breakpoint) {
  switch (breakpoint) {
    case 'M':
    case 'L':
      return 760;
    default:
      return 680;
  }
}
function BaseThemeWrapper(_ref) {
  var baseFontSize = _ref.baseFontSize,
    children = _ref.children;
  var memoizedTheme = (0, _react.useMemo)(function () {
    return {
      baseFontSize: baseFontSize || (0, _constants.fontSize)(),
      layoutMaxWidth: _editorSharedStyles.akEditorDefaultLayoutWidth
    };
  }, [baseFontSize]);
  return /*#__PURE__*/_react.default.createElement(_react2.ThemeProvider, {
    theme: memoizedTheme
  }, children);
}
function BaseTheme(_ref2) {
  var children = _ref2.children,
    baseFontSize = _ref2.baseFontSize;
  return /*#__PURE__*/_react.default.createElement(_WidthProvider.WidthConsumer, null, function (_ref3) {
    var breakpoint = _ref3.breakpoint;
    return /*#__PURE__*/_react.default.createElement(BaseThemeWrapper, {
      breakpoint: breakpoint,
      baseFontSize: baseFontSize
    }, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children));
  });
}