@leancodepl/kratos 8.5.0 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/index.cjs.default.js +1 -0
  2. package/index.cjs.js +4681 -0
  3. package/index.cjs.mjs +2 -0
  4. package/index.d.ts +1 -0
  5. package/index.esm.js +4653 -0
  6. package/package.json +1 -6
  7. package/src/index.d.ts +12 -0
  8. package/src/lib/cards/index.d.ts +2 -0
  9. package/src/lib/cards/userAuthCard.d.ts +62 -0
  10. package/src/lib/cards/userSettingsCard.d.ts +36 -0
  11. package/src/lib/createKratosClient.d.ts +19 -0
  12. package/src/lib/defaultComponents/DefaultButtonComponent/index.d.ts +2 -0
  13. package/src/lib/defaultComponents/DefaultCheckboxComponent/index.d.ts +2 -0
  14. package/src/lib/defaultComponents/DefaultImageComponent/index.d.ts +2 -0
  15. package/src/lib/defaultComponents/DefaultInputComponent/index.d.ts +2 -0
  16. package/src/lib/defaultComponents/DefaultLinkComponent/index.d.ts +2 -0
  17. package/src/lib/defaultComponents/DefaultMessageComponent/index.d.ts +2 -0
  18. package/src/lib/defaultComponents/DefaultMessageFormatComponent/index.d.ts +2 -0
  19. package/src/lib/defaultComponents/DefaultTextComponent/index.d.ts +2 -0
  20. package/src/lib/defaultComponents/DefaultUiMessagesComponent/index.d.ts +2 -0
  21. package/src/lib/defaultComponents.d.ts +2 -0
  22. package/src/lib/flows/index.d.ts +7 -0
  23. package/src/lib/flows/useLoginFlow.d.ts +50 -0
  24. package/src/lib/flows/useLogoutFlow.d.ts +33 -0
  25. package/src/lib/flows/useReauthenticationFlow.d.ts +31 -0
  26. package/src/lib/flows/useRecoveryFlow.d.ts +47 -0
  27. package/src/lib/flows/useRegistrationFlow.d.ts +47 -0
  28. package/src/lib/flows/useSettingsFlow.d.ts +47 -0
  29. package/src/lib/flows/useVerificationFlow.d.ts +47 -0
  30. package/src/lib/helpers/errorMessages.d.ts +7 -0
  31. package/src/lib/helpers/filterFlowNodes.d.ts +7 -0
  32. package/src/lib/helpers/formattedMessage.d.ts +4 -0
  33. package/src/lib/helpers/getNodeLabel.d.ts +2 -0
  34. package/src/lib/helpers/node.d.ts +7 -0
  35. package/src/lib/helpers/useScriptNodes.d.ts +5 -0
  36. package/src/lib/helpers/userAuthForm.d.ts +31 -0
  37. package/src/lib/kratosContext.d.ts +29 -0
  38. package/src/lib/kratosContextProvider.d.ts +34 -0
  39. package/src/lib/sections/authCodeSection.d.ts +14 -0
  40. package/src/lib/sections/identifierFirstLoginSection.d.ts +8 -0
  41. package/src/lib/sections/linkSection.d.ts +14 -0
  42. package/src/lib/sections/loginSection.d.ts +8 -0
  43. package/src/lib/sections/lookupSecretSettingsSection.d.ts +8 -0
  44. package/src/lib/sections/oidcSection.d.ts +8 -0
  45. package/src/lib/sections/oidcSettingsSection.d.ts +8 -0
  46. package/src/lib/sections/passkeySettingsSection.d.ts +8 -0
  47. package/src/lib/sections/passwordSettingsSection.d.ts +8 -0
  48. package/src/lib/sections/passwordlessSection.d.ts +8 -0
  49. package/src/lib/sections/profileLoginSection.d.ts +8 -0
  50. package/src/lib/sections/profileRegistrationSection.d.ts +8 -0
  51. package/src/lib/sections/profileSettingsSection.d.ts +8 -0
  52. package/src/lib/sections/registrationSection.d.ts +8 -0
  53. package/src/lib/sections/totpSettingsSection.d.ts +8 -0
  54. package/src/lib/sessionManager/baseSessionManager.d.ts +35 -0
  55. package/src/lib/types/components.d.ts +78 -0
  56. package/src/lib/types/enums/errorId.d.ts +16 -0
  57. package/src/lib/types/enums/errorValidation.d.ts +30 -0
  58. package/src/lib/types/enums/errorValidationLogin.d.ts +9 -0
  59. package/src/lib/types/enums/errorValidationRecovery.d.ts +9 -0
  60. package/src/lib/types/enums/errorValidationRegistration.d.ts +4 -0
  61. package/src/lib/types/enums/errorValidationSettings.d.ts +4 -0
  62. package/src/lib/types/enums/errorValidationVerification.d.ts +9 -0
  63. package/src/lib/types/enums/index.d.ts +14 -0
  64. package/src/lib/types/enums/infoNodeLabel.d.ts +14 -0
  65. package/src/lib/types/enums/infoSelfServiceLogin.d.ts +16 -0
  66. package/src/lib/types/enums/infoSelfServiceRecovery.d.ts +6 -0
  67. package/src/lib/types/enums/infoSelfServiceRegistration.d.ts +7 -0
  68. package/src/lib/types/enums/infoSelfServiceSettings.d.ts +21 -0
  69. package/src/lib/types/enums/infoSelfServiceVerification.d.ts +6 -0
  70. package/src/lib/types/enums/misc.d.ts +10 -0
  71. package/src/lib/types/responseError.d.ts +2 -0
  72. package/src/lib/types/useHandleFlowError.d.ts +13 -0
  73. package/src/lib/utils/filterNodesByGroups.d.ts +22 -0
  74. package/src/lib/utils/getNodeInputType.d.ts +1 -0
  75. package/src/lib/utils/handleCancelError.d.ts +2 -0
  76. package/src/lib/utils/helpers.d.ts +11 -0
  77. package/src/lib/utils/typeGuards.d.ts +24 -0
  78. package/src/lib/utils/variables.d.ts +4 -0
