function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

/* eslint-disable react/prefer-stateless-function */
import { Icon } from '@whalecloud/fdx';
import React, { Component } from 'react';
import CommonTitleLayout from '../common-title';
import ProductItem from '../common/ProductItem';
import CountDown from '../count-down';
import './index.less';

var FlashSale = /*#__PURE__*/function (_Component) {
  _inherits(FlashSale, _Component);

  var _super = _createSuper(FlashSale);

  function FlashSale() {
    _classCallCheck(this, FlashSale);

    return _super.apply(this, arguments);
  }

  _createClass(FlashSale, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          loading = _this$props.loading,
          prefixCls = _this$props.prefixCls,
          data = _this$props.data,
          _onItemClick = _this$props.onItemClick,
          _onEndClick = _this$props.onEndClick,
          rightTxt = _this$props.rightTxt,
          title = _this$props.title,
          itemStyle = _this$props.itemStyle,
          endTime = _this$props.endTime,
          nowTime = _this$props.nowTime;
      return /*#__PURE__*/React.createElement(React.Fragment, null, data && data.length > 0 && /*#__PURE__*/React.createElement("div", {
        className: "".concat(prefixCls)
      }, /*#__PURE__*/React.createElement(CommonTitleLayout, {
        renderMidCustomView: function renderMidCustomView() {
          return /*#__PURE__*/React.createElement(CountDown, {
            hourStyle: {
              marginLeft: 14
            },
            endTime: endTime,
            nowTime: nowTime
          });
        },
        title: title,
        isShowRightIcon: true,
        rightTxt: rightTxt,
        onEndClick: function onEndClick() {
          // window.location.href = "/spike"
          _onEndClick && _onEndClick();
        }
      }), /*#__PURE__*/React.createElement("div", {
        className: "".concat(prefixCls, "-list"),
        style: itemStyle
      }, data.map(function (item) {
        return /*#__PURE__*/React.createElement(ProductItem, {
          hidePromotions: true,
          hideProName: true,
          hideRate: true,
          data: item,
          key: item.id,
          onItemClick: function onItemClick() {
            return _onItemClick && _onItemClick(item);
          },
          style: {
            display: 'inline-block',
            width: '160px',
            flex: 'none',
            background: '#fff',
            marginRight: '12px'
          }
        });
      }), loading && /*#__PURE__*/React.createElement("div", {
        className: "loading-wrap"
      }, /*#__PURE__*/React.createElement(Icon, {
        type: "loading",
        style: {
          fontSize: 32,
          color: '#abacb2',
          cursor: 'pointer'
        }
      })))));
    }
  }]);

  return FlashSale;
}(Component);

_defineProperty(FlashSale, "defaultProps", {
  prefixCls: 'new-cylon-flash-sale',
  data: [{
    img: 'https://s3.ax1x.com/2020/12/21/rwtM24.png',
    title: 'Meet hotel',
    des: 'Product Name more and more more Product Name more and more more ',
    id: 1,
    price: 199.09,
    salePercent: 0,
    discountPercent: '75'
  }, {
    img: 'https://s3.ax1x.com/2020/12/21/rwtM24.png',
    title: 'Product Name more and more more Product Name more and more more',
    des: 'Product Name more and more more Product Name more and more more ',
    id: 2,
    price: 199.09,
    salePercent: 40
  }, {
    img: 'https://s3.ax1x.com/2020/12/21/rwtM24.png',
    title: 'Eat the week',
    des: 'Product Name more and more more Product Name more and more more ',
    id: 3,
    price: 199.09,
    salePercent: 20
  }, {
    img: 'https://s3.ax1x.com/2020/12/21/rwtM24.png',
    title: 'Eat the week',
    des: 'Product Name more and more more Product Name more and more more ',
    id: 3,
    price: 199.09,
    salePercent: 20
  }],
  rightTxt: 'See All',
  title: 'Flash Sale'
});

export { FlashSale as default };