text: 'use strict';
  
  exports.__esModule = true;
  
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  
  var _react = require('react');
  
  var _react2 = _interopRequireDefault(_react);
  
  var _propTypes = require('prop-types');
  
  var _propTypes2 = _interopRequireDefault(_propTypes);
  
  var _reactContainerDimensions = require('react-container-dimensions');
  
  var _reactContainerDimensions2 = _interopRequireDefault(_reactContainerDimensions);
  
  var _IconButton = require('material-ui/IconButton/IconButton');
  
  var _IconButton2 = _interopRequireDefault(_IconButton);
  
  var _ListMenu = require('./ListMenu.js');
  
  var _ListMenu2 = _interopRequireDefault(_ListMenu);
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  var styles = {
    menu_container: {
      display: 'flex',
      width: '100%',
      justifyContent: 'flex-end',
      margin: 0,
      padding: 0
    }
  };
  
  var getIcon = function getIcon(item, i) {
    if (item.seperator) {
      return undefined;
    } else if (item.menu) {
      return item.getSelectMenuItems();
    } else {
      return _react2.default.createElement(
        _IconButton2.default,
        {
          key: i,
          disabled: item.disabled,
          onClick: item.onClick,
          tooltip: item.tooltip },
        item.icon
      );
    }
  };
  
  var Menu = function Menu(props) {
    var iconMenuColor = props.iconMenuColor,
        width = props.width,
        marginCorrection = props.marginCorrection,
        iconWidth = props.iconWidth,
        menuList = props.menuList;
  
  
    var icons = [];
    var menus = [];
  
    var visibleItems = menuList.filter(function (item) {
      return item.hidden !== true;
    });
    var iconW = iconWidth !== undefined ? iconWidth : 48;
    var correction = marginCorrection !== undefined ? marginCorrection : 0;
    var breackLimit = visibleItems.length * iconW;
  
    var hiddenWidth = breackLimit - width - correction;
    var hiddenIcons = Math.ceil(hiddenWidth / iconW) + 1;
  
    if (hiddenIcons > 0) {
      menus = visibleItems.slice(visibleItems.length - hiddenIcons, visibleItems.length), icons = visibleItems.slice(0, hiddenIcons * -1);
    } else {
      menus = [];
      icons = visibleItems;
    }
  
    return _react2.default.createElement(
      'div',
      {
        style: styles.menu_container,
        ref: function ref(container) {
          undefined.menuContainer = container;
        } },
      icons.map(function (item, i) {
        return getIcon(item, i);
      }),
      menus.length != 0 && _react2.default.createElement(_ListMenu2.default, {
        items: menus,
        iconMenuColor: iconMenuColor
      })
    );
  };
  
  var ResponsiveMenu = function ResponsiveMenu(props) {
    return _react2.default.createElement(
      _reactContainerDimensions2.default,
      null,
      function (_ref) {
        var width = _ref.width;
        return _react2.default.createElement(Menu, _extends({ width: width }, props));
      }
    );
  };
  
  ResponsiveMenu.propTypes = process.env.NODE_ENV !== "production" ? {
    menuList: _propTypes2.default.array.isRequired,
    iconWidth: _propTypes2.default.number,
    marginCorrection: _propTypes2.default.number,
    iconMenuColor: _propTypes2.default.string
  } : {};
  
  exports.default = ResponsiveMenu;
  module.exports = exports['default'];