@lumoauth/react 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,2472 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ AuthCallback: () => AuthCallback,
25
+ LumoAuth: () => import_client4.LumoAuth,
26
+ LumoAuthProvider: () => LumoAuthProvider,
27
+ Protect: () => Protect,
28
+ RedirectToSignIn: () => RedirectToSignIn,
29
+ SignIn: () => SignIn,
30
+ SignInButton: () => SignInButton,
31
+ SignOutButton: () => SignOutButton,
32
+ SignUp: () => SignUp,
33
+ SignUpButton: () => SignUpButton,
34
+ SignedIn: () => SignedIn,
35
+ SignedOut: () => SignedOut,
36
+ UserAvatar: () => UserAvatar,
37
+ UserButton: () => UserButton,
38
+ UserProfile: () => UserProfile,
39
+ useAbac: () => useAbac,
40
+ useAuth: () => useAuth,
41
+ useEmailFirst: () => useEmailFirst,
42
+ useLumoAuth: () => useLumoAuth,
43
+ useMagicLink: () => useMagicLink,
44
+ usePermission: () => usePermission,
45
+ useSession: () => useSession,
46
+ useSignIn: () => useSignIn,
47
+ useUser: () => useUser,
48
+ useZanzibar: () => useZanzibar
49
+ });
50
+ module.exports = __toCommonJS(index_exports);
51
+ var import_client4 = require("@lumoauth/client");
52
+
53
+ // src/provider.tsx
54
+ var import_react = require("react");
55
+ var import_client = require("@lumoauth/client");
56
+ var import_client2 = require("@lumoauth/client");
57
+
58
+ // src/styles.ts
59
+ var STYLE_ID = "lumoauth-react-styles";
60
+ var injected = false;
61
+ function injectStyles() {
62
+ if (injected) return;
63
+ if (typeof document === "undefined") return;
64
+ if (document.getElementById(STYLE_ID)) {
65
+ injected = true;
66
+ return;
67
+ }
68
+ const style = document.createElement("style");
69
+ style.id = STYLE_ID;
70
+ style.textContent = CSS_CONTENT;
71
+ document.head.appendChild(style);
72
+ injected = true;
73
+ }
74
+ var CSS_CONTENT = `
75
+ /* \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
76
+ @lumoauth/react \u2014 Self-contained component styles
77
+ \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 */
78
+
79
+ :root {
80
+ --la-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
81
+ --la-font-size-sm: 0.8125rem;
82
+ --la-font-size-base: 0.875rem;
83
+ --la-font-size-lg: 1rem;
84
+ --la-font-size-xl: 1.25rem;
85
+ --la-font-size-2xl: 1.5rem;
86
+ --la-font-weight-normal: 400;
87
+ --la-font-weight-medium: 500;
88
+ --la-font-weight-semibold: 600;
89
+
90
+ --la-radius-sm: 6px;
91
+ --la-radius-md: 8px;
92
+ --la-radius-lg: 12px;
93
+ --la-radius-xl: 16px;
94
+ --la-radius-full: 9999px;
95
+
96
+ --la-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
97
+ --la-shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
98
+ --la-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
99
+ --la-shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
100
+
101
+ --la-transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
102
+
103
+ /* Light theme (default) */
104
+ --la-bg: #ffffff;
105
+ --la-bg-subtle: #f8f9fb;
106
+ --la-bg-muted: #f1f3f5;
107
+ --la-bg-hover: #e9ecef;
108
+ --la-border: #dee2e6;
109
+ --la-border-focus: #7c5cfc;
110
+ --la-text: #1a1a2e;
111
+ --la-text-secondary: #6c757d;
112
+ --la-text-muted: #adb5bd;
113
+ --la-primary: #7c5cfc;
114
+ --la-primary-hover: #6a4ce0;
115
+ --la-primary-text: #ffffff;
116
+ --la-danger: #e74c3c;
117
+ --la-danger-bg: #fef2f2;
118
+ --la-success: #27ae60;
119
+ --la-success-bg: #f0fdf4;
120
+ --la-link: #7c5cfc;
121
+ --la-overlay: rgba(0,0,0,0.5);
122
+ --la-card-shadow: var(--la-shadow-xl);
123
+ }
124
+
125
+ /* Dark theme */
126
+ [data-lumoauth-theme="dark"],
127
+ .la-dark {
128
+ --la-bg: #1a1a2e;
129
+ --la-bg-subtle: #16213e;
130
+ --la-bg-muted: #0f3460;
131
+ --la-bg-hover: #1a3a6a;
132
+ --la-border: #2a2a4a;
133
+ --la-border-focus: #9d85f7;
134
+ --la-text: #e8e8f0;
135
+ --la-text-secondary: #a0a0b8;
136
+ --la-text-muted: #6a6a88;
137
+ --la-primary: #9d85f7;
138
+ --la-primary-hover: #b39dff;
139
+ --la-primary-text: #1a1a2e;
140
+ --la-danger: #ff6b6b;
141
+ --la-danger-bg: #2d1b1b;
142
+ --la-success: #51cf66;
143
+ --la-success-bg: #1b2d1b;
144
+ --la-link: #9d85f7;
145
+ --la-overlay: rgba(0,0,0,0.7);
146
+ --la-card-shadow: 0 20px 25px -5px rgba(0,0,0,0.3), 0 10px 10px -5px rgba(0,0,0,0.2);
147
+ }
148
+
149
+ @media (prefers-color-scheme: dark) {
150
+ :root:not([data-lumoauth-theme="light"]):not(.la-light) {
151
+ --la-bg: #1a1a2e;
152
+ --la-bg-subtle: #16213e;
153
+ --la-bg-muted: #0f3460;
154
+ --la-bg-hover: #1a3a6a;
155
+ --la-border: #2a2a4a;
156
+ --la-border-focus: #9d85f7;
157
+ --la-text: #e8e8f0;
158
+ --la-text-secondary: #a0a0b8;
159
+ --la-text-muted: #6a6a88;
160
+ --la-primary: #9d85f7;
161
+ --la-primary-hover: #b39dff;
162
+ --la-primary-text: #1a1a2e;
163
+ --la-danger: #ff6b6b;
164
+ --la-danger-bg: #2d1b1b;
165
+ --la-success: #51cf66;
166
+ --la-success-bg: #1b2d1b;
167
+ --la-link: #9d85f7;
168
+ --la-overlay: rgba(0,0,0,0.7);
169
+ --la-card-shadow: 0 20px 25px -5px rgba(0,0,0,0.3), 0 10px 10px -5px rgba(0,0,0,0.2);
170
+ }
171
+ }
172
+
173
+ /* \u2500\u2500\u2500 Card Container \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
174
+
175
+ .la-card {
176
+ font-family: var(--la-font-family);
177
+ background: var(--la-bg);
178
+ border: 1px solid var(--la-border);
179
+ border-radius: var(--la-radius-xl);
180
+ box-shadow: var(--la-card-shadow);
181
+ width: 100%;
182
+ max-width: 400px;
183
+ padding: 2rem;
184
+ box-sizing: border-box;
185
+ color: var(--la-text);
186
+ }
187
+
188
+ .la-card * {
189
+ box-sizing: border-box;
190
+ }
191
+
192
+ .la-card-header {
193
+ text-align: center;
194
+ margin-bottom: 1.5rem;
195
+ }
196
+
197
+ .la-card-title {
198
+ font-size: var(--la-font-size-2xl);
199
+ font-weight: var(--la-font-weight-semibold);
200
+ color: var(--la-text);
201
+ margin: 0 0 0.25rem 0;
202
+ line-height: 1.3;
203
+ }
204
+
205
+ .la-card-subtitle {
206
+ font-size: var(--la-font-size-base);
207
+ color: var(--la-text-secondary);
208
+ margin: 0;
209
+ line-height: 1.5;
210
+ }
211
+
212
+ /* \u2500\u2500\u2500 Form Elements \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
213
+
214
+ .la-form-group {
215
+ margin-bottom: 1rem;
216
+ }
217
+
218
+ .la-label {
219
+ display: block;
220
+ font-size: var(--la-font-size-sm);
221
+ font-weight: var(--la-font-weight-medium);
222
+ color: var(--la-text);
223
+ margin-bottom: 0.375rem;
224
+ }
225
+
226
+ .la-input {
227
+ display: block;
228
+ width: 100%;
229
+ padding: 0.625rem 0.75rem;
230
+ font-family: var(--la-font-family);
231
+ font-size: var(--la-font-size-base);
232
+ color: var(--la-text);
233
+ background: var(--la-bg-subtle);
234
+ border: 1px solid var(--la-border);
235
+ border-radius: var(--la-radius-md);
236
+ outline: none;
237
+ transition: border-color var(--la-transition), box-shadow var(--la-transition);
238
+ line-height: 1.5;
239
+ }
240
+
241
+ .la-input::placeholder {
242
+ color: var(--la-text-muted);
243
+ }
244
+
245
+ .la-input:focus {
246
+ border-color: var(--la-border-focus);
247
+ box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.15);
248
+ }
249
+
250
+ .la-input:disabled {
251
+ opacity: 0.6;
252
+ cursor: not-allowed;
253
+ }
254
+
255
+ /* \u2500\u2500\u2500 Buttons \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
256
+
257
+ .la-btn {
258
+ display: inline-flex;
259
+ align-items: center;
260
+ justify-content: center;
261
+ gap: 0.5rem;
262
+ width: 100%;
263
+ padding: 0.625rem 1rem;
264
+ font-family: var(--la-font-family);
265
+ font-size: var(--la-font-size-base);
266
+ font-weight: var(--la-font-weight-medium);
267
+ line-height: 1.5;
268
+ border-radius: var(--la-radius-md);
269
+ border: 1px solid transparent;
270
+ cursor: pointer;
271
+ transition: all var(--la-transition);
272
+ text-decoration: none;
273
+ outline: none;
274
+ }
275
+
276
+ .la-btn:focus-visible {
277
+ box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.25);
278
+ }
279
+
280
+ .la-btn:disabled {
281
+ opacity: 0.6;
282
+ cursor: not-allowed;
283
+ }
284
+
285
+ .la-btn-primary {
286
+ background: var(--la-primary);
287
+ color: var(--la-primary-text);
288
+ border-color: var(--la-primary);
289
+ }
290
+
291
+ .la-btn-primary:hover:not(:disabled) {
292
+ background: var(--la-primary-hover);
293
+ border-color: var(--la-primary-hover);
294
+ }
295
+
296
+ .la-btn-outline {
297
+ background: transparent;
298
+ color: var(--la-text);
299
+ border-color: var(--la-border);
300
+ }
301
+
302
+ .la-btn-outline:hover:not(:disabled) {
303
+ background: var(--la-bg-hover);
304
+ }
305
+
306
+ .la-btn-ghost {
307
+ background: transparent;
308
+ color: var(--la-text-secondary);
309
+ border: none;
310
+ padding: 0.375rem 0.5rem;
311
+ width: auto;
312
+ }
313
+
314
+ .la-btn-ghost:hover:not(:disabled) {
315
+ color: var(--la-text);
316
+ background: var(--la-bg-hover);
317
+ }
318
+
319
+ .la-btn-danger {
320
+ background: transparent;
321
+ color: var(--la-danger);
322
+ border: none;
323
+ width: auto;
324
+ padding: 0.375rem 0.5rem;
325
+ }
326
+
327
+ .la-btn-danger:hover:not(:disabled) {
328
+ background: var(--la-danger-bg);
329
+ }
330
+
331
+ /* \u2500\u2500\u2500 Spinner \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
332
+
333
+ .la-spinner {
334
+ display: inline-block;
335
+ width: 1rem;
336
+ height: 1rem;
337
+ border: 2px solid var(--la-border);
338
+ border-top-color: var(--la-primary);
339
+ border-radius: 50%;
340
+ animation: la-spin 0.6s linear infinite;
341
+ }
342
+
343
+ .la-spinner-sm {
344
+ width: 0.75rem;
345
+ height: 0.75rem;
346
+ border-width: 1.5px;
347
+ }
348
+
349
+ @keyframes la-spin {
350
+ to { transform: rotate(360deg); }
351
+ }
352
+
353
+ /* \u2500\u2500\u2500 Alert / Error \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
354
+
355
+ .la-alert {
356
+ padding: 0.625rem 0.75rem;
357
+ border-radius: var(--la-radius-md);
358
+ font-size: var(--la-font-size-sm);
359
+ line-height: 1.5;
360
+ margin-bottom: 1rem;
361
+ }
362
+
363
+ .la-alert-error {
364
+ background: var(--la-danger-bg);
365
+ color: var(--la-danger);
366
+ border: 1px solid rgba(231, 76, 60, 0.15);
367
+ }
368
+
369
+ .la-alert-success {
370
+ background: var(--la-success-bg);
371
+ color: var(--la-success);
372
+ border: 1px solid rgba(39, 174, 96, 0.15);
373
+ }
374
+
375
+ /* \u2500\u2500\u2500 Divider \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
376
+
377
+ .la-divider {
378
+ display: flex;
379
+ align-items: center;
380
+ gap: 0.75rem;
381
+ margin: 1.25rem 0;
382
+ color: var(--la-text-muted);
383
+ font-size: var(--la-font-size-sm);
384
+ }
385
+
386
+ .la-divider::before,
387
+ .la-divider::after {
388
+ content: '';
389
+ flex: 1;
390
+ height: 1px;
391
+ background: var(--la-border);
392
+ }
393
+
394
+ /* \u2500\u2500\u2500 Social Button \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
395
+
396
+ .la-social-btn {
397
+ display: flex;
398
+ align-items: center;
399
+ justify-content: center;
400
+ gap: 0.5rem;
401
+ width: 100%;
402
+ padding: 0.5rem 0.75rem;
403
+ font-family: var(--la-font-family);
404
+ font-size: var(--la-font-size-sm);
405
+ font-weight: var(--la-font-weight-medium);
406
+ color: var(--la-text);
407
+ background: var(--la-bg);
408
+ border: 1px solid var(--la-border);
409
+ border-radius: var(--la-radius-md);
410
+ cursor: pointer;
411
+ transition: all var(--la-transition);
412
+ outline: none;
413
+ line-height: 1.5;
414
+ }
415
+
416
+ .la-social-btn:hover {
417
+ background: var(--la-bg-hover);
418
+ }
419
+
420
+ .la-social-btn:focus-visible {
421
+ box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.15);
422
+ }
423
+
424
+ .la-social-buttons {
425
+ display: flex;
426
+ flex-direction: column;
427
+ gap: 0.5rem;
428
+ margin-bottom: 0.25rem;
429
+ }
430
+
431
+ .la-social-icon {
432
+ width: 1.125rem;
433
+ height: 1.125rem;
434
+ flex-shrink: 0;
435
+ }
436
+
437
+ /* \u2500\u2500\u2500 Footer Link \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
438
+
439
+ .la-footer {
440
+ text-align: center;
441
+ margin-top: 1.25rem;
442
+ font-size: var(--la-font-size-sm);
443
+ color: var(--la-text-secondary);
444
+ }
445
+
446
+ .la-footer a,
447
+ .la-link {
448
+ color: var(--la-link);
449
+ text-decoration: none;
450
+ font-weight: var(--la-font-weight-medium);
451
+ cursor: pointer;
452
+ }
453
+
454
+ .la-footer a:hover,
455
+ .la-link:hover {
456
+ text-decoration: underline;
457
+ }
458
+
459
+ /* \u2500\u2500\u2500 Password Strength \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
460
+
461
+ .la-password-strength {
462
+ margin-top: 0.375rem;
463
+ }
464
+
465
+ .la-password-bar {
466
+ height: 3px;
467
+ border-radius: 2px;
468
+ background: var(--la-bg-muted);
469
+ overflow: hidden;
470
+ }
471
+
472
+ .la-password-fill {
473
+ height: 100%;
474
+ border-radius: 2px;
475
+ transition: width var(--la-transition), background var(--la-transition);
476
+ }
477
+
478
+ .la-password-fill[data-strength="0"] { width: 0%; }
479
+ .la-password-fill[data-strength="1"] { width: 25%; background: var(--la-danger); }
480
+ .la-password-fill[data-strength="2"] { width: 50%; background: #f39c12; }
481
+ .la-password-fill[data-strength="3"] { width: 75%; background: #3498db; }
482
+ .la-password-fill[data-strength="4"] { width: 100%; background: var(--la-success); }
483
+
484
+ .la-password-label {
485
+ font-size: 0.6875rem;
486
+ color: var(--la-text-muted);
487
+ margin-top: 0.25rem;
488
+ }
489
+
490
+ /* \u2500\u2500\u2500 UserButton \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
491
+
492
+ .la-user-button {
493
+ position: relative;
494
+ display: inline-flex;
495
+ font-family: var(--la-font-family);
496
+ }
497
+
498
+ .la-user-trigger {
499
+ display: flex;
500
+ align-items: center;
501
+ gap: 0.5rem;
502
+ padding: 0.25rem;
503
+ background: none;
504
+ border: none;
505
+ cursor: pointer;
506
+ border-radius: var(--la-radius-full);
507
+ transition: all var(--la-transition);
508
+ outline: none;
509
+ }
510
+
511
+ .la-user-trigger:hover {
512
+ background: var(--la-bg-hover);
513
+ }
514
+
515
+ .la-user-trigger:focus-visible {
516
+ box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.25);
517
+ }
518
+
519
+ .la-user-avatar {
520
+ width: 2rem;
521
+ height: 2rem;
522
+ border-radius: 50%;
523
+ background: var(--la-primary);
524
+ color: var(--la-primary-text);
525
+ display: flex;
526
+ align-items: center;
527
+ justify-content: center;
528
+ font-size: var(--la-font-size-sm);
529
+ font-weight: var(--la-font-weight-semibold);
530
+ overflow: hidden;
531
+ flex-shrink: 0;
532
+ }
533
+
534
+ .la-user-avatar img {
535
+ width: 100%;
536
+ height: 100%;
537
+ object-fit: cover;
538
+ }
539
+
540
+ .la-user-name {
541
+ font-size: var(--la-font-size-sm);
542
+ font-weight: var(--la-font-weight-medium);
543
+ color: var(--la-text);
544
+ }
545
+
546
+ .la-user-dropdown {
547
+ position: absolute;
548
+ top: calc(100% + 0.5rem);
549
+ right: 0;
550
+ min-width: 220px;
551
+ background: var(--la-bg);
552
+ border: 1px solid var(--la-border);
553
+ border-radius: var(--la-radius-lg);
554
+ box-shadow: var(--la-shadow-lg);
555
+ padding: 0.375rem;
556
+ z-index: 9999;
557
+ animation: la-dropdown-in 0.15s ease-out;
558
+ }
559
+
560
+ @keyframes la-dropdown-in {
561
+ from {
562
+ opacity: 0;
563
+ transform: translateY(-4px) scale(0.97);
564
+ }
565
+ to {
566
+ opacity: 1;
567
+ transform: translateY(0) scale(1);
568
+ }
569
+ }
570
+
571
+ .la-user-dropdown-header {
572
+ padding: 0.5rem 0.625rem;
573
+ border-bottom: 1px solid var(--la-border);
574
+ margin-bottom: 0.25rem;
575
+ }
576
+
577
+ .la-user-dropdown-email {
578
+ font-size: var(--la-font-size-sm);
579
+ color: var(--la-text-secondary);
580
+ overflow: hidden;
581
+ text-overflow: ellipsis;
582
+ white-space: nowrap;
583
+ }
584
+
585
+ .la-user-dropdown-name {
586
+ font-size: var(--la-font-size-sm);
587
+ font-weight: var(--la-font-weight-medium);
588
+ color: var(--la-text);
589
+ }
590
+
591
+ .la-dropdown-item {
592
+ display: flex;
593
+ align-items: center;
594
+ gap: 0.5rem;
595
+ width: 100%;
596
+ padding: 0.5rem 0.625rem;
597
+ font-family: var(--la-font-family);
598
+ font-size: var(--la-font-size-sm);
599
+ color: var(--la-text);
600
+ background: none;
601
+ border: none;
602
+ border-radius: var(--la-radius-sm);
603
+ cursor: pointer;
604
+ transition: background var(--la-transition);
605
+ text-align: left;
606
+ outline: none;
607
+ }
608
+
609
+ .la-dropdown-item:hover {
610
+ background: var(--la-bg-hover);
611
+ }
612
+
613
+ .la-dropdown-item-danger {
614
+ color: var(--la-danger);
615
+ }
616
+
617
+ .la-dropdown-item-danger:hover {
618
+ background: var(--la-danger-bg);
619
+ }
620
+
621
+ .la-dropdown-divider {
622
+ height: 1px;
623
+ background: var(--la-border);
624
+ margin: 0.25rem 0;
625
+ }
626
+
627
+ /* \u2500\u2500\u2500 Protect Loading \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
628
+
629
+ .la-protect-loading {
630
+ display: flex;
631
+ align-items: center;
632
+ justify-content: center;
633
+ padding: 1rem;
634
+ }
635
+
636
+ /* \u2500\u2500\u2500 Forgot Password Link \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
637
+
638
+ .la-forgot {
639
+ text-align: right;
640
+ margin-top: -0.5rem;
641
+ margin-bottom: 1rem;
642
+ }
643
+
644
+ .la-forgot a {
645
+ font-size: var(--la-font-size-sm);
646
+ color: var(--la-link);
647
+ text-decoration: none;
648
+ }
649
+
650
+ .la-forgot a:hover {
651
+ text-decoration: underline;
652
+ }
653
+
654
+ /* \u2500\u2500\u2500 UserAvatar (standalone) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
655
+
656
+ .la-avatar {
657
+ display: inline-flex;
658
+ align-items: center;
659
+ justify-content: center;
660
+ font-family: var(--la-font-family);
661
+ font-weight: var(--la-font-weight-semibold);
662
+ color: #fff;
663
+ background: var(--la-primary);
664
+ overflow: hidden;
665
+ flex-shrink: 0;
666
+ user-select: none;
667
+ line-height: 1;
668
+ }
669
+
670
+ .la-avatar img {
671
+ width: 100%;
672
+ height: 100%;
673
+ object-fit: cover;
674
+ }
675
+
676
+ .la-avatar-circle {
677
+ border-radius: var(--la-radius-full);
678
+ }
679
+
680
+ .la-avatar-square {
681
+ border-radius: var(--la-radius-md);
682
+ }
683
+
684
+ /* \u2500\u2500\u2500 UserProfile Card \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
685
+
686
+ .la-profile-card {
687
+ max-width: 420px;
688
+ }
689
+
690
+ .la-profile-header {
691
+ display: flex;
692
+ align-items: center;
693
+ gap: 1rem;
694
+ padding-bottom: 1.25rem;
695
+ border-bottom: 1px solid var(--la-border);
696
+ margin-bottom: 1rem;
697
+ }
698
+
699
+ .la-profile-avatar {
700
+ width: 56px;
701
+ height: 56px;
702
+ font-size: 1.25rem;
703
+ flex-shrink: 0;
704
+ }
705
+
706
+ .la-profile-avatar img {
707
+ width: 100%;
708
+ height: 100%;
709
+ object-fit: cover;
710
+ }
711
+
712
+ .la-profile-header-info {
713
+ min-width: 0;
714
+ }
715
+
716
+ .la-profile-name {
717
+ font-size: var(--la-font-size-lg);
718
+ font-weight: var(--la-font-weight-semibold);
719
+ color: var(--la-text-primary);
720
+ line-height: 1.3;
721
+ overflow: hidden;
722
+ text-overflow: ellipsis;
723
+ white-space: nowrap;
724
+ }
725
+
726
+ .la-profile-email {
727
+ font-size: var(--la-font-size-sm);
728
+ color: var(--la-text-secondary);
729
+ overflow: hidden;
730
+ text-overflow: ellipsis;
731
+ white-space: nowrap;
732
+ }
733
+
734
+ .la-profile-section {
735
+ margin-bottom: 1rem;
736
+ }
737
+
738
+ .la-profile-section-title {
739
+ font-size: var(--la-font-size-sm);
740
+ font-weight: var(--la-font-weight-semibold);
741
+ color: var(--la-text-secondary);
742
+ text-transform: uppercase;
743
+ letter-spacing: 0.05em;
744
+ margin-bottom: 0.625rem;
745
+ }
746
+
747
+ .la-profile-row {
748
+ display: flex;
749
+ align-items: center;
750
+ gap: 0.625rem;
751
+ padding: 0.5rem 0;
752
+ font-size: var(--la-font-size-base);
753
+ color: var(--la-text-primary);
754
+ }
755
+
756
+ .la-profile-row svg {
757
+ color: var(--la-text-secondary);
758
+ flex-shrink: 0;
759
+ }
760
+
761
+ .la-profile-row-label {
762
+ color: var(--la-text-secondary);
763
+ min-width: 3.5rem;
764
+ flex-shrink: 0;
765
+ }
766
+
767
+ .la-profile-row-value {
768
+ flex: 1;
769
+ min-width: 0;
770
+ overflow: hidden;
771
+ text-overflow: ellipsis;
772
+ white-space: nowrap;
773
+ }
774
+
775
+ .la-profile-badge {
776
+ display: inline-flex;
777
+ align-items: center;
778
+ gap: 0.25rem;
779
+ font-size: 0.75rem;
780
+ font-weight: var(--la-font-weight-medium);
781
+ padding: 0.125rem 0.5rem;
782
+ border-radius: var(--la-radius-full);
783
+ flex-shrink: 0;
784
+ }
785
+
786
+ .la-badge-success {
787
+ background: #dcfce7;
788
+ color: #166534;
789
+ }
790
+
791
+ .la-badge-warning {
792
+ background: #fef9c3;
793
+ color: #854d0e;
794
+ }
795
+
796
+ .la-badge-muted {
797
+ background: var(--la-bg-muted);
798
+ color: var(--la-text-secondary);
799
+ }
800
+
801
+ .la-dark .la-badge-success {
802
+ background: rgba(22, 163, 74, 0.15);
803
+ color: #4ade80;
804
+ }
805
+
806
+ .la-dark .la-badge-warning {
807
+ background: rgba(234, 179, 8, 0.15);
808
+ color: #facc15;
809
+ }
810
+
811
+ .la-dark .la-badge-muted {
812
+ background: rgba(255, 255, 255, 0.08);
813
+ color: var(--la-text-secondary);
814
+ }
815
+
816
+ .la-profile-tags {
817
+ display: flex;
818
+ flex-wrap: wrap;
819
+ gap: 0.375rem;
820
+ flex: 1;
821
+ }
822
+
823
+ .la-profile-tag {
824
+ display: inline-block;
825
+ font-size: 0.75rem;
826
+ font-weight: var(--la-font-weight-medium);
827
+ padding: 0.125rem 0.5rem;
828
+ border-radius: var(--la-radius-full);
829
+ background: var(--la-bg-muted);
830
+ color: var(--la-text-secondary);
831
+ border: 1px solid var(--la-border);
832
+ }
833
+
834
+ .la-profile-actions {
835
+ padding-top: 0.5rem;
836
+ border-top: 1px solid var(--la-border);
837
+ margin-top: 0.5rem;
838
+ }
839
+
840
+ .la-profile-signout-btn {
841
+ width: 100%;
842
+ display: flex;
843
+ align-items: center;
844
+ justify-content: center;
845
+ gap: 0.5rem;
846
+ }
847
+
848
+ .la-btn-outline {
849
+ background: transparent;
850
+ border: 1px solid var(--la-border);
851
+ color: var(--la-text-primary);
852
+ padding: 0.625rem 1rem;
853
+ border-radius: var(--la-radius-md);
854
+ font-size: var(--la-font-size-base);
855
+ font-weight: var(--la-font-weight-medium);
856
+ cursor: pointer;
857
+ transition: background var(--la-transition), border-color var(--la-transition);
858
+ }
859
+
860
+ .la-btn-outline:hover {
861
+ background: var(--la-bg-hover);
862
+ border-color: var(--la-text-secondary);
863
+ }
864
+
865
+ .la-btn-outline:disabled {
866
+ opacity: 0.5;
867
+ cursor: not-allowed;
868
+ }
869
+ `;
870
+
871
+ // src/provider.tsx
872
+ var import_jsx_runtime = require("react/jsx-runtime");
873
+ var LumoAuthContext = (0, import_react.createContext)(null);
874
+ LumoAuthContext.displayName = "LumoAuthContext";
875
+ function useLumoAuthContext() {
876
+ const ctx = (0, import_react.useContext)(LumoAuthContext);
877
+ if (!ctx) {
878
+ throw new Error(
879
+ 'useLumoAuthContext must be used within <LumoAuthProvider>. Wrap your application with <LumoAuthProvider domain="..." orgId="..." clientId="...">.'
880
+ );
881
+ }
882
+ return ctx;
883
+ }
884
+ var PKCE_VERIFIER_KEY = "lumoauth_pkce_verifier";
885
+ var PKCE_STATE_KEY = "lumoauth_pkce_state";
886
+ function savePkceParams(codeVerifier, state) {
887
+ try {
888
+ if (typeof window !== "undefined") {
889
+ sessionStorage.setItem(PKCE_VERIFIER_KEY, codeVerifier);
890
+ sessionStorage.setItem(PKCE_STATE_KEY, state);
891
+ }
892
+ } catch {
893
+ }
894
+ }
895
+ function loadPkceParams() {
896
+ try {
897
+ if (typeof window !== "undefined") {
898
+ return {
899
+ codeVerifier: sessionStorage.getItem(PKCE_VERIFIER_KEY),
900
+ state: sessionStorage.getItem(PKCE_STATE_KEY)
901
+ };
902
+ }
903
+ } catch {
904
+ }
905
+ return { codeVerifier: null, state: null };
906
+ }
907
+ function clearPkceParams() {
908
+ try {
909
+ if (typeof window !== "undefined") {
910
+ sessionStorage.removeItem(PKCE_VERIFIER_KEY);
911
+ sessionStorage.removeItem(PKCE_STATE_KEY);
912
+ }
913
+ } catch {
914
+ }
915
+ }
916
+ function parseUserFromUserInfo(data) {
917
+ const firstName = data.given_name || data.first_name || "";
918
+ const lastName = data.family_name || data.last_name || "";
919
+ const email = data.email || "";
920
+ const displayName = data.name || [firstName, lastName].filter(Boolean).join(" ") || email;
921
+ return {
922
+ id: data.sub || data.id || "",
923
+ email,
924
+ firstName: firstName || void 0,
925
+ lastName: lastName || void 0,
926
+ displayName,
927
+ avatarUrl: data.picture || void 0,
928
+ emailVerified: data.email_verified ?? false,
929
+ mfaEnabled: data.mfa_enabled ?? false,
930
+ roles: Array.isArray(data.roles) ? data.roles : [],
931
+ groups: Array.isArray(data.groups) ? data.groups : [],
932
+ sub: data.sub || void 0,
933
+ claims: data
934
+ };
935
+ }
936
+ function LumoAuthProvider({
937
+ domain,
938
+ orgId,
939
+ clientId,
940
+ authStrategy = "pkce",
941
+ redirectUri,
942
+ afterSignInUrl,
943
+ afterSignUpUrl,
944
+ afterSignOutUrl,
945
+ storage,
946
+ crossTab = true,
947
+ children
948
+ }) {
949
+ const [user, setUser] = (0, import_react.useState)(null);
950
+ const tokensRef = (0, import_react.useRef)({ accessToken: null, refreshToken: null, expiresAt: null, idToken: null });
951
+ const callbackHandledRef = (0, import_react.useRef)(false);
952
+ const callbackInflightRef = (0, import_react.useRef)(null);
953
+ (0, import_react.useEffect)(() => {
954
+ injectStyles();
955
+ }, []);
956
+ const authModule = (0, import_react.useMemo)(
957
+ () => new import_client2.AuthModule({
958
+ baseUrl: domain,
959
+ orgId,
960
+ clientId
961
+ }),
962
+ [domain, orgId, clientId]
963
+ );
964
+ const resolvedRedirectUri = (0, import_react.useMemo)(() => {
965
+ if (redirectUri) return redirectUri;
966
+ if (typeof window !== "undefined") {
967
+ return `${window.location.origin}/auth/callback`;
968
+ }
969
+ return "";
970
+ }, [redirectUri]);
971
+ const session = (0, import_react.useMemo)(
972
+ () => new import_client.LumoAuthSession({
973
+ auth: authModule,
974
+ redirectUri: resolvedRedirectUri,
975
+ storage,
976
+ crossTab,
977
+ // Mirror the store's tokens into the ref the flow code below
978
+ // still reads, so signOut can build id_token_hint and the
979
+ // callback path can inspect what was persisted.
980
+ onTokens: (t) => {
981
+ tokensRef.current = {
982
+ accessToken: t.accessToken,
983
+ refreshToken: t.refreshToken,
984
+ idToken: t.idToken,
985
+ expiresAt: t.expiresAt
986
+ };
987
+ }
988
+ }),
989
+ [authModule, resolvedRedirectUri, storage, crossTab]
990
+ );
991
+ (0, import_react.useEffect)(() => () => session.dispose(), [session]);
992
+ const sessionState = (0, import_react.useSyncExternalStore)(
993
+ session.subscribe,
994
+ session.getSnapshot,
995
+ session.getServerSnapshot
996
+ );
997
+ const state = (0, import_react.useMemo)(
998
+ () => ({
999
+ status: sessionState.status,
1000
+ user: sessionState.isSignedIn ? user : null,
1001
+ isLoaded: sessionState.isLoaded,
1002
+ isSignedIn: sessionState.isSignedIn
1003
+ }),
1004
+ [sessionState, user]
1005
+ );
1006
+ const dispatch = (0, import_react.useCallback)(
1007
+ (action) => {
1008
+ if (action.type === "AUTHENTICATED") setUser(action.user);
1009
+ else if (action.type === "UNAUTHENTICATED" || action.type === "ERROR") setUser(null);
1010
+ },
1011
+ []
1012
+ );
1013
+ const fetchUser = (0, import_react.useCallback)(async (accessToken) => {
1014
+ const data = await authModule.getUserInfo(accessToken);
1015
+ return parseUserFromUserInfo(data);
1016
+ }, [authModule]);
1017
+ const refreshAccessToken = (0, import_react.useCallback)(
1018
+ () => session.refresh(),
1019
+ [session]
1020
+ );
1021
+ const getToken = (0, import_react.useCallback)(
1022
+ () => session.getToken(),
1023
+ [session]
1024
+ );
1025
+ const signInWithRedirect = (0, import_react.useCallback)(() => {
1026
+ authModule.buildAuthorizationUrl({
1027
+ redirectUri: resolvedRedirectUri,
1028
+ scope: "openid profile email"
1029
+ }).then(({ url, codeVerifier, state: stateParam }) => {
1030
+ savePkceParams(codeVerifier, stateParam);
1031
+ if (typeof window !== "undefined") {
1032
+ window.location.href = url;
1033
+ }
1034
+ });
1035
+ }, [authModule, resolvedRedirectUri]);
1036
+ const signInWithSocial = (0, import_react.useCallback)((provider) => {
1037
+ authModule.buildAuthorizationUrl({
1038
+ redirectUri: resolvedRedirectUri,
1039
+ scope: "openid profile email",
1040
+ extraParams: { provider }
1041
+ }).then(({ url, codeVerifier, state: stateParam }) => {
1042
+ savePkceParams(codeVerifier, stateParam);
1043
+ if (typeof window !== "undefined") {
1044
+ window.location.href = url;
1045
+ }
1046
+ });
1047
+ }, [authModule, resolvedRedirectUri]);
1048
+ const signIn = (0, import_react.useCallback)(async (email, password) => {
1049
+ if (authStrategy === "pkce" || !email && !password) {
1050
+ signInWithRedirect();
1051
+ return;
1052
+ }
1053
+ if (!email || !password) {
1054
+ throw new Error("Email and password are required for password-based sign-in");
1055
+ }
1056
+ dispatch({ type: "LOADING" });
1057
+ try {
1058
+ const data = await authModule.passwordGrant(
1059
+ email,
1060
+ password,
1061
+ "openid profile email",
1062
+ redirectUri
1063
+ );
1064
+ await session.adopt(data);
1065
+ const user2 = await fetchUser(data.access_token);
1066
+ dispatch({ type: "AUTHENTICATED", user: user2 });
1067
+ } catch (err) {
1068
+ dispatch({ type: "ERROR", error: err instanceof Error ? err.message : "Sign in failed" });
1069
+ throw err;
1070
+ }
1071
+ }, [authStrategy, authModule, redirectUri, fetchUser, session, signInWithRedirect, dispatch]);
1072
+ const handleCallback = (0, import_react.useCallback)(async () => {
1073
+ if (typeof window === "undefined") return;
1074
+ const params = new URLSearchParams(window.location.search);
1075
+ const code = params.get("code");
1076
+ if (code && callbackInflightRef.current?.code === code) {
1077
+ return callbackInflightRef.current.promise;
1078
+ }
1079
+ const promise = (async () => {
1080
+ const returnedState = params.get("state");
1081
+ const error = params.get("error");
1082
+ const errorDescription = params.get("error_description");
1083
+ if (error) {
1084
+ dispatch({ type: "ERROR", error: errorDescription || error });
1085
+ throw new Error(errorDescription || error);
1086
+ }
1087
+ if (!code) {
1088
+ dispatch({ type: "ERROR", error: "No authorization code found in callback URL" });
1089
+ throw new Error("No authorization code found in callback URL");
1090
+ }
1091
+ const { codeVerifier, state: savedState } = loadPkceParams();
1092
+ if (!savedState || savedState !== returnedState) {
1093
+ clearPkceParams();
1094
+ dispatch({ type: "ERROR", error: "Invalid state parameter \u2014 possible CSRF attack" });
1095
+ throw new Error("Invalid state parameter \u2014 possible CSRF attack");
1096
+ }
1097
+ if (!codeVerifier) {
1098
+ clearPkceParams();
1099
+ dispatch({ type: "ERROR", error: "No PKCE code verifier found" });
1100
+ throw new Error("No PKCE code verifier found");
1101
+ }
1102
+ dispatch({ type: "LOADING" });
1103
+ try {
1104
+ const data = await authModule.exchangeCodeForTokens({
1105
+ code,
1106
+ codeVerifier,
1107
+ redirectUri: resolvedRedirectUri
1108
+ });
1109
+ clearPkceParams();
1110
+ await session.adopt(data);
1111
+ const user2 = await fetchUser(data.access_token);
1112
+ dispatch({ type: "AUTHENTICATED", user: user2 });
1113
+ } catch (err) {
1114
+ clearPkceParams();
1115
+ dispatch({ type: "ERROR", error: err instanceof Error ? err.message : "Token exchange failed" });
1116
+ throw err;
1117
+ }
1118
+ })();
1119
+ if (code) {
1120
+ callbackInflightRef.current = { code, promise };
1121
+ promise.catch(() => {
1122
+ if (callbackInflightRef.current?.promise === promise) {
1123
+ callbackInflightRef.current = null;
1124
+ }
1125
+ });
1126
+ }
1127
+ return promise;
1128
+ }, [authModule, resolvedRedirectUri, fetchUser, session, dispatch]);
1129
+ const signUp = (0, import_react.useCallback)(async (_params) => {
1130
+ if (authStrategy === "pkce") {
1131
+ const safeOrgId = encodeURIComponent(orgId);
1132
+ const signUpUrl = `${domain.replace(/\/+$/, "")}/orgs/${safeOrgId}/register?` + new URLSearchParams({
1133
+ client_id: clientId,
1134
+ redirect_uri: resolvedRedirectUri,
1135
+ response_type: "code",
1136
+ scope: "openid profile email"
1137
+ }).toString();
1138
+ if (typeof window !== "undefined") {
1139
+ window.location.href = signUpUrl;
1140
+ }
1141
+ return;
1142
+ }
1143
+ dispatch({
1144
+ type: "ERROR",
1145
+ error: "inline_registration_unsupported"
1146
+ });
1147
+ throw new Error(
1148
+ `Inline registration is not supported by this LumoAuth server: there is no JSON registration endpoint. Use redirectToSignUp() to send the user to the hosted registration page (${domain.replace(/\/+$/, "")}/orgs/${encodeURIComponent(orgId)}/register), or set authStrategy: "pkce".`
1149
+ );
1150
+ }, [authStrategy, domain, orgId, clientId, resolvedRedirectUri, signIn]);
1151
+ const sendMagicLink = (0, import_react.useCallback)(async (email, redirectUri2) => {
1152
+ await authModule.requestMagicLink({ email, redirectUri: redirectUri2 });
1153
+ }, [authModule]);
1154
+ const checkEmail = (0, import_react.useCallback)(
1155
+ (email) => authModule.checkEmailExists(email),
1156
+ [authModule]
1157
+ );
1158
+ const signOut = (0, import_react.useCallback)(async (options) => {
1159
+ const { accessToken, idToken } = tokensRef.current;
1160
+ if (typeof window === "undefined") {
1161
+ if (accessToken) {
1162
+ authModule.revokeToken(accessToken, accessToken).catch(() => {
1163
+ });
1164
+ }
1165
+ tokensRef.current = { accessToken: null, refreshToken: null, expiresAt: null, idToken: null };
1166
+ await session.clearSession();
1167
+ dispatch({ type: "UNAUTHENTICATED" });
1168
+ return;
1169
+ }
1170
+ const targetUrl = options?.afterSignOutUrl || afterSignOutUrl || "/";
1171
+ const postLogoutRedirectUri = new URL(targetUrl, window.location.origin).toString();
1172
+ const safeOrgId = encodeURIComponent(orgId);
1173
+ const params = new URLSearchParams({
1174
+ post_logout_redirect_uri: postLogoutRedirectUri
1175
+ });
1176
+ if (idToken) {
1177
+ params.set("id_token_hint", idToken);
1178
+ }
1179
+ const logoutUrl = `${domain.replace(/\/+$/, "")}/orgs/${safeOrgId}/api/v1/oauth/logout?${params.toString()}`;
1180
+ if (accessToken) {
1181
+ authModule.revokeToken(accessToken, accessToken).catch(() => {
1182
+ });
1183
+ }
1184
+ tokensRef.current = { accessToken: null, refreshToken: null, expiresAt: null, idToken: null };
1185
+ await session.clearSession(null, { emit: false });
1186
+ window.location.replace(logoutUrl);
1187
+ await new Promise(() => {
1188
+ });
1189
+ }, [authModule, domain, orgId, afterSignOutUrl, session, dispatch]);
1190
+ (0, import_react.useEffect)(() => {
1191
+ let cancelled = false;
1192
+ async function init() {
1193
+ if (typeof window === "undefined") return;
1194
+ const params = new URLSearchParams(window.location.search);
1195
+ const code = params.get("code");
1196
+ const returnedState = params.get("state");
1197
+ if (code && returnedState) {
1198
+ if (callbackHandledRef.current) return;
1199
+ callbackHandledRef.current = true;
1200
+ try {
1201
+ await handleCallback();
1202
+ if (cancelled) return;
1203
+ params.delete("code");
1204
+ params.delete("state");
1205
+ params.delete("iss");
1206
+ const cleanUrl = params.toString() ? `${window.location.pathname}?${params}` : window.location.pathname;
1207
+ window.history.replaceState({}, "", cleanUrl);
1208
+ return;
1209
+ } catch {
1210
+ callbackHandledRef.current = false;
1211
+ if (!cancelled) dispatch({ type: "UNAUTHENTICATED" });
1212
+ return;
1213
+ }
1214
+ }
1215
+ }
1216
+ init().then(() => {
1217
+ if (!cancelled) void session.hydrate();
1218
+ });
1219
+ return () => {
1220
+ cancelled = true;
1221
+ };
1222
+ }, [fetchUser, handleCallback, refreshAccessToken, session]);
1223
+ (0, import_react.useEffect)(() => {
1224
+ let cancelled = false;
1225
+ if (!sessionState.isSignedIn) {
1226
+ setUser(null);
1227
+ return;
1228
+ }
1229
+ if (user) return;
1230
+ void (async () => {
1231
+ const token = await session.getToken().catch(() => null);
1232
+ if (cancelled || !token) return;
1233
+ try {
1234
+ const fetched = await fetchUser(token);
1235
+ if (!cancelled) setUser(fetched);
1236
+ } catch {
1237
+ }
1238
+ })();
1239
+ return () => {
1240
+ cancelled = true;
1241
+ };
1242
+ }, [sessionState.isSignedIn, user, session, fetchUser]);
1243
+ const contextValue = (0, import_react.useMemo)(() => ({
1244
+ ...state,
1245
+ signIn,
1246
+ signInWithRedirect,
1247
+ signInWithSocial,
1248
+ signUp,
1249
+ signOut,
1250
+ getToken,
1251
+ handleCallback,
1252
+ sendMagicLink,
1253
+ checkEmail,
1254
+ authStrategy,
1255
+ config: {
1256
+ domain,
1257
+ orgId,
1258
+ clientId,
1259
+ redirectUri: resolvedRedirectUri,
1260
+ afterSignInUrl,
1261
+ afterSignUpUrl,
1262
+ afterSignOutUrl
1263
+ }
1264
+ }), [state, signIn, signInWithRedirect, signInWithSocial, signUp, signOut, getToken, handleCallback, sendMagicLink, checkEmail, authStrategy, domain, orgId, clientId, resolvedRedirectUri, afterSignInUrl, afterSignUpUrl, afterSignOutUrl]);
1265
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LumoAuthContext.Provider, { value: contextValue, children });
1266
+ }
1267
+
1268
+ // src/components/SignIn.tsx
1269
+ var import_react2 = require("react");
1270
+
1271
+ // src/utils/url.ts
1272
+ function sanitizeRedirectUrl(url, defaultUrl = "/") {
1273
+ if (!url || typeof url !== "string") {
1274
+ return defaultUrl;
1275
+ }
1276
+ let sanitizedUrl = url.trim().replace(/[\x00-\x1F\x7F]/g, "");
1277
+ try {
1278
+ const parsedUrl = new URL(sanitizedUrl, typeof window !== "undefined" ? window.location.origin : "http://localhost");
1279
+ if (sanitizedUrl.startsWith("/") && !sanitizedUrl.startsWith("//")) {
1280
+ return sanitizedUrl;
1281
+ }
1282
+ const dangerousSchemes = ["javascript:", "data:", "vbscript:", "file:"];
1283
+ if (dangerousSchemes.includes(parsedUrl.protocol.toLowerCase())) {
1284
+ return defaultUrl;
1285
+ }
1286
+ if (typeof window !== "undefined" && parsedUrl.origin !== window.location.origin) {
1287
+ return defaultUrl;
1288
+ }
1289
+ return parsedUrl.href;
1290
+ } catch {
1291
+ return defaultUrl;
1292
+ }
1293
+ }
1294
+
1295
+ // src/components/SignIn.tsx
1296
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1297
+ var SOCIAL_ICONS = {
1298
+ google: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { className: "la-social-icon", viewBox: "0 0 24 24", fill: "none", children: [
1299
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z", fill: "#4285F4" }),
1300
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z", fill: "#34A853" }),
1301
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z", fill: "#FBBC05" }),
1302
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z", fill: "#EA4335" })
1303
+ ] }),
1304
+ github: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { className: "la-social-icon", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" }) }),
1305
+ microsoft: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { className: "la-social-icon", viewBox: "0 0 24 24", fill: "none", children: [
1306
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "1", y: "1", width: "10", height: "10", fill: "#F25022" }),
1307
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "13", y: "1", width: "10", height: "10", fill: "#7FBA00" }),
1308
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "1", y: "13", width: "10", height: "10", fill: "#00A4EF" }),
1309
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "13", y: "13", width: "10", height: "10", fill: "#FFB900" })
1310
+ ] }),
1311
+ apple: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { className: "la-social-icon", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.48-3.24 0-1.44.62-2.2.44-3.06-.4C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z" }) })
1312
+ };
1313
+ function getSocialLabel(provider) {
1314
+ const names = {
1315
+ google: "Google",
1316
+ github: "GitHub",
1317
+ microsoft: "Microsoft",
1318
+ apple: "Apple",
1319
+ facebook: "Facebook",
1320
+ linkedin: "LinkedIn",
1321
+ twitter: "X (Twitter)",
1322
+ gitlab: "GitLab"
1323
+ };
1324
+ return names[provider] || provider.charAt(0).toUpperCase() + provider.slice(1);
1325
+ }
1326
+ function SignIn({
1327
+ afterSignInUrl,
1328
+ signUpUrl,
1329
+ appearance,
1330
+ socialProviders = []
1331
+ }) {
1332
+ const { signIn, signInWithSocial, config, status, authStrategy } = useLumoAuthContext();
1333
+ const resolvedAfterSignInUrl = afterSignInUrl || config.afterSignInUrl || "/";
1334
+ const resolvedSignUpUrl = signUpUrl || config.afterSignUpUrl || "/sign-up";
1335
+ const themeClass = appearance?.theme === "dark" ? "la-dark" : appearance?.theme === "light" ? "la-light" : "";
1336
+ if (status === "authenticated") {
1337
+ return null;
1338
+ }
1339
+ if (authStrategy === "pkce") {
1340
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1341
+ SignInPkce,
1342
+ {
1343
+ signIn,
1344
+ signInWithSocial,
1345
+ socialProviders,
1346
+ resolvedSignUpUrl,
1347
+ themeClass,
1348
+ appearance
1349
+ }
1350
+ );
1351
+ }
1352
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1353
+ SignInPassword,
1354
+ {
1355
+ signIn,
1356
+ signInWithSocial,
1357
+ socialProviders,
1358
+ config,
1359
+ resolvedAfterSignInUrl,
1360
+ resolvedSignUpUrl,
1361
+ themeClass,
1362
+ appearance
1363
+ }
1364
+ );
1365
+ }
1366
+ function SignInPkce({
1367
+ signIn,
1368
+ signInWithSocial,
1369
+ socialProviders,
1370
+ resolvedSignUpUrl,
1371
+ themeClass,
1372
+ appearance
1373
+ }) {
1374
+ const handleSocialLogin = (0, import_react2.useCallback)((provider) => {
1375
+ signInWithSocial(provider);
1376
+ }, [signInWithSocial]);
1377
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1378
+ "div",
1379
+ {
1380
+ className: `la-card ${themeClass} ${appearance?.className || ""}`,
1381
+ style: appearance?.variables,
1382
+ children: [
1383
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "la-card-header", children: [
1384
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { className: "la-card-title", children: "Sign in" }),
1385
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "la-card-subtitle", children: "Welcome back! Please sign in to continue." })
1386
+ ] }),
1387
+ socialProviders.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "la-social-buttons", children: socialProviders.map((provider) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1388
+ "button",
1389
+ {
1390
+ type: "button",
1391
+ className: "la-social-btn",
1392
+ onClick: () => handleSocialLogin(provider),
1393
+ children: [
1394
+ SOCIAL_ICONS[provider] || null,
1395
+ "Continue with ",
1396
+ getSocialLabel(provider)
1397
+ ]
1398
+ },
1399
+ provider
1400
+ )) }),
1401
+ socialProviders.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "la-divider", children: "or" }),
1402
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1403
+ "button",
1404
+ {
1405
+ type: "button",
1406
+ className: "la-btn la-btn-primary",
1407
+ onClick: () => signIn(),
1408
+ children: "Sign in with email"
1409
+ }
1410
+ ),
1411
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "la-footer", children: [
1412
+ "Don't have an account?",
1413
+ " ",
1414
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { href: resolvedSignUpUrl, children: "Sign up" })
1415
+ ] })
1416
+ ]
1417
+ }
1418
+ );
1419
+ }
1420
+ function SignInPassword({
1421
+ signIn,
1422
+ signInWithSocial,
1423
+ socialProviders,
1424
+ config,
1425
+ resolvedAfterSignInUrl,
1426
+ resolvedSignUpUrl,
1427
+ themeClass,
1428
+ appearance
1429
+ }) {
1430
+ const [email, setEmail] = (0, import_react2.useState)("");
1431
+ const [password, setPassword] = (0, import_react2.useState)("");
1432
+ const [error, setError] = (0, import_react2.useState)(null);
1433
+ const [loading, setLoading] = (0, import_react2.useState)(false);
1434
+ const handleSubmit = (0, import_react2.useCallback)(async (e) => {
1435
+ e.preventDefault();
1436
+ setError(null);
1437
+ setLoading(true);
1438
+ try {
1439
+ await signIn(email, password);
1440
+ if (typeof window !== "undefined") {
1441
+ window.location.href = sanitizeRedirectUrl(resolvedAfterSignInUrl);
1442
+ }
1443
+ } catch (err) {
1444
+ setError(err instanceof Error ? err.message : "Sign in failed. Please try again.");
1445
+ } finally {
1446
+ setLoading(false);
1447
+ }
1448
+ }, [signIn, email, password, resolvedAfterSignInUrl]);
1449
+ const handleSocialLogin = (0, import_react2.useCallback)((provider) => {
1450
+ signInWithSocial(provider);
1451
+ }, [signInWithSocial]);
1452
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1453
+ "div",
1454
+ {
1455
+ className: `la-card ${themeClass} ${appearance?.className || ""}`,
1456
+ style: appearance?.variables,
1457
+ children: [
1458
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "la-card-header", children: [
1459
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { className: "la-card-title", children: "Sign in" }),
1460
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "la-card-subtitle", children: "Welcome back! Please sign in to continue." })
1461
+ ] }),
1462
+ socialProviders.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "la-social-buttons", children: socialProviders.map((provider) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1463
+ "button",
1464
+ {
1465
+ type: "button",
1466
+ className: "la-social-btn",
1467
+ onClick: () => handleSocialLogin(provider),
1468
+ disabled: loading,
1469
+ children: [
1470
+ SOCIAL_ICONS[provider] || null,
1471
+ "Continue with ",
1472
+ getSocialLabel(provider)
1473
+ ]
1474
+ },
1475
+ provider
1476
+ )) }),
1477
+ socialProviders.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "la-divider", children: "or" }),
1478
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("form", { onSubmit: handleSubmit, children: [
1479
+ error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "la-alert la-alert-error", role: "alert", children: error }),
1480
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "la-form-group", children: [
1481
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { className: "la-label", htmlFor: "la-signin-email", children: "Email address" }),
1482
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1483
+ "input",
1484
+ {
1485
+ id: "la-signin-email",
1486
+ className: "la-input",
1487
+ type: "email",
1488
+ placeholder: "name@example.com",
1489
+ value: email,
1490
+ onChange: (e) => setEmail(e.target.value),
1491
+ required: true,
1492
+ autoComplete: "email",
1493
+ disabled: loading
1494
+ }
1495
+ )
1496
+ ] }),
1497
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "la-form-group", children: [
1498
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { className: "la-label", htmlFor: "la-signin-password", children: "Password" }),
1499
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1500
+ "input",
1501
+ {
1502
+ id: "la-signin-password",
1503
+ className: "la-input",
1504
+ type: "password",
1505
+ placeholder: "Enter your password",
1506
+ value: password,
1507
+ onChange: (e) => setPassword(e.target.value),
1508
+ required: true,
1509
+ autoComplete: "current-password",
1510
+ disabled: loading
1511
+ }
1512
+ )
1513
+ ] }),
1514
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "la-forgot", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { href: `${config.domain}/account/forgot-password`, children: "Forgot password?" }) }),
1515
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1516
+ "button",
1517
+ {
1518
+ type: "submit",
1519
+ className: "la-btn la-btn-primary",
1520
+ disabled: loading || !email || !password,
1521
+ children: [
1522
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "la-spinner la-spinner-sm" }) : null,
1523
+ loading ? "Signing in\u2026" : "Sign in"
1524
+ ]
1525
+ }
1526
+ )
1527
+ ] }),
1528
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "la-footer", children: [
1529
+ "Don't have an account?",
1530
+ " ",
1531
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { href: resolvedSignUpUrl, children: "Sign up" })
1532
+ ] })
1533
+ ]
1534
+ }
1535
+ );
1536
+ }
1537
+
1538
+ // src/components/SignUp.tsx
1539
+ var import_react3 = require("react");
1540
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1541
+ function getPasswordStrength(password) {
1542
+ if (!password) return { score: 0, label: "" };
1543
+ let score = 0;
1544
+ if (password.length >= 8) score++;
1545
+ if (password.length >= 12) score++;
1546
+ if (/[A-Z]/.test(password) && /[a-z]/.test(password)) score++;
1547
+ if (/\d/.test(password)) score++;
1548
+ if (/[^A-Za-z0-9]/.test(password)) score++;
1549
+ const capped = Math.min(score, 4);
1550
+ const labels = ["", "Weak", "Fair", "Good", "Strong"];
1551
+ return { score: capped, label: labels[capped] };
1552
+ }
1553
+ function SignUp({
1554
+ afterSignUpUrl,
1555
+ signInUrl,
1556
+ appearance
1557
+ }) {
1558
+ const { signUp, config, status, authStrategy } = useLumoAuthContext();
1559
+ const resolvedSignInUrl = signInUrl || "/sign-in";
1560
+ const themeClass = appearance?.theme === "dark" ? "la-dark" : appearance?.theme === "light" ? "la-light" : "";
1561
+ if (status === "authenticated") {
1562
+ return null;
1563
+ }
1564
+ if (authStrategy === "pkce") {
1565
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1566
+ "div",
1567
+ {
1568
+ className: `la-card ${themeClass} ${appearance?.className || ""}`,
1569
+ style: appearance?.variables,
1570
+ children: [
1571
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "la-card-header", children: [
1572
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { className: "la-card-title", children: "Create your account" }),
1573
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "la-card-subtitle", children: "Get started \u2014 it only takes a minute." })
1574
+ ] }),
1575
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1576
+ "button",
1577
+ {
1578
+ type: "button",
1579
+ className: "la-btn la-btn-primary",
1580
+ onClick: () => signUp({ email: "", password: "" }),
1581
+ children: "Create account"
1582
+ }
1583
+ ),
1584
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "la-footer", children: [
1585
+ "Already have an account?",
1586
+ " ",
1587
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { href: resolvedSignInUrl, children: "Sign in" })
1588
+ ] })
1589
+ ]
1590
+ }
1591
+ );
1592
+ }
1593
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1594
+ SignUpPasswordForm,
1595
+ {
1596
+ signUp,
1597
+ resolvedAfterSignUpUrl: afterSignUpUrl || config.afterSignUpUrl || "/",
1598
+ resolvedSignInUrl,
1599
+ themeClass,
1600
+ appearance
1601
+ }
1602
+ );
1603
+ }
1604
+ function SignUpPasswordForm({
1605
+ signUp,
1606
+ resolvedAfterSignUpUrl,
1607
+ resolvedSignInUrl,
1608
+ themeClass,
1609
+ appearance
1610
+ }) {
1611
+ const [firstName, setFirstName] = (0, import_react3.useState)("");
1612
+ const [lastName, setLastName] = (0, import_react3.useState)("");
1613
+ const [email, setEmail] = (0, import_react3.useState)("");
1614
+ const [password, setPassword] = (0, import_react3.useState)("");
1615
+ const [error, setError] = (0, import_react3.useState)(null);
1616
+ const [loading, setLoading] = (0, import_react3.useState)(false);
1617
+ const passwordStrength = (0, import_react3.useMemo)(() => getPasswordStrength(password), [password]);
1618
+ const handleSubmit = (0, import_react3.useCallback)(async (e) => {
1619
+ e.preventDefault();
1620
+ setError(null);
1621
+ setLoading(true);
1622
+ try {
1623
+ await signUp({
1624
+ email,
1625
+ password,
1626
+ firstName: firstName || void 0,
1627
+ lastName: lastName || void 0
1628
+ });
1629
+ if (typeof window !== "undefined") {
1630
+ window.location.href = sanitizeRedirectUrl(resolvedAfterSignUpUrl);
1631
+ }
1632
+ } catch (err) {
1633
+ setError(err instanceof Error ? err.message : "Registration failed. Please try again.");
1634
+ } finally {
1635
+ setLoading(false);
1636
+ }
1637
+ }, [signUp, email, password, firstName, lastName, resolvedAfterSignUpUrl]);
1638
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1639
+ "div",
1640
+ {
1641
+ className: `la-card ${themeClass} ${appearance?.className || ""}`,
1642
+ style: appearance?.variables,
1643
+ children: [
1644
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "la-card-header", children: [
1645
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { className: "la-card-title", children: "Create your account" }),
1646
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "la-card-subtitle", children: "Get started \u2014 it only takes a minute." })
1647
+ ] }),
1648
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("form", { onSubmit: handleSubmit, children: [
1649
+ error && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "la-alert la-alert-error", role: "alert", children: error }),
1650
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", gap: "0.75rem" }, children: [
1651
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "la-form-group", style: { flex: 1 }, children: [
1652
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { className: "la-label", htmlFor: "la-signup-firstname", children: "First name" }),
1653
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1654
+ "input",
1655
+ {
1656
+ id: "la-signup-firstname",
1657
+ className: "la-input",
1658
+ type: "text",
1659
+ placeholder: "Jane",
1660
+ value: firstName,
1661
+ onChange: (e) => setFirstName(e.target.value),
1662
+ autoComplete: "given-name",
1663
+ disabled: loading
1664
+ }
1665
+ )
1666
+ ] }),
1667
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "la-form-group", style: { flex: 1 }, children: [
1668
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { className: "la-label", htmlFor: "la-signup-lastname", children: "Last name" }),
1669
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1670
+ "input",
1671
+ {
1672
+ id: "la-signup-lastname",
1673
+ className: "la-input",
1674
+ type: "text",
1675
+ placeholder: "Doe",
1676
+ value: lastName,
1677
+ onChange: (e) => setLastName(e.target.value),
1678
+ autoComplete: "family-name",
1679
+ disabled: loading
1680
+ }
1681
+ )
1682
+ ] })
1683
+ ] }),
1684
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "la-form-group", children: [
1685
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { className: "la-label", htmlFor: "la-signup-email", children: "Email address" }),
1686
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1687
+ "input",
1688
+ {
1689
+ id: "la-signup-email",
1690
+ className: "la-input",
1691
+ type: "email",
1692
+ placeholder: "name@example.com",
1693
+ value: email,
1694
+ onChange: (e) => setEmail(e.target.value),
1695
+ required: true,
1696
+ autoComplete: "email",
1697
+ disabled: loading
1698
+ }
1699
+ )
1700
+ ] }),
1701
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "la-form-group", children: [
1702
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { className: "la-label", htmlFor: "la-signup-password", children: "Password" }),
1703
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1704
+ "input",
1705
+ {
1706
+ id: "la-signup-password",
1707
+ className: "la-input",
1708
+ type: "password",
1709
+ placeholder: "Create a strong password",
1710
+ value: password,
1711
+ onChange: (e) => setPassword(e.target.value),
1712
+ required: true,
1713
+ minLength: 8,
1714
+ autoComplete: "new-password",
1715
+ disabled: loading
1716
+ }
1717
+ ),
1718
+ password && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "la-password-strength", children: [
1719
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "la-password-bar", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1720
+ "div",
1721
+ {
1722
+ className: "la-password-fill",
1723
+ "data-strength": passwordStrength.score
1724
+ }
1725
+ ) }),
1726
+ passwordStrength.label && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "la-password-label", children: passwordStrength.label })
1727
+ ] })
1728
+ ] }),
1729
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1730
+ "button",
1731
+ {
1732
+ type: "submit",
1733
+ className: "la-btn la-btn-primary",
1734
+ disabled: loading || !email || !password,
1735
+ style: { marginTop: "0.5rem" },
1736
+ children: [
1737
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "la-spinner la-spinner-sm" }) : null,
1738
+ loading ? "Creating account\u2026" : "Create account"
1739
+ ]
1740
+ }
1741
+ )
1742
+ ] }),
1743
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "la-footer", children: [
1744
+ "Already have an account?",
1745
+ " ",
1746
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { href: resolvedSignInUrl, children: "Sign in" })
1747
+ ] })
1748
+ ]
1749
+ }
1750
+ );
1751
+ }
1752
+
1753
+ // src/components/AuthCallback.tsx
1754
+ var import_react4 = require("react");
1755
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1756
+ function AuthCallback({
1757
+ afterSignInUrl,
1758
+ loading,
1759
+ error: errorComponent
1760
+ }) {
1761
+ const { handleCallback, config } = useLumoAuthContext();
1762
+ const [error, setError] = (0, import_react4.useState)(null);
1763
+ const resolvedAfterSignInUrl = afterSignInUrl || config.afterSignInUrl || "/";
1764
+ (0, import_react4.useEffect)(() => {
1765
+ let cancelled = false;
1766
+ handleCallback().then(() => {
1767
+ if (!cancelled && typeof window !== "undefined") {
1768
+ window.location.href = sanitizeRedirectUrl(resolvedAfterSignInUrl);
1769
+ }
1770
+ }).catch((err) => {
1771
+ if (!cancelled) {
1772
+ setError(err instanceof Error ? err.message : "Authentication failed");
1773
+ }
1774
+ });
1775
+ return () => {
1776
+ cancelled = true;
1777
+ };
1778
+ }, [handleCallback, resolvedAfterSignInUrl]);
1779
+ if (error) {
1780
+ if (errorComponent) {
1781
+ return typeof errorComponent === "function" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: errorComponent(error) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: errorComponent });
1782
+ }
1783
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "la-card", children: [
1784
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "la-card-header", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { className: "la-card-title", children: "Authentication Error" }) }),
1785
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "la-alert la-alert-error", role: "alert", children: error }),
1786
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1787
+ "button",
1788
+ {
1789
+ type: "button",
1790
+ className: "la-btn la-btn-primary",
1791
+ onClick: () => {
1792
+ if (typeof window !== "undefined") {
1793
+ window.location.href = "/";
1794
+ }
1795
+ },
1796
+ children: "Return home"
1797
+ }
1798
+ )
1799
+ ] });
1800
+ }
1801
+ if (loading) {
1802
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: loading });
1803
+ }
1804
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "la-card", style: { textAlign: "center" }, children: [
1805
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "la-spinner" }),
1806
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { marginTop: "1rem", color: "var(--la-text-secondary)" }, children: "Completing sign-in\u2026" })
1807
+ ] });
1808
+ }
1809
+
1810
+ // src/components/UserButton.tsx
1811
+ var import_react5 = require("react");
1812
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1813
+ function UserButton({
1814
+ afterSignOutUrl,
1815
+ showName = false,
1816
+ appearance
1817
+ }) {
1818
+ const { user, isSignedIn, signOut, config } = useLumoAuthContext();
1819
+ const [isOpen, setIsOpen] = (0, import_react5.useState)(false);
1820
+ const containerRef = (0, import_react5.useRef)(null);
1821
+ const resolvedSignOutUrl = afterSignOutUrl || config.afterSignOutUrl || "/";
1822
+ (0, import_react5.useEffect)(() => {
1823
+ function handleClickOutside(e) {
1824
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
1825
+ setIsOpen(false);
1826
+ }
1827
+ }
1828
+ if (isOpen) {
1829
+ document.addEventListener("mousedown", handleClickOutside);
1830
+ return () => document.removeEventListener("mousedown", handleClickOutside);
1831
+ }
1832
+ }, [isOpen]);
1833
+ (0, import_react5.useEffect)(() => {
1834
+ function handleEscape(e) {
1835
+ if (e.key === "Escape") setIsOpen(false);
1836
+ }
1837
+ if (isOpen) {
1838
+ document.addEventListener("keydown", handleEscape);
1839
+ return () => document.removeEventListener("keydown", handleEscape);
1840
+ }
1841
+ }, [isOpen]);
1842
+ const handleSignOut = (0, import_react5.useCallback)(async () => {
1843
+ setIsOpen(false);
1844
+ await signOut({ afterSignOutUrl: sanitizeRedirectUrl(resolvedSignOutUrl) });
1845
+ }, [signOut, resolvedSignOutUrl]);
1846
+ if (!isSignedIn || !user) {
1847
+ return null;
1848
+ }
1849
+ const initials = [user.firstName, user.lastName].filter(Boolean).map((n) => n.charAt(0).toUpperCase()).join("") || user.email.charAt(0).toUpperCase();
1850
+ const themeClass = appearance?.theme === "dark" ? "la-dark" : appearance?.theme === "light" ? "la-light" : "";
1851
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1852
+ "div",
1853
+ {
1854
+ ref: containerRef,
1855
+ className: `la-user-button ${themeClass} ${appearance?.className || ""}`,
1856
+ style: appearance?.variables,
1857
+ children: [
1858
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1859
+ "button",
1860
+ {
1861
+ type: "button",
1862
+ className: "la-user-trigger",
1863
+ onClick: () => setIsOpen(!isOpen),
1864
+ "aria-expanded": isOpen,
1865
+ "aria-haspopup": "menu",
1866
+ "aria-label": "User menu",
1867
+ children: [
1868
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "la-user-avatar", children: user.avatarUrl ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: user.avatarUrl, alt: user.displayName }) : initials }),
1869
+ showName && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "la-user-name", children: user.displayName })
1870
+ ]
1871
+ }
1872
+ ),
1873
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "la-user-dropdown", role: "menu", children: [
1874
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "la-user-dropdown-header", children: [
1875
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "la-user-dropdown-name", children: user.displayName }),
1876
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "la-user-dropdown-email", children: user.email })
1877
+ ] }),
1878
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1879
+ "button",
1880
+ {
1881
+ type: "button",
1882
+ className: "la-dropdown-item",
1883
+ role: "menuitem",
1884
+ onClick: () => {
1885
+ setIsOpen(false);
1886
+ window.location.href = `${config.domain}/account/profile`;
1887
+ },
1888
+ children: [
1889
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1890
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" }),
1891
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { cx: "12", cy: "7", r: "4" })
1892
+ ] }),
1893
+ "Manage account"
1894
+ ]
1895
+ }
1896
+ ),
1897
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "la-dropdown-divider" }),
1898
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1899
+ "button",
1900
+ {
1901
+ type: "button",
1902
+ className: "la-dropdown-item la-dropdown-item-danger",
1903
+ role: "menuitem",
1904
+ onClick: handleSignOut,
1905
+ children: [
1906
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1907
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
1908
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("polyline", { points: "16 17 21 12 16 7" }),
1909
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
1910
+ ] }),
1911
+ "Sign out"
1912
+ ]
1913
+ }
1914
+ )
1915
+ ] })
1916
+ ]
1917
+ }
1918
+ );
1919
+ }
1920
+
1921
+ // src/components/UserAvatar.tsx
1922
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1923
+ function UserAvatar({
1924
+ size = 32,
1925
+ shape = "circle",
1926
+ appearance
1927
+ }) {
1928
+ const { user, isSignedIn } = useLumoAuthContext();
1929
+ if (!isSignedIn || !user) {
1930
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1931
+ "span",
1932
+ {
1933
+ className: `la-avatar la-avatar-${shape} ${appearance?.className || ""}`,
1934
+ style: {
1935
+ width: size,
1936
+ height: size,
1937
+ fontSize: size * 0.4,
1938
+ ...appearance?.variables
1939
+ },
1940
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", width: size * 0.5, height: size * 0.5, children: [
1941
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" }),
1942
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("circle", { cx: "12", cy: "7", r: "4" })
1943
+ ] })
1944
+ }
1945
+ );
1946
+ }
1947
+ const initials = [user.firstName, user.lastName].filter(Boolean).map((n) => n.charAt(0).toUpperCase()).join("") || user.email.charAt(0).toUpperCase();
1948
+ const themeClass = appearance?.theme === "dark" ? "la-dark" : appearance?.theme === "light" ? "la-light" : "";
1949
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1950
+ "span",
1951
+ {
1952
+ className: `la-avatar la-avatar-${shape} ${themeClass} ${appearance?.className || ""}`,
1953
+ style: {
1954
+ width: size,
1955
+ height: size,
1956
+ fontSize: size * 0.4,
1957
+ ...appearance?.variables
1958
+ },
1959
+ title: user.displayName,
1960
+ children: user.avatarUrl ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1961
+ "img",
1962
+ {
1963
+ src: user.avatarUrl,
1964
+ alt: user.displayName,
1965
+ style: { width: "100%", height: "100%", objectFit: "cover" }
1966
+ }
1967
+ ) : initials
1968
+ }
1969
+ );
1970
+ }
1971
+
1972
+ // src/components/UserProfile.tsx
1973
+ var import_react6 = require("react");
1974
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1975
+ var ICONS = {
1976
+ user: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1977
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" }),
1978
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("circle", { cx: "12", cy: "7", r: "4" })
1979
+ ] }),
1980
+ mail: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1981
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("rect", { x: "2", y: "4", width: "20", height: "16", rx: "2" }),
1982
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7" })
1983
+ ] }),
1984
+ shield: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" }) }),
1985
+ key: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4" }) }),
1986
+ check: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("polyline", { points: "20 6 9 17 4 12" }) }),
1987
+ x: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", children: [
1988
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1989
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1990
+ ] }),
1991
+ signOut: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1992
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
1993
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("polyline", { points: "16 17 21 12 16 7" }),
1994
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
1995
+ ] })
1996
+ };
1997
+ function UserProfile({
1998
+ afterSignOutUrl,
1999
+ mode = "full",
2000
+ appearance
2001
+ }) {
2002
+ const { user, isSignedIn, isLoaded, signOut, config } = useLumoAuthContext();
2003
+ const [signingOut, setSigningOut] = (0, import_react6.useState)(false);
2004
+ const resolvedSignOutUrl = afterSignOutUrl || config.afterSignOutUrl || "/";
2005
+ const handleSignOut = (0, import_react6.useCallback)(async () => {
2006
+ setSigningOut(true);
2007
+ await signOut({ afterSignOutUrl: resolvedSignOutUrl });
2008
+ }, [signOut, resolvedSignOutUrl]);
2009
+ if (!isLoaded) {
2010
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "la-card", style: { textAlign: "center", padding: "2rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "la-spinner" }) });
2011
+ }
2012
+ if (!isSignedIn || !user) {
2013
+ return null;
2014
+ }
2015
+ const initials = [user.firstName, user.lastName].filter(Boolean).map((n) => n.charAt(0).toUpperCase()).join("") || user.email.charAt(0).toUpperCase();
2016
+ const themeClass = appearance?.theme === "dark" ? "la-dark" : appearance?.theme === "light" ? "la-light" : "";
2017
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
2018
+ "div",
2019
+ {
2020
+ className: `la-card la-profile-card ${themeClass} ${appearance?.className || ""}`,
2021
+ style: appearance?.variables,
2022
+ children: [
2023
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "la-profile-header", children: [
2024
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "la-avatar la-avatar-circle la-profile-avatar", children: user.avatarUrl ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("img", { src: user.avatarUrl, alt: user.displayName }) : initials }),
2025
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "la-profile-header-info", children: [
2026
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "la-profile-name", children: user.displayName }),
2027
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "la-profile-email", children: user.email })
2028
+ ] })
2029
+ ] }),
2030
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "la-profile-section", children: [
2031
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "la-profile-section-title", children: "Account" }),
2032
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "la-profile-row", children: [
2033
+ ICONS.mail,
2034
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "la-profile-row-label", children: "Email" }),
2035
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "la-profile-row-value", children: user.email }),
2036
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: `la-profile-badge ${user.emailVerified ? "la-badge-success" : "la-badge-warning"}`, children: [
2037
+ user.emailVerified ? ICONS.check : ICONS.x,
2038
+ user.emailVerified ? "Verified" : "Unverified"
2039
+ ] })
2040
+ ] }),
2041
+ user.firstName && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "la-profile-row", children: [
2042
+ ICONS.user,
2043
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "la-profile-row-label", children: "Name" }),
2044
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "la-profile-row-value", children: [user.firstName, user.lastName].filter(Boolean).join(" ") })
2045
+ ] })
2046
+ ] }),
2047
+ mode === "full" && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
2048
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "la-profile-section", children: [
2049
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "la-profile-section-title", children: "Security" }),
2050
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "la-profile-row", children: [
2051
+ ICONS.shield,
2052
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "la-profile-row-label", children: "MFA" }),
2053
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: `la-profile-badge ${user.mfaEnabled ? "la-badge-success" : "la-badge-muted"}`, children: [
2054
+ user.mfaEnabled ? ICONS.check : ICONS.x,
2055
+ user.mfaEnabled ? "Enabled" : "Disabled"
2056
+ ] })
2057
+ ] })
2058
+ ] }),
2059
+ (user.roles.length > 0 || user.groups.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "la-profile-section", children: [
2060
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "la-profile-section-title", children: "Roles & Groups" }),
2061
+ user.roles.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "la-profile-row", children: [
2062
+ ICONS.key,
2063
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "la-profile-row-label", children: "Roles" }),
2064
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "la-profile-tags", children: user.roles.map((role) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "la-profile-tag", children: role }, role)) })
2065
+ ] }),
2066
+ user.groups.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "la-profile-row", children: [
2067
+ ICONS.user,
2068
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "la-profile-row-label", children: "Groups" }),
2069
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "la-profile-tags", children: user.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "la-profile-tag", children: group }, group)) })
2070
+ ] })
2071
+ ] })
2072
+ ] }),
2073
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "la-profile-section la-profile-actions", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
2074
+ "button",
2075
+ {
2076
+ type: "button",
2077
+ className: "la-btn la-btn-outline la-profile-signout-btn",
2078
+ onClick: handleSignOut,
2079
+ disabled: signingOut,
2080
+ children: [
2081
+ signingOut ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "la-spinner la-spinner-sm" }) : ICONS.signOut,
2082
+ signingOut ? "Signing out\u2026" : "Sign out"
2083
+ ]
2084
+ }
2085
+ ) })
2086
+ ]
2087
+ }
2088
+ );
2089
+ }
2090
+
2091
+ // src/hooks.ts
2092
+ var import_react7 = require("react");
2093
+ var import_client3 = require("@lumoauth/client");
2094
+ function useAuth() {
2095
+ return useLumoAuthContext();
2096
+ }
2097
+ function useUser() {
2098
+ const { user } = useLumoAuthContext();
2099
+ return user;
2100
+ }
2101
+ function useSignIn() {
2102
+ const { signIn, signInWithRedirect, status } = useLumoAuthContext();
2103
+ return {
2104
+ signIn,
2105
+ signInWithRedirect,
2106
+ isLoading: status === "loading"
2107
+ };
2108
+ }
2109
+ function useSession() {
2110
+ const { isSignedIn, isLoaded, getToken, status } = useLumoAuthContext();
2111
+ return {
2112
+ isActive: isSignedIn,
2113
+ isLoaded,
2114
+ getToken,
2115
+ status
2116
+ };
2117
+ }
2118
+ function useLumoAuth() {
2119
+ const { getToken, config } = useLumoAuthContext();
2120
+ const client = (0, import_react7.useMemo)(
2121
+ () => new import_client3.LumoAuth({
2122
+ baseUrl: config.domain,
2123
+ orgId: config.orgId,
2124
+ clientId: config.clientId,
2125
+ token: () => getToken().then((t) => t || "")
2126
+ }),
2127
+ [config.domain, config.orgId, config.clientId, getToken]
2128
+ );
2129
+ return client;
2130
+ }
2131
+ function usePermission(slug) {
2132
+ const client = useLumoAuth();
2133
+ const { isSignedIn, isLoaded } = useLumoAuthContext();
2134
+ const [allowed, setAllowed] = (0, import_react7.useState)(false);
2135
+ const [isLoading, setIsLoading] = (0, import_react7.useState)(true);
2136
+ (0, import_react7.useEffect)(() => {
2137
+ if (!isLoaded || !isSignedIn) {
2138
+ setAllowed(false);
2139
+ setIsLoading(!isLoaded);
2140
+ return;
2141
+ }
2142
+ let cancelled = false;
2143
+ setIsLoading(true);
2144
+ client.permissions.check(slug).then((result) => {
2145
+ if (!cancelled) {
2146
+ setAllowed(result);
2147
+ setIsLoading(false);
2148
+ }
2149
+ }).catch(() => {
2150
+ if (!cancelled) {
2151
+ setAllowed(false);
2152
+ setIsLoading(false);
2153
+ }
2154
+ });
2155
+ return () => {
2156
+ cancelled = true;
2157
+ };
2158
+ }, [client, slug, isSignedIn, isLoaded]);
2159
+ return { allowed, isLoading };
2160
+ }
2161
+ function useZanzibar(request) {
2162
+ const client = useLumoAuth();
2163
+ const { isSignedIn, isLoaded } = useLumoAuthContext();
2164
+ const [allowed, setAllowed] = (0, import_react7.useState)(false);
2165
+ const [isLoading, setIsLoading] = (0, import_react7.useState)(true);
2166
+ const requestKey = `${request.object}:${request.relation}:${request.subject}`;
2167
+ (0, import_react7.useEffect)(() => {
2168
+ if (!isLoaded || !isSignedIn) {
2169
+ setAllowed(false);
2170
+ setIsLoading(!isLoaded);
2171
+ return;
2172
+ }
2173
+ let cancelled = false;
2174
+ setIsLoading(true);
2175
+ client.zanzibar.check(request).then((result) => {
2176
+ if (!cancelled) {
2177
+ setAllowed(result);
2178
+ setIsLoading(false);
2179
+ }
2180
+ }).catch(() => {
2181
+ if (!cancelled) {
2182
+ setAllowed(false);
2183
+ setIsLoading(false);
2184
+ }
2185
+ });
2186
+ return () => {
2187
+ cancelled = true;
2188
+ };
2189
+ }, [client, requestKey, isSignedIn, isLoaded]);
2190
+ return { allowed, isLoading };
2191
+ }
2192
+ function useAbac(request) {
2193
+ const client = useLumoAuth();
2194
+ const { isSignedIn, isLoaded } = useLumoAuthContext();
2195
+ const [allowed, setAllowed] = (0, import_react7.useState)(false);
2196
+ const [isLoading, setIsLoading] = (0, import_react7.useState)(true);
2197
+ const requestKey = `${request.resourceType}:${request.action}:${request.resourceId || ""}`;
2198
+ (0, import_react7.useEffect)(() => {
2199
+ if (!isLoaded || !isSignedIn) {
2200
+ setAllowed(false);
2201
+ setIsLoading(!isLoaded);
2202
+ return;
2203
+ }
2204
+ let cancelled = false;
2205
+ setIsLoading(true);
2206
+ client.abac.check(request).then((res) => {
2207
+ if (!cancelled) {
2208
+ setAllowed(res.allowed);
2209
+ setIsLoading(false);
2210
+ }
2211
+ }).catch(() => {
2212
+ if (!cancelled) {
2213
+ setAllowed(false);
2214
+ setIsLoading(false);
2215
+ }
2216
+ });
2217
+ return () => {
2218
+ cancelled = true;
2219
+ };
2220
+ }, [client, requestKey, isSignedIn, isLoaded]);
2221
+ return { allowed, isLoading };
2222
+ }
2223
+ function useMagicLink() {
2224
+ const { sendMagicLink: sendMagicLinkCtx } = useLumoAuthContext();
2225
+ const [isLoading, setIsLoading] = (0, import_react7.useState)(false);
2226
+ const [isSent, setIsSent] = (0, import_react7.useState)(false);
2227
+ const [error, setError] = (0, import_react7.useState)(null);
2228
+ const sendMagicLink = (0, import_react7.useCallback)(async (email, redirectUri) => {
2229
+ setIsLoading(true);
2230
+ setError(null);
2231
+ try {
2232
+ await sendMagicLinkCtx(email, redirectUri);
2233
+ setIsSent(true);
2234
+ } catch (err) {
2235
+ setError(err instanceof Error ? err.message : "Failed to send magic link");
2236
+ } finally {
2237
+ setIsLoading(false);
2238
+ }
2239
+ }, [sendMagicLinkCtx]);
2240
+ const reset = (0, import_react7.useCallback)(() => {
2241
+ setIsSent(false);
2242
+ setError(null);
2243
+ setIsLoading(false);
2244
+ }, []);
2245
+ return { sendMagicLink, isLoading, isSent, error, reset };
2246
+ }
2247
+ function useEmailFirst() {
2248
+ const { checkEmail: checkEmailCtx } = useLumoAuthContext();
2249
+ const [isLoading, setIsLoading] = (0, import_react7.useState)(false);
2250
+ const [result, setResult] = (0, import_react7.useState)(null);
2251
+ const checkEmail = (0, import_react7.useCallback)(async (email) => {
2252
+ setIsLoading(true);
2253
+ try {
2254
+ const res = await checkEmailCtx(email);
2255
+ setResult(res);
2256
+ return res;
2257
+ } finally {
2258
+ setIsLoading(false);
2259
+ }
2260
+ }, [checkEmailCtx]);
2261
+ const reset = (0, import_react7.useCallback)(() => {
2262
+ setResult(null);
2263
+ setIsLoading(false);
2264
+ }, []);
2265
+ return { checkEmail, isLoading, result, exists: result?.exists ?? null, reset };
2266
+ }
2267
+
2268
+ // src/components/Protect.tsx
2269
+ var import_jsx_runtime8 = require("react/jsx-runtime");
2270
+ function Protect({
2271
+ permission,
2272
+ zanzibar,
2273
+ abac,
2274
+ fallback = null,
2275
+ children
2276
+ }) {
2277
+ const { isLoaded, isSignedIn } = useLumoAuthContext();
2278
+ if (permission) {
2279
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2280
+ ProtectWithPermission,
2281
+ {
2282
+ permission,
2283
+ fallback,
2284
+ isLoaded,
2285
+ isSignedIn,
2286
+ children
2287
+ }
2288
+ );
2289
+ }
2290
+ if (zanzibar) {
2291
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2292
+ ProtectWithZanzibar,
2293
+ {
2294
+ zanzibar,
2295
+ fallback,
2296
+ isLoaded,
2297
+ isSignedIn,
2298
+ children
2299
+ }
2300
+ );
2301
+ }
2302
+ if (abac) {
2303
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2304
+ ProtectWithAbac,
2305
+ {
2306
+ abac,
2307
+ fallback,
2308
+ isLoaded,
2309
+ isSignedIn,
2310
+ children
2311
+ }
2312
+ );
2313
+ }
2314
+ if (!isLoaded) {
2315
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "la-protect-loading", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "la-spinner" }) });
2316
+ }
2317
+ return isSignedIn ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: fallback });
2318
+ }
2319
+ function ProtectWithPermission({
2320
+ permission,
2321
+ fallback,
2322
+ isLoaded,
2323
+ isSignedIn,
2324
+ children
2325
+ }) {
2326
+ const { allowed, isLoading } = usePermission(permission);
2327
+ if (!isLoaded || isLoading) {
2328
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "la-protect-loading", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "la-spinner" }) });
2329
+ }
2330
+ if (!isSignedIn || !allowed) {
2331
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: fallback });
2332
+ }
2333
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children });
2334
+ }
2335
+ function ProtectWithZanzibar({
2336
+ zanzibar,
2337
+ fallback,
2338
+ isLoaded,
2339
+ isSignedIn,
2340
+ children
2341
+ }) {
2342
+ const { allowed, isLoading } = useZanzibar({
2343
+ object: zanzibar.object,
2344
+ relation: zanzibar.relation,
2345
+ subject: zanzibar.subject || "user:me"
2346
+ });
2347
+ if (!isLoaded || isLoading) {
2348
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "la-protect-loading", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "la-spinner" }) });
2349
+ }
2350
+ if (!isSignedIn || !allowed) {
2351
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: fallback });
2352
+ }
2353
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children });
2354
+ }
2355
+ function ProtectWithAbac({
2356
+ abac,
2357
+ fallback,
2358
+ isLoaded,
2359
+ isSignedIn,
2360
+ children
2361
+ }) {
2362
+ const { allowed, isLoading } = useAbac({
2363
+ resourceType: abac.resourceType,
2364
+ action: abac.action,
2365
+ resourceId: abac.resourceId
2366
+ });
2367
+ if (!isLoaded || isLoading) {
2368
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "la-protect-loading", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "la-spinner" }) });
2369
+ }
2370
+ if (!isSignedIn || !allowed) {
2371
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: fallback });
2372
+ }
2373
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children });
2374
+ }
2375
+
2376
+ // src/components/Control.tsx
2377
+ var import_react8 = require("react");
2378
+ var import_jsx_runtime9 = require("react/jsx-runtime");
2379
+ function SignedIn({ children }) {
2380
+ const { isLoaded, isSignedIn } = useLumoAuthContext();
2381
+ if (!isLoaded || !isSignedIn) return null;
2382
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children });
2383
+ }
2384
+ function SignedOut({ children }) {
2385
+ const { isLoaded, isSignedIn } = useLumoAuthContext();
2386
+ if (!isLoaded || isSignedIn) return null;
2387
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children });
2388
+ }
2389
+ function SignInButton({ children, signInUrl, className }) {
2390
+ const { signIn, authStrategy, config } = useLumoAuthContext();
2391
+ const handleClick = () => {
2392
+ if (authStrategy === "pkce") {
2393
+ signIn();
2394
+ } else if (signInUrl) {
2395
+ window.location.href = sanitizeRedirectUrl(signInUrl);
2396
+ } else {
2397
+ window.location.href = sanitizeRedirectUrl(config.afterSignInUrl || "/sign-in");
2398
+ }
2399
+ };
2400
+ if (children) {
2401
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { onClick: handleClick, role: "button", tabIndex: 0, onKeyDown: (e) => {
2402
+ if (e.key === "Enter" || e.key === " ") handleClick();
2403
+ }, children });
2404
+ }
2405
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className, onClick: handleClick, children: "Sign in" });
2406
+ }
2407
+ function SignUpButton({ children, signUpUrl, className }) {
2408
+ const { config } = useLumoAuthContext();
2409
+ const handleClick = () => {
2410
+ const url = signUpUrl || config.afterSignUpUrl || "/sign-up";
2411
+ window.location.href = sanitizeRedirectUrl(url);
2412
+ };
2413
+ if (children) {
2414
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { onClick: handleClick, role: "button", tabIndex: 0, onKeyDown: (e) => {
2415
+ if (e.key === "Enter" || e.key === " ") handleClick();
2416
+ }, children });
2417
+ }
2418
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className, onClick: handleClick, children: "Sign up" });
2419
+ }
2420
+ function SignOutButton({ children, afterSignOutUrl, className }) {
2421
+ const { signOut, config } = useLumoAuthContext();
2422
+ const handleClick = async () => {
2423
+ const redirectUrl = afterSignOutUrl || config.afterSignOutUrl || "/";
2424
+ await signOut({ afterSignOutUrl: sanitizeRedirectUrl(redirectUrl) });
2425
+ };
2426
+ if (children) {
2427
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { onClick: handleClick, role: "button", tabIndex: 0, onKeyDown: (e) => {
2428
+ if (e.key === "Enter" || e.key === " ") handleClick();
2429
+ }, children });
2430
+ }
2431
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className, onClick: handleClick, children: "Sign out" });
2432
+ }
2433
+ function RedirectToSignIn({ signInUrl }) {
2434
+ const { signIn, authStrategy } = useLumoAuthContext();
2435
+ (0, import_react8.useEffect)(() => {
2436
+ if (authStrategy === "pkce") {
2437
+ signIn();
2438
+ } else if (signInUrl && typeof window !== "undefined") {
2439
+ window.location.href = sanitizeRedirectUrl(signInUrl);
2440
+ }
2441
+ }, [signIn, authStrategy, signInUrl]);
2442
+ return null;
2443
+ }
2444
+ // Annotate the CommonJS export names for ESM import in node:
2445
+ 0 && (module.exports = {
2446
+ AuthCallback,
2447
+ LumoAuth,
2448
+ LumoAuthProvider,
2449
+ Protect,
2450
+ RedirectToSignIn,
2451
+ SignIn,
2452
+ SignInButton,
2453
+ SignOutButton,
2454
+ SignUp,
2455
+ SignUpButton,
2456
+ SignedIn,
2457
+ SignedOut,
2458
+ UserAvatar,
2459
+ UserButton,
2460
+ UserProfile,
2461
+ useAbac,
2462
+ useAuth,
2463
+ useEmailFirst,
2464
+ useLumoAuth,
2465
+ useMagicLink,
2466
+ usePermission,
2467
+ useSession,
2468
+ useSignIn,
2469
+ useUser,
2470
+ useZanzibar
2471
+ });
2472
+ //# sourceMappingURL=index.js.map