@firecms/user_management 3.0.0-3.0.0-beta.4.pre.1.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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +157 -0
  3. package/dist/UserManagementProvider.d.ts +7 -0
  4. package/dist/admin_views.d.ts +2 -0
  5. package/dist/components/index.d.ts +2 -0
  6. package/dist/components/roles/RoleChip.d.ts +5 -0
  7. package/dist/components/roles/RolesDetailsForm.d.ts +20 -0
  8. package/dist/components/roles/RolesTable.d.ts +5 -0
  9. package/dist/components/roles/RolesView.d.ts +4 -0
  10. package/dist/components/roles/default_roles.d.ts +2 -0
  11. package/dist/components/roles/index.d.ts +4 -0
  12. package/dist/components/users/UserDetailsForm.d.ts +20 -0
  13. package/dist/components/users/UsersTable.d.ts +4 -0
  14. package/dist/components/users/UsersView.d.ts +4 -0
  15. package/dist/components/users/index.d.ts +3 -0
  16. package/dist/hooks/index.d.ts +2 -0
  17. package/dist/hooks/useBuildFirestoreUserManagement.d.ts +44 -0
  18. package/dist/hooks/useUserManagement.d.ts +2 -0
  19. package/dist/index.d.ts +7 -0
  20. package/dist/index.es.js +1263 -0
  21. package/dist/index.es.js.map +1 -0
  22. package/dist/index.umd.js +2 -0
  23. package/dist/index.umd.js.map +1 -0
  24. package/dist/types/firecms_user.d.ts +7 -0
  25. package/dist/types/index.d.ts +3 -0
  26. package/dist/types/roles.d.ts +31 -0
  27. package/dist/types/user_management.d.ts +39 -0
  28. package/dist/useUserManagementPlugin.d.ts +5 -0
  29. package/dist/utils/colors.d.ts +2 -0
  30. package/dist/utils/index.d.ts +3 -0
  31. package/dist/utils/local_storage.d.ts +3 -0
  32. package/dist/utils/permissions.d.ts +9 -0
  33. package/dist/utils/useTraceUpdate.d.ts +1 -0
  34. package/package.json +76 -0
  35. package/src/UserManagementProvider.tsx +19 -0
  36. package/src/admin_views.tsx +19 -0
  37. package/src/components/index.ts +2 -0
  38. package/src/components/roles/RoleChip.tsx +28 -0
  39. package/src/components/roles/RolesDetailsForm.tsx +402 -0
  40. package/src/components/roles/RolesTable.tsx +139 -0
  41. package/src/components/roles/RolesView.tsx +63 -0
  42. package/src/components/roles/default_roles.tsx +36 -0
  43. package/src/components/roles/index.ts +4 -0
  44. package/src/components/users/UserDetailsForm.tsx +230 -0
  45. package/src/components/users/UsersTable.tsx +178 -0
  46. package/src/components/users/UsersView.tsx +59 -0
  47. package/src/components/users/index.ts +3 -0
  48. package/src/hooks/index.ts +2 -0
  49. package/src/hooks/useBuildFirestoreUserManagement.tsx +241 -0
  50. package/src/hooks/useUserManagement.tsx +5 -0
  51. package/src/index.ts +7 -0
  52. package/src/types/firecms_user.ts +8 -0
  53. package/src/types/index.ts +3 -0
  54. package/src/types/roles.ts +41 -0
  55. package/src/types/user_management.tsx +50 -0
  56. package/src/useUserManagementPlugin.tsx +18 -0
  57. package/src/utils/colors.ts +52 -0
  58. package/src/utils/index.ts +3 -0
  59. package/src/utils/local_storage.ts +53 -0
  60. package/src/utils/permissions.ts +83 -0
  61. package/src/utils/useTraceUpdate.tsx +23 -0
  62. package/tailwind.config.js +68 -0
