"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Placeholder = Placeholder;
exports.App = App;

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

var _react = require("react");

var _ai = require("react-icons/ai");

var _im = require("react-icons/im");

var _vsc = require("react-icons/vsc");

var _reactQuery = require("react-query");

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

var _auth = require("./api/auth");

var _Layout = require("./components/Layout");

var _Loading = require("./components/Loading");

var _Traces = require("./components/Traces");

var _context = require("./context");

var _pages = require("./pages");

var _dropdownDemo = require("./pages/Examples/dropdown-demo");

var _modalPage = require("./pages/Examples/Modal/modal-page");

var _topologyDropdown = require("./pages/Examples/topology-dropdown");

var _rsDemo = require("./pages/Examples/rs-demo");

var _topologyPage = require("./pages/Examples/Topology/topology-page");

var _TopologySelectorModalPage = require("./pages/Examples/TopologySelectorModalPage/TopologySelectorModalPage");

var _health = require("./pages/health");

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

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 queryClient = new _reactQuery.QueryClient({
  defaultOptions: {
    queries: {
      refetchOnWindowFocus: true,
      refetchOnMount: true,
      refetchOnReconnect: true
    }
  }
});
var navigation = [{
  name: "Topology",
  href: "/",
  icon: _outline.HomeIcon,
  current: false
}, {
  name: "Health",
  href: "/health",
  icon: _ai.AiFillHeart,
  current: false
}, {
  name: "Logs",
  href: "/logs",
  icon: _outline.FolderIcon,
  current: false
}, // { name: "Metrics", href: "/metrics", icon: VscGraph, current: false },
// { name: "Traces", href: "/traces", icon: FaProjectDiagram, current: false },
{
  name: "Config",
  href: "/config",
  icon: _vsc.VscJson,
  current: false
}, // {
//   name: "Timeline",
//   href: "/timeline",
//   icon: MdTimeline,
//   current: false
// },
{
  name: "Incidents",
  href: "/incidents",
  icon: _im.ImLifebuoy
}];

function Placeholder(_ref) {
  var text = _ref.text;
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: "py-4",
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "h-96 border-4 border-dashed border-gray-200 rounded-lg",
      children: text
    })
  });
}

function App() {
  var _useState = (0, _react.useState)(),
      _useState2 = _slicedToArray(_useState, 2),
      user = _useState2[0],
      setUser = _useState2[1];

  (0, _react.useEffect)(function () {
    (0, _auth.getUser)().then(function (u) {
      setUser(u);
    });
  }, []);

  if (user == null) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.Loading, {
      text: "Logging in"
    });
  }

  var sidebar = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Layout.SidebarLayout, {
    navigation: navigation
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactQuery.QueryClientProvider, {
    client: queryClient,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.AuthContext.Provider, {
      value: user,
      children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactRouterDom.Routes, {
        path: "/",
        element: sidebar,
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
          path: "",
          element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Navigate, {
            to: "/topology"
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactRouterDom.Route, {
          path: "incidents",
          element: sidebar,
          children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            path: ":id",
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_pages.IncidentDetailsPage, {})
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            path: "create",
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_pages.IncidentCreatePage, {})
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            index: true,
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_pages.IncidentListPage, {})
          })]
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
          path: "health",
          element: sidebar,
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            index: true,
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_health.HealthPage, {
              url: "/canary/api"
            })
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactRouterDom.Route, {
          path: "topology",
          element: sidebar,
          children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            path: ":id",
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_pages.TopologyPage, {
              url: "/canary/api"
            })
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            index: true,
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_pages.TopologyPage, {
              url: "/canary/api"
            })
          })]
        }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactRouterDom.Route, {
          path: "examples",
          element: sidebar,
          children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            path: "rs",
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_rsDemo.RsDemoPage, {})
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            path: "dropdown",
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_dropdownDemo.DropdownDemoPage, {})
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            path: "topology",
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_topologyPage.TopologyPage, {
              url: "/canary/api"
            })
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            path: "topology-selector",
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TopologySelectorModalPage.TopologySelectorModalPage, {
              url: "/canary/api"
            })
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            path: "modal",
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_modalPage.ModalPage, {})
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            path: "topology-dropdown",
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_topologyDropdown.TypologyDropdownDemo, {})
          })]
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
          path: "logs",
          element: sidebar,
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            index: true,
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_pages.LogsPage, {})
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactRouterDom.Route, {
          path: "config",
          element: sidebar,
          children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            index: true,
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_pages.ConfigListPage, {})
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            path: ":id",
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_pages.ConfigDetailsPage, {})
          })]
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
          path: "timeline",
          element: sidebar,
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            index: true,
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_pages.TimelinePage, {})
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
          path: "metrics",
          element: sidebar,
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            index: true,
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(Placeholder, {
              text: "metrics"
            })
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
          path: "layout",
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            index: true,
            element: sidebar
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
          path: "traces",
          element: sidebar,
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
            index: true,
            element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Traces.TraceView, {})
          })
        })]
      })
    })
  });
}