"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

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

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

var _classnames = _interopRequireDefault(require("classnames"));

var _bookDemo = _interopRequireDefault(require("../book-demo"));

var _interface = require("./interface");

var _errorBoundary = _interopRequireDefault(require("../error-boundary"));

var _errorLevel = _interopRequireDefault(require("../../utils/error-level"));

var _helpers = require("../../utils/helpers");

var _platform = require("../../utils/platform");

var _award = _interopRequireDefault(require("./img/award.png"));

require("./index.css");

var _getTenantInfo;

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

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var preCls = 'order-have-award';
var isPerformance = ((_getTenantInfo = (0, _helpers.getTenantInfo)()) === null || _getTenantInfo === void 0 ? void 0 : _getTenantInfo.tenantType) == 2;
var noshowChangeVersion = (0, _platform.isFeishu)(true) && isPerformance;

var OrderAward = function OrderAward() {
  var bookDemoRef = (0, _react.useRef)();

  var getBookDemoVersion = function getBookDemoVersion() {
    var _window$BSGlobal$tena;

    var menuVersion = (_window$BSGlobal$tena = window.BSGlobal.tenantAuthentication) === null || _window$BSGlobal$tena === void 0 ? void 0 : _window$BSGlobal$tena.MenuVersion;

    if (menuVersion === _interface.ETrialVersion.OKR) {
      return _bookDemo["default"].DemoType.TryOKR;
    }

    if (menuVersion === _interface.ETrialVersion.Performance) {
      return _bookDemo["default"].DemoType.TryPerformance;
    }

    return _bookDemo["default"].DemoType.UniversalBookDemo;
  };

  var handlePoint = function handlePoint(e) {
    if (bookDemoRef.current) {
      bookDemoRef.current.show();
    }

    if (window.titaTracker) {
      window.titaTracker('action').record({
        actionName: '申请演示',
        actionGroup: '试用版-申请演示',
        productName: '系统内-申请演示'
      });
    }
  };

  if (noshowChangeVersion) return null;
  return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])('order-have-award'),
    onClick: handlePoint
  }, /*#__PURE__*/_react["default"].createElement("img", {
    className: (0, _classnames["default"])("".concat(preCls, "__img")),
    src: _award["default"],
    alt: "\u9884\u7EA6\u6709\u5956"
  })), /*#__PURE__*/_react["default"].createElement(_errorBoundary["default"], {
    errorLevel: _errorLevel["default"].P0,
    errorTag: "\u7533\u8BF7\u9884\u7EA6\u6F14\u793A\u5F02\u5E38"
  }, /*#__PURE__*/_react["default"].createElement(_bookDemo["default"].BookDemoPC, {
    visible: false,
    ref: bookDemoRef,
    type: getBookDemoVersion()
  })));
};

var _default = OrderAward;
exports["default"] = _default;