import { r as reactExports, j as jsxRuntimeExports, E as compilerRuntimeExports, T as useNavigate } from "./vendor-react-DYNCg6N5.js";
import { a4 as useHomeWidgetSlice, R as ROUTES, c as useAppSelector, i as isSaaS, H as HEADER_HEIGHT, E as ErrorBoundary, L as Layout } from "./index-DfebxkL9.js";
import { C as CardContainer, L as ListItem, P as PaymentSection, U as UsersSection, D as DiskSpaceSection } from "./index-BIbihtfI.js";
import { M as Modal } from "./index-DqcA8P_y.js";
import { R as RolesCreateForm } from "./form-BjvLuBG-.js";
import { u as useTranslation } from "./vendor-i18n-wisIXUFi.js";
import { c as IconUsersGroup, d as gj, P as PN, r as rBe, E as Ece, B as Bje, s as sVe } from "./vendor-icons-xWhXK_Ui.js";
import { S as Stack, F as Flex, g as Loader, c as createStyles, T as Text, a0 as SimpleGrid, b as Box, Y as Skeleton } from "./vendor-mantine-h0WlM2Mj.js";
import { C as CreateFilialForm } from "./createForm-CM9BvDgp.js";
import { M as MailServerForm } from "./serverForm-BbGb2r52.js";
import { T as TEMPLATE_MAIL_SERVER } from "./types-DVpDEwlm.js";
import { m as mailIcon, c as calendarIcon, a as contactsIcon, p as projectsIcon, b as pagesIcon, f as formsIcon } from "./icon-forms-C3RNUl8Z.js";
import { d as drawIcon } from "./icon-draw-BHY0kAVH.js";
import { H as HealthServiceType } from "./index-TL41xEJi.js";
import "./index-C7llsr9G.js";
import "./styles-3NoIlzov.js";
import "./validation-Ds00Zghx.js";
import "./validate-Bw-sUlFj.js";
import "./useGeneratePolicy-B4rO5xUa.js";
import "./passwordUtils-B3CN2t6O.js";
import "./types-espwwxTQ.js";
import "./options-CRIRDAK6.js";
import "./index-C-CFogWu.js";
import "./index-3c9En-DB.js";
import "./index-CfN7Ll0p.js";
import "./errorIcon-PZO0f1IY.js";
import "./index.es-BTZFX8B-.js";
import "./useUpdateUser-innD962A.js";
import "./index-C6QQOvbB.js";
import "./index-CcqTjOWY.js";
import "./useDebounce-DTubzIUC.js";
import "./index-C_Fw_IUU.js";
import "./index-_NgMYV3i.js";
import "./index-CNv4hlnY.js";
import "./utils-D5kCyTRM.js";
import "./types-B9VC9FeZ.js";
import "./index-B9yUPW9X.js";
import "./index-leRPH4yM.js";
import "./index-D4BAIihc.js";
import "./useCopyToClipboard-C-S2RacD.js";
import "./useTerminateSessions-Cb3ukMTY.js";
import "./index-DMTgSMwy.js";
import "./index-DFEP7Sv_.js";
import "./index-woYEqWvh.js";
import "./index-Ds4Bnwmy.js";
import "./date-bOIw2uwV.js";
import "./format-CMT-x-V3.js";
import "./papaparse.min-Ds9XhCoe.js";
import "./ru-Bush41s2.js";
import "./index-CUcivY9l.js";
import "./index-BvQfhnV_.js";
import "./styles-C9HVNQJ0.js";
import "./index-72JBTuLT.js";
import "./index-DnphFLKH.js";
import "./index-CslanKI5.js";
import "./styles-Dnu4P1Zm.js";
import "./index-C2HWmCvh.js";
import "./index-BWhdniX1.js";
import "./index-BoQKW1g7.js";
import "./index-zpOhy7mV.js";
import "./index-CEv9Eejp.js";
import "./validateTextInput-2E2Z5K9Z.js";
import "./index-DFZKJmic.js";
import "./index-DOixMRp5.js";
import "./passwordOptions-b-kjbiiT.js";
import "./validate-CA6bwF22.js";
import "./styles-rKP3r-bS.js";
import "./utiils-DzEu0_6s.js";
import "./index-B7nmdYVM.js";
const RolesSection = () => {
  const {
    t
  } = useTranslation();
  const [isModalOpen, setIsModalOpen] = reactExports.useState(false);
  const [{
    data
  }] = useHomeWidgetSlice().useRoleWidget().useState();
  const {
    LoadRoleSection
  } = useHomeWidgetSlice().actions;
  reactExports.useEffect(() => {
    LoadRoleSection();
  }, []);
  const handleCreateRole = () => {
    setIsModalOpen(true);
  };
  const rolesMenu = {
    withCheck: false,
    items: [{
      name: t("roles.list"),
      link: ROUTES.roles.path,
      badge: data && data.TotalCount
    }, {
      name: t("profile.addRole"),
      openModal: handleCreateRole
    }]
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(CardContainer, { sectionName: t("profile.roles"), Icon: IconUsersGroup, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Stack, { gap: "11px", sx: {
      width: "100%"
    }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ListItem, { items: rolesMenu.items, withCheck: rolesMenu.withCheck }) }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { opened: isModalOpen, onClose: () => setIsModalOpen(false), title: t("roles.create"), zIndex: 1002, children: /* @__PURE__ */ jsxRuntimeExports.jsx(RolesCreateForm, { onSuccess: LoadRoleSection, close: () => setIsModalOpen(false) }) })
  ] });
};
const FilialSection = ({
  filialId
}) => {
  const {
    t
  } = useTranslation();
  const [{
    data: filialsData
  }] = useHomeWidgetSlice().useFilialWidget().useState();
  const {
    LoadFilialSection
  } = useHomeWidgetSlice().actions;
  const {
    Settings
  } = useAppSelector((state) => state.userInfo);
  const [isModalOpen, setIsModalOpen] = reactExports.useState(false);
  reactExports.useEffect(() => {
    LoadFilialSection();
  }, []);
  const handleCreateFilial = () => {
    setIsModalOpen(true);
  };
  const filialMenu = {
    withCheck: false,
    items: [{
      name: t("filials.list"),
      link: ROUTES.filials.path,
      badge: (filialsData == null ? void 0 : filialsData.TotalCount) || 0
    }, ...!isSaaS(Settings) ? [{
      name: t("roles.addFilial"),
      openModal: handleCreateFilial
    }] : [], {
      name: t("filials.configureLdap"),
      link: `${ROUTES.filials.edit.clearPath}/${filialId}/${ROUTES.filials.edit.pages.auth.ldap}`
    }]
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(CardContainer, { sectionName: t("navigation.units"), Icon: gj, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Stack, { gap: "11px", sx: {
      width: "100%"
    }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ListItem, { items: filialMenu.items, withCheck: filialMenu.withCheck }) }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { opened: isModalOpen, onClose: () => setIsModalOpen(false), title: t("filials.create"), zIndex: 1002, children: /* @__PURE__ */ jsxRuntimeExports.jsx(CreateFilialForm, { onSuccess: LoadFilialSection, onClose: () => setIsModalOpen(false) }) })
  ] });
};
const StatisticsSection = () => {
  const $ = compilerRuntimeExports.c(25);
  const {
    t
  } = useTranslation();
  let t0;
  if ($[0] !== t) {
    t0 = t("statistics.activity");
    $[0] = t;
    $[1] = t0;
  } else {
    t0 = $[1];
  }
  let t1;
  if ($[2] !== t0) {
    t1 = {
      name: t0,
      link: ROUTES.statistics.fullPath
    };
    $[2] = t0;
    $[3] = t1;
  } else {
    t1 = $[3];
  }
  let t2;
  if ($[4] !== t) {
    t2 = t("statistics.disk_space");
    $[4] = t;
    $[5] = t2;
  } else {
    t2 = $[5];
  }
  let t3;
  if ($[6] !== t2) {
    t3 = {
      name: t2,
      link: `${ROUTES.statistics.fullPath}/${ROUTES.statistics.links.diskSpace}`
    };
    $[6] = t2;
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  let t4;
  if ($[8] !== t) {
    t4 = t("statistics.audit");
    $[8] = t;
    $[9] = t4;
  } else {
    t4 = $[9];
  }
  let t5;
  if ($[10] !== t4) {
    t5 = {
      name: t4,
      link: `${ROUTES.statistics.fullPath}/${ROUTES.statistics.links.audit}`
    };
    $[10] = t4;
    $[11] = t5;
  } else {
    t5 = $[11];
  }
  let t6;
  if ($[12] !== t1 || $[13] !== t3 || $[14] !== t5) {
    t6 = {
      withCheck: false,
      items: [t1, t3, t5]
    };
    $[12] = t1;
    $[13] = t3;
    $[14] = t5;
    $[15] = t6;
  } else {
    t6 = $[15];
  }
  const statisticsMenu = t6;
  let t7;
  if ($[16] !== t) {
    t7 = t("navigation.statistics");
    $[16] = t;
    $[17] = t7;
  } else {
    t7 = $[17];
  }
  let t8;
  if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
    t8 = {
      width: "100%"
    };
    $[18] = t8;
  } else {
    t8 = $[18];
  }
  let t9;
  if ($[19] !== statisticsMenu.items || $[20] !== statisticsMenu.withCheck) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx(Stack, { gap: "11px", sx: t8, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ListItem, { items: statisticsMenu.items, withCheck: statisticsMenu.withCheck }) });
    $[19] = statisticsMenu.items;
    $[20] = statisticsMenu.withCheck;
    $[21] = t9;
  } else {
    t9 = $[21];
  }
  let t10;
  if ($[22] !== t7 || $[23] !== t9) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsx(CardContainer, { sectionName: t7, Icon: PN, children: t9 });
    $[22] = t7;
    $[23] = t9;
    $[24] = t10;
  } else {
    t10 = $[24];
  }
  return t10;
};
const SafetySection = (t0) => {
  const $ = compilerRuntimeExports.c(22);
  const {
    filialId
  } = t0;
  const {
    t
  } = useTranslation();
  let t1;
  if ($[0] !== t) {
    t1 = t("filialSecurity.ipSecurity");
    $[0] = t;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  const t2 = `${ROUTES.filials.edit.clearPath}/${filialId}/${ROUTES.filials.edit.pages.common.security}`;
  let t3;
  if ($[2] !== t1 || $[3] !== t2) {
    t3 = {
      name: t1,
      link: t2
    };
    $[2] = t1;
    $[3] = t2;
    $[4] = t3;
  } else {
    t3 = $[4];
  }
  let t4;
  if ($[5] !== t) {
    t4 = t("filialSecurity.passwordSecurity");
    $[5] = t;
    $[6] = t4;
  } else {
    t4 = $[6];
  }
  const t5 = `${ROUTES.filials.edit.clearPath}/${filialId}/${ROUTES.filials.edit.pages.common.security}`;
  let t6;
  if ($[7] !== t4 || $[8] !== t5) {
    t6 = {
      name: t4,
      link: t5
    };
    $[7] = t4;
    $[8] = t5;
    $[9] = t6;
  } else {
    t6 = $[9];
  }
  let t7;
  if ($[10] !== t3 || $[11] !== t6) {
    t7 = {
      withCheck: false,
      items: [t3, t6]
    };
    $[10] = t3;
    $[11] = t6;
    $[12] = t7;
  } else {
    t7 = $[12];
  }
  const safetyMenu = t7;
  let t8;
  if ($[13] !== t) {
    t8 = t("profile.safety");
    $[13] = t;
    $[14] = t8;
  } else {
    t8 = $[14];
  }
  let t9;
  if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
    t9 = {
      width: "100%"
    };
    $[15] = t9;
  } else {
    t9 = $[15];
  }
  let t10;
  if ($[16] !== safetyMenu.items || $[17] !== safetyMenu.withCheck) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsx(Stack, { gap: "11px", sx: t9, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ListItem, { items: safetyMenu.items, withCheck: safetyMenu.withCheck }) });
    $[16] = safetyMenu.items;
    $[17] = safetyMenu.withCheck;
    $[18] = t10;
  } else {
    t10 = $[18];
  }
  let t11;
  if ($[19] !== t10 || $[20] !== t8) {
    t11 = /* @__PURE__ */ jsxRuntimeExports.jsx(CardContainer, { sectionName: t8, Icon: rBe, children: t10 });
    $[19] = t10;
    $[20] = t8;
    $[21] = t11;
  } else {
    t11 = $[21];
  }
  return t11;
};
const MailSection = ({
  filialId
}) => {
  const {
    t
  } = useTranslation();
  const {
    Settings
  } = useAppSelector((state) => state.userInfo);
  const [isModalOpen, setIsModalOpen] = reactExports.useState(false);
  const [{
    data,
    isLoading
  }] = useHomeWidgetSlice().useMailWidget().useState();
  const {
    LoadServicesSection,
    LoadMailSection
  } = useHomeWidgetSlice().actions;
  const handleCreateServer = () => {
    setIsModalOpen(true);
  };
  reactExports.useEffect(() => {
    LoadMailSection(filialId);
  }, []);
  const update = () => {
    LoadServicesSection(filialId);
    LoadMailSection(filialId);
  };
  const safetyMenu = {
    withCheck: false,
    items: [{
      name: t("filials.serverList"),
      link: `${ROUTES.filials.edit.clearPath}/${filialId}/${ROUTES.filials.edit.pages.common.mailServers}`,
      badge: (data == null ? void 0 : data.length) || 0
    }, {
      name: t("filials.addServer"),
      openModal: handleCreateServer
    }, ...!isSaaS(Settings) ? [{
      name: t("filials.emailSetting"),
      link: `${ROUTES.filials.edit.clearPath}/${filialId}/${ROUTES.filials.edit.pages.common.mailingSetup}`
    }] : []]
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(CardContainer, { sectionName: t("servers.title"), Icon: Ece, children: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { w: "100%", align: "center", justify: "center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { size: "sm" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Stack, { gap: "11px", sx: {
      width: "100%"
    }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ListItem, { items: safetyMenu.items, withCheck: safetyMenu.withCheck }) }) }),
    isModalOpen && /* @__PURE__ */ jsxRuntimeExports.jsx(MailServerForm, { mailServer: TEMPLATE_MAIL_SERVER.TEMPLATE_MAIL_SERVER_ENTITY, CustomerId: filialId, opened: isModalOpen, handleChange: update, handleClose: () => setIsModalOpen(false), isEditing: false })
  ] });
};
const useStyles$1 = createStyles((_theme, _, utils) => ({
  homeContainer: {
    width: "100%",
    flexGrow: 1,
    backgroundColor: "#f6f7f9",
    height: `calc(100vh - ${HEADER_HEIGHT}px)`,
    overflow: "scroll",
    padding: "16px"
  },
  homeColumns: {
    columnCount: 4,
    columnGap: "8px",
    [utils.largerThan("xl")]: {
      maxWidth: "1504px"
    },
    [utils.smallerThan("xl")]: {
      columnCount: 4
    },
    [utils.smallerThan("lg")]: {
      columnCount: 3
    },
    [utils.smallerThan("md")]: {
      columnCount: 2
    },
    [utils.smallerThan("xs")]: {
      columnCount: 1
    },
    '& [data-name="card-container"]': {
      breakInside: "avoid",
      marginBottom: "8px"
    }
  }
}));
const useStyles = createStyles(() => ({
  moduleItem: {
    padding: "4px",
    "&:hover": {
      cursor: "pointer",
      backgroundColor: "#A0B0C31A",
      borderRadius: "8px"
    }
  }
}));
const ModuleItem = (t0) => {
  const $ = compilerRuntimeExports.c(14);
  const {
    item
  } = t0;
  const {
    classes
  } = useStyles();
  const navigate = useNavigate();
  let t1;
  if ($[0] !== navigate) {
    t1 = (item_0) => {
      navigate(item_0.link);
    };
    $[0] = navigate;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  const handleRedirect = t1;
  let t2;
  if ($[2] !== handleRedirect || $[3] !== item) {
    t2 = () => handleRedirect(item);
    $[2] = handleRedirect;
    $[3] = item;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  let t3;
  if ($[5] !== item.icon) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: item.icon, alt: "icon", width: "24px" });
    $[5] = item.icon;
    $[6] = t3;
  } else {
    t3 = $[6];
  }
  let t4;
  if ($[7] !== item.label) {
    t4 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "14px", fw: "400", c: "#848E98", children: item.label });
    $[7] = item.label;
    $[8] = t4;
  } else {
    t4 = $[8];
  }
  let t5;
  if ($[9] !== classes.moduleItem || $[10] !== t2 || $[11] !== t3 || $[12] !== t4) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { align: "center", gap: "10px", className: classes.moduleItem, onClick: t2, children: [
      t3,
      t4
    ] });
    $[9] = classes.moduleItem;
    $[10] = t2;
    $[11] = t3;
    $[12] = t4;
    $[13] = t5;
  } else {
    t5 = $[13];
  }
  return t5;
};
const ModulesSection = (t0) => {
  const $ = compilerRuntimeExports.c(50);
  const {
    filialId
  } = t0;
  const {
    t
  } = useTranslation();
  let t1;
  if ($[0] !== t) {
    t1 = t("filials.mail");
    $[0] = t;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  const t2 = `${ROUTES.filials.edit.clearPath}/${filialId}/${ROUTES.filials.edit.pages.modules.email}`;
  let t3;
  if ($[2] !== t1 || $[3] !== t2) {
    t3 = {
      label: t1,
      icon: mailIcon,
      link: t2
    };
    $[2] = t1;
    $[3] = t2;
    $[4] = t3;
  } else {
    t3 = $[4];
  }
  let t4;
  if ($[5] !== t) {
    t4 = t("filials.calendar");
    $[5] = t;
    $[6] = t4;
  } else {
    t4 = $[6];
  }
  const t5 = `${ROUTES.filials.edit.clearPath}/${filialId}/${ROUTES.filials.edit.pages.modules.calendar}`;
  let t6;
  if ($[7] !== t4 || $[8] !== t5) {
    t6 = {
      label: t4,
      icon: calendarIcon,
      link: t5
    };
    $[7] = t4;
    $[8] = t5;
    $[9] = t6;
  } else {
    t6 = $[9];
  }
  let t7;
  if ($[10] !== t) {
    t7 = t("filials.draw");
    $[10] = t;
    $[11] = t7;
  } else {
    t7 = $[11];
  }
  const t8 = `${ROUTES.filials.edit.clearPath}/${filialId}/${ROUTES.filials.edit.pages.modules.draw}`;
  let t9;
  if ($[12] !== t7 || $[13] !== t8) {
    t9 = {
      label: t7,
      icon: drawIcon,
      link: t8
    };
    $[12] = t7;
    $[13] = t8;
    $[14] = t9;
  } else {
    t9 = $[14];
  }
  let t10;
  if ($[15] !== t) {
    t10 = t("filials.contacts");
    $[15] = t;
    $[16] = t10;
  } else {
    t10 = $[16];
  }
  const t11 = `${ROUTES.filials.edit.clearPath}/${filialId}/${ROUTES.filials.edit.pages.modules.contacts}`;
  let t12;
  if ($[17] !== t10 || $[18] !== t11) {
    t12 = {
      label: t10,
      icon: contactsIcon,
      link: t11
    };
    $[17] = t10;
    $[18] = t11;
    $[19] = t12;
  } else {
    t12 = $[19];
  }
  let t13;
  if ($[20] !== t) {
    t13 = t("filials.projects");
    $[20] = t;
    $[21] = t13;
  } else {
    t13 = $[21];
  }
  const t14 = `${ROUTES.filials.edit.clearPath}/${filialId}/${ROUTES.filials.edit.pages.modules.projects}`;
  let t15;
  if ($[22] !== t13 || $[23] !== t14) {
    t15 = {
      label: t13,
      icon: projectsIcon,
      link: t14
    };
    $[22] = t13;
    $[23] = t14;
    $[24] = t15;
  } else {
    t15 = $[24];
  }
  let t16;
  if ($[25] !== t) {
    t16 = t("filials.pages");
    $[25] = t;
    $[26] = t16;
  } else {
    t16 = $[26];
  }
  const t17 = `${ROUTES.filials.edit.clearPath}/${filialId}/${ROUTES.filials.edit.pages.modules.pages}`;
  let t18;
  if ($[27] !== t16 || $[28] !== t17) {
    t18 = {
      label: t16,
      icon: pagesIcon,
      link: t17
    };
    $[27] = t16;
    $[28] = t17;
    $[29] = t18;
  } else {
    t18 = $[29];
  }
  let t19;
  if ($[30] !== t) {
    t19 = t("filials.forms");
    $[30] = t;
    $[31] = t19;
  } else {
    t19 = $[31];
  }
  const t20 = `${ROUTES.filials.edit.clearPath}/${filialId}/${ROUTES.filials.edit.pages.modules.forms}`;
  let t21;
  if ($[32] !== t19 || $[33] !== t20) {
    t21 = {
      label: t19,
      icon: formsIcon,
      link: t20
    };
    $[32] = t19;
    $[33] = t20;
    $[34] = t21;
  } else {
    t21 = $[34];
  }
  let t22;
  if ($[35] !== t12 || $[36] !== t15 || $[37] !== t18 || $[38] !== t21 || $[39] !== t3 || $[40] !== t6 || $[41] !== t9) {
    t22 = [t3, t6, t9, t12, t15, t18, t21];
    $[35] = t12;
    $[36] = t15;
    $[37] = t18;
    $[38] = t21;
    $[39] = t3;
    $[40] = t6;
    $[41] = t9;
    $[42] = t22;
  } else {
    t22 = $[42];
  }
  const modulesMenu = t22;
  let t23;
  if ($[43] !== t) {
    t23 = t("filials.modules.config");
    $[43] = t;
    $[44] = t23;
  } else {
    t23 = $[44];
  }
  let t24;
  if ($[45] !== modulesMenu) {
    t24 = /* @__PURE__ */ jsxRuntimeExports.jsx(SimpleGrid, { cols: 2, spacing: "0", children: modulesMenu.map(_temp$1) });
    $[45] = modulesMenu;
    $[46] = t24;
  } else {
    t24 = $[46];
  }
  let t25;
  if ($[47] !== t23 || $[48] !== t24) {
    t25 = /* @__PURE__ */ jsxRuntimeExports.jsx(CardContainer, { sectionName: t23, Icon: Bje, children: t24 });
    $[47] = t23;
    $[48] = t24;
    $[49] = t25;
  } else {
    t25 = $[49];
  }
  return t25;
};
function _temp$1(item, index) {
  return /* @__PURE__ */ jsxRuntimeExports.jsx(ModuleItem, { item }, index);
}
const ServicesSection = ({
  filialId
}) => {
  const {
    t
  } = useTranslation();
  const [{
    data,
    isLoading
  }] = useHomeWidgetSlice().useServicesWidget().useState();
  const {
    LoadServicesSection
  } = useHomeWidgetSlice().actions;
  reactExports.useEffect(() => {
    LoadServicesSection(filialId);
  }, []);
  const servicesList = (data == null ? void 0 : data.map((item) => {
    const serviceName = t(`filials.services.${HealthServiceType[item.Type]}`);
    return {
      name: item.Name ? `${serviceName} ${item.Name}` : serviceName,
      valid: item.Health
    };
  })) || [];
  if (isLoading) {
    return /* @__PURE__ */ jsxRuntimeExports.jsx(CardContainer, { sectionName: t("filials.availableServices"), Icon: sVe, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { w: "100%", children: Array(8).fill(0).map((_, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { justify: "space-between", align: "center", mb: "xs", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { height: 20, width: "70%", radius: "xl" }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { height: 20, width: 20, circle: true })
    ] }, index)) }) });
  }
  return /* @__PURE__ */ jsxRuntimeExports.jsx(CardContainer, { sectionName: t("filials.availableServices"), Icon: sVe, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Stack, { gap: "7px", sx: {
    width: "100%"
  }, mt: "16px", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ListItem, { items: servicesList, withCheck: true }) }) });
};
const Home = () => {
  const $ = compilerRuntimeExports.c(29);
  const {
    classes
  } = useStyles$1();
  const {
    Settings
  } = useAppSelector(_temp);
  const currentUserFilial = useAppSelector(_temp2);
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    const urlParams = new URLSearchParams(window.location.search);
    t0 = urlParams.get("paymentsDate");
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  const paymentsDate = t0;
  if (currentUserFilial === void 0) {
    return null;
  }
  let t1;
  let t2;
  if ($[1] !== currentUserFilial) {
    t1 = /* @__PURE__ */ jsxRuntimeExports.jsx(UsersSection, { filialId: currentUserFilial });
    t2 = /* @__PURE__ */ jsxRuntimeExports.jsx(MailSection, { filialId: currentUserFilial });
    $[1] = currentUserFilial;
    $[2] = t1;
    $[3] = t2;
  } else {
    t1 = $[2];
    t2 = $[3];
  }
  let t3;
  if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx(RolesSection, {});
    $[4] = t3;
  } else {
    t3 = $[4];
  }
  let t4;
  if ($[5] !== Settings || $[6] !== currentUserFilial) {
    t4 = isSaaS(Settings) && /* @__PURE__ */ jsxRuntimeExports.jsx(PaymentSection, { filialId: currentUserFilial, paymentsDate });
    $[5] = Settings;
    $[6] = currentUserFilial;
    $[7] = t4;
  } else {
    t4 = $[7];
  }
  let t5;
  if ($[8] !== currentUserFilial) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(ServicesSection, { filialId: currentUserFilial });
    $[8] = currentUserFilial;
    $[9] = t5;
  } else {
    t5 = $[9];
  }
  let t6;
  if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(StatisticsSection, {});
    $[10] = t6;
  } else {
    t6 = $[10];
  }
  let t10;
  let t7;
  let t8;
  let t9;
  if ($[11] !== currentUserFilial) {
    t7 = /* @__PURE__ */ jsxRuntimeExports.jsx(DiskSpaceSection, { filialId: currentUserFilial });
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsx(FilialSection, { filialId: currentUserFilial });
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx(ModulesSection, { filialId: currentUserFilial });
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsx(SafetySection, { filialId: currentUserFilial });
    $[11] = currentUserFilial;
    $[12] = t10;
    $[13] = t7;
    $[14] = t8;
    $[15] = t9;
  } else {
    t10 = $[12];
    t7 = $[13];
    t8 = $[14];
    t9 = $[15];
  }
  let t11;
  if ($[16] !== classes.homeColumns || $[17] !== t1 || $[18] !== t10 || $[19] !== t2 || $[20] !== t4 || $[21] !== t5 || $[22] !== t7 || $[23] !== t8 || $[24] !== t9) {
    t11 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.homeColumns, children: [
      t1,
      t2,
      t3,
      t4,
      t5,
      t6,
      t7,
      t8,
      t9,
      t10
    ] });
    $[16] = classes.homeColumns;
    $[17] = t1;
    $[18] = t10;
    $[19] = t2;
    $[20] = t4;
    $[21] = t5;
    $[22] = t7;
    $[23] = t8;
    $[24] = t9;
    $[25] = t11;
  } else {
    t11 = $[25];
  }
  let t12;
  if ($[26] !== classes.homeContainer || $[27] !== t11) {
    t12 = /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { componentTitle: "Home page", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Layout, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.homeContainer, children: t11 }) }) });
    $[26] = classes.homeContainer;
    $[27] = t11;
    $[28] = t12;
  } else {
    t12 = $[28];
  }
  return t12;
};
function _temp(state) {
  return state.userInfo;
}
function _temp2(state_0) {
  var _a, _b;
  return (_b = (_a = state_0.userInfo) == null ? void 0 : _a.User) == null ? void 0 : _b.Customer.Id;
}
export {
  Home
};
//# sourceMappingURL=index-DUqj3r8B.js.map
