import { E as compilerRuntimeExports, j as jsxRuntimeExports, J as useLocation, T as useNavigate, a4 as matchRoutes } from "./vendor-react-DYNCg6N5.js";
import { S as ScrollContainer } from "./index-DfebxkL9.js";
import { c as createStyles, W as useMediaQuery, X as Drawer, G as Group, S as Stack, b as Box, T as Text, aC as NavLink } from "./vendor-mantine-h0WlM2Mj.js";
const useStyles$1 = createStyles((theme, _, utils) => ({
  navbar: {
    backgroundColor: theme.colors.backgroundGray[0],
    borderRight: "none"
  },
  list: {
    gap: 0,
    [utils.largerThan("md")]: {
      padding: `${theme.spacing.md} ${theme.spacing.sm} 0px ${theme.spacing.sm}`
    }
  }
}));
const SimpleNavbar = (t0) => {
  const $ = compilerRuntimeExports.c(15);
  let children;
  let isOpen;
  let props;
  let setIsOpen;
  let widthNav;
  if ($[0] !== t0) {
    ({
      isOpen,
      setIsOpen,
      widthNav,
      children,
      ...props
    } = t0);
    $[0] = t0;
    $[1] = children;
    $[2] = isOpen;
    $[3] = props;
    $[4] = setIsOpen;
    $[5] = widthNav;
  } else {
    children = $[1];
    isOpen = $[2];
    props = $[3];
    setIsOpen = $[4];
    widthNav = $[5];
  }
  const {
    classes
  } = useStyles$1();
  const isMobile = useMediaQuery("(max-width: 992px)");
  let t1;
  if ($[6] !== children || $[7] !== classes.list || $[8] !== classes.navbar || $[9] !== isMobile || $[10] !== isOpen || $[11] !== props || $[12] !== setIsOpen || $[13] !== widthNav) {
    t1 = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isMobile ? /* @__PURE__ */ jsxRuntimeExports.jsx(Drawer, { opened: isOpen, onClose: () => setIsOpen(false), zIndex: 1002, size: 300, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Group, { className: classes.navbar, sx: {
      width: "auto"
    }, ...props, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollContainer, { sx: {
      height: "100%"
    }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Stack, { className: classes.list, styles: {
      root: {
        flexGrow: 1
      }
    }, children }) }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Group, { className: classes.navbar, sx: {
      width: widthNav
    }, ...props, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollContainer, { h: "100%", w: widthNav, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Stack, { className: classes.list, styles: {
      root: {
        flexGrow: 1
      }
    }, children }) }) }) });
    $[6] = children;
    $[7] = classes.list;
    $[8] = classes.navbar;
    $[9] = isMobile;
    $[10] = isOpen;
    $[11] = props;
    $[12] = setIsOpen;
    $[13] = widthNav;
    $[14] = t1;
  } else {
    t1 = $[14];
  }
  return t1;
};
const useStyles = createStyles((theme) => ({
  heading: {
    color: theme.colors.brandGray[0],
    lineHeight: "17.5px",
    paddingBottom: "12px",
    paddingTop: "27px"
  },
  navLinkItem: {
    "&.mantine-NavLink-root": {
      borderRadius: "8px",
      "&[data-active=true]": {
        backgroundColor: theme.colors.brandGray[1],
        fontWeight: "bold",
        color: "#101828"
      },
      "@media (max-width: 992px)": {
        paddingRight: "8px",
        paddingLeft: "8px"
      }
    }
  }
}));
const SidebarMenu = (t0) => {
  var _a;
  const $ = compilerRuntimeExports.c(13);
  const {
    setIsOpen,
    linksBlocks,
    routes
  } = t0;
  const {
    classes
  } = useStyles();
  const location = useLocation();
  const navigate = useNavigate();
  let t1;
  if ($[0] !== location || $[1] !== routes) {
    t1 = matchRoutes(routes, location) || [];
    $[0] = location;
    $[1] = routes;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  const [currentRoute] = t1;
  const currentPage = (_a = currentRoute == null ? void 0 : currentRoute.route) == null ? void 0 : _a.chunk;
  let t2;
  if ($[3] !== navigate || $[4] !== setIsOpen) {
    t2 = (path, e) => {
      if (e.button === 0 && !e.ctrlKey && !e.metaKey) {
        setIsOpen(false);
        navigate(path);
      }
    };
    $[3] = navigate;
    $[4] = setIsOpen;
    $[5] = t2;
  } else {
    t2 = $[5];
  }
  const handleNavigation = t2;
  let t3;
  if ($[6] !== classes || $[7] !== currentPage || $[8] !== handleNavigation || $[9] !== linksBlocks) {
    t3 = linksBlocks == null ? void 0 : linksBlocks.map((block, index) => {
      var _a2;
      return /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { mb: "sm", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.heading, fz: "sm", ml: "sm", children: block.label }),
        (_a2 = block.pages) == null ? void 0 : _a2.map((item, index_0) => {
          const isActive = item.value === currentPage;
          const Icon = item.icon;
          return /* @__PURE__ */ jsxRuntimeExports.jsx(NavLink, { className: classes.navLinkItem, label: item.label, leftSection: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { stroke: isActive ? "#101828" : "#667085" }), onClick: (e_0) => handleNavigation(item.value, e_0), active: isActive, component: "div", style: {
            cursor: "pointer"
          } }, index_0);
        })
      ] }, index);
    });
    $[6] = classes;
    $[7] = currentPage;
    $[8] = handleNavigation;
    $[9] = linksBlocks;
    $[10] = t3;
  } else {
    t3 = $[10];
  }
  let t4;
  if ($[11] !== t3) {
    t4 = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: t3 });
    $[11] = t3;
    $[12] = t4;
  } else {
    t4 = $[12];
  }
  return t4;
};
export {
  SidebarMenu as S,
  SimpleNavbar as a
};
//# sourceMappingURL=index-B7nmdYVM.js.map
