"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 = _interopRequireDefault(require("react"));

var _ramda = require("ramda");

var _propTypes = _interopRequireDefault(require("prop-types"));

var styles = _interopRequireWildcard(require("./styles/styles.js"));

var constants = _interopRequireWildcard(require("./constants/constants.js"));

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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

/* eslint-disable-next-line no-console */
var logWarningOnce = (0, _ramda.once)(console.warn);

function AccessDenied(props) {
  var config = props.config;
  var fid = config.fid;
  var owner_username = fid.split(':')[0];
  return /*#__PURE__*/_react["default"].createElement("div", {
    style: (0, _ramda.mergeRight)(styles.base.html, styles.base.container)
  }, /*#__PURE__*/_react["default"].createElement("div", {
    style: styles.base.h2
  }, "Access Denied"), /*#__PURE__*/_react["default"].createElement("div", {
    style: styles.base.h4
  }, "Uh oh! You don't have access to this Dash app."), /*#__PURE__*/_react["default"].createElement("div", null, "This app is owned by ", owner_username, ". Reach out to", owner_username, " to grant you access to this app and then try refreshing the app."), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement("a", {
    style: styles.base.a,
    onClick: function onClick() {
      try {
        document.cookie = "".concat(constants.OAUTH_COOKIE_NAME, "=; ") + 'expires=Thu, 01 Jan 1970 00:00:01 GMT;';
      } catch (e) {
        logWarningOnce(e);
      }

      window.location.reload(true);
    }
  }, "Log out of session"));
}

AccessDenied.propTypes = {
  config: _propTypes["default"].object
};
var _default = AccessDenied;
exports["default"] = _default;