@memori.ai/memori-react 9.2.0 → 9.2.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 (78) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/components/Chat/Chat.d.ts +2 -0
  3. package/dist/components/Chat/Chat.js +74 -11
  4. package/dist/components/Chat/Chat.js.map +1 -1
  5. package/dist/components/ChatBubble/ChatBubble.d.ts +5 -0
  6. package/dist/components/ChatBubble/ChatBubble.js +2 -2
  7. package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
  8. package/dist/components/IconButton/IconButton.d.ts +1 -1
  9. package/dist/components/InstructionProposalCard/InstructionProposalCard.css +115 -0
  10. package/dist/components/InstructionProposalCard/InstructionProposalCard.d.ts +31 -0
  11. package/dist/components/InstructionProposalCard/InstructionProposalCard.js +288 -0
  12. package/dist/components/InstructionProposalCard/InstructionProposalCard.js.map +1 -0
  13. package/dist/components/MediaWidget/MediaItemWidget.css +6 -0
  14. package/dist/components/MediaWidget/MediaItemWidget.js +16 -4
  15. package/dist/components/MediaWidget/MediaItemWidget.js.map +1 -1
  16. package/dist/components/MediaWidget/MediaItemWidget.types.d.ts +5 -0
  17. package/dist/components/MediaWidget/MediaWidget.d.ts +4 -0
  18. package/dist/components/MediaWidget/MediaWidget.js +2 -2
  19. package/dist/components/MediaWidget/MediaWidget.js.map +1 -1
  20. package/dist/components/MemoriWidget/MemoriWidget.js +32 -3
  21. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  22. package/dist/components/layouts/flows/FlowWidget.js +2 -2
  23. package/dist/components/layouts/flows/FlowWidget.js.map +1 -1
  24. package/dist/helpers/constants.d.ts +1 -0
  25. package/dist/helpers/constants.js +2 -1
  26. package/dist/helpers/constants.js.map +1 -1
  27. package/dist/index.js +1 -6
  28. package/dist/index.js.map +1 -1
  29. package/dist/locales/de.json +75 -0
  30. package/dist/locales/en.json +75 -0
  31. package/dist/locales/es.json +75 -0
  32. package/dist/locales/fr.json +75 -0
  33. package/dist/locales/it.json +75 -0
  34. package/dist/styles.css +1 -1
  35. package/dist/types/instructionProposal.d.ts +64 -0
  36. package/dist/types/instructionProposal.js +3 -0
  37. package/dist/types/instructionProposal.js.map +1 -0
  38. package/dist/version.d.ts +1 -1
  39. package/dist/version.js +1 -1
  40. package/esm/components/Chat/Chat.d.ts +2 -0
  41. package/esm/components/Chat/Chat.js +75 -12
  42. package/esm/components/Chat/Chat.js.map +1 -1
  43. package/esm/components/ChatBubble/ChatBubble.d.ts +5 -0
  44. package/esm/components/ChatBubble/ChatBubble.js +2 -2
  45. package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
  46. package/esm/components/IconButton/IconButton.d.ts +1 -1
  47. package/esm/components/InstructionProposalCard/InstructionProposalCard.css +115 -0
  48. package/esm/components/InstructionProposalCard/InstructionProposalCard.d.ts +31 -0
  49. package/esm/components/InstructionProposalCard/InstructionProposalCard.js +278 -0
  50. package/esm/components/InstructionProposalCard/InstructionProposalCard.js.map +1 -0
  51. package/esm/components/MediaWidget/MediaItemWidget.css +6 -0
  52. package/esm/components/MediaWidget/MediaItemWidget.js +17 -5
  53. package/esm/components/MediaWidget/MediaItemWidget.js.map +1 -1
  54. package/esm/components/MediaWidget/MediaItemWidget.types.d.ts +5 -0
  55. package/esm/components/MediaWidget/MediaWidget.d.ts +4 -0
  56. package/esm/components/MediaWidget/MediaWidget.js +2 -2
  57. package/esm/components/MediaWidget/MediaWidget.js.map +1 -1
  58. package/esm/components/MemoriWidget/MemoriWidget.js +32 -3
  59. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  60. package/esm/components/layouts/flows/FlowWidget.js +2 -2
  61. package/esm/components/layouts/flows/FlowWidget.js.map +1 -1
  62. package/esm/helpers/constants.d.ts +1 -0
  63. package/esm/helpers/constants.js +1 -0
  64. package/esm/helpers/constants.js.map +1 -1
  65. package/esm/index.js +1 -6
  66. package/esm/index.js.map +1 -1
  67. package/esm/locales/de.json +75 -0
  68. package/esm/locales/en.json +75 -0
  69. package/esm/locales/es.json +75 -0
  70. package/esm/locales/fr.json +75 -0
  71. package/esm/locales/it.json +75 -0
  72. package/esm/styles.css +1 -1
  73. package/esm/types/instructionProposal.d.ts +64 -0
  74. package/esm/types/instructionProposal.js +2 -0
  75. package/esm/types/instructionProposal.js.map +1 -0
  76. package/esm/version.d.ts +1 -1
  77. package/esm/version.js +1 -1
  78. package/package.json +3 -3
@@ -5,5 +5,5 @@ export type IconButtonProps = Omit<React.ComponentProps<typeof Button>, 'variant
5
5
  recording?: boolean;
6
6
  variant?: React.ComponentProps<typeof Button>['variant'];
7
7
  };
