@firecms/user_management 3.0.0-canary.38 → 3.0.0-canary.40

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