"use strict";
const pathname_rental = require("./pathname.rental-C9fm1WTq.js");
const images = require("./images-CY-_BlWh.js");
const pathname_hrms = require("./pathname.hrms-2_BEXO_r.js");
const apiConfig = require("./api-config-DXwDMFn-.js");
const moduleRoutesConfig = require("./module-routes-config-B8IucBuj.js");
let PathnameDocument = {
  LANDING_PAGE: "/",
  PRIVATE: "/private",
  SHARED: "/shared",
  PUBLIC: "/public",
  SETTING: "/setting",
  FORMS: "/setting/forms",
  ADD_CUSTOM_FIELDS: "/setting/forms/add-custom-fields"
};
const PathnameOnBoarding = {
  LANDING_PAGE: "/",
  LIST: "/list",
  FORMS: "/settings/forms"
};
const getOnboardingMenuItem = (t, env) => {
  if (!["ksa"].includes(env)) {
    return [];
  }
  return [
    {
      label: t("onboarding.name"),
      link: pathname_rental.Pathname.DASHBOARD_ONBOARDING,
      sidebar: images.images.sidebar.user,
      bacModuleName: "user",
      icon: images.images.user,
      permission: "",
      beModuleName: "rbac",
      bg: "#F3E8FF",
      connectedRoutes: Object.values(PathnameOnBoarding).map(
        (path) => pathname_rental.Pathname.DASHBOARD_ONBOARDING + path
      ),
      translationModule: ["onboarding"]
    }
  ];
};
const modules = (t) => {
  const u_data = localStorage.getItem("_u_data") || void 0;
  const userData = u_data ? JSON.parse(u_data) : "";
  const config = apiConfig.getApiConfig();
  const access_modules = (userData == null ? void 0 : userData.module_access) || [];
  const VITE_APP_ENV = (config == null ? void 0 : config.zatcaEnvironment) || "simulation";
  const accessibleModules = access_modules.map((module2) => module2.module_name);
  const accessibleModulesSet = new Set(accessibleModules);
  const MenuBar = [
    {
      label: t("user.name"),
      link: pathname_rental.Pathname.DASHBOARD_USER,
      sidebar: images.images.sidebar.user,
      bacModuleName: "user",
      icon: images.images.user,
      permission: "",
      beModuleName: "rbac",
      bg: "#F3E8FF",
      connectedRoutes: Object.values(pathname_hrms.PathnameUsers).map(
        (path) => pathname_rental.Pathname.DASHBOARD_USER + path
      ),
      translationModule: ["user"]
    },
    {
      label: t("document.name"),
      link: pathname_rental.Pathname.DASHBOARD_DOCUMENT,
      sidebar: images.images.sidebar.document,
      bacModuleName: "document",
      icon: images.images.document,
      permission: "",
      beModuleName: "document",
      bg: "#E0F2FE",
      connectedRoutes: Object.values(PathnameDocument).map(
        (path) => pathname_rental.Pathname.DASHBOARD_DOCUMENT + path
      ),
      translationModule: ["document"]
    },
    {
      label: t("accounting.name"),
      link: pathname_rental.Pathname.DASHBOARD_ACCOUNTING,
      sidebar: images.images.sidebar.accountingIcon,
      bacModuleName: "accounts-and-finance",
      icon: images.images.accounting,
      permission: "",
      beModuleName: "accounts-and-finance",
      bg: "#E8EAF6",
      connectedRoutes: Object.values(pathname_rental.PathnameAccounting).map(
        (path) => pathname_rental.Pathname.DASHBOARD_ACCOUNTING + path
      ),
      translationModule: ["accounting"]
    },
    {
      label: t("inventory.name"),
      link: pathname_rental.Pathname.DASHBOARD_INVENTORY,
      sidebar: images.images.sidebar.inventoryIcon,
      bacModuleName: "inventory",
      icon: images.images.inventory,
      permission: "",
      beModuleName: "inventory",
      bg: "#FFF3E6",
      connectedRoutes: Object.values(pathname_rental.PathnameInventory).map(
        (path) => pathname_rental.Pathname.DASHBOARD_INVENTORY + path
      ),
      translationModule: ["inventory"]
    },
    {
      label: t("project.name"),
      link: pathname_rental.Pathname.DASHBOARD_PROJECT,
      sidebar: images.images.sidebar.projectIcon,
      bacModuleName: "project",
      icon: images.images.project,
      permission: "",
      beModuleName: "project",
      bg: "#DCFCE7",
      connectedRoutes: [],
      translationModule: ["project"]
    },
    {
      label: t("procurement.name"),
      link: pathname_rental.Pathname.DASHBOARD_PROCUREMENT,
      sidebar: images.images.sidebar.procurementIcon,
      bacModuleName: "purchase",
      icon: images.images.procurement,
      permission: "",
      beModuleName: "purchase",
      bg: "#FFEBE6",
      connectedRoutes: Object.values(pathname_rental.PathnamePurchase).map(
        (path) => pathname_rental.Pathname.DASHBOARD_PROCUREMENT + path
      ),
      // connectedRoutes: [],
      translationModule: ["procurement"]
    },
    {
      label: t("manufacturing.name"),
      link: pathname_rental.Pathname.DASHBOARD_MANUFACTURING,
      sidebar: images.images.sidebar.manufacturingIcon,
      bacModuleName: "manufacturing",
      icon: images.images.manufacturing,
      permission: "",
      beModuleName: "manufacturing",
      bg: "#F0FDF4",
      connectedRoutes: Object.values(pathname_rental.PathnameManufacturing).map(
        (path) => pathname_rental.Pathname.DASHBOARD_MANUFACTURING + path
      ),
      translationModule: ["manufacturing"]
    },
    {
      label: t("crm.name"),
      link: pathname_rental.Pathname.DASHBOARD_CRM,
      sidebar: images.images.sidebar.crmIcon,
      bacModuleName: "sales",
      icon: images.images.crm,
      permission: "",
      beModuleName: "sales",
      bg: "#FCEBEC",
      connectedRoutes: Object.values(pathname_rental.PathnameCrm).map(
        (path) => pathname_rental.Pathname.DASHBOARD_CRM + path
      ),
      translationModule: ["crm"]
    },
    // {
    //   label: t("purchase.name"),
    //   link: Pathname.DASHBOARD_PURCHASE,
    //   sidebar: image.sidebar.purchaseIcon,
    //   icon: image.sidebar.purchaseIcon,
    //   permission: "",
    //   bg: "rgba(111, 102, 215, 0.10)",
    //   connectedRoutes: [],
    // },
    {
      label: t("hrms.name"),
      link: pathname_rental.Pathname.DASHBOARD_HRMS,
      sidebar: images.images.sidebar.hrmsIcon,
      bacModuleName: "hrms",
      icon: images.images.hrms,
      permission: "",
      beModuleName: "hrms",
      bg: "#EBF9F2",
      connectedRoutes: (() => {
        const mfeRoutes = moduleRoutesConfig.getModuleRoutes("hrms");
        if (mfeRoutes.length > 0) return mfeRoutes;
        return Object.values(pathname_hrms.PathnameHrms).map(
          (path) => pathname_rental.Pathname.DASHBOARD_HRMS + path
        );
      })(),
      translationModule: ["hrms"]
    },
    {
      label: t("office.name"),
      link: pathname_rental.Pathname.DASHBOARD_OFFICE,
      sidebar: images.images.sidebar.officeIcon,
      bacModuleName: "office",
      icon: images.images.office,
      permission: "",
      beModuleName: "office",
      bg: "#DCFCE7",
      connectedRoutes: [],
      translationModule: ["office"]
    },
    {
      label: t("rental.name"),
      link: pathname_rental.Pathname.DASHBOARD_RENTAL,
      sidebar: images.images.sidebar.rentalIcon,
      bacModuleName: "rental",
      icon: images.images.rental,
      permission: "",
      beModuleName: "rental",
      bg: "#FEF3C7",
      connectedRoutes: Object.values(pathname_rental.PathnameRental).map(
        (path) => pathname_rental.Pathname.DASHBOARD_RENTAL + path
      ),
      translationModule: ["rental", "inventory"]
    },
    {
      label: "Settings",
      link: pathname_rental.Pathname.DASHBOARD_QUOTES,
      sidebar: images.images.sidebar.setting,
      bacModuleName: "setting",
      icon: images.images.settings,
      permission: "",
      beModuleName: "setting",
      bg: "#EEF2FF",
      connectedRoutes: [],
      translationModule: ["settings"]
    },
    ...getOnboardingMenuItem(t, VITE_APP_ENV)
  ];
  function filterMenu(menu) {
    return menu.filter((item) => {
      const isModuleAccessible = accessibleModulesSet.has(item.bacModuleName);
      let hasValidSubmenu = false;
      if (item.submenu && item.submenu.length > 0) {
        item.submenu = filterMenu(item.submenu);
        hasValidSubmenu = item.submenu.length > 0;
      }
      return isModuleAccessible || hasValidSubmenu;
    });
  }
  const filteredMenu = filterMenu(MenuBar);
  return filteredMenu;
};
exports.PathnameDocument = PathnameDocument;
exports.modules = modules;
//# sourceMappingURL=modules-BKRTgB3s.js.map
