require('./NavigationDrawer_x642ct.css');
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var React = require('react');
var cls = require('classnames');
var react = require('@linaria/react');
var base$1 = require('./variations/_view/base.js');
var base = require('./variations/_size/base.js');
var NavigationDrawer_styles = require('./NavigationDrawer.styles.js');
var NavigationDrawer_tokens = require('./NavigationDrawer.tokens.js');
var Section = require('./ui/Section/Section.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);
var cls__default = /*#__PURE__*/_interopDefault(cls);

var _excluded = ["opened", "header", "sections", "footer", "withContentLeft", "mode", "onHide", "children"];
var Wrapper = /*#__PURE__*/react.styled('div')({
  name: "Wrapper",
  "class": "wp29eiz",
  propsAsIs: false
});
var navigationDrawerRoot = function navigationDrawerRoot(Root) {
  return /*#__PURE__*/React.forwardRef(function (props, ref) {
    var _props$opened = props.opened,
      opened = _props$opened === void 0 ? true : _props$opened,
      header = props.header,
      sections = props.sections,
      footer = props.footer,
      _props$withContentLef = props.withContentLeft,
      withContentLeft = _props$withContentLef === void 0 ? true : _props$withContentLef,
      _props$mode = props.mode,
      mode = _props$mode === void 0 ? 'static' : _props$mode,
      onHide = props.onHide,
      children = props.children,
      rest = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
    var isOpen = opened || !withContentLeft;
    var isOverlay = mode === 'overlay' || mode === 'drawer';
    return /*#__PURE__*/React__default.default.createElement(Root, _rollupPluginBabelHelpers.extends({
      ref: ref
    }, rest), /*#__PURE__*/React__default.default.createElement(Wrapper, {
      className: cls__default.default(NavigationDrawer_tokens.classes.navigationDrawerSidebar, isOverlay && NavigationDrawer_tokens.classes.navigationDrawerSidebarOverlay, !isOpen && NavigationDrawer_tokens.classes.navigationDrawerSidebarClosed)
    }, header, sections.map(function (_ref, index) {
      var items = _ref.items,
        label = _ref.label,
        hasDivider = _ref.hasDivider;
      return /*#__PURE__*/React__default.default.createElement(Section.Section, {
        key: index,
        items: items,
        label: label,
        withContentLeft: withContentLeft,
        isOpen: isOpen,
        hasDivider: hasDivider
      });
    }), footer && /*#__PURE__*/React__default.default.createElement(NavigationDrawer_styles.Footer, null, footer)), mode === 'overlay' && opened && /*#__PURE__*/React__default.default.createElement(NavigationDrawer_styles.Overlay, {
      onClick: onHide
    }), /*#__PURE__*/React__default.default.createElement(NavigationDrawer_styles.Content, {
      className: cls__default.default(isOverlay && NavigationDrawer_tokens.classes.navigationDrawerContentOverlay)
    }, children));
  });
};
var navigationDrawerConfig = {
  name: 'NavigationDrawer',
  tag: 'div',
  layout: navigationDrawerRoot,
  base: NavigationDrawer_styles.base,
  variations: {
    size: {
      css: base.base
    },
    view: {
      css: base$1.base
    }
  },
  defaults: {
    view: 'default'
  }
};

exports.navigationDrawerConfig = navigationDrawerConfig;
exports.navigationDrawerRoot = navigationDrawerRoot;
