@memori.ai/memori-react 9.0.0-alpha.6 → 9.0.0-alpha.8
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.
- package/CHANGELOG.md +20 -0
- package/dist/components/AgeVerificationModal/AgeVerificationModal.js +3 -1
- package/dist/components/AgeVerificationModal/AgeVerificationModal.js.map +1 -1
- package/dist/components/Auth/Auth.js +3 -1
- package/dist/components/Auth/Auth.js.map +1 -1
- package/dist/components/Chat/Chat.js +3 -1
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/ChatBubble/ChatBubble.js +3 -1
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/ChatHistoryDrawer/ChatHistory.js +3 -1
- package/dist/components/ChatHistoryDrawer/ChatHistory.js.map +1 -1
- package/dist/components/ContentPreviewModal/ContentPreviewModal.js +3 -1
- package/dist/components/ContentPreviewModal/ContentPreviewModal.js.map +1 -1
- package/dist/components/ExpertsDrawer/ExpertsDrawer.js +3 -1
- package/dist/components/ExpertsDrawer/ExpertsDrawer.js.map +1 -1
- package/dist/components/KnownFacts/KnownFacts.js +5 -3
- package/dist/components/KnownFacts/KnownFacts.js.map +1 -1
- package/dist/components/LoginDrawer/LoginDrawer.js +3 -1
- package/dist/components/LoginDrawer/LoginDrawer.js.map +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +19 -5
- package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js +4 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.css +4 -2
- package/dist/components/MemoriWidget/MemoriWidget.js +139 -130
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/SettingsDrawer/SettingsDrawer.js +3 -1
- package/dist/components/SettingsDrawer/SettingsDrawer.js.map +1 -1
- package/dist/components/StartPanel/StartPanel.js +3 -1
- package/dist/components/StartPanel/StartPanel.js.map +1 -1
- package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js +3 -1
- package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
- package/dist/components/UploadButton/UploadImages/UploadImages.js +3 -1
- package/dist/components/UploadButton/UploadImages/UploadImages.js.map +1 -1
- package/dist/components/WhyThisAnswer/WhyThisAnswer.js +3 -1
- package/dist/components/WhyThisAnswer/WhyThisAnswer.js.map +1 -1
- package/dist/components/layouts/HiddenChat.js +4 -223
- package/dist/components/layouts/HiddenChat.js.map +1 -1
- package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.js +3 -1
- package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.js.map +1 -1
- package/dist/components/layouts/WebsiteAssistant/website-assistant.css +19 -0
- package/dist/components/layouts/chat.css +2 -1
- package/dist/components/layouts/fullpage.css +31 -8
- package/dist/components/layouts/hidden-chat.css +1 -6
- package/dist/components/layouts/totem.css +2 -1
- package/dist/components/layouts/zoomed-full-body.css +32 -7
- package/dist/context/widgetSurfaceContext.d.ts +3 -0
- package/dist/context/widgetSurfaceContext.js +11 -0
- package/dist/context/widgetSurfaceContext.js.map +1 -0
- package/dist/helpers/positionPopover.d.ts +1 -0
- package/dist/helpers/positionPopover.js +7 -0
- package/dist/helpers/positionPopover.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/esm/components/AgeVerificationModal/AgeVerificationModal.js +3 -1
- package/esm/components/AgeVerificationModal/AgeVerificationModal.js.map +1 -1
- package/esm/components/Auth/Auth.js +3 -1
- package/esm/components/Auth/Auth.js.map +1 -1
- package/esm/components/Chat/Chat.js +3 -1
- package/esm/components/Chat/Chat.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.js +3 -1
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/ChatHistoryDrawer/ChatHistory.js +3 -1
- package/esm/components/ChatHistoryDrawer/ChatHistory.js.map +1 -1
- package/esm/components/ContentPreviewModal/ContentPreviewModal.js +3 -1
- package/esm/components/ContentPreviewModal/ContentPreviewModal.js.map +1 -1
- package/esm/components/ExpertsDrawer/ExpertsDrawer.js +3 -1
- package/esm/components/ExpertsDrawer/ExpertsDrawer.js.map +1 -1
- package/esm/components/KnownFacts/KnownFacts.js +5 -3
- package/esm/components/KnownFacts/KnownFacts.js.map +1 -1
- package/esm/components/LoginDrawer/LoginDrawer.js +3 -1
- package/esm/components/LoginDrawer/LoginDrawer.js.map +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +19 -5
- package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js +4 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.css +4 -2
- package/esm/components/MemoriWidget/MemoriWidget.js +139 -130
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/SettingsDrawer/SettingsDrawer.js +3 -1
- package/esm/components/SettingsDrawer/SettingsDrawer.js.map +1 -1
- package/esm/components/StartPanel/StartPanel.js +3 -1
- package/esm/components/StartPanel/StartPanel.js.map +1 -1
- package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js +3 -1
- package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
- package/esm/components/UploadButton/UploadImages/UploadImages.js +3 -1
- package/esm/components/UploadButton/UploadImages/UploadImages.js.map +1 -1
- package/esm/components/WhyThisAnswer/WhyThisAnswer.js +3 -1
- package/esm/components/WhyThisAnswer/WhyThisAnswer.js.map +1 -1
- package/esm/components/layouts/HiddenChat.js +6 -225
- package/esm/components/layouts/HiddenChat.js.map +1 -1
- package/esm/components/layouts/WebsiteAssistant/WebsiteAssistant.js +3 -1
- package/esm/components/layouts/WebsiteAssistant/WebsiteAssistant.js.map +1 -1
- package/esm/components/layouts/WebsiteAssistant/website-assistant.css +19 -0
- package/esm/components/layouts/chat.css +2 -1
- package/esm/components/layouts/fullpage.css +31 -8
- package/esm/components/layouts/hidden-chat.css +1 -6
- package/esm/components/layouts/totem.css +2 -1
- package/esm/components/layouts/zoomed-full-body.css +32 -7
- package/esm/context/widgetSurfaceContext.d.ts +3 -0
- package/esm/context/widgetSurfaceContext.js +7 -0
- package/esm/context/widgetSurfaceContext.js.map +1 -0
- package/esm/helpers/positionPopover.d.ts +1 -0
- package/esm/helpers/positionPopover.js +4 -0
- package/esm/helpers/positionPopover.js.map +1 -0
- package/esm/styles.css +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/package.json +1 -1
- package/src/components/AgeVerificationModal/AgeVerificationModal.tsx +3 -0
- package/src/components/Auth/Auth.tsx +3 -0
- package/src/components/Chat/Chat.tsx +3 -0
- package/src/components/ChatBubble/ChatBubble.tsx +3 -0
- package/src/components/ChatHistoryDrawer/ChatHistory.tsx +3 -0
- package/src/components/ContentPreviewModal/ContentPreviewModal.tsx +3 -0
- package/src/components/ExpertsDrawer/ExpertsDrawer.tsx +3 -0
- package/src/components/KnownFacts/KnownFacts.tsx +5 -0
- package/src/components/LoginDrawer/LoginDrawer.tsx +3 -0
- package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +19 -5
- package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.tsx +4 -0
- package/src/components/MemoriWidget/MemoriWidget.css +4 -2
- package/src/components/MemoriWidget/MemoriWidget.tsx +45 -22
- package/src/components/SettingsDrawer/SettingsDrawer.tsx +3 -0
- package/src/components/StartPanel/StartPanel.tsx +3 -0
- package/src/components/UploadButton/UploadDocuments/UploadDocuments.tsx +3 -0
- package/src/components/UploadButton/UploadImages/UploadImages.tsx +3 -0
- package/src/components/WhyThisAnswer/WhyThisAnswer.tsx +3 -0
- package/src/components/layouts/HiddenChat.tsx +3 -389
- package/src/components/layouts/WebsiteAssistant/WebsiteAssistant.tsx +4 -0
- package/src/components/layouts/WebsiteAssistant/__snapshots__/WebsiteAssistant.test.tsx.snap +48 -44
- package/src/components/layouts/WebsiteAssistant/website-assistant.css +19 -0
- package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +533 -529
- package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +1058 -1050
- package/src/components/layouts/__snapshots__/HiddenChat.test.tsx.snap +406 -441
- package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +584 -580
- package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +528 -524
- package/src/components/layouts/chat.css +2 -1
- package/src/components/layouts/fullpage.css +31 -8
- package/src/components/layouts/hidden-chat.css +1 -6
- package/src/components/layouts/totem.css +2 -1
- package/src/components/layouts/zoomed-full-body.css +32 -7
- package/src/context/widgetSurfaceContext.tsx +14 -0
- package/src/helpers/positionPopover.test.ts +33 -0
- package/src/helpers/positionPopover.ts +13 -0
- package/src/styles.css +61 -1
- package/src/version.ts +1 -1
|
@@ -5,12 +5,14 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const ArtifactAPI_1 = require("../MemoriArtifactSystem/utils/ArtifactAPI");
|
|
7
7
|
const piiDetection_1 = require("../../helpers/piiDetection");
|
|
8
|
+
const positionPopover_1 = require("../../helpers/positionPopover");
|
|
8
9
|
const react_1 = require("react");
|
|
9
10
|
const react_i18next_1 = require("react-i18next");
|
|
10
11
|
const memori_api_client_1 = tslib_1.__importDefault(require("@memori.ai/memori-api-client"));
|
|
11
12
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
12
13
|
const luxon_1 = require("luxon");
|
|
13
14
|
const ui_1 = require("@memori.ai/ui");
|
|
15
|
+
const widgetSurfaceContext_1 = require("../../context/widgetSurfaceContext");
|
|
14
16
|
const Auth_1 = tslib_1.__importDefault(require("../Auth/Auth"));
|
|
15
17
|
const Chat_1 = tslib_1.__importDefault(require("../Chat/Chat"));
|
|
16
18
|
const StartPanel_1 = tslib_1.__importDefault(require("../StartPanel/StartPanel"));
|
|
@@ -213,6 +215,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
213
215
|
const [instruct, setInstruct] = (0, react_1.useState)(false);
|
|
214
216
|
const [enableFocusChatInput, setEnableFocusChatInput] = (0, react_1.useState)(true);
|
|
215
217
|
const [widgetRootEl, setWidgetRootEl] = (0, react_1.useState)(null);
|
|
218
|
+
const [widgetSurfaceEl, setWidgetSurfaceEl] = (0, react_1.useState)(null);
|
|
216
219
|
const [isDarkTheme, setIsDarkTheme] = (0, react_1.useState)(false);
|
|
217
220
|
(0, react_1.useEffect)(() => {
|
|
218
221
|
var _a;
|
|
@@ -1997,10 +2000,14 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1997
2000
|
}
|
|
1998
2001
|
}, [memoriPwd, memori, memoriTokens, birthDate, sessionId, userLang, position]);
|
|
1999
2002
|
const setPositionPopoverOpen = (0, react_1.useCallback)((open) => {
|
|
2000
|
-
setPositionPopoverOpenState(
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2003
|
+
setPositionPopoverOpenState(wasOpen => {
|
|
2004
|
+
if ((0, positionPopover_1.shouldRestartSessionOnPositionPopoverClose)(wasOpen, open, autoStart)) {
|
|
2005
|
+
queueMicrotask(() => {
|
|
2006
|
+
onClickStart();
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
return open;
|
|
2010
|
+
});
|
|
2004
2011
|
}, [autoStart, onClickStart]);
|
|
2005
2012
|
(0, react_1.useEffect)(() => {
|
|
2006
2013
|
if (!clickedStart &&
|
|
@@ -2342,7 +2349,9 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2342
2349
|
: FullPage_1.default;
|
|
2343
2350
|
const widgetTheme = (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.theme) === 'light' || (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.theme) === 'dark'
|
|
2344
2351
|
? integrationConfig.theme
|
|
2345
|
-
:
|
|
2352
|
+
: isDarkTheme
|
|
2353
|
+
? 'dark'
|
|
2354
|
+
: undefined;
|
|
2346
2355
|
return ((0, jsx_runtime_1.jsx)("div", { ref: setWidgetRootEl, className: (0, classnames_1.default)('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'}`, {
|
|
2347
2356
|
'memori--auto-start': autoStart,
|
|
2348
2357
|
'memori--preview': preview,
|
|
@@ -2355,132 +2364,132 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2355
2364
|
}), "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({
|
|
2356
2365
|
...currentDialogState,
|
|
2357
2366
|
sessionID: sessionId,
|
|
2358
|
-
}), style: { height }, children: (0, jsx_runtime_1.
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
});
|
|
2371
|
-
} }), (0, jsx_runtime_1.jsx)("audio", { id: "memori-audio", style: { display: 'none' }, src: "https://aisuru.com/intro.mp3" }), isClient && ((0, jsx_runtime_1.jsx)(Auth_1.default, { 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 && ((0, jsx_runtime_1.jsx)(AgeVerificationModal_1.default, { visible: showAgeVerification, minAge: minAge, onClose: birthDate => {
|
|
2405
|
-
var _a, _b, _c, _d;
|
|
2406
|
-
if (birthDate) {
|
|
2407
|
-
setBirthDate(birthDate);
|
|
2408
|
-
(0, configuration_1.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 && ((0, jsx_runtime_1.jsx)(SettingsDrawer_1.default, { 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 && ((0, jsx_runtime_1.jsx)(ChatHistory_1.default, { 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 && ((0, jsx_runtime_1.jsx)(KnownFacts_1.default, { apiClient: client, memori: memori, sessionID: sessionId, visible: showKnownFactsDrawer, closeDrawer: () => setShowKnownFactsDrawer(false) })), showExpertsDrawer && !!experts && ((0, jsx_runtime_1.jsx)(ExpertsDrawer_1.default, { 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) && ((0, jsx_runtime_1.jsx)(LoginDrawer_1.default, { 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
|
-
(0, configuration_1.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,
|
|
2367
|
+
}), style: { height }, children: (0, jsx_runtime_1.jsx)(ui_1.MemoriUIProvider, { container: widgetRootEl, theme: widgetTheme, children: (0, jsx_runtime_1.jsx)(widgetSurfaceContext_1.WidgetSurfaceProvider, { value: widgetSurfaceEl, children: (0, jsx_runtime_1.jsxs)("div", { ref: setWidgetSurfaceEl, className: "memori-widget__surface", children: [(0, jsx_runtime_1.jsx)(Layout, { Header: Header_1.default, headerProps: headerProps, Avatar: Avatar_1.default, avatarProps: avatarProps, Chat: Chat_1.default, chatProps: chatProps, StartPanel: StartPanel_1.default, 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 }), (0, jsx_runtime_1.jsx)(ArtifactAPI_1.ArtifactAPIBridge, { pushMessage: (message) => {
|
|
2368
|
+
setHistory(history => {
|
|
2369
|
+
if (!history.length)
|
|
2370
|
+
return history;
|
|
2371
|
+
const lastMessage = history[history.length - 1];
|
|
2372
|
+
if (!lastMessage || lastMessage.fromUser)
|
|
2373
|
+
return history;
|
|
2374
|
+
const updatedLastMessage = {
|
|
2375
|
+
...lastMessage,
|
|
2376
|
+
text: lastMessage.text + message.text,
|
|
2377
|
+
};
|
|
2378
|
+
return [...history.slice(0, -1), updatedLastMessage];
|
|
2469
2379
|
});
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2380
|
+
} }), (0, jsx_runtime_1.jsx)("audio", { id: "memori-audio", style: { display: 'none' }, src: "https://aisuru.com/intro.mp3" }), isClient && ((0, jsx_runtime_1.jsx)(Auth_1.default, { withModal: true, pwdOrTokens: authModalState, openModal: !!authModalState, setPwdOrTokens: setAuthModalState, showTokens: memori.privacyType === 'SECRET', onFinish: (values) => {
|
|
2381
|
+
var _a, _b, _c, _d;
|
|
2382
|
+
if (values['password'])
|
|
2383
|
+
setMemoriPwd(values['password']);
|
|
2384
|
+
if (values['password'])
|
|
2385
|
+
memoriPassword = values['password'];
|
|
2386
|
+
if (values['tokens'])
|
|
2387
|
+
setMemoriTokens(values['tokens']);
|
|
2388
|
+
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, {
|
|
2389
|
+
LANG: userLang,
|
|
2390
|
+
PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
|
|
2391
|
+
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()) || '',
|
|
2392
|
+
...(initialContextVars || {}),
|
|
2393
|
+
}, initialQuestion, birthDate)
|
|
2394
|
+
.then(state => {
|
|
2395
|
+
if (!(state === null || state === void 0 ? void 0 : state.sessionID)) {
|
|
2396
|
+
throw new Error('AUTH_FAILED');
|
|
2397
|
+
}
|
|
2398
|
+
setAuthModalState(null);
|
|
2399
|
+
if (state === null || state === void 0 ? void 0 : state.dialogState) {
|
|
2400
|
+
setHasUserActivatedSpeak(true);
|
|
2401
|
+
}
|
|
2402
|
+
else {
|
|
2403
|
+
onClickStart(state);
|
|
2404
|
+
}
|
|
2405
|
+
})
|
|
2406
|
+
.catch(error => {
|
|
2407
|
+
if (!(error instanceof Error) ||
|
|
2408
|
+
error.message !== 'AUTH_FAILED') {
|
|
2409
|
+
setGotErrorInOpening(true);
|
|
2410
|
+
}
|
|
2411
|
+
throw error;
|
|
2412
|
+
});
|
|
2413
|
+
}, minimumNumberOfRecoveryTokens: (_17 = memori === null || memori === void 0 ? void 0 : memori.minimumNumberOfRecoveryTokens) !== null && _17 !== void 0 ? _17 : 1 })), isClient && ((0, jsx_runtime_1.jsx)(AgeVerificationModal_1.default, { visible: showAgeVerification, minAge: minAge, onClose: birthDate => {
|
|
2414
|
+
var _a, _b, _c, _d;
|
|
2415
|
+
if (birthDate) {
|
|
2416
|
+
setBirthDate(birthDate);
|
|
2417
|
+
(0, configuration_1.setLocalConfig)('birthDate', birthDate);
|
|
2418
|
+
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, {
|
|
2419
|
+
LANG: userLang,
|
|
2420
|
+
PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
|
|
2421
|
+
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()) || '',
|
|
2422
|
+
...(initialContextVars || {}),
|
|
2423
|
+
}, initialQuestion, birthDate)
|
|
2424
|
+
.then(state => {
|
|
2425
|
+
setShowAgeVerification(false);
|
|
2426
|
+
setAuthModalState(null);
|
|
2427
|
+
onClickStart(state || undefined);
|
|
2428
|
+
})
|
|
2429
|
+
.catch(() => {
|
|
2430
|
+
setShowAgeVerification(false);
|
|
2431
|
+
setGotErrorInOpening(true);
|
|
2432
|
+
});
|
|
2433
|
+
}
|
|
2434
|
+
else {
|
|
2435
|
+
setShowAgeVerification(false);
|
|
2436
|
+
setClickedStart(false);
|
|
2437
|
+
}
|
|
2438
|
+
} })), showSettingsDrawer && ((0, jsx_runtime_1.jsx)(SettingsDrawer_1.default, { 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 && ((0, jsx_runtime_1.jsx)(ChatHistory_1.default, { open: !!showChatHistoryDrawer, onClose: () => setShowChatHistoryDrawer(false), resumeSession: chatLog => {
|
|
2439
|
+
setChatLogID(chatLog.chatLogID);
|
|
2440
|
+
onClickStart(undefined, false, chatLog);
|
|
2441
|
+
setShowChatHistoryDrawer(false);
|
|
2442
|
+
}, 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 && ((0, jsx_runtime_1.jsx)(KnownFacts_1.default, { apiClient: client, memori: memori, sessionID: sessionId, visible: showKnownFactsDrawer, closeDrawer: () => setShowKnownFactsDrawer(false) })), showExpertsDrawer && !!experts && ((0, jsx_runtime_1.jsx)(ExpertsDrawer_1.default, { 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) && ((0, jsx_runtime_1.jsx)(LoginDrawer_1.default, { tenant: tenant, apiClient: client, open: !!showLoginDrawer, user: user, loginToken: loginToken, onClose: () => setShowLoginDrawer(false), drawerClassName: selectedLayout === 'WEBSITE_ASSISTANT'
|
|
2443
|
+
? 'memori-drawer--above-website-assistant'
|
|
2444
|
+
: undefined, onLogin: (user, token) => {
|
|
2445
|
+
var _a, _b, _c, _d;
|
|
2446
|
+
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, {
|
|
2447
|
+
LANG: userLang,
|
|
2448
|
+
PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
|
|
2449
|
+
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()) || '',
|
|
2450
|
+
...(initialContextVars || {}),
|
|
2451
|
+
}, undefined, birthDate, { loginToken: token }, undefined, sessionId).then(state => {
|
|
2452
|
+
var _a, _b;
|
|
2453
|
+
setShowLoginDrawer(false);
|
|
2454
|
+
setUser(user);
|
|
2455
|
+
setLoginToken(token);
|
|
2456
|
+
userTokenRef.current = token;
|
|
2457
|
+
(0, configuration_1.setLocalConfig)('loginToken', token);
|
|
2458
|
+
if ((state === null || state === void 0 ? void 0 : state.sessionID) &&
|
|
2459
|
+
state.sessionID !== sessionId &&
|
|
2460
|
+
(state === null || state === void 0 ? void 0 : state.dialogState)) {
|
|
2461
|
+
const username = (user === null || user === void 0 ? void 0 : user.userName) || t('login.user');
|
|
2462
|
+
pushMessage({
|
|
2463
|
+
text: '',
|
|
2464
|
+
emitter: state.dialogState.emitter,
|
|
2465
|
+
media: (_b = (_a = state.dialogState.emittedMedia) !== null && _a !== void 0 ? _a : state.dialogState.media) !== null && _b !== void 0 ? _b : [],
|
|
2466
|
+
fromUser: false,
|
|
2467
|
+
initial: t('login.successfullyLoggedIn', {
|
|
2468
|
+
username,
|
|
2469
|
+
}),
|
|
2470
|
+
contextVars: state.dialogState.contextVars,
|
|
2471
|
+
date: state.dialogState.currentDate,
|
|
2472
|
+
placeName: state.dialogState.currentPlaceName,
|
|
2473
|
+
placeLatitude: state.dialogState.currentLatitude,
|
|
2474
|
+
placeLongitude: state.dialogState.currentLongitude,
|
|
2475
|
+
placeUncertaintyKm: state.dialogState.currentUncertaintyKm,
|
|
2476
|
+
tag: state.dialogState.currentTag,
|
|
2477
|
+
memoryTags: state.dialogState.memoryTags,
|
|
2478
|
+
});
|
|
2479
|
+
setCurrentDialogState(state.dialogState);
|
|
2480
|
+
}
|
|
2481
|
+
});
|
|
2482
|
+
}, setUser: setUser, onLogout: () => {
|
|
2483
|
+
if (!loginToken)
|
|
2484
|
+
return;
|
|
2485
|
+
client.backend.pwlUserLogout(loginToken).then(() => {
|
|
2486
|
+
setShowLoginDrawer(false);
|
|
2487
|
+
setUser(undefined);
|
|
2488
|
+
setLoginToken(undefined);
|
|
2489
|
+
userTokenRef.current = undefined;
|
|
2490
|
+
(0, configuration_1.removeLocalConfig)('loginToken');
|
|
2491
|
+
});
|
|
2492
|
+
} }))] }) }) }) }));
|
|
2484
2493
|
};
|
|
2485
2494
|
exports.default = MemoriWidget;
|
|
2486
2495
|
//# sourceMappingURL=MemoriWidget.js.map
|