datakeen-session-react 1.1.171 → 1.1.172

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 (30) hide show
  1. package/dist/cjs/components/template/ExternalVerificationNodeHandler.js +248 -77
  2. package/dist/cjs/components/template/ExternalVerificationNodeHandler.js.map +1 -1
  3. package/dist/cjs/components/template/TemplateNodeRenderer.js +23 -8
  4. package/dist/cjs/components/template/TemplateNodeRenderer.js.map +1 -1
  5. package/dist/cjs/hooks/useStepNavigation.js +23 -0
  6. package/dist/cjs/hooks/useStepNavigation.js.map +1 -1
  7. package/dist/cjs/hooks/useUserInputForm.js +29 -0
  8. package/dist/cjs/hooks/useUserInputForm.js.map +1 -1
  9. package/dist/cjs/i18n/en.json.js +23 -1
  10. package/dist/cjs/i18n/en.json.js.map +1 -1
  11. package/dist/cjs/i18n/fr.json.js +23 -1
  12. package/dist/cjs/i18n/fr.json.js.map +1 -1
  13. package/dist/cjs/index.css.js +1 -1
  14. package/dist/cjs/types/session.js.map +1 -1
  15. package/dist/esm/components/template/ExternalVerificationNodeHandler.js +250 -79
  16. package/dist/esm/components/template/ExternalVerificationNodeHandler.js.map +1 -1
  17. package/dist/esm/components/template/TemplateNodeRenderer.js +23 -8
  18. package/dist/esm/components/template/TemplateNodeRenderer.js.map +1 -1
  19. package/dist/esm/hooks/useStepNavigation.js +23 -0
  20. package/dist/esm/hooks/useStepNavigation.js.map +1 -1
  21. package/dist/esm/hooks/useUserInputForm.js +29 -0
  22. package/dist/esm/hooks/useUserInputForm.js.map +1 -1
  23. package/dist/esm/i18n/en.json.js +22 -2
  24. package/dist/esm/i18n/en.json.js.map +1 -1
  25. package/dist/esm/i18n/fr.json.js +22 -2
  26. package/dist/esm/i18n/fr.json.js.map +1 -1
  27. package/dist/esm/index.css.js +1 -1
  28. package/dist/esm/types/session.js.map +1 -1
  29. package/docs/multi-runs.md +5 -1
  30. package/package.json +1 -1
@@ -7,20 +7,30 @@ var jsxRuntime = require('react/jsx-runtime');
7
7
  var React = require('react');
8
8
  var reactI18next = require('react-i18next');
9
9
  var index = require('../../i18n/index.js');
10
- var lucideReact = require('lucide-react');
11
10
  var api = require('../../services/api.js');
11
+ var check = require('../../assets/check.svg.js');
12
+ var LoadingState = require('../states/LoadingState.js');
13
+ var Title = require('../ui/Title.js');
14
+ var Subtitle = require('../ui/Subtitle.js');
15
+ var Button = require('../ui/Button.js');
12
16
 
17
+ // ─── Helpers ──────────────────────────────────────────────────────────────────
13
18
  var FIELD_ALIASES = {
14
19
  siren: ['siren', 'siren_number', 'company_siren', 'legal_siren', 'num_siren'],
15
20
  siret: ['siret', 'siret_number', 'company_siret', 'legal_siret', 'num_siret'],
16
21
  };
22
+ var STANDARD_FIELD_ALIASES = {
23
+ prenom: ['firstName', 'first_name', 'prenom'],
24
+ nom: ['lastName', 'last_name', 'surname', 'familyName', 'nom'],
25
+ date_naissance: ['birthDate', 'birth_date', 'dateOfBirth', 'date_naissance'],
26
+ };
17
27
  var normalizeReferenceField = function (field) {
18
28
  if (!field)
19
29
  return undefined;
20
- var normalized = field.toLowerCase().replace(/[\s_.-]/g, '');
21
- if (normalized.includes('siret'))
30
+ var n = field.toLowerCase().replace(/[\s_.-]/g, '');
31
+ if (n.includes('siret'))
22
32
  return 'siret';
23
- if (normalized.includes('siren'))
33
+ if (n.includes('siren'))
24
34
  return 'siren';
25
35
  return undefined;
26
36
  };
@@ -32,150 +42,311 @@ var maskReferenceValue = function (value) {
32
42
  return '****';
33
43
  return "".concat('*'.repeat(clean.length - 4)).concat(clean.slice(-4));
34
44
  };
