"use strict";var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_objectSpread2=_interopRequireDefault(require("@babel/runtime/helpers/objectSpread")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")),_getPrototypeOf3=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")),_inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits")),_assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_react=_interopRequireWildcard(require("react")),_ErrorBoundary=_interopRequireDefault(require("../../hoc/ErrorBoundary")),NewsLetterSubScription=/*#__PURE__*/function(_Component){function NewsLetterSubScription(){var _getPrototypeOf2,_this;(0,_classCallCheck2.default)(this,NewsLetterSubScription);for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];return _this=(0,_possibleConstructorReturn2.default)(this,(_getPrototypeOf2=(0,_getPrototypeOf3.default)(NewsLetterSubScription)).call.apply(_getPrototypeOf2,[this].concat(args))),(0,_defineProperty2.default)((0,_assertThisInitialized2.default)((0,_assertThisInitialized2.default)(_this)),"state",{isSignUp:!1,isSusScribed:!1,emailAddress:"",msg:"You have been added to our mailing list"}),(0,_defineProperty2.default)((0,_assertThisInitialized2.default)((0,_assertThisInitialized2.default)(_this)),"subScribe",/*#__PURE__*/(0,_asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(){var emailAddress,regex,variables;return _regenerator.default.wrap(function(_context){for(;;)switch(_context.prev=_context.next){case 0:emailAddress=_this.state.emailAddress,regex=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,regex.test(emailAddress)&&(variables={emailAddress:emailAddress},mixpanel&&mixpanel.track("Subscribe",(0,_objectSpread2.default)({},variables)));case 3:case"end":return _context.stop();}},_callee,this)}))),(0,_defineProperty2.default)((0,_assertThisInitialized2.default)((0,_assertThisInitialized2.default)(_this)),"onChangeEmail",function(event){_this.setState({emailAddress:event.target.value})}),_this}return(0,_inherits2.default)(NewsLetterSubScription,_Component),(0,_createClass2.default)(NewsLetterSubScription,[{key:"render",value:function render(){var _this2=this,_this$state=this.state,isSignUp=_this$state.isSignUp,isSusScribed=_this$state.isSusScribed,msg=_this$state.msg;return _react.default.createElement(_ErrorBoundary.default,null,_react.default.createElement("section",{className:"signup_bg"},_react.default.createElement("div",{className:"container"},_react.default.createElement("div",{className:"signup clearfix"},_react.default.createElement("div",{className:"heading"},_react.default.createElement("h3",null,"STAY CONNECTED")),_react.default.createElement("div",{className:"left_signup clearfix"},_react.default.createElement("div",{className:"left_thumnail"},_react.default.createElement("img",{src:require("../../assets/images/mail-icon@3x.png")})),isSignUp?_react.default.createElement("div",{className:"desc"},!isSusScribed&&_react.default.createElement("input",{type:"text",onChange:this.onChangeEmail,className:"form-control newslettersubscripe",placeholder:"Email ...."}),isSusScribed&&_react.default.createElement("p",null,msg)):_react.default.createElement("div",{className:"desc"},_react.default.createElement("p",null,"Sign up to the Kudoo newsletter and stay up to date with the latest news and product releases."))),_react.default.createElement("div",{className:"right_signup"},isSignUp?!isSusScribed&&_react.default.createElement("a",{className:"btn signup_btn",onClick:this.subScribe},"Send"):_react.default.createElement("a",{className:"btn signup_btn",onClick:function onClick(){return _this2.setState({isSignUp:!0})}},"Sign me up"))))))}}]),NewsLetterSubScription}(_react.Component),_default=NewsLetterSubScription;exports.default=_default;