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