import _objectSpread from "@babel/runtime/helpers/objectSpread";
import _extends from "@babel/runtime/helpers/extends";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { style, classes } from 'typestyle';
import Card from '@material-ui/core/Card';
var cn = {
  flex: style({
    display: 'flex'
  }),
  max: style({
    maxHeight: '100%'
  })
};

var getCn = function getCn(props) {
  return {
    root: style({
      position: 'relative',
      width: 0,
      order: props.order,
      boxSizing: 'border-box',
      maxWidth: '100%',
      maxHeight: '100%',
      height: '100%',
      direction: 'ltr',
      flex: '0 0 auto',
      flexBasis: props.visible ? props.flexBasis : 0,
      padding: props.visible ? '16px 20px 16px 0' : 0,
      overflow: props.visible ? 'initial' : 'hidden'
    }),
    card: style({
      display: 'flex',
      flex: 1,
      flexDirection: 'column',
      position: 'relative',
      overflow: 'visible' // position: sticky のために必要

    })
  };
};

var CardWindow =
/*#__PURE__*/
function (_PureComponent) {
  _inherits(CardWindow, _PureComponent);

  function CardWindow() {
    _classCallCheck(this, CardWindow);

    return _possibleConstructorReturn(this, _getPrototypeOf(CardWindow).apply(this, arguments));
  }

  _createClass(CardWindow, [{
    key: "render",
    value: function render() {
      var dcn = getCn(this.props);
      var fit = this.props.fit;
      return React.createElement("div", {
        id: this.props.name,
        className: classes(dcn.root, fit ? cn.flex : cn.max)
      }, React.createElement(Card, _extends({}, this.cardProps, {
        className: classes(dcn.card, fit ? cn.flex : cn.max)
      }), this.props.children), this.props.footer || null, React.createElement("div", {
        id: "".concat(this.props.name, "-BottomAnchor")
      }));
    }
  }, {
    key: "cardProps",
    get: function get() {
      var props = _objectSpread({}, this.props);

      for (var key in CardWindow.propTypes) {
        delete props[key];
      }

      return props;
    }
  }]);

  return CardWindow;
}(PureComponent);

_defineProperty(CardWindow, "propTypes", {
  name: PropTypes.string.isRequired,
  visible: PropTypes.bool.isRequired,
  order: PropTypes.number.isRequired,
  cardProps: PropTypes.object.isRequired,
  fit: PropTypes.bool.isRequired,
  showAll: PropTypes.bool.isRequired,
  footer: PropTypes.node,
  flexBasis: PropTypes.string.isRequired
});

_defineProperty(CardWindow, "defaultProps", {
  visible: false,
  fit: false,
  footer: null,
  flexBasis: '50%'
});

export { CardWindow as default };