@@ -0,0 +1,1263 @@
1
+ import A, { useRef as Se, useEffect as Z, useCallback as E, useContext as Ie, useState as F } from "react";
2
+ import { getFirestore as ee, onSnapshot as le, collection as se, setDoc as ae, doc as G, deleteDoc as ce } from "firebase/firestore";
3
+ import { jsx as e, jsxs as s, Fragment as H } from "react/jsx-runtime";
4
+ import { getColorSchemeForSeed as ke, Chip as Ee, Dialog as de, DialogContent as ue, Typography as _, TextField as K, Paper as Pe, Table as ie, TableHeader as re, TableCell as a, TableBody as oe, TableRow as M, Tooltip as L, Checkbox as P, Select as ne, SelectItem as T, DialogActions as me, Button as q, LoadingButton as he, DoneIcon as fe, IconButton as ge, DeleteIcon as pe, CenteredView as Ce, Container as ve, AddIcon as we, MultiSelect as Ae, MultiSelectItem as Fe } from "@firecms/ui";
5
+ import * as V from "yup";
6
+ import { toSnakeCase as Te, FieldCaption as B, DeleteConfirmationDialog as ye, useNavigationController as Be, useSnackbarController as be, useAuthController as Le, useCustomizationController as Ve, defaultDateFormat as _e } from "@firecms/core";
7
+ import { useCreateFormex as Ne, getIn as j, Formex as xe } from "@firecms/formex";
8
+ import { format as Oe } from "date-fns";
9
+ import * as $e from "date-fns/locale";
10
+ const hn = ["Admin"], Me = {
11
+ read: !1,
12
+ edit: !1,
13
+ create: !1,
14
+ delete: !1
15
+ };
16
+ function qe({ collection: t, user: i }) {
17
+ const n = i?.roles;
18
+ if (n) {
19
+ if (t.ownerId === i?.uid)
20
+ return {
21
+ read: !0,
22
+ create: !0,
23
+ edit: !0,
24
+ delete: !0
25
+ };
26
+ {
27
+ const d = {
28
+ read: !1,
29
+ create: !1,
30
+ edit: !1,
31
+ delete: !1
32
+ };
33
+ return n.map((r) => Ye(r, t.id)).reduce(te, d);
34
+ }
35
+ } else
36
+ return Me;
37
+ }
38
+ function Ye(t, i) {
39
+ const n = {
40
+ read: t.isAdmin || t.defaultPermissions?.read,
41
+ create: t.isAdmin || t.defaultPermissions?.create,
42
+ edit: t.isAdmin || t.defaultPermissions?.edit,
43
+ delete: t.isAdmin || t.defaultPermissions?.delete
44
+ };
45
+ return t.collectionPermissions && t.collectionPermissions[i] ? te(t.collectionPermissions[i], n) : t.defaultPermissions ? te(t.defaultPermissions, n) : n;
46
+ }
47
+ const te = (t, i) => ({
48
+ read: t.read || i.read,
49
+ create: t.create || i.create,
50
+ edit: t.edit || i.edit,
51
+ delete: t.delete || i.delete
52
+ });
53
+ function fn(t, i) {
54
+ return t ? i.roles ? i.roles.map((n) => t.find((d) => d.id === n.id)).filter(Boolean) : [] : void 0;
55
+ }
56
+ const We = (t, i) => {
57
+ const n = t.map((r) => r.id), d = i.map((r) => r.id);
58
+ return n.length === i.length && n.every((r) => d.includes(r));
59
+ };
60
+ function gn(t, i) {
61
+ if (!i)
62
+ return;
63
+ const n = je(i), d = new Date(n.exp * 1e3);
64
+ localStorage.setItem(`auth_token::${t}`, JSON.stringify({
65
+ token: i,
66
+ expiry: d
67
+ }));
68
+ }
69
+ function pn(t) {
70
+ const i = localStorage.getItem(`auth_token::${t}`);
71
+ if (i) {
72
+ const n = JSON.parse(i);
73
+ if (n.expiry = new Date(n.expiry), n.expiry > /* @__PURE__ */ new Date())
74
+ return n.token;
75
+ }
76
+ }
77
+ function Cn() {
78
+ for (let t = 0; t < localStorage.length; t++) {
79
+ const i = localStorage.key(t);
80
+ i?.startsWith("auth_token::") && localStorage.removeItem(i);
81
+ }
82
+ }
83
+ function je(t) {
84
+ if (!t)
85
+ throw new Error("No JWT token");
86
+ const n = t.split(".")[1].replace(/-/g, "+").replace(/_/g, "/"), d = decodeURIComponent(window.atob(n).split("").map(function(r) {
87
+ return "%" + ("00" + r.charCodeAt(0).toString(16)).slice(-2);
88
+ }).join(""));
89
+ return JSON.parse(d);
90
+ }
91
+ function vn(t, i = 10) {
92
+ if (!/^#([0-9A-Fa-f]{3}){1,2}$/.test(t))
93
+ throw new Error("Invalid color format");
94
+ let n = t.substring(1).split("");
95
+ n.length === 3 && (n = [n[0], n[0], n[1], n[1], n[2], n[2]]);
96
+ let d = parseInt(n[0] + n[1], 16), r = parseInt(n[2] + n[3], 16), m = parseInt(n[4] + n[5], 16);
97
+ return d = Math.floor(d * (1 - i / 100)), r = Math.floor(r * (1 - i / 100)), m = Math.floor(m * (1 - i / 100)), "#" + (d < 16 ? "0" : "") + d.toString(16) + (r < 16 ? "0" : "") + r.toString(16) + (m < 16 ? "0" : "") + m.toString(16);
98
+ }
99
+ function wn(t, i = 10) {
100
+ if (!/^#([0-9A-Fa-f]{3}){1,2}$/.test(t))
101
+ throw new Error("Invalid color format");
102
+ let n = t.substring(1).split("");
103
+ n.length === 3 && (n = [n[0], n[0], n[1], n[1], n[2], n[2]]);
104
+ const d = parseInt(n[0] + n[1], 16), r = parseInt(n[2] + n[3], 16), m = parseInt(n[4] + n[5], 16), f = i / 100;
105
+ return `rgba(${d}, ${r}, ${m}, ${f})`;
106
+ }
107
+ function yn({
108
+ firebaseApp: t,
109
+ usersPath: i = "__FIRECMS/config/users",
110
+ rolesPath: n = "__FIRECMS/config/roles",
111
+ usersLimit: d,
112
+ canEditRoles: r = !0,
113
+ authController: m,
114
+ allowDefaultRolesCreation: f,
115
+ includeCollectionConfigPermissions: p
116
+ }) {
117
+ const N = Se(), [v, c] = A.useState(!0), [I, w] = A.useState(!0), [l, g] = A.useState([]), [R, y] = A.useState([]), O = R.map((C) => ({
118
+ ...C,
119
+ roles: l.filter((b) => C.roles?.includes(b.id))
120
+ })), [z, u] = A.useState(), [h, x] = A.useState(), U = v || I, k = O.find((C) => C.email?.toLowerCase() === m.user?.email?.toLowerCase());
121
+ Z(() => {
122
+ t && (N.current = ee(t));
123
+ }, [t]), Z(() => {
124
+ if (!t || !n)
125
+ return;
126
+ const C = ee(t);
127
+ return le(
128
+ se(C, n),
129
+ {
130
+ next: (b) => {
131
+ u(void 0);
132
+ try {
133
+ const D = Je(b.docs);
134
+ g(D);
135
+ } catch (D) {
136
+ u(D);
137
+ }
138
+ c(!1);
139
+ },
140
+ error: (b) => {
141
+ u(b), c(!1);
142
+ }
143
+ }
144
+ );
145
+ }, [t, n]), Z(() => {
146
+ if (!t || !i)
147
+ return;
148
+ const C = ee(t);
149
+ return le(
150
+ se(C, i),
151
+ {
152
+ next: (b) => {
153
+ x(void 0);
154
+ try {
155
+ const D = ze(b.docs);
156
+ y(D);
157
+ } catch (D) {
158
+ x(D);
159
+ }
160
+ w(!1);
161
+ },
162
+ error: (b) => {
163
+ x(b), w(!1);
164
+ }
165
+ }
166
+ );
167
+ }, [t, i]);
168
+ const o = E(async (C) => {
169
+ const b = N.current;
170
+ if (!b || !i)
171
+ throw Error("useFirestoreConfigurationPersistence Firestore not initialised");
172
+ console.debug("Persisting user", C);
173
+ const D = C.roles.map((Ue) => Ue.id), {
174
+ uid: W,
175
+ ...X
176
+ } = C;
177
+ return ae(G(b, i, W), { ...X, roles: D }, { merge: !0 }).then(() => C);
178
+ }, [i]), S = E((C) => {
179
+ const b = N.current;
180
+ if (!b || !n)
181
+ throw Error("useFirestoreConfigurationPersistence Firestore not initialised");
182
+ console.debug("Persisting role", C);
183
+ const {
184
+ id: D,
185
+ ...W
186
+ } = C, X = G(b, n, D);
187
+ return ae(X, W, { merge: !0 });
188
+ }, [n]), $ = E(async (C) => {
189
+ const b = N.current;
190
+ if (!b || !i)
191
+ throw Error("useFirestoreConfigurationPersistence Firestore not initialised");
192
+ console.debug("Deleting", C);
193
+ const { uid: D } = C;
194
+ return ce(G(b, i, D));
195
+ }, [i]), J = E((C) => {
196
+ const b = N.current;
197
+ if (!b || !n)
198
+ throw Error("useFirestoreConfigurationPersistence Firestore not initialised");
199
+ console.debug("Deleting", C);
200
+ const { id: D } = C, W = G(b, n, D);
201
+ return ce(W);
202
+ }, [n]), De = E(({
203
+ collection: C
204
+ }) => qe({
205
+ collection: C,
206
+ user: k ?? null
207
+ }), [k?.uid]);
208
+ return {
209
+ loading: U,
210
+ loggedInUser: k,
211
+ roles: l,
212
+ users: O,
213
+ saveUser: o,
214
+ saveRole: S,
215
+ deleteUser: $,
216
+ deleteRole: J,
217
+ usersLimit: d,
218
+ canEditRoles: r === void 0 ? !0 : r,
219
+ allowDefaultRolesCreation: f === void 0 ? !0 : f,
220
+ includeCollectionConfigPermissions: !!p,
221
+ collectionPermissions: De
222
+ };
223
+ }
224
+ const ze = (t) => t.map((i) => {
225
+ const n = i.data();
226
+ return {
227
+ uid: i.id,
228
+ ...n,
229
+ created_on: n?.created_on?.toDate(),
230
+ updated_on: n?.updated_on?.toDate()
231
+ };
232
+ }), Je = (t) => t.map((i) => ({
233
+ id: i.id,
234
+ ...i.data()
235
+ })), Re = A.createContext({});
236
+ function Ge({
237
+ children: t,
238
+ userManagement: i
239
+ }) {
240
+ return /* @__PURE__ */ e(Re.Provider, { value: i, children: t });
241
+ }
242
+ const Y = () => Ie(Re);
243
+ function Q({ role: t }) {
244
+ let i;
245
+ return t.isAdmin ? i = "blueDarker" : t.id === "editor" ? i = "yellowLight" : t.id === "viewer" ? i = "grayLight" : i = ke(t.id), /* @__PURE__ */ e(
246
+ Ee,
247
+ {
248
+ colorScheme: i,
249
+ children: t.name
250
+ },
251
+ t.id
252
+ );
253
+ }
254
+ const He = V.object().shape({
255
+ id: V.string().required("Required"),
256
+ name: V.string().required("Required")
257
+ });
258
+ function Ke({
259
+ open: t,
260
+ role: i,
261
+ editable: n,
262
+ handleClose: d,
263
+ collections: r
264
+ }) {
265
+ const { saveRole: m } = Y(), f = !i, [p, N] = F(), v = E((o) => (N(void 0), m(o)), [m]), c = Ne({
266
+ initialValues: i ?? {
267
+ name: ""
268
+ },
269
+ onSubmit: (o, S) => v(o).then(() => {
270
+ S.resetForm({
271
+ values: o
272
+ }), d();
273
+ }).catch(($) => N($)),
274
+ validation: (o) => He.validate(o, { abortEarly: !1 }).then(() => ({})).catch((S) => {
275
+ const $ = {};
276
+ return S.inner.forEach((J) => {
277
+ $[J.path] = J.message;
278
+ }), $;
279
+ })
280
+ }), {
281
+ isSubmitting: I,
282
+ touched: w,
283
+ values: l,
284
+ errors: g,
285
+ handleChange: R,
286
+ setFieldValue: y,
287
+ dirty: O,
288
+ setFieldTouched: z
289
+ } = c, u = l.isAdmin ?? !1, h = l.defaultPermissions?.create ?? !1, x = l.defaultPermissions?.read ?? !1, U = l.defaultPermissions?.edit ?? !1, k = l.defaultPermissions?.delete ?? !1;
290
+ return A.useEffect(() => {
291
+ !j(w, "id") && l.name && y("id", Te(l.name));
292
+ }, [w, l.name]), /* @__PURE__ */ e(
293
+ de,
294
+ {
295
+ open: t,
296
+ maxWidth: "4xl",
297
+ children: /* @__PURE__ */ e(xe, { value: c, children: /* @__PURE__ */ s(
298
+ "form",
299
+ {
300
+ noValidate: !0,
301
+ autoComplete: "off",
302
+ onSubmit: c.handleSubmit,
303
+ style: {
304
+ display: "flex",
305
+ flexDirection: "column",
306
+ position: "relative",
307
+ height: "100%"
308
+ },
309
+ children: [
310
+ /* @__PURE__ */ s(ue, { className: "flex-grow", children: [
311
+ /* @__PURE__ */ e(
312
+ "div",
313
+ {
314
+ className: "flex flex-row pt-12 pb-8",
315
+ children: /* @__PURE__ */ e(
316
+ _,
317
+ {
318
+ variant: "h4",
319
+ className: "flex-grow",
320
+ children: "Role"
321
+ }
322
+ )
323
+ }
324
+ ),
325
+ /* @__PURE__ */ s("div", { className: "grid grid-cols-12 gap-8", children: [
326
+ /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-8", children: [
327
+ /* @__PURE__ */ e(
328
+ K,
329
+ {
330
+ name: "name",
331
+ required: !0,
332
+ error: w.name && !!g.name,
333
+ value: l.name,
334
+ disabled: u || !n,
335
+ onChange: R,
336
+ "aria-describedby": "name-helper-text",
337
+ label: "Name"
338
+ }
339
+ ),
340
+ /* @__PURE__ */ e(B, { children: w.name && g.name ? g.name : "Name of this role" })
341
+ ] }),
342
+ /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
343
+ /* @__PURE__ */ e(
344
+ K,
345
+ {
346
+ name: "id",
347
+ required: !0,
348
+ error: w.id && !!g.id,
349
+ value: l.id,
350
+ disabled: !f || !n,
351
+ onChange: (o) => {
352
+ R(o), z("id", !0);
353
+ },
354
+ "aria-describedby": "id-helper-text",
355
+ label: "ID"
356
+ }
357
+ ),
358
+ /* @__PURE__ */ e(B, { children: w.id && g.id ? g.id : "ID of this role" })
359
+ ] }),
360
+ /* @__PURE__ */ s("div", { className: "col-span-12", children: [
361
+ /* @__PURE__ */ e(
362
+ Pe,
363
+ {
364
+ className: "bg-inherit",
365
+ children: /* @__PURE__ */ s(ie, { children: [
366
+ /* @__PURE__ */ s(re, { children: [
367
+ /* @__PURE__ */ e(a, {}),
368
+ /* @__PURE__ */ e(
369
+ a,
370
+ {
371
+ align: "center",
372
+ children: "Create entities"
373
+ }
374
+ ),
375
+ /* @__PURE__ */ e(
376
+ a,
377
+ {
378
+ align: "center",
379
+ children: "Read entities"
380
+ }
381
+ ),
382
+ /* @__PURE__ */ e(
383
+ a,
384
+ {
385
+ align: "center",
386
+ children: "Update entities"
387
+ }
388
+ ),
389
+ /* @__PURE__ */ e(
390
+ a,
391
+ {
392
+ align: "center",
393
+ children: "Delete entities"
394
+ }
395
+ )
396
+ ] }),
397
+ /* @__PURE__ */ s(oe, { children: [
398
+ /* @__PURE__ */ s(M, { children: [
399
+ /* @__PURE__ */ e(
400
+ a,
401
+ {
402
+ scope: "row",
403
+ children: /* @__PURE__ */ e("strong", { children: "All collections" })
404
+ }
405
+ ),
406
+ /* @__PURE__ */ e(
407
+ a,
408
+ {
409
+ align: "center",
410
+ children: /* @__PURE__ */ e(
411
+ L,
412
+ {
413
+ title: "Create entities in collections",
414
+ children: /* @__PURE__ */ e(
415
+ P,
416
+ {
417
+ disabled: u || !n,
418
+ checked: (u || h) ?? !1,
419
+ onCheckedChange: (o) => y("defaultPermissions.create", o)
420
+ }
421
+ )
422
+ }
423
+ )
424
+ }
425
+ ),
426
+ /* @__PURE__ */ e(
427
+ a,
428
+ {
429
+ align: "center",
430
+ children: /* @__PURE__ */ e(
431
+ L,
432
+ {
433
+ title: "Access all data in every collection",
434
+ children: /* @__PURE__ */ e(
435
+ P,
436
+ {
437
+ disabled: u || !n,
438
+ checked: (u || x) ?? !1,
439
+ onCheckedChange: (o) => y("defaultPermissions.read", o)
440
+ }
441
+ )
442
+ }
443
+ )
444
+ }
445
+ ),
446
+ /* @__PURE__ */ e(
447
+ a,
448
+ {
449
+ align: "center",
450
+ children: /* @__PURE__ */ e(
451
+ L,
452
+ {
453
+ title: "Update data in any collection",
454
+ children: /* @__PURE__ */ e(
455
+ P,
456
+ {
457
+ disabled: u || !n,
458
+ checked: (u || U) ?? !1,
459
+ onCheckedChange: (o) => y("defaultPermissions.edit", o)
460
+ }
461
+ )
462
+ }
463
+ )
464
+ }
465
+ ),
466
+ /* @__PURE__ */ e(
467
+ a,
468
+ {
469
+ align: "center",
470
+ children: /* @__PURE__ */ e(
471
+ L,
472
+ {
473
+ title: "Delete data in any collection",
474
+ children: /* @__PURE__ */ e(
475
+ P,
476
+ {
477
+ disabled: u || !n,
478
+ checked: (u || k) ?? !1,
479
+ onCheckedChange: (o) => y("defaultPermissions.delete", o)
480
+ }
481
+ )
482
+ }
483
+ )
484
+ }
485
+ )
486
+ ] }),
487
+ r && r.map((o) => /* @__PURE__ */ s(M, { children: [
488
+ /* @__PURE__ */ e(
489
+ a,
490
+ {
491
+ scope: "row",
492
+ children: o.name
493
+ }
494
+ ),
495
+ /* @__PURE__ */ e(
496
+ a,
497
+ {
498
+ align: "center",
499
+ children: /* @__PURE__ */ e(
500
+ P,
501
+ {
502
+ disabled: u || h || !n,
503
+ checked: (u || h || j(l, `collectionPermissions.${o.path}.create`)) ?? !1,
504
+ onCheckedChange: (S) => y(`collectionPermissions.${o.path}.create`, S)
505
+ }
506
+ )
507
+ }
508
+ ),
509
+ /* @__PURE__ */ e(
510
+ a,
511
+ {
512
+ align: "center",
513
+ children: /* @__PURE__ */ e(
514
+ P,
515
+ {
516
+ disabled: u || x || !n,
517
+ checked: (u || x || j(l, `collectionPermissions.${o.path}.read`)) ?? !1,
518
+ onCheckedChange: (S) => y(`collectionPermissions.${o.path}.read`, S)
519
+ }
520
+ )
521
+ }
522
+ ),
523
+ /* @__PURE__ */ e(
524
+ a,
525
+ {
526
+ align: "center",
527
+ children: /* @__PURE__ */ e(
528
+ P,
529
+ {
530
+ disabled: u || U || !n,
531
+ checked: (u || U || j(l, `collectionPermissions.${o.path}.edit`)) ?? !1,
532
+ onCheckedChange: (S) => y(`collectionPermissions.${o.path}.edit`, S)
533
+ }
534
+ )
535
+ }
536
+ ),
537
+ /* @__PURE__ */ e(
538
+ a,
539
+ {
540
+ align: "center",
541
+ children: /* @__PURE__ */ e(
542
+ P,
543
+ {
544
+ disabled: u || k || !n,
545
+ checked: (u || k || j(l, `collectionPermissions.${o.path}.delete`)) ?? !1,
546
+ onCheckedChange: (S) => y(`collectionPermissions.${o.path}.delete`, S)
547
+ }
548
+ )
549
+ }
550
+ )
551
+ ] }, o.name))
552
+ ] })
553
+ ] })
554
+ }
555
+ ),
556
+ /* @__PURE__ */ e(B, { children: "You can customise the permissions that the users related to this role can perform in the entities of each collection" })
557
+ ] }),
558
+ /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
559
+ /* @__PURE__ */ s(
560
+ ne,
561
+ {
562
+ error: w.config && !!g.config,
563
+ id: "createCollections",
564
+ name: "createCollections",
565
+ label: "Create collections",
566
+ position: "item-aligned",
567
+ disabled: u || !n,
568
+ onChange: (o) => y("config.createCollections", o.target.value === "true"),
569
+ value: u || l.config?.createCollections ? "true" : "false",
570
+ renderValue: (o) => o === "true" ? "Yes" : "No",
571
+ children: [
572
+ /* @__PURE__ */ e(
573
+ T,
574
+ {
575
+ value: "true",
576
+ children: " Yes "
577
+ }
578
+ ),
579
+ /* @__PURE__ */ e(
580
+ T,
581
+ {
582
+ value: "false",
583
+ children: " No "
584
+ }
585
+ )
586
+ ]
587
+ }
588
+ ),
589
+ /* @__PURE__ */ e(B, { children: w.config && g.config ? g.config : "Can the user create collections" })
590
+ ] }),
591
+ /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
592
+ /* @__PURE__ */ s(
593
+ ne,
594
+ {
595
+ error: w.config && !!g.config,
596
+ id: "editCollections",
597
+ name: "editCollections",
598
+ label: "Edit collections",
599
+ disabled: u || !n,
600
+ position: "item-aligned",
601
+ onChange: (o) => y("config.editCollections", o.target.value === "own" ? "own" : o.target.value === "true"),
602
+ value: u ? "true" : l.config?.editCollections === "own" ? "own" : l.config?.editCollections ? "true" : "false",
603
+ renderValue: (o) => o === "own" ? "Own" : o === "true" ? "Yes" : "No",
604
+ children: [
605
+ /* @__PURE__ */ e(
606
+ T,
607
+ {
608
+ value: "true",
609
+ children: " Yes "
610
+ }
611
+ ),
612
+ /* @__PURE__ */ e(
613
+ T,
614
+ {
615
+ value: "false",
616
+ children: " No "
617
+ }
618
+ ),
619
+ /* @__PURE__ */ e(
620
+ T,
621
+ {
622
+ value: "own",
623
+ children: " Only his/her own "
624
+ }
625
+ )
626
+ ]
627
+ }
628
+ ),
629
+ /* @__PURE__ */ e(B, { children: w.config && g.config ? g.config : "Can the user edit collections" })
630
+ ] }),
631
+ /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
632
+ /* @__PURE__ */ s(
633
+ ne,
634
+ {
635
+ error: w.config && !!g.config,
636
+ id: "deleteCollections",
637
+ name: "deleteCollections",
638
+ label: "Delete collections",
639
+ disabled: u || !n,
640
+ position: "item-aligned",
641
+ onChange: (o) => y("config.deleteCollections", o.target.value === "own" ? "own" : o.target.value === "true"),
642
+ value: u ? "true" : l.config?.deleteCollections === "own" ? "own" : l.config?.deleteCollections ? "true" : "false",
643
+ renderValue: (o) => o === "own" ? "Own" : o === "true" ? "Yes" : "No",
644
+ children: [
645
+ /* @__PURE__ */ e(
646
+ T,
647
+ {
648
+ value: "true",
649
+ children: " Yes "
650
+ }
651
+ ),
652
+ /* @__PURE__ */ e(
653
+ T,
654
+ {
655
+ value: "false",
656
+ children: " No "
657
+ }
658
+ ),
659
+ /* @__PURE__ */ e(
660
+ T,
661
+ {
662
+ value: "own",
663
+ children: " Only his/her own "
664
+ }
665
+ )
666
+ ]
667
+ }
668
+ ),
669
+ /* @__PURE__ */ e(B, { children: w.config && g.config ? g.config : "Can the user delete collections" })
670
+ ] })
671
+ ] })
672
+ ] }),
673
+ /* @__PURE__ */ s(me, { position: "sticky", children: [
674
+ p && /* @__PURE__ */ e(_, { className: "text-red-500", children: "There was an error saving this role" }),
675
+ /* @__PURE__ */ e(
676
+ q,
677
+ {
678
+ variant: "text",
679
+ onClick: () => {
680
+ d();
681
+ },
682
+ children: "Cancel"
683
+ }
684
+ ),
685
+ /* @__PURE__ */ e(
686
+ he,
687
+ {
688
+ variant: "filled",
689
+ color: "primary",
690
+ type: "submit",
691
+ disabled: !O,
692
+ loading: I,
693
+ startIcon: /* @__PURE__ */ e(fe, {}),
694
+ children: f ? "Create role" : "Update"
695
+ }
696
+ )
697
+ ] })
698
+ ]
699
+ }
700
+ ) })
701
+ }
702
+ );
703
+ }
704
+ const Qe = [
705
+ {
706
+ id: "admin",
707
+ name: "Admin",
708
+ isAdmin: !0
709
+ },
710
+ {
711
+ id: "editor",
712
+ name: "Editor",
713
+ isAdmin: !1,
714
+ defaultPermissions: {
715
+ read: !0,
716
+ create: !0,
717
+ edit: !0,
718
+ delete: !0
719
+ },
720
+ config: {
721
+ createCollections: !0,
722
+ editCollections: "own",
723
+ deleteCollections: "own"
724
+ }
725
+ },
726
+ {
727
+ id: "viewer",
728
+ name: "Viewer",
729
+ isAdmin: !1,
730
+ defaultPermissions: {
731
+ read: !0,
732
+ create: !1,
733
+ edit: !1,
734
+ delete: !1
735
+ }
736
+ }
737
+ ];
738
+ function Xe({
739
+ onRoleClicked: t,
740
+ editable: i
741
+ }) {
742
+ const {
743
+ roles: n,
744
+ saveRole: d,
745
+ deleteRole: r,
746
+ allowDefaultRolesCreation: m
747
+ } = Y(), [f, p] = F(void 0), [N, v] = F(!1);
748
+ return /* @__PURE__ */ s(
749
+ "div",
750
+ {
751
+ className: "w-full overflow-auto",
752
+ children: [
753
+ /* @__PURE__ */ s(ie, { children: [
754
+ /* @__PURE__ */ s(re, { children: [
755
+ /* @__PURE__ */ e(a, { header: !0, className: "w-16" }),
756
+ /* @__PURE__ */ e(a, { header: !0, children: "Role" }),
757
+ /* @__PURE__ */ e(a, { header: !0, className: "items-center", children: "Is Admin" }),
758
+ /* @__PURE__ */ e(a, { header: !0, children: "Default permissions" })
759
+ ] }),
760
+ /* @__PURE__ */ s(oe, { children: [
761
+ n && n.map((c) => {
762
+ const I = c.isAdmin || c.defaultPermissions?.create, w = c.isAdmin || c.defaultPermissions?.read, l = c.isAdmin || c.defaultPermissions?.edit, g = c.isAdmin || c.defaultPermissions?.delete;
763
+ return /* @__PURE__ */ s(
764
+ M,
765
+ {
766
+ onClick: () => {
767
+ t(c);
768
+ },
769
+ children: [
770
+ /* @__PURE__ */ e(a, { style: { width: "64px" }, children: !c.isAdmin && /* @__PURE__ */ e(L, { title: "Delete this role", children: /* @__PURE__ */ e(
771
+ ge,
772
+ {
773
+ size: "small",
774
+ disabled: !i,
775
+ onClick: (R) => (R.stopPropagation(), p(c)),
776
+ children: /* @__PURE__ */ e(pe, {})
777
+ }
778
+ ) }) }),
779
+ /* @__PURE__ */ e(a, { children: /* @__PURE__ */ e(Q, { role: c }) }),
780
+ /* @__PURE__ */ e(a, { className: "items-center", children: /* @__PURE__ */ e(P, { checked: c.isAdmin ?? !1 }) }),
781
+ /* @__PURE__ */ e(a, { children: /* @__PURE__ */ s("ul", { children: [
782
+ I && /* @__PURE__ */ e("li", { children: "Create" }),
783
+ w && /* @__PURE__ */ e("li", { children: "Read" }),
784
+ l && /* @__PURE__ */ e("li", { children: "Update" }),
785
+ g && /* @__PURE__ */ e("li", { children: "Delete" })
786
+ ] }) })
787
+ ]
788
+ },
789
+ c.name
790
+ );
791
+ }),
792
+ (!n || n.length === 0) && /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e(a, { colspan: 4, children: /* @__PURE__ */ s(Ce, { className: "flex flex-col gap-4 my-8 items-center", children: [
793
+ /* @__PURE__ */ e(_, { variant: "label", children: "You don't have any roles yet." }),
794
+ m && /* @__PURE__ */ e(
795
+ q,
796
+ {
797
+ variant: "outlined",
798
+ onClick: () => {
799
+ Qe.forEach((c) => {
800
+ d(c);
801
+ });
802
+ },
803
+ children: "Create default roles"
804
+ }
805
+ )
806
+ ] }) }) })
807
+ ] })
808
+ ] }),
809
+ /* @__PURE__ */ e(
810
+ ye,
811
+ {
812
+ open: !!f,
813
+ loading: N,
814
+ onAccept: () => {
815
+ f && (v(!0), r(f).then(() => {
816
+ p(void 0);
817
+ }).finally(() => {
818
+ v(!1);
819
+ }));
820
+ },
821
+ onCancel: () => {
822
+ p(void 0);
823
+ },
824
+ title: /* @__PURE__ */ e(H, { children: "Delete?" }),
825
+ body: /* @__PURE__ */ e(H, { children: "Are you sure you want to delete this role?" })
826
+ }
827
+ )
828
+ ]
829
+ }
830
+ );
831
+ }
832
+ const Ze = A.memo(
833
+ function({ children: i }) {
834
+ const { collections: n } = Be(), [d, r] = F(!1), [m, f] = F(), { canEditRoles: p } = Y(), N = E((c) => {
835
+ r(!0), f(c);
836
+ }, []);
837
+ return /* @__PURE__ */ s(ve, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
838
+ i,
839
+ /* @__PURE__ */ s("div", { className: "flex items-center mt-12", children: [
840
+ /* @__PURE__ */ e(
841
+ _,
842
+ {
843
+ gutterBottom: !0,
844
+ variant: "h4",
845
+ className: "flex-grow",
846
+ component: "h4",
847
+ children: "Roles"
848
+ }
849
+ ),
850
+ /* @__PURE__ */ e(L, { title: p ? void 0 : "Update plans to customise roles", children: /* @__PURE__ */ e(
851
+ q,
852
+ {
853
+ size: "large",
854
+ disabled: !p,
855
+ startIcon: /* @__PURE__ */ e(we, {}),
856
+ onClick: () => r(!0),
857
+ children: "Add role"
858
+ }
859
+ ) })
860
+ ] }),
861
+ /* @__PURE__ */ e(Xe, { onRoleClicked: N, editable: !!p }),
862
+ /* @__PURE__ */ e(
863
+ Ke,
864
+ {
865
+ open: d,
866
+ role: m,
867
+ editable: p,
868
+ collections: n,
869
+ handleClose: () => {
870
+ f(void 0), r(!1);
871
+ }
872
+ },
873
+ m?.id ?? "new"
874
+ )
875
+ ] });
876
+ }
877
+ ), en = V.object().shape({
878
+ displayName: V.string().required("Required"),
879
+ email: V.string().email().required("Required"),
880
+ roles: V.array().min(1)
881
+ });
882
+ function nn(t, i, n, d, r) {
883
+ const m = n.filter((v) => v.roles.map((c) => c.id).includes("admin")), f = t.roles.map((v) => v.id).includes("admin");
884
+ if ((!r || !We(r.roles, i.roles)) && !f)
885
+ throw new Error("Only admins can change roles");
886
+ if (r && r.roles.map((v) => v.id).includes("admin") && !i.roles.map((v) => v.id).includes("admin") && m.length === 1)
887
+ throw new Error("There must be at least one admin");
888
+ return !0;
889
+ }
890
+ function tn({
891
+ open: t,
892
+ user: i,
893
+ handleClose: n
894
+ }) {
895
+ const d = be(), {
896
+ loggedInUser: r,
897
+ saveUser: m,
898
+ users: f,
899
+ roles: p
900
+ } = Y(), N = !i, v = E((h) => {
901
+ if (!r)
902
+ throw new Error("Logged user not found");
903
+ try {
904
+ return nn(r, h, f, p, i), m(h);
905
+ } catch (x) {
906
+ return Promise.reject(x);
907
+ }
908
+ }, [p, m, i, f, r]), c = Ne({
909
+ initialValues: i ?? {
910
+ displayName: "",
911
+ email: "",
912
+ roles: p.filter((h) => h.id === "editor")
913
+ },
914
+ validation: (h) => en.validate(h, { abortEarly: !1 }).then(() => ({})).catch((x) => x.inner.reduce((U, k) => (U[k.path] = k.message, U), {})),
915
+ onSubmit: (h, x) => v(h).then(() => {
916
+ n(), x.resetForm({
917
+ values: h
918
+ });
919
+ }).catch((U) => {
920
+ d.open({
921
+ type: "error",
922
+ message: U.message
923
+ });
924
+ })
925
+ }), {
926
+ isSubmitting: I,
927
+ touched: w,
928
+ handleChange: l,
929
+ values: g,
930
+ errors: R,
931
+ setFieldValue: y,
932
+ dirty: O,
933
+ handleSubmit: z,
934
+ submitCount: u
935
+ } = c;
936
+ return /* @__PURE__ */ e(
937
+ de,
938
+ {
939
+ open: t,
940
+ onOpenChange: (h) => h ? void 0 : n(),
941
+ maxWidth: "4xl",
942
+ children: /* @__PURE__ */ e(xe, { value: c, children: /* @__PURE__ */ s(
943
+ "form",
944
+ {
945
+ onSubmit: z,
946
+ autoComplete: "off",
947
+ noValidate: !0,
948
+ style: {
949
+ display: "flex",
950
+ flexDirection: "column",
951
+ position: "relative",
952
+ height: "100%"
953
+ },
954
+ children: [
955
+ /* @__PURE__ */ s(ue, { className: "h-full flex-grow", children: [
956
+ /* @__PURE__ */ e(
957
+ "div",
958
+ {
959
+ className: "flex flex-row pt-4 pb-4",
960
+ children: /* @__PURE__ */ e(
961
+ _,
962
+ {
963
+ variant: "h4",
964
+ className: "flex-grow",
965
+ children: "User"
966
+ }
967
+ )
968
+ }
969
+ ),
970
+ /* @__PURE__ */ s("div", { className: "grid grid-cols-12 gap-8", children: [
971
+ /* @__PURE__ */ s("div", { className: "col-span-12", children: [
972
+ /* @__PURE__ */ e(
973
+ K,
974
+ {
975
+ name: "displayName",
976
+ required: !0,
977
+ error: u > 0 && !!R.displayName,
978
+ value: g.displayName ?? "",
979
+ onChange: l,
980
+ "aria-describedby": "name-helper-text",
981
+ label: "Name"
982
+ }
983
+ ),
984
+ /* @__PURE__ */ e(B, { children: u > 0 && R.displayName ? R.displayName : "Name of this user" })
985
+ ] }),
986
+ /* @__PURE__ */ s("div", { className: "col-span-12", children: [
987
+ /* @__PURE__ */ e(
988
+ K,
989
+ {
990
+ required: !0,
991
+ error: u > 0 && !!R.email,
992
+ name: "email",
993
+ value: g.email ?? "",
994
+ onChange: l,
995
+ "aria-describedby": "email-helper-text",
996
+ label: "Email"
997
+ }
998
+ ),
999
+ /* @__PURE__ */ e(B, { children: u > 0 && R.email ? R.email : "Email of this user" })
1000
+ ] }),
1001
+ /* @__PURE__ */ e("div", { className: "col-span-12", children: /* @__PURE__ */ e(
1002
+ Ae,
1003
+ {
1004
+ label: "Roles",
1005
+ value: g.roles.map((h) => h.id) ?? [],
1006
+ onMultiValueChange: (h) => y("roles", h.map((x) => p.find((U) => U.id === x))),
1007
+ renderValue: (h) => {
1008
+ const x = p.find((U) => U.id === h);
1009
+ return x ? /* @__PURE__ */ e("div", { className: "flex flex-wrap space-x-2 space-y-2", children: /* @__PURE__ */ e(Q, { role: x }, x?.id) }) : null;
1010
+ },
1011
+ children: p.map((h) => /* @__PURE__ */ e(
1012
+ Fe,
1013
+ {
1014
+ value: h.id,
1015
+ children: /* @__PURE__ */ e(Q, { role: h }, h?.id)
1016
+ },
1017
+ h.id
1018
+ ))
1019
+ }
1020
+ ) })
1021
+ ] })
1022
+ ] }),
1023
+ /* @__PURE__ */ s(me, { children: [
1024
+ /* @__PURE__ */ e(
1025
+ q,
1026
+ {
1027
+ variant: "text",
1028
+ onClick: () => {
1029
+ n();
1030
+ },
1031
+ children: "Cancel"
1032
+ }
1033
+ ),
1034
+ /* @__PURE__ */ e(
1035
+ he,
1036
+ {
1037
+ variant: "filled",
1038
+ color: "primary",
1039
+ type: "submit",
1040
+ disabled: !O,
1041
+ loading: I,
1042
+ startIcon: /* @__PURE__ */ e(fe, {}),
1043
+ children: N ? "Create user" : "Update"
1044
+ }
1045
+ )
1046
+ ] })
1047
+ ]
1048
+ }
1049
+ ) })
1050
+ }
1051
+ );
1052
+ }
1053
+ function rn({ onUserClicked: t }) {
1054
+ const {
1055
+ users: i,
1056
+ saveUser: n,
1057
+ deleteUser: d
1058
+ } = Y(), r = Le(), m = be(), f = Ve(), p = f?.locale ? $e[f?.locale] : void 0, N = f?.dateTimeFormat ?? _e, [v, c] = F(void 0), [I, w] = F(!1);
1059
+ return /* @__PURE__ */ s("div", { className: "overflow-auto", children: [
1060
+ /* @__PURE__ */ s(ie, { children: [
1061
+ /* @__PURE__ */ s(re, { children: [
1062
+ /* @__PURE__ */ e(a, { className: "truncate w-16" }),
1063
+ /* @__PURE__ */ e(a, { children: "ID" }),
1064
+ /* @__PURE__ */ e(a, { children: "Email" }),
1065
+ /* @__PURE__ */ e(a, { children: "Name" }),
1066
+ /* @__PURE__ */ e(a, { children: "Roles" }),
1067
+ /* @__PURE__ */ e(a, { children: "Created on" })
1068
+ ] }),
1069
+ /* @__PURE__ */ s(oe, { children: [
1070
+ i && i.map((l) => {
1071
+ const g = l.roles, R = l.created_on ? Oe(l.created_on, N, { locale: p }) : "";
1072
+ return /* @__PURE__ */ s(
1073
+ M,
1074
+ {
1075
+ onClick: () => {
1076
+ t(l);
1077
+ },
1078
+ children: [
1079
+ /* @__PURE__ */ e(a, { className: "w-10", children: /* @__PURE__ */ e(L, { title: "Delete this user", children: /* @__PURE__ */ e(
1080
+ ge,
1081
+ {
1082
+ size: "small",
1083
+ onClick: (y) => (y.stopPropagation(), c(l)),
1084
+ children: /* @__PURE__ */ e(pe, {})
1085
+ }
1086
+ ) }) }),
1087
+ /* @__PURE__ */ e(a, { children: l.uid }),
1088
+ /* @__PURE__ */ e(a, { children: l.email }),
1089
+ /* @__PURE__ */ e(a, { className: "font-medium align-left", children: l.displayName }),
1090
+ /* @__PURE__ */ e(a, { className: "align-left", children: g ? /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-2", children: g.map(
1091
+ (y) => /* @__PURE__ */ e(Q, { role: y }, y?.id)
1092
+ ) }) : null }),
1093
+ /* @__PURE__ */ e(a, { children: R })
1094
+ ]
1095
+ },
1096
+ "row_" + l.uid
1097
+ );
1098
+ }),
1099
+ (!i || i.length === 0) && /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e(a, { colspan: 6, children: /* @__PURE__ */ s(Ce, { className: "flex flex-col gap-4 my-8 items-center", children: [
1100
+ /* @__PURE__ */ e(_, { variant: "label", children: "There are no users yet" }),
1101
+ /* @__PURE__ */ e(
1102
+ q,
1103
+ {
1104
+ variant: "outlined",
1105
+ onClick: () => {
1106
+ if (!r.user?.uid)
1107
+ throw Error("UsersTable, authController misconfiguration");
1108
+ n({
1109
+ uid: r.user?.uid,
1110
+ email: r.user?.email,
1111
+ displayName: r.user?.displayName,
1112
+ photoURL: r.user?.photoURL,
1113
+ providerId: r.user?.providerId,
1114
+ isAnonymous: r.user?.isAnonymous,
1115
+ roles: [{ id: "admin", name: "Admin" }],
1116
+ created_on: /* @__PURE__ */ new Date()
1117
+ }).then(() => {
1118
+ m.open({
1119
+ type: "success",
1120
+ message: "User added successfully"
1121
+ });
1122
+ }).catch((l) => {
1123
+ m.open({
1124
+ type: "error",
1125
+ message: "Error adding user: " + l.message
1126
+ });
1127
+ });
1128
+ },
1129
+ children: "Add the logged user as an admin"
1130
+ }
1131
+ )
1132
+ ] }) }) })
1133
+ ] })
1134
+ ] }),
1135
+ /* @__PURE__ */ e(
1136
+ ye,
1137
+ {
1138
+ open: !!v,
1139
+ loading: I,
1140
+ onAccept: () => {
1141
+ v && (w(!0), d(v).then(() => {
1142
+ c(void 0);
1143
+ }).catch((l) => {
1144
+ m.open({
1145
+ type: "error",
1146
+ message: "Error deleting user: " + l.message
1147
+ });
1148
+ }).finally(() => {
1149
+ w(!1);
1150
+ }));
1151
+ },
1152
+ onCancel: () => {
1153
+ c(void 0);
1154
+ },
1155
+ title: /* @__PURE__ */ e(H, { children: "Delete?" }),
1156
+ body: /* @__PURE__ */ e(H, { children: "Are you sure you want to delete this user?" })
1157
+ }
1158
+ )
1159
+ ] });
1160
+ }
1161
+ const on = function({ children: i }) {
1162
+ const [n, d] = F(), [r, m] = F(), { users: f, usersLimit: p } = Y(), N = p !== void 0 && f && f.length >= p, v = E((I) => {
1163
+ m(I), d(!0);
1164
+ }, []), c = E(() => {
1165
+ d(!1), m(void 0);
1166
+ }, []);
1167
+ return /* @__PURE__ */ s(ve, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
1168
+ i,
1169
+ /* @__PURE__ */ s(
1170
+ "div",
1171
+ {
1172
+ className: "flex items-center mt-12",
1173
+ children: [
1174
+ /* @__PURE__ */ e(
1175
+ _,
1176
+ {
1177
+ gutterBottom: !0,
1178
+ variant: "h4",
1179
+ className: "flex-grow",
1180
+ component: "h4",
1181
+ children: "Users"
1182
+ }
1183
+ ),
1184
+ /* @__PURE__ */ e(
1185
+ q,
1186
+ {
1187
+ size: "large",
1188
+ disabled: N,
1189
+ startIcon: /* @__PURE__ */ e(we, {}),
1190
+ onClick: () => d(!0),
1191
+ children: "Add user"
1192
+ }
1193
+ )
1194
+ ]
1195
+ }
1196
+ ),
1197
+ /* @__PURE__ */ e(rn, { onUserClicked: v }),
1198
+ /* @__PURE__ */ e(
1199
+ tn,
1200
+ {
1201
+ open: n ?? !1,
1202
+ user: r,
1203
+ handleClose: c
1204
+ },
1205
+ r?.uid ?? "new"
1206
+ )
1207
+ ] });
1208
+ };
1209
+ function bn({ userManagement: t }) {
1210
+ return {
1211
+ name: "User management plugin",
1212
+ loading: t.loading,
1213
+ provider: {
1214
+ Component: Ge,
1215
+ props: {
1216
+ userManagement: t
1217
+ }
1218
+ }
1219
+ };
1220
+ }
1221
+ const Nn = [
1222
+ {
1223
+ path: "users",
1224
+ name: "CMS Users",
1225
+ group: "Admin",
1226
+ icon: "face",
1227
+ view: /* @__PURE__ */ e(on, {})
1228
+ },
1229
+ {
1230
+ path: "roles",
1231
+ name: "Roles",
1232
+ group: "Admin",
1233
+ icon: "gpp_good",
1234
+ view: /* @__PURE__ */ e(Ze, {})
1235
+ }
1236
+ ];
1237
+ export {
1238
+ hn as RESERVED_GROUPS,
1239
+ Q as RoleChip,
1240
+ He as RoleYupSchema,
1241
+ Ke as RolesDetailsForm,
1242
+ Xe as RolesTable,
1243
+ Ze as RolesView,
1244
+ tn as UserDetailsForm,
1245
+ Re as UserManagementContext,
1246
+ Ge as UserManagementProvider,
1247
+ en as UserYupSchema,
1248
+ rn as UsersTable,
1249
+ on as UsersView,
1250
+ We as areRolesEqual,
1251
+ gn as cacheDelegatedLoginToken,
1252
+ Cn as clearDelegatedLoginTokensCache,
1253
+ vn as darkenColor,
1254
+ pn as getDelegatedLoginTokenFromCache,
1255
+ fn as getUserRoles,
1256
+ wn as hexToRgbaWithOpacity,
1257
+ qe as resolveUserRolePermissions,
1258
+ yn as useBuildFirestoreUserManagement,
1259
+ Y as useUserManagement,
1260
+ bn as useUserManagementPlugin,
1261
+ Nn as userManagementAdminViews
1262
+ };
1263
+ //# sourceMappingURL=index.es.js.map