@archbase/security-ui 3.0.0

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.
package/dist/index.js ADDED
@@ -0,0 +1,1814 @@
1
+ import { Modal as Ce, ScrollArea as Ae, Stack as ne, Grid as C, Group as P, Button as V, Paper as Ie, Box as oe, Text as Z, List as Te, Checkbox as He, Tooltip as de, ActionIcon as N, Flex as ae, Space as nr, Input as ue, useTree as Qe, useMantineColorScheme as Me, TextInput as Ye, Tree as Xe, Badge as we, Tabs as le } from "@mantine/core";
2
+ import { useFocusTrap as Ee, useDebouncedValue as Ke } from "@mantine/hooks";
3
+ import { getI18nextInstance as t, ARCHBASE_IOC_API_TYPE as X, convertDateToISOString as Nr, getKeyByEnumValue as ce, useArchbaseTheme as ir, useArchbaseValidator as Or, useArchbaseTranslation as Br, emit as Wr, builder as _e, processErrorMessage as ke, processDetailErrorMessage as Re } from "@archbase/core";
4
+ import { ArchbaseEdit as _, ArchbaseNotifications as Y, ArchbasePasswordEdit as qr, ArchbaseSelect as lr, ArchbaseCheckbox as he, ArchbaseAvatarEdit as Jr, Columns as me, ArchbaseDataGridColumn as m, ArchbaseDataGrid as be, ArchbaseDialog as te } from "@archbase/components";
5
+ import { useArchbaseV1V2Compatibility as ie, useArchbaseDataSourceListener as er, useArchbaseRemoteServiceApi as K, useArchbaseRemoteDataSource as se, ArchbaseDataSource as Zr, useArchbaseStore as cr, useArchbaseDataSource as Hr } from "@archbase/data";
6
+ import { useState as U, useCallback as fe, useEffect as Ne, forwardRef as Qr, useMemo as pe, useRef as je } from "react";
7
+ import { IconArrowRight as dr, IconArrowLeft as ur, IconChevronDown as rr, IconBorderCornerSquare as ar, IconEye as Ge, IconEdit as xe, IconTrashX as ve, IconShieldCheckered as Le, IconPlus as Fe } from "@tabler/icons-react";
8
+ import { UserGroupDto as Yr, SecurityType as k, UserDto as Xr, GroupDto as Kr, ProfileDto as _r, ApiTokenDto as ea } from "@archbase/security";
9
+ import { DateTimePicker as ra } from "@mantine/dates";
10
+ import { ArchbaseSpaceFixed as aa, ArchbaseSpaceFill as ta, ArchbaseSpaceBottom as oa } from "@archbase/layout";
11
+ var $e = { exports: {} }, Se = {};
12
+ /**
13
+ * @license React
14
+ * react-jsx-runtime.production.js
15
+ *
16
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
17
+ *
18
+ * This source code is licensed under the MIT license found in the
19
+ * LICENSE file in the root directory of this source tree.
20
+ */
21
+ var tr;
22
+ function sa() {
23
+ if (tr)
24
+ return Se;
25
+ tr = 1;
26
+ var r = Symbol.for("react.transitional.element"), l = Symbol.for("react.fragment");
27
+ function f(S, s, p) {
28
+ var c = null;
29
+ if (p !== void 0 && (c = "" + p), s.key !== void 0 && (c = "" + s.key), "key" in s) {
30
+ p = {};
31
+ for (var u in s)
32
+ u !== "key" && (p[u] = s[u]);
33
+ } else
34
+ p = s;
35
+ return s = p.ref, {
36
+ $$typeof: r,
37
+ type: S,
38
+ key: c,
39
+ ref: s !== void 0 ? s : null,
40
+ props: p
41
+ };
42
+ }
43
+ return Se.Fragment = l, Se.jsx = f, Se.jsxs = f, Se;
44
+ }
45
+ var or;
46
+ function na() {
47
+ return or || (or = 1, $e.exports = sa()), $e.exports;
48
+ }
49
+ var e = na();
50
+ const ia = (r) => {
51
+ Ee();
52
+ const l = { ...r.options ?? {} }, f = () => {
53
+ r.onCustomSave ? r.onCustomSave(r.dataSource.current, (s) => {
54
+ s && r.onAfterSave && r.onAfterSave(r.dataSource.current), r.onClickOk(r.dataSource.current, s);
55
+ }) : r.onClickOk(r.dataSource.current, !0);
56
+ }, S = () => {
57
+ r.onClickCancel(r.dataSource.current);
58
+ };
59
+ return /* @__PURE__ */ e.jsx(
60
+ Ce,
61
+ {
62
+ opened: r.opened,
63
+ onClose: S,
64
+ title: t().t("archbase:Perfil"),
65
+ size: "60%",
66
+ styles: { content: { maxWidth: 1e3 } },
67
+ children: /* @__PURE__ */ e.jsx(Ae, { style: { height: "460px" }, children: /* @__PURE__ */ e.jsxs(ne, { w: "98%", children: [
68
+ l?.customContentBefore && /* @__PURE__ */ e.jsx(e.Fragment, { children: l.customContentBefore }),
69
+ /* @__PURE__ */ e.jsxs(C, { children: [
70
+ /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12, md: 12, lg: 12 }, children: /* @__PURE__ */ e.jsx(
71
+ _,
72
+ {
73
+ label: `${t().t("archbase:Nome do perfil")}`,
74
+ placeholder: `${t().t("archbase:Informe o nome do perfil")}`,
75
+ dataSource: r.dataSource,
76
+ dataField: "name"
77
+ }
78
+ ) }),
79
+ /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12, md: 12, lg: 12 }, children: /* @__PURE__ */ e.jsx(
80
+ _,
81
+ {
82
+ label: `${t().t("archbase:Descrição do perfil")}`,
83
+ placeholder: `${t().t("archbase:Informe a descrição do perfil")}`,
84
+ dataSource: r.dataSource,
85
+ dataField: "description"
86
+ }
87
+ ) })
88
+ ] }),
89
+ l?.customContentAfter && /* @__PURE__ */ e.jsx(e.Fragment, { children: l.customContentAfter }),
90
+ /* @__PURE__ */ e.jsxs(P, { justify: "flex-end", mt: "md", children: [
91
+ /* @__PURE__ */ e.jsx(V, { variant: "default", onClick: S, children: t().t("archbase:Cancelar") }),
92
+ /* @__PURE__ */ e.jsx(V, { onClick: f, children: t().t("archbase:Salvar") })
93
+ ] })
94
+ ] }) })
95
+ }
96
+ );
97
+ };
98
+ function la({
99
+ availableItemsDS: r,
100
+ assignedItemsDS: l,
101
+ idFieldAvailable: f,
102
+ labelFieldAvailable: S,
103
+ idFieldAssigned: s,
104
+ labelFieldAssigned: p,
105
+ handleCreateAssociationObject: c,
106
+ width: u = "400px",
107
+ height: z = "200px",
108
+ titleAvailable: R = "Disponíveis",
109
+ titleAssigned: v = "Selecionados"
110
+ }) {
111
+ ie(
112
+ "ArchbaseDualListSelector-Available",
113
+ r,
114
+ void 0,
115
+ []
116
+ );
117
+ const d = ie(
118
+ "ArchbaseDualListSelector-Assigned",
119
+ l,
120
+ void 0,
121
+ []
122
+ ), [h, H] = U([]), [j, ee] = U([]), [W, re] = U([]), [Q, E] = U([]), M = fe(() => {
123
+ r && H(r.browseRecords()), l && ee(l.browseRecords());
124
+ }, [r, l]);
125
+ er({
126
+ dataSource: r,
127
+ listener: () => M()
128
+ }), er({
129
+ dataSource: l,
130
+ listener: () => M()
131
+ }), Ne(() => {
132
+ M();
133
+ }, [M]);
134
+ const F = (x, b) => typeof b == "function" ? b(x) : x[b], B = (x, b) => typeof b == "function" ? b(x) : x[b], o = (x, b) => {
135
+ x((D) => D.includes(b) ? D.filter((ge) => ge !== b) : [...D, b]);
136
+ }, g = () => {
137
+ W.forEach((x) => {
138
+ const b = h.find((D) => F(D, f) === x);
139
+ if (b) {
140
+ const D = c(b);
141
+ d.isDataSourceV2 ? (l.insert(D), l.save()) : (l.insert(D), l.save(), d.v1State.forceUpdate());
142
+ }
143
+ }), re([]);
144
+ }, q = () => {
145
+ Q.forEach((x) => {
146
+ const b = j.find((D) => F(D, s) === x);
147
+ if (b) {
148
+ const D = typeof s == "function" ? { customId: s(b) } : { [s]: x };
149
+ d.isDataSourceV2 ? l.remove(() => l.locate(D)) : (l.remove(() => l.locate(D)), d.v1State.forceUpdate());
150
+ }
151
+ }), E([]);
152
+ };
153
+ return /* @__PURE__ */ e.jsxs(Ie, { withBorder: !0, style: { display: "flex", width: u, height: z }, children: [
154
+ /* @__PURE__ */ e.jsxs(oe, { style: { minWidth: "44%", minHeight: z }, children: [
155
+ /* @__PURE__ */ e.jsx(Z, { children: R }),
156
+ /* @__PURE__ */ e.jsx(
157
+ Te,
158
+ {
159
+ spacing: "xs",
160
+ size: "sm",
161
+ center: !0,
162
+ listStyleType: "none",
163
+ style: {
164
+ margin: "6px",
165
+ overflowY: "auto",
166
+ overflowX: "hidden",
167
+ height: "calc(100% - 32px)"
168
+ },
169
+ children: h.map((x) => /* @__PURE__ */ e.jsx(Te.Item, { children: /* @__PURE__ */ e.jsx(
170
+ He,
171
+ {
172
+ label: B(x, S),
173
+ checked: W.includes(F(x, f)),
174
+ onChange: () => o(re, F(x, f)),
175
+ disabled: j.some(
176
+ (b) => F(b, s) === F(x, f)
177
+ )
178
+ }
179
+ ) }, F(x, f)))
180
+ }
181
+ )
182
+ ] }),
183
+ /* @__PURE__ */ e.jsxs(ne, { gap: 5, style: { minWidth: "10%" }, justify: "center", align: "center", children: [
184
+ /* @__PURE__ */ e.jsx(de, { label: "Adicionar", children: /* @__PURE__ */ e.jsx(N, { onClick: g, disabled: !W.length, children: /* @__PURE__ */ e.jsx(dr, {}) }) }),
185
+ /* @__PURE__ */ e.jsx(de, { label: "Remover", children: /* @__PURE__ */ e.jsx(N, { onClick: q, disabled: !Q.length, children: /* @__PURE__ */ e.jsx(ur, {}) }) })
186
+ ] }),
187
+ /* @__PURE__ */ e.jsxs(oe, { style: { minWidth: "44%", minHeight: z }, children: [
188
+ /* @__PURE__ */ e.jsx(Z, { children: v }),
189
+ /* @__PURE__ */ e.jsx(
190
+ Te,
191
+ {
192
+ spacing: "xs",
193
+ size: "sm",
194
+ center: !0,
195
+ listStyleType: "none",
196
+ style: {
197
+ margin: "6px",
198
+ overflowY: "auto",
199
+ overflowX: "hidden",
200
+ height: "calc(100% - 32px)"
201
+ },
202
+ children: j.map((x) => /* @__PURE__ */ e.jsx(Te.Item, { children: /* @__PURE__ */ e.jsx(
203
+ He,
204
+ {
205
+ label: B(x, p),
206
+ checked: Q.includes(F(x, s)),
207
+ onChange: () => o(E, F(x, s))
208
+ }
209
+ ) }, F(x, s)))
210
+ }
211
+ )
212
+ ] })
213
+ ] });
214
+ }
215
+ const ca = Qr(
216
+ ({ image: r, label: l, description: f, origin: S, ...s }, p) => /* @__PURE__ */ e.jsx("div", { ref: p, ...s, children: /* @__PURE__ */ e.jsxs(ae, { children: [
217
+ /* @__PURE__ */ e.jsx(Z, { size: "sm", fw: 600, children: S ? S.name : "" }),
218
+ /* @__PURE__ */ e.jsx(nr, { w: "lg" })
219
+ ] }) })
220
+ ), da = {
221
+ // Campos de identificação
222
+ showNickname: !0,
223
+ // Campos de perfil e grupos
224
+ showProfile: !0,
225
+ showGroups: !0,
226
+ // Campos de configuração de senha
227
+ showChangePasswordOnNextLogin: !0,
228
+ showAllowPasswordChange: !0,
229
+ showPasswordNeverExpires: !0,
230
+ // Campos de status da conta
231
+ showAccountConfigLabel: !0,
232
+ showAccountDeactivated: !0,
233
+ showAccountLocked: !0,
234
+ showIsAdministrator: !0,
235
+ // Configurações de campos obrigatórios
236
+ requiredNickname: !0,
237
+ avatarMaxSizeKB: 2e3,
238
+ avatarImageQuality: 1,
239
+ allowEditEmail: !0
240
+ }, ua = (r) => {
241
+ const l = Ee(), [f, S] = U(""), s = { ...da, ...r.options ?? {} }, p = K(X.Group), { dataSource: c } = se({
242
+ name: "dsGroups",
243
+ service: p,
244
+ pageSize: 9999,
245
+ loadOnStart: !0,
246
+ sort: ["name:asc"],
247
+ onError: (d, h) => {
248
+ Y.showError(t().t("archbase:WARNING"), d, h);
249
+ }
250
+ }), u = K(X.Profile), { dataSource: z } = se({
251
+ name: "dsProfiles",
252
+ service: u,
253
+ pageSize: 9999,
254
+ loadOnStart: !0,
255
+ sort: ["name:asc"],
256
+ onError: (d, h) => {
257
+ Y.showError(t().t("archbase:WARNING"), d, h);
258
+ }
259
+ });
260
+ Ne(() => {
261
+ S("");
262
+ }, [r.dataSource.getFieldValue("password")]);
263
+ const R = () => {
264
+ const d = r.dataSource.current;
265
+ if (!d.password && r.dataSource.isInserting()) {
266
+ S(t().t("archbase:Informe a senha"));
267
+ return;
268
+ }
269
+ r.onCustomSave ? r.onCustomSave(d, (h) => {
270
+ h && r.onAfterSave && r.onAfterSave(d), r.onClickOk(d, h);
271
+ }) : r.onClickOk(d, !0);
272
+ }, v = () => {
273
+ r.onClickCancel(r.dataSource.current);
274
+ };
275
+ return /* @__PURE__ */ e.jsxs(
276
+ Ce,
277
+ {
278
+ opened: r.opened,
279
+ onClose: v,
280
+ title: t().t("archbase:Usuário"),
281
+ size: "80%",
282
+ styles: { content: { maxWidth: 1e3 } },
283
+ children: [
284
+ /* @__PURE__ */ e.jsx(Ae, { ref: l, style: { height: "500px" }, children: /* @__PURE__ */ e.jsxs(ne, { w: "98%", children: [
285
+ s?.customContentBefore && /* @__PURE__ */ e.jsx(e.Fragment, { children: s.customContentBefore }),
286
+ /* @__PURE__ */ e.jsxs(C, { children: [
287
+ /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12, md: 6, lg: 6 }, children: /* @__PURE__ */ e.jsxs(P, { children: [
288
+ /* @__PURE__ */ e.jsx(
289
+ _,
290
+ {
291
+ label: `${t().t("archbase:Nome completo")}`,
292
+ placeholder: `${t().t("archbase:Informe o nome completo do usuário")}`,
293
+ dataSource: r.dataSource,
294
+ dataField: "name",
295
+ required: !0,
296
+ width: "calc(100% - 208px)"
297
+ }
298
+ ),
299
+ s.showNickname && /* @__PURE__ */ e.jsx(
300
+ _,
301
+ {
302
+ label: `${t().t("archbase:Apelido")}`,
303
+ placeholder: `${t().t("archbase:Apelido")}`,
304
+ dataSource: r.dataSource,
305
+ dataField: "nickname",
306
+ required: s.requiredNickname
307
+ }
308
+ )
309
+ ] }) }),
310
+ /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12, md: 6, lg: 6 }, children: /* @__PURE__ */ e.jsx(
311
+ _,
312
+ {
313
+ label: `${t().t("archbase:Descrição do usuário")}`,
314
+ placeholder: `${t().t("archbase:Informe a descrição do usuário")}`,
315
+ dataSource: r.dataSource,
316
+ dataField: "description",
317
+ required: !0
318
+ }
319
+ ) })
320
+ ] }),
321
+ /* @__PURE__ */ e.jsxs(C, { children: [
322
+ /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12, md: 6, lg: 6 }, children: /* @__PURE__ */ e.jsx(
323
+ _,
324
+ {
325
+ label: `${t().t("archbase:E-mail")}`,
326
+ placeholder: `${t().t("archbase:Informe o e-mail do usuário")}`,
327
+ dataSource: r.dataSource,
328
+ onChangeValue: (d) => r.dataSource.setFieldValue("userName", d),
329
+ dataField: "email",
330
+ readOnly: r.dataSource.isEditing() ? !s.allowEditEmail : !1,
331
+ required: !0
332
+ }
333
+ ) }),
334
+ /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12, md: 6, lg: 6 }, children: /* @__PURE__ */ e.jsx(
335
+ qr,
336
+ {
337
+ label: `${t().t("archbase:Senha usuário")}`,
338
+ dataSource: r.dataSource,
339
+ dataField: "password",
340
+ error: f,
341
+ required: r.dataSource.getFieldValue("isNewUser")
342
+ }
343
+ ) })
344
+ ] }),
345
+ /* @__PURE__ */ e.jsx(C, { children: s.showProfile && /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12, md: 6, lg: 6 }, children: /* @__PURE__ */ e.jsx(
346
+ lr,
347
+ {
348
+ label: `${t().t("archbase:Perfil do usuário")}`,
349
+ dataSource: r.dataSource,
350
+ dataField: "profile",
351
+ options: z,
352
+ allowDeselect: !0,
353
+ optionsLabelField: "nome",
354
+ itemComponent: ca,
355
+ getOptionLabel: (d) => d.name,
356
+ getOptionValue: (d) => d.id
357
+ }
358
+ ) }) }),
359
+ /* @__PURE__ */ e.jsxs(C, { children: [
360
+ /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12 }, children: s.showAccountConfigLabel && /* @__PURE__ */ e.jsx(Z, { fz: 14, fw: 500, children: "Informe" }) }),
361
+ /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12, md: 4, lg: 4 }, children: /* @__PURE__ */ e.jsxs(ne, { gap: "lg", children: [
362
+ s.showChangePasswordOnNextLogin && /* @__PURE__ */ e.jsx(ue.Wrapper, { label: "", children: /* @__PURE__ */ e.jsx(
363
+ he,
364
+ {
365
+ dataSource: r.dataSource,
366
+ dataField: "changePasswordOnNextLogin",
367
+ label: `${t().t("archbase:Deve alterar senha próximo login ?")}`
368
+ }
369
+ ) }),
370
+ s.showAllowPasswordChange && /* @__PURE__ */ e.jsx(ue.Wrapper, { label: "", children: /* @__PURE__ */ e.jsx(
371
+ he,
372
+ {
373
+ dataSource: r.dataSource,
374
+ dataField: "allowPasswordChange",
375
+ label: `${t().t("archbase:Pode alterar a senha ?")}`
376
+ }
377
+ ) }),
378
+ s.showPasswordNeverExpires && /* @__PURE__ */ e.jsx(ue.Wrapper, { label: "", children: /* @__PURE__ */ e.jsx(
379
+ he,
380
+ {
381
+ dataSource: r.dataSource,
382
+ dataField: "passwordNeverExpires",
383
+ label: `${t().t("archbase:Senha nunca expira ?")}`
384
+ }
385
+ ) })
386
+ ] }) }),
387
+ /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12, md: 4, lg: 4 }, children: /* @__PURE__ */ e.jsxs(ne, { gap: "lg", children: [
388
+ s.showAccountDeactivated && /* @__PURE__ */ e.jsx(ue.Wrapper, { label: "", children: /* @__PURE__ */ e.jsx(
389
+ he,
390
+ {
391
+ dataSource: r.dataSource,
392
+ dataField: "accountDeactivated",
393
+ label: `${t().t("archbase:Conta desativada ?")}`
394
+ }
395
+ ) }),
396
+ s.showAccountLocked && /* @__PURE__ */ e.jsx(ue.Wrapper, { label: "", children: /* @__PURE__ */ e.jsx(
397
+ he,
398
+ {
399
+ dataSource: r.dataSource,
400
+ dataField: "accountLocked",
401
+ label: `${t().t("archbase:Conta bloqueada ?")}`
402
+ }
403
+ ) }),
404
+ s.showIsAdministrator && /* @__PURE__ */ e.jsx(ue.Wrapper, { label: "", children: /* @__PURE__ */ e.jsx(
405
+ he,
406
+ {
407
+ dataSource: r.dataSource,
408
+ dataField: "isAdministrator",
409
+ label: `${t().t("archbase:Administrador ?")}`
410
+ }
411
+ ) })
412
+ ] }) }),
413
+ /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12, md: 4, lg: 4 }, children: /* @__PURE__ */ e.jsx(ne, { gap: "lg", children: /* @__PURE__ */ e.jsx(
414
+ Jr,
415
+ {
416
+ label: t().t("archbase:Foto do usuário"),
417
+ dataSource: r.dataSource,
418
+ dataField: "avatar",
419
+ width: 120,
420
+ height: 120,
421
+ maxSizeKB: s.avatarMaxSizeKB,
422
+ imageQuality: s.avatarImageQuality
423
+ }
424
+ ) }) })
425
+ ] }),
426
+ s.showGroups && /* @__PURE__ */ e.jsxs(C, { children: [
427
+ /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12 }, children: /* @__PURE__ */ e.jsx(Z, { fz: 14, fw: 500, children: "Grupos" }) }),
428
+ /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12 }, children: /* @__PURE__ */ e.jsx(
429
+ la,
430
+ {
431
+ titleAvailable: t().t("archbase:Disponíveis"),
432
+ titleAssigned: t().t("archbase:Selecionados"),
433
+ assignedItemsDS: new Zr("dsDualList", {
434
+ records: r.dataSource.getFieldValue("groups"),
435
+ grandTotalRecords: r.dataSource.getFieldValue("groups").length,
436
+ currentPage: 0,
437
+ totalPages: 0,
438
+ pageSize: 999999
439
+ }),
440
+ width: "100%",
441
+ height: "200px",
442
+ availableItemsDS: c,
443
+ handleCreateAssociationObject: (d) => Yr.newInstance(d),
444
+ idFieldAssigned: (d) => d && d.group ? d.group.id : "",
445
+ idFieldAvailable: "id",
446
+ labelFieldAssigned: (d) => d && d.group ? d.group.name : "",
447
+ labelFieldAvailable: "name"
448
+ }
449
+ ) })
450
+ ] }),
451
+ s?.customContentAfter && /* @__PURE__ */ e.jsx(e.Fragment, { children: s.customContentAfter }),
452
+ /* @__PURE__ */ e.jsx(nr, { h: "12px" })
453
+ ] }) }),
454
+ /* @__PURE__ */ e.jsxs(P, { justify: "flex-end", mt: "md", children: [
455
+ /* @__PURE__ */ e.jsx(V, { variant: "default", onClick: v, children: t().t("archbase:Cancelar") }),
456
+ /* @__PURE__ */ e.jsx(V, { onClick: R, children: t().t("archbase:Salvar") })
457
+ ] })
458
+ ]
459
+ }
460
+ );
461
+ }, ha = (r) => {
462
+ Ee();
463
+ const l = { ...r.options ?? {} }, f = () => {
464
+ r.onCustomSave ? r.onCustomSave(r.dataSource.current, (s) => {
465
+ s && r.onAfterSave && r.onAfterSave(r.dataSource.current), r.onClickOk(r.dataSource.current, s);
466
+ }) : r.onClickOk(r.dataSource.current, !0);
467
+ }, S = () => {
468
+ r.onClickCancel(r.dataSource.current);
469
+ };
470
+ return /* @__PURE__ */ e.jsx(
471
+ Ce,
472
+ {
473
+ opened: r.opened,
474
+ onClose: S,
475
+ title: t().t("archbase:Grupo"),
476
+ size: "60%",
477
+ styles: { content: { maxWidth: 1e3 } },
478
+ children: /* @__PURE__ */ e.jsx(Ae, { style: { height: "460px" }, children: /* @__PURE__ */ e.jsxs(ne, { w: "98%", children: [
479
+ l?.customContentBefore && /* @__PURE__ */ e.jsx(e.Fragment, { children: r.options.customContentBefore }),
480
+ /* @__PURE__ */ e.jsxs(C, { children: [
481
+ /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12 }, children: /* @__PURE__ */ e.jsx(
482
+ _,
483
+ {
484
+ label: `${t().t("archbase:Nome do grupo")}`,
485
+ placeholder: `${t().t("archbase:Informe o nome do grupo")}`,
486
+ dataSource: r.dataSource,
487
+ dataField: "name"
488
+ }
489
+ ) }),
490
+ /* @__PURE__ */ e.jsx(C.Col, { span: { base: 12 }, children: /* @__PURE__ */ e.jsx(
491
+ _,
492
+ {
493
+ label: `${t().t("archbase:Descrição do grupo")}`,
494
+ placeholder: `${t().t("archbase:Informe a descrição do grupo")}`,
495
+ dataSource: r.dataSource,
496
+ dataField: "description"
497
+ }
498
+ ) })
499
+ ] }),
500
+ l?.customContentAfter && /* @__PURE__ */ e.jsx(e.Fragment, { children: r.options.customContentAfter }),
501
+ /* @__PURE__ */ e.jsxs(P, { justify: "flex-end", mt: "md", children: [
502
+ /* @__PURE__ */ e.jsx(V, { variant: "default", onClick: S, children: t().t("archbase:Cancelar") }),
503
+ /* @__PURE__ */ e.jsx(V, { onClick: f, children: t().t("archbase:Salvar") })
504
+ ] })
505
+ ] }) })
506
+ }
507
+ );
508
+ }, pa = ({ image: r, label: l, description: f, ...S }) => /* @__PURE__ */ e.jsx("div", { ...S, children: /* @__PURE__ */ e.jsxs(P, { grow: !0, children: [
509
+ /* @__PURE__ */ e.jsx("img", { style: { maxWidth: "32px" }, src: r }),
510
+ /* @__PURE__ */ e.jsxs("div", { children: [
511
+ /* @__PURE__ */ e.jsx(Z, { size: "sm", children: l }),
512
+ /* @__PURE__ */ e.jsx(Z, { size: "xs", opacity: 0.65, children: f })
513
+ ] })
514
+ ] }) }), xa = (r) => {
515
+ Ee();
516
+ const [l, f] = U();
517
+ K(X.User);
518
+ const S = ie(
519
+ "ApiTokenModal",
520
+ r.dataSource,
521
+ "expirationDate",
522
+ ""
523
+ ), s = (u) => {
524
+ if (!u)
525
+ S.handleValueChange(void 0);
526
+ else {
527
+ const z = typeof u == "string" ? new Date(u) : u, R = Nr(z);
528
+ S.handleValueChange(R);
529
+ }
530
+ f(u);
531
+ }, p = () => {
532
+ r.onCustomSave ? r.onCustomSave(r.dataSource.current, (u) => {
533
+ u && r.onAfterSave && r.onAfterSave(r.dataSource.current), r.onClickOk(r.dataSource.current, u);
534
+ }) : r.onClickOk(r.dataSource.current, !0);
535
+ }, c = () => {
536
+ r.onClickCancel(r.dataSource.current);
537
+ };
538
+ return /* @__PURE__ */ e.jsxs(
539
+ Ce,
540
+ {
541
+ opened: r.opened,
542
+ onClose: c,
543
+ title: t().t("archbase:Token de API"),
544
+ size: "50%",
545
+ children: [
546
+ /* @__PURE__ */ e.jsxs(Ae, { style: { height: "300px" }, children: [
547
+ /* @__PURE__ */ e.jsx(
548
+ _,
549
+ {
550
+ label: `${t().t("archbase:Nome do token")}`,
551
+ placeholder: `${t().t("archbase:Informe o nome do token")}`,
552
+ dataSource: r.dataSource,
553
+ dataField: "name"
554
+ }
555
+ ),
556
+ /* @__PURE__ */ e.jsx(
557
+ _,
558
+ {
559
+ label: `${t().t("archbase:Descrição do token")}`,
560
+ placeholder: `${t().t("archbase:Informe a descrição do token")}`,
561
+ dataSource: r.dataSource,
562
+ dataField: "description"
563
+ }
564
+ ),
565
+ /* @__PURE__ */ e.jsx(
566
+ ra,
567
+ {
568
+ withSeconds: !0,
569
+ value: l,
570
+ onChange: s,
571
+ label: "Data/hora expiração",
572
+ placeholder: "Selecione a data de expiração"
573
+ }
574
+ ),
575
+ /* @__PURE__ */ e.jsx(
576
+ lr,
577
+ {
578
+ label: `${t().t("archbase:Usuário")}`,
579
+ dataSource: r.dataSource,
580
+ dataField: "user",
581
+ placeholder: `${t().t("archbase:Digite aqui o nome do usuário")}`,
582
+ getOptionLabel: (u) => u && u.email,
583
+ getOptionValue: (u) => u.id?.toString() || "",
584
+ debounceTime: 500,
585
+ itemComponent: pa,
586
+ options: []
587
+ }
588
+ )
589
+ ] }),
590
+ /* @__PURE__ */ e.jsxs(P, { justify: "flex-end", mt: "md", children: [
591
+ /* @__PURE__ */ e.jsx(V, { variant: "default", onClick: c, children: t().t("archbase:Cancelar") }),
592
+ /* @__PURE__ */ e.jsx(V, { onClick: p, children: t().t("archbase:Salvar") })
593
+ ] })
594
+ ]
595
+ }
596
+ );
597
+ }, sr = (r) => {
598
+ const l = "->";
599
+ return r.includes(l) ? r.split(l).map((s) => s.trim()).map((s) => t().t(s)).join(` ${l} `) : t().t(r);
600
+ };
601
+ function Ve({ dataSource: r, opened: l, close: f }) {
602
+ const S = pe(() => r?.getFieldValue("name") || "", [r]), s = pe(() => r?.getFieldValue("id") || "", [r]), p = pe(() => r?.getFieldValue("type") || "", [r]), c = Qe(), u = Qe(), [z, R] = U([]), [v, d] = U([]), [h, H] = U(), [j, ee] = U(), [W, re] = U(""), [Q] = Ke(W, 200), [E, M] = U(""), [F] = Ke(E, 200), B = K(X.Resource), { colorScheme: o } = Me(), g = o === "dark" ? "var(--mantine-primary-color-7)" : "var(--mantine-primary-color-4)", q = pe(() => v.sort((n, i) => n.resourceDescription.localeCompare(i.resourceDescription)).map((n) => ({
603
+ value: n.resourceId,
604
+ label: n.resourceDescription,
605
+ children: n.permissions.filter((i) => i.actionDescription.toLowerCase().includes(F.toLowerCase())).sort((i, G) => i.actionDescription.localeCompare(G.actionDescription)).map((i) => ({
606
+ value: i.actionId,
607
+ label: i.actionDescription,
608
+ nodeProps: {
609
+ permissionId: i.permissionId,
610
+ types: i.types ?? [],
611
+ owner: n
612
+ }
613
+ }))
614
+ })), [v, F]), x = pe(() => v.map((n) => n.permissions.map((i) => i.actionId)).flat(), [v]), b = pe(() => z.sort((n, i) => n.resourceDescription.localeCompare(i.resourceDescription)).map((n) => ({
615
+ value: n.resourceId,
616
+ label: n.resourceDescription,
617
+ children: n.permissions.filter((i) => i.actionDescription.toLowerCase().includes(Q.toLowerCase())).sort((i, G) => i.actionDescription.localeCompare(G.actionDescription)).map((i) => {
618
+ const G = v.find((y) => y.resourceId === n.resourceId)?.permissions.find((y) => y.actionId === i.actionId);
619
+ return {
620
+ value: i.actionId,
621
+ label: i.actionDescription,
622
+ nodeProps: {
623
+ granted: x.includes(i.actionId) && G?.types?.includes(ce(k, p)),
624
+ owner: n
625
+ }
626
+ };
627
+ })
628
+ })), [z, v, x, p, Q]), D = fe(async () => {
629
+ if (s) {
630
+ const n = await B.getPermissionsBySecurityId(s, p), i = await B.getAllPermissionsAvailable();
631
+ R(i), d(n);
632
+ }
633
+ }, [s, p]), ge = fe(() => {
634
+ h?.value && s && B.createPermission(s, h.value, p).then((n) => {
635
+ if (n) {
636
+ d((I) => {
637
+ let A;
638
+ return I.map((w) => w.resourceId).includes(n.resourceId) ? A = I.map((w) => w.resourceId === n.resourceId ? w.permissions.map((T) => T.actionId).includes(h.value) ? {
639
+ ...w,
640
+ permissions: w.permissions.map(
641
+ (T) => T.actionId === h.value ? {
642
+ ...T,
643
+ permissionId: n.permissionId,
644
+ types: [...T.types ?? [], ce(k, p)]
645
+ } : T
646
+ )
647
+ } : {
648
+ ...w,
649
+ permissions: [
650
+ ...w.permissions ?? [],
651
+ {
652
+ actionId: n.actionId,
653
+ actionDescription: n.actionDescription,
654
+ permissionId: n.permissionId,
655
+ types: [ce(k, p)]
656
+ }
657
+ ]
658
+ } : w) : A = [
659
+ ...I,
660
+ {
661
+ resourceId: n.resourceId,
662
+ resourceDescription: n.resourceDescription,
663
+ permissions: [
664
+ {
665
+ actionId: n.actionId,
666
+ actionDescription: n.actionDescription,
667
+ permissionId: n.permissionId,
668
+ types: [ce(k, p)]
669
+ }
670
+ ]
671
+ }
672
+ ], A;
673
+ });
674
+ const i = b.filter((I) => I.value === h?.nodeProps?.owner?.resourceId).map((I) => I.children).flat(), G = i.map((I) => I.value).indexOf(h.value), y = i.find((I, A) => !I?.nodeProps?.granted && I?.value !== h.value && (i.length > G + 1 ? A > G : !0));
675
+ y?.value && c.select(y.value), u.expand(n.resourceId), H(y);
676
+ }
677
+ });
678
+ }, [h, s, p, B, b, z, v, c, u]), ze = fe(() => {
679
+ j?.nodeProps?.permissionId && B.deletePermission(j.nodeProps.permissionId).then(() => {
680
+ d((y) => [...y].filter((A) => {
681
+ let w = !0;
682
+ return A.permissions?.forEach((T) => {
683
+ T.permissionId !== void 0 && T.permissionId === j?.nodeProps?.permissionId && A.permissions.length === 1 && T?.types?.length === 1 && T.types[0] === ce(k, p) && (w = !1);
684
+ }), w;
685
+ }).map((A) => {
686
+ const w = j?.nodeProps?.owner;
687
+ return A.resourceId === w.resourceId ? j?.nodeProps?.types?.length === 1 ? {
688
+ ...A,
689
+ permissions: [...(A.permissions ?? []).filter((T) => T.permissionId !== j?.nodeProps?.permissionId)]
690
+ } : {
691
+ ...A,
692
+ permissions: (A.permissions ?? []).map((T) => T.actionId === j.value ? {
693
+ actionId: T.actionId,
694
+ actionDescription: T.actionDescription,
695
+ types: [...T.types?.filter((L) => L && L !== ce(k, p)) ?? []]
696
+ } : T)
697
+ } : A;
698
+ }));
699
+ const n = q.filter((y) => y.value === j?.nodeProps?.owner?.resourceId).map((y) => y.children).flat(), i = n.map((y) => y.value).indexOf(j.value), G = n.find((y, I) => y?.nodeProps?.types.includes(ce(k, p)) && y?.value !== j.value && (n.length > i + 1 ? I > i : !0));
700
+ G?.value && u.select(G.value), ee(G);
701
+ });
702
+ }, [j, B, p, q, v, u]);
703
+ return Ne(() => {
704
+ l && r && (H(void 0), ee(void 0), re(""), M(""), u.collapseAllNodes(), c.collapseAllNodes(), D());
705
+ }, [l, p, s, D]), r ? /* @__PURE__ */ e.jsx(Ce, { opened: l, onClose: f, title: `${t().t(`archbase:${p}`)}: ${S}`, size: "80%", styles: { root: { overflow: "hidden" } }, children: /* @__PURE__ */ e.jsxs(aa, { height: "540px", children: [
706
+ /* @__PURE__ */ e.jsx(ta, { children: /* @__PURE__ */ e.jsx(Ae, { h: "500px", children: /* @__PURE__ */ e.jsx(Ie, { withBorder: !0, my: 20, p: 20, children: /* @__PURE__ */ e.jsxs(C, { columns: 20, children: [
707
+ /* @__PURE__ */ e.jsxs(C.Col, { span: 9, children: [
708
+ /* @__PURE__ */ e.jsxs(P, { mb: 20, children: [
709
+ /* @__PURE__ */ e.jsx(Z, { children: t().t("archbase:Available") }),
710
+ /* @__PURE__ */ e.jsx(
711
+ Ye,
712
+ {
713
+ size: "xs",
714
+ value: W,
715
+ onChange: (n) => re(n.target.value),
716
+ placeholder: t().t("archbase:Filter available permissions")
717
+ }
718
+ )
719
+ ] }),
720
+ /* @__PURE__ */ e.jsx(
721
+ Xe,
722
+ {
723
+ data: b,
724
+ selectOnClick: !0,
725
+ allowRangeSelection: !1,
726
+ tree: c,
727
+ renderNode: ({ level: n, node: i, expanded: G, hasChildren: y, selected: I, elementProps: A }) => {
728
+ const w = i?.nodeProps?.granted, T = w ? "dimmed" : void 0, L = w ? "line-through" : void 0, Pe = fe((O) => {
729
+ H(i), A.onClick(O);
730
+ }, [i, A.onClick]);
731
+ return /* @__PURE__ */ e.jsxs(
732
+ P,
733
+ {
734
+ ml: y ? 0 : 5,
735
+ gap: 5,
736
+ ...A,
737
+ bg: I && n === 2 ? g : "",
738
+ onClick: Pe,
739
+ children: [
740
+ y && /* @__PURE__ */ e.jsx(
741
+ rr,
742
+ {
743
+ size: 18,
744
+ style: { transform: G ? "rotate(0deg)" : "rotate(-90deg)" }
745
+ }
746
+ ),
747
+ !y && /* @__PURE__ */ e.jsx(
748
+ ar,
749
+ {
750
+ size: 12,
751
+ style: { transform: "rotate(-90deg)", marginTop: "-5px" }
752
+ }
753
+ ),
754
+ /* @__PURE__ */ e.jsx(
755
+ Z,
756
+ {
757
+ c: T,
758
+ td: L,
759
+ children: sr(i.label)
760
+ }
761
+ )
762
+ ]
763
+ }
764
+ );
765
+ }
766
+ }
767
+ )
768
+ ] }),
769
+ /* @__PURE__ */ e.jsx(C.Col, { span: 2, children: /* @__PURE__ */ e.jsxs(ne, { gap: 5, style: { minWidth: "10%" }, justify: "center", align: "center", h: "100%", children: [
770
+ /* @__PURE__ */ e.jsx(de, { label: t().t("archbase:Add"), children: /* @__PURE__ */ e.jsx(N, { onClick: ge, disabled: !h || h?.nodeProps?.granted || !h.nodeProps, children: /* @__PURE__ */ e.jsx(dr, {}) }) }),
771
+ /* @__PURE__ */ e.jsx(de, { label: t().t("archbase:Remove"), children: /* @__PURE__ */ e.jsx(N, { onClick: ze, disabled: !j || !j?.nodeProps?.permissionId || !j.nodeProps, children: /* @__PURE__ */ e.jsx(ur, {}) }) })
772
+ ] }) }),
773
+ /* @__PURE__ */ e.jsxs(C.Col, { span: 9, children: [
774
+ /* @__PURE__ */ e.jsxs(P, { mb: 20, children: [
775
+ /* @__PURE__ */ e.jsx(Z, { children: t().t("archbase:Granted") }),
776
+ /* @__PURE__ */ e.jsx(
777
+ Ye,
778
+ {
779
+ size: "xs",
780
+ value: E,
781
+ onChange: (n) => M(n.target.value),
782
+ placeholder: t().t("archbase:Filter granted permissions")
783
+ }
784
+ )
785
+ ] }),
786
+ /* @__PURE__ */ e.jsx(
787
+ Xe,
788
+ {
789
+ data: q,
790
+ selectOnClick: !0,
791
+ allowRangeSelection: !1,
792
+ tree: u,
793
+ renderNode: ({ level: n, node: i, expanded: G, hasChildren: y, selected: I, elementProps: A }) => {
794
+ const w = fe((T) => {
795
+ ee(i), A.onClick(T);
796
+ }, [i, A.onClick]);
797
+ return /* @__PURE__ */ e.jsxs(
798
+ P,
799
+ {
800
+ ml: y ? 0 : 5,
801
+ gap: 5,
802
+ ...A,
803
+ bg: I && n === 2 ? g : "",
804
+ onClick: w,
805
+ children: [
806
+ y && /* @__PURE__ */ e.jsx(
807
+ rr,
808
+ {
809
+ size: 18,
810
+ style: { transform: G ? "rotate(0deg)" : "rotate(-90deg)" }
811
+ }
812
+ ),
813
+ !y && /* @__PURE__ */ e.jsx(
814
+ ar,
815
+ {
816
+ size: 12,
817
+ style: { transform: "rotate(-90deg)", marginTop: "-5px" }
818
+ }
819
+ ),
820
+ /* @__PURE__ */ e.jsx(Z, { children: sr(i.label) }),
821
+ i?.nodeProps?.types?.includes("USER") && /* @__PURE__ */ e.jsx(we, { color: "blue", children: t().t("archbase:user") }),
822
+ i?.nodeProps?.types?.includes("GROUP") && /* @__PURE__ */ e.jsx(we, { color: "orange", children: t().t("archbase:group") }),
823
+ i?.nodeProps?.types?.includes("PROFILE") && /* @__PURE__ */ e.jsx(we, { color: "pink", children: t().t("archbase:profile") })
824
+ ]
825
+ }
826
+ );
827
+ }
828
+ }
829
+ )
830
+ ] })
831
+ ] }) }) }) }),
832
+ /* @__PURE__ */ e.jsx(oa, { size: "40px", children: /* @__PURE__ */ e.jsx(P, { justify: "flex-end", children: /* @__PURE__ */ e.jsx(V, { onClick: f, children: t().t("archbase:Close") }) }) })
833
+ ] }) }) : null;
834
+ }
835
+ const Ue = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABMCAMAAAD5ogFjAAABj1BMVEUAAADMzMzLy8vAwMDLy8vLy8vLy8vMzMzKysrR0dHPz8/MzMzNzc3KysrMzMzKysrLy8vLy8vLy8vJycnR0dHMzMzPz8/Ozs7MzMxPT0/Nzc1UVFTJyclTU1PMzMzKysrMzMzJycldXV1iYmLMzMzIyMhNTU1NTU3MzMzLy8vNzc3MzMxVVVXLy8vMzMzLy8vLy8tNTU3MzMzOzs5QUFDLy8vKyspRUVFRUVHMzMxZWVlycnLLy8tUVFTJycnKyspZWVlXV1dhYWHGxsZMTExQUFBPT0/Ozs7Ly8vPz89SUlJSUlLMzMxVVVVWVlZVVVXKysptbW1bW1t6enpmZmbLy8tKSkrQ0NDOzs5FRUXNzc1NTU3S0tLU1NRHR0dSUlKzs7ORkZF4eHhPT0/Jycm9vb26urp8fHxYWFisrKylpaWdnZ11dXVubm5fX1+8vLy3t7ehoaFkZGRVVVXBwcG/v7+vr6+ZmZmUlJSNjY2GhoZzc3NcXFzGxsbDw8Ofn5+WlpaBgYGwsLCpqalqampaWRCJAAAAVXRSTlMA+YUG1M7Df1AQ8urbdWdiXjo2HQkE+/vu4qqIcV1bRDEpIRwXFO/q2ZiObWJZSiv+9uTe3cq8s6qkgX55b1pWR0YVDfvJyLCcmZWTi2lZVz82LRcUQGGNCgAAA9pJREFUWMPll2db2zAQgJ0AgUIYDSl7tZRZ6N57793akizZCSSEEJKw9yi0/eHtEwgid5IxfOX9mnvenM93J8s4tZw5391Q3/Hu0mj3lTMnllys+hi6HqBCCCIEDVwPDVddPEEqXW9qiEOoeQAlDqlpGz1eYo2VYSFsE2ELcSPY6FvTV1njUFMDdVqCff48DWGgAdhOuMtPie8JrUaWq+3I5zs76Jg+cG50e3seVxPTF6S63svT0URNn1BSqffUEhvHE/ofgn8x9aZLKJpcja/sZnO57Pp0yqbIVKv2VDUBD93amedsn0QuA1U2eazynG8BceRPnrnWAczdmAERtLoHe6IhAaJWLWaVwNLLBPxXxQskCjogZse1ICz2G+TkDKNGbAb5THELwzaXQB2bzpZ6zt0GD5acZ5bKNA4LGSorET2BDz/NLDVT0FQywGW34GT81YhYForKo4dbCHjsVMLSEJuxgWnUkMAKkTmmE7E52ExhuX2vBGDzj+lFa7AKzRHUQ1K0qheNQZETPHj3FQSKfulF0zCYlpcVpyyAlseypcOdojC6uThxdQLt94mYTpRI2WjvduyL3kqRbGxXk1A+iYJFmywRhEyCIuEZwUXqq7Hxb+M60QYOtlsaZa3BT7PazuZxisP3VkA3/MX79a8QHH5574iWtfbZ2RDRUBDVA5HPzsbvvw6LaMZraLGodu9YdEzPhsRrBCIq985FLDKpto8mKY4WD+VWQymlXWVjpydshaiuILpcEKGxjSkfLE4VwaSqIOq5aioQ40w1IMRUEUEjgrctXkaqEZFDi1lccL1fGd5s94RKRLMMJZSTHrBGcEfiMxJ3Ne5HeYhg7CX03vgsVUZGiuesLBJqSrzUcNxgFBxHMGA2gVeRAjFkFOkJmCqSebekqzeTyrDmQ182IV8NEJtQNtytc+irBn5rwUHLqMJEvSGJlitCCCr2BsVRNFzyGdklcEQcHwAZop58SRmqEt2aZ3iJpChMuyJqlPC1CQRs51RDm08RdIAAhpzD6dCpvPpjNJ2hh5NyhvCFb5DIq0F83NKd/VY2LlWkXHFXjlTTfU1qlzNLC+OTs8Tev0JElHfZQkpkaT0GNEiVWJ8oqIjm8vdQ2GR7bAFrsGphbZHYQnthC5orm8y1fOCy9Fhy2NDyANVYr3IfGB6MXOM+Rdc+GZ48venLxG8+M46g9y734bl7wTiazlZ+hKZ1xPBFb/sA99D0t/cafrnQ3sq50sJb2+FTefOz804/50DC+++MPDeOTe+XD68GeJGXA6/ff4bJ+OfHt2edj+7ff9T59Ptz47TyD0dpv5fjoIC3AAAAAElFTkSuQmCC", ma = (r) => r.groups ? /* @__PURE__ */ e.jsx("div", { style: { display: "flex" }, children: r.groups ? r.groups.map((l, f) => /* @__PURE__ */ e.jsx("div", { style: { paddingRight: "2px" }, children: /* @__PURE__ */ e.jsx(we, { color: "blue", children: l.group?.name }) }, f)) : null }) : null, ba = (r) => r.profile ? /* @__PURE__ */ e.jsx(we, { color: "green", children: r.profile?.name }) : null;
836
+ function ka({
837
+ height: r = "400px",
838
+ width: l = "100%",
839
+ createEntitiesWithId: f = !0,
840
+ userModalOptions: S,
841
+ profileModalOptions: s,
842
+ groupModalOptions: p
843
+ }) {
844
+ const c = ir(), u = cr("securityStore"), z = Or(), { colorScheme: R } = Me(), [v, d] = U(void 0), [h, H] = U("users"), j = K(X.User), ee = K(X.Group), W = K(X.Resource), re = K(X.Profile), [Q, E] = U(""), [M, F] = U(""), B = K(X.AccessToken), { t: o } = Br(), g = ie(
845
+ "ArchbaseSecurityView-Users",
846
+ void 0,
847
+ // Will be set when dsUsers is available
848
+ void 0,
849
+ void 0
850
+ ), q = ie(
851
+ "ArchbaseSecurityView-Groups",
852
+ void 0,
853
+ // Will be set when dsGroups is available
854
+ void 0,
855
+ void 0
856
+ ), x = ie(
857
+ "ArchbaseSecurityView-Profiles",
858
+ void 0,
859
+ // Will be set when dsProfiles is available
860
+ void 0,
861
+ void 0
862
+ ), b = je(null), D = je(null), ge = je(null), ze = je(null), n = je(null), i = (a) => a.id, G = (a) => a.id, y = (a) => a.id, I = (a) => a.id, A = (a) => a.id, { dataSource: w, isLoading: T } = se({
863
+ name: "accessTokenApi",
864
+ service: B,
865
+ store: u,
866
+ validator: z,
867
+ pageSize: 25,
868
+ loadOnStart: !0,
869
+ filter: Wr(_e.or(_e.eq("revoked", "false"))),
870
+ sort: ["user.email", "expirationTime:desc"],
871
+ onLoadComplete: (a) => {
872
+ },
873
+ onDestroy: (a) => {
874
+ },
875
+ onError: (a, $) => {
876
+ d(a), Y.showError(`${o("archbase:WARNING")}`, a, $);
877
+ }
878
+ }), { dataSource: L, isLoading: Pe } = se({
879
+ name: "dsUsers",
880
+ service: j,
881
+ store: u,
882
+ validator: z,
883
+ pageSize: 25,
884
+ loadOnStart: !0,
885
+ onLoadComplete: (a) => {
886
+ },
887
+ onDestroy: (a) => {
888
+ },
889
+ onError: (a, $) => {
890
+ d(a), Y.showError(`${o("archbase:WARNING")}`, a, $);
891
+ }
892
+ }), { dataSource: O, isLoading: hr } = se({
893
+ name: "dsGroups",
894
+ service: ee,
895
+ store: u,
896
+ validator: z,
897
+ pageSize: 25,
898
+ loadOnStart: !0,
899
+ onLoadComplete: (a) => {
900
+ },
901
+ onDestroy: (a) => {
902
+ },
903
+ onError: (a, $) => {
904
+ d(a), Y.showError(`${o("archbase:WARNING")}`, a, $);
905
+ }
906
+ }), { dataSource: J, isLoading: pr } = se({
907
+ name: "dsProfile",
908
+ service: re,
909
+ store: u,
910
+ validator: z,
911
+ pageSize: 25,
912
+ loadOnStart: !0,
913
+ onLoadComplete: (a) => {
914
+ },
915
+ onDestroy: (a) => {
916
+ },
917
+ onError: (a, $) => {
918
+ d(a), Y.showError(`${o("archbase:WARNING")}`, a, $);
919
+ }
920
+ }), { dataSource: xr, isLoading: mr } = se({
921
+ name: "dsResources",
922
+ service: W,
923
+ store: u,
924
+ validator: z,
925
+ pageSize: 25,
926
+ loadOnStart: !0,
927
+ onLoadComplete: (a) => {
928
+ },
929
+ onDestroy: (a) => {
930
+ },
931
+ onError: (a, $) => {
932
+ d(a), Y.showError(`${o("archbase:WARNING")}`, a, $);
933
+ }
934
+ }), ye = `calc(${r} - 40px)`, br = /* @__PURE__ */ e.jsxs(me, { children: [
935
+ /* @__PURE__ */ e.jsx(
936
+ m,
937
+ {
938
+ dataField: "user.avatar",
939
+ dataType: "image",
940
+ size: 80,
941
+ header: `${o("archbase:Foto")}`,
942
+ render: (a) => /* @__PURE__ */ e.jsx(
943
+ "img",
944
+ {
945
+ style: { borderRadius: 50, height: "32px", maxHeight: "32px" },
946
+ src: a.row.user && a.row.user.avatar ? atob(a.row.user.avatar) : Ue
947
+ }
948
+ ),
949
+ inputFilterType: "text",
950
+ align: "center"
951
+ }
952
+ ),
953
+ /* @__PURE__ */ e.jsx(
954
+ m,
955
+ {
956
+ dataField: "user.userName",
957
+ dataType: "text",
958
+ size: 300,
959
+ header: `${o("archbase:Nome de Usuário")}`,
960
+ inputFilterType: "text"
961
+ }
962
+ ),
963
+ /* @__PURE__ */ e.jsx(
964
+ m,
965
+ {
966
+ dataField: "user.email",
967
+ dataType: "text",
968
+ header: `${o("archbase:Email")}`,
969
+ size: 300,
970
+ inputFilterType: "text"
971
+ }
972
+ ),
973
+ /* @__PURE__ */ e.jsx(
974
+ m,
975
+ {
976
+ dataField: "expirationDate",
977
+ dataType: "text",
978
+ size: 300,
979
+ header: `${o("archbase:Expira em")}`,
980
+ render: (a) => /* @__PURE__ */ e.jsx(Z, { size: "sm", children: a.row.expirationDate }),
981
+ inputFilterType: "text"
982
+ }
983
+ ),
984
+ /* @__PURE__ */ e.jsx(
985
+ m,
986
+ {
987
+ dataField: "revoked",
988
+ dataType: "boolean",
989
+ header: `${o("archbase:Revogado ?")}`,
990
+ inputFilterType: "checkbox"
991
+ }
992
+ ),
993
+ /* @__PURE__ */ e.jsx(
994
+ m,
995
+ {
996
+ dataField: "expired",
997
+ dataType: "boolean",
998
+ header: `${o("archbase:Expirado ?")}`,
999
+ inputFilterType: "checkbox"
1000
+ }
1001
+ ),
1002
+ /* @__PURE__ */ e.jsx(
1003
+ m,
1004
+ {
1005
+ dataField: "token",
1006
+ dataType: "text",
1007
+ header: `${o("archbase:Token Acesso")}`,
1008
+ size: 300,
1009
+ inputFilterType: "text"
1010
+ }
1011
+ )
1012
+ ] }), fr = /* @__PURE__ */ e.jsxs(me, { children: [
1013
+ /* @__PURE__ */ e.jsx(
1014
+ m,
1015
+ {
1016
+ dataField: "avatar",
1017
+ dataType: "image",
1018
+ size: 80,
1019
+ header: `${o("archbase:Foto")}`,
1020
+ render: (a) => /* @__PURE__ */ e.jsx(
1021
+ "img",
1022
+ {
1023
+ style: { borderRadius: 50, height: "32px", maxHeight: "32px" },
1024
+ src: a.row.avatar ? atob(a.row.avatar) : Ue
1025
+ }
1026
+ ),
1027
+ enableSorting: !1,
1028
+ enableColumnFilter: !1,
1029
+ enableGlobalFilter: !1,
1030
+ align: "center"
1031
+ }
1032
+ ),
1033
+ /* @__PURE__ */ e.jsx(
1034
+ m,
1035
+ {
1036
+ dataField: "name",
1037
+ dataType: "text",
1038
+ size: 300,
1039
+ header: `${o("archbase:Nome")}`,
1040
+ inputFilterType: "text"
1041
+ }
1042
+ ),
1043
+ /* @__PURE__ */ e.jsx(
1044
+ m,
1045
+ {
1046
+ dataField: "nickname",
1047
+ dataType: "text",
1048
+ size: 120,
1049
+ header: `${o("archbase:Apelido")}`,
1050
+ inputFilterType: "text"
1051
+ }
1052
+ ),
1053
+ /* @__PURE__ */ e.jsx(
1054
+ m,
1055
+ {
1056
+ dataField: "email",
1057
+ dataType: "text",
1058
+ header: `${o("archbase:Email")}`,
1059
+ size: 300,
1060
+ inputFilterType: "text"
1061
+ }
1062
+ ),
1063
+ /* @__PURE__ */ e.jsx(
1064
+ m,
1065
+ {
1066
+ dataField: "profile.name",
1067
+ dataType: "text",
1068
+ header: `${o("archbase:Perfil")}`,
1069
+ size: 200,
1070
+ render: (a) => ba(a.row),
1071
+ inputFilterType: "text"
1072
+ }
1073
+ ),
1074
+ /* @__PURE__ */ e.jsx(
1075
+ m,
1076
+ {
1077
+ dataField: "groups",
1078
+ dataType: "text",
1079
+ size: 300,
1080
+ header: `${o("archbase:Grupos")}`,
1081
+ render: (a) => ma(a.row),
1082
+ enableSorting: !1,
1083
+ enableColumnFilter: !1,
1084
+ enableGlobalFilter: !1
1085
+ }
1086
+ ),
1087
+ /* @__PURE__ */ e.jsx(
1088
+ m,
1089
+ {
1090
+ dataField: "isAdministrator",
1091
+ dataType: "boolean",
1092
+ header: `${o("archbase:Admin ?")}`,
1093
+ inputFilterType: "checkbox"
1094
+ }
1095
+ ),
1096
+ /* @__PURE__ */ e.jsx(
1097
+ m,
1098
+ {
1099
+ dataField: "changePasswordOnNextLogin",
1100
+ dataType: "boolean",
1101
+ header: `${o("archbase:Alt.senha próximo login?")}`,
1102
+ inputFilterType: "checkbox",
1103
+ size: 120
1104
+ }
1105
+ ),
1106
+ /* @__PURE__ */ e.jsx(
1107
+ m,
1108
+ {
1109
+ dataField: "allowPasswordChange",
1110
+ dataType: "boolean",
1111
+ header: `${o("archbase:Pode alterar senha?")}`,
1112
+ inputFilterType: "checkbox",
1113
+ size: 120
1114
+ }
1115
+ ),
1116
+ /* @__PURE__ */ e.jsx(
1117
+ m,
1118
+ {
1119
+ dataField: "allowMultipleLogins",
1120
+ dataType: "boolean",
1121
+ header: `${o("archbase:Permite multiplos logins?")}`,
1122
+ inputFilterType: "checkbox",
1123
+ size: 120
1124
+ }
1125
+ ),
1126
+ /* @__PURE__ */ e.jsx(
1127
+ m,
1128
+ {
1129
+ dataField: "passwordNeverExpires",
1130
+ dataType: "boolean",
1131
+ header: `${o("archbase:Senha nunca expira?")}`,
1132
+ inputFilterType: "checkbox",
1133
+ size: 120
1134
+ }
1135
+ ),
1136
+ /* @__PURE__ */ e.jsx(
1137
+ m,
1138
+ {
1139
+ dataField: "accountDeactivated",
1140
+ dataType: "boolean",
1141
+ header: `${o("archbase:Desativado?")}`,
1142
+ inputFilterType: "checkbox",
1143
+ size: 120
1144
+ }
1145
+ ),
1146
+ /* @__PURE__ */ e.jsx(
1147
+ m,
1148
+ {
1149
+ dataField: "accountLocked",
1150
+ dataType: "boolean",
1151
+ header: `${o("archbase:Bloqueado?")}`,
1152
+ inputFilterType: "checkbox",
1153
+ size: 120
1154
+ }
1155
+ ),
1156
+ /* @__PURE__ */ e.jsx(
1157
+ m,
1158
+ {
1159
+ dataField: "unlimitedAccessHours",
1160
+ dataType: "boolean",
1161
+ header: `${o("archbase:Horário acesso ilimitado?")}`,
1162
+ inputFilterType: "checkbox",
1163
+ size: 140
1164
+ }
1165
+ )
1166
+ ] }), jr = /* @__PURE__ */ e.jsxs(me, { children: [
1167
+ /* @__PURE__ */ e.jsx(
1168
+ m,
1169
+ {
1170
+ dataField: "name",
1171
+ dataType: "text",
1172
+ size: 300,
1173
+ header: `${o("archbase:Nome do grupo")}`,
1174
+ inputFilterType: "text"
1175
+ }
1176
+ ),
1177
+ /* @__PURE__ */ e.jsx(
1178
+ m,
1179
+ {
1180
+ dataField: "description",
1181
+ dataType: "text",
1182
+ header: `${o("archbase:Descrição")}`,
1183
+ size: 800,
1184
+ inputFilterType: "text"
1185
+ }
1186
+ )
1187
+ ] }), gr = /* @__PURE__ */ e.jsxs(me, { children: [
1188
+ /* @__PURE__ */ e.jsx(
1189
+ m,
1190
+ {
1191
+ dataField: "name",
1192
+ dataType: "text",
1193
+ size: 300,
1194
+ header: `${o("archbase:Nome do perfil")}`,
1195
+ inputFilterType: "text"
1196
+ }
1197
+ ),
1198
+ /* @__PURE__ */ e.jsx(
1199
+ m,
1200
+ {
1201
+ dataField: "description",
1202
+ dataType: "text",
1203
+ header: `${o("archbase:Descrição")}`,
1204
+ size: 800,
1205
+ inputFilterType: "text"
1206
+ }
1207
+ )
1208
+ ] }), yr = /* @__PURE__ */ e.jsxs(me, { children: [
1209
+ /* @__PURE__ */ e.jsx(
1210
+ m,
1211
+ {
1212
+ dataField: "name",
1213
+ dataType: "text",
1214
+ size: 300,
1215
+ header: `${o("archbase:Nome do recurso")}`,
1216
+ inputFilterType: "text"
1217
+ }
1218
+ ),
1219
+ /* @__PURE__ */ e.jsx(
1220
+ m,
1221
+ {
1222
+ dataField: "description",
1223
+ dataType: "text",
1224
+ header: `${o("archbase:Descrição")}`,
1225
+ size: 800,
1226
+ inputFilterType: "text"
1227
+ }
1228
+ )
1229
+ ] }), Sr = () => {
1230
+ const a = Xr.newInstance();
1231
+ f || (a.id = void 0), L.insert(a), L && !g.isDataSourceV2 && g.v1State.forceUpdate(), E(k.USER);
1232
+ }, vr = (a) => {
1233
+ L.isEmpty() || L.gotoRecordByData(a) && (L.edit(), g.isDataSourceV2 || g.v1State.forceUpdate(), E(k.USER));
1234
+ }, wr = (a) => {
1235
+ L.isEmpty() || L.gotoRecordByData(a) && te.showConfirmDialogYesNo(
1236
+ `${o("archbase:Confirme")}`,
1237
+ `${o("archbase:Deseja remover o usuário ")}${a.name} ?`,
1238
+ () => {
1239
+ L.remove(), g.isDataSourceV2 || g.v1State.forceUpdate();
1240
+ },
1241
+ () => {
1242
+ }
1243
+ );
1244
+ }, Cr = (a) => {
1245
+ L.isEmpty() || L.gotoRecordByData(a) && E(k.USER);
1246
+ }, Ar = (a) => /* @__PURE__ */ e.jsxs(P, { gap: 1, wrap: "nowrap", children: [
1247
+ /* @__PURE__ */ e.jsx(N, { variant: "transparent", onClick: () => Cr(a), children: /* @__PURE__ */ e.jsx(Ge, { size: 20, color: R === "dark" ? c.colors.blue[8] : c.colors.blue[4] }) }),
1248
+ /* @__PURE__ */ e.jsx(N, { variant: "transparent", onClick: () => vr(a), children: /* @__PURE__ */ e.jsx(xe, { size: 20, color: R === "dark" ? c.colors.yellow[8] : c.colors.yellow[4] }) }),
1249
+ /* @__PURE__ */ e.jsx(N, { variant: "transparent", onClick: () => wr(a), children: /* @__PURE__ */ e.jsx(ve, { size: 20, color: R === "dark" ? c.colors.red[8] : c.colors.red[4] }) }),
1250
+ /* @__PURE__ */ e.jsx(de, { withinPortal: !0, withArrow: !0, position: "left", label: `${o("archbase:Edit permissions")}`, children: /* @__PURE__ */ e.jsx(N, { variant: "transparent", onClick: qe, children: /* @__PURE__ */ e.jsx(Le, { size: 20, color: R === "dark" ? c.colors.green[8] : c.colors.green[4] }) }) })
1251
+ ] }), Tr = () => {
1252
+ const a = Kr.newInstance();
1253
+ f || (a.id = void 0), O.insert(a), O && !q.isDataSourceV2 && q.v1State.forceUpdate(), E(k.GROUP);
1254
+ }, kr = (a) => {
1255
+ O.isEmpty() || O.gotoRecordByData(a) && (O.edit(), E(k.GROUP));
1256
+ }, Rr = (a) => {
1257
+ O.isEmpty() || O.gotoRecordByData(a) && te.showConfirmDialogYesNo(
1258
+ `${o("archbase:Confirme")}`,
1259
+ `${o("archbase:Deseja remover o grupo ")}${a.name} ?`,
1260
+ () => {
1261
+ O.remove();
1262
+ },
1263
+ () => {
1264
+ }
1265
+ );
1266
+ }, Fr = (a) => {
1267
+ O.isEmpty() || O.gotoRecordByData(a) && E(k.GROUP);
1268
+ }, Ir = (a) => /* @__PURE__ */ e.jsxs(P, { gap: 1, wrap: "nowrap", children: [
1269
+ /* @__PURE__ */ e.jsx(N, { variant: "transparent", onClick: () => Fr(a), children: /* @__PURE__ */ e.jsx(Ge, { size: 20, color: R === "dark" ? c.colors.blue[8] : c.colors.blue[4] }) }),
1270
+ /* @__PURE__ */ e.jsx(N, { variant: "transparent", onClick: () => kr(a), children: /* @__PURE__ */ e.jsx(xe, { size: 20, color: R === "dark" ? c.colors.yellow[8] : c.colors.yellow[4] }) }),
1271
+ /* @__PURE__ */ e.jsx(N, { variant: "transparent", onClick: () => Rr(a), children: /* @__PURE__ */ e.jsx(ve, { size: 20, color: R === "dark" ? c.colors.red[8] : c.colors.red[4] }) }),
1272
+ /* @__PURE__ */ e.jsx(de, { withinPortal: !0, withArrow: !0, position: "left", label: `${o("archbase:Edit permissions")}`, children: /* @__PURE__ */ e.jsx(N, { variant: "transparent", onClick: Je, children: /* @__PURE__ */ e.jsx(Le, { size: 20, color: R === "dark" ? c.colors.green[8] : c.colors.green[4] }) }) })
1273
+ ] }), Oe = () => {
1274
+ E("");
1275
+ }, Be = () => {
1276
+ E("");
1277
+ }, We = () => {
1278
+ E("");
1279
+ }, Er = () => {
1280
+ const a = _r.newInstance();
1281
+ f || (a.id = void 0), J.insert(a), J && !x.isDataSourceV2 && x.v1State.forceUpdate(), E(k.PROFILE);
1282
+ }, zr = (a) => {
1283
+ J.isEmpty() || J.gotoRecordByData(a) && (J.edit(), E(k.PROFILE));
1284
+ }, Pr = (a) => {
1285
+ J.isEmpty() || J.gotoRecordByData(a) && te.showConfirmDialogYesNo(
1286
+ `${o("archbase:Confirme")}`,
1287
+ `${o("archbase:Deseja remover o perfil ")}${a.name} ?`,
1288
+ () => {
1289
+ J.remove();
1290
+ },
1291
+ () => {
1292
+ }
1293
+ );
1294
+ }, Dr = (a) => {
1295
+ J.isEmpty() || J.gotoRecordByData(a) && E(k.PROFILE);
1296
+ }, Gr = (a) => /* @__PURE__ */ e.jsxs(P, { gap: 1, wrap: "nowrap", children: [
1297
+ /* @__PURE__ */ e.jsx(N, { variant: "transparent", onClick: () => Dr(a), children: /* @__PURE__ */ e.jsx(Ge, { size: 20, color: R === "dark" ? c.colors.blue[8] : c.colors.blue[4] }) }),
1298
+ /* @__PURE__ */ e.jsx(N, { variant: "transparent", onClick: () => zr(a), children: /* @__PURE__ */ e.jsx(xe, { size: 20, color: R === "dark" ? c.colors.yellow[8] : c.colors.yellow[4] }) }),
1299
+ /* @__PURE__ */ e.jsx(N, { variant: "transparent", onClick: () => Pr(a), children: /* @__PURE__ */ e.jsx(ve, { size: 20, color: R === "dark" ? c.colors.red[8] : c.colors.red[4] }) }),
1300
+ /* @__PURE__ */ e.jsx(de, { withinPortal: !0, withArrow: !0, position: "left", label: `${o("archbase:Edit permissions")}`, children: /* @__PURE__ */ e.jsx(N, { variant: "transparent", onClick: Ze, children: /* @__PURE__ */ e.jsx(Le, { size: 20, color: R === "dark" ? c.colors.green[8] : c.colors.green[4] }) }) })
1301
+ ] }), Lr = () => {
1302
+ w.getCurrentRecord() && te.showConfirmDialogYesNo(
1303
+ `${o("archbase:Confirme")}`,
1304
+ `${o("archbase:Deseja revogar o token de Acesso do usuário ")}${w.getCurrentRecord().user.name} ?`,
1305
+ async () => {
1306
+ await B.revoke(w.getCurrentRecord().token).then(async () => {
1307
+ Y.showSuccess(
1308
+ `${o("mentors:Informação")}`,
1309
+ `${o("mentors:Token de Acesso revogado com sucesso!")}`
1310
+ ), w.refreshData();
1311
+ }).catch((a) => {
1312
+ te.showErrorWithDetails(
1313
+ `${o("mentors:Atenção")}`,
1314
+ ke(a),
1315
+ Re(a)
1316
+ );
1317
+ });
1318
+ },
1319
+ () => {
1320
+ }
1321
+ );
1322
+ }, qe = () => {
1323
+ F(k.USER);
1324
+ }, Je = () => {
1325
+ F(k.GROUP);
1326
+ }, Ze = () => {
1327
+ F(k.PROFILE);
1328
+ }, De = () => {
1329
+ F("");
1330
+ }, $r = () => /* @__PURE__ */ e.jsxs(ae, { justify: "space-between", style: { width: "50%" }, children: [
1331
+ /* @__PURE__ */ e.jsxs(P, { align: "end", gap: "4px", wrap: "nowrap", children: [
1332
+ /* @__PURE__ */ e.jsx(V, { color: "green", leftSection: /* @__PURE__ */ e.jsx(Fe, {}), onClick: Sr, children: `${o("archbase:New")}` }),
1333
+ /* @__PURE__ */ e.jsx(V, { color: "blue", leftSection: /* @__PURE__ */ e.jsx(xe, {}), onClick: qe, children: `${o("archbase:Edit permissions")}` })
1334
+ ] }),
1335
+ /* @__PURE__ */ e.jsx(ae, { align: "flex-start", justify: "flex-end", style: { width: "200px" } })
1336
+ ] }), Vr = () => /* @__PURE__ */ e.jsxs(ae, { justify: "space-between", style: { width: "50%" }, children: [
1337
+ /* @__PURE__ */ e.jsxs(P, { align: "end", gap: "4px", wrap: "nowrap", children: [
1338
+ /* @__PURE__ */ e.jsx(V, { color: "green", leftSection: /* @__PURE__ */ e.jsx(Fe, {}), onClick: Tr, children: `${o("archbase:New")}` }),
1339
+ /* @__PURE__ */ e.jsx(V, { color: "blue", leftSection: /* @__PURE__ */ e.jsx(xe, {}), onClick: Je, children: `${o("archbase:Edit permissions")}` })
1340
+ ] }),
1341
+ /* @__PURE__ */ e.jsx(ae, { align: "flex-start", justify: "flex-end", style: { width: "200px" } })
1342
+ ] }), Ur = () => /* @__PURE__ */ e.jsxs(ae, { justify: "space-between", style: { width: "50%" }, children: [
1343
+ /* @__PURE__ */ e.jsxs(P, { align: "end", gap: "4px", wrap: "nowrap", children: [
1344
+ /* @__PURE__ */ e.jsx(V, { color: "green", leftSection: /* @__PURE__ */ e.jsx(Fe, {}), onClick: Er, children: `${o("archbase:New")}` }),
1345
+ /* @__PURE__ */ e.jsx(V, { color: "blue", leftSection: /* @__PURE__ */ e.jsx(xe, {}), onClick: Ze, children: `${o("archbase:Edit permissions")}` })
1346
+ ] }),
1347
+ /* @__PURE__ */ e.jsx(ae, { align: "flex-start", justify: "flex-end", style: { width: "200px" } })
1348
+ ] }), Mr = () => /* @__PURE__ */ e.jsx(ae, { justify: "space-between", style: { width: "50%" }, children: /* @__PURE__ */ e.jsx(P, { align: "start", gap: "4px", wrap: "nowrap", children: /* @__PURE__ */ e.jsx(
1349
+ V,
1350
+ {
1351
+ disabled: !w.getCurrentRecord(),
1352
+ color: "red",
1353
+ leftSection: /* @__PURE__ */ e.jsx(ve, {}),
1354
+ onClick: Lr,
1355
+ children: `${o("archbase:Revoke")}`
1356
+ }
1357
+ ) }) });
1358
+ return /* @__PURE__ */ e.jsxs(Ie, { style: { height: r }, children: [
1359
+ /* @__PURE__ */ e.jsx(le, { variant: "pills", value: h, onChange: H, children: /* @__PURE__ */ e.jsxs(le.List, { children: [
1360
+ /* @__PURE__ */ e.jsx(le.Tab, { value: "users", children: `${o("Usuários")}` }),
1361
+ /* @__PURE__ */ e.jsx(le.Tab, { value: "groups", children: `${o("Grupos")}` }),
1362
+ /* @__PURE__ */ e.jsx(le.Tab, { value: "profiles", children: `${o("Perfis")}` }),
1363
+ /* @__PURE__ */ e.jsx(le.Tab, { value: "resources", children: `${o("Recursos")}` }),
1364
+ /* @__PURE__ */ e.jsx(le.Tab, { value: "accessTokens", children: `${o("Tokens Acesso")}` })
1365
+ ] }) }),
1366
+ /* @__PURE__ */ e.jsx(
1367
+ oe,
1368
+ {
1369
+ style: {
1370
+ height: ye,
1371
+ display: h === "users" ? "flex" : "none",
1372
+ width: "100%"
1373
+ },
1374
+ children: /* @__PURE__ */ e.jsx(
1375
+ be,
1376
+ {
1377
+ gridRef: b,
1378
+ printTitle: "Usuários",
1379
+ width: "100%",
1380
+ height: "100%",
1381
+ withBorder: !1,
1382
+ dataSource: L,
1383
+ withColumnBorders: !0,
1384
+ striped: !0,
1385
+ enableTopToolbar: !0,
1386
+ enableRowActions: !0,
1387
+ pageSize: 50,
1388
+ isLoading: Pe,
1389
+ isError: !!v,
1390
+ error: v,
1391
+ enableGlobalFilter: !0,
1392
+ getRowId: i,
1393
+ toolbarLeftContent: $r(),
1394
+ renderRowActions: Ar,
1395
+ children: fr
1396
+ }
1397
+ )
1398
+ }
1399
+ ),
1400
+ /* @__PURE__ */ e.jsx(
1401
+ oe,
1402
+ {
1403
+ style: {
1404
+ height: ye,
1405
+ display: h === "groups" ? "flex" : "none"
1406
+ },
1407
+ children: /* @__PURE__ */ e.jsx(
1408
+ be,
1409
+ {
1410
+ gridRef: D,
1411
+ printTitle: "Grupos",
1412
+ width: "100%",
1413
+ height: "100%",
1414
+ withBorder: !1,
1415
+ dataSource: O,
1416
+ withColumnBorders: !0,
1417
+ striped: !1,
1418
+ enableTopToolbar: !0,
1419
+ enableRowActions: !0,
1420
+ pageSize: 50,
1421
+ isLoading: hr,
1422
+ isError: !!v,
1423
+ error: v,
1424
+ enableGlobalFilter: !0,
1425
+ getRowId: G,
1426
+ renderRowActions: Ir,
1427
+ children: jr,
1428
+ toolbarLeftContent: Vr()
1429
+ }
1430
+ )
1431
+ }
1432
+ ),
1433
+ /* @__PURE__ */ e.jsx(
1434
+ oe,
1435
+ {
1436
+ style: {
1437
+ height: ye,
1438
+ display: h === "profiles" ? "flex" : "none"
1439
+ },
1440
+ children: /* @__PURE__ */ e.jsx(
1441
+ be,
1442
+ {
1443
+ gridRef: ge,
1444
+ printTitle: "Perfis",
1445
+ width: "100%",
1446
+ height: "100%",
1447
+ withBorder: !1,
1448
+ dataSource: J,
1449
+ withColumnBorders: !0,
1450
+ striped: !1,
1451
+ enableTopToolbar: !0,
1452
+ enableRowActions: !0,
1453
+ pageSize: 50,
1454
+ isLoading: pr,
1455
+ isError: !!v,
1456
+ error: v,
1457
+ enableGlobalFilter: !0,
1458
+ getRowId: y,
1459
+ toolbarLeftContent: Ur(),
1460
+ renderRowActions: Gr,
1461
+ children: gr
1462
+ }
1463
+ )
1464
+ }
1465
+ ),
1466
+ /* @__PURE__ */ e.jsx(
1467
+ oe,
1468
+ {
1469
+ style: {
1470
+ height: ye,
1471
+ display: h === "resources" ? "flex" : "none"
1472
+ },
1473
+ children: /* @__PURE__ */ e.jsx(
1474
+ be,
1475
+ {
1476
+ gridRef: ze,
1477
+ printTitle: "Recursos",
1478
+ width: "100%",
1479
+ height: "100%",
1480
+ withBorder: !1,
1481
+ dataSource: xr,
1482
+ withColumnBorders: !0,
1483
+ striped: !1,
1484
+ enableTopToolbar: !0,
1485
+ enableRowActions: !1,
1486
+ pageSize: 50,
1487
+ isLoading: mr,
1488
+ isError: !!v,
1489
+ error: v,
1490
+ enableGlobalFilter: !0,
1491
+ getRowId: I,
1492
+ children: yr
1493
+ }
1494
+ )
1495
+ }
1496
+ ),
1497
+ /* @__PURE__ */ e.jsx(
1498
+ oe,
1499
+ {
1500
+ style: {
1501
+ height: ye,
1502
+ display: h === "accessTokens" ? "flex" : "none",
1503
+ width: "100%"
1504
+ },
1505
+ children: /* @__PURE__ */ e.jsx(
1506
+ be,
1507
+ {
1508
+ gridRef: n,
1509
+ printTitle: "Tokens de API",
1510
+ width: "100%",
1511
+ height: "100%",
1512
+ withBorder: !1,
1513
+ dataSource: w,
1514
+ withColumnBorders: !0,
1515
+ striped: !0,
1516
+ enableTopToolbar: !0,
1517
+ enableRowActions: !1,
1518
+ pageSize: 50,
1519
+ isLoading: T,
1520
+ isError: !!v,
1521
+ error: v,
1522
+ enableGlobalFilter: !0,
1523
+ getRowId: A,
1524
+ toolbarLeftContent: Mr(),
1525
+ children: br
1526
+ }
1527
+ )
1528
+ }
1529
+ ),
1530
+ Q === k.USER ? /* @__PURE__ */ e.jsx(
1531
+ ua,
1532
+ {
1533
+ onClickOk: Oe,
1534
+ opened: !0,
1535
+ dataSource: L,
1536
+ onClickCancel: Oe,
1537
+ options: S
1538
+ }
1539
+ ) : null,
1540
+ Q === k.GROUP ? /* @__PURE__ */ e.jsx(
1541
+ ha,
1542
+ {
1543
+ onClickOk: Be,
1544
+ opened: !0,
1545
+ dataSource: O,
1546
+ onClickCancel: Be,
1547
+ options: p
1548
+ }
1549
+ ) : null,
1550
+ Q === k.PROFILE ? /* @__PURE__ */ e.jsx(
1551
+ ia,
1552
+ {
1553
+ onClickOk: We,
1554
+ opened: !0,
1555
+ dataSource: J,
1556
+ onClickCancel: We,
1557
+ options: s
1558
+ }
1559
+ ) : null,
1560
+ M === k.USER ? /* @__PURE__ */ e.jsx(
1561
+ Ve,
1562
+ {
1563
+ dataSource: L,
1564
+ opened: !!M,
1565
+ close: De
1566
+ }
1567
+ ) : null,
1568
+ M === k.GROUP ? /* @__PURE__ */ e.jsx(
1569
+ Ve,
1570
+ {
1571
+ dataSource: O,
1572
+ opened: !!M,
1573
+ close: De
1574
+ }
1575
+ ) : null,
1576
+ M === k.PROFILE ? /* @__PURE__ */ e.jsx(
1577
+ Ve,
1578
+ {
1579
+ dataSource: J,
1580
+ opened: !!M,
1581
+ close: De
1582
+ }
1583
+ ) : null
1584
+ ] });
1585
+ }
1586
+ function Ra({ height: r = "400px", width: l = "100%" }) {
1587
+ ir();
1588
+ const f = cr("apiTokenStore"), S = { validateEntity: () => [] }, { colorScheme: s } = Me(), [p, c] = U(void 0), u = K(X.ApiToken), [z, R] = U(""), v = je(null), d = (g) => g.id, { dataSource: h } = Hr({
1589
+ initialData: [],
1590
+ name: "dataSource"
1591
+ }), H = ie(
1592
+ "ArchbaseApiTokenView-LocalDataSource",
1593
+ h,
1594
+ void 0,
1595
+ void 0
1596
+ ), { dataSource: j, isLoading: ee } = se({
1597
+ name: "dsApiToken",
1598
+ service: u,
1599
+ store: f,
1600
+ validator: S,
1601
+ pageSize: 25,
1602
+ loadOnStart: !0,
1603
+ onLoadComplete: (g) => {
1604
+ },
1605
+ onDestroy: (g) => {
1606
+ },
1607
+ onError: (g, q) => {
1608
+ c(g), Y.showError(t().t("archbase:WARNING"), g, q);
1609
+ }
1610
+ }), W = ie(
1611
+ "ArchbaseApiTokenView-RemoteDataSource",
1612
+ j,
1613
+ void 0,
1614
+ void 0
1615
+ ), re = `calc(${r} - 40px)`, Q = /* @__PURE__ */ e.jsxs(me, { children: [
1616
+ /* @__PURE__ */ e.jsx(
1617
+ m,
1618
+ {
1619
+ dataField: "user.avatar",
1620
+ dataType: "image",
1621
+ size: 80,
1622
+ header: "Foto",
1623
+ render: (g) => /* @__PURE__ */ e.jsx(
1624
+ "img",
1625
+ {
1626
+ style: { borderRadius: 50, height: "32px", maxHeight: "32px" },
1627
+ src: g.row.user && g.row.user.avatar ? atob(g.row.user.avatar) : Ue
1628
+ }
1629
+ ),
1630
+ inputFilterType: "text",
1631
+ align: "center"
1632
+ }
1633
+ ),
1634
+ /* @__PURE__ */ e.jsx(
1635
+ m,
1636
+ {
1637
+ dataField: "user.userName",
1638
+ dataType: "text",
1639
+ size: 300,
1640
+ header: "Nome de Usuário",
1641
+ inputFilterType: "text"
1642
+ }
1643
+ ),
1644
+ /* @__PURE__ */ e.jsx(
1645
+ m,
1646
+ {
1647
+ dataField: "user.email",
1648
+ dataType: "text",
1649
+ header: "Email",
1650
+ size: 240,
1651
+ inputFilterType: "text"
1652
+ }
1653
+ ),
1654
+ /* @__PURE__ */ e.jsx(
1655
+ m,
1656
+ {
1657
+ dataField: "token",
1658
+ dataType: "text",
1659
+ header: "Token API",
1660
+ size: 260,
1661
+ inputFilterType: "text",
1662
+ enableClickToCopy: !0
1663
+ }
1664
+ ),
1665
+ /* @__PURE__ */ e.jsx(
1666
+ m,
1667
+ {
1668
+ dataField: "tenantId",
1669
+ dataType: "text",
1670
+ header: "Tenant ID",
1671
+ size: 260,
1672
+ inputFilterType: "text",
1673
+ enableClickToCopy: !0
1674
+ }
1675
+ ),
1676
+ /* @__PURE__ */ e.jsx(
1677
+ m,
1678
+ {
1679
+ dataField: "expirationDate",
1680
+ dataType: "text",
1681
+ size: 300,
1682
+ header: "Expira em",
1683
+ render: (g) => /* @__PURE__ */ e.jsx(Z, { children: g.row.expirationDate ? new Date(g.row.expirationDate).toLocaleDateString() : "-" }),
1684
+ inputFilterType: "text"
1685
+ }
1686
+ ),
1687
+ /* @__PURE__ */ e.jsx(
1688
+ m,
1689
+ {
1690
+ dataField: "activated",
1691
+ dataType: "boolean",
1692
+ header: "Ativado ?",
1693
+ inputFilterType: "checkbox"
1694
+ }
1695
+ ),
1696
+ /* @__PURE__ */ e.jsx(
1697
+ m,
1698
+ {
1699
+ dataField: "revoked",
1700
+ dataType: "boolean",
1701
+ header: "Revogado ?",
1702
+ inputFilterType: "checkbox"
1703
+ }
1704
+ )
1705
+ ] }), E = () => {
1706
+ h.insert(ea.newInstance()), h && !H.isDataSourceV2 && H.v1State.forceUpdate(), R("apiToken");
1707
+ }, M = () => {
1708
+ j.getCurrentRecord() && te.showConfirmDialogYesNo(
1709
+ `${t().t("archbase:Confirme")}`,
1710
+ `${t().t("archbase:Deseja revogar o token de API do usuário ")}${j.getCurrentRecord().user.name} ?`,
1711
+ async () => {
1712
+ await u.revoke(j.getCurrentRecord().token).then(async () => {
1713
+ Y.showSuccess(
1714
+ `${t().t("mentors:Informação")}`,
1715
+ `${t().t("mentors:Token de API revogado com sucesso!")}`
1716
+ ), j.refreshData(), j && !W.isDataSourceV2 && W.v1State.forceUpdate();
1717
+ }).catch((g) => {
1718
+ te.showErrorWithDetails(
1719
+ `${t().t("mentors:Atenção")}`,
1720
+ ke(g),
1721
+ Re(g)
1722
+ );
1723
+ });
1724
+ },
1725
+ () => {
1726
+ }
1727
+ );
1728
+ }, F = () => {
1729
+ R("");
1730
+ }, B = async (g, q) => {
1731
+ const x = h.getCurrentRecord();
1732
+ if (x)
1733
+ try {
1734
+ h.validate(), await u.create(x.user.email, x.expirationDate, x.name, x.description).then(async (b) => {
1735
+ h.cancel(), h && !H.isDataSourceV2 && H.v1State.forceUpdate(), j.append(b), j && !W.isDataSourceV2 && W.v1State.forceUpdate(), Y.showSuccess(
1736
+ `${t().t("mentors:Informação")}`,
1737
+ `${t().t("mentors:Token de API gerado com sucesso!")}`
1738
+ ), q && q();
1739
+ }).catch((b) => {
1740
+ te.showErrorWithDetails(
1741
+ `${t().t("mentors:Atenção")}`,
1742
+ ke(b),
1743
+ Re(b)
1744
+ );
1745
+ });
1746
+ } catch (b) {
1747
+ te.showErrorWithDetails(
1748
+ `${t().t("mentors:Atenção")}`,
1749
+ ke(b),
1750
+ Re(b)
1751
+ );
1752
+ }
1753
+ }, o = () => /* @__PURE__ */ e.jsx(ae, { justify: "space-between", style: { width: "50%" }, children: /* @__PURE__ */ e.jsxs(P, { align: "start", gap: "2px", wrap: "nowrap", children: [
1754
+ /* @__PURE__ */ e.jsx(V, { color: "green", leftSection: /* @__PURE__ */ e.jsx(Fe, {}), onClick: E, children: t().t("archbase:New") }),
1755
+ /* @__PURE__ */ e.jsx(V, { disabled: !j.getCurrentRecord(), color: "red", leftSection: /* @__PURE__ */ e.jsx(ve, {}), onClick: M, children: t().t("archbase:Revoke") })
1756
+ ] }) });
1757
+ return /* @__PURE__ */ e.jsxs(Ie, { style: { height: r }, children: [
1758
+ /* @__PURE__ */ e.jsx(
1759
+ oe,
1760
+ {
1761
+ style: {
1762
+ height: re,
1763
+ display: "flex",
1764
+ width: "100%"
1765
+ },
1766
+ children: /* @__PURE__ */ e.jsx(
1767
+ be,
1768
+ {
1769
+ gridRef: v,
1770
+ printTitle: "Tokens de API",
1771
+ width: "100%",
1772
+ height: "100%",
1773
+ withBorder: !1,
1774
+ dataSource: j,
1775
+ withColumnBorders: !0,
1776
+ striped: !0,
1777
+ enableTopToolbar: !0,
1778
+ enableRowActions: !1,
1779
+ pageSize: 50,
1780
+ isLoading: ee,
1781
+ isError: !!p,
1782
+ error: p,
1783
+ enableGlobalFilter: !0,
1784
+ getRowId: d,
1785
+ toolbarLeftContent: o(),
1786
+ children: Q
1787
+ }
1788
+ )
1789
+ }
1790
+ ),
1791
+ z === "apiToken" ? /* @__PURE__ */ e.jsx(
1792
+ xa,
1793
+ {
1794
+ onClickOk: F,
1795
+ opened: !0,
1796
+ dataSource: h,
1797
+ onCustomSave: B,
1798
+ onClickCancel: F
1799
+ }
1800
+ ) : null
1801
+ ] });
1802
+ }
1803
+ export {
1804
+ xa as ApiTokenModal,
1805
+ Ra as ArchbaseApiTokenView,
1806
+ la as ArchbaseDualListSelector,
1807
+ ka as ArchbaseSecurityView,
1808
+ ha as GroupModal,
1809
+ Ve as PermissionsSelectorModal,
1810
+ ia as ProfileModal,
1811
+ ca as RenderProfileUserItem,
1812
+ ua as UserModal
1813
+ };
1814
+ //# sourceMappingURL=index.js.map