import { jsxs as s, jsx as a, Fragment as H } from "react/jsx-runtime";
import { useRef as X, useState as J, useEffect as he } from "react";
import { Modal as ge, Box as A, IconButton as pe, FormControl as y, FormGroup as fe, Button as Q } from "@mui/material";
import ye from "@/hooks/useTrackEvent";
import { g as be, a as ve, b as Ne } from "./RoleManagement-BThAL5LO.js";
import { getRoleList as Te, getLocationTypes as we, execute as O } from "@/common/services/GlobalApis";
import { showToast as W } from "@/common/toaster/toaster";
import { useForm as Ie } from "react-hook-form";
import { yupResolver as xe } from "@hookform/resolvers/yup";
import "@/assets/scss/scrollBar.scss";
import { FormItem as c } from "@/views/custom-components/FormItem.jsx";
import * as N from "yup";
import j from "@/views/custom-components/CustomTextField";
import Z from "@/views/custom-components/CustomDropdown";
import $ from "@/views/custom-components/CustomCheckBox";
import x from "@/views/custom-components/CustomAutoComplete";
import { useTranslateProvider as Me } from "@/common/languageTranslator/TranslationContext";
import { FontAwesomeIcon as Re } from "@fortawesome/react-fontawesome";
import { faXmark as Be } from "@fortawesome/free-solid-svg-icons";
import b from "@/common/services/util/GeneralUtil";
import v from "prop-types";
import G from "@/views/custom-components/CustomToggleSwitch";
import { useSelector as Le } from "react-redux";
import { getUseSkeleton as ke } from "@/store/reducers/SkeletonReducer";
const ee = ({ children: T, isLoading: f }) => !Le(ke) || !f ? T : /* @__PURE__ */ s("div", { className: "pt-6 h-[88vh]", children: [
  /* @__PURE__ */ s("div", { className: "px-8 pt-2 pb-4 flex items-center justify-between", children: [
    /* @__PURE__ */ a("div", { className: "bg-gray-300 animate-pulse rounded-md w-32 h-8" }),
    /* @__PURE__ */ a("div", { className: "bg-gray-300 animate-pulse rounded-full w-10 h-10" })
  ] }),
  /* @__PURE__ */ s("div", { className: "px-8 pb-8 space-y-6 overflow-y-auto max-h-[80vh]", children: [
    /* @__PURE__ */ a("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: [1, 2, 3].map((h) => /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
      /* @__PURE__ */ a("div", { className: "h-4 bg-gray-300 rounded w-1/3 mb-2 animate-pulse" }),
      /* @__PURE__ */ a("div", { className: "h-10 bg-gray-300 rounded animate-pulse w-full" })
    ] }, h)) }),
    /* @__PURE__ */ a("div", { className: "flex items-center gap-6 w-full", children: /* @__PURE__ */ s("div", { className: "w-full", children: [
      /* @__PURE__ */ a("div", { className: "h-4 bg-gray-300 rounded w-1/4 mb-2 animate-pulse" }),
      /* @__PURE__ */ a("div", { className: "h-8 bg-gray-300 rounded-full w-16 animate-pulse" })
    ] }) }),
    /* @__PURE__ */ s("div", { className: "space-y-4", children: [
      [1, 2].map((h) => /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ a("div", { className: "h-4 bg-gray-300 rounded w-1/4 mb-2 animate-pulse" }),
        /* @__PURE__ */ a("div", { className: "h-10 bg-gray-300 rounded animate-pulse w-full" })
      ] }, h)),
      /* @__PURE__ */ a("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [1, 2].map((h) => /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ a("div", { className: "h-4 bg-gray-300 rounded w-1/3 mb-2 animate-pulse" }),
        /* @__PURE__ */ a("div", { className: "h-10 bg-gray-300 rounded animate-pulse w-full" })
      ] }, h)) }),
      [1, 2].map((h) => /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ a("div", { className: "h-4 bg-gray-300 rounded w-1/3 mb-2 animate-pulse" }),
        /* @__PURE__ */ a("div", { className: "h-10 bg-gray-300 rounded animate-pulse w-full" })
      ] }, h))
    ] }),
    /* @__PURE__ */ s("div", { className: "flex items-center gap-6", children: [
      /* @__PURE__ */ s("div", { className: "w-[60%]", children: [
        /* @__PURE__ */ a("div", { className: "h-4 bg-gray-300 rounded w-1/3 mb-2 animate-pulse" }),
        /* @__PURE__ */ a("div", { className: "h-8 bg-gray-300 rounded-full w-16 animate-pulse" })
      ] }),
      /* @__PURE__ */ s("div", { className: "w-[40%] flex items-center gap-2", children: [
        /* @__PURE__ */ a("div", { className: "h-5 w-5 bg-gray-300 rounded animate-pulse" }),
        /* @__PURE__ */ a("div", { className: "h-4 bg-gray-300 rounded w-1/3 animate-pulse" })
      ] })
    ] }),
    /* @__PURE__ */ s("div", { className: "space-y-2", children: [
      /* @__PURE__ */ a("div", { className: "h-4 bg-gray-300 rounded w-1/4 mb-2 animate-pulse" }),
      /* @__PURE__ */ a("div", { className: "flex flex-wrap gap-4", children: [1, 2, 3, 4].map((h) => /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
        /* @__PURE__ */ a("div", { className: "h-5 w-5 bg-gray-300 rounded animate-pulse" }),
        /* @__PURE__ */ a("div", { className: "h-4 w-16 bg-gray-300 rounded animate-pulse" })
      ] }, h)) })
    ] })
  ] }),
  /* @__PURE__ */ s("div", { className: "flex items-center justify-end gap-3 pt-6 px-8 pb-4 border-t border-slate-100", children: [
    /* @__PURE__ */ a("div", { className: "h-9 w-20 bg-gray-300 rounded animate-pulse" }),
    /* @__PURE__ */ a("div", { className: "h-9 w-24 bg-gray-300 rounded animate-pulse" })
  ] })
] });
ee.propTypes = {
  children: v.any,
  isLoading: v.any
};
const Ce = [{ name: "WEB" }, { name: "MOBILE" }, { name: "BOTH" }], Se = [
  { label: "Authenticator App", value: "AUTHENTICATOR_APP" }
], qe = ({
  selectedId: T,
  isUpdate: f,
  open: L,
  setOpen: h,
  isRoleListModified: ae
}) => {
  const z = X(null), V = X(!1), F = ye(), [i, U] = J({}), [te, _] = J(!1), le = N.object().shape({
    name: N.string().required("Enter Role Name"),
    locationTypes: N.array().when("isLocationRequired", {
      is: !0,
      then: (e) => e.min(1, "Select Location Type").required("Select Location Type"),
      otherwise: (e) => e.notRequired()
    }),
    roleType: N.string().required("Select Role Type"),
    isBankDetailsRequired: b.isTecho ? N.boolean().notRequired() : N.boolean().nullable().defined("Please Select a Value"),
    healthInfrastructureIds: N.array().when("isHealthInfraMandatory", {
      is: !0,
      then: (e) => e.min(1, "Select Health Infrastructure Type").required("Select Health Infrastructure Type"),
      otherwise: (e) => e.notRequired()
    })
  }), {
    control: r,
    handleSubmit: se,
    formState: { errors: m, isSubmitting: ne },
    setValue: g,
    // getValues,
    watch: w,
    reset: oe
  } = Ie({
    defaultValues: {
      name: "",
      locationTypes: [],
      maxPosition: "",
      maxHealthInfra: "",
      roleType: "",
      isLastNameMandatory: !1,
      isAadharNumMandatory: !1,
      isEmailMandatory: !1,
      isContactNumMandatory: !1,
      isConvoxIdMandatory: !1,
      isHealthInfraMandatory: !1,
      isGeolocationMandatory: !1,
      roleIds: [],
      canManageRoleIds: [],
      manageByTeamTypeIds: [],
      canSelfManage: !1,
      healthInfrastructureIds: [],
      categoryIds: [],
      isBankDetailsRequired: !1,
      isBankDetailsMandatory: !1,
      isTwoFactorEnabled: !1,
      twoFactorType: "",
      id: "",
      code: "",
      description: "",
      createdBy: "",
      state: "",
      createdOn: "",
      assignedFeatureList: "",
      assignedFeatures: "",
      isSmagTrainedMandatory: "",
      isLocationRequired: !0,
      isNodalMandatory: !1
    },
    resolver: xe(le),
    mode: "onChange",
    shouldUnregister: !1
  }), re = w("isBankDetailsRequired"), ie = w("isTwoFactorEnabled"), Y = w("roleType"), de = Y === "WEB" || Y === "BOTH", E = w("locationTypes"), { translate: D } = Me(), ce = w("isLocationRequired"), me = w("isHealthInfraMandatory"), P = [
    { label: "Email", value: "isEmailMandatory" },
    ...(i == null ? void 0 : i.env) !== "chip" ? [{ label: "Aadhar Number", value: "isAadharNumMandatory" }] : [],
    { label: "Contact Number", value: "isContactNumMandatory" },
    ...(i == null ? void 0 : i.env) !== "chip" ? [{ label: "Convox Id", value: "isConvoxIdMandatory" }] : [],
    { label: "Last Name", value: "isLastNameMandatory" },
    { label: "Health Infrastructure", value: "isHealthInfraMandatory" },
    { label: "GeoLocation", value: "isGeolocationMandatory" },
    ...(i == null ? void 0 : i.env) !== "chip" ? [{ label: "Smag Trained", value: "isSmagTrainedMandatory" }] : [],
    { label: "Nodal", value: "isNodalMandatory" }
  ].filter((e) => b.isTecho ? ![
    "isGeolocationMandatory",
    "isHealthInfraMandatory",
    "isLastNameMandatory",
    "isSmagTrainedMandatory"
  ].includes(e.value) : b.isSewaRural || b.isPhmp || b.isImomcare ? e.value !== "isNodalMandatory" : b.isEkavach ? ![
    "isGeolocationMandatory",
    "isHealthInfraMandatory",
    "isLastNameMandatory",
    "isNodalMandatory",
    "isSmagTrainedMandatory"
  ].includes(e.value) : !0), k = () => {
    h(0), oe(), F("conversion_event", {
      form: z.current,
      form_name: "Manage Role",
      submit: V.current
    }), F("button_click", {
      button_name: "add role close button",
      button_type: "cancel",
      button_id: "managerole-close-button"
    });
  }, I = (e, t, d) => {
    g(d, t);
  }, ue = async (e) => {
    var t, d;
    try {
      F("button_click", {
        button_name: f ? "update role  button" : "add role  button",
        button_type: "submit",
        button_id: "managerole-add-button"
      }), delete e.bankDetailsRequired, delete e.bankDetailsMandatory, e.roleType !== "WEB" && e.roleType !== "BOTH" && (e.isTwoFactorEnabled = !1), e.isTwoFactorEnabled ? e.twoFactorType || (e.twoFactorType = "AUTHENTICATOR_APP") : e.twoFactorType = null, f || (delete e.id, delete e.state, delete e.createdOn, delete e.createdBy, delete e.code, delete e.description, delete e.assignedFeatures, delete e.assignedFeatureList), e.roleIds = e.roleIds.map((l) => l == null ? void 0 : l.id), e.canManageRoleIds = e.canManageRoleIds.map((l) => l == null ? void 0 : l.id), e.manageByTeamTypeIds = e.manageByTeamTypeIds.map(
        (l) => l == null ? void 0 : l.id
      ), e.healthInfrastructureIds = e.healthInfrastructureIds.map(
        (l) => l == null ? void 0 : l.id
      ), e.categoryIds = e.categoryIds.map((l) => l == null ? void 0 : l.id), e.locationTypes = e.isLocationRequired === !0 ? e.locationTypes : [], delete e.isLocationRequired, e.manageByRoleIds = e.roleIds, f ? await ve(e) : await Ne(e), W({
        type: "success",
        message: `Role ${f ? "Updated" : "Added"} Successfully`
      }), V.current = !0, k(), ae();
    } catch (l) {
      W({
        type: "error",
        message: `Role Cannot be added: ${(d = (t = l == null ? void 0 : l.response) == null ? void 0 : t.data) == null ? void 0 : d.message}`
      });
    }
  };
  return he(() => {
    (async () => {
      try {
        _((d) => !d);
        const t = b.getEnv();
        if (L !== 0) {
          const [d, l, C, S, q] = await Promise.all([
            Te(),
            we(),
            O({
              code: "team_all_types_for_roles",
              parameters: {}
            }),
            O({
              code: "retrieve_field_values_for_form_field",
              parameters: {
                form: "WEB",
                fieldKey: "role_catg"
              }
            }),
            O({
              code: "retrieve_field_values_for_form_field",
              parameters: {
                form: "WEB",
                fieldKey: "infra_type"
              }
            })
          ]);
          if (U((p) => {
            var M, R, B;
            return {
              ...p,
              roles: d.data,
              locationData: l.data,
              manageTeam: (M = C == null ? void 0 : C.data) == null ? void 0 : M.result,
              category: (R = S == null ? void 0 : S.data) == null ? void 0 : R.result,
              healthInfraType: (B = q == null ? void 0 : q.data) == null ? void 0 : B.result
            };
          }), T) {
            const { data: p } = await be(T);
            U((n) => ({ ...n, roleData: p, env: t })), Object.keys(p).map((n) => g(n, p[n])), g("isBankDetailsRequired", p.isBankDetailsRequired), g("isBankDetailsMandatory", p.isBankDetailsMandatory);
            const {
              manageByTeamTypeIds: M,
              healthInfrastructureIds: R,
              roleIds: B,
              categoryIds: K
            } = p;
            g(
              "manageByTeamTypeIds",
              M ? M.map(
                (n) => {
                  var u;
                  return (u = C.data.result) == null ? void 0 : u.find((o) => (o == null ? void 0 : o.id) === n);
                }
              ) : []
            ), g(
              "healthInfrastructureIds",
              R ? R.map(
                (n) => {
                  var u;
                  return (u = q.data.result) == null ? void 0 : u.find(
                    (o) => (o == null ? void 0 : o.id) === n
                  );
                }
              ).filter((n) => n !== void 0) : []
            ), g(
              "categoryIds",
              K ? K.map(
                (n) => {
                  var u;
                  return (u = S.data.result) == null ? void 0 : u.find((o) => (o == null ? void 0 : o.id) === n);
                }
              ) : []
            ), g(
              "roleIds",
              B ? B.map((n) => {
                var u;
                return (u = d.data) == null ? void 0 : u.find((o) => (o == null ? void 0 : o.id) === n);
              }).filter((n) => n !== void 0) : []
            ), g(
              "canManageRoleIds",
              p.canManageRoleIds ? p.canManageRoleIds.map((n) => {
                var u;
                return (u = d.data) == null ? void 0 : u.find((o) => (o == null ? void 0 : o.id) === n);
              }).filter((n) => n !== void 0) : []
            ), p.locationTypes.length > 0 ? g("isLocationRequired", !0) : g("isLocationRequired", !1);
          }
        }
        _((d) => !d);
      } catch (t) {
        W({
          message: `Error in manage role :${t == null ? void 0 : t.message}`,
          type: "error"
        }), _((d) => !d);
      }
    })();
  }, [T, L]), /* @__PURE__ */ a(
    ge,
    {
      open: L !== 0,
      onClose: k,
      "data-testid": "managerole-modal",
      children: /* @__PURE__ */ a("div", { className: "mt-10 fixed inset-0 z-[100] flex items-center justify-center p-4 animate-in fade-in duration-200", children: /* @__PURE__ */ a(
        A,
        {
          className: "w-full max-w-2xl rounded-[2.5rem] shadow-2xl shadow-blue-900/10 overflow-hidden flex flex-col animate-in zoom-in-95 duration-300",
          sx: { bgcolor: (e) => e.palette.custom.customBackground },
          children: /* @__PURE__ */ s(ee, { isLoading: te, children: [
            /* @__PURE__ */ s("div", { className: "px-8 pt-8 pb-4 flex items-center justify-between", children: [
              /* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(
                A,
                {
                  component: "h2",
                  className: "text-2xl font-bold text-customBlue",
                  sx: { color: "text.primary" },
                  children: f ? "Update Role" : "Add New Role"
                }
              ) }),
              /* @__PURE__ */ a(
                pe,
                {
                  size: "small",
                  onClick: k,
                  className: "w-10 h-10 rounded-full bg-slate-100 flex items-center justify-center text-slate-400 hover:bg-slate-200 hover:text-slate-600 transition-all",
                  "data-testid": "managerole-close-icon",
                  children: /* @__PURE__ */ a(Re, { icon: Be, size: "lg" })
                }
              )
            ] }),
            /* @__PURE__ */ s(
              "form",
              {
                onSubmit: se(ue),
                ref: z,
                className: "px-8 pb-8 space-y-6 overflow-y-auto max-h-[80vh]",
                children: [
                  /* @__PURE__ */ s("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: [
                    /* @__PURE__ */ a(y, { variant: "outlined", children: /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(c, { label: "Role Name", children: /* @__PURE__ */ a(
                      j,
                      {
                        placeholder: "Role Name",
                        name: "name",
                        id: "name",
                        errors: m,
                        control: r,
                        dataTestId: "managerole-role-name-field"
                      }
                    ) }) }) }),
                    /* @__PURE__ */ a(y, { variant: "outlined", children: /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(
                      c,
                      {
                        label: "Max Position",
                        tooltip: "This is the maximum no of users that can be created at one location of this role type",
                        children: /* @__PURE__ */ a(
                          j,
                          {
                            name: "maxPosition",
                            id: "maxPosition",
                            errors: m,
                            control: r,
                            rules: {
                              maxLength: 3,
                              pattern: /^\d{1,3}$/
                            },
                            inputProps: {
                              maxLength: 3,
                              inputMode: "numeric",
                              pattern: "[0-9]*",
                              onInput: (e) => {
                                e.target.value = e.target.value.replace(/\D/g, "");
                              }
                            },
                            dataTestId: "managerole-max-position-field"
                          }
                        )
                      }
                    ) }) }),
                    !b.isTecho && /* @__PURE__ */ a(y, { variant: "outlined", children: /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(c, { label: "Max Health Infrastructure", children: /* @__PURE__ */ a(
                      j,
                      {
                        name: "maxHealthInfra",
                        id: "maxHealthInfra",
                        control: r,
                        errors: m,
                        rules: {
                          maxLength: 3,
                          pattern: /^\d{1,3}$/
                        },
                        inputProps: {
                          maxLength: 3,
                          inputMode: "numeric",
                          pattern: "[0-9]*",
                          onInput: (e) => {
                            e.target.value = e.target.value.replace(
                              /\D/g,
                              ""
                            );
                          }
                        },
                        dataTestId: "managerole-max-health-infra-field"
                      }
                    ) }) }) })
                  ] }),
                  /* @__PURE__ */ a("div", { className: "flex items-center gap-6 w-full", children: /* @__PURE__ */ a(
                    y,
                    {
                      variant: "outlined",
                      className: "flex flex-row items-center w-full ",
                      children: /* @__PURE__ */ a(
                        c,
                        {
                          label: "Location Required",
                          required: !0,
                          direction: "row",
                          children: /* @__PURE__ */ a(
                            G,
                            {
                              control: r,
                              name: "isLocationRequired",
                              options: [
                                { label: "Yes", value: !0 },
                                { label: "No", value: !1 }
                              ],
                              errors: m
                            }
                          )
                        }
                      )
                    }
                  ) }),
                  /* @__PURE__ */ s("div", { className: "space-y-4", children: [
                    (ce === !0 || ne) && /* @__PURE__ */ a(H, { children: /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(
                      c,
                      {
                        label: "Location",
                        required: !0,
                        tooltip: "The OU level where users of this role perform their job function",
                        children: /* @__PURE__ */ a(
                          x,
                          {
                            id: "locationTypes",
                            control: r,
                            name: "locationTypes",
                            options: i.locationData,
                            value: E == null ? void 0 : E.map(
                              (e) => {
                                var t;
                                return (t = i.locationData) == null ? void 0 : t.find(
                                  (d) => d.type === (e == null ? void 0 : e.type)
                                );
                              }
                            ),
                            errors: m,
                            getOptionLabel: (e) => e == null ? void 0 : e.name,
                            dataTestId: "managerole-location-type-select",
                            checkEquality: "type",
                            onChange: (e, t) => I(e, t, "locationTypes")
                          }
                        )
                      }
                    ) }) }),
                    /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(
                      c,
                      {
                        label: "Can Manage Role",
                        tooltip: "Please select the roles that shall be managed by this role",
                        children: /* @__PURE__ */ a(
                          x,
                          {
                            name: "roleIds",
                            id: "roleIds",
                            errors: m,
                            control: r,
                            dataTestId: "managerole-manage-role-select",
                            options: i.roles,
                            onChange: (e, t) => I(e, t, "roleIds"),
                            getOptionLabel: (e) => e == null ? void 0 : e.name
                          }
                        )
                      }
                    ) }),
                    /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(
                      c,
                      {
                        label: "Managed From",
                        tooltip: "Please select the roles that can manage  this role",
                        children: /* @__PURE__ */ a(
                          x,
                          {
                            name: "canManageRoleIds",
                            id: "canManageRoleIds",
                            errors: m,
                            control: r,
                            dataTestId: "managerole-managed-by-role-select",
                            options: i.roles,
                            onChange: (e, t) => I(e, t, "canManageRoleIds"),
                            getOptionLabel: (e) => e == null ? void 0 : e.name
                          }
                        )
                      }
                    ) }),
                    /* @__PURE__ */ s("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
                      /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(
                        c,
                        {
                          label: "Role Type",
                          tooltip: "Please select Role Type",
                          required: !0,
                          children: /* @__PURE__ */ a(
                            Z,
                            {
                              control: r,
                              id: "roleType",
                              name: "roleType",
                              options: Ce,
                              displayName: "name",
                              optionValue: "name",
                              errors: m,
                              dataTestId: "managerole-role-type-dropdown"
                            }
                          )
                        }
                      ) }),
                      /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(
                        c,
                        {
                          label: "Can Manage Team",
                          tooltip: "Please select the teams that shall be managed by this role",
                          children: /* @__PURE__ */ a(
                            x,
                            {
                              control: r,
                              name: "manageByTeamTypeIds",
                              id: "manageByTeamTypeIds",
                              errors: m,
                              options: i.manageTeam,
                              dataTestId: "managerole-manage-team-select",
                              onChange: (e, t) => I(e, t, "manageByTeamTypeIds"),
                              getOptionLabel: (e) => e == null ? void 0 : e.type
                            }
                          )
                        }
                      ) })
                    ] }),
                    /* @__PURE__ */ a("div", { className: "space-y-4", children: /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(
                      c,
                      {
                        label: "Select Health Infrastructure type",
                        tooltip: "Please select the institute to be associated with the role",
                        required: me,
                        children: /* @__PURE__ */ a(
                          x,
                          {
                            options: i.healthInfraType,
                            errors: m,
                            name: "healthInfrastructureIds",
                            id: "healthInfrastructureIds",
                            dataTestId: "managerole-health-infrastructure-select",
                            control: r,
                            onChange: (e, t) => I(e, t, "healthInfrastructureIds"),
                            getOptionLabel: (e) => e == null ? void 0 : e.value
                          }
                        )
                      }
                    ) }) }),
                    !b.isBahaar && /* @__PURE__ */ a(H, { children: /* @__PURE__ */ a("div", { className: "space-y-4", children: /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(
                      c,
                      {
                        label: "Category",
                        tooltip: "Please select the category to be associated with the role",
                        children: /* @__PURE__ */ a(
                          x,
                          {
                            id: "categoryIds",
                            name: "categoryIds",
                            errors: m,
                            options: i.category,
                            dataTestId: "managerole-role-category-select",
                            control: r,
                            onChange: (e, t) => I(e, t, "categoryIds"),
                            getOptionLabel: (e) => e == null ? void 0 : e.value
                          }
                        )
                      }
                    ) }) }) })
                  ] }),
                  /* @__PURE__ */ s("div", { className: "flex items-center gap-6", children: [
                    /* @__PURE__ */ a(
                      y,
                      {
                        variant: "outlined",
                        className: "flex flex-row items-center w-[60%] ",
                        children: /* @__PURE__ */ a(
                          c,
                          {
                            label: "Bank Details Required",
                            tooltip: "Select if bank details are required for this role",
                            required: !0,
                            labelWidth: "50%",
                            childrenWidth: "50%",
                            direction: "row",
                            children: /* @__PURE__ */ a(
                              G,
                              {
                                control: r,
                                name: "isBankDetailsRequired",
                                options: [
                                  { label: "Yes", value: !0 },
                                  { label: "No", value: !1 }
                                ],
                                errors: m
                              }
                            )
                          }
                        )
                      }
                    ),
                    !f && /* @__PURE__ */ a(H, { children: /* @__PURE__ */ a(y, { variant: "outlined ", className: "w-[40%]", children: /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ a(
                      c,
                      {
                        label: "Self Manage",
                        labelWidth: "60%",
                        childrenWidth: "40%",
                        direction: "row",
                        children: /* @__PURE__ */ a(
                          $,
                          {
                            name: "canSelfManage",
                            control: r,
                            isFullWidth: !1,
                            "data-testid": "managerole-self-manage-checkbox"
                          }
                        )
                      }
                    ) }) }) })
                  ] }),
                  de && /* @__PURE__ */ s("div", { className: "flex items-center gap-6 w-full", children: [
                    /* @__PURE__ */ a(
                      y,
                      {
                        variant: "outlined",
                        className: "flex flex-row items-center w-[50%]",
                        children: /* @__PURE__ */ a(
                          c,
                          {
                            label: "Two-Factor Authentication",
                            tooltip: "Require users of this role to use a two-factor authentication app",
                            labelWidth: "60%",
                            childrenWidth: "40%",
                            direction: "row",
                            children: /* @__PURE__ */ a(
                              G,
                              {
                                control: r,
                                name: "isTwoFactorEnabled",
                                options: [
                                  { label: "Yes", value: !0 },
                                  { label: "No", value: !1 }
                                ],
                                errors: m
                              }
                            )
                          }
                        )
                      }
                    ),
                    ie === !0 && /* @__PURE__ */ a(y, { variant: "outlined", className: "w-[50%]", children: /* @__PURE__ */ a(
                      c,
                      {
                        label: "Authentication Method",
                        tooltip: "Select which authentication method users of this role will use",
                        children: /* @__PURE__ */ a(
                          Z,
                          {
                            control: r,
                            id: "twoFactorType",
                            name: "twoFactorType",
                            options: Se,
                            displayName: "label",
                            optionValue: "value",
                            errors: m,
                            dataTestId: "managerole-two-factor-type-dropdown"
                          }
                        )
                      }
                    ) })
                  ] }),
                  /* @__PURE__ */ a("div", { className: "flex items-center gap-6", children: /* @__PURE__ */ a(
                    y,
                    {
                      variant: "outlined",
                      className: "flex flex-col items-start  justify-between",
                      children: /* @__PURE__ */ a(
                        c,
                        {
                          label: "Mandatory Fields",
                          tooltip: "These fields are Mandatory when creating users of this role type",
                          children: /* @__PURE__ */ s(fe, { row: !0, children: [
                            P == null ? void 0 : P.map((e) => /* @__PURE__ */ a(
                              $,
                              {
                                control: r,
                                name: e.value,
                                label: e.label,
                                isFullWidth: !1,
                                "data-testid": `managerole-mandatory-field-${e.value}`
                              },
                              e.value
                            )),
                            re === !0 && /* @__PURE__ */ a(
                              $,
                              {
                                name: "isBankDetailsMandatory",
                                control: r,
                                label: "Bank Details",
                                isFullWidth: !1,
                                "data-testid": "managerole-bank-details-mandatory-checkbox"
                              }
                            )
                          ] })
                        }
                      )
                    }
                  ) }),
                  /* @__PURE__ */ s(
                    A,
                    {
                      className: "flex items-center justify-end gap-3 pt-6 border-t",
                      sx: { borderColor: "divider" },
                      children: [
                        /* @__PURE__ */ a(
                          Q,
                          {
                            variant: "contained",
                            color: "secondary",
                            size: "small",
                            onClick: k,
                            "data-testid": "managerole-close-button",
                            children: D("Close")
                          }
                        ),
                        /* @__PURE__ */ a(
                          Q,
                          {
                            variant: "contained",
                            color: "primary",
                            size: "small",
                            type: "submit",
                            "data-testid": "managerole-submit-button",
                            children: f ? `${D("Update Role")}` : `${D("Add Role")}`
                          }
                        )
                      ]
                    }
                  )
                ]
              }
            )
          ] })
        }
      ) })
    }
  );
};
qe.propTypes = {
  isUpdate: v.bool,
  role: v.object,
  onClose: v.func,
  open: v.bool,
  setOpen: v.func,
  selectedId: v.string,
  isRoleListModified: v.bool
};
export {
  qe as default
};
//# sourceMappingURL=ManageRole-Cbs9dUhc.js.map
