import { jsxs as s, jsx as a, Fragment as E } from "react/jsx-runtime";
import { useRef as K, useState as Y, useEffect as de } from "react";
import { Modal as ce, Box as j, IconButton as me, FormControl as v, FormGroup as ue, Button as X } from "@mui/material";
import he from "@/hooks/useTrackEvent";
import { g as ge, a as pe } from "./RoleManagement-C0feJCuq.js";
import { getRoleList as fe, getLocationTypes as ye, execute as O } from "@/common/services/GlobalApis";
import { showToast as W } from "@/common/toaster/toaster";
import { useForm as be } from "react-hook-form";
import { yupResolver as ve } from "@hookform/resolvers/yup";
import "@/assets/scss/scrollBar.scss";
import { FormItem as m } from "@/views/custom-components/FormItem.jsx";
import * as N from "yup";
import A from "@/views/custom-components/CustomTextField";
import Ne from "@/views/custom-components/CustomDropdown";
import $ from "@/views/custom-components/CustomCheckBox";
import w from "@/views/custom-components/CustomAutoComplete";
import { useTranslateProvider as Ie } from "@/common/languageTranslator/TranslationContext";
import { FontAwesomeIcon as xe } from "@fortawesome/react-fontawesome";
import { faXmark as we } from "@fortawesome/free-solid-svg-icons";
import f from "@/common/services/util/GeneralUtil";
import y from "prop-types";
import J from "@/views/custom-components/CustomToggleSwitch";
import { useSelector as Te } from "react-redux";
import { getUseSkeleton as Me } from "@/store/reducers/SkeletonReducer";
const Q = ({ children: I, isLoading: b }) => !Te(Me) || !b ? I : /* @__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" })
  ] })
] });
Q.propTypes = {
  children: y.any,
  isLoading: y.any
};
const Re = [{ name: "WEB" }, { name: "MOBILE" }, { name: "BOTH" }], Le = ({
  selectedId: I,
  isUpdate: b,
  open: L,
  setOpen: h,
  isRoleListModified: Z
}) => {
  const G = K(null), z = K(!1), _ = he(), [i, V] = Y({}), [ee, D] = Y(!1), ae = 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: f.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: d,
    handleSubmit: te,
    formState: { errors: u, isSubmitting: le },
    setValue: g,
    // getValues,
    watch: B,
    reset: se
  } = be({
    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,
      id: "",
      code: "",
      description: "",
      createdBy: "",
      state: "",
      createdOn: "",
      assignedFeatureList: "",
      assignedFeatures: "",
      isSmagTrainedMandatory: "",
      isLocationRequired: !0,
      isNodalMandatory: !1
    },
    resolver: ve(ae),
    mode: "onChange",
    shouldUnregister: !1
  }), ne = B("isBankDetailsRequired"), F = B("locationTypes"), { translate: P } = Ie(), re = B("isLocationRequired"), ie = B("isHealthInfraMandatory"), H = [
    { 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) => f.isTecho ? ![
    "isGeolocationMandatory",
    "isHealthInfraMandatory",
    "isLastNameMandatory",
    "isSmagTrainedMandatory"
  ].includes(e.value) : f.isSewaRural || f.isPhmp || f.isImomcare ? e.value !== "isNodalMandatory" : f.isEkavach ? ![
    "isGeolocationMandatory",
    "isHealthInfraMandatory",
    "isLastNameMandatory",
    "isNodalMandatory",
    "isSmagTrainedMandatory"
  ].includes(e.value) : !0), k = () => {
    h(0), se(), _("conversion_event", {
      form: G.current,
      form_name: "Manage Role",
      submit: z.current
    }), _("button_click", {
      button_name: "add role close button",
      button_type: "cancel",
      button_id: "managerole-close-button"
    });
  }, x = (e, t, o) => {
    g(o, t);
  }, oe = async (e) => {
    var t, o;
    try {
      _("button_click", {
        button_name: b ? "update role  button" : "add role  button",
        button_type: "submit",
        button_id: "managerole-add-button"
      }), delete e.bankDetailsRequired, delete e.bankDetailsMandatory, b || (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, await pe(e), W({
        type: "success",
        message: `Role ${b ? "Updated" : "Added"} Successfully`
      }), z.current = !0, k(), Z();
    } catch (l) {
      W({
        type: "error",
        message: `Role Cannot be added: ${(o = (t = l == null ? void 0 : l.response) == null ? void 0 : t.data) == null ? void 0 : o.message}`
      });
    }
  };
  return de(() => {
    (async () => {
      try {
        D((o) => !o);
        const t = f.getEnv();
        if (L !== 0) {
          const [o, l, q, C, S] = await Promise.all([
            fe(),
            ye(),
            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 (V((p) => {
            var T, M, R;
            return {
              ...p,
              roles: o.data,
              locationData: l.data,
              manageTeam: (T = q == null ? void 0 : q.data) == null ? void 0 : T.result,
              category: (M = C == null ? void 0 : C.data) == null ? void 0 : M.result,
              healthInfraType: (R = S == null ? void 0 : S.data) == null ? void 0 : R.result
            };
          }), I) {
            const { data: p } = await ge(I);
            V((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: T,
              healthInfrastructureIds: M,
              roleIds: R,
              categoryIds: U
            } = p;
            g(
              "manageByTeamTypeIds",
              T ? T.map(
                (n) => {
                  var c;
                  return (c = q.data.result) == null ? void 0 : c.find((r) => (r == null ? void 0 : r.id) === n);
                }
              ) : []
            ), g(
              "healthInfrastructureIds",
              M ? M.map(
                (n) => {
                  var c;
                  return (c = S.data.result) == null ? void 0 : c.find(
                    (r) => (r == null ? void 0 : r.id) === n
                  );
                }
              ).filter((n) => n !== void 0) : []
            ), g(
              "categoryIds",
              U ? U.map(
                (n) => {
                  var c;
                  return (c = C.data.result) == null ? void 0 : c.find((r) => (r == null ? void 0 : r.id) === n);
                }
              ) : []
            ), g(
              "roleIds",
              R ? R.map((n) => {
                var c;
                return (c = o.data) == null ? void 0 : c.find((r) => (r == null ? void 0 : r.id) === n);
              }).filter((n) => n !== void 0) : []
            ), g(
              "canManageRoleIds",
              p.canManageRoleIds ? p.canManageRoleIds.map((n) => {
                var c;
                return (c = o.data) == null ? void 0 : c.find((r) => (r == null ? void 0 : r.id) === n);
              }).filter((n) => n !== void 0) : []
            ), p.locationTypes.length > 0 ? g("isLocationRequired", !0) : g("isLocationRequired", !1);
          }
        }
        D((o) => !o);
      } catch (t) {
        W({
          message: `Error in manage role :${t == null ? void 0 : t.message}`,
          type: "error"
        }), D((o) => !o);
      }
    })();
  }, [I, L]), /* @__PURE__ */ a(
    ce,
    {
      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(
        j,
        {
          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(Q, { isLoading: ee, children: [
            /* @__PURE__ */ s("div", { className: "px-8 pt-8 pb-4 flex items-center justify-between", children: [
              /* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(
                j,
                {
                  component: "h2",
                  className: "text-2xl font-bold text-customBlue",
                  sx: { color: "text.primary" },
                  children: b ? "Update Role" : "Add New Role"
                }
              ) }),
              /* @__PURE__ */ a(
                me,
                {
                  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(xe, { icon: we, size: "lg" })
                }
              )
            ] }),
            /* @__PURE__ */ s(
              "form",
              {
                onSubmit: te(oe),
                ref: G,
                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(v, { variant: "outlined", children: /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(m, { label: "Role Name", children: /* @__PURE__ */ a(
                      A,
                      {
                        placeholder: "Role Name",
                        name: "name",
                        id: "name",
                        errors: u,
                        control: d,
                        dataTestId: "managerole-role-name-field"
                      }
                    ) }) }) }),
                    /* @__PURE__ */ a(v, { variant: "outlined", children: /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(
                      m,
                      {
                        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(
                          A,
                          {
                            name: "maxPosition",
                            id: "maxPosition",
                            errors: u,
                            control: d,
                            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"
                          }
                        )
                      }
                    ) }) }),
                    !f.isTecho && /* @__PURE__ */ a(v, { variant: "outlined", children: /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(m, { label: "Max Health Infrastructure", children: /* @__PURE__ */ a(
                      A,
                      {
                        name: "maxHealthInfra",
                        id: "maxHealthInfra",
                        control: d,
                        errors: u,
                        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(
                    v,
                    {
                      variant: "outlined",
                      className: "flex flex-row items-center w-full ",
                      children: /* @__PURE__ */ a(
                        m,
                        {
                          label: "Location Required",
                          required: !0,
                          direction: "row",
                          children: /* @__PURE__ */ a(
                            J,
                            {
                              control: d,
                              name: "isLocationRequired",
                              options: [
                                { label: "Yes", value: !0 },
                                { label: "No", value: !1 }
                              ],
                              errors: u
                            }
                          )
                        }
                      )
                    }
                  ) }),
                  /* @__PURE__ */ s("div", { className: "space-y-4", children: [
                    (re === !0 || le) && /* @__PURE__ */ a(E, { children: /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(
                      m,
                      {
                        label: "Location",
                        required: !0,
                        tooltip: "The OU level where users of this role perform their job function",
                        children: /* @__PURE__ */ a(
                          w,
                          {
                            id: "locationTypes",
                            control: d,
                            name: "locationTypes",
                            options: i.locationData,
                            value: F == null ? void 0 : F.map(
                              (e) => {
                                var t;
                                return (t = i.locationData) == null ? void 0 : t.find(
                                  (o) => o.type === (e == null ? void 0 : e.type)
                                );
                              }
                            ),
                            errors: u,
                            getOptionLabel: (e) => e == null ? void 0 : e.name,
                            dataTestId: "managerole-location-type-select",
                            checkEquality: "type",
                            onChange: (e, t) => x(e, t, "locationTypes")
                          }
                        )
                      }
                    ) }) }),
                    /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(
                      m,
                      {
                        label: "Can Manage Role",
                        tooltip: "Please select the roles that shall be managed by this role",
                        children: /* @__PURE__ */ a(
                          w,
                          {
                            name: "roleIds",
                            id: "roleIds",
                            errors: u,
                            control: d,
                            dataTestId: "managerole-manage-role-select",
                            options: i.roles,
                            onChange: (e, t) => x(e, t, "roleIds"),
                            getOptionLabel: (e) => e == null ? void 0 : e.name
                          }
                        )
                      }
                    ) }),
                    /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(
                      m,
                      {
                        label: "Managed From",
                        tooltip: "Please select the roles that can manage  this role",
                        children: /* @__PURE__ */ a(
                          w,
                          {
                            name: "canManageRoleIds",
                            id: "canManageRoleIds",
                            errors: u,
                            control: d,
                            dataTestId: "managerole-managed-by-role-select",
                            options: i.roles,
                            onChange: (e, t) => x(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(
                        m,
                        {
                          label: "Role Type",
                          tooltip: "Please select Role Type",
                          required: !0,
                          children: /* @__PURE__ */ a(
                            Ne,
                            {
                              control: d,
                              id: "roleType",
                              name: "roleType",
                              options: Re,
                              displayName: "name",
                              optionValue: "name",
                              errors: u,
                              dataTestId: "managerole-role-type-dropdown"
                            }
                          )
                        }
                      ) }),
                      /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(
                        m,
                        {
                          label: "Can Manage Team",
                          tooltip: "Please select the teams that shall be managed by this role",
                          children: /* @__PURE__ */ a(
                            w,
                            {
                              control: d,
                              name: "manageByTeamTypeIds",
                              id: "manageByTeamTypeIds",
                              errors: u,
                              options: i.manageTeam,
                              dataTestId: "managerole-manage-team-select",
                              onChange: (e, t) => x(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(
                      m,
                      {
                        label: "Select Health Infrastructure type",
                        tooltip: "Please select the institute to be associated with the role",
                        required: ie,
                        children: /* @__PURE__ */ a(
                          w,
                          {
                            options: i.healthInfraType,
                            errors: u,
                            name: "healthInfrastructureIds",
                            id: "healthInfrastructureIds",
                            dataTestId: "managerole-health-infrastructure-select",
                            control: d,
                            onChange: (e, t) => x(e, t, "healthInfrastructureIds"),
                            getOptionLabel: (e) => e == null ? void 0 : e.value
                          }
                        )
                      }
                    ) }) }),
                    !f.isBahaar && /* @__PURE__ */ a(E, { children: /* @__PURE__ */ a("div", { className: "space-y-4", children: /* @__PURE__ */ a("div", { className: "space-y-1.5", children: /* @__PURE__ */ a(
                      m,
                      {
                        label: "Category",
                        tooltip: "Please select the category to be associated with the role",
                        children: /* @__PURE__ */ a(
                          w,
                          {
                            id: "categoryIds",
                            name: "categoryIds",
                            errors: u,
                            options: i.category,
                            dataTestId: "managerole-role-category-select",
                            control: d,
                            onChange: (e, t) => x(e, t, "categoryIds"),
                            getOptionLabel: (e) => e == null ? void 0 : e.value
                          }
                        )
                      }
                    ) }) }) })
                  ] }),
                  /* @__PURE__ */ s("div", { className: "flex items-center gap-6", children: [
                    /* @__PURE__ */ a(
                      v,
                      {
                        variant: "outlined",
                        className: "flex flex-row items-center w-[60%] ",
                        children: /* @__PURE__ */ a(
                          m,
                          {
                            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(
                              J,
                              {
                                control: d,
                                name: "isBankDetailsRequired",
                                options: [
                                  { label: "Yes", value: !0 },
                                  { label: "No", value: !1 }
                                ],
                                errors: u
                              }
                            )
                          }
                        )
                      }
                    ),
                    !b && /* @__PURE__ */ a(E, { children: /* @__PURE__ */ a(v, { variant: "outlined ", className: "w-[40%]", children: /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ a(
                      m,
                      {
                        label: "Self Manage",
                        labelWidth: "60%",
                        childrenWidth: "40%",
                        direction: "row",
                        children: /* @__PURE__ */ a(
                          $,
                          {
                            name: "canSelfManage",
                            control: d,
                            isFullWidth: !1,
                            "data-testid": "managerole-self-manage-checkbox"
                          }
                        )
                      }
                    ) }) }) })
                  ] }),
                  /* @__PURE__ */ a("div", { className: "flex items-center gap-6", children: /* @__PURE__ */ a(
                    v,
                    {
                      variant: "outlined",
                      className: "flex flex-col items-start  justify-between",
                      children: /* @__PURE__ */ a(
                        m,
                        {
                          label: "Mandatory Fields",
                          tooltip: "These fields are Mandatory when creating users of this role type",
                          children: /* @__PURE__ */ s(ue, { row: !0, children: [
                            H == null ? void 0 : H.map((e) => /* @__PURE__ */ a(
                              $,
                              {
                                control: d,
                                name: e.value,
                                label: e.label,
                                isFullWidth: !1,
                                "data-testid": `managerole-mandatory-field-${e.value}`
                              },
                              e.value
                            )),
                            ne === !0 && /* @__PURE__ */ a(
                              $,
                              {
                                name: "isBankDetailsMandatory",
                                control: d,
                                label: "Bank Details",
                                isFullWidth: !1,
                                "data-testid": "managerole-bank-details-mandatory-checkbox"
                              }
                            )
                          ] })
                        }
                      )
                    }
                  ) }),
                  /* @__PURE__ */ s(
                    j,
                    {
                      className: "flex items-center justify-end gap-3 pt-6 border-t",
                      sx: { borderColor: "divider" },
                      children: [
                        /* @__PURE__ */ a(
                          X,
                          {
                            variant: "contained",
                            color: "secondary",
                            size: "small",
                            onClick: k,
                            "data-testid": "managerole-close-button",
                            children: P("Close")
                          }
                        ),
                        /* @__PURE__ */ a(
                          X,
                          {
                            variant: "contained",
                            color: "primary",
                            size: "small",
                            type: "submit",
                            "data-testid": "managerole-submit-button",
                            children: b ? `${P("Update Role")}` : `${P("Add Role")}`
                          }
                        )
                      ]
                    }
                  )
                ]
              }
            )
          ] })
        }
      ) })
    }
  );
};
Le.propTypes = {
  isUpdate: y.bool,
  role: y.object,
  onClose: y.func,
  open: y.bool,
  setOpen: y.func,
  selectedId: y.string,
  isRoleListModified: y.bool
};
export {
  Le as default
};
//# sourceMappingURL=ManageRole-CuXmWQyp.js.map
