"use strict";

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

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

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

var _reactEasyState = require("react-easy-state");

var _env = _interopRequireDefault(require("../env"));

var _emphasize = _interopRequireDefault(require("../utils/emphasize"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

const fg = _env.default.KTRM_UI_THEME_BG;

const lineNb = str => Math.ceil(str.length / (process.stdout.columns * 3 / 4 - 2));

class Volumes extends _react.Component {
  render() {
    const mounts = this.props.data.Mounts.map(entry => [entry.Source, entry.Destination]);
    let currentHeight = 0;
    return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement("box", {
      width: "75%",
      shrink: true,
      left: "25%",
      top: "0%+3",
      height: "100%-4",
      alwaysScroll: true,
      scrollable: true,
      mouse: true,
      label: " Volumes ",
      border: {
        type: 'line'
      },
      style: {
        border: {
          fg
        }
      }
    }, mounts.map((entry, i) => {
      const content = `${entry[0]} ${(0, _emphasize.default)('→')} ${entry[1]}`;
      const envHeight = lineNb(content);
      currentHeight += envHeight;
      return _react.default.createElement("box", {
        shrink: true,
        key: i,
        top: `0%+${currentHeight - envHeight}`,
        height: `0%+${envHeight}`,
        tags: true,
        content: content
      });
    })));
  }

}

Volumes.propTypes = {
  data: _propTypes.default.object
};

var _default = (0, _reactEasyState.view)(Volumes);

exports.default = _default;