"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.TopologyDropdownMenu = void 0;

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

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

var _react2 = require("@headlessui/react");

var _outline = require("@heroicons/react/outline");

var _reactRouterDom = require("react-router-dom");

var _bi = require("react-icons/bi");

var _md = require("react-icons/md");

var _jsxRuntime = require("react/jsx-runtime");

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 TopologyDropdownMenu = function TopologyDropdownMenu(_ref) {
  var topology = _ref.topology;
  var location = (0, _reactRouterDom.useLocation)();
  var navigate = (0, _reactRouterDom.useNavigate)();

  var viewLogs = function viewLogs() {
    navigate("/logs?topologyId=".concat(topology.id));
  };

  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react2.Menu, {
    as: "div",
    className: "relative inline-block flex flex-initial",
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Menu.Button, {
      className: "p-0.5 min-w-7 rounded-full text-gray-400 hover:text-gray-500",
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_outline.DotsVerticalIcon, {
        className: "h-6 w-6"
      })
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Transition, {
      as: _react.Fragment,
      enter: "transition ease-out duration-100",
      enterFrom: "transform opacity-0 scale-95",
      enterTo: "transform opacity-100 scale-100",
      leave: "transition ease-in duration-75",
      leaveFrom: "transform opacity-100 scale-100",
      leaveTo: "transform opacity-0 scale-95",
      children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react2.Menu.Items, {
        className: "absolute right-0 top-full font-inter w-56 mt-2 origin-top-right bg-white divide-y divide-gray-100 rounded-md shadow-card  focus:outline-none ",
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Menu.Item, {
          children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
            onClick: viewLogs,
            type: "button",
            className: "flex items-center w-full text-gray-700 hover:bg-gray-200",
            children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_md.MdTableRows, {
              className: "ml-3"
            }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
              className: "py-3 pl-2 pr-3 text-sm block",
              children: "View Logs"
            })]
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Menu.Item, {
          children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactRouterDom.Link, {
            to: "/incidents/create?topology=".concat(topology.id),
            className: "flex items-center w-full text-gray-700 hover:bg-gray-200",
            state: {
              backgroundLocation: location,
              evidenceType: "topology",
              evidence: {
                id: topology.id
              }
            },
            children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_md.MdAlarmAdd, {
              className: "ml-3"
            }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
              className: "py-3 pl-2 pr-3 text-sm block",
              children: "Create Incident"
            })]
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Menu.Item, {
          children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactRouterDom.Link, {
            to: "/topology/".concat(topology.id),
            className: "flex items-center w-full text-gray-700 hover:bg-gray-200",
            children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_bi.BiZoomIn, {
              className: "ml-3"
            }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
              className: "py-3 pl-2 pr-3 text-sm block",
              children: "Zoom In"
            })]
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Menu.Item, {
          children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactRouterDom.Link, {
            to: "/topology/".concat(topology.id),
            className: "flex items-center w-full text-gray-700 hover:bg-gray-200",
            children: [" ", /*#__PURE__*/(0, _jsxRuntime.jsx)(_bi.BiHide, {
              className: "ml-3"
            }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
              className: "py-3 pl-2 pr-3 text-sm block",
              children: "Hide"
            })]
          })
        })]
      })
    })]
  });
};

exports.TopologyDropdownMenu = TopologyDropdownMenu;
TopologyDropdownMenu.propTypes = {
  topology: _propTypes.default.shape({}).isRequired
};