'use strict';

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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _electron = require('electron');

var _divider = require('../components/divider');

var _divider2 = _interopRequireDefault(_divider);

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

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

var _lodash = require('lodash');

var _checkbox = require('../components/checkbox');

var _checkbox2 = _interopRequireDefault(_checkbox);

var _update = require('views/services/update');

var _contributors = require('poi-asset-contributor-data/dist/contributors.json');

var _contributors2 = _interopRequireDefault(_contributors);

var _reactFontawesome = require('react-fontawesome');

var _reactFontawesome2 = _interopRequireDefault(_reactFontawesome);

var _downloadProgress = require('./download-progress');

var _downloadProgress2 = _interopRequireDefault(_downloadProgress);

var _appMetrics = require('./app-metrics');

var _appMetrics2 = _interopRequireDefault(_appMetrics);

var _fcd = require('./fcd');

var _fcd2 = _interopRequireDefault(_fcd);

var _wctfDb = require('./wctf-db');

var _wctfDb2 = _interopRequireDefault(_wctfDb);

require('../assets/misc.css');

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

const { ROOT, POI_VERSION, CONST, i18n, config } = window;
const __ = i18n.setting.__.bind(i18n.setting);
const { changeChannel } = process.platform !== 'linux' ? _electron.remote.require('./lib/updater') : {};

config.on('config.set', (path, value) => {
  if (path === 'poi.betaChannel' && process.platform !== 'linux') {
    changeChannel(value ? "beta" : "latest");
  }
});

const getAvatarUrl = url => /.*githubusercontent.com\/u\/.*/.test(url) ? `${url}&s=160` : url;

function _ref(i) {
  return _react2.default.createElement(
    'a',
    {
      href: `https://opencollective.com/poi/sponsor/${i}/website`,
      key: i
    },
    _react2.default.createElement('img', { src: `https://opencollective.com/poi/sponsor/${i}/avatar.svg` })
  );
}

