function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

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); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

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

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

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 } }); 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 _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; }

import React, { Component, PureComponent } from 'react';
import moment from 'moment';

var PerHalfDayHeaderNav =
/*#__PURE__*/
function (_ref) {
  _inherits(PerHalfDayHeaderNav, _ref);

  function PerHalfDayHeaderNav() {
    var _getPrototypeOf2;

    var _this;

    _classCallCheck(this, PerHalfDayHeaderNav);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(PerHalfDayHeaderNav)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _defineProperty(_assertThisInitialized(_this), "state", {
      unitWidth: window.innerWidth * 1 / 4,
      headerContent: []
    });

    _defineProperty(_assertThisInitialized(_this), "getHtml", function () {
      var windowWidth = window.innerWidth;
      var windowHeight = window.innerHeight;
      var _this$state = _this.state,
          headerContent = _this$state.headerContent,
          unitWitdh = _this$state.unitWitdh,
          ruleDate = _this$state.ruleDate;
      var _window$$$RESOURCECON = window.$$RESOURCECONTEXT,
          autoAssign = _window$$$RESOURCECON.autoAssign,
          rentalType = _window$$$RESOURCECON.rentalType;
      var Months = ['', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'];
      var html;

      if (String(rentalType) === '0') {
        html = React.createElement("div", {
          className: "weekDate1"
        }, React.createElement("div", {
          id: "select-date",
          className: "left"
        }, React.createElement("div", {
          onClick: function onClick() {
            _this.props.setParentState({
              calendarShow: true
            });
          },
          className: "select-date",
          style: {
            height: '0.8rem',
            lineHeight: '0.8rem',
            width: "".concat(windowWidth / 4, "px")
          }
        }, String(autoAssign) === '1' ? moment(ruleDate).format('MM月DD日') : '选择日期')), React.createElement("div", {
          className: "main",
          id: "scroller-week-date"
        }, React.createElement("div", {
          className: "slide"
        }, React.createElement("div", {
          id: "pull-right-refresh",
          style: {
            top: "".concat(windowHeight / 2 - 109 * window.devicePixelRatio, "px")
          }
        }, React.createElement("div", {
          id: "pull-right-icon"
        }), String(rentalType) === '0' && String(autoAssign) === '0' && React.createElement("div", {
          id: "pull-right-text"
        })), headerContent.map(function (ele, index) {
          return React.createElement("div", {
            key: String(index),
            className: "column"
          }, React.createElement("div", {
            className: "week-num",
            style: {
              width: "".concat(unitWitdh, "px")
            }
          }, ele.title), React.createElement("div", {
            className: "week-month",
            style: {
              width: "".concat(unitWitdh, "px")
            }
          }, ele.date));
        }), React.createElement("div", {
          id: "pull-left-refresh",
          style: {
            top: "".concat(windowHeight / 2 - 109 * window.devicePixelRatio, "px")
          }
        }, React.createElement("div", {
          id: "pull-left-icon"
        }), String(rentalType) === '0' && String(autoAssign) === '0' && React.createElement("div", {
          id: "pull-left-text"
        })))));
      } else if (String(rentalType) === '1' || String(rentalType) === '3' || String(rentalType) === '5' || String(rentalType) === '2') {
        html = React.createElement("section", {
          className: "weekDate1"
        }, React.createElement("div", {
          id: "select-date",
          className: "left"
        }, React.createElement("div", {
          onClick: function onClick() {
            _this.props.setParentState({
              calendarShow: true
            });
          },
          className: "select-date",
          style: {
            height: '0.8rem',
            lineHeight: '0.8rem',
            width: "".concat(windowWidth / 3, "px")
          }
        }, String(autoAssign) === '1' ? "".concat(Months[Number(moment(ruleDate).format('M'))], "\u6708") : '选择日期')), React.createElement("div", {
          className: "main",
          id: "scroller-week-date"
        }, React.createElement("div", {
          className: "slide"
        }, headerContent.map(function (ele, index) {
          return React.createElement("div", {
            key: String(index),
            className: "column"
          }, React.createElement("div", {
            id: "week-num",
            className: "week-num",
            style: {
              width: unitWitdh
            }
          }, ele.title), React.createElement("div", {
            className: "week-month",
            style: {
              width: unitWitdh
            }
          }, ele.date));
        }))));
      } else if (String(rentalType) === '4') {
        html = React.createElement("section", {
          className: "weekDate1"
        }, React.createElement("div", {
          id: "select-date",
          className: "left"
        }, React.createElement("div", {
          onClick: function onClick() {
            _this.props.setParentState({
              calendarShow: true
            });
          },
          className: "select-date",
          style: {
            height: '0.8rem',
            lineHeight: '0.8rem',
            width: "".concat(windowWidth / 3, "px")
          }
        }, "\u9009\u62E9\u65E5\u671F")), React.createElement("div", {
          className: "main",
          id: "scroller-week-date"
        }, React.createElement("div", {
          className: "slide"
        }, headerContent.map(function (ele, index) {
          return React.createElement("div", {
            key: String(index),
            className: "column"
          }, React.createElement("div", {
            className: "week-num",
            id: "week-num",
            style: {
              width: unitWitdh
            }
          }, ele.title), React.createElement("div", {
            className: "week-month",
            style: {
              width: unitWitdh
            }
          }, ele.date));
        }))));
      }

      return html;
    });

    return _this;
  }

  _createClass(PerHalfDayHeaderNav, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      this.initComponent(this.props);
    }
  }, {
    key: "componentWillReceiveProps",
    value: function componentWillReceiveProps(nextProps) {
      this.initComponent(nextProps);
    }
  }, {
    key: "initComponent",
    value: function initComponent(props) {
      var windowWidth = window.innerWidth;
      var _props$headerContent = props.headerContent,
          headerContent = _props$headerContent === void 0 ? [] : _props$headerContent,
          ruleDate = props.ruleDate;
      var _window$$$RESOURCECON2 = window.$$RESOURCECONTEXT,
          autoAssign = _window$$$RESOURCECON2.autoAssign,
          rentalType = _window$$$RESOURCECON2.rentalType;
      var unitWitdh = "".concat(windowWidth * 2 / 3, "px");
      var widthValue = {
        0: 2 / 3,
        1: 2 / 3,
        2: 1 / 3
      };

      if (String(rentalType) === '0') {
        widthValue = {
          0: 3 / 4,
          1: 3 / 4,
          2: 3 / 8,
          3: 1 / 4
        };

        if (String(autoAssign) === '1') {
          unitWitdh = widthValue[String(headerContent.length)] ? "".concat(windowWidth * widthValue[String(headerContent.length)]) : windowWidth * 1 / 4;
        } else {
          unitWitdh = windowWidth * 1 / 4;
        }
      } else if (String(autoAssign) === '1') {
        unitWitdh = widthValue[String(headerContent.length)] ? "".concat(windowWidth * widthValue[String(headerContent.length)]) : '2rem';
      }

      this.setState({
        headerContent: headerContent,
        unitWitdh: unitWitdh,
        ruleDate: ruleDate
      });
    }
  }, {
    key: "render",
    value: function render() {
      return React.createElement("header", null, this.getHtml());
    }
  }]);

  return PerHalfDayHeaderNav;
}(PureComponent || Component);

export default PerHalfDayHeaderNav;