"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _extends2=require("babel-runtime/helpers/extends"),_extends3=_interopRequireDefault(_extends2),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_createClass2=require("babel-runtime/helpers/createClass"),_createClass3=_interopRequireDefault(_createClass2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2),_react=require("react"),React=_interopRequireWildcard(_react),_lodash=require("lodash.debounce"),_lodash2=_interopRequireDefault(_lodash);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}if("undefined"!=typeof window){var matchMediaPolyfill=function(e){return{media:e,matches:!1,addListener:function(){},removeListener:function(){}}};window.matchMedia=window.matchMedia||matchMediaPolyfill}var SlickCarousel=require("react-slick").default,Carousel=function(e){function i(e){(0,_classCallCheck3.default)(this,i);var t=(0,_possibleConstructorReturn3.default)(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e));return t.onWindowResized=function(){t.props.autoplay&&t.slick&&t.slick.innerSlider&&t.slick.innerSlider.autoPlay&&t.slick.innerSlider.autoPlay()},t.saveSlick=function(e){t.slick=e},t.onWindowResized=(0,_lodash2.default)(t.onWindowResized,500,{leading:!1}),t}return(0,_inherits3.default)(i,e),(0,_createClass3.default)(i,[{key:"componentDidMount",value:function(){this.props.autoplay&&window.addEventListener("resize",this.onWindowResized),this.innerSlider=this.slick&&this.slick.innerSlider}},{key:"componentWillUnmount",value:function(){this.props.autoplay&&(window.removeEventListener("resize",this.onWindowResized),this.onWindowResized.cancel())}},{key:"next",value:function(){this.slick.slickNext()}},{key:"prev",value:function(){this.slick.slickPrev()}},{key:"goTo",value:function(e){this.slick.slickGoTo(e)}},{key:"render",value:function(){var e=(0,_extends3.default)({},this.props);"fade"===e.effect&&(e.fade=!0);var t=e.prefixCls;return e.vertical&&(t=t+" "+t+"-vertical"),React.createElement("div",{className:t},React.createElement(SlickCarousel,(0,_extends3.default)({ref:this.saveSlick},e)))}}]),i}(React.Component);(exports.default=Carousel).defaultProps={dots:!0,arrows:!1,prefixCls:"dt-carousel",draggable:!1},module.exports=exports.default;