8
- declare const IconButton: React.ForwardRefExoticComponent<Pick<IconButtonProps, "children" | "form" | "slot" | "style" | "title" | "shape" | "value" | "className" | "name" | "onSubmit" | "role" | "key" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "type" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "focusableWhenDisabled" | "nativeButton" | "render" | "variant" | "size" | "fullWidth" | "loading" | "icon" | "iconPosition" | "shadow" | "active" | "recording" | "danger" | "ariaLabel"> & React.RefAttributes<HTMLButtonElement>>;
8
+ declare const IconButton: React.ForwardRefExoticComponent<Pick<IconButtonProps, "children" | "form" | "slot" | "style" | "title" | "shape" | "name" | "value" | "className" | "onSubmit" | "role" | "key" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "type" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "focusableWhenDisabled" | "nativeButton" | "render" | "variant" | "size" | "fullWidth" | "loading" | "icon" | "iconPosition" | "shadow" | "active" | "recording" | "danger" | "ariaLabel"> & React.RefAttributes<HTMLButtonElement>>;
9
9
  export default IconButton;
@@ -0,0 +1,115 @@
1
+ .memori-instruction-proposal {
2
+ width: 100%;
3
+ max-width: 560px;
4
+ box-sizing: border-box;
5
+ margin-top: var(--memori-spacing-sm);
6
+ color: var(--memori-text-color);
7
+ }
8
+
9
+ /* Title and reason use the title and description of the @memori.ai/ui Card */
10
+ .memori-instruction-proposal--header {
11
+ display: flex;
12
+ flex-direction: column;
13
+ gap: var(--memori-spacing-xs);
14
+ }
15
+
16
+ .memori-instruction-proposal--type {
17
+ color: var(--memori-primary);
18
+ font-size: var(--memori-text-size-sm);
19
+ font-weight: var(--memori-text-weight-medium);
20
+ line-height: var(--memori-text-line-normal);
21
+ }
22
+
23
+ .memori-instruction-proposal--title {
24
+ word-break: break-word;
25
+ }
26
+
27
+ .memori-instruction-proposal--section {
28
+ display: flex;
29
+ flex-direction: column;
30
+ margin-bottom: var(--memori-spacing-sm);
31
+ gap: var(--memori-spacing-xs);
32
+ }
33
+
34
+ .memori-instruction-proposal--label {
35
+ color: var(--memori-neutral);
36
+ font-size: var(--memori-text-size-sm);
37
+ font-weight: var(--memori-text-weight-medium);
38
+ line-height: var(--memori-text-line-normal);
39
+ }
40
+
41
+ .memori-instruction-proposal--text {
42
+ margin: 0;
43
+ font-size: var(--memori-text-size-sm);
44
+ line-height: var(--memori-text-line-normal);
45
+ white-space: pre-wrap;
46
+ word-break: break-word;
47
+ }
48
+
49
+ .memori-instruction-proposal--removed,
50
+ .memori-instruction-proposal--added {
51
+ padding: 0 2px;
52
+ border-radius: var(--memori-radius-xs);
53
+ }
54
+
55
+ .memori-instruction-proposal--removed {
56
+ color: var(--memori-neutral);
57
+ text-decoration: line-through;
58
+ }
59
+
60
+ .memori-instruction-proposal--added {
61
+ background: color-mix(in oklch, var(--memori-success) 22%, transparent);
62
+ text-decoration: none;
63
+ }
64
+
65
+ .memori-instruction-proposal--list {
66
+ padding-left: var(--memori-spacing-md);
67
+ margin: 0;
68
+ font-size: var(--memori-text-size-sm);
69
+ }
70
+
71
+ .memori-instruction-proposal--form {
72
+ display: flex;
73
+ flex-direction: column;
74
+ margin-top: var(--memori-spacing-sm);
75
+ gap: var(--memori-spacing-sm);
76
+ }
77
+
78
+ .memori-instruction-proposal--form p {
79
+ margin-top: 0;
80
+ }
81
+
82
+ .memori-instruction-proposal--status {
83
+ padding-top: var(--memori-spacing-sm);
84
+ border-top: var(--memori-border) solid var(--memori-border-color);
85
+ margin: var(--memori-spacing-md) 0 0;
86
+ font-size: var(--memori-text-size-sm);
87
+ font-weight: var(--memori-text-weight-medium);
88
+ }
89
+
90
+ .memori-instruction-proposal--ignored .memori-instruction-proposal--status,
91
+ .memori-instruction-proposal--notPending .memori-instruction-proposal--status {
92
+ color: var(--memori-neutral);
93
+ }
94
+
95
+ .memori-instruction-proposal--error .memori-instruction-proposal--status {
96
+ color: var(--memori-error-text);
97
+ }
98
+
99
+ .memori-instruction-proposal--actions {
100
+ display: flex;
101
+ flex-wrap: wrap;
102
+ margin-top: var(--memori-spacing-md);
103
+ gap: var(--memori-spacing-sm);
104
+ }
105
+
106
+ .memori-instruction-proposal--hint {
107
+ margin: var(--memori-spacing-xs) 0 0;
108
+ color: var(--memori-neutral);
109
+ font-size: var(--memori-text-size-sm);
110
+ }
111
+
112
+ .memori-instruction-proposal--timezone {
113
+ color: var(--memori-neutral);
114
+ white-space: nowrap;
115
+ }
@@ -0,0 +1,31 @@
1
+ import { Medium } from '@memori.ai/memori-api-client/dist/types';
2
+ import { InstructionConnectorField, InstructionProposal, InstructionProposalConfirm } from '../../types/instructionProposal';
3
+ export type InstructionProposalStatus = 'pending' | 'sending' | 'applied' | 'ignored' | 'notPending' | 'error';
4
+ export interface Props {
5
+ medium: Medium;
6
+ onConfirm?: InstructionProposalConfirm;
7
+ defaultStatus?: InstructionProposalStatus;
8
+ proposalsPending?: boolean;
9
+ expired?: boolean;
10
+ }
11
+ export declare const parseInstructionProposal: (medium: Medium) => InstructionProposal | null;
12
+ export declare const hasInstructionProposalCard: (medium: Medium) => boolean;
13
+ export declare const getMissingConnectorFields: (fields: InstructionConnectorField[], values: {
14
+ [key: string]: string;
15
+ }) => InstructionConnectorField[];
16
+ export type ScheduleDescription = {
17
+ key: string;
18
+ values: {
19
+ [key: string]: string;
20
+ };
21
+ };
22
+ export declare const describeCron: (cron: string, language?: string) => ScheduleDescription | null;
23
+ export declare const formatRunAt: (runAt: string, language?: string) => string;
24
+ export type WordDiffPart = {
25
+ text: string;
26
+ added?: boolean;
27
+ removed?: boolean;
28
+ };
29
+ export declare const diffWords: (before: string, after: string) => WordDiffPart[] | null;
30
+ declare const InstructionProposalCard: ({ medium, onConfirm, defaultStatus, proposalsPending, expired, }: Props) => JSX.Element | null;
31
+ export default InstructionProposalCard;
@@ -0,0 +1,278 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useRef, useState } from 'react';
3
+ import { Button, Card, Expandable, FieldGroup, Input } from '@memori.ai/ui';
4
+ import { useTranslation } from 'react-i18next';
5
+ import cx from 'classnames';
6
+ export const parseInstructionProposal = (medium) => {
7
+ var _a;
8
+ try {
9
+ const proposal = JSON.parse((_a = medium.content) !== null && _a !== void 0 ? _a : '');
10
+ return (proposal === null || proposal === void 0 ? void 0 : proposal.id) && (proposal === null || proposal === void 0 ? void 0 : proposal.type) ? proposal : null;
11
+ }
12
+ catch (_b) {
13
+ return null;
14
+ }
15
+ };
16
+ const CARD_PROPOSAL_TYPES = [
17
+ 'NewContent',
18
+ 'ContentVariants',
19
+ 'ContentAnswerChange',
20
+ 'PromptChange',
21
+ 'PromptRevert',
22
+ 'AttachmentPlacement',
23
+ 'Snippet',
24
+ 'LandingPage',
25
+ 'Connector',
26
+ 'ScheduledTask',
27
+ ];
28
+ export const hasInstructionProposalCard = (medium) => {
29
+ const proposal = parseInstructionProposal(medium);
30
+ return !!proposal && CARD_PROPOSAL_TYPES.includes(proposal.type);
31
+ };
32
+ export const getMissingConnectorFields = (fields, values) => fields.filter(f => { var _a; return f.required && !((_a = values[f.name]) === null || _a === void 0 ? void 0 : _a.trim()); });
33
+ export const describeCron = (cron, language) => {
34
+ const [minute, hour, day, month, weekday, ...rest] = cron.trim().split(/\s+/);
35
+ if (rest.length > 0 ||
36
+ month !== '*' ||
37
+ !/^\d{1,2}$/.test(minute !== null && minute !== void 0 ? minute : '') ||
38
+ !/^\d{1,2}$/.test(hour !== null && hour !== void 0 ? hour : ''))
39
+ return null;
40
+ const time = `${hour.padStart(2, '0')}:${minute.padStart(2, '0')}`;
41
+ if (day === '*' && weekday === '*')
42
+ return { key: 'scheduleDaily', values: { time } };
43
+ if (day === '*' && weekday === '1-5')
44
+ return { key: 'scheduleWeekdays', values: { time } };
45
+ if (day === '*' && /^[0-7]$/.test(weekday !== null && weekday !== void 0 ? weekday : '')) {
46
+ const date = new Date(2024, 0, 7 + (Number(weekday) % 7));
47
+ const name = new Intl.DateTimeFormat(language, { weekday: 'long' }).format(date);
48
+ return { key: 'scheduleWeekly', values: { time, day: name } };
49
+ }
50
+ if (/^\d{1,2}$/.test(day !== null && day !== void 0 ? day : '') && weekday === '*')
51
+ return { key: 'scheduleMonthly', values: { time, day } };
52
+ return null;
53
+ };
54
+ export const formatRunAt = (runAt, language) => {
55
+ const match = /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})$/.exec(runAt);
56
+ if (!match)
57
+ return runAt;
58
+ const [, year, month, day, hour, minute] = match.map(Number);
59
+ return new Intl.DateTimeFormat(language, {
60
+ dateStyle: 'full',
61
+ timeStyle: 'short',
62
+ }).format(new Date(year, month - 1, day, hour, minute));
63
+ };
64
+ const MAX_WORD_DIFF_PAIRS = 250000;
65
+ export const diffWords = (before, after) => {
66
+ const a = before.split(/(\s+)/).filter(x => x.length > 0);
67
+ const b = after.split(/(\s+)/).filter(x => x.length > 0);
68
+ if (a.length * b.length > MAX_WORD_DIFF_PAIRS)
69
+ return null;
70
+ const lcs = Array.from({ length: a.length + 1 }, () => new Array(b.length + 1).fill(0));
71
+ for (let i = a.length - 1; i >= 0; i--)
72
+ for (let j = b.length - 1; j >= 0; j--)
73
+ lcs[i][j] =
74
+ a[i] === b[j]
75
+ ? lcs[i + 1][j + 1] + 1
76
+ : Math.max(lcs[i + 1][j], lcs[i][j + 1]);
77
+ const parts = [];
78
+ const add = (text, kind) => {
79
+ const last = parts[parts.length - 1];
80
+ const lastKind = !last
81
+ ? null
82
+ : last.added
83
+ ? 'added'
84
+ : last.removed
85
+ ? 'removed'
86
+ : 'same';
87
+ if (last && lastKind === kind)
88
+ last.text += text;
89
+ else
90
+ parts.push({
91
+ text,
92
+ ...(kind === 'added' ? { added: true } : {}),
93
+ ...(kind === 'removed' ? { removed: true } : {}),
94
+ });
95
+ };
96
+ let i = 0;
97
+ let j = 0;
98
+ while (i < a.length && j < b.length) {
99
+ if (a[i] === b[j]) {
100
+ add(a[i], 'same');
101
+ i++;
102
+ j++;
103
+ }
104
+ else if (lcs[i + 1][j] >= lcs[i][j + 1])
105
+ add(a[i++], 'removed');
106
+ else
107
+ add(b[j++], 'added');
108
+ }
109
+ while (i < a.length)
110
+ add(a[i++], 'removed');
111
+ while (j < b.length)
112
+ add(b[j++], 'added');
113
+ return parts;
114
+ };
115
+ const InstructionProposalCard = ({ medium, onConfirm, defaultStatus = 'pending', proposalsPending = true, expired = false, }) => {
116
+ var _a;
117
+ const { t, i18n } = useTranslation();
118
+ const proposal = useMemo(() => parseInstructionProposal(medium), [medium]);
119
+ const [status, setStatus] = useState(() => expired && !!onConfirm && defaultStatus === 'pending'
120
+ ? 'notPending'
121
+ : defaultStatus);
122
+ const [lastAction, setLastAction] = useState(true);
123
+ const wasPending = useRef(proposalsPending);
124
+ useEffect(() => {
125
+ if (!!onConfirm && (expired || (wasPending.current && !proposalsPending)))
126
+ setStatus(s => (s === 'pending' || s === 'error' ? 'notPending' : s));
127
+ wasPending.current = proposalsPending;
128
+ }, [proposalsPending, expired, onConfirm]);
129
+ const answerDiff = useMemo(() => {
130
+ var _a;
131
+ return (proposal === null || proposal === void 0 ? void 0 : proposal.type) === 'ContentAnswerChange' && !!proposal.baseAnswer
132
+ ? diffWords(proposal.baseAnswer, (_a = proposal.answer) !== null && _a !== void 0 ? _a : '')
133
+ : null;
134
+ }, [proposal]);
135
+ const fields = (_a = proposal === null || proposal === void 0 ? void 0 : proposal.connectorFields) !== null && _a !== void 0 ? _a : [];
136
+ const [values, setValues] = useState(() => fields.reduce((acc, f) => {
137
+ var _a, _b;
138
+ return ({
139
+ ...acc,
140
+ [f.name]: f.secret ? '' : (_b = (_a = proposal === null || proposal === void 0 ? void 0 : proposal.connectorParameters) === null || _a === void 0 ? void 0 : _a[f.name]) !== null && _b !== void 0 ? _b : '',
141
+ });
142
+ }, {}));
143
+ if (!proposal)
144
+ return null;
145
+ const isConnector = proposal.type === 'Connector';
146
+ const isScheduledTask = proposal.type === 'ScheduledTask';
147
+ const missingFields = getMissingConnectorFields(fields, values);
148
+ const canAct = !!onConfirm && (status === 'pending' || status === 'error');
149
+ const confirm = async (apply) => {
150
+ if (!onConfirm)
151
+ return;
152
+ setLastAction(apply);
153
+ setStatus('sending');
154
+ const parameters = apply && isConnector
155
+ ? Object.fromEntries(Object.entries(values)
156
+ .map(([name, value]) => [name, value.trim()])
157
+ .filter(([, value]) => value.length > 0))
158
+ : undefined;
159
+ const clearSecrets = () => setValues(v => Object.fromEntries(Object.entries(v).map(([name, value]) => {
160
+ var _a;
161
+ return [
162
+ name,
163
+ ((_a = fields.find(f => f.name === name)) === null || _a === void 0 ? void 0 : _a.secret) ? '' : value,
164
+ ];
165
+ })));
166
+ try {
167
+ const handled = await onConfirm(proposal.id, apply, parameters && Object.keys(parameters).length > 0
168
+ ? parameters
169
+ : undefined);
170
+ clearSecrets();
171
+ setStatus(handled ? (apply ? 'applied' : 'ignored') : 'notPending');
172
+ }
173
+ catch (_a) {
174
+ setStatus('error');
175
+ }
176
+ };
177
+ const renderText = (label, text) => !!(text === null || text === void 0 ? void 0 : text.length) && (_jsxs("div", { className: "memori-instruction-proposal--section", children: [_jsx("span", { className: "memori-instruction-proposal--label", children: label }), _jsx("p", { className: "memori-instruction-proposal--text", children: text })] }));
178
+ const renderChange = (label, text, previousText) => text === undefined || text === null ? null : !previousText ||
179
+ previousText === text ? (renderText(label, text)) : (_jsxs("div", { className: "memori-instruction-proposal--section", children: [_jsx("span", { className: "memori-instruction-proposal--label", children: label }), _jsxs("p", { className: "memori-instruction-proposal--text", children: [_jsx("del", { className: "memori-instruction-proposal--removed", children: previousText }), !!text && (_jsxs(_Fragment, { children: [' ', _jsx("ins", { className: "memori-instruction-proposal--added", children: text })] }))] })] }));
180
+ const renderSettingValue = (value) => value === 'true'
181
+ ? t('instructionProposal.settingOn')
182
+ : value === 'false'
183
+ ? t('instructionProposal.settingOff')
184
+ : value;
185
+ const describeSchedule = () => {
186
+ if (proposal.scheduledTaskRunAt)
187
+ return t('instructionProposal.scheduleOnce', {
188
+ date: formatRunAt(proposal.scheduledTaskRunAt, i18n === null || i18n === void 0 ? void 0 : i18n.language),
189
+ });
190
+ if (!proposal.scheduledTaskCron)
191
+ return undefined;
192
+ const description = describeCron(proposal.scheduledTaskCron, i18n === null || i18n === void 0 ? void 0 : i18n.language);
193
+ return description
194
+ ? t(`instructionProposal.${description.key}`, description.values)
195
+ : proposal.scheduledTaskCron;
196
+ };
197
+ const renderVariants = () => {
198
+ var _a;
199
+ return !!((_a = proposal.variants) === null || _a === void 0 ? void 0 : _a.length) && (_jsxs("div", { className: "memori-instruction-proposal--section", children: [_jsx("span", { className: "memori-instruction-proposal--label", children: t('instructionProposal.variants') }), _jsx("ul", { className: "memori-instruction-proposal--list", children: proposal.variants.map((v, index) => (_jsx("li", { children: v }, `${index}-${v}`))) })] }));
200
+ };
201
+ const renderBody = () => {
202
+ var _a, _b, _c, _d, _e;
203
+ switch (proposal.type) {
204
+ case 'NewContent':
205
+ case 'ContentVariants':
206
+ return (_jsxs(_Fragment, { children: [renderText(t('instructionProposal.question'), proposal.question), renderText(t('instructionProposal.answer'), proposal.answer), renderVariants()] }));
207
+ case 'ContentAnswerChange':
208
+ return (_jsxs(_Fragment, { children: [renderText(t('instructionProposal.question'), proposal.question), _jsxs("div", { className: "memori-instruction-proposal--section", children: [_jsx("span", { className: "memori-instruction-proposal--label", children: t('instructionProposal.answer') }), answerDiff ? (_jsx("p", { className: "memori-instruction-proposal--text", children: answerDiff.map((part, index) => part.removed ? (_jsx("del", { className: "memori-instruction-proposal--removed", children: part.text }, index)) : part.added ? (_jsx("ins", { className: "memori-instruction-proposal--added", children: part.text }, index)) : (_jsx("span", { children: part.text }, index))) })) : (_jsxs(_Fragment, { children: [!!proposal.baseAnswer && (_jsx("del", { className: "memori-instruction-proposal--text memori-instruction-proposal--removed", children: proposal.baseAnswer })), _jsx("ins", { className: "memori-instruction-proposal--text memori-instruction-proposal--added", children: proposal.answer })] }))] })] }));
209
+ case 'PromptChange':
210
+ return (_jsxs("div", { className: "memori-instruction-proposal--section", children: [_jsx("span", { className: "memori-instruction-proposal--label", children: t('instructionProposal.prompt') }), _jsx(Expandable, { rows: 6, children: _jsx("p", { className: "memori-instruction-proposal--text", children: proposal.prompt }) })] }));
211
+ case 'PromptRevert':
212
+ return (_jsxs(_Fragment, { children: [_jsx("p", { className: "memori-instruction-proposal--text", children: t('instructionProposal.promptRevert') }), !!proposal.prompt && (_jsxs("div", { className: "memori-instruction-proposal--section", children: [_jsx("span", { className: "memori-instruction-proposal--label", children: t('instructionProposal.restoredPrompt') }), _jsx(Expandable, { rows: 6, children: _jsx("p", { className: "memori-instruction-proposal--text", children: proposal.prompt }) })] }))] }));
213
+ case 'AttachmentPlacement':
214
+ return (_jsxs(_Fragment, { children: [renderText(t('instructionProposal.attachment'), proposal.attachmentName), renderText(t('instructionProposal.documentTitle'), proposal.documentTitle)] }));
215
+ case 'Snippet':
216
+ return (_jsxs(_Fragment, { children: [renderText(t('instructionProposal.question'), proposal.question), renderText(t('instructionProposal.answer'), proposal.answer), renderVariants(), renderText(t('instructionProposal.snippet'), proposal.snippetTemplate), renderText(t('instructionProposal.snippetTitle'), (_a = proposal.snippetParameters) === null || _a === void 0 ? void 0 : _a.title), renderText(t('instructionProposal.snippetText'), (_b = proposal.snippetParameters) === null || _b === void 0 ? void 0 : _b.text), renderText(t('instructionProposal.snippetSubmitLabel'), (_c = proposal.snippetParameters) === null || _c === void 0 ? void 0 : _c.submit_label), renderText(t('instructionProposal.snippetSelector'), (_d = proposal.snippetParameters) === null || _d === void 0 ? void 0 : _d.selector), !!((_e = proposal.snippetFields) === null || _e === void 0 ? void 0 : _e.length) && (_jsxs("div", { className: "memori-instruction-proposal--section", children: [_jsx("span", { className: "memori-instruction-proposal--label", children: t('instructionProposal.snippetFields') }), _jsx("ul", { className: "memori-instruction-proposal--list", children: proposal.snippetFields.map(f => (_jsx("li", { children: f.label || f.name }, f.name))) })] }))] }));
217
+ case 'LandingPage':
218
+ return (_jsxs(_Fragment, { children: [renderChange(t('instructionProposal.layout'), proposal.landingPageLayout, proposal.previousLandingPageLayout), renderChange(t('instructionProposal.initialQuestion'), proposal.initialQuestion, proposal.previousInitialQuestion), !!proposal.landingPageSettings &&
219
+ Object.keys(proposal.landingPageSettings).length > 0 && (_jsxs("div", { className: "memori-instruction-proposal--section", children: [_jsx("span", { className: "memori-instruction-proposal--label", children: t('instructionProposal.pageSettings') }), _jsx("ul", { className: "memori-instruction-proposal--list", children: Object.entries(proposal.landingPageSettings).map(([name, value]) => {
220
+ var _a;
221
+ const previousValue = (_a = proposal.previousLandingPageSettings) === null || _a === void 0 ? void 0 : _a[name];
222
+ return (_jsxs("li", { children: [t(`instructionProposal.pageSettingNames.${name}`, {
223
+ defaultValue: name,
224
+ }), ":", ' ', !!previousValue && (_jsxs(_Fragment, { children: [_jsx("del", { className: "memori-instruction-proposal--removed", children: renderSettingValue(previousValue) }), ' '] })), _jsx("ins", { className: "memori-instruction-proposal--added", children: renderSettingValue(value) })] }, name));
225
+ }) })] }))] }));
226
+ case 'Connector':
227
+ return (_jsxs(_Fragment, { children: [!!proposal.connectorDescription && (_jsx("p", { className: "memori-instruction-proposal--text", children: proposal.connectorDescription })), fields.length > 0 && (_jsx("form", { className: "memori-instruction-proposal--form", autoComplete: "off", onSubmit: e => {
228
+ e.preventDefault();
229
+ if (canAct && missingFields.length === 0)
230
+ confirm(true);
231
+ }, children: fields.map(f => {
232
+ var _a;
233
+ return (_jsx(FieldGroup, { label: f.name, helperText: f.secret
234
+ ? [f.description, t('instructionProposal.secretField')]
235
+ .filter(Boolean)
236
+ .join(' ')
237
+ : f.description, required: f.required, children: _jsx(Input, { name: f.name, type: f.secret ? 'password' : 'text', autoComplete: f.secret ? 'new-password' : 'off', placeholder: f.secret ? undefined : f.example, value: (_a = values[f.name]) !== null && _a !== void 0 ? _a : '', disabled: !canAct, fullWidth: true, onChange: (e) => setValues(v => ({ ...v, [f.name]: e.target.value })) }) }, f.name));
238
+ }) }))] }));
239
+ case 'ScheduledTask':
240
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "memori-instruction-proposal--section", children: [_jsx("span", { className: "memori-instruction-proposal--label", children: t('instructionProposal.taskWhen') }), _jsxs("p", { className: "memori-instruction-proposal--text", children: [describeSchedule(), !!proposal.scheduledTaskTimezone && (_jsxs("span", { className: "memori-instruction-proposal--timezone", children: [' · ', t('instructionProposal.timezone', {
241
+ timezone: proposal.scheduledTaskTimezone,
242
+ })] }))] })] }), _jsxs("div", { className: "memori-instruction-proposal--section", children: [_jsx("span", { className: "memori-instruction-proposal--label", children: t('instructionProposal.taskPrompt') }), _jsx(Expandable, { rows: 6, children: _jsx("p", { className: "memori-instruction-proposal--text", children: proposal.scheduledTaskPrompt }) })] })] }));
243
+ default:
244
+ return null;
245
+ }
246
+ };
247
+ const renderStatus = () => {
248
+ switch (status) {
249
+ case 'applied':
250
+ return t(isConnector
251
+ ? 'instructionProposal.linked'
252
+ : isScheduledTask
253
+ ? 'instructionProposal.scheduled'
254
+ : 'instructionProposal.applied');
255
+ case 'ignored':
256
+ return t('instructionProposal.ignored');
257
+ case 'notPending':
258
+ return t('instructionProposal.notPending');
259
+ case 'error':
260
+ return t('instructionProposal.error');
261
+ default:
262
+ return null;
263
+ }
264
+ };
265
+ const statusText = renderStatus();
266
+ return (_jsxs(Card, { variant: "outlined", padding: "md", className: cx('memori-instruction-proposal', `memori-instruction-proposal--${status}`), title: _jsxs("span", { className: "memori-instruction-proposal--header", children: [_jsx("span", { className: "memori-instruction-proposal--type", children: t(`instructionProposal.types.${proposal.type}`) }), !!medium.title && (_jsx("span", { className: "memori-instruction-proposal--title", children: medium.title }))] }), description: proposal.reason || undefined, children: [renderBody(), !!statusText && (_jsx("p", { className: "memori-instruction-proposal--status", role: status === 'error' ? 'alert' : 'status', children: statusText })), !!onConfirm &&
267
+ (status === 'pending' ||
268
+ status === 'sending' ||
269
+ status === 'error') && (_jsxs("div", { className: "memori-instruction-proposal--actions", children: [_jsx(Button, { variant: "primary", size: "sm", disabled: !canAct || missingFields.length > 0, loading: status === 'sending' && lastAction, onClick: () => confirm(true), children: t(isConnector
270
+ ? 'instructionProposal.link'
271
+ : isScheduledTask
272
+ ? 'instructionProposal.schedule'
273
+ : 'instructionProposal.apply') }), _jsx(Button, { variant: "outline", size: "sm", disabled: !canAct, loading: status === 'sending' && !lastAction, onClick: () => confirm(false), children: t('instructionProposal.ignore') })] })), canAct && isConnector && missingFields.length > 0 && (_jsx("p", { className: "memori-instruction-proposal--hint", children: t('instructionProposal.fillRequired', {
274
+ fields: missingFields.map(f => f.name).join(', '),
275
+ }) }))] }));
276
+ };
277
+ export default InstructionProposalCard;
278
+ //# sourceMappingURL=InstructionProposalCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InstructionProposalCard.js","sourceRoot":"","sources":["../../../src/components/InstructionProposalCard/InstructionProposalCard.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,MAAM,YAAY,CAAC;AA0B5B,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,MAAc,EACc,EAAE;;IAC9B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC;QAClD,OAAO,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,EAAE,MAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAA,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1D,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAIF,MAAM,mBAAmB,GAAkC;IACzD,YAAY;IACZ,iBAAiB;IACjB,qBAAqB;IACrB,cAAc;IACd,cAAc;IACd,qBAAqB;IACrB,SAAS;IACT,aAAa;IACb,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CAAC,EAC7C,OAAO,EAAE,MAAM,KAAK,SAAS,IAAI,UAAU,EAC3C,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,YAE3B,CAAC,CACA,WAAW;4BACT,CAAC,CAAC,0BAA0B;4BAC5B,CAAC,CAAC,eAAe;gCACjB,CAAC,CAAC,8BAA8B;gCAChC,CAAC,CAAC,2BAA2B,CAChC,GACM,EACT,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,IAAI,EACT,QAAQ,EAAE,CAAC,MAAM,EACjB,OAAO,EAAE,MAAM,KAAK,SAAS,IAAI,CAAC,UAAU,EAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,YAE5B,CAAC,CAAC,4BAA4B,CAAC,GACzB,IACL,CACP,EACF,MAAM,IAAI,WAAW,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,CACpD,YAAG,SAAS,EAAC,mCAAmC,YAC7C,CAAC,CAAC,kCAAkC,EAAE;oBACrC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;iBAClD,CAAC,GACA,CACL,IACI,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
@@ -575,6 +575,12 @@ div.memori-media-item--link:focus-visible {
575
575
  max-width: 100%;
576
576
  }
