@memori.ai/memori-react 7.12.2 → 7.13.1

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 (77) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +4 -4
  3. package/dist/components/Avatar/Avatar.js +2 -1
  4. package/dist/components/Avatar/Avatar.js.map +1 -1
  5. package/dist/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.d.ts +0 -1
  6. package/dist/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.js +23 -11
  7. package/dist/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.js.map +1 -1
  8. package/dist/components/Chat/Chat.d.ts +0 -1
  9. package/dist/components/Chat/Chat.js +5 -10
  10. package/dist/components/Chat/Chat.js.map +1 -1
  11. package/dist/components/MemoriWidget/MemoriWidget.css +10 -4
  12. package/dist/components/MemoriWidget/MemoriWidget.d.ts +3 -6
  13. package/dist/components/MemoriWidget/MemoriWidget.js +39 -253
  14. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  15. package/dist/components/layouts/Chat.js +1 -1
  16. package/dist/components/layouts/Chat.js.map +1 -1
  17. package/dist/components/layouts/FullPage.js +1 -1
  18. package/dist/components/layouts/FullPage.js.map +1 -1
  19. package/dist/components/layouts/Totem.js +1 -1
  20. package/dist/components/layouts/Totem.js.map +1 -1
  21. package/dist/components/layouts/WebsiteAssistant.js +2 -2
  22. package/dist/components/layouts/WebsiteAssistant.js.map +1 -1
  23. package/dist/components/layouts/ZoomedFullBody.js +2 -2
  24. package/dist/components/layouts/ZoomedFullBody.js.map +1 -1
  25. package/dist/index.d.ts +4 -2
  26. package/dist/index.js +6 -4
  27. package/dist/index.js.map +1 -1
  28. package/dist/styles.css +1 -0
  29. package/esm/components/Avatar/Avatar.js +2 -1
  30. package/esm/components/Avatar/Avatar.js.map +1 -1
  31. package/esm/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.d.ts +0 -1
  32. package/esm/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.js +23 -11
  33. package/esm/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.js.map +1 -1
  34. package/esm/components/Chat/Chat.d.ts +0 -1
  35. package/esm/components/Chat/Chat.js +5 -10
  36. package/esm/components/Chat/Chat.js.map +1 -1
  37. package/esm/components/MemoriWidget/MemoriWidget.css +10 -4
  38. package/esm/components/MemoriWidget/MemoriWidget.d.ts +3 -6
  39. package/esm/components/MemoriWidget/MemoriWidget.js +40 -254
  40. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  41. package/esm/components/layouts/Chat.js +1 -1
  42. package/esm/components/layouts/Chat.js.map +1 -1
  43. package/esm/components/layouts/FullPage.js +1 -1
  44. package/esm/components/layouts/FullPage.js.map +1 -1
  45. package/esm/components/layouts/Totem.js +1 -1
  46. package/esm/components/layouts/Totem.js.map +1 -1
  47. package/esm/components/layouts/WebsiteAssistant.js +2 -2
  48. package/esm/components/layouts/WebsiteAssistant.js.map +1 -1
  49. package/esm/components/layouts/ZoomedFullBody.js +2 -2
  50. package/esm/components/layouts/ZoomedFullBody.js.map +1 -1
  51. package/esm/index.d.ts +4 -2
  52. package/esm/index.js +6 -4
  53. package/esm/index.js.map +1 -1
  54. package/esm/styles.css +1 -0
  55. package/package.json +1 -1
  56. package/src/components/Avatar/Avatar.tsx +3 -4
  57. package/src/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.tsx +35 -13
  58. package/src/components/Chat/Chat.test.tsx +0 -81
  59. package/src/components/Chat/Chat.tsx +1 -26
  60. package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +0 -1159
  61. package/src/components/MemoriWidget/MemoriWidget.css +10 -4
  62. package/src/components/MemoriWidget/MemoriWidget.stories.tsx +7 -10
  63. package/src/components/MemoriWidget/MemoriWidget.tsx +55 -317
  64. package/src/components/layouts/Chat.tsx +0 -6
  65. package/src/components/layouts/FullPage.test.tsx +21 -1
  66. package/src/components/layouts/FullPage.tsx +0 -7
  67. package/src/components/layouts/Totem.tsx +0 -6
  68. package/src/components/layouts/WebsiteAssistant.tsx +0 -7
  69. package/src/components/layouts/ZoomedFullBody.tsx +0 -9
  70. package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +1 -1
  71. package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +463 -1
  72. package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +1 -1
  73. package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +1 -1
  74. package/src/components/layouts/layouts.stories.tsx +36 -38
  75. package/src/index.stories.tsx +1 -2
  76. package/src/index.tsx +20 -10
  77. package/src/styles.css +1 -0
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState, useEffect, useCallback, useRef, } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import memoriApiClient from '@memori.ai/memori-api-client';
5
- import { AudioContext, } from 'standardized-audio-context';
5
+ import { AudioContext } from 'standardized-audio-context';
6
6
  import * as speechSdk from 'microsoft-cognitiveservices-speech-sdk';
