import { E as compilerRuntimeExports, j as jsxRuntimeExports, r as reactExports, a0 as useParams, V as Outlet } from "./vendor-react-DYNCg6N5.js";
import { K as IUsersSortField, U as UserStatusEnum, H as HEADER_HEIGHT, R as ROUTES, aD as UsersIcon, c6 as FilialsIcon, aE as ShieldIcon, aF as MailIcon, a2 as DriveIcon, aH as TimezonesIcon, c7 as BellIcon, c8 as BellCogIcon, c9 as ChecklistIcon, c as useAppSelector, i as isSaaS, bT as isAdmin, bL as useGetUserInfoQuery, L as Layout, E as ErrorBoundary, aR as NotFound } from "./index-DfebxkL9.js";
import { S as SidebarMenu, a as SimpleNavbar } from "./index-B7nmdYVM.js";
import { c as createStyles, F as Flex, g as Loader, b as Box, o as Burger } from "./vendor-mantine-h0WlM2Mj.js";
import { g as getUserEditRoutes } from "./utils-D5kCyTRM.js";
import { u as useTranslation } from "./vendor-i18n-wisIXUFi.js";
var IUserTypeEnum = /* @__PURE__ */ ((IUserTypeEnum2) => {
  IUserTypeEnum2[IUserTypeEnum2["Contact"] = 0] = "Contact";
  IUserTypeEnum2[IUserTypeEnum2["LDAP"] = 20] = "LDAP";
  IUserTypeEnum2[IUserTypeEnum2["SSO"] = 21] = "SSO";
  return IUserTypeEnum2;
})(IUserTypeEnum || {});
var HealthServiceType = /* @__PURE__ */ ((HealthServiceType2) => {
  HealthServiceType2[HealthServiceType2["Unknown"] = 0] = "Unknown";
  HealthServiceType2[HealthServiceType2["MailService"] = 1] = "MailService";
  HealthServiceType2[HealthServiceType2["DocumentServer"] = 2] = "DocumentServer";
  HealthServiceType2[HealthServiceType2["MailModule"] = 3] = "MailModule";
  HealthServiceType2[HealthServiceType2["ContactsModule"] = 4] = "ContactsModule";
  HealthServiceType2[HealthServiceType2["DiskModule"] = 5] = "DiskModule";
  HealthServiceType2[HealthServiceType2["DrawModule"] = 6] = "DrawModule";
  HealthServiceType2[HealthServiceType2["CalendarModule"] = 7] = "CalendarModule";
  HealthServiceType2[HealthServiceType2["ProjectsModule"] = 8] = "ProjectsModule";
  HealthServiceType2[HealthServiceType2["LdapServer"] = 9] = "LdapServer";
  return HealthServiceType2;
})(HealthServiceType || {});
({
  Status: UserStatusEnum.Ban,
  UserType: IUserTypeEnum.Contact
});
const credentialsInit = {
  Email: "",
  Login: "",
  Password: "",
  PasswordResetUrl: "",
  AdditionalEmail: null,
  isCreateEmail: true
};
const commonInit = {
  FirstName: "",
  SurName: "",
  MiddleName: "",
  Gender: 0,
  BirthDate: null,
  Address: "",
  Phone: "",
  AdditionalPhone: "",
  LastEntryDate: "",
  DateOfCreate: /* @__PURE__ */ new Date()
};
const initForm = {
  Id: 0,
  Avatar: "",
  AvatarId: null,
  Status: -2,
  UserType: IUsersSortField.UserType,
  Credentials: credentialsInit,
  Common: commonInit,
  // default select filial with Id: 1`
  Customer: {
    Id: 0
  },
  Positions: [],
  Roles: [],
  LdapIdentifier: null,
  Connections: [],
  LinkedEmail: [],
  Quota: {
    Id: 0,
    Name: ""
  },
  StorageData: {},
  TimeZone: null
};
const useStyles = createStyles((theme, _, utils) => ({
  container: {
    flexGrow: 1,
    width: `calc(100% - 580px)`,
    backgroundColor: theme.colors.backgroundGray[0],
    padding: `${theme.spacing.md} ${theme.spacing.sm} ${theme.spacing.md} ${theme.spacing.sm}`,
    [utils.smallerThan("lg")]: {
      width: "100%"
    },
    [utils.smallerThan("md")]: {
      padding: "16px"
    },
    [utils.largerThan("lg")]: {
      marginRight: 290
    },
    [utils.largerThan("md")]: {
      marginLeft: 290
    }
  },
  section: {
    height: `calc(100vh - ${HEADER_HEIGHT}px)`
  },
  scrollContainer: {
    display: "flex",
    alignItems: "center",
    justifyContent: "flex-start",
    flexDirection: "column",
    borderRadius: "8px",
    height: "100%",
    backgroundColor: theme.colors.backgroundGray[0]
  },
  headerMenu: {
    backgroundColor: "white",
    padding: "10px 0 0 10px",
    [utils.largerThan("md")]: {
      display: "none"
    }
  },
  headerMenuBurger: {
    div: {
      height: "2px"
    }
  },
  simpleNavbar: {
    backgroundColor: theme.colors.backgroundGray[0],
    position: "fixed",
    overflowY: "auto",
    [utils.smallerThan("md")]: {
      alignItems: "flex-start",
      marginRight: theme.spacing.xs,
      marginLeft: theme.spacing.xs,
      backgroundColor: "white",
      padding: "0"
    }
  },
  select: {
    "& .mantine-Select-input": {
      borderRadius: "8px",
      border: "1px solid #D0D5DD"
    }
  }
}));
const useGetNavMenuItems = (isSaaSProduct) => {
  const $ = compilerRuntimeExports.c(47);
  const {
    t
  } = useTranslation();
  let t0;
  if ($[0] !== t) {
    t0 = t("profile.personalData");
    $[0] = t;
    $[1] = t0;
  } else {
    t0 = $[1];
  }
  let t1;
  if ($[2] !== t0) {
    t1 = {
      label: t0,
      icon: UsersIcon,
      value: ROUTES.profile.pages.personalData
    };
    $[2] = t0;
    $[3] = t1;
  } else {
    t1 = $[3];
  }
  let t2;
  if ($[4] !== t) {
    t2 = t("profile.company");
    $[4] = t;
    $[5] = t2;
  } else {
    t2 = $[5];
  }
  let t3;
  if ($[6] !== t2) {
    t3 = {
      label: t2,
      icon: FilialsIcon,
      value: ROUTES.profile.pages.filials
    };
    $[6] = t2;
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  let t4;
  if ($[8] !== t) {
    t4 = t("profile.safety");
    $[8] = t;
    $[9] = t4;
  } else {
    t4 = $[9];
  }
  let t5;
  if ($[10] !== t4) {
    t5 = {
      label: t4,
      icon: ShieldIcon,
      value: ROUTES.profile.pages.safety
    };
    $[10] = t4;
    $[11] = t5;
  } else {
    t5 = $[11];
  }
  let t6;
  if ($[12] !== t) {
    t6 = t("profile.emailAccount");
    $[12] = t;
    $[13] = t6;
  } else {
    t6 = $[13];
  }
  let t7;
  if ($[14] !== t6) {
    t7 = {
      label: t6,
      icon: MailIcon,
      value: ROUTES.profile.pages.mailAccount
    };
    $[14] = t6;
    $[15] = t7;
  } else {
    t7 = $[15];
  }
  let t8;
  if ($[16] !== t) {
    t8 = t("filials.diskSpace.disk");
    $[16] = t;
    $[17] = t8;
  } else {
    t8 = $[17];
  }
  let t9;
  if ($[18] !== t8) {
    t9 = {
      label: t8,
      icon: DriveIcon,
      value: ROUTES.profile.pages.disk
    };
    $[18] = t8;
    $[19] = t9;
  } else {
    t9 = $[19];
  }
  let t10;
  if ($[20] !== t) {
    t10 = t("profile.locale");
    $[20] = t;
    $[21] = t10;
  } else {
    t10 = $[21];
  }
  let t11;
  if ($[22] !== t10) {
    t11 = {
      label: t10,
      icon: TimezonesIcon,
      value: ROUTES.profile.pages.locale
    };
    $[22] = t10;
    $[23] = t11;
  } else {
    t11 = $[23];
  }
  let t12;
  if ($[24] !== t) {
    t12 = t("profile.notifications");
    $[24] = t;
    $[25] = t12;
  } else {
    t12 = $[25];
  }
  let t13;
  if ($[26] !== t12) {
    t13 = {
      label: t12,
      icon: BellIcon,
      value: ROUTES.profile.pages.notifications
    };
    $[26] = t12;
    $[27] = t13;
  } else {
    t13 = $[27];
  }
  let t14;
  if ($[28] !== t) {
    t14 = t("profile.notificationSettings");
    $[28] = t;
    $[29] = t14;
  } else {
    t14 = $[29];
  }
  let t15;
  if ($[30] !== t14) {
    t15 = {
      label: t14,
      icon: BellCogIcon,
      value: ROUTES.profile.pages.notificationSettings
    };
    $[30] = t14;
    $[31] = t15;
  } else {
    t15 = $[31];
  }
  let t16;
  if ($[32] !== isSaaSProduct || $[33] !== t || $[34] !== t1 || $[35] !== t11 || $[36] !== t13 || $[37] !== t15 || $[38] !== t3 || $[39] !== t5 || $[40] !== t7 || $[41] !== t9) {
    const editProfileNavItems = [t1, t3, t5, t7, t9, t11, t13, t15];
    if (isSaaSProduct) {
      let t17;
      if ($[43] !== t) {
        t17 = t("license.licenses");
        $[43] = t;
        $[44] = t17;
      } else {
        t17 = $[44];
      }
      let t18;
      if ($[45] !== t17) {
        t18 = {
          label: t17,
          icon: ChecklistIcon,
          value: ROUTES.profile.pages.licenses
        };
        $[45] = t17;
        $[46] = t18;
      } else {
        t18 = $[46];
      }
      editProfileNavItems.push(t18);
    }
    t16 = {
      editProfileNavItems
    };
    $[32] = isSaaSProduct;
    $[33] = t;
    $[34] = t1;
    $[35] = t11;
    $[36] = t13;
    $[37] = t15;
    $[38] = t3;
    $[39] = t5;
    $[40] = t7;
    $[41] = t9;
    $[42] = t16;
  } else {
    t16 = $[42];
  }
  return t16;
};
const NavMenu = (t0) => {
  const $ = compilerRuntimeExports.c(11);
  const {
    setIsOpen
  } = t0;
  const {
    t
  } = useTranslation();
  const {
    Settings
  } = useAppSelector(_temp$1);
  let t1;
  if ($[0] !== Settings) {
    t1 = isSaaS(Settings);
    $[0] = Settings;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  const isSaaSProduct = t1;
  const {
    editProfileNavItems
  } = useGetNavMenuItems(isSaaSProduct);
  let t2;
  if ($[2] !== t) {
    t2 = t("profil");
    $[2] = t;
    $[3] = t2;
  } else {
    t2 = $[3];
  }
  let t3;
  if ($[4] !== editProfileNavItems || $[5] !== t2) {
    t3 = [{
      label: t2,
      pages: editProfileNavItems
    }];
    $[4] = editProfileNavItems;
    $[5] = t2;
    $[6] = t3;
  } else {
    t3 = $[6];
  }
  const linksBlocks = t3;
  let t4;
  if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
    t4 = getUserEditRoutes();
    $[7] = t4;
  } else {
    t4 = $[7];
  }
  let t5;
  if ($[8] !== linksBlocks || $[9] !== setIsOpen) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenu, { routes: t4, setIsOpen, linksBlocks });
    $[8] = linksBlocks;
    $[9] = setIsOpen;
    $[10] = t5;
  } else {
    t5 = $[10];
  }
  return t5;
};
function _temp$1(state) {
  return state.userInfo;
}
const EditUserInfoContext = reactExports.createContext({});
const Profile = (t0) => {
  const $ = compilerRuntimeExports.c(21);
  const {
    children
  } = t0;
  const {
    id: t1
  } = useParams();
  const id = t1 === void 0 ? "" : t1;
  const containerRef = reactExports.useRef(null);
  const [isOpen, setIsOpen] = reactExports.useState(false);
  const [userData, setUserData] = reactExports.useState(initForm);
  const currentId = id ? Number(id) : 0;
  const currentUser = useAppSelector(_temp);
  let t2;
  if ($[0] !== currentUser) {
    t2 = isAdmin(currentUser);
    $[0] = currentUser;
    $[1] = t2;
  } else {
    t2 = $[1];
  }
  const isLimitedAccess = !t2;
  const {
    classes
  } = useStyles();
  const {
    data,
    error,
    isLoading,
    refetch
  } = useGetUserInfoQuery(currentId);
  const [avatarKey, setAvatarKey] = reactExports.useState("");
  let t3;
  let t4;
  if ($[2] !== data) {
    t3 = () => {
      if (data) {
        setUserData(data);
      }
    };
    t4 = [data];
    $[2] = data;
    $[3] = t3;
    $[4] = t4;
  } else {
    t3 = $[3];
    t4 = $[4];
  }
  reactExports.useEffect(t3, t4);
  const isLdapUser = !!(userData == null ? void 0 : userData.LdapIdentifier);
  let t5;
  if ($[5] !== avatarKey || $[6] !== currentId || $[7] !== isLdapUser || $[8] !== isLimitedAccess || $[9] !== refetch || $[10] !== userData) {
    t5 = {
      currentId,
      isLimitedAccess,
      userInfoCommon: userData,
      avatarKey,
      setAvatarKey,
      isLdapUser,
      refetchUserInfo: refetch
    };
    $[5] = avatarKey;
    $[6] = currentId;
    $[7] = isLdapUser;
    $[8] = isLimitedAccess;
    $[9] = refetch;
    $[10] = userData;
    $[11] = t5;
  } else {
    t5 = $[11];
  }
  const initialValues = t5;
  if (currentId !== void 0 && isNaN(Number(currentId)) || error) {
    let t62;
    if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
      t62 = /* @__PURE__ */ jsxRuntimeExports.jsx(NotFound, {});
      $[12] = t62;
    } else {
      t62 = $[12];
    }
    return t62;
  }
  let t6;
  if ($[13] !== children || $[14] !== classes || $[15] !== isLoading || $[16] !== isOpen) {
    t6 = isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { justify: "center", align: "center", w: "100vw", h: "100vh", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, {}) }) : /* @__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, { 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 })
    ] });
    $[13] = children;
    $[14] = classes;
    $[15] = isLoading;
    $[16] = isOpen;
    $[17] = t6;
  } else {
    t6 = $[17];
  }
  let t7;
  if ($[18] !== initialValues || $[19] !== t6) {
    t7 = /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { componentTitle: "EditUser page", children: /* @__PURE__ */ jsxRuntimeExports.jsx(EditUserInfoContext.Provider, { value: initialValues, children: t6 }) });
    $[18] = initialValues;
    $[19] = t6;
    $[20] = t7;
  } else {
    t7 = $[20];
  }
  return t7;
};
function _temp(state) {
  return state.userInfo.User;
}
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  EditUserInfoContext,
  Profile
}, Symbol.toStringTag, { value: "Module" }));
export {
  EditUserInfoContext as E,
  HealthServiceType as H,
  IUserTypeEnum as I,
  index as a,
  initForm as i
};
//# sourceMappingURL=index-TL41xEJi.js.map