577
577
 
578
+ .memori-media-items--grid .memori-media-item:has(.memori-instruction-proposal) {
579
+ width: 100%;
580
+ min-width: 0;
581
+ max-width: 100%;
582
+ }
583
+
578
584
  .memori-media-items--grid .memori-media-item--snippet-direct {
579
585
  max-width: none;
580
586
  }
@@ -3,9 +3,10 @@ import { useCallback, useEffect, useMemo, useState, memo, useRef, } from 'react'
3
3
  import { getResourceUrl } from '../../helpers/media';
4
4
  import { stripHTML, stripDocumentAttachmentTags, isAssetOnlyDocumentAttachment, getDocumentAttachmentAssetUrl, } from '../../helpers/utils';
5
5
  import { getTranslation } from '../../helpers/translations';
6
- import { prismSyntaxLangs } from '../../helpers/constants';
6
+ import { INSTRUCTION_PROPOSAL_MIME_TYPE, prismSyntaxLangs, } from '../../helpers/constants';
7
7
  import ModelViewer from '../CustomGLBModelViewer/ModelViewer';
8
8
  import Snippet from '../Snippet/Snippet';
9
+ import InstructionProposalCard, { hasInstructionProposalCard, } from '../InstructionProposalCard/InstructionProposalCard';
9
10
  import { Card } from '@memori.ai/ui';
