@memori.ai/memori-react 8.41.2 → 8.41.4

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 (53) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +8 -1
  3. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
  4. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js +1 -1
  5. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js.map +1 -1
  6. package/dist/components/Avatar/AvatarView/AvatarComponent/constants.d.ts +2 -0
  7. package/dist/components/Avatar/AvatarView/AvatarComponent/constants.js +14 -5
  8. package/dist/components/Avatar/AvatarView/AvatarComponent/constants.js.map +1 -1
  9. package/dist/components/ChatBubble/ChatBubble.js +16 -11
  10. package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
  11. package/dist/components/MemoriWidget/MemoriWidget.js +121 -84
  12. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  13. package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js +79 -52
  14. package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
  15. package/dist/helpers/constants.d.ts +1 -1
  16. package/dist/helpers/constants.js +0 -1
  17. package/dist/helpers/constants.js.map +1 -1
  18. package/dist/helpers/utils.d.ts +1 -1
  19. package/dist/version.d.ts +1 -1
  20. package/dist/version.js +1 -1
  21. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +9 -2
  22. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
  23. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js +2 -2
  24. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js.map +1 -1
  25. package/esm/components/Avatar/AvatarView/AvatarComponent/constants.d.ts +2 -0
  26. package/esm/components/Avatar/AvatarView/AvatarComponent/constants.js +13 -4
  27. package/esm/components/Avatar/AvatarView/AvatarComponent/constants.js.map +1 -1
  28. package/esm/components/ChatBubble/ChatBubble.js +16 -11
  29. package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
  30. package/esm/components/MemoriWidget/MemoriWidget.js +121 -84
  31. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  32. package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js +79 -52
  33. package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
  34. package/esm/helpers/constants.d.ts +1 -1
  35. package/esm/helpers/constants.js +0 -1
  36. package/esm/helpers/constants.js.map +1 -1
  37. package/esm/helpers/utils.d.ts +1 -1
  38. package/esm/version.d.ts +1 -1
  39. package/esm/version.js +1 -1
  40. package/package.json +1 -1
  41. package/src/components/Avatar/Avatar.test.tsx +27 -0
  42. package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.tsx +12 -5
  43. package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.ts +2 -1
  44. package/src/components/Avatar/AvatarView/AvatarComponent/constants.ts +16 -4
  45. package/src/components/Avatar/__snapshots__/Avatar.test.tsx.snap +63 -0
  46. package/src/components/ChatBubble/ChatBubble.tsx +28 -3
  47. package/src/components/MemoriWidget/MemoriWidget.tsx +110 -68
  48. package/src/components/UploadButton/UploadDocuments/UploadDocuments.tsx +103 -55
  49. package/src/components/UploadButton/__snapshots__/UploadButton.test.tsx.snap +2 -2
  50. package/src/components/layouts/layouts.stories.tsx +6 -13
  51. package/src/helpers/constants.ts +0 -1
  52. package/src/helpers/utils.test.ts +1 -1
  53. package/src/version.ts +1 -1
@@ -64,6 +64,10 @@ const getMemoriState = (integrationId) => {
64
64
  loginToken,
65
65
  };
66
66
  };
