@argusoft/medplat-form-engine 1.0.15 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/AccessRights-BMRM1u9S-D1Gc0rKI.js +1228 -0
  2. package/dist/AccessRights-BMRM1u9S-D1Gc0rKI.js.map +1 -0
  3. package/dist/AddEditQueryBuilder-7JRplV5J-DHgS6TYG.js +313 -0
  4. package/dist/AddEditQueryBuilder-7JRplV5J-DHgS6TYG.js.map +1 -0
  5. package/dist/AddEditQueryBuilder-7JRplV5J.css +1 -0
  6. package/dist/AddFeatures-CkTu7sOI-BGplSFp6.js +212 -0
  7. package/dist/AddFeatures-CkTu7sOI-BGplSFp6.js.map +1 -0
  8. package/dist/AddLabelModal-DE3ploGD-OOyaGC02.js +734 -0
  9. package/dist/AddLabelModal-DE3ploGD-OOyaGC02.js.map +1 -0
  10. package/dist/AddMenuConfiguration-QWfpcnuP-TAM2c68S.js +5389 -0
  11. package/dist/AddMenuConfiguration-QWfpcnuP-TAM2c68S.js.map +1 -0
  12. package/dist/AddMenuConfiguration-QWfpcnuP.css +1 -0
  13. package/dist/AddRoleDrawer-ZK1eejxI-BM6rfhh5.js +453 -0
  14. package/dist/AddRoleDrawer-ZK1eejxI-BM6rfhh5.js.map +1 -0
  15. package/dist/AppModal-BgZyfrd--BO3wW4ma.js +428 -0
  16. package/dist/AppModal-BgZyfrd--BO3wW4ma.js.map +1 -0
  17. package/dist/ChangePasswordModalCore-DIe4rzW--Dz71RCI6.js +176 -0
  18. package/dist/ChangePasswordModalCore-DIe4rzW--Dz71RCI6.js.map +1 -0
  19. package/dist/ConditionConfig-GDCXIg3C-DuEy85LD.js +395 -0
  20. package/dist/ConditionConfig-GDCXIg3C-DuEy85LD.js.map +1 -0
  21. package/dist/ConditionConfig-GDCXIg3C.css +1 -0
  22. package/dist/EntityManagement-D-x6Qzal-BE01iKNR.js +50 -0
  23. package/dist/EntityManagement-D-x6Qzal-BE01iKNR.js.map +1 -0
  24. package/dist/EventConfigurations-jGCJ4LqP-CJBCGp6J.js +384 -0
  25. package/dist/EventConfigurations-jGCJ4LqP-CJBCGp6J.js.map +1 -0
  26. package/dist/EventConfigurations-jGCJ4LqP.css +1 -0
  27. package/dist/EventsExceptionModal-BF6E1Np7-DHT7pQsx.js +200 -0
  28. package/dist/EventsExceptionModal-BF6E1Np7-DHT7pQsx.js.map +1 -0
  29. package/dist/EventsSkeleton-BN7_0IGs-BAnd1Vug.js +74 -0
  30. package/dist/EventsSkeleton-BN7_0IGs-BAnd1Vug.js.map +1 -0
  31. package/dist/FeatureMenu-Ds6lFg4w-ShGx4okQ.js +249 -0
  32. package/dist/FeatureMenu-Ds6lFg4w-ShGx4okQ.js.map +1 -0
  33. package/dist/Features-Cshdl06N-CZ02Tt89.js +12 -0
  34. package/dist/Features-Cshdl06N-CZ02Tt89.js.map +1 -0
  35. package/dist/FileSaver.min-CN9EpL2h-N-3OFAd7.js +77 -0
  36. package/dist/FileSaver.min-CN9EpL2h-N-3OFAd7.js.map +1 -0
  37. package/dist/FlywayQuery-Cx2sly6g-DdhUw6bN.js +169 -0
  38. package/dist/FlywayQuery-Cx2sly6g-DdhUw6bN.js.map +1 -0
  39. package/dist/ImmunizationConfigurationBase-DZ8EqXlF-B4x4_1v0.js +5162 -0
  40. package/dist/ImmunizationConfigurationBase-DZ8EqXlF-B4x4_1v0.js.map +1 -0
  41. package/dist/ImmunizationConfigurationBase-DZ8EqXlF.css +1 -0
  42. package/dist/ImmunizationConfigurationsList-CQnxWa09-Bbr0iyGy.js +335 -0
  43. package/dist/ImmunizationConfigurationsList-CQnxWa09-Bbr0iyGy.js.map +1 -0
  44. package/dist/ImmunizationSkeleton-D2tdv5k--B7SY-gnr.js +186 -0
  45. package/dist/ImmunizationSkeleton-D2tdv5k--B7SY-gnr.js.map +1 -0
  46. package/dist/LanguagesModal-rk6IGQwY-B0Jtpivu.js +394 -0
  47. package/dist/LanguagesModal-rk6IGQwY-B0Jtpivu.js.map +1 -0
  48. package/dist/ManageDynamicFeature-C2I7Ho7i-Bbxkpw0S.js +4189 -0
  49. package/dist/ManageDynamicFeature-C2I7Ho7i-Bbxkpw0S.js.map +1 -0
  50. package/dist/ManageEventConfiguration-BJxS2Su0-CRATBMym.js +1017 -0
  51. package/dist/ManageEventConfiguration-BJxS2Su0-CRATBMym.js.map +1 -0
  52. package/dist/ManageEventConfiguration-BJxS2Su0.css +1 -0
  53. package/dist/ManageNotification-DMN2szWy-DQvdrfwC.js +6819 -0
  54. package/dist/ManageNotification-DMN2szWy-DQvdrfwC.js.map +1 -0
  55. package/dist/ManageRole-CuXmWQyp-Cy15Mlax.js +728 -0
  56. package/dist/ManageRole-CuXmWQyp-Cy15Mlax.js.map +1 -0
  57. package/dist/ManageTranslation-BTxvSYKb-CdO4Fk7f.js +616 -0
  58. package/dist/ManageTranslation-BTxvSYKb-CdO4Fk7f.js.map +1 -0
  59. package/dist/ManageTranslation-BTxvSYKb.css +1 -0
  60. package/dist/ManageUser-Dr3ptCYp-CzLX1rCi.js +2179 -0
  61. package/dist/ManageUser-Dr3ptCYp-CzLX1rCi.js.map +1 -0
  62. package/dist/ManageUser-Dr3ptCYp.css +1 -0
  63. package/dist/MedplatFormWrapper-CfKQpZOJ.js +52228 -0
  64. package/dist/MedplatFormWrapper-CfKQpZOJ.js.map +1 -0
  65. package/dist/MedplatFormWrapper.css +1 -0
  66. package/dist/MobileMenuManagement-BmrO-7MN-xFkU87j6.js +111 -0
  67. package/dist/MobileMenuManagement-BmrO-7MN-xFkU87j6.js.map +1 -0
  68. package/dist/MobileTypeEventConfigModal-ChhO_A4f-DfJDqFB9.js +783 -0
  69. package/dist/MobileTypeEventConfigModal-ChhO_A4f-DfJDqFB9.js.map +1 -0
  70. package/dist/NewServerManagement-5YcAtF-g-DHV6PFTR.js +1002 -0
  71. package/dist/NewServerManagement-5YcAtF-g-DHV6PFTR.js.map +1 -0
  72. package/dist/NotificationFlywayQuery-BY8Zzml_-C7G-28dx.js +244 -0
  73. package/dist/NotificationFlywayQuery-BY8Zzml_-C7G-28dx.js.map +1 -0
  74. package/dist/NotificationList-BqibwMaM-D4mMbj4h.js +400 -0
  75. package/dist/NotificationList-BqibwMaM-D4mMbj4h.js.map +1 -0
  76. package/dist/OtherTypeEventConfigModal-ZnCGWm9v-D7x0QObl.js +1953 -0
  77. package/dist/OtherTypeEventConfigModal-ZnCGWm9v-D7x0QObl.js.map +1 -0
  78. package/dist/QueryBuilder-BPfavHH9-M3wgeHB3.js +378 -0
  79. package/dist/QueryBuilder-BPfavHH9-M3wgeHB3.js.map +1 -0
  80. package/dist/QueryBuilder-BPfavHH9.css +1 -0
  81. package/dist/QueryManagement-DXA73N2j-C2RCVmd2.js +671 -0
  82. package/dist/QueryManagement-DXA73N2j-C2RCVmd2.js.map +1 -0
  83. package/dist/QueryManagement-DXA73N2j.css +1 -0
  84. package/dist/RoleManagement-C0feJCuq-DIGwGqOD.js +410 -0
  85. package/dist/RoleManagement-C0feJCuq-DIGwGqOD.js.map +1 -0
  86. package/dist/SecurityAuditLogList-DHTcOtbx-VvwDlRuu.js +746 -0
  87. package/dist/SecurityAuditLogList-DHTcOtbx-VvwDlRuu.js.map +1 -0
  88. package/dist/ServerSyncModal-D_oFpv3C-C6c3_3lx.js +836 -0
  89. package/dist/ServerSyncModal-D_oFpv3C-C6c3_3lx.js.map +1 -0
  90. package/dist/ShowFlywayQuery-BkyA6QaA-2t9pZjcx.js +130 -0
  91. package/dist/ShowFlywayQuery-BkyA6QaA-2t9pZjcx.js.map +1 -0
  92. package/dist/ShowFlywayQuery-DVRCd384-BypXcNWX.js +259 -0
  93. package/dist/ShowFlywayQuery-DVRCd384-BypXcNWX.js.map +1 -0
  94. package/dist/ShowQueryHistory-BDN0tzHg-17BxK88Z.js +190 -0
  95. package/dist/ShowQueryHistory-BDN0tzHg-17BxK88Z.js.map +1 -0
  96. package/dist/SubMenu-DAfZC9Xi-B0BQYLdI.js +188 -0
  97. package/dist/SubMenu-DAfZC9Xi-B0BQYLdI.js.map +1 -0
  98. package/dist/TableDetails-DzREeJkm-B-WEBbQz.js +1508 -0
  99. package/dist/TableDetails-DzREeJkm-B-WEBbQz.js.map +1 -0
  100. package/dist/TableList-B9hr05Hs-BIsMbnIV.js +428 -0
  101. package/dist/TableList-B9hr05Hs-BIsMbnIV.js.map +1 -0
  102. package/dist/TypeConfiguration-C-lk8Szs-DkvHWHhr.js +117 -0
  103. package/dist/TypeConfiguration-C-lk8Szs-DkvHWHhr.js.map +1 -0
  104. package/dist/UserList-S5Q76wO7-Cj5u_K4_.js +1104 -0
  105. package/dist/UserList-S5Q76wO7-Cj5u_K4_.js.map +1 -0
  106. package/dist/UserList-S5Q76wO7.css +1 -0
  107. package/dist/UserListSkeleton-cglK2SaU-B_Tj5gUp.js +184 -0
  108. package/dist/UserListSkeleton-cglK2SaU-B_Tj5gUp.js.map +1 -0
  109. package/dist/WidgetList-BSApErov-Z61Kpq4T.js +188 -0
  110. package/dist/WidgetList-BSApErov-Z61Kpq4T.js.map +1 -0
  111. package/dist/_commonjsHelpers-B4e78b8K-B9tZyK9c.js +29 -0
  112. package/dist/_commonjsHelpers-B4e78b8K-B9tZyK9c.js.map +1 -0
  113. package/dist/default-DlLB_mdl.js +11341 -0
  114. package/dist/default-DlLB_mdl.js.map +1 -0
  115. package/dist/default.css +1 -0
  116. package/dist/i18next-CTOWN_jH-BKKbdDel.js +1389 -0
  117. package/dist/i18next-CTOWN_jH-BKKbdDel.js.map +1 -0
  118. package/dist/index-B4r0wjBD.js +563 -0
  119. package/dist/index-B4r0wjBD.js.map +1 -0
  120. package/dist/index-BFznsakV-CzCTrTvj.js +42638 -0
  121. package/dist/index-BFznsakV-CzCTrTvj.js.map +1 -0
  122. package/dist/index-Dta_LKti.js +744 -0
  123. package/dist/index-Dta_LKti.js.map +1 -0
  124. package/dist/index.css +1 -1
  125. package/dist/index.js +6 -52390
  126. package/dist/index.js.map +1 -1
  127. package/dist/manageImmunization-B4swS745-JldexHrO.js +1204 -0
  128. package/dist/manageImmunization-B4swS745-JldexHrO.js.map +1 -0
  129. package/dist/manageImmunization-B4swS745.css +1 -0
  130. package/dist/xlsx.min-D1LFqt_b-BGwkpd8r.js +11869 -0
  131. package/dist/xlsx.min-D1LFqt_b-BGwkpd8r.js.map +1 -0
  132. package/package.json +1 -4
