"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;

class Ports extends _react.Component {
  render() {
    const NS = this.props.data.NetworkSettings.Ports;
    const ports = Object.keys(NS).map(from => [from.slice(0, from.indexOf('/')), `${NS[from][0].HostIp}:${NS[from][0].HostPort}`]);
    return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement("box", {
      width: "75%",
      shrink: true,
      scroll: true,
      left: "25%",
      top: "0%+3",
      label: " General ",
      border: {
        type: 'line'
      },
      style: {
        border: {
          fg
        }
      }
    }, _react.default.createElement("box", {
      shrink: true,
      tags: true,
      content: `${(0, _emphasize.default)('Hostname:')} ${this.props.data.Config.Hostname}`
    })), _react.default.createElement("box", {
      width: "75%",
      shrink: true,
      left: "25%",
      top: "0%+7",
      height: "100%-8",
      alwaysScroll: true,
      scrollable: true,
      mouse: true,
      label: " Ports Mapping ",
      border: {
        type: 'line'
      },
      style: {
        border: {
          fg
        }
      }
    }, ports.map((entry, i) => _react.default.createElement("box", {
      shrink: true,
      key: i,
      top: `0%+${i}`,
      tags: true,
      content: `{bold}${entry[0]}{/bold} → ${entry[1]}`
    }))));
  }

}

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

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

exports.default = _default;