(function (global, factory) {
    if (typeof define === "function" && define.amd) {
        define(['exports', 'react', 'react-redux', 'styled-components', 'react-icons/lib/fa', 'prop-types', '../actions'], factory);
    } else if (typeof exports !== "undefined") {
        factory(exports, require('react'), require('react-redux'), require('styled-components'), require('react-icons/lib/fa'), require('prop-types'), require('../actions'));
    } else {
        var mod = {
            exports: {}
        };
        factory(mod.exports, global.react, global.reactRedux, global.styledComponents, global.fa, global.propTypes, global.actions);
        global.audio_assistant = mod.exports;
    }
})(this, function (exports, _react, _reactRedux, _styledComponents, _fa, _propTypes, _actions) {
    'use strict';

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

    var _react2 = _interopRequireDefault(_react);

    var _styledComponents2 = _interopRequireDefault(_styledComponents);

    var _propTypes2 = _interopRequireDefault(_propTypes);

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

    function _classCallCheck(instance, Constructor) {
        if (!(instance instanceof Constructor)) {
            throw new TypeError("Cannot call a class as a function");
        }
    }

    var _createClass = function () {
        function defineProperties(target, props) {
            for (var i = 0; i < props.length; i++) {
                var descriptor = props[i];
                descriptor.enumerable = descriptor.enumerable || false;
                descriptor.configurable = true;
                if ("value" in descriptor) descriptor.writable = true;
                Object.defineProperty(target, descriptor.key, descriptor);
            }
        }

        return function (Constructor, protoProps, staticProps) {
            if (protoProps) defineProperties(Constructor.prototype, protoProps);
            if (staticProps) defineProperties(Constructor, staticProps);
            return Constructor;
        };
    }();

    function _possibleConstructorReturn(self, call) {
        if (!self) {
            throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
        }

        return call && (typeof call === "object" || typeof call === "function") ? call : self;
    }

    function _inherits(subClass, superClass) {
        if (typeof superClass !== "function" && superClass !== null) {
            throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
        }

        subClass.prototype = Object.create(superClass && superClass.prototype, {
            constructor: {
                value: subClass,
                enumerable: false,
                writable: true,
                configurable: true
            }
        });
        if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
    }

    var _templateObject = _taggedTemplateLiteral(['\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    position: fixed;\n    left: ', ';\n    bottom: ', ';\n    height: ', ';\n    width: ', ';\n    background-color: ', ';\n    border-radius: 50%;\n    box-shadow: 0 0 15px rgba(0,0,0,.3);\n    color: #fff;\n    cursor: pointer;\n    font-size: 50px;\n    transition: all 200ms;\n    &:hover {\n        background-color: #B71C1C;\n    }\n    .icon {\n        display: flex;\n        align-items: center;\n        z-index: 1;\n        animation: ', ';\n        @keyframes Listening-Cloud {\n            0% {\n                transform: scale(1.2);\n            }\n            50% {\n                transform: scale(.8);\n            }\n            100% {\n                transform: scale(1.2);\n            }\n        }\n    }\n    .feedback {\n        display: flex;\n        align-items: center;\n        justify-content: flex-end;\n        position: absolute;\n        left: 0;\n        top: 0;\n        bottom: 0;\n        height: 100%;\n        width: 100px;\n        opacity: 0;\n        padding: 20px;\n        transition: all 200ms;\n        background-color: #D68585;\n        box-shadow: 0 0 15px rgba(0,0,0,.3);\n        color: #fff;\n        border-radius: 50px;\n        font-size: 14px;\n        &.active {\n            opacity: 1;\n            width: 300px;\n        }\n        .simulated-button {\n            position: absolute;\n            left: 0;\n            top: 0;\n            bottom: 0;\n            height: 100px;\n            width: 100px;\n            border-radius: 50%;\n            background-color: #C62828;\n        }\n    }\n'], ['\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    position: fixed;\n    left: ', ';\n    bottom: ', ';\n    height: ', ';\n    width: ', ';\n    background-color: ', ';\n    border-radius: 50%;\n    box-shadow: 0 0 15px rgba(0,0,0,.3);\n    color: #fff;\n    cursor: pointer;\n    font-size: 50px;\n    transition: all 200ms;\n    &:hover {\n        background-color: #B71C1C;\n    }\n    .icon {\n        display: flex;\n        align-items: center;\n        z-index: 1;\n        animation: ', ';\n        @keyframes Listening-Cloud {\n            0% {\n                transform: scale(1.2);\n            }\n            50% {\n                transform: scale(.8);\n            }\n            100% {\n                transform: scale(1.2);\n            }\n        }\n    }\n    .feedback {\n        display: flex;\n        align-items: center;\n        justify-content: flex-end;\n        position: absolute;\n        left: 0;\n        top: 0;\n        bottom: 0;\n        height: 100%;\n        width: 100px;\n        opacity: 0;\n        padding: 20px;\n        transition: all 200ms;\n        background-color: #D68585;\n        box-shadow: 0 0 15px rgba(0,0,0,.3);\n        color: #fff;\n        border-radius: 50px;\n        font-size: 14px;\n        &.active {\n            opacity: 1;\n            width: 300px;\n        }\n        .simulated-button {\n            position: absolute;\n            left: 0;\n            top: 0;\n            bottom: 0;\n            height: 100px;\n            width: 100px;\n            border-radius: 50%;\n            background-color: #C62828;\n        }\n    }\n']);

    function _taggedTemplateLiteral(strings, raw) {
        return Object.freeze(Object.defineProperties(strings, {
            raw: {
                value: Object.freeze(raw)
            }
        }));
    }

    var StyledAudioAssistant = _styledComponents2.default.div(_templateObject, function (_ref) {
        var listening = _ref.listening;
        return listening ? '75px' : '100px';
    }, function (_ref2) {
        var listening = _ref2.listening;
        return listening ? '50px' : '80px';
    }, function (_ref3) {
        var listening = _ref3.listening;
        return listening ? '150px' : '100px';
    }, function (_ref4) {
        var listening = _ref4.listening;
        return listening ? '150px' : '100px';
    }, function (_ref5) {
        var listening = _ref5.listening;
        return listening ? '#B71C1C' : '#C62828';
    }, function (_ref6) {
        var listening = _ref6.listening;
        return listening ? 'Listening-Cloud infinite 2s linear' : '';
    });

    var AudioAssistant = function (_Component) {
        _inherits(AudioAssistant, _Component);

        function AudioAssistant(props) {
            _classCallCheck(this, AudioAssistant);

            var _this = _possibleConstructorReturn(this, (AudioAssistant.__proto__ || Object.getPrototypeOf(AudioAssistant)).call(this, props));

            _this.onListen = _this.onListen.bind(_this);
            return _this;
        }

        _createClass(AudioAssistant, [{
            key: 'componentDidUpdate',
            value: function componentDidUpdate() {
                var _props = this.props,
                    nextTarget = _props.nextTarget,
                    navigate = _props.navigate;

                if (nextTarget) navigate(nextTarget);
            }
        }, {
            key: 'onListen',
            value: function onListen() {
                var listening = this.props.listening;

                if (!listening) this.props.listen();else this.props.stopListening();
            }
        }, {
            key: 'renderIcon',
            value: function renderIcon() {
                var listening = this.props.listening;

                if (listening) return _react2.default.createElement(_fa.FaSoundcloud, { key: 1, className: 'icon-animate' });
                return _react2.default.createElement(_fa.FaMicrophone, { key: 2 });
            }
        }, {
            key: 'renderFeedback',
            value: function renderFeedback() {
                var _props2 = this.props,
                    repeat = _props2.repeat,
                    sayTarget = _props2.sayTarget;

                if (repeat) return 'Sorry, couldn\'t get that';else if (sayTarget) return 'Where do you want to go?';
                return '';
            }
        }, {
            key: 'render',
            value: function render() {
                var _props3 = this.props,
                    listening = _props3.listening,
                    repeat = _props3.repeat,
                    sayTarget = _props3.sayTarget;

                return _react2.default.createElement(
                    StyledAudioAssistant,
                    { onClick: this.onListen, listening: listening },
                    _react2.default.createElement(
                        'div',
                        { className: 'icon' },
                        this.renderIcon()
                    ),
                    _react2.default.createElement(
                        'div',
                        { className: 'feedback' + (repeat || sayTarget ? ' active' : '') },
                        _react2.default.createElement('div', { className: 'simulated-button' }),
                        this.renderFeedback()
                    )
                );
            }
        }]);

        return AudioAssistant;
    }(_react.Component);

    AudioAssistant.propTypes = {
        navigate: _propTypes2.default.func.isRequired
    };


    function mapStateToProps(_ref7) {
        var _ref7$audioAssistant = _ref7.audioAssistant,
            listening = _ref7$audioAssistant.listening,
            currentTarget = _ref7$audioAssistant.currentTarget,
            nextTarget = _ref7$audioAssistant.nextTarget,
            repeat = _ref7$audioAssistant.repeat,
            sayTarget = _ref7$audioAssistant.sayTarget;

        return {
            listening: listening,
            currentTarget: currentTarget,
            nextTarget: nextTarget,
            repeat: repeat,
            sayTarget: sayTarget
        };
    }

    exports.default = (0, _reactRedux.connect)(mapStateToProps, {
        listen: _actions.listen,
        stopListening: _actions.stopListening,
        navigate: _actions.navigate
    })(AudioAssistant);
});