10
11
  import { File, Volume2, Link as LinkIcon } from 'lucide-react';
11
12
  import cx from 'classnames';
@@ -302,7 +303,7 @@ export const RenderSnippetItem = memo(function RenderSnippetItem({ item, onClick
302
303
  }
303
304
  }, className: "memori-media-item--link", title: item.title, children: _jsx(Card, { hoverable: true, className: "memori-media-item--card memori-media-item--snippet", children: _jsxs("div", { className: "memori-media-item--snippet-body", children: [_jsx("div", { className: "memori-media-item--snippet-title", children: item.title }), _jsx("div", { className: "memori-media-item--snippet-preview", children: _jsx(Snippet, { showCopyButton: false, preview: true, medium: item }) }), _jsx("div", { className: "memori-media-item--snippet-header", children: _jsx("span", { className: "memori-media-item--snippet-meta", children: lineText }) })] }) }) }));
304
305
  });
305
- const MediaItemWidget = ({ items, sessionID, tenantID, translateTo, baseURL, apiURL, customMediaRenderer, fromUser = false, descriptionOneLine = false, onLinkPreviewInfo, }) => {
306
+ const MediaItemWidget = ({ items, sessionID, tenantID, translateTo, baseURL, apiURL, customMediaRenderer, onProposalConfirm, proposalsPending = true, proposalsExpired = false, proposalStatuses, fromUser = false, descriptionOneLine = false, onLinkPreviewInfo, }) => {
306
307
  const [media, setMedia] = useState(items);
307
308
  const [openModalMedium, setOpenModalMedium] = useState();
308
309
  useEffect(() => {
@@ -330,15 +331,23 @@ const MediaItemWidget = ({ items, sessionID, tenantID, translateTo, baseURL, api
330
331
  if (translateTo)
331
332
  translateMediaCaptions();
332
333
  }, [translateTo, translateMediaCaptions]);
334
+ const rendersProposalsItself = useMemo(() => !!(customMediaRenderer === null || customMediaRenderer === void 0 ? void 0 : customMediaRenderer(INSTRUCTION_PROPOSAL_MIME_TYPE)), [customMediaRenderer]);
335
+ const isInstructionProposal = useCallback((m) => m.mimeType === INSTRUCTION_PROPOSAL_MIME_TYPE && !rendersProposalsItself, [rendersProposalsItself]);
333
336
  const nonCodeDisplayMedia = useMemo(() => media
334
- .filter(m => { var _a; return !((_a = m.properties) === null || _a === void 0 ? void 0 : _a.executable) && !CODE_MIME_TYPES.includes(m.mimeType); })
337
+ .filter(m => {
338
+ var _a;
339
+ return !((_a = m.properties) === null || _a === void 0 ? void 0 : _a.executable) &&
340
+ !CODE_MIME_TYPES.includes(m.mimeType) &&
341
+ !isInstructionProposal(m);
342
+ })
335
343
  .sort((a, b) => {
336
344
  var _a, _b;
337
345
  const at = (_a = a.creationTimestamp) !== null && _a !== void 0 ? _a : 0;
338
346
  const bt = (_b = b.creationTimestamp) !== null && _b !== void 0 ? _b : 0;
339
347
  return at > bt ? 1 : at < bt ? -1 : 0;
340
- }), [media]);
348
+ }), [media, isInstructionProposal]);
341
349
  const codeSnippets = useMemo(() => media.filter(m => { var _a; return !((_a = m.properties) === null || _a === void 0 ? void 0 : _a.executable) && CODE_MIME_TYPES.includes(m.mimeType); }), [media]);
350
+ const instructionProposals = useMemo(() => media.filter(m => isInstructionProposal(m) && hasInstructionProposalCard(m)), [media, isInstructionProposal]);
342
351
  const cssExecutableCode = useMemo(() => media.filter(m => { var _a; return m.mimeType === 'text/css' && !!((_a = m.properties) === null || _a === void 0 ? void 0 : _a.executable); }), [media]);
343
352
  const tileCount = nonCodeDisplayMedia.length;
344
353
  const handleMediaItemClick = useCallback((item) => {
@@ -380,7 +389,10 @@ const MediaItemWidget = ({ items, sessionID, tenantID, translateTo, baseURL, api
380
389
  content: item.content,
381
390
  type: 'document',
382
391
  } }) }, `snippet-${index}-${(_b = (_a = item.mediumID) !== null && _a !== void 0 ? _a : item.url) !== null && _b !== void 0 ? _b : 'n'}`));