@@ -0,0 +1,4189 @@
1
+ import { jsx as i, jsxs as l, Fragment as me } from "react/jsx-runtime";
2
+ import { execute as J, executeAll as Ei } from "@/common/services/QueryBuilder";
3
+ import { useDebounceFn as cn } from "@/hooks/useDebounceFn.js";
4
+ import Ve from "@/views/custom-components/CustomDropdown";
5
+ import Mt from "@/views/custom-components/CustomSvgUpload";
6
+ import ee from "@/views/custom-components/CustomTextField";
7
+ import { yupResolver as Nn } from "@hookform/resolvers/yup";
8
+ import { d as Lt } from "./index-B4r0wjBD.js";
9
+ import { generateUUID as mn } from "@/utils/UUIDgenerator";
10
+ import { getRoleList as $t, executeQuery as Jt } from "@/common/services/GlobalApis";
11
+ import { useTheme as kn, debounce as jt, Box as d, Step as Qt, Typography as m, FormControl as K, Accordion as Di, AccordionSummary as Fi, AccordionDetails as Vi, Tooltip as Gt, RadioGroup as pn, FormControlLabel as si, Radio as di, Divider as Ye, Button as O, Checkbox as fn, FormGroup as Ht, TextField as In, TableContainer as hn, Table as gn, TableHead as yn, TableRow as ui, TableCell as Y, TableBody as bn, IconButton as Ue, Dialog as Tn, DialogTitle as _n, DialogContent as Dn, DialogContentText as Zt, Grid2 as be, Chip as ci, Alert as Yt, DialogActions as Fn, Stack as Vn, Select as Xt, MenuItem as vn, Modal as Kt, Card as er, alpha as ir } from "@mui/material";
12
+ import j from "@mui/material/Grid2";
13
+ import { D as mi } from "./i18next-CTOWN_jH-BKKbdDel.js";
14
+ import nr, { useRef as tr, useMemo as xn, useState as g, useEffect as ne, useCallback as rr } from "react";
15
+ import { useForm as fi, useWatch as pi, Controller as M } from "react-hook-form";
16
+ import { useSelector as ar } from "react-redux";
17
+ import { useLocation as lr, useNavigate as or } from "react-router";
18
+ import * as B from "yup";
19
+ import { showToast as ce } from "@/common/toaster/toaster";
20
+ import { FormConfiguratorService as Cn } from "@/common/services/FormConfiguratorService";
21
+ import w from "prop-types";
22
+ import { useDebounceFn as sr } from "@/hooks/useDebounceFn";
23
+ import oe from "@/common/fontAwesomeIcons/FontAwesomeIcons";
24
+ import Pe from "@/views/custom-components/CustomAutoComplete.jsx";
25
+ import { o as Sn, u as dr, c as ur } from "./Features-Cshdl06N-CZ02Tt89.js";
26
+ import ke from "@/views/custom-components/CustomSwitch";
27
+ import cr from "@/views/custom-components/CustomTextArea";
28
+ import Pi from "@/views/custom-components/CustomCheckBox";
29
+ import wn from "@/views/custom-components/CustomDatePicker";
30
+ import ge from "@/views/custom-components/FieldDescription";
31
+ import { useTranslateProvider as mr } from "@/common/languageTranslator/TranslationContext";
32
+ import pr from "@/views/custom-components/CustomRadioComponent";
33
+ function Pn({
34
+ mainFormCtrl: _,
35
+ openAddFormModal: q,
36
+ setModal: E,
37
+ reloadForms: P
38
+ }) {
39
+ const [h, I] = g(""), [S, X] = g([]), [se, Q] = g(!0), U = B.object().shape({
40
+ formName: B.string().required("Enter form name"),
41
+ formCode: B.string().required("Enter form code").matches(
42
+ /^[A-Z_]*$/,
43
+ "Only uppercase letters and underscores are allowed"
44
+ ),
45
+ state: B.string().required("Select state"),
46
+ formType: B.string().required("Select form type"),
47
+ description: B.string().required("Enter description")
48
+ }), u = fi({
49
+ defaultValues: {
50
+ formName: "",
51
+ formCode: "",
52
+ state: "ACTIVE",
53
+ description: "",
54
+ menuConfigId: null,
55
+ pageParams: "",
56
+ formType: null,
57
+ navigationState: "medplat.form"
58
+ },
59
+ resolver: Nn(U),
60
+ mode: "onChange"
61
+ }), te = () => {
62
+ if (h.trim() && !S.includes(h)) {
63
+ const C = [...S, h];
64
+ X(C), I(""), u.setValue("pageParams", C.join(","));
65
+ }
66
+ }, ye = (C) => {
67
+ const k = S.filter((G) => G !== C);
68
+ X(k), u.setValue("pageParams", k.join(","));
69
+ }, W = (C) => {
70
+ const k = C.target.value;
71
+ /^[a-zA-Z_]*$/.test(k) && I(k);
72
+ }, T = () => {
73
+ E(!1);
74
+ }, x = (C) => {
75
+ de(C);
76
+ }, de = (C) => {
77
+ if (!se) {
78
+ ce({ message: "Form Code is already taken!", type: "error" });
79
+ return;
80
+ }
81
+ const k = () => {
82
+ const G = new FormData();
83
+ return G.append(
84
+ "form",
85
+ new Blob([JSON.stringify(C)], {
86
+ type: "application/json"
87
+ })
88
+ ), console.log(G), G;
89
+ };
90
+ C.isSeparateFeature = !0, Cn.saveForm(k()).then(() => {
91
+ ce({
92
+ message: "Configuration created sucessfully!",
93
+ type: "success"
94
+ });
95
+ let G = [];
96
+ C.formName && C.formName.length > 0 && G.push({
97
+ code: "medplat_form_insert_into_translation_master",
98
+ parameters: {
99
+ translation_key: C.formName.replaceAll(" ", ""),
100
+ translation_value: C.formName,
101
+ form_code: C.formCode
102
+ },
103
+ sequence: 1
104
+ }), G.length > 0 && Ei(G), _.setValue("formCode", C.formCode), _.setValue("version", "DRAFT"), _.setValue("navigationState", C.navigationState), T(), u.reset({
105
+ formName: "",
106
+ formCode: "",
107
+ state: "ACTIVE",
108
+ description: "",
109
+ menuConfigId: null,
110
+ pageParams: "",
111
+ formType: null,
112
+ navigationState: "medplat.form"
113
+ }), P();
114
+ });
115
+ }, pe = sr(async (C) => {
116
+ if (!(C != null && C.trim())) return;
117
+ const k = (await Cn.checkFormCodeAvailability(C)).data;
118
+ return Q(k), k;
119
+ }, 500);
120
+ return /* @__PURE__ */ i(
121
+ Tn,
122
+ {
123
+ open: q,
124
+ fullWidth: !0,
125
+ maxWidth: "lg",
126
+ onClose: T,
127
+ slotProps: {
128
+ paper: {
129
+ style: {
130
+ borderRadius: "8px"
131
+ }
132
+ }
133
+ },
134
+ children: /* @__PURE__ */ l(
135
+ "form",
136
+ {
137
+ noValidate: !0,
138
+ onSubmit: (C) => {
139
+ C.preventDefault(), C.stopPropagation(), u.handleSubmit(x)();
140
+ },
141
+ children: [
142
+ /* @__PURE__ */ i(_n, { children: "Add new form" }),
143
+ /* @__PURE__ */ l(Dn, { children: [
144
+ /* @__PURE__ */ i(Zt, { id: "alert-dialog-slide-description", children: "Please enter all details" }),
145
+ /* @__PURE__ */ l(be, { container: !0, spacing: 2, columns: 12, sx: { mt: 1 }, children: [
146
+ /* @__PURE__ */ i(be, { size: 12, children: /* @__PURE__ */ i(Ye, { children: /* @__PURE__ */ i(ci, { label: "Basic Details", size: "small" }) }) }),
147
+ /* @__PURE__ */ i(be, { size: 4, children: /* @__PURE__ */ i(
148
+ ee,
149
+ {
150
+ control: u.control,
151
+ name: "formName",
152
+ id: "formName",
153
+ fullWidth: !0,
154
+ size: "small",
155
+ label: "Name",
156
+ errors: u.formState.errors,
157
+ required: !0
158
+ }
159
+ ) }),
160
+ /* @__PURE__ */ i(be, { size: 4, children: /* @__PURE__ */ i(
161
+ ee,
162
+ {
163
+ control: u.control,
164
+ name: "formCode",
165
+ id: "formCode",
166
+ fullWidth: !0,
167
+ size: "small",
168
+ label: "Code",
169
+ errors: {
170
+ ...u.formState.errors,
171
+ ...se === !1 && {
172
+ formCode: { message: "Form Code is already taken!" }
173
+ }
174
+ },
175
+ required: !0,
176
+ onChange: (C) => {
177
+ const k = C.target.value.toUpperCase().replace(/[^A-Z_]/g, "");
178
+ u.setValue("formCode", k), u.setValue(
179
+ "navigationState",
180
+ `medplat.form.${k}`
181
+ ), pe(k);
182
+ }
183
+ }
184
+ ) }),
185
+ /* @__PURE__ */ i(be, { size: 2, children: /* @__PURE__ */ i(K, { required: !0, fullWidth: !0, size: "small", children: /* @__PURE__ */ i(
186
+ Ve,
187
+ {
188
+ control: u.control,
189
+ name: "state",
190
+ id: "state",
191
+ options: ["ACTIVE", "INACTIVE"],
192
+ errors: u.formState.errors,
193
+ size: "small",
194
+ placeholder: "",
195
+ label: "State",
196
+ required: !0
197
+ }
198
+ ) }) }),
199
+ /* @__PURE__ */ i(be, { size: 2, children: /* @__PURE__ */ i(K, { required: !0, fullWidth: !0, size: "small", children: /* @__PURE__ */ i(
200
+ Ve,
201
+ {
202
+ control: u.control,
203
+ name: "formType",
204
+ id: "formType",
205
+ options: ["FORM", "SEARCH", "WRAPPER"],
206
+ errors: u.formState.errors,
207
+ size: "small",
208
+ placeholder: "",
209
+ label: "Type",
210
+ required: !0
211
+ }
212
+ ) }) }),
213
+ /* @__PURE__ */ i(be, { size: 12, children: /* @__PURE__ */ i(
214
+ ee,
215
+ {
216
+ control: u.control,
217
+ name: "description",
218
+ id: "description",
219
+ fullWidth: !0,
220
+ multiline: !0,
221
+ rows: 2,
222
+ size: "small",
223
+ label: "Description",
224
+ errors: u.formState.errors,
225
+ required: !0
226
+ }
227
+ ) }),
228
+ /* @__PURE__ */ i(be, { size: 12, children: /* @__PURE__ */ i(Ye, { children: /* @__PURE__ */ i(ci, { label: "Page Param Details", size: "small" }) }) }),
229
+ /* @__PURE__ */ l(be, { size: 12, children: [
230
+ /* @__PURE__ */ i(
231
+ M,
232
+ {
233
+ name: "pageParams",
234
+ control: u.control,
235
+ render: ({ field: C }) => /* @__PURE__ */ i(
236
+ In,
237
+ {
238
+ ...C,
239
+ label: "Page Params",
240
+ size: "small",
241
+ placeholder: "Add Page Params",
242
+ value: h,
243
+ onChange: W,
244
+ onKeyDown: (k) => {
245
+ k.key === "Enter" && (k.preventDefault(), te());
246
+ },
247
+ fullWidth: !0,
248
+ slotProps: {
249
+ input: {
250
+ endAdornment: /* @__PURE__ */ i(Ue, { color: "primary", onClick: te, children: /* @__PURE__ */ i(
251
+ oe,
252
+ {
253
+ iconName: "faArrowRightToBracket",
254
+ size: "xs"
255
+ }
256
+ ) })
257
+ }
258
+ }
259
+ }
260
+ )
261
+ }
262
+ ),
263
+ /* @__PURE__ */ i(d, { sx: { display: "flex", flexWrap: "wrap", gap: 1, mt: 2 }, children: S.map((C, k) => /* @__PURE__ */ i(
264
+ ci,
265
+ {
266
+ label: C,
267
+ onDelete: () => ye(C),
268
+ color: "primary"
269
+ },
270
+ k + 1
271
+ )) }),
272
+ S.length === 0 && /* @__PURE__ */ i(Yt, { severity: "info", variant: "outlined", children: "No page params added" })
273
+ ] }),
274
+ ["FORM", "SEARCH"].includes(u.getValues("formType")) && /* @__PURE__ */ l(me, { children: [
275
+ /* @__PURE__ */ i(be, { size: 12, children: /* @__PURE__ */ i(Ye, { children: /* @__PURE__ */ i(ci, { label: "Route Details", size: "small" }) }) }),
276
+ /* @__PURE__ */ i(
277
+ ee,
278
+ {
279
+ control: u.control,
280
+ name: "navigationState",
281
+ id: "navigationState",
282
+ fullWidth: !0,
283
+ size: "small",
284
+ label: "Navigation State",
285
+ errors: u.formState.errors,
286
+ disabled: !0
287
+ }
288
+ )
289
+ ] })
290
+ ] })
291
+ ] }),
292
+ /* @__PURE__ */ l(Fn, { children: [
293
+ /* @__PURE__ */ i(O, { type: "submit", color: "success", children: "Create" }),
294
+ /* @__PURE__ */ i(O, { onClick: T, children: "Close" })
295
+ ] })
296
+ ]
297
+ }
298
+ )
299
+ }
300
+ );
301
+ }
302
+ Pn.propTypes = {
303
+ mainFormCtrl: w.any,
304
+ openAddFormModal: w.any,
305
+ setModal: w.any,
306
+ reloadForms: w.any
307
+ };
308
+ const Wi = ({
309
+ permission: _,
310
+ index: q,
311
+ depth: E = 0,
312
+ onEdit: P,
313
+ onRemove: h,
314
+ handleAddChildClick: I,
315
+ isLastChild: S = !1,
316
+ isDynamicFeature: X
317
+ }) => {
318
+ var se;
319
+ const Q = kn(), U = (u) => u.replaceAll(".child.", ".");
320
+ return /* @__PURE__ */ l(d, { sx: { position: "relative", pl: E * 3 }, children: [
321
+ E > 0 && /* @__PURE__ */ l(me, { children: [
322
+ /* @__PURE__ */ i(
323
+ d,
324
+ {
325
+ sx: {
326
+ position: "absolute",
327
+ left: 16,
328
+ top: 0,
329
+ bottom: S ? "50%" : 0,
330
+ width: 2,
331
+ bgcolor: Q.palette.divider
332
+ }
333
+ }
334
+ ),
335
+ /* @__PURE__ */ i(
336
+ d,
337
+ {
338
+ sx: {
339
+ position: "absolute",
340
+ left: 16,
341
+ top: 22,
342
+ width: 24,
343
+ height: 2,
344
+ bgcolor: Q.palette.divider
345
+ }
346
+ }
347
+ )
348
+ ] }),
349
+ /* @__PURE__ */ l(
350
+ d,
351
+ {
352
+ sx: {
353
+ display: "flex",
354
+ alignItems: "center",
355
+ gap: 1.5,
356
+ border: `1px solid ${Q.palette.divider}`,
357
+ borderRadius: 2,
358
+ padding: "8px 12px",
359
+ backgroundColor: E === 0 ? Q.palette.background.paper : ir(Q.palette.background.paper, 0.8),
360
+ ml: E > 0 ? 3 : 0,
361
+ position: "relative"
362
+ },
363
+ children: [
364
+ E === 0 && /* @__PURE__ */ l(m, { sx: { width: 24, color: "text.secondary" }, children: [
365
+ q + 1,
366
+ "."
367
+ ] }),
368
+ /* @__PURE__ */ i(m, { sx: { flexGrow: 1, fontWeight: 500 }, children: U(_.permissionId) }),
369
+ E === 0 && /* @__PURE__ */ i(
370
+ O,
371
+ {
372
+ variant: "outlined",
373
+ size: "small",
374
+ startIcon: /* @__PURE__ */ i(oe, { iconName: "faPlus" }),
375
+ onClick: () => I(_),
376
+ children: "Add Child"
377
+ }
378
+ ),
379
+ (!_.isDefault || _.isDefault && !X) && /* @__PURE__ */ i(
380
+ Ue,
381
+ {
382
+ color: "secondary",
383
+ onClick: () => P(_, q),
384
+ children: /* @__PURE__ */ i(oe, { iconName: "faEdit", size: "sm" })
385
+ }
386
+ ),
387
+ !_.isDefault && /* @__PURE__ */ i(Ue, { color: "error", onClick: () => h(_), children: /* @__PURE__ */ i(oe, { iconName: "faTrash", size: "sm" }) })
388
+ ]
389
+ }
390
+ ),
391
+ ((se = _.childPermissions) == null ? void 0 : se.length) > 0 && /* @__PURE__ */ i(Vn, { spacing: 1, sx: { mt: 1 }, children: _.childPermissions.map((u, te) => /* @__PURE__ */ i(
392
+ Wi,
393
+ {
394
+ permission: u,
395
+ index: te,
396
+ depth: E + 1,
397
+ onEdit: P,
398
+ onRemove: h,
399
+ handleAddChildClick: I,
400
+ isLastChild: te === _.childPermissions.length - 1,
401
+ isDynamicFeature: X
402
+ },
403
+ te
404
+ )) })
405
+ ] });
406
+ }, En = ({
407
+ permissions: _,
408
+ onEdit: q,
409
+ onRemove: E,
410
+ handleAddChildClick: P,
411
+ isDynamicFeature: h
412
+ }) => /* @__PURE__ */ i(Vn, { spacing: 1, children: _.map((I, S) => /* @__PURE__ */ i(
413
+ Wi,
414
+ {
415
+ permission: I,
416
+ index: S,
417
+ depth: 0,
418
+ onEdit: q,
419
+ onRemove: E,
420
+ handleAddChildClick: P,
421
+ isLastChild: S === _.length - 1,
422
+ isDynamicFeature: h
423
+ },
424
+ S
425
+ )) }), Wn = ({
426
+ open: _,
427
+ onClose: q,
428
+ onSave: E,
429
+ formCtrl: P,
430
+ editData: h,
431
+ parentPermissionId: I = null,
432
+ mode: S = "add-parent",
433
+ permissionTypes: X,
434
+ setPermissionTypes: se,
435
+ existingPermissionIds: Q,
436
+ isDynamicFeature: U = !0
437
+ }) => {
438
+ var u, te, ye;
439
+ const [W, T] = g(""), [x, de] = g([]), [pe, C] = g(""), k = {
440
+ permissionType: "",
441
+ permissionId: "--",
442
+ permissionName: "",
443
+ permissionDesc: "",
444
+ enabled: !0,
445
+ permissionSuffix: "",
446
+ parentPermissionSuffix: ""
447
+ }, G = {
448
+ backendUrl: "",
449
+ urlType: "",
450
+ queryCodeRequired: h ? (u = h == null ? void 0 : h.backendUrl) != null && u.trim() && (te = h == null ? void 0 : h.urlType) != null && te.trim() ? !1 : (ye = h == null ? void 0 : h.queryCode) != null && ye.trim() ? !0 : void 0 : void 0,
451
+ queryCode: ""
452
+ }, hi = U ? k : { ...k, ...G }, {
453
+ control: A,
454
+ watch: ue,
455
+ handleSubmit: gi,
456
+ reset: Se,
457
+ setValue: L,
458
+ getValues: ve,
459
+ setError: xe,
460
+ clearErrors: Ie,
461
+ formState: Te
462
+ } = fi({
463
+ mode: "onChange",
464
+ defaultValues: hi
465
+ }), $ = ue("queryCodeRequired"), z = ue("permissionType"), Ee = ue("permissionSuffix"), We = ue("backendUrl"), qe = ue("queryCode"), ze = [
466
+ { label: "Query", value: !0 },
467
+ { label: "API", value: !1 }
468
+ ], Me = (f = {}) => ({ ...U ? k : { ...k, ...G }, ...f }), Ae = ue("parentPermissionSuffix"), Ce = (f) => f.trim().toLowerCase().split(/\s+/).map(
469
+ (b, y) => y === 0 ? b : b.charAt(0).toUpperCase() + b.slice(1)
470
+ ).join(""), yi = async (f) => {
471
+ const b = (await J({
472
+ code: "GET_ALL_QUERY_CODE",
473
+ parameters: { search: f }
474
+ })).data;
475
+ de((b == null ? void 0 : b.result) || []);
476
+ };
477
+ ne(() => {
478
+ !U && (async () => {
479
+ const f = (await J({
480
+ code: "GET_ALL_QUERY_CODE",
481
+ parameters: {
482
+ search: ve("queryCode") ? ve("queryCode") : ""
483
+ }
484
+ })).data;
485
+ de((f == null ? void 0 : f.result) || []), C(ve("queryCode"));
486
+ })();
487
+ }, [qe]), ne(() => {
488
+ $ === !0 && !We ? (L("backendUrl", ""), L("urlType", "")) : $ === !1 && !qe && L("queryCode", "");
489
+ }, [$]), ne(() => {
490
+ var f, b, y;
491
+ if (_) {
492
+ if (S === "edit" && h) {
493
+ const D = {
494
+ permissionType: h.permissionType || "",
495
+ permissionId: h.permissionId || "--",
496
+ permissionName: h.permissionName || "",
497
+ permissionDesc: h.permissionDesc || "",
498
+ enabled: !!h.enabled,
499
+ permissionSuffix: ""
500
+ };
501
+ if (U)
502
+ Se(D);
503
+ else {
504
+ const re = ((f = h == null ? void 0 : h.backendUrl) == null ? void 0 : f.trim()) && ((b = h == null ? void 0 : h.urlType) == null ? void 0 : b.trim()), ie = (y = h == null ? void 0 : h.queryCode) == null ? void 0 : y.trim();
505
+ Se({
506
+ ...D,
507
+ urlType: h.urlType || "",
508
+ backendUrl: h.backendUrl || "",
509
+ queryCode: h.queryCode || "",
510
+ queryCodeRequired: h ? re ? !1 : ie ? !0 : void 0 : void 0
511
+ });
512
+ }
513
+ return;
514
+ }
515
+ if (S === "add-child" && I) {
516
+ const D = I.split(".")[0] || "";
517
+ Se(
518
+ Me({
519
+ permissionType: D,
520
+ permissionId: I,
521
+ permissionName: "",
522
+ permissionDesc: "",
523
+ enabled: !0,
524
+ permissionSuffix: "",
525
+ urlType: "",
526
+ backendUrl: "",
527
+ queryCodeRequired: void 0,
528
+ queryCode: ""
529
+ })
530
+ );
531
+ return;
532
+ }
533
+ Se(Me());
534
+ }
535
+ }, [_, S, h, I, Se]), ne(() => {
536
+ if (S === "add-parent") {
537
+ const f = (z == null ? void 0 : z.type) === "menu" ? "view" : z == null ? void 0 : z.type;
538
+ if (!f) {
539
+ L("permissionId", "--");
540
+ return;
541
+ }
542
+ const b = P.getValues("menuType") || "menuType", y = P.getValues("featureConstant") || "feature";
543
+ let D;
544
+ if (U)
545
+ D = `${f}.${b}.${y}`;
546
+ else {
547
+ const re = P.getValues("menuName");
548
+ D = `${f}.${b}.${Ce(re)}`;
549
+ }
550
+ Ae != null && Ae.trim() && (D = `${D}.${Ae.trim()}`), L("permissionId", D);
551
+ }
552
+ }, [z, Ae, S]), ne(() => {
553
+ $ === !0 && !We ? (L("backendUrl", ""), L("urlType", "")) : $ === !1 && !qe && L("queryCode", "");
554
+ }, [$]), ne(() => {
555
+ if (S === "add-child" && I !== null) {
556
+ const f = I.split(".")[0] || "", b = `${I}.child`, y = Ee ? `${b}.${Ee}` : b;
557
+ L("permissionId", y), L("permissionType", f);
558
+ }
559
+ }, [Ee, S, I, L]);
560
+ const bi = (f) => {
561
+ const b = {
562
+ permissionId: f.permissionId,
563
+ permissionType: f.permissionType || (I ? I.split(".")[0] : ""),
564
+ permissionName: f.permissionName,
565
+ permissionDesc: f.permissionDesc,
566
+ enabled: f.enabled,
567
+ backendUrl: f != null && f.backendUrl && !$ ? f.backendUrl : null,
568
+ urlType: f != null && f.urlType && !$ ? f.urlType : null,
569
+ queryCode: f != null && f.queryCode && $ ? f.queryCode : null,
570
+ childPermissions: [],
571
+ isDefault: h != null && h.isDefault ? h == null ? void 0 : h.isDefault : !1
572
+ };
573
+ E(b), Se(), q();
574
+ }, Xe = async (f) => !f || f === "--" ? void 0 : (await J({
575
+ code: "CHECK_UNIQUE_PERMISSION_ID",
576
+ parameters: { permissionId: f }
577
+ })).data.result[0].exists;
578
+ return /* @__PURE__ */ l(Tn, { open: _, onClose: q, fullWidth: !0, maxWidth: "sm", children: [
579
+ /* @__PURE__ */ i(_n, { children: S === "edit" ? "Edit Permission" : "Add Permission" }),
580
+ /* @__PURE__ */ l(
581
+ Dn,
582
+ {
583
+ sx: { display: "flex", flexDirection: "column", gap: 2, mt: 1 },
584
+ children: [
585
+ S !== "add-child" && S !== "edit" && /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
586
+ /* @__PURE__ */ l(
587
+ m,
588
+ {
589
+ sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
590
+ children: [
591
+ "Permission Type",
592
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" })
593
+ ]
594
+ }
595
+ ),
596
+ /* @__PURE__ */ i(K, { fullWidth: !0, size: "small", children: /* @__PURE__ */ i(
597
+ M,
598
+ {
599
+ name: "permissionType",
600
+ control: A,
601
+ rules: { required: !0 },
602
+ render: ({ field: f }) => /* @__PURE__ */ i(
603
+ Pe,
604
+ {
605
+ id: "permissionType",
606
+ name: "permissionType",
607
+ control: A,
608
+ singleSelect: !0,
609
+ checkEquality: "type",
610
+ freeSolo: !0,
611
+ disableClearable: !1,
612
+ placeholder: "Choose permission type",
613
+ options: X ? !W || X.some(
614
+ (b) => b.type.toLowerCase() === W.toLowerCase()
615
+ ) ? X : [
616
+ ...X,
617
+ { type: `__add_new__${W}`, isNew: !0 }
618
+ ] : [],
619
+ getOptionLabel: (b) => b.isNew ? `Add "${b.type.replace("__add_new__", "")}"` : b.type,
620
+ onInputChange: (b, y) => T(y),
621
+ onChange: (b, y) => {
622
+ if (!y) {
623
+ f.onChange(null), L("permissionId", "--");
624
+ return;
625
+ }
626
+ if (y.isNew) {
627
+ const D = y.type.replace("__add_new__", ""), re = { type: D };
628
+ se(
629
+ (ie) => ie.some((Ke) => Ke.type === D) ? ie : [...ie, re]
630
+ ), f.onChange(re);
631
+ return;
632
+ }
633
+ f.onChange(y);
634
+ }
635
+ }
636
+ )
637
+ }
638
+ ) })
639
+ ] }),
640
+ S === "add-child" ? /* @__PURE__ */ i(me, { children: /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
641
+ /* @__PURE__ */ l(
642
+ m,
643
+ {
644
+ sx: {
645
+ minWidth: 160,
646
+ fontWeight: 500,
647
+ color: "text.secondary"
648
+ },
649
+ children: [
650
+ "Permission ID",
651
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" })
652
+ ]
653
+ }
654
+ ),
655
+ /* @__PURE__ */ l(d, { sx: { display: "flex", gap: 1, flexGrow: 1 }, children: [
656
+ /* @__PURE__ */ i(
657
+ ee,
658
+ {
659
+ control: A,
660
+ name: "parentPermissionDisplay",
661
+ value: `${I}.child.`,
662
+ disabled: !0,
663
+ fullWidth: !0
664
+ }
665
+ ),
666
+ /* @__PURE__ */ i(
667
+ ee,
668
+ {
669
+ control: A,
670
+ name: "permissionSuffix",
671
+ placeholder: "Enter child suffix",
672
+ errors: Te.errors,
673
+ fullWidth: !0,
674
+ onChange: async (f) => {
675
+ const b = f.target.value.trim();
676
+ if (L("permissionSuffix", b), b.toLowerCase() === "child") {
677
+ xe("permissionSuffix", {
678
+ type: "manual",
679
+ message: "Suffix cannot be 'child'"
680
+ });
681
+ return;
682
+ }
683
+ Ie("permissionSuffix");
684
+ const y = `${I}.child.${b}`;
685
+ if (L("permissionId", y), Q != null && Q.has(y)) {
686
+ xe("permissionSuffix", {
687
+ type: "manual",
688
+ message: "Permission ID already exists"
689
+ });
690
+ return;
691
+ }
692
+ await Xe(y) ? xe("permissionSuffix", {
693
+ type: "manual",
694
+ message: "Permission ID already exists in DB"
695
+ }) : Ie("permissionSuffix");
696
+ }
697
+ }
698
+ )
699
+ ] })
700
+ ] }) }) : S === "add-parent" ? z != null && z.type ? /* @__PURE__ */ i(me, { children: /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
701
+ /* @__PURE__ */ l(
702
+ m,
703
+ {
704
+ sx: {
705
+ minWidth: 160,
706
+ fontWeight: 500,
707
+ color: "text.secondary"
708
+ },
709
+ children: [
710
+ "Permission ID",
711
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" })
712
+ ]
713
+ }
714
+ ),
715
+ /* @__PURE__ */ i(
716
+ ee,
717
+ {
718
+ control: A,
719
+ name: "baseId",
720
+ value: `${(z == null ? void 0 : z.type) === "menu" ? "view" : z == null ? void 0 : z.type}.${P.getValues("menuType")}.${U ? P.getValues("featureConstant") : Ce(P.getValues("menuName"))}.`,
721
+ disabled: !0,
722
+ fullWidth: !0
723
+ }
724
+ ),
725
+ /* @__PURE__ */ i(
726
+ ee,
727
+ {
728
+ control: A,
729
+ name: "parentPermissionSuffix",
730
+ placeholder: "Enter suffix",
731
+ errors: Te.errors,
732
+ fullWidth: !0,
733
+ onChange: async (f) => {
734
+ const b = f.target.value.trim();
735
+ if (L("parentPermissionSuffix", b), b.toLowerCase() === "child") {
736
+ xe("parentPermissionSuffix", {
737
+ type: "manual",
738
+ message: "Suffix cannot be 'child'"
739
+ });
740
+ return;
741
+ }
742
+ Ie("parentPermissionSuffix");
743
+ const y = (z == null ? void 0 : z.type) === "menu" ? "view" : (z == null ? void 0 : z.type) || z || "", D = P.getValues("menuType"), re = P.getValues("featureConstant");
744
+ let ie;
745
+ if (U ? ie = `${y}.${D}.${re}.${b}` : ie = `${y}.${D}.${Ce(P.getValues("menuName"))}.${b}`, L("permissionId", ie), Q != null && Q.has(ie)) {
746
+ xe("parentPermissionSuffix", {
747
+ type: "manual",
748
+ message: "Permission ID already exists"
749
+ });
750
+ return;
751
+ }
752
+ await Xe(ie) ? xe("parentPermissionSuffix", {
753
+ type: "manual",
754
+ message: "Permission ID already exists in DB"
755
+ }) : Ie("parentPermissionSuffix");
756
+ }
757
+ }
758
+ )
759
+ ] }) }) : /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
760
+ /* @__PURE__ */ l(
761
+ m,
762
+ {
763
+ sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
764
+ children: [
765
+ "Permission ID",
766
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" })
767
+ ]
768
+ }
769
+ ),
770
+ /* @__PURE__ */ i(
771
+ ee,
772
+ {
773
+ control: A,
774
+ name: "permissionId",
775
+ value: "--",
776
+ disabled: !0,
777
+ fullWidth: !0
778
+ }
779
+ )
780
+ ] }) : /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
781
+ /* @__PURE__ */ l(
782
+ m,
783
+ {
784
+ sx: {
785
+ minWidth: 160,
786
+ fontWeight: 500,
787
+ color: "text.secondary"
788
+ },
789
+ children: [
790
+ "Permission ID",
791
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" })
792
+ ]
793
+ }
794
+ ),
795
+ /* @__PURE__ */ i(
796
+ ee,
797
+ {
798
+ control: A,
799
+ name: "permissionId",
800
+ label: "Permission ID",
801
+ disabled: !0,
802
+ fullWidth: !0
803
+ }
804
+ )
805
+ ] }),
806
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
807
+ /* @__PURE__ */ l(
808
+ m,
809
+ {
810
+ sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
811
+ children: [
812
+ "Permission Name",
813
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" })
814
+ ]
815
+ }
816
+ ),
817
+ /* @__PURE__ */ i(
818
+ M,
819
+ {
820
+ name: "permissionName",
821
+ control: A,
822
+ rules: { required: !0 },
823
+ render: ({ field: f }) => /* @__PURE__ */ i(
824
+ ee,
825
+ {
826
+ control: A,
827
+ ...f,
828
+ placeholder: "Enter name"
829
+ }
830
+ )
831
+ }
832
+ )
833
+ ] }),
834
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "flex-start", gap: 2, children: [
835
+ /* @__PURE__ */ i(
836
+ m,
837
+ {
838
+ sx: {
839
+ minWidth: 160,
840
+ fontWeight: 500,
841
+ color: "text.secondary",
842
+ mt: 1
843
+ },
844
+ children: "Description"
845
+ }
846
+ ),
847
+ /* @__PURE__ */ i(
848
+ M,
849
+ {
850
+ name: "permissionDesc",
851
+ control: A,
852
+ render: ({ field: f }) => /* @__PURE__ */ i(
853
+ cr,
854
+ {
855
+ control: A,
856
+ ...f,
857
+ placeholder: "Enter description (optional)",
858
+ minRows: 2
859
+ }
860
+ )
861
+ }
862
+ )
863
+ ] }),
864
+ !U && /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
865
+ /* @__PURE__ */ l(
866
+ m,
867
+ {
868
+ sx: {
869
+ minWidth: 160,
870
+ fontWeight: 500,
871
+ color: "text.secondary"
872
+ },
873
+ children: [
874
+ "Type",
875
+ " "
876
+ ]
877
+ }
878
+ ),
879
+ /* @__PURE__ */ i(
880
+ pr,
881
+ {
882
+ name: "queryCodeRequired",
883
+ control: A,
884
+ options: ze,
885
+ direction: "row",
886
+ dataTestId: "queryOrApi"
887
+ }
888
+ )
889
+ ] }),
890
+ !U && $ !== void 0 && /* @__PURE__ */ i(me, { children: $ === !1 ? /* @__PURE__ */ l(me, { children: [
891
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
892
+ /* @__PURE__ */ i(
893
+ m,
894
+ {
895
+ sx: {
896
+ minWidth: 160,
897
+ fontWeight: 500,
898
+ color: "text.secondary"
899
+ },
900
+ children: "URL Type"
901
+ }
902
+ ),
903
+ /* @__PURE__ */ i(K, { fullWidth: !0, size: "small", children: /* @__PURE__ */ i(
904
+ M,
905
+ {
906
+ name: "urlType",
907
+ control: A,
908
+ render: ({ field: f }) => /* @__PURE__ */ l(Xt, { ...f, displayEmpty: !0, children: [
909
+ /* @__PURE__ */ i(vn, { value: "", children: /* @__PURE__ */ i("em", { children: "Select Type" }) }),
910
+ ["GET", "POST", "PUT", "DELETE"].map((b) => /* @__PURE__ */ i(vn, { value: b, children: b }, b))
911
+ ] })
912
+ }
913
+ ) })
914
+ ] }),
915
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
916
+ /* @__PURE__ */ i(
917
+ m,
918
+ {
919
+ sx: {
920
+ minWidth: 160,
921
+ fontWeight: 500,
922
+ color: "text.secondary"
923
+ },
924
+ children: "Backend URL"
925
+ }
926
+ ),
927
+ /* @__PURE__ */ i(
928
+ M,
929
+ {
930
+ name: "backendUrl",
931
+ control: A,
932
+ render: ({ field: f }) => /* @__PURE__ */ i(
933
+ ee,
934
+ {
935
+ control: A,
936
+ ...f,
937
+ placeholder: "Enter URL"
938
+ }
939
+ )
940
+ }
941
+ )
942
+ ] })
943
+ ] }) : /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
944
+ /* @__PURE__ */ i(
945
+ m,
946
+ {
947
+ sx: {
948
+ minWidth: 160,
949
+ fontWeight: 500,
950
+ color: "text.secondary"
951
+ },
952
+ children: "Query Code"
953
+ }
954
+ ),
955
+ /* @__PURE__ */ i(
956
+ M,
957
+ {
958
+ name: "queryCode",
959
+ control: A,
960
+ render: ({ field: f, fieldState: { error: b } }) => /* @__PURE__ */ i(
961
+ Pe,
962
+ {
963
+ id: "queryCode",
964
+ name: "queryCode",
965
+ control: A,
966
+ options: x,
967
+ getOptionLabel: (y) => (y == null ? void 0 : y.code) || "",
968
+ checkEquality: "code",
969
+ inputValue: pe,
970
+ disableClearable: !1,
971
+ value: (x == null ? void 0 : x.find((y) => y.code === f.value)) || null,
972
+ onInputChange: (y, D, re) => {
973
+ re === "input" && (C(D), yi(D));
974
+ },
975
+ singleSelect: !0,
976
+ onChange: (y, D) => {
977
+ f.onChange((D == null ? void 0 : D.code) || ""), C((D == null ? void 0 : D.code) || "");
978
+ },
979
+ placeholder: "Search Query Code...",
980
+ errors: b,
981
+ fullWidth: !0,
982
+ freeSolo: !1
983
+ }
984
+ )
985
+ }
986
+ )
987
+ ] }) }),
988
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
989
+ /* @__PURE__ */ l(
990
+ m,
991
+ {
992
+ sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
993
+ children: [
994
+ "Is Active",
995
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" })
996
+ ]
997
+ }
998
+ ),
999
+ /* @__PURE__ */ i(
1000
+ M,
1001
+ {
1002
+ name: "enabled",
1003
+ control: A,
1004
+ render: ({ field: f }) => /* @__PURE__ */ i(
1005
+ ke,
1006
+ {
1007
+ ...f,
1008
+ disabled: (h == null ? void 0 : h.isDefault) && !U,
1009
+ checked: f.value,
1010
+ onChange: (b) => f.onChange(b.target.checked)
1011
+ }
1012
+ )
1013
+ }
1014
+ )
1015
+ ] })
1016
+ ]
1017
+ }
1018
+ ),
1019
+ /* @__PURE__ */ l(Fn, { children: [
1020
+ /* @__PURE__ */ i(O, { onClick: q, children: "Cancel" }),
1021
+ /* @__PURE__ */ i(
1022
+ O,
1023
+ {
1024
+ onClick: gi(bi),
1025
+ variant: "contained",
1026
+ disabled: !Te.isValid || Object.keys(Te.errors).length > 0,
1027
+ children: S === "edit" ? "Update" : S === "add-child" ? "Add Child" : "Add"
1028
+ }
1029
+ )
1030
+ ] })
1031
+ ] });
1032
+ }, qn = ({
1033
+ open: _,
1034
+ onClose: q,
1035
+ onSave: E,
1036
+ entityData: P,
1037
+ permissions: h = []
1038
+ }) => {
1039
+ const { control: I, watch: S, getValues: X } = fi({
1040
+ defaultValues: {
1041
+ noStartDate: !0,
1042
+ noEndDate: !0,
1043
+ startDate: null,
1044
+ endDate: null,
1045
+ isBackendOnly: !1
1046
+ }
1047
+ }), se = S("noStartDate"), Q = S("noEndDate"), U = S("startDate"), u = S("endDate"), te = () => {
1048
+ const W = X();
1049
+ ye(W);
1050
+ }, ye = (W) => {
1051
+ const T = [];
1052
+ P.forEach((x) => {
1053
+ if (x.type === "user") {
1054
+ const de = Array.isArray(x.id) ? x.id : [x.id];
1055
+ T.push(
1056
+ ...de.map((pe) => ({
1057
+ entityType: "user",
1058
+ user_id: pe,
1059
+ name: x.name,
1060
+ startDate: W.noStartDate ? null : W.startDate,
1061
+ endDate: W.noEndDate ? null : W.endDate,
1062
+ isBackendOnly: W.isBackendOnly,
1063
+ permissions: JSON.parse(JSON.stringify(h))
1064
+ }))
1065
+ );
1066
+ }
1067
+ x.type === "role" && x.ids.forEach((de, pe) => {
1068
+ T.push({
1069
+ entityType: "role",
1070
+ role_id: de,
1071
+ name: x.names[pe],
1072
+ startDate: W.noStartDate ? null : W.startDate,
1073
+ endDate: W.noEndDate ? null : W.endDate,
1074
+ isBackendOnly: W.isBackendOnly,
1075
+ permissions: JSON.parse(JSON.stringify(h))
1076
+ });
1077
+ });
1078
+ }), T.forEach((x) => E(x)), q();
1079
+ };
1080
+ return /* @__PURE__ */ i(Kt, { open: _, onClose: q, children: /* @__PURE__ */ i(d, { className: "fixed inset-0 flex items-start justify-center z-50 bg-opacity-10 overflow-y-auto", children: /* @__PURE__ */ l(er, { className: "relative mt-10 p-4 shadow-lg flex flex-col rounded-xl", children: [
1081
+ /* @__PURE__ */ l(j, { className: "flex justify-between items-center mb-4", children: [
1082
+ /* @__PURE__ */ i(m, { variant: "h6", children: "Grant Access" }),
1083
+ /* @__PURE__ */ i(Ue, { onClick: q, children: /* @__PURE__ */ i(oe, { iconName: "faXmark", size: "sm" }) })
1084
+ ] }),
1085
+ /* @__PURE__ */ i(j, { container: !0, spacing: 2, children: /* @__PURE__ */ l(j, { item: !0, xs: 12, display: "flex", gap: 2, children: [
1086
+ /* @__PURE__ */ l(d, { display: "flex", flexDirection: "column", flex: 1, children: [
1087
+ /* @__PURE__ */ i(
1088
+ Pi,
1089
+ {
1090
+ label: "No Start Date",
1091
+ name: "noStartDate",
1092
+ control: I,
1093
+ sx: { mb: 1 }
1094
+ }
1095
+ ),
1096
+ /* @__PURE__ */ i(
1097
+ wn,
1098
+ {
1099
+ name: "startDate",
1100
+ control: I,
1101
+ disabled: se,
1102
+ maxDate: u || void 0
1103
+ }
1104
+ )
1105
+ ] }),
1106
+ /* @__PURE__ */ l(d, { display: "flex", flexDirection: "column", flex: 1, children: [
1107
+ /* @__PURE__ */ i(
1108
+ Pi,
1109
+ {
1110
+ label: "No End Date",
1111
+ name: "noEndDate",
1112
+ control: I,
1113
+ sx: { mb: 1 }
1114
+ }
1115
+ ),
1116
+ /* @__PURE__ */ i(
1117
+ wn,
1118
+ {
1119
+ name: "endDate",
1120
+ control: I,
1121
+ disabled: Q,
1122
+ minDate: U || void 0
1123
+ }
1124
+ )
1125
+ ] })
1126
+ ] }) }),
1127
+ /* @__PURE__ */ i(d, { mt: 2, children: /* @__PURE__ */ i(
1128
+ Pi,
1129
+ {
1130
+ label: "Is Backend Only?",
1131
+ name: "isBackendOnly",
1132
+ control: I
1133
+ }
1134
+ ) }),
1135
+ /* @__PURE__ */ l(j, { className: "flex justify-end gap-2 mt-4", children: [
1136
+ /* @__PURE__ */ i(O, { type: "button", variant: "outlined", onClick: q, children: "Cancel" }),
1137
+ /* @__PURE__ */ i(O, { variant: "contained", type: "button", onClick: te, children: "Save" })
1138
+ ] })
1139
+ ] }) }) });
1140
+ }, qi = ({ permissions: _, onToggle: q, isChild: E = !1 }) => {
1141
+ const P = (h) => h.replaceAll(".child", "");
1142
+ return _.map((h, I) => {
1143
+ var S;
1144
+ return /* @__PURE__ */ l(
1145
+ d,
1146
+ {
1147
+ display: "flex",
1148
+ flexDirection: "column",
1149
+ gap: 1,
1150
+ ml: E ? 2 : 0,
1151
+ children: [
1152
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 1, children: [
1153
+ /* @__PURE__ */ i(
1154
+ ke,
1155
+ {
1156
+ sx: {
1157
+ transform: "scale(0.75)",
1158
+ transformOrigin: "left center"
1159
+ },
1160
+ checked: !!h.enabled,
1161
+ disabled: E,
1162
+ onChange: () => {
1163
+ E || q(h);
1164
+ }
1165
+ }
1166
+ ),
1167
+ /* @__PURE__ */ i(m, { variant: "subtitle1", children: P(h.permissionId) })
1168
+ ] }),
1169
+ ((S = h.childPermissions) == null ? void 0 : S.length) > 0 && /* @__PURE__ */ i(
1170
+ qi,
1171
+ {
1172
+ permissions: h.childPermissions,
1173
+ onToggle: q,
1174
+ isChild: !0
1175
+ }
1176
+ )
1177
+ ]
1178
+ },
1179
+ I
1180
+ );
1181
+ });
1182
+ };
1183
+ function Jr() {
1184
+ var _, q, E, P, h, I, S, X, se, Q, U;
1185
+ const { translate: u } = mr(), te = tr(null), ye = lr(), W = or(), { isNew: T } = ye.state || {}, x = xn(
1186
+ () => new URLSearchParams(ye.search),
1187
+ [ye.search]
1188
+ ), de = kn(), [pe, C] = g([]), [k, G] = g(!1), [hi, A] = g([]), [ue, gi] = g([]), [Se, L] = g(), [ve, xe] = g({}), [Ie, Te] = g(!1), [$, z] = g(!1), [Ee, We] = g(""), [qe, ze] = g(""), [Me, Ae] = g(""), [Ce, yi] = g(), [bi, Xe] = g([]), [f, b] = g(!1), [y, D] = g(0), [re, ie] = g(!1), [Ke, Ai] = g([]), [Ri, Bi] = g([]), [Re, An] = g([]), [we, vi] = g([]), [Rn, xi] = g([]), [ae, ei] = g({}), [Le, $e] = g([]), [ii, Bn] = g({}), [fe, Je] = g([]), [On, je] = g(!1), [Qe, ni] = g("add-parent"), [Ci, ti] = g(null), [Un, ri] = g(null), [zn, ai] = g(null), [Mn, Si] = g(!1), [Ln, $n] = g(null), [Ne, Be] = g([]), [Jn, Oi] = g(!1), [_e, li] = g(!1), [Ui, jn] = g(!1), [H, zi] = g({ value: !1, length: 0 }), [Qn, Gn] = g([
1189
+ { type: "update" },
1190
+ { type: "menu" },
1191
+ { type: "create" },
1192
+ { type: "download" },
1193
+ { type: "execute" }
1194
+ ]), [Oe, Hn] = g([]), [Zn, Ge] = g(""), [Yn, He] = g(""), [wi, Ni] = g({
1195
+ basicConfig: !0,
1196
+ trainingConfig: !1,
1197
+ notificationConfig: !1
1198
+ }), [Mi, Xn] = nr.useState(null), Kn = (e) => Ke.includes(e), [et, Li] = g(/* @__PURE__ */ new Set()), it = ar((e) => e.theme.mode), R = [
1199
+ { key: "featureDetails", label: "Feature Details" },
1200
+ { key: "mobileConfig", label: "Mobile Config" },
1201
+ { key: "formLinking", label: "Form Linking" },
1202
+ { key: "additionalPermissions", label: "Permission Management" },
1203
+ { key: "assignFeatures", label: "Assignment" },
1204
+ { key: "submit", label: "Submit" }
1205
+ ], nt = B.object().shape({
1206
+ menuName: B.string().required("Enter Feature Name"),
1207
+ featureConstant: B.string().when("isDynamicFeature", {
1208
+ is: !0,
1209
+ then: (e) => e.required("Enter Feature Constant"),
1210
+ otherwise: (e) => e.notRequired()
1211
+ }),
1212
+ navigationState: B.string().when("isDynamicFeature", {
1213
+ is: !1,
1214
+ then: (e) => e.required("Enter Navigation State").matches(
1215
+ /^(techo\.[a-zA-Z]+\.[a-zA-Z]+|medplat(\.form\.[a-zA-Z_]+|\..+))$/,
1216
+ "invalid format for state"
1217
+ ),
1218
+ otherwise: (e) => e.notRequired()
1219
+ }),
1220
+ menuType: B.string().required("Enter Feature Type"),
1221
+ icon: B.string().when("$showMobileFields", {
1222
+ is: !0,
1223
+ then: (e) => e.required("Please upload an icon"),
1224
+ otherwise: (e) => e.notRequired()
1225
+ }),
1226
+ conditions: B.string().transform((e) => e ? e.trim() : ""),
1227
+ mobileMode: B.string().when("$showMobileFields", {
1228
+ is: !0,
1229
+ then: (e) => e.required("Please select a mode"),
1230
+ otherwise: (e) => e.notRequired()
1231
+ }),
1232
+ trainingQuery: B.string().when("trainingRequired", {
1233
+ is: !0,
1234
+ then: (e) => e.required("Please select a training query"),
1235
+ otherwise: (e) => e.notRequired()
1236
+ }),
1237
+ notificationBadgeType: B.string().when("notificationBadgeEnabled", {
1238
+ is: !0,
1239
+ then: (e) => e.required("Please select a badge type"),
1240
+ otherwise: (e) => e.notRequired()
1241
+ }),
1242
+ notificationBadgeQuery: B.string().when(
1243
+ ["notificationBadgeEnabled", "notificationBadgeType"],
1244
+ (e, n) => {
1245
+ const [t, r] = e;
1246
+ return t && r ? n.required(
1247
+ r === "COUNT" ? "Please select a count query" : "Please select a nudge query"
1248
+ ) : n.notRequired();
1249
+ }
1250
+ ),
1251
+ updatedFields: B.array().when(
1252
+ ["isDynamicFeature", "isNew", "isUpdate", "showFields"],
1253
+ (e, n) => {
1254
+ const [t, r, o, c] = e;
1255
+ return t === !1 && (r == null ? void 0 : r.val) === !1 && (o == null ? void 0 : o.value) === !0 && c === !0 ? n.of(
1256
+ B.object().shape({
1257
+ value: B.string().required("Right is required")
1258
+ })
1259
+ ) : n.optional();
1260
+ }
1261
+ )
1262
+ }), a = fi({
1263
+ defaultValues: {
1264
+ menuName: "",
1265
+ featureConstant: "",
1266
+ navigationState: "medplat.form",
1267
+ menuType: "",
1268
+ menuGroup: "",
1269
+ isDynamicFeature: !0,
1270
+ isWebFeature: !1,
1271
+ isMobileFeature: !1,
1272
+ accessRights: [],
1273
+ entityName: null,
1274
+ mobileEntitiesSync: [],
1275
+ icon: "",
1276
+ mobileMode: null,
1277
+ conditions: "",
1278
+ formCode: "",
1279
+ version: null,
1280
+ additionalPermissions: [],
1281
+ fields: [],
1282
+ updatedFields: [],
1283
+ trainingRequired: !1,
1284
+ trainingQuery: "",
1285
+ notificationBadgeEnabled: !1,
1286
+ notificationBadgeType: "",
1287
+ notificationBadgeQuery: ""
1288
+ },
1289
+ resolver: Nn(nt),
1290
+ mode: "onChange"
1291
+ }), F = pi({
1292
+ control: a.control,
1293
+ name: "isDynamicFeature"
1294
+ }), $i = pi({
1295
+ control: a.control,
1296
+ name: "isMobileFeature"
1297
+ }), Ji = pi({
1298
+ control: a.control,
1299
+ name: "isWebFeature"
1300
+ }), tt = pi({
1301
+ control: a.control,
1302
+ name: at((_ = R[y]) == null ? void 0 : _.key)
1303
+ }), rt = a.watch();
1304
+ function at(e) {
1305
+ switch (e) {
1306
+ case "featureDetails":
1307
+ return F ? ["menuName", "featureConstant", "menuType"] : ["menuName", "navigationState", "menuType"];
1308
+ case "mobileConfig":
1309
+ return k ? [
1310
+ "icon",
1311
+ "mobileMode",
1312
+ "trainingRequired",
1313
+ "trainingQuery",
1314
+ "notificationBadgeEnabled",
1315
+ "notificationBadgeType",
1316
+ "notificationBadgeQuery"
1317
+ ] : [];
1318
+ case "formLinking":
1319
+ return F ? ["formCode", "version"] : [];
1320
+ case "additionalPermissions":
1321
+ return !F && (T == null ? void 0 : T.val) === !1 ? ["updatedFields"] : ["additionalPermissions"];
1322
+ default:
1323
+ return [];
1324
+ }
1325
+ }
1326
+ const ji = xn(() => {
1327
+ var e;
1328
+ switch ((e = R[y]) == null ? void 0 : e.key) {
1329
+ case "featureDetails": {
1330
+ const n = !!a.formState.errors.navigationState, t = !!a.formState.errors.featureConstant;
1331
+ return a.formState.isValid && !!a.getValues("menuName") && (F ? !!a.getValues("featureConstant") && !t : !!a.getValues("navigationState") && !n) && !!a.getValues("menuType");
1332
+ }
1333
+ case "mobileConfig": {
1334
+ if (!k) return !0;
1335
+ const n = !!a.getValues("icon"), t = !!a.getValues("mobileMode"), r = a.getValues("trainingRequired"), o = a.getValues("trainingQuery"), c = a.getValues("notificationBadgeEnabled"), s = a.getValues("notificationBadgeType"), p = a.getValues("notificationBadgeQuery");
1336
+ return n && t && (!r || !!o) && (!c || !!s) && (!c || !s || !!p);
1337
+ }
1338
+ case "formLinking": {
1339
+ if (!F) return !0;
1340
+ const n = a.getValues("formCode"), t = a.getValues("version");
1341
+ return !!n && !!t;
1342
+ }
1343
+ case "additionalPermissions": {
1344
+ if (!F && (T == null ? void 0 : T.val) === !1 && _e)
1345
+ return (a.getValues("updatedFields") || []).every(
1346
+ (n) => n.value && n.value.trim()
1347
+ );
1348
+ {
1349
+ const n = a.getValues("additionalPermissions") || [];
1350
+ return n.length > 0 && n.every(
1351
+ (t) => {
1352
+ var r, o, c, s;
1353
+ return ((r = t.permissionId) == null ? void 0 : r.trim()) && ((o = t.permissionName) == null ? void 0 : o.trim()) && ((s = (c = t.permissionType) == null ? void 0 : c.type) == null ? void 0 : s.trim());
1354
+ }
1355
+ );
1356
+ }
1357
+ }
1358
+ default:
1359
+ return !0;
1360
+ }
1361
+ }, [
1362
+ tt,
1363
+ a.formState.isValid,
1364
+ y,
1365
+ k
1366
+ ]), Ze = R.filter(
1367
+ (e) => (e.key !== "mobileConfig" || k) && (e.key !== "formLinking" || F)
1368
+ ), ki = async () => {
1369
+ const e = R[y].key;
1370
+ if (Kn(e)) {
1371
+ Qi();
1372
+ return;
1373
+ }
1374
+ await a.trigger(Gi(e)) && (Li((n) => new Set(n).add(e)), Ai((n) => n.filter((t) => t !== e)), Qi());
1375
+ }, Qi = () => {
1376
+ const e = R[y].key, n = Ze.findIndex(
1377
+ (r) => r.key === e
1378
+ ), t = Ze[n + 1];
1379
+ if (t) {
1380
+ t.key === "additionalPermissions" && fe.length === 0 && ut(), e === "additionalPermissions" && t.key === "assignFeatures" && Be(
1381
+ st(fe, Ne)
1382
+ );
1383
+ const r = R.findIndex(
1384
+ (o) => o.key === t.key
1385
+ );
1386
+ D(r);
1387
+ }
1388
+ };
1389
+ ne(() => {
1390
+ if ($ === !0) {
1391
+ const e = a.getValues("mobileMode");
1392
+ Xn(e);
1393
+ }
1394
+ }, [$, a]), ne(() => {
1395
+ F ? a.setValue("navigationState", "medplat.form") : (x.get("featureId") === null && a.setValue("navigationState", ""), a.setValue("featureConstant", ""), We(""), a.clearErrors("featureConstant"));
1396
+ }, [F]);
1397
+ const Gi = (e) => {
1398
+ switch (e) {
1399
+ case "formLinking":
1400
+ return ["formCode", "version"];
1401
+ case "additionalPermissions":
1402
+ return ["permissionId", "permissionName", "permissionType"];
1403
+ default:
1404
+ return [];
1405
+ }
1406
+ }, lt = () => {
1407
+ y === 0 && W("/ui/medplat/manage/menu");
1408
+ const e = R[y].key, n = Ze.findIndex(
1409
+ (r) => r.key === e
1410
+ ), t = Ze[n - 1];
1411
+ if (t) {
1412
+ const r = R.findIndex(
1413
+ (o) => o.key === t.key
1414
+ );
1415
+ D(r);
1416
+ }
1417
+ }, ot = (e) => {
1418
+ const n = R[e].key;
1419
+ return et.has(n);
1420
+ };
1421
+ ne(() => {
1422
+ (async () => {
1423
+ var e;
1424
+ if (await ft(), await ht(), await gt(), b(!0), await Xi(), await yt(), await De(), x.get("featureId") && F) {
1425
+ const { data: n } = await Sn(x.get("featureId"));
1426
+ if (n != null && n.permissions) {
1427
+ const t = Hi(
1428
+ n.permissions
1429
+ );
1430
+ if (((e = n == null ? void 0 : n.userMenuItemDtos) == null ? void 0 : e.length) > 0) {
1431
+ const r = Zi(
1432
+ t,
1433
+ n.userMenuItemDtos
1434
+ ).map((o) => ({
1435
+ ...o,
1436
+ permissions: Ii(o.permissions)
1437
+ }));
1438
+ Be(r);
1439
+ }
1440
+ Je(t);
1441
+ }
1442
+ }
1443
+ })();
1444
+ }, []), ne(() => {
1445
+ if (ii != null && ii.userMenuItemDtos) {
1446
+ const e = a.getValues("updatedFields") || [], n = e == null ? void 0 : e.reduce((r, o) => (r[o.name] = o.enabled, r), {}), t = ii.userMenuItemDtos.map((r) => {
1447
+ let o = {};
1448
+ try {
1449
+ o = r.featureJson ? JSON.parse(r.featureJson) : {};
1450
+ } catch (s) {
1451
+ console.warn("Invalid JSON in featureJson:", s);
1452
+ }
1453
+ const c = {
1454
+ ...n,
1455
+ ...o
1456
+ };
1457
+ return {
1458
+ ...r,
1459
+ featureJson: JSON.stringify(c)
1460
+ };
1461
+ });
1462
+ $e(t);
1463
+ }
1464
+ }, [ii]), ne(() => {
1465
+ try {
1466
+ const e = x.get("featureId");
1467
+ if (x.get("featureType") && e) {
1468
+ const n = async () => {
1469
+ var t;
1470
+ if (T != null && T.val) {
1471
+ const { data: r } = await Sn(e);
1472
+ if (Oi(!0), await Yi(), r != null && r.permissions) {
1473
+ const o = Hi(
1474
+ r.permissions
1475
+ );
1476
+ if (((t = r == null ? void 0 : r.userMenuItemDtos) == null ? void 0 : t.length) > 0) {
1477
+ const c = Zi(
1478
+ o,
1479
+ r.userMenuItemDtos
1480
+ ).map((s) => ({
1481
+ ...s,
1482
+ permissions: Ii(s.permissions)
1483
+ }));
1484
+ Be(c);
1485
+ }
1486
+ Je(o);
1487
+ }
1488
+ zi((o) => ({ ...o, value: !0, length: 0 }));
1489
+ } else {
1490
+ const { data: r } = await dr(e);
1491
+ Bn(r), await Yi();
1492
+ const o = JSON.parse(r.featureJson || "{}"), c = Object.keys(o).map((s, p) => ({
1493
+ id: p + 1,
1494
+ value: s,
1495
+ checkbox: o[s],
1496
+ updated: !0
1497
+ }));
1498
+ a.setValue("updatedFields", c), li(c.length > 0), c.length > 0 && Oi(!0), zi((s) => ({ ...s, value: !0, length: o.length || 0 })), jn(r == null ? void 0 : r.isSeparateFeature);
1499
+ }
1500
+ };
1501
+ Ti(), n();
1502
+ }
1503
+ } catch (e) {
1504
+ ce({
1505
+ type: "error",
1506
+ message: `error :${e == null ? void 0 : e.message}`
1507
+ });
1508
+ }
1509
+ }, [x, a.setValue, f, Ce]);
1510
+ const Hi = (e) => {
1511
+ const n = a.getValues("menuType"), t = a.getValues("featureConstant"), r = (s) => s.trim().toLowerCase().split(/\s+/).map(
1512
+ (p, v) => v === 0 ? p : p.charAt(0).toUpperCase() + p.slice(1)
1513
+ ).join("");
1514
+ let o;
1515
+ if (!F || (t == null ? void 0 : t.length) === 0) {
1516
+ const s = a.getValues("menuName");
1517
+ o = `view.${n}.${r(s)}`;
1518
+ } else
1519
+ o = `view.${n}.${t}`;
1520
+ const c = (s) => {
1521
+ const p = s.id === o;
1522
+ return {
1523
+ permissionId: s.id,
1524
+ permissionType: { type: s.type },
1525
+ permissionName: s.name,
1526
+ permissionDesc: s.desc || "",
1527
+ enabled: s.is_active,
1528
+ isDefault: p,
1529
+ childPermissions: s.child ? s.child.map((v) => c(v)) : [],
1530
+ urlType: (s == null ? void 0 : s.httpMethod) || "",
1531
+ backendUrl: (s == null ? void 0 : s.url) || "",
1532
+ queryCodeRequired: !(s != null && s.url),
1533
+ queryCode: (s == null ? void 0 : s.queryCodes) || ""
1534
+ };
1535
+ };
1536
+ return e.map(c);
1537
+ }, Zi = (e, n) => {
1538
+ if (!Array.isArray(n)) return [];
1539
+ const t = (r, o) => {
1540
+ var c;
1541
+ const s = ((c = r.childPermissions) == null ? void 0 : c.map(
1542
+ (V) => t(V, o)
1543
+ )) || [], p = s.some((V) => V.enabled), v = o.includes(r.permissionId) || p;
1544
+ return { ...r, enabled: v, childPermissions: s };
1545
+ };
1546
+ return n.map((r) => {
1547
+ var o, c, s, p, v, V, N;
1548
+ const he = ((o = r.permissions) == null ? void 0 : o.map((_i) => _i.id)) || [], Z = !!r.roleName || !!r.designationId || !!r.roleId, le = !!r.userId || !!r.fullName, Fe = e.map(
1549
+ (_i) => t(_i, he)
1550
+ );
1551
+ return {
1552
+ entityType: Z ? "role" : "user",
1553
+ user_id: le && r.userId || null,
1554
+ role_id: Z && (r.designationId || r.roleId) || null,
1555
+ name: le ? r.fullName || "" : r.roleName || "",
1556
+ startDate: ((s = (c = r.permissions) == null ? void 0 : c[0]) == null ? void 0 : s.startDate) || null,
1557
+ endDate: ((v = (p = r.permissions) == null ? void 0 : p[0]) == null ? void 0 : v.endDate) || null,
1558
+ isBackendOnly: ((N = (V = r.permissions) == null ? void 0 : V[0]) == null ? void 0 : N.isBackendOnly) || !1,
1559
+ permissions: Fe
1560
+ };
1561
+ });
1562
+ }, Ii = (e) => {
1563
+ const n = (t) => {
1564
+ var r, o;
1565
+ let c = [];
1566
+ if ((r = t.childPermissions) != null && r.length) {
1567
+ c = t.childPermissions.map(n);
1568
+ const s = c.every((p) => p.enabled);
1569
+ t.enabled = t.enabled || s;
1570
+ }
1571
+ return t.enabled && (o = t.childPermissions) != null && o.length && (c = c.map((s) => {
1572
+ var p;
1573
+ return {
1574
+ ...s,
1575
+ enabled: !0,
1576
+ childPermissions: (p = s.childPermissions) != null && p.length ? Ii(s.childPermissions) : []
1577
+ };
1578
+ })), {
1579
+ ...t,
1580
+ childPermissions: c
1581
+ };
1582
+ };
1583
+ return e.map(n);
1584
+ }, st = (e, n) => {
1585
+ const t = /* @__PURE__ */ new Map(), r = (c) => {
1586
+ c.forEach((s) => {
1587
+ var p;
1588
+ t.set(s.permissionId, s), (p = s.childPermissions) != null && p.length && r(s.childPermissions);
1589
+ });
1590
+ };
1591
+ r(e);
1592
+ const o = (c, s) => c.map((p) => {
1593
+ const v = (s == null ? void 0 : s.find((N) => N.permissionId === p.permissionId)) || {}, V = o(
1594
+ p.childPermissions || [],
1595
+ v.childPermissions || []
1596
+ );
1597
+ return {
1598
+ ...p,
1599
+ enabled: v.enabled ?? p.enabled,
1600
+ childPermissions: V
1601
+ };
1602
+ });
1603
+ return n.map((c) => ({
1604
+ ...c,
1605
+ permissions: o(e, c.permissions)
1606
+ }));
1607
+ }, dt = async () => {
1608
+ try {
1609
+ const e = (await J({
1610
+ code: "RETREIVE_DYNAMIC_FEATURE_INFO",
1611
+ parameters: {
1612
+ id: parseInt(x.get("featureId")),
1613
+ menuType: x.get("featureType")
1614
+ }
1615
+ })).data;
1616
+ if (e.result) {
1617
+ let n = e.result[0];
1618
+ const t = (() => {
1619
+ try {
1620
+ return n.mobile_config ? JSON.parse(n.mobile_config) : {};
1621
+ } catch {
1622
+ return {};
1623
+ }
1624
+ })(), r = ((t == null ? void 0 : t.mobile_entities_sync) ?? []).map(
1625
+ (s) => ue == null ? void 0 : ue.find((p) => p.tableName === s)
1626
+ ).filter(Boolean);
1627
+ a.reset({
1628
+ menuName: n.menuName ? n.menuName : "",
1629
+ featureConstant: n.featureConstant ? n.featureConstant : "",
1630
+ navigationState: n.navigationState ? n.navigationState : "medplat.form",
1631
+ isDynamicFeature: n.isDynamicFeature !== void 0 && n.isDynamicFeature !== null ? n.isDynamicFeature : !1,
1632
+ menuType: n.menuType ? n.menuType : "",
1633
+ menuGroup: n.group_id ? n.group_id.toString() : "",
1634
+ isWebFeature: n.isWebFeature ? n.isWebFeature : !1,
1635
+ isMobileFeature: n.isMobileFeature ? n.isMobileFeature : !1,
1636
+ entityName: (t == null ? void 0 : t.entity_name) ?? "",
1637
+ mobileMode: (t == null ? void 0 : t.mobile_mode) ?? null,
1638
+ icon: (t == null ? void 0 : t.icon) ?? "",
1639
+ mobileEntitiesSync: t != null && t.mobile_entities_sync ? t.mobile_entities_sync : [],
1640
+ conditions: (t == null ? void 0 : t.conditions) ?? "",
1641
+ formCode: n.formCode ? n.formCode : "",
1642
+ version: n.currentVersion ? n.currentVersion : "",
1643
+ trainingRequired: (t == null ? void 0 : t.training_required) ?? !1,
1644
+ trainingQuery: (t == null ? void 0 : t.training_query) ?? "",
1645
+ notificationBadgeEnabled: (t == null ? void 0 : t.notification_badge_enabled) ?? !1,
1646
+ notificationBadgeType: (t == null ? void 0 : t.notification_badge_type) ?? "",
1647
+ notificationBadgeQuery: (t == null ? void 0 : t.notification_badge_query) ?? ""
1648
+ }), xi(r), n.isMobileFeature && G(!0);
1649
+ const o = (t == null ? void 0 : t.training_query) ?? "", c = (t == null ? void 0 : t.notification_badge_query) ?? "";
1650
+ o && (Ge(o), De(o)), c && (He(c), De(c)), n.formCode && (ze(n.formCode), Ae(n.formCode)), Ti(), z(!0);
1651
+ }
1652
+ } catch (e) {
1653
+ ce({
1654
+ message: e.message,
1655
+ type: "error"
1656
+ });
1657
+ }
1658
+ }, Yi = async () => {
1659
+ try {
1660
+ const e = (await J({
1661
+ code: "RETREIVE_DYNAMIC_FEATURE_INFO",
1662
+ parameters: {
1663
+ id: parseInt(x.get("featureId")),
1664
+ menuType: x.get("featureType")
1665
+ }
1666
+ })).data;
1667
+ if (e.result) {
1668
+ let n = e.result[0];
1669
+ const t = (() => {
1670
+ try {
1671
+ return n.mobile_config ? JSON.parse(n.mobile_config) : {};
1672
+ } catch {
1673
+ return {};
1674
+ }
1675
+ })(), r = (p, v = null) => {
1676
+ try {
1677
+ return !p || typeof p != "string" ? v : JSON.parse(p);
1678
+ } catch {
1679
+ return v;
1680
+ }
1681
+ }, o = ((t == null ? void 0 : t.mobile_entities_sync) ?? []).map(
1682
+ (p) => ue == null ? void 0 : ue.find((v) => v.tableName === p)
1683
+ ).filter(Boolean);
1684
+ a.setValue("menuName", n.menuName ? n.menuName : ""), a.setValue(
1685
+ "navigationState",
1686
+ n.navigationState ? n.navigationState : ""
1687
+ ), a.setValue(
1688
+ "isDynamicFeature",
1689
+ n.isDynamicFeature !== void 0 && n.isDynamicFeature !== null ? n.isDynamicFeature : !1
1690
+ ), a.setValue("menuType", n.menuType ? n.menuType : ""), a.setValue(
1691
+ "menuGroup",
1692
+ n.group_id ? n.group_id.toString() : ""
1693
+ ), a.setValue(
1694
+ "isWebFeature",
1695
+ n.isWebFeature ? n.isWebFeature : !1
1696
+ ), a.setValue(
1697
+ "isMobileFeature",
1698
+ n.isMobileFeature ? n.isMobileFeature : !1
1699
+ ), a.setValue("entityName", (t == null ? void 0 : t.entity_name) ?? ""), a.setValue("mobileMode", (t == null ? void 0 : t.mobile_mode) ?? null), a.setValue("icon", (t == null ? void 0 : t.icon) ?? ""), a.setValue(
1700
+ "mobileEntitiesSync",
1701
+ (t == null ? void 0 : t.mobile_entities_sync) ?? []
1702
+ ), a.setValue("conditions", (t == null ? void 0 : t.conditions) ?? ""), a.setValue(
1703
+ "trainingRequired",
1704
+ (t == null ? void 0 : t.training_required) ?? !1
1705
+ ), a.setValue("trainingQuery", (t == null ? void 0 : t.training_query) ?? ""), a.setValue(
1706
+ "notificationBadgeEnabled",
1707
+ (t == null ? void 0 : t.notification_badge_enabled) ?? !1
1708
+ ), a.setValue(
1709
+ "notificationBadgeType",
1710
+ (t == null ? void 0 : t.notification_badge_type) ?? ""
1711
+ ), a.setValue(
1712
+ "notificationBadgeQuery",
1713
+ (t == null ? void 0 : t.notification_badge_query) ?? ""
1714
+ ), xi(o), n.isMobileFeature && G(!0);
1715
+ const c = (t == null ? void 0 : t.training_query) ?? "", s = (t == null ? void 0 : t.notification_badge_query) ?? "";
1716
+ c && (Ge(c), De(c)), s && (He(s), De(s)), z(!0);
1717
+ }
1718
+ } catch (e) {
1719
+ ce({
1720
+ message: e.message,
1721
+ type: "error"
1722
+ });
1723
+ }
1724
+ }, ut = () => {
1725
+ const e = a.getValues("menuType") || "menuType", n = a.getValues("featureConstant") || "feature", t = (c) => c.trim().toLowerCase().split(/\s+/).map(
1726
+ (s, p) => p === 0 ? s : s.charAt(0).toUpperCase() + s.slice(1)
1727
+ ).join("");
1728
+ let r;
1729
+ if (F)
1730
+ r = `view.${e}.${n}`;
1731
+ else {
1732
+ const c = a.getValues("menuName");
1733
+ r = `view.${e}.${t(c)}`;
1734
+ }
1735
+ const o = {
1736
+ permissionId: r,
1737
+ permissionType: { type: "menu" },
1738
+ permissionName: `view ${n}`,
1739
+ permissionDesc: "",
1740
+ enabled: !0,
1741
+ isDefault: !0,
1742
+ childPermissions: [],
1743
+ ...F === !1 && {
1744
+ backendUrl: "",
1745
+ urlType: "",
1746
+ queryCode: ""
1747
+ }
1748
+ };
1749
+ Je([o]);
1750
+ }, ct = (e) => {
1751
+ vi(e);
1752
+ }, mt = (e) => {
1753
+ const n = (e == null ? void 0 : e.map((t) => t == null ? void 0 : t.tableName)) || [];
1754
+ xi(e), a.setValue("mobileEntitiesSync", n);
1755
+ }, pt = (e, n) => {
1756
+ ei(n);
1757
+ };
1758
+ ne(() => {
1759
+ const e = (x == null ? void 0 : x.get("staticOrDynamic")) === "STATIC";
1760
+ f && Ce && x.get("featureId") && !e && dt();
1761
+ }, [f, Ce]);
1762
+ const ft = async () => {
1763
+ const e = (await J({
1764
+ code: "fetch_menu_groups"
1765
+ })).data;
1766
+ Xe(e.result.map((n) => n.menu_type)), yi(e.result);
1767
+ }, ht = async () => {
1768
+ const e = (await J({
1769
+ code: "mfa_retreive_all_table_names"
1770
+ })).data;
1771
+ A(e.result.map((n) => n.table_name));
1772
+ }, gt = async () => {
1773
+ const e = (await J({
1774
+ code: "retrieve_synced_tables"
1775
+ })).data;
1776
+ gi(e == null ? void 0 : e.result);
1777
+ }, Xi = async () => {
1778
+ const e = (await J({
1779
+ code: "mfa_retrieve_separate_feature_forms"
1780
+ })).data;
1781
+ if (e.result) {
1782
+ let n = e.result;
1783
+ L(n);
1784
+ let t = {};
1785
+ return n.forEach((r) => {
1786
+ try {
1787
+ const o = JSON.parse(r.versions);
1788
+ t[r.form_code] = o;
1789
+ } catch (o) {
1790
+ console.error("Invalid JSON in form.versions:", r.versions, o), t[r.form_code] = [];
1791
+ }
1792
+ }), xe(t), t;
1793
+ }
1794
+ }, yt = async () => {
1795
+ try {
1796
+ const { data: e } = await J({
1797
+ code: "user_search_for_selectize",
1798
+ parameters: {
1799
+ searchString: ""
1800
+ }
1801
+ });
1802
+ Bi(e == null ? void 0 : e.result);
1803
+ const n = await $t();
1804
+ An(n.data);
1805
+ } catch (e) {
1806
+ console.error("Error fetching users or roles:", e);
1807
+ }
1808
+ }, De = async (e = "") => {
1809
+ try {
1810
+ const n = (await J({
1811
+ code: "GET_ALL_QUERY_CODE",
1812
+ parameters: { search: e }
1813
+ })).data;
1814
+ Hn((n == null ? void 0 : n.result) || []);
1815
+ } catch (n) {
1816
+ console.error("Error fetching query codes:", n);
1817
+ }
1818
+ }, Ki = () => a.getValues("isMobileFeature") && a.getValues("isWebFeature") ? Re : Re.filter((e) => {
1819
+ const { roleType: n } = e;
1820
+ return !!(n === null || a.getValues("isMobileFeature") && (n === "MOBILE" || n === "BOTH") || a.getValues("isWebFeature") && (n === "WEB" || n === "BOTH"));
1821
+ });
1822
+ ne(() => {
1823
+ if (!(Re != null && Re.length)) return;
1824
+ const e = Le.filter((n) => {
1825
+ if (!n.roleName) return !0;
1826
+ const t = Re.find((o) => o.name === n.roleName);
1827
+ if (!t) return !0;
1828
+ const { roleType: r } = t;
1829
+ return !(!$i && r === "MOBILE" || !Ji && r === "WEB");
1830
+ });
1831
+ $e(e);
1832
+ }, [$i, Ji, Re]);
1833
+ const bt = (e) => {
1834
+ const { firstName: n, lastName: t, userName: r } = e;
1835
+ return !n && !t && !r ? "" : n && !t && !r ? n : `${n} ${t} (${r})`;
1836
+ }, Ti = () => {
1837
+ C(() => {
1838
+ const e = a.getValues("menuType") ? JSON.parse(
1839
+ Ce == null ? void 0 : Ce.find(
1840
+ (t) => t.menu_type === a.getValues("menuType")
1841
+ ).groupNames
1842
+ ) : null, n = e == null ? void 0 : e.filter((t) => t.id !== null);
1843
+ return n != null && n.length || a.setValue("menuGroup", ""), n;
1844
+ });
1845
+ }, vt = (e) => {
1846
+ a.setValue("menuGroup", e.target.value);
1847
+ }, xt = (e) => {
1848
+ e.target.checked ? G(!0) : (G(!1), a.setValue("entityName", null), a.setValue("icon", null), a.setValue("mobileEntitiesSync", null), a.setValue("conditions", null), a.setValue("mobileMode", null));
1849
+ }, Ct = (e) => {
1850
+ e.target.checked || (a.setValue("formCode", null), a.setValue("version", null));
1851
+ }, St = () => {
1852
+ ni("add-parent"), ti(null), ri(null), ai(null), je(!0);
1853
+ }, wt = (e) => {
1854
+ ni("add-child"), ti(e.permissionId), ri(null), ai(null), je(!0);
1855
+ }, Nt = (e) => {
1856
+ ni("edit"), ti(null), ri(e), ai(e.permissionId), je(!0);
1857
+ }, en = (e, n, t) => e.map((r) => r.permissionId === n ? {
1858
+ ...r,
1859
+ childPermissions: [...r.childPermissions || [], t]
1860
+ } : {
1861
+ ...r,
1862
+ childPermissions: en(
1863
+ r.childPermissions || [],
1864
+ n,
1865
+ t
1866
+ )
1867
+ }), nn = (e, n, t) => e.map((r) => r.permissionId === n ? {
1868
+ ...t,
1869
+ childPermissions: r.childPermissions || []
1870
+ } : {
1871
+ ...r,
1872
+ childPermissions: nn(
1873
+ r.childPermissions || [],
1874
+ n,
1875
+ t
1876
+ )
1877
+ }), tn = (e, n) => e.filter((t) => t.permissionId !== n).map((t) => ({
1878
+ ...t,
1879
+ childPermissions: tn(
1880
+ t.childPermissions || [],
1881
+ n
1882
+ )
1883
+ })), kt = (e) => {
1884
+ Je((n) => {
1885
+ let t = [...n];
1886
+ if (Qe === "add-parent")
1887
+ t = [...n, e];
1888
+ else if (Qe === "add-child") {
1889
+ const r = (s, p) => {
1890
+ var v;
1891
+ for (const V of s) {
1892
+ if (V.permissionId === p) return V;
1893
+ if ((v = V.childPermissions) != null && v.length) {
1894
+ const N = r(V.childPermissions, p);
1895
+ if (N) return N;
1896
+ }
1897
+ }
1898
+ return null;
1899
+ }, o = r(n, Ci), c = {
1900
+ ...e,
1901
+ permissionType: typeof o.permissionType == "string" ? { type: o.permissionType } : o.permissionType
1902
+ };
1903
+ t = en(
1904
+ n,
1905
+ Ci,
1906
+ c
1907
+ );
1908
+ } else Qe === "edit" && (t = nn(
1909
+ n,
1910
+ zn,
1911
+ e
1912
+ ));
1913
+ return t;
1914
+ }), je(!1), ni("add-parent"), ti(null), ri(null), ai(null);
1915
+ }, It = (e) => {
1916
+ const n = typeof e == "string" ? e : e.permissionId;
1917
+ Je((t) => tn(t, n));
1918
+ };
1919
+ ne(() => {
1920
+ a.setValue("additionalPermissions", fe);
1921
+ }, [fe, a]);
1922
+ const oi = (e, n = null) => {
1923
+ let t = [];
1924
+ return e.forEach((r) => {
1925
+ const {
1926
+ permissionId: o,
1927
+ permissionType: c,
1928
+ permissionName: s,
1929
+ permissionDesc: p,
1930
+ enabled: v,
1931
+ backendUrl: V,
1932
+ urlType: N,
1933
+ queryCode: he
1934
+ } = r;
1935
+ t.push({
1936
+ permissionId: o,
1937
+ permissionType: c == null ? void 0 : c.type,
1938
+ permissionName: s,
1939
+ permissionDesc: p,
1940
+ parentPermissionId: n,
1941
+ enabled: v,
1942
+ backendUrl: V,
1943
+ urlType: N,
1944
+ queryCode: he
1945
+ }), r.childPermissions && r.childPermissions.length > 0 && (t = t.concat(
1946
+ oi(r.childPermissions, o)
1947
+ ));
1948
+ }), t;
1949
+ }, Tt = () => {
1950
+ (async () => {
1951
+ let e = await Xi();
1952
+ xe(e), ze(a.getValues("formCode"));
1953
+ })();
1954
+ }, rn = JSON.stringify(
1955
+ (q = H.value ? a.getValues("updatedFields") : a.getValues("fields")) == null ? void 0 : q.reduce((e, n) => {
1956
+ var t;
1957
+ return (t = n.value) != null && t.trim() && (e[n.value.trim()] = n.checkbox), e;
1958
+ }, {})
1959
+ ), _t = () => {
1960
+ if (!F && (T == null ? void 0 : T.val) === !1)
1961
+ try {
1962
+ const e = [];
1963
+ ae != null && ae.id && e.push({
1964
+ designationId: null,
1965
+ userId: ae.id,
1966
+ fullName: `${ae.firstName || ""} ${ae.lastName || ""}`.trim(),
1967
+ featureJson: rn
1968
+ }), (we == null ? void 0 : we.length) > 0 && e.push(
1969
+ ...we.map((n) => ({
1970
+ designationId: n.id,
1971
+ roleName: n.name,
1972
+ featureJson: rn
1973
+ }))
1974
+ ), $e((n) => [...n, ...e]), ce({
1975
+ message: "Menu item added successfully",
1976
+ type: "success"
1977
+ }), vi([]), ei({});
1978
+ } catch (e) {
1979
+ console.error(e), ce({
1980
+ message: "Cannot add menu item",
1981
+ type: "error"
1982
+ });
1983
+ }
1984
+ else {
1985
+ const e = [];
1986
+ if (ae != null && ae.id && e.push({
1987
+ type: "user",
1988
+ id: ae.id,
1989
+ name: ae.firstName + " " + ae.lastName
1990
+ }), we.length > 0 && e.push({
1991
+ type: "role",
1992
+ ids: we.map((n) => n.id),
1993
+ names: we.map((n) => n.name)
1994
+ }), e.length === 0) return;
1995
+ $n(e), Si(!0), ei(null), vi([]);
1996
+ }
1997
+ }, an = (e) => {
1998
+ const n = [], t = (r, o) => {
1999
+ for (const c of r)
2000
+ c.enabled && n.push({
2001
+ permission_id: c.permissionId,
2002
+ user_id: o.user_id || null,
2003
+ role_id: o.role_id || null,
2004
+ is_backend_only: o.isBackendOnly || !1,
2005
+ start_date: o.startDate || null,
2006
+ end_date: o.endDate || null
2007
+ });
2008
+ };
2009
+ for (const r of e)
2010
+ t(r.permissions || [], r);
2011
+ return n;
2012
+ }, Dt = (e, n) => {
2013
+ Be((t) => {
2014
+ const r = [...t];
2015
+ return r[e] = {
2016
+ ...r[e],
2017
+ permissions: ln(
2018
+ r[e].permissions,
2019
+ n.permissionId,
2020
+ !n.enabled
2021
+ )
2022
+ }, r;
2023
+ });
2024
+ }, ln = (e, n, t) => e.map((r) => {
2025
+ var o, c;
2026
+ if (r.permissionId === n)
2027
+ return {
2028
+ ...r,
2029
+ enabled: t,
2030
+ childPermissions: (o = r.childPermissions) != null && o.length ? on(r.childPermissions, t) : []
2031
+ };
2032
+ if ((c = r.childPermissions) != null && c.length) {
2033
+ const s = ln(
2034
+ r.childPermissions,
2035
+ n,
2036
+ t
2037
+ ), p = s.length > 0 && s.every((v) => v.enabled === !0);
2038
+ return {
2039
+ ...r,
2040
+ enabled: p,
2041
+ childPermissions: s
2042
+ };
2043
+ }
2044
+ return r;
2045
+ }), on = (e, n) => e.map((t) => {
2046
+ var r;
2047
+ return {
2048
+ ...t,
2049
+ enabled: n,
2050
+ childPermissions: (r = t.childPermissions) != null && r.length ? on(t.childPermissions, n) : []
2051
+ };
2052
+ }), Ft = async (e) => {
2053
+ (await J({
2054
+ code: "check_unique_feature_constant",
2055
+ parameters: {
2056
+ featureConstant: e
2057
+ }
2058
+ })).data.result[0].exists ? a.setError("featureConstant", {
2059
+ type: "manual",
2060
+ message: "Feature constant already exists"
2061
+ }) : We(`${e} Feature constant is available`);
2062
+ }, Vt = async (e) => {
2063
+ (await J({
2064
+ code: "CHECK_UNIQUE_NAVIGATION_STATE",
2065
+ parameters: {
2066
+ featureState: e
2067
+ }
2068
+ })).data.result[0].exists ? a.setError("navigationState", {
2069
+ type: "manual",
2070
+ message: "Feature State already exists"
2071
+ }) : We(`${e} Feature State is available`);
2072
+ }, Pt = cn(Ft, 500), Et = cn(
2073
+ Vt,
2074
+ 500
2075
+ ), sn = jt(
2076
+ async (e, n, t) => {
2077
+ const { data: r } = await J({
2078
+ code: "user_search_for_selectize",
2079
+ parameters: {
2080
+ searchString: e
2081
+ }
2082
+ });
2083
+ n(r.result), t({ firstName: e, lastName: "", userName: "" });
2084
+ },
2085
+ 500
2086
+ ), Wt = async (e) => {
2087
+ const n = oi(fe);
2088
+ let t = {
2089
+ code: "insert_dynamic_feature_into_menu_config",
2090
+ parameters: {
2091
+ menuName: e.menuName ? e.menuName : null,
2092
+ featureConstant: e.featureConstant ? e.featureConstant : null,
2093
+ formCode: e.formCode && e.formCode !== "" ? e.formCode : null,
2094
+ prevFormCode: Me || null,
2095
+ deLinkPrevForm: Me !== e.formCode,
2096
+ menuType: e.menuType ? e.menuType : null,
2097
+ menuGroup: e.menuGroup ? parseInt(e.menuGroup) : null,
2098
+ navigationState: e.navigationState && e.formCode && e.formCode !== "" ? e.navigationState : null,
2099
+ formVersion: e.version ? e.version : null,
2100
+ isMobileFeature: e.isMobileFeature ? e.isMobileFeature : null,
2101
+ isWebFeature: e.isWebFeature ? e.isWebFeature : null,
2102
+ permissions: JSON.stringify(n),
2103
+ mobileConfig: JSON.stringify({
2104
+ entity_name: e.entityName ?? null,
2105
+ mobile_mode: e.mobileMode ? e.mobileMode.toUpperCase() : null,
2106
+ icon: e.icon ?? null,
2107
+ mobile_entities_sync: e.mobileEntitiesSync ?? [],
2108
+ conditions: e.conditions ?? null,
2109
+ training_required: e.trainingRequired ?? !1,
2110
+ training_query: e.trainingQuery ?? null,
2111
+ notification_badge_enabled: e.notificationBadgeEnabled ?? !1,
2112
+ notification_badge_type: e.notificationBadgeType ?? null,
2113
+ notification_badge_query: e.notificationBadgeQuery ?? null
2114
+ })
2115
+ }
2116
+ };
2117
+ try {
2118
+ if (await J(t)) {
2119
+ let r = [];
2120
+ e.menuName && e.menuName.length > 0 && r.push({
2121
+ code: "medplat_form_insert_into_translation_master",
2122
+ parameters: {
2123
+ translation_key: e.menuName.replaceAll(" ", ""),
2124
+ translation_value: e.menuName,
2125
+ form_code: "General"
2126
+ },
2127
+ sequence: 1
2128
+ }), r.length > 0 && await Ei(r);
2129
+ const o = an(Ne);
2130
+ o && await J({
2131
+ code: "GRANT_PERMISSION_USER_MAP",
2132
+ parameters: {
2133
+ permissionUserMap: JSON.stringify(o)
2134
+ }
2135
+ });
2136
+ }
2137
+ ce({
2138
+ message: x.get("featureId") ? "Feature updated successfully" : "New Dynamic feature created successfully!",
2139
+ type: "success"
2140
+ }), ie(!0);
2141
+ } catch (r) {
2142
+ ce({
2143
+ message: r.message,
2144
+ type: "error"
2145
+ });
2146
+ }
2147
+ }, qt = async (e) => {
2148
+ var n, t, r, o;
2149
+ try {
2150
+ let c = null, s = null, p = null;
2151
+ const v = mn();
2152
+ (n = e == null ? void 0 : e.menuGroup) != null && n.length && (c = mn());
2153
+ const V = oi(fe), N = {
2154
+ code: "insert_menu_config",
2155
+ parameters: {
2156
+ UUID: v,
2157
+ featureJson: null,
2158
+ menuGroup: e.menuGroup ? parseInt(e.menuGroup) : null,
2159
+ groupUUID: c,
2160
+ menuName: e.menuName ? e.menuName : null,
2161
+ menuType: e.menuType ? e.menuType : null,
2162
+ navigationState: e.navigationState ? e.navigationState : null,
2163
+ subgroupId: s,
2164
+ subgroupUUID: p,
2165
+ isMobileFeature: e != null && e.isMobileFeature ? e == null ? void 0 : e.isMobileFeature : null,
2166
+ isWebFeature: e != null && e.isWebFeature ? e == null ? void 0 : e.isWebFeature : null,
2167
+ permissions: JSON.stringify(V),
2168
+ isNewFeature: "true",
2169
+ mobileConfig: JSON.stringify({
2170
+ entity_name: (e == null ? void 0 : e.entityName) ?? null,
2171
+ mobile_mode: e != null && e.mobileMode ? e == null ? void 0 : e.mobileMode.toUpperCase() : null,
2172
+ icon: (e == null ? void 0 : e.icon) ?? null,
2173
+ mobile_entities_sync: (e == null ? void 0 : e.mobileEntitiesSync) ?? [],
2174
+ conditions: (e == null ? void 0 : e.conditions) ?? null,
2175
+ training_required: e.trainingRequired ?? !1,
2176
+ training_query: e.trainingQuery ?? null,
2177
+ notification_badge_enabled: e.notificationBadgeEnabled ?? !1,
2178
+ notification_badge_type: e.notificationBadgeType ?? null,
2179
+ notification_badge_query: e.notificationBadgeQuery ?? null
2180
+ })
2181
+ }
2182
+ };
2183
+ if (H.value && (T == null ? void 0 : T.val) === !1) {
2184
+ N.code = "update_menu_config";
2185
+ const { fields: Z, updatedFields: le } = e, Fe = H.value && _e ? un(le) : (t = Z[0]) != null && t.value && _e ? un(Z) : {};
2186
+ a.setValue("featureJson", Fe), delete N.parameters.UUID, delete N.parameters.groupUUID, delete N.parameters.subgroupUUID, delete N.parameters.permissions, delete N.parameters.isNewFeature, N.parameters.featureType = x.get("featureType"), N.parameters.featureId = x.get("featureId"), N.parameters.featureJson = Fe;
2187
+ }
2188
+ let he;
2189
+ if (H.value && (T == null ? void 0 : T.val) === !1) {
2190
+ const { data: Z } = await Jt(N);
2191
+ he = Z, await ur((r = Z == null ? void 0 : Z.result[0]) == null ? void 0 : r.id, Le);
2192
+ } else {
2193
+ H.value && (delete N.parameters.UUID, delete N.parameters.groupUUID, delete N.parameters.subgroupUUID, delete N.parameters.isNewFeature, N.parameters.featureType = x.get("featureType"), N.parameters.featureId = x.get("featureId"));
2194
+ const { data: Z } = await J(N);
2195
+ if (he = Z, Z) {
2196
+ let le = [];
2197
+ e.menuName && e.menuName.length > 0 && le.push({
2198
+ code: "medplat_form_insert_into_translation_master",
2199
+ parameters: {
2200
+ translation_key: e.menuName.replaceAll(" ", ""),
2201
+ translation_value: e.menuName,
2202
+ form_code: "General"
2203
+ },
2204
+ sequence: 1
2205
+ }), le.length > 0 && await Ei(le);
2206
+ const Fe = an(Ne);
2207
+ Fe && await J({
2208
+ code: "GRANT_PERMISSION_USER_MAP",
2209
+ parameters: {
2210
+ permissionUserMap: JSON.stringify(Fe)
2211
+ }
2212
+ });
2213
+ }
2214
+ }
2215
+ (o = he == null ? void 0 : he.result) != null && o.length ? ce({
2216
+ message: H.value ? "FEATURE EDITED SUCCESFULLY" : "FEATURE ADDED SUCCESFULLY",
2217
+ type: "success"
2218
+ }) : ce({
2219
+ message: "FEATURE CONFIGURATION ALREADY EXISTS ",
2220
+ type: "error"
2221
+ }), ie(!0);
2222
+ } catch (c) {
2223
+ ce({
2224
+ message: c.message,
2225
+ type: "error"
2226
+ });
2227
+ }
2228
+ }, dn = async (e) => {
2229
+ F ? Wt(e) : qt(e);
2230
+ }, un = (e) => JSON.stringify(
2231
+ e == null ? void 0 : e.reduce((n, t) => (n[t.value] = t.checkbox, n), {})
2232
+ ), At = (e, n) => {
2233
+ e && e.type === "change" && Rt(n);
2234
+ }, Rt = rr(
2235
+ (e) => {
2236
+ sn(e, Bi, ei);
2237
+ },
2238
+ [sn]
2239
+ ), Bt = () => {
2240
+ li(!_e), _e || (H.value ? a.setValue("updatedFields", [
2241
+ { id: 1, value: "", checkbox: !1 }
2242
+ ]) : a.setValue("fields", [{ id: 1, value: "", checkbox: !1 }]));
2243
+ }, Ot = (e) => {
2244
+ const n = (H.value ? a.getValues("updatedFields") : a.getValues("fields")).map((t) => t.id === e ? { ...t, checkbox: !t.checkbox } : t);
2245
+ H.value ? a.setValue("updatedFields", n) : a.setValue("fields", n);
2246
+ }, Ut = () => {
2247
+ const e = H.value ? a.getValues("updatedFields") : a.getValues("fields"), n = e[(e == null ? void 0 : e.length) - 1];
2248
+ if ((n == null ? void 0 : n.value.trim()) === "") {
2249
+ alert("Enter the right name before adding a new one.");
2250
+ return;
2251
+ }
2252
+ const t = {
2253
+ id: e.length + 1,
2254
+ value: "",
2255
+ checkbox: !1
2256
+ };
2257
+ H.value ? a.setValue("updatedFields", [...e, t]) : a.setValue("fields", [...e, t]);
2258
+ }, zt = (e) => {
2259
+ const n = (H.value ? a.getValues("updatedFields") : a.getValues("fields")).filter((t) => t.id !== e);
2260
+ H.value ? a.setValue("updatedFields", n) : a.setValue("fields", n), (n == null ? void 0 : n.length) === 0 && (H.value ? li(!0) : li(!1));
2261
+ };
2262
+ return /* @__PURE__ */ i(
2263
+ "form",
2264
+ {
2265
+ noValidate: !0,
2266
+ ref: te,
2267
+ onSubmit: a.handleSubmit(dn),
2268
+ method: "POST",
2269
+ children: /* @__PURE__ */ i(d, { sx: { width: "100%", p: 3, borderRadius: 2 }, children: /* @__PURE__ */ l(d, { sx: { display: "flex" }, children: [
2270
+ /* @__PURE__ */ i(
2271
+ d,
2272
+ {
2273
+ sx: {
2274
+ width: "30%",
2275
+ maxHeight: "87vh",
2276
+ background: `linear-gradient(to right, ${de.palette.custom.featureList || "#3576BA"}, ${de.palette.custom.black2 || "#1C2128"})`,
2277
+ p: 3,
2278
+ borderTopLeftRadius: 16,
2279
+ borderBottomLeftRadius: 16,
2280
+ borderTopRightRadius: 0,
2281
+ borderBottomRightRadius: 0,
2282
+ display: "flex",
2283
+ flexDirection: "column",
2284
+ justifyContent: "center",
2285
+ gap: 5
2286
+ },
2287
+ children: R.map((e, n) => {
2288
+ const t = n === y, r = ot(n), o = Ze.some((V) => V.key === e.key) && !r && !t, c = !o && !r && !t;
2289
+ let s = "transparent", p = "2px solid rgba(255,255,255,0.5)", v = "white";
2290
+ return t ? (s = "#BEE2FD", v = "#1e3a8a", p = "2px solid #BEE2FD") : r ? (s = "white", v = "#4caf50", p = "2px solid #4caf50") : o ? (s = "transparent", v = "white", p = "2px solid #BEE2FD") : c && (s = "transparent", v = "rgba(255,255,255,0.5)", p = "2px solid rgba(255,255,255,0.2)"), /* @__PURE__ */ i(Qt, { sx: { p: 0, m: 0 }, children: /* @__PURE__ */ l(
2291
+ d,
2292
+ {
2293
+ sx: {
2294
+ display: "flex",
2295
+ alignItems: "center",
2296
+ position: "relative",
2297
+ backgroundColor: t ? "custom.gray3" : "transparent",
2298
+ px: 1,
2299
+ py: 1,
2300
+ transition: "all 0.3s ease",
2301
+ borderRadius: 2,
2302
+ minHeight: 64
2303
+ },
2304
+ children: [
2305
+ n < (R == null ? void 0 : R.length) - 1 && /* @__PURE__ */ i(
2306
+ d,
2307
+ {
2308
+ sx: {
2309
+ position: "absolute",
2310
+ top: "45%",
2311
+ left: 22,
2312
+ height: "calc(100% + -10px)",
2313
+ width: 2,
2314
+ backgroundColor: "white",
2315
+ opacity: c ? 0.3 : 1,
2316
+ zIndex: 0,
2317
+ transform: "translateY(50%)"
2318
+ }
2319
+ }
2320
+ ),
2321
+ /* @__PURE__ */ i(
2322
+ d,
2323
+ {
2324
+ sx: {
2325
+ width: 32,
2326
+ height: 32,
2327
+ borderRadius: "50%",
2328
+ backgroundColor: s,
2329
+ border: p,
2330
+ color: v,
2331
+ fontWeight: "bold",
2332
+ fontSize: 14,
2333
+ display: "flex",
2334
+ alignItems: "center",
2335
+ justifyContent: "center",
2336
+ zIndex: 1,
2337
+ flexShrink: 0
2338
+ },
2339
+ children: r && !t ? /* @__PURE__ */ i(oe, { iconName: "faCheck", size: "lg" }) : n + 1
2340
+ }
2341
+ ),
2342
+ /* @__PURE__ */ l(d, { sx: { ml: 2 }, children: [
2343
+ /* @__PURE__ */ l(
2344
+ m,
2345
+ {
2346
+ variant: "caption",
2347
+ sx: {
2348
+ color: r ? "primary.main" : "white",
2349
+ fontWeight: "bold",
2350
+ textTransform: "uppercase",
2351
+ fontSize: 14,
2352
+ opacity: c ? 0.5 : 1
2353
+ },
2354
+ children: [
2355
+ "STEP ",
2356
+ n + 1
2357
+ ]
2358
+ }
2359
+ ),
2360
+ /* @__PURE__ */ i(
2361
+ m,
2362
+ {
2363
+ variant: "subtitle2",
2364
+ sx: {
2365
+ color: r ? "primary.main" : "white",
2366
+ fontWeight: "bold",
2367
+ textTransform: "uppercase",
2368
+ fontSize: 14,
2369
+ opacity: c ? 0.5 : 1
2370
+ },
2371
+ children: e.label
2372
+ }
2373
+ )
2374
+ ] })
2375
+ ]
2376
+ }
2377
+ ) }, e.key);
2378
+ })
2379
+ }
2380
+ ),
2381
+ /* @__PURE__ */ l(
2382
+ d,
2383
+ {
2384
+ sx: {
2385
+ width: "80%",
2386
+ backgroundColor: "background.paper",
2387
+ padding: 2,
2388
+ borderRadius: "10px",
2389
+ display: "flex",
2390
+ flexDirection: "column",
2391
+ maxHeight: "87vh",
2392
+ overflowY: "auto"
2393
+ },
2394
+ children: [
2395
+ ((E = R[y]) == null ? void 0 : E.key) === "featureDetails" && /* @__PURE__ */ i(d, { display: "flex", justifyContent: "center", children: /* @__PURE__ */ l(d, { width: "80%", children: [
2396
+ /* @__PURE__ */ i(
2397
+ m,
2398
+ {
2399
+ variant: "h5",
2400
+ sx: {
2401
+ fontWeight: "bold",
2402
+ textAlign: "center",
2403
+ marginBottom: 1,
2404
+ marginTop: 2
2405
+ },
2406
+ children: u("Feature Details")
2407
+ }
2408
+ ),
2409
+ /* @__PURE__ */ i(
2410
+ m,
2411
+ {
2412
+ sx: { textAlign: "center", marginBottom: 4, color: "grey" },
2413
+ children: "Please provide the necessary details for the new feature, including its name, constant, and where it should be linked in the menu."
2414
+ }
2415
+ ),
2416
+ /* @__PURE__ */ i(j, { children: /* @__PURE__ */ l(
2417
+ K,
2418
+ {
2419
+ variant: "outlined",
2420
+ className: "m-3 flex flex-row items-center w-[80%] justify-between",
2421
+ children: [
2422
+ /* @__PURE__ */ l(
2423
+ m,
2424
+ {
2425
+ variant: "subtitle1",
2426
+ className: "whitespace-nowrap",
2427
+ children: [
2428
+ u("Is"),
2429
+ " ",
2430
+ u("dynamic"),
2431
+ " ",
2432
+ u("feature? "),
2433
+ ":"
2434
+ ]
2435
+ }
2436
+ ),
2437
+ /* @__PURE__ */ i(d, { className: "w-[60%]", children: /* @__PURE__ */ i(
2438
+ M,
2439
+ {
2440
+ name: "isDynamicFeature",
2441
+ control: a.control,
2442
+ rules: { required: "Required field" },
2443
+ render: ({ field: e }) => /* @__PURE__ */ i(
2444
+ ke,
2445
+ {
2446
+ checked: e.value,
2447
+ disabled: !!x.get("featureId"),
2448
+ onChange: (n) => {
2449
+ e.onChange(n.target.checked), Ct(n);
2450
+ }
2451
+ }
2452
+ )
2453
+ }
2454
+ ) })
2455
+ ]
2456
+ }
2457
+ ) }),
2458
+ /* @__PURE__ */ i(j, { children: /* @__PURE__ */ l(
2459
+ K,
2460
+ {
2461
+ variant: "outlined",
2462
+ className: " m-3 flex flex-row items-center w-[80%] justify-between",
2463
+ children: [
2464
+ /* @__PURE__ */ l(m, { variant: "subtitle1", children: [
2465
+ u("Feature"),
2466
+ " ",
2467
+ u("Name"),
2468
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" }),
2469
+ " :"
2470
+ ] }),
2471
+ /* @__PURE__ */ i(d, { className: "w-[60%]", children: /* @__PURE__ */ i(
2472
+ ee,
2473
+ {
2474
+ control: a.control,
2475
+ id: "menuName",
2476
+ name: "menuName",
2477
+ errors: a.formState.errors,
2478
+ disabled: Ui,
2479
+ placeholder: "Feature Name"
2480
+ }
2481
+ ) })
2482
+ ]
2483
+ }
2484
+ ) }),
2485
+ F ? /* @__PURE__ */ i(j, { children: /* @__PURE__ */ l(
2486
+ K,
2487
+ {
2488
+ variant: "outlined",
2489
+ className: " m-3 flex flex-row items-center w-[80%] justify-between",
2490
+ children: [
2491
+ /* @__PURE__ */ l(m, { variant: "subtitle1", children: [
2492
+ u("Feature"),
2493
+ " ",
2494
+ u("Constant"),
2495
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" }),
2496
+ " :"
2497
+ ] }),
2498
+ /* @__PURE__ */ i(d, { className: "w-[60%]", children: /* @__PURE__ */ i(
2499
+ ee,
2500
+ {
2501
+ control: a.control,
2502
+ id: "featureConstant",
2503
+ name: "featureConstant",
2504
+ errors: a.formState.errors,
2505
+ successMessage: Ee,
2506
+ placeholder: "Feature Constant",
2507
+ disabled: $,
2508
+ onChange: (e) => Pt(e.target.value)
2509
+ }
2510
+ ) })
2511
+ ]
2512
+ }
2513
+ ) }, "static-feature") : /* @__PURE__ */ i(j, { children: /* @__PURE__ */ l(
2514
+ K,
2515
+ {
2516
+ variant: "outlined",
2517
+ className: " m-2 flex flex-row items-center w-[80%] justify-between",
2518
+ children: [
2519
+ /* @__PURE__ */ l(m, { variant: "subtitle1", children: [
2520
+ u("Feature"),
2521
+ " ",
2522
+ u("State"),
2523
+ /* @__PURE__ */ i("span", { className: "text-red-500 mx-1", children: "*" }),
2524
+ /* @__PURE__ */ i(
2525
+ ge,
2526
+ {
2527
+ title: /* @__PURE__ */ i(
2528
+ m,
2529
+ {
2530
+ fontSize: 12,
2531
+ maxWidth: 200,
2532
+ sx: { whiteSpace: "pre-line" },
2533
+ children: `Must follow one of these formats:
2534
+ • techo.*
2535
+ • medplat.*
2536
+ • medplat.form.*`
2537
+ }
2538
+ ),
2539
+ size: "sm"
2540
+ }
2541
+ )
2542
+ ] }),
2543
+ /* @__PURE__ */ i(d, { className: "w-[60%]", children: /* @__PURE__ */ i(
2544
+ ee,
2545
+ {
2546
+ control: a.control,
2547
+ id: "navigationState",
2548
+ name: "navigationState",
2549
+ placeholder: "Feature State",
2550
+ disabled: Ui || $,
2551
+ successMessage: Ee,
2552
+ dataTestId: "managefeature-textfield-feature-state",
2553
+ errors: a.formState.errors,
2554
+ onChange: (e) => Et(
2555
+ e.target.value
2556
+ )
2557
+ }
2558
+ ) })
2559
+ ]
2560
+ }
2561
+ ) }, "dynamic-feature"),
2562
+ /* @__PURE__ */ i(j, { children: /* @__PURE__ */ l(
2563
+ K,
2564
+ {
2565
+ variant: "outlined",
2566
+ className: " m-3 flex flex-row items-center w-[80%] justify-between",
2567
+ children: [
2568
+ /* @__PURE__ */ l(m, { variant: "subtitle1", children: [
2569
+ u("Link"),
2570
+ " ",
2571
+ u("to"),
2572
+ " ",
2573
+ u("Menu"),
2574
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" }),
2575
+ " :"
2576
+ ] }),
2577
+ /* @__PURE__ */ i(d, { className: " w-[60%]", children: /* @__PURE__ */ i(
2578
+ Ve,
2579
+ {
2580
+ control: a.control,
2581
+ name: "menuType",
2582
+ options: bi,
2583
+ errors: a.formState.errors,
2584
+ disableClearable: !1,
2585
+ onChange: (e) => {
2586
+ a.setValue("menuType", e.target.value), Ti();
2587
+ }
2588
+ }
2589
+ ) })
2590
+ ]
2591
+ }
2592
+ ) }),
2593
+ /* @__PURE__ */ i(j, { children: (pe == null ? void 0 : pe.length) > 0 && /* @__PURE__ */ l(
2594
+ K,
2595
+ {
2596
+ variant: "outlined",
2597
+ className: " m-3 flex flex-row items-center w-[80%] justify-between",
2598
+ children: [
2599
+ /* @__PURE__ */ l(m, { variant: "subtitle1", children: [
2600
+ u("Menu"),
2601
+ " ",
2602
+ u("SubGroup"),
2603
+ " :"
2604
+ ] }),
2605
+ /* @__PURE__ */ i(d, { className: " w-[60%]", children: /* @__PURE__ */ i(
2606
+ Ve,
2607
+ {
2608
+ control: a.control,
2609
+ name: "menuGroup",
2610
+ errors: a.formState.errors,
2611
+ displayName: "name",
2612
+ optionValue: "id",
2613
+ options: pe,
2614
+ disableClearable: !1,
2615
+ onChange: vt
2616
+ }
2617
+ ) })
2618
+ ]
2619
+ }
2620
+ ) }),
2621
+ /* @__PURE__ */ i(j, { children: /* @__PURE__ */ l(
2622
+ K,
2623
+ {
2624
+ variant: "outlined",
2625
+ className: "m-3 flex flex-row items-center w-[80%] justify-between",
2626
+ children: [
2627
+ /* @__PURE__ */ l(
2628
+ m,
2629
+ {
2630
+ variant: "subtitle1",
2631
+ className: "whitespace-nowrap",
2632
+ children: [
2633
+ u("Enable"),
2634
+ " ",
2635
+ u("feature"),
2636
+ " ",
2637
+ u("for"),
2638
+ ":"
2639
+ ]
2640
+ }
2641
+ ),
2642
+ /* @__PURE__ */ l(d, { className: "w-[60%] flex flex-row gap-6 items-center", children: [
2643
+ /* @__PURE__ */ l(d, { className: "flex items-center gap-1", children: [
2644
+ /* @__PURE__ */ i(m, { variant: "subtitle1", children: u("Web") }),
2645
+ /* @__PURE__ */ i(
2646
+ M,
2647
+ {
2648
+ name: "isWebFeature",
2649
+ control: a.control,
2650
+ render: ({ field: e }) => /* @__PURE__ */ i(
2651
+ ke,
2652
+ {
2653
+ ...e,
2654
+ checked: e.value,
2655
+ onChange: (n) => e.onChange(n.target.checked)
2656
+ }
2657
+ )
2658
+ }
2659
+ )
2660
+ ] }),
2661
+ /* @__PURE__ */ l(d, { className: "flex items-center gap-1", children: [
2662
+ /* @__PURE__ */ i(m, { variant: "subtitle1", children: u("Mobile") }),
2663
+ /* @__PURE__ */ i(
2664
+ M,
2665
+ {
2666
+ name: "isMobileFeature",
2667
+ control: a.control,
2668
+ render: ({ field: e }) => /* @__PURE__ */ i(
2669
+ ke,
2670
+ {
2671
+ ...e,
2672
+ checked: e.value,
2673
+ onChange: (n) => {
2674
+ e.onChange(n.target.checked), xt(n);
2675
+ }
2676
+ }
2677
+ )
2678
+ }
2679
+ )
2680
+ ] })
2681
+ ] })
2682
+ ]
2683
+ }
2684
+ ) })
2685
+ ] }) }),
2686
+ ((P = R[y]) == null ? void 0 : P.key) === "mobileConfig" && k && /* @__PURE__ */ i(d, { display: "flex", justifyContent: "center", children: /* @__PURE__ */ l(d, { width: "95%", children: [
2687
+ /* @__PURE__ */ i(
2688
+ m,
2689
+ {
2690
+ variant: "h5",
2691
+ sx: { fontWeight: "bold", textAlign: "center", mb: 1 },
2692
+ children: u("Mobile Setup")
2693
+ }
2694
+ ),
2695
+ /* @__PURE__ */ i(
2696
+ m,
2697
+ {
2698
+ sx: { textAlign: "center", mb: 3, color: "grey" },
2699
+ children: "Set up how this feature should behave and appear in the mobile app, including its entity, icon and condition query."
2700
+ }
2701
+ ),
2702
+ /* @__PURE__ */ l(
2703
+ Di,
2704
+ {
2705
+ expanded: wi.basicConfig,
2706
+ onChange: () => Ni((e) => ({
2707
+ ...e,
2708
+ basicConfig: !e.basicConfig
2709
+ })),
2710
+ sx: {
2711
+ mb: 1.5,
2712
+ borderRadius: 2,
2713
+ boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
2714
+ border: "1px solid rgba(33, 150, 243, 0.2)",
2715
+ borderLeft: "4px solid #2196f3",
2716
+ "&:before": { display: "none" },
2717
+ overflow: "hidden"
2718
+ },
2719
+ children: [
2720
+ /* @__PURE__ */ i(
2721
+ Fi,
2722
+ {
2723
+ expandIcon: /* @__PURE__ */ i(oe, { iconName: "faChevronDown", size: "sm" }),
2724
+ sx: {
2725
+ backgroundColor: "rgba(33, 150, 243, 0.06)",
2726
+ "&:hover": {
2727
+ backgroundColor: "rgba(33, 150, 243, 0.12)"
2728
+ },
2729
+ minHeight: 52
2730
+ },
2731
+ children: /* @__PURE__ */ i(m, { fontWeight: 700, fontSize: 15, children: "Basic Config" })
2732
+ }
2733
+ ),
2734
+ /* @__PURE__ */ l(
2735
+ Vi,
2736
+ {
2737
+ sx: { display: "flex", flexDirection: "column", gap: 2 },
2738
+ children: [
2739
+ /* @__PURE__ */ l(
2740
+ d,
2741
+ {
2742
+ display: "flex",
2743
+ flexDirection: "row",
2744
+ alignItems: "center",
2745
+ children: [
2746
+ /* @__PURE__ */ l(
2747
+ d,
2748
+ {
2749
+ display: "flex",
2750
+ alignItems: "center",
2751
+ gap: 2,
2752
+ sx: { width: "50%" },
2753
+ children: [
2754
+ /* @__PURE__ */ l(
2755
+ m,
2756
+ {
2757
+ variant: "subtitle1",
2758
+ sx: { minWidth: "140px", flexShrink: 0 },
2759
+ children: [
2760
+ u("Feature Icon"),
2761
+ " ",
2762
+ /* @__PURE__ */ i("span", { style: { color: "#d32f2f" }, children: "* " }),
2763
+ /* @__PURE__ */ i(
2764
+ ge,
2765
+ {
2766
+ title: /* @__PURE__ */ i(m, { fontSize: 12, maxWidth: 200, children: "Upload Feature Icon" }),
2767
+ size: "sm"
2768
+ }
2769
+ )
2770
+ ]
2771
+ }
2772
+ ),
2773
+ /* @__PURE__ */ i(Gt, { title: "Upload Icon", children: /* @__PURE__ */ i(
2774
+ d,
2775
+ {
2776
+ sx: {
2777
+ transform: "scale(0.55)",
2778
+ transformOrigin: "left center",
2779
+ "& svg": {
2780
+ fontSize: "2.5rem"
2781
+ }
2782
+ },
2783
+ children: /* @__PURE__ */ i(
2784
+ Mt,
2785
+ {
2786
+ onUpload: (e) => a.setValue("icon", e),
2787
+ formControl: a,
2788
+ name: "icon",
2789
+ accept: "image/svg+xml, image/svg",
2790
+ errors: k ? a.formState.errors : null,
2791
+ triggerType: "icon"
2792
+ }
2793
+ )
2794
+ }
2795
+ ) })
2796
+ ]
2797
+ }
2798
+ ),
2799
+ /* @__PURE__ */ l(
2800
+ d,
2801
+ {
2802
+ display: "flex",
2803
+ alignItems: "center",
2804
+ gap: 2,
2805
+ my: 4,
2806
+ sx: { width: "50%" },
2807
+ children: [
2808
+ /* @__PURE__ */ l(
2809
+ m,
2810
+ {
2811
+ variant: "subtitle1",
2812
+ sx: { minWidth: "140px", flexShrink: 0 },
2813
+ children: [
2814
+ u("Mode"),
2815
+ " ",
2816
+ /* @__PURE__ */ i("span", { style: { color: "#d32f2f" }, children: "* " }),
2817
+ /* @__PURE__ */ i(
2818
+ ge,
2819
+ {
2820
+ title: /* @__PURE__ */ i(m, { fontSize: 12, maxWidth: 200, children: "Choose whether this feature should work online or offline" }),
2821
+ size: "sm"
2822
+ }
2823
+ )
2824
+ ]
2825
+ }
2826
+ ),
2827
+ /* @__PURE__ */ i(d, { sx: { display: "flex", flex: 1 }, children: /* @__PURE__ */ i(
2828
+ M,
2829
+ {
2830
+ name: "mobileMode",
2831
+ control: a.control,
2832
+ render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ l(me, { children: [
2833
+ /* @__PURE__ */ l(
2834
+ pn,
2835
+ {
2836
+ value: e.value ?? "",
2837
+ row: !0,
2838
+ ...e,
2839
+ children: [
2840
+ /* @__PURE__ */ i(
2841
+ si,
2842
+ {
2843
+ value: "ONLINE",
2844
+ control: /* @__PURE__ */ i(
2845
+ di,
2846
+ {
2847
+ disabled: $ && Mi !== null
2848
+ }
2849
+ ),
2850
+ label: "Online"
2851
+ }
2852
+ ),
2853
+ /* @__PURE__ */ i(
2854
+ si,
2855
+ {
2856
+ value: "OFFLINE",
2857
+ control: /* @__PURE__ */ i(
2858
+ di,
2859
+ {
2860
+ disabled: $ && Mi !== null
2861
+ }
2862
+ ),
2863
+ label: "Offline"
2864
+ }
2865
+ )
2866
+ ]
2867
+ }
2868
+ ),
2869
+ (n == null ? void 0 : n.message) && /* @__PURE__ */ i(
2870
+ m,
2871
+ {
2872
+ variant: "caption",
2873
+ color: "error",
2874
+ sx: { mt: 0.5 },
2875
+ children: n.message
2876
+ }
2877
+ )
2878
+ ] })
2879
+ }
2880
+ ) })
2881
+ ]
2882
+ }
2883
+ )
2884
+ ]
2885
+ }
2886
+ ),
2887
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
2888
+ /* @__PURE__ */ l(
2889
+ m,
2890
+ {
2891
+ variant: "subtitle1",
2892
+ sx: { minWidth: "140px", flexShrink: 0 },
2893
+ children: [
2894
+ u("Entity Name"),
2895
+ " ",
2896
+ /* @__PURE__ */ i(
2897
+ ge,
2898
+ {
2899
+ title: /* @__PURE__ */ i(m, { fontSize: 12, maxWidth: 200, children: "Select Entity Name" }),
2900
+ size: "sm"
2901
+ }
2902
+ )
2903
+ ]
2904
+ }
2905
+ ),
2906
+ /* @__PURE__ */ i(
2907
+ d,
2908
+ {
2909
+ sx: {
2910
+ display: "flex",
2911
+ alignItems: "center",
2912
+ gap: 2,
2913
+ flex: 1
2914
+ },
2915
+ children: /* @__PURE__ */ i(
2916
+ Ve,
2917
+ {
2918
+ control: a.control,
2919
+ name: "entityName",
2920
+ options: hi || [],
2921
+ errors: k ? a.formState.errors : null,
2922
+ size: "small",
2923
+ disableClearable: !1,
2924
+ sx: { flex: 1 }
2925
+ }
2926
+ )
2927
+ }
2928
+ )
2929
+ ] }),
2930
+ a.getValues("entityName") && ((h = a.getValues("entityName")) == null ? void 0 : h.trim().length) > 0 && /* @__PURE__ */ l(
2931
+ d,
2932
+ {
2933
+ display: "flex",
2934
+ alignItems: "flex-start",
2935
+ gap: 2,
2936
+ my: 2,
2937
+ children: [
2938
+ /* @__PURE__ */ l(
2939
+ m,
2940
+ {
2941
+ variant: "subtitle1",
2942
+ sx: {
2943
+ minWidth: "140px",
2944
+ flexShrink: 0,
2945
+ pt: 0.5
2946
+ },
2947
+ children: [
2948
+ u("Condition Query"),
2949
+ " :",
2950
+ " ",
2951
+ /* @__PURE__ */ i(
2952
+ ge,
2953
+ {
2954
+ title: /* @__PURE__ */ i(m, { fontSize: 12, maxWidth: 200, children: "Write Condition Query in the editor" }),
2955
+ size: "sm"
2956
+ }
2957
+ )
2958
+ ]
2959
+ }
2960
+ ),
2961
+ /* @__PURE__ */ i(
2962
+ d,
2963
+ {
2964
+ flex: 1,
2965
+ sx: {
2966
+ border: "1px solid #bdbdbd",
2967
+ borderRadius: 2,
2968
+ height: "20vh",
2969
+ overflow: "hidden",
2970
+ boxShadow: "0 1px 6px rgba(0, 0, 0, 0.08)"
2971
+ },
2972
+ children: /* @__PURE__ */ i(
2973
+ M,
2974
+ {
2975
+ name: "conditions",
2976
+ control: a.control,
2977
+ render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ l(me, { children: [
2978
+ /* @__PURE__ */ i(
2979
+ Lt,
2980
+ {
2981
+ height: "100%",
2982
+ defaultLanguage: "sql",
2983
+ theme: it == "light" ? "light" : "vs-dark",
2984
+ options: {
2985
+ fontSize: 13,
2986
+ minimap: { enabled: !1 },
2987
+ automaticLayout: !0,
2988
+ scrollBeyondLastLine: !1,
2989
+ wordWrap: "on",
2990
+ occurrencesHighlight: !1,
2991
+ selectionHighlight: !1
2992
+ },
2993
+ value: e.value || "",
2994
+ onChange: e.onChange,
2995
+ editorProps: { $blockScrolling: !0 }
2996
+ }
2997
+ ),
2998
+ (n == null ? void 0 : n.message) && /* @__PURE__ */ i(
2999
+ m,
3000
+ {
3001
+ variant: "caption",
3002
+ color: "error",
3003
+ sx: { mt: 0.75, ml: 1 },
3004
+ children: n.message
3005
+ }
3006
+ )
3007
+ ] })
3008
+ }
3009
+ )
3010
+ }
3011
+ )
3012
+ ]
3013
+ }
3014
+ ),
3015
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
3016
+ /* @__PURE__ */ l(
3017
+ m,
3018
+ {
3019
+ variant: "subtitle1",
3020
+ sx: { minWidth: "140px", flexShrink: 0 },
3021
+ children: [
3022
+ u("Tables to sync"),
3023
+ " ",
3024
+ /* @__PURE__ */ i(
3025
+ ge,
3026
+ {
3027
+ title: /* @__PURE__ */ i(m, { fontSize: 12, maxWidth: 200, children: "Select at least one table to sync" }),
3028
+ size: "sm"
3029
+ }
3030
+ )
3031
+ ]
3032
+ }
3033
+ ),
3034
+ /* @__PURE__ */ i(
3035
+ d,
3036
+ {
3037
+ sx: {
3038
+ display: "flex",
3039
+ alignItems: "center",
3040
+ gap: 2,
3041
+ flex: 1
3042
+ },
3043
+ children: /* @__PURE__ */ i(
3044
+ Pe,
3045
+ {
3046
+ id: "mobileEntitiesSync",
3047
+ name: "mobileEntitiesSync",
3048
+ control: a.control,
3049
+ options: ue,
3050
+ onChange: (e, n) => mt(n),
3051
+ getOptionLabel: (e) => e == null ? void 0 : e.tableName,
3052
+ checkEquality: "tableName",
3053
+ errors: k ? a.formState.errors : null,
3054
+ dataTestId: "syncentities-select-table",
3055
+ value: Rn,
3056
+ fullWidth: !0
3057
+ }
3058
+ )
3059
+ }
3060
+ )
3061
+ ] })
3062
+ ]
3063
+ }
3064
+ )
3065
+ ]
3066
+ }
3067
+ ),
3068
+ /* @__PURE__ */ l(
3069
+ Di,
3070
+ {
3071
+ expanded: wi.trainingConfig,
3072
+ onChange: () => Ni((e) => ({
3073
+ ...e,
3074
+ trainingConfig: !e.trainingConfig
3075
+ })),
3076
+ sx: {
3077
+ mb: 1.5,
3078
+ borderRadius: 2,
3079
+ boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
3080
+ border: "1px solid rgba(76, 175, 80, 0.2)",
3081
+ borderLeft: "4px solid #4caf50",
3082
+ "&:before": { display: "none" },
3083
+ overflow: "hidden"
3084
+ },
3085
+ children: [
3086
+ /* @__PURE__ */ i(
3087
+ Fi,
3088
+ {
3089
+ expandIcon: /* @__PURE__ */ i(oe, { iconName: "faChevronDown", size: "sm" }),
3090
+ sx: {
3091
+ backgroundColor: "rgba(76, 175, 80, 0.06)",
3092
+ "&:hover": {
3093
+ backgroundColor: "rgba(76, 175, 80, 0.12)"
3094
+ },
3095
+ minHeight: 52
3096
+ },
3097
+ children: /* @__PURE__ */ i(m, { fontWeight: 700, fontSize: 15, children: "Training Config" })
3098
+ }
3099
+ ),
3100
+ /* @__PURE__ */ l(
3101
+ Vi,
3102
+ {
3103
+ sx: { display: "flex", flexDirection: "column", gap: 2 },
3104
+ children: [
3105
+ /* @__PURE__ */ l(
3106
+ d,
3107
+ {
3108
+ display: "flex",
3109
+ alignItems: "center",
3110
+ justifyContent: "space-between",
3111
+ children: [
3112
+ /* @__PURE__ */ l(
3113
+ m,
3114
+ {
3115
+ variant: "subtitle1",
3116
+ sx: { minWidth: "200px", flexShrink: 0 },
3117
+ children: [
3118
+ u("Training Required"),
3119
+ " ",
3120
+ /* @__PURE__ */ i(
3121
+ ge,
3122
+ {
3123
+ title: /* @__PURE__ */ i(m, { fontSize: 12, maxWidth: 220, children: mi(
3124
+ "Enable if the user must complete training before accessing this feature"
3125
+ ) }),
3126
+ size: "sm"
3127
+ }
3128
+ )
3129
+ ]
3130
+ }
3131
+ ),
3132
+ /* @__PURE__ */ i(d, { sx: { flex: 1 }, children: /* @__PURE__ */ i(
3133
+ M,
3134
+ {
3135
+ name: "trainingRequired",
3136
+ control: a.control,
3137
+ render: ({ field: e }) => /* @__PURE__ */ i(
3138
+ ke,
3139
+ {
3140
+ ...e,
3141
+ checked: !!e.value,
3142
+ onChange: (n) => {
3143
+ e.onChange(n.target.checked), n.target.checked || (a.setValue("trainingQuery", ""), Ge(""));
3144
+ }
3145
+ }
3146
+ )
3147
+ }
3148
+ ) })
3149
+ ]
3150
+ }
3151
+ ),
3152
+ a.watch("trainingRequired") && /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
3153
+ /* @__PURE__ */ l(
3154
+ m,
3155
+ {
3156
+ variant: "subtitle1",
3157
+ sx: { minWidth: "200px", flexShrink: 0 },
3158
+ children: [
3159
+ u("Training Query"),
3160
+ " ",
3161
+ /* @__PURE__ */ i(
3162
+ ge,
3163
+ {
3164
+ title: /* @__PURE__ */ i(m, { fontSize: 12, maxWidth: 220, children: mi(
3165
+ "Select a query that returns a boolean — true if training is completed, false otherwise"
3166
+ ) }),
3167
+ size: "sm"
3168
+ }
3169
+ )
3170
+ ]
3171
+ }
3172
+ ),
3173
+ /* @__PURE__ */ i(d, { sx: { flex: 1 }, children: /* @__PURE__ */ i(
3174
+ M,
3175
+ {
3176
+ name: "trainingQuery",
3177
+ control: a.control,
3178
+ render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ i(
3179
+ Pe,
3180
+ {
3181
+ id: "trainingQuery",
3182
+ name: "trainingQuery",
3183
+ control: a.control,
3184
+ options: Oe,
3185
+ getOptionLabel: (t) => (t == null ? void 0 : t.code) || "",
3186
+ checkEquality: "code",
3187
+ inputValue: Zn,
3188
+ disableClearable: !1,
3189
+ singleSelect: !0,
3190
+ value: (Oe == null ? void 0 : Oe.find(
3191
+ (t) => t.code === e.value
3192
+ )) || null,
3193
+ onInputChange: (t, r, o) => {
3194
+ o === "input" && (Ge(r), De(r));
3195
+ },
3196
+ onChange: (t, r) => {
3197
+ e.onChange((r == null ? void 0 : r.code) || ""), Ge((r == null ? void 0 : r.code) || "");
3198
+ },
3199
+ placeholder: "Search training query code...",
3200
+ errors: n,
3201
+ fullWidth: !0,
3202
+ freeSolo: !1
3203
+ }
3204
+ )
3205
+ }
3206
+ ) })
3207
+ ] })
3208
+ ]
3209
+ }
3210
+ )
3211
+ ]
3212
+ }
3213
+ ),
3214
+ /* @__PURE__ */ l(
3215
+ Di,
3216
+ {
3217
+ expanded: wi.notificationConfig,
3218
+ onChange: () => Ni((e) => ({
3219
+ ...e,
3220
+ notificationConfig: !e.notificationConfig
3221
+ })),
3222
+ sx: {
3223
+ mb: 1.5,
3224
+ borderRadius: 2,
3225
+ boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
3226
+ border: "1px solid rgba(255, 152, 0, 0.2)",
3227
+ borderLeft: "4px solid #ff9800",
3228
+ "&:before": { display: "none" },
3229
+ overflow: "hidden"
3230
+ },
3231
+ children: [
3232
+ /* @__PURE__ */ i(
3233
+ Fi,
3234
+ {
3235
+ expandIcon: /* @__PURE__ */ i(oe, { iconName: "faChevronDown", size: "sm" }),
3236
+ sx: {
3237
+ backgroundColor: "rgba(255, 152, 0, 0.06)",
3238
+ "&:hover": {
3239
+ backgroundColor: "rgba(255, 152, 0, 0.12)"
3240
+ },
3241
+ minHeight: 52
3242
+ },
3243
+ children: /* @__PURE__ */ l(m, { fontWeight: 700, fontSize: 15, children: [
3244
+ u("Notification Config"),
3245
+ " "
3246
+ ] })
3247
+ }
3248
+ ),
3249
+ /* @__PURE__ */ l(
3250
+ Vi,
3251
+ {
3252
+ sx: { display: "flex", flexDirection: "column", gap: 2 },
3253
+ children: [
3254
+ /* @__PURE__ */ l(
3255
+ d,
3256
+ {
3257
+ display: "flex",
3258
+ alignItems: "center",
3259
+ justifyContent: "space-between",
3260
+ children: [
3261
+ /* @__PURE__ */ l(
3262
+ m,
3263
+ {
3264
+ variant: "subtitle1",
3265
+ sx: { minWidth: "200px", flexShrink: 0 },
3266
+ children: [
3267
+ u("Enable Notification Badge"),
3268
+ " ",
3269
+ /* @__PURE__ */ i(
3270
+ ge,
3271
+ {
3272
+ title: /* @__PURE__ */ i(m, { fontSize: 12, maxWidth: 220, children: mi(
3273
+ "Show a count or nudge badge on this feature's icon in the mobile app"
3274
+ ) }),
3275
+ size: "sm"
3276
+ }
3277
+ )
3278
+ ]
3279
+ }
3280
+ ),
3281
+ /* @__PURE__ */ i(d, { sx: { flex: 1 }, children: /* @__PURE__ */ i(
3282
+ M,
3283
+ {
3284
+ name: "notificationBadgeEnabled",
3285
+ control: a.control,
3286
+ render: ({ field: e }) => /* @__PURE__ */ i(
3287
+ ke,
3288
+ {
3289
+ ...e,
3290
+ checked: !!e.value,
3291
+ onChange: (n) => {
3292
+ e.onChange(n.target.checked), n.target.checked || (a.setValue(
3293
+ "notificationBadgeType",
3294
+ ""
3295
+ ), a.setValue(
3296
+ "notificationBadgeQuery",
3297
+ ""
3298
+ ), He(""));
3299
+ }
3300
+ }
3301
+ )
3302
+ }
3303
+ ) })
3304
+ ]
3305
+ }
3306
+ ),
3307
+ a.watch("notificationBadgeEnabled") && /* @__PURE__ */ l(me, { children: [
3308
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
3309
+ /* @__PURE__ */ l(
3310
+ m,
3311
+ {
3312
+ variant: "subtitle1",
3313
+ sx: { minWidth: "200px", flexShrink: 0 },
3314
+ children: [
3315
+ u("Badge Type"),
3316
+ " ",
3317
+ /* @__PURE__ */ i(
3318
+ ge,
3319
+ {
3320
+ title: /* @__PURE__ */ i(m, { fontSize: 12, maxWidth: 220, children: mi(
3321
+ `Count Based: query returns a number.
3322
+
3323
+ Nudge Based: query returns true/false.`
3324
+ ) }),
3325
+ size: "sm"
3326
+ }
3327
+ )
3328
+ ]
3329
+ }
3330
+ ),
3331
+ /* @__PURE__ */ i(d, { sx: { flex: 1 }, children: /* @__PURE__ */ i(
3332
+ M,
3333
+ {
3334
+ name: "notificationBadgeType",
3335
+ control: a.control,
3336
+ render: ({ field: e }) => /* @__PURE__ */ l(pn, { row: !0, ...e, children: [
3337
+ /* @__PURE__ */ i(
3338
+ si,
3339
+ {
3340
+ value: "COUNT",
3341
+ control: /* @__PURE__ */ i(di, {}),
3342
+ label: "Count Based"
3343
+ }
3344
+ ),
3345
+ /* @__PURE__ */ i(
3346
+ si,
3347
+ {
3348
+ value: "NUDGE",
3349
+ control: /* @__PURE__ */ i(di, {}),
3350
+ label: "Nudge Based"
3351
+ }
3352
+ )
3353
+ ] })
3354
+ }
3355
+ ) })
3356
+ ] }),
3357
+ a.watch("notificationBadgeType") && /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
3358
+ /* @__PURE__ */ l(
3359
+ m,
3360
+ {
3361
+ variant: "subtitle1",
3362
+ sx: { minWidth: "200px", flexShrink: 0 },
3363
+ children: [
3364
+ a.watch("notificationBadgeType") === "COUNT" ? "Count Query" : "Nudge Query",
3365
+ " ",
3366
+ /* @__PURE__ */ i(
3367
+ ge,
3368
+ {
3369
+ title: /* @__PURE__ */ i(m, { fontSize: 12, maxWidth: 220, children: a.watch(
3370
+ "notificationBadgeType"
3371
+ ) === "COUNT" ? "Select a query that returns a numeric count for the badge" : "Select a query that returns true/false to show or hide the badge" }),
3372
+ size: "sm"
3373
+ }
3374
+ )
3375
+ ]
3376
+ }
3377
+ ),
3378
+ /* @__PURE__ */ i(d, { sx: { flex: 1 }, children: /* @__PURE__ */ i(
3379
+ M,
3380
+ {
3381
+ name: "notificationBadgeQuery",
3382
+ control: a.control,
3383
+ render: ({
3384
+ field: e,
3385
+ fieldState: { error: n }
3386
+ }) => /* @__PURE__ */ i(
3387
+ Pe,
3388
+ {
3389
+ id: "notificationBadgeQuery",
3390
+ name: "notificationBadgeQuery",
3391
+ control: a.control,
3392
+ options: Oe,
3393
+ getOptionLabel: (t) => (t == null ? void 0 : t.code) || "",
3394
+ checkEquality: "code",
3395
+ inputValue: Yn,
3396
+ disableClearable: !1,
3397
+ singleSelect: !0,
3398
+ value: (Oe == null ? void 0 : Oe.find(
3399
+ (t) => t.code === e.value
3400
+ )) || null,
3401
+ onInputChange: (t, r, o) => {
3402
+ o === "input" && (He(r), De(r));
3403
+ },
3404
+ onChange: (t, r) => {
3405
+ e.onChange((r == null ? void 0 : r.code) || ""), He(
3406
+ (r == null ? void 0 : r.code) || ""
3407
+ );
3408
+ },
3409
+ placeholder: a.watch(
3410
+ "notificationBadgeType"
3411
+ ) === "COUNT" ? "Search count query code..." : "Search nudge query code...",
3412
+ errors: n,
3413
+ fullWidth: !0,
3414
+ freeSolo: !1
3415
+ }
3416
+ )
3417
+ }
3418
+ ) })
3419
+ ] })
3420
+ ] })
3421
+ ]
3422
+ }
3423
+ )
3424
+ ]
3425
+ }
3426
+ )
3427
+ ] }) }),
3428
+ ((I = R[y]) == null ? void 0 : I.key) === "formLinking" && F && /* @__PURE__ */ i(d, { display: "flex", justifyContent: "center", children: /* @__PURE__ */ l(d, { width: "80%", children: [
3429
+ /* @__PURE__ */ i(
3430
+ m,
3431
+ {
3432
+ variant: "h5",
3433
+ sx: {
3434
+ fontWeight: "bold",
3435
+ textAlign: "center",
3436
+ marginBottom: 1,
3437
+ marginTop: 2
3438
+ },
3439
+ children: u("Form Linking")
3440
+ }
3441
+ ),
3442
+ /* @__PURE__ */ i(
3443
+ m,
3444
+ {
3445
+ sx: { textAlign: "center", mb: 4, color: "grey" },
3446
+ children: "Link this feature to an existing form, or create a new form to be associated with it."
3447
+ }
3448
+ ),
3449
+ /* @__PURE__ */ l(j, { container: !0, mt: 3, className: "flex flex-col w-[98%]", children: [
3450
+ /* @__PURE__ */ i(
3451
+ m,
3452
+ {
3453
+ variant: "subtitle1",
3454
+ sx: {
3455
+ marginLeft: 1,
3456
+ marginBottom: "0.5rem",
3457
+ fontWeight: 600
3458
+ },
3459
+ children: "Use Existing Form"
3460
+ }
3461
+ ),
3462
+ /* @__PURE__ */ i(j, { container: !0, sx: { alignItems: "center" }, children: /* @__PURE__ */ l(
3463
+ K,
3464
+ {
3465
+ variant: "outlined",
3466
+ className: "m-3 flex flex-row items-center w-[80%] justify-between",
3467
+ children: [
3468
+ /* @__PURE__ */ l(m, { variant: "subtitle1", children: [
3469
+ u("Select"),
3470
+ " ",
3471
+ u("Form"),
3472
+ ":"
3473
+ ] }),
3474
+ /* @__PURE__ */ i(d, { className: "w-[60%]", children: /* @__PURE__ */ i(
3475
+ Ve,
3476
+ {
3477
+ control: a.control,
3478
+ name: "formCode",
3479
+ options: Se || [],
3480
+ getOptionDisabled: (e) => e.menu_config_id && e.menu_config_id !== parseInt(x.get("featureId")),
3481
+ displayName: "form_name",
3482
+ optionValue: "form_code",
3483
+ errors: a.formState.errors,
3484
+ size: "small",
3485
+ disableClearable: !1,
3486
+ onChange: (e) => {
3487
+ e.target.value ? (a.setValue(
3488
+ "navigationState",
3489
+ `medplat.form.${e.target.value}`
3490
+ ), ze(e.target.value)) : (a.setValue("version", null), a.setValue(
3491
+ "navigationState",
3492
+ "medplat.form."
3493
+ ));
3494
+ }
3495
+ }
3496
+ ) })
3497
+ ]
3498
+ }
3499
+ ) }),
3500
+ /* @__PURE__ */ l(
3501
+ K,
3502
+ {
3503
+ variant: "outlined",
3504
+ className: "m-3 flex flex-row items-center w-[80%] justify-between",
3505
+ children: [
3506
+ /* @__PURE__ */ l(m, { variant: "subtitle1", children: [
3507
+ u("Select"),
3508
+ " ",
3509
+ u("Version"),
3510
+ ":"
3511
+ ] }),
3512
+ /* @__PURE__ */ i(d, { className: "w-[60%]", children: /* @__PURE__ */ i(
3513
+ Ve,
3514
+ {
3515
+ control: a.control,
3516
+ name: "version",
3517
+ options: Array.isArray(ve == null ? void 0 : ve[qe]) ? ve[qe].map(
3518
+ (e) => e.version
3519
+ ) : [],
3520
+ errors: a.formState.errors,
3521
+ disableClearable: !1,
3522
+ size: "small"
3523
+ }
3524
+ ) })
3525
+ ]
3526
+ }
3527
+ ),
3528
+ /* @__PURE__ */ i(
3529
+ Ye,
3530
+ {
3531
+ sx: {
3532
+ width: "80%",
3533
+ margin: "1rem auto",
3534
+ position: "relative"
3535
+ },
3536
+ children: /* @__PURE__ */ i(
3537
+ m,
3538
+ {
3539
+ variant: "caption",
3540
+ sx: {
3541
+ position: "absolute",
3542
+ top: "-0.6rem",
3543
+ left: "50%",
3544
+ transform: "translateX(-50%)",
3545
+ backgroundColor: "background.paper",
3546
+ padding: "0 0.5rem"
3547
+ },
3548
+ children: "OR"
3549
+ }
3550
+ )
3551
+ }
3552
+ ),
3553
+ /* @__PURE__ */ l(d, { className: "flex justify-center", children: [
3554
+ /* @__PURE__ */ i(
3555
+ O,
3556
+ {
3557
+ variant: "outlined",
3558
+ size: "small",
3559
+ onClick: () => {
3560
+ a.setValue("formCode", null), Te(!0);
3561
+ },
3562
+ children: "Add New Form"
3563
+ }
3564
+ ),
3565
+ Ie && /* @__PURE__ */ i(
3566
+ Pn,
3567
+ {
3568
+ mainFormCtrl: a,
3569
+ openAddFormModal: Ie,
3570
+ setModal: (e) => {
3571
+ Te(e);
3572
+ },
3573
+ reloadForms: Tt
3574
+ }
3575
+ )
3576
+ ] })
3577
+ ] })
3578
+ ] }) }),
3579
+ ((S = R[y]) == null ? void 0 : S.key) === "additionalPermissions" && /* @__PURE__ */ i(j, { item: !0, xs: 12, md: 6, children: /* @__PURE__ */ l(d, { mt: 3, className: "flex flex-col w-full", children: [
3580
+ /* @__PURE__ */ i(
3581
+ m,
3582
+ {
3583
+ variant: "h5",
3584
+ sx: { fontWeight: "bold", textAlign: "center", mb: 1 },
3585
+ children: "Additional Permissions"
3586
+ }
3587
+ ),
3588
+ /* @__PURE__ */ i(
3589
+ m,
3590
+ {
3591
+ sx: { textAlign: "center", mb: 4, color: "grey" },
3592
+ children: "Define custom permissions for this feature. These will be used to control fine-grained permissions beyond default roles."
3593
+ }
3594
+ ),
3595
+ !F && (T == null ? void 0 : T.val) === !1 ? /* @__PURE__ */ l(me, { children: [
3596
+ /* @__PURE__ */ i(j, { children: /* @__PURE__ */ l(
3597
+ K,
3598
+ {
3599
+ variant: "outlined",
3600
+ className: "flex flex-row items-center ml-3 ",
3601
+ children: [
3602
+ /* @__PURE__ */ i(m, { variant: "body2", children: u("Add feature JSON access rights") }),
3603
+ /* @__PURE__ */ i(
3604
+ fn,
3605
+ {
3606
+ disabled: Jn,
3607
+ checked: _e,
3608
+ onChange: Bt,
3609
+ "data-testid": "managefeature-checkbox-access-rights"
3610
+ }
3611
+ )
3612
+ ]
3613
+ }
3614
+ ) }),
3615
+ /* @__PURE__ */ i(j, { children: H.value && _e && /* @__PURE__ */ i(j, { children: /* @__PURE__ */ i(Ht, { className: "ml-2", children: (X = a.getValues("updatedFields")) == null ? void 0 : X.map((e, n) => {
3616
+ var t;
3617
+ return /* @__PURE__ */ l(
3618
+ j,
3619
+ {
3620
+ className: " mb-2.5 flex flex-row items-center ",
3621
+ children: [
3622
+ /* @__PURE__ */ i(K, { children: /* @__PURE__ */ i(
3623
+ M,
3624
+ {
3625
+ name: `updatedFields[${n}].value`,
3626
+ control: a.control,
3627
+ render: ({ field: r }) => /* @__PURE__ */ i(
3628
+ In,
3629
+ {
3630
+ ...r,
3631
+ label: `${u("Right")} ${n + 1}`,
3632
+ value: r.value || "",
3633
+ sx: {
3634
+ "& .MuiInputLabel-root": {
3635
+ fontSize: "14px"
3636
+ },
3637
+ "& .MuiInputBase-input": {
3638
+ fontSize: "14px"
3639
+ }
3640
+ }
3641
+ }
3642
+ )
3643
+ }
3644
+ ) }),
3645
+ /* @__PURE__ */ i(
3646
+ fn,
3647
+ {
3648
+ disabled: e.updated,
3649
+ checked: e.checkbox,
3650
+ onChange: () => Ot(e.id),
3651
+ className: " mr-2.5",
3652
+ "data-testid": `managefeature-checkbox-updated-right-${n + 1}`
3653
+ }
3654
+ ),
3655
+ n + 1 === ((t = a.getValues("updatedFields")) == null ? void 0 : t.length) && /* @__PURE__ */ i(
3656
+ O,
3657
+ {
3658
+ variant: "contained",
3659
+ color: "primary",
3660
+ onClick: Ut,
3661
+ size: "small",
3662
+ className: " mr-2.5",
3663
+ disabled: !rt.updatedFields.some(
3664
+ (r) => r.id === (e == null ? void 0 : e.id) && r.value
3665
+ ),
3666
+ "data-testid": "managefeature-button-add-updated",
3667
+ children: u("Add")
3668
+ }
3669
+ ),
3670
+ !e.updated && /* @__PURE__ */ i(
3671
+ O,
3672
+ {
3673
+ variant: "contained",
3674
+ size: "small",
3675
+ color: "secondary",
3676
+ onClick: () => zt(e.id),
3677
+ "data-testid": `managefeature-button-delete-updated-${n + 1}`,
3678
+ children: u("Delete")
3679
+ }
3680
+ )
3681
+ ]
3682
+ },
3683
+ e.id
3684
+ );
3685
+ }) }) }) })
3686
+ ] }) : /* @__PURE__ */ l(me, { children: [
3687
+ (fe == null ? void 0 : fe.length) === 0 ? /* @__PURE__ */ i(
3688
+ m,
3689
+ {
3690
+ variant: "subtitle1",
3691
+ color: "text.secondary",
3692
+ align: "center",
3693
+ sx: { py: 2 },
3694
+ children: "No permissions added yet."
3695
+ }
3696
+ ) : /* @__PURE__ */ i(
3697
+ En,
3698
+ {
3699
+ permissions: fe,
3700
+ onEdit: (e) => Nt(e),
3701
+ onRemove: (e) => It(e),
3702
+ handleAddChildClick: (e) => wt(e),
3703
+ isDynamicFeature: F
3704
+ }
3705
+ ),
3706
+ /* @__PURE__ */ i(
3707
+ d,
3708
+ {
3709
+ sx: {
3710
+ display: "flex",
3711
+ justifyContent: "flex-end",
3712
+ mt: 2
3713
+ },
3714
+ children: /* @__PURE__ */ i(
3715
+ O,
3716
+ {
3717
+ variant: "outlined",
3718
+ size: "small",
3719
+ startIcon: /* @__PURE__ */ i(oe, { iconName: "faPlus" }),
3720
+ onClick: St,
3721
+ sx: {
3722
+ textTransform: "none",
3723
+ fontWeight: 500,
3724
+ borderRadius: 2,
3725
+ px: 2,
3726
+ py: 0.75,
3727
+ minWidth: 120
3728
+ },
3729
+ children: "Add Parent Permission"
3730
+ }
3731
+ )
3732
+ }
3733
+ ),
3734
+ /* @__PURE__ */ i(
3735
+ Wn,
3736
+ {
3737
+ open: On,
3738
+ onClose: () => je(!1),
3739
+ onSave: kt,
3740
+ formCtrl: a,
3741
+ editData: Un,
3742
+ parentPermissionId: Qe === "add-child" ? Ci : null,
3743
+ mode: Qe,
3744
+ permissionTypes: Qn,
3745
+ setPermissionTypes: Gn,
3746
+ existingPermissionIds: new Set(
3747
+ oi(fe).map(
3748
+ (e) => e.permissionId
3749
+ )
3750
+ ),
3751
+ isDynamicFeature: F
3752
+ }
3753
+ )
3754
+ ] })
3755
+ ] }) }),
3756
+ ((se = R[y]) == null ? void 0 : se.key) === "assignFeatures" && /* @__PURE__ */ l(d, { mt: 3, className: "flex flex-col w-full", children: [
3757
+ /* @__PURE__ */ i(
3758
+ m,
3759
+ {
3760
+ variant: "h5",
3761
+ sx: { fontWeight: "bold", textAlign: "center", mb: 1 },
3762
+ children: u("Assign Features")
3763
+ }
3764
+ ),
3765
+ /* @__PURE__ */ i(m, { sx: { textAlign: "center", mb: 4, color: "grey" }, children: "Assign this feature to specific users or roles. You can toggle individual permissions below after assigning." }),
3766
+ /* @__PURE__ */ l(d, { display: "flex", gap: 2, flexWrap: "wrap", mb: 3, children: [
3767
+ /* @__PURE__ */ l(d, { flex: "1 1 300px", minWidth: 300, children: [
3768
+ /* @__PURE__ */ i(m, { variant: "subtitle1", sx: { mb: 1 }, children: u("User") }),
3769
+ /* @__PURE__ */ i(
3770
+ Pe,
3771
+ {
3772
+ id: "roles",
3773
+ name: "roles",
3774
+ control: a.control,
3775
+ options: !F && (T == null ? void 0 : T.val) === !1 ? Ri.filter(
3776
+ (e) => !Ne.some(
3777
+ (n) => n.entityType === "user" && n.user_id === e.id
3778
+ )
3779
+ ) : Ri,
3780
+ value: ae,
3781
+ singleSelect: !0,
3782
+ onChange: pt,
3783
+ onInputChange: At,
3784
+ getOptionLabel: bt,
3785
+ "data-testid": "accessrights-autocomplete-user",
3786
+ fullWidth: !0
3787
+ }
3788
+ )
3789
+ ] }),
3790
+ /* @__PURE__ */ l(d, { flex: "1 1 300px", minWidth: 300, children: [
3791
+ /* @__PURE__ */ i(m, { variant: "subtitle1", sx: { mb: 1 }, children: u("Role") }),
3792
+ /* @__PURE__ */ i(
3793
+ Pe,
3794
+ {
3795
+ id: "selectedRoles",
3796
+ name: "selectedRoles",
3797
+ control: a.control,
3798
+ options: !F && (T == null ? void 0 : T.val) === !1 ? Ki().filter(
3799
+ (e) => !Ne.some(
3800
+ (n) => n.entityType === "role" && n.role_id === e.id
3801
+ )
3802
+ ) : Ki(),
3803
+ onChange: (e, n) => ct(n),
3804
+ getOptionLabel: (e) => e == null ? void 0 : e.name,
3805
+ dataTestId: "accessrights-select-role",
3806
+ value: we,
3807
+ fullWidth: !0
3808
+ }
3809
+ )
3810
+ ] }),
3811
+ /* @__PURE__ */ i(
3812
+ d,
3813
+ {
3814
+ display: "flex",
3815
+ alignItems: "flex-end",
3816
+ flexShrink: 0,
3817
+ sx: { minWidth: 120 },
3818
+ children: /* @__PURE__ */ i(
3819
+ O,
3820
+ {
3821
+ variant: "contained",
3822
+ size: "medium",
3823
+ fullWidth: !0,
3824
+ disabled: !(we.length > 0 || ae != null && ae.id),
3825
+ "data-testid": "accessrights-add-button",
3826
+ onClick: _t,
3827
+ sx: { minWidth: 120, marginBottom: "10px" },
3828
+ children: u("Add")
3829
+ }
3830
+ )
3831
+ }
3832
+ )
3833
+ ] }),
3834
+ !F && (T == null ? void 0 : T.val) === !1 ? /* @__PURE__ */ i(hn, { sx: { maxHeight: 360, overflowY: "auto" }, children: /* @__PURE__ */ l(gn, { size: "small", children: [
3835
+ /* @__PURE__ */ i(yn, { children: /* @__PURE__ */ l(ui, { children: [
3836
+ /* @__PURE__ */ i(Y, { sx: { fontWeight: "bold" }, children: u("Type") }),
3837
+ /* @__PURE__ */ i(Y, { sx: { fontWeight: "bold" }, children: u("Name") }),
3838
+ /* @__PURE__ */ i(Y, { sx: { fontWeight: "bold" }, children: u("Access Right") }),
3839
+ /* @__PURE__ */ i(Y, { sx: { fontWeight: "bold" }, children: u("Actions") })
3840
+ ] }) }),
3841
+ /* @__PURE__ */ i(bn, { children: Le.map((e, n) => /* @__PURE__ */ l(ui, { children: [
3842
+ /* @__PURE__ */ i(Y, { children: e.designationId ? "Role" : "User" }),
3843
+ /* @__PURE__ */ i(Y, { children: e.roleName || e.fullName }),
3844
+ /* @__PURE__ */ i(Y, { children: /* @__PURE__ */ i(
3845
+ d,
3846
+ {
3847
+ display: "flex",
3848
+ flexDirection: "column",
3849
+ gap: 1,
3850
+ children: (() => {
3851
+ const t = H.value ? a.getValues("updatedFields") : a.getValues("fields"), r = t == null ? void 0 : t.reduce((p, v) => (p[v.value] = v.checkbox, p), {}), o = e.featureJson ? JSON.parse(e.featureJson) : {}, c = Object.fromEntries(
3852
+ Object.entries(o).map(
3853
+ ([p, v]) => [
3854
+ p,
3855
+ v === !0 || v === "true"
3856
+ ]
3857
+ )
3858
+ ), s = {
3859
+ ...c,
3860
+ ...Object.fromEntries(
3861
+ Object.entries(
3862
+ r || {}
3863
+ ).filter(
3864
+ ([p]) => !(p in c)
3865
+ )
3866
+ )
3867
+ };
3868
+ return Object.entries(s).map(
3869
+ ([p, v]) => /* @__PURE__ */ l(
3870
+ d,
3871
+ {
3872
+ display: "flex",
3873
+ alignItems: "center",
3874
+ gap: 1,
3875
+ children: [
3876
+ /* @__PURE__ */ i(
3877
+ ke,
3878
+ {
3879
+ sx: {
3880
+ transform: "scale(0.75)",
3881
+ transformOrigin: "left center"
3882
+ },
3883
+ checked: !!v,
3884
+ onChange: () => {
3885
+ const V = [
3886
+ ...Le
3887
+ ];
3888
+ let N = {};
3889
+ try {
3890
+ N = e.featureJson ? JSON.parse(
3891
+ e.featureJson
3892
+ ) : {};
3893
+ } catch (Z) {
3894
+ console.warn(
3895
+ "Invalid JSON in featureJson:",
3896
+ Z
3897
+ );
3898
+ }
3899
+ const he = (H.value ? a.getValues(
3900
+ "updatedFields"
3901
+ ) : a.getValues(
3902
+ "fields"
3903
+ ) || []).reduce(
3904
+ (Z, le) => (Z[le.value] = le.value in N ? N[le.value] : le.checkbox, Z),
3905
+ {}
3906
+ );
3907
+ he[p] = !v, V[n] = {
3908
+ ...e,
3909
+ featureJson: JSON.stringify(
3910
+ he
3911
+ )
3912
+ }, $e(V);
3913
+ }
3914
+ }
3915
+ ),
3916
+ /* @__PURE__ */ i(m, { variant: "subtitle1", children: p })
3917
+ ]
3918
+ },
3919
+ p
3920
+ )
3921
+ );
3922
+ })()
3923
+ }
3924
+ ) }),
3925
+ /* @__PURE__ */ i(Y, { children: /* @__PURE__ */ i(
3926
+ Ue,
3927
+ {
3928
+ size: "small",
3929
+ color: "error",
3930
+ onClick: () => {
3931
+ const t = Le.filter(
3932
+ (r, o) => o !== n
3933
+ );
3934
+ $e(t);
3935
+ },
3936
+ children: /* @__PURE__ */ i(
3937
+ oe,
3938
+ {
3939
+ iconName: "faTrashAlt",
3940
+ size: "sm"
3941
+ }
3942
+ )
3943
+ }
3944
+ ) })
3945
+ ] }, n)) })
3946
+ ] }) }) : /* @__PURE__ */ i(me, { children: Ne.length > 0 && /* @__PURE__ */ i(
3947
+ hn,
3948
+ {
3949
+ sx: { maxHeight: 360, overflowY: "auto" },
3950
+ children: /* @__PURE__ */ l(gn, { size: "small", children: [
3951
+ /* @__PURE__ */ i(yn, { children: /* @__PURE__ */ l(ui, { children: [
3952
+ /* @__PURE__ */ i(Y, { sx: { fontWeight: "bold" }, children: u("Type") }),
3953
+ /* @__PURE__ */ i(Y, { sx: { fontWeight: "bold" }, children: u("Name") }),
3954
+ /* @__PURE__ */ i(Y, { sx: { fontWeight: "bold" }, children: u("Permissions") }),
3955
+ /* @__PURE__ */ i(Y, { sx: { fontWeight: "bold" }, children: u("Actions") })
3956
+ ] }) }),
3957
+ /* @__PURE__ */ i(bn, { children: Ne.map((e, n) => /* @__PURE__ */ l(ui, { children: [
3958
+ /* @__PURE__ */ i(Y, { children: e.entityType === "role" ? "Role" : "User" }),
3959
+ /* @__PURE__ */ i(Y, { children: e.name }),
3960
+ /* @__PURE__ */ i(Y, { children: /* @__PURE__ */ i(
3961
+ qi,
3962
+ {
3963
+ permissions: e.permissions,
3964
+ onToggle: (t) => Dt(n, t)
3965
+ }
3966
+ ) }),
3967
+ /* @__PURE__ */ i(Y, { children: /* @__PURE__ */ i(
3968
+ Ue,
3969
+ {
3970
+ size: "small",
3971
+ color: "error",
3972
+ onClick: () => {
3973
+ const t = Ne.filter(
3974
+ (r, o) => o !== n
3975
+ );
3976
+ Be(t);
3977
+ },
3978
+ children: /* @__PURE__ */ i(
3979
+ oe,
3980
+ {
3981
+ iconName: "faTrashAlt",
3982
+ size: "sm"
3983
+ }
3984
+ )
3985
+ }
3986
+ ) })
3987
+ ] }, n)) })
3988
+ ] })
3989
+ }
3990
+ ) }),
3991
+ /* @__PURE__ */ i(
3992
+ qn,
3993
+ {
3994
+ open: Mn,
3995
+ onClose: () => Si(!1),
3996
+ permissions: fe,
3997
+ entityData: Ln,
3998
+ onSave: (e) => {
3999
+ Be((n) => [...n, e]), Si(!1);
4000
+ }
4001
+ }
4002
+ )
4003
+ ] }),
4004
+ ((Q = R[y]) == null ? void 0 : Q.key) === "submit" && re && /* @__PURE__ */ l(
4005
+ d,
4006
+ {
4007
+ sx: {
4008
+ mt: 4,
4009
+ display: "flex",
4010
+ flexDirection: "column",
4011
+ alignItems: "center",
4012
+ justifyContent: "center",
4013
+ textAlign: "center",
4014
+ minHeight: "300px",
4015
+ px: 3,
4016
+ mx: "auto",
4017
+ maxWidth: 500,
4018
+ backgroundColor: "background.default",
4019
+ borderRadius: 3,
4020
+ boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
4021
+ border: `1px solid ${de.palette.divider}`,
4022
+ p: 6
4023
+ },
4024
+ children: [
4025
+ /* @__PURE__ */ i(d, { sx: { color: "success.main", fontSize: 40, mb: 2 }, children: /* @__PURE__ */ i(oe, { iconName: "faCheckCircle" }) }),
4026
+ /* @__PURE__ */ l(
4027
+ m,
4028
+ {
4029
+ variant: "h6",
4030
+ gutterBottom: !0,
4031
+ sx: { fontWeight: "bold" },
4032
+ children: [
4033
+ "Feature was successfully",
4034
+ x.get("featureId") ? "updated" : "created",
4035
+ "!"
4036
+ ]
4037
+ }
4038
+ ),
4039
+ /* @__PURE__ */ i(Ye, { sx: { my: 2, width: "100%" } }),
4040
+ /* @__PURE__ */ l(m, { variant: "subtitle1", gutterBottom: !0, children: [
4041
+ /* @__PURE__ */ i("strong", { children: "Feature Name:" }),
4042
+ " ",
4043
+ a.getValues("menuName")
4044
+ ] }),
4045
+ F && /* @__PURE__ */ l(m, { variant: "subtitle1", gutterBottom: !0, children: [
4046
+ /* @__PURE__ */ i("strong", { children: "Feature Constant:" }),
4047
+ " ",
4048
+ a.getValues("featureConstant")
4049
+ ] }),
4050
+ /* @__PURE__ */ i(d, { mt: 5, width: "100%", display: "flex", justifyContent: "center", children: a.getValues("formCode") && a.getValues("version") ? /* @__PURE__ */ i(
4051
+ O,
4052
+ {
4053
+ variant: "contained",
4054
+ color: "primary",
4055
+ onClick: () => {
4056
+ var e;
4057
+ const n = a.getValues("formCode"), t = a.getValues("version"), r = (e = ve == null ? void 0 : ve[n]) == null ? void 0 : e.find(
4058
+ (o) => o.version === t
4059
+ );
4060
+ r != null && r.uuid ? W(
4061
+ `/ui/medplat/admin/medplatForms/form/${r.uuid}`
4062
+ ) : console.warn("Could not find matching version UUID");
4063
+ },
4064
+ children: "Configure Form"
4065
+ }
4066
+ ) : /* @__PURE__ */ i(
4067
+ O,
4068
+ {
4069
+ variant: "outlined",
4070
+ color: "primary",
4071
+ onClick: () => W("/ui/medplat/manage/menu"),
4072
+ children: "Go Back to Menu"
4073
+ }
4074
+ ) })
4075
+ ]
4076
+ }
4077
+ ),
4078
+ !re && /* @__PURE__ */ l(
4079
+ d,
4080
+ {
4081
+ mt: "auto",
4082
+ display: "flex",
4083
+ justifyContent: "flex-end",
4084
+ gap: 2,
4085
+ sx: { paddingTop: 4 },
4086
+ children: [
4087
+ /* @__PURE__ */ i(
4088
+ O,
4089
+ {
4090
+ variant: "outlined",
4091
+ sx: { color: "text.secondary" },
4092
+ onClick: lt,
4093
+ children: "Back"
4094
+ }
4095
+ ),
4096
+ ((U = R[y]) == null ? void 0 : U.key) !== "submit" && (() => {
4097
+ var e;
4098
+ const n = (e = R[y]) == null ? void 0 : e.key, t = ["formLinking"].includes(n), r = Ke.includes(n), [o, c] = a.getValues(Gi(n)), s = n === "formLinking" ? !!(o != null && o.trim()) || !!(c != null && c.trim()) : n === "additionalPermissions" ? Array.isArray(o) && o.length > 0 : !1, p = a.handleSubmit(
4099
+ (v) => {
4100
+ dn(v);
4101
+ const V = R.findIndex(
4102
+ (N) => N.key === "submit"
4103
+ );
4104
+ Li((N) => new Set(N).add(n)), D(V);
4105
+ }
4106
+ );
4107
+ return n === "assignFeatures" || n === "accessRights" ? /* @__PURE__ */ i(
4108
+ O,
4109
+ {
4110
+ variant: "contained",
4111
+ onClick: p,
4112
+ children: "Save"
4113
+ }
4114
+ ) : t ? ji ? /* @__PURE__ */ i(O, { variant: "contained", onClick: ki, children: "Next" }) : s ? /* @__PURE__ */ i(O, { variant: "contained", disabled: !0, children: "Next" }) : /* @__PURE__ */ i(
4115
+ O,
4116
+ {
4117
+ variant: "outlined",
4118
+ color: "secondary",
4119
+ onClick: () => {
4120
+ r || Ai((v) => [...v, n]), ki();
4121
+ },
4122
+ children: "Skip for now"
4123
+ }
4124
+ ) : /* @__PURE__ */ i(
4125
+ O,
4126
+ {
4127
+ variant: "contained",
4128
+ onClick: ki,
4129
+ disabled: !ji,
4130
+ children: "Next"
4131
+ }
4132
+ );
4133
+ })()
4134
+ ]
4135
+ }
4136
+ )
4137
+ ]
4138
+ }
4139
+ )
4140
+ ] }) })
4141
+ }
4142
+ );
4143
+ }
4144
+ En.propTypes = {
4145
+ permissions: w.any,
4146
+ onEdit: w.any,
4147
+ onRemove: w.any,
4148
+ handleAddChildClick: w.any,
4149
+ isDynamicFeature: w.any
4150
+ };
4151
+ Wn.propTypes = {
4152
+ open: w.any,
4153
+ onClose: w.any,
4154
+ onSave: w.any,
4155
+ formCtrl: w.any,
4156
+ editData: w.any,
4157
+ parentPermissionId: w.any,
4158
+ mode: w.any,
4159
+ permissionTypes: w.any,
4160
+ setPermissionTypes: w.any,
4161
+ isDynamicFeature: w.any,
4162
+ existingPermissionIds: w.any
4163
+ };
4164
+ Wi.propTypes = {
4165
+ permission: w.any,
4166
+ index: w.any,
4167
+ depth: w.any,
4168
+ onEdit: w.any,
4169
+ onRemove: w.any,
4170
+ handleAddChildClick: w.any,
4171
+ isLastChild: w.any,
4172
+ isDynamicFeature: w.any
4173
+ };
4174
+ qi.propTypes = {
4175
+ permissions: w.any,
4176
+ onToggle: w.any,
4177
+ isChild: w.any
4178
+ };
4179
+ qn.propTypes = {
4180
+ open: w.any,
4181
+ onClose: w.any,
4182
+ onSave: w.any,
4183
+ entityData: w.any,
4184
+ permissions: w.any
4185
+ };
4186
+ export {
4187
+ Jr as default
4188
+ };
4189
+ //# sourceMappingURL=ManageDynamicFeature-C2I7Ho7i-Bbxkpw0S.js.map