7
7
  import cx from 'classnames';
8
8
  import { DateTime } from 'luxon';
@@ -12,7 +12,6 @@ import MemoriAuth from '../Auth/Auth';
12
12
  import Chat from '../Chat/Chat';
13
13
  import StartPanel from '../StartPanel/StartPanel';
14
14
  import Avatar from '../Avatar/Avatar';
15
- import ChangeMode from '../ChangeMode/ChangeMode';
16
15
  import Header from '../Header/Header';
17
16
  import PoweredBy from '../PoweredBy/PoweredBy';
18
17
  import AgeVerificationModal from '../AgeVerificationModal/AgeVerificationModal';
@@ -152,7 +151,7 @@ let memoriPassword;
152
151
  let speakerMuted = false;
153
152
  let memoriSpeaking = false;
154
153
  let userToken;
155
- const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenantID, memoriLang, multilingual, integration, layout = 'DEFAULT', customLayout, showInstruct = false, showShare, preview = false, embed = false, showCopyButton = true, showTranslationOriginal = false, showInputs = true, showDates = false, showContextPerLine = false, showSettings = true, showTypingText = false, showClear = false, showLogin = false, showUpload = false, showOnlyLastMessages, height = '100vh', secret, baseUrl = 'https://aisuru.com', apiURL = 'https://backend.memori.ai', engineURL = 'https://engine.memori.ai', initialContextVars, initialQuestion, ogImage, sessionID: initialSessionID, tenant, personification, authToken, AZURE_COGNITIVE_SERVICES_TTS_KEY, enableAudio, defaultSpeakerActive = true, disableTextEnteredEvents = false, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, userAvatar, useMathFormatting = false, }) => {
154
+ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenantID, memoriLang, multilingual, integration, layout = 'DEFAULT', customLayout, showShare, preview = false, embed = false, showCopyButton = true, showTranslationOriginal = false, showInputs = true, showDates = false, showContextPerLine = false, showSettings = true, showTypingText = false, showClear = false, showLogin = false, showUpload = false, showOnlyLastMessages, height = '100vh', secret, baseUrl = 'https://aisuru.com', apiURL = 'https://backend.memori.ai', engineURL = 'https://engine.memori.ai', initialContextVars, initialQuestion, ogImage, sessionID: initialSessionID, tenant, personification, authToken, AZURE_COGNITIVE_SERVICES_TTS_KEY, enableAudio, defaultSpeakerActive = true, disableTextEnteredEvents = false, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, userAvatar, useMathFormatting = false, autoStart = false, applyVarsToRoot = false, }) => {
156
155
  var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
157
156
  const { t, i18n } = useTranslation();
158
157
  const [isClient, setIsClient] = useState(false);
@@ -222,7 +221,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
222
221
  const [showSettingsDrawer, setShowSettingsDrawer] = useState(false);
223
222
  const [showKnownFactsDrawer, setShowKnownFactsDrawer] = useState(false);
224
223
  const [showExpertsDrawer, setShowExpertsDrawer] = useState(false);
225
- const [muteSpeaker, setMuteSpeaker] = useState(!defaultEnableAudio || !defaultSpeakerActive);
224
+ const [muteSpeaker, setMuteSpeaker] = useState(!defaultEnableAudio || !defaultSpeakerActive || autoStart);
226
225
  const [continuousSpeech, setContinuousSpeech] = useState(false);
227
226
  const [continuousSpeechTimeout, setContinuousSpeechTimeout] = useState(2);
228
227
  const [isPlayingAudio, setIsPlayingAudio] = useState(false);
@@ -249,8 +248,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
249
248
  else {
250
249
  defaultControlsPosition = 'bottom';
251
250
  }
252
- setMuteSpeaker(getLocalConfig('muteSpeaker', !defaultEnableAudio || !defaultSpeakerActive));
253
- speakerMuted = getLocalConfig('muteSpeaker', !defaultEnableAudio || !defaultSpeakerActive);
251
+ setMuteSpeaker(autoStart ||
252
+ getLocalConfig('muteSpeaker', !defaultEnableAudio || !defaultSpeakerActive || autoStart));
253
+ speakerMuted =
254
+ autoStart ||
255
+ getLocalConfig('muteSpeaker', !defaultEnableAudio || !defaultSpeakerActive || autoStart);
254
256
  setContinuousSpeech(microphoneMode === 'CONTINUOUS');
255
257
  setContinuousSpeechTimeout(getLocalConfig('continuousSpeechTimeout', 2));
256
258
  setControlsPosition(getLocalConfig('controlsPosition', defaultControlsPosition));
@@ -353,7 +355,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
353
355
  try {
354
356
  if (!hidden &&
355
357
  translate &&
356
- !instruct &&
357
358
  isMultilanguageEnabled &&
358
359
  userLang.toUpperCase() !== language.toUpperCase()) {
359
360
  const translation = await getTranslation(text, language, userLang, baseUrl);
@@ -370,78 +371,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
370
371
  const emission = useLoaderTextAsMsg && typingText
371
372
  ? typingText
372
373
  : (_d = currentState.emission) !== null && _d !== void 0 ? _d : currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.emission;
373
- if (currentState.state === 'X4' && memori.giverTag) {
374
- const { currentState, ...resp } = await postTagChangedEvent(sessionID, memori.giverTag);
375
- if (resp.resultCode === 0) {
376
- setCurrentDialogState(currentState);
377
- if (emission) {
378
- pushMessage({
379
- text: emission,
380
- emitter: currentState.emitter,
381
- media: currentState.media,
382
- fromUser: false,
383
- questionAnswered: msg,
384
- contextVars: currentState.contextVars,
385
- date: currentState.currentDate,
386
- placeName: currentState.currentPlaceName,
387
- placeLatitude: currentState.currentLatitude,
388
- placeLongitude: currentState.currentLongitude,
389
- placeUncertaintyKm: currentState.currentUncertaintyKm,
390
- tag: currentState.currentTag,
391
- memoryTags: currentState.memoryTags,
392
- });
393
- speak(emission);
394
- }
395
- }
396
- else {
397
- console.error(response, resp);
398
- toast.error(t(getErrori18nKey(resp.resultCode)));
399
- gotError = true;
400
- }
401
- }
402
- else if (currentState.state === 'X2d' && memori.giverTag) {
403
- const { currentState, ...resp } = await postTextEnteredEvent({
404
- sessionId: sessionID,
405
- text: Math.random().toString().substring(2, 8),
406
- });
407
- if (resp.resultCode === 0) {
408
- const { currentState, ...resp } = await postTagChangedEvent(sessionID, memori.giverTag);
409
- if (resp.resultCode === 0) {
410
- setCurrentDialogState(currentState);
411
- if (emission) {
412
- pushMessage({
413
- text: emission,
414
- emitter: currentState.emitter,
415
- media: currentState.media,
416
- fromUser: false,
417
- questionAnswered: msg,
418
- contextVars: currentState.contextVars,
419
- date: currentState.currentDate,
420
- placeName: currentState.currentPlaceName,
421
- placeLatitude: currentState.currentLatitude,
422
- placeLongitude: currentState.currentLongitude,
423
- placeUncertaintyKm: currentState.currentUncertaintyKm,
424
- tag: currentState.currentTag,
425
- memoryTags: currentState.memoryTags,
426
- });
427
- speak(emission);
428
- }
429
- }
430
- else {
431
- console.error(response, resp);
432
- toast.error(t(getErrori18nKey(resp.resultCode)));
433
- gotError = true;
434
- }
435
- }
436
- else {
437
- console.error(response, resp);
438
- toast.error(t(getErrori18nKey(resp.resultCode)));
439
- gotError = true;
440
- }
441
- }
442
- else if (userLang.toLowerCase() !== language.toLowerCase() &&
374
+ if (userLang.toLowerCase() !== language.toLowerCase() &&
443
375
  emission &&
444
- !instruct &&
445
376
  isMultilanguageEnabled) {
446
377
  translateDialogState(currentState, userLang, msg).then(ts => {
447
378
  let text = ts.translatedEmission || ts.emission;
@@ -478,7 +409,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
478
409
  }
479
410
  else if (response.resultCode === 404) {
480
411
  setHistory(h => [...h.slice(0, h.length - 1)]);
481
- reopenSession(false, memoriPwd || memori.secretToken, memoriTokens, instruct && memori.giverTag ? memori.giverTag : undefined, instruct && memori.giverPIN ? memori.giverPIN : undefined, {
412
+ reopenSession(false, memoriPwd || memori.secretToken, memoriTokens, undefined, undefined, {
482
413
  PATHNAME: window.location.pathname,
483
414
  ROUTE: ((_g = (_f = window.location.pathname) === null || _f === void 0 ? void 0 : _f.split('/')) === null || _g === void 0 ? void 0 : _g.pop()) || '',
484
415
  ...(initialContextVars || {}),
@@ -509,7 +440,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
509
440
  let translatedState = { ...state };
510
441
  let translatedMsg = null;
511
442
  if (!emission ||
512
- instruct ||
513
443
  language.toUpperCase() === userLang.toUpperCase() ||
514
444
  !isMultilanguageEnabled) {
515
445
  translatedState = { ...state, emission };
@@ -643,7 +573,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
643
573
  });
644
574
  };
645
575
  const fetchSession = async (params) => {
646
- var _a, _b, _c, _d, _f, _g;
576
+ var _a, _b, _c, _d, _f;
647
577
  let storageBirthDate = getLocalConfig('birthDate', undefined);
648
578
  let userBirthDate = (_a = birthDate !== null && birthDate !== void 0 ? birthDate : params.birthDate) !== null && _a !== void 0 ? _a : storageBirthDate;
649
579
  if (!userBirthDate && !!minAge) {
@@ -659,13 +589,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
659
589
  }
660
590
  setLoading(true);
661
591
  try {
662
- if (!memori.giverTag && !!((_b = memori.receivedInvitations) === null || _b === void 0 ? void 0 : _b.length)) {
663
- let giverInvitation = memori.receivedInvitations.find((i) => i.type === 'GIVER' && i.state === 'ACCEPTED');
664
- if (giverInvitation) {
665
- memori.giverTag = giverInvitation.tag;
666
- memori.giverPIN = giverInvitation.pin;
667
- }
668
- }
669
592
  let referral;
670
593
  try {
671
594
  referral = (() => {
@@ -678,11 +601,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
678
601
  const session = await initSession({
679
602
  ...params,
680
603
  birthDate: userBirthDate,
681
- tag: (_c = params.tag) !== null && _c !== void 0 ? _c : personification === null || personification === void 0 ? void 0 : personification.tag,
682
- pin: (_d = params.pin) !== null && _d !== void 0 ? _d : personification === null || personification === void 0 ? void 0 : personification.pin,
604
+ tag: (_b = params.tag) !== null && _b !== void 0 ? _b : personification === null || personification === void 0 ? void 0 : personification.tag,
605
+ pin: (_c = params.pin) !== null && _c !== void 0 ? _c : personification === null || personification === void 0 ? void 0 : personification.pin,
683
606
  additionalInfo: {
684
607
  ...(additionalInfo || {}),
685
- 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,
608
+ loginToken: (_f = (_d = userToken !== null && userToken !== void 0 ? userToken : loginToken) !== null && _d !== void 0 ? _d : additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _f !== void 0 ? _f : authToken,
686
609
  language: getCultureCodeByLanguage(userLang),
687
610
  referral: referral,
688
611
  timeZoneOffset: new Date().getTimezoneOffset().toString(),
@@ -692,6 +615,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
692
615
  (session === null || session === void 0 ? void 0 : session.currentState) &&
693
616
  session.resultCode === 0) {
694
617
  setSessionId(session.sessionID);
618
+ setInstruct((currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) === memori.giverTag);
695
619
  if (position)
696
620
  applyPosition(position, session.sessionID);
697
621
  setLoading(false);
@@ -751,8 +675,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
751
675
  memoriID: (_a = memori.engineMemoriID) !== null && _a !== void 0 ? _a : '',
752
676
  password: password || memoriPwd || memori.secretToken,
753
677
  recoveryTokens: recoveryTokens || memoriTokens,
754
- tag,
755
- pin,
678
+ tag: tag !== null && tag !== void 0 ? tag : personification === null || personification === void 0 ? void 0 : personification.tag,
679
+ pin: pin !== null && pin !== void 0 ? pin : personification === null || personification === void 0 ? void 0 : personification.pin,
756
680
  initialContextVars: {
757
681
  PATHNAME: window.location.pathname,
758
682
  ROUTE: ((_c = (_b = window.location.pathname) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop()) || '',
@@ -883,8 +807,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
883
807
  fetchSession({
884
808
  memoriID: (_a = memori.engineMemoriID) !== null && _a !== void 0 ? _a : '',
885
809
  password: secret || memoriPwd || memori.secretToken,
886
- tag: memori.giverTag,
887
- pin: memori.giverPIN,
810
+ tag: tag !== null && tag !== void 0 ? tag : personification === null || personification === void 0 ? void 0 : personification.tag,
811
+ pin: pin !== null && pin !== void 0 ? pin : personification === null || personification === void 0 ? void 0 : personification.pin,
888
812
  initialContextVars: {
889
813
  PATHNAME: window.location.pathname,
890
814
  ROUTE: ((_c = (_b = window.location.pathname) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop()) || '',
@@ -917,19 +841,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
917
841
  }
918
842
  return null;
919
843
  };
920
- const restoreGiverTag = async () => {
921
- if (sessionId && memori.giverTag && memori.giverPIN) {
922
- setHistory([]);
923
- await changeTag(memori.engineMemoriID, sessionId, memori.giverTag, memori.giverPIN);
924
- }
925
- };
926
- useEffect(() => {
927
- return () => {
928
- if (!currentDialogState ||
929
- (currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) !== memori.giverTag)
930
- restoreGiverTag();
931
- };
932
- }, []);
933
844
  const sendDateChangedEvent = useCallback(async ({ sessionID, date, state, }) => {
934
845
  var _a;
935
846
  const session = sessionID !== null && sessionID !== void 0 ? sessionID : sessionId;
@@ -1001,8 +912,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1001
912
  const { currentState, ...response } = await postTimeoutEvent(sessionId);
1002
913
  if (response.resultCode === 0 && currentState) {
1003
914
  const emission = currentState.emission;
1004
- if (!instruct &&
1005
- isMultilanguageEnabled &&
915
+ if (isMultilanguageEnabled &&
1006
916
  userLang !== (i18n === null || i18n === void 0 ? void 0 : i18n.language) &&
1007
917
  emission &&
1008
918
  emission.length > 0) {
@@ -1267,15 +1177,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1267
1177
  const e = new CustomEvent('MemoriEndSpeak');
1268
1178
  document.dispatchEvent(e);
1269
1179
  };
1270
- const handleSpeechEnd = () => {
1271
- memoriSpeaking = false;
1272
- setMemoriTyping(false);
1273
- emitEndSpeakEvent();
1274
- };
1275
- const generateSSMLText = (text) => {
1276
- const textToSpeak = escapeHTML(stripMarkdown(stripEmojis(stripHTML(stripOutputTags(text)))));
1277
- return `<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xmlns:emo="http://www.w3.org/2009/10/emotionml" xml:lang="${getCultureCodeByLanguage(userLang)}"><voice name="${getTTSVoice(userLang)}"><s>${replaceTextWithPhonemes(textToSpeak, userLang.toLowerCase())}</s></voice></speak>`;
1278
- };
1279
1180
  const speak = (text) => {
1280
1181
  if (!AZURE_COGNITIVE_SERVICES_TTS_KEY || preview) {
1281
1182
  emitEndSpeakEvent();
@@ -1619,7 +1520,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1619
1520
  const integrationProperties = (integration
1620
1521
  ? {
1621
1522
  '--memori-chat-bubble-bg': '#fff',
1622
- ...(integrationConfig && !showInstruct
1523
+ ...(integrationConfig && !instruct
1623
1524
  ? { '--memori-text-color': (_q = integrationConfig.textColor) !== null && _q !== void 0 ? _q : '#000' }
1624
1525
  : {}),
1625
1526
  ...((integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.buttonBgColor)
@@ -1657,11 +1558,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1657
1558
  }
1658
1559
  : {});
1659
1560
  const integrationStylesheet = `
1660
- ${preview
1661
- ? '#preview,'
1662
- : selectedLayout === 'WEBSITE_ASSISTANT'
1663
- ? ''
1664
- : ':root,'} .memori-widget, .memori-drawer, .memori-modal {
1561
+ ${preview ? '#preview, ' : applyVarsToRoot ? ':root, ' : ''}memori-client, .memori-widget, .memori-drawer, .memori-modal {
1665
1562
  ${Object.entries(integrationProperties)
1666
1563
  .map(([key, value]) => `${key}: ${value};`)
1667
1564
  .join('\n')}
@@ -1708,74 +1605,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1708
1605
  document.head.append(meta);
1709
1606
  }
1710
1607
  }, [integrationConfig, memori.avatarURL, ogImage]);
1711
- const selectReceiverTag = async (tag) => {
1712
- var _a;
1713
- if (!sessionId)
1714
- return;
1715
- try {
1716
- const { currentState, ...resp } = await postTagChangedEvent(sessionId, tag);
1717
- if (resp.resultCode === 0) {
1718
- pushMessage({
1719
- text: tag,
1720
- fromUser: true,
1721
- });
1722
- if (currentState.state === 'X4' && memori.giverTag) {
1723
- const { currentState, ...resp } = await client.postTagChangedEvent(sessionId, memori.giverTag);
1724
- if (resp.resultCode === 0) {
1725
- setCurrentDialogState(currentState);
1726
- if (currentState.emission) {
1727
- pushMessage({
1728
- text: currentState.emission,
1729
- emitter: currentState.emitter,
1730
- media: currentState.media,
1731
- fromUser: false,
1732
- contextVars: currentState.contextVars,
1733
- date: currentState.currentDate,
1734
- placeName: currentState.currentPlaceName,
1735
- placeLatitude: currentState.currentLatitude,
1736
- placeLongitude: currentState.currentLongitude,
1737
- placeUncertaintyKm: currentState.currentUncertaintyKm,
1738
- tag: currentState.currentTag,
1739
- memoryTags: currentState.memoryTags,
1740
- });
1741
- }
1742
- }
1743
- else {
1744
- console.error(resp);
1745
- toast.error(t(getErrori18nKey(resp.resultCode)));
1746
- }
1747
- }
1748
- else {
1749
- setCurrentDialogState(currentState);
1750
- if (currentState.emission) {
1751
- pushMessage({
1752
- text: currentState.emission,
1753
- emitter: currentState.emitter,
1754
- media: currentState.media,
1755
- fromUser: false,
1756
- contextVars: currentState.contextVars,
1757
- date: currentState.currentDate,
1758
- placeName: currentState.currentPlaceName,
1759
- placeLatitude: currentState.currentLatitude,
1760
- placeLongitude: currentState.currentLongitude,
1761
- placeUncertaintyKm: currentState.currentUncertaintyKm,
1762
- tag: currentState.currentTag,
1763
- memoryTags: currentState.memoryTags,
1764
- });
1765
- }
1766
- }
1767
- }
1768
- else {
1769
- console.error(resp, tag, (_a = currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.knownTags) === null || _a === void 0 ? void 0 : _a[tag]);
1770
- toast.error(t(getErrori18nKey(resp.resultCode)));
1771
- }
1772
- }
1773
- catch (e) {
1774
- let err = e;
1775
- console.error(err);
1776
- toast.error(err.message);
1777
- }
1778
- };
1779
1608
  const simulateUserPrompt = (text, translatedText) => {
1780
1609
  stopListening();
1781
1610
  stopAudio();
@@ -1818,7 +1647,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1818
1647
  };
1819
1648
  }, [sessionId, userLang, disableTextEnteredEvents]);
1820
1649
  const onClickStart = useCallback(async (session, initialSessionExpired = false) => {
1821
- var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _t, _u, _v, _w;
1650
+ var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
1822
1651
  const sessionID = (session === null || session === void 0 ? void 0 : session.sessionID) || sessionId;
1823
1652
  const dialogState = (session === null || session === void 0 ? void 0 : session.dialogState) || currentDialogState;
1824
1653
  setClickedStart(true);
@@ -1902,44 +1731,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1902
1731
  applyPosition(position, sessionID);
1903
1732
  if (memori.needsDateTime)
1904
1733
  sendDateChangedEvent({ sessionID: sessionID, state: currentState });
1905
- if (instruct &&
1906
- memori.giverTag &&
1907
- (currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) !== memori.giverTag) {
1908
- try {
1909
- console.debug('change tag #0');
1910
- await changeTag(memori.engineMemoriID, sessionID, '-');
1911
- const session = await changeTag(memori.engineMemoriID, sessionID, memori.giverTag, memori.giverPIN);
1912
- if (session && session.resultCode === 0) {
1913
- translateDialogState(session.currentState, userLang)
1914
- .then(ts => {
1915
- let text = ts.translatedEmission || ts.emission;
1916
- if (text) {
1917
- speak(text);
1918
- }
1919
- })
1920
- .finally(() => {
1921
- setHasUserActivatedSpeak(true);
1922
- });
1923
- }
1924
- else {
1925
- console.error('session #1', session);
1926
- throw new Error('No session');
1927
- }
1928
- }
1929
- catch (e) {
1930
- console.error('session #2', e);
1931
- reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, memori === null || memori === void 0 ? void 0 : memori.giverTag, memori === null || memori === void 0 ? void 0 : memori.giverPIN, {
1932
- PATHNAME: (_h = window.location.pathname) === null || _h === void 0 ? void 0 : _h.toUpperCase(),
1933
- ROUTE: ((_l = (_k = (_j = window.location.pathname) === null || _j === void 0 ? void 0 : _j.split('/')) === null || _k === void 0 ? void 0 : _k.pop()) === null || _l === void 0 ? void 0 : _l.toUpperCase()) ||
1934
- '',
1935
- ...(initialContextVars || {}),
1936
- }, initialQuestion, birth).then(() => {
1937
- setHasUserActivatedSpeak(true);
1938
- });
1939
- }
1940
- }
1941
- else if (!instruct &&
1942
- personification &&
1734
+ if (personification &&
1943
1735
  (currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) !== personification.tag) {
1944
1736
  try {
1945
1737
  console.debug('change tag #3');
@@ -1965,8 +1757,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1965
1757
  catch (e) {
1966
1758
  console.error('session #5', e);
1967
1759
  reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, personification.tag, personification.pin, {
1968
- PATHNAME: (_m = window.location.pathname) === null || _m === void 0 ? void 0 : _m.toUpperCase(),
1969
- ROUTE: ((_q = (_p = (_o = window.location.pathname) === null || _o === void 0 ? void 0 : _o.split('/')) === null || _p === void 0 ? void 0 : _p.pop()) === null || _q === void 0 ? void 0 : _q.toUpperCase()) ||
1760
+ PATHNAME: (_h = window.location.pathname) === null || _h === void 0 ? void 0 : _h.toUpperCase(),
1761
+ ROUTE: ((_l = (_k = (_j = window.location.pathname) === null || _j === void 0 ? void 0 : _j.split('/')) === null || _k === void 0 ? void 0 : _k.pop()) === null || _l === void 0 ? void 0 : _l.toUpperCase()) ||
1970
1762
  '',
1971
1763
  ...(initialContextVars || {}),
1972
1764
  }, initialQuestion, birth).then(() => {
@@ -1974,8 +1766,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1974
1766
  });
1975
1767
  }
1976
1768
  }
1977
- else if (!instruct &&
1978
- !personification &&
1769
+ else if (!personification &&
1979
1770
  (currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) &&
1980
1771
  (currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) !== anonTag &&
1981
1772
  (currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) !== '-') {
@@ -2003,8 +1794,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2003
1794
  catch (e) {
2004
1795
  console.error('session #8', e);
2005
1796
  reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, undefined, undefined, {
2006
- PATHNAME: (_r = window.location.pathname) === null || _r === void 0 ? void 0 : _r.toUpperCase(),
2007
- ROUTE: ((_v = (_u = (_t = window.location.pathname) === null || _t === void 0 ? void 0 : _t.split('/')) === null || _u === void 0 ? void 0 : _u.pop()) === null || _v === void 0 ? void 0 : _v.toUpperCase()) ||
1797
+ PATHNAME: (_m = window.location.pathname) === null || _m === void 0 ? void 0 : _m.toUpperCase(),
1798
+ ROUTE: ((_q = (_p = (_o = window.location.pathname) === null || _o === void 0 ? void 0 : _o.split('/')) === null || _p === void 0 ? void 0 : _p.pop()) === null || _q === void 0 ? void 0 : _q.toUpperCase()) ||
2008
1799
  '',
2009
1800
  ...(initialContextVars || {}),
2010
1801
  }, initialQuestion, birth).then(() => {
@@ -2015,7 +1806,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2015
1806
  else {
2016
1807
  try {
2017
1808
  const { chatLogs, ...resp } = await getSessionChatLogs(sessionID, sessionID);
2018
- const messages = (_w = chatLogs === null || chatLogs === void 0 ? void 0 : chatLogs[0]) === null || _w === void 0 ? void 0 : _w.lines.map((l, i) => {
1809
+ const messages = (_r = chatLogs === null || chatLogs === void 0 ? void 0 : chatLogs[0]) === null || _r === void 0 ? void 0 : _r.lines.map((l, i) => {
2019
1810
  var _a, _b;
2020
1811
  return ({
2021
1812
  text: l.text,
@@ -2078,6 +1869,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2078
1869
  });
2079
1870
  }
2080
1871
  }, [memoriPwd, memori, memoriTokens, birthDate, sessionId, userLang, position]);
1872
+ useEffect(() => {
1873
+ if (!clickedStart && autoStart) {
1874
+ onClickStart();
1875
+ }
1876
+ }, [clickedStart, autoStart]);
2081
1877
  useEffect(() => {
2082
1878
  const targetNode = document.querySelector(`memori-client[memoriname="${memori.name}"]`) ||
2083
1879
  document.querySelector(`memori-client[memoriid="${memori.memoriID}"]`) ||
@@ -2280,14 +2076,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2280
2076
  showCopyButton,
2281
2077
  showTranslationOriginal,
2282
2078
  client,
2283
- selectReceiverTag,
2079
+ instruct,
2284
2080
  preview,
2285
2081
  sendOnEnter,
2286
2082
  setSendOnEnter,
2287
2083
  microphoneMode: continuousSpeech ? 'CONTINUOUS' : 'HOLD_TO_TALK',
2288
2084
  attachmentsMenuOpen,
2289
2085
  setAttachmentsMenuOpen,
2290
- instruct,
2291
2086
  showInputs,
2292
2087
  showMicrophone: !!AZURE_COGNITIVE_SERVICES_TTS_KEY,
2293
2088
  userMessage,
@@ -2324,16 +2119,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2324
2119
  };
2325
2120
  const integrationBackground = integration && globalBackgroundUrl ? (_jsx("div", { className: "memori--global-background", children: _jsx("div", { className: "memori--global-background-image", style: { backgroundImage: globalBackgroundUrl } }) })) : (_jsx("div", { className: "memori--global-background no-background-image" }));
2326
2121
  const integrationStyle = integration ? (_jsx("style", { dangerouslySetInnerHTML: { __html: integrationStylesheet } })) : null;
2327
- const onChangeMode = (mode) => {
2328
- setInstruct(mode === 'instruct');
2329
- setHasUserActivatedSpeak(false);
2330
- setClickedStart(false);
2331
- };
2332
- const changeModeProps = {
2333
- canInstruct: !!memori.giverTag,
2334
- instruct: !!instruct,
2335
- onChangeMode,
2336
- };
2337
2122
  const poweredBy = (_jsx(PoweredBy, { tenant: tenant, userLang: userLang, integrationID: integration === null || integration === void 0 ? void 0 : integration.integrationID, memoriHash: `${memori.ownerTenantName}-${memori.ownerUserName}-${memori.name}` }));
2338
2123
  const Layout = customLayout
2339
2124
  ? customLayout
@@ -2351,6 +2136,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2351
2136
  ? ZoomedFullBodyLayout
2352
2137
  : FullPageLayout;
2353
2138
  return (_jsxs("div", { className: cx('memori', 'memori-widget', `memori-layout-${layout.toLowerCase()}`, `memori-controls-${controlsPosition.toLowerCase()}`, `memori--avatar-${(integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.avatar) || 'default'}`, {
2139
+ 'memori--auto-start': autoStart,
2354
2140
  'memori--preview': preview,
2355
2141
  'memori--embed': embed,
2356
2142
  'memori--with-integration': integration,
@@ -2361,7 +2147,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2361
2147
  }), "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({
2362
2148
  ...currentDialogState,
2363
2149
  sessionID: sessionId,
2364
- }), style: { height }, children: [_jsx(Layout, { Header: Header, headerProps: headerProps, Avatar: Avatar, avatarProps: avatarProps, Chat: Chat, chatProps: chatProps, StartPanel: StartPanel, startPanelProps: startPanelProps, integrationStyle: integrationStyle, integrationBackground: integrationBackground, ChangeMode: ChangeMode, changeModeProps: changeModeProps, poweredBy: poweredBy, sessionId: sessionId, hasUserActivatedSpeak: hasUserActivatedSpeak, showInstruct: showInstruct, loading: loading }), _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: async (values) => {
2150
+ }), style: { height }, 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, sessionId: sessionId, hasUserActivatedSpeak: hasUserActivatedSpeak, loading: loading }), _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: async (values) => {
2365
2151
  var _a, _b, _c, _d;
2366
2152
  if (values['password'])
2367
2153
  setMemoriPwd(values['password']);
@@ -2369,7 +2155,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2369
2155
  memoriPassword = values['password'];
2370
2156
  if (values['tokens'])
2371
2157
  setMemoriTokens(values['tokens']);
2372
- reopenSession(!sessionId, values['password'], values['tokens'], instruct ? memori.giverTag : personification === null || personification === void 0 ? void 0 : personification.tag, instruct ? memori.giverPIN : personification === null || personification === void 0 ? void 0 : personification.pin, {
2158
+ reopenSession(!sessionId, values['password'], values['tokens'], personification === null || personification === void 0 ? void 0 : personification.tag, personification === null || personification === void 0 ? void 0 : personification.pin, {
2373
2159
  PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2374
2160
  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()) ||
2375
2161
  '',
@@ -2388,7 +2174,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2388
2174
  if (birthDate) {
2389
2175
  setBirthDate(birthDate);
2390
2176
  setLocalConfig('birthDate', birthDate);
2391
- reopenSession(!sessionId, memoriPassword || memoriPwd || (memori === null || memori === void 0 ? void 0 : memori.secretToken), memoriTokens, instruct ? memori.giverTag : personification === null || personification === void 0 ? void 0 : personification.tag, instruct ? memori.giverPIN : personification === null || personification === void 0 ? void 0 : personification.pin, {
2177
+ 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, {
2392
2178
  PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2393
2179
  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()) || '',
2394
2180
  ...(initialContextVars || {}),