"use strict";

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

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

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

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

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

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

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

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

var _react = _interopRequireWildcard(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _classnames2 = _interopRequireDefault(require("classnames"));

var _lib = _interopRequireDefault(require("@instructure/ui-themeable/lib"));

var _theme = _interopRequireDefault(require("./theme"));

var _dec, _class, _class2, _temp;

var styles = {
  componentId: 'fwguO',
  template: function template(theme) {
    return "\n\n.fwguO_gasz{display:flex;font-family:".concat(theme.fontFamily || 'inherit', ";height:100%;margin:0}\n\n@media screen and (--phoneBreakPoint){.fwguO_caGd{-webkit-overflow-scrolling:touch}}\n\n.fwguO_caGd{transition:transform 0.3s;width:100%}\n\n.fwguO_dxaC{overflow-x:hidden;overflow-y:auto}");
  },
  'wrapper': 'fwguO_gasz',
  'content': 'fwguO_caGd',
  'scrollable': 'fwguO_dxaC'
};
var Page = (_dec = (0, _lib.default)(_theme.default, styles), _dec(_class = (_temp = _class2 =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(Page, _Component);

  function Page() {
    (0, _classCallCheck2.default)(this, Page);
    return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Page).apply(this, arguments));
  }

  (0, _createClass2.default)(Page, [{
    key: "shouldRenderSidebar",
    value: function shouldRenderSidebar() {
      return this.props.sidebarComponent != null && this.props.sidebarOpen != null;
    }
  }, {
    key: "renderSidebar",
    value: function renderSidebar() {
      return _react.default.createElement(this.props.sidebarComponent, {
        role: this.props.sidebarRole,
        sidebarOpen: this.props.sidebarOpen,
        toggleSidebar: this.props.toggleSidebar
      });
    }
  }, {
    key: "render",
    value: function render() {
      var childrenWrapperStyles = (0, _classnames2.default)(styles.content, (0, _defineProperty2.default)({}, styles.scrollable, this.shouldRenderSidebar()));
      return _react.default.createElement("div", {
        className: styles.wrapper
      }, this.shouldRenderSidebar() ? this.renderSidebar() : null, _react.default.createElement("div", {
        role: this.props.contentRole,
        className: childrenWrapperStyles
      }, this.props.children));
    }
  }]);
  Page.displayName = "Page";
  return Page;
}(_react.Component), _class2.propTypes = {
  children: _propTypes.default.node.isRequired,
  contentRole: _propTypes.default.string,
  sidebarComponent: _propTypes.default.func,
  sidebarOpen: _propTypes.default.bool,
  sidebarRole: _propTypes.default.string,
  toggleSidebar: _propTypes.default.func
}, _class2.defaultProps = {
  contentRole: 'main',
  sidebarComponent: null,
  sidebarOpen: null,
  sidebarRole: 'navigation',
  toggleSidebar: function toggleSidebar() {}
}, _temp)) || _class);
exports.default = Page;