const Misc = (0, _reactRedux.connect)(state => ({
  layout: (0, _lodash.get)(state, 'config.poi.layout', 'horizontal')
}))(class Misc extends _react.Component {
  render() {
    return _react2.default.createElement(
      'div',
      { id: 'poi-others', className: 'poi-others' },
      _react2.default.createElement(
        _reactBootstrap.Grid,
        null,
        _react2.default.createElement(
          _reactBootstrap.Col,
          { xs: 12 },
          _react2.default.createElement('img', { src: `file://${ROOT}/assets/img/logo.png`, style: { width: '100%' } })
        )
      ),
      _react2.default.createElement(
        _reactBootstrap.Grid,
        null,
        _react2.default.createElement(
          _reactBootstrap.Row,
          null,
          _react2.default.createElement(
            _reactBootstrap.Col,
            { xs: 6 },
            _react2.default.createElement(_divider2.default, { text: `${__("Current version")}: ${POI_VERSION}` })
          ),
          _react2.default.createElement(
            _reactBootstrap.Col,
            { xs: 6 },
            _react2.default.createElement(_downloadProgress2.default, null)
          )
        )
      ),
      _react2.default.createElement(
        _reactBootstrap.Grid,
        null,
        _react2.default.createElement(
          _reactBootstrap.Col,
          { xs: 6 },
          _react2.default.createElement(
            _reactBootstrap.Button,
            { onClick: _update.checkUpdate },
            __("Check Update")
          )
        ),
        _react2.default.createElement(
          _reactBootstrap.Col,
          { xs: 6 },
          _react2.default.createElement(_checkbox2.default, {
            label: __('Check update of beta version'),
            configName: 'poi.betaChannel',
            defaultVal: false })
        ),
        _react2.default.createElement(
          _reactBootstrap.Col,
          { xs: 12 },
          _react2.default.createElement(
            'p',
            null,
            __("poi-description %s", process.versions.electron)
          ),
          _react2.default.createElement(
            'div',
            { className: 'desc-buttons' },
            ['zh-CN', 'zh-TW'].includes(window.language) && _react2.default.createElement(
              _reactBootstrap.Button,
              { onClick: _electron.shell.openExternal.bind(this, 'http://weibo.com/letspoi') },
              _react2.default.createElement(_reactFontawesome2.default, { name: 'weibo' }),
              ' @\u4ECA\u5929poi\u51FA\u65B0\u7248\u672C\u4E86\u5417'
            ),
            ['zh-CN', 'zh-TW'].includes(window.language) ? _react2.default.createElement(
              _reactBootstrap.Button,
              null,
              _react2.default.createElement(_reactFontawesome2.default, { name: 'qq' }),
              ' \u7528\u6237\u4EA4\u6D41\u7FA4\uFF1A 378320628 '
            ) : _react2.default.createElement(
              _reactBootstrap.Button,
              { onClick: _electron.shell.openExternal.bind(this, 'https://discordapp.com/channels/118339803660943369/367575898313981952') },
              'Discord channel'
            ),
            _react2.default.createElement(
              _reactBootstrap.Button,
              { onClick: _electron.shell.openExternal.bind(this, 'http://db.kcwiki.moe') },
              _react2.default.createElement(_reactFontawesome2.default, { name: 'database' }),
              ' ',
              __("Database")
            ),
            _react2.default.createElement(
              _reactBootstrap.Button,
              { onClick: _electron.shell.openExternal.bind(this, 'https://github.com/poooi/poi/wiki') },
              _react2.default.createElement(_reactFontawesome2.default, { name: 'question' }),
              ' ',
              __("Wiki")
            ),
            _react2.default.createElement(
              _reactBootstrap.Button,
              { onClick: _electron.shell.openExternal.bind(this, 'https://github.com/poooi/poi') },
              _react2.default.createElement(_reactFontawesome2.default, { name: 'github' }),
              ' GitHub'
            ),
            _react2.default.createElement(
              _reactBootstrap.Button,
              { onClick: _electron.shell.openExternal.bind(this, 'https://opencollective.com/poi') },
              'OpenCollective'
            )
          )
        )
      ),
      _react2.default.createElement(_divider2.default, { text: __("Data version") }),
      _react2.default.createElement(
        _reactBootstrap.Grid,
        null,
        _react2.default.createElement(
          _reactBootstrap.Col,
          { xs: 12 },
          _react2.default.createElement(_fcd2.default, null)
        ),
        _react2.default.createElement(
          _reactBootstrap.Col,
          { xs: 12 },
          _react2.default.createElement(_wctfDb2.default, null)
        )
      ),
      _react2.default.createElement(_divider2.default, { text: __('Performance Monitor') }),
      _react2.default.createElement(
        _reactBootstrap.Col,
        { xs: 12 },
        _react2.default.createElement(_appMetrics2.default, null)
      ),
      _react2.default.createElement(_divider2.default, { text: 'Contributors' }),
      _react2.default.createElement(
        _reactBootstrap.Grid,
        null,
        _react2.default.createElement(
          _reactBootstrap.Col,
          { xs: 12, className: 'contributors' },
          _contributors2.default.map((e, i) => _react2.default.createElement(
            'div',
            { key: i, className: 'contributor-item' },
            _react2.default.createElement('img', {
              className: 'avatar-img',
              src: getAvatarUrl(e.avatar_url),
              onClick: _electron.shell.openExternal.bind(this, e.html_url),
              title: e.name || e.login
            })
          ))
        )
      ),
      _react2.default.createElement(_divider2.default, { text: 'OpenCollective' }),
      _react2.default.createElement(
        _reactBootstrap.Grid,
        { className: 'opencollective container' },
        _react2.default.createElement(
          _reactBootstrap.Col,
          { xs: 12 },
          _react2.default.createElement(
            'div',
            null,
            (0, _lodash.range)(10).map(_ref)
          ),
          _react2.default.createElement(
            'div',
            null,
            _react2.default.createElement(
              'a',
              { href: 'https://opencollective.com/poi#backers' },
              _react2.default.createElement('img', { src: `https://opencollective.com/poi/backers.svg?width=${this.props.layout === 'horizontal' ? 450 : 900}` })
            )
          )
        )
      ),
      _react2.default.createElement(_divider2.default, { text: 'Special Thanks To' }),
      _react2.default.createElement(
        _reactBootstrap.Grid,
        { className: 'thanks-to sp-thanks-to' },
        _react2.default.createElement(
          'div',
          { className: 'div-row thanks-to-item' },
          _react2.default.createElement(
            'div',
            { className: 'thanks-to-img-container' },
            _react2.default.createElement('img', { className: 'thanks-to-img',
              src: 'https://upload.kcwiki.moe/commons/thumb/d/d1/Kcwiki-banner.png/600px-Kcwiki-banner.png',
              style: {
                WebkitClipPath: 'inset(0px 78% 0px 0px)',
                maxHeight: '100%',
                marginLeft: '5%'
              },
              onClick: _electron.shell.openExternal.bind(this, 'https://zh.kcwiki.moe/wiki/%E8%88%B0%E5%A8%98%E7%99%BE%E7%A7%91'),
              title: 'KCWiki'
            })
          ),
          _react2.default.createElement(
            'div',
            { className: 'thanks-to-container' },
            _react2.default.createElement(
              'b',
              null,
              'KCWiki'
            ),
            _react2.default.createElement(
              'p',
              null,
              'For sponsing poi data server, providing data of item imporvment, task info, shipgirl qoutes, etc.'
            )
          )
        )
      ),
      _react2.default.createElement(_divider2.default, { text: 'Thanks To' }),
      _react2.default.createElement(
        _reactBootstrap.Grid,
        { className: 'thanks-to' },
        CONST.thanksTo.map((e, i) => _react2.default.createElement(
          'div',
          { className: 'div-row thanks-to-item', key: i },
          _react2.default.createElement(
            'div',
            { className: 'thanks-to-img-container' },
            _react2.default.createElement('img', { className: 'thanks-to-img', src: e.avatar, style: e.extraCSS, onClick: _electron.shell.openExternal.bind(this, e.link), title: e.name })
          ),
          _react2.default.createElement(
            'div',
            { className: 'thanks-to-container' },
            _react2.default.createElement(
              'b',
              null,
              e.name
            ),
            _react2.default.createElement(
              'p',
              null,
              e.description
            )
          )
        ))
      )
    );
  }
});

exports.default = Misc;
module.exports = exports['default'];