@nice2dev/auth 1.0.21 → 1.0.22

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.mjs CHANGED
@@ -1,178 +1,178 @@
1
- import { useState as _, useCallback as x, forwardRef as E, useMemo as V } from "react";
2
- import { jsxs as n, jsx as e, Fragment as q } from "react/jsx-runtime";
3
- function X(a = {}) {
4
- const { onLogin: t, onRefresh: o, onLogout: d, storageKey: u = "nice_auth", persistAuth: f = !1 } = a, [r, m] = _(() => {
5
- if (f && typeof window < "u")
1
+ import { useState as _, useCallback as w, forwardRef as O, useMemo as X, useRef as U, useImperativeHandle as ae, useEffect as W } from "react";
2
+ import { jsxs as a, jsx as e, Fragment as ce } from "react/jsx-runtime";
3
+ function ve(i = {}) {
4
+ const { onLogin: t, onRefresh: c, onLogout: n, storageKey: r = "nice_auth", persistAuth: l = !1 } = i, [o, p] = _(() => {
5
+ if (l && typeof window < "u")
6
6
  try {
7
- const s = localStorage.getItem(u);
8
- if (s)
9
- return { ...JSON.parse(s), loading: !1, error: null };
7
+ const h = localStorage.getItem(r);
8
+ if (h)
9
+ return { ...JSON.parse(h), loading: !1, error: null };
10
10
  } catch {
11
11
  }
12
12
  return { isAuthenticated: !1, user: null, tokens: null, loading: !1, error: null };
13
- }), c = x(
14
- (s) => {
15
- m((h) => {
16
- const p = { ...h, ...s };
17
- return f && typeof window < "u" && (p.isAuthenticated ? localStorage.setItem(
18
- u,
19
- JSON.stringify({ isAuthenticated: !0, user: p.user })
20
- ) : localStorage.removeItem(u)), p;
13
+ }), d = w(
14
+ (h) => {
15
+ p((m) => {
16
+ const f = { ...m, ...h };
17
+ return l && typeof window < "u" && (f.isAuthenticated ? localStorage.setItem(
18
+ r,
19
+ JSON.stringify({ isAuthenticated: !0, user: f.user })
20
+ ) : localStorage.removeItem(r)), f;
21
21
  });
22
22
  },
23
- [f, u]
24
- ), v = x(
25
- async (s, h) => {
26
- c({ loading: !0, error: null });
23
+ [l, r]
24
+ ), $ = w(
25
+ async (h, m) => {
26
+ d({ loading: !0, error: null });
27
27
  try {
28
28
  if (t) {
29
- const p = await t(s, h);
30
- return c({
29
+ const f = await t(h, m);
30
+ return d({
31
31
  isAuthenticated: !0,
32
- user: p.user,
33
- tokens: p.tokens,
32
+ user: f.user,
33
+ tokens: f.tokens,
34
34
  loading: !1
35
35
  }), !0;
36
36
  }
37
- return c({ loading: !1, error: "No login handler configured" }), !1;
38
- } catch (p) {
39
- return c({
37
+ return d({ loading: !1, error: "No login handler configured" }), !1;
38
+ } catch (f) {
39
+ return d({
40
40
  loading: !1,
41
- error: (p == null ? void 0 : p.message) ?? "Login failed"
41
+ error: (f == null ? void 0 : f.message) ?? "Login failed"
42
42
  }), !1;
43
43
  }
44
44
  },
45
- [t, c]
46
- ), i = x(() => {
47
- d == null || d(), c({ isAuthenticated: !1, user: null, tokens: null, loading: !1, error: null });
48
- }, [d, c]), k = x(async () => {
49
- var s;
50
- if (!((s = r.tokens) != null && s.refreshToken) || !o)
45
+ [t, d]
46
+ ), s = w(() => {
47
+ n == null || n(), d({ isAuthenticated: !1, user: null, tokens: null, loading: !1, error: null });
48
+ }, [n, d]), C = w(async () => {
49
+ var h;
50
+ if (!((h = o.tokens) != null && h.refreshToken) || !c)
51
51
  return !1;
52
52
  try {
53
- const h = await o(r.tokens.refreshToken);
54
- return c({ tokens: h }), !0;
53
+ const m = await c(o.tokens.refreshToken);
54
+ return d({ tokens: m }), !0;
55
55
  } catch {
56
- return i(), !1;
56
+ return s(), !1;
57
57
  }
58
- }, [r.tokens, o, c, i]), b = x(
59
- (s, h) => {
60
- c({ isAuthenticated: !0, user: s, tokens: h, loading: !1, error: null });
58
+ }, [o.tokens, c, d, s]), b = w(
59
+ (h, m) => {
60
+ d({ isAuthenticated: !0, user: h, tokens: m, loading: !1, error: null });
61
61
  },
62
- [c]
63
- ), C = x(
64
- (...s) => r.user ? s.every((h) => r.user.roles.includes(h)) : !1,
65
- [r.user]
66
- ), w = x(
67
- (...s) => r.user ? s.every((h) => r.user.permissions.includes(h)) : !1,
68
- [r.user]
69
- ), A = x(() => {
70
- c({ error: null });
71
- }, [c]);
62
+ [d]
63
+ ), x = w(
64
+ (...h) => o.user ? h.every((m) => o.user.roles.includes(m)) : !1,
65
+ [o.user]
66
+ ), g = w(
67
+ (...h) => o.user ? h.every((m) => o.user.permissions.includes(m)) : !1,
68
+ [o.user]
69
+ ), F = w(() => {
70
+ d({ error: null });
71
+ }, [d]);
72
72
  return {
73
- ...r,
74
- login: v,
75
- logout: i,
76
- refreshToken: k,
73
+ ...o,
74
+ login: $,
75
+ logout: s,
76
+ refreshToken: C,
77
77
  setAuth: b,
78
- hasRoles: C,
79
- hasPermissions: w,
80
- clearError: A
78
+ hasRoles: x,
79
+ hasPermissions: g,
80
+ clearError: F
81
81
  };
82
82
  }
83
- const j = E(
83
+ const ie = O(
84
84
  ({
85
- onSubmit: a,
85
+ onSubmit: i,
86
86
  loading: t = !1,
87
- error: o,
88
- showRememberMe: d = !0,
89
- showForgotPassword: u = !0,
90
- onForgotPassword: f,
91
- showRegisterLink: r = !0,
92
- onRegisterClick: m,
93
- title: c = "Sign In",
94
- submitLabel: v = "Sign In",
95
- logo: i,
96
- footer: k,
87
+ error: c,
88
+ showRememberMe: n = !0,
89
+ showForgotPassword: r = !0,
90
+ onForgotPassword: l,
91
+ showRegisterLink: o = !0,
92
+ onRegisterClick: p,
93
+ title: d = "Sign In",
94
+ submitLabel: $ = "Sign In",
95
+ logo: s,
96
+ footer: C,
97
97
  className: b,
98
- style: C,
99
- emailLabel: w = "Email",
100
- passwordLabel: A = "Password",
101
- tracelessPolicy: s,
102
- privacyMessage: h
103
- }, p) => {
104
- const [$, g] = _(""), [S, y] = _(""), [T, R] = _(!1), L = V(() => !(!d || s && !s.cookiesAllowed), [d, s]), P = x(
105
- (F) => {
106
- F.preventDefault();
107
- const D = (s == null ? void 0 : s.cookiesAllowed) === !1 ? !1 : T;
108
- a == null || a({ email: $, password: S, rememberMe: D });
98
+ style: x,
99
+ emailLabel: g = "Email",
100
+ passwordLabel: F = "Password",
101
+ tracelessPolicy: h,
102
+ privacyMessage: m
103
+ }, f) => {
104
+ const [T, N] = _(""), [P, S] = _(""), [E, k] = _(!1), M = X(() => !(!n || h && !h.cookiesAllowed), [n, h]), q = w(
105
+ (A) => {
106
+ A.preventDefault();
107
+ const D = (h == null ? void 0 : h.cookiesAllowed) === !1 ? !1 : E;
108
+ i == null || i({ email: T, password: P, rememberMe: D });
109
109
  },
110
- [$, S, T, a, s]
110
+ [T, P, E, i, h]
111
111
  );
112
- return /* @__PURE__ */ n(
112
+ return /* @__PURE__ */ a(
113
113
  "form",
114
114
  {
115
- ref: p,
115
+ ref: f,
116
116
  className: `nice-login-form${b ? ` ${b}` : ""}`,
117
- style: C,
118
- onSubmit: P,
117
+ style: x,
118
+ onSubmit: q,
119
119
  noValidate: !0,
120
120
  children: [
121
- i && /* @__PURE__ */ e("div", { className: "nice-login-form__logo", children: i }),
122
- /* @__PURE__ */ e("h2", { className: "nice-login-form__title", children: c }),
123
- o && /* @__PURE__ */ e("div", { className: "nice-login-form__error", role: "alert", children: o }),
124
- /* @__PURE__ */ n("div", { className: "nice-login-form__field", children: [
125
- /* @__PURE__ */ e("label", { htmlFor: "nice-login-email", children: w }),
121
+ s && /* @__PURE__ */ e("div", { className: "nice-login-form__logo", children: s }),
122
+ /* @__PURE__ */ e("h2", { className: "nice-login-form__title", children: d }),
123
+ c && /* @__PURE__ */ e("div", { className: "nice-login-form__error", role: "alert", children: c }),
124
+ /* @__PURE__ */ a("div", { className: "nice-login-form__field", children: [
125
+ /* @__PURE__ */ e("label", { htmlFor: "nice-login-email", children: g }),
126
126
  /* @__PURE__ */ e(
127
127
  "input",
128
128
  {
129
129
  id: "nice-login-email",
130
130
  className: "nice-input",
131
131
  type: "email",
132
- value: $,
133
- onChange: (F) => g(F.target.value),
132
+ value: T,
133
+ onChange: (A) => N(A.target.value),
134
134
  autoComplete: "email",
135
135
  required: !0,
136
136
  disabled: t
137
137
  }
138
138
  )
139
139
  ] }),
140
- /* @__PURE__ */ n("div", { className: "nice-login-form__field", children: [
141
- /* @__PURE__ */ e("label", { htmlFor: "nice-login-password", children: A }),
140
+ /* @__PURE__ */ a("div", { className: "nice-login-form__field", children: [
141
+ /* @__PURE__ */ e("label", { htmlFor: "nice-login-password", children: F }),
142
142
  /* @__PURE__ */ e(
143
143
  "input",
144
144
  {
145
145
  id: "nice-login-password",
146
146
  className: "nice-input",
147
147
  type: "password",
148
- value: S,
149
- onChange: (F) => y(F.target.value),
148
+ value: P,
149
+ onChange: (A) => S(A.target.value),
150
150
  autoComplete: "current-password",
151
151
  required: !0,
152
152
  disabled: t
153
153
  }
154
154
  )
155
155
  ] }),
156
- /* @__PURE__ */ n("div", { className: "nice-login-form__options", children: [
157
- L && /* @__PURE__ */ n("label", { className: "nice-login-form__remember", children: [
156
+ /* @__PURE__ */ a("div", { className: "nice-login-form__options", children: [
157
+ M && /* @__PURE__ */ a("label", { className: "nice-login-form__remember", children: [
158
158
  /* @__PURE__ */ e(
159
159
  "input",
160
160
  {
161
161
  type: "checkbox",
162
- checked: T,
163
- onChange: (F) => R(F.target.checked),
162
+ checked: E,
163
+ onChange: (A) => k(A.target.checked),
164
164
  disabled: t
165
165
  }
166
166
  ),
167
167
  /* @__PURE__ */ e("span", { children: "Remember me" })
168
168
  ] }),
169
- !L && d && h && /* @__PURE__ */ e("span", { className: "nice-login-form__privacy-notice", children: h }),
170
- u && /* @__PURE__ */ e(
169
+ !M && n && m && /* @__PURE__ */ e("span", { className: "nice-login-form__privacy-notice", children: m }),
170
+ r && /* @__PURE__ */ e(
171
171
  "button",
172
172
  {
173
173
  type: "button",
174
174
  className: "nice-login-form__forgot",
175
- onClick: f,
175
+ onClick: l,
176
176
  disabled: t,
177
177
  children: "Forgot password?"
178
178
  }
@@ -183,92 +183,92 @@ const j = E(
183
183
  {
184
184
  type: "submit",
185
185
  className: "nice-btn nice-btn--primary nice-login-form__submit",
186
- disabled: t || !$ || !S,
187
- children: t ? "…" : v
186
+ disabled: t || !T || !P,
187
+ children: t ? "…" : $
188
188
  }
189
189
  ),
190
- r && /* @__PURE__ */ n("div", { className: "nice-login-form__register", children: [
190
+ o && /* @__PURE__ */ a("div", { className: "nice-login-form__register", children: [
191
191
  /* @__PURE__ */ e("span", { children: "Don't have an account? " }),
192
- /* @__PURE__ */ e("button", { type: "button", onClick: m, disabled: t, children: "Register" })
192
+ /* @__PURE__ */ e("button", { type: "button", onClick: p, disabled: t, children: "Register" })
193
193
  ] }),
194
- k && /* @__PURE__ */ e("div", { className: "nice-login-form__footer", children: k })
194
+ C && /* @__PURE__ */ e("div", { className: "nice-login-form__footer", children: C })
195
195
  ]
196
196
  }
197
197
  );
198
198
  }
199
199
  );
200
- j.displayName = "NiceLoginForm";
201
- const B = {
200
+ ie.displayName = "NiceLoginForm";
201
+ const re = {
202
202
  0: "Very weak",
203
203
  1: "Weak",
204
204
  2: "Fair",
205
205
  3: "Strong",
206
206
  4: "Very strong"
207
- }, G = {
207
+ }, se = {
208
208
  0: "#d9534f",
209
209
  1: "#f0ad4e",
210
210
  2: "#5bc0de",
211
211
  3: "#5cb85c",
212
212
  4: "#2e7d32"
213
213
  };
214
- function I(a) {
215
- if (!a)
214
+ function J(i) {
215
+ if (!i)
216
216
  return 0;
217
217
  let t = 0;
218
- return a.length >= 8 && t++, a.length >= 12 && t++, /[a-z]/.test(a) && /[A-Z]/.test(a) && t++, /\d/.test(a) && t++, /[^a-zA-Z0-9]/.test(a) && t++, Math.min(4, t);
218
+ return i.length >= 8 && t++, i.length >= 12 && t++, /[a-z]/.test(i) && /[A-Z]/.test(i) && t++, /\d/.test(i) && t++, /[^a-zA-Z0-9]/.test(i) && t++, Math.min(4, t);
219
219
  }
220
- const M = E(
221
- ({ password: a, strength: t, showLabel: o = !0, labels: d = B, className: u }, f) => {
222
- const r = t ?? I(a), m = G[r], c = (r + 1) / 5 * 100;
223
- return /* @__PURE__ */ n("div", { ref: f, className: `nice-password-strength${u ? ` ${u}` : ""}`, children: [
220
+ const Z = O(
221
+ ({ password: i, strength: t, showLabel: c = !0, labels: n = re, className: r }, l) => {
222
+ const o = t ?? J(i), p = se[o], d = (o + 1) / 5 * 100;
223
+ return /* @__PURE__ */ a("div", { ref: l, className: `nice-password-strength${r ? ` ${r}` : ""}`, children: [
224
224
  /* @__PURE__ */ e("div", { className: "nice-password-strength__bar", children: /* @__PURE__ */ e(
225
225
  "div",
226
226
  {
227
227
  className: "nice-password-strength__fill",
228
- style: { width: `${c}%`, backgroundColor: m }
228
+ style: { width: `${d}%`, backgroundColor: p }
229
229
  }
230
230
  ) }),
231
- o && /* @__PURE__ */ e("span", { className: "nice-password-strength__label", style: { color: m }, children: d[r] })
231
+ c && /* @__PURE__ */ e("span", { className: "nice-password-strength__label", style: { color: p }, children: n[o] })
232
232
  ] });
233
233
  }
234
234
  );
235
- M.displayName = "NicePasswordStrength";
236
- const Q = E(
235
+ Z.displayName = "NicePasswordStrength";
236
+ const le = O(
237
237
  ({
238
- onSubmit: a,
238
+ onSubmit: i,
239
239
  loading: t = !1,
240
- error: o,
241
- onLoginClick: d,
242
- showPasswordStrength: u = !0,
243
- minPasswordStrength: f = 2,
244
- termsUrl: r,
245
- privacyUrl: m,
246
- title: c = "Create Account",
247
- logo: v,
248
- footer: i,
249
- className: k,
240
+ error: c,
241
+ onLoginClick: n,
242
+ showPasswordStrength: r = !0,
243
+ minPasswordStrength: l = 2,
244
+ termsUrl: o,
245
+ privacyUrl: p,
246
+ title: d = "Create Account",
247
+ logo: $,
248
+ footer: s,
249
+ className: C,
250
250
  style: b
251
- }, C) => {
252
- const [w, A] = _(""), [s, h] = _(""), [p, $] = _(""), [g, S] = _(""), [y, T] = _(""), [R, L] = _(!1), P = I(g), F = g === y, D = w && p && g && F && R && P >= f && !t, l = x(
253
- (N) => {
254
- N.preventDefault(), D && (a == null || a({ firstName: w, lastName: s, email: p, password: g, acceptTerms: R }));
251
+ }, x) => {
252
+ const [g, F] = _(""), [h, m] = _(""), [f, T] = _(""), [N, P] = _(""), [S, E] = _(""), [k, M] = _(!1), q = J(N), A = N === S, D = g && f && N && A && k && q >= l && !t, u = w(
253
+ (v) => {
254
+ v.preventDefault(), D && (i == null || i({ firstName: g, lastName: h, email: f, password: N, acceptTerms: k }));
255
255
  },
256
- [D, w, s, p, g, R, a]
256
+ [D, g, h, f, N, k, i]
257
257
  );
258
- return /* @__PURE__ */ n(
258
+ return /* @__PURE__ */ a(
259
259
  "form",
260
260
  {
261
- ref: C,
262
- className: `nice-register-form${k ? ` ${k}` : ""}`,
261
+ ref: x,
262
+ className: `nice-register-form${C ? ` ${C}` : ""}`,
263
263
  style: b,
264
- onSubmit: l,
264
+ onSubmit: u,
265
265
  noValidate: !0,
266
266
  children: [
267
- v && /* @__PURE__ */ e("div", { className: "nice-register-form__logo", children: v }),
268
- /* @__PURE__ */ e("h2", { className: "nice-register-form__title", children: c }),
269
- o && /* @__PURE__ */ e("div", { className: "nice-register-form__error", role: "alert", children: o }),
270
- /* @__PURE__ */ n("div", { className: "nice-register-form__row", children: [
271
- /* @__PURE__ */ n("div", { className: "nice-register-form__field", children: [
267
+ $ && /* @__PURE__ */ e("div", { className: "nice-register-form__logo", children: $ }),
268
+ /* @__PURE__ */ e("h2", { className: "nice-register-form__title", children: d }),
269
+ c && /* @__PURE__ */ e("div", { className: "nice-register-form__error", role: "alert", children: c }),
270
+ /* @__PURE__ */ a("div", { className: "nice-register-form__row", children: [
271
+ /* @__PURE__ */ a("div", { className: "nice-register-form__field", children: [
272
272
  /* @__PURE__ */ e("label", { htmlFor: "nice-reg-first", children: "First name *" }),
273
273
  /* @__PURE__ */ e(
274
274
  "input",
@@ -276,15 +276,15 @@ const Q = E(
276
276
  id: "nice-reg-first",
277
277
  className: "nice-input",
278
278
  type: "text",
279
- value: w,
280
- onChange: (N) => A(N.target.value),
279
+ value: g,
280
+ onChange: (v) => F(v.target.value),
281
281
  required: !0,
282
282
  disabled: t,
283
283
  autoComplete: "given-name"
284
284
  }
285
285
  )
286
286
  ] }),
287
- /* @__PURE__ */ n("div", { className: "nice-register-form__field", children: [
287
+ /* @__PURE__ */ a("div", { className: "nice-register-form__field", children: [
288
288
  /* @__PURE__ */ e("label", { htmlFor: "nice-reg-last", children: "Last name" }),
289
289
  /* @__PURE__ */ e(
290
290
  "input",
@@ -292,15 +292,15 @@ const Q = E(
292
292
  id: "nice-reg-last",
293
293
  className: "nice-input",
294
294
  type: "text",
295
- value: s,
296
- onChange: (N) => h(N.target.value),
295
+ value: h,
296
+ onChange: (v) => m(v.target.value),
297
297
  disabled: t,
298
298
  autoComplete: "family-name"
299
299
  }
300
300
  )
301
301
  ] })
302
302
  ] }),
303
- /* @__PURE__ */ n("div", { className: "nice-register-form__field", children: [
303
+ /* @__PURE__ */ a("div", { className: "nice-register-form__field", children: [
304
304
  /* @__PURE__ */ e("label", { htmlFor: "nice-reg-email", children: "Email *" }),
305
305
  /* @__PURE__ */ e(
306
306
  "input",
@@ -308,15 +308,15 @@ const Q = E(
308
308
  id: "nice-reg-email",
309
309
  className: "nice-input",
310
310
  type: "email",
311
- value: p,
312
- onChange: (N) => $(N.target.value),
311
+ value: f,
312
+ onChange: (v) => T(v.target.value),
313
313
  required: !0,
314
314
  disabled: t,
315
315
  autoComplete: "email"
316
316
  }
317
317
  )
318
318
  ] }),
319
- /* @__PURE__ */ n("div", { className: "nice-register-form__field", children: [
319
+ /* @__PURE__ */ a("div", { className: "nice-register-form__field", children: [
320
320
  /* @__PURE__ */ e("label", { htmlFor: "nice-reg-pass", children: "Password *" }),
321
321
  /* @__PURE__ */ e(
322
322
  "input",
@@ -324,16 +324,16 @@ const Q = E(
324
324
  id: "nice-reg-pass",
325
325
  className: "nice-input",
326
326
  type: "password",
327
- value: g,
328
- onChange: (N) => S(N.target.value),
327
+ value: N,
328
+ onChange: (v) => P(v.target.value),
329
329
  required: !0,
330
330
  disabled: t,
331
331
  autoComplete: "new-password"
332
332
  }
333
333
  ),
334
- u && g.length > 0 && /* @__PURE__ */ e(M, { password: g })
334
+ r && N.length > 0 && /* @__PURE__ */ e(Z, { password: N })
335
335
  ] }),
336
- /* @__PURE__ */ n("div", { className: "nice-register-form__field", children: [
336
+ /* @__PURE__ */ a("div", { className: "nice-register-form__field", children: [
337
337
  /* @__PURE__ */ e("label", { htmlFor: "nice-reg-confirm", children: "Confirm password *" }),
338
338
  /* @__PURE__ */ e(
339
339
  "input",
@@ -341,34 +341,34 @@ const Q = E(
341
341
  id: "nice-reg-confirm",
342
342
  className: "nice-input",
343
343
  type: "password",
344
- value: y,
345
- onChange: (N) => T(N.target.value),
344
+ value: S,
345
+ onChange: (v) => E(v.target.value),
346
346
  required: !0,
347
347
  disabled: t,
348
348
  autoComplete: "new-password"
349
349
  }
350
350
  ),
351
- y && !F && /* @__PURE__ */ e("span", { className: "nice-error-text", children: "Passwords do not match" })
351
+ S && !A && /* @__PURE__ */ e("span", { className: "nice-error-text", children: "Passwords do not match" })
352
352
  ] }),
353
- /* @__PURE__ */ n("label", { className: "nice-register-form__terms", children: [
353
+ /* @__PURE__ */ a("label", { className: "nice-register-form__terms", children: [
354
354
  /* @__PURE__ */ e(
355
355
  "input",
356
356
  {
357
357
  type: "checkbox",
358
- checked: R,
359
- onChange: (N) => L(N.target.checked),
358
+ checked: k,
359
+ onChange: (v) => M(v.target.checked),
360
360
  disabled: t
361
361
  }
362
362
  ),
363
- /* @__PURE__ */ n("span", { children: [
363
+ /* @__PURE__ */ a("span", { children: [
364
364
  "I accept the",
365
365
  " ",
366
- r ? /* @__PURE__ */ e("a", { href: r, target: "_blank", rel: "noopener noreferrer", children: "Terms" }) : "Terms",
367
- m && /* @__PURE__ */ n(q, { children: [
366
+ o ? /* @__PURE__ */ e("a", { href: o, target: "_blank", rel: "noopener noreferrer", children: "Terms" }) : "Terms",
367
+ p && /* @__PURE__ */ a(ce, { children: [
368
368
  " ",
369
369
  "and",
370
370
  " ",
371
- /* @__PURE__ */ e("a", { href: m, target: "_blank", rel: "noopener noreferrer", children: "Privacy Policy" })
371
+ /* @__PURE__ */ e("a", { href: p, target: "_blank", rel: "noopener noreferrer", children: "Privacy Policy" })
372
372
  ] }),
373
373
  " *"
374
374
  ] })
@@ -382,51 +382,51 @@ const Q = E(
382
382
  children: t ? "…" : "Register"
383
383
  }
384
384
  ),
385
- d && /* @__PURE__ */ n("div", { className: "nice-register-form__login", children: [
385
+ n && /* @__PURE__ */ a("div", { className: "nice-register-form__login", children: [
386
386
  /* @__PURE__ */ e("span", { children: "Already have an account? " }),
387
- /* @__PURE__ */ e("button", { type: "button", onClick: d, children: "Sign in" })
387
+ /* @__PURE__ */ e("button", { type: "button", onClick: n, children: "Sign in" })
388
388
  ] }),
389
- i && /* @__PURE__ */ e("div", { className: "nice-register-form__footer", children: i })
389
+ s && /* @__PURE__ */ e("div", { className: "nice-register-form__footer", children: s })
390
390
  ]
391
391
  }
392
392
  );
393
393
  }
394
394
  );
395
- Q.displayName = "NiceRegistrationForm";
396
- const z = E(
395
+ le.displayName = "NiceRegistrationForm";
396
+ const oe = O(
397
397
  ({
398
- requireCurrentPassword: a = !0,
398
+ requireCurrentPassword: i = !0,
399
399
  onSubmit: t,
400
- loading: o = !1,
401
- error: d,
402
- success: u,
403
- minPasswordStrength: f = 2,
404
- title: r = "Change Password",
405
- className: m,
406
- style: c
407
- }, v) => {
408
- const [i, k] = _(""), [b, C] = _(""), [w, A] = _(""), s = I(b), h = b === w, p = (!a || i.length > 0) && b.length > 0 && h && s >= f && !o, $ = x(
409
- (g) => {
410
- g.preventDefault(), p && (t == null || t({
411
- currentPassword: a ? i : void 0,
400
+ loading: c = !1,
401
+ error: n,
402
+ success: r,
403
+ minPasswordStrength: l = 2,
404
+ title: o = "Change Password",
405
+ className: p,
406
+ style: d
407
+ }, $) => {
408
+ const [s, C] = _(""), [b, x] = _(""), [g, F] = _(""), h = J(b), m = b === g, f = (!i || s.length > 0) && b.length > 0 && m && h >= l && !c, T = w(
409
+ (N) => {
410
+ N.preventDefault(), f && (t == null || t({
411
+ currentPassword: i ? s : void 0,
412
412
  newPassword: b
413
413
  }));
414
414
  },
415
- [p, i, b, a, t]
415
+ [f, s, b, i, t]
416
416
  );
417
- return /* @__PURE__ */ n(
417
+ return /* @__PURE__ */ a(
418
418
  "form",
419
419
  {
420
- ref: v,
421
- className: `nice-change-password${m ? ` ${m}` : ""}`,
422
- style: c,
423
- onSubmit: $,
420
+ ref: $,
421
+ className: `nice-change-password${p ? ` ${p}` : ""}`,
422
+ style: d,
423
+ onSubmit: T,
424
424
  noValidate: !0,
425
425
  children: [
426
- /* @__PURE__ */ e("h3", { className: "nice-change-password__title", children: r }),
427
- d && /* @__PURE__ */ e("div", { className: "nice-change-password__error", role: "alert", children: d }),
428
- u && /* @__PURE__ */ e("div", { className: "nice-change-password__success", role: "status", children: u }),
429
- a && /* @__PURE__ */ n("div", { className: "nice-change-password__field", children: [
426
+ /* @__PURE__ */ e("h3", { className: "nice-change-password__title", children: o }),
427
+ n && /* @__PURE__ */ e("div", { className: "nice-change-password__error", role: "alert", children: n }),
428
+ r && /* @__PURE__ */ e("div", { className: "nice-change-password__success", role: "status", children: r }),
429
+ i && /* @__PURE__ */ a("div", { className: "nice-change-password__field", children: [
430
430
  /* @__PURE__ */ e("label", { htmlFor: "nice-cp-current", children: "Current password" }),
431
431
  /* @__PURE__ */ e(
432
432
  "input",
@@ -434,15 +434,15 @@ const z = E(
434
434
  id: "nice-cp-current",
435
435
  className: "nice-input",
436
436
  type: "password",
437
- value: i,
438
- onChange: (g) => k(g.target.value),
437
+ value: s,
438
+ onChange: (N) => C(N.target.value),
439
439
  autoComplete: "current-password",
440
- disabled: o,
440
+ disabled: c,
441
441
  required: !0
442
442
  }
443
443
  )
444
444
  ] }),
445
- /* @__PURE__ */ n("div", { className: "nice-change-password__field", children: [
445
+ /* @__PURE__ */ a("div", { className: "nice-change-password__field", children: [
446
446
  /* @__PURE__ */ e("label", { htmlFor: "nice-cp-new", children: "New password" }),
447
447
  /* @__PURE__ */ e(
448
448
  "input",
@@ -451,15 +451,15 @@ const z = E(
451
451
  className: "nice-input",
452
452
  type: "password",
453
453
  value: b,
454
- onChange: (g) => C(g.target.value),
454
+ onChange: (N) => x(N.target.value),
455
455
  autoComplete: "new-password",
456
- disabled: o,
456
+ disabled: c,
457
457
  required: !0
458
458
  }
459
459
  ),
460
- b.length > 0 && /* @__PURE__ */ e(M, { password: b })
460
+ b.length > 0 && /* @__PURE__ */ e(Z, { password: b })
461
461
  ] }),
462
- /* @__PURE__ */ n("div", { className: "nice-change-password__field", children: [
462
+ /* @__PURE__ */ a("div", { className: "nice-change-password__field", children: [
463
463
  /* @__PURE__ */ e("label", { htmlFor: "nice-cp-confirm", children: "Confirm new password" }),
464
464
  /* @__PURE__ */ e(
465
465
  "input",
@@ -467,57 +467,57 @@ const z = E(
467
467
  id: "nice-cp-confirm",
468
468
  className: "nice-input",
469
469
  type: "password",
470
- value: w,
471
- onChange: (g) => A(g.target.value),
470
+ value: g,
471
+ onChange: (N) => F(N.target.value),
472
472
  autoComplete: "new-password",
473
- disabled: o,
473
+ disabled: c,
474
474
  required: !0
475
475
  }
476
476
  ),
477
- w && !h && /* @__PURE__ */ e("span", { className: "nice-error-text", children: "Passwords do not match" })
477
+ g && !m && /* @__PURE__ */ e("span", { className: "nice-error-text", children: "Passwords do not match" })
478
478
  ] }),
479
- /* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: !p, children: o ? "…" : "Change Password" })
479
+ /* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: !f, children: c ? "…" : "Change Password" })
480
480
  ]
481
481
  }
482
482
  );
483
483
  }
484
484
  );
485
- z.displayName = "NiceChangePassword";
486
- const J = E(({
487
- secret: a,
485
+ oe.displayName = "NiceChangePassword";
486
+ const de = O(({
487
+ secret: i,
488
488
  qrCodeUrl: t,
489
- issuer: o,
490
- accountName: d,
491
- onVerify: u,
492
- loading: f = !1,
493
- error: r,
494
- onCancel: m,
495
- recoveryCodes: c,
496
- step: v = "setup",
497
- onStepChange: i,
498
- className: k,
489
+ issuer: c,
490
+ accountName: n,
491
+ onVerify: r,
492
+ loading: l = !1,
493
+ error: o,
494
+ onCancel: p,
495
+ recoveryCodes: d,
496
+ step: $ = "setup",
497
+ onStepChange: s,
498
+ className: C,
499
499
  style: b
500
- }, C) => {
501
- const [w, A] = _(""), [s, h] = _(!1), [p, $] = _(!1), g = x((y) => {
502
- y.preventDefault(), w.length >= 6 && (u == null || u(w));
503
- }, [w, u]), S = `otpauth://totp/${o ? `${o}:` : ""}${d ?? "user"}?secret=${a}${o ? `&issuer=${o}` : ""}&digits=6&period=30`;
504
- return /* @__PURE__ */ n("div", { ref: C, className: `nice-2fa-setup${k ? ` ${k}` : ""}`, style: b, children: [
500
+ }, x) => {
501
+ const [g, F] = _(""), [h, m] = _(!1), [f, T] = _(!1), N = w((S) => {
502
+ S.preventDefault(), g.length >= 6 && (r == null || r(g));
503
+ }, [g, r]), P = `otpauth://totp/${c ? `${c}:` : ""}${n ?? "user"}?secret=${i}${c ? `&issuer=${c}` : ""}&digits=6&period=30`;
504
+ return /* @__PURE__ */ a("div", { ref: x, className: `nice-2fa-setup${C ? ` ${C}` : ""}`, style: b, children: [
505
505
  /* @__PURE__ */ e("h3", { className: "nice-2fa-setup__title", children: "Two-Factor Authentication" }),
506
- v === "setup" && /* @__PURE__ */ n("div", { className: "nice-2fa-setup__step", children: [
506
+ $ === "setup" && /* @__PURE__ */ a("div", { className: "nice-2fa-setup__step", children: [
507
507
  /* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: "Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.):" }),
508
- t ? /* @__PURE__ */ e("img", { src: t, alt: "2FA QR Code", className: "nice-2fa-setup__qr" }) : /* @__PURE__ */ n("div", { className: "nice-2fa-setup__qr-placeholder", children: [
508
+ t ? /* @__PURE__ */ e("img", { src: t, alt: "2FA QR Code", className: "nice-2fa-setup__qr" }) : /* @__PURE__ */ a("div", { className: "nice-2fa-setup__qr-placeholder", children: [
509
509
  /* @__PURE__ */ e("span", { children: "QR Code" }),
510
- /* @__PURE__ */ e("code", { className: "nice-2fa-setup__uri", children: S })
510
+ /* @__PURE__ */ e("code", { className: "nice-2fa-setup__uri", children: P })
511
511
  ] }),
512
- /* @__PURE__ */ n("div", { className: "nice-2fa-setup__secret", children: [
512
+ /* @__PURE__ */ a("div", { className: "nice-2fa-setup__secret", children: [
513
513
  /* @__PURE__ */ e("span", { children: "Or enter manually: " }),
514
- s ? /* @__PURE__ */ e("code", { className: "nice-2fa-setup__secret-key", children: a }) : /* @__PURE__ */ e("button", { type: "button", onClick: () => h(!0), children: "Show secret key" })
514
+ h ? /* @__PURE__ */ e("code", { className: "nice-2fa-setup__secret-key", children: i }) : /* @__PURE__ */ e("button", { type: "button", onClick: () => m(!0), children: "Show secret key" })
515
515
  ] }),
516
- /* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--primary", onClick: () => i == null ? void 0 : i("verify"), children: "Next — Verify" })
516
+ /* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--primary", onClick: () => s == null ? void 0 : s("verify"), children: "Next — Verify" })
517
517
  ] }),
518
- v === "verify" && /* @__PURE__ */ n("form", { className: "nice-2fa-setup__step", onSubmit: g, children: [
518
+ $ === "verify" && /* @__PURE__ */ a("form", { className: "nice-2fa-setup__step", onSubmit: N, children: [
519
519
  /* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: "Enter the 6-digit code from your authenticator app:" }),
520
- r && /* @__PURE__ */ e("div", { className: "nice-2fa-setup__error", role: "alert", children: r }),
520
+ o && /* @__PURE__ */ e("div", { className: "nice-2fa-setup__error", role: "alert", children: o }),
521
521
  /* @__PURE__ */ e(
522
522
  "input",
523
523
  {
@@ -525,240 +525,477 @@ const J = E(({
525
525
  type: "text",
526
526
  inputMode: "numeric",
527
527
  maxLength: 6,
528
- value: w,
529
- onChange: (y) => A(y.target.value.replace(/\D/g, "").slice(0, 6)),
528
+ value: g,
529
+ onChange: (S) => F(S.target.value.replace(/\D/g, "").slice(0, 6)),
530
530
  placeholder: "000000",
531
531
  autoFocus: !0,
532
- disabled: f,
532
+ disabled: l,
533
533
  autoComplete: "one-time-code"
534
534
  }
535
535
  ),
536
- /* @__PURE__ */ n("div", { className: "nice-2fa-setup__actions", children: [
537
- /* @__PURE__ */ e("button", { type: "button", className: "nice-btn", onClick: () => i == null ? void 0 : i("setup"), children: "Back" }),
538
- /* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: f || w.length < 6, children: f ? "…" : "Verify" })
536
+ /* @__PURE__ */ a("div", { className: "nice-2fa-setup__actions", children: [
537
+ /* @__PURE__ */ e("button", { type: "button", className: "nice-btn", onClick: () => s == null ? void 0 : s("setup"), children: "Back" }),
538
+ /* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: l || g.length < 6, children: l ? "…" : "Verify" })
539
539
  ] })
540
540
  ] }),
541
- v === "recovery" && c && /* @__PURE__ */ n("div", { className: "nice-2fa-setup__step", children: [
541
+ $ === "recovery" && d && /* @__PURE__ */ a("div", { className: "nice-2fa-setup__step", children: [
542
542
  /* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: "Save these recovery codes in a safe place. Each code can only be used once:" }),
543
- /* @__PURE__ */ e("div", { className: "nice-2fa-setup__recovery-codes", children: c.map((y, T) => /* @__PURE__ */ e("code", { className: "nice-2fa-setup__recovery-code", children: y }, T)) }),
543
+ /* @__PURE__ */ e("div", { className: "nice-2fa-setup__recovery-codes", children: d.map((S, E) => /* @__PURE__ */ e("code", { className: "nice-2fa-setup__recovery-code", children: S }, E)) }),
544
544
  /* @__PURE__ */ e(
545
545
  "button",
546
546
  {
547
547
  type: "button",
548
548
  className: "nice-btn",
549
549
  onClick: () => {
550
- var y;
551
- (y = navigator.clipboard) == null || y.writeText(c.join(`
552
- `)), $(!0);
550
+ var S;
551
+ (S = navigator.clipboard) == null || S.writeText(d.join(`
552
+ `)), T(!0);
553
553
  },
554
- children: p ? "Copied!" : "Copy all codes"
554
+ children: f ? "Copied!" : "Copy all codes"
555
555
  }
556
556
  ),
557
- m && /* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--primary", onClick: m, children: "Done" })
557
+ p && /* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--primary", onClick: p, children: "Done" })
558
558
  ] }),
559
- m && v !== "recovery" && /* @__PURE__ */ e("button", { type: "button", className: "nice-2fa-setup__cancel", onClick: m, children: "Cancel" })
559
+ p && $ !== "recovery" && /* @__PURE__ */ e("button", { type: "button", className: "nice-2fa-setup__cancel", onClick: p, children: "Cancel" })
560
560
  ] });
561
561
  });
562
- J.displayName = "NiceTwoFaSetup";
563
- const K = E(
564
- ({
565
- provider: a = "custom",
566
- siteKey: t,
567
- onVerify: o,
568
- onExpire: d,
569
- onError: u,
570
- theme: f = "light",
571
- size: r = "normal",
572
- customRender: m,
573
- className: c,
574
- style: v
575
- }, i) => a === "custom" && m ? /* @__PURE__ */ e(
576
- "div",
577
- {
578
- ref: i,
579
- className: `nice-captcha nice-captcha--custom${c ? ` ${c}` : ""}`,
580
- style: v,
581
- children: m
562
+ de.displayName = "NiceTwoFaSetup";
563
+ const he = 500;
564
+ function I(i, t) {
565
+ return Math.floor(Math.random() * (t - i + 1)) + i;
566
+ }
567
+ function ue() {
568
+ return `${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
569
+ }
570
+ function me(i, t) {
571
+ switch (i) {
572
+ case "math": {
573
+ const c = t === "easy" ? 5 : t === "hard" ? 20 : 10, n = I(1, c), r = I(1, c), l = t !== "easy" && n >= r && Math.random() < 0.5, o = l ? n - r : n + r;
574
+ return { kind: "math", prompt: `${n} ${l ? "−" : "+"} ${r}`, answer: o };
575
+ }
576
+ case "text": {
577
+ const c = t === "easy" ? 4 : t === "hard" ? 7 : 5, n = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
578
+ let r = "";
579
+ for (let l = 0; l < c; l++)
580
+ r += n[I(0, n.length - 1)];
581
+ return { kind: "text", text: r };
582
582
  }
583
- ) : /* @__PURE__ */ e(
583
+ case "slider":
584
+ return { kind: "slider", target: I(70, 92), tolerance: t === "easy" ? 8 : t === "hard" ? 2 : 4 };
585
+ case "checkbox":
586
+ default:
587
+ return { kind: "checkbox" };
588
+ }
589
+ }
590
+ function pe(i, t, c) {
591
+ if (!i)
592
+ return;
593
+ const n = i.getContext("2d");
594
+ if (!n)
595
+ return;
596
+ const r = i.width, l = i.height;
597
+ n.clearRect(0, 0, r, l), n.fillStyle = c ? "#1a1a1a" : "#f3f4f6", n.fillRect(0, 0, r, l), n.strokeStyle = c ? "rgba(255,255,255,0.18)" : "rgba(0,0,0,0.18)", n.lineWidth = 1;
598
+ for (let p = 0; p < 6; p++)
599
+ n.beginPath(), n.moveTo(I(0, r), I(0, l)), n.lineTo(I(0, r), I(0, l)), n.stroke();
600
+ n.fillStyle = c ? "#e5e7eb" : "#111827", n.textBaseline = "middle";
601
+ const o = r / (t.length + 1);
602
+ for (let p = 0; p < t.length; p++) {
603
+ const d = I(22, 30);
604
+ n.save(), n.translate(o * (p + 1), l / 2 + I(-4, 4)), n.rotate(I(-22, 22) * Math.PI / 180), n.font = `bold ${d}px monospace`, n.fillText(t[p], -d / 3, 0), n.restore();
605
+ }
606
+ }
607
+ const fe = O((i, t) => {
608
+ const {
609
+ variant: c,
610
+ difficulty: n = "medium",
611
+ refreshable: r = !0,
612
+ verifyToken: l,
613
+ expiresMs: o,
614
+ label: p = "I'm not a robot",
615
+ provider: d = "custom",
616
+ siteKey: $,
617
+ onVerify: s,
618
+ onExpire: C,
619
+ onError: b,
620
+ onRefresh: x,
621
+ theme: g = "light",
622
+ size: F = "normal",
623
+ customRender: h,
624
+ className: m,
625
+ style: f
626
+ } = i, T = U(null), N = U(null), P = U(), [S, E] = _(0), [k, M] = _("idle"), [q, A] = _(""), [D, u] = _(""), [v, z] = _(0), R = X(
627
+ () => me(c ?? "checkbox", n),
628
+ [c, n, S]
629
+ ), K = w(() => {
630
+ M("idle"), A(""), u(""), z(0), E((y) => y + 1);
631
+ }, []), G = w(() => {
632
+ K(), x == null || x();
633
+ }, [K, x]);
634
+ ae(
635
+ t,
636
+ () => ({ reset: K, refresh: G, container: T.current }),
637
+ [K, G]
638
+ ), W(() => {
639
+ c === "text" && R.kind === "text" && pe(N.current, R.text, g === "dark");
640
+ }, [c, R, g]), W(() => {
641
+ if (k !== "verified" || !o)
642
+ return;
643
+ const y = setTimeout(() => {
644
+ C == null || C(), K();
645
+ }, o);
646
+ return () => clearTimeout(y);
647
+ }, [k, o, C, K]);
648
+ const B = w(() => {
649
+ const y = `ntd-cap:${c}:${ue()}`;
650
+ l ? (M("verifying"), A(""), Promise.resolve().then(() => l(y)).then((Q) => {
651
+ Q ? (M("verified"), s == null || s(y)) : (M("error"), A("Verification failed. Please try again."), E((ne) => ne + 1), u(""));
652
+ }).catch((Q) => {
653
+ M("error"), A("Verification error. Please try again."), b == null || b(Q);
654
+ })) : (M("verified"), s == null || s(y));
655
+ }, [c, l, s, b]), H = w(() => {
656
+ M("error"), A("Incorrect, please try again."), E((y) => y + 1), u("");
657
+ }, []), Y = w(() => {
658
+ k === "verifying" || k === "verified" || (M("verifying"), A(""), P.current = setTimeout(B, he));
659
+ }, [k, B]);
660
+ W(() => () => clearTimeout(P.current), []);
661
+ const j = w(() => {
662
+ R.kind === "math" ? D.trim() !== "" && Number(D) === R.answer ? B() : H() : R.kind === "text" && (D.trim().toUpperCase() === R.text ? B() : H());
663
+ }, [R, D, B, H]), ee = w(
664
+ (y) => {
665
+ z(y), !(R.kind !== "slider" || k === "verified" || k === "verifying") && Math.abs(y - R.target) <= R.tolerance && B();
666
+ },
667
+ [R, k, B]
668
+ );
669
+ if (!c)
670
+ return d === "custom" && h ? /* @__PURE__ */ e(
671
+ "div",
672
+ {
673
+ ref: T,
674
+ className: `nice-captcha nice-captcha--custom${m ? ` ${m}` : ""}`,
675
+ style: f,
676
+ children: h
677
+ }
678
+ ) : /* @__PURE__ */ e(
679
+ "div",
680
+ {
681
+ ref: T,
682
+ className: `nice-captcha nice-captcha--${d} nice-captcha--${g}${F === "compact" ? " nice-captcha--compact" : ""}${m ? ` ${m}` : ""}`,
683
+ style: f,
684
+ "data-sitekey": $,
685
+ "data-theme": g,
686
+ "data-size": F,
687
+ children: /* @__PURE__ */ a("div", { className: "nice-captcha__placeholder", children: [
688
+ /* @__PURE__ */ a("span", { children: [
689
+ "🔒 Captcha (",
690
+ d,
691
+ ")"
692
+ ] }),
693
+ /* @__PURE__ */ a("p", { children: [
694
+ "Load the ",
695
+ d,
696
+ " SDK to activate verification."
697
+ ] })
698
+ ] })
699
+ }
700
+ );
701
+ const L = k === "verifying", V = k === "verified", te = `nice-captcha nice-captcha--${c} nice-captcha--${g} nice-captcha--${k}${F === "compact" ? " nice-captcha--compact" : ""}${m ? ` ${m}` : ""}`;
702
+ return /* @__PURE__ */ a(
584
703
  "div",
585
704
  {
586
- ref: i,
587
- className: `nice-captcha nice-captcha--${a} nice-captcha--${f}${r === "compact" ? " nice-captcha--compact" : ""}${c ? ` ${c}` : ""}`,
588
- style: v,
589
- "data-sitekey": t,
590
- "data-theme": f,
591
- "data-size": r,
592
- children: /* @__PURE__ */ n("div", { className: "nice-captcha__placeholder", children: [
593
- /* @__PURE__ */ n("span", { children: [
594
- "🔒 Captcha (",
595
- a,
596
- ")"
705
+ ref: T,
706
+ className: te,
707
+ style: f,
708
+ role: "group",
709
+ "aria-label": "Captcha challenge",
710
+ "data-variant": c,
711
+ "data-status": k,
712
+ "data-theme": g,
713
+ children: [
714
+ c === "checkbox" && /* @__PURE__ */ a(
715
+ "button",
716
+ {
717
+ type: "button",
718
+ className: "nice-captcha__checkbox",
719
+ role: "checkbox",
720
+ "aria-checked": V,
721
+ "aria-busy": L,
722
+ disabled: L || V,
723
+ onClick: Y,
724
+ children: [
725
+ /* @__PURE__ */ e("span", { className: "nice-captcha__box", "aria-hidden": "true", children: L ? "…" : V ? "✓" : "" }),
726
+ /* @__PURE__ */ e("span", { className: "nice-captcha__label", children: p })
727
+ ]
728
+ }
729
+ ),
730
+ c === "math" && R.kind === "math" && /* @__PURE__ */ a("div", { className: "nice-captcha__challenge", children: [
731
+ /* @__PURE__ */ a("span", { className: "nice-captcha__prompt", "aria-hidden": "true", children: [
732
+ R.prompt,
733
+ " ="
734
+ ] }),
735
+ /* @__PURE__ */ e(
736
+ "input",
737
+ {
738
+ className: "nice-input nice-captcha__answer",
739
+ type: "number",
740
+ inputMode: "numeric",
741
+ value: D,
742
+ "aria-label": `What is ${R.prompt}?`,
743
+ disabled: L || V,
744
+ onChange: (y) => u(y.target.value),
745
+ onKeyDown: (y) => {
746
+ y.key === "Enter" && (y.preventDefault(), j());
747
+ }
748
+ }
749
+ ),
750
+ /* @__PURE__ */ e(
751
+ "button",
752
+ {
753
+ type: "button",
754
+ className: "nice-btn nice-btn--primary nice-captcha__verify",
755
+ disabled: L || V || D.trim() === "",
756
+ onClick: j,
757
+ children: L ? "…" : "Verify"
758
+ }
759
+ )
760
+ ] }),
761
+ c === "text" && R.kind === "text" && /* @__PURE__ */ a("div", { className: "nice-captcha__challenge", children: [
762
+ /* @__PURE__ */ e(
763
+ "canvas",
764
+ {
765
+ ref: N,
766
+ className: "nice-captcha__canvas",
767
+ width: 160,
768
+ height: 56,
769
+ "aria-hidden": "true"
770
+ }
771
+ ),
772
+ /* @__PURE__ */ e(
773
+ "input",
774
+ {
775
+ className: "nice-input nice-captcha__answer",
776
+ type: "text",
777
+ autoCapitalize: "characters",
778
+ autoComplete: "off",
779
+ value: D,
780
+ "aria-label": "Type the characters shown in the image",
781
+ disabled: L || V,
782
+ onChange: (y) => u(y.target.value),
783
+ onKeyDown: (y) => {
784
+ y.key === "Enter" && (y.preventDefault(), j());
785
+ }
786
+ }
787
+ ),
788
+ /* @__PURE__ */ e(
789
+ "button",
790
+ {
791
+ type: "button",
792
+ className: "nice-btn nice-btn--primary nice-captcha__verify",
793
+ disabled: L || V || D.trim() === "",
794
+ onClick: j,
795
+ children: L ? "…" : "Verify"
796
+ }
797
+ )
597
798
  ] }),
598
- /* @__PURE__ */ n("p", { children: [
599
- "Load the ",
600
- a,
601
- " SDK to activate verification."
799
+ c === "slider" && R.kind === "slider" && /* @__PURE__ */ a("div", { className: "nice-captcha__challenge nice-captcha__challenge--slider", children: [
800
+ /* @__PURE__ */ e("span", { className: "nice-captcha__slider-hint", "aria-hidden": "true", children: V ? "Verified ✓" : "Slide to the marker" }),
801
+ /* @__PURE__ */ a("div", { className: "nice-captcha__track", children: [
802
+ /* @__PURE__ */ e(
803
+ "span",
804
+ {
805
+ className: "nice-captcha__target",
806
+ "aria-hidden": "true",
807
+ style: { left: `${R.target}%` }
808
+ }
809
+ ),
810
+ /* @__PURE__ */ e(
811
+ "input",
812
+ {
813
+ className: "nice-captcha__slider",
814
+ type: "range",
815
+ min: 0,
816
+ max: 100,
817
+ value: v,
818
+ "aria-label": "Slide the handle to the marker to verify",
819
+ "aria-valuetext": `${v}%`,
820
+ disabled: V || L,
821
+ onChange: (y) => ee(Number(y.target.value))
822
+ }
823
+ )
824
+ ] })
825
+ ] }),
826
+ /* @__PURE__ */ a("div", { className: "nice-captcha__footer", children: [
827
+ /* @__PURE__ */ e("div", { className: "nice-captcha__message", role: "status", "aria-live": "polite", children: q }),
828
+ r && /* @__PURE__ */ e(
829
+ "button",
830
+ {
831
+ type: "button",
832
+ className: "nice-captcha__refresh",
833
+ "aria-label": "Refresh challenge",
834
+ title: "Refresh challenge",
835
+ onClick: G,
836
+ children: "↻"
837
+ }
838
+ )
602
839
  ] })
603
- ] })
840
+ ]
604
841
  }
605
- )
606
- );
607
- K.displayName = "NiceCaptcha";
608
- const U = [
842
+ );
843
+ });
844
+ fe.displayName = "NiceCaptcha";
845
+ const ge = [
609
846
  { id: "google", label: "Google", icon: "🔵", color: "#4285f4", textColor: "#fff" },
610
847
  { id: "microsoft", label: "Microsoft", icon: "🟦", color: "#00a4ef", textColor: "#fff" },
611
848
  { id: "discord", label: "Discord", icon: "💬", color: "#5865f2", textColor: "#fff" },
612
849
  { id: "spotify", label: "Spotify", icon: "🎵", color: "#1db954", textColor: "#fff" },
613
850
  { id: "github", label: "GitHub", icon: "🐙", color: "#24292e", textColor: "#fff" }
614
- ], Z = E(({
615
- providers: a = U,
851
+ ], _e = O(({
852
+ providers: i = ge,
616
853
  onProviderClick: t,
617
- disabled: o = !1,
618
- loadingProvider: d,
619
- direction: u = "vertical",
620
- separatorText: f = "or continue with",
621
- showSeparator: r = !0,
622
- className: m,
623
- style: c
624
- }, v) => /* @__PURE__ */ n(
854
+ disabled: c = !1,
855
+ loadingProvider: n,
856
+ direction: r = "vertical",
857
+ separatorText: l = "or continue with",
858
+ showSeparator: o = !0,
859
+ className: p,
860
+ style: d
861
+ }, $) => /* @__PURE__ */ a(
625
862
  "div",
626
863
  {
627
- ref: v,
628
- className: `nice-oauth nice-oauth--${u}${m ? ` ${m}` : ""}`,
629
- style: c,
864
+ ref: $,
865
+ className: `nice-oauth nice-oauth--${r}${p ? ` ${p}` : ""}`,
866
+ style: d,
630
867
  children: [
631
- r && /* @__PURE__ */ n("div", { className: "nice-oauth__separator", children: [
868
+ o && /* @__PURE__ */ a("div", { className: "nice-oauth__separator", children: [
632
869
  /* @__PURE__ */ e("hr", {}),
633
- /* @__PURE__ */ e("span", { children: f }),
870
+ /* @__PURE__ */ e("span", { children: l }),
634
871
  /* @__PURE__ */ e("hr", {})
635
872
  ] }),
636
- /* @__PURE__ */ e("div", { className: "nice-oauth__buttons", children: a.map((i) => /* @__PURE__ */ n(
873
+ /* @__PURE__ */ e("div", { className: "nice-oauth__buttons", children: i.map((s) => /* @__PURE__ */ a(
637
874
  "button",
638
875
  {
639
876
  type: "button",
640
- className: `nice-oauth__btn${d === i.id ? " nice-oauth__btn--loading" : ""}`,
641
- style: { backgroundColor: i.color, color: i.textColor },
642
- onClick: () => t == null ? void 0 : t(i.id),
643
- disabled: o || !!d,
877
+ className: `nice-oauth__btn${n === s.id ? " nice-oauth__btn--loading" : ""}`,
878
+ style: { backgroundColor: s.color, color: s.textColor },
879
+ onClick: () => t == null ? void 0 : t(s.id),
880
+ disabled: c || !!n,
644
881
  children: [
645
- i.icon && /* @__PURE__ */ e("span", { className: "nice-oauth__btn-icon", children: i.icon }),
646
- /* @__PURE__ */ e("span", { className: "nice-oauth__btn-label", children: d === i.id ? "…" : i.label })
882
+ s.icon && /* @__PURE__ */ e("span", { className: "nice-oauth__btn-icon", children: s.icon }),
883
+ /* @__PURE__ */ e("span", { className: "nice-oauth__btn-label", children: n === s.id ? "…" : s.label })
647
884
  ]
648
885
  },
649
- i.id
886
+ s.id
650
887
  )) })
651
888
  ]
652
889
  }
653
890
  ));
654
- Z.displayName = "NiceOAuthButtons";
655
- const Y = E(
656
- function(t, o) {
891
+ _e.displayName = "NiceOAuthButtons";
892
+ const ye = O(
893
+ function(t, c) {
657
894
  const {
658
- tokens: d,
659
- onCreate: u,
660
- onRevoke: f,
661
- availableScopes: r = [],
662
- maxTokens: m = 10,
663
- title: c = "API Tokens",
664
- className: v,
665
- style: i
666
- } = t, [k, b] = _(!1), [C, w] = _(""), [A, s] = _([]), [h, p] = _("90"), [$, g] = _(null), [S, y] = _(!1), [T, R] = _(null), L = x(async () => {
667
- if (!(!u || !C.trim())) {
668
- y(!0);
895
+ tokens: n,
896
+ onCreate: r,
897
+ onRevoke: l,
898
+ availableScopes: o = [],
899
+ maxTokens: p = 10,
900
+ title: d = "API Tokens",
901
+ className: $,
902
+ style: s
903
+ } = t, [C, b] = _(!1), [x, g] = _(""), [F, h] = _([]), [m, f] = _("90"), [T, N] = _(null), [P, S] = _(!1), [E, k] = _(null), M = w(async () => {
904
+ if (!(!r || !x.trim())) {
905
+ S(!0);
669
906
  try {
670
- const l = h ? parseInt(h, 10) : void 0, N = await u(C.trim(), A, l);
671
- g(N), w(""), s([]), b(!1);
907
+ const u = m ? parseInt(m, 10) : void 0, v = await r(x.trim(), F, u);
908
+ N(v), g(""), h([]), b(!1);
672
909
  } finally {
673
- y(!1);
910
+ S(!1);
674
911
  }
675
912
  }
676
- }, [u, C, A, h]), P = x(
677
- async (l) => {
678
- if (f) {
679
- R(l);
913
+ }, [r, x, F, m]), q = w(
914
+ async (u) => {
915
+ if (l) {
916
+ k(u);
680
917
  try {
681
- await f(l);
918
+ await l(u);
682
919
  } finally {
683
- R(null);
920
+ k(null);
684
921
  }
685
922
  }
686
923
  },
687
- [f]
688
- ), F = (l) => {
689
- s(
690
- (N) => N.includes(l) ? N.filter((O) => O !== l) : [...N, l]
924
+ [l]
925
+ ), A = (u) => {
926
+ h(
927
+ (v) => v.includes(u) ? v.filter((z) => z !== u) : [...v, u]
691
928
  );
692
- }, D = d.length < m;
693
- return /* @__PURE__ */ n("div", { ref: o, className: `nice-token-management ${v ?? ""}`, style: i, children: [
694
- /* @__PURE__ */ n("div", { className: "nice-token-management__header", children: [
695
- /* @__PURE__ */ e("h3", { children: c }),
929
+ }, D = n.length < p;
930
+ return /* @__PURE__ */ a("div", { ref: c, className: `nice-token-management ${$ ?? ""}`, style: s, children: [
931
+ /* @__PURE__ */ a("div", { className: "nice-token-management__header", children: [
932
+ /* @__PURE__ */ e("h3", { children: d }),
696
933
  D && /* @__PURE__ */ e(
697
934
  "button",
698
935
  {
699
936
  className: "nice-token-management__new-btn",
700
937
  onClick: () => b(!0),
701
- disabled: k,
938
+ disabled: C,
702
939
  children: "+ New Token"
703
940
  }
704
941
  )
705
942
  ] }),
706
- $ && /* @__PURE__ */ n("div", { className: "nice-token-management__reveal", children: [
707
- /* @__PURE__ */ n("p", { children: [
943
+ T && /* @__PURE__ */ a("div", { className: "nice-token-management__reveal", children: [
944
+ /* @__PURE__ */ a("p", { children: [
708
945
  /* @__PURE__ */ e("strong", { children: "New token created!" }),
709
946
  " Copy it now — it won't be shown again."
710
947
  ] }),
711
- /* @__PURE__ */ e("code", { className: "nice-token-management__token-value", children: $ }),
712
- /* @__PURE__ */ e("button", { onClick: () => g(null), children: "Dismiss" })
948
+ /* @__PURE__ */ e("code", { className: "nice-token-management__token-value", children: T }),
949
+ /* @__PURE__ */ e("button", { onClick: () => N(null), children: "Dismiss" })
713
950
  ] }),
714
- k && /* @__PURE__ */ n("div", { className: "nice-token-management__create-form", children: [
715
- /* @__PURE__ */ n("label", { children: [
951
+ C && /* @__PURE__ */ a("div", { className: "nice-token-management__create-form", children: [
952
+ /* @__PURE__ */ a("label", { children: [
716
953
  "Name",
717
954
  /* @__PURE__ */ e(
718
955
  "input",
719
956
  {
720
957
  type: "text",
721
- value: C,
722
- onChange: (l) => w(l.target.value),
958
+ value: x,
959
+ onChange: (u) => g(u.target.value),
723
960
  placeholder: "My API token",
724
961
  maxLength: 64
725
962
  }
726
963
  )
727
964
  ] }),
728
- r.length > 0 && /* @__PURE__ */ n("fieldset", { children: [
965
+ o.length > 0 && /* @__PURE__ */ a("fieldset", { children: [
729
966
  /* @__PURE__ */ e("legend", { children: "Scopes" }),
730
- r.map((l) => /* @__PURE__ */ n("label", { className: "nice-token-management__scope", children: [
967
+ o.map((u) => /* @__PURE__ */ a("label", { className: "nice-token-management__scope", children: [
731
968
  /* @__PURE__ */ e(
732
969
  "input",
733
970
  {
734
971
  type: "checkbox",
735
- checked: A.includes(l),
736
- onChange: () => F(l)
972
+ checked: F.includes(u),
973
+ onChange: () => A(u)
737
974
  }
738
975
  ),
739
- l
740
- ] }, l))
976
+ u
977
+ ] }, u))
741
978
  ] }),
742
- /* @__PURE__ */ n("label", { children: [
979
+ /* @__PURE__ */ a("label", { children: [
743
980
  "Expires in (days)",
744
981
  /* @__PURE__ */ e(
745
982
  "input",
746
983
  {
747
984
  type: "number",
748
- value: h,
749
- onChange: (l) => p(l.target.value),
985
+ value: m,
986
+ onChange: (u) => f(u.target.value),
750
987
  min: 1,
751
988
  max: 365
752
989
  }
753
990
  )
754
991
  ] }),
755
- /* @__PURE__ */ n("div", { className: "nice-token-management__create-actions", children: [
756
- /* @__PURE__ */ e("button", { onClick: L, disabled: S || !C.trim(), children: S ? "Creating…" : "Create Token" }),
992
+ /* @__PURE__ */ a("div", { className: "nice-token-management__create-actions", children: [
993
+ /* @__PURE__ */ e("button", { onClick: M, disabled: P || !x.trim(), children: P ? "Creating…" : "Create Token" }),
757
994
  /* @__PURE__ */ e("button", { onClick: () => b(!1), children: "Cancel" })
758
995
  ] })
759
996
  ] }),
760
- d.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-token-management__empty", children: "No API tokens yet." }) : /* @__PURE__ */ n("table", { className: "nice-token-management__table", children: [
761
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ n("tr", { children: [
997
+ n.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-token-management__empty", children: "No API tokens yet." }) : /* @__PURE__ */ a("table", { className: "nice-token-management__table", children: [
998
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ a("tr", { children: [
762
999
  /* @__PURE__ */ e("th", { children: "Name" }),
763
1000
  /* @__PURE__ */ e("th", { children: "Prefix" }),
764
1001
  /* @__PURE__ */ e("th", { children: "Created" }),
@@ -767,43 +1004,43 @@ const Y = E(
767
1004
  /* @__PURE__ */ e("th", { children: "Scopes" }),
768
1005
  /* @__PURE__ */ e("th", {})
769
1006
  ] }) }),
770
- /* @__PURE__ */ e("tbody", { children: d.map((l) => {
771
- var N;
772
- return /* @__PURE__ */ n("tr", { children: [
773
- /* @__PURE__ */ e("td", { children: l.name }),
774
- /* @__PURE__ */ e("td", { children: /* @__PURE__ */ n("code", { children: [
775
- l.prefix,
1007
+ /* @__PURE__ */ e("tbody", { children: n.map((u) => {
1008
+ var v;
1009
+ return /* @__PURE__ */ a("tr", { children: [
1010
+ /* @__PURE__ */ e("td", { children: u.name }),
1011
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ a("code", { children: [
1012
+ u.prefix,
776
1013
  "…"
777
1014
  ] }) }),
778
- /* @__PURE__ */ e("td", { children: l.createdAt }),
779
- /* @__PURE__ */ e("td", { children: l.expiresAt ?? "—" }),
780
- /* @__PURE__ */ e("td", { children: l.lastUsedAt ?? "Never" }),
781
- /* @__PURE__ */ e("td", { children: ((N = l.scopes) == null ? void 0 : N.join(", ")) || "—" }),
1015
+ /* @__PURE__ */ e("td", { children: u.createdAt }),
1016
+ /* @__PURE__ */ e("td", { children: u.expiresAt ?? "—" }),
1017
+ /* @__PURE__ */ e("td", { children: u.lastUsedAt ?? "Never" }),
1018
+ /* @__PURE__ */ e("td", { children: ((v = u.scopes) == null ? void 0 : v.join(", ")) || "—" }),
782
1019
  /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
783
1020
  "button",
784
1021
  {
785
1022
  className: "nice-token-management__revoke-btn",
786
- onClick: () => P(l.id),
787
- disabled: T === l.id,
788
- children: T === l.id ? "Revoking…" : "Revoke"
1023
+ onClick: () => q(u.id),
1024
+ disabled: E === u.id,
1025
+ children: E === u.id ? "Revoking…" : "Revoke"
789
1026
  }
790
1027
  ) })
791
- ] }, l.id);
1028
+ ] }, u.id);
792
1029
  }) })
793
1030
  ] })
794
1031
  ] });
795
1032
  }
796
1033
  );
797
1034
  export {
798
- K as NiceCaptcha,
799
- z as NiceChangePassword,
800
- j as NiceLoginForm,
801
- Z as NiceOAuthButtons,
802
- M as NicePasswordStrength,
803
- Q as NiceRegistrationForm,
804
- Y as NiceTokenManagement,
805
- J as NiceTwoFaSetup,
806
- I as calcPasswordStrength,
807
- X as useAuth
1035
+ fe as NiceCaptcha,
1036
+ oe as NiceChangePassword,
1037
+ ie as NiceLoginForm,
1038
+ _e as NiceOAuthButtons,
1039
+ Z as NicePasswordStrength,
1040
+ le as NiceRegistrationForm,
1041
+ ye as NiceTokenManagement,
1042
+ de as NiceTwoFaSetup,
1043
+ J as calcPasswordStrength,
1044
+ ve as useAuth
808
1045
  };
809
1046
  //# sourceMappingURL=index.mjs.map