'use strict';

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

var _defineProperty2 = require('babel-runtime/helpers/defineProperty');

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _LocaleReceiver = require('antd/es/locale-provider/LocaleReceiver');

var _LocaleReceiver2 = _interopRequireDefault(_LocaleReceiver);

var _default = require('../locale/default');

var _default2 = _interopRequireDefault(_default);

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

var Video = function (_Component) {
    (0, _inherits3['default'])(Video, _Component);

    function Video() {
        (0, _classCallCheck3['default'])(this, Video);

        var _this = (0, _possibleConstructorReturn3['default'])(this, (Video.__proto__ || Object.getPrototypeOf(Video)).apply(this, arguments));

        _this.creatVideo = function () {
            var _this$props = _this.props,
                playerProps = _this$props.playerProps,
                callBack = _this$props.callBack,
                local = _this$props.local;

            var player = new window.Aliplayer((0, _extends3['default'])((0, _extends3['default'])({}, playerProps), { language: local.name, languageTexts: (0, _defineProperty3['default'])({}, local.name, local.content) }), function () {
                callBack(player);
            });
        };
        return _this;
    }

    (0, _createClass3['default'])(Video, [{
        key: 'componentDidMount',
        value: function componentDidMount() {
            this.creatVideo();
        }
    }, {
        key: 'render',
        value: function render() {
            return _react2['default'].createElement('div', { id: this.props.id });
        }
    }]);
    return Video;
}(_react.Component);

function VideoPlayer(props) {
    var id = props.id,
        playerProps = props.playerProps,
        callBack = props.callBack;

    return _react2['default'].createElement(
        _LocaleReceiver2['default'],
        { componentName: 'VideoPlayer', defaultLocale: _default2['default'].VideoPlayer },
        function (locale) {
            return _react2['default'].createElement(Video, { id: id, playerProps: playerProps, callBack: callBack, local: locale });
        }
    );
}
exports['default'] = VideoPlayer;
module.exports = exports['default'];