'use strict';

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _reactDom = require('react-dom');

var _reactDom2 = _interopRequireDefault(_reactDom);

var _reactAddonsPureRenderMixin = require('react-addons-pure-render-mixin');

var _reactAddonsPureRenderMixin2 = _interopRequireDefault(_reactAddonsPureRenderMixin);

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

var _reactNotificationSystem = require('react-notification-system');

var _reactNotificationSystem2 = _interopRequireDefault(_reactNotificationSystem);

var _store = require('./store');

var _store2 = _interopRequireDefault(_store);

var _reducers = require('./reducers');

var _notebook = require('./components/notebook');

var _notebook2 = _interopRequireDefault(_notebook);

var _actions = require('./actions');

var _menu = require('./menu');

var _nativeWindow = require('./native-window');

var _globalEvents = require('./global-events');

var _records = require('./records');

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

const store = (0, _store2.default)({
  app: new _records.AppRecord(),
  metadata: new _records.MetadataRecord(),
  document: new _records.DocumentRecord()
}, _reducers.reducers);

// Register for debugging
window.store = store;

(0, _nativeWindow.initNativeHandlers)(store);
(0, _menu.initMenuHandlers)(store);
(0, _globalEvents.initGlobalHandlers)(store);

class App extends _react2.default.Component {
  constructor(props) {
    super(props);
    this.shouldComponentUpdate = _reactAddonsPureRenderMixin2.default.shouldComponentUpdate.bind(this);
  }
  componentDidMount() {
    store.dispatch((0, _actions.setNotificationSystem)(this.refs.notificationSystem));
  }
  render() {
    // eslint-disable-line class-methods-use-this
    return _react2.default.createElement(
      _reactRedux.Provider,
      { store: store },
      _react2.default.createElement(
        'div',
        null,
        _react2.default.createElement(_notebook2.default, null),
        _react2.default.createElement(_reactNotificationSystem2.default, { ref: 'notificationSystem' }),
        _react2.default.createElement('link', { rel: 'stylesheet', href: '../static/styles/main.css' })
      )
    );
  }
}

_reactDom2.default.render(_react2.default.createElement(App, null), document.querySelector('#app'));