"use strict";

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

var _tslib = require("tslib");

var _react = _interopRequireDefault(require("react"));

var _consoleComponents = require("@alicloud/console-components");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function Page(props) {
  var returnIcon = function returnIcon(type) {
    var icon = undefined;

    switch (type) {
      case 'success':
        icon = /*#__PURE__*/_react["default"].createElement(_consoleComponents.Icon, {
          type: "success",
          style: {
            color: '#1DC11D',
            marginRight: '8px'
          }
        });
        break;

      case 'error':
        icon = /*#__PURE__*/_react["default"].createElement(_consoleComponents.Icon, {
          type: "error",
          style: {
            color: '#FF3333',
            marginRight: '8px'
          }
        });
        break;

      case 'warning':
        icon = /*#__PURE__*/_react["default"].createElement(_consoleComponents.Icon, {
          type: "warning",
          style: {
            color: '#FFA003',
            marginRight: '8px'
          }
        });
        break;

      case 'noPower':
        icon = /*#__PURE__*/_react["default"].createElement("img", {
          src: "https://img.alicdn.com/tfs/TB1mnLer1H2gK0jSZJnXXaT1FXa-72-72.svg"
        });
        break;

      case 'noRule':
        icon = /*#__PURE__*/_react["default"].createElement("img", {
          src: "https://img.alicdn.com/tfs/TB1oxV2sEz1gK0jSZLeXXb9kVXa-72-72.svg"
        });
        break;

      case 'noEquipment':
        icon = /*#__PURE__*/_react["default"].createElement("img", {
          src: "https://img.alicdn.com/tfs/TB1WMpSsEz1gK0jSZLeXXb9kVXa-72-72.svg"
        });
        break;

      case 'noContent':
        icon = /*#__PURE__*/_react["default"].createElement("img", {
          src: "https://img.alicdn.com/tfs/TB1wUubeW61gK0jSZFlXXXDKFXa-72-72.svg"
        });
        break;

      case 'imgFail':
        icon = /*#__PURE__*/_react["default"].createElement("img", {
          src: "https://img.alicdn.com/tfs/TB1U9Ydr.Y1gK0jSZFCXXcwqXXa-72-72.svg"
        });
        break;

      case 'arrears':
        icon = /*#__PURE__*/_react["default"].createElement("img", {
          src: "https://img.alicdn.com/tfs/TB1bTFQspT7gK0jSZFpXXaTkpXa-72-72.svg"
        });
        break;

      case '404':
        icon = /*#__PURE__*/_react["default"].createElement("img", {
          src: "https://img.alicdn.com/tfs/TB16fm.rVY7gK0jSZKzXXaikpXa-72-72.svg"
        });
        break;

      case '500':
        icon = /*#__PURE__*/_react["default"].createElement("img", {
          src: "https://img.alicdn.com/tfs/TB13M2Xr7L0gK0jSZFtXXXQCXXa-72-72.svg"
        });
        break;

      default:
        icon = undefined;
    }

    return icon;
  };

  var returnButtons = function returnButtons(buttons) {
    var bts = buttons.map(function (bt, i) {
      var name = bt.name,
          func = bt.func,
          btProps = (0, _tslib.__rest)(bt, ["name", "func"]);
      return /*#__PURE__*/_react["default"].createElement(_consoleComponents.Button, (0, _tslib.__assign)({
        key: 'ResultPage_' + name + i,
        type: i === 0 ? 'primary' : 'normal',
        onClick: func || bt.onClick
      }, btProps), name);
    });
    return bts;
  };

  var title = props.title,
      _a = props.content,
      content = _a === void 0 ? "" : _a,
      icon = props.icon,
      _b = props.type,
      type = _b === void 0 ? 'success' : _b,
      _c = props.buttons,
      buttons = _c === void 0 ? [] : _c;
  var onlyTitleAndImg = buttons.length === 0 && content === '';
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "lp-result-page"
  }, /*#__PURE__*/_react["default"].createElement("ul", {
    className: "lp-result-page-content",
    style: {
      textAlign: onlyTitleAndImg ? 'center' : 'inherit'
    }
  }, /*#__PURE__*/_react["default"].createElement("li", {
    className: onlyTitleAndImg ? 'icon-area_' : 'icon-area'
  }, icon ? icon : returnIcon(type)), /*#__PURE__*/_react["default"].createElement("li", {
    className: onlyTitleAndImg ? 'show-area_' : 'show-area'
  }, /*#__PURE__*/_react["default"].createElement("h2", null, title), /*#__PURE__*/_react["default"].createElement("p", null, content), buttons && buttons.length > 0 ? /*#__PURE__*/_react["default"].createElement("div", {
    className: "button-area"
  }, returnButtons(buttons)) : null)));
}

function EmptyPage(props) {
  return /*#__PURE__*/_react["default"].createElement(Page, (0, _tslib.__assign)({}, props));
}

Page.empty = EmptyPage;

function ResultPage(props) {
  var firstButtons = props.firstButtons,
      secondButtons = props.secondButtons,
      rest = (0, _tslib.__rest)(props, ["firstButtons", "secondButtons"]);
  var buttons = [];

  if (firstButtons) {
    buttons.push(firstButtons);
  }

  if (secondButtons) {
    buttons.push(secondButtons);
  }

  return /*#__PURE__*/_react["default"].createElement(Page, (0, _tslib.__assign)({}, rest, {
    buttons: buttons
  }));
}

Page.result = ResultPage;
;

function UnususlPage(props) {
  return /*#__PURE__*/_react["default"].createElement(Page, (0, _tslib.__assign)({}, props));
}

Page.unusual = UnususlPage;
var _default = Page;
exports["default"] = _default;