"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 _WidthProvider = require("../WidthProvider");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766

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 || 14,
      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));
  });
}