import { E as compilerRuntimeExports, j as jsxRuntimeExports, r as reactExports, V as Outlet } from "./vendor-react-DYNCg6N5.js";
import { R as ROUTES, i as isSaaS, cJ as isFeature, cK as SettingsIcon, a3 as FileIcon, cL as NotificationNavIcon, cM as RocketIcon, c as useAppSelector, bh as isSuperAdmin, cN as useCommonSettingsQuery, b as useActions, E as ErrorBoundary, aR as NotFound, L as Layout } from "./index-DfebxkL9.js";
import { S as SidebarMenu, a as SimpleNavbar } from "./index-B7nmdYVM.js";
import { u as useStyles } from "./styles-CGXtrnyw.js";
import { af as Loe, D as DR } from "./vendor-icons-xWhXK_Ui.js";
import { u as useTranslation } from "./vendor-i18n-wisIXUFi.js";
import { b as Box, o as Burger, V as LoadingOverlay } from "./vendor-mantine-h0WlM2Mj.js";
const getCommonSettingsRoutes = () => {
  const {
    fullPath,
    pages
  } = ROUTES.commonSettings;
  return Object.values(pages).map((value) => {
    const path = `${fullPath}/${value ? `${value}` : ""}`;
    return {
      path,
      chunk: value
    };
  });
};
const useGetNavMenuItems = (t0) => {
  const $ = compilerRuntimeExports.c(31);
  const {
    Settings
  } = t0;
  const {
    t
  } = useTranslation();
  let t1;
  if ($[0] !== t) {
    t1 = t("filials.integrations");
    $[0] = t;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  let t2;
  if ($[2] !== t1) {
    t2 = {
      label: t1,
      icon: SettingsIcon,
      value: ROUTES.commonSettings.pages.integrations
    };
    $[2] = t1;
    $[3] = t2;
  } else {
    t2 = $[3];
  }
  let t3;
  if ($[4] !== t) {
    t3 = t("sso.authMethod");
    $[4] = t;
    $[5] = t3;
  } else {
    t3 = $[5];
  }
  let t4;
  if ($[6] !== t3) {
    t4 = {
      label: t3,
      icon: Loe,
      value: ROUTES.commonSettings.pages.sso
    };
    $[6] = t3;
    $[7] = t4;
  } else {
    t4 = $[7];
  }
  let t5;
  if ($[8] !== t) {
    t5 = t("filials.auditTrail");
    $[8] = t;
    $[9] = t5;
  } else {
    t5 = $[9];
  }
  let t6;
  if ($[10] !== t5) {
    t6 = {
      label: t5,
      icon: FileIcon,
      value: ROUTES.commonSettings.pages.auditTrail
    };
    $[10] = t5;
    $[11] = t6;
  } else {
    t6 = $[11];
  }
  let t7;
  if ($[12] !== t) {
    t7 = t("filials.storages");
    $[12] = t;
    $[13] = t7;
  } else {
    t7 = $[13];
  }
  let t8;
  if ($[14] !== t7) {
    t8 = {
      label: t7,
      icon: DR,
      value: ROUTES.commonSettings.pages.storage
    };
    $[14] = t7;
    $[15] = t8;
  } else {
    t8 = $[15];
  }
  let commonSettingsMenuItems;
  if ($[16] !== Settings || $[17] !== t || $[18] !== t2 || $[19] !== t4 || $[20] !== t6 || $[21] !== t8) {
    commonSettingsMenuItems = [t2, t4, t6, t8];
    if (isSaaS(Settings)) {
      let t9;
      if ($[23] !== t) {
        t9 = t("commonSettings.notifications");
        $[23] = t;
        $[24] = t9;
      } else {
        t9 = $[24];
      }
      let t10;
      if ($[25] !== t9) {
        t10 = {
          label: t9,
          icon: NotificationNavIcon,
          value: ROUTES.commonSettings.pages.notifications
        };
        $[25] = t9;
        $[26] = t10;
      } else {
        t10 = $[26];
      }
      commonSettingsMenuItems.push(t10);
    }
    if (isFeature()) {
      let t9;
      if ($[27] !== t) {
        t9 = t("filials.branding");
        $[27] = t;
        $[28] = t9;
      } else {
        t9 = $[28];
      }
      let t10;
      if ($[29] !== t9) {
        t10 = {
          label: t9,
          icon: RocketIcon,
          value: ROUTES.commonSettings.pages.branding
        };
        $[29] = t9;
        $[30] = t10;
      } else {
        t10 = $[30];
      }
      commonSettingsMenuItems.push(t10);
    }
    $[16] = Settings;
    $[17] = t;
    $[18] = t2;
    $[19] = t4;
    $[20] = t6;
    $[21] = t8;
    $[22] = commonSettingsMenuItems;
  } else {
    commonSettingsMenuItems = $[22];
  }
  return commonSettingsMenuItems;
};
const NavMenu = (t0) => {
  const $ = compilerRuntimeExports.c(13);
  const {
    setIsOpen,
    Settings
  } = t0;
  const {
    t
  } = useTranslation();
  let t1;
  if ($[0] !== Settings) {
    t1 = {
      Settings
    };
    $[0] = Settings;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  const commonSettingsMenuItems = useGetNavMenuItems(t1);
  let t2;
  if ($[2] !== t) {
    t2 = t("common");
    $[2] = t;
    $[3] = t2;
  } else {
    t2 = $[3];
  }
  let t3;
  if ($[4] !== commonSettingsMenuItems) {
    t3 = commonSettingsMenuItems || [];
    $[4] = commonSettingsMenuItems;
    $[5] = t3;
  } else {
    t3 = $[5];
  }
  let t4;
  if ($[6] !== t2 || $[7] !== t3) {
    t4 = [{
      label: t2,
      pages: t3
    }];
    $[6] = t2;
    $[7] = t3;
    $[8] = t4;
  } else {
    t4 = $[8];
  }
  const linksBlocks = t4;
  let t5;
  if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
    t5 = getCommonSettingsRoutes();
    $[9] = t5;
  } else {
    t5 = $[9];
  }
  let t6;
  if ($[10] !== linksBlocks || $[11] !== setIsOpen) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenu, { routes: t5, setIsOpen, linksBlocks });
    $[10] = linksBlocks;
    $[11] = setIsOpen;
    $[12] = t6;
  } else {
    t6 = $[12];
  }
  return t6;
};
const CommonSettingsPage = (t0) => {
  const $ = compilerRuntimeExports.c(14);
  const {
    children
  } = t0;
  const {
    classes
  } = useStyles();
  const containerRef = reactExports.useRef(null);
  const [isOpen, setIsOpen] = reactExports.useState(false);
  const {
    Settings,
    User
  } = useAppSelector(_temp);
  let t1;
  if ($[0] !== User) {
    t1 = isSuperAdmin(User);
    $[0] = User;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  const isLimitedAccess = !t1;
  const {
    data,
    isLoading
  } = useCommonSettingsQuery();
  const {
    setCommonSettings
  } = useActions();
  let t2;
  if ($[2] !== data || $[3] !== setCommonSettings) {
    t2 = () => {
      if (data) {
        setCommonSettings(data);
      }
    };
    $[2] = data;
    $[3] = setCommonSettings;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  let t3;
  if ($[5] !== data) {
    t3 = [data];
    $[5] = data;
    $[6] = t3;
  } else {
    t3 = $[6];
  }
  reactExports.useEffect(t2, t3);
  let t4;
  if ($[7] !== Settings || $[8] !== children || $[9] !== classes || $[10] !== isLimitedAccess || $[11] !== isLoading || $[12] !== isOpen) {
    t4 = /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { componentTitle: "Settings page", children: isLimitedAccess ? /* @__PURE__ */ jsxRuntimeExports.jsx(NotFound, {}) : /* @__PURE__ */ jsxRuntimeExports.jsxs(Layout, { leftNavbarContent: /* @__PURE__ */ jsxRuntimeExports.jsx(SimpleNavbar, { widthNav: 290, style: {
      flexShrink: 0,
      borderRight: "none"
    }, className: classes.simpleNavbar, isOpen, setIsOpen, children: /* @__PURE__ */ jsxRuntimeExports.jsx(NavMenu, { Settings, setIsOpen }) }), children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.container, ref: containerRef, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.headerMenu, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Burger, { opened: isOpen, onClick: () => setIsOpen(true), className: classes.headerMenuBurger, size: "sm" }) }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Outlet, {})
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.section, children }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingOverlay, { visible: isLoading, overlayProps: {
        blur: 4
      } })
    ] }) });
    $[7] = Settings;
    $[8] = children;
    $[9] = classes;
    $[10] = isLimitedAccess;
    $[11] = isLoading;
    $[12] = isOpen;
    $[13] = t4;
  } else {
    t4 = $[13];
  }
  return t4;
};
function _temp(state) {
  return state.userInfo;
}
export {
  CommonSettingsPage as default
};
//# sourceMappingURL=index-C17ZigX9.js.map
