"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _menus = require("./menus");

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

var _default = /*#__PURE__*/function () {
  function _default(history, isManager) {
    _classCallCheck(this, _default);

    this.history = null;
    this.history = history;
    this.isManager = isManager;
  }

  _createClass(_default, [{
    key: "highlight",
    value: function highlight(cb) {
      if (this.isUnAssigned()) cb(_menus.PAGE_UNASSIGNED_DEMOFREE);else if (this.isAssigned()) cb(_menus.PAGE_ASSIGNED_DEMOFREE);else if (this.isReserved()) cb(_menus.PAGE_RESERVED_DEMOFREE);else if (this.isDone()) cb(_menus.PAGE_DONE_DEMOFREE);else if (this.isIgnore()) cb(_menus.PAGE_IGNORED_DEMOFREE);else if (this.isChart()) cb(_menus.PAGE_CHARTS_DEMOFREE);else if (this.isRechargeList()) cb(_menus.PAGE_RECHARGE_LIST);else if (this.isRechargeStatistics()) cb(_menus.PAGE_RECHARGE_STATISTICS);else if (this.isRechargeStatus()) cb(_menus.PAGE_RECHARGE_STATUS);else if (this.isDueDateOrder()) cb(_menus.PAGE_DUEDATE_ORDER);else if (this.isAllCustomer()) cb(_menus.PAGE_ALL_CUSTOMER);else if (this.isPublicCustomer()) cb(_menus.PAGE_PUBLIC_CUSTOMER);else if (this.isMyCustomer()) cb(_menus.PAGE_MY_CUSTOMER);else if (this.isLimitCustomer()) cb(_menus.PAGE_LIMIT_CUSTOMER);
    }
  }, {
    key: "isChart",
    value: function isChart() {
      var pathname = this.history.location.pathname;
      return pathname.match(/demofree\/charts/);
    }
  }, {
    key: "isRechargeStatus",
    value: function isRechargeStatus() {
      var pathname = this.history.location.pathname;
      return pathname.match(/demofree\/recharge\/status/);
    }
  }, {
    key: "isDueDateOrder",
    value: function isDueDateOrder() {
      var pathname = this.history.location.pathname;
      return pathname.match(/demofree\/recharge\/order/);
    }
  }, {
    key: "isRechargeList",
    value: function isRechargeList() {
      var pathname = this.history.location.pathname;
      return pathname.match(/demofree\/recharge\/list/);
    }
  }, {
    key: "isRechargeStatistics",
    value: function isRechargeStatistics() {
      var pathname = this.history.location.pathname;
      return pathname.match(/demofree\/recharge\/statistics/);
    }
  }, {
    key: "isUnAssigned",
    value: function isUnAssigned() {
      var _this$history$locatio = this.history.location,
          pathname = _this$history$locatio.pathname,
          search = _this$history$locatio.search;

      if (this.isManager) {
        return pathname.match(/demofree\/list/) && (!search || search.match(/selected[\s]*?=[\s]*?unassigned/));
      }

      return pathname.match(/demofree/) && search.match(/selected[\s]*?=[\s]*?unassigned/);
    }
  }, {
    key: "isAssigned",
    value: function isAssigned() {
      var _this$history$locatio2 = this.history.location,
          pathname = _this$history$locatio2.pathname,
          search = _this$history$locatio2.search;
      return pathname.match(/demofree\/list/) && (!search || search.match(/selected[\s]*?=[\s]*?assigned/));
    }
  }, {
    key: "isReserved",
    value: function isReserved() {
      var _this$history$locatio3 = this.history.location,
          pathname = _this$history$locatio3.pathname,
          search = _this$history$locatio3.search;
      return pathname.match(/demofree/) && search.match(/selected[\s]*?=[\s]*?reserved/);
    }
  }, {
    key: "isDone",
    value: function isDone() {
      var _this$history$locatio4 = this.history.location,
          pathname = _this$history$locatio4.pathname,
          search = _this$history$locatio4.search;
      return pathname.match(/demofree/) && search.match(/selected[\s]*?=[\s]*?done/);
    }
  }, {
    key: "isIgnore",
    value: function isIgnore() {
      var _this$history$locatio5 = this.history.location,
          pathname = _this$history$locatio5.pathname,
          search = _this$history$locatio5.search;
      return pathname.match(/demofree/) && search.match(/selected[\s]*?=[\s]*?ignore/);
    }
  }, {
    key: "isPublicCustomer",
    value: function isPublicCustomer() {
      var pathname = this.history.location.pathname;
      return pathname.match(/demofree\/customer\/public/);
    }
  }, {
    key: "isMyCustomer",
    value: function isMyCustomer() {
      var pathname = this.history.location.pathname;
      return pathname.match(/demofree\/customer\/my/);
    }
  }, {
    key: "isAllCustomer",
    value: function isAllCustomer() {
      var pathname = this.history.location.pathname;
      return pathname.match(/demofree\/customer\/all/);
    }
  }, {
    key: "isLimitCustomer",
    value: function isLimitCustomer() {
      var pathname = this.history.location.pathname;
      return pathname.match(/demofree\/customer\/limit/);
    }
  }]);

  return _default;
}();

exports["default"] = _default;