383
- }) })), cssExecutableCode.map(m => (_jsx("style", { dangerouslySetInnerHTML: { __html: m.content || '' } }, m.mediumID))), openModalMedium && (_jsx(MediaPreviewModal, { medium: openModalMedium, onClose: handleCloseModal, sessionID: sessionID, tenantID: tenantID, baseURL: baseURL, apiURL: apiURL, customMediaRenderer: customMediaRenderer, descriptionOneLine: descriptionOneLine, onLinkPreviewInfo: onLinkPreviewInfo, onMediumClick: handleModalNavigate }))] }));
392
+ }) })), instructionProposals.length > 0 && (_jsx("div", { className: cx('memori-media-items--grid memori-chat-scroll-item', {
393
+ 'memori-media-items--user': fromUser,
394
+ 'memori-media-items--agent': !fromUser,
395
+ }), children: instructionProposals.map(item => (_jsx("div", { className: "memori-media-item", children: _jsx(InstructionProposalCard, { medium: item, onConfirm: onProposalConfirm, proposalsPending: proposalsPending, expired: proposalsExpired, defaultStatus: proposalStatuses === null || proposalStatuses === void 0 ? void 0 : proposalStatuses[item.mediumID] }) }, item.mediumID))) })), cssExecutableCode.map(m => (_jsx("style", { dangerouslySetInnerHTML: { __html: m.content || '' } }, m.mediumID))), openModalMedium && (_jsx(MediaPreviewModal, { medium: openModalMedium, onClose: handleCloseModal, sessionID: sessionID, tenantID: tenantID, baseURL: baseURL, apiURL: apiURL, customMediaRenderer: customMediaRenderer, descriptionOneLine: descriptionOneLine, onLinkPreviewInfo: onLinkPreviewInfo, onMediumClick: handleModalNavigate }))] }));
384
396
  };
385
397
  export default memo(MediaItemWidget);
386
398
  //# sourceMappingURL=MediaItemWidget.js.map