package/index.esm.js ADDED
@@ -0,0 +1,4653 @@
1
+ import { FrontendApi, Configuration, AuthenticatorAssuranceLevel, UiNodeGroupEnum } from '@ory/client';
2
+ import axios from 'axios';
3
+ import { createContext, useContext, useMemo, useState, useCallback, useEffect } from 'react';
4
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
+ import { ReplaySubject, map, shareReplay, Subject, switchMap, from, catchError, of } from 'rxjs';
6
+ import yn from 'yn';
7
+
8
+ /**
9
+ * Creates Ory Kratos FrontendApi client with axios and credentials configuration.
10
+ *
11
+ * Initializes a Kratos client for browser-based applications with automatic
12
+ * cookie handling and CORS support for authentication flows.
13
+ *
14
+ * @param configuration - Kratos client configuration parameters
15
+ * @returns Configured FrontendApi instance for Kratos operations
16
+ * @example
17
+ * ```typescript
18
+ * import { createKratosClient } from '@leancodepl/kratos';
19
+ *
20
+ * const kratosClient = createKratosClient({
21
+ * basePath: 'https://auth.example.com'
22
+ * });
23
+ * ```
24
+ */ function createKratosClient(configuration) {
25
+ return new FrontendApi(new Configuration(configuration), undefined, axios.create({
26
+ withCredentials: true
27
+ }));
28
+ }
29
+
30
+ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
31
+ try {
32
+ var info = gen[key](arg);
33
+ var value = info.value;
34
+ } catch (error) {
35
+ reject(error);
36
+ return;
37
+ }
38
+ if (info.done) {
39
+ resolve(value);
40
+ } else {
41
+ Promise.resolve(value).then(_next, _throw);
42
+ }
43
+ }
44
+ function _async_to_generator$2(fn) {
45
+ return function() {
46
+ var self = this, args = arguments;
47
+ return new Promise(function(resolve, reject) {
48
+ var gen = fn.apply(self, args);
49
+ function _next(value) {
50
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
51
+ }
52
+ function _throw(err) {
53
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
54
+ }
55
+ _next(undefined);
56
+ });
57
+ };
58
+ }
59
+ function _ts_generator$2(thisArg, body) {
60
+ var f, y, t, g, _ = {
61
+ label: 0,
62
+ sent: function() {
63
+ if (t[0] & 1) throw t[1];
64
+ return t[1];
65
+ },
66
+ trys: [],
67
+ ops: []
68
+ };
69
+ return g = {
70
+ next: verb(0),
71
+ "throw": verb(1),
72
+ "return": verb(2)
73
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
74
+ return this;
75
+ }), g;
76
+ function verb(n) {
77
+ return function(v) {
78
+ return step([
79
+ n,
80
+ v
81
+ ]);
82
+ };
83
+ }
84
+ function step(op) {
85
+ if (f) throw new TypeError("Generator is already executing.");
86
+ while(_)try {
87
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
88
+ if (y = 0, t) op = [
89
+ op[0] & 2,
90
+ t.value
91
+ ];
92
+ switch(op[0]){
93
+ case 0:
94
+ case 1:
95
+ t = op;
96
+ break;
97
+ case 4:
98
+ _.label++;
99
+ return {
100
+ value: op[1],
101
+ done: false
102
+ };
103
+ case 5:
104
+ _.label++;
105
+ y = op[1];
106
+ op = [
107
+ 0
108
+ ];
109
+ continue;
110
+ case 7:
111
+ op = _.ops.pop();
112
+ _.trys.pop();
113
+ continue;
114
+ default:
115
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
116
+ _ = 0;
117
+ continue;
118
+ }
119
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
120
+ _.label = op[1];
121
+ break;
122
+ }
123
+ if (op[0] === 6 && _.label < t[1]) {
124
+ _.label = t[1];
125
+ t = op;
126
+ break;
127
+ }
128
+ if (t && _.label < t[2]) {
129
+ _.label = t[2];
130
+ _.ops.push(op);
131
+ break;
132
+ }
133
+ if (t[2]) _.ops.pop();
134
+ _.trys.pop();
135
+ continue;
136
+ }
137
+ op = body.call(thisArg, _);
138
+ } catch (e) {
139
+ op = [
140
+ 6,
141
+ e
142
+ ];
143
+ y = 0;
144
+ } finally{
145
+ f = t = 0;
146
+ }
147
+ if (op[0] & 5) throw op[1];
148
+ return {
149
+ value: op[0] ? op[1] : void 0,
150
+ done: true
151
+ };
152
+ }
153
+ }
154
+ var kratosContext = /*#__PURE__*/ createContext({
155
+ components: undefined,
156
+ useHandleFlowError: function() {
157
+ return /*#__PURE__*/ _async_to_generator$2(function() {
158
+ return _ts_generator$2(this, function(_state) {
159
+ return [
160
+ 2,
161
+ undefined
162
+ ];
163
+ });
164
+ });
165
+ },
166
+ excludeScripts: false
167
+ });
168
+ /**
169
+ * Access Kratos context data with components and error handling.
170
+ *
171
+ * Retrieves the current Kratos context including UI components, error handlers,
172
+ * and configuration. Throws error if components are not initialized.
173
+ *
174
+ * @returns Kratos context data with initialized components
175
+ * @throws Error when Kratos context components are not initialized
176
+ * @example
177
+ * ```typescript
178
+ * import { useKratosContext } from '@leancodepl/kratos';
179
+ *
180
+ * function LoginComponent() {
181
+ * const { components, useHandleFlowError } = useKratosContext();
182
+ * // Use components and error handling...
183
+ * }
184
+ * ```
185
+ */ function useKratosContext() {
186
+ var context = useContext(kratosContext);
187
+ if (context.components === undefined) {
188
+ throw new Error("Kratos context components were not initialized");
189
+ }
190
+ return context;
191
+ }
192
+
193
+ function _define_property$p(obj, key, value) {
194
+ if (key in obj) {
195
+ Object.defineProperty(obj, key, {
196
+ value: value,
197
+ enumerable: true,
198
+ configurable: true,
199
+ writable: true
200
+ });
201
+ } else {
202
+ obj[key] = value;
203
+ }
204
+ return obj;
205
+ }
206
+ function _object_spread$o(target) {
207
+ for(var i = 1; i < arguments.length; i++){
208
+ var source = arguments[i] != null ? arguments[i] : {};
209
+ var ownKeys = Object.keys(source);
210
+ if (typeof Object.getOwnPropertySymbols === "function") {
211
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
212
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
213
+ }));
214
+ }
215
+ ownKeys.forEach(function(key) {
216
+ _define_property$p(target, key, source[key]);
217
+ });
218
+ }
219
+ return target;
220
+ }
221
+ function ownKeys$f(object, enumerableOnly) {
222
+ var keys = Object.keys(object);
223
+ if (Object.getOwnPropertySymbols) {
224
+ var symbols = Object.getOwnPropertySymbols(object);
225
+ keys.push.apply(keys, symbols);
226
+ }
227
+ return keys;
228
+ }
229
+ function _object_spread_props$f(target, source) {
230
+ source = source != null ? source : {};
231
+ if (Object.getOwnPropertyDescriptors) {
232
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
233
+ } else {
234
+ ownKeys$f(Object(source)).forEach(function(key) {
235
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
236
+ });
237
+ }
238
+ return target;
239
+ }
240
+ function _object_without_properties$b(source, excluded) {
241
+ if (source == null) return {};
242
+ var target = _object_without_properties_loose$b(source, excluded);
243
+ var key, i;
244
+ if (Object.getOwnPropertySymbols) {
245
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
246
+ for(i = 0; i < sourceSymbolKeys.length; i++){
247
+ key = sourceSymbolKeys[i];
248
+ if (excluded.indexOf(key) >= 0) continue;
249
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
250
+ target[key] = source[key];
251
+ }
252
+ }
253
+ return target;
254
+ }
255
+ function _object_without_properties_loose$b(source, excluded) {
256
+ if (source == null) return {};
257
+ var target = {};
258
+ var sourceKeys = Object.keys(source);
259
+ var key, i;
260
+ for(i = 0; i < sourceKeys.length; i++){
261
+ key = sourceKeys[i];
262
+ if (excluded.indexOf(key) >= 0) continue;
263
+ target[key] = source[key];
264
+ }
265
+ return target;
266
+ }
267
+ function DefaultButtonComponent(_param) {
268
+ var header = _param.header, props = _object_without_properties$b(_param, [
269
+ "header"
270
+ ]);
271
+ return /*#__PURE__*/ jsx("button", _object_spread_props$f(_object_spread$o({}, props), {
272
+ children: header
273
+ }));
274
+ }
275
+
276
+ function _define_property$o(obj, key, value) {
277
+ if (key in obj) {
278
+ Object.defineProperty(obj, key, {
279
+ value: value,
280
+ enumerable: true,
281
+ configurable: true,
282
+ writable: true
283
+ });
284
+ } else {
285
+ obj[key] = value;
286
+ }
287
+ return obj;
288
+ }
289
+ function _object_spread$n(target) {
290
+ for(var i = 1; i < arguments.length; i++){
291
+ var source = arguments[i] != null ? arguments[i] : {};
292
+ var ownKeys = Object.keys(source);
293
+ if (typeof Object.getOwnPropertySymbols === "function") {
294
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
295
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
296
+ }));
297
+ }
298
+ ownKeys.forEach(function(key) {
299
+ _define_property$o(target, key, source[key]);
300
+ });
301
+ }
302
+ return target;
303
+ }
304
+ function ownKeys$e(object, enumerableOnly) {
305
+ var keys = Object.keys(object);
306
+ if (Object.getOwnPropertySymbols) {
307
+ var symbols = Object.getOwnPropertySymbols(object);
308
+ keys.push.apply(keys, symbols);
309
+ }
310
+ return keys;
311
+ }
312
+ function _object_spread_props$e(target, source) {
313
+ source = source != null ? source : {};
314
+ if (Object.getOwnPropertyDescriptors) {
315
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
316
+ } else {
317
+ ownKeys$e(Object(source)).forEach(function(key) {
318
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
319
+ });
320
+ }
321
+ return target;
322
+ }
323
+ function _object_without_properties$a(source, excluded) {
324
+ if (source == null) return {};
325
+ var target = _object_without_properties_loose$a(source, excluded);
326
+ var key, i;
327
+ if (Object.getOwnPropertySymbols) {
328
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
329
+ for(i = 0; i < sourceSymbolKeys.length; i++){
330
+ key = sourceSymbolKeys[i];
331
+ if (excluded.indexOf(key) >= 0) continue;
332
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
333
+ target[key] = source[key];
334
+ }
335
+ }
336
+ return target;
337
+ }
338
+ function _object_without_properties_loose$a(source, excluded) {
339
+ if (source == null) return {};
340
+ var target = {};
341
+ var sourceKeys = Object.keys(source);
342
+ var key, i;
343
+ for(i = 0; i < sourceKeys.length; i++){
344
+ key = sourceKeys[i];
345
+ if (excluded.indexOf(key) >= 0) continue;
346
+ target[key] = source[key];
347
+ }
348
+ return target;
349
+ }
350
+ function DefaultCheckboxComponent(_param) {
351
+ var label = _param.label, helperMessage = _param.helperMessage, props = _object_without_properties$a(_param, [
352
+ "label",
353
+ "helperMessage"
354
+ ]);
355
+ return /*#__PURE__*/ jsxs("div", {
356
+ children: [
357
+ /*#__PURE__*/ jsxs("label", {
358
+ children: [
359
+ /*#__PURE__*/ jsx("input", _object_spread_props$e(_object_spread$n({}, props), {
360
+ type: "checkbox"
361
+ })),
362
+ label
363
+ ]
364
+ }),
365
+ helperMessage
366
+ ]
367
+ });
368
+ }
369
+
370
+ function _define_property$n(obj, key, value) {
371
+ if (key in obj) {
372
+ Object.defineProperty(obj, key, {
373
+ value: value,
374
+ enumerable: true,
375
+ configurable: true,
376
+ writable: true
377
+ });
378
+ } else {
379
+ obj[key] = value;
380
+ }
381
+ return obj;
382
+ }
383
+ function _object_spread$m(target) {
384
+ for(var i = 1; i < arguments.length; i++){
385
+ var source = arguments[i] != null ? arguments[i] : {};
386
+ var ownKeys = Object.keys(source);
387
+ if (typeof Object.getOwnPropertySymbols === "function") {
388
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
389
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
390
+ }));
391
+ }
392
+ ownKeys.forEach(function(key) {
393
+ _define_property$n(target, key, source[key]);
394
+ });
395
+ }
396
+ return target;
397
+ }
398
+ function _object_without_properties$9(source, excluded) {
399
+ if (source == null) return {};
400
+ var target = _object_without_properties_loose$9(source, excluded);
401
+ var key, i;
402
+ if (Object.getOwnPropertySymbols) {
403
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
404
+ for(i = 0; i < sourceSymbolKeys.length; i++){
405
+ key = sourceSymbolKeys[i];
406
+ if (excluded.indexOf(key) >= 0) continue;
407
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
408
+ target[key] = source[key];
409
+ }
410
+ }
411
+ return target;
412
+ }
413
+ function _object_without_properties_loose$9(source, excluded) {
414
+ if (source == null) return {};
415
+ var target = {};
416
+ var sourceKeys = Object.keys(source);
417
+ var key, i;
418
+ for(i = 0; i < sourceKeys.length; i++){
419
+ key = sourceKeys[i];
420
+ if (excluded.indexOf(key) >= 0) continue;
421
+ target[key] = source[key];
422
+ }
423
+ return target;
424
+ }
425
+ function DefaultImageComponent(_param) {
426
+ var header = _param.header, props = _object_without_properties$9(_param, [
427
+ "header"
428
+ ]);
429
+ return /*#__PURE__*/ jsxs("div", {
430
+ children: [
431
+ header && /*#__PURE__*/ jsx("p", {
432
+ children: header
433
+ }),
434
+ /*#__PURE__*/ jsx("img", _object_spread$m({}, props))
435
+ ]
436
+ });
437
+ }
438
+
439
+ function _define_property$m(obj, key, value) {
440
+ if (key in obj) {
441
+ Object.defineProperty(obj, key, {
442
+ value: value,
443
+ enumerable: true,
444
+ configurable: true,
445
+ writable: true
446
+ });
447
+ } else {
448
+ obj[key] = value;
449
+ }
450
+ return obj;
451
+ }
452
+ function _object_spread$l(target) {
453
+ for(var i = 1; i < arguments.length; i++){
454
+ var source = arguments[i] != null ? arguments[i] : {};
455
+ var ownKeys = Object.keys(source);
456
+ if (typeof Object.getOwnPropertySymbols === "function") {
457
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
458
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
459
+ }));
460
+ }
461
+ ownKeys.forEach(function(key) {
462
+ _define_property$m(target, key, source[key]);
463
+ });
464
+ }
465
+ return target;
466
+ }
467
+ function _object_without_properties$8(source, excluded) {
468
+ if (source == null) return {};
469
+ var target = _object_without_properties_loose$8(source, excluded);
470
+ var key, i;
471
+ if (Object.getOwnPropertySymbols) {
472
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
473
+ for(i = 0; i < sourceSymbolKeys.length; i++){
474
+ key = sourceSymbolKeys[i];
475
+ if (excluded.indexOf(key) >= 0) continue;
476
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
477
+ target[key] = source[key];
478
+ }
479
+ }
480
+ return target;
481
+ }
482
+ function _object_without_properties_loose$8(source, excluded) {
483
+ if (source == null) return {};
484
+ var target = {};
485
+ var sourceKeys = Object.keys(source);
486
+ var key, i;
487
+ for(i = 0; i < sourceKeys.length; i++){
488
+ key = sourceKeys[i];
489
+ if (excluded.indexOf(key) >= 0) continue;
490
+ target[key] = source[key];
491
+ }
492
+ return target;
493
+ }
494
+ function DefaultInputComponent(_param) {
495
+ var helperMessage = _param.helperMessage, header = _param.header, props = _object_without_properties$8(_param, [
496
+ "helperMessage",
497
+ "header"
498
+ ]);
499
+ return /*#__PURE__*/ jsxs("div", {
500
+ children: [
501
+ /*#__PURE__*/ jsxs("label", {
502
+ children: [
503
+ header && /*#__PURE__*/ jsx("p", {
504
+ children: header
505
+ }),
506
+ /*#__PURE__*/ jsx("input", _object_spread$l({}, props))
507
+ ]
508
+ }),
509
+ helperMessage
510
+ ]
511
+ });
512
+ }
513
+
514
+ function _define_property$l(obj, key, value) {
515
+ if (key in obj) {
516
+ Object.defineProperty(obj, key, {
517
+ value: value,
518
+ enumerable: true,
519
+ configurable: true,
520
+ writable: true
521
+ });
522
+ } else {
523
+ obj[key] = value;
524
+ }
525
+ return obj;
526
+ }
527
+ function _object_spread$k(target) {
528
+ for(var i = 1; i < arguments.length; i++){
529
+ var source = arguments[i] != null ? arguments[i] : {};
530
+ var ownKeys = Object.keys(source);
531
+ if (typeof Object.getOwnPropertySymbols === "function") {
532
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
533
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
534
+ }));
535
+ }
536
+ ownKeys.forEach(function(key) {
537
+ _define_property$l(target, key, source[key]);
538
+ });
539
+ }
540
+ return target;
541
+ }
542
+ function _object_without_properties$7(source, excluded) {
543
+ if (source == null) return {};
544
+ var target = _object_without_properties_loose$7(source, excluded);
545
+ var key, i;
546
+ if (Object.getOwnPropertySymbols) {
547
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
548
+ for(i = 0; i < sourceSymbolKeys.length; i++){
549
+ key = sourceSymbolKeys[i];
550
+ if (excluded.indexOf(key) >= 0) continue;
551
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
552
+ target[key] = source[key];
553
+ }
554
+ }
555
+ return target;
556
+ }
557
+ function _object_without_properties_loose$7(source, excluded) {
558
+ if (source == null) return {};
559
+ var target = {};
560
+ var sourceKeys = Object.keys(source);
561
+ var key, i;
562
+ for(i = 0; i < sourceKeys.length; i++){
563
+ key = sourceKeys[i];
564
+ if (excluded.indexOf(key) >= 0) continue;
565
+ target[key] = source[key];
566
+ }
567
+ return target;
568
+ }
569
+ function DefaultLinkComponent(_param) {
570
+ _param.href; var props = _object_without_properties$7(_param, [
571
+ "href"
572
+ ]);
573
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
574
+ return /*#__PURE__*/ jsx("a", _object_spread$k({}, props));
575
+ }
576
+
577
+ function DefaultMessageComponent(param) {
578
+ var children = param.children;
579
+ return /*#__PURE__*/ jsx(Fragment, {
580
+ children: children
581
+ });
582
+ }
583
+
584
+ function DefaultMessageFormatComponent(param) {
585
+ var text = param.text;
586
+ return /*#__PURE__*/ jsx("span", {
587
+ children: text
588
+ });
589
+ }
590
+
591
+ function _define_property$k(obj, key, value) {
592
+ if (key in obj) {
593
+ Object.defineProperty(obj, key, {
594
+ value: value,
595
+ enumerable: true,
596
+ configurable: true,
597
+ writable: true
598
+ });
599
+ } else {
600
+ obj[key] = value;
601
+ }
602
+ return obj;
603
+ }
604
+ function _object_spread$j(target) {
605
+ for(var i = 1; i < arguments.length; i++){
606
+ var source = arguments[i] != null ? arguments[i] : {};
607
+ var ownKeys = Object.keys(source);
608
+ if (typeof Object.getOwnPropertySymbols === "function") {
609
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
610
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
611
+ }));
612
+ }
613
+ ownKeys.forEach(function(key) {
614
+ _define_property$k(target, key, source[key]);
615
+ });
616
+ }
617
+ return target;
618
+ }
619
+ function FormattedMessage(param) {
620
+ var message = param.message;
621
+ var _useKratosContext = useKratosContext(), MessageFormat = _useKratosContext.components.MessageFormat;
622
+ if (!message) return null;
623
+ return /*#__PURE__*/ jsx(MessageFormat, _object_spread$j({}, message));
624
+ }
625
+
626
+ function DefaultTextComponent(param) {
627
+ var label = param.label, codes = param.codes;
628
+ return /*#__PURE__*/ jsxs("div", {
629
+ children: [
630
+ /*#__PURE__*/ jsx("span", {
631
+ children: label
632
+ }),
633
+ codes === null || codes === void 0 ? void 0 : codes.map(function(code) {
634
+ return /*#__PURE__*/ jsx("pre", {
635
+ children: /*#__PURE__*/ jsx("code", {
636
+ children: /*#__PURE__*/ jsx(FormattedMessage, {
637
+ message: code
638
+ })
639
+ })
640
+ }, code.text);
641
+ })
642
+ ]
643
+ });
644
+ }
645
+
646
+ function _array_like_to_array$7(arr, len) {
647
+ if (len == null || len > arr.length) len = arr.length;
648
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
649
+ return arr2;
650
+ }
651
+ function _array_without_holes$1(arr) {
652
+ if (Array.isArray(arr)) return _array_like_to_array$7(arr);
653
+ }
654
+ function _define_property$j(obj, key, value) {
655
+ if (key in obj) {
656
+ Object.defineProperty(obj, key, {
657
+ value: value,
658
+ enumerable: true,
659
+ configurable: true,
660
+ writable: true
661
+ });
662
+ } else {
663
+ obj[key] = value;
664
+ }
665
+ return obj;
666
+ }
667
+ function _iterable_to_array$1(iter) {
668
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
669
+ }
670
+ function _non_iterable_spread$1() {
671
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
672
+ }
673
+ function _object_spread$i(target) {
674
+ for(var i = 1; i < arguments.length; i++){
675
+ var source = arguments[i] != null ? arguments[i] : {};
676
+ var ownKeys = Object.keys(source);
677
+ if (typeof Object.getOwnPropertySymbols === "function") {
678
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
679
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
680
+ }));
681
+ }
682
+ ownKeys.forEach(function(key) {
683
+ _define_property$j(target, key, source[key]);
684
+ });
685
+ }
686
+ return target;
687
+ }
688
+ function ownKeys$d(object, enumerableOnly) {
689
+ var keys = Object.keys(object);
690
+ if (Object.getOwnPropertySymbols) {
691
+ var symbols = Object.getOwnPropertySymbols(object);
692
+ keys.push.apply(keys, symbols);
693
+ }
694
+ return keys;
695
+ }
696
+ function _object_spread_props$d(target, source) {
697
+ source = source != null ? source : {};
698
+ if (Object.getOwnPropertyDescriptors) {
699
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
700
+ } else {
701
+ ownKeys$d(Object(source)).forEach(function(key) {
702
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
703
+ });
704
+ }
705
+ return target;
706
+ }
707
+ function _object_without_properties$6(source, excluded) {
708
+ if (source == null) return {};
709
+ var target = _object_without_properties_loose$6(source, excluded);
710
+ var key, i;
711
+ if (Object.getOwnPropertySymbols) {
712
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
713
+ for(i = 0; i < sourceSymbolKeys.length; i++){
714
+ key = sourceSymbolKeys[i];
715
+ if (excluded.indexOf(key) >= 0) continue;
716
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
717
+ target[key] = source[key];
718
+ }
719
+ }
720
+ return target;
721
+ }
722
+ function _object_without_properties_loose$6(source, excluded) {
723
+ if (source == null) return {};
724
+ var target = {};
725
+ var sourceKeys = Object.keys(source);
726
+ var key, i;
727
+ for(i = 0; i < sourceKeys.length; i++){
728
+ key = sourceKeys[i];
729
+ if (excluded.indexOf(key) >= 0) continue;
730
+ target[key] = source[key];
731
+ }
732
+ return target;
733
+ }
734
+ function _to_consumable_array$1(arr) {
735
+ return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$1();
736
+ }
737
+ function _unsupported_iterable_to_array$7(o, minLen) {
738
+ if (!o) return;
739
+ if (typeof o === "string") return _array_like_to_array$7(o, minLen);
740
+ var n = Object.prototype.toString.call(o).slice(8, -1);
741
+ if (n === "Object" && o.constructor) n = o.constructor.name;
742
+ if (n === "Map" || n === "Set") return Array.from(n);
743
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$7(o, minLen);
744
+ }
745
+ function NodeMessage(_param) {
746
+ var message = _param.message, props = _object_without_properties$6(_param, [
747
+ "message"
748
+ ]);
749
+ var _useKratosContext = useKratosContext(), Message = _useKratosContext.components.Message;
750
+ return /*#__PURE__*/ jsx(Message, _object_spread_props$d(_object_spread$i({
751
+ message: message,
752
+ severity: message.type
753
+ }, props), {
754
+ children: /*#__PURE__*/ jsx(FormattedMessage, {
755
+ message: message
756
+ })
757
+ }));
758
+ }
759
+ function NodeMessages(param) {
760
+ var nodes = param.nodes, uiMessages = param.uiMessages;
761
+ var _nodes_reduce;
762
+ var $groupMessages = (_nodes_reduce = nodes === null || nodes === void 0 ? void 0 : nodes.reduce(function(groups, param) {
763
+ var messages = param.messages;
764
+ var _groups;
765
+ (_groups = groups).push.apply(_groups, _to_consumable_array$1(messages.map(function(message, key) {
766
+ return /*#__PURE__*/ jsx(NodeMessage, {
767
+ message: message
768
+ }, "node-group-message-".concat(message.id, "-").concat(key));
769
+ }).filter(Boolean)));
770
+ return groups;
771
+ }, [])) !== null && _nodes_reduce !== void 0 ? _nodes_reduce : [];
772
+ var _uiMessages_map;
773
+ var $messages = (_uiMessages_map = uiMessages === null || uiMessages === void 0 ? void 0 : uiMessages.map(function(message, key) {
774
+ return /*#__PURE__*/ jsx(NodeMessage, {
775
+ message: message
776
+ }, "ui-message-".concat(message.id, "-").concat(key));
777
+ })) !== null && _uiMessages_map !== void 0 ? _uiMessages_map : [];
778
+ var $allMessages = _to_consumable_array$1($groupMessages).concat(_to_consumable_array$1($messages));
779
+ if ($allMessages.length <= 0) return null;
780
+ return /*#__PURE__*/ jsx("div", {
781
+ children: $allMessages
782
+ });
783
+ }
784
+
785
+ function _define_property$i(obj, key, value) {
786
+ if (key in obj) {
787
+ Object.defineProperty(obj, key, {
788
+ value: value,
789
+ enumerable: true,
790
+ configurable: true,
791
+ writable: true
792
+ });
793
+ } else {
794
+ obj[key] = value;
795
+ }
796
+ return obj;
797
+ }
798
+ function _object_spread$h(target) {
799
+ for(var i = 1; i < arguments.length; i++){
800
+ var source = arguments[i] != null ? arguments[i] : {};
801
+ var ownKeys = Object.keys(source);
802
+ if (typeof Object.getOwnPropertySymbols === "function") {
803
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
804
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
805
+ }));
806
+ }
807
+ ownKeys.forEach(function(key) {
808
+ _define_property$i(target, key, source[key]);
809
+ });
810
+ }
811
+ return target;
812
+ }
813
+ function DefaultUiMessagesComponent(props) {
814
+ return /*#__PURE__*/ jsx(NodeMessages, _object_spread$h({}, props));
815
+ }
816
+
817
+ var defaultComponents = {
818
+ Image: DefaultImageComponent,
819
+ Text: DefaultTextComponent,
820
+ Link: DefaultLinkComponent,
821
+ Input: DefaultInputComponent,
822
+ Message: DefaultMessageComponent,
823
+ Button: DefaultButtonComponent,
824
+ Checkbox: DefaultCheckboxComponent,
825
+ UiMessages: DefaultUiMessagesComponent,
826
+ MessageFormat: DefaultMessageFormatComponent,
827
+ OidcSectionWrapper: "div",
828
+ PasswordlessSectionWrapper: "div",
829
+ AuthCodeSectionWrapper: "div",
830
+ LoginSectionWrapper: "div",
831
+ RegistrationSectionWrapper: "div",
832
+ LinkSectionWrapper: "div",
833
+ ProfileSettingsSectionWrapper: "div",
834
+ PasswordSettingsSectionWrapper: "div",
835
+ WebAuthnSettingsSectionWrapper: "div",
836
+ LookupSecretSettingsSectionWrapper: "div",
837
+ OidcSettingsSectionWrapper: "div",
838
+ TotpSettingsSectionWrapper: "div",
839
+ IdentifierFirstLoginSectionWrapper: "div",
840
+ ProfileLoginSectionWrapper: "div",
841
+ ProfileRegistrationSectionWrapper: "div"
842
+ };
843
+
844
+ function _define_property$h(obj, key, value) {
845
+ if (key in obj) {
846
+ Object.defineProperty(obj, key, {
847
+ value: value,
848
+ enumerable: true,
849
+ configurable: true,
850
+ writable: true
851
+ });
852
+ } else {
853
+ obj[key] = value;
854
+ }
855
+ return obj;
856
+ }
857
+ function _object_spread$g(target) {
858
+ for(var i = 1; i < arguments.length; i++){
859
+ var source = arguments[i] != null ? arguments[i] : {};
860
+ var ownKeys = Object.keys(source);
861
+ if (typeof Object.getOwnPropertySymbols === "function") {
862
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
863
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
864
+ }));
865
+ }
866
+ ownKeys.forEach(function(key) {
867
+ _define_property$h(target, key, source[key]);
868
+ });
869
+ }
870
+ return target;
871
+ }
872
+ /**
873
+ * Provides Kratos context to child components with customizable configuration.
874
+ *
875
+ * Sets up the React context for Kratos integration, allowing customization of
876
+ * UI components, error handling, and script loading behavior.
877
+ *
878
+ * @param components - Partial override of default Kratos UI components
879
+ * @param useHandleFlowError - Custom error handler for authentication flows
880
+ * @param excludeScripts - Whether to exclude script node execution
881
+ * @param children - Child React components
882
+ * @returns JSX element providing Kratos context
883
+ * @example
884
+ * ```typescript
885
+ * import { KratosContextProvider } from '@leancodepl/kratos';
886
+ *
887
+ * function App() {
888
+ * return (
889
+ * <KratosContextProvider>
890
+ * <LoginPage />
891
+ * </KratosContextProvider>
892
+ * );
893
+ * }
894
+ * ```
895
+ */ function KratosContextProvider(param) {
896
+ var _param_components = param.components, components = _param_components === void 0 ? {} : _param_components, useHandleFlowError = param.useHandleFlowError, excludeScripts = param.excludeScripts, children = param.children;
897
+ var _useContext = useContext(kratosContext), baseComponents = _useContext.components, baseUseHandleFlowError = _useContext.useHandleFlowError, baseExcludeScripts = _useContext.excludeScripts;
898
+ var value = useMemo(function() {
899
+ return {
900
+ components: _object_spread$g({}, baseComponents !== null && baseComponents !== void 0 ? baseComponents : defaultComponents, components),
901
+ useHandleFlowError: useHandleFlowError !== null && useHandleFlowError !== void 0 ? useHandleFlowError : baseUseHandleFlowError,
902
+ excludeScripts: excludeScripts !== null && excludeScripts !== void 0 ? excludeScripts : baseExcludeScripts
903
+ };
904
+ }, [
905
+ baseComponents,
906
+ components,
907
+ useHandleFlowError,
908
+ baseUseHandleFlowError,
909
+ excludeScripts,
910
+ baseExcludeScripts
911
+ ]);
912
+ return /*#__PURE__*/ jsx(kratosContext.Provider, {
913
+ value: value,
914
+ children: children
915
+ });
916
+ }
917
+
918
+ var returnToParameterName = "return_to";
919
+ var aalParameterName = "aal";
920
+ var flowIdParameterName = "flow";
921
+ var refreshParameterName = "refresh";
922
+
923
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
924
+ var ErrorId;
925
+ (function(ErrorId) {
926
+ ErrorId["ErrIDNeedsPrivilegedSession"] = "session_refresh_required";
927
+ ErrorId["ErrIDSelfServiceFlowExpired"] = "self_service_flow_expired";
928
+ ErrorId["ErrIDSelfServiceFlowDisabled"] = "self_service_flow_disabled";
929
+ ErrorId["ErrIDSelfServiceBrowserLocationChangeRequiredError"] = "browser_location_change_required";
930
+ ErrorId["ErrIDSelfServiceFlowReplaced"] = "self_service_flow_replaced";
931
+ ErrorId["ErrIDAlreadyLoggedIn"] = "session_already_available";
932
+ ErrorId["ErrIDAddressNotVerified"] = "session_verified_address_required";
933
+ ErrorId["ErrIDSessionHasAALAlready"] = "session_aal_already_fulfilled";
934
+ ErrorId["ErrIDSessionRequiredForHigherAAL"] = "session_aal1_required";
935
+ ErrorId["ErrIDHigherAALRequired"] = "session_aal2_required";
936
+ ErrorId["ErrNoActiveSession"] = "session_inactive";
937
+ ErrorId["ErrIDRedirectURLNotAllowed"] = "self_service_flow_return_to_forbidden";
938
+ ErrorId["ErrIDInitiatedBySomeoneElse"] = "security_identity_mismatch";
939
+ ErrorId["ErrIDCSRF"] = "security_csrf_violation";
940
+ })(ErrorId || (ErrorId = {}));
941
+
942
+ function _class_call_check(instance, Constructor) {
943
+ if (!(instance instanceof Constructor)) {
944
+ throw new TypeError("Cannot call a class as a function");
945
+ }
946
+ }
947
+ function _defineProperties(target, props) {
948
+ for(var i = 0; i < props.length; i++){
949
+ var descriptor = props[i];
950
+ descriptor.enumerable = descriptor.enumerable || false;
951
+ descriptor.configurable = true;
952
+ if ("value" in descriptor) descriptor.writable = true;
953
+ Object.defineProperty(target, descriptor.key, descriptor);
954
+ }
955
+ }
956
+ function _create_class(Constructor, protoProps, staticProps) {
957
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
958
+ return Constructor;
959
+ }
960
+ function _define_property$g(obj, key, value) {
961
+ if (key in obj) {
962
+ Object.defineProperty(obj, key, {
963
+ value: value,
964
+ enumerable: true,
965
+ configurable: true,
966
+ writable: true
967
+ });
968
+ } else {
969
+ obj[key] = value;
970
+ }
971
+ return obj;
972
+ }
973
+ /**
974
+ * Manages Kratos session state with RxJS observables for authentication status.
975
+ *
976
+ * Provides reactive session management with automatic status checking, user identity
977
+ * tracking, and AAL (Authenticator Assurance Level) handling for multi-factor authentication.
978
+ *
979
+ * @param authUrl - Base URL for Kratos authentication endpoints
980
+ * @param loginRoute - Application route for login page
981
+ * @example
982
+ * ```typescript
983
+ * import { BaseSessionManager } from '@leancodepl/kratos';
984
+ *
985
+ * const sessionManager = new BaseSessionManager(
986
+ * 'https://auth.example.com',
987
+ * '/login'
988
+ * );
989
+ *
990
+ * sessionManager.isLoggedIn.subscribe(loggedIn => {
991
+ * console.log('User logged in:', loggedIn);
992
+ * });
993
+ * ```
994
+ */ var BaseSessionManager = /*#__PURE__*/ function() {
995
+ function BaseSessionManager(authUrl, loginRoute) {
996
+ var _this = this;
997
+ _class_call_check(this, BaseSessionManager);
998
+ _define_property$g(this, "authUrl", void 0);
999
+ _define_property$g(this, "loginRoute", void 0);
1000
+ _define_property$g(this, "session$", new ReplaySubject(1));
1001
+ _define_property$g(this, "isLoggedIn", this.session$.pipe(map(function(session) {
1002
+ return !!(session === null || session === void 0 ? void 0 : session.active);
1003
+ }), shareReplay(1)));
1004
+ _define_property$g(this, "identity$", this.session$.pipe(map(function(session) {
1005
+ return session === null || session === void 0 ? void 0 : session.identity;
1006
+ }), shareReplay(1)));
1007
+ _define_property$g(this, "userId$", this.identity$.pipe(map(function(identity) {
1008
+ return identity === null || identity === void 0 ? void 0 : identity.id;
1009
+ }), shareReplay(1)));
1010
+ _define_property$g(this, "checkIfLoggedIn", function() {
1011
+ var fetchSubject = new Subject();
1012
+ fetchSubject.pipe(switchMap(function() {
1013
+ return from(axios.get("".concat(_this.authUrl, "/sessions/whoami"), {
1014
+ withCredentials: true
1015
+ })).pipe(map(function(response) {
1016
+ var returnTo = new URLSearchParams(window.location.search).get(returnToParameterName);
1017
+ if (returnTo) {
1018
+ window.location.href = returnTo;
1019
+ }
1020
+ return response.data;
1021
+ }), catchError(function(err) {
1022
+ switch(err.response.status){
1023
+ case 403:
1024
+ case 422:
1025
+ var _err_response_data_error;
1026
+ if (((_err_response_data_error = err.response.data.error) === null || _err_response_data_error === void 0 ? void 0 : _err_response_data_error.id) === ErrorId.ErrIDHigherAALRequired) {
1027
+ var searchParams = new URLSearchParams(window.location.search);
1028
+ if (searchParams.get(aalParameterName)) {
1029
+ break;
1030
+ }
1031
+ var redirectUrl = new URL(_this.loginRoute, window.location.href);
1032
+ if (window.location.pathname === _this.loginRoute) {
1033
+ var searchParams1 = new URLSearchParams(window.location.search);
1034
+ searchParams1.append(aalParameterName, AuthenticatorAssuranceLevel.Aal2);
1035
+ redirectUrl.search = searchParams1.toString();
1036
+ } else {
1037
+ var _obj;
1038
+ redirectUrl.search = new URLSearchParams((_obj = {}, _define_property$g(_obj, aalParameterName, AuthenticatorAssuranceLevel.Aal2), _define_property$g(_obj, returnToParameterName, "".concat(window.location.pathname).concat(window.location.search)), _obj)).toString();
1039
+ }
1040
+ window.location.href = redirectUrl.toString();
1041
+ }
1042
+ break;
1043
+ }
1044
+ return of(undefined);
1045
+ }));
1046
+ })).subscribe({
1047
+ next: function(session) {
1048
+ return _this.session$.next(session);
1049
+ }
1050
+ });
1051
+ return function() {
1052
+ return fetchSubject.next(undefined);
1053
+ };
1054
+ }());
1055
+ this.authUrl = authUrl;
1056
+ this.loginRoute = loginRoute;
1057
+ this.checkIfLoggedIn();
1058
+ }
1059
+ _create_class(BaseSessionManager, [
1060
+ {
1061
+ key: "setSession",
1062
+ value: function setSession(session) {
1063
+ this.session$.next(session);
1064
+ if (!session) this.checkIfLoggedIn();
1065
+ }
1066
+ }
1067
+ ]);
1068
+ return BaseSessionManager;
1069
+ }();
1070
+
1071
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1072
+ var ErrorValidation;
1073
+ (function(ErrorValidation) {
1074
+ ErrorValidation[ErrorValidation["ErrorValidation"] = 4000000] = "ErrorValidation";
1075
+ ErrorValidation[ErrorValidation["ErrorValidationGeneric"] = 4000001] = "ErrorValidationGeneric";
1076
+ ErrorValidation[ErrorValidation["ErrorValidationRequired"] = 4000002] = "ErrorValidationRequired";
1077
+ ErrorValidation[ErrorValidation["ErrorValidationMinLength"] = 4000003] = "ErrorValidationMinLength";
1078
+ ErrorValidation[ErrorValidation["ErrorValidationInvalidFormat"] = 4000004] = "ErrorValidationInvalidFormat";
1079
+ ErrorValidation[ErrorValidation["ErrorValidationPasswordPolicyViolation"] = 4000005] = "ErrorValidationPasswordPolicyViolation";
1080
+ ErrorValidation[ErrorValidation["ErrorValidationInvalidCredentials"] = 4000006] = "ErrorValidationInvalidCredentials";
1081
+ ErrorValidation[ErrorValidation["ErrorValidationDuplicateCredentials"] = 4000007] = "ErrorValidationDuplicateCredentials";
1082
+ ErrorValidation[ErrorValidation["ErrorValidationTOTPVerifierWrong"] = 4000008] = "ErrorValidationTOTPVerifierWrong";
1083
+ ErrorValidation[ErrorValidation["ErrorValidationIdentifierMissing"] = 4000009] = "ErrorValidationIdentifierMissing";
1084
+ ErrorValidation[ErrorValidation["ErrorValidationAddressNotVerified"] = 4000010] = "ErrorValidationAddressNotVerified";
1085
+ ErrorValidation[ErrorValidation["ErrorValidationNoTOTPDevice"] = 4000011] = "ErrorValidationNoTOTPDevice";
1086
+ ErrorValidation[ErrorValidation["ErrorValidationLookupAlreadyUsed"] = 4000012] = "ErrorValidationLookupAlreadyUsed";
1087
+ ErrorValidation[ErrorValidation["ErrorValidationNoWebAuthnDevice"] = 4000013] = "ErrorValidationNoWebAuthnDevice";
1088
+ ErrorValidation[ErrorValidation["ErrorValidationNoLookup"] = 4000014] = "ErrorValidationNoLookup";
1089
+ ErrorValidation[ErrorValidation["ErrorValidationSuchNoWebAuthnUser"] = 4000015] = "ErrorValidationSuchNoWebAuthnUser";
1090
+ ErrorValidation[ErrorValidation["ErrorValidationLookupInvalid"] = 4000016] = "ErrorValidationLookupInvalid";
1091
+ ErrorValidation[ErrorValidation["ErrorValidationMaxLength"] = 4000017] = "ErrorValidationMaxLength";
1092
+ ErrorValidation[ErrorValidation["ErrorValidationMinimum"] = 4000018] = "ErrorValidationMinimum";
1093
+ ErrorValidation[ErrorValidation["ErrorValidationExclusiveMinimum"] = 4000019] = "ErrorValidationExclusiveMinimum";
1094
+ ErrorValidation[ErrorValidation["ErrorValidationMaximum"] = 4000020] = "ErrorValidationMaximum";
1095
+ ErrorValidation[ErrorValidation["ErrorValidationExclusiveMaximum"] = 4000021] = "ErrorValidationExclusiveMaximum";
1096
+ ErrorValidation[ErrorValidation["ErrorValidationMultipleOf"] = 4000022] = "ErrorValidationMultipleOf";
1097
+ ErrorValidation[ErrorValidation["ErrorValidationMaxItems"] = 4000023] = "ErrorValidationMaxItems";
1098
+ ErrorValidation[ErrorValidation["ErrorValidationMinItems"] = 4000024] = "ErrorValidationMinItems";
1099
+ ErrorValidation[ErrorValidation["ErrorValidationUniqueItems"] = 4000025] = "ErrorValidationUniqueItems";
1100
+ ErrorValidation[ErrorValidation["ErrorValidationWrongType"] = 4000026] = "ErrorValidationWrongType";
1101
+ ErrorValidation[ErrorValidation["ErrorValidationDuplicateCredentialsOnOIDCLink"] = 4000027] = "ErrorValidationDuplicateCredentialsOnOIDCLink";
1102
+ })(ErrorValidation || (ErrorValidation = {}));
1103
+
1104
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1105
+ var ErrorValidationLogin;
1106
+ (function(ErrorValidationLogin) {
1107
+ ErrorValidationLogin[ErrorValidationLogin["ErrorValidationLogin"] = 4010000] = "ErrorValidationLogin";
1108
+ ErrorValidationLogin[ErrorValidationLogin["ErrorValidationLoginFlowExpired"] = 4010001] = "ErrorValidationLoginFlowExpired";
1109
+ ErrorValidationLogin[ErrorValidationLogin["ErrorValidationLoginNoStrategyFound"] = 4010002] = "ErrorValidationLoginNoStrategyFound";
1110
+ ErrorValidationLogin[ErrorValidationLogin["ErrorValidationRegistrationNoStrategyFound"] = 4010003] = "ErrorValidationRegistrationNoStrategyFound";
1111
+ ErrorValidationLogin[ErrorValidationLogin["ErrorValidationSettingsNoStrategyFound"] = 4010004] = "ErrorValidationSettingsNoStrategyFound";
1112
+ ErrorValidationLogin[ErrorValidationLogin["ErrorValidationRecoveryNoStrategyFound"] = 4010005] = "ErrorValidationRecoveryNoStrategyFound";
1113
+ ErrorValidationLogin[ErrorValidationLogin["ErrorValidationVerificationNoStrategyFound"] = 4010006] = "ErrorValidationVerificationNoStrategyFound";
1114
+ })(ErrorValidationLogin || (ErrorValidationLogin = {}));
1115
+
1116
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1117
+ var ErrorValidationRecovery;
1118
+ (function(ErrorValidationRecovery) {
1119
+ ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecovery"] = 4060000] = "ErrorValidationRecovery";
1120
+ ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryRetrySuccess"] = 4060001] = "ErrorValidationRecoveryRetrySuccess";
1121
+ ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryStateFailure"] = 4060002] = "ErrorValidationRecoveryStateFailure";
1122
+ ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryMissingRecoveryToken"] = 4060003] = "ErrorValidationRecoveryMissingRecoveryToken";
1123
+ ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryTokenInvalidOrAlreadyUsed"] = 4060004] = "ErrorValidationRecoveryTokenInvalidOrAlreadyUsed";
1124
+ ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryFlowExpired"] = 4060005] = "ErrorValidationRecoveryFlowExpired";
1125
+ ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryCodeInvalidOrAlreadyUsed"] = 4060006] = "ErrorValidationRecoveryCodeInvalidOrAlreadyUsed";
1126
+ })(ErrorValidationRecovery || (ErrorValidationRecovery = {}));
1127
+
1128
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1129
+ var ErrorValidationRegistration;
1130
+ (function(ErrorValidationRegistration) {
1131
+ ErrorValidationRegistration[ErrorValidationRegistration["ErrorValidationRegistration"] = 4040000] = "ErrorValidationRegistration";
1132
+ ErrorValidationRegistration[ErrorValidationRegistration["ErrorValidationRegistrationFlowExpired"] = 4040001] = "ErrorValidationRegistrationFlowExpired";
1133
+ })(ErrorValidationRegistration || (ErrorValidationRegistration = {}));
1134
+
1135
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1136
+ var ErrorValidationSettings;
1137
+ (function(ErrorValidationSettings) {
1138
+ ErrorValidationSettings[ErrorValidationSettings["ErrorValidationSettings"] = 4050000] = "ErrorValidationSettings";
1139
+ ErrorValidationSettings[ErrorValidationSettings["ErrorValidationSettingsFlowExpired"] = 4050001] = "ErrorValidationSettingsFlowExpired";
1140
+ })(ErrorValidationSettings || (ErrorValidationSettings = {}));
1141
+
1142
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1143
+ var ErrorValidationVerification;
1144
+ (function(ErrorValidationVerification) {
1145
+ ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerification"] = 4070000] = "ErrorValidationVerification";
1146
+ ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationTokenInvalidOrAlreadyUsed"] = 4070001] = "ErrorValidationVerificationTokenInvalidOrAlreadyUsed";
1147
+ ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationRetrySuccess"] = 4070002] = "ErrorValidationVerificationRetrySuccess";
1148
+ ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationStateFailure"] = 4070003] = "ErrorValidationVerificationStateFailure";
1149
+ ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationMissingVerificationToken"] = 4070004] = "ErrorValidationVerificationMissingVerificationToken";
1150
+ ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationFlowExpired"] = 4070005] = "ErrorValidationVerificationFlowExpired";
1151
+ ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationCodeInvalidOrAlreadyUsed"] = 4070006] = "ErrorValidationVerificationCodeInvalidOrAlreadyUsed";
1152
+ })(ErrorValidationVerification || (ErrorValidationVerification = {}));
1153
+
1154
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1155
+ var InfoNodeLabel;
1156
+ (function(InfoNodeLabel) {
1157
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabel"] = 1070000] = "InfoNodeLabel";
1158
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelInputPassword"] = 1070001] = "InfoNodeLabelInputPassword";
1159
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelGenerated"] = 1070002] = "InfoNodeLabelGenerated";
1160
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelSave"] = 1070003] = "InfoNodeLabelSave";
1161
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelID"] = 1070004] = "InfoNodeLabelID";
1162
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelSubmit"] = 1070005] = "InfoNodeLabelSubmit";
1163
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelVerifyOTP"] = 1070006] = "InfoNodeLabelVerifyOTP";
1164
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelEmail"] = 1070007] = "InfoNodeLabelEmail";
1165
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelResendOTP"] = 1070008] = "InfoNodeLabelResendOTP";
1166
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelContinue"] = 1070009] = "InfoNodeLabelContinue";
1167
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelRecoveryCode"] = 1070010] = "InfoNodeLabelRecoveryCode";
1168
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelVerificationCode"] = 1070011] = "InfoNodeLabelVerificationCode";
1169
+ })(InfoNodeLabel || (InfoNodeLabel = {}));
1170
+
1171
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1172
+ var InfoSelfServiceLogin;
1173
+ (function(InfoSelfServiceLogin) {
1174
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginRoot"] = 1010000] = "InfoSelfServiceLoginRoot";
1175
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLogin"] = 1010001] = "InfoSelfServiceLogin";
1176
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginWith"] = 1010002] = "InfoSelfServiceLoginWith";
1177
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginReAuth"] = 1010003] = "InfoSelfServiceLoginReAuth";
1178
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginMFA"] = 1010004] = "InfoSelfServiceLoginMFA";
1179
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginVerify"] = 1010005] = "InfoSelfServiceLoginVerify";
1180
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginTOTPLabel"] = 1010006] = "InfoSelfServiceLoginTOTPLabel";
1181
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoLoginLookupLabel"] = 1010007] = "InfoLoginLookupLabel";
1182
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginWebAuthn"] = 1010008] = "InfoSelfServiceLoginWebAuthn";
1183
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoLoginTOTP"] = 1010009] = "InfoLoginTOTP";
1184
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoLoginLookup"] = 1010010] = "InfoLoginLookup";
1185
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginContinueWebAuthn"] = 1010011] = "InfoSelfServiceLoginContinueWebAuthn";
1186
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginWebAuthnPasswordless"] = 1010012] = "InfoSelfServiceLoginWebAuthnPasswordless";
1187
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginContinue"] = 1010013] = "InfoSelfServiceLoginContinue";
1188
+ })(InfoSelfServiceLogin || (InfoSelfServiceLogin = {}));
1189
+
1190
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1191
+ var InfoSelfServiceRecovery;
1192
+ (function(InfoSelfServiceRecovery) {
1193
+ InfoSelfServiceRecovery[InfoSelfServiceRecovery["InfoSelfServiceRecovery"] = 1060000] = "InfoSelfServiceRecovery";
1194
+ InfoSelfServiceRecovery[InfoSelfServiceRecovery["InfoSelfServiceRecoverySuccessful"] = 1060001] = "InfoSelfServiceRecoverySuccessful";
1195
+ InfoSelfServiceRecovery[InfoSelfServiceRecovery["InfoSelfServiceRecoveryEmailSent"] = 1060002] = "InfoSelfServiceRecoveryEmailSent";
1196
+ InfoSelfServiceRecovery[InfoSelfServiceRecovery["InfoSelfServiceRecoveryEmailWithCodeSent"] = 1060003] = "InfoSelfServiceRecoveryEmailWithCodeSent";
1197
+ })(InfoSelfServiceRecovery || (InfoSelfServiceRecovery = {}));
1198
+
1199
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1200
+ var InfoSelfServiceRegistration;
1201
+ (function(InfoSelfServiceRegistration) {
1202
+ InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistrationRoot"] = 1040000] = "InfoSelfServiceRegistrationRoot";
1203
+ InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistration"] = 1040001] = "InfoSelfServiceRegistration";
1204
+ InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistrationWith"] = 1040002] = "InfoSelfServiceRegistrationWith";
1205
+ InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistrationContinue"] = 1040003] = "InfoSelfServiceRegistrationContinue";
1206
+ InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistrationRegisterWebAuthn"] = 1040004] = "InfoSelfServiceRegistrationRegisterWebAuthn";
1207
+ })(InfoSelfServiceRegistration || (InfoSelfServiceRegistration = {}));
1208
+
1209
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1210
+ var InfoSelfServiceSettings;
1211
+ (function(InfoSelfServiceSettings) {
1212
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettings"] = 1050000] = "InfoSelfServiceSettings";
1213
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsUpdateSuccess"] = 1050001] = "InfoSelfServiceSettingsUpdateSuccess";
1214
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsUpdateLinkOidc"] = 1050002] = "InfoSelfServiceSettingsUpdateLinkOidc";
1215
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsUpdateUnlinkOidc"] = 1050003] = "InfoSelfServiceSettingsUpdateUnlinkOidc";
1216
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsUpdateUnlinkTOTP"] = 1050004] = "InfoSelfServiceSettingsUpdateUnlinkTOTP";
1217
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsTOTPQRCode"] = 1050005] = "InfoSelfServiceSettingsTOTPQRCode";
1218
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsTOTPSecret"] = 1050006] = "InfoSelfServiceSettingsTOTPSecret";
1219
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRevealLookup"] = 1050007] = "InfoSelfServiceSettingsRevealLookup";
1220
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRegenerateLookup"] = 1050008] = "InfoSelfServiceSettingsRegenerateLookup";
1221
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupSecret"] = 1050009] = "InfoSelfServiceSettingsLookupSecret";
1222
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupSecretLabel"] = 1050010] = "InfoSelfServiceSettingsLookupSecretLabel";
1223
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupConfirm"] = 1050011] = "InfoSelfServiceSettingsLookupConfirm";
1224
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRegisterWebAuthn"] = 1050012] = "InfoSelfServiceSettingsRegisterWebAuthn";
1225
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRegisterWebAuthnDisplayName"] = 1050013] = "InfoSelfServiceSettingsRegisterWebAuthnDisplayName";
1226
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupSecretUsed"] = 1050014] = "InfoSelfServiceSettingsLookupSecretUsed";
1227
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupSecretList"] = 1050015] = "InfoSelfServiceSettingsLookupSecretList";
1228
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsDisableLookup"] = 1050016] = "InfoSelfServiceSettingsDisableLookup";
1229
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsTOTPSecretLabel"] = 1050017] = "InfoSelfServiceSettingsTOTPSecretLabel";
1230
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRemoveWebAuthn"] = 1050018] = "InfoSelfServiceSettingsRemoveWebAuthn";
1231
+ })(InfoSelfServiceSettings || (InfoSelfServiceSettings = {}));
1232
+
1233
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1234
+ var InfoSelfServiceVerification;
1235
+ (function(InfoSelfServiceVerification) {
1236
+ InfoSelfServiceVerification[InfoSelfServiceVerification["InfoSelfServiceVerification"] = 1080000] = "InfoSelfServiceVerification";
1237
+ InfoSelfServiceVerification[InfoSelfServiceVerification["InfoSelfServiceVerificationEmailSent"] = 1080001] = "InfoSelfServiceVerificationEmailSent";
1238
+ InfoSelfServiceVerification[InfoSelfServiceVerification["InfoSelfServiceVerificationSuccessful"] = 1080002] = "InfoSelfServiceVerificationSuccessful";
1239
+ InfoSelfServiceVerification[InfoSelfServiceVerification["InfoSelfServiceVerificationEmailWithCodeSent"] = 1080003] = "InfoSelfServiceVerificationEmailWithCodeSent";
1240
+ })(InfoSelfServiceVerification || (InfoSelfServiceVerification = {}));
1241
+
1242
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1243
+ var ErrorSystem;
1244
+ (function(ErrorSystem) {
1245
+ ErrorSystem[ErrorSystem["ErrorSystem"] = 5000000] = "ErrorSystem";
1246
+ ErrorSystem[ErrorSystem["ErrorSystemGeneric"] = 5000001] = "ErrorSystemGeneric";
1247
+ })(ErrorSystem || (ErrorSystem = {}));
1248
+ var InfoSelfServiceLogout;
1249
+ (function(InfoSelfServiceLogout) {
1250
+ InfoSelfServiceLogout[InfoSelfServiceLogout["InfoSelfServiceLogout"] = 1020000] = "InfoSelfServiceLogout";
1251
+ })(InfoSelfServiceLogout || (InfoSelfServiceLogout = {}));
1252
+ var InfoSelfServiceMFA;
1253
+ (function(InfoSelfServiceMFA) {
1254
+ InfoSelfServiceMFA[InfoSelfServiceMFA["InfoSelfServiceMFA"] = 1030000] = "InfoSelfServiceMFA";
1255
+ })(InfoSelfServiceMFA || (InfoSelfServiceMFA = {}));
1256
+
1257
+ function isUiNodeAnchorAttributes(attrs) {
1258
+ return attrs.node_type === "a";
1259
+ }
1260
+ function isUiNodeImageAttributes(attrs) {
1261
+ return attrs.node_type === "img";
1262
+ }
1263
+ function isUiNodeInputAttributes(attrs) {
1264
+ return attrs.node_type === "input";
1265
+ }
1266
+ function isUiNodeTextAttributes(attrs) {
1267
+ return attrs.node_type === "text";
1268
+ }
1269
+ function isUiNodeScriptAttributes(attrs) {
1270
+ return attrs.node_type === "script";
1271
+ }
1272
+ function isUiNodeTextSecretsAttributes(attributes) {
1273
+ return attributes.text.id === 1050015;
1274
+ }
1275
+
1276
+ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
1277
+ try {
1278
+ var info = gen[key](arg);
1279
+ var value = info.value;
1280
+ } catch (error) {
1281
+ reject(error);
1282
+ return;
1283
+ }
1284
+ if (info.done) {
1285
+ resolve(value);
1286
+ } else {
1287
+ Promise.resolve(value).then(_next, _throw);
1288
+ }
1289
+ }
1290
+ function _async_to_generator$1(fn) {
1291
+ return function() {
1292
+ var self = this, args = arguments;
1293
+ return new Promise(function(resolve, reject) {
1294
+ var gen = fn.apply(self, args);
1295
+ function _next(value) {
1296
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
1297
+ }
1298
+ function _throw(err) {
1299
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
1300
+ }
1301
+ _next(undefined);
1302
+ });
1303
+ };
1304
+ }
1305
+ function _ts_generator$1(thisArg, body) {
1306
+ var f, y, t, g, _ = {
1307
+ label: 0,
1308
+ sent: function() {
1309
+ if (t[0] & 1) throw t[1];
1310
+ return t[1];
1311
+ },
1312
+ trys: [],
1313
+ ops: []
1314
+ };
1315
+ return g = {
1316
+ next: verb(0),
1317
+ "throw": verb(1),
1318
+ "return": verb(2)
1319
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
1320
+ return this;
1321
+ }), g;
1322
+ function verb(n) {
1323
+ return function(v) {
1324
+ return step([
1325
+ n,
1326
+ v
1327
+ ]);
1328
+ };
1329
+ }
1330
+ function step(op) {
1331
+ if (f) throw new TypeError("Generator is already executing.");
1332
+ while(_)try {
1333
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1334
+ if (y = 0, t) op = [
1335
+ op[0] & 2,
1336
+ t.value
1337
+ ];
1338
+ switch(op[0]){
1339
+ case 0:
1340
+ case 1:
1341
+ t = op;
1342
+ break;
1343
+ case 4:
1344
+ _.label++;
1345
+ return {
1346
+ value: op[1],
1347
+ done: false
1348
+ };
1349
+ case 5:
1350
+ _.label++;
1351
+ y = op[1];
1352
+ op = [
1353
+ 0
1354
+ ];
1355
+ continue;
1356
+ case 7:
1357
+ op = _.ops.pop();
1358
+ _.trys.pop();
1359
+ continue;
1360
+ default:
1361
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1362
+ _ = 0;
1363
+ continue;
1364
+ }
1365
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1366
+ _.label = op[1];
1367
+ break;
1368
+ }
1369
+ if (op[0] === 6 && _.label < t[1]) {
1370
+ _.label = t[1];
1371
+ t = op;
1372
+ break;
1373
+ }
1374
+ if (t && _.label < t[2]) {
1375
+ _.label = t[2];
1376
+ _.ops.push(op);
1377
+ break;
1378
+ }
1379
+ if (t[2]) _.ops.pop();
1380
+ _.trys.pop();
1381
+ continue;
1382
+ }
1383
+ op = body.call(thisArg, _);
1384
+ } catch (e) {
1385
+ op = [
1386
+ 6,
1387
+ e
1388
+ ];
1389
+ y = 0;
1390
+ } finally{
1391
+ f = t = 0;
1392
+ }
1393
+ if (op[0] & 5) throw op[1];
1394
+ return {
1395
+ value: op[0] ? op[1] : void 0,
1396
+ done: true
1397
+ };
1398
+ }
1399
+ }
1400
+ function handleCancelError(err) {
1401
+ return _handleCancelError.apply(this, arguments);
1402
+ }
1403
+ function _handleCancelError() {
1404
+ _handleCancelError = _async_to_generator$1(function(err) {
1405
+ return _ts_generator$1(this, function(_state) {
1406
+ if (err.code !== "ERR_CANCELED") {
1407
+ throw err;
1408
+ }
1409
+ return [
1410
+ 2
1411
+ ];
1412
+ });
1413
+ });
1414
+ return _handleCancelError.apply(this, arguments);
1415
+ }
1416
+
1417
+ function _array_like_to_array$6(arr, len) {
1418
+ if (len == null || len > arr.length) len = arr.length;
1419
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1420
+ return arr2;
1421
+ }
1422
+ function _array_with_holes$5(arr) {
1423
+ if (Array.isArray(arr)) return arr;
1424
+ }
1425
+ function _iterable_to_array_limit$5(arr, i) {
1426
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1427
+ if (_i == null) return;
1428
+ var _arr = [];
1429
+ var _n = true;
1430
+ var _d = false;
1431
+ var _s, _e;
1432
+ try {
1433
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1434
+ _arr.push(_s.value);
1435
+ if (i && _arr.length === i) break;
1436
+ }
1437
+ } catch (err) {
1438
+ _d = true;
1439
+ _e = err;
1440
+ } finally{
1441
+ try {
1442
+ if (!_n && _i["return"] != null) _i["return"]();
1443
+ } finally{
1444
+ if (_d) throw _e;
1445
+ }
1446
+ }
1447
+ return _arr;
1448
+ }
1449
+ function _non_iterable_rest$5() {
1450
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1451
+ }
1452
+ function _sliced_to_array$5(arr, i) {
1453
+ return _array_with_holes$5(arr) || _iterable_to_array_limit$5(arr, i) || _unsupported_iterable_to_array$6(arr, i) || _non_iterable_rest$5();
1454
+ }
1455
+ function _unsupported_iterable_to_array$6(o, minLen) {
1456
+ if (!o) return;
1457
+ if (typeof o === "string") return _array_like_to_array$6(o, minLen);
1458
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1459
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1460
+ if (n === "Map" || n === "Set") return Array.from(n);
1461
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
1462
+ }
1463
+ /**
1464
+ * Manages Kratos reauthentication flow for elevated security operations.
1465
+ *
1466
+ * Handles reauthentication flow creation and submission for operations requiring
1467
+ * fresh authentication, such as changing passwords or accessing sensitive data.
1468
+ *
1469
+ * @param kratosClient - Configured Kratos FrontendApi client
1470
+ * @param onReauthenticated - Callback executed with session after successful reauthentication
1471
+ * @returns Object with current flow and submit function
1472
+ * @example
1473
+ * ```typescript
1474
+ * import { useReauthenticationFlow } from '@leancodepl/kratos';
1475
+ *
1476
+ * function ReauthForm() {
1477
+ * const { flow, submit } = useReauthenticationFlow({
1478
+ * kratosClient,
1479
+ * onReauthenticated: (session) => navigate('/secure-area')
1480
+ * });
1481
+ *
1482
+ * return <form onSubmit={submit}>...</form>;
1483
+ * }
1484
+ * ```
1485
+ */ function useReauthenticationFlow(param) {
1486
+ var kratosClient = param.kratosClient, onReauthenticated = param.onReauthenticated;
1487
+ var useHandleFlowError = useKratosContext().useHandleFlowError;
1488
+ var _useState = _sliced_to_array$5(useState(), 2), flow = _useState[0], setFlow = _useState[1];
1489
+ var handleFlowError = useHandleFlowError({
1490
+ resetFlow: useCallback(function() {
1491
+ return void setFlow(undefined);
1492
+ }, [])
1493
+ });
1494
+ useEffect(function() {
1495
+ if (flow) return;
1496
+ var controller = new AbortController();
1497
+ kratosClient.createBrowserLoginFlow({
1498
+ refresh: true
1499
+ }, {
1500
+ signal: controller.signal
1501
+ }).then(function(param) {
1502
+ var data = param.data;
1503
+ return setFlow(data);
1504
+ }).catch(handleFlowError);
1505
+ return function() {
1506
+ controller.abort();
1507
+ };
1508
+ }, [
1509
+ flow,
1510
+ handleFlowError,
1511
+ kratosClient
1512
+ ]);
1513
+ var submit = useCallback(function(values) {
1514
+ if (!flow) return;
1515
+ return kratosClient.updateLoginFlow({
1516
+ flow: flow.id,
1517
+ updateLoginFlowBody: values
1518
+ }).then(function(param) {
1519
+ var data = param.data;
1520
+ return onReauthenticated(data.session);
1521
+ }).catch(handleCancelError).catch(handleFlowError).catch(function(err) {
1522
+ var _err_response;
1523
+ if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
1524
+ var _err_response1;
1525
+ var flow = err === null || err === void 0 ? void 0 : (_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data;
1526
+ setFlow(flow);
1527
+ return;
1528
+ }
1529
+ return Promise.reject(err);
1530
+ });
1531
+ }, [
1532
+ flow,
1533
+ kratosClient,
1534
+ handleFlowError,
1535
+ onReauthenticated
1536
+ ]);
1537
+ return {
1538
+ flow: flow,
1539
+ submit: submit
1540
+ };
1541
+ }
1542
+
1543
+ function _array_like_to_array$5(arr, len) {
1544
+ if (len == null || len > arr.length) len = arr.length;
1545
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1546
+ return arr2;
1547
+ }
1548
+ function _array_with_holes$4(arr) {
1549
+ if (Array.isArray(arr)) return arr;
1550
+ }
1551
+ function _define_property$f(obj, key, value) {
1552
+ if (key in obj) {
1553
+ Object.defineProperty(obj, key, {
1554
+ value: value,
1555
+ enumerable: true,
1556
+ configurable: true,
1557
+ writable: true
1558
+ });
1559
+ } else {
1560
+ obj[key] = value;
1561
+ }
1562
+ return obj;
1563
+ }
1564
+ function _iterable_to_array_limit$4(arr, i) {
1565
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1566
+ if (_i == null) return;
1567
+ var _arr = [];
1568
+ var _n = true;
1569
+ var _d = false;
1570
+ var _s, _e;
1571
+ try {
1572
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1573
+ _arr.push(_s.value);
1574
+ if (i && _arr.length === i) break;
1575
+ }
1576
+ } catch (err) {
1577
+ _d = true;
1578
+ _e = err;
1579
+ } finally{
1580
+ try {
1581
+ if (!_n && _i["return"] != null) _i["return"]();
1582
+ } finally{
1583
+ if (_d) throw _e;
1584
+ }
1585
+ }
1586
+ return _arr;
1587
+ }
1588
+ function _non_iterable_rest$4() {
1589
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1590
+ }
1591
+ function _object_spread$f(target) {
1592
+ for(var i = 1; i < arguments.length; i++){
1593
+ var source = arguments[i] != null ? arguments[i] : {};
1594
+ var ownKeys = Object.keys(source);
1595
+ if (typeof Object.getOwnPropertySymbols === "function") {
1596
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1597
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1598
+ }));
1599
+ }
1600
+ ownKeys.forEach(function(key) {
1601
+ _define_property$f(target, key, source[key]);
1602
+ });
1603
+ }
1604
+ return target;
1605
+ }
1606
+ function ownKeys$c(object, enumerableOnly) {
1607
+ var keys = Object.keys(object);
1608
+ if (Object.getOwnPropertySymbols) {
1609
+ var symbols = Object.getOwnPropertySymbols(object);
1610
+ keys.push.apply(keys, symbols);
1611
+ }
1612
+ return keys;
1613
+ }
1614
+ function _object_spread_props$c(target, source) {
1615
+ source = source != null ? source : {};
1616
+ if (Object.getOwnPropertyDescriptors) {
1617
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1618
+ } else {
1619
+ ownKeys$c(Object(source)).forEach(function(key) {
1620
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1621
+ });
1622
+ }
1623
+ return target;
1624
+ }
1625
+ function _object_without_properties$5(source, excluded) {
1626
+ if (source == null) return {};
1627
+ var target = _object_without_properties_loose$5(source, excluded);
1628
+ var key, i;
1629
+ if (Object.getOwnPropertySymbols) {
1630
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
1631
+ for(i = 0; i < sourceSymbolKeys.length; i++){
1632
+ key = sourceSymbolKeys[i];
1633
+ if (excluded.indexOf(key) >= 0) continue;
1634
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1635
+ target[key] = source[key];
1636
+ }
1637
+ }
1638
+ return target;
1639
+ }
1640
+ function _object_without_properties_loose$5(source, excluded) {
1641
+ if (source == null) return {};
1642
+ var target = {};
1643
+ var sourceKeys = Object.keys(source);
1644
+ var key, i;
1645
+ for(i = 0; i < sourceKeys.length; i++){
1646
+ key = sourceKeys[i];
1647
+ if (excluded.indexOf(key) >= 0) continue;
1648
+ target[key] = source[key];
1649
+ }
1650
+ return target;
1651
+ }
1652
+ function _sliced_to_array$4(arr, i) {
1653
+ return _array_with_holes$4(arr) || _iterable_to_array_limit$4(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest$4();
1654
+ }
1655
+ function _to_primitive$3(input, hint) {
1656
+ if (_type_of$3(input) !== "object" || input === null) return input;
1657
+ var prim = input[Symbol.toPrimitive];
1658
+ if (prim !== undefined) {
1659
+ var res = prim.call(input, hint);
1660
+ if (_type_of$3(res) !== "object") return res;
1661
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1662
+ }
1663
+ return (String )(input);
1664
+ }
1665
+ function _to_property_key$3(arg) {
1666
+ var key = _to_primitive$3(arg, "string");
1667
+ return _type_of$3(key) === "symbol" ? key : String(key);
1668
+ }
1669
+ function _type_of$3(obj) {
1670
+ "@swc/helpers - typeof";
1671
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1672
+ }
1673
+ function _unsupported_iterable_to_array$5(o, minLen) {
1674
+ if (!o) return;
1675
+ if (typeof o === "string") return _array_like_to_array$5(o, minLen);
1676
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1677
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1678
+ if (n === "Map" || n === "Set") return Array.from(n);
1679
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
1680
+ }
1681
+ /**
1682
+ * Manages Kratos account recovery flow state and form submission.
1683
+ *
1684
+ * Handles recovery flow creation, retrieval, and submission with automatic error handling,
1685
+ * URL parameter management, and continue-with callbacks for post-recovery actions.
1686
+ *
1687
+ * @param kratosClient - Configured Kratos FrontendApi client
1688
+ * @param onSessionAlreadyAvailable - Callback when session already exists
1689
+ * @param onContinueWith - Optional callback for post-recovery actions
1690
+ * @param searchParams - URL search parameters for flow state
1691
+ * @param updateSearchParams - Function to update URL search parameters
1692
+ * @returns Object with current flow, submit function, and recovery status
1693
+ * @example
1694
+ * ```typescript
1695
+ * import { useRecoveryFlow } from '@leancodepl/kratos';
1696
+ *
1697
+ * function RecoveryForm() {
1698
+ * const { flow, submit, isRecovering } = useRecoveryFlow({
1699
+ * kratosClient,
1700
+ * onSessionAlreadyAvailable: () => navigate('/dashboard'),
1701
+ * updateSearchParams: (params) => setSearchParams(params)
1702
+ * });
1703
+ *
1704
+ * return <form onSubmit={submit}>...</form>;
1705
+ * }
1706
+ * ```
1707
+ */ function useRecoveryFlow(param) {
1708
+ var kratosClient = param.kratosClient, onSessionAlreadyAvailable = param.onSessionAlreadyAvailable, onContinueWith = param.onContinueWith, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
1709
+ var useHandleFlowError = useKratosContext().useHandleFlowError;
1710
+ var _useState = _sliced_to_array$4(useState(), 2), flow = _useState[0], setFlow = _useState[1];
1711
+ var flowId = searchParams[flowIdParameterName], returnTo = searchParams[returnToParameterName];
1712
+ var _obj;
1713
+ var handleFlowError = useHandleFlowError((_obj = {}, _define_property$f(_obj, "resetFlow", useCallback(function() {
1714
+ searchParams[flowIdParameterName]; var newParams = _object_without_properties$5(searchParams, [
1715
+ flowIdParameterName
1716
+ ].map(_to_property_key$3));
1717
+ updateSearchParams(newParams);
1718
+ setFlow(undefined);
1719
+ }, [
1720
+ searchParams,
1721
+ updateSearchParams
1722
+ ])), _define_property$f(_obj, "onSessionAlreadyAvailable", onSessionAlreadyAvailable), _obj));
1723
+ useEffect(function() {
1724
+ if (flow) return;
1725
+ var controller = new AbortController();
1726
+ if (flowId) {
1727
+ kratosClient.getRecoveryFlow({
1728
+ id: flowId
1729
+ }, {
1730
+ signal: controller.signal
1731
+ }).then(function(param) {
1732
+ var data = param.data;
1733
+ return setFlow(data);
1734
+ }).catch(handleCancelError).catch(handleFlowError);
1735
+ return;
1736
+ } else {
1737
+ kratosClient.createBrowserRecoveryFlow({
1738
+ returnTo: returnTo
1739
+ }, {
1740
+ signal: controller.signal
1741
+ }).then(function(param) {
1742
+ var data = param.data;
1743
+ return setFlow(data);
1744
+ }).catch(handleCancelError).catch(handleFlowError);
1745
+ }
1746
+ return function() {
1747
+ controller.abort();
1748
+ };
1749
+ }, [
1750
+ flowId,
1751
+ returnTo,
1752
+ flow,
1753
+ handleFlowError,
1754
+ kratosClient
1755
+ ]);
1756
+ var submit = useCallback(function(param) {
1757
+ var body = param.body;
1758
+ if (!flow) return;
1759
+ updateSearchParams(_object_spread_props$c(_object_spread$f({}, searchParams), _define_property$f({}, flowIdParameterName, flow.id)));
1760
+ return kratosClient.updateRecoveryFlow({
1761
+ flow: flow.id,
1762
+ updateRecoveryFlowBody: body
1763
+ }).then(function(param) {
1764
+ var data = param.data;
1765
+ setFlow(data);
1766
+ if (data.continue_with) {
1767
+ onContinueWith === null || onContinueWith === void 0 ? void 0 : onContinueWith(data.continue_with);
1768
+ }
1769
+ }).catch(handleFlowError).catch(function(err) {
1770
+ var _err_response;
1771
+ if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
1772
+ var _err_response1;
1773
+ setFlow((_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
1774
+ return;
1775
+ }
1776
+ return Promise.reject(err);
1777
+ });
1778
+ }, [
1779
+ flow,
1780
+ updateSearchParams,
1781
+ searchParams,
1782
+ kratosClient,
1783
+ handleFlowError,
1784
+ onContinueWith
1785
+ ]);
1786
+ return {
1787
+ flow: flow,
1788
+ submit: submit,
1789
+ isRecovering: (flow === null || flow === void 0 ? void 0 : flow.state) === "sent_email"
1790
+ };
1791
+ }
1792
+
1793
+ function _array_like_to_array$4(arr, len) {
1794
+ if (len == null || len > arr.length) len = arr.length;
1795
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1796
+ return arr2;
1797
+ }
1798
+ function _array_with_holes$3(arr) {
1799
+ if (Array.isArray(arr)) return arr;
1800
+ }
1801
+ function _define_property$e(obj, key, value) {
1802
+ if (key in obj) {
1803
+ Object.defineProperty(obj, key, {
1804
+ value: value,
1805
+ enumerable: true,
1806
+ configurable: true,
1807
+ writable: true
1808
+ });
1809
+ } else {
1810
+ obj[key] = value;
1811
+ }
1812
+ return obj;
1813
+ }
1814
+ function _iterable_to_array_limit$3(arr, i) {
1815
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1816
+ if (_i == null) return;
1817
+ var _arr = [];
1818
+ var _n = true;
1819
+ var _d = false;
1820
+ var _s, _e;
1821
+ try {
1822
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1823
+ _arr.push(_s.value);
1824
+ if (i && _arr.length === i) break;
1825
+ }
1826
+ } catch (err) {
1827
+ _d = true;
1828
+ _e = err;
1829
+ } finally{
1830
+ try {
1831
+ if (!_n && _i["return"] != null) _i["return"]();
1832
+ } finally{
1833
+ if (_d) throw _e;
1834
+ }
1835
+ }
1836
+ return _arr;
1837
+ }
1838
+ function _non_iterable_rest$3() {
1839
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1840
+ }
1841
+ function _object_spread$e(target) {
1842
+ for(var i = 1; i < arguments.length; i++){
1843
+ var source = arguments[i] != null ? arguments[i] : {};
1844
+ var ownKeys = Object.keys(source);
1845
+ if (typeof Object.getOwnPropertySymbols === "function") {
1846
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1847
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1848
+ }));
1849
+ }
1850
+ ownKeys.forEach(function(key) {
1851
+ _define_property$e(target, key, source[key]);
1852
+ });
1853
+ }
1854
+ return target;
1855
+ }
1856
+ function ownKeys$b(object, enumerableOnly) {
1857
+ var keys = Object.keys(object);
1858
+ if (Object.getOwnPropertySymbols) {
1859
+ var symbols = Object.getOwnPropertySymbols(object);
1860
+ keys.push.apply(keys, symbols);
1861
+ }
1862
+ return keys;
1863
+ }
1864
+ function _object_spread_props$b(target, source) {
1865
+ source = source != null ? source : {};
1866
+ if (Object.getOwnPropertyDescriptors) {
1867
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1868
+ } else {
1869
+ ownKeys$b(Object(source)).forEach(function(key) {
1870
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1871
+ });
1872
+ }
1873
+ return target;
1874
+ }
1875
+ function _object_without_properties$4(source, excluded) {
1876
+ if (source == null) return {};
1877
+ var target = _object_without_properties_loose$4(source, excluded);
1878
+ var key, i;
1879
+ if (Object.getOwnPropertySymbols) {
1880
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
1881
+ for(i = 0; i < sourceSymbolKeys.length; i++){
1882
+ key = sourceSymbolKeys[i];
1883
+ if (excluded.indexOf(key) >= 0) continue;
1884
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1885
+ target[key] = source[key];
1886
+ }
1887
+ }
1888
+ return target;
1889
+ }
1890
+ function _object_without_properties_loose$4(source, excluded) {
1891
+ if (source == null) return {};
1892
+ var target = {};
1893
+ var sourceKeys = Object.keys(source);
1894
+ var key, i;
1895
+ for(i = 0; i < sourceKeys.length; i++){
1896
+ key = sourceKeys[i];
1897
+ if (excluded.indexOf(key) >= 0) continue;
1898
+ target[key] = source[key];
1899
+ }
1900
+ return target;
1901
+ }
1902
+ function _sliced_to_array$3(arr, i) {
1903
+ return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$4(arr, i) || _non_iterable_rest$3();
1904
+ }
1905
+ function _to_primitive$2(input, hint) {
1906
+ if (_type_of$2(input) !== "object" || input === null) return input;
1907
+ var prim = input[Symbol.toPrimitive];
1908
+ if (prim !== undefined) {
1909
+ var res = prim.call(input, hint);
1910
+ if (_type_of$2(res) !== "object") return res;
1911
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1912
+ }
1913
+ return (String )(input);
1914
+ }
1915
+ function _to_property_key$2(arg) {
1916
+ var key = _to_primitive$2(arg, "string");
1917
+ return _type_of$2(key) === "symbol" ? key : String(key);
1918
+ }
1919
+ function _type_of$2(obj) {
1920
+ "@swc/helpers - typeof";
1921
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1922
+ }
1923
+ function _unsupported_iterable_to_array$4(o, minLen) {
1924
+ if (!o) return;
1925
+ if (typeof o === "string") return _array_like_to_array$4(o, minLen);
1926
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1927
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1928
+ if (n === "Map" || n === "Set") return Array.from(n);
1929
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
1930
+ }
1931
+ /**
1932
+ * Manages Kratos user settings flow state and form submission.
1933
+ *
1934
+ * Handles settings flow creation, retrieval, and submission for profile updates,
1935
+ * password changes, and security settings management.
1936
+ *
1937
+ * @param kratosClient - Configured Kratos FrontendApi client
1938
+ * @param params - Optional Axios request parameters
1939
+ * @param onContinueWith - Optional callback for post-settings actions
1940
+ * @param searchParams - URL search parameters for flow state
1941
+ * @param updateSearchParams - Function to update URL search parameters
1942
+ * @returns Object with current flow and submit function
1943
+ * @example
1944
+ * ```typescript
1945
+ * import { useSettingsFlow } from '@leancodepl/kratos';
1946
+ *
1947
+ * function UserSettingsForm() {
1948
+ * const { flow, submit } = useSettingsFlow({
1949
+ * kratosClient,
1950
+ * onContinueWith: (actions) => console.log('Settings updated'),
1951
+ * updateSearchParams: (params) => setSearchParams(params)
1952
+ * });
1953
+ *
1954
+ * return <form onSubmit={submit}>...</form>;
1955
+ * }
1956
+ * ```
1957
+ */ function useSettingsFlow(param) {
1958
+ var kratosClient = param.kratosClient, params = param.params, onContinueWith = param.onContinueWith, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
1959
+ var useHandleFlowError = useKratosContext().useHandleFlowError;
1960
+ var _useState = _sliced_to_array$3(useState(), 2), flow = _useState[0], setFlow = _useState[1];
1961
+ var flowId = searchParams[flowIdParameterName], returnTo = searchParams[returnToParameterName];
1962
+ var handleFlowError = useHandleFlowError(_define_property$e({}, "resetFlow", useCallback(function() {
1963
+ searchParams[flowIdParameterName]; var newParams = _object_without_properties$4(searchParams, [
1964
+ flowIdParameterName
1965
+ ].map(_to_property_key$2));
1966
+ updateSearchParams(newParams);
1967
+ setFlow(undefined);
1968
+ }, [
1969
+ searchParams,
1970
+ updateSearchParams
1971
+ ])));
1972
+ useEffect(function() {
1973
+ if (flow) return;
1974
+ var controller = new AbortController();
1975
+ if (flowId) {
1976
+ kratosClient.getSettingsFlow({
1977
+ id: flowId
1978
+ }, {
1979
+ signal: controller.signal
1980
+ }).then(function(param) {
1981
+ var data = param.data;
1982
+ return setFlow(data);
1983
+ }).catch(handleCancelError).catch(handleFlowError);
1984
+ } else {
1985
+ kratosClient.createBrowserSettingsFlow({
1986
+ returnTo: returnTo
1987
+ }, {
1988
+ params: params,
1989
+ signal: controller.signal
1990
+ }).then(function(param) {
1991
+ var data = param.data;
1992
+ return setFlow(data);
1993
+ }).catch(handleCancelError).catch(handleFlowError);
1994
+ }
1995
+ return function() {
1996
+ controller.abort();
1997
+ };
1998
+ }, [
1999
+ flow,
2000
+ flowId,
2001
+ handleFlowError,
2002
+ kratosClient,
2003
+ params,
2004
+ returnTo
2005
+ ]);
2006
+ var submit = useCallback(function(param) {
2007
+ var body = param.body;
2008
+ if (!flow) return;
2009
+ updateSearchParams(_object_spread_props$b(_object_spread$e({}, searchParams), _define_property$e({}, flowIdParameterName, flow.id)));
2010
+ return kratosClient.updateSettingsFlow({
2011
+ flow: flow.id,
2012
+ updateSettingsFlowBody: body
2013
+ }).then(function(param) {
2014
+ var data = param.data;
2015
+ if (flow.return_to) {
2016
+ window.location.href = flow.return_to;
2017
+ return;
2018
+ }
2019
+ setFlow(data);
2020
+ if (data.continue_with) {
2021
+ onContinueWith === null || onContinueWith === void 0 ? void 0 : onContinueWith(data.continue_with);
2022
+ }
2023
+ }).catch(handleFlowError).catch(function(err) {
2024
+ var _err_response;
2025
+ if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
2026
+ var _err_response1;
2027
+ setFlow((_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
2028
+ return;
2029
+ }
2030
+ return Promise.reject(err);
2031
+ });
2032
+ }, [
2033
+ flow,
2034
+ updateSearchParams,
2035
+ searchParams,
2036
+ kratosClient,
2037
+ handleFlowError,
2038
+ onContinueWith
2039
+ ]);
2040
+ return {
2041
+ flow: flow,
2042
+ submit: submit
2043
+ };
2044
+ }
2045
+
2046
+ function _array_like_to_array$3(arr, len) {
2047
+ if (len == null || len > arr.length) len = arr.length;
2048
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
2049
+ return arr2;
2050
+ }
2051
+ function _array_with_holes$2(arr) {
2052
+ if (Array.isArray(arr)) return arr;
2053
+ }
2054
+ function _define_property$d(obj, key, value) {
2055
+ if (key in obj) {
2056
+ Object.defineProperty(obj, key, {
2057
+ value: value,
2058
+ enumerable: true,
2059
+ configurable: true,
2060
+ writable: true
2061
+ });
2062
+ } else {
2063
+ obj[key] = value;
2064
+ }
2065
+ return obj;
2066
+ }
2067
+ function _iterable_to_array_limit$2(arr, i) {
2068
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
2069
+ if (_i == null) return;
2070
+ var _arr = [];
2071
+ var _n = true;
2072
+ var _d = false;
2073
+ var _s, _e;
2074
+ try {
2075
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
2076
+ _arr.push(_s.value);
2077
+ if (i && _arr.length === i) break;
2078
+ }
2079
+ } catch (err) {
2080
+ _d = true;
2081
+ _e = err;
2082
+ } finally{
2083
+ try {
2084
+ if (!_n && _i["return"] != null) _i["return"]();
2085
+ } finally{
2086
+ if (_d) throw _e;
2087
+ }
2088
+ }
2089
+ return _arr;
2090
+ }
2091
+ function _non_iterable_rest$2() {
2092
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2093
+ }
2094
+ function _object_spread$d(target) {
2095
+ for(var i = 1; i < arguments.length; i++){
2096
+ var source = arguments[i] != null ? arguments[i] : {};
2097
+ var ownKeys = Object.keys(source);
2098
+ if (typeof Object.getOwnPropertySymbols === "function") {
2099
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
2100
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
2101
+ }));
2102
+ }
2103
+ ownKeys.forEach(function(key) {
2104
+ _define_property$d(target, key, source[key]);
2105
+ });
2106
+ }
2107
+ return target;
2108
+ }
2109
+ function ownKeys$a(object, enumerableOnly) {
2110
+ var keys = Object.keys(object);
2111
+ if (Object.getOwnPropertySymbols) {
2112
+ var symbols = Object.getOwnPropertySymbols(object);
2113
+ keys.push.apply(keys, symbols);
2114
+ }
2115
+ return keys;
2116
+ }
2117
+ function _object_spread_props$a(target, source) {
2118
+ source = source != null ? source : {};
2119
+ if (Object.getOwnPropertyDescriptors) {
2120
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
2121
+ } else {
2122
+ ownKeys$a(Object(source)).forEach(function(key) {
2123
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2124
+ });
2125
+ }
2126
+ return target;
2127
+ }
2128
+ function _object_without_properties$3(source, excluded) {
2129
+ if (source == null) return {};
2130
+ var target = _object_without_properties_loose$3(source, excluded);
2131
+ var key, i;
2132
+ if (Object.getOwnPropertySymbols) {
2133
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
2134
+ for(i = 0; i < sourceSymbolKeys.length; i++){
2135
+ key = sourceSymbolKeys[i];
2136
+ if (excluded.indexOf(key) >= 0) continue;
2137
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
2138
+ target[key] = source[key];
2139
+ }
2140
+ }
2141
+ return target;
2142
+ }
2143
+ function _object_without_properties_loose$3(source, excluded) {
2144
+ if (source == null) return {};
2145
+ var target = {};
2146
+ var sourceKeys = Object.keys(source);
2147
+ var key, i;
2148
+ for(i = 0; i < sourceKeys.length; i++){
2149
+ key = sourceKeys[i];
2150
+ if (excluded.indexOf(key) >= 0) continue;
2151
+ target[key] = source[key];
2152
+ }
2153
+ return target;
2154
+ }
2155
+ function _sliced_to_array$2(arr, i) {
2156
+ return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$2();
2157
+ }
2158
+ function _to_primitive$1(input, hint) {
2159
+ if (_type_of$1(input) !== "object" || input === null) return input;
2160
+ var prim = input[Symbol.toPrimitive];
2161
+ if (prim !== undefined) {
2162
+ var res = prim.call(input, hint);
2163
+ if (_type_of$1(res) !== "object") return res;
2164
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2165
+ }
2166
+ return (String )(input);
2167
+ }
2168
+ function _to_property_key$1(arg) {
2169
+ var key = _to_primitive$1(arg, "string");
2170
+ return _type_of$1(key) === "symbol" ? key : String(key);
2171
+ }
2172
+ function _type_of$1(obj) {
2173
+ "@swc/helpers - typeof";
2174
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
2175
+ }
2176
+ function _unsupported_iterable_to_array$3(o, minLen) {
2177
+ if (!o) return;
2178
+ if (typeof o === "string") return _array_like_to_array$3(o, minLen);
2179
+ var n = Object.prototype.toString.call(o).slice(8, -1);
2180
+ if (n === "Object" && o.constructor) n = o.constructor.name;
2181
+ if (n === "Map" || n === "Set") return Array.from(n);
2182
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
2183
+ }
2184
+ /**
2185
+ * Manages Kratos login flow state and form submission.
2186
+ *
2187
+ * Handles login flow creation, retrieval, and submission with automatic error handling,
2188
+ * URL parameter management, and session callbacks. Supports multi-factor authentication
2189
+ * and refresh flows.
2190
+ *
2191
+ * @param kratosClient - Configured Kratos FrontendApi client
2192
+ * @param returnTo - URL to redirect after successful login
2193
+ * @param onLoggedIn - Callback executed when user successfully logs in
2194
+ * @param onSessionAlreadyAvailable - Callback when session already exists
2195
+ * @param searchParams - URL search parameters for flow state
2196
+ * @param updateSearchParams - Function to update URL search parameters
2197
+ * @returns Object with current flow and submit function
2198
+ * @example
2199
+ * ```typescript
2200
+ * import { useLoginFlow } from '@leancodepl/kratos';
2201
+ *
2202
+ * function LoginForm() {
2203
+ * const { flow, submit } = useLoginFlow({
2204
+ * kratosClient,
2205
+ * onLoggedIn: (session) => navigate('/dashboard'),
2206
+ * updateSearchParams: (params) => setSearchParams(params)
2207
+ * });
2208
+ *
2209
+ * return <form onSubmit={submit}>...</form>;
2210
+ * }
2211
+ * ```
2212
+ */ function useLoginFlow(param) {
2213
+ var kratosClient = param.kratosClient, returnTo = param.returnTo, onLoggedIn = param.onLoggedIn, onSessionAlreadyAvailable = param.onSessionAlreadyAvailable, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
2214
+ var useHandleFlowError = useKratosContext().useHandleFlowError;
2215
+ var _useState = _sliced_to_array$2(useState(), 2), flow = _useState[0], setFlow = _useState[1];
2216
+ var flowId = searchParams[flowIdParameterName], returnToFromSearch = searchParams[returnToParameterName], refresh = searchParams[refreshParameterName], authorizationAssuranceLevel = searchParams[aalParameterName];
2217
+ useEffect(function() {
2218
+ setFlow(undefined);
2219
+ }, [
2220
+ authorizationAssuranceLevel
2221
+ ]);
2222
+ var _obj;
2223
+ var handleFlowError = useHandleFlowError((_obj = {}, _define_property$d(_obj, "resetFlow", useCallback(function() {
2224
+ searchParams[flowIdParameterName]; searchParams[aalParameterName]; var newParams = _object_without_properties$3(searchParams, [
2225
+ flowIdParameterName,
2226
+ aalParameterName
2227
+ ].map(_to_property_key$1));
2228
+ updateSearchParams(newParams);
2229
+ setFlow(undefined);
2230
+ }, [
2231
+ searchParams,
2232
+ updateSearchParams
2233
+ ])), _define_property$d(_obj, "onSessionAlreadyAvailable", onSessionAlreadyAvailable), _obj));
2234
+ useEffect(function() {
2235
+ if (flow) return;
2236
+ var controller = new AbortController();
2237
+ if (flowId) {
2238
+ kratosClient.getLoginFlow({
2239
+ id: flowId
2240
+ }, {
2241
+ signal: controller.signal
2242
+ }).then(function(param) {
2243
+ var data = param.data;
2244
+ return setFlow(data);
2245
+ }).catch(handleCancelError).catch(handleFlowError);
2246
+ } else {
2247
+ kratosClient.createBrowserLoginFlow({
2248
+ aal: authorizationAssuranceLevel,
2249
+ refresh: yn(refresh),
2250
+ returnTo: returnTo !== null && returnTo !== void 0 ? returnTo : returnToFromSearch
2251
+ }, {
2252
+ signal: controller.signal
2253
+ }).then(function(param) {
2254
+ var data = param.data;
2255
+ return setFlow(data);
2256
+ }).catch(handleCancelError).catch(handleFlowError);
2257
+ }
2258
+ return function() {
2259
+ controller.abort();
2260
+ };
2261
+ }, [
2262
+ authorizationAssuranceLevel,
2263
+ flow,
2264
+ flowId,
2265
+ handleFlowError,
2266
+ kratosClient,
2267
+ refresh,
2268
+ returnTo,
2269
+ returnToFromSearch
2270
+ ]);
2271
+ var submit = useCallback(function(param) {
2272
+ var body = param.body;
2273
+ if (!flow) return;
2274
+ updateSearchParams(_object_spread_props$a(_object_spread$d({}, searchParams), _define_property$d({}, flowIdParameterName, flow.id)));
2275
+ kratosClient.updateLoginFlow({
2276
+ flow: flow.id,
2277
+ updateLoginFlowBody: body
2278
+ }).then(function(param) {
2279
+ var data = param.data;
2280
+ if (flow.return_to) {
2281
+ window.location.href = flow.return_to;
2282
+ return;
2283
+ }
2284
+ onLoggedIn === null || onLoggedIn === void 0 ? void 0 : onLoggedIn(data.session);
2285
+ }).catch(handleFlowError).catch(function(err) {
2286
+ var _err_response;
2287
+ if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
2288
+ var _err_response1;
2289
+ setFlow(err === null || err === void 0 ? void 0 : (_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
2290
+ return;
2291
+ }
2292
+ return Promise.reject(err);
2293
+ });
2294
+ }, [
2295
+ flow,
2296
+ updateSearchParams,
2297
+ searchParams,
2298
+ kratosClient,
2299
+ handleFlowError,
2300
+ onLoggedIn
2301
+ ]);
2302
+ return {
2303
+ flow: flow,
2304
+ submit: submit
2305
+ };
2306
+ }
2307
+
2308
+ function _array_like_to_array$2(arr, len) {
2309
+ if (len == null || len > arr.length) len = arr.length;
2310
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
2311
+ return arr2;
2312
+ }
2313
+ function _array_with_holes$1(arr) {
2314
+ if (Array.isArray(arr)) return arr;
2315
+ }
2316
+ function _define_property$c(obj, key, value) {
2317
+ if (key in obj) {
2318
+ Object.defineProperty(obj, key, {
2319
+ value: value,
2320
+ enumerable: true,
2321
+ configurable: true,
2322
+ writable: true
2323
+ });
2324
+ } else {
2325
+ obj[key] = value;
2326
+ }
2327
+ return obj;
2328
+ }
2329
+ function _iterable_to_array_limit$1(arr, i) {
2330
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
2331
+ if (_i == null) return;
2332
+ var _arr = [];
2333
+ var _n = true;
2334
+ var _d = false;
2335
+ var _s, _e;
2336
+ try {
2337
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
2338
+ _arr.push(_s.value);
2339
+ if (i && _arr.length === i) break;
2340
+ }
2341
+ } catch (err) {
2342
+ _d = true;
2343
+ _e = err;
2344
+ } finally{
2345
+ try {
2346
+ if (!_n && _i["return"] != null) _i["return"]();
2347
+ } finally{
2348
+ if (_d) throw _e;
2349
+ }
2350
+ }
2351
+ return _arr;
2352
+ }
2353
+ function _non_iterable_rest$1() {
2354
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2355
+ }
2356
+ function _object_spread$c(target) {
2357
+ for(var i = 1; i < arguments.length; i++){
2358
+ var source = arguments[i] != null ? arguments[i] : {};
2359
+ var ownKeys = Object.keys(source);
2360
+ if (typeof Object.getOwnPropertySymbols === "function") {
2361
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
2362
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
2363
+ }));
2364
+ }
2365
+ ownKeys.forEach(function(key) {
2366
+ _define_property$c(target, key, source[key]);
2367
+ });
2368
+ }
2369
+ return target;
2370
+ }
2371
+ function ownKeys$9(object, enumerableOnly) {
2372
+ var keys = Object.keys(object);
2373
+ if (Object.getOwnPropertySymbols) {
2374
+ var symbols = Object.getOwnPropertySymbols(object);
2375
+ keys.push.apply(keys, symbols);
2376
+ }
2377
+ return keys;
2378
+ }
2379
+ function _object_spread_props$9(target, source) {
2380
+ source = source != null ? source : {};
2381
+ if (Object.getOwnPropertyDescriptors) {
2382
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
2383
+ } else {
2384
+ ownKeys$9(Object(source)).forEach(function(key) {
2385
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2386
+ });
2387
+ }
2388
+ return target;
2389
+ }
2390
+ function _object_without_properties$2(source, excluded) {
2391
+ if (source == null) return {};
2392
+ var target = _object_without_properties_loose$2(source, excluded);
2393
+ var key, i;
2394
+ if (Object.getOwnPropertySymbols) {
2395
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
2396
+ for(i = 0; i < sourceSymbolKeys.length; i++){
2397
+ key = sourceSymbolKeys[i];
2398
+ if (excluded.indexOf(key) >= 0) continue;
2399
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
2400
+ target[key] = source[key];
2401
+ }
2402
+ }
2403
+ return target;
2404
+ }
2405
+ function _object_without_properties_loose$2(source, excluded) {
2406
+ if (source == null) return {};
2407
+ var target = {};
2408
+ var sourceKeys = Object.keys(source);
2409
+ var key, i;
2410
+ for(i = 0; i < sourceKeys.length; i++){
2411
+ key = sourceKeys[i];
2412
+ if (excluded.indexOf(key) >= 0) continue;
2413
+ target[key] = source[key];
2414
+ }
2415
+ return target;
2416
+ }
2417
+ function _sliced_to_array$1(arr, i) {
2418
+ return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$1();
2419
+ }
2420
+ function _to_primitive(input, hint) {
2421
+ if (_type_of(input) !== "object" || input === null) return input;
2422
+ var prim = input[Symbol.toPrimitive];
2423
+ if (prim !== undefined) {
2424
+ var res = prim.call(input, hint);
2425
+ if (_type_of(res) !== "object") return res;
2426
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2427
+ }
2428
+ return (String )(input);
2429
+ }
2430
+ function _to_property_key(arg) {
2431
+ var key = _to_primitive(arg, "string");
2432
+ return _type_of(key) === "symbol" ? key : String(key);
2433
+ }
2434
+ function _type_of(obj) {
2435
+ "@swc/helpers - typeof";
2436
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
2437
+ }
2438
+ function _unsupported_iterable_to_array$2(o, minLen) {
2439
+ if (!o) return;
2440
+ if (typeof o === "string") return _array_like_to_array$2(o, minLen);
2441
+ var n = Object.prototype.toString.call(o).slice(8, -1);
2442
+ if (n === "Object" && o.constructor) n = o.constructor.name;
2443
+ if (n === "Map" || n === "Set") return Array.from(n);
2444
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
2445
+ }
2446
+ /**
2447
+ * Manages Kratos registration flow state and form submission.
2448
+ *
2449
+ * Handles registration flow creation, retrieval, and submission with automatic error handling,
2450
+ * URL parameter management, and continue-with callbacks for post-registration actions.
2451
+ *
2452
+ * @param kratosClient - Configured Kratos FrontendApi client
2453
+ * @param onSessionAlreadyAvailable - Callback when session already exists
2454
+ * @param onContinueWith - Optional callback for post-registration actions
2455
+ * @param searchParams - URL search parameters for flow state
2456
+ * @param updateSearchParams - Function to update URL search parameters
2457
+ * @returns Object with current flow, submit function, and registration status
2458
+ * @example
2459
+ * ```typescript
2460
+ * import { useRegisterFlow } from '@leancodepl/kratos';
2461
+ *
2462
+ * function RegisterForm() {
2463
+ * const { flow, submit, isRegistered } = useRegisterFlow({
2464
+ * kratosClient,
2465
+ * onSessionAlreadyAvailable: () => navigate('/dashboard'),
2466
+ * updateSearchParams: (params) => setSearchParams(params)
2467
+ * });
2468
+ *
2469
+ * return <form onSubmit={submit}>...</form>;
2470
+ * }
2471
+ * ```
2472
+ */ function useRegisterFlow(param) {
2473
+ var kratosClient = param.kratosClient, onSessionAlreadyAvailable = param.onSessionAlreadyAvailable, onContinueWith = param.onContinueWith, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
2474
+ var useHandleFlowError = useKratosContext().useHandleFlowError;
2475
+ var _useState = _sliced_to_array$1(useState(), 2), flow = _useState[0], setFlow = _useState[1];
2476
+ var _useState1 = _sliced_to_array$1(useState(false), 2), isRegistered = _useState1[0], setIsRegistered = _useState1[1];
2477
+ var flowId = searchParams[flowIdParameterName], returnTo = searchParams[returnToParameterName];
2478
+ var _obj;
2479
+ var handleFlowError = useHandleFlowError((_obj = {}, _define_property$c(_obj, "resetFlow", useCallback(function() {
2480
+ searchParams[flowIdParameterName]; var newParams = _object_without_properties$2(searchParams, [
2481
+ flowIdParameterName
2482
+ ].map(_to_property_key));
2483
+ updateSearchParams(newParams);
2484
+ setFlow(undefined);
2485
+ }, [
2486
+ searchParams,
2487
+ updateSearchParams
2488
+ ])), _define_property$c(_obj, "onSessionAlreadyAvailable", onSessionAlreadyAvailable), _obj));
2489
+ useEffect(function() {
2490
+ if (flow) return;
2491
+ var controller = new AbortController();
2492
+ if (flowId) {
2493
+ kratosClient.getRegistrationFlow({
2494
+ id: flowId
2495
+ }, {
2496
+ signal: controller.signal
2497
+ }).then(function(param) {
2498
+ var data = param.data;
2499
+ return setFlow(data);
2500
+ }).catch(handleCancelError).catch(handleFlowError);
2501
+ } else {
2502
+ kratosClient.createBrowserRegistrationFlow({
2503
+ returnTo: returnTo
2504
+ }, {
2505
+ signal: controller.signal
2506
+ }).then(function(param) {
2507
+ var data = param.data;
2508
+ return setFlow(data);
2509
+ }).catch(handleCancelError).catch(handleFlowError);
2510
+ }
2511
+ return function() {
2512
+ controller.abort();
2513
+ };
2514
+ }, [
2515
+ flowId,
2516
+ returnTo,
2517
+ flow,
2518
+ handleFlowError,
2519
+ kratosClient
2520
+ ]);
2521
+ var submit = useCallback(function(param) {
2522
+ var body = param.body;
2523
+ if (!flow) return;
2524
+ updateSearchParams(_object_spread_props$9(_object_spread$c({}, searchParams), _define_property$c({}, flowIdParameterName, flow.id)));
2525
+ return kratosClient.updateRegistrationFlow({
2526
+ flow: flow.id,
2527
+ updateRegistrationFlowBody: body
2528
+ }).then(function(data) {
2529
+ setIsRegistered(true);
2530
+ if (data.data.continue_with) {
2531
+ onContinueWith === null || onContinueWith === void 0 ? void 0 : onContinueWith(data.data.continue_with);
2532
+ }
2533
+ }).catch(handleFlowError).catch(function(err) {
2534
+ var _err_response;
2535
+ if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
2536
+ var _err_response1;
2537
+ setFlow((_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
2538
+ return;
2539
+ }
2540
+ return Promise.reject(err);
2541
+ });
2542
+ }, [
2543
+ flow,
2544
+ updateSearchParams,
2545
+ searchParams,
2546
+ kratosClient,
2547
+ handleFlowError,
2548
+ onContinueWith
2549
+ ]);
2550
+ return {
2551
+ flow: flow,
2552
+ submit: submit,
2553
+ isRegistered: isRegistered
2554
+ };
2555
+ }
2556
+
2557
+ function _array_like_to_array$1(arr, len) {
2558
+ if (len == null || len > arr.length) len = arr.length;
2559
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
2560
+ return arr2;
2561
+ }
2562
+ function _array_with_holes(arr) {
2563
+ if (Array.isArray(arr)) return arr;
2564
+ }
2565
+ function _define_property$b(obj, key, value) {
2566
+ if (key in obj) {
2567
+ Object.defineProperty(obj, key, {
2568
+ value: value,
2569
+ enumerable: true,
2570
+ configurable: true,
2571
+ writable: true
2572
+ });
2573
+ } else {
2574
+ obj[key] = value;
2575
+ }
2576
+ return obj;
2577
+ }
2578
+ function _iterable_to_array_limit(arr, i) {
2579
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
2580
+ if (_i == null) return;
2581
+ var _arr = [];
2582
+ var _n = true;
2583
+ var _d = false;
2584
+ var _s, _e;
2585
+ try {
2586
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
2587
+ _arr.push(_s.value);
2588
+ if (i && _arr.length === i) break;
2589
+ }
2590
+ } catch (err) {
2591
+ _d = true;
2592
+ _e = err;
2593
+ } finally{
2594
+ try {
2595
+ if (!_n && _i["return"] != null) _i["return"]();
2596
+ } finally{
2597
+ if (_d) throw _e;
2598
+ }
2599
+ }
2600
+ return _arr;
2601
+ }
2602
+ function _non_iterable_rest() {
2603
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2604
+ }
2605
+ function _object_spread$b(target) {
2606
+ for(var i = 1; i < arguments.length; i++){
2607
+ var source = arguments[i] != null ? arguments[i] : {};
2608
+ var ownKeys = Object.keys(source);
2609
+ if (typeof Object.getOwnPropertySymbols === "function") {
2610
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
2611
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
2612
+ }));
2613
+ }
2614
+ ownKeys.forEach(function(key) {
2615
+ _define_property$b(target, key, source[key]);
2616
+ });
2617
+ }
2618
+ return target;
2619
+ }
2620
+ function ownKeys$8(object, enumerableOnly) {
2621
+ var keys = Object.keys(object);
2622
+ if (Object.getOwnPropertySymbols) {
2623
+ var symbols = Object.getOwnPropertySymbols(object);
2624
+ keys.push.apply(keys, symbols);
2625
+ }
2626
+ return keys;
2627
+ }
2628
+ function _object_spread_props$8(target, source) {
2629
+ source = source != null ? source : {};
2630
+ if (Object.getOwnPropertyDescriptors) {
2631
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
2632
+ } else {
2633
+ ownKeys$8(Object(source)).forEach(function(key) {
2634
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2635
+ });
2636
+ }
2637
+ return target;
2638
+ }
2639
+ function _sliced_to_array(arr, i) {
2640
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest();
2641
+ }
2642
+ function _unsupported_iterable_to_array$1(o, minLen) {
2643
+ if (!o) return;
2644
+ if (typeof o === "string") return _array_like_to_array$1(o, minLen);
2645
+ var n = Object.prototype.toString.call(o).slice(8, -1);
2646
+ if (n === "Object" && o.constructor) n = o.constructor.name;
2647
+ if (n === "Map" || n === "Set") return Array.from(n);
2648
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
2649
+ }
2650
+ /**
2651
+ * Manages Kratos email/phone verification flow state and form submission.
2652
+ *
2653
+ * Handles verification flow creation, retrieval, and submission with automatic error handling,
2654
+ * URL parameter management, and verification status tracking.
2655
+ *
2656
+ * @param initialFlowId - Optional initial flow ID to start with
2657
+ * @param kratosClient - Configured Kratos FrontendApi client
2658
+ * @param onVerified - Callback executed when verification is successful
2659
+ * @param searchParams - URL search parameters for flow state
2660
+ * @param updateSearchParams - Function to update URL search parameters
2661
+ * @returns Object with current flow, submit function, and reset function
2662
+ * @example
2663
+ * ```typescript
2664
+ * import { useVerificationFlow } from '@leancodepl/kratos';
2665
+ *
2666
+ * function VerifyEmailForm() {
2667
+ * const { flow, submit, reset } = useVerificationFlow({
2668
+ * kratosClient,
2669
+ * onVerified: () => navigate('/dashboard'),
2670
+ * updateSearchParams: (params) => setSearchParams(params)
2671
+ * });
2672
+ *
2673
+ * return <form onSubmit={submit}>...</form>;
2674
+ * }
2675
+ * ```
2676
+ */ function useVerificationFlow(param) {
2677
+ var initialFlowId = param.initialFlowId, kratosClient = param.kratosClient, onVerified = param.onVerified, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
2678
+ var useHandleFlowError = useKratosContext().useHandleFlowError;
2679
+ var _useState = _sliced_to_array(useState(), 2), flow = _useState[0], setFlow = _useState[1];
2680
+ var tmp = searchParams[flowIdParameterName], flowId = tmp === void 0 ? initialFlowId : tmp, returnTo = searchParams[returnToParameterName];
2681
+ var resetFlow = useCallback(function(flowId) {
2682
+ updateSearchParams(_object_spread_props$8(_object_spread$b({}, searchParams), _define_property$b({}, flowIdParameterName, flowId)));
2683
+ setFlow(undefined);
2684
+ }, [
2685
+ searchParams,
2686
+ updateSearchParams
2687
+ ]);
2688
+ var reset = function() {
2689
+ resetFlow();
2690
+ };
2691
+ var handleFlowError = useHandleFlowError({
2692
+ resetFlow: resetFlow
2693
+ });
2694
+ useEffect(function() {
2695
+ if ((flow === null || flow === void 0 ? void 0 : flow.state) === "passed_challenge") onVerified();
2696
+ }, [
2697
+ flow === null || flow === void 0 ? void 0 : flow.state,
2698
+ onVerified
2699
+ ]);
2700
+ useEffect(function() {
2701
+ if (flow) return;
2702
+ var controller = new AbortController();
2703
+ if (flowId) {
2704
+ kratosClient.getVerificationFlow({
2705
+ id: flowId
2706
+ }, {
2707
+ signal: controller.signal
2708
+ }).then(function(param) {
2709
+ var data = param.data;
2710
+ return setFlow(data);
2711
+ }).catch(handleCancelError).catch(handleFlowError);
2712
+ } else {
2713
+ kratosClient.createBrowserVerificationFlow({
2714
+ returnTo: returnTo
2715
+ }, {
2716
+ signal: controller.signal
2717
+ }).then(function(param) {
2718
+ var data = param.data;
2719
+ return setFlow(data);
2720
+ }).catch(handleCancelError).catch(handleFlowError);
2721
+ }
2722
+ return function() {
2723
+ controller.abort();
2724
+ };
2725
+ }, [
2726
+ flowId,
2727
+ returnTo,
2728
+ flow,
2729
+ handleFlowError,
2730
+ kratosClient,
2731
+ onVerified
2732
+ ]);
2733
+ var submit = useCallback(function(param) {
2734
+ var body = param.body;
2735
+ if (!flow) return;
2736
+ updateSearchParams(_object_spread_props$8(_object_spread$b({}, searchParams), _define_property$b({}, flowIdParameterName, flow.id)));
2737
+ return kratosClient.updateVerificationFlow({
2738
+ flow: flow.id,
2739
+ updateVerificationFlowBody: body
2740
+ }).then(function(param) {
2741
+ var data = param.data;
2742
+ return setFlow(data);
2743
+ }).catch(handleFlowError).catch(function(err) {
2744
+ var _err_response;
2745
+ if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
2746
+ var _err_response1;
2747
+ setFlow((_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
2748
+ return;
2749
+ }
2750
+ return Promise.reject(err);
2751
+ });
2752
+ }, [
2753
+ flow,
2754
+ updateSearchParams,
2755
+ searchParams,
2756
+ kratosClient,
2757
+ handleFlowError
2758
+ ]);
2759
+ return {
2760
+ flow: flow,
2761
+ submit: submit,
2762
+ reset: reset
2763
+ };
2764
+ }
2765
+
2766
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2767
+ try {
2768
+ var info = gen[key](arg);
2769
+ var value = info.value;
2770
+ } catch (error) {
2771
+ reject(error);
2772
+ return;
2773
+ }
2774
+ if (info.done) {
2775
+ resolve(value);
2776
+ } else {
2777
+ Promise.resolve(value).then(_next, _throw);
2778
+ }
2779
+ }
2780
+ function _async_to_generator(fn) {
2781
+ return function() {
2782
+ var self = this, args = arguments;
2783
+ return new Promise(function(resolve, reject) {
2784
+ var gen = fn.apply(self, args);
2785
+ function _next(value) {
2786
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
2787
+ }
2788
+ function _throw(err) {
2789
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
2790
+ }
2791
+ _next(undefined);
2792
+ });
2793
+ };
2794
+ }
2795
+ function _ts_generator(thisArg, body) {
2796
+ var f, y, t, g, _ = {
2797
+ label: 0,
2798
+ sent: function() {
2799
+ if (t[0] & 1) throw t[1];
2800
+ return t[1];
2801
+ },
2802
+ trys: [],
2803
+ ops: []
2804
+ };
2805
+ return g = {
2806
+ next: verb(0),
2807
+ "throw": verb(1),
2808
+ "return": verb(2)
2809
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
2810
+ return this;
2811
+ }), g;
2812
+ function verb(n) {
2813
+ return function(v) {
2814
+ return step([
2815
+ n,
2816
+ v
2817
+ ]);
2818
+ };
2819
+ }
2820
+ function step(op) {
2821
+ if (f) throw new TypeError("Generator is already executing.");
2822
+ while(_)try {
2823
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
2824
+ if (y = 0, t) op = [
2825
+ op[0] & 2,
2826
+ t.value
2827
+ ];
2828
+ switch(op[0]){
2829
+ case 0:
2830
+ case 1:
2831
+ t = op;
2832
+ break;
2833
+ case 4:
2834
+ _.label++;
2835
+ return {
2836
+ value: op[1],
2837
+ done: false
2838
+ };
2839
+ case 5:
2840
+ _.label++;
2841
+ y = op[1];
2842
+ op = [
2843
+ 0
2844
+ ];
2845
+ continue;
2846
+ case 7:
2847
+ op = _.ops.pop();
2848
+ _.trys.pop();
2849
+ continue;
2850
+ default:
2851
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
2852
+ _ = 0;
2853
+ continue;
2854
+ }
2855
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
2856
+ _.label = op[1];
2857
+ break;
2858
+ }
2859
+ if (op[0] === 6 && _.label < t[1]) {
2860
+ _.label = t[1];
2861
+ t = op;
2862
+ break;
2863
+ }
2864
+ if (t && _.label < t[2]) {
2865
+ _.label = t[2];
2866
+ _.ops.push(op);
2867
+ break;
2868
+ }
2869
+ if (t[2]) _.ops.pop();
2870
+ _.trys.pop();
2871
+ continue;
2872
+ }
2873
+ op = body.call(thisArg, _);
2874
+ } catch (e) {
2875
+ op = [
2876
+ 6,
2877
+ e
2878
+ ];
2879
+ y = 0;
2880
+ } finally{
2881
+ f = t = 0;
2882
+ }
2883
+ if (op[0] & 5) throw op[1];
2884
+ return {
2885
+ value: op[0] ? op[1] : void 0,
2886
+ done: true
2887
+ };
2888
+ }
2889
+ }
2890
+ /**
2891
+ * Manages Kratos user logout flow with callback support.
2892
+ *
2893
+ * Provides a logout function that creates and executes logout flow,
2894
+ * handling token invalidation and redirect logic.
2895
+ *
2896
+ * @param kratosClient - Configured Kratos FrontendApi client
2897
+ * @param returnTo - Optional URL to redirect after logout
2898
+ * @param onLoggedOut - Optional callback executed after successful logout
2899
+ * @returns Object with logout function
2900
+ * @example
2901
+ * ```typescript
2902
+ * import { useLogoutFlow } from '@leancodepl/kratos';
2903
+ *
2904
+ * function LogoutButton() {
2905
+ * const { logout } = useLogoutFlow({
2906
+ * kratosClient,
2907
+ * returnTo: '/login',
2908
+ * onLoggedOut: () => console.log('User logged out')
2909
+ * });
2910
+ *
2911
+ * return <button onClick={logout}>Logout</button>;
2912
+ * }
2913
+ * ```
2914
+ */ function useLogoutFlow(param) {
2915
+ var kratosClient = param.kratosClient, returnTo = param.returnTo, onLoggedOut = param.onLoggedOut;
2916
+ var logout = useCallback(/*#__PURE__*/ _async_to_generator(function() {
2917
+ var flow;
2918
+ return _ts_generator(this, function(_state) {
2919
+ switch(_state.label){
2920
+ case 0:
2921
+ return [
2922
+ 4,
2923
+ kratosClient.createBrowserLogoutFlow(undefined, {
2924
+ params: {
2925
+ return_url: "/"
2926
+ }
2927
+ })
2928
+ ];
2929
+ case 1:
2930
+ flow = _state.sent();
2931
+ kratosClient.updateLogoutFlow({
2932
+ returnTo: returnTo,
2933
+ token: flow.data.logout_token
2934
+ }).then(function() {
2935
+ onLoggedOut === null || onLoggedOut === void 0 ? void 0 : onLoggedOut();
2936
+ }).catch(function(err) {
2937
+ var _err_response;
2938
+ if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
2939
+ return;
2940
+ }
2941
+ return Promise.reject(err);
2942
+ });
2943
+ return [
2944
+ 2
2945
+ ];
2946
+ }
2947
+ });
2948
+ }), [
2949
+ kratosClient,
2950
+ returnTo,
2951
+ onLoggedOut
2952
+ ]);
2953
+ return {
2954
+ logout: logout
2955
+ };
2956
+ }
2957
+
2958
+ function getNodeInputType(attr) {
2959
+ return attr && typeof attr === "object" && "type" in attr && attr.type && typeof attr.type === "string" ? attr.type : "";
2960
+ }
2961
+
2962
+ /**
2963
+ * Filters nodes by their groups and attributes.
2964
+ * If no filtering options are specified, all nodes are returned.
2965
+ * Will always add default nodes unless `withoutDefaultGroup` is true.
2966
+ * Will always add default attributes unless `withoutDefaultAttributes` is true.
2967
+ * @param {Object} filterNodesByGroups - An object containing the nodes and the filtering options.
2968
+ * @param {Array<UiNode>} filterNodesByGroups.nodes - An array of nodes.
2969
+ * @param {Array<UiNodeGroupEnum | string> | string} filterNodesByGroups.groups - An array or comma seperated strings of groups to filter by.
2970
+ * @param {boolean} filterNodesByGroups.withoutDefaultGroup - If true, will not add default nodes under the 'default' category.
2971
+ * @param {Array<UiNodeInputAttributesTypeEnum | string> | string} filterNodesByGroups.attributes - An array or comma seperated strings of attributes to filter by.
2972
+ * @param {boolean} filterNodesByGroups.withoutDefaultAttributes - If true, will not add default attributes such as 'hidden' and 'script'.
2973
+ */ var filterNodesByGroups = function(param) {
2974
+ var nodes = param.nodes, groups = param.groups, withoutDefaultGroup = param.withoutDefaultGroup, attributes = param.attributes, withoutDefaultAttributes = param.withoutDefaultAttributes, excludeAttributes = param.excludeAttributes;
2975
+ return nodes.filter(function(param) {
2976
+ var group = param.group, attr = param.attributes;
2977
+ // if we have not specified any group or attribute filters, return all nodes
2978
+ if (!groups && !attributes && !excludeAttributes) return true;
2979
+ var g = search(groups);
2980
+ if (!withoutDefaultGroup) {
2981
+ g.push(UiNodeGroupEnum.Default);
2982
+ }
2983
+ // filter the attributes
2984
+ var a = search(attributes);
2985
+ if (!withoutDefaultAttributes) {
2986
+ // always add hidden fields e.g. csrf
2987
+ if (group.includes(UiNodeGroupEnum.Default)) {
2988
+ a.push("hidden");
2989
+ }
2990
+ // automatically add the necessary fields for webauthn and totp
2991
+ if (group.includes(UiNodeGroupEnum.Webauthn) || group.includes(UiNodeGroupEnum.Totp)) {
2992
+ a.push("input", "script");
2993
+ }
2994
+ }
2995
+ // filter the attributes to exclude
2996
+ var ea = search(excludeAttributes);
2997
+ var filterGroup = groups ? g.includes(group) : true;
2998
+ var filterAttributes = attributes ? a.includes(getNodeInputType(attr)) : true;
2999
+ var filterExcludeAttributes = excludeAttributes ? !ea.includes(getNodeInputType(attr)) : true;
3000
+ return filterGroup && filterAttributes && filterExcludeAttributes;
3001
+ });
3002
+ };
3003
+ function search(s) {
3004
+ if (s !== undefined && typeof s === "string") return s.split(",");
3005
+ return s !== null && s !== void 0 ? s : [];
3006
+ }
3007
+
3008
+ var getNodeLabel = function(node) {
3009
+ var attributes = node.attributes;
3010
+ if (isUiNodeAnchorAttributes(attributes)) {
3011
+ return attributes.title;
3012
+ }
3013
+ if (isUiNodeImageAttributes(attributes)) {
3014
+ return node.meta.label;
3015
+ }
3016
+ if (isUiNodeInputAttributes(attributes) && attributes.label) {
3017
+ return attributes.label;
3018
+ }
3019
+ return node.meta.label;
3020
+ };
3021
+
3022
+ function _define_property$a(obj, key, value) {
3023
+ if (key in obj) {
3024
+ Object.defineProperty(obj, key, {
3025
+ value: value,
3026
+ enumerable: true,
3027
+ configurable: true,
3028
+ writable: true
3029
+ });
3030
+ } else {
3031
+ obj[key] = value;
3032
+ }
3033
+ return obj;
3034
+ }
3035
+ function _object_spread$a(target) {
3036
+ for(var i = 1; i < arguments.length; i++){
3037
+ var source = arguments[i] != null ? arguments[i] : {};
3038
+ var ownKeys = Object.keys(source);
3039
+ if (typeof Object.getOwnPropertySymbols === "function") {
3040
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3041
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3042
+ }));
3043
+ }
3044
+ ownKeys.forEach(function(key) {
3045
+ _define_property$a(target, key, source[key]);
3046
+ });
3047
+ }
3048
+ return target;
3049
+ }
3050
+ function Node(param) {
3051
+ var node = param.node, className = param.className;
3052
+ var _useKratosContext = useKratosContext(), _useKratosContext_components = _useKratosContext.components, Image = _useKratosContext_components.Image, Text = _useKratosContext_components.Text, Link = _useKratosContext_components.Link, Input = _useKratosContext_components.Input, Button = _useKratosContext_components.Button, Checkbox = _useKratosContext_components.Checkbox;
3053
+ if (isUiNodeImageAttributes(node.attributes)) {
3054
+ return /*#__PURE__*/ jsx(Image, {
3055
+ header: /*#__PURE__*/ jsx(FormattedMessage, {
3056
+ message: node.meta.label
3057
+ }),
3058
+ height: node.attributes.height,
3059
+ node: node,
3060
+ src: node.attributes.src,
3061
+ width: node.attributes.width
3062
+ });
3063
+ } else if (isUiNodeTextAttributes(node.attributes)) {
3064
+ return /*#__PURE__*/ jsx(Text, {
3065
+ attributes: node.attributes,
3066
+ codes: isUiNodeTextSecretsAttributes(node.attributes) ? node.attributes.text.context.secrets.map(function(text) {
3067
+ return text;
3068
+ }) : [
3069
+ node.attributes.text
3070
+ ],
3071
+ id: node.attributes.id,
3072
+ label: /*#__PURE__*/ jsx(FormattedMessage, {
3073
+ message: node.meta.label
3074
+ }),
3075
+ node: node
3076
+ });
3077
+ } else if (isUiNodeInputAttributes(node.attributes)) {
3078
+ var attrs = node.attributes;
3079
+ var nodeType = attrs.type;
3080
+ switch(nodeType){
3081
+ case "button":
3082
+ case "submit":
3083
+ {
3084
+ var _node_meta_label;
3085
+ var isSocial = (attrs.name === "provider" || attrs.name === "link") && node.group === UiNodeGroupEnum.Oidc;
3086
+ var submit = {
3087
+ type: attrs.type,
3088
+ name: attrs.name
3089
+ };
3090
+ if (attrs.value) {
3091
+ submit.value = attrs.value;
3092
+ }
3093
+ if (isSocial) {
3094
+ submit.formNoValidate = true;
3095
+ submit.onClick = function(e) {
3096
+ e.currentTarget.type = "submit";
3097
+ e.currentTarget.dispatchEvent(new Event("submit", {
3098
+ cancelable: true,
3099
+ bubbles: true
3100
+ }));
3101
+ };
3102
+ }
3103
+ if (attrs.onclick) {
3104
+ // This is a bit hacky but it wouldn't work otherwise.
3105
+ var oc = attrs.onclick;
3106
+ submit.onClick = function() {
3107
+ // eslint-disable-next-line no-eval
3108
+ eval(oc);
3109
+ };
3110
+ }
3111
+ // the recovery code resend button
3112
+ if (((_node_meta_label = node.meta.label) === null || _node_meta_label === void 0 ? void 0 : _node_meta_label.id) === 1070008) {
3113
+ // on html forms the required flag on an input field will prevent the form from submitting.
3114
+ // we disable validation for this form since the resend button does not rely on any input fields
3115
+ submit.formNoValidate = true;
3116
+ }
3117
+ return /*#__PURE__*/ jsx(Button, _object_spread$a({
3118
+ fullWidth: true,
3119
+ className: className,
3120
+ disabled: attrs.disabled,
3121
+ header: /*#__PURE__*/ jsx(FormattedMessage, {
3122
+ message: getNodeLabel(node)
3123
+ }),
3124
+ node: node,
3125
+ social: isSocial ? attrs.value.toLowerCase() : undefined
3126
+ }, submit));
3127
+ }
3128
+ case "datetime-local":
3129
+ case "checkbox":
3130
+ return /*#__PURE__*/ jsx(Checkbox, {
3131
+ className: className,
3132
+ defaultChecked: Boolean(attrs.value),
3133
+ disabled: attrs.disabled,
3134
+ helperMessage: /*#__PURE__*/ jsx(NodeMessages, {
3135
+ nodes: [
3136
+ node
3137
+ ]
3138
+ }),
3139
+ isError: node.messages.length > 0,
3140
+ label: /*#__PURE__*/ jsx(FormattedMessage, {
3141
+ message: getNodeLabel(node)
3142
+ }),
3143
+ name: attrs.name,
3144
+ node: node,
3145
+ required: attrs.required,
3146
+ value: "true"
3147
+ });
3148
+ default:
3149
+ var _attrs_autocomplete;
3150
+ return /*#__PURE__*/ jsx(Input, {
3151
+ autoComplete: (_attrs_autocomplete = attrs.autocomplete) !== null && _attrs_autocomplete !== void 0 ? _attrs_autocomplete : attrs.name === "identifier" ? "username" : undefined,
3152
+ className: className,
3153
+ defaultValue: attrs.value,
3154
+ disabled: attrs.disabled,
3155
+ header: /*#__PURE__*/ jsx(FormattedMessage, {
3156
+ message: getNodeLabel(node)
3157
+ }),
3158
+ helperMessage: /*#__PURE__*/ jsx(NodeMessages, {
3159
+ nodes: [
3160
+ node
3161
+ ]
3162
+ }),
3163
+ isError: node.messages.length > 0,
3164
+ name: attrs.name,
3165
+ node: node,
3166
+ pattern: attrs.pattern,
3167
+ required: attrs.required,
3168
+ type: attrs.type
3169
+ });
3170
+ }
3171
+ } else if (isUiNodeAnchorAttributes(node.attributes)) {
3172
+ return /*#__PURE__*/ jsx(Link, {
3173
+ className: className,
3174
+ href: node.attributes.href,
3175
+ node: node,
3176
+ children: /*#__PURE__*/ jsx(FormattedMessage, {
3177
+ message: node.attributes.title
3178
+ })
3179
+ });
3180
+ }
3181
+ return null;
3182
+ }
3183
+
3184
+ function _define_property$9(obj, key, value) {
3185
+ if (key in obj) {
3186
+ Object.defineProperty(obj, key, {
3187
+ value: value,
3188
+ enumerable: true,
3189
+ configurable: true,
3190
+ writable: true
3191
+ });
3192
+ } else {
3193
+ obj[key] = value;
3194
+ }
3195
+ return obj;
3196
+ }
3197
+ function _object_spread$9(target) {
3198
+ for(var i = 1; i < arguments.length; i++){
3199
+ var source = arguments[i] != null ? arguments[i] : {};
3200
+ var ownKeys = Object.keys(source);
3201
+ if (typeof Object.getOwnPropertySymbols === "function") {
3202
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3203
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3204
+ }));
3205
+ }
3206
+ ownKeys.forEach(function(key) {
3207
+ _define_property$9(target, key, source[key]);
3208
+ });
3209
+ }
3210
+ return target;
3211
+ }
3212
+ function _object_without_properties$1(source, excluded) {
3213
+ if (source == null) return {};
3214
+ var target = _object_without_properties_loose$1(source, excluded);
3215
+ var key, i;
3216
+ if (Object.getOwnPropertySymbols) {
3217
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
3218
+ for(i = 0; i < sourceSymbolKeys.length; i++){
3219
+ key = sourceSymbolKeys[i];
3220
+ if (excluded.indexOf(key) >= 0) continue;
3221
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
3222
+ target[key] = source[key];
3223
+ }
3224
+ }
3225
+ return target;
3226
+ }
3227
+ function _object_without_properties_loose$1(source, excluded) {
3228
+ if (source == null) return {};
3229
+ var target = {};
3230
+ var sourceKeys = Object.keys(source);
3231
+ var key, i;
3232
+ for(i = 0; i < sourceKeys.length; i++){
3233
+ key = sourceKeys[i];
3234
+ if (excluded.indexOf(key) >= 0) continue;
3235
+ target[key] = source[key];
3236
+ }
3237
+ return target;
3238
+ }
3239
+ function FilterFlowNodes(_param) {
3240
+ var filter = _param.filter, includeCSRF = _param.includeCSRF, overrides = _object_without_properties$1(_param, [
3241
+ "filter",
3242
+ "includeCSRF"
3243
+ ]);
3244
+ var getInputName = function(node) {
3245
+ return isUiNodeInputAttributes(node.attributes) ? node.attributes.name : "";
3246
+ };
3247
+ var nodes = filterNodesByGroups(filter)// we don't want to map the csrf token every time, only on the form level
3248
+ .filter(function(node) {
3249
+ return includeCSRF || !(getInputName(node) === "csrf_token");
3250
+ }).map(function(node, k) {
3251
+ return {
3252
+ node: /*#__PURE__*/ jsx(Node, _object_spread$9({
3253
+ node: node
3254
+ }, overrides), isUiNodeInputAttributes(node.attributes) ? (node.attributes.type === "button" || node.attributes.type === "submit") && node.attributes.value ? "".concat(node.attributes.name, "_").concat(node.attributes.value) : node.attributes.name : isUiNodeImageAttributes(node.attributes) ? node.attributes.src : isUiNodeAnchorAttributes(node.attributes) || isUiNodeTextAttributes(node.attributes) || isUiNodeScriptAttributes(node.attributes) ? node.attributes.id : k),
3255
+ hidden: getNodeInputType(node.attributes) === "hidden"
3256
+ };
3257
+ });
3258
+ if (nodes.length === 0) return null;
3259
+ return /*#__PURE__*/ jsx(Fragment, {
3260
+ children: nodes.map(function(node) {
3261
+ return node.node;
3262
+ })
3263
+ });
3264
+ }
3265
+
3266
+ /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */ function _define_property$8(obj, key, value) {
3267
+ if (key in obj) {
3268
+ Object.defineProperty(obj, key, {
3269
+ value: value,
3270
+ enumerable: true,
3271
+ configurable: true,
3272
+ writable: true
3273
+ });
3274
+ } else {
3275
+ obj[key] = value;
3276
+ }
3277
+ return obj;
3278
+ }
3279
+ function _object_spread$8(target) {
3280
+ for(var i = 1; i < arguments.length; i++){
3281
+ var source = arguments[i] != null ? arguments[i] : {};
3282
+ var ownKeys = Object.keys(source);
3283
+ if (typeof Object.getOwnPropertySymbols === "function") {
3284
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3285
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3286
+ }));
3287
+ }
3288
+ ownKeys.forEach(function(key) {
3289
+ _define_property$8(target, key, source[key]);
3290
+ });
3291
+ }
3292
+ return target;
3293
+ }
3294
+ function ownKeys$7(object, enumerableOnly) {
3295
+ var keys = Object.keys(object);
3296
+ if (Object.getOwnPropertySymbols) {
3297
+ var symbols = Object.getOwnPropertySymbols(object);
3298
+ keys.push.apply(keys, symbols);
3299
+ }
3300
+ return keys;
3301
+ }
3302
+ function _object_spread_props$7(target, source) {
3303
+ source = source != null ? source : {};
3304
+ if (Object.getOwnPropertyDescriptors) {
3305
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3306
+ } else {
3307
+ ownKeys$7(Object(source)).forEach(function(key) {
3308
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3309
+ });
3310
+ }
3311
+ return target;
3312
+ }
3313
+ function _object_without_properties(source, excluded) {
3314
+ if (source == null) return {};
3315
+ var target = _object_without_properties_loose(source, excluded);
3316
+ var key, i;
3317
+ if (Object.getOwnPropertySymbols) {
3318
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
3319
+ for(i = 0; i < sourceSymbolKeys.length; i++){
3320
+ key = sourceSymbolKeys[i];
3321
+ if (excluded.indexOf(key) >= 0) continue;
3322
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
3323
+ target[key] = source[key];
3324
+ }
3325
+ }
3326
+ return target;
3327
+ }
3328
+ function _object_without_properties_loose(source, excluded) {
3329
+ if (source == null) return {};
3330
+ var target = {};
3331
+ var sourceKeys = Object.keys(source);
3332
+ var key, i;
3333
+ for(i = 0; i < sourceKeys.length; i++){
3334
+ key = sourceKeys[i];
3335
+ if (excluded.indexOf(key) >= 0) continue;
3336
+ target[key] = source[key];
3337
+ }
3338
+ return target;
3339
+ }
3340
+ /**
3341
+ * UserAuthForm is a component that renders a form for a given Ory flow.
3342
+ * It automatically adds the form action and method and adds csrf tokens to the form.
3343
+ * When the `onSubmit` parameter is passed, it also automatically maps the form data to the request body and prevents native form submits.
3344
+ * @see UserAuthFormProps
3345
+ * @returns JSX.Element
3346
+ */ function UserAuthForm(_param) {
3347
+ var flow = _param.flow, children = _param.children, submitOnEnter = _param.submitOnEnter, onSubmit = _param.onSubmit, formFilterOverride = _param.formFilterOverride, props = _object_without_properties(_param, [
3348
+ "flow",
3349
+ "children",
3350
+ "submitOnEnter",
3351
+ "onSubmit",
3352
+ "formFilterOverride"
3353
+ ]);
3354
+ return /*#__PURE__*/ jsxs("form", _object_spread_props$7(_object_spread$8({
3355
+ noValidate: true,
3356
+ action: flow.ui.action,
3357
+ method: flow.ui.method,
3358
+ onKeyDown: function(e) {
3359
+ if (e.key === "Enter" && !submitOnEnter) {
3360
+ e.stopPropagation();
3361
+ e.preventDefault();
3362
+ }
3363
+ }
3364
+ }, onSubmit && {
3365
+ onSubmit: function(event) {
3366
+ event.preventDefault();
3367
+ var form = event.currentTarget;
3368
+ var formData = new FormData(form);
3369
+ // map the entire form data to JSON for the request body
3370
+ var body = Object.fromEntries(formData);
3371
+ // We need the method specified from the name and value of the submit button.
3372
+ // when multiple submit buttons are present, the clicked one's value is used.
3373
+ if ("submitter" in event.nativeEvent) {
3374
+ var method = event.nativeEvent.submitter;
3375
+ body = _object_spread$8({}, body, _define_property$8({}, method.name, method.value));
3376
+ }
3377
+ onSubmit({
3378
+ body: body,
3379
+ event: event
3380
+ });
3381
+ }
3382
+ }, props), {
3383
+ children: [
3384
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3385
+ includeCSRF: true,
3386
+ filter: formFilterOverride !== null && formFilterOverride !== void 0 ? formFilterOverride : {
3387
+ nodes: flow.ui.nodes,
3388
+ groups: UiNodeGroupEnum.Default,
3389
+ attributes: "hidden"
3390
+ }
3391
+ }),
3392
+ children
3393
+ ]
3394
+ }));
3395
+ }
3396
+
3397
+ function _array_like_to_array(arr, len) {
3398
+ if (len == null || len > arr.length) len = arr.length;
3399
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
3400
+ return arr2;
3401
+ }
3402
+ function _array_without_holes(arr) {
3403
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
3404
+ }
3405
+ function _iterable_to_array(iter) {
3406
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
3407
+ }
3408
+ function _non_iterable_spread() {
3409
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3410
+ }
3411
+ function _to_consumable_array(arr) {
3412
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
3413
+ }
3414
+ function _unsupported_iterable_to_array(o, minLen) {
3415
+ if (!o) return;
3416
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
3417
+ var n = Object.prototype.toString.call(o).slice(8, -1);
3418
+ if (n === "Object" && o.constructor) n = o.constructor.name;
3419
+ if (n === "Map" || n === "Set") return Array.from(n);
3420
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
3421
+ }
3422
+ function useScriptNodes(param) {
3423
+ var nodes = param.nodes, excludeScripts = param.excludeScripts;
3424
+ useEffect(function() {
3425
+ if (excludeScripts) {
3426
+ return;
3427
+ }
3428
+ var scriptNodes = filterNodesByGroups({
3429
+ nodes: nodes,
3430
+ groups: UiNodeGroupEnum.Webauthn,
3431
+ attributes: "text/javascript",
3432
+ withoutDefaultGroup: true,
3433
+ withoutDefaultAttributes: true
3434
+ }).reduce(function(accumulator, node) {
3435
+ var attr = node.attributes;
3436
+ if (document.querySelector('script[src="'.concat(attr.src, '"]'))) {
3437
+ return accumulator;
3438
+ }
3439
+ var script = document.createElement("script");
3440
+ script.src = attr.src;
3441
+ script.type = attr.type;
3442
+ script.async = attr.async;
3443
+ script.referrerPolicy = attr.referrerpolicy;
3444
+ script.crossOrigin = attr.crossorigin;
3445
+ script.integrity = attr.integrity;
3446
+ document.body.appendChild(script);
3447
+ return _to_consumable_array(accumulator).concat([
3448
+ script
3449
+ ]);
3450
+ }, []);
3451
+ return function() {
3452
+ scriptNodes.forEach(function(script) {
3453
+ document.body.removeChild(script);
3454
+ });
3455
+ };
3456
+ }, [
3457
+ excludeScripts,
3458
+ nodes
3459
+ ]);
3460
+ }
3461
+
3462
+ function hasOidc(nodes) {
3463
+ return nodes.some(function(param) {
3464
+ var group = param.group;
3465
+ return group === UiNodeGroupEnum.Oidc;
3466
+ });
3467
+ }
3468
+ function hasPassword(nodes) {
3469
+ return nodes.some(function(param) {
3470
+ var group = param.group;
3471
+ return group === UiNodeGroupEnum.Password;
3472
+ });
3473
+ }
3474
+ function hasDefault(nodes) {
3475
+ return nodes.some(function(param) {
3476
+ var group = param.group;
3477
+ return group === UiNodeGroupEnum.Default;
3478
+ });
3479
+ }
3480
+ function hasProfile(nodes) {
3481
+ return nodes.some(function(param) {
3482
+ var group = param.group;
3483
+ return group === UiNodeGroupEnum.Profile;
3484
+ });
3485
+ }
3486
+ function hasPasskey(nodes) {
3487
+ return nodes.some(function(param) {
3488
+ var group = param.group;
3489
+ return group === UiNodeGroupEnum.Passkey;
3490
+ });
3491
+ }
3492
+ function hasIdentifierFirst(nodes) {
3493
+ return nodes.some(function(param) {
3494
+ var group = param.group;
3495
+ return group === UiNodeGroupEnum.IdentifierFirst;
3496
+ });
3497
+ }
3498
+ function hasLookupSecret(nodes) {
3499
+ return nodes.some(function(param) {
3500
+ var group = param.group;
3501
+ return group === UiNodeGroupEnum.LookupSecret;
3502
+ });
3503
+ }
3504
+ function hasTotp(nodes) {
3505
+ return nodes.some(function(param) {
3506
+ var group = param.group;
3507
+ return group === UiNodeGroupEnum.Totp;
3508
+ });
3509
+ }
3510
+ function hasCode(nodes) {
3511
+ return nodes.some(function(param) {
3512
+ var group = param.group;
3513
+ return group === UiNodeGroupEnum.Code;
3514
+ });
3515
+ }
3516
+
3517
+ /**
3518
+ * AuthCodeSection renders the fields for login and registration via one-time code.
3519
+ * Please see the Ory docs for more information: https://www.ory.sh/docs/kratos/passwordless/one-time-code
3520
+ * @param nodes - Ory UiNode[]
3521
+ * @see AuthCodeSectionProps
3522
+ */ function AuthCodeSection(param) {
3523
+ var nodes = param.nodes, AuthCodeSectionWrapper = param.AuthCodeSectionWrapper;
3524
+ if (!hasCode(nodes)) return null;
3525
+ return /*#__PURE__*/ jsxs(AuthCodeSectionWrapper, {
3526
+ children: [
3527
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3528
+ filter: {
3529
+ nodes: nodes,
3530
+ groups: UiNodeGroupEnum.Code,
3531
+ // we don't want to map the default group twice
3532
+ // the form already maps hidden fields under the default group
3533
+ // we are only interested in hidden fields that are under the code group
3534
+ withoutDefaultGroup: true,
3535
+ withoutDefaultAttributes: true,
3536
+ attributes: [
3537
+ "hidden"
3538
+ ]
3539
+ }
3540
+ }),
3541
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3542
+ filter: {
3543
+ nodes: nodes,
3544
+ groups: UiNodeGroupEnum.Code,
3545
+ withoutDefaultAttributes: true,
3546
+ excludeAttributes: [
3547
+ "hidden",
3548
+ "button",
3549
+ "submit"
3550
+ ]
3551
+ }
3552
+ }),
3553
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3554
+ filter: {
3555
+ nodes: nodes,
3556
+ groups: UiNodeGroupEnum.Code,
3557
+ withoutDefaultAttributes: true,
3558
+ attributes: [
3559
+ "button",
3560
+ "submit"
3561
+ ]
3562
+ }
3563
+ })
3564
+ ]
3565
+ });
3566
+ }
3567
+
3568
+ function IdentifierFirstLoginSection(param) {
3569
+ var nodes = param.nodes, IdentifierFirstLoginSectionWrapper = param.IdentifierFirstLoginSectionWrapper;
3570
+ return /*#__PURE__*/ jsxs(IdentifierFirstLoginSectionWrapper, {
3571
+ children: [
3572
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3573
+ filter: {
3574
+ nodes: nodes,
3575
+ groups: [
3576
+ UiNodeGroupEnum.Default,
3577
+ UiNodeGroupEnum.IdentifierFirst
3578
+ ],
3579
+ excludeAttributes: [
3580
+ "submit",
3581
+ "hidden"
3582
+ ]
3583
+ }
3584
+ }),
3585
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3586
+ filter: {
3587
+ nodes: nodes,
3588
+ groups: UiNodeGroupEnum.IdentifierFirst,
3589
+ attributes: "submit"
3590
+ }
3591
+ })
3592
+ ]
3593
+ });
3594
+ }
3595
+
3596
+ /**
3597
+ * LinkSection renders the fields for recovery and verification
3598
+ * Please see the Ory docs for more information:
3599
+ * - https://www.ory.sh/docs/kratos/self-service/flows/account-recovery-password-reset
3600
+ * - https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation
3601
+ */ function LinkSection(param) {
3602
+ var nodes = param.nodes, LinkSectionWrapper = param.LinkSectionWrapper;
3603
+ return /*#__PURE__*/ jsxs(LinkSectionWrapper, {
3604
+ children: [
3605
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3606
+ filter: {
3607
+ nodes: nodes,
3608
+ groups: [
3609
+ UiNodeGroupEnum.Link,
3610
+ UiNodeGroupEnum.Code
3611
+ ],
3612
+ excludeAttributes: "submit"
3613
+ }
3614
+ }),
3615
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3616
+ filter: {
3617
+ nodes: nodes,
3618
+ groups: [
3619
+ UiNodeGroupEnum.Link,
3620
+ UiNodeGroupEnum.Code
3621
+ ],
3622
+ attributes: "submit"
3623
+ }
3624
+ })
3625
+ ]
3626
+ });
3627
+ }
3628
+
3629
+ function LoginSection(param) {
3630
+ var nodes = param.nodes, LoginSectionWrapper = param.LoginSectionWrapper;
3631
+ if (!hasPassword(nodes)) return null;
3632
+ return /*#__PURE__*/ jsxs(LoginSectionWrapper, {
3633
+ children: [
3634
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3635
+ filter: {
3636
+ nodes: nodes,
3637
+ groups: [
3638
+ UiNodeGroupEnum.Default,
3639
+ UiNodeGroupEnum.Password
3640
+ ],
3641
+ excludeAttributes: [
3642
+ "submit",
3643
+ "hidden"
3644
+ ]
3645
+ }
3646
+ }),
3647
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3648
+ filter: {
3649
+ nodes: nodes,
3650
+ groups: UiNodeGroupEnum.Password,
3651
+ attributes: "submit"
3652
+ }
3653
+ })
3654
+ ]
3655
+ });
3656
+ }
3657
+
3658
+ function OidcSection(param) {
3659
+ var flow = param.flow, OidcSectionWrapper = param.OidcSectionWrapper;
3660
+ if (!hasOidc(flow.ui.nodes)) return null;
3661
+ var hasOidcTraits = filterNodesByGroups({
3662
+ nodes: flow.ui.nodes,
3663
+ groups: UiNodeGroupEnum.Oidc,
3664
+ withoutDefaultGroup: true,
3665
+ excludeAttributes: "submit"
3666
+ }).length > 0;
3667
+ return /*#__PURE__*/ jsxs(OidcSectionWrapper, {
3668
+ children: [
3669
+ hasOidcTraits && /*#__PURE__*/ jsx(FilterFlowNodes, {
3670
+ filter: {
3671
+ nodes: flow.ui.nodes,
3672
+ groups: UiNodeGroupEnum.Oidc,
3673
+ withoutDefaultGroup: true,
3674
+ excludeAttributes: "submit"
3675
+ }
3676
+ }),
3677
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3678
+ filter: {
3679
+ nodes: flow.ui.nodes,
3680
+ groups: UiNodeGroupEnum.Oidc,
3681
+ attributes: "submit"
3682
+ }
3683
+ })
3684
+ ]
3685
+ });
3686
+ }
3687
+
3688
+ function _define_property$7(obj, key, value) {
3689
+ if (key in obj) {
3690
+ Object.defineProperty(obj, key, {
3691
+ value: value,
3692
+ enumerable: true,
3693
+ configurable: true,
3694
+ writable: true
3695
+ });
3696
+ } else {
3697
+ obj[key] = value;
3698
+ }
3699
+ return obj;
3700
+ }
3701
+ function _object_spread$7(target) {
3702
+ for(var i = 1; i < arguments.length; i++){
3703
+ var source = arguments[i] != null ? arguments[i] : {};
3704
+ var ownKeys = Object.keys(source);
3705
+ if (typeof Object.getOwnPropertySymbols === "function") {
3706
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3707
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3708
+ }));
3709
+ }
3710
+ ownKeys.forEach(function(key) {
3711
+ _define_property$7(target, key, source[key]);
3712
+ });
3713
+ }
3714
+ return target;
3715
+ }
3716
+ function ownKeys$6(object, enumerableOnly) {
3717
+ var keys = Object.keys(object);
3718
+ if (Object.getOwnPropertySymbols) {
3719
+ var symbols = Object.getOwnPropertySymbols(object);
3720
+ keys.push.apply(keys, symbols);
3721
+ }
3722
+ return keys;
3723
+ }
3724
+ function _object_spread_props$6(target, source) {
3725
+ source = source != null ? source : {};
3726
+ if (Object.getOwnPropertyDescriptors) {
3727
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3728
+ } else {
3729
+ ownKeys$6(Object(source)).forEach(function(key) {
3730
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3731
+ });
3732
+ }
3733
+ return target;
3734
+ }
3735
+ function PasswordlessSection(param) {
3736
+ var flow = param.flow, PasswordlessSectionWrapper = param.PasswordlessSectionWrapper;
3737
+ if (!hasPasskey(flow.ui.nodes)) return null;
3738
+ var filter = {
3739
+ nodes: flow.ui.nodes,
3740
+ groups: UiNodeGroupEnum.Passkey,
3741
+ withoutDefaultAttributes: true
3742
+ };
3743
+ return /*#__PURE__*/ jsxs(PasswordlessSectionWrapper, {
3744
+ children: [
3745
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3746
+ filter: _object_spread_props$6(_object_spread$7({}, filter), {
3747
+ groups: [
3748
+ "identifier_first",
3749
+ "passkey"
3750
+ ],
3751
+ attributes: [
3752
+ "hidden"
3753
+ ]
3754
+ })
3755
+ }),
3756
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3757
+ filter: _object_spread_props$6(_object_spread$7({}, filter), {
3758
+ excludeAttributes: [
3759
+ "hidden",
3760
+ "button",
3761
+ "submit"
3762
+ ]
3763
+ })
3764
+ }),
3765
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3766
+ filter: _object_spread_props$6(_object_spread$7({}, filter), {
3767
+ attributes: [
3768
+ "button",
3769
+ "submit"
3770
+ ],
3771
+ excludeAttributes: [
3772
+ "hidden"
3773
+ ]
3774
+ })
3775
+ })
3776
+ ]
3777
+ });
3778
+ }
3779
+
3780
+ function ProfileLoginSection(param) {
3781
+ var nodes = param.nodes, ProfileLoginSectionWrapper = param.ProfileLoginSectionWrapper;
3782
+ return /*#__PURE__*/ jsxs(ProfileLoginSectionWrapper, {
3783
+ children: [
3784
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3785
+ filter: {
3786
+ nodes: nodes,
3787
+ groups: UiNodeGroupEnum.Profile,
3788
+ excludeAttributes: "submit,hidden"
3789
+ }
3790
+ }),
3791
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3792
+ filter: {
3793
+ nodes: nodes,
3794
+ groups: UiNodeGroupEnum.Profile,
3795
+ excludeAttributes: "hidden",
3796
+ attributes: "submit"
3797
+ }
3798
+ })
3799
+ ]
3800
+ });
3801
+ }
3802
+
3803
+ function ProfileRegistrationSection(param) {
3804
+ var nodes = param.nodes, ProfileRegistrationSectionWrapper = param.ProfileRegistrationSectionWrapper;
3805
+ return /*#__PURE__*/ jsxs(ProfileRegistrationSectionWrapper, {
3806
+ children: [
3807
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3808
+ filter: {
3809
+ nodes: nodes,
3810
+ groups: UiNodeGroupEnum.Profile,
3811
+ excludeAttributes: "submit,hidden"
3812
+ }
3813
+ }),
3814
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3815
+ filter: {
3816
+ nodes: nodes,
3817
+ groups: UiNodeGroupEnum.Profile,
3818
+ excludeAttributes: "hidden",
3819
+ attributes: "submit"
3820
+ }
3821
+ })
3822
+ ]
3823
+ });
3824
+ }
3825
+
3826
+ function _define_property$6(obj, key, value) {
3827
+ if (key in obj) {
3828
+ Object.defineProperty(obj, key, {
3829
+ value: value,
3830
+ enumerable: true,
3831
+ configurable: true,
3832
+ writable: true
3833
+ });
3834
+ } else {
3835
+ obj[key] = value;
3836
+ }
3837
+ return obj;
3838
+ }
3839
+ function _object_spread$6(target) {
3840
+ for(var i = 1; i < arguments.length; i++){
3841
+ var source = arguments[i] != null ? arguments[i] : {};
3842
+ var ownKeys = Object.keys(source);
3843
+ if (typeof Object.getOwnPropertySymbols === "function") {
3844
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3845
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3846
+ }));
3847
+ }
3848
+ ownKeys.forEach(function(key) {
3849
+ _define_property$6(target, key, source[key]);
3850
+ });
3851
+ }
3852
+ return target;
3853
+ }
3854
+ function ownKeys$5(object, enumerableOnly) {
3855
+ var keys = Object.keys(object);
3856
+ if (Object.getOwnPropertySymbols) {
3857
+ var symbols = Object.getOwnPropertySymbols(object);
3858
+ keys.push.apply(keys, symbols);
3859
+ }
3860
+ return keys;
3861
+ }
3862
+ function _object_spread_props$5(target, source) {
3863
+ source = source != null ? source : {};
3864
+ if (Object.getOwnPropertyDescriptors) {
3865
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3866
+ } else {
3867
+ ownKeys$5(Object(source)).forEach(function(key) {
3868
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3869
+ });
3870
+ }
3871
+ return target;
3872
+ }
3873
+ function RegistrationSection(param) {
3874
+ var nodes = param.nodes, RegistrationSectionWrapper = param.RegistrationSectionWrapper;
3875
+ if (!hasPassword(nodes)) return null;
3876
+ var filter = {
3877
+ nodes: nodes,
3878
+ groups: UiNodeGroupEnum.Password
3879
+ };
3880
+ return /*#__PURE__*/ jsxs(RegistrationSectionWrapper, {
3881
+ children: [
3882
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3883
+ filter: _object_spread_props$5(_object_spread$6({}, filter), {
3884
+ excludeAttributes: "submit,hidden"
3885
+ })
3886
+ }),
3887
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
3888
+ filter: _object_spread_props$5(_object_spread$6({}, filter), {
3889
+ excludeAttributes: "hidden",
3890
+ attributes: "submit"
3891
+ })
3892
+ })
3893
+ ]
3894
+ });
3895
+ }
3896
+
3897
+ function _define_property$5(obj, key, value) {
3898
+ if (key in obj) {
3899
+ Object.defineProperty(obj, key, {
3900
+ value: value,
3901
+ enumerable: true,
3902
+ configurable: true,
3903
+ writable: true
3904
+ });
3905
+ } else {
3906
+ obj[key] = value;
3907
+ }
3908
+ return obj;
3909
+ }
3910
+ function _extends() {
3911
+ _extends = Object.assign || function(target) {
3912
+ for(var i = 1; i < arguments.length; i++){
3913
+ var source = arguments[i];
3914
+ for(var key in source){
3915
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
3916
+ target[key] = source[key];
3917
+ }
3918
+ }
3919
+ }
3920
+ return target;
3921
+ };
3922
+ return _extends.apply(this, arguments);
3923
+ }
3924
+ function _object_destructuring_empty(o) {
3925
+ if (o === null || o === void 0) throw new TypeError("Cannot destructure " + o);
3926
+ return o;
3927
+ }
3928
+ function _object_spread$5(target) {
3929
+ for(var i = 1; i < arguments.length; i++){
3930
+ var source = arguments[i] != null ? arguments[i] : {};
3931
+ var ownKeys = Object.keys(source);
3932
+ if (typeof Object.getOwnPropertySymbols === "function") {
3933
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3934
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3935
+ }));
3936
+ }
3937
+ ownKeys.forEach(function(key) {
3938
+ _define_property$5(target, key, source[key]);
3939
+ });
3940
+ }
3941
+ return target;
3942
+ }
3943
+ /**
3944
+ * UserAuthCard renders a login, registration, verification or recovery flow
3945
+ * it can also handle multi factor authentication on login flows
3946
+ * @param UserAuthCardProps - a card that renders a login, registration, verification or recovery flow
3947
+ * @returns JSX.Element
3948
+ */ function UserAuthCard(param) {
3949
+ var flow = param.flow, flowType = param.flowType, onSubmit = param.onSubmit, className = param.className;
3950
+ var _useKratosContext = useKratosContext(), _useKratosContext_components = _useKratosContext.components, PasswordlessSectionWrapper = _useKratosContext_components.PasswordlessSectionWrapper, OidcSectionWrapper = _useKratosContext_components.OidcSectionWrapper, AuthCodeSectionWrapper = _useKratosContext_components.AuthCodeSectionWrapper, LoginSectionWrapper = _useKratosContext_components.LoginSectionWrapper, RegistrationSectionWrapper = _useKratosContext_components.RegistrationSectionWrapper, UiMessages = _useKratosContext_components.UiMessages, LinkSectionWrapper = _useKratosContext_components.LinkSectionWrapper, IdentifierFirstLoginSectionWrapper = _useKratosContext_components.IdentifierFirstLoginSectionWrapper, ProfileLoginSectionWrapper = _useKratosContext_components.ProfileLoginSectionWrapper, ProfileRegistrationSectionWrapper = _useKratosContext_components.ProfileRegistrationSectionWrapper, excludeScripts = _useKratosContext.excludeScripts;
3951
+ useScriptNodes({
3952
+ nodes: flow.ui.nodes,
3953
+ excludeScripts: excludeScripts
3954
+ });
3955
+ var $flow = undefined;
3956
+ var $oidc = undefined;
3957
+ var $code = undefined;
3958
+ var $passkey = undefined;
3959
+ var $twoStep = undefined;
3960
+ var $profile = undefined;
3961
+ // the current flow is a two factor flow if the user is logged in and has any of the second factor methods enabled.
3962
+ var isTwoFactor = flowType === "login" && isLoggedIn(flow) && (hasTotp(flow.ui.nodes) || hasPasskey(flow.ui.nodes) || hasLookupSecret(flow.ui.nodes));
3963
+ // This array contains all the 2fa flows mapped to their own respective forms.
3964
+ var twoFactorFlows = isTwoFactor && [
3965
+ hasPasskey(flow.ui.nodes) && /*#__PURE__*/ jsx(UserAuthForm, {
3966
+ flow: flow,
3967
+ children: /*#__PURE__*/ jsx(FilterFlowNodes, {
3968
+ filter: {
3969
+ nodes: flow.ui.nodes,
3970
+ groups: UiNodeGroupEnum.Passkey,
3971
+ withoutDefaultGroup: true
3972
+ }
3973
+ })
3974
+ }),
3975
+ hasPassword(flow.ui.nodes) && /*#__PURE__*/ jsx(UserAuthForm, {
3976
+ flow: flow,
3977
+ children: /*#__PURE__*/ jsx(FilterFlowNodes, {
3978
+ filter: {
3979
+ nodes: flow.ui.nodes,
3980
+ groups: UiNodeGroupEnum.Password,
3981
+ withoutDefaultGroup: true
3982
+ }
3983
+ })
3984
+ }),
3985
+ hasProfile(flow.ui.nodes) && /*#__PURE__*/ jsx(UserAuthForm, {
3986
+ flow: flow,
3987
+ children: /*#__PURE__*/ jsx(FilterFlowNodes, {
3988
+ filter: {
3989
+ nodes: flow.ui.nodes,
3990
+ groups: UiNodeGroupEnum.Profile,
3991
+ withoutDefaultGroup: true
3992
+ }
3993
+ })
3994
+ }),
3995
+ hasTotp(flow.ui.nodes) && /*#__PURE__*/ jsxs(UserAuthForm, {
3996
+ submitOnEnter: true,
3997
+ flow: flow,
3998
+ onSubmit: onSubmit,
3999
+ children: [
4000
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
4001
+ filter: {
4002
+ nodes: flow.ui.nodes,
4003
+ groups: UiNodeGroupEnum.Totp,
4004
+ withoutDefaultGroup: true,
4005
+ excludeAttributes: "submit"
4006
+ }
4007
+ }),
4008
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
4009
+ filter: {
4010
+ nodes: flow.ui.nodes,
4011
+ groups: UiNodeGroupEnum.Totp,
4012
+ withoutDefaultGroup: true,
4013
+ attributes: "submit"
4014
+ }
4015
+ })
4016
+ ]
4017
+ }),
4018
+ hasLookupSecret(flow.ui.nodes) && /*#__PURE__*/ jsx(UserAuthForm, {
4019
+ submitOnEnter: true,
4020
+ flow: flow,
4021
+ onSubmit: onSubmit,
4022
+ children: /*#__PURE__*/ jsx(FilterFlowNodes, {
4023
+ filter: {
4024
+ nodes: flow.ui.nodes,
4025
+ groups: UiNodeGroupEnum.LookupSecret,
4026
+ withoutDefaultGroup: true
4027
+ }
4028
+ })
4029
+ })
4030
+ ].filter(Boolean) // remove nulls
4031
+ ;
4032
+ switch(flowType){
4033
+ case "login":
4034
+ $oidc = hasOidc(flow.ui.nodes) ? /*#__PURE__*/ jsx(OidcSection, {
4035
+ flow: flow,
4036
+ OidcSectionWrapper: OidcSectionWrapper
4037
+ }) : undefined;
4038
+ $passkey = hasPasskey(flow.ui.nodes) ? /*#__PURE__*/ jsx(PasswordlessSection, {
4039
+ flow: flow,
4040
+ PasswordlessSectionWrapper: PasswordlessSectionWrapper
4041
+ }) : undefined;
4042
+ $twoStep = hasIdentifierFirst(flow.ui.nodes) ? /*#__PURE__*/ jsx(IdentifierFirstLoginSection, {
4043
+ IdentifierFirstLoginSectionWrapper: IdentifierFirstLoginSectionWrapper,
4044
+ nodes: flow.ui.nodes
4045
+ }) : undefined;
4046
+ $profile = hasProfile(flow.ui.nodes) ? /*#__PURE__*/ jsx(ProfileLoginSection, {
4047
+ nodes: flow.ui.nodes,
4048
+ ProfileLoginSectionWrapper: ProfileLoginSectionWrapper
4049
+ }) : undefined;
4050
+ $flow = hasPassword(flow.ui.nodes) ? /*#__PURE__*/ jsx(LoginSection, {
4051
+ LoginSectionWrapper: LoginSectionWrapper,
4052
+ nodes: flow.ui.nodes
4053
+ }) : undefined;
4054
+ $code = hasCode(flow.ui.nodes) ? /*#__PURE__*/ jsx(AuthCodeSection, {
4055
+ AuthCodeSectionWrapper: AuthCodeSectionWrapper,
4056
+ nodes: flow.ui.nodes
4057
+ }) : undefined;
4058
+ break;
4059
+ case "registration":
4060
+ $passkey = hasPasskey(flow.ui.nodes) ? /*#__PURE__*/ jsx(PasswordlessSection, {
4061
+ flow: flow,
4062
+ PasswordlessSectionWrapper: PasswordlessSectionWrapper
4063
+ }) : undefined;
4064
+ $profile = hasProfile(flow.ui.nodes) ? /*#__PURE__*/ jsx(ProfileRegistrationSection, {
4065
+ nodes: flow.ui.nodes,
4066
+ ProfileRegistrationSectionWrapper: ProfileRegistrationSectionWrapper
4067
+ }) : undefined;
4068
+ $oidc = hasOidc(flow.ui.nodes) ? /*#__PURE__*/ jsx(OidcSection, {
4069
+ flow: flow,
4070
+ OidcSectionWrapper: OidcSectionWrapper
4071
+ }) : undefined;
4072
+ $code = hasCode(flow.ui.nodes) ? /*#__PURE__*/ jsx(AuthCodeSection, {
4073
+ AuthCodeSectionWrapper: AuthCodeSectionWrapper,
4074
+ nodes: flow.ui.nodes
4075
+ }) : undefined;
4076
+ $flow = hasDefault(flow.ui.nodes) || hasPassword(flow.ui.nodes) ? /*#__PURE__*/ jsx(RegistrationSection, {
4077
+ nodes: flow.ui.nodes,
4078
+ RegistrationSectionWrapper: RegistrationSectionWrapper
4079
+ }) : undefined;
4080
+ break;
4081
+ // both verification and recovery use the same flow.
4082
+ case "recovery":
4083
+ case "verification":
4084
+ $flow = /*#__PURE__*/ jsx(LinkSection, {
4085
+ LinkSectionWrapper: LinkSectionWrapper,
4086
+ nodes: flow.ui.nodes
4087
+ });
4088
+ break;
4089
+ }
4090
+ var canShowPasskey = !!$passkey && (!isLoggedIn(flow) || flowType === "registration");
4091
+ var canShowProfile = !!$profile && hasProfile(flow.ui.nodes);
4092
+ return /*#__PURE__*/ jsxs("div", {
4093
+ className: className,
4094
+ children: [
4095
+ /*#__PURE__*/ jsx(UiMessages, {
4096
+ uiMessages: flow.ui.messages
4097
+ }),
4098
+ $oidc && /*#__PURE__*/ jsx(UserAuthForm, {
4099
+ flow: flow,
4100
+ children: $oidc
4101
+ }),
4102
+ $twoStep && /*#__PURE__*/ jsx(UserAuthForm, {
4103
+ flow: flow,
4104
+ children: $twoStep
4105
+ }),
4106
+ canShowPasskey && /*#__PURE__*/ jsx(UserAuthForm, {
4107
+ submitOnEnter: true,
4108
+ flow: flow,
4109
+ onSubmit: onSubmit,
4110
+ children: $passkey
4111
+ }),
4112
+ $code && /*#__PURE__*/ jsx(UserAuthForm, {
4113
+ flow: flow,
4114
+ children: $code
4115
+ }),
4116
+ $flow && !isTwoFactor && /*#__PURE__*/ jsx(UserAuthForm, {
4117
+ submitOnEnter: true,
4118
+ flow: flow,
4119
+ onSubmit: onSubmit,
4120
+ children: $flow
4121
+ }),
4122
+ isTwoFactor && /*#__PURE__*/ jsxs(Fragment, {
4123
+ children: [
4124
+ /*#__PURE__*/ jsx(NodeMessages, {
4125
+ nodes: filterNodesByGroups({
4126
+ nodes: flow.ui.nodes,
4127
+ groups: [
4128
+ UiNodeGroupEnum.Password,
4129
+ UiNodeGroupEnum.Webauthn,
4130
+ UiNodeGroupEnum.Passkey,
4131
+ UiNodeGroupEnum.Totp,
4132
+ UiNodeGroupEnum.LookupSecret
4133
+ ]
4134
+ })
4135
+ }),
4136
+ twoFactorFlows
4137
+ ]
4138
+ }),
4139
+ canShowProfile && /*#__PURE__*/ jsx(UserAuthForm, {
4140
+ flow: flow,
4141
+ children: $profile
4142
+ })
4143
+ ]
4144
+ });
4145
+ }
4146
+ function mkCard(flowType) {
4147
+ return function(_param) {
4148
+ var props = _extends({}, _object_destructuring_empty(_param));
4149
+ return /*#__PURE__*/ jsx(UserAuthCard, _object_spread$5({
4150
+ flowType: flowType
4151
+ }, props));
4152
+ };
4153
+ }
4154
+ /**
4155
+ * Pre-built login card component for Kratos login flows.
4156
+ *
4157
+ * Renders a complete login form with support for password, passkey, OIDC,
4158
+ * multi-factor authentication, and identifier-first flows.
4159
+ *
4160
+ * @param flow - Kratos login flow object
4161
+ * @param onSubmit - Form submission handler
4162
+ * @param className - Optional CSS class name
4163
+ * @returns JSX element with login form
4164
+ */ var LoginCard = mkCard("login");
4165
+ /**
4166
+ * Pre-built verification card component for Kratos verification flows.
4167
+ *
4168
+ * Renders a complete verification form for email/phone verification processes.
4169
+ *
4170
+ * @param flow - Kratos verification flow object
4171
+ * @param onSubmit - Form submission handler
4172
+ * @param className - Optional CSS class name
4173
+ * @returns JSX element with verification form
4174
+ */ var VerificationCard = mkCard("verification");
4175
+ /**
4176
+ * Pre-built registration card component for Kratos registration flows.
4177
+ *
4178
+ * Renders a complete registration form with support for profile fields,
4179
+ * password, passkey, and OIDC registration methods.
4180
+ *
4181
+ * @param flow - Kratos registration flow object
4182
+ * @param onSubmit - Form submission handler
4183
+ * @param className - Optional CSS class name
4184
+ * @returns JSX element with registration form
4185
+ */ var RegistrationCard = mkCard("registration");
4186
+ /**
4187
+ * Pre-built recovery card component for Kratos account recovery flows.
4188
+ *
4189
+ * Renders a complete recovery form for password reset and account recovery processes.
4190
+ *
4191
+ * @param flow - Kratos recovery flow object
4192
+ * @param onSubmit - Form submission handler
4193
+ * @param className - Optional CSS class name
4194
+ * @returns JSX element with recovery form
4195
+ */ var RecoveryCard = mkCard("recovery");
4196
+ // the user might need to logout on the second factor page.
4197
+ function isLoggedIn(flow) {
4198
+ if ("requested_aal" in flow && flow.requested_aal === AuthenticatorAssuranceLevel.Aal2) {
4199
+ return true;
4200
+ } else if ("refresh" in flow && flow.refresh) {
4201
+ return true;
4202
+ }
4203
+ return false;
4204
+ }
4205
+
4206
+ function _define_property$4(obj, key, value) {
4207
+ if (key in obj) {
4208
+ Object.defineProperty(obj, key, {
4209
+ value: value,
4210
+ enumerable: true,
4211
+ configurable: true,
4212
+ writable: true
4213
+ });
4214
+ } else {
4215
+ obj[key] = value;
4216
+ }
4217
+ return obj;
4218
+ }
4219
+ function _object_spread$4(target) {
4220
+ for(var i = 1; i < arguments.length; i++){
4221
+ var source = arguments[i] != null ? arguments[i] : {};
4222
+ var ownKeys = Object.keys(source);
4223
+ if (typeof Object.getOwnPropertySymbols === "function") {
4224
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
4225
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
4226
+ }));
4227
+ }
4228
+ ownKeys.forEach(function(key) {
4229
+ _define_property$4(target, key, source[key]);
4230
+ });
4231
+ }
4232
+ return target;
4233
+ }
4234
+ function ownKeys$4(object, enumerableOnly) {
4235
+ var keys = Object.keys(object);
4236
+ if (Object.getOwnPropertySymbols) {
4237
+ var symbols = Object.getOwnPropertySymbols(object);
4238
+ keys.push.apply(keys, symbols);
4239
+ }
4240
+ return keys;
4241
+ }
4242
+ function _object_spread_props$4(target, source) {
4243
+ source = source != null ? source : {};
4244
+ if (Object.getOwnPropertyDescriptors) {
4245
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
4246
+ } else {
4247
+ ownKeys$4(Object(source)).forEach(function(key) {
4248
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
4249
+ });
4250
+ }
4251
+ return target;
4252
+ }
4253
+ function LookupSecretSettingsSection(param) {
4254
+ var flow = param.flow, LookupSecretSettingsSectionWrapper = param.LookupSecretSettingsSectionWrapper;
4255
+ var filter = {
4256
+ nodes: flow.ui.nodes,
4257
+ groups: UiNodeGroupEnum.LookupSecret,
4258
+ withoutDefaultGroup: true
4259
+ };
4260
+ if (!hasLookupSecret(flow.ui.nodes)) return null;
4261
+ return /*#__PURE__*/ jsxs(LookupSecretSettingsSectionWrapper, {
4262
+ children: [
4263
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
4264
+ filter: _object_spread_props$4(_object_spread$4({}, filter), {
4265
+ excludeAttributes: "submit,button"
4266
+ })
4267
+ }),
4268
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
4269
+ filter: _object_spread_props$4(_object_spread$4({}, filter), {
4270
+ attributes: "submit,button"
4271
+ })
4272
+ })
4273
+ ]
4274
+ });
4275
+ }
4276
+
4277
+ function OidcSettingsSection(param) {
4278
+ var flow = param.flow, OidcSettingsSectionWrapper = param.OidcSettingsSectionWrapper;
4279
+ if (!hasOidc(flow.ui.nodes)) return null;
4280
+ return /*#__PURE__*/ jsx(OidcSettingsSectionWrapper, {
4281
+ children: /*#__PURE__*/ jsx(FilterFlowNodes, {
4282
+ filter: {
4283
+ nodes: flow.ui.nodes,
4284
+ groups: UiNodeGroupEnum.Oidc,
4285
+ withoutDefaultGroup: true
4286
+ }
4287
+ })
4288
+ });
4289
+ }
4290
+
4291
+ function _define_property$3(obj, key, value) {
4292
+ if (key in obj) {
4293
+ Object.defineProperty(obj, key, {
4294
+ value: value,
4295
+ enumerable: true,
4296
+ configurable: true,
4297
+ writable: true
4298
+ });
4299
+ } else {
4300
+ obj[key] = value;
4301
+ }
4302
+ return obj;
4303
+ }
4304
+ function _object_spread$3(target) {
4305
+ for(var i = 1; i < arguments.length; i++){
4306
+ var source = arguments[i] != null ? arguments[i] : {};
4307
+ var ownKeys = Object.keys(source);
4308
+ if (typeof Object.getOwnPropertySymbols === "function") {
4309
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
4310
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
4311
+ }));
4312
+ }
4313
+ ownKeys.forEach(function(key) {
4314
+ _define_property$3(target, key, source[key]);
4315
+ });
4316
+ }
4317
+ return target;
4318
+ }
4319
+ function ownKeys$3(object, enumerableOnly) {
4320
+ var keys = Object.keys(object);
4321
+ if (Object.getOwnPropertySymbols) {
4322
+ var symbols = Object.getOwnPropertySymbols(object);
4323
+ keys.push.apply(keys, symbols);
4324
+ }
4325
+ return keys;
4326
+ }
4327
+ function _object_spread_props$3(target, source) {
4328
+ source = source != null ? source : {};
4329
+ if (Object.getOwnPropertyDescriptors) {
4330
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
4331
+ } else {
4332
+ ownKeys$3(Object(source)).forEach(function(key) {
4333
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
4334
+ });
4335
+ }
4336
+ return target;
4337
+ }
4338
+ function PasskeySettingsSection(param) {
4339
+ var flow = param.flow, PasskeySettingsSectionWrapper = param.PasskeySettingsSectionWrapper;
4340
+ if (!hasPasskey(flow.ui.nodes)) return null;
4341
+ var filter = {
4342
+ nodes: flow.ui.nodes,
4343
+ groups: UiNodeGroupEnum.Passkey,
4344
+ withoutDefaultGroup: true
4345
+ };
4346
+ return /*#__PURE__*/ jsxs(PasskeySettingsSectionWrapper, {
4347
+ children: [
4348
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
4349
+ filter: _object_spread_props$3(_object_spread$3({}, filter), {
4350
+ excludeAttributes: "submit,button"
4351
+ })
4352
+ }),
4353
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
4354
+ filter: _object_spread_props$3(_object_spread$3({}, filter), {
4355
+ attributes: "submit,button"
4356
+ })
4357
+ })
4358
+ ]
4359
+ });
4360
+ }
4361
+
4362
+ function _define_property$2(obj, key, value) {
4363
+ if (key in obj) {
4364
+ Object.defineProperty(obj, key, {
4365
+ value: value,
4366
+ enumerable: true,
4367
+ configurable: true,
4368
+ writable: true
4369
+ });
4370
+ } else {
4371
+ obj[key] = value;
4372
+ }
4373
+ return obj;
4374
+ }
4375
+ function _object_spread$2(target) {
4376
+ for(var i = 1; i < arguments.length; i++){
4377
+ var source = arguments[i] != null ? arguments[i] : {};
4378
+ var ownKeys = Object.keys(source);
4379
+ if (typeof Object.getOwnPropertySymbols === "function") {
4380
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
4381
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
4382
+ }));
4383
+ }
4384
+ ownKeys.forEach(function(key) {
4385
+ _define_property$2(target, key, source[key]);
4386
+ });
4387
+ }
4388
+ return target;
4389
+ }
4390
+ function ownKeys$2(object, enumerableOnly) {
4391
+ var keys = Object.keys(object);
4392
+ if (Object.getOwnPropertySymbols) {
4393
+ var symbols = Object.getOwnPropertySymbols(object);
4394
+ keys.push.apply(keys, symbols);
4395
+ }
4396
+ return keys;
4397
+ }
4398
+ function _object_spread_props$2(target, source) {
4399
+ source = source != null ? source : {};
4400
+ if (Object.getOwnPropertyDescriptors) {
4401
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
4402
+ } else {
4403
+ ownKeys$2(Object(source)).forEach(function(key) {
4404
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
4405
+ });
4406
+ }
4407
+ return target;
4408
+ }
4409
+ function PasswordSettingsSection(param) {
4410
+ var flow = param.flow, PasswordSettingsSectionWrapper = param.PasswordSettingsSectionWrapper;
4411
+ if (!hasPassword(flow.ui.nodes)) return null;
4412
+ var filter = {
4413
+ nodes: flow.ui.nodes,
4414
+ groups: UiNodeGroupEnum.Password,
4415
+ withoutDefaultGroup: true
4416
+ };
4417
+ return /*#__PURE__*/ jsxs(PasswordSettingsSectionWrapper, {
4418
+ children: [
4419
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
4420
+ filter: _object_spread_props$2(_object_spread$2({}, filter), {
4421
+ excludeAttributes: "submit,button"
4422
+ })
4423
+ }),
4424
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
4425
+ filter: _object_spread_props$2(_object_spread$2({}, filter), {
4426
+ attributes: "submit,button"
4427
+ })
4428
+ })
4429
+ ]
4430
+ });
4431
+ }
4432
+
4433
+ function _define_property$1(obj, key, value) {
4434
+ if (key in obj) {
4435
+ Object.defineProperty(obj, key, {
4436
+ value: value,
4437
+ enumerable: true,
4438
+ configurable: true,
4439
+ writable: true
4440
+ });
4441
+ } else {
4442
+ obj[key] = value;
4443
+ }
4444
+ return obj;
4445
+ }
4446
+ function _object_spread$1(target) {
4447
+ for(var i = 1; i < arguments.length; i++){
4448
+ var source = arguments[i] != null ? arguments[i] : {};
4449
+ var ownKeys = Object.keys(source);
4450
+ if (typeof Object.getOwnPropertySymbols === "function") {
4451
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
4452
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
4453
+ }));
4454
+ }
4455
+ ownKeys.forEach(function(key) {
4456
+ _define_property$1(target, key, source[key]);
4457
+ });
4458
+ }
4459
+ return target;
4460
+ }
4461
+ function ownKeys$1(object, enumerableOnly) {
4462
+ var keys = Object.keys(object);
4463
+ if (Object.getOwnPropertySymbols) {
4464
+ var symbols = Object.getOwnPropertySymbols(object);
4465
+ keys.push.apply(keys, symbols);
4466
+ }
4467
+ return keys;
4468
+ }
4469
+ function _object_spread_props$1(target, source) {
4470
+ source = source != null ? source : {};
4471
+ if (Object.getOwnPropertyDescriptors) {
4472
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
4473
+ } else {
4474
+ ownKeys$1(Object(source)).forEach(function(key) {
4475
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
4476
+ });
4477
+ }
4478
+ return target;
4479
+ }
4480
+ function ProfileSettingsSection(param) {
4481
+ var flow = param.flow, ProfileSettingsSectionWrapper = param.ProfileSettingsSectionWrapper;
4482
+ var filter = {
4483
+ nodes: flow.ui.nodes,
4484
+ groups: UiNodeGroupEnum.Profile
4485
+ };
4486
+ return /*#__PURE__*/ jsxs(ProfileSettingsSectionWrapper, {
4487
+ children: [
4488
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
4489
+ filter: _object_spread_props$1(_object_spread$1({}, filter), {
4490
+ excludeAttributes: "submit,button"
4491
+ })
4492
+ }),
4493
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
4494
+ filter: _object_spread_props$1(_object_spread$1({}, filter), {
4495
+ attributes: "submit,button"
4496
+ })
4497
+ })
4498
+ ]
4499
+ });
4500
+ }
4501
+
4502
+ function _define_property(obj, key, value) {
4503
+ if (key in obj) {
4504
+ Object.defineProperty(obj, key, {
4505
+ value: value,
4506
+ enumerable: true,
4507
+ configurable: true,
4508
+ writable: true
4509
+ });
4510
+ } else {
4511
+ obj[key] = value;
4512
+ }
4513
+ return obj;
4514
+ }
4515
+ function _object_spread(target) {
4516
+ for(var i = 1; i < arguments.length; i++){
4517
+ var source = arguments[i] != null ? arguments[i] : {};
4518
+ var ownKeys = Object.keys(source);
4519
+ if (typeof Object.getOwnPropertySymbols === "function") {
4520
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
4521
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
4522
+ }));
4523
+ }
4524
+ ownKeys.forEach(function(key) {
4525
+ _define_property(target, key, source[key]);
4526
+ });
4527
+ }
4528
+ return target;
4529
+ }
4530
+ function ownKeys(object, enumerableOnly) {
4531
+ var keys = Object.keys(object);
4532
+ if (Object.getOwnPropertySymbols) {
4533
+ var symbols = Object.getOwnPropertySymbols(object);
4534
+ keys.push.apply(keys, symbols);
4535
+ }
4536
+ return keys;
4537
+ }
4538
+ function _object_spread_props(target, source) {
4539
+ source = source != null ? source : {};
4540
+ if (Object.getOwnPropertyDescriptors) {
4541
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
4542
+ } else {
4543
+ ownKeys(Object(source)).forEach(function(key) {
4544
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
4545
+ });
4546
+ }
4547
+ return target;
4548
+ }
4549
+ function TotpSettingsSection(param) {
4550
+ var flow = param.flow, TotpSettingsSectionWrapper = param.TotpSettingsSectionWrapper;
4551
+ if (!hasTotp(flow.ui.nodes)) return null;
4552
+ var filter = {
4553
+ nodes: flow.ui.nodes,
4554
+ groups: UiNodeGroupEnum.Totp,
4555
+ withoutDefaultGroup: true
4556
+ };
4557
+ return /*#__PURE__*/ jsxs(TotpSettingsSectionWrapper, {
4558
+ children: [
4559
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
4560
+ filter: _object_spread_props(_object_spread({}, filter), {
4561
+ excludeAttributes: "submit,button"
4562
+ })
4563
+ }),
4564
+ /*#__PURE__*/ jsx(FilterFlowNodes, {
4565
+ filter: _object_spread_props(_object_spread({}, filter), {
4566
+ attributes: "submit,button"
4567
+ })
4568
+ })
4569
+ ]
4570
+ });
4571
+ }
4572
+
4573
+ /**
4574
+ * Pre-built settings card component for Kratos settings flows.
4575
+ *
4576
+ * Renders different settings sections based on flow type: profile, password,
4577
+ * passkey, TOTP, lookup secrets, or OIDC settings management.
4578
+ *
4579
+ * @param flow - Kratos settings flow object
4580
+ * @param flowType - Type of settings flow to render
4581
+ * @param onSubmit - Form submission handler
4582
+ * @param className - Optional CSS class name
4583
+ * @returns JSX element with settings form or null if flow type unavailable
4584
+ * @example
4585
+ * ```typescript
4586
+ * import { UserSettingsCard } from '@leancodepl/kratos';
4587
+ *
4588
+ * function ProfileSettings() {
4589
+ * return (
4590
+ * <UserSettingsCard
4591
+ * flow={settingsFlow}
4592
+ * flowType="profile"
4593
+ * onSubmit={handleSubmit}
4594
+ * />
4595
+ * );
4596
+ * }
4597
+ * ```
4598
+ */ function UserSettingsCard(param) {
4599
+ var flow = param.flow, flowType = param.flowType, onSubmit = param.onSubmit, className = param.className;
4600
+ var _useKratosContext = useKratosContext(), _useKratosContext_components = _useKratosContext.components, ProfileSettingsSectionWrapper = _useKratosContext_components.ProfileSettingsSectionWrapper, PasswordSettingsSectionWrapper = _useKratosContext_components.PasswordSettingsSectionWrapper, WebAuthnSettingsSectionWrapper = _useKratosContext_components.WebAuthnSettingsSectionWrapper, LookupSecretSettingsSectionWrapper = _useKratosContext_components.LookupSecretSettingsSectionWrapper, OidcSettingsSectionWrapper = _useKratosContext_components.OidcSettingsSectionWrapper, TotpSettingsSectionWrapper = _useKratosContext_components.TotpSettingsSectionWrapper, UiMessages = _useKratosContext_components.UiMessages, excludeScripts = _useKratosContext.excludeScripts;
4601
+ useScriptNodes({
4602
+ nodes: flow.ui.nodes,
4603
+ excludeScripts: excludeScripts
4604
+ });
4605
+ var $flow = function() {
4606
+ if (flowType === UiNodeGroupEnum.Profile) {
4607
+ return /*#__PURE__*/ jsx(ProfileSettingsSection, {
4608
+ flow: flow,
4609
+ ProfileSettingsSectionWrapper: ProfileSettingsSectionWrapper
4610
+ });
4611
+ } else if (flowType === UiNodeGroupEnum.Password && hasPassword(flow.ui.nodes)) {
4612
+ return /*#__PURE__*/ jsx(PasswordSettingsSection, {
4613
+ flow: flow,
4614
+ PasswordSettingsSectionWrapper: PasswordSettingsSectionWrapper
4615
+ });
4616
+ } else if (flowType === UiNodeGroupEnum.Passkey && hasPasskey(flow.ui.nodes)) {
4617
+ return /*#__PURE__*/ jsx(PasskeySettingsSection, {
4618
+ flow: flow,
4619
+ PasskeySettingsSectionWrapper: WebAuthnSettingsSectionWrapper
4620
+ });
4621
+ } else if (flowType === UiNodeGroupEnum.LookupSecret && hasLookupSecret(flow.ui.nodes)) {
4622
+ return /*#__PURE__*/ jsx(LookupSecretSettingsSection, {
4623
+ flow: flow,
4624
+ LookupSecretSettingsSectionWrapper: LookupSecretSettingsSectionWrapper
4625
+ });
4626
+ } else if (flowType === UiNodeGroupEnum.Oidc && hasOidc(flow.ui.nodes)) {
4627
+ return /*#__PURE__*/ jsx(OidcSettingsSection, {
4628
+ flow: flow,
4629
+ OidcSettingsSectionWrapper: OidcSettingsSectionWrapper
4630
+ });
4631
+ } else if (flowType === UiNodeGroupEnum.Totp && hasTotp(flow.ui.nodes)) {
4632
+ return /*#__PURE__*/ jsx(TotpSettingsSection, {
4633
+ flow: flow,
4634
+ TotpSettingsSectionWrapper: TotpSettingsSectionWrapper
4635
+ });
4636
+ }
4637
+ return null;
4638
+ }();
4639
+ if (!$flow) return null;
4640
+ return /*#__PURE__*/ jsxs(UserAuthForm, {
4641
+ className: className,
4642
+ flow: flow,
4643
+ onSubmit: onSubmit,
4644
+ children: [
4645
+ /*#__PURE__*/ jsx(UiMessages, {
4646
+ uiMessages: flow.ui.messages
4647
+ }),
4648
+ $flow
4649
+ ]
4650
+ });
4651
+ }
4652
+
4653
+ export { BaseSessionManager, ErrorId, ErrorSystem, ErrorValidation, ErrorValidationLogin, ErrorValidationRecovery, ErrorValidationRegistration, ErrorValidationSettings, ErrorValidationVerification, InfoNodeLabel, InfoSelfServiceLogin, InfoSelfServiceLogout, InfoSelfServiceMFA, InfoSelfServiceRecovery, InfoSelfServiceRegistration, InfoSelfServiceSettings, InfoSelfServiceVerification, KratosContextProvider, LoginCard, RecoveryCard, RegistrationCard, UserSettingsCard, VerificationCard, aalParameterName, createKratosClient, flowIdParameterName, isUiNodeAnchorAttributes, isUiNodeImageAttributes, isUiNodeInputAttributes, isUiNodeScriptAttributes, isUiNodeTextAttributes, isUiNodeTextSecretsAttributes, kratosContext, refreshParameterName, returnToParameterName, useKratosContext, useLoginFlow, useLogoutFlow, useReauthenticationFlow, useRecoveryFlow, useRegisterFlow, useSettingsFlow, useVerificationFlow };