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