'use strict';

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

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

const { config, i18n, POI_VERSION } = window;
const __ = window.i18n.others.__.bind(i18n.others);

// Readme contents
const dontShowAgain = () => config.set('poi.first', POI_VERSION);

class GoogleAnalyticsOption extends _react.Component {
  constructor(...args) {
    var _temp;

    return _temp = super(...args), this.state = {
      checked: config.get('poi.sendAnalytics', true)
    }, this.handleChange = e => {
      config.set('poi.sendAnalytics', !this.state.checked);
      this.setState({ checked: !this.state.checked });
    }, _temp;
  }

  render() {
    return _react2.default.createElement(
      _reactBootstrap.Checkbox,
      {
        checked: this.state.checked,
        onChange: this.handleChange },
      window.i18n.setting.__('Send data to Google Analytics')
    );
  }
}

if (config.get('poi.first', '0.0.0') != POI_VERSION) {
  const isHan = ['zh-CN', 'zh-TW'].includes(window.language);
  const isEn = window.language === 'en-US';
  const isCN = window.language === 'zh-CN';
  const title = 'README';
  const content = _react2.default.createElement(
    'div',
    null,
    _react2.default.createElement(
      'div',
      null,
      _react2.default.createElement(GoogleAnalyticsOption, null)
    ),
    _react2.default.createElement(
      'p',
      null,
      __('Good day and welcome to poi %s! Before your use, here are some information for you', POI_VERSION)
    ),
    _react2.default.createElement(
      'p',
      { style: { color: '#FFCCFF', fontWeight: 'bold', fontSize: 'large' } },
      __('poi will never modify your game data package, but please use trusted executables and plugins!')
    ),
    _react2.default.createElement(
      'p',
      null,
      __('poi does not use proxy by default, which you may change in settings panel.')
    ),
    _react2.default.createElement(
      'div',
      null,
      _react2.default.createElement(
        'ul',
        null,
        isCN ? _react2.default.createElement(
          'li',
          null,
          __('For Shimakaze Go, use HTTP proxy with address 127.0.0.1 and port 8099 (default case).')
        ) : _react2.default.createElement(
          'li',
          null,
          __('For cookie method, check Editing DMM Cookie Region Flag setting.')
        ),
        _react2.default.createElement(
          'li',
          null,
          __('For Shadowsocks and other Socks5 proxies, use Socks5.')
        ),
        _react2.default.createElement(
          'li',
          null,
          __('For VPN, simply leave it unset.')
        )
      )
    ),
    _react2.default.createElement(
      'p',
      null,
      __('If you see error on displaying, manually set content size and it will auto-adjust.')
    ),
    _react2.default.createElement(
      'p',
      null,
      __('If poi is under performance, you may disable some plugins and do a restart.')
    ),
    isEn && _react2.default.createElement(
      'p',
      null,
      'If you prefer Kata to Kanji, you may try translator plugin.'
    ),
    isHan && _react2.default.createElement(
      'p',
      null,
      __('更多帮助参考'),
      ' poi wiki - https://github.com/poooi/poi/wiki\u3002'
    ),
    isHan && _react2.default.createElement(
      'p',
      null,
      __('poi 交流群：'),
      '378320628\u3002'
    ),
    _react2.default.createElement(
      'p',
      null,
      __('Draft an issue, contribute your code, or plugins for poi'),
      ' - GitHub: https://github.com/poooi/poi.'
    )
  );
  const footer = [{
    name: __('I know'),
    func: dontShowAgain,
    style: 'success'
  }];
  const toggle = () => window.toggleModal(title, content, footer);
  // using setTimeout to avoid disturbing the magic being cast in layout.es
  setTimeout(toggle, 5000);
}