@memori.ai/memori-react 9.0.0-alpha.6 → 9.0.0-alpha.7

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 (132) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/components/AgeVerificationModal/AgeVerificationModal.js +3 -1
  3. package/dist/components/AgeVerificationModal/AgeVerificationModal.js.map +1 -1
  4. package/dist/components/Auth/Auth.js +3 -1
  5. package/dist/components/Auth/Auth.js.map +1 -1
  6. package/dist/components/Chat/Chat.js +3 -1
  7. package/dist/components/Chat/Chat.js.map +1 -1
  8. package/dist/components/ChatBubble/ChatBubble.js +3 -1
  9. package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
  10. package/dist/components/ChatHistoryDrawer/ChatHistory.js +3 -1
  11. package/dist/components/ChatHistoryDrawer/ChatHistory.js.map +1 -1
  12. package/dist/components/ContentPreviewModal/ContentPreviewModal.js +3 -1
  13. package/dist/components/ContentPreviewModal/ContentPreviewModal.js.map +1 -1
  14. package/dist/components/ExpertsDrawer/ExpertsDrawer.js +3 -1
  15. package/dist/components/ExpertsDrawer/ExpertsDrawer.js.map +1 -1
  16. package/dist/components/KnownFacts/KnownFacts.js +5 -3
  17. package/dist/components/KnownFacts/KnownFacts.js.map +1 -1
  18. package/dist/components/LoginDrawer/LoginDrawer.js +3 -1
  19. package/dist/components/LoginDrawer/LoginDrawer.js.map +1 -1
  20. package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +19 -5
  21. package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js +4 -1
  22. package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js.map +1 -1
  23. package/dist/components/MemoriWidget/MemoriWidget.css +4 -2
  24. package/dist/components/MemoriWidget/MemoriWidget.js +130 -126
  25. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  26. package/dist/components/SettingsDrawer/SettingsDrawer.js +3 -1
  27. package/dist/components/SettingsDrawer/SettingsDrawer.js.map +1 -1
  28. package/dist/components/StartPanel/StartPanel.js +3 -1
  29. package/dist/components/StartPanel/StartPanel.js.map +1 -1
  30. package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js +3 -1
  31. package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
  32. package/dist/components/UploadButton/UploadImages/UploadImages.js +3 -1
  33. package/dist/components/UploadButton/UploadImages/UploadImages.js.map +1 -1
  34. package/dist/components/WhyThisAnswer/WhyThisAnswer.js +3 -1
  35. package/dist/components/WhyThisAnswer/WhyThisAnswer.js.map +1 -1
  36. package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.js +3 -1
  37. package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.js.map +1 -1
  38. package/dist/components/layouts/WebsiteAssistant/website-assistant.css +19 -0
  39. package/dist/components/layouts/chat.css +2 -1
  40. package/dist/components/layouts/fullpage.css +31 -8
  41. package/dist/components/layouts/hidden-chat.css +1 -0
  42. package/dist/components/layouts/totem.css +2 -1
  43. package/dist/components/layouts/zoomed-full-body.css +32 -7
  44. package/dist/context/widgetSurfaceContext.d.ts +3 -0
  45. package/dist/context/widgetSurfaceContext.js +11 -0
  46. package/dist/context/widgetSurfaceContext.js.map +1 -0
  47. package/dist/styles.css +1 -1
  48. package/dist/version.d.ts +1 -1
  49. package/dist/version.js +1 -1
  50. package/esm/components/AgeVerificationModal/AgeVerificationModal.js +3 -1
  51. package/esm/components/AgeVerificationModal/AgeVerificationModal.js.map +1 -1
  52. package/esm/components/Auth/Auth.js +3 -1
  53. package/esm/components/Auth/Auth.js.map +1 -1
  54. package/esm/components/Chat/Chat.js +3 -1
  55. package/esm/components/Chat/Chat.js.map +1 -1
  56. package/esm/components/ChatBubble/ChatBubble.js +3 -1
  57. package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
  58. package/esm/components/ChatHistoryDrawer/ChatHistory.js +3 -1
  59. package/esm/components/ChatHistoryDrawer/ChatHistory.js.map +1 -1
  60. package/esm/components/ContentPreviewModal/ContentPreviewModal.js +3 -1
  61. package/esm/components/ContentPreviewModal/ContentPreviewModal.js.map +1 -1
  62. package/esm/components/ExpertsDrawer/ExpertsDrawer.js +3 -1
  63. package/esm/components/ExpertsDrawer/ExpertsDrawer.js.map +1 -1
  64. package/esm/components/KnownFacts/KnownFacts.js +5 -3
  65. package/esm/components/KnownFacts/KnownFacts.js.map +1 -1
  66. package/esm/components/LoginDrawer/LoginDrawer.js +3 -1
  67. package/esm/components/LoginDrawer/LoginDrawer.js.map +1 -1
  68. package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +19 -5
  69. package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js +4 -1
  70. package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js.map +1 -1
  71. package/esm/components/MemoriWidget/MemoriWidget.css +4 -2
  72. package/esm/components/MemoriWidget/MemoriWidget.js +130 -126
  73. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  74. package/esm/components/SettingsDrawer/SettingsDrawer.js +3 -1
  75. package/esm/components/SettingsDrawer/SettingsDrawer.js.map +1 -1
  76. package/esm/components/StartPanel/StartPanel.js +3 -1
  77. package/esm/components/StartPanel/StartPanel.js.map +1 -1
  78. package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js +3 -1
  79. package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
  80. package/esm/components/UploadButton/UploadImages/UploadImages.js +3 -1
  81. package/esm/components/UploadButton/UploadImages/UploadImages.js.map +1 -1
  82. package/esm/components/WhyThisAnswer/WhyThisAnswer.js +3 -1
  83. package/esm/components/WhyThisAnswer/WhyThisAnswer.js.map +1 -1
  84. package/esm/components/layouts/WebsiteAssistant/WebsiteAssistant.js +3 -1
  85. package/esm/components/layouts/WebsiteAssistant/WebsiteAssistant.js.map +1 -1
  86. package/esm/components/layouts/WebsiteAssistant/website-assistant.css +19 -0
  87. package/esm/components/layouts/chat.css +2 -1
  88. package/esm/components/layouts/fullpage.css +31 -8
  89. package/esm/components/layouts/hidden-chat.css +1 -0
  90. package/esm/components/layouts/totem.css +2 -1
  91. package/esm/components/layouts/zoomed-full-body.css +32 -7
  92. package/esm/context/widgetSurfaceContext.d.ts +3 -0
  93. package/esm/context/widgetSurfaceContext.js +7 -0
  94. package/esm/context/widgetSurfaceContext.js.map +1 -0
  95. package/esm/styles.css +1 -1
  96. package/esm/version.d.ts +1 -1
  97. package/esm/version.js +1 -1
  98. package/package.json +1 -1
  99. package/src/components/AgeVerificationModal/AgeVerificationModal.tsx +3 -0
  100. package/src/components/Auth/Auth.tsx +3 -0
  101. package/src/components/Chat/Chat.tsx +3 -0
  102. package/src/components/ChatBubble/ChatBubble.tsx +3 -0
  103. package/src/components/ChatHistoryDrawer/ChatHistory.tsx +3 -0
  104. package/src/components/ContentPreviewModal/ContentPreviewModal.tsx +3 -0
  105. package/src/components/ExpertsDrawer/ExpertsDrawer.tsx +3 -0
  106. package/src/components/KnownFacts/KnownFacts.tsx +5 -0
  107. package/src/components/LoginDrawer/LoginDrawer.tsx +3 -0
  108. package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +19 -5
  109. package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.tsx +4 -0
  110. package/src/components/MemoriWidget/MemoriWidget.css +4 -2
  111. package/src/components/MemoriWidget/MemoriWidget.tsx +33 -18
  112. package/src/components/SettingsDrawer/SettingsDrawer.tsx +3 -0
  113. package/src/components/StartPanel/StartPanel.tsx +3 -0
  114. package/src/components/UploadButton/UploadDocuments/UploadDocuments.tsx +3 -0
  115. package/src/components/UploadButton/UploadImages/UploadImages.tsx +3 -0
  116. package/src/components/WhyThisAnswer/WhyThisAnswer.tsx +3 -0
  117. package/src/components/layouts/WebsiteAssistant/WebsiteAssistant.tsx +4 -0
  118. package/src/components/layouts/WebsiteAssistant/__snapshots__/WebsiteAssistant.test.tsx.snap +48 -44
  119. package/src/components/layouts/WebsiteAssistant/website-assistant.css +19 -0
  120. package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +533 -529
  121. package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +1058 -1050
  122. package/src/components/layouts/__snapshots__/HiddenChat.test.tsx.snap +443 -439
  123. package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +584 -580
  124. package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +528 -524
  125. package/src/components/layouts/chat.css +2 -1
  126. package/src/components/layouts/fullpage.css +31 -8
  127. package/src/components/layouts/hidden-chat.css +1 -0
  128. package/src/components/layouts/totem.css +2 -1
  129. package/src/components/layouts/zoomed-full-body.css +32 -7
  130. package/src/context/widgetSurfaceContext.tsx +14 -0
  131. package/src/styles.css +61 -1
  132. package/src/version.ts +1 -1
