"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 _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")),_getPrototypeOf2=_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")),_classnames=_interopRequireDefault(require("classnames")),_withStyles=_interopRequireDefault(require("../../hoc/withStyles")),_Tabs=_interopRequireDefault(require("@material-ui/core/Tabs")),_Tab=_interopRequireDefault(require("@material-ui/core/Tab")),_ErrorBoundary=_interopRequireDefault(require("../../hoc/ErrorBoundary")),_styles=_interopRequireDefault(require("./styles")),TabsNavigation=/*#__PURE__*/function(_React$Component){function TabsNavigation(props){var _this;return(0,_classCallCheck2.default)(this,TabsNavigation),_this=(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(TabsNavigation).call(this,props)),(0,_defineProperty2.default)((0,_assertThisInitialized2.default)((0,_assertThisInitialized2.default)(_this)),"changeActiveIndex",function(index){_this.setState({activeIndex:index}),_this.props.onChange&&_this.props.onChange(index)}),(0,_defineProperty2.default)((0,_assertThisInitialized2.default)((0,_assertThisInitialized2.default)(_this)),"_handleChange",function(event,value){_this.setState({activeIndex:value}),_this.props.onChange&&_this.props.onChange(value)}),_this.state={activeIndex:props.activeIndex},_this}return(0,_inherits2.default)(TabsNavigation,_React$Component),(0,_createClass2.default)(TabsNavigation,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){var props=this.props;props.activeIndex!==prevProps.activeIndex&&this.setState({activeIndex:props.activeIndex})}},{key:"_renderTabs",value:function _renderTabs(){var _this$props=this.props,tabs=_this$props.tabs,classes=_this$props.classes,tabTheme=_this$props.tabTheme;return React.createElement(_Tabs.default,{value:this.state.activeIndex,onChange:this._handleChange,classes:{root:(0,_classnames.default)(classes.tabsWrapper,{secondary:"secondary"===tabTheme,tertiary:"tertiary"===tabTheme}),indicator:(0,_classnames.default)(classes.tabsIndicator,{secondary:"secondary"===tabTheme,tertiary:"tertiary"===tabTheme})}},tabs.map(function(tab,index){return React.createElement(_Tab.default,{classes:{root:(0,_classnames.default)(classes.tabWrapper,{secondary:"secondary"===tabTheme,tertiary:"tertiary"===tabTheme}),textColorInherit:(0,_classnames.default)(classes.textColorInherit,{secondary:"secondary"===tabTheme,tertiary:"tertiary"===tabTheme}),selected:(0,_classnames.default)(classes.selectedTab,{secondary:"secondary"===tabTheme,tertiary:"tertiary"===tabTheme}),label:(0,_classnames.default)(classes.label,{secondary:"secondary"===tabTheme,tertiary:"tertiary"===tabTheme})},"data-test":"tab-".concat(tab.label),label:tab.label,key:index,onClick:tab.onClick})}))}},{key:"render",value:function render(){var classes=this.props.classes;return React.createElement(_ErrorBoundary.default,null,React.createElement("div",{className:classes.component},this._renderTabs()))}}]),TabsNavigation}(React.Component);(0,_defineProperty2.default)(TabsNavigation,"defaultProps",{tabTheme:"secondary",onChange:function onChange(){},tabs:[]});var _default=(0,_withStyles.default)(_styles.default)(TabsNavigation);exports.default=_default;