45
+ var resolveFieldValue = function (nodeInput, userInputFlat, keys) {
46
+ var _a, _b, _c, _d, _e;
47
+ for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
48
+ var key = keys_1[_i];
49
+ var candidate = (_e = (_c = (_a = nodeInput === null || nodeInput === void 0 ? void 0 : nodeInput[key]) !== null && _a !== void 0 ? _a : (_b = nodeInput === null || nodeInput === void 0 ? void 0 : nodeInput.customFormData) === null || _b === void 0 ? void 0 : _b[key]) !== null && _c !== void 0 ? _c : (_d = userInputFlat === null || userInputFlat === void 0 ? void 0 : userInputFlat.customFormData) === null || _d === void 0 ? void 0 : _d[key]) !== null && _e !== void 0 ? _e : userInputFlat === null || userInputFlat === void 0 ? void 0 : userInputFlat[key];
50
+ if (candidate !== undefined && candidate !== null && "".concat(candidate).trim() !== '') {
51
+ return String(candidate);
52
+ }
53
+ }
54
+ return undefined;
55
+ };
56
+ var expandFieldKey = function (key) { var _a; return tslib_es6.__spreadArray([key], ((_a = STANDARD_FIELD_ALIASES[key]) !== null && _a !== void 0 ? _a : []), true); };
57
+ // ─── Component ────────────────────────────────────────────────────────────────
35
58
  var ExternalVerificationNodeHandler = function (_a) {
36
- var node = _a.node, session = _a.session, userInput = _a.userInput, setUserInput = _a.setUserInput, onNext = _a.onNext;
59
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
60
+ var node = _a.node, session = _a.session, userInput = _a.userInput, setUserInput = _a.setUserInput, onNext = _a.onNext, onPrevious = _a.onPrevious, onNavigateToNode = _a.onNavigateToNode;
37
61
  var t = reactI18next.useTranslation('translation', { i18n: index.default }).t;
62
+ var nodeData = node;
63
+ var apiType = String(nodeData.targetApi || 'INSEE');
64
+ var isInpiRbe = apiType === 'INPI_RBE';
65
+ var _o = React.useState('loading'), phase = _o[0], setPhase = _o[1];
66
+ var _p = React.useState(null), errorScreenData = _p[0], setErrorScreenData = _p[1];
67
+ var _q = React.useState(function () {
68
+ if (isInpiRbe) {
69
+ return [
70
+ {
71
+ title: t('inpi_verification.step1', 'Appel au RNE'),
72
+ subtitle: t('inpi_verification.step1_sub', 'Connexion au registre national des entreprises'),
73
+ status: 'active',
74
+ },
75
+ {
76
+ title: t('inpi_verification.step2', "Récupération des données d'entreprise"),
77
+ subtitle: t('inpi_verification.step2_sub', 'Lecture des informations légales et des dirigeants'),
78
+ status: 'pending',
79
+ },
80
+ {
81
+ title: t('inpi_verification.step3', 'Comparaison avec les données saisies'),
82
+ subtitle: t('inpi_verification.step3_sub', 'Vérification de la concordance des informations'),
83
+ status: 'pending',
84
+ },
85
+ ];
86
+ }
87
+ return [{
88
+ title: t('verification_node.verifying_title', 'Vérification en cours…'),
89
+ subtitle: t('verification_node.verifying_desc', 'Connexion au service externe'),
90
+ status: 'active',
91
+ }];
92
+ }), steps = _q[0], setSteps = _q[1];
93
+ var advanceStep = function (index) {
94
+ setSteps(function (prev) {
95
+ return prev.map(function (s, i) {
96
+ if (i < index)
97
+ return tslib_es6.__assign(tslib_es6.__assign({}, s), { status: 'done' });
98
+ if (i === index)
99
+ return tslib_es6.__assign(tslib_es6.__assign({}, s), { status: 'active' });
100
+ return s;
101
+ });
102
+ });
103
+ };
104
+ var completeSteps = function () { return setSteps(function (prev) { return prev.map(function (s) { return (tslib_es6.__assign(tslib_es6.__assign({}, s), { status: 'done' })); }); }); };
38
105
  React.useEffect(function () {
39
- var performVerification = function () { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
40
- var verificationResult, apiType, referenceField, referenceValueMasked, nodeData, referenceNodeId, referenceVariable, nodeInput, userInputFlat, lookupKeys, referenceValue, _i, lookupKeys_1, key, candidateValue, allCustomFields, _a, _b, _c, key, value, stringValue, response, result, apiErr_1, apiResult, err_1;
41
- var _d, _e, _f, _g, _h, _j, _k, _l;
42
- return tslib_es6.__generator(this, function (_m) {
43
- switch (_m.label) {
106
+ var abortController = new AbortController();
107
+ var run = function () { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
108
+ var result, referenceField, referenceValueMasked, resolvedReferenceValue, referenceNodeId, referenceVariable, submittedFirstName, submittedLastName, nodeInput, userInputFlat, lookupKeys, referenceValue, allCustomFields, _i, _a, _b, value, str, comparisonConfig, cfg, personNodeInput, flat, firstNameKeys, lastNameKeys, birthDateKeys, dateOfBirth, response, res, apiErr_1, apiResult, inpi, cfg;
109
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
110
+ return tslib_es6.__generator(this, function (_s) {
111
+ switch (_s.label) {
44
112
  case 0:
45
- verificationResult = {
113
+ result = {
46
114
  isVerified: false,
47
115
  status: 'external_error',
48
116
  message: 'Verification did not run.',
49
117
  };
50
- apiType = node.targetApi || 'INSEE';
51
118
  referenceValueMasked = '';
52
- console.log("Api Type :", apiType);
53
- _m.label = 1;
54
- case 1:
55
- _m.trys.push([1, 8, , 9]);
56
- if (!(session === null || session === void 0 ? void 0 : session.id)) {
57
- throw new Error('Session ID is missing');
58
- }
59
- nodeData = node;
60
- apiType = String(nodeData.targetApi || 'INSEE');
119
+ resolvedReferenceValue = '';
61
120
  referenceNodeId = String(nodeData.referenceNodeId || '');
62
121
  referenceVariable = String(nodeData.referenceVariable || '');
122
+ submittedFirstName = '';
123
+ submittedLastName = '';
124
+ _s.label = 1;
125
+ case 1:
126
+ _s.trys.push([1, 9, , 10]);
127
+ if (!(session === null || session === void 0 ? void 0 : session.id))
128
+ throw new Error('Session ID is missing');
63
129
  referenceField = normalizeReferenceField(String(nodeData.referenceField || referenceVariable || ''));
64
130
  if (!(!referenceNodeId || !referenceField)) return [3 /*break*/, 2];
65
- verificationResult = {
131
+ result = {
66
132
  isVerified: false,
67
133
  status: 'config_error',
68
134
  message: 'External verification node is missing reference configuration.',
69
135
  errorCode: 'MISSING_REFERENCE_CONFIG',
70
136
  };
71
- return [3 /*break*/, 7];
137
+ return [3 /*break*/, 8];
72
138
  case 2:
73
139
  nodeInput = userInput[referenceNodeId];
74
140
  userInputFlat = userInput;
75
- lookupKeys = Array.from(new Set(tslib_es6.__spreadArray([
76
- referenceVariable,
77
- referenceField
78
- ], FIELD_ALIASES[referenceField], true).filter(Boolean)));
79
- referenceValue = void 0;
80
- for (_i = 0, lookupKeys_1 = lookupKeys; _i < lookupKeys_1.length; _i++) {
81
- key = lookupKeys_1[_i];
82
- candidateValue = (_h = (_f = (_d = nodeInput === null || nodeInput === void 0 ? void 0 : nodeInput[key]) !== null && _d !== void 0 ? _d : (_e = nodeInput === null || nodeInput === void 0 ? void 0 : nodeInput.customFormData) === null || _e === void 0 ? void 0 : _e[key]) !== null && _f !== void 0 ? _f : (_g = userInputFlat === null || userInputFlat === void 0 ? void 0 : userInputFlat.customFormData) === null || _g === void 0 ? void 0 : _g[key]) !== null && _h !== void 0 ? _h : userInputFlat === null || userInputFlat === void 0 ? void 0 : userInputFlat[key];
83
- if (candidateValue !== undefined && candidateValue !== null && "".concat(candidateValue).trim() !== '') {
84
- referenceValue = String(candidateValue);
85
- break;
86
- }
87
- }
88
- // Fallback: Smart lookup if no value found by key
141
+ lookupKeys = Array.from(new Set(tslib_es6.__spreadArray([referenceVariable, referenceField], FIELD_ALIASES[referenceField], true).filter(Boolean)));
142
+ referenceValue = resolveFieldValue(nodeInput, userInputFlat, lookupKeys);
89
143
  if (!referenceValue) {
90
144
  allCustomFields = tslib_es6.__assign(tslib_es6.__assign(tslib_es6.__assign({}, ((userInputFlat === null || userInputFlat === void 0 ? void 0 : userInputFlat.customFormData) || {})), ((nodeInput === null || nodeInput === void 0 ? void 0 : nodeInput.customFormData) || {})), (nodeInput || {}));
91
- for (_a = 0, _b = Object.entries(allCustomFields); _a < _b.length; _a++) {
92
- _c = _b[_a], key = _c[0], value = _c[1];
145
+ for (_i = 0, _a = Object.entries(allCustomFields); _i < _a.length; _i++) {
146
+ _b = _a[_i], value = _b[1];
93
147
  if (typeof value !== 'string' && typeof value !== 'number')
94
148
  continue;
95
- stringValue = String(value).replace(/\s+/g, '');
96
- // 9-digit SIREN pattern
97
- if (referenceField === 'siren' && /^\d{9}$/.test(stringValue)) {
98
- referenceValue = stringValue;
149
+ str = String(value).replace(/\s+/g, '');
150
+ if (referenceField === 'siren' && /^\d{9}$/.test(str)) {
151
+ referenceValue = str;
99
152
  break;
100
153
  }
101
- // 14-digit SIRET pattern
102
- if (referenceField === 'siret' && /^\d{14}$/.test(stringValue)) {
103
- referenceValue = stringValue;
154
+ if (referenceField === 'siret' && /^\d{14}$/.test(str)) {
155
+ referenceValue = str;
104
156
  break;
105
157
  }
106
158
  }
107
159
  }
108
160
  if (!!referenceValue) return [3 /*break*/, 3];
109
- verificationResult = {
161
+ result = {
110
162
  isVerified: false,
111
163
  status: 'invalid_input',
112
164
  message: 'No SIREN/SIRET value found in source node data.',
113
165
  errorCode: 'REFERENCE_VALUE_NOT_FOUND',
114
166
  };
115
- return [3 /*break*/, 7];
167
+ return [3 /*break*/, 8];
116
168
  case 3:
169
+ resolvedReferenceValue = referenceValue;
117
170
  referenceValueMasked = maskReferenceValue(referenceValue);
118
- _m.label = 4;
171
+ comparisonConfig = void 0;
172
+ if (isInpiRbe && ((_c = nodeData.comparisonConfig) === null || _c === void 0 ? void 0 : _c.personReferenceNodeId)) {
173
+ cfg = nodeData.comparisonConfig;
174
+ personNodeInput = (_d = userInput[cfg.personReferenceNodeId]) !== null && _d !== void 0 ? _d : {};
175
+ flat = userInput;
176
+ firstNameKeys = expandFieldKey((_e = cfg.personFirstNameField) !== null && _e !== void 0 ? _e : '').filter(Boolean);
177
+ lastNameKeys = expandFieldKey((_f = cfg.personLastNameField) !== null && _f !== void 0 ? _f : '').filter(Boolean);
178
+ birthDateKeys = cfg.personBirthDateField
179
+ ? expandFieldKey(cfg.personBirthDateField).filter(Boolean)
180
+ : [];
181
+ submittedFirstName = (_g = resolveFieldValue(personNodeInput, flat, firstNameKeys)) !== null && _g !== void 0 ? _g : '';
182
+ submittedLastName = (_h = resolveFieldValue(personNodeInput, flat, lastNameKeys)) !== null && _h !== void 0 ? _h : '';
183
+ dateOfBirth = cfg.compareBirthDate && birthDateKeys.length
184
+ ? resolveFieldValue(personNodeInput, flat, birthDateKeys)
185
+ : undefined;
186
+ if (submittedFirstName && submittedLastName) {
187
+ comparisonConfig = tslib_es6.__assign({ firstName: submittedFirstName, lastName: submittedLastName, compareTargets: (_j = cfg.compareTargets) !== null && _j !== void 0 ? _j : ['mandataires'] }, (dateOfBirth ? { dateOfBirth: dateOfBirth } : {}));
188
+ }
189
+ }
190
+ if (isInpiRbe)
191
+ advanceStep(1);
192
+ _s.label = 4;
119
193
  case 4:
120
- _m.trys.push([4, 6, , 7]);
121
- return [4 /*yield*/, api.apiService.post("/session/sdk/".concat(session.id, "/verify-external/").concat(node.id), { apiType: apiType, referenceValue: referenceValue, referenceField: referenceField })];
194
+ _s.trys.push([4, 7, , 8]);
195
+ return [4 /*yield*/, api.apiService.post("/session/sdk/".concat(session.id, "/verify-external/").concat(node.id), tslib_es6.__assign({ apiType: apiType, referenceValue: referenceValue, referenceField: referenceField }, (comparisonConfig ? { comparisonConfig: comparisonConfig } : {})), { signal: abortController.signal })];
122
196
  case 5:
123
- response = _m.sent();
124
- result = (_j = response.data) === null || _j === void 0 ? void 0 : _j.data;
125
- if (result && typeof result.isVerified === 'boolean') {
126
- verificationResult = result;
127
- }
128
- return [3 /*break*/, 7];
197
+ response = _s.sent();
198
+ if (isInpiRbe)
199
+ advanceStep(2);
200
+ return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, 600); })];
129
201
  case 6:
130
- apiErr_1 = _m.sent();
131
- apiResult = (_l = (_k = apiErr_1 === null || apiErr_1 === void 0 ? void 0 : apiErr_1.response) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.data;
202
+ _s.sent();
203
+ res = (_k = response.data) === null || _k === void 0 ? void 0 : _k.data;
204
+ if (res && typeof res.isVerified === 'boolean') {
205
+ result = res;
206
+ }
207
+ return [3 /*break*/, 8];
208
+ case 7:
209
+ apiErr_1 = _s.sent();
210
+ if (abortController.signal.aborted)
211
+ return [2 /*return*/];
212
+ if (isInpiRbe)
213
+ advanceStep(2);
214
+ apiResult = (_m = (_l = apiErr_1 === null || apiErr_1 === void 0 ? void 0 : apiErr_1.response) === null || _l === void 0 ? void 0 : _l.data) === null || _m === void 0 ? void 0 : _m.data;
132
215
  if (apiResult && typeof apiResult.isVerified === 'boolean') {
133
- verificationResult = apiResult;
216
+ result = apiResult;
134
217
  }
135
218
  else {
136
- verificationResult = {
219
+ result = {
137
220
  isVerified: false,
138
221
  status: 'external_error',
139
222
  message: 'External verification request failed.',
140
223
  errorCode: 'REQUEST_FAILED',
141
224
  };
142
225
  }
143
- return [3 /*break*/, 7];
144
- case 7: return [3 /*break*/, 9];
145
- case 8:
146
- err_1 = _m.sent();
147
- verificationResult = {
226
+ return [3 /*break*/, 8];
227
+ case 8: return [3 /*break*/, 10];
228
+ case 9:
229
+ _s.sent();
230
+ result = {
148
231
  isVerified: false,
149
232
  status: 'external_error',
150
233
  message: 'Unexpected error during verification.',
151
234
  errorCode: 'UNEXPECTED_ERROR',
152
235
  };
153
- console.warn('[ExternalVerificationNodeHandler] Unexpected error:', err_1);
154
- return [3 /*break*/, 9];
155
- case 9:
236
+ return [3 /*break*/, 10];
237
+ case 10:
238
+ if (abortController.signal.aborted)
239
+ return [2 /*return*/];
240
+ completeSteps();
156
241
  setUserInput(function (prev) {
157
242
  var _a;
158
243
  return (tslib_es6.__assign(tslib_es6.__assign({}, prev), (_a = {}, _a[node.id] = {
159
- isVerified: verificationResult.isVerified,
244
+ isVerified: result.isVerified,
160
245
  apiType: apiType,
161
246
  referenceField: referenceField,
162
247
  referenceValueMasked: referenceValueMasked,
163
248
  verifiedAt: new Date().toISOString(),
164
- status: verificationResult.status,
165
- errorCode: verificationResult.errorCode,
166
- message: verificationResult.message,
167
- hasError: verificationResult.status !== 'ok' && verificationResult.status !== 'not_found',
249
+ status: result.status,
250
+ errorCode: result.errorCode,
251
+ message: result.message,
252
+ inpiData: result.inpiData,
253
+ hasError: result.status !== 'ok' && result.status !== 'not_found' && result.status !== 'person_mismatch',
168
254
  }, _a)));
169
255
  });
170
- onNext();
256
+ if (result.status === 'person_mismatch') {
257
+ inpi = result.inpiData;
258
+ cfg = nodeData.comparisonConfig;
259
+ setErrorScreenData({
260
+ submittedLastName: submittedLastName,
261
+ submittedFirstName: submittedFirstName,
262
+ mandataires: ((_o = inpi === null || inpi === void 0 ? void 0 : inpi.mandataires) !== null && _o !== void 0 ? _o : []).filter(function (m) { return m.type === 'individu'; }),
263
+ beneficiairesEffectifs: (_p = inpi === null || inpi === void 0 ? void 0 : inpi.beneficiairesEffectifs) !== null && _p !== void 0 ? _p : [],
264
+ compareTargets: (_q = cfg === null || cfg === void 0 ? void 0 : cfg.compareTargets) !== null && _q !== void 0 ? _q : ['mandataires'],
265
+ personNodeId: (_r = cfg === null || cfg === void 0 ? void 0 : cfg.personReferenceNodeId) !== null && _r !== void 0 ? _r : '',
266
+ siren: resolvedReferenceValue,
267
+ sirenNodeId: referenceNodeId,
268
+ });
269
+ setPhase('mismatch');
270
+ }
271
+ else if (result.status === 'not_found' || result.status === 'invalid_input') {
272
+ setErrorScreenData({
273
+ submittedLastName: '',
274
+ submittedFirstName: '',
275
+ mandataires: [],
276
+ beneficiairesEffectifs: [],
277
+ compareTargets: [],
278
+ personNodeId: '',
279
+ siren: resolvedReferenceValue,
280
+ sirenNodeId: referenceNodeId,
281
+ });
282
+ setPhase('not_found');
283
+ }
284
+ else if (result.isVerified || result.status === 'ok') {
285
+ setPhase('success');
286
+ setTimeout(onNext, 1200);
287
+ }
288
+ else if (result.status === 'config_error') {
289
+ setPhase('success');
290
+ setTimeout(onNext, 800);
291
+ }
292
+ else {
293
+ setPhase('error');
294
+ setTimeout(onNext, 1500);
295
+ }
171
296
  return [2 /*return*/];
172
297
  }
173
298
  });
174
299
  }); };
175
- performVerification();
300
+ run();
301
+ return function () { return abortController.abort(); };
176
302
  // eslint-disable-next-line react-hooks/exhaustive-deps
177
303
  }, []);
178
- return (jsxRuntime.jsxs("div", { className: "flex min-h-[300px] flex-col items-center justify-center space-y-4 p-6 text-center", children: [jsxRuntime.jsx(lucideReact.Loader2, { className: "h-12 w-12 animate-spin text-[#1c2c5c]" }), jsxRuntime.jsx("h3", { className: "text-xl font-semibold text-gray-900", children: t('verification_node.verifying_title', 'Vérification en cours...') }), jsxRuntime.jsx("p", { className: "text-gray-500", children: t('verification_node.verifying_desc', 'Nous interrogeons la base de données.') })] }));
304
+ // ─── Navigation helper ────────────────────────────────────────────────────
305
+ var handleCorrect = function () {
306
+ if (phase === 'mismatch' && (errorScreenData === null || errorScreenData === void 0 ? void 0 : errorScreenData.personNodeId) && onNavigateToNode) {
307
+ onNavigateToNode(errorScreenData.personNodeId);
308
+ }
309
+ else if (phase === 'not_found' && (errorScreenData === null || errorScreenData === void 0 ? void 0 : errorScreenData.sirenNodeId) && onNavigateToNode) {
310
+ onNavigateToNode(errorScreenData.sirenNodeId);
311
+ }
312
+ else {
313
+ onPrevious();
314
+ }
315
+ };
316
+ // ─── Loading phase ─────────────────────────────────────────────────────────
317
+ if (phase === 'loading') {
318
+ return (jsxRuntime.jsx("div", { className: "flex flex-col justify-between h-full w-full", children: jsxRuntime.jsx("div", { className: "flex-1 px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsxRuntime.jsxs("div", { className: "text-center space-y-4", children: [jsxRuntime.jsx(Title.default, { className: "text-xl md:text-2xl lg:text-3xl", children: t('verification_node.verifying_title', 'Vérification en cours…') }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm text-gray-600 leading-relaxed", children: t('verification_node.verifying_desc', 'Nous vérifions vos informations. Cela peut prendre quelques instants.') })] }), jsxRuntime.jsx("div", { className: "w-full flex justify-center", children: jsxRuntime.jsx("div", { className: "space-y-5", children: steps.map(function (step, index) { return (jsxRuntime.jsxs("div", { className: "flex items-start", children: [jsxRuntime.jsx("div", { className: "mr-4 mt-1 flex-shrink-0", children: step.status === 'done' ? (jsxRuntime.jsx("div", { className: "flex items-center justify-center w-6 h-6 rounded-full bg-[#11E5C5] text-white text-xs", children: "\u2713" })) : step.status === 'active' ? (jsxRuntime.jsx("div", { className: "w-6 h-6 rounded-full border-2 border-t-[#11E5C5] border-r-[#11E5C5] border-b-[#11E5C5] border-l-transparent animate-spin" })) : (jsxRuntime.jsx("div", { className: "w-6 h-6 rounded-full border-2 border-gray-300" })) }), jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [jsxRuntime.jsx("p", { className: "font-medium text-[#3C3C40] text-sm", children: step.title }), jsxRuntime.jsx("p", { className: "text-xs text-gray-500 mt-1", children: step.subtitle })] })] }, index)); }) }) })] }) }) }));
319
+ }
320
+ // ─── Success phase ─────────────────────────────────────────────────────────
321
+ if (phase === 'success') {
322
+ return (jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center h-full px-6 py-8 text-center space-y-4", children: [jsxRuntime.jsx("img", { src: check.default, alt: "success", className: "w-24 h-24" }), jsxRuntime.jsx("h3", { className: "text-[#3C3C40] font-poppins text-xl font-bold", children: t('inpi_verification.success_title', 'Vérification réussie') }), jsxRuntime.jsx("p", { className: "text-gray-500 text-sm", children: t('inpi_verification.success_desc', "Passage à l'étape suivante…") })] }));
323
+ }
324
+ // ─── Mismatch phase ────────────────────────────────────────────────────────
325
+ if (phase === 'mismatch') {
326
+ var d = errorScreenData;
327
+ var showBeneficiaires = ((_b = d === null || d === void 0 ? void 0 : d.compareTargets) === null || _b === void 0 ? void 0 : _b.includes('beneficiairesEffectifs')) && ((_d = (_c = d === null || d === void 0 ? void 0 : d.beneficiairesEffectifs) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0;
328
+ var showMandataires = (!((_e = d === null || d === void 0 ? void 0 : d.compareTargets) === null || _e === void 0 ? void 0 : _e.length) || ((_f = d === null || d === void 0 ? void 0 : d.compareTargets) === null || _f === void 0 ? void 0 : _f.includes('mandataires'))) &&
329
+ ((_h = (_g = d === null || d === void 0 ? void 0 : d.mandataires) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) > 0;
330
+ var personListLabel = ((_j = d === null || d === void 0 ? void 0 : d.compareTargets) === null || _j === void 0 ? void 0 : _j.includes('beneficiairesEffectifs')) && !((_k = d === null || d === void 0 ? void 0 : d.compareTargets) === null || _k === void 0 ? void 0 : _k.includes('mandataires'))
331
+ ? t('inpi_verification.beneficiaires_label', 'Bénéficiaires effectifs renseignés au RNE')
332
+ : ((_l = d === null || d === void 0 ? void 0 : d.compareTargets) === null || _l === void 0 ? void 0 : _l.includes('mandataires')) && !((_m = d === null || d === void 0 ? void 0 : d.compareTargets) === null || _m === void 0 ? void 0 : _m.includes('beneficiairesEffectifs'))
333
+ ? t('inpi_verification.mandataires_label', 'Mandataires renseignés au RNE')
334
+ : t('inpi_verification.persons_label', 'Personnes renseignées au RNE');
335
+ return (jsxRuntime.jsxs("div", { className: "flex flex-col justify-between h-full w-full", children: [jsxRuntime.jsx("div", { className: "flex-1 px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsxRuntime.jsx("div", { className: "text-center", children: jsxRuntime.jsx("div", { className: "mx-auto w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4", children: jsxRuntime.jsx("div", { className: "w-8 h-8 bg-red-500 rounded-full flex items-center justify-center", children: jsxRuntime.jsx("span", { className: "text-white text-lg", children: "\u2715" }) }) }) }), jsxRuntime.jsxs("div", { className: "text-center space-y-4", children: [jsxRuntime.jsx(Title.default, { className: "text-xl md:text-2xl lg:text-3xl text-red-600", children: t('inpi_verification.mismatch_title', 'Identité non confirmée') }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm text-gray-600 leading-relaxed", children: t('inpi_verification.mismatch_desc', "Les informations saisies ne correspondent à aucune personne déclarée à l'INPI pour cette société.") })] }), d && (d.submittedLastName || d.submittedFirstName) && (jsxRuntime.jsxs("div", { className: "bg-red-50 border border-red-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-red-900 mb-2", children: t('errors.problems_detected', 'Problèmes détectés') }), jsxRuntime.jsxs("div", { className: "text-sm text-red-800 space-y-1", children: [d.submittedLastName && (jsxRuntime.jsxs("p", { children: [t('inpi_verification.submitted_last_name', 'Nom saisi'), ' : ', jsxRuntime.jsx("strong", { children: d.submittedLastName })] })), d.submittedFirstName && (jsxRuntime.jsxs("p", { children: [t('inpi_verification.submitted_first_name', 'Prénom saisi'), ' : ', jsxRuntime.jsx("strong", { children: d.submittedFirstName })] }))] })] })), (showMandataires || showBeneficiaires) && (jsxRuntime.jsxs("div", { className: "bg-blue-50 border border-blue-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-blue-900 mb-2", children: personListLabel }), jsxRuntime.jsxs("div", { className: "text-sm text-blue-800 space-y-1", children: [showMandataires && d.mandataires.map(function (m, i) {
336
+ var _a, _b;
337
+ return (jsxRuntime.jsxs("p", { children: [jsxRuntime.jsx("strong", { children: (_a = m.nom) !== null && _a !== void 0 ? _a : '—' }), ((_b = m.prenoms) !== null && _b !== void 0 ? _b : []).length > 0 && " ".concat(m.prenoms.join(' '))] }, "m-".concat(i)));
338
+ }), showBeneficiaires && d.beneficiairesEffectifs.map(function (b, i) {
339
+ var _a, _b;
340
+ return (jsxRuntime.jsxs("p", { children: [jsxRuntime.jsx("strong", { children: (_a = b.nom) !== null && _a !== void 0 ? _a : '—' }), ((_b = b.prenoms) !== null && _b !== void 0 ? _b : []).length > 0 && " ".concat(b.prenoms.join(' '))] }, "b-".concat(i)));
341
+ })] })] }))] }) }), jsxRuntime.jsx("div", { className: "sticky bottom-0 md:static bg-white border-t md:border-t-0 p-4 md:p-0 md:pb-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto", children: [jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3 md:hidden", children: [jsxRuntime.jsx(Button.default, { variant: "secondary", onClick: handleCorrect, "data-cy": "inpi-mismatch-go-back", children: t('inpi_verification.mismatch_correct', 'Corriger ma saisie') }), jsxRuntime.jsx(Button.default, { onClick: onNext, "data-cy": "inpi-mismatch-continue", children: t('inpi_verification.mismatch_continue', 'Continuer quand même') })] }), jsxRuntime.jsxs("div", { className: "hidden md:flex justify-center space-x-3", children: [jsxRuntime.jsx(Button.default, { variant: "secondary", onClick: handleCorrect, "data-cy": "inpi-mismatch-go-back", children: t('inpi_verification.mismatch_correct', 'Corriger ma saisie') }), jsxRuntime.jsx(Button.default, { onClick: onNext, "data-cy": "inpi-mismatch-continue", children: t('inpi_verification.mismatch_continue', 'Continuer quand même') })] })] }) })] }));
342
+ }
343
+ // ─── Not found phase ───────────────────────────────────────────────────────
344
+ if (phase === 'not_found') {
345
+ var d = errorScreenData;
346
+ return (jsxRuntime.jsxs("div", { className: "flex flex-col justify-between h-full w-full", children: [jsxRuntime.jsx("div", { className: "flex-1 px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsxRuntime.jsx("div", { className: "text-center", children: jsxRuntime.jsx("div", { className: "mx-auto w-16 h-16 bg-orange-100 rounded-full flex items-center justify-center mb-4", children: jsxRuntime.jsx("div", { className: "w-8 h-8 bg-orange-500 rounded-full flex items-center justify-center", children: jsxRuntime.jsx("span", { className: "text-white text-lg font-bold", children: "!" }) }) }) }), jsxRuntime.jsxs("div", { className: "text-center space-y-4", children: [jsxRuntime.jsx(Title.default, { className: "text-xl md:text-2xl lg:text-3xl text-orange-600", children: t('inpi_verification.not_found_title', 'Société introuvable') }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm text-gray-600 leading-relaxed", children: t('inpi_verification.not_found_desc', "Le numéro saisi ne correspond à aucune société enregistrée dans le Registre National des Entreprises.") })] }), jsxRuntime.jsxs("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-orange-900 mb-2", children: t('errors.problems_detected', 'Problèmes détectés') }), jsxRuntime.jsxs("div", { className: "text-sm text-orange-800 space-y-1", children: [(d === null || d === void 0 ? void 0 : d.siren) && (jsxRuntime.jsxs("p", { children: [t('inpi_verification.siren_label', 'SIREN'), ' : ', jsxRuntime.jsx("strong", { children: d.siren })] })), jsxRuntime.jsx("p", { children: t('inpi_verification.not_found_detail', 'Aucune société trouvée dans le Registre National des Entreprises.') })] })] })] }) }), jsxRuntime.jsx("div", { className: "sticky bottom-0 md:static bg-white border-t md:border-t-0 p-4 md:p-0 md:pb-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto", children: [jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3 md:hidden", children: [jsxRuntime.jsx(Button.default, { variant: "secondary", onClick: handleCorrect, "data-cy": "inpi-not-found-go-back", children: t('inpi_verification.mismatch_correct', 'Corriger ma saisie') }), jsxRuntime.jsx(Button.default, { onClick: onNext, "data-cy": "inpi-not-found-continue", children: t('inpi_verification.mismatch_continue', 'Continuer quand même') })] }), jsxRuntime.jsxs("div", { className: "hidden md:flex justify-center space-x-3", children: [jsxRuntime.jsx(Button.default, { variant: "secondary", onClick: handleCorrect, "data-cy": "inpi-not-found-go-back", children: t('inpi_verification.mismatch_correct', 'Corriger ma saisie') }), jsxRuntime.jsx(Button.default, { onClick: onNext, "data-cy": "inpi-not-found-continue", children: t('inpi_verification.mismatch_continue', 'Continuer quand même') })] })] }) })] }));
347
+ }
348
+ // ─── Error / fallback ─────────────────────────────────────────────────────
349
+ return (jsxRuntime.jsx(LoadingState.default, { message: t('verification_node.verifying_title', 'Vérification en cours…'), subtitle: t('verification_node.verifying_desc', 'Vérification en cours…') }));
179
350
  };
180
351
 
181
352
  exports.default = ExternalVerificationNodeHandler;