@@ -7,6 +7,7 @@ import memoriApiClient from '@memori.ai/memori-api-client';
7
7
  import cx from 'classnames';
8
8
  import { DateTime } from 'luxon';
9
9
  import { useAlertManager, createAlertOptions, MemoriUIProvider, } from '@memori.ai/ui';
10
+ import { WidgetSurfaceProvider } from '../../context/widgetSurfaceContext';
10
11
  import MemoriAuth from '../Auth/Auth';
11
12
  import Chat from '../Chat/Chat';
12
13
  import StartPanel from '../StartPanel/StartPanel';
@@ -209,6 +210,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
209
210
  const [instruct, setInstruct] = useState(false);
210
211
  const [enableFocusChatInput, setEnableFocusChatInput] = useState(true);
211
212
  const [widgetRootEl, setWidgetRootEl] = useState(null);
213
+ const [widgetSurfaceEl, setWidgetSurfaceEl] = useState(null);
212
214
  const [isDarkTheme, setIsDarkTheme] = useState(false);
213
215
  useEffect(() => {
214
216
  var _a;
@@ -2338,7 +2340,9 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2338
2340
  : FullPageLayout;
2339
2341
  const widgetTheme = (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.theme) === 'light' || (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.theme) === 'dark'
2340
2342
  ? integrationConfig.theme
2341
- : undefined;
2343
+ : isDarkTheme
2344
+ ? 'dark'
2345
+ : undefined;
2342
2346
  return (_jsx("div", { ref: setWidgetRootEl, className: cx('memori', 'memori-widget', `memori-layout-${String(selectedLayout).toLowerCase()}`, `memori-controls-${String(controlsPosition).toLowerCase()}`, `memori--avatar-${(integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.avatar) || 'default'}`, {
2343
2347
  'memori--auto-start': autoStart,
2344
2348
  'memori--preview': preview,
@@ -2351,132 +2355,132 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2351
2355
  }), "data-theme": widgetTheme, "data-memori-name": memori === null || memori === void 0 ? void 0 : memori.name, "data-memori-id": memori === null || memori === void 0 ? void 0 : memori.engineMemoriID, "data-memori-secondary-id": memori === null || memori === void 0 ? void 0 : memori.memoriID, "data-memori-session-id": sessionId, "data-memori-integration": integration === null || integration === void 0 ? void 0 : integration.integrationID, "data-memori-engine-state": JSON.stringify({
2352
2356
  ...currentDialogState,
2353
2357
  sessionID: sessionId,
2354
- }), style: { height }, children: _jsxs(MemoriUIProvider, { container: widgetRootEl, theme: widgetTheme, children: [_jsx(Layout, { Header: Header, headerProps: headerProps, Avatar: Avatar, avatarProps: avatarProps, Chat: Chat, chatProps: chatProps, StartPanel: StartPanel, startPanelProps: startPanelProps, integrationStyle: integrationStyle, integrationBackground: integrationBackground, poweredBy: poweredBy, autoStart: autoStart, sessionId: sessionId, hasUserActivatedSpeak: hasUserActivatedSpeak, loading: loading, avatar3dHidden: avatar3dHidden !== null && avatar3dHidden !== void 0 ? avatar3dHidden : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.avatar_3d_hidden }), _jsx(ArtifactAPIBridge, { pushMessage: (message) => {
2355
- setHistory(history => {
2356
- if (!history.length)
2357
- return history;
2358
- const lastMessage = history[history.length - 1];
2359
- if (!lastMessage || lastMessage.fromUser)
2360
- return history;
2361
- const updatedLastMessage = {
2362
- ...lastMessage,
2363
- text: lastMessage.text + message.text,
2364
- };
2365
- return [...history.slice(0, -1), updatedLastMessage];
2366
- });
2367
- } }), _jsx("audio", { id: "memori-audio", style: { display: 'none' }, src: "https://aisuru.com/intro.mp3" }), isClient && (_jsx(MemoriAuth, { withModal: true, pwdOrTokens: authModalState, openModal: !!authModalState, setPwdOrTokens: setAuthModalState, showTokens: memori.privacyType === 'SECRET', onFinish: (values) => {
2368
- var _a, _b, _c, _d;
2369
- if (values['password'])
2370
- setMemoriPwd(values['password']);
2371
- if (values['password'])
2372
- memoriPassword = values['password'];
2373
- if (values['tokens'])
2374
- setMemoriTokens(values['tokens']);
2375
- return reopenSession(!sessionId, values['password'], values['tokens'], personification === null || personification === void 0 ? void 0 : personification.tag, personification === null || personification === void 0 ? void 0 : personification.pin, {
2376
- LANG: userLang,
2377
- PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2378
- ROUTE: ((_d = (_c = (_b = window.location.pathname) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) || '',
2379
- ...(initialContextVars || {}),
2380
- }, initialQuestion, birthDate)
2381
- .then(state => {
2382
- if (!(state === null || state === void 0 ? void 0 : state.sessionID)) {
2383
- throw new Error('AUTH_FAILED');
2384
- }
2385
- setAuthModalState(null);
2386
- if (state === null || state === void 0 ? void 0 : state.dialogState) {
2387
- setHasUserActivatedSpeak(true);
2388
- }
2389
- else {
2390
- onClickStart(state);
2391
- }
2392
- })
2393
- .catch(error => {
2394
- if (!(error instanceof Error) ||
2395
- error.message !== 'AUTH_FAILED') {
2396
- setGotErrorInOpening(true);
2397
- }
2398
- throw error;
2399
- });
2400
- }, minimumNumberOfRecoveryTokens: (_17 = memori === null || memori === void 0 ? void 0 : memori.minimumNumberOfRecoveryTokens) !== null && _17 !== void 0 ? _17 : 1 })), isClient && (_jsx(AgeVerificationModal, { visible: showAgeVerification, minAge: minAge, onClose: birthDate => {
2401
- var _a, _b, _c, _d;
2402
- if (birthDate) {
2403
- setBirthDate(birthDate);
2404
- setLocalConfig('birthDate', birthDate);
2405
- reopenSession(!sessionId, memoriPassword || memoriPwd || (memori === null || memori === void 0 ? void 0 : memori.secretToken), memoriTokens, personification === null || personification === void 0 ? void 0 : personification.tag, personification === null || personification === void 0 ? void 0 : personification.pin, {
2406
- LANG: userLang,
2407
- PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2408
- ROUTE: ((_d = (_c = (_b = window.location.pathname) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) || '',
2409
- ...(initialContextVars || {}),
2410
- }, initialQuestion, birthDate)
2411
- .then(state => {
2412
- setShowAgeVerification(false);
2413
- setAuthModalState(null);
2414
- onClickStart(state || undefined);
2415
- })
2416
- .catch(() => {
2417
- setShowAgeVerification(false);
2418
- setGotErrorInOpening(true);
2419
- });
2420
- }
2421
- else {
2422
- setShowAgeVerification(false);
2423
- setClickedStart(false);
2424
- }
2425
- } })), showSettingsDrawer && (_jsx(SettingsDrawer, { layout: selectedLayout, open: !!showSettingsDrawer, onClose: () => setShowSettingsDrawer(false), microphoneMode: continuousSpeech ? 'CONTINUOUS' : 'HOLD_TO_TALK', continuousSpeechTimeout: continuousSpeechTimeout, setMicrophoneMode: mode => setContinuousSpeech(mode === 'CONTINUOUS'), setContinuousSpeechTimeout: setContinuousSpeechTimeout, controlsPosition: controlsPosition, setControlsPosition: setControlsPosition, hideEmissions: hideEmissions, setHideEmissions: setHideEmissions, avatarType: avatarType, setAvatarType: setAvatarType, enablePositionControls: enablePositionControls, setEnablePositionControls: setEnablePositionControls, isAvatar3d: !!(integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.avatarURL), additionalSettings: additionalSettings, speakerMuted: speakerMuted })), showChatHistoryDrawer && (_jsx(ChatHistoryDrawer, { open: !!showChatHistoryDrawer, onClose: () => setShowChatHistoryDrawer(false), resumeSession: chatLog => {
2426
- setChatLogID(chatLog.chatLogID);
2427
- onClickStart(undefined, false, chatLog);
2428
- setShowChatHistoryDrawer(false);
2429
- }, apiClient: client, sessionId: sessionId || '', memori: memori, baseUrl: baseUrl, history: history, apiUrl: client.constants.BACKEND_URL, loginToken: loginToken, language: language, userLang: userLang, isMultilanguageEnabled: isMultilanguageEnabled })), showKnownFactsDrawer && sessionId && (_jsx(KnownFacts, { apiClient: client, memori: memori, sessionID: sessionId, visible: showKnownFactsDrawer, closeDrawer: () => setShowKnownFactsDrawer(false) })), showExpertsDrawer && !!experts && (_jsx(ExpertsDrawer, { apiUrl: client.constants.BACKEND_URL, baseUrl: baseUrl, tenant: tenant, experts: experts, open: showExpertsDrawer, onClose: () => setShowExpertsDrawer(false) })), showLoginDrawer && (tenant === null || tenant === void 0 ? void 0 : tenant.name) && (_jsx(LoginDrawer, { tenant: tenant, apiClient: client, open: !!showLoginDrawer, user: user, loginToken: loginToken, onClose: () => setShowLoginDrawer(false), drawerClassName: selectedLayout === 'WEBSITE_ASSISTANT'
2430
- ? 'memori-drawer--above-website-assistant'
2431
- : undefined, onLogin: (user, token) => {
2432
- var _a, _b, _c, _d;
2433
- reopenSession(false, memoriPassword || memoriPwd || (memori === null || memori === void 0 ? void 0 : memori.secretToken), [], personification === null || personification === void 0 ? void 0 : personification.tag, personification === null || personification === void 0 ? void 0 : personification.pin, {
2434
- LANG: userLang,
2435
- PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2436
- ROUTE: ((_d = (_c = (_b = window.location.pathname) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) || '',
2437
- ...(initialContextVars || {}),
2438
- }, undefined, birthDate, { loginToken: token }, undefined, sessionId).then(state => {
2439
- var _a, _b;
2440
- setShowLoginDrawer(false);
2441
- setUser(user);
2442
- setLoginToken(token);
2443
- userTokenRef.current = token;
2444
- setLocalConfig('loginToken', token);
2445
- if ((state === null || state === void 0 ? void 0 : state.sessionID) &&
2446
- state.sessionID !== sessionId &&
2447
- (state === null || state === void 0 ? void 0 : state.dialogState)) {
2448
- const username = (user === null || user === void 0 ? void 0 : user.userName) || t('login.user');
2449
- pushMessage({
2450
- text: '',
2451
- emitter: state.dialogState.emitter,
2452
- media: (_b = (_a = state.dialogState.emittedMedia) !== null && _a !== void 0 ? _a : state.dialogState.media) !== null && _b !== void 0 ? _b : [],
2453
- fromUser: false,
2454
- initial: t('login.successfullyLoggedIn', {
2455
- username,
2456
- }),
2457
- contextVars: state.dialogState.contextVars,
2458
- date: state.dialogState.currentDate,
2459
- placeName: state.dialogState.currentPlaceName,
2460
- placeLatitude: state.dialogState.currentLatitude,
2461
- placeLongitude: state.dialogState.currentLongitude,
2462
- placeUncertaintyKm: state.dialogState.currentUncertaintyKm,
2463
- tag: state.dialogState.currentTag,
2464
- memoryTags: state.dialogState.memoryTags,
2358
+ }), style: { height }, children: _jsx(MemoriUIProvider, { container: widgetRootEl, theme: widgetTheme, children: _jsx(WidgetSurfaceProvider, { value: widgetSurfaceEl, children: _jsxs("div", { ref: setWidgetSurfaceEl, className: "memori-widget__surface", children: [_jsx(Layout, { Header: Header, headerProps: headerProps, Avatar: Avatar, avatarProps: avatarProps, Chat: Chat, chatProps: chatProps, StartPanel: StartPanel, startPanelProps: startPanelProps, integrationStyle: integrationStyle, integrationBackground: integrationBackground, poweredBy: poweredBy, autoStart: autoStart, sessionId: sessionId, hasUserActivatedSpeak: hasUserActivatedSpeak, loading: loading, avatar3dHidden: avatar3dHidden !== null && avatar3dHidden !== void 0 ? avatar3dHidden : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.avatar_3d_hidden }), _jsx(ArtifactAPIBridge, { pushMessage: (message) => {
2359
+ setHistory(history => {
2360
+ if (!history.length)
2361
+ return history;
2362
+ const lastMessage = history[history.length - 1];
2363
+ if (!lastMessage || lastMessage.fromUser)
2364
+ return history;
2365
+ const updatedLastMessage = {
2366
+ ...lastMessage,
2367
+ text: lastMessage.text + message.text,
2368
+ };
2369
+ return [...history.slice(0, -1), updatedLastMessage];
2465
2370
  });
2466
- setCurrentDialogState(state.dialogState);
2467
- }
2468
- });
2469
- }, setUser: setUser, onLogout: () => {
2470
- if (!loginToken)
2471
- return;
2472
- client.backend.pwlUserLogout(loginToken).then(() => {
2473
- setShowLoginDrawer(false);
2474
- setUser(undefined);
2475
- setLoginToken(undefined);
2476
- userTokenRef.current = undefined;
2477
- removeLocalConfig('loginToken');
2478
- });
2479
- } }))] }) }));
2371
+ } }), _jsx("audio", { id: "memori-audio", style: { display: 'none' }, src: "https://aisuru.com/intro.mp3" }), isClient && (_jsx(MemoriAuth, { withModal: true, pwdOrTokens: authModalState, openModal: !!authModalState, setPwdOrTokens: setAuthModalState, showTokens: memori.privacyType === 'SECRET', onFinish: (values) => {
2372
+ var _a, _b, _c, _d;
2373
+ if (values['password'])
2374
+ setMemoriPwd(values['password']);
2375
+ if (values['password'])
2376
+ memoriPassword = values['password'];
2377
+ if (values['tokens'])
2378
+ setMemoriTokens(values['tokens']);
2379
+ return reopenSession(!sessionId, values['password'], values['tokens'], personification === null || personification === void 0 ? void 0 : personification.tag, personification === null || personification === void 0 ? void 0 : personification.pin, {
2380
+ LANG: userLang,
2381
+ PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2382
+ ROUTE: ((_d = (_c = (_b = window.location.pathname) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) || '',
2383
+ ...(initialContextVars || {}),
2384
+ }, initialQuestion, birthDate)
2385
+ .then(state => {
2386
+ if (!(state === null || state === void 0 ? void 0 : state.sessionID)) {
2387
+ throw new Error('AUTH_FAILED');
2388
+ }
2389
+ setAuthModalState(null);
2390
+ if (state === null || state === void 0 ? void 0 : state.dialogState) {
2391
+ setHasUserActivatedSpeak(true);
2392
+ }
2393
+ else {
2394
+ onClickStart(state);
2395
+ }
2396
+ })
2397
+ .catch(error => {
2398
+ if (!(error instanceof Error) ||
2399
+ error.message !== 'AUTH_FAILED') {
2400
+ setGotErrorInOpening(true);
2401
+ }
2402
+ throw error;
2403
+ });
2404
+ }, minimumNumberOfRecoveryTokens: (_17 = memori === null || memori === void 0 ? void 0 : memori.minimumNumberOfRecoveryTokens) !== null && _17 !== void 0 ? _17 : 1 })), isClient && (_jsx(AgeVerificationModal, { visible: showAgeVerification, minAge: minAge, onClose: birthDate => {
2405
+ var _a, _b, _c, _d;
2406
+ if (birthDate) {
2407
+ setBirthDate(birthDate);
2408
+ setLocalConfig('birthDate', birthDate);
2409
+ reopenSession(!sessionId, memoriPassword || memoriPwd || (memori === null || memori === void 0 ? void 0 : memori.secretToken), memoriTokens, personification === null || personification === void 0 ? void 0 : personification.tag, personification === null || personification === void 0 ? void 0 : personification.pin, {
2410
+ LANG: userLang,
2411
+ PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2412
+ ROUTE: ((_d = (_c = (_b = window.location.pathname) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) || '',
2413
+ ...(initialContextVars || {}),
2414
+ }, initialQuestion, birthDate)
2415
+ .then(state => {
2416
+ setShowAgeVerification(false);
2417
+ setAuthModalState(null);
2418
+ onClickStart(state || undefined);
2419
+ })
2420
+ .catch(() => {
2421
+ setShowAgeVerification(false);
2422
+ setGotErrorInOpening(true);
2423
+ });
2424
+ }
2425
+ else {
2426
+ setShowAgeVerification(false);
2427
+ setClickedStart(false);
2428
+ }
2429
+ } })), showSettingsDrawer && (_jsx(SettingsDrawer, { layout: selectedLayout, open: !!showSettingsDrawer, onClose: () => setShowSettingsDrawer(false), microphoneMode: continuousSpeech ? 'CONTINUOUS' : 'HOLD_TO_TALK', continuousSpeechTimeout: continuousSpeechTimeout, setMicrophoneMode: mode => setContinuousSpeech(mode === 'CONTINUOUS'), setContinuousSpeechTimeout: setContinuousSpeechTimeout, controlsPosition: controlsPosition, setControlsPosition: setControlsPosition, hideEmissions: hideEmissions, setHideEmissions: setHideEmissions, avatarType: avatarType, setAvatarType: setAvatarType, enablePositionControls: enablePositionControls, setEnablePositionControls: setEnablePositionControls, isAvatar3d: !!(integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.avatarURL), additionalSettings: additionalSettings, speakerMuted: speakerMuted })), showChatHistoryDrawer && (_jsx(ChatHistoryDrawer, { open: !!showChatHistoryDrawer, onClose: () => setShowChatHistoryDrawer(false), resumeSession: chatLog => {
2430
+ setChatLogID(chatLog.chatLogID);
2431
+ onClickStart(undefined, false, chatLog);
2432
+ setShowChatHistoryDrawer(false);
2433
+ }, apiClient: client, sessionId: sessionId || '', memori: memori, baseUrl: baseUrl, history: history, apiUrl: client.constants.BACKEND_URL, loginToken: loginToken, language: language, userLang: userLang, isMultilanguageEnabled: isMultilanguageEnabled })), showKnownFactsDrawer && sessionId && (_jsx(KnownFacts, { apiClient: client, memori: memori, sessionID: sessionId, visible: showKnownFactsDrawer, closeDrawer: () => setShowKnownFactsDrawer(false) })), showExpertsDrawer && !!experts && (_jsx(ExpertsDrawer, { apiUrl: client.constants.BACKEND_URL, baseUrl: baseUrl, tenant: tenant, experts: experts, open: showExpertsDrawer, onClose: () => setShowExpertsDrawer(false) })), showLoginDrawer && (tenant === null || tenant === void 0 ? void 0 : tenant.name) && (_jsx(LoginDrawer, { tenant: tenant, apiClient: client, open: !!showLoginDrawer, user: user, loginToken: loginToken, onClose: () => setShowLoginDrawer(false), drawerClassName: selectedLayout === 'WEBSITE_ASSISTANT'
2434
+ ? 'memori-drawer--above-website-assistant'
2435
+ : undefined, onLogin: (user, token) => {
2436
+ var _a, _b, _c, _d;
2437
+ reopenSession(false, memoriPassword || memoriPwd || (memori === null || memori === void 0 ? void 0 : memori.secretToken), [], personification === null || personification === void 0 ? void 0 : personification.tag, personification === null || personification === void 0 ? void 0 : personification.pin, {
2438
+ LANG: userLang,
2439
+ PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2440
+ ROUTE: ((_d = (_c = (_b = window.location.pathname) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) || '',
2441
+ ...(initialContextVars || {}),
2442
+ }, undefined, birthDate, { loginToken: token }, undefined, sessionId).then(state => {
2443
+ var _a, _b;
2444
+ setShowLoginDrawer(false);
2445
+ setUser(user);
2446
+ setLoginToken(token);
2447
+ userTokenRef.current = token;
2448
+ setLocalConfig('loginToken', token);
2449
+ if ((state === null || state === void 0 ? void 0 : state.sessionID) &&
2450
+ state.sessionID !== sessionId &&
2451
+ (state === null || state === void 0 ? void 0 : state.dialogState)) {
2452
+ const username = (user === null || user === void 0 ? void 0 : user.userName) || t('login.user');
2453
+ pushMessage({
2454
+ text: '',
2455
+ emitter: state.dialogState.emitter,
2456
+ media: (_b = (_a = state.dialogState.emittedMedia) !== null && _a !== void 0 ? _a : state.dialogState.media) !== null && _b !== void 0 ? _b : [],
2457
+ fromUser: false,
2458
+ initial: t('login.successfullyLoggedIn', {
2459
+ username,
2460
+ }),
2461
+ contextVars: state.dialogState.contextVars,
2462
+ date: state.dialogState.currentDate,
2463
+ placeName: state.dialogState.currentPlaceName,
2464
+ placeLatitude: state.dialogState.currentLatitude,
2465
+ placeLongitude: state.dialogState.currentLongitude,
2466
+ placeUncertaintyKm: state.dialogState.currentUncertaintyKm,
2467
+ tag: state.dialogState.currentTag,
2468
+ memoryTags: state.dialogState.memoryTags,
2469
+ });
2470
+ setCurrentDialogState(state.dialogState);
2471
+ }
2472
+ });
2473
+ }, setUser: setUser, onLogout: () => {
2474
+ if (!loginToken)
2475
+ return;
2476
+ client.backend.pwlUserLogout(loginToken).then(() => {
2477
+ setShowLoginDrawer(false);
2478
+ setUser(undefined);
2479
+ setLoginToken(undefined);
2480
+ userTokenRef.current = undefined;
2481
+ removeLocalConfig('loginToken');
2482
+ });
2483
+ } }))] }) }) }) }));
2480
2484
  };
2481
2485
  export default MemoriWidget;
2482
2486
  //# sourceMappingURL=MemoriWidget.js.map