67
+ const resolveLoginTokenValue = (loginToken, userTokenRef, callAdditionalInfoLoginToken, additionalInfoLoginToken, authTokenProp) => {
68
+ var _a, _b, _c;
69
+ return (_c = (_b = (_a = loginToken !== null && loginToken !== void 0 ? loginToken : userTokenRef) !== null && _a !== void 0 ? _a : callAdditionalInfoLoginToken) !== null && _b !== void 0 ? _b : additionalInfoLoginToken) !== null && _c !== void 0 ? _c : authTokenProp;
70
+ };
67
71
  const NULL_PLACE_SPEC = {
68
72
  placeName: null,
69
73
  latitude: null,
@@ -172,7 +176,6 @@ window.typeMessageHidden = typeMessageHidden;
172
176
  window.typeBatchMessages = typeBatchMessages;
173
177
  let audioContext;
174
178
  let memoriPassword;
175
- let userToken;
176
179
  const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenantID, memoriLang, uiLang, spokenLang, multilingual, integration, layout, customLayout, showShare, preview = false, embed = false, showCopyButton = true, showTranslationOriginal = false, showInputs = true, showDates = false, showContextPerLine = false, showMessageConsumption = false, showSettings, showTypingText = false, showClear = false, showLogin = false, showUpload, showOnlyLastMessages, showChatHistory, showReasoning, avatar3dHidden, height = '100vh', secret, baseUrl = 'https://aisuru-staging.aclambda.online', apiURL = 'https://backend-staging.memori.ai', engineURL = 'https://engine-staging.memori.ai', initialContextVars, initialQuestion, ttsProvider, ogImage, sessionID: initialSessionID, tenant, personification, authToken, enableAudio, defaultSpeakerActive = true, disableTextEnteredEvents = false, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, userAvatar, __WEBCOMPONENT__ = false, useMathFormatting = false, autoStart = false, applyVarsToRoot = false, showFunctionCache = false, maxTotalMessagePayload, maxTextareaCharacters, }) => {
177
180
  var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
178
181
  const { t, i18n } = (0, react_i18next_1.useTranslation)();
@@ -185,35 +188,61 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
185
188
  const [instruct, setInstruct] = (0, react_1.useState)(false);
186
189
  const [enableFocusChatInput, setEnableFocusChatInput] = (0, react_1.useState)(true);
187
190
  const [loginToken, setLoginToken] = (0, react_1.useState)((_a = additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _a !== void 0 ? _a : authToken);
191
+ const userTokenRef = (0, react_1.useRef)((_b = additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _b !== void 0 ? _b : authToken);
192
+ const prevPropsLoginTokenRef = (0, react_1.useRef)((_c = additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _c !== void 0 ? _c : authToken);
188
193
  const [user, setUser] = (0, react_1.useState)({
189
194
  avatarURL: typeof userAvatar === 'string' ? userAvatar : undefined,
190
195
  });
196
+ const resolveLoginToken = (0, react_1.useCallback)((callAdditionalInfoLoginToken) => resolveLoginTokenValue(loginToken, userTokenRef.current, callAdditionalInfoLoginToken, additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken, authToken), [loginToken, additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken, authToken]);
191
197
  (0, react_1.useEffect)(() => {
192
- if (loginToken &&
193
- !(user === null || user === void 0 ? void 0 : user.userID) &&
194
- (showLogin || memori.requireLoginToken)) {
195
- client.backend
196
- .pwlGetCurrentUser(loginToken)
197
- .then(({ user, resultCode }) => {
198
- if (user && resultCode === 0) {
199
- setUser(user);
200
- (0, configuration_1.setLocalConfig)('loginToken', loginToken);
201
- if (!birthDate && user.birthDate) {
202
- setBirthDate(user.birthDate);
203
- (0, configuration_1.setLocalConfig)('birthDate', user.birthDate);
204
- }
205
- }
206
- else {
207
- (0, configuration_1.removeLocalConfig)('loginToken');
208
- }
209
- });
198
+ var _a;
199
+ const incomingToken = (_a = additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _a !== void 0 ? _a : authToken;
200
+ const prevPropsToken = prevPropsLoginTokenRef.current;
201
+ prevPropsLoginTokenRef.current = incomingToken;
202
+ if (incomingToken !== prevPropsToken) {
203
+ setLoginToken(incomingToken);
204
+ userTokenRef.current = incomingToken;
205
+ if (!incomingToken) {
206
+ (0, configuration_1.removeLocalConfig)('loginToken');
207
+ setUser(undefined);
208
+ }
209
+ }
210
+ }, [additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken, authToken]);
211
+ (0, react_1.useEffect)(() => {
212
+ if (!loginToken || !(showLogin || memori.requireLoginToken)) {
213
+ return;
210
214
  }
211
- }, [loginToken, user === null || user === void 0 ? void 0 : user.userID]);
215
+ let cancelled = false;
216
+ client.backend
217
+ .pwlGetCurrentUser(loginToken)
218
+ .then(({ user: fetchedUser, resultCode }) => {
219
+ if (cancelled)
220
+ return;
221
+ if (fetchedUser && resultCode === 0) {
222
+ setUser(fetchedUser);
223
+ (0, configuration_1.setLocalConfig)('loginToken', loginToken);
224
+ userTokenRef.current = loginToken;
225
+ if (!birthDate && fetchedUser.birthDate) {
226
+ setBirthDate(fetchedUser.birthDate);
227
+ (0, configuration_1.setLocalConfig)('birthDate', fetchedUser.birthDate);
228
+ }
229
+ }
230
+ else {
231
+ setLoginToken(undefined);
232
+ userTokenRef.current = undefined;
233
+ setUser(undefined);
234
+ (0, configuration_1.removeLocalConfig)('loginToken');
235
+ }
236
+ });
237
+ return () => {
238
+ cancelled = true;
239
+ };
240
+ }, [loginToken, showLogin, memori.requireLoginToken]);
212
241
  const [showLoginDrawer, setShowLoginDrawer] = (0, react_1.useState)(false);
213
242
  const [clickedStart, setClickedStart] = (0, react_1.useState)(false);
214
243
  const sessionStartingRef = (0, react_1.useRef)(false);
215
- const language = ((_d = (_c = (_b = memori.culture) === null || _b === void 0 ? void 0 : _b.split('-')) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.toUpperCase()) ||
216
- ((_j = (_h = (_g = (_f = memoriConfigs === null || memoriConfigs === void 0 ? void 0 : memoriConfigs.find(c => c.memoriConfigID === memori.memoriConfigurationID)) === null || _f === void 0 ? void 0 : _f.culture) === null || _g === void 0 ? void 0 : _g.split('-')) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.toUpperCase());
244
+ const language = ((_g = (_f = (_d = memori.culture) === null || _d === void 0 ? void 0 : _d.split('-')) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.toUpperCase()) ||
245
+ ((_l = (_k = (_j = (_h = memoriConfigs === null || memoriConfigs === void 0 ? void 0 : memoriConfigs.find(c => c.memoriConfigID === memori.memoriConfigurationID)) === null || _h === void 0 ? void 0 : _h.culture) === null || _j === void 0 ? void 0 : _j.split('-')) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.toUpperCase());
217
246
  const integrationConfig = (integration === null || integration === void 0 ? void 0 : integration.customData)
218
247
  ? JSON.parse(integration.customData)
219
248
  : null;
@@ -221,7 +250,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
221
250
  ? multilingual
222
251
  : !!(integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.multilanguage);
223
252
  const forcedTimeout = integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.forcedTimeout;
224
- const [userLang, setUserLang] = (0, react_1.useState)((_p = (_o = (_m = (_l = (_k = spokenLang !== null && spokenLang !== void 0 ? spokenLang : memoriLang) !== null && _k !== void 0 ? _k : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.lang) !== null && _l !== void 0 ? _l : language) !== null && _m !== void 0 ? _m : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.uiLang) !== null && _o !== void 0 ? _o : i18n.language) !== null && _p !== void 0 ? _p : 'IT');
253
+ const [userLang, setUserLang] = (0, react_1.useState)((_r = (_q = (_p = (_o = (_m = spokenLang !== null && spokenLang !== void 0 ? spokenLang : memoriLang) !== null && _m !== void 0 ? _m : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.lang) !== null && _o !== void 0 ? _o : language) !== null && _p !== void 0 ? _p : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.uiLang) !== null && _q !== void 0 ? _q : i18n.language) !== null && _r !== void 0 ? _r : 'IT');
225
254
  (0, react_1.useEffect)(() => {
226
255
  if (spokenLang != null) {
227
256
  setUserLang(spokenLang);
@@ -253,14 +282,14 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
253
282
  ? layout
254
283
  : typeof (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.layout) === 'string'
255
284
  ? integrationConfig.layout
256
- : (_q = integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.layout) === null || _q === void 0 ? void 0 : _q.name;
285
+ : (_s = integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.layout) === null || _s === void 0 ? void 0 : _s.name;
257
286
  const selectedLayout = layoutName || 'DEFAULT';
258
287
  const piiDetection = typeof (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.layout) === 'object' &&
259
288
  (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.layout) !== null &&
260
- ((_s = (_r = integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.layout) === null || _r === void 0 ? void 0 : _r.piiDetection) === null || _s === void 0 ? void 0 : _s.enabled)
289
+ ((_u = (_t = integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.layout) === null || _t === void 0 ? void 0 : _t.piiDetection) === null || _u === void 0 ? void 0 : _u.enabled)
261
290
  ? integrationConfig.layout.piiDetection
262
291
  : undefined;
263
- const defaultEnableAudio = (_t = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _t !== void 0 ? _t : true;
292
+ const defaultEnableAudio = (_v = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _v !== void 0 ? _v : true;
264
293
  const [hasUserActivatedListening, setHasUserActivatedListening] = (0, react_1.useState)(false);
265
294
  const [hasUserTypedMessage, setHasUserTypedMessage] = (0, react_1.useState)(false);
266
295
  const [showPositionDrawer, setShowPositionDrawer] = (0, react_1.useState)(false);
@@ -303,7 +332,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
303
332
  setRuntimeShowMessageConsumption((0, configuration_1.getLocalConfig)('showMessageConsumption', (_a = showMessageConsumption !== null && showMessageConsumption !== void 0 ? showMessageConsumption : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showMessageConsumption) !== null && _a !== void 0 ? _a : false));
304
333
  if (!(additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) && !authToken) {
305
334
  setLoginToken((0, configuration_1.getLocalConfig)('loginToken', undefined));
306
- userToken = (0, configuration_1.getLocalConfig)('loginToken', undefined);
335
+ userTokenRef.current = (0, configuration_1.getLocalConfig)('loginToken', undefined);
307
336
  setBirthDate((0, configuration_1.getLocalConfig)('birthDate', undefined));
308
337
  }
309
338
  if (!((_b = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _b !== void 0 ? _b : true)) {
@@ -722,7 +751,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
722
751
  }
723
752
  }, [initialSessionID]);
724
753
  const fetchSession = async (params) => {
725
- var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l;
754
+ var _a, _b, _c, _d, _f, _g, _h;
726
755
  let storageBirthDate = (0, configuration_1.getLocalConfig)('birthDate', undefined);
727
756
  let userBirthDate = (_a = birthDate !== null && birthDate !== void 0 ? birthDate : params.birthDate) !== null && _a !== void 0 ? _a : storageBirthDate;
728
757
  if (!userBirthDate && !!minAge) {
@@ -747,7 +776,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
747
776
  return window.location.href;
748
777
  })();
749
778
  }
750
- catch (_m) {
779
+ catch (_j) {
751
780
  }
752
781
  const session = await initSession({
753
782
  ...params,
@@ -756,8 +785,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
756
785
  pin: (_c = params.pin) !== null && _c !== void 0 ? _c : personification === null || personification === void 0 ? void 0 : personification.pin,
757
786
  additionalInfo: {
758
787
  ...(params.additionalInfo || additionalInfo || {}),
759
- loginToken: (_h = (_g = (_d = userToken !== null && userToken !== void 0 ? userToken : loginToken) !== null && _d !== void 0 ? _d : (_f = params.additionalInfo) === null || _f === void 0 ? void 0 : _f.loginToken) !== null && _g !== void 0 ? _g : additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _h !== void 0 ? _h : authToken,
760
- language: ((_l = userLang !== null && userLang !== void 0 ? userLang : (_k = (_j = memori.culture) === null || _j === void 0 ? void 0 : _j.split('-')) === null || _k === void 0 ? void 0 : _k[0]) !== null && _l !== void 0 ? _l : 'IT').toLowerCase(),
788
+ loginToken: resolveLoginToken((_d = params.additionalInfo) === null || _d === void 0 ? void 0 : _d.loginToken),
789
+ language: ((_h = userLang !== null && userLang !== void 0 ? userLang : (_g = (_f = memori.culture) === null || _f === void 0 ? void 0 : _f.split('-')) === null || _g === void 0 ? void 0 : _g[0]) !== null && _h !== void 0 ? _h : 'IT').toLowerCase(),
761
790
  referral: referral,
762
791
  timeZoneOffset: new Date().getTimezoneOffset().toString(),
763
792
  },
@@ -798,7 +827,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
798
827
  }
799
828
  };
800
829
  const reopenSession = async (updateDialogState = false, password, recoveryTokens, tag, pin, initialContextVars, initialQuestion, birthDate, additionalInfoProp, continueFromChatLogID, continueFromSessionID, isSessionExpired, suppressHistoryUpdate) => {
801
- var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m;
830
+ var _a, _b, _c, _d, _f, _g, _h, _j;
802
831
  setLoading(true);
803
832
  let storageBirthDate = (0, configuration_1.getLocalConfig)('birthDate', undefined);
804
833
  let userBirthDate = birthDate !== null && birthDate !== void 0 ? birthDate : storageBirthDate;
@@ -826,7 +855,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
826
855
  return window.location.href;
827
856
  })();
828
857
  }
829
- catch (_o) {
858
+ catch (_k) {
830
859
  }
831
860
  const { sessionID, currentState, ...response } = await initSession({
832
861
  memoriID: (_a = memori.engineMemoriID) !== null && _a !== void 0 ? _a : '',
@@ -846,8 +875,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
846
875
  birthDate: userBirthDate,
847
876
  additionalInfo: {
848
877
  ...(additionalInfoProp || additionalInfo || {}),
849
- loginToken: (_g = (_f = (_d = userToken !== null && userToken !== void 0 ? userToken : loginToken) !== null && _d !== void 0 ? _d : additionalInfoProp === null || additionalInfoProp === void 0 ? void 0 : additionalInfoProp.loginToken) !== null && _f !== void 0 ? _f : additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _g !== void 0 ? _g : authToken,
850
- language: ((_k = userLang !== null && userLang !== void 0 ? userLang : (_j = (_h = memori.culture) === null || _h === void 0 ? void 0 : _h.split('-')) === null || _j === void 0 ? void 0 : _j[0]) !== null && _k !== void 0 ? _k : 'IT').toLowerCase(),
878
+ loginToken: resolveLoginToken(additionalInfoProp === null || additionalInfoProp === void 0 ? void 0 : additionalInfoProp.loginToken),
879
+ language: ((_g = userLang !== null && userLang !== void 0 ? userLang : (_f = (_d = memori.culture) === null || _d === void 0 ? void 0 : _d.split('-')) === null || _f === void 0 ? void 0 : _f[0]) !== null && _g !== void 0 ? _g : 'IT').toLowerCase(),
851
880
  referral: referral,
852
881
  timeZoneOffset: new Date().getTimezoneOffset().toString(),
853
882
  },
@@ -880,7 +909,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
880
909
  {
881
910
  text: currentState.emission,
882
911
  emitter: currentState.emitter,
883
- media: (_l = currentState.emittedMedia) !== null && _l !== void 0 ? _l : currentState.media,
912
+ media: (_h = currentState.emittedMedia) !== null && _h !== void 0 ? _h : currentState.media,
884
913
  fromUser: false,
885
914
  initial: (initialStatus === true
886
915
  ? true
@@ -898,7 +927,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
898
927
  : pushMessage({
899
928
  text: currentState.emission,
900
929
  emitter: currentState.emitter,
901
- media: (_m = currentState.emittedMedia) !== null && _m !== void 0 ? _m : currentState.media,
930
+ media: (_j = currentState.emittedMedia) !== null && _j !== void 0 ? _j : currentState.media,
902
931
  fromUser: false,
903
932
  initial: (initialStatus === true
904
933
  ? true
@@ -983,7 +1012,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
983
1012
  });
984
1013
  };
985
1014
  const changeTag = async (memoriId, sessionId, tag, pin) => {
986
- var _a, _b, _c, _d, _f, _g, _h, _j, _k;
1015
+ var _a, _b, _c, _d, _f, _g, _h;
987
1016
  if (!memoriId || !sessionId) {
988
1017
  return Promise.reject('Session not found');
989
1018
  }
@@ -1023,7 +1052,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1023
1052
  return window.location.href;
1024
1053
  })();
1025
1054
  }
1026
- catch (_l) {
1055
+ catch (_j) {
1027
1056
  }
1028
1057
  fetchSession({
1029
1058
  memoriID: (_b = memori.engineMemoriID) !== null && _b !== void 0 ? _b : '',
@@ -1040,8 +1069,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1040
1069
  birthDate: birthDate || storageBirthDate || undefined,
1041
1070
  additionalInfo: {
1042
1071
  ...(additionalInfo || {}),
1043
- loginToken: (_g = (_f = userToken !== null && userToken !== void 0 ? userToken : loginToken) !== null && _f !== void 0 ? _f : additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _g !== void 0 ? _g : authToken,
1044
- language: ((_k = userLang !== null && userLang !== void 0 ? userLang : (_j = (_h = memori.culture) === null || _h === void 0 ? void 0 : _h.split('-')) === null || _j === void 0 ? void 0 : _j[0]) !== null && _k !== void 0 ? _k : 'IT').toLowerCase(),
1072
+ loginToken: resolveLoginToken(),
1073
+ language: ((_h = userLang !== null && userLang !== void 0 ? userLang : (_g = (_f = memori.culture) === null || _f === void 0 ? void 0 : _f.split('-')) === null || _g === void 0 ? void 0 : _g[0]) !== null && _h !== void 0 ? _h : 'IT').toLowerCase(),
1045
1074
  referral: referral,
1046
1075
  timeZoneOffset: new Date().getTimezoneOffset().toString(),
1047
1076
  },
@@ -1105,7 +1134,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1105
1134
  apiUrl: `${baseUrl}/api/tts`,
1106
1135
  continuousSpeech: continuousSpeech,
1107
1136
  preview: preview,
1108
- }, autoStart, defaultEnableAudio, (_u = defaultSpeakerActive !== null && defaultSpeakerActive !== void 0 ? defaultSpeakerActive : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.defaultSpeakerActive) !== null && _u !== void 0 ? _u : true);
1137
+ }, autoStart, defaultEnableAudio, (_w = defaultSpeakerActive !== null && defaultSpeakerActive !== void 0 ? defaultSpeakerActive : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.defaultSpeakerActive) !== null && _w !== void 0 ? _w : true);
1109
1138
  const shouldPlayAudio = (text) => {
1110
1139
  const currentSpeakerMuted = (0, configuration_1.getLocalConfig)('muteSpeaker', !defaultEnableAudio);
1111
1140
  return (text &&
@@ -1453,7 +1482,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1453
1482
  ? {
1454
1483
  '--memori-chat-bubble-bg': '#fff',
1455
1484
  ...(integrationConfig && !instruct
1456
- ? { '--memori-text-color': (_v = integrationConfig.textColor) !== null && _v !== void 0 ? _v : '#000' }
1485
+ ? { '--memori-text-color': (_x = integrationConfig.textColor) !== null && _x !== void 0 ? _x : '#000' }
1457
1486
  : {}),
1458
1487
  ...((integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.buttonBgColor)
1459
1488
  ? {
@@ -1477,12 +1506,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1477
1506
  ? {
1478
1507
  '--memori-inner-bg': `rgba(${integrationConfig.innerBgColor === 'dark'
1479
1508
  ? '0, 0, 0'
1480
- : '255, 255, 255'}, ${(_w = integrationConfig.innerBgAlpha) !== null && _w !== void 0 ? _w : 0.4})`,
1509
+ : '255, 255, 255'}, ${(_y = integrationConfig.innerBgAlpha) !== null && _y !== void 0 ? _y : 0.4})`,
1481
1510
  '--memori-inner-content-pad': '1.5rem',
1482
1511
  '--memori-nav-bg-image': 'none',
1483
1512
  '--memori-nav-bg': `rgba(${integrationConfig.innerBgColor === 'dark'
1484
1513
  ? '0, 0, 0'
1485
- : '255, 255, 255'}, ${(_x = integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.innerBgAlpha) !== null && _x !== void 0 ? _x : 0.4})`,
1514
+ : '255, 255, 255'}, ${(_z = integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.innerBgAlpha) !== null && _z !== void 0 ? _z : 0.4})`,
1486
1515
  }
1487
1516
  : {
1488
1517
  '--memori-inner-content-pad': '0px',
@@ -1581,7 +1610,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1581
1610
  };
1582
1611
  }, [sessionId, userLang, disableTextEnteredEvents]);
1583
1612
  const onClickStart = (0, react_1.useCallback)(async (session, initialSessionExpired = false, chatLog, targetSessionID) => {
1584
- var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
1613
+ var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
1585
1614
  const sessionID = chatLog ? undefined : (session === null || session === void 0 ? void 0 : session.sessionID) || sessionId;
1586
1615
  const dialogState = chatLog
1587
1616
  ? undefined
@@ -1642,8 +1671,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1642
1671
  birthDate: birth,
1643
1672
  additionalInfo: {
1644
1673
  ...(additionalInfo || {}),
1645
- loginToken: (_g = (_f = userToken !== null && userToken !== void 0 ? userToken : loginToken) !== null && _f !== void 0 ? _f : additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _g !== void 0 ? _g : authToken,
1646
- language: ((_k = userLang !== null && userLang !== void 0 ? userLang : (_j = (_h = memori.culture) === null || _h === void 0 ? void 0 : _h.split('-')) === null || _j === void 0 ? void 0 : _j[0]) !== null && _k !== void 0 ? _k : 'IT').toLowerCase(),
1674
+ loginToken: resolveLoginToken(),
1675
+ language: ((_h = userLang !== null && userLang !== void 0 ? userLang : (_g = (_f = memori.culture) === null || _f === void 0 ? void 0 : _f.split('-')) === null || _g === void 0 ? void 0 : _g[0]) !== null && _h !== void 0 ? _h : 'IT').toLowerCase(),
1647
1676
  timeZoneOffset: new Date().getTimezoneOffset().toString(),
1648
1677
  },
1649
1678
  });
@@ -1685,7 +1714,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1685
1714
  };
1686
1715
  }));
1687
1716
  }
1688
- catch (_w) {
1717
+ catch (_u) {
1689
1718
  }
1690
1719
  }
1691
1720
  setHistory(translatedMessages);
@@ -1732,11 +1761,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1732
1761
  throw new Error('No session');
1733
1762
  }
1734
1763
  }
1735
- catch (_x) {
1764
+ catch (_v) {
1736
1765
  reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, personification.tag, personification.pin, {
1737
1766
  LANG: userLang,
1738
- PATHNAME: (_l = window.location.pathname) === null || _l === void 0 ? void 0 : _l.toUpperCase(),
1739
- ROUTE: ((_p = (_o = (_m = window.location.pathname) === null || _m === void 0 ? void 0 : _m.split('/')) === null || _o === void 0 ? void 0 : _o.pop()) === null || _p === void 0 ? void 0 : _p.toUpperCase()) ||
1767
+ PATHNAME: (_j = window.location.pathname) === null || _j === void 0 ? void 0 : _j.toUpperCase(),
1768
+ ROUTE: ((_m = (_l = (_k = window.location.pathname) === null || _k === void 0 ? void 0 : _k.split('/')) === null || _l === void 0 ? void 0 : _l.pop()) === null || _m === void 0 ? void 0 : _m.toUpperCase()) ||
1740
1769
  '',
1741
1770
  ...(initialContextVars || {}),
1742
1771
  }, initialQuestion, birth).then(() => {
@@ -1763,8 +1792,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1763
1792
  catch (e) {
1764
1793
  reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, undefined, undefined, {
1765
1794
  LANG: userLang,
1766
- PATHNAME: (_q = window.location.pathname) === null || _q === void 0 ? void 0 : _q.toUpperCase(),
1767
- ROUTE: ((_t = (_s = (_r = window.location.pathname) === null || _r === void 0 ? void 0 : _r.split('/')) === null || _s === void 0 ? void 0 : _s.pop()) === null || _t === void 0 ? void 0 : _t.toUpperCase()) ||
1795
+ PATHNAME: (_o = window.location.pathname) === null || _o === void 0 ? void 0 : _o.toUpperCase(),
1796
+ ROUTE: ((_r = (_q = (_p = window.location.pathname) === null || _p === void 0 ? void 0 : _p.split('/')) === null || _q === void 0 ? void 0 : _q.pop()) === null || _r === void 0 ? void 0 : _r.toUpperCase()) ||
1768
1797
  '',
1769
1798
  ...(initialContextVars || {}),
1770
1799
  }, initialQuestion, birth).then(() => {
@@ -1776,7 +1805,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1776
1805
  else {
1777
1806
  try {
1778
1807
  const { chatLogs } = await getSessionChatLogs(sessionID, sessionID);
1779
- const messages = (_u = chatLogs === null || chatLogs === void 0 ? void 0 : chatLogs[0]) === null || _u === void 0 ? void 0 : _u.lines.map((l, i) => {
1808
+ const messages = (_s = chatLogs === null || chatLogs === void 0 ? void 0 : chatLogs[0]) === null || _s === void 0 ? void 0 : _s.lines.map((l, i) => {
1780
1809
  var _a, _b;
1781
1810
  return ({
1782
1811
  text: l.text,
@@ -1801,12 +1830,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1801
1830
  text: (await (0, translations_1.getTranslation)(m.text, userLang, language, baseUrl)).text,
1802
1831
  })));
1803
1832
  }
1804
- catch (_y) {
1833
+ catch (_w) {
1805
1834
  }
1806
1835
  }
1807
1836
  setHistory(translatedMessages);
1808
1837
  }
1809
- catch (_z) {
1838
+ catch (_x) {
1810
1839
  }
1811
1840
  if ((!!(translatedMessages === null || translatedMessages === void 0 ? void 0 : translatedMessages.length) && translatedMessages.length > 1) ||
1812
1841
  !initialQuestion) {
@@ -1822,7 +1851,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1822
1851
  sessionId: sessionID,
1823
1852
  text: initialQuestion,
1824
1853
  ...(memori.needsDateTime && {
1825
- dateUTC: (_v = luxon_1.DateTime.utc().toISO()) !== null && _v !== void 0 ? _v : undefined,
1854
+ dateUTC: (_t = luxon_1.DateTime.utc().toISO()) !== null && _t !== void 0 ? _t : undefined,
1826
1855
  }),
1827
1856
  ...(placeSpec !== undefined && { place: placeSpec }),
1828
1857
  });
@@ -1888,27 +1917,35 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1888
1917
  hasEnoughCredits,
1889
1918
  ]);
1890
1919
  (0, react_1.useEffect)(() => {
1920
+ var _a;
1891
1921
  const targetNode = document.querySelector(`memori-client[memoriname="${memori.name}"]`) ||
1892
1922
  document.querySelector(`memori-client[memoriid="${memori.memoriID}"]`) ||
1893
1923
  document.querySelector('memori-client');
1894
1924
  if (!targetNode) {
1895
1925
  return;
1896
1926
  }
1927
+ const propsToken = (_a = additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _a !== void 0 ? _a : authToken;
1928
+ const initialDomToken = targetNode.getAttribute('authtoken') || undefined;
1929
+ if (initialDomToken && !propsToken) {
1930
+ setLoginToken(initialDomToken);
1931
+ userTokenRef.current = initialDomToken;
1932
+ }
1933
+ const applyAuthTokenFromElement = (element) => {
1934
+ var _a;
1935
+ const clientNode = element.nodeName === 'MEMORI-CLIENT'
1936
+ ? element
1937
+ : (_a = element.closest('memori-client')) !== null && _a !== void 0 ? _a : element.parentElement;
1938
+ const token = (clientNode === null || clientNode === void 0 ? void 0 : clientNode.getAttribute('authtoken')) || undefined;
1939
+ setLoginToken(token);
1940
+ userTokenRef.current = token;
1941
+ };
1897
1942
  const config = { attributes: true, childList: false, subtree: false };
1898
- const callback = (mutationList, _observer) => {
1899
- var _a, _b, _c;
1943
+ const callback = mutationList => {
1944
+ var _a;
1900
1945
  for (const mutation of mutationList) {
1901
1946
  if (mutation.type === 'attributes' &&
1902
1947
  ((_a = mutation.attributeName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'authtoken') {
1903
- if (mutation.target.nodeName === 'MEMORI-CLIENT') {
1904
- setLoginToken(mutation.target.getAttribute('authtoken') || undefined);
1905
- userToken = mutation.target.getAttribute('authtoken') || undefined;
1906
- }
1907
- else {
1908
- setLoginToken(((_c = (_b = mutation.target) === null || _b === void 0 ? void 0 : _b.parentElement) === null || _c === void 0 ? void 0 : _c.getAttribute('authtoken')) ||
1909
- undefined);
1910
- userToken = mutation.target.getAttribute('authtoken') || undefined;
1911
- }
1948
+ applyAuthTokenFromElement(mutation.target);
1912
1949
  }
1913
1950
  }
1914
1951
  };
@@ -1917,7 +1954,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1917
1954
  return () => {
1918
1955
  observer.disconnect();
1919
1956
  };
1920
- }, []);
1957
+ }, [memori.name, memori.memoriID, additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken, authToken]);
1921
1958
  const [experts, setExperts] = (0, react_1.useState)();
1922
1959
  const fetchExperts = (0, react_1.useCallback)(async () => {
1923
1960
  if (!sessionId || !(memori === null || memori === void 0 ? void 0 : memori.enableBoardOfExperts))
@@ -2015,16 +2052,16 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2015
2052
  ? selectedLayout !== 'TOTEM' && selectedLayout !== 'WEBSITE_ASSISTANT'
2016
2053
  : !showOnlyLastMessages;
2017
2054
  const canShowLoginButton = !(tenant === null || tenant === void 0 ? void 0 : tenant.ssoLogin) &&
2018
- ((_y = showLogin !== null && showLogin !== void 0 ? showLogin : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showLogin) !== null && _y !== void 0 ? _y : memori.requireLoginToken);
2055
+ ((_0 = showLogin !== null && showLogin !== void 0 ? showLogin : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showLogin) !== null && _0 !== void 0 ? _0 : memori.requireLoginToken);
2019
2056
  const headerProps = {
2020
2057
  memori: {
2021
2058
  ...memori,
2022
- ownerUserID: (_0 = (_z = memori.ownerUserID) !== null && _z !== void 0 ? _z : ownerUserID) !== null && _0 !== void 0 ? _0 : undefined,
2059
+ ownerUserID: (_2 = (_1 = memori.ownerUserID) !== null && _1 !== void 0 ? _1 : ownerUserID) !== null && _2 !== void 0 ? _2 : undefined,
2023
2060
  },
2024
2061
  apiClient: client,
2025
2062
  tenant,
2026
2063
  history,
2027
- showShare: (_1 = showShare !== null && showShare !== void 0 ? showShare : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showShare) !== null && _1 !== void 0 ? _1 : true,
2064
+ showShare: (_3 = showShare !== null && showShare !== void 0 ? showShare : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showShare) !== null && _3 !== void 0 ? _3 : true,
2028
2065
  position,
2029
2066
  layout: selectedLayout,
2030
2067
  additionalSettings,
@@ -2032,18 +2069,18 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2032
2069
  setShowSettingsDrawer,
2033
2070
  setShowKnownFactsDrawer,
2034
2071
  setShowExpertsDrawer,
2035
- enableAudio: (_2 = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _2 !== void 0 ? _2 : true,
2072
+ enableAudio: (_4 = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _4 !== void 0 ? _4 : true,
2036
2073
  speakerMuted: speakerMuted !== null && speakerMuted !== void 0 ? speakerMuted : false,
2037
2074
  setSpeakerMuted: (mute) => {
2038
2075
  toggleMute(mute);
2039
2076
  },
2040
2077
  setShowChatHistoryDrawer,
2041
- showSettings: (_3 = showSettings !== null && showSettings !== void 0 ? showSettings : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showSettings) !== null && _3 !== void 0 ? _3 : true,
2042
- showChatHistory: (_4 = showChatHistory !== null && showChatHistory !== void 0 ? showChatHistory : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showChatHistory) !== null && _4 !== void 0 ? _4 : true,
2078
+ showSettings: (_5 = showSettings !== null && showSettings !== void 0 ? showSettings : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showSettings) !== null && _5 !== void 0 ? _5 : true,
2079
+ showChatHistory: (_6 = showChatHistory !== null && showChatHistory !== void 0 ? showChatHistory : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showChatHistory) !== null && _6 !== void 0 ? _6 : true,
2043
2080
  showMessageConsumption: enableMessageConsumption,
2044
2081
  hasUserActivatedSpeak,
2045
2082
  showReload: selectedLayout === 'TOTEM',
2046
- showClear: (_5 = showClear !== null && showClear !== void 0 ? showClear : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showClear) !== null && _5 !== void 0 ? _5 : false,
2083
+ showClear: (_7 = showClear !== null && showClear !== void 0 ? showClear : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showClear) !== null && _7 !== void 0 ? _7 : false,
2047
2084
  clearHistory: () => setHistory(h => h.slice(-1)),
2048
2085
  showLogin: canShowLoginButton,
2049
2086
  setShowLoginDrawer,
@@ -2058,7 +2095,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2058
2095
  setShowLoginDrawer(false);
2059
2096
  setUser(undefined);
2060
2097
  setLoginToken(undefined);
2061
- userToken = undefined;
2098
+ userTokenRef.current = undefined;
2062
2099
  (0, configuration_1.removeLocalConfig)('loginToken');
2063
2100
  });
2064
2101
  },
@@ -2074,7 +2111,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2074
2111
  hasUserActivatedSpeak,
2075
2112
  isPlayingAudio: isPlayingAudio &&
2076
2113
  !speakerMuted &&
2077
- ((_6 = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _6 !== void 0 ? _6 : true),
2114
+ ((_8 = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _8 !== void 0 ? _8 : true),
2078
2115
  loading: !!memoriTyping,
2079
2116
  baseUrl,
2080
2117
  apiUrl: client.constants.BACKEND_URL,
@@ -2111,7 +2148,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2111
2148
  tenant,
2112
2149
  translateTo: isMultilanguageEnabled &&
2113
2150
  userLang.toUpperCase() !==
2114
- ((_11 = ((_10 = (_9 = (_8 = (_7 = memori.culture) === null || _7 === void 0 ? void 0 : _7.split('-')) === null || _8 === void 0 ? void 0 : _8[0]) !== null && _9 !== void 0 ? _9 : i18n.language) !== null && _10 !== void 0 ? _10 : 'IT')) === null || _11 === void 0 ? void 0 : _11.toUpperCase())
2151
+ ((_13 = ((_12 = (_11 = (_10 = (_9 = memori.culture) === null || _9 === void 0 ? void 0 : _9.split('-')) === null || _10 === void 0 ? void 0 : _10[0]) !== null && _11 !== void 0 ? _11 : i18n.language) !== null && _12 !== void 0 ? _12 : 'IT')) === null || _13 === void 0 ? void 0 : _13.toUpperCase())
2115
2152
  ? userLang
2116
2153
  : undefined,
2117
2154
  baseUrl,
@@ -2119,9 +2156,9 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2119
2156
  layout,
2120
2157
  memoriTyping,
2121
2158
  typingText,
2122
- showTypingText: (_12 = showTypingText !== null && showTypingText !== void 0 ? showTypingText : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showTypingText) !== null && _12 !== void 0 ? _12 : false,
2159
+ showTypingText: (_14 = showTypingText !== null && showTypingText !== void 0 ? showTypingText : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showTypingText) !== null && _14 !== void 0 ? _14 : false,
2123
2160
  history: showFullHistory ? history : history.slice(-2),
2124
- authToken: (_14 = (_13 = loginToken !== null && loginToken !== void 0 ? loginToken : userToken) !== null && _13 !== void 0 ? _13 : additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _14 !== void 0 ? _14 : authToken,
2161
+ authToken: resolveLoginToken(),
2125
2162
  dialogState: currentDialogState,
2126
2163
  pushMessage,
2127
2164
  simulateUserPrompt,
@@ -2294,7 +2331,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2294
2331
  setShowLoginDrawer(false);
2295
2332
  setUser(user);
2296
2333
  setLoginToken(token);
2297
- userToken = token;
2334
+ userTokenRef.current = token;
2298
2335
  (0, configuration_1.setLocalConfig)('loginToken', token);
2299
2336
  if ((state === null || state === void 0 ? void 0 : state.sessionID) &&
2300
2337
  state.sessionID !== sessionId &&
@@ -2325,7 +2362,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2325
2362
  setShowLoginDrawer(false);
2326
2363
  setUser(undefined);
2327
2364
  setLoginToken(undefined);
2328
- userToken = undefined;
2365
+ userTokenRef.current = undefined;
2329
2366
  (0, configuration_1.removeLocalConfig)('loginToken');
2330
2367
  });
2331
2368
  } }))] }));