"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 _titaUi = require("tita-ui");

var _bsGlobal = require("../../utils/bs-global");

var _localStorage = require("../../utils/local-storage");

require("./index.css");

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

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

var preCls = "tt-stop-taking-model";
var storage = new _localStorage.LocalStorage();

function StopTakingModel() {
  var _useState = (0, _react.useState)(function () {
    var _getTenantInfo;

    if (((_getTenantInfo = (0, _bsGlobal.getTenantInfo)()) === null || _getTenantInfo === void 0 ? void 0 : _getTenantInfo.Source) === 964) return false;
    var stopTaking = storage.getItem("stopTaking");

    if (stopTaking !== null && stopTaking !== void 0 && stopTaking.date) {
      var oldDate = new Date(stopTaking === null || stopTaking === void 0 ? void 0 : stopTaking.date).getDate();
      var newDate = new Date().getDate();

      if (newDate > oldDate) {
        return true;
      }

      return false;
    }

    return true;
  }),
      _useState2 = _slicedToArray(_useState, 2),
      visible = _useState2[0],
      setVisible = _useState2[1];

  var handleClose = (0, _react.useCallback)(function () {
    setVisible(false);
    storage.setItem("stopTaking", {
      bol: false,
      date: new Date()
    });
  }, []);
  return /*#__PURE__*/_react["default"].createElement(_titaUi.Modal, {
    visible: visible,
    customContent: true,
    footer: null,
    width: 420
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: preCls
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(preCls, "__background")
  }), /*#__PURE__*/_react["default"].createElement("span", {
    className: "tu-icon-close ".concat(preCls, "__close"),
    onClick: handleClose
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(preCls, "__head")
  }, "\u4EB2\u7231\u7684\u7528\u6237"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(preCls, "__content")
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(preCls, "__content-line1")
  }, "\u60A8\u597D\uFF5E"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(preCls, "__content-line2")
  }, "\u4E3A\u4E86\u7ED9\u60A8\u5E26\u6765\u66F4\u597D\u7684\u5B89\u5168\u4E0E\u7A33\u5B9A\u4F53\u9A8C\uFF0CTita \u5C06\u5728\u5468\u4E94\u665A\u4E0A\u8FDB\u884C\u5347\u7EA7\uFF0C\u9884\u8BA1\u8017\u65F6\u4E00\u5929\uFF0C\u4ECB\u65F6\u5C06\u65E0\u6CD5\u4F7F\u7528 Tita\uFF0C\u8BF7\u60A8\u63D0\u524D\u5B89\u6392\u597D\u5DE5\u4F5C\uFF0C\u611F\u8C22\u60A8\u7684\u652F\u6301\u4E0E\u7406\u89E3\uFF01"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(preCls, "__content-line3")
  }, "\u5347\u7EA7\u65F6\u95F4\uFF1A", /*#__PURE__*/_react["default"].createElement("span", {
    style: {
      color: "#2879ff",
      fontWeight: 500
    }
  }, "1.21 (\u5468\u4E94) 23:00 - 1.22 (\u5468\u516D) 23:59"))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(preCls, "__action"),
    onClick: function onClick() {
      return window.open("https://wiki.tita.com/x/RICeAQ");
    }
  }, "\u4E86\u89E3\u8BE6\u60C5")));
}

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