'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.SquardRow = undefined;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _reactRedux = require('react-redux');

var _reactBootstrap = require('react-bootstrap');

var _reselect = require('reselect');

var _gameUtils = require('views/utils/game-utils');

var _slotitems = require('./slotitems');

var _selectors = require('views/utils/selectors');

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

const { i18n } = window;
const __ = i18n.main.__.bind(i18n.main);

const SquardRow = exports.SquardRow = (0, _reactRedux.connect)((state, { squardId }) => (0, _reselect.createSelector)([(0, _selectors.landbaseSelectorFactory)(squardId), (0, _selectors.landbaseEquipDataSelectorFactory)(squardId)], (landbase, equipsData) => ({
  landbase,
  equipsData,
  squardId
})))(({ landbase, equipsData, squardId }) => {
  let { api_action_kind, api_distance, api_name, api_nowhp, api_maxhp } = landbase;
  api_nowhp = api_nowhp || 200;
  api_maxhp = api_maxhp || 200;
  const tyku = (0, _gameUtils.getTyku)([equipsData], api_action_kind);
  const hpPercentage = api_nowhp / api_maxhp * 100;
  const statuslabel = (() => {
    switch (api_action_kind) {
      // 0=待機, 1=出撃, 2=防空, 3=退避, 4=休息
      case 0:
        return _react2.default.createElement(
          _reactBootstrap.Label,
          { bsStyle: 'default' },
          __('Standby')
        );
      case 1:
        return _react2.default.createElement(
          _reactBootstrap.Label,
          { bsStyle: 'danger' },
          __('Sortie')
        );
      case 2:
        return _react2.default.createElement(
          _reactBootstrap.Label,
          { bsStyle: 'warning' },
          __('Defense')
        );
      case 3:
        return _react2.default.createElement(
          _reactBootstrap.Label,
          { bsStyle: 'primary' },
          __('Retreat')
        );
      case 4:
        return _react2.default.createElement(
          _reactBootstrap.Label,
          { bsStyle: 'success' },
          __('Rest')
        );
    }
  })();
  return _react2.default.createElement(
    'div',
    { className: 'ship-item' },
    _react2.default.createElement(
      'div',
      { className: 'ship-tile' },
      _react2.default.createElement(
        'div',
        { className: 'ship-basic-item' },
        _react2.default.createElement(
          'div',
          { className: 'ship-info' },
          _react2.default.createElement(
            'span',
            { className: 'ship-name' },
            api_name
          ),
          _react2.default.createElement(
            'div',
            { className: 'ship-exp' },
            _react2.default.createElement(
              'span',
              { className: 'ship-lv' },
              __('Range'),
              ': ',
              api_distance
            ),
            _react2.default.createElement(
              'span',
              { className: 'ship-speed' },
              __('Fighter Power'),
              ': ',
              tyku.max
            )
          )
        ),
        _react2.default.createElement(
          'div',
          { className: 'ship-stat landbase-stat' },
          _react2.default.createElement(
            'div',
            { className: 'div-row' },
            _react2.default.createElement(
              'span',
              { className: 'ship-hp' },
              api_nowhp,
              ' / ',
              api_maxhp
            ),
            _react2.default.createElement(
              'div',
              { className: 'lbac-status-label' },
              statuslabel
            )
          ),
          _react2.default.createElement(
            'span',
            { className: 'hp-progress top-space' },
            _react2.default.createElement(_reactBootstrap.ProgressBar, { bsStyle: (0, _gameUtils.getHpStyle)(hpPercentage),
              now: hpPercentage })
          )
        )
      )
    ),
    _react2.default.createElement(
      'div',
      { className: 'ship-slot' },
      _react2.default.createElement(_slotitems.LandbaseSlotitems, { landbaseId: squardId, isMini: false })
    )
  );
});