text: import _defineProperty from 'babel-runtime/helpers/defineProperty';
  import classnames from 'classnames';
  import { setTransform, isTransformSupported } from './utils';
  import React from 'react';
  
  export default {
    getDefaultProps: function getDefaultProps() {
      return {
        scrollAnimated: true,
        onPrevClick: function onPrevClick() {},
        onNextClick: function onNextClick() {}
      };
    },
    getInitialState: function getInitialState() {
      this.offset = 0;
      return {
        next: false,
        prev: false
      };
    },
    componentDidMount: function componentDidMount() {
      this.componentDidUpdate();
    },
    componentDidUpdate: function componentDidUpdate(prevProps) {
      var props = this.props;
      if (prevProps && prevProps.tabBarPosition !== props.tabBarPosition) {
        this.setOffset(0);
        return;
      }
      var nextPrev = this.setNextPrev();
      // wait next, prev show hide
      /* eslint react/no-did-update-set-state:0 */
      if (this.isNextPrevShown(this.state) !== this.isNextPrevShown(nextPrev)) {
        this.setState({}, this.scrollToActiveTab);
      } else {
        // can not use props.activeKey
        if (!prevProps || props.activeKey !== prevProps.activeKey) {
          this.scrollToActiveTab();
        }
      }
    },
    setNextPrev: function setNextPrev() {
      var navNode = this.refs.nav;
      var navNodeWH = this.getOffsetWH(navNode);
      var navWrapNode = this.refs.navWrap;
      var navWrapNodeWH = this.getOffsetWH(navWrapNode);
      var offset = this.offset;
  
      var minOffset = navWrapNodeWH - navNodeWH;
      var _state = this.state,
          next = _state.next,
          prev = _state.prev;
  
      if (minOffset >= 0) {
        next = false;
        this.setOffset(0, false);
        offset = 0;
      } else if (minOffset < offset) {
        next = true;
      } else {
        next = false;
        this.setOffset(minOffset, false);
        offset = minOffset;
      }
  
      if (offset < 0) {
        prev = true;
      } else {
        prev = false;
      }
  
      this.setNext(next);
      this.setPrev(prev);
      return {
        next: next,
        prev: prev
      };
    },
    getOffsetWH: function getOffsetWH(node) {
      var tabBarPosition = this.props.tabBarPosition;
      var prop = 'offsetWidth';
      if (tabBarPosition === 'left' || tabBarPosition === 'right') {
        prop = 'offsetHeight';
      }
      return node[prop];
    },
    getOffsetLT: function getOffsetLT(node) {
      var tabBarPosition = this.props.tabBarPosition;
      var prop = 'left';
      if (tabBarPosition === 'left' || tabBarPosition === 'right') {
        prop = 'top';
      }
      return node.getBoundingClientRect()[prop];
    },
    setOffset: function setOffset(offset) {
      var checkNextPrev = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  
      var target = Math.min(0, offset);
      if (this.offset !== target) {
        this.offset = target;
        var navOffset = {};
        var tabBarPosition = this.props.tabBarPosition;
        var navStyle = this.refs.nav.style;
        var transformSupported = isTransformSupported(navStyle);
        if (tabBarPosition === 'left' || tabBarPosition === 'right') {
          if (transformSupported) {
            navOffset = {
              value: 'translate3d(0,' + target + 'px,0)'
            };
          } else {
            navOffset = {
              name: 'top',
              value: target + 'px'
            };
          }
        } else {
          if (transformSupported) {
            navOffset = {
              value: 'translate3d(' + target + 'px,0,0)'
            };
          } else {
            navOffset = {
              name: 'left',
              value: target + 'px'
            };
          }
        }
        if (transformSupported) {
          setTransform(navStyle, navOffset.value);
        } else {
          navStyle[navOffset.name] = navOffset.value;
        }
        if (checkNextPrev) {
          this.setNextPrev();
        }
      }
    },
    setPrev: function setPrev(v) {
      if (this.state.prev !== v) {
        this.setState({
          prev: v
        });
      }
    },
    setNext: function setNext(v) {
      if (this.state.next !== v) {
        this.setState({
          next: v
        });
      }
    },
    isNextPrevShown: function isNextPrevShown(state) {
      return state.next || state.prev;
    },
    scrollToActiveTab: function scrollToActiveTab() {
      var _refs = this.refs,
          activeTab = _refs.activeTab,
          navWrap = _refs.navWrap;
  
      if (activeTab) {
        var activeTabWH = this.getOffsetWH(activeTab);
        var navWrapNodeWH = this.getOffsetWH(navWrap);
        var offset = this.offset;
  
        var wrapOffset = this.getOffsetLT(navWrap);
        var activeTabOffset = this.getOffsetLT(activeTab);
        if (wrapOffset > activeTabOffset) {
          offset += wrapOffset - activeTabOffset;
          this.setOffset(offset);
        } else if (wrapOffset + navWrapNodeWH < activeTabOffset + activeTabWH) {
          offset -= activeTabOffset + activeTabWH - (wrapOffset + navWrapNodeWH);
          this.setOffset(offset);
        }
      }
    },
    prev: function prev(e) {
      this.props.onPrevClick(e);
      var navWrapNode = this.refs.navWrap;
      var navWrapNodeWH = this.getOffsetWH(navWrapNode);
      var offset = this.offset;
  
      this.setOffset(offset + navWrapNodeWH);
    },
    next: function next(e) {
      this.props.onNextClick(e);
      var navWrapNode = this.refs.navWrap;
      var navWrapNodeWH = this.getOffsetWH(navWrapNode);
      var offset = this.offset;
  
      this.setOffset(offset - navWrapNodeWH);
    },
    getScrollBarNode: function getScrollBarNode(content) {
      var _classnames3, _classnames4;
  
      var _state2 = this.state,
          next = _state2.next,
          prev = _state2.prev;
      var _props = this.props,
          prefixCls = _props.prefixCls,
          scrollAnimated = _props.scrollAnimated;
  
      var nextButton = void 0;
      var prevButton = void 0;
      var showNextPrev = prev || next;
  
      if (showNextPrev) {
        var _classnames, _classnames2;
  
        prevButton = React.createElement(
          'span',
          {
            onClick: prev ? this.prev : null,
            unselectable: 'unselectable',
            className: classnames((_classnames = {}, _defineProperty(_classnames, prefixCls + '-tab-prev', 1), _defineProperty(_classnames, prefixCls + '-tab-btn-disabled', !prev), _classnames))
          },
          React.createElement('span', { className: prefixCls + '-tab-prev-icon' })
        );
  
        nextButton = React.createElement(
          'span',
          {
            onClick: next ? this.next : null,
            unselectable: 'unselectable',
            className: classnames((_classnames2 = {}, _defineProperty(_classnames2, prefixCls + '-tab-next', 1), _defineProperty(_classnames2, prefixCls + '-tab-btn-disabled', !next), _classnames2))
          },
          React.createElement('span', { className: prefixCls + '-tab-next-icon' })
        );
      }
  
      var navClassName = prefixCls + '-nav';
      var navClasses = classnames((_classnames3 = {}, _defineProperty(_classnames3, navClassName, true), _defineProperty(_classnames3, scrollAnimated ? navClassName + '-animated' : navClassName + '-no-animated', true), _classnames3));
  
      return React.createElement(
        'div',
        {
          className: classnames((_classnames4 = {}, _defineProperty(_classnames4, prefixCls + '-nav-container', 1), _defineProperty(_classnames4, prefixCls + '-nav-container-scrolling', showNextPrev), _classnames4)),
          key: 'container',
          ref: 'container'
        },
        prevButton,
        nextButton,
        React.createElement(
          'div',
          { className: prefixCls + '-nav-wrap', ref: 'navWrap' },
          React.createElement(
            'div',
            { className: prefixCls + '-nav-scroll' },
            React.createElement(
              'div',
              { className: navClasses, ref: 'nav' },
              content
            )
          )
        